hgbook

view po/zh.po @ 660:f7add9f718a8

Update Chinese translation
author Dongsheng Song <dongsheng.song@gmail.com>
date Tue Mar 31 10:02:16 2009 +0800 (2009-03-31)
parents 433040113eaf
children 65b82a891cf7
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-03-30 21:36+0800\n"
45 "PO-Revision-Date: 2009-03-31 10:12+0800\n"
46 "Last-Translator: \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><authorgroup><author><firstname>
66 #: ../en/00book.xml:50
67 msgid "Bryan"
68 msgstr "Bryan"
70 #. type: Content of: <book><bookinfo><authorgroup><author><surname>
71 #: ../en/00book.xml:51
72 msgid "O'Sullivan"
73 msgstr "O'Sullivan"
75 #. type: Content of: <book><bookinfo>
76 #: ../en/00book.xml:55
77 msgid ""
78 "<editor> <firstname>Mike</firstname> <surname>Loukides</surname> </editor> "
79 "<copyright> <year>2006</year> <year>2007</year> <year>2008</year> <year>2009</"
80 "year> <holder>Bryan O'Sullivan</holder> </copyright>"
81 msgstr ""
82 "<editor> <firstname>Mike</firstname> <surname>Loukides</surname> </editor> "
83 "<copyright> <year>2006</year> <year>2007</year> <year>2008</year> <year>2009</"
84 "year> <holder>Bryan O'Sullivan</holder> </copyright>"
86 #. type: Content of: <book><appendix><title>
87 #: ../en/appA-cmdref.xml:5
88 msgid "Command reference"
89 msgstr "命令参考"
91 #. type: Content of: <book><appendix><para>
92 #: ../en/appA-cmdref.xml:7
93 msgid ""
94 "\\cmdref{add}{add files at the next commit} \\optref{add}{I}{include} \\optref"
95 "{add}{X}{exclude} \\optref{add}{n}{dry-run}"
96 msgstr ""
98 #. type: Content of: <book><appendix><para>
99 #: ../en/appA-cmdref.xml:12
100 msgid "\\cmdref{diff}{print changes in history or working directory}"
101 msgstr ""
103 #. type: Content of: <book><appendix><para>
104 #: ../en/appA-cmdref.xml:14
105 msgid ""
106 "Show differences between revisions for the specified files or directories, "
107 "using the unified diff format. For a description of the unified diff format, "
108 "see <xref linkend=\"sec:mq:patch\"/>."
109 msgstr ""
111 #. type: Content of: <book><appendix><para>
112 #: ../en/appA-cmdref.xml:18
113 msgid ""
114 "By default, this command does not print diffs for files that Mercurial "
115 "considers to contain binary data. To control this behaviour, see the <option "
116 "role=\"hg-opt-diff\">-a</option> and <option role=\"hg-opt-diff\">--git</"
117 "option> options."
118 msgstr ""
120 #. type: Content of: <book><appendix><sect2><title>
121 #: ../en/appA-cmdref.xml:23
122 msgid "Options"
123 msgstr "选项"
125 #. type: Content of: <book><appendix><sect2><para>
126 #: ../en/appA-cmdref.xml:25
127 msgid "\\loptref{diff}{nodates}"
128 msgstr ""
130 #. type: Content of: <book><appendix><sect2><para>
131 #: ../en/appA-cmdref.xml:27
132 msgid "Omit date and time information when printing diff headers."
133 msgstr ""
135 #. type: Content of: <book><appendix><sect2><para>
136 #: ../en/appA-cmdref.xml:29
137 msgid "\\optref{diff}{B}{ignore-blank-lines}"
138 msgstr ""
140 #. type: Content of: <book><appendix><sect2><para>
141 #: ../en/appA-cmdref.xml:31
142 msgid ""
143 "Do not print changes that only insert or delete blank lines. A line that "
144 "contains only whitespace is not considered blank."
145 msgstr ""
147 #. type: Content of: <book><appendix><sect2><para>
148 #: ../en/appA-cmdref.xml:35
149 msgid "\\optref{diff}{I}{include}"
150 msgstr ""
152 #. type: Content of: <book><appendix><sect2><para>
153 #: ../en/appA-cmdref.xml:38
154 msgid "Include files and directories whose names match the given patterns."
155 msgstr ""
157 #. type: Content of: <book><appendix><sect2><para>
158 #: ../en/appA-cmdref.xml:41
159 msgid "\\optref{diff}{X}{exclude}"
160 msgstr ""
162 #. type: Content of: <book><appendix><sect2><para>
163 #: ../en/appA-cmdref.xml:44
164 msgid "Exclude files and directories whose names match the given patterns."
165 msgstr ""
167 #. type: Content of: <book><appendix><sect2><para>
168 #: ../en/appA-cmdref.xml:47
169 msgid "\\optref{diff}{a}{text}"
170 msgstr ""
172 #. type: Content of: <book><appendix><sect2><para>
173 #: ../en/appA-cmdref.xml:50
174 msgid ""
175 "If this option is not specified, <command role=\"hg-cmd\">hg diff</command> "
176 "will refuse to print diffs for files that it detects as binary. Specifying "
177 "<option role=\"hg-opt-diff\">-a</option> forces <command role=\"hg-cmd\">hg "
178 "diff</command> to treat all files as text, and generate diffs for all of them."
179 msgstr ""
181 #. type: Content of: <book><appendix><sect2><para>
182 #: ../en/appA-cmdref.xml:56
183 msgid ""
184 "This option is useful for files that are <quote>mostly text</quote> but have "
185 "a few embedded NUL characters. If you use it on files that contain a lot of "
186 "binary data, its output will be incomprehensible."
187 msgstr ""
189 #. type: Content of: <book><appendix><sect2><para>
190 #: ../en/appA-cmdref.xml:61
191 msgid "\\optref{diff}{b}{ignore-space-change}"
192 msgstr ""
194 #. type: Content of: <book><appendix><sect2><para>
195 #: ../en/appA-cmdref.xml:64
196 msgid ""
197 "Do not print a line if the only change to that line is in the amount of white "
198 "space it contains."
199 msgstr ""
201 #. type: Content of: <book><appendix><sect2><para>
202 #: ../en/appA-cmdref.xml:68
203 msgid "\\optref{diff}{g}{git}"
204 msgstr ""
206 #. type: Content of: <book><appendix><sect2><para>
207 #: ../en/appA-cmdref.xml:71
208 msgid ""
209 "Print <command>git</command>-compatible diffs. XXX reference a format "
210 "description."
211 msgstr ""
213 #. type: Content of: <book><appendix><sect2><para>
214 #: ../en/appA-cmdref.xml:75
215 msgid "\\optref{diff}{p}{show-function}"
216 msgstr ""
218 #. type: Content of: <book><appendix><sect2><para>
219 #: ../en/appA-cmdref.xml:78
220 msgid ""
221 "Display the name of the enclosing function in a hunk header, using a simple "
222 "heuristic. This functionality is enabled by default, so the <option role="
223 "\"hg-opt-diff\">-p</option> option has no effect unless you change the value "
224 "of the <envar role=\"rc-item-diff\">showfunc</envar> config item, as in the "
225 "following example."
226 msgstr ""
228 #. type: Content of: <book><appendix><sect2><para>
229 #: ../en/appA-cmdref.xml:85
230 msgid "\\optref{diff}{r}{rev}"
231 msgstr ""
233 #. type: Content of: <book><appendix><sect2><para>
234 #: ../en/appA-cmdref.xml:88
235 msgid ""
236 "Specify one or more revisions to compare. The <command role=\"hg-cmd\">hg "
237 "diff</command> command accepts up to two <option role=\"hg-opt-diff\">-r</"
238 "option> options to specify the revisions to compare."
239 msgstr ""
241 #. type: Content of: <book><appendix><sect2><orderedlist><listitem><para>
242 #: ../en/appA-cmdref.xml:94
243 msgid ""
244 "Display the differences between the parent revision of the working directory "
245 "and the working directory."
246 msgstr ""
248 #. type: Content of: <book><appendix><sect2><orderedlist><listitem><para>
249 #: ../en/appA-cmdref.xml:98
250 msgid ""
251 "Display the differences between the specified changeset and the working "
252 "directory."
253 msgstr ""
255 #. type: Content of: <book><appendix><sect2><orderedlist><listitem><para>
256 #: ../en/appA-cmdref.xml:102
257 msgid "Display the differences between the two specified changesets."
258 msgstr ""
260 #. type: Content of: <book><appendix><sect2><para>
261 #: ../en/appA-cmdref.xml:106
262 msgid ""
263 "You can specify two revisions using either two <option role=\"hg-opt-diff\">-"
264 "r</option> options or revision range notation. For example, the two revision "
265 "specifications below are equivalent."
266 msgstr ""
268 #. type: Content of: <book><appendix><sect2><para>
269 #: ../en/appA-cmdref.xml:113
270 msgid ""
271 "When you provide two revisions, Mercurial treats the order of those revisions "
272 "as significant. Thus, <command role=\"hg-cmd\">hg diff -r10:20</command> "
273 "will produce a diff that will transform files from their contents as of "
274 "revision 10 to their contents as of revision 20, while <command role=\"hg-cmd"
275 "\">hg diff -r20:10</command> means the opposite: the diff that will transform "
276 "files from their revision 20 contents to their revision 10 contents. You "
277 "cannot reverse the ordering in this way if you are diffing against the "
278 "working directory."
279 msgstr ""
281 #. type: Content of: <book><appendix><sect2><para>
282 #: ../en/appA-cmdref.xml:123
283 msgid "\\optref{diff}{w}{ignore-all-space}"
284 msgstr ""
286 #. type: Content of: <book><appendix><sect2><para>
287 #: ../en/appA-cmdref.xml:126
288 msgid "\\cmdref{version}{print version and copyright information}"
289 msgstr ""
291 #. type: Content of: <book><appendix><sect2><para>
292 #: ../en/appA-cmdref.xml:129
293 msgid ""
294 "This command displays the version of Mercurial you are running, and its "
295 "copyright license. There are four kinds of version string that you may see."
296 msgstr ""
298 #. type: Content of: <book><appendix><sect2><itemizedlist><listitem><para>
299 #: ../en/appA-cmdref.xml:134
300 msgid ""
301 "The string <quote><literal>unknown</literal></quote>. This version of "
302 "Mercurial was not built in a Mercurial repository, and cannot determine its "
303 "own version."
304 msgstr ""
306 #. type: Content of: <book><appendix><sect2><itemizedlist><listitem><para>
307 #: ../en/appA-cmdref.xml:139
308 msgid ""
309 "A short numeric string, such as <quote><literal>1.1</literal></quote>. This "
310 "is a build of a revision of Mercurial that was identified by a specific tag "
311 "in the repository where it was built. (This doesn't necessarily mean that "
312 "you're running an official release; someone else could have added that tag to "
313 "any revision in the repository where they built Mercurial.)"
314 msgstr ""
316 #. type: Content of: <book><appendix><sect2><itemizedlist><listitem><para>
317 #: ../en/appA-cmdref.xml:147
318 msgid ""
319 "A hexadecimal string, such as <quote><literal>875489e31abe</literal></"
320 "quote>. This is a build of the given revision of Mercurial."
321 msgstr ""
323 #. type: Content of: <book><appendix><sect2><itemizedlist><listitem><para>
324 #: ../en/appA-cmdref.xml:151
325 msgid ""
326 "A hexadecimal string followed by a date, such as <quote><literal>875489e31abe"
327 "+20070205</literal></quote>. This is a build of the given revision of "
328 "Mercurial, where the build repository contained some local changes that had "
329 "not been committed."
330 msgstr ""
332 #. type: Content of: <book><appendix><sect2><title>
333 #: ../en/appA-cmdref.xml:160
334 msgid "Tips and tricks"
335 msgstr ""
337 #. type: Content of: <book><appendix><sect2><sect3><title>
338 #: ../en/appA-cmdref.xml:163
339 msgid ""
340 "Why do the results of <command role=\"hg-cmd\">hg diff</command> and <command "
341 "role=\"hg-cmd\">hg status</command> differ?"
342 msgstr ""
343 "为什么 <command role=\"hg-cmd\">hg diff</command> 与 <command role=\"hg-cmd"
344 "\">hg status</command> 的结果不同 ?"
346 #. type: Content of: <book><appendix><sect2><sect3><para>
347 #: ../en/appA-cmdref.xml:165
348 msgid ""
349 "When you run the <command role=\"hg-cmd\">hg status</command> command, you'll "
350 "see a list of files that Mercurial will record changes for the next time you "
351 "perform a commit. If you run the <command role=\"hg-cmd\">hg diff</command> "
352 "command, you may notice that it prints diffs for only a <emphasis>subset</"
353 "emphasis> of the files that <command role=\"hg-cmd\">hg status</command> "
354 "listed. There are two possible reasons for this."
355 msgstr ""
357 #. type: Content of: <book><appendix><sect2><sect3><para>
358 #: ../en/appA-cmdref.xml:172
359 msgid ""
360 "The first is that <command role=\"hg-cmd\">hg status</command> prints some "
361 "kinds of modifications that <command role=\"hg-cmd\">hg diff</command> "
362 "doesn't normally display. The <command role=\"hg-cmd\">hg diff</command> "
363 "command normally outputs unified diffs, which don't have the ability to "
364 "represent some changes that Mercurial can track. Most notably, traditional "
365 "diffs can't represent a change in whether or not a file is executable, but "
366 "Mercurial records this information."
367 msgstr ""
369 #. type: Content of: <book><appendix><sect2><sect3><para>
370 #: ../en/appA-cmdref.xml:180
371 msgid ""
372 "If you use the <option role=\"hg-opt-diff\">--git</option> option to <command "
373 "role=\"hg-cmd\">hg diff</command>, it will display <command>git</command>-"
374 "compatible diffs that <emphasis>can</emphasis> display this extra information."
375 msgstr ""
377 #. type: Content of: <book><appendix><sect2><sect3><para>
378 #: ../en/appA-cmdref.xml:185
379 msgid ""
380 "The second possible reason that <command role=\"hg-cmd\">hg diff</command> "
381 "might be printing diffs for a subset of the files displayed by <command role="
382 "\"hg-cmd\">hg status</command> is that if you invoke it without any "
383 "arguments, <command role=\"hg-cmd\">hg diff</command> prints diffs against "
384 "the first parent of the working directory. If you have run <command role="
385 "\"hg-cmd\">hg merge</command> to merge two changesets, but you haven't yet "
386 "committed the results of the merge, your working directory has two parents "
387 "(use <command role=\"hg-cmd\">hg parents</command> to see them). While "
388 "<command role=\"hg-cmd\">hg status</command> prints modifications relative to "
389 "<emphasis>both</emphasis> parents after an uncommitted merge, <command role="
390 "\"hg-cmd\">hg diff</command> still operates relative only to the first "
391 "parent. You can get it to print diffs relative to the second parent by "
392 "specifying that parent with the <option role=\"hg-opt-diff\">-r</option> "
393 "option. There is no way to print diffs relative to both parents."
394 msgstr ""
396 #. type: Content of: <book><appendix><sect2><sect3><title>
397 #: ../en/appA-cmdref.xml:201
398 msgid "Generating safe binary diffs"
399 msgstr "生成安全的二进制差异"
401 #. type: Content of: <book><appendix><sect2><sect3><para>
402 #: ../en/appA-cmdref.xml:203
403 msgid ""
404 "If you use the <option role=\"hg-opt-diff\">-a</option> option to force "
405 "Mercurial to print diffs of files that are either <quote>mostly text</quote> "
406 "or contain lots of binary data, those diffs cannot subsequently be applied by "
407 "either Mercurial's <command role=\"hg-cmd\">hg import</command> command or "
408 "the system's <command>patch</command> command."
409 msgstr ""
411 #. type: Content of: <book><appendix><sect2><sect3><para>
412 #: ../en/appA-cmdref.xml:210
413 msgid ""
414 "If you want to generate a diff of a binary file that is safe to use as input "
415 "for <command role=\"hg-cmd\">hg import</command>, use the <command role=\"hg-"
416 "cmd\">hg diff</command>{--git} option when you generate the patch. The "
417 "system <command>patch</command> command cannot handle binary patches at all."
418 msgstr ""
420 #. type: Content of: <book><appendix><title>
421 #: ../en/appB-mq-ref.xml:5
422 msgid "Mercurial Queues reference"
423 msgstr "Mercurial 队列参考"
425 #. type: Content of: <book><appendix><sect1><title>
426 #: ../en/appB-mq-ref.xml:8
427 msgid "MQ command reference"
428 msgstr "MQ 命令参考"
430 #. type: Content of: <book><appendix><sect1><para>
431 #: ../en/appB-mq-ref.xml:10
432 msgid ""
433 "For an overview of the commands provided by MQ, use the command <command role="
434 "\"hg-cmd\">hg help mq</command>."
435 msgstr ""
437 #. type: Content of: <book><appendix><sect1><sect2><title>
438 #: ../en/appB-mq-ref.xml:14
439 msgid ""
440 "<command role=\"hg-ext-mq\">qapplied</command>&emdash;print applied patches"
441 msgstr "<command role=\"hg-ext-mq\">qapplied</command>&emdash;显示已应用的补丁"
443 #. type: Content of: <book><appendix><sect1><sect2><para>
444 #: ../en/appB-mq-ref.xml:17
445 msgid ""
446 "The <command role=\"hg-ext-mq\">qapplied</command> command prints the current "
447 "stack of applied patches. Patches are printed in oldest-to-newest order, so "
448 "the last patch in the list is the <quote>top</quote> patch."
449 msgstr ""
451 #. type: Content of: <book><appendix><sect1><sect2><title>
452 #: ../en/appB-mq-ref.xml:24
453 msgid ""
454 "<command role=\"hg-ext-mq\">qcommit</command>&emdash;commit changes in the "
455 "queue repository"
456 msgstr "<command role=\"hg-ext-mq\">qcommit</command>&emdash;提交队列中的修改"
458 #. type: Content of: <book><appendix><sect1><sect2><para>
459 #: ../en/appB-mq-ref.xml:27
460 msgid ""
461 "The <command role=\"hg-ext-mq\">qcommit</command> command commits any "
462 "outstanding changes in the <filename role=\"special\" class=\"directory\">.hg/"
463 "patches</filename> repository. This command only works if the <filename role="
464 "\"special\" class=\"directory\">.hg/patches</filename> directory is a "
465 "repository, i.e. you created the directory using <command role=\"hg-cmd\">hg "
466 "qinit <option role=\"hg-ext-mq-cmd-qinit-opt\">-c</option></command> or ran "
467 "<command role=\"hg-cmd\">hg init</command> in the directory after running "
468 "<command role=\"hg-ext-mq\">qinit</command>."
469 msgstr ""
471 #. type: Content of: <book><appendix><sect1><sect2><para>
472 #: ../en/appB-mq-ref.xml:39
473 msgid ""
474 "This command is shorthand for <command role=\"hg-cmd\">hg commit --cwd .hg/"
475 "patches</command>."
476 msgstr ""
478 #. type: Content of: <book><appendix><sect1><sect2><title>
479 #: ../en/appB-mq-ref.xml:43
480 msgid ""
481 "<command role=\"hg-ext-mq\">qdelete</command>&emdash;delete a patch from the "
482 "<filename role=\"special\">series</filename> file"
483 msgstr ""
484 "<command role=\"hg-ext-mq\">qdelete</command>&emdash;从文件 <filename role="
485 "\"special\">series</filename> 中删除补丁"
487 #. type: Content of: <book><appendix><sect1><sect2><para>
488 #: ../en/appB-mq-ref.xml:48
489 msgid ""
490 "The <command role=\"hg-ext-mq\">qdelete</command> command removes the entry "
491 "for a patch from the <filename role=\"special\">series</filename> file in the "
492 "<filename role=\"special\" class=\"directory\">.hg/patches</filename> "
493 "directory. It does not pop the patch if the patch is already applied. By "
494 "default, it does not delete the patch file; use the <option role=\"hg-ext-mq-"
495 "cmd-qdel-opt\">-f</option> option to do that."
496 msgstr ""
498 #. type: Content of: <book><appendix><sect1><sect2><para>
499 #: ../en/appB-mq-ref.xml:57 ../en/appB-mq-ref.xml:99 ../en/appB-mq-ref.xml:157
500 #: ../en/appB-mq-ref.xml:197 ../en/appB-mq-ref.xml:264
501 #: ../en/appB-mq-ref.xml:335 ../en/appB-mq-ref.xml:404
502 #: ../en/appB-mq-ref.xml:497
503 msgid "Options:"
504 msgstr ""
506 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
507 #: ../en/appB-mq-ref.xml:59
508 msgid ""
509 "<option role=\"hg-ext-mq-cmd-qdel-opt\">-f</option>: Delete the patch file."
510 msgstr ""
512 #. type: Content of: <book><appendix><sect1><sect2><title>
513 #: ../en/appB-mq-ref.xml:66
514 msgid ""
515 "<command role=\"hg-ext-mq\">qdiff</command>&emdash;print a diff of the "
516 "topmost applied patch"
517 msgstr ""
518 "<command role=\"hg-ext-mq\">qdiff</command>&emdash;显示最新应用补丁的差异"
520 #. type: Content of: <book><appendix><sect1><sect2><para>
521 #: ../en/appB-mq-ref.xml:69
522 msgid ""
523 "The <command role=\"hg-ext-mq\">qdiff</command> command prints a diff of the "
524 "topmost applied patch. It is equivalent to <command role=\"hg-cmd\">hg diff -"
525 "r-2:-1</command>."
526 msgstr ""
528 #. type: Content of: <book><appendix><sect1><sect2><title>
529 #: ../en/appB-mq-ref.xml:75
530 msgid ""
531 "<command role=\"hg-ext-mq\">qfold</command>&emdash;merge (<quote>fold</"
532 "quote>) several patches into one"
533 msgstr ""
534 "<command role=\"hg-ext-mq\">qfold</command>&emdash;将多个补丁合并(<quote>折叠"
535 "</quote>)成一个"
537 #. type: Content of: <book><appendix><sect1><sect2><para>
538 #: ../en/appB-mq-ref.xml:78
539 msgid ""
540 "The <command role=\"hg-ext-mq\">qfold</command> command merges multiple "
541 "patches into the topmost applied patch, so that the topmost applied patch "
542 "makes the union of all of the changes in the patches in question."
543 msgstr ""
545 #. type: Content of: <book><appendix><sect1><sect2><para>
546 #: ../en/appB-mq-ref.xml:83
547 msgid ""
548 "The patches to fold must not be applied; <command role=\"hg-ext-mq\">qfold</"
549 "command> will exit with an error if any is. The order in which patches are "
550 "folded is significant; <command role=\"hg-cmd\">hg qfold a b</command> means "
551 "<quote>apply the current topmost patch, followed by <literal>a</literal>, "
552 "followed by <literal>b</literal></quote>."
553 msgstr ""
555 #. type: Content of: <book><appendix><sect1><sect2><para>
556 #: ../en/appB-mq-ref.xml:91
557 msgid ""
558 "The comments from the folded patches are appended to the comments of the "
559 "destination patch, with each block of comments separated by three asterisk "
560 "(<quote><literal>*</literal></quote>) characters. Use the <option role=\"hg-"
561 "ext-mq-cmd-qfold-opt\">-e</option> option to edit the commit message for the "
562 "combined patch/changeset after the folding has completed."
563 msgstr ""
565 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
566 #: ../en/appB-mq-ref.xml:101
567 msgid ""
568 "<option role=\"hg-ext-mq-cmd-qfold-opt\">-e</option>: Edit the commit message "
569 "and patch description for the newly folded patch."
570 msgstr ""
572 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
573 #: ../en/appB-mq-ref.xml:106
574 msgid ""
575 "<option role=\"hg-ext-mq-cmd-qfold-opt\">-l</option>: Use the contents of the "
576 "given file as the new commit message and patch description for the folded "
577 "patch."
578 msgstr ""
580 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
581 #: ../en/appB-mq-ref.xml:111
582 msgid ""
583 "<option role=\"hg-ext-mq-cmd-qfold-opt\">-m</option>: Use the given text as "
584 "the new commit message and patch description for the folded patch."
585 msgstr ""
587 #. type: Content of: <book><appendix><sect1><sect2><title>
588 #: ../en/appB-mq-ref.xml:119
589 msgid ""
590 "<command role=\"hg-ext-mq\">qheader</command>&emdash;display the header/"
591 "description of a patch"
592 msgstr "<command role=\"hg-ext-mq\">qheader</command>&emdash;显示补丁头部描述"
594 #. type: Content of: <book><appendix><sect1><sect2><para>
595 #: ../en/appB-mq-ref.xml:123
596 msgid ""
597 "The <command role=\"hg-ext-mq\">qheader</command> command prints the header, "
598 "or description, of a patch. By default, it prints the header of the topmost "
599 "applied patch. Given an argument, it prints the header of the named patch."
600 msgstr ""
602 #. type: Content of: <book><appendix><sect1><sect2><title>
603 #: ../en/appB-mq-ref.xml:130
604 msgid ""
605 "<command role=\"hg-ext-mq\">qimport</command>&emdash;import a third-party "
606 "patch into the queue"
607 msgstr ""
608 "<command role=\"hg-ext-mq\">qimport</command>&emdash;将第三方补丁导入队列"
610 #. type: Content of: <book><appendix><sect1><sect2><para>
611 #: ../en/appB-mq-ref.xml:133
612 msgid ""
613 "The <command role=\"hg-ext-mq\">qimport</command> command adds an entry for "
614 "an external patch to the <filename role=\"special\">series</filename> file, "
615 "and copies the patch into the <filename role=\"special\" class=\"directory\">."
616 "hg/patches</filename> directory. It adds the entry immediately after the "
617 "topmost applied patch, but does not push the patch."
618 msgstr ""
620 #. type: Content of: <book><appendix><sect1><sect2><para>
621 #: ../en/appB-mq-ref.xml:141
622 msgid ""
623 "If the <filename role=\"special\" class=\"directory\">.hg/patches</filename> "
624 "directory is a repository, <command role=\"hg-ext-mq\">qimport</command> "
625 "automatically does an <command role=\"hg-cmd\">hg add</command> of the "
626 "imported patch."
627 msgstr ""
629 #. type: Content of: <book><appendix><sect1><sect2><title>
630 #: ../en/appB-mq-ref.xml:149
631 msgid ""
632 "<command role=\"hg-ext-mq\">qinit</command>&emdash;prepare a repository to "
633 "work with MQ"
634 msgstr "<command role=\"hg-ext-mq\">qinit</command>&emdash;为使用 MQ 配置版本库"
636 #. type: Content of: <book><appendix><sect1><sect2><para>
637 #: ../en/appB-mq-ref.xml:152
638 msgid ""
639 "The <command role=\"hg-ext-mq\">qinit</command> command prepares a repository "
640 "to work with MQ. It creates a directory called <filename role=\"special\" "
641 "class=\"directory\">.hg/patches</filename>."
642 msgstr ""
644 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
645 #: ../en/appB-mq-ref.xml:159
646 msgid ""
647 "<option role=\"hg-ext-mq-cmd-qinit-opt\">-c</option>: Create <filename role="
648 "\"special\" class=\"directory\">.hg/patches</filename> as a repository in its "
649 "own right. Also creates a <filename role=\"special\">.hgignore</filename> "
650 "file that will ignore the <filename role=\"special\">status</filename> file."
651 msgstr ""
653 #. type: Content of: <book><appendix><sect1><sect2><para>
654 #: ../en/appB-mq-ref.xml:169
655 msgid ""
656 "When the <filename role=\"special\" class=\"directory\">.hg/patches</"
657 "filename> directory is a repository, the <command role=\"hg-ext-mq\">qimport</"
658 "command> and <command role=\"hg-ext-mq\">qnew</command> commands "
659 "automatically <command role=\"hg-cmd\">hg add</command> new patches."
660 msgstr ""
662 #. type: Content of: <book><appendix><sect1><sect2><title>
663 #: ../en/appB-mq-ref.xml:178
664 msgid "<command role=\"hg-ext-mq\">qnew</command>&emdash;create a new patch"
665 msgstr "<command role=\"hg-ext-mq\">qnew</command>&emdash;创建新补丁"
667 #. type: Content of: <book><appendix><sect1><sect2><para>
668 #: ../en/appB-mq-ref.xml:181
669 msgid ""
670 "The <command role=\"hg-ext-mq\">qnew</command> command creates a new patch. "
671 "It takes one mandatory argument, the name to use for the patch file. The "
672 "newly created patch is created empty by default. It is added to the "
673 "<filename role=\"special\">series</filename> file after the current topmost "
674 "applied patch, and is immediately pushed on top of that patch."
675 msgstr ""
677 #. type: Content of: <book><appendix><sect1><sect2><para>
678 #: ../en/appB-mq-ref.xml:189
679 msgid ""
680 "If <command role=\"hg-ext-mq\">qnew</command> finds modified files in the "
681 "working directory, it will refuse to create a new patch unless the <option "
682 "role=\"hg-ext-mq-cmd-qnew-opt\">-f</option> option is used (see below). This "
683 "behaviour allows you to <command role=\"hg-ext-mq\">qrefresh</command> your "
684 "topmost applied patch before you apply a new patch on top of it."
685 msgstr ""
687 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
688 #: ../en/appB-mq-ref.xml:199
689 msgid ""
690 "<option role=\"hg-ext-mq-cmd-qnew-opt\">-f</option>: Create a new patch if "
691 "the contents of the working directory are modified. Any outstanding "
692 "modifications are added to the newly created patch, so after this command "
693 "completes, the working directory will no longer be modified."
694 msgstr ""
696 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
697 #: ../en/appB-mq-ref.xml:206
698 msgid ""
699 "<option role=\"hg-ext-mq-cmd-qnew-opt\">-m</option>: Use the given text as "
700 "the commit message. This text will be stored at the beginning of the patch "
701 "file, before the patch data."
702 msgstr ""
704 #. type: Content of: <book><appendix><sect1><sect2><title>
705 #: ../en/appB-mq-ref.xml:215
706 msgid ""
707 "<command role=\"hg-ext-mq\">qnext</command>&emdash;print the name of the next "
708 "patch"
709 msgstr "<command role=\"hg-ext-mq\">qnext</command>&emdash;显示下个补丁的名称"
711 #. type: Content of: <book><appendix><sect1><sect2><para>
712 #: ../en/appB-mq-ref.xml:218
713 msgid ""
714 "The <command role=\"hg-ext-mq\">qnext</command> command prints the name name "
715 "of the next patch in the <filename role=\"special\">series</filename> file "
716 "after the topmost applied patch. This patch will become the topmost applied "
717 "patch if you run <command role=\"hg-ext-mq\">qpush</command>."
718 msgstr ""
720 #. type: Content of: <book><appendix><sect1><sect2><title>
721 #: ../en/appB-mq-ref.xml:227
722 msgid ""
723 "<command role=\"hg-ext-mq\">qpop</command>&emdash;pop patches off the stack"
724 msgstr "<command role=\"hg-ext-mq\">qpop</command>&emdash;删除堆栈顶部的补丁"
726 #. type: Content of: <book><appendix><sect1><sect2><para>
727 #: ../en/appB-mq-ref.xml:230
728 msgid ""
729 "The <command role=\"hg-ext-mq\">qpop</command> command removes applied "
730 "patches from the top of the stack of applied patches. By default, it removes "
731 "only one patch."
732 msgstr ""
734 #. type: Content of: <book><appendix><sect1><sect2><para>
735 #: ../en/appB-mq-ref.xml:234
736 msgid ""
737 "This command removes the changesets that represent the popped patches from "
738 "the repository, and updates the working directory to undo the effects of the "
739 "patches."
740 msgstr ""
742 #. type: Content of: <book><appendix><sect1><sect2><para>
743 #: ../en/appB-mq-ref.xml:238
744 msgid ""
745 "This command takes an optional argument, which it uses as the name or index "
746 "of the patch to pop to. If given a name, it will pop patches until the named "
747 "patch is the topmost applied patch. If given a number, <command role=\"hg-"
748 "ext-mq\">qpop</command> treats the number as an index into the entries in the "
749 "series file, counting from zero (empty lines and lines containing only "
750 "comments do not count). It pops patches until the patch identified by the "
751 "given index is the topmost applied patch."
752 msgstr ""
754 #. type: Content of: <book><appendix><sect1><sect2><para>
755 #: ../en/appB-mq-ref.xml:248
756 msgid ""
757 "The <command role=\"hg-ext-mq\">qpop</command> command does not read or write "
758 "patches or the <filename role=\"special\">series</filename> file. It is thus "
759 "safe to <command role=\"hg-ext-mq\">qpop</command> a patch that you have "
760 "removed from the <filename role=\"special\">series</filename> file, or a "
761 "patch that you have renamed or deleted entirely. In the latter two cases, "
762 "use the name of the patch as it was when you applied it."
763 msgstr ""
765 #. type: Content of: <book><appendix><sect1><sect2><para>
766 #: ../en/appB-mq-ref.xml:257
767 msgid ""
768 "By default, the <command role=\"hg-ext-mq\">qpop</command> command will not "
769 "pop any patches if the working directory has been modified. You can override "
770 "this behaviour using the <option role=\"hg-ext-mq-cmd-qpop-opt\">-f</option> "
771 "option, which reverts all modifications in the working directory."
772 msgstr ""
774 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
775 #: ../en/appB-mq-ref.xml:266
776 msgid ""
777 "<option role=\"hg-ext-mq-cmd-qpop-opt\">-a</option>: Pop all applied "
778 "patches. This returns the repository to its state before you applied any "
779 "patches."
780 msgstr ""
782 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
783 #: ../en/appB-mq-ref.xml:271
784 msgid ""
785 "<option role=\"hg-ext-mq-cmd-qpop-opt\">-f</option>: Forcibly revert any "
786 "modifications to the working directory when popping."
787 msgstr ""
789 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
790 #: ../en/appB-mq-ref.xml:276
791 msgid ""
792 "<option role=\"hg-ext-mq-cmd-qpop-opt\">-n</option>: Pop a patch from the "
793 "named queue."
794 msgstr ""
796 #. type: Content of: <book><appendix><sect1><sect2><para>
797 #: ../en/appB-mq-ref.xml:281
798 msgid ""
799 "The <command role=\"hg-ext-mq\">qpop</command> command removes one line from "
800 "the end of the <filename role=\"special\">status</filename> file for each "
801 "patch that it pops."
802 msgstr ""
804 #. type: Content of: <book><appendix><sect1><sect2><title>
805 #: ../en/appB-mq-ref.xml:288
806 msgid ""
807 "<command role=\"hg-ext-mq\">qprev</command>&emdash;print the name of the "
808 "previous patch"
809 msgstr "<command role=\"hg-ext-mq\">qprev</command>&emdash;显示上个补丁的名称"
811 #. type: Content of: <book><appendix><sect1><sect2><para>
812 #: ../en/appB-mq-ref.xml:291
813 msgid ""
814 "The <command role=\"hg-ext-mq\">qprev</command> command prints the name of "
815 "the patch in the <filename role=\"special\">series</filename> file that comes "
816 "before the topmost applied patch. This will become the topmost applied patch "
817 "if you run <command role=\"hg-ext-mq\">qpop</command>."
818 msgstr ""
820 #. type: Content of: <book><appendix><sect1><sect2><title>
821 #: ../en/appB-mq-ref.xml:300
822 msgid ""
823 "<command role=\"hg-ext-mq\">qpush</command>&emdash;push patches onto the stack"
824 msgstr "<command role=\"hg-ext-mq\">qpush</command>&emdash;增加补丁到堆栈"
826 #. type: Content of: <book><appendix><sect1><sect2><para>
827 #: ../en/appB-mq-ref.xml:303
828 msgid ""
829 "The <command role=\"hg-ext-mq\">qpush</command> command adds patches onto the "
830 "applied stack. By default, it adds only one patch."
831 msgstr ""
833 #. type: Content of: <book><appendix><sect1><sect2><para>
834 #: ../en/appB-mq-ref.xml:307
835 msgid ""
836 "This command creates a new changeset to represent each applied patch, and "
837 "updates the working directory to apply the effects of the patches."
838 msgstr ""
840 #. type: Content of: <book><appendix><sect1><sect2><para>
841 #: ../en/appB-mq-ref.xml:311
842 msgid "The default data used when creating a changeset are as follows:"
843 msgstr ""
845 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
846 #: ../en/appB-mq-ref.xml:314
847 msgid ""
848 "The commit date and time zone are the current date and time zone. Because "
849 "these data are used to compute the identity of a changeset, this means that "
850 "if you <command role=\"hg-ext-mq\">qpop</command> a patch and <command role="
851 "\"hg-ext-mq\">qpush</command> it again, the changeset that you push will have "
852 "a different identity than the changeset you popped."
853 msgstr ""
855 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
856 #: ../en/appB-mq-ref.xml:322
857 msgid ""
858 "The author is the same as the default used by the <command role=\"hg-cmd\">hg "
859 "commit</command> command."
860 msgstr ""
862 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
863 #: ../en/appB-mq-ref.xml:326
864 msgid ""
865 "The commit message is any text from the patch file that comes before the "
866 "first diff header. If there is no such text, a default commit message is "
867 "used that identifies the name of the patch."
868 msgstr ""
870 #. type: Content of: <book><appendix><sect1><sect2><para>
871 #: ../en/appB-mq-ref.xml:331
872 msgid ""
873 "If a patch contains a Mercurial patch header (XXX add link), the information "
874 "in the patch header overrides these defaults."
875 msgstr ""
877 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
878 #: ../en/appB-mq-ref.xml:337
879 msgid ""
880 "<option role=\"hg-ext-mq-cmd-qpush-opt\">-a</option>: Push all unapplied "
881 "patches from the <filename role=\"special\">series</filename> file until "
882 "there are none left to push."
883 msgstr ""
885 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
886 #: ../en/appB-mq-ref.xml:343
887 msgid ""
888 "<option role=\"hg-ext-mq-cmd-qpush-opt\">-l</option>: Add the name of the "
889 "patch to the end of the commit message."
890 msgstr ""
892 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
893 #: ../en/appB-mq-ref.xml:347
894 msgid ""
895 "<option role=\"hg-ext-mq-cmd-qpush-opt\">-m</option>: If a patch fails to "
896 "apply cleanly, use the entry for the patch in another saved queue to compute "
897 "the parameters for a three-way merge, and perform a three-way merge using the "
898 "normal Mercurial merge machinery. Use the resolution of the merge as the new "
899 "patch content."
900 msgstr ""
902 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
903 #: ../en/appB-mq-ref.xml:355
904 msgid ""
905 "<option role=\"hg-ext-mq-cmd-qpush-opt\">-n</option>: Use the named queue if "
906 "merging while pushing."
907 msgstr ""
909 #. type: Content of: <book><appendix><sect1><sect2><para>
910 #: ../en/appB-mq-ref.xml:360
911 msgid ""
912 "The <command role=\"hg-ext-mq\">qpush</command> command reads, but does not "
913 "modify, the <filename role=\"special\">series</filename> file. It appends "
914 "one line to the <command role=\"hg-cmd\">hg status</command> file for each "
915 "patch that it pushes."
916 msgstr ""
918 #. type: Content of: <book><appendix><sect1><sect2><title>
919 #: ../en/appB-mq-ref.xml:368
920 msgid ""
921 "<command role=\"hg-ext-mq\">qrefresh</command>&emdash;update the topmost "
922 "applied patch"
923 msgstr "<command role=\"hg-ext-mq\">qrefresh</command>&emdash;更新最新的补丁"
925 #. type: Content of: <book><appendix><sect1><sect2><para>
926 #: ../en/appB-mq-ref.xml:372
927 msgid ""
928 "The <command role=\"hg-ext-mq\">qrefresh</command> command updates the "
929 "topmost applied patch. It modifies the patch, removes the old changeset that "
930 "represented the patch, and creates a new changeset to represent the modified "
931 "patch."
932 msgstr ""
934 #. type: Content of: <book><appendix><sect1><sect2><para>
935 #: ../en/appB-mq-ref.xml:378
936 msgid ""
937 "The <command role=\"hg-ext-mq\">qrefresh</command> command looks for the "
938 "following modifications:"
939 msgstr ""
941 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
942 #: ../en/appB-mq-ref.xml:381
943 msgid ""
944 "Changes to the commit message, i.e. the text before the first diff header in "
945 "the patch file, are reflected in the new changeset that represents the patch."
946 msgstr ""
948 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
949 #: ../en/appB-mq-ref.xml:386
950 msgid ""
951 "Modifications to tracked files in the working directory are added to the "
952 "patch."
953 msgstr ""
955 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
956 #: ../en/appB-mq-ref.xml:389
957 msgid ""
958 "Changes to the files tracked using <command role=\"hg-cmd\">hg add</command>, "
959 "<command role=\"hg-cmd\">hg copy</command>, <command role=\"hg-cmd\">hg "
960 "remove</command>, or <command role=\"hg-cmd\">hg rename</command>. Added "
961 "files and copy and rename destinations are added to the patch, while removed "
962 "files and rename sources are removed."
963 msgstr ""
965 #. type: Content of: <book><appendix><sect1><sect2><para>
966 #: ../en/appB-mq-ref.xml:398
967 msgid ""
968 "Even if <command role=\"hg-ext-mq\">qrefresh</command> detects no changes, it "
969 "still recreates the changeset that represents the patch. This causes the "
970 "identity of the changeset to differ from the previous changeset that "
971 "identified the patch."
972 msgstr ""
974 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
975 #: ../en/appB-mq-ref.xml:406
976 msgid ""
977 "<option role=\"hg-ext-mq-cmd-qrefresh-opt\">-e</option>: Modify the commit "
978 "and patch description, using the preferred text editor."
979 msgstr ""
981 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
982 #: ../en/appB-mq-ref.xml:411
983 msgid ""
984 "<option role=\"hg-ext-mq-cmd-qrefresh-opt\">-m</option>: Modify the commit "
985 "message and patch description, using the given text."
986 msgstr ""
988 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
989 #: ../en/appB-mq-ref.xml:416
990 msgid ""
991 "<option role=\"hg-ext-mq-cmd-qrefresh-opt\">-l</option>: Modify the commit "
992 "message and patch description, using text from the given file."
993 msgstr ""
995 #. type: Content of: <book><appendix><sect1><sect2><title>
996 #: ../en/appB-mq-ref.xml:424
997 msgid "<command role=\"hg-ext-mq\">qrename</command>&emdash;rename a patch"
998 msgstr "<command role=\"hg-ext-mq\">qrename</command>&emdash;改名补丁"
1000 #. type: Content of: <book><appendix><sect1><sect2><para>
1001 #: ../en/appB-mq-ref.xml:427
1002 msgid ""
1003 "The <command role=\"hg-ext-mq\">qrename</command> command renames a patch, "
1004 "and changes the entry for the patch in the <filename role=\"special\">series</"
1005 "filename> file."
1006 msgstr ""
1008 #. type: Content of: <book><appendix><sect1><sect2><para>
1009 #: ../en/appB-mq-ref.xml:431
1010 msgid ""
1011 "With a single argument, <command role=\"hg-ext-mq\">qrename</command> renames "
1012 "the topmost applied patch. With two arguments, it renames its first argument "
1013 "to its second."
1014 msgstr ""
1016 #. type: Content of: <book><appendix><sect1><sect2><title>
1017 #: ../en/appB-mq-ref.xml:438
1018 msgid ""
1019 "<command role=\"hg-ext-mq\">qrestore</command>&emdash;restore saved queue "
1020 "state"
1021 msgstr "<command role=\"hg-ext-mq\">qrestore</command>&emdash;恢复保存的队列"
1023 #. type: Content of: <book><appendix><sect1><sect2><para>
1024 #: ../en/appB-mq-ref.xml:442
1025 msgid "XXX No idea what this does."
1026 msgstr ""
1028 #. type: Content of: <book><appendix><sect1><sect2><title>
1029 #: ../en/appB-mq-ref.xml:446
1030 msgid ""
1031 "<command role=\"hg-ext-mq\">qsave</command>&emdash;save current queue state"
1032 msgstr "<command role=\"hg-ext-mq\">qsave</command>&emdash;保存当前的队列状态"
1034 #. type: Content of: <book><appendix><sect1><sect2><para>
1035 #: ../en/appB-mq-ref.xml:449
1036 msgid "XXX Likewise."
1037 msgstr ""
1039 #. type: Content of: <book><appendix><sect1><sect2><title>
1040 #: ../en/appB-mq-ref.xml:453
1041 msgid ""
1042 "<command role=\"hg-ext-mq\">qseries</command>&emdash;print the entire patch "
1043 "series"
1044 msgstr "<command role=\"hg-ext-mq\">qseries</command>&emdash;显示补丁序列"
1046 #. type: Content of: <book><appendix><sect1><sect2><para>
1047 #: ../en/appB-mq-ref.xml:456
1048 msgid ""
1049 "The <command role=\"hg-ext-mq\">qseries</command> command prints the entire "
1050 "patch series from the <filename role=\"special\">series</filename> file. It "
1051 "prints only patch names, not empty lines or comments. It prints in order "
1052 "from first to be applied to last."
1053 msgstr ""
1055 #. type: Content of: <book><appendix><sect1><sect2><title>
1056 #: ../en/appB-mq-ref.xml:464
1057 msgid ""
1058 "<command role=\"hg-ext-mq\">qtop</command>&emdash;print the name of the "
1059 "current patch"
1060 msgstr "<command role=\"hg-ext-mq\">qtop</command>&emdash;显示当前补丁的名称"
1062 #. type: Content of: <book><appendix><sect1><sect2><para>
1063 #: ../en/appB-mq-ref.xml:467
1064 msgid ""
1065 "The <command role=\"hg-ext-mq\">qtop</command> prints the name of the topmost "
1066 "currently applied patch."
1067 msgstr ""
1069 #. type: Content of: <book><appendix><sect1><sect2><title>
1070 #: ../en/appB-mq-ref.xml:472
1071 msgid ""
1072 "<command role=\"hg-ext-mq\">qunapplied</command>&emdash;print patches not yet "
1073 "applied"
1074 msgstr ""
1075 "<command role=\"hg-ext-mq\">qunapplied</command>&emdash;显示尚未应用的补丁"
1077 #. type: Content of: <book><appendix><sect1><sect2><para>
1078 #: ../en/appB-mq-ref.xml:476
1079 msgid ""
1080 "The <command role=\"hg-ext-mq\">qunapplied</command> command prints the names "
1081 "of patches from the <filename role=\"special\">series</filename> file that "
1082 "are not yet applied. It prints them in order from the next patch that will "
1083 "be pushed to the last."
1084 msgstr ""
1086 #. type: Content of: <book><appendix><sect1><sect2><title>
1087 #: ../en/appB-mq-ref.xml:484
1088 msgid ""
1089 "<command role=\"hg-cmd\">hg strip</command>&emdash;remove a revision and "
1090 "descendants"
1091 msgstr "<command role=\"hg-cmd\">hg strip</command>&emdash;删除一个版本及其后继"
1093 #. type: Content of: <book><appendix><sect1><sect2><para>
1094 #: ../en/appB-mq-ref.xml:487
1095 msgid ""
1096 "The <command role=\"hg-cmd\">hg strip</command> command removes a revision, "
1097 "and all of its descendants, from the repository. It undoes the effects of "
1098 "the removed revisions from the repository, and updates the working directory "
1099 "to the first parent of the removed revision."
1100 msgstr ""
1102 #. type: Content of: <book><appendix><sect1><sect2><para>
1103 #: ../en/appB-mq-ref.xml:493
1104 msgid ""
1105 "The <command role=\"hg-cmd\">hg strip</command> command saves a backup of the "
1106 "removed changesets in a bundle, so that they can be reapplied if removed in "
1107 "error."
1108 msgstr ""
1110 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1111 #: ../en/appB-mq-ref.xml:499
1112 msgid ""
1113 "<option role=\"hg-opt-strip\">-b</option>: Save unrelated changesets that are "
1114 "intermixed with the stripped changesets in the backup bundle."
1115 msgstr ""
1117 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1118 #: ../en/appB-mq-ref.xml:503
1119 msgid ""
1120 "<option role=\"hg-opt-strip\">-f</option>: If a branch has multiple heads, "
1121 "remove all heads. XXX This should be renamed, and use <literal>-f</literal> "
1122 "to strip revs when there are pending changes."
1123 msgstr ""
1125 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1126 #: ../en/appB-mq-ref.xml:508
1127 msgid "<option role=\"hg-opt-strip\">-n</option>: Do not save a backup bundle."
1128 msgstr ""
1130 #. type: Content of: <book><appendix><sect1><title>
1131 #: ../en/appB-mq-ref.xml:515
1132 msgid "MQ file reference"
1133 msgstr "MQ 文件参考"
1135 #. type: Content of: <book><appendix><sect1><sect2><title>
1136 #: ../en/appB-mq-ref.xml:518
1137 msgid "The <filename role=\"special\">series</filename> file"
1138 msgstr "<filename role=\"special\">序列</filename>文件"
1140 #. type: Content of: <book><appendix><sect1><sect2><para>
1141 #: ../en/appB-mq-ref.xml:521
1142 msgid ""
1143 "The <filename role=\"special\">series</filename> file contains a list of the "
1144 "names of all patches that MQ can apply. It is represented as a list of "
1145 "names, with one name saved per line. Leading and trailing white space in "
1146 "each line are ignored."
1147 msgstr ""
1149 #. type: Content of: <book><appendix><sect1><sect2><para>
1150 #: ../en/appB-mq-ref.xml:527
1151 msgid ""
1152 "Lines may contain comments. A comment begins with the <quote><literal>#</"
1153 "literal></quote> character, and extends to the end of the line. Empty lines, "
1154 "and lines that contain only comments, are ignored."
1155 msgstr ""
1157 #. type: Content of: <book><appendix><sect1><sect2><para>
1158 #: ../en/appB-mq-ref.xml:532
1159 msgid ""
1160 "You will often need to edit the <filename role=\"special\">series</filename> "
1161 "file by hand, hence the support for comments and empty lines noted above. "
1162 "For example, you can comment out a patch temporarily, and <command role=\"hg-"
1163 "ext-mq\">qpush</command> will skip over that patch when applying patches. "
1164 "You can also change the order in which patches are applied by reordering "
1165 "their entries in the <filename role=\"special\">series</filename> file."
1166 msgstr ""
1168 #. type: Content of: <book><appendix><sect1><sect2><para>
1169 #: ../en/appB-mq-ref.xml:541
1170 msgid ""
1171 "Placing the <filename role=\"special\">series</filename> file under revision "
1172 "control is also supported; it is a good idea to place all of the patches that "
1173 "it refers to under revision control, as well. If you create a patch "
1174 "directory using the <option role=\"hg-ext-mq-cmd-qinit-opt\">-c</option> "
1175 "option to <command role=\"hg-ext-mq\">qinit</command>, this will be done for "
1176 "you automatically."
1177 msgstr ""
1179 #. type: Content of: <book><appendix><sect1><sect2><title>
1180 #: ../en/appB-mq-ref.xml:551
1181 msgid "The <filename role=\"special\">status</filename> file"
1182 msgstr "<filename role=\"special\">状态</filename>文件"
1184 #. type: Content of: <book><appendix><sect1><sect2><para>
1185 #: ../en/appB-mq-ref.xml:554
1186 msgid ""
1187 "The <filename role=\"special\">status</filename> file contains the names and "
1188 "changeset hashes of all patches that MQ currently has applied. Unlike the "
1189 "<filename role=\"special\">series</filename> file, this file is not intended "
1190 "for editing. You should not place this file under revision control, or "
1191 "modify it in any way. It is used by MQ strictly for internal book-keeping."
1192 msgstr ""
1194 #. type: Content of: <book><appendix><title>
1195 #: ../en/appC-srcinstall.xml:5
1196 msgid "Installing Mercurial from source"
1197 msgstr "从源代码安装 Mercurial"
1199 #. type: Content of: <book><appendix><sect1><title>
1200 #: ../en/appC-srcinstall.xml:8
1201 msgid "On a Unix-like system"
1202 msgstr "类 Unix 系统"
1204 #. type: Content of: <book><appendix><sect1><para>
1205 #: ../en/appC-srcinstall.xml:10
1206 msgid ""
1207 "If you are using a Unix-like system that has a sufficiently recent version of "
1208 "Python (2.3 or newer) available, it is easy to install Mercurial from source."
1209 msgstr ""
1211 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1212 #: ../en/appC-srcinstall.xml:14
1213 msgid ""
1214 "Download a recent source tarball from <ulink url=\"http://www.selenic.com/"
1215 "mercurial/download\">http://www.selenic.com/mercurial/download</ulink>."
1216 msgstr ""
1218 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1219 #: ../en/appC-srcinstall.xml:17
1220 msgid "Unpack the tarball:"
1221 msgstr ""
1223 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1224 #: ../en/appC-srcinstall.xml:20
1225 msgid ""
1226 "Go into the source directory and run the installer script. This will build "
1227 "Mercurial and install it in your home directory."
1228 msgstr ""
1230 #. type: Content of: <book><appendix><sect1><para>
1231 #: ../en/appC-srcinstall.xml:27
1232 msgid ""
1233 "Once the install finishes, Mercurial will be in the <literal>bin</literal> "
1234 "subdirectory of your home directory. Don't forget to make sure that this "
1235 "directory is present in your shell's search path."
1236 msgstr ""
1238 #. type: Content of: <book><appendix><sect1><para>
1239 #: ../en/appC-srcinstall.xml:32
1240 msgid ""
1241 "You will probably need to set the <envar>PYTHONPATH</envar> environment "
1242 "variable so that the Mercurial executable can find the rest of the Mercurial "
1243 "packages. For example, on my laptop, I have set it to <literal>/home/bos/lib/"
1244 "python</literal>. The exact path that you will need to use depends on how "
1245 "Python was built for your system, but should be easy to figure out. If "
1246 "you're uncertain, look through the output of the installer script above, and "
1247 "see where the contents of the <literal>mercurial</literal> directory were "
1248 "installed to."
1249 msgstr ""
1251 #. type: Content of: <book><appendix><sect1><title>
1252 #: ../en/appC-srcinstall.xml:44
1253 msgid "On Windows"
1254 msgstr "Windows 系统"
1256 #. type: Content of: <book><appendix><sect1><para>
1257 #: ../en/appC-srcinstall.xml:46
1258 msgid ""
1259 "Building and installing Mercurial on Windows requires a variety of tools, a "
1260 "fair amount of technical knowledge, and considerable patience. I very much "
1261 "<emphasis>do not recommend</emphasis> this route if you are a <quote>casual "
1262 "user</quote>. Unless you intend to hack on Mercurial, I strongly suggest "
1263 "that you use a binary package instead."
1264 msgstr ""
1266 #. type: Content of: <book><appendix><sect1><para>
1267 #: ../en/appC-srcinstall.xml:53
1268 msgid ""
1269 "If you are intent on building Mercurial from source on Windows, follow the "
1270 "<quote>hard way</quote> directions on the Mercurial wiki at <ulink url="
1271 "\"http://www.selenic.com/mercurial/wiki/index.cgi/WindowsInstall\">http://www."
1272 "selenic.com/mercurial/wiki/index.cgi/WindowsInstall</ulink>, and expect the "
1273 "process to involve a lot of fiddly work."
1274 msgstr ""
1276 #. type: Content of: <book><appendix><title>
1277 #: ../en/appD-license.xml:5
1278 msgid "Open Publication License"
1279 msgstr ""
1281 #. type: Content of: <book><appendix><para>
1282 #: ../en/appD-license.xml:7
1283 msgid "Version 1.0, 8 June 1999"
1284 msgstr ""
1286 #. type: Content of: <book><appendix><sect1><title>
1287 #: ../en/appD-license.xml:10
1288 msgid "Requirements on both unmodified and modified versions"
1289 msgstr ""
1291 #. type: Content of: <book><appendix><sect1><para>
1292 #: ../en/appD-license.xml:13
1293 msgid ""
1294 "The Open Publication works may be reproduced and distributed in whole or in "
1295 "part, in any medium physical or electronic, provided that the terms of this "
1296 "license are adhered to, and that this license or an incorporation of it by "
1297 "reference (with any options elected by the author(s) and/or publisher) is "
1298 "displayed in the reproduction."
1299 msgstr ""
1301 #. type: Content of: <book><appendix><sect1><para>
1302 #: ../en/appD-license.xml:20
1303 msgid "Proper form for an incorporation by reference is as follows:"
1304 msgstr ""
1306 #. type: Content of: <book><appendix><sect1><blockquote><para>
1307 #: ../en/appD-license.xml:24
1308 msgid ""
1309 "Copyright (c) <emphasis>year</emphasis> by <emphasis>author's name or "
1310 "designee</emphasis>. This material may be distributed only subject to the "
1311 "terms and conditions set forth in the Open Publication License, v<emphasis>x."
1312 "y</emphasis> or later (the latest version is presently available at <ulink "
1313 "url=\"http://www.opencontent.org/openpub/\">http://www.opencontent.org/"
1314 "openpub/</ulink>)."
1315 msgstr ""
1317 #. type: Content of: <book><appendix><sect1><para>
1318 #: ../en/appD-license.xml:33
1319 msgid ""
1320 "The reference must be immediately followed with any options elected by the "
1321 "author(s) and/or publisher of the document (see <xref linkend=\"sec:opl:"
1322 "options\"/>)."
1323 msgstr ""
1325 #. type: Content of: <book><appendix><sect1><para>
1326 #: ../en/appD-license.xml:37
1327 msgid ""
1328 "Commercial redistribution of Open Publication-licensed material is permitted."
1329 msgstr ""
1331 #. type: Content of: <book><appendix><sect1><para>
1332 #: ../en/appD-license.xml:40
1333 msgid ""
1334 "Any publication in standard (paper) book form shall require the citation of "
1335 "the original publisher and author. The publisher and author's names shall "
1336 "appear on all outer surfaces of the book. On all outer surfaces of the book "
1337 "the original publisher's name shall be as large as the title of the work and "
1338 "cited as possessive with respect to the title."
1339 msgstr ""
1341 #. type: Content of: <book><appendix><sect1><title>
1342 #: ../en/appD-license.xml:49
1343 msgid "Copyright"
1344 msgstr ""
1346 #. type: Content of: <book><appendix><sect1><para>
1347 #: ../en/appD-license.xml:51
1348 msgid ""
1349 "The copyright to each Open Publication is owned by its author(s) or designee."
1350 msgstr ""
1352 #. type: Content of: <book><appendix><sect1><title>
1353 #: ../en/appD-license.xml:56
1354 msgid "Scope of license"
1355 msgstr ""
1357 #. type: Content of: <book><appendix><sect1><para>
1358 #: ../en/appD-license.xml:58
1359 msgid ""
1360 "The following license terms apply to all Open Publication works, unless "
1361 "otherwise explicitly stated in the document."
1362 msgstr ""
1364 #. type: Content of: <book><appendix><sect1><para>
1365 #: ../en/appD-license.xml:62
1366 msgid ""
1367 "Mere aggregation of Open Publication works or a portion of an Open "
1368 "Publication work with other works or programs on the same media shall not "
1369 "cause this license to apply to those other works. The aggregate work shall "
1370 "contain a notice specifying the inclusion of the Open Publication material "
1371 "and appropriate copyright notice."
1372 msgstr ""
1374 #. type: Content of: <book><appendix><sect1><para>
1375 #: ../en/appD-license.xml:69
1376 msgid ""
1377 "<emphasis role=\"bold\">Severability</emphasis>. If any part of this license "
1378 "is found to be unenforceable in any jurisdiction, the remaining portions of "
1379 "the license remain in force."
1380 msgstr ""
1382 #. type: Content of: <book><appendix><sect1><para>
1383 #: ../en/appD-license.xml:74
1384 msgid ""
1385 "<emphasis role=\"bold\">No warranty</emphasis>. Open Publication works are "
1386 "licensed and provided <quote>as is</quote> without warranty of any kind, "
1387 "express or implied, including, but not limited to, the implied warranties of "
1388 "merchantability and fitness for a particular purpose or a warranty of non-"
1389 "infringement."
1390 msgstr ""
1392 #. type: Content of: <book><appendix><sect1><title>
1393 #: ../en/appD-license.xml:83
1394 msgid "Requirements on modified works"
1395 msgstr ""
1397 #. type: Content of: <book><appendix><sect1><para>
1398 #: ../en/appD-license.xml:85
1399 msgid ""
1400 "All modified versions of documents covered by this license, including "
1401 "translations, anthologies, compilations and partial documents, must meet the "
1402 "following requirements:"
1403 msgstr ""
1405 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1406 #: ../en/appD-license.xml:90
1407 msgid "The modified version must be labeled as such."
1408 msgstr ""
1410 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1411 #: ../en/appD-license.xml:93
1412 msgid ""
1413 "The person making the modifications must be identified and the modifications "
1414 "dated."
1415 msgstr ""
1417 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1418 #: ../en/appD-license.xml:96
1419 msgid ""
1420 "Acknowledgement of the original author and publisher if applicable must be "
1421 "retained according to normal academic citation practices."
1422 msgstr ""
1424 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1425 #: ../en/appD-license.xml:100
1426 msgid "The location of the original unmodified document must be identified."
1427 msgstr ""
1429 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1430 #: ../en/appD-license.xml:103
1431 msgid ""
1432 "The original author's (or authors') name(s) may not be used to assert or "
1433 "imply endorsement of the resulting document without the original author's (or "
1434 "authors') permission."
1435 msgstr ""
1437 #. type: Content of: <book><appendix><sect1><title>
1438 #: ../en/appD-license.xml:111
1439 msgid "Good-practice recommendations"
1440 msgstr ""
1442 #. type: Content of: <book><appendix><sect1><para>
1443 #: ../en/appD-license.xml:113
1444 msgid ""
1445 "In addition to the requirements of this license, it is requested from and "
1446 "strongly recommended of redistributors that:"
1447 msgstr ""
1449 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1450 #: ../en/appD-license.xml:118
1451 msgid ""
1452 "If you are distributing Open Publication works on hardcopy or CD-ROM, you "
1453 "provide email notification to the authors of your intent to redistribute at "
1454 "least thirty days before your manuscript or media freeze, to give the authors "
1455 "time to provide updated documents. This notification should describe "
1456 "modifications, if any, made to the document."
1457 msgstr ""
1459 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1460 #: ../en/appD-license.xml:125
1461 msgid ""
1462 "All substantive modifications (including deletions) be either clearly marked "
1463 "up in the document or else described in an attachment to the document."
1464 msgstr ""
1466 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1467 #: ../en/appD-license.xml:129
1468 msgid ""
1469 "Finally, while it is not mandatory under this license, it is considered good "
1470 "form to offer a free copy of any hardcopy and CD-ROM expression of an Open "
1471 "Publication-licensed work to its author(s)."
1472 msgstr ""
1474 #. type: Content of: <book><appendix><sect1><title>
1475 #: ../en/appD-license.xml:137
1476 msgid "License options"
1477 msgstr ""
1479 #. type: Content of: <book><appendix><sect1><para>
1480 #: ../en/appD-license.xml:139
1481 msgid ""
1482 "The author(s) and/or publisher of an Open Publication-licensed document may "
1483 "elect certain options by appending language to the reference to or copy of "
1484 "the license. These options are considered part of the license instance and "
1485 "must be included with the license (or its incorporation by reference) in "
1486 "derived works."
1487 msgstr ""
1489 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1490 #: ../en/appD-license.xml:147
1491 msgid ""
1492 "To prohibit distribution of substantively modified versions without the "
1493 "explicit permission of the author(s). <quote>Substantive modification</quote> "
1494 "is defined as a change to the semantic content of the document, and excludes "
1495 "mere changes in format or typographical corrections."
1496 msgstr ""
1498 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1499 #: ../en/appD-license.xml:154
1500 msgid ""
1501 "To accomplish this, add the phrase <quote>Distribution of substantively "
1502 "modified versions of this document is prohibited without the explicit "
1503 "permission of the copyright holder.</quote> to the license reference or copy."
1504 msgstr ""
1506 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1507 #: ../en/appD-license.xml:160
1508 msgid ""
1509 "To prohibit any publication of this work or derivative works in whole or in "
1510 "part in standard (paper) book form for commercial purposes is prohibited "
1511 "unless prior permission is obtained from the copyright holder."
1512 msgstr ""
1514 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1515 #: ../en/appD-license.xml:165
1516 msgid ""
1517 "To accomplish this, add the phrase <quote>Distribution of the work or "
1518 "derivative of the work in any standard (paper) book form is prohibited unless "
1519 "prior permission is obtained from the copyright holder.</quote> to the "
1520 "license reference or copy."
1521 msgstr ""
1523 #. type: Content of: <book><preface><title>
1524 #: ../en/ch00-preface.xml:5
1525 msgid "Preface"
1526 msgstr "序言"
1528 #. type: Content of: <book><preface><sect1><title>
1529 #: ../en/ch00-preface.xml:8
1530 msgid "Why revision control? Why Mercurial?"
1531 msgstr "为什么使用版本控制? 为什么使用 Mercurial?"
1533 #. type: Content of: <book><preface><sect1><para>
1534 #: ../en/ch00-preface.xml:10
1535 msgid ""
1536 "Revision control is the process of managing multiple versions of a piece of "
1537 "information. In its simplest form, this is something that many people do by "
1538 "hand: every time you modify a file, save it under a new name that contains a "
1539 "number, each one higher than the number of the preceding version."
1540 msgstr ""
1542 #. type: Content of: <book><preface><sect1><para>
1543 #: ../en/ch00-preface.xml:16
1544 msgid ""
1545 "Manually managing multiple versions of even a single file is an error-prone "
1546 "task, though, so software tools to help automate this process have long been "
1547 "available. The earliest automated revision control tools were intended to "
1548 "help a single user to manage revisions of a single file. Over the past few "
1549 "decades, the scope of revision control tools has expanded greatly; they now "
1550 "manage multiple files, and help multiple people to work together. The best "
1551 "modern revision control tools have no problem coping with thousands of people "
1552 "working together on projects that consist of hundreds of thousands of files."
1553 msgstr ""
1555 #. type: Content of: <book><preface><sect1><para>
1556 #: ../en/ch00-preface.xml:27
1557 msgid ""
1558 "The arrival of distributed revision control is relatively recent, and so far "
1559 "this new field has grown due to people's willingness to explore ill-charted "
1560 "territory."
1561 msgstr ""
1563 #. type: Content of: <book><preface><sect1><para>
1564 #: ../en/ch00-preface.xml:31
1565 msgid ""
1566 "I am writing a book about distributed revision control because I believe that "
1567 "it is an important subject that deserves a field guide. I chose to write "
1568 "about Mercurial because it is the easiest tool to learn the terrain with, and "
1569 "yet it scales to the demands of real, challenging environments where many "
1570 "other revision control tools buckle."
1571 msgstr ""
1573 #. type: Content of: <book><preface><sect1><sect2><title>
1574 #: ../en/ch00-preface.xml:39
1575 msgid "Why use revision control?"
1576 msgstr "为什么使用版本控制?"
1578 #. type: Content of: <book><preface><sect1><sect2><para>
1579 #: ../en/ch00-preface.xml:41
1580 msgid ""
1581 "There are a number of reasons why you or your team might want to use an "
1582 "automated revision control tool for a project."
1583 msgstr ""
1585 #. type: Content of: <book><preface><sect1><sect2><itemizedlist><listitem><para>
1586 #: ../en/ch00-preface.xml:46
1587 msgid ""
1588 "It will track the history and evolution of your project, so you don't have "
1589 "to. For every change, you'll have a log of <emphasis>who</emphasis> made it; "
1590 "<emphasis>why</emphasis> they made it; <emphasis>when</emphasis> they made "
1591 "it; and <emphasis>what</emphasis> the change was."
1592 msgstr ""
1594 #. type: Content of: <book><preface><sect1><sect2><itemizedlist><listitem><para>
1595 #: ../en/ch00-preface.xml:53
1596 msgid ""
1597 "When you're working with other people, revision control software makes it "
1598 "easier for you to collaborate. For example, when people more or less "
1599 "simultaneously make potentially incompatible changes, the software will help "
1600 "you to identify and resolve those conflicts."
1601 msgstr ""
1603 #. type: Content of: <book><preface><sect1><sect2><itemizedlist><listitem><para>
1604 #: ../en/ch00-preface.xml:59
1605 msgid ""
1606 "It can help you to recover from mistakes. If you make a change that later "
1607 "turns out to be in error, you can revert to an earlier version of one or more "
1608 "files. In fact, a <emphasis>really</emphasis> good revision control tool "
1609 "will even help you to efficiently figure out exactly when a problem was "
1610 "introduced (see <xref linkend=\"sec:undo:bisect\"/> for details)."
1611 msgstr ""
1613 #. type: Content of: <book><preface><sect1><sect2><itemizedlist><listitem><para>
1614 #: ../en/ch00-preface.xml:66
1615 msgid ""
1616 "It will help you to work simultaneously on, and manage the drift between, "
1617 "multiple versions of your project."
1618 msgstr ""
1620 #. type: Content of: <book><preface><sect1><sect2><para>
1621 #: ../en/ch00-preface.xml:71
1622 msgid ""
1623 "Most of these reasons are equally valid---at least in theory---whether you're "
1624 "working on a project by yourself, or with a hundred other people."
1625 msgstr ""
1627 #. type: Content of: <book><preface><sect1><sect2><para>
1628 #: ../en/ch00-preface.xml:75
1629 msgid ""
1630 "A key question about the practicality of revision control at these two "
1631 "different scales (<quote>lone hacker</quote> and <quote>huge team</quote>) is "
1632 "how its <emphasis>benefits</emphasis> compare to its <emphasis>costs</"
1633 "emphasis>. A revision control tool that's difficult to understand or use is "
1634 "going to impose a high cost."
1635 msgstr ""
1637 #. type: Content of: <book><preface><sect1><sect2><para>
1638 #: ../en/ch00-preface.xml:83
1639 msgid ""
1640 "A five-hundred-person project is likely to collapse under its own weight "
1641 "almost immediately without a revision control tool and process. In this case, "
1642 "the cost of using revision control might hardly seem worth considering, since "
1643 "<emphasis>without</emphasis> it, failure is almost guaranteed."
1644 msgstr ""
1646 #. type: Content of: <book><preface><sect1><sect2><para>
1647 #: ../en/ch00-preface.xml:90
1648 msgid ""
1649 "On the other hand, a one-person <quote>quick hack</quote> might seem like a "
1650 "poor place to use a revision control tool, because surely the cost of using "
1651 "one must be close to the overall cost of the project. Right?"
1652 msgstr ""
1654 #. type: Content of: <book><preface><sect1><sect2><para>
1655 #: ../en/ch00-preface.xml:95
1656 msgid ""
1657 "Mercurial uniquely supports <emphasis>both</emphasis> of these scales of "
1658 "development. You can learn the basics in just a few minutes, and due to its "
1659 "low overhead, you can apply revision control to the smallest of projects with "
1660 "ease. Its simplicity means you won't have a lot of abstruse concepts or "
1661 "command sequences competing for mental space with whatever you're "
1662 "<emphasis>really</emphasis> trying to do. At the same time, Mercurial's high "
1663 "performance and peer-to-peer nature let you scale painlessly to handle large "
1664 "projects."
1665 msgstr ""
1667 #. type: Content of: <book><preface><sect1><sect2><para>
1668 #: ../en/ch00-preface.xml:105
1669 msgid ""
1670 "No revision control tool can rescue a poorly run project, but a good choice "
1671 "of tools can make a huge difference to the fluidity with which you can work "
1672 "on a project."
1673 msgstr ""
1675 #. type: Content of: <book><preface><sect1><sect2><title>
1676 #: ../en/ch00-preface.xml:112
1677 msgid "The many names of revision control"
1678 msgstr "版本控制的别名"
1680 #. type: Content of: <book><preface><sect1><sect2><para>
1681 #: ../en/ch00-preface.xml:114
1682 msgid ""
1683 "Revision control is a diverse field, so much so that it is referred to by "
1684 "many names and acronyms. Here are a few of the more common variations you'll "
1685 "encounter:"
1686 msgstr ""
1688 #. type: Content of: <book><preface><sect1><sect2><itemizedlist><listitem><para>
1689 #: ../en/ch00-preface.xml:118
1690 msgid "Revision control (RCS)"
1691 msgstr "版本控制(RCS)"
1693 #. type: Content of: <book><preface><sect1><sect2><itemizedlist><listitem><para>
1694 #: ../en/ch00-preface.xml:119
1695 msgid "Software configuration management (SCM), or configuration management"
1696 msgstr "软件配置管理(SCM),或配置管理"
1698 #. type: Content of: <book><preface><sect1><sect2><itemizedlist><listitem><para>
1699 #: ../en/ch00-preface.xml:121
1700 msgid "Source code management"
1701 msgstr "源代码管理"
1703 #. type: Content of: <book><preface><sect1><sect2><itemizedlist><listitem><para>
1704 #: ../en/ch00-preface.xml:122
1705 msgid "Source code control, or source control"
1706 msgstr "源代码控制,或源控制"
1708 #. type: Content of: <book><preface><sect1><sect2><itemizedlist><listitem><para>
1709 #: ../en/ch00-preface.xml:124
1710 msgid "Version control (VCS)"
1711 msgstr "版本控制(VCS)"
1713 #. type: Content of: <book><preface><sect1><sect2><para>
1714 #: ../en/ch00-preface.xml:126
1715 msgid ""
1716 "Some people claim that these terms actually have different meanings, but in "
1717 "practice they overlap so much that there's no agreed or even useful way to "
1718 "tease them apart."
1719 msgstr ""
1721 #. type: Content of: <book><preface><sect1><title>
1722 #: ../en/ch00-preface.xml:134
1723 msgid "This book is a work in progress"
1724 msgstr "本书正在编写中"
1726 #. type: Content of: <book><preface><sect1><para>
1727 #: ../en/ch00-preface.xml:136
1728 msgid ""
1729 "I am releasing this book while I am still writing it, in the hope that it "
1730 "will prove useful to others. I am writing under an open license in the hope "
1731 "that you, my readers, will contribute feedback and perhaps content of your "
1732 "own."
1733 msgstr ""
1735 #. type: Content of: <book><preface><sect1><title>
1736 #: ../en/ch00-preface.xml:143
1737 msgid "About the examples in this book"
1738 msgstr "本书的例子"
1740 #. type: Content of: <book><preface><sect1><para>
1741 #: ../en/ch00-preface.xml:145
1742 msgid ""
1743 "This book takes an unusual approach to code samples. Every example is "
1744 "<quote>live</quote>---each one is actually the result of a shell script that "
1745 "executes the Mercurial commands you see. Every time an image of the book is "
1746 "built from its sources, all the example scripts are automatically run, and "
1747 "their current results compared against their expected results."
1748 msgstr ""
1750 #. type: Content of: <book><preface><sect1><para>
1751 #: ../en/ch00-preface.xml:152
1752 msgid ""
1753 "The advantage of this approach is that the examples are always accurate; they "
1754 "describe <emphasis>exactly</emphasis> the behaviour of the version of "
1755 "Mercurial that's mentioned at the front of the book. If I update the version "
1756 "of Mercurial that I'm documenting, and the output of some command changes, "
1757 "the build fails."
1758 msgstr ""
1760 #. type: Content of: <book><preface><sect1><para>
1761 #: ../en/ch00-preface.xml:159
1762 msgid ""
1763 "There is a small disadvantage to this approach, which is that the dates and "
1764 "times you'll see in examples tend to be <quote>squashed</quote> together in a "
1765 "way that they wouldn't be if the same commands were being typed by a human. "
1766 "Where a human can issue no more than one command every few seconds, with any "
1767 "resulting timestamps correspondingly spread out, my automated example scripts "
1768 "run many commands in one second."
1769 msgstr ""
1771 #. type: Content of: <book><preface><sect1><para>
1772 #: ../en/ch00-preface.xml:167
1773 msgid ""
1774 "As an instance of this, several consecutive commits in an example can show up "
1775 "as having occurred during the same second. You can see this occur in the "
1776 "<literal role=\"hg-ext\">bisect</literal> example in <xref linkend=\"sec:undo:"
1777 "bisect\"/>, for instance."
1778 msgstr ""
1780 #. type: Content of: <book><preface><sect1><para>
1781 #: ../en/ch00-preface.xml:173
1782 msgid ""
1783 "So when you're reading examples, don't place too much weight on the dates or "
1784 "times you see in the output of commands. But <emphasis>do</emphasis> be "
1785 "confident that the behaviour you're seeing is consistent and reproducible."
1786 msgstr ""
1788 #. type: Content of: <book><preface><sect1><title>
1789 #: ../en/ch00-preface.xml:181
1790 msgid "Trends in the field"
1791 msgstr "版本控制的发展趋势"
1793 #. type: Content of: <book><preface><sect1><para>
1794 #: ../en/ch00-preface.xml:183
1795 msgid ""
1796 "There has been an unmistakable trend in the development and use of revision "
1797 "control tools over the past four decades, as people have become familiar with "
1798 "the capabilities of their tools and constrained by their limitations."
1799 msgstr ""
1801 #. type: Content of: <book><preface><sect1><para>
1802 #: ../en/ch00-preface.xml:188
1803 msgid ""
1804 "The first generation began by managing single files on individual computers. "
1805 "Although these tools represented a huge advance over ad-hoc manual revision "
1806 "control, their locking model and reliance on a single computer limited them "
1807 "to small, tightly-knit teams."
1808 msgstr ""
1810 #. type: Content of: <book><preface><sect1><para>
1811 #: ../en/ch00-preface.xml:194
1812 msgid ""
1813 "The second generation loosened these constraints by moving to network-"
1814 "centered architectures, and managing entire projects at a time. As projects "
1815 "grew larger, they ran into new problems. With clients needing to talk to "
1816 "servers very frequently, server scaling became an issue for large projects. "
1817 "An unreliable network connection could prevent remote users from being able "
1818 "to talk to the server at all. As open source projects started making read-"
1819 "only access available anonymously to anyone, people without commit privileges "
1820 "found that they could not use the tools to interact with a project in a "
1821 "natural way, as they could not record their changes."
1822 msgstr ""
1824 #. type: Content of: <book><preface><sect1><para>
1825 #: ../en/ch00-preface.xml:206
1826 msgid ""
1827 "The current generation of revision control tools is peer-to-peer in nature. "
1828 "All of these systems have dropped the dependency on a single central server, "
1829 "and allow people to distribute their revision control data to where it's "
1830 "actually needed. Collaboration over the Internet has moved from constrained "
1831 "by technology to a matter of choice and consensus. Modern tools can operate "
1832 "offline indefinitely and autonomously, with a network connection only needed "
1833 "when syncing changes with another repository."
1834 msgstr ""
1836 #. type: Content of: <book><preface><sect1><title>
1837 #: ../en/ch00-preface.xml:218
1838 msgid "A few of the advantages of distributed revision control"
1839 msgstr "分布版本控制的优点"
1841 #. type: Content of: <book><preface><sect1><para>
1842 #: ../en/ch00-preface.xml:221
1843 msgid ""
1844 "Even though distributed revision control tools have for several years been as "
1845 "robust and usable as their previous-generation counterparts, people using "
1846 "older tools have not yet necessarily woken up to their advantages. There are "
1847 "a number of ways in which distributed tools shine relative to centralised "
1848 "ones."
1849 msgstr ""
1851 #. type: Content of: <book><preface><sect1><para>
1852 #: ../en/ch00-preface.xml:228
1853 msgid ""
1854 "For an individual developer, distributed tools are almost always much faster "
1855 "than centralised tools. This is for a simple reason: a centralised tool "
1856 "needs to talk over the network for many common operations, because most "
1857 "metadata is stored in a single copy on the central server. A distributed "
1858 "tool stores all of its metadata locally. All else being equal, talking over "
1859 "the network adds overhead to a centralised tool. Don't underestimate the "
1860 "value of a snappy, responsive tool: you're going to spend a lot of time "
1861 "interacting with your revision control software."
1862 msgstr ""
1864 #. type: Content of: <book><preface><sect1><para>
1865 #: ../en/ch00-preface.xml:239
1866 msgid ""
1867 "Distributed tools are indifferent to the vagaries of your server "
1868 "infrastructure, again because they replicate metadata to so many locations. "
1869 "If you use a centralised system and your server catches fire, you'd better "
1870 "hope that your backup media are reliable, and that your last backup was "
1871 "recent and actually worked. With a distributed tool, you have many backups "
1872 "available on every contributor's computer."
1873 msgstr ""
1875 #. type: Content of: <book><preface><sect1><para>
1876 #: ../en/ch00-preface.xml:247
1877 msgid ""
1878 "The reliability of your network will affect distributed tools far less than "
1879 "it will centralised tools. You can't even use a centralised tool without a "
1880 "network connection, except for a few highly constrained commands. With a "
1881 "distributed tool, if your network connection goes down while you're working, "
1882 "you may not even notice. The only thing you won't be able to do is talk to "
1883 "repositories on other computers, something that is relatively rare compared "
1884 "with local operations. If you have a far-flung team of collaborators, this "
1885 "may be significant."
1886 msgstr ""
1888 #. type: Content of: <book><preface><sect1><sect2><title>
1889 #: ../en/ch00-preface.xml:258
1890 msgid "Advantages for open source projects"
1891 msgstr "开源项目的优点"
1893 #. type: Content of: <book><preface><sect1><sect2><para>
1894 #: ../en/ch00-preface.xml:260
1895 msgid ""
1896 "If you take a shine to an open source project and decide that you would like "
1897 "to start hacking on it, and that project uses a distributed revision control "
1898 "tool, you are at once a peer with the people who consider themselves the "
1899 "<quote>core</quote> of that project. If they publish their repositories, you "
1900 "can immediately copy their project history, start making changes, and record "
1901 "your work, using the same tools in the same ways as insiders. By contrast, "
1902 "with a centralised tool, you must use the software in a <quote>read only</"
1903 "quote> mode unless someone grants you permission to commit changes to their "
1904 "central server. Until then, you won't be able to record changes, and your "
1905 "local modifications will be at risk of corruption any time you try to update "
1906 "your client's view of the repository."
1907 msgstr ""
1909 #. type: Content of: <book><preface><sect1><sect2><sect3><title>
1910 #: ../en/ch00-preface.xml:276
1911 msgid "The forking non-problem"
1912 msgstr "分叉不是问题"
1914 #. type: Content of: <book><preface><sect1><sect2><sect3><para>
1915 #: ../en/ch00-preface.xml:278
1916 msgid ""
1917 "It has been suggested that distributed revision control tools pose some sort "
1918 "of risk to open source projects because they make it easy to <quote>fork</"
1919 "quote> the development of a project. A fork happens when there are "
1920 "differences in opinion or attitude between groups of developers that cause "
1921 "them to decide that they can't work together any longer. Each side takes a "
1922 "more or less complete copy of the project's source code, and goes off in its "
1923 "own direction."
1924 msgstr ""
1926 #. type: Content of: <book><preface><sect1><sect2><sect3><para>
1927 #: ../en/ch00-preface.xml:288
1928 msgid ""
1929 "Sometimes the camps in a fork decide to reconcile their differences. With a "
1930 "centralised revision control system, the <emphasis>technical</emphasis> "
1931 "process of reconciliation is painful, and has to be performed largely by "
1932 "hand. You have to decide whose revision history is going to <quote>win</"
1933 "quote>, and graft the other team's changes into the tree somehow. This "
1934 "usually loses some or all of one side's revision history."
1935 msgstr ""
1937 #. type: Content of: <book><preface><sect1><sect2><sect3><para>
1938 #: ../en/ch00-preface.xml:297
1939 msgid ""
1940 "What distributed tools do with respect to forking is they make forking the "
1941 "<emphasis>only</emphasis> way to develop a project. Every single change that "
1942 "you make is potentially a fork point. The great strength of this approach is "
1943 "that a distributed revision control tool has to be really good at "
1944 "<emphasis>merging</emphasis> forks, because forks are absolutely fundamental: "
1945 "they happen all the time."
1946 msgstr ""
1948 #. type: Content of: <book><preface><sect1><sect2><sect3><para>
1949 #: ../en/ch00-preface.xml:306
1950 msgid ""
1951 "If every piece of work that everybody does, all the time, is framed in terms "
1952 "of forking and merging, then what the open source world refers to as a "
1953 "<quote>fork</quote> becomes <emphasis>purely</emphasis> a social issue. If "
1954 "anything, distributed tools <emphasis>lower</emphasis> the likelihood of a "
1955 "fork:"
1956 msgstr ""
1958 #. type: Content of: <book><preface><sect1><sect2><sect3><itemizedlist><listitem><para>
1959 #: ../en/ch00-preface.xml:313
1960 msgid ""
1961 "They eliminate the social distinction that centralised tools impose: that "
1962 "between insiders (people with commit access) and outsiders (people without)."
1963 msgstr ""
1965 #. type: Content of: <book><preface><sect1><sect2><sect3><itemizedlist><listitem><para>
1966 #: ../en/ch00-preface.xml:317
1967 msgid ""
1968 "They make it easier to reconcile after a social fork, because all that's "
1969 "involved from the perspective of the revision control software is just "
1970 "another merge."
1971 msgstr ""
1973 #. type: Content of: <book><preface><sect1><sect2><sect3><para>
1974 #: ../en/ch00-preface.xml:322
1975 msgid ""
1976 "Some people resist distributed tools because they want to retain tight "
1977 "control over their projects, and they believe that centralised tools give "
1978 "them this control. However, if you're of this belief, and you publish your "
1979 "CVS or Subversion repositories publicly, there are plenty of tools available "
1980 "that can pull out your entire project's history (albeit slowly) and recreate "
1981 "it somewhere that you don't control. So while your control in this case is "
1982 "illusory, you are forgoing the ability to fluidly collaborate with whatever "
1983 "people feel compelled to mirror and fork your history."
1984 msgstr ""
1986 #. type: Content of: <book><preface><sect1><sect2><title>
1987 #: ../en/ch00-preface.xml:337
1988 msgid "Advantages for commercial projects"
1989 msgstr "商业项目的优点"
1991 #. type: Content of: <book><preface><sect1><sect2><para>
1992 #: ../en/ch00-preface.xml:339
1993 msgid ""
1994 "Many commercial projects are undertaken by teams that are scattered across "
1995 "the globe. Contributors who are far from a central server will see slower "
1996 "command execution and perhaps less reliability. Commercial revision control "
1997 "systems attempt to ameliorate these problems with remote-site replication add-"
1998 "ons that are typically expensive to buy and cantankerous to administer. A "
1999 "distributed system doesn't suffer from these problems in the first place. "
2000 "Better yet, you can easily set up multiple authoritative servers, say one per "
2001 "site, so that there's no redundant communication between repositories over "
2002 "expensive long-haul network links."
2003 msgstr ""
2005 #. type: Content of: <book><preface><sect1><sect2><para>
2006 #: ../en/ch00-preface.xml:351
2007 msgid ""
2008 "Centralised revision control systems tend to have relatively low "
2009 "scalability. It's not unusual for an expensive centralised system to fall "
2010 "over under the combined load of just a few dozen concurrent users. Once "
2011 "again, the typical response tends to be an expensive and clunky replication "
2012 "facility. Since the load on a central server---if you have one at all---is "
2013 "many times lower with a distributed tool (because all of the data is "
2014 "replicated everywhere), a single cheap server can handle the needs of a much "
2015 "larger team, and replication to balance load becomes a simple matter of "
2016 "scripting."
2017 msgstr ""
2019 #. type: Content of: <book><preface><sect1><sect2><para>
2020 #: ../en/ch00-preface.xml:363
2021 msgid ""
2022 "If you have an employee in the field, troubleshooting a problem at a "
2023 "customer's site, they'll benefit from distributed revision control. The tool "
2024 "will let them generate custom builds, try different fixes in isolation from "
2025 "each other, and search efficiently through history for the sources of bugs "
2026 "and regressions in the customer's environment, all without needing to connect "
2027 "to your company's network."
2028 msgstr ""
2030 #. type: Content of: <book><preface><sect1><title>
2031 #: ../en/ch00-preface.xml:374
2032 msgid "Why choose Mercurial?"
2033 msgstr "为什么选择 Mercurial?"
2035 #. type: Content of: <book><preface><sect1><para>
2036 #: ../en/ch00-preface.xml:376
2037 msgid ""
2038 "Mercurial has a unique set of properties that make it a particularly good "
2039 "choice as a revision control system."
2040 msgstr ""
2042 #. type: Content of: <book><preface><sect1><itemizedlist><listitem><para>
2043 #: ../en/ch00-preface.xml:379
2044 msgid "It is easy to learn and use."
2045 msgstr ""
2047 #. type: Content of: <book><preface><sect1><itemizedlist><listitem><para>
2048 #: ../en/ch00-preface.xml:380
2049 msgid "It is lightweight."
2050 msgstr ""
2052 #. type: Content of: <book><preface><sect1><itemizedlist><listitem><para>
2053 #: ../en/ch00-preface.xml:381
2054 msgid "It scales excellently."
2055 msgstr ""
2057 #. type: Content of: <book><preface><sect1><itemizedlist><listitem><para>
2058 #: ../en/ch00-preface.xml:382
2059 msgid "It is easy to customise."
2060 msgstr ""
2062 #. type: Content of: <book><preface><sect1><para>
2063 #: ../en/ch00-preface.xml:385
2064 msgid ""
2065 "If you are at all familiar with revision control systems, you should be able "
2066 "to get up and running with Mercurial in less than five minutes. Even if not, "
2067 "it will take no more than a few minutes longer. Mercurial's command and "
2068 "feature sets are generally uniform and consistent, so you can keep track of a "
2069 "few general rules instead of a host of exceptions."
2070 msgstr ""
2072 #. type: Content of: <book><preface><sect1><para>
2073 #: ../en/ch00-preface.xml:392
2074 msgid ""
2075 "On a small project, you can start working with Mercurial in moments. Creating "
2076 "new changes and branches; transferring changes around (whether locally or "
2077 "over a network); and history and status operations are all fast. Mercurial "
2078 "attempts to stay nimble and largely out of your way by combining low "
2079 "cognitive overhead with blazingly fast operations."
2080 msgstr ""
2082 #. type: Content of: <book><preface><sect1><para>
2083 #: ../en/ch00-preface.xml:399
2084 msgid ""
2085 "The usefulness of Mercurial is not limited to small projects: it is used by "
2086 "projects with hundreds to thousands of contributors, each containing tens of "
2087 "thousands of files and hundreds of megabytes of source code."
2088 msgstr ""
2090 #. type: Content of: <book><preface><sect1><para>
2091 #: ../en/ch00-preface.xml:404
2092 msgid ""
2093 "If the core functionality of Mercurial is not enough for you, it's easy to "
2094 "build on. Mercurial is well suited to scripting tasks, and its clean "
2095 "internals and implementation in Python make it easy to add features in the "
2096 "form of extensions. There are a number of popular and useful extensions "
2097 "already available, ranging from helping to identify bugs to improving "
2098 "performance."
2099 msgstr ""
2101 #. type: Content of: <book><preface><sect1><title>
2102 #: ../en/ch00-preface.xml:414
2103 msgid "Mercurial compared with other tools"
2104 msgstr "Mercurial 与其它工具的比较"
2106 #. type: Content of: <book><preface><sect1><para>
2107 #: ../en/ch00-preface.xml:416
2108 msgid ""
2109 "Before you read on, please understand that this section necessarily reflects "
2110 "my own experiences, interests, and (dare I say it) biases. I have used every "
2111 "one of the revision control tools listed below, in most cases for several "
2112 "years at a time."
2113 msgstr ""
2115 #. type: Content of: <book><preface><sect1><itemizedlist><listitem><para>
2116 #: ../en/ch00-preface.xml:424 ../en/ch00-preface.xml:635
2117 msgid "Subversion"
2118 msgstr ""
2120 #. type: Content of: <book><preface><sect1><sect2><para>
2121 #: ../en/ch00-preface.xml:426
2122 msgid ""
2123 "Subversion is a popular revision control tool, developed to replace CVS. It "
2124 "has a centralised client/server architecture."
2125 msgstr ""
2127 #. type: Content of: <book><preface><sect1><sect2><para>
2128 #: ../en/ch00-preface.xml:430
2129 msgid ""
2130 "Subversion and Mercurial have similarly named commands for performing the "
2131 "same operations, so if you're familiar with one, it is easy to learn to use "
2132 "the other. Both tools are portable to all popular operating systems."
2133 msgstr ""
2135 #. type: Content of: <book><preface><sect1><sect2><para>
2136 #: ../en/ch00-preface.xml:435
2137 msgid ""
2138 "Prior to version 1.5, Subversion had no useful support for merges. At the "
2139 "time of writing, its merge tracking capability is new, and known to be <ulink "
2140 "url=\"http://svnbook.red-bean.com/nightly/en/svn.branchmerge.advanced."
2141 "html#svn.branchmerge.advanced.finalword\">complicated and buggy</ulink>."
2142 msgstr ""
2144 #. type: Content of: <book><preface><sect1><sect2><para>
2145 #: ../en/ch00-preface.xml:441
2146 msgid ""
2147 "Mercurial has a substantial performance advantage over Subversion on every "
2148 "revision control operation I have benchmarked. I have measured its advantage "
2149 "as ranging from a factor of two to a factor of six when compared with "
2150 "Subversion 1.4.3's <emphasis>ra_local</emphasis> file store, which is the "
2151 "fastest access method available. In more realistic deployments involving a "
2152 "network-based store, Subversion will be at a substantially larger "
2153 "disadvantage. Because many Subversion commands must talk to the server and "
2154 "Subversion does not have useful replication facilities, server capacity and "
2155 "network bandwidth become bottlenecks for modestly large projects."
2156 msgstr ""
2158 #. type: Content of: <book><preface><sect1><sect2><para>
2159 #: ../en/ch00-preface.xml:454
2160 msgid ""
2161 "Additionally, Subversion incurs substantial storage overhead to avoid network "
2162 "transactions for a few common operations, such as finding modified files "
2163 "(<literal>status</literal>) and displaying modifications against the current "
2164 "revision (<literal>diff</literal>). As a result, a Subversion working copy "
2165 "is often the same size as, or larger than, a Mercurial repository and working "
2166 "directory, even though the Mercurial repository contains a complete history "
2167 "of the project."
2168 msgstr ""
2170 #. type: Content of: <book><preface><sect1><sect2><para>
2171 #: ../en/ch00-preface.xml:464
2172 msgid ""
2173 "Subversion is widely supported by third party tools. Mercurial currently "
2174 "lags considerably in this area. This gap is closing, however, and indeed "
2175 "some of Mercurial's GUI tools now outshine their Subversion equivalents. "
2176 "Like Mercurial, Subversion has an excellent user manual."
2177 msgstr ""
2179 #. type: Content of: <book><preface><sect1><sect2><para>
2180 #: ../en/ch00-preface.xml:470
2181 msgid ""
2182 "Because Subversion doesn't store revision history on the client, it is well "
2183 "suited to managing projects that deal with lots of large, opaque binary "
2184 "files. If you check in fifty revisions to an incompressible 10MB file, "
2185 "Subversion's client-side space usage stays constant The space used by any "
2186 "distributed SCM will grow rapidly in proportion to the number of revisions, "
2187 "because the differences between each revision are large."
2188 msgstr ""
2190 #. type: Content of: <book><preface><sect1><sect2><para>
2191 #: ../en/ch00-preface.xml:479
2192 msgid ""
2193 "In addition, it's often difficult or, more usually, impossible to merge "
2194 "different versions of a binary file. Subversion's ability to let a user lock "
2195 "a file, so that they temporarily have the exclusive right to commit changes "
2196 "to it, can be a significant advantage to a project where binary files are "
2197 "widely used."
2198 msgstr ""
2200 #. type: Content of: <book><preface><sect1><sect2><para>
2201 #: ../en/ch00-preface.xml:486
2202 msgid ""
2203 "Mercurial can import revision history from a Subversion repository. It can "
2204 "also export revision history to a Subversion repository. This makes it easy "
2205 "to <quote>test the waters</quote> and use Mercurial and Subversion in "
2206 "parallel before deciding to switch. History conversion is incremental, so "
2207 "you can perform an initial conversion, then small additional conversions "
2208 "afterwards to bring in new changes."
2209 msgstr ""
2211 #. type: Content of: <book><preface><sect1><itemizedlist><listitem><para>
2212 #: ../en/ch00-preface.xml:498 ../en/ch00-preface.xml:637
2213 msgid "Git"
2214 msgstr ""
2216 #. type: Content of: <book><preface><sect1><sect2><para>
2217 #: ../en/ch00-preface.xml:500
2218 msgid ""
2219 "Git is a distributed revision control tool that was developed for managing "
2220 "the Linux kernel source tree. Like Mercurial, its early design was somewhat "
2221 "influenced by Monotone."
2222 msgstr ""
2224 #. type: Content of: <book><preface><sect1><sect2><para>
2225 #: ../en/ch00-preface.xml:505
2226 msgid ""
2227 "Git has a very large command set, with version 1.5.0 providing 139 individual "
2228 "commands. It has something of a reputation for being difficult to learn. "
2229 "Compared to Git, Mercurial has a strong focus on simplicity."
2230 msgstr ""
2232 #. type: Content of: <book><preface><sect1><sect2><para>
2233 #: ../en/ch00-preface.xml:510
2234 msgid ""
2235 "In terms of performance, Git is extremely fast. In several cases, it is "
2236 "faster than Mercurial, at least on Linux, while Mercurial performs better on "
2237 "other operations. However, on Windows, the performance and general level of "
2238 "support that Git provides is, at the time of writing, far behind that of "
2239 "Mercurial."
2240 msgstr ""
2242 #. type: Content of: <book><preface><sect1><sect2><para>
2243 #: ../en/ch00-preface.xml:517
2244 msgid ""
2245 "While a Mercurial repository needs no maintenance, a Git repository requires "
2246 "frequent manual <quote>repacks</quote> of its metadata. Without these, "
2247 "performance degrades, while space usage grows rapidly. A server that "
2248 "contains many Git repositories that are not rigorously and frequently "
2249 "repacked will become heavily disk-bound during backups, and there have been "
2250 "instances of daily backups taking far longer than 24 hours as a result. A "
2251 "freshly packed Git repository is slightly smaller than a Mercurial "
2252 "repository, but an unpacked repository is several orders of magnitude larger."
2253 msgstr ""
2255 #. type: Content of: <book><preface><sect1><sect2><para>
2256 #: ../en/ch00-preface.xml:528
2257 msgid ""
2258 "The core of Git is written in C. Many Git commands are implemented as shell "
2259 "or Perl scripts, and the quality of these scripts varies widely. I have "
2260 "encountered several instances where scripts charged along blindly in the "
2261 "presence of errors that should have been fatal."
2262 msgstr ""
2264 #. type: Content of: <book><preface><sect1><sect2><para>
2265 #: ../en/ch00-preface.xml:534
2266 msgid "Mercurial can import revision history from a Git repository."
2267 msgstr ""
2269 #. type: Content of: <book><preface><sect1><itemizedlist><listitem><para>
2270 #: ../en/ch00-preface.xml:540 ../en/ch00-preface.xml:636
2271 msgid "CVS"
2272 msgstr ""
2274 #. type: Content of: <book><preface><sect1><sect2><para>
2275 #: ../en/ch00-preface.xml:542
2276 msgid ""
2277 "CVS is probably the most widely used revision control tool in the world. Due "
2278 "to its age and internal untidiness, it has been only lightly maintained for "
2279 "many years."
2280 msgstr ""
2282 #. type: Content of: <book><preface><sect1><sect2><para>
2283 #: ../en/ch00-preface.xml:546
2284 msgid ""
2285 "It has a centralised client/server architecture. It does not group related "
2286 "file changes into atomic commits, making it easy for people to <quote>break "
2287 "the build</quote>: one person can successfully commit part of a change and "
2288 "then be blocked by the need for a merge, causing other people to see only a "
2289 "portion of the work they intended to do. This also affects how you work with "
2290 "project history. If you want to see all of the modifications someone made as "
2291 "part of a task, you will need to manually inspect the descriptions and "
2292 "timestamps of the changes made to each file involved (if you even know what "
2293 "those files were)."
2294 msgstr ""
2296 #. type: Content of: <book><preface><sect1><sect2><para>
2297 #: ../en/ch00-preface.xml:558
2298 msgid ""
2299 "CVS has a muddled notion of tags and branches that I will not attempt to even "
2300 "describe. It does not support renaming of files or directories well, making "
2301 "it easy to corrupt a repository. It has almost no internal consistency "
2302 "checking capabilities, so it is usually not even possible to tell whether or "
2303 "how a repository is corrupt. I would not recommend CVS for any project, "
2304 "existing or new."
2305 msgstr ""
2307 #. type: Content of: <book><preface><sect1><sect2><para>
2308 #: ../en/ch00-preface.xml:566
2309 msgid ""
2310 "Mercurial can import CVS revision history. However, there are a few caveats "
2311 "that apply; these are true of every other revision control tool's CVS "
2312 "importer, too. Due to CVS's lack of atomic changes and unversioned "
2313 "filesystem hierarchy, it is not possible to reconstruct CVS history "
2314 "completely accurately; some guesswork is involved, and renames will usually "
2315 "not show up. Because a lot of advanced CVS administration has to be done by "
2316 "hand and is hence error-prone, it's common for CVS importers to run into "
2317 "multiple problems with corrupted repositories (completely bogus revision "
2318 "timestamps and files that have remained locked for over a decade are just two "
2319 "of the less interesting problems I can recall from personal experience)."
2320 msgstr ""
2322 #. type: Content of: <book><preface><sect1><sect2><para>
2323 #: ../en/ch00-preface.xml:580
2324 msgid "Mercurial can import revision history from a CVS repository."
2325 msgstr ""
2327 #. type: Content of: <book><preface><sect1><sect2><title>
2328 #: ../en/ch00-preface.xml:586
2329 msgid "Commercial tools"
2330 msgstr "商业工具"
2332 #. type: Content of: <book><preface><sect1><sect2><para>
2333 #: ../en/ch00-preface.xml:588
2334 msgid ""
2335 "Perforce has a centralised client/server architecture, with no client-side "
2336 "caching of any data. Unlike modern revision control tools, Perforce requires "
2337 "that a user run a command to inform the server about every file they intend "
2338 "to edit."
2339 msgstr ""
2341 #. type: Content of: <book><preface><sect1><sect2><para>
2342 #: ../en/ch00-preface.xml:594
2343 msgid ""
2344 "The performance of Perforce is quite good for small teams, but it falls off "
2345 "rapidly as the number of users grows beyond a few dozen. Modestly large "
2346 "Perforce installations require the deployment of proxies to cope with the "
2347 "load their users generate."
2348 msgstr ""
2350 #. type: Content of: <book><preface><sect1><sect2><title>
2351 #: ../en/ch00-preface.xml:603
2352 msgid "Choosing a revision control tool"
2353 msgstr "选择版本控制工具"
2355 #. type: Content of: <book><preface><sect1><sect2><para>
2356 #: ../en/ch00-preface.xml:605
2357 msgid ""
2358 "With the exception of CVS, all of the tools listed above have unique "
2359 "strengths that suit them to particular styles of work. There is no single "
2360 "revision control tool that is best in all situations."
2361 msgstr ""
2363 #. type: Content of: <book><preface><sect1><sect2><para>
2364 #: ../en/ch00-preface.xml:610
2365 msgid ""
2366 "As an example, Subversion is a good choice for working with frequently edited "
2367 "binary files, due to its centralised nature and support for file locking."
2368 msgstr ""
2370 #. type: Content of: <book><preface><sect1><sect2><para>
2371 #: ../en/ch00-preface.xml:614
2372 msgid ""
2373 "I personally find Mercurial's properties of simplicity, performance, and good "
2374 "merge support to be a compelling combination that has served me well for "
2375 "several years."
2376 msgstr ""
2378 #. type: Content of: <book><preface><sect1><title>
2379 #: ../en/ch00-preface.xml:622
2380 msgid "Switching from another tool to Mercurial"
2381 msgstr "从其它工具切换到 Mercurial"
2383 #. type: Content of: <book><preface><sect1><para>
2384 #: ../en/ch00-preface.xml:624
2385 msgid ""
2386 "Mercurial is bundled with an extension named <literal role=\"hg-ext"
2387 "\">convert</literal>, which can incrementally import revision history from "
2388 "several other revision control tools. By <quote>incremental</quote>, I mean "
2389 "that you can convert all of a project's history to date in one go, then rerun "
2390 "the conversion later to obtain new changes that happened after the initial "
2391 "conversion."
2392 msgstr ""
2394 #. type: Content of: <book><preface><sect1><para>
2395 #: ../en/ch00-preface.xml:632
2396 msgid ""
2397 "The revision control tools supported by <literal role=\"hg-ext\">convert</"
2398 "literal> are as follows:"
2399 msgstr "<literal role=\"hg-ext\">convert</literal> 支持的版本控制工具有:"
2401 #. type: Content of: <book><preface><sect1><itemizedlist><listitem><para>
2402 #: ../en/ch00-preface.xml:638
2403 msgid "Darcs"
2404 msgstr ""
2406 #. type: Content of: <book><preface><sect1><para>
2407 #: ../en/ch00-preface.xml:640
2408 msgid ""
2409 "In addition, <literal role=\"hg-ext\">convert</literal> can export changes "
2410 "from Mercurial to Subversion. This makes it possible to try Subversion and "
2411 "Mercurial in parallel before committing to a switchover, without risking the "
2412 "loss of any work."
2413 msgstr ""
2415 #. type: Content of: <book><preface><sect1><para>
2416 #: ../en/ch00-preface.xml:646
2417 msgid ""
2418 "The <command role=\"hg-ext-convert\">convert</command> command is easy to "
2419 "use. Simply point it at the path or URL of the source repository, optionally "
2420 "give it the name of the destination repository, and it will start working. "
2421 "After the initial conversion, just run the same command again to import new "
2422 "changes."
2423 msgstr ""
2425 #. type: Content of: <book><preface><sect1><title>
2426 #: ../en/ch00-preface.xml:655
2427 msgid "A short history of revision control"
2428 msgstr "版本控制简史"
2430 #. type: Content of: <book><preface><sect1><para>
2431 #: ../en/ch00-preface.xml:657
2432 msgid ""
2433 "The best known of the old-time revision control tools is SCCS (Source Code "
2434 "Control System), which Marc Rochkind wrote at Bell Labs, in the early 1970s. "
2435 "SCCS operated on individual files, and required every person working on a "
2436 "project to have access to a shared workspace on a single system. Only one "
2437 "person could modify a file at any time; arbitration for access to files was "
2438 "via locks. It was common for people to lock files, and later forget to "
2439 "unlock them, preventing anyone else from modifying those files without the "
2440 "help of an administrator."
2441 msgstr ""
2443 #. type: Content of: <book><preface><sect1><para>
2444 #: ../en/ch00-preface.xml:668
2445 msgid ""
2446 "Walter Tichy developed a free alternative to SCCS in the early 1980s; he "
2447 "called his program RCS (Revision Control System). Like SCCS, RCS required "
2448 "developers to work in a single shared workspace, and to lock files to prevent "
2449 "multiple people from modifying them simultaneously."
2450 msgstr ""
2452 #. type: Content of: <book><preface><sect1><para>
2453 #: ../en/ch00-preface.xml:674
2454 msgid ""
2455 "Later in the 1980s, Dick Grune used RCS as a building block for a set of "
2456 "shell scripts he initially called cmt, but then renamed to CVS (Concurrent "
2457 "Versions System). The big innovation of CVS was that it let developers work "
2458 "simultaneously and somewhat independently in their own personal workspaces. "
2459 "The personal workspaces prevented developers from stepping on each other's "
2460 "toes all the time, as was common with SCCS and RCS. Each developer had a copy "
2461 "of every project file, and could modify their copies independently. They had "
2462 "to merge their edits prior to committing changes to the central repository."
2463 msgstr ""
2465 #. type: Content of: <book><preface><sect1><para>
2466 #: ../en/ch00-preface.xml:685
2467 msgid ""
2468 "Brian Berliner took Grune's original scripts and rewrote them in C, releasing "
2469 "in 1989 the code that has since developed into the modern version of CVS. "
2470 "CVS subsequently acquired the ability to operate over a network connection, "
2471 "giving it a client/server architecture. CVS's architecture is centralised; "
2472 "only the server has a copy of the history of the project. Client workspaces "
2473 "just contain copies of recent versions of the project's files, and a little "
2474 "metadata to tell them where the server is. CVS has been enormously "
2475 "successful; it is probably the world's most widely used revision control "
2476 "system."
2477 msgstr ""
2479 #. type: Content of: <book><preface><sect1><para>
2480 #: ../en/ch00-preface.xml:696
2481 msgid ""
2482 "In the early 1990s, Sun Microsystems developed an early distributed revision "
2483 "control system, called TeamWare. A TeamWare workspace contains a complete "
2484 "copy of the project's history. TeamWare has no notion of a central "
2485 "repository. (CVS relied upon RCS for its history storage; TeamWare used "
2486 "SCCS.)"
2487 msgstr ""
2489 #. type: Content of: <book><preface><sect1><para>
2490 #: ../en/ch00-preface.xml:703
2491 msgid ""
2492 "As the 1990s progressed, awareness grew of a number of problems with CVS. It "
2493 "records simultaneous changes to multiple files individually, instead of "
2494 "grouping them together as a single logically atomic operation. It does not "
2495 "manage its file hierarchy well; it is easy to make a mess of a repository by "
2496 "renaming files and directories. Worse, its source code is difficult to read "
2497 "and maintain, which made the <quote>pain level</quote> of fixing these "
2498 "architectural problems prohibitive."
2499 msgstr ""
2501 #. type: Content of: <book><preface><sect1><para>
2502 #: ../en/ch00-preface.xml:713
2503 msgid ""
2504 "In 2001, Jim Blandy and Karl Fogel, two developers who had worked on CVS, "
2505 "started a project to replace it with a tool that would have a better "
2506 "architecture and cleaner code. The result, Subversion, does not stray from "
2507 "CVS's centralised client/server model, but it adds multi-file atomic commits, "
2508 "better namespace management, and a number of other features that make it a "
2509 "generally better tool than CVS. Since its initial release, it has rapidly "
2510 "grown in popularity."
2511 msgstr ""
2513 #. type: Content of: <book><preface><sect1><para>
2514 #: ../en/ch00-preface.xml:722
2515 msgid ""
2516 "More or less simultaneously, Graydon Hoare began working on an ambitious "
2517 "distributed revision control system that he named Monotone. While Monotone "
2518 "addresses many of CVS's design flaws and has a peer-to-peer architecture, it "
2519 "goes beyond earlier (and subsequent) revision control tools in a number of "
2520 "innovative ways. It uses cryptographic hashes as identifiers, and has an "
2521 "integral notion of <quote>trust</quote> for code from different sources."
2522 msgstr ""
2524 #. type: Content of: <book><preface><sect1><para>
2525 #: ../en/ch00-preface.xml:731
2526 msgid ""
2527 "Mercurial began life in 2005. While a few aspects of its design are "
2528 "influenced by Monotone, Mercurial focuses on ease of use, high performance, "
2529 "and scalability to very large projects."
2530 msgstr ""
2532 #. type: Content of: <book><preface><sect1><title>
2533 #: ../en/ch00-preface.xml:739
2534 msgid "Colophon&emdash;this book is Free"
2535 msgstr "后记&emdash;本书是自由的!"
2537 #. type: Content of: <book><preface><sect1><para>
2538 #: ../en/ch00-preface.xml:741
2539 msgid ""
2540 "This book is licensed under the Open Publication License, and is produced "
2541 "entirely using Free Software tools. It is typeset with DocBook XML. "
2542 "Illustrations are drawn and rendered with <ulink url=\"http://www.inkscape."
2543 "org/\">Inkscape</ulink>."
2544 msgstr ""
2546 #. type: Content of: <book><preface><sect1><para>
2547 #: ../en/ch00-preface.xml:746
2548 msgid ""
2549 "The complete source code for this book is published as a Mercurial "
2550 "repository, at <ulink url=\"http://hg.serpentine.com/mercurial/book\">http://"
2551 "hg.serpentine.com/mercurial/book</ulink>."
2552 msgstr ""
2554 #. type: Content of: <book><chapter><title>
2555 #: ../en/ch01-tour-basic.xml:5
2556 msgid "A tour of Mercurial: the basics"
2557 msgstr "Mercurial 教程: 基础知识"
2559 #. type: Content of: <book><chapter><sect1><title>
2560 #: ../en/ch01-tour-basic.xml:8
2561 msgid "Installing Mercurial on your system"
2562 msgstr "安装 Mercurial"
2564 #. type: Content of: <book><chapter><sect1><para>
2565 #: ../en/ch01-tour-basic.xml:10
2566 msgid ""
2567 "Prebuilt binary packages of Mercurial are available for every popular "
2568 "operating system. These make it easy to start using Mercurial on your "
2569 "computer immediately."
2570 msgstr ""
2571 "对于每种流行的操作系统,都有已经构建的二进制软件包。这让在你的计算机上开始使"
2572 "用 Mercurial 变得很容易。"
2574 #. type: Content of: <book><chapter><sect1><sect2><title>
2575 #: ../en/ch01-tour-basic.xml:15
2576 msgid "Linux"
2577 msgstr "Linux"
2579 #. type: Content of: <book><chapter><sect1><sect2><para>
2580 #: ../en/ch01-tour-basic.xml:17
2581 msgid ""
2582 "Because each Linux distribution has its own packaging tools, policies, and "
2583 "rate of development, it's difficult to give a comprehensive set of "
2584 "instructions on how to install Mercurial binaries. The version of Mercurial "
2585 "that you will end up with can vary depending on how active the person is who "
2586 "maintains the package for your distribution."
2587 msgstr ""
2588 "由于每种 Linux 发行版都有自己的包管理工具,开发策略和进度,从而很难给出安装 "
2589 "Mercurial 二进制包的全面说明。你安装的 Mercurial 版本,在很大程度上依赖于你所"
2590 "使用的发行版的 Mercurial 维护者的活跃程度。"
2592 #. type: Content of: <book><chapter><sect1><sect2><para>
2593 #: ../en/ch01-tour-basic.xml:24
2594 msgid ""
2595 "To keep things simple, I will focus on installing Mercurial from the command "
2596 "line under the most popular Linux distributions. Most of these distributions "
2597 "provide graphical package managers that will let you install Mercurial with a "
2598 "single click; the package name to look for is <literal>mercurial</literal>."
2599 msgstr ""
2600 "为了让事情简单,我会致力于说明在最流行的 Linux 发行版中,从命令行安装 "
2601 "Mercurial 的方法。这些发行版都提供了图形界面的包管理器,让你通过点击鼠标安装 "
2602 "Mercurial;寻找的包名称是 <literal>mercurial</literal>。"
2604 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2605 #: ../en/ch01-tour-basic.xml:32
2606 msgid "Debian:"
2607 msgstr "Debian:"
2609 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2610 #: ../en/ch01-tour-basic.xml:34
2611 msgid "Fedora Core:"
2612 msgstr "Fedora Core:"
2614 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2615 #: ../en/ch01-tour-basic.xml:36
2616 msgid "Gentoo:"
2617 msgstr "Gentoo:"
2619 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2620 #: ../en/ch01-tour-basic.xml:38
2621 msgid "OpenSUSE:"
2622 msgstr "OpenSUSE:"
2624 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2625 #: ../en/ch01-tour-basic.xml:40
2626 msgid ""
2627 "Ubuntu: Ubuntu's Mercurial package is based on Debian's. To install it, run "
2628 "the following command."
2629 msgstr "Ubuntu: Ubuntu 的 Mercurial 包基于 Debian。安装时,使用如下命令:"
2631 #. type: Content of: <book><chapter><sect1><sect2><title>
2632 #: ../en/ch01-tour-basic.xml:48
2633 msgid "Solaris"
2634 msgstr "Solaris"
2636 #. type: Content of: <book><chapter><sect1><sect2><para>
2637 #: ../en/ch01-tour-basic.xml:50
2638 msgid ""
2639 "SunFreeWare, at <ulink url=\"http://www.sunfreeware.com\">http://www."
2640 "sunfreeware.com</ulink>, is a good source for a large number of pre-built "
2641 "Solaris packages for 32 and 64 bit Intel and Sparc architectures, including "
2642 "current versions of Mercurial."
2643 msgstr ""
2644 "位于 <ulink url=\"http://www.sunfreeware.com\">http://www.sunfreeware.com</"
2645 "ulink> 的 SunFreeWare 是很好的二进制安装源,它包含 Intel 和 Sparc 架构的 32 位"
2646 "和 64 位包,包含 Mercurial 的当前版本。"
2648 #. type: Content of: <book><chapter><sect1><sect2><title>
2649 #: ../en/ch01-tour-basic.xml:58
2650 msgid "Mac OS X"
2651 msgstr "Mac OS X"
2653 #. type: Content of: <book><chapter><sect1><sect2><para>
2654 #: ../en/ch01-tour-basic.xml:60
2655 msgid ""
2656 "Lee Cantey publishes an installer of Mercurial for Mac OS X at <ulink url="
2657 "\"http://mercurial.berkwood.com\">http://mercurial.berkwood.com</ulink>. "
2658 "This package works on both Intel- and Power-based Macs. Before you can use "
2659 "it, you must install a compatible version of Universal MacPython "
2660 "<citation>web:macpython</citation>. This is easy to do; simply follow the "
2661 "instructions on Lee's site."
2662 msgstr ""
2664 #. type: Content of: <book><chapter><sect1><sect2><para>
2665 #: ../en/ch01-tour-basic.xml:69
2666 msgid ""
2667 "It's also possible to install Mercurial using Fink or MacPorts, two popular "
2668 "free package managers for Mac OS X. If you have Fink, use <command>sudo apt-"
2669 "get install mercurial-py25</command>. If MacPorts, <command>sudo port "
2670 "install mercurial</command>."
2671 msgstr ""
2673 #. type: Content of: <book><chapter><sect1><sect2><title>
2674 #: ../en/ch01-tour-basic.xml:77
2675 msgid "Windows"
2676 msgstr ""
2678 #. type: Content of: <book><chapter><sect1><sect2><para>
2679 #: ../en/ch01-tour-basic.xml:79
2680 msgid ""
2681 "Lee Cantey publishes an installer of Mercurial for Windows at <ulink url="
2682 "\"http://mercurial.berkwood.com\">http://mercurial.berkwood.com</ulink>. "
2683 "This package has no external dependencies; it <quote>just works</quote>."
2684 msgstr ""
2686 #. type: Content of: <book><chapter><sect1><sect2><note><para>
2687 #: ../en/ch01-tour-basic.xml:86
2688 msgid ""
2689 "The Windows version of Mercurial does not automatically convert line endings "
2690 "between Windows and Unix styles. If you want to share work with Unix users, "
2691 "you must do a little additional configuration work. XXX Flesh this out."
2692 msgstr ""
2694 #. type: Content of: <book><chapter><sect1><title>
2695 #: ../en/ch01-tour-basic.xml:96
2696 msgid "Getting started"
2697 msgstr "开始"
2699 #. type: Content of: <book><chapter><sect1><para>
2700 #: ../en/ch01-tour-basic.xml:98
2701 msgid ""
2702 "To begin, we'll use the <command role=\"hg-cmd\">hg version</command> command "
2703 "to find out whether Mercurial is actually installed properly. The actual "
2704 "version information that it prints isn't so important; it's whether it prints "
2705 "anything at all that we care about."
2706 msgstr ""
2708 #. type: Content of: <book><chapter><sect1><sect2><title>
2709 #: ../en/ch01-tour-basic.xml:107
2710 msgid "Built-in help"
2711 msgstr "内置帮助"
2713 #. type: Content of: <book><chapter><sect1><sect2><para>
2714 #: ../en/ch01-tour-basic.xml:109
2715 msgid ""
2716 "Mercurial provides a built-in help system. This is invaluable for those "
2717 "times when you find yourself stuck trying to remember how to run a command. "
2718 "If you are completely stuck, simply run <command role=\"hg-cmd\">hg help</"
2719 "command>; it will print a brief list of commands, along with a description of "
2720 "what each does. If you ask for help on a specific command (as below), it "
2721 "prints more detailed information."
2722 msgstr ""
2724 #. type: Content of: <book><chapter><sect1><sect2><para>
2725 #: ../en/ch01-tour-basic.xml:120
2726 msgid ""
2727 "For a more impressive level of detail (which you won't usually need) run "
2728 "<command role=\"hg-cmd\">hg help <option role=\"hg-opt-global\">-v</option></"
2729 "command>. The <option role=\"hg-opt-global\">-v</option> option is short for "
2730 "<option role=\"hg-opt-global\">--verbose</option>, and tells Mercurial to "
2731 "print more information than it usually would."
2732 msgstr ""
2734 #. type: Content of: <book><chapter><sect1><title>
2735 #: ../en/ch01-tour-basic.xml:131
2736 msgid "Working with a repository"
2737 msgstr "使用版本库"
2739 #. type: Content of: <book><chapter><sect1><para>
2740 #: ../en/ch01-tour-basic.xml:133
2741 msgid ""
2742 "In Mercurial, everything happens inside a <emphasis>repository</emphasis>. "
2743 "The repository for a project contains all of the files that <quote>belong to</"
2744 "quote> that project, along with a historical record of the project's files."
2745 msgstr ""
2747 #. type: Content of: <book><chapter><sect1><para>
2748 #: ../en/ch01-tour-basic.xml:139
2749 msgid ""
2750 "There's nothing particularly magical about a repository; it is simply a "
2751 "directory tree in your filesystem that Mercurial treats as special. You can "
2752 "rename or delete a repository any time you like, using either the command "
2753 "line or your file browser."
2754 msgstr ""
2756 #. type: Content of: <book><chapter><sect1><sect2><title>
2757 #: ../en/ch01-tour-basic.xml:146
2758 msgid "Making a local copy of a repository"
2759 msgstr "创建版本库的工作副本"
2761 #. type: Content of: <book><chapter><sect1><sect2><para>
2762 #: ../en/ch01-tour-basic.xml:148
2763 msgid ""
2764 "<emphasis>Copying</emphasis> a repository is just a little bit special. "
2765 "While you could use a normal file copying command to make a copy of a "
2766 "repository, it's best to use a built-in command that Mercurial provides. "
2767 "This command is called <command role=\"hg-cmd\">hg clone</command>, because "
2768 "it creates an identical copy of an existing repository."
2769 msgstr ""
2771 #. type: Content of: <book><chapter><sect1><sect2><para>
2772 #: ../en/ch01-tour-basic.xml:157
2773 msgid ""
2774 "If our clone succeeded, we should now have a local directory called <filename "
2775 "class=\"directory\">hello</filename>. This directory will contain some files."
2776 msgstr ""
2778 #. type: Content of: <book><chapter><sect1><sect2><para>
2779 #: ../en/ch01-tour-basic.xml:163
2780 msgid ""
2781 "These files have the same contents and history in our repository as they do "
2782 "in the repository we cloned."
2783 msgstr ""
2785 #. type: Content of: <book><chapter><sect1><sect2><para>
2786 #: ../en/ch01-tour-basic.xml:166
2787 msgid ""
2788 "Every Mercurial repository is complete, self-contained, and independent. It "
2789 "contains its own private copy of a project's files and history. A cloned "
2790 "repository remembers the location of the repository it was cloned from, but "
2791 "it does not communicate with that repository, or any other, unless you tell "
2792 "it to."
2793 msgstr ""
2795 #. type: Content of: <book><chapter><sect1><sect2><para>
2796 #: ../en/ch01-tour-basic.xml:173
2797 msgid ""
2798 "What this means for now is that we're free to experiment with our repository, "
2799 "safe in the knowledge that it's a private <quote>sandbox</quote> that won't "
2800 "affect anyone else."
2801 msgstr ""
2803 #. type: Content of: <book><chapter><sect1><sect2><title>
2804 #: ../en/ch01-tour-basic.xml:179
2805 msgid "What's in a repository?"
2806 msgstr "什么是版本库?"
2808 #. type: Content of: <book><chapter><sect1><sect2><para>
2809 #: ../en/ch01-tour-basic.xml:181
2810 msgid ""
2811 "When we take a more detailed look inside a repository, we can see that it "
2812 "contains a directory named <filename class=\"directory\">.hg</filename>. "
2813 "This is where Mercurial keeps all of its metadata for the repository."
2814 msgstr ""
2816 #. type: Content of: <book><chapter><sect1><sect2><para>
2817 #: ../en/ch01-tour-basic.xml:188
2818 msgid ""
2819 "The contents of the <filename class=\"directory\">.hg</filename> directory "
2820 "and its subdirectories are private to Mercurial. Every other file and "
2821 "directory in the repository is yours to do with as you please."
2822 msgstr ""
2824 #. type: Content of: <book><chapter><sect1><sect2><para>
2825 #: ../en/ch01-tour-basic.xml:194
2826 msgid ""
2827 "To introduce a little terminology, the <filename class=\"directory\">.hg</"
2828 "filename> directory is the <quote>real</quote> repository, and all of the "
2829 "files and directories that coexist with it are said to live in the "
2830 "<emphasis>working directory</emphasis>. An easy way to remember the "
2831 "distinction is that the <emphasis>repository</emphasis> contains the "
2832 "<emphasis>history</emphasis> of your project, while the <emphasis>working "
2833 "directory</emphasis> contains a <emphasis>snapshot</emphasis> of your project "
2834 "at a particular point in history."
2835 msgstr ""
2837 #. type: Content of: <book><chapter><sect1><title>
2838 #: ../en/ch01-tour-basic.xml:209
2839 msgid "A tour through history"
2840 msgstr "回溯历史"
2842 #. type: Content of: <book><chapter><sect1><para>
2843 #: ../en/ch01-tour-basic.xml:211
2844 msgid ""
2845 "One of the first things we might want to do with a new, unfamiliar repository "
2846 "is understand its history. The <command role=\"hg-cmd\">hg log</command> "
2847 "command gives us a view of history."
2848 msgstr ""
2850 #. type: Content of: <book><chapter><sect1><para>
2851 #: ../en/ch01-tour-basic.xml:218
2852 msgid ""
2853 "By default, this command prints a brief paragraph of output for each change "
2854 "to the project that was recorded. In Mercurial terminology, we call each of "
2855 "these recorded events a <emphasis>changeset</emphasis>, because it can "
2856 "contain a record of changes to several files."
2857 msgstr ""
2859 #. type: Content of: <book><chapter><sect1><para>
2860 #: ../en/ch01-tour-basic.xml:224
2861 msgid ""
2862 "The fields in a record of output from <command role=\"hg-cmd\">hg log</"
2863 "command> are as follows."
2864 msgstr ""
2866 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
2867 #: ../en/ch01-tour-basic.xml:227
2868 msgid ""
2869 "<literal>changeset</literal>: This field has the format of a number, followed "
2870 "by a colon, followed by a hexadecimal string. These are "
2871 "<emphasis>identifiers</emphasis> for the changeset. There are two "
2872 "identifiers because the number is shorter and easier to type than the hex "
2873 "string."
2874 msgstr ""
2876 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
2877 #: ../en/ch01-tour-basic.xml:233
2878 msgid ""
2879 "<literal>user</literal>: The identity of the person who created the "
2880 "changeset. This is a free-form field, but it most often contains a person's "
2881 "name and email address."
2882 msgstr ""
2884 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
2885 #: ../en/ch01-tour-basic.xml:237
2886 msgid ""
2887 "<literal>date</literal>: The date and time on which the changeset was "
2888 "created, and the timezone in which it was created. (The date and time are "
2889 "local to that timezone; they display what time and date it was for the person "
2890 "who created the changeset.)"
2891 msgstr ""
2893 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
2894 #: ../en/ch01-tour-basic.xml:242
2895 msgid ""
2896 "<literal>summary</literal>: The first line of the text message that the "
2897 "creator of the changeset entered to describe the changeset."
2898 msgstr ""
2900 #. type: Content of: <book><chapter><sect1><para>
2901 #: ../en/ch01-tour-basic.xml:245
2902 msgid ""
2903 "The default output printed by <command role=\"hg-cmd\">hg log</command> is "
2904 "purely a summary; it is missing a lot of detail."
2905 msgstr ""
2907 #. type: Content of: <book><chapter><sect1><para>
2908 #: ../en/ch01-tour-basic.xml:249
2909 msgid ""
2910 "<xref linkend=\"fig:tour-basic:history\"/> provides a graphical "
2911 "representation of the history of the <filename class=\"directory\">hello</"
2912 "filename> repository, to make it a little easier to see which direction "
2913 "history is <quote>flowing</quote> in. We'll be returning to this figure "
2914 "several times in this chapter and the chapter that follows."
2915 msgstr ""
2917 #. type: Content of: <book><chapter><sect1><figure><title>
2918 #: ../en/ch01-tour-basic.xml:258
2919 msgid ""
2920 "Graphical history of the <filename class=\"directory\">hello</filename> "
2921 "repository"
2922 msgstr "版本库 <filename class=\"directory\">hello</filename> 的历史图"
2924 #. type: Content of: <book><chapter><sect1><figure>
2925 #: ../en/ch01-tour-basic.xml:260 ../en/ch02-tour-merge.xml:50
2926 #: ../en/ch02-tour-merge.xml:181 ../en/ch03-concepts.xml:293
2927 msgid "<placeholder type=\"mediaobject\" id=\"0\"/>"
2928 msgstr ""
2930 #. type: Content of: <book><chapter><sect1><figure><mediaobject>
2931 #: ../en/ch01-tour-basic.xml:261
2932 msgid ""
2933 "<imageobject><imagedata fileref=\"figs/tour-history.png\"/></imageobject>"
2934 msgstr ""
2936 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject><textobject><phrase>
2937 #: ../en/ch01-tour-basic.xml:262 ../en/ch02-tour-merge.xml:52
2938 #: ../en/ch02-tour-merge.xml:82 ../en/ch02-tour-merge.xml:129
2939 #: ../en/ch02-tour-merge.xml:183 ../en/ch02-tour-merge.xml:254
2940 #: ../en/ch03-concepts.xml:57 ../en/ch03-concepts.xml:106
2941 #: ../en/ch03-concepts.xml:191 ../en/ch03-concepts.xml:295
2942 #: ../en/ch03-concepts.xml:346 ../en/ch03-concepts.xml:361
2943 #: ../en/ch03-concepts.xml:402 ../en/ch03-concepts.xml:422
2944 #: ../en/ch03-concepts.xml:465 ../en/ch05-collab.xml:276
2945 #: ../en/ch08-undo.xml:365 ../en/ch08-undo.xml:412 ../en/ch08-undo.xml:477
2946 #: ../en/ch08-undo.xml:515 ../en/ch11-mq.xml:412
2947 msgid "XXX add text"
2948 msgstr ""
2950 #. type: Content of: <book><chapter><sect1><sect2><title>
2951 #: ../en/ch01-tour-basic.xml:267
2952 msgid "Changesets, revisions, and talking to other people"
2953 msgstr "改变集,版本,与其它用户交互"
2955 #. type: Content of: <book><chapter><sect1><sect2><para>
2956 #: ../en/ch01-tour-basic.xml:270
2957 msgid ""
2958 "As English is a notoriously sloppy language, and computer science has a "
2959 "hallowed history of terminological confusion (why use one term when four will "
2960 "do?), revision control has a variety of words and phrases that mean the same "
2961 "thing. If you are talking about Mercurial history with other people, you "
2962 "will find that the word <quote>changeset</quote> is often compressed to "
2963 "<quote>change</quote> or (when written) <quote>cset</quote>, and sometimes a "
2964 "changeset is referred to as a <quote>revision</quote> or a <quote>rev</quote>."
2965 msgstr ""
2967 #. type: Content of: <book><chapter><sect1><sect2><para>
2968 #: ../en/ch01-tour-basic.xml:280
2969 msgid ""
2970 "While it doesn't matter what <emphasis>word</emphasis> you use to refer to "
2971 "the concept of <quote>a changeset</quote>, the <emphasis>identifier</"
2972 "emphasis> that you use to refer to <quote>a <emphasis>specific</emphasis> "
2973 "changeset</quote> is of great importance. Recall that the <literal>changeset</"
2974 "literal> field in the output from <command role=\"hg-cmd\">hg log</command> "
2975 "identifies a changeset using both a number and a hexadecimal string."
2976 msgstr ""
2978 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2979 #: ../en/ch01-tour-basic.xml:289
2980 msgid ""
2981 "The revision number is <emphasis>only valid in that repository</emphasis>,"
2982 msgstr ""
2984 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2985 #: ../en/ch01-tour-basic.xml:291
2986 msgid ""
2987 "while the hex string is the <emphasis>permanent, unchanging identifier</"
2988 "emphasis> that will always identify that exact changeset in <emphasis>every</"
2989 "emphasis> copy of the repository."
2990 msgstr ""
2992 #. type: Content of: <book><chapter><sect1><sect2><para>
2993 #: ../en/ch01-tour-basic.xml:296
2994 msgid ""
2995 "This distinction is important. If you send someone an email talking about "
2996 "<quote>revision 33</quote>, there's a high likelihood that their revision 33 "
2997 "will <emphasis>not be the same</emphasis> as yours. The reason for this is "
2998 "that a revision number depends on the order in which changes arrived in a "
2999 "repository, and there is no guarantee that the same changes will happen in "
3000 "the same order in different repositories. Three changes $a,b,c$ can easily "
3001 "appear in one repository as $0,1,2$, while in another as $1,0,2$."
3002 msgstr ""
3004 #. type: Content of: <book><chapter><sect1><sect2><para>
3005 #: ../en/ch01-tour-basic.xml:306
3006 msgid ""
3007 "Mercurial uses revision numbers purely as a convenient shorthand. If you "
3008 "need to discuss a changeset with someone, or make a record of a changeset for "
3009 "some other reason (for example, in a bug report), use the hexadecimal "
3010 "identifier."
3011 msgstr ""
3013 #. type: Content of: <book><chapter><sect1><sect2><title>
3014 #: ../en/ch01-tour-basic.xml:314
3015 msgid "Viewing specific revisions"
3016 msgstr "察看指定版本"
3018 #. type: Content of: <book><chapter><sect1><sect2><para>
3019 #: ../en/ch01-tour-basic.xml:316
3020 msgid ""
3021 "To narrow the output of <command role=\"hg-cmd\">hg log</command> down to a "
3022 "single revision, use the <option role=\"hg-opt-log\">-r</option> (or <option "
3023 "role=\"hg-opt-log\">--rev</option>) option. You can use either a revision "
3024 "number or a long-form changeset identifier, and you can provide as many "
3025 "revisions as you want."
3026 msgstr ""
3028 #. type: Content of: <book><chapter><sect1><sect2><para>
3029 #: ../en/ch01-tour-basic.xml:325
3030 msgid ""
3031 "If you want to see the history of several revisions without having to list "
3032 "each one, you can use <emphasis>range notation</emphasis>; this lets you "
3033 "express the idea <quote>I want all revisions between <literal>abc</literal> "
3034 "and <literal>def</literal>, inclusive</quote>."
3035 msgstr ""
3037 #. type: Content of: <book><chapter><sect1><sect2><para>
3038 #: ../en/ch01-tour-basic.xml:333
3039 msgid ""
3040 "Mercurial also honours the order in which you specify revisions, so <command "
3041 "role=\"hg-cmd\">hg log -r 2:4</command> prints 2, 3, and 4. while <command "
3042 "role=\"hg-cmd\">hg log -r 4:2</command> prints 4, 3, and 2."
3043 msgstr ""
3045 #. type: Content of: <book><chapter><sect1><sect2><title>
3046 #: ../en/ch01-tour-basic.xml:340
3047 msgid "More detailed information"
3048 msgstr "更详细的信息"
3050 #. type: Content of: <book><chapter><sect1><sect2><para>
3051 #: ../en/ch01-tour-basic.xml:342
3052 msgid ""
3053 "While the summary information printed by <command role=\"hg-cmd\">hg log</"
3054 "command> is useful if you already know what you're looking for, you may need "
3055 "to see a complete description of the change, or a list of the files changed, "
3056 "if you're trying to decide whether a changeset is the one you're looking for. "
3057 "The <command role=\"hg-cmd\">hg log</command> command's <option role=\"hg-opt-"
3058 "global\">-v</option> (or <option role=\"hg-opt-global\">--verbose</option>) "
3059 "option gives you this extra detail."
3060 msgstr ""
3062 #. type: Content of: <book><chapter><sect1><sect2><para>
3063 #: ../en/ch01-tour-basic.xml:354
3064 msgid ""
3065 "If you want to see both the description and content of a change, add the "
3066 "<option role=\"hg-opt-log\">-p</option> (or <option role=\"hg-opt-log\">--"
3067 "patch</option>) option. This displays the content of a change as a "
3068 "<emphasis>unified diff</emphasis> (if you've never seen a unified diff "
3069 "before, see <xref linkend=\"sec:mq:patch\"/> for an overview)."
3070 msgstr ""
3072 #. type: Content of: <book><chapter><sect1><title>
3073 #: ../en/ch01-tour-basic.xml:367
3074 msgid "All about command options"
3075 msgstr "命令选项"
3077 #. type: Content of: <book><chapter><sect1><para>
3078 #: ../en/ch01-tour-basic.xml:369
3079 msgid ""
3080 "Let's take a brief break from exploring Mercurial commands to discuss a "
3081 "pattern in the way that they work; you may find this useful to keep in mind "
3082 "as we continue our tour."
3083 msgstr ""
3085 #. type: Content of: <book><chapter><sect1><para>
3086 #: ../en/ch01-tour-basic.xml:373
3087 msgid ""
3088 "Mercurial has a consistent and straightforward approach to dealing with the "
3089 "options that you can pass to commands. It follows the conventions for "
3090 "options that are common to modern Linux and Unix systems."
3091 msgstr ""
3093 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
3094 #: ../en/ch01-tour-basic.xml:378
3095 msgid ""
3096 "Every option has a long name. For example, as we've already seen, the "
3097 "<command role=\"hg-cmd\">hg log</command> command accepts a <option role=\"hg-"
3098 "opt-log\">--rev</option> option."
3099 msgstr ""
3101 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
3102 #: ../en/ch01-tour-basic.xml:382
3103 msgid ""
3104 "Most options have short names, too. Instead of <option role=\"hg-opt-log\">--"
3105 "rev</option>, we can use <option role=\"hg-opt-log\">-r</option>. (The "
3106 "reason that some options don't have short names is that the options in "
3107 "question are rarely used.)"
3108 msgstr ""
3110 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
3111 #: ../en/ch01-tour-basic.xml:387
3112 msgid ""
3113 "Long options start with two dashes (e.g. <option role=\"hg-opt-log\">--rev</"
3114 "option>), while short options start with one (e.g. <option role=\"hg-opt-log"
3115 "\">-r</option>)."
3116 msgstr ""
3118 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
3119 #: ../en/ch01-tour-basic.xml:391
3120 msgid ""
3121 "Option naming and usage is consistent across commands. For example, every "
3122 "command that lets you specify a changeset ID or revision number accepts both "
3123 "<option role=\"hg-opt-log\">-r</option> and <option role=\"hg-opt-log\">--"
3124 "rev</option> arguments."
3125 msgstr ""
3127 #. type: Content of: <book><chapter><sect1><para>
3128 #: ../en/ch01-tour-basic.xml:397
3129 msgid ""
3130 "In the examples throughout this book, I use short options instead of long. "
3131 "This just reflects my own preference, so don't read anything significant into "
3132 "it."
3133 msgstr ""
3135 #. type: Content of: <book><chapter><sect1><para>
3136 #: ../en/ch01-tour-basic.xml:401
3137 msgid ""
3138 "Most commands that print output of some kind will print more output when "
3139 "passed a <option role=\"hg-opt-global\">-v</option> (or <option role=\"hg-opt-"
3140 "global\">--verbose</option>) option, and less when passed <option role=\"hg-"
3141 "opt-global\">-q</option> (or <option role=\"hg-opt-global\">--quiet</option>)."
3142 msgstr ""
3144 #. type: Content of: <book><chapter><sect1><title>
3145 #: ../en/ch01-tour-basic.xml:409
3146 msgid "Making and reviewing changes"
3147 msgstr "创建和复审修改"
3149 #. type: Content of: <book><chapter><sect1><para>
3150 #: ../en/ch01-tour-basic.xml:411
3151 msgid ""
3152 "Now that we have a grasp of viewing history in Mercurial, let's take a look "
3153 "at making some changes and examining them."
3154 msgstr ""
3156 #. type: Content of: <book><chapter><sect1><para>
3157 #: ../en/ch01-tour-basic.xml:415
3158 msgid ""
3159 "The first thing we'll do is isolate our experiment in a repository of its "
3160 "own. We use the <command role=\"hg-cmd\">hg clone</command> command, but we "
3161 "don't need to clone a copy of the remote repository. Since we already have a "
3162 "copy of it locally, we can just clone that instead. This is much faster than "
3163 "cloning over the network, and cloning a local repository uses less disk space "
3164 "in most cases, too."
3165 msgstr ""
3167 #. type: Content of: <book><chapter><sect1><para>
3168 #: ../en/ch01-tour-basic.xml:425
3169 msgid ""
3170 "As an aside, it's often good practice to keep a <quote>pristine</quote> copy "
3171 "of a remote repository around, which you can then make temporary clones of to "
3172 "create sandboxes for each task you want to work on. This lets you work on "
3173 "multiple tasks in parallel, each isolated from the others until it's complete "
3174 "and you're ready to integrate it back. Because local clones are so cheap, "
3175 "there's almost no overhead to cloning and destroying repositories whenever "
3176 "you want."
3177 msgstr ""
3179 #. type: Content of: <book><chapter><sect1><para>
3180 #: ../en/ch01-tour-basic.xml:434
3181 msgid ""
3182 "In our <filename class=\"directory\">my-hello</filename> repository, we have "
3183 "a file <filename>hello.c</filename> that contains the classic <quote>hello, "
3184 "world</quote> program. Let's use the ancient and venerable <command>sed</"
3185 "command> command to edit this file so that it prints a second line of "
3186 "output. (I'm only using <command>sed</command> to do this because it's easy "
3187 "to write a scripted example this way. Since you're not under the same "
3188 "constraint, you probably won't want to use <command>sed</command>; simply use "
3189 "your preferred text editor to do the same thing.)"
3190 msgstr ""
3192 #. type: Content of: <book><chapter><sect1><para>
3193 #: ../en/ch01-tour-basic.xml:447
3194 msgid ""
3195 "Mercurial's <command role=\"hg-cmd\">hg status</command> command will tell us "
3196 "what Mercurial knows about the files in the repository."
3197 msgstr ""
3199 #. type: Content of: <book><chapter><sect1><para>
3200 #: ../en/ch01-tour-basic.xml:453
3201 msgid ""
3202 "The <command role=\"hg-cmd\">hg status</command> command prints no output for "
3203 "some files, but a line starting with <quote><literal>M</literal></quote> for "
3204 "<filename>hello.c</filename>. Unless you tell it to, <command role=\"hg-cmd"
3205 "\">hg status</command> will not print any output for files that have not been "
3206 "modified."
3207 msgstr ""
3209 #. type: Content of: <book><chapter><sect1><para>
3210 #: ../en/ch01-tour-basic.xml:460
3211 msgid ""
3212 "The <quote><literal>M</literal></quote> indicates that Mercurial has noticed "
3213 "that we modified <filename>hello.c</filename>. We didn't need to "
3214 "<emphasis>inform</emphasis> Mercurial that we were going to modify the file "
3215 "before we started, or that we had modified the file after we were done; it "
3216 "was able to figure this out itself."
3217 msgstr ""
3219 #. type: Content of: <book><chapter><sect1><para>
3220 #: ../en/ch01-tour-basic.xml:468
3221 msgid ""
3222 "It's a little bit helpful to know that we've modified <filename>hello.c</"
3223 "filename>, but we might prefer to know exactly <emphasis>what</emphasis> "
3224 "changes we've made to it. To do this, we use the <command role=\"hg-cmd\">hg "
3225 "diff</command> command."
3226 msgstr ""
3228 #. type: Content of: <book><chapter><sect1><title>
3229 #: ../en/ch01-tour-basic.xml:478
3230 msgid "Recording changes in a new changeset"
3231 msgstr "在新修改集中记录修改"
3233 #. type: Content of: <book><chapter><sect1><para>
3234 #: ../en/ch01-tour-basic.xml:480
3235 msgid ""
3236 "We can modify files, build and test our changes, and use <command role=\"hg-"
3237 "cmd\">hg status</command> and <command role=\"hg-cmd\">hg diff</command> to "
3238 "review our changes, until we're satisfied with what we've done and arrive at "
3239 "a natural stopping point where we want to record our work in a new changeset."
3240 msgstr ""
3242 #. type: Content of: <book><chapter><sect1><para>
3243 #: ../en/ch01-tour-basic.xml:487
3244 msgid ""
3245 "The <command role=\"hg-cmd\">hg commit</command> command lets us create a new "
3246 "changeset; we'll usually refer to this as <quote>making a commit</quote> or "
3247 "<quote>committing</quote>."
3248 msgstr ""
3250 #. type: Content of: <book><chapter><sect1><sect2><title>
3251 #: ../en/ch01-tour-basic.xml:493
3252 msgid "Setting up a username"
3253 msgstr "配置用户名称"
3255 #. type: Content of: <book><chapter><sect1><sect2><para>
3256 #: ../en/ch01-tour-basic.xml:495
3257 msgid ""
3258 "When you try to run <command role=\"hg-cmd\">hg commit</command> for the "
3259 "first time, it is not guaranteed to succeed. Mercurial records your name and "
3260 "address with each change that you commit, so that you and others will later "
3261 "be able to tell who made each change. Mercurial tries to automatically "
3262 "figure out a sensible username to commit the change with. It will attempt "
3263 "each of the following methods, in order:"
3264 msgstr ""
3266 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
3267 #: ../en/ch01-tour-basic.xml:504
3268 msgid ""
3269 "If you specify a <option role=\"hg-opt-commit\">-u</option> option to the "
3270 "<command role=\"hg-cmd\">hg commit</command> command on the command line, "
3271 "followed by a username, this is always given the highest precedence."
3272 msgstr ""
3274 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
3275 #: ../en/ch01-tour-basic.xml:509
3276 msgid ""
3277 "If you have set the <envar>HGUSER</envar> environment variable, this is "
3278 "checked next."
3279 msgstr ""
3281 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
3282 #: ../en/ch01-tour-basic.xml:512
3283 msgid ""
3284 "If you create a file in your home directory called <filename role=\"special"
3285 "\">.hgrc</filename>, with a <envar role=\"rc-item-ui\">username</envar> "
3286 "entry, that will be used next. To see what the contents of this file should "
3287 "look like, refer to <xref linkend=\"sec:tour-basic:username\"/> below."
3288 msgstr ""
3290 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
3291 #: ../en/ch01-tour-basic.xml:520
3292 msgid ""
3293 "If you have set the <envar>EMAIL</envar> environment variable, this will be "
3294 "used next."
3295 msgstr ""
3297 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
3298 #: ../en/ch01-tour-basic.xml:523
3299 msgid ""
3300 "Mercurial will query your system to find out your local user name and host "
3301 "name, and construct a username from these components. Since this often "
3302 "results in a username that is not very useful, it will print a warning if it "
3303 "has to do this."
3304 msgstr ""
3306 #. type: Content of: <book><chapter><sect1><sect2><para>
3307 #: ../en/ch01-tour-basic.xml:530
3308 msgid ""
3309 "If all of these mechanisms fail, Mercurial will fail, printing an error "
3310 "message. In this case, it will not let you commit until you set up a "
3311 "username."
3312 msgstr ""
3314 #. type: Content of: <book><chapter><sect1><sect2><para>
3315 #: ../en/ch01-tour-basic.xml:534
3316 msgid ""
3317 "You should think of the <envar>HGUSER</envar> environment variable and the "
3318 "<option role=\"hg-opt-commit\">-u</option> option to the <command role=\"hg-"
3319 "cmd\">hg commit</command> command as ways to <emphasis>override</emphasis> "
3320 "Mercurial's default selection of username. For normal use, the simplest and "
3321 "most robust way to set a username for yourself is by creating a <filename "
3322 "role=\"special\">.hgrc</filename> file; see below for details."
3323 msgstr ""
3325 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
3326 #: ../en/ch01-tour-basic.xml:543
3327 msgid "Creating a Mercurial configuration file"
3328 msgstr "创建 Mercurial 的配置文件"
3330 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
3331 #: ../en/ch01-tour-basic.xml:545
3332 msgid ""
3333 "To set a user name, use your favourite editor to create a file called "
3334 "<filename role=\"special\">.hgrc</filename> in your home directory. "
3335 "Mercurial will use this file to look up your personalised configuration "
3336 "settings. The initial contents of your <filename role=\"special\">.hgrc</"
3337 "filename> should look like this."
3338 msgstr ""
3340 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
3341 #: ../en/ch01-tour-basic.xml:557
3342 msgid ""
3343 "The <quote><literal>[ui]</literal></quote> line begins a <emphasis>section</"
3344 "emphasis> of the config file, so you can read the <quote><literal>username "
3345 "= ...</literal></quote> line as meaning <quote>set the value of the "
3346 "<literal>username</literal> item in the <literal>ui</literal> section</"
3347 "quote>. A section continues until a new section begins, or the end of the "
3348 "file. Mercurial ignores empty lines and treats any text from "
3349 "<quote><literal>#</literal></quote> to the end of a line as a comment."
3350 msgstr ""
3352 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
3353 #: ../en/ch01-tour-basic.xml:570
3354 msgid "Choosing a user name"
3355 msgstr "选择用户名称"
3357 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
3358 #: ../en/ch01-tour-basic.xml:572
3359 msgid ""
3360 "You can use any text you like as the value of the <literal>username</literal> "
3361 "config item, since this information is for reading by other people, but for "
3362 "interpreting by Mercurial. The convention that most people follow is to use "
3363 "their name and email address, as in the example above."
3364 msgstr ""
3366 #. type: Content of: <book><chapter><sect1><sect2><sect3><note><para>
3367 #: ../en/ch01-tour-basic.xml:579
3368 msgid ""
3369 "Mercurial's built-in web server obfuscates email addresses, to make it more "
3370 "difficult for the email harvesting tools that spammers use. This reduces the "
3371 "likelihood that you'll start receiving more junk email if you publish a "
3372 "Mercurial repository on the web."
3373 msgstr ""
3375 #. type: Content of: <book><chapter><sect1><sect2><title>
3376 #: ../en/ch01-tour-basic.xml:589
3377 msgid "Writing a commit message"
3378 msgstr "写提交日志"
3380 #. type: Content of: <book><chapter><sect1><sect2><para>
3381 #: ../en/ch01-tour-basic.xml:591
3382 msgid ""
3383 "When we commit a change, Mercurial drops us into a text editor, to enter a "
3384 "message that will describe the modifications we've made in this changeset. "
3385 "This is called the <emphasis>commit message</emphasis>. It will be a record "
3386 "for readers of what we did and why, and it will be printed by <command role="
3387 "\"hg-cmd\">hg log</command> after we've finished committing."
3388 msgstr ""
3390 #. type: Content of: <book><chapter><sect1><sect2><para>
3391 #: ../en/ch01-tour-basic.xml:601
3392 msgid ""
3393 "The editor that the <command role=\"hg-cmd\">hg commit</command> command "
3394 "drops us into will contain an empty line, followed by a number of lines "
3395 "starting with <quote><literal>HG:</literal></quote>."
3396 msgstr ""
3398 #. type: Content of: <book><chapter><sect1><sect2><para>
3399 #: ../en/ch01-tour-basic.xml:608
3400 msgid ""
3401 "Mercurial ignores the lines that start with <quote><literal>HG:</literal></"
3402 "quote>; it uses them only to tell us which files it's recording changes to. "
3403 "Modifying or deleting these lines has no effect."
3404 msgstr ""
3406 #. type: Content of: <book><chapter><sect1><sect2><title>
3407 #: ../en/ch01-tour-basic.xml:614
3408 msgid "Writing a good commit message"
3409 msgstr "写好提交日志"
3411 #. type: Content of: <book><chapter><sect1><sect2><para>
3412 #: ../en/ch01-tour-basic.xml:616
3413 msgid ""
3414 "Since <command role=\"hg-cmd\">hg log</command> only prints the first line of "
3415 "a commit message by default, it's best to write a commit message whose first "
3416 "line stands alone. Here's a real example of a commit message that "
3417 "<emphasis>doesn't</emphasis> follow this guideline, and hence has a summary "
3418 "that is not readable."
3419 msgstr ""
3421 #. type: Content of: <book><chapter><sect1><sect2><para>
3422 #: ../en/ch01-tour-basic.xml:630
3423 msgid ""
3424 "As far as the remainder of the contents of the commit message are concerned, "
3425 "there are no hard-and-fast rules. Mercurial itself doesn't interpret or care "
3426 "about the contents of the commit message, though your project may have "
3427 "policies that dictate a certain kind of formatting."
3428 msgstr ""
3430 #. type: Content of: <book><chapter><sect1><sect2><para>
3431 #: ../en/ch01-tour-basic.xml:636
3432 msgid ""
3433 "My personal preference is for short, but informative, commit messages that "
3434 "tell me something that I can't figure out with a quick glance at the output "
3435 "of <command role=\"hg-cmd\">hg log --patch</command>."
3436 msgstr ""
3438 #. type: Content of: <book><chapter><sect1><sect2><title>
3439 #: ../en/ch01-tour-basic.xml:643
3440 msgid "Aborting a commit"
3441 msgstr "终止提交"
3443 #. type: Content of: <book><chapter><sect1><sect2><para>
3444 #: ../en/ch01-tour-basic.xml:645
3445 msgid ""
3446 "If you decide that you don't want to commit while in the middle of editing a "
3447 "commit message, simply exit from your editor without saving the file that "
3448 "it's editing. This will cause nothing to happen to either the repository or "
3449 "the working directory."
3450 msgstr ""
3452 #. type: Content of: <book><chapter><sect1><sect2><para>
3453 #: ../en/ch01-tour-basic.xml:650
3454 msgid ""
3455 "If we run the <command role=\"hg-cmd\">hg commit</command> command without "
3456 "any arguments, it records all of the changes we've made, as reported by "
3457 "<command role=\"hg-cmd\">hg status</command> and <command role=\"hg-cmd\">hg "
3458 "diff</command>."
3459 msgstr ""
3461 #. type: Content of: <book><chapter><sect1><sect2><title>
3462 #: ../en/ch01-tour-basic.xml:657
3463 msgid "Admiring our new handiwork"
3464 msgstr "欣赏我们的新手艺"
3466 #. type: Content of: <book><chapter><sect1><sect2><para>
3467 #: ../en/ch01-tour-basic.xml:659
3468 msgid ""
3469 "Once we've finished the commit, we can use the <command role=\"hg-cmd\">hg "
3470 "tip</command> command to display the changeset we just created. This command "
3471 "produces output that is identical to <command role=\"hg-cmd\">hg log</"
3472 "command>, but it only displays the newest revision in the repository."
3473 msgstr ""
3475 #. type: Content of: <book><chapter><sect1><sect2><para>
3476 #: ../en/ch01-tour-basic.xml:668
3477 msgid ""
3478 "We refer to the newest revision in the repository as the tip revision, or "
3479 "simply the tip."
3480 msgstr ""
3482 #. type: Content of: <book><chapter><sect1><title>
3483 #: ../en/ch01-tour-basic.xml:675
3484 msgid "Sharing changes"
3485 msgstr "共享修改"
3487 #. type: Content of: <book><chapter><sect1><para>
3488 #: ../en/ch01-tour-basic.xml:677
3489 msgid ""
3490 "We mentioned earlier that repositories in Mercurial are self-contained. This "
3491 "means that the changeset we just created exists only in our <filename class="
3492 "\"directory\">my-hello</filename> repository. Let's look at a few ways that "
3493 "we can propagate this change into other repositories."
3494 msgstr ""
3496 #. type: Content of: <book><chapter><sect1><sect2><title>
3497 #: ../en/ch01-tour-basic.xml:685
3498 msgid "Pulling changes from another repository"
3499 msgstr "从其它版本库取得修改"
3501 #. type: Content of: <book><chapter><sect1><sect2><para>
3502 #: ../en/ch01-tour-basic.xml:686
3503 msgid ""
3504 "To get started, let's clone our original <filename class=\"directory\">hello</"
3505 "filename> repository, which does not contain the change we just committed. "
3506 "We'll call our temporary repository <filename class=\"directory\">hello-pull</"
3507 "filename>."
3508 msgstr ""
3510 #. type: Content of: <book><chapter><sect1><sect2><para>
3511 #: ../en/ch01-tour-basic.xml:694
3512 msgid ""
3513 "We'll use the <command role=\"hg-cmd\">hg pull</command> command to bring "
3514 "changes from <filename class=\"directory\">my-hello</filename> into <filename "
3515 "class=\"directory\">hello-pull</filename>. However, blindly pulling unknown "
3516 "changes into a repository is a somewhat scary prospect. Mercurial provides "
3517 "the <command role=\"hg-cmd\">hg incoming</command> command to tell us what "
3518 "changes the <command role=\"hg-cmd\">hg pull</command> command "
3519 "<emphasis>would</emphasis> pull into the repository, without actually pulling "
3520 "the changes in."
3521 msgstr ""
3523 #. type: Content of: <book><chapter><sect1><sect2><para>
3524 #: ../en/ch01-tour-basic.xml:707
3525 msgid ""
3526 "(Of course, someone could cause more changesets to appear in the repository "
3527 "that we ran <command role=\"hg-cmd\">hg incoming</command> in, before we get "
3528 "a chance to <command role=\"hg-cmd\">hg pull</command> the changes, so that "
3529 "we could end up pulling changes that we didn't expect.)"
3530 msgstr ""
3532 #. type: Content of: <book><chapter><sect1><sect2><para>
3533 #: ../en/ch01-tour-basic.xml:714
3534 msgid ""
3535 "Bringing changes into a repository is a simple matter of running the <command "
3536 "role=\"hg-cmd\">hg pull</command> command, and telling it which repository to "
3537 "pull from."
3538 msgstr ""
3540 #. type: Content of: <book><chapter><sect1><sect2><para>
3541 #: ../en/ch01-tour-basic.xml:721
3542 msgid ""
3543 "As you can see from the before-and-after output of <command role=\"hg-cmd"
3544 "\">hg tip</command>, we have successfully pulled changes into our "
3545 "repository. There remains one step before we can see these changes in the "
3546 "working directory."
3547 msgstr ""
3549 #. type: Content of: <book><chapter><sect1><sect2><title>
3550 #: ../en/ch01-tour-basic.xml:729
3551 msgid "Updating the working directory"
3552 msgstr "更新工作目录"
3554 #. type: Content of: <book><chapter><sect1><sect2><para>
3555 #: ../en/ch01-tour-basic.xml:731
3556 msgid ""
3557 "We have so far glossed over the relationship between a repository and its "
3558 "working directory. The <command role=\"hg-cmd\">hg pull</command> command "
3559 "that we ran in <xref linkend=\"sec:tour:pull\"/> brought changes into the "
3560 "repository, but if we check, there's no sign of those changes in the working "
3561 "directory. This is because <command role=\"hg-cmd\">hg pull</command> does "
3562 "not (by default) touch the working directory. Instead, we use the <command "
3563 "role=\"hg-cmd\">hg update</command> command to do this."
3564 msgstr ""
3566 #. type: Content of: <book><chapter><sect1><sect2><para>
3567 #: ../en/ch01-tour-basic.xml:743
3568 msgid ""
3569 "It might seem a bit strange that <command role=\"hg-cmd\">hg pull</command> "
3570 "doesn't update the working directory automatically. There's actually a good "
3571 "reason for this: you can use <command role=\"hg-cmd\">hg update</command> to "
3572 "update the working directory to the state it was in at <emphasis>any "
3573 "revision</emphasis> in the history of the repository. If you had the working "
3574 "directory updated to an old revision---to hunt down the origin of a bug, "
3575 "say---and ran a <command role=\"hg-cmd\">hg pull</command> which "
3576 "automatically updated the working directory to a new revision, you might not "
3577 "be terribly happy."
3578 msgstr ""
3580 #. type: Content of: <book><chapter><sect1><sect2><para>
3581 #: ../en/ch01-tour-basic.xml:754
3582 msgid ""
3583 "However, since pull-then-update is such a common thing to do, Mercurial lets "
3584 "you combine the two by passing the <option role=\"hg-opt-pull\">-u</option> "
3585 "option to <command role=\"hg-cmd\">hg pull</command>."
3586 msgstr ""
3588 #. type: Content of: <book><chapter><sect1><sect2><para>
3589 #: ../en/ch01-tour-basic.xml:759
3590 msgid ""
3591 "If you look back at the output of <command role=\"hg-cmd\">hg pull</command> "
3592 "in <xref linkend=\"sec:tour:pull\"/> when we ran it without <option role=\"hg-"
3593 "opt-pull\">-u</option>, you can see that it printed a helpful reminder that "
3594 "we'd have to take an explicit step to update the working directory:"
3595 msgstr ""
3597 #. type: Content of: <book><chapter><sect1><sect2><para>
3598 #: ../en/ch01-tour-basic.xml:768
3599 msgid ""
3600 "To find out what revision the working directory is at, use the <command role="
3601 "\"hg-cmd\">hg parents</command> command."
3602 msgstr ""
3604 #. type: Content of: <book><chapter><sect1><sect2><para>
3605 #: ../en/ch01-tour-basic.xml:774
3606 msgid ""
3607 "If you look back at <xref linkend=\"fig:tour-basic:history\"/>, you'll see "
3608 "arrows connecting each changeset. The node that the arrow leads "
3609 "<emphasis>from</emphasis> in each case is a parent, and the node that the "
3610 "arrow leads <emphasis>to</emphasis> is its child. The working directory has "
3611 "a parent in just the same way; this is the changeset that the working "
3612 "directory currently contains."
3613 msgstr ""
3615 #. type: Content of: <book><chapter><sect1><sect2><para>
3616 #: ../en/ch01-tour-basic.xml:783
3617 msgid ""
3618 "To update the working directory to a particular revision, give a revision "
3619 "number or changeset ID to the <command role=\"hg-cmd\">hg update</command> "
3620 "command."
3621 msgstr ""
3623 #. type: Content of: <book><chapter><sect1><sect2><para>
3624 #: ../en/ch01-tour-basic.xml:790
3625 msgid ""
3626 "If you omit an explicit revision, <command role=\"hg-cmd\">hg update</"
3627 "command> will update to the tip revision, as shown by the second call to "
3628 "<command role=\"hg-cmd\">hg update</command> in the example above."
3629 msgstr ""
3631 #. type: Content of: <book><chapter><sect1><sect2><title>
3632 #: ../en/ch01-tour-basic.xml:798
3633 msgid "Pushing changes to another repository"
3634 msgstr "发布修改到其它版本库"
3636 #. type: Content of: <book><chapter><sect1><sect2><para>
3637 #: ../en/ch01-tour-basic.xml:800
3638 msgid ""
3639 "Mercurial lets us push changes to another repository, from the repository "
3640 "we're currently visiting. As with the example of <command role=\"hg-cmd\">hg "
3641 "pull</command> above, we'll create a temporary repository to push our changes "
3642 "into."
3643 msgstr ""
3645 #. type: Content of: <book><chapter><sect1><sect2><para>
3646 #: ../en/ch01-tour-basic.xml:808
3647 msgid ""
3648 "The <command role=\"hg-cmd\">hg outgoing</command> command tells us what "
3649 "changes would be pushed into another repository."
3650 msgstr ""
3652 #. type: Content of: <book><chapter><sect1><sect2><para>
3653 #: ../en/ch01-tour-basic.xml:814
3654 msgid ""
3655 "And the <command role=\"hg-cmd\">hg push</command> command does the actual "
3656 "push."
3657 msgstr ""
3659 #. type: Content of: <book><chapter><sect1><sect2><para>
3660 #: ../en/ch01-tour-basic.xml:820
3661 msgid ""
3662 "As with <command role=\"hg-cmd\">hg pull</command>, the <command role=\"hg-cmd"
3663 "\">hg push</command> command does not update the working directory in the "
3664 "repository that it's pushing changes into. (Unlike <command role=\"hg-cmd"
3665 "\">hg pull</command>, <command role=\"hg-cmd\">hg push</command> does not "
3666 "provide a <literal>-u</literal> option that updates the other repository's "
3667 "working directory.)"
3668 msgstr ""
3670 #. type: Content of: <book><chapter><sect1><sect2><para>
3671 #: ../en/ch01-tour-basic.xml:829
3672 msgid ""
3673 "What happens if we try to pull or push changes and the receiving repository "
3674 "already has those changes? Nothing too exciting."
3675 msgstr ""
3677 #. type: Content of: <book><chapter><sect1><sect2><title>
3678 #: ../en/ch01-tour-basic.xml:836
3679 msgid "Sharing changes over a network"
3680 msgstr "通过网络共享修改"
3682 #. type: Content of: <book><chapter><sect1><sect2><para>
3683 #: ../en/ch01-tour-basic.xml:838
3684 msgid ""
3685 "The commands we have covered in the previous few sections are not limited to "
3686 "working with local repositories. Each works in exactly the same fashion over "
3687 "a network connection; simply pass in a URL instead of a local path."
3688 msgstr ""
3690 #. type: Content of: <book><chapter><sect1><sect2><para>
3691 #: ../en/ch01-tour-basic.xml:846
3692 msgid ""
3693 "In this example, we can see what changes we could push to the remote "
3694 "repository, but the repository is understandably not set up to let anonymous "
3695 "users push to it."
3696 msgstr ""
3698 #. type: Content of: <book><chapter><title>
3699 #: ../en/ch02-tour-merge.xml:5
3700 msgid "A tour of Mercurial: merging work"
3701 msgstr "Mercurial 教程: 合并工作"
3703 #. type: Content of: <book><chapter><para>
3704 #: ../en/ch02-tour-merge.xml:7
3705 msgid ""
3706 "We've now covered cloning a repository, making changes in a repository, and "
3707 "pulling or pushing changes from one repository into another. Our next step "
3708 "is <emphasis>merging</emphasis> changes from separate repositories."
3709 msgstr ""
3711 #. type: Content of: <book><chapter><sect1><title>
3712 #: ../en/ch02-tour-merge.xml:13
3713 msgid "Merging streams of work"
3714 msgstr "合并的流程"
3716 #. type: Content of: <book><chapter><sect1><para>
3717 #: ../en/ch02-tour-merge.xml:15
3718 msgid ""
3719 "Merging is a fundamental part of working with a distributed revision control "
3720 "tool."
3721 msgstr ""
3723 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
3724 #: ../en/ch02-tour-merge.xml:18
3725 msgid ""
3726 "Alice and Bob each have a personal copy of a repository for a project they're "
3727 "collaborating on. Alice fixes a bug in her repository; Bob adds a new "
3728 "feature in his. They want the shared repository to contain both the bug fix "
3729 "and the new feature."
3730 msgstr ""
3732 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
3733 #: ../en/ch02-tour-merge.xml:24
3734 msgid ""
3735 "I frequently work on several different tasks for a single project at once, "
3736 "each safely isolated in its own repository. Working this way means that I "
3737 "often need to merge one piece of my own work with another."
3738 msgstr ""
3740 #. type: Content of: <book><chapter><sect1><para>
3741 #: ../en/ch02-tour-merge.xml:30
3742 msgid ""
3743 "Because merging is such a common thing to need to do, Mercurial makes it "
3744 "easy. Let's walk through the process. We'll begin by cloning yet another "
3745 "repository (see how often they spring up?) and making a change in it."
3746 msgstr ""
3748 #. type: Content of: <book><chapter><sect1><para>
3749 #: ../en/ch02-tour-merge.xml:37
3750 msgid ""
3751 "We should now have two copies of <filename>hello.c</filename> with different "
3752 "contents. The histories of the two repositories have also diverged, as "
3753 "illustrated in <xref linkend=\"fig:tour-merge:sep-repos\"/>."
3754 msgstr ""
3756 #. type: Content of: <book><chapter><sect1><figure><title>
3757 #: ../en/ch02-tour-merge.xml:46
3758 msgid ""
3759 "Divergent recent histories of the <filename class=\"directory\">my-hello</"
3760 "filename> and <filename class=\"directory\">my-new-hello</filename> "
3761 "repositories"
3762 msgstr ""
3763 "<filename class=\"directory\">my-hello</filename> 与 <filename class="
3764 "\"directory\">my-new-hello</filename> 最新的历史分叉"
3766 #. type: Content of: <book><chapter><sect1><figure><mediaobject>
3767 #: ../en/ch02-tour-merge.xml:51
3768 msgid ""
3769 "<imageobject><imagedata fileref=\"figs/tour-merge-sep-repos.png\"/></"
3770 "imageobject>"
3771 msgstr ""
3773 #. type: Content of: <book><chapter><sect1><para>
3774 #: ../en/ch02-tour-merge.xml:56
3775 msgid ""
3776 "We already know that pulling changes from our <filename class=\"directory"
3777 "\">my-hello</filename> repository will have no effect on the working "
3778 "directory."
3779 msgstr ""
3781 #. type: Content of: <book><chapter><sect1><para>
3782 #: ../en/ch02-tour-merge.xml:62
3783 msgid ""
3784 "However, the <command role=\"hg-cmd\">hg pull</command> command says "
3785 "something about <quote>heads</quote>."
3786 msgstr ""
3788 #. type: Content of: <book><chapter><sect1><sect2><title>
3789 #: ../en/ch02-tour-merge.xml:66
3790 msgid "Head changesets"
3791 msgstr "顶点改变集"
3793 #. type: Content of: <book><chapter><sect1><sect2><para>
3794 #: ../en/ch02-tour-merge.xml:68
3795 msgid ""
3796 "A head is a change that has no descendants, or children, as they're also "
3797 "known. The tip revision is thus a head, because the newest revision in a "
3798 "repository doesn't have any children, but a repository can contain more than "
3799 "one head."
3800 msgstr ""
3802 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
3803 #: ../en/ch02-tour-merge.xml:75
3804 msgid ""
3805 "Repository contents after pulling from <filename class=\"directory\">my-"
3806 "hello</filename> into <filename class=\"directory\">my-new-hello</filename>"
3807 msgstr ""
3808 "从 <filename class=\"directory\">my-hello</filename> 拉到 <filename class="
3809 "\"directory\">my-new-hello</filename> 之后版本库的内容"
3811 #. type: Content of: <book><chapter><sect1><sect2><figure>
3812 #: ../en/ch02-tour-merge.xml:78 ../en/ch02-tour-merge.xml:125
3813 #: ../en/ch02-tour-merge.xml:250 ../en/ch03-concepts.xml:55
3814 #: ../en/ch03-concepts.xml:104 ../en/ch03-concepts.xml:189
3815 #: ../en/ch03-concepts.xml:344 ../en/ch03-concepts.xml:359
3816 #: ../en/ch03-concepts.xml:400 ../en/ch03-concepts.xml:420
3817 #: ../en/ch03-concepts.xml:461 ../en/ch05-collab.xml:274
3818 #: ../en/ch08-undo.xml:363 ../en/ch08-undo.xml:410 ../en/ch08-undo.xml:475
3819 #: ../en/ch08-undo.xml:513 ../en/ch11-mq.xml:410
3820 msgid " <placeholder type=\"mediaobject\" id=\"0\"/>"
3821 msgstr ""
3823 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
3824 #: ../en/ch02-tour-merge.xml:79
3825 msgid ""
3826 "<imageobject> <imagedata fileref=\"figs/tour-merge-pull.png\"/> </imageobject>"
3827 msgstr ""
3829 #. type: Content of: <book><chapter><sect1><sect2><para>
3830 #: ../en/ch02-tour-merge.xml:86
3831 msgid ""
3832 "In <xref linkend=\"fig:tour-merge:pull\"/>, you can see the effect of the "
3833 "pull from <filename class=\"directory\">my-hello</filename> into <filename "
3834 "class=\"directory\">my-new-hello</filename>. The history that was already "
3835 "present in <filename class=\"directory\">my-new-hello</filename> is "
3836 "untouched, but a new revision has been added. By referring to <xref linkend="
3837 "\"fig:tour-merge:sep-repos\"/>, we can see that the <emphasis>changeset ID</"
3838 "emphasis> remains the same in the new repository, but the <emphasis>revision "
3839 "number</emphasis> has changed. (This, incidentally, is a fine example of why "
3840 "it's not safe to use revision numbers when discussing changesets.) We can "
3841 "view the heads in a repository using the <command role=\"hg-cmd\">hg heads</"
3842 "command> command."
3843 msgstr ""
3845 #. type: Content of: <book><chapter><sect1><sect2><title>
3846 #: ../en/ch02-tour-merge.xml:105
3847 msgid "Performing the merge"
3848 msgstr "执行合并"
3850 #. type: Content of: <book><chapter><sect1><sect2><para>
3851 #: ../en/ch02-tour-merge.xml:107
3852 msgid ""
3853 "What happens if we try to use the normal <command role=\"hg-cmd\">hg update</"
3854 "command> command to update to the new tip?"
3855 msgstr ""
3857 #. type: Content of: <book><chapter><sect1><sect2><para>
3858 #: ../en/ch02-tour-merge.xml:113
3859 msgid ""
3860 "Mercurial is telling us that the <command role=\"hg-cmd\">hg update</command> "
3861 "command won't do a merge; it won't update the working directory when it "
3862 "thinks we might be wanting to do a merge, unless we force it to do so. "
3863 "Instead, we use the <command role=\"hg-cmd\">hg merge</command> command to "
3864 "merge the two heads."
3865 msgstr ""
3867 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
3868 #: ../en/ch02-tour-merge.xml:123
3869 msgid "Working directory and repository during merge, and following commit"
3870 msgstr "在合并期间,以及提交之后的工作目录与版本库"
3872 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
3873 #: ../en/ch02-tour-merge.xml:126
3874 msgid ""
3875 "<imageobject> <imagedata fileref=\"figs/tour-merge-merge.png\"/> </"
3876 "imageobject>"
3877 msgstr ""
3879 #. type: Content of: <book><chapter><sect1><sect2><para>
3880 #: ../en/ch02-tour-merge.xml:133
3881 msgid ""
3882 "This updates the working directory so that it contains changes from "
3883 "<emphasis>both</emphasis> heads, which is reflected in both the output of "
3884 "<command role=\"hg-cmd\">hg parents</command> and the contents of "
3885 "<filename>hello.c</filename>."
3886 msgstr ""
3888 #. type: Content of: <book><chapter><sect1><sect2><title>
3889 #: ../en/ch02-tour-merge.xml:143
3890 msgid "Committing the results of the merge"
3891 msgstr "提交合并结果"
3893 #. type: Content of: <book><chapter><sect1><sect2><para>
3894 #: ../en/ch02-tour-merge.xml:145
3895 msgid ""
3896 "Whenever we've done a merge, <command role=\"hg-cmd\">hg parents</command> "
3897 "will display two parents until we <command role=\"hg-cmd\">hg commit</"
3898 "command> the results of the merge."
3899 msgstr ""
3901 #. type: Content of: <book><chapter><sect1><sect2><para>
3902 #: ../en/ch02-tour-merge.xml:152
3903 msgid ""
3904 "We now have a new tip revision; notice that it has <emphasis>both</emphasis> "
3905 "of our former heads as its parents. These are the same revisions that were "
3906 "previously displayed by <command role=\"hg-cmd\">hg parents</command>."
3907 msgstr ""
3909 #. type: Content of: <book><chapter><sect1><sect2><para>
3910 #: ../en/ch02-tour-merge.xml:159
3911 msgid ""
3912 "In <xref linkend=\"fig:tour-merge:merge\"/>, you can see a representation of "
3913 "what happens to the working directory during the merge, and how this affects "
3914 "the repository when the commit happens. During the merge, the working "
3915 "directory has two parent changesets, and these become the parents of the new "
3916 "changeset."
3917 msgstr ""
3919 #. type: Content of: <book><chapter><sect1><title>
3920 #: ../en/ch02-tour-merge.xml:170
3921 msgid "Merging conflicting changes"
3922 msgstr "合并有冲突的改变"
3924 #. type: Content of: <book><chapter><sect1><para>
3925 #: ../en/ch02-tour-merge.xml:172
3926 msgid ""
3927 "Most merges are simple affairs, but sometimes you'll find yourself merging "
3928 "changes where each modifies the same portions of the same files. Unless both "
3929 "modifications are identical, this results in a <emphasis>conflict</emphasis>, "
3930 "where you have to decide how to reconcile the different changes into "
3931 "something coherent."
3932 msgstr ""
3934 #. type: Content of: <book><chapter><sect1><figure><title>
3935 #: ../en/ch02-tour-merge.xml:180
3936 msgid "Conflicting changes to a document"
3937 msgstr "冲突的修改"
3939 #. type: Content of: <book><chapter><sect1><figure><mediaobject>
3940 #: ../en/ch02-tour-merge.xml:182
3941 msgid ""
3942 "<imageobject><imagedata fileref=\"figs/tour-merge-conflict.png\"/></"
3943 "imageobject>"
3944 msgstr ""
3946 #. type: Content of: <book><chapter><sect1><para>
3947 #: ../en/ch02-tour-merge.xml:187
3948 msgid ""
3949 "<xref linkend=\"fig:tour-merge:conflict\"/> illustrates an instance of two "
3950 "conflicting changes to a document. We started with a single version of the "
3951 "file; then we made some changes; while someone else made different changes to "
3952 "the same text. Our task in resolving the conflicting changes is to decide "
3953 "what the file should look like."
3954 msgstr ""
3956 #. type: Content of: <book><chapter><sect1><para>
3957 #: ../en/ch02-tour-merge.xml:194
3958 msgid ""
3959 "Mercurial doesn't have a built-in facility for handling conflicts. Instead, "
3960 "it runs an external program called <command>hgmerge</command>. This is a "
3961 "shell script that is bundled with Mercurial; you can change it to behave "
3962 "however you please. What it does by default is try to find one of several "
3963 "different merging tools that are likely to be installed on your system. It "
3964 "first tries a few fully automatic merging tools; if these don't succeed "
3965 "(because the resolution process requires human guidance) or aren't present, "
3966 "the script tries a few different graphical merging tools."
3967 msgstr ""
3969 #. type: Content of: <book><chapter><sect1><para>
3970 #: ../en/ch02-tour-merge.xml:205
3971 msgid ""
3972 "It's also possible to get Mercurial to run another program or script instead "
3973 "of <command>hgmerge</command>, by setting the <envar>HGMERGE</envar> "
3974 "environment variable to the name of your preferred program."
3975 msgstr ""
3977 #. type: Content of: <book><chapter><sect1><sect2><title>
3978 #: ../en/ch02-tour-merge.xml:211
3979 msgid "Using a graphical merge tool"
3980 msgstr "使用图形合并工具"
3982 #. type: Content of: <book><chapter><sect1><sect2><para>
3983 #: ../en/ch02-tour-merge.xml:213
3984 msgid ""
3985 "My preferred graphical merge tool is <command>kdiff3</command>, which I'll "
3986 "use to describe the features that are common to graphical file merging "
3987 "tools. You can see a screenshot of <command>kdiff3</command> in action in "
3988 "<xref linkend=\"fig:tour-merge:kdiff3\"/>. The kind of merge it is "
3989 "performing is called a <emphasis>three-way merge</emphasis>, because there "
3990 "are three different versions of the file of interest to us. The tool thus "
3991 "splits the upper portion of the window into three panes:"
3992 msgstr ""
3994 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
3995 #: ../en/ch02-tour-merge.xml:223
3996 msgid ""
3997 "At the left is the <emphasis>base</emphasis> version of the file, i.e. the "
3998 "most recent version from which the two versions we're trying to merge are "
3999 "descended."
4000 msgstr ""
4002 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
4003 #: ../en/ch02-tour-merge.xml:228
4004 msgid ""
4005 "In the middle is <quote>our</quote> version of the file, with the contents "
4006 "that we modified."
4007 msgstr ""
4009 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
4010 #: ../en/ch02-tour-merge.xml:231
4011 msgid ""
4012 "On the right is <quote>their</quote> version of the file, the one that from "
4013 "the changeset that we're trying to merge with."
4014 msgstr ""
4016 #. type: Content of: <book><chapter><sect1><sect2><para>
4017 #: ../en/ch02-tour-merge.xml:235
4018 msgid ""
4019 "In the pane below these is the current <emphasis>result</emphasis> of the "
4020 "merge. Our task is to replace all of the red text, which indicates unresolved "
4021 "conflicts, with some sensible merger of the <quote>ours</quote> and "
4022 "<quote>theirs</quote> versions of the file."
4023 msgstr ""
4025 #. type: Content of: <book><chapter><sect1><sect2><para>
4026 #: ../en/ch02-tour-merge.xml:242
4027 msgid ""
4028 "All four of these panes are <emphasis>locked together</emphasis>; if we "
4029 "scroll vertically or horizontally in any of them, the others are updated to "
4030 "display the corresponding sections of their respective files."
4031 msgstr ""
4033 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
4034 #: ../en/ch02-tour-merge.xml:248
4035 msgid "Using <command>kdiff3</command> to merge versions of a file"
4036 msgstr "使用 <command>kdiff3</command> 合并文件的不同版本"
4038 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
4039 #: ../en/ch02-tour-merge.xml:251
4040 msgid ""
4041 "<imageobject> <imagedata width=\"100%\" fileref=\"figs/kdiff3.png\"/></"
4042 "imageobject>"
4043 msgstr ""
4045 #. type: Content of: <book><chapter><sect1><sect2><para>
4046 #: ../en/ch02-tour-merge.xml:259
4047 msgid ""
4048 "For each conflicting portion of the file, we can choose to resolve the "
4049 "conflict using some combination of text from the base version, ours, or "
4050 "theirs. We can also manually edit the merged file at any time, in case we "
4051 "need to make further modifications."
4052 msgstr ""
4054 #. type: Content of: <book><chapter><sect1><sect2><para>
4055 #: ../en/ch02-tour-merge.xml:265
4056 msgid ""
4057 "There are <emphasis>many</emphasis> file merging tools available, too many to "
4058 "cover here. They vary in which platforms they are available for, and in "
4059 "their particular strengths and weaknesses. Most are tuned for merging files "
4060 "containing plain text, while a few are aimed at specialised file formats "
4061 "(generally XML)."
4062 msgstr ""
4064 #. type: Content of: <book><chapter><sect1><sect2><title>
4065 #: ../en/ch02-tour-merge.xml:274
4066 msgid "A worked example"
4067 msgstr "合并实例"
4069 #. type: Content of: <book><chapter><sect1><sect2><para>
4070 #: ../en/ch02-tour-merge.xml:276
4071 msgid ""
4072 "In this example, we will reproduce the file modification history of <xref "
4073 "linkend=\"fig:tour-merge:conflict\"/> above. Let's begin by creating a "
4074 "repository with a base version of our document."
4075 msgstr ""
4077 #. type: Content of: <book><chapter><sect1><sect2><para>
4078 #: ../en/ch02-tour-merge.xml:283
4079 msgid "We'll clone the repository and make a change to the file."
4080 msgstr ""
4082 #. type: Content of: <book><chapter><sect1><sect2><para>
4083 #: ../en/ch02-tour-merge.xml:288
4084 msgid ""
4085 "And another clone, to simulate someone else making a change to the file. "
4086 "(This hints at the idea that it's not all that unusual to merge with yourself "
4087 "when you isolate tasks in separate repositories, and indeed to find and "
4088 "resolve conflicts while doing so.)"
4089 msgstr ""
4091 #. type: Content of: <book><chapter><sect1><sect2><para>
4092 #: ../en/ch02-tour-merge.xml:296
4093 msgid ""
4094 "Having created two different versions of the file, we'll set up an "
4095 "environment suitable for running our merge."
4096 msgstr ""
4098 #. type: Content of: <book><chapter><sect1><sect2><para>
4099 #: ../en/ch02-tour-merge.xml:302
4100 msgid ""
4101 "In this example, I won't use Mercurial's normal <command>hgmerge</command> "
4102 "program to do the merge, because it would drop my nice automated example-"
4103 "running tool into a graphical user interface. Instead, I'll set "
4104 "<envar>HGMERGE</envar> to tell Mercurial to use the non-interactive "
4105 "<command>merge</command> command. This is bundled with many Unix-like "
4106 "systems. If you're following this example on your computer, don't bother "
4107 "setting <envar>HGMERGE</envar>."
4108 msgstr ""
4110 #. type: Content of: <book><chapter><sect1><sect2><para>
4111 #: ../en/ch02-tour-merge.xml:312
4112 msgid "<emphasis role=\"bold\">XXX FIX THIS EXAMPLE.</emphasis>"
4113 msgstr ""
4115 #. type: Content of: <book><chapter><sect1><sect2><para>
4116 #: ../en/ch02-tour-merge.xml:317
4117 msgid ""
4118 "Because <command>merge</command> can't resolve the conflicting changes, it "
4119 "leaves <emphasis>merge markers</emphasis> inside the file that has conflicts, "
4120 "indicating which lines have conflicts, and whether they came from our version "
4121 "of the file or theirs."
4122 msgstr ""
4124 #. type: Content of: <book><chapter><sect1><sect2><para>
4125 #: ../en/ch02-tour-merge.xml:323
4126 msgid ""
4127 "Mercurial can tell from the way <command>merge</command> exits that it wasn't "
4128 "able to merge successfully, so it tells us what commands we'll need to run if "
4129 "we want to redo the merging operation. This could be useful if, for example, "
4130 "we were running a graphical merge tool and quit because we were confused or "
4131 "realised we had made a mistake."
4132 msgstr ""
4134 #. type: Content of: <book><chapter><sect1><sect2><para>
4135 #: ../en/ch02-tour-merge.xml:330
4136 msgid ""
4137 "If automatic or manual merges fail, there's nothing to prevent us from "
4138 "<quote>fixing up</quote> the affected files ourselves, and committing the "
4139 "results of our merge:"
4140 msgstr ""
4142 #. type: Content of: <book><chapter><sect1><title>
4143 #: ../en/ch02-tour-merge.xml:339
4144 msgid "Simplifying the pull-merge-commit sequence"
4145 msgstr "简化拉-合并-提交程序"
4147 #. type: Content of: <book><chapter><sect1><para>
4148 #: ../en/ch02-tour-merge.xml:341
4149 msgid ""
4150 "The process of merging changes as outlined above is straightforward, but "
4151 "requires running three commands in sequence."
4152 msgstr ""
4154 #. type: Content of: <book><chapter><sect1><para>
4155 #: ../en/ch02-tour-merge.xml:347
4156 msgid ""
4157 "In the case of the final commit, you also need to enter a commit message, "
4158 "which is almost always going to be a piece of uninteresting "
4159 "<quote>boilerplate</quote> text."
4160 msgstr ""
4162 #. type: Content of: <book><chapter><sect1><para>
4163 #: ../en/ch02-tour-merge.xml:351
4164 msgid ""
4165 "It would be nice to reduce the number of steps needed, if this were "
4166 "possible. Indeed, Mercurial is distributed with an extension called <literal "
4167 "role=\"hg-ext\">fetch</literal> that does just this."
4168 msgstr ""
4170 #. type: Content of: <book><chapter><sect1><para>
4171 #: ../en/ch02-tour-merge.xml:356
4172 msgid ""
4173 "Mercurial provides a flexible extension mechanism that lets people extend its "
4174 "functionality, while keeping the core of Mercurial small and easy to deal "
4175 "with. Some extensions add new commands that you can use from the command "
4176 "line, while others work <quote>behind the scenes,</quote> for example adding "
4177 "capabilities to the server."
4178 msgstr ""
4180 #. type: Content of: <book><chapter><sect1><para>
4181 #: ../en/ch02-tour-merge.xml:363
4182 msgid ""
4183 "The <literal role=\"hg-ext\">fetch</literal> extension adds a new command "
4184 "called, not surprisingly, <command role=\"hg-cmd\">hg fetch</command>. This "
4185 "extension acts as a combination of <command role=\"hg-cmd\">hg pull</"
4186 "command>, <command role=\"hg-cmd\">hg update</command> and <command role=\"hg-"
4187 "cmd\">hg merge</command>. It begins by pulling changes from another "
4188 "repository into the current repository. If it finds that the changes added a "
4189 "new head to the repository, it begins a merge, then commits the result of the "
4190 "merge with an automatically-generated commit message. If no new heads were "
4191 "added, it updates the working directory to the new tip changeset."
4192 msgstr ""
4194 #. type: Content of: <book><chapter><sect1><para>
4195 #: ../en/ch02-tour-merge.xml:376
4196 msgid ""
4197 "Enabling the <literal role=\"hg-ext\">fetch</literal> extension is easy. "
4198 "Edit your <filename role=\"special\">.hgrc</filename>, and either go to the "
4199 "<literal role=\"rc-extensions\">extensions</literal> section or create an "
4200 "<literal role=\"rc-extensions\">extensions</literal> section. Then add a line "
4201 "that simply reads <quote><literal>fetch </literal></quote>."
4202 msgstr ""
4204 #. type: Content of: <book><chapter><sect1><para>
4205 #: ../en/ch02-tour-merge.xml:385
4206 msgid ""
4207 "(Normally, on the right-hand side of the <quote><literal>=</literal></quote> "
4208 "would appear the location of the extension, but since the <literal role=\"hg-"
4209 "ext\">fetch</literal> extension is in the standard distribution, Mercurial "
4210 "knows where to search for it.)"
4211 msgstr ""
4213 #. type: Content of: <book><chapter><title>
4214 #: ../en/ch03-concepts.xml:5
4215 msgid "Behind the scenes"
4216 msgstr "Mercurial 内幕"
4218 #. type: Content of: <book><chapter><para>
4219 #: ../en/ch03-concepts.xml:7
4220 msgid ""
4221 "Unlike many revision control systems, the concepts upon which Mercurial is "
4222 "built are simple enough that it's easy to understand how the software really "
4223 "works. Knowing this certainly isn't necessary, but I find it useful to have "
4224 "a <quote>mental model</quote> of what's going on."
4225 msgstr ""
4227 #. type: Content of: <book><chapter><para>
4228 #: ../en/ch03-concepts.xml:13
4229 msgid ""
4230 "This understanding gives me confidence that Mercurial has been carefully "
4231 "designed to be both <emphasis>safe</emphasis> and <emphasis>efficient</"
4232 "emphasis>. And just as importantly, if it's easy for me to retain a good "
4233 "idea of what the software is doing when I perform a revision control task, "
4234 "I'm less likely to be surprised by its behaviour."
4235 msgstr ""
4237 #. type: Content of: <book><chapter><para>
4238 #: ../en/ch03-concepts.xml:20
4239 msgid ""
4240 "In this chapter, we'll initially cover the core concepts behind Mercurial's "
4241 "design, then continue to discuss some of the interesting details of its "
4242 "implementation."
4243 msgstr ""
4245 #. type: Content of: <book><chapter><sect1><title>
4246 #: ../en/ch03-concepts.xml:25
4247 msgid "Mercurial's historical record"
4248 msgstr "Mercurial 的历史记录"
4250 #. type: Content of: <book><chapter><sect1><sect2><title>
4251 #: ../en/ch03-concepts.xml:28
4252 msgid "Tracking the history of a single file"
4253 msgstr "跟踪单一文件的历史"
4255 #. type: Content of: <book><chapter><sect1><sect2><para>
4256 #: ../en/ch03-concepts.xml:30
4257 msgid ""
4258 "When Mercurial tracks modifications to a file, it stores the history of that "
4259 "file in a metadata object called a <emphasis>filelog</emphasis>. Each entry "
4260 "in the filelog contains enough information to reconstruct one revision of the "
4261 "file that is being tracked. Filelogs are stored as files in the <filename "
4262 "role=\"special\" class=\"directory\">.hg/store/data</filename> directory. A "
4263 "filelog contains two kinds of information: revision data, and an index to "
4264 "help Mercurial to find a revision efficiently."
4265 msgstr ""
4267 #. type: Content of: <book><chapter><sect1><sect2><para>
4268 #: ../en/ch03-concepts.xml:41
4269 msgid ""
4270 "A file that is large, or has a lot of history, has its filelog stored in "
4271 "separate data (<quote><literal>.d</literal></quote> suffix) and index "
4272 "(<quote><literal>.i</literal></quote> suffix) files. For small files without "
4273 "much history, the revision data and index are combined in a single "
4274 "<quote><literal>.i</literal></quote> file. The correspondence between a file "
4275 "in the working directory and the filelog that tracks its history in the "
4276 "repository is illustrated in <xref linkend=\"fig:concepts:filelog\"/>."
4277 msgstr ""
4279 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
4280 #: ../en/ch03-concepts.xml:53
4281 msgid ""
4282 "Relationships between files in working directory and filelogs in repository"
4283 msgstr "工作目录中的文件与版本库中的文件日志之间的关系"
4285 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
4286 #: ../en/ch03-concepts.xml:56
4287 msgid "<imageobject><imagedata fileref=\"figs/filelog.png\"/></imageobject>"
4288 msgstr ""
4290 #. type: Content of: <book><chapter><sect1><sect2><title>
4291 #: ../en/ch03-concepts.xml:63
4292 msgid "Managing tracked files"
4293 msgstr "管理跟踪的文件"
4295 #. type: Content of: <book><chapter><sect1><sect2><para>
4296 #: ../en/ch03-concepts.xml:65
4297 msgid ""
4298 "Mercurial uses a structure called a <emphasis>manifest</emphasis> to collect "
4299 "together information about the files that it tracks. Each entry in the "
4300 "manifest contains information about the files present in a single changeset. "
4301 "An entry records which files are present in the changeset, the revision of "
4302 "each file, and a few other pieces of file metadata."
4303 msgstr ""
4305 #. type: Content of: <book><chapter><sect1><sect2><title>
4306 #: ../en/ch03-concepts.xml:75
4307 msgid "Recording changeset information"
4308 msgstr "记录修改集信息"
4310 #. type: Content of: <book><chapter><sect1><sect2><para>
4311 #: ../en/ch03-concepts.xml:77
4312 msgid ""
4313 "The <emphasis>changelog</emphasis> contains information about each "
4314 "changeset. Each revision records who committed a change, the changeset "
4315 "comment, other pieces of changeset-related information, and the revision of "
4316 "the manifest to use."
4317 msgstr ""
4319 #. type: Content of: <book><chapter><sect1><sect2><title>
4320 #: ../en/ch03-concepts.xml:85
4321 msgid "Relationships between revisions"
4322 msgstr "版本之间的关系"
4324 #. type: Content of: <book><chapter><sect1><sect2><para>
4325 #: ../en/ch03-concepts.xml:87
4326 msgid ""
4327 "Within a changelog, a manifest, or a filelog, each revision stores a pointer "
4328 "to its immediate parent (or to its two parents, if it's a merge revision). "
4329 "As I mentioned above, there are also relationships between revisions "
4330 "<emphasis>across</emphasis> these structures, and they are hierarchical in "
4331 "nature."
4332 msgstr ""
4334 #. type: Content of: <book><chapter><sect1><sect2><para>
4335 #: ../en/ch03-concepts.xml:94
4336 msgid ""
4337 "For every changeset in a repository, there is exactly one revision stored in "
4338 "the changelog. Each revision of the changelog contains a pointer to a single "
4339 "revision of the manifest. A revision of the manifest stores a pointer to a "
4340 "single revision of each filelog tracked when that changeset was created. "
4341 "These relationships are illustrated in <xref linkend=\"fig:concepts:metadata"
4342 "\"/>."
4343 msgstr ""
4345 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
4346 #: ../en/ch03-concepts.xml:103
4347 msgid "Metadata relationships"
4348 msgstr "元数据之间的关系"
4350 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
4351 #: ../en/ch03-concepts.xml:105
4352 msgid "<imageobject><imagedata fileref=\"figs/metadata.png\"/></imageobject>"
4353 msgstr ""
4355 #. type: Content of: <book><chapter><sect1><sect2><para>
4356 #: ../en/ch03-concepts.xml:110
4357 msgid ""
4358 "As the illustration shows, there is <emphasis>not</emphasis> a <quote>one to "
4359 "one</quote> relationship between revisions in the changelog, manifest, or "
4360 "filelog. If the manifest hasn't changed between two changesets, the changelog "
4361 "entries for those changesets will point to the same revision of the "
4362 "manifest. If a file that Mercurial tracks hasn't changed between two "
4363 "changesets, the entry for that file in the two revisions of the manifest will "
4364 "point to the same revision of its filelog."
4365 msgstr ""
4367 #. type: Content of: <book><chapter><sect1><title>
4368 #: ../en/ch03-concepts.xml:123
4369 msgid "Safe, efficient storage"
4370 msgstr "安全,高效的存储"
4372 #. type: Content of: <book><chapter><sect1><para>
4373 #: ../en/ch03-concepts.xml:125
4374 msgid ""
4375 "The underpinnings of changelogs, manifests, and filelogs are provided by a "
4376 "single structure called the <emphasis>revlog</emphasis>."
4377 msgstr ""
4379 #. type: Content of: <book><chapter><sect1><sect2><title>
4380 #: ../en/ch03-concepts.xml:130
4381 msgid "Efficient storage"
4382 msgstr "高效存储"
4384 #. type: Content of: <book><chapter><sect1><sect2><para>
4385 #: ../en/ch03-concepts.xml:132
4386 msgid ""
4387 "The revlog provides efficient storage of revisions using a <emphasis>delta</"
4388 "emphasis> mechanism. Instead of storing a complete copy of a file for each "
4389 "revision, it stores the changes needed to transform an older revision into "
4390 "the new revision. For many kinds of file data, these deltas are typically a "
4391 "fraction of a percent of the size of a full copy of a file."
4392 msgstr ""
4394 #. type: Content of: <book><chapter><sect1><sect2><para>
4395 #: ../en/ch03-concepts.xml:140
4396 msgid ""
4397 "Some obsolete revision control systems can only work with deltas of text "
4398 "files. They must either store binary files as complete snapshots or encoded "
4399 "into a text representation, both of which are wasteful approaches. Mercurial "
4400 "can efficiently handle deltas of files with arbitrary binary contents; it "
4401 "doesn't need to treat text as special."
4402 msgstr ""
4404 #. type: Content of: <book><chapter><sect1><sect2><title>
4405 #: ../en/ch03-concepts.xml:149
4406 msgid "Safe operation"
4407 msgstr "安全操作"
4409 #. type: Content of: <book><chapter><sect1><sect2><para>
4410 #: ../en/ch03-concepts.xml:151
4411 msgid ""
4412 "Mercurial only ever <emphasis>appends</emphasis> data to the end of a revlog "
4413 "file. It never modifies a section of a file after it has written it. This is "
4414 "both more robust and efficient than schemes that need to modify or rewrite "
4415 "data."
4416 msgstr ""
4418 #. type: Content of: <book><chapter><sect1><sect2><para>
4419 #: ../en/ch03-concepts.xml:157
4420 msgid ""
4421 "In addition, Mercurial treats every write as part of a <emphasis>transaction</"
4422 "emphasis> that can span a number of files. A transaction is "
4423 "<emphasis>atomic</emphasis>: either the entire transaction succeeds and its "
4424 "effects are all visible to readers in one go, or the whole thing is undone. "
4425 "This guarantee of atomicity means that if you're running two copies of "
4426 "Mercurial, where one is reading data and one is writing it, the reader will "
4427 "never see a partially written result that might confuse it."
4428 msgstr ""
4430 #. type: Content of: <book><chapter><sect1><sect2><para>
4431 #: ../en/ch03-concepts.xml:167
4432 msgid ""
4433 "The fact that Mercurial only appends to files makes it easier to provide this "
4434 "transactional guarantee. The easier it is to do stuff like this, the more "
4435 "confident you should be that it's done correctly."
4436 msgstr ""
4438 #. type: Content of: <book><chapter><sect1><sect2><title>
4439 #: ../en/ch03-concepts.xml:174
4440 msgid "Fast retrieval"
4441 msgstr "快速检索"
4443 #. type: Content of: <book><chapter><sect1><sect2><para>
4444 #: ../en/ch03-concepts.xml:176
4445 msgid ""
4446 "Mercurial cleverly avoids a pitfall common to all earlier revision control "
4447 "systems: the problem of <emphasis>inefficient retrieval</emphasis>. Most "
4448 "revision control systems store the contents of a revision as an incremental "
4449 "series of modifications against a <quote>snapshot</quote>. To reconstruct a "
4450 "specific revision, you must first read the snapshot, and then every one of "
4451 "the revisions between the snapshot and your target revision. The more "
4452 "history that a file accumulates, the more revisions you must read, hence the "
4453 "longer it takes to reconstruct a particular revision."
4454 msgstr ""
4456 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
4457 #: ../en/ch03-concepts.xml:188
4458 msgid "Snapshot of a revlog, with incremental deltas"
4459 msgstr "版本日志的快照,以及增量差异"
4461 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
4462 #: ../en/ch03-concepts.xml:190
4463 msgid "<imageobject><imagedata fileref=\"figs/snapshot.png\"/></imageobject>"
4464 msgstr ""
4466 #. type: Content of: <book><chapter><sect1><sect2><para>
4467 #: ../en/ch03-concepts.xml:195
4468 msgid ""
4469 "The innovation that Mercurial applies to this problem is simple but "
4470 "effective. Once the cumulative amount of delta information stored since the "
4471 "last snapshot exceeds a fixed threshold, it stores a new snapshot "
4472 "(compressed, of course), instead of another delta. This makes it possible to "
4473 "reconstruct <emphasis>any</emphasis> revision of a file quickly. This "
4474 "approach works so well that it has since been copied by several other "
4475 "revision control systems."
4476 msgstr ""
4478 #. type: Content of: <book><chapter><sect1><sect2><para>
4479 #: ../en/ch03-concepts.xml:204
4480 msgid ""
4481 "<xref linkend=\"fig:concepts:snapshot\"/> illustrates the idea. In an entry "
4482 "in a revlog's index file, Mercurial stores the range of entries from the data "
4483 "file that it must read to reconstruct a particular revision."
4484 msgstr ""
4486 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
4487 #: ../en/ch03-concepts.xml:210
4488 msgid "Aside: the influence of video compression"
4489 msgstr "旁白: 视频压缩的影响"
4491 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
4492 #: ../en/ch03-concepts.xml:212
4493 msgid ""
4494 "If you're familiar with video compression or have ever watched a TV feed "
4495 "through a digital cable or satellite service, you may know that most video "
4496 "compression schemes store each frame of video as a delta against its "
4497 "predecessor frame. In addition, these schemes use <quote>lossy</quote> "
4498 "compression techniques to increase the compression ratio, so visual errors "
4499 "accumulate over the course of a number of inter-frame deltas."
4500 msgstr ""
4502 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
4503 #: ../en/ch03-concepts.xml:221
4504 msgid ""
4505 "Because it's possible for a video stream to <quote>drop out</quote> "
4506 "occasionally due to signal glitches, and to limit the accumulation of "
4507 "artefacts introduced by the lossy compression process, video encoders "
4508 "periodically insert a complete frame (called a <quote>key frame</quote>) into "
4509 "the video stream; the next delta is generated against that frame. This means "
4510 "that if the video signal gets interrupted, it will resume once the next key "
4511 "frame is received. Also, the accumulation of encoding errors restarts anew "
4512 "with each key frame."
4513 msgstr ""
4515 #. type: Content of: <book><chapter><sect1><sect2><title>
4516 #: ../en/ch03-concepts.xml:235
4517 msgid "Identification and strong integrity"
4518 msgstr "鉴别和强完整性"
4520 #. type: Content of: <book><chapter><sect1><sect2><para>
4521 #: ../en/ch03-concepts.xml:237
4522 msgid ""
4523 "Along with delta or snapshot information, a revlog entry contains a "
4524 "cryptographic hash of the data that it represents. This makes it difficult "
4525 "to forge the contents of a revision, and easy to detect accidental corruption."
4526 msgstr ""
4528 #. type: Content of: <book><chapter><sect1><sect2><para>
4529 #: ../en/ch03-concepts.xml:242
4530 msgid ""
4531 "Hashes provide more than a mere check against corruption; they are used as "
4532 "the identifiers for revisions. The changeset identification hashes that you "
4533 "see as an end user are from revisions of the changelog. Although filelogs "
4534 "and the manifest also use hashes, Mercurial only uses these behind the scenes."
4535 msgstr ""
4537 #. type: Content of: <book><chapter><sect1><sect2><para>
4538 #: ../en/ch03-concepts.xml:249
4539 msgid ""
4540 "Mercurial verifies that hashes are correct when it retrieves file revisions "
4541 "and when it pulls changes from another repository. If it encounters an "
4542 "integrity problem, it will complain and stop whatever it's doing."
4543 msgstr ""
4545 #. type: Content of: <book><chapter><sect1><sect2><para>
4546 #: ../en/ch03-concepts.xml:254
4547 msgid ""
4548 "In addition to the effect it has on retrieval efficiency, Mercurial's use of "
4549 "periodic snapshots makes it more robust against partial data corruption. If "
4550 "a revlog becomes partly corrupted due to a hardware error or system bug, it's "
4551 "often possible to reconstruct some or most revisions from the uncorrupted "
4552 "sections of the revlog, both before and after the corrupted section. This "
4553 "would not be possible with a delta-only storage model."
4554 msgstr ""
4556 #. type: Content of: <book><chapter><sect1><title>
4557 #: ../en/ch03-concepts.xml:266
4558 msgid "Revision history, branching, and merging"
4559 msgstr "修订历史,分支与合并"
4561 #. type: Content of: <book><chapter><sect1><para>
4562 #: ../en/ch03-concepts.xml:268
4563 msgid ""
4564 "Every entry in a Mercurial revlog knows the identity of its immediate "
4565 "ancestor revision, usually referred to as its <emphasis>parent</emphasis>. "
4566 "In fact, a revision contains room for not one parent, but two. Mercurial "
4567 "uses a special hash, called the <quote>null ID</quote>, to represent the idea "
4568 "<quote>there is no parent here</quote>. This hash is simply a string of "
4569 "zeroes."
4570 msgstr ""
4572 #. type: Content of: <book><chapter><sect1><para>
4573 #: ../en/ch03-concepts.xml:276
4574 msgid ""
4575 "In <xref linkend=\"fig:concepts:revlog\"/>, you can see an example of the "
4576 "conceptual structure of a revlog. Filelogs, manifests, and changelogs all "
4577 "have this same structure; they differ only in the kind of data stored in each "
4578 "delta or snapshot."
4579 msgstr ""
4581 #. type: Content of: <book><chapter><sect1><para>
4582 #: ../en/ch03-concepts.xml:282
4583 msgid ""
4584 "The first revision in a revlog (at the bottom of the image) has the null ID "
4585 "in both of its parent slots. For a <quote>normal</quote> revision, its first "
4586 "parent slot contains the ID of its parent revision, and its second contains "
4587 "the null ID, indicating that the revision has only one real parent. Any two "
4588 "revisions that have the same parent ID are branches. A revision that "
4589 "represents a merge between branches has two normal revision IDs in its parent "
4590 "slots."
4591 msgstr ""
4593 #. type: Content of: <book><chapter><sect1><figure><title>
4594 #: ../en/ch03-concepts.xml:292
4595 msgid "The conceptual structure of a revlog"
4596 msgstr "版本日志的设计结构"
4598 #. type: Content of: <book><chapter><sect1><figure><mediaobject>
4599 #: ../en/ch03-concepts.xml:294
4600 msgid "<imageobject><imagedata fileref=\"figs/revlog.png\"/></imageobject>"
4601 msgstr ""
4603 #. type: Content of: <book><chapter><sect1><title>
4604 #: ../en/ch03-concepts.xml:301
4605 msgid "The working directory"
4606 msgstr "工作目录"
4608 #. type: Content of: <book><chapter><sect1><para>
4609 #: ../en/ch03-concepts.xml:303
4610 msgid ""
4611 "In the working directory, Mercurial stores a snapshot of the files from the "
4612 "repository as of a particular changeset."
4613 msgstr ""
4615 #. type: Content of: <book><chapter><sect1><para>
4616 #: ../en/ch03-concepts.xml:306
4617 msgid ""
4618 "The working directory <quote>knows</quote> which changeset it contains. When "
4619 "you update the working directory to contain a particular changeset, Mercurial "
4620 "looks up the appropriate revision of the manifest to find out which files it "
4621 "was tracking at the time that changeset was committed, and which revision of "
4622 "each file was then current. It then recreates a copy of each of those files, "
4623 "with the same contents it had when the changeset was committed."
4624 msgstr ""
4626 #. type: Content of: <book><chapter><sect1><para>
4627 #: ../en/ch03-concepts.xml:315
4628 msgid ""
4629 "The <emphasis>dirstate</emphasis> contains Mercurial's knowledge of the "
4630 "working directory. This details which changeset the working directory is "
4631 "updated to, and all of the files that Mercurial is tracking in the working "
4632 "directory."
4633 msgstr ""
4635 #. type: Content of: <book><chapter><sect1><para>
4636 #: ../en/ch03-concepts.xml:321
4637 msgid ""
4638 "Just as a revision of a revlog has room for two parents, so that it can "
4639 "represent either a normal revision (with one parent) or a merge of two "
4640 "earlier revisions, the dirstate has slots for two parents. When you use the "
4641 "<command role=\"hg-cmd\">hg update</command> command, the changeset that you "
4642 "update to is stored in the <quote>first parent</quote> slot, and the null ID "
4643 "in the second. When you <command role=\"hg-cmd\">hg merge</command> with "
4644 "another changeset, the first parent remains unchanged, and the second parent "
4645 "is filled in with the changeset you're merging with. The <command role=\"hg-"
4646 "cmd\">hg parents</command> command tells you what the parents of the dirstate "
4647 "are."
4648 msgstr ""
4650 #. type: Content of: <book><chapter><sect1><sect2><title>
4651 #: ../en/ch03-concepts.xml:335
4652 msgid "What happens when you commit"
4653 msgstr "当你提交时发生的事情"
4655 #. type: Content of: <book><chapter><sect1><sect2><para>
4656 #: ../en/ch03-concepts.xml:337
4657 msgid ""
4658 "The dirstate stores parent information for more than just book-keeping "
4659 "purposes. Mercurial uses the parents of the dirstate as <emphasis>the "
4660 "parents of a new changeset</emphasis> when you perform a commit."
4661 msgstr ""
4663 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
4664 #: ../en/ch03-concepts.xml:343
4665 msgid "The working directory can have two parents"
4666 msgstr "工作目录可以有两个父亲"
4668 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
4669 #: ../en/ch03-concepts.xml:345
4670 msgid "<imageobject><imagedata fileref=\"figs/wdir.png\"/></imageobject>"
4671 msgstr ""
4673 #. type: Content of: <book><chapter><sect1><sect2><para>
4674 #: ../en/ch03-concepts.xml:350
4675 msgid ""
4676 "<xref linkend=\"fig:concepts:wdir\"/> shows the normal state of the working "
4677 "directory, where it has a single changeset as parent. That changeset is the "
4678 "<emphasis>tip</emphasis>, the newest changeset in the repository that has no "
4679 "children."
4680 msgstr ""
4682 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
4683 #: ../en/ch03-concepts.xml:357
4684 msgid "The working directory gains new parents after a commit"
4685 msgstr "提交之后,工作目录的父亲就改变了"
4687 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
4688 #: ../en/ch03-concepts.xml:360
4689 msgid ""
4690 "<imageobject><imagedata fileref=\"figs/wdir-after-commit.png\"/></imageobject>"
4691 msgstr ""
4693 #. type: Content of: <book><chapter><sect1><sect2><para>
4694 #: ../en/ch03-concepts.xml:365
4695 msgid ""
4696 "It's useful to think of the working directory as <quote>the changeset I'm "
4697 "about to commit</quote>. Any files that you tell Mercurial that you've "
4698 "added, removed, renamed, or copied will be reflected in that changeset, as "
4699 "will modifications to any files that Mercurial is already tracking; the new "
4700 "changeset will have the parents of the working directory as its parents."
4701 msgstr ""
4703 #. type: Content of: <book><chapter><sect1><sect2><para>
4704 #: ../en/ch03-concepts.xml:373
4705 msgid ""
4706 "After a commit, Mercurial will update the parents of the working directory, "
4707 "so that the first parent is the ID of the new changeset, and the second is "
4708 "the null ID. This is shown in <xref linkend=\"fig:concepts:wdir-after-commit"
4709 "\"/>. Mercurial doesn't touch any of the files in the working directory when "
4710 "you commit; it just modifies the dirstate to note its new parents."
4711 msgstr ""
4713 #. type: Content of: <book><chapter><sect1><sect2><title>
4714 #: ../en/ch03-concepts.xml:384
4715 msgid "Creating a new head"
4716 msgstr "创建新顶点"
4718 #. type: Content of: <book><chapter><sect1><sect2><para>
4719 #: ../en/ch03-concepts.xml:386
4720 msgid ""
4721 "It's perfectly normal to update the working directory to a changeset other "
4722 "than the current tip. For example, you might want to know what your project "
4723 "looked like last Tuesday, or you could be looking through changesets to see "
4724 "which one introduced a bug. In cases like this, the natural thing to do is "
4725 "update the working directory to the changeset you're interested in, and then "
4726 "examine the files in the working directory directly to see their contents as "
4727 "they were when you committed that changeset. The effect of this is shown in "
4728 "<xref linkend=\"fig:concepts:wdir-pre-branch\"/>."
4729 msgstr ""
4731 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
4732 #: ../en/ch03-concepts.xml:398
4733 msgid "The working directory, updated to an older changeset"
4734 msgstr "同步到旧修改集的工作目录"
4736 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
4737 #: ../en/ch03-concepts.xml:401
4738 msgid ""
4739 "<imageobject><imagedata fileref=\"figs/wdir-pre-branch.png\"/></imageobject>"
4740 msgstr ""
4742 #. type: Content of: <book><chapter><sect1><sect2><para>
4743 #: ../en/ch03-concepts.xml:406
4744 msgid ""
4745 "Having updated the working directory to an older changeset, what happens if "
4746 "you make some changes, and then commit? Mercurial behaves in the same way as "
4747 "I outlined above. The parents of the working directory become the parents of "
4748 "the new changeset. This new changeset has no children, so it becomes the new "
4749 "tip. And the repository now contains two changesets that have no children; "
4750 "we call these <emphasis>heads</emphasis>. You can see the structure that "
4751 "this creates in <xref linkend=\"fig:concepts:wdir-branch\"/>."
4752 msgstr ""
4754 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
4755 #: ../en/ch03-concepts.xml:418
4756 msgid "After a commit made while synced to an older changeset"
4757 msgstr "对同步到旧修改集的工作目录提交之后"
4759 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
4760 #: ../en/ch03-concepts.xml:421
4761 msgid "<imageobject><imagedata fileref=\"figs/wdir-branch.png\"/></imageobject>"
4762 msgstr ""
4764 #. type: Content of: <book><chapter><sect1><sect2><note><para>
4765 #: ../en/ch03-concepts.xml:427
4766 msgid ""
4767 "If you're new to Mercurial, you should keep in mind a common <quote>error</"
4768 "quote>, which is to use the <command role=\"hg-cmd\">hg pull</command> "
4769 "command without any options. By default, the <command role=\"hg-cmd\">hg "
4770 "pull</command> command <emphasis>does not</emphasis> update the working "
4771 "directory, so you'll bring new changesets into your repository, but the "
4772 "working directory will stay synced at the same changeset as before the pull. "
4773 "If you make some changes and commit afterwards, you'll thus create a new "
4774 "head, because your working directory isn't synced to whatever the current tip "
4775 "is."
4776 msgstr ""
4778 #. type: Content of: <book><chapter><sect1><sect2><note><para>
4779 #: ../en/ch03-concepts.xml:439
4780 msgid ""
4781 "I put the word <quote>error</quote> in quotes because all that you need to do "
4782 "to rectify this situation is <command role=\"hg-cmd\">hg merge</command>, "
4783 "then <command role=\"hg-cmd\">hg commit</command>. In other words, this "
4784 "almost never has negative consequences; it just surprises people. I'll "
4785 "discuss other ways to avoid this behaviour, and why Mercurial behaves in this "
4786 "initially surprising way, later on."
4787 msgstr ""
4789 #. type: Content of: <book><chapter><sect1><sect2><title>
4790 #: ../en/ch03-concepts.xml:451
4791 msgid "Merging heads"
4792 msgstr "合并顶点"
4794 #. type: Content of: <book><chapter><sect1><sect2><para>
4795 #: ../en/ch03-concepts.xml:453
4796 msgid ""
4797 "When you run the <command role=\"hg-cmd\">hg merge</command> command, "
4798 "Mercurial leaves the first parent of the working directory unchanged, and "
4799 "sets the second parent to the changeset you're merging with, as shown in "
4800 "<xref linkend=\"fig:concepts:wdir-merge\"/>."
4801 msgstr ""
4803 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
4804 #: ../en/ch03-concepts.xml:460
4805 msgid "Merging two heads"
4806 msgstr "合并两个顶点"
4808 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
4809 #: ../en/ch03-concepts.xml:462
4810 msgid ""
4811 "<imageobject> <imagedata fileref=\"figs/wdir-merge.png\"/> </imageobject>"
4812 msgstr ""
4814 #. type: Content of: <book><chapter><sect1><sect2><para>
4815 #: ../en/ch03-concepts.xml:469
4816 msgid ""
4817 "Mercurial also has to modify the working directory, to merge the files "
4818 "managed in the two changesets. Simplified a little, the merging process goes "
4819 "like this, for every file in the manifests of both changesets."
4820 msgstr ""
4822 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
4823 #: ../en/ch03-concepts.xml:474
4824 msgid "If neither changeset has modified a file, do nothing with that file."
4825 msgstr ""
4827 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
4828 #: ../en/ch03-concepts.xml:477
4829 msgid ""
4830 "If one changeset has modified a file, and the other hasn't, create the "
4831 "modified copy of the file in the working directory."
4832 msgstr ""
4834 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
4835 #: ../en/ch03-concepts.xml:481
4836 msgid ""
4837 "If one changeset has removed a file, and the other hasn't (or has also "
4838 "deleted it), delete the file from the working directory."
4839 msgstr ""
4841 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
4842 #: ../en/ch03-concepts.xml:485
4843 msgid ""
4844 "If one changeset has removed a file, but the other has modified the file, ask "
4845 "the user what to do: keep the modified file, or remove it?"
4846 msgstr ""
4848 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
4849 #: ../en/ch03-concepts.xml:489
4850 msgid ""
4851 "If both changesets have modified a file, invoke an external merge program to "
4852 "choose the new contents for the merged file. This may require input from the "
4853 "user."
4854 msgstr ""
4856 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
4857 #: ../en/ch03-concepts.xml:494
4858 msgid ""
4859 "If one changeset has modified a file, and the other has renamed or copied the "
4860 "file, make sure that the changes follow the new name of the file."
4861 msgstr ""
4863 #. type: Content of: <book><chapter><sect1><sect2><para>
4864 #: ../en/ch03-concepts.xml:498
4865 msgid ""
4866 "There are more details&emdash;merging has plenty of corner cases&emdash;but "
4867 "these are the most common choices that are involved in a merge. As you can "
4868 "see, most cases are completely automatic, and indeed most merges finish "
4869 "automatically, without requiring your input to resolve any conflicts."
4870 msgstr ""
4872 #. type: Content of: <book><chapter><sect1><sect2><para>
4873 #: ../en/ch03-concepts.xml:505
4874 msgid ""
4875 "When you're thinking about what happens when you commit after a merge, once "
4876 "again the working directory is <quote>the changeset I'm about to commit</"
4877 "quote>. After the <command role=\"hg-cmd\">hg merge</command> command "
4878 "completes, the working directory has two parents; these will become the "
4879 "parents of the new changeset."
4880 msgstr ""
4882 #. type: Content of: <book><chapter><sect1><sect2><para>
4883 #: ../en/ch03-concepts.xml:512
4884 msgid ""
4885 "Mercurial lets you perform multiple merges, but you must commit the results "
4886 "of each individual merge as you go. This is necessary because Mercurial only "
4887 "tracks two parents for both revisions and the working directory. While it "
4888 "would be technically possible to merge multiple changesets at once, the "
4889 "prospect of user confusion and making a terrible mess of a merge immediately "
4890 "becomes overwhelming."
4891 msgstr ""
4893 #. type: Content of: <book><chapter><sect1><title>
4894 #: ../en/ch03-concepts.xml:523
4895 msgid "Other interesting design features"
4896 msgstr "其它有趣的设计特性"
4898 #. type: Content of: <book><chapter><sect1><para>
4899 #: ../en/ch03-concepts.xml:525
4900 msgid ""
4901 "In the sections above, I've tried to highlight some of the most important "
4902 "aspects of Mercurial's design, to illustrate that it pays careful attention "
4903 "to reliability and performance. However, the attention to detail doesn't "
4904 "stop there. There are a number of other aspects of Mercurial's construction "
4905 "that I personally find interesting. I'll detail a few of them here, separate "
4906 "from the <quote>big ticket</quote> items above, so that if you're interested, "
4907 "you can gain a better idea of the amount of thinking that goes into a well-"
4908 "designed system."
4909 msgstr ""
4911 #. type: Content of: <book><chapter><sect1><sect2><title>
4912 #: ../en/ch03-concepts.xml:536
4913 msgid "Clever compression"
4914 msgstr "智能压缩"
4916 #. type: Content of: <book><chapter><sect1><sect2><para>
4917 #: ../en/ch03-concepts.xml:538
4918 msgid ""
4919 "When appropriate, Mercurial will store both snapshots and deltas in "
4920 "compressed form. It does this by always <emphasis>trying to</emphasis> "
4921 "compress a snapshot or delta, but only storing the compressed version if it's "
4922 "smaller than the uncompressed version."
4923 msgstr ""
4925 #. type: Content of: <book><chapter><sect1><sect2><para>
4926 #: ../en/ch03-concepts.xml:544
4927 msgid ""
4928 "This means that Mercurial does <quote>the right thing</quote> when storing a "
4929 "file whose native form is compressed, such as a <literal>zip</literal> "
4930 "archive or a JPEG image. When these types of files are compressed a second "
4931 "time, the resulting file is usually bigger than the once-compressed form, and "
4932 "so Mercurial will store the plain <literal>zip</literal> or JPEG."
4933 msgstr ""
4935 #. type: Content of: <book><chapter><sect1><sect2><para>
4936 #: ../en/ch03-concepts.xml:552
4937 msgid ""
4938 "Deltas between revisions of a compressed file are usually larger than "
4939 "snapshots of the file, and Mercurial again does <quote>the right thing</"
4940 "quote> in these cases. It finds that such a delta exceeds the threshold at "
4941 "which it should store a complete snapshot of the file, so it stores the "
4942 "snapshot, again saving space compared to a naive delta-only approach."
4943 msgstr ""
4945 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
4946 #: ../en/ch03-concepts.xml:561
4947 msgid "Network recompression"
4948 msgstr "网络重新压缩"
4950 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
4951 #: ../en/ch03-concepts.xml:563
4952 msgid ""
4953 "When storing revisions on disk, Mercurial uses the <quote>deflate</quote> "
4954 "compression algorithm (the same one used by the popular <literal>zip</"
4955 "literal> archive format), which balances good speed with a respectable "
4956 "compression ratio. However, when transmitting revision data over a network "
4957 "connection, Mercurial uncompresses the compressed revision data."
4958 msgstr ""
4960 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
4961 #: ../en/ch03-concepts.xml:571
4962 msgid ""
4963 "If the connection is over HTTP, Mercurial recompresses the entire stream of "
4964 "data using a compression algorithm that gives a better compression ratio (the "
4965 "Burrows-Wheeler algorithm from the widely used <literal>bzip2</literal> "
4966 "compression package). This combination of algorithm and compression of the "
4967 "entire stream (instead of a revision at a time) substantially reduces the "
4968 "number of bytes to be transferred, yielding better network performance over "
4969 "almost all kinds of network."
4970 msgstr ""
4972 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
4973 #: ../en/ch03-concepts.xml:581
4974 msgid ""
4975 "(If the connection is over <command>ssh</command>, Mercurial "
4976 "<emphasis>doesn't</emphasis> recompress the stream, because <command>ssh</"
4977 "command> can already do this itself.)"
4978 msgstr ""
4980 #. type: Content of: <book><chapter><sect1><sect2><title>
4981 #: ../en/ch03-concepts.xml:589
4982 msgid "Read/write ordering and atomicity"
4983 msgstr "读写顺序与原子性"
4985 #. type: Content of: <book><chapter><sect1><sect2><para>
4986 #: ../en/ch03-concepts.xml:591
4987 msgid ""
4988 "Appending to files isn't the whole story when it comes to guaranteeing that a "
4989 "reader won't see a partial write. If you recall <xref linkend=\"fig:concepts:"
4990 "metadata\"/>, revisions in the changelog point to revisions in the manifest, "
4991 "and revisions in the manifest point to revisions in filelogs. This hierarchy "
4992 "is deliberate."
4993 msgstr ""
4995 #. type: Content of: <book><chapter><sect1><sect2><para>
4996 #: ../en/ch03-concepts.xml:599
4997 msgid ""
4998 "A writer starts a transaction by writing filelog and manifest data, and "
4999 "doesn't write any changelog data until those are finished. A reader starts "
5000 "by reading changelog data, then manifest data, followed by filelog data."
5001 msgstr ""
5003 #. type: Content of: <book><chapter><sect1><sect2><para>
5004 #: ../en/ch03-concepts.xml:604
5005 msgid ""
5006 "Since the writer has always finished writing filelog and manifest data before "
5007 "it writes to the changelog, a reader will never read a pointer to a partially "
5008 "written manifest revision from the changelog, and it will never read a "
5009 "pointer to a partially written filelog revision from the manifest."
5010 msgstr ""
5012 #. type: Content of: <book><chapter><sect1><sect2><title>
5013 #: ../en/ch03-concepts.xml:612
5014 msgid "Concurrent access"
5015 msgstr "并发访问"
5017 #. type: Content of: <book><chapter><sect1><sect2><para>
5018 #: ../en/ch03-concepts.xml:614
5019 msgid ""
5020 "The read/write ordering and atomicity guarantees mean that Mercurial never "
5021 "needs to <emphasis>lock</emphasis> a repository when it's reading data, even "
5022 "if the repository is being written to while the read is occurring. This has a "
5023 "big effect on scalability; you can have an arbitrary number of Mercurial "
5024 "processes safely reading data from a repository safely all at once, no matter "
5025 "whether it's being written to or not."
5026 msgstr ""
5028 #. type: Content of: <book><chapter><sect1><sect2><para>
5029 #: ../en/ch03-concepts.xml:623
5030 msgid ""
5031 "The lockless nature of reading means that if you're sharing a repository on a "
5032 "multi-user system, you don't need to grant other local users permission to "
5033 "<emphasis>write</emphasis> to your repository in order for them to be able to "
5034 "clone it or pull changes from it; they only need <emphasis>read</emphasis> "
5035 "permission. (This is <emphasis>not</emphasis> a common feature among "
5036 "revision control systems, so don't take it for granted! Most require readers "
5037 "to be able to lock a repository to access it safely, and this requires write "
5038 "permission on at least one directory, which of course makes for all kinds of "
5039 "nasty and annoying security and administrative problems.)"
5040 msgstr ""
5042 #. type: Content of: <book><chapter><sect1><sect2><para>
5043 #: ../en/ch03-concepts.xml:636
5044 msgid ""
5045 "Mercurial uses locks to ensure that only one process can write to a "
5046 "repository at a time (the locking mechanism is safe even over filesystems "
5047 "that are notoriously hostile to locking, such as NFS). If a repository is "
5048 "locked, a writer will wait for a while to retry if the repository becomes "
5049 "unlocked, but if the repository remains locked for too long, the process "
5050 "attempting to write will time out after a while. This means that your daily "
5051 "automated scripts won't get stuck forever and pile up if a system crashes "
5052 "unnoticed, for example. (Yes, the timeout is configurable, from zero to "
5053 "infinity.)"
5054 msgstr ""
5056 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
5057 #: ../en/ch03-concepts.xml:648
5058 msgid "Safe dirstate access"
5059 msgstr "安全的目录状态访问"
5061 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
5062 #: ../en/ch03-concepts.xml:650
5063 msgid ""
5064 "As with revision data, Mercurial doesn't take a lock to read the dirstate "
5065 "file; it does acquire a lock to write it. To avoid the possibility of "
5066 "reading a partially written copy of the dirstate file, Mercurial writes to a "
5067 "file with a unique name in the same directory as the dirstate file, then "
5068 "renames the temporary file atomically to <filename>dirstate</filename>. The "
5069 "file named <filename>dirstate</filename> is thus guaranteed to be complete, "
5070 "not partially written."
5071 msgstr ""
5073 #. type: Content of: <book><chapter><sect1><sect2><title>
5074 #: ../en/ch03-concepts.xml:663
5075 msgid "Avoiding seeks"
5076 msgstr "避免查找"
5078 #. type: Content of: <book><chapter><sect1><sect2><para>
5079 #: ../en/ch03-concepts.xml:665
5080 msgid ""
5081 "Critical to Mercurial's performance is the avoidance of seeks of the disk "
5082 "head, since any seek is far more expensive than even a comparatively large "
5083 "read operation."
5084 msgstr ""
5086 #. type: Content of: <book><chapter><sect1><sect2><para>
5087 #: ../en/ch03-concepts.xml:669
5088 msgid ""
5089 "This is why, for example, the dirstate is stored in a single file. If there "
5090 "were a dirstate file per directory that Mercurial tracked, the disk would "
5091 "seek once per directory. Instead, Mercurial reads the entire single dirstate "
5092 "file in one step."
5093 msgstr ""
5095 #. type: Content of: <book><chapter><sect1><sect2><para>
5096 #: ../en/ch03-concepts.xml:675
5097 msgid ""
5098 "Mercurial also uses a <quote>copy on write</quote> scheme when cloning a "
5099 "repository on local storage. Instead of copying every revlog file from the "
5100 "old repository into the new repository, it makes a <quote>hard link</quote>, "
5101 "which is a shorthand way to say <quote>these two names point to the same "
5102 "file</quote>. When Mercurial is about to write to one of a revlog's files, "
5103 "it checks to see if the number of names pointing at the file is greater than "
5104 "one. If it is, more than one repository is using the file, so Mercurial "
5105 "makes a new copy of the file that is private to this repository."
5106 msgstr ""
5108 #. type: Content of: <book><chapter><sect1><sect2><para>
5109 #: ../en/ch03-concepts.xml:686
5110 msgid ""
5111 "A few revision control developers have pointed out that this idea of making a "
5112 "complete private copy of a file is not very efficient in its use of storage. "
5113 "While this is true, storage is cheap, and this method gives the highest "
5114 "performance while deferring most book-keeping to the operating system. An "
5115 "alternative scheme would most likely reduce performance and increase the "
5116 "complexity of the software, each of which is much more important to the "
5117 "<quote>feel</quote> of day-to-day use."
5118 msgstr ""
5120 #. type: Content of: <book><chapter><sect1><sect2><title>
5121 #: ../en/ch03-concepts.xml:698
5122 msgid "Other contents of the dirstate"
5123 msgstr "目录状态的其它内容"
5125 #. type: Content of: <book><chapter><sect1><sect2><para>
5126 #: ../en/ch03-concepts.xml:700
5127 msgid ""
5128 "Because Mercurial doesn't force you to tell it when you're modifying a file, "
5129 "it uses the dirstate to store some extra information so it can determine "
5130 "efficiently whether you have modified a file. For each file in the working "
5131 "directory, it stores the time that it last modified the file itself, and the "
5132 "size of the file at that time."
5133 msgstr ""
5135 #. type: Content of: <book><chapter><sect1><sect2><para>
5136 #: ../en/ch03-concepts.xml:707
5137 msgid ""
5138 "When you explicitly <command role=\"hg-cmd\">hg add</command>, <command role="
5139 "\"hg-cmd\">hg remove</command>, <command role=\"hg-cmd\">hg rename</command> "
5140 "or <command role=\"hg-cmd\">hg copy</command> files, Mercurial updates the "
5141 "dirstate so that it knows what to do with those files when you commit."
5142 msgstr ""
5144 #. type: Content of: <book><chapter><sect1><sect2><para>
5145 #: ../en/ch03-concepts.xml:714
5146 msgid ""
5147 "When Mercurial is checking the states of files in the working directory, it "
5148 "first checks a file's modification time. If that has not changed, the file "
5149 "must not have been modified. If the file's size has changed, the file must "
5150 "have been modified. If the modification time has changed, but the size has "
5151 "not, only then does Mercurial need to read the actual contents of the file to "
5152 "see if they've changed. Storing these few extra pieces of information "
5153 "dramatically reduces the amount of data that Mercurial needs to read, which "
5154 "yields large performance improvements compared to other revision control "
5155 "systems."
5156 msgstr ""
5158 #. type: Content of: <book><chapter><title>
5159 #: ../en/ch04-daily.xml:5
5160 msgid "Mercurial in daily use"
5161 msgstr "Mercurial 的日常使用"
5163 #. type: Content of: <book><chapter><sect1><title>
5164 #: ../en/ch04-daily.xml:8
5165 msgid "Telling Mercurial which files to track"
5166 msgstr "告诉 Mercurial 要跟踪哪些文件"
5168 #. type: Content of: <book><chapter><sect1><para>
5169 #: ../en/ch04-daily.xml:10
5170 msgid ""
5171 "Mercurial does not work with files in your repository unless you tell it to "
5172 "manage them. The <command role=\"hg-cmd\">hg status</command> command will "
5173 "tell you which files Mercurial doesn't know about; it uses a <quote><literal>?"
5174 "</literal></quote> to display such files."
5175 msgstr ""
5178 #. type: Content of: <book><chapter><sect1><para>
5179 #: ../en/ch04-daily.xml:17
5180 msgid ""
5181 "To tell Mercurial to track a file, use the <command role=\"hg-cmd\">hg add</"
5182 "command> command. Once you have added a file, the entry in the output of "
5183 "<command role=\"hg-cmd\">hg status</command> for that file changes from "
5184 "<quote><literal>?</literal></quote> to <quote><literal>A</literal></quote>."
5185 msgstr ""
5187 #. type: Content of: <book><chapter><sect1><para>
5188 #: ../en/ch04-daily.xml:26
5189 msgid ""
5190 "After you run a <command role=\"hg-cmd\">hg commit</command>, the files that "
5191 "you added before the commit will no longer be listed in the output of "
5192 "<command role=\"hg-cmd\">hg status</command>. The reason for this is that "
5193 "<command role=\"hg-cmd\">hg status</command> only tells you about "
5194 "<quote>interesting</quote> files&emdash;those that you have modified or told "
5195 "Mercurial to do something with&emdash;by default. If you have a repository "
5196 "that contains thousands of files, you will rarely want to know about files "
5197 "that Mercurial is tracking, but that have not changed. (You can still get "
5198 "this information; we'll return to this later.)"
5199 msgstr ""
5201 #. type: Content of: <book><chapter><sect1><para>
5202 #: ../en/ch04-daily.xml:38
5203 msgid ""
5204 "Once you add a file, Mercurial doesn't do anything with it immediately. "
5205 "Instead, it will take a snapshot of the file's state the next time you "
5206 "perform a commit. It will then continue to track the changes you make to the "
5207 "file every time you commit, until you remove the file."
5208 msgstr ""
5210 #. type: Content of: <book><chapter><sect1><sect2><title>
5211 #: ../en/ch04-daily.xml:45
5212 msgid "Explicit versus implicit file naming"
5213 msgstr "明确与隐含文件命名"
5215 #. type: Content of: <book><chapter><sect1><sect2><para>
5216 #: ../en/ch04-daily.xml:47
5217 msgid ""
5218 "A useful behaviour that Mercurial has is that if you pass the name of a "
5219 "directory to a command, every Mercurial command will treat this as <quote>I "
5220 "want to operate on every file in this directory and its subdirectories</"
5221 "quote>."
5222 msgstr ""
5224 #. type: Content of: <book><chapter><sect1><sect2><para>
5225 #: ../en/ch04-daily.xml:54
5226 msgid ""
5227 "Notice in this example that Mercurial printed the names of the files it "
5228 "added, whereas it didn't do so when we added the file named <filename>a</"
5229 "filename> in the earlier example."
5230 msgstr ""
5232 #. type: Content of: <book><chapter><sect1><sect2><para>
5233 #: ../en/ch04-daily.xml:59
5234 msgid ""
5235 "What's going on is that in the former case, we explicitly named the file to "
5236 "add on the command line, so the assumption that Mercurial makes in such cases "
5237 "is that you know what you were doing, and it doesn't print any output."
5238 msgstr ""
5240 #. type: Content of: <book><chapter><sect1><sect2><para>
5241 #: ../en/ch04-daily.xml:64
5242 msgid ""
5243 "However, when we <emphasis>imply</emphasis> the names of files by giving the "
5244 "name of a directory, Mercurial takes the extra step of printing the name of "
5245 "each file that it does something with. This makes it more clear what is "
5246 "happening, and reduces the likelihood of a silent and nasty surprise. This "
5247 "behaviour is common to most Mercurial commands."
5248 msgstr ""
5250 #. type: Content of: <book><chapter><sect1><sect2><title>
5251 #: ../en/ch04-daily.xml:73
5252 msgid "Aside: Mercurial tracks files, not directories"
5253 msgstr "旁白: Mercurial 只跟踪文件,不跟踪目录"
5255 #. type: Content of: <book><chapter><sect1><sect2><para>
5256 #: ../en/ch04-daily.xml:75
5257 msgid ""
5258 "Mercurial does not track directory information. Instead, it tracks the path "
5259 "to a file. Before creating a file, it first creates any missing directory "
5260 "components of the path. After it deletes a file, it then deletes any empty "
5261 "directories that were in the deleted file's path. This sounds like a trivial "
5262 "distinction, but it has one minor practical consequence: it is not possible "
5263 "to represent a completely empty directory in Mercurial."
5264 msgstr ""
5266 #. type: Content of: <book><chapter><sect1><sect2><para>
5267 #: ../en/ch04-daily.xml:84
5268 msgid ""
5269 "Empty directories are rarely useful, and there are unintrusive workarounds "
5270 "that you can use to achieve an appropriate effect. The developers of "
5271 "Mercurial thus felt that the complexity that would be required to manage "
5272 "empty directories was not worth the limited benefit this feature would bring."
5273 msgstr ""
5275 #. type: Content of: <book><chapter><sect1><sect2><para>
5276 #: ../en/ch04-daily.xml:91
5277 msgid ""
5278 "If you need an empty directory in your repository, there are a few ways to "
5279 "achieve this. One is to create a directory, then <command role=\"hg-cmd\">hg "
5280 "add</command> a <quote>hidden</quote> file to that directory. On Unix-like "
5281 "systems, any file name that begins with a period (<quote><literal>.</"
5282 "literal></quote>) is treated as hidden by most commands and GUI tools. This "
5283 "approach is illustrated below."
5284 msgstr ""
5286 #. type: Content of: <book><chapter><sect1><sect2><para>
5287 #: ../en/ch04-daily.xml:102
5288 msgid ""
5289 "Another way to tackle a need for an empty directory is to simply create one "
5290 "in your automated build scripts before they will need it."
5291 msgstr ""
5293 #. type: Content of: <book><chapter><sect1><title>
5294 #: ../en/ch04-daily.xml:109
5295 msgid "How to stop tracking a file"
5296 msgstr "如何停止跟踪文件"
5299 #. type: Content of: <book><chapter><sect1><para>
5300 #: ../en/ch04-daily.xml:111
5301 msgid ""
5302 "Once you decide that a file no longer belongs in your repository, use the "
5303 "<command role=\"hg-cmd\">hg remove</command> command; this deletes the file, "
5304 "and tells Mercurial to stop tracking it. A removed file is represented in "
5305 "the output of <command role=\"hg-cmd\">hg status</command> with a "
5306 "<quote><literal>R</literal></quote>."
5307 msgstr ""
5309 #. type: Content of: <book><chapter><sect1><para>
5310 #: ../en/ch04-daily.xml:120
5311 msgid ""
5312 "After you <command role=\"hg-cmd\">hg remove</command> a file, Mercurial will "
5313 "no longer track changes to that file, even if you recreate a file with the "
5314 "same name in your working directory. If you do recreate a file with the same "
5315 "name and want Mercurial to track the new file, simply <command role=\"hg-cmd"
5316 "\">hg add</command> it. Mercurial will know that the newly added file is not "
5317 "related to the old file of the same name."
5318 msgstr ""
5320 #. type: Content of: <book><chapter><sect1><sect2><title>
5321 #: ../en/ch04-daily.xml:129
5322 msgid "Removing a file does not affect its history"
5323 msgstr "删除文件不影响历史"
5325 #. type: Content of: <book><chapter><sect1><sect2><para>
5326 #: ../en/ch04-daily.xml:131
5327 msgid "It is important to understand that removing a file has only two effects."
5328 msgstr ""
5330 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
5331 #: ../en/ch04-daily.xml:134
5332 msgid "It removes the current version of the file from the working directory."
5333 msgstr ""
5335 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
5336 #: ../en/ch04-daily.xml:137
5337 msgid ""
5338 "It stops Mercurial from tracking changes to the file, from the time of the "
5339 "next commit."
5340 msgstr ""
5342 #. type: Content of: <book><chapter><sect1><sect2><para>
5343 #: ../en/ch04-daily.xml:140
5344 msgid ""
5345 "Removing a file <emphasis>does not</emphasis> in any way alter the "
5346 "<emphasis>history</emphasis> of the file."
5347 msgstr ""
5349 #. type: Content of: <book><chapter><sect1><sect2><para>
5350 #: ../en/ch04-daily.xml:143
5351 msgid ""
5352 "If you update the working directory to a changeset in which a file that you "
5353 "have removed was still tracked, it will reappear in the working directory, "
5354 "with the contents it had when you committed that changeset. If you then "
5355 "update the working directory to a later changeset, in which the file had been "
5356 "removed, Mercurial will once again remove the file from the working directory."
5357 msgstr ""
5359 #. type: Content of: <book><chapter><sect1><sect2><title>
5360 #: ../en/ch04-daily.xml:153
5361 msgid "Missing files"
5362 msgstr "丢失的文件"
5364 #. type: Content of: <book><chapter><sect1><sect2><para>
5365 #: ../en/ch04-daily.xml:155
5366 msgid ""
5367 "Mercurial considers a file that you have deleted, but not used <command role="
5368 "\"hg-cmd\">hg remove</command> to delete, to be <emphasis>missing</"
5369 "emphasis>. A missing file is represented with <quote><literal>!</literal></"
5370 "quote> in the output of <command role=\"hg-cmd\">hg status</command>. "
5371 "Mercurial commands will not generally do anything with missing files."
5372 msgstr ""
5374 #. type: Content of: <book><chapter><sect1><sect2><para>
5375 #: ../en/ch04-daily.xml:165
5376 msgid ""
5377 "If your repository contains a file that <command role=\"hg-cmd\">hg status</"
5378 "command> reports as missing, and you want the file to stay gone, you can run "
5379 "<command role=\"hg-cmd\">hg remove <option role=\"hg-opt-remove\">--after</"
5380 "option></command> at any time later on, to tell Mercurial that you really did "
5381 "mean to remove the file."
5382 msgstr ""
5384 #. type: Content of: <book><chapter><sect1><sect2><para>
5385 #: ../en/ch04-daily.xml:175
5386 msgid ""
5387 "On the other hand, if you deleted the missing file by accident, give <command "
5388 "role=\"hg-cmd\">hg revert</command> the name of the file to recover. It will "
5389 "reappear, in unmodified form."
5390 msgstr ""
5392 #. type: Content of: <book><chapter><sect1><sect2><title>
5393 #: ../en/ch04-daily.xml:184
5394 msgid "Aside: why tell Mercurial explicitly to remove a file?"
5395 msgstr "旁白: 为什么要明确告诉 Mercurial 删除文件?"
5397 #. type: Content of: <book><chapter><sect1><sect2><para>
5398 #: ../en/ch04-daily.xml:187
5399 msgid ""
5400 "You might wonder why Mercurial requires you to explicitly tell it that you "
5401 "are deleting a file. Early during the development of Mercurial, it let you "
5402 "delete a file however you pleased; Mercurial would notice the absence of the "
5403 "file automatically when you next ran a <command role=\"hg-cmd\">hg commit</"
5404 "command>, and stop tracking the file. In practice, this made it too easy to "
5405 "accidentally remove a file without noticing."
5406 msgstr ""
5408 #. type: Content of: <book><chapter><sect1><sect2><title>
5409 #: ../en/ch04-daily.xml:198
5410 msgid "Useful shorthand&emdash;adding and removing files in one step"
5411 msgstr "有用的速记&emdash;一个步骤添加和删除文件"
5413 #. type: Content of: <book><chapter><sect1><sect2><para>
5414 #: ../en/ch04-daily.xml:201
5415 msgid ""
5416 "Mercurial offers a combination command, <command role=\"hg-cmd\">hg "
5417 "addremove</command>, that adds untracked files and marks missing files as "
5418 "removed."
5419 msgstr ""
5421 #. type: Content of: <book><chapter><sect1><sect2><para>
5422 #: ../en/ch04-daily.xml:207
5423 msgid ""
5424 "The <command role=\"hg-cmd\">hg commit</command> command also provides a "
5425 "<option role=\"hg-opt-commit\">-A</option> option that performs this same add-"
5426 "and-remove, immediately followed by a commit."
5427 msgstr ""
5429 #. type: Content of: <book><chapter><sect1><title>
5430 #: ../en/ch04-daily.xml:217
5431 msgid "Copying files"
5432 msgstr "复制文件"
5434 #. type: Content of: <book><chapter><sect1><para>
5435 #: ../en/ch04-daily.xml:219
5436 msgid ""
5437 "Mercurial provides a <command role=\"hg-cmd\">hg copy</command> command that "
5438 "lets you make a new copy of a file. When you copy a file using this command, "
5439 "Mercurial makes a record of the fact that the new file is a copy of the "
5440 "original file. It treats these copied files specially when you merge your "
5441 "work with someone else's."
5442 msgstr ""
5444 #. type: Content of: <book><chapter><sect1><sect2><title>
5445 #: ../en/ch04-daily.xml:227
5446 msgid "The results of copying during a merge"
5447 msgstr "合并期间的复制结果"
5449 #. type: Content of: <book><chapter><sect1><sect2><para>
5450 #: ../en/ch04-daily.xml:229
5451 msgid ""
5452 "What happens during a merge is that changes <quote>follow</quote> a copy. To "
5453 "best illustrate what this means, let's create an example. We'll start with "
5454 "the usual tiny repository that contains a single file."
5455 msgstr ""
5457 #. type: Content of: <book><chapter><sect1><sect2><para>
5458 #: ../en/ch04-daily.xml:236
5459 msgid ""
5460 "We need to do some work in parallel, so that we'll have something to merge. "
5461 "So let's clone our repository."
5462 msgstr ""
5464 #. type: Content of: <book><chapter><sect1><sect2><para>
5465 #: ../en/ch04-daily.xml:242
5466 msgid ""
5467 "Back in our initial repository, let's use the <command role=\"hg-cmd\">hg "
5468 "copy</command> command to make a copy of the first file we created."
5469 msgstr ""
5471 #. type: Content of: <book><chapter><sect1><sect2><para>
5472 #: ../en/ch04-daily.xml:248
5473 msgid ""
5474 "If we look at the output of the <command role=\"hg-cmd\">hg status</command> "
5475 "command afterwards, the copied file looks just like a normal added file."
5476 msgstr ""
5478 #. type: Content of: <book><chapter><sect1><sect2><para>
5479 #: ../en/ch04-daily.xml:254
5480 msgid ""
5481 "But if we pass the <option role=\"hg-opt-status\">-C</option> option to "
5482 "<command role=\"hg-cmd\">hg status</command>, it prints another line of "
5483 "output: this is the file that our newly-added file was copied <emphasis>from</"
5484 "emphasis>."
5485 msgstr ""
5487 #. type: Content of: <book><chapter><sect1><sect2><para>
5488 #: ../en/ch04-daily.xml:262
5489 msgid ""
5490 "Now, back in the repository we cloned, let's make a change in parallel. "
5491 "We'll add a line of content to the original file that we created."
5492 msgstr ""
5494 #. type: Content of: <book><chapter><sect1><sect2><para>
5495 #: ../en/ch04-daily.xml:268
5496 msgid ""
5497 "Now we have a modified <filename>file</filename> in this repository. When we "
5498 "pull the changes from the first repository, and merge the two heads, "
5499 "Mercurial will propagate the changes that we made locally to <filename>file</"
5500 "filename> into its copy, <filename>new-file</filename>."
5501 msgstr ""
5503 #. type: Content of: <book><chapter><sect1><sect2><title>
5504 #: ../en/ch04-daily.xml:278
5505 msgid "Why should changes follow copies?"
5506 msgstr "为什么复制后需要后续修改?"
5508 #. type: Content of: <book><chapter><sect1><sect2><para>
5509 #: ../en/ch04-daily.xml:280
5510 msgid ""
5511 "This behaviour, of changes to a file propagating out to copies of the file, "
5512 "might seem esoteric, but in most cases it's highly desirable."
5513 msgstr ""
5515 #. type: Content of: <book><chapter><sect1><sect2><para>
5516 #: ../en/ch04-daily.xml:284
5517 msgid ""
5518 "First of all, remember that this propagation <emphasis>only</emphasis> "
5519 "happens when you merge. So if you <command role=\"hg-cmd\">hg copy</command> "
5520 "a file, and subsequently modify the original file during the normal course of "
5521 "your work, nothing will happen."
5522 msgstr ""
5524 #. type: Content of: <book><chapter><sect1><sect2><para>
5525 #: ../en/ch04-daily.xml:290
5526 msgid ""
5527 "The second thing to know is that modifications will only propagate across a "
5528 "copy as long as the repository that you're pulling changes from "
5529 "<emphasis>doesn't know</emphasis> about the copy."
5530 msgstr ""
5532 #. type: Content of: <book><chapter><sect1><sect2><para>
5533 #: ../en/ch04-daily.xml:295
5534 msgid ""
5535 "The reason that Mercurial does this is as follows. Let's say I make an "
5536 "important bug fix in a source file, and commit my changes. Meanwhile, you've "
5537 "decided to <command role=\"hg-cmd\">hg copy</command> the file in your "
5538 "repository, without knowing about the bug or having seen the fix, and you "
5539 "have started hacking on your copy of the file."
5540 msgstr ""
5542 #. type: Content of: <book><chapter><sect1><sect2><para>
5543 #: ../en/ch04-daily.xml:302
5544 msgid ""
5545 "If you pulled and merged my changes, and Mercurial <emphasis>didn't</"
5546 "emphasis> propagate changes across copies, your source file would now contain "
5547 "the bug, and unless you remembered to propagate the bug fix by hand, the bug "
5548 "would <emphasis>remain</emphasis> in your copy of the file."
5549 msgstr ""
5551 #. type: Content of: <book><chapter><sect1><sect2><para>
5552 #: ../en/ch04-daily.xml:308
5553 msgid ""
5554 "By automatically propagating the change that fixed the bug from the original "
5555 "file to the copy, Mercurial prevents this class of problem. To my knowledge, "
5556 "Mercurial is the <emphasis>only</emphasis> revision control system that "
5557 "propagates changes across copies like this."
5558 msgstr ""
5560 #. type: Content of: <book><chapter><sect1><sect2><para>
5561 #: ../en/ch04-daily.xml:314
5562 msgid ""
5563 "Once your change history has a record that the copy and subsequent merge "
5564 "occurred, there's usually no further need to propagate changes from the "
5565 "original file to the copied file, and that's why Mercurial only propagates "
5566 "changes across copies until this point, and no further."
5567 msgstr ""
5569 #. type: Content of: <book><chapter><sect1><sect2><title>
5570 #: ../en/ch04-daily.xml:322
5571 msgid "How to make changes <emphasis>not</emphasis> follow a copy"
5572 msgstr "如何让复制后<emphasis>不</emphasis>修改?"
5574 #. type: Content of: <book><chapter><sect1><sect2><para>
5575 #: ../en/ch04-daily.xml:325
5576 msgid ""
5577 "If, for some reason, you decide that this business of automatically "
5578 "propagating changes across copies is not for you, simply use your system's "
5579 "normal file copy command (on Unix-like systems, that's <command>cp</command>) "
5580 "to make a copy of a file, then <command role=\"hg-cmd\">hg add</command> the "
5581 "new copy by hand. Before you do so, though, please do reread <xref linkend="
5582 "\"sec:daily:why-copy\"/>, and make an informed decision that this behaviour "
5583 "is not appropriate to your specific case."
5584 msgstr ""
5586 #. type: Content of: <book><chapter><sect1><sect2><title>
5587 #: ../en/ch04-daily.xml:338
5588 msgid "Behaviour of the <command role=\"hg-cmd\">hg copy</command> command"
5589 msgstr "命令 <command role=\"hg-cmd\">hg copy</command> 的特性"
5591 #. type: Content of: <book><chapter><sect1><sect2><para>
5592 #: ../en/ch04-daily.xml:341
5593 msgid ""
5594 "When you use the <command role=\"hg-cmd\">hg copy</command> command, "
5595 "Mercurial makes a copy of each source file as it currently stands in the "
5596 "working directory. This means that if you make some modifications to a file, "
5597 "then <command role=\"hg-cmd\">hg copy</command> it without first having "
5598 "committed those changes, the new copy will also contain the modifications you "
5599 "have made up until that point. (I find this behaviour a little "
5600 "counterintuitive, which is why I mention it here.)"
5601 msgstr ""
5603 #. type: Content of: <book><chapter><sect1><sect2><para>
5604 #: ../en/ch04-daily.xml:351
5605 msgid ""
5606 "The <command role=\"hg-cmd\">hg copy</command> command acts similarly to the "
5607 "Unix <command>cp</command> command (you can use the <command role=\"hg-cmd"
5608 "\">hg cp</command> alias if you prefer). The last argument is the "
5609 "<emphasis>destination</emphasis>, and all prior arguments are "
5610 "<emphasis>sources</emphasis>. If you pass it a single file as the source, "
5611 "and the destination does not exist, it creates a new file with that name."
5612 msgstr ""
5614 #. type: Content of: <book><chapter><sect1><sect2><para>
5615 #: ../en/ch04-daily.xml:362
5616 msgid ""
5617 "If the destination is a directory, Mercurial copies its sources into that "
5618 "directory."
5619 msgstr ""
5621 #. type: Content of: <book><chapter><sect1><sect2><para>
5622 #: ../en/ch04-daily.xml:367
5623 msgid ""
5624 "Copying a directory is recursive, and preserves the directory structure of "
5625 "the source."
5626 msgstr ""
5628 #. type: Content of: <book><chapter><sect1><sect2><para>
5629 #: ../en/ch04-daily.xml:373
5630 msgid ""
5631 "If the source and destination are both directories, the source tree is "
5632 "recreated in the destination directory."
5633 msgstr ""
5636 #. type: Content of: <book><chapter><sect1><sect2><para>
5637 #: ../en/ch04-daily.xml:378
5638 msgid ""
5639 "As with the <command role=\"hg-cmd\">hg rename</command> command, if you copy "
5640 "a file manually and then want Mercurial to know that you've copied the file, "
5641 "simply use the <option role=\"hg-opt-copy\">--after</option> option to "
5642 "<command role=\"hg-cmd\">hg copy</command>."
5643 msgstr ""
5645 #. type: Content of: <book><chapter><sect1><title>
5646 #: ../en/ch04-daily.xml:389
5647 msgid "Renaming files"
5648 msgstr "改名文件"
5650 #. type: Content of: <book><chapter><sect1><para>
5651 #: ../en/ch04-daily.xml:391
5652 msgid ""
5653 "It's rather more common to need to rename a file than to make a copy of it. "
5654 "The reason I discussed the <command role=\"hg-cmd\">hg copy</command> command "
5655 "before talking about renaming files is that Mercurial treats a rename in "
5656 "essentially the same way as a copy. Therefore, knowing what Mercurial does "
5657 "when you copy a file tells you what to expect when you rename a file."
5658 msgstr ""
5660 #. type: Content of: <book><chapter><sect1><para>
5661 #: ../en/ch04-daily.xml:399
5662 msgid ""
5663 "When you use the <command role=\"hg-cmd\">hg rename</command> command, "
5664 "Mercurial makes a copy of each source file, then deletes it and marks the "
5665 "file as removed."
5666 msgstr ""
5668 #. type: Content of: <book><chapter><sect1><para>
5669 #: ../en/ch04-daily.xml:405
5670 msgid ""
5671 "The <command role=\"hg-cmd\">hg status</command> command shows the newly "
5672 "copied file as added, and the copied-from file as removed."
5673 msgstr ""
5675 #. type: Content of: <book><chapter><sect1><para>
5676 #: ../en/ch04-daily.xml:411
5677 msgid ""
5678 "As with the results of a <command role=\"hg-cmd\">hg copy</command>, we must "
5679 "use the <option role=\"hg-opt-status\">-C</option> option to <command role="
5680 "\"hg-cmd\">hg status</command> to see that the added file is really being "
5681 "tracked by Mercurial as a copy of the original, now removed, file."
5682 msgstr ""
5684 #. type: Content of: <book><chapter><sect1><para>
5685 #: ../en/ch04-daily.xml:420
5686 msgid ""
5687 "As with <command role=\"hg-cmd\">hg remove</command> and <command role=\"hg-"
5688 "cmd\">hg copy</command>, you can tell Mercurial about a rename after the fact "
5689 "using the <option role=\"hg-opt-rename\">--after</option> option. In most "
5690 "other respects, the behaviour of the <command role=\"hg-cmd\">hg rename</"
5691 "command> command, and the options it accepts, are similar to the <command "
5692 "role=\"hg-cmd\">hg copy</command> command."
5693 msgstr ""
5695 #. type: Content of: <book><chapter><sect1><sect2><title>
5696 #: ../en/ch04-daily.xml:430
5697 msgid "Renaming files and merging changes"
5698 msgstr "改名文件与合并修改"
5700 #. type: Content of: <book><chapter><sect1><sect2><para>
5701 #: ../en/ch04-daily.xml:432
5702 msgid ""
5703 "Since Mercurial's rename is implemented as copy-and-remove, the same "
5704 "propagation of changes happens when you merge after a rename as after a copy."
5705 msgstr ""
5707 #. type: Content of: <book><chapter><sect1><sect2><para>
5708 #: ../en/ch04-daily.xml:436
5709 msgid ""
5710 "If I modify a file, and you rename it to a new name, and then we merge our "
5711 "respective changes, my modifications to the file under its original name will "
5712 "be propagated into the file under its new name. (This is something you might "
5713 "expect to <quote>simply work,</quote> but not all revision control systems "
5714 "actually do this.)"
5715 msgstr ""
5717 #. type: Content of: <book><chapter><sect1><sect2><para>
5718 #: ../en/ch04-daily.xml:443
5719 msgid ""
5720 "Whereas having changes follow a copy is a feature where you can perhaps nod "
5721 "and say <quote>yes, that might be useful,</quote> it should be clear that "
5722 "having them follow a rename is definitely important. Without this facility, "
5723 "it would simply be too easy for changes to become orphaned when files are "
5724 "renamed."
5725 msgstr ""
5727 #. type: Content of: <book><chapter><sect1><sect2><title>
5728 #: ../en/ch04-daily.xml:452
5729 msgid "Divergent renames and merging"
5730 msgstr "改名与合并的分歧"
5732 #. type: Content of: <book><chapter><sect1><sect2><para>
5733 #: ../en/ch04-daily.xml:454
5734 msgid ""
5735 "The case of diverging names occurs when two developers start with a "
5736 "file&emdash;let's call it <filename>foo</filename>&emdash;in their respective "
5737 "repositories."
5738 msgstr ""
5740 #. type: Content of: <book><chapter><sect1><sect2><para>
5741 #: ../en/ch04-daily.xml:461
5742 msgid "Anne renames the file to <filename>bar</filename>."
5743 msgstr ""
5745 #. type: Content of: <book><chapter><sect1><sect2><para>
5746 #: ../en/ch04-daily.xml:465
5747 msgid "Meanwhile, Bob renames it to <filename>quux</filename>."
5748 msgstr ""
5750 #. type: Content of: <book><chapter><sect1><sect2><para>
5751 #: ../en/ch04-daily.xml:470
5752 msgid ""
5753 "I like to think of this as a conflict because each developer has expressed "
5754 "different intentions about what the file ought to be named."
5755 msgstr ""
5758 #. type: Content of: <book><chapter><sect1><sect2><para>
5759 #: ../en/ch04-daily.xml:474
5760 msgid ""
5761 "What do you think should happen when they merge their work? Mercurial's "
5762 "actual behaviour is that it always preserves <emphasis>both</emphasis> names "
5763 "when it merges changesets that contain divergent renames."
5764 msgstr ""
5766 #. type: Content of: <book><chapter><sect1><sect2><para>
5767 #: ../en/ch04-daily.xml:481
5768 msgid ""
5769 "Notice that Mercurial does warn about the divergent renames, but it leaves it "
5770 "up to you to do something about the divergence after the merge."
5771 msgstr ""
5773 #. type: Content of: <book><chapter><sect1><sect2><title>
5774 #: ../en/ch04-daily.xml:487
5775 msgid "Convergent renames and merging"
5776 msgstr "收敛改名与合并"
5778 #. type: Content of: <book><chapter><sect1><sect2><para>
5779 #: ../en/ch04-daily.xml:489
5780 msgid ""
5781 "Another kind of rename conflict occurs when two people choose to rename "
5782 "different <emphasis>source</emphasis> files to the same "
5783 "<emphasis>destination</emphasis>. In this case, Mercurial runs its normal "
5784 "merge machinery, and lets you guide it to a suitable resolution."
5785 msgstr ""
5787 #. type: Content of: <book><chapter><sect1><sect2><title>
5788 #: ../en/ch04-daily.xml:497
5789 msgid "Other name-related corner cases"
5790 msgstr "其它名称相关的角落"
5792 #. type: Content of: <book><chapter><sect1><sect2><para>
5793 #: ../en/ch04-daily.xml:499
5794 msgid ""
5795 "Mercurial has a longstanding bug in which it fails to handle a merge where "
5796 "one side has a file with a given name, while another has a directory with the "
5797 "same name. This is documented as <ulink role=\"hg-bug\" url=\"http://www."
5798 "selenic.com/mercurial/bts/issue29\">issue 29</ulink>."
5799 msgstr ""
5801 #. type: Content of: <book><chapter><sect1><title>
5802 #: ../en/ch04-daily.xml:511
5803 msgid "Recovering from mistakes"
5804 msgstr "从错误恢复"
5806 #. type: Content of: <book><chapter><sect1><para>
5807 #: ../en/ch04-daily.xml:513
5808 msgid ""
5809 "Mercurial has some useful commands that will help you to recover from some "
5810 "common mistakes."
5811 msgstr ""
5813 #. type: Content of: <book><chapter><sect1><para>
5814 #: ../en/ch04-daily.xml:516
5815 msgid ""
5816 "The <command role=\"hg-cmd\">hg revert</command> command lets you undo "
5817 "changes that you have made to your working directory. For example, if you "
5818 "<command role=\"hg-cmd\">hg add</command> a file by accident, just run "
5819 "<command role=\"hg-cmd\">hg revert</command> with the name of the file you "
5820 "added, and while the file won't be touched in any way, it won't be tracked "
5821 "for adding by Mercurial any longer, either. You can also use <command role="
5822 "\"hg-cmd\">hg revert</command> to get rid of erroneous changes to a file."
5823 msgstr ""
5825 #. type: Content of: <book><chapter><sect1><para>
5826 #: ../en/ch04-daily.xml:526
5827 msgid ""
5828 "It's useful to remember that the <command role=\"hg-cmd\">hg revert</command> "
5829 "command is useful for changes that you have not yet committed. Once you've "
5830 "committed a change, if you decide it was a mistake, you can still do "
5831 "something about it, though your options may be more limited."
5832 msgstr ""
5834 #. type: Content of: <book><chapter><sect1><para>
5835 #: ../en/ch04-daily.xml:532
5836 msgid ""
5837 "For more information about the <command role=\"hg-cmd\">hg revert</command> "
5838 "command, and details about how to deal with changes you have already "
5839 "committed, see <xref linkend=\"chap:undo\"/>."
5840 msgstr ""
5842 #. type: Content of: <book><chapter><title>
5843 #: ../en/ch05-collab.xml:5
5844 msgid "Collaborating with other people"
5845 msgstr "团体协作"
5847 #. type: Content of: <book><chapter><para>
5848 #: ../en/ch05-collab.xml:7
5849 msgid ""
5850 "As a completely decentralised tool, Mercurial doesn't impose any policy on "
5851 "how people ought to work with each other. However, if you're new to "
5852 "distributed revision control, it helps to have some tools and examples in "
5853 "mind when you're thinking about possible workflow models."
5854 msgstr ""
5856 #. type: Content of: <book><chapter><sect1><title>
5857 #: ../en/ch05-collab.xml:14
5858 msgid "Mercurial's web interface"
5859 msgstr "Mercurial 的 web 接口"
5861 #. type: Content of: <book><chapter><sect1><para>
5862 #: ../en/ch05-collab.xml:16
5863 msgid ""
5864 "Mercurial has a powerful web interface that provides several useful "
5865 "capabilities."
5866 msgstr ""
5868 #. type: Content of: <book><chapter><sect1><para>
5869 #: ../en/ch05-collab.xml:19
5870 msgid ""
5871 "For interactive use, the web interface lets you browse a single repository or "
5872 "a collection of repositories. You can view the history of a repository, "
5873 "examine each change (comments and diffs), and view the contents of each "
5874 "directory and file."
5875 msgstr ""
5877 #. type: Content of: <book><chapter><sect1><para>
5878 #: ../en/ch05-collab.xml:24
5879 msgid ""
5880 "Also for human consumption, the web interface provides an RSS feed of the "
5881 "changes in a repository. This lets you <quote>subscribe</quote> to a "
5882 "repository using your favourite feed reader, and be automatically notified of "
5883 "activity in that repository as soon as it happens. I find this capability "
5884 "much more convenient than the model of subscribing to a mailing list to which "
5885 "notifications are sent, as it requires no additional configuration on the "
5886 "part of whoever is serving the repository."
5887 msgstr ""
5889 #. type: Content of: <book><chapter><sect1><para>
5890 #: ../en/ch05-collab.xml:34
5891 msgid ""
5892 "The web interface also lets remote users clone a repository, pull changes "
5893 "from it, and (when the server is configured to permit it) push changes back "
5894 "to it. Mercurial's HTTP tunneling protocol aggressively compresses data, so "
5895 "that it works efficiently even over low-bandwidth network connections."
5896 msgstr ""
5898 #. type: Content of: <book><chapter><sect1><para>
5899 #: ../en/ch05-collab.xml:40
5900 msgid ""
5901 "The easiest way to get started with the web interface is to use your web "
5902 "browser to visit an existing repository, such as the master Mercurial "
5903 "repository at <ulink url=\"http://www.selenic.com/repo/hg?style=gitweb"
5904 "\">http://www.selenic.com/repo/hg?style=gitweb</ulink>."
5905 msgstr ""
5907 #. type: Content of: <book><chapter><sect1><para>
5908 #: ../en/ch05-collab.xml:45
5909 msgid ""
5910 "If you're interested in providing a web interface to your own repositories, "
5911 "Mercurial provides two ways to do this. The first is using the <command role="
5912 "\"hg-cmd\">hg serve</command> command, which is best suited to short-term "
5913 "<quote>lightweight</quote> serving. See <xref linkend=\"sec:collab:serve\"/> "
5914 "below for details of how to use this command. If you have a long-lived "
5915 "repository that you'd like to make permanently available, Mercurial has built-"
5916 "in support for the CGI (Common Gateway Interface) standard, which all common "
5917 "web servers support. See <xref linkend=\"sec:collab:cgi\"/> for details of "
5918 "CGI configuration."
5919 msgstr ""
5921 #. type: Content of: <book><chapter><sect1><title>
5922 #: ../en/ch05-collab.xml:60
5923 msgid "Collaboration models"
5924 msgstr "协作模型"
5926 #. type: Content of: <book><chapter><sect1><para>
5927 #: ../en/ch05-collab.xml:62
5928 msgid ""
5929 "With a suitably flexible tool, making decisions about workflow is much more "
5930 "of a social engineering challenge than a technical one. Mercurial imposes few "
5931 "limitations on how you can structure the flow of work in a project, so it's "
5932 "up to you and your group to set up and live with a model that matches your "
5933 "own particular needs."
5934 msgstr ""
5936 #. type: Content of: <book><chapter><sect1><sect2><title>
5937 #: ../en/ch05-collab.xml:70
5938 msgid "Factors to keep in mind"
5939 msgstr "要牢记的因素"
5941 #. type: Content of: <book><chapter><sect1><sect2><para>
5942 #: ../en/ch05-collab.xml:72
5943 msgid ""
5944 "The most important aspect of any model that you must keep in mind is how well "
5945 "it matches the needs and capabilities of the people who will be using it. "
5946 "This might seem self-evident; even so, you still can't afford to forget it "
5947 "for a moment."
5948 msgstr ""
5950 #. type: Content of: <book><chapter><sect1><sect2><para>
5951 #: ../en/ch05-collab.xml:78
5952 msgid ""
5953 "I once put together a workflow model that seemed to make perfect sense to me, "
5954 "but that caused a considerable amount of consternation and strife within my "
5955 "development team. In spite of my attempts to explain why we needed a complex "
5956 "set of branches, and how changes ought to flow between them, a few team "
5957 "members revolted. Even though they were smart people, they didn't want to "
5958 "pay attention to the constraints we were operating under, or face the "
5959 "consequences of those constraints in the details of the model that I was "
5960 "advocating."
5961 msgstr ""
5963 #. type: Content of: <book><chapter><sect1><sect2><para>
5964 #: ../en/ch05-collab.xml:88
5965 msgid ""
5966 "Don't sweep foreseeable social or technical problems under the rug. Whatever "
5967 "scheme you put into effect, you should plan for mistakes and problem "
5968 "scenarios. Consider adding automated machinery to prevent, or quickly "
5969 "recover from, trouble that you can anticipate. As an example, if you intend "
5970 "to have a branch with not-for-release changes in it, you'd do well to think "
5971 "early about the possibility that someone might accidentally merge those "
5972 "changes into a release branch. You could avoid this particular problem by "
5973 "writing a hook that prevents changes from being merged from an inappropriate "
5974 "branch."
5975 msgstr ""
5977 #. type: Content of: <book><chapter><sect1><sect2><title>
5978 #: ../en/ch05-collab.xml:102
5979 msgid "Informal anarchy"
5980 msgstr "无政府状态"
5982 #. type: Content of: <book><chapter><sect1><sect2><para>
5983 #: ../en/ch05-collab.xml:104
5984 msgid ""
5985 "I wouldn't suggest an <quote>anything goes</quote> approach as something "
5986 "sustainable, but it's a model that's easy to grasp, and it works perfectly "
5987 "well in a few unusual situations."
5988 msgstr ""
5990 #. type: Content of: <book><chapter><sect1><sect2><para>
5991 #: ../en/ch05-collab.xml:109
5992 msgid ""
5993 "As one example, many projects have a loose-knit group of collaborators who "
5994 "rarely physically meet each other. Some groups like to overcome the "
5995 "isolation of working at a distance by organising occasional <quote>sprints</"
5996 "quote>. In a sprint, a number of people get together in a single location (a "
5997 "company's conference room, a hotel meeting room, that kind of place) and "
5998 "spend several days more or less locked in there, hacking intensely on a "
5999 "handful of projects."
6000 msgstr ""
6002 #. type: Content of: <book><chapter><sect1><sect2><para>
6003 #: ../en/ch05-collab.xml:118
6004 msgid ""
6005 "A sprint is the perfect place to use the <command role=\"hg-cmd\">hg serve</"
6006 "command> command, since <command role=\"hg-cmd\">hg serve</command> does not "
6007 "require any fancy server infrastructure. You can get started with <command "
6008 "role=\"hg-cmd\">hg serve</command> in moments, by reading <xref linkend=\"sec:"
6009 "collab:serve\"/> below. Then simply tell the person next to you that you're "
6010 "running a server, send the URL to them in an instant message, and you "
6011 "immediately have a quick-turnaround way to work together. They can type your "
6012 "URL into their web browser and quickly review your changes; or they can pull "
6013 "a bugfix from you and verify it; or they can clone a branch containing a new "
6014 "feature and try it out."
6015 msgstr ""
6017 #. type: Content of: <book><chapter><sect1><sect2><para>
6018 #: ../en/ch05-collab.xml:132
6019 msgid ""
6020 "The charm, and the problem, with doing things in an ad hoc fashion like this "
6021 "is that only people who know about your changes, and where they are, can see "
6022 "them. Such an informal approach simply doesn't scale beyond a handful "
6023 "people, because each individual needs to know about $n$ different "
6024 "repositories to pull from."
6025 msgstr ""
6027 #. type: Content of: <book><chapter><sect1><sect2><title>
6028 #: ../en/ch05-collab.xml:141
6029 msgid "A single central repository"
6030 msgstr "单一中央版本库"
6032 #. type: Content of: <book><chapter><sect1><sect2><para>
6033 #: ../en/ch05-collab.xml:143
6034 msgid ""
6035 "For smaller projects migrating from a centralised revision control tool, "
6036 "perhaps the easiest way to get started is to have changes flow through a "
6037 "single shared central repository. This is also the most common "
6038 "<quote>building block</quote> for more ambitious workflow schemes."
6039 msgstr ""
6041 #. type: Content of: <book><chapter><sect1><sect2><para>
6042 #: ../en/ch05-collab.xml:149
6043 msgid ""
6044 "Contributors start by cloning a copy of this repository. They can pull "
6045 "changes from it whenever they need to, and some (perhaps all) developers have "
6046 "permission to push a change back when they're ready for other people to see "
6047 "it."
6048 msgstr ""
6050 #. type: Content of: <book><chapter><sect1><sect2><para>
6051 #: ../en/ch05-collab.xml:154
6052 msgid ""
6053 "Under this model, it can still often make sense for people to pull changes "
6054 "directly from each other, without going through the central repository. "
6055 "Consider a case in which I have a tentative bug fix, but I am worried that if "
6056 "I were to publish it to the central repository, it might subsequently break "
6057 "everyone else's trees as they pull it. To reduce the potential for damage, I "
6058 "can ask you to clone my repository into a temporary repository of your own "
6059 "and test it. This lets us put off publishing the potentially unsafe change "
6060 "until it has had a little testing."
6061 msgstr ""
6063 #. type: Content of: <book><chapter><sect1><sect2><para>
6064 #: ../en/ch05-collab.xml:165
6065 msgid ""
6066 "In this kind of scenario, people usually use the <command>ssh</command> "
6067 "protocol to securely push changes to the central repository, as documented in "
6068 "<xref linkend=\"sec:collab:ssh\"/>. It's also usual to publish a read-only "
6069 "copy of the repository over HTTP using CGI, as in <xref linkend=\"sec:collab:"
6070 "cgi\"/>. Publishing over HTTP satisfies the needs of people who don't have "
6071 "push access, and those who want to use web browsers to browse the "
6072 "repository's history."
6073 msgstr ""
6075 #. type: Content of: <book><chapter><sect1><sect2><title>
6076 #: ../en/ch05-collab.xml:177
6077 msgid "Working with multiple branches"
6078 msgstr "使用多个分支工作"
6080 #. type: Content of: <book><chapter><sect1><sect2><para>
6081 #: ../en/ch05-collab.xml:179
6082 msgid ""
6083 "Projects of any significant size naturally tend to make progress on several "
6084 "fronts simultaneously. In the case of software, it's common for a project to "
6085 "go through periodic official releases. A release might then go into "
6086 "<quote>maintenance mode</quote> for a while after its first publication; "
6087 "maintenance releases tend to contain only bug fixes, not new features. In "
6088 "parallel with these maintenance releases, one or more future releases may be "
6089 "under development. People normally use the word <quote>branch</quote> to "
6090 "refer to one of these many slightly different directions in which development "
6091 "is proceeding."
6092 msgstr ""
6094 #. type: Content of: <book><chapter><sect1><sect2><para>
6095 #: ../en/ch05-collab.xml:192
6096 msgid ""
6097 "Mercurial is particularly well suited to managing a number of simultaneous, "
6098 "but not identical, branches. Each <quote>development direction</quote> can "
6099 "live in its own central repository, and you can merge changes from one to "
6100 "another as the need arises. Because repositories are independent of each "
6101 "other, unstable changes in a development branch will never affect a stable "
6102 "branch unless someone explicitly merges those changes in."
6103 msgstr ""
6105 #. type: Content of: <book><chapter><sect1><sect2><para>
6106 #: ../en/ch05-collab.xml:201
6107 msgid ""
6108 "Here's an example of how this can work in practice. Let's say you have one "
6109 "<quote>main branch</quote> on a central server."
6110 msgstr ""
6112 #. type: Content of: <book><chapter><sect1><sect2><para>
6113 #: ../en/ch05-collab.xml:207
6114 msgid "People clone it, make changes locally, test them, and push them back."
6115 msgstr ""
6117 #. type: Content of: <book><chapter><sect1><sect2><para>
6118 #: ../en/ch05-collab.xml:210
6119 msgid ""
6120 "Once the main branch reaches a release milestone, you can use the <command "
6121 "role=\"hg-cmd\">hg tag</command> command to give a permanent name to the "
6122 "milestone revision."
6123 msgstr ""
6125 #. type: Content of: <book><chapter><sect1><sect2><para>
6126 #: ../en/ch05-collab.xml:216
6127 msgid "Let's say some ongoing development occurs on the main branch."
6128 msgstr ""
6130 #. type: Content of: <book><chapter><sect1><sect2><para>
6131 #: ../en/ch05-collab.xml:221
6132 msgid ""
6133 "Using the tag that was recorded at the milestone, people who clone that "
6134 "repository at any time in the future can use <command role=\"hg-cmd\">hg "
6135 "update</command> to get a copy of the working directory exactly as it was "
6136 "when that tagged revision was committed."
6137 msgstr ""
6140 #. type: Content of: <book><chapter><sect1><sect2><para>
6141 #: ../en/ch05-collab.xml:229
6142 msgid ""
6143 "In addition, immediately after the main branch is tagged, someone can then "
6144 "clone the main branch on the server to a new <quote>stable</quote> branch, "
6145 "also on the server."
6146 msgstr ""
6148 #. type: Content of: <book><chapter><sect1><sect2><para>
6149 #: ../en/ch05-collab.xml:235
6150 msgid ""
6151 "Someone who needs to make a change to the stable branch can then clone "
6152 "<emphasis>that</emphasis> repository, make their changes, commit, and push "
6153 "their changes back there."
6154 msgstr ""
6156 #. type: Content of: <book><chapter><sect1><sect2><para>
6157 #: ../en/ch05-collab.xml:241
6158 msgid ""
6159 "Because Mercurial repositories are independent, and Mercurial doesn't move "
6160 "changes around automatically, the stable and main branches are "
6161 "<emphasis>isolated</emphasis> from each other. The changes that you made on "
6162 "the main branch don't <quote>leak</quote> to the stable branch, and vice "
6163 "versa."
6164 msgstr ""
6166 #. type: Content of: <book><chapter><sect1><sect2><para>
6167 #: ../en/ch05-collab.xml:248
6168 msgid ""
6169 "You'll often want all of your bugfixes on the stable branch to show up on the "
6170 "main branch, too. Rather than rewrite a bugfix on the main branch, you can "
6171 "simply pull and merge changes from the stable to the main branch, and "
6172 "Mercurial will bring those bugfixes in for you."
6173 msgstr ""
6175 #. type: Content of: <book><chapter><sect1><sect2><para>
6176 #: ../en/ch05-collab.xml:256
6177 msgid ""
6178 "The main branch will still contain changes that are not on the stable branch, "
6179 "but it will also contain all of the bugfixes from the stable branch. The "
6180 "stable branch remains unaffected by these changes."
6181 msgstr ""
6183 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
6184 #: ../en/ch05-collab.xml:263 ../en/ch05-collab.xml:273
6185 msgid "Feature branches"
6186 msgstr "特性分支"
6188 #. type: Content of: <book><chapter><sect1><sect2><para>
6189 #: ../en/ch05-collab.xml:265
6190 msgid ""
6191 "For larger projects, an effective way to manage change is to break up a team "
6192 "into smaller groups. Each group has a shared branch of its own, cloned from "
6193 "a single <quote>master</quote> branch used by the entire project. People "
6194 "working on an individual branch are typically quite isolated from "
6195 "developments on other branches."
6196 msgstr ""
6198 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
6199 #: ../en/ch05-collab.xml:275
6200 msgid ""
6201 "<imageobject><imagedata width=\"100%\" fileref=\"figs/feature-branches.png\"/"
6202 "></imageobject>"
6203 msgstr ""
6205 #. type: Content of: <book><chapter><sect1><sect2><para>
6206 #: ../en/ch05-collab.xml:280
6207 msgid ""
6208 "When a particular feature is deemed to be in suitable shape, someone on that "
6209 "feature team pulls and merges from the master branch into the feature branch, "
6210 "then pushes back up to the master branch."
6211 msgstr ""
6213 #. type: Content of: <book><chapter><sect1><sect2><title>
6214 #: ../en/ch05-collab.xml:287
6215 msgid "The release train"
6216 msgstr "发布列车"
6218 #. type: Content of: <book><chapter><sect1><sect2><para>
6219 #: ../en/ch05-collab.xml:289
6220 msgid ""
6221 "Some projects are organised on a <quote>train</quote> basis: a release is "
6222 "scheduled to happen every few months, and whatever features are ready when "
6223 "the <quote>train</quote> is ready to leave are allowed in."
6224 msgstr ""
6226 #. type: Content of: <book><chapter><sect1><sect2><para>
6227 #: ../en/ch05-collab.xml:294
6228 msgid ""
6229 "This model resembles working with feature branches. The difference is that "
6230 "when a feature branch misses a train, someone on the feature team pulls and "
6231 "merges the changes that went out on that train release into the feature "
6232 "branch, and the team continues its work on top of that release so that their "
6233 "feature can make the next release."
6234 msgstr ""
6236 #. type: Content of: <book><chapter><sect1><sect2><title>
6237 #: ../en/ch05-collab.xml:303
6238 msgid "The Linux kernel model"
6239 msgstr "Linux 内核模型"
6241 #. type: Content of: <book><chapter><sect1><sect2><para>
6242 #: ../en/ch05-collab.xml:305
6243 msgid ""
6244 "The development of the Linux kernel has a shallow hierarchical structure, "
6245 "surrounded by a cloud of apparent chaos. Because most Linux developers use "
6246 "<command>git</command>, a distributed revision control tool with capabilities "
6247 "similar to Mercurial, it's useful to describe the way work flows in that "
6248 "environment; if you like the ideas, the approach translates well across tools."
6249 msgstr ""
6251 #. type: Content of: <book><chapter><sect1><sect2><para>
6252 #: ../en/ch05-collab.xml:313
6253 msgid ""
6254 "At the center of the community sits Linus Torvalds, the creator of Linux. He "
6255 "publishes a single source repository that is considered the "
6256 "<quote>authoritative</quote> current tree by the entire developer community. "
6257 "Anyone can clone Linus's tree, but he is very choosy about whose trees he "
6258 "pulls from."
6259 msgstr ""
6261 #. type: Content of: <book><chapter><sect1><sect2><para>
6262 #: ../en/ch05-collab.xml:320
6263 msgid ""
6264 "Linus has a number of <quote>trusted lieutenants</quote>. As a general rule, "
6265 "he pulls whatever changes they publish, in most cases without even reviewing "
6266 "those changes. Some of those lieutenants are generally agreed to be "
6267 "<quote>maintainers</quote>, responsible for specific subsystems within the "
6268 "kernel. If a random kernel hacker wants to make a change to a subsystem that "
6269 "they want to end up in Linus's tree, they must find out who the subsystem's "
6270 "maintainer is, and ask that maintainer to take their change. If the "
6271 "maintainer reviews their changes and agrees to take them, they'll pass them "
6272 "along to Linus in due course."
6273 msgstr ""
6275 #. type: Content of: <book><chapter><sect1><sect2><para>
6276 #: ../en/ch05-collab.xml:332
6277 msgid ""
6278 "Individual lieutenants have their own approaches to reviewing, accepting, and "
6279 "publishing changes; and for deciding when to feed them to Linus. In "
6280 "addition, there are several well known branches that people use for different "
6281 "purposes. For example, a few people maintain <quote>stable</quote> "
6282 "repositories of older versions of the kernel, to which they apply critical "
6283 "fixes as needed. Some maintainers publish multiple trees: one for "
6284 "experimental changes; one for changes that they are about to feed upstream; "
6285 "and so on. Others just publish a single tree."
6286 msgstr ""
6288 #. type: Content of: <book><chapter><sect1><sect2><para>
6289 #: ../en/ch05-collab.xml:343
6290 msgid ""
6291 "This model has two notable features. The first is that it's <quote>pull "
6292 "only</quote>. You have to ask, convince, or beg another developer to take a "
6293 "change from you, because there are almost no trees to which more than one "
6294 "person can push, and there's no way to push changes into a tree that someone "
6295 "else controls."
6296 msgstr ""
6298 #. type: Content of: <book><chapter><sect1><sect2><para>
6299 #: ../en/ch05-collab.xml:350
6300 msgid ""
6301 "The second is that it's based on reputation and acclaim. If you're an "
6302 "unknown, Linus will probably ignore changes from you without even "
6303 "responding. But a subsystem maintainer will probably review them, and will "
6304 "likely take them if they pass their criteria for suitability. The more "
6305 "<quote>good</quote> changes you contribute to a maintainer, the more likely "
6306 "they are to trust your judgment and accept your changes. If you're well-"
6307 "known and maintain a long-lived branch for something Linus hasn't yet "
6308 "accepted, people with similar interests may pull your changes regularly to "
6309 "keep up with your work."
6310 msgstr ""
6312 #. type: Content of: <book><chapter><sect1><sect2><para>
6313 #: ../en/ch05-collab.xml:361
6314 msgid ""
6315 "Reputation and acclaim don't necessarily cross subsystem or <quote>people</"
6316 "quote> boundaries. If you're a respected but specialised storage hacker, and "
6317 "you try to fix a networking bug, that change will receive a level of scrutiny "
6318 "from a network maintainer comparable to a change from a complete stranger."
6319 msgstr ""
6321 #. type: Content of: <book><chapter><sect1><sect2><para>
6322 #: ../en/ch05-collab.xml:368
6323 msgid ""
6324 "To people who come from more orderly project backgrounds, the comparatively "
6325 "chaotic Linux kernel development process often seems completely insane. It's "
6326 "subject to the whims of individuals; people make sweeping changes whenever "
6327 "they deem it appropriate; and the pace of development is astounding. And yet "
6328 "Linux is a highly successful, well-regarded piece of software."
6329 msgstr ""
6331 #. type: Content of: <book><chapter><sect1><sect2><title>
6332 #: ../en/ch05-collab.xml:378
6333 msgid "Pull-only versus shared-push collaboration"
6334 msgstr "只读与共享写协作"
6336 #. type: Content of: <book><chapter><sect1><sect2><para>
6337 #: ../en/ch05-collab.xml:380
6338 msgid ""
6339 "A perpetual source of heat in the open source community is whether a "
6340 "development model in which people only ever pull changes from others is "
6341 "<quote>better than</quote> one in which multiple people can push changes to a "
6342 "shared repository."
6343 msgstr ""
6345 #. type: Content of: <book><chapter><sect1><sect2><para>
6346 #: ../en/ch05-collab.xml:386
6347 msgid ""
6348 "Typically, the backers of the shared-push model use tools that actively "
6349 "enforce this approach. If you're using a centralised revision control tool "
6350 "such as Subversion, there's no way to make a choice over which model you'll "
6351 "use: the tool gives you shared-push, and if you want to do anything else, "
6352 "you'll have to roll your own approach on top (such as applying a patch by "
6353 "hand)."
6354 msgstr ""
6356 #. type: Content of: <book><chapter><sect1><sect2><para>
6357 #: ../en/ch05-collab.xml:394
6358 msgid ""
6359 "A good distributed revision control tool, such as Mercurial, will support "
6360 "both models. You and your collaborators can then structure how you work "
6361 "together based on your own needs and preferences, not on what contortions "
6362 "your tools force you into."
6363 msgstr ""
6365 #. type: Content of: <book><chapter><sect1><sect2><title>
6366 #: ../en/ch05-collab.xml:402
6367 msgid "Where collaboration meets branch management"
6368 msgstr "协作与分支管理"
6370 #. type: Content of: <book><chapter><sect1><sect2><para>
6371 #: ../en/ch05-collab.xml:404
6372 msgid ""
6373 "Once you and your team set up some shared repositories and start propagating "
6374 "changes back and forth between local and shared repos, you begin to face a "
6375 "related, but slightly different challenge: that of managing the multiple "
6376 "directions in which your team may be moving at once. Even though this "
6377 "subject is intimately related to how your team collaborates, it's dense "
6378 "enough to merit treatment of its own, in <xref linkend=\"chap:branch\"/>."
6379 msgstr ""
6381 #. type: Content of: <book><chapter><sect1><title>
6382 #: ../en/ch05-collab.xml:416
6383 msgid "The technical side of sharing"
6384 msgstr "共享的技术因素"
6386 #. type: Content of: <book><chapter><sect1><para>
6387 #: ../en/ch05-collab.xml:418
6388 msgid ""
6389 "The remainder of this chapter is devoted to the question of serving data to "
6390 "your collaborators."
6391 msgstr ""
6393 #. type: Content of: <book><chapter><sect1><title>
6394 #: ../en/ch05-collab.xml:423
6395 msgid "Informal sharing with <command role=\"hg-cmd\">hg serve</command>"
6396 msgstr "使用 <command role=\"hg-cmd\">hg serve</command> 进行非正式共享"
6398 #. type: Content of: <book><chapter><sect1><para>
6399 #: ../en/ch05-collab.xml:426
6400 msgid ""
6401 "Mercurial's <command role=\"hg-cmd\">hg serve</command> command is "
6402 "wonderfully suited to small, tight-knit, and fast-paced group environments. "
6403 "It also provides a great way to get a feel for using Mercurial commands over "
6404 "a network."
6405 msgstr ""
6407 #. type: Content of: <book><chapter><sect1><para>
6408 #: ../en/ch05-collab.xml:431
6409 msgid ""
6410 "Run <command role=\"hg-cmd\">hg serve</command> inside a repository, and in "
6411 "under a second it will bring up a specialised HTTP server; this will accept "
6412 "connections from any client, and serve up data for that repository until you "
6413 "terminate it. Anyone who knows the URL of the server you just started, and "
6414 "can talk to your computer over the network, can then use a web browser or "
6415 "Mercurial to read data from that repository. A URL for a <command role=\"hg-"
6416 "cmd\">hg serve</command> instance running on a laptop is likely to look "
6417 "something like <literal>http://my-laptop.local:8000/</literal>."
6418 msgstr ""
6420 #. type: Content of: <book><chapter><sect1><para>
6421 #: ../en/ch05-collab.xml:442
6422 msgid ""
6423 "The <command role=\"hg-cmd\">hg serve</command> command is <emphasis>not</"
6424 "emphasis> a general-purpose web server. It can do only two things:"
6425 msgstr ""
6427 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
6428 #: ../en/ch05-collab.xml:446
6429 msgid ""
6430 "Allow people to browse the history of the repository it's serving, from their "
6431 "normal web browsers."
6432 msgstr ""
6434 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
6435 #: ../en/ch05-collab.xml:450
6436 msgid ""
6437 "Speak Mercurial's wire protocol, so that people can <command role=\"hg-cmd"
6438 "\">hg clone</command> or <command role=\"hg-cmd\">hg pull</command> changes "
6439 "from that repository."
6440 msgstr ""
6442 #. type: Content of: <book><chapter><sect1><para>
6443 #: ../en/ch05-collab.xml:455
6444 msgid ""
6445 "In particular, <command role=\"hg-cmd\">hg serve</command> won't allow remote "
6446 "users to <emphasis>modify</emphasis> your repository. It's intended for read-"
6447 "only use."
6448 msgstr ""
6450 #. type: Content of: <book><chapter><sect1><para>
6451 #: ../en/ch05-collab.xml:459
6452 msgid ""
6453 "If you're getting started with Mercurial, there's nothing to prevent you from "
6454 "using <command role=\"hg-cmd\">hg serve</command> to serve up a repository on "
6455 "your own computer, then use commands like <command role=\"hg-cmd\">hg clone</"
6456 "command>, <command role=\"hg-cmd\">hg incoming</command>, and so on to talk "
6457 "to that server as if the repository was hosted remotely. This can help you to "
6458 "quickly get acquainted with using commands on network-hosted repositories."
6459 msgstr ""
6461 #. type: Content of: <book><chapter><sect1><sect2><title>
6462 #: ../en/ch05-collab.xml:469
6463 msgid "A few things to keep in mind"
6464 msgstr "要牢记的几件事"
6466 #. type: Content of: <book><chapter><sect1><sect2><para>
6467 #: ../en/ch05-collab.xml:471
6468 msgid ""
6469 "Because it provides unauthenticated read access to all clients, you should "
6470 "only use <command role=\"hg-cmd\">hg serve</command> in an environment where "
6471 "you either don't care, or have complete control over, who can access your "
6472 "network and pull data from your repository."
6473 msgstr ""
6475 #. type: Content of: <book><chapter><sect1><sect2><para>
6476 #: ../en/ch05-collab.xml:477
6477 msgid ""
6478 "The <command role=\"hg-cmd\">hg serve</command> command knows nothing about "
6479 "any firewall software you might have installed on your system or network. It "
6480 "cannot detect or control your firewall software. If other people are unable "
6481 "to talk to a running <command role=\"hg-cmd\">hg serve</command> instance, "
6482 "the second thing you should do (<emphasis>after</emphasis> you make sure that "
6483 "they're using the correct URL) is check your firewall configuration."
6484 msgstr ""
6486 #. type: Content of: <book><chapter><sect1><sect2><para>
6487 #: ../en/ch05-collab.xml:486
6488 msgid ""
6489 "By default, <command role=\"hg-cmd\">hg serve</command> listens for incoming "
6490 "connections on port 8000. If another process is already listening on the "
6491 "port you want to use, you can specify a different port to listen on using the "
6492 "<option role=\"hg-opt-serve\">-p</option> option."
6493 msgstr ""
6495 #. type: Content of: <book><chapter><sect1><sect2><para>
6496 #: ../en/ch05-collab.xml:492
6497 msgid ""
6498 "Normally, when <command role=\"hg-cmd\">hg serve</command> starts, it prints "
6499 "no output, which can be a bit unnerving. If you'd like to confirm that it is "
6500 "indeed running correctly, and find out what URL you should send to your "
6501 "collaborators, start it with the <option role=\"hg-opt-global\">-v</option> "
6502 "option."
6503 msgstr ""
6505 #. type: Content of: <book><chapter><sect1><title>
6506 #: ../en/ch05-collab.xml:502
6507 msgid "Using the Secure Shell (ssh) protocol"
6508 msgstr "使用 ssh 协议"
6510 #. type: Content of: <book><chapter><sect1><para>
6511 #: ../en/ch05-collab.xml:504
6512 msgid ""
6513 "You can pull and push changes securely over a network connection using the "
6514 "Secure Shell (<literal>ssh</literal>) protocol. To use this successfully, "
6515 "you may have to do a little bit of configuration on the client or server "
6516 "sides."
6517 msgstr ""
6519 #. type: Content of: <book><chapter><sect1><para>
6520 #: ../en/ch05-collab.xml:509
6521 msgid ""
6522 "If you're not familiar with ssh, it's a network protocol that lets you "
6523 "securely communicate with another computer. To use it with Mercurial, you'll "
6524 "be setting up one or more user accounts on a server so that remote users can "
6525 "log in and execute commands."
6526 msgstr ""
6528 #. type: Content of: <book><chapter><sect1><para>
6529 #: ../en/ch05-collab.xml:515
6530 msgid ""
6531 "(If you <emphasis>are</emphasis> familiar with ssh, you'll probably find some "
6532 "of the material that follows to be elementary in nature.)"
6533 msgstr ""
6535 #. type: Content of: <book><chapter><sect1><sect2><title>
6536 #: ../en/ch05-collab.xml:520
6537 msgid "How to read and write ssh URLs"
6538 msgstr "如何读写 ssh 路径"
6540 #. type: Content of: <book><chapter><sect1><sect2><para>
6541 #: ../en/ch05-collab.xml:522
6542 msgid "An ssh URL tends to look like this:"
6543 msgstr ""
6545 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
6546 #: ../en/ch05-collab.xml:525
6547 msgid ""
6548 "The <quote><literal>ssh://</literal></quote> part tells Mercurial to use the "
6549 "ssh protocol."
6550 msgstr ""
6552 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
6553 #: ../en/ch05-collab.xml:528
6554 msgid ""
6555 "The <quote><literal>bos@</literal></quote> component indicates what username "
6556 "to log into the server as. You can leave this out if the remote username is "
6557 "the same as your local username."
6558 msgstr ""
6560 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
6561 #: ../en/ch05-collab.xml:533
6562 msgid ""
6563 "The <quote><literal>hg.serpentine.com</literal></quote> gives the hostname of "
6564 "the server to log into."
6565 msgstr ""
6567 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
6568 #: ../en/ch05-collab.xml:537
6569 msgid ""
6570 "The <quote>:22</quote> identifies the port number to connect to the server "
6571 "on. The default port is 22, so you only need to specify a colon and port "
6572 "number if you're <emphasis>not</emphasis> using port 22."
6573 msgstr ""
6575 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
6576 #: ../en/ch05-collab.xml:542
6577 msgid ""
6578 "The remainder of the URL is the local path to the repository on the server."
6579 msgstr ""
6581 #. type: Content of: <book><chapter><sect1><sect2><para>
6582 #: ../en/ch05-collab.xml:546
6583 msgid ""
6584 "There's plenty of scope for confusion with the path component of ssh URLs, as "
6585 "there is no standard way for tools to interpret it. Some programs behave "
6586 "differently than others when dealing with these paths. This isn't an ideal "
6587 "situation, but it's unlikely to change. Please read the following paragraphs "
6588 "carefully."
6589 msgstr ""
6591 #. type: Content of: <book><chapter><sect1><sect2><para>
6592 #: ../en/ch05-collab.xml:553
6593 msgid ""
6594 "Mercurial treats the path to a repository on the server as relative to the "
6595 "remote user's home directory. For example, if user <literal>foo</literal> on "
6596 "the server has a home directory of <filename class=\"directory\">/home/foo</"
6597 "filename>, then an ssh URL that contains a path component of <filename class="
6598 "\"directory\">bar</filename> <emphasis>really</emphasis> refers to the "
6599 "directory <filename class=\"directory\">/home/foo/bar</filename>."
6600 msgstr ""
6602 #. type: Content of: <book><chapter><sect1><sect2><para>
6603 #: ../en/ch05-collab.xml:562
6604 msgid ""
6605 "If you want to specify a path relative to another user's home directory, you "
6606 "can use a path that starts with a tilde character followed by the user's name "
6607 "(let's call them <literal>otheruser</literal>), like this."
6608 msgstr ""
6610 #. type: Content of: <book><chapter><sect1><sect2><para>
6611 #: ../en/ch05-collab.xml:568
6612 msgid ""
6613 "And if you really want to specify an <emphasis>absolute</emphasis> path on "
6614 "the server, begin the path component with two slashes, as in this example."
6615 msgstr ""
6617 #. type: Content of: <book><chapter><sect1><sect2><title>
6618 #: ../en/ch05-collab.xml:575
6619 msgid "Finding an ssh client for your system"
6620 msgstr "为你的系统寻找 ssh 客户端"
6622 #. type: Content of: <book><chapter><sect1><sect2><para>
6623 #: ../en/ch05-collab.xml:577
6624 msgid ""
6625 "Almost every Unix-like system comes with OpenSSH preinstalled. If you're "
6626 "using such a system, run <literal>which ssh</literal> to find out if the "
6627 "<command>ssh</command> command is installed (it's usually in <filename class="
6628 "\"directory\">/usr/bin</filename>). In the unlikely event that it isn't "
6629 "present, take a look at your system documentation to figure out how to "
6630 "install it."
6631 msgstr ""
6633 #. type: Content of: <book><chapter><sect1><sect2><para>
6634 #: ../en/ch05-collab.xml:585
6635 msgid ""
6636 "On Windows, you'll first need to download a suitable ssh client. There are "
6637 "two alternatives."
6638 msgstr ""
6640 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6641 #: ../en/ch05-collab.xml:588
6642 msgid ""
6643 "Simon Tatham's excellent PuTTY package <citation>web:putty</citation> "
6644 "provides a complete suite of ssh client commands."
6645 msgstr ""
6647 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6648 #: ../en/ch05-collab.xml:592
6649 msgid ""
6650 "If you have a high tolerance for pain, you can use the Cygwin port of OpenSSH."
6651 msgstr ""
6653 #. type: Content of: <book><chapter><sect1><sect2><para>
6654 #: ../en/ch05-collab.xml:595
6655 msgid ""
6656 "In either case, you'll need to edit your <filename role=\"special\">hg.ini</"
6657 "filename> file to tell Mercurial where to find the actual client command. "
6658 "For example, if you're using PuTTY, you'll need to use the <command>plink</"
6659 "command> command as a command-line ssh client."
6660 msgstr ""
6662 #. type: Content of: <book><chapter><sect1><sect2><note><para>
6663 #: ../en/ch05-collab.xml:605
6664 msgid ""
6665 "The path to <command>plink</command> shouldn't contain any whitespace "
6666 "characters, or Mercurial may not be able to run it correctly (so putting it "
6667 "in <filename class=\"directory\">C:\\Program Files</filename> is probably not "
6668 "a good idea)."
6669 msgstr ""
6671 #. type: Content of: <book><chapter><sect1><sect2><title>
6672 #: ../en/ch05-collab.xml:614
6673 msgid "Generating a key pair"
6674 msgstr "产生密钥对"
6676 #. type: Content of: <book><chapter><sect1><sect2><para>
6677 #: ../en/ch05-collab.xml:616
6678 msgid ""
6679 "To avoid the need to repetitively type a password every time you need to use "
6680 "your ssh client, I recommend generating a key pair. On a Unix-like system, "
6681 "the <command>ssh-keygen</command> command will do the trick. On Windows, if "
6682 "you're using PuTTY, the <command>puttygen</command> command is what you'll "
6683 "need."
6684 msgstr ""
6686 #. type: Content of: <book><chapter><sect1><sect2><para>
6687 #: ../en/ch05-collab.xml:624
6688 msgid ""
6689 "When you generate a key pair, it's usually <emphasis>highly</emphasis> "
6690 "advisable to protect it with a passphrase. (The only time that you might not "
6691 "want to do this is when you're using the ssh protocol for automated tasks on "
6692 "a secure network.)"
6693 msgstr ""
6695 #. type: Content of: <book><chapter><sect1><sect2><para>
6696 #: ../en/ch05-collab.xml:630
6697 msgid ""
6698 "Simply generating a key pair isn't enough, however. You'll need to add the "
6699 "public key to the set of authorised keys for whatever user you're logging in "
6700 "remotely as. For servers using OpenSSH (the vast majority), this will mean "
6701 "adding the public key to a list in a file called <filename role=\"special"
6702 "\">authorized_keys</filename> in their <filename role=\"special\" class="
6703 "\"directory\">.ssh</filename> directory."
6704 msgstr ""
6706 #. type: Content of: <book><chapter><sect1><sect2><para>
6707 #: ../en/ch05-collab.xml:639
6708 msgid ""
6709 "On a Unix-like system, your public key will have a <filename>.pub</filename> "
6710 "extension. If you're using <command>puttygen</command> on Windows, you can "
6711 "save the public key to a file of your choosing, or paste it from the window "
6712 "it's displayed in straight into the <filename role=\"special"
6713 "\">authorized_keys</filename> file."
6714 msgstr ""
6716 #. type: Content of: <book><chapter><sect1><sect2><title>
6717 #: ../en/ch05-collab.xml:648
6718 msgid "Using an authentication agent"
6719 msgstr "使用认证代理"
6721 #. type: Content of: <book><chapter><sect1><sect2><para>
6722 #: ../en/ch05-collab.xml:650
6723 msgid ""
6724 "An authentication agent is a daemon that stores passphrases in memory (so it "
6725 "will forget passphrases if you log out and log back in again). An ssh client "
6726 "will notice if it's running, and query it for a passphrase. If there's no "
6727 "authentication agent running, or the agent doesn't store the necessary "
6728 "passphrase, you'll have to type your passphrase every time Mercurial tries to "
6729 "communicate with a server on your behalf (e.g. whenever you pull or push "
6730 "changes)."
6731 msgstr ""
6733 #. type: Content of: <book><chapter><sect1><sect2><para>
6734 #: ../en/ch05-collab.xml:659
6735 msgid ""
6736 "The downside of storing passphrases in an agent is that it's possible for a "
6737 "well-prepared attacker to recover the plain text of your passphrases, in some "
6738 "cases even if your system has been power-cycled. You should make your own "
6739 "judgment as to whether this is an acceptable risk. It certainly saves a lot "
6740 "of repeated typing."
6741 msgstr ""
6743 #. type: Content of: <book><chapter><sect1><sect2><para>
6744 #: ../en/ch05-collab.xml:666
6745 msgid ""
6746 "On Unix-like systems, the agent is called <command>ssh-agent</command>, and "
6747 "it's often run automatically for you when you log in. You'll need to use the "
6748 "<command>ssh-add</command> command to add passphrases to the agent's store. "
6749 "On Windows, if you're using PuTTY, the <command>pageant</command> command "
6750 "acts as the agent. It adds an icon to your system tray that will let you "
6751 "manage stored passphrases."
6752 msgstr ""
6754 #. type: Content of: <book><chapter><sect1><sect2><title>
6755 #: ../en/ch05-collab.xml:677
6756 msgid "Configuring the server side properly"
6757 msgstr "正确配置服务器端"
6759 #. type: Content of: <book><chapter><sect1><sect2><para>
6760 #: ../en/ch05-collab.xml:679
6761 msgid ""
6762 "Because ssh can be fiddly to set up if you're new to it, there's a variety of "
6763 "things that can go wrong. Add Mercurial on top, and there's plenty more "
6764 "scope for head-scratching. Most of these potential problems occur on the "
6765 "server side, not the client side. The good news is that once you've gotten a "
6766 "configuration working, it will usually continue to work indefinitely."
6767 msgstr ""
6769 #. type: Content of: <book><chapter><sect1><sect2><para>
6770 #: ../en/ch05-collab.xml:687
6771 msgid ""
6772 "Before you try using Mercurial to talk to an ssh server, it's best to make "
6773 "sure that you can use the normal <command>ssh</command> or <command>putty</"
6774 "command> command to talk to the server first. If you run into problems with "
6775 "using these commands directly, Mercurial surely won't work. Worse, it will "
6776 "obscure the underlying problem. Any time you want to debug ssh-related "
6777 "Mercurial problems, you should drop back to making sure that plain ssh client "
6778 "commands work first, <emphasis>before</emphasis> you worry about whether "
6779 "there's a problem with Mercurial."
6780 msgstr ""
6782 #. type: Content of: <book><chapter><sect1><sect2><para>
6783 #: ../en/ch05-collab.xml:698
6784 msgid ""
6785 "The first thing to be sure of on the server side is that you can actually log "
6786 "in from another machine at all. If you can't use <command>ssh</command> or "
6787 "<command>putty</command> to log in, the error message you get may give you a "
6788 "few hints as to what's wrong. The most common problems are as follows."
6789 msgstr ""
6791 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6792 #: ../en/ch05-collab.xml:705
6793 msgid ""
6794 "If you get a <quote>connection refused</quote> error, either there isn't an "
6795 "SSH daemon running on the server at all, or it's inaccessible due to firewall "
6796 "configuration."
6797 msgstr ""
6799 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6800 #: ../en/ch05-collab.xml:710
6801 msgid ""
6802 "If you get a <quote>no route to host</quote> error, you either have an "
6803 "incorrect address for the server or a seriously locked down firewall that "
6804 "won't admit its existence at all."
6805 msgstr ""
6807 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6808 #: ../en/ch05-collab.xml:715
6809 msgid ""
6810 "If you get a <quote>permission denied</quote> error, you may have mistyped "
6811 "the username on the server, or you could have mistyped your key's passphrase "
6812 "or the remote user's password."
6813 msgstr ""
6815 #. type: Content of: <book><chapter><sect1><sect2><para>
6816 #: ../en/ch05-collab.xml:720
6817 msgid ""
6818 "In summary, if you're having trouble talking to the server's ssh daemon, "
6819 "first make sure that one is running at all. On many systems it will be "
6820 "installed, but disabled, by default. Once you're done with this step, you "
6821 "should then check that the server's firewall is configured to allow incoming "
6822 "connections on the port the ssh daemon is listening on (usually 22). Don't "
6823 "worry about more exotic possibilities for misconfiguration until you've "
6824 "checked these two first."
6825 msgstr ""
6827 #. type: Content of: <book><chapter><sect1><sect2><para>
6828 #: ../en/ch05-collab.xml:730
6829 msgid ""
6830 "If you're using an authentication agent on the client side to store "
6831 "passphrases for your keys, you ought to be able to log into the server "
6832 "without being prompted for a passphrase or a password. If you're prompted "
6833 "for a passphrase, there are a few possible culprits."
6834 msgstr ""
6836 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6837 #: ../en/ch05-collab.xml:736
6838 msgid ""
6839 "You might have forgotten to use <command>ssh-add</command> or "
6840 "<command>pageant</command> to store the passphrase."
6841 msgstr ""
6843 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6844 #: ../en/ch05-collab.xml:740
6845 msgid "You might have stored the passphrase for the wrong key."
6846 msgstr ""
6848 #. type: Content of: <book><chapter><sect1><sect2><para>
6849 #: ../en/ch05-collab.xml:743
6850 msgid ""
6851 "If you're being prompted for the remote user's password, there are another "
6852 "few possible problems to check."
6853 msgstr ""
6855 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6856 #: ../en/ch05-collab.xml:746
6857 msgid ""
6858 "Either the user's home directory or their <filename role=\"special\" class="
6859 "\"directory\">.ssh</filename> directory might have excessively liberal "
6860 "permissions. As a result, the ssh daemon will not trust or read their "
6861 "<filename role=\"special\">authorized_keys</filename> file. For example, a "
6862 "group-writable home or <filename role=\"special\" class=\"directory\">.ssh</"
6863 "filename> directory will often cause this symptom."
6864 msgstr ""
6866 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6867 #: ../en/ch05-collab.xml:755
6868 msgid ""
6869 "The user's <filename role=\"special\">authorized_keys</filename> file may "
6870 "have a problem. If anyone other than the user owns or can write to that file, "
6871 "the ssh daemon will not trust or read it."
6872 msgstr ""
6874 #. type: Content of: <book><chapter><sect1><sect2><para>
6875 #: ../en/ch05-collab.xml:762
6876 msgid ""
6877 "In the ideal world, you should be able to run the following command "
6878 "successfully, and it should print exactly one line of output, the current "
6879 "date and time."
6880 msgstr ""
6882 #. type: Content of: <book><chapter><sect1><sect2><para>
6883 #: ../en/ch05-collab.xml:767
6884 msgid ""
6885 "If, on your server, you have login scripts that print banners or other junk "
6886 "even when running non-interactive commands like this, you should fix them "
6887 "before you continue, so that they only print output if they're run "
6888 "interactively. Otherwise these banners will at least clutter up Mercurial's "
6889 "output. Worse, they could potentially cause problems with running Mercurial "
6890 "commands remotely. Mercurial makes tries to detect and ignore banners in non-"
6891 "interactive <command>ssh</command> sessions, but it is not foolproof. (If "
6892 "you're editing your login scripts on your server, the usual way to see if a "
6893 "login script is running in an interactive shell is to check the return code "
6894 "from the command <literal>tty -s</literal>.)"
6895 msgstr ""
6897 #. type: Content of: <book><chapter><sect1><sect2><para>
6898 #: ../en/ch05-collab.xml:781
6899 msgid ""
6900 "Once you've verified that plain old ssh is working with your server, the next "
6901 "step is to ensure that Mercurial runs on the server. The following command "
6902 "should run successfully:"
6903 msgstr ""
6905 #. type: Content of: <book><chapter><sect1><sect2><para>
6906 #: ../en/ch05-collab.xml:788
6907 msgid ""
6908 "If you see an error message instead of normal <command role=\"hg-cmd\">hg "
6909 "version</command> output, this is usually because you haven't installed "
6910 "Mercurial to <filename class=\"directory\">/usr/bin</filename>. Don't worry "
6911 "if this is the case; you don't need to do that. But you should check for a "
6912 "few possible problems."
6913 msgstr ""
6915 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6916 #: ../en/ch05-collab.xml:795
6917 msgid ""
6918 "Is Mercurial really installed on the server at all? I know this sounds "
6919 "trivial, but it's worth checking!"
6920 msgstr ""
6922 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6923 #: ../en/ch05-collab.xml:799
6924 msgid ""
6925 "Maybe your shell's search path (usually set via the <envar>PATH</envar> "
6926 "environment variable) is simply misconfigured."
6927 msgstr ""
6929 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6930 #: ../en/ch05-collab.xml:803
6931 msgid ""
6932 "Perhaps your <envar>PATH</envar> environment variable is only being set to "
6933 "point to the location of the <command>hg</command> executable if the login "
6934 "session is interactive. This can happen if you're setting the path in the "
6935 "wrong shell login script. See your shell's documentation for details."
6936 msgstr ""
6938 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6939 #: ../en/ch05-collab.xml:810
6940 msgid ""
6941 "The <envar>PYTHONPATH</envar> environment variable may need to contain the "
6942 "path to the Mercurial Python modules. It might not be set at all; it could "
6943 "be incorrect; or it may be set only if the login is interactive."
6944 msgstr ""
6946 #. type: Content of: <book><chapter><sect1><sect2><para>
6947 #: ../en/ch05-collab.xml:817
6948 msgid ""
6949 "If you can run <command role=\"hg-cmd\">hg version</command> over an ssh "
6950 "connection, well done! You've got the server and client sorted out. You "
6951 "should now be able to use Mercurial to access repositories hosted by that "
6952 "username on that server. If you run into problems with Mercurial and ssh at "
6953 "this point, try using the <option role=\"hg-opt-global\">--debug</option> "
6954 "option to get a clearer picture of what's going on."
6955 msgstr ""
6957 #. type: Content of: <book><chapter><sect1><sect2><title>
6958 #: ../en/ch05-collab.xml:827
6959 msgid "Using compression with ssh"
6960 msgstr "通过 ssh 使用压缩"
6962 #. type: Content of: <book><chapter><sect1><sect2><para>
6963 #: ../en/ch05-collab.xml:829
6964 msgid ""
6965 "Mercurial does not compress data when it uses the ssh protocol, because the "
6966 "ssh protocol can transparently compress data. However, the default behaviour "
6967 "of ssh clients is <emphasis>not</emphasis> to request compression."
6968 msgstr ""
6970 #. type: Content of: <book><chapter><sect1><sect2><para>
6971 #: ../en/ch05-collab.xml:834
6972 msgid ""
6973 "Over any network other than a fast LAN (even a wireless network), using "
6974 "compression is likely to significantly speed up Mercurial's network "
6975 "operations. For example, over a WAN, someone measured compression as "
6976 "reducing the amount of time required to clone a particularly large repository "
6977 "from 51 minutes to 17 minutes."
6978 msgstr ""
6980 #. type: Content of: <book><chapter><sect1><sect2><para>
6981 #: ../en/ch05-collab.xml:841
6982 msgid ""
6983 "Both <command>ssh</command> and <command>plink</command> accept a <option "
6984 "role=\"cmd-opt-ssh\">-C</option> option which turns on compression. You can "
6985 "easily edit your <filename role=\"special\">~/.hgrc</filename> to enable "
6986 "compression for all of Mercurial's uses of the ssh protocol."
6987 msgstr ""
6989 #. type: Content of: <book><chapter><sect1><sect2><para>
6990 #: ../en/ch05-collab.xml:849
6991 msgid ""
6992 "If you use <command>ssh</command>, you can configure it to always use "
6993 "compression when talking to your server. To do this, edit your <filename "
6994 "role=\"special\">.ssh/config</filename> file (which may not yet exist), as "
6995 "follows."
6996 msgstr ""
6998 #. type: Content of: <book><chapter><sect1><sect2><para>
6999 #: ../en/ch05-collab.xml:857
7000 msgid ""
7001 "This defines an alias, <literal>hg</literal>. When you use it on the "
7002 "<command>ssh</command> command line or in a Mercurial <literal>ssh</literal>-"
7003 "protocol URL, it will cause <command>ssh</command> to connect to <literal>hg."
7004 "example.com</literal> and use compression. This gives you both a shorter "
7005 "name to type and compression, each of which is a good thing in its own right."
7006 msgstr ""
7008 #. type: Content of: <book><chapter><sect1><title>
7009 #: ../en/ch05-collab.xml:868
7010 msgid "Serving over HTTP using CGI"
7011 msgstr "使用 CGI 通过 HTTP 提供服务"
7013 #. type: Content of: <book><chapter><sect1><para>
7014 #: ../en/ch05-collab.xml:870
7015 msgid ""
7016 "Depending on how ambitious you are, configuring Mercurial's CGI interface can "
7017 "take anything from a few moments to several hours."
7018 msgstr ""
7020 #. type: Content of: <book><chapter><sect1><para>
7021 #: ../en/ch05-collab.xml:874
7022 msgid ""
7023 "We'll begin with the simplest of examples, and work our way towards a more "
7024 "complex configuration. Even for the most basic case, you're almost certainly "
7025 "going to need to read and modify your web server's configuration."
7026 msgstr ""
7028 #. type: Content of: <book><chapter><sect1><note><para>
7029 #: ../en/ch05-collab.xml:880
7030 msgid ""
7031 "Configuring a web server is a complex, fiddly, and highly system-dependent "
7032 "activity. I can't possibly give you instructions that will cover anything "
7033 "like all of the cases you will encounter. Please use your discretion and "
7034 "judgment in following the sections below. Be prepared to make plenty of "
7035 "mistakes, and to spend a lot of time reading your server's error logs."
7036 msgstr ""
7038 #. type: Content of: <book><chapter><sect1><sect2><title>
7039 #: ../en/ch05-collab.xml:890
7040 msgid "Web server configuration checklist"
7041 msgstr "Web 服务器配置检查表"
7043 #. type: Content of: <book><chapter><sect1><sect2><para>
7044 #: ../en/ch05-collab.xml:892
7045 msgid ""
7046 "Before you continue, do take a few moments to check a few aspects of your "
7047 "system's setup."
7048 msgstr ""
7050 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
7051 #: ../en/ch05-collab.xml:896
7052 msgid ""
7053 "Do you have a web server installed at all? Mac OS X ships with Apache, but "
7054 "many other systems may not have a web server installed."
7055 msgstr ""
7057 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
7058 #: ../en/ch05-collab.xml:900
7059 msgid ""
7060 "If you have a web server installed, is it actually running? On most systems, "
7061 "even if one is present, it will be disabled by default."
7062 msgstr ""
7064 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
7065 #: ../en/ch05-collab.xml:904
7066 msgid ""
7067 "Is your server configured to allow you to run CGI programs in the directory "
7068 "where you plan to do so? Most servers default to explicitly disabling the "
7069 "ability to run CGI programs."
7070 msgstr ""
7072 #. type: Content of: <book><chapter><sect1><sect2><para>
7073 #: ../en/ch05-collab.xml:910
7074 msgid ""
7075 "If you don't have a web server installed, and don't have substantial "
7076 "experience configuring Apache, you should consider using the "
7077 "<literal>lighttpd</literal> web server instead of Apache. Apache has a well-"
7078 "deserved reputation for baroque and confusing configuration. While "
7079 "<literal>lighttpd</literal> is less capable in some ways than Apache, most of "
7080 "these capabilities are not relevant to serving Mercurial repositories. And "
7081 "<literal>lighttpd</literal> is undeniably <emphasis>much</emphasis> easier to "
7082 "get started with than Apache."
7083 msgstr ""
7085 #. type: Content of: <book><chapter><sect1><sect2><title>
7086 #: ../en/ch05-collab.xml:923
7087 msgid "Basic CGI configuration"
7088 msgstr "基本 CGI 配置"
7090 #. type: Content of: <book><chapter><sect1><sect2><para>
7091 #: ../en/ch05-collab.xml:925
7092 msgid ""
7093 "On Unix-like systems, it's common for users to have a subdirectory named "
7094 "something like <filename class=\"directory\">public_html</filename> in their "
7095 "home directory, from which they can serve up web pages. A file named "
7096 "<filename>foo</filename> in this directory will be accessible at a URL of the "
7097 "form <literal>http://www.example.com/username/foo</literal>."
7098 msgstr ""
7100 #. type: Content of: <book><chapter><sect1><sect2><para>
7101 #: ../en/ch05-collab.xml:933
7102 msgid ""
7103 "To get started, find the <filename role=\"special\">hgweb.cgi</filename> "
7104 "script that should be present in your Mercurial installation. If you can't "
7105 "quickly find a local copy on your system, simply download one from the master "
7106 "Mercurial repository at <ulink url=\"http://www.selenic.com/repo/hg/raw-file/"
7107 "tip/hgweb.cgi\">http://www.selenic.com/repo/hg/raw-file/tip/hgweb.cgi</ulink>."
7108 msgstr ""
7110 #. type: Content of: <book><chapter><sect1><sect2><para>
7111 #: ../en/ch05-collab.xml:940 ../en/ch05-collab.xml:1109
7112 msgid ""
7113 "You'll need to copy this script into your <filename class=\"directory"
7114 "\">public_html</filename> directory, and ensure that it's executable."
7115 msgstr ""
7117 #. type: Content of: <book><chapter><sect1><sect2><para>
7118 #: ../en/ch05-collab.xml:945
7119 msgid ""
7120 "The <literal>755</literal> argument to <command>chmod</command> is a little "
7121 "more general than just making the script executable: it ensures that the "
7122 "script is executable by anyone, and that <quote>group</quote> and "
7123 "<quote>other</quote> write permissions are <emphasis>not</emphasis> set. If "
7124 "you were to leave those write permissions enabled, Apache's <literal>suexec</"
7125 "literal> subsystem would likely refuse to execute the script. In fact, "
7126 "<literal>suexec</literal> also insists that the <emphasis>directory</"
7127 "emphasis> in which the script resides must not be writable by others."
7128 msgstr ""
7130 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
7131 #: ../en/ch05-collab.xml:959
7132 msgid "What could <emphasis>possibly</emphasis> go wrong?"
7133 msgstr "什么<emphasis>可能</emphasis>会出错?"
7135 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7136 #: ../en/ch05-collab.xml:962
7137 msgid ""
7138 "Once you've copied the CGI script into place, go into a web browser, and try "
7139 "to open the URL <ulink url=\"http://myhostname/ myuser/hgweb.cgi\">http://"
7140 "myhostname/ myuser/hgweb.cgi</ulink>, <emphasis>but</emphasis> brace yourself "
7141 "for instant failure. There's a high probability that trying to visit this "
7142 "URL will fail, and there are many possible reasons for this. In fact, you're "
7143 "likely to stumble over almost every one of the possible errors below, so "
7144 "please read carefully. The following are all of the problems I ran into on a "
7145 "system running Fedora 7, with a fresh installation of Apache, and a user "
7146 "account that I created specially to perform this exercise."
7147 msgstr ""
7149 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7150 #: ../en/ch05-collab.xml:976
7151 msgid ""
7152 "Your web server may have per-user directories disabled. If you're using "
7153 "Apache, search your config file for a <literal>UserDir</literal> directive. "
7154 "If there's none present, per-user directories will be disabled. If one "
7155 "exists, but its value is <literal>disabled</literal>, then per-user "
7156 "directories will be disabled. Otherwise, the string after <literal>UserDir</"
7157 "literal> gives the name of the subdirectory that Apache will look in under "
7158 "your home directory, for example <filename class=\"directory\">public_html</"
7159 "filename>."
7160 msgstr ""
7162 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7163 #: ../en/ch05-collab.xml:987
7164 msgid ""
7165 "Your file access permissions may be too restrictive. The web server must be "
7166 "able to traverse your home directory and directories under your <filename "
7167 "class=\"directory\">public_html</filename> directory, and read files under "
7168 "the latter too. Here's a quick recipe to help you to make your permissions "
7169 "more appropriate."
7170 msgstr ""
7172 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7173 #: ../en/ch05-collab.xml:997
7174 msgid ""
7175 "The other possibility with permissions is that you might get a completely "
7176 "empty window when you try to load the script. In this case, it's likely that "
7177 "your access permissions are <emphasis>too permissive</emphasis>. Apache's "
7178 "<literal>suexec</literal> subsystem won't execute a script that's group- or "
7179 "world-writable, for example."
7180 msgstr ""
7182 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7183 #: ../en/ch05-collab.xml:1004
7184 msgid ""
7185 "Your web server may be configured to disallow execution of CGI programs in "
7186 "your per-user web directory. Here's Apache's default per-user configuration "
7187 "from my Fedora system."
7188 msgstr ""
7190 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7191 #: ../en/ch05-collab.xml:1011
7192 msgid ""
7193 "If you find a similar-looking <literal>Directory</literal> group in your "
7194 "Apache configuration, the directive to look at inside it is <literal>Options</"
7195 "literal>. Add <literal>ExecCGI</literal> to the end of this list if it's "
7196 "missing, and restart the web server."
7197 msgstr ""
7199 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7200 #: ../en/ch05-collab.xml:1018
7201 msgid ""
7202 "If you find that Apache serves you the text of the CGI script instead of "
7203 "executing it, you may need to either uncomment (if already present) or add a "
7204 "directive like this."
7205 msgstr ""
7207 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7208 #: ../en/ch05-collab.xml:1024
7209 msgid ""
7210 "The next possibility is that you might be served with a colourful Python "
7211 "backtrace claiming that it can't import a <literal>mercurial</literal>-"
7212 "related module. This is actually progress! The server is now capable of "
7213 "executing your CGI script. This error is only likely to occur if you're "
7214 "running a private installation of Mercurial, instead of a system-wide "
7215 "version. Remember that the web server runs the CGI program without any of "
7216 "the environment variables that you take for granted in an interactive "
7217 "session. If this error happens to you, edit your copy of <filename role="
7218 "\"special\">hgweb.cgi</filename> and follow the directions inside it to "
7219 "correctly set your <envar>PYTHONPATH</envar> environment variable."
7220 msgstr ""
7222 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7223 #: ../en/ch05-collab.xml:1038
7224 msgid ""
7225 "Finally, you are <emphasis>certain</emphasis> to by served with another "
7226 "colourful Python backtrace: this one will complain that it can't find "
7227 "<filename class=\"directory\">/path/to/repository</filename>. Edit your "
7228 "<filename role=\"special\">hgweb.cgi</filename> script and replace the "
7229 "<filename class=\"directory\">/path/to/repository</filename> string with the "
7230 "complete path to the repository you want to serve up."
7231 msgstr ""
7233 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7234 #: ../en/ch05-collab.xml:1048
7235 msgid ""
7236 "At this point, when you try to reload the page, you should be presented with "
7237 "a nice HTML view of your repository's history. Whew!"
7238 msgstr ""
7240 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
7241 #: ../en/ch05-collab.xml:1054
7242 msgid "Configuring lighttpd"
7243 msgstr "配置 lighttpd"
7245 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7246 #: ../en/ch05-collab.xml:1056
7247 msgid ""
7248 "To be exhaustive in my experiments, I tried configuring the increasingly "
7249 "popular <literal>lighttpd</literal> web server to serve the same repository "
7250 "as I described with Apache above. I had already overcome all of the problems "
7251 "I outlined with Apache, many of which are not server-specific. As a result, "
7252 "I was fairly sure that my file and directory permissions were good, and that "
7253 "my <filename role=\"special\">hgweb.cgi</filename> script was properly edited."
7254 msgstr ""
7256 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7257 #: ../en/ch05-collab.xml:1066
7258 msgid ""
7259 "Once I had Apache running, getting <literal>lighttpd</literal> to serve the "
7260 "repository was a snap (in other words, even if you're trying to use "
7261 "<literal>lighttpd</literal>, you should read the Apache section). I first "
7262 "had to edit the <literal>mod_access</literal> section of its config file to "
7263 "enable <literal>mod_cgi</literal> and <literal>mod_userdir</literal>, both of "
7264 "which were disabled by default on my system. I then added a few lines to the "
7265 "end of the config file, to configure these modules."
7266 msgstr ""
7268 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7269 #: ../en/ch05-collab.xml:1078
7270 msgid ""
7271 "With this done, <literal>lighttpd</literal> ran immediately for me. If I had "
7272 "configured <literal>lighttpd</literal> before Apache, I'd almost certainly "
7273 "have run into many of the same system-level configuration problems as I did "
7274 "with Apache. However, I found <literal>lighttpd</literal> to be noticeably "
7275 "easier to configure than Apache, even though I've used Apache for over a "
7276 "decade, and this was my first exposure to <literal>lighttpd</literal>."
7277 msgstr ""
7279 #. type: Content of: <book><chapter><sect1><sect2><title>
7280 #: ../en/ch05-collab.xml:1091
7281 msgid "Sharing multiple repositories with one CGI script"
7282 msgstr "使用一个 CGI 脚本共享多个版本库"
7284 #. type: Content of: <book><chapter><sect1><sect2><para>
7285 #: ../en/ch05-collab.xml:1093
7286 msgid ""
7287 "The <filename role=\"special\">hgweb.cgi</filename> script only lets you "
7288 "publish a single repository, which is an annoying restriction. If you want "
7289 "to publish more than one without wracking yourself with multiple copies of "
7290 "the same script, each with different names, a better choice is to use the "
7291 "<filename role=\"special\">hgwebdir.cgi</filename> script."
7292 msgstr ""
7294 #. type: Content of: <book><chapter><sect1><sect2><para>
7295 #: ../en/ch05-collab.xml:1101
7296 msgid ""
7297 "The procedure to configure <filename role=\"special\">hgwebdir.cgi</filename> "
7298 "is only a little more involved than for <filename role=\"special\">hgweb.cgi</"
7299 "filename>. First, you must obtain a copy of the script. If you don't have "
7300 "one handy, you can download a copy from the master Mercurial repository at "
7301 "<ulink url=\"http://www.selenic.com/repo/hg/raw-file/tip/hgwebdir.cgi"
7302 "\">http://www.selenic.com/repo/hg/raw-file/tip/hgwebdir.cgi</ulink>."
7303 msgstr ""
7305 #. type: Content of: <book><chapter><sect1><sect2><para>
7306 #: ../en/ch05-collab.xml:1116
7307 msgid ""
7308 "With basic configuration out of the way, try to visit <ulink url=\"http://"
7309 "myhostname/ myuser/hgwebdir.cgi\">http://myhostname/ myuser/hgwebdir.cgi</"
7310 "ulink> in your browser. It should display an empty list of repositories. If "
7311 "you get a blank window or error message, try walking through the list of "
7312 "potential problems in <xref linkend=\"sec:collab:wtf\"/>."
7313 msgstr ""
7315 #. type: Content of: <book><chapter><sect1><sect2><para>
7316 #: ../en/ch05-collab.xml:1125
7317 msgid ""
7318 "The <filename role=\"special\">hgwebdir.cgi</filename> script relies on an "
7319 "external configuration file. By default, it searches for a file named "
7320 "<filename role=\"special\">hgweb.config</filename> in the same directory as "
7321 "itself. You'll need to create this file, and make it world-readable. The "
7322 "format of the file is similar to a Windows <quote>ini</quote> file, as "
7323 "understood by Python's <literal>ConfigParser</literal> <citation>web:"
7324 "configparser</citation> module."
7325 msgstr ""
7327 #. type: Content of: <book><chapter><sect1><sect2><para>
7328 #: ../en/ch05-collab.xml:1135
7329 msgid ""
7330 "The easiest way to configure <filename role=\"special\">hgwebdir.cgi</"
7331 "filename> is with a section named <literal>collections</literal>. This will "
7332 "automatically publish <emphasis>every</emphasis> repository under the "
7333 "directories you name. The section should look like this:"
7334 msgstr ""
7336 #. type: Content of: <book><chapter><sect1><sect2><para>
7337 #: ../en/ch05-collab.xml:1143
7338 msgid ""
7339 "Mercurial interprets this by looking at the directory name on the "
7340 "<emphasis>right</emphasis> hand side of the <quote><literal>=</literal></"
7341 "quote> sign; finding repositories in that directory hierarchy; and using the "
7342 "text on the <emphasis>left</emphasis> to strip off matching text from the "
7343 "names it will actually list in the web interface. The remaining component of "
7344 "a path after this stripping has occurred is called a <quote>virtual path</"
7345 "quote>."
7346 msgstr ""
7348 #. type: Content of: <book><chapter><sect1><sect2><para>
7349 #: ../en/ch05-collab.xml:1152
7350 msgid ""
7351 "Given the example above, if we have a repository whose local path is "
7352 "<filename class=\"directory\">/my/root/this/repo</filename>, the CGI script "
7353 "will strip the leading <filename class=\"directory\">/my/root</filename> from "
7354 "the name, and publish the repository with a virtual path of <filename class="
7355 "\"directory\">this/repo</filename>. If the base URL for our CGI script is "
7356 "<ulink url=\"http://myhostname/ myuser/hgwebdir.cgi\">http://myhostname/ "
7357 "myuser/hgwebdir.cgi</ulink>, the complete URL for that repository will be "
7358 "<ulink url=\"http://myhostname/ myuser/hgwebdir.cgi/this/repo\">http://"
7359 "myhostname/ myuser/hgwebdir.cgi/this/repo</ulink>."
7360 msgstr ""
7362 #. type: Content of: <book><chapter><sect1><sect2><para>
7363 #: ../en/ch05-collab.xml:1166
7364 msgid ""
7365 "If we replace <filename class=\"directory\">/my/root</filename> on the left "
7366 "hand side of this example with <filename class=\"directory\">/my</filename>, "
7367 "then <filename role=\"special\">hgwebdir.cgi</filename> will only strip off "
7368 "<filename class=\"directory\">/my</filename> from the repository name, and "
7369 "will give us a virtual path of <filename class=\"directory\">root/this/repo</"
7370 "filename> instead of <filename class=\"directory\">this/repo</filename>."
7371 msgstr ""
7373 #. type: Content of: <book><chapter><sect1><sect2><para>
7374 #: ../en/ch05-collab.xml:1176
7375 msgid ""
7376 "The <filename role=\"special\">hgwebdir.cgi</filename> script will "
7377 "recursively search each directory listed in the <literal>collections</"
7378 "literal> section of its configuration file, but it will <literal>not</"
7379 "literal> recurse into the repositories it finds."
7380 msgstr ""
7382 #. type: Content of: <book><chapter><sect1><sect2><para>
7383 #: ../en/ch05-collab.xml:1182
7384 msgid ""
7385 "The <literal>collections</literal> mechanism makes it easy to publish many "
7386 "repositories in a <quote>fire and forget</quote> manner. You only need to "
7387 "set up the CGI script and configuration file one time. Afterwards, you can "
7388 "publish or unpublish a repository at any time by simply moving it into, or "
7389 "out of, the directory hierarchy in which you've configured <filename role="
7390 "\"special\">hgwebdir.cgi</filename> to look."
7391 msgstr ""
7393 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
7394 #: ../en/ch05-collab.xml:1192
7395 msgid "Explicitly specifying which repositories to publish"
7396 msgstr "明确指出要发布的版本库"
7398 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7399 #: ../en/ch05-collab.xml:1195
7400 msgid ""
7401 "In addition to the <literal>collections</literal> mechanism, the <filename "
7402 "role=\"special\">hgwebdir.cgi</filename> script allows you to publish a "
7403 "specific list of repositories. To do so, create a <literal>paths</literal> "
7404 "section, with contents of the following form."
7405 msgstr ""
7407 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7408 #: ../en/ch05-collab.xml:1204
7409 msgid ""
7410 "In this case, the virtual path (the component that will appear in a URL) is "
7411 "on the left hand side of each definition, while the path to the repository is "
7412 "on the right. Notice that there does not need to be any relationship between "
7413 "the virtual path you choose and the location of a repository in your "
7414 "filesystem."
7415 msgstr ""
7417 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7418 #: ../en/ch05-collab.xml:1211
7419 msgid ""
7420 "If you wish, you can use both the <literal>collections</literal> and "
7421 "<literal>paths</literal> mechanisms simultaneously in a single configuration "
7422 "file."
7423 msgstr ""
7425 #. type: Content of: <book><chapter><sect1><sect2><sect3><note><para>
7426 #: ../en/ch05-collab.xml:1217
7427 msgid ""
7428 "If multiple repositories have the same virtual path, <filename role=\"special"
7429 "\">hgwebdir.cgi</filename> will not report an error. Instead, it will behave "
7430 "unpredictably."
7431 msgstr ""
7433 #. type: Content of: <book><chapter><sect1><sect2><title>
7434 #: ../en/ch05-collab.xml:1226
7435 msgid "Downloading source archives"
7436 msgstr "下载源代码档案包"
7438 #. type: Content of: <book><chapter><sect1><sect2><para>
7439 #: ../en/ch05-collab.xml:1228
7440 msgid ""
7441 "Mercurial's web interface lets users download an archive of any revision. "
7442 "This archive will contain a snapshot of the working directory as of that "
7443 "revision, but it will not contain a copy of the repository data."
7444 msgstr ""
7446 #. type: Content of: <book><chapter><sect1><sect2><para>
7447 #: ../en/ch05-collab.xml:1233
7448 msgid ""
7449 "By default, this feature is not enabled. To enable it, you'll need to add an "
7450 "<envar role=\"rc-item-web\">allow_archive</envar> item to the <literal role="
7451 "\"rc-web\">web</literal> section of your <filename role=\"special\">~/.hgrc</"
7452 "filename>."
7453 msgstr ""
7455 #. type: Content of: <book><chapter><sect1><sect2><title>
7456 #: ../en/ch05-collab.xml:1241
7457 msgid "Web configuration options"
7458 msgstr "Web 配置选项"
7460 #. type: Content of: <book><chapter><sect1><sect2><para>
7461 #: ../en/ch05-collab.xml:1243
7462 msgid ""
7463 "Mercurial's web interfaces (the <command role=\"hg-cmd\">hg serve</command> "
7464 "command, and the <filename role=\"special\">hgweb.cgi</filename> and "
7465 "<filename role=\"special\">hgwebdir.cgi</filename> scripts) have a number of "
7466 "configuration options that you can set. These belong in a section named "
7467 "<literal role=\"rc-web\">web</literal>."
7468 msgstr ""
7470 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
7471 #: ../en/ch05-collab.xml:1251
7472 msgid ""
7473 "<envar role=\"rc-item-web\">allow_archive</envar>: Determines which (if any) "
7474 "archive download mechanisms Mercurial supports. If you enable this feature, "
7475 "users of the web interface will be able to download an archive of whatever "
7476 "revision of a repository they are viewing. To enable the archive feature, "
7477 "this item must take the form of a sequence of words drawn from the list below."
7478 msgstr ""
7480 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
7481 #: ../en/ch05-collab.xml:1260
7482 msgid ""
7483 "<literal>bz2</literal>: A <command>tar</command> archive, compressed using "
7484 "<literal>bzip2</literal> compression. This has the best compression ratio, "
7485 "but uses the most CPU time on the server."
7486 msgstr ""
7488 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
7489 #: ../en/ch05-collab.xml:1266
7490 msgid ""
7491 "<literal>gz</literal>: A <command>tar</command> archive, compressed using "
7492 "<literal>gzip</literal> compression."
7493 msgstr ""
7495 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
7496 #: ../en/ch05-collab.xml:1270
7497 msgid ""
7498 "<literal>zip</literal>: A <command>zip</command> archive, compressed using "
7499 "LZW compression. This format has the worst compression ratio, but is widely "
7500 "used in the Windows world."
7501 msgstr ""
7503 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
7504 #: ../en/ch05-collab.xml:1276
7505 msgid ""
7506 "If you provide an empty list, or don't have an <envar role=\"rc-item-web"
7507 "\">allow_archive</envar> entry at all, this feature will be disabled. Here "
7508 "is an example of how to enable all three supported formats."
7509 msgstr ""
7511 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
7512 #: ../en/ch05-collab.xml:1283
7513 msgid ""
7514 "<envar role=\"rc-item-web\">allowpull</envar>: Boolean. Determines whether "
7515 "the web interface allows remote users to <command role=\"hg-cmd\">hg pull</"
7516 "command> and <command role=\"hg-cmd\">hg clone</command> this repository over "
7517 "HTTP. If set to <literal>no</literal> or <literal>false</literal>, only the "
7518 "<quote>human-oriented</quote> portion of the web interface is available."
7519 msgstr ""
7521 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
7522 #: ../en/ch05-collab.xml:1292
7523 msgid ""
7524 "<envar role=\"rc-item-web\">contact</envar>: String. A free-form (but "
7525 "preferably brief) string identifying the person or group in charge of the "
7526 "repository. This often contains the name and email address of a person or "
7527 "mailing list. It often makes sense to place this entry in a repository's own "
7528 "<filename role=\"special\">.hg/hgrc</filename> file, but it can make sense to "
7529 "use in a global <filename role=\"special\">~/.hgrc</filename> if every "
7530 "repository has a single maintainer."
7531 msgstr ""
7533 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
7534 #: ../en/ch05-collab.xml:1303
7535 msgid ""
7536 "<envar role=\"rc-item-web\">maxchanges</envar>: Integer. The default maximum "
7537 "number of changesets to display in a single page of output."
7538 msgstr ""
7540 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
7541 #: ../en/ch05-collab.xml:1307
7542 msgid ""
7543 "<envar role=\"rc-item-web\">maxfiles</envar>: Integer. The default maximum "
7544 "number of modified files to display in a single page of output."
7545 msgstr ""
7547 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
7548 #: ../en/ch05-collab.xml:1311
7549 msgid ""
7550 "<envar role=\"rc-item-web\">stripes</envar>: Integer. If the web interface "
7551 "displays alternating <quote>stripes</quote> to make it easier to visually "
7552 "align rows when you are looking at a table, this number controls the number "
7553 "of rows in each stripe."
7554 msgstr ""
7556 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
7557 #: ../en/ch05-collab.xml:1317
7558 msgid ""
7559 "<envar role=\"rc-item-web\">style</envar>: Controls the template Mercurial "
7560 "uses to display the web interface. Mercurial ships with two web templates, "
7561 "named <literal>default</literal> and <literal>gitweb</literal> (the latter is "
7562 "much more visually attractive). You can also specify a custom template of "
7563 "your own; see <xref linkend=\"chap:template\"/> for details. Here, you can "
7564 "see how to enable the <literal>gitweb</literal> style."
7565 msgstr ""
7567 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
7568 #: ../en/ch05-collab.xml:1330
7569 msgid ""
7570 "<envar role=\"rc-item-web\">templates</envar>: Path. The directory in which "
7571 "to search for template files. By default, Mercurial searches in the "
7572 "directory in which it was installed."
7573 msgstr ""
7575 #. type: Content of: <book><chapter><sect1><sect2><para>
7576 #: ../en/ch05-collab.xml:1335
7577 msgid ""
7578 "If you are using <filename role=\"special\">hgwebdir.cgi</filename>, you can "
7579 "place a few configuration items in a <literal role=\"rc-web\">web</literal> "
7580 "section of the <filename role=\"special\">hgweb.config</filename> file "
7581 "instead of a <filename role=\"special\">~/.hgrc</filename> file, for "
7582 "convenience. These items are <envar role=\"rc-item-web\">motd</envar> and "
7583 "<envar role=\"rc-item-web\">style</envar>."
7584 msgstr ""
7586 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
7587 #: ../en/ch05-collab.xml:1346
7588 msgid "Options specific to an individual repository"
7589 msgstr "针对单个版本库的选项"
7591 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7592 #: ../en/ch05-collab.xml:1348
7593 msgid ""
7594 "A few <literal role=\"rc-web\">web</literal> configuration items ought to be "
7595 "placed in a repository's local <filename role=\"special\">.hg/hgrc</"
7596 "filename>, rather than a user's or global <filename role=\"special\">~/.hgrc</"
7597 "filename>."
7598 msgstr ""
7600 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
7601 #: ../en/ch05-collab.xml:1353
7602 msgid ""
7603 "<envar role=\"rc-item-web\">description</envar>: String. A free-form (but "
7604 "preferably brief) string that describes the contents or purpose of the "
7605 "repository."
7606 msgstr ""
7608 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
7609 #: ../en/ch05-collab.xml:1358
7610 msgid ""
7611 "<envar role=\"rc-item-web\">name</envar>: String. The name to use for the "
7612 "repository in the web interface. This overrides the default name, which is "
7613 "the last component of the repository's path."
7614 msgstr ""
7616 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
7617 #: ../en/ch05-collab.xml:1366
7618 msgid ""
7619 "Options specific to the <command role=\"hg-cmd\">hg serve</command> command"
7620 msgstr "命令 <command role=\"hg-cmd\">hg serve</command> 的选项"
7622 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7623 #: ../en/ch05-collab.xml:1369
7624 msgid ""
7625 "Some of the items in the <literal role=\"rc-web\">web</literal> section of a "
7626 "<filename role=\"special\">~/.hgrc</filename> file are only for use with the "
7627 "<command role=\"hg-cmd\">hg serve</command> command."
7628 msgstr ""
7630 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
7631 #: ../en/ch05-collab.xml:1375
7632 msgid ""
7633 "<envar role=\"rc-item-web\">accesslog</envar>: Path. The name of a file into "
7634 "which to write an access log. By default, the <command role=\"hg-cmd\">hg "
7635 "serve</command> command writes this information to standard output, not to a "
7636 "file. Log entries are written in the standard <quote>combined</quote> file "
7637 "format used by almost all web servers."
7638 msgstr ""
7640 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
7641 #: ../en/ch05-collab.xml:1383
7642 msgid ""
7643 "<envar role=\"rc-item-web\">address</envar>: String. The local address on "
7644 "which the server should listen for incoming connections. By default, the "
7645 "server listens on all addresses."
7646 msgstr ""
7648 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
7649 #: ../en/ch05-collab.xml:1388
7650 msgid ""
7651 "<envar role=\"rc-item-web\">errorlog</envar>: Path. The name of a file into "
7652 "which to write an error log. By default, the <command role=\"hg-cmd\">hg "
7653 "serve</command> command writes this information to standard error, not to a "
7654 "file."
7655 msgstr ""
7657 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
7658 #: ../en/ch05-collab.xml:1394
7659 msgid ""
7660 "<envar role=\"rc-item-web\">ipv6</envar>: Boolean. Whether to use the IPv6 "
7661 "protocol. By default, IPv6 is not used."
7662 msgstr ""
7664 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
7665 #: ../en/ch05-collab.xml:1398
7666 msgid ""
7667 "<envar role=\"rc-item-web\">port</envar>: Integer. The TCP port number on "
7668 "which the server should listen. The default port number used is 8000."
7669 msgstr ""
7671 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
7672 #: ../en/ch05-collab.xml:1405
7673 msgid ""
7674 "Choosing the right <filename role=\"special\">~/.hgrc</filename> file to add "
7675 "<literal role=\"rc-web\">web</literal> items to"
7676 msgstr ""
7677 "选择正确的 <filename role=\"special\"> ~/.hgrc</filename> 文件增加到 <literal "
7678 "role=\"rc-web\">web</literal> 条目"
7680 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7681 #: ../en/ch05-collab.xml:1409
7682 msgid ""
7683 "It is important to remember that a web server like Apache or "
7684 "<literal>lighttpd</literal> will run under a user ID that is different to "
7685 "yours. CGI scripts run by your server, such as <filename role=\"special"
7686 "\">hgweb.cgi</filename>, will usually also run under that user ID."
7687 msgstr ""
7689 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7690 #: ../en/ch05-collab.xml:1416
7691 msgid ""
7692 "If you add <literal role=\"rc-web\">web</literal> items to your own personal "
7693 "<filename role=\"special\">~/.hgrc</filename> file, CGI scripts won't read "
7694 "that <filename role=\"special\">~/.hgrc</filename> file. Those settings will "
7695 "thus only affect the behaviour of the <command role=\"hg-cmd\">hg serve</"
7696 "command> command when you run it. To cause CGI scripts to see your settings, "
7697 "either create a <filename role=\"special\">~/.hgrc</filename> file in the "
7698 "home directory of the user ID that runs your web server, or add those "
7699 "settings to a system-wide <filename role=\"special\">~/.hgrc</filename> file."
7700 msgstr ""
7702 #. type: Content of: <book><chapter><title>
7703 #: ../en/ch06-filenames.xml:5
7704 msgid "File names and pattern matching"
7705 msgstr "文件名称与模式匹配"
7707 #. type: Content of: <book><chapter><para>
7708 #: ../en/ch06-filenames.xml:7
7709 msgid ""
7710 "Mercurial provides mechanisms that let you work with file names in a "
7711 "consistent and expressive way."
7712 msgstr ""
7714 #. type: Content of: <book><chapter><sect1><title>
7715 #: ../en/ch06-filenames.xml:11
7716 msgid "Simple file naming"
7717 msgstr "简单文件名称"
7719 #. type: Content of: <book><chapter><sect1><para>
7720 #: ../en/ch06-filenames.xml:13
7721 msgid ""
7722 "Mercurial uses a unified piece of machinery <quote>under the hood</quote> to "
7723 "handle file names. Every command behaves uniformly with respect to file "
7724 "names. The way in which commands work with file names is as follows."
7725 msgstr ""
7727 #. type: Content of: <book><chapter><sect1><para>
7728 #: ../en/ch06-filenames.xml:18
7729 msgid ""
7730 "If you explicitly name real files on the command line, Mercurial works with "
7731 "exactly those files, as you would expect. &interaction.filenames.files;"
7732 msgstr ""
7735 #. type: Content of: <book><chapter><sect1><para>
7736 #: ../en/ch06-filenames.xml:22
7737 msgid ""
7738 "When you provide a directory name, Mercurial will interpret this as "
7739 "<quote>operate on every file in this directory and its subdirectories</"
7740 "quote>. Mercurial traverses the files and subdirectories in a directory in "
7741 "alphabetical order. When it encounters a subdirectory, it will traverse that "
7742 "subdirectory before continuing with the current directory."
7743 msgstr ""
7745 #. type: Content of: <book><chapter><sect1><title>
7746 #: ../en/ch06-filenames.xml:33
7747 msgid "Running commands without any file names"
7748 msgstr "不提供文件名称的执行命令"
7750 #. type: Content of: <book><chapter><sect1><para>
7751 #: ../en/ch06-filenames.xml:35
7752 msgid ""
7753 "Mercurial's commands that work with file names have useful default behaviours "
7754 "when you invoke them without providing any file names or patterns. What kind "
7755 "of behaviour you should expect depends on what the command does. Here are a "
7756 "few rules of thumb you can use to predict what a command is likely to do if "
7757 "you don't give it any names to work with."
7758 msgstr ""
7760 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
7761 #: ../en/ch06-filenames.xml:42
7762 msgid ""
7763 "Most commands will operate on the entire working directory. This is what the "
7764 "<command role=\"hg-cmd\">hg add</command> command does, for example."
7765 msgstr ""
7767 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
7768 #: ../en/ch06-filenames.xml:46
7769 msgid ""
7770 "If the command has effects that are difficult or impossible to reverse, it "
7771 "will force you to explicitly provide at least one name or pattern (see "
7772 "below). This protects you from accidentally deleting files by running "
7773 "<command role=\"hg-cmd\">hg remove</command> with no arguments, for example."
7774 msgstr ""
7777 #. type: Content of: <book><chapter><sect1><para>
7778 #: ../en/ch06-filenames.xml:54
7779 msgid ""
7780 "It's easy to work around these default behaviours if they don't suit you. If "
7781 "a command normally operates on the whole working directory, you can invoke it "
7782 "on just the current directory and its subdirectories by giving it the name "
7783 "<quote><filename class=\"directory\">.</filename></quote>."
7784 msgstr ""
7787 #. type: Content of: <book><chapter><sect1><para>
7788 #: ../en/ch06-filenames.xml:62
7789 msgid ""
7790 "Along the same lines, some commands normally print file names relative to the "
7791 "root of the repository, even if you're invoking them from a subdirectory. "
7792 "Such a command will print file names relative to your subdirectory if you "
7793 "give it explicit names. Here, we're going to run <command role=\"hg-cmd\">hg "
7794 "status</command> from a subdirectory, and get it to operate on the entire "
7795 "working directory while printing file names relative to our subdirectory, by "
7796 "passing it the output of the <command role=\"hg-cmd\">hg root</command> "
7797 "command."
7798 msgstr ""
7800 #. type: Content of: <book><chapter><sect1><title>
7801 #: ../en/ch06-filenames.xml:76
7802 msgid "Telling you what's going on"
7803 msgstr "告诉你正在做什么"
7805 #. type: Content of: <book><chapter><sect1><para>
7806 #: ../en/ch06-filenames.xml:78
7807 msgid ""
7808 "The <command role=\"hg-cmd\">hg add</command> example in the preceding "
7809 "section illustrates something else that's helpful about Mercurial commands. "
7810 "If a command operates on a file that you didn't name explicitly on the "
7811 "command line, it will usually print the name of the file, so that you will "
7812 "not be surprised what's going on."
7813 msgstr ""
7815 #. type: Content of: <book><chapter><sect1><para>
7816 #: ../en/ch06-filenames.xml:85
7817 msgid ""
7818 "The principle here is of <emphasis>least surprise</emphasis>. If you've "
7819 "exactly named a file on the command line, there's no point in repeating it "
7820 "back at you. If Mercurial is acting on a file <emphasis>implicitly</"
7821 "emphasis>, because you provided no names, or a directory, or a pattern (see "
7822 "below), it's safest to tell you what it's doing."
7823 msgstr ""
7825 #. type: Content of: <book><chapter><sect1><para>
7826 #: ../en/ch06-filenames.xml:92
7827 msgid ""
7828 "For commands that behave this way, you can silence them using the <option "
7829 "role=\"hg-opt-global\">-q</option> option. You can also get them to print "
7830 "the name of every file, even those you've named explicitly, using the <option "
7831 "role=\"hg-opt-global\">-v</option> option."
7832 msgstr ""
7834 #. type: Content of: <book><chapter><sect1><title>
7835 #: ../en/ch06-filenames.xml:100
7836 msgid "Using patterns to identify files"
7837 msgstr "使用模式标识文件"
7839 #. type: Content of: <book><chapter><sect1><para>
7840 #: ../en/ch06-filenames.xml:102
7841 msgid ""
7842 "In addition to working with file and directory names, Mercurial lets you use "
7843 "<emphasis>patterns</emphasis> to identify files. Mercurial's pattern "
7844 "handling is expressive."
7845 msgstr ""
7847 #. type: Content of: <book><chapter><sect1><para>
7848 #: ../en/ch06-filenames.xml:106
7849 msgid ""
7850 "On Unix-like systems (Linux, MacOS, etc.), the job of matching file names to "
7851 "patterns normally falls to the shell. On these systems, you must explicitly "
7852 "tell Mercurial that a name is a pattern. On Windows, the shell does not "
7853 "expand patterns, so Mercurial will automatically identify names that are "
7854 "patterns, and expand them for you."
7855 msgstr ""
7857 #. type: Content of: <book><chapter><sect1><para>
7858 #: ../en/ch06-filenames.xml:113
7859 msgid ""
7860 "To provide a pattern in place of a regular name on the command line, the "
7861 "mechanism is simple:"
7862 msgstr ""
7864 #. type: Content of: <book><chapter><sect1><para>
7865 #: ../en/ch06-filenames.xml:116
7866 msgid ""
7867 "That is, a pattern is identified by a short text string that says what kind "
7868 "of pattern this is, followed by a colon, followed by the actual pattern."
7869 msgstr ""
7871 #. type: Content of: <book><chapter><sect1><para>
7872 #: ../en/ch06-filenames.xml:120
7873 msgid ""
7874 "Mercurial supports two kinds of pattern syntax. The most frequently used is "
7875 "called <literal>glob</literal>; this is the same kind of pattern matching "
7876 "used by the Unix shell, and should be familiar to Windows command prompt "
7877 "users, too."
7878 msgstr ""
7880 #. type: Content of: <book><chapter><sect1><para>
7881 #: ../en/ch06-filenames.xml:125
7882 msgid ""
7883 "When Mercurial does automatic pattern matching on Windows, it uses "
7884 "<literal>glob</literal> syntax. You can thus omit the <quote><literal>glob:</"
7885 "literal></quote> prefix on Windows, but it's safe to use it, too."
7886 msgstr ""
7888 #. type: Content of: <book><chapter><sect1><para>
7889 #: ../en/ch06-filenames.xml:130
7890 msgid ""
7891 "The <literal>re</literal> syntax is more powerful; it lets you specify "
7892 "patterns using regular expressions, also known as regexps."
7893 msgstr ""
7895 #. type: Content of: <book><chapter><sect1><para>
7896 #: ../en/ch06-filenames.xml:134
7897 msgid ""
7898 "By the way, in the examples that follow, notice that I'm careful to wrap all "
7899 "of my patterns in quote characters, so that they won't get expanded by the "
7900 "shell before Mercurial sees them."
7901 msgstr ""
7903 #. type: Content of: <book><chapter><sect1><sect2><title>
7904 #: ../en/ch06-filenames.xml:140
7905 msgid "Shell-style <literal>glob</literal> patterns"
7906 msgstr "外壳风格的 <literal>glob</literal> 模式"
7908 #. type: Content of: <book><chapter><sect1><sect2><para>
7909 #: ../en/ch06-filenames.xml:142
7910 msgid ""
7911 "This is an overview of the kinds of patterns you can use when you're matching "
7912 "on glob patterns."
7913 msgstr ""
7916 #. type: Content of: <book><chapter><sect1><sect2><para>
7917 #: ../en/ch06-filenames.xml:145
7918 msgid ""
7919 "The <quote><literal>*</literal></quote> character matches any string, within "
7920 "a single directory."
7921 msgstr ""
7924 #. type: Content of: <book><chapter><sect1><sect2><para>
7925 #: ../en/ch06-filenames.xml:150
7926 msgid ""
7927 "The <quote><literal>**</literal></quote> pattern matches any string, and "
7928 "crosses directory boundaries. It's not a standard Unix glob token, but it's "
7929 "accepted by several popular Unix shells, and is very useful."
7930 msgstr ""
7933 #. type: Content of: <book><chapter><sect1><sect2><para>
7934 #: ../en/ch06-filenames.xml:157
7935 msgid ""
7936 "The <quote><literal>?</literal></quote> pattern matches any single character."
7937 msgstr ""
7939 #. type: Content of: <book><chapter><sect1><sect2><para>
7940 #: ../en/ch06-filenames.xml:162
7941 msgid ""
7942 "The <quote><literal>[</literal></quote> character begins a "
7943 "<emphasis>character class</emphasis>. This matches any single character "
7944 "within the class. The class ends with a <quote><literal>]</literal></quote> "
7945 "character. A class may contain multiple <emphasis>range</emphasis>s of the "
7946 "form <quote><literal>a-f</literal></quote>, which is shorthand for "
7947 "<quote><literal>abcdef</literal></quote>."
7948 msgstr ""
7950 #. type: Content of: <book><chapter><sect1><sect2><para>
7951 #: ../en/ch06-filenames.xml:172
7952 msgid ""
7953 "If the first character after the <quote><literal>[</literal></quote> in a "
7954 "character class is a <quote><literal>!</literal></quote>, it "
7955 "<emphasis>negates</emphasis> the class, making it match any single character "
7956 "not in the class."
7957 msgstr ""
7959 #. type: Content of: <book><chapter><sect1><sect2><para>
7960 #: ../en/ch06-filenames.xml:178
7961 msgid ""
7962 "A <quote><literal>{</literal></quote> begins a group of subpatterns, where "
7963 "the whole group matches if any subpattern in the group matches. The "
7964 "<quote><literal>,</literal></quote> character separates subpatterns, and "
7965 "<quote><literal>}</literal></quote> ends the group."
7966 msgstr ""
7968 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
7969 #: ../en/ch06-filenames.xml:187
7970 msgid "Watch out!"
7971 msgstr "千万小心!"
7974 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7975 #: ../en/ch06-filenames.xml:189
7976 msgid ""
7977 "Don't forget that if you want to match a pattern in any directory, you should "
7978 "not be using the <quote><literal>*</literal></quote> match-any token, as this "
7979 "will only match within one directory. Instead, use the <quote><literal>**</"
7980 "literal></quote> token. This small example illustrates the difference "
7981 "between the two."
7982 msgstr ""
7984 #. type: Content of: <book><chapter><sect1><sect2><title>
7985 #: ../en/ch06-filenames.xml:201
7986 msgid "Regular expression matching with <literal>re</literal> patterns"
7987 msgstr "使用 <literal>re</literal> 模式的正则表达式匹配"
7989 #. type: Content of: <book><chapter><sect1><sect2><para>
7990 #: ../en/ch06-filenames.xml:204
7991 msgid ""
7992 "Mercurial accepts the same regular expression syntax as the Python "
7993 "programming language (it uses Python's regexp engine internally). This is "
7994 "based on the Perl language's regexp syntax, which is the most popular dialect "
7995 "in use (it's also used in Java, for example)."
7996 msgstr ""
7998 #. type: Content of: <book><chapter><sect1><sect2><para>
7999 #: ../en/ch06-filenames.xml:210
8000 msgid ""
8001 "I won't discuss Mercurial's regexp dialect in any detail here, as regexps are "
8002 "not often used. Perl-style regexps are in any case already exhaustively "
8003 "documented on a multitude of web sites, and in many books. Instead, I will "
8004 "focus here on a few things you should know if you find yourself needing to "
8005 "use regexps with Mercurial."
8006 msgstr ""
8008 #. type: Content of: <book><chapter><sect1><sect2><para>
8009 #: ../en/ch06-filenames.xml:217
8010 msgid ""
8011 "A regexp is matched against an entire file name, relative to the root of the "
8012 "repository. In other words, even if you're already in subbdirectory "
8013 "<filename class=\"directory\">foo</filename>, if you want to match files "
8014 "under this directory, your pattern must start with <quote><literal>foo/</"
8015 "literal></quote>."
8016 msgstr ""
8018 #. type: Content of: <book><chapter><sect1><sect2><para>
8019 #: ../en/ch06-filenames.xml:224
8020 msgid ""
8021 "One thing to note, if you're familiar with Perl-style regexps, is that "
8022 "Mercurial's are <emphasis>rooted</emphasis>. That is, a regexp starts "
8023 "matching against the beginning of a string; it doesn't look for a match "
8024 "anywhere within the string. To match anywhere in a string, start your "
8025 "pattern with <quote><literal>.*</literal></quote>."
8026 msgstr ""
8028 #. type: Content of: <book><chapter><sect1><title>
8029 #: ../en/ch06-filenames.xml:234
8030 msgid "Filtering files"
8031 msgstr "过滤文件"
8033 #. type: Content of: <book><chapter><sect1><para>
8034 #: ../en/ch06-filenames.xml:236
8035 msgid ""
8036 "Not only does Mercurial give you a variety of ways to specify files; it lets "
8037 "you further winnow those files using <emphasis>filters</emphasis>. Commands "
8038 "that work with file names accept two filtering options."
8039 msgstr ""
8041 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8042 #: ../en/ch06-filenames.xml:241
8043 msgid ""
8044 "<option role=\"hg-opt-global\">-I</option>, or <option role=\"hg-opt-global"
8045 "\">--include</option>, lets you specify a pattern that file names must match "
8046 "in order to be processed."
8047 msgstr ""
8049 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8050 #: ../en/ch06-filenames.xml:246
8051 msgid ""
8052 "<option role=\"hg-opt-global\">-X</option>, or <option role=\"hg-opt-global"
8053 "\">--exclude</option>, gives you a way to <emphasis>avoid</emphasis> "
8054 "processing files, if they match this pattern."
8055 msgstr ""
8057 #. type: Content of: <book><chapter><sect1><para>
8058 #: ../en/ch06-filenames.xml:251
8059 msgid ""
8060 "You can provide multiple <option role=\"hg-opt-global\">-I</option> and "
8061 "<option role=\"hg-opt-global\">-X</option> options on the command line, and "
8062 "intermix them as you please. Mercurial interprets the patterns you provide "
8063 "using glob syntax by default (but you can use regexps if you need to)."
8064 msgstr ""
8066 #. type: Content of: <book><chapter><sect1><para>
8067 #: ../en/ch06-filenames.xml:258
8068 msgid ""
8069 "You can read a <option role=\"hg-opt-global\">-I</option> filter as "
8070 "<quote>process only the files that match this filter</quote>."
8071 msgstr ""
8073 #. type: Content of: <book><chapter><sect1><para>
8074 #: ../en/ch06-filenames.xml:264
8075 msgid ""
8076 "The <option role=\"hg-opt-global\">-X</option> filter is best read as "
8077 "<quote>process only the files that don't match this pattern</quote>."
8078 msgstr ""
8080 #. type: Content of: <book><chapter><sect1><title>
8081 #: ../en/ch06-filenames.xml:272
8082 msgid "Ignoring unwanted files and directories"
8083 msgstr "忽略不需要的文件和目录"
8085 #. type: Content of: <book><chapter><sect1><para>
8086 #: ../en/ch06-filenames.xml:274
8087 msgid "XXX."
8088 msgstr ""
8090 #. type: Content of: <book><chapter><sect1><title>
8091 #: ../en/ch06-filenames.xml:278
8092 msgid "Case sensitivity"
8093 msgstr "大小写敏感性"
8095 #. type: Content of: <book><chapter><sect1><para>
8096 #: ../en/ch06-filenames.xml:280
8097 msgid ""
8098 "If you're working in a mixed development environment that contains both Linux "
8099 "(or other Unix) systems and Macs or Windows systems, you should keep in the "
8100 "back of your mind the knowledge that they treat the case (<quote>N</quote> "
8101 "versus <quote>n</quote>) of file names in incompatible ways. This is not "
8102 "very likely to affect you, and it's easy to deal with if it does, but it "
8103 "could surprise you if you don't know about it."
8104 msgstr ""
8106 #. type: Content of: <book><chapter><sect1><para>
8107 #: ../en/ch06-filenames.xml:289
8108 msgid ""
8109 "Operating systems and filesystems differ in the way they handle the "
8110 "<emphasis>case</emphasis> of characters in file and directory names. There "
8111 "are three common ways to handle case in names."
8112 msgstr ""
8114 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8115 #: ../en/ch06-filenames.xml:294
8116 msgid ""
8117 "Completely case insensitive. Uppercase and lowercase versions of a letter "
8118 "are treated as identical, both when creating a file and during subsequent "
8119 "accesses. This is common on older DOS-based systems."
8120 msgstr ""
8122 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8123 #: ../en/ch06-filenames.xml:299
8124 msgid ""
8125 "Case preserving, but insensitive. When a file or directory is created, the "
8126 "case of its name is stored, and can be retrieved and displayed by the "
8127 "operating system. When an existing file is being looked up, its case is "
8128 "ignored. This is the standard arrangement on Windows and MacOS. The names "
8129 "<filename>foo</filename> and <filename>FoO</filename> identify the same "
8130 "file. This treatment of uppercase and lowercase letters as interchangeable "
8131 "is also referred to as <emphasis>case folding</emphasis>."
8132 msgstr ""
8134 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8135 #: ../en/ch06-filenames.xml:310
8136 msgid ""
8137 "Case sensitive. The case of a name is significant at all times. The names "
8138 "<filename>foo</filename> and {FoO} identify different files. This is the way "
8139 "Linux and Unix systems normally work."
8140 msgstr ""
8142 #. type: Content of: <book><chapter><sect1><para>
8143 #: ../en/ch06-filenames.xml:316
8144 msgid ""
8145 "On Unix-like systems, it is possible to have any or all of the above ways of "
8146 "handling case in action at once. For example, if you use a USB thumb drive "
8147 "formatted with a FAT32 filesystem on a Linux system, Linux will handle names "
8148 "on that filesystem in a case preserving, but insensitive, way."
8149 msgstr ""
8151 #. type: Content of: <book><chapter><sect1><sect2><title>
8152 #: ../en/ch06-filenames.xml:323
8153 msgid "Safe, portable repository storage"
8154 msgstr "安全,可移植的版本库存储"
8156 #. type: Content of: <book><chapter><sect1><sect2><para>
8157 #: ../en/ch06-filenames.xml:325
8158 msgid ""
8159 "Mercurial's repository storage mechanism is <emphasis>case safe</emphasis>. "
8160 "It translates file names so that they can be safely stored on both case "
8161 "sensitive and case insensitive filesystems. This means that you can use "
8162 "normal file copying tools to transfer a Mercurial repository onto, for "
8163 "example, a USB thumb drive, and safely move that drive and repository back "
8164 "and forth between a Mac, a PC running Windows, and a Linux box."
8165 msgstr ""
8167 #. type: Content of: <book><chapter><sect1><sect2><title>
8168 #: ../en/ch06-filenames.xml:336
8169 msgid "Detecting case conflicts"
8170 msgstr "检测大小写冲突"
8172 #. type: Content of: <book><chapter><sect1><sect2><para>
8173 #: ../en/ch06-filenames.xml:338
8174 msgid ""
8175 "When operating in the working directory, Mercurial honours the naming policy "
8176 "of the filesystem where the working directory is located. If the filesystem "
8177 "is case preserving, but insensitive, Mercurial will treat names that differ "
8178 "only in case as the same."
8179 msgstr ""
8181 #. type: Content of: <book><chapter><sect1><sect2><para>
8182 #: ../en/ch06-filenames.xml:344
8183 msgid ""
8184 "An important aspect of this approach is that it is possible to commit a "
8185 "changeset on a case sensitive (typically Linux or Unix) filesystem that will "
8186 "cause trouble for users on case insensitive (usually Windows and MacOS) "
8187 "users. If a Linux user commits changes to two files, one named "
8188 "<filename>myfile.c</filename> and the other named <filename>MyFile.C</"
8189 "filename>, they will be stored correctly in the repository. And in the "
8190 "working directories of other Linux users, they will be correctly represented "
8191 "as separate files."
8192 msgstr ""
8194 #. type: Content of: <book><chapter><sect1><sect2><para>
8195 #: ../en/ch06-filenames.xml:355
8196 msgid ""
8197 "If a Windows or Mac user pulls this change, they will not initially have a "
8198 "problem, because Mercurial's repository storage mechanism is case safe. "
8199 "However, once they try to <command role=\"hg-cmd\">hg update</command> the "
8200 "working directory to that changeset, or <command role=\"hg-cmd\">hg merge</"
8201 "command> with that changeset, Mercurial will spot the conflict between the "
8202 "two file names that the filesystem would treat as the same, and forbid the "
8203 "update or merge from occurring."
8204 msgstr ""
8206 #. type: Content of: <book><chapter><sect1><sect2><title>
8207 #: ../en/ch06-filenames.xml:367
8208 msgid "Fixing a case conflict"
8209 msgstr "修正大小写冲突"
8211 #. type: Content of: <book><chapter><sect1><sect2><para>
8212 #: ../en/ch06-filenames.xml:369
8213 msgid ""
8214 "If you are using Windows or a Mac in a mixed environment where some of your "
8215 "collaborators are using Linux or Unix, and Mercurial reports a case folding "
8216 "conflict when you try to <command role=\"hg-cmd\">hg update</command> or "
8217 "<command role=\"hg-cmd\">hg merge</command>, the procedure to fix the problem "
8218 "is simple."
8219 msgstr ""
8221 #. type: Content of: <book><chapter><sect1><sect2><para>
8222 #: ../en/ch06-filenames.xml:376
8223 msgid ""
8224 "Just find a nearby Linux or Unix box, clone the problem repository onto it, "
8225 "and use Mercurial's <command role=\"hg-cmd\">hg rename</command> command to "
8226 "change the names of any offending files or directories so that they will no "
8227 "longer cause case folding conflicts. Commit this change, <command role=\"hg-"
8228 "cmd\">hg pull</command> or <command role=\"hg-cmd\">hg push</command> it "
8229 "across to your Windows or MacOS system, and <command role=\"hg-cmd\">hg "
8230 "update</command> to the revision with the non-conflicting names."
8231 msgstr ""
8233 #. type: Content of: <book><chapter><sect1><sect2><para>
8234 #: ../en/ch06-filenames.xml:386
8235 msgid ""
8236 "The changeset with case-conflicting names will remain in your project's "
8237 "history, and you still won't be able to <command role=\"hg-cmd\">hg update</"
8238 "command> your working directory to that changeset on a Windows or MacOS "
8239 "system, but you can continue development unimpeded."
8240 msgstr ""
8242 #. type: Content of: <book><chapter><sect1><sect2><note><para>
8243 #: ../en/ch06-filenames.xml:393
8244 msgid ""
8245 "Prior to version 0.9.3, Mercurial did not use a case safe repository storage "
8246 "mechanism, and did not detect case folding conflicts. If you are using an "
8247 "older version of Mercurial on Windows or MacOS, I strongly recommend that you "
8248 "upgrade."
8249 msgstr ""
8251 #. type: Content of: <book><chapter><title>
8252 #: ../en/ch07-branch.xml:5
8253 msgid "Managing releases and branchy development"
8254 msgstr "发布管理与分支开发"
8256 #. type: Content of: <book><chapter><para>
8257 #: ../en/ch07-branch.xml:7
8258 msgid ""
8259 "Mercurial provides several mechanisms for you to manage a project that is "
8260 "making progress on multiple fronts at once. To understand these mechanisms, "
8261 "let's first take a brief look at a fairly normal software project structure."
8262 msgstr ""
8264 #. type: Content of: <book><chapter><para>
8265 #: ../en/ch07-branch.xml:12
8266 msgid ""
8267 "Many software projects issue periodic <quote>major</quote> releases that "
8268 "contain substantial new features. In parallel, they may issue <quote>minor</"
8269 "quote> releases. These are usually identical to the major releases off which "
8270 "they're based, but with a few bugs fixed."
8271 msgstr ""
8273 #. type: Content of: <book><chapter><para>
8274 #: ../en/ch07-branch.xml:18
8275 msgid ""
8276 "In this chapter, we'll start by talking about how to keep records of project "
8277 "milestones such as releases. We'll then continue on to talk about the flow "
8278 "of work between different phases of a project, and how Mercurial can help you "
8279 "to isolate and manage this work."
8280 msgstr ""
8282 #. type: Content of: <book><chapter><sect1><title>
8283 #: ../en/ch07-branch.xml:25
8284 msgid "Giving a persistent name to a revision"
8285 msgstr "给版本指定一个永久的名称"
8287 #. type: Content of: <book><chapter><sect1><para>
8288 #: ../en/ch07-branch.xml:27
8289 msgid ""
8290 "Once you decide that you'd like to call a particular revision a "
8291 "<quote>release</quote>, it's a good idea to record the identity of that "
8292 "revision. This will let you reproduce that release at a later date, for "
8293 "whatever purpose you might need at the time (reproducing a bug, porting to a "
8294 "new platform, etc). &interaction.tag.init;"
8295 msgstr ""
8298 #. type: Content of: <book><chapter><sect1><para>
8299 #: ../en/ch07-branch.xml:34
8300 msgid ""
8301 "Mercurial lets you give a permanent name to any revision using the <command "
8302 "role=\"hg-cmd\">hg tag</command> command. Not surprisingly, these names are "
8303 "called <quote>tags</quote>."
8304 msgstr ""
8306 #. type: Content of: <book><chapter><sect1><para>
8307 #: ../en/ch07-branch.xml:40
8308 msgid ""
8309 "A tag is nothing more than a <quote>symbolic name</quote> for a revision. "
8310 "Tags exist purely for your convenience, so that you have a handy permanent "
8311 "way to refer to a revision; Mercurial doesn't interpret the tag names you use "
8312 "in any way. Neither does Mercurial place any restrictions on the name of a "
8313 "tag, beyond a few that are necessary to ensure that a tag can be parsed "
8314 "unambiguously. A tag name cannot contain any of the following characters:"
8315 msgstr ""
8317 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8318 #: ../en/ch07-branch.xml:49
8319 msgid "Colon (ASCII 58, <quote><literal>:</literal></quote>)"
8320 msgstr ""
8322 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8323 #: ../en/ch07-branch.xml:52
8324 msgid "Carriage return (ASCII 13, <quote><literal>\\r</literal></quote>)"
8325 msgstr ""
8327 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8328 #: ../en/ch07-branch.xml:55
8329 msgid "Newline (ASCII 10, <quote><literal>\\n</literal></quote>)"
8330 msgstr ""
8332 #. type: Content of: <book><chapter><sect1><para>
8333 #: ../en/ch07-branch.xml:59
8334 msgid ""
8335 "You can use the <command role=\"hg-cmd\">hg tags</command> command to display "
8336 "the tags present in your repository. In the output, each tagged revision is "
8337 "identified first by its name, then by revision number, and finally by the "
8338 "unique hash of the revision."
8339 msgstr ""
8341 #. type: Content of: <book><chapter><sect1><para>
8342 #: ../en/ch07-branch.xml:67
8343 msgid ""
8344 "Notice that <literal>tip</literal> is listed in the output of <command role="
8345 "\"hg-cmd\">hg tags</command>. The <literal>tip</literal> tag is a special "
8346 "<quote>floating</quote> tag, which always identifies the newest revision in "
8347 "the repository."
8348 msgstr ""
8350 #. type: Content of: <book><chapter><sect1><para>
8351 #: ../en/ch07-branch.xml:73
8352 msgid ""
8353 "In the output of the <command role=\"hg-cmd\">hg tags</command> command, tags "
8354 "are listed in reverse order, by revision number. This usually means that "
8355 "recent tags are listed before older tags. It also means that <literal>tip</"
8356 "literal> is always going to be the first tag listed in the output of <command "
8357 "role=\"hg-cmd\">hg tags</command>."
8358 msgstr ""
8360 #. type: Content of: <book><chapter><sect1><para>
8361 #: ../en/ch07-branch.xml:80
8362 msgid ""
8363 "When you run <command role=\"hg-cmd\">hg log</command>, if it displays a "
8364 "revision that has tags associated with it, it will print those tags."
8365 msgstr ""
8368 #. type: Content of: <book><chapter><sect1><para>
8369 #: ../en/ch07-branch.xml:86
8370 msgid ""
8371 "Any time you need to provide a revision ID to a Mercurial command, the "
8372 "command will accept a tag name in its place. Internally, Mercurial will "
8373 "translate your tag name into the corresponding revision ID, then use that."
8374 msgstr ""
8376 #. type: Content of: <book><chapter><sect1><para>
8377 #: ../en/ch07-branch.xml:93
8378 msgid ""
8379 "There's no limit on the number of tags you can have in a repository, or on "
8380 "the number of tags that a single revision can have. As a practical matter, "
8381 "it's not a great idea to have <quote>too many</quote> (a number which will "
8382 "vary from project to project), simply because tags are supposed to help you "
8383 "to find revisions. If you have lots of tags, the ease of using them to "
8384 "identify revisions diminishes rapidly."
8385 msgstr ""
8387 #. type: Content of: <book><chapter><sect1><para>
8388 #: ../en/ch07-branch.xml:101
8389 msgid ""
8390 "For example, if your project has milestones as frequent as every few days, "
8391 "it's perfectly reasonable to tag each one of those. But if you have a "
8392 "continuous build system that makes sure every revision can be built cleanly, "
8393 "you'd be introducing a lot of noise if you were to tag every clean build. "
8394 "Instead, you could tag failed builds (on the assumption that they're rare!), "
8395 "or simply not use tags to track buildability."
8396 msgstr ""
8398 #. type: Content of: <book><chapter><sect1><para>
8399 #: ../en/ch07-branch.xml:109
8400 msgid ""
8401 "If you want to remove a tag that you no longer want, use <command role=\"hg-"
8402 "cmd\">hg tag --remove</command>."
8403 msgstr ""
8405 #. type: Content of: <book><chapter><sect1><para>
8406 #: ../en/ch07-branch.xml:114
8407 msgid ""
8408 "You can also modify a tag at any time, so that it identifies a different "
8409 "revision, by simply issuing a new <command role=\"hg-cmd\">hg tag</command> "
8410 "command. You'll have to use the <option role=\"hg-opt-tag\">-f</option> "
8411 "option to tell Mercurial that you <emphasis>really</emphasis> want to update "
8412 "the tag."
8413 msgstr ""
8415 #. type: Content of: <book><chapter><sect1><para>
8416 #: ../en/ch07-branch.xml:123
8417 msgid ""
8418 "There will still be a permanent record of the previous identity of the tag, "
8419 "but Mercurial will no longer use it. There's thus no penalty to tagging the "
8420 "wrong revision; all you have to do is turn around and tag the correct "
8421 "revision once you discover your error."
8422 msgstr ""
8425 #. type: Content of: <book><chapter><sect1><para>
8426 #: ../en/ch07-branch.xml:129
8427 msgid ""
8428 "Mercurial stores tags in a normal revision-controlled file in your "
8429 "repository. If you've created any tags, you'll find them in a file named "
8430 "<filename role=\"special\">.hgtags</filename>. When you run the <command "
8431 "role=\"hg-cmd\">hg tag</command> command, Mercurial modifies this file, then "
8432 "automatically commits the change to it. This means that every time you run "
8433 "<command role=\"hg-cmd\">hg tag</command>, you'll see a corresponding "
8434 "changeset in the output of <command role=\"hg-cmd\">hg log</command>."
8435 msgstr ""
8437 #. type: Content of: <book><chapter><sect1><sect2><title>
8438 #: ../en/ch07-branch.xml:142
8439 msgid "Handling tag conflicts during a merge"
8440 msgstr "在合并期间处理标签冲突"
8442 #. type: Content of: <book><chapter><sect1><sect2><para>
8443 #: ../en/ch07-branch.xml:144
8444 msgid ""
8445 "You won't often need to care about the <filename role=\"special\">.hgtags</"
8446 "filename> file, but it sometimes makes its presence known during a merge. "
8447 "The format of the file is simple: it consists of a series of lines. Each "
8448 "line starts with a changeset hash, followed by a space, followed by the name "
8449 "of a tag."
8450 msgstr ""
8452 #. type: Content of: <book><chapter><sect1><sect2><para>
8453 #: ../en/ch07-branch.xml:151
8454 msgid ""
8455 "If you're resolving a conflict in the <filename role=\"special\">.hgtags</"
8456 "filename> file during a merge, there's one twist to modifying the <filename "
8457 "role=\"special\">.hgtags</filename> file: when Mercurial is parsing the tags "
8458 "in a repository, it <emphasis>never</emphasis> reads the working copy of the "
8459 "<filename role=\"special\">.hgtags</filename> file. Instead, it reads the "
8460 "<emphasis>most recently committed</emphasis> revision of the file."
8461 msgstr ""
8463 #. type: Content of: <book><chapter><sect1><sect2><para>
8464 #: ../en/ch07-branch.xml:161
8465 msgid ""
8466 "An unfortunate consequence of this design is that you can't actually verify "
8467 "that your merged <filename role=\"special\">.hgtags</filename> file is "
8468 "correct until <emphasis>after</emphasis> you've committed a change. So if "
8469 "you find yourself resolving a conflict on <filename role=\"special\">.hgtags</"
8470 "filename> during a merge, be sure to run <command role=\"hg-cmd\">hg tags</"
8471 "command> after you commit. If it finds an error in the <filename role="
8472 "\"special\">.hgtags</filename> file, it will report the location of the "
8473 "error, which you can then fix and commit. You should then run <command role="
8474 "\"hg-cmd\">hg tags</command> again, just to be sure that your fix is correct."
8475 msgstr ""
8477 #. type: Content of: <book><chapter><sect1><sect2><title>
8478 #: ../en/ch07-branch.xml:176
8479 msgid "Tags and cloning"
8480 msgstr "标签与克隆"
8482 #. type: Content of: <book><chapter><sect1><sect2><para>
8483 #: ../en/ch07-branch.xml:178
8484 msgid ""
8485 "You may have noticed that the <command role=\"hg-cmd\">hg clone</command> "
8486 "command has a <option role=\"hg-opt-clone\">-r</option> option that lets you "
8487 "clone an exact copy of the repository as of a particular changeset. The new "
8488 "clone will not contain any project history that comes after the revision you "
8489 "specified. This has an interaction with tags that can surprise the unwary."
8490 msgstr ""
8492 #. type: Content of: <book><chapter><sect1><sect2><para>
8493 #: ../en/ch07-branch.xml:186
8494 msgid ""
8495 "Recall that a tag is stored as a revision to the <filename role=\"special\">."
8496 "hgtags</filename> file, so that when you create a tag, the changeset in which "
8497 "it's recorded necessarily refers to an older changeset. When you run "
8498 "<command role=\"hg-cmd\">hg clone -r foo</command> to clone a repository as "
8499 "of tag <literal>foo</literal>, the new clone <emphasis>will not contain the "
8500 "history that created the tag</emphasis> that you used to clone the "
8501 "repository. The result is that you'll get exactly the right subset of the "
8502 "project's history in the new repository, but <emphasis>not</emphasis> the tag "
8503 "you might have expected."
8504 msgstr ""
8506 #. type: Content of: <book><chapter><sect1><sect2><title>
8507 #: ../en/ch07-branch.xml:201
8508 msgid "When permanent tags are too much"
8509 msgstr "当永久标签太多的时候"
8511 #. type: Content of: <book><chapter><sect1><sect2><para>
8512 #: ../en/ch07-branch.xml:203
8513 msgid ""
8514 "Since Mercurial's tags are revision controlled and carried around with a "
8515 "project's history, everyone you work with will see the tags you create. But "
8516 "giving names to revisions has uses beyond simply noting that revision "
8517 "<literal>4237e45506ee</literal> is really <literal>v2.0.2</literal>. If "
8518 "you're trying to track down a subtle bug, you might want a tag to remind you "
8519 "of something like <quote>Anne saw the symptoms with this revision</quote>."
8520 msgstr ""
8522 #. type: Content of: <book><chapter><sect1><sect2><para>
8523 #: ../en/ch07-branch.xml:213
8524 msgid ""
8525 "For cases like this, what you might want to use are <emphasis>local</"
8526 "emphasis> tags. You can create a local tag with the <option role=\"hg-opt-tag"
8527 "\">-l</option> option to the <command role=\"hg-cmd\">hg tag</command> "
8528 "command. This will store the tag in a file called <filename role=\"special"
8529 "\">.hg/localtags</filename>. Unlike <filename role=\"special\">.hgtags</"
8530 "filename>, <filename role=\"special\">.hg/localtags</filename> is not "
8531 "revision controlled. Any tags you create using <option role=\"hg-opt-tag\">-"
8532 "l</option> remain strictly local to the repository you're currently working "
8533 "in."
8534 msgstr ""
8536 #. type: Content of: <book><chapter><sect1><title>
8537 #: ../en/ch07-branch.xml:228
8538 msgid "The flow of changes&emdash;big picture vs. little"
8539 msgstr "修改流程&emdash;宏观与微观"
8541 #. type: Content of: <book><chapter><sect1><para>
8542 #: ../en/ch07-branch.xml:230
8543 msgid ""
8544 "To return to the outline I sketched at the beginning of a chapter, let's "
8545 "think about a project that has multiple concurrent pieces of work under "
8546 "development at once."
8547 msgstr ""
8549 #. type: Content of: <book><chapter><sect1><para>
8550 #: ../en/ch07-branch.xml:234
8551 msgid ""
8552 "There might be a push for a new <quote>main</quote> release; a new minor "
8553 "bugfix release to the last main release; and an unexpected <quote>hot fix</"
8554 "quote> to an old release that is now in maintenance mode."
8555 msgstr ""
8557 #. type: Content of: <book><chapter><sect1><para>
8558 #: ../en/ch07-branch.xml:239
8559 msgid ""
8560 "The usual way people refer to these different concurrent directions of "
8561 "development is as <quote>branches</quote>. However, we've already seen "
8562 "numerous times that Mercurial treats <emphasis>all of history</emphasis> as a "
8563 "series of branches and merges. Really, what we have here is two ideas that "
8564 "are peripherally related, but which happen to share a name."
8565 msgstr ""
8567 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8568 #: ../en/ch07-branch.xml:246
8569 msgid ""
8570 "<quote>Big picture</quote> branches represent the sweep of a project's "
8571 "evolution; people give them names, and talk about them in conversation."
8572 msgstr ""
8574 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8575 #: ../en/ch07-branch.xml:250
8576 msgid ""
8577 "<quote>Little picture</quote> branches are artefacts of the day-to-day "
8578 "activity of developing and merging changes. They expose the narrative of how "
8579 "the code was developed."
8580 msgstr ""
8582 #. type: Content of: <book><chapter><sect1><title>
8583 #: ../en/ch07-branch.xml:258
8584 msgid "Managing big-picture branches in repositories"
8585 msgstr "在版本库中管理分支"
8587 #. type: Content of: <book><chapter><sect1><para>
8588 #: ../en/ch07-branch.xml:260
8589 msgid ""
8590 "The easiest way to isolate a <quote>big picture</quote> branch in Mercurial "
8591 "is in a dedicated repository. If you have an existing shared "
8592 "repository&emdash;let's call it <literal>myproject</literal>&emdash;that "
8593 "reaches a <quote>1.0</quote> milestone, you can start to prepare for future "
8594 "maintenance releases on top of version 1.0 by tagging the revision from which "
8595 "you prepared the 1.0 release."
8596 msgstr ""
8598 #. type: Content of: <book><chapter><sect1><para>
8599 #: ../en/ch07-branch.xml:270
8600 msgid ""
8601 "You can then clone a new shared <literal>myproject-1.0.1</literal> repository "
8602 "as of that tag."
8603 msgstr ""
8605 #. type: Content of: <book><chapter><sect1><para>
8606 #: ../en/ch07-branch.xml:276
8607 msgid ""
8608 "Afterwards, if someone needs to work on a bug fix that ought to go into an "
8609 "upcoming 1.0.1 minor release, they clone the <literal>myproject-1.0.1</"
8610 "literal> repository, make their changes, and push them back."
8611 msgstr ""
8613 #. type: Content of: <book><chapter><sect1><para>
8614 #: ../en/ch07-branch.xml:283
8615 msgid ""
8616 "Meanwhile, development for the next major release can continue, isolated and "
8617 "unabated, in the <literal>myproject</literal> repository."
8618 msgstr ""
8620 #. type: Content of: <book><chapter><sect1><title>
8621 #: ../en/ch07-branch.xml:291
8622 msgid "Don't repeat yourself: merging across branches"
8623 msgstr "不要重复劳动:在分支间合并"
8625 #. type: Content of: <book><chapter><sect1><para>
8626 #: ../en/ch07-branch.xml:293
8627 msgid ""
8628 "In many cases, if you have a bug to fix on a maintenance branch, the chances "
8629 "are good that the bug exists on your project's main branch (and possibly "
8630 "other maintenance branches, too). It's a rare developer who wants to fix the "
8631 "same bug multiple times, so let's look at a few ways that Mercurial can help "
8632 "you to manage these bugfixes without duplicating your work."
8633 msgstr ""
8635 #. type: Content of: <book><chapter><sect1><para>
8636 #: ../en/ch07-branch.xml:301
8637 msgid ""
8638 "In the simplest instance, all you need to do is pull changes from your "
8639 "maintenance branch into your local clone of the target branch."
8640 msgstr ""
8642 #. type: Content of: <book><chapter><sect1><para>
8643 #: ../en/ch07-branch.xml:307
8644 msgid ""
8645 "You'll then need to merge the heads of the two branches, and push back to the "
8646 "main branch."
8647 msgstr ""
8649 #. type: Content of: <book><chapter><sect1><title>
8650 #: ../en/ch07-branch.xml:314
8651 msgid "Naming branches within one repository"
8652 msgstr "版本库中的命名分支"
8654 #. type: Content of: <book><chapter><sect1><para>
8655 #: ../en/ch07-branch.xml:316
8656 msgid ""
8657 "In most instances, isolating branches in repositories is the right approach. "
8658 "Its simplicity makes it easy to understand; and so it's hard to make "
8659 "mistakes. There's a one-to-one relationship between branches you're working "
8660 "in and directories on your system. This lets you use normal (non-Mercurial-"
8661 "aware) tools to work on files within a branch/repository."
8662 msgstr ""
8664 #. type: Content of: <book><chapter><sect1><para>
8665 #: ../en/ch07-branch.xml:323
8666 msgid ""
8667 "If you're more in the <quote>power user</quote> category (<emphasis>and</"
8668 "emphasis> your collaborators are too), there is an alternative way of "
8669 "handling branches that you can consider. I've already mentioned the human-"
8670 "level distinction between <quote>small picture</quote> and <quote>big "
8671 "picture</quote> branches. While Mercurial works with multiple <quote>small "
8672 "picture</quote> branches in a repository all the time (for example after you "
8673 "pull changes in, but before you merge them), it can <emphasis>also</emphasis> "
8674 "work with multiple <quote>big picture</quote> branches."
8675 msgstr ""
8677 #. type: Content of: <book><chapter><sect1><para>
8678 #: ../en/ch07-branch.xml:334
8679 msgid ""
8680 "The key to working this way is that Mercurial lets you assign a persistent "
8681 "<emphasis>name</emphasis> to a branch. There always exists a branch named "
8682 "<literal>default</literal>. Even before you start naming branches yourself, "
8683 "you can find traces of the <literal>default</literal> branch if you look for "
8684 "them."
8685 msgstr ""
8687 #. type: Content of: <book><chapter><sect1><para>
8688 #: ../en/ch07-branch.xml:341
8689 msgid ""
8690 "As an example, when you run the <command role=\"hg-cmd\">hg commit</command> "
8691 "command, and it pops up your editor so that you can enter a commit message, "
8692 "look for a line that contains the text <quote><literal>HG: branch default</"
8693 "literal></quote> at the bottom. This is telling you that your commit will "
8694 "occur on the branch named <literal>default</literal>."
8695 msgstr ""
8697 #. type: Content of: <book><chapter><sect1><para>
8698 #: ../en/ch07-branch.xml:348
8699 msgid ""
8700 "To start working with named branches, use the <command role=\"hg-cmd\">hg "
8701 "branches</command> command. This command lists the named branches already "
8702 "present in your repository, telling you which changeset is the tip of each."
8703 msgstr ""
8705 #. type: Content of: <book><chapter><sect1><para>
8706 #: ../en/ch07-branch.xml:355
8707 msgid ""
8708 "Since you haven't created any named branches yet, the only one that exists is "
8709 "<literal>default</literal>."
8710 msgstr ""
8712 #. type: Content of: <book><chapter><sect1><para>
8713 #: ../en/ch07-branch.xml:358
8714 msgid ""
8715 "To find out what the <quote>current</quote> branch is, run the <command role="
8716 "\"hg-cmd\">hg branch</command> command, giving it no arguments. This tells "
8717 "you what branch the parent of the current changeset is on."
8718 msgstr ""
8721 #. type: Content of: <book><chapter><sect1><para>
8722 #: ../en/ch07-branch.xml:365
8723 msgid ""
8724 "To create a new branch, run the <command role=\"hg-cmd\">hg branch</command> "
8725 "command again. This time, give it one argument: the name of the branch you "
8726 "want to create."
8727 msgstr ""
8729 #. type: Content of: <book><chapter><sect1><para>
8730 #: ../en/ch07-branch.xml:371
8731 msgid ""
8732 "After you've created a branch, you might wonder what effect the <command role="
8733 "\"hg-cmd\">hg branch</command> command has had. What do the <command role="
8734 "\"hg-cmd\">hg status</command> and <command role=\"hg-cmd\">hg tip</command> "
8735 "commands report?"
8736 msgstr ""
8738 #. type: Content of: <book><chapter><sect1><para>
8739 #: ../en/ch07-branch.xml:378
8740 msgid ""
8741 "Nothing has changed in the working directory, and there's been no new history "
8742 "created. As this suggests, running the <command role=\"hg-cmd\">hg branch</"
8743 "command> command has no permanent effect; it only tells Mercurial what branch "
8744 "name to use the <emphasis>next</emphasis> time you commit a changeset."
8745 msgstr ""
8747 #. type: Content of: <book><chapter><sect1><para>
8748 #: ../en/ch07-branch.xml:385
8749 msgid ""
8750 "When you commit a change, Mercurial records the name of the branch on which "
8751 "you committed. Once you've switched from the <literal>default</literal> "
8752 "branch to another and committed, you'll see the name of the new branch show "
8753 "up in the output of <command role=\"hg-cmd\">hg log</command>, <command role="
8754 "\"hg-cmd\">hg tip</command>, and other commands that display the same kind of "
8755 "output."
8756 msgstr ""
8758 #. type: Content of: <book><chapter><sect1><para>
8759 #: ../en/ch07-branch.xml:395
8760 msgid ""
8761 "The <command role=\"hg-cmd\">hg log</command>-like commands will print the "
8762 "branch name of every changeset that's not on the <literal>default</literal> "
8763 "branch. As a result, if you never use named branches, you'll never see this "
8764 "information."
8765 msgstr ""
8767 #. type: Content of: <book><chapter><sect1><para>
8768 #: ../en/ch07-branch.xml:400
8769 msgid ""
8770 "Once you've named a branch and committed a change with that name, every "
8771 "subsequent commit that descends from that change will inherit the same branch "
8772 "name. You can change the name of a branch at any time, using the <command "
8773 "role=\"hg-cmd\">hg branch</command> command."
8774 msgstr ""
8776 #. type: Content of: <book><chapter><sect1><para>
8777 #: ../en/ch07-branch.xml:408
8778 msgid ""
8779 "In practice, this is something you won't do very often, as branch names tend "
8780 "to have fairly long lifetimes. (This isn't a rule, just an observation.)"
8781 msgstr ""
8783 #. type: Content of: <book><chapter><sect1><title>
8784 #: ../en/ch07-branch.xml:414
8785 msgid "Dealing with multiple named branches in a repository"
8786 msgstr "在版本库中处理多个命名分支"
8788 #. type: Content of: <book><chapter><sect1><para>
8789 #: ../en/ch07-branch.xml:417
8790 msgid ""
8791 "If you have more than one named branch in a repository, Mercurial will "
8792 "remember the branch that your working directory on when you start a command "
8793 "like <command role=\"hg-cmd\">hg update</command> or <command role=\"hg-cmd"
8794 "\">hg pull -u</command>. It will update the working directory to the tip of "
8795 "this branch, no matter what the <quote>repo-wide</quote> tip is. To update "
8796 "to a revision that's on a different named branch, you may need to use the "
8797 "<option role=\"hg-opt-update\">-C</option> option to <command role=\"hg-cmd"
8798 "\">hg update</command>."
8799 msgstr ""
8801 #. type: Content of: <book><chapter><sect1><para>
8802 #: ../en/ch07-branch.xml:427
8803 msgid ""
8804 "This behaviour is a little subtle, so let's see it in action. First, let's "
8805 "remind ourselves what branch we're currently on, and what branches are in our "
8806 "repository."
8807 msgstr ""
8809 #. type: Content of: <book><chapter><sect1><para>
8810 #: ../en/ch07-branch.xml:433
8811 msgid ""
8812 "We're on the <literal>bar</literal> branch, but there also exists an older "
8813 "<command role=\"hg-cmd\">hg foo</command> branch."
8814 msgstr ""
8816 #. type: Content of: <book><chapter><sect1><para>
8817 #: ../en/ch07-branch.xml:437
8818 msgid ""
8819 "We can <command role=\"hg-cmd\">hg update</command> back and forth between "
8820 "the tips of the <literal>foo</literal> and <literal>bar</literal> branches "
8821 "without needing to use the <option role=\"hg-opt-update\">-C</option> option, "
8822 "because this only involves going backwards and forwards linearly through our "
8823 "change history."
8824 msgstr ""
8827 #. type: Content of: <book><chapter><sect1><para>
8828 #: ../en/ch07-branch.xml:446
8829 msgid ""
8830 "If we go back to the <literal>foo</literal> branch and then run <command role="
8831 "\"hg-cmd\">hg update</command>, it will keep us on <literal>foo</literal>, "
8832 "not move us to the tip of <literal>bar</literal>."
8833 msgstr ""
8836 #. type: Content of: <book><chapter><sect1><para>
8837 #: ../en/ch07-branch.xml:453
8838 msgid ""
8839 "Committing a new change on the <literal>foo</literal> branch introduces a new "
8840 "head."
8841 msgstr ""
8843 #. type: Content of: <book><chapter><sect1><title>
8844 #: ../en/ch07-branch.xml:460
8845 msgid "Branch names and merging"
8846 msgstr "分支名称与合并"
8848 #. type: Content of: <book><chapter><sect1><para>
8849 #: ../en/ch07-branch.xml:462
8850 msgid ""
8851 "As you've probably noticed, merges in Mercurial are not symmetrical. Let's "
8852 "say our repository has two heads, 17 and 23. If I <command role=\"hg-cmd"
8853 "\">hg update</command> to 17 and then <command role=\"hg-cmd\">hg merge</"
8854 "command> with 23, Mercurial records 17 as the first parent of the merge, and "
8855 "23 as the second. Whereas if I <command role=\"hg-cmd\">hg update</command> "
8856 "to 23 and then <command role=\"hg-cmd\">hg merge</command> with 17, it "
8857 "records 23 as the first parent, and 17 as the second."
8858 msgstr ""
8860 #. type: Content of: <book><chapter><sect1><para>
8861 #: ../en/ch07-branch.xml:472
8862 msgid ""
8863 "This affects Mercurial's choice of branch name when you merge. After a "
8864 "merge, Mercurial will retain the branch name of the first parent when you "
8865 "commit the result of the merge. If your first parent's branch name is "
8866 "<literal>foo</literal>, and you merge with <literal>bar</literal>, the branch "
8867 "name will still be <literal>foo</literal> after you merge."
8868 msgstr ""
8870 #. type: Content of: <book><chapter><sect1><para>
8871 #: ../en/ch07-branch.xml:479
8872 msgid ""
8873 "It's not unusual for a repository to contain multiple heads, each with the "
8874 "same branch name. Let's say I'm working on the <literal>foo</literal> "
8875 "branch, and so are you. We commit different changes; I pull your changes; I "
8876 "now have two heads, each claiming to be on the <literal>foo</literal> "
8877 "branch. The result of a merge will be a single head on the <literal>foo</"
8878 "literal> branch, as you might hope."
8879 msgstr ""
8882 #. type: Content of: <book><chapter><sect1><para>
8883 #: ../en/ch07-branch.xml:487
8884 msgid ""
8885 "But if I'm working on the <literal>bar</literal> branch, and I merge work "
8886 "from the <literal>foo</literal> branch, the result will remain on the "
8887 "<literal>bar</literal> branch."
8888 msgstr ""
8890 #. type: Content of: <book><chapter><sect1><para>
8891 #: ../en/ch07-branch.xml:493
8892 msgid ""
8893 "To give a more concrete example, if I'm working on the <literal>bleeding-"
8894 "edge</literal> branch, and I want to bring in the latest fixes from the "
8895 "<literal>stable</literal> branch, Mercurial will choose the <quote>right</"
8896 "quote> (<literal>bleeding-edge</literal>) branch name when I pull and merge "
8897 "from <literal>stable</literal>."
8898 msgstr ""
8900 #. type: Content of: <book><chapter><sect1><title>
8901 #: ../en/ch07-branch.xml:502
8902 msgid "Branch naming is generally useful"
8903 msgstr "分支名称通常都很有用"
8905 #. type: Content of: <book><chapter><sect1><para>
8906 #: ../en/ch07-branch.xml:504
8907 msgid ""
8908 "You shouldn't think of named branches as applicable only to situations where "
8909 "you have multiple long-lived branches cohabiting in a single repository. "
8910 "They're very useful even in the one-branch-per-repository case."
8911 msgstr ""
8913 #. type: Content of: <book><chapter><sect1><para>
8914 #: ../en/ch07-branch.xml:509
8915 msgid ""
8916 "In the simplest case, giving a name to each branch gives you a permanent "
8917 "record of which branch a changeset originated on. This gives you more "
8918 "context when you're trying to follow the history of a long-lived branchy "
8919 "project."
8920 msgstr ""
8922 #. type: Content of: <book><chapter><sect1><para>
8923 #: ../en/ch07-branch.xml:514
8924 msgid ""
8925 "If you're working with shared repositories, you can set up a <literal role="
8926 "\"hook\">pretxnchangegroup</literal> hook on each that will block incoming "
8927 "changes that have the <quote>wrong</quote> branch name. This provides a "
8928 "simple, but effective, defence against people accidentally pushing changes "
8929 "from a <quote>bleeding edge</quote> branch to a <quote>stable</quote> "
8930 "branch. Such a hook might look like this inside the shared repo's <filename "
8931 "role=\"special\"> /.hgrc</filename>."
8932 msgstr ""
8934 #. type: Content of: <book><chapter><title>
8935 #: ../en/ch08-undo.xml:5
8936 msgid "Finding and fixing mistakes"
8937 msgstr "查找和修改错误"
8939 #. type: Content of: <book><chapter><para>
8940 #: ../en/ch08-undo.xml:7
8941 msgid ""
8942 "To err might be human, but to really handle the consequences well takes a top-"
8943 "notch revision control system. In this chapter, we'll discuss some of the "
8944 "techniques you can use when you find that a problem has crept into your "
8945 "project. Mercurial has some highly capable features that will help you to "
8946 "isolate the sources of problems, and to handle them appropriately."
8947 msgstr ""
8949 #. type: Content of: <book><chapter><sect1><title>
8950 #: ../en/ch08-undo.xml:15
8951 msgid "Erasing local history"
8952 msgstr "销毁本地历史"
8954 #. type: Content of: <book><chapter><sect1><sect2><title>
8955 #: ../en/ch08-undo.xml:18
8956 msgid "The accidental commit"
8957 msgstr "意外的提交"
8959 #. type: Content of: <book><chapter><sect1><sect2><para>
8960 #: ../en/ch08-undo.xml:20
8961 msgid ""
8962 "I have the occasional but persistent problem of typing rather more quickly "
8963 "than I can think, which sometimes results in me committing a changeset that "
8964 "is either incomplete or plain wrong. In my case, the usual kind of "
8965 "incomplete changeset is one in which I've created a new source file, but "
8966 "forgotten to <command role=\"hg-cmd\">hg add</command> it. A <quote>plain "
8967 "wrong</quote> changeset is not as common, but no less annoying."
8968 msgstr ""
8970 #. type: Content of: <book><chapter><sect1><sect2><title>
8971 #: ../en/ch08-undo.xml:31
8972 msgid "Rolling back a transaction"
8973 msgstr "回滚一个事务"
8975 #. type: Content of: <book><chapter><sect1><sect2><para>
8976 #: ../en/ch08-undo.xml:33
8977 msgid ""
8978 "In <xref linkend=\"sec:concepts:txn\"/>, I mentioned that Mercurial treats "
8979 "each modification of a repository as a <emphasis>transaction</emphasis>. "
8980 "Every time you commit a changeset or pull changes from another repository, "
8981 "Mercurial remembers what you did. You can undo, or <emphasis>roll back</"
8982 "emphasis>, exactly one of these actions using the <command role=\"hg-cmd\">hg "
8983 "rollback</command> command. (See <xref linkend=\"sec:undo:rollback-after-push"
8984 "\"/> for an important caveat about the use of this command.)"
8985 msgstr ""
8987 #. type: Content of: <book><chapter><sect1><sect2><para>
8988 #: ../en/ch08-undo.xml:43
8989 msgid ""
8990 "Here's a mistake that I often find myself making: committing a change in "
8991 "which I've created a new file, but forgotten to <command role=\"hg-cmd\">hg "
8992 "add</command> it."
8993 msgstr ""
8995 #. type: Content of: <book><chapter><sect1><sect2><para>
8996 #: ../en/ch08-undo.xml:50
8997 msgid ""
8998 "Looking at the output of <command role=\"hg-cmd\">hg status</command> after "
8999 "the commit immediately confirms the error."
9000 msgstr ""
9002 #. type: Content of: <book><chapter><sect1><sect2><para>
9003 #: ../en/ch08-undo.xml:56
9004 msgid ""
9005 "The commit captured the changes to the file <filename>a</filename>, but not "
9006 "the new file <filename>b</filename>. If I were to push this changeset to a "
9007 "repository that I shared with a colleague, the chances are high that "
9008 "something in <filename>a</filename> would refer to <filename>b</filename>, "
9009 "which would not be present in their repository when they pulled my changes. "
9010 "I would thus become the object of some indignation."
9011 msgstr ""
9013 #. type: Content of: <book><chapter><sect1><sect2><para>
9014 #: ../en/ch08-undo.xml:65
9015 msgid ""
9016 "However, luck is with me&emdash;I've caught my error before I pushed the "
9017 "changeset. I use the <command role=\"hg-cmd\">hg rollback</command> command, "
9018 "and Mercurial makes that last changeset vanish."
9019 msgstr ""
9021 #. type: Content of: <book><chapter><sect1><sect2><para>
9022 #: ../en/ch08-undo.xml:72
9023 msgid ""
9024 "Notice that the changeset is no longer present in the repository's history, "
9025 "and the working directory once again thinks that the file <filename>a</"
9026 "filename> is modified. The commit and rollback have left the working "
9027 "directory exactly as it was prior to the commit; the changeset has been "
9028 "completely erased. I can now safely <command role=\"hg-cmd\">hg add</"
9029 "command> the file <filename>b</filename>, and rerun my commit."
9030 msgstr ""
9032 #. type: Content of: <book><chapter><sect1><sect2><title>
9033 #: ../en/ch08-undo.xml:85
9034 msgid "The erroneous pull"
9035 msgstr "错误的抓取"
9037 #. type: Content of: <book><chapter><sect1><sect2><para>
9038 #: ../en/ch08-undo.xml:87
9039 msgid ""
9040 "It's common practice with Mercurial to maintain separate development branches "
9041 "of a project in different repositories. Your development team might have one "
9042 "shared repository for your project's <quote>0.9</quote> release, and another, "
9043 "containing different changes, for the <quote>1.0</quote> release."
9044 msgstr ""
9046 #. type: Content of: <book><chapter><sect1><sect2><para>
9047 #: ../en/ch08-undo.xml:94
9048 msgid ""
9049 "Given this, you can imagine that the consequences could be messy if you had a "
9050 "local <quote>0.9</quote> repository, and accidentally pulled changes from the "
9051 "shared <quote>1.0</quote> repository into it. At worst, you could be paying "
9052 "insufficient attention, and push those changes into the shared <quote>0.9</"
9053 "quote> tree, confusing your entire team (but don't worry, we'll return to "
9054 "this horror scenario later). However, it's more likely that you'll notice "
9055 "immediately, because Mercurial will display the URL it's pulling from, or you "
9056 "will see it pull a suspiciously large number of changes into the repository."
9057 msgstr ""
9059 #. type: Content of: <book><chapter><sect1><sect2><para>
9060 #: ../en/ch08-undo.xml:106
9061 msgid ""
9062 "The <command role=\"hg-cmd\">hg rollback</command> command will work nicely "
9063 "to expunge all of the changesets that you just pulled. Mercurial groups all "
9064 "changes from one <command role=\"hg-cmd\">hg pull</command> into a single "
9065 "transaction, so one <command role=\"hg-cmd\">hg rollback</command> is all you "
9066 "need to undo this mistake."
9067 msgstr ""
9069 #. type: Content of: <book><chapter><sect1><sect2><title>
9070 #: ../en/ch08-undo.xml:115
9071 msgid "Rolling back is useless once you've pushed"
9072 msgstr "当完成推送后,回滚是无效的"
9074 #. type: Content of: <book><chapter><sect1><sect2><para>
9075 #: ../en/ch08-undo.xml:117
9076 msgid ""
9077 "The value of the <command role=\"hg-cmd\">hg rollback</command> command drops "
9078 "to zero once you've pushed your changes to another repository. Rolling back "
9079 "a change makes it disappear entirely, but <emphasis>only</emphasis> in the "
9080 "repository in which you perform the <command role=\"hg-cmd\">hg rollback</"
9081 "command>. Because a rollback eliminates history, there's no way for the "
9082 "disappearance of a change to propagate between repositories."
9083 msgstr ""
9085 #. type: Content of: <book><chapter><sect1><sect2><para>
9086 #: ../en/ch08-undo.xml:126
9087 msgid ""
9088 "If you've pushed a change to another repository&emdash;particularly if it's a "
9089 "shared repository&emdash;it has essentially <quote>escaped into the wild,</"
9090 "quote> and you'll have to recover from your mistake in a different way. What "
9091 "will happen if you push a changeset somewhere, then roll it back, then pull "
9092 "from the repository you pushed to, is that the changeset will reappear in "
9093 "your repository."
9094 msgstr ""
9096 #. type: Content of: <book><chapter><sect1><sect2><para>
9097 #: ../en/ch08-undo.xml:135
9098 msgid ""
9099 "(If you absolutely know for sure that the change you want to roll back is the "
9100 "most recent change in the repository that you pushed to, <emphasis>and</"
9101 "emphasis> you know that nobody else could have pulled it from that "
9102 "repository, you can roll back the changeset there, too, but you really should "
9103 "really not rely on this working reliably. If you do this, sooner or later a "
9104 "change really will make it into a repository that you don't directly control "
9105 "(or have forgotten about), and come back to bite you.)"
9106 msgstr ""
9108 #. type: Content of: <book><chapter><sect1><sect2><title>
9109 #: ../en/ch08-undo.xml:147
9110 msgid "You can only roll back once"
9111 msgstr "你只能回滚一次"
9113 #. type: Content of: <book><chapter><sect1><sect2><para>
9114 #: ../en/ch08-undo.xml:149
9115 msgid ""
9116 "Mercurial stores exactly one transaction in its transaction log; that "
9117 "transaction is the most recent one that occurred in the repository. This "
9118 "means that you can only roll back one transaction. If you expect to be able "
9119 "to roll back one transaction, then its predecessor, this is not the behaviour "
9120 "you will get."
9121 msgstr ""
9123 #. type: Content of: <book><chapter><sect1><sect2><para>
9124 #: ../en/ch08-undo.xml:158
9125 msgid ""
9126 "Once you've rolled back one transaction in a repository, you can't roll back "
9127 "again in that repository until you perform another commit or pull."
9128 msgstr ""
9130 #. type: Content of: <book><chapter><sect1><title>
9131 #: ../en/ch08-undo.xml:165
9132 msgid "Reverting the mistaken change"
9133 msgstr "撤销错误的修改"
9135 #. type: Content of: <book><chapter><sect1><para>
9136 #: ../en/ch08-undo.xml:167
9137 msgid ""
9138 "If you make a modification to a file, and decide that you really didn't want "
9139 "to change the file at all, and you haven't yet committed your changes, the "
9140 "<command role=\"hg-cmd\">hg revert</command> command is the one you'll need. "
9141 "It looks at the changeset that's the parent of the working directory, and "
9142 "restores the contents of the file to their state as of that changeset. "
9143 "(That's a long-winded way of saying that, in the normal case, it undoes your "
9144 "modifications.)"
9145 msgstr ""
9147 #. type: Content of: <book><chapter><sect1><para>
9148 #: ../en/ch08-undo.xml:176
9149 msgid ""
9150 "Let's illustrate how the <command role=\"hg-cmd\">hg revert</command> command "
9151 "works with yet another small example. We'll begin by modifying a file that "
9152 "Mercurial is already tracking."
9153 msgstr ""
9155 #. type: Content of: <book><chapter><sect1><para>
9156 #: ../en/ch08-undo.xml:183
9157 msgid ""
9158 "If we don't want that change, we can simply <command role=\"hg-cmd\">hg "
9159 "revert</command> the file."
9160 msgstr ""
9162 #. type: Content of: <book><chapter><sect1><para>
9163 #: ../en/ch08-undo.xml:189
9164 msgid ""
9165 "The <command role=\"hg-cmd\">hg revert</command> command provides us with an "
9166 "extra degree of safety by saving our modified file with a <filename>.orig</"
9167 "filename> extension."
9168 msgstr ""
9170 #. type: Content of: <book><chapter><sect1><para>
9171 #: ../en/ch08-undo.xml:196
9172 msgid ""
9173 "Here is a summary of the cases that the <command role=\"hg-cmd\">hg revert</"
9174 "command> command can deal with. We will describe each of these in more "
9175 "detail in the section that follows."
9176 msgstr ""
9178 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
9179 #: ../en/ch08-undo.xml:201
9180 msgid "If you modify a file, it will restore the file to its unmodified state."
9181 msgstr ""
9183 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
9184 #: ../en/ch08-undo.xml:204
9185 msgid ""
9186 "If you <command role=\"hg-cmd\">hg add</command> a file, it will undo the "
9187 "<quote>added</quote> state of the file, but leave the file itself untouched."
9188 msgstr ""
9190 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
9191 #: ../en/ch08-undo.xml:208
9192 msgid ""
9193 "If you delete a file without telling Mercurial, it will restore the file to "
9194 "its unmodified contents."
9195 msgstr ""
9197 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
9198 #: ../en/ch08-undo.xml:211
9199 msgid ""
9200 "If you use the <command role=\"hg-cmd\">hg remove</command> command to remove "
9201 "a file, it will undo the <quote>removed</quote> state of the file, and "
9202 "restore the file to its unmodified contents."
9203 msgstr ""
9205 #. type: Content of: <book><chapter><sect1><sect2><title>
9206 #: ../en/ch08-undo.xml:218
9207 msgid "File management errors"
9208 msgstr "文件管理错误"
9210 #. type: Content of: <book><chapter><sect1><sect2><para>
9211 #: ../en/ch08-undo.xml:220
9212 msgid ""
9213 "The <command role=\"hg-cmd\">hg revert</command> command is useful for more "
9214 "than just modified files. It lets you reverse the results of all of "
9215 "Mercurial's file management commands&emdash;<command role=\"hg-cmd\">hg add</"
9216 "command>, <command role=\"hg-cmd\">hg remove</command>, and so on."
9217 msgstr ""
9220 #. type: Content of: <book><chapter><sect1><sect2><para>
9221 #: ../en/ch08-undo.xml:226
9222 msgid ""
9223 "If you <command role=\"hg-cmd\">hg add</command> a file, then decide that in "
9224 "fact you don't want Mercurial to track it, use <command role=\"hg-cmd\">hg "
9225 "revert</command> to undo the add. Don't worry; Mercurial will not modify the "
9226 "file in any way. It will just <quote>unmark</quote> the file."
9227 msgstr ""
9229 #. type: Content of: <book><chapter><sect1><sect2><para>
9230 #: ../en/ch08-undo.xml:234
9231 msgid ""
9232 "Similarly, if you ask Mercurial to <command role=\"hg-cmd\">hg remove</"
9233 "command> a file, you can use <command role=\"hg-cmd\">hg revert</command> to "
9234 "restore it to the contents it had as of the parent of the working directory. "
9235 "&interaction.daily.revert.remove; This works just as well for a file that you "
9236 "deleted by hand, without telling Mercurial (recall that in Mercurial "
9237 "terminology, this kind of file is called <quote>missing</quote>)."
9238 msgstr ""
9241 #. type: Content of: <book><chapter><sect1><sect2><para>
9242 #: ../en/ch08-undo.xml:245
9243 msgid ""
9244 "If you revert a <command role=\"hg-cmd\">hg copy</command>, the copied-to "
9245 "file remains in your working directory afterwards, untracked. Since a copy "
9246 "doesn't affect the copied-from file in any way, Mercurial doesn't do anything "
9247 "with the copied-from file."
9248 msgstr ""
9250 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
9251 #: ../en/ch08-undo.xml:254
9252 msgid "A slightly special case: reverting a rename"
9253 msgstr "一个稍微特别的案例:撤销改名"
9255 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9256 #: ../en/ch08-undo.xml:256
9257 msgid ""
9258 "If you <command role=\"hg-cmd\">hg rename</command> a file, there is one "
9259 "small detail that you should remember. When you <command role=\"hg-cmd\">hg "
9260 "revert</command> a rename, it's not enough to provide the name of the renamed-"
9261 "to file, as you can see here."
9262 msgstr ""
9264 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9265 #: ../en/ch08-undo.xml:264
9266 msgid ""
9267 "As you can see from the output of <command role=\"hg-cmd\">hg status</"
9268 "command>, the renamed-to file is no longer identified as added, but the "
9269 "renamed-<emphasis>from</emphasis> file is still removed! This is counter-"
9270 "intuitive (at least to me), but at least it's easy to deal with."
9271 msgstr ""
9273 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9274 #: ../en/ch08-undo.xml:273
9275 msgid ""
9276 "So remember, to revert a <command role=\"hg-cmd\">hg rename</command>, you "
9277 "must provide <emphasis>both</emphasis> the source and destination names."
9278 msgstr ""
9280 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9281 #: ../en/ch08-undo.xml:278
9282 msgid "% TODO: the output doesn't look like it will be removed!"
9283 msgstr ""
9285 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9286 #: ../en/ch08-undo.xml:281
9287 msgid ""
9288 "(By the way, if you rename a file, then modify the renamed-to file, then "
9289 "revert both components of the rename, when Mercurial restores the file that "
9290 "was removed as part of the rename, it will be unmodified. If you need the "
9291 "modifications in the renamed-to file to show up in the renamed-from file, "
9292 "don't forget to copy them over.)"
9293 msgstr ""
9295 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9296 #: ../en/ch08-undo.xml:288
9297 msgid ""
9298 "These fiddly aspects of reverting a rename arguably constitute a small bug in "
9299 "Mercurial."
9300 msgstr ""
9302 #. type: Content of: <book><chapter><sect1><title>
9303 #: ../en/ch08-undo.xml:295
9304 msgid "Dealing with committed changes"
9305 msgstr "处理已经提交的修改"
9307 #. type: Content of: <book><chapter><sect1><para>
9308 #: ../en/ch08-undo.xml:297
9309 msgid ""
9310 "Consider a case where you have committed a change $a$, and another change $b$ "
9311 "on top of it; you then realise that change $a$ was incorrect. Mercurial lets "
9312 "you <quote>back out</quote> an entire changeset automatically, and building "
9313 "blocks that let you reverse part of a changeset by hand."
9314 msgstr ""
9316 #. type: Content of: <book><chapter><sect1><para>
9317 #: ../en/ch08-undo.xml:303
9318 msgid ""
9319 "Before you read this section, here's something to keep in mind: the <command "
9320 "role=\"hg-cmd\">hg backout</command> command undoes changes by "
9321 "<emphasis>adding</emphasis> history, not by modifying or erasing it. It's "
9322 "the right tool to use if you're fixing bugs, but not if you're trying to undo "
9323 "some change that has catastrophic consequences. To deal with those, see "
9324 "<xref linkend=\"sec:undo:aaaiiieee\"/>."
9325 msgstr ""
9327 #. type: Content of: <book><chapter><sect1><sect2><title>
9328 #: ../en/ch08-undo.xml:312
9329 msgid "Backing out a changeset"
9330 msgstr "恢复一个修改集"
9332 #. type: Content of: <book><chapter><sect1><sect2><para>
9333 #: ../en/ch08-undo.xml:314
9334 msgid ""
9335 "The <command role=\"hg-cmd\">hg backout</command> command lets you "
9336 "<quote>undo</quote> the effects of an entire changeset in an automated "
9337 "fashion. Because Mercurial's history is immutable, this command "
9338 "<emphasis>does not</emphasis> get rid of the changeset you want to undo. "
9339 "Instead, it creates a new changeset that <emphasis>reverses</emphasis> the "
9340 "effect of the to-be-undone changeset."
9341 msgstr ""
9344 #. type: Content of: <book><chapter><sect1><sect2><para>
9345 #: ../en/ch08-undo.xml:323
9346 msgid ""
9347 "The operation of the <command role=\"hg-cmd\">hg backout</command> command is "
9348 "a little intricate, so let's illustrate it with some examples. First, we'll "
9349 "create a repository with some simple changes."
9350 msgstr ""
9352 #. type: Content of: <book><chapter><sect1><sect2><para>
9353 #: ../en/ch08-undo.xml:330
9354 msgid ""
9355 "The <command role=\"hg-cmd\">hg backout</command> command takes a single "
9356 "changeset ID as its argument; this is the changeset to back out. Normally, "
9357 "<command role=\"hg-cmd\">hg backout</command> will drop you into a text "
9358 "editor to write a commit message, so you can record why you're backing the "
9359 "change out. In this example, we provide a commit message on the command line "
9360 "using the <option role=\"hg-opt-backout\">-m</option> option."
9361 msgstr ""
9363 #. type: Content of: <book><chapter><sect1><sect2><title>
9364 #: ../en/ch08-undo.xml:341
9365 msgid "Backing out the tip changeset"
9366 msgstr "恢复顶点修改集"
9368 #. type: Content of: <book><chapter><sect1><sect2><para>
9369 #: ../en/ch08-undo.xml:343
9370 msgid "We're going to start by backing out the last changeset we committed."
9371 msgstr ""
9373 #. type: Content of: <book><chapter><sect1><sect2><para>
9374 #: ../en/ch08-undo.xml:348
9375 msgid ""
9376 "You can see that the second line from <filename>myfile</filename> is no "
9377 "longer present. Taking a look at the output of <command role=\"hg-cmd\">hg "
9378 "log</command> gives us an idea of what the <command role=\"hg-cmd\">hg "
9379 "backout</command> command has done. &interaction.backout.simple.log; Notice "
9380 "that the new changeset that <command role=\"hg-cmd\">hg backout</command> has "
9381 "created is a child of the changeset we backed out. It's easier to see this "
9382 "in <xref linkend=\"fig:undo:backout\"/>, which presents a graphical view of "
9383 "the change history. As you can see, the history is nice and linear."
9384 msgstr ""
9386 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
9387 #: ../en/ch08-undo.xml:361 ../en/ch08-undo.xml:473
9388 msgid ""
9389 "Backing out a change using the <command role=\"hg-cmd\">hg backout</command> "
9390 "command"
9391 msgstr "使用 <command role=\"hg-cmd\">hg backout</command> 恢复一个修改"
9393 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
9394 #: ../en/ch08-undo.xml:364
9395 msgid "<imageobject><imagedata fileref=\"figs/undo-simple.png\"/></imageobject>"
9396 msgstr ""
9398 #. type: Content of: <book><chapter><sect1><sect2><title>
9399 #: ../en/ch08-undo.xml:371
9400 msgid "Backing out a non-tip change"
9401 msgstr "恢复非顶点的修改"
9403 #. type: Content of: <book><chapter><sect1><sect2><para>
9404 #: ../en/ch08-undo.xml:373
9405 msgid ""
9406 "If you want to back out a change other than the last one you committed, pass "
9407 "the <option role=\"hg-opt-backout\">--merge</option> option to the <command "
9408 "role=\"hg-cmd\">hg backout</command> command."
9409 msgstr ""
9411 #. type: Content of: <book><chapter><sect1><sect2><para>
9412 #: ../en/ch08-undo.xml:380
9413 msgid ""
9414 "This makes backing out any changeset a <quote>one-shot</quote> operation "
9415 "that's usually simple and fast."
9416 msgstr ""
9418 #. type: Content of: <book><chapter><sect1><sect2><para>
9419 #: ../en/ch08-undo.xml:386
9420 msgid ""
9421 "If you take a look at the contents of <filename>myfile</filename> after the "
9422 "backout finishes, you'll see that the first and third changes are present, "
9423 "but not the second."
9424 msgstr ""
9426 #. type: Content of: <book><chapter><sect1><sect2><para>
9427 #: ../en/ch08-undo.xml:393
9428 msgid ""
9429 "As the graphical history in <xref linkend=\"fig:undo:backout-non-tip\"/> "
9430 "illustrates, Mercurial actually commits <emphasis>two</emphasis> changes in "
9431 "this kind of situation (the box-shaped nodes are the ones that Mercurial "
9432 "commits automatically). Before Mercurial begins the backout process, it "
9433 "first remembers what the current parent of the working directory is. It then "
9434 "backs out the target changeset, and commits that as a changeset. Finally, it "
9435 "merges back to the previous parent of the working directory, and commits the "
9436 "result of the merge."
9437 msgstr ""
9439 #. type: Content of: <book><chapter><sect1><sect2><para>
9440 #: ../en/ch08-undo.xml:404
9441 msgid ""
9442 "% TODO: to me it looks like mercurial doesn't commit the second merge "
9443 "automatically!"
9444 msgstr ""
9446 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
9447 #: ../en/ch08-undo.xml:408
9448 msgid ""
9449 "Automated backout of a non-tip change using the <command role=\"hg-cmd\">hg "
9450 "backout</command> command"
9451 msgstr "使用 <command role=\"hg-cmd\">hg backout</command> 自动恢复非顶点的修改"
9453 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
9454 #: ../en/ch08-undo.xml:411
9455 msgid ""
9456 "<imageobject><imagedata fileref=\"figs/undo-non-tip.png\"/></imageobject>"
9457 msgstr ""
9459 #. type: Content of: <book><chapter><sect1><sect2><para>
9460 #: ../en/ch08-undo.xml:416
9461 msgid ""
9462 "The result is that you end up <quote>back where you were</quote>, only with "
9463 "some extra history that undoes the effect of the changeset you wanted to back "
9464 "out."
9465 msgstr ""
9467 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
9468 #: ../en/ch08-undo.xml:421
9469 msgid "Always use the <option role=\"hg-opt-backout\">--merge</option> option"
9470 msgstr "始终使用选项 <option role=\"hg-opt-backout\">--merge</option>"
9472 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9473 #: ../en/ch08-undo.xml:424
9474 msgid ""
9475 "In fact, since the <option role=\"hg-opt-backout\">--merge</option> option "
9476 "will do the <quote>right thing</quote> whether or not the changeset you're "
9477 "backing out is the tip (i.e. it won't try to merge if it's backing out the "
9478 "tip, since there's no need), you should <emphasis>always</emphasis> use this "
9479 "option when you run the <command role=\"hg-cmd\">hg backout</command> command."
9480 msgstr ""
9482 #. type: Content of: <book><chapter><sect1><sect2><title>
9483 #: ../en/ch08-undo.xml:435
9484 msgid "Gaining more control of the backout process"
9485 msgstr "在恢复处理中获得更多控制"
9487 #. type: Content of: <book><chapter><sect1><sect2><para>
9488 #: ../en/ch08-undo.xml:437
9489 msgid ""
9490 "While I've recommended that you always use the <option role=\"hg-opt-backout"
9491 "\">--merge</option> option when backing out a change, the <command role=\"hg-"
9492 "cmd\">hg backout</command> command lets you decide how to merge a backout "
9493 "changeset. Taking control of the backout process by hand is something you "
9494 "will rarely need to do, but it can be useful to understand what the <command "
9495 "role=\"hg-cmd\">hg backout</command> command is doing for you automatically. "
9496 "To illustrate this, let's clone our first repository, but omit the backout "
9497 "change that it contains."
9498 msgstr ""
9500 #. type: Content of: <book><chapter><sect1><sect2><para>
9501 #: ../en/ch08-undo.xml:450
9502 msgid ""
9503 "As with our earlier example, We'll commit a third changeset, then back out "
9504 "its parent, and see what happens."
9505 msgstr ""
9507 #. type: Content of: <book><chapter><sect1><sect2><para>
9508 #: ../en/ch08-undo.xml:456
9509 msgid ""
9510 "Our new changeset is again a descendant of the changeset we backout out; it's "
9511 "thus a new head, <emphasis>not</emphasis> a descendant of the changeset that "
9512 "was the tip. The <command role=\"hg-cmd\">hg backout</command> command was "
9513 "quite explicit in telling us this."
9514 msgstr ""
9516 #. type: Content of: <book><chapter><sect1><sect2><para>
9517 #: ../en/ch08-undo.xml:464
9518 msgid ""
9519 "Again, it's easier to see what has happened by looking at a graph of the "
9520 "revision history, in <xref linkend=\"fig:undo:backout-manual\"/>. This makes "
9521 "it clear that when we use <command role=\"hg-cmd\">hg backout</command> to "
9522 "back out a change other than the tip, Mercurial adds a new head to the "
9523 "repository (the change it committed is box-shaped)."
9524 msgstr ""
9526 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
9527 #: ../en/ch08-undo.xml:476
9528 msgid "<imageobject><imagedata fileref=\"figs/undo-manual.png\"/></imageobject>"
9529 msgstr ""
9531 #. type: Content of: <book><chapter><sect1><sect2><para>
9532 #: ../en/ch08-undo.xml:481
9533 msgid ""
9534 "After the <command role=\"hg-cmd\">hg backout</command> command has "
9535 "completed, it leaves the new <quote>backout</quote> changeset as the parent "
9536 "of the working directory."
9537 msgstr ""
9539 #. type: Content of: <book><chapter><sect1><sect2><para>
9540 #: ../en/ch08-undo.xml:488
9541 msgid "Now we have two isolated sets of changes."
9542 msgstr ""
9544 #. type: Content of: <book><chapter><sect1><sect2><para>
9545 #: ../en/ch08-undo.xml:492
9546 msgid ""
9547 "Let's think about what we expect to see as the contents of <filename>myfile</"
9548 "filename> now. The first change should be present, because we've never "
9549 "backed it out. The second change should be missing, as that's the change we "
9550 "backed out. Since the history graph shows the third change as a separate "
9551 "head, we <emphasis>don't</emphasis> expect to see the third change present in "
9552 "<filename>myfile</filename>."
9553 msgstr ""
9555 #. type: Content of: <book><chapter><sect1><sect2><para>
9556 #: ../en/ch08-undo.xml:502
9557 msgid ""
9558 "To get the third change back into the file, we just do a normal merge of our "
9559 "two heads."
9560 msgstr ""
9562 #. type: Content of: <book><chapter><sect1><sect2><para>
9563 #: ../en/ch08-undo.xml:507
9564 msgid ""
9565 "Afterwards, the graphical history of our repository looks like <xref linkend="
9566 "\"fig:undo:backout-manual-merge\"/>."
9567 msgstr ""
9569 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
9570 #: ../en/ch08-undo.xml:512
9571 msgid "Manually merging a backout change"
9572 msgstr "手工合并恢复修改"
9574 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
9575 #: ../en/ch08-undo.xml:514
9576 msgid ""
9577 "<imageobject><imagedata fileref=\"figs/undo-manual-merge.png\"/></imageobject>"
9578 msgstr ""
9580 #. type: Content of: <book><chapter><sect1><sect2><title>
9581 #: ../en/ch08-undo.xml:521
9582 msgid "Why <command role=\"hg-cmd\">hg backout</command> works as it does"
9583 msgstr "<command role=\"hg-cmd\">hg backout</command> 的内幕"
9585 #. type: Content of: <book><chapter><sect1><sect2><para>
9586 #: ../en/ch08-undo.xml:524
9587 msgid ""
9588 "Here's a brief description of how the <command role=\"hg-cmd\">hg backout</"
9589 "command> command works."
9590 msgstr ""
9592 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
9593 #: ../en/ch08-undo.xml:527
9594 msgid ""
9595 "It ensures that the working directory is <quote>clean</quote>, i.e. that the "
9596 "output of <command role=\"hg-cmd\">hg status</command> would be empty."
9597 msgstr ""
9599 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
9600 #: ../en/ch08-undo.xml:531
9601 msgid ""
9602 "It remembers the current parent of the working directory. Let's call this "
9603 "changeset <literal>orig</literal>"
9604 msgstr ""
9606 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
9607 #: ../en/ch08-undo.xml:535
9608 msgid ""
9609 "It does the equivalent of a <command role=\"hg-cmd\">hg update</command> to "
9610 "sync the working directory to the changeset you want to back out. Let's call "
9611 "this changeset <literal>backout</literal>"
9612 msgstr ""
9614 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
9615 #: ../en/ch08-undo.xml:540
9616 msgid ""
9617 "It finds the parent of that changeset. Let's call that changeset "
9618 "<literal>parent</literal>."
9619 msgstr ""
9621 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
9622 #: ../en/ch08-undo.xml:543
9623 msgid ""
9624 "For each file that the <literal>backout</literal> changeset affected, it does "
9625 "the equivalent of a <command role=\"hg-cmd\">hg revert -r parent</command> on "
9626 "that file, to restore it to the contents it had before that changeset was "
9627 "committed."
9628 msgstr ""
9630 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
9631 #: ../en/ch08-undo.xml:550
9632 msgid ""
9633 "It commits the result as a new changeset. This changeset has "
9634 "<literal>backout</literal> as its parent."
9635 msgstr ""
9637 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
9638 #: ../en/ch08-undo.xml:554
9639 msgid ""
9640 "If you specify <option role=\"hg-opt-backout\">--merge</option> on the "
9641 "command line, it merges with <literal>orig</literal>, and commits the result "
9642 "of the merge."
9643 msgstr ""
9645 #. type: Content of: <book><chapter><sect1><sect2><para>
9646 #: ../en/ch08-undo.xml:560
9647 msgid ""
9648 "An alternative way to implement the <command role=\"hg-cmd\">hg backout</"
9649 "command> command would be to <command role=\"hg-cmd\">hg export</command> the "
9650 "to-be-backed-out changeset as a diff, then use the <option role=\"cmd-opt-"
9651 "patch\">--reverse</option> option to the <command>patch</command> command to "
9652 "reverse the effect of the change without fiddling with the working "
9653 "directory. This sounds much simpler, but it would not work nearly as well."
9654 msgstr ""
9656 #. type: Content of: <book><chapter><sect1><sect2><para>
9657 #: ../en/ch08-undo.xml:570
9658 msgid ""
9659 "The reason that <command role=\"hg-cmd\">hg backout</command> does an update, "
9660 "a commit, a merge, and another commit is to give the merge machinery the best "
9661 "chance to do a good job when dealing with all the changes <emphasis>between</"
9662 "emphasis> the change you're backing out and the current tip."
9663 msgstr ""
9665 #. type: Content of: <book><chapter><sect1><sect2><para>
9666 #: ../en/ch08-undo.xml:577
9667 msgid ""
9668 "If you're backing out a changeset that's 100 revisions back in your project's "
9669 "history, the chances that the <command>patch</command> command will be able "
9670 "to apply a reverse diff cleanly are not good, because intervening changes are "
9671 "likely to have <quote>broken the context</quote> that <command>patch</"
9672 "command> uses to determine whether it can apply a patch (if this sounds like "
9673 "gibberish, see <xref linkend=\"sec:mq:patch\"/> for a discussion of the "
9674 "<command>patch</command> command). Also, Mercurial's merge machinery will "
9675 "handle files and directories being renamed, permission changes, and "
9676 "modifications to binary files, none of which <command>patch</command> can "
9677 "deal with."
9678 msgstr ""
9680 #. type: Content of: <book><chapter><sect1><title>
9681 #: ../en/ch08-undo.xml:594
9682 msgid "Changes that should never have been"
9683 msgstr "不该发生的修改"
9685 #. type: Content of: <book><chapter><sect1><para>
9686 #: ../en/ch08-undo.xml:596
9687 msgid ""
9688 "Most of the time, the <command role=\"hg-cmd\">hg backout</command> command "
9689 "is exactly what you need if you want to undo the effects of a change. It "
9690 "leaves a permanent record of exactly what you did, both when committing the "
9691 "original changeset and when you cleaned up after it."
9692 msgstr ""
9694 #. type: Content of: <book><chapter><sect1><para>
9695 #: ../en/ch08-undo.xml:602
9696 msgid ""
9697 "On rare occasions, though, you may find that you've committed a change that "
9698 "really should not be present in the repository at all. For example, it would "
9699 "be very unusual, and usually considered a mistake, to commit a software "
9700 "project's object files as well as its source files. Object files have almost "
9701 "no intrinsic value, and they're <emphasis>big</emphasis>, so they increase "
9702 "the size of the repository and the amount of time it takes to clone or pull "
9703 "changes."
9704 msgstr ""
9706 #. type: Content of: <book><chapter><sect1><para>
9707 #: ../en/ch08-undo.xml:611
9708 msgid ""
9709 "Before I discuss the options that you have if you commit a <quote>brown paper "
9710 "bag</quote> change (the kind that's so bad that you want to pull a brown "
9711 "paper bag over your head), let me first discuss some approaches that probably "
9712 "won't work."
9713 msgstr ""
9715 #. type: Content of: <book><chapter><sect1><para>
9716 #: ../en/ch08-undo.xml:616
9717 msgid ""
9718 "Since Mercurial treats history as accumulative&emdash;every change builds on "
9719 "top of all changes that preceded it&emdash;you generally can't just make "
9720 "disastrous changes disappear. The one exception is when you've just "
9721 "committed a change, and it hasn't been pushed or pulled into another "
9722 "repository. That's when you can safely use the <command role=\"hg-cmd\">hg "
9723 "rollback</command> command, as I detailed in <xref linkend=\"sec:undo:rollback"
9724 "\"/>."
9725 msgstr ""
9727 #. type: Content of: <book><chapter><sect1><para>
9728 #: ../en/ch08-undo.xml:625
9729 msgid ""
9730 "After you've pushed a bad change to another repository, you <emphasis>could</"
9731 "emphasis> still use <command role=\"hg-cmd\">hg rollback</command> to make "
9732 "your local copy of the change disappear, but it won't have the consequences "
9733 "you want. The change will still be present in the remote repository, so it "
9734 "will reappear in your local repository the next time you pull."
9735 msgstr ""
9737 #. type: Content of: <book><chapter><sect1><para>
9738 #: ../en/ch08-undo.xml:633
9739 msgid ""
9740 "If a situation like this arises, and you know which repositories your bad "
9741 "change has propagated into, you can <emphasis>try</emphasis> to get rid of "
9742 "the changeefrom <emphasis>every</emphasis> one of those repositories. This "
9743 "is, of course, not a satisfactory solution: if you miss even a single "
9744 "repository while you're expunging, the change is still <quote>in the wild</"
9745 "quote>, and could propagate further."
9746 msgstr ""
9748 #. type: Content of: <book><chapter><sect1><para>
9749 #: ../en/ch08-undo.xml:641
9750 msgid ""
9751 "If you've committed one or more changes <emphasis>after</emphasis> the change "
9752 "that you'd like to see disappear, your options are further reduced. Mercurial "
9753 "doesn't provide a way to <quote>punch a hole</quote> in history, leaving "
9754 "changesets intact."
9755 msgstr ""
9757 #. type: Content of: <book><chapter><sect1><para>
9758 #: ../en/ch08-undo.xml:647
9759 msgid ""
9760 "XXX This needs filling out. The <literal>hg-replay</literal> script in the "
9761 "<literal>examples</literal> directory works, but doesn't handle merge "
9762 "changesets. Kind of an important omission."
9763 msgstr ""
9765 #. type: Content of: <book><chapter><sect1><sect2><title>
9766 #: ../en/ch08-undo.xml:653
9767 msgid "Protect yourself from <quote>escaped</quote> changes"
9768 msgstr "使用<quote>校验</quote>修改来保护你自己"
9770 #. type: Content of: <book><chapter><sect1><sect2><para>
9771 #: ../en/ch08-undo.xml:656
9772 msgid ""
9773 "If you've committed some changes to your local repository and they've been "
9774 "pushed or pulled somewhere else, this isn't necessarily a disaster. You can "
9775 "protect yourself ahead of time against some classes of bad changeset. This "
9776 "is particularly easy if your team usually pulls changes from a central "
9777 "repository."
9778 msgstr ""
9780 #. type: Content of: <book><chapter><sect1><sect2><para>
9781 #: ../en/ch08-undo.xml:663
9782 msgid ""
9783 "By configuring some hooks on that repository to validate incoming changesets "
9784 "(see chapter <xref linkend=\"chap:hook\"/>), you can automatically prevent "
9785 "some kinds of bad changeset from being pushed to the central repository at "
9786 "all. With such a configuration in place, some kinds of bad changeset will "
9787 "naturally tend to <quote>die out</quote> because they can't propagate into "
9788 "the central repository. Better yet, this happens without any need for "
9789 "explicit intervention."
9790 msgstr ""
9792 #. type: Content of: <book><chapter><sect1><sect2><para>
9793 #: ../en/ch08-undo.xml:673
9794 msgid ""
9795 "For instance, an incoming change hook that verifies that a changeset will "
9796 "actually compile can prevent people from inadvertantly <quote>breaking the "
9797 "build</quote>."
9798 msgstr ""
9800 #. type: Content of: <book><chapter><sect1><title>
9801 #: ../en/ch08-undo.xml:680
9802 msgid "Finding the source of a bug"
9803 msgstr "查找问题的根源"
9805 #. type: Content of: <book><chapter><sect1><para>
9806 #: ../en/ch08-undo.xml:682
9807 msgid ""
9808 "While it's all very well to be able to back out a changeset that introduced a "
9809 "bug, this requires that you know which changeset to back out. Mercurial "
9810 "provides an invaluable command, called <command role=\"hg-cmd\">hg bisect</"
9811 "command>, that helps you to automate this process and accomplish it very "
9812 "efficiently."
9813 msgstr ""
9815 #. type: Content of: <book><chapter><sect1><para>
9816 #: ../en/ch08-undo.xml:689
9817 msgid ""
9818 "The idea behind the <command role=\"hg-cmd\">hg bisect</command> command is "
9819 "that a changeset has introduced some change of behaviour that you can "
9820 "identify with a simple binary test. You don't know which piece of code "
9821 "introduced the change, but you know how to test for the presence of the bug. "
9822 "The <command role=\"hg-cmd\">hg bisect</command> command uses your test to "
9823 "direct its search for the changeset that introduced the code that caused the "
9824 "bug."
9825 msgstr ""
9827 #. type: Content of: <book><chapter><sect1><para>
9828 #: ../en/ch08-undo.xml:698
9829 msgid ""
9830 "Here are a few scenarios to help you understand how you might apply this "
9831 "command."
9832 msgstr ""
9834 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
9835 #: ../en/ch08-undo.xml:701
9836 msgid ""
9837 "The most recent version of your software has a bug that you remember wasn't "
9838 "present a few weeks ago, but you don't know when it was introduced. Here, "
9839 "your binary test checks for the presence of that bug."
9840 msgstr ""
9842 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
9843 #: ../en/ch08-undo.xml:706
9844 msgid ""
9845 "You fixed a bug in a rush, and now it's time to close the entry in your "
9846 "team's bug database. The bug database requires a changeset ID when you close "
9847 "an entry, but you don't remember which changeset you fixed the bug in. Once "
9848 "again, your binary test checks for the presence of the bug."
9849 msgstr ""
9851 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
9852 #: ../en/ch08-undo.xml:713
9853 msgid ""
9854 "Your software works correctly, but runs 15% slower than the last time you "
9855 "measured it. You want to know which changeset introduced the performance "
9856 "regression. In this case, your binary test measures the performance of your "
9857 "software, to see whether it's <quote>fast</quote> or <quote>slow</quote>."
9858 msgstr ""
9860 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
9861 #: ../en/ch08-undo.xml:720
9862 msgid ""
9863 "The sizes of the components of your project that you ship exploded recently, "
9864 "and you suspect that something changed in the way you build your project."
9865 msgstr ""
9867 #. type: Content of: <book><chapter><sect1><para>
9868 #: ../en/ch08-undo.xml:725
9869 msgid ""
9870 "From these examples, it should be clear that the <command role=\"hg-cmd\">hg "
9871 "bisect</command> command is not useful only for finding the sources of bugs. "
9872 "You can use it to find any <quote>emergent property</quote> of a repository "
9873 "(anything that you can't find from a simple text search of the files in the "
9874 "tree) for which you can write a binary test."
9875 msgstr ""
9877 #. type: Content of: <book><chapter><sect1><para>
9878 #: ../en/ch08-undo.xml:732
9879 msgid ""
9880 "We'll introduce a little bit of terminology here, just to make it clear which "
9881 "parts of the search process are your responsibility, and which are "
9882 "Mercurial's. A <emphasis>test</emphasis> is something that <emphasis>you</"
9883 "emphasis> run when <command role=\"hg-cmd\">hg bisect</command> chooses a "
9884 "changeset. A <emphasis>probe</emphasis> is what <command role=\"hg-cmd\">hg "
9885 "bisect</command> runs to tell whether a revision is good. Finally, we'll use "
9886 "the word <quote>bisect</quote>, as both a noun and a verb, to stand in for "
9887 "the phrase <quote>search using the <command role=\"hg-cmd\">hg bisect</"
9888 "command> command</quote>."
9889 msgstr ""
9891 #. type: Content of: <book><chapter><sect1><para>
9892 #: ../en/ch08-undo.xml:745
9893 msgid ""
9894 "One simple way to automate the searching process would be simply to probe "
9895 "every changeset. However, this scales poorly. If it took ten minutes to "
9896 "test a single changeset, and you had 10,000 changesets in your repository, "
9897 "the exhaustive approach would take on average 35 <emphasis>days</emphasis> to "
9898 "find the changeset that introduced a bug. Even if you knew that the bug was "
9899 "introduced by one of the last 500 changesets, and limited your search to "
9900 "those, you'd still be looking at over 40 hours to find the changeset that "
9901 "introduced your bug."
9902 msgstr ""
9904 #. type: Content of: <book><chapter><sect1><para>
9905 #: ../en/ch08-undo.xml:755
9906 msgid ""
9907 "What the <command role=\"hg-cmd\">hg bisect</command> command does is use its "
9908 "knowledge of the <quote>shape</quote> of your project's revision history to "
9909 "perform a search in time proportional to the <emphasis>logarithm</emphasis> "
9910 "of the number of changesets to check (the kind of search it performs is "
9911 "called a dichotomic search). With this approach, searching through 10,000 "
9912 "changesets will take less than three hours, even at ten minutes per test (the "
9913 "search will require about 14 tests). Limit your search to the last hundred "
9914 "changesets, and it will take only about an hour (roughly seven tests)."
9915 msgstr ""
9917 #. type: Content of: <book><chapter><sect1><para>
9918 #: ../en/ch08-undo.xml:766
9919 msgid ""
9920 "The <command role=\"hg-cmd\">hg bisect</command> command is aware of the "
9921 "<quote>branchy</quote> nature of a Mercurial project's revision history, so "
9922 "it has no problems dealing with branches, merges, or multiple heads in a "
9923 "repository. It can prune entire branches of history with a single probe, "
9924 "which is how it operates so efficiently."
9925 msgstr ""
9927 #. type: Content of: <book><chapter><sect1><sect2><title>
9928 #: ../en/ch08-undo.xml:774
9929 msgid "Using the <command role=\"hg-cmd\">hg bisect</command> command"
9930 msgstr "使用命令 <command role=\"hg-cmd\">hg bisect</command>"
9932 #. type: Content of: <book><chapter><sect1><sect2><para>
9933 #: ../en/ch08-undo.xml:777
9934 msgid ""
9935 "Here's an example of <command role=\"hg-cmd\">hg bisect</command> in action."
9936 msgstr ""
9938 #. type: Content of: <book><chapter><sect1><sect2><note><para>
9939 #: ../en/ch08-undo.xml:781
9940 msgid ""
9941 "In versions 0.9.5 and earlier of Mercurial, <command role=\"hg-cmd\">hg "
9942 "bisect</command> was not a core command: it was distributed with Mercurial as "
9943 "an extension. This section describes the built-in command, not the old "
9944 "extension."
9945 msgstr ""
9947 #. type: Content of: <book><chapter><sect1><sect2><para>
9948 #: ../en/ch08-undo.xml:788
9949 msgid ""
9950 "Now let's create a repository, so that we can try out the <command role=\"hg-"
9951 "cmd\">hg bisect</command> command in isolation."
9952 msgstr ""
9954 #. type: Content of: <book><chapter><sect1><sect2><para>
9955 #: ../en/ch08-undo.xml:794
9956 msgid ""
9957 "We'll simulate a project that has a bug in it in a simple-minded way: create "
9958 "trivial changes in a loop, and nominate one specific change that will have "
9959 "the <quote>bug</quote>. This loop creates 35 changesets, each adding a "
9960 "single file to the repository. We'll represent our <quote>bug</quote> with a "
9961 "file that contains the text <quote>i have a gub</quote>."
9962 msgstr ""
9964 #. type: Content of: <book><chapter><sect1><sect2><para>
9965 #: ../en/ch08-undo.xml:804
9966 msgid ""
9967 "The next thing that we'd like to do is figure out how to use the <command "
9968 "role=\"hg-cmd\">hg bisect</command> command. We can use Mercurial's normal "
9969 "built-in help mechanism for this."
9970 msgstr ""
9972 #. type: Content of: <book><chapter><sect1><sect2><para>
9973 #: ../en/ch08-undo.xml:811
9974 msgid ""
9975 "The <command role=\"hg-cmd\">hg bisect</command> command works in steps. "
9976 "Each step proceeds as follows."
9977 msgstr ""
9979 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
9980 #: ../en/ch08-undo.xml:814
9981 msgid "You run your binary test."
9982 msgstr ""
9984 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><itemizedlist><listitem><para>
9985 #: ../en/ch08-undo.xml:816
9986 msgid ""
9987 "If the test succeeded, you tell <command role=\"hg-cmd\">hg bisect</command> "
9988 "by running the <command role=\"hg-cmd\">hg bisect good</command> command."
9989 msgstr ""
9991 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><itemizedlist><listitem><para>
9992 #: ../en/ch08-undo.xml:821
9993 msgid ""
9994 "If it failed, run the <command role=\"hg-cmd\">hg bisect bad</command> "
9995 "command."
9996 msgstr ""
9998 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
9999 #: ../en/ch08-undo.xml:825
10000 msgid ""
10001 "The command uses your information to decide which changeset to test next."
10002 msgstr ""
10004 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
10005 #: ../en/ch08-undo.xml:828
10006 msgid ""
10007 "It updates the working directory to that changeset, and the process begins "
10008 "again."
10009 msgstr ""
10011 #. type: Content of: <book><chapter><sect1><sect2><para>
10012 #: ../en/ch08-undo.xml:831
10013 msgid ""
10014 "The process ends when <command role=\"hg-cmd\">hg bisect</command> identifies "
10015 "a unique changeset that marks the point where your test transitioned from "
10016 "<quote>succeeding</quote> to <quote>failing</quote>."
10017 msgstr ""
10020 #. type: Content of: <book><chapter><sect1><sect2><para>
10021 #: ../en/ch08-undo.xml:836
10022 msgid ""
10023 "To start the search, we must run the <command role=\"hg-cmd\">hg bisect --"
10024 "reset</command> command."
10025 msgstr ""
10027 #. type: Content of: <book><chapter><sect1><sect2><para>
10028 #: ../en/ch08-undo.xml:841
10029 msgid ""
10030 "In our case, the binary test we use is simple: we check to see if any file in "
10031 "the repository contains the string <quote>i have a gub</quote>. If it does, "
10032 "this changeset contains the change that <quote>caused the bug</quote>. By "
10033 "convention, a changeset that has the property we're searching for is "
10034 "<quote>bad</quote>, while one that doesn't is <quote>good</quote>."
10035 msgstr ""
10037 #. type: Content of: <book><chapter><sect1><sect2><para>
10038 #: ../en/ch08-undo.xml:849
10039 msgid ""
10040 "Most of the time, the revision to which the working directory is synced "
10041 "(usually the tip) already exhibits the problem introduced by the buggy "
10042 "change, so we'll mark it as <quote>bad</quote>."
10043 msgstr ""
10046 #. type: Content of: <book><chapter><sect1><sect2><para>
10047 #: ../en/ch08-undo.xml:856
10048 msgid ""
10049 "Our next task is to nominate a changeset that we know <emphasis>doesn't</"
10050 "emphasis> have the bug; the <command role=\"hg-cmd\">hg bisect</command> "
10051 "command will <quote>bracket</quote> its search between the first pair of good "
10052 "and bad changesets. In our case, we know that revision 10 didn't have the "
10053 "bug. (I'll have more words about choosing the first <quote>good</quote> "
10054 "changeset later.)"
10055 msgstr ""
10057 #. type: Content of: <book><chapter><sect1><sect2><para>
10058 #: ../en/ch08-undo.xml:866
10059 msgid "Notice that this command printed some output."
10060 msgstr ""
10062 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
10063 #: ../en/ch08-undo.xml:868
10064 msgid ""
10065 "It told us how many changesets it must consider before it can identify the "
10066 "one that introduced the bug, and how many tests that will require."
10067 msgstr ""
10069 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
10070 #: ../en/ch08-undo.xml:872
10071 msgid ""
10072 "It updated the working directory to the next changeset to test, and told us "
10073 "which changeset it's testing."
10074 msgstr ""
10076 #. type: Content of: <book><chapter><sect1><sect2><para>
10077 #: ../en/ch08-undo.xml:877
10078 msgid ""
10079 "We now run our test in the working directory. We use the <command>grep</"
10080 "command> command to see if our <quote>bad</quote> file is present in the "
10081 "working directory. If it is, this revision is bad; if not, this revision is "
10082 "good. &interaction.bisect.search.step1;"
10083 msgstr ""
10085 #. type: Content of: <book><chapter><sect1><sect2><para>
10086 #: ../en/ch08-undo.xml:883
10087 msgid ""
10088 "This test looks like a perfect candidate for automation, so let's turn it "
10089 "into a shell function."
10090 msgstr ""
10092 #. type: Content of: <book><chapter><sect1><sect2><para>
10093 #: ../en/ch08-undo.xml:887
10094 msgid ""
10095 "We can now run an entire test step with a single command, <literal>mytest</"
10096 "literal>."
10097 msgstr ""
10099 #. type: Content of: <book><chapter><sect1><sect2><para>
10100 #: ../en/ch08-undo.xml:892
10101 msgid "A few more invocations of our canned test step command, and we're done."
10102 msgstr ""
10104 #. type: Content of: <book><chapter><sect1><sect2><para>
10105 #: ../en/ch08-undo.xml:897
10106 msgid ""
10107 "Even though we had 40 changesets to search through, the <command role=\"hg-cmd"
10108 "\">hg bisect</command> command let us find the changeset that introduced our "
10109 "<quote>bug</quote> with only five tests. Because the number of tests that "
10110 "the <command role=\"hg-cmd\">hg bisect</command> command performs grows "
10111 "logarithmically with the number of changesets to search, the advantage that "
10112 "it has over the <quote>brute force</quote> search approach increases with "
10113 "every changeset you add."
10114 msgstr ""
10116 #. type: Content of: <book><chapter><sect1><sect2><title>
10117 #: ../en/ch08-undo.xml:908
10118 msgid "Cleaning up after your search"
10119 msgstr "搜索后的清理"
10122 #. type: Content of: <book><chapter><sect1><sect2><para>
10123 #: ../en/ch08-undo.xml:910
10124 msgid ""
10125 "When you're finished using the <command role=\"hg-cmd\">hg bisect</command> "
10126 "command in a repository, you can use the <command role=\"hg-cmd\">hg bisect "
10127 "reset</command> command to drop the information it was using to drive your "
10128 "search. The command doesn't use much space, so it doesn't matter if you "
10129 "forget to run this command. However, <command role=\"hg-cmd\">hg bisect</"
10130 "command> won't let you start a new search in that repository until you do a "
10131 "<command role=\"hg-cmd\">hg bisect reset</command>."
10132 msgstr ""
10134 #. type: Content of: <book><chapter><sect1><title>
10135 #: ../en/ch08-undo.xml:925
10136 msgid "Tips for finding bugs effectively"
10137 msgstr "有效查找问题的技巧"
10139 #. type: Content of: <book><chapter><sect1><sect2><title>
10140 #: ../en/ch08-undo.xml:928
10141 msgid "Give consistent input"
10142 msgstr "给出一致的输入"
10144 #. type: Content of: <book><chapter><sect1><sect2><para>
10145 #: ../en/ch08-undo.xml:930
10146 msgid ""
10147 "The <command role=\"hg-cmd\">hg bisect</command> command requires that you "
10148 "correctly report the result of every test you perform. If you tell it that a "
10149 "test failed when it really succeeded, it <emphasis>might</emphasis> be able "
10150 "to detect the inconsistency. If it can identify an inconsistency in your "
10151 "reports, it will tell you that a particular changeset is both good and bad. "
10152 "However, it can't do this perfectly; it's about as likely to report the wrong "
10153 "changeset as the source of the bug."
10154 msgstr ""
10156 #. type: Content of: <book><chapter><sect1><sect2><title>
10157 #: ../en/ch08-undo.xml:942
10158 msgid "Automate as much as possible"
10159 msgstr "尽量自动"
10161 #. type: Content of: <book><chapter><sect1><sect2><para>
10162 #: ../en/ch08-undo.xml:944
10163 msgid ""
10164 "When I started using the <command role=\"hg-cmd\">hg bisect</command> "
10165 "command, I tried a few times to run my tests by hand, on the command line. "
10166 "This is an approach that I, at least, am not suited to. After a few tries, I "
10167 "found that I was making enough mistakes that I was having to restart my "
10168 "searches several times before finally getting correct results."
10169 msgstr ""
10171 #. type: Content of: <book><chapter><sect1><sect2><para>
10172 #: ../en/ch08-undo.xml:952
10173 msgid ""
10174 "My initial problems with driving the <command role=\"hg-cmd\">hg bisect</"
10175 "command> command by hand occurred even with simple searches on small "
10176 "repositories; if the problem you're looking for is more subtle, or the number "
10177 "of tests that <command role=\"hg-cmd\">hg bisect</command> must perform "
10178 "increases, the likelihood of operator error ruining the search is much "
10179 "higher. Once I started automating my tests, I had much better results."
10180 msgstr ""
10182 #. type: Content of: <book><chapter><sect1><sect2><para>
10183 #: ../en/ch08-undo.xml:961
10184 msgid "The key to automated testing is twofold:"
10185 msgstr ""
10187 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
10188 #: ../en/ch08-undo.xml:963
10189 msgid "always test for the same symptom, and"
10190 msgstr ""
10192 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
10193 #: ../en/ch08-undo.xml:965
10194 msgid ""
10195 "always feed consistent input to the <command role=\"hg-cmd\">hg bisect</"
10196 "command> command."
10197 msgstr ""
10199 #. type: Content of: <book><chapter><sect1><sect2><para>
10200 #: ../en/ch08-undo.xml:968
10201 msgid ""
10202 "In my tutorial example above, the <command>grep</command> command tests for "
10203 "the symptom, and the <literal>if</literal> statement takes the result of this "
10204 "check and ensures that we always feed the same input to the <command role="
10205 "\"hg-cmd\">hg bisect</command> command. The <literal>mytest</literal> "
10206 "function marries these together in a reproducible way, so that every test is "
10207 "uniform and consistent."
10208 msgstr ""
10210 #. type: Content of: <book><chapter><sect1><sect2><title>
10211 #: ../en/ch08-undo.xml:978
10212 msgid "Check your results"
10213 msgstr "检查你的结果"
10215 #. type: Content of: <book><chapter><sect1><sect2><para>
10216 #: ../en/ch08-undo.xml:980
10217 msgid ""
10218 "Because the output of a <command role=\"hg-cmd\">hg bisect</command> search "
10219 "is only as good as the input you give it, don't take the changeset it reports "
10220 "as the absolute truth. A simple way to cross-check its report is to manually "
10221 "run your test at each of the following changesets:"
10222 msgstr ""
10224 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
10225 #: ../en/ch08-undo.xml:986
10226 msgid ""
10227 "The changeset that it reports as the first bad revision. Your test should "
10228 "still report this as bad."
10229 msgstr ""
10231 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
10232 #: ../en/ch08-undo.xml:990
10233 msgid ""
10234 "The parent of that changeset (either parent, if it's a merge). Your test "
10235 "should report this changeset as good."
10236 msgstr ""
10238 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
10239 #: ../en/ch08-undo.xml:994
10240 msgid ""
10241 "A child of that changeset. Your test should report this changeset as bad."
10242 msgstr ""
10244 #. type: Content of: <book><chapter><sect1><sect2><title>
10245 #: ../en/ch08-undo.xml:1000
10246 msgid "Beware interference between bugs"
10247 msgstr "谨防问题之间的冲突"
10249 #. type: Content of: <book><chapter><sect1><sect2><para>
10250 #: ../en/ch08-undo.xml:1002
10251 msgid ""
10252 "It's possible that your search for one bug could be disrupted by the presence "
10253 "of another. For example, let's say your software crashes at revision 100, "
10254 "and worked correctly at revision 50. Unknown to you, someone else introduced "
10255 "a different crashing bug at revision 60, and fixed it at revision 80. This "
10256 "could distort your results in one of several ways."
10257 msgstr ""
10259 #. type: Content of: <book><chapter><sect1><sect2><para>
10260 #: ../en/ch08-undo.xml:1010
10261 msgid ""
10262 "It is possible that this other bug completely <quote>masks</quote> yours, "
10263 "which is to say that it occurs before your bug has a chance to manifest "
10264 "itself. If you can't avoid that other bug (for example, it prevents your "
10265 "project from building), and so can't tell whether your bug is present in a "
10266 "particular changeset, the <command role=\"hg-cmd\">hg bisect</command> "
10267 "command cannot help you directly. Instead, you can mark a changeset as "
10268 "untested by running <command role=\"hg-cmd\">hg bisect --skip</command>."
10269 msgstr ""
10271 #. type: Content of: <book><chapter><sect1><sect2><para>
10272 #: ../en/ch08-undo.xml:1020
10273 msgid ""
10274 "A different problem could arise if your test for a bug's presence is not "
10275 "specific enough. If you check for <quote>my program crashes</quote>, then "
10276 "both your crashing bug and an unrelated crashing bug that masks it will look "
10277 "like the same thing, and mislead <command role=\"hg-cmd\">hg bisect</command>."
10278 msgstr ""
10280 #. type: Content of: <book><chapter><sect1><sect2><para>
10281 #: ../en/ch08-undo.xml:1027
10282 msgid ""
10283 "Another useful situation in which to use <command role=\"hg-cmd\">hg bisect --"
10284 "skip</command> is if you can't test a revision because your project was in a "
10285 "broken and hence untestable state at that revision, perhaps because someone "
10286 "checked in a change that prevented the project from building."
10287 msgstr ""
10289 #. type: Content of: <book><chapter><sect1><sect2><title>
10290 #: ../en/ch08-undo.xml:1036
10291 msgid "Bracket your search lazily"
10292 msgstr "减少你的查找工作"
10294 #. type: Content of: <book><chapter><sect1><sect2><para>
10295 #: ../en/ch08-undo.xml:1038
10296 msgid ""
10297 "Choosing the first <quote>good</quote> and <quote>bad</quote> changesets that "
10298 "will mark the end points of your search is often easy, but it bears a little "
10299 "discussion nevertheless. From the perspective of <command role=\"hg-cmd\">hg "
10300 "bisect</command>, the <quote>newest</quote> changeset is conventionally "
10301 "<quote>bad</quote>, and the older changeset is <quote>good</quote>."
10302 msgstr ""
10304 #. type: Content of: <book><chapter><sect1><sect2><para>
10305 #: ../en/ch08-undo.xml:1046
10306 msgid ""
10307 "If you're having trouble remembering when a suitable <quote>good</quote> "
10308 "change was, so that you can tell <command role=\"hg-cmd\">hg bisect</"
10309 "command>, you could do worse than testing changesets at random. Just "
10310 "remember to eliminate contenders that can't possibly exhibit the bug (perhaps "
10311 "because the feature with the bug isn't present yet) and those where another "
10312 "problem masks the bug (as I discussed above)."
10313 msgstr ""
10315 #. type: Content of: <book><chapter><sect1><sect2><para>
10316 #: ../en/ch08-undo.xml:1055
10317 msgid ""
10318 "Even if you end up <quote>early</quote> by thousands of changesets or months "
10319 "of history, you will only add a handful of tests to the total number that "
10320 "<command role=\"hg-cmd\">hg bisect</command> must perform, thanks to its "
10321 "logarithmic behaviour."
10322 msgstr ""
10324 #. type: Content of: <book><chapter><title>
10325 #: ../en/ch09-hook.xml:5
10326 msgid "Handling repository events with hooks"
10327 msgstr "使用钩子处理版本库事件"
10329 #. type: Content of: <book><chapter><para>
10330 #: ../en/ch09-hook.xml:7
10331 msgid ""
10332 "Mercurial offers a powerful mechanism to let you perform automated actions in "
10333 "response to events that occur in a repository. In some cases, you can even "
10334 "control Mercurial's response to those events."
10335 msgstr ""
10337 #. type: Content of: <book><chapter><para>
10338 #: ../en/ch09-hook.xml:12
10339 msgid ""
10340 "The name Mercurial uses for one of these actions is a <emphasis>hook</"
10341 "emphasis>. Hooks are called <quote>triggers</quote> in some revision control "
10342 "systems, but the two names refer to the same idea."
10343 msgstr ""
10345 #. type: Content of: <book><chapter><sect1><title>
10346 #: ../en/ch09-hook.xml:18
10347 msgid "An overview of hooks in Mercurial"
10348 msgstr "Mercurial 钩子概述"
10350 #. type: Content of: <book><chapter><sect1><para>
10351 #: ../en/ch09-hook.xml:20
10352 msgid ""
10353 "Here is a brief list of the hooks that Mercurial supports. We will revisit "
10354 "each of these hooks in more detail later, in <xref linkend=\"sec:hook:ref\"/>."
10355 msgstr ""
10357 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10358 #: ../en/ch09-hook.xml:25
10359 msgid ""
10360 "<literal role=\"hook\">changegroup</literal>: This is run after a group of "
10361 "changesets has been brought into the repository from elsewhere."
10362 msgstr ""
10364 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10365 #: ../en/ch09-hook.xml:29
10366 msgid ""
10367 "<literal role=\"hook\">commit</literal>: This is run after a new changeset "
10368 "has been created in the local repository."
10369 msgstr ""
10371 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10372 #: ../en/ch09-hook.xml:33
10373 msgid ""
10374 "<literal role=\"hook\">incoming</literal>: This is run once for each new "
10375 "changeset that is brought into the repository from elsewhere. Notice the "
10376 "difference from <literal role=\"hook\">changegroup</literal>, which is run "
10377 "once per <emphasis>group</emphasis> of changesets brought in."
10378 msgstr ""
10380 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10381 #: ../en/ch09-hook.xml:40
10382 msgid ""
10383 "<literal role=\"hook\">outgoing</literal>: This is run after a group of "
10384 "changesets has been transmitted from this repository."
10385 msgstr ""
10387 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10388 #: ../en/ch09-hook.xml:44
10389 msgid ""
10390 "<literal role=\"hook\">prechangegroup</literal>: This is run before starting "
10391 "to bring a group of changesets into the repository."
10392 msgstr ""
10394 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10395 #: ../en/ch09-hook.xml:49
10396 msgid ""
10397 "<literal role=\"hook\">precommit</literal>: Controlling. This is run before "
10398 "starting a commit."
10399 msgstr ""
10401 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10402 #: ../en/ch09-hook.xml:53
10403 msgid ""
10404 "<literal role=\"hook\">preoutgoing</literal>: Controlling. This is run before "
10405 "starting to transmit a group of changesets from this repository."
10406 msgstr ""
10408 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10409 #: ../en/ch09-hook.xml:58
10410 msgid ""
10411 "<literal role=\"hook\">pretag</literal>: Controlling. This is run before "
10412 "creating a tag."
10413 msgstr ""
10415 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10416 #: ../en/ch09-hook.xml:62
10417 msgid ""
10418 "<literal role=\"hook\">pretxnchangegroup</literal>: Controlling. This is run "
10419 "after a group of changesets has been brought into the local repository from "
10420 "another, but before the transaction completes that will make the changes "
10421 "permanent in the repository."
10422 msgstr ""
10424 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10425 #: ../en/ch09-hook.xml:70
10426 msgid ""
10427 "<literal role=\"hook\">pretxncommit</literal>: Controlling. This is run after "
10428 "a new changeset has been created in the local repository, but before the "
10429 "transaction completes that will make it permanent."
10430 msgstr ""
10432 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10433 #: ../en/ch09-hook.xml:76
10434 msgid ""
10435 "<literal role=\"hook\">preupdate</literal>: Controlling. This is run before "
10436 "starting an update or merge of the working directory."
10437 msgstr ""
10439 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10440 #: ../en/ch09-hook.xml:81
10441 msgid ""
10442 "<literal role=\"hook\">tag</literal>: This is run after a tag is created."
10443 msgstr ""
10445 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10446 #: ../en/ch09-hook.xml:85
10447 msgid ""
10448 "<literal role=\"hook\">update</literal>: This is run after an update or merge "
10449 "of the working directory has finished."
10450 msgstr ""
10452 #. type: Content of: <book><chapter><sect1><para>
10453 #: ../en/ch09-hook.xml:90
10454 msgid ""
10455 "Each of the hooks whose description begins with the word <quote>Controlling</"
10456 "quote> has the ability to determine whether an activity can proceed. If the "
10457 "hook succeeds, the activity may proceed; if it fails, the activity is either "
10458 "not permitted or undone, depending on the hook."
10459 msgstr ""
10461 #. type: Content of: <book><chapter><sect1><title>
10462 #: ../en/ch09-hook.xml:99
10463 msgid "Hooks and security"
10464 msgstr "钩子与安全性"
10466 #. type: Content of: <book><chapter><sect1><sect2><title>
10467 #: ../en/ch09-hook.xml:102
10468 msgid "Hooks are run with your privileges"
10469 msgstr "钩子以你的特权执行"
10471 #. type: Content of: <book><chapter><sect1><sect2><para>
10472 #: ../en/ch09-hook.xml:104
10473 msgid ""
10474 "When you run a Mercurial command in a repository, and the command causes a "
10475 "hook to run, that hook runs on <emphasis>your</emphasis> system, under "
10476 "<emphasis>your</emphasis> user account, with <emphasis>your</emphasis> "
10477 "privilege level. Since hooks are arbitrary pieces of executable code, you "
10478 "should treat them with an appropriate level of suspicion. Do not install a "
10479 "hook unless you are confident that you know who created it and what it does."
10480 msgstr ""
10482 #. type: Content of: <book><chapter><sect1><sect2><para>
10483 #: ../en/ch09-hook.xml:115
10484 msgid ""
10485 "In some cases, you may be exposed to hooks that you did not install "
10486 "yourself. If you work with Mercurial on an unfamiliar system, Mercurial will "
10487 "run hooks defined in that system's global <filename role=\"special\">~/.hgrc</"
10488 "filename> file."
10489 msgstr ""
10491 #. type: Content of: <book><chapter><sect1><sect2><para>
10492 #: ../en/ch09-hook.xml:122
10493 msgid ""
10494 "If you are working with a repository owned by another user, Mercurial can run "
10495 "hooks defined in that user's repository, but it will still run them as "
10496 "<quote>you</quote>. For example, if you <command role=\"hg-cmd\">hg pull</"
10497 "command> from that repository, and its <filename role=\"special\">.hg/hgrc</"
10498 "filename> defines a local <literal role=\"hook\">outgoing</literal> hook, "
10499 "that hook will run under your user account, even though you don't own that "
10500 "repository."
10501 msgstr ""
10503 #. type: Content of: <book><chapter><sect1><sect2><note><para>
10504 #: ../en/ch09-hook.xml:134
10505 msgid ""
10506 "This only applies if you are pulling from a repository on a local or network "
10507 "filesystem. If you're pulling over http or ssh, any <literal role=\"hook"
10508 "\">outgoing</literal> hook will run under whatever account is executing the "
10509 "server process, on the server."
10510 msgstr ""
10512 #. type: Content of: <book><chapter><sect1><sect2><para>
10513 #: ../en/ch09-hook.xml:142
10514 msgid ""
10515 "XXX To see what hooks are defined in a repository, use the <command role=\"hg-"
10516 "cmd\">hg config hooks</command> command. If you are working in one "
10517 "repository, but talking to another that you do not own (e.g. using <command "
10518 "role=\"hg-cmd\">hg pull</command> or <command role=\"hg-cmd\">hg incoming</"
10519 "command>), remember that it is the other repository's hooks you should be "
10520 "checking, not your own."
10521 msgstr ""
10523 #. type: Content of: <book><chapter><sect1><sect2><title>
10524 #: ../en/ch09-hook.xml:153
10525 msgid "Hooks do not propagate"
10526 msgstr "钩子不会传播"
10528 #. type: Content of: <book><chapter><sect1><sect2><para>
10529 #: ../en/ch09-hook.xml:155
10530 msgid ""
10531 "In Mercurial, hooks are not revision controlled, and do not propagate when "
10532 "you clone, or pull from, a repository. The reason for this is simple: a hook "
10533 "is a completely arbitrary piece of executable code. It runs under your user "
10534 "identity, with your privilege level, on your machine."
10535 msgstr ""
10537 #. type: Content of: <book><chapter><sect1><sect2><para>
10538 #: ../en/ch09-hook.xml:162
10539 msgid ""
10540 "It would be extremely reckless for any distributed revision control system to "
10541 "implement revision-controlled hooks, as this would offer an easily "
10542 "exploitable way to subvert the accounts of users of the revision control "
10543 "system."
10544 msgstr ""
10546 #. type: Content of: <book><chapter><sect1><sect2><para>
10547 #: ../en/ch09-hook.xml:168
10548 msgid ""
10549 "Since Mercurial does not propagate hooks, if you are collaborating with other "
10550 "people on a common project, you should not assume that they are using the "
10551 "same Mercurial hooks as you are, or that theirs are correctly configured. "
10552 "You should document the hooks you expect people to use."
10553 msgstr ""
10555 #. type: Content of: <book><chapter><sect1><sect2><para>
10556 #: ../en/ch09-hook.xml:175
10557 msgid ""
10558 "In a corporate intranet, this is somewhat easier to control, as you can for "
10559 "example provide a <quote>standard</quote> installation of Mercurial on an NFS "
10560 "filesystem, and use a site-wide <filename role=\"special\">~/.hgrc</filename> "
10561 "file to define hooks that all users will see. However, this too has its "
10562 "limits; see below."
10563 msgstr ""
10565 #. type: Content of: <book><chapter><sect1><sect2><title>
10566 #: ../en/ch09-hook.xml:184
10567 msgid "Hooks can be overridden"
10568 msgstr "钩子可以被覆盖"
10570 #. type: Content of: <book><chapter><sect1><sect2><para>
10571 #: ../en/ch09-hook.xml:186
10572 msgid ""
10573 "Mercurial allows you to override a hook definition by redefining the hook. "
10574 "You can disable it by setting its value to the empty string, or change its "
10575 "behaviour as you wish."
10576 msgstr ""
10578 #. type: Content of: <book><chapter><sect1><sect2><para>
10579 #: ../en/ch09-hook.xml:191
10580 msgid ""
10581 "If you deploy a system- or site-wide <filename role=\"special\">~/.hgrc</"
10582 "filename> file that defines some hooks, you should thus understand that your "
10583 "users can disable or override those hooks."
10584 msgstr ""
10586 #. type: Content of: <book><chapter><sect1><sect2><title>
10587 #: ../en/ch09-hook.xml:199
10588 msgid "Ensuring that critical hooks are run"
10589 msgstr "确保关键钩子的执行"
10591 #. type: Content of: <book><chapter><sect1><sect2><para>
10592 #: ../en/ch09-hook.xml:201
10593 msgid ""
10594 "Sometimes you may want to enforce a policy that you do not want others to be "
10595 "able to work around. For example, you may have a requirement that every "
10596 "changeset must pass a rigorous set of tests. Defining this requirement via a "
10597 "hook in a site-wide <filename role=\"special\">~/.hgrc</filename> won't work "
10598 "for remote users on laptops, and of course local users can subvert it at will "
10599 "by overriding the hook."
10600 msgstr ""
10602 #. type: Content of: <book><chapter><sect1><sect2><para>
10603 #: ../en/ch09-hook.xml:210
10604 msgid ""
10605 "Instead, you can set up your policies for use of Mercurial so that people are "
10606 "expected to propagate changes through a well-known <quote>canonical</quote> "
10607 "server that you have locked down and configured appropriately."
10608 msgstr ""
10610 #. type: Content of: <book><chapter><sect1><sect2><para>
10611 #: ../en/ch09-hook.xml:216
10612 msgid ""
10613 "One way to do this is via a combination of social engineering and "
10614 "technology. Set up a restricted-access account; users can push changes over "
10615 "the network to repositories managed by this account, but they cannot log into "
10616 "the account and run normal shell commands. In this scenario, a user can "
10617 "commit a changeset that contains any old garbage they want."
10618 msgstr ""
10620 #. type: Content of: <book><chapter><sect1><sect2><para>
10621 #: ../en/ch09-hook.xml:225
10622 msgid ""
10623 "When someone pushes a changeset to the server that everyone pulls from, the "
10624 "server will test the changeset before it accepts it as permanent, and reject "
10625 "it if it fails to pass the test suite. If people only pull changes from this "
10626 "filtering server, it will serve to ensure that all changes that people pull "
10627 "have been automatically vetted."
10628 msgstr ""
10630 #. type: Content of: <book><chapter><sect1><title>
10631 #: ../en/ch09-hook.xml:236
10632 msgid "Care with <literal>pretxn</literal> hooks in a shared-access repository"
10633 msgstr "在共享版本库中注意 <literal>pretxn</literal> 钩子"
10635 #. type: Content of: <book><chapter><sect1><para>
10636 #: ../en/ch09-hook.xml:239
10637 msgid ""
10638 "If you want to use hooks to do some automated work in a repository that a "
10639 "number of people have shared access to, you need to be careful in how you do "
10640 "this."
10641 msgstr ""
10643 #. type: Content of: <book><chapter><sect1><para>
10644 #: ../en/ch09-hook.xml:244
10645 msgid ""
10646 "Mercurial only locks a repository when it is writing to the repository, and "
10647 "only the parts of Mercurial that write to the repository pay attention to "
10648 "locks. Write locks are necessary to prevent multiple simultaneous writers "
10649 "from scribbling on each other's work, corrupting the repository."
10650 msgstr ""
10652 #. type: Content of: <book><chapter><sect1><para>
10653 #: ../en/ch09-hook.xml:251
10654 msgid ""
10655 "Because Mercurial is careful with the order in which it reads and writes "
10656 "data, it does not need to acquire a lock when it wants to read data from the "
10657 "repository. The parts of Mercurial that read from the repository never pay "
10658 "attention to locks. This lockless reading scheme greatly increases "
10659 "performance and concurrency."
10660 msgstr ""
10662 #. type: Content of: <book><chapter><sect1><para>
10663 #: ../en/ch09-hook.xml:259
10664 msgid ""
10665 "With great performance comes a trade-off, though, one which has the potential "
10666 "to cause you trouble unless you're aware of it. To describe this requires a "
10667 "little detail about how Mercurial adds changesets to a repository and reads "
10668 "those changes."
10669 msgstr ""
10671 #. type: Content of: <book><chapter><sect1><para>
10672 #: ../en/ch09-hook.xml:266
10673 msgid ""
10674 "When Mercurial <emphasis>writes</emphasis> metadata, it writes it straight "
10675 "into the destination file. It writes file data first, then manifest data "
10676 "(which contains pointers to the new file data), then changelog data (which "
10677 "contains pointers to the new manifest data). Before the first write to each "
10678 "file, it stores a record of where the end of the file was in its transaction "
10679 "log. If the transaction must be rolled back, Mercurial simply truncates each "
10680 "file back to the size it was before the transaction began."
10681 msgstr ""
10683 #. type: Content of: <book><chapter><sect1><para>
10684 #: ../en/ch09-hook.xml:277
10685 msgid ""
10686 "When Mercurial <emphasis>reads</emphasis> metadata, it reads the changelog "
10687 "first, then everything else. Since a reader will only access parts of the "
10688 "manifest or file metadata that it can see in the changelog, it can never see "
10689 "partially written data."
10690 msgstr ""
10692 #. type: Content of: <book><chapter><sect1><para>
10693 #: ../en/ch09-hook.xml:283
10694 msgid ""
10695 "Some controlling hooks (<literal role=\"hook\">pretxncommit</literal> and "
10696 "<literal role=\"hook\">pretxnchangegroup</literal>) run when a transaction is "
10697 "almost complete. All of the metadata has been written, but Mercurial can "
10698 "still roll the transaction back and cause the newly-written data to disappear."
10699 msgstr ""
10701 #. type: Content of: <book><chapter><sect1><para>
10702 #: ../en/ch09-hook.xml:291
10703 msgid ""
10704 "If one of these hooks runs for long, it opens a window of time during which a "
10705 "reader can see the metadata for changesets that are not yet permanent, and "
10706 "should not be thought of as <quote>really there</quote>. The longer the hook "
10707 "runs, the longer that window is open."
10708 msgstr ""
10710 #. type: Content of: <book><chapter><sect1><sect2><title>
10711 #: ../en/ch09-hook.xml:299
10712 msgid "The problem illustrated"
10713 msgstr "问题的演示"
10715 #. type: Content of: <book><chapter><sect1><sect2><para>
10716 #: ../en/ch09-hook.xml:301
10717 msgid ""
10718 "In principle, a good use for the <literal role=\"hook\">pretxnchangegroup</"
10719 "literal> hook would be to automatically build and test incoming changes "
10720 "before they are accepted into a central repository. This could let you "
10721 "guarantee that nobody can push changes to this repository that <quote>break "
10722 "the build</quote>. But if a client can pull changes while they're being "
10723 "tested, the usefulness of the test is zero; an unsuspecting someone can pull "
10724 "untested changes, potentially breaking their build."
10725 msgstr ""
10727 #. type: Content of: <book><chapter><sect1><sect2><para>
10728 #: ../en/ch09-hook.xml:312
10729 msgid ""
10730 "The safest technological answer to this challenge is to set up such a "
10731 "<quote>gatekeeper</quote> repository as <emphasis>unidirectional</emphasis>. "
10732 "Let it take changes pushed in from the outside, but do not allow anyone to "
10733 "pull changes from it (use the <literal role=\"hook\">preoutgoing</literal> "
10734 "hook to lock it down). Configure a <literal role=\"hook\">changegroup</"
10735 "literal> hook so that if a build or test succeeds, the hook will push the new "
10736 "changes out to another repository that people <emphasis>can</emphasis> pull "
10737 "from."
10738 msgstr ""
10740 #. type: Content of: <book><chapter><sect1><sect2><para>
10741 #: ../en/ch09-hook.xml:324
10742 msgid ""
10743 "In practice, putting a centralised bottleneck like this in place is not often "
10744 "a good idea, and transaction visibility has nothing to do with the problem. "
10745 "As the size of a project&emdash;and the time it takes to build and "
10746 "test&emdash;grows, you rapidly run into a wall with this <quote>try before "
10747 "you buy</quote> approach, where you have more changesets to test than time in "
10748 "which to deal with them. The inevitable result is frustration on the part of "
10749 "all involved."
10750 msgstr ""
10752 #. type: Content of: <book><chapter><sect1><sect2><para>
10753 #: ../en/ch09-hook.xml:335
10754 msgid ""
10755 "An approach that scales better is to get people to build and test before they "
10756 "push, then run automated builds and tests centrally <emphasis>after</"
10757 "emphasis> a push, to be sure all is well. The advantage of this approach is "
10758 "that it does not impose a limit on the rate at which the repository can "
10759 "accept changes."
10760 msgstr ""
10762 #. type: Content of: <book><chapter><sect1><title>
10763 #: ../en/ch09-hook.xml:346
10764 msgid "A short tutorial on using hooks"
10765 msgstr "使用钩子的简短指南"
10767 #. type: Content of: <book><chapter><sect1><para>
10768 #: ../en/ch09-hook.xml:348
10769 msgid ""
10770 "It is easy to write a Mercurial hook. Let's start with a hook that runs when "
10771 "you finish a <command role=\"hg-cmd\">hg commit</command>, and simply prints "
10772 "the hash of the changeset you just created. The hook is called <literal role="
10773 "\"hook\">commit</literal>."
10774 msgstr ""
10776 #. type: Content of: <book><chapter><sect1><para>
10777 #: ../en/ch09-hook.xml:355
10778 msgid "All hooks follow the pattern in this example."
10779 msgstr ""
10781 #. type: Content of: <book><chapter><sect1><para>
10782 #: ../en/ch09-hook.xml:359
10783 msgid ""
10784 "You add an entry to the <literal role=\"rc-hooks\">hooks</literal> section of "
10785 "your <filename role=\"special\">~/.hgrc</filename>. On the left is the name "
10786 "of the event to trigger on; on the right is the action to take. As you can "
10787 "see, you can run an arbitrary shell command in a hook. Mercurial passes "
10788 "extra information to the hook using environment variables (look for "
10789 "<envar>HG_NODE</envar> in the example)."
10790 msgstr ""
10792 #. type: Content of: <book><chapter><sect1><sect2><title>
10793 #: ../en/ch09-hook.xml:369
10794 msgid "Performing multiple actions per event"
10795 msgstr "每个事件执行多个操作"
10797 #. type: Content of: <book><chapter><sect1><sect2><para>
10798 #: ../en/ch09-hook.xml:371
10799 msgid ""
10800 "Quite often, you will want to define more than one hook for a particular kind "
10801 "of event, as shown below."
10802 msgstr ""
10804 #. type: Content of: <book><chapter><sect1><sect2><para>
10805 #: ../en/ch09-hook.xml:376
10806 msgid ""
10807 "Mercurial lets you do this by adding an <emphasis>extension</emphasis> to the "
10808 "end of a hook's name. You extend a hook's name by giving the name of the "
10809 "hook, followed by a full stop (the <quote><literal>.</literal></quote> "
10810 "character), followed by some more text of your choosing. For example, "
10811 "Mercurial will run both <literal>commit.foo</literal> and <literal>commit."
10812 "bar</literal> when the <literal>commit</literal> event occurs."
10813 msgstr ""
10815 #. type: Content of: <book><chapter><sect1><sect2><para>
10816 #: ../en/ch09-hook.xml:387
10817 msgid ""
10818 "To give a well-defined order of execution when there are multiple hooks "
10819 "defined for an event, Mercurial sorts hooks by extension, and executes the "
10820 "hook commands in this sorted order. In the above example, it will execute "
10821 "<literal>commit.bar</literal> before <literal>commit.foo</literal>, and "
10822 "<literal>commit</literal> before both."
10823 msgstr ""
10825 #. type: Content of: <book><chapter><sect1><sect2><para>
10826 #: ../en/ch09-hook.xml:396
10827 msgid ""
10828 "It is a good idea to use a somewhat descriptive extension when you define a "
10829 "new hook. This will help you to remember what the hook was for. If the hook "
10830 "fails, you'll get an error message that contains the hook name and extension, "
10831 "so using a descriptive extension could give you an immediate hint as to why "
10832 "the hook failed (see <xref linkend=\"sec:hook:perm\"/> for an example)."
10833 msgstr ""
10835 #. type: Content of: <book><chapter><sect1><sect2><title>
10836 #: ../en/ch09-hook.xml:407
10837 msgid "Controlling whether an activity can proceed"
10838 msgstr "控制处理的活动"
10840 #. type: Content of: <book><chapter><sect1><sect2><para>
10841 #: ../en/ch09-hook.xml:409
10842 msgid ""
10843 "In our earlier examples, we used the <literal role=\"hook\">commit</literal> "
10844 "hook, which is run after a commit has completed. This is one of several "
10845 "Mercurial hooks that run after an activity finishes. Such hooks have no way "
10846 "of influencing the activity itself."
10847 msgstr ""
10849 #. type: Content of: <book><chapter><sect1><sect2><para>
10850 #: ../en/ch09-hook.xml:416
10851 msgid ""
10852 "Mercurial defines a number of events that occur before an activity starts; or "
10853 "after it starts, but before it finishes. Hooks that trigger on these events "
10854 "have the added ability to choose whether the activity can continue, or will "
10855 "abort."
10856 msgstr ""
10858 #. type: Content of: <book><chapter><sect1><sect2><para>
10859 #: ../en/ch09-hook.xml:422
10860 msgid ""
10861 "The <literal role=\"hook\">pretxncommit</literal> hook runs after a commit "
10862 "has all but completed. In other words, the metadata representing the "
10863 "changeset has been written out to disk, but the transaction has not yet been "
10864 "allowed to complete. The <literal role=\"hook\">pretxncommit</literal> hook "
10865 "has the ability to decide whether the transaction can complete, or must be "
10866 "rolled back."
10867 msgstr ""
10869 #. type: Content of: <book><chapter><sect1><sect2><para>
10870 #: ../en/ch09-hook.xml:431
10871 msgid ""
10872 "If the <literal role=\"hook\">pretxncommit</literal> hook exits with a status "
10873 "code of zero, the transaction is allowed to complete; the commit finishes; "
10874 "and the <literal role=\"hook\">commit</literal> hook is run. If the <literal "
10875 "role=\"hook\">pretxncommit</literal> hook exits with a non-zero status code, "
10876 "the transaction is rolled back; the metadata representing the changeset is "
10877 "erased; and the <literal role=\"hook\">commit</literal> hook is not run."
10878 msgstr ""
10880 #. type: Content of: <book><chapter><sect1><sect2><para>
10881 #: ../en/ch09-hook.xml:443
10882 msgid ""
10883 "The hook in the example above checks that a commit comment contains a bug "
10884 "ID. If it does, the commit can complete. If not, the commit is rolled back."
10885 msgstr ""
10887 #. type: Content of: <book><chapter><sect1><title>
10888 #: ../en/ch09-hook.xml:451
10889 msgid "Writing your own hooks"
10890 msgstr "编写钩子"
10892 #. type: Content of: <book><chapter><sect1><para>
10893 #: ../en/ch09-hook.xml:453
10894 msgid ""
10895 "When you are writing a hook, you might find it useful to run Mercurial either "
10896 "with the <option role=\"hg-opt-global\">-v</option> option, or the <envar "
10897 "role=\"rc-item-ui\">verbose</envar> config item set to <quote>true</quote>. "
10898 "When you do so, Mercurial will print a message before it calls each hook."
10899 msgstr ""
10901 #. type: Content of: <book><chapter><sect1><sect2><title>
10902 #: ../en/ch09-hook.xml:462
10903 msgid "Choosing how your hook should run"
10904 msgstr "选择钩子的执行方式"
10906 #. type: Content of: <book><chapter><sect1><sect2><para>
10907 #: ../en/ch09-hook.xml:464
10908 msgid ""
10909 "You can write a hook either as a normal program&emdash;typically a shell "
10910 "script&emdash;or as a Python function that is executed within the Mercurial "
10911 "process."
10912 msgstr ""
10914 #. type: Content of: <book><chapter><sect1><sect2><para>
10915 #: ../en/ch09-hook.xml:469
10916 msgid ""
10917 "Writing a hook as an external program has the advantage that it requires no "
10918 "knowledge of Mercurial's internals. You can call normal Mercurial commands "
10919 "to get any added information you need. The trade-off is that external hooks "
10920 "are slower than in-process hooks."
10921 msgstr ""
10923 #. type: Content of: <book><chapter><sect1><sect2><para>
10924 #: ../en/ch09-hook.xml:476
10925 msgid ""
10926 "An in-process Python hook has complete access to the Mercurial API, and does "
10927 "not <quote>shell out</quote> to another process, so it is inherently faster "
10928 "than an external hook. It is also easier to obtain much of the information "
10929 "that a hook requires by using the Mercurial API than by running Mercurial "
10930 "commands."
10931 msgstr ""
10933 #. type: Content of: <book><chapter><sect1><sect2><para>
10934 #: ../en/ch09-hook.xml:484
10935 msgid ""
10936 "If you are comfortable with Python, or require high performance, writing your "
10937 "hooks in Python may be a good choice. However, when you have a "
10938 "straightforward hook to write and you don't need to care about performance "
10939 "(probably the majority of hooks), a shell script is perfectly fine."
10940 msgstr ""
10942 #. type: Content of: <book><chapter><sect1><sect2><title>
10943 #: ../en/ch09-hook.xml:493
10944 msgid "Hook parameters"
10945 msgstr "钩子的参数"
10947 #. type: Content of: <book><chapter><sect1><sect2><para>
10948 #: ../en/ch09-hook.xml:495
10949 msgid ""
10950 "Mercurial calls each hook with a set of well-defined parameters. In Python, "
10951 "a parameter is passed as a keyword argument to your hook function. For an "
10952 "external program, a parameter is passed as an environment variable."
10953 msgstr ""
10955 #. type: Content of: <book><chapter><sect1><sect2><para>
10956 #: ../en/ch09-hook.xml:501
10957 msgid ""
10958 "Whether your hook is written in Python or as a shell script, the hook-"
10959 "specific parameter names and values will be the same. A boolean parameter "
10960 "will be represented as a boolean value in Python, but as the number 1 (for "
10961 "<quote>true</quote>) or 0 (for <quote>false</quote>) as an environment "
10962 "variable for an external hook. If a hook parameter is named <literal>foo</"
10963 "literal>, the keyword argument for a Python hook will also be named "
10964 "<literal>foo</literal>, while the environment variable for an external hook "
10965 "will be named <literal>HG_FOO</literal>."
10966 msgstr ""
10968 #. type: Content of: <book><chapter><sect1><sect2><title>
10969 #: ../en/ch09-hook.xml:515
10970 msgid "Hook return values and activity control"
10971 msgstr "钩子的返回值与活动控制"
10973 #. type: Content of: <book><chapter><sect1><sect2><para>
10974 #: ../en/ch09-hook.xml:517
10975 msgid ""
10976 "A hook that executes successfully must exit with a status of zero if "
10977 "external, or return boolean <quote>false</quote> if in-process. Failure is "
10978 "indicated with a non-zero exit status from an external hook, or an in-process "
10979 "hook returning boolean <quote>true</quote>. If an in-process hook raises an "
10980 "exception, the hook is considered to have failed."
10981 msgstr ""
10983 #. type: Content of: <book><chapter><sect1><sect2><para>
10984 #: ../en/ch09-hook.xml:525
10985 msgid ""
10986 "For a hook that controls whether an activity can proceed, zero/false means "
10987 "<quote>allow</quote>, while non-zero/true/exception means <quote>deny</quote>."
10988 msgstr ""
10990 #. type: Content of: <book><chapter><sect1><sect2><title>
10991 #: ../en/ch09-hook.xml:532
10992 msgid "Writing an external hook"
10993 msgstr "编写外部钩子"
10995 #. type: Content of: <book><chapter><sect1><sect2><para>
10996 #: ../en/ch09-hook.xml:534
10997 msgid ""
10998 "When you define an external hook in your <filename role=\"special\">~/.hgrc</"
10999 "filename> and the hook is run, its value is passed to your shell, which "
11000 "interprets it. This means that you can use normal shell constructs in the "
11001 "body of the hook."
11002 msgstr ""
11004 #. type: Content of: <book><chapter><sect1><sect2><para>
11005 #: ../en/ch09-hook.xml:541
11006 msgid ""
11007 "An executable hook is always run with its current directory set to a "
11008 "repository's root directory."
11009 msgstr ""
11011 #. type: Content of: <book><chapter><sect1><sect2><para>
11012 #: ../en/ch09-hook.xml:545
11013 msgid ""
11014 "Each hook parameter is passed in as an environment variable; the name is "
11015 "upper-cased, and prefixed with the string <quote><literal>HG_</literal></"
11016 "quote>."
11017 msgstr ""
11019 #. type: Content of: <book><chapter><sect1><sect2><para>
11020 #: ../en/ch09-hook.xml:550
11021 msgid ""
11022 "With the exception of hook parameters, Mercurial does not set or modify any "
11023 "environment variables when running a hook. This is useful to remember if you "
11024 "are writing a site-wide hook that may be run by a number of different users "
11025 "with differing environment variables set. In multi-user situations, you "
11026 "should not rely on environment variables being set to the values you have in "
11027 "your environment when testing the hook."
11028 msgstr ""
11030 #. type: Content of: <book><chapter><sect1><sect2><title>
11031 #: ../en/ch09-hook.xml:561
11032 msgid "Telling Mercurial to use an in-process hook"
11033 msgstr "让 Mercurial 使用进程内钩子"
11035 #. type: Content of: <book><chapter><sect1><sect2><para>
11036 #: ../en/ch09-hook.xml:563
11037 msgid ""
11038 "The <filename role=\"special\">~/.hgrc</filename> syntax for defining an in-"
11039 "process hook is slightly different than for an executable hook. The value of "
11040 "the hook must start with the text <quote><literal>python:</literal></quote>, "
11041 "and continue with the fully-qualified name of a callable object to use as the "
11042 "hook's value."
11043 msgstr ""
11045 #. type: Content of: <book><chapter><sect1><sect2><para>
11046 #: ../en/ch09-hook.xml:571
11047 msgid ""
11048 "The module in which a hook lives is automatically imported when a hook is "
11049 "run. So long as you have the module name and <envar>PYTHONPATH</envar> "
11050 "right, it should <quote>just work</quote>."
11051 msgstr ""
11053 #. type: Content of: <book><chapter><sect1><sect2><para>
11054 #: ../en/ch09-hook.xml:577
11055 msgid ""
11056 "The following <filename role=\"special\">~/.hgrc</filename> example snippet "
11057 "illustrates the syntax and meaning of the notions we just described."
11058 msgstr ""
11060 #. type: Content of: <book><chapter><sect1><sect2><para>
11061 #: ../en/ch09-hook.xml:583
11062 msgid ""
11063 "When Mercurial runs the <literal>commit.example</literal> hook, it imports "
11064 "<literal>mymodule.submodule</literal>, looks for the callable object named "
11065 "<literal>myhook</literal>, and calls it."
11066 msgstr ""
11068 #. type: Content of: <book><chapter><sect1><sect2><title>
11069 #: ../en/ch09-hook.xml:591
11070 msgid "Writing an in-process hook"
11071 msgstr "编写进程内钩子"
11073 #. type: Content of: <book><chapter><sect1><sect2><para>
11074 #: ../en/ch09-hook.xml:593
11075 msgid ""
11076 "The simplest in-process hook does nothing, but illustrates the basic shape of "
11077 "the hook API:"
11078 msgstr ""
11080 #. type: Content of: <book><chapter><sect1><sect2><para>
11081 #: ../en/ch09-hook.xml:598
11082 msgid ""
11083 "The first argument to a Python hook is always a <literal role=\"py-mod-"
11084 "mercurial.ui\">ui</literal> object. The second is a repository object; at "
11085 "the moment, it is always an instance of <literal role=\"py-mod-mercurial."
11086 "localrepo\">localrepository</literal>. Following these two arguments are "
11087 "other keyword arguments. Which ones are passed in depends on the hook being "
11088 "called, but a hook can ignore arguments it doesn't care about by dropping "
11089 "them into a keyword argument dict, as with <literal>**kwargs</literal> above."
11090 msgstr ""
11092 #. type: Content of: <book><chapter><sect1><title>
11093 #: ../en/ch09-hook.xml:613
11094 msgid "Some hook examples"
11095 msgstr "钩子样例"
11097 #. type: Content of: <book><chapter><sect1><sect2><title>
11098 #: ../en/ch09-hook.xml:616
11099 msgid "Writing meaningful commit messages"
11100 msgstr "编写有意义的提交日志"
11102 #. type: Content of: <book><chapter><sect1><sect2><para>
11103 #: ../en/ch09-hook.xml:618
11104 msgid ""
11105 "It's hard to imagine a useful commit message being very short. The simple "
11106 "<literal role=\"hook\">pretxncommit</literal> hook of the example below will "
11107 "prevent you from committing a changeset with a message that is less than ten "
11108 "bytes long."
11109 msgstr ""
11111 #. type: Content of: <book><chapter><sect1><sect2><title>
11112 #: ../en/ch09-hook.xml:628
11113 msgid "Checking for trailing whitespace"
11114 msgstr "检查行尾空格"
11116 #. type: Content of: <book><chapter><sect1><sect2><para>
11117 #: ../en/ch09-hook.xml:630
11118 msgid ""
11119 "An interesting use of a commit-related hook is to help you to write cleaner "
11120 "code. A simple example of <quote>cleaner code</quote> is the dictum that a "
11121 "change should not add any new lines of text that contain <quote>trailing "
11122 "whitespace</quote>. Trailing whitespace is a series of space and tab "
11123 "characters at the end of a line of text. In most cases, trailing whitespace "
11124 "is unnecessary, invisible noise, but it is occasionally problematic, and "
11125 "people often prefer to get rid of it."
11126 msgstr ""
11128 #. type: Content of: <book><chapter><sect1><sect2><para>
11129 #: ../en/ch09-hook.xml:641
11130 msgid ""
11131 "You can use either the <literal role=\"hook\">precommit</literal> or <literal "
11132 "role=\"hook\">pretxncommit</literal> hook to tell whether you have a trailing "
11133 "whitespace problem. If you use the <literal role=\"hook\">precommit</"
11134 "literal> hook, the hook will not know which files you are committing, so it "
11135 "will have to check every modified file in the repository for trailing white "
11136 "space. If you want to commit a change to just the file <filename>foo</"
11137 "filename>, but the file <filename>bar</filename> contains trailing "
11138 "whitespace, doing a check in the <literal role=\"hook\">precommit</literal> "
11139 "hook will prevent you from committing <filename>foo</filename> due to the "
11140 "problem with <filename>bar</filename>. This doesn't seem right."
11141 msgstr ""
11143 #. type: Content of: <book><chapter><sect1><sect2><para>
11144 #: ../en/ch09-hook.xml:657
11145 msgid ""
11146 "Should you choose the <literal role=\"hook\">pretxncommit</literal> hook, the "
11147 "check won't occur until just before the transaction for the commit "
11148 "completes. This will allow you to check for problems only the exact files "
11149 "that are being committed. However, if you entered the commit message "
11150 "interactively and the hook fails, the transaction will roll back; you'll have "
11151 "to re-enter the commit message after you fix the trailing whitespace and run "
11152 "<command role=\"hg-cmd\">hg commit</command> again."
11153 msgstr ""
11155 #. type: Content of: <book><chapter><sect1><sect2><para>
11156 #: ../en/ch09-hook.xml:670
11157 msgid ""
11158 "In this example, we introduce a simple <literal role=\"hook\">pretxncommit</"
11159 "literal> hook that checks for trailing whitespace. This hook is short, but "
11160 "not very helpful. It exits with an error status if a change adds a line with "
11161 "trailing whitespace to any file, but does not print any information that "
11162 "might help us to identify the offending file or line. It also has the nice "
11163 "property of not paying attention to unmodified lines; only lines that "
11164 "introduce new trailing whitespace cause problems."
11165 msgstr ""
11167 #. type: Content of: <book><chapter><sect1><sect2><para>
11168 #: ../en/ch09-hook.xml:681
11169 msgid ""
11170 "The above version is much more complex, but also more useful. It parses a "
11171 "unified diff to see if any lines add trailing whitespace, and prints the name "
11172 "of the file and the line number of each such occurrence. Even better, if the "
11173 "change adds trailing whitespace, this hook saves the commit comment and "
11174 "prints the name of the save file before exiting and telling Mercurial to roll "
11175 "the transaction back, so you can use the <option role=\"hg-opt-commit\">-l "
11176 "filename</option> option to <command role=\"hg-cmd\">hg commit</command> to "
11177 "reuse the saved commit message once you've corrected the problem."
11178 msgstr ""
11180 #. type: Content of: <book><chapter><sect1><sect2><para>
11181 #: ../en/ch09-hook.xml:695
11182 msgid ""
11183 "As a final aside, note in the example above the use of <command>perl</"
11184 "command>'s in-place editing feature to get rid of trailing whitespace from a "
11185 "file. This is concise and useful enough that I will reproduce it here."
11186 msgstr ""
11188 #. type: Content of: <book><chapter><sect1><title>
11189 #: ../en/ch09-hook.xml:705
11190 msgid "Bundled hooks"
11191 msgstr "内置的钩子"
11193 #. type: Content of: <book><chapter><sect1><para>
11194 #: ../en/ch09-hook.xml:707
11195 msgid ""
11196 "Mercurial ships with several bundled hooks. You can find them in the "
11197 "<filename class=\"directory\">hgext</filename> directory of a Mercurial "
11198 "source tree. If you are using a Mercurial binary package, the hooks will be "
11199 "located in the <filename class=\"directory\">hgext</filename> directory of "
11200 "wherever your package installer put Mercurial."
11201 msgstr ""
11203 #. type: Content of: <book><chapter><sect1><sect2><title>
11204 #: ../en/ch09-hook.xml:716
11205 msgid ""
11206 "<literal role=\"hg-ext\">acl</literal>&emdash;access control for parts of a "
11207 "repository"
11208 msgstr "<literal role=\"hg-ext\">acl</literal>&emdash;版本库的访问控制"
11210 #. type: Content of: <book><chapter><sect1><sect2><para>
11211 #: ../en/ch09-hook.xml:719
11212 msgid ""
11213 "The <literal role=\"hg-ext\">acl</literal> extension lets you control which "
11214 "remote users are allowed to push changesets to a networked server. You can "
11215 "protect any portion of a repository (including the entire repo), so that a "
11216 "specific remote user can push changes that do not affect the protected "
11217 "portion."
11218 msgstr ""
11220 #. type: Content of: <book><chapter><sect1><sect2><para>
11221 #: ../en/ch09-hook.xml:727
11222 msgid ""
11223 "This extension implements access control based on the identity of the user "
11224 "performing a push, <emphasis>not</emphasis> on who committed the changesets "
11225 "they're pushing. It makes sense to use this hook only if you have a locked-"
11226 "down server environment that authenticates remote users, and you want to be "
11227 "sure that only specific users are allowed to push changes to that server."
11228 msgstr ""
11230 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
11231 #: ../en/ch09-hook.xml:737
11232 msgid "Configuring the <literal role=\"hook\">acl</literal> hook"
11233 msgstr "配置 <literal role=\"hook\">acl</literal> 钩子"
11235 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11236 #: ../en/ch09-hook.xml:740
11237 msgid ""
11238 "In order to manage incoming changesets, the <literal role=\"hg-ext\">acl</"
11239 "literal> hook must be used as a <literal role=\"hook\">pretxnchangegroup</"
11240 "literal> hook. This lets it see which files are modified by each incoming "
11241 "changeset, and roll back a group of changesets if they modify "
11242 "<quote>forbidden</quote> files. Example:"
11243 msgstr ""
11245 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11246 #: ../en/ch09-hook.xml:750
11247 msgid ""
11248 "The <literal role=\"hg-ext\">acl</literal> extension is configured using "
11249 "three sections."
11250 msgstr ""
11252 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11253 #: ../en/ch09-hook.xml:754
11254 msgid ""
11255 "The <literal role=\"rc-acl\">acl</literal> section has only one entry, <envar "
11256 "role=\"rc-item-acl\">sources</envar>, which lists the sources of incoming "
11257 "changesets that the hook should pay attention to. You don't normally need to "
11258 "configure this section."
11259 msgstr ""
11261 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11262 #: ../en/ch09-hook.xml:761
11263 msgid ""
11264 "<envar role=\"rc-item-acl\">serve</envar>: Control incoming changesets that "
11265 "are arriving from a remote repository over http or ssh. This is the default "
11266 "value of <envar role=\"rc-item-acl\">sources</envar>, and usually the only "
11267 "setting you'll need for this configuration item."
11268 msgstr ""
11270 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11271 #: ../en/ch09-hook.xml:769
11272 msgid ""
11273 "<envar role=\"rc-item-acl\">pull</envar>: Control incoming changesets that "
11274 "are arriving via a pull from a local repository."
11275 msgstr ""
11277 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11278 #: ../en/ch09-hook.xml:774
11279 msgid ""
11280 "<envar role=\"rc-item-acl\">push</envar>: Control incoming changesets that "
11281 "are arriving via a push from a local repository."
11282 msgstr ""
11284 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11285 #: ../en/ch09-hook.xml:779
11286 msgid ""
11287 "<envar role=\"rc-item-acl\">bundle</envar>: Control incoming changesets that "
11288 "are arriving from another repository via a bundle."
11289 msgstr ""
11291 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11292 #: ../en/ch09-hook.xml:785
11293 msgid ""
11294 "The <literal role=\"rc-acl.allow\">acl.allow</literal> section controls the "
11295 "users that are allowed to add changesets to the repository. If this section "
11296 "is not present, all users that are not explicitly denied are allowed. If "
11297 "this section is present, all users that are not explicitly allowed are denied "
11298 "(so an empty section means that all users are denied)."
11299 msgstr ""
11301 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11302 #: ../en/ch09-hook.xml:794
11303 msgid ""
11304 "The <literal role=\"rc-acl.deny\">acl.deny</literal> section determines which "
11305 "users are denied from adding changesets to the repository. If this section "
11306 "is not present or is empty, no users are denied."
11307 msgstr ""
11309 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11310 #: ../en/ch09-hook.xml:800
11311 msgid ""
11312 "The syntaxes for the <literal role=\"rc-acl.allow\">acl.allow</literal> and "
11313 "<literal role=\"rc-acl.deny\">acl.deny</literal> sections are identical. On "
11314 "the left of each entry is a glob pattern that matches files or directories, "
11315 "relative to the root of the repository; on the right, a user name."
11316 msgstr ""
11318 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11319 #: ../en/ch09-hook.xml:808
11320 msgid ""
11321 "In the following example, the user <literal>docwriter</literal> can only push "
11322 "changes to the <filename class=\"directory\">docs</filename> subtree of the "
11323 "repository, while <literal>intern</literal> can push changes to any file or "
11324 "directory except <filename class=\"directory\">source/sensitive</filename>."
11325 msgstr ""
11327 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
11328 #: ../en/ch09-hook.xml:822 ../en/ch09-hook.xml:1089 ../en/ch09-hook.xml:1279
11329 msgid "Testing and troubleshooting"
11330 msgstr "测试与问题处理"
11332 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11333 #: ../en/ch09-hook.xml:824
11334 msgid ""
11335 "If you want to test the <literal role=\"hg-ext\">acl</literal> hook, run it "
11336 "with Mercurial's debugging output enabled. Since you'll probably be running "
11337 "it on a server where it's not convenient (or sometimes possible) to pass in "
11338 "the <option role=\"hg-opt-global\">--debug</option> option, don't forget that "
11339 "you can enable debugging output in your <filename role=\"special\">~/.hgrc</"
11340 "filename>:"
11341 msgstr ""
11343 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11344 #: ../en/ch09-hook.xml:835
11345 msgid ""
11346 "With this enabled, the <literal role=\"hg-ext\">acl</literal> hook will print "
11347 "enough information to let you figure out why it is allowing or forbidding "
11348 "pushes from specific users."
11349 msgstr ""
11351 #. type: Content of: <book><chapter><sect1><sect2><title>
11352 #: ../en/ch09-hook.xml:844
11353 msgid ""
11354 "<literal role=\"hg-ext\">bugzilla</literal>&emdash;integration with Bugzilla"
11355 msgstr "<literal role=\"hg-ext\">bugzilla</literal>&emdash;与 Bugzilla 的集成"
11357 #. type: Content of: <book><chapter><sect1><sect2><para>
11358 #: ../en/ch09-hook.xml:848
11359 msgid ""
11360 "The <literal role=\"hg-ext\">bugzilla</literal> extension adds a comment to a "
11361 "Bugzilla bug whenever it finds a reference to that bug ID in a commit "
11362 "comment. You can install this hook on a shared server, so that any time a "
11363 "remote user pushes changes to this server, the hook gets run."
11364 msgstr ""
11366 #. type: Content of: <book><chapter><sect1><sect2><para>
11367 #: ../en/ch09-hook.xml:855
11368 msgid ""
11369 "It adds a comment to the bug that looks like this (you can configure the "
11370 "contents of the comment&emdash;see below):"
11371 msgstr ""
11373 #. type: Content of: <book><chapter><sect1><sect2><para>
11374 #: ../en/ch09-hook.xml:864
11375 msgid ""
11376 "The value of this hook is that it automates the process of updating a bug any "
11377 "time a changeset refers to it. If you configure the hook properly, it makes "
11378 "it easy for people to browse straight from a Bugzilla bug to a changeset that "
11379 "refers to that bug."
11380 msgstr ""
11382 #. type: Content of: <book><chapter><sect1><sect2><para>
11383 #: ../en/ch09-hook.xml:871
11384 msgid ""
11385 "You can use the code in this hook as a starting point for some more exotic "
11386 "Bugzilla integration recipes. Here are a few possibilities:"
11387 msgstr ""
11389 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
11390 #: ../en/ch09-hook.xml:876
11391 msgid ""
11392 "Require that every changeset pushed to the server have a valid bug ID in its "
11393 "commit comment. In this case, you'd want to configure the hook as a <literal "
11394 "role=\"hook\">pretxncommit</literal> hook. This would allow the hook to "
11395 "reject changes that didn't contain bug IDs."
11396 msgstr ""
11398 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
11399 #: ../en/ch09-hook.xml:884
11400 msgid ""
11401 "Allow incoming changesets to automatically modify the <emphasis>state</"
11402 "emphasis> of a bug, as well as simply adding a comment. For example, the "
11403 "hook could recognise the string <quote>fixed bug 31337</quote> as indicating "
11404 "that it should update the state of bug 31337 to <quote>requires testing</"
11405 "quote>."
11406 msgstr ""
11408 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
11409 #: ../en/ch09-hook.xml:894
11410 msgid "Configuring the <literal role=\"hook\">bugzilla</literal> hook"
11411 msgstr "配置 <literal role=\"hook\">bugzilla</literal> 钩子"
11413 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11414 #: ../en/ch09-hook.xml:897
11415 msgid ""
11416 "You should configure this hook in your server's <filename role=\"special\">~/."
11417 "hgrc</filename> as an <literal role=\"hook\">incoming</literal> hook, for "
11418 "example as follows:"
11419 msgstr ""
11421 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11422 #: ../en/ch09-hook.xml:905
11423 msgid ""
11424 "Because of the specialised nature of this hook, and because Bugzilla was not "
11425 "written with this kind of integration in mind, configuring this hook is a "
11426 "somewhat involved process."
11427 msgstr ""
11429 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11430 #: ../en/ch09-hook.xml:911
11431 msgid ""
11432 "Before you begin, you must install the MySQL bindings for Python on the host"
11433 "(s) where you'll be running the hook. If this is not available as a binary "
11434 "package for your system, you can download it from <citation>web:mysql-python</"
11435 "citation>."
11436 msgstr ""
11438 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11439 #: ../en/ch09-hook.xml:918
11440 msgid ""
11441 "Configuration information for this hook lives in the <literal role=\"rc-"
11442 "bugzilla\">bugzilla</literal> section of your <filename role=\"special\">~/."
11443 "hgrc</filename>."
11444 msgstr ""
11446 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11447 #: ../en/ch09-hook.xml:923
11448 msgid ""
11449 "<envar role=\"rc-item-bugzilla\">version</envar>: The version of Bugzilla "
11450 "installed on the server. The database schema that Bugzilla uses changes "
11451 "occasionally, so this hook has to know exactly which schema to use. At the "
11452 "moment, the only version supported is <literal>2.16</literal>."
11453 msgstr ""
11455 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11456 #: ../en/ch09-hook.xml:932
11457 msgid ""
11458 "<envar role=\"rc-item-bugzilla\">host</envar>: The hostname of the MySQL "
11459 "server that stores your Bugzilla data. The database must be configured to "
11460 "allow connections from whatever host you are running the <literal role=\"hook"
11461 "\">bugzilla</literal> hook on."
11462 msgstr ""
11464 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11465 #: ../en/ch09-hook.xml:939
11466 msgid ""
11467 "<envar role=\"rc-item-bugzilla\">user</envar>: The username with which to "
11468 "connect to the MySQL server. The database must be configured to allow this "
11469 "user to connect from whatever host you are running the <literal role=\"hook"
11470 "\">bugzilla</literal> hook on. This user must be able to access and modify "
11471 "Bugzilla tables. The default value of this item is <literal>bugs</literal>, "
11472 "which is the standard name of the Bugzilla user in a MySQL database."
11473 msgstr ""
11475 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11476 #: ../en/ch09-hook.xml:950
11477 msgid ""
11478 "<envar role=\"rc-item-bugzilla\">password</envar>: The MySQL password for the "
11479 "user you configured above. This is stored as plain text, so you should make "
11480 "sure that unauthorised users cannot read the <filename role=\"special\">~/."
11481 "hgrc</filename> file where you store this information."
11482 msgstr ""
11484 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11485 #: ../en/ch09-hook.xml:959
11486 msgid ""
11487 "<envar role=\"rc-item-bugzilla\">db</envar>: The name of the Bugzilla "
11488 "database on the MySQL server. The default value of this item is "
11489 "<literal>bugs</literal>, which is the standard name of the MySQL database "
11490 "where Bugzilla stores its data."
11491 msgstr ""
11493 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11494 #: ../en/ch09-hook.xml:966
11495 msgid ""
11496 "<envar role=\"rc-item-bugzilla\">notify</envar>: If you want Bugzilla to send "
11497 "out a notification email to subscribers after this hook has added a comment "
11498 "to a bug, you will need this hook to run a command whenever it updates the "
11499 "database. The command to run depends on where you have installed Bugzilla, "
11500 "but it will typically look something like this, if you have Bugzilla "
11501 "installed in <filename class=\"directory\">/var/www/html/bugzilla</filename>:"
11502 msgstr ""
11504 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11505 #: ../en/ch09-hook.xml:979
11506 msgid ""
11507 "The Bugzilla <literal>processmail</literal> program expects to be given a bug "
11508 "ID (the hook replaces <quote><literal>%s</literal></quote> with the bug ID) "
11509 "and an email address. It also expects to be able to write to some files in "
11510 "the directory that it runs in. If Bugzilla and this hook are not installed "
11511 "on the same machine, you will need to find a way to run <literal>processmail</"
11512 "literal> on the server where Bugzilla is installed."
11513 msgstr ""
11515 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
11516 #: ../en/ch09-hook.xml:994
11517 msgid "Mapping committer names to Bugzilla user names"
11518 msgstr "提交者的名称与 Bugzilla 用户名称的映射"
11520 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11521 #: ../en/ch09-hook.xml:996
11522 msgid ""
11523 "By default, the <literal role=\"hg-ext\">bugzilla</literal> hook tries to use "
11524 "the email address of a changeset's committer as the Bugzilla user name with "
11525 "which to update a bug. If this does not suit your needs, you can map "
11526 "committer email addresses to Bugzilla user names using a <literal role=\"rc-"
11527 "usermap\">usermap</literal> section."
11528 msgstr ""
11530 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11531 #: ../en/ch09-hook.xml:1005
11532 msgid ""
11533 "Each item in the <literal role=\"rc-usermap\">usermap</literal> section "
11534 "contains an email address on the left, and a Bugzilla user name on the right."
11535 msgstr ""
11537 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11538 #: ../en/ch09-hook.xml:1012
11539 msgid ""
11540 "You can either keep the <literal role=\"rc-usermap\">usermap</literal> data "
11541 "in a normal <filename role=\"special\">~/.hgrc</filename>, or tell the "
11542 "<literal role=\"hg-ext\">bugzilla</literal> hook to read the information from "
11543 "an external <filename>usermap</filename> file. In the latter case, you can "
11544 "store <filename>usermap</filename> data by itself in (for example) a user-"
11545 "modifiable repository. This makes it possible to let your users maintain "
11546 "their own <envar role=\"rc-item-bugzilla\">usermap</envar> entries. The main "
11547 "<filename role=\"special\">~/.hgrc</filename> file might look like this:"
11548 msgstr ""
11550 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11551 #: ../en/ch09-hook.xml:1028
11552 msgid ""
11553 "While the <filename>usermap</filename> file that it refers to might look like "
11554 "this:"
11555 msgstr ""
11557 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
11558 #: ../en/ch09-hook.xml:1036
11559 msgid "Configuring the text that gets added to a bug"
11560 msgstr "配置增加到问题中的正文"
11562 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11563 #: ../en/ch09-hook.xml:1038
11564 msgid ""
11565 "You can configure the text that this hook adds as a comment; you specify it "
11566 "in the form of a Mercurial template. Several <filename role=\"special\">~/."
11567 "hgrc</filename> entries (still in the <literal role=\"rc-bugzilla\">bugzilla</"
11568 "literal> section) control this behaviour."
11569 msgstr ""
11571 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11572 #: ../en/ch09-hook.xml:1045
11573 msgid ""
11574 "<literal>strip</literal>: The number of leading path elements to strip from a "
11575 "repository's path name to construct a partial path for a URL. For example, if "
11576 "the repositories on your server live under <filename class=\"directory\">/"
11577 "home/hg/repos</filename>, and you have a repository whose path is <filename "
11578 "class=\"directory\">/home/hg/repos/app/tests</filename>, then setting "
11579 "<literal>strip</literal> to <literal>4</literal> will give a partial path of "
11580 "<filename class=\"directory\">app/tests</filename>. The hook will make this "
11581 "partial path available when expanding a template, as <literal>webroot</"
11582 "literal>."
11583 msgstr ""
11585 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11586 #: ../en/ch09-hook.xml:1059
11587 msgid ""
11588 "<literal>template</literal>: The text of the template to use. In addition to "
11589 "the usual changeset-related variables, this template can use <literal>hgweb</"
11590 "literal> (the value of the <literal>hgweb</literal> configuration item above) "
11591 "and <literal>webroot</literal> (the path constructed using <literal>strip</"
11592 "literal> above)."
11593 msgstr ""
11595 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11596 #: ../en/ch09-hook.xml:1069
11597 msgid ""
11598 "In addition, you can add a <envar role=\"rc-item-web\">baseurl</envar> item "
11599 "to the <literal role=\"rc-web\">web</literal> section of your <filename role="
11600 "\"special\">~/.hgrc</filename>. The <literal role=\"hg-ext\">bugzilla</"
11601 "literal> hook will make this available when expanding a template, as the base "
11602 "string to use when constructing a URL that will let users browse from a "
11603 "Bugzilla comment to view a changeset. Example:"
11604 msgstr ""
11606 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11607 #: ../en/ch09-hook.xml:1081
11608 msgid ""
11609 "Here is an example set of <literal role=\"hg-ext\">bugzilla</literal> hook "
11610 "config information."
11611 msgstr ""
11613 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11614 #: ../en/ch09-hook.xml:1091
11615 msgid ""
11616 "The most common problems with configuring the <literal role=\"hg-ext"
11617 "\">bugzilla</literal> hook relate to running Bugzilla's "
11618 "<filename>processmail</filename> script and mapping committer names to user "
11619 "names."
11620 msgstr ""
11622 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11623 #: ../en/ch09-hook.xml:1097
11624 msgid ""
11625 "Recall from <xref linkend=\"sec:hook:bugzilla:config\"/> above that the user "
11626 "that runs the Mercurial process on the server is also the one that will run "
11627 "the <filename>processmail</filename> script. The <filename>processmail</"
11628 "filename> script sometimes causes Bugzilla to write to files in its "
11629 "configuration directory, and Bugzilla's configuration files are usually owned "
11630 "by the user that your web server runs under."
11631 msgstr ""
11633 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11634 #: ../en/ch09-hook.xml:1108
11635 msgid ""
11636 "You can cause <filename>processmail</filename> to be run with the suitable "
11637 "user's identity using the <command>sudo</command> command. Here is an "
11638 "example entry for a <filename>sudoers</filename> file."
11639 msgstr ""
11641 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11642 #: ../en/ch09-hook.xml:1115
11643 msgid ""
11644 "This allows the <literal>hg_user</literal> user to run a "
11645 "<filename>processmail-wrapper</filename> program under the identity of "
11646 "<literal>httpd_user</literal>."
11647 msgstr ""
11649 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11650 #: ../en/ch09-hook.xml:1120
11651 msgid ""
11652 "This indirection through a wrapper script is necessary, because "
11653 "<filename>processmail</filename> expects to be run with its current directory "
11654 "set to wherever you installed Bugzilla; you can't specify that kind of "
11655 "constraint in a <filename>sudoers</filename> file. The contents of the "
11656 "wrapper script are simple:"
11657 msgstr ""
11659 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11660 #: ../en/ch09-hook.xml:1129
11661 msgid ""
11662 "It doesn't seem to matter what email address you pass to "
11663 "<filename>processmail</filename>."
11664 msgstr ""
11666 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11667 #: ../en/ch09-hook.xml:1133
11668 msgid ""
11669 "If your <literal role=\"rc-usermap\">usermap</literal> is not set up "
11670 "correctly, users will see an error message from the <literal role=\"hg-ext"
11671 "\">bugzilla</literal> hook when they push changes to the server. The error "
11672 "message will look like this:"
11673 msgstr ""
11675 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11676 #: ../en/ch09-hook.xml:1140
11677 msgid ""
11678 "What this means is that the committer's address, <literal>john.q."
11679 "public@example.com</literal>, is not a valid Bugzilla user name, nor does it "
11680 "have an entry in your <literal role=\"rc-usermap\">usermap</literal> that "
11681 "maps it to a valid Bugzilla user name."
11682 msgstr ""
11684 #. type: Content of: <book><chapter><sect1><sect2><title>
11685 #: ../en/ch09-hook.xml:1150
11686 msgid ""
11687 "<literal role=\"hg-ext\">notify</literal>&emdash;send email notifications"
11688 msgstr "<literal role=\"hg-ext\">notify</literal>&emdash;邮件通知"
11690 #. type: Content of: <book><chapter><sect1><sect2><para>
11691 #: ../en/ch09-hook.xml:1153
11692 msgid ""
11693 "Although Mercurial's built-in web server provides RSS feeds of changes in "
11694 "every repository, many people prefer to receive change notifications via "
11695 "email. The <literal role=\"hg-ext\">notify</literal> hook lets you send out "
11696 "notifications to a set of email addresses whenever changesets arrive that "
11697 "those subscribers are interested in."
11698 msgstr ""
11700 #. type: Content of: <book><chapter><sect1><sect2><para>
11701 #: ../en/ch09-hook.xml:1161
11702 msgid ""
11703 "As with the <literal role=\"hg-ext\">bugzilla</literal> hook, the <literal "
11704 "role=\"hg-ext\">notify</literal> hook is template-driven, so you can "
11705 "customise the contents of the notification messages that it sends."
11706 msgstr ""
11708 #. type: Content of: <book><chapter><sect1><sect2><para>
11709 #: ../en/ch09-hook.xml:1167
11710 msgid ""
11711 "By default, the <literal role=\"hg-ext\">notify</literal> hook includes a "
11712 "diff of every changeset that it sends out; you can limit the size of the "
11713 "diff, or turn this feature off entirely. It is useful for letting "
11714 "subscribers review changes immediately, rather than clicking to follow a URL."
11715 msgstr ""
11717 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
11718 #: ../en/ch09-hook.xml:1175
11719 msgid "Configuring the <literal role=\"hg-ext\">notify</literal> hook"
11720 msgstr "配置 <literal role=\"hg-ext\">notify</literal> 钩子"
11722 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11723 #: ../en/ch09-hook.xml:1178
11724 msgid ""
11725 "You can set up the <literal role=\"hg-ext\">notify</literal> hook to send one "
11726 "email message per incoming changeset, or one per incoming group of changesets "
11727 "(all those that arrived in a single pull or push)."
11728 msgstr ""
11730 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11731 #: ../en/ch09-hook.xml:1190
11732 msgid ""
11733 "Configuration information for this hook lives in the <literal role=\"rc-notify"
11734 "\">notify</literal> section of a <filename role=\"special\">~/.hgrc</"
11735 "filename> file."
11736 msgstr ""
11738 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11739 #: ../en/ch09-hook.xml:1195
11740 msgid ""
11741 "<envar role=\"rc-item-notify\">test</envar>: By default, this hook does not "
11742 "send out email at all; instead, it prints the message that it "
11743 "<emphasis>would</emphasis> send. Set this item to <literal>false</literal> "
11744 "to allow email to be sent. The reason that sending of email is turned off by "
11745 "default is that it takes several tries to configure this extension exactly as "
11746 "you would like, and it would be bad form to spam subscribers with a number of "
11747 "<quote>broken</quote> notifications while you debug your configuration."
11748 msgstr ""
11750 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11751 #: ../en/ch09-hook.xml:1207
11752 msgid ""
11753 "<envar role=\"rc-item-notify\">config</envar>: The path to a configuration "
11754 "file that contains subscription information. This is kept separate from the "
11755 "main <filename role=\"special\">~/.hgrc</filename> so that you can maintain "
11756 "it in a repository of its own. People can then clone that repository, update "
11757 "their subscriptions, and push the changes back to your server."
11758 msgstr ""
11760 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11761 #: ../en/ch09-hook.xml:1216
11762 msgid ""
11763 "<envar role=\"rc-item-notify\">strip</envar>: The number of leading path "
11764 "separator characters to strip from a repository's path, when deciding whether "
11765 "a repository has subscribers. For example, if the repositories on your "
11766 "server live in <filename class=\"directory\">/home/hg/repos</filename>, and "
11767 "<literal role=\"hg-ext\">notify</literal> is considering a repository named "
11768 "<filename class=\"directory\">/home/hg/repos/shared/test</filename>, setting "
11769 "<envar role=\"rc-item-notify\">strip</envar> to <literal>4</literal> will "
11770 "cause <literal role=\"hg-ext\">notify</literal> to trim the path it considers "
11771 "down to <filename class=\"directory\">shared/test</filename>, and it will "
11772 "match subscribers against that."
11773 msgstr ""
11775 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11776 #: ../en/ch09-hook.xml:1233
11777 msgid ""
11778 "<envar role=\"rc-item-notify\">template</envar>: The template text to use "
11779 "when sending messages. This specifies both the contents of the message "
11780 "header and its body."
11781 msgstr ""
11783 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11784 #: ../en/ch09-hook.xml:1239
11785 msgid ""
11786 "<envar role=\"rc-item-notify\">maxdiff</envar>: The maximum number of lines "
11787 "of diff data to append to the end of a message. If a diff is longer than "
11788 "this, it is truncated. By default, this is set to 300. Set this to "
11789 "<literal>0</literal> to omit diffs from notification emails."
11790 msgstr ""
11792 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11793 #: ../en/ch09-hook.xml:1248
11794 msgid ""
11795 "<envar role=\"rc-item-notify\">sources</envar>: A list of sources of "
11796 "changesets to consider. This lets you limit <literal role=\"hg-ext\">notify</"
11797 "literal> to only sending out email about changes that remote users pushed "
11798 "into this repository via a server, for example. See <xref linkend=\"sec:hook:"
11799 "sources\"/> for the sources you can specify here."
11800 msgstr ""
11802 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11803 #: ../en/ch09-hook.xml:1259
11804 msgid ""
11805 "If you set the <envar role=\"rc-item-web\">baseurl</envar> item in the "
11806 "<literal role=\"rc-web\">web</literal> section, you can use it in a template; "
11807 "it will be available as <literal>webroot</literal>."
11808 msgstr ""
11810 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11811 #: ../en/ch09-hook.xml:1265
11812 msgid ""
11813 "Here is an example set of <literal role=\"hg-ext\">notify</literal> "
11814 "configuration information."
11815 msgstr ""
11817 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11818 #: ../en/ch09-hook.xml:1271
11819 msgid "This will produce a message that looks like the following:"
11820 msgstr ""
11822 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11823 #: ../en/ch09-hook.xml:1281
11824 msgid ""
11825 "Do not forget that by default, the <literal role=\"hg-ext\">notify</literal> "
11826 "extension <emphasis>will not send any mail</emphasis> until you explicitly "
11827 "configure it to do so, by setting <envar role=\"rc-item-notify\">test</envar> "
11828 "to <literal>false</literal>. Until you do that, it simply prints the message "
11829 "it <emphasis>would</emphasis> send."
11830 msgstr ""
11832 #. type: Content of: <book><chapter><sect1><title>
11833 #: ../en/ch09-hook.xml:1293
11834 msgid "Information for writers of hooks"
11835 msgstr "编写钩子的信息"
11837 #. type: Content of: <book><chapter><sect1><sect2><title>
11838 #: ../en/ch09-hook.xml:1296
11839 msgid "In-process hook execution"
11840 msgstr "进程内钩子的执行"
11842 #. type: Content of: <book><chapter><sect1><sect2><para>
11843 #: ../en/ch09-hook.xml:1298
11844 msgid "An in-process hook is called with arguments of the following form:"
11845 msgstr ""
11847 #. type: Content of: <book><chapter><sect1><sect2><para>
11848 #: ../en/ch09-hook.xml:1302
11849 msgid ""
11850 "The <literal>ui</literal> parameter is a <literal role=\"py-mod-mercurial.ui"
11851 "\">ui</literal> object. The <literal>repo</literal> parameter is a <literal "
11852 "role=\"py-mod-mercurial.localrepo\">localrepository</literal> object. The "
11853 "names and values of the <literal>**kwargs</literal> parameters depend on the "
11854 "hook being invoked, with the following common features:"
11855 msgstr ""
11857 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
11858 #: ../en/ch09-hook.xml:1311
11859 msgid ""
11860 "If a parameter is named <literal>node</literal> or <literal>parentN</"
11861 "literal>, it will contain a hexadecimal changeset ID. The empty string is "
11862 "used to represent <quote>null changeset ID</quote> instead of a string of "
11863 "zeroes."
11864 msgstr ""
11866 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
11867 #: ../en/ch09-hook.xml:1318
11868 msgid ""
11869 "If a parameter is named <literal>url</literal>, it will contain the URL of a "
11870 "remote repository, if that can be determined."
11871 msgstr ""
11873 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
11874 #: ../en/ch09-hook.xml:1323
11875 msgid ""
11876 "Boolean-valued parameters are represented as Python <literal>bool</literal> "
11877 "objects."
11878 msgstr ""
11880 #. type: Content of: <book><chapter><sect1><sect2><para>
11881 #: ../en/ch09-hook.xml:1328
11882 msgid ""
11883 "An in-process hook is called without a change to the process's working "
11884 "directory (unlike external hooks, which are run in the root of the "
11885 "repository). It must not change the process's working directory, or it will "
11886 "cause any calls it makes into the Mercurial API to fail."
11887 msgstr ""
11889 #. type: Content of: <book><chapter><sect1><sect2><para>
11890 #: ../en/ch09-hook.xml:1335
11891 msgid ""
11892 "If a hook returns a boolean <quote>false</quote> value, it is considered to "
11893 "have succeeded. If it returns a boolean <quote>true</quote> value or raises "
11894 "an exception, it is considered to have failed. A useful way to think of the "
11895 "calling convention is <quote>tell me if you fail</quote>."
11896 msgstr ""
11898 #. type: Content of: <book><chapter><sect1><sect2><para>
11899 #: ../en/ch09-hook.xml:1342
11900 msgid ""
11901 "Note that changeset IDs are passed into Python hooks as hexadecimal strings, "
11902 "not the binary hashes that Mercurial's APIs normally use. To convert a hash "
11903 "from hex to binary, use the <literal>bin</literal> function."
11904 msgstr ""
11906 #. type: Content of: <book><chapter><sect1><sect2><title>
11907 #: ../en/ch09-hook.xml:1350
11908 msgid "External hook execution"
11909 msgstr "外部钩子的执行"
11911 #. type: Content of: <book><chapter><sect1><sect2><para>
11912 #: ../en/ch09-hook.xml:1352
11913 msgid ""
11914 "An external hook is passed to the shell of the user running Mercurial. "
11915 "Features of that shell, such as variable substitution and command "
11916 "redirection, are available. The hook is run in the root directory of the "
11917 "repository (unlike in-process hooks, which are run in the same directory that "
11918 "Mercurial was run in)."
11919 msgstr ""
11921 #. type: Content of: <book><chapter><sect1><sect2><para>
11922 #: ../en/ch09-hook.xml:1360
11923 msgid ""
11924 "Hook parameters are passed to the hook as environment variables. Each "
11925 "environment variable's name is converted in upper case and prefixed with the "
11926 "string <quote><literal>HG_</literal></quote>. For example, if the name of a "
11927 "parameter is <quote><literal>node</literal></quote>, the name of the "
11928 "environment variable representing that parameter will be "
11929 "<quote><literal>HG_NODE</literal></quote>."
11930 msgstr ""
11932 #. type: Content of: <book><chapter><sect1><sect2><para>
11933 #: ../en/ch09-hook.xml:1369
11934 msgid ""
11935 "A boolean parameter is represented as the string <quote><literal>1</literal></"
11936 "quote> for <quote>true</quote>, <quote><literal>0</literal></quote> for "
11937 "<quote>false</quote>. If an environment variable is named <envar>HG_NODE</"
11938 "envar>, <envar>HG_PARENT1</envar> or <envar>HG_PARENT2</envar>, it contains a "
11939 "changeset ID represented as a hexadecimal string. The empty string is used "
11940 "to represent <quote>null changeset ID</quote> instead of a string of zeroes. "
11941 "If an environment variable is named <envar>HG_URL</envar>, it will contain "
11942 "the URL of a remote repository, if that can be determined."
11943 msgstr ""
11945 #. type: Content of: <book><chapter><sect1><sect2><para>
11946 #: ../en/ch09-hook.xml:1381
11947 msgid ""
11948 "If a hook exits with a status of zero, it is considered to have succeeded. "
11949 "If it exits with a non-zero status, it is considered to have failed."
11950 msgstr ""
11952 #. type: Content of: <book><chapter><sect1><sect2><title>
11953 #: ../en/ch09-hook.xml:1388
11954 msgid "Finding out where changesets come from"
11955 msgstr "检查修改集来自何处"
11957 #. type: Content of: <book><chapter><sect1><sect2><para>
11958 #: ../en/ch09-hook.xml:1390
11959 msgid ""
11960 "A hook that involves the transfer of changesets between a local repository "
11961 "and another may be able to find out information about the <quote>far side</"
11962 "quote>. Mercurial knows <emphasis>how</emphasis> changes are being "
11963 "transferred, and in many cases <emphasis>where</emphasis> they are being "
11964 "transferred to or from."
11965 msgstr ""
11967 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
11968 #: ../en/ch09-hook.xml:1399
11969 msgid "Sources of changesets"
11970 msgstr "修改集的来源"
11972 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11973 #: ../en/ch09-hook.xml:1401
11974 msgid ""
11975 "Mercurial will tell a hook what means are, or were, used to transfer "
11976 "changesets between repositories. This is provided by Mercurial in a Python "
11977 "parameter named <literal>source</literal>, or an environment variable named "
11978 "<envar>HG_SOURCE</envar>."
11979 msgstr ""
11981 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11982 #: ../en/ch09-hook.xml:1409
11983 msgid ""
11984 "<literal>serve</literal>: Changesets are transferred to or from a remote "
11985 "repository over http or ssh."
11986 msgstr ""
11988 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11989 #: ../en/ch09-hook.xml:1414
11990 msgid ""
11991 "<literal>pull</literal>: Changesets are being transferred via a pull from one "
11992 "repository into another."
11993 msgstr ""
11995 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11996 #: ../en/ch09-hook.xml:1419
11997 msgid ""
11998 "<literal>push</literal>: Changesets are being transferred via a push from one "
11999 "repository into another."
12000 msgstr ""
12002 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
12003 #: ../en/ch09-hook.xml:1424
12004 msgid ""
12005 "<literal>bundle</literal>: Changesets are being transferred to or from a "
12006 "bundle."
12007 msgstr ""
12009 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
12010 #: ../en/ch09-hook.xml:1431
12011 msgid "Where changes are going&emdash;remote repository URLs"
12012 msgstr "修改集要到哪里&emdash;远程版本库的地址"
12014 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
12015 #: ../en/ch09-hook.xml:1434
12016 msgid ""
12017 "When possible, Mercurial will tell a hook the location of the <quote>far "
12018 "side</quote> of an activity that transfers changeset data between "
12019 "repositories. This is provided by Mercurial in a Python parameter named "
12020 "<literal>url</literal>, or an environment variable named <envar>HG_URL</"
12021 "envar>."
12022 msgstr ""
12024 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
12025 #: ../en/ch09-hook.xml:1442
12026 msgid ""
12027 "This information is not always known. If a hook is invoked in a repository "
12028 "that is being served via http or ssh, Mercurial cannot tell where the remote "
12029 "repository is, but it may know where the client is connecting from. In such "
12030 "cases, the URL will take one of the following forms:"
12031 msgstr ""
12033 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
12034 #: ../en/ch09-hook.xml:1449
12035 msgid ""
12036 "<literal>remote:ssh:1.2.3.4</literal>&emdash;remote ssh client, at the IP "
12037 "address <literal>1.2.3.4</literal>."
12038 msgstr ""
12040 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
12041 #: ../en/ch09-hook.xml:1454
12042 msgid ""
12043 "<literal>remote:http:1.2.3.4</literal>&emdash;remote http client, at the IP "
12044 "address <literal>1.2.3.4</literal>. If the client is using SSL, this will be "
12045 "of the form <literal>remote:https:1.2.3.4</literal>."
12046 msgstr ""
12048 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
12049 #: ../en/ch09-hook.xml:1461
12050 msgid "Empty&emdash;no information could be discovered about the remote client."
12051 msgstr ""
12053 #. type: Content of: <book><chapter><sect1><title>
12054 #: ../en/ch09-hook.xml:1470
12055 msgid "Hook reference"
12056 msgstr "钩子参考"
12058 #. type: Content of: <book><chapter><sect1><sect2><title>
12059 #: ../en/ch09-hook.xml:1473
12060 msgid ""
12061 "<literal role=\"hook\">changegroup</literal>&emdash;after remote changesets "
12062 "added"
12063 msgstr "<literal role=\"hook\">changegroup</literal>&emdash;增加远程修改集之后"
12065 #. type: Content of: <book><chapter><sect1><sect2><para>
12066 #: ../en/ch09-hook.xml:1476
12067 msgid ""
12068 "This hook is run after a group of pre-existing changesets has been added to "
12069 "the repository, for example via a <command role=\"hg-cmd\">hg pull</command> "
12070 "or <command role=\"hg-cmd\">hg unbundle</command>. This hook is run once per "
12071 "operation that added one or more changesets. This is in contrast to the "
12072 "<literal role=\"hook\">incoming</literal> hook, which is run once per "
12073 "changeset, regardless of whether the changesets arrive in a group."
12074 msgstr ""
12076 #. type: Content of: <book><chapter><sect1><sect2><para>
12077 #: ../en/ch09-hook.xml:1486
12078 msgid ""
12079 "Some possible uses for this hook include kicking off an automated build or "
12080 "test of the added changesets, updating a bug database, or notifying "
12081 "subscribers that a repository contains new changes."
12082 msgstr ""
12084 #. type: Content of: <book><chapter><sect1><sect2><para>
12085 #: ../en/ch09-hook.xml:1492 ../en/ch09-hook.xml:1532 ../en/ch09-hook.xml:1576
12086 #: ../en/ch09-hook.xml:1618 ../en/ch09-hook.xml:1673 ../en/ch09-hook.xml:1713
12087 #: ../en/ch09-hook.xml:1749 ../en/ch09-hook.xml:1783 ../en/ch09-hook.xml:1846
12088 #: ../en/ch09-hook.xml:1904 ../en/ch09-hook.xml:1940 ../en/ch09-hook.xml:1967
12089 msgid "Parameters to this hook:"
12090 msgstr ""
12092 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12093 #: ../en/ch09-hook.xml:1495 ../en/ch09-hook.xml:1849
12094 msgid ""
12095 "<literal>node</literal>: A changeset ID. The changeset ID of the first "
12096 "changeset in the group that was added. All changesets between this and "
12097 "<literal role=\"tag\">tip</literal>, inclusive, were added by a single "
12098 "<command role=\"hg-cmd\">hg pull</command>, <command role=\"hg-cmd\">hg push</"
12099 "command> or <command role=\"hg-cmd\">hg unbundle</command>."
12100 msgstr ""
12102 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12103 #: ../en/ch09-hook.xml:1504 ../en/ch09-hook.xml:1583 ../en/ch09-hook.xml:1676
12104 #: ../en/ch09-hook.xml:1859
12105 msgid ""
12106 "<literal>source</literal>: A string. The source of these changes. See <xref "
12107 "linkend=\"sec:hook:sources\"/> for details."
12108 msgstr ""
12110 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12111 #: ../en/ch09-hook.xml:1509 ../en/ch09-hook.xml:1588 ../en/ch09-hook.xml:1639
12112 #: ../en/ch09-hook.xml:1681 ../en/ch09-hook.xml:1762 ../en/ch09-hook.xml:1864
12113 msgid ""
12114 "<literal>url</literal>: A URL. The location of the remote repository, if "
12115 "known. See <xref linkend=\"sec:hook:url\"/> for more information."
12116 msgstr ""
12118 #. type: Content of: <book><chapter><sect1><sect2><para>
12119 #: ../en/ch09-hook.xml:1515
12120 msgid ""
12121 "See also: <literal role=\"hook\">incoming</literal> (<xref linkend=\"sec:hook:"
12122 "incoming\"/>), <literal role=\"hook\">prechangegroup</literal> (<xref linkend="
12123 "\"sec:hook:prechangegroup\"/>), <literal role=\"hook\">pretxnchangegroup</"
12124 "literal> (<xref linkend=\"sec:hook:pretxnchangegroup\"/>)"
12125 msgstr ""
12127 #. type: Content of: <book><chapter><sect1><sect2><title>
12128 #: ../en/ch09-hook.xml:1526
12129 msgid ""
12130 "<literal role=\"hook\">commit</literal>&emdash;after a new changeset is "
12131 "created"
12132 msgstr "<literal role=\"hook\">commit</literal>&emdash;创建新修改集之后"
12134 #. type: Content of: <book><chapter><sect1><sect2><para>
12135 #: ../en/ch09-hook.xml:1529
12136 msgid "This hook is run after a new changeset has been created."
12137 msgstr ""
12139 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12140 #: ../en/ch09-hook.xml:1535 ../en/ch09-hook.xml:1907
12141 msgid ""
12142 "<literal>node</literal>: A changeset ID. The changeset ID of the newly "
12143 "committed changeset."
12144 msgstr ""
12146 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12147 #: ../en/ch09-hook.xml:1539 ../en/ch09-hook.xml:1911
12148 msgid ""
12149 "<literal>parent1</literal>: A changeset ID. The changeset ID of the first "
12150 "parent of the newly committed changeset."
12151 msgstr ""
12153 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12154 #: ../en/ch09-hook.xml:1544 ../en/ch09-hook.xml:1916
12155 msgid ""
12156 "<literal>parent2</literal>: A changeset ID. The changeset ID of the second "
12157 "parent of the newly committed changeset."
12158 msgstr ""
12160 #. type: Content of: <book><chapter><sect1><sect2><para>
12161 #: ../en/ch09-hook.xml:1550
12162 msgid ""
12163 "See also: <literal role=\"hook\">precommit</literal> (<xref linkend=\"sec:"
12164 "hook:precommit\"/>), <literal role=\"hook\">pretxncommit</literal> (<xref "
12165 "linkend=\"sec:hook:pretxncommit\"/>)"
12166 msgstr ""
12168 #. type: Content of: <book><chapter><sect1><sect2><title>
12169 #: ../en/ch09-hook.xml:1559
12170 msgid ""
12171 "<literal role=\"hook\">incoming</literal>&emdash;after one remote changeset "
12172 "is added"
12173 msgstr "<literal role=\"hook\">incoming</literal>&emdash;增加远程修改集之后"
12175 #. type: Content of: <book><chapter><sect1><sect2><para>
12176 #: ../en/ch09-hook.xml:1562
12177 msgid ""
12178 "This hook is run after a pre-existing changeset has been added to the "
12179 "repository, for example via a <command role=\"hg-cmd\">hg push</command>. If "
12180 "a group of changesets was added in a single operation, this hook is called "
12181 "once for each added changeset."
12182 msgstr ""
12184 #. type: Content of: <book><chapter><sect1><sect2><para>
12185 #: ../en/ch09-hook.xml:1569
12186 msgid ""
12187 "You can use this hook for the same purposes as the <literal role=\"hook"
12188 "\">changegroup</literal> hook (<xref linkend=\"sec:hook:changegroup\"/>); "
12189 "it's simply more convenient sometimes to run a hook once per group of "
12190 "changesets, while other times it's handier once per changeset."
12191 msgstr ""
12193 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12194 #: ../en/ch09-hook.xml:1579
12195 msgid ""
12196 "<literal>node</literal>: A changeset ID. The ID of the newly added changeset."
12197 msgstr ""
12199 #. type: Content of: <book><chapter><sect1><sect2><para>
12200 #: ../en/ch09-hook.xml:1594
12201 msgid ""
12202 "See also: <literal role=\"hook\">changegroup</literal> (<xref linkend=\"sec:"
12203 "hook:changegroup\"/>) <literal role=\"hook\">prechangegroup</literal> (<xref "
12204 "linkend=\"sec:hook:prechangegroup\"/>), <literal role=\"hook"
12205 "\">pretxnchangegroup</literal> (<xref linkend=\"sec:hook:pretxnchangegroup\"/"
12206 ">)"
12207 msgstr ""
12209 #. type: Content of: <book><chapter><sect1><sect2><title>
12210 #: ../en/ch09-hook.xml:1605
12211 msgid ""
12212 "<literal role=\"hook\">outgoing</literal>&emdash;after changesets are "
12213 "propagated"
12214 msgstr "<literal role=\"hook\">outgoing</literal>&emdash;传播修改集之后"
12216 #. type: Content of: <book><chapter><sect1><sect2><para>
12217 #: ../en/ch09-hook.xml:1608
12218 msgid ""
12219 "This hook is run after a group of changesets has been propagated out of this "
12220 "repository, for example by a <command role=\"hg-cmd\">hg push</command> or "
12221 "<command role=\"hg-cmd\">hg bundle</command> command."
12222 msgstr ""
12224 #. type: Content of: <book><chapter><sect1><sect2><para>
12225 #: ../en/ch09-hook.xml:1614
12226 msgid ""
12227 "One possible use for this hook is to notify administrators that changes have "
12228 "been pulled."
12229 msgstr ""
12231 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12232 #: ../en/ch09-hook.xml:1621
12233 msgid ""
12234 "<literal>node</literal>: A changeset ID. The changeset ID of the first "
12235 "changeset of the group that was sent."
12236 msgstr ""
12238 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12239 #: ../en/ch09-hook.xml:1626
12240 msgid ""
12241 "<literal>source</literal>: A string. The source of the of the operation (see "
12242 "<xref linkend=\"sec:hook:sources\"/>). If a remote client pulled changes "
12243 "from this repository, <literal>source</literal> will be <literal>serve</"
12244 "literal>. If the client that obtained changes from this repository was "
12245 "local, <literal>source</literal> will be <literal>bundle</literal>, "
12246 "<literal>pull</literal>, or <literal>push</literal>, depending on the "
12247 "operation the client performed."
12248 msgstr ""
12250 #. type: Content of: <book><chapter><sect1><sect2><para>
12251 #: ../en/ch09-hook.xml:1645
12252 msgid ""
12253 "See also: <literal role=\"hook\">preoutgoing</literal> (<xref linkend=\"sec:"
12254 "hook:preoutgoing\"/>)"
12255 msgstr ""
12257 #. type: Content of: <book><chapter><sect1><sect2><title>
12258 #: ../en/ch09-hook.xml:1652
12259 msgid ""
12260 "<literal role=\"hook\">prechangegroup</literal>&emdash;before starting to add "
12261 "remote changesets"
12262 msgstr ""
12263 "<literal role=\"hook\">prechangegroup</literal>&emdash;增加远程修改集之前"
12265 #. type: Content of: <book><chapter><sect1><sect2><para>
12266 #: ../en/ch09-hook.xml:1656
12267 msgid ""
12268 "This controlling hook is run before Mercurial begins to add a group of "
12269 "changesets from another repository."
12270 msgstr ""
12272 #. type: Content of: <book><chapter><sect1><sect2><para>
12273 #: ../en/ch09-hook.xml:1660
12274 msgid ""
12275 "This hook does not have any information about the changesets to be added, "
12276 "because it is run before transmission of those changesets is allowed to "
12277 "begin. If this hook fails, the changesets will not be transmitted."
12278 msgstr ""
12280 #. type: Content of: <book><chapter><sect1><sect2><para>
12281 #: ../en/ch09-hook.xml:1666
12282 msgid ""
12283 "One use for this hook is to prevent external changes from being added to a "
12284 "repository. For example, you could use this to <quote>freeze</quote> a "
12285 "server-hosted branch temporarily or permanently so that users cannot push to "
12286 "it, while still allowing a local administrator to modify the repository."
12287 msgstr ""
12289 #. type: Content of: <book><chapter><sect1><sect2><para>
12290 #: ../en/ch09-hook.xml:1687
12291 msgid ""
12292 "See also: <literal role=\"hook\">changegroup</literal> (<xref linkend=\"sec:"
12293 "hook:changegroup\"/>), <literal role=\"hook\">incoming</literal> (<xref "
12294 "linkend=\"sec:hook:incoming\"/>), <literal role=\"hook\">pretxnchangegroup</"
12295 "literal> (<xref linkend=\"sec:hook:pretxnchangegroup\"/>)"
12296 msgstr ""
12298 #. type: Content of: <book><chapter><sect1><sect2><title>
12299 #: ../en/ch09-hook.xml:1698
12300 msgid ""
12301 "<literal role=\"hook\">precommit</literal>&emdash;before starting to commit a "
12302 "changeset"
12303 msgstr "<literal role=\"hook\">precommit</literal>&emdash;提交修改集之前"
12305 #. type: Content of: <book><chapter><sect1><sect2><para>
12306 #: ../en/ch09-hook.xml:1701
12307 msgid ""
12308 "This hook is run before Mercurial begins to commit a new changeset. It is run "
12309 "before Mercurial has any of the metadata for the commit, such as the files to "
12310 "be committed, the commit message, or the commit date."
12311 msgstr ""
12313 #. type: Content of: <book><chapter><sect1><sect2><para>
12314 #: ../en/ch09-hook.xml:1707
12315 msgid ""
12316 "One use for this hook is to disable the ability to commit new changesets, "
12317 "while still allowing incoming changesets. Another is to run a build or test, "
12318 "and only allow the commit to begin if the build or test succeeds."
12319 msgstr ""
12321 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12322 #: ../en/ch09-hook.xml:1716
12323 msgid ""
12324 "<literal>parent1</literal>: A changeset ID. The changeset ID of the first "
12325 "parent of the working directory."
12326 msgstr ""
12328 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12329 #: ../en/ch09-hook.xml:1721
12330 msgid ""
12331 "<literal>parent2</literal>: A changeset ID. The changeset ID of the second "
12332 "parent of the working directory."
12333 msgstr ""
12335 #. type: Content of: <book><chapter><sect1><sect2><para>
12336 #: ../en/ch09-hook.xml:1726
12337 msgid ""
12338 "If the commit proceeds, the parents of the working directory will become the "
12339 "parents of the new changeset."
12340 msgstr ""
12342 #. type: Content of: <book><chapter><sect1><sect2><para>
12343 #: ../en/ch09-hook.xml:1730
12344 msgid ""
12345 "See also: <literal role=\"hook\">commit</literal> (<xref linkend=\"sec:hook:"
12346 "commit\"/>), <literal role=\"hook\">pretxncommit</literal> (<xref linkend="
12347 "\"sec:hook:pretxncommit\"/>)"
12348 msgstr ""
12350 #. type: Content of: <book><chapter><sect1><sect2><title>
12351 #: ../en/ch09-hook.xml:1738
12352 msgid ""
12353 "<literal role=\"hook\">preoutgoing</literal>&emdash;before starting to "
12354 "propagate changesets"
12355 msgstr "<literal role=\"hook\">preoutgoing</literal>&emdash;传播修改集之前"
12357 #. type: Content of: <book><chapter><sect1><sect2><para>
12358 #: ../en/ch09-hook.xml:1741
12359 msgid ""
12360 "This hook is invoked before Mercurial knows the identities of the changesets "
12361 "to be transmitted."
12362 msgstr ""
12364 #. type: Content of: <book><chapter><sect1><sect2><para>
12365 #: ../en/ch09-hook.xml:1745
12366 msgid ""
12367 "One use for this hook is to prevent changes from being transmitted to another "
12368 "repository."
12369 msgstr ""
12371 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12372 #: ../en/ch09-hook.xml:1752
12373 msgid ""
12374 "<literal>source</literal>: A string. The source of the operation that is "
12375 "attempting to obtain changes from this repository (see <xref linkend=\"sec:"
12376 "hook:sources\"/>). See the documentation for the <literal>source</literal> "
12377 "parameter to the <literal role=\"hook\">outgoing</literal> hook, in <xref "
12378 "linkend=\"sec:hook:outgoing\"/>, for possible values of this parameter."
12379 msgstr ""
12381 #. type: Content of: <book><chapter><sect1><sect2><para>
12382 #: ../en/ch09-hook.xml:1768
12383 msgid ""
12384 "See also: <literal role=\"hook\">outgoing</literal> (<xref linkend=\"sec:hook:"
12385 "outgoing\"/>)"
12386 msgstr ""
12388 #. type: Content of: <book><chapter><sect1><sect2><title>
12389 #: ../en/ch09-hook.xml:1775
12390 msgid ""
12391 "<literal role=\"hook\">pretag</literal>&emdash;before tagging a changeset"
12392 msgstr "<literal role=\"hook\">pretag</literal>&emdash;创建标签之前"
12394 #. type: Content of: <book><chapter><sect1><sect2><para>
12395 #: ../en/ch09-hook.xml:1778
12396 msgid ""
12397 "This controlling hook is run before a tag is created. If the hook succeeds, "
12398 "creation of the tag proceeds. If the hook fails, the tag is not created."
12399 msgstr ""
12401 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12402 #: ../en/ch09-hook.xml:1786
12403 msgid ""
12404 "<literal>local</literal>: A boolean. Whether the tag is local to this "
12405 "repository instance (i.e. stored in <filename role=\"special\">.hg/localtags</"
12406 "filename>) or managed by Mercurial (stored in <filename role=\"special\">."
12407 "hgtags</filename>)."
12408 msgstr ""
12410 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12411 #: ../en/ch09-hook.xml:1793
12412 msgid ""
12413 "<literal>node</literal>: A changeset ID. The ID of the changeset to be "
12414 "tagged."
12415 msgstr ""
12417 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12418 #: ../en/ch09-hook.xml:1797
12419 msgid "<literal>tag</literal>: A string. The name of the tag to be created."
12420 msgstr ""
12422 #. type: Content of: <book><chapter><sect1><sect2><para>
12423 #: ../en/ch09-hook.xml:1802
12424 msgid ""
12425 "If the tag to be created is revision-controlled, the <literal role=\"hook"
12426 "\">precommit</literal> and <literal role=\"hook\">pretxncommit</literal> "
12427 "hooks (<xref linkend=\"sec:hook:commit\"/> and <xref linkend=\"sec:hook:"
12428 "pretxncommit\"/>) will also be run."
12429 msgstr ""
12431 #. type: Content of: <book><chapter><sect1><sect2><para>
12432 #: ../en/ch09-hook.xml:1810
12433 msgid ""
12434 "See also: <literal role=\"hook\">tag</literal> (<xref linkend=\"sec:hook:tag"
12435 "\"/>)"
12436 msgstr ""
12438 #. type: Content of: <book><chapter><sect1><sect2><title>
12439 #: ../en/ch09-hook.xml:1815
12440 msgid ""
12441 "<literal role=\"hook\">pretxnchangegroup</literal>&emdash;before completing "
12442 "addition of remote changesets"
12443 msgstr ""
12444 "<literal role=\"hook\">pretxnchangegroup</literal>&emdash;完成增加远程修改集之"
12445 "前"
12447 #. type: Content of: <book><chapter><sect1><sect2><para>
12448 #: ../en/ch09-hook.xml:1819
12449 msgid ""
12450 "This controlling hook is run before a transaction&emdash;that manages the "
12451 "addition of a group of new changesets from outside the repository&emdash;"
12452 "completes. If the hook succeeds, the transaction completes, and all of the "
12453 "changesets become permanent within this repository. If the hook fails, the "
12454 "transaction is rolled back, and the data for the changesets is erased."
12455 msgstr ""
12457 #. type: Content of: <book><chapter><sect1><sect2><para>
12458 #: ../en/ch09-hook.xml:1828
12459 msgid ""
12460 "This hook can access the metadata associated with the almost-added "
12461 "changesets, but it should not do anything permanent with this data. It must "
12462 "also not modify the working directory."
12463 msgstr ""
12465 #. type: Content of: <book><chapter><sect1><sect2><para>
12466 #: ../en/ch09-hook.xml:1834
12467 msgid ""
12468 "While this hook is running, if other Mercurial processes access this "
12469 "repository, they will be able to see the almost-added changesets as if they "
12470 "are permanent. This may lead to race conditions if you do not take steps to "
12471 "avoid them."
12472 msgstr ""
12474 #. type: Content of: <book><chapter><sect1><sect2><para>
12475 #: ../en/ch09-hook.xml:1841
12476 msgid ""
12477 "This hook can be used to automatically vet a group of changesets. If the "
12478 "hook fails, all of the changesets are <quote>rejected</quote> when the "
12479 "transaction rolls back."
12480 msgstr ""
12482 #. type: Content of: <book><chapter><sect1><sect2><para>
12483 #: ../en/ch09-hook.xml:1870
12484 msgid ""
12485 "See also: <literal role=\"hook\">changegroup</literal> (<xref linkend=\"sec:"
12486 "hook:changegroup\"/>), <literal role=\"hook\">incoming</literal> (<xref "
12487 "linkend=\"sec:hook:incoming\"/>), <literal role=\"hook\">prechangegroup</"
12488 "literal> (<xref linkend=\"sec:hook:prechangegroup\"/>)"
12489 msgstr ""
12491 #. type: Content of: <book><chapter><sect1><sect2><title>
12492 #: ../en/ch09-hook.xml:1881
12493 msgid ""
12494 "<literal role=\"hook\">pretxncommit</literal>&emdash;before completing commit "
12495 "of new changeset"
12496 msgstr "<literal role=\"hook\">pretxncommit</literal>&emdash;完成提交之前"
12498 #. type: Content of: <book><chapter><sect1><sect2><para>
12499 #: ../en/ch09-hook.xml:1884
12500 msgid ""
12501 "This controlling hook is run before a transaction&emdash;that manages a new "
12502 "commit&emdash;completes. If the hook succeeds, the transaction completes and "
12503 "the changeset becomes permanent within this repository. If the hook fails, "
12504 "the transaction is rolled back, and the commit data is erased."
12505 msgstr ""
12507 #. type: Content of: <book><chapter><sect1><sect2><para>
12508 #: ../en/ch09-hook.xml:1892
12509 msgid ""
12510 "This hook can access the metadata associated with the almost-new changeset, "
12511 "but it should not do anything permanent with this data. It must also not "
12512 "modify the working directory."
12513 msgstr ""
12515 #. type: Content of: <book><chapter><sect1><sect2><para>
12516 #: ../en/ch09-hook.xml:1898
12517 msgid ""
12518 "While this hook is running, if other Mercurial processes access this "
12519 "repository, they will be able to see the almost-new changeset as if it is "
12520 "permanent. This may lead to race conditions if you do not take steps to "
12521 "avoid them."
12522 msgstr ""
12524 #. type: Content of: <book><chapter><sect1><sect2><para>
12525 #: ../en/ch09-hook.xml:1922
12526 msgid ""
12527 "See also: <literal role=\"hook\">precommit</literal> (<xref linkend=\"sec:"
12528 "hook:precommit\"/>)"
12529 msgstr ""
12530 "参见: <literal role=\"hook\">precommit</literal> (<xref linkend=\"sec:hook:"
12531 "precommit\"/>)"
12533 #. type: Content of: <book><chapter><sect1><sect2><title>
12534 #: ../en/ch09-hook.xml:1929
12535 msgid ""
12536 "<literal role=\"hook\">preupdate</literal>&emdash;before updating or merging "
12537 "working directory"
12538 msgstr ""
12539 "<literal role=\"hook\">preupdate</literal>&emdash;更新或合并工作目录之前"
12541 #. type: Content of: <book><chapter><sect1><sect2><para>
12542 #: ../en/ch09-hook.xml:1932
12543 msgid ""
12544 "This controlling hook is run before an update or merge of the working "
12545 "directory begins. It is run only if Mercurial's normal pre-update checks "
12546 "determine that the update or merge can proceed. If the hook succeeds, the "
12547 "update or merge may proceed; if it fails, the update or merge does not start."
12548 msgstr ""
12550 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12551 #: ../en/ch09-hook.xml:1943
12552 msgid ""
12553 "<literal>parent1</literal>: A changeset ID. The ID of the parent that the "
12554 "working directory is to be updated to. If the working directory is being "
12555 "merged, it will not change this parent."
12556 msgstr ""
12558 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12559 #: ../en/ch09-hook.xml:1949
12560 msgid ""
12561 "<literal>parent2</literal>: A changeset ID. Only set if the working directory "
12562 "is being merged. The ID of the revision that the working directory is being "
12563 "merged with."
12564 msgstr ""
12566 #. type: Content of: <book><chapter><sect1><sect2><para>
12567 #: ../en/ch09-hook.xml:1956
12568 msgid ""
12569 "See also: <literal role=\"hook\">update</literal> (<xref linkend=\"sec:hook:"
12570 "update\"/>)"
12571 msgstr ""
12573 #. type: Content of: <book><chapter><sect1><sect2><title>
12574 #: ../en/ch09-hook.xml:1961
12575 msgid "<literal role=\"hook\">tag</literal>&emdash;after tagging a changeset"
12576 msgstr "<literal role=\"hook\">tag</literal>&emdash;创建标签之后"
12578 #. type: Content of: <book><chapter><sect1><sect2><para>
12579 #: ../en/ch09-hook.xml:1964
12580 msgid "This hook is run after a tag has been created."
12581 msgstr ""
12583 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12584 #: ../en/ch09-hook.xml:1970
12585 msgid ""
12586 "<literal>local</literal>: A boolean. Whether the new tag is local to this "
12587 "repository instance (i.e. stored in <filename role=\"special\">.hg/"
12588 "localtags</filename>) or managed by Mercurial (stored in <filename role="
12589 "\"special\">.hgtags</filename>)."
12590 msgstr ""
12592 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12593 #: ../en/ch09-hook.xml:1978
12594 msgid ""
12595 "<literal>node</literal>: A changeset ID. The ID of the changeset that was "
12596 "tagged."
12597 msgstr ""
12599 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12600 #: ../en/ch09-hook.xml:1982
12601 msgid "<literal>tag</literal>: A string. The name of the tag that was created."
12602 msgstr ""
12604 #. type: Content of: <book><chapter><sect1><sect2><para>
12605 #: ../en/ch09-hook.xml:1987
12606 msgid ""
12607 "If the created tag is revision-controlled, the <literal role=\"hook\">commit</"
12608 "literal> hook (section <xref linkend=\"sec:hook:commit\"/>) is run before "
12609 "this hook."
12610 msgstr ""
12612 #. type: Content of: <book><chapter><sect1><sect2><para>
12613 #: ../en/ch09-hook.xml:1992
12614 msgid ""
12615 "See also: <literal role=\"hook\">pretag</literal> (<xref linkend=\"sec:hook:"
12616 "pretag\"/>)"
12617 msgstr ""
12618 "参见: <literal role=\"hook\">pretag</literal> (<xref linkend=\"sec:hook:pretag"
12619 "\"/>)"
12621 #. type: Content of: <book><chapter><sect1><sect2><title>
12622 #: ../en/ch09-hook.xml:1998
12623 msgid ""
12624 "<literal role=\"hook\">update</literal>&emdash;after updating or merging "
12625 "working directory"
12626 msgstr "<literal role=\"hook\">update</literal>&emdash;更新或合并工作目录之后"
12628 #. type: Content of: <book><chapter><sect1><sect2><para>
12629 #: ../en/ch09-hook.xml:2001
12630 msgid ""
12631 "This hook is run after an update or merge of the working directory "
12632 "completes. Since a merge can fail (if the external <command>hgmerge</"
12633 "command> command fails to resolve conflicts in a file), this hook "
12634 "communicates whether the update or merge completed cleanly."
12635 msgstr ""
12637 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12638 #: ../en/ch09-hook.xml:2009
12639 msgid ""
12640 "<literal>error</literal>: A boolean. Indicates whether the update or merge "
12641 "completed successfully."
12642 msgstr ""
12644 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12645 #: ../en/ch09-hook.xml:2014
12646 msgid ""
12647 "<literal>parent1</literal>: A changeset ID. The ID of the parent that the "
12648 "working directory was updated to. If the working directory was merged, it "
12649 "will not have changed this parent."
12650 msgstr ""
12652 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12653 #: ../en/ch09-hook.xml:2020
12654 msgid ""
12655 "<literal>parent2</literal>: A changeset ID. Only set if the working "
12656 "directory was merged. The ID of the revision that the working directory was "
12657 "merged with."
12658 msgstr ""
12660 #. type: Content of: <book><chapter><sect1><sect2><para>
12661 #: ../en/ch09-hook.xml:2026
12662 msgid ""
12663 "See also: <literal role=\"hook\">preupdate</literal> (<xref linkend=\"sec:"
12664 "hook:preupdate\"/>)"
12665 msgstr ""
12667 #. type: Content of: <book><chapter><title>
12668 #: ../en/ch10-template.xml:5
12669 msgid "Customising the output of Mercurial"
12670 msgstr "定制 Mercurial 的输出"
12672 #. type: Content of: <book><chapter><para>
12673 #: ../en/ch10-template.xml:7
12674 msgid ""
12675 "Mercurial provides a powerful mechanism to let you control how it displays "
12676 "information. The mechanism is based on templates. You can use templates to "
12677 "generate specific output for a single command, or to customise the entire "
12678 "appearance of the built-in web interface."
12679 msgstr ""
12681 #. type: Content of: <book><chapter><sect1><title>
12682 #: ../en/ch10-template.xml:14
12683 msgid "Using precanned output styles"
12684 msgstr "使用预定义的输出样式"
12686 #. type: Content of: <book><chapter><sect1><para>
12687 #: ../en/ch10-template.xml:16
12688 msgid ""
12689 "Packaged with Mercurial are some output styles that you can use immediately. "
12690 "A style is simply a precanned template that someone wrote and installed "
12691 "somewhere that Mercurial can find."
12692 msgstr ""
12694 #. type: Content of: <book><chapter><sect1><para>
12695 #: ../en/ch10-template.xml:21
12696 msgid ""
12697 "Before we take a look at Mercurial's bundled styles, let's review its normal "
12698 "output."
12699 msgstr ""
12701 #. type: Content of: <book><chapter><sect1><para>
12702 #: ../en/ch10-template.xml:26
12703 msgid ""
12704 "This is somewhat informative, but it takes up a lot of space&emdash;five "
12705 "lines of output per changeset. The <literal>compact</literal> style reduces "
12706 "this to three lines, presented in a sparse manner."
12707 msgstr ""
12709 #. type: Content of: <book><chapter><sect1><para>
12710 #: ../en/ch10-template.xml:33
12711 msgid ""
12712 "The <literal>changelog</literal> style hints at the expressive power of "
12713 "Mercurial's templating engine. This style attempts to follow the GNU "
12714 "Project's changelog guidelines<citation>web:changelog</citation>."
12715 msgstr ""
12717 #. type: Content of: <book><chapter><sect1><para>
12718 #: ../en/ch10-template.xml:40
12719 msgid ""
12720 "You will not be shocked to learn that Mercurial's default output style is "
12721 "named <literal>default</literal>."
12722 msgstr ""
12724 #. type: Content of: <book><chapter><sect1><sect2><title>
12725 #: ../en/ch10-template.xml:44
12726 msgid "Setting a default style"
12727 msgstr "设置默认样式"
12729 #. type: Content of: <book><chapter><sect1><sect2><para>
12730 #: ../en/ch10-template.xml:46
12731 msgid ""
12732 "You can modify the output style that Mercurial will use for every command by "
12733 "editing your <filename role=\"special\">~/.hgrc</filename> file, naming the "
12734 "style you would prefer to use."
12735 msgstr ""
12737 #. type: Content of: <book><chapter><sect1><sect2><para>
12738 #: ../en/ch10-template.xml:54
12739 msgid ""
12740 "If you write a style of your own, you can use it by either providing the path "
12741 "to your style file, or copying your style file into a location where "
12742 "Mercurial can find it (typically the <literal>templates</literal> "
12743 "subdirectory of your Mercurial install directory)."
12744 msgstr ""
12746 #. type: Content of: <book><chapter><sect1><title>
12747 #: ../en/ch10-template.xml:63
12748 msgid "Commands that support styles and templates"
12749 msgstr "支持样式和模版的命令"
12751 #. type: Content of: <book><chapter><sect1><para>
12752 #: ../en/ch10-template.xml:65
12753 msgid ""
12754 "All of Mercurial's <quote><literal>log</literal>-like</quote> commands let "
12755 "you use styles and templates: <command role=\"hg-cmd\">hg incoming</command>, "
12756 "<command role=\"hg-cmd\">hg log</command>, <command role=\"hg-cmd\">hg "
12757 "outgoing</command>, and <command role=\"hg-cmd\">hg tip</command>."
12758 msgstr ""
12760 #. type: Content of: <book><chapter><sect1><para>
12761 #: ../en/ch10-template.xml:72
12762 msgid ""
12763 "As I write this manual, these are so far the only commands that support "
12764 "styles and templates. Since these are the most important commands that need "
12765 "customisable output, there has been little pressure from the Mercurial user "
12766 "community to add style and template support to other commands."
12767 msgstr ""
12769 #. type: Content of: <book><chapter><sect1><title>
12770 #: ../en/ch10-template.xml:80
12771 msgid "The basics of templating"
12772 msgstr "模版基础"
12774 #. type: Content of: <book><chapter><sect1><para>
12775 #: ../en/ch10-template.xml:82
12776 msgid ""
12777 "At its simplest, a Mercurial template is a piece of text. Some of the text "
12778 "never changes, while other parts are <emphasis>expanded</emphasis>, or "
12779 "replaced with new text, when necessary."
12780 msgstr ""
12782 #. type: Content of: <book><chapter><sect1><para>
12783 #: ../en/ch10-template.xml:87
12784 msgid ""
12785 "Before we continue, let's look again at a simple example of Mercurial's "
12786 "normal output."
12787 msgstr ""
12789 #. type: Content of: <book><chapter><sect1><para>
12790 #: ../en/ch10-template.xml:92
12791 msgid ""
12792 "Now, let's run the same command, but using a template to change its output."
12793 msgstr ""
12795 #. type: Content of: <book><chapter><sect1><para>
12796 #: ../en/ch10-template.xml:97
12797 msgid ""
12798 "The example above illustrates the simplest possible template; it's just a "
12799 "piece of static text, printed once for each changeset. The <option role=\"hg-"
12800 "opt-log\">--template</option> option to the <command role=\"hg-cmd\">hg log</"
12801 "command> command tells Mercurial to use the given text as the template when "
12802 "printing each changeset."
12803 msgstr ""
12805 #. type: Content of: <book><chapter><sect1><para>
12806 #: ../en/ch10-template.xml:105
12807 msgid ""
12808 "Notice that the template string above ends with the text <quote><literal>\\n</"
12809 "literal></quote>. This is an <emphasis>escape sequence</emphasis>, telling "
12810 "Mercurial to print a newline at the end of each template item. If you omit "
12811 "this newline, Mercurial will run each piece of output together. See <xref "
12812 "linkend=\"sec:template:escape\"/> for more details of escape sequences."
12813 msgstr ""
12815 #. type: Content of: <book><chapter><sect1><para>
12816 #: ../en/ch10-template.xml:113
12817 msgid ""
12818 "A template that prints a fixed string of text all the time isn't very useful; "
12819 "let's try something a bit more complex."
12820 msgstr ""
12822 #. type: Content of: <book><chapter><sect1><para>
12823 #: ../en/ch10-template.xml:119
12824 msgid ""
12825 "As you can see, the string <quote><literal>{desc}</literal></quote> in the "
12826 "template has been replaced in the output with the description of each "
12827 "changeset. Every time Mercurial finds text enclosed in curly braces "
12828 "(<quote><literal>{</literal></quote> and <quote><literal>}</literal></"
12829 "quote>), it will try to replace the braces and text with the expansion of "
12830 "whatever is inside. To print a literal curly brace, you must escape it, as "
12831 "described in <xref linkend=\"sec:template:escape\"/>."
12832 msgstr ""
12834 #. type: Content of: <book><chapter><sect1><title>
12835 #: ../en/ch10-template.xml:131
12836 msgid "Common template keywords"
12837 msgstr "模版关键字"
12839 #. type: Content of: <book><chapter><sect1><para>
12840 #: ../en/ch10-template.xml:133
12841 msgid ""
12842 "You can start writing simple templates immediately using the keywords below."
12843 msgstr ""
12845 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12846 #: ../en/ch10-template.xml:137
12847 msgid ""
12848 "<literal role=\"template-keyword\">author</literal>: String. The unmodified "
12849 "author of the changeset."
12850 msgstr ""
12852 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12853 #: ../en/ch10-template.xml:141
12854 msgid ""
12855 "<literal role=\"template-keyword\">branches</literal>: String. The name of "
12856 "the branch on which the changeset was committed. Will be empty if the branch "
12857 "name was <literal>default</literal>."
12858 msgstr ""
12860 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12861 #: ../en/ch10-template.xml:147
12862 msgid ""
12863 "<literal role=\"template-keyword\">date</literal>: Date information. The "
12864 "date when the changeset was committed. This is <emphasis>not</emphasis> "
12865 "human-readable; you must pass it through a filter that will render it "
12866 "appropriately. See <xref linkend=\"sec:template:filter\"/> for more "
12867 "information on filters. The date is expressed as a pair of numbers. The "
12868 "first number is a Unix UTC timestamp (seconds since January 1, 1970); the "
12869 "second is the offset of the committer's timezone from UTC, in seconds."
12870 msgstr ""
12872 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12873 #: ../en/ch10-template.xml:158
12874 msgid ""
12875 "<literal role=\"template-keyword\">desc</literal>: String. The text of the "
12876 "changeset description."
12877 msgstr ""
12879 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12880 #: ../en/ch10-template.xml:161
12881 msgid ""
12882 "<literal role=\"template-keyword\">files</literal>: List of strings. All "
12883 "files modified, added, or removed by this changeset."
12884 msgstr ""
12886 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12887 #: ../en/ch10-template.xml:166
12888 msgid ""
12889 "<literal role=\"template-keyword\">file_adds</literal>: List of strings. "
12890 "Files added by this changeset."
12891 msgstr ""
12893 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12894 #: ../en/ch10-template.xml:170
12895 msgid ""
12896 "<literal role=\"template-keyword\">file_dels</literal>: List of strings. "
12897 "Files removed by this changeset."
12898 msgstr ""
12900 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12901 #: ../en/ch10-template.xml:174
12902 msgid ""
12903 "<literal role=\"template-keyword\">node</literal>: String. The changeset "
12904 "identification hash, as a 40-character hexadecimal string."
12905 msgstr ""
12907 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12908 #: ../en/ch10-template.xml:178
12909 msgid ""
12910 "<literal role=\"template-keyword\">parents</literal>: List of strings. The "
12911 "parents of the changeset."
12912 msgstr ""
12914 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12915 #: ../en/ch10-template.xml:182
12916 msgid ""
12917 "<literal role=\"template-keyword\">rev</literal>: Integer. The repository-"
12918 "local changeset revision number."
12919 msgstr ""
12921 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12922 #: ../en/ch10-template.xml:186
12923 msgid ""
12924 "<literal role=\"template-keyword\">tags</literal>: List of strings. Any tags "
12925 "associated with the changeset."
12926 msgstr ""
12928 #. type: Content of: <book><chapter><sect1><para>
12929 #: ../en/ch10-template.xml:191
12930 msgid ""
12931 "A few simple experiments will show us what to expect when we use these "
12932 "keywords; you can see the results below."
12933 msgstr ""
12935 #. type: Content of: <book><chapter><sect1><para>
12936 #: ../en/ch10-template.xml:196
12937 msgid ""
12938 "As we noted above, the date keyword does not produce human-readable output, "
12939 "so we must treat it specially. This involves using a <emphasis>filter</"
12940 "emphasis>, about which more in <xref linkend=\"sec:template:filter\"/>."
12941 msgstr ""
12943 #. type: Content of: <book><chapter><sect1><title>
12944 #: ../en/ch10-template.xml:205
12945 msgid "Escape sequences"
12946 msgstr "转义序列"
12948 #. type: Content of: <book><chapter><sect1><para>
12949 #: ../en/ch10-template.xml:207
12950 msgid ""
12951 "Mercurial's templating engine recognises the most commonly used escape "
12952 "sequences in strings. When it sees a backslash (<quote><literal>\\</"
12953 "literal></quote>) character, it looks at the following character and "
12954 "substitutes the two characters with a single replacement, as described below."
12955 msgstr ""
12957 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12958 #: ../en/ch10-template.xml:214
12959 msgid ""
12960 "<literal>\\</literal>: Backslash, <quote><literal>\\</literal></quote>, ASCII "
12961 "134."
12962 msgstr ""
12964 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12965 #: ../en/ch10-template.xml:218
12966 msgid "<literal>\\n</literal>: Newline, ASCII 12."
12967 msgstr ""
12969 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12970 #: ../en/ch10-template.xml:221
12971 msgid "<literal>\\r</literal>: Carriage return, ASCII 15."
12972 msgstr ""
12974 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12975 #: ../en/ch10-template.xml:224
12976 msgid "<literal>\\t</literal>: Tab, ASCII 11."
12977 msgstr ""
12979 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12980 #: ../en/ch10-template.xml:227
12981 msgid "<literal>\\v</literal>: Vertical tab, ASCII 13."
12982 msgstr ""
12984 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12985 #: ../en/ch10-template.xml:230
12986 msgid ""
12987 "<literal>{</literal>: Open curly brace, <quote><literal>{</literal></quote>, "
12988 "ASCII 173."
12989 msgstr ""
12991 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12992 #: ../en/ch10-template.xml:234
12993 msgid ""
12994 "<literal>}</literal>: Close curly brace, <quote><literal>}</literal></quote>, "
12995 "ASCII 175."
12996 msgstr ""
12998 #. type: Content of: <book><chapter><sect1><para>
12999 #: ../en/ch10-template.xml:239
13000 msgid ""
13001 "As indicated above, if you want the expansion of a template to contain a "
13002 "literal <quote><literal>\\</literal></quote>, <quote><literal>{</literal></"
13003 "quote>, or <quote><literal>{</literal></quote> character, you must escape it."
13004 msgstr ""
13006 #. type: Content of: <book><chapter><sect1><title>
13007 #: ../en/ch10-template.xml:247
13008 msgid "Filtering keywords to change their results"
13009 msgstr "通过过滤关键字来修改输出结果"
13011 #. type: Content of: <book><chapter><sect1><para>
13012 #: ../en/ch10-template.xml:249
13013 msgid ""
13014 "Some of the results of template expansion are not immediately easy to use. "
13015 "Mercurial lets you specify an optional chain of <emphasis>filters</emphasis> "
13016 "to modify the result of expanding a keyword. You have already seen a common "
13017 "filter, <literal role=\"template-kw-filt-date\">isodate</literal>, in action "
13018 "above, to make a date readable."
13019 msgstr ""
13021 #. type: Content of: <book><chapter><sect1><para>
13022 #: ../en/ch10-template.xml:256
13023 msgid ""
13024 "Below is a list of the most commonly used filters that Mercurial supports. "
13025 "While some filters can be applied to any text, others can only be used in "
13026 "specific circumstances. The name of each filter is followed first by an "
13027 "indication of where it can be used, then a description of its effect."
13028 msgstr ""
13030 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13031 #: ../en/ch10-template.xml:263
13032 msgid ""
13033 "<literal role=\"template-filter\">addbreaks</literal>: Any text. Add an XHTML "
13034 "<quote><literal>&lt;br/&gt;</literal></quote> tag before the end of every "
13035 "line except the last. For example, <quote><literal>foo\\nbar</literal></"
13036 "quote> becomes <quote><literal>foo&lt;br/&gt;\\nbar</literal></quote>."
13037 msgstr ""
13039 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13040 #: ../en/ch10-template.xml:270
13041 msgid ""
13042 "<literal role=\"template-kw-filt-date\">age</literal>: <literal role="
13043 "\"template-keyword\">date</literal> keyword. Render the age of the date, "
13044 "relative to the current time. Yields a string like <quote><literal>10 "
13045 "minutes</literal></quote>."
13046 msgstr ""
13048 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13049 #: ../en/ch10-template.xml:277
13050 msgid ""
13051 "<literal role=\"template-filter\">basename</literal>: Any text, but most "
13052 "useful for the <literal role=\"template-keyword\">files</literal> keyword and "
13053 "its relatives. Treat the text as a path, and return the basename. For "
13054 "example, <quote><literal>foo/bar/baz</literal></quote> becomes "
13055 "<quote><literal>baz</literal></quote>."
13056 msgstr ""
13058 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13059 #: ../en/ch10-template.xml:286
13060 msgid ""
13061 "<literal role=\"template-kw-filt-date\">date</literal>: <literal role="
13062 "\"template-keyword\">date</literal> keyword. Render a date in a similar "
13063 "format to the Unix <literal role=\"template-keyword\">date</literal> command, "
13064 "but with timezone included. Yields a string like <quote><literal>Mon Sep 04 "
13065 "15:13:13 2006 -0700</literal></quote>."
13066 msgstr ""
13068 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13069 #: ../en/ch10-template.xml:294
13070 msgid ""
13071 "<literal role=\"template-kw-filt-author\">domain</literal>: Any text, but "
13072 "most useful for the <literal role=\"template-keyword\">author</literal> "
13073 "keyword. Finds the first string that looks like an email address, and "
13074 "extract just the domain component. For example, <quote><literal>Bryan "
13075 "O'Sullivan &lt;bos@serpentine.com&gt;</literal></quote> becomes "
13076 "<quote><literal>serpentine.com</literal></quote>."
13077 msgstr ""
13079 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13080 #: ../en/ch10-template.xml:304
13081 msgid ""
13082 "<literal role=\"template-kw-filt-author\">email</literal>: Any text, but most "
13083 "useful for the <literal role=\"template-keyword\">author</literal> keyword. "
13084 "Extract the first string that looks like an email address. For example, "
13085 "<quote><literal>Bryan O'Sullivan &lt;bos@serpentine.com&gt;</literal></quote> "
13086 "becomes <quote><literal>bos@serpentine.com</literal></quote>."
13087 msgstr ""
13089 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13090 #: ../en/ch10-template.xml:313
13091 msgid ""
13092 "<literal role=\"template-filter\">escape</literal>: Any text. Replace the "
13093 "special XML/XHTML characters <quote><literal>&amp;</literal></quote>, "
13094 "<quote><literal>&lt;</literal></quote> and <quote><literal>&gt;</literal></"
13095 "quote> with XML entities."
13096 msgstr ""
13098 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13099 #: ../en/ch10-template.xml:321
13100 msgid ""
13101 "<literal role=\"template-filter\">fill68</literal>: Any text. Wrap the text "
13102 "to fit in 68 columns. This is useful before you pass text through the "
13103 "<literal role=\"template-filter\">tabindent</literal> filter, and still want "
13104 "it to fit in an 80-column fixed-font window."
13105 msgstr ""
13107 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13108 #: ../en/ch10-template.xml:329
13109 msgid ""
13110 "<literal role=\"template-filter\">fill76</literal>: Any text. Wrap the text "
13111 "to fit in 76 columns."
13112 msgstr ""
13114 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13115 #: ../en/ch10-template.xml:333
13116 msgid ""
13117 "<literal role=\"template-filter\">firstline</literal>: Any text. Yield the "
13118 "first line of text, without any trailing newlines."
13119 msgstr ""
13121 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13122 #: ../en/ch10-template.xml:338
13123 msgid ""
13124 "<literal role=\"template-kw-filt-date\">hgdate</literal>: <literal role="
13125 "\"template-keyword\">date</literal> keyword. Render the date as a pair of "
13126 "readable numbers. Yields a string like <quote><literal>1157407993 25200</"
13127 "literal></quote>."
13128 msgstr ""
13130 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13131 #: ../en/ch10-template.xml:345
13132 msgid ""
13133 "<literal role=\"template-kw-filt-date\">isodate</literal>: <literal role="
13134 "\"template-keyword\">date</literal> keyword. Render the date as a text "
13135 "string in ISO 8601 format. Yields a string like <quote><literal>2006-09-04 "
13136 "15:13:13 -0700</literal></quote>."
13137 msgstr ""
13139 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13140 #: ../en/ch10-template.xml:352
13141 msgid ""
13142 "<literal role=\"template-filter\">obfuscate</literal>: Any text, but most "
13143 "useful for the <literal role=\"template-keyword\">author</literal> keyword. "
13144 "Yield the input text rendered as a sequence of XML entities. This helps to "
13145 "defeat some particularly stupid screen-scraping email harvesting spambots."
13146 msgstr ""
13148 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13149 #: ../en/ch10-template.xml:360
13150 msgid ""
13151 "<literal role=\"template-kw-filt-author\">person</literal>: Any text, but "
13152 "most useful for the <literal role=\"template-keyword\">author</literal> "
13153 "keyword. Yield the text before an email address. For example, "
13154 "<quote><literal>Bryan O'Sullivan &lt;bos@serpentine.com&gt;</literal></quote> "
13155 "becomes <quote><literal>Bryan O'Sullivan</literal></quote>."
13156 msgstr ""
13158 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13159 #: ../en/ch10-template.xml:369
13160 msgid ""
13161 "<literal role=\"template-kw-filt-date\">rfc822date</literal>: <literal role="
13162 "\"template-keyword\">date</literal> keyword. Render a date using the same "
13163 "format used in email headers. Yields a string like <quote><literal>Mon, 04 "
13164 "Sep 2006 15:13:13 -0700</literal></quote>."
13165 msgstr ""
13167 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13168 #: ../en/ch10-template.xml:376
13169 msgid ""
13170 "<literal role=\"template-kw-filt-node\">short</literal>: Changeset hash. "
13171 "Yield the short form of a changeset hash, i.e. a 12-character hexadecimal "
13172 "string."
13173 msgstr ""
13175 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13176 #: ../en/ch10-template.xml:381
13177 msgid ""
13178 "<literal role=\"template-kw-filt-date\">shortdate</literal>: <literal role="
13179 "\"template-keyword\">date</literal> keyword. Render the year, month, and day "
13180 "of the date. Yields a string like <quote><literal>2006-09-04</literal></"
13181 "quote>."
13182 msgstr ""
13184 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13185 #: ../en/ch10-template.xml:387
13186 msgid ""
13187 "<literal role=\"template-filter\">strip</literal>: Any text. Strip all "
13188 "leading and trailing whitespace from the string."
13189 msgstr ""
13191 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13192 #: ../en/ch10-template.xml:391
13193 msgid ""
13194 "<literal role=\"template-filter\">tabindent</literal>: Any text. Yield the "
13195 "text, with every line except the first starting with a tab character."
13196 msgstr ""
13198 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13199 #: ../en/ch10-template.xml:396
13200 msgid ""
13201 "<literal role=\"template-filter\">urlescape</literal>: Any text. Escape all "
13202 "characters that are considered <quote>special</quote> by URL parsers. For "
13203 "example, <literal>foo bar</literal> becomes <literal>foo%20bar</literal>."
13204 msgstr ""
13206 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13207 #: ../en/ch10-template.xml:403
13208 msgid ""
13209 "<literal role=\"template-kw-filt-author\">user</literal>: Any text, but most "
13210 "useful for the <literal role=\"template-keyword\">author</literal> keyword. "
13211 "Return the <quote>user</quote> portion of an email address. For example, "
13212 "<quote><literal>Bryan O'Sullivan &lt;bos@serpentine.com&gt;</literal></quote> "
13213 "becomes <quote><literal>bos</literal></quote>."
13214 msgstr ""
13216 #. type: Content of: <book><chapter><sect1><note><para>
13217 #: ../en/ch10-template.xml:416
13218 msgid ""
13219 "If you try to apply a filter to a piece of data that it cannot process, "
13220 "Mercurial will fail and print a Python exception. For example, trying to run "
13221 "the output of the <literal role=\"template-keyword\">desc</literal> keyword "
13222 "into the <literal role=\"template-kw-filt-date\">isodate</literal> filter is "
13223 "not a good idea."
13224 msgstr ""
13226 #. type: Content of: <book><chapter><sect1><sect2><title>
13227 #: ../en/ch10-template.xml:425
13228 msgid "Combining filters"
13229 msgstr "组合过滤器"
13231 #. type: Content of: <book><chapter><sect1><sect2><para>
13232 #: ../en/ch10-template.xml:427
13233 msgid ""
13234 "It is easy to combine filters to yield output in the form you would like. "
13235 "The following chain of filters tidies up a description, then makes sure that "
13236 "it fits cleanly into 68 columns, then indents it by a further 8 characters "
13237 "(at least on Unix-like systems, where a tab is conventionally 8 characters "
13238 "wide)."
13239 msgstr ""
13241 #. type: Content of: <book><chapter><sect1><sect2><para>
13242 #: ../en/ch10-template.xml:436
13243 msgid ""
13244 "Note the use of <quote><literal>\\t</literal></quote> (a tab character) in "
13245 "the template to force the first line to be indented; this is necessary since "
13246 "<literal role=\"template-keyword\">tabindent</literal> indents all lines "
13247 "<emphasis>except</emphasis> the first."
13248 msgstr ""
13250 #. type: Content of: <book><chapter><sect1><sect2><para>
13251 #: ../en/ch10-template.xml:442
13252 msgid ""
13253 "Keep in mind that the order of filters in a chain is significant. The first "
13254 "filter is applied to the result of the keyword; the second to the result of "
13255 "the first filter; and so on. For example, using <literal>fill68|tabindent</"
13256 "literal> gives very different results from <literal>tabindent|fill68</"
13257 "literal>."
13258 msgstr ""
13260 #. type: Content of: <book><chapter><sect1><title>
13261 #: ../en/ch10-template.xml:453
13262 msgid "From templates to styles"
13263 msgstr "从模版到样式"
13265 #. type: Content of: <book><chapter><sect1><para>
13266 #: ../en/ch10-template.xml:455
13267 msgid ""
13268 "A command line template provides a quick and simple way to format some "
13269 "output. Templates can become verbose, though, and it's useful to be able to "
13270 "give a template a name. A style file is a template with a name, stored in a "
13271 "file."
13272 msgstr ""
13274 #. type: Content of: <book><chapter><sect1><para>
13275 #: ../en/ch10-template.xml:460
13276 msgid ""
13277 "More than that, using a style file unlocks the power of Mercurial's "
13278 "templating engine in ways that are not possible using the command line "
13279 "<option role=\"hg-opt-log\">--template</option> option."
13280 msgstr ""
13282 #. type: Content of: <book><chapter><sect1><sect2><title>
13283 #: ../en/ch10-template.xml:466
13284 msgid "The simplest of style files"
13285 msgstr "最简单的样式文件"
13287 #. type: Content of: <book><chapter><sect1><sect2><para>
13288 #: ../en/ch10-template.xml:468
13289 msgid "Our simple style file contains just one line:"
13290 msgstr ""
13292 #. type: Content of: <book><chapter><sect1><sect2><para>
13293 #: ../en/ch10-template.xml:472
13294 msgid ""
13295 "This tells Mercurial, <quote>if you're printing a changeset, use the text on "
13296 "the right as the template</quote>."
13297 msgstr ""
13299 #. type: Content of: <book><chapter><sect1><sect2><title>
13300 #: ../en/ch10-template.xml:478
13301 msgid "Style file syntax"
13302 msgstr "样式文件语法"
13304 #. type: Content of: <book><chapter><sect1><sect2><para>
13305 #: ../en/ch10-template.xml:480
13306 msgid "The syntax rules for a style file are simple."
13307 msgstr ""
13309 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13310 #: ../en/ch10-template.xml:483
13311 msgid "The file is processed one line at a time."
13312 msgstr ""
13314 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13315 #: ../en/ch10-template.xml:486
13316 msgid "Leading and trailing white space are ignored."
13317 msgstr ""
13319 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13320 #: ../en/ch10-template.xml:489
13321 msgid "Empty lines are skipped."
13322 msgstr ""
13324 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13325 #: ../en/ch10-template.xml:491
13326 msgid ""
13327 "If a line starts with either of the characters <quote><literal>#</literal></"
13328 "quote> or <quote><literal>;</literal></quote>, the entire line is treated as "
13329 "a comment, and skipped as if empty."
13330 msgstr ""
13332 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13333 #: ../en/ch10-template.xml:496
13334 msgid ""
13335 "A line starts with a keyword. This must start with an alphabetic character "
13336 "or underscore, and can subsequently contain any alphanumeric character or "
13337 "underscore. (In regexp notation, a keyword must match <literal>[A-Za-z_][A-"
13338 "Za-z0-9_]*</literal>.)"
13339 msgstr ""
13341 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13342 #: ../en/ch10-template.xml:502
13343 msgid ""
13344 "The next element must be an <quote><literal>=</literal></quote> character, "
13345 "which can be preceded or followed by an arbitrary amount of white space."
13346 msgstr ""
13348 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13349 #: ../en/ch10-template.xml:507
13350 msgid ""
13351 "If the rest of the line starts and ends with matching quote characters "
13352 "(either single or double quote), it is treated as a template body."
13353 msgstr ""
13355 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13356 #: ../en/ch10-template.xml:511
13357 msgid ""
13358 "If the rest of the line <emphasis>does not</emphasis> start with a quote "
13359 "character, it is treated as the name of a file; the contents of this file "
13360 "will be read and used as a template body."
13361 msgstr ""
13363 #. type: Content of: <book><chapter><sect1><title>
13364 #: ../en/ch10-template.xml:520
13365 msgid "Style files by example"
13366 msgstr "样式文件例子"
13368 #. type: Content of: <book><chapter><sect1><para>
13369 #: ../en/ch10-template.xml:522
13370 msgid ""
13371 "To illustrate how to write a style file, we will construct a few by example. "
13372 "Rather than provide a complete style file and walk through it, we'll mirror "
13373 "the usual process of developing a style file by starting with something very "
13374 "simple, and walking through a series of successively more complete examples."
13375 msgstr ""
13377 #. type: Content of: <book><chapter><sect1><sect2><title>
13378 #: ../en/ch10-template.xml:529
13379 msgid "Identifying mistakes in style files"
13380 msgstr "在样式文件中定位错误"
13382 #. type: Content of: <book><chapter><sect1><sect2><para>
13383 #: ../en/ch10-template.xml:531
13384 msgid ""
13385 "If Mercurial encounters a problem in a style file you are working on, it "
13386 "prints a terse error message that, once you figure out what it means, is "
13387 "actually quite useful."
13388 msgstr ""
13390 #. type: Content of: <book><chapter><sect1><sect2><para>
13391 #: ../en/ch10-template.xml:537
13392 msgid ""
13393 "Notice that <filename>broken.style</filename> attempts to define a "
13394 "<literal>changeset</literal> keyword, but forgets to give any content for it. "
13395 "When instructed to use this style file, Mercurial promptly complains."
13396 msgstr ""
13398 #. type: Content of: <book><chapter><sect1><sect2><para>
13399 #: ../en/ch10-template.xml:544
13400 msgid "This error message looks intimidating, but it is not too hard to follow."
13401 msgstr ""
13403 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13404 #: ../en/ch10-template.xml:548
13405 msgid ""
13406 "The first component is simply Mercurial's way of saying <quote>I am giving "
13407 "up</quote>."
13408 msgstr ""
13410 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13411 #: ../en/ch10-template.xml:552
13412 msgid "Next comes the name of the style file that contains the error."
13413 msgstr ""
13415 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13416 #: ../en/ch10-template.xml:556
13417 msgid ""
13418 "Following the file name is the line number where the error was encountered."
13419 msgstr ""
13421 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13422 #: ../en/ch10-template.xml:560
13423 msgid "Finally, a description of what went wrong."
13424 msgstr ""
13426 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13427 #: ../en/ch10-template.xml:564
13428 msgid ""
13429 "The description of the problem is not always clear (as in this case), but "
13430 "even when it is cryptic, it is almost always trivial to visually inspect the "
13431 "offending line in the style file and see what is wrong."
13432 msgstr ""
13434 #. type: Content of: <book><chapter><sect1><sect2><title>
13435 #: ../en/ch10-template.xml:572
13436 msgid "Uniquely identifying a repository"
13437 msgstr "版本库的唯一标识"
13439 #. type: Content of: <book><chapter><sect1><sect2><para>
13440 #: ../en/ch10-template.xml:574
13441 msgid ""
13442 "If you would like to be able to identify a Mercurial repository <quote>fairly "
13443 "uniquely</quote> using a short string as an identifier, you can use the first "
13444 "revision in the repository."
13445 msgstr ""
13447 #. type: Content of: <book><chapter><sect1><sect2><para>
13448 #: ../en/ch10-template.xml:581
13449 msgid ""
13450 "This is not guaranteed to be unique, but it is nevertheless useful in many "
13451 "cases."
13452 msgstr ""
13454 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13455 #: ../en/ch10-template.xml:584
13456 msgid ""
13457 "It will not work in a completely empty repository, because such a repository "
13458 "does not have a revision zero."
13459 msgstr ""
13461 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13462 #: ../en/ch10-template.xml:588
13463 msgid ""
13464 "Neither will it work in the (extremely rare) case where a repository is a "
13465 "merge of two or more formerly independent repositories, and you still have "
13466 "those repositories around."
13467 msgstr ""
13469 #. type: Content of: <book><chapter><sect1><sect2><para>
13470 #: ../en/ch10-template.xml:593
13471 msgid "Here are some uses to which you could put this identifier:"
13472 msgstr ""
13474 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13475 #: ../en/ch10-template.xml:596
13476 msgid ""
13477 "As a key into a table for a database that manages repositories on a server."
13478 msgstr ""
13480 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13481 #: ../en/ch10-template.xml:599
13482 msgid ""
13483 "As half of a {<emphasis>repository ID</emphasis>, <emphasis>revision ID</"
13484 "emphasis>} tuple. Save this information away when you run an automated build "
13485 "or other activity, so that you can <quote>replay</quote> the build later if "
13486 "necessary."
13487 msgstr ""
13489 #. type: Content of: <book><chapter><sect1><sect2><title>
13490 #: ../en/ch10-template.xml:608
13491 msgid "Mimicking Subversion's output"
13492 msgstr "模仿 Subversion 的输出"
13495 #. type: Content of: <book><chapter><sect1><sect2><para>
13496 #: ../en/ch10-template.xml:610
13497 msgid ""
13498 "Let's try to emulate the default output format used by another revision "
13499 "control tool, Subversion."
13500 msgstr ""
13503 #. type: Content of: <book><chapter><sect1><sect2><para>
13504 #: ../en/ch10-template.xml:615
13505 msgid ""
13506 "Since Subversion's output style is fairly simple, it is easy to copy-and-"
13507 "paste a hunk of its output into a file, and replace the text produced above "
13508 "by Subversion with the template values we'd like to see expanded."
13509 msgstr ""
13511 #. type: Content of: <book><chapter><sect1><sect2><para>
13512 #: ../en/ch10-template.xml:622
13513 msgid ""
13514 "There are a few small ways in which this template deviates from the output "
13515 "produced by Subversion."
13516 msgstr ""
13518 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13519 #: ../en/ch10-template.xml:625
13520 msgid ""
13521 "Subversion prints a <quote>readable</quote> date (the <quote><literal>Wed, 27 "
13522 "Sep 2006</literal></quote> in the example output above) in parentheses. "
13523 "Mercurial's templating engine does not provide a way to display a date in "
13524 "this format without also printing the time and time zone."
13525 msgstr ""
13527 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13528 #: ../en/ch10-template.xml:632
13529 msgid ""
13530 "We emulate Subversion's printing of <quote>separator</quote> lines full of "
13531 "<quote><literal>-</literal></quote> characters by ending the template with "
13532 "such a line. We use the templating engine's <literal role=\"template-keyword"
13533 "\">header</literal> keyword to print a separator line as the first line of "
13534 "output (see below), thus achieving similar output to Subversion."
13535 msgstr ""
13537 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13538 #: ../en/ch10-template.xml:641
13539 msgid ""
13540 "Subversion's output includes a count in the header of the number of lines in "
13541 "the commit message. We cannot replicate this in Mercurial; the templating "
13542 "engine does not currently provide a filter that counts the number of lines "
13543 "the template generates."
13544 msgstr ""
13547 #. type: Content of: <book><chapter><sect1><sect2><para>
13548 #: ../en/ch10-template.xml:647
13549 msgid ""
13550 "It took me no more than a minute or two of work to replace literal text from "
13551 "an example of Subversion's output with some keywords and filters to give the "
13552 "template above. The style file simply refers to the template."
13553 msgstr ""
13555 #. type: Content of: <book><chapter><sect1><sect2><para>
13556 #: ../en/ch10-template.xml:654
13557 msgid ""
13558 "We could have included the text of the template file directly in the style "
13559 "file by enclosing it in quotes and replacing the newlines with "
13560 "<quote><literal>\\n</literal></quote> sequences, but it would have made the "
13561 "style file too difficult to read. Readability is a good guide when you're "
13562 "trying to decide whether some text belongs in a style file, or in a template "
13563 "file that the style file points to. If the style file will look too big or "
13564 "cluttered if you insert a literal piece of text, drop it into a template "
13565 "instead."
13566 msgstr ""
13568 #. type: Content of: <book><chapter><title>
13569 #: ../en/ch11-mq.xml:5
13570 msgid "Managing change with Mercurial Queues"
13571 msgstr "使用 MQ 管理修改"
13573 #. type: Content of: <book><chapter><sect1><title>
13574 #: ../en/ch11-mq.xml:8
13575 msgid "The patch management problem"
13576 msgstr "补丁的管理问题"
13578 #. type: Content of: <book><chapter><sect1><para>
13579 #: ../en/ch11-mq.xml:10
13580 msgid ""
13581 "Here is a common scenario: you need to install a software package from "
13582 "source, but you find a bug that you must fix in the source before you can "
13583 "start using the package. You make your changes, forget about the package for "
13584 "a while, and a few months later you need to upgrade to a newer version of the "
13585 "package. If the newer version of the package still has the bug, you must "
13586 "extract your fix from the older source tree and apply it against the newer "
13587 "version. This is a tedious task, and it's easy to make mistakes."
13588 msgstr ""
13590 #. type: Content of: <book><chapter><sect1><para>
13591 #: ../en/ch11-mq.xml:20
13592 msgid ""
13593 "This is a simple case of the <quote>patch management</quote> problem. You "
13594 "have an <quote>upstream</quote> source tree that you can't change; you need "
13595 "to make some local changes on top of the upstream tree; and you'd like to be "
13596 "able to keep those changes separate, so that you can apply them to newer "
13597 "versions of the upstream source."
13598 msgstr ""
13600 #. type: Content of: <book><chapter><sect1><para>
13601 #: ../en/ch11-mq.xml:27
13602 msgid ""
13603 "The patch management problem arises in many situations. Probably the most "
13604 "visible is that a user of an open source software project will contribute a "
13605 "bug fix or new feature to the project's maintainers in the form of a patch."
13606 msgstr ""
13608 #. type: Content of: <book><chapter><sect1><para>
13609 #: ../en/ch11-mq.xml:32
13610 msgid ""
13611 "Distributors of operating systems that include open source software often "
13612 "need to make changes to the packages they distribute so that they will build "
13613 "properly in their environments."
13614 msgstr ""
13616 #. type: Content of: <book><chapter><sect1><para>
13617 #: ../en/ch11-mq.xml:37
13618 msgid ""
13619 "When you have few changes to maintain, it is easy to manage a single patch "
13620 "using the standard <command>diff</command> and <command>patch</command> "
13621 "programs (see <xref linkend=\"sec:mq:patch\"/> for a discussion of these "
13622 "tools). Once the number of changes grows, it starts to make sense to maintain "
13623 "patches as discrete <quote>chunks of work,</quote> so that for example a "
13624 "single patch will contain only one bug fix (the patch might modify several "
13625 "files, but it's doing <quote>only one thing</quote>), and you may have a "
13626 "number of such patches for different bugs you need fixed and local changes "
13627 "you require. In this situation, if you submit a bug fix patch to the "
13628 "upstream maintainers of a package and they include your fix in a subsequent "
13629 "release, you can simply drop that single patch when you're updating to the "
13630 "newer release."
13631 msgstr ""
13633 #. type: Content of: <book><chapter><sect1><para>
13634 #: ../en/ch11-mq.xml:52
13635 msgid ""
13636 "Maintaining a single patch against an upstream tree is a little tedious and "
13637 "error-prone, but not difficult. However, the complexity of the problem grows "
13638 "rapidly as the number of patches you have to maintain increases. With more "
13639 "than a tiny number of patches in hand, understanding which ones you have "
13640 "applied and maintaining them moves from messy to overwhelming."
13641 msgstr ""
13643 #. type: Content of: <book><chapter><sect1><para>
13644 #: ../en/ch11-mq.xml:59
13645 msgid ""
13646 "Fortunately, Mercurial includes a powerful extension, Mercurial Queues (or "
13647 "simply <quote>MQ</quote>), that massively simplifies the patch management "
13648 "problem."
13649 msgstr ""
13651 #. type: Content of: <book><chapter><sect1><title>
13652 #: ../en/ch11-mq.xml:65
13653 msgid "The prehistory of Mercurial Queues"
13654 msgstr "MQ 的历史"
13656 #. type: Content of: <book><chapter><sect1><para>
13657 #: ../en/ch11-mq.xml:67
13658 msgid ""
13659 "During the late 1990s, several Linux kernel developers started to maintain "
13660 "<quote>patch series</quote> that modified the behaviour of the Linux kernel. "
13661 "Some of these series were focused on stability, some on feature coverage, and "
13662 "others were more speculative."
13663 msgstr ""
13665 #. type: Content of: <book><chapter><sect1><para>
13666 #: ../en/ch11-mq.xml:73
13667 msgid ""
13668 "The sizes of these patch series grew rapidly. In 2002, Andrew Morton "
13669 "published some shell scripts he had been using to automate the task of "
13670 "managing his patch queues. Andrew was successfully using these scripts to "
13671 "manage hundreds (sometimes thousands) of patches on top of the Linux kernel."
13672 msgstr ""
13674 #. type: Content of: <book><chapter><sect1><sect2><title>
13675 #: ../en/ch11-mq.xml:80
13676 msgid "A patchwork quilt"
13677 msgstr ""
13679 #. type: Content of: <book><chapter><sect1><sect2><para>
13680 #: ../en/ch11-mq.xml:82
13681 msgid ""
13682 "In early 2003, Andreas Gruenbacher and Martin Quinson borrowed the approach "
13683 "of Andrew's scripts and published a tool called <quote>patchwork quilt</"
13684 "quote> <citation>web:quilt</citation>, or simply <quote>quilt</quote> (see "
13685 "<citation>gruenbacher:2005</citation> for a paper describing it). Because "
13686 "quilt substantially automated patch management, it rapidly gained a large "
13687 "following among open source software developers."
13688 msgstr ""
13690 #. type: Content of: <book><chapter><sect1><sect2><para>
13691 #: ../en/ch11-mq.xml:91
13692 msgid ""
13693 "Quilt manages a <emphasis>stack of patches</emphasis> on top of a directory "
13694 "tree. To begin, you tell quilt to manage a directory tree, and tell it which "
13695 "files you want to manage; it stores away the names and contents of those "
13696 "files. To fix a bug, you create a new patch (using a single command), edit "
13697 "the files you need to fix, then <quote>refresh</quote> the patch."
13698 msgstr ""
13700 #. type: Content of: <book><chapter><sect1><sect2><para>
13701 #: ../en/ch11-mq.xml:99
13702 msgid ""
13703 "The refresh step causes quilt to scan the directory tree; it updates the "
13704 "patch with all of the changes you have made. You can create another patch on "
13705 "top of the first, which will track the changes required to modify the tree "
13706 "from <quote>tree with one patch applied</quote> to <quote>tree with two "
13707 "patches applied</quote>."
13708 msgstr ""
13710 #. type: Content of: <book><chapter><sect1><sect2><para>
13711 #: ../en/ch11-mq.xml:106
13712 msgid ""
13713 "You can <emphasis>change</emphasis> which patches are applied to the tree. "
13714 "If you <quote>pop</quote> a patch, the changes made by that patch will vanish "
13715 "from the directory tree. Quilt remembers which patches you have popped, "
13716 "though, so you can <quote>push</quote> a popped patch again, and the "
13717 "directory tree will be restored to contain the modifications in the patch. "
13718 "Most importantly, you can run the <quote>refresh</quote> command at any time, "
13719 "and the topmost applied patch will be updated. This means that you can, at "
13720 "any time, change both which patches are applied and what modifications those "
13721 "patches make."
13722 msgstr ""
13724 #. type: Content of: <book><chapter><sect1><sect2><para>
13725 #: ../en/ch11-mq.xml:118
13726 msgid ""
13727 "Quilt knows nothing about revision control tools, so it works equally well on "
13728 "top of an unpacked tarball or a Subversion working copy."
13729 msgstr ""
13731 #. type: Content of: <book><chapter><sect1><sect2><title>
13732 #: ../en/ch11-mq.xml:124
13733 msgid "From patchwork quilt to Mercurial Queues"
13734 msgstr "从 patchwork quilt 到 MQ"
13736 #. type: Content of: <book><chapter><sect1><sect2><para>
13737 #: ../en/ch11-mq.xml:126
13738 msgid ""
13739 "In mid-2005, Chris Mason took the features of quilt and wrote an extension "
13740 "that he called Mercurial Queues, which added quilt-like behaviour to "
13741 "Mercurial."
13742 msgstr ""
13744 #. type: Content of: <book><chapter><sect1><sect2><para>
13745 #: ../en/ch11-mq.xml:130
13746 msgid ""
13747 "The key difference between quilt and MQ is that quilt knows nothing about "
13748 "revision control systems, while MQ is <emphasis>integrated</emphasis> into "
13749 "Mercurial. Each patch that you push is represented as a Mercurial "
13750 "changeset. Pop a patch, and the changeset goes away."
13751 msgstr ""
13753 #. type: Content of: <book><chapter><sect1><sect2><para>
13754 #: ../en/ch11-mq.xml:136
13755 msgid ""
13756 "Because quilt does not care about revision control tools, it is still a "
13757 "tremendously useful piece of software to know about for situations where you "
13758 "cannot use Mercurial and MQ."
13759 msgstr ""
13761 #. type: Content of: <book><chapter><sect1><title>
13762 #: ../en/ch11-mq.xml:144
13763 msgid "The huge advantage of MQ"
13764 msgstr "MQ 的巨大优势"
13766 #. type: Content of: <book><chapter><sect1><para>
13767 #: ../en/ch11-mq.xml:146
13768 msgid ""
13769 "I cannot overstate the value that MQ offers through the unification of "
13770 "patches and revision control."
13771 msgstr ""
13773 #. type: Content of: <book><chapter><sect1><para>
13774 #: ../en/ch11-mq.xml:149
13775 msgid ""
13776 "A major reason that patches have persisted in the free software and open "
13777 "source world&emdash;in spite of the availability of increasingly capable "
13778 "revision control tools over the years&emdash;is the <emphasis>agility</"
13779 "emphasis> they offer."
13780 msgstr ""
13782 #. type: Content of: <book><chapter><sect1><para>
13783 #: ../en/ch11-mq.xml:155
13784 msgid ""
13785 "Traditional revision control tools make a permanent, irreversible record of "
13786 "everything that you do. While this has great value, it's also somewhat "
13787 "stifling. If you want to perform a wild-eyed experiment, you have to be "
13788 "careful in how you go about it, or you risk leaving unneeded&emdash;or worse, "
13789 "misleading or destabilising&emdash;traces of your missteps and errors in the "
13790 "permanent revision record."
13791 msgstr ""
13793 #. type: Content of: <book><chapter><sect1><para>
13794 #: ../en/ch11-mq.xml:163
13795 msgid ""
13796 "By contrast, MQ's marriage of distributed revision control with patches makes "
13797 "it much easier to isolate your work. Your patches live on top of normal "
13798 "revision history, and you can make them disappear or reappear at will. If "
13799 "you don't like a patch, you can drop it. If a patch isn't quite as you want "
13800 "it to be, simply fix it&emdash;as many times as you need to, until you have "
13801 "refined it into the form you desire."
13802 msgstr ""
13804 #. type: Content of: <book><chapter><sect1><para>
13805 #: ../en/ch11-mq.xml:171
13806 msgid ""
13807 "As an example, the integration of patches with revision control makes "
13808 "understanding patches and debugging their effects&emdash;and their interplay "
13809 "with the code they're based on&emdash;<emphasis>enormously</emphasis> easier. "
13810 "Since every applied patch has an associated changeset, you can give <command "
13811 "role=\"hg-cmd\">hg log</command> a file name to see which changesets and "
13812 "patches affected the file. You can use the <command role=\"hg-cmd\">hg "
13813 "bisect</command> command to binary-search through all changesets and applied "
13814 "patches to see where a bug got introduced or fixed. You can use the <command "
13815 "role=\"hg-cmd\">hg annotate</command> command to see which changeset or patch "
13816 "modified a particular line of a source file. And so on."
13817 msgstr ""
13819 #. type: Content of: <book><chapter><sect1><title>
13820 #: ../en/ch11-mq.xml:187
13821 msgid "Understanding patches"
13822 msgstr "理解补丁"
13824 #. type: Content of: <book><chapter><sect1><para>
13825 #: ../en/ch11-mq.xml:189
13826 msgid ""
13827 "Because MQ doesn't hide its patch-oriented nature, it is helpful to "
13828 "understand what patches are, and a little about the tools that work with them."
13829 msgstr ""
13831 #. type: Content of: <book><chapter><sect1><para>
13832 #: ../en/ch11-mq.xml:193
13833 msgid ""
13834 "The traditional Unix <command>diff</command> command compares two files, and "
13835 "prints a list of differences between them. The <command>patch</command> "
13836 "command understands these differences as <emphasis>modifications</emphasis> "
13837 "to make to a file. Take a look below for a simple example of these commands "
13838 "in action."
13839 msgstr ""
13841 #. type: Content of: <book><chapter><sect1><para>
13842 #: ../en/ch11-mq.xml:202
13843 msgid ""
13844 "The type of file that <command>diff</command> generates (and <command>patch</"
13845 "command> takes as input) is called a <quote>patch</quote> or a <quote>diff</"
13846 "quote>; there is no difference between a patch and a diff. (We'll use the "
13847 "term <quote>patch</quote>, since it's more commonly used.)"
13848 msgstr ""
13850 #. type: Content of: <book><chapter><sect1><para>
13851 #: ../en/ch11-mq.xml:208
13852 msgid ""
13853 "A patch file can start with arbitrary text; the <command>patch</command> "
13854 "command ignores this text, but MQ uses it as the commit message when creating "
13855 "changesets. To find the beginning of the patch content, <command>patch</"
13856 "command> searches for the first line that starts with the string "
13857 "<quote><literal>diff -</literal></quote>."
13858 msgstr ""
13860 #. type: Content of: <book><chapter><sect1><para>
13861 #: ../en/ch11-mq.xml:215
13862 msgid ""
13863 "MQ works with <emphasis>unified</emphasis> diffs (<command>patch</command> "
13864 "can accept several other diff formats, but MQ doesn't). A unified diff "
13865 "contains two kinds of header. The <emphasis>file header</emphasis> describes "
13866 "the file being modified; it contains the name of the file to modify. When "
13867 "<command>patch</command> sees a new file header, it looks for a file with "
13868 "that name to start modifying."
13869 msgstr ""
13871 #. type: Content of: <book><chapter><sect1><para>
13872 #: ../en/ch11-mq.xml:223
13873 msgid ""
13874 "After the file header comes a series of <emphasis>hunks</emphasis>. Each "
13875 "hunk starts with a header; this identifies the range of line numbers within "
13876 "the file that the hunk should modify. Following the header, a hunk starts "
13877 "and ends with a few (usually three) lines of text from the unmodified file; "
13878 "these are called the <emphasis>context</emphasis> for the hunk. If there's "
13879 "only a small amount of context between successive hunks, <command>diff</"
13880 "command> doesn't print a new hunk header; it just runs the hunks together, "
13881 "with a few lines of context between modifications."
13882 msgstr ""
13884 #. type: Content of: <book><chapter><sect1><para>
13885 #: ../en/ch11-mq.xml:235
13886 msgid ""
13887 "Each line of context begins with a space character. Within the hunk, a line "
13888 "that begins with <quote><literal>-</literal></quote> means <quote>remove this "
13889 "line,</quote> while a line that begins with <quote><literal>+</literal></"
13890 "quote> means <quote>insert this line.</quote> For example, a line that is "
13891 "modified is represented by one deletion and one insertion."
13892 msgstr ""
13894 #. type: Content of: <book><chapter><sect1><para>
13895 #: ../en/ch11-mq.xml:243
13896 msgid ""
13897 "We will return to some of the more subtle aspects of patches later (in <xref "
13898 "linkend=\"sec:mq:adv-patch\"/>), but you should have enough information now "
13899 "to use MQ."
13900 msgstr ""
13902 #. type: Content of: <book><chapter><sect1><title>
13903 #: ../en/ch11-mq.xml:250
13904 msgid "Getting started with Mercurial Queues"
13905 msgstr "开始使用 MQ"
13907 #. type: Content of: <book><chapter><sect1><para>
13908 #: ../en/ch11-mq.xml:252
13909 msgid ""
13910 "Because MQ is implemented as an extension, you must explicitly enable before "
13911 "you can use it. (You don't need to download anything; MQ ships with the "
13912 "standard Mercurial distribution.) To enable MQ, edit your <filename role="
13913 "\"home\">~/.hgrc</filename> file, and add the lines below."
13914 msgstr ""
13916 #. type: Content of: <book><chapter><sect1><para>
13917 #: ../en/ch11-mq.xml:262
13918 msgid ""
13919 "Once the extension is enabled, it will make a number of new commands "
13920 "available. To verify that the extension is working, you can use <command "
13921 "role=\"hg-cmd\">hg help</command> to see if the <command role=\"hg-ext-mq"
13922 "\">qinit</command> command is now available."
13923 msgstr ""
13925 #. type: Content of: <book><chapter><sect1><para>
13926 #: ../en/ch11-mq.xml:270
13927 msgid ""
13928 "You can use MQ with <emphasis>any</emphasis> Mercurial repository, and its "
13929 "commands only operate within that repository. To get started, simply prepare "
13930 "the repository using the <command role=\"hg-ext-mq\">qinit</command> command."
13931 msgstr ""
13933 #. type: Content of: <book><chapter><sect1><para>
13934 #: ../en/ch11-mq.xml:277
13935 msgid ""
13936 "This command creates an empty directory called <filename role=\"special\" "
13937 "class=\"directory\">.hg/patches</filename>, where MQ will keep its metadata. "
13938 "As with many Mercurial commands, the <command role=\"hg-ext-mq\">qinit</"
13939 "command> command prints nothing if it succeeds."
13940 msgstr ""
13942 #. type: Content of: <book><chapter><sect1><sect2><title>
13943 #: ../en/ch11-mq.xml:284
13944 msgid "Creating a new patch"
13945 msgstr "创建新补丁"
13947 #. type: Content of: <book><chapter><sect1><sect2><para>
13948 #: ../en/ch11-mq.xml:286
13949 msgid ""
13950 "To begin work on a new patch, use the <command role=\"hg-ext-mq\">qnew</"
13951 "command> command. This command takes one argument, the name of the patch to "
13952 "create."
13953 msgstr ""
13955 #. type: Content of: <book><chapter><sect1><sect2><para>
13956 #: ../en/ch11-mq.xml:290
13957 msgid ""
13958 "MQ will use this as the name of an actual file in the <filename role=\"special"
13959 "\" class=\"directory\">.hg/patches</filename> directory, as you can see below."
13960 msgstr ""
13962 #. type: Content of: <book><chapter><sect1><sect2><para>
13963 #: ../en/ch11-mq.xml:297
13964 msgid ""
13965 "Also newly present in the <filename role=\"special\" class=\"directory\">.hg/"
13966 "patches</filename> directory are two other files, <filename role=\"special"
13967 "\">series</filename> and <filename role=\"special\">status</filename>. The "
13968 "<filename role=\"special\">series</filename> file lists all of the patches "
13969 "that MQ knows about for this repository, with one patch per line. Mercurial "
13970 "uses the <filename role=\"special\">status</filename> file for internal book-"
13971 "keeping; it tracks all of the patches that MQ has <emphasis>applied</"
13972 "emphasis> in this repository."
13973 msgstr ""
13975 #. type: Content of: <book><chapter><sect1><sect2><note><para>
13976 #: ../en/ch11-mq.xml:309
13977 msgid ""
13978 "You may sometimes want to edit the <filename role=\"special\">series</"
13979 "filename> file by hand; for example, to change the sequence in which some "
13980 "patches are applied. However, manually editing the <filename role=\"special"
13981 "\">status</filename> file is almost always a bad idea, as it's easy to "
13982 "corrupt MQ's idea of what is happening."
13983 msgstr ""
13985 #. type: Content of: <book><chapter><sect1><sect2><para>
13986 #: ../en/ch11-mq.xml:318
13987 msgid ""
13988 "Once you have created your new patch, you can edit files in the working "
13989 "directory as you usually would. All of the normal Mercurial commands, such "
13990 "as <command role=\"hg-cmd\">hg diff</command> and <command role=\"hg-cmd\">hg "
13991 "annotate</command>, work exactly as they did before."
13992 msgstr ""
13994 #. type: Content of: <book><chapter><sect1><sect2><title>
13995 #: ../en/ch11-mq.xml:326
13996 msgid "Refreshing a patch"
13997 msgstr "刷新补丁"
13999 #. type: Content of: <book><chapter><sect1><sect2><para>
14000 #: ../en/ch11-mq.xml:328
14001 msgid ""
14002 "When you reach a point where you want to save your work, use the <command "
14003 "role=\"hg-ext-mq\">qrefresh</command> command to update the patch you are "
14004 "working on."
14005 msgstr ""
14007 #. type: Content of: <book><chapter><sect1><sect2><para>
14008 #: ../en/ch11-mq.xml:334
14009 msgid ""
14010 "This command folds the changes you have made in the working directory into "
14011 "your patch, and updates its corresponding changeset to contain those changes."
14012 msgstr ""
14014 #. type: Content of: <book><chapter><sect1><sect2><para>
14015 #: ../en/ch11-mq.xml:338
14016 msgid ""
14017 "You can run <command role=\"hg-ext-mq\">qrefresh</command> as often as you "
14018 "like, so it's a good way to <quote>checkpoint</quote> your work. Refresh "
14019 "your patch at an opportune time; try an experiment; and if the experiment "
14020 "doesn't work out, <command role=\"hg-cmd\">hg revert</command> your "
14021 "modifications back to the last time you refreshed."
14022 msgstr ""
14024 #. type: Content of: <book><chapter><sect1><sect2><title>
14025 #: ../en/ch11-mq.xml:349
14026 msgid "Stacking and tracking patches"
14027 msgstr "堆叠和跟踪补丁"
14029 #. type: Content of: <book><chapter><sect1><sect2><para>
14030 #: ../en/ch11-mq.xml:351
14031 msgid ""
14032 "Once you have finished working on a patch, or need to work on another, you "
14033 "can use the <command role=\"hg-ext-mq\">qnew</command> command again to "
14034 "create a new patch. Mercurial will apply this patch on top of your existing "
14035 "patch."
14036 msgstr ""
14038 #. type: Content of: <book><chapter><sect1><sect2><para>
14039 #: ../en/ch11-mq.xml:358
14040 msgid ""
14041 "Notice that the patch contains the changes in our prior patch as part of its "
14042 "context (you can see this more clearly in the output of <command role=\"hg-cmd"
14043 "\">hg annotate</command>)."
14044 msgstr ""
14046 #. type: Content of: <book><chapter><sect1><sect2><para>
14047 #: ../en/ch11-mq.xml:363
14048 msgid ""
14049 "So far, with the exception of <command role=\"hg-ext-mq\">qnew</command> and "
14050 "<command role=\"hg-ext-mq\">qrefresh</command>, we've been careful to only "
14051 "use regular Mercurial commands. However, MQ provides many commands that are "
14052 "easier to use when you are thinking about patches, as illustrated below."
14053 msgstr ""
14055 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14056 #: ../en/ch11-mq.xml:373
14057 msgid ""
14058 "The <command role=\"hg-ext-mq\">qseries</command> command lists every patch "
14059 "that MQ knows about in this repository, from oldest to newest (most recently "
14060 "<emphasis>created</emphasis>)."
14061 msgstr ""
14063 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14064 #: ../en/ch11-mq.xml:379
14065 msgid ""
14066 "The <command role=\"hg-ext-mq\">qapplied</command> command lists every patch "
14067 "that MQ has <emphasis>applied</emphasis> in this repository, again from "
14068 "oldest to newest (most recently applied)."
14069 msgstr ""
14071 #. type: Content of: <book><chapter><sect1><sect2><title>
14072 #: ../en/ch11-mq.xml:388
14073 msgid "Manipulating the patch stack"
14074 msgstr "操作补丁堆栈"
14076 #. type: Content of: <book><chapter><sect1><sect2><para>
14077 #: ../en/ch11-mq.xml:390
14078 msgid ""
14079 "The previous discussion implied that there must be a difference between "
14080 "<quote>known</quote> and <quote>applied</quote> patches, and there is. MQ "
14081 "can manage a patch without it being applied in the repository."
14082 msgstr ""
14084 #. type: Content of: <book><chapter><sect1><sect2><para>
14085 #: ../en/ch11-mq.xml:395
14086 msgid ""
14087 "An <emphasis>applied</emphasis> patch has a corresponding changeset in the "
14088 "repository, and the effects of the patch and changeset are visible in the "
14089 "working directory. You can undo the application of a patch using the "
14090 "<command role=\"hg-ext-mq\">qpop</command> command. MQ still <emphasis>knows "
14091 "about</emphasis>, or manages, a popped patch, but the patch no longer has a "
14092 "corresponding changeset in the repository, and the working directory does not "
14093 "contain the changes made by the patch. <xref linkend=\"fig:mq:stack\"/> "
14094 "illustrates the difference between applied and tracked patches."
14095 msgstr ""
14097 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
14098 #: ../en/ch11-mq.xml:408
14099 msgid "Applied and unapplied patches in the MQ patch stack"
14100 msgstr "在 MQ 补丁堆栈中应用和撤销补丁"
14102 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
14103 #: ../en/ch11-mq.xml:411
14104 msgid "<imageobject><imagedata fileref=\"figs/mq-stack.png\"/></imageobject>"
14105 msgstr ""
14107 #. type: Content of: <book><chapter><sect1><sect2><para>
14108 #: ../en/ch11-mq.xml:416
14109 msgid ""
14110 "You can reapply an unapplied, or popped, patch using the <command role=\"hg-"
14111 "ext-mq\">qpush</command> command. This creates a new changeset to correspond "
14112 "to the patch, and the patch's changes once again become present in the "
14113 "working directory. See below for examples of <command role=\"hg-ext-mq"
14114 "\">qpop</command> and <command role=\"hg-ext-mq\">qpush</command> in action."
14115 msgstr ""
14117 #. type: Content of: <book><chapter><sect1><sect2><para>
14118 #: ../en/ch11-mq.xml:425
14119 msgid ""
14120 "Notice that once we have popped a patch or two patches, the output of "
14121 "<command role=\"hg-ext-mq\">qseries</command> remains the same, while that of "
14122 "<command role=\"hg-ext-mq\">qapplied</command> has changed."
14123 msgstr ""
14125 #. type: Content of: <book><chapter><sect1><sect2><title>
14126 #: ../en/ch11-mq.xml:433
14127 msgid "Pushing and popping many patches"
14128 msgstr "压入或弹出多个补丁"
14130 #. type: Content of: <book><chapter><sect1><sect2><para>
14131 #: ../en/ch11-mq.xml:435
14132 msgid ""
14133 "While <command role=\"hg-ext-mq\">qpush</command> and <command role=\"hg-ext-"
14134 "mq\">qpop</command> each operate on a single patch at a time by default, you "
14135 "can push and pop many patches in one go. The <option role=\"hg-ext-mq-cmd-"
14136 "qpush-opt\">hg -a</option> option to <command role=\"hg-ext-mq\">qpush</"
14137 "command> causes it to push all unapplied patches, while the <option role=\"hg-"
14138 "ext-mq-cmd-qpop-opt\">-a</option> option to <command role=\"hg-ext-mq\">qpop</"
14139 "command> causes it to pop all applied patches. (For some more ways to push "
14140 "and pop many patches, see <xref linkend=\"sec:mq:perf\"/> below.)"
14141 msgstr ""
14143 #. type: Content of: <book><chapter><sect1><sect2><title>
14144 #: ../en/ch11-mq.xml:451
14145 msgid "Safety checks, and overriding them"
14146 msgstr "安全的检查,然后覆盖它们"
14148 #. type: Content of: <book><chapter><sect1><sect2><para>
14149 #: ../en/ch11-mq.xml:453
14150 msgid ""
14151 "Several MQ commands check the working directory before they do anything, and "
14152 "fail if they find any modifications. They do this to ensure that you won't "
14153 "lose any changes that you have made, but not yet incorporated into a patch. "
14154 "The example below illustrates this; the <command role=\"hg-ext-mq\">qnew</"
14155 "command> command will not create a new patch if there are outstanding "
14156 "changes, caused in this case by the <command role=\"hg-cmd\">hg add</command> "
14157 "of <filename>file3</filename>."
14158 msgstr ""
14160 #. type: Content of: <book><chapter><sect1><sect2><para>
14161 #: ../en/ch11-mq.xml:465
14162 msgid ""
14163 "Commands that check the working directory all take an <quote>I know what I'm "
14164 "doing</quote> option, which is always named <option>-f</option>. The exact "
14165 "meaning of <option>-f</option> depends on the command. For example, <command "
14166 "role=\"hg-cmd\">hg qnew <option role=\"hg-ext-mq-cmd-qnew-opt\">hg -f</"
14167 "option></command> will incorporate any outstanding changes into the new patch "
14168 "it creates, but <command role=\"hg-cmd\">hg qpop <option role=\"hg-ext-mq-cmd-"
14169 "qpop-opt\">hg -f</option></command> will revert modifications to any files "
14170 "affected by the patch that it is popping. Be sure to read the documentation "
14171 "for a command's <option>-f</option> option before you use it!"
14172 msgstr ""
14174 #. type: Content of: <book><chapter><sect1><sect2><title>
14175 #: ../en/ch11-mq.xml:480
14176 msgid "Working on several patches at once"
14177 msgstr "同时处理多个补丁"
14179 #. type: Content of: <book><chapter><sect1><sect2><para>
14180 #: ../en/ch11-mq.xml:482
14181 msgid ""
14182 "The <command role=\"hg-ext-mq\">qrefresh</command> command always refreshes "
14183 "the <emphasis>topmost</emphasis> applied patch. This means that you can "
14184 "suspend work on one patch (by refreshing it), pop or push to make a different "
14185 "patch the top, and work on <emphasis>that</emphasis> patch for a while."
14186 msgstr ""
14188 #. type: Content of: <book><chapter><sect1><sect2><para>
14189 #: ../en/ch11-mq.xml:489
14190 msgid ""
14191 "Here's an example that illustrates how you can use this ability. Let's say "
14192 "you're developing a new feature as two patches. The first is a change to the "
14193 "core of your software, and the second&emdash;layered on top of the "
14194 "first&emdash;changes the user interface to use the code you just added to the "
14195 "core. If you notice a bug in the core while you're working on the UI patch, "
14196 "it's easy to fix the core. Simply <command role=\"hg-ext-mq\">qrefresh</"
14197 "command> the UI patch to save your in-progress changes, and <command role="
14198 "\"hg-ext-mq\">qpop</command> down to the core patch. Fix the core bug, "
14199 "<command role=\"hg-ext-mq\">qrefresh</command> the core patch, and <command "
14200 "role=\"hg-ext-mq\">qpush</command> back to the UI patch to continue where you "
14201 "left off."
14202 msgstr ""
14204 #. type: Content of: <book><chapter><sect1><title>
14205 #: ../en/ch11-mq.xml:506
14206 msgid "More about patches"
14207 msgstr "关于补丁的更多信息"
14209 #. type: Content of: <book><chapter><sect1><para>
14210 #: ../en/ch11-mq.xml:508
14211 msgid ""
14212 "MQ uses the GNU <command>patch</command> command to apply patches, so it's "
14213 "helpful to know a few more detailed aspects of how <command>patch</command> "
14214 "works, and about patches themselves."
14215 msgstr ""
14217 #. type: Content of: <book><chapter><sect1><sect2><title>
14218 #: ../en/ch11-mq.xml:514
14219 msgid "The strip count"
14220 msgstr "修剪计数"
14222 #. type: Content of: <book><chapter><sect1><sect2><para>
14223 #: ../en/ch11-mq.xml:516
14224 msgid ""
14225 "If you look at the file headers in a patch, you will notice that the "
14226 "pathnames usually have an extra component on the front that isn't present in "
14227 "the actual path name. This is a holdover from the way that people used to "
14228 "generate patches (people still do this, but it's somewhat rare with modern "
14229 "revision control tools)."
14230 msgstr ""
14232 #. type: Content of: <book><chapter><sect1><sect2><para>
14233 #: ../en/ch11-mq.xml:523
14234 msgid ""
14235 "Alice would unpack a tarball, edit her files, then decide that she wanted to "
14236 "create a patch. So she'd rename her working directory, unpack the tarball "
14237 "again (hence the need for the rename), and use the <option role=\"cmd-opt-diff"
14238 "\">-r</option> and <option role=\"cmd-opt-diff\">-N</option> options to "
14239 "<command>diff</command> to recursively generate a patch between the "
14240 "unmodified directory and the modified one. The result would be that the name "
14241 "of the unmodified directory would be at the front of the left-hand path in "
14242 "every file header, and the name of the modified directory would be at the "
14243 "front of the right-hand path."
14244 msgstr ""
14246 #. type: Content of: <book><chapter><sect1><sect2><para>
14247 #: ../en/ch11-mq.xml:536
14248 msgid ""
14249 "Since someone receiving a patch from the Alices of the net would be unlikely "
14250 "to have unmodified and modified directories with exactly the same names, the "
14251 "<command>patch</command> command has a <option role=\"cmd-opt-patch\">-p</"
14252 "option> option that indicates the number of leading path name components to "
14253 "strip when trying to apply a patch. This number is called the "
14254 "<emphasis>strip count</emphasis>."
14255 msgstr ""
14257 #. type: Content of: <book><chapter><sect1><sect2><para>
14258 #: ../en/ch11-mq.xml:544
14259 msgid ""
14260 "An option of <quote><literal>-p1</literal></quote> means <quote>use a strip "
14261 "count of one</quote>. If <command>patch</command> sees a file name "
14262 "<filename>foo/bar/baz</filename> in a file header, it will strip "
14263 "<filename>foo</filename> and try to patch a file named <filename>bar/baz</"
14264 "filename>. (Strictly speaking, the strip count refers to the number of "
14265 "<emphasis>path separators</emphasis> (and the components that go with them ) "
14266 "to strip. A strip count of one will turn <filename>foo/bar</filename> into "
14267 "<filename>bar</filename>, but <filename>/foo/bar</filename> (notice the extra "
14268 "leading slash) into <filename>foo/bar</filename>.)"
14269 msgstr ""
14271 #. type: Content of: <book><chapter><sect1><sect2><para>
14272 #: ../en/ch11-mq.xml:557
14273 msgid ""
14274 "The <quote>standard</quote> strip count for patches is one; almost all "
14275 "patches contain one leading path name component that needs to be stripped. "
14276 "Mercurial's <command role=\"hg-cmd\">hg diff</command> command generates path "
14277 "names in this form, and the <command role=\"hg-cmd\">hg import</command> "
14278 "command and MQ expect patches to have a strip count of one."
14279 msgstr ""
14281 #. type: Content of: <book><chapter><sect1><sect2><para>
14282 #: ../en/ch11-mq.xml:565
14283 msgid ""
14284 "If you receive a patch from someone that you want to add to your patch queue, "
14285 "and the patch needs a strip count other than one, you cannot just <command "
14286 "role=\"hg-ext-mq\">qimport</command> the patch, because <command role=\"hg-"
14287 "ext-mq\">qimport</command> does not yet have a <literal>-p</literal> option "
14288 "(see <ulink role=\"hg-bug\" url=\"http://www.selenic.com/mercurial/bts/"
14289 "issue311\">issue 311</ulink>). Your best bet is to <command role=\"hg-ext-mq"
14290 "\">qnew</command> a patch of your own, then use <command>patch -pN</command> "
14291 "to apply their patch, followed by <command role=\"hg-cmd\">hg addremove</"
14292 "command> to pick up any files added or removed by the patch, followed by "
14293 "<command role=\"hg-ext-mq\">hg qrefresh</command>. This complexity may become "
14294 "unnecessary; see <ulink role=\"hg-bug\" url=\"http://www.selenic.com/"
14295 "mercurial/bts/issue311\">issue 311</ulink> for details."
14296 msgstr ""
14298 #. type: Content of: <book><chapter><sect1><sect2><title>
14299 #: ../en/ch11-mq.xml:584
14300 msgid "Strategies for applying a patch"
14301 msgstr "应用补丁的策略"
14303 #. type: Content of: <book><chapter><sect1><sect2><para>
14304 #: ../en/ch11-mq.xml:586
14305 msgid ""
14306 "When <command>patch</command> applies a hunk, it tries a handful of "
14307 "successively less accurate strategies to try to make the hunk apply. This "
14308 "falling-back technique often makes it possible to take a patch that was "
14309 "generated against an old version of a file, and apply it against a newer "
14310 "version of that file."
14311 msgstr ""
14313 #. type: Content of: <book><chapter><sect1><sect2><para>
14314 #: ../en/ch11-mq.xml:593
14315 msgid ""
14316 "First, <command>patch</command> tries an exact match, where the line numbers, "
14317 "the context, and the text to be modified must apply exactly. If it cannot "
14318 "make an exact match, it tries to find an exact match for the context, without "
14319 "honouring the line numbering information. If this succeeds, it prints a line "
14320 "of output saying that the hunk was applied, but at some <emphasis>offset</"
14321 "emphasis> from the original line number."
14322 msgstr ""
14324 #. type: Content of: <book><chapter><sect1><sect2><para>
14325 #: ../en/ch11-mq.xml:602
14326 msgid ""
14327 "If a context-only match fails, <command>patch</command> removes the first and "
14328 "last lines of the context, and tries a <emphasis>reduced</emphasis> context-"
14329 "only match. If the hunk with reduced context succeeds, it prints a message "
14330 "saying that it applied the hunk with a <emphasis>fuzz factor</emphasis> (the "
14331 "number after the fuzz factor indicates how many lines of context "
14332 "<command>patch</command> had to trim before the patch applied)."
14333 msgstr ""
14335 #. type: Content of: <book><chapter><sect1><sect2><para>
14336 #: ../en/ch11-mq.xml:611
14337 msgid ""
14338 "When neither of these techniques works, <command>patch</command> prints a "
14339 "message saying that the hunk in question was rejected. It saves rejected "
14340 "hunks (also simply called <quote>rejects</quote>) to a file with the same "
14341 "name, and an added <filename role=\"special\">.rej</filename> extension. It "
14342 "also saves an unmodified copy of the file with a <filename role=\"special\">."
14343 "orig</filename> extension; the copy of the file without any extensions will "
14344 "contain any changes made by hunks that <emphasis>did</emphasis> apply "
14345 "cleanly. If you have a patch that modifies <filename>foo</filename> with six "
14346 "hunks, and one of them fails to apply, you will have: an unmodified "
14347 "<filename>foo.orig</filename>, a <filename>foo.rej</filename> containing one "
14348 "hunk, and <filename>foo</filename>, containing the changes made by the five "
14349 "successful hunks."
14350 msgstr ""
14352 #. type: Content of: <book><chapter><sect1><sect2><title>
14353 #: ../en/ch11-mq.xml:629
14354 msgid "Some quirks of patch representation"
14355 msgstr "补丁的一些特性"
14357 #. type: Content of: <book><chapter><sect1><sect2><para>
14358 #: ../en/ch11-mq.xml:631
14359 msgid ""
14360 "There are a few useful things to know about how <command>patch</command> "
14361 "works with files."
14362 msgstr ""
14364 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14365 #: ../en/ch11-mq.xml:634
14366 msgid ""
14367 "This should already be obvious, but <command>patch</command> cannot handle "
14368 "binary files."
14369 msgstr ""
14371 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14372 #: ../en/ch11-mq.xml:638
14373 msgid ""
14374 "Neither does it care about the executable bit; it creates new files as "
14375 "readable, but not executable."
14376 msgstr ""
14378 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14379 #: ../en/ch11-mq.xml:642
14380 msgid ""
14381 "<command>patch</command> treats the removal of a file as a diff between the "
14382 "file to be removed and the empty file. So your idea of <quote>I deleted this "
14383 "file</quote> looks like <quote>every line of this file was deleted</quote> in "
14384 "a patch."
14385 msgstr ""
14387 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14388 #: ../en/ch11-mq.xml:648
14389 msgid ""
14390 "It treats the addition of a file as a diff between the empty file and the "
14391 "file to be added. So in a patch, your idea of <quote>I added this file</"
14392 "quote> looks like <quote>every line of this file was added</quote>."
14393 msgstr ""
14395 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14396 #: ../en/ch11-mq.xml:654
14397 msgid ""
14398 "It treats a renamed file as the removal of the old name, and the addition of "
14399 "the new name. This means that renamed files have a big footprint in "
14400 "patches. (Note also that Mercurial does not currently try to infer when "
14401 "files have been renamed or copied in a patch.)"
14402 msgstr ""
14404 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14405 #: ../en/ch11-mq.xml:660
14406 msgid ""
14407 "<command>patch</command> cannot represent empty files, so you cannot use a "
14408 "patch to represent the notion <quote>I added this empty file to the tree</"
14409 "quote>."
14410 msgstr ""
14412 #. type: Content of: <book><chapter><sect1><sect2><title>
14413 #: ../en/ch11-mq.xml:667
14414 msgid "Beware the fuzz"
14415 msgstr "当心毛刺"
14417 #. type: Content of: <book><chapter><sect1><sect2><para>
14418 #: ../en/ch11-mq.xml:669
14419 msgid ""
14420 "While applying a hunk at an offset, or with a fuzz factor, will often be "
14421 "completely successful, these inexact techniques naturally leave open the "
14422 "possibility of corrupting the patched file. The most common cases typically "
14423 "involve applying a patch twice, or at an incorrect location in the file. If "
14424 "<command>patch</command> or <command role=\"hg-ext-mq\">qpush</command> ever "
14425 "mentions an offset or fuzz factor, you should make sure that the modified "
14426 "files are correct afterwards."
14427 msgstr ""
14429 #. type: Content of: <book><chapter><sect1><sect2><para>
14430 #: ../en/ch11-mq.xml:679
14431 msgid ""
14432 "It's often a good idea to refresh a patch that has applied with an offset or "
14433 "fuzz factor; refreshing the patch generates new context information that will "
14434 "make it apply cleanly. I say <quote>often,</quote> not <quote>always,</"
14435 "quote> because sometimes refreshing a patch will make it fail to apply "
14436 "against a different revision of the underlying files. In some cases, such as "
14437 "when you're maintaining a patch that must sit on top of multiple versions of "
14438 "a source tree, it's acceptable to have a patch apply with some fuzz, provided "
14439 "you've verified the results of the patching process in such cases."
14440 msgstr ""
14442 #. type: Content of: <book><chapter><sect1><sect2><title>
14443 #: ../en/ch11-mq.xml:692
14444 msgid "Handling rejection"
14445 msgstr "处理拒绝"
14447 #. type: Content of: <book><chapter><sect1><sect2><para>
14448 #: ../en/ch11-mq.xml:694
14449 msgid ""
14450 "If <command role=\"hg-ext-mq\">qpush</command> fails to apply a patch, it "
14451 "will print an error message and exit. If it has left <filename role=\"special"
14452 "\">.rej</filename> files behind, it is usually best to fix up the rejected "
14453 "hunks before you push more patches or do any further work."
14454 msgstr ""
14456 #. type: Content of: <book><chapter><sect1><sect2><para>
14457 #: ../en/ch11-mq.xml:700
14458 msgid ""
14459 "If your patch <emphasis>used to</emphasis> apply cleanly, and no longer does "
14460 "because you've changed the underlying code that your patches are based on, "
14461 "Mercurial Queues can help; see <xref linkend=\"sec:mq:merge\"/> for details."
14462 msgstr ""
14464 #. type: Content of: <book><chapter><sect1><sect2><para>
14465 #: ../en/ch11-mq.xml:705
14466 msgid ""
14467 "Unfortunately, there aren't any great techniques for dealing with rejected "
14468 "hunks. Most often, you'll need to view the <filename role=\"special\">.rej</"
14469 "filename> file and edit the target file, applying the rejected hunks by hand."
14470 msgstr ""
14472 #. type: Content of: <book><chapter><sect1><sect2><para>
14473 #: ../en/ch11-mq.xml:710
14474 msgid ""
14475 "If you're feeling adventurous, Neil Brown, a Linux kernel hacker, wrote a "
14476 "tool called <command>wiggle</command> <citation>web:wiggle</citation>, which "
14477 "is more vigorous than <command>patch</command> in its attempts to make a "
14478 "patch apply."
14479 msgstr ""
14481 #. type: Content of: <book><chapter><sect1><sect2><para>
14482 #: ../en/ch11-mq.xml:716
14483 msgid ""
14484 "Another Linux kernel hacker, Chris Mason (the author of Mercurial Queues), "
14485 "wrote a similar tool called <command>mpatch</command> <citation>web:mpatch</"
14486 "citation>, which takes a simple approach to automating the application of "
14487 "hunks rejected by <command>patch</command>. The <command>mpatch</command> "
14488 "command can help with four common reasons that a hunk may be rejected:"
14489 msgstr ""
14491 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14492 #: ../en/ch11-mq.xml:725
14493 msgid "The context in the middle of a hunk has changed."
14494 msgstr ""
14496 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14497 #: ../en/ch11-mq.xml:728
14498 msgid "A hunk is missing some context at the beginning or end."
14499 msgstr ""
14501 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14502 #: ../en/ch11-mq.xml:731
14503 msgid ""
14504 "A large hunk might apply better&emdash;either entirely or in part&emdash;if "
14505 "it was broken up into smaller hunks."
14506 msgstr ""
14508 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14509 #: ../en/ch11-mq.xml:735
14510 msgid ""
14511 "A hunk removes lines with slightly different content than those currently "
14512 "present in the file."
14513 msgstr ""
14515 #. type: Content of: <book><chapter><sect1><sect2><para>
14516 #: ../en/ch11-mq.xml:739
14517 msgid ""
14518 "If you use <command>wiggle</command> or <command>mpatch</command>, you should "
14519 "be doubly careful to check your results when you're done. In fact, "
14520 "<command>mpatch</command> enforces this method of double-checking the tool's "
14521 "output, by automatically dropping you into a merge program when it has done "
14522 "its job, so that you can verify its work and finish off any remaining merges."
14523 msgstr ""
14525 #. type: Content of: <book><chapter><sect1><title>
14526 #: ../en/ch11-mq.xml:751
14527 msgid "Getting the best performance out of MQ"
14528 msgstr "MQ 的性能"
14530 #. type: Content of: <book><chapter><sect1><para>
14531 #: ../en/ch11-mq.xml:753
14532 msgid ""
14533 "MQ is very efficient at handling a large number of patches. I ran some "
14534 "performance experiments in mid-2006 for a talk that I gave at the 2006 "
14535 "EuroPython conference <citation>web:europython</citation>. I used as my data "
14536 "set the Linux 2.6.17-mm1 patch series, which consists of 1,738 patches. I "
14537 "applied these on top of a Linux kernel repository containing all 27,472 "
14538 "revisions between Linux 2.6.12-rc2 and Linux 2.6.17."
14539 msgstr ""
14541 #. type: Content of: <book><chapter><sect1><para>
14542 #: ../en/ch11-mq.xml:762
14543 msgid ""
14544 "On my old, slow laptop, I was able to <command role=\"hg-cmd\">hg qpush "
14545 "<option role=\"hg-ext-mq-cmd-qpush-opt\">hg -a</option></command> all 1,738 "
14546 "patches in 3.5 minutes, and <command role=\"hg-cmd\">hg qpop <option role="
14547 "\"hg-ext-mq-cmd-qpop-opt\">hg -a</option></command> them all in 30 seconds. "
14548 "(On a newer laptop, the time to push all patches dropped to two minutes.) I "
14549 "could <command role=\"hg-ext-mq\">qrefresh</command> one of the biggest "
14550 "patches (which made 22,779 lines of changes to 287 files) in 6.6 seconds."
14551 msgstr ""
14553 #. type: Content of: <book><chapter><sect1><para>
14554 #: ../en/ch11-mq.xml:773
14555 msgid ""
14556 "Clearly, MQ is well suited to working in large trees, but there are a few "
14557 "tricks you can use to get the best performance of it."
14558 msgstr ""
14560 #. type: Content of: <book><chapter><sect1><para>
14561 #: ../en/ch11-mq.xml:777
14562 msgid ""
14563 "First of all, try to <quote>batch</quote> operations together. Every time "
14564 "you run <command role=\"hg-ext-mq\">qpush</command> or <command role=\"hg-ext-"
14565 "mq\">qpop</command>, these commands scan the working directory once to make "
14566 "sure you haven't made some changes and then forgotten to run <command role="
14567 "\"hg-ext-mq\">qrefresh</command>. On a small tree, the time that this scan "
14568 "takes is unnoticeable. However, on a medium-sized tree (containing tens of "
14569 "thousands of files), it can take a second or more."
14570 msgstr ""
14572 #. type: Content of: <book><chapter><sect1><para>
14573 #: ../en/ch11-mq.xml:788
14574 msgid ""
14575 "The <command role=\"hg-ext-mq\">qpush</command> and <command role=\"hg-ext-mq"
14576 "\">qpop</command> commands allow you to push and pop multiple patches at a "
14577 "time. You can identify the <quote>destination patch</quote> that you want to "
14578 "end up at. When you <command role=\"hg-ext-mq\">qpush</command> with a "
14579 "destination specified, it will push patches until that patch is at the top of "
14580 "the applied stack. When you <command role=\"hg-ext-mq\">qpop</command> to a "
14581 "destination, MQ will pop patches until the destination patch is at the top."
14582 msgstr ""
14584 #. type: Content of: <book><chapter><sect1><para>
14585 #: ../en/ch11-mq.xml:798
14586 msgid ""
14587 "You can identify a destination patch using either the name of the patch, or "
14588 "by number. If you use numeric addressing, patches are counted from zero; "
14589 "this means that the first patch is zero, the second is one, and so on."
14590 msgstr ""
14592 #. type: Content of: <book><chapter><sect1><title>
14593 #: ../en/ch11-mq.xml:805
14594 msgid "Updating your patches when the underlying code changes"
14595 msgstr "当基础代码改变时,更新补丁的方法"
14597 #. type: Content of: <book><chapter><sect1><para>
14598 #: ../en/ch11-mq.xml:808
14599 msgid ""
14600 "It's common to have a stack of patches on top of an underlying repository "
14601 "that you don't modify directly. If you're working on changes to third-party "
14602 "code, or on a feature that is taking longer to develop than the rate of "
14603 "change of the code beneath, you will often need to sync up with the "
14604 "underlying code, and fix up any hunks in your patches that no longer apply. "
14605 "This is called <emphasis>rebasing</emphasis> your patch series."
14606 msgstr ""
14608 #. type: Content of: <book><chapter><sect1><para>
14609 #: ../en/ch11-mq.xml:817
14610 msgid ""
14611 "The simplest way to do this is to <command role=\"hg-cmd\">hg qpop <option "
14612 "role=\"hg-ext-mq-cmd-qpop-opt\">hg -a</option></command> your patches, then "
14613 "<command role=\"hg-cmd\">hg pull</command> changes into the underlying "
14614 "repository, and finally <command role=\"hg-cmd\">hg qpush <option role=\"hg-"
14615 "ext-mq-cmd-qpop-opt\">hg -a</option></command> your patches again. MQ will "
14616 "stop pushing any time it runs across a patch that fails to apply during "
14617 "conflicts, allowing you to fix your conflicts, <command role=\"hg-ext-mq"
14618 "\">qrefresh</command> the affected patch, and continue pushing until you have "
14619 "fixed your entire stack."
14620 msgstr ""
14622 #. type: Content of: <book><chapter><sect1><para>
14623 #: ../en/ch11-mq.xml:829
14624 msgid ""
14625 "This approach is easy to use and works well if you don't expect changes to "
14626 "the underlying code to affect how well your patches apply. If your patch "
14627 "stack touches code that is modified frequently or invasively in the "
14628 "underlying repository, however, fixing up rejected hunks by hand quickly "
14629 "becomes tiresome."
14630 msgstr ""
14632 #. type: Content of: <book><chapter><sect1><para>
14633 #: ../en/ch11-mq.xml:836
14634 msgid ""
14635 "It's possible to partially automate the rebasing process. If your patches "
14636 "apply cleanly against some revision of the underlying repo, MQ can use this "
14637 "information to help you to resolve conflicts between your patches and a "
14638 "different revision."
14639 msgstr ""
14641 #. type: Content of: <book><chapter><sect1><para>
14642 #: ../en/ch11-mq.xml:842
14643 msgid "The process is a little involved."
14644 msgstr ""
14646 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
14647 #: ../en/ch11-mq.xml:844
14648 msgid ""
14649 "To begin, <command role=\"hg-cmd\">hg qpush -a</command> all of your patches "
14650 "on top of the revision where you know that they apply cleanly."
14651 msgstr ""
14653 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
14654 #: ../en/ch11-mq.xml:848
14655 msgid ""
14656 "Save a backup copy of your patch directory using <command role=\"hg-cmd\">hg "
14657 "qsave <option role=\"hg-ext-mq-cmd-qsave-opt\">hg -e</option> <option role="
14658 "\"hg-ext-mq-cmd-qsave-opt\">hg -c</option></command>. This prints the name "
14659 "of the directory that it has saved the patches in. It will save the patches "
14660 "to a directory called <filename role=\"special\" class=\"directory\">.hg/"
14661 "patches.N</filename>, where <literal>N</literal> is a small integer. It also "
14662 "commits a <quote>save changeset</quote> on top of your applied patches; this "
14663 "is for internal book-keeping, and records the states of the <filename role="
14664 "\"special\">series</filename> and <filename role=\"special\">status</"
14665 "filename> files."
14666 msgstr ""
14668 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
14669 #: ../en/ch11-mq.xml:862
14670 msgid ""
14671 "Use <command role=\"hg-cmd\">hg pull</command> to bring new changes into the "
14672 "underlying repository. (Don't run <command role=\"hg-cmd\">hg pull -u</"
14673 "command>; see below for why.)"
14674 msgstr ""
14676 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
14677 #: ../en/ch11-mq.xml:867
14678 msgid ""
14679 "Update to the new tip revision, using <command role=\"hg-cmd\">hg update "
14680 "<option role=\"hg-opt-update\">-C</option></command> to override the patches "
14681 "you have pushed."
14682 msgstr ""
14684 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
14685 #: ../en/ch11-mq.xml:872
14686 msgid ""
14687 "Merge all patches using <command>hg qpush -m -a</command>. The <option role="
14688 "\"hg-ext-mq-cmd-qpush-opt\">-m</option> option to <command role=\"hg-ext-mq"
14689 "\">qpush</command> tells MQ to perform a three-way merge if the patch fails "
14690 "to apply."
14691 msgstr ""
14693 #. type: Content of: <book><chapter><sect1><para>
14694 #: ../en/ch11-mq.xml:880
14695 msgid ""
14696 "During the <command role=\"hg-cmd\">hg qpush <option role=\"hg-ext-mq-cmd-"
14697 "qpush-opt\">hg -m</option></command>, each patch in the <filename role="
14698 "\"special\">series</filename> file is applied normally. If a patch applies "
14699 "with fuzz or rejects, MQ looks at the queue you <command role=\"hg-ext-mq"
14700 "\">qsave</command>d, and performs a three-way merge with the corresponding "
14701 "changeset. This merge uses Mercurial's normal merge machinery, so it may pop "
14702 "up a GUI merge tool to help you to resolve problems."
14703 msgstr ""
14705 #. type: Content of: <book><chapter><sect1><para>
14706 #: ../en/ch11-mq.xml:890
14707 msgid ""
14708 "When you finish resolving the effects of a patch, MQ refreshes your patch "
14709 "based on the result of the merge."
14710 msgstr ""
14712 #. type: Content of: <book><chapter><sect1><para>
14713 #: ../en/ch11-mq.xml:893
14714 msgid ""
14715 "At the end of this process, your repository will have one extra head from the "
14716 "old patch queue, and a copy of the old patch queue will be in <filename role="
14717 "\"special\" class=\"directory\">.hg/patches.N</filename>. You can remove the "
14718 "extra head using <command role=\"hg-cmd\">hg qpop -a -n patches.N</command> "
14719 "or <command role=\"hg-cmd\">hg strip</command>. You can delete <filename "
14720 "role=\"special\" class=\"directory\">.hg/patches.N</filename> once you are "
14721 "sure that you no longer need it as a backup."
14722 msgstr ""
14724 #. type: Content of: <book><chapter><sect1><title>
14725 #: ../en/ch11-mq.xml:905
14726 msgid "Identifying patches"
14727 msgstr "标识补丁"
14729 #. type: Content of: <book><chapter><sect1><para>
14730 #: ../en/ch11-mq.xml:907
14731 msgid ""
14732 "MQ commands that work with patches let you refer to a patch either by using "
14733 "its name or by a number. By name is obvious enough; pass the name "
14734 "<filename>foo.patch</filename> to <command role=\"hg-ext-mq\">qpush</"
14735 "command>, for example, and it will push patches until <filename>foo.patch</"
14736 "filename> is applied."
14737 msgstr ""
14739 #. type: Content of: <book><chapter><sect1><para>
14740 #: ../en/ch11-mq.xml:914
14741 msgid ""
14742 "As a shortcut, you can refer to a patch using both a name and a numeric "
14743 "offset; <literal>foo.patch-2</literal> means <quote>two patches before "
14744 "<literal>foo.patch</literal></quote>, while <literal>bar.patch+4</literal> "
14745 "means <quote>four patches after <literal>bar.patch</literal></quote>."
14746 msgstr ""
14748 #. type: Content of: <book><chapter><sect1><para>
14749 #: ../en/ch11-mq.xml:920
14750 msgid ""
14751 "Referring to a patch by index isn't much different. The first patch printed "
14752 "in the output of <command role=\"hg-ext-mq\">qseries</command> is patch zero "
14753 "(yes, it's one of those start-at-zero counting systems); the second is patch "
14754 "one; and so on."
14755 msgstr ""
14757 #. type: Content of: <book><chapter><sect1><para>
14758 #: ../en/ch11-mq.xml:926
14759 msgid ""
14760 "MQ also makes it easy to work with patches when you are using normal "
14761 "Mercurial commands. Every command that accepts a changeset ID will also "
14762 "accept the name of an applied patch. MQ augments the tags normally in the "
14763 "repository with an eponymous one for each applied patch. In addition, the "
14764 "special tags <literal role=\"tag\">qbase</literal> and <literal role=\"tag"
14765 "\">qtip</literal> identify the <quote>bottom-most</quote> and topmost applied "
14766 "patches, respectively."
14767 msgstr ""
14769 #. type: Content of: <book><chapter><sect1><para>
14770 #: ../en/ch11-mq.xml:936
14771 msgid ""
14772 "These additions to Mercurial's normal tagging capabilities make dealing with "
14773 "patches even more of a breeze."
14774 msgstr ""
14776 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14777 #: ../en/ch11-mq.xml:939
14778 msgid "Want to patchbomb a mailing list with your latest series of changes?"
14779 msgstr ""
14781 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14782 #: ../en/ch11-mq.xml:942
14783 msgid ""
14784 "(Don't know what <quote>patchbombing</quote> is? See <xref linkend=\"sec:"
14785 "hgext:patchbomb\"/>.)"
14786 msgstr ""
14788 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14789 #: ../en/ch11-mq.xml:945
14790 msgid ""
14791 "Need to see all of the patches since <literal>foo.patch</literal> that have "
14792 "touched files in a subdirectory of your tree?"
14793 msgstr ""
14795 #. type: Content of: <book><chapter><sect1><para>
14796 #: ../en/ch11-mq.xml:952
14797 msgid ""
14798 "Because MQ makes the names of patches available to the rest of Mercurial "
14799 "through its normal internal tag machinery, you don't need to type in the "
14800 "entire name of a patch when you want to identify it by name."
14801 msgstr ""
14803 #. type: Content of: <book><chapter><sect1><para>
14804 #: ../en/ch11-mq.xml:957
14805 msgid ""
14806 "Another nice consequence of representing patch names as tags is that when you "
14807 "run the <command role=\"hg-cmd\">hg log</command> command, it will display a "
14808 "patch's name as a tag, simply as part of its normal output. This makes it "
14809 "easy to visually distinguish applied patches from underlying <quote>normal</"
14810 "quote> revisions. The following example shows a few normal Mercurial "
14811 "commands in use with applied patches."
14812 msgstr ""
14814 #. type: Content of: <book><chapter><sect1><title>
14815 #: ../en/ch11-mq.xml:970
14816 msgid "Useful things to know about"
14817 msgstr "其它需要了解的东西"
14819 #. type: Content of: <book><chapter><sect1><para>
14820 #: ../en/ch11-mq.xml:972
14821 msgid ""
14822 "There are a number of aspects of MQ usage that don't fit tidily into sections "
14823 "of their own, but that are good to know. Here they are, in one place."
14824 msgstr ""
14826 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14827 #: ../en/ch11-mq.xml:977
14828 msgid ""
14829 "Normally, when you <command role=\"hg-ext-mq\">qpop</command> a patch and "
14830 "<command role=\"hg-ext-mq\">qpush</command> it again, the changeset that "
14831 "represents the patch after the pop/push will have a <emphasis>different "
14832 "identity</emphasis> than the changeset that represented the hash beforehand. "
14833 "See <xref linkend=\"sec:mqref:cmd:qpush\"/> for information as to why this is."
14834 msgstr ""
14836 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14837 #: ../en/ch11-mq.xml:986
14838 msgid ""
14839 "It's not a good idea to <command role=\"hg-cmd\">hg merge</command> changes "
14840 "from another branch with a patch changeset, at least if you want to maintain "
14841 "the <quote>patchiness</quote> of that changeset and changesets below it on "
14842 "the patch stack. If you try to do this, it will appear to succeed, but MQ "
14843 "will become confused."
14844 msgstr ""
14846 #. type: Content of: <book><chapter><sect1><title>
14847 #: ../en/ch11-mq.xml:997
14848 msgid "Managing patches in a repository"
14849 msgstr "在版本库管理补丁"
14851 #. type: Content of: <book><chapter><sect1><para>
14852 #: ../en/ch11-mq.xml:999
14853 msgid ""
14854 "Because MQ's <filename role=\"special\" class=\"directory\">.hg/patches</"
14855 "filename> directory resides outside a Mercurial repository's working "
14856 "directory, the <quote>underlying</quote> Mercurial repository knows nothing "
14857 "about the management or presence of patches."
14858 msgstr ""
14860 #. type: Content of: <book><chapter><sect1><para>
14861 #: ../en/ch11-mq.xml:1005
14862 msgid ""
14863 "This presents the interesting possibility of managing the contents of the "
14864 "patch directory as a Mercurial repository in its own right. This can be a "
14865 "useful way to work. For example, you can work on a patch for a while, "
14866 "<command role=\"hg-ext-mq\">qrefresh</command> it, then <command role=\"hg-cmd"
14867 "\">hg commit</command> the current state of the patch. This lets you "
14868 "<quote>roll back</quote> to that version of the patch later on."
14869 msgstr ""
14871 #. type: Content of: <book><chapter><sect1><para>
14872 #: ../en/ch11-mq.xml:1014
14873 msgid ""
14874 "You can then share different versions of the same patch stack among multiple "
14875 "underlying repositories. I use this when I am developing a Linux kernel "
14876 "feature. I have a pristine copy of my kernel sources for each of several CPU "
14877 "architectures, and a cloned repository under each that contains the patches I "
14878 "am working on. When I want to test a change on a different architecture, I "
14879 "push my current patches to the patch repository associated with that kernel "
14880 "tree, pop and push all of my patches, and build and test that kernel."
14881 msgstr ""
14883 #. type: Content of: <book><chapter><sect1><para>
14884 #: ../en/ch11-mq.xml:1024
14885 msgid ""
14886 "Managing patches in a repository makes it possible for multiple developers to "
14887 "work on the same patch series without colliding with each other, all on top "
14888 "of an underlying source base that they may or may not control."
14889 msgstr ""
14891 #. type: Content of: <book><chapter><sect1><sect2><title>
14892 #: ../en/ch11-mq.xml:1030
14893 msgid "MQ support for patch repositories"
14894 msgstr "MQ 支持补丁版本库"
14896 #. type: Content of: <book><chapter><sect1><sect2><para>
14897 #: ../en/ch11-mq.xml:1032
14898 msgid ""
14899 "MQ helps you to work with the <filename role=\"special\" class=\"directory\">."
14900 "hg/patches</filename> directory as a repository; when you prepare a "
14901 "repository for working with patches using <command role=\"hg-ext-mq\">qinit</"
14902 "command>, you can pass the <option role=\"hg-ext-mq-cmd-qinit-opt\">hg -c</"
14903 "option> option to create the <filename role=\"special\" class=\"directory\">."
14904 "hg/patches</filename> directory as a Mercurial repository."
14905 msgstr ""
14907 #. type: Content of: <book><chapter><sect1><sect2><note><para>
14908 #: ../en/ch11-mq.xml:1042
14909 msgid ""
14910 "If you forget to use the <option role=\"hg-ext-mq-cmd-qinit-opt\">hg -c</"
14911 "option> option, you can simply go into the <filename role=\"special\" class="
14912 "\"directory\">.hg/patches</filename> directory at any time and run <command "
14913 "role=\"hg-cmd\">hg init</command>. Don't forget to add an entry for the "
14914 "<filename role=\"special\">status</filename> file to the <filename role="
14915 "\"special\">.hgignore</filename> file, though"
14916 msgstr ""
14918 #. type: Content of: <book><chapter><sect1><sect2><note><para>
14919 #: ../en/ch11-mq.xml:1051
14920 msgid ""
14921 "(<command role=\"hg-cmd\">hg qinit <option role=\"hg-ext-mq-cmd-qinit-opt"
14922 "\">hg -c</option></command> does this for you automatically); you "
14923 "<emphasis>really</emphasis> don't want to manage the <filename role=\"special"
14924 "\">status</filename> file."
14925 msgstr ""
14927 #. type: Content of: <book><chapter><sect1><sect2><para>
14928 #: ../en/ch11-mq.xml:1058
14929 msgid ""
14930 "As a convenience, if MQ notices that the <filename class=\"directory\">.hg/"
14931 "patches</filename> directory is a repository, it will automatically <command "
14932 "role=\"hg-cmd\">hg add</command> every patch that you create and import."
14933 msgstr ""
14935 #. type: Content of: <book><chapter><sect1><sect2><para>
14936 #: ../en/ch11-mq.xml:1063
14937 msgid ""
14938 "MQ provides a shortcut command, <command role=\"hg-ext-mq\">qcommit</"
14939 "command>, that runs <command role=\"hg-cmd\">hg commit</command> in the "
14940 "<filename role=\"special\" class=\"directory\">.hg/patches</filename> "
14941 "directory. This saves some bothersome typing."
14942 msgstr ""
14944 #. type: Content of: <book><chapter><sect1><sect2><para>
14945 #: ../en/ch11-mq.xml:1069
14946 msgid ""
14947 "Finally, as a convenience to manage the patch directory, you can define the "
14948 "alias <command>mq</command> on Unix systems. For example, on Linux systems "
14949 "using the <command>bash</command> shell, you can include the following "
14950 "snippet in your <filename role=\"home\">~/.bashrc</filename>."
14951 msgstr ""
14953 #. type: Content of: <book><chapter><sect1><sect2><para>
14954 #: ../en/ch11-mq.xml:1078
14955 msgid ""
14956 "You can then issue commands of the form <command>mq pull</command> from the "
14957 "main repository."
14958 msgstr ""
14960 #. type: Content of: <book><chapter><sect1><sect2><title>
14961 #: ../en/ch11-mq.xml:1083
14962 msgid "A few things to watch out for"
14963 msgstr "需要注意的事情"
14965 #. type: Content of: <book><chapter><sect1><sect2><para>
14966 #: ../en/ch11-mq.xml:1085
14967 msgid ""
14968 "MQ's support for working with a repository full of patches is limited in a "
14969 "few small respects."
14970 msgstr ""
14972 #. type: Content of: <book><chapter><sect1><sect2><para>
14973 #: ../en/ch11-mq.xml:1088
14974 msgid ""
14975 "MQ cannot automatically detect changes that you make to the patch directory. "
14976 "If you <command role=\"hg-cmd\">hg pull</command>, manually edit, or <command "
14977 "role=\"hg-cmd\">hg update</command> changes to patches or the <filename role="
14978 "\"special\">series</filename> file, you will have to <command role=\"hg-cmd"
14979 "\">hg qpop <option role=\"hg-ext-mq-cmd-qpop-opt\">hg -a</option></command> "
14980 "and then <command role=\"hg-cmd\">hg qpush <option role=\"hg-ext-mq-cmd-qpush-"
14981 "opt\">hg -a</option></command> in the underlying repository to see those "
14982 "changes show up there. If you forget to do this, you can confuse MQ's idea "
14983 "of which patches are applied."
14984 msgstr ""
14986 #. type: Content of: <book><chapter><sect1><title>
14987 #: ../en/ch11-mq.xml:1104
14988 msgid "Third party tools for working with patches"
14989 msgstr "操作补丁的第三方工具"
14991 #. type: Content of: <book><chapter><sect1><para>
14992 #: ../en/ch11-mq.xml:1106
14993 msgid ""
14994 "Once you've been working with patches for a while, you'll find yourself "
14995 "hungry for tools that will help you to understand and manipulate the patches "
14996 "you're dealing with."
14997 msgstr ""
14999 #. type: Content of: <book><chapter><sect1><para>
15000 #: ../en/ch11-mq.xml:1110
15001 msgid ""
15002 "The <command>diffstat</command> command <citation>web:diffstat</citation> "
15003 "generates a histogram of the modifications made to each file in a patch. It "
15004 "provides a good way to <quote>get a sense of</quote> a patch&emdash;which "
15005 "files it affects, and how much change it introduces to each file and as a "
15006 "whole. (I find that it's a good idea to use <command>diffstat</command>'s "
15007 "<option role=\"cmd-opt-diffstat\">-p</option> option as a matter of course, "
15008 "as otherwise it will try to do clever things with prefixes of file names that "
15009 "inevitably confuse at least me.)"
15010 msgstr ""
15012 #. type: Content of: <book><chapter><sect1><para>
15013 #: ../en/ch11-mq.xml:1124
15014 msgid ""
15015 "The <literal role=\"package\">patchutils</literal> package <citation>web:"
15016 "patchutils</citation> is invaluable. It provides a set of small utilities "
15017 "that follow the <quote>Unix philosophy;</quote> each does one useful thing "
15018 "with a patch. The <literal role=\"package\">patchutils</literal> command I "
15019 "use most is <command>filterdiff</command>, which extracts subsets from a "
15020 "patch file. For example, given a patch that modifies hundreds of files "
15021 "across dozens of directories, a single invocation of <command>filterdiff</"
15022 "command> can generate a smaller patch that only touches files whose names "
15023 "match a particular glob pattern. See <xref linkend=\"mq-collab:tips:interdiff"
15024 "\"/> for another example."
15025 msgstr ""
15027 #. type: Content of: <book><chapter><sect1><title>
15028 #: ../en/ch11-mq.xml:1140
15029 msgid "Good ways to work with patches"
15030 msgstr "操作补丁的好习惯"
15032 #. type: Content of: <book><chapter><sect1><para>
15033 #: ../en/ch11-mq.xml:1142
15034 msgid ""
15035 "Whether you are working on a patch series to submit to a free software or "
15036 "open source project, or a series that you intend to treat as a sequence of "
15037 "regular changesets when you're done, you can use some simple techniques to "
15038 "keep your work well organised."
15039 msgstr ""
15041 #. type: Content of: <book><chapter><sect1><para>
15042 #: ../en/ch11-mq.xml:1148
15043 msgid ""
15044 "Give your patches descriptive names. A good name for a patch might be "
15045 "<filename>rework-device-alloc.patch</filename>, because it will immediately "
15046 "give you a hint what the purpose of the patch is. Long names shouldn't be a "
15047 "problem; you won't be typing the names often, but you <emphasis>will</"
15048 "emphasis> be running commands like <command role=\"hg-ext-mq\">qapplied</"
15049 "command> and <command role=\"hg-ext-mq\">qtop</command> over and over. Good "
15050 "naming becomes especially important when you have a number of patches to work "
15051 "with, or if you are juggling a number of different tasks and your patches "
15052 "only get a fraction of your attention."
15053 msgstr ""
15055 #. type: Content of: <book><chapter><sect1><para>
15056 #: ../en/ch11-mq.xml:1160
15057 msgid ""
15058 "Be aware of what patch you're working on. Use the <command role=\"hg-ext-mq"
15059 "\">qtop</command> command and skim over the text of your patches "
15060 "frequently&emdash;for example, using <command role=\"hg-cmd\">hg tip <option "
15061 "role=\"hg-opt-tip\">-p</option></command>)&emdash;to be sure of where you "
15062 "stand. I have several times worked on and <command role=\"hg-ext-mq"
15063 "\">qrefresh</command>ed a patch other than the one I intended, and it's often "
15064 "tricky to migrate changes into the right patch after making them in the wrong "
15065 "one."
15066 msgstr ""
15068 #. type: Content of: <book><chapter><sect1><para>
15069 #: ../en/ch11-mq.xml:1170
15070 msgid ""
15071 "For this reason, it is very much worth investing a little time to learn how "
15072 "to use some of the third-party tools I described in <xref linkend=\"sec:mq:"
15073 "tools\"/>, particularly <command>diffstat</command> and <command>filterdiff</"
15074 "command>. The former will give you a quick idea of what changes your patch "
15075 "is making, while the latter makes it easy to splice hunks selectively out of "
15076 "one patch and into another."
15077 msgstr ""
15079 #. type: Content of: <book><chapter><sect1><title>
15080 #: ../en/ch11-mq.xml:1181
15081 msgid "MQ cookbook"
15082 msgstr "MQ 手册"
15084 #. type: Content of: <book><chapter><sect1><sect2><title>
15085 #: ../en/ch11-mq.xml:1184
15086 msgid "Manage <quote>trivial</quote> patches"
15087 msgstr "管理<quote>琐碎的</quote>补丁"
15089 #. type: Content of: <book><chapter><sect1><sect2><para>
15090 #: ../en/ch11-mq.xml:1186
15091 msgid ""
15092 "Because the overhead of dropping files into a new Mercurial repository is so "
15093 "low, it makes a lot of sense to manage patches this way even if you simply "
15094 "want to make a few changes to a source tarball that you downloaded."
15095 msgstr ""
15098 #. type: Content of: <book><chapter><sect1><sect2><para>
15099 #: ../en/ch11-mq.xml:1191
15100 msgid ""
15101 "Begin by downloading and unpacking the source tarball, and turning it into a "
15102 "Mercurial repository."
15103 msgstr ""
15105 #. type: Content of: <book><chapter><sect1><sect2><para>
15106 #: ../en/ch11-mq.xml:1196
15107 msgid "Continue by creating a patch stack and making your changes."
15108 msgstr ""
15110 #. type: Content of: <book><chapter><sect1><sect2><para>
15111 #: ../en/ch11-mq.xml:1201
15112 msgid ""
15113 "Let's say a few weeks or months pass, and your package author releases a new "
15114 "version. First, bring their changes into the repository."
15115 msgstr ""
15117 #. type: Content of: <book><chapter><sect1><sect2><para>
15118 #: ../en/ch11-mq.xml:1207
15119 msgid ""
15120 "The pipeline starting with <command role=\"hg-cmd\">hg locate</command> above "
15121 "deletes all files in the working directory, so that <command role=\"hg-cmd"
15122 "\">hg commit</command>'s <option role=\"hg-opt-commit\">--addremove</option> "
15123 "option can actually tell which files have really been removed in the newer "
15124 "version of the source."
15125 msgstr ""
15127 #. type: Content of: <book><chapter><sect1><sect2><para>
15128 #: ../en/ch11-mq.xml:1215
15129 msgid "Finally, you can apply your patches on top of the new tree."
15130 msgstr ""
15132 #. type: Content of: <book><chapter><sect1><sect2><title>
15133 #: ../en/ch11-mq.xml:1222
15134 msgid "Combining entire patches"
15135 msgstr "组合全部的补丁"
15137 #. type: Content of: <book><chapter><sect1><sect2><para>
15138 #: ../en/ch11-mq.xml:1224
15139 msgid ""
15140 "MQ provides a command, <command role=\"hg-ext-mq\">qfold</command> that lets "
15141 "you combine entire patches. This <quote>folds</quote> the patches you name, "
15142 "in the order you name them, into the topmost applied patch, and concatenates "
15143 "their descriptions onto the end of its description. The patches that you "
15144 "fold must be unapplied before you fold them."
15145 msgstr ""
15147 #. type: Content of: <book><chapter><sect1><sect2><para>
15148 #: ../en/ch11-mq.xml:1232
15149 msgid ""
15150 "The order in which you fold patches matters. If your topmost applied patch "
15151 "is <literal>foo</literal>, and you <command role=\"hg-ext-mq\">qfold</"
15152 "command> <literal>bar</literal> and <literal>quux</literal> into it, you will "
15153 "end up with a patch that has the same effect as if you applied first "
15154 "<literal>foo</literal>, then <literal>bar</literal>, followed by "
15155 "<literal>quux</literal>."
15156 msgstr ""
15158 #. type: Content of: <book><chapter><sect1><sect2><title>
15159 #: ../en/ch11-mq.xml:1243
15160 msgid "Merging part of one patch into another"
15161 msgstr "合并补丁的部分内容到其它补丁"
15163 #. type: Content of: <book><chapter><sect1><sect2><para>
15164 #: ../en/ch11-mq.xml:1245
15165 msgid ""
15166 "Merging <emphasis>part</emphasis> of one patch into another is more difficult "
15167 "than combining entire patches."
15168 msgstr ""
15170 #. type: Content of: <book><chapter><sect1><sect2><para>
15171 #: ../en/ch11-mq.xml:1249
15172 msgid ""
15173 "If you want to move changes to entire files, you can use <command>filterdiff</"
15174 "command>'s <option role=\"cmd-opt-filterdiff\">-i</option> and <option role="
15175 "\"cmd-opt-filterdiff\">-x</option> options to choose the modifications to "
15176 "snip out of one patch, concatenating its output onto the end of the patch you "
15177 "want to merge into. You usually won't need to modify the patch you've merged "
15178 "the changes from. Instead, MQ will report some rejected hunks when you "
15179 "<command role=\"hg-ext-mq\">qpush</command> it (from the hunks you moved into "
15180 "the other patch), and you can simply <command role=\"hg-ext-mq\">qrefresh</"
15181 "command> the patch to drop the duplicate hunks."
15182 msgstr ""
15184 #. type: Content of: <book><chapter><sect1><sect2><para>
15185 #: ../en/ch11-mq.xml:1262
15186 msgid ""
15187 "If you have a patch that has multiple hunks modifying a file, and you only "
15188 "want to move a few of those hunks, the job becomes more messy, but you can "
15189 "still partly automate it. Use <command>lsdiff -nvv</command> to print some "
15190 "metadata about the patch."
15191 msgstr ""
15193 #. type: Content of: <book><chapter><sect1><sect2><para>
15194 #: ../en/ch11-mq.xml:1270
15195 msgid "This command prints three different kinds of number:"
15196 msgstr ""
15198 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15199 #: ../en/ch11-mq.xml:1273
15200 msgid ""
15201 "(in the first column) a <emphasis>file number</emphasis> to identify each "
15202 "file modified in the patch;"
15203 msgstr ""
15205 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15206 #: ../en/ch11-mq.xml:1277
15207 msgid ""
15208 "(on the next line, indented) the line number within a modified file where a "
15209 "hunk starts; and"
15210 msgstr ""
15212 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15213 #: ../en/ch11-mq.xml:1280
15214 msgid ""
15215 "(on the same line) a <emphasis>hunk number</emphasis> to identify that hunk."
15216 msgstr ""
15218 #. type: Content of: <book><chapter><sect1><sect2><para>
15219 #: ../en/ch11-mq.xml:1284
15220 msgid ""
15221 "You'll have to use some visual inspection, and reading of the patch, to "
15222 "identify the file and hunk numbers you'll want, but you can then pass them to "
15223 "to <command>filterdiff</command>'s <option role=\"cmd-opt-filterdiff\">--"
15224 "files</option> and <option role=\"cmd-opt-filterdiff\">--hunks</option> "
15225 "options, to select exactly the file and hunk you want to extract."
15226 msgstr ""
15228 #. type: Content of: <book><chapter><sect1><sect2><para>
15229 #: ../en/ch11-mq.xml:1292
15230 msgid ""
15231 "Once you have this hunk, you can concatenate it onto the end of your "
15232 "destination patch and continue with the remainder of <xref linkend=\"sec:mq:"
15233 "combine\"/>."
15234 msgstr ""
15236 #. type: Content of: <book><chapter><sect1><title>
15237 #: ../en/ch11-mq.xml:1299
15238 msgid "Differences between quilt and MQ"
15239 msgstr "MQ 与 quilt 的区别"
15241 #. type: Content of: <book><chapter><sect1><para>
15242 #: ../en/ch11-mq.xml:1301
15243 msgid ""
15244 "If you are already familiar with quilt, MQ provides a similar command set. "
15245 "There are a few differences in the way that it works."
15246 msgstr ""
15248 #. type: Content of: <book><chapter><sect1><para>
15249 #: ../en/ch11-mq.xml:1305
15250 msgid ""
15251 "You will already have noticed that most quilt commands have MQ counterparts "
15252 "that simply begin with a <quote><literal>q</literal></quote>. The exceptions "
15253 "are quilt's <literal>add</literal> and <literal>remove</literal> commands, "
15254 "the counterparts for which are the normal Mercurial <command role=\"hg-cmd"
15255 "\">hg add</command> and <command role=\"hg-cmd\">hg remove</command> "
15256 "commands. There is no MQ equivalent of the quilt <literal>edit</literal> "
15257 "command."
15258 msgstr ""
15260 #. type: Content of: <book><chapter><title>
15261 #: ../en/ch12-mq-collab.xml:5
15262 msgid "Advanced uses of Mercurial Queues"
15263 msgstr "MQ 的高级用法"
15265 #. type: Content of: <book><chapter><para>
15266 #: ../en/ch12-mq-collab.xml:7
15267 msgid ""
15268 "While it's easy to pick up straightforward uses of Mercurial Queues, use of a "
15269 "little discipline and some of MQ's less frequently used capabilities makes it "
15270 "possible to work in complicated development environments."
15271 msgstr ""
15273 #. type: Content of: <book><chapter><para>
15274 #: ../en/ch12-mq-collab.xml:12
15275 msgid ""
15276 "In this chapter, I will use as an example a technique I have used to manage "
15277 "the development of an Infiniband device driver for the Linux kernel. The "
15278 "driver in question is large (at least as drivers go), with 25,000 lines of "
15279 "code spread across 35 source files. It is maintained by a small team of "
15280 "developers."
15281 msgstr ""
15283 #. type: Content of: <book><chapter><para>
15284 #: ../en/ch12-mq-collab.xml:18
15285 msgid ""
15286 "While much of the material in this chapter is specific to Linux, the same "
15287 "principles apply to any code base for which you're not the primary owner, and "
15288 "upon which you need to do a lot of development."
15289 msgstr ""
15291 #. type: Content of: <book><chapter><sect1><title>
15292 #: ../en/ch12-mq-collab.xml:24
15293 msgid "The problem of many targets"
15294 msgstr "多个目标的问题"
15296 #. type: Content of: <book><chapter><sect1><para>
15297 #: ../en/ch12-mq-collab.xml:26
15298 msgid ""
15299 "The Linux kernel changes rapidly, and has never been internally stable; "
15300 "developers frequently make drastic changes between releases. This means that "
15301 "a version of the driver that works well with a particular released version of "
15302 "the kernel will not even <emphasis>compile</emphasis> correctly against, "
15303 "typically, any other version."
15304 msgstr ""
15306 #. type: Content of: <book><chapter><sect1><para>
15307 #: ../en/ch12-mq-collab.xml:33
15308 msgid ""
15309 "To maintain a driver, we have to keep a number of distinct versions of Linux "
15310 "in mind."
15311 msgstr ""
15313 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15314 #: ../en/ch12-mq-collab.xml:36
15315 msgid ""
15316 "One target is the main Linux kernel development tree. Maintenance of the code "
15317 "is in this case partly shared by other developers in the kernel community, "
15318 "who make <quote>drive-by</quote> modifications to the driver as they develop "
15319 "and refine kernel subsystems."
15320 msgstr ""
15322 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15323 #: ../en/ch12-mq-collab.xml:42
15324 msgid ""
15325 "We also maintain a number of <quote>backports</quote> to older versions of "
15326 "the Linux kernel, to support the needs of customers who are running older "
15327 "Linux distributions that do not incorporate our drivers. (To "
15328 "<emphasis>backport</emphasis> a piece of code is to modify it to work in an "
15329 "older version of its target environment than the version it was developed "
15330 "for.)"
15331 msgstr ""
15333 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15334 #: ../en/ch12-mq-collab.xml:50
15335 msgid ""
15336 "Finally, we make software releases on a schedule that is necessarily not "
15337 "aligned with those used by Linux distributors and kernel developers, so that "
15338 "we can deliver new features to customers without forcing them to upgrade "
15339 "their entire kernels or distributions."
15340 msgstr ""
15342 #. type: Content of: <book><chapter><sect1><sect2><title>
15343 #: ../en/ch12-mq-collab.xml:58
15344 msgid "Tempting approaches that don't work well"
15345 msgstr "工作不好的诱人方法"
15347 #. type: Content of: <book><chapter><sect1><sect2><para>
15348 #: ../en/ch12-mq-collab.xml:60
15349 msgid ""
15350 "There are two <quote>standard</quote> ways to maintain a piece of software "
15351 "that has to target many different environments."
15352 msgstr ""
15354 #. type: Content of: <book><chapter><sect1><sect2><para>
15355 #: ../en/ch12-mq-collab.xml:64
15356 msgid ""
15357 "The first is to maintain a number of branches, each intended for a single "
15358 "target. The trouble with this approach is that you must maintain iron "
15359 "discipline in the flow of changes between repositories. A new feature or bug "
15360 "fix must start life in a <quote>pristine</quote> repository, then percolate "
15361 "out to every backport repository. Backport changes are more limited in the "
15362 "branches they should propagate to; a backport change that is applied to a "
15363 "branch where it doesn't belong will probably stop the driver from compiling."
15364 msgstr ""
15366 #. type: Content of: <book><chapter><sect1><sect2><para>
15367 #: ../en/ch12-mq-collab.xml:74
15368 msgid ""
15369 "The second is to maintain a single source tree filled with conditional "
15370 "statements that turn chunks of code on or off depending on the intended "
15371 "target. Because these <quote>ifdefs</quote> are not allowed in the Linux "
15372 "kernel tree, a manual or automatic process must be followed to strip them out "
15373 "and yield a clean tree. A code base maintained in this fashion rapidly "
15374 "becomes a rat's nest of conditional blocks that are difficult to understand "
15375 "and maintain."
15376 msgstr ""
15378 #. type: Content of: <book><chapter><sect1><sect2><para>
15379 #: ../en/ch12-mq-collab.xml:83
15380 msgid ""
15381 "Neither of these approaches is well suited to a situation where you don't "
15382 "<quote>own</quote> the canonical copy of a source tree. In the case of a "
15383 "Linux driver that is distributed with the standard kernel, Linus's tree "
15384 "contains the copy of the code that will be treated by the world as "
15385 "canonical. The upstream version of <quote>my</quote> driver can be modified "
15386 "by people I don't know, without me even finding out about it until after the "
15387 "changes show up in Linus's tree."
15388 msgstr ""
15390 #. type: Content of: <book><chapter><sect1><sect2><para>
15391 #: ../en/ch12-mq-collab.xml:93
15392 msgid ""
15393 "These approaches have the added weakness of making it difficult to generate "
15394 "well-formed patches to submit upstream."
15395 msgstr ""
15397 #. type: Content of: <book><chapter><sect1><sect2><para>
15398 #: ../en/ch12-mq-collab.xml:97
15399 msgid ""
15400 "In principle, Mercurial Queues seems like a good candidate to manage a "
15401 "development scenario such as the above. While this is indeed the case, MQ "
15402 "contains a few added features that make the job more pleasant."
15403 msgstr ""
15405 #. type: Content of: <book><chapter><sect1><title>
15406 #: ../en/ch12-mq-collab.xml:105
15407 msgid "Conditionally applying patches with guards"
15408 msgstr "有条件的应用补丁"
15410 #. type: Content of: <book><chapter><sect1><para>
15411 #: ../en/ch12-mq-collab.xml:107
15412 msgid ""
15413 "Perhaps the best way to maintain sanity with so many targets is to be able to "
15414 "choose specific patches to apply for a given situation. MQ provides a "
15415 "feature called <quote>guards</quote> (which originates with quilt's "
15416 "<literal>guards</literal> command) that does just this. To start off, let's "
15417 "create a simple repository for experimenting in."
15418 msgstr ""
15420 #. type: Content of: <book><chapter><sect1><para>
15421 #: ../en/ch12-mq-collab.xml:116
15422 msgid ""
15423 "This gives us a tiny repository that contains two patches that don't have any "
15424 "dependencies on each other, because they touch different files."
15425 msgstr ""
15427 #. type: Content of: <book><chapter><sect1><para>
15428 #: ../en/ch12-mq-collab.xml:120
15429 msgid ""
15430 "The idea behind conditional application is that you can <quote>tag</quote> a "
15431 "patch with a <emphasis>guard</emphasis>, which is simply a text string of "
15432 "your choosing, then tell MQ to select specific guards to use when applying "
15433 "patches. MQ will then either apply, or skip over, a guarded patch, depending "
15434 "on the guards that you have selected."
15435 msgstr ""
15437 #. type: Content of: <book><chapter><sect1><para>
15438 #: ../en/ch12-mq-collab.xml:127
15439 msgid ""
15440 "A patch can have an arbitrary number of guards; each one is "
15441 "<emphasis>positive</emphasis> (<quote>apply this patch if this guard is "
15442 "selected</quote>) or <emphasis>negative</emphasis> (<quote>skip this patch if "
15443 "this guard is selected</quote>). A patch with no guards is always applied."
15444 msgstr ""
15446 #. type: Content of: <book><chapter><sect1><title>
15447 #: ../en/ch12-mq-collab.xml:135
15448 msgid "Controlling the guards on a patch"
15449 msgstr "控制补丁的应用条件"
15451 #. type: Content of: <book><chapter><sect1><para>
15452 #: ../en/ch12-mq-collab.xml:137
15453 msgid ""
15454 "The <command role=\"hg-ext-mq\">qguard</command> command lets you determine "
15455 "which guards should apply to a patch, or display the guards that are already "
15456 "in effect. Without any arguments, it displays the guards on the current "
15457 "topmost patch."
15458 msgstr ""
15460 #. type: Content of: <book><chapter><sect1><para>
15461 #: ../en/ch12-mq-collab.xml:144
15462 msgid ""
15463 "To set a positive guard on a patch, prefix the name of the guard with a "
15464 "<quote><literal>+</literal></quote>."
15465 msgstr ""
15467 #. type: Content of: <book><chapter><sect1><para>
15468 #: ../en/ch12-mq-collab.xml:149
15469 msgid ""
15470 "To set a negative guard on a patch, prefix the name of the guard with a "
15471 "<quote><literal>-</literal></quote>."
15472 msgstr ""
15474 #. type: Content of: <book><chapter><sect1><note><para>
15475 #: ../en/ch12-mq-collab.xml:156
15476 msgid ""
15477 "The <command role=\"hg-ext-mq\">qguard</command> command <emphasis>sets</"
15478 "emphasis> the guards on a patch; it doesn't <emphasis>modify</emphasis> "
15479 "them. What this means is that if you run <command role=\"hg-cmd\">hg qguard "
15480 "+a +b</command> on a patch, then <command role=\"hg-cmd\">hg qguard +c</"
15481 "command> on the same patch, the <emphasis>only</emphasis> guard that will be "
15482 "set on it afterwards is <literal>+c</literal>."
15483 msgstr ""
15486 #. type: Content of: <book><chapter><sect1><para>
15487 #: ../en/ch12-mq-collab.xml:165
15488 msgid ""
15489 "Mercurial stores guards in the <filename role=\"special\">series</filename> "
15490 "file; the form in which they are stored is easy both to understand and to "
15491 "edit by hand. (In other words, you don't have to use the <command role=\"hg-"
15492 "ext-mq\">qguard</command> command if you don't want to; it's okay to simply "
15493 "edit the <filename role=\"special\">series</filename> file.)"
15494 msgstr ""
15496 #. type: Content of: <book><chapter><sect1><title>
15497 #: ../en/ch12-mq-collab.xml:177
15498 msgid "Selecting the guards to use"
15499 msgstr "选择使用的条件"
15501 #. type: Content of: <book><chapter><sect1><para>
15502 #: ../en/ch12-mq-collab.xml:179
15503 msgid ""
15504 "The <command role=\"hg-ext-mq\">qselect</command> command determines which "
15505 "guards are active at a given time. The effect of this is to determine which "
15506 "patches MQ will apply the next time you run <command role=\"hg-ext-mq"
15507 "\">qpush</command>. It has no other effect; in particular, it doesn't do "
15508 "anything to patches that are already applied."
15509 msgstr ""
15511 #. type: Content of: <book><chapter><sect1><para>
15512 #: ../en/ch12-mq-collab.xml:186
15513 msgid ""
15514 "With no arguments, the <command role=\"hg-ext-mq\">qselect</command> command "
15515 "lists the guards currently in effect, one per line of output. Each argument "
15516 "is treated as the name of a guard to apply."
15517 msgstr ""
15519 #. type: Content of: <book><chapter><sect1><para>
15520 #: ../en/ch12-mq-collab.xml:193
15521 msgid ""
15522 "In case you're interested, the currently selected guards are stored in the "
15523 "<filename role=\"special\">guards</filename> file."
15524 msgstr ""
15526 #. type: Content of: <book><chapter><sect1><para>
15527 #: ../en/ch12-mq-collab.xml:198
15528 msgid ""
15529 "We can see the effect the selected guards have when we run <command role=\"hg-"
15530 "ext-mq\">qpush</command>."
15531 msgstr ""
15533 #. type: Content of: <book><chapter><sect1><para>
15534 #: ../en/ch12-mq-collab.xml:203
15535 msgid ""
15536 "A guard cannot start with a <quote><literal>+</literal></quote> or "
15537 "<quote><literal>-</literal></quote> character. The name of a guard must not "
15538 "contain white space, but most other characters are acceptable. If you try to "
15539 "use a guard with an invalid name, MQ will complain:"
15540 msgstr ""
15542 #. type: Content of: <book><chapter><sect1><para>
15543 #: ../en/ch12-mq-collab.xml:212
15544 msgid "Changing the selected guards changes the patches that are applied."
15545 msgstr ""
15547 #. type: Content of: <book><chapter><sect1><para>
15548 #: ../en/ch12-mq-collab.xml:217
15549 msgid ""
15550 "You can see in the example below that negative guards take precedence over "
15551 "positive guards."
15552 msgstr ""
15554 #. type: Content of: <book><chapter><sect1><title>
15555 #: ../en/ch12-mq-collab.xml:224
15556 msgid "MQ's rules for applying patches"
15557 msgstr "MQ 应用补丁的规则"
15559 #. type: Content of: <book><chapter><sect1><para>
15560 #: ../en/ch12-mq-collab.xml:226
15561 msgid ""
15562 "The rules that MQ uses when deciding whether to apply a patch are as follows."
15563 msgstr ""
15565 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15566 #: ../en/ch12-mq-collab.xml:229
15567 msgid "A patch that has no guards is always applied."
15568 msgstr ""
15570 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15571 #: ../en/ch12-mq-collab.xml:232
15572 msgid ""
15573 "If the patch has any negative guard that matches any currently selected "
15574 "guard, the patch is skipped."
15575 msgstr ""
15577 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15578 #: ../en/ch12-mq-collab.xml:235
15579 msgid ""
15580 "If the patch has any positive guard that matches any currently selected "
15581 "guard, the patch is applied."
15582 msgstr ""
15584 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15585 #: ../en/ch12-mq-collab.xml:238
15586 msgid ""
15587 "If the patch has positive or negative guards, but none matches any currently "
15588 "selected guard, the patch is skipped."
15589 msgstr ""
15591 #. type: Content of: <book><chapter><sect1><title>
15592 #: ../en/ch12-mq-collab.xml:245
15593 msgid "Trimming the work environment"
15594 msgstr "修剪工作环境"
15596 #. type: Content of: <book><chapter><sect1><para>
15597 #: ../en/ch12-mq-collab.xml:247
15598 msgid ""
15599 "In working on the device driver I mentioned earlier, I don't apply the "
15600 "patches to a normal Linux kernel tree. Instead, I use a repository that "
15601 "contains only a snapshot of the source files and headers that are relevant to "
15602 "Infiniband development. This repository is 1% the size of a kernel "
15603 "repository, so it's easier to work with."
15604 msgstr ""
15606 #. type: Content of: <book><chapter><sect1><para>
15607 #: ../en/ch12-mq-collab.xml:254
15608 msgid ""
15609 "I then choose a <quote>base</quote> version on top of which the patches are "
15610 "applied. This is a snapshot of the Linux kernel tree as of a revision of my "
15611 "choosing. When I take the snapshot, I record the changeset ID from the "
15612 "kernel repository in the commit message. Since the snapshot preserves the "
15613 "<quote>shape</quote> and content of the relevant parts of the kernel tree, I "
15614 "can apply my patches on top of either my tiny repository or a normal kernel "
15615 "tree."
15616 msgstr ""
15618 #. type: Content of: <book><chapter><sect1><para>
15619 #: ../en/ch12-mq-collab.xml:263
15620 msgid ""
15621 "Normally, the base tree atop which the patches apply should be a snapshot of "
15622 "a very recent upstream tree. This best facilitates the development of "
15623 "patches that can easily be submitted upstream with few or no modifications."
15624 msgstr ""
15626 #. type: Content of: <book><chapter><sect1><title>
15627 #: ../en/ch12-mq-collab.xml:270
15628 msgid "Dividing up the <filename role=\"special\">series</filename> file"
15629 msgstr "分类补丁<filename role=\"special\">系列</filename>"
15631 #. type: Content of: <book><chapter><sect1><para>
15632 #: ../en/ch12-mq-collab.xml:273
15633 msgid ""
15634 "I categorise the patches in the <filename role=\"special\">series</filename> "
15635 "file into a number of logical groups. Each section of like patches begins "
15636 "with a block of comments that describes the purpose of the patches that "
15637 "follow."
15638 msgstr ""
15640 #. type: Content of: <book><chapter><sect1><para>
15641 #: ../en/ch12-mq-collab.xml:279
15642 msgid ""
15643 "The sequence of patch groups that I maintain follows. The ordering of these "
15644 "groups is important; I'll describe why after I introduce the groups."
15645 msgstr ""
15647 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15648 #: ../en/ch12-mq-collab.xml:283
15649 msgid ""
15650 "The <quote>accepted</quote> group. Patches that the development team has "
15651 "submitted to the maintainer of the Infiniband subsystem, and which he has "
15652 "accepted, but which are not present in the snapshot that the tiny repository "
15653 "is based on. These are <quote>read only</quote> patches, present only to "
15654 "transform the tree into a similar state as it is in the upstream maintainer's "
15655 "repository."
15656 msgstr ""
15658 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15659 #: ../en/ch12-mq-collab.xml:291
15660 msgid ""
15661 "The <quote>rework</quote> group. Patches that I have submitted, but that the "
15662 "upstream maintainer has requested modifications to before he will accept them."
15663 msgstr ""
15665 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15666 #: ../en/ch12-mq-collab.xml:296
15667 msgid ""
15668 "The <quote>pending</quote> group. Patches that I have not yet submitted to "
15669 "the upstream maintainer, but which we have finished working on. These will be "
15670 "<quote>read only</quote> for a while. If the upstream maintainer accepts "
15671 "them upon submission, I'll move them to the end of the <quote>accepted</"
15672 "quote> group. If he requests that I modify any, I'll move them to the "
15673 "beginning of the <quote>rework</quote> group."
15674 msgstr ""
15676 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15677 #: ../en/ch12-mq-collab.xml:305
15678 msgid ""
15679 "The <quote>in progress</quote> group. Patches that are actively being "
15680 "developed, and should not be submitted anywhere yet."
15681 msgstr ""
15683 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15684 #: ../en/ch12-mq-collab.xml:309
15685 msgid ""
15686 "The <quote>backport</quote> group. Patches that adapt the source tree to "
15687 "older versions of the kernel tree."
15688 msgstr ""
15690 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15691 #: ../en/ch12-mq-collab.xml:313
15692 msgid ""
15693 "The <quote>do not ship</quote> group. Patches that for some reason should "
15694 "never be submitted upstream. For example, one such patch might change "
15695 "embedded driver identification strings to make it easier to distinguish, in "
15696 "the field, between an out-of-tree version of the driver and a version shipped "
15697 "by a distribution vendor."
15698 msgstr ""
15700 #. type: Content of: <book><chapter><sect1><para>
15701 #: ../en/ch12-mq-collab.xml:321
15702 msgid ""
15703 "Now to return to the reasons for ordering groups of patches in this way. We "
15704 "would like the lowest patches in the stack to be as stable as possible, so "
15705 "that we will not need to rework higher patches due to changes in context. "
15706 "Putting patches that will never be changed first in the <filename role="
15707 "\"special\">series</filename> file serves this purpose."
15708 msgstr ""
15710 #. type: Content of: <book><chapter><sect1><para>
15711 #: ../en/ch12-mq-collab.xml:329
15712 msgid ""
15713 "We would also like the patches that we know we'll need to modify to be "
15714 "applied on top of a source tree that resembles the upstream tree as closely "
15715 "as possible. This is why we keep accepted patches around for a while."
15716 msgstr ""
15718 #. type: Content of: <book><chapter><sect1><para>
15719 #: ../en/ch12-mq-collab.xml:334
15720 msgid ""
15721 "The <quote>backport</quote> and <quote>do not ship</quote> patches float at "
15722 "the end of the <filename role=\"special\">series</filename> file. The "
15723 "backport patches must be applied on top of all other patches, and the "
15724 "<quote>do not ship</quote> patches might as well stay out of harm's way."
15725 msgstr ""
15727 #. type: Content of: <book><chapter><sect1><title>
15728 #: ../en/ch12-mq-collab.xml:343
15729 msgid "Maintaining the patch series"
15730 msgstr "维护补丁系列"
15732 #. type: Content of: <book><chapter><sect1><para>
15733 #: ../en/ch12-mq-collab.xml:345
15734 msgid ""
15735 "In my work, I use a number of guards to control which patches are to be "
15736 "applied."
15737 msgstr ""
15739 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15740 #: ../en/ch12-mq-collab.xml:349
15741 msgid ""
15742 "<quote>Accepted</quote> patches are guarded with <literal>accepted</"
15743 "literal>. I enable this guard most of the time. When I'm applying the "
15744 "patches on top of a tree where the patches are already present, I can turn "
15745 "this patch off, and the patches that follow it will apply cleanly."
15746 msgstr ""
15748 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15749 #: ../en/ch12-mq-collab.xml:356
15750 msgid ""
15751 "Patches that are <quote>finished</quote>, but not yet submitted, have no "
15752 "guards. If I'm applying the patch stack to a copy of the upstream tree, I "
15753 "don't need to enable any guards in order to get a reasonably safe source tree."
15754 msgstr ""
15756 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15757 #: ../en/ch12-mq-collab.xml:362
15758 msgid ""
15759 "Those patches that need reworking before being resubmitted are guarded with "
15760 "<literal>rework</literal>."
15761 msgstr ""
15763 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15764 #: ../en/ch12-mq-collab.xml:366
15765 msgid ""
15766 "For those patches that are still under development, I use <literal>devel</"
15767 "literal>."
15768 msgstr ""
15770 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15771 #: ../en/ch12-mq-collab.xml:369
15772 msgid ""
15773 "A backport patch may have several guards, one for each version of the kernel "
15774 "to which it applies. For example, a patch that backports a piece of code to "
15775 "2.6.9 will have a <literal>2.6.9</literal> guard."
15776 msgstr ""
15778 #. type: Content of: <book><chapter><sect1><para>
15779 #: ../en/ch12-mq-collab.xml:374
15780 msgid ""
15781 "This variety of guards gives me considerable flexibility in determining what "
15782 "kind of source tree I want to end up with. For most situations, the "
15783 "selection of appropriate guards is automated during the build process, but I "
15784 "can manually tune the guards to use for less common circumstances."
15785 msgstr ""
15787 #. type: Content of: <book><chapter><sect1><sect2><title>
15788 #: ../en/ch12-mq-collab.xml:381
15789 msgid "The art of writing backport patches"
15790 msgstr "编写向后移植补丁的艺术"
15792 #. type: Content of: <book><chapter><sect1><sect2><para>
15793 #: ../en/ch12-mq-collab.xml:383
15794 msgid ""
15795 "Using MQ, writing a backport patch is a simple process. All such a patch has "
15796 "to do is modify a piece of code that uses a kernel feature not present in the "
15797 "older version of the kernel, so that the driver continues to work correctly "
15798 "under that older version."
15799 msgstr ""
15801 #. type: Content of: <book><chapter><sect1><sect2><para>
15802 #: ../en/ch12-mq-collab.xml:389
15803 msgid ""
15804 "A useful goal when writing a good backport patch is to make your code look as "
15805 "if it was written for the older version of the kernel you're targeting. The "
15806 "less obtrusive the patch, the easier it will be to understand and maintain. "
15807 "If you're writing a collection of backport patches to avoid the <quote>rat's "
15808 "nest</quote> effect of lots of <literal>#ifdef</literal>s (hunks of source "
15809 "code that are only used conditionally) in your code, don't introduce version-"
15810 "dependent <literal>#ifdef</literal>s into the patches. Instead, write "
15811 "several patches, each of which makes unconditional changes, and control their "
15812 "application using guards."
15813 msgstr ""
15815 #. type: Content of: <book><chapter><sect1><sect2><para>
15816 #: ../en/ch12-mq-collab.xml:402
15817 msgid ""
15818 "There are two reasons to divide backport patches into a distinct group, away "
15819 "from the <quote>regular</quote> patches whose effects they modify. The first "
15820 "is that intermingling the two makes it more difficult to use a tool like the "
15821 "<literal role=\"hg-ext\">patchbomb</literal> extension to automate the "
15822 "process of submitting the patches to an upstream maintainer. The second is "
15823 "that a backport patch could perturb the context in which a subsequent regular "
15824 "patch is applied, making it impossible to apply the regular patch cleanly "
15825 "<emphasis>without</emphasis> the earlier backport patch already being applied."
15826 msgstr ""
15828 #. type: Content of: <book><chapter><sect1><title>
15829 #: ../en/ch12-mq-collab.xml:417
15830 msgid "Useful tips for developing with MQ"
15831 msgstr "使用 MQ 开发的技巧"
15833 #. type: Content of: <book><chapter><sect1><sect2><title>
15834 #: ../en/ch12-mq-collab.xml:420
15835 msgid "Organising patches in directories"
15836 msgstr "将补丁放到几个目录中"
15838 #. type: Content of: <book><chapter><sect1><sect2><para>
15839 #: ../en/ch12-mq-collab.xml:422
15840 msgid ""
15841 "If you're working on a substantial project with MQ, it's not difficult to "
15842 "accumulate a large number of patches. For example, I have one patch "
15843 "repository that contains over 250 patches."
15844 msgstr ""
15846 #. type: Content of: <book><chapter><sect1><sect2><para>
15847 #: ../en/ch12-mq-collab.xml:427
15848 msgid ""
15849 "If you can group these patches into separate logical categories, you can if "
15850 "you like store them in different directories; MQ has no problems with patch "
15851 "names that contain path separators."
15852 msgstr ""
15854 #. type: Content of: <book><chapter><sect1><sect2><title>
15855 #: ../en/ch12-mq-collab.xml:434
15856 msgid "Viewing the history of a patch"
15857 msgstr "察看补丁的历史"
15859 #. type: Content of: <book><chapter><sect1><sect2><para>
15860 #: ../en/ch12-mq-collab.xml:436
15861 msgid ""
15862 "If you're developing a set of patches over a long time, it's a good idea to "
15863 "maintain them in a repository, as discussed in <xref linkend=\"sec:mq:repo\"/"
15864 ">. If you do so, you'll quickly discover that using the <command role=\"hg-"
15865 "cmd\">hg diff</command> command to look at the history of changes to a patch "
15866 "is unworkable. This is in part because you're looking at the second "
15867 "derivative of the real code (a diff of a diff), but also because MQ adds "
15868 "noise to the process by modifying time stamps and directory names when it "
15869 "updates a patch."
15870 msgstr ""
15872 #. type: Content of: <book><chapter><sect1><sect2><para>
15873 #: ../en/ch12-mq-collab.xml:448
15874 msgid ""
15875 "However, you can use the <literal role=\"hg-ext\">extdiff</literal> "
15876 "extension, which is bundled with Mercurial, to turn a diff of two versions of "
15877 "a patch into something readable. To do this, you will need a third-party "
15878 "package called <literal role=\"package\">patchutils</literal> <citation>web:"
15879 "patchutils</citation>. This provides a command named <command>interdiff</"
15880 "command>, which shows the differences between two diffs as a diff. Used on "
15881 "two versions of the same diff, it generates a diff that represents the diff "
15882 "from the first to the second version."
15883 msgstr ""
15885 #. type: Content of: <book><chapter><sect1><sect2><para>
15886 #: ../en/ch12-mq-collab.xml:459
15887 msgid ""
15888 "You can enable the <literal role=\"hg-ext\">extdiff</literal> extension in "
15889 "the usual way, by adding a line to the <literal role=\"rc-extensions"
15890 "\">extensions</literal> section of your <filename role=\"special\">~/.hgrc</"
15891 "filename>."
15892 msgstr ""
15895 #. &example.hg-interdiff;
15896 #. type: Content of: <book><chapter><sect1><sect2><para>
15897 #: ../en/ch12-mq-collab.xml:466
15898 msgid ""
15899 "The <command>interdiff</command> command expects to be passed the names of "
15900 "two files, but the <literal role=\"hg-ext\">extdiff</literal> extension "
15901 "passes the program it runs a pair of directories, each of which can contain "
15902 "an arbitrary number of files. We thus need a small program that will run "
15903 "<command>interdiff</command> on each pair of files in these two directories. "
15904 "This program is available as <filename role=\"special\">hg-interdiff</"
15905 "filename> in the <filename class=\"directory\">examples</filename> directory "
15906 "of the source code repository that accompanies this book."
15907 msgstr ""
15909 #. type: Content of: <book><chapter><sect1><sect2><para>
15910 #: ../en/ch12-mq-collab.xml:478
15911 msgid ""
15912 "With the <filename role=\"special\">hg-interdiff</filename> program in your "
15913 "shell's search path, you can run it as follows, from inside an MQ patch "
15914 "directory:"
15915 msgstr ""
15917 #. type: Content of: <book><chapter><sect1><sect2><para>
15918 #: ../en/ch12-mq-collab.xml:482
15919 msgid ""
15920 "Since you'll probably want to use this long-winded command a lot, you can get "
15921 "<literal role=\"hg-ext\">hgext</literal> to make it available as a normal "
15922 "Mercurial command, again by editing your <filename role=\"special\">~/.hgrc</"
15923 "filename>."
15924 msgstr ""
15926 #. type: Content of: <book><chapter><sect1><sect2><para>
15927 #: ../en/ch12-mq-collab.xml:489
15928 msgid ""
15929 "This directs <literal role=\"hg-ext\">hgext</literal> to make an "
15930 "<literal>interdiff</literal> command available, so you can now shorten the "
15931 "previous invocation of <command role=\"hg-ext-extdiff\">extdiff</command> to "
15932 "something a little more wieldy."
15933 msgstr ""
15935 #. type: Content of: <book><chapter><sect1><sect2><note><para>
15936 #: ../en/ch12-mq-collab.xml:497
15937 msgid ""
15938 "The <command>interdiff</command> command works well only if the underlying "
15939 "files against which versions of a patch are generated remain the same. If "
15940 "you create a patch, modify the underlying files, and then regenerate the "
15941 "patch, <command>interdiff</command> may not produce useful output."
15942 msgstr ""
15944 #. type: Content of: <book><chapter><sect1><sect2><para>
15945 #: ../en/ch12-mq-collab.xml:505
15946 msgid ""
15947 "The <literal role=\"hg-ext\">extdiff</literal> extension is useful for more "
15948 "than merely improving the presentation of MQ patches. To read more about it, "
15949 "go to <xref linkend=\"sec:hgext:extdiff\"/>."
15950 msgstr ""
15952 #. type: Content of: <book><chapter><title>
15953 #: ../en/ch13-hgext.xml:5
15954 msgid "Adding functionality with extensions"
15955 msgstr "使用扩展增加功能"
15957 #. type: Content of: <book><chapter><para>
15958 #: ../en/ch13-hgext.xml:7
15959 msgid ""
15960 "While the core of Mercurial is quite complete from a functionality "
15961 "standpoint, it's deliberately shorn of fancy features. This approach of "
15962 "preserving simplicity keeps the software easy to deal with for both "
15963 "maintainers and users."
15964 msgstr ""
15966 #. type: Content of: <book><chapter><para>
15967 #: ../en/ch13-hgext.xml:12
15968 msgid ""
15969 "However, Mercurial doesn't box you in with an inflexible command set: you can "
15970 "add features to it as <emphasis>extensions</emphasis> (sometimes known as "
15971 "<emphasis>plugins</emphasis>). We've already discussed a few of these "
15972 "extensions in earlier chapters."
15973 msgstr ""
15975 #. type: Content of: <book><chapter><itemizedlist><listitem><para>
15976 #: ../en/ch13-hgext.xml:18
15977 msgid ""
15978 "<xref linkend=\"sec:tour-merge:fetch\"/> covers the <literal role=\"hg-ext"
15979 "\">fetch</literal> extension; this combines pulling new changes and merging "
15980 "them with local changes into a single command, <command role=\"hg-ext-fetch"
15981 "\">fetch</command>."
15982 msgstr ""
15984 #. type: Content of: <book><chapter><itemizedlist><listitem><para>
15985 #: ../en/ch13-hgext.xml:24
15986 msgid ""
15987 "In <xref linkend=\"chap:hook\"/>, we covered several extensions that are "
15988 "useful for hook-related functionality: <literal role=\"hg-ext\">acl</literal> "
15989 "adds access control lists; <literal role=\"hg-ext\">bugzilla</literal> adds "
15990 "integration with the Bugzilla bug tracking system; and <literal role=\"hg-ext"
15991 "\">notify</literal> sends notification emails on new changes."
15992 msgstr ""
15994 #. type: Content of: <book><chapter><itemizedlist><listitem><para>
15995 #: ../en/ch13-hgext.xml:33
15996 msgid ""
15997 "The Mercurial Queues patch management extension is so invaluable that it "
15998 "merits two chapters and an appendix all to itself. <xref linkend=\"chap:mq\"/"
15999 "> covers the basics; <xref linkend=\"chap:mq-collab\"/> discusses advanced "
16000 "topics; and <xref linkend=\"chap:mqref\"/> goes into detail on each command."
16001 msgstr ""
16003 #. type: Content of: <book><chapter><para>
16004 #: ../en/ch13-hgext.xml:43
16005 msgid ""
16006 "In this chapter, we'll cover some of the other extensions that are available "
16007 "for Mercurial, and briefly touch on some of the machinery you'll need to know "
16008 "about if you want to write an extension of your own."
16009 msgstr ""
16011 #. type: Content of: <book><chapter><itemizedlist><listitem><para>
16012 #: ../en/ch13-hgext.xml:48
16013 msgid ""
16014 "In <xref linkend=\"sec:hgext:inotify\"/>, we'll discuss the possibility of "
16015 "<emphasis>huge</emphasis> performance improvements using the <literal role="
16016 "\"hg-ext\">inotify</literal> extension."
16017 msgstr ""
16019 #. type: Content of: <book><chapter><sect1><title>
16020 #: ../en/ch13-hgext.xml:55
16021 msgid ""
16022 "Improve performance with the <literal role=\"hg-ext\">inotify</literal> "
16023 "extension"
16024 msgstr "使用扩展 <literal role=\"hg-ext\">inotify</literal> 以提高性能"
16026 #. type: Content of: <book><chapter><sect1><para>
16027 #: ../en/ch13-hgext.xml:58
16028 msgid ""
16029 "Are you interested in having some of the most common Mercurial operations run "
16030 "as much as a hundred times faster? Read on!"
16031 msgstr ""
16033 #. type: Content of: <book><chapter><sect1><para>
16034 #: ../en/ch13-hgext.xml:62
16035 msgid ""
16036 "Mercurial has great performance under normal circumstances. For example, "
16037 "when you run the <command role=\"hg-cmd\">hg status</command> command, "
16038 "Mercurial has to scan almost every directory and file in your repository so "
16039 "that it can display file status. Many other Mercurial commands need to do "
16040 "the same work behind the scenes; for example, the <command role=\"hg-cmd\">hg "
16041 "diff</command> command uses the status machinery to avoid doing an expensive "
16042 "comparison operation on files that obviously haven't changed."
16043 msgstr ""
16045 #. type: Content of: <book><chapter><sect1><para>
16046 #: ../en/ch13-hgext.xml:72
16047 msgid ""
16048 "Because obtaining file status is crucial to good performance, the authors of "
16049 "Mercurial have optimised this code to within an inch of its life. However, "
16050 "there's no avoiding the fact that when you run <command role=\"hg-cmd\">hg "
16051 "status</command>, Mercurial is going to have to perform at least one "
16052 "expensive system call for each managed file to determine whether it's changed "
16053 "since the last time Mercurial checked. For a sufficiently large repository, "
16054 "this can take a long time."
16055 msgstr ""
16057 #. type: Content of: <book><chapter><sect1><para>
16058 #: ../en/ch13-hgext.xml:82
16059 msgid ""
16060 "To put a number on the magnitude of this effect, I created a repository "
16061 "containing 150,000 managed files. I timed <command role=\"hg-cmd\">hg "
16062 "status</command> as taking ten seconds to run, even when <emphasis>none</"
16063 "emphasis> of those files had been modified."
16064 msgstr ""
16066 #. type: Content of: <book><chapter><sect1><para>
16067 #: ../en/ch13-hgext.xml:88
16068 msgid ""
16069 "Many modern operating systems contain a file notification facility. If a "
16070 "program signs up to an appropriate service, the operating system will notify "
16071 "it every time a file of interest is created, modified, or deleted. On Linux "
16072 "systems, the kernel component that does this is called <literal>inotify</"
16073 "literal>."
16074 msgstr ""
16076 #. type: Content of: <book><chapter><sect1><para>
16077 #: ../en/ch13-hgext.xml:95
16078 msgid ""
16079 "Mercurial's <literal role=\"hg-ext\">inotify</literal> extension talks to the "
16080 "kernel's <literal>inotify</literal> component to optimise <command role=\"hg-"
16081 "cmd\">hg status</command> commands. The extension has two components. A "
16082 "daemon sits in the background and receives notifications from the "
16083 "<literal>inotify</literal> subsystem. It also listens for connections from a "
16084 "regular Mercurial command. The extension modifies Mercurial's behaviour so "
16085 "that instead of scanning the filesystem, it queries the daemon. Since the "
16086 "daemon has perfect information about the state of the repository, it can "
16087 "respond with a result instantaneously, avoiding the need to scan every "
16088 "directory and file in the repository."
16089 msgstr ""
16091 #. type: Content of: <book><chapter><sect1><para>
16092 #: ../en/ch13-hgext.xml:108
16093 msgid ""
16094 "Recall the ten seconds that I measured plain Mercurial as taking to run "
16095 "<command role=\"hg-cmd\">hg status</command> on a 150,000 file repository. "
16096 "With the <literal role=\"hg-ext\">inotify</literal> extension enabled, the "
16097 "time dropped to 0.1 seconds, a factor of <emphasis>one hundred</emphasis> "
16098 "faster."
16099 msgstr ""
16101 #. type: Content of: <book><chapter><sect1><para>
16102 #: ../en/ch13-hgext.xml:115
16103 msgid "Before we continue, please pay attention to some caveats."
16104 msgstr ""
16106 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
16107 #: ../en/ch13-hgext.xml:118
16108 msgid ""
16109 "The <literal role=\"hg-ext\">inotify</literal> extension is Linux-specific. "
16110 "Because it interfaces directly to the Linux kernel's <literal>inotify</"
16111 "literal> subsystem, it does not work on other operating systems."
16112 msgstr ""
16114 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
16115 #: ../en/ch13-hgext.xml:123
16116 msgid ""
16117 "It should work on any Linux distribution that was released after early 2005. "
16118 "Older distributions are likely to have a kernel that lacks <literal>inotify</"
16119 "literal>, or a version of <literal>glibc</literal> that does not have the "
16120 "necessary interfacing support."
16121 msgstr ""
16123 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
16124 #: ../en/ch13-hgext.xml:130
16125 msgid ""
16126 "Not all filesystems are suitable for use with the <literal role=\"hg-ext"
16127 "\">inotify</literal> extension. Network filesystems such as NFS are a non-"
16128 "starter, for example, particularly if you're running Mercurial on several "
16129 "systems, all mounting the same network filesystem. The kernel's "
16130 "<literal>inotify</literal> system has no way of knowing about changes made on "
16131 "another system. Most local filesystems (e.g. ext3, XFS, ReiserFS) should "
16132 "work fine."
16133 msgstr ""
16135 #. type: Content of: <book><chapter><sect1><para>
16136 #: ../en/ch13-hgext.xml:141
16137 msgid ""
16138 "The <literal role=\"hg-ext\">inotify</literal> extension is not yet shipped "
16139 "with Mercurial as of May 2007, so it's a little more involved to set up than "
16140 "other extensions. But the performance improvement is worth it!"
16141 msgstr ""
16143 #. type: Content of: <book><chapter><sect1><para>
16144 #: ../en/ch13-hgext.xml:146
16145 msgid ""
16146 "The extension currently comes in two parts: a set of patches to the Mercurial "
16147 "source code, and a library of Python bindings to the <literal>inotify</"
16148 "literal> subsystem."
16149 msgstr ""
16151 #. type: Content of: <book><chapter><sect1><note><para>
16152 #: ../en/ch13-hgext.xml:150
16153 msgid ""
16154 "There are <emphasis>two</emphasis> Python <literal>inotify</literal> binding "
16155 "libraries. One of them is called <literal>pyinotify</literal>, and is "
16156 "packaged by some Linux distributions as <literal>python-inotify</literal>. "
16157 "This is <emphasis>not</emphasis> the one you'll need, as it is too buggy and "
16158 "inefficient to be practical."
16159 msgstr ""
16161 #. type: Content of: <book><chapter><sect1><para>
16162 #: ../en/ch13-hgext.xml:157
16163 msgid ""
16164 "To get going, it's best to already have a functioning copy of Mercurial "
16165 "installed."
16166 msgstr ""
16168 #. type: Content of: <book><chapter><sect1><note><para>
16169 #: ../en/ch13-hgext.xml:160
16170 msgid ""
16171 "If you follow the instructions below, you'll be <emphasis>replacing</"
16172 "emphasis> and overwriting any existing installation of Mercurial that you "
16173 "might already have, using the latest <quote>bleeding edge</quote> Mercurial "
16174 "code. Don't say you weren't warned!"
16175 msgstr ""
16177 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
16178 #: ../en/ch13-hgext.xml:167
16179 msgid ""
16180 "Clone the Python <literal>inotify</literal> binding repository. Build and "
16181 "install it."
16182 msgstr ""
16184 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
16185 #: ../en/ch13-hgext.xml:174
16186 msgid ""
16187 "Clone the <filename class=\"directory\">crew</filename> Mercurial "
16188 "repository. Clone the <literal role=\"hg-ext\">inotify</literal> patch "
16189 "repository so that Mercurial Queues will be able to apply patches to your "
16190 "cope of the <filename class=\"directory\">crew</filename> repository."
16191 msgstr ""
16193 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
16194 #: ../en/ch13-hgext.xml:184
16195 msgid ""
16196 "Make sure that you have the Mercurial Queues extension, <literal role=\"hg-ext"
16197 "\">mq</literal>, enabled. If you've never used MQ, read <xref linkend=\"sec:"
16198 "mq:start\"/> to get started quickly."
16199 msgstr ""
16201 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
16202 #: ../en/ch13-hgext.xml:190
16203 msgid ""
16204 "Go into the <filename class=\"directory\">inotify</filename> repo, and apply "
16205 "all of the <literal role=\"hg-ext\">inotify</literal> patches using the "
16206 "<option role=\"hg-ext-mq-cmd-qpush-opt\">hg -a</option> option to the "
16207 "<command role=\"hg-ext-mq\">qpush</command> command."
16208 msgstr ""
16210 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
16211 #: ../en/ch13-hgext.xml:199
16212 msgid ""
16213 "If you get an error message from <command role=\"hg-ext-mq\">qpush</command>, "
16214 "you should not continue. Instead, ask for help."
16215 msgstr ""
16217 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
16218 #: ../en/ch13-hgext.xml:203
16219 msgid "Build and install the patched version of Mercurial."
16220 msgstr ""
16222 #. type: Content of: <book><chapter><sect1><para>
16223 #: ../en/ch13-hgext.xml:209
16224 msgid ""
16225 "Once you've build a suitably patched version of Mercurial, all you need to do "
16226 "to enable the <literal role=\"hg-ext\">inotify</literal> extension is add an "
16227 "entry to your <filename role=\"special\">~/.hgrc</filename>."
16228 msgstr ""
16230 #. type: Content of: <book><chapter><sect1><para>
16231 #: ../en/ch13-hgext.xml:214
16232 msgid ""
16233 "When the <literal role=\"hg-ext\">inotify</literal> extension is enabled, "
16234 "Mercurial will automatically and transparently start the status daemon the "
16235 "first time you run a command that needs status in a repository. It runs one "
16236 "status daemon per repository."
16237 msgstr ""
16239 #. type: Content of: <book><chapter><sect1><para>
16240 #: ../en/ch13-hgext.xml:220
16241 msgid ""
16242 "The status daemon is started silently, and runs in the background. If you "
16243 "look at a list of running processes after you've enabled the <literal role="
16244 "\"hg-ext\">inotify</literal> extension and run a few commands in different "
16245 "repositories, you'll thus see a few <literal>hg</literal> processes sitting "
16246 "around, waiting for updates from the kernel and queries from Mercurial."
16247 msgstr ""
16249 #. type: Content of: <book><chapter><sect1><para>
16250 #: ../en/ch13-hgext.xml:228
16251 msgid ""
16252 "The first time you run a Mercurial command in a repository when you have the "
16253 "<literal role=\"hg-ext\">inotify</literal> extension enabled, it will run "
16254 "with about the same performance as a normal Mercurial command. This is "
16255 "because the status daemon needs to perform a normal status scan so that it "
16256 "has a baseline against which to apply later updates from the kernel. "
16257 "However, <emphasis>every</emphasis> subsequent command that does any kind of "
16258 "status check should be noticeably faster on repositories of even fairly "
16259 "modest size. Better yet, the bigger your repository is, the greater a "
16260 "performance advantage you'll see. The <literal role=\"hg-ext\">inotify</"
16261 "literal> daemon makes status operations almost instantaneous on repositories "
16262 "of all sizes!"
16263 msgstr ""
16265 #. type: Content of: <book><chapter><sect1><para>
16266 #: ../en/ch13-hgext.xml:242
16267 msgid ""
16268 "If you like, you can manually start a status daemon using the <command role="
16269 "\"hg-ext-inotify\">inserve</command> command. This gives you slightly finer "
16270 "control over how the daemon ought to run. This command will of course only "
16271 "be available when the <literal role=\"hg-ext\">inotify</literal> extension is "
16272 "enabled."
16273 msgstr ""
16275 #. type: Content of: <book><chapter><sect1><para>
16276 #: ../en/ch13-hgext.xml:249
16277 msgid ""
16278 "When you're using the <literal role=\"hg-ext\">inotify</literal> extension, "
16279 "you should notice <emphasis>no difference at all</emphasis> in Mercurial's "
16280 "behaviour, with the sole exception of status-related commands running a whole "
16281 "lot faster than they used to. You should specifically expect that commands "
16282 "will not print different output; neither should they give different results. "
16283 "If either of these situations occurs, please report a bug."
16284 msgstr ""
16286 #. type: Content of: <book><chapter><sect1><title>
16287 #: ../en/ch13-hgext.xml:260
16288 msgid ""
16289 "Flexible diff support with the <literal role=\"hg-ext\">extdiff</literal> "
16290 "extension"
16291 msgstr "使用扩展 <literal role=\"hg-ext\">extdiff</literal> 以扩展差异支持"
16293 #. type: Content of: <book><chapter><sect1><para>
16294 #: ../en/ch13-hgext.xml:263
16295 msgid ""
16296 "Mercurial's built-in <command role=\"hg-cmd\">hg diff</command> command "
16297 "outputs plaintext unified diffs."
16298 msgstr ""
16299 "Mercurial 内置命令 <command role=\"hg-cmd\">hg diff</command> 的输出与统一差异"
16300 "不同。"
16302 #. type: Content of: <book><chapter><sect1><para>
16303 #: ../en/ch13-hgext.xml:268
16304 msgid ""
16305 "If you would like to use an external tool to display modifications, you'll "
16306 "want to use the <literal role=\"hg-ext\">extdiff</literal> extension. This "
16307 "will let you use, for example, a graphical diff tool."
16308 msgstr ""
16310 #. type: Content of: <book><chapter><sect1><para>
16311 #: ../en/ch13-hgext.xml:273
16312 msgid ""
16313 "The <literal role=\"hg-ext\">extdiff</literal> extension is bundled with "
16314 "Mercurial, so it's easy to set up. In the <literal role=\"rc-extensions"
16315 "\">extensions</literal> section of your <filename role=\"special\">~/.hgrc</"
16316 "filename>, simply add a one-line entry to enable the extension."
16317 msgstr ""
16319 #. type: Content of: <book><chapter><sect1><para>
16320 #: ../en/ch13-hgext.xml:280
16321 msgid ""
16322 "This introduces a command named <command role=\"hg-ext-extdiff\">extdiff</"
16323 "command>, which by default uses your system's <command>diff</command> command "
16324 "to generate a unified diff in the same form as the built-in <command role="
16325 "\"hg-cmd\">hg diff</command> command."
16326 msgstr ""
16328 #. type: Content of: <book><chapter><sect1><para>
16329 #: ../en/ch13-hgext.xml:288
16330 msgid ""
16331 "The result won't be exactly the same as with the built-in <command role=\"hg-"
16332 "cmd\">hg diff</command> variations, because the output of <command>diff</"
16333 "command> varies from one system to another, even when passed the same options."
16334 msgstr ""
16336 #. type: Content of: <book><chapter><sect1><para>
16337 #: ../en/ch13-hgext.xml:293
16338 msgid ""
16339 "As the <quote><literal>making snapshot</literal></quote> lines of output "
16340 "above imply, the <command role=\"hg-ext-extdiff\">extdiff</command> command "
16341 "works by creating two snapshots of your source tree. The first snapshot is "
16342 "of the source revision; the second, of the target revision or working "
16343 "directory. The <command role=\"hg-ext-extdiff\">extdiff</command> command "
16344 "generates these snapshots in a temporary directory, passes the name of each "
16345 "directory to an external diff viewer, then deletes the temporary directory. "
16346 "For efficiency, it only snapshots the directories and files that have changed "
16347 "between the two revisions."
16348 msgstr ""
16350 #. type: Content of: <book><chapter><sect1><para>
16351 #: ../en/ch13-hgext.xml:306
16352 msgid ""
16353 "Snapshot directory names have the same base name as your repository. If your "
16354 "repository path is <filename class=\"directory\">/quux/bar/foo</filename>, "
16355 "then <filename class=\"directory\">foo</filename> will be the name of each "
16356 "snapshot directory. Each snapshot directory name has its changeset ID "
16357 "appended, if appropriate. If a snapshot is of revision "
16358 "<literal>a631aca1083f</literal>, the directory will be named <filename class="
16359 "\"directory\">foo.a631aca1083f</filename>. A snapshot of the working "
16360 "directory won't have a changeset ID appended, so it would just be <filename "
16361 "class=\"directory\">foo</filename> in this example. To see what this looks "
16362 "like in practice, look again at the <command role=\"hg-ext-extdiff\">extdiff</"
16363 "command> example above. Notice that the diff has the snapshot directory "
16364 "names embedded in its header."
16365 msgstr ""
16367 #. type: Content of: <book><chapter><sect1><para>
16368 #: ../en/ch13-hgext.xml:322
16369 msgid ""
16370 "The <command role=\"hg-ext-extdiff\">extdiff</command> command accepts two "
16371 "important options. The <option role=\"hg-ext-extdiff-cmd-extdiff-opt\">hg -p</"
16372 "option> option lets you choose a program to view differences with, instead of "
16373 "<command>diff</command>. With the <option role=\"hg-ext-extdiff-cmd-extdiff-"
16374 "opt\">hg -o</option> option, you can change the options that <command role="
16375 "\"hg-ext-extdiff\">extdiff</command> passes to the program (by default, these "
16376 "options are <quote><literal>-Npru</literal></quote>, which only make sense if "
16377 "you're running <command>diff</command>). In other respects, the <command "
16378 "role=\"hg-ext-extdiff\">extdiff</command> command acts similarly to the built-"
16379 "in <command role=\"hg-cmd\">hg diff</command> command: you use the same "
16380 "option names, syntax, and arguments to specify the revisions you want, the "
16381 "files you want, and so on."
16382 msgstr ""
16385 #. type: Content of: <book><chapter><sect1><para>
16386 #: ../en/ch13-hgext.xml:339
16387 msgid ""
16388 "As an example, here's how to run the normal system <command>diff</command> "
16389 "command, getting it to generate context diffs (using the <option role=\"cmd-"
16390 "opt-diff\">-c</option> option) instead of unified diffs, and five lines of "
16391 "context instead of the default three (passing <literal>5</literal> as the "
16392 "argument to the <option role=\"cmd-opt-diff\">-C</option> option)."
16393 msgstr ""
16395 #. type: Content of: <book><chapter><sect1><para>
16396 #: ../en/ch13-hgext.xml:348
16397 msgid ""
16398 "Launching a visual diff tool is just as easy. Here's how to launch the "
16399 "<command>kdiff3</command> viewer."
16400 msgstr ""
16402 #. type: Content of: <book><chapter><sect1><para>
16403 #: ../en/ch13-hgext.xml:352
16404 msgid ""
16405 "If your diff viewing command can't deal with directories, you can easily work "
16406 "around this with a little scripting. For an example of such scripting in "
16407 "action with the <literal role=\"hg-ext\">mq</literal> extension and the "
16408 "<command>interdiff</command> command, see <xref linkend=\"mq-collab:tips:"
16409 "interdiff\"/>."
16410 msgstr ""
16412 #. type: Content of: <book><chapter><sect1><sect2><title>
16413 #: ../en/ch13-hgext.xml:360
16414 msgid "Defining command aliases"
16415 msgstr "定义命令的别名"
16417 #. type: Content of: <book><chapter><sect1><sect2><para>
16418 #: ../en/ch13-hgext.xml:362
16419 msgid ""
16420 "It can be cumbersome to remember the options to both the <command role=\"hg-"
16421 "ext-extdiff\">extdiff</command> command and the diff viewer you want to use, "
16422 "so the <literal role=\"hg-ext\">extdiff</literal> extension lets you define "
16423 "<emphasis>new</emphasis> commands that will invoke your diff viewer with "
16424 "exactly the right options."
16425 msgstr ""
16427 #. type: Content of: <book><chapter><sect1><sect2><para>
16428 #: ../en/ch13-hgext.xml:369
16429 msgid ""
16430 "All you need to do is edit your <filename role=\"special\">~/.hgrc</"
16431 "filename>, and add a section named <literal role=\"rc-extdiff\">extdiff</"
16432 "literal>. Inside this section, you can define multiple commands. Here's how "
16433 "to add a <literal>kdiff3</literal> command. Once you've defined this, you "
16434 "can type <quote><literal>hg kdiff3</literal></quote> and the <literal role="
16435 "\"hg-ext\">extdiff</literal> extension will run <command>kdiff3</command> for "
16436 "you."
16437 msgstr ""
16439 #. type: Content of: <book><chapter><sect1><sect2><para>
16440 #: ../en/ch13-hgext.xml:379
16441 msgid ""
16442 "If you leave the right hand side of the definition empty, as above, the "
16443 "<literal role=\"hg-ext\">extdiff</literal> extension uses the name of the "
16444 "command you defined as the name of the external program to run. But these "
16445 "names don't have to be the same. Here, we define a command named "
16446 "<quote><literal>hg wibble</literal></quote>, which runs <command>kdiff3</"
16447 "command>."
16448 msgstr ""
16450 #. type: Content of: <book><chapter><sect1><sect2><para>
16451 #: ../en/ch13-hgext.xml:389
16452 msgid ""
16453 "You can also specify the default options that you want to invoke your diff "
16454 "viewing program with. The prefix to use is <quote><literal>opts.</literal></"
16455 "quote>, followed by the name of the command to which the options apply. This "
16456 "example defines a <quote><literal>hg vimdiff</literal></quote> command that "
16457 "runs the <command>vim</command> editor's <literal>DirDiff</literal> extension."
16458 msgstr ""
16460 #. type: Content of: <book><chapter><sect1><title>
16461 #: ../en/ch13-hgext.xml:403
16462 msgid ""
16463 "Cherrypicking changes with the <literal role=\"hg-ext\">transplant</literal> "
16464 "extension"
16465 msgstr "使用扩展 <literal role=\"hg-ext\">transplant</literal> 以挑选修改"
16467 #. type: Content of: <book><chapter><sect1><para>
16468 #: ../en/ch13-hgext.xml:406
16469 msgid "Need to have a long chat with Brendan about this."
16470 msgstr ""
16472 #. type: Content of: <book><chapter><sect1><title>
16473 #: ../en/ch13-hgext.xml:410
16474 msgid ""
16475 "Send changes via email with the <literal role=\"hg-ext\">patchbomb</literal> "
16476 "extension"
16477 msgstr ""
16478 "使用扩展 <literal role=\"hg-ext\">patchbomb</literal> 通过 email 发送修改"
16480 #. type: Content of: <book><chapter><sect1><para>
16481 #: ../en/ch13-hgext.xml:413
16482 msgid ""
16483 "Many projects have a culture of <quote>change review</quote>, in which people "
16484 "send their modifications to a mailing list for others to read and comment on "
16485 "before they commit the final version to a shared repository. Some projects "
16486 "have people who act as gatekeepers; they apply changes from other people to a "
16487 "repository to which those others don't have access."
16488 msgstr ""
16490 #. type: Content of: <book><chapter><sect1><para>
16491 #: ../en/ch13-hgext.xml:421
16492 msgid ""
16493 "Mercurial makes it easy to send changes over email for review or application, "
16494 "via its <literal role=\"hg-ext\">patchbomb</literal> extension. The "
16495 "extension is so named because changes are formatted as patches, and it's "
16496 "usual to send one changeset per email message. Sending a long series of "
16497 "changes by email is thus much like <quote>bombing</quote> the recipient's "
16498 "inbox, hence <quote>patchbomb</quote>."
16499 msgstr ""
16501 #. type: Content of: <book><chapter><sect1><para>
16502 #: ../en/ch13-hgext.xml:429
16503 msgid ""
16504 "As usual, the basic configuration of the <literal role=\"hg-ext\">patchbomb</"
16505 "literal> extension takes just one or two lines in your <filename role="
16506 "\"special\"> /.hgrc</filename>."
16507 msgstr ""
16509 #. type: Content of: <book><chapter><sect1><para>
16510 #: ../en/ch13-hgext.xml:435
16511 msgid ""
16512 "Once you've enabled the extension, you will have a new command available, "
16513 "named <command role=\"hg-ext-patchbomb\">email</command>."
16514 msgstr ""
16516 #. type: Content of: <book><chapter><sect1><para>
16517 #: ../en/ch13-hgext.xml:439
16518 msgid ""
16519 "The safest and best way to invoke the <command role=\"hg-ext-patchbomb"
16520 "\">email</command> command is to <emphasis>always</emphasis> run it first "
16521 "with the <option role=\"hg-ext-patchbomb-cmd-email-opt\">hg -n</option> "
16522 "option. This will show you what the command <emphasis>would</emphasis> send, "
16523 "without actually sending anything. Once you've had a quick glance over the "
16524 "changes and verified that you are sending the right ones, you can rerun the "
16525 "same command, with the <option role=\"hg-ext-patchbomb-cmd-email-opt\">hg -n</"
16526 "option> option removed."
16527 msgstr ""
16529 #. type: Content of: <book><chapter><sect1><para>
16530 #: ../en/ch13-hgext.xml:450
16531 msgid ""
16532 "The <command role=\"hg-ext-patchbomb\">email</command> command accepts the "
16533 "same kind of revision syntax as every other Mercurial command. For example, "
16534 "this command will send every revision between 7 and <literal>tip</literal>, "
16535 "inclusive."
16536 msgstr ""
16538 #. type: Content of: <book><chapter><sect1><para>
16539 #: ../en/ch13-hgext.xml:455
16540 msgid ""
16541 "You can also specify a <emphasis>repository</emphasis> to compare with. If "
16542 "you provide a repository but no revisions, the <command role=\"hg-ext-"
16543 "patchbomb\">email</command> command will send all revisions in the local "
16544 "repository that are not present in the remote repository. If you "
16545 "additionally specify revisions or a branch name (the latter using the <option "
16546 "role=\"hg-ext-patchbomb-cmd-email-opt\">hg -b</option> option), this will "
16547 "constrain the revisions sent."
16548 msgstr ""
16550 #. type: Content of: <book><chapter><sect1><para>
16551 #: ../en/ch13-hgext.xml:464
16552 msgid ""
16553 "It's perfectly safe to run the <command role=\"hg-ext-patchbomb\">email</"
16554 "command> command without the names of the people you want to send to: if you "
16555 "do this, it will just prompt you for those values interactively. (If you're "
16556 "using a Linux or Unix-like system, you should have enhanced "
16557 "<literal>readline</literal>-style editing capabilities when entering those "
16558 "headers, too, which is useful.)"
16559 msgstr ""
16561 #. type: Content of: <book><chapter><sect1><para>
16562 #: ../en/ch13-hgext.xml:472
16563 msgid ""
16564 "When you are sending just one revision, the <command role=\"hg-ext-patchbomb"
16565 "\">email</command> command will by default use the first line of the "
16566 "changeset description as the subject of the single email message it sends."
16567 msgstr ""
16569 #. type: Content of: <book><chapter><sect1><para>
16570 #: ../en/ch13-hgext.xml:477
16571 msgid ""
16572 "If you send multiple revisions, the <command role=\"hg-ext-patchbomb\">email</"
16573 "command> command will usually send one message per changeset. It will "
16574 "preface the series with an introductory message, in which you should describe "
16575 "the purpose of the series of changes you're sending."
16576 msgstr ""
16578 #. type: Content of: <book><chapter><sect1><sect2><title>
16579 #: ../en/ch13-hgext.xml:484
16580 msgid "Changing the behaviour of patchbombs"
16581 msgstr "修改 patchbomb 的行为"
16583 #. type: Content of: <book><chapter><sect1><sect2><para>
16584 #: ../en/ch13-hgext.xml:486
16585 msgid ""
16586 "Not every project has exactly the same conventions for sending changes in "
16587 "email; the <literal role=\"hg-ext\">patchbomb</literal> extension tries to "
16588 "accommodate a number of variations through command line options."
16589 msgstr ""
16591 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16592 #: ../en/ch13-hgext.xml:492
16593 msgid ""
16594 "You can write a subject for the introductory message on the command line "
16595 "using the <option role=\"hg-ext-patchbomb-cmd-email-opt\">hg -s</option> "
16596 "option. This takes one argument, the text of the subject to use."
16597 msgstr ""
16599 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16600 #: ../en/ch13-hgext.xml:498
16601 msgid ""
16602 "To change the email address from which the messages originate, use the "
16603 "<option role=\"hg-ext-patchbomb-cmd-email-opt\">hg -f</option> option. This "
16604 "takes one argument, the email address to use."
16605 msgstr ""
16607 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16608 #: ../en/ch13-hgext.xml:504
16609 msgid ""
16610 "The default behaviour is to send unified diffs (see <xref linkend=\"sec:mq:"
16611 "patch\"/> for a description of the format), one per message. You can send a "
16612 "binary bundle instead with the <option role=\"hg-ext-patchbomb-cmd-email-opt"
16613 "\">hg -b</option> option."
16614 msgstr ""
16616 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16617 #: ../en/ch13-hgext.xml:512
16618 msgid ""
16619 "Unified diffs are normally prefaced with a metadata header. You can omit "
16620 "this, and send unadorned diffs, with the <option role=\"hg-ext-patchbomb-cmd-"
16621 "email-opt\">hg --plain</option> option."
16622 msgstr ""
16624 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16625 #: ../en/ch13-hgext.xml:518
16626 msgid ""
16627 "Diffs are normally sent <quote>inline</quote>, in the same body part as the "
16628 "description of a patch. This makes it easiest for the largest number of "
16629 "readers to quote and respond to parts of a diff, as some mail clients will "
16630 "only quote the first MIME body part in a message. If you'd prefer to send the "
16631 "description and the diff in separate body parts, use the <option role=\"hg-"
16632 "ext-patchbomb-cmd-email-opt\">hg -a</option> option."
16633 msgstr ""
16635 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16636 #: ../en/ch13-hgext.xml:528
16637 msgid ""
16638 "Instead of sending mail messages, you can write them to an <literal>mbox</"
16639 "literal>-format mail folder using the <option role=\"hg-ext-patchbomb-cmd-"
16640 "email-opt\">hg -m</option> option. That option takes one argument, the name "
16641 "of the file to write to."
16642 msgstr ""
16644 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16645 #: ../en/ch13-hgext.xml:535
16646 msgid ""
16647 "If you would like to add a <command>diffstat</command>-format summary to each "
16648 "patch, and one to the introductory message, use the <option role=\"hg-ext-"
16649 "patchbomb-cmd-email-opt\">hg -d</option> option. The <command>diffstat</"
16650 "command> command displays a table containing the name of each file patched, "
16651 "the number of lines affected, and a histogram showing how much each file is "
16652 "modified. This gives readers a qualitative glance at how complex a patch is."
16653 msgstr ""