hgbook

view po/zh.po @ 650:7e7c47481e4f

Oops, this is the real merge for my hg's oddity
author Dongsheng Song <dongsheng.song@gmail.com>
date Fri Mar 20 16:43:35 2009 +0800 (2009-03-20)
parents c2cefd9f9893
children 6b1577ef5135
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 # Update to new pot:
9 # msgmerge --update zh.po hgbook.pot
10 #
11 # Check translation:
12 # msgfmt --statistics -c -o zh.mo zh.po
13 #
14 # Please format your translation before commit:
15 # msgcat --sort-by-file --width=80 -o zh_new.po zh.po
16 # mv -f zh_new.po zh.po
17 #
18 # Dictionary:
19 # blame 追溯
20 # branch 分支
21 # changes 修改
22 # changeset 修改集
23 # checkout 检出
24 # remove 移除(从版本库删除)
25 # delete 删除(只从文件系统删除)
26 # patchset 补丁集
27 # pushing to 推到
28 # pulling from 拉自,抓取
29 # rename 改名
30 # repository 版本库
31 # revert 恢复
32 # revision 版本
33 # tag 标签
34 # tip 顶点
35 # undo 撤销
36 # unversioned 未版本控制
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-20 15:47+0800\n"
45 "PO-Revision-Date: 2009-03-18 19:50+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:4
88 msgid "Command reference"
89 msgstr "命令参考"
91 #. type: Content of: <book><appendix><para>
92 #: ../en/appA-cmdref.xml:6
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:11
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:13
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 section <xref linkend=\"sec.mq.patch\"/>."
109 msgstr ""
111 #. type: Content of: <book><appendix><para>
112 #: ../en/appA-cmdref.xml:17
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:22
122 msgid "Options"
123 msgstr "选项"
125 #. type: Content of: <book><appendix><sect2><para>
126 #: ../en/appA-cmdref.xml:24
127 msgid "\\loptref{diff}{nodates}"
128 msgstr ""
130 #. type: Content of: <book><appendix><sect2><para>
131 #: ../en/appA-cmdref.xml:26
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:28
137 msgid "\\optref{diff}{B}{ignore-blank-lines}"
138 msgstr ""
140 #. type: Content of: <book><appendix><sect2><para>
141 #: ../en/appA-cmdref.xml:30
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:34
149 msgid "\\optref{diff}{I}{include}"
150 msgstr ""
152 #. type: Content of: <book><appendix><sect2><para>
153 #: ../en/appA-cmdref.xml:37
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:40
159 msgid "\\optref{diff}{X}{exclude}"
160 msgstr ""
162 #. type: Content of: <book><appendix><sect2><para>
163 #: ../en/appA-cmdref.xml:43
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:46
169 msgid "\\optref{diff}{a}{text}"
170 msgstr ""
172 #. type: Content of: <book><appendix><sect2><para>
173 #: ../en/appA-cmdref.xml:49
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:55
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:60
191 msgid "\\optref{diff}{b}{ignore-space-change}"
192 msgstr ""
194 #. type: Content of: <book><appendix><sect2><para>
195 #: ../en/appA-cmdref.xml:63
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:67
203 msgid "\\optref{diff}{g}{git}"
204 msgstr ""
206 #. type: Content of: <book><appendix><sect2><para>
207 #: ../en/appA-cmdref.xml:70
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:74
215 msgid "\\optref{diff}{p}{show-function}"
216 msgstr ""
218 #. type: Content of: <book><appendix><sect2><para>
219 #: ../en/appA-cmdref.xml:77
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:84
230 msgid "\\optref{diff}{r}{rev}"
231 msgstr ""
233 #. type: Content of: <book><appendix><sect2><para>
234 #: ../en/appA-cmdref.xml:87
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:93
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:97
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:101
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:105
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:112
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:122
283 msgid "\\optref{diff}{w}{ignore-all-space}"
284 msgstr ""
286 #. type: Content of: <book><appendix><sect2><para>
287 #: ../en/appA-cmdref.xml:125
288 msgid "\\cmdref{version}{print version and copyright information}"
289 msgstr ""
291 #. type: Content of: <book><appendix><sect2><para>
292 #: ../en/appA-cmdref.xml:128
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:133
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:138
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:146
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:150
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:159
334 msgid "Tips and tricks"
335 msgstr ""
337 #. type: Content of: <book><appendix><sect2><sect3><title>
338 #: ../en/appA-cmdref.xml:162
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:164
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:171
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:179
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:184
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:200
398 msgid "Generating safe binary diffs"
399 msgstr "生成安全的二进制差异"
401 #. type: Content of: <book><appendix><sect2><sect3><para>
402 #: ../en/appA-cmdref.xml:202
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:209
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 #, fuzzy
481 msgid ""
482 "<command role=\"hg-ext-mq\">qdelete</command>&emdash;delete a patch from the "
483 "<filename role=\"special\">series</filename> file}"
484 msgstr "<command role=\"hg-ext-mq\">qseries</command>&emdash;显示补丁序列"
486 #. type: Content of: <book><appendix><sect1><sect2><para>
487 #: ../en/appB-mq-ref.xml:48
488 msgid ""
489 "The <command role=\"hg-ext-mq\">qdelete</command> command removes the entry "
490 "for a patch from the <filename role=\"special\">series</filename> file in the "
491 "<filename role=\"special\" class=\"directory\">.hg/patches</filename> "
492 "directory. It does not pop the patch if the patch is already applied. By "
493 "default, it does not delete the patch file; use the <option role=\"hg-ext-mq-"
494 "cmd-qdel-opt\">-f</option> option to do that."
495 msgstr ""
497 #. type: Content of: <book><appendix><sect1><sect2><para>
498 #: ../en/appB-mq-ref.xml:57 ../en/appB-mq-ref.xml:99 ../en/appB-mq-ref.xml:157
499 #: ../en/appB-mq-ref.xml:197 ../en/appB-mq-ref.xml:264
500 #: ../en/appB-mq-ref.xml:335 ../en/appB-mq-ref.xml:404
501 #: ../en/appB-mq-ref.xml:497
502 msgid "Options:"
503 msgstr ""
505 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
506 #: ../en/appB-mq-ref.xml:59
507 msgid ""
508 "<option role=\"hg-ext-mq-cmd-qdel-opt\">-f</option>: Delete the patch file."
509 msgstr ""
511 #. type: Content of: <book><appendix><sect1><sect2><title>
512 #: ../en/appB-mq-ref.xml:66
513 msgid ""
514 "<command role=\"hg-ext-mq\">qdiff</command>&emdash;print a diff of the "
515 "topmost applied patch"
516 msgstr ""
517 "<command role=\"hg-ext-mq\">qdiff</command>&emdash;显示最新应用补丁的差异"
519 #. type: Content of: <book><appendix><sect1><sect2><para>
520 #: ../en/appB-mq-ref.xml:69
521 msgid ""
522 "The <command role=\"hg-ext-mq\">qdiff</command> command prints a diff of the "
523 "topmost applied patch. It is equivalent to <command role=\"hg-cmd\">hg diff -"
524 "r-2:-1</command>."
525 msgstr ""
527 #. type: Content of: <book><appendix><sect1><sect2><title>
528 #: ../en/appB-mq-ref.xml:75
529 msgid ""
530 "<command role=\"hg-ext-mq\">qfold</command>&emdash;merge (<quote>fold</"
531 "quote>) several patches into one"
532 msgstr ""
533 "<command role=\"hg-ext-mq\">qfold</command>&emdash;将多个补丁合并(<quote>折叠"
534 "</quote>)成一个"
536 #. type: Content of: <book><appendix><sect1><sect2><para>
537 #: ../en/appB-mq-ref.xml:78
538 msgid ""
539 "The <command role=\"hg-ext-mq\">qfold</command> command merges multiple "
540 "patches into the topmost applied patch, so that the topmost applied patch "
541 "makes the union of all of the changes in the patches in question."
542 msgstr ""
544 #. type: Content of: <book><appendix><sect1><sect2><para>
545 #: ../en/appB-mq-ref.xml:83
546 msgid ""
547 "The patches to fold must not be applied; <command role=\"hg-ext-mq\">qfold</"
548 "command> will exit with an error if any is. The order in which patches are "
549 "folded is significant; <command role=\"hg-cmd\">hg qfold a b</command> means "
550 "<quote>apply the current topmost patch, followed by <literal>a</literal>, "
551 "followed by <literal>b</literal></quote>."
552 msgstr ""
554 #. type: Content of: <book><appendix><sect1><sect2><para>
555 #: ../en/appB-mq-ref.xml:91
556 msgid ""
557 "The comments from the folded patches are appended to the comments of the "
558 "destination patch, with each block of comments separated by three asterisk "
559 "(<quote><literal>*</literal></quote>) characters. Use the <option role=\"hg-"
560 "ext-mq-cmd-qfold-opt\">-e</option> option to edit the commit message for the "
561 "combined patch/changeset after the folding has completed."
562 msgstr ""
564 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
565 #: ../en/appB-mq-ref.xml:101
566 msgid ""
567 "<option role=\"hg-ext-mq-cmd-qfold-opt\">-e</option>: Edit the commit message "
568 "and patch description for the newly folded patch."
569 msgstr ""
571 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
572 #: ../en/appB-mq-ref.xml:106
573 msgid ""
574 "<option role=\"hg-ext-mq-cmd-qfold-opt\">-l</option>: Use the contents of the "
575 "given file as the new commit message and patch description for the folded "
576 "patch."
577 msgstr ""
579 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
580 #: ../en/appB-mq-ref.xml:111
581 msgid ""
582 "<option role=\"hg-ext-mq-cmd-qfold-opt\">-m</option>: Use the given text as "
583 "the new commit message and patch description for the folded patch."
584 msgstr ""
586 #. type: Content of: <book><appendix><sect1><sect2><title>
587 #: ../en/appB-mq-ref.xml:119
588 msgid ""
589 "<command role=\"hg-ext-mq\">qheader</command>&emdash;display the header/"
590 "description of a patch"
591 msgstr "<command role=\"hg-ext-mq\">qheader</command>&emdash;显示补丁头部描述"
593 #. type: Content of: <book><appendix><sect1><sect2><para>
594 #: ../en/appB-mq-ref.xml:123
595 msgid ""
596 "The <command role=\"hg-ext-mq\">qheader</command> command prints the header, "
597 "or description, of a patch. By default, it prints the header of the topmost "
598 "applied patch. Given an argument, it prints the header of the named patch."
599 msgstr ""
601 #. type: Content of: <book><appendix><sect1><sect2><title>
602 #: ../en/appB-mq-ref.xml:130
603 msgid ""
604 "<command role=\"hg-ext-mq\">qimport</command>&emdash;import a third-party "
605 "patch into the queue"
606 msgstr ""
607 "<command role=\"hg-ext-mq\">qimport</command>&emdash;将第三方补丁导入队列"
609 #. type: Content of: <book><appendix><sect1><sect2><para>
610 #: ../en/appB-mq-ref.xml:133
611 msgid ""
612 "The <command role=\"hg-ext-mq\">qimport</command> command adds an entry for "
613 "an external patch to the <filename role=\"special\">series</filename> file, "
614 "and copies the patch into the <filename role=\"special\" class=\"directory\">."
615 "hg/patches</filename> directory. It adds the entry immediately after the "
616 "topmost applied patch, but does not push the patch."
617 msgstr ""
619 #. type: Content of: <book><appendix><sect1><sect2><para>
620 #: ../en/appB-mq-ref.xml:141
621 msgid ""
622 "If the <filename role=\"special\" class=\"directory\">.hg/patches</filename> "
623 "directory is a repository, <command role=\"hg-ext-mq\">qimport</command> "
624 "automatically does an <command role=\"hg-cmd\">hg add</command> of the "
625 "imported patch."
626 msgstr ""
628 #. type: Content of: <book><appendix><sect1><sect2><title>
629 #: ../en/appB-mq-ref.xml:149
630 msgid ""
631 "<command role=\"hg-ext-mq\">qinit</command>&emdash;prepare a repository to "
632 "work with MQ"
633 msgstr "<command role=\"hg-ext-mq\">qinit</command>&emdash;为使用 MQ 配置版本库"
635 #. type: Content of: <book><appendix><sect1><sect2><para>
636 #: ../en/appB-mq-ref.xml:152
637 msgid ""
638 "The <command role=\"hg-ext-mq\">qinit</command> command prepares a repository "
639 "to work with MQ. It creates a directory called <filename role=\"special\" "
640 "class=\"directory\">.hg/patches</filename>."
641 msgstr ""
643 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
644 #: ../en/appB-mq-ref.xml:159
645 msgid ""
646 "<option role=\"hg-ext-mq-cmd-qinit-opt\">-c</option>: Create <filename role="
647 "\"special\" class=\"directory\">.hg/patches</filename> as a repository in its "
648 "own right. Also creates a <filename role=\"special\">.hgignore</filename> "
649 "file that will ignore the <filename role=\"special\">status</filename> file."
650 msgstr ""
652 #. type: Content of: <book><appendix><sect1><sect2><para>
653 #: ../en/appB-mq-ref.xml:169
654 msgid ""
655 "When the <filename role=\"special\" class=\"directory\">.hg/patches</"
656 "filename> directory is a repository, the <command role=\"hg-ext-mq\">qimport</"
657 "command> and <command role=\"hg-ext-mq\">qnew</command> commands "
658 "automatically <command role=\"hg-cmd\">hg add</command> new patches."
659 msgstr ""
661 #. type: Content of: <book><appendix><sect1><sect2><title>
662 #: ../en/appB-mq-ref.xml:178
663 msgid "<command role=\"hg-ext-mq\">qnew</command>&emdash;create a new patch"
664 msgstr "<command role=\"hg-ext-mq\">qnew</command>&emdash;创建新补丁"
666 #. type: Content of: <book><appendix><sect1><sect2><para>
667 #: ../en/appB-mq-ref.xml:181
668 msgid ""
669 "The <command role=\"hg-ext-mq\">qnew</command> command creates a new patch. "
670 "It takes one mandatory argument, the name to use for the patch file. The "
671 "newly created patch is created empty by default. It is added to the "
672 "<filename role=\"special\">series</filename> file after the current topmost "
673 "applied patch, and is immediately pushed on top of that patch."
674 msgstr ""
676 #. type: Content of: <book><appendix><sect1><sect2><para>
677 #: ../en/appB-mq-ref.xml:189
678 msgid ""
679 "If <command role=\"hg-ext-mq\">qnew</command> finds modified files in the "
680 "working directory, it will refuse to create a new patch unless the <option "
681 "role=\"hg-ext-mq-cmd-qnew-opt\">-f</option> option is used (see below). This "
682 "behaviour allows you to <command role=\"hg-ext-mq\">qrefresh</command> your "
683 "topmost applied patch before you apply a new patch on top of it."
684 msgstr ""
686 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
687 #: ../en/appB-mq-ref.xml:199
688 msgid ""
689 "<option role=\"hg-ext-mq-cmd-qnew-opt\">-f</option>: Create a new patch if "
690 "the contents of the working directory are modified. Any outstanding "
691 "modifications are added to the newly created patch, so after this command "
692 "completes, the working directory will no longer be modified."
693 msgstr ""
695 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
696 #: ../en/appB-mq-ref.xml:206
697 msgid ""
698 "<option role=\"hg-ext-mq-cmd-qnew-opt\">-m</option>: Use the given text as "
699 "the commit message. This text will be stored at the beginning of the patch "
700 "file, before the patch data."
701 msgstr ""
703 #. type: Content of: <book><appendix><sect1><sect2><title>
704 #: ../en/appB-mq-ref.xml:215
705 msgid ""
706 "<command role=\"hg-ext-mq\">qnext</command>&emdash;print the name of the next "
707 "patch"
708 msgstr "<command role=\"hg-ext-mq\">qnext</command>&emdash;显示下个补丁的名称"
710 #. type: Content of: <book><appendix><sect1><sect2><para>
711 #: ../en/appB-mq-ref.xml:218
712 msgid ""
713 "The <command role=\"hg-ext-mq\">qnext</command> command prints the name name "
714 "of the next patch in the <filename role=\"special\">series</filename> file "
715 "after the topmost applied patch. This patch will become the topmost applied "
716 "patch if you run <command role=\"hg-ext-mq\">qpush</command>."
717 msgstr ""
719 #. type: Content of: <book><appendix><sect1><sect2><title>
720 #: ../en/appB-mq-ref.xml:227
721 msgid ""
722 "<command role=\"hg-ext-mq\">qpop</command>&emdash;pop patches off the stack"
723 msgstr "<command role=\"hg-ext-mq\">qpop</command>&emdash;删除堆栈顶部的补丁"
725 #. type: Content of: <book><appendix><sect1><sect2><para>
726 #: ../en/appB-mq-ref.xml:230
727 msgid ""
728 "The <command role=\"hg-ext-mq\">qpop</command> command removes applied "
729 "patches from the top of the stack of applied patches. By default, it removes "
730 "only one patch."
731 msgstr ""
733 #. type: Content of: <book><appendix><sect1><sect2><para>
734 #: ../en/appB-mq-ref.xml:234
735 msgid ""
736 "This command removes the changesets that represent the popped patches from "
737 "the repository, and updates the working directory to undo the effects of the "
738 "patches."
739 msgstr ""
741 #. type: Content of: <book><appendix><sect1><sect2><para>
742 #: ../en/appB-mq-ref.xml:238
743 msgid ""
744 "This command takes an optional argument, which it uses as the name or index "
745 "of the patch to pop to. If given a name, it will pop patches until the named "
746 "patch is the topmost applied patch. If given a number, <command role=\"hg-"
747 "ext-mq\">qpop</command> treats the number as an index into the entries in the "
748 "series file, counting from zero (empty lines and lines containing only "
749 "comments do not count). It pops patches until the patch identified by the "
750 "given index is the topmost applied patch."
751 msgstr ""
753 #. type: Content of: <book><appendix><sect1><sect2><para>
754 #: ../en/appB-mq-ref.xml:248
755 msgid ""
756 "The <command role=\"hg-ext-mq\">qpop</command> command does not read or write "
757 "patches or the <filename role=\"special\">series</filename> file. It is thus "
758 "safe to <command role=\"hg-ext-mq\">qpop</command> a patch that you have "
759 "removed from the <filename role=\"special\">series</filename> file, or a "
760 "patch that you have renamed or deleted entirely. In the latter two cases, "
761 "use the name of the patch as it was when you applied it."
762 msgstr ""
764 #. type: Content of: <book><appendix><sect1><sect2><para>
765 #: ../en/appB-mq-ref.xml:257
766 msgid ""
767 "By default, the <command role=\"hg-ext-mq\">qpop</command> command will not "
768 "pop any patches if the working directory has been modified. You can override "
769 "this behaviour using the <option role=\"hg-ext-mq-cmd-qpop-opt\">-f</option> "
770 "option, which reverts all modifications in the working directory."
771 msgstr ""
773 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
774 #: ../en/appB-mq-ref.xml:266
775 msgid ""
776 "<option role=\"hg-ext-mq-cmd-qpop-opt\">-a</option>: Pop all applied "
777 "patches. This returns the repository to its state before you applied any "
778 "patches."
779 msgstr ""
781 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
782 #: ../en/appB-mq-ref.xml:271
783 msgid ""
784 "<option role=\"hg-ext-mq-cmd-qpop-opt\">-f</option>: Forcibly revert any "
785 "modifications to the working directory when popping."
786 msgstr ""
788 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
789 #: ../en/appB-mq-ref.xml:276
790 msgid ""
791 "<option role=\"hg-ext-mq-cmd-qpop-opt\">-n</option>: Pop a patch from the "
792 "named queue."
793 msgstr ""
795 #. type: Content of: <book><appendix><sect1><sect2><para>
796 #: ../en/appB-mq-ref.xml:281
797 msgid ""
798 "The <command role=\"hg-ext-mq\">qpop</command> command removes one line from "
799 "the end of the <filename role=\"special\">status</filename> file for each "
800 "patch that it pops."
801 msgstr ""
803 #. type: Content of: <book><appendix><sect1><sect2><title>
804 #: ../en/appB-mq-ref.xml:288
805 msgid ""
806 "<command role=\"hg-ext-mq\">qprev</command>&emdash;print the name of the "
807 "previous patch"
808 msgstr "<command role=\"hg-ext-mq\">qprev</command>&emdash;显示上个补丁的名称"
810 #. type: Content of: <book><appendix><sect1><sect2><para>
811 #: ../en/appB-mq-ref.xml:291
812 msgid ""
813 "The <command role=\"hg-ext-mq\">qprev</command> command prints the name of "
814 "the patch in the <filename role=\"special\">series</filename> file that comes "
815 "before the topmost applied patch. This will become the topmost applied patch "
816 "if you run <command role=\"hg-ext-mq\">qpop</command>."
817 msgstr ""
819 #. type: Content of: <book><appendix><sect1><sect2><title>
820 #: ../en/appB-mq-ref.xml:300
821 msgid ""
822 "<command role=\"hg-ext-mq\">qpush</command>&emdash;push patches onto the stack"
823 msgstr "<command role=\"hg-ext-mq\">qpush</command>&emdash;增加补丁到堆栈"
825 #. type: Content of: <book><appendix><sect1><sect2><para>
826 #: ../en/appB-mq-ref.xml:303
827 msgid ""
828 "The <command role=\"hg-ext-mq\">qpush</command> command adds patches onto the "
829 "applied stack. By default, it adds only one patch."
830 msgstr ""
832 #. type: Content of: <book><appendix><sect1><sect2><para>
833 #: ../en/appB-mq-ref.xml:307
834 msgid ""
835 "This command creates a new changeset to represent each applied patch, and "
836 "updates the working directory to apply the effects of the patches."
837 msgstr ""
839 #. type: Content of: <book><appendix><sect1><sect2><para>
840 #: ../en/appB-mq-ref.xml:311
841 msgid "The default data used when creating a changeset are as follows:"
842 msgstr ""
844 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
845 #: ../en/appB-mq-ref.xml:314
846 msgid ""
847 "The commit date and time zone are the current date and time zone. Because "
848 "these data are used to compute the identity of a changeset, this means that "
849 "if you <command role=\"hg-ext-mq\">qpop</command> a patch and <command role="
850 "\"hg-ext-mq\">qpush</command> it again, the changeset that you push will have "
851 "a different identity than the changeset you popped."
852 msgstr ""
854 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
855 #: ../en/appB-mq-ref.xml:322
856 msgid ""
857 "The author is the same as the default used by the <command role=\"hg-cmd\">hg "
858 "commit</command> command."
859 msgstr ""
861 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
862 #: ../en/appB-mq-ref.xml:326
863 msgid ""
864 "The commit message is any text from the patch file that comes before the "
865 "first diff header. If there is no such text, a default commit message is "
866 "used that identifies the name of the patch."
867 msgstr ""
869 #. type: Content of: <book><appendix><sect1><sect2><para>
870 #: ../en/appB-mq-ref.xml:331
871 msgid ""
872 "If a patch contains a Mercurial patch header (XXX add link), the information "
873 "in the patch header overrides these defaults."
874 msgstr ""
876 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
877 #: ../en/appB-mq-ref.xml:337
878 msgid ""
879 "<option role=\"hg-ext-mq-cmd-qpush-opt\">-a</option>: Push all unapplied "
880 "patches from the <filename role=\"special\">series</filename> file until "
881 "there are none left to push."
882 msgstr ""
884 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
885 #: ../en/appB-mq-ref.xml:343
886 msgid ""
887 "<option role=\"hg-ext-mq-cmd-qpush-opt\">-l</option>: Add the name of the "
888 "patch to the end of the commit message."
889 msgstr ""
891 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
892 #: ../en/appB-mq-ref.xml:347
893 msgid ""
894 "<option role=\"hg-ext-mq-cmd-qpush-opt\">-m</option>: If a patch fails to "
895 "apply cleanly, use the entry for the patch in another saved queue to compute "
896 "the parameters for a three-way merge, and perform a three-way merge using the "
897 "normal Mercurial merge machinery. Use the resolution of the merge as the new "
898 "patch content."
899 msgstr ""
901 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
902 #: ../en/appB-mq-ref.xml:355
903 msgid ""
904 "<option role=\"hg-ext-mq-cmd-qpush-opt\">-n</option>: Use the named queue if "
905 "merging while pushing."
906 msgstr ""
908 #. type: Content of: <book><appendix><sect1><sect2><para>
909 #: ../en/appB-mq-ref.xml:360
910 msgid ""
911 "The <command role=\"hg-ext-mq\">qpush</command> command reads, but does not "
912 "modify, the <filename role=\"special\">series</filename> file. It appends "
913 "one line to the <command role=\"hg-cmd\">hg status</command> file for each "
914 "patch that it pushes."
915 msgstr ""
917 #. type: Content of: <book><appendix><sect1><sect2><title>
918 #: ../en/appB-mq-ref.xml:368
919 msgid ""
920 "<command role=\"hg-ext-mq\">qrefresh</command>&emdash;update the topmost "
921 "applied patch"
922 msgstr "<command role=\"hg-ext-mq\">qrefresh</command>&emdash;更新最新的补丁"
924 #. type: Content of: <book><appendix><sect1><sect2><para>
925 #: ../en/appB-mq-ref.xml:372
926 msgid ""
927 "The <command role=\"hg-ext-mq\">qrefresh</command> command updates the "
928 "topmost applied patch. It modifies the patch, removes the old changeset that "
929 "represented the patch, and creates a new changeset to represent the modified "
930 "patch."
931 msgstr ""
933 #. type: Content of: <book><appendix><sect1><sect2><para>
934 #: ../en/appB-mq-ref.xml:378
935 msgid ""
936 "The <command role=\"hg-ext-mq\">qrefresh</command> command looks for the "
937 "following modifications:"
938 msgstr ""
940 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
941 #: ../en/appB-mq-ref.xml:381
942 msgid ""
943 "Changes to the commit message, i.e. the text before the first diff header in "
944 "the patch file, are reflected in the new changeset that represents the patch."
945 msgstr ""
947 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
948 #: ../en/appB-mq-ref.xml:386
949 msgid ""
950 "Modifications to tracked files in the working directory are added to the "
951 "patch."
952 msgstr ""
954 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
955 #: ../en/appB-mq-ref.xml:389
956 msgid ""
957 "Changes to the files tracked using <command role=\"hg-cmd\">hg add</command>, "
958 "<command role=\"hg-cmd\">hg copy</command>, <command role=\"hg-cmd\">hg "
959 "remove</command>, or <command role=\"hg-cmd\">hg rename</command>. Added "
960 "files and copy and rename destinations are added to the patch, while removed "
961 "files and rename sources are removed."
962 msgstr ""
964 #. type: Content of: <book><appendix><sect1><sect2><para>
965 #: ../en/appB-mq-ref.xml:398
966 msgid ""
967 "Even if <command role=\"hg-ext-mq\">qrefresh</command> detects no changes, it "
968 "still recreates the changeset that represents the patch. This causes the "
969 "identity of the changeset to differ from the previous changeset that "
970 "identified the patch."
971 msgstr ""
973 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
974 #: ../en/appB-mq-ref.xml:406
975 msgid ""
976 "<option role=\"hg-ext-mq-cmd-qrefresh-opt\">-e</option>: Modify the commit "
977 "and patch description, using the preferred text editor."
978 msgstr ""
980 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
981 #: ../en/appB-mq-ref.xml:411
982 msgid ""
983 "<option role=\"hg-ext-mq-cmd-qrefresh-opt\">-m</option>: Modify the commit "
984 "message and patch description, using the given text."
985 msgstr ""
987 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
988 #: ../en/appB-mq-ref.xml:416
989 msgid ""
990 "<option role=\"hg-ext-mq-cmd-qrefresh-opt\">-l</option>: Modify the commit "
991 "message and patch description, using text from the given file."
992 msgstr ""
994 #. type: Content of: <book><appendix><sect1><sect2><title>
995 #: ../en/appB-mq-ref.xml:424
996 msgid "<command role=\"hg-ext-mq\">qrename</command>&emdash;rename a patch"
997 msgstr "<command role=\"hg-ext-mq\">qrename</command>&emdash;改名补丁"
999 #. type: Content of: <book><appendix><sect1><sect2><para>
1000 #: ../en/appB-mq-ref.xml:427
1001 msgid ""
1002 "The <command role=\"hg-ext-mq\">qrename</command> command renames a patch, "
1003 "and changes the entry for the patch in the <filename role=\"special\">series</"
1004 "filename> file."
1005 msgstr ""
1007 #. type: Content of: <book><appendix><sect1><sect2><para>
1008 #: ../en/appB-mq-ref.xml:431
1009 msgid ""
1010 "With a single argument, <command role=\"hg-ext-mq\">qrename</command> renames "
1011 "the topmost applied patch. With two arguments, it renames its first argument "
1012 "to its second."
1013 msgstr ""
1015 #. type: Content of: <book><appendix><sect1><sect2><title>
1016 #: ../en/appB-mq-ref.xml:438
1017 msgid ""
1018 "<command role=\"hg-ext-mq\">qrestore</command>&emdash;restore saved queue "
1019 "state"
1020 msgstr "<command role=\"hg-ext-mq\">qrestore</command>&emdash;恢复保存的队列"
1022 #. type: Content of: <book><appendix><sect1><sect2><para>
1023 #: ../en/appB-mq-ref.xml:442
1024 msgid "XXX No idea what this does."
1025 msgstr ""
1027 #. type: Content of: <book><appendix><sect1><sect2><title>
1028 #: ../en/appB-mq-ref.xml:446
1029 msgid ""
1030 "<command role=\"hg-ext-mq\">qsave</command>&emdash;save current queue state"
1031 msgstr "<command role=\"hg-ext-mq\">qsave</command>&emdash;保存当前的队列状态"
1033 #. type: Content of: <book><appendix><sect1><sect2><para>
1034 #: ../en/appB-mq-ref.xml:449
1035 msgid "XXX Likewise."
1036 msgstr ""
1038 #. type: Content of: <book><appendix><sect1><sect2><title>
1039 #: ../en/appB-mq-ref.xml:453
1040 msgid ""
1041 "<command role=\"hg-ext-mq\">qseries</command>&emdash;print the entire patch "
1042 "series"
1043 msgstr "<command role=\"hg-ext-mq\">qseries</command>&emdash;显示补丁序列"
1045 #. type: Content of: <book><appendix><sect1><sect2><para>
1046 #: ../en/appB-mq-ref.xml:456
1047 msgid ""
1048 "The <command role=\"hg-ext-mq\">qseries</command> command prints the entire "
1049 "patch series from the <filename role=\"special\">series</filename> file. It "
1050 "prints only patch names, not empty lines or comments. It prints in order "
1051 "from first to be applied to last."
1052 msgstr ""
1054 #. type: Content of: <book><appendix><sect1><sect2><title>
1055 #: ../en/appB-mq-ref.xml:464
1056 msgid ""
1057 "<command role=\"hg-ext-mq\">qtop</command>&emdash;print the name of the "
1058 "current patch"
1059 msgstr "<command role=\"hg-ext-mq\">qtop</command>&emdash;显示当前补丁的名称"
1061 #. type: Content of: <book><appendix><sect1><sect2><para>
1062 #: ../en/appB-mq-ref.xml:467
1063 msgid ""
1064 "The <command role=\"hg-ext-mq\">qtop</command> prints the name of the topmost "
1065 "currently applied patch."
1066 msgstr ""
1068 #. type: Content of: <book><appendix><sect1><sect2><title>
1069 #: ../en/appB-mq-ref.xml:472
1070 msgid ""
1071 "<command role=\"hg-ext-mq\">qunapplied</command>&emdash;print patches not yet "
1072 "applied"
1073 msgstr ""
1074 "<command role=\"hg-ext-mq\">qunapplied</command>&emdash;显示尚未应用的补丁"
1076 #. type: Content of: <book><appendix><sect1><sect2><para>
1077 #: ../en/appB-mq-ref.xml:476
1078 msgid ""
1079 "The <command role=\"hg-ext-mq\">qunapplied</command> command prints the names "
1080 "of patches from the <filename role=\"special\">series</filename> file that "
1081 "are not yet applied. It prints them in order from the next patch that will "
1082 "be pushed to the last."
1083 msgstr ""
1085 #. type: Content of: <book><appendix><sect1><sect2><title>
1086 #: ../en/appB-mq-ref.xml:484
1087 msgid ""
1088 "<command role=\"hg-cmd\">hg strip</command>&emdash;remove a revision and "
1089 "descendants"
1090 msgstr "<command role=\"hg-cmd\">hg strip</command>&emdash;删除一个版本及其后继"
1092 #. type: Content of: <book><appendix><sect1><sect2><para>
1093 #: ../en/appB-mq-ref.xml:487
1094 msgid ""
1095 "The <command role=\"hg-cmd\">hg strip</command> command removes a revision, "
1096 "and all of its descendants, from the repository. It undoes the effects of "
1097 "the removed revisions from the repository, and updates the working directory "
1098 "to the first parent of the removed revision."
1099 msgstr ""
1101 #. type: Content of: <book><appendix><sect1><sect2><para>
1102 #: ../en/appB-mq-ref.xml:493
1103 msgid ""
1104 "The <command role=\"hg-cmd\">hg strip</command> command saves a backup of the "
1105 "removed changesets in a bundle, so that they can be reapplied if removed in "
1106 "error."
1107 msgstr ""
1109 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1110 #: ../en/appB-mq-ref.xml:499
1111 msgid ""
1112 "<option role=\"hg-opt-strip\">-b</option>: Save unrelated changesets that are "
1113 "intermixed with the stripped changesets in the backup bundle."
1114 msgstr ""
1116 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1117 #: ../en/appB-mq-ref.xml:503
1118 msgid ""
1119 "<option role=\"hg-opt-strip\">-f</option>: If a branch has multiple heads, "
1120 "remove all heads. XXX This should be renamed, and use <literal>-f</literal> "
1121 "to strip revs when there are pending changes."
1122 msgstr ""
1124 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1125 #: ../en/appB-mq-ref.xml:508
1126 msgid "<option role=\"hg-opt-strip\">-n</option>: Do not save a backup bundle."
1127 msgstr ""
1129 #. type: Content of: <book><appendix><sect1><title>
1130 #: ../en/appB-mq-ref.xml:515
1131 msgid "MQ file reference"
1132 msgstr "MQ 文件参考"
1134 #. type: Content of: <book><appendix><sect1><sect2><title>
1135 #: ../en/appB-mq-ref.xml:518
1136 msgid "The <filename role=\"special\">series</filename> file"
1137 msgstr "<filename role=\"special\">序列</filename>文件"
1139 #. type: Content of: <book><appendix><sect1><sect2><para>
1140 #: ../en/appB-mq-ref.xml:521
1141 msgid ""
1142 "The <filename role=\"special\">series</filename> file contains a list of the "
1143 "names of all patches that MQ can apply. It is represented as a list of "
1144 "names, with one name saved per line. Leading and trailing white space in "
1145 "each line are ignored."
1146 msgstr ""
1148 #. type: Content of: <book><appendix><sect1><sect2><para>
1149 #: ../en/appB-mq-ref.xml:527
1150 msgid ""
1151 "Lines may contain comments. A comment begins with the <quote><literal>#</"
1152 "literal></quote> character, and extends to the end of the line. Empty lines, "
1153 "and lines that contain only comments, are ignored."
1154 msgstr ""
1156 #. type: Content of: <book><appendix><sect1><sect2><para>
1157 #: ../en/appB-mq-ref.xml:532
1158 msgid ""
1159 "You will often need to edit the <filename role=\"special\">series</filename> "
1160 "file by hand, hence the support for comments and empty lines noted above. "
1161 "For example, you can comment out a patch temporarily, and <command role=\"hg-"
1162 "ext-mq\">qpush</command> will skip over that patch when applying patches. "
1163 "You can also change the order in which patches are applied by reordering "
1164 "their entries in the <filename role=\"special\">series</filename> file."
1165 msgstr ""
1167 #. type: Content of: <book><appendix><sect1><sect2><para>
1168 #: ../en/appB-mq-ref.xml:541
1169 msgid ""
1170 "Placing the <filename role=\"special\">series</filename> file under revision "
1171 "control is also supported; it is a good idea to place all of the patches that "
1172 "it refers to under revision control, as well. If you create a patch "
1173 "directory using the <option role=\"hg-ext-mq-cmd-qinit-opt\">-c</option> "
1174 "option to <command role=\"hg-ext-mq\">qinit</command>, this will be done for "
1175 "you automatically."
1176 msgstr ""
1178 #. type: Content of: <book><appendix><sect1><sect2><title>
1179 #: ../en/appB-mq-ref.xml:551
1180 msgid "The <filename role=\"special\">status</filename> file"
1181 msgstr "<filename role=\"special\">状态</filename>文件"
1183 #. type: Content of: <book><appendix><sect1><sect2><para>
1184 #: ../en/appB-mq-ref.xml:554
1185 msgid ""
1186 "The <filename role=\"special\">status</filename> file contains the names and "
1187 "changeset hashes of all patches that MQ currently has applied. Unlike the "
1188 "<filename role=\"special\">series</filename> file, this file is not intended "
1189 "for editing. You should not place this file under revision control, or "
1190 "modify it in any way. It is used by MQ strictly for internal book-keeping."
1191 msgstr ""
1193 #. type: Content of: <book><appendix><title>
1194 #: ../en/appC-srcinstall.xml:5
1195 msgid "Installing Mercurial from source"
1196 msgstr "从源代码安装 Mercurial"
1198 #. type: Content of: <book><appendix><sect1><title>
1199 #: ../en/appC-srcinstall.xml:8
1200 msgid "On a Unix-like system"
1201 msgstr "类 Unix 系统"
1203 #. type: Content of: <book><appendix><sect1><para>
1204 #: ../en/appC-srcinstall.xml:10
1205 msgid ""
1206 "If you are using a Unix-like system that has a sufficiently recent version of "
1207 "Python (2.3 or newer) available, it is easy to install Mercurial from source."
1208 msgstr ""
1210 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1211 #: ../en/appC-srcinstall.xml:14
1212 msgid ""
1213 "Download a recent source tarball from <ulink url=\"http://www.selenic.com/"
1214 "mercurial/download\">http://www.selenic.com/mercurial/download</ulink>."
1215 msgstr ""
1217 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1218 #: ../en/appC-srcinstall.xml:17
1219 msgid "Unpack the tarball:"
1220 msgstr ""
1222 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1223 #: ../en/appC-srcinstall.xml:20
1224 msgid ""
1225 "Go into the source directory and run the installer script. This will build "
1226 "Mercurial and install it in your home directory."
1227 msgstr ""
1229 #. type: Content of: <book><appendix><sect1><para>
1230 #: ../en/appC-srcinstall.xml:27
1231 msgid ""
1232 "Once the install finishes, Mercurial will be in the <literal>bin</literal> "
1233 "subdirectory of your home directory. Don't forget to make sure that this "
1234 "directory is present in your shell's search path."
1235 msgstr ""
1237 #. type: Content of: <book><appendix><sect1><para>
1238 #: ../en/appC-srcinstall.xml:32
1239 msgid ""
1240 "You will probably need to set the <envar>PYTHONPATH</envar> environment "
1241 "variable so that the Mercurial executable can find the rest of the Mercurial "
1242 "packages. For example, on my laptop, I have set it to <literal>/home/bos/lib/"
1243 "python</literal>. The exact path that you will need to use depends on how "
1244 "Python was built for your system, but should be easy to figure out. If "
1245 "you're uncertain, look through the output of the installer script above, and "
1246 "see where the contents of the <literal>mercurial</literal> directory were "
1247 "installed to."
1248 msgstr ""
1250 #. type: Content of: <book><appendix><sect1><title>
1251 #: ../en/appC-srcinstall.xml:44
1252 msgid "On Windows"
1253 msgstr "Windows 系统"
1255 #. type: Content of: <book><appendix><sect1><para>
1256 #: ../en/appC-srcinstall.xml:46
1257 msgid ""
1258 "Building and installing Mercurial on Windows requires a variety of tools, a "
1259 "fair amount of technical knowledge, and considerable patience. I very much "
1260 "<emphasis>do not recommend</emphasis> this route if you are a <quote>casual "
1261 "user</quote>. Unless you intend to hack on Mercurial, I strongly suggest "
1262 "that you use a binary package instead."
1263 msgstr ""
1265 #. type: Content of: <book><appendix><sect1><para>
1266 #: ../en/appC-srcinstall.xml:53
1267 msgid ""
1268 "If you are intent on building Mercurial from source on Windows, follow the "
1269 "<quote>hard way</quote> directions on the Mercurial wiki at <ulink url="
1270 "\"http://www.selenic.com/mercurial/wiki/index.cgi/WindowsInstall\">http://www."
1271 "selenic.com/mercurial/wiki/index.cgi/WindowsInstall</ulink>, and expect the "
1272 "process to involve a lot of fiddly work."
1273 msgstr ""
1275 #. type: Content of: <book><appendix><title>
1276 #: ../en/appD-license.xml:5
1277 msgid "Open Publication License"
1278 msgstr ""
1280 #. type: Content of: <book><appendix><para>
1281 #: ../en/appD-license.xml:7
1282 msgid "Version 1.0, 8 June 1999"
1283 msgstr ""
1285 #. type: Content of: <book><appendix><sect1><title>
1286 #: ../en/appD-license.xml:10
1287 msgid "Requirements on both unmodified and modified versions"
1288 msgstr ""
1290 #. type: Content of: <book><appendix><sect1><para>
1291 #: ../en/appD-license.xml:13
1292 msgid ""
1293 "The Open Publication works may be reproduced and distributed in whole or in "
1294 "part, in any medium physical or electronic, provided that the terms of this "
1295 "license are adhered to, and that this license or an incorporation of it by "
1296 "reference (with any options elected by the author(s) and/or publisher) is "
1297 "displayed in the reproduction."
1298 msgstr ""
1300 #. type: Content of: <book><appendix><sect1><para>
1301 #: ../en/appD-license.xml:20
1302 msgid "Proper form for an incorporation by reference is as follows:"
1303 msgstr ""
1305 #. type: Content of: <book><appendix><sect1><blockquote><para>
1306 #: ../en/appD-license.xml:24
1307 msgid ""
1308 "Copyright (c) <emphasis>year</emphasis> by <emphasis>author's name or "
1309 "designee</emphasis>. This material may be distributed only subject to the "
1310 "terms and conditions set forth in the Open Publication License, v<emphasis>x."
1311 "y</emphasis> or later (the latest version is presently available at <ulink "
1312 "url=\"http://www.opencontent.org/openpub/\">http://www.opencontent.org/"
1313 "openpub/</ulink>)."
1314 msgstr ""
1316 #. type: Content of: <book><appendix><sect1><para>
1317 #: ../en/appD-license.xml:33
1318 msgid ""
1319 "The reference must be immediately followed with any options elected by the "
1320 "author(s) and/or publisher of the document (see section <xref linkend=\"sec."
1321 "opl.options\"/>)."
1322 msgstr ""
1324 #. type: Content of: <book><appendix><sect1><para>
1325 #: ../en/appD-license.xml:37
1326 msgid ""
1327 "Commercial redistribution of Open Publication-licensed material is permitted."
1328 msgstr ""
1330 #. type: Content of: <book><appendix><sect1><para>
1331 #: ../en/appD-license.xml:40
1332 msgid ""
1333 "Any publication in standard (paper) book form shall require the citation of "
1334 "the original publisher and author. The publisher and author's names shall "
1335 "appear on all outer surfaces of the book. On all outer surfaces of the book "
1336 "the original publisher's name shall be as large as the title of the work and "
1337 "cited as possessive with respect to the title."
1338 msgstr ""
1340 #. type: Content of: <book><appendix><sect1><title>
1341 #: ../en/appD-license.xml:49
1342 msgid "Copyright"
1343 msgstr ""
1345 #. type: Content of: <book><appendix><sect1><para>
1346 #: ../en/appD-license.xml:51
1347 msgid ""
1348 "The copyright to each Open Publication is owned by its author(s) or designee."
1349 msgstr ""
1351 #. type: Content of: <book><appendix><sect1><title>
1352 #: ../en/appD-license.xml:56
1353 msgid "Scope of license"
1354 msgstr ""
1356 #. type: Content of: <book><appendix><sect1><para>
1357 #: ../en/appD-license.xml:58
1358 msgid ""
1359 "The following license terms apply to all Open Publication works, unless "
1360 "otherwise explicitly stated in the document."
1361 msgstr ""
1363 #. type: Content of: <book><appendix><sect1><para>
1364 #: ../en/appD-license.xml:62
1365 msgid ""
1366 "Mere aggregation of Open Publication works or a portion of an Open "
1367 "Publication work with other works or programs on the same media shall not "
1368 "cause this license to apply to those other works. The aggregate work shall "
1369 "contain a notice specifying the inclusion of the Open Publication material "
1370 "and appropriate copyright notice."
1371 msgstr ""
1373 #. type: Content of: <book><appendix><sect1><para>
1374 #: ../en/appD-license.xml:69
1375 msgid ""
1376 "<emphasis role=\"bold\">Severability</emphasis>. If any part of this license "
1377 "is found to be unenforceable in any jurisdiction, the remaining portions of "
1378 "the license remain in force."
1379 msgstr ""
1381 #. type: Content of: <book><appendix><sect1><para>
1382 #: ../en/appD-license.xml:74
1383 msgid ""
1384 "<emphasis role=\"bold\">No warranty</emphasis>. Open Publication works are "
1385 "licensed and provided <quote>as is</quote> without warranty of any kind, "
1386 "express or implied, including, but not limited to, the implied warranties of "
1387 "merchantability and fitness for a particular purpose or a warranty of non-"
1388 "infringement."
1389 msgstr ""
1391 #. type: Content of: <book><appendix><sect1><title>
1392 #: ../en/appD-license.xml:83
1393 msgid "Requirements on modified works"
1394 msgstr ""
1396 #. type: Content of: <book><appendix><sect1><para>
1397 #: ../en/appD-license.xml:85
1398 msgid ""
1399 "All modified versions of documents covered by this license, including "
1400 "translations, anthologies, compilations and partial documents, must meet the "
1401 "following requirements:"
1402 msgstr ""
1404 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1405 #: ../en/appD-license.xml:90
1406 msgid "The modified version must be labeled as such."
1407 msgstr ""
1409 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1410 #: ../en/appD-license.xml:93
1411 msgid ""
1412 "The person making the modifications must be identified and the modifications "
1413 "dated."
1414 msgstr ""
1416 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1417 #: ../en/appD-license.xml:96
1418 msgid ""
1419 "Acknowledgement of the original author and publisher if applicable must be "
1420 "retained according to normal academic citation practices."
1421 msgstr ""
1423 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1424 #: ../en/appD-license.xml:100
1425 msgid "The location of the original unmodified document must be identified."
1426 msgstr ""
1428 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1429 #: ../en/appD-license.xml:103
1430 msgid ""
1431 "The original author's (or authors') name(s) may not be used to assert or "
1432 "imply endorsement of the resulting document without the original author's (or "
1433 "authors') permission."
1434 msgstr ""
1436 #. type: Content of: <book><appendix><sect1><title>
1437 #: ../en/appD-license.xml:111
1438 msgid "Good-practice recommendations"
1439 msgstr ""
1441 #. type: Content of: <book><appendix><sect1><para>
1442 #: ../en/appD-license.xml:113
1443 msgid ""
1444 "In addition to the requirements of this license, it is requested from and "
1445 "strongly recommended of redistributors that:"
1446 msgstr ""
1448 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1449 #: ../en/appD-license.xml:118
1450 msgid ""
1451 "If you are distributing Open Publication works on hardcopy or CD-ROM, you "
1452 "provide email notification to the authors of your intent to redistribute at "
1453 "least thirty days before your manuscript or media freeze, to give the authors "
1454 "time to provide updated documents. This notification should describe "
1455 "modifications, if any, made to the document."
1456 msgstr ""
1458 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1459 #: ../en/appD-license.xml:125
1460 msgid ""
1461 "All substantive modifications (including deletions) be either clearly marked "
1462 "up in the document or else described in an attachment to the document."
1463 msgstr ""
1465 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1466 #: ../en/appD-license.xml:129
1467 msgid ""
1468 "Finally, while it is not mandatory under this license, it is considered good "
1469 "form to offer a free copy of any hardcopy and CD-ROM expression of an Open "
1470 "Publication-licensed work to its author(s)."
1471 msgstr ""
1473 #. type: Content of: <book><appendix><sect1><title>
1474 #: ../en/appD-license.xml:137
1475 msgid "License options"
1476 msgstr ""
1478 #. type: Content of: <book><appendix><sect1><para>
1479 #: ../en/appD-license.xml:139
1480 msgid ""
1481 "The author(s) and/or publisher of an Open Publication-licensed document may "
1482 "elect certain options by appending language to the reference to or copy of "
1483 "the license. These options are considered part of the license instance and "
1484 "must be included with the license (or its incorporation by reference) in "
1485 "derived works."
1486 msgstr ""
1488 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1489 #: ../en/appD-license.xml:147
1490 msgid ""
1491 "To prohibit distribution of substantively modified versions without the "
1492 "explicit permission of the author(s). <quote>Substantive modification</quote> "
1493 "is defined as a change to the semantic content of the document, and excludes "
1494 "mere changes in format or typographical corrections."
1495 msgstr ""
1497 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1498 #: ../en/appD-license.xml:154
1499 msgid ""
1500 "To accomplish this, add the phrase <quote>Distribution of substantively "
1501 "modified versions of this document is prohibited without the explicit "
1502 "permission of the copyright holder.</quote> to the license reference or copy."
1503 msgstr ""
1505 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1506 #: ../en/appD-license.xml:160
1507 msgid ""
1508 "To prohibit any publication of this work or derivative works in whole or in "
1509 "part in standard (paper) book form for commercial purposes is prohibited "
1510 "unless prior permission is obtained from the copyright holder."
1511 msgstr ""
1513 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1514 #: ../en/appD-license.xml:165
1515 msgid ""
1516 "To accomplish this, add the phrase <quote>Distribution of the work or "
1517 "derivative of the work in any standard (paper) book form is prohibited unless "
1518 "prior permission is obtained from the copyright holder.</quote> to the "
1519 "license reference or copy."
1520 msgstr ""
1522 #. type: Content of: <book><chapter><title>
1523 #: ../en/ch01-tour-basic.xml:5
1524 msgid "A tour of Mercurial: the basics"
1525 msgstr "Mercurial 教程: 基础知识"
1527 #. type: Content of: <book><chapter><sect1><title>
1528 #: ../en/ch01-tour-basic.xml:8
1529 msgid "Installing Mercurial on your system"
1530 msgstr "安装 Mercurial"
1532 #. type: Content of: <book><chapter><sect1><para>
1533 #: ../en/ch01-tour-basic.xml:10
1534 msgid ""
1535 "Prebuilt binary packages of Mercurial are available for every popular "
1536 "operating system. These make it easy to start using Mercurial on your "
1537 "computer immediately."
1538 msgstr ""
1539 "对于每种流行的操作系统,都有已经构建的二进制软件包。这让在你的计算机上开始使"
1540 "用 Mercurial 变得很容易。"
1542 #. type: Content of: <book><chapter><sect1><sect2><title>
1543 #: ../en/ch01-tour-basic.xml:15
1544 msgid "Linux"
1545 msgstr "Linux"
1547 #. type: Content of: <book><chapter><sect1><sect2><para>
1548 #: ../en/ch01-tour-basic.xml:17
1549 msgid ""
1550 "Because each Linux distribution has its own packaging tools, policies, and "
1551 "rate of development, it's difficult to give a comprehensive set of "
1552 "instructions on how to install Mercurial binaries. The version of Mercurial "
1553 "that you will end up with can vary depending on how active the person is who "
1554 "maintains the package for your distribution."
1555 msgstr ""
1556 "由于每种 Linux 发行版都有自己的包管理工具,开发策略和进度,从而很难给出安装 "
1557 "Mercurial 二进制包的全面说明。你安装的 Mercurial 版本,在很大程度上依赖于你所"
1558 "使用的发行版的 Mercurial 维护者的活跃程度。"
1560 #. type: Content of: <book><chapter><sect1><sect2><para>
1561 #: ../en/ch01-tour-basic.xml:24
1562 msgid ""
1563 "To keep things simple, I will focus on installing Mercurial from the command "
1564 "line under the most popular Linux distributions. Most of these distributions "
1565 "provide graphical package managers that will let you install Mercurial with a "
1566 "single click; the package name to look for is <literal>mercurial</literal>."
1567 msgstr ""
1568 "为了让事情简单,我会致力于说明在最流行的 Linux 发行版中,从命令行安装 "
1569 "Mercurial 的方法。这些发行版都提供了图形界面的包管理器,让你通过点击鼠标安装 "
1570 "Mercurial;寻找的包名称是 <literal>mercurial</literal>。"
1572 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
1573 #: ../en/ch01-tour-basic.xml:32
1574 msgid "Debian:"
1575 msgstr "Debian:"
1577 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
1578 #: ../en/ch01-tour-basic.xml:34
1579 msgid "Fedora Core:"
1580 msgstr "Fedora Core:"
1582 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
1583 #: ../en/ch01-tour-basic.xml:36
1584 msgid "Gentoo:"
1585 msgstr "Gentoo:"
1587 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
1588 #: ../en/ch01-tour-basic.xml:38
1589 msgid "OpenSUSE:"
1590 msgstr "OpenSUSE:"
1592 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
1593 #: ../en/ch01-tour-basic.xml:40
1594 msgid ""
1595 "Ubuntu: Ubuntu's Mercurial package is based on Debian's. To install it, run "
1596 "the following command."
1597 msgstr "Ubuntu: Ubuntu 的 Mercurial 包基于 Debian。安装时,使用如下命令:"
1599 #. type: Content of: <book><chapter><sect1><sect2><title>
1600 #: ../en/ch01-tour-basic.xml:48
1601 msgid "Solaris"
1602 msgstr "Solaris"
1604 #. type: Content of: <book><chapter><sect1><sect2><para>
1605 #: ../en/ch01-tour-basic.xml:50
1606 msgid ""
1607 "SunFreeWare, at <ulink url=\"http://www.sunfreeware.com\">http://www."
1608 "sunfreeware.com</ulink>, is a good source for a large number of pre-built "
1609 "Solaris packages for 32 and 64 bit Intel and Sparc architectures, including "
1610 "current versions of Mercurial."
1611 msgstr ""
1612 "位于 <ulink url=\"http://www.sunfreeware.com\">http://www.sunfreeware.com</"
1613 "ulink> 的 SunFreeWare 是很好的二进制安装源,它包含 Intel 和 Sparc 架构的 32 位"
1614 "和 64 位包,包含 Mercurial 的当前版本。"
1616 #. type: Content of: <book><chapter><sect1><sect2><title>
1617 #: ../en/ch01-tour-basic.xml:58
1618 msgid "Mac OS X"
1619 msgstr "Mac OS X"
1621 #. type: Content of: <book><chapter><sect1><sect2><para>
1622 #: ../en/ch01-tour-basic.xml:60
1623 msgid ""
1624 "Lee Cantey publishes an installer of Mercurial for Mac OS X at <ulink url="
1625 "\"http://mercurial.berkwood.com\">http://mercurial.berkwood.com</ulink>. "
1626 "This package works on both Intel- and Power-based Macs. Before you can use "
1627 "it, you must install a compatible version of Universal MacPython "
1628 "<citation>web:macpython</citation>. This is easy to do; simply follow the "
1629 "instructions on Lee's site."
1630 msgstr ""
1632 #. type: Content of: <book><chapter><sect1><sect2><para>
1633 #: ../en/ch01-tour-basic.xml:69
1634 msgid ""
1635 "It's also possible to install Mercurial using Fink or MacPorts, two popular "
1636 "free package managers for Mac OS X. If you have Fink, use <command>sudo apt-"
1637 "get install mercurial-py25</command>. If MacPorts, <command>sudo port "
1638 "install mercurial</command>."
1639 msgstr ""
1641 #. type: Content of: <book><chapter><sect1><sect2><title>
1642 #: ../en/ch01-tour-basic.xml:77
1643 msgid "Windows"
1644 msgstr ""
1646 #. type: Content of: <book><chapter><sect1><sect2><para>
1647 #: ../en/ch01-tour-basic.xml:79
1648 msgid ""
1649 "Lee Cantey publishes an installer of Mercurial for Windows at <ulink url="
1650 "\"http://mercurial.berkwood.com\">http://mercurial.berkwood.com</ulink>. "
1651 "This package has no external dependencies; it <quote>just works</quote>."
1652 msgstr ""
1654 #. type: Content of: <book><chapter><sect1><sect2><note><para>
1655 #: ../en/ch01-tour-basic.xml:86
1656 msgid ""
1657 "The Windows version of Mercurial does not automatically convert line endings "
1658 "between Windows and Unix styles. If you want to share work with Unix users, "
1659 "you must do a little additional configuration work. XXX Flesh this out."
1660 msgstr ""
1662 #. type: Content of: <book><chapter><sect1><title>
1663 #: ../en/ch01-tour-basic.xml:96
1664 msgid "Getting started"
1665 msgstr "开始"
1667 #. type: Content of: <book><chapter><sect1><para>
1668 #: ../en/ch01-tour-basic.xml:98
1669 msgid ""
1670 "To begin, we'll use the <command role=\"hg-cmd\">hg version</command> command "
1671 "to find out whether Mercurial is actually installed properly. The actual "
1672 "version information that it prints isn't so important; it's whether it prints "
1673 "anything at all that we care about."
1674 msgstr ""
1676 #. type: Content of: <book><chapter><sect1><sect2><title>
1677 #: ../en/ch01-tour-basic.xml:107
1678 msgid "Built-in help"
1679 msgstr "内置帮助"
1681 #. type: Content of: <book><chapter><sect1><sect2><para>
1682 #: ../en/ch01-tour-basic.xml:109
1683 msgid ""
1684 "Mercurial provides a built-in help system. This is invaluable for those "
1685 "times when you find yourself stuck trying to remember how to run a command. "
1686 "If you are completely stuck, simply run <command role=\"hg-cmd\">hg help</"
1687 "command>; it will print a brief list of commands, along with a description of "
1688 "what each does. If you ask for help on a specific command (as below), it "
1689 "prints more detailed information."
1690 msgstr ""
1692 #. type: Content of: <book><chapter><sect1><sect2><para>
1693 #: ../en/ch01-tour-basic.xml:120
1694 msgid ""
1695 "For a more impressive level of detail (which you won't usually need) run "
1696 "<command role=\"hg-cmd\">hg help <option role=\"hg-opt-global\">-v</option></"
1697 "command>. The <option role=\"hg-opt-global\">-v</option> option is short for "
1698 "<option role=\"hg-opt-global\">--verbose</option>, and tells Mercurial to "
1699 "print more information than it usually would."
1700 msgstr ""
1702 #. type: Content of: <book><chapter><sect1><title>
1703 #: ../en/ch01-tour-basic.xml:131
1704 msgid "Working with a repository"
1705 msgstr "使用版本库"
1707 #. type: Content of: <book><chapter><sect1><para>
1708 #: ../en/ch01-tour-basic.xml:133
1709 msgid ""
1710 "In Mercurial, everything happens inside a <emphasis>repository</emphasis>. "
1711 "The repository for a project contains all of the files that <quote>belong to</"
1712 "quote> that project, along with a historical record of the project's files."
1713 msgstr ""
1715 #. type: Content of: <book><chapter><sect1><para>
1716 #: ../en/ch01-tour-basic.xml:139
1717 msgid ""
1718 "There's nothing particularly magical about a repository; it is simply a "
1719 "directory tree in your filesystem that Mercurial treats as special. You can "
1720 "rename or delete a repository any time you like, using either the command "
1721 "line or your file browser."
1722 msgstr ""
1724 #. type: Content of: <book><chapter><sect1><sect2><title>
1725 #: ../en/ch01-tour-basic.xml:146
1726 msgid "Making a local copy of a repository"
1727 msgstr "创建版本库的工作副本"
1729 #. type: Content of: <book><chapter><sect1><sect2><para>
1730 #: ../en/ch01-tour-basic.xml:148
1731 msgid ""
1732 "<emphasis>Copying</emphasis> a repository is just a little bit special. "
1733 "While you could use a normal file copying command to make a copy of a "
1734 "repository, it's best to use a built-in command that Mercurial provides. "
1735 "This command is called <command role=\"hg-cmd\">hg clone</command>, because "
1736 "it creates an identical copy of an existing repository."
1737 msgstr ""
1739 #. type: Content of: <book><chapter><sect1><sect2><para>
1740 #: ../en/ch01-tour-basic.xml:157
1741 msgid ""
1742 "If our clone succeeded, we should now have a local directory called <filename "
1743 "class=\"directory\">hello</filename>. This directory will contain some files."
1744 msgstr ""
1746 #. type: Content of: <book><chapter><sect1><sect2><para>
1747 #: ../en/ch01-tour-basic.xml:163
1748 msgid ""
1749 "These files have the same contents and history in our repository as they do "
1750 "in the repository we cloned."
1751 msgstr ""
1753 #. type: Content of: <book><chapter><sect1><sect2><para>
1754 #: ../en/ch01-tour-basic.xml:166
1755 msgid ""
1756 "Every Mercurial repository is complete, self-contained, and independent. It "
1757 "contains its own private copy of a project's files and history. A cloned "
1758 "repository remembers the location of the repository it was cloned from, but "
1759 "it does not communicate with that repository, or any other, unless you tell "
1760 "it to."
1761 msgstr ""
1763 #. type: Content of: <book><chapter><sect1><sect2><para>
1764 #: ../en/ch01-tour-basic.xml:173
1765 msgid ""
1766 "What this means for now is that we're free to experiment with our repository, "
1767 "safe in the knowledge that it's a private <quote>sandbox</quote> that won't "
1768 "affect anyone else."
1769 msgstr ""
1771 #. type: Content of: <book><chapter><sect1><sect2><title>
1772 #: ../en/ch01-tour-basic.xml:179
1773 msgid "What's in a repository?"
1774 msgstr "什么是版本库?"
1776 #. type: Content of: <book><chapter><sect1><sect2><para>
1777 #: ../en/ch01-tour-basic.xml:181
1778 msgid ""
1779 "When we take a more detailed look inside a repository, we can see that it "
1780 "contains a directory named <filename class=\"directory\">.hg</filename>. "
1781 "This is where Mercurial keeps all of its metadata for the repository."
1782 msgstr ""
1784 #. type: Content of: <book><chapter><sect1><sect2><para>
1785 #: ../en/ch01-tour-basic.xml:188
1786 msgid ""
1787 "The contents of the <filename class=\"directory\">.hg</filename> directory "
1788 "and its subdirectories are private to Mercurial. Every other file and "
1789 "directory in the repository is yours to do with as you please."
1790 msgstr ""
1792 #. type: Content of: <book><chapter><sect1><sect2><para>
1793 #: ../en/ch01-tour-basic.xml:194
1794 msgid ""
1795 "To introduce a little terminology, the <filename class=\"directory\">.hg</"
1796 "filename> directory is the <quote>real</quote> repository, and all of the "
1797 "files and directories that coexist with it are said to live in the "
1798 "<emphasis>working directory</emphasis>. An easy way to remember the "
1799 "distinction is that the <emphasis>repository</emphasis> contains the "
1800 "<emphasis>history</emphasis> of your project, while the <emphasis>working "
1801 "directory</emphasis> contains a <emphasis>snapshot</emphasis> of your project "
1802 "at a particular point in history."
1803 msgstr ""
1805 #. type: Content of: <book><chapter><sect1><title>
1806 #: ../en/ch01-tour-basic.xml:209
1807 msgid "A tour through history"
1808 msgstr "回溯历史"
1810 #. type: Content of: <book><chapter><sect1><para>
1811 #: ../en/ch01-tour-basic.xml:211
1812 msgid ""
1813 "One of the first things we might want to do with a new, unfamiliar repository "
1814 "is understand its history. The <command role=\"hg-cmd\">hg log</command> "
1815 "command gives us a view of history."
1816 msgstr ""
1818 #. type: Content of: <book><chapter><sect1><para>
1819 #: ../en/ch01-tour-basic.xml:218
1820 msgid ""
1821 "By default, this command prints a brief paragraph of output for each change "
1822 "to the project that was recorded. In Mercurial terminology, we call each of "
1823 "these recorded events a <emphasis>changeset</emphasis>, because it can "
1824 "contain a record of changes to several files."
1825 msgstr ""
1827 #. type: Content of: <book><chapter><sect1><para>
1828 #: ../en/ch01-tour-basic.xml:224
1829 msgid ""
1830 "The fields in a record of output from <command role=\"hg-cmd\">hg log</"
1831 "command> are as follows."
1832 msgstr ""
1834 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
1835 #: ../en/ch01-tour-basic.xml:227
1836 msgid ""
1837 "<literal>changeset</literal>: This field has the format of a number, followed "
1838 "by a colon, followed by a hexadecimal string. These are "
1839 "<emphasis>identifiers</emphasis> for the changeset. There are two "
1840 "identifiers because the number is shorter and easier to type than the hex "
1841 "string."
1842 msgstr ""
1844 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
1845 #: ../en/ch01-tour-basic.xml:233
1846 msgid ""
1847 "<literal>user</literal>: The identity of the person who created the "
1848 "changeset. This is a free-form field, but it most often contains a person's "
1849 "name and email address."
1850 msgstr ""
1852 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
1853 #: ../en/ch01-tour-basic.xml:237
1854 msgid ""
1855 "<literal>date</literal>: The date and time on which the changeset was "
1856 "created, and the timezone in which it was created. (The date and time are "
1857 "local to that timezone; they display what time and date it was for the person "
1858 "who created the changeset.)"
1859 msgstr ""
1861 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
1862 #: ../en/ch01-tour-basic.xml:242
1863 msgid ""
1864 "<literal>summary</literal>: The first line of the text message that the "
1865 "creator of the changeset entered to describe the changeset."
1866 msgstr ""
1868 #. type: Content of: <book><chapter><sect1><para>
1869 #: ../en/ch01-tour-basic.xml:245
1870 msgid ""
1871 "The default output printed by <command role=\"hg-cmd\">hg log</command> is "
1872 "purely a summary; it is missing a lot of detail."
1873 msgstr ""
1875 #. type: Content of: <book><chapter><sect1><para>
1876 #: ../en/ch01-tour-basic.xml:249
1877 msgid ""
1878 "Figure <xref endterm=\"fig.tour-basic.history.caption\" linkend=\"fig.tour-"
1879 "basic.history\"/> provides a graphical representation of the history of the "
1880 "<filename class=\"directory\">hello</filename> repository, to make it a "
1881 "little easier to see which direction history is <quote>flowing</quote> in. "
1882 "We'll be returning to this figure several times in this chapter and the "
1883 "chapter that follows."
1884 msgstr ""
1886 #. type: Content of: <book><chapter><sect1><informalfigure><mediaobject>
1887 #: ../en/ch01-tour-basic.xml:260
1888 msgid ""
1889 "<imageobject><imagedata fileref=\"images/tour-history.png\"/></imageobject>"
1890 msgstr ""
1892 #. type: Content of: <book><chapter><sect1><sect2><informalfigure><mediaobject><textobject><phrase>
1893 #: ../en/ch01-tour-basic.xml:261 ../en/ch02-tour-merge.xml:48
1894 #: ../en/ch02-tour-merge.xml:78 ../en/ch02-tour-merge.xml:126
1895 #: ../en/ch02-tour-merge.xml:182 ../en/ch02-tour-merge.xml:254
1896 #: ../en/ch03-concepts.xml:56 ../en/ch03-concepts.xml:108
1897 #: ../en/ch03-concepts.xml:194 ../en/ch03-concepts.xml:301
1898 #: ../en/ch03-concepts.xml:353 ../en/ch03-concepts.xml:370
1899 #: ../en/ch03-concepts.xml:414 ../en/ch03-concepts.xml:436
1900 #: ../en/ch03-concepts.xml:480 ../en/ch05-collab.xml:277
1901 #: ../en/ch08-undo.xml:366 ../en/ch08-undo.xml:417 ../en/ch08-undo.xml:485
1902 #: ../en/ch08-undo.xml:527 ../en/ch11-mq.xml:410
1903 msgid "XXX add text"
1904 msgstr ""
1906 #. type: Content of: <book><chapter><sect1><informalfigure><mediaobject><caption><para>
1907 #: ../en/ch01-tour-basic.xml:262
1908 msgid ""
1909 "Graphical history of the <filename class=\"directory\">hello</filename> "
1910 "repository"
1911 msgstr ""
1913 #. type: Content of: <book><chapter><sect1><sect2><title>
1914 #: ../en/ch01-tour-basic.xml:269
1915 msgid "Changesets, revisions, and talking to other people"
1916 msgstr "改变集,版本,与其它用户交互"
1918 #. type: Content of: <book><chapter><sect1><sect2><para>
1919 #: ../en/ch01-tour-basic.xml:272
1920 msgid ""
1921 "As English is a notoriously sloppy language, and computer science has a "
1922 "hallowed history of terminological confusion (why use one term when four will "
1923 "do?), revision control has a variety of words and phrases that mean the same "
1924 "thing. If you are talking about Mercurial history with other people, you "
1925 "will find that the word <quote>changeset</quote> is often compressed to "
1926 "<quote>change</quote> or (when written) <quote>cset</quote>, and sometimes a "
1927 "changeset is referred to as a <quote>revision</quote> or a <quote>rev</quote>."
1928 msgstr ""
1930 #. type: Content of: <book><chapter><sect1><sect2><para>
1931 #: ../en/ch01-tour-basic.xml:282
1932 msgid ""
1933 "While it doesn't matter what <emphasis>word</emphasis> you use to refer to "
1934 "the concept of <quote>a changeset</quote>, the <emphasis>identifier</"
1935 "emphasis> that you use to refer to <quote>a <emphasis>specific</emphasis> "
1936 "changeset</quote> is of great importance. Recall that the <literal>changeset</"
1937 "literal> field in the output from <command role=\"hg-cmd\">hg log</command> "
1938 "identifies a changeset using both a number and a hexadecimal string."
1939 msgstr ""
1941 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
1942 #: ../en/ch01-tour-basic.xml:291
1943 msgid ""
1944 "The revision number is <emphasis>only valid in that repository</emphasis>,"
1945 msgstr ""
1947 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
1948 #: ../en/ch01-tour-basic.xml:293
1949 msgid ""
1950 "while the hex string is the <emphasis>permanent, unchanging identifier</"
1951 "emphasis> that will always identify that exact changeset in <emphasis>every</"
1952 "emphasis> copy of the repository."
1953 msgstr ""
1955 #. type: Content of: <book><chapter><sect1><sect2><para>
1956 #: ../en/ch01-tour-basic.xml:298
1957 msgid ""
1958 "This distinction is important. If you send someone an email talking about "
1959 "<quote>revision 33</quote>, there's a high likelihood that their revision 33 "
1960 "will <emphasis>not be the same</emphasis> as yours. The reason for this is "
1961 "that a revision number depends on the order in which changes arrived in a "
1962 "repository, and there is no guarantee that the same changes will happen in "
1963 "the same order in different repositories. Three changes $a,b,c$ can easily "
1964 "appear in one repository as $0,1,2$, while in another as $1,0,2$."
1965 msgstr ""
1967 #. type: Content of: <book><chapter><sect1><sect2><para>
1968 #: ../en/ch01-tour-basic.xml:308
1969 msgid ""
1970 "Mercurial uses revision numbers purely as a convenient shorthand. If you "
1971 "need to discuss a changeset with someone, or make a record of a changeset for "
1972 "some other reason (for example, in a bug report), use the hexadecimal "
1973 "identifier."
1974 msgstr ""
1976 #. type: Content of: <book><chapter><sect1><sect2><title>
1977 #: ../en/ch01-tour-basic.xml:316
1978 msgid "Viewing specific revisions"
1979 msgstr "察看指定版本"
1981 #. type: Content of: <book><chapter><sect1><sect2><para>
1982 #: ../en/ch01-tour-basic.xml:318
1983 msgid ""
1984 "To narrow the output of <command role=\"hg-cmd\">hg log</command> down to a "
1985 "single revision, use the <option role=\"hg-opt-log\">-r</option> (or <option "
1986 "role=\"hg-opt-log\">--rev</option>) option. You can use either a revision "
1987 "number or a long-form changeset identifier, and you can provide as many "
1988 "revisions as you want."
1989 msgstr ""
1991 #. type: Content of: <book><chapter><sect1><sect2><para>
1992 #: ../en/ch01-tour-basic.xml:327
1993 msgid ""
1994 "If you want to see the history of several revisions without having to list "
1995 "each one, you can use <emphasis>range notation</emphasis>; this lets you "
1996 "express the idea <quote>I want all revisions between <literal>abc</literal> "
1997 "and <literal>def</literal>, inclusive</quote>."
1998 msgstr ""
2000 #. type: Content of: <book><chapter><sect1><sect2><para>
2001 #: ../en/ch01-tour-basic.xml:335
2002 msgid ""
2003 "Mercurial also honours the order in which you specify revisions, so <command "
2004 "role=\"hg-cmd\">hg log -r 2:4</command> prints 2, 3, and 4. while <command "
2005 "role=\"hg-cmd\">hg log -r 4:2</command> prints 4, 3, and 2."
2006 msgstr ""
2008 #. type: Content of: <book><chapter><sect1><sect2><title>
2009 #: ../en/ch01-tour-basic.xml:342
2010 msgid "More detailed information"
2011 msgstr "更详细的信息"
2013 #. type: Content of: <book><chapter><sect1><sect2><para>
2014 #: ../en/ch01-tour-basic.xml:344
2015 msgid ""
2016 "While the summary information printed by <command role=\"hg-cmd\">hg log</"
2017 "command> is useful if you already know what you're looking for, you may need "
2018 "to see a complete description of the change, or a list of the files changed, "
2019 "if you're trying to decide whether a changeset is the one you're looking for. "
2020 "The <command role=\"hg-cmd\">hg log</command> command's <option role=\"hg-opt-"
2021 "global\">-v</option> (or <option role=\"hg-opt-global\">--verbose</option>) "
2022 "option gives you this extra detail."
2023 msgstr ""
2025 #. type: Content of: <book><chapter><sect1><sect2><para>
2026 #: ../en/ch01-tour-basic.xml:356
2027 msgid ""
2028 "If you want to see both the description and content of a change, add the "
2029 "<option role=\"hg-opt-log\">-p</option> (or <option role=\"hg-opt-log\">--"
2030 "patch</option>) option. This displays the content of a change as a "
2031 "<emphasis>unified diff</emphasis> (if you've never seen a unified diff "
2032 "before, see section <xref linkend=\"sec.mq.patch\"/> for an overview)."
2033 msgstr ""
2035 #. type: Content of: <book><chapter><sect1><title>
2036 #: ../en/ch01-tour-basic.xml:369
2037 msgid "All about command options"
2038 msgstr "命令选项"
2040 #. type: Content of: <book><chapter><sect1><para>
2041 #: ../en/ch01-tour-basic.xml:371
2042 msgid ""
2043 "Let's take a brief break from exploring Mercurial commands to discuss a "
2044 "pattern in the way that they work; you may find this useful to keep in mind "
2045 "as we continue our tour."
2046 msgstr ""
2048 #. type: Content of: <book><chapter><sect1><para>
2049 #: ../en/ch01-tour-basic.xml:375
2050 msgid ""
2051 "Mercurial has a consistent and straightforward approach to dealing with the "
2052 "options that you can pass to commands. It follows the conventions for "
2053 "options that are common to modern Linux and Unix systems."
2054 msgstr ""
2056 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
2057 #: ../en/ch01-tour-basic.xml:380
2058 msgid ""
2059 "Every option has a long name. For example, as we've already seen, the "
2060 "<command role=\"hg-cmd\">hg log</command> command accepts a <option role=\"hg-"
2061 "opt-log\">--rev</option> option."
2062 msgstr ""
2064 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
2065 #: ../en/ch01-tour-basic.xml:384
2066 msgid ""
2067 "Most options have short names, too. Instead of <option role=\"hg-opt-log\">--"
2068 "rev</option>, we can use <option role=\"hg-opt-log\">-r</option>. (The "
2069 "reason that some options don't have short names is that the options in "
2070 "question are rarely used.)"
2071 msgstr ""
2073 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
2074 #: ../en/ch01-tour-basic.xml:389
2075 msgid ""
2076 "Long options start with two dashes (e.g. <option role=\"hg-opt-log\">--rev</"
2077 "option>), while short options start with one (e.g. <option role=\"hg-opt-log"
2078 "\">-r</option>)."
2079 msgstr ""
2081 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
2082 #: ../en/ch01-tour-basic.xml:393
2083 msgid ""
2084 "Option naming and usage is consistent across commands. For example, every "
2085 "command that lets you specify a changeset ID or revision number accepts both "
2086 "<option role=\"hg-opt-log\">-r</option> and <option role=\"hg-opt-log\">--"
2087 "rev</option> arguments."
2088 msgstr ""
2090 #. type: Content of: <book><chapter><sect1><para>
2091 #: ../en/ch01-tour-basic.xml:399
2092 msgid ""
2093 "In the examples throughout this book, I use short options instead of long. "
2094 "This just reflects my own preference, so don't read anything significant into "
2095 "it."
2096 msgstr ""
2098 #. type: Content of: <book><chapter><sect1><para>
2099 #: ../en/ch01-tour-basic.xml:403
2100 msgid ""
2101 "Most commands that print output of some kind will print more output when "
2102 "passed a <option role=\"hg-opt-global\">-v</option> (or <option role=\"hg-opt-"
2103 "global\">--verbose</option>) option, and less when passed <option role=\"hg-"
2104 "opt-global\">-q</option> (or <option role=\"hg-opt-global\">--quiet</option>)."
2105 msgstr ""
2107 #. type: Content of: <book><chapter><sect1><title>
2108 #: ../en/ch01-tour-basic.xml:411
2109 msgid "Making and reviewing changes"
2110 msgstr "创建和复审修改"
2112 #. type: Content of: <book><chapter><sect1><para>
2113 #: ../en/ch01-tour-basic.xml:413
2114 msgid ""
2115 "Now that we have a grasp of viewing history in Mercurial, let's take a look "
2116 "at making some changes and examining them."
2117 msgstr ""
2119 #. type: Content of: <book><chapter><sect1><para>
2120 #: ../en/ch01-tour-basic.xml:417
2121 msgid ""
2122 "The first thing we'll do is isolate our experiment in a repository of its "
2123 "own. We use the <command role=\"hg-cmd\">hg clone</command> command, but we "
2124 "don't need to clone a copy of the remote repository. Since we already have a "
2125 "copy of it locally, we can just clone that instead. This is much faster than "
2126 "cloning over the network, and cloning a local repository uses less disk space "
2127 "in most cases, too."
2128 msgstr ""
2130 #. type: Content of: <book><chapter><sect1><para>
2131 #: ../en/ch01-tour-basic.xml:427
2132 msgid ""
2133 "As an aside, it's often good practice to keep a <quote>pristine</quote> copy "
2134 "of a remote repository around, which you can then make temporary clones of to "
2135 "create sandboxes for each task you want to work on. This lets you work on "
2136 "multiple tasks in parallel, each isolated from the others until it's complete "
2137 "and you're ready to integrate it back. Because local clones are so cheap, "
2138 "there's almost no overhead to cloning and destroying repositories whenever "
2139 "you want."
2140 msgstr ""
2142 #. type: Content of: <book><chapter><sect1><para>
2143 #: ../en/ch01-tour-basic.xml:436
2144 msgid ""
2145 "In our <filename class=\"directory\">my-hello</filename> repository, we have "
2146 "a file <filename>hello.c</filename> that contains the classic <quote>hello, "
2147 "world</quote> program. Let's use the ancient and venerable <command>sed</"
2148 "command> command to edit this file so that it prints a second line of "
2149 "output. (I'm only using <command>sed</command> to do this because it's easy "
2150 "to write a scripted example this way. Since you're not under the same "
2151 "constraint, you probably won't want to use <command>sed</command>; simply use "
2152 "your preferred text editor to do the same thing.)"
2153 msgstr ""
2155 #. type: Content of: <book><chapter><sect1><para>
2156 #: ../en/ch01-tour-basic.xml:449
2157 msgid ""
2158 "Mercurial's <command role=\"hg-cmd\">hg status</command> command will tell us "
2159 "what Mercurial knows about the files in the repository."
2160 msgstr ""
2162 #. type: Content of: <book><chapter><sect1><para>
2163 #: ../en/ch01-tour-basic.xml:455
2164 msgid ""
2165 "The <command role=\"hg-cmd\">hg status</command> command prints no output for "
2166 "some files, but a line starting with <quote><literal>M</literal></quote> for "
2167 "<filename>hello.c</filename>. Unless you tell it to, <command role=\"hg-cmd"
2168 "\">hg status</command> will not print any output for files that have not been "
2169 "modified."
2170 msgstr ""
2172 #. type: Content of: <book><chapter><sect1><para>
2173 #: ../en/ch01-tour-basic.xml:462
2174 msgid ""
2175 "The <quote><literal>M</literal></quote> indicates that Mercurial has noticed "
2176 "that we modified <filename>hello.c</filename>. We didn't need to "
2177 "<emphasis>inform</emphasis> Mercurial that we were going to modify the file "
2178 "before we started, or that we had modified the file after we were done; it "
2179 "was able to figure this out itself."
2180 msgstr ""
2182 #. type: Content of: <book><chapter><sect1><para>
2183 #: ../en/ch01-tour-basic.xml:470
2184 msgid ""
2185 "It's a little bit helpful to know that we've modified <filename>hello.c</"
2186 "filename>, but we might prefer to know exactly <emphasis>what</emphasis> "
2187 "changes we've made to it. To do this, we use the <command role=\"hg-cmd\">hg "
2188 "diff</command> command."
2189 msgstr ""
2191 #. type: Content of: <book><chapter><sect1><title>
2192 #: ../en/ch01-tour-basic.xml:480
2193 msgid "Recording changes in a new changeset"
2194 msgstr "在新修改集中记录修改"
2196 #. type: Content of: <book><chapter><sect1><para>
2197 #: ../en/ch01-tour-basic.xml:482
2198 msgid ""
2199 "We can modify files, build and test our changes, and use <command role=\"hg-"
2200 "cmd\">hg status</command> and <command role=\"hg-cmd\">hg diff</command> to "
2201 "review our changes, until we're satisfied with what we've done and arrive at "
2202 "a natural stopping point where we want to record our work in a new changeset."
2203 msgstr ""
2205 #. type: Content of: <book><chapter><sect1><para>
2206 #: ../en/ch01-tour-basic.xml:489
2207 msgid ""
2208 "The <command role=\"hg-cmd\">hg commit</command> command lets us create a new "
2209 "changeset; we'll usually refer to this as <quote>making a commit</quote> or "
2210 "<quote>committing</quote>."
2211 msgstr ""
2213 #. type: Content of: <book><chapter><sect1><sect2><title>
2214 #: ../en/ch01-tour-basic.xml:495
2215 msgid "Setting up a username"
2216 msgstr "配置用户名称"
2218 #. type: Content of: <book><chapter><sect1><sect2><para>
2219 #: ../en/ch01-tour-basic.xml:497
2220 msgid ""
2221 "When you try to run <command role=\"hg-cmd\">hg commit</command> for the "
2222 "first time, it is not guaranteed to succeed. Mercurial records your name and "
2223 "address with each change that you commit, so that you and others will later "
2224 "be able to tell who made each change. Mercurial tries to automatically "
2225 "figure out a sensible username to commit the change with. It will attempt "
2226 "each of the following methods, in order:"
2227 msgstr ""
2229 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
2230 #: ../en/ch01-tour-basic.xml:506
2231 msgid ""
2232 "If you specify a <option role=\"hg-opt-commit\">-u</option> option to the "
2233 "<command role=\"hg-cmd\">hg commit</command> command on the command line, "
2234 "followed by a username, this is always given the highest precedence."
2235 msgstr ""
2237 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
2238 #: ../en/ch01-tour-basic.xml:511
2239 msgid ""
2240 "If you have set the <envar>HGUSER</envar> environment variable, this is "
2241 "checked next."
2242 msgstr ""
2244 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
2245 #: ../en/ch01-tour-basic.xml:514
2246 msgid ""
2247 "If you create a file in your home directory called <filename role=\"special"
2248 "\">.hgrc</filename>, with a <envar role=\"rc-item-ui\">username</envar> "
2249 "entry, that will be used next. To see what the contents of this file should "
2250 "look like, refer to section <xref linkend=\"sec.tour-basic.username\"/> below."
2251 msgstr ""
2253 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
2254 #: ../en/ch01-tour-basic.xml:521
2255 msgid ""
2256 "If you have set the <envar>EMAIL</envar> environment variable, this will be "
2257 "used next."
2258 msgstr ""
2260 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
2261 #: ../en/ch01-tour-basic.xml:524
2262 msgid ""
2263 "Mercurial will query your system to find out your local user name and host "
2264 "name, and construct a username from these components. Since this often "
2265 "results in a username that is not very useful, it will print a warning if it "
2266 "has to do this."
2267 msgstr ""
2269 #. type: Content of: <book><chapter><sect1><sect2><para>
2270 #: ../en/ch01-tour-basic.xml:531
2271 msgid ""
2272 "If all of these mechanisms fail, Mercurial will fail, printing an error "
2273 "message. In this case, it will not let you commit until you set up a "
2274 "username."
2275 msgstr ""
2277 #. type: Content of: <book><chapter><sect1><sect2><para>
2278 #: ../en/ch01-tour-basic.xml:535
2279 msgid ""
2280 "You should think of the <envar>HGUSER</envar> environment variable and the "
2281 "<option role=\"hg-opt-commit\">-u</option> option to the <command role=\"hg-"
2282 "cmd\">hg commit</command> command as ways to <emphasis>override</emphasis> "
2283 "Mercurial's default selection of username. For normal use, the simplest and "
2284 "most robust way to set a username for yourself is by creating a <filename "
2285 "role=\"special\">.hgrc</filename> file; see below for details."
2286 msgstr ""
2288 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
2289 #: ../en/ch01-tour-basic.xml:544
2290 msgid "Creating a Mercurial configuration file"
2291 msgstr "创建 Mercurial 的配置文件"
2293 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
2294 #: ../en/ch01-tour-basic.xml:546
2295 msgid ""
2296 "To set a user name, use your favourite editor to create a file called "
2297 "<filename role=\"special\">.hgrc</filename> in your home directory. "
2298 "Mercurial will use this file to look up your personalised configuration "
2299 "settings. The initial contents of your <filename role=\"special\">.hgrc</"
2300 "filename> should look like this."
2301 msgstr ""
2303 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
2304 #: ../en/ch01-tour-basic.xml:558
2305 msgid ""
2306 "The <quote><literal>[ui]</literal></quote> line begins a <emphasis>section</"
2307 "emphasis> of the config file, so you can read the <quote><literal>username "
2308 "= ...</literal></quote> line as meaning <quote>set the value of the "
2309 "<literal>username</literal> item in the <literal>ui</literal> section</"
2310 "quote>. A section continues until a new section begins, or the end of the "
2311 "file. Mercurial ignores empty lines and treats any text from "
2312 "<quote><literal>#</literal></quote> to the end of a line as a comment."
2313 msgstr ""
2315 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
2316 #: ../en/ch01-tour-basic.xml:571
2317 msgid "Choosing a user name"
2318 msgstr "选择用户名称"
2320 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
2321 #: ../en/ch01-tour-basic.xml:573
2322 msgid ""
2323 "You can use any text you like as the value of the <literal>username</literal> "
2324 "config item, since this information is for reading by other people, but for "
2325 "interpreting by Mercurial. The convention that most people follow is to use "
2326 "their name and email address, as in the example above."
2327 msgstr ""
2329 #. type: Content of: <book><chapter><sect1><sect2><sect3><note><para>
2330 #: ../en/ch01-tour-basic.xml:580
2331 msgid ""
2332 "Mercurial's built-in web server obfuscates email addresses, to make it more "
2333 "difficult for the email harvesting tools that spammers use. This reduces the "
2334 "likelihood that you'll start receiving more junk email if you publish a "
2335 "Mercurial repository on the web."
2336 msgstr ""
2338 #. type: Content of: <book><chapter><sect1><sect2><title>
2339 #: ../en/ch01-tour-basic.xml:590
2340 msgid "Writing a commit message"
2341 msgstr "写提交日志"
2343 #. type: Content of: <book><chapter><sect1><sect2><para>
2344 #: ../en/ch01-tour-basic.xml:592
2345 msgid ""
2346 "When we commit a change, Mercurial drops us into a text editor, to enter a "
2347 "message that will describe the modifications we've made in this changeset. "
2348 "This is called the <emphasis>commit message</emphasis>. It will be a record "
2349 "for readers of what we did and why, and it will be printed by <command role="
2350 "\"hg-cmd\">hg log</command> after we've finished committing."
2351 msgstr ""
2353 #. type: Content of: <book><chapter><sect1><sect2><para>
2354 #: ../en/ch01-tour-basic.xml:602
2355 msgid ""
2356 "The editor that the <command role=\"hg-cmd\">hg commit</command> command "
2357 "drops us into will contain an empty line, followed by a number of lines "
2358 "starting with <quote><literal>HG:</literal></quote>."
2359 msgstr ""
2361 #. type: Content of: <book><chapter><sect1><sect2><para>
2362 #: ../en/ch01-tour-basic.xml:609
2363 msgid ""
2364 "Mercurial ignores the lines that start with <quote><literal>HG:</literal></"
2365 "quote>; it uses them only to tell us which files it's recording changes to. "
2366 "Modifying or deleting these lines has no effect."
2367 msgstr ""
2369 #. type: Content of: <book><chapter><sect1><sect2><title>
2370 #: ../en/ch01-tour-basic.xml:615
2371 msgid "Writing a good commit message"
2372 msgstr "写好提交日志"
2374 #. type: Content of: <book><chapter><sect1><sect2><para>
2375 #: ../en/ch01-tour-basic.xml:617
2376 msgid ""
2377 "Since <command role=\"hg-cmd\">hg log</command> only prints the first line of "
2378 "a commit message by default, it's best to write a commit message whose first "
2379 "line stands alone. Here's a real example of a commit message that "
2380 "<emphasis>doesn't</emphasis> follow this guideline, and hence has a summary "
2381 "that is not readable."
2382 msgstr ""
2384 #. type: Content of: <book><chapter><sect1><sect2><para>
2385 #: ../en/ch01-tour-basic.xml:631
2386 msgid ""
2387 "As far as the remainder of the contents of the commit message are concerned, "
2388 "there are no hard-and-fast rules. Mercurial itself doesn't interpret or care "
2389 "about the contents of the commit message, though your project may have "
2390 "policies that dictate a certain kind of formatting."
2391 msgstr ""
2393 #. type: Content of: <book><chapter><sect1><sect2><para>
2394 #: ../en/ch01-tour-basic.xml:637
2395 msgid ""
2396 "My personal preference is for short, but informative, commit messages that "
2397 "tell me something that I can't figure out with a quick glance at the output "
2398 "of <command role=\"hg-cmd\">hg log --patch</command>."
2399 msgstr ""
2401 #. type: Content of: <book><chapter><sect1><sect2><title>
2402 #: ../en/ch01-tour-basic.xml:644
2403 msgid "Aborting a commit"
2404 msgstr "终止提交"
2406 #. type: Content of: <book><chapter><sect1><sect2><para>
2407 #: ../en/ch01-tour-basic.xml:646
2408 msgid ""
2409 "If you decide that you don't want to commit while in the middle of editing a "
2410 "commit message, simply exit from your editor without saving the file that "
2411 "it's editing. This will cause nothing to happen to either the repository or "
2412 "the working directory."
2413 msgstr ""
2415 #. type: Content of: <book><chapter><sect1><sect2><para>
2416 #: ../en/ch01-tour-basic.xml:651
2417 msgid ""
2418 "If we run the <command role=\"hg-cmd\">hg commit</command> command without "
2419 "any arguments, it records all of the changes we've made, as reported by "
2420 "<command role=\"hg-cmd\">hg status</command> and <command role=\"hg-cmd\">hg "
2421 "diff</command>."
2422 msgstr ""
2424 #. type: Content of: <book><chapter><sect1><sect2><title>
2425 #: ../en/ch01-tour-basic.xml:658
2426 msgid "Admiring our new handiwork"
2427 msgstr "欣赏我们的新手艺"
2429 #. type: Content of: <book><chapter><sect1><sect2><para>
2430 #: ../en/ch01-tour-basic.xml:660
2431 msgid ""
2432 "Once we've finished the commit, we can use the <command role=\"hg-cmd\">hg "
2433 "tip</command> command to display the changeset we just created. This command "
2434 "produces output that is identical to <command role=\"hg-cmd\">hg log</"
2435 "command>, but it only displays the newest revision in the repository."
2436 msgstr ""
2438 #. type: Content of: <book><chapter><sect1><sect2><para>
2439 #: ../en/ch01-tour-basic.xml:669
2440 msgid ""
2441 "We refer to the newest revision in the repository as the tip revision, or "
2442 "simply the tip."
2443 msgstr ""
2445 #. type: Content of: <book><chapter><sect1><title>
2446 #: ../en/ch01-tour-basic.xml:676
2447 msgid "Sharing changes"
2448 msgstr "共享修改"
2450 #. type: Content of: <book><chapter><sect1><para>
2451 #: ../en/ch01-tour-basic.xml:678
2452 msgid ""
2453 "We mentioned earlier that repositories in Mercurial are self-contained. This "
2454 "means that the changeset we just created exists only in our <filename class="
2455 "\"directory\">my-hello</filename> repository. Let's look at a few ways that "
2456 "we can propagate this change into other repositories."
2457 msgstr ""
2459 #. type: Content of: <book><chapter><sect1><sect2><title>
2460 #: ../en/ch01-tour-basic.xml:686
2461 msgid "Pulling changes from another repository"
2462 msgstr "从其它版本库取得修改"
2464 #. type: Content of: <book><chapter><sect1><sect2><para>
2465 #: ../en/ch01-tour-basic.xml:687
2466 msgid ""
2467 "To get started, let's clone our original <filename class=\"directory\">hello</"
2468 "filename> repository, which does not contain the change we just committed. "
2469 "We'll call our temporary repository <filename class=\"directory\">hello-pull</"
2470 "filename>."
2471 msgstr ""
2473 #. type: Content of: <book><chapter><sect1><sect2><para>
2474 #: ../en/ch01-tour-basic.xml:695
2475 msgid ""
2476 "We'll use the <command role=\"hg-cmd\">hg pull</command> command to bring "
2477 "changes from <filename class=\"directory\">my-hello</filename> into <filename "
2478 "class=\"directory\">hello-pull</filename>. However, blindly pulling unknown "
2479 "changes into a repository is a somewhat scary prospect. Mercurial provides "
2480 "the <command role=\"hg-cmd\">hg incoming</command> command to tell us what "
2481 "changes the <command role=\"hg-cmd\">hg pull</command> command "
2482 "<emphasis>would</emphasis> pull into the repository, without actually pulling "
2483 "the changes in."
2484 msgstr ""
2486 #. type: Content of: <book><chapter><sect1><sect2><para>
2487 #: ../en/ch01-tour-basic.xml:708
2488 msgid ""
2489 "(Of course, someone could cause more changesets to appear in the repository "
2490 "that we ran <command role=\"hg-cmd\">hg incoming</command> in, before we get "
2491 "a chance to <command role=\"hg-cmd\">hg pull</command> the changes, so that "
2492 "we could end up pulling changes that we didn't expect.)"
2493 msgstr ""
2495 #. type: Content of: <book><chapter><sect1><sect2><para>
2496 #: ../en/ch01-tour-basic.xml:715
2497 msgid ""
2498 "Bringing changes into a repository is a simple matter of running the <command "
2499 "role=\"hg-cmd\">hg pull</command> command, and telling it which repository to "
2500 "pull from."
2501 msgstr ""
2503 #. type: Content of: <book><chapter><sect1><sect2><para>
2504 #: ../en/ch01-tour-basic.xml:722
2505 msgid ""
2506 "As you can see from the before-and-after output of <command role=\"hg-cmd"
2507 "\">hg tip</command>, we have successfully pulled changes into our "
2508 "repository. There remains one step before we can see these changes in the "
2509 "working directory."
2510 msgstr ""
2512 #. type: Content of: <book><chapter><sect1><sect2><title>
2513 #: ../en/ch01-tour-basic.xml:730
2514 msgid "Updating the working directory"
2515 msgstr "更新工作目录"
2517 #. type: Content of: <book><chapter><sect1><sect2><para>
2518 #: ../en/ch01-tour-basic.xml:732
2519 msgid ""
2520 "We have so far glossed over the relationship between a repository and its "
2521 "working directory. The <command role=\"hg-cmd\">hg pull</command> command "
2522 "that we ran in section <xref linkend=\"sec.tour.pull\"/> brought changes into "
2523 "the repository, but if we check, there's no sign of those changes in the "
2524 "working directory. This is because <command role=\"hg-cmd\">hg pull</"
2525 "command> does not (by default) touch the working directory. Instead, we use "
2526 "the <command role=\"hg-cmd\">hg update</command> command to do this."
2527 msgstr ""
2529 #. type: Content of: <book><chapter><sect1><sect2><para>
2530 #: ../en/ch01-tour-basic.xml:744
2531 msgid ""
2532 "It might seem a bit strange that <command role=\"hg-cmd\">hg pull</command> "
2533 "doesn't update the working directory automatically. There's actually a good "
2534 "reason for this: you can use <command role=\"hg-cmd\">hg update</command> to "
2535 "update the working directory to the state it was in at <emphasis>any "
2536 "revision</emphasis> in the history of the repository. If you had the working "
2537 "directory updated to an old revision---to hunt down the origin of a bug, "
2538 "say---and ran a <command role=\"hg-cmd\">hg pull</command> which "
2539 "automatically updated the working directory to a new revision, you might not "
2540 "be terribly happy."
2541 msgstr ""
2543 #. type: Content of: <book><chapter><sect1><sect2><para>
2544 #: ../en/ch01-tour-basic.xml:755
2545 msgid ""
2546 "However, since pull-then-update is such a common thing to do, Mercurial lets "
2547 "you combine the two by passing the <option role=\"hg-opt-pull\">-u</option> "
2548 "option to <command role=\"hg-cmd\">hg pull</command>."
2549 msgstr ""
2551 #. type: Content of: <book><chapter><sect1><sect2><para>
2552 #: ../en/ch01-tour-basic.xml:760
2553 msgid ""
2554 "If you look back at the output of <command role=\"hg-cmd\">hg pull</command> "
2555 "in section <xref linkend=\"sec.tour.pull\"/> when we ran it without <option "
2556 "role=\"hg-opt-pull\">-u</option>, you can see that it printed a helpful "
2557 "reminder that we'd have to take an explicit step to update the working "
2558 "directory:"
2559 msgstr ""
2561 #. type: Content of: <book><chapter><sect1><sect2><para>
2562 #: ../en/ch01-tour-basic.xml:769
2563 msgid ""
2564 "To find out what revision the working directory is at, use the <command role="
2565 "\"hg-cmd\">hg parents</command> command."
2566 msgstr ""
2568 #. type: Content of: <book><chapter><sect1><sect2><para>
2569 #: ../en/ch01-tour-basic.xml:775
2570 msgid ""
2571 "If you look back at figure <xref endterm=\"fig.tour-basic.history.caption\" "
2572 "linkend=\"fig.tour-basic.history\"/>, you'll see arrows connecting each "
2573 "changeset. The node that the arrow leads <emphasis>from</emphasis> in each "
2574 "case is a parent, and the node that the arrow leads <emphasis>to</emphasis> "
2575 "is its child. The working directory has a parent in just the same way; this "
2576 "is the changeset that the working directory currently contains."
2577 msgstr ""
2579 #. type: Content of: <book><chapter><sect1><sect2><para>
2580 #: ../en/ch01-tour-basic.xml:785
2581 msgid ""
2582 "To update the working directory to a particular revision, give a revision "
2583 "number or changeset ID to the <command role=\"hg-cmd\">hg update</command> "
2584 "command."
2585 msgstr ""
2587 #. type: Content of: <book><chapter><sect1><sect2><para>
2588 #: ../en/ch01-tour-basic.xml:792
2589 msgid ""
2590 "If you omit an explicit revision, <command role=\"hg-cmd\">hg update</"
2591 "command> will update to the tip revision, as shown by the second call to "
2592 "<command role=\"hg-cmd\">hg update</command> in the example above."
2593 msgstr ""
2595 #. type: Content of: <book><chapter><sect1><sect2><title>
2596 #: ../en/ch01-tour-basic.xml:800
2597 msgid "Pushing changes to another repository"
2598 msgstr "发布修改到其它版本库"
2600 #. type: Content of: <book><chapter><sect1><sect2><para>
2601 #: ../en/ch01-tour-basic.xml:802
2602 msgid ""
2603 "Mercurial lets us push changes to another repository, from the repository "
2604 "we're currently visiting. As with the example of <command role=\"hg-cmd\">hg "
2605 "pull</command> above, we'll create a temporary repository to push our changes "
2606 "into."
2607 msgstr ""
2609 #. type: Content of: <book><chapter><sect1><sect2><para>
2610 #: ../en/ch01-tour-basic.xml:810
2611 msgid ""
2612 "The <command role=\"hg-cmd\">hg outgoing</command> command tells us what "
2613 "changes would be pushed into another repository."
2614 msgstr ""
2616 #. type: Content of: <book><chapter><sect1><sect2><para>
2617 #: ../en/ch01-tour-basic.xml:816
2618 msgid ""
2619 "And the <command role=\"hg-cmd\">hg push</command> command does the actual "
2620 "push."
2621 msgstr ""
2623 #. type: Content of: <book><chapter><sect1><sect2><para>
2624 #: ../en/ch01-tour-basic.xml:822
2625 msgid ""
2626 "As with <command role=\"hg-cmd\">hg pull</command>, the <command role=\"hg-cmd"
2627 "\">hg push</command> command does not update the working directory in the "
2628 "repository that it's pushing changes into. (Unlike <command role=\"hg-cmd"
2629 "\">hg pull</command>, <command role=\"hg-cmd\">hg push</command> does not "
2630 "provide a <literal>-u</literal> option that updates the other repository's "
2631 "working directory.)"
2632 msgstr ""
2634 #. type: Content of: <book><chapter><sect1><sect2><para>
2635 #: ../en/ch01-tour-basic.xml:831
2636 msgid ""
2637 "What happens if we try to pull or push changes and the receiving repository "
2638 "already has those changes? Nothing too exciting."
2639 msgstr ""
2641 #. type: Content of: <book><chapter><sect1><sect2><title>
2642 #: ../en/ch01-tour-basic.xml:838
2643 msgid "Sharing changes over a network"
2644 msgstr "通过网络共享修改"
2646 #. type: Content of: <book><chapter><sect1><sect2><para>
2647 #: ../en/ch01-tour-basic.xml:840
2648 msgid ""
2649 "The commands we have covered in the previous few sections are not limited to "
2650 "working with local repositories. Each works in exactly the same fashion over "
2651 "a network connection; simply pass in a URL instead of a local path."
2652 msgstr ""
2654 #. type: Content of: <book><chapter><sect1><sect2><para>
2655 #: ../en/ch01-tour-basic.xml:848
2656 msgid ""
2657 "In this example, we can see what changes we could push to the remote "
2658 "repository, but the repository is understandably not set up to let anonymous "
2659 "users push to it."
2660 msgstr ""
2662 #. type: Content of: <book><chapter><title>
2663 #: ../en/ch02-tour-merge.xml:5
2664 msgid "A tour of Mercurial: merging work"
2665 msgstr "Mercurial 教程: 合并工作"
2667 #. type: Content of: <book><chapter><para>
2668 #: ../en/ch02-tour-merge.xml:7
2669 msgid ""
2670 "We've now covered cloning a repository, making changes in a repository, and "
2671 "pulling or pushing changes from one repository into another. Our next step "
2672 "is <emphasis>merging</emphasis> changes from separate repositories."
2673 msgstr ""
2675 #. type: Content of: <book><chapter><sect1><title>
2676 #: ../en/ch02-tour-merge.xml:13
2677 msgid "Merging streams of work"
2678 msgstr "合并的流程"
2680 #. type: Content of: <book><chapter><sect1><para>
2681 #: ../en/ch02-tour-merge.xml:15
2682 msgid ""
2683 "Merging is a fundamental part of working with a distributed revision control "
2684 "tool."
2685 msgstr ""
2687 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
2688 #: ../en/ch02-tour-merge.xml:18
2689 msgid ""
2690 "Alice and Bob each have a personal copy of a repository for a project they're "
2691 "collaborating on. Alice fixes a bug in her repository; Bob adds a new "
2692 "feature in his. They want the shared repository to contain both the bug fix "
2693 "and the new feature."
2694 msgstr ""
2696 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
2697 #: ../en/ch02-tour-merge.xml:24
2698 msgid ""
2699 "I frequently work on several different tasks for a single project at once, "
2700 "each safely isolated in its own repository. Working this way means that I "
2701 "often need to merge one piece of my own work with another."
2702 msgstr ""
2704 #. type: Content of: <book><chapter><sect1><para>
2705 #: ../en/ch02-tour-merge.xml:30
2706 msgid ""
2707 "Because merging is such a common thing to need to do, Mercurial makes it "
2708 "easy. Let's walk through the process. We'll begin by cloning yet another "
2709 "repository (see how often they spring up?) and making a change in it."
2710 msgstr ""
2712 #. type: Content of: <book><chapter><sect1><para>
2713 #: ../en/ch02-tour-merge.xml:37
2714 msgid ""
2715 "We should now have two copies of <filename>hello.c</filename> with different "
2716 "contents. The histories of the two repositories have also diverged, as "
2717 "illustrated in figure <xref endterm=\"fig.tour-merge.sep-repos.caption\" "
2718 "linkend=\"fig.tour-merge.sep-repos\"/>."
2719 msgstr ""
2721 #. type: Content of: <book><chapter><sect1><informalfigure><mediaobject>
2722 #: ../en/ch02-tour-merge.xml:47
2723 msgid ""
2724 "<imageobject><imagedata fileref=\"images/tour-merge-sep-repos.png\"/></"
2725 "imageobject>"
2726 msgstr ""
2728 #. type: Content of: <book><chapter><sect1><informalfigure><mediaobject><caption><para>
2729 #: ../en/ch02-tour-merge.xml:49
2730 msgid ""
2731 "Divergent recent histories of the <filename class=\"directory\">my-hello</"
2732 "filename> and <filename class=\"directory\">my-new-hello</filename> "
2733 "repositories"
2734 msgstr ""
2736 #. type: Content of: <book><chapter><sect1><para>
2737 #: ../en/ch02-tour-merge.xml:57
2738 msgid ""
2739 "We already know that pulling changes from our <filename class=\"directory"
2740 "\">my-hello</filename> repository will have no effect on the working "
2741 "directory."
2742 msgstr ""
2744 #. type: Content of: <book><chapter><sect1><para>
2745 #: ../en/ch02-tour-merge.xml:63
2746 msgid ""
2747 "However, the <command role=\"hg-cmd\">hg pull</command> command says "
2748 "something about <quote>heads</quote>."
2749 msgstr ""
2751 #. type: Content of: <book><chapter><sect1><sect2><title>
2752 #: ../en/ch02-tour-merge.xml:67
2753 msgid "Head changesets"
2754 msgstr "顶点改变集"
2756 #. type: Content of: <book><chapter><sect1><sect2><para>
2757 #: ../en/ch02-tour-merge.xml:69
2758 msgid ""
2759 "A head is a change that has no descendants, or children, as they're also "
2760 "known. The tip revision is thus a head, because the newest revision in a "
2761 "repository doesn't have any children, but a repository can contain more than "
2762 "one head."
2763 msgstr ""
2765 #. type: Content of: <book><chapter><sect1><sect2><informalfigure><mediaobject>
2766 #: ../en/ch02-tour-merge.xml:77
2767 msgid ""
2768 "<imageobject><imagedata fileref=\"images/tour-merge-pull.png\"/></imageobject>"
2769 msgstr ""
2771 #. type: Content of: <book><chapter><sect1><sect2><informalfigure><mediaobject><caption><para>
2772 #: ../en/ch02-tour-merge.xml:79
2773 msgid ""
2774 "Repository contents after pulling from <filename class=\"directory\">my-"
2775 "hello</filename> into <filename class=\"directory\">my-new-hello</filename>"
2776 msgstr ""
2778 #. type: Content of: <book><chapter><sect1><sect2><para>
2779 #: ../en/ch02-tour-merge.xml:85
2780 msgid ""
2781 "In figure <xref endterm=\"fig.tour-merge.pull.caption\" linkend=\"fig.tour-"
2782 "merge.pull\"/>, you can see the effect of the pull from <filename class="
2783 "\"directory\">my-hello</filename> into <filename class=\"directory\">my-new-"
2784 "hello</filename>. The history that was already present in <filename class="
2785 "\"directory\">my-new-hello</filename> is untouched, but a new revision has "
2786 "been added. By referring to figure <xref endterm=\"fig.tour-merge.sep-repos."
2787 "caption\" linkend=\"fig.tour-merge.sep-repos\"/>, we can see that the "
2788 "<emphasis>changeset ID</emphasis> remains the same in the new repository, but "
2789 "the <emphasis>revision number</emphasis> has changed. (This, incidentally, "
2790 "is a fine example of why it's not safe to use revision numbers when "
2791 "discussing changesets.) We can view the heads in a repository using the "
2792 "<command role=\"hg-cmd\">hg heads</command> command."
2793 msgstr ""
2795 #. type: Content of: <book><chapter><sect1><sect2><title>
2796 #: ../en/ch02-tour-merge.xml:106
2797 msgid "Performing the merge"
2798 msgstr "执行合并"
2800 #. type: Content of: <book><chapter><sect1><sect2><para>
2801 #: ../en/ch02-tour-merge.xml:108
2802 msgid ""
2803 "What happens if we try to use the normal <command role=\"hg-cmd\">hg update</"
2804 "command> command to update to the new tip?"
2805 msgstr ""
2807 #. type: Content of: <book><chapter><sect1><sect2><para>
2808 #: ../en/ch02-tour-merge.xml:114
2809 msgid ""
2810 "Mercurial is telling us that the <command role=\"hg-cmd\">hg update</command> "
2811 "command won't do a merge; it won't update the working directory when it "
2812 "thinks we might be wanting to do a merge, unless we force it to do so. "
2813 "Instead, we use the <command role=\"hg-cmd\">hg merge</command> command to "
2814 "merge the two heads."
2815 msgstr ""
2817 #. type: Content of: <book><chapter><sect1><sect2><informalfigure><mediaobject>
2818 #: ../en/ch02-tour-merge.xml:125
2819 msgid ""
2820 "<imageobject><imagedata fileref=\"images/tour-merge-merge.png\"/></"
2821 "imageobject>"
2822 msgstr ""
2824 #. type: Content of: <book><chapter><sect1><sect2><informalfigure><mediaobject><caption><para>
2825 #: ../en/ch02-tour-merge.xml:127
2826 msgid "Working directory and repository during merge, and following commit"
2827 msgstr ""
2829 #. type: Content of: <book><chapter><sect1><sect2><para>
2830 #: ../en/ch02-tour-merge.xml:132
2831 msgid ""
2832 "This updates the working directory so that it contains changes from "
2833 "<emphasis>both</emphasis> heads, which is reflected in both the output of "
2834 "<command role=\"hg-cmd\">hg parents</command> and the contents of "
2835 "<filename>hello.c</filename>."
2836 msgstr ""
2838 #. type: Content of: <book><chapter><sect1><sect2><title>
2839 #: ../en/ch02-tour-merge.xml:142
2840 msgid "Committing the results of the merge"
2841 msgstr "提交合并结果"
2843 #. type: Content of: <book><chapter><sect1><sect2><para>
2844 #: ../en/ch02-tour-merge.xml:144
2845 msgid ""
2846 "Whenever we've done a merge, <command role=\"hg-cmd\">hg parents</command> "
2847 "will display two parents until we <command role=\"hg-cmd\">hg commit</"
2848 "command> the results of the merge."
2849 msgstr ""
2851 #. type: Content of: <book><chapter><sect1><sect2><para>
2852 #: ../en/ch02-tour-merge.xml:151
2853 msgid ""
2854 "We now have a new tip revision; notice that it has <emphasis>both</emphasis> "
2855 "of our former heads as its parents. These are the same revisions that were "
2856 "previously displayed by <command role=\"hg-cmd\">hg parents</command>."
2857 msgstr ""
2859 #. type: Content of: <book><chapter><sect1><sect2><para>
2860 #: ../en/ch02-tour-merge.xml:158
2861 msgid ""
2862 "In figure <xref endterm=\"fig.tour-merge.merge.caption\" linkend=\"fig.tour-"
2863 "merge.merge\"/>, you can see a representation of what happens to the working "
2864 "directory during the merge, and how this affects the repository when the "
2865 "commit happens. During the merge, the working directory has two parent "
2866 "changesets, and these become the parents of the new changeset."
2867 msgstr ""
2869 #. type: Content of: <book><chapter><sect1><title>
2870 #: ../en/ch02-tour-merge.xml:169
2871 msgid "Merging conflicting changes"
2872 msgstr "合并有冲突的改变"
2874 #. type: Content of: <book><chapter><sect1><para>
2875 #: ../en/ch02-tour-merge.xml:171
2876 msgid ""
2877 "Most merges are simple affairs, but sometimes you'll find yourself merging "
2878 "changes where each modifies the same portions of the same files. Unless both "
2879 "modifications are identical, this results in a <emphasis>conflict</emphasis>, "
2880 "where you have to decide how to reconcile the different changes into "
2881 "something coherent."
2882 msgstr ""
2884 #. type: Content of: <book><chapter><sect1><informalfigure><mediaobject>
2885 #: ../en/ch02-tour-merge.xml:180
2886 msgid ""
2887 "<imageobject><imagedata fileref=\"images/tour-merge-conflict.png\"/> </"
2888 "imageobject>"
2889 msgstr ""
2891 #. type: Content of: <book><chapter><sect1><informalfigure><mediaobject><caption><para>
2892 #: ../en/ch02-tour-merge.xml:183
2893 msgid "Conflicting changes to a document"
2894 msgstr ""
2896 #. type: Content of: <book><chapter><sect1><para>
2897 #: ../en/ch02-tour-merge.xml:188
2898 msgid ""
2899 "Figure <xref endterm=\"fig.tour-merge.conflict.caption\" linkend=\"fig.tour-"
2900 "merge.conflict\"/> illustrates an instance of two conflicting changes to a "
2901 "document. We started with a single version of the file; then we made some "
2902 "changes; while someone else made different changes to the same text. Our "
2903 "task in resolving the conflicting changes is to decide what the file should "
2904 "look like."
2905 msgstr ""
2907 #. type: Content of: <book><chapter><sect1><para>
2908 #: ../en/ch02-tour-merge.xml:196
2909 msgid ""
2910 "Mercurial doesn't have a built-in facility for handling conflicts. Instead, "
2911 "it runs an external program called <command>hgmerge</command>. This is a "
2912 "shell script that is bundled with Mercurial; you can change it to behave "
2913 "however you please. What it does by default is try to find one of several "
2914 "different merging tools that are likely to be installed on your system. It "
2915 "first tries a few fully automatic merging tools; if these don't succeed "
2916 "(because the resolution process requires human guidance) or aren't present, "
2917 "the script tries a few different graphical merging tools."
2918 msgstr ""
2920 #. type: Content of: <book><chapter><sect1><para>
2921 #: ../en/ch02-tour-merge.xml:207
2922 msgid ""
2923 "It's also possible to get Mercurial to run another program or script instead "
2924 "of <command>hgmerge</command>, by setting the <envar>HGMERGE</envar> "
2925 "environment variable to the name of your preferred program."
2926 msgstr ""
2928 #. type: Content of: <book><chapter><sect1><sect2><title>
2929 #: ../en/ch02-tour-merge.xml:213
2930 msgid "Using a graphical merge tool"
2931 msgstr "使用图形合并工具"
2933 #. type: Content of: <book><chapter><sect1><sect2><para>
2934 #: ../en/ch02-tour-merge.xml:215
2935 msgid ""
2936 "My preferred graphical merge tool is <command>kdiff3</command>, which I'll "
2937 "use to describe the features that are common to graphical file merging "
2938 "tools. You can see a screenshot of <command>kdiff3</command> in action in "
2939 "figure <xref endterm=\"fig.tour-merge.kdiff3.caption\" linkend=\"fig.tour-"
2940 "merge.kdiff3\"/>. The kind of merge it is performing is called a "
2941 "<emphasis>three-way merge</emphasis>, because there are three different "
2942 "versions of the file of interest to us. The tool thus splits the upper "
2943 "portion of the window into three panes:"
2944 msgstr ""
2946 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2947 #: ../en/ch02-tour-merge.xml:226
2948 msgid ""
2949 "At the left is the <emphasis>base</emphasis> version of the file, i.e. the "
2950 "most recent version from which the two versions we're trying to merge are "
2951 "descended."
2952 msgstr ""
2954 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2955 #: ../en/ch02-tour-merge.xml:231
2956 msgid ""
2957 "In the middle is <quote>our</quote> version of the file, with the contents "
2958 "that we modified."
2959 msgstr ""
2961 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2962 #: ../en/ch02-tour-merge.xml:234
2963 msgid ""
2964 "On the right is <quote>their</quote> version of the file, the one that from "
2965 "the changeset that we're trying to merge with."
2966 msgstr ""
2968 #. type: Content of: <book><chapter><sect1><sect2><para>
2969 #: ../en/ch02-tour-merge.xml:238
2970 msgid ""
2971 "In the pane below these is the current <emphasis>result</emphasis> of the "
2972 "merge. Our task is to replace all of the red text, which indicates unresolved "
2973 "conflicts, with some sensible merger of the <quote>ours</quote> and "
2974 "<quote>theirs</quote> versions of the file."
2975 msgstr ""
2977 #. type: Content of: <book><chapter><sect1><sect2><para>
2978 #: ../en/ch02-tour-merge.xml:245
2979 msgid ""
2980 "All four of these panes are <emphasis>locked together</emphasis>; if we "
2981 "scroll vertically or horizontally in any of them, the others are updated to "
2982 "display the corresponding sections of their respective files."
2983 msgstr ""
2985 #. type: Content of: <book><chapter><sect1><sect2><informalfigure><mediaobject>
2986 #: ../en/ch02-tour-merge.xml:252
2987 msgid ""
2988 "<imageobject><imagedata width=\"100%\" fileref=\"images/kdiff3.png\"/> </"
2989 "imageobject>"
2990 msgstr ""
2992 #. type: Content of: <book><chapter><sect1><sect2><informalfigure><mediaobject><caption><para>
2993 #: ../en/ch02-tour-merge.xml:255
2994 msgid "Using <command>kdiff3</command> to merge versions of a file"
2995 msgstr ""
2997 #. type: Content of: <book><chapter><sect1><sect2><para>
2998 #: ../en/ch02-tour-merge.xml:261
2999 msgid ""
3000 "For each conflicting portion of the file, we can choose to resolve the "
3001 "conflict using some combination of text from the base version, ours, or "
3002 "theirs. We can also manually edit the merged file at any time, in case we "
3003 "need to make further modifications."
3004 msgstr ""
3006 #. type: Content of: <book><chapter><sect1><sect2><para>
3007 #: ../en/ch02-tour-merge.xml:267
3008 msgid ""
3009 "There are <emphasis>many</emphasis> file merging tools available, too many to "
3010 "cover here. They vary in which platforms they are available for, and in "
3011 "their particular strengths and weaknesses. Most are tuned for merging files "
3012 "containing plain text, while a few are aimed at specialised file formats "
3013 "(generally XML)."
3014 msgstr ""
3016 #. type: Content of: <book><chapter><sect1><sect2><title>
3017 #: ../en/ch02-tour-merge.xml:276
3018 msgid "A worked example"
3019 msgstr "合并实例"
3021 #. type: Content of: <book><chapter><sect1><sect2><para>
3022 #: ../en/ch02-tour-merge.xml:278
3023 msgid ""
3024 "In this example, we will reproduce the file modification history of figure "
3025 "<xref endterm=\"fig.tour-merge.conflict.caption\" linkend=\"fig.tour-merge."
3026 "conflict\"/> above. Let's begin by creating a repository with a base version "
3027 "of our document."
3028 msgstr ""
3030 #. type: Content of: <book><chapter><sect1><sect2><para>
3031 #: ../en/ch02-tour-merge.xml:286
3032 msgid "We'll clone the repository and make a change to the file."
3033 msgstr ""
3035 #. type: Content of: <book><chapter><sect1><sect2><para>
3036 #: ../en/ch02-tour-merge.xml:291
3037 msgid ""
3038 "And another clone, to simulate someone else making a change to the file. "
3039 "(This hints at the idea that it's not all that unusual to merge with yourself "
3040 "when you isolate tasks in separate repositories, and indeed to find and "
3041 "resolve conflicts while doing so.)"
3042 msgstr ""
3044 #. type: Content of: <book><chapter><sect1><sect2><para>
3045 #: ../en/ch02-tour-merge.xml:299
3046 msgid ""
3047 "Having created two different versions of the file, we'll set up an "
3048 "environment suitable for running our merge."
3049 msgstr ""
3051 #. type: Content of: <book><chapter><sect1><sect2><para>
3052 #: ../en/ch02-tour-merge.xml:305
3053 msgid ""
3054 "In this example, I won't use Mercurial's normal <command>hgmerge</command> "
3055 "program to do the merge, because it would drop my nice automated example-"
3056 "running tool into a graphical user interface. Instead, I'll set "
3057 "<envar>HGMERGE</envar> to tell Mercurial to use the non-interactive "
3058 "<command>merge</command> command. This is bundled with many Unix-like "
3059 "systems. If you're following this example on your computer, don't bother "
3060 "setting <envar>HGMERGE</envar>."
3061 msgstr ""
3063 #. type: Content of: <book><chapter><sect1><sect2><para>
3064 #: ../en/ch02-tour-merge.xml:315
3065 msgid "<emphasis role=\"bold\">XXX FIX THIS EXAMPLE.</emphasis>"
3066 msgstr ""
3068 #. type: Content of: <book><chapter><sect1><sect2><para>
3069 #: ../en/ch02-tour-merge.xml:320
3070 msgid ""
3071 "Because <command>merge</command> can't resolve the conflicting changes, it "
3072 "leaves <emphasis>merge markers</emphasis> inside the file that has conflicts, "
3073 "indicating which lines have conflicts, and whether they came from our version "
3074 "of the file or theirs."
3075 msgstr ""
3077 #. type: Content of: <book><chapter><sect1><sect2><para>
3078 #: ../en/ch02-tour-merge.xml:326
3079 msgid ""
3080 "Mercurial can tell from the way <command>merge</command> exits that it wasn't "
3081 "able to merge successfully, so it tells us what commands we'll need to run if "
3082 "we want to redo the merging operation. This could be useful if, for example, "
3083 "we were running a graphical merge tool and quit because we were confused or "
3084 "realised we had made a mistake."
3085 msgstr ""
3087 #. type: Content of: <book><chapter><sect1><sect2><para>
3088 #: ../en/ch02-tour-merge.xml:333
3089 msgid ""
3090 "If automatic or manual merges fail, there's nothing to prevent us from "
3091 "<quote>fixing up</quote> the affected files ourselves, and committing the "
3092 "results of our merge:"
3093 msgstr ""
3095 #. type: Content of: <book><chapter><sect1><title>
3096 #: ../en/ch02-tour-merge.xml:342
3097 msgid "Simplifying the pull-merge-commit sequence"
3098 msgstr "简化拉-合并-提交程序"
3100 #. type: Content of: <book><chapter><sect1><para>
3101 #: ../en/ch02-tour-merge.xml:344
3102 msgid ""
3103 "The process of merging changes as outlined above is straightforward, but "
3104 "requires running three commands in sequence."
3105 msgstr ""
3107 #. type: Content of: <book><chapter><sect1><para>
3108 #: ../en/ch02-tour-merge.xml:350
3109 msgid ""
3110 "In the case of the final commit, you also need to enter a commit message, "
3111 "which is almost always going to be a piece of uninteresting "
3112 "<quote>boilerplate</quote> text."
3113 msgstr ""
3115 #. type: Content of: <book><chapter><sect1><para>
3116 #: ../en/ch02-tour-merge.xml:354
3117 msgid ""
3118 "It would be nice to reduce the number of steps needed, if this were "
3119 "possible. Indeed, Mercurial is distributed with an extension called <literal "
3120 "role=\"hg-ext\">fetch</literal> that does just this."
3121 msgstr ""
3123 #. type: Content of: <book><chapter><sect1><para>
3124 #: ../en/ch02-tour-merge.xml:359
3125 msgid ""
3126 "Mercurial provides a flexible extension mechanism that lets people extend its "
3127 "functionality, while keeping the core of Mercurial small and easy to deal "
3128 "with. Some extensions add new commands that you can use from the command "
3129 "line, while others work <quote>behind the scenes,</quote> for example adding "
3130 "capabilities to the server."
3131 msgstr ""
3133 #. type: Content of: <book><chapter><sect1><para>
3134 #: ../en/ch02-tour-merge.xml:366
3135 msgid ""
3136 "The <literal role=\"hg-ext\">fetch</literal> extension adds a new command "
3137 "called, not surprisingly, <command role=\"hg-cmd\">hg fetch</command>. This "
3138 "extension acts as a combination of <command role=\"hg-cmd\">hg pull</"
3139 "command>, <command role=\"hg-cmd\">hg update</command> and <command role=\"hg-"
3140 "cmd\">hg merge</command>. It begins by pulling changes from another "
3141 "repository into the current repository. If it finds that the changes added a "
3142 "new head to the repository, it begins a merge, then commits the result of the "
3143 "merge with an automatically-generated commit message. If no new heads were "
3144 "added, it updates the working directory to the new tip changeset."
3145 msgstr ""
3147 #. type: Content of: <book><chapter><sect1><para>
3148 #: ../en/ch02-tour-merge.xml:379
3149 msgid ""
3150 "Enabling the <literal role=\"hg-ext\">fetch</literal> extension is easy. "
3151 "Edit your <filename role=\"special\">.hgrc</filename>, and either go to the "
3152 "<literal role=\"rc-extensions\">extensions</literal> section or create an "
3153 "<literal role=\"rc-extensions\">extensions</literal> section. Then add a line "
3154 "that simply reads <quote><literal>fetch </literal></quote>."
3155 msgstr ""
3157 #. type: Content of: <book><chapter><sect1><para>
3158 #: ../en/ch02-tour-merge.xml:388
3159 msgid ""
3160 "(Normally, on the right-hand side of the <quote><literal>=</literal></quote> "
3161 "would appear the location of the extension, but since the <literal role=\"hg-"
3162 "ext\">fetch</literal> extension is in the standard distribution, Mercurial "
3163 "knows where to search for it.)"
3164 msgstr ""
3166 #. type: Content of: <book><chapter><title>
3167 #: ../en/ch03-concepts.xml:5
3168 msgid "Behind the scenes"
3169 msgstr "Mercurial 内幕"
3171 #. type: Content of: <book><chapter><para>
3172 #: ../en/ch03-concepts.xml:7
3173 msgid ""
3174 "Unlike many revision control systems, the concepts upon which Mercurial is "
3175 "built are simple enough that it's easy to understand how the software really "
3176 "works. Knowing this certainly isn't necessary, but I find it useful to have "
3177 "a <quote>mental model</quote> of what's going on."
3178 msgstr ""
3180 #. type: Content of: <book><chapter><para>
3181 #: ../en/ch03-concepts.xml:13
3182 msgid ""
3183 "This understanding gives me confidence that Mercurial has been carefully "
3184 "designed to be both <emphasis>safe</emphasis> and <emphasis>efficient</"
3185 "emphasis>. And just as importantly, if it's easy for me to retain a good "
3186 "idea of what the software is doing when I perform a revision control task, "
3187 "I'm less likely to be surprised by its behaviour."
3188 msgstr ""
3190 #. type: Content of: <book><chapter><para>
3191 #: ../en/ch03-concepts.xml:20
3192 msgid ""
3193 "In this chapter, we'll initially cover the core concepts behind Mercurial's "
3194 "design, then continue to discuss some of the interesting details of its "
3195 "implementation."
3196 msgstr ""
3198 #. type: Content of: <book><chapter><sect1><title>
3199 #: ../en/ch03-concepts.xml:25
3200 msgid "Mercurial's historical record"
3201 msgstr "Mercurial 的历史记录"
3203 #. type: Content of: <book><chapter><sect1><sect2><title>
3204 #: ../en/ch03-concepts.xml:28
3205 msgid "Tracking the history of a single file"
3206 msgstr "跟踪单一文件的历史"
3208 #. type: Content of: <book><chapter><sect1><sect2><para>
3209 #: ../en/ch03-concepts.xml:30
3210 msgid ""
3211 "When Mercurial tracks modifications to a file, it stores the history of that "
3212 "file in a metadata object called a <emphasis>filelog</emphasis>. Each entry "
3213 "in the filelog contains enough information to reconstruct one revision of the "
3214 "file that is being tracked. Filelogs are stored as files in the <filename "
3215 "role=\"special\" class=\"directory\">.hg/store/data</filename> directory. A "
3216 "filelog contains two kinds of information: revision data, and an index to "
3217 "help Mercurial to find a revision efficiently."
3218 msgstr ""
3220 #. type: Content of: <book><chapter><sect1><sect2><para>
3221 #: ../en/ch03-concepts.xml:41
3222 msgid ""
3223 "A file that is large, or has a lot of history, has its filelog stored in "
3224 "separate data (<quote><literal>.d</literal></quote> suffix) and index "
3225 "(<quote><literal>.i</literal></quote> suffix) files. For small files without "
3226 "much history, the revision data and index are combined in a single "
3227 "<quote><literal>.i</literal></quote> file. The correspondence between a file "
3228 "in the working directory and the filelog that tracks its history in the "
3229 "repository is illustrated in figure <xref endterm=\"fig.concepts.filelog."
3230 "caption\" linkend=\"fig.concepts.filelog\"/>."
3231 msgstr ""
3233 #. type: Content of: <book><chapter><sect1><sect2><informalfigure><mediaobject>
3234 #: ../en/ch03-concepts.xml:55
3235 msgid "<imageobject><imagedata fileref=\"images/filelog.png\"/></imageobject>"
3236 msgstr ""
3238 #. type: Content of: <book><chapter><sect1><sect2><informalfigure><mediaobject><caption><para>
3239 #: ../en/ch03-concepts.xml:57
3240 msgid ""
3241 "Relationships between files in working directory and filelogs in repository"
3242 msgstr ""
3244 #. type: Content of: <book><chapter><sect1><sect2><title>
3245 #: ../en/ch03-concepts.xml:65
3246 msgid "Managing tracked files"
3247 msgstr "管理跟踪的文件"
3249 #. type: Content of: <book><chapter><sect1><sect2><para>
3250 #: ../en/ch03-concepts.xml:67
3251 msgid ""
3252 "Mercurial uses a structure called a <emphasis>manifest</emphasis> to collect "
3253 "together information about the files that it tracks. Each entry in the "
3254 "manifest contains information about the files present in a single changeset. "
3255 "An entry records which files are present in the changeset, the revision of "
3256 "each file, and a few other pieces of file metadata."
3257 msgstr ""
3259 #. type: Content of: <book><chapter><sect1><sect2><title>
3260 #: ../en/ch03-concepts.xml:77
3261 msgid "Recording changeset information"
3262 msgstr "记录修改集信息"
3264 #. type: Content of: <book><chapter><sect1><sect2><para>
3265 #: ../en/ch03-concepts.xml:79
3266 msgid ""
3267 "The <emphasis>changelog</emphasis> contains information about each "
3268 "changeset. Each revision records who committed a change, the changeset "
3269 "comment, other pieces of changeset-related information, and the revision of "
3270 "the manifest to use."
3271 msgstr ""
3273 #. type: Content of: <book><chapter><sect1><sect2><title>
3274 #: ../en/ch03-concepts.xml:87
3275 msgid "Relationships between revisions"
3276 msgstr "版本之间的关系"
3278 #. type: Content of: <book><chapter><sect1><sect2><para>
3279 #: ../en/ch03-concepts.xml:89
3280 msgid ""
3281 "Within a changelog, a manifest, or a filelog, each revision stores a pointer "
3282 "to its immediate parent (or to its two parents, if it's a merge revision). "
3283 "As I mentioned above, there are also relationships between revisions "
3284 "<emphasis>across</emphasis> these structures, and they are hierarchical in "
3285 "nature."
3286 msgstr ""
3288 #. type: Content of: <book><chapter><sect1><sect2><para>
3289 #: ../en/ch03-concepts.xml:96
3290 msgid ""
3291 "For every changeset in a repository, there is exactly one revision stored in "
3292 "the changelog. Each revision of the changelog contains a pointer to a single "
3293 "revision of the manifest. A revision of the manifest stores a pointer to a "
3294 "single revision of each filelog tracked when that changeset was created. "
3295 "These relationships are illustrated in figure <xref endterm=\"fig.concepts."
3296 "metadata.caption\" linkend=\"fig.concepts.metadata\"/>."
3297 msgstr ""
3299 #. type: Content of: <book><chapter><sect1><sect2><informalfigure><mediaobject>
3300 #: ../en/ch03-concepts.xml:107
3301 msgid "<imageobject><imagedata fileref=\"images/metadata.png\"/></imageobject>"
3302 msgstr ""
3304 #. type: Content of: <book><chapter><sect1><sect2><informalfigure><mediaobject><caption><para>
3305 #: ../en/ch03-concepts.xml:109
3306 msgid "Metadata relationships"
3307 msgstr ""
3309 #. type: Content of: <book><chapter><sect1><sect2><para>
3310 #: ../en/ch03-concepts.xml:114
3311 msgid ""
3312 "As the illustration shows, there is <emphasis>not</emphasis> a <quote>one to "
3313 "one</quote> relationship between revisions in the changelog, manifest, or "
3314 "filelog. If the manifest hasn't changed between two changesets, the changelog "
3315 "entries for those changesets will point to the same revision of the "
3316 "manifest. If a file that Mercurial tracks hasn't changed between two "
3317 "changesets, the entry for that file in the two revisions of the manifest will "
3318 "point to the same revision of its filelog."
3319 msgstr ""
3321 #. type: Content of: <book><chapter><sect1><title>
3322 #: ../en/ch03-concepts.xml:127
3323 msgid "Safe, efficient storage"
3324 msgstr "安全,高效的存储"
3326 #. type: Content of: <book><chapter><sect1><para>
3327 #: ../en/ch03-concepts.xml:129
3328 msgid ""
3329 "The underpinnings of changelogs, manifests, and filelogs are provided by a "
3330 "single structure called the <emphasis>revlog</emphasis>."
3331 msgstr ""
3333 #. type: Content of: <book><chapter><sect1><sect2><title>
3334 #: ../en/ch03-concepts.xml:134
3335 msgid "Efficient storage"
3336 msgstr "高效存储"
3338 #. type: Content of: <book><chapter><sect1><sect2><para>
3339 #: ../en/ch03-concepts.xml:136
3340 msgid ""
3341 "The revlog provides efficient storage of revisions using a <emphasis>delta</"
3342 "emphasis> mechanism. Instead of storing a complete copy of a file for each "
3343 "revision, it stores the changes needed to transform an older revision into "
3344 "the new revision. For many kinds of file data, these deltas are typically a "
3345 "fraction of a percent of the size of a full copy of a file."
3346 msgstr ""
3348 #. type: Content of: <book><chapter><sect1><sect2><para>
3349 #: ../en/ch03-concepts.xml:144
3350 msgid ""
3351 "Some obsolete revision control systems can only work with deltas of text "
3352 "files. They must either store binary files as complete snapshots or encoded "
3353 "into a text representation, both of which are wasteful approaches. Mercurial "
3354 "can efficiently handle deltas of files with arbitrary binary contents; it "
3355 "doesn't need to treat text as special."
3356 msgstr ""
3358 #. type: Content of: <book><chapter><sect1><sect2><title>
3359 #: ../en/ch03-concepts.xml:153
3360 msgid "Safe operation"
3361 msgstr "安全操作"
3363 #. type: Content of: <book><chapter><sect1><sect2><para>
3364 #: ../en/ch03-concepts.xml:155
3365 msgid ""
3366 "Mercurial only ever <emphasis>appends</emphasis> data to the end of a revlog "
3367 "file. It never modifies a section of a file after it has written it. This is "
3368 "both more robust and efficient than schemes that need to modify or rewrite "
3369 "data."
3370 msgstr ""
3372 #. type: Content of: <book><chapter><sect1><sect2><para>
3373 #: ../en/ch03-concepts.xml:161
3374 msgid ""
3375 "In addition, Mercurial treats every write as part of a <emphasis>transaction</"
3376 "emphasis> that can span a number of files. A transaction is "
3377 "<emphasis>atomic</emphasis>: either the entire transaction succeeds and its "
3378 "effects are all visible to readers in one go, or the whole thing is undone. "
3379 "This guarantee of atomicity means that if you're running two copies of "
3380 "Mercurial, where one is reading data and one is writing it, the reader will "
3381 "never see a partially written result that might confuse it."
3382 msgstr ""
3384 #. type: Content of: <book><chapter><sect1><sect2><para>
3385 #: ../en/ch03-concepts.xml:171
3386 msgid ""
3387 "The fact that Mercurial only appends to files makes it easier to provide this "
3388 "transactional guarantee. The easier it is to do stuff like this, the more "
3389 "confident you should be that it's done correctly."
3390 msgstr ""
3392 #. type: Content of: <book><chapter><sect1><sect2><title>
3393 #: ../en/ch03-concepts.xml:178
3394 msgid "Fast retrieval"
3395 msgstr "快速检索"
3397 #. type: Content of: <book><chapter><sect1><sect2><para>
3398 #: ../en/ch03-concepts.xml:180
3399 msgid ""
3400 "Mercurial cleverly avoids a pitfall common to all earlier revision control "
3401 "systems: the problem of <emphasis>inefficient retrieval</emphasis>. Most "
3402 "revision control systems store the contents of a revision as an incremental "
3403 "series of modifications against a <quote>snapshot</quote>. To reconstruct a "
3404 "specific revision, you must first read the snapshot, and then every one of "
3405 "the revisions between the snapshot and your target revision. The more "
3406 "history that a file accumulates, the more revisions you must read, hence the "
3407 "longer it takes to reconstruct a particular revision."
3408 msgstr ""
3410 #. type: Content of: <book><chapter><sect1><sect2><informalfigure><mediaobject>
3411 #: ../en/ch03-concepts.xml:193
3412 msgid "<imageobject><imagedata fileref=\"images/snapshot.png\"/></imageobject>"
3413 msgstr ""
3415 #. type: Content of: <book><chapter><sect1><sect2><informalfigure><mediaobject><caption><para>
3416 #: ../en/ch03-concepts.xml:195
3417 msgid "Snapshot of a revlog, with incremental deltas"
3418 msgstr ""
3420 #. type: Content of: <book><chapter><sect1><sect2><para>
3421 #: ../en/ch03-concepts.xml:200
3422 msgid ""
3423 "The innovation that Mercurial applies to this problem is simple but "
3424 "effective. Once the cumulative amount of delta information stored since the "
3425 "last snapshot exceeds a fixed threshold, it stores a new snapshot "
3426 "(compressed, of course), instead of another delta. This makes it possible to "
3427 "reconstruct <emphasis>any</emphasis> revision of a file quickly. This "
3428 "approach works so well that it has since been copied by several other "
3429 "revision control systems."
3430 msgstr ""
3432 #. type: Content of: <book><chapter><sect1><sect2><para>
3433 #: ../en/ch03-concepts.xml:209
3434 msgid ""
3435 "Figure <xref endterm=\"fig.concepts.snapshot.caption\" linkend=\"fig.concepts."
3436 "snapshot\"/> illustrates the idea. In an entry in a revlog's index file, "
3437 "Mercurial stores the range of entries from the data file that it must read to "
3438 "reconstruct a particular revision."
3439 msgstr ""
3441 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
3442 #: ../en/ch03-concepts.xml:216
3443 msgid "Aside: the influence of video compression"
3444 msgstr ""
3446 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
3447 #: ../en/ch03-concepts.xml:218
3448 msgid ""
3449 "If you're familiar with video compression or have ever watched a TV feed "
3450 "through a digital cable or satellite service, you may know that most video "
3451 "compression schemes store each frame of video as a delta against its "
3452 "predecessor frame. In addition, these schemes use <quote>lossy</quote> "
3453 "compression techniques to increase the compression ratio, so visual errors "
3454 "accumulate over the course of a number of inter-frame deltas."
3455 msgstr ""
3457 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
3458 #: ../en/ch03-concepts.xml:227
3459 msgid ""
3460 "Because it's possible for a video stream to <quote>drop out</quote> "
3461 "occasionally due to signal glitches, and to limit the accumulation of "
3462 "artefacts introduced by the lossy compression process, video encoders "
3463 "periodically insert a complete frame (called a <quote>key frame</quote>) into "
3464 "the video stream; the next delta is generated against that frame. This means "
3465 "that if the video signal gets interrupted, it will resume once the next key "
3466 "frame is received. Also, the accumulation of encoding errors restarts anew "
3467 "with each key frame."
3468 msgstr ""
3470 #. type: Content of: <book><chapter><sect1><sect2><title>
3471 #: ../en/ch03-concepts.xml:241
3472 msgid "Identification and strong integrity"
3473 msgstr "鉴别和强完整性"
3475 #. type: Content of: <book><chapter><sect1><sect2><para>
3476 #: ../en/ch03-concepts.xml:243
3477 msgid ""
3478 "Along with delta or snapshot information, a revlog entry contains a "
3479 "cryptographic hash of the data that it represents. This makes it difficult "
3480 "to forge the contents of a revision, and easy to detect accidental corruption."
3481 msgstr ""
3483 #. type: Content of: <book><chapter><sect1><sect2><para>
3484 #: ../en/ch03-concepts.xml:248
3485 msgid ""
3486 "Hashes provide more than a mere check against corruption; they are used as "
3487 "the identifiers for revisions. The changeset identification hashes that you "
3488 "see as an end user are from revisions of the changelog. Although filelogs "
3489 "and the manifest also use hashes, Mercurial only uses these behind the scenes."
3490 msgstr ""
3492 #. type: Content of: <book><chapter><sect1><sect2><para>
3493 #: ../en/ch03-concepts.xml:255
3494 msgid ""
3495 "Mercurial verifies that hashes are correct when it retrieves file revisions "
3496 "and when it pulls changes from another repository. If it encounters an "
3497 "integrity problem, it will complain and stop whatever it's doing."
3498 msgstr ""
3500 #. type: Content of: <book><chapter><sect1><sect2><para>
3501 #: ../en/ch03-concepts.xml:260
3502 msgid ""
3503 "In addition to the effect it has on retrieval efficiency, Mercurial's use of "
3504 "periodic snapshots makes it more robust against partial data corruption. If "
3505 "a revlog becomes partly corrupted due to a hardware error or system bug, it's "
3506 "often possible to reconstruct some or most revisions from the uncorrupted "
3507 "sections of the revlog, both before and after the corrupted section. This "
3508 "would not be possible with a delta-only storage model."
3509 msgstr ""
3511 #. type: Content of: <book><chapter><sect1><title>
3512 #: ../en/ch03-concepts.xml:272
3513 msgid "Revision history, branching, and merging"
3514 msgstr "修订历史,分支与合并"
3516 #. type: Content of: <book><chapter><sect1><para>
3517 #: ../en/ch03-concepts.xml:274
3518 msgid ""
3519 "Every entry in a Mercurial revlog knows the identity of its immediate "
3520 "ancestor revision, usually referred to as its <emphasis>parent</emphasis>. "
3521 "In fact, a revision contains room for not one parent, but two. Mercurial "
3522 "uses a special hash, called the <quote>null ID</quote>, to represent the idea "
3523 "<quote>there is no parent here</quote>. This hash is simply a string of "
3524 "zeroes."
3525 msgstr ""
3527 #. type: Content of: <book><chapter><sect1><para>
3528 #: ../en/ch03-concepts.xml:282
3529 msgid ""
3530 "In figure <xref endterm=\"fig.concepts.revlog.caption\" linkend=\"fig."
3531 "concepts.revlog\"/>, you can see an example of the conceptual structure of a "
3532 "revlog. Filelogs, manifests, and changelogs all have this same structure; "
3533 "they differ only in the kind of data stored in each delta or snapshot."
3534 msgstr ""
3536 #. type: Content of: <book><chapter><sect1><para>
3537 #: ../en/ch03-concepts.xml:289
3538 msgid ""
3539 "The first revision in a revlog (at the bottom of the image) has the null ID "
3540 "in both of its parent slots. For a <quote>normal</quote> revision, its first "
3541 "parent slot contains the ID of its parent revision, and its second contains "
3542 "the null ID, indicating that the revision has only one real parent. Any two "
3543 "revisions that have the same parent ID are branches. A revision that "
3544 "represents a merge between branches has two normal revision IDs in its parent "
3545 "slots."
3546 msgstr ""
3548 #. type: Content of: <book><chapter><sect1><informalfigure><mediaobject>
3549 #: ../en/ch03-concepts.xml:300
3550 msgid "<imageobject><imagedata fileref=\"images/revlog.png\"/></imageobject>"
3551 msgstr ""
3553 #. type: Content of: <book><chapter><sect1><informalfigure><mediaobject><caption><para>
3554 #: ../en/ch03-concepts.xml:302
3555 msgid "Revision in revlog"
3556 msgstr ""
3558 #. type: Content of: <book><chapter><sect1><title>
3559 #: ../en/ch03-concepts.xml:309
3560 msgid "The working directory"
3561 msgstr "工作目录"
3563 #. type: Content of: <book><chapter><sect1><para>
3564 #: ../en/ch03-concepts.xml:311
3565 msgid ""
3566 "In the working directory, Mercurial stores a snapshot of the files from the "
3567 "repository as of a particular changeset."
3568 msgstr ""
3570 #. type: Content of: <book><chapter><sect1><para>
3571 #: ../en/ch03-concepts.xml:314
3572 msgid ""
3573 "The working directory <quote>knows</quote> which changeset it contains. When "
3574 "you update the working directory to contain a particular changeset, Mercurial "
3575 "looks up the appropriate revision of the manifest to find out which files it "
3576 "was tracking at the time that changeset was committed, and which revision of "
3577 "each file was then current. It then recreates a copy of each of those files, "
3578 "with the same contents it had when the changeset was committed."
3579 msgstr ""
3581 #. type: Content of: <book><chapter><sect1><para>
3582 #: ../en/ch03-concepts.xml:323
3583 msgid ""
3584 "The <emphasis>dirstate</emphasis> contains Mercurial's knowledge of the "
3585 "working directory. This details which changeset the working directory is "
3586 "updated to, and all of the files that Mercurial is tracking in the working "
3587 "directory."
3588 msgstr ""
3590 #. type: Content of: <book><chapter><sect1><para>
3591 #: ../en/ch03-concepts.xml:329
3592 msgid ""
3593 "Just as a revision of a revlog has room for two parents, so that it can "
3594 "represent either a normal revision (with one parent) or a merge of two "
3595 "earlier revisions, the dirstate has slots for two parents. When you use the "
3596 "<command role=\"hg-cmd\">hg update</command> command, the changeset that you "
3597 "update to is stored in the <quote>first parent</quote> slot, and the null ID "
3598 "in the second. When you <command role=\"hg-cmd\">hg merge</command> with "
3599 "another changeset, the first parent remains unchanged, and the second parent "
3600 "is filled in with the changeset you're merging with. The <command role=\"hg-"
3601 "cmd\">hg parents</command> command tells you what the parents of the dirstate "
3602 "are."
3603 msgstr ""
3605 #. type: Content of: <book><chapter><sect1><sect2><title>
3606 #: ../en/ch03-concepts.xml:343
3607 msgid "What happens when you commit"
3608 msgstr "当你提交时发生的事情"
3610 #. type: Content of: <book><chapter><sect1><sect2><para>
3611 #: ../en/ch03-concepts.xml:345
3612 msgid ""
3613 "The dirstate stores parent information for more than just book-keeping "
3614 "purposes. Mercurial uses the parents of the dirstate as <emphasis>the "
3615 "parents of a new changeset</emphasis> when you perform a commit."
3616 msgstr ""
3618 #. type: Content of: <book><chapter><sect1><sect2><informalfigure><mediaobject>
3619 #: ../en/ch03-concepts.xml:352
3620 msgid "<imageobject><imagedata fileref=\"images/wdir.png\"/></imageobject>"
3621 msgstr ""
3623 #. type: Content of: <book><chapter><sect1><sect2><informalfigure><mediaobject><caption><para>
3624 #: ../en/ch03-concepts.xml:354
3625 msgid "The working directory can have two parents"
3626 msgstr ""
3628 #. type: Content of: <book><chapter><sect1><sect2><para>
3629 #: ../en/ch03-concepts.xml:359
3630 msgid ""
3631 "Figure <xref endterm=\"fig.concepts.wdir.caption\" linkend=\"fig.concepts.wdir"
3632 "\"/> shows the normal state of the working directory, where it has a single "
3633 "changeset as parent. That changeset is the <emphasis>tip</emphasis>, the "
3634 "newest changeset in the repository that has no children."
3635 msgstr ""
3637 #. type: Content of: <book><chapter><sect1><sect2><informalfigure><mediaobject>
3638 #: ../en/ch03-concepts.xml:368
3639 msgid ""
3640 "<imageobject><imagedata fileref=\"images/wdir-after-commit.png\"/> </"
3641 "imageobject>"
3642 msgstr ""
3644 #. type: Content of: <book><chapter><sect1><sect2><informalfigure><mediaobject><caption><para>
3645 #: ../en/ch03-concepts.xml:371
3646 msgid "The working directory gains new parents after a commit"
3647 msgstr ""
3649 #. type: Content of: <book><chapter><sect1><sect2><para>
3650 #: ../en/ch03-concepts.xml:376
3651 msgid ""
3652 "It's useful to think of the working directory as <quote>the changeset I'm "
3653 "about to commit</quote>. Any files that you tell Mercurial that you've "
3654 "added, removed, renamed, or copied will be reflected in that changeset, as "
3655 "will modifications to any files that Mercurial is already tracking; the new "
3656 "changeset will have the parents of the working directory as its parents."
3657 msgstr ""
3659 #. type: Content of: <book><chapter><sect1><sect2><para>
3660 #: ../en/ch03-concepts.xml:384
3661 msgid ""
3662 "After a commit, Mercurial will update the parents of the working directory, "
3663 "so that the first parent is the ID of the new changeset, and the second is "
3664 "the null ID. This is shown in figure <xref endterm=\"fig.concepts.wdir-after-"
3665 "commit.caption\" linkend=\"fig.concepts.wdir-after-commit\"/>. Mercurial "
3666 "doesn't touch any of the files in the working directory when you commit; it "
3667 "just modifies the dirstate to note its new parents."
3668 msgstr ""
3670 #. type: Content of: <book><chapter><sect1><sect2><title>
3671 #: ../en/ch03-concepts.xml:396
3672 msgid "Creating a new head"
3673 msgstr "创建新顶点"
3675 #. type: Content of: <book><chapter><sect1><sect2><para>
3676 #: ../en/ch03-concepts.xml:398
3677 msgid ""
3678 "It's perfectly normal to update the working directory to a changeset other "
3679 "than the current tip. For example, you might want to know what your project "
3680 "looked like last Tuesday, or you could be looking through changesets to see "
3681 "which one introduced a bug. In cases like this, the natural thing to do is "
3682 "update the working directory to the changeset you're interested in, and then "
3683 "examine the files in the working directory directly to see their contents as "
3684 "they were when you committed that changeset. The effect of this is shown in "
3685 "figure <xref endterm=\"fig.concepts.wdir-pre-branch.caption\" linkend=\"fig."
3686 "concepts.wdir-pre-branch\"/>."
3687 msgstr ""
3689 #. type: Content of: <book><chapter><sect1><sect2><informalfigure><mediaobject>
3690 #: ../en/ch03-concepts.xml:412
3691 msgid ""
3692 "<imageobject><imagedata fileref=\"images/wdir-pre-branch.png\"/> </"
3693 "imageobject>"
3694 msgstr ""
3696 #. type: Content of: <book><chapter><sect1><sect2><informalfigure><mediaobject><caption><para>
3697 #: ../en/ch03-concepts.xml:415
3698 msgid "The working directory, updated to an older changeset"
3699 msgstr ""
3701 #. type: Content of: <book><chapter><sect1><sect2><para>
3702 #: ../en/ch03-concepts.xml:420
3703 msgid ""
3704 "Having updated the working directory to an older changeset, what happens if "
3705 "you make some changes, and then commit? Mercurial behaves in the same way as "
3706 "I outlined above. The parents of the working directory become the parents of "
3707 "the new changeset. This new changeset has no children, so it becomes the new "
3708 "tip. And the repository now contains two changesets that have no children; "
3709 "we call these <emphasis>heads</emphasis>. You can see the structure that "
3710 "this creates in figure <xref endterm=\"fig.concepts.wdir-branch.caption\" "
3711 "linkend=\"fig.concepts.wdir-branch\"/>."
3712 msgstr ""
3714 #. type: Content of: <book><chapter><sect1><sect2><informalfigure><mediaobject>
3715 #: ../en/ch03-concepts.xml:434
3716 msgid ""
3717 "<imageobject><imagedata fileref=\"images/wdir-branch.png\"/> </imageobject>"
3718 msgstr ""
3720 #. type: Content of: <book><chapter><sect1><sect2><informalfigure><mediaobject><caption><para>
3721 #: ../en/ch03-concepts.xml:437
3722 msgid "After a commit made while synced to an older changeset"
3723 msgstr ""
3725 #. type: Content of: <book><chapter><sect1><sect2><note><para>
3726 #: ../en/ch03-concepts.xml:443
3727 msgid ""
3728 "If you're new to Mercurial, you should keep in mind a common <quote>error</"
3729 "quote>, which is to use the <command role=\"hg-cmd\">hg pull</command> "
3730 "command without any options. By default, the <command role=\"hg-cmd\">hg "
3731 "pull</command> command <emphasis>does not</emphasis> update the working "
3732 "directory, so you'll bring new changesets into your repository, but the "
3733 "working directory will stay synced at the same changeset as before the pull. "
3734 "If you make some changes and commit afterwards, you'll thus create a new "
3735 "head, because your working directory isn't synced to whatever the current tip "
3736 "is."
3737 msgstr ""
3739 #. type: Content of: <book><chapter><sect1><sect2><note><para>
3740 #: ../en/ch03-concepts.xml:455
3741 msgid ""
3742 "I put the word <quote>error</quote> in quotes because all that you need to do "
3743 "to rectify this situation is <command role=\"hg-cmd\">hg merge</command>, "
3744 "then <command role=\"hg-cmd\">hg commit</command>. In other words, this "
3745 "almost never has negative consequences; it just surprises people. I'll "
3746 "discuss other ways to avoid this behaviour, and why Mercurial behaves in this "
3747 "initially surprising way, later on."
3748 msgstr ""
3750 #. type: Content of: <book><chapter><sect1><sect2><title>
3751 #: ../en/ch03-concepts.xml:467
3752 msgid "Merging heads"
3753 msgstr "合并顶点"
3755 #. type: Content of: <book><chapter><sect1><sect2><para>
3756 #: ../en/ch03-concepts.xml:469
3757 msgid ""
3758 "When you run the <command role=\"hg-cmd\">hg merge</command> command, "
3759 "Mercurial leaves the first parent of the working directory unchanged, and "
3760 "sets the second parent to the changeset you're merging with, as shown in "
3761 "figure <xref endterm=\"fig.concepts.wdir-merge.caption\" linkend=\"fig."
3762 "concepts.wdir-merge\"/>."
3763 msgstr ""
3765 #. type: Content of: <book><chapter><sect1><sect2><informalfigure><mediaobject>
3766 #: ../en/ch03-concepts.xml:478
3767 msgid ""
3768 "<imageobject><imagedata fileref=\"images/wdir-merge.png\"/> </imageobject>"
3769 msgstr ""
3771 #. type: Content of: <book><chapter><sect1><sect2><informalfigure><mediaobject><caption><para>
3772 #: ../en/ch03-concepts.xml:481
3773 msgid "Merging two heads"
3774 msgstr ""
3776 #. type: Content of: <book><chapter><sect1><sect2><para>
3777 #: ../en/ch03-concepts.xml:486
3778 msgid ""
3779 "Mercurial also has to modify the working directory, to merge the files "
3780 "managed in the two changesets. Simplified a little, the merging process goes "
3781 "like this, for every file in the manifests of both changesets."
3782 msgstr ""
3784 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
3785 #: ../en/ch03-concepts.xml:491
3786 msgid "If neither changeset has modified a file, do nothing with that file."
3787 msgstr ""
3789 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
3790 #: ../en/ch03-concepts.xml:494
3791 msgid ""
3792 "If one changeset has modified a file, and the other hasn't, create the "
3793 "modified copy of the file in the working directory."
3794 msgstr ""
3796 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
3797 #: ../en/ch03-concepts.xml:498
3798 msgid ""
3799 "If one changeset has removed a file, and the other hasn't (or has also "
3800 "deleted it), delete the file from the working directory."
3801 msgstr ""
3803 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
3804 #: ../en/ch03-concepts.xml:502
3805 msgid ""
3806 "If one changeset has removed a file, but the other has modified the file, ask "
3807 "the user what to do: keep the modified file, or remove it?"
3808 msgstr ""
3810 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
3811 #: ../en/ch03-concepts.xml:506
3812 msgid ""
3813 "If both changesets have modified a file, invoke an external merge program to "
3814 "choose the new contents for the merged file. This may require input from the "
3815 "user."
3816 msgstr ""
3818 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
3819 #: ../en/ch03-concepts.xml:511
3820 msgid ""
3821 "If one changeset has modified a file, and the other has renamed or copied the "
3822 "file, make sure that the changes follow the new name of the file."
3823 msgstr ""
3825 #. type: Content of: <book><chapter><sect1><sect2><para>
3826 #: ../en/ch03-concepts.xml:515
3827 msgid ""
3828 "There are more details&emdash;merging has plenty of corner cases&emdash;but "
3829 "these are the most common choices that are involved in a merge. As you can "
3830 "see, most cases are completely automatic, and indeed most merges finish "
3831 "automatically, without requiring your input to resolve any conflicts."
3832 msgstr ""
3834 #. type: Content of: <book><chapter><sect1><sect2><para>
3835 #: ../en/ch03-concepts.xml:522
3836 msgid ""
3837 "When you're thinking about what happens when you commit after a merge, once "
3838 "again the working directory is <quote>the changeset I'm about to commit</"
3839 "quote>. After the <command role=\"hg-cmd\">hg merge</command> command "
3840 "completes, the working directory has two parents; these will become the "
3841 "parents of the new changeset."
3842 msgstr ""
3844 #. type: Content of: <book><chapter><sect1><sect2><para>
3845 #: ../en/ch03-concepts.xml:529
3846 msgid ""
3847 "Mercurial lets you perform multiple merges, but you must commit the results "
3848 "of each individual merge as you go. This is necessary because Mercurial only "
3849 "tracks two parents for both revisions and the working directory. While it "
3850 "would be technically possible to merge multiple changesets at once, the "
3851 "prospect of user confusion and making a terrible mess of a merge immediately "
3852 "becomes overwhelming."
3853 msgstr ""
3855 #. type: Content of: <book><chapter><sect1><title>
3856 #: ../en/ch03-concepts.xml:540
3857 msgid "Other interesting design features"
3858 msgstr "其它有趣的设计特性"
3860 #. type: Content of: <book><chapter><sect1><para>
3861 #: ../en/ch03-concepts.xml:542
3862 msgid ""
3863 "In the sections above, I've tried to highlight some of the most important "
3864 "aspects of Mercurial's design, to illustrate that it pays careful attention "
3865 "to reliability and performance. However, the attention to detail doesn't "
3866 "stop there. There are a number of other aspects of Mercurial's construction "
3867 "that I personally find interesting. I'll detail a few of them here, separate "
3868 "from the <quote>big ticket</quote> items above, so that if you're interested, "
3869 "you can gain a better idea of the amount of thinking that goes into a well-"
3870 "designed system."
3871 msgstr ""
3873 #. type: Content of: <book><chapter><sect1><sect2><title>
3874 #: ../en/ch03-concepts.xml:553
3875 msgid "Clever compression"
3876 msgstr "智能压缩"
3878 #. type: Content of: <book><chapter><sect1><sect2><para>
3879 #: ../en/ch03-concepts.xml:555
3880 msgid ""
3881 "When appropriate, Mercurial will store both snapshots and deltas in "
3882 "compressed form. It does this by always <emphasis>trying to</emphasis> "
3883 "compress a snapshot or delta, but only storing the compressed version if it's "
3884 "smaller than the uncompressed version."
3885 msgstr ""
3887 #. type: Content of: <book><chapter><sect1><sect2><para>
3888 #: ../en/ch03-concepts.xml:561
3889 msgid ""
3890 "This means that Mercurial does <quote>the right thing</quote> when storing a "
3891 "file whose native form is compressed, such as a <literal>zip</literal> "
3892 "archive or a JPEG image. When these types of files are compressed a second "
3893 "time, the resulting file is usually bigger than the once-compressed form, and "
3894 "so Mercurial will store the plain <literal>zip</literal> or JPEG."
3895 msgstr ""
3897 #. type: Content of: <book><chapter><sect1><sect2><para>
3898 #: ../en/ch03-concepts.xml:569
3899 msgid ""
3900 "Deltas between revisions of a compressed file are usually larger than "
3901 "snapshots of the file, and Mercurial again does <quote>the right thing</"
3902 "quote> in these cases. It finds that such a delta exceeds the threshold at "
3903 "which it should store a complete snapshot of the file, so it stores the "
3904 "snapshot, again saving space compared to a naive delta-only approach."
3905 msgstr ""
3907 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
3908 #: ../en/ch03-concepts.xml:578
3909 msgid "Network recompression"
3910 msgstr "网络重新压缩"
3912 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
3913 #: ../en/ch03-concepts.xml:580
3914 msgid ""
3915 "When storing revisions on disk, Mercurial uses the <quote>deflate</quote> "
3916 "compression algorithm (the same one used by the popular <literal>zip</"
3917 "literal> archive format), which balances good speed with a respectable "
3918 "compression ratio. However, when transmitting revision data over a network "
3919 "connection, Mercurial uncompresses the compressed revision data."
3920 msgstr ""
3922 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
3923 #: ../en/ch03-concepts.xml:588
3924 msgid ""
3925 "If the connection is over HTTP, Mercurial recompresses the entire stream of "
3926 "data using a compression algorithm that gives a better compression ratio (the "
3927 "Burrows-Wheeler algorithm from the widely used <literal>bzip2</literal> "
3928 "compression package). This combination of algorithm and compression of the "
3929 "entire stream (instead of a revision at a time) substantially reduces the "
3930 "number of bytes to be transferred, yielding better network performance over "
3931 "almost all kinds of network."
3932 msgstr ""
3934 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
3935 #: ../en/ch03-concepts.xml:598
3936 msgid ""
3937 "(If the connection is over <command>ssh</command>, Mercurial "
3938 "<emphasis>doesn't</emphasis> recompress the stream, because <command>ssh</"
3939 "command> can already do this itself.)"
3940 msgstr ""
3942 #. type: Content of: <book><chapter><sect1><sect2><title>
3943 #: ../en/ch03-concepts.xml:606
3944 msgid "Read/write ordering and atomicity"
3945 msgstr "读写顺序与原子性"
3947 #. type: Content of: <book><chapter><sect1><sect2><para>
3948 #: ../en/ch03-concepts.xml:608
3949 msgid ""
3950 "Appending to files isn't the whole story when it comes to guaranteeing that a "
3951 "reader won't see a partial write. If you recall figure <xref endterm=\"fig."
3952 "concepts.metadata.caption\" linkend=\"fig.concepts.metadata\"/>, revisions in "
3953 "the changelog point to revisions in the manifest, and revisions in the "
3954 "manifest point to revisions in filelogs. This hierarchy is deliberate."
3955 msgstr ""
3957 #. type: Content of: <book><chapter><sect1><sect2><para>
3958 #: ../en/ch03-concepts.xml:616
3959 msgid ""
3960 "A writer starts a transaction by writing filelog and manifest data, and "
3961 "doesn't write any changelog data until those are finished. A reader starts "
3962 "by reading changelog data, then manifest data, followed by filelog data."
3963 msgstr ""
3965 #. type: Content of: <book><chapter><sect1><sect2><para>
3966 #: ../en/ch03-concepts.xml:621
3967 msgid ""
3968 "Since the writer has always finished writing filelog and manifest data before "
3969 "it writes to the changelog, a reader will never read a pointer to a partially "
3970 "written manifest revision from the changelog, and it will never read a "
3971 "pointer to a partially written filelog revision from the manifest."
3972 msgstr ""
3974 #. type: Content of: <book><chapter><sect1><sect2><title>
3975 #: ../en/ch03-concepts.xml:629
3976 msgid "Concurrent access"
3977 msgstr "并发访问"
3979 #. type: Content of: <book><chapter><sect1><sect2><para>
3980 #: ../en/ch03-concepts.xml:631
3981 msgid ""
3982 "The read/write ordering and atomicity guarantees mean that Mercurial never "
3983 "needs to <emphasis>lock</emphasis> a repository when it's reading data, even "
3984 "if the repository is being written to while the read is occurring. This has a "
3985 "big effect on scalability; you can have an arbitrary number of Mercurial "
3986 "processes safely reading data from a repository safely all at once, no matter "
3987 "whether it's being written to or not."
3988 msgstr ""
3990 #. type: Content of: <book><chapter><sect1><sect2><para>
3991 #: ../en/ch03-concepts.xml:640
3992 msgid ""
3993 "The lockless nature of reading means that if you're sharing a repository on a "
3994 "multi-user system, you don't need to grant other local users permission to "
3995 "<emphasis>write</emphasis> to your repository in order for them to be able to "
3996 "clone it or pull changes from it; they only need <emphasis>read</emphasis> "
3997 "permission. (This is <emphasis>not</emphasis> a common feature among "
3998 "revision control systems, so don't take it for granted! Most require readers "
3999 "to be able to lock a repository to access it safely, and this requires write "
4000 "permission on at least one directory, which of course makes for all kinds of "
4001 "nasty and annoying security and administrative problems.)"
4002 msgstr ""
4004 #. type: Content of: <book><chapter><sect1><sect2><para>
4005 #: ../en/ch03-concepts.xml:653
4006 msgid ""
4007 "Mercurial uses locks to ensure that only one process can write to a "
4008 "repository at a time (the locking mechanism is safe even over filesystems "
4009 "that are notoriously hostile to locking, such as NFS). If a repository is "
4010 "locked, a writer will wait for a while to retry if the repository becomes "
4011 "unlocked, but if the repository remains locked for too long, the process "
4012 "attempting to write will time out after a while. This means that your daily "
4013 "automated scripts won't get stuck forever and pile up if a system crashes "
4014 "unnoticed, for example. (Yes, the timeout is configurable, from zero to "
4015 "infinity.)"
4016 msgstr ""
4018 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
4019 #: ../en/ch03-concepts.xml:665
4020 msgid "Safe dirstate access"
4021 msgstr "安全的目录状态访问"
4023 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
4024 #: ../en/ch03-concepts.xml:667
4025 msgid ""
4026 "As with revision data, Mercurial doesn't take a lock to read the dirstate "
4027 "file; it does acquire a lock to write it. To avoid the possibility of "
4028 "reading a partially written copy of the dirstate file, Mercurial writes to a "
4029 "file with a unique name in the same directory as the dirstate file, then "
4030 "renames the temporary file atomically to <filename>dirstate</filename>. The "
4031 "file named <filename>dirstate</filename> is thus guaranteed to be complete, "
4032 "not partially written."
4033 msgstr ""
4035 #. type: Content of: <book><chapter><sect1><sect2><title>
4036 #: ../en/ch03-concepts.xml:680
4037 msgid "Avoiding seeks"
4038 msgstr "避免查找"
4040 #. type: Content of: <book><chapter><sect1><sect2><para>
4041 #: ../en/ch03-concepts.xml:682
4042 msgid ""
4043 "Critical to Mercurial's performance is the avoidance of seeks of the disk "
4044 "head, since any seek is far more expensive than even a comparatively large "
4045 "read operation."
4046 msgstr ""
4048 #. type: Content of: <book><chapter><sect1><sect2><para>
4049 #: ../en/ch03-concepts.xml:686
4050 msgid ""
4051 "This is why, for example, the dirstate is stored in a single file. If there "
4052 "were a dirstate file per directory that Mercurial tracked, the disk would "
4053 "seek once per directory. Instead, Mercurial reads the entire single dirstate "
4054 "file in one step."
4055 msgstr ""
4057 #. type: Content of: <book><chapter><sect1><sect2><para>
4058 #: ../en/ch03-concepts.xml:692
4059 msgid ""
4060 "Mercurial also uses a <quote>copy on write</quote> scheme when cloning a "
4061 "repository on local storage. Instead of copying every revlog file from the "
4062 "old repository into the new repository, it makes a <quote>hard link</quote>, "
4063 "which is a shorthand way to say <quote>these two names point to the same "
4064 "file</quote>. When Mercurial is about to write to one of a revlog's files, "
4065 "it checks to see if the number of names pointing at the file is greater than "
4066 "one. If it is, more than one repository is using the file, so Mercurial "
4067 "makes a new copy of the file that is private to this repository."
4068 msgstr ""
4070 #. type: Content of: <book><chapter><sect1><sect2><para>
4071 #: ../en/ch03-concepts.xml:703
4072 msgid ""
4073 "A few revision control developers have pointed out that this idea of making a "
4074 "complete private copy of a file is not very efficient in its use of storage. "
4075 "While this is true, storage is cheap, and this method gives the highest "
4076 "performance while deferring most book-keeping to the operating system. An "
4077 "alternative scheme would most likely reduce performance and increase the "
4078 "complexity of the software, each of which is much more important to the "
4079 "<quote>feel</quote> of day-to-day use."
4080 msgstr ""
4082 #. type: Content of: <book><chapter><sect1><sect2><title>
4083 #: ../en/ch03-concepts.xml:715
4084 msgid "Other contents of the dirstate"
4085 msgstr "目录状态的其它内容"
4087 #. type: Content of: <book><chapter><sect1><sect2><para>
4088 #: ../en/ch03-concepts.xml:717
4089 msgid ""
4090 "Because Mercurial doesn't force you to tell it when you're modifying a file, "
4091 "it uses the dirstate to store some extra information so it can determine "
4092 "efficiently whether you have modified a file. For each file in the working "
4093 "directory, it stores the time that it last modified the file itself, and the "
4094 "size of the file at that time."
4095 msgstr ""
4097 #. type: Content of: <book><chapter><sect1><sect2><para>
4098 #: ../en/ch03-concepts.xml:724
4099 msgid ""
4100 "When you explicitly <command role=\"hg-cmd\">hg add</command>, <command role="
4101 "\"hg-cmd\">hg remove</command>, <command role=\"hg-cmd\">hg rename</command> "
4102 "or <command role=\"hg-cmd\">hg copy</command> files, Mercurial updates the "
4103 "dirstate so that it knows what to do with those files when you commit."
4104 msgstr ""
4106 #. type: Content of: <book><chapter><sect1><sect2><para>
4107 #: ../en/ch03-concepts.xml:731
4108 msgid ""
4109 "When Mercurial is checking the states of files in the working directory, it "
4110 "first checks a file's modification time. If that has not changed, the file "
4111 "must not have been modified. If the file's size has changed, the file must "
4112 "have been modified. If the modification time has changed, but the size has "
4113 "not, only then does Mercurial need to read the actual contents of the file to "
4114 "see if they've changed. Storing these few extra pieces of information "
4115 "dramatically reduces the amount of data that Mercurial needs to read, which "
4116 "yields large performance improvements compared to other revision control "
4117 "systems."
4118 msgstr ""
4120 #. type: Content of: <book><chapter><title>
4121 #: ../en/ch04-daily.xml:5
4122 msgid "Mercurial in daily use"
4123 msgstr "Mercurial 的日常使用"
4125 #. type: Content of: <book><chapter><sect1><title>
4126 #: ../en/ch04-daily.xml:8
4127 msgid "Telling Mercurial which files to track"
4128 msgstr "告诉 Mercurial 要跟踪哪些文件"
4130 #. type: Content of: <book><chapter><sect1><para>
4131 #: ../en/ch04-daily.xml:10
4132 msgid ""
4133 "Mercurial does not work with files in your repository unless you tell it to "
4134 "manage them. The <command role=\"hg-cmd\">hg status</command> command will "
4135 "tell you which files Mercurial doesn't know about; it uses a <quote><literal>?"
4136 "</literal></quote> to display such files."
4137 msgstr ""
4140 #. type: Content of: <book><chapter><sect1><para>
4141 #: ../en/ch04-daily.xml:17
4142 msgid ""
4143 "To tell Mercurial to track a file, use the <command role=\"hg-cmd\">hg add</"
4144 "command> command. Once you have added a file, the entry in the output of "
4145 "<command role=\"hg-cmd\">hg status</command> for that file changes from "
4146 "<quote><literal>?</literal></quote> to <quote><literal>A</literal></quote>."
4147 msgstr ""
4149 #. type: Content of: <book><chapter><sect1><para>
4150 #: ../en/ch04-daily.xml:26
4151 msgid ""
4152 "After you run a <command role=\"hg-cmd\">hg commit</command>, the files that "
4153 "you added before the commit will no longer be listed in the output of "
4154 "<command role=\"hg-cmd\">hg status</command>. The reason for this is that "
4155 "<command role=\"hg-cmd\">hg status</command> only tells you about "
4156 "<quote>interesting</quote> files&emdash;those that you have modified or told "
4157 "Mercurial to do something with&emdash;by default. If you have a repository "
4158 "that contains thousands of files, you will rarely want to know about files "
4159 "that Mercurial is tracking, but that have not changed. (You can still get "
4160 "this information; we'll return to this later.)"
4161 msgstr ""
4163 #. type: Content of: <book><chapter><sect1><para>
4164 #: ../en/ch04-daily.xml:38
4165 msgid ""
4166 "Once you add a file, Mercurial doesn't do anything with it immediately. "
4167 "Instead, it will take a snapshot of the file's state the next time you "
4168 "perform a commit. It will then continue to track the changes you make to the "
4169 "file every time you commit, until you remove the file."
4170 msgstr ""
4172 #. type: Content of: <book><chapter><sect1><sect2><title>
4173 #: ../en/ch04-daily.xml:45
4174 msgid "Explicit versus implicit file naming"
4175 msgstr "明确与隐含文件命名"
4177 #. type: Content of: <book><chapter><sect1><sect2><para>
4178 #: ../en/ch04-daily.xml:47
4179 msgid ""
4180 "A useful behaviour that Mercurial has is that if you pass the name of a "
4181 "directory to a command, every Mercurial command will treat this as <quote>I "
4182 "want to operate on every file in this directory and its subdirectories</"
4183 "quote>."
4184 msgstr ""
4186 #. type: Content of: <book><chapter><sect1><sect2><para>
4187 #: ../en/ch04-daily.xml:54
4188 msgid ""
4189 "Notice in this example that Mercurial printed the names of the files it "
4190 "added, whereas it didn't do so when we added the file named <filename>a</"
4191 "filename> in the earlier example."
4192 msgstr ""
4194 #. type: Content of: <book><chapter><sect1><sect2><para>
4195 #: ../en/ch04-daily.xml:59
4196 msgid ""
4197 "What's going on is that in the former case, we explicitly named the file to "
4198 "add on the command line, so the assumption that Mercurial makes in such cases "
4199 "is that you know what you were doing, and it doesn't print any output."
4200 msgstr ""
4202 #. type: Content of: <book><chapter><sect1><sect2><para>
4203 #: ../en/ch04-daily.xml:64
4204 msgid ""
4205 "However, when we <emphasis>imply</emphasis> the names of files by giving the "
4206 "name of a directory, Mercurial takes the extra step of printing the name of "
4207 "each file that it does something with. This makes it more clear what is "
4208 "happening, and reduces the likelihood of a silent and nasty surprise. This "
4209 "behaviour is common to most Mercurial commands."
4210 msgstr ""
4212 #. type: Content of: <book><chapter><sect1><sect2><title>
4213 #: ../en/ch04-daily.xml:73
4214 msgid "Aside: Mercurial tracks files, not directories"
4215 msgstr "旁白: Mercurial 只跟踪文件,不跟踪目录"
4217 #. type: Content of: <book><chapter><sect1><sect2><para>
4218 #: ../en/ch04-daily.xml:75
4219 msgid ""
4220 "Mercurial does not track directory information. Instead, it tracks the path "
4221 "to a file. Before creating a file, it first creates any missing directory "
4222 "components of the path. After it deletes a file, it then deletes any empty "
4223 "directories that were in the deleted file's path. This sounds like a trivial "
4224 "distinction, but it has one minor practical consequence: it is not possible "
4225 "to represent a completely empty directory in Mercurial."
4226 msgstr ""
4228 #. type: Content of: <book><chapter><sect1><sect2><para>
4229 #: ../en/ch04-daily.xml:84
4230 msgid ""
4231 "Empty directories are rarely useful, and there are unintrusive workarounds "
4232 "that you can use to achieve an appropriate effect. The developers of "
4233 "Mercurial thus felt that the complexity that would be required to manage "
4234 "empty directories was not worth the limited benefit this feature would bring."
4235 msgstr ""
4237 #. type: Content of: <book><chapter><sect1><sect2><para>
4238 #: ../en/ch04-daily.xml:91
4239 msgid ""
4240 "If you need an empty directory in your repository, there are a few ways to "
4241 "achieve this. One is to create a directory, then <command role=\"hg-cmd\">hg "
4242 "add</command> a <quote>hidden</quote> file to that directory. On Unix-like "
4243 "systems, any file name that begins with a period (<quote><literal>.</"
4244 "literal></quote>) is treated as hidden by most commands and GUI tools. This "
4245 "approach is illustrated below."
4246 msgstr ""
4248 #. type: Content of: <book><chapter><sect1><sect2><para>
4249 #: ../en/ch04-daily.xml:102
4250 msgid ""
4251 "Another way to tackle a need for an empty directory is to simply create one "
4252 "in your automated build scripts before they will need it."
4253 msgstr ""
4255 #. type: Content of: <book><chapter><sect1><title>
4256 #: ../en/ch04-daily.xml:109
4257 msgid "How to stop tracking a file"
4258 msgstr "如何停止跟踪文件"
4261 #. type: Content of: <book><chapter><sect1><para>
4262 #: ../en/ch04-daily.xml:111
4263 msgid ""
4264 "Once you decide that a file no longer belongs in your repository, use the "
4265 "<command role=\"hg-cmd\">hg remove</command> command; this deletes the file, "
4266 "and tells Mercurial to stop tracking it. A removed file is represented in "
4267 "the output of <command role=\"hg-cmd\">hg status</command> with a "
4268 "<quote><literal>R</literal></quote>."
4269 msgstr ""
4271 #. type: Content of: <book><chapter><sect1><para>
4272 #: ../en/ch04-daily.xml:120
4273 msgid ""
4274 "After you <command role=\"hg-cmd\">hg remove</command> a file, Mercurial will "
4275 "no longer track changes to that file, even if you recreate a file with the "
4276 "same name in your working directory. If you do recreate a file with the same "
4277 "name and want Mercurial to track the new file, simply <command role=\"hg-cmd"
4278 "\">hg add</command> it. Mercurial will know that the newly added file is not "
4279 "related to the old file of the same name."
4280 msgstr ""
4282 #. type: Content of: <book><chapter><sect1><sect2><title>
4283 #: ../en/ch04-daily.xml:129
4284 msgid "Removing a file does not affect its history"
4285 msgstr "删除文件不影响历史"
4287 #. type: Content of: <book><chapter><sect1><sect2><para>
4288 #: ../en/ch04-daily.xml:131
4289 msgid "It is important to understand that removing a file has only two effects."
4290 msgstr ""
4292 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
4293 #: ../en/ch04-daily.xml:134
4294 msgid "It removes the current version of the file from the working directory."
4295 msgstr ""
4297 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
4298 #: ../en/ch04-daily.xml:137
4299 msgid ""
4300 "It stops Mercurial from tracking changes to the file, from the time of the "
4301 "next commit."
4302 msgstr ""
4304 #. type: Content of: <book><chapter><sect1><sect2><para>
4305 #: ../en/ch04-daily.xml:140
4306 msgid ""
4307 "Removing a file <emphasis>does not</emphasis> in any way alter the "
4308 "<emphasis>history</emphasis> of the file."
4309 msgstr ""
4311 #. type: Content of: <book><chapter><sect1><sect2><para>
4312 #: ../en/ch04-daily.xml:143
4313 msgid ""
4314 "If you update the working directory to a changeset in which a file that you "
4315 "have removed was still tracked, it will reappear in the working directory, "
4316 "with the contents it had when you committed that changeset. If you then "
4317 "update the working directory to a later changeset, in which the file had been "
4318 "removed, Mercurial will once again remove the file from the working directory."
4319 msgstr ""
4321 #. type: Content of: <book><chapter><sect1><sect2><title>
4322 #: ../en/ch04-daily.xml:153
4323 msgid "Missing files"
4324 msgstr "丢失的文件"
4326 #. type: Content of: <book><chapter><sect1><sect2><para>
4327 #: ../en/ch04-daily.xml:155
4328 msgid ""
4329 "Mercurial considers a file that you have deleted, but not used <command role="
4330 "\"hg-cmd\">hg remove</command> to delete, to be <emphasis>missing</"
4331 "emphasis>. A missing file is represented with <quote><literal>!</literal></"
4332 "quote> in the output of <command role=\"hg-cmd\">hg status</command>. "
4333 "Mercurial commands will not generally do anything with missing files."
4334 msgstr ""
4336 #. type: Content of: <book><chapter><sect1><sect2><para>
4337 #: ../en/ch04-daily.xml:165
4338 msgid ""
4339 "If your repository contains a file that <command role=\"hg-cmd\">hg status</"
4340 "command> reports as missing, and you want the file to stay gone, you can run "
4341 "<command role=\"hg-cmd\">hg remove <option role=\"hg-opt-remove\">--after</"
4342 "option></command> at any time later on, to tell Mercurial that you really did "
4343 "mean to remove the file."
4344 msgstr ""
4346 #. type: Content of: <book><chapter><sect1><sect2><para>
4347 #: ../en/ch04-daily.xml:175
4348 msgid ""
4349 "On the other hand, if you deleted the missing file by accident, give <command "
4350 "role=\"hg-cmd\">hg revert</command> the name of the file to recover. It will "
4351 "reappear, in unmodified form."
4352 msgstr ""
4354 #. type: Content of: <book><chapter><sect1><sect2><title>
4355 #: ../en/ch04-daily.xml:184
4356 msgid "Aside: why tell Mercurial explicitly to remove a file?"
4357 msgstr "旁白: 为什么要明确告诉 Mercurial 删除文件?"
4359 #. type: Content of: <book><chapter><sect1><sect2><para>
4360 #: ../en/ch04-daily.xml:187
4361 msgid ""
4362 "You might wonder why Mercurial requires you to explicitly tell it that you "
4363 "are deleting a file. Early during the development of Mercurial, it let you "
4364 "delete a file however you pleased; Mercurial would notice the absence of the "
4365 "file automatically when you next ran a <command role=\"hg-cmd\">hg commit</"
4366 "command>, and stop tracking the file. In practice, this made it too easy to "
4367 "accidentally remove a file without noticing."
4368 msgstr ""
4370 #. type: Content of: <book><chapter><sect1><sect2><title>
4371 #: ../en/ch04-daily.xml:198
4372 msgid "Useful shorthand&emdash;adding and removing files in one step"
4373 msgstr "有用的速记&emdash;一个步骤添加和删除文件"
4375 #. type: Content of: <book><chapter><sect1><sect2><para>
4376 #: ../en/ch04-daily.xml:201
4377 msgid ""
4378 "Mercurial offers a combination command, <command role=\"hg-cmd\">hg "
4379 "addremove</command>, that adds untracked files and marks missing files as "
4380 "removed."
4381 msgstr ""
4383 #. type: Content of: <book><chapter><sect1><sect2><para>
4384 #: ../en/ch04-daily.xml:207
4385 msgid ""
4386 "The <command role=\"hg-cmd\">hg commit</command> command also provides a "
4387 "<option role=\"hg-opt-commit\">-A</option> option that performs this same add-"
4388 "and-remove, immediately followed by a commit."
4389 msgstr ""
4391 #. type: Content of: <book><chapter><sect1><title>
4392 #: ../en/ch04-daily.xml:217
4393 msgid "Copying files"
4394 msgstr "复制文件"
4396 #. type: Content of: <book><chapter><sect1><para>
4397 #: ../en/ch04-daily.xml:219
4398 msgid ""
4399 "Mercurial provides a <command role=\"hg-cmd\">hg copy</command> command that "
4400 "lets you make a new copy of a file. When you copy a file using this command, "
4401 "Mercurial makes a record of the fact that the new file is a copy of the "
4402 "original file. It treats these copied files specially when you merge your "
4403 "work with someone else's."
4404 msgstr ""
4406 #. type: Content of: <book><chapter><sect1><sect2><title>
4407 #: ../en/ch04-daily.xml:227
4408 msgid "The results of copying during a merge"
4409 msgstr "合并期间的复制结果"
4411 #. type: Content of: <book><chapter><sect1><sect2><para>
4412 #: ../en/ch04-daily.xml:229
4413 msgid ""
4414 "What happens during a merge is that changes <quote>follow</quote> a copy. To "
4415 "best illustrate what this means, let's create an example. We'll start with "
4416 "the usual tiny repository that contains a single file."
4417 msgstr ""
4419 #. type: Content of: <book><chapter><sect1><sect2><para>
4420 #: ../en/ch04-daily.xml:236
4421 msgid ""
4422 "We need to do some work in parallel, so that we'll have something to merge. "
4423 "So let's clone our repository."
4424 msgstr ""
4426 #. type: Content of: <book><chapter><sect1><sect2><para>
4427 #: ../en/ch04-daily.xml:242
4428 msgid ""
4429 "Back in our initial repository, let's use the <command role=\"hg-cmd\">hg "
4430 "copy</command> command to make a copy of the first file we created."
4431 msgstr ""
4433 #. type: Content of: <book><chapter><sect1><sect2><para>
4434 #: ../en/ch04-daily.xml:248
4435 msgid ""
4436 "If we look at the output of the <command role=\"hg-cmd\">hg status</command> "
4437 "command afterwards, the copied file looks just like a normal added file."
4438 msgstr ""
4440 #. type: Content of: <book><chapter><sect1><sect2><para>
4441 #: ../en/ch04-daily.xml:254
4442 msgid ""
4443 "But if we pass the <option role=\"hg-opt-status\">-C</option> option to "
4444 "<command role=\"hg-cmd\">hg status</command>, it prints another line of "
4445 "output: this is the file that our newly-added file was copied <emphasis>from</"
4446 "emphasis>."
4447 msgstr ""
4449 #. type: Content of: <book><chapter><sect1><sect2><para>
4450 #: ../en/ch04-daily.xml:262
4451 msgid ""
4452 "Now, back in the repository we cloned, let's make a change in parallel. "
4453 "We'll add a line of content to the original file that we created."
4454 msgstr ""
4456 #. type: Content of: <book><chapter><sect1><sect2><para>
4457 #: ../en/ch04-daily.xml:268
4458 msgid ""
4459 "Now we have a modified <filename>file</filename> in this repository. When we "
4460 "pull the changes from the first repository, and merge the two heads, "
4461 "Mercurial will propagate the changes that we made locally to <filename>file</"
4462 "filename> into its copy, <filename>new-file</filename>."
4463 msgstr ""
4465 #. type: Content of: <book><chapter><sect1><sect2><title>
4466 #: ../en/ch04-daily.xml:278
4467 msgid "Why should changes follow copies?"
4468 msgstr "为什么复制后需要后续修改?"
4470 #. type: Content of: <book><chapter><sect1><sect2><para>
4471 #: ../en/ch04-daily.xml:280
4472 msgid ""
4473 "This behaviour, of changes to a file propagating out to copies of the file, "
4474 "might seem esoteric, but in most cases it's highly desirable."
4475 msgstr ""
4477 #. type: Content of: <book><chapter><sect1><sect2><para>
4478 #: ../en/ch04-daily.xml:284
4479 msgid ""
4480 "First of all, remember that this propagation <emphasis>only</emphasis> "
4481 "happens when you merge. So if you <command role=\"hg-cmd\">hg copy</command> "
4482 "a file, and subsequently modify the original file during the normal course of "
4483 "your work, nothing will happen."
4484 msgstr ""
4486 #. type: Content of: <book><chapter><sect1><sect2><para>
4487 #: ../en/ch04-daily.xml:290
4488 msgid ""
4489 "The second thing to know is that modifications will only propagate across a "
4490 "copy as long as the repository that you're pulling changes from "
4491 "<emphasis>doesn't know</emphasis> about the copy."
4492 msgstr ""
4494 #. type: Content of: <book><chapter><sect1><sect2><para>
4495 #: ../en/ch04-daily.xml:295
4496 msgid ""
4497 "The reason that Mercurial does this is as follows. Let's say I make an "
4498 "important bug fix in a source file, and commit my changes. Meanwhile, you've "
4499 "decided to <command role=\"hg-cmd\">hg copy</command> the file in your "
4500 "repository, without knowing about the bug or having seen the fix, and you "
4501 "have started hacking on your copy of the file."
4502 msgstr ""
4504 #. type: Content of: <book><chapter><sect1><sect2><para>
4505 #: ../en/ch04-daily.xml:302
4506 msgid ""
4507 "If you pulled and merged my changes, and Mercurial <emphasis>didn't</"
4508 "emphasis> propagate changes across copies, your source file would now contain "
4509 "the bug, and unless you remembered to propagate the bug fix by hand, the bug "
4510 "would <emphasis>remain</emphasis> in your copy of the file."
4511 msgstr ""
4513 #. type: Content of: <book><chapter><sect1><sect2><para>
4514 #: ../en/ch04-daily.xml:308
4515 msgid ""
4516 "By automatically propagating the change that fixed the bug from the original "
4517 "file to the copy, Mercurial prevents this class of problem. To my knowledge, "
4518 "Mercurial is the <emphasis>only</emphasis> revision control system that "
4519 "propagates changes across copies like this."
4520 msgstr ""
4522 #. type: Content of: <book><chapter><sect1><sect2><para>
4523 #: ../en/ch04-daily.xml:314
4524 msgid ""
4525 "Once your change history has a record that the copy and subsequent merge "
4526 "occurred, there's usually no further need to propagate changes from the "
4527 "original file to the copied file, and that's why Mercurial only propagates "
4528 "changes across copies until this point, and no further."
4529 msgstr ""
4531 #. type: Content of: <book><chapter><sect1><sect2><title>
4532 #: ../en/ch04-daily.xml:322
4533 msgid "How to make changes <emphasis>not</emphasis> follow a copy"
4534 msgstr "如何让复制后<emphasis>不</emphasis>修改?"
4536 #. type: Content of: <book><chapter><sect1><sect2><para>
4537 #: ../en/ch04-daily.xml:325
4538 msgid ""
4539 "If, for some reason, you decide that this business of automatically "
4540 "propagating changes across copies is not for you, simply use your system's "
4541 "normal file copy command (on Unix-like systems, that's <command>cp</command>) "
4542 "to make a copy of a file, then <command role=\"hg-cmd\">hg add</command> the "
4543 "new copy by hand. Before you do so, though, please do reread section <xref "
4544 "linkend=\"sec.daily.why-copy\"/>, and make an informed decision that this "
4545 "behaviour is not appropriate to your specific case."
4546 msgstr ""
4548 #. type: Content of: <book><chapter><sect1><sect2><title>
4549 #: ../en/ch04-daily.xml:338
4550 msgid "Behaviour of the <command role=\"hg-cmd\">hg copy</command> command"
4551 msgstr "命令 <command role=\"hg-cmd\">hg copy</command> 的特性"
4553 #. type: Content of: <book><chapter><sect1><sect2><para>
4554 #: ../en/ch04-daily.xml:341
4555 msgid ""
4556 "When you use the <command role=\"hg-cmd\">hg copy</command> command, "
4557 "Mercurial makes a copy of each source file as it currently stands in the "
4558 "working directory. This means that if you make some modifications to a file, "
4559 "then <command role=\"hg-cmd\">hg copy</command> it without first having "
4560 "committed those changes, the new copy will also contain the modifications you "
4561 "have made up until that point. (I find this behaviour a little "
4562 "counterintuitive, which is why I mention it here.)"
4563 msgstr ""
4565 #. type: Content of: <book><chapter><sect1><sect2><para>
4566 #: ../en/ch04-daily.xml:351
4567 msgid ""
4568 "The <command role=\"hg-cmd\">hg copy</command> command acts similarly to the "
4569 "Unix <command>cp</command> command (you can use the <command role=\"hg-cmd"
4570 "\">hg cp</command> alias if you prefer). The last argument is the "
4571 "<emphasis>destination</emphasis>, and all prior arguments are "
4572 "<emphasis>sources</emphasis>. If you pass it a single file as the source, "
4573 "and the destination does not exist, it creates a new file with that name."
4574 msgstr ""
4576 #. type: Content of: <book><chapter><sect1><sect2><para>
4577 #: ../en/ch04-daily.xml:362
4578 msgid ""
4579 "If the destination is a directory, Mercurial copies its sources into that "
4580 "directory."
4581 msgstr ""
4583 #. type: Content of: <book><chapter><sect1><sect2><para>
4584 #: ../en/ch04-daily.xml:367
4585 msgid ""
4586 "Copying a directory is recursive, and preserves the directory structure of "
4587 "the source."
4588 msgstr ""
4590 #. type: Content of: <book><chapter><sect1><sect2><para>
4591 #: ../en/ch04-daily.xml:373
4592 msgid ""
4593 "If the source and destination are both directories, the source tree is "
4594 "recreated in the destination directory."
4595 msgstr ""
4598 #. type: Content of: <book><chapter><sect1><sect2><para>
4599 #: ../en/ch04-daily.xml:378
4600 msgid ""
4601 "As with the <command role=\"hg-cmd\">hg rename</command> command, if you copy "
4602 "a file manually and then want Mercurial to know that you've copied the file, "
4603 "simply use the <option role=\"hg-opt-copy\">--after</option> option to "
4604 "<command role=\"hg-cmd\">hg copy</command>."
4605 msgstr ""
4607 #. type: Content of: <book><chapter><sect1><title>
4608 #: ../en/ch04-daily.xml:389
4609 msgid "Renaming files"
4610 msgstr "改名文件"
4612 #. type: Content of: <book><chapter><sect1><para>
4613 #: ../en/ch04-daily.xml:391
4614 msgid ""
4615 "It's rather more common to need to rename a file than to make a copy of it. "
4616 "The reason I discussed the <command role=\"hg-cmd\">hg copy</command> command "
4617 "before talking about renaming files is that Mercurial treats a rename in "
4618 "essentially the same way as a copy. Therefore, knowing what Mercurial does "
4619 "when you copy a file tells you what to expect when you rename a file."
4620 msgstr ""
4622 #. type: Content of: <book><chapter><sect1><para>
4623 #: ../en/ch04-daily.xml:399
4624 msgid ""
4625 "When you use the <command role=\"hg-cmd\">hg rename</command> command, "
4626 "Mercurial makes a copy of each source file, then deletes it and marks the "
4627 "file as removed."
4628 msgstr ""
4630 #. type: Content of: <book><chapter><sect1><para>
4631 #: ../en/ch04-daily.xml:405
4632 msgid ""
4633 "The <command role=\"hg-cmd\">hg status</command> command shows the newly "
4634 "copied file as added, and the copied-from file as removed."
4635 msgstr ""
4637 #. type: Content of: <book><chapter><sect1><para>
4638 #: ../en/ch04-daily.xml:411
4639 msgid ""
4640 "As with the results of a <command role=\"hg-cmd\">hg copy</command>, we must "
4641 "use the <option role=\"hg-opt-status\">-C</option> option to <command role="
4642 "\"hg-cmd\">hg status</command> to see that the added file is really being "
4643 "tracked by Mercurial as a copy of the original, now removed, file."
4644 msgstr ""
4646 #. type: Content of: <book><chapter><sect1><para>
4647 #: ../en/ch04-daily.xml:420
4648 msgid ""
4649 "As with <command role=\"hg-cmd\">hg remove</command> and <command role=\"hg-"
4650 "cmd\">hg copy</command>, you can tell Mercurial about a rename after the fact "
4651 "using the <option role=\"hg-opt-rename\">--after</option> option. In most "
4652 "other respects, the behaviour of the <command role=\"hg-cmd\">hg rename</"
4653 "command> command, and the options it accepts, are similar to the <command "
4654 "role=\"hg-cmd\">hg copy</command> command."
4655 msgstr ""
4657 #. type: Content of: <book><chapter><sect1><sect2><title>
4658 #: ../en/ch04-daily.xml:430
4659 msgid "Renaming files and merging changes"
4660 msgstr "改名文件与合并修改"
4662 #. type: Content of: <book><chapter><sect1><sect2><para>
4663 #: ../en/ch04-daily.xml:432
4664 msgid ""
4665 "Since Mercurial's rename is implemented as copy-and-remove, the same "
4666 "propagation of changes happens when you merge after a rename as after a copy."
4667 msgstr ""
4669 #. type: Content of: <book><chapter><sect1><sect2><para>
4670 #: ../en/ch04-daily.xml:436
4671 msgid ""
4672 "If I modify a file, and you rename it to a new name, and then we merge our "
4673 "respective changes, my modifications to the file under its original name will "
4674 "be propagated into the file under its new name. (This is something you might "
4675 "expect to <quote>simply work,</quote> but not all revision control systems "
4676 "actually do this.)"
4677 msgstr ""
4679 #. type: Content of: <book><chapter><sect1><sect2><para>
4680 #: ../en/ch04-daily.xml:443
4681 msgid ""
4682 "Whereas having changes follow a copy is a feature where you can perhaps nod "
4683 "and say <quote>yes, that might be useful,</quote> it should be clear that "
4684 "having them follow a rename is definitely important. Without this facility, "
4685 "it would simply be too easy for changes to become orphaned when files are "
4686 "renamed."
4687 msgstr ""
4689 #. type: Content of: <book><chapter><sect1><sect2><title>
4690 #: ../en/ch04-daily.xml:452
4691 msgid "Divergent renames and merging"
4692 msgstr "改名与合并的分歧"
4694 #. type: Content of: <book><chapter><sect1><sect2><para>
4695 #: ../en/ch04-daily.xml:454
4696 msgid ""
4697 "The case of diverging names occurs when two developers start with a "
4698 "file&emdash;let's call it <filename>foo</filename>&emdash;in their respective "
4699 "repositories."
4700 msgstr ""
4702 #. type: Content of: <book><chapter><sect1><sect2><para>
4703 #: ../en/ch04-daily.xml:461
4704 msgid "Anne renames the file to <filename>bar</filename>."
4705 msgstr ""
4707 #. type: Content of: <book><chapter><sect1><sect2><para>
4708 #: ../en/ch04-daily.xml:465
4709 msgid "Meanwhile, Bob renames it to <filename>quux</filename>."
4710 msgstr ""
4712 #. type: Content of: <book><chapter><sect1><sect2><para>
4713 #: ../en/ch04-daily.xml:470
4714 msgid ""
4715 "I like to think of this as a conflict because each developer has expressed "
4716 "different intentions about what the file ought to be named."
4717 msgstr ""
4720 #. type: Content of: <book><chapter><sect1><sect2><para>
4721 #: ../en/ch04-daily.xml:474
4722 msgid ""
4723 "What do you think should happen when they merge their work? Mercurial's "
4724 "actual behaviour is that it always preserves <emphasis>both</emphasis> names "
4725 "when it merges changesets that contain divergent renames."
4726 msgstr ""
4728 #. type: Content of: <book><chapter><sect1><sect2><para>
4729 #: ../en/ch04-daily.xml:481
4730 msgid ""
4731 "Notice that Mercurial does warn about the divergent renames, but it leaves it "
4732 "up to you to do something about the divergence after the merge."
4733 msgstr ""
4735 #. type: Content of: <book><chapter><sect1><sect2><title>
4736 #: ../en/ch04-daily.xml:487
4737 msgid "Convergent renames and merging"
4738 msgstr "收敛改名与合并"
4740 #. type: Content of: <book><chapter><sect1><sect2><para>
4741 #: ../en/ch04-daily.xml:489
4742 msgid ""
4743 "Another kind of rename conflict occurs when two people choose to rename "
4744 "different <emphasis>source</emphasis> files to the same "
4745 "<emphasis>destination</emphasis>. In this case, Mercurial runs its normal "
4746 "merge machinery, and lets you guide it to a suitable resolution."
4747 msgstr ""
4749 #. type: Content of: <book><chapter><sect1><sect2><title>
4750 #: ../en/ch04-daily.xml:497
4751 msgid "Other name-related corner cases"
4752 msgstr "其它名称相关的角落"
4754 #. type: Content of: <book><chapter><sect1><sect2><para>
4755 #: ../en/ch04-daily.xml:499
4756 msgid ""
4757 "Mercurial has a longstanding bug in which it fails to handle a merge where "
4758 "one side has a file with a given name, while another has a directory with the "
4759 "same name. This is documented as <ulink role=\"hg-bug\" url=\"http://www."
4760 "selenic.com/mercurial/bts/issue29\">issue 29</ulink>."
4761 msgstr ""
4763 #. type: Content of: <book><chapter><sect1><title>
4764 #: ../en/ch04-daily.xml:511
4765 msgid "Recovering from mistakes"
4766 msgstr "从错误恢复"
4768 #. type: Content of: <book><chapter><sect1><para>
4769 #: ../en/ch04-daily.xml:513
4770 msgid ""
4771 "Mercurial has some useful commands that will help you to recover from some "
4772 "common mistakes."
4773 msgstr ""
4775 #. type: Content of: <book><chapter><sect1><para>
4776 #: ../en/ch04-daily.xml:516
4777 msgid ""
4778 "The <command role=\"hg-cmd\">hg revert</command> command lets you undo "
4779 "changes that you have made to your working directory. For example, if you "
4780 "<command role=\"hg-cmd\">hg add</command> a file by accident, just run "
4781 "<command role=\"hg-cmd\">hg revert</command> with the name of the file you "
4782 "added, and while the file won't be touched in any way, it won't be tracked "
4783 "for adding by Mercurial any longer, either. You can also use <command role="
4784 "\"hg-cmd\">hg revert</command> to get rid of erroneous changes to a file."
4785 msgstr ""
4787 #. type: Content of: <book><chapter><sect1><para>
4788 #: ../en/ch04-daily.xml:526
4789 msgid ""
4790 "It's useful to remember that the <command role=\"hg-cmd\">hg revert</command> "
4791 "command is useful for changes that you have not yet committed. Once you've "
4792 "committed a change, if you decide it was a mistake, you can still do "
4793 "something about it, though your options may be more limited."
4794 msgstr ""
4796 #. type: Content of: <book><chapter><sect1><para>
4797 #: ../en/ch04-daily.xml:532
4798 msgid ""
4799 "For more information about the <command role=\"hg-cmd\">hg revert</command> "
4800 "command, and details about how to deal with changes you have already "
4801 "committed, see chapter <xref linkend=\"chap.undo\"/>."
4802 msgstr ""
4804 #. type: Content of: <book><chapter><title>
4805 #: ../en/ch05-collab.xml:5
4806 msgid "Collaborating with other people"
4807 msgstr "团体协作"
4809 #. type: Content of: <book><chapter><para>
4810 #: ../en/ch05-collab.xml:7
4811 msgid ""
4812 "As a completely decentralised tool, Mercurial doesn't impose any policy on "
4813 "how people ought to work with each other. However, if you're new to "
4814 "distributed revision control, it helps to have some tools and examples in "
4815 "mind when you're thinking about possible workflow models."
4816 msgstr ""
4818 #. type: Content of: <book><chapter><sect1><title>
4819 #: ../en/ch05-collab.xml:14
4820 msgid "Mercurial's web interface"
4821 msgstr "Mercurial 的 web 接口"
4823 #. type: Content of: <book><chapter><sect1><para>
4824 #: ../en/ch05-collab.xml:16
4825 msgid ""
4826 "Mercurial has a powerful web interface that provides several useful "
4827 "capabilities."
4828 msgstr ""
4830 #. type: Content of: <book><chapter><sect1><para>
4831 #: ../en/ch05-collab.xml:19
4832 msgid ""
4833 "For interactive use, the web interface lets you browse a single repository or "
4834 "a collection of repositories. You can view the history of a repository, "
4835 "examine each change (comments and diffs), and view the contents of each "
4836 "directory and file."
4837 msgstr ""
4839 #. type: Content of: <book><chapter><sect1><para>
4840 #: ../en/ch05-collab.xml:24
4841 msgid ""
4842 "Also for human consumption, the web interface provides an RSS feed of the "
4843 "changes in a repository. This lets you <quote>subscribe</quote> to a "
4844 "repository using your favourite feed reader, and be automatically notified of "
4845 "activity in that repository as soon as it happens. I find this capability "
4846 "much more convenient than the model of subscribing to a mailing list to which "
4847 "notifications are sent, as it requires no additional configuration on the "
4848 "part of whoever is serving the repository."
4849 msgstr ""
4851 #. type: Content of: <book><chapter><sect1><para>
4852 #: ../en/ch05-collab.xml:34
4853 msgid ""
4854 "The web interface also lets remote users clone a repository, pull changes "
4855 "from it, and (when the server is configured to permit it) push changes back "
4856 "to it. Mercurial's HTTP tunneling protocol aggressively compresses data, so "
4857 "that it works efficiently even over low-bandwidth network connections."
4858 msgstr ""
4860 #. type: Content of: <book><chapter><sect1><para>
4861 #: ../en/ch05-collab.xml:40
4862 msgid ""
4863 "The easiest way to get started with the web interface is to use your web "
4864 "browser to visit an existing repository, such as the master Mercurial "
4865 "repository at <ulink url=\"http://www.selenic.com/repo/hg?style=gitweb"
4866 "\">http://www.selenic.com/repo/hg?style=gitweb</ulink>."
4867 msgstr ""
4869 #. type: Content of: <book><chapter><sect1><para>
4870 #: ../en/ch05-collab.xml:45
4871 msgid ""
4872 "If you're interested in providing a web interface to your own repositories, "
4873 "Mercurial provides two ways to do this. The first is using the <command role="
4874 "\"hg-cmd\">hg serve</command> command, which is best suited to short-term "
4875 "<quote>lightweight</quote> serving. See section <xref linkend=\"sec.collab."
4876 "serve\"/> below for details of how to use this command. If you have a long-"
4877 "lived repository that you'd like to make permanently available, Mercurial has "
4878 "built-in support for the CGI (Common Gateway Interface) standard, which all "
4879 "common web servers support. See section <xref linkend=\"sec.collab.cgi\"/> "
4880 "for details of CGI configuration."
4881 msgstr ""
4883 #. type: Content of: <book><chapter><sect1><title>
4884 #: ../en/ch05-collab.xml:60
4885 msgid "Collaboration models"
4886 msgstr "协作模型"
4888 #. type: Content of: <book><chapter><sect1><para>
4889 #: ../en/ch05-collab.xml:62
4890 msgid ""
4891 "With a suitably flexible tool, making decisions about workflow is much more "
4892 "of a social engineering challenge than a technical one. Mercurial imposes few "
4893 "limitations on how you can structure the flow of work in a project, so it's "
4894 "up to you and your group to set up and live with a model that matches your "
4895 "own particular needs."
4896 msgstr ""
4898 #. type: Content of: <book><chapter><sect1><sect2><title>
4899 #: ../en/ch05-collab.xml:70
4900 msgid "Factors to keep in mind"
4901 msgstr "要牢记的因素"
4903 #. type: Content of: <book><chapter><sect1><sect2><para>
4904 #: ../en/ch05-collab.xml:72
4905 msgid ""
4906 "The most important aspect of any model that you must keep in mind is how well "
4907 "it matches the needs and capabilities of the people who will be using it. "
4908 "This might seem self-evident; even so, you still can't afford to forget it "
4909 "for a moment."
4910 msgstr ""
4912 #. type: Content of: <book><chapter><sect1><sect2><para>
4913 #: ../en/ch05-collab.xml:78
4914 msgid ""
4915 "I once put together a workflow model that seemed to make perfect sense to me, "
4916 "but that caused a considerable amount of consternation and strife within my "
4917 "development team. In spite of my attempts to explain why we needed a complex "
4918 "set of branches, and how changes ought to flow between them, a few team "
4919 "members revolted. Even though they were smart people, they didn't want to "
4920 "pay attention to the constraints we were operating under, or face the "
4921 "consequences of those constraints in the details of the model that I was "
4922 "advocating."
4923 msgstr ""
4925 #. type: Content of: <book><chapter><sect1><sect2><para>
4926 #: ../en/ch05-collab.xml:88
4927 msgid ""
4928 "Don't sweep foreseeable social or technical problems under the rug. Whatever "
4929 "scheme you put into effect, you should plan for mistakes and problem "
4930 "scenarios. Consider adding automated machinery to prevent, or quickly "
4931 "recover from, trouble that you can anticipate. As an example, if you intend "
4932 "to have a branch with not-for-release changes in it, you'd do well to think "
4933 "early about the possibility that someone might accidentally merge those "
4934 "changes into a release branch. You could avoid this particular problem by "
4935 "writing a hook that prevents changes from being merged from an inappropriate "
4936 "branch."
4937 msgstr ""
4939 #. type: Content of: <book><chapter><sect1><sect2><title>
4940 #: ../en/ch05-collab.xml:102
4941 msgid "Informal anarchy"
4942 msgstr "无政府状态"
4944 #. type: Content of: <book><chapter><sect1><sect2><para>
4945 #: ../en/ch05-collab.xml:104
4946 msgid ""
4947 "I wouldn't suggest an <quote>anything goes</quote> approach as something "
4948 "sustainable, but it's a model that's easy to grasp, and it works perfectly "
4949 "well in a few unusual situations."
4950 msgstr ""
4952 #. type: Content of: <book><chapter><sect1><sect2><para>
4953 #: ../en/ch05-collab.xml:109
4954 msgid ""
4955 "As one example, many projects have a loose-knit group of collaborators who "
4956 "rarely physically meet each other. Some groups like to overcome the "
4957 "isolation of working at a distance by organising occasional <quote>sprints</"
4958 "quote>. In a sprint, a number of people get together in a single location (a "
4959 "company's conference room, a hotel meeting room, that kind of place) and "
4960 "spend several days more or less locked in there, hacking intensely on a "
4961 "handful of projects."
4962 msgstr ""
4964 #. type: Content of: <book><chapter><sect1><sect2><para>
4965 #: ../en/ch05-collab.xml:118
4966 msgid ""
4967 "A sprint is the perfect place to use the <command role=\"hg-cmd\">hg serve</"
4968 "command> command, since <command role=\"hg-cmd\">hg serve</command> does not "
4969 "require any fancy server infrastructure. You can get started with <command "
4970 "role=\"hg-cmd\">hg serve</command> in moments, by reading section <xref "
4971 "linkend=\"sec.collab.serve\"/> below. Then simply tell the person next to "
4972 "you that you're running a server, send the URL to them in an instant message, "
4973 "and you immediately have a quick-turnaround way to work together. They can "
4974 "type your URL into their web browser and quickly review your changes; or they "
4975 "can pull a bugfix from you and verify it; or they can clone a branch "
4976 "containing a new feature and try it out."
4977 msgstr ""
4979 #. type: Content of: <book><chapter><sect1><sect2><para>
4980 #: ../en/ch05-collab.xml:132
4981 msgid ""
4982 "The charm, and the problem, with doing things in an ad hoc fashion like this "
4983 "is that only people who know about your changes, and where they are, can see "
4984 "them. Such an informal approach simply doesn't scale beyond a handful "
4985 "people, because each individual needs to know about $n$ different "
4986 "repositories to pull from."
4987 msgstr ""
4989 #. type: Content of: <book><chapter><sect1><sect2><title>
4990 #: ../en/ch05-collab.xml:141
4991 msgid "A single central repository"
4992 msgstr "单一中央版本库"
4994 #. type: Content of: <book><chapter><sect1><sect2><para>
4995 #: ../en/ch05-collab.xml:143
4996 msgid ""
4997 "For smaller projects migrating from a centralised revision control tool, "
4998 "perhaps the easiest way to get started is to have changes flow through a "
4999 "single shared central repository. This is also the most common "
5000 "<quote>building block</quote> for more ambitious workflow schemes."
5001 msgstr ""
5003 #. type: Content of: <book><chapter><sect1><sect2><para>
5004 #: ../en/ch05-collab.xml:149
5005 msgid ""
5006 "Contributors start by cloning a copy of this repository. They can pull "
5007 "changes from it whenever they need to, and some (perhaps all) developers have "
5008 "permission to push a change back when they're ready for other people to see "
5009 "it."
5010 msgstr ""
5012 #. type: Content of: <book><chapter><sect1><sect2><para>
5013 #: ../en/ch05-collab.xml:154
5014 msgid ""
5015 "Under this model, it can still often make sense for people to pull changes "
5016 "directly from each other, without going through the central repository. "
5017 "Consider a case in which I have a tentative bug fix, but I am worried that if "
5018 "I were to publish it to the central repository, it might subsequently break "
5019 "everyone else's trees as they pull it. To reduce the potential for damage, I "
5020 "can ask you to clone my repository into a temporary repository of your own "
5021 "and test it. This lets us put off publishing the potentially unsafe change "
5022 "until it has had a little testing."
5023 msgstr ""
5025 #. type: Content of: <book><chapter><sect1><sect2><para>
5026 #: ../en/ch05-collab.xml:165
5027 msgid ""
5028 "In this kind of scenario, people usually use the <command>ssh</command> "
5029 "protocol to securely push changes to the central repository, as documented in "
5030 "section <xref linkend=\"sec.collab.ssh\"/>. It's also usual to publish a "
5031 "read-only copy of the repository over HTTP using CGI, as in section <xref "
5032 "linkend=\"sec.collab.cgi\"/>. Publishing over HTTP satisfies the needs of "
5033 "people who don't have push access, and those who want to use web browsers to "
5034 "browse the repository's history."
5035 msgstr ""
5037 #. type: Content of: <book><chapter><sect1><sect2><title>
5038 #: ../en/ch05-collab.xml:178
5039 msgid "Working with multiple branches"
5040 msgstr "使用多个分支工作"
5042 #. type: Content of: <book><chapter><sect1><sect2><para>
5043 #: ../en/ch05-collab.xml:180
5044 msgid ""
5045 "Projects of any significant size naturally tend to make progress on several "
5046 "fronts simultaneously. In the case of software, it's common for a project to "
5047 "go through periodic official releases. A release might then go into "
5048 "<quote>maintenance mode</quote> for a while after its first publication; "
5049 "maintenance releases tend to contain only bug fixes, not new features. In "
5050 "parallel with these maintenance releases, one or more future releases may be "
5051 "under development. People normally use the word <quote>branch</quote> to "
5052 "refer to one of these many slightly different directions in which development "
5053 "is proceeding."
5054 msgstr ""
5056 #. type: Content of: <book><chapter><sect1><sect2><para>
5057 #: ../en/ch05-collab.xml:193
5058 msgid ""
5059 "Mercurial is particularly well suited to managing a number of simultaneous, "
5060 "but not identical, branches. Each <quote>development direction</quote> can "
5061 "live in its own central repository, and you can merge changes from one to "
5062 "another as the need arises. Because repositories are independent of each "
5063 "other, unstable changes in a development branch will never affect a stable "
5064 "branch unless someone explicitly merges those changes in."
5065 msgstr ""
5067 #. type: Content of: <book><chapter><sect1><sect2><para>
5068 #: ../en/ch05-collab.xml:202
5069 msgid ""
5070 "Here's an example of how this can work in practice. Let's say you have one "
5071 "<quote>main branch</quote> on a central server."
5072 msgstr ""
5074 #. type: Content of: <book><chapter><sect1><sect2><para>
5075 #: ../en/ch05-collab.xml:208
5076 msgid "People clone it, make changes locally, test them, and push them back."
5077 msgstr ""
5079 #. type: Content of: <book><chapter><sect1><sect2><para>
5080 #: ../en/ch05-collab.xml:211
5081 msgid ""
5082 "Once the main branch reaches a release milestone, you can use the <command "
5083 "role=\"hg-cmd\">hg tag</command> command to give a permanent name to the "
5084 "milestone revision."
5085 msgstr ""
5087 #. type: Content of: <book><chapter><sect1><sect2><para>
5088 #: ../en/ch05-collab.xml:217
5089 msgid "Let's say some ongoing development occurs on the main branch."
5090 msgstr ""
5092 #. type: Content of: <book><chapter><sect1><sect2><para>
5093 #: ../en/ch05-collab.xml:222
5094 msgid ""
5095 "Using the tag that was recorded at the milestone, people who clone that "
5096 "repository at any time in the future can use <command role=\"hg-cmd\">hg "
5097 "update</command> to get a copy of the working directory exactly as it was "
5098 "when that tagged revision was committed."
5099 msgstr ""
5102 #. type: Content of: <book><chapter><sect1><sect2><para>
5103 #: ../en/ch05-collab.xml:230
5104 msgid ""
5105 "In addition, immediately after the main branch is tagged, someone can then "
5106 "clone the main branch on the server to a new <quote>stable</quote> branch, "
5107 "also on the server."
5108 msgstr ""
5110 #. type: Content of: <book><chapter><sect1><sect2><para>
5111 #: ../en/ch05-collab.xml:236
5112 msgid ""
5113 "Someone who needs to make a change to the stable branch can then clone "
5114 "<emphasis>that</emphasis> repository, make their changes, commit, and push "
5115 "their changes back there."
5116 msgstr ""
5118 #. type: Content of: <book><chapter><sect1><sect2><para>
5119 #: ../en/ch05-collab.xml:242
5120 msgid ""
5121 "Because Mercurial repositories are independent, and Mercurial doesn't move "
5122 "changes around automatically, the stable and main branches are "
5123 "<emphasis>isolated</emphasis> from each other. The changes that you made on "
5124 "the main branch don't <quote>leak</quote> to the stable branch, and vice "
5125 "versa."
5126 msgstr ""
5128 #. type: Content of: <book><chapter><sect1><sect2><para>
5129 #: ../en/ch05-collab.xml:249
5130 msgid ""
5131 "You'll often want all of your bugfixes on the stable branch to show up on the "
5132 "main branch, too. Rather than rewrite a bugfix on the main branch, you can "
5133 "simply pull and merge changes from the stable to the main branch, and "
5134 "Mercurial will bring those bugfixes in for you."
5135 msgstr ""
5137 #. type: Content of: <book><chapter><sect1><sect2><para>
5138 #: ../en/ch05-collab.xml:257
5139 msgid ""
5140 "The main branch will still contain changes that are not on the stable branch, "
5141 "but it will also contain all of the bugfixes from the stable branch. The "
5142 "stable branch remains unaffected by these changes."
5143 msgstr ""
5145 #. type: Content of: <book><chapter><sect1><sect2><informalfigure><mediaobject><caption><para>
5146 #: ../en/ch05-collab.xml:264 ../en/ch05-collab.xml:278
5147 msgid "Feature branches"
5148 msgstr "特性分支"
5150 #. type: Content of: <book><chapter><sect1><sect2><para>
5151 #: ../en/ch05-collab.xml:266
5152 msgid ""
5153 "For larger projects, an effective way to manage change is to break up a team "
5154 "into smaller groups. Each group has a shared branch of its own, cloned from "
5155 "a single <quote>master</quote> branch used by the entire project. People "
5156 "working on an individual branch are typically quite isolated from "
5157 "developments on other branches."
5158 msgstr ""
5160 #. type: Content of: <book><chapter><sect1><sect2><informalfigure><mediaobject>
5161 #: ../en/ch05-collab.xml:275
5162 msgid ""
5163 "<imageobject><imagedata fileref=\"images/feature-branches.png\"/> </"
5164 "imageobject>"
5165 msgstr ""
5167 #. type: Content of: <book><chapter><sect1><sect2><para>
5168 #: ../en/ch05-collab.xml:283
5169 msgid ""
5170 "When a particular feature is deemed to be in suitable shape, someone on that "
5171 "feature team pulls and merges from the master branch into the feature branch, "
5172 "then pushes back up to the master branch."
5173 msgstr ""
5175 #. type: Content of: <book><chapter><sect1><sect2><title>
5176 #: ../en/ch05-collab.xml:290
5177 msgid "The release train"
5178 msgstr "发布列车"
5180 #. type: Content of: <book><chapter><sect1><sect2><para>
5181 #: ../en/ch05-collab.xml:292
5182 msgid ""
5183 "Some projects are organised on a <quote>train</quote> basis: a release is "
5184 "scheduled to happen every few months, and whatever features are ready when "
5185 "the <quote>train</quote> is ready to leave are allowed in."
5186 msgstr ""
5188 #. type: Content of: <book><chapter><sect1><sect2><para>
5189 #: ../en/ch05-collab.xml:297
5190 msgid ""
5191 "This model resembles working with feature branches. The difference is that "
5192 "when a feature branch misses a train, someone on the feature team pulls and "
5193 "merges the changes that went out on that train release into the feature "
5194 "branch, and the team continues its work on top of that release so that their "
5195 "feature can make the next release."
5196 msgstr ""
5198 #. type: Content of: <book><chapter><sect1><sect2><title>
5199 #: ../en/ch05-collab.xml:306
5200 msgid "The Linux kernel model"
5201 msgstr "Linux 内核模型"
5203 #. type: Content of: <book><chapter><sect1><sect2><para>
5204 #: ../en/ch05-collab.xml:308
5205 msgid ""
5206 "The development of the Linux kernel has a shallow hierarchical structure, "
5207 "surrounded by a cloud of apparent chaos. Because most Linux developers use "
5208 "<command>git</command>, a distributed revision control tool with capabilities "
5209 "similar to Mercurial, it's useful to describe the way work flows in that "
5210 "environment; if you like the ideas, the approach translates well across tools."
5211 msgstr ""
5213 #. type: Content of: <book><chapter><sect1><sect2><para>
5214 #: ../en/ch05-collab.xml:316
5215 msgid ""
5216 "At the center of the community sits Linus Torvalds, the creator of Linux. He "
5217 "publishes a single source repository that is considered the "
5218 "<quote>authoritative</quote> current tree by the entire developer community. "
5219 "Anyone can clone Linus's tree, but he is very choosy about whose trees he "
5220 "pulls from."
5221 msgstr ""
5223 #. type: Content of: <book><chapter><sect1><sect2><para>
5224 #: ../en/ch05-collab.xml:323
5225 msgid ""
5226 "Linus has a number of <quote>trusted lieutenants</quote>. As a general rule, "
5227 "he pulls whatever changes they publish, in most cases without even reviewing "
5228 "those changes. Some of those lieutenants are generally agreed to be "
5229 "<quote>maintainers</quote>, responsible for specific subsystems within the "
5230 "kernel. If a random kernel hacker wants to make a change to a subsystem that "
5231 "they want to end up in Linus's tree, they must find out who the subsystem's "
5232 "maintainer is, and ask that maintainer to take their change. If the "
5233 "maintainer reviews their changes and agrees to take them, they'll pass them "
5234 "along to Linus in due course."
5235 msgstr ""
5237 #. type: Content of: <book><chapter><sect1><sect2><para>
5238 #: ../en/ch05-collab.xml:335
5239 msgid ""
5240 "Individual lieutenants have their own approaches to reviewing, accepting, and "
5241 "publishing changes; and for deciding when to feed them to Linus. In "
5242 "addition, there are several well known branches that people use for different "
5243 "purposes. For example, a few people maintain <quote>stable</quote> "
5244 "repositories of older versions of the kernel, to which they apply critical "
5245 "fixes as needed. Some maintainers publish multiple trees: one for "
5246 "experimental changes; one for changes that they are about to feed upstream; "
5247 "and so on. Others just publish a single tree."
5248 msgstr ""
5250 #. type: Content of: <book><chapter><sect1><sect2><para>
5251 #: ../en/ch05-collab.xml:346
5252 msgid ""
5253 "This model has two notable features. The first is that it's <quote>pull "
5254 "only</quote>. You have to ask, convince, or beg another developer to take a "
5255 "change from you, because there are almost no trees to which more than one "
5256 "person can push, and there's no way to push changes into a tree that someone "
5257 "else controls."
5258 msgstr ""
5260 #. type: Content of: <book><chapter><sect1><sect2><para>
5261 #: ../en/ch05-collab.xml:353
5262 msgid ""
5263 "The second is that it's based on reputation and acclaim. If you're an "
5264 "unknown, Linus will probably ignore changes from you without even "
5265 "responding. But a subsystem maintainer will probably review them, and will "
5266 "likely take them if they pass their criteria for suitability. The more "
5267 "<quote>good</quote> changes you contribute to a maintainer, the more likely "
5268 "they are to trust your judgment and accept your changes. If you're well-"
5269 "known and maintain a long-lived branch for something Linus hasn't yet "
5270 "accepted, people with similar interests may pull your changes regularly to "
5271 "keep up with your work."
5272 msgstr ""
5274 #. type: Content of: <book><chapter><sect1><sect2><para>
5275 #: ../en/ch05-collab.xml:364
5276 msgid ""
5277 "Reputation and acclaim don't necessarily cross subsystem or <quote>people</"
5278 "quote> boundaries. If you're a respected but specialised storage hacker, and "
5279 "you try to fix a networking bug, that change will receive a level of scrutiny "
5280 "from a network maintainer comparable to a change from a complete stranger."
5281 msgstr ""
5283 #. type: Content of: <book><chapter><sect1><sect2><para>
5284 #: ../en/ch05-collab.xml:371
5285 msgid ""
5286 "To people who come from more orderly project backgrounds, the comparatively "
5287 "chaotic Linux kernel development process often seems completely insane. It's "
5288 "subject to the whims of individuals; people make sweeping changes whenever "
5289 "they deem it appropriate; and the pace of development is astounding. And yet "
5290 "Linux is a highly successful, well-regarded piece of software."
5291 msgstr ""
5293 #. type: Content of: <book><chapter><sect1><sect2><title>
5294 #: ../en/ch05-collab.xml:381
5295 msgid "Pull-only versus shared-push collaboration"
5296 msgstr "只读与共享写协作"
5298 #. type: Content of: <book><chapter><sect1><sect2><para>
5299 #: ../en/ch05-collab.xml:383
5300 msgid ""
5301 "A perpetual source of heat in the open source community is whether a "
5302 "development model in which people only ever pull changes from others is "
5303 "<quote>better than</quote> one in which multiple people can push changes to a "
5304 "shared repository."
5305 msgstr ""
5307 #. type: Content of: <book><chapter><sect1><sect2><para>
5308 #: ../en/ch05-collab.xml:389
5309 msgid ""
5310 "Typically, the backers of the shared-push model use tools that actively "
5311 "enforce this approach. If you're using a centralised revision control tool "
5312 "such as Subversion, there's no way to make a choice over which model you'll "
5313 "use: the tool gives you shared-push, and if you want to do anything else, "
5314 "you'll have to roll your own approach on top (such as applying a patch by "
5315 "hand)."
5316 msgstr ""
5318 #. type: Content of: <book><chapter><sect1><sect2><para>
5319 #: ../en/ch05-collab.xml:397
5320 msgid ""
5321 "A good distributed revision control tool, such as Mercurial, will support "
5322 "both models. You and your collaborators can then structure how you work "
5323 "together based on your own needs and preferences, not on what contortions "
5324 "your tools force you into."
5325 msgstr ""
5327 #. type: Content of: <book><chapter><sect1><sect2><title>
5328 #: ../en/ch05-collab.xml:405
5329 msgid "Where collaboration meets branch management"
5330 msgstr "协作与分支管理"
5332 #. type: Content of: <book><chapter><sect1><sect2><para>
5333 #: ../en/ch05-collab.xml:407
5334 msgid ""
5335 "Once you and your team set up some shared repositories and start propagating "
5336 "changes back and forth between local and shared repos, you begin to face a "
5337 "related, but slightly different challenge: that of managing the multiple "
5338 "directions in which your team may be moving at once. Even though this "
5339 "subject is intimately related to how your team collaborates, it's dense "
5340 "enough to merit treatment of its own, in chapter <xref linkend=\"chap.branch"
5341 "\"/>."
5342 msgstr ""
5344 #. type: Content of: <book><chapter><sect1><title>
5345 #: ../en/ch05-collab.xml:419
5346 msgid "The technical side of sharing"
5347 msgstr "共享的技术因素"
5349 #. type: Content of: <book><chapter><sect1><para>
5350 #: ../en/ch05-collab.xml:421
5351 msgid ""
5352 "The remainder of this chapter is devoted to the question of serving data to "
5353 "your collaborators."
5354 msgstr ""
5356 #. type: Content of: <book><chapter><sect1><title>
5357 #: ../en/ch05-collab.xml:426
5358 msgid "Informal sharing with <command role=\"hg-cmd\">hg serve</command>"
5359 msgstr "使用 <command role=\"hg-cmd\">hg serve</command> 进行非正式共享"
5361 #. type: Content of: <book><chapter><sect1><para>
5362 #: ../en/ch05-collab.xml:429
5363 msgid ""
5364 "Mercurial's <command role=\"hg-cmd\">hg serve</command> command is "
5365 "wonderfully suited to small, tight-knit, and fast-paced group environments. "
5366 "It also provides a great way to get a feel for using Mercurial commands over "
5367 "a network."
5368 msgstr ""
5370 #. type: Content of: <book><chapter><sect1><para>
5371 #: ../en/ch05-collab.xml:434
5372 msgid ""
5373 "Run <command role=\"hg-cmd\">hg serve</command> inside a repository, and in "
5374 "under a second it will bring up a specialised HTTP server; this will accept "
5375 "connections from any client, and serve up data for that repository until you "
5376 "terminate it. Anyone who knows the URL of the server you just started, and "
5377 "can talk to your computer over the network, can then use a web browser or "
5378 "Mercurial to read data from that repository. A URL for a <command role=\"hg-"
5379 "cmd\">hg serve</command> instance running on a laptop is likely to look "
5380 "something like <literal>http://my-laptop.local:8000/</literal>."
5381 msgstr ""
5383 #. type: Content of: <book><chapter><sect1><para>
5384 #: ../en/ch05-collab.xml:445
5385 msgid ""
5386 "The <command role=\"hg-cmd\">hg serve</command> command is <emphasis>not</"
5387 "emphasis> a general-purpose web server. It can do only two things:"
5388 msgstr ""
5390 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
5391 #: ../en/ch05-collab.xml:449
5392 msgid ""
5393 "Allow people to browse the history of the repository it's serving, from their "
5394 "normal web browsers."
5395 msgstr ""
5397 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
5398 #: ../en/ch05-collab.xml:453
5399 msgid ""
5400 "Speak Mercurial's wire protocol, so that people can <command role=\"hg-cmd"
5401 "\">hg clone</command> or <command role=\"hg-cmd\">hg pull</command> changes "
5402 "from that repository."
5403 msgstr ""
5405 #. type: Content of: <book><chapter><sect1><para>
5406 #: ../en/ch05-collab.xml:458
5407 msgid ""
5408 "In particular, <command role=\"hg-cmd\">hg serve</command> won't allow remote "
5409 "users to <emphasis>modify</emphasis> your repository. It's intended for read-"
5410 "only use."
5411 msgstr ""
5413 #. type: Content of: <book><chapter><sect1><para>
5414 #: ../en/ch05-collab.xml:462
5415 msgid ""
5416 "If you're getting started with Mercurial, there's nothing to prevent you from "
5417 "using <command role=\"hg-cmd\">hg serve</command> to serve up a repository on "
5418 "your own computer, then use commands like <command role=\"hg-cmd\">hg clone</"
5419 "command>, <command role=\"hg-cmd\">hg incoming</command>, and so on to talk "
5420 "to that server as if the repository was hosted remotely. This can help you to "
5421 "quickly get acquainted with using commands on network-hosted repositories."
5422 msgstr ""
5424 #. type: Content of: <book><chapter><sect1><sect2><title>
5425 #: ../en/ch05-collab.xml:472
5426 msgid "A few things to keep in mind"
5427 msgstr "要牢记的几件事"
5429 #. type: Content of: <book><chapter><sect1><sect2><para>
5430 #: ../en/ch05-collab.xml:474
5431 msgid ""
5432 "Because it provides unauthenticated read access to all clients, you should "
5433 "only use <command role=\"hg-cmd\">hg serve</command> in an environment where "
5434 "you either don't care, or have complete control over, who can access your "
5435 "network and pull data from your repository."
5436 msgstr ""
5438 #. type: Content of: <book><chapter><sect1><sect2><para>
5439 #: ../en/ch05-collab.xml:480
5440 msgid ""
5441 "The <command role=\"hg-cmd\">hg serve</command> command knows nothing about "
5442 "any firewall software you might have installed on your system or network. It "
5443 "cannot detect or control your firewall software. If other people are unable "
5444 "to talk to a running <command role=\"hg-cmd\">hg serve</command> instance, "
5445 "the second thing you should do (<emphasis>after</emphasis> you make sure that "
5446 "they're using the correct URL) is check your firewall configuration."
5447 msgstr ""
5449 #. type: Content of: <book><chapter><sect1><sect2><para>
5450 #: ../en/ch05-collab.xml:489
5451 msgid ""
5452 "By default, <command role=\"hg-cmd\">hg serve</command> listens for incoming "
5453 "connections on port 8000. If another process is already listening on the "
5454 "port you want to use, you can specify a different port to listen on using the "
5455 "<option role=\"hg-opt-serve\">-p</option> option."
5456 msgstr ""
5458 #. type: Content of: <book><chapter><sect1><sect2><para>
5459 #: ../en/ch05-collab.xml:495
5460 msgid ""
5461 "Normally, when <command role=\"hg-cmd\">hg serve</command> starts, it prints "
5462 "no output, which can be a bit unnerving. If you'd like to confirm that it is "
5463 "indeed running correctly, and find out what URL you should send to your "
5464 "collaborators, start it with the <option role=\"hg-opt-global\">-v</option> "
5465 "option."
5466 msgstr ""
5468 #. type: Content of: <book><chapter><sect1><title>
5469 #: ../en/ch05-collab.xml:505
5470 msgid "Using the Secure Shell (ssh) protocol"
5471 msgstr "使用 ssh 协议"
5473 #. type: Content of: <book><chapter><sect1><para>
5474 #: ../en/ch05-collab.xml:507
5475 msgid ""
5476 "You can pull and push changes securely over a network connection using the "
5477 "Secure Shell (<literal>ssh</literal>) protocol. To use this successfully, "
5478 "you may have to do a little bit of configuration on the client or server "
5479 "sides."
5480 msgstr ""
5482 #. type: Content of: <book><chapter><sect1><para>
5483 #: ../en/ch05-collab.xml:512
5484 msgid ""
5485 "If you're not familiar with ssh, it's a network protocol that lets you "
5486 "securely communicate with another computer. To use it with Mercurial, you'll "
5487 "be setting up one or more user accounts on a server so that remote users can "
5488 "log in and execute commands."
5489 msgstr ""
5491 #. type: Content of: <book><chapter><sect1><para>
5492 #: ../en/ch05-collab.xml:518
5493 msgid ""
5494 "(If you <emphasis>are</emphasis> familiar with ssh, you'll probably find some "
5495 "of the material that follows to be elementary in nature.)"
5496 msgstr ""
5498 #. type: Content of: <book><chapter><sect1><sect2><title>
5499 #: ../en/ch05-collab.xml:523
5500 msgid "How to read and write ssh URLs"
5501 msgstr "如何读写 ssh 路径"
5503 #. type: Content of: <book><chapter><sect1><sect2><para>
5504 #: ../en/ch05-collab.xml:525
5505 msgid "An ssh URL tends to look like this:"
5506 msgstr ""
5508 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
5509 #: ../en/ch05-collab.xml:528
5510 msgid ""
5511 "The <quote><literal>ssh://</literal></quote> part tells Mercurial to use the "
5512 "ssh protocol."
5513 msgstr ""
5515 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
5516 #: ../en/ch05-collab.xml:531
5517 msgid ""
5518 "The <quote><literal>bos@</literal></quote> component indicates what username "
5519 "to log into the server as. You can leave this out if the remote username is "
5520 "the same as your local username."
5521 msgstr ""
5523 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
5524 #: ../en/ch05-collab.xml:536
5525 msgid ""
5526 "The <quote><literal>hg.serpentine.com</literal></quote> gives the hostname of "
5527 "the server to log into."
5528 msgstr ""
5530 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
5531 #: ../en/ch05-collab.xml:540
5532 msgid ""
5533 "The <quote>:22</quote> identifies the port number to connect to the server "
5534 "on. The default port is 22, so you only need to specify a colon and port "
5535 "number if you're <emphasis>not</emphasis> using port 22."
5536 msgstr ""
5538 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
5539 #: ../en/ch05-collab.xml:545
5540 msgid ""
5541 "The remainder of the URL is the local path to the repository on the server."
5542 msgstr ""
5544 #. type: Content of: <book><chapter><sect1><sect2><para>
5545 #: ../en/ch05-collab.xml:549
5546 msgid ""
5547 "There's plenty of scope for confusion with the path component of ssh URLs, as "
5548 "there is no standard way for tools to interpret it. Some programs behave "
5549 "differently than others when dealing with these paths. This isn't an ideal "
5550 "situation, but it's unlikely to change. Please read the following paragraphs "
5551 "carefully."
5552 msgstr ""
5554 #. type: Content of: <book><chapter><sect1><sect2><para>
5555 #: ../en/ch05-collab.xml:556
5556 msgid ""
5557 "Mercurial treats the path to a repository on the server as relative to the "
5558 "remote user's home directory. For example, if user <literal>foo</literal> on "
5559 "the server has a home directory of <filename class=\"directory\">/home/foo</"
5560 "filename>, then an ssh URL that contains a path component of <filename class="
5561 "\"directory\">bar</filename> <emphasis>really</emphasis> refers to the "
5562 "directory <filename class=\"directory\">/home/foo/bar</filename>."
5563 msgstr ""
5565 #. type: Content of: <book><chapter><sect1><sect2><para>
5566 #: ../en/ch05-collab.xml:565
5567 msgid ""
5568 "If you want to specify a path relative to another user's home directory, you "
5569 "can use a path that starts with a tilde character followed by the user's name "
5570 "(let's call them <literal>otheruser</literal>), like this."
5571 msgstr ""
5573 #. type: Content of: <book><chapter><sect1><sect2><para>
5574 #: ../en/ch05-collab.xml:571
5575 msgid ""
5576 "And if you really want to specify an <emphasis>absolute</emphasis> path on "
5577 "the server, begin the path component with two slashes, as in this example."
5578 msgstr ""
5580 #. type: Content of: <book><chapter><sect1><sect2><title>
5581 #: ../en/ch05-collab.xml:578
5582 msgid "Finding an ssh client for your system"
5583 msgstr "为你的系统寻找 ssh 客户端"
5585 #. type: Content of: <book><chapter><sect1><sect2><para>
5586 #: ../en/ch05-collab.xml:580
5587 msgid ""
5588 "Almost every Unix-like system comes with OpenSSH preinstalled. If you're "
5589 "using such a system, run <literal>which ssh</literal> to find out if the "
5590 "<command>ssh</command> command is installed (it's usually in <filename class="
5591 "\"directory\">/usr/bin</filename>). In the unlikely event that it isn't "
5592 "present, take a look at your system documentation to figure out how to "
5593 "install it."
5594 msgstr ""
5596 #. type: Content of: <book><chapter><sect1><sect2><para>
5597 #: ../en/ch05-collab.xml:588
5598 msgid ""
5599 "On Windows, you'll first need to download a suitable ssh client. There are "
5600 "two alternatives."
5601 msgstr ""
5603 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
5604 #: ../en/ch05-collab.xml:591
5605 msgid ""
5606 "Simon Tatham's excellent PuTTY package <citation>web:putty</citation> "
5607 "provides a complete suite of ssh client commands."
5608 msgstr ""
5610 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
5611 #: ../en/ch05-collab.xml:595
5612 msgid ""
5613 "If you have a high tolerance for pain, you can use the Cygwin port of OpenSSH."
5614 msgstr ""
5616 #. type: Content of: <book><chapter><sect1><sect2><para>
5617 #: ../en/ch05-collab.xml:598
5618 msgid ""
5619 "In either case, you'll need to edit your <filename role=\"special\">hg.ini</"
5620 "filename> file to tell Mercurial where to find the actual client command. "
5621 "For example, if you're using PuTTY, you'll need to use the <command>plink</"
5622 "command> command as a command-line ssh client."
5623 msgstr ""
5625 #. type: Content of: <book><chapter><sect1><sect2><note><para>
5626 #: ../en/ch05-collab.xml:608
5627 msgid ""
5628 "The path to <command>plink</command> shouldn't contain any whitespace "
5629 "characters, or Mercurial may not be able to run it correctly (so putting it "
5630 "in <filename class=\"directory\">C:\\Program Files</filename> is probably not "
5631 "a good idea)."
5632 msgstr ""
5634 #. type: Content of: <book><chapter><sect1><sect2><title>
5635 #: ../en/ch05-collab.xml:617
5636 msgid "Generating a key pair"
5637 msgstr "产生密钥对"
5639 #. type: Content of: <book><chapter><sect1><sect2><para>
5640 #: ../en/ch05-collab.xml:619
5641 msgid ""
5642 "To avoid the need to repetitively type a password every time you need to use "
5643 "your ssh client, I recommend generating a key pair. On a Unix-like system, "
5644 "the <command>ssh-keygen</command> command will do the trick. On Windows, if "
5645 "you're using PuTTY, the <command>puttygen</command> command is what you'll "
5646 "need."
5647 msgstr ""
5649 #. type: Content of: <book><chapter><sect1><sect2><para>
5650 #: ../en/ch05-collab.xml:627
5651 msgid ""
5652 "When you generate a key pair, it's usually <emphasis>highly</emphasis> "
5653 "advisable to protect it with a passphrase. (The only time that you might not "
5654 "want to do this is when you're using the ssh protocol for automated tasks on "
5655 "a secure network.)"
5656 msgstr ""
5658 #. type: Content of: <book><chapter><sect1><sect2><para>
5659 #: ../en/ch05-collab.xml:633
5660 msgid ""
5661 "Simply generating a key pair isn't enough, however. You'll need to add the "
5662 "public key to the set of authorised keys for whatever user you're logging in "
5663 "remotely as. For servers using OpenSSH (the vast majority), this will mean "
5664 "adding the public key to a list in a file called <filename role=\"special"
5665 "\">authorized_keys</filename> in their <filename role=\"special\" class="
5666 "\"directory\">.ssh</filename> directory."
5667 msgstr ""
5669 #. type: Content of: <book><chapter><sect1><sect2><para>
5670 #: ../en/ch05-collab.xml:642
5671 msgid ""
5672 "On a Unix-like system, your public key will have a <filename>.pub</filename> "
5673 "extension. If you're using <command>puttygen</command> on Windows, you can "
5674 "save the public key to a file of your choosing, or paste it from the window "
5675 "it's displayed in straight into the <filename role=\"special"
5676 "\">authorized_keys</filename> file."
5677 msgstr ""
5679 #. type: Content of: <book><chapter><sect1><sect2><title>
5680 #: ../en/ch05-collab.xml:651
5681 msgid "Using an authentication agent"
5682 msgstr "使用认证代理"
5684 #. type: Content of: <book><chapter><sect1><sect2><para>
5685 #: ../en/ch05-collab.xml:653
5686 msgid ""
5687 "An authentication agent is a daemon that stores passphrases in memory (so it "
5688 "will forget passphrases if you log out and log back in again). An ssh client "
5689 "will notice if it's running, and query it for a passphrase. If there's no "
5690 "authentication agent running, or the agent doesn't store the necessary "
5691 "passphrase, you'll have to type your passphrase every time Mercurial tries to "
5692 "communicate with a server on your behalf (e.g. whenever you pull or push "
5693 "changes)."
5694 msgstr ""
5696 #. type: Content of: <book><chapter><sect1><sect2><para>
5697 #: ../en/ch05-collab.xml:662
5698 msgid ""
5699 "The downside of storing passphrases in an agent is that it's possible for a "
5700 "well-prepared attacker to recover the plain text of your passphrases, in some "
5701 "cases even if your system has been power-cycled. You should make your own "
5702 "judgment as to whether this is an acceptable risk. It certainly saves a lot "
5703 "of repeated typing."
5704 msgstr ""
5706 #. type: Content of: <book><chapter><sect1><sect2><para>
5707 #: ../en/ch05-collab.xml:669
5708 msgid ""
5709 "On Unix-like systems, the agent is called <command>ssh-agent</command>, and "
5710 "it's often run automatically for you when you log in. You'll need to use the "
5711 "<command>ssh-add</command> command to add passphrases to the agent's store. "
5712 "On Windows, if you're using PuTTY, the <command>pageant</command> command "
5713 "acts as the agent. It adds an icon to your system tray that will let you "
5714 "manage stored passphrases."
5715 msgstr ""
5717 #. type: Content of: <book><chapter><sect1><sect2><title>
5718 #: ../en/ch05-collab.xml:680
5719 msgid "Configuring the server side properly"
5720 msgstr "正确配置服务器端"
5722 #. type: Content of: <book><chapter><sect1><sect2><para>
5723 #: ../en/ch05-collab.xml:682
5724 msgid ""
5725 "Because ssh can be fiddly to set up if you're new to it, there's a variety of "
5726 "things that can go wrong. Add Mercurial on top, and there's plenty more "
5727 "scope for head-scratching. Most of these potential problems occur on the "
5728 "server side, not the client side. The good news is that once you've gotten a "
5729 "configuration working, it will usually continue to work indefinitely."
5730 msgstr ""
5732 #. type: Content of: <book><chapter><sect1><sect2><para>
5733 #: ../en/ch05-collab.xml:690
5734 msgid ""
5735 "Before you try using Mercurial to talk to an ssh server, it's best to make "
5736 "sure that you can use the normal <command>ssh</command> or <command>putty</"
5737 "command> command to talk to the server first. If you run into problems with "
5738 "using these commands directly, Mercurial surely won't work. Worse, it will "
5739 "obscure the underlying problem. Any time you want to debug ssh-related "
5740 "Mercurial problems, you should drop back to making sure that plain ssh client "
5741 "commands work first, <emphasis>before</emphasis> you worry about whether "
5742 "there's a problem with Mercurial."
5743 msgstr ""
5745 #. type: Content of: <book><chapter><sect1><sect2><para>
5746 #: ../en/ch05-collab.xml:701
5747 msgid ""
5748 "The first thing to be sure of on the server side is that you can actually log "
5749 "in from another machine at all. If you can't use <command>ssh</command> or "
5750 "<command>putty</command> to log in, the error message you get may give you a "
5751 "few hints as to what's wrong. The most common problems are as follows."
5752 msgstr ""
5754 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
5755 #: ../en/ch05-collab.xml:708
5756 msgid ""
5757 "If you get a <quote>connection refused</quote> error, either there isn't an "
5758 "SSH daemon running on the server at all, or it's inaccessible due to firewall "
5759 "configuration."
5760 msgstr ""
5762 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
5763 #: ../en/ch05-collab.xml:713
5764 msgid ""
5765 "If you get a <quote>no route to host</quote> error, you either have an "
5766 "incorrect address for the server or a seriously locked down firewall that "
5767 "won't admit its existence at all."
5768 msgstr ""
5770 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
5771 #: ../en/ch05-collab.xml:718
5772 msgid ""
5773 "If you get a <quote>permission denied</quote> error, you may have mistyped "
5774 "the username on the server, or you could have mistyped your key's passphrase "
5775 "or the remote user's password."
5776 msgstr ""
5778 #. type: Content of: <book><chapter><sect1><sect2><para>
5779 #: ../en/ch05-collab.xml:723
5780 msgid ""
5781 "In summary, if you're having trouble talking to the server's ssh daemon, "
5782 "first make sure that one is running at all. On many systems it will be "
5783 "installed, but disabled, by default. Once you're done with this step, you "
5784 "should then check that the server's firewall is configured to allow incoming "
5785 "connections on the port the ssh daemon is listening on (usually 22). Don't "
5786 "worry about more exotic possibilities for misconfiguration until you've "
5787 "checked these two first."
5788 msgstr ""
5790 #. type: Content of: <book><chapter><sect1><sect2><para>
5791 #: ../en/ch05-collab.xml:733
5792 msgid ""
5793 "If you're using an authentication agent on the client side to store "
5794 "passphrases for your keys, you ought to be able to log into the server "
5795 "without being prompted for a passphrase or a password. If you're prompted "
5796 "for a passphrase, there are a few possible culprits."
5797 msgstr ""
5799 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
5800 #: ../en/ch05-collab.xml:739
5801 msgid ""
5802 "You might have forgotten to use <command>ssh-add</command> or "
5803 "<command>pageant</command> to store the passphrase."
5804 msgstr ""
5806 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
5807 #: ../en/ch05-collab.xml:743
5808 msgid "You might have stored the passphrase for the wrong key."
5809 msgstr ""
5811 #. type: Content of: <book><chapter><sect1><sect2><para>
5812 #: ../en/ch05-collab.xml:746
5813 msgid ""
5814 "If you're being prompted for the remote user's password, there are another "
5815 "few possible problems to check."
5816 msgstr ""
5818 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
5819 #: ../en/ch05-collab.xml:749
5820 msgid ""
5821 "Either the user's home directory or their <filename role=\"special\" class="
5822 "\"directory\">.ssh</filename> directory might have excessively liberal "
5823 "permissions. As a result, the ssh daemon will not trust or read their "
5824 "<filename role=\"special\">authorized_keys</filename> file. For example, a "
5825 "group-writable home or <filename role=\"special\" class=\"directory\">.ssh</"
5826 "filename> directory will often cause this symptom."
5827 msgstr ""
5829 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
5830 #: ../en/ch05-collab.xml:758
5831 msgid ""
5832 "The user's <filename role=\"special\">authorized_keys</filename> file may "
5833 "have a problem. If anyone other than the user owns or can write to that file, "
5834 "the ssh daemon will not trust or read it."
5835 msgstr ""
5837 #. type: Content of: <book><chapter><sect1><sect2><para>
5838 #: ../en/ch05-collab.xml:765
5839 msgid ""
5840 "In the ideal world, you should be able to run the following command "
5841 "successfully, and it should print exactly one line of output, the current "
5842 "date and time."
5843 msgstr ""
5845 #. type: Content of: <book><chapter><sect1><sect2><para>
5846 #: ../en/ch05-collab.xml:770
5847 msgid ""
5848 "If, on your server, you have login scripts that print banners or other junk "
5849 "even when running non-interactive commands like this, you should fix them "
5850 "before you continue, so that they only print output if they're run "
5851 "interactively. Otherwise these banners will at least clutter up Mercurial's "
5852 "output. Worse, they could potentially cause problems with running Mercurial "
5853 "commands remotely. Mercurial makes tries to detect and ignore banners in non-"
5854 "interactive <command>ssh</command> sessions, but it is not foolproof. (If "
5855 "you're editing your login scripts on your server, the usual way to see if a "
5856 "login script is running in an interactive shell is to check the return code "
5857 "from the command <literal>tty -s</literal>.)"
5858 msgstr ""
5860 #. type: Content of: <book><chapter><sect1><sect2><para>
5861 #: ../en/ch05-collab.xml:784
5862 msgid ""
5863 "Once you've verified that plain old ssh is working with your server, the next "
5864 "step is to ensure that Mercurial runs on the server. The following command "
5865 "should run successfully:"
5866 msgstr ""
5868 #. type: Content of: <book><chapter><sect1><sect2><para>
5869 #: ../en/ch05-collab.xml:791
5870 msgid ""
5871 "If you see an error message instead of normal <command role=\"hg-cmd\">hg "
5872 "version</command> output, this is usually because you haven't installed "
5873 "Mercurial to <filename class=\"directory\">/usr/bin</filename>. Don't worry "
5874 "if this is the case; you don't need to do that. But you should check for a "
5875 "few possible problems."
5876 msgstr ""
5878 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
5879 #: ../en/ch05-collab.xml:798
5880 msgid ""
5881 "Is Mercurial really installed on the server at all? I know this sounds "
5882 "trivial, but it's worth checking!"
5883 msgstr ""
5885 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
5886 #: ../en/ch05-collab.xml:802
5887 msgid ""
5888 "Maybe your shell's search path (usually set via the <envar>PATH</envar> "
5889 "environment variable) is simply misconfigured."
5890 msgstr ""
5892 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
5893 #: ../en/ch05-collab.xml:806
5894 msgid ""
5895 "Perhaps your <envar>PATH</envar> environment variable is only being set to "
5896 "point to the location of the <command>hg</command> executable if the login "
5897 "session is interactive. This can happen if you're setting the path in the "
5898 "wrong shell login script. See your shell's documentation for details."
5899 msgstr ""
5901 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
5902 #: ../en/ch05-collab.xml:813
5903 msgid ""
5904 "The <envar>PYTHONPATH</envar> environment variable may need to contain the "
5905 "path to the Mercurial Python modules. It might not be set at all; it could "
5906 "be incorrect; or it may be set only if the login is interactive."
5907 msgstr ""
5909 #. type: Content of: <book><chapter><sect1><sect2><para>
5910 #: ../en/ch05-collab.xml:820
5911 msgid ""
5912 "If you can run <command role=\"hg-cmd\">hg version</command> over an ssh "
5913 "connection, well done! You've got the server and client sorted out. You "
5914 "should now be able to use Mercurial to access repositories hosted by that "
5915 "username on that server. If you run into problems with Mercurial and ssh at "
5916 "this point, try using the <option role=\"hg-opt-global\">--debug</option> "
5917 "option to get a clearer picture of what's going on."
5918 msgstr ""
5920 #. type: Content of: <book><chapter><sect1><sect2><title>
5921 #: ../en/ch05-collab.xml:830
5922 msgid "Using compression with ssh"
5923 msgstr "通过 ssh 使用压缩"
5925 #. type: Content of: <book><chapter><sect1><sect2><para>
5926 #: ../en/ch05-collab.xml:832
5927 msgid ""
5928 "Mercurial does not compress data when it uses the ssh protocol, because the "
5929 "ssh protocol can transparently compress data. However, the default behaviour "
5930 "of ssh clients is <emphasis>not</emphasis> to request compression."
5931 msgstr ""
5933 #. type: Content of: <book><chapter><sect1><sect2><para>
5934 #: ../en/ch05-collab.xml:837
5935 msgid ""
5936 "Over any network other than a fast LAN (even a wireless network), using "
5937 "compression is likely to significantly speed up Mercurial's network "
5938 "operations. For example, over a WAN, someone measured compression as "
5939 "reducing the amount of time required to clone a particularly large repository "
5940 "from 51 minutes to 17 minutes."
5941 msgstr ""
5943 #. type: Content of: <book><chapter><sect1><sect2><para>
5944 #: ../en/ch05-collab.xml:844
5945 msgid ""
5946 "Both <command>ssh</command> and <command>plink</command> accept a <option "
5947 "role=\"cmd-opt-ssh\">-C</option> option which turns on compression. You can "
5948 "easily edit your <filename role=\"special\">~/.hgrc</filename> to enable "
5949 "compression for all of Mercurial's uses of the ssh protocol."
5950 msgstr ""
5952 #. type: Content of: <book><chapter><sect1><sect2><para>
5953 #: ../en/ch05-collab.xml:852
5954 msgid ""
5955 "If you use <command>ssh</command>, you can configure it to always use "
5956 "compression when talking to your server. To do this, edit your <filename "
5957 "role=\"special\">.ssh/config</filename> file (which may not yet exist), as "
5958 "follows."
5959 msgstr ""
5961 #. type: Content of: <book><chapter><sect1><sect2><para>
5962 #: ../en/ch05-collab.xml:860
5963 msgid ""
5964 "This defines an alias, <literal>hg</literal>. When you use it on the "
5965 "<command>ssh</command> command line or in a Mercurial <literal>ssh</literal>-"
5966 "protocol URL, it will cause <command>ssh</command> to connect to <literal>hg."
5967 "example.com</literal> and use compression. This gives you both a shorter "
5968 "name to type and compression, each of which is a good thing in its own right."
5969 msgstr ""
5971 #. type: Content of: <book><chapter><sect1><title>
5972 #: ../en/ch05-collab.xml:871
5973 msgid "Serving over HTTP using CGI"
5974 msgstr "使用 CGI 通过 HTTP 提供服务"
5976 #. type: Content of: <book><chapter><sect1><para>
5977 #: ../en/ch05-collab.xml:873
5978 msgid ""
5979 "Depending on how ambitious you are, configuring Mercurial's CGI interface can "
5980 "take anything from a few moments to several hours."
5981 msgstr ""
5983 #. type: Content of: <book><chapter><sect1><para>
5984 #: ../en/ch05-collab.xml:877
5985 msgid ""
5986 "We'll begin with the simplest of examples, and work our way towards a more "
5987 "complex configuration. Even for the most basic case, you're almost certainly "
5988 "going to need to read and modify your web server's configuration."
5989 msgstr ""
5991 #. type: Content of: <book><chapter><sect1><note><para>
5992 #: ../en/ch05-collab.xml:883
5993 msgid ""
5994 "Configuring a web server is a complex, fiddly, and highly system-dependent "
5995 "activity. I can't possibly give you instructions that will cover anything "
5996 "like all of the cases you will encounter. Please use your discretion and "
5997 "judgment in following the sections below. Be prepared to make plenty of "
5998 "mistakes, and to spend a lot of time reading your server's error logs."
5999 msgstr ""
6001 #. type: Content of: <book><chapter><sect1><sect2><title>
6002 #: ../en/ch05-collab.xml:893
6003 msgid "Web server configuration checklist"
6004 msgstr "Web 服务器配置检查表"
6006 #. type: Content of: <book><chapter><sect1><sect2><para>
6007 #: ../en/ch05-collab.xml:895
6008 msgid ""
6009 "Before you continue, do take a few moments to check a few aspects of your "
6010 "system's setup."
6011 msgstr ""
6013 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
6014 #: ../en/ch05-collab.xml:899
6015 msgid ""
6016 "Do you have a web server installed at all? Mac OS X ships with Apache, but "
6017 "many other systems may not have a web server installed."
6018 msgstr ""
6020 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
6021 #: ../en/ch05-collab.xml:903
6022 msgid ""
6023 "If you have a web server installed, is it actually running? On most systems, "
6024 "even if one is present, it will be disabled by default."
6025 msgstr ""
6027 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
6028 #: ../en/ch05-collab.xml:907
6029 msgid ""
6030 "Is your server configured to allow you to run CGI programs in the directory "
6031 "where you plan to do so? Most servers default to explicitly disabling the "
6032 "ability to run CGI programs."
6033 msgstr ""
6035 #. type: Content of: <book><chapter><sect1><sect2><para>
6036 #: ../en/ch05-collab.xml:913
6037 msgid ""
6038 "If you don't have a web server installed, and don't have substantial "
6039 "experience configuring Apache, you should consider using the "
6040 "<literal>lighttpd</literal> web server instead of Apache. Apache has a well-"
6041 "deserved reputation for baroque and confusing configuration. While "
6042 "<literal>lighttpd</literal> is less capable in some ways than Apache, most of "
6043 "these capabilities are not relevant to serving Mercurial repositories. And "
6044 "<literal>lighttpd</literal> is undeniably <emphasis>much</emphasis> easier to "
6045 "get started with than Apache."
6046 msgstr ""
6048 #. type: Content of: <book><chapter><sect1><sect2><title>
6049 #: ../en/ch05-collab.xml:926
6050 msgid "Basic CGI configuration"
6051 msgstr "基本 CGI 配置"
6053 #. type: Content of: <book><chapter><sect1><sect2><para>
6054 #: ../en/ch05-collab.xml:928
6055 msgid ""
6056 "On Unix-like systems, it's common for users to have a subdirectory named "
6057 "something like <filename class=\"directory\">public_html</filename> in their "
6058 "home directory, from which they can serve up web pages. A file named "
6059 "<filename>foo</filename> in this directory will be accessible at a URL of the "
6060 "form <literal>http://www.example.com/username/foo</literal>."
6061 msgstr ""
6063 #. type: Content of: <book><chapter><sect1><sect2><para>
6064 #: ../en/ch05-collab.xml:936
6065 msgid ""
6066 "To get started, find the <filename role=\"special\">hgweb.cgi</filename> "
6067 "script that should be present in your Mercurial installation. If you can't "
6068 "quickly find a local copy on your system, simply download one from the master "
6069 "Mercurial repository at <ulink url=\"http://www.selenic.com/repo/hg/raw-file/"
6070 "tip/hgweb.cgi\">http://www.selenic.com/repo/hg/raw-file/tip/hgweb.cgi</ulink>."
6071 msgstr ""
6073 #. type: Content of: <book><chapter><sect1><sect2><para>
6074 #: ../en/ch05-collab.xml:943 ../en/ch05-collab.xml:1112
6075 msgid ""
6076 "You'll need to copy this script into your <filename class=\"directory"
6077 "\">public_html</filename> directory, and ensure that it's executable."
6078 msgstr ""
6080 #. type: Content of: <book><chapter><sect1><sect2><para>
6081 #: ../en/ch05-collab.xml:948
6082 msgid ""
6083 "The <literal>755</literal> argument to <command>chmod</command> is a little "
6084 "more general than just making the script executable: it ensures that the "
6085 "script is executable by anyone, and that <quote>group</quote> and "
6086 "<quote>other</quote> write permissions are <emphasis>not</emphasis> set. If "
6087 "you were to leave those write permissions enabled, Apache's <literal>suexec</"
6088 "literal> subsystem would likely refuse to execute the script. In fact, "
6089 "<literal>suexec</literal> also insists that the <emphasis>directory</"
6090 "emphasis> in which the script resides must not be writable by others."
6091 msgstr ""
6093 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
6094 #: ../en/ch05-collab.xml:962
6095 msgid "What could <emphasis>possibly</emphasis> go wrong?"
6096 msgstr "什么<emphasis>可能</emphasis>会出错?"
6098 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
6099 #: ../en/ch05-collab.xml:965
6100 msgid ""
6101 "Once you've copied the CGI script into place, go into a web browser, and try "
6102 "to open the URL <ulink url=\"http://myhostname/ myuser/hgweb.cgi\">http://"
6103 "myhostname/ myuser/hgweb.cgi</ulink>, <emphasis>but</emphasis> brace yourself "
6104 "for instant failure. There's a high probability that trying to visit this "
6105 "URL will fail, and there are many possible reasons for this. In fact, you're "
6106 "likely to stumble over almost every one of the possible errors below, so "
6107 "please read carefully. The following are all of the problems I ran into on a "
6108 "system running Fedora 7, with a fresh installation of Apache, and a user "
6109 "account that I created specially to perform this exercise."
6110 msgstr ""
6112 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
6113 #: ../en/ch05-collab.xml:979
6114 msgid ""
6115 "Your web server may have per-user directories disabled. If you're using "
6116 "Apache, search your config file for a <literal>UserDir</literal> directive. "
6117 "If there's none present, per-user directories will be disabled. If one "
6118 "exists, but its value is <literal>disabled</literal>, then per-user "
6119 "directories will be disabled. Otherwise, the string after <literal>UserDir</"
6120 "literal> gives the name of the subdirectory that Apache will look in under "
6121 "your home directory, for example <filename class=\"directory\">public_html</"
6122 "filename>."
6123 msgstr ""
6125 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
6126 #: ../en/ch05-collab.xml:990
6127 msgid ""
6128 "Your file access permissions may be too restrictive. The web server must be "
6129 "able to traverse your home directory and directories under your <filename "
6130 "class=\"directory\">public_html</filename> directory, and read files under "
6131 "the latter too. Here's a quick recipe to help you to make your permissions "
6132 "more appropriate."
6133 msgstr ""
6135 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
6136 #: ../en/ch05-collab.xml:1000
6137 msgid ""
6138 "The other possibility with permissions is that you might get a completely "
6139 "empty window when you try to load the script. In this case, it's likely that "
6140 "your access permissions are <emphasis>too permissive</emphasis>. Apache's "
6141 "<literal>suexec</literal> subsystem won't execute a script that's group- or "
6142 "world-writable, for example."
6143 msgstr ""
6145 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
6146 #: ../en/ch05-collab.xml:1007
6147 msgid ""
6148 "Your web server may be configured to disallow execution of CGI programs in "
6149 "your per-user web directory. Here's Apache's default per-user configuration "
6150 "from my Fedora system."
6151 msgstr ""
6153 #. type: CDATA
6154 #: ../en/ch05-collab.xml:1012
6155 #, no-wrap
6156 msgid "&ch06-apache-config.lst;]]"
6157 msgstr ""
6159 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
6160 #: ../en/ch05-collab.xml:1014
6161 msgid ""
6162 "If you find a similar-looking <literal>Directory</literal> group in your "
6163 "Apache configuration, the directive to look at inside it is <literal>Options</"
6164 "literal>. Add <literal>ExecCGI</literal> to the end of this list if it's "
6165 "missing, and restart the web server."
6166 msgstr ""
6168 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
6169 #: ../en/ch05-collab.xml:1021
6170 msgid ""
6171 "If you find that Apache serves you the text of the CGI script instead of "
6172 "executing it, you may need to either uncomment (if already present) or add a "
6173 "directive like this."
6174 msgstr ""
6176 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
6177 #: ../en/ch05-collab.xml:1027
6178 msgid ""
6179 "The next possibility is that you might be served with a colourful Python "
6180 "backtrace claiming that it can't import a <literal>mercurial</literal>-"
6181 "related module. This is actually progress! The server is now capable of "
6182 "executing your CGI script. This error is only likely to occur if you're "
6183 "running a private installation of Mercurial, instead of a system-wide "
6184 "version. Remember that the web server runs the CGI program without any of "
6185 "the environment variables that you take for granted in an interactive "
6186 "session. If this error happens to you, edit your copy of <filename role="
6187 "\"special\">hgweb.cgi</filename> and follow the directions inside it to "
6188 "correctly set your <envar>PYTHONPATH</envar> environment variable."
6189 msgstr ""
6191 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
6192 #: ../en/ch05-collab.xml:1041
6193 msgid ""
6194 "Finally, you are <emphasis>certain</emphasis> to by served with another "
6195 "colourful Python backtrace: this one will complain that it can't find "
6196 "<filename class=\"directory\">/path/to/repository</filename>. Edit your "
6197 "<filename role=\"special\">hgweb.cgi</filename> script and replace the "
6198 "<filename class=\"directory\">/path/to/repository</filename> string with the "
6199 "complete path to the repository you want to serve up."
6200 msgstr ""
6202 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
6203 #: ../en/ch05-collab.xml:1051
6204 msgid ""
6205 "At this point, when you try to reload the page, you should be presented with "
6206 "a nice HTML view of your repository's history. Whew!"
6207 msgstr ""
6209 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
6210 #: ../en/ch05-collab.xml:1057
6211 msgid "Configuring lighttpd"
6212 msgstr "配置 lighttpd"
6214 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
6215 #: ../en/ch05-collab.xml:1059
6216 msgid ""
6217 "To be exhaustive in my experiments, I tried configuring the increasingly "
6218 "popular <literal>lighttpd</literal> web server to serve the same repository "
6219 "as I described with Apache above. I had already overcome all of the problems "
6220 "I outlined with Apache, many of which are not server-specific. As a result, "
6221 "I was fairly sure that my file and directory permissions were good, and that "
6222 "my <filename role=\"special\">hgweb.cgi</filename> script was properly edited."
6223 msgstr ""
6225 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
6226 #: ../en/ch05-collab.xml:1069
6227 msgid ""
6228 "Once I had Apache running, getting <literal>lighttpd</literal> to serve the "
6229 "repository was a snap (in other words, even if you're trying to use "
6230 "<literal>lighttpd</literal>, you should read the Apache section). I first "
6231 "had to edit the <literal>mod_access</literal> section of its config file to "
6232 "enable <literal>mod_cgi</literal> and <literal>mod_userdir</literal>, both of "
6233 "which were disabled by default on my system. I then added a few lines to the "
6234 "end of the config file, to configure these modules."
6235 msgstr ""
6237 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
6238 #: ../en/ch05-collab.xml:1081
6239 msgid ""
6240 "With this done, <literal>lighttpd</literal> ran immediately for me. If I had "
6241 "configured <literal>lighttpd</literal> before Apache, I'd almost certainly "
6242 "have run into many of the same system-level configuration problems as I did "
6243 "with Apache. However, I found <literal>lighttpd</literal> to be noticeably "
6244 "easier to configure than Apache, even though I've used Apache for over a "
6245 "decade, and this was my first exposure to <literal>lighttpd</literal>."
6246 msgstr ""
6248 #. type: Content of: <book><chapter><sect1><sect2><title>
6249 #: ../en/ch05-collab.xml:1094
6250 msgid "Sharing multiple repositories with one CGI script"
6251 msgstr "使用一个 CGI 脚本共享多个版本库"
6253 #. type: Content of: <book><chapter><sect1><sect2><para>
6254 #: ../en/ch05-collab.xml:1096
6255 msgid ""
6256 "The <filename role=\"special\">hgweb.cgi</filename> script only lets you "
6257 "publish a single repository, which is an annoying restriction. If you want "
6258 "to publish more than one without wracking yourself with multiple copies of "
6259 "the same script, each with different names, a better choice is to use the "
6260 "<filename role=\"special\">hgwebdir.cgi</filename> script."
6261 msgstr ""
6263 #. type: Content of: <book><chapter><sect1><sect2><para>
6264 #: ../en/ch05-collab.xml:1104
6265 msgid ""
6266 "The procedure to configure <filename role=\"special\">hgwebdir.cgi</filename> "
6267 "is only a little more involved than for <filename role=\"special\">hgweb.cgi</"
6268 "filename>. First, you must obtain a copy of the script. If you don't have "
6269 "one handy, you can download a copy from the master Mercurial repository at "
6270 "<ulink url=\"http://www.selenic.com/repo/hg/raw-file/tip/hgwebdir.cgi"
6271 "\">http://www.selenic.com/repo/hg/raw-file/tip/hgwebdir.cgi</ulink>."
6272 msgstr ""
6274 #. type: Content of: <book><chapter><sect1><sect2><para>
6275 #: ../en/ch05-collab.xml:1117
6276 msgid ""
6277 "With basic configuration out of the way, try to visit <ulink url=\"http://"
6278 "myhostname/ myuser/hgwebdir.cgi\">http://myhostname/ myuser/hgwebdir.cgi</"
6279 "ulink> in your browser. It should display an empty list of repositories. If "
6280 "you get a blank window or error message, try walking through the list of "
6281 "potential problems in section <xref linkend=\"sec.collab.wtf\"/>."
6282 msgstr ""
6284 #. type: Content of: <book><chapter><sect1><sect2><para>
6285 #: ../en/ch05-collab.xml:1126
6286 msgid ""
6287 "The <filename role=\"special\">hgwebdir.cgi</filename> script relies on an "
6288 "external configuration file. By default, it searches for a file named "
6289 "<filename role=\"special\">hgweb.config</filename> in the same directory as "
6290 "itself. You'll need to create this file, and make it world-readable. The "
6291 "format of the file is similar to a Windows <quote>ini</quote> file, as "
6292 "understood by Python's <literal>ConfigParser</literal> <citation>web:"
6293 "configparser</citation> module."
6294 msgstr ""
6296 #. type: Content of: <book><chapter><sect1><sect2><para>
6297 #: ../en/ch05-collab.xml:1136
6298 msgid ""
6299 "The easiest way to configure <filename role=\"special\">hgwebdir.cgi</"
6300 "filename> is with a section named <literal>collections</literal>. This will "
6301 "automatically publish <emphasis>every</emphasis> repository under the "
6302 "directories you name. The section should look like this:"
6303 msgstr ""
6305 #. type: Content of: <book><chapter><sect1><sect2><para>
6306 #: ../en/ch05-collab.xml:1144
6307 msgid ""
6308 "Mercurial interprets this by looking at the directory name on the "
6309 "<emphasis>right</emphasis> hand side of the <quote><literal>=</literal></"
6310 "quote> sign; finding repositories in that directory hierarchy; and using the "
6311 "text on the <emphasis>left</emphasis> to strip off matching text from the "
6312 "names it will actually list in the web interface. The remaining component of "
6313 "a path after this stripping has occurred is called a <quote>virtual path</"
6314 "quote>."
6315 msgstr ""
6317 #. type: Content of: <book><chapter><sect1><sect2><para>
6318 #: ../en/ch05-collab.xml:1153
6319 msgid ""
6320 "Given the example above, if we have a repository whose local path is "
6321 "<filename class=\"directory\">/my/root/this/repo</filename>, the CGI script "
6322 "will strip the leading <filename class=\"directory\">/my/root</filename> from "
6323 "the name, and publish the repository with a virtual path of <filename class="
6324 "\"directory\">this/repo</filename>. If the base URL for our CGI script is "
6325 "<ulink url=\"http://myhostname/ myuser/hgwebdir.cgi\">http://myhostname/ "
6326 "myuser/hgwebdir.cgi</ulink>, the complete URL for that repository will be "
6327 "<ulink url=\"http://myhostname/ myuser/hgwebdir.cgi/this/repo\">http://"
6328 "myhostname/ myuser/hgwebdir.cgi/this/repo</ulink>."
6329 msgstr ""
6331 #. type: Content of: <book><chapter><sect1><sect2><para>
6332 #: ../en/ch05-collab.xml:1167
6333 msgid ""
6334 "If we replace <filename class=\"directory\">/my/root</filename> on the left "
6335 "hand side of this example with <filename class=\"directory\">/my</filename>, "
6336 "then <filename role=\"special\">hgwebdir.cgi</filename> will only strip off "
6337 "<filename class=\"directory\">/my</filename> from the repository name, and "
6338 "will give us a virtual path of <filename class=\"directory\">root/this/repo</"
6339 "filename> instead of <filename class=\"directory\">this/repo</filename>."
6340 msgstr ""
6342 #. type: Content of: <book><chapter><sect1><sect2><para>
6343 #: ../en/ch05-collab.xml:1177
6344 msgid ""
6345 "The <filename role=\"special\">hgwebdir.cgi</filename> script will "
6346 "recursively search each directory listed in the <literal>collections</"
6347 "literal> section of its configuration file, but it will <literal>not</"
6348 "literal> recurse into the repositories it finds."
6349 msgstr ""
6351 #. type: Content of: <book><chapter><sect1><sect2><para>
6352 #: ../en/ch05-collab.xml:1183
6353 msgid ""
6354 "The <literal>collections</literal> mechanism makes it easy to publish many "
6355 "repositories in a <quote>fire and forget</quote> manner. You only need to "
6356 "set up the CGI script and configuration file one time. Afterwards, you can "
6357 "publish or unpublish a repository at any time by simply moving it into, or "
6358 "out of, the directory hierarchy in which you've configured <filename role="
6359 "\"special\">hgwebdir.cgi</filename> to look."
6360 msgstr ""
6362 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
6363 #: ../en/ch05-collab.xml:1193
6364 msgid "Explicitly specifying which repositories to publish"
6365 msgstr "明确指出要发布的版本库"
6367 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
6368 #: ../en/ch05-collab.xml:1196
6369 msgid ""
6370 "In addition to the <literal>collections</literal> mechanism, the <filename "
6371 "role=\"special\">hgwebdir.cgi</filename> script allows you to publish a "
6372 "specific list of repositories. To do so, create a <literal>paths</literal> "
6373 "section, with contents of the following form."
6374 msgstr ""
6376 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
6377 #: ../en/ch05-collab.xml:1205
6378 msgid ""
6379 "In this case, the virtual path (the component that will appear in a URL) is "
6380 "on the left hand side of each definition, while the path to the repository is "
6381 "on the right. Notice that there does not need to be any relationship between "
6382 "the virtual path you choose and the location of a repository in your "
6383 "filesystem."
6384 msgstr ""
6386 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
6387 #: ../en/ch05-collab.xml:1212
6388 msgid ""
6389 "If you wish, you can use both the <literal>collections</literal> and "
6390 "<literal>paths</literal> mechanisms simultaneously in a single configuration "
6391 "file."
6392 msgstr ""
6394 #. type: Content of: <book><chapter><sect1><sect2><sect3><note><para>
6395 #: ../en/ch05-collab.xml:1218
6396 msgid ""
6397 "If multiple repositories have the same virtual path, <filename role=\"special"
6398 "\">hgwebdir.cgi</filename> will not report an error. Instead, it will behave "
6399 "unpredictably."
6400 msgstr ""
6402 #. type: Content of: <book><chapter><sect1><sect2><title>
6403 #: ../en/ch05-collab.xml:1227
6404 msgid "Downloading source archives"
6405 msgstr "下载源代码档案包"
6407 #. type: Content of: <book><chapter><sect1><sect2><para>
6408 #: ../en/ch05-collab.xml:1229
6409 msgid ""
6410 "Mercurial's web interface lets users download an archive of any revision. "
6411 "This archive will contain a snapshot of the working directory as of that "
6412 "revision, but it will not contain a copy of the repository data."
6413 msgstr ""
6415 #. type: Content of: <book><chapter><sect1><sect2><para>
6416 #: ../en/ch05-collab.xml:1234
6417 msgid ""
6418 "By default, this feature is not enabled. To enable it, you'll need to add an "
6419 "<envar role=\"rc-item-web\">allow_archive</envar> item to the <literal role="
6420 "\"rc-web\">web</literal> section of your <filename role=\"special\">~/.hgrc</"
6421 "filename>."
6422 msgstr ""
6424 #. type: Content of: <book><chapter><sect1><sect2><title>
6425 #: ../en/ch05-collab.xml:1242
6426 msgid "Web configuration options"
6427 msgstr "Web 配置选项"
6429 #. type: Content of: <book><chapter><sect1><sect2><para>
6430 #: ../en/ch05-collab.xml:1244
6431 msgid ""
6432 "Mercurial's web interfaces (the <command role=\"hg-cmd\">hg serve</command> "
6433 "command, and the <filename role=\"special\">hgweb.cgi</filename> and "
6434 "<filename role=\"special\">hgwebdir.cgi</filename> scripts) have a number of "
6435 "configuration options that you can set. These belong in a section named "
6436 "<literal role=\"rc-web\">web</literal>."
6437 msgstr ""
6439 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6440 #: ../en/ch05-collab.xml:1252
6441 msgid ""
6442 "<envar role=\"rc-item-web\">allow_archive</envar>: Determines which (if any) "
6443 "archive download mechanisms Mercurial supports. If you enable this feature, "
6444 "users of the web interface will be able to download an archive of whatever "
6445 "revision of a repository they are viewing. To enable the archive feature, "
6446 "this item must take the form of a sequence of words drawn from the list below."
6447 msgstr ""
6449 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
6450 #: ../en/ch05-collab.xml:1261
6451 msgid ""
6452 "<literal>bz2</literal>: A <command>tar</command> archive, compressed using "
6453 "<literal>bzip2</literal> compression. This has the best compression ratio, "
6454 "but uses the most CPU time on the server."
6455 msgstr ""
6457 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
6458 #: ../en/ch05-collab.xml:1267
6459 msgid ""
6460 "<literal>gz</literal>: A <command>tar</command> archive, compressed using "
6461 "<literal>gzip</literal> compression."
6462 msgstr ""
6464 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
6465 #: ../en/ch05-collab.xml:1271
6466 msgid ""
6467 "<literal>zip</literal>: A <command>zip</command> archive, compressed using "
6468 "LZW compression. This format has the worst compression ratio, but is widely "
6469 "used in the Windows world."
6470 msgstr ""
6472 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6473 #: ../en/ch05-collab.xml:1277
6474 msgid ""
6475 "If you provide an empty list, or don't have an <envar role=\"rc-item-web"
6476 "\">allow_archive</envar> entry at all, this feature will be disabled. Here "
6477 "is an example of how to enable all three supported formats."
6478 msgstr ""
6480 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6481 #: ../en/ch05-collab.xml:1284
6482 msgid ""
6483 "<envar role=\"rc-item-web\">allowpull</envar>: Boolean. Determines whether "
6484 "the web interface allows remote users to <command role=\"hg-cmd\">hg pull</"
6485 "command> and <command role=\"hg-cmd\">hg clone</command> this repository over "
6486 "HTTP. If set to <literal>no</literal> or <literal>false</literal>, only the "
6487 "<quote>human-oriented</quote> portion of the web interface is available."
6488 msgstr ""
6490 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6491 #: ../en/ch05-collab.xml:1293
6492 msgid ""
6493 "<envar role=\"rc-item-web\">contact</envar>: String. A free-form (but "
6494 "preferably brief) string identifying the person or group in charge of the "
6495 "repository. This often contains the name and email address of a person or "
6496 "mailing list. It often makes sense to place this entry in a repository's own "
6497 "<filename role=\"special\">.hg/hgrc</filename> file, but it can make sense to "
6498 "use in a global <filename role=\"special\">~/.hgrc</filename> if every "
6499 "repository has a single maintainer."
6500 msgstr ""
6502 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6503 #: ../en/ch05-collab.xml:1304
6504 msgid ""
6505 "<envar role=\"rc-item-web\">maxchanges</envar>: Integer. The default maximum "
6506 "number of changesets to display in a single page of output."
6507 msgstr ""
6509 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6510 #: ../en/ch05-collab.xml:1308
6511 msgid ""
6512 "<envar role=\"rc-item-web\">maxfiles</envar>: Integer. The default maximum "
6513 "number of modified files to display in a single page of output."
6514 msgstr ""
6516 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6517 #: ../en/ch05-collab.xml:1312
6518 msgid ""
6519 "<envar role=\"rc-item-web\">stripes</envar>: Integer. If the web interface "
6520 "displays alternating <quote>stripes</quote> to make it easier to visually "
6521 "align rows when you are looking at a table, this number controls the number "
6522 "of rows in each stripe."
6523 msgstr ""
6525 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6526 #: ../en/ch05-collab.xml:1318
6527 msgid ""
6528 "<envar role=\"rc-item-web\">style</envar>: Controls the template Mercurial "
6529 "uses to display the web interface. Mercurial ships with two web templates, "
6530 "named <literal>default</literal> and <literal>gitweb</literal> (the latter is "
6531 "much more visually attractive). You can also specify a custom template of "
6532 "your own; see chapter <xref linkend=\"chap.template\"/> for details. Here, "
6533 "you can see how to enable the <literal>gitweb</literal> style."
6534 msgstr ""
6536 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6537 #: ../en/ch05-collab.xml:1330
6538 msgid ""
6539 "<envar role=\"rc-item-web\">templates</envar>: Path. The directory in which "
6540 "to search for template files. By default, Mercurial searches in the "
6541 "directory in which it was installed."
6542 msgstr ""
6544 #. type: Content of: <book><chapter><sect1><sect2><para>
6545 #: ../en/ch05-collab.xml:1335
6546 msgid ""
6547 "If you are using <filename role=\"special\">hgwebdir.cgi</filename>, you can "
6548 "place a few configuration items in a <literal role=\"rc-web\">web</literal> "
6549 "section of the <filename role=\"special\">hgweb.config</filename> file "
6550 "instead of a <filename role=\"special\">~/.hgrc</filename> file, for "
6551 "convenience. These items are <envar role=\"rc-item-web\">motd</envar> and "
6552 "<envar role=\"rc-item-web\">style</envar>."
6553 msgstr ""
6555 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
6556 #: ../en/ch05-collab.xml:1346
6557 msgid "Options specific to an individual repository"
6558 msgstr "针对单个版本库的选项"
6560 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
6561 #: ../en/ch05-collab.xml:1348
6562 msgid ""
6563 "A few <literal role=\"rc-web\">web</literal> configuration items ought to be "
6564 "placed in a repository's local <filename role=\"special\">.hg/hgrc</"
6565 "filename>, rather than a user's or global <filename role=\"special\">~/.hgrc</"
6566 "filename>."
6567 msgstr ""
6569 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
6570 #: ../en/ch05-collab.xml:1353
6571 msgid ""
6572 "<envar role=\"rc-item-web\">description</envar>: String. A free-form (but "
6573 "preferably brief) string that describes the contents or purpose of the "
6574 "repository."
6575 msgstr ""
6577 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
6578 #: ../en/ch05-collab.xml:1358
6579 msgid ""
6580 "<envar role=\"rc-item-web\">name</envar>: String. The name to use for the "
6581 "repository in the web interface. This overrides the default name, which is "
6582 "the last component of the repository's path."
6583 msgstr ""
6585 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
6586 #: ../en/ch05-collab.xml:1366
6587 msgid ""
6588 "Options specific to the <command role=\"hg-cmd\">hg serve</command> command"
6589 msgstr "命令 <command role=\"hg-cmd\">hg serve</command> 的选项"
6591 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
6592 #: ../en/ch05-collab.xml:1369
6593 msgid ""
6594 "Some of the items in the <literal role=\"rc-web\">web</literal> section of a "
6595 "<filename role=\"special\">~/.hgrc</filename> file are only for use with the "
6596 "<command role=\"hg-cmd\">hg serve</command> command."
6597 msgstr ""
6599 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
6600 #: ../en/ch05-collab.xml:1375
6601 msgid ""
6602 "<envar role=\"rc-item-web\">accesslog</envar>: Path. The name of a file into "
6603 "which to write an access log. By default, the <command role=\"hg-cmd\">hg "
6604 "serve</command> command writes this information to standard output, not to a "
6605 "file. Log entries are written in the standard <quote>combined</quote> file "
6606 "format used by almost all web servers."
6607 msgstr ""
6609 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
6610 #: ../en/ch05-collab.xml:1383
6611 msgid ""
6612 "<envar role=\"rc-item-web\">address</envar>: String. The local address on "
6613 "which the server should listen for incoming connections. By default, the "
6614 "server listens on all addresses."
6615 msgstr ""
6617 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
6618 #: ../en/ch05-collab.xml:1388
6619 msgid ""
6620 "<envar role=\"rc-item-web\">errorlog</envar>: Path. The name of a file into "
6621 "which to write an error log. By default, the <command role=\"hg-cmd\">hg "
6622 "serve</command> command writes this information to standard error, not to a "
6623 "file."
6624 msgstr ""
6626 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
6627 #: ../en/ch05-collab.xml:1394
6628 msgid ""
6629 "<envar role=\"rc-item-web\">ipv6</envar>: Boolean. Whether to use the IPv6 "
6630 "protocol. By default, IPv6 is not used."
6631 msgstr ""
6633 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
6634 #: ../en/ch05-collab.xml:1398
6635 msgid ""
6636 "<envar role=\"rc-item-web\">port</envar>: Integer. The TCP port number on "
6637 "which the server should listen. The default port number used is 8000."
6638 msgstr ""
6640 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
6641 #: ../en/ch05-collab.xml:1405
6642 #, fuzzy
6643 msgid ""
6644 "Choosing the right <filename role=\"special\">~/.hgrc</filename> file to add "
6645 "<literal role=\"rc-web\">web</literal> items to"
6646 msgstr ""
6647 "选择正确的 <filename role=\"special\"> /.hgrc</filename> 文件增加到 <literal "
6648 "role=\"rc-web\">web</literal> 条目"
6650 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
6651 #: ../en/ch05-collab.xml:1409
6652 msgid ""
6653 "It is important to remember that a web server like Apache or "
6654 "<literal>lighttpd</literal> will run under a user ID that is different to "
6655 "yours. CGI scripts run by your server, such as <filename role=\"special"
6656 "\">hgweb.cgi</filename>, will usually also run under that user ID."
6657 msgstr ""
6659 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
6660 #: ../en/ch05-collab.xml:1416
6661 msgid ""
6662 "If you add <literal role=\"rc-web\">web</literal> items to your own personal "
6663 "<filename role=\"special\">~/.hgrc</filename> file, CGI scripts won't read "
6664 "that <filename role=\"special\">~/.hgrc</filename> file. Those settings will "
6665 "thus only affect the behaviour of the <command role=\"hg-cmd\">hg serve</"
6666 "command> command when you run it. To cause CGI scripts to see your settings, "
6667 "either create a <filename role=\"special\">~/.hgrc</filename> file in the "
6668 "home directory of the user ID that runs your web server, or add those "
6669 "settings to a system-wide <filename role=\"special\">~/.hgrc</filename> file."
6670 msgstr ""
6672 #. type: Content of: <book><chapter><title>
6673 #: ../en/ch06-filenames.xml:5
6674 msgid "File names and pattern matching"
6675 msgstr "文件名称与模式匹配"
6677 #. type: Content of: <book><chapter><para>
6678 #: ../en/ch06-filenames.xml:7
6679 msgid ""
6680 "Mercurial provides mechanisms that let you work with file names in a "
6681 "consistent and expressive way."
6682 msgstr ""
6684 #. type: Content of: <book><chapter><sect1><title>
6685 #: ../en/ch06-filenames.xml:11
6686 msgid "Simple file naming"
6687 msgstr "简单文件名称"
6689 #. type: Content of: <book><chapter><sect1><para>
6690 #: ../en/ch06-filenames.xml:13
6691 msgid ""
6692 "Mercurial uses a unified piece of machinery <quote>under the hood</quote> to "
6693 "handle file names. Every command behaves uniformly with respect to file "
6694 "names. The way in which commands work with file names is as follows."
6695 msgstr ""
6697 #. type: Content of: <book><chapter><sect1><para>
6698 #: ../en/ch06-filenames.xml:18
6699 msgid ""
6700 "If you explicitly name real files on the command line, Mercurial works with "
6701 "exactly those files, as you would expect. &interaction.filenames.files;"
6702 msgstr ""
6705 #. type: Content of: <book><chapter><sect1><para>
6706 #: ../en/ch06-filenames.xml:22
6707 msgid ""
6708 "When you provide a directory name, Mercurial will interpret this as "
6709 "<quote>operate on every file in this directory and its subdirectories</"
6710 "quote>. Mercurial traverses the files and subdirectories in a directory in "
6711 "alphabetical order. When it encounters a subdirectory, it will traverse that "
6712 "subdirectory before continuing with the current directory."
6713 msgstr ""
6715 #. type: Content of: <book><chapter><sect1><title>
6716 #: ../en/ch06-filenames.xml:33
6717 msgid "Running commands without any file names"
6718 msgstr "不提供文件名称的执行命令"
6720 #. type: Content of: <book><chapter><sect1><para>
6721 #: ../en/ch06-filenames.xml:35
6722 msgid ""
6723 "Mercurial's commands that work with file names have useful default behaviours "
6724 "when you invoke them without providing any file names or patterns. What kind "
6725 "of behaviour you should expect depends on what the command does. Here are a "
6726 "few rules of thumb you can use to predict what a command is likely to do if "
6727 "you don't give it any names to work with."
6728 msgstr ""
6730 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
6731 #: ../en/ch06-filenames.xml:42
6732 msgid ""
6733 "Most commands will operate on the entire working directory. This is what the "
6734 "<command role=\"hg-cmd\">hg add</command> command does, for example."
6735 msgstr ""
6737 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
6738 #: ../en/ch06-filenames.xml:46
6739 msgid ""
6740 "If the command has effects that are difficult or impossible to reverse, it "
6741 "will force you to explicitly provide at least one name or pattern (see "
6742 "below). This protects you from accidentally deleting files by running "
6743 "<command role=\"hg-cmd\">hg remove</command> with no arguments, for example."
6744 msgstr ""
6747 #. type: Content of: <book><chapter><sect1><para>
6748 #: ../en/ch06-filenames.xml:54
6749 msgid ""
6750 "It's easy to work around these default behaviours if they don't suit you. If "
6751 "a command normally operates on the whole working directory, you can invoke it "
6752 "on just the current directory and its subdirectories by giving it the name "
6753 "<quote><filename class=\"directory\">.</filename></quote>."
6754 msgstr ""
6757 #. type: Content of: <book><chapter><sect1><para>
6758 #: ../en/ch06-filenames.xml:62
6759 msgid ""
6760 "Along the same lines, some commands normally print file names relative to the "
6761 "root of the repository, even if you're invoking them from a subdirectory. "
6762 "Such a command will print file names relative to your subdirectory if you "
6763 "give it explicit names. Here, we're going to run <command role=\"hg-cmd\">hg "
6764 "status</command> from a subdirectory, and get it to operate on the entire "
6765 "working directory while printing file names relative to our subdirectory, by "
6766 "passing it the output of the <command role=\"hg-cmd\">hg root</command> "
6767 "command."
6768 msgstr ""
6770 #. type: Content of: <book><chapter><sect1><title>
6771 #: ../en/ch06-filenames.xml:76
6772 msgid "Telling you what's going on"
6773 msgstr "告诉你正在做什么"
6775 #. type: Content of: <book><chapter><sect1><para>
6776 #: ../en/ch06-filenames.xml:78
6777 msgid ""
6778 "The <command role=\"hg-cmd\">hg add</command> example in the preceding "
6779 "section illustrates something else that's helpful about Mercurial commands. "
6780 "If a command operates on a file that you didn't name explicitly on the "
6781 "command line, it will usually print the name of the file, so that you will "
6782 "not be surprised what's going on."
6783 msgstr ""
6785 #. type: Content of: <book><chapter><sect1><para>
6786 #: ../en/ch06-filenames.xml:85
6787 msgid ""
6788 "The principle here is of <emphasis>least surprise</emphasis>. If you've "
6789 "exactly named a file on the command line, there's no point in repeating it "
6790 "back at you. If Mercurial is acting on a file <emphasis>implicitly</"
6791 "emphasis>, because you provided no names, or a directory, or a pattern (see "
6792 "below), it's safest to tell you what it's doing."
6793 msgstr ""
6795 #. type: Content of: <book><chapter><sect1><para>
6796 #: ../en/ch06-filenames.xml:92
6797 msgid ""
6798 "For commands that behave this way, you can silence them using the <option "
6799 "role=\"hg-opt-global\">-q</option> option. You can also get them to print "
6800 "the name of every file, even those you've named explicitly, using the <option "
6801 "role=\"hg-opt-global\">-v</option> option."
6802 msgstr ""
6804 #. type: Content of: <book><chapter><sect1><title>
6805 #: ../en/ch06-filenames.xml:100
6806 msgid "Using patterns to identify files"
6807 msgstr "使用模式标识文件"
6809 #. type: Content of: <book><chapter><sect1><para>
6810 #: ../en/ch06-filenames.xml:102
6811 msgid ""
6812 "In addition to working with file and directory names, Mercurial lets you use "
6813 "<emphasis>patterns</emphasis> to identify files. Mercurial's pattern "
6814 "handling is expressive."
6815 msgstr ""
6817 #. type: Content of: <book><chapter><sect1><para>
6818 #: ../en/ch06-filenames.xml:106
6819 msgid ""
6820 "On Unix-like systems (Linux, MacOS, etc.), the job of matching file names to "
6821 "patterns normally falls to the shell. On these systems, you must explicitly "
6822 "tell Mercurial that a name is a pattern. On Windows, the shell does not "
6823 "expand patterns, so Mercurial will automatically identify names that are "
6824 "patterns, and expand them for you."
6825 msgstr ""
6827 #. type: Content of: <book><chapter><sect1><para>
6828 #: ../en/ch06-filenames.xml:113
6829 msgid ""
6830 "To provide a pattern in place of a regular name on the command line, the "
6831 "mechanism is simple:"
6832 msgstr ""
6834 #. type: Content of: <book><chapter><sect1><para>
6835 #: ../en/ch06-filenames.xml:116
6836 msgid ""
6837 "That is, a pattern is identified by a short text string that says what kind "
6838 "of pattern this is, followed by a colon, followed by the actual pattern."
6839 msgstr ""
6841 #. type: Content of: <book><chapter><sect1><para>
6842 #: ../en/ch06-filenames.xml:120
6843 msgid ""
6844 "Mercurial supports two kinds of pattern syntax. The most frequently used is "
6845 "called <literal>glob</literal>; this is the same kind of pattern matching "
6846 "used by the Unix shell, and should be familiar to Windows command prompt "
6847 "users, too."
6848 msgstr ""
6850 #. type: Content of: <book><chapter><sect1><para>
6851 #: ../en/ch06-filenames.xml:125
6852 msgid ""
6853 "When Mercurial does automatic pattern matching on Windows, it uses "
6854 "<literal>glob</literal> syntax. You can thus omit the <quote><literal>glob:</"
6855 "literal></quote> prefix on Windows, but it's safe to use it, too."
6856 msgstr ""
6858 #. type: Content of: <book><chapter><sect1><para>
6859 #: ../en/ch06-filenames.xml:130
6860 msgid ""
6861 "The <literal>re</literal> syntax is more powerful; it lets you specify "
6862 "patterns using regular expressions, also known as regexps."
6863 msgstr ""
6865 #. type: Content of: <book><chapter><sect1><para>
6866 #: ../en/ch06-filenames.xml:134
6867 msgid ""
6868 "By the way, in the examples that follow, notice that I'm careful to wrap all "
6869 "of my patterns in quote characters, so that they won't get expanded by the "
6870 "shell before Mercurial sees them."
6871 msgstr ""
6873 #. type: Content of: <book><chapter><sect1><sect2><title>
6874 #: ../en/ch06-filenames.xml:140
6875 msgid "Shell-style <literal>glob</literal> patterns"
6876 msgstr "外壳风格的 <literal>glob</literal> 模式"
6878 #. type: Content of: <book><chapter><sect1><sect2><para>
6879 #: ../en/ch06-filenames.xml:142
6880 msgid ""
6881 "This is an overview of the kinds of patterns you can use when you're matching "
6882 "on glob patterns."
6883 msgstr ""
6886 #. type: Content of: <book><chapter><sect1><sect2><para>
6887 #: ../en/ch06-filenames.xml:145
6888 msgid ""
6889 "The <quote><literal>*</literal></quote> character matches any string, within "
6890 "a single directory."
6891 msgstr ""
6894 #. type: Content of: <book><chapter><sect1><sect2><para>
6895 #: ../en/ch06-filenames.xml:150
6896 msgid ""
6897 "The <quote><literal>**</literal></quote> pattern matches any string, and "
6898 "crosses directory boundaries. It's not a standard Unix glob token, but it's "
6899 "accepted by several popular Unix shells, and is very useful."
6900 msgstr ""
6903 #. type: Content of: <book><chapter><sect1><sect2><para>
6904 #: ../en/ch06-filenames.xml:157
6905 msgid ""
6906 "The <quote><literal>?</literal></quote> pattern matches any single character."
6907 msgstr ""
6909 #. type: Content of: <book><chapter><sect1><sect2><para>
6910 #: ../en/ch06-filenames.xml:162
6911 msgid ""
6912 "The <quote><literal>[</literal></quote> character begins a "
6913 "<emphasis>character class</emphasis>. This matches any single character "
6914 "within the class. The class ends with a <quote><literal>]</literal></quote> "
6915 "character. A class may contain multiple <emphasis>range</emphasis>s of the "
6916 "form <quote><literal>a-f</literal></quote>, which is shorthand for "
6917 "<quote><literal>abcdef</literal></quote>."
6918 msgstr ""
6920 #. type: Content of: <book><chapter><sect1><sect2><para>
6921 #: ../en/ch06-filenames.xml:172
6922 msgid ""
6923 "If the first character after the <quote><literal>[</literal></quote> in a "
6924 "character class is a <quote><literal>!</literal></quote>, it "
6925 "<emphasis>negates</emphasis> the class, making it match any single character "
6926 "not in the class."
6927 msgstr ""
6929 #. type: Content of: <book><chapter><sect1><sect2><para>
6930 #: ../en/ch06-filenames.xml:178
6931 msgid ""
6932 "A <quote><literal>{</literal></quote> begins a group of subpatterns, where "
6933 "the whole group matches if any subpattern in the group matches. The "
6934 "<quote><literal>,</literal></quote> character separates subpatterns, and "
6935 "<quote><literal>}</literal></quote> ends the group."
6936 msgstr ""
6938 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
6939 #: ../en/ch06-filenames.xml:187
6940 msgid "Watch out!"
6941 msgstr "千万小心!"
6944 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
6945 #: ../en/ch06-filenames.xml:189
6946 msgid ""
6947 "Don't forget that if you want to match a pattern in any directory, you should "
6948 "not be using the <quote><literal>*</literal></quote> match-any token, as this "
6949 "will only match within one directory. Instead, use the <quote><literal>**</"
6950 "literal></quote> token. This small example illustrates the difference "
6951 "between the two."
6952 msgstr ""
6954 #. type: Content of: <book><chapter><sect1><sect2><title>
6955 #: ../en/ch06-filenames.xml:201
6956 msgid "Regular expression matching with <literal>re</literal> patterns"
6957 msgstr "使用 <literal>re</literal> 模式的正则表达式匹配"
6959 #. type: Content of: <book><chapter><sect1><sect2><para>
6960 #: ../en/ch06-filenames.xml:204
6961 msgid ""
6962 "Mercurial accepts the same regular expression syntax as the Python "
6963 "programming language (it uses Python's regexp engine internally). This is "
6964 "based on the Perl language's regexp syntax, which is the most popular dialect "
6965 "in use (it's also used in Java, for example)."
6966 msgstr ""
6968 #. type: Content of: <book><chapter><sect1><sect2><para>
6969 #: ../en/ch06-filenames.xml:210
6970 msgid ""
6971 "I won't discuss Mercurial's regexp dialect in any detail here, as regexps are "
6972 "not often used. Perl-style regexps are in any case already exhaustively "
6973 "documented on a multitude of web sites, and in many books. Instead, I will "
6974 "focus here on a few things you should know if you find yourself needing to "
6975 "use regexps with Mercurial."
6976 msgstr ""
6978 #. type: Content of: <book><chapter><sect1><sect2><para>
6979 #: ../en/ch06-filenames.xml:217
6980 msgid ""
6981 "A regexp is matched against an entire file name, relative to the root of the "
6982 "repository. In other words, even if you're already in subbdirectory "
6983 "<filename class=\"directory\">foo</filename>, if you want to match files "
6984 "under this directory, your pattern must start with <quote><literal>foo/</"
6985 "literal></quote>."
6986 msgstr ""
6988 #. type: Content of: <book><chapter><sect1><sect2><para>
6989 #: ../en/ch06-filenames.xml:224
6990 msgid ""
6991 "One thing to note, if you're familiar with Perl-style regexps, is that "
6992 "Mercurial's are <emphasis>rooted</emphasis>. That is, a regexp starts "
6993 "matching against the beginning of a string; it doesn't look for a match "
6994 "anywhere within the string. To match anywhere in a string, start your "
6995 "pattern with <quote><literal>.*</literal></quote>."
6996 msgstr ""
6998 #. type: Content of: <book><chapter><sect1><title>
6999 #: ../en/ch06-filenames.xml:234
7000 msgid "Filtering files"
7001 msgstr "过滤文件"
7003 #. type: Content of: <book><chapter><sect1><para>
7004 #: ../en/ch06-filenames.xml:236
7005 msgid ""
7006 "Not only does Mercurial give you a variety of ways to specify files; it lets "
7007 "you further winnow those files using <emphasis>filters</emphasis>. Commands "
7008 "that work with file names accept two filtering options."
7009 msgstr ""
7011 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
7012 #: ../en/ch06-filenames.xml:241
7013 msgid ""
7014 "<option role=\"hg-opt-global\">-I</option>, or <option role=\"hg-opt-global"
7015 "\">--include</option>, lets you specify a pattern that file names must match "
7016 "in order to be processed."
7017 msgstr ""
7019 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
7020 #: ../en/ch06-filenames.xml:246
7021 msgid ""
7022 "<option role=\"hg-opt-global\">-X</option>, or <option role=\"hg-opt-global"
7023 "\">--exclude</option>, gives you a way to <emphasis>avoid</emphasis> "
7024 "processing files, if they match this pattern."
7025 msgstr ""
7027 #. type: Content of: <book><chapter><sect1><para>
7028 #: ../en/ch06-filenames.xml:251
7029 msgid ""
7030 "You can provide multiple <option role=\"hg-opt-global\">-I</option> and "
7031 "<option role=\"hg-opt-global\">-X</option> options on the command line, and "
7032 "intermix them as you please. Mercurial interprets the patterns you provide "
7033 "using glob syntax by default (but you can use regexps if you need to)."
7034 msgstr ""
7036 #. type: Content of: <book><chapter><sect1><para>
7037 #: ../en/ch06-filenames.xml:258
7038 msgid ""
7039 "You can read a <option role=\"hg-opt-global\">-I</option> filter as "
7040 "<quote>process only the files that match this filter</quote>."
7041 msgstr ""
7043 #. type: Content of: <book><chapter><sect1><para>
7044 #: ../en/ch06-filenames.xml:264
7045 msgid ""
7046 "The <option role=\"hg-opt-global\">-X</option> filter is best read as "
7047 "<quote>process only the files that don't match this pattern</quote>."
7048 msgstr ""
7050 #. type: Content of: <book><chapter><sect1><title>
7051 #: ../en/ch06-filenames.xml:272
7052 msgid "Ignoring unwanted files and directories"
7053 msgstr "忽略不需要的文件和目录"
7055 #. type: Content of: <book><chapter><sect1><para>
7056 #: ../en/ch06-filenames.xml:274
7057 msgid "XXX."
7058 msgstr ""
7060 #. type: Content of: <book><chapter><sect1><title>
7061 #: ../en/ch06-filenames.xml:278
7062 msgid "Case sensitivity"
7063 msgstr "大小写敏感性"
7065 #. type: Content of: <book><chapter><sect1><para>
7066 #: ../en/ch06-filenames.xml:280
7067 msgid ""
7068 "If you're working in a mixed development environment that contains both Linux "
7069 "(or other Unix) systems and Macs or Windows systems, you should keep in the "
7070 "back of your mind the knowledge that they treat the case (<quote>N</quote> "
7071 "versus <quote>n</quote>) of file names in incompatible ways. This is not "
7072 "very likely to affect you, and it's easy to deal with if it does, but it "
7073 "could surprise you if you don't know about it."
7074 msgstr ""
7076 #. type: Content of: <book><chapter><sect1><para>
7077 #: ../en/ch06-filenames.xml:289
7078 msgid ""
7079 "Operating systems and filesystems differ in the way they handle the "
7080 "<emphasis>case</emphasis> of characters in file and directory names. There "
7081 "are three common ways to handle case in names."
7082 msgstr ""
7084 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
7085 #: ../en/ch06-filenames.xml:294
7086 msgid ""
7087 "Completely case insensitive. Uppercase and lowercase versions of a letter "
7088 "are treated as identical, both when creating a file and during subsequent "
7089 "accesses. This is common on older DOS-based systems."
7090 msgstr ""
7092 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
7093 #: ../en/ch06-filenames.xml:299
7094 msgid ""
7095 "Case preserving, but insensitive. When a file or directory is created, the "
7096 "case of its name is stored, and can be retrieved and displayed by the "
7097 "operating system. When an existing file is being looked up, its case is "
7098 "ignored. This is the standard arrangement on Windows and MacOS. The names "
7099 "<filename>foo</filename> and <filename>FoO</filename> identify the same "
7100 "file. This treatment of uppercase and lowercase letters as interchangeable "
7101 "is also referred to as <emphasis>case folding</emphasis>."
7102 msgstr ""
7104 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
7105 #: ../en/ch06-filenames.xml:310
7106 msgid ""
7107 "Case sensitive. The case of a name is significant at all times. The names "
7108 "<filename>foo</filename> and {FoO} identify different files. This is the way "
7109 "Linux and Unix systems normally work."
7110 msgstr ""
7112 #. type: Content of: <book><chapter><sect1><para>
7113 #: ../en/ch06-filenames.xml:316
7114 msgid ""
7115 "On Unix-like systems, it is possible to have any or all of the above ways of "
7116 "handling case in action at once. For example, if you use a USB thumb drive "
7117 "formatted with a FAT32 filesystem on a Linux system, Linux will handle names "
7118 "on that filesystem in a case preserving, but insensitive, way."
7119 msgstr ""
7121 #. type: Content of: <book><chapter><sect1><sect2><title>
7122 #: ../en/ch06-filenames.xml:323
7123 msgid "Safe, portable repository storage"
7124 msgstr "安全,可移植的版本库存储"
7126 #. type: Content of: <book><chapter><sect1><sect2><para>
7127 #: ../en/ch06-filenames.xml:325
7128 msgid ""
7129 "Mercurial's repository storage mechanism is <emphasis>case safe</emphasis>. "
7130 "It translates file names so that they can be safely stored on both case "
7131 "sensitive and case insensitive filesystems. This means that you can use "
7132 "normal file copying tools to transfer a Mercurial repository onto, for "
7133 "example, a USB thumb drive, and safely move that drive and repository back "
7134 "and forth between a Mac, a PC running Windows, and a Linux box."
7135 msgstr ""
7137 #. type: Content of: <book><chapter><sect1><sect2><title>
7138 #: ../en/ch06-filenames.xml:336
7139 msgid "Detecting case conflicts"
7140 msgstr "检测大小写冲突"
7142 #. type: Content of: <book><chapter><sect1><sect2><para>
7143 #: ../en/ch06-filenames.xml:338
7144 msgid ""
7145 "When operating in the working directory, Mercurial honours the naming policy "
7146 "of the filesystem where the working directory is located. If the filesystem "
7147 "is case preserving, but insensitive, Mercurial will treat names that differ "
7148 "only in case as the same."
7149 msgstr ""
7151 #. type: Content of: <book><chapter><sect1><sect2><para>
7152 #: ../en/ch06-filenames.xml:344
7153 msgid ""
7154 "An important aspect of this approach is that it is possible to commit a "
7155 "changeset on a case sensitive (typically Linux or Unix) filesystem that will "
7156 "cause trouble for users on case insensitive (usually Windows and MacOS) "
7157 "users. If a Linux user commits changes to two files, one named "
7158 "<filename>myfile.c</filename> and the other named <filename>MyFile.C</"
7159 "filename>, they will be stored correctly in the repository. And in the "
7160 "working directories of other Linux users, they will be correctly represented "
7161 "as separate files."
7162 msgstr ""
7164 #. type: Content of: <book><chapter><sect1><sect2><para>
7165 #: ../en/ch06-filenames.xml:355
7166 msgid ""
7167 "If a Windows or Mac user pulls this change, they will not initially have a "
7168 "problem, because Mercurial's repository storage mechanism is case safe. "
7169 "However, once they try to <command role=\"hg-cmd\">hg update</command> the "
7170 "working directory to that changeset, or <command role=\"hg-cmd\">hg merge</"
7171 "command> with that changeset, Mercurial will spot the conflict between the "
7172 "two file names that the filesystem would treat as the same, and forbid the "
7173 "update or merge from occurring."
7174 msgstr ""
7176 #. type: Content of: <book><chapter><sect1><sect2><title>
7177 #: ../en/ch06-filenames.xml:367
7178 msgid "Fixing a case conflict"
7179 msgstr "修正大小写冲突"
7181 #. type: Content of: <book><chapter><sect1><sect2><para>
7182 #: ../en/ch06-filenames.xml:369
7183 msgid ""
7184 "If you are using Windows or a Mac in a mixed environment where some of your "
7185 "collaborators are using Linux or Unix, and Mercurial reports a case folding "
7186 "conflict when you try to <command role=\"hg-cmd\">hg update</command> or "
7187 "<command role=\"hg-cmd\">hg merge</command>, the procedure to fix the problem "
7188 "is simple."
7189 msgstr ""
7191 #. type: Content of: <book><chapter><sect1><sect2><para>
7192 #: ../en/ch06-filenames.xml:376
7193 msgid ""
7194 "Just find a nearby Linux or Unix box, clone the problem repository onto it, "
7195 "and use Mercurial's <command role=\"hg-cmd\">hg rename</command> command to "
7196 "change the names of any offending files or directories so that they will no "
7197 "longer cause case folding conflicts. Commit this change, <command role=\"hg-"
7198 "cmd\">hg pull</command> or <command role=\"hg-cmd\">hg push</command> it "
7199 "across to your Windows or MacOS system, and <command role=\"hg-cmd\">hg "
7200 "update</command> to the revision with the non-conflicting names."
7201 msgstr ""
7203 #. type: Content of: <book><chapter><sect1><sect2><para>
7204 #: ../en/ch06-filenames.xml:386
7205 msgid ""
7206 "The changeset with case-conflicting names will remain in your project's "
7207 "history, and you still won't be able to <command role=\"hg-cmd\">hg update</"
7208 "command> your working directory to that changeset on a Windows or MacOS "
7209 "system, but you can continue development unimpeded."
7210 msgstr ""
7212 #. type: Content of: <book><chapter><sect1><sect2><note><para>
7213 #: ../en/ch06-filenames.xml:393
7214 msgid ""
7215 "Prior to version 0.9.3, Mercurial did not use a case safe repository storage "
7216 "mechanism, and did not detect case folding conflicts. If you are using an "
7217 "older version of Mercurial on Windows or MacOS, I strongly recommend that you "
7218 "upgrade."
7219 msgstr ""
7221 #. type: Content of: <book><chapter><title>
7222 #: ../en/ch07-branch.xml:5
7223 msgid "Managing releases and branchy development"
7224 msgstr "发布管理与分支开发"
7226 #. type: Content of: <book><chapter><para>
7227 #: ../en/ch07-branch.xml:7
7228 msgid ""
7229 "Mercurial provides several mechanisms for you to manage a project that is "
7230 "making progress on multiple fronts at once. To understand these mechanisms, "
7231 "let's first take a brief look at a fairly normal software project structure."
7232 msgstr ""
7234 #. type: Content of: <book><chapter><para>
7235 #: ../en/ch07-branch.xml:12
7236 msgid ""
7237 "Many software projects issue periodic <quote>major</quote> releases that "
7238 "contain substantial new features. In parallel, they may issue <quote>minor</"
7239 "quote> releases. These are usually identical to the major releases off which "
7240 "they're based, but with a few bugs fixed."
7241 msgstr ""
7243 #. type: Content of: <book><chapter><para>
7244 #: ../en/ch07-branch.xml:18
7245 msgid ""
7246 "In this chapter, we'll start by talking about how to keep records of project "
7247 "milestones such as releases. We'll then continue on to talk about the flow "
7248 "of work between different phases of a project, and how Mercurial can help you "
7249 "to isolate and manage this work."
7250 msgstr ""
7252 #. type: Content of: <book><chapter><sect1><title>
7253 #: ../en/ch07-branch.xml:25
7254 msgid "Giving a persistent name to a revision"
7255 msgstr "给版本指定一个永久的名称"
7257 #. type: Content of: <book><chapter><sect1><para>
7258 #: ../en/ch07-branch.xml:27
7259 msgid ""
7260 "Once you decide that you'd like to call a particular revision a "
7261 "<quote>release</quote>, it's a good idea to record the identity of that "
7262 "revision. This will let you reproduce that release at a later date, for "
7263 "whatever purpose you might need at the time (reproducing a bug, porting to a "
7264 "new platform, etc). &interaction.tag.init;"
7265 msgstr ""
7268 #. type: Content of: <book><chapter><sect1><para>
7269 #: ../en/ch07-branch.xml:34
7270 msgid ""
7271 "Mercurial lets you give a permanent name to any revision using the <command "
7272 "role=\"hg-cmd\">hg tag</command> command. Not surprisingly, these names are "
7273 "called <quote>tags</quote>."
7274 msgstr ""
7276 #. type: Content of: <book><chapter><sect1><para>
7277 #: ../en/ch07-branch.xml:40
7278 msgid ""
7279 "A tag is nothing more than a <quote>symbolic name</quote> for a revision. "
7280 "Tags exist purely for your convenience, so that you have a handy permanent "
7281 "way to refer to a revision; Mercurial doesn't interpret the tag names you use "
7282 "in any way. Neither does Mercurial place any restrictions on the name of a "
7283 "tag, beyond a few that are necessary to ensure that a tag can be parsed "
7284 "unambiguously. A tag name cannot contain any of the following characters:"
7285 msgstr ""
7287 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
7288 #: ../en/ch07-branch.xml:49
7289 msgid "Colon (ASCII 58, <quote><literal>:</literal></quote>)"
7290 msgstr ""
7292 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
7293 #: ../en/ch07-branch.xml:52
7294 msgid "Carriage return (ASCII 13, <quote><literal>\\r</literal></quote>)"
7295 msgstr ""
7297 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
7298 #: ../en/ch07-branch.xml:55
7299 msgid "Newline (ASCII 10, <quote><literal>\\n</literal></quote>)"
7300 msgstr ""
7302 #. type: Content of: <book><chapter><sect1><para>
7303 #: ../en/ch07-branch.xml:59
7304 msgid ""
7305 "You can use the <command role=\"hg-cmd\">hg tags</command> command to display "
7306 "the tags present in your repository. In the output, each tagged revision is "
7307 "identified first by its name, then by revision number, and finally by the "
7308 "unique hash of the revision."
7309 msgstr ""
7311 #. type: Content of: <book><chapter><sect1><para>
7312 #: ../en/ch07-branch.xml:67
7313 msgid ""
7314 "Notice that <literal>tip</literal> is listed in the output of <command role="
7315 "\"hg-cmd\">hg tags</command>. The <literal>tip</literal> tag is a special "
7316 "<quote>floating</quote> tag, which always identifies the newest revision in "
7317 "the repository."
7318 msgstr ""
7320 #. type: Content of: <book><chapter><sect1><para>
7321 #: ../en/ch07-branch.xml:73
7322 msgid ""
7323 "In the output of the <command role=\"hg-cmd\">hg tags</command> command, tags "
7324 "are listed in reverse order, by revision number. This usually means that "
7325 "recent tags are listed before older tags. It also means that <literal>tip</"
7326 "literal> is always going to be the first tag listed in the output of <command "
7327 "role=\"hg-cmd\">hg tags</command>."
7328 msgstr ""
7330 #. type: Content of: <book><chapter><sect1><para>
7331 #: ../en/ch07-branch.xml:80
7332 msgid ""
7333 "When you run <command role=\"hg-cmd\">hg log</command>, if it displays a "
7334 "revision that has tags associated with it, it will print those tags."
7335 msgstr ""
7338 #. type: Content of: <book><chapter><sect1><para>
7339 #: ../en/ch07-branch.xml:86
7340 msgid ""
7341 "Any time you need to provide a revision ID to a Mercurial command, the "
7342 "command will accept a tag name in its place. Internally, Mercurial will "
7343 "translate your tag name into the corresponding revision ID, then use that."
7344 msgstr ""
7346 #. type: Content of: <book><chapter><sect1><para>
7347 #: ../en/ch07-branch.xml:93
7348 msgid ""
7349 "There's no limit on the number of tags you can have in a repository, or on "
7350 "the number of tags that a single revision can have. As a practical matter, "
7351 "it's not a great idea to have <quote>too many</quote> (a number which will "
7352 "vary from project to project), simply because tags are supposed to help you "
7353 "to find revisions. If you have lots of tags, the ease of using them to "
7354 "identify revisions diminishes rapidly."
7355 msgstr ""
7357 #. type: Content of: <book><chapter><sect1><para>
7358 #: ../en/ch07-branch.xml:101
7359 msgid ""
7360 "For example, if your project has milestones as frequent as every few days, "
7361 "it's perfectly reasonable to tag each one of those. But if you have a "
7362 "continuous build system that makes sure every revision can be built cleanly, "
7363 "you'd be introducing a lot of noise if you were to tag every clean build. "
7364 "Instead, you could tag failed builds (on the assumption that they're rare!), "
7365 "or simply not use tags to track buildability."
7366 msgstr ""
7368 #. type: Content of: <book><chapter><sect1><para>
7369 #: ../en/ch07-branch.xml:109
7370 msgid ""
7371 "If you want to remove a tag that you no longer want, use <command role=\"hg-"
7372 "cmd\">hg tag --remove</command>."
7373 msgstr ""
7375 #. type: Content of: <book><chapter><sect1><para>
7376 #: ../en/ch07-branch.xml:114
7377 msgid ""
7378 "You can also modify a tag at any time, so that it identifies a different "
7379 "revision, by simply issuing a new <command role=\"hg-cmd\">hg tag</command> "
7380 "command. You'll have to use the <option role=\"hg-opt-tag\">-f</option> "
7381 "option to tell Mercurial that you <emphasis>really</emphasis> want to update "
7382 "the tag."
7383 msgstr ""
7385 #. type: Content of: <book><chapter><sect1><para>
7386 #: ../en/ch07-branch.xml:123
7387 msgid ""
7388 "There will still be a permanent record of the previous identity of the tag, "
7389 "but Mercurial will no longer use it. There's thus no penalty to tagging the "
7390 "wrong revision; all you have to do is turn around and tag the correct "
7391 "revision once you discover your error."
7392 msgstr ""
7395 #. type: Content of: <book><chapter><sect1><para>
7396 #: ../en/ch07-branch.xml:129
7397 msgid ""
7398 "Mercurial stores tags in a normal revision-controlled file in your "
7399 "repository. If you've created any tags, you'll find them in a file named "
7400 "<filename role=\"special\">.hgtags</filename>. When you run the <command "
7401 "role=\"hg-cmd\">hg tag</command> command, Mercurial modifies this file, then "
7402 "automatically commits the change to it. This means that every time you run "
7403 "<command role=\"hg-cmd\">hg tag</command>, you'll see a corresponding "
7404 "changeset in the output of <command role=\"hg-cmd\">hg log</command>."
7405 msgstr ""
7407 #. type: Content of: <book><chapter><sect1><sect2><title>
7408 #: ../en/ch07-branch.xml:142
7409 msgid "Handling tag conflicts during a merge"
7410 msgstr "在合并期间处理标签冲突"
7412 #. type: Content of: <book><chapter><sect1><sect2><para>
7413 #: ../en/ch07-branch.xml:144
7414 msgid ""
7415 "You won't often need to care about the <filename role=\"special\">.hgtags</"
7416 "filename> file, but it sometimes makes its presence known during a merge. "
7417 "The format of the file is simple: it consists of a series of lines. Each "
7418 "line starts with a changeset hash, followed by a space, followed by the name "
7419 "of a tag."
7420 msgstr ""
7422 #. type: Content of: <book><chapter><sect1><sect2><para>
7423 #: ../en/ch07-branch.xml:151
7424 msgid ""
7425 "If you're resolving a conflict in the <filename role=\"special\">.hgtags</"
7426 "filename> file during a merge, there's one twist to modifying the <filename "
7427 "role=\"special\">.hgtags</filename> file: when Mercurial is parsing the tags "
7428 "in a repository, it <emphasis>never</emphasis> reads the working copy of the "
7429 "<filename role=\"special\">.hgtags</filename> file. Instead, it reads the "
7430 "<emphasis>most recently committed</emphasis> revision of the file."
7431 msgstr ""
7433 #. type: Content of: <book><chapter><sect1><sect2><para>
7434 #: ../en/ch07-branch.xml:161
7435 msgid ""
7436 "An unfortunate consequence of this design is that you can't actually verify "
7437 "that your merged <filename role=\"special\">.hgtags</filename> file is "
7438 "correct until <emphasis>after</emphasis> you've committed a change. So if "
7439 "you find yourself resolving a conflict on <filename role=\"special\">.hgtags</"
7440 "filename> during a merge, be sure to run <command role=\"hg-cmd\">hg tags</"
7441 "command> after you commit. If it finds an error in the <filename role="
7442 "\"special\">.hgtags</filename> file, it will report the location of the "
7443 "error, which you can then fix and commit. You should then run <command role="
7444 "\"hg-cmd\">hg tags</command> again, just to be sure that your fix is correct."
7445 msgstr ""
7447 #. type: Content of: <book><chapter><sect1><sect2><title>
7448 #: ../en/ch07-branch.xml:176
7449 msgid "Tags and cloning"
7450 msgstr "标签与克隆"
7452 #. type: Content of: <book><chapter><sect1><sect2><para>
7453 #: ../en/ch07-branch.xml:178
7454 msgid ""
7455 "You may have noticed that the <command role=\"hg-cmd\">hg clone</command> "
7456 "command has a <option role=\"hg-opt-clone\">-r</option> option that lets you "
7457 "clone an exact copy of the repository as of a particular changeset. The new "
7458 "clone will not contain any project history that comes after the revision you "
7459 "specified. This has an interaction with tags that can surprise the unwary."
7460 msgstr ""
7462 #. type: Content of: <book><chapter><sect1><sect2><para>
7463 #: ../en/ch07-branch.xml:186
7464 msgid ""
7465 "Recall that a tag is stored as a revision to the <filename role=\"special\">."
7466 "hgtags</filename> file, so that when you create a tag, the changeset in which "
7467 "it's recorded necessarily refers to an older changeset. When you run "
7468 "<command role=\"hg-cmd\">hg clone -r foo</command> to clone a repository as "
7469 "of tag <literal>foo</literal>, the new clone <emphasis>will not contain the "
7470 "history that created the tag</emphasis> that you used to clone the "
7471 "repository. The result is that you'll get exactly the right subset of the "
7472 "project's history in the new repository, but <emphasis>not</emphasis> the tag "
7473 "you might have expected."
7474 msgstr ""
7476 #. type: Content of: <book><chapter><sect1><sect2><title>
7477 #: ../en/ch07-branch.xml:201
7478 msgid "When permanent tags are too much"
7479 msgstr "当永久标签太多的时候"
7481 #. type: Content of: <book><chapter><sect1><sect2><para>
7482 #: ../en/ch07-branch.xml:203
7483 msgid ""
7484 "Since Mercurial's tags are revision controlled and carried around with a "
7485 "project's history, everyone you work with will see the tags you create. But "
7486 "giving names to revisions has uses beyond simply noting that revision "
7487 "<literal>4237e45506ee</literal> is really <literal>v2.0.2</literal>. If "
7488 "you're trying to track down a subtle bug, you might want a tag to remind you "
7489 "of something like <quote>Anne saw the symptoms with this revision</quote>."
7490 msgstr ""
7492 #. type: Content of: <book><chapter><sect1><sect2><para>
7493 #: ../en/ch07-branch.xml:213
7494 msgid ""
7495 "For cases like this, what you might want to use are <emphasis>local</"
7496 "emphasis> tags. You can create a local tag with the <option role=\"hg-opt-tag"
7497 "\">-l</option> option to the <command role=\"hg-cmd\">hg tag</command> "
7498 "command. This will store the tag in a file called <filename role=\"special"
7499 "\">.hg/localtags</filename>. Unlike <filename role=\"special\">.hgtags</"
7500 "filename>, <filename role=\"special\">.hg/localtags</filename> is not "
7501 "revision controlled. Any tags you create using <option role=\"hg-opt-tag\">-"
7502 "l</option> remain strictly local to the repository you're currently working "
7503 "in."
7504 msgstr ""
7506 #. type: Content of: <book><chapter><sect1><title>
7507 #: ../en/ch07-branch.xml:228
7508 msgid "The flow of changes&emdash;big picture vs. little"
7509 msgstr "修改流程&emdash;宏观与微观"
7511 #. type: Content of: <book><chapter><sect1><para>
7512 #: ../en/ch07-branch.xml:230
7513 msgid ""
7514 "To return to the outline I sketched at the beginning of a chapter, let's "
7515 "think about a project that has multiple concurrent pieces of work under "
7516 "development at once."
7517 msgstr ""
7519 #. type: Content of: <book><chapter><sect1><para>
7520 #: ../en/ch07-branch.xml:234
7521 msgid ""
7522 "There might be a push for a new <quote>main</quote> release; a new minor "
7523 "bugfix release to the last main release; and an unexpected <quote>hot fix</"
7524 "quote> to an old release that is now in maintenance mode."
7525 msgstr ""
7527 #. type: Content of: <book><chapter><sect1><para>
7528 #: ../en/ch07-branch.xml:239
7529 msgid ""
7530 "The usual way people refer to these different concurrent directions of "
7531 "development is as <quote>branches</quote>. However, we've already seen "
7532 "numerous times that Mercurial treats <emphasis>all of history</emphasis> as a "
7533 "series of branches and merges. Really, what we have here is two ideas that "
7534 "are peripherally related, but which happen to share a name."
7535 msgstr ""
7537 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
7538 #: ../en/ch07-branch.xml:246
7539 msgid ""
7540 "<quote>Big picture</quote> branches represent the sweep of a project's "
7541 "evolution; people give them names, and talk about them in conversation."
7542 msgstr ""
7544 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
7545 #: ../en/ch07-branch.xml:250
7546 msgid ""
7547 "<quote>Little picture</quote> branches are artefacts of the day-to-day "
7548 "activity of developing and merging changes. They expose the narrative of how "
7549 "the code was developed."
7550 msgstr ""
7552 #. type: Content of: <book><chapter><sect1><title>
7553 #: ../en/ch07-branch.xml:258
7554 msgid "Managing big-picture branches in repositories"
7555 msgstr "在版本库中管理分支"
7557 #. type: Content of: <book><chapter><sect1><para>
7558 #: ../en/ch07-branch.xml:260
7559 msgid ""
7560 "The easiest way to isolate a <quote>big picture</quote> branch in Mercurial "
7561 "is in a dedicated repository. If you have an existing shared "
7562 "repository&emdash;let's call it <literal>myproject</literal>&emdash;that "
7563 "reaches a <quote>1.0</quote> milestone, you can start to prepare for future "
7564 "maintenance releases on top of version 1.0 by tagging the revision from which "
7565 "you prepared the 1.0 release."
7566 msgstr ""
7568 #. type: Content of: <book><chapter><sect1><para>
7569 #: ../en/ch07-branch.xml:270
7570 msgid ""
7571 "You can then clone a new shared <literal>myproject-1.0.1</literal> repository "
7572 "as of that tag."
7573 msgstr ""
7575 #. type: Content of: <book><chapter><sect1><para>
7576 #: ../en/ch07-branch.xml:276
7577 msgid ""
7578 "Afterwards, if someone needs to work on a bug fix that ought to go into an "
7579 "upcoming 1.0.1 minor release, they clone the <literal>myproject-1.0.1</"
7580 "literal> repository, make their changes, and push them back."
7581 msgstr ""
7583 #. type: Content of: <book><chapter><sect1><para>
7584 #: ../en/ch07-branch.xml:283
7585 msgid ""
7586 "Meanwhile, development for the next major release can continue, isolated and "
7587 "unabated, in the <literal>myproject</literal> repository."
7588 msgstr ""
7590 #. type: Content of: <book><chapter><sect1><title>
7591 #: ../en/ch07-branch.xml:291
7592 msgid "Don't repeat yourself: merging across branches"
7593 msgstr "不要重复劳动:在分支间合并"
7595 #. type: Content of: <book><chapter><sect1><para>
7596 #: ../en/ch07-branch.xml:293
7597 msgid ""
7598 "In many cases, if you have a bug to fix on a maintenance branch, the chances "
7599 "are good that the bug exists on your project's main branch (and possibly "
7600 "other maintenance branches, too). It's a rare developer who wants to fix the "
7601 "same bug multiple times, so let's look at a few ways that Mercurial can help "
7602 "you to manage these bugfixes without duplicating your work."
7603 msgstr ""
7605 #. type: Content of: <book><chapter><sect1><para>
7606 #: ../en/ch07-branch.xml:301
7607 msgid ""
7608 "In the simplest instance, all you need to do is pull changes from your "
7609 "maintenance branch into your local clone of the target branch."
7610 msgstr ""
7612 #. type: Content of: <book><chapter><sect1><para>
7613 #: ../en/ch07-branch.xml:307
7614 msgid ""
7615 "You'll then need to merge the heads of the two branches, and push back to the "
7616 "main branch."
7617 msgstr ""
7619 #. type: Content of: <book><chapter><sect1><title>
7620 #: ../en/ch07-branch.xml:314
7621 msgid "Naming branches within one repository"
7622 msgstr "版本库中的命名分支"
7624 #. type: Content of: <book><chapter><sect1><para>
7625 #: ../en/ch07-branch.xml:316
7626 msgid ""
7627 "In most instances, isolating branches in repositories is the right approach. "
7628 "Its simplicity makes it easy to understand; and so it's hard to make "
7629 "mistakes. There's a one-to-one relationship between branches you're working "
7630 "in and directories on your system. This lets you use normal (non-Mercurial-"
7631 "aware) tools to work on files within a branch/repository."
7632 msgstr ""
7634 #. type: Content of: <book><chapter><sect1><para>
7635 #: ../en/ch07-branch.xml:323
7636 msgid ""
7637 "If you're more in the <quote>power user</quote> category (<emphasis>and</"
7638 "emphasis> your collaborators are too), there is an alternative way of "
7639 "handling branches that you can consider. I've already mentioned the human-"
7640 "level distinction between <quote>small picture</quote> and <quote>big "
7641 "picture</quote> branches. While Mercurial works with multiple <quote>small "
7642 "picture</quote> branches in a repository all the time (for example after you "
7643 "pull changes in, but before you merge them), it can <emphasis>also</emphasis> "
7644 "work with multiple <quote>big picture</quote> branches."
7645 msgstr ""
7647 #. type: Content of: <book><chapter><sect1><para>
7648 #: ../en/ch07-branch.xml:334
7649 msgid ""
7650 "The key to working this way is that Mercurial lets you assign a persistent "
7651 "<emphasis>name</emphasis> to a branch. There always exists a branch named "
7652 "<literal>default</literal>. Even before you start naming branches yourself, "
7653 "you can find traces of the <literal>default</literal> branch if you look for "
7654 "them."
7655 msgstr ""
7657 #. type: Content of: <book><chapter><sect1><para>
7658 #: ../en/ch07-branch.xml:341
7659 msgid ""
7660 "As an example, when you run the <command role=\"hg-cmd\">hg commit</command> "
7661 "command, and it pops up your editor so that you can enter a commit message, "
7662 "look for a line that contains the text <quote><literal>HG: branch default</"
7663 "literal></quote> at the bottom. This is telling you that your commit will "
7664 "occur on the branch named <literal>default</literal>."
7665 msgstr ""
7667 #. type: Content of: <book><chapter><sect1><para>
7668 #: ../en/ch07-branch.xml:348
7669 msgid ""
7670 "To start working with named branches, use the <command role=\"hg-cmd\">hg "
7671 "branches</command> command. This command lists the named branches already "
7672 "present in your repository, telling you which changeset is the tip of each."
7673 msgstr ""
7675 #. type: Content of: <book><chapter><sect1><para>
7676 #: ../en/ch07-branch.xml:355
7677 msgid ""
7678 "Since you haven't created any named branches yet, the only one that exists is "
7679 "<literal>default</literal>."
7680 msgstr ""
7682 #. type: Content of: <book><chapter><sect1><para>
7683 #: ../en/ch07-branch.xml:358
7684 msgid ""
7685 "To find out what the <quote>current</quote> branch is, run the <command role="
7686 "\"hg-cmd\">hg branch</command> command, giving it no arguments. This tells "
7687 "you what branch the parent of the current changeset is on."
7688 msgstr ""
7691 #. type: Content of: <book><chapter><sect1><para>
7692 #: ../en/ch07-branch.xml:365
7693 msgid ""
7694 "To create a new branch, run the <command role=\"hg-cmd\">hg branch</command> "
7695 "command again. This time, give it one argument: the name of the branch you "
7696 "want to create."
7697 msgstr ""
7699 #. type: Content of: <book><chapter><sect1><para>
7700 #: ../en/ch07-branch.xml:371
7701 msgid ""
7702 "After you've created a branch, you might wonder what effect the <command role="
7703 "\"hg-cmd\">hg branch</command> command has had. What do the <command role="
7704 "\"hg-cmd\">hg status</command> and <command role=\"hg-cmd\">hg tip</command> "
7705 "commands report?"
7706 msgstr ""
7708 #. type: Content of: <book><chapter><sect1><para>
7709 #: ../en/ch07-branch.xml:378
7710 msgid ""
7711 "Nothing has changed in the working directory, and there's been no new history "
7712 "created. As this suggests, running the <command role=\"hg-cmd\">hg branch</"
7713 "command> command has no permanent effect; it only tells Mercurial what branch "
7714 "name to use the <emphasis>next</emphasis> time you commit a changeset."
7715 msgstr ""
7717 #. type: Content of: <book><chapter><sect1><para>
7718 #: ../en/ch07-branch.xml:385
7719 msgid ""
7720 "When you commit a change, Mercurial records the name of the branch on which "
7721 "you committed. Once you've switched from the <literal>default</literal> "
7722 "branch to another and committed, you'll see the name of the new branch show "
7723 "up in the output of <command role=\"hg-cmd\">hg log</command>, <command role="
7724 "\"hg-cmd\">hg tip</command>, and other commands that display the same kind of "
7725 "output."
7726 msgstr ""
7728 #. type: Content of: <book><chapter><sect1><para>
7729 #: ../en/ch07-branch.xml:395
7730 msgid ""
7731 "The <command role=\"hg-cmd\">hg log</command>-like commands will print the "
7732 "branch name of every changeset that's not on the <literal>default</literal> "
7733 "branch. As a result, if you never use named branches, you'll never see this "
7734 "information."
7735 msgstr ""
7737 #. type: Content of: <book><chapter><sect1><para>
7738 #: ../en/ch07-branch.xml:400
7739 msgid ""
7740 "Once you've named a branch and committed a change with that name, every "
7741 "subsequent commit that descends from that change will inherit the same branch "
7742 "name. You can change the name of a branch at any time, using the <command "
7743 "role=\"hg-cmd\">hg branch</command> command."
7744 msgstr ""
7746 #. type: Content of: <book><chapter><sect1><para>
7747 #: ../en/ch07-branch.xml:408
7748 msgid ""
7749 "In practice, this is something you won't do very often, as branch names tend "
7750 "to have fairly long lifetimes. (This isn't a rule, just an observation.)"
7751 msgstr ""
7753 #. type: Content of: <book><chapter><sect1><title>
7754 #: ../en/ch07-branch.xml:414
7755 msgid "Dealing with multiple named branches in a repository"
7756 msgstr "在版本库中处理多个命名分支"
7758 #. type: Content of: <book><chapter><sect1><para>
7759 #: ../en/ch07-branch.xml:417
7760 msgid ""
7761 "If you have more than one named branch in a repository, Mercurial will "
7762 "remember the branch that your working directory on when you start a command "
7763 "like <command role=\"hg-cmd\">hg update</command> or <command role=\"hg-cmd"
7764 "\">hg pull -u</command>. It will update the working directory to the tip of "
7765 "this branch, no matter what the <quote>repo-wide</quote> tip is. To update "
7766 "to a revision that's on a different named branch, you may need to use the "
7767 "<option role=\"hg-opt-update\">-C</option> option to <command role=\"hg-cmd"
7768 "\">hg update</command>."
7769 msgstr ""
7771 #. type: Content of: <book><chapter><sect1><para>
7772 #: ../en/ch07-branch.xml:427
7773 msgid ""
7774 "This behaviour is a little subtle, so let's see it in action. First, let's "
7775 "remind ourselves what branch we're currently on, and what branches are in our "
7776 "repository."
7777 msgstr ""
7779 #. type: Content of: <book><chapter><sect1><para>
7780 #: ../en/ch07-branch.xml:433
7781 msgid ""
7782 "We're on the <literal>bar</literal> branch, but there also exists an older "
7783 "<command role=\"hg-cmd\">hg foo</command> branch."
7784 msgstr ""
7786 #. type: Content of: <book><chapter><sect1><para>
7787 #: ../en/ch07-branch.xml:437
7788 msgid ""
7789 "We can <command role=\"hg-cmd\">hg update</command> back and forth between "
7790 "the tips of the <literal>foo</literal> and <literal>bar</literal> branches "
7791 "without needing to use the <option role=\"hg-opt-update\">-C</option> option, "
7792 "because this only involves going backwards and forwards linearly through our "
7793 "change history."
7794 msgstr ""
7797 #. type: Content of: <book><chapter><sect1><para>
7798 #: ../en/ch07-branch.xml:446
7799 msgid ""
7800 "If we go back to the <literal>foo</literal> branch and then run <command role="
7801 "\"hg-cmd\">hg update</command>, it will keep us on <literal>foo</literal>, "
7802 "not move us to the tip of <literal>bar</literal>."
7803 msgstr ""
7806 #. type: Content of: <book><chapter><sect1><para>
7807 #: ../en/ch07-branch.xml:453
7808 msgid ""
7809 "Committing a new change on the <literal>foo</literal> branch introduces a new "
7810 "head."
7811 msgstr ""
7813 #. type: Content of: <book><chapter><sect1><title>
7814 #: ../en/ch07-branch.xml:460
7815 msgid "Branch names and merging"
7816 msgstr "分支名称与合并"
7818 #. type: Content of: <book><chapter><sect1><para>
7819 #: ../en/ch07-branch.xml:462
7820 msgid ""
7821 "As you've probably noticed, merges in Mercurial are not symmetrical. Let's "
7822 "say our repository has two heads, 17 and 23. If I <command role=\"hg-cmd"
7823 "\">hg update</command> to 17 and then <command role=\"hg-cmd\">hg merge</"
7824 "command> with 23, Mercurial records 17 as the first parent of the merge, and "
7825 "23 as the second. Whereas if I <command role=\"hg-cmd\">hg update</command> "
7826 "to 23 and then <command role=\"hg-cmd\">hg merge</command> with 17, it "
7827 "records 23 as the first parent, and 17 as the second."
7828 msgstr ""
7830 #. type: Content of: <book><chapter><sect1><para>
7831 #: ../en/ch07-branch.xml:472
7832 msgid ""
7833 "This affects Mercurial's choice of branch name when you merge. After a "
7834 "merge, Mercurial will retain the branch name of the first parent when you "
7835 "commit the result of the merge. If your first parent's branch name is "
7836 "<literal>foo</literal>, and you merge with <literal>bar</literal>, the branch "
7837 "name will still be <literal>foo</literal> after you merge."
7838 msgstr ""
7840 #. type: Content of: <book><chapter><sect1><para>
7841 #: ../en/ch07-branch.xml:479
7842 msgid ""
7843 "It's not unusual for a repository to contain multiple heads, each with the "
7844 "same branch name. Let's say I'm working on the <literal>foo</literal> "
7845 "branch, and so are you. We commit different changes; I pull your changes; I "
7846 "now have two heads, each claiming to be on the <literal>foo</literal> "
7847 "branch. The result of a merge will be a single head on the <literal>foo</"
7848 "literal> branch, as you might hope."
7849 msgstr ""
7852 #. type: Content of: <book><chapter><sect1><para>
7853 #: ../en/ch07-branch.xml:487
7854 msgid ""
7855 "But if I'm working on the <literal>bar</literal> branch, and I merge work "
7856 "from the <literal>foo</literal> branch, the result will remain on the "
7857 "<literal>bar</literal> branch."
7858 msgstr ""
7860 #. type: Content of: <book><chapter><sect1><para>
7861 #: ../en/ch07-branch.xml:493
7862 msgid ""
7863 "To give a more concrete example, if I'm working on the <literal>bleeding-"
7864 "edge</literal> branch, and I want to bring in the latest fixes from the "
7865 "<literal>stable</literal> branch, Mercurial will choose the <quote>right</"
7866 "quote> (<literal>bleeding-edge</literal>) branch name when I pull and merge "
7867 "from <literal>stable</literal>."
7868 msgstr ""
7870 #. type: Content of: <book><chapter><sect1><title>
7871 #: ../en/ch07-branch.xml:502
7872 msgid "Branch naming is generally useful"
7873 msgstr "分支名称通常都很有用"
7875 #. type: Content of: <book><chapter><sect1><para>
7876 #: ../en/ch07-branch.xml:504
7877 msgid ""
7878 "You shouldn't think of named branches as applicable only to situations where "
7879 "you have multiple long-lived branches cohabiting in a single repository. "
7880 "They're very useful even in the one-branch-per-repository case."
7881 msgstr ""
7883 #. type: Content of: <book><chapter><sect1><para>
7884 #: ../en/ch07-branch.xml:509
7885 msgid ""
7886 "In the simplest case, giving a name to each branch gives you a permanent "
7887 "record of which branch a changeset originated on. This gives you more "
7888 "context when you're trying to follow the history of a long-lived branchy "
7889 "project."
7890 msgstr ""
7892 #. type: Content of: <book><chapter><sect1><para>
7893 #: ../en/ch07-branch.xml:514
7894 msgid ""
7895 "If you're working with shared repositories, you can set up a <literal role="
7896 "\"hook\">pretxnchangegroup</literal> hook on each that will block incoming "
7897 "changes that have the <quote>wrong</quote> branch name. This provides a "
7898 "simple, but effective, defence against people accidentally pushing changes "
7899 "from a <quote>bleeding edge</quote> branch to a <quote>stable</quote> "
7900 "branch. Such a hook might look like this inside the shared repo's <filename "
7901 "role=\"special\"> /.hgrc</filename>."
7902 msgstr ""
7904 #. type: Content of: <book><chapter><title>
7905 #: ../en/ch08-undo.xml:5
7906 msgid "Finding and fixing mistakes"
7907 msgstr "查找和修改错误"
7909 #. type: Content of: <book><chapter><para>
7910 #: ../en/ch08-undo.xml:7
7911 msgid ""
7912 "To err might be human, but to really handle the consequences well takes a top-"
7913 "notch revision control system. In this chapter, we'll discuss some of the "
7914 "techniques you can use when you find that a problem has crept into your "
7915 "project. Mercurial has some highly capable features that will help you to "
7916 "isolate the sources of problems, and to handle them appropriately."
7917 msgstr ""
7919 #. type: Content of: <book><chapter><sect1><title>
7920 #: ../en/ch08-undo.xml:15
7921 msgid "Erasing local history"
7922 msgstr "销毁本地历史"
7924 #. type: Content of: <book><chapter><sect1><sect2><title>
7925 #: ../en/ch08-undo.xml:18
7926 msgid "The accidental commit"
7927 msgstr "意外的提交"
7929 #. type: Content of: <book><chapter><sect1><sect2><para>
7930 #: ../en/ch08-undo.xml:20
7931 msgid ""
7932 "I have the occasional but persistent problem of typing rather more quickly "
7933 "than I can think, which sometimes results in me committing a changeset that "
7934 "is either incomplete or plain wrong. In my case, the usual kind of "
7935 "incomplete changeset is one in which I've created a new source file, but "
7936 "forgotten to <command role=\"hg-cmd\">hg add</command> it. A <quote>plain "
7937 "wrong</quote> changeset is not as common, but no less annoying."
7938 msgstr ""
7940 #. type: Content of: <book><chapter><sect1><sect2><title>
7941 #: ../en/ch08-undo.xml:31
7942 msgid "Rolling back a transaction"
7943 msgstr "回滚一个事务"
7945 #. type: Content of: <book><chapter><sect1><sect2><para>
7946 #: ../en/ch08-undo.xml:33
7947 msgid ""
7948 "In section <xref linkend=\"sec.concepts.txn\"/>, I mentioned that Mercurial "
7949 "treats each modification of a repository as a <emphasis>transaction</"
7950 "emphasis>. Every time you commit a changeset or pull changes from another "
7951 "repository, Mercurial remembers what you did. You can undo, or "
7952 "<emphasis>roll back</emphasis>, exactly one of these actions using the "
7953 "<command role=\"hg-cmd\">hg rollback</command> command. (See section <xref "
7954 "linkend=\"sec.undo.rollback-after-push\"/> for an important caveat about the "
7955 "use of this command.)"
7956 msgstr ""
7958 #. type: Content of: <book><chapter><sect1><sect2><para>
7959 #: ../en/ch08-undo.xml:43
7960 msgid ""
7961 "Here's a mistake that I often find myself making: committing a change in "
7962 "which I've created a new file, but forgotten to <command role=\"hg-cmd\">hg "
7963 "add</command> it."
7964 msgstr ""
7966 #. type: Content of: <book><chapter><sect1><sect2><para>
7967 #: ../en/ch08-undo.xml:50
7968 msgid ""
7969 "Looking at the output of <command role=\"hg-cmd\">hg status</command> after "
7970 "the commit immediately confirms the error."
7971 msgstr ""
7973 #. type: Content of: <book><chapter><sect1><sect2><para>
7974 #: ../en/ch08-undo.xml:56
7975 msgid ""
7976 "The commit captured the changes to the file <filename>a</filename>, but not "
7977 "the new file <filename>b</filename>. If I were to push this changeset to a "
7978 "repository that I shared with a colleague, the chances are high that "
7979 "something in <filename>a</filename> would refer to <filename>b</filename>, "
7980 "which would not be present in their repository when they pulled my changes. "
7981 "I would thus become the object of some indignation."
7982 msgstr ""
7984 #. type: Content of: <book><chapter><sect1><sect2><para>
7985 #: ../en/ch08-undo.xml:65
7986 msgid ""
7987 "However, luck is with me&emdash;I've caught my error before I pushed the "
7988 "changeset. I use the <command role=\"hg-cmd\">hg rollback</command> command, "
7989 "and Mercurial makes that last changeset vanish."
7990 msgstr ""
7992 #. type: Content of: <book><chapter><sect1><sect2><para>
7993 #: ../en/ch08-undo.xml:72
7994 msgid ""
7995 "Notice that the changeset is no longer present in the repository's history, "
7996 "and the working directory once again thinks that the file <filename>a</"
7997 "filename> is modified. The commit and rollback have left the working "
7998 "directory exactly as it was prior to the commit; the changeset has been "
7999 "completely erased. I can now safely <command role=\"hg-cmd\">hg add</"
8000 "command> the file <filename>b</filename>, and rerun my commit."
8001 msgstr ""
8003 #. type: Content of: <book><chapter><sect1><sect2><title>
8004 #: ../en/ch08-undo.xml:85
8005 msgid "The erroneous pull"
8006 msgstr "错误的抓取"
8008 #. type: Content of: <book><chapter><sect1><sect2><para>
8009 #: ../en/ch08-undo.xml:87
8010 msgid ""
8011 "It's common practice with Mercurial to maintain separate development branches "
8012 "of a project in different repositories. Your development team might have one "
8013 "shared repository for your project's <quote>0.9</quote> release, and another, "
8014 "containing different changes, for the <quote>1.0</quote> release."
8015 msgstr ""
8017 #. type: Content of: <book><chapter><sect1><sect2><para>
8018 #: ../en/ch08-undo.xml:94
8019 msgid ""
8020 "Given this, you can imagine that the consequences could be messy if you had a "
8021 "local <quote>0.9</quote> repository, and accidentally pulled changes from the "
8022 "shared <quote>1.0</quote> repository into it. At worst, you could be paying "
8023 "insufficient attention, and push those changes into the shared <quote>0.9</"
8024 "quote> tree, confusing your entire team (but don't worry, we'll return to "
8025 "this horror scenario later). However, it's more likely that you'll notice "
8026 "immediately, because Mercurial will display the URL it's pulling from, or you "
8027 "will see it pull a suspiciously large number of changes into the repository."
8028 msgstr ""
8030 #. type: Content of: <book><chapter><sect1><sect2><para>
8031 #: ../en/ch08-undo.xml:106
8032 msgid ""
8033 "The <command role=\"hg-cmd\">hg rollback</command> command will work nicely "
8034 "to expunge all of the changesets that you just pulled. Mercurial groups all "
8035 "changes from one <command role=\"hg-cmd\">hg pull</command> into a single "
8036 "transaction, so one <command role=\"hg-cmd\">hg rollback</command> is all you "
8037 "need to undo this mistake."
8038 msgstr ""
8040 #. type: Content of: <book><chapter><sect1><sect2><title>
8041 #: ../en/ch08-undo.xml:115
8042 msgid "Rolling back is useless once you've pushed"
8043 msgstr "当完成推送后,回滚是无效的"
8045 #. type: Content of: <book><chapter><sect1><sect2><para>
8046 #: ../en/ch08-undo.xml:117
8047 msgid ""
8048 "The value of the <command role=\"hg-cmd\">hg rollback</command> command drops "
8049 "to zero once you've pushed your changes to another repository. Rolling back "
8050 "a change makes it disappear entirely, but <emphasis>only</emphasis> in the "
8051 "repository in which you perform the <command role=\"hg-cmd\">hg rollback</"
8052 "command>. Because a rollback eliminates history, there's no way for the "
8053 "disappearance of a change to propagate between repositories."
8054 msgstr ""
8056 #. type: Content of: <book><chapter><sect1><sect2><para>
8057 #: ../en/ch08-undo.xml:126
8058 msgid ""
8059 "If you've pushed a change to another repository&emdash;particularly if it's a "
8060 "shared repository&emdash;it has essentially <quote>escaped into the wild,</"
8061 "quote> and you'll have to recover from your mistake in a different way. What "
8062 "will happen if you push a changeset somewhere, then roll it back, then pull "
8063 "from the repository you pushed to, is that the changeset will reappear in "
8064 "your repository."
8065 msgstr ""
8067 #. type: Content of: <book><chapter><sect1><sect2><para>
8068 #: ../en/ch08-undo.xml:135
8069 msgid ""
8070 "(If you absolutely know for sure that the change you want to roll back is the "
8071 "most recent change in the repository that you pushed to, <emphasis>and</"
8072 "emphasis> you know that nobody else could have pulled it from that "
8073 "repository, you can roll back the changeset there, too, but you really should "
8074 "really not rely on this working reliably. If you do this, sooner or later a "
8075 "change really will make it into a repository that you don't directly control "
8076 "(or have forgotten about), and come back to bite you.)"
8077 msgstr ""
8079 #. type: Content of: <book><chapter><sect1><sect2><title>
8080 #: ../en/ch08-undo.xml:147
8081 msgid "You can only roll back once"
8082 msgstr "你只能回滚一次"
8084 #. type: Content of: <book><chapter><sect1><sect2><para>
8085 #: ../en/ch08-undo.xml:149
8086 msgid ""
8087 "Mercurial stores exactly one transaction in its transaction log; that "
8088 "transaction is the most recent one that occurred in the repository. This "
8089 "means that you can only roll back one transaction. If you expect to be able "
8090 "to roll back one transaction, then its predecessor, this is not the behaviour "
8091 "you will get."
8092 msgstr ""
8094 #. type: Content of: <book><chapter><sect1><sect2><para>
8095 #: ../en/ch08-undo.xml:158
8096 msgid ""
8097 "Once you've rolled back one transaction in a repository, you can't roll back "
8098 "again in that repository until you perform another commit or pull."
8099 msgstr ""
8101 #. type: Content of: <book><chapter><sect1><title>
8102 #: ../en/ch08-undo.xml:165
8103 msgid "Reverting the mistaken change"
8104 msgstr "撤销错误的修改"
8106 #. type: Content of: <book><chapter><sect1><para>
8107 #: ../en/ch08-undo.xml:167
8108 msgid ""
8109 "If you make a modification to a file, and decide that you really didn't want "
8110 "to change the file at all, and you haven't yet committed your changes, the "
8111 "<command role=\"hg-cmd\">hg revert</command> command is the one you'll need. "
8112 "It looks at the changeset that's the parent of the working directory, and "
8113 "restores the contents of the file to their state as of that changeset. "
8114 "(That's a long-winded way of saying that, in the normal case, it undoes your "
8115 "modifications.)"
8116 msgstr ""
8118 #. type: Content of: <book><chapter><sect1><para>
8119 #: ../en/ch08-undo.xml:176
8120 msgid ""
8121 "Let's illustrate how the <command role=\"hg-cmd\">hg revert</command> command "
8122 "works with yet another small example. We'll begin by modifying a file that "
8123 "Mercurial is already tracking."
8124 msgstr ""
8126 #. type: Content of: <book><chapter><sect1><para>
8127 #: ../en/ch08-undo.xml:183
8128 msgid ""
8129 "If we don't want that change, we can simply <command role=\"hg-cmd\">hg "
8130 "revert</command> the file."
8131 msgstr ""
8133 #. type: Content of: <book><chapter><sect1><para>
8134 #: ../en/ch08-undo.xml:189
8135 msgid ""
8136 "The <command role=\"hg-cmd\">hg revert</command> command provides us with an "
8137 "extra degree of safety by saving our modified file with a <filename>.orig</"
8138 "filename> extension."
8139 msgstr ""
8141 #. type: Content of: <book><chapter><sect1><para>
8142 #: ../en/ch08-undo.xml:196
8143 msgid ""
8144 "Here is a summary of the cases that the <command role=\"hg-cmd\">hg revert</"
8145 "command> command can deal with. We will describe each of these in more "
8146 "detail in the section that follows."
8147 msgstr ""
8149 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8150 #: ../en/ch08-undo.xml:201
8151 msgid "If you modify a file, it will restore the file to its unmodified state."
8152 msgstr ""
8154 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8155 #: ../en/ch08-undo.xml:204
8156 msgid ""
8157 "If you <command role=\"hg-cmd\">hg add</command> a file, it will undo the "
8158 "<quote>added</quote> state of the file, but leave the file itself untouched."
8159 msgstr ""
8161 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8162 #: ../en/ch08-undo.xml:208
8163 msgid ""
8164 "If you delete a file without telling Mercurial, it will restore the file to "
8165 "its unmodified contents."
8166 msgstr ""
8168 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8169 #: ../en/ch08-undo.xml:211
8170 msgid ""
8171 "If you use the <command role=\"hg-cmd\">hg remove</command> command to remove "
8172 "a file, it will undo the <quote>removed</quote> state of the file, and "
8173 "restore the file to its unmodified contents."
8174 msgstr ""
8176 #. type: Content of: <book><chapter><sect1><sect2><title>
8177 #: ../en/ch08-undo.xml:218
8178 msgid "File management errors"
8179 msgstr "文件管理错误"
8181 #. type: Content of: <book><chapter><sect1><sect2><para>
8182 #: ../en/ch08-undo.xml:220
8183 msgid ""
8184 "The <command role=\"hg-cmd\">hg revert</command> command is useful for more "
8185 "than just modified files. It lets you reverse the results of all of "
8186 "Mercurial's file management commands&emdash;<command role=\"hg-cmd\">hg add</"
8187 "command>, <command role=\"hg-cmd\">hg remove</command>, and so on."
8188 msgstr ""
8191 #. type: Content of: <book><chapter><sect1><sect2><para>
8192 #: ../en/ch08-undo.xml:226
8193 msgid ""
8194 "If you <command role=\"hg-cmd\">hg add</command> a file, then decide that in "
8195 "fact you don't want Mercurial to track it, use <command role=\"hg-cmd\">hg "
8196 "revert</command> to undo the add. Don't worry; Mercurial will not modify the "
8197 "file in any way. It will just <quote>unmark</quote> the file."
8198 msgstr ""
8200 #. type: Content of: <book><chapter><sect1><sect2><para>
8201 #: ../en/ch08-undo.xml:234
8202 msgid ""
8203 "Similarly, if you ask Mercurial to <command role=\"hg-cmd\">hg remove</"
8204 "command> a file, you can use <command role=\"hg-cmd\">hg revert</command> to "
8205 "restore it to the contents it had as of the parent of the working directory. "
8206 "&interaction.daily.revert.remove; This works just as well for a file that you "
8207 "deleted by hand, without telling Mercurial (recall that in Mercurial "
8208 "terminology, this kind of file is called <quote>missing</quote>)."
8209 msgstr ""
8212 #. type: Content of: <book><chapter><sect1><sect2><para>
8213 #: ../en/ch08-undo.xml:245
8214 msgid ""
8215 "If you revert a <command role=\"hg-cmd\">hg copy</command>, the copied-to "
8216 "file remains in your working directory afterwards, untracked. Since a copy "
8217 "doesn't affect the copied-from file in any way, Mercurial doesn't do anything "
8218 "with the copied-from file."
8219 msgstr ""
8221 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
8222 #: ../en/ch08-undo.xml:254
8223 msgid "A slightly special case: reverting a rename"
8224 msgstr "一个稍微特别的案例:撤销改名"
8226 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
8227 #: ../en/ch08-undo.xml:256
8228 msgid ""
8229 "If you <command role=\"hg-cmd\">hg rename</command> a file, there is one "
8230 "small detail that you should remember. When you <command role=\"hg-cmd\">hg "
8231 "revert</command> a rename, it's not enough to provide the name of the renamed-"
8232 "to file, as you can see here."
8233 msgstr ""
8235 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
8236 #: ../en/ch08-undo.xml:264
8237 msgid ""
8238 "As you can see from the output of <command role=\"hg-cmd\">hg status</"
8239 "command>, the renamed-to file is no longer identified as added, but the "
8240 "renamed-<emphasis>from</emphasis> file is still removed! This is counter-"
8241 "intuitive (at least to me), but at least it's easy to deal with."
8242 msgstr ""
8244 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
8245 #: ../en/ch08-undo.xml:273
8246 msgid ""
8247 "So remember, to revert a <command role=\"hg-cmd\">hg rename</command>, you "
8248 "must provide <emphasis>both</emphasis> the source and destination names."
8249 msgstr ""
8251 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
8252 #: ../en/ch08-undo.xml:278
8253 msgid "% TODO: the output doesn't look like it will be removed!"
8254 msgstr ""
8256 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
8257 #: ../en/ch08-undo.xml:281
8258 msgid ""
8259 "(By the way, if you rename a file, then modify the renamed-to file, then "
8260 "revert both components of the rename, when Mercurial restores the file that "
8261 "was removed as part of the rename, it will be unmodified. If you need the "
8262 "modifications in the renamed-to file to show up in the renamed-from file, "
8263 "don't forget to copy them over.)"
8264 msgstr ""
8266 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
8267 #: ../en/ch08-undo.xml:288
8268 msgid ""
8269 "These fiddly aspects of reverting a rename arguably constitute a small bug in "
8270 "Mercurial."
8271 msgstr ""
8273 #. type: Content of: <book><chapter><sect1><title>
8274 #: ../en/ch08-undo.xml:295
8275 msgid "Dealing with committed changes"
8276 msgstr "处理已经提交的修改"
8278 #. type: Content of: <book><chapter><sect1><para>
8279 #: ../en/ch08-undo.xml:297
8280 msgid ""
8281 "Consider a case where you have committed a change $a$, and another change $b$ "
8282 "on top of it; you then realise that change $a$ was incorrect. Mercurial lets "
8283 "you <quote>back out</quote> an entire changeset automatically, and building "
8284 "blocks that let you reverse part of a changeset by hand."
8285 msgstr ""
8287 #. type: Content of: <book><chapter><sect1><para>
8288 #: ../en/ch08-undo.xml:303
8289 msgid ""
8290 "Before you read this section, here's something to keep in mind: the <command "
8291 "role=\"hg-cmd\">hg backout</command> command undoes changes by "
8292 "<emphasis>adding</emphasis> history, not by modifying or erasing it. It's "
8293 "the right tool to use if you're fixing bugs, but not if you're trying to undo "
8294 "some change that has catastrophic consequences. To deal with those, see "
8295 "section <xref linkend=\"sec.undo.aaaiiieee\"/>."
8296 msgstr ""
8298 #. type: Content of: <book><chapter><sect1><sect2><title>
8299 #: ../en/ch08-undo.xml:312
8300 msgid "Backing out a changeset"
8301 msgstr "恢复一个修改集"
8303 #. type: Content of: <book><chapter><sect1><sect2><para>
8304 #: ../en/ch08-undo.xml:314
8305 msgid ""
8306 "The <command role=\"hg-cmd\">hg backout</command> command lets you "
8307 "<quote>undo</quote> the effects of an entire changeset in an automated "
8308 "fashion. Because Mercurial's history is immutable, this command "
8309 "<emphasis>does not</emphasis> get rid of the changeset you want to undo. "
8310 "Instead, it creates a new changeset that <emphasis>reverses</emphasis> the "
8311 "effect of the to-be-undone changeset."
8312 msgstr ""
8315 #. type: Content of: <book><chapter><sect1><sect2><para>
8316 #: ../en/ch08-undo.xml:323
8317 msgid ""
8318 "The operation of the <command role=\"hg-cmd\">hg backout</command> command is "
8319 "a little intricate, so let's illustrate it with some examples. First, we'll "
8320 "create a repository with some simple changes."
8321 msgstr ""
8323 #. type: Content of: <book><chapter><sect1><sect2><para>
8324 #: ../en/ch08-undo.xml:330
8325 msgid ""
8326 "The <command role=\"hg-cmd\">hg backout</command> command takes a single "
8327 "changeset ID as its argument; this is the changeset to back out. Normally, "
8328 "<command role=\"hg-cmd\">hg backout</command> will drop you into a text "
8329 "editor to write a commit message, so you can record why you're backing the "
8330 "change out. In this example, we provide a commit message on the command line "
8331 "using the <option role=\"hg-opt-backout\">-m</option> option."
8332 msgstr ""
8334 #. type: Content of: <book><chapter><sect1><sect2><title>
8335 #: ../en/ch08-undo.xml:341
8336 msgid "Backing out the tip changeset"
8337 msgstr "恢复顶点修改集"
8339 #. type: Content of: <book><chapter><sect1><sect2><para>
8340 #: ../en/ch08-undo.xml:343
8341 msgid "We're going to start by backing out the last changeset we committed."
8342 msgstr ""
8344 #. type: Content of: <book><chapter><sect1><sect2><para>
8345 #: ../en/ch08-undo.xml:348
8346 msgid ""
8347 "You can see that the second line from <filename>myfile</filename> is no "
8348 "longer present. Taking a look at the output of <command role=\"hg-cmd\">hg "
8349 "log</command> gives us an idea of what the <command role=\"hg-cmd\">hg "
8350 "backout</command> command has done. &interaction.backout.simple.log; Notice "
8351 "that the new changeset that <command role=\"hg-cmd\">hg backout</command> has "
8352 "created is a child of the changeset we backed out. It's easier to see this "
8353 "in figure <xref endterm=\"fig.undo.backout.caption\" linkend=\"fig.undo."
8354 "backout\"/>, which presents a graphical view of the change history. As you "
8355 "can see, the history is nice and linear."
8356 msgstr ""
8358 #. type: Content of: <book><chapter><sect1><sect2><informalfigure><mediaobject>
8359 #: ../en/ch08-undo.xml:364
8360 msgid ""
8361 "<imageobject><imagedata fileref=\"images/undo-simple.png\"/> </imageobject>"
8362 msgstr ""
8364 #. type: Content of: <book><chapter><sect1><sect2><informalfigure><mediaobject><caption><para>
8365 #: ../en/ch08-undo.xml:367 ../en/ch08-undo.xml:486
8366 msgid ""
8367 "Backing out a change using the <command role=\"hg-cmd\">hg backout</command> "
8368 "command"
8369 msgstr ""
8371 #. type: Content of: <book><chapter><sect1><sect2><title>
8372 #: ../en/ch08-undo.xml:376
8373 msgid "Backing out a non-tip change"
8374 msgstr "恢复非顶点的修改"
8376 #. type: Content of: <book><chapter><sect1><sect2><para>
8377 #: ../en/ch08-undo.xml:378
8378 msgid ""
8379 "If you want to back out a change other than the last one you committed, pass "
8380 "the <option role=\"hg-opt-backout\">--merge</option> option to the <command "
8381 "role=\"hg-cmd\">hg backout</command> command."
8382 msgstr ""
8384 #. type: Content of: <book><chapter><sect1><sect2><para>
8385 #: ../en/ch08-undo.xml:385
8386 msgid ""
8387 "This makes backing out any changeset a <quote>one-shot</quote> operation "
8388 "that's usually simple and fast."
8389 msgstr ""
8391 #. type: Content of: <book><chapter><sect1><sect2><para>
8392 #: ../en/ch08-undo.xml:391
8393 msgid ""
8394 "If you take a look at the contents of <filename>myfile</filename> after the "
8395 "backout finishes, you'll see that the first and third changes are present, "
8396 "but not the second."
8397 msgstr ""
8399 #. type: Content of: <book><chapter><sect1><sect2><para>
8400 #: ../en/ch08-undo.xml:398
8401 msgid ""
8402 "As the graphical history in figure <xref endterm=\"fig.undo.backout-non-tip."
8403 "caption\" linkend=\"fig.undo.backout-non-tip\"/> illustrates, Mercurial "
8404 "actually commits <emphasis>two</emphasis> changes in this kind of situation "
8405 "(the box-shaped nodes are the ones that Mercurial commits automatically). "
8406 "Before Mercurial begins the backout process, it first remembers what the "
8407 "current parent of the working directory is. It then backs out the target "
8408 "changeset, and commits that as a changeset. Finally, it merges back to the "
8409 "previous parent of the working directory, and commits the result of the merge."
8410 msgstr ""
8412 #. type: Content of: <book><chapter><sect1><sect2><para>
8413 #: ../en/ch08-undo.xml:410
8414 msgid ""
8415 "% TODO: to me it looks like mercurial doesn't commit the second merge "
8416 "automatically!"
8417 msgstr ""
8419 #. type: Content of: <book><chapter><sect1><sect2><informalfigure><mediaobject>
8420 #: ../en/ch08-undo.xml:415
8421 msgid ""
8422 "<imageobject><imagedata fileref=\"images/undo-non-tip.png\"/> </imageobject>"
8423 msgstr ""
8425 #. type: Content of: <book><chapter><sect1><sect2><informalfigure><mediaobject><caption><para>
8426 #: ../en/ch08-undo.xml:418
8427 msgid ""
8428 "Automated backout of a non-tip change using the <command role=\"hg-cmd\">hg "
8429 "backout</command> command"
8430 msgstr ""
8432 #. type: Content of: <book><chapter><sect1><sect2><para>
8433 #: ../en/ch08-undo.xml:424
8434 msgid ""
8435 "The result is that you end up <quote>back where you were</quote>, only with "
8436 "some extra history that undoes the effect of the changeset you wanted to back "
8437 "out."
8438 msgstr ""
8440 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
8441 #: ../en/ch08-undo.xml:429
8442 msgid "Always use the <option role=\"hg-opt-backout\">--merge</option> option"
8443 msgstr "始终使用选项 <option role=\"hg-opt-backout\">--merge</option>"
8445 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
8446 #: ../en/ch08-undo.xml:432
8447 msgid ""
8448 "In fact, since the <option role=\"hg-opt-backout\">--merge</option> option "
8449 "will do the <quote>right thing</quote> whether or not the changeset you're "
8450 "backing out is the tip (i.e. it won't try to merge if it's backing out the "
8451 "tip, since there's no need), you should <emphasis>always</emphasis> use this "
8452 "option when you run the <command role=\"hg-cmd\">hg backout</command> command."
8453 msgstr ""
8455 #. type: Content of: <book><chapter><sect1><sect2><title>
8456 #: ../en/ch08-undo.xml:443
8457 msgid "Gaining more control of the backout process"
8458 msgstr "在恢复处理中获得更多控制"
8460 #. type: Content of: <book><chapter><sect1><sect2><para>
8461 #: ../en/ch08-undo.xml:445
8462 msgid ""
8463 "While I've recommended that you always use the <option role=\"hg-opt-backout"
8464 "\">--merge</option> option when backing out a change, the <command role=\"hg-"
8465 "cmd\">hg backout</command> command lets you decide how to merge a backout "
8466 "changeset. Taking control of the backout process by hand is something you "
8467 "will rarely need to do, but it can be useful to understand what the <command "
8468 "role=\"hg-cmd\">hg backout</command> command is doing for you automatically. "
8469 "To illustrate this, let's clone our first repository, but omit the backout "
8470 "change that it contains."
8471 msgstr ""
8473 #. type: Content of: <book><chapter><sect1><sect2><para>
8474 #: ../en/ch08-undo.xml:458
8475 msgid ""
8476 "As with our earlier example, We'll commit a third changeset, then back out "
8477 "its parent, and see what happens."
8478 msgstr ""
8480 #. type: Content of: <book><chapter><sect1><sect2><para>
8481 #: ../en/ch08-undo.xml:464
8482 msgid ""
8483 "Our new changeset is again a descendant of the changeset we backout out; it's "
8484 "thus a new head, <emphasis>not</emphasis> a descendant of the changeset that "
8485 "was the tip. The <command role=\"hg-cmd\">hg backout</command> command was "
8486 "quite explicit in telling us this."
8487 msgstr ""
8489 #. type: Content of: <book><chapter><sect1><sect2><para>
8490 #: ../en/ch08-undo.xml:472
8491 msgid ""
8492 "Again, it's easier to see what has happened by looking at a graph of the "
8493 "revision history, in figure <xref endterm=\"fig.undo.backout-manual.caption\" "
8494 "linkend=\"fig.undo.backout-manual\"/>. This makes it clear that when we use "
8495 "<command role=\"hg-cmd\">hg backout</command> to back out a change other than "
8496 "the tip, Mercurial adds a new head to the repository (the change it committed "
8497 "is box-shaped)."
8498 msgstr ""
8500 #. type: Content of: <book><chapter><sect1><sect2><informalfigure><mediaobject>
8501 #: ../en/ch08-undo.xml:483
8502 msgid ""
8503 "<imageobject><imagedata fileref=\"images/undo-manual.png\"/> </imageobject>"
8504 msgstr ""
8506 #. type: Content of: <book><chapter><sect1><sect2><para>
8507 #: ../en/ch08-undo.xml:492
8508 msgid ""
8509 "After the <command role=\"hg-cmd\">hg backout</command> command has "
8510 "completed, it leaves the new <quote>backout</quote> changeset as the parent "
8511 "of the working directory."
8512 msgstr ""
8514 #. type: Content of: <book><chapter><sect1><sect2><para>
8515 #: ../en/ch08-undo.xml:499
8516 msgid "Now we have two isolated sets of changes."
8517 msgstr ""
8519 #. type: Content of: <book><chapter><sect1><sect2><para>
8520 #: ../en/ch08-undo.xml:503
8521 msgid ""
8522 "Let's think about what we expect to see as the contents of <filename>myfile</"
8523 "filename> now. The first change should be present, because we've never "
8524 "backed it out. The second change should be missing, as that's the change we "
8525 "backed out. Since the history graph shows the third change as a separate "
8526 "head, we <emphasis>don't</emphasis> expect to see the third change present in "
8527 "<filename>myfile</filename>."
8528 msgstr ""
8530 #. type: Content of: <book><chapter><sect1><sect2><para>
8531 #: ../en/ch08-undo.xml:513
8532 msgid ""
8533 "To get the third change back into the file, we just do a normal merge of our "
8534 "two heads."
8535 msgstr ""
8537 #. type: Content of: <book><chapter><sect1><sect2><para>
8538 #: ../en/ch08-undo.xml:518
8539 msgid ""
8540 "Afterwards, the graphical history of our repository looks like figure <xref "
8541 "endterm=\"fig.undo.backout-manual-merge.caption\" linkend=\"fig.undo.backout-"
8542 "manual-merge\"/>."
8543 msgstr ""
8545 #. type: Content of: <book><chapter><sect1><sect2><informalfigure><mediaobject>
8546 #: ../en/ch08-undo.xml:525
8547 msgid ""
8548 "<imageobject><imagedata fileref=\"images/undo-manual-merge.png\"/> </"
8549 "imageobject>"
8550 msgstr ""
8552 #. type: Content of: <book><chapter><sect1><sect2><informalfigure><mediaobject><caption><para>
8553 #: ../en/ch08-undo.xml:528
8554 msgid "Manually merging a backout change"
8555 msgstr ""
8557 #. type: Content of: <book><chapter><sect1><sect2><title>
8558 #: ../en/ch08-undo.xml:535
8559 msgid "Why <command role=\"hg-cmd\">hg backout</command> works as it does"
8560 msgstr "<command role=\"hg-cmd\">hg backout</command> 的内幕"
8562 #. type: Content of: <book><chapter><sect1><sect2><para>
8563 #: ../en/ch08-undo.xml:538
8564 msgid ""
8565 "Here's a brief description of how the <command role=\"hg-cmd\">hg backout</"
8566 "command> command works."
8567 msgstr ""
8569 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
8570 #: ../en/ch08-undo.xml:541
8571 msgid ""
8572 "It ensures that the working directory is <quote>clean</quote>, i.e. that the "
8573 "output of <command role=\"hg-cmd\">hg status</command> would be empty."
8574 msgstr ""
8576 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
8577 #: ../en/ch08-undo.xml:545
8578 msgid ""
8579 "It remembers the current parent of the working directory. Let's call this "
8580 "changeset <literal>orig</literal>"
8581 msgstr ""
8583 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
8584 #: ../en/ch08-undo.xml:549
8585 msgid ""
8586 "It does the equivalent of a <command role=\"hg-cmd\">hg update</command> to "
8587 "sync the working directory to the changeset you want to back out. Let's call "
8588 "this changeset <literal>backout</literal>"
8589 msgstr ""
8591 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
8592 #: ../en/ch08-undo.xml:554
8593 msgid ""
8594 "It finds the parent of that changeset. Let's call that changeset "
8595 "<literal>parent</literal>."
8596 msgstr ""
8598 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
8599 #: ../en/ch08-undo.xml:557
8600 msgid ""
8601 "For each file that the <literal>backout</literal> changeset affected, it does "
8602 "the equivalent of a <command role=\"hg-cmd\">hg revert -r parent</command> on "
8603 "that file, to restore it to the contents it had before that changeset was "
8604 "committed."
8605 msgstr ""
8607 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
8608 #: ../en/ch08-undo.xml:564
8609 msgid ""
8610 "It commits the result as a new changeset. This changeset has "
8611 "<literal>backout</literal> as its parent."
8612 msgstr ""
8614 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
8615 #: ../en/ch08-undo.xml:568
8616 msgid ""
8617 "If you specify <option role=\"hg-opt-backout\">--merge</option> on the "
8618 "command line, it merges with <literal>orig</literal>, and commits the result "
8619 "of the merge."
8620 msgstr ""
8622 #. type: Content of: <book><chapter><sect1><sect2><para>
8623 #: ../en/ch08-undo.xml:574
8624 msgid ""
8625 "An alternative way to implement the <command role=\"hg-cmd\">hg backout</"
8626 "command> command would be to <command role=\"hg-cmd\">hg export</command> the "
8627 "to-be-backed-out changeset as a diff, then use the <option role=\"cmd-opt-"
8628 "patch\">--reverse</option> option to the <command>patch</command> command to "
8629 "reverse the effect of the change without fiddling with the working "
8630 "directory. This sounds much simpler, but it would not work nearly as well."
8631 msgstr ""
8633 #. type: Content of: <book><chapter><sect1><sect2><para>
8634 #: ../en/ch08-undo.xml:584
8635 msgid ""
8636 "The reason that <command role=\"hg-cmd\">hg backout</command> does an update, "
8637 "a commit, a merge, and another commit is to give the merge machinery the best "
8638 "chance to do a good job when dealing with all the changes <emphasis>between</"
8639 "emphasis> the change you're backing out and the current tip."
8640 msgstr ""
8642 #. type: Content of: <book><chapter><sect1><sect2><para>
8643 #: ../en/ch08-undo.xml:591
8644 msgid ""
8645 "If you're backing out a changeset that's 100 revisions back in your project's "
8646 "history, the chances that the <command>patch</command> command will be able "
8647 "to apply a reverse diff cleanly are not good, because intervening changes are "
8648 "likely to have <quote>broken the context</quote> that <command>patch</"
8649 "command> uses to determine whether it can apply a patch (if this sounds like "
8650 "gibberish, see <xref linkend=\"sec.mq.patch\"/> for a discussion of the "
8651 "<command>patch</command> command). Also, Mercurial's merge machinery will "
8652 "handle files and directories being renamed, permission changes, and "
8653 "modifications to binary files, none of which <command>patch</command> can "
8654 "deal with."
8655 msgstr ""
8657 #. type: Content of: <book><chapter><sect1><title>
8658 #: ../en/ch08-undo.xml:608
8659 msgid "Changes that should never have been"
8660 msgstr "不该发生的修改"
8662 #. type: Content of: <book><chapter><sect1><para>
8663 #: ../en/ch08-undo.xml:610
8664 msgid ""
8665 "Most of the time, the <command role=\"hg-cmd\">hg backout</command> command "
8666 "is exactly what you need if you want to undo the effects of a change. It "
8667 "leaves a permanent record of exactly what you did, both when committing the "
8668 "original changeset and when you cleaned up after it."
8669 msgstr ""
8671 #. type: Content of: <book><chapter><sect1><para>
8672 #: ../en/ch08-undo.xml:616
8673 msgid ""
8674 "On rare occasions, though, you may find that you've committed a change that "
8675 "really should not be present in the repository at all. For example, it would "
8676 "be very unusual, and usually considered a mistake, to commit a software "
8677 "project's object files as well as its source files. Object files have almost "
8678 "no intrinsic value, and they're <emphasis>big</emphasis>, so they increase "
8679 "the size of the repository and the amount of time it takes to clone or pull "
8680 "changes."
8681 msgstr ""
8683 #. type: Content of: <book><chapter><sect1><para>
8684 #: ../en/ch08-undo.xml:625
8685 msgid ""
8686 "Before I discuss the options that you have if you commit a <quote>brown paper "
8687 "bag</quote> change (the kind that's so bad that you want to pull a brown "
8688 "paper bag over your head), let me first discuss some approaches that probably "
8689 "won't work."
8690 msgstr ""
8692 #. type: Content of: <book><chapter><sect1><para>
8693 #: ../en/ch08-undo.xml:630
8694 msgid ""
8695 "Since Mercurial treats history as accumulative&emdash;every change builds on "
8696 "top of all changes that preceded it&emdash;you generally can't just make "
8697 "disastrous changes disappear. The one exception is when you've just "
8698 "committed a change, and it hasn't been pushed or pulled into another "
8699 "repository. That's when you can safely use the <command role=\"hg-cmd\">hg "
8700 "rollback</command> command, as I detailed in section <xref linkend=\"sec.undo."
8701 "rollback\"/>."
8702 msgstr ""
8704 #. type: Content of: <book><chapter><sect1><para>
8705 #: ../en/ch08-undo.xml:639
8706 msgid ""
8707 "After you've pushed a bad change to another repository, you <emphasis>could</"
8708 "emphasis> still use <command role=\"hg-cmd\">hg rollback</command> to make "
8709 "your local copy of the change disappear, but it won't have the consequences "
8710 "you want. The change will still be present in the remote repository, so it "
8711 "will reappear in your local repository the next time you pull."
8712 msgstr ""
8714 #. type: Content of: <book><chapter><sect1><para>
8715 #: ../en/ch08-undo.xml:647
8716 msgid ""
8717 "If a situation like this arises, and you know which repositories your bad "
8718 "change has propagated into, you can <emphasis>try</emphasis> to get rid of "
8719 "the changeefrom <emphasis>every</emphasis> one of those repositories. This "
8720 "is, of course, not a satisfactory solution: if you miss even a single "
8721 "repository while you're expunging, the change is still <quote>in the wild</"
8722 "quote>, and could propagate further."
8723 msgstr ""
8725 #. type: Content of: <book><chapter><sect1><para>
8726 #: ../en/ch08-undo.xml:655
8727 msgid ""
8728 "If you've committed one or more changes <emphasis>after</emphasis> the change "
8729 "that you'd like to see disappear, your options are further reduced. Mercurial "
8730 "doesn't provide a way to <quote>punch a hole</quote> in history, leaving "
8731 "changesets intact."
8732 msgstr ""
8734 #. type: Content of: <book><chapter><sect1><para>
8735 #: ../en/ch08-undo.xml:661
8736 msgid ""
8737 "XXX This needs filling out. The <literal>hg-replay</literal> script in the "
8738 "<literal>examples</literal> directory works, but doesn't handle merge "
8739 "changesets. Kind of an important omission."
8740 msgstr ""
8742 #. type: Content of: <book><chapter><sect1><sect2><title>
8743 #: ../en/ch08-undo.xml:667
8744 msgid "Protect yourself from <quote>escaped</quote> changes"
8745 msgstr "使用<quote>校验</quote>修改来保护你自己"
8747 #. type: Content of: <book><chapter><sect1><sect2><para>
8748 #: ../en/ch08-undo.xml:670
8749 msgid ""
8750 "If you've committed some changes to your local repository and they've been "
8751 "pushed or pulled somewhere else, this isn't necessarily a disaster. You can "
8752 "protect yourself ahead of time against some classes of bad changeset. This "
8753 "is particularly easy if your team usually pulls changes from a central "
8754 "repository."
8755 msgstr ""
8757 #. type: Content of: <book><chapter><sect1><sect2><para>
8758 #: ../en/ch08-undo.xml:677
8759 msgid ""
8760 "By configuring some hooks on that repository to validate incoming changesets "
8761 "(see chapter <xref linkend=\"chap.hook\"/>), you can automatically prevent "
8762 "some kinds of bad changeset from being pushed to the central repository at "
8763 "all. With such a configuration in place, some kinds of bad changeset will "
8764 "naturally tend to <quote>die out</quote> because they can't propagate into "
8765 "the central repository. Better yet, this happens without any need for "
8766 "explicit intervention."
8767 msgstr ""
8769 #. type: Content of: <book><chapter><sect1><sect2><para>
8770 #: ../en/ch08-undo.xml:687
8771 msgid ""
8772 "For instance, an incoming change hook that verifies that a changeset will "
8773 "actually compile can prevent people from inadvertantly <quote>breaking the "
8774 "build</quote>."
8775 msgstr ""
8777 #. type: Content of: <book><chapter><sect1><title>
8778 #: ../en/ch08-undo.xml:694
8779 msgid "Finding the source of a bug"
8780 msgstr "查找问题的根源"
8782 #. type: Content of: <book><chapter><sect1><para>
8783 #: ../en/ch08-undo.xml:696
8784 msgid ""
8785 "While it's all very well to be able to back out a changeset that introduced a "
8786 "bug, this requires that you know which changeset to back out. Mercurial "
8787 "provides an invaluable command, called <command role=\"hg-cmd\">hg bisect</"
8788 "command>, that helps you to automate this process and accomplish it very "
8789 "efficiently."
8790 msgstr ""
8792 #. type: Content of: <book><chapter><sect1><para>
8793 #: ../en/ch08-undo.xml:703
8794 msgid ""
8795 "The idea behind the <command role=\"hg-cmd\">hg bisect</command> command is "
8796 "that a changeset has introduced some change of behaviour that you can "
8797 "identify with a simple binary test. You don't know which piece of code "
8798 "introduced the change, but you know how to test for the presence of the bug. "
8799 "The <command role=\"hg-cmd\">hg bisect</command> command uses your test to "
8800 "direct its search for the changeset that introduced the code that caused the "
8801 "bug."
8802 msgstr ""
8804 #. type: Content of: <book><chapter><sect1><para>
8805 #: ../en/ch08-undo.xml:712
8806 msgid ""
8807 "Here are a few scenarios to help you understand how you might apply this "
8808 "command."
8809 msgstr ""
8811 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8812 #: ../en/ch08-undo.xml:715
8813 msgid ""
8814 "The most recent version of your software has a bug that you remember wasn't "
8815 "present a few weeks ago, but you don't know when it was introduced. Here, "
8816 "your binary test checks for the presence of that bug."
8817 msgstr ""
8819 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8820 #: ../en/ch08-undo.xml:720
8821 msgid ""
8822 "You fixed a bug in a rush, and now it's time to close the entry in your "
8823 "team's bug database. The bug database requires a changeset ID when you close "
8824 "an entry, but you don't remember which changeset you fixed the bug in. Once "
8825 "again, your binary test checks for the presence of the bug."
8826 msgstr ""
8828 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8829 #: ../en/ch08-undo.xml:727
8830 msgid ""
8831 "Your software works correctly, but runs 15% slower than the last time you "
8832 "measured it. You want to know which changeset introduced the performance "
8833 "regression. In this case, your binary test measures the performance of your "
8834 "software, to see whether it's <quote>fast</quote> or <quote>slow</quote>."
8835 msgstr ""
8837 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8838 #: ../en/ch08-undo.xml:734
8839 msgid ""
8840 "The sizes of the components of your project that you ship exploded recently, "
8841 "and you suspect that something changed in the way you build your project."
8842 msgstr ""
8844 #. type: Content of: <book><chapter><sect1><para>
8845 #: ../en/ch08-undo.xml:739
8846 msgid ""
8847 "From these examples, it should be clear that the <command role=\"hg-cmd\">hg "
8848 "bisect</command> command is not useful only for finding the sources of bugs. "
8849 "You can use it to find any <quote>emergent property</quote> of a repository "
8850 "(anything that you can't find from a simple text search of the files in the "
8851 "tree) for which you can write a binary test."
8852 msgstr ""
8854 #. type: Content of: <book><chapter><sect1><para>
8855 #: ../en/ch08-undo.xml:746
8856 msgid ""
8857 "We'll introduce a little bit of terminology here, just to make it clear which "
8858 "parts of the search process are your responsibility, and which are "
8859 "Mercurial's. A <emphasis>test</emphasis> is something that <emphasis>you</"
8860 "emphasis> run when <command role=\"hg-cmd\">hg bisect</command> chooses a "
8861 "changeset. A <emphasis>probe</emphasis> is what <command role=\"hg-cmd\">hg "
8862 "bisect</command> runs to tell whether a revision is good. Finally, we'll use "
8863 "the word <quote>bisect</quote>, as both a noun and a verb, to stand in for "
8864 "the phrase <quote>search using the <command role=\"hg-cmd\">hg bisect</"
8865 "command> command</quote>."
8866 msgstr ""
8868 #. type: Content of: <book><chapter><sect1><para>
8869 #: ../en/ch08-undo.xml:759
8870 msgid ""
8871 "One simple way to automate the searching process would be simply to probe "
8872 "every changeset. However, this scales poorly. If it took ten minutes to "
8873 "test a single changeset, and you had 10,000 changesets in your repository, "
8874 "the exhaustive approach would take on average 35 <emphasis>days</emphasis> to "
8875 "find the changeset that introduced a bug. Even if you knew that the bug was "
8876 "introduced by one of the last 500 changesets, and limited your search to "
8877 "those, you'd still be looking at over 40 hours to find the changeset that "
8878 "introduced your bug."
8879 msgstr ""
8881 #. type: Content of: <book><chapter><sect1><para>
8882 #: ../en/ch08-undo.xml:769
8883 msgid ""
8884 "What the <command role=\"hg-cmd\">hg bisect</command> command does is use its "
8885 "knowledge of the <quote>shape</quote> of your project's revision history to "
8886 "perform a search in time proportional to the <emphasis>logarithm</emphasis> "
8887 "of the number of changesets to check (the kind of search it performs is "
8888 "called a dichotomic search). With this approach, searching through 10,000 "
8889 "changesets will take less than three hours, even at ten minutes per test (the "
8890 "search will require about 14 tests). Limit your search to the last hundred "
8891 "changesets, and it will take only about an hour (roughly seven tests)."
8892 msgstr ""
8894 #. type: Content of: <book><chapter><sect1><para>
8895 #: ../en/ch08-undo.xml:780
8896 msgid ""
8897 "The <command role=\"hg-cmd\">hg bisect</command> command is aware of the "
8898 "<quote>branchy</quote> nature of a Mercurial project's revision history, so "
8899 "it has no problems dealing with branches, merges, or multiple heads in a "
8900 "repository. It can prune entire branches of history with a single probe, "
8901 "which is how it operates so efficiently."
8902 msgstr ""
8904 #. type: Content of: <book><chapter><sect1><sect2><title>
8905 #: ../en/ch08-undo.xml:788
8906 msgid "Using the <command role=\"hg-cmd\">hg bisect</command> command"
8907 msgstr "使用命令 <command role=\"hg-cmd\">hg bisect</command>"
8909 #. type: Content of: <book><chapter><sect1><sect2><para>
8910 #: ../en/ch08-undo.xml:791
8911 msgid ""
8912 "Here's an example of <command role=\"hg-cmd\">hg bisect</command> in action."
8913 msgstr ""
8915 #. type: Content of: <book><chapter><sect1><sect2><note><para>
8916 #: ../en/ch08-undo.xml:795
8917 msgid ""
8918 "In versions 0.9.5 and earlier of Mercurial, <command role=\"hg-cmd\">hg "
8919 "bisect</command> was not a core command: it was distributed with Mercurial as "
8920 "an extension. This section describes the built-in command, not the old "
8921 "extension."
8922 msgstr ""
8924 #. type: Content of: <book><chapter><sect1><sect2><para>
8925 #: ../en/ch08-undo.xml:802
8926 msgid ""
8927 "Now let's create a repository, so that we can try out the <command role=\"hg-"
8928 "cmd\">hg bisect</command> command in isolation."
8929 msgstr ""
8931 #. type: Content of: <book><chapter><sect1><sect2><para>
8932 #: ../en/ch08-undo.xml:808
8933 msgid ""
8934 "We'll simulate a project that has a bug in it in a simple-minded way: create "
8935 "trivial changes in a loop, and nominate one specific change that will have "
8936 "the <quote>bug</quote>. This loop creates 35 changesets, each adding a "
8937 "single file to the repository. We'll represent our <quote>bug</quote> with a "
8938 "file that contains the text <quote>i have a gub</quote>."
8939 msgstr ""
8941 #. type: Content of: <book><chapter><sect1><sect2><para>
8942 #: ../en/ch08-undo.xml:818
8943 msgid ""
8944 "The next thing that we'd like to do is figure out how to use the <command "
8945 "role=\"hg-cmd\">hg bisect</command> command. We can use Mercurial's normal "
8946 "built-in help mechanism for this."
8947 msgstr ""
8949 #. type: Content of: <book><chapter><sect1><sect2><para>
8950 #: ../en/ch08-undo.xml:825
8951 msgid ""
8952 "The <command role=\"hg-cmd\">hg bisect</command> command works in steps. "
8953 "Each step proceeds as follows."
8954 msgstr ""
8956 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
8957 #: ../en/ch08-undo.xml:828
8958 msgid "You run your binary test."
8959 msgstr ""
8961 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><itemizedlist><listitem><para>
8962 #: ../en/ch08-undo.xml:830
8963 msgid ""
8964 "If the test succeeded, you tell <command role=\"hg-cmd\">hg bisect</command> "
8965 "by running the <command role=\"hg-cmd\">hg bisect good</command> command."
8966 msgstr ""
8968 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><itemizedlist><listitem><para>
8969 #: ../en/ch08-undo.xml:835
8970 msgid ""
8971 "If it failed, run the <command role=\"hg-cmd\">hg bisect bad</command> "
8972 "command."
8973 msgstr ""
8975 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
8976 #: ../en/ch08-undo.xml:839
8977 msgid ""
8978 "The command uses your information to decide which changeset to test next."
8979 msgstr ""
8981 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
8982 #: ../en/ch08-undo.xml:842
8983 msgid ""
8984 "It updates the working directory to that changeset, and the process begins "
8985 "again."
8986 msgstr ""
8988 #. type: Content of: <book><chapter><sect1><sect2><para>
8989 #: ../en/ch08-undo.xml:845
8990 msgid ""
8991 "The process ends when <command role=\"hg-cmd\">hg bisect</command> identifies "
8992 "a unique changeset that marks the point where your test transitioned from "
8993 "<quote>succeeding</quote> to <quote>failing</quote>."
8994 msgstr ""
8997 #. type: Content of: <book><chapter><sect1><sect2><para>
8998 #: ../en/ch08-undo.xml:850
8999 msgid ""
9000 "To start the search, we must run the <command role=\"hg-cmd\">hg bisect --"
9001 "reset</command> command."
9002 msgstr ""
9004 #. type: Content of: <book><chapter><sect1><sect2><para>
9005 #: ../en/ch08-undo.xml:855
9006 msgid ""
9007 "In our case, the binary test we use is simple: we check to see if any file in "
9008 "the repository contains the string <quote>i have a gub</quote>. If it does, "
9009 "this changeset contains the change that <quote>caused the bug</quote>. By "
9010 "convention, a changeset that has the property we're searching for is "
9011 "<quote>bad</quote>, while one that doesn't is <quote>good</quote>."
9012 msgstr ""
9014 #. type: Content of: <book><chapter><sect1><sect2><para>
9015 #: ../en/ch08-undo.xml:863
9016 msgid ""
9017 "Most of the time, the revision to which the working directory is synced "
9018 "(usually the tip) already exhibits the problem introduced by the buggy "
9019 "change, so we'll mark it as <quote>bad</quote>."
9020 msgstr ""
9023 #. type: Content of: <book><chapter><sect1><sect2><para>
9024 #: ../en/ch08-undo.xml:870
9025 msgid ""
9026 "Our next task is to nominate a changeset that we know <emphasis>doesn't</"
9027 "emphasis> have the bug; the <command role=\"hg-cmd\">hg bisect</command> "
9028 "command will <quote>bracket</quote> its search between the first pair of good "
9029 "and bad changesets. In our case, we know that revision 10 didn't have the "
9030 "bug. (I'll have more words about choosing the first <quote>good</quote> "
9031 "changeset later.)"
9032 msgstr ""
9034 #. type: Content of: <book><chapter><sect1><sect2><para>
9035 #: ../en/ch08-undo.xml:880
9036 msgid "Notice that this command printed some output."
9037 msgstr ""
9039 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9040 #: ../en/ch08-undo.xml:882
9041 msgid ""
9042 "It told us how many changesets it must consider before it can identify the "
9043 "one that introduced the bug, and how many tests that will require."
9044 msgstr ""
9046 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9047 #: ../en/ch08-undo.xml:886
9048 msgid ""
9049 "It updated the working directory to the next changeset to test, and told us "
9050 "which changeset it's testing."
9051 msgstr ""
9053 #. type: Content of: <book><chapter><sect1><sect2><para>
9054 #: ../en/ch08-undo.xml:891
9055 msgid ""
9056 "We now run our test in the working directory. We use the <command>grep</"
9057 "command> command to see if our <quote>bad</quote> file is present in the "
9058 "working directory. If it is, this revision is bad; if not, this revision is "
9059 "good. &interaction.bisect.search.step1;"
9060 msgstr ""
9062 #. type: Content of: <book><chapter><sect1><sect2><para>
9063 #: ../en/ch08-undo.xml:897
9064 msgid ""
9065 "This test looks like a perfect candidate for automation, so let's turn it "
9066 "into a shell function."
9067 msgstr ""
9069 #. type: Content of: <book><chapter><sect1><sect2><para>
9070 #: ../en/ch08-undo.xml:901
9071 msgid ""
9072 "We can now run an entire test step with a single command, <literal>mytest</"
9073 "literal>."
9074 msgstr ""
9076 #. type: Content of: <book><chapter><sect1><sect2><para>
9077 #: ../en/ch08-undo.xml:906
9078 msgid "A few more invocations of our canned test step command, and we're done."
9079 msgstr ""
9081 #. type: Content of: <book><chapter><sect1><sect2><para>
9082 #: ../en/ch08-undo.xml:911
9083 msgid ""
9084 "Even though we had 40 changesets to search through, the <command role=\"hg-cmd"
9085 "\">hg bisect</command> command let us find the changeset that introduced our "
9086 "<quote>bug</quote> with only five tests. Because the number of tests that "
9087 "the <command role=\"hg-cmd\">hg bisect</command> command performs grows "
9088 "logarithmically with the number of changesets to search, the advantage that "
9089 "it has over the <quote>brute force</quote> search approach increases with "
9090 "every changeset you add."
9091 msgstr ""
9093 #. type: Content of: <book><chapter><sect1><sect2><title>
9094 #: ../en/ch08-undo.xml:922
9095 msgid "Cleaning up after your search"
9096 msgstr "搜索后的清理"
9099 #. type: Content of: <book><chapter><sect1><sect2><para>
9100 #: ../en/ch08-undo.xml:924
9101 msgid ""
9102 "When you're finished using the <command role=\"hg-cmd\">hg bisect</command> "
9103 "command in a repository, you can use the <command role=\"hg-cmd\">hg bisect "
9104 "reset</command> command to drop the information it was using to drive your "
9105 "search. The command doesn't use much space, so it doesn't matter if you "
9106 "forget to run this command. However, <command role=\"hg-cmd\">hg bisect</"
9107 "command> won't let you start a new search in that repository until you do a "
9108 "<command role=\"hg-cmd\">hg bisect reset</command>."
9109 msgstr ""
9111 #. type: Content of: <book><chapter><sect1><title>
9112 #: ../en/ch08-undo.xml:939
9113 msgid "Tips for finding bugs effectively"
9114 msgstr "有效查找问题的技巧"
9116 #. type: Content of: <book><chapter><sect1><sect2><title>
9117 #: ../en/ch08-undo.xml:942
9118 msgid "Give consistent input"
9119 msgstr "给出一致的输入"
9121 #. type: Content of: <book><chapter><sect1><sect2><para>
9122 #: ../en/ch08-undo.xml:944
9123 msgid ""
9124 "The <command role=\"hg-cmd\">hg bisect</command> command requires that you "
9125 "correctly report the result of every test you perform. If you tell it that a "
9126 "test failed when it really succeeded, it <emphasis>might</emphasis> be able "
9127 "to detect the inconsistency. If it can identify an inconsistency in your "
9128 "reports, it will tell you that a particular changeset is both good and bad. "
9129 "However, it can't do this perfectly; it's about as likely to report the wrong "
9130 "changeset as the source of the bug."
9131 msgstr ""
9133 #. type: Content of: <book><chapter><sect1><sect2><title>
9134 #: ../en/ch08-undo.xml:956
9135 msgid "Automate as much as possible"
9136 msgstr "尽量自动"
9138 #. type: Content of: <book><chapter><sect1><sect2><para>
9139 #: ../en/ch08-undo.xml:958
9140 msgid ""
9141 "When I started using the <command role=\"hg-cmd\">hg bisect</command> "
9142 "command, I tried a few times to run my tests by hand, on the command line. "
9143 "This is an approach that I, at least, am not suited to. After a few tries, I "
9144 "found that I was making enough mistakes that I was having to restart my "
9145 "searches several times before finally getting correct results."
9146 msgstr ""
9148 #. type: Content of: <book><chapter><sect1><sect2><para>
9149 #: ../en/ch08-undo.xml:966
9150 msgid ""
9151 "My initial problems with driving the <command role=\"hg-cmd\">hg bisect</"
9152 "command> command by hand occurred even with simple searches on small "
9153 "repositories; if the problem you're looking for is more subtle, or the number "
9154 "of tests that <command role=\"hg-cmd\">hg bisect</command> must perform "
9155 "increases, the likelihood of operator error ruining the search is much "
9156 "higher. Once I started automating my tests, I had much better results."
9157 msgstr ""
9159 #. type: Content of: <book><chapter><sect1><sect2><para>
9160 #: ../en/ch08-undo.xml:975
9161 msgid "The key to automated testing is twofold:"
9162 msgstr ""
9164 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9165 #: ../en/ch08-undo.xml:977
9166 msgid "always test for the same symptom, and"
9167 msgstr ""
9169 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9170 #: ../en/ch08-undo.xml:979
9171 msgid ""
9172 "always feed consistent input to the <command role=\"hg-cmd\">hg bisect</"
9173 "command> command."
9174 msgstr ""
9176 #. type: Content of: <book><chapter><sect1><sect2><para>
9177 #: ../en/ch08-undo.xml:982
9178 msgid ""
9179 "In my tutorial example above, the <command>grep</command> command tests for "
9180 "the symptom, and the <literal>if</literal> statement takes the result of this "
9181 "check and ensures that we always feed the same input to the <command role="
9182 "\"hg-cmd\">hg bisect</command> command. The <literal>mytest</literal> "
9183 "function marries these together in a reproducible way, so that every test is "
9184 "uniform and consistent."
9185 msgstr ""
9187 #. type: Content of: <book><chapter><sect1><sect2><title>
9188 #: ../en/ch08-undo.xml:992
9189 msgid "Check your results"
9190 msgstr "检查你的结果"
9192 #. type: Content of: <book><chapter><sect1><sect2><para>
9193 #: ../en/ch08-undo.xml:994
9194 msgid ""
9195 "Because the output of a <command role=\"hg-cmd\">hg bisect</command> search "
9196 "is only as good as the input you give it, don't take the changeset it reports "
9197 "as the absolute truth. A simple way to cross-check its report is to manually "
9198 "run your test at each of the following changesets:"
9199 msgstr ""
9201 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9202 #: ../en/ch08-undo.xml:1000
9203 msgid ""
9204 "The changeset that it reports as the first bad revision. Your test should "
9205 "still report this as bad."
9206 msgstr ""
9208 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9209 #: ../en/ch08-undo.xml:1004
9210 msgid ""
9211 "The parent of that changeset (either parent, if it's a merge). Your test "
9212 "should report this changeset as good."
9213 msgstr ""
9215 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9216 #: ../en/ch08-undo.xml:1008
9217 msgid ""
9218 "A child of that changeset. Your test should report this changeset as bad."
9219 msgstr ""
9221 #. type: Content of: <book><chapter><sect1><sect2><title>
9222 #: ../en/ch08-undo.xml:1014
9223 msgid "Beware interference between bugs"
9224 msgstr "谨防问题之间的冲突"
9226 #. type: Content of: <book><chapter><sect1><sect2><para>
9227 #: ../en/ch08-undo.xml:1016
9228 msgid ""
9229 "It's possible that your search for one bug could be disrupted by the presence "
9230 "of another. For example, let's say your software crashes at revision 100, "
9231 "and worked correctly at revision 50. Unknown to you, someone else introduced "
9232 "a different crashing bug at revision 60, and fixed it at revision 80. This "
9233 "could distort your results in one of several ways."
9234 msgstr ""
9236 #. type: Content of: <book><chapter><sect1><sect2><para>
9237 #: ../en/ch08-undo.xml:1024
9238 msgid ""
9239 "It is possible that this other bug completely <quote>masks</quote> yours, "
9240 "which is to say that it occurs before your bug has a chance to manifest "
9241 "itself. If you can't avoid that other bug (for example, it prevents your "
9242 "project from building), and so can't tell whether your bug is present in a "
9243 "particular changeset, the <command role=\"hg-cmd\">hg bisect</command> "
9244 "command cannot help you directly. Instead, you can mark a changeset as "
9245 "untested by running <command role=\"hg-cmd\">hg bisect --skip</command>."
9246 msgstr ""
9248 #. type: Content of: <book><chapter><sect1><sect2><para>
9249 #: ../en/ch08-undo.xml:1034
9250 msgid ""
9251 "A different problem could arise if your test for a bug's presence is not "
9252 "specific enough. If you check for <quote>my program crashes</quote>, then "
9253 "both your crashing bug and an unrelated crashing bug that masks it will look "
9254 "like the same thing, and mislead <command role=\"hg-cmd\">hg bisect</command>."
9255 msgstr ""
9257 #. type: Content of: <book><chapter><sect1><sect2><para>
9258 #: ../en/ch08-undo.xml:1041
9259 msgid ""
9260 "Another useful situation in which to use <command role=\"hg-cmd\">hg bisect --"
9261 "skip</command> is if you can't test a revision because your project was in a "
9262 "broken and hence untestable state at that revision, perhaps because someone "
9263 "checked in a change that prevented the project from building."
9264 msgstr ""
9266 #. type: Content of: <book><chapter><sect1><sect2><title>
9267 #: ../en/ch08-undo.xml:1050
9268 msgid "Bracket your search lazily"
9269 msgstr "减少你的查找工作"
9271 #. type: Content of: <book><chapter><sect1><sect2><para>
9272 #: ../en/ch08-undo.xml:1052
9273 msgid ""
9274 "Choosing the first <quote>good</quote> and <quote>bad</quote> changesets that "
9275 "will mark the end points of your search is often easy, but it bears a little "
9276 "discussion nevertheless. From the perspective of <command role=\"hg-cmd\">hg "
9277 "bisect</command>, the <quote>newest</quote> changeset is conventionally "
9278 "<quote>bad</quote>, and the older changeset is <quote>good</quote>."
9279 msgstr ""
9281 #. type: Content of: <book><chapter><sect1><sect2><para>
9282 #: ../en/ch08-undo.xml:1060
9283 msgid ""
9284 "If you're having trouble remembering when a suitable <quote>good</quote> "
9285 "change was, so that you can tell <command role=\"hg-cmd\">hg bisect</"
9286 "command>, you could do worse than testing changesets at random. Just "
9287 "remember to eliminate contenders that can't possibly exhibit the bug (perhaps "
9288 "because the feature with the bug isn't present yet) and those where another "
9289 "problem masks the bug (as I discussed above)."
9290 msgstr ""
9292 #. type: Content of: <book><chapter><sect1><sect2><para>
9293 #: ../en/ch08-undo.xml:1069
9294 msgid ""
9295 "Even if you end up <quote>early</quote> by thousands of changesets or months "
9296 "of history, you will only add a handful of tests to the total number that "
9297 "<command role=\"hg-cmd\">hg bisect</command> must perform, thanks to its "
9298 "logarithmic behaviour."
9299 msgstr ""
9301 #. type: Content of: <book><chapter><title>
9302 #: ../en/ch09-hook.xml:5
9303 msgid "Handling repository events with hooks"
9304 msgstr "使用钩子处理版本库事件"
9306 #. type: Content of: <book><chapter><para>
9307 #: ../en/ch09-hook.xml:7
9308 msgid ""
9309 "Mercurial offers a powerful mechanism to let you perform automated actions in "
9310 "response to events that occur in a repository. In some cases, you can even "
9311 "control Mercurial's response to those events."
9312 msgstr ""
9314 #. type: Content of: <book><chapter><para>
9315 #: ../en/ch09-hook.xml:12
9316 msgid ""
9317 "The name Mercurial uses for one of these actions is a <emphasis>hook</"
9318 "emphasis>. Hooks are called <quote>triggers</quote> in some revision control "
9319 "systems, but the two names refer to the same idea."
9320 msgstr ""
9322 #. type: Content of: <book><chapter><sect1><title>
9323 #: ../en/ch09-hook.xml:18
9324 msgid "An overview of hooks in Mercurial"
9325 msgstr "Mercurial 钩子概述"
9327 #. type: Content of: <book><chapter><sect1><para>
9328 #: ../en/ch09-hook.xml:20
9329 msgid ""
9330 "Here is a brief list of the hooks that Mercurial supports. We will revisit "
9331 "each of these hooks in more detail later, in section <xref linkend=\"sec.hook."
9332 "ref\"/>."
9333 msgstr ""
9335 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
9336 #: ../en/ch09-hook.xml:25
9337 msgid ""
9338 "<literal role=\"hook\">changegroup</literal>: This is run after a group of "
9339 "changesets has been brought into the repository from elsewhere."
9340 msgstr ""
9342 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
9343 #: ../en/ch09-hook.xml:29
9344 msgid ""
9345 "<literal role=\"hook\">commit</literal>: This is run after a new changeset "
9346 "has been created in the local repository."
9347 msgstr ""
9349 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
9350 #: ../en/ch09-hook.xml:33
9351 msgid ""
9352 "<literal role=\"hook\">incoming</literal>: This is run once for each new "
9353 "changeset that is brought into the repository from elsewhere. Notice the "
9354 "difference from <literal role=\"hook\">changegroup</literal>, which is run "
9355 "once per <emphasis>group</emphasis> of changesets brought in."
9356 msgstr ""
9358 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
9359 #: ../en/ch09-hook.xml:40
9360 msgid ""
9361 "<literal role=\"hook\">outgoing</literal>: This is run after a group of "
9362 "changesets has been transmitted from this repository."
9363 msgstr ""
9365 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
9366 #: ../en/ch09-hook.xml:44
9367 msgid ""
9368 "<literal role=\"hook\">prechangegroup</literal>: This is run before starting "
9369 "to bring a group of changesets into the repository."
9370 msgstr ""
9372 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
9373 #: ../en/ch09-hook.xml:49
9374 msgid ""
9375 "<literal role=\"hook\">precommit</literal>: Controlling. This is run before "
9376 "starting a commit."
9377 msgstr ""
9379 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
9380 #: ../en/ch09-hook.xml:53
9381 msgid ""
9382 "<literal role=\"hook\">preoutgoing</literal>: Controlling. This is run before "
9383 "starting to transmit a group of changesets from this repository."
9384 msgstr ""
9386 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
9387 #: ../en/ch09-hook.xml:58
9388 msgid ""
9389 "<literal role=\"hook\">pretag</literal>: Controlling. This is run before "
9390 "creating a tag."
9391 msgstr ""
9393 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
9394 #: ../en/ch09-hook.xml:62
9395 msgid ""
9396 "<literal role=\"hook\">pretxnchangegroup</literal>: Controlling. This is run "
9397 "after a group of changesets has been brought into the local repository from "
9398 "another, but before the transaction completes that will make the changes "
9399 "permanent in the repository."
9400 msgstr ""
9402 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
9403 #: ../en/ch09-hook.xml:70
9404 msgid ""
9405 "<literal role=\"hook\">pretxncommit</literal>: Controlling. This is run after "
9406 "a new changeset has been created in the local repository, but before the "
9407 "transaction completes that will make it permanent."
9408 msgstr ""
9410 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
9411 #: ../en/ch09-hook.xml:76
9412 msgid ""
9413 "<literal role=\"hook\">preupdate</literal>: Controlling. This is run before "
9414 "starting an update or merge of the working directory."
9415 msgstr ""
9417 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
9418 #: ../en/ch09-hook.xml:81
9419 msgid ""
9420 "<literal role=\"hook\">tag</literal>: This is run after a tag is created."
9421 msgstr ""
9423 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
9424 #: ../en/ch09-hook.xml:85
9425 msgid ""
9426 "<literal role=\"hook\">update</literal>: This is run after an update or merge "
9427 "of the working directory has finished."
9428 msgstr ""
9430 #. type: Content of: <book><chapter><sect1><para>
9431 #: ../en/ch09-hook.xml:90
9432 msgid ""
9433 "Each of the hooks whose description begins with the word <quote>Controlling</"
9434 "quote> has the ability to determine whether an activity can proceed. If the "
9435 "hook succeeds, the activity may proceed; if it fails, the activity is either "
9436 "not permitted or undone, depending on the hook."
9437 msgstr ""
9439 #. type: Content of: <book><chapter><sect1><title>
9440 #: ../en/ch09-hook.xml:99
9441 msgid "Hooks and security"
9442 msgstr "钩子与安全性"
9444 #. type: Content of: <book><chapter><sect1><sect2><title>
9445 #: ../en/ch09-hook.xml:102
9446 msgid "Hooks are run with your privileges"
9447 msgstr "钩子以你的特权执行"
9449 #. type: Content of: <book><chapter><sect1><sect2><para>
9450 #: ../en/ch09-hook.xml:104
9451 msgid ""
9452 "When you run a Mercurial command in a repository, and the command causes a "
9453 "hook to run, that hook runs on <emphasis>your</emphasis> system, under "
9454 "<emphasis>your</emphasis> user account, with <emphasis>your</emphasis> "
9455 "privilege level. Since hooks are arbitrary pieces of executable code, you "
9456 "should treat them with an appropriate level of suspicion. Do not install a "
9457 "hook unless you are confident that you know who created it and what it does."
9458 msgstr ""
9460 #. type: Content of: <book><chapter><sect1><sect2><para>
9461 #: ../en/ch09-hook.xml:115
9462 msgid ""
9463 "In some cases, you may be exposed to hooks that you did not install "
9464 "yourself. If you work with Mercurial on an unfamiliar system, Mercurial will "
9465 "run hooks defined in that system's global <filename role=\"special\">~/.hgrc</"
9466 "filename> file."
9467 msgstr ""
9469 #. type: Content of: <book><chapter><sect1><sect2><para>
9470 #: ../en/ch09-hook.xml:122
9471 msgid ""
9472 "If you are working with a repository owned by another user, Mercurial can run "
9473 "hooks defined in that user's repository, but it will still run them as "
9474 "<quote>you</quote>. For example, if you <command role=\"hg-cmd\">hg pull</"
9475 "command> from that repository, and its <filename role=\"special\">.hg/hgrc</"
9476 "filename> defines a local <literal role=\"hook\">outgoing</literal> hook, "
9477 "that hook will run under your user account, even though you don't own that "
9478 "repository."
9479 msgstr ""
9481 #. type: Content of: <book><chapter><sect1><sect2><note><para>
9482 #: ../en/ch09-hook.xml:134
9483 msgid ""
9484 "This only applies if you are pulling from a repository on a local or network "
9485 "filesystem. If you're pulling over http or ssh, any <literal role=\"hook"
9486 "\">outgoing</literal> hook will run under whatever account is executing the "
9487 "server process, on the server."
9488 msgstr ""
9490 #. type: Content of: <book><chapter><sect1><sect2><para>
9491 #: ../en/ch09-hook.xml:142
9492 msgid ""
9493 "XXX To see what hooks are defined in a repository, use the <command role=\"hg-"
9494 "cmd\">hg config hooks</command> command. If you are working in one "
9495 "repository, but talking to another that you do not own (e.g. using <command "
9496 "role=\"hg-cmd\">hg pull</command> or <command role=\"hg-cmd\">hg incoming</"
9497 "command>), remember that it is the other repository's hooks you should be "
9498 "checking, not your own."
9499 msgstr ""
9501 #. type: Content of: <book><chapter><sect1><sect2><title>
9502 #: ../en/ch09-hook.xml:153
9503 msgid "Hooks do not propagate"
9504 msgstr "钩子不会传播"
9506 #. type: Content of: <book><chapter><sect1><sect2><para>
9507 #: ../en/ch09-hook.xml:155
9508 msgid ""
9509 "In Mercurial, hooks are not revision controlled, and do not propagate when "
9510 "you clone, or pull from, a repository. The reason for this is simple: a hook "
9511 "is a completely arbitrary piece of executable code. It runs under your user "
9512 "identity, with your privilege level, on your machine."
9513 msgstr ""
9515 #. type: Content of: <book><chapter><sect1><sect2><para>
9516 #: ../en/ch09-hook.xml:162
9517 msgid ""
9518 "It would be extremely reckless for any distributed revision control system to "
9519 "implement revision-controlled hooks, as this would offer an easily "
9520 "exploitable way to subvert the accounts of users of the revision control "
9521 "system."
9522 msgstr ""
9524 #. type: Content of: <book><chapter><sect1><sect2><para>
9525 #: ../en/ch09-hook.xml:168
9526 msgid ""
9527 "Since Mercurial does not propagate hooks, if you are collaborating with other "
9528 "people on a common project, you should not assume that they are using the "
9529 "same Mercurial hooks as you are, or that theirs are correctly configured. "
9530 "You should document the hooks you expect people to use."
9531 msgstr ""
9533 #. type: Content of: <book><chapter><sect1><sect2><para>
9534 #: ../en/ch09-hook.xml:175
9535 msgid ""
9536 "In a corporate intranet, this is somewhat easier to control, as you can for "
9537 "example provide a <quote>standard</quote> installation of Mercurial on an NFS "
9538 "filesystem, and use a site-wide <filename role=\"special\">~/.hgrc</filename> "
9539 "file to define hooks that all users will see. However, this too has its "
9540 "limits; see below."
9541 msgstr ""
9543 #. type: Content of: <book><chapter><sect1><sect2><title>
9544 #: ../en/ch09-hook.xml:184
9545 msgid "Hooks can be overridden"
9546 msgstr "钩子可以被覆盖"
9548 #. type: Content of: <book><chapter><sect1><sect2><para>
9549 #: ../en/ch09-hook.xml:186
9550 msgid ""
9551 "Mercurial allows you to override a hook definition by redefining the hook. "
9552 "You can disable it by setting its value to the empty string, or change its "
9553 "behaviour as you wish."
9554 msgstr ""
9556 #. type: Content of: <book><chapter><sect1><sect2><para>
9557 #: ../en/ch09-hook.xml:191
9558 msgid ""
9559 "If you deploy a system- or site-wide <filename role=\"special\">~/.hgrc</"
9560 "filename> file that defines some hooks, you should thus understand that your "
9561 "users can disable or override those hooks."
9562 msgstr ""
9564 #. type: Content of: <book><chapter><sect1><sect2><title>
9565 #: ../en/ch09-hook.xml:199
9566 msgid "Ensuring that critical hooks are run"
9567 msgstr "确保关键钩子的执行"
9569 #. type: Content of: <book><chapter><sect1><sect2><para>
9570 #: ../en/ch09-hook.xml:201
9571 msgid ""
9572 "Sometimes you may want to enforce a policy that you do not want others to be "
9573 "able to work around. For example, you may have a requirement that every "
9574 "changeset must pass a rigorous set of tests. Defining this requirement via a "
9575 "hook in a site-wide <filename role=\"special\">~/.hgrc</filename> won't work "
9576 "for remote users on laptops, and of course local users can subvert it at will "
9577 "by overriding the hook."
9578 msgstr ""
9580 #. type: Content of: <book><chapter><sect1><sect2><para>
9581 #: ../en/ch09-hook.xml:210
9582 msgid ""
9583 "Instead, you can set up your policies for use of Mercurial so that people are "
9584 "expected to propagate changes through a well-known <quote>canonical</quote> "
9585 "server that you have locked down and configured appropriately."
9586 msgstr ""
9588 #. type: Content of: <book><chapter><sect1><sect2><para>
9589 #: ../en/ch09-hook.xml:216
9590 msgid ""
9591 "One way to do this is via a combination of social engineering and "
9592 "technology. Set up a restricted-access account; users can push changes over "
9593 "the network to repositories managed by this account, but they cannot log into "
9594 "the account and run normal shell commands. In this scenario, a user can "
9595 "commit a changeset that contains any old garbage they want."
9596 msgstr ""
9598 #. type: Content of: <book><chapter><sect1><sect2><para>
9599 #: ../en/ch09-hook.xml:225
9600 msgid ""
9601 "When someone pushes a changeset to the server that everyone pulls from, the "
9602 "server will test the changeset before it accepts it as permanent, and reject "
9603 "it if it fails to pass the test suite. If people only pull changes from this "
9604 "filtering server, it will serve to ensure that all changes that people pull "
9605 "have been automatically vetted."
9606 msgstr ""
9608 #. type: Content of: <book><chapter><sect1><title>
9609 #: ../en/ch09-hook.xml:236
9610 msgid "Care with <literal>pretxn</literal> hooks in a shared-access repository"
9611 msgstr "在共享版本库中注意 <literal>pretxn</literal> 钩子"
9613 #. type: Content of: <book><chapter><sect1><para>
9614 #: ../en/ch09-hook.xml:239
9615 msgid ""
9616 "If you want to use hooks to do some automated work in a repository that a "
9617 "number of people have shared access to, you need to be careful in how you do "
9618 "this."
9619 msgstr ""
9621 #. type: Content of: <book><chapter><sect1><para>
9622 #: ../en/ch09-hook.xml:244
9623 msgid ""
9624 "Mercurial only locks a repository when it is writing to the repository, and "
9625 "only the parts of Mercurial that write to the repository pay attention to "
9626 "locks. Write locks are necessary to prevent multiple simultaneous writers "
9627 "from scribbling on each other's work, corrupting the repository."
9628 msgstr ""
9630 #. type: Content of: <book><chapter><sect1><para>
9631 #: ../en/ch09-hook.xml:251
9632 msgid ""
9633 "Because Mercurial is careful with the order in which it reads and writes "
9634 "data, it does not need to acquire a lock when it wants to read data from the "
9635 "repository. The parts of Mercurial that read from the repository never pay "
9636 "attention to locks. This lockless reading scheme greatly increases "
9637 "performance and concurrency."
9638 msgstr ""
9640 #. type: Content of: <book><chapter><sect1><para>
9641 #: ../en/ch09-hook.xml:259
9642 msgid ""
9643 "With great performance comes a trade-off, though, one which has the potential "
9644 "to cause you trouble unless you're aware of it. To describe this requires a "
9645 "little detail about how Mercurial adds changesets to a repository and reads "
9646 "those changes."
9647 msgstr ""
9649 #. type: Content of: <book><chapter><sect1><para>
9650 #: ../en/ch09-hook.xml:266
9651 msgid ""
9652 "When Mercurial <emphasis>writes</emphasis> metadata, it writes it straight "
9653 "into the destination file. It writes file data first, then manifest data "
9654 "(which contains pointers to the new file data), then changelog data (which "
9655 "contains pointers to the new manifest data). Before the first write to each "
9656 "file, it stores a record of where the end of the file was in its transaction "
9657 "log. If the transaction must be rolled back, Mercurial simply truncates each "
9658 "file back to the size it was before the transaction began."
9659 msgstr ""
9661 #. type: Content of: <book><chapter><sect1><para>
9662 #: ../en/ch09-hook.xml:277
9663 msgid ""
9664 "When Mercurial <emphasis>reads</emphasis> metadata, it reads the changelog "
9665 "first, then everything else. Since a reader will only access parts of the "
9666 "manifest or file metadata that it can see in the changelog, it can never see "
9667 "partially written data."
9668 msgstr ""
9670 #. type: Content of: <book><chapter><sect1><para>
9671 #: ../en/ch09-hook.xml:283
9672 msgid ""
9673 "Some controlling hooks (<literal role=\"hook\">pretxncommit</literal> and "
9674 "<literal role=\"hook\">pretxnchangegroup</literal>) run when a transaction is "
9675 "almost complete. All of the metadata has been written, but Mercurial can "
9676 "still roll the transaction back and cause the newly-written data to disappear."
9677 msgstr ""
9679 #. type: Content of: <book><chapter><sect1><para>
9680 #: ../en/ch09-hook.xml:291
9681 msgid ""
9682 "If one of these hooks runs for long, it opens a window of time during which a "
9683 "reader can see the metadata for changesets that are not yet permanent, and "
9684 "should not be thought of as <quote>really there</quote>. The longer the hook "
9685 "runs, the longer that window is open."
9686 msgstr ""
9688 #. type: Content of: <book><chapter><sect1><sect2><title>
9689 #: ../en/ch09-hook.xml:299
9690 msgid "The problem illustrated"
9691 msgstr "问题的演示"
9693 #. type: Content of: <book><chapter><sect1><sect2><para>
9694 #: ../en/ch09-hook.xml:301
9695 msgid ""
9696 "In principle, a good use for the <literal role=\"hook\">pretxnchangegroup</"
9697 "literal> hook would be to automatically build and test incoming changes "
9698 "before they are accepted into a central repository. This could let you "
9699 "guarantee that nobody can push changes to this repository that <quote>break "
9700 "the build</quote>. But if a client can pull changes while they're being "
9701 "tested, the usefulness of the test is zero; an unsuspecting someone can pull "
9702 "untested changes, potentially breaking their build."
9703 msgstr ""
9705 #. type: Content of: <book><chapter><sect1><sect2><para>
9706 #: ../en/ch09-hook.xml:312
9707 msgid ""
9708 "The safest technological answer to this challenge is to set up such a "
9709 "<quote>gatekeeper</quote> repository as <emphasis>unidirectional</emphasis>. "
9710 "Let it take changes pushed in from the outside, but do not allow anyone to "
9711 "pull changes from it (use the <literal role=\"hook\">preoutgoing</literal> "
9712 "hook to lock it down). Configure a <literal role=\"hook\">changegroup</"
9713 "literal> hook so that if a build or test succeeds, the hook will push the new "
9714 "changes out to another repository that people <emphasis>can</emphasis> pull "
9715 "from."
9716 msgstr ""
9718 #. type: Content of: <book><chapter><sect1><sect2><para>
9719 #: ../en/ch09-hook.xml:324
9720 msgid ""
9721 "In practice, putting a centralised bottleneck like this in place is not often "
9722 "a good idea, and transaction visibility has nothing to do with the problem. "
9723 "As the size of a project&emdash;and the time it takes to build and "
9724 "test&emdash;grows, you rapidly run into a wall with this <quote>try before "
9725 "you buy</quote> approach, where you have more changesets to test than time in "
9726 "which to deal with them. The inevitable result is frustration on the part of "
9727 "all involved."
9728 msgstr ""
9730 #. type: Content of: <book><chapter><sect1><sect2><para>
9731 #: ../en/ch09-hook.xml:335
9732 msgid ""
9733 "An approach that scales better is to get people to build and test before they "
9734 "push, then run automated builds and tests centrally <emphasis>after</"
9735 "emphasis> a push, to be sure all is well. The advantage of this approach is "
9736 "that it does not impose a limit on the rate at which the repository can "
9737 "accept changes."
9738 msgstr ""
9740 #. type: Content of: <book><chapter><sect1><title>
9741 #: ../en/ch09-hook.xml:346
9742 msgid "A short tutorial on using hooks"
9743 msgstr "使用钩子的简短指南"
9745 #. type: Content of: <book><chapter><sect1><para>
9746 #: ../en/ch09-hook.xml:348
9747 msgid ""
9748 "It is easy to write a Mercurial hook. Let's start with a hook that runs when "
9749 "you finish a <command role=\"hg-cmd\">hg commit</command>, and simply prints "
9750 "the hash of the changeset you just created. The hook is called <literal role="
9751 "\"hook\">commit</literal>."
9752 msgstr ""
9754 #. type: Content of: <book><chapter><sect1><para>
9755 #: ../en/ch09-hook.xml:355
9756 msgid "All hooks follow the pattern in this example."
9757 msgstr ""
9759 #. type: Content of: <book><chapter><sect1><para>
9760 #: ../en/ch09-hook.xml:359
9761 msgid ""
9762 "You add an entry to the <literal role=\"rc-hooks\">hooks</literal> section of "
9763 "your <filename role=\"special\">~/.hgrc</filename>. On the left is the name "
9764 "of the event to trigger on; on the right is the action to take. As you can "
9765 "see, you can run an arbitrary shell command in a hook. Mercurial passes "
9766 "extra information to the hook using environment variables (look for "
9767 "<envar>HG_NODE</envar> in the example)."
9768 msgstr ""
9770 #. type: Content of: <book><chapter><sect1><sect2><title>
9771 #: ../en/ch09-hook.xml:369
9772 msgid "Performing multiple actions per event"
9773 msgstr "每个事件执行多个操作"
9775 #. type: Content of: <book><chapter><sect1><sect2><para>
9776 #: ../en/ch09-hook.xml:371
9777 msgid ""
9778 "Quite often, you will want to define more than one hook for a particular kind "
9779 "of event, as shown below."
9780 msgstr ""
9782 #. type: Content of: <book><chapter><sect1><sect2><para>
9783 #: ../en/ch09-hook.xml:376
9784 msgid ""
9785 "Mercurial lets you do this by adding an <emphasis>extension</emphasis> to the "
9786 "end of a hook's name. You extend a hook's name by giving the name of the "
9787 "hook, followed by a full stop (the <quote><literal>.</literal></quote> "
9788 "character), followed by some more text of your choosing. For example, "
9789 "Mercurial will run both <literal>commit.foo</literal> and <literal>commit."
9790 "bar</literal> when the <literal>commit</literal> event occurs."
9791 msgstr ""
9793 #. type: Content of: <book><chapter><sect1><sect2><para>
9794 #: ../en/ch09-hook.xml:387
9795 msgid ""
9796 "To give a well-defined order of execution when there are multiple hooks "
9797 "defined for an event, Mercurial sorts hooks by extension, and executes the "
9798 "hook commands in this sorted order. In the above example, it will execute "
9799 "<literal>commit.bar</literal> before <literal>commit.foo</literal>, and "
9800 "<literal>commit</literal> before both."
9801 msgstr ""
9803 #. type: Content of: <book><chapter><sect1><sect2><para>
9804 #: ../en/ch09-hook.xml:396
9805 msgid ""
9806 "It is a good idea to use a somewhat descriptive extension when you define a "
9807 "new hook. This will help you to remember what the hook was for. If the hook "
9808 "fails, you'll get an error message that contains the hook name and extension, "
9809 "so using a descriptive extension could give you an immediate hint as to why "
9810 "the hook failed (see section <xref linkend=\"sec.hook.perm\"/> for an "
9811 "example)."
9812 msgstr ""
9814 #. type: Content of: <book><chapter><sect1><sect2><title>
9815 #: ../en/ch09-hook.xml:407
9816 msgid "Controlling whether an activity can proceed"
9817 msgstr "控制处理的活动"
9819 #. type: Content of: <book><chapter><sect1><sect2><para>
9820 #: ../en/ch09-hook.xml:409
9821 msgid ""
9822 "In our earlier examples, we used the <literal role=\"hook\">commit</literal> "
9823 "hook, which is run after a commit has completed. This is one of several "
9824 "Mercurial hooks that run after an activity finishes. Such hooks have no way "
9825 "of influencing the activity itself."
9826 msgstr ""
9828 #. type: Content of: <book><chapter><sect1><sect2><para>
9829 #: ../en/ch09-hook.xml:416
9830 msgid ""
9831 "Mercurial defines a number of events that occur before an activity starts; or "
9832 "after it starts, but before it finishes. Hooks that trigger on these events "
9833 "have the added ability to choose whether the activity can continue, or will "
9834 "abort."
9835 msgstr ""
9837 #. type: Content of: <book><chapter><sect1><sect2><para>
9838 #: ../en/ch09-hook.xml:422
9839 msgid ""
9840 "The <literal role=\"hook\">pretxncommit</literal> hook runs after a commit "
9841 "has all but completed. In other words, the metadata representing the "
9842 "changeset has been written out to disk, but the transaction has not yet been "
9843 "allowed to complete. The <literal role=\"hook\">pretxncommit</literal> hook "
9844 "has the ability to decide whether the transaction can complete, or must be "
9845 "rolled back."
9846 msgstr ""
9848 #. type: Content of: <book><chapter><sect1><sect2><para>
9849 #: ../en/ch09-hook.xml:431
9850 msgid ""
9851 "If the <literal role=\"hook\">pretxncommit</literal> hook exits with a status "
9852 "code of zero, the transaction is allowed to complete; the commit finishes; "
9853 "and the <literal role=\"hook\">commit</literal> hook is run. If the <literal "
9854 "role=\"hook\">pretxncommit</literal> hook exits with a non-zero status code, "
9855 "the transaction is rolled back; the metadata representing the changeset is "
9856 "erased; and the <literal role=\"hook\">commit</literal> hook is not run."
9857 msgstr ""
9859 #. type: Content of: <book><chapter><sect1><sect2><para>
9860 #: ../en/ch09-hook.xml:443
9861 msgid ""
9862 "The hook in the example above checks that a commit comment contains a bug "
9863 "ID. If it does, the commit can complete. If not, the commit is rolled back."
9864 msgstr ""
9866 #. type: Content of: <book><chapter><sect1><title>
9867 #: ../en/ch09-hook.xml:451
9868 msgid "Writing your own hooks"
9869 msgstr "编写钩子"
9871 #. type: Content of: <book><chapter><sect1><para>
9872 #: ../en/ch09-hook.xml:453
9873 msgid ""
9874 "When you are writing a hook, you might find it useful to run Mercurial either "
9875 "with the <option role=\"hg-opt-global\">-v</option> option, or the <envar "
9876 "role=\"rc-item-ui\">verbose</envar> config item set to <quote>true</quote>. "
9877 "When you do so, Mercurial will print a message before it calls each hook."
9878 msgstr ""
9880 #. type: Content of: <book><chapter><sect1><sect2><title>
9881 #: ../en/ch09-hook.xml:462
9882 msgid "Choosing how your hook should run"
9883 msgstr "选择钩子的执行方式"
9885 #. type: Content of: <book><chapter><sect1><sect2><para>
9886 #: ../en/ch09-hook.xml:464
9887 msgid ""
9888 "You can write a hook either as a normal program&emdash;typically a shell "
9889 "script&emdash;or as a Python function that is executed within the Mercurial "
9890 "process."
9891 msgstr ""
9893 #. type: Content of: <book><chapter><sect1><sect2><para>
9894 #: ../en/ch09-hook.xml:469
9895 msgid ""
9896 "Writing a hook as an external program has the advantage that it requires no "
9897 "knowledge of Mercurial's internals. You can call normal Mercurial commands "
9898 "to get any added information you need. The trade-off is that external hooks "
9899 "are slower than in-process hooks."
9900 msgstr ""
9902 #. type: Content of: <book><chapter><sect1><sect2><para>
9903 #: ../en/ch09-hook.xml:476
9904 msgid ""
9905 "An in-process Python hook has complete access to the Mercurial API, and does "
9906 "not <quote>shell out</quote> to another process, so it is inherently faster "
9907 "than an external hook. It is also easier to obtain much of the information "
9908 "that a hook requires by using the Mercurial API than by running Mercurial "
9909 "commands."
9910 msgstr ""
9912 #. type: Content of: <book><chapter><sect1><sect2><para>
9913 #: ../en/ch09-hook.xml:484
9914 msgid ""
9915 "If you are comfortable with Python, or require high performance, writing your "
9916 "hooks in Python may be a good choice. However, when you have a "
9917 "straightforward hook to write and you don't need to care about performance "
9918 "(probably the majority of hooks), a shell script is perfectly fine."
9919 msgstr ""
9921 #. type: Content of: <book><chapter><sect1><sect2><title>
9922 #: ../en/ch09-hook.xml:493
9923 msgid "Hook parameters"
9924 msgstr "钩子的参数"
9926 #. type: Content of: <book><chapter><sect1><sect2><para>
9927 #: ../en/ch09-hook.xml:495
9928 msgid ""
9929 "Mercurial calls each hook with a set of well-defined parameters. In Python, "
9930 "a parameter is passed as a keyword argument to your hook function. For an "
9931 "external program, a parameter is passed as an environment variable."
9932 msgstr ""
9934 #. type: Content of: <book><chapter><sect1><sect2><para>
9935 #: ../en/ch09-hook.xml:501
9936 msgid ""
9937 "Whether your hook is written in Python or as a shell script, the hook-"
9938 "specific parameter names and values will be the same. A boolean parameter "
9939 "will be represented as a boolean value in Python, but as the number 1 (for "
9940 "<quote>true</quote>) or 0 (for <quote>false</quote>) as an environment "
9941 "variable for an external hook. If a hook parameter is named <literal>foo</"
9942 "literal>, the keyword argument for a Python hook will also be named "
9943 "<literal>foo</literal>, while the environment variable for an external hook "
9944 "will be named <literal>HG_FOO</literal>."
9945 msgstr ""
9947 #. type: Content of: <book><chapter><sect1><sect2><title>
9948 #: ../en/ch09-hook.xml:515
9949 msgid "Hook return values and activity control"
9950 msgstr "钩子的返回值与活动控制"
9952 #. type: Content of: <book><chapter><sect1><sect2><para>
9953 #: ../en/ch09-hook.xml:517
9954 msgid ""
9955 "A hook that executes successfully must exit with a status of zero if "
9956 "external, or return boolean <quote>false</quote> if in-process. Failure is "
9957 "indicated with a non-zero exit status from an external hook, or an in-process "
9958 "hook returning boolean <quote>true</quote>. If an in-process hook raises an "
9959 "exception, the hook is considered to have failed."
9960 msgstr ""
9962 #. type: Content of: <book><chapter><sect1><sect2><para>
9963 #: ../en/ch09-hook.xml:525
9964 msgid ""
9965 "For a hook that controls whether an activity can proceed, zero/false means "
9966 "<quote>allow</quote>, while non-zero/true/exception means <quote>deny</quote>."
9967 msgstr ""
9969 #. type: Content of: <book><chapter><sect1><sect2><title>
9970 #: ../en/ch09-hook.xml:532
9971 msgid "Writing an external hook"
9972 msgstr "编写外部钩子"
9974 #. type: Content of: <book><chapter><sect1><sect2><para>
9975 #: ../en/ch09-hook.xml:534
9976 msgid ""
9977 "When you define an external hook in your <filename role=\"special\">~/.hgrc</"
9978 "filename> and the hook is run, its value is passed to your shell, which "
9979 "interprets it. This means that you can use normal shell constructs in the "
9980 "body of the hook."
9981 msgstr ""
9983 #. type: Content of: <book><chapter><sect1><sect2><para>
9984 #: ../en/ch09-hook.xml:541
9985 msgid ""
9986 "An executable hook is always run with its current directory set to a "
9987 "repository's root directory."
9988 msgstr ""
9990 #. type: Content of: <book><chapter><sect1><sect2><para>
9991 #: ../en/ch09-hook.xml:545
9992 msgid ""
9993 "Each hook parameter is passed in as an environment variable; the name is "
9994 "upper-cased, and prefixed with the string <quote><literal>HG_</literal></"
9995 "quote>."
9996 msgstr ""
9998 #. type: Content of: <book><chapter><sect1><sect2><para>
9999 #: ../en/ch09-hook.xml:550
10000 msgid ""
10001 "With the exception of hook parameters, Mercurial does not set or modify any "
10002 "environment variables when running a hook. This is useful to remember if you "
10003 "are writing a site-wide hook that may be run by a number of different users "
10004 "with differing environment variables set. In multi-user situations, you "
10005 "should not rely on environment variables being set to the values you have in "
10006 "your environment when testing the hook."
10007 msgstr ""
10009 #. type: Content of: <book><chapter><sect1><sect2><title>
10010 #: ../en/ch09-hook.xml:561
10011 msgid "Telling Mercurial to use an in-process hook"
10012 msgstr "让 Mercurial 使用进程内钩子"
10014 #. type: Content of: <book><chapter><sect1><sect2><para>
10015 #: ../en/ch09-hook.xml:563
10016 msgid ""
10017 "The <filename role=\"special\">~/.hgrc</filename> syntax for defining an in-"
10018 "process hook is slightly different than for an executable hook. The value of "
10019 "the hook must start with the text <quote><literal>python:</literal></quote>, "
10020 "and continue with the fully-qualified name of a callable object to use as the "
10021 "hook's value."
10022 msgstr ""
10024 #. type: Content of: <book><chapter><sect1><sect2><para>
10025 #: ../en/ch09-hook.xml:571
10026 msgid ""
10027 "The module in which a hook lives is automatically imported when a hook is "
10028 "run. So long as you have the module name and <envar>PYTHONPATH</envar> "
10029 "right, it should <quote>just work</quote>."
10030 msgstr ""
10032 #. type: Content of: <book><chapter><sect1><sect2><para>
10033 #: ../en/ch09-hook.xml:577
10034 msgid ""
10035 "The following <filename role=\"special\">~/.hgrc</filename> example snippet "
10036 "illustrates the syntax and meaning of the notions we just described."
10037 msgstr ""
10039 #. type: Content of: <book><chapter><sect1><sect2><para>
10040 #: ../en/ch09-hook.xml:583
10041 msgid ""
10042 "When Mercurial runs the <literal>commit.example</literal> hook, it imports "
10043 "<literal>mymodule.submodule</literal>, looks for the callable object named "
10044 "<literal>myhook</literal>, and calls it."
10045 msgstr ""
10047 #. type: Content of: <book><chapter><sect1><sect2><title>
10048 #: ../en/ch09-hook.xml:591
10049 msgid "Writing an in-process hook"
10050 msgstr "编写进程内钩子"
10052 #. type: Content of: <book><chapter><sect1><sect2><para>
10053 #: ../en/ch09-hook.xml:593
10054 msgid ""
10055 "The simplest in-process hook does nothing, but illustrates the basic shape of "
10056 "the hook API:"
10057 msgstr ""
10059 #. type: Content of: <book><chapter><sect1><sect2><para>
10060 #: ../en/ch09-hook.xml:598
10061 msgid ""
10062 "The first argument to a Python hook is always a <literal role=\"py-mod-"
10063 "mercurial.ui\">ui</literal> object. The second is a repository object; at "
10064 "the moment, it is always an instance of <literal role=\"py-mod-mercurial."
10065 "localrepo\">localrepository</literal>. Following these two arguments are "
10066 "other keyword arguments. Which ones are passed in depends on the hook being "
10067 "called, but a hook can ignore arguments it doesn't care about by dropping "
10068 "them into a keyword argument dict, as with <literal>**kwargs</literal> above."
10069 msgstr ""
10071 #. type: Content of: <book><chapter><sect1><title>
10072 #: ../en/ch09-hook.xml:613
10073 msgid "Some hook examples"
10074 msgstr "钩子样例"
10076 #. type: Content of: <book><chapter><sect1><sect2><title>
10077 #: ../en/ch09-hook.xml:616
10078 msgid "Writing meaningful commit messages"
10079 msgstr "编写有意义的提交日志"
10081 #. type: Content of: <book><chapter><sect1><sect2><para>
10082 #: ../en/ch09-hook.xml:618
10083 msgid ""
10084 "It's hard to imagine a useful commit message being very short. The simple "
10085 "<literal role=\"hook\">pretxncommit</literal> hook of the example below will "
10086 "prevent you from committing a changeset with a message that is less than ten "
10087 "bytes long."
10088 msgstr ""
10090 #. type: Content of: <book><chapter><sect1><sect2><title>
10091 #: ../en/ch09-hook.xml:628
10092 msgid "Checking for trailing whitespace"
10093 msgstr "检查行尾空格"
10095 #. type: Content of: <book><chapter><sect1><sect2><para>
10096 #: ../en/ch09-hook.xml:630
10097 msgid ""
10098 "An interesting use of a commit-related hook is to help you to write cleaner "
10099 "code. A simple example of <quote>cleaner code</quote> is the dictum that a "
10100 "change should not add any new lines of text that contain <quote>trailing "
10101 "whitespace</quote>. Trailing whitespace is a series of space and tab "
10102 "characters at the end of a line of text. In most cases, trailing whitespace "
10103 "is unnecessary, invisible noise, but it is occasionally problematic, and "
10104 "people often prefer to get rid of it."
10105 msgstr ""
10107 #. type: Content of: <book><chapter><sect1><sect2><para>
10108 #: ../en/ch09-hook.xml:641
10109 msgid ""
10110 "You can use either the <literal role=\"hook\">precommit</literal> or <literal "
10111 "role=\"hook\">pretxncommit</literal> hook to tell whether you have a trailing "
10112 "whitespace problem. If you use the <literal role=\"hook\">precommit</"
10113 "literal> hook, the hook will not know which files you are committing, so it "
10114 "will have to check every modified file in the repository for trailing white "
10115 "space. If you want to commit a change to just the file <filename>foo</"
10116 "filename>, but the file <filename>bar</filename> contains trailing "
10117 "whitespace, doing a check in the <literal role=\"hook\">precommit</literal> "
10118 "hook will prevent you from committing <filename>foo</filename> due to the "
10119 "problem with <filename>bar</filename>. This doesn't seem right."
10120 msgstr ""
10122 #. type: Content of: <book><chapter><sect1><sect2><para>
10123 #: ../en/ch09-hook.xml:657
10124 msgid ""
10125 "Should you choose the <literal role=\"hook\">pretxncommit</literal> hook, the "
10126 "check won't occur until just before the transaction for the commit "
10127 "completes. This will allow you to check for problems only the exact files "
10128 "that are being committed. However, if you entered the commit message "
10129 "interactively and the hook fails, the transaction will roll back; you'll have "
10130 "to re-enter the commit message after you fix the trailing whitespace and run "
10131 "<command role=\"hg-cmd\">hg commit</command> again."
10132 msgstr ""
10134 #. type: Content of: <book><chapter><sect1><sect2><para>
10135 #: ../en/ch09-hook.xml:670
10136 msgid ""
10137 "In this example, we introduce a simple <literal role=\"hook\">pretxncommit</"
10138 "literal> hook that checks for trailing whitespace. This hook is short, but "
10139 "not very helpful. It exits with an error status if a change adds a line with "
10140 "trailing whitespace to any file, but does not print any information that "
10141 "might help us to identify the offending file or line. It also has the nice "
10142 "property of not paying attention to unmodified lines; only lines that "
10143 "introduce new trailing whitespace cause problems."
10144 msgstr ""
10146 #. type: Content of: <book><chapter><sect1><sect2><para>
10147 #: ../en/ch09-hook.xml:681
10148 msgid ""
10149 "The above version is much more complex, but also more useful. It parses a "
10150 "unified diff to see if any lines add trailing whitespace, and prints the name "
10151 "of the file and the line number of each such occurrence. Even better, if the "
10152 "change adds trailing whitespace, this hook saves the commit comment and "
10153 "prints the name of the save file before exiting and telling Mercurial to roll "
10154 "the transaction back, so you can use the <option role=\"hg-opt-commit\">-l "
10155 "filename</option> option to <command role=\"hg-cmd\">hg commit</command> to "
10156 "reuse the saved commit message once you've corrected the problem."
10157 msgstr ""
10159 #. type: Content of: <book><chapter><sect1><sect2><para>
10160 #: ../en/ch09-hook.xml:695
10161 msgid ""
10162 "As a final aside, note in the example above the use of <command>perl</"
10163 "command>'s in-place editing feature to get rid of trailing whitespace from a "
10164 "file. This is concise and useful enough that I will reproduce it here."
10165 msgstr ""
10167 #. type: Content of: <book><chapter><sect1><title>
10168 #: ../en/ch09-hook.xml:705
10169 msgid "Bundled hooks"
10170 msgstr "内置的钩子"
10172 #. type: Content of: <book><chapter><sect1><para>
10173 #: ../en/ch09-hook.xml:707
10174 msgid ""
10175 "Mercurial ships with several bundled hooks. You can find them in the "
10176 "<filename class=\"directory\">hgext</filename> directory of a Mercurial "
10177 "source tree. If you are using a Mercurial binary package, the hooks will be "
10178 "located in the <filename class=\"directory\">hgext</filename> directory of "
10179 "wherever your package installer put Mercurial."
10180 msgstr ""
10182 #. type: Content of: <book><chapter><sect1><sect2><title>
10183 #: ../en/ch09-hook.xml:716
10184 msgid ""
10185 "<literal role=\"hg-ext\">acl</literal>&emdash;access control for parts of a "
10186 "repository"
10187 msgstr "<literal role=\"hg-ext\">acl</literal>&emdash;版本库的访问控制"
10189 #. type: Content of: <book><chapter><sect1><sect2><para>
10190 #: ../en/ch09-hook.xml:719
10191 msgid ""
10192 "The <literal role=\"hg-ext\">acl</literal> extension lets you control which "
10193 "remote users are allowed to push changesets to a networked server. You can "
10194 "protect any portion of a repository (including the entire repo), so that a "
10195 "specific remote user can push changes that do not affect the protected "
10196 "portion."
10197 msgstr ""
10199 #. type: Content of: <book><chapter><sect1><sect2><para>
10200 #: ../en/ch09-hook.xml:727
10201 msgid ""
10202 "This extension implements access control based on the identity of the user "
10203 "performing a push, <emphasis>not</emphasis> on who committed the changesets "
10204 "they're pushing. It makes sense to use this hook only if you have a locked-"
10205 "down server environment that authenticates remote users, and you want to be "
10206 "sure that only specific users are allowed to push changes to that server."
10207 msgstr ""
10209 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
10210 #: ../en/ch09-hook.xml:737
10211 msgid "Configuring the <literal role=\"hook\">acl</literal> hook"
10212 msgstr "配置 <literal role=\"hook\">acl</literal> 钩子"
10214 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
10215 #: ../en/ch09-hook.xml:740
10216 msgid ""
10217 "In order to manage incoming changesets, the <literal role=\"hg-ext\">acl</"
10218 "literal> hook must be used as a <literal role=\"hook\">pretxnchangegroup</"
10219 "literal> hook. This lets it see which files are modified by each incoming "
10220 "changeset, and roll back a group of changesets if they modify "
10221 "<quote>forbidden</quote> files. Example:"
10222 msgstr ""
10224 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
10225 #: ../en/ch09-hook.xml:750
10226 msgid ""
10227 "The <literal role=\"hg-ext\">acl</literal> extension is configured using "
10228 "three sections."
10229 msgstr ""
10231 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
10232 #: ../en/ch09-hook.xml:754
10233 msgid ""
10234 "The <literal role=\"rc-acl\">acl</literal> section has only one entry, <envar "
10235 "role=\"rc-item-acl\">sources</envar>, which lists the sources of incoming "
10236 "changesets that the hook should pay attention to. You don't normally need to "
10237 "configure this section."
10238 msgstr ""
10240 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
10241 #: ../en/ch09-hook.xml:761
10242 msgid ""
10243 "<envar role=\"rc-item-acl\">serve</envar>: Control incoming changesets that "
10244 "are arriving from a remote repository over http or ssh. This is the default "
10245 "value of <envar role=\"rc-item-acl\">sources</envar>, and usually the only "
10246 "setting you'll need for this configuration item."
10247 msgstr ""
10249 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
10250 #: ../en/ch09-hook.xml:769
10251 msgid ""
10252 "<envar role=\"rc-item-acl\">pull</envar>: Control incoming changesets that "
10253 "are arriving via a pull from a local repository."
10254 msgstr ""
10256 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
10257 #: ../en/ch09-hook.xml:774
10258 msgid ""
10259 "<envar role=\"rc-item-acl\">push</envar>: Control incoming changesets that "
10260 "are arriving via a push from a local repository."
10261 msgstr ""
10263 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
10264 #: ../en/ch09-hook.xml:779
10265 msgid ""
10266 "<envar role=\"rc-item-acl\">bundle</envar>: Control incoming changesets that "
10267 "are arriving from another repository via a bundle."
10268 msgstr ""
10270 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
10271 #: ../en/ch09-hook.xml:785
10272 msgid ""
10273 "The <literal role=\"rc-acl.allow\">acl.allow</literal> section controls the "
10274 "users that are allowed to add changesets to the repository. If this section "
10275 "is not present, all users that are not explicitly denied are allowed. If "
10276 "this section is present, all users that are not explicitly allowed are denied "
10277 "(so an empty section means that all users are denied)."
10278 msgstr ""
10280 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
10281 #: ../en/ch09-hook.xml:794
10282 msgid ""
10283 "The <literal role=\"rc-acl.deny\">acl.deny</literal> section determines which "
10284 "users are denied from adding changesets to the repository. If this section "
10285 "is not present or is empty, no users are denied."
10286 msgstr ""
10288 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
10289 #: ../en/ch09-hook.xml:800
10290 msgid ""
10291 "The syntaxes for the <literal role=\"rc-acl.allow\">acl.allow</literal> and "
10292 "<literal role=\"rc-acl.deny\">acl.deny</literal> sections are identical. On "
10293 "the left of each entry is a glob pattern that matches files or directories, "
10294 "relative to the root of the repository; on the right, a user name."
10295 msgstr ""
10297 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
10298 #: ../en/ch09-hook.xml:808
10299 msgid ""
10300 "In the following example, the user <literal>docwriter</literal> can only push "
10301 "changes to the <filename class=\"directory\">docs</filename> subtree of the "
10302 "repository, while <literal>intern</literal> can push changes to any file or "
10303 "directory except <filename class=\"directory\">source/sensitive</filename>."
10304 msgstr ""
10306 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
10307 #: ../en/ch09-hook.xml:822 ../en/ch09-hook.xml:1089 ../en/ch09-hook.xml:1280
10308 msgid "Testing and troubleshooting"
10309 msgstr "测试与问题处理"
10311 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
10312 #: ../en/ch09-hook.xml:824
10313 msgid ""
10314 "If you want to test the <literal role=\"hg-ext\">acl</literal> hook, run it "
10315 "with Mercurial's debugging output enabled. Since you'll probably be running "
10316 "it on a server where it's not convenient (or sometimes possible) to pass in "
10317 "the <option role=\"hg-opt-global\">--debug</option> option, don't forget that "
10318 "you can enable debugging output in your <filename role=\"special\">~/.hgrc</"
10319 "filename>:"
10320 msgstr ""
10322 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
10323 #: ../en/ch09-hook.xml:835
10324 msgid ""
10325 "With this enabled, the <literal role=\"hg-ext\">acl</literal> hook will print "
10326 "enough information to let you figure out why it is allowing or forbidding "
10327 "pushes from specific users."
10328 msgstr ""
10330 #. type: Content of: <book><chapter><sect1><sect2><title>
10331 #: ../en/ch09-hook.xml:844
10332 msgid ""
10333 "<literal role=\"hg-ext\">bugzilla</literal>&emdash;integration with Bugzilla"
10334 msgstr "<literal role=\"hg-ext\">bugzilla</literal>&emdash;与 Bugzilla 的集成"
10336 #. type: Content of: <book><chapter><sect1><sect2><para>
10337 #: ../en/ch09-hook.xml:848
10338 msgid ""
10339 "The <literal role=\"hg-ext\">bugzilla</literal> extension adds a comment to a "
10340 "Bugzilla bug whenever it finds a reference to that bug ID in a commit "
10341 "comment. You can install this hook on a shared server, so that any time a "
10342 "remote user pushes changes to this server, the hook gets run."
10343 msgstr ""
10345 #. type: Content of: <book><chapter><sect1><sect2><para>
10346 #: ../en/ch09-hook.xml:855
10347 msgid ""
10348 "It adds a comment to the bug that looks like this (you can configure the "
10349 "contents of the comment&emdash;see below):"
10350 msgstr ""
10352 #. type: Content of: <book><chapter><sect1><sect2><para>
10353 #: ../en/ch09-hook.xml:864
10354 msgid ""
10355 "The value of this hook is that it automates the process of updating a bug any "
10356 "time a changeset refers to it. If you configure the hook properly, it makes "
10357 "it easy for people to browse straight from a Bugzilla bug to a changeset that "
10358 "refers to that bug."
10359 msgstr ""
10361 #. type: Content of: <book><chapter><sect1><sect2><para>
10362 #: ../en/ch09-hook.xml:871
10363 msgid ""
10364 "You can use the code in this hook as a starting point for some more exotic "
10365 "Bugzilla integration recipes. Here are a few possibilities:"
10366 msgstr ""
10368 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
10369 #: ../en/ch09-hook.xml:876
10370 msgid ""
10371 "Require that every changeset pushed to the server have a valid bug ID in its "
10372 "commit comment. In this case, you'd want to configure the hook as a <literal "
10373 "role=\"hook\">pretxncommit</literal> hook. This would allow the hook to "
10374 "reject changes that didn't contain bug IDs."
10375 msgstr ""
10377 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
10378 #: ../en/ch09-hook.xml:884
10379 msgid ""
10380 "Allow incoming changesets to automatically modify the <emphasis>state</"
10381 "emphasis> of a bug, as well as simply adding a comment. For example, the "
10382 "hook could recognise the string <quote>fixed bug 31337</quote> as indicating "
10383 "that it should update the state of bug 31337 to <quote>requires testing</"
10384 "quote>."
10385 msgstr ""
10387 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
10388 #: ../en/ch09-hook.xml:894
10389 msgid "Configuring the <literal role=\"hook\">bugzilla</literal> hook"
10390 msgstr "配置 <literal role=\"hook\">bugzilla</literal> 钩子"
10392 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
10393 #: ../en/ch09-hook.xml:897
10394 #, fuzzy
10395 msgid ""
10396 "You should configure this hook in your server's <filename role=\"special\">~/."
10397 "hgrc</filename> as an <literal role=\"hook\">incoming</literal> hook, for "
10398 "example as follows:"
10399 msgstr ""
10400 "选择正确的 <filename role=\"special\"> /.hgrc</filename> 文件增加到 <literal "
10401 "role=\"rc-web\">web</literal> 条目"
10403 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
10404 #: ../en/ch09-hook.xml:905
10405 msgid ""
10406 "Because of the specialised nature of this hook, and because Bugzilla was not "
10407 "written with this kind of integration in mind, configuring this hook is a "
10408 "somewhat involved process."
10409 msgstr ""
10411 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
10412 #: ../en/ch09-hook.xml:911
10413 msgid ""
10414 "Before you begin, you must install the MySQL bindings for Python on the host"
10415 "(s) where you'll be running the hook. If this is not available as a binary "
10416 "package for your system, you can download it from <citation>web:mysql-python</"
10417 "citation>."
10418 msgstr ""
10420 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
10421 #: ../en/ch09-hook.xml:918
10422 msgid ""
10423 "Configuration information for this hook lives in the <literal role=\"rc-"
10424 "bugzilla\">bugzilla</literal> section of your <filename role=\"special\">~/."
10425 "hgrc</filename>."
10426 msgstr ""
10428 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
10429 #: ../en/ch09-hook.xml:923
10430 msgid ""
10431 "<envar role=\"rc-item-bugzilla\">version</envar>: The version of Bugzilla "
10432 "installed on the server. The database schema that Bugzilla uses changes "
10433 "occasionally, so this hook has to know exactly which schema to use. At the "
10434 "moment, the only version supported is <literal>2.16</literal>."
10435 msgstr ""
10437 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
10438 #: ../en/ch09-hook.xml:932
10439 msgid ""
10440 "<envar role=\"rc-item-bugzilla\">host</envar>: The hostname of the MySQL "
10441 "server that stores your Bugzilla data. The database must be configured to "
10442 "allow connections from whatever host you are running the <literal role=\"hook"
10443 "\">bugzilla</literal> hook on."
10444 msgstr ""
10446 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
10447 #: ../en/ch09-hook.xml:939
10448 msgid ""
10449 "<envar role=\"rc-item-bugzilla\">user</envar>: The username with which to "
10450 "connect to the MySQL server. The database must be configured to allow this "
10451 "user to connect from whatever host you are running the <literal role=\"hook"
10452 "\">bugzilla</literal> hook on. This user must be able to access and modify "
10453 "Bugzilla tables. The default value of this item is <literal>bugs</literal>, "
10454 "which is the standard name of the Bugzilla user in a MySQL database."
10455 msgstr ""
10457 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
10458 #: ../en/ch09-hook.xml:950
10459 msgid ""
10460 "<envar role=\"rc-item-bugzilla\">password</envar>: The MySQL password for the "
10461 "user you configured above. This is stored as plain text, so you should make "
10462 "sure that unauthorised users cannot read the <filename role=\"special\">~/."
10463 "hgrc</filename> file where you store this information."
10464 msgstr ""
10466 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
10467 #: ../en/ch09-hook.xml:959
10468 msgid ""
10469 "<envar role=\"rc-item-bugzilla\">db</envar>: The name of the Bugzilla "
10470 "database on the MySQL server. The default value of this item is "
10471 "<literal>bugs</literal>, which is the standard name of the MySQL database "
10472 "where Bugzilla stores its data."
10473 msgstr ""
10475 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
10476 #: ../en/ch09-hook.xml:966
10477 msgid ""
10478 "<envar role=\"rc-item-bugzilla\">notify</envar>: If you want Bugzilla to send "
10479 "out a notification email to subscribers after this hook has added a comment "
10480 "to a bug, you will need this hook to run a command whenever it updates the "
10481 "database. The command to run depends on where you have installed Bugzilla, "
10482 "but it will typically look something like this, if you have Bugzilla "
10483 "installed in <filename class=\"directory\">/var/www/html/bugzilla</filename>:"
10484 msgstr ""
10486 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
10487 #: ../en/ch09-hook.xml:979
10488 msgid ""
10489 "The Bugzilla <literal>processmail</literal> program expects to be given a bug "
10490 "ID (the hook replaces <quote><literal>%s</literal></quote> with the bug ID) "
10491 "and an email address. It also expects to be able to write to some files in "
10492 "the directory that it runs in. If Bugzilla and this hook are not installed "
10493 "on the same machine, you will need to find a way to run <literal>processmail</"
10494 "literal> on the server where Bugzilla is installed."
10495 msgstr ""
10497 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
10498 #: ../en/ch09-hook.xml:994
10499 msgid "Mapping committer names to Bugzilla user names"
10500 msgstr "提交者的名称与 Bugzilla 用户名称的映射"
10502 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
10503 #: ../en/ch09-hook.xml:996
10504 msgid ""
10505 "By default, the <literal role=\"hg-ext\">bugzilla</literal> hook tries to use "
10506 "the email address of a changeset's committer as the Bugzilla user name with "
10507 "which to update a bug. If this does not suit your needs, you can map "
10508 "committer email addresses to Bugzilla user names using a <literal role=\"rc-"
10509 "usermap\">usermap</literal> section."
10510 msgstr ""
10512 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
10513 #: ../en/ch09-hook.xml:1005
10514 msgid ""
10515 "Each item in the <literal role=\"rc-usermap\">usermap</literal> section "
10516 "contains an email address on the left, and a Bugzilla user name on the right."
10517 msgstr ""
10519 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
10520 #: ../en/ch09-hook.xml:1012
10521 msgid ""
10522 "You can either keep the <literal role=\"rc-usermap\">usermap</literal> data "
10523 "in a normal <filename role=\"special\">~/.hgrc</filename>, or tell the "
10524 "<literal role=\"hg-ext\">bugzilla</literal> hook to read the information from "
10525 "an external <filename>usermap</filename> file. In the latter case, you can "
10526 "store <filename>usermap</filename> data by itself in (for example) a user-"
10527 "modifiable repository. This makes it possible to let your users maintain "
10528 "their own <envar role=\"rc-item-bugzilla\">usermap</envar> entries. The main "
10529 "<filename role=\"special\">~/.hgrc</filename> file might look like this:"
10530 msgstr ""
10532 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
10533 #: ../en/ch09-hook.xml:1028
10534 msgid ""
10535 "While the <filename>usermap</filename> file that it refers to might look like "
10536 "this:"
10537 msgstr ""
10539 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
10540 #: ../en/ch09-hook.xml:1036
10541 msgid "Configuring the text that gets added to a bug"
10542 msgstr "配置增加到问题中的正文"
10544 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
10545 #: ../en/ch09-hook.xml:1038
10546 msgid ""
10547 "You can configure the text that this hook adds as a comment; you specify it "
10548 "in the form of a Mercurial template. Several <filename role=\"special\">~/."
10549 "hgrc</filename> entries (still in the <literal role=\"rc-bugzilla\">bugzilla</"
10550 "literal> section) control this behaviour."
10551 msgstr ""
10553 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
10554 #: ../en/ch09-hook.xml:1045
10555 msgid ""
10556 "<literal>strip</literal>: The number of leading path elements to strip from a "
10557 "repository's path name to construct a partial path for a URL. For example, if "
10558 "the repositories on your server live under <filename class=\"directory\">/"
10559 "home/hg/repos</filename>, and you have a repository whose path is <filename "
10560 "class=\"directory\">/home/hg/repos/app/tests</filename>, then setting "
10561 "<literal>strip</literal> to <literal>4</literal> will give a partial path of "
10562 "<filename class=\"directory\">app/tests</filename>. The hook will make this "
10563 "partial path available when expanding a template, as <literal>webroot</"
10564 "literal>."
10565 msgstr ""
10567 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
10568 #: ../en/ch09-hook.xml:1059
10569 msgid ""
10570 "<literal>template</literal>: The text of the template to use. In addition to "
10571 "the usual changeset-related variables, this template can use <literal>hgweb</"
10572 "literal> (the value of the <literal>hgweb</literal> configuration item above) "
10573 "and <literal>webroot</literal> (the path constructed using <literal>strip</"
10574 "literal> above)."
10575 msgstr ""
10577 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
10578 #: ../en/ch09-hook.xml:1069
10579 msgid ""
10580 "In addition, you can add a <envar role=\"rc-item-web\">baseurl</envar> item "
10581 "to the <literal role=\"rc-web\">web</literal> section of your <filename role="
10582 "\"special\">~/.hgrc</filename>. The <literal role=\"hg-ext\">bugzilla</"
10583 "literal> hook will make this available when expanding a template, as the base "
10584 "string to use when constructing a URL that will let users browse from a "
10585 "Bugzilla comment to view a changeset. Example:"
10586 msgstr ""
10588 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
10589 #: ../en/ch09-hook.xml:1081
10590 msgid ""
10591 "Here is an example set of <literal role=\"hg-ext\">bugzilla</literal> hook "
10592 "config information."
10593 msgstr ""
10595 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
10596 #: ../en/ch09-hook.xml:1091
10597 msgid ""
10598 "The most common problems with configuring the <literal role=\"hg-ext"
10599 "\">bugzilla</literal> hook relate to running Bugzilla's "
10600 "<filename>processmail</filename> script and mapping committer names to user "
10601 "names."
10602 msgstr ""
10604 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
10605 #: ../en/ch09-hook.xml:1097
10606 msgid ""
10607 "Recall from section <xref linkend=\"sec.hook.bugzilla.config\"/> above that "
10608 "the user that runs the Mercurial process on the server is also the one that "
10609 "will run the <filename>processmail</filename> script. The "
10610 "<filename>processmail</filename> script sometimes causes Bugzilla to write to "
10611 "files in its configuration directory, and Bugzilla's configuration files are "
10612 "usually owned by the user that your web server runs under."
10613 msgstr ""
10615 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
10616 #: ../en/ch09-hook.xml:1108
10617 msgid ""
10618 "You can cause <filename>processmail</filename> to be run with the suitable "
10619 "user's identity using the <command>sudo</command> command. Here is an "
10620 "example entry for a <filename>sudoers</filename> file."
10621 msgstr ""
10623 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
10624 #: ../en/ch09-hook.xml:1115
10625 msgid ""
10626 "This allows the <literal>hg_user</literal> user to run a "
10627 "<filename>processmail-wrapper</filename> program under the identity of "
10628 "<literal>httpd_user</literal>."
10629 msgstr ""
10631 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
10632 #: ../en/ch09-hook.xml:1120
10633 msgid ""
10634 "This indirection through a wrapper script is necessary, because "
10635 "<filename>processmail</filename> expects to be run with its current directory "
10636 "set to wherever you installed Bugzilla; you can't specify that kind of "
10637 "constraint in a <filename>sudoers</filename> file. The contents of the "
10638 "wrapper script are simple:"
10639 msgstr ""
10641 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
10642 #: ../en/ch09-hook.xml:1129
10643 msgid ""
10644 "It doesn't seem to matter what email address you pass to "
10645 "<filename>processmail</filename>."
10646 msgstr ""
10648 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
10649 #: ../en/ch09-hook.xml:1133
10650 msgid ""
10651 "If your <literal role=\"rc-usermap\">usermap</literal> is not set up "
10652 "correctly, users will see an error message from the <literal role=\"hg-ext"
10653 "\">bugzilla</literal> hook when they push changes to the server. The error "
10654 "message will look like this:"
10655 msgstr ""
10657 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
10658 #: ../en/ch09-hook.xml:1140
10659 msgid ""
10660 "What this means is that the committer's address, <literal>john.q."
10661 "public@example.com</literal>, is not a valid Bugzilla user name, nor does it "
10662 "have an entry in your <literal role=\"rc-usermap\">usermap</literal> that "
10663 "maps it to a valid Bugzilla user name."
10664 msgstr ""
10666 #. type: Content of: <book><chapter><sect1><sect2><title>
10667 #: ../en/ch09-hook.xml:1150
10668 msgid ""
10669 "<literal role=\"hg-ext\">notify</literal>&emdash;send email notifications"
10670 msgstr "<literal role=\"hg-ext\">notify</literal>&emdash;邮件通知"
10672 #. type: Content of: <book><chapter><sect1><sect2><para>
10673 #: ../en/ch09-hook.xml:1153
10674 msgid ""
10675 "Although Mercurial's built-in web server provides RSS feeds of changes in "
10676 "every repository, many people prefer to receive change notifications via "
10677 "email. The <literal role=\"hg-ext\">notify</literal> hook lets you send out "
10678 "notifications to a set of email addresses whenever changesets arrive that "
10679 "those subscribers are interested in."
10680 msgstr ""
10682 #. type: Content of: <book><chapter><sect1><sect2><para>
10683 #: ../en/ch09-hook.xml:1161
10684 msgid ""
10685 "As with the <literal role=\"hg-ext\">bugzilla</literal> hook, the <literal "
10686 "role=\"hg-ext\">notify</literal> hook is template-driven, so you can "
10687 "customise the contents of the notification messages that it sends."
10688 msgstr ""
10690 #. type: Content of: <book><chapter><sect1><sect2><para>
10691 #: ../en/ch09-hook.xml:1167
10692 msgid ""
10693 "By default, the <literal role=\"hg-ext\">notify</literal> hook includes a "
10694 "diff of every changeset that it sends out; you can limit the size of the "
10695 "diff, or turn this feature off entirely. It is useful for letting "
10696 "subscribers review changes immediately, rather than clicking to follow a URL."
10697 msgstr ""
10699 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
10700 #: ../en/ch09-hook.xml:1175
10701 msgid "Configuring the <literal role=\"hg-ext\">notify</literal> hook"
10702 msgstr "配置 <literal role=\"hg-ext\">notify</literal> 钩子"
10704 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
10705 #: ../en/ch09-hook.xml:1178
10706 msgid ""
10707 "You can set up the <literal role=\"hg-ext\">notify</literal> hook to send one "
10708 "email message per incoming changeset, or one per incoming group of changesets "
10709 "(all those that arrived in a single pull or push)."
10710 msgstr ""
10712 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
10713 #: ../en/ch09-hook.xml:1190
10714 msgid ""
10715 "Configuration information for this hook lives in the <literal role=\"rc-notify"
10716 "\">notify</literal> section of a <filename role=\"special\">~/.hgrc</"
10717 "filename> file."
10718 msgstr ""
10720 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
10721 #: ../en/ch09-hook.xml:1195
10722 msgid ""
10723 "<envar role=\"rc-item-notify\">test</envar>: By default, this hook does not "
10724 "send out email at all; instead, it prints the message that it "
10725 "<emphasis>would</emphasis> send. Set this item to <literal>false</literal> "
10726 "to allow email to be sent. The reason that sending of email is turned off by "
10727 "default is that it takes several tries to configure this extension exactly as "
10728 "you would like, and it would be bad form to spam subscribers with a number of "
10729 "<quote>broken</quote> notifications while you debug your configuration."
10730 msgstr ""
10732 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
10733 #: ../en/ch09-hook.xml:1207
10734 msgid ""
10735 "<envar role=\"rc-item-notify\">config</envar>: The path to a configuration "
10736 "file that contains subscription information. This is kept separate from the "
10737 "main <filename role=\"special\">~/.hgrc</filename> so that you can maintain "
10738 "it in a repository of its own. People can then clone that repository, update "
10739 "their subscriptions, and push the changes back to your server."
10740 msgstr ""
10742 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
10743 #: ../en/ch09-hook.xml:1216
10744 msgid ""
10745 "<envar role=\"rc-item-notify\">strip</envar>: The number of leading path "
10746 "separator characters to strip from a repository's path, when deciding whether "
10747 "a repository has subscribers. For example, if the repositories on your "
10748 "server live in <filename class=\"directory\">/home/hg/repos</filename>, and "
10749 "<literal role=\"hg-ext\">notify</literal> is considering a repository named "
10750 "<filename class=\"directory\">/home/hg/repos/shared/test</filename>, setting "
10751 "<envar role=\"rc-item-notify\">strip</envar> to <literal>4</literal> will "
10752 "cause <literal role=\"hg-ext\">notify</literal> to trim the path it considers "
10753 "down to <filename class=\"directory\">shared/test</filename>, and it will "
10754 "match subscribers against that."
10755 msgstr ""
10757 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
10758 #: ../en/ch09-hook.xml:1233
10759 msgid ""
10760 "<envar role=\"rc-item-notify\">template</envar>: The template text to use "
10761 "when sending messages. This specifies both the contents of the message "
10762 "header and its body."
10763 msgstr ""
10765 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
10766 #: ../en/ch09-hook.xml:1239
10767 msgid ""
10768 "<envar role=\"rc-item-notify\">maxdiff</envar>: The maximum number of lines "
10769 "of diff data to append to the end of a message. If a diff is longer than "
10770 "this, it is truncated. By default, this is set to 300. Set this to "
10771 "<literal>0</literal> to omit diffs from notification emails."
10772 msgstr ""
10774 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
10775 #: ../en/ch09-hook.xml:1248
10776 msgid ""
10777 "<envar role=\"rc-item-notify\">sources</envar>: A list of sources of "
10778 "changesets to consider. This lets you limit <literal role=\"hg-ext\">notify</"
10779 "literal> to only sending out email about changes that remote users pushed "
10780 "into this repository via a server, for example. See section <xref linkend="
10781 "\"sec.hook.sources\"/> for the sources you can specify here."
10782 msgstr ""
10784 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
10785 #: ../en/ch09-hook.xml:1260
10786 msgid ""
10787 "If you set the <envar role=\"rc-item-web\">baseurl</envar> item in the "
10788 "<literal role=\"rc-web\">web</literal> section, you can use it in a template; "
10789 "it will be available as <literal>webroot</literal>."
10790 msgstr ""
10792 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
10793 #: ../en/ch09-hook.xml:1266
10794 msgid ""
10795 "Here is an example set of <literal role=\"hg-ext\">notify</literal> "
10796 "configuration information."
10797 msgstr ""
10799 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
10800 #: ../en/ch09-hook.xml:1272
10801 msgid "This will produce a message that looks like the following:"
10802 msgstr ""
10804 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
10805 #: ../en/ch09-hook.xml:1282
10806 msgid ""
10807 "Do not forget that by default, the <literal role=\"hg-ext\">notify</literal> "
10808 "extension <emphasis>will not send any mail</emphasis> until you explicitly "
10809 "configure it to do so, by setting <envar role=\"rc-item-notify\">test</envar> "
10810 "to <literal>false</literal>. Until you do that, it simply prints the message "
10811 "it <emphasis>would</emphasis> send."
10812 msgstr ""
10814 #. type: Content of: <book><chapter><sect1><title>
10815 #: ../en/ch09-hook.xml:1294
10816 msgid "Information for writers of hooks"
10817 msgstr "编写钩子的信息"
10819 #. type: Content of: <book><chapter><sect1><sect2><title>
10820 #: ../en/ch09-hook.xml:1297
10821 msgid "In-process hook execution"
10822 msgstr "进程内钩子的执行"
10824 #. type: Content of: <book><chapter><sect1><sect2><para>
10825 #: ../en/ch09-hook.xml:1299
10826 msgid "An in-process hook is called with arguments of the following form:"
10827 msgstr ""
10829 #. type: Content of: <book><chapter><sect1><sect2><para>
10830 #: ../en/ch09-hook.xml:1303
10831 msgid ""
10832 "The <literal>ui</literal> parameter is a <literal role=\"py-mod-mercurial.ui"
10833 "\">ui</literal> object. The <literal>repo</literal> parameter is a <literal "
10834 "role=\"py-mod-mercurial.localrepo\">localrepository</literal> object. The "
10835 "names and values of the <literal>**kwargs</literal> parameters depend on the "
10836 "hook being invoked, with the following common features:"
10837 msgstr ""
10839 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
10840 #: ../en/ch09-hook.xml:1312
10841 msgid ""
10842 "If a parameter is named <literal>node</literal> or <literal>parentN</"
10843 "literal>, it will contain a hexadecimal changeset ID. The empty string is "
10844 "used to represent <quote>null changeset ID</quote> instead of a string of "
10845 "zeroes."
10846 msgstr ""
10848 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
10849 #: ../en/ch09-hook.xml:1319
10850 msgid ""
10851 "If a parameter is named <literal>url</literal>, it will contain the URL of a "
10852 "remote repository, if that can be determined."
10853 msgstr ""
10855 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
10856 #: ../en/ch09-hook.xml:1324
10857 msgid ""
10858 "Boolean-valued parameters are represented as Python <literal>bool</literal> "
10859 "objects."
10860 msgstr ""
10862 #. type: Content of: <book><chapter><sect1><sect2><para>
10863 #: ../en/ch09-hook.xml:1329
10864 msgid ""
10865 "An in-process hook is called without a change to the process's working "
10866 "directory (unlike external hooks, which are run in the root of the "
10867 "repository). It must not change the process's working directory, or it will "
10868 "cause any calls it makes into the Mercurial API to fail."
10869 msgstr ""
10871 #. type: Content of: <book><chapter><sect1><sect2><para>
10872 #: ../en/ch09-hook.xml:1336
10873 msgid ""
10874 "If a hook returns a boolean <quote>false</quote> value, it is considered to "
10875 "have succeeded. If it returns a boolean <quote>true</quote> value or raises "
10876 "an exception, it is considered to have failed. A useful way to think of the "
10877 "calling convention is <quote>tell me if you fail</quote>."
10878 msgstr ""
10880 #. type: Content of: <book><chapter><sect1><sect2><para>
10881 #: ../en/ch09-hook.xml:1343
10882 msgid ""
10883 "Note that changeset IDs are passed into Python hooks as hexadecimal strings, "
10884 "not the binary hashes that Mercurial's APIs normally use. To convert a hash "
10885 "from hex to binary, use the <literal>bin</literal> function."
10886 msgstr ""
10888 #. type: Content of: <book><chapter><sect1><sect2><title>
10889 #: ../en/ch09-hook.xml:1351
10890 msgid "External hook execution"
10891 msgstr "外部钩子的执行"
10893 #. type: Content of: <book><chapter><sect1><sect2><para>
10894 #: ../en/ch09-hook.xml:1353
10895 msgid ""
10896 "An external hook is passed to the shell of the user running Mercurial. "
10897 "Features of that shell, such as variable substitution and command "
10898 "redirection, are available. The hook is run in the root directory of the "
10899 "repository (unlike in-process hooks, which are run in the same directory that "
10900 "Mercurial was run in)."
10901 msgstr ""
10903 #. type: Content of: <book><chapter><sect1><sect2><para>
10904 #: ../en/ch09-hook.xml:1361
10905 msgid ""
10906 "Hook parameters are passed to the hook as environment variables. Each "
10907 "environment variable's name is converted in upper case and prefixed with the "
10908 "string <quote><literal>HG_</literal></quote>. For example, if the name of a "
10909 "parameter is <quote><literal>node</literal></quote>, the name of the "
10910 "environment variable representing that parameter will be "
10911 "<quote><literal>HG_NODE</literal></quote>."
10912 msgstr ""
10914 #. type: Content of: <book><chapter><sect1><sect2><para>
10915 #: ../en/ch09-hook.xml:1370
10916 msgid ""
10917 "A boolean parameter is represented as the string <quote><literal>1</literal></"
10918 "quote> for <quote>true</quote>, <quote><literal>0</literal></quote> for "
10919 "<quote>false</quote>. If an environment variable is named <envar>HG_NODE</"
10920 "envar>, <envar>HG_PARENT1</envar> or <envar>HG_PARENT2</envar>, it contains a "
10921 "changeset ID represented as a hexadecimal string. The empty string is used "
10922 "to represent <quote>null changeset ID</quote> instead of a string of zeroes. "
10923 "If an environment variable is named <envar>HG_URL</envar>, it will contain "
10924 "the URL of a remote repository, if that can be determined."
10925 msgstr ""
10927 #. type: Content of: <book><chapter><sect1><sect2><para>
10928 #: ../en/ch09-hook.xml:1382
10929 msgid ""
10930 "If a hook exits with a status of zero, it is considered to have succeeded. "
10931 "If it exits with a non-zero status, it is considered to have failed."
10932 msgstr ""
10934 #. type: Content of: <book><chapter><sect1><sect2><title>
10935 #: ../en/ch09-hook.xml:1389
10936 msgid "Finding out where changesets come from"
10937 msgstr "检查修改集来自何处"
10939 #. type: Content of: <book><chapter><sect1><sect2><para>
10940 #: ../en/ch09-hook.xml:1391
10941 msgid ""
10942 "A hook that involves the transfer of changesets between a local repository "
10943 "and another may be able to find out information about the <quote>far side</"
10944 "quote>. Mercurial knows <emphasis>how</emphasis> changes are being "
10945 "transferred, and in many cases <emphasis>where</emphasis> they are being "
10946 "transferred to or from."
10947 msgstr ""
10949 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
10950 #: ../en/ch09-hook.xml:1400
10951 msgid "Sources of changesets"
10952 msgstr "修改集的来源"
10954 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
10955 #: ../en/ch09-hook.xml:1402
10956 msgid ""
10957 "Mercurial will tell a hook what means are, or were, used to transfer "
10958 "changesets between repositories. This is provided by Mercurial in a Python "
10959 "parameter named <literal>source</literal>, or an environment variable named "
10960 "<envar>HG_SOURCE</envar>."
10961 msgstr ""
10963 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
10964 #: ../en/ch09-hook.xml:1410
10965 msgid ""
10966 "<literal>serve</literal>: Changesets are transferred to or from a remote "
10967 "repository over http or ssh."
10968 msgstr ""
10970 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
10971 #: ../en/ch09-hook.xml:1415
10972 msgid ""
10973 "<literal>pull</literal>: Changesets are being transferred via a pull from one "
10974 "repository into another."
10975 msgstr ""
10977 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
10978 #: ../en/ch09-hook.xml:1420
10979 msgid ""
10980 "<literal>push</literal>: Changesets are being transferred via a push from one "
10981 "repository into another."
10982 msgstr ""
10984 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
10985 #: ../en/ch09-hook.xml:1425
10986 msgid ""
10987 "<literal>bundle</literal>: Changesets are being transferred to or from a "
10988 "bundle."
10989 msgstr ""
10991 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
10992 #: ../en/ch09-hook.xml:1432
10993 msgid "Where changes are going&emdash;remote repository URLs"
10994 msgstr "修改集要到哪里&emdash;远程版本库的地址"
10996 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
10997 #: ../en/ch09-hook.xml:1435
10998 msgid ""
10999 "When possible, Mercurial will tell a hook the location of the <quote>far "
11000 "side</quote> of an activity that transfers changeset data between "
11001 "repositories. This is provided by Mercurial in a Python parameter named "
11002 "<literal>url</literal>, or an environment variable named <envar>HG_URL</"
11003 "envar>."
11004 msgstr ""
11006 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11007 #: ../en/ch09-hook.xml:1443
11008 msgid ""
11009 "This information is not always known. If a hook is invoked in a repository "
11010 "that is being served via http or ssh, Mercurial cannot tell where the remote "
11011 "repository is, but it may know where the client is connecting from. In such "
11012 "cases, the URL will take one of the following forms:"
11013 msgstr ""
11015 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11016 #: ../en/ch09-hook.xml:1450
11017 msgid ""
11018 "<literal>remote:ssh:1.2.3.4</literal>&emdash;remote ssh client, at the IP "
11019 "address <literal>1.2.3.4</literal>."
11020 msgstr ""
11022 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11023 #: ../en/ch09-hook.xml:1455
11024 msgid ""
11025 "<literal>remote:http:1.2.3.4</literal>&emdash;remote http client, at the IP "
11026 "address <literal>1.2.3.4</literal>. If the client is using SSL, this will be "
11027 "of the form <literal>remote:https:1.2.3.4</literal>."
11028 msgstr ""
11030 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11031 #: ../en/ch09-hook.xml:1462
11032 msgid "Empty&emdash;no information could be discovered about the remote client."
11033 msgstr ""
11035 #. type: Content of: <book><chapter><sect1><title>
11036 #: ../en/ch09-hook.xml:1471
11037 msgid "Hook reference"
11038 msgstr "钩子参考"
11040 #. type: Content of: <book><chapter><sect1><sect2><title>
11041 #: ../en/ch09-hook.xml:1474
11042 msgid ""
11043 "<literal role=\"hook\">changegroup</literal>&emdash;after remote changesets "
11044 "added"
11045 msgstr "<literal role=\"hook\">changegroup</literal>&emdash;增加远程修改集之后"
11047 #. type: Content of: <book><chapter><sect1><sect2><para>
11048 #: ../en/ch09-hook.xml:1477
11049 msgid ""
11050 "This hook is run after a group of pre-existing changesets has been added to "
11051 "the repository, for example via a <command role=\"hg-cmd\">hg pull</command> "
11052 "or <command role=\"hg-cmd\">hg unbundle</command>. This hook is run once per "
11053 "operation that added one or more changesets. This is in contrast to the "
11054 "<literal role=\"hook\">incoming</literal> hook, which is run once per "
11055 "changeset, regardless of whether the changesets arrive in a group."
11056 msgstr ""
11058 #. type: Content of: <book><chapter><sect1><sect2><para>
11059 #: ../en/ch09-hook.xml:1487
11060 msgid ""
11061 "Some possible uses for this hook include kicking off an automated build or "
11062 "test of the added changesets, updating a bug database, or notifying "
11063 "subscribers that a repository contains new changes."
11064 msgstr ""
11066 #. type: Content of: <book><chapter><sect1><sect2><para>
11067 #: ../en/ch09-hook.xml:1493 ../en/ch09-hook.xml:1533 ../en/ch09-hook.xml:1576
11068 #: ../en/ch09-hook.xml:1618 ../en/ch09-hook.xml:1673 ../en/ch09-hook.xml:1713
11069 #: ../en/ch09-hook.xml:1749 ../en/ch09-hook.xml:1784 ../en/ch09-hook.xml:1846
11070 #: ../en/ch09-hook.xml:1904 ../en/ch09-hook.xml:1938 ../en/ch09-hook.xml:1966
11071 msgid "Parameters to this hook:"
11072 msgstr ""
11074 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
11075 #: ../en/ch09-hook.xml:1496 ../en/ch09-hook.xml:1849
11076 msgid ""
11077 "<literal>node</literal>: A changeset ID. The changeset ID of the first "
11078 "changeset in the group that was added. All changesets between this and "
11079 "<literal role=\"tag\">tip</literal>, inclusive, were added by a single "
11080 "<command role=\"hg-cmd\">hg pull</command>, <command role=\"hg-cmd\">hg push</"
11081 "command> or <command role=\"hg-cmd\">hg unbundle</command>."
11082 msgstr ""
11084 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
11085 #: ../en/ch09-hook.xml:1505 ../en/ch09-hook.xml:1583 ../en/ch09-hook.xml:1676
11086 #: ../en/ch09-hook.xml:1859
11087 msgid ""
11088 "<literal>source</literal>: A string. The source of these changes. See "
11089 "section <xref linkend=\"sec.hook.sources\"/> for details."
11090 msgstr ""
11092 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
11093 #: ../en/ch09-hook.xml:1510 ../en/ch09-hook.xml:1588 ../en/ch09-hook.xml:1639
11094 #: ../en/ch09-hook.xml:1681 ../en/ch09-hook.xml:1763 ../en/ch09-hook.xml:1864
11095 msgid ""
11096 "<literal>url</literal>: A URL. The location of the remote repository, if "
11097 "known. See section <xref linkend=\"sec.hook.url\"/> for more information."
11098 msgstr ""
11100 #. type: Content of: <book><chapter><sect1><sect2><para>
11101 #: ../en/ch09-hook.xml:1517
11102 msgid ""
11103 "See also: <literal role=\"hook\">incoming</literal> (section <xref linkend="
11104 "\"sec.hook.incoming\"/>), <literal role=\"hook\">prechangegroup</literal> "
11105 "(section <xref linkend=\"sec.hook.prechangegroup\"/>), <literal role=\"hook"
11106 "\">pretxnchangegroup</literal> (section <xref linkend=\"sec.hook."
11107 "pretxnchangegroup\"/>)"
11108 msgstr ""
11110 #. type: Content of: <book><chapter><sect1><sect2><title>
11111 #: ../en/ch09-hook.xml:1527
11112 msgid ""
11113 "<literal role=\"hook\">commit</literal>&emdash;after a new changeset is "
11114 "created"
11115 msgstr "<literal role=\"hook\">commit</literal>&emdash;创建新修改集之后"
11117 #. type: Content of: <book><chapter><sect1><sect2><para>
11118 #: ../en/ch09-hook.xml:1530
11119 msgid "This hook is run after a new changeset has been created."
11120 msgstr ""
11122 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
11123 #: ../en/ch09-hook.xml:1536 ../en/ch09-hook.xml:1907
11124 msgid ""
11125 "<literal>node</literal>: A changeset ID. The changeset ID of the newly "
11126 "committed changeset."
11127 msgstr ""
11129 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
11130 #: ../en/ch09-hook.xml:1540 ../en/ch09-hook.xml:1911
11131 msgid ""
11132 "<literal>parent1</literal>: A changeset ID. The changeset ID of the first "
11133 "parent of the newly committed changeset."
11134 msgstr ""
11136 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
11137 #: ../en/ch09-hook.xml:1545 ../en/ch09-hook.xml:1916
11138 msgid ""
11139 "<literal>parent2</literal>: A changeset ID. The changeset ID of the second "
11140 "parent of the newly committed changeset."
11141 msgstr ""
11143 #. type: Content of: <book><chapter><sect1><sect2><para>
11144 #: ../en/ch09-hook.xml:1551
11145 msgid ""
11146 "See also: <literal role=\"hook\">precommit</literal> (section <xref linkend="
11147 "\"sec.hook.precommit\"/>), <literal role=\"hook\">pretxncommit</literal> "
11148 "(section <xref linkend=\"sec.hook.pretxncommit\"/>)"
11149 msgstr ""
11151 #. type: Content of: <book><chapter><sect1><sect2><title>
11152 #: ../en/ch09-hook.xml:1559
11153 msgid ""
11154 "<literal role=\"hook\">incoming</literal>&emdash;after one remote changeset "
11155 "is added"
11156 msgstr "<literal role=\"hook\">incoming</literal>&emdash;增加远程修改集之后"
11158 #. type: Content of: <book><chapter><sect1><sect2><para>
11159 #: ../en/ch09-hook.xml:1562
11160 msgid ""
11161 "This hook is run after a pre-existing changeset has been added to the "
11162 "repository, for example via a <command role=\"hg-cmd\">hg push</command>. If "
11163 "a group of changesets was added in a single operation, this hook is called "
11164 "once for each added changeset."
11165 msgstr ""
11167 #. type: Content of: <book><chapter><sect1><sect2><para>
11168 #: ../en/ch09-hook.xml:1569
11169 msgid ""
11170 "You can use this hook for the same purposes as the <literal role=\"hook"
11171 "\">changegroup</literal> hook (section <xref linkend=\"sec.hook.changegroup\"/"
11172 ">); it's simply more convenient sometimes to run a hook once per group of "
11173 "changesets, while other times it's handier once per changeset."
11174 msgstr ""
11176 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
11177 #: ../en/ch09-hook.xml:1579
11178 msgid ""
11179 "<literal>node</literal>: A changeset ID. The ID of the newly added changeset."
11180 msgstr ""
11182 #. type: Content of: <book><chapter><sect1><sect2><para>
11183 #: ../en/ch09-hook.xml:1595
11184 msgid ""
11185 "See also: <literal role=\"hook\">changegroup</literal> (section <xref linkend="
11186 "\"sec.hook.changegroup\"/>) <literal role=\"hook\">prechangegroup</literal> "
11187 "(section <xref linkend=\"sec.hook.prechangegroup\"/>), <literal role=\"hook"
11188 "\">pretxnchangegroup</literal> (section <xref linkend=\"sec.hook."
11189 "pretxnchangegroup\"/>)"
11190 msgstr ""
11192 #. type: Content of: <book><chapter><sect1><sect2><title>
11193 #: ../en/ch09-hook.xml:1605
11194 msgid ""
11195 "<literal role=\"hook\">outgoing</literal>&emdash;after changesets are "
11196 "propagated"
11197 msgstr "<literal role=\"hook\">outgoing</literal>&emdash;传播修改集之后"
11199 #. type: Content of: <book><chapter><sect1><sect2><para>
11200 #: ../en/ch09-hook.xml:1608
11201 msgid ""
11202 "This hook is run after a group of changesets has been propagated out of this "
11203 "repository, for example by a <command role=\"hg-cmd\">hg push</command> or "
11204 "<command role=\"hg-cmd\">hg bundle</command> command."
11205 msgstr ""
11207 #. type: Content of: <book><chapter><sect1><sect2><para>
11208 #: ../en/ch09-hook.xml:1614
11209 msgid ""
11210 "One possible use for this hook is to notify administrators that changes have "
11211 "been pulled."
11212 msgstr ""
11214 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
11215 #: ../en/ch09-hook.xml:1621
11216 msgid ""
11217 "<literal>node</literal>: A changeset ID. The changeset ID of the first "
11218 "changeset of the group that was sent."
11219 msgstr ""
11221 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
11222 #: ../en/ch09-hook.xml:1626
11223 msgid ""
11224 "<literal>source</literal>: A string. The source of the of the operation (see "
11225 "section <xref linkend=\"sec.hook.sources\"/>). If a remote client pulled "
11226 "changes from this repository, <literal>source</literal> will be "
11227 "<literal>serve</literal>. If the client that obtained changes from this "
11228 "repository was local, <literal>source</literal> will be <literal>bundle</"
11229 "literal>, <literal>pull</literal>, or <literal>push</literal>, depending on "
11230 "the operation the client performed."
11231 msgstr ""
11233 #. type: Content of: <book><chapter><sect1><sect2><para>
11234 #: ../en/ch09-hook.xml:1646
11235 msgid ""
11236 "See also: <literal role=\"hook\">preoutgoing</literal> (section <xref linkend="
11237 "\"sec.hook.preoutgoing\"/>)"
11238 msgstr ""
11240 #. type: Content of: <book><chapter><sect1><sect2><title>
11241 #: ../en/ch09-hook.xml:1652
11242 msgid ""
11243 "<literal role=\"hook\">prechangegroup</literal>&emdash;before starting to add "
11244 "remote changesets"
11245 msgstr ""
11246 "<literal role=\"hook\">prechangegroup</literal>&emdash;增加远程修改集之前"
11248 #. type: Content of: <book><chapter><sect1><sect2><para>
11249 #: ../en/ch09-hook.xml:1656
11250 msgid ""
11251 "This controlling hook is run before Mercurial begins to add a group of "
11252 "changesets from another repository."
11253 msgstr ""
11255 #. type: Content of: <book><chapter><sect1><sect2><para>
11256 #: ../en/ch09-hook.xml:1660
11257 msgid ""
11258 "This hook does not have any information about the changesets to be added, "
11259 "because it is run before transmission of those changesets is allowed to "
11260 "begin. If this hook fails, the changesets will not be transmitted."
11261 msgstr ""
11263 #. type: Content of: <book><chapter><sect1><sect2><para>
11264 #: ../en/ch09-hook.xml:1666
11265 msgid ""
11266 "One use for this hook is to prevent external changes from being added to a "
11267 "repository. For example, you could use this to <quote>freeze</quote> a "
11268 "server-hosted branch temporarily or permanently so that users cannot push to "
11269 "it, while still allowing a local administrator to modify the repository."
11270 msgstr ""
11272 #. type: Content of: <book><chapter><sect1><sect2><para>
11273 #: ../en/ch09-hook.xml:1688
11274 msgid ""
11275 "See also: <literal role=\"hook\">changegroup</literal> (section <xref linkend="
11276 "\"sec.hook.changegroup\"/>), <literal role=\"hook\">incoming</literal> "
11277 "(section <xref linkend=\"sec.hook.incoming\"/>), , <literal role=\"hook"
11278 "\">pretxnchangegroup</literal> (section <xref linkend=\"sec.hook."
11279 "pretxnchangegroup\"/>)"
11280 msgstr ""
11282 #. type: Content of: <book><chapter><sect1><sect2><title>
11283 #: ../en/ch09-hook.xml:1698
11284 msgid ""
11285 "<literal role=\"hook\">precommit</literal>&emdash;before starting to commit a "
11286 "changeset"
11287 msgstr "<literal role=\"hook\">precommit</literal>&emdash;提交修改集之前"
11289 #. type: Content of: <book><chapter><sect1><sect2><para>
11290 #: ../en/ch09-hook.xml:1701
11291 msgid ""
11292 "This hook is run before Mercurial begins to commit a new changeset. It is run "
11293 "before Mercurial has any of the metadata for the commit, such as the files to "
11294 "be committed, the commit message, or the commit date."
11295 msgstr ""
11297 #. type: Content of: <book><chapter><sect1><sect2><para>
11298 #: ../en/ch09-hook.xml:1707
11299 msgid ""
11300 "One use for this hook is to disable the ability to commit new changesets, "
11301 "while still allowing incoming changesets. Another is to run a build or test, "
11302 "and only allow the commit to begin if the build or test succeeds."
11303 msgstr ""
11305 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
11306 #: ../en/ch09-hook.xml:1716
11307 msgid ""
11308 "<literal>parent1</literal>: A changeset ID. The changeset ID of the first "
11309 "parent of the working directory."
11310 msgstr ""
11312 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
11313 #: ../en/ch09-hook.xml:1721
11314 msgid ""
11315 "<literal>parent2</literal>: A changeset ID. The changeset ID of the second "
11316 "parent of the working directory."
11317 msgstr ""
11319 #. type: Content of: <book><chapter><sect1><sect2><para>
11320 #: ../en/ch09-hook.xml:1726
11321 msgid ""
11322 "If the commit proceeds, the parents of the working directory will become the "
11323 "parents of the new changeset."
11324 msgstr ""
11326 #. type: Content of: <book><chapter><sect1><sect2><para>
11327 #: ../en/ch09-hook.xml:1730
11328 msgid ""
11329 "See also: <literal role=\"hook\">commit</literal> (section <xref linkend="
11330 "\"sec.hook.commit\"/>), <literal role=\"hook\">pretxncommit</literal> "
11331 "(section <xref linkend=\"sec.hook.pretxncommit\"/>)"
11332 msgstr ""
11334 #. type: Content of: <book><chapter><sect1><sect2><title>
11335 #: ../en/ch09-hook.xml:1738
11336 msgid ""
11337 "<literal role=\"hook\">preoutgoing</literal>&emdash;before starting to "
11338 "propagate changesets"
11339 msgstr "<literal role=\"hook\">preoutgoing</literal>&emdash;传播修改集之前"
11341 #. type: Content of: <book><chapter><sect1><sect2><para>
11342 #: ../en/ch09-hook.xml:1741
11343 msgid ""
11344 "This hook is invoked before Mercurial knows the identities of the changesets "
11345 "to be transmitted."
11346 msgstr ""
11348 #. type: Content of: <book><chapter><sect1><sect2><para>
11349 #: ../en/ch09-hook.xml:1745
11350 msgid ""
11351 "One use for this hook is to prevent changes from being transmitted to another "
11352 "repository."
11353 msgstr ""
11355 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
11356 #: ../en/ch09-hook.xml:1752
11357 msgid ""
11358 "<literal>source</literal>: A string. The source of the operation that is "
11359 "attempting to obtain changes from this repository (see section <xref linkend="
11360 "\"sec.hook.sources\"/>). See the documentation for the <literal>source</"
11361 "literal> parameter to the <literal role=\"hook\">outgoing</literal> hook, in "
11362 "section <xref linkend=\"sec.hook.outgoing\"/>, for possible values of this "
11363 "parameter."
11364 msgstr ""
11366 #. type: Content of: <book><chapter><sect1><sect2><para>
11367 #: ../en/ch09-hook.xml:1770
11368 msgid ""
11369 "See also: <literal role=\"hook\">outgoing</literal> (section <xref linkend="
11370 "\"sec.hook.outgoing\"/>)"
11371 msgstr ""
11373 #. type: Content of: <book><chapter><sect1><sect2><title>
11374 #: ../en/ch09-hook.xml:1776
11375 msgid ""
11376 "<literal role=\"hook\">pretag</literal>&emdash;before tagging a changeset"
11377 msgstr "<literal role=\"hook\">pretag</literal>&emdash;创建标签之前"
11379 #. type: Content of: <book><chapter><sect1><sect2><para>
11380 #: ../en/ch09-hook.xml:1779
11381 msgid ""
11382 "This controlling hook is run before a tag is created. If the hook succeeds, "
11383 "creation of the tag proceeds. If the hook fails, the tag is not created."
11384 msgstr ""
11386 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
11387 #: ../en/ch09-hook.xml:1787
11388 msgid ""
11389 "<literal>local</literal>: A boolean. Whether the tag is local to this "
11390 "repository instance (i.e. stored in <filename role=\"special\">.hg/localtags</"
11391 "filename>) or managed by Mercurial (stored in <filename role=\"special\">."
11392 "hgtags</filename>)."
11393 msgstr ""
11395 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
11396 #: ../en/ch09-hook.xml:1794
11397 msgid ""
11398 "<literal>node</literal>: A changeset ID. The ID of the changeset to be "
11399 "tagged."
11400 msgstr ""
11402 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
11403 #: ../en/ch09-hook.xml:1798
11404 msgid "<literal>tag</literal>: A string. The name of the tag to be created."
11405 msgstr ""
11407 #. type: Content of: <book><chapter><sect1><sect2><para>
11408 #: ../en/ch09-hook.xml:1803
11409 msgid ""
11410 "If the tag to be created is revision-controlled, the <literal role=\"hook"
11411 "\">precommit</literal> and <literal role=\"hook\">pretxncommit</literal> "
11412 "hooks (sections <xref linkend=\"sec.hook.commit\"/> and <xref linkend=\"sec."
11413 "hook.pretxncommit\"/>) will also be run."
11414 msgstr ""
11416 #. type: Content of: <book><chapter><sect1><sect2><para>
11417 #: ../en/ch09-hook.xml:1810
11418 msgid ""
11419 "See also: <literal role=\"hook\">tag</literal> (section <xref linkend=\"sec."
11420 "hook.tag\"/>)"
11421 msgstr ""
11423 #. type: Content of: <book><chapter><sect1><sect2><title>
11424 #: ../en/ch09-hook.xml:1815
11425 msgid ""
11426 "<literal role=\"hook\">pretxnchangegroup</literal>&emdash;before completing "
11427 "addition of remote changesets"
11428 msgstr ""
11429 "<literal role=\"hook\">pretxnchangegroup</literal>&emdash;完成增加远程修改集之"
11430 "前"
11432 #. type: Content of: <book><chapter><sect1><sect2><para>
11433 #: ../en/ch09-hook.xml:1819
11434 msgid ""
11435 "This controlling hook is run before a transaction&emdash;that manages the "
11436 "addition of a group of new changesets from outside the repository&emdash;"
11437 "completes. If the hook succeeds, the transaction completes, and all of the "
11438 "changesets become permanent within this repository. If the hook fails, the "
11439 "transaction is rolled back, and the data for the changesets is erased."
11440 msgstr ""
11442 #. type: Content of: <book><chapter><sect1><sect2><para>
11443 #: ../en/ch09-hook.xml:1828
11444 msgid ""
11445 "This hook can access the metadata associated with the almost-added "
11446 "changesets, but it should not do anything permanent with this data. It must "
11447 "also not modify the working directory."
11448 msgstr ""
11450 #. type: Content of: <book><chapter><sect1><sect2><para>
11451 #: ../en/ch09-hook.xml:1834
11452 msgid ""
11453 "While this hook is running, if other Mercurial processes access this "
11454 "repository, they will be able to see the almost-added changesets as if they "
11455 "are permanent. This may lead to race conditions if you do not take steps to "
11456 "avoid them."
11457 msgstr ""
11459 #. type: Content of: <book><chapter><sect1><sect2><para>
11460 #: ../en/ch09-hook.xml:1841
11461 msgid ""
11462 "This hook can be used to automatically vet a group of changesets. If the "
11463 "hook fails, all of the changesets are <quote>rejected</quote> when the "
11464 "transaction rolls back."
11465 msgstr ""
11467 #. type: Content of: <book><chapter><sect1><sect2><para>
11468 #: ../en/ch09-hook.xml:1871
11469 msgid ""
11470 "See also: <literal role=\"hook\">changegroup</literal> (section <xref linkend="
11471 "\"sec.hook.changegroup\"/>), <literal role=\"hook\">incoming</literal> "
11472 "(section <xref linkend=\"sec.hook.incoming\"/>), <literal role=\"hook"
11473 "\">prechangegroup</literal> (section <xref linkend=\"sec.hook.prechangegroup"
11474 "\"/>)"
11475 msgstr ""
11477 #. type: Content of: <book><chapter><sect1><sect2><title>
11478 #: ../en/ch09-hook.xml:1881
11479 msgid ""
11480 "<literal role=\"hook\">pretxncommit</literal>&emdash;before completing commit "
11481 "of new changeset"
11482 msgstr "<literal role=\"hook\">pretxncommit</literal>&emdash;完成提交之前"
11484 #. type: Content of: <book><chapter><sect1><sect2><para>
11485 #: ../en/ch09-hook.xml:1884
11486 msgid ""
11487 "This controlling hook is run before a transaction&emdash;that manages a new "
11488 "commit&emdash;completes. If the hook succeeds, the transaction completes and "
11489 "the changeset becomes permanent within this repository. If the hook fails, "
11490 "the transaction is rolled back, and the commit data is erased."
11491 msgstr ""
11493 #. type: Content of: <book><chapter><sect1><sect2><para>
11494 #: ../en/ch09-hook.xml:1892
11495 msgid ""
11496 "This hook can access the metadata associated with the almost-new changeset, "
11497 "but it should not do anything permanent with this data. It must also not "
11498 "modify the working directory."
11499 msgstr ""
11501 #. type: Content of: <book><chapter><sect1><sect2><para>
11502 #: ../en/ch09-hook.xml:1898
11503 msgid ""
11504 "While this hook is running, if other Mercurial processes access this "
11505 "repository, they will be able to see the almost-new changeset as if it is "
11506 "permanent. This may lead to race conditions if you do not take steps to "
11507 "avoid them."
11508 msgstr ""
11510 #. type: Content of: <book><chapter><sect1><sect2><para>
11511 #: ../en/ch09-hook.xml:1922
11512 msgid ""
11513 "See also: <literal role=\"hook\">precommit</literal> (section <xref linkend="
11514 "\"sec.hook.precommit\"/>)"
11515 msgstr ""
11517 #. type: Content of: <book><chapter><sect1><sect2><title>
11518 #: ../en/ch09-hook.xml:1928
11519 msgid ""
11520 "<literal role=\"hook\">preupdate</literal>&emdash;before updating or merging "
11521 "working directory"
11522 msgstr ""
11523 "<literal role=\"hook\">preupdate</literal>&emdash;更新或合并工作目录之前"
11525 #. type: Content of: <book><chapter><sect1><sect2><para>
11526 #: ../en/ch09-hook.xml:1931
11527 msgid ""
11528 "This controlling hook is run before an update or merge of the working "
11529 "directory begins. It is run only if Mercurial's normal pre-update checks "
11530 "determine that the update or merge can proceed. If the hook succeeds, the "
11531 "update or merge may proceed; if it fails, the update or merge does not start."
11532 msgstr ""
11534 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
11535 #: ../en/ch09-hook.xml:1941
11536 msgid ""
11537 "<literal>parent1</literal>: A changeset ID. The ID of the parent that the "
11538 "working directory is to be updated to. If the working directory is being "
11539 "merged, it will not change this parent."
11540 msgstr ""
11542 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
11543 #: ../en/ch09-hook.xml:1947
11544 msgid ""
11545 "<literal>parent2</literal>: A changeset ID. Only set if the working "
11546 "directory is being merged. The ID of the revision that the working directory "
11547 "is being merged with."
11548 msgstr ""
11550 #. type: Content of: <book><chapter><sect1><sect2><para>
11551 #: ../en/ch09-hook.xml:1954
11552 msgid ""
11553 "See also: <literal role=\"hook\">update</literal> (section <xref linkend="
11554 "\"sec.hook.update\"/>)"
11555 msgstr ""
11557 #. type: Content of: <book><chapter><sect1><sect2><title>
11558 #: ../en/ch09-hook.xml:1960
11559 msgid "<literal role=\"hook\">tag</literal>&emdash;after tagging a changeset"
11560 msgstr "<literal role=\"hook\">tag</literal>&emdash;创建标签之后"
11562 #. type: Content of: <book><chapter><sect1><sect2><para>
11563 #: ../en/ch09-hook.xml:1963
11564 msgid "This hook is run after a tag has been created."
11565 msgstr ""
11567 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
11568 #: ../en/ch09-hook.xml:1969
11569 msgid ""
11570 "<literal>local</literal>: A boolean. Whether the new tag is local to this "
11571 "repository instance (i.e. stored in <filename role=\"special\">.hg/"
11572 "localtags</filename>) or managed by Mercurial (stored in <filename role="
11573 "\"special\">.hgtags</filename>)."
11574 msgstr ""
11576 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
11577 #: ../en/ch09-hook.xml:1977
11578 msgid ""
11579 "<literal>node</literal>: A changeset ID. The ID of the changeset that was "
11580 "tagged."
11581 msgstr ""
11583 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
11584 #: ../en/ch09-hook.xml:1981
11585 msgid "<literal>tag</literal>: A string. The name of the tag that was created."
11586 msgstr ""
11588 #. type: Content of: <book><chapter><sect1><sect2><para>
11589 #: ../en/ch09-hook.xml:1986
11590 msgid ""
11591 "If the created tag is revision-controlled, the <literal role=\"hook\">commit</"
11592 "literal> hook (section <xref linkend=\"sec.hook.commit\"/>) is run before "
11593 "this hook."
11594 msgstr ""
11596 #. type: Content of: <book><chapter><sect1><sect2><para>
11597 #: ../en/ch09-hook.xml:1991
11598 msgid ""
11599 "See also: <literal role=\"hook\">pretag</literal> (section <xref linkend="
11600 "\"sec.hook.pretag\"/>)"
11601 msgstr ""
11603 #. type: Content of: <book><chapter><sect1><sect2><title>
11604 #: ../en/ch09-hook.xml:1997
11605 msgid ""
11606 "<literal role=\"hook\">update</literal>&emdash;after updating or merging "
11607 "working directory"
11608 msgstr "<literal role=\"hook\">update</literal>&emdash;更新或合并工作目录之后"
11610 #. type: Content of: <book><chapter><sect1><sect2><para>
11611 #: ../en/ch09-hook.xml:2000
11612 msgid ""
11613 "This hook is run after an update or merge of the working directory "
11614 "completes. Since a merge can fail (if the external <command>hgmerge</"
11615 "command> command fails to resolve conflicts in a file), this hook "
11616 "communicates whether the update or merge completed cleanly."
11617 msgstr ""
11619 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
11620 #: ../en/ch09-hook.xml:2008
11621 msgid ""
11622 "<literal>error</literal>: A boolean. Indicates whether the update or merge "
11623 "completed successfully."
11624 msgstr ""
11626 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
11627 #: ../en/ch09-hook.xml:2013
11628 msgid ""
11629 "<literal>parent1</literal>: A changeset ID. The ID of the parent that the "
11630 "working directory was updated to. If the working directory was merged, it "
11631 "will not have changed this parent."
11632 msgstr ""
11634 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
11635 #: ../en/ch09-hook.xml:2019
11636 msgid ""
11637 "<literal>parent2</literal>: A changeset ID. Only set if the working "
11638 "directory was merged. The ID of the revision that the working directory was "
11639 "merged with."
11640 msgstr ""
11642 #. type: Content of: <book><chapter><sect1><sect2><para>
11643 #: ../en/ch09-hook.xml:2025
11644 msgid ""
11645 "See also: <literal role=\"hook\">preupdate</literal> (section <xref linkend="
11646 "\"sec.hook.preupdate\"/>)"
11647 msgstr ""
11649 #. type: Content of: <book><chapter><title>
11650 #: ../en/ch10-template.xml:5
11651 msgid "Customising the output of Mercurial"
11652 msgstr "定制 Mercurial 的输出"
11654 #. type: Content of: <book><chapter><para>
11655 #: ../en/ch10-template.xml:7
11656 msgid ""
11657 "Mercurial provides a powerful mechanism to let you control how it displays "
11658 "information. The mechanism is based on templates. You can use templates to "
11659 "generate specific output for a single command, or to customise the entire "
11660 "appearance of the built-in web interface."
11661 msgstr ""
11663 #. type: Content of: <book><chapter><sect1><title>
11664 #: ../en/ch10-template.xml:14
11665 msgid "Using precanned output styles"
11666 msgstr "使用预定义的输出样式"
11668 #. type: Content of: <book><chapter><sect1><para>
11669 #: ../en/ch10-template.xml:16
11670 msgid ""
11671 "Packaged with Mercurial are some output styles that you can use immediately. "
11672 "A style is simply a precanned template that someone wrote and installed "
11673 "somewhere that Mercurial can find."
11674 msgstr ""
11676 #. type: Content of: <book><chapter><sect1><para>
11677 #: ../en/ch10-template.xml:21
11678 msgid ""
11679 "Before we take a look at Mercurial's bundled styles, let's review its normal "
11680 "output."
11681 msgstr ""
11683 #. type: Content of: <book><chapter><sect1><para>
11684 #: ../en/ch10-template.xml:26
11685 msgid ""
11686 "This is somewhat informative, but it takes up a lot of space&emdash;five "
11687 "lines of output per changeset. The <literal>compact</literal> style reduces "
11688 "this to three lines, presented in a sparse manner."
11689 msgstr ""
11691 #. type: Content of: <book><chapter><sect1><para>
11692 #: ../en/ch10-template.xml:33
11693 msgid ""
11694 "The <literal>changelog</literal> style hints at the expressive power of "
11695 "Mercurial's templating engine. This style attempts to follow the GNU "
11696 "Project's changelog guidelines<citation>web:changelog</citation>."
11697 msgstr ""
11699 #. type: Content of: <book><chapter><sect1><para>
11700 #: ../en/ch10-template.xml:40
11701 msgid ""
11702 "You will not be shocked to learn that Mercurial's default output style is "
11703 "named <literal>default</literal>."
11704 msgstr ""
11706 #. type: Content of: <book><chapter><sect1><sect2><title>
11707 #: ../en/ch10-template.xml:44
11708 msgid "Setting a default style"
11709 msgstr "设置默认样式"
11711 #. type: Content of: <book><chapter><sect1><sect2><para>
11712 #: ../en/ch10-template.xml:46
11713 msgid ""
11714 "You can modify the output style that Mercurial will use for every command by "
11715 "editing your <filename role=\"special\">~/.hgrc</filename> file, naming the "
11716 "style you would prefer to use."
11717 msgstr ""
11719 #. type: Content of: <book><chapter><sect1><sect2><para>
11720 #: ../en/ch10-template.xml:54
11721 msgid ""
11722 "If you write a style of your own, you can use it by either providing the path "
11723 "to your style file, or copying your style file into a location where "
11724 "Mercurial can find it (typically the <literal>templates</literal> "
11725 "subdirectory of your Mercurial install directory)."
11726 msgstr ""
11728 #. type: Content of: <book><chapter><sect1><title>
11729 #: ../en/ch10-template.xml:63
11730 msgid "Commands that support styles and templates"
11731 msgstr "支持样式和模版的命令"
11733 #. type: Content of: <book><chapter><sect1><para>
11734 #: ../en/ch10-template.xml:65
11735 msgid ""
11736 "All of Mercurial's <quote><literal>log</literal>-like</quote> commands let "
11737 "you use styles and templates: <command role=\"hg-cmd\">hg incoming</command>, "
11738 "<command role=\"hg-cmd\">hg log</command>, <command role=\"hg-cmd\">hg "
11739 "outgoing</command>, and <command role=\"hg-cmd\">hg tip</command>."
11740 msgstr ""
11742 #. type: Content of: <book><chapter><sect1><para>
11743 #: ../en/ch10-template.xml:72
11744 msgid ""
11745 "As I write this manual, these are so far the only commands that support "
11746 "styles and templates. Since these are the most important commands that need "
11747 "customisable output, there has been little pressure from the Mercurial user "
11748 "community to add style and template support to other commands."
11749 msgstr ""
11751 #. type: Content of: <book><chapter><sect1><title>
11752 #: ../en/ch10-template.xml:80
11753 msgid "The basics of templating"
11754 msgstr "模版基础"
11756 #. type: Content of: <book><chapter><sect1><para>
11757 #: ../en/ch10-template.xml:82
11758 msgid ""
11759 "At its simplest, a Mercurial template is a piece of text. Some of the text "
11760 "never changes, while other parts are <emphasis>expanded</emphasis>, or "
11761 "replaced with new text, when necessary."
11762 msgstr ""
11764 #. type: Content of: <book><chapter><sect1><para>
11765 #: ../en/ch10-template.xml:87
11766 msgid ""
11767 "Before we continue, let's look again at a simple example of Mercurial's "
11768 "normal output."
11769 msgstr ""
11771 #. type: Content of: <book><chapter><sect1><para>
11772 #: ../en/ch10-template.xml:92
11773 msgid ""
11774 "Now, let's run the same command, but using a template to change its output."
11775 msgstr ""
11777 #. type: Content of: <book><chapter><sect1><para>
11778 #: ../en/ch10-template.xml:97
11779 msgid ""
11780 "The example above illustrates the simplest possible template; it's just a "
11781 "piece of static text, printed once for each changeset. The <option role=\"hg-"
11782 "opt-log\">--template</option> option to the <command role=\"hg-cmd\">hg log</"
11783 "command> command tells Mercurial to use the given text as the template when "
11784 "printing each changeset."
11785 msgstr ""
11787 #. type: Content of: <book><chapter><sect1><para>
11788 #: ../en/ch10-template.xml:105
11789 msgid ""
11790 "Notice that the template string above ends with the text <quote><literal>\\n</"
11791 "literal></quote>. This is an <emphasis>escape sequence</emphasis>, telling "
11792 "Mercurial to print a newline at the end of each template item. If you omit "
11793 "this newline, Mercurial will run each piece of output together. See section "
11794 "<xref linkend=\"sec.template.escape\"/> for more details of escape sequences."
11795 msgstr ""
11797 #. type: Content of: <book><chapter><sect1><para>
11798 #: ../en/ch10-template.xml:113
11799 msgid ""
11800 "A template that prints a fixed string of text all the time isn't very useful; "
11801 "let's try something a bit more complex."
11802 msgstr ""
11804 #. type: Content of: <book><chapter><sect1><para>
11805 #: ../en/ch10-template.xml:119
11806 msgid ""
11807 "As you can see, the string <quote><literal>{desc}</literal></quote> in the "
11808 "template has been replaced in the output with the description of each "
11809 "changeset. Every time Mercurial finds text enclosed in curly braces "
11810 "(<quote><literal>{</literal></quote> and <quote><literal>}</literal></"
11811 "quote>), it will try to replace the braces and text with the expansion of "
11812 "whatever is inside. To print a literal curly brace, you must escape it, as "
11813 "described in section <xref linkend=\"sec.template.escape\"/>."
11814 msgstr ""
11816 #. type: Content of: <book><chapter><sect1><title>
11817 #: ../en/ch10-template.xml:132
11818 msgid "Common template keywords"
11819 msgstr "模版关键字"
11821 #. type: Content of: <book><chapter><sect1><para>
11822 #: ../en/ch10-template.xml:134
11823 msgid ""
11824 "You can start writing simple templates immediately using the keywords below."
11825 msgstr ""
11827 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
11828 #: ../en/ch10-template.xml:138
11829 msgid ""
11830 "<literal role=\"template-keyword\">author</literal>: String. The unmodified "
11831 "author of the changeset."
11832 msgstr ""
11834 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
11835 #: ../en/ch10-template.xml:142
11836 msgid ""
11837 "<literal role=\"template-keyword\">branches</literal>: String. The name of "
11838 "the branch on which the changeset was committed. Will be empty if the branch "
11839 "name was <literal>default</literal>."
11840 msgstr ""
11842 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
11843 #: ../en/ch10-template.xml:148
11844 msgid ""
11845 "<literal role=\"template-keyword\">date</literal>: Date information. The "
11846 "date when the changeset was committed. This is <emphasis>not</emphasis> "
11847 "human-readable; you must pass it through a filter that will render it "
11848 "appropriately. See section <xref linkend=\"sec.template.filter\"/> for more "
11849 "information on filters. The date is expressed as a pair of numbers. The "
11850 "first number is a Unix UTC timestamp (seconds since January 1, 1970); the "
11851 "second is the offset of the committer's timezone from UTC, in seconds."
11852 msgstr ""
11854 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
11855 #: ../en/ch10-template.xml:159
11856 msgid ""
11857 "<literal role=\"template-keyword\">desc</literal>: String. The text of the "
11858 "changeset description."
11859 msgstr ""
11861 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
11862 #: ../en/ch10-template.xml:162
11863 msgid ""
11864 "<literal role=\"template-keyword\">files</literal>: List of strings. All "
11865 "files modified, added, or removed by this changeset."
11866 msgstr ""
11868 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
11869 #: ../en/ch10-template.xml:167
11870 msgid ""
11871 "<literal role=\"template-keyword\">file_adds</literal>: List of strings. "
11872 "Files added by this changeset."
11873 msgstr ""
11875 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
11876 #: ../en/ch10-template.xml:171
11877 msgid ""
11878 "<literal role=\"template-keyword\">file_dels</literal>: List of strings. "
11879 "Files removed by this changeset."
11880 msgstr ""
11882 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
11883 #: ../en/ch10-template.xml:175
11884 msgid ""
11885 "<literal role=\"template-keyword\">node</literal>: String. The changeset "
11886 "identification hash, as a 40-character hexadecimal string."
11887 msgstr ""
11889 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
11890 #: ../en/ch10-template.xml:179
11891 msgid ""
11892 "<literal role=\"template-keyword\">parents</literal>: List of strings. The "
11893 "parents of the changeset."
11894 msgstr ""
11896 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
11897 #: ../en/ch10-template.xml:183
11898 msgid ""
11899 "<literal role=\"template-keyword\">rev</literal>: Integer. The repository-"
11900 "local changeset revision number."
11901 msgstr ""
11903 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
11904 #: ../en/ch10-template.xml:187
11905 msgid ""
11906 "<literal role=\"template-keyword\">tags</literal>: List of strings. Any tags "
11907 "associated with the changeset."
11908 msgstr ""
11910 #. type: Content of: <book><chapter><sect1><para>
11911 #: ../en/ch10-template.xml:192
11912 msgid ""
11913 "A few simple experiments will show us what to expect when we use these "
11914 "keywords; you can see the results below."
11915 msgstr ""
11917 #. type: Content of: <book><chapter><sect1><para>
11918 #: ../en/ch10-template.xml:197
11919 msgid ""
11920 "As we noted above, the date keyword does not produce human-readable output, "
11921 "so we must treat it specially. This involves using a <emphasis>filter</"
11922 "emphasis>, about which more in section <xref linkend=\"sec.template.filter\"/"
11923 ">."
11924 msgstr ""
11926 #. type: Content of: <book><chapter><sect1><title>
11927 #: ../en/ch10-template.xml:207
11928 msgid "Escape sequences"
11929 msgstr "转义序列"
11931 #. type: Content of: <book><chapter><sect1><para>
11932 #: ../en/ch10-template.xml:209
11933 msgid ""
11934 "Mercurial's templating engine recognises the most commonly used escape "
11935 "sequences in strings. When it sees a backslash (<quote><literal>\\</"
11936 "literal></quote>) character, it looks at the following character and "
11937 "substitutes the two characters with a single replacement, as described below."
11938 msgstr ""
11940 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
11941 #: ../en/ch10-template.xml:216
11942 msgid ""
11943 "<literal>\\</literal>: Backslash, <quote><literal>\\</literal></quote>, ASCII "
11944 "134."
11945 msgstr ""
11947 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
11948 #: ../en/ch10-template.xml:220
11949 msgid "<literal>\\n</literal>: Newline, ASCII 12."
11950 msgstr ""
11952 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
11953 #: ../en/ch10-template.xml:223
11954 msgid "<literal>\\r</literal>: Carriage return, ASCII 15."
11955 msgstr ""
11957 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
11958 #: ../en/ch10-template.xml:226
11959 msgid "<literal>\\t</literal>: Tab, ASCII 11."
11960 msgstr ""
11962 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
11963 #: ../en/ch10-template.xml:229
11964 msgid "<literal>\\v</literal>: Vertical tab, ASCII 13."
11965 msgstr ""
11967 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
11968 #: ../en/ch10-template.xml:232
11969 msgid ""
11970 "<literal>{</literal>: Open curly brace, <quote><literal>{</literal></quote>, "
11971 "ASCII 173."
11972 msgstr ""
11974 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
11975 #: ../en/ch10-template.xml:236
11976 msgid ""
11977 "<literal>}</literal>: Close curly brace, <quote><literal>}</literal></quote>, "
11978 "ASCII 175."
11979 msgstr ""
11981 #. type: Content of: <book><chapter><sect1><para>
11982 #: ../en/ch10-template.xml:241
11983 msgid ""
11984 "As indicated above, if you want the expansion of a template to contain a "
11985 "literal <quote><literal>\\</literal></quote>, <quote><literal>{</literal></"
11986 "quote>, or <quote><literal>{</literal></quote> character, you must escape it."
11987 msgstr ""
11989 #. type: Content of: <book><chapter><sect1><title>
11990 #: ../en/ch10-template.xml:249
11991 msgid "Filtering keywords to change their results"
11992 msgstr "通过过滤关键字来修改输出结果"
11994 #. type: Content of: <book><chapter><sect1><para>
11995 #: ../en/ch10-template.xml:251
11996 msgid ""
11997 "Some of the results of template expansion are not immediately easy to use. "
11998 "Mercurial lets you specify an optional chain of <emphasis>filters</emphasis> "
11999 "to modify the result of expanding a keyword. You have already seen a common "
12000 "filter, <literal role=\"template-kw-filt-date\">isodate</literal>, in action "
12001 "above, to make a date readable."
12002 msgstr ""
12004 #. type: Content of: <book><chapter><sect1><para>
12005 #: ../en/ch10-template.xml:258
12006 msgid ""
12007 "Below is a list of the most commonly used filters that Mercurial supports. "
12008 "While some filters can be applied to any text, others can only be used in "
12009 "specific circumstances. The name of each filter is followed first by an "
12010 "indication of where it can be used, then a description of its effect."
12011 msgstr ""
12013 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12014 #: ../en/ch10-template.xml:265
12015 msgid ""
12016 "<literal role=\"template-filter\">addbreaks</literal>: Any text. Add an XHTML "
12017 "<quote><literal>&lt;br/&gt;</literal></quote> tag before the end of every "
12018 "line except the last. For example, <quote><literal>foo\\nbar</literal></"
12019 "quote> becomes <quote><literal>foo&lt;br/&gt;\\nbar</literal></quote>."
12020 msgstr ""
12022 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12023 #: ../en/ch10-template.xml:272
12024 msgid ""
12025 "<literal role=\"template-kw-filt-date\">age</literal>: <literal role="
12026 "\"template-keyword\">date</literal> keyword. Render the age of the date, "
12027 "relative to the current time. Yields a string like <quote><literal>10 "
12028 "minutes</literal></quote>."
12029 msgstr ""
12031 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12032 #: ../en/ch10-template.xml:279
12033 msgid ""
12034 "<literal role=\"template-filter\">basename</literal>: Any text, but most "
12035 "useful for the <literal role=\"template-keyword\">files</literal> keyword and "
12036 "its relatives. Treat the text as a path, and return the basename. For "
12037 "example, <quote><literal>foo/bar/baz</literal></quote> becomes "
12038 "<quote><literal>baz</literal></quote>."
12039 msgstr ""
12041 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12042 #: ../en/ch10-template.xml:288
12043 msgid ""
12044 "<literal role=\"template-kw-filt-date\">date</literal>: <literal role="
12045 "\"template-keyword\">date</literal> keyword. Render a date in a similar "
12046 "format to the Unix <literal role=\"template-keyword\">date</literal> command, "
12047 "but with timezone included. Yields a string like <quote><literal>Mon Sep 04 "
12048 "15:13:13 2006 -0700</literal></quote>."
12049 msgstr ""
12051 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12052 #: ../en/ch10-template.xml:296
12053 msgid ""
12054 "<literal role=\"template-kw-filt-author\">domain</literal>: Any text, but "
12055 "most useful for the <literal role=\"template-keyword\">author</literal> "
12056 "keyword. Finds the first string that looks like an email address, and "
12057 "extract just the domain component. For example, <quote><literal>Bryan "
12058 "O'Sullivan &lt;bos@serpentine.com&gt;</literal></quote> becomes "
12059 "<quote><literal>serpentine.com</literal></quote>."
12060 msgstr ""
12062 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12063 #: ../en/ch10-template.xml:306
12064 msgid ""
12065 "<literal role=\"template-kw-filt-author\">email</literal>: Any text, but most "
12066 "useful for the <literal role=\"template-keyword\">author</literal> keyword. "
12067 "Extract the first string that looks like an email address. For example, "
12068 "<quote><literal>Bryan O'Sullivan &lt;bos@serpentine.com&gt;</literal></quote> "
12069 "becomes <quote><literal>bos@serpentine.com</literal></quote>."
12070 msgstr ""
12072 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12073 #: ../en/ch10-template.xml:315
12074 msgid ""
12075 "<literal role=\"template-filter\">escape</literal>: Any text. Replace the "
12076 "special XML/XHTML characters <quote><literal>&amp;</literal></quote>, "
12077 "<quote><literal>&lt;</literal></quote> and <quote><literal>&gt;</literal></"
12078 "quote> with XML entities."
12079 msgstr ""
12081 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12082 #: ../en/ch10-template.xml:323
12083 msgid ""
12084 "<literal role=\"template-filter\">fill68</literal>: Any text. Wrap the text "
12085 "to fit in 68 columns. This is useful before you pass text through the "
12086 "<literal role=\"template-filter\">tabindent</literal> filter, and still want "
12087 "it to fit in an 80-column fixed-font window."
12088 msgstr ""
12090 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12091 #: ../en/ch10-template.xml:331
12092 msgid ""
12093 "<literal role=\"template-filter\">fill76</literal>: Any text. Wrap the text "
12094 "to fit in 76 columns."
12095 msgstr ""
12097 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12098 #: ../en/ch10-template.xml:335
12099 msgid ""
12100 "<literal role=\"template-filter\">firstline</literal>: Any text. Yield the "
12101 "first line of text, without any trailing newlines."
12102 msgstr ""
12104 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12105 #: ../en/ch10-template.xml:340
12106 msgid ""
12107 "<literal role=\"template-kw-filt-date\">hgdate</literal>: <literal role="
12108 "\"template-keyword\">date</literal> keyword. Render the date as a pair of "
12109 "readable numbers. Yields a string like <quote><literal>1157407993 25200</"
12110 "literal></quote>."
12111 msgstr ""
12113 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12114 #: ../en/ch10-template.xml:347
12115 msgid ""
12116 "<literal role=\"template-kw-filt-date\">isodate</literal>: <literal role="
12117 "\"template-keyword\">date</literal> keyword. Render the date as a text "
12118 "string in ISO 8601 format. Yields a string like <quote><literal>2006-09-04 "
12119 "15:13:13 -0700</literal></quote>."
12120 msgstr ""
12122 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12123 #: ../en/ch10-template.xml:354
12124 msgid ""
12125 "<literal role=\"template-filter\">obfuscate</literal>: Any text, but most "
12126 "useful for the <literal role=\"template-keyword\">author</literal> keyword. "
12127 "Yield the input text rendered as a sequence of XML entities. This helps to "
12128 "defeat some particularly stupid screen-scraping email harvesting spambots."
12129 msgstr ""
12131 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12132 #: ../en/ch10-template.xml:362
12133 msgid ""
12134 "<literal role=\"template-kw-filt-author\">person</literal>: Any text, but "
12135 "most useful for the <literal role=\"template-keyword\">author</literal> "
12136 "keyword. Yield the text before an email address. For example, "
12137 "<quote><literal>Bryan O'Sullivan &lt;bos@serpentine.com&gt;</literal></quote> "
12138 "becomes <quote><literal>Bryan O'Sullivan</literal></quote>."
12139 msgstr ""
12141 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12142 #: ../en/ch10-template.xml:371
12143 msgid ""
12144 "<literal role=\"template-kw-filt-date\">rfc822date</literal>: <literal role="
12145 "\"template-keyword\">date</literal> keyword. Render a date using the same "
12146 "format used in email headers. Yields a string like <quote><literal>Mon, 04 "
12147 "Sep 2006 15:13:13 -0700</literal></quote>."
12148 msgstr ""
12150 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12151 #: ../en/ch10-template.xml:378
12152 msgid ""
12153 "<literal role=\"template-kw-filt-node\">short</literal>: Changeset hash. "
12154 "Yield the short form of a changeset hash, i.e. a 12-character hexadecimal "
12155 "string."
12156 msgstr ""
12158 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12159 #: ../en/ch10-template.xml:383
12160 msgid ""
12161 "<literal role=\"template-kw-filt-date\">shortdate</literal>: <literal role="
12162 "\"template-keyword\">date</literal> keyword. Render the year, month, and day "
12163 "of the date. Yields a string like <quote><literal>2006-09-04</literal></"
12164 "quote>."
12165 msgstr ""
12167 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12168 #: ../en/ch10-template.xml:389
12169 msgid ""
12170 "<literal role=\"template-filter\">strip</literal>: Any text. Strip all "
12171 "leading and trailing whitespace from the string."
12172 msgstr ""
12174 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12175 #: ../en/ch10-template.xml:393
12176 msgid ""
12177 "<literal role=\"template-filter\">tabindent</literal>: Any text. Yield the "
12178 "text, with every line except the first starting with a tab character."
12179 msgstr ""
12181 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12182 #: ../en/ch10-template.xml:398
12183 msgid ""
12184 "<literal role=\"template-filter\">urlescape</literal>: Any text. Escape all "
12185 "characters that are considered <quote>special</quote> by URL parsers. For "
12186 "example, <literal>foo bar</literal> becomes <literal>foo%20bar</literal>."
12187 msgstr ""
12189 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12190 #: ../en/ch10-template.xml:405
12191 msgid ""
12192 "<literal role=\"template-kw-filt-author\">user</literal>: Any text, but most "
12193 "useful for the <literal role=\"template-keyword\">author</literal> keyword. "
12194 "Return the <quote>user</quote> portion of an email address. For example, "
12195 "<quote><literal>Bryan O'Sullivan &lt;bos@serpentine.com&gt;</literal></quote> "
12196 "becomes <quote><literal>bos</literal></quote>."
12197 msgstr ""
12199 #. type: Content of: <book><chapter><sect1><note><para>
12200 #: ../en/ch10-template.xml:418
12201 msgid ""
12202 "If you try to apply a filter to a piece of data that it cannot process, "
12203 "Mercurial will fail and print a Python exception. For example, trying to run "
12204 "the output of the <literal role=\"template-keyword\">desc</literal> keyword "
12205 "into the <literal role=\"template-kw-filt-date\">isodate</literal> filter is "
12206 "not a good idea."
12207 msgstr ""
12209 #. type: Content of: <book><chapter><sect1><sect2><title>
12210 #: ../en/ch10-template.xml:427
12211 msgid "Combining filters"
12212 msgstr "组合过滤器"
12214 #. type: Content of: <book><chapter><sect1><sect2><para>
12215 #: ../en/ch10-template.xml:429
12216 msgid ""
12217 "It is easy to combine filters to yield output in the form you would like. "
12218 "The following chain of filters tidies up a description, then makes sure that "
12219 "it fits cleanly into 68 columns, then indents it by a further 8 characters "
12220 "(at least on Unix-like systems, where a tab is conventionally 8 characters "
12221 "wide)."
12222 msgstr ""
12224 #. type: Content of: <book><chapter><sect1><sect2><para>
12225 #: ../en/ch10-template.xml:438
12226 msgid ""
12227 "Note the use of <quote><literal>\\t</literal></quote> (a tab character) in "
12228 "the template to force the first line to be indented; this is necessary since "
12229 "<literal role=\"template-keyword\">tabindent</literal> indents all lines "
12230 "<emphasis>except</emphasis> the first."
12231 msgstr ""
12233 #. type: Content of: <book><chapter><sect1><sect2><para>
12234 #: ../en/ch10-template.xml:444
12235 msgid ""
12236 "Keep in mind that the order of filters in a chain is significant. The first "
12237 "filter is applied to the result of the keyword; the second to the result of "
12238 "the first filter; and so on. For example, using <literal>fill68|tabindent</"
12239 "literal> gives very different results from <literal>tabindent|fill68</"
12240 "literal>."
12241 msgstr ""
12243 #. type: Content of: <book><chapter><sect1><title>
12244 #: ../en/ch10-template.xml:455
12245 msgid "From templates to styles"
12246 msgstr "从模版到样式"
12248 #. type: Content of: <book><chapter><sect1><para>
12249 #: ../en/ch10-template.xml:457
12250 msgid ""
12251 "A command line template provides a quick and simple way to format some "
12252 "output. Templates can become verbose, though, and it's useful to be able to "
12253 "give a template a name. A style file is a template with a name, stored in a "
12254 "file."
12255 msgstr ""
12257 #. type: Content of: <book><chapter><sect1><para>
12258 #: ../en/ch10-template.xml:462
12259 msgid ""
12260 "More than that, using a style file unlocks the power of Mercurial's "
12261 "templating engine in ways that are not possible using the command line "
12262 "<option role=\"hg-opt-log\">--template</option> option."
12263 msgstr ""
12265 #. type: Content of: <book><chapter><sect1><sect2><title>
12266 #: ../en/ch10-template.xml:468
12267 msgid "The simplest of style files"
12268 msgstr "最简单的样式文件"
12270 #. type: Content of: <book><chapter><sect1><sect2><para>
12271 #: ../en/ch10-template.xml:470
12272 msgid "Our simple style file contains just one line:"
12273 msgstr ""
12275 #. type: Content of: <book><chapter><sect1><sect2><para>
12276 #: ../en/ch10-template.xml:474
12277 msgid ""
12278 "This tells Mercurial, <quote>if you're printing a changeset, use the text on "
12279 "the right as the template</quote>."
12280 msgstr ""
12282 #. type: Content of: <book><chapter><sect1><sect2><title>
12283 #: ../en/ch10-template.xml:480
12284 msgid "Style file syntax"
12285 msgstr "样式文件语法"
12287 #. type: Content of: <book><chapter><sect1><sect2><para>
12288 #: ../en/ch10-template.xml:482
12289 msgid "The syntax rules for a style file are simple."
12290 msgstr ""
12292 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12293 #: ../en/ch10-template.xml:485
12294 msgid "The file is processed one line at a time."
12295 msgstr ""
12297 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12298 #: ../en/ch10-template.xml:488
12299 msgid "Leading and trailing white space are ignored."
12300 msgstr ""
12302 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12303 #: ../en/ch10-template.xml:491
12304 msgid "Empty lines are skipped."
12305 msgstr ""
12307 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12308 #: ../en/ch10-template.xml:493
12309 msgid ""
12310 "If a line starts with either of the characters <quote><literal>#</literal></"
12311 "quote> or <quote><literal>;</literal></quote>, the entire line is treated as "
12312 "a comment, and skipped as if empty."
12313 msgstr ""
12315 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12316 #: ../en/ch10-template.xml:498
12317 msgid ""
12318 "A line starts with a keyword. This must start with an alphabetic character "
12319 "or underscore, and can subsequently contain any alphanumeric character or "
12320 "underscore. (In regexp notation, a keyword must match <literal>[A-Za-z_][A-"
12321 "Za-z0-9_]*</literal>.)"
12322 msgstr ""
12324 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12325 #: ../en/ch10-template.xml:504
12326 msgid ""
12327 "The next element must be an <quote><literal>=</literal></quote> character, "
12328 "which can be preceded or followed by an arbitrary amount of white space."
12329 msgstr ""
12331 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12332 #: ../en/ch10-template.xml:509
12333 msgid ""
12334 "If the rest of the line starts and ends with matching quote characters "
12335 "(either single or double quote), it is treated as a template body."
12336 msgstr ""
12338 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12339 #: ../en/ch10-template.xml:513
12340 msgid ""
12341 "If the rest of the line <emphasis>does not</emphasis> start with a quote "
12342 "character, it is treated as the name of a file; the contents of this file "
12343 "will be read and used as a template body."
12344 msgstr ""
12346 #. type: Content of: <book><chapter><sect1><title>
12347 #: ../en/ch10-template.xml:522
12348 msgid "Style files by example"
12349 msgstr "样式文件例子"
12351 #. type: Content of: <book><chapter><sect1><para>
12352 #: ../en/ch10-template.xml:524
12353 msgid ""
12354 "To illustrate how to write a style file, we will construct a few by example. "
12355 "Rather than provide a complete style file and walk through it, we'll mirror "
12356 "the usual process of developing a style file by starting with something very "
12357 "simple, and walking through a series of successively more complete examples."
12358 msgstr ""
12360 #. type: Content of: <book><chapter><sect1><sect2><title>
12361 #: ../en/ch10-template.xml:531
12362 msgid "Identifying mistakes in style files"
12363 msgstr "在样式文件中定位错误"
12365 #. type: Content of: <book><chapter><sect1><sect2><para>
12366 #: ../en/ch10-template.xml:533
12367 msgid ""
12368 "If Mercurial encounters a problem in a style file you are working on, it "
12369 "prints a terse error message that, once you figure out what it means, is "
12370 "actually quite useful."
12371 msgstr ""
12373 #. type: Content of: <book><chapter><sect1><sect2><para>
12374 #: ../en/ch10-template.xml:539
12375 msgid ""
12376 "Notice that <filename>broken.style</filename> attempts to define a "
12377 "<literal>changeset</literal> keyword, but forgets to give any content for it. "
12378 "When instructed to use this style file, Mercurial promptly complains."
12379 msgstr ""
12381 #. type: Content of: <book><chapter><sect1><sect2><para>
12382 #: ../en/ch10-template.xml:546
12383 msgid "This error message looks intimidating, but it is not too hard to follow."
12384 msgstr ""
12386 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12387 #: ../en/ch10-template.xml:550
12388 msgid ""
12389 "The first component is simply Mercurial's way of saying <quote>I am giving "
12390 "up</quote>."
12391 msgstr ""
12393 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12394 #: ../en/ch10-template.xml:554
12395 msgid "Next comes the name of the style file that contains the error."
12396 msgstr ""
12398 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12399 #: ../en/ch10-template.xml:558
12400 msgid ""
12401 "Following the file name is the line number where the error was encountered."
12402 msgstr ""
12404 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12405 #: ../en/ch10-template.xml:562
12406 msgid "Finally, a description of what went wrong."
12407 msgstr ""
12409 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12410 #: ../en/ch10-template.xml:566
12411 msgid ""
12412 "The description of the problem is not always clear (as in this case), but "
12413 "even when it is cryptic, it is almost always trivial to visually inspect the "
12414 "offending line in the style file and see what is wrong."
12415 msgstr ""
12417 #. type: Content of: <book><chapter><sect1><sect2><title>
12418 #: ../en/ch10-template.xml:574
12419 msgid "Uniquely identifying a repository"
12420 msgstr "版本库的唯一标识"
12422 #. type: Content of: <book><chapter><sect1><sect2><para>
12423 #: ../en/ch10-template.xml:576
12424 msgid ""
12425 "If you would like to be able to identify a Mercurial repository <quote>fairly "
12426 "uniquely</quote> using a short string as an identifier, you can use the first "
12427 "revision in the repository."
12428 msgstr ""
12430 #. type: Content of: <book><chapter><sect1><sect2><para>
12431 #: ../en/ch10-template.xml:583
12432 msgid ""
12433 "This is not guaranteed to be unique, but it is nevertheless useful in many "
12434 "cases."
12435 msgstr ""
12437 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12438 #: ../en/ch10-template.xml:586
12439 msgid ""
12440 "It will not work in a completely empty repository, because such a repository "
12441 "does not have a revision zero."
12442 msgstr ""
12444 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12445 #: ../en/ch10-template.xml:590
12446 msgid ""
12447 "Neither will it work in the (extremely rare) case where a repository is a "
12448 "merge of two or more formerly independent repositories, and you still have "
12449 "those repositories around."
12450 msgstr ""
12452 #. type: Content of: <book><chapter><sect1><sect2><para>
12453 #: ../en/ch10-template.xml:595
12454 msgid "Here are some uses to which you could put this identifier:"
12455 msgstr ""
12457 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12458 #: ../en/ch10-template.xml:598
12459 msgid ""
12460 "As a key into a table for a database that manages repositories on a server."
12461 msgstr ""
12463 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12464 #: ../en/ch10-template.xml:601
12465 msgid ""
12466 "As half of a {<emphasis>repository ID</emphasis>, <emphasis>revision ID</"
12467 "emphasis>} tuple. Save this information away when you run an automated build "
12468 "or other activity, so that you can <quote>replay</quote> the build later if "
12469 "necessary."
12470 msgstr ""
12472 #. type: Content of: <book><chapter><sect1><sect2><title>
12473 #: ../en/ch10-template.xml:610
12474 msgid "Mimicking Subversion's output"
12475 msgstr "模仿 Subversion 的输出"
12478 #. type: Content of: <book><chapter><sect1><sect2><para>
12479 #: ../en/ch10-template.xml:612
12480 msgid ""
12481 "Let's try to emulate the default output format used by another revision "
12482 "control tool, Subversion."
12483 msgstr ""
12486 #. type: Content of: <book><chapter><sect1><sect2><para>
12487 #: ../en/ch10-template.xml:617
12488 msgid ""
12489 "Since Subversion's output style is fairly simple, it is easy to copy-and-"
12490 "paste a hunk of its output into a file, and replace the text produced above "
12491 "by Subversion with the template values we'd like to see expanded."
12492 msgstr ""
12494 #. type: Content of: <book><chapter><sect1><sect2><para>
12495 #: ../en/ch10-template.xml:624
12496 msgid ""
12497 "There are a few small ways in which this template deviates from the output "
12498 "produced by Subversion."
12499 msgstr ""
12501 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12502 #: ../en/ch10-template.xml:627
12503 msgid ""
12504 "Subversion prints a <quote>readable</quote> date (the <quote><literal>Wed, 27 "
12505 "Sep 2006</literal></quote> in the example output above) in parentheses. "
12506 "Mercurial's templating engine does not provide a way to display a date in "
12507 "this format without also printing the time and time zone."
12508 msgstr ""
12510 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12511 #: ../en/ch10-template.xml:634
12512 msgid ""
12513 "We emulate Subversion's printing of <quote>separator</quote> lines full of "
12514 "<quote><literal>-</literal></quote> characters by ending the template with "
12515 "such a line. We use the templating engine's <literal role=\"template-keyword"
12516 "\">header</literal> keyword to print a separator line as the first line of "
12517 "output (see below), thus achieving similar output to Subversion."
12518 msgstr ""
12520 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12521 #: ../en/ch10-template.xml:643
12522 msgid ""
12523 "Subversion's output includes a count in the header of the number of lines in "
12524 "the commit message. We cannot replicate this in Mercurial; the templating "
12525 "engine does not currently provide a filter that counts the number of lines "
12526 "the template generates."
12527 msgstr ""
12530 #. type: Content of: <book><chapter><sect1><sect2><para>
12531 #: ../en/ch10-template.xml:649
12532 msgid ""
12533 "It took me no more than a minute or two of work to replace literal text from "
12534 "an example of Subversion's output with some keywords and filters to give the "
12535 "template above. The style file simply refers to the template."
12536 msgstr ""
12538 #. type: Content of: <book><chapter><sect1><sect2><para>
12539 #: ../en/ch10-template.xml:656
12540 msgid ""
12541 "We could have included the text of the template file directly in the style "
12542 "file by enclosing it in quotes and replacing the newlines with "
12543 "<quote><literal>\\n</literal></quote> sequences, but it would have made the "
12544 "style file too difficult to read. Readability is a good guide when you're "
12545 "trying to decide whether some text belongs in a style file, or in a template "
12546 "file that the style file points to. If the style file will look too big or "
12547 "cluttered if you insert a literal piece of text, drop it into a template "
12548 "instead."
12549 msgstr ""
12551 #. type: Content of: <book><chapter><title>
12552 #: ../en/ch11-mq.xml:5
12553 msgid "Managing change with Mercurial Queues"
12554 msgstr "使用 MQ 管理修改"
12556 #. type: Content of: <book><chapter><sect1><title>
12557 #: ../en/ch11-mq.xml:8
12558 msgid "The patch management problem"
12559 msgstr "补丁的管理问题"
12561 #. type: Content of: <book><chapter><sect1><para>
12562 #: ../en/ch11-mq.xml:10
12563 msgid ""
12564 "Here is a common scenario: you need to install a software package from "
12565 "source, but you find a bug that you must fix in the source before you can "
12566 "start using the package. You make your changes, forget about the package for "
12567 "a while, and a few months later you need to upgrade to a newer version of the "
12568 "package. If the newer version of the package still has the bug, you must "
12569 "extract your fix from the older source tree and apply it against the newer "
12570 "version. This is a tedious task, and it's easy to make mistakes."
12571 msgstr ""
12573 #. type: Content of: <book><chapter><sect1><para>
12574 #: ../en/ch11-mq.xml:20
12575 msgid ""
12576 "This is a simple case of the <quote>patch management</quote> problem. You "
12577 "have an <quote>upstream</quote> source tree that you can't change; you need "
12578 "to make some local changes on top of the upstream tree; and you'd like to be "
12579 "able to keep those changes separate, so that you can apply them to newer "
12580 "versions of the upstream source."
12581 msgstr ""
12583 #. type: Content of: <book><chapter><sect1><para>
12584 #: ../en/ch11-mq.xml:27
12585 msgid ""
12586 "The patch management problem arises in many situations. Probably the most "
12587 "visible is that a user of an open source software project will contribute a "
12588 "bug fix or new feature to the project's maintainers in the form of a patch."
12589 msgstr ""
12591 #. type: Content of: <book><chapter><sect1><para>
12592 #: ../en/ch11-mq.xml:32
12593 msgid ""
12594 "Distributors of operating systems that include open source software often "
12595 "need to make changes to the packages they distribute so that they will build "
12596 "properly in their environments."
12597 msgstr ""
12599 #. type: Content of: <book><chapter><sect1><para>
12600 #: ../en/ch11-mq.xml:37
12601 msgid ""
12602 "When you have few changes to maintain, it is easy to manage a single patch "
12603 "using the standard <command>diff</command> and <command>patch</command> "
12604 "programs (see section <xref linkend=\"sec.mq.patch\"/> for a discussion of "
12605 "these tools). Once the number of changes grows, it starts to make sense to "
12606 "maintain patches as discrete <quote>chunks of work,</quote> so that for "
12607 "example a single patch will contain only one bug fix (the patch might modify "
12608 "several files, but it's doing <quote>only one thing</quote>), and you may "
12609 "have a number of such patches for different bugs you need fixed and local "
12610 "changes you require. In this situation, if you submit a bug fix patch to the "
12611 "upstream maintainers of a package and they include your fix in a subsequent "
12612 "release, you can simply drop that single patch when you're updating to the "
12613 "newer release."
12614 msgstr ""
12616 #. type: Content of: <book><chapter><sect1><para>
12617 #: ../en/ch11-mq.xml:52
12618 msgid ""
12619 "Maintaining a single patch against an upstream tree is a little tedious and "
12620 "error-prone, but not difficult. However, the complexity of the problem grows "
12621 "rapidly as the number of patches you have to maintain increases. With more "
12622 "than a tiny number of patches in hand, understanding which ones you have "
12623 "applied and maintaining them moves from messy to overwhelming."
12624 msgstr ""
12626 #. type: Content of: <book><chapter><sect1><para>
12627 #: ../en/ch11-mq.xml:59
12628 msgid ""
12629 "Fortunately, Mercurial includes a powerful extension, Mercurial Queues (or "
12630 "simply <quote>MQ</quote>), that massively simplifies the patch management "
12631 "problem."
12632 msgstr ""
12634 #. type: Content of: <book><chapter><sect1><title>
12635 #: ../en/ch11-mq.xml:65
12636 msgid "The prehistory of Mercurial Queues"
12637 msgstr "MQ 的历史"
12639 #. type: Content of: <book><chapter><sect1><para>
12640 #: ../en/ch11-mq.xml:67
12641 msgid ""
12642 "During the late 1990s, several Linux kernel developers started to maintain "
12643 "<quote>patch series</quote> that modified the behaviour of the Linux kernel. "
12644 "Some of these series were focused on stability, some on feature coverage, and "
12645 "others were more speculative."
12646 msgstr ""
12648 #. type: Content of: <book><chapter><sect1><para>
12649 #: ../en/ch11-mq.xml:73
12650 msgid ""
12651 "The sizes of these patch series grew rapidly. In 2002, Andrew Morton "
12652 "published some shell scripts he had been using to automate the task of "
12653 "managing his patch queues. Andrew was successfully using these scripts to "
12654 "manage hundreds (sometimes thousands) of patches on top of the Linux kernel."
12655 msgstr ""
12657 #. type: Content of: <book><chapter><sect1><sect2><title>
12658 #: ../en/ch11-mq.xml:80
12659 msgid "A patchwork quilt"
12660 msgstr ""
12662 #. type: Content of: <book><chapter><sect1><sect2><para>
12663 #: ../en/ch11-mq.xml:82
12664 msgid ""
12665 "In early 2003, Andreas Gruenbacher and Martin Quinson borrowed the approach "
12666 "of Andrew's scripts and published a tool called <quote>patchwork quilt</"
12667 "quote> <citation>web:quilt</citation>, or simply <quote>quilt</quote> (see "
12668 "<citation>gruenbacher:2005</citation> for a paper describing it). Because "
12669 "quilt substantially automated patch management, it rapidly gained a large "
12670 "following among open source software developers."
12671 msgstr ""
12673 #. type: Content of: <book><chapter><sect1><sect2><para>
12674 #: ../en/ch11-mq.xml:91
12675 msgid ""
12676 "Quilt manages a <emphasis>stack of patches</emphasis> on top of a directory "
12677 "tree. To begin, you tell quilt to manage a directory tree, and tell it which "
12678 "files you want to manage; it stores away the names and contents of those "
12679 "files. To fix a bug, you create a new patch (using a single command), edit "
12680 "the files you need to fix, then <quote>refresh</quote> the patch."
12681 msgstr ""
12683 #. type: Content of: <book><chapter><sect1><sect2><para>
12684 #: ../en/ch11-mq.xml:99
12685 msgid ""
12686 "The refresh step causes quilt to scan the directory tree; it updates the "
12687 "patch with all of the changes you have made. You can create another patch on "
12688 "top of the first, which will track the changes required to modify the tree "
12689 "from <quote>tree with one patch applied</quote> to <quote>tree with two "
12690 "patches applied</quote>."
12691 msgstr ""
12693 #. type: Content of: <book><chapter><sect1><sect2><para>
12694 #: ../en/ch11-mq.xml:106
12695 msgid ""
12696 "You can <emphasis>change</emphasis> which patches are applied to the tree. "
12697 "If you <quote>pop</quote> a patch, the changes made by that patch will vanish "
12698 "from the directory tree. Quilt remembers which patches you have popped, "
12699 "though, so you can <quote>push</quote> a popped patch again, and the "
12700 "directory tree will be restored to contain the modifications in the patch. "
12701 "Most importantly, you can run the <quote>refresh</quote> command at any time, "
12702 "and the topmost applied patch will be updated. This means that you can, at "
12703 "any time, change both which patches are applied and what modifications those "
12704 "patches make."
12705 msgstr ""
12707 #. type: Content of: <book><chapter><sect1><sect2><para>
12708 #: ../en/ch11-mq.xml:118
12709 msgid ""
12710 "Quilt knows nothing about revision control tools, so it works equally well on "
12711 "top of an unpacked tarball or a Subversion working copy."
12712 msgstr ""
12714 #. type: Content of: <book><chapter><sect1><sect2><title>
12715 #: ../en/ch11-mq.xml:124
12716 msgid "From patchwork quilt to Mercurial Queues"
12717 msgstr "从 patchwork quilt 到 MQ"
12719 #. type: Content of: <book><chapter><sect1><sect2><para>
12720 #: ../en/ch11-mq.xml:126
12721 msgid ""
12722 "In mid-2005, Chris Mason took the features of quilt and wrote an extension "
12723 "that he called Mercurial Queues, which added quilt-like behaviour to "
12724 "Mercurial."
12725 msgstr ""
12727 #. type: Content of: <book><chapter><sect1><sect2><para>
12728 #: ../en/ch11-mq.xml:130
12729 msgid ""
12730 "The key difference between quilt and MQ is that quilt knows nothing about "
12731 "revision control systems, while MQ is <emphasis>integrated</emphasis> into "
12732 "Mercurial. Each patch that you push is represented as a Mercurial "
12733 "changeset. Pop a patch, and the changeset goes away."
12734 msgstr ""
12736 #. type: Content of: <book><chapter><sect1><sect2><para>
12737 #: ../en/ch11-mq.xml:136
12738 msgid ""
12739 "Because quilt does not care about revision control tools, it is still a "
12740 "tremendously useful piece of software to know about for situations where you "
12741 "cannot use Mercurial and MQ."
12742 msgstr ""
12744 #. type: Content of: <book><chapter><sect1><title>
12745 #: ../en/ch11-mq.xml:144
12746 msgid "The huge advantage of MQ"
12747 msgstr "MQ 的巨大优势"
12749 #. type: Content of: <book><chapter><sect1><para>
12750 #: ../en/ch11-mq.xml:146
12751 msgid ""
12752 "I cannot overstate the value that MQ offers through the unification of "
12753 "patches and revision control."
12754 msgstr ""
12756 #. type: Content of: <book><chapter><sect1><para>
12757 #: ../en/ch11-mq.xml:149
12758 msgid ""
12759 "A major reason that patches have persisted in the free software and open "
12760 "source world&emdash;in spite of the availability of increasingly capable "
12761 "revision control tools over the years&emdash;is the <emphasis>agility</"
12762 "emphasis> they offer."
12763 msgstr ""
12765 #. type: Content of: <book><chapter><sect1><para>
12766 #: ../en/ch11-mq.xml:155
12767 msgid ""
12768 "Traditional revision control tools make a permanent, irreversible record of "
12769 "everything that you do. While this has great value, it's also somewhat "
12770 "stifling. If you want to perform a wild-eyed experiment, you have to be "
12771 "careful in how you go about it, or you risk leaving unneeded&emdash;or worse, "
12772 "misleading or destabilising&emdash;traces of your missteps and errors in the "
12773 "permanent revision record."
12774 msgstr ""
12776 #. type: Content of: <book><chapter><sect1><para>
12777 #: ../en/ch11-mq.xml:163
12778 msgid ""
12779 "By contrast, MQ's marriage of distributed revision control with patches makes "
12780 "it much easier to isolate your work. Your patches live on top of normal "
12781 "revision history, and you can make them disappear or reappear at will. If "
12782 "you don't like a patch, you can drop it. If a patch isn't quite as you want "
12783 "it to be, simply fix it&emdash;as many times as you need to, until you have "
12784 "refined it into the form you desire."
12785 msgstr ""
12787 #. type: Content of: <book><chapter><sect1><para>
12788 #: ../en/ch11-mq.xml:171
12789 msgid ""
12790 "As an example, the integration of patches with revision control makes "
12791 "understanding patches and debugging their effects&emdash;and their interplay "
12792 "with the code they're based on&emdash;<emphasis>enormously</emphasis> easier. "
12793 "Since every applied patch has an associated changeset, you can give <command "
12794 "role=\"hg-cmd\">hg log</command> a file name to see which changesets and "
12795 "patches affected the file. You can use the <command role=\"hg-cmd\">hg "
12796 "bisect</command> command to binary-search through all changesets and applied "
12797 "patches to see where a bug got introduced or fixed. You can use the <command "
12798 "role=\"hg-cmd\">hg annotate</command> command to see which changeset or patch "
12799 "modified a particular line of a source file. And so on."
12800 msgstr ""
12802 #. type: Content of: <book><chapter><sect1><title>
12803 #: ../en/ch11-mq.xml:187
12804 msgid "Understanding patches"
12805 msgstr "理解补丁"
12807 #. type: Content of: <book><chapter><sect1><para>
12808 #: ../en/ch11-mq.xml:189
12809 msgid ""
12810 "Because MQ doesn't hide its patch-oriented nature, it is helpful to "
12811 "understand what patches are, and a little about the tools that work with them."
12812 msgstr ""
12814 #. type: Content of: <book><chapter><sect1><para>
12815 #: ../en/ch11-mq.xml:193
12816 msgid ""
12817 "The traditional Unix <command>diff</command> command compares two files, and "
12818 "prints a list of differences between them. The <command>patch</command> "
12819 "command understands these differences as <emphasis>modifications</emphasis> "
12820 "to make to a file. Take a look below for a simple example of these commands "
12821 "in action."
12822 msgstr ""
12824 #. type: Content of: <book><chapter><sect1><para>
12825 #: ../en/ch11-mq.xml:202
12826 msgid ""
12827 "The type of file that <command>diff</command> generates (and <command>patch</"
12828 "command> takes as input) is called a <quote>patch</quote> or a <quote>diff</"
12829 "quote>; there is no difference between a patch and a diff. (We'll use the "
12830 "term <quote>patch</quote>, since it's more commonly used.)"
12831 msgstr ""
12833 #. type: Content of: <book><chapter><sect1><para>
12834 #: ../en/ch11-mq.xml:208
12835 msgid ""
12836 "A patch file can start with arbitrary text; the <command>patch</command> "
12837 "command ignores this text, but MQ uses it as the commit message when creating "
12838 "changesets. To find the beginning of the patch content, <command>patch</"
12839 "command> searches for the first line that starts with the string "
12840 "<quote><literal>diff -</literal></quote>."
12841 msgstr ""
12843 #. type: Content of: <book><chapter><sect1><para>
12844 #: ../en/ch11-mq.xml:215
12845 msgid ""
12846 "MQ works with <emphasis>unified</emphasis> diffs (<command>patch</command> "
12847 "can accept several other diff formats, but MQ doesn't). A unified diff "
12848 "contains two kinds of header. The <emphasis>file header</emphasis> describes "
12849 "the file being modified; it contains the name of the file to modify. When "
12850 "<command>patch</command> sees a new file header, it looks for a file with "
12851 "that name to start modifying."
12852 msgstr ""
12854 #. type: Content of: <book><chapter><sect1><para>
12855 #: ../en/ch11-mq.xml:223
12856 msgid ""
12857 "After the file header comes a series of <emphasis>hunks</emphasis>. Each "
12858 "hunk starts with a header; this identifies the range of line numbers within "
12859 "the file that the hunk should modify. Following the header, a hunk starts "
12860 "and ends with a few (usually three) lines of text from the unmodified file; "
12861 "these are called the <emphasis>context</emphasis> for the hunk. If there's "
12862 "only a small amount of context between successive hunks, <command>diff</"
12863 "command> doesn't print a new hunk header; it just runs the hunks together, "
12864 "with a few lines of context between modifications."
12865 msgstr ""
12867 #. type: Content of: <book><chapter><sect1><para>
12868 #: ../en/ch11-mq.xml:235
12869 msgid ""
12870 "Each line of context begins with a space character. Within the hunk, a line "
12871 "that begins with <quote><literal>-</literal></quote> means <quote>remove this "
12872 "line,</quote> while a line that begins with <quote><literal>+</literal></"
12873 "quote> means <quote>insert this line.</quote> For example, a line that is "
12874 "modified is represented by one deletion and one insertion."
12875 msgstr ""
12877 #. type: Content of: <book><chapter><sect1><para>
12878 #: ../en/ch11-mq.xml:243
12879 msgid ""
12880 "We will return to some of the more subtle aspects of patches later (in "
12881 "section <xref linkend=\"sec.mq.adv-patch\"/>), but you should have enough "
12882 "information now to use MQ."
12883 msgstr ""
12885 #. type: Content of: <book><chapter><sect1><title>
12886 #: ../en/ch11-mq.xml:250
12887 msgid "Getting started with Mercurial Queues"
12888 msgstr "开始使用 MQ"
12890 #. type: Content of: <book><chapter><sect1><para>
12891 #: ../en/ch11-mq.xml:252
12892 msgid ""
12893 "Because MQ is implemented as an extension, you must explicitly enable before "
12894 "you can use it. (You don't need to download anything; MQ ships with the "
12895 "standard Mercurial distribution.) To enable MQ, edit your <filename role="
12896 "\"home\">~/.hgrc</filename> file, and add the lines below."
12897 msgstr ""
12899 #. type: Content of: <book><chapter><sect1><para>
12900 #: ../en/ch11-mq.xml:262
12901 msgid ""
12902 "Once the extension is enabled, it will make a number of new commands "
12903 "available. To verify that the extension is working, you can use <command "
12904 "role=\"hg-cmd\">hg help</command> to see if the <command role=\"hg-ext-mq"
12905 "\">qinit</command> command is now available."
12906 msgstr ""
12908 #. type: Content of: <book><chapter><sect1><para>
12909 #: ../en/ch11-mq.xml:270
12910 msgid ""
12911 "You can use MQ with <emphasis>any</emphasis> Mercurial repository, and its "
12912 "commands only operate within that repository. To get started, simply prepare "
12913 "the repository using the <command role=\"hg-ext-mq\">qinit</command> command."
12914 msgstr ""
12916 #. type: Content of: <book><chapter><sect1><para>
12917 #: ../en/ch11-mq.xml:277
12918 msgid ""
12919 "This command creates an empty directory called <filename role=\"special\" "
12920 "class=\"directory\">.hg/patches</filename>, where MQ will keep its metadata. "
12921 "As with many Mercurial commands, the <command role=\"hg-ext-mq\">qinit</"
12922 "command> command prints nothing if it succeeds."
12923 msgstr ""
12925 #. type: Content of: <book><chapter><sect1><sect2><title>
12926 #: ../en/ch11-mq.xml:284
12927 msgid "Creating a new patch"
12928 msgstr "创建新补丁"
12930 #. type: Content of: <book><chapter><sect1><sect2><para>
12931 #: ../en/ch11-mq.xml:286
12932 msgid ""
12933 "To begin work on a new patch, use the <command role=\"hg-ext-mq\">qnew</"
12934 "command> command. This command takes one argument, the name of the patch to "
12935 "create."
12936 msgstr ""
12938 #. type: Content of: <book><chapter><sect1><sect2><para>
12939 #: ../en/ch11-mq.xml:290
12940 msgid ""
12941 "MQ will use this as the name of an actual file in the <filename role=\"special"
12942 "\" class=\"directory\">.hg/patches</filename> directory, as you can see below."
12943 msgstr ""
12945 #. type: Content of: <book><chapter><sect1><sect2><para>
12946 #: ../en/ch11-mq.xml:297
12947 msgid ""
12948 "Also newly present in the <filename role=\"special\" class=\"directory\">.hg/"
12949 "patches</filename> directory are two other files, <filename role=\"special"
12950 "\">series</filename> and <filename role=\"special\">status</filename>. The "
12951 "<filename role=\"special\">series</filename> file lists all of the patches "
12952 "that MQ knows about for this repository, with one patch per line. Mercurial "
12953 "uses the <filename role=\"special\">status</filename> file for internal book-"
12954 "keeping; it tracks all of the patches that MQ has <emphasis>applied</"
12955 "emphasis> in this repository."
12956 msgstr ""
12958 #. type: Content of: <book><chapter><sect1><sect2><note><para>
12959 #: ../en/ch11-mq.xml:309
12960 msgid ""
12961 "You may sometimes want to edit the <filename role=\"special\">series</"
12962 "filename> file by hand; for example, to change the sequence in which some "
12963 "patches are applied. However, manually editing the <filename role=\"special"
12964 "\">status</filename> file is almost always a bad idea, as it's easy to "
12965 "corrupt MQ's idea of what is happening."
12966 msgstr ""
12968 #. type: Content of: <book><chapter><sect1><sect2><para>
12969 #: ../en/ch11-mq.xml:318
12970 msgid ""
12971 "Once you have created your new patch, you can edit files in the working "
12972 "directory as you usually would. All of the normal Mercurial commands, such "
12973 "as <command role=\"hg-cmd\">hg diff</command> and <command role=\"hg-cmd\">hg "
12974 "annotate</command>, work exactly as they did before."
12975 msgstr ""
12977 #. type: Content of: <book><chapter><sect1><sect2><title>
12978 #: ../en/ch11-mq.xml:326
12979 msgid "Refreshing a patch"
12980 msgstr "刷新补丁"
12982 #. type: Content of: <book><chapter><sect1><sect2><para>
12983 #: ../en/ch11-mq.xml:328
12984 msgid ""
12985 "When you reach a point where you want to save your work, use the <command "
12986 "role=\"hg-ext-mq\">qrefresh</command> command to update the patch you are "
12987 "working on."
12988 msgstr ""
12990 #. type: Content of: <book><chapter><sect1><sect2><para>
12991 #: ../en/ch11-mq.xml:334
12992 msgid ""
12993 "This command folds the changes you have made in the working directory into "
12994 "your patch, and updates its corresponding changeset to contain those changes."
12995 msgstr ""
12997 #. type: Content of: <book><chapter><sect1><sect2><para>
12998 #: ../en/ch11-mq.xml:338
12999 msgid ""
13000 "You can run <command role=\"hg-ext-mq\">qrefresh</command> as often as you "
13001 "like, so it's a good way to <quote>checkpoint</quote> your work. Refresh "
13002 "your patch at an opportune time; try an experiment; and if the experiment "
13003 "doesn't work out, <command role=\"hg-cmd\">hg revert</command> your "
13004 "modifications back to the last time you refreshed."
13005 msgstr ""
13007 #. type: Content of: <book><chapter><sect1><sect2><title>
13008 #: ../en/ch11-mq.xml:349
13009 msgid "Stacking and tracking patches"
13010 msgstr "堆叠和跟踪补丁"
13012 #. type: Content of: <book><chapter><sect1><sect2><para>
13013 #: ../en/ch11-mq.xml:351
13014 msgid ""
13015 "Once you have finished working on a patch, or need to work on another, you "
13016 "can use the <command role=\"hg-ext-mq\">qnew</command> command again to "
13017 "create a new patch. Mercurial will apply this patch on top of your existing "
13018 "patch."
13019 msgstr ""
13021 #. type: Content of: <book><chapter><sect1><sect2><para>
13022 #: ../en/ch11-mq.xml:358
13023 msgid ""
13024 "Notice that the patch contains the changes in our prior patch as part of its "
13025 "context (you can see this more clearly in the output of <command role=\"hg-cmd"
13026 "\">hg annotate</command>)."
13027 msgstr ""
13029 #. type: Content of: <book><chapter><sect1><sect2><para>
13030 #: ../en/ch11-mq.xml:363
13031 msgid ""
13032 "So far, with the exception of <command role=\"hg-ext-mq\">qnew</command> and "
13033 "<command role=\"hg-ext-mq\">qrefresh</command>, we've been careful to only "
13034 "use regular Mercurial commands. However, MQ provides many commands that are "
13035 "easier to use when you are thinking about patches, as illustrated below."
13036 msgstr ""
13038 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13039 #: ../en/ch11-mq.xml:373
13040 msgid ""
13041 "The <command role=\"hg-ext-mq\">qseries</command> command lists every patch "
13042 "that MQ knows about in this repository, from oldest to newest (most recently "
13043 "<emphasis>created</emphasis>)."
13044 msgstr ""
13046 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13047 #: ../en/ch11-mq.xml:379
13048 msgid ""
13049 "The <command role=\"hg-ext-mq\">qapplied</command> command lists every patch "
13050 "that MQ has <emphasis>applied</emphasis> in this repository, again from "
13051 "oldest to newest (most recently applied)."
13052 msgstr ""
13054 #. type: Content of: <book><chapter><sect1><sect2><title>
13055 #: ../en/ch11-mq.xml:388
13056 msgid "Manipulating the patch stack"
13057 msgstr "操作补丁堆栈"
13059 #. type: Content of: <book><chapter><sect1><sect2><para>
13060 #: ../en/ch11-mq.xml:390
13061 msgid ""
13062 "The previous discussion implied that there must be a difference between "
13063 "<quote>known</quote> and <quote>applied</quote> patches, and there is. MQ "
13064 "can manage a patch without it being applied in the repository."
13065 msgstr ""
13067 #. type: Content of: <book><chapter><sect1><sect2><para>
13068 #: ../en/ch11-mq.xml:395
13069 msgid ""
13070 "An <emphasis>applied</emphasis> patch has a corresponding changeset in the "
13071 "repository, and the effects of the patch and changeset are visible in the "
13072 "working directory. You can undo the application of a patch using the "
13073 "<command role=\"hg-ext-mq\">qpop</command> command. MQ still <emphasis>knows "
13074 "about</emphasis>, or manages, a popped patch, but the patch no longer has a "
13075 "corresponding changeset in the repository, and the working directory does not "
13076 "contain the changes made by the patch. Figure <xref endterm=\"fig.mq.stack."
13077 "caption\" linkend=\"fig.mq.stack\"/> illustrates the difference between "
13078 "applied and tracked patches."
13079 msgstr ""
13081 #. type: Content of: <book><chapter><sect1><sect2><informalfigure><mediaobject>
13082 #: ../en/ch11-mq.xml:409
13083 msgid "<imageobject><imagedata fileref=\"images/mq-stack.png\"/></imageobject>"
13084 msgstr ""
13086 #. type: Content of: <book><chapter><sect1><sect2><informalfigure><mediaobject><caption><para>
13087 #: ../en/ch11-mq.xml:411
13088 msgid "Applied and unapplied patches in the MQ patch stack"
13089 msgstr ""
13091 #. type: Content of: <book><chapter><sect1><sect2><para>
13092 #: ../en/ch11-mq.xml:416
13093 msgid ""
13094 "You can reapply an unapplied, or popped, patch using the <command role=\"hg-"
13095 "ext-mq\">qpush</command> command. This creates a new changeset to correspond "
13096 "to the patch, and the patch's changes once again become present in the "
13097 "working directory. See below for examples of <command role=\"hg-ext-mq"
13098 "\">qpop</command> and <command role=\"hg-ext-mq\">qpush</command> in action."
13099 msgstr ""
13101 #. type: Content of: <book><chapter><sect1><sect2><para>
13102 #: ../en/ch11-mq.xml:425
13103 msgid ""
13104 "Notice that once we have popped a patch or two patches, the output of "
13105 "<command role=\"hg-ext-mq\">qseries</command> remains the same, while that of "
13106 "<command role=\"hg-ext-mq\">qapplied</command> has changed."
13107 msgstr ""
13109 #. type: Content of: <book><chapter><sect1><sect2><title>
13110 #: ../en/ch11-mq.xml:433
13111 msgid "Pushing and popping many patches"
13112 msgstr "压入或弹出多个补丁"
13114 #. type: Content of: <book><chapter><sect1><sect2><para>
13115 #: ../en/ch11-mq.xml:435
13116 msgid ""
13117 "While <command role=\"hg-ext-mq\">qpush</command> and <command role=\"hg-ext-"
13118 "mq\">qpop</command> each operate on a single patch at a time by default, you "
13119 "can push and pop many patches in one go. The <option role=\"hg-ext-mq-cmd-"
13120 "qpush-opt\">hg -a</option> option to <command role=\"hg-ext-mq\">qpush</"
13121 "command> causes it to push all unapplied patches, while the <option role=\"hg-"
13122 "ext-mq-cmd-qpop-opt\">-a</option> option to <command role=\"hg-ext-mq\">qpop</"
13123 "command> causes it to pop all applied patches. (For some more ways to push "
13124 "and pop many patches, see section <xref linkend=\"sec.mq.perf\"/> below.)"
13125 msgstr ""
13127 #. type: Content of: <book><chapter><sect1><sect2><title>
13128 #: ../en/ch11-mq.xml:452
13129 msgid "Safety checks, and overriding them"
13130 msgstr "安全的检查,然后覆盖它们"
13132 #. type: Content of: <book><chapter><sect1><sect2><para>
13133 #: ../en/ch11-mq.xml:454
13134 msgid ""
13135 "Several MQ commands check the working directory before they do anything, and "
13136 "fail if they find any modifications. They do this to ensure that you won't "
13137 "lose any changes that you have made, but not yet incorporated into a patch. "
13138 "The example below illustrates this; the <command role=\"hg-ext-mq\">qnew</"
13139 "command> command will not create a new patch if there are outstanding "
13140 "changes, caused in this case by the <command role=\"hg-cmd\">hg add</command> "
13141 "of <filename>file3</filename>."
13142 msgstr ""
13144 #. type: Content of: <book><chapter><sect1><sect2><para>
13145 #: ../en/ch11-mq.xml:466
13146 msgid ""
13147 "Commands that check the working directory all take an <quote>I know what I'm "
13148 "doing</quote> option, which is always named <option>-f</option>. The exact "
13149 "meaning of <option>-f</option> depends on the command. For example, <command "
13150 "role=\"hg-cmd\">hg qnew <option role=\"hg-ext-mq-cmd-qnew-opt\">hg -f</"
13151 "option></command> will incorporate any outstanding changes into the new patch "
13152 "it creates, but <command role=\"hg-cmd\">hg qpop <option role=\"hg-ext-mq-cmd-"
13153 "qpop-opt\">hg -f</option></command> will revert modifications to any files "
13154 "affected by the patch that it is popping. Be sure to read the documentation "
13155 "for a command's <option>-f</option> option before you use it!"
13156 msgstr ""
13158 #. type: Content of: <book><chapter><sect1><sect2><title>
13159 #: ../en/ch11-mq.xml:481
13160 msgid "Working on several patches at once"
13161 msgstr "同时处理多个补丁"
13163 #. type: Content of: <book><chapter><sect1><sect2><para>
13164 #: ../en/ch11-mq.xml:483
13165 msgid ""
13166 "The <command role=\"hg-ext-mq\">qrefresh</command> command always refreshes "
13167 "the <emphasis>topmost</emphasis> applied patch. This means that you can "
13168 "suspend work on one patch (by refreshing it), pop or push to make a different "
13169 "patch the top, and work on <emphasis>that</emphasis> patch for a while."
13170 msgstr ""
13172 #. type: Content of: <book><chapter><sect1><sect2><para>
13173 #: ../en/ch11-mq.xml:490
13174 msgid ""
13175 "Here's an example that illustrates how you can use this ability. Let's say "
13176 "you're developing a new feature as two patches. The first is a change to the "
13177 "core of your software, and the second&emdash;layered on top of the "
13178 "first&emdash;changes the user interface to use the code you just added to the "
13179 "core. If you notice a bug in the core while you're working on the UI patch, "
13180 "it's easy to fix the core. Simply <command role=\"hg-ext-mq\">qrefresh</"
13181 "command> the UI patch to save your in-progress changes, and <command role="
13182 "\"hg-ext-mq\">qpop</command> down to the core patch. Fix the core bug, "
13183 "<command role=\"hg-ext-mq\">qrefresh</command> the core patch, and <command "
13184 "role=\"hg-ext-mq\">qpush</command> back to the UI patch to continue where you "
13185 "left off."
13186 msgstr ""
13188 #. type: Content of: <book><chapter><sect1><title>
13189 #: ../en/ch11-mq.xml:507
13190 msgid "More about patches"
13191 msgstr "关于补丁的更多信息"
13193 #. type: Content of: <book><chapter><sect1><para>
13194 #: ../en/ch11-mq.xml:509
13195 msgid ""
13196 "MQ uses the GNU <command>patch</command> command to apply patches, so it's "
13197 "helpful to know a few more detailed aspects of how <command>patch</command> "
13198 "works, and about patches themselves."
13199 msgstr ""
13201 #. type: Content of: <book><chapter><sect1><sect2><title>
13202 #: ../en/ch11-mq.xml:515
13203 msgid "The strip count"
13204 msgstr "修剪计数"
13206 #. type: Content of: <book><chapter><sect1><sect2><para>
13207 #: ../en/ch11-mq.xml:517
13208 msgid ""
13209 "If you look at the file headers in a patch, you will notice that the "
13210 "pathnames usually have an extra component on the front that isn't present in "
13211 "the actual path name. This is a holdover from the way that people used to "
13212 "generate patches (people still do this, but it's somewhat rare with modern "
13213 "revision control tools)."
13214 msgstr ""
13216 #. type: Content of: <book><chapter><sect1><sect2><para>
13217 #: ../en/ch11-mq.xml:524
13218 msgid ""
13219 "Alice would unpack a tarball, edit her files, then decide that she wanted to "
13220 "create a patch. So she'd rename her working directory, unpack the tarball "
13221 "again (hence the need for the rename), and use the <option role=\"cmd-opt-diff"
13222 "\">-r</option> and <option role=\"cmd-opt-diff\">-N</option> options to "
13223 "<command>diff</command> to recursively generate a patch between the "
13224 "unmodified directory and the modified one. The result would be that the name "
13225 "of the unmodified directory would be at the front of the left-hand path in "
13226 "every file header, and the name of the modified directory would be at the "
13227 "front of the right-hand path."
13228 msgstr ""
13230 #. type: Content of: <book><chapter><sect1><sect2><para>
13231 #: ../en/ch11-mq.xml:537
13232 msgid ""
13233 "Since someone receiving a patch from the Alices of the net would be unlikely "
13234 "to have unmodified and modified directories with exactly the same names, the "
13235 "<command>patch</command> command has a <option role=\"cmd-opt-patch\">-p</"
13236 "option> option that indicates the number of leading path name components to "
13237 "strip when trying to apply a patch. This number is called the "
13238 "<emphasis>strip count</emphasis>."
13239 msgstr ""
13241 #. type: Content of: <book><chapter><sect1><sect2><para>
13242 #: ../en/ch11-mq.xml:545
13243 msgid ""
13244 "An option of <quote><literal>-p1</literal></quote> means <quote>use a strip "
13245 "count of one</quote>. If <command>patch</command> sees a file name "
13246 "<filename>foo/bar/baz</filename> in a file header, it will strip "
13247 "<filename>foo</filename> and try to patch a file named <filename>bar/baz</"
13248 "filename>. (Strictly speaking, the strip count refers to the number of "
13249 "<emphasis>path separators</emphasis> (and the components that go with them ) "
13250 "to strip. A strip count of one will turn <filename>foo/bar</filename> into "
13251 "<filename>bar</filename>, but <filename>/foo/bar</filename> (notice the extra "
13252 "leading slash) into <filename>foo/bar</filename>.)"
13253 msgstr ""
13255 #. type: Content of: <book><chapter><sect1><sect2><para>
13256 #: ../en/ch11-mq.xml:558
13257 msgid ""
13258 "The <quote>standard</quote> strip count for patches is one; almost all "
13259 "patches contain one leading path name component that needs to be stripped. "
13260 "Mercurial's <command role=\"hg-cmd\">hg diff</command> command generates path "
13261 "names in this form, and the <command role=\"hg-cmd\">hg import</command> "
13262 "command and MQ expect patches to have a strip count of one."
13263 msgstr ""
13265 #. type: Content of: <book><chapter><sect1><sect2><para>
13266 #: ../en/ch11-mq.xml:566
13267 msgid ""
13268 "If you receive a patch from someone that you want to add to your patch queue, "
13269 "and the patch needs a strip count other than one, you cannot just <command "
13270 "role=\"hg-ext-mq\">qimport</command> the patch, because <command role=\"hg-"
13271 "ext-mq\">qimport</command> does not yet have a <literal>-p</literal> option "
13272 "(see <ulink role=\"hg-bug\" url=\"http://www.selenic.com/mercurial/bts/"
13273 "issue311\">issue 311</ulink>). Your best bet is to <command role=\"hg-ext-mq"
13274 "\">qnew</command> a patch of your own, then use <command>patch -pN</command> "
13275 "to apply their patch, followed by <command role=\"hg-cmd\">hg addremove</"
13276 "command> to pick up any files added or removed by the patch, followed by "
13277 "<command role=\"hg-ext-mq\">hg qrefresh</command>. This complexity may become "
13278 "unnecessary; see <ulink role=\"hg-bug\" url=\"http://www.selenic.com/"
13279 "mercurial/bts/issue311\">issue 311</ulink> for details."
13280 msgstr ""
13282 #. type: Content of: <book><chapter><sect1><sect2><title>
13283 #: ../en/ch11-mq.xml:585
13284 msgid "Strategies for applying a patch"
13285 msgstr "应用补丁的策略"
13287 #. type: Content of: <book><chapter><sect1><sect2><para>
13288 #: ../en/ch11-mq.xml:587
13289 msgid ""
13290 "When <command>patch</command> applies a hunk, it tries a handful of "
13291 "successively less accurate strategies to try to make the hunk apply. This "
13292 "falling-back technique often makes it possible to take a patch that was "
13293 "generated against an old version of a file, and apply it against a newer "
13294 "version of that file."
13295 msgstr ""
13297 #. type: Content of: <book><chapter><sect1><sect2><para>
13298 #: ../en/ch11-mq.xml:594
13299 msgid ""
13300 "First, <command>patch</command> tries an exact match, where the line numbers, "
13301 "the context, and the text to be modified must apply exactly. If it cannot "
13302 "make an exact match, it tries to find an exact match for the context, without "
13303 "honouring the line numbering information. If this succeeds, it prints a line "
13304 "of output saying that the hunk was applied, but at some <emphasis>offset</"
13305 "emphasis> from the original line number."
13306 msgstr ""
13308 #. type: Content of: <book><chapter><sect1><sect2><para>
13309 #: ../en/ch11-mq.xml:603
13310 msgid ""
13311 "If a context-only match fails, <command>patch</command> removes the first and "
13312 "last lines of the context, and tries a <emphasis>reduced</emphasis> context-"
13313 "only match. If the hunk with reduced context succeeds, it prints a message "
13314 "saying that it applied the hunk with a <emphasis>fuzz factor</emphasis> (the "
13315 "number after the fuzz factor indicates how many lines of context "
13316 "<command>patch</command> had to trim before the patch applied)."
13317 msgstr ""
13319 #. type: Content of: <book><chapter><sect1><sect2><para>
13320 #: ../en/ch11-mq.xml:612
13321 msgid ""
13322 "When neither of these techniques works, <command>patch</command> prints a "
13323 "message saying that the hunk in question was rejected. It saves rejected "
13324 "hunks (also simply called <quote>rejects</quote>) to a file with the same "
13325 "name, and an added <filename role=\"special\">.rej</filename> extension. It "
13326 "also saves an unmodified copy of the file with a <filename role=\"special\">."
13327 "orig</filename> extension; the copy of the file without any extensions will "
13328 "contain any changes made by hunks that <emphasis>did</emphasis> apply "
13329 "cleanly. If you have a patch that modifies <filename>foo</filename> with six "
13330 "hunks, and one of them fails to apply, you will have: an unmodified "
13331 "<filename>foo.orig</filename>, a <filename>foo.rej</filename> containing one "
13332 "hunk, and <filename>foo</filename>, containing the changes made by the five "
13333 "successful hunks."
13334 msgstr ""
13336 #. type: Content of: <book><chapter><sect1><sect2><title>
13337 #: ../en/ch11-mq.xml:630
13338 msgid "Some quirks of patch representation"
13339 msgstr "补丁的一些特性"
13341 #. type: Content of: <book><chapter><sect1><sect2><para>
13342 #: ../en/ch11-mq.xml:632
13343 msgid ""
13344 "There are a few useful things to know about how <command>patch</command> "
13345 "works with files."
13346 msgstr ""
13348 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13349 #: ../en/ch11-mq.xml:635
13350 msgid ""
13351 "This should already be obvious, but <command>patch</command> cannot handle "
13352 "binary files."
13353 msgstr ""
13355 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13356 #: ../en/ch11-mq.xml:639
13357 msgid ""
13358 "Neither does it care about the executable bit; it creates new files as "
13359 "readable, but not executable."
13360 msgstr ""
13362 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13363 #: ../en/ch11-mq.xml:643
13364 msgid ""
13365 "<command>patch</command> treats the removal of a file as a diff between the "
13366 "file to be removed and the empty file. So your idea of <quote>I deleted this "
13367 "file</quote> looks like <quote>every line of this file was deleted</quote> in "
13368 "a patch."
13369 msgstr ""
13371 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13372 #: ../en/ch11-mq.xml:649
13373 msgid ""
13374 "It treats the addition of a file as a diff between the empty file and the "
13375 "file to be added. So in a patch, your idea of <quote>I added this file</"
13376 "quote> looks like <quote>every line of this file was added</quote>."
13377 msgstr ""
13379 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13380 #: ../en/ch11-mq.xml:655
13381 msgid ""
13382 "It treats a renamed file as the removal of the old name, and the addition of "
13383 "the new name. This means that renamed files have a big footprint in "
13384 "patches. (Note also that Mercurial does not currently try to infer when "
13385 "files have been renamed or copied in a patch.)"
13386 msgstr ""
13388 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13389 #: ../en/ch11-mq.xml:661
13390 msgid ""
13391 "<command>patch</command> cannot represent empty files, so you cannot use a "
13392 "patch to represent the notion <quote>I added this empty file to the tree</"
13393 "quote>."
13394 msgstr ""
13396 #. type: Content of: <book><chapter><sect1><sect2><title>
13397 #: ../en/ch11-mq.xml:668
13398 msgid "Beware the fuzz"
13399 msgstr "当心毛刺"
13401 #. type: Content of: <book><chapter><sect1><sect2><para>
13402 #: ../en/ch11-mq.xml:670
13403 msgid ""
13404 "While applying a hunk at an offset, or with a fuzz factor, will often be "
13405 "completely successful, these inexact techniques naturally leave open the "
13406 "possibility of corrupting the patched file. The most common cases typically "
13407 "involve applying a patch twice, or at an incorrect location in the file. If "
13408 "<command>patch</command> or <command role=\"hg-ext-mq\">qpush</command> ever "
13409 "mentions an offset or fuzz factor, you should make sure that the modified "
13410 "files are correct afterwards."
13411 msgstr ""
13413 #. type: Content of: <book><chapter><sect1><sect2><para>
13414 #: ../en/ch11-mq.xml:680
13415 msgid ""
13416 "It's often a good idea to refresh a patch that has applied with an offset or "
13417 "fuzz factor; refreshing the patch generates new context information that will "
13418 "make it apply cleanly. I say <quote>often,</quote> not <quote>always,</"
13419 "quote> because sometimes refreshing a patch will make it fail to apply "
13420 "against a different revision of the underlying files. In some cases, such as "
13421 "when you're maintaining a patch that must sit on top of multiple versions of "
13422 "a source tree, it's acceptable to have a patch apply with some fuzz, provided "
13423 "you've verified the results of the patching process in such cases."
13424 msgstr ""
13426 #. type: Content of: <book><chapter><sect1><sect2><title>
13427 #: ../en/ch11-mq.xml:693
13428 msgid "Handling rejection"
13429 msgstr "处理拒绝"
13431 #. type: Content of: <book><chapter><sect1><sect2><para>
13432 #: ../en/ch11-mq.xml:695
13433 msgid ""
13434 "If <command role=\"hg-ext-mq\">qpush</command> fails to apply a patch, it "
13435 "will print an error message and exit. If it has left <filename role=\"special"
13436 "\">.rej</filename> files behind, it is usually best to fix up the rejected "
13437 "hunks before you push more patches or do any further work."
13438 msgstr ""
13440 #. type: Content of: <book><chapter><sect1><sect2><para>
13441 #: ../en/ch11-mq.xml:701
13442 msgid ""
13443 "If your patch <emphasis>used to</emphasis> apply cleanly, and no longer does "
13444 "because you've changed the underlying code that your patches are based on, "
13445 "Mercurial Queues can help; see section <xref linkend=\"sec.mq.merge\"/> for "
13446 "details."
13447 msgstr ""
13449 #. type: Content of: <book><chapter><sect1><sect2><para>
13450 #: ../en/ch11-mq.xml:707
13451 msgid ""
13452 "Unfortunately, there aren't any great techniques for dealing with rejected "
13453 "hunks. Most often, you'll need to view the <filename role=\"special\">.rej</"
13454 "filename> file and edit the target file, applying the rejected hunks by hand."
13455 msgstr ""
13457 #. type: Content of: <book><chapter><sect1><sect2><para>
13458 #: ../en/ch11-mq.xml:712
13459 msgid ""
13460 "If you're feeling adventurous, Neil Brown, a Linux kernel hacker, wrote a "
13461 "tool called <command>wiggle</command> <citation>web:wiggle</citation>, which "
13462 "is more vigorous than <command>patch</command> in its attempts to make a "
13463 "patch apply."
13464 msgstr ""
13466 #. type: Content of: <book><chapter><sect1><sect2><para>
13467 #: ../en/ch11-mq.xml:718
13468 msgid ""
13469 "Another Linux kernel hacker, Chris Mason (the author of Mercurial Queues), "
13470 "wrote a similar tool called <command>mpatch</command> <citation>web:mpatch</"
13471 "citation>, which takes a simple approach to automating the application of "
13472 "hunks rejected by <command>patch</command>. The <command>mpatch</command> "
13473 "command can help with four common reasons that a hunk may be rejected:"
13474 msgstr ""
13476 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13477 #: ../en/ch11-mq.xml:727
13478 msgid "The context in the middle of a hunk has changed."
13479 msgstr ""
13481 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13482 #: ../en/ch11-mq.xml:730
13483 msgid "A hunk is missing some context at the beginning or end."
13484 msgstr ""
13486 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13487 #: ../en/ch11-mq.xml:733
13488 msgid ""
13489 "A large hunk might apply better&emdash;either entirely or in part&emdash;if "
13490 "it was broken up into smaller hunks."
13491 msgstr ""
13493 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13494 #: ../en/ch11-mq.xml:737
13495 msgid ""
13496 "A hunk removes lines with slightly different content than those currently "
13497 "present in the file."
13498 msgstr ""
13500 #. type: Content of: <book><chapter><sect1><sect2><para>
13501 #: ../en/ch11-mq.xml:741
13502 msgid ""
13503 "If you use <command>wiggle</command> or <command>mpatch</command>, you should "
13504 "be doubly careful to check your results when you're done. In fact, "
13505 "<command>mpatch</command> enforces this method of double-checking the tool's "
13506 "output, by automatically dropping you into a merge program when it has done "
13507 "its job, so that you can verify its work and finish off any remaining merges."
13508 msgstr ""
13510 #. type: Content of: <book><chapter><sect1><title>
13511 #: ../en/ch11-mq.xml:753
13512 msgid "Getting the best performance out of MQ"
13513 msgstr "MQ 的性能"
13515 #. type: Content of: <book><chapter><sect1><para>
13516 #: ../en/ch11-mq.xml:755
13517 msgid ""
13518 "MQ is very efficient at handling a large number of patches. I ran some "
13519 "performance experiments in mid-2006 for a talk that I gave at the 2006 "
13520 "EuroPython conference <citation>web:europython</citation>. I used as my data "
13521 "set the Linux 2.6.17-mm1 patch series, which consists of 1,738 patches. I "
13522 "applied these on top of a Linux kernel repository containing all 27,472 "
13523 "revisions between Linux 2.6.12-rc2 and Linux 2.6.17."
13524 msgstr ""
13526 #. type: Content of: <book><chapter><sect1><para>
13527 #: ../en/ch11-mq.xml:764
13528 msgid ""
13529 "On my old, slow laptop, I was able to <command role=\"hg-cmd\">hg qpush "
13530 "<option role=\"hg-ext-mq-cmd-qpush-opt\">hg -a</option></command> all 1,738 "
13531 "patches in 3.5 minutes, and <command role=\"hg-cmd\">hg qpop <option role="
13532 "\"hg-ext-mq-cmd-qpop-opt\">hg -a</option></command> them all in 30 seconds. "
13533 "(On a newer laptop, the time to push all patches dropped to two minutes.) I "
13534 "could <command role=\"hg-ext-mq\">qrefresh</command> one of the biggest "
13535 "patches (which made 22,779 lines of changes to 287 files) in 6.6 seconds."
13536 msgstr ""
13538 #. type: Content of: <book><chapter><sect1><para>
13539 #: ../en/ch11-mq.xml:775
13540 msgid ""
13541 "Clearly, MQ is well suited to working in large trees, but there are a few "
13542 "tricks you can use to get the best performance of it."
13543 msgstr ""
13545 #. type: Content of: <book><chapter><sect1><para>
13546 #: ../en/ch11-mq.xml:779
13547 msgid ""
13548 "First of all, try to <quote>batch</quote> operations together. Every time "
13549 "you run <command role=\"hg-ext-mq\">qpush</command> or <command role=\"hg-ext-"
13550 "mq\">qpop</command>, these commands scan the working directory once to make "
13551 "sure you haven't made some changes and then forgotten to run <command role="
13552 "\"hg-ext-mq\">qrefresh</command>. On a small tree, the time that this scan "
13553 "takes is unnoticeable. However, on a medium-sized tree (containing tens of "
13554 "thousands of files), it can take a second or more."
13555 msgstr ""
13557 #. type: Content of: <book><chapter><sect1><para>
13558 #: ../en/ch11-mq.xml:790
13559 msgid ""
13560 "The <command role=\"hg-ext-mq\">qpush</command> and <command role=\"hg-ext-mq"
13561 "\">qpop</command> commands allow you to push and pop multiple patches at a "
13562 "time. You can identify the <quote>destination patch</quote> that you want to "
13563 "end up at. When you <command role=\"hg-ext-mq\">qpush</command> with a "
13564 "destination specified, it will push patches until that patch is at the top of "
13565 "the applied stack. When you <command role=\"hg-ext-mq\">qpop</command> to a "
13566 "destination, MQ will pop patches until the destination patch is at the top."
13567 msgstr ""
13569 #. type: Content of: <book><chapter><sect1><para>
13570 #: ../en/ch11-mq.xml:800
13571 msgid ""
13572 "You can identify a destination patch using either the name of the patch, or "
13573 "by number. If you use numeric addressing, patches are counted from zero; "
13574 "this means that the first patch is zero, the second is one, and so on."
13575 msgstr ""
13577 #. type: Content of: <book><chapter><sect1><title>
13578 #: ../en/ch11-mq.xml:807
13579 msgid "Updating your patches when the underlying code changes"
13580 msgstr "当基础代码改变时,更新补丁的方法"
13582 #. type: Content of: <book><chapter><sect1><para>
13583 #: ../en/ch11-mq.xml:810
13584 msgid ""
13585 "It's common to have a stack of patches on top of an underlying repository "
13586 "that you don't modify directly. If you're working on changes to third-party "
13587 "code, or on a feature that is taking longer to develop than the rate of "
13588 "change of the code beneath, you will often need to sync up with the "
13589 "underlying code, and fix up any hunks in your patches that no longer apply. "
13590 "This is called <emphasis>rebasing</emphasis> your patch series."
13591 msgstr ""
13593 #. type: Content of: <book><chapter><sect1><para>
13594 #: ../en/ch11-mq.xml:819
13595 msgid ""
13596 "The simplest way to do this is to <command role=\"hg-cmd\">hg qpop <option "
13597 "role=\"hg-ext-mq-cmd-qpop-opt\">hg -a</option></command> your patches, then "
13598 "<command role=\"hg-cmd\">hg pull</command> changes into the underlying "
13599 "repository, and finally <command role=\"hg-cmd\">hg qpush <option role=\"hg-"
13600 "ext-mq-cmd-qpop-opt\">hg -a</option></command> your patches again. MQ will "
13601 "stop pushing any time it runs across a patch that fails to apply during "
13602 "conflicts, allowing you to fix your conflicts, <command role=\"hg-ext-mq"
13603 "\">qrefresh</command> the affected patch, and continue pushing until you have "
13604 "fixed your entire stack."
13605 msgstr ""
13607 #. type: Content of: <book><chapter><sect1><para>
13608 #: ../en/ch11-mq.xml:831
13609 msgid ""
13610 "This approach is easy to use and works well if you don't expect changes to "
13611 "the underlying code to affect how well your patches apply. If your patch "
13612 "stack touches code that is modified frequently or invasively in the "
13613 "underlying repository, however, fixing up rejected hunks by hand quickly "
13614 "becomes tiresome."
13615 msgstr ""
13617 #. type: Content of: <book><chapter><sect1><para>
13618 #: ../en/ch11-mq.xml:838
13619 msgid ""
13620 "It's possible to partially automate the rebasing process. If your patches "
13621 "apply cleanly against some revision of the underlying repo, MQ can use this "
13622 "information to help you to resolve conflicts between your patches and a "
13623 "different revision."
13624 msgstr ""
13626 #. type: Content of: <book><chapter><sect1><para>
13627 #: ../en/ch11-mq.xml:844
13628 msgid "The process is a little involved."
13629 msgstr ""
13631 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
13632 #: ../en/ch11-mq.xml:846
13633 msgid ""
13634 "To begin, <command role=\"hg-cmd\">hg qpush -a</command> all of your patches "
13635 "on top of the revision where you know that they apply cleanly."
13636 msgstr ""
13638 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
13639 #: ../en/ch11-mq.xml:850
13640 msgid ""
13641 "Save a backup copy of your patch directory using <command role=\"hg-cmd\">hg "
13642 "qsave <option role=\"hg-ext-mq-cmd-qsave-opt\">hg -e</option> <option role="
13643 "\"hg-ext-mq-cmd-qsave-opt\">hg -c</option></command>. This prints the name "
13644 "of the directory that it has saved the patches in. It will save the patches "
13645 "to a directory called <filename role=\"special\" class=\"directory\">.hg/"
13646 "patches.N</filename>, where <literal>N</literal> is a small integer. It also "
13647 "commits a <quote>save changeset</quote> on top of your applied patches; this "
13648 "is for internal book-keeping, and records the states of the <filename role="
13649 "\"special\">series</filename> and <filename role=\"special\">status</"
13650 "filename> files."
13651 msgstr ""
13653 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
13654 #: ../en/ch11-mq.xml:864
13655 msgid ""
13656 "Use <command role=\"hg-cmd\">hg pull</command> to bring new changes into the "
13657 "underlying repository. (Don't run <command role=\"hg-cmd\">hg pull -u</"
13658 "command>; see below for why.)"
13659 msgstr ""
13661 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
13662 #: ../en/ch11-mq.xml:869
13663 msgid ""
13664 "Update to the new tip revision, using <command role=\"hg-cmd\">hg update "
13665 "<option role=\"hg-opt-update\">-C</option></command> to override the patches "
13666 "you have pushed."
13667 msgstr ""
13669 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
13670 #: ../en/ch11-mq.xml:874
13671 msgid ""
13672 "Merge all patches using <command>hg qpush -m -a</command>. The <option role="
13673 "\"hg-ext-mq-cmd-qpush-opt\">-m</option> option to <command role=\"hg-ext-mq"
13674 "\">qpush</command> tells MQ to perform a three-way merge if the patch fails "
13675 "to apply."
13676 msgstr ""
13678 #. type: Content of: <book><chapter><sect1><para>
13679 #: ../en/ch11-mq.xml:882
13680 msgid ""
13681 "During the <command role=\"hg-cmd\">hg qpush <option role=\"hg-ext-mq-cmd-"
13682 "qpush-opt\">hg -m</option></command>, each patch in the <filename role="
13683 "\"special\">series</filename> file is applied normally. If a patch applies "
13684 "with fuzz or rejects, MQ looks at the queue you <command role=\"hg-ext-mq"
13685 "\">qsave</command>d, and performs a three-way merge with the corresponding "
13686 "changeset. This merge uses Mercurial's normal merge machinery, so it may pop "
13687 "up a GUI merge tool to help you to resolve problems."
13688 msgstr ""
13690 #. type: Content of: <book><chapter><sect1><para>
13691 #: ../en/ch11-mq.xml:892
13692 msgid ""
13693 "When you finish resolving the effects of a patch, MQ refreshes your patch "
13694 "based on the result of the merge."
13695 msgstr ""
13697 #. type: Content of: <book><chapter><sect1><para>
13698 #: ../en/ch11-mq.xml:895
13699 msgid ""
13700 "At the end of this process, your repository will have one extra head from the "
13701 "old patch queue, and a copy of the old patch queue will be in <filename role="
13702 "\"special\" class=\"directory\">.hg/patches.N</filename>. You can remove the "
13703 "extra head using <command role=\"hg-cmd\">hg qpop -a -n patches.N</command> "
13704 "or <command role=\"hg-cmd\">hg strip</command>. You can delete <filename "
13705 "role=\"special\" class=\"directory\">.hg/patches.N</filename> once you are "
13706 "sure that you no longer need it as a backup."
13707 msgstr ""
13709 #. type: Content of: <book><chapter><sect1><title>
13710 #: ../en/ch11-mq.xml:907
13711 msgid "Identifying patches"
13712 msgstr "标识补丁"
13714 #. type: Content of: <book><chapter><sect1><para>
13715 #: ../en/ch11-mq.xml:909
13716 msgid ""
13717 "MQ commands that work with patches let you refer to a patch either by using "
13718 "its name or by a number. By name is obvious enough; pass the name "
13719 "<filename>foo.patch</filename> to <command role=\"hg-ext-mq\">qpush</"
13720 "command>, for example, and it will push patches until <filename>foo.patch</"
13721 "filename> is applied."
13722 msgstr ""
13724 #. type: Content of: <book><chapter><sect1><para>
13725 #: ../en/ch11-mq.xml:916
13726 msgid ""
13727 "As a shortcut, you can refer to a patch using both a name and a numeric "
13728 "offset; <literal>foo.patch-2</literal> means <quote>two patches before "
13729 "<literal>foo.patch</literal></quote>, while <literal>bar.patch+4</literal> "
13730 "means <quote>four patches after <literal>bar.patch</literal></quote>."
13731 msgstr ""
13733 #. type: Content of: <book><chapter><sect1><para>
13734 #: ../en/ch11-mq.xml:922
13735 msgid ""
13736 "Referring to a patch by index isn't much different. The first patch printed "
13737 "in the output of <command role=\"hg-ext-mq\">qseries</command> is patch zero "
13738 "(yes, it's one of those start-at-zero counting systems); the second is patch "
13739 "one; and so on."
13740 msgstr ""
13742 #. type: Content of: <book><chapter><sect1><para>
13743 #: ../en/ch11-mq.xml:928
13744 msgid ""
13745 "MQ also makes it easy to work with patches when you are using normal "
13746 "Mercurial commands. Every command that accepts a changeset ID will also "
13747 "accept the name of an applied patch. MQ augments the tags normally in the "
13748 "repository with an eponymous one for each applied patch. In addition, the "
13749 "special tags <literal role=\"tag\">qbase</literal> and <literal role=\"tag"
13750 "\">qtip</literal> identify the <quote>bottom-most</quote> and topmost applied "
13751 "patches, respectively."
13752 msgstr ""
13754 #. type: Content of: <book><chapter><sect1><para>
13755 #: ../en/ch11-mq.xml:938
13756 msgid ""
13757 "These additions to Mercurial's normal tagging capabilities make dealing with "
13758 "patches even more of a breeze."
13759 msgstr ""
13761 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13762 #: ../en/ch11-mq.xml:941
13763 msgid "Want to patchbomb a mailing list with your latest series of changes?"
13764 msgstr ""
13766 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13767 #: ../en/ch11-mq.xml:944
13768 msgid ""
13769 "(Don't know what <quote>patchbombing</quote> is? See section <xref linkend="
13770 "\"sec.hgext.patchbomb\"/>.)"
13771 msgstr ""
13773 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13774 #: ../en/ch11-mq.xml:947
13775 msgid ""
13776 "Need to see all of the patches since <literal>foo.patch</literal> that have "
13777 "touched files in a subdirectory of your tree?"
13778 msgstr ""
13780 #. type: Content of: <book><chapter><sect1><para>
13781 #: ../en/ch11-mq.xml:954
13782 msgid ""
13783 "Because MQ makes the names of patches available to the rest of Mercurial "
13784 "through its normal internal tag machinery, you don't need to type in the "
13785 "entire name of a patch when you want to identify it by name."
13786 msgstr ""
13788 #. type: Content of: <book><chapter><sect1><para>
13789 #: ../en/ch11-mq.xml:959
13790 msgid ""
13791 "Another nice consequence of representing patch names as tags is that when you "
13792 "run the <command role=\"hg-cmd\">hg log</command> command, it will display a "
13793 "patch's name as a tag, simply as part of its normal output. This makes it "
13794 "easy to visually distinguish applied patches from underlying <quote>normal</"
13795 "quote> revisions. The following example shows a few normal Mercurial "
13796 "commands in use with applied patches."
13797 msgstr ""
13799 #. type: Content of: <book><chapter><sect1><title>
13800 #: ../en/ch11-mq.xml:972
13801 msgid "Useful things to know about"
13802 msgstr "其它需要了解的东西"
13804 #. type: Content of: <book><chapter><sect1><para>
13805 #: ../en/ch11-mq.xml:974
13806 msgid ""
13807 "There are a number of aspects of MQ usage that don't fit tidily into sections "
13808 "of their own, but that are good to know. Here they are, in one place."
13809 msgstr ""
13811 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13812 #: ../en/ch11-mq.xml:979
13813 msgid ""
13814 "Normally, when you <command role=\"hg-ext-mq\">qpop</command> a patch and "
13815 "<command role=\"hg-ext-mq\">qpush</command> it again, the changeset that "
13816 "represents the patch after the pop/push will have a <emphasis>different "
13817 "identity</emphasis> than the changeset that represented the hash beforehand. "
13818 "See section <xref linkend=\"sec.mqref.cmd.qpush\"/> for information as to why "
13819 "this is."
13820 msgstr ""
13822 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13823 #: ../en/ch11-mq.xml:988
13824 msgid ""
13825 "It's not a good idea to <command role=\"hg-cmd\">hg merge</command> changes "
13826 "from another branch with a patch changeset, at least if you want to maintain "
13827 "the <quote>patchiness</quote> of that changeset and changesets below it on "
13828 "the patch stack. If you try to do this, it will appear to succeed, but MQ "
13829 "will become confused."
13830 msgstr ""
13832 #. type: Content of: <book><chapter><sect1><title>
13833 #: ../en/ch11-mq.xml:999
13834 msgid "Managing patches in a repository"
13835 msgstr "在版本库管理补丁"
13837 #. type: Content of: <book><chapter><sect1><para>
13838 #: ../en/ch11-mq.xml:1001
13839 msgid ""
13840 "Because MQ's <filename role=\"special\" class=\"directory\">.hg/patches</"
13841 "filename> directory resides outside a Mercurial repository's working "
13842 "directory, the <quote>underlying</quote> Mercurial repository knows nothing "
13843 "about the management or presence of patches."
13844 msgstr ""
13846 #. type: Content of: <book><chapter><sect1><para>
13847 #: ../en/ch11-mq.xml:1007
13848 msgid ""
13849 "This presents the interesting possibility of managing the contents of the "
13850 "patch directory as a Mercurial repository in its own right. This can be a "
13851 "useful way to work. For example, you can work on a patch for a while, "
13852 "<command role=\"hg-ext-mq\">qrefresh</command> it, then <command role=\"hg-cmd"
13853 "\">hg commit</command> the current state of the patch. This lets you "
13854 "<quote>roll back</quote> to that version of the patch later on."
13855 msgstr ""
13857 #. type: Content of: <book><chapter><sect1><para>
13858 #: ../en/ch11-mq.xml:1016
13859 msgid ""
13860 "You can then share different versions of the same patch stack among multiple "
13861 "underlying repositories. I use this when I am developing a Linux kernel "
13862 "feature. I have a pristine copy of my kernel sources for each of several CPU "
13863 "architectures, and a cloned repository under each that contains the patches I "
13864 "am working on. When I want to test a change on a different architecture, I "
13865 "push my current patches to the patch repository associated with that kernel "
13866 "tree, pop and push all of my patches, and build and test that kernel."
13867 msgstr ""
13869 #. type: Content of: <book><chapter><sect1><para>
13870 #: ../en/ch11-mq.xml:1026
13871 msgid ""
13872 "Managing patches in a repository makes it possible for multiple developers to "
13873 "work on the same patch series without colliding with each other, all on top "
13874 "of an underlying source base that they may or may not control."
13875 msgstr ""
13877 #. type: Content of: <book><chapter><sect1><sect2><title>
13878 #: ../en/ch11-mq.xml:1032
13879 msgid "MQ support for patch repositories"
13880 msgstr "MQ 支持补丁版本库"
13882 #. type: Content of: <book><chapter><sect1><sect2><para>
13883 #: ../en/ch11-mq.xml:1034
13884 msgid ""
13885 "MQ helps you to work with the <filename role=\"special\" class=\"directory\">."
13886 "hg/patches</filename> directory as a repository; when you prepare a "
13887 "repository for working with patches using <command role=\"hg-ext-mq\">qinit</"
13888 "command>, you can pass the <option role=\"hg-ext-mq-cmd-qinit-opt\">hg -c</"
13889 "option> option to create the <filename role=\"special\" class=\"directory\">."
13890 "hg/patches</filename> directory as a Mercurial repository."
13891 msgstr ""
13893 #. type: Content of: <book><chapter><sect1><sect2><note><para>
13894 #: ../en/ch11-mq.xml:1044
13895 msgid ""
13896 "If you forget to use the <option role=\"hg-ext-mq-cmd-qinit-opt\">hg -c</"
13897 "option> option, you can simply go into the <filename role=\"special\" class="
13898 "\"directory\">.hg/patches</filename> directory at any time and run <command "
13899 "role=\"hg-cmd\">hg init</command>. Don't forget to add an entry for the "
13900 "<filename role=\"special\">status</filename> file to the <filename role="
13901 "\"special\">.hgignore</filename> file, though"
13902 msgstr ""
13904 #. type: Content of: <book><chapter><sect1><sect2><note><para>
13905 #: ../en/ch11-mq.xml:1053
13906 msgid ""
13907 "(<command role=\"hg-cmd\">hg qinit <option role=\"hg-ext-mq-cmd-qinit-opt"
13908 "\">hg -c</option></command> does this for you automatically); you "
13909 "<emphasis>really</emphasis> don't want to manage the <filename role=\"special"
13910 "\">status</filename> file."
13911 msgstr ""
13913 #. type: Content of: <book><chapter><sect1><sect2><para>
13914 #: ../en/ch11-mq.xml:1060
13915 msgid ""
13916 "As a convenience, if MQ notices that the <filename class=\"directory\">.hg/"
13917 "patches</filename> directory is a repository, it will automatically <command "
13918 "role=\"hg-cmd\">hg add</command> every patch that you create and import."
13919 msgstr ""
13921 #. type: Content of: <book><chapter><sect1><sect2><para>
13922 #: ../en/ch11-mq.xml:1065
13923 msgid ""
13924 "MQ provides a shortcut command, <command role=\"hg-ext-mq\">qcommit</"
13925 "command>, that runs <command role=\"hg-cmd\">hg commit</command> in the "
13926 "<filename role=\"special\" class=\"directory\">.hg/patches</filename> "
13927 "directory. This saves some bothersome typing."
13928 msgstr ""
13930 #. type: Content of: <book><chapter><sect1><sect2><para>
13931 #: ../en/ch11-mq.xml:1071
13932 msgid ""
13933 "Finally, as a convenience to manage the patch directory, you can define the "
13934 "alias <command>mq</command> on Unix systems. For example, on Linux systems "
13935 "using the <command>bash</command> shell, you can include the following "
13936 "snippet in your <filename role=\"home\">~/.bashrc</filename>."
13937 msgstr ""
13939 #. type: Content of: <book><chapter><sect1><sect2><para>
13940 #: ../en/ch11-mq.xml:1080
13941 msgid ""
13942 "You can then issue commands of the form <command>mq pull</command> from the "
13943 "main repository."
13944 msgstr ""
13946 #. type: Content of: <book><chapter><sect1><sect2><title>
13947 #: ../en/ch11-mq.xml:1085
13948 msgid "A few things to watch out for"
13949 msgstr "需要注意的事情"
13951 #. type: Content of: <book><chapter><sect1><sect2><para>
13952 #: ../en/ch11-mq.xml:1087
13953 msgid ""
13954 "MQ's support for working with a repository full of patches is limited in a "
13955 "few small respects."
13956 msgstr ""
13958 #. type: Content of: <book><chapter><sect1><sect2><para>
13959 #: ../en/ch11-mq.xml:1090
13960 msgid ""
13961 "MQ cannot automatically detect changes that you make to the patch directory. "
13962 "If you <command role=\"hg-cmd\">hg pull</command>, manually edit, or <command "
13963 "role=\"hg-cmd\">hg update</command> changes to patches or the <filename role="
13964 "\"special\">series</filename> file, you will have to <command role=\"hg-cmd"
13965 "\">hg qpop <option role=\"hg-ext-mq-cmd-qpop-opt\">hg -a</option></command> "
13966 "and then <command role=\"hg-cmd\">hg qpush <option role=\"hg-ext-mq-cmd-qpush-"
13967 "opt\">hg -a</option></command> in the underlying repository to see those "
13968 "changes show up there. If you forget to do this, you can confuse MQ's idea "
13969 "of which patches are applied."
13970 msgstr ""
13972 #. type: Content of: <book><chapter><sect1><title>
13973 #: ../en/ch11-mq.xml:1106
13974 msgid "Third party tools for working with patches"
13975 msgstr "操作补丁的第三方工具"
13977 #. type: Content of: <book><chapter><sect1><para>
13978 #: ../en/ch11-mq.xml:1108
13979 msgid ""
13980 "Once you've been working with patches for a while, you'll find yourself "
13981 "hungry for tools that will help you to understand and manipulate the patches "
13982 "you're dealing with."
13983 msgstr ""
13985 #. type: Content of: <book><chapter><sect1><para>
13986 #: ../en/ch11-mq.xml:1112
13987 msgid ""
13988 "The <command>diffstat</command> command <citation>web:diffstat</citation> "
13989 "generates a histogram of the modifications made to each file in a patch. It "
13990 "provides a good way to <quote>get a sense of</quote> a patch&emdash;which "
13991 "files it affects, and how much change it introduces to each file and as a "
13992 "whole. (I find that it's a good idea to use <command>diffstat</command>'s "
13993 "<option role=\"cmd-opt-diffstat\">-p</option> option as a matter of course, "
13994 "as otherwise it will try to do clever things with prefixes of file names that "
13995 "inevitably confuse at least me.)"
13996 msgstr ""
13998 #. type: Content of: <book><chapter><sect1><para>
13999 #: ../en/ch11-mq.xml:1126
14000 msgid ""
14001 "The <literal role=\"package\">patchutils</literal> package <citation>web:"
14002 "patchutils</citation> is invaluable. It provides a set of small utilities "
14003 "that follow the <quote>Unix philosophy;</quote> each does one useful thing "
14004 "with a patch. The <literal role=\"package\">patchutils</literal> command I "
14005 "use most is <command>filterdiff</command>, which extracts subsets from a "
14006 "patch file. For example, given a patch that modifies hundreds of files "
14007 "across dozens of directories, a single invocation of <command>filterdiff</"
14008 "command> can generate a smaller patch that only touches files whose names "
14009 "match a particular glob pattern. See section <xref linkend=\"mq-collab.tips."
14010 "interdiff\"/> for another example."
14011 msgstr ""
14013 #. type: Content of: <book><chapter><sect1><title>
14014 #: ../en/ch11-mq.xml:1142
14015 msgid "Good ways to work with patches"
14016 msgstr "操作补丁的好习惯"
14018 #. type: Content of: <book><chapter><sect1><para>
14019 #: ../en/ch11-mq.xml:1144
14020 msgid ""
14021 "Whether you are working on a patch series to submit to a free software or "
14022 "open source project, or a series that you intend to treat as a sequence of "
14023 "regular changesets when you're done, you can use some simple techniques to "
14024 "keep your work well organised."
14025 msgstr ""
14027 #. type: Content of: <book><chapter><sect1><para>
14028 #: ../en/ch11-mq.xml:1150
14029 msgid ""
14030 "Give your patches descriptive names. A good name for a patch might be "
14031 "<filename>rework-device-alloc.patch</filename>, because it will immediately "
14032 "give you a hint what the purpose of the patch is. Long names shouldn't be a "
14033 "problem; you won't be typing the names often, but you <emphasis>will</"
14034 "emphasis> be running commands like <command role=\"hg-ext-mq\">qapplied</"
14035 "command> and <command role=\"hg-ext-mq\">qtop</command> over and over. Good "
14036 "naming becomes especially important when you have a number of patches to work "
14037 "with, or if you are juggling a number of different tasks and your patches "
14038 "only get a fraction of your attention."
14039 msgstr ""
14041 #. type: Content of: <book><chapter><sect1><para>
14042 #: ../en/ch11-mq.xml:1162
14043 msgid ""
14044 "Be aware of what patch you're working on. Use the <command role=\"hg-ext-mq"
14045 "\">qtop</command> command and skim over the text of your patches "
14046 "frequently&emdash;for example, using <command role=\"hg-cmd\">hg tip <option "
14047 "role=\"hg-opt-tip\">-p</option></command>)&emdash;to be sure of where you "
14048 "stand. I have several times worked on and <command role=\"hg-ext-mq"
14049 "\">qrefresh</command>ed a patch other than the one I intended, and it's often "
14050 "tricky to migrate changes into the right patch after making them in the wrong "
14051 "one."
14052 msgstr ""
14054 #. type: Content of: <book><chapter><sect1><para>
14055 #: ../en/ch11-mq.xml:1172
14056 msgid ""
14057 "For this reason, it is very much worth investing a little time to learn how "
14058 "to use some of the third-party tools I described in section <xref linkend="
14059 "\"sec.mq.tools\"/>, particularly <command>diffstat</command> and "
14060 "<command>filterdiff</command>. The former will give you a quick idea of what "
14061 "changes your patch is making, while the latter makes it easy to splice hunks "
14062 "selectively out of one patch and into another."
14063 msgstr ""
14065 #. type: Content of: <book><chapter><sect1><title>
14066 #: ../en/ch11-mq.xml:1183
14067 msgid "MQ cookbook"
14068 msgstr "MQ 手册"
14070 #. type: Content of: <book><chapter><sect1><sect2><title>
14071 #: ../en/ch11-mq.xml:1186
14072 msgid "Manage <quote>trivial</quote> patches"
14073 msgstr "管理<quote>琐碎的</quote>补丁"
14075 #. type: Content of: <book><chapter><sect1><sect2><para>
14076 #: ../en/ch11-mq.xml:1188
14077 msgid ""
14078 "Because the overhead of dropping files into a new Mercurial repository is so "
14079 "low, it makes a lot of sense to manage patches this way even if you simply "
14080 "want to make a few changes to a source tarball that you downloaded."
14081 msgstr ""
14084 #. type: Content of: <book><chapter><sect1><sect2><para>
14085 #: ../en/ch11-mq.xml:1193
14086 msgid ""
14087 "Begin by downloading and unpacking the source tarball, and turning it into a "
14088 "Mercurial repository."
14089 msgstr ""
14091 #. type: Content of: <book><chapter><sect1><sect2><para>
14092 #: ../en/ch11-mq.xml:1198
14093 msgid "Continue by creating a patch stack and making your changes."
14094 msgstr ""
14096 #. type: Content of: <book><chapter><sect1><sect2><para>
14097 #: ../en/ch11-mq.xml:1203
14098 msgid ""
14099 "Let's say a few weeks or months pass, and your package author releases a new "
14100 "version. First, bring their changes into the repository."
14101 msgstr ""
14103 #. type: Content of: <book><chapter><sect1><sect2><para>
14104 #: ../en/ch11-mq.xml:1209
14105 msgid ""
14106 "The pipeline starting with <command role=\"hg-cmd\">hg locate</command> above "
14107 "deletes all files in the working directory, so that <command role=\"hg-cmd"
14108 "\">hg commit</command>'s <option role=\"hg-opt-commit\">--addremove</option> "
14109 "option can actually tell which files have really been removed in the newer "
14110 "version of the source."
14111 msgstr ""
14113 #. type: Content of: <book><chapter><sect1><sect2><para>
14114 #: ../en/ch11-mq.xml:1217
14115 msgid "Finally, you can apply your patches on top of the new tree."
14116 msgstr ""
14118 #. type: Content of: <book><chapter><sect1><sect2><title>
14119 #: ../en/ch11-mq.xml:1224
14120 msgid "Combining entire patches"
14121 msgstr "组合全部的补丁"
14123 #. type: Content of: <book><chapter><sect1><sect2><para>
14124 #: ../en/ch11-mq.xml:1226
14125 msgid ""
14126 "MQ provides a command, <command role=\"hg-ext-mq\">qfold</command> that lets "
14127 "you combine entire patches. This <quote>folds</quote> the patches you name, "
14128 "in the order you name them, into the topmost applied patch, and concatenates "
14129 "their descriptions onto the end of its description. The patches that you "
14130 "fold must be unapplied before you fold them."
14131 msgstr ""
14133 #. type: Content of: <book><chapter><sect1><sect2><para>
14134 #: ../en/ch11-mq.xml:1234
14135 msgid ""
14136 "The order in which you fold patches matters. If your topmost applied patch "
14137 "is <literal>foo</literal>, and you <command role=\"hg-ext-mq\">qfold</"
14138 "command> <literal>bar</literal> and <literal>quux</literal> into it, you will "
14139 "end up with a patch that has the same effect as if you applied first "
14140 "<literal>foo</literal>, then <literal>bar</literal>, followed by "
14141 "<literal>quux</literal>."
14142 msgstr ""
14144 #. type: Content of: <book><chapter><sect1><sect2><title>
14145 #: ../en/ch11-mq.xml:1245
14146 msgid "Merging part of one patch into another"
14147 msgstr "合并补丁的部分内容到其它补丁"
14149 #. type: Content of: <book><chapter><sect1><sect2><para>
14150 #: ../en/ch11-mq.xml:1247
14151 msgid ""
14152 "Merging <emphasis>part</emphasis> of one patch into another is more difficult "
14153 "than combining entire patches."
14154 msgstr ""
14156 #. type: Content of: <book><chapter><sect1><sect2><para>
14157 #: ../en/ch11-mq.xml:1251
14158 msgid ""
14159 "If you want to move changes to entire files, you can use <command>filterdiff</"
14160 "command>'s <option role=\"cmd-opt-filterdiff\">-i</option> and <option role="
14161 "\"cmd-opt-filterdiff\">-x</option> options to choose the modifications to "
14162 "snip out of one patch, concatenating its output onto the end of the patch you "
14163 "want to merge into. You usually won't need to modify the patch you've merged "
14164 "the changes from. Instead, MQ will report some rejected hunks when you "
14165 "<command role=\"hg-ext-mq\">qpush</command> it (from the hunks you moved into "
14166 "the other patch), and you can simply <command role=\"hg-ext-mq\">qrefresh</"
14167 "command> the patch to drop the duplicate hunks."
14168 msgstr ""
14170 #. type: Content of: <book><chapter><sect1><sect2><para>
14171 #: ../en/ch11-mq.xml:1264
14172 msgid ""
14173 "If you have a patch that has multiple hunks modifying a file, and you only "
14174 "want to move a few of those hunks, the job becomes more messy, but you can "
14175 "still partly automate it. Use <command>lsdiff -nvv</command> to print some "
14176 "metadata about the patch."
14177 msgstr ""
14179 #. type: Content of: <book><chapter><sect1><sect2><para>
14180 #: ../en/ch11-mq.xml:1272
14181 msgid "This command prints three different kinds of number:"
14182 msgstr ""
14184 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14185 #: ../en/ch11-mq.xml:1275
14186 msgid ""
14187 "(in the first column) a <emphasis>file number</emphasis> to identify each "
14188 "file modified in the patch;"
14189 msgstr ""
14191 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14192 #: ../en/ch11-mq.xml:1279
14193 msgid ""
14194 "(on the next line, indented) the line number within a modified file where a "
14195 "hunk starts; and"
14196 msgstr ""
14198 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14199 #: ../en/ch11-mq.xml:1282
14200 msgid ""
14201 "(on the same line) a <emphasis>hunk number</emphasis> to identify that hunk."
14202 msgstr ""
14204 #. type: Content of: <book><chapter><sect1><sect2><para>
14205 #: ../en/ch11-mq.xml:1286
14206 msgid ""
14207 "You'll have to use some visual inspection, and reading of the patch, to "
14208 "identify the file and hunk numbers you'll want, but you can then pass them to "
14209 "to <command>filterdiff</command>'s <option role=\"cmd-opt-filterdiff\">--"
14210 "files</option> and <option role=\"cmd-opt-filterdiff\">--hunks</option> "
14211 "options, to select exactly the file and hunk you want to extract."
14212 msgstr ""
14214 #. type: Content of: <book><chapter><sect1><sect2><para>
14215 #: ../en/ch11-mq.xml:1294
14216 msgid ""
14217 "Once you have this hunk, you can concatenate it onto the end of your "
14218 "destination patch and continue with the remainder of section <xref linkend="
14219 "\"sec.mq.combine\"/>."
14220 msgstr ""
14222 #. type: Content of: <book><chapter><sect1><title>
14223 #: ../en/ch11-mq.xml:1301
14224 msgid "Differences between quilt and MQ"
14225 msgstr "MQ 与 quilt 的区别"
14227 #. type: Content of: <book><chapter><sect1><para>
14228 #: ../en/ch11-mq.xml:1303
14229 msgid ""
14230 "If you are already familiar with quilt, MQ provides a similar command set. "
14231 "There are a few differences in the way that it works."
14232 msgstr ""
14234 #. type: Content of: <book><chapter><sect1><para>
14235 #: ../en/ch11-mq.xml:1307
14236 msgid ""
14237 "You will already have noticed that most quilt commands have MQ counterparts "
14238 "that simply begin with a <quote><literal>q</literal></quote>. The exceptions "
14239 "are quilt's <literal>add</literal> and <literal>remove</literal> commands, "
14240 "the counterparts for which are the normal Mercurial <command role=\"hg-cmd"
14241 "\">hg add</command> and <command role=\"hg-cmd\">hg remove</command> "
14242 "commands. There is no MQ equivalent of the quilt <literal>edit</literal> "
14243 "command."
14244 msgstr ""
14246 #. type: Content of: <book><chapter><title>
14247 #: ../en/ch12-mq-collab.xml:5
14248 msgid "Advanced uses of Mercurial Queues"
14249 msgstr "MQ 的高级用法"
14251 #. type: Content of: <book><chapter><para>
14252 #: ../en/ch12-mq-collab.xml:7
14253 msgid ""
14254 "While it's easy to pick up straightforward uses of Mercurial Queues, use of a "
14255 "little discipline and some of MQ's less frequently used capabilities makes it "
14256 "possible to work in complicated development environments."
14257 msgstr ""
14259 #. type: Content of: <book><chapter><para>
14260 #: ../en/ch12-mq-collab.xml:12
14261 msgid ""
14262 "In this chapter, I will use as an example a technique I have used to manage "
14263 "the development of an Infiniband device driver for the Linux kernel. The "
14264 "driver in question is large (at least as drivers go), with 25,000 lines of "
14265 "code spread across 35 source files. It is maintained by a small team of "
14266 "developers."
14267 msgstr ""
14269 #. type: Content of: <book><chapter><para>
14270 #: ../en/ch12-mq-collab.xml:18
14271 msgid ""
14272 "While much of the material in this chapter is specific to Linux, the same "
14273 "principles apply to any code base for which you're not the primary owner, and "
14274 "upon which you need to do a lot of development."
14275 msgstr ""
14277 #. type: Content of: <book><chapter><sect1><title>
14278 #: ../en/ch12-mq-collab.xml:24
14279 msgid "The problem of many targets"
14280 msgstr "多个目标的问题"
14282 #. type: Content of: <book><chapter><sect1><para>
14283 #: ../en/ch12-mq-collab.xml:26
14284 msgid ""
14285 "The Linux kernel changes rapidly, and has never been internally stable; "
14286 "developers frequently make drastic changes between releases. This means that "
14287 "a version of the driver that works well with a particular released version of "
14288 "the kernel will not even <emphasis>compile</emphasis> correctly against, "
14289 "typically, any other version."
14290 msgstr ""
14292 #. type: Content of: <book><chapter><sect1><para>
14293 #: ../en/ch12-mq-collab.xml:33
14294 msgid ""
14295 "To maintain a driver, we have to keep a number of distinct versions of Linux "
14296 "in mind."
14297 msgstr ""
14299 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14300 #: ../en/ch12-mq-collab.xml:36
14301 msgid ""
14302 "One target is the main Linux kernel development tree. Maintenance of the code "
14303 "is in this case partly shared by other developers in the kernel community, "
14304 "who make <quote>drive-by</quote> modifications to the driver as they develop "
14305 "and refine kernel subsystems."
14306 msgstr ""
14308 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14309 #: ../en/ch12-mq-collab.xml:42
14310 msgid ""
14311 "We also maintain a number of <quote>backports</quote> to older versions of "
14312 "the Linux kernel, to support the needs of customers who are running older "
14313 "Linux distributions that do not incorporate our drivers. (To "
14314 "<emphasis>backport</emphasis> a piece of code is to modify it to work in an "
14315 "older version of its target environment than the version it was developed "
14316 "for.)"
14317 msgstr ""
14319 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14320 #: ../en/ch12-mq-collab.xml:50
14321 msgid ""
14322 "Finally, we make software releases on a schedule that is necessarily not "
14323 "aligned with those used by Linux distributors and kernel developers, so that "
14324 "we can deliver new features to customers without forcing them to upgrade "
14325 "their entire kernels or distributions."
14326 msgstr ""
14328 #. type: Content of: <book><chapter><sect1><sect2><title>
14329 #: ../en/ch12-mq-collab.xml:58
14330 msgid "Tempting approaches that don't work well"
14331 msgstr "工作不好的诱人方法"
14333 #. type: Content of: <book><chapter><sect1><sect2><para>
14334 #: ../en/ch12-mq-collab.xml:60
14335 msgid ""
14336 "There are two <quote>standard</quote> ways to maintain a piece of software "
14337 "that has to target many different environments."
14338 msgstr ""
14340 #. type: Content of: <book><chapter><sect1><sect2><para>
14341 #: ../en/ch12-mq-collab.xml:64
14342 msgid ""
14343 "The first is to maintain a number of branches, each intended for a single "
14344 "target. The trouble with this approach is that you must maintain iron "
14345 "discipline in the flow of changes between repositories. A new feature or bug "
14346 "fix must start life in a <quote>pristine</quote> repository, then percolate "
14347 "out to every backport repository. Backport changes are more limited in the "
14348 "branches they should propagate to; a backport change that is applied to a "
14349 "branch where it doesn't belong will probably stop the driver from compiling."
14350 msgstr ""
14352 #. type: Content of: <book><chapter><sect1><sect2><para>
14353 #: ../en/ch12-mq-collab.xml:74
14354 msgid ""
14355 "The second is to maintain a single source tree filled with conditional "
14356 "statements that turn chunks of code on or off depending on the intended "
14357 "target. Because these <quote>ifdefs</quote> are not allowed in the Linux "
14358 "kernel tree, a manual or automatic process must be followed to strip them out "
14359 "and yield a clean tree. A code base maintained in this fashion rapidly "
14360 "becomes a rat's nest of conditional blocks that are difficult to understand "
14361 "and maintain."
14362 msgstr ""
14364 #. type: Content of: <book><chapter><sect1><sect2><para>
14365 #: ../en/ch12-mq-collab.xml:83
14366 msgid ""
14367 "Neither of these approaches is well suited to a situation where you don't "
14368 "<quote>own</quote> the canonical copy of a source tree. In the case of a "
14369 "Linux driver that is distributed with the standard kernel, Linus's tree "
14370 "contains the copy of the code that will be treated by the world as "
14371 "canonical. The upstream version of <quote>my</quote> driver can be modified "
14372 "by people I don't know, without me even finding out about it until after the "
14373 "changes show up in Linus's tree."
14374 msgstr ""
14376 #. type: Content of: <book><chapter><sect1><sect2><para>
14377 #: ../en/ch12-mq-collab.xml:93
14378 msgid ""
14379 "These approaches have the added weakness of making it difficult to generate "
14380 "well-formed patches to submit upstream."
14381 msgstr ""
14383 #. type: Content of: <book><chapter><sect1><sect2><para>
14384 #: ../en/ch12-mq-collab.xml:97
14385 msgid ""
14386 "In principle, Mercurial Queues seems like a good candidate to manage a "
14387 "development scenario such as the above. While this is indeed the case, MQ "
14388 "contains a few added features that make the job more pleasant."
14389 msgstr ""
14391 #. type: Content of: <book><chapter><sect1><title>
14392 #: ../en/ch12-mq-collab.xml:105
14393 msgid "Conditionally applying patches with guards"
14394 msgstr "有条件的应用补丁"
14396 #. type: Content of: <book><chapter><sect1><para>
14397 #: ../en/ch12-mq-collab.xml:107
14398 msgid ""
14399 "Perhaps the best way to maintain sanity with so many targets is to be able to "
14400 "choose specific patches to apply for a given situation. MQ provides a "
14401 "feature called <quote>guards</quote> (which originates with quilt's "
14402 "<literal>guards</literal> command) that does just this. To start off, let's "
14403 "create a simple repository for experimenting in."
14404 msgstr ""
14406 #. type: Content of: <book><chapter><sect1><para>
14407 #: ../en/ch12-mq-collab.xml:116
14408 msgid ""
14409 "This gives us a tiny repository that contains two patches that don't have any "
14410 "dependencies on each other, because they touch different files."
14411 msgstr ""
14413 #. type: Content of: <book><chapter><sect1><para>
14414 #: ../en/ch12-mq-collab.xml:120
14415 msgid ""
14416 "The idea behind conditional application is that you can <quote>tag</quote> a "
14417 "patch with a <emphasis>guard</emphasis>, which is simply a text string of "
14418 "your choosing, then tell MQ to select specific guards to use when applying "
14419 "patches. MQ will then either apply, or skip over, a guarded patch, depending "
14420 "on the guards that you have selected."
14421 msgstr ""
14423 #. type: Content of: <book><chapter><sect1><para>
14424 #: ../en/ch12-mq-collab.xml:127
14425 msgid ""
14426 "A patch can have an arbitrary number of guards; each one is "
14427 "<emphasis>positive</emphasis> (<quote>apply this patch if this guard is "
14428 "selected</quote>) or <emphasis>negative</emphasis> (<quote>skip this patch if "
14429 "this guard is selected</quote>). A patch with no guards is always applied."
14430 msgstr ""
14432 #. type: Content of: <book><chapter><sect1><title>
14433 #: ../en/ch12-mq-collab.xml:135
14434 msgid "Controlling the guards on a patch"
14435 msgstr "控制补丁的应用条件"
14437 #. type: Content of: <book><chapter><sect1><para>
14438 #: ../en/ch12-mq-collab.xml:137
14439 msgid ""
14440 "The <command role=\"hg-ext-mq\">qguard</command> command lets you determine "
14441 "which guards should apply to a patch, or display the guards that are already "
14442 "in effect. Without any arguments, it displays the guards on the current "
14443 "topmost patch."
14444 msgstr ""
14446 #. type: Content of: <book><chapter><sect1><para>
14447 #: ../en/ch12-mq-collab.xml:144
14448 msgid ""
14449 "To set a positive guard on a patch, prefix the name of the guard with a "
14450 "<quote><literal>+</literal></quote>."
14451 msgstr ""
14453 #. type: Content of: <book><chapter><sect1><para>
14454 #: ../en/ch12-mq-collab.xml:149
14455 msgid ""
14456 "To set a negative guard on a patch, prefix the name of the guard with a "
14457 "<quote><literal>-</literal></quote>."
14458 msgstr ""
14460 #. type: Content of: <book><chapter><sect1><note><para>
14461 #: ../en/ch12-mq-collab.xml:156
14462 msgid ""
14463 "The <command role=\"hg-ext-mq\">qguard</command> command <emphasis>sets</"
14464 "emphasis> the guards on a patch; it doesn't <emphasis>modify</emphasis> "
14465 "them. What this means is that if you run <command role=\"hg-cmd\">hg qguard "
14466 "+a +b</command> on a patch, then <command role=\"hg-cmd\">hg qguard +c</"
14467 "command> on the same patch, the <emphasis>only</emphasis> guard that will be "
14468 "set on it afterwards is <literal>+c</literal>."
14469 msgstr ""
14472 #. type: Content of: <book><chapter><sect1><para>
14473 #: ../en/ch12-mq-collab.xml:165
14474 msgid ""
14475 "Mercurial stores guards in the <filename role=\"special\">series</filename> "
14476 "file; the form in which they are stored is easy both to understand and to "
14477 "edit by hand. (In other words, you don't have to use the <command role=\"hg-"
14478 "ext-mq\">qguard</command> command if you don't want to; it's okay to simply "
14479 "edit the <filename role=\"special\">series</filename> file.)"
14480 msgstr ""
14482 #. type: Content of: <book><chapter><sect1><title>
14483 #: ../en/ch12-mq-collab.xml:177
14484 msgid "Selecting the guards to use"
14485 msgstr "选择使用的条件"
14487 #. type: Content of: <book><chapter><sect1><para>
14488 #: ../en/ch12-mq-collab.xml:179
14489 msgid ""
14490 "The <command role=\"hg-ext-mq\">qselect</command> command determines which "
14491 "guards are active at a given time. The effect of this is to determine which "
14492 "patches MQ will apply the next time you run <command role=\"hg-ext-mq"
14493 "\">qpush</command>. It has no other effect; in particular, it doesn't do "
14494 "anything to patches that are already applied."
14495 msgstr ""
14497 #. type: Content of: <book><chapter><sect1><para>
14498 #: ../en/ch12-mq-collab.xml:186
14499 msgid ""
14500 "With no arguments, the <command role=\"hg-ext-mq\">qselect</command> command "
14501 "lists the guards currently in effect, one per line of output. Each argument "
14502 "is treated as the name of a guard to apply."
14503 msgstr ""
14505 #. type: Content of: <book><chapter><sect1><para>
14506 #: ../en/ch12-mq-collab.xml:193
14507 msgid ""
14508 "In case you're interested, the currently selected guards are stored in the "
14509 "<filename role=\"special\">guards</filename> file."
14510 msgstr ""
14512 #. type: Content of: <book><chapter><sect1><para>
14513 #: ../en/ch12-mq-collab.xml:198
14514 msgid ""
14515 "We can see the effect the selected guards have when we run <command role=\"hg-"
14516 "ext-mq\">qpush</command>."
14517 msgstr ""
14519 #. type: Content of: <book><chapter><sect1><para>
14520 #: ../en/ch12-mq-collab.xml:203
14521 msgid ""
14522 "A guard cannot start with a <quote><literal>+</literal></quote> or "
14523 "<quote><literal>-</literal></quote> character. The name of a guard must not "
14524 "contain white space, but most other characters are acceptable. If you try to "
14525 "use a guard with an invalid name, MQ will complain:"
14526 msgstr ""
14528 #. type: Content of: <book><chapter><sect1><para>
14529 #: ../en/ch12-mq-collab.xml:212
14530 msgid "Changing the selected guards changes the patches that are applied."
14531 msgstr ""
14533 #. type: Content of: <book><chapter><sect1><para>
14534 #: ../en/ch12-mq-collab.xml:217
14535 msgid ""
14536 "You can see in the example below that negative guards take precedence over "
14537 "positive guards."
14538 msgstr ""
14540 #. type: Content of: <book><chapter><sect1><title>
14541 #: ../en/ch12-mq-collab.xml:224
14542 msgid "MQ's rules for applying patches"
14543 msgstr "MQ 应用补丁的规则"
14545 #. type: Content of: <book><chapter><sect1><para>
14546 #: ../en/ch12-mq-collab.xml:226
14547 msgid ""
14548 "The rules that MQ uses when deciding whether to apply a patch are as follows."
14549 msgstr ""
14551 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14552 #: ../en/ch12-mq-collab.xml:229
14553 msgid "A patch that has no guards is always applied."
14554 msgstr ""
14556 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14557 #: ../en/ch12-mq-collab.xml:232
14558 msgid ""
14559 "If the patch has any negative guard that matches any currently selected "
14560 "guard, the patch is skipped."
14561 msgstr ""
14563 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14564 #: ../en/ch12-mq-collab.xml:235
14565 msgid ""
14566 "If the patch has any positive guard that matches any currently selected "
14567 "guard, the patch is applied."
14568 msgstr ""
14570 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14571 #: ../en/ch12-mq-collab.xml:238
14572 msgid ""
14573 "If the patch has positive or negative guards, but none matches any currently "
14574 "selected guard, the patch is skipped."
14575 msgstr ""
14577 #. type: Content of: <book><chapter><sect1><title>
14578 #: ../en/ch12-mq-collab.xml:245
14579 msgid "Trimming the work environment"
14580 msgstr "修剪工作环境"
14582 #. type: Content of: <book><chapter><sect1><para>
14583 #: ../en/ch12-mq-collab.xml:247
14584 msgid ""
14585 "In working on the device driver I mentioned earlier, I don't apply the "
14586 "patches to a normal Linux kernel tree. Instead, I use a repository that "
14587 "contains only a snapshot of the source files and headers that are relevant to "
14588 "Infiniband development. This repository is 1% the size of a kernel "
14589 "repository, so it's easier to work with."
14590 msgstr ""
14592 #. type: Content of: <book><chapter><sect1><para>
14593 #: ../en/ch12-mq-collab.xml:254
14594 msgid ""
14595 "I then choose a <quote>base</quote> version on top of which the patches are "
14596 "applied. This is a snapshot of the Linux kernel tree as of a revision of my "
14597 "choosing. When I take the snapshot, I record the changeset ID from the "
14598 "kernel repository in the commit message. Since the snapshot preserves the "
14599 "<quote>shape</quote> and content of the relevant parts of the kernel tree, I "
14600 "can apply my patches on top of either my tiny repository or a normal kernel "
14601 "tree."
14602 msgstr ""
14604 #. type: Content of: <book><chapter><sect1><para>
14605 #: ../en/ch12-mq-collab.xml:263
14606 msgid ""
14607 "Normally, the base tree atop which the patches apply should be a snapshot of "
14608 "a very recent upstream tree. This best facilitates the development of "
14609 "patches that can easily be submitted upstream with few or no modifications."
14610 msgstr ""
14612 #. type: Content of: <book><chapter><sect1><title>
14613 #: ../en/ch12-mq-collab.xml:270
14614 msgid "Dividing up the <filename role=\"special\">series</filename> file"
14615 msgstr "分类补丁<filename role=\"special\">系列</filename>"
14617 #. type: Content of: <book><chapter><sect1><para>
14618 #: ../en/ch12-mq-collab.xml:273
14619 msgid ""
14620 "I categorise the patches in the <filename role=\"special\">series</filename> "
14621 "file into a number of logical groups. Each section of like patches begins "
14622 "with a block of comments that describes the purpose of the patches that "
14623 "follow."
14624 msgstr ""
14626 #. type: Content of: <book><chapter><sect1><para>
14627 #: ../en/ch12-mq-collab.xml:279
14628 msgid ""
14629 "The sequence of patch groups that I maintain follows. The ordering of these "
14630 "groups is important; I'll describe why after I introduce the groups."
14631 msgstr ""
14633 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14634 #: ../en/ch12-mq-collab.xml:283
14635 msgid ""
14636 "The <quote>accepted</quote> group. Patches that the development team has "
14637 "submitted to the maintainer of the Infiniband subsystem, and which he has "
14638 "accepted, but which are not present in the snapshot that the tiny repository "
14639 "is based on. These are <quote>read only</quote> patches, present only to "
14640 "transform the tree into a similar state as it is in the upstream maintainer's "
14641 "repository."
14642 msgstr ""
14644 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14645 #: ../en/ch12-mq-collab.xml:291
14646 msgid ""
14647 "The <quote>rework</quote> group. Patches that I have submitted, but that the "
14648 "upstream maintainer has requested modifications to before he will accept them."
14649 msgstr ""
14651 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14652 #: ../en/ch12-mq-collab.xml:296
14653 msgid ""
14654 "The <quote>pending</quote> group. Patches that I have not yet submitted to "
14655 "the upstream maintainer, but which we have finished working on. These will be "
14656 "<quote>read only</quote> for a while. If the upstream maintainer accepts "
14657 "them upon submission, I'll move them to the end of the <quote>accepted</"
14658 "quote> group. If he requests that I modify any, I'll move them to the "
14659 "beginning of the <quote>rework</quote> group."
14660 msgstr ""
14662 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14663 #: ../en/ch12-mq-collab.xml:305
14664 msgid ""
14665 "The <quote>in progress</quote> group. Patches that are actively being "
14666 "developed, and should not be submitted anywhere yet."
14667 msgstr ""
14669 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14670 #: ../en/ch12-mq-collab.xml:309
14671 msgid ""
14672 "The <quote>backport</quote> group. Patches that adapt the source tree to "
14673 "older versions of the kernel tree."
14674 msgstr ""
14676 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14677 #: ../en/ch12-mq-collab.xml:313
14678 msgid ""
14679 "The <quote>do not ship</quote> group. Patches that for some reason should "
14680 "never be submitted upstream. For example, one such patch might change "
14681 "embedded driver identification strings to make it easier to distinguish, in "
14682 "the field, between an out-of-tree version of the driver and a version shipped "
14683 "by a distribution vendor."
14684 msgstr ""
14686 #. type: Content of: <book><chapter><sect1><para>
14687 #: ../en/ch12-mq-collab.xml:321
14688 msgid ""
14689 "Now to return to the reasons for ordering groups of patches in this way. We "
14690 "would like the lowest patches in the stack to be as stable as possible, so "
14691 "that we will not need to rework higher patches due to changes in context. "
14692 "Putting patches that will never be changed first in the <filename role="
14693 "\"special\">series</filename> file serves this purpose."
14694 msgstr ""
14696 #. type: Content of: <book><chapter><sect1><para>
14697 #: ../en/ch12-mq-collab.xml:329
14698 msgid ""
14699 "We would also like the patches that we know we'll need to modify to be "
14700 "applied on top of a source tree that resembles the upstream tree as closely "
14701 "as possible. This is why we keep accepted patches around for a while."
14702 msgstr ""
14704 #. type: Content of: <book><chapter><sect1><para>
14705 #: ../en/ch12-mq-collab.xml:334
14706 msgid ""
14707 "The <quote>backport</quote> and <quote>do not ship</quote> patches float at "
14708 "the end of the <filename role=\"special\">series</filename> file. The "
14709 "backport patches must be applied on top of all other patches, and the "
14710 "<quote>do not ship</quote> patches might as well stay out of harm's way."
14711 msgstr ""
14713 #. type: Content of: <book><chapter><sect1><title>
14714 #: ../en/ch12-mq-collab.xml:343
14715 msgid "Maintaining the patch series"
14716 msgstr "维护补丁系列"
14718 #. type: Content of: <book><chapter><sect1><para>
14719 #: ../en/ch12-mq-collab.xml:345
14720 msgid ""
14721 "In my work, I use a number of guards to control which patches are to be "
14722 "applied."
14723 msgstr ""
14725 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14726 #: ../en/ch12-mq-collab.xml:349
14727 msgid ""
14728 "<quote>Accepted</quote> patches are guarded with <literal>accepted</"
14729 "literal>. I enable this guard most of the time. When I'm applying the "
14730 "patches on top of a tree where the patches are already present, I can turn "
14731 "this patch off, and the patches that follow it will apply cleanly."
14732 msgstr ""
14734 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14735 #: ../en/ch12-mq-collab.xml:356
14736 msgid ""
14737 "Patches that are <quote>finished</quote>, but not yet submitted, have no "
14738 "guards. If I'm applying the patch stack to a copy of the upstream tree, I "
14739 "don't need to enable any guards in order to get a reasonably safe source tree."
14740 msgstr ""
14742 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14743 #: ../en/ch12-mq-collab.xml:362
14744 msgid ""
14745 "Those patches that need reworking before being resubmitted are guarded with "
14746 "<literal>rework</literal>."
14747 msgstr ""
14749 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14750 #: ../en/ch12-mq-collab.xml:366
14751 msgid ""
14752 "For those patches that are still under development, I use <literal>devel</"
14753 "literal>."
14754 msgstr ""
14756 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14757 #: ../en/ch12-mq-collab.xml:369
14758 msgid ""
14759 "A backport patch may have several guards, one for each version of the kernel "
14760 "to which it applies. For example, a patch that backports a piece of code to "
14761 "2.6.9 will have a <literal>2.6.9</literal> guard."
14762 msgstr ""
14764 #. type: Content of: <book><chapter><sect1><para>
14765 #: ../en/ch12-mq-collab.xml:374
14766 msgid ""
14767 "This variety of guards gives me considerable flexibility in determining what "
14768 "kind of source tree I want to end up with. For most situations, the "
14769 "selection of appropriate guards is automated during the build process, but I "
14770 "can manually tune the guards to use for less common circumstances."
14771 msgstr ""
14773 #. type: Content of: <book><chapter><sect1><sect2><title>
14774 #: ../en/ch12-mq-collab.xml:381
14775 msgid "The art of writing backport patches"
14776 msgstr "编写向后移植补丁的艺术"
14778 #. type: Content of: <book><chapter><sect1><sect2><para>
14779 #: ../en/ch12-mq-collab.xml:383
14780 msgid ""
14781 "Using MQ, writing a backport patch is a simple process. All such a patch has "
14782 "to do is modify a piece of code that uses a kernel feature not present in the "
14783 "older version of the kernel, so that the driver continues to work correctly "
14784 "under that older version."
14785 msgstr ""
14787 #. type: Content of: <book><chapter><sect1><sect2><para>
14788 #: ../en/ch12-mq-collab.xml:389
14789 msgid ""
14790 "A useful goal when writing a good backport patch is to make your code look as "
14791 "if it was written for the older version of the kernel you're targeting. The "
14792 "less obtrusive the patch, the easier it will be to understand and maintain. "
14793 "If you're writing a collection of backport patches to avoid the <quote>rat's "
14794 "nest</quote> effect of lots of <literal>#ifdef</literal>s (hunks of source "
14795 "code that are only used conditionally) in your code, don't introduce version-"
14796 "dependent <literal>#ifdef</literal>s into the patches. Instead, write "
14797 "several patches, each of which makes unconditional changes, and control their "
14798 "application using guards."
14799 msgstr ""
14801 #. type: Content of: <book><chapter><sect1><sect2><para>
14802 #: ../en/ch12-mq-collab.xml:402
14803 msgid ""
14804 "There are two reasons to divide backport patches into a distinct group, away "
14805 "from the <quote>regular</quote> patches whose effects they modify. The first "
14806 "is that intermingling the two makes it more difficult to use a tool like the "
14807 "<literal role=\"hg-ext\">patchbomb</literal> extension to automate the "
14808 "process of submitting the patches to an upstream maintainer. The second is "
14809 "that a backport patch could perturb the context in which a subsequent regular "
14810 "patch is applied, making it impossible to apply the regular patch cleanly "
14811 "<emphasis>without</emphasis> the earlier backport patch already being applied."
14812 msgstr ""
14814 #. type: Content of: <book><chapter><sect1><title>
14815 #: ../en/ch12-mq-collab.xml:417
14816 msgid "Useful tips for developing with MQ"
14817 msgstr "使用 MQ 开发的技巧"
14819 #. type: Content of: <book><chapter><sect1><sect2><title>
14820 #: ../en/ch12-mq-collab.xml:420
14821 msgid "Organising patches in directories"
14822 msgstr "将补丁放到几个目录中"
14824 #. type: Content of: <book><chapter><sect1><sect2><para>
14825 #: ../en/ch12-mq-collab.xml:422
14826 msgid ""
14827 "If you're working on a substantial project with MQ, it's not difficult to "
14828 "accumulate a large number of patches. For example, I have one patch "
14829 "repository that contains over 250 patches."
14830 msgstr ""
14832 #. type: Content of: <book><chapter><sect1><sect2><para>
14833 #: ../en/ch12-mq-collab.xml:427
14834 msgid ""
14835 "If you can group these patches into separate logical categories, you can if "
14836 "you like store them in different directories; MQ has no problems with patch "
14837 "names that contain path separators."
14838 msgstr ""
14840 #. type: Content of: <book><chapter><sect1><sect2><title>
14841 #: ../en/ch12-mq-collab.xml:434
14842 msgid "Viewing the history of a patch"
14843 msgstr "察看补丁的历史"
14845 #. type: Content of: <book><chapter><sect1><sect2><para>
14846 #: ../en/ch12-mq-collab.xml:436
14847 msgid ""
14848 "If you're developing a set of patches over a long time, it's a good idea to "
14849 "maintain them in a repository, as discussed in section <xref linkend=\"sec.mq."
14850 "repo\"/>. If you do so, you'll quickly discover that using the <command role="
14851 "\"hg-cmd\">hg diff</command> command to look at the history of changes to a "
14852 "patch is unworkable. This is in part because you're looking at the second "
14853 "derivative of the real code (a diff of a diff), but also because MQ adds "
14854 "noise to the process by modifying time stamps and directory names when it "
14855 "updates a patch."
14856 msgstr ""
14858 #. type: Content of: <book><chapter><sect1><sect2><para>
14859 #: ../en/ch12-mq-collab.xml:448
14860 msgid ""
14861 "However, you can use the <literal role=\"hg-ext\">extdiff</literal> "
14862 "extension, which is bundled with Mercurial, to turn a diff of two versions of "
14863 "a patch into something readable. To do this, you will need a third-party "
14864 "package called <literal role=\"package\">patchutils</literal> <citation>web:"
14865 "patchutils</citation>. This provides a command named <command>interdiff</"
14866 "command>, which shows the differences between two diffs as a diff. Used on "
14867 "two versions of the same diff, it generates a diff that represents the diff "
14868 "from the first to the second version."
14869 msgstr ""
14871 #. type: Content of: <book><chapter><sect1><sect2><para>
14872 #: ../en/ch12-mq-collab.xml:459
14873 msgid ""
14874 "You can enable the <literal role=\"hg-ext\">extdiff</literal> extension in "
14875 "the usual way, by adding a line to the <literal role=\"rc-extensions"
14876 "\">extensions</literal> section of your <filename role=\"special\">~/.hgrc</"
14877 "filename>."
14878 msgstr ""
14881 #. &example.hg-interdiff;
14882 #. type: Content of: <book><chapter><sect1><sect2><para>
14883 #: ../en/ch12-mq-collab.xml:466
14884 msgid ""
14885 "The <command>interdiff</command> command expects to be passed the names of "
14886 "two files, but the <literal role=\"hg-ext\">extdiff</literal> extension "
14887 "passes the program it runs a pair of directories, each of which can contain "
14888 "an arbitrary number of files. We thus need a small program that will run "
14889 "<command>interdiff</command> on each pair of files in these two directories. "
14890 "This program is available as <filename role=\"special\">hg-interdiff</"
14891 "filename> in the <filename class=\"directory\">examples</filename> directory "
14892 "of the source code repository that accompanies this book."
14893 msgstr ""
14895 #. type: Content of: <book><chapter><sect1><sect2><para>
14896 #: ../en/ch12-mq-collab.xml:478
14897 msgid ""
14898 "With the <filename role=\"special\">hg-interdiff</filename> program in your "
14899 "shell's search path, you can run it as follows, from inside an MQ patch "
14900 "directory:"
14901 msgstr ""
14903 #. type: Content of: <book><chapter><sect1><sect2><para>
14904 #: ../en/ch12-mq-collab.xml:482
14905 msgid ""
14906 "Since you'll probably want to use this long-winded command a lot, you can get "
14907 "<literal role=\"hg-ext\">hgext</literal> to make it available as a normal "
14908 "Mercurial command, again by editing your <filename role=\"special\">~/.hgrc</"
14909 "filename>."
14910 msgstr ""
14912 #. type: Content of: <book><chapter><sect1><sect2><para>
14913 #: ../en/ch12-mq-collab.xml:489
14914 msgid ""
14915 "This directs <literal role=\"hg-ext\">hgext</literal> to make an "
14916 "<literal>interdiff</literal> command available, so you can now shorten the "
14917 "previous invocation of <command role=\"hg-ext-extdiff\">extdiff</command> to "
14918 "something a little more wieldy."
14919 msgstr ""
14921 #. type: Content of: <book><chapter><sect1><sect2><note><para>
14922 #: ../en/ch12-mq-collab.xml:497
14923 msgid ""
14924 "The <command>interdiff</command> command works well only if the underlying "
14925 "files against which versions of a patch are generated remain the same. If "
14926 "you create a patch, modify the underlying files, and then regenerate the "
14927 "patch, <command>interdiff</command> may not produce useful output."
14928 msgstr ""
14930 #. type: Content of: <book><chapter><sect1><sect2><para>
14931 #: ../en/ch12-mq-collab.xml:505
14932 msgid ""
14933 "The <literal role=\"hg-ext\">extdiff</literal> extension is useful for more "
14934 "than merely improving the presentation of MQ patches. To read more about it, "
14935 "go to section <xref linkend=\"sec.hgext.extdiff\"/>."
14936 msgstr ""
14938 #. type: Content of: <book><chapter><title>
14939 #: ../en/ch13-hgext.xml:5
14940 msgid "Adding functionality with extensions"
14941 msgstr "使用扩展增加功能"
14943 #. type: Content of: <book><chapter><para>
14944 #: ../en/ch13-hgext.xml:7
14945 msgid ""
14946 "While the core of Mercurial is quite complete from a functionality "
14947 "standpoint, it's deliberately shorn of fancy features. This approach of "
14948 "preserving simplicity keeps the software easy to deal with for both "
14949 "maintainers and users."
14950 msgstr ""
14952 #. type: Content of: <book><chapter><para>
14953 #: ../en/ch13-hgext.xml:12
14954 msgid ""
14955 "However, Mercurial doesn't box you in with an inflexible command set: you can "
14956 "add features to it as <emphasis>extensions</emphasis> (sometimes known as "
14957 "<emphasis>plugins</emphasis>). We've already discussed a few of these "
14958 "extensions in earlier chapters."
14959 msgstr ""
14961 #. type: Content of: <book><chapter><itemizedlist><listitem><para>
14962 #: ../en/ch13-hgext.xml:18
14963 msgid ""
14964 "Section <xref linkend=\"sec.tour-merge.fetch\"/> covers the <literal role="
14965 "\"hg-ext\">fetch</literal> extension; this combines pulling new changes and "
14966 "merging them with local changes into a single command, <command role=\"hg-ext-"
14967 "fetch\">fetch</command>."
14968 msgstr ""
14970 #. type: Content of: <book><chapter><itemizedlist><listitem><para>
14971 #: ../en/ch13-hgext.xml:24
14972 msgid ""
14973 "In chapter <xref linkend=\"chap.hook\"/>, we covered several extensions that "
14974 "are useful for hook-related functionality: <literal role=\"hg-ext\">acl</"
14975 "literal> adds access control lists; <literal role=\"hg-ext\">bugzilla</"
14976 "literal> adds integration with the Bugzilla bug tracking system; and <literal "
14977 "role=\"hg-ext\">notify</literal> sends notification emails on new changes."
14978 msgstr ""
14980 #. type: Content of: <book><chapter><itemizedlist><listitem><para>
14981 #: ../en/ch13-hgext.xml:33
14982 msgid ""
14983 "The Mercurial Queues patch management extension is so invaluable that it "
14984 "merits two chapters and an appendix all to itself. Chapter <xref linkend="
14985 "\"chap.mq\"/> covers the basics; chapter <xref linkend=\"chap.mq-collab\"/> "
14986 "discusses advanced topics; and appendix <xref linkend=\"chap.mqref\"/> goes "
14987 "into detail on each command."
14988 msgstr ""
14990 #. type: Content of: <book><chapter><para>
14991 #: ../en/ch13-hgext.xml:43
14992 msgid ""
14993 "In this chapter, we'll cover some of the other extensions that are available "
14994 "for Mercurial, and briefly touch on some of the machinery you'll need to know "
14995 "about if you want to write an extension of your own."
14996 msgstr ""
14998 #. type: Content of: <book><chapter><itemizedlist><listitem><para>
14999 #: ../en/ch13-hgext.xml:48
15000 msgid ""
15001 "In section <xref linkend=\"sec.hgext.inotify\"/>, we'll discuss the "
15002 "possibility of <emphasis>huge</emphasis> performance improvements using the "
15003 "<literal role=\"hg-ext\">inotify</literal> extension."
15004 msgstr ""
15006 #. type: Content of: <book><chapter><sect1><title>
15007 #: ../en/ch13-hgext.xml:55
15008 msgid ""
15009 "Improve performance with the <literal role=\"hg-ext\">inotify</literal> "
15010 "extension"
15011 msgstr "使用扩展 <literal role=\"hg-ext\">inotify</literal> 以提高性能"
15013 #. type: Content of: <book><chapter><sect1><para>
15014 #: ../en/ch13-hgext.xml:58
15015 msgid ""
15016 "Are you interested in having some of the most common Mercurial operations run "
15017 "as much as a hundred times faster? Read on!"
15018 msgstr ""
15020 #. type: Content of: <book><chapter><sect1><para>
15021 #: ../en/ch13-hgext.xml:62
15022 msgid ""
15023 "Mercurial has great performance under normal circumstances. For example, "
15024 "when you run the <command role=\"hg-cmd\">hg status</command> command, "
15025 "Mercurial has to scan almost every directory and file in your repository so "
15026 "that it can display file status. Many other Mercurial commands need to do "
15027 "the same work behind the scenes; for example, the <command role=\"hg-cmd\">hg "
15028 "diff</command> command uses the status machinery to avoid doing an expensive "
15029 "comparison operation on files that obviously haven't changed."
15030 msgstr ""
15032 #. type: Content of: <book><chapter><sect1><para>
15033 #: ../en/ch13-hgext.xml:72
15034 msgid ""
15035 "Because obtaining file status is crucial to good performance, the authors of "
15036 "Mercurial have optimised this code to within an inch of its life. However, "
15037 "there's no avoiding the fact that when you run <command role=\"hg-cmd\">hg "
15038 "status</command>, Mercurial is going to have to perform at least one "
15039 "expensive system call for each managed file to determine whether it's changed "
15040 "since the last time Mercurial checked. For a sufficiently large repository, "
15041 "this can take a long time."
15042 msgstr ""
15044 #. type: Content of: <book><chapter><sect1><para>
15045 #: ../en/ch13-hgext.xml:82
15046 msgid ""
15047 "To put a number on the magnitude of this effect, I created a repository "
15048 "containing 150,000 managed files. I timed <command role=\"hg-cmd\">hg "
15049 "status</command> as taking ten seconds to run, even when <emphasis>none</"
15050 "emphasis> of those files had been modified."
15051 msgstr ""
15053 #. type: Content of: <book><chapter><sect1><para>
15054 #: ../en/ch13-hgext.xml:88
15055 msgid ""
15056 "Many modern operating systems contain a file notification facility. If a "
15057 "program signs up to an appropriate service, the operating system will notify "
15058 "it every time a file of interest is created, modified, or deleted. On Linux "
15059 "systems, the kernel component that does this is called <literal>inotify</"
15060 "literal>."
15061 msgstr ""
15063 #. type: Content of: <book><chapter><sect1><para>
15064 #: ../en/ch13-hgext.xml:95
15065 msgid ""
15066 "Mercurial's <literal role=\"hg-ext\">inotify</literal> extension talks to the "
15067 "kernel's <literal>inotify</literal> component to optimise <command role=\"hg-"
15068 "cmd\">hg status</command> commands. The extension has two components. A "
15069 "daemon sits in the background and receives notifications from the "
15070 "<literal>inotify</literal> subsystem. It also listens for connections from a "
15071 "regular Mercurial command. The extension modifies Mercurial's behaviour so "
15072 "that instead of scanning the filesystem, it queries the daemon. Since the "
15073 "daemon has perfect information about the state of the repository, it can "
15074 "respond with a result instantaneously, avoiding the need to scan every "
15075 "directory and file in the repository."
15076 msgstr ""
15078 #. type: Content of: <book><chapter><sect1><para>
15079 #: ../en/ch13-hgext.xml:108
15080 msgid ""
15081 "Recall the ten seconds that I measured plain Mercurial as taking to run "
15082 "<command role=\"hg-cmd\">hg status</command> on a 150,000 file repository. "
15083 "With the <literal role=\"hg-ext\">inotify</literal> extension enabled, the "
15084 "time dropped to 0.1 seconds, a factor of <emphasis>one hundred</emphasis> "
15085 "faster."
15086 msgstr ""
15088 #. type: Content of: <book><chapter><sect1><para>
15089 #: ../en/ch13-hgext.xml:115
15090 msgid "Before we continue, please pay attention to some caveats."
15091 msgstr ""
15093 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15094 #: ../en/ch13-hgext.xml:118
15095 msgid ""
15096 "The <literal role=\"hg-ext\">inotify</literal> extension is Linux-specific. "
15097 "Because it interfaces directly to the Linux kernel's <literal>inotify</"
15098 "literal> subsystem, it does not work on other operating systems."
15099 msgstr ""
15101 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15102 #: ../en/ch13-hgext.xml:123
15103 msgid ""
15104 "It should work on any Linux distribution that was released after early 2005. "
15105 "Older distributions are likely to have a kernel that lacks <literal>inotify</"
15106 "literal>, or a version of <literal>glibc</literal> that does not have the "
15107 "necessary interfacing support."
15108 msgstr ""
15110 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15111 #: ../en/ch13-hgext.xml:130
15112 msgid ""
15113 "Not all filesystems are suitable for use with the <literal role=\"hg-ext"
15114 "\">inotify</literal> extension. Network filesystems such as NFS are a non-"
15115 "starter, for example, particularly if you're running Mercurial on several "
15116 "systems, all mounting the same network filesystem. The kernel's "
15117 "<literal>inotify</literal> system has no way of knowing about changes made on "
15118 "another system. Most local filesystems (e.g. ext3, XFS, ReiserFS) should "
15119 "work fine."
15120 msgstr ""
15122 #. type: Content of: <book><chapter><sect1><para>
15123 #: ../en/ch13-hgext.xml:141
15124 msgid ""
15125 "The <literal role=\"hg-ext\">inotify</literal> extension is not yet shipped "
15126 "with Mercurial as of May 2007, so it's a little more involved to set up than "
15127 "other extensions. But the performance improvement is worth it!"
15128 msgstr ""
15130 #. type: Content of: <book><chapter><sect1><para>
15131 #: ../en/ch13-hgext.xml:146
15132 msgid ""
15133 "The extension currently comes in two parts: a set of patches to the Mercurial "
15134 "source code, and a library of Python bindings to the <literal>inotify</"
15135 "literal> subsystem."
15136 msgstr ""
15138 #. type: Content of: <book><chapter><sect1><note><para>
15139 #: ../en/ch13-hgext.xml:150
15140 msgid ""
15141 "There are <emphasis>two</emphasis> Python <literal>inotify</literal> binding "
15142 "libraries. One of them is called <literal>pyinotify</literal>, and is "
15143 "packaged by some Linux distributions as <literal>python-inotify</literal>. "
15144 "This is <emphasis>not</emphasis> the one you'll need, as it is too buggy and "
15145 "inefficient to be practical."
15146 msgstr ""
15148 #. type: Content of: <book><chapter><sect1><para>
15149 #: ../en/ch13-hgext.xml:157
15150 msgid ""
15151 "To get going, it's best to already have a functioning copy of Mercurial "
15152 "installed."
15153 msgstr ""
15155 #. type: Content of: <book><chapter><sect1><note><para>
15156 #: ../en/ch13-hgext.xml:160
15157 msgid ""
15158 "If you follow the instructions below, you'll be <emphasis>replacing</"
15159 "emphasis> and overwriting any existing installation of Mercurial that you "
15160 "might already have, using the latest <quote>bleeding edge</quote> Mercurial "
15161 "code. Don't say you weren't warned!"
15162 msgstr ""
15164 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
15165 #: ../en/ch13-hgext.xml:167
15166 msgid ""
15167 "Clone the Python <literal>inotify</literal> binding repository. Build and "
15168 "install it."
15169 msgstr ""
15171 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
15172 #: ../en/ch13-hgext.xml:174
15173 msgid ""
15174 "Clone the <filename class=\"directory\">crew</filename> Mercurial "
15175 "repository. Clone the <literal role=\"hg-ext\">inotify</literal> patch "
15176 "repository so that Mercurial Queues will be able to apply patches to your "
15177 "cope of the <filename class=\"directory\">crew</filename> repository."
15178 msgstr ""
15180 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
15181 #: ../en/ch13-hgext.xml:184
15182 msgid ""
15183 "Make sure that you have the Mercurial Queues extension, <literal role=\"hg-ext"
15184 "\">mq</literal>, enabled. If you've never used MQ, read section <xref "
15185 "linkend=\"sec.mq.start\"/> to get started quickly."
15186 msgstr ""
15188 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
15189 #: ../en/ch13-hgext.xml:190
15190 msgid ""
15191 "Go into the <filename class=\"directory\">inotify</filename> repo, and apply "
15192 "all of the <literal role=\"hg-ext\">inotify</literal> patches using the "
15193 "<option role=\"hg-ext-mq-cmd-qpush-opt\">hg -a</option> option to the "
15194 "<command role=\"hg-ext-mq\">qpush</command> command."
15195 msgstr ""
15197 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
15198 #: ../en/ch13-hgext.xml:199
15199 msgid ""
15200 "If you get an error message from <command role=\"hg-ext-mq\">qpush</command>, "
15201 "you should not continue. Instead, ask for help."
15202 msgstr ""
15204 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
15205 #: ../en/ch13-hgext.xml:203
15206 msgid "Build and install the patched version of Mercurial."
15207 msgstr ""
15209 #. type: Content of: <book><chapter><sect1><para>
15210 #: ../en/ch13-hgext.xml:209
15211 msgid ""
15212 "Once you've build a suitably patched version of Mercurial, all you need to do "
15213 "to enable the <literal role=\"hg-ext\">inotify</literal> extension is add an "
15214 "entry to your <filename role=\"special\">~/.hgrc</filename>."
15215 msgstr ""
15217 #. type: Content of: <book><chapter><sect1><para>
15218 #: ../en/ch13-hgext.xml:214
15219 msgid ""
15220 "When the <literal role=\"hg-ext\">inotify</literal> extension is enabled, "
15221 "Mercurial will automatically and transparently start the status daemon the "
15222 "first time you run a command that needs status in a repository. It runs one "
15223 "status daemon per repository."
15224 msgstr ""
15226 #. type: Content of: <book><chapter><sect1><para>
15227 #: ../en/ch13-hgext.xml:220
15228 msgid ""
15229 "The status daemon is started silently, and runs in the background. If you "
15230 "look at a list of running processes after you've enabled the <literal role="
15231 "\"hg-ext\">inotify</literal> extension and run a few commands in different "
15232 "repositories, you'll thus see a few <literal>hg</literal> processes sitting "
15233 "around, waiting for updates from the kernel and queries from Mercurial."
15234 msgstr ""
15236 #. type: Content of: <book><chapter><sect1><para>
15237 #: ../en/ch13-hgext.xml:228
15238 msgid ""
15239 "The first time you run a Mercurial command in a repository when you have the "
15240 "<literal role=\"hg-ext\">inotify</literal> extension enabled, it will run "
15241 "with about the same performance as a normal Mercurial command. This is "
15242 "because the status daemon needs to perform a normal status scan so that it "
15243 "has a baseline against which to apply later updates from the kernel. "
15244 "However, <emphasis>every</emphasis> subsequent command that does any kind of "
15245 "status check should be noticeably faster on repositories of even fairly "
15246 "modest size. Better yet, the bigger your repository is, the greater a "
15247 "performance advantage you'll see. The <literal role=\"hg-ext\">inotify</"
15248 "literal> daemon makes status operations almost instantaneous on repositories "
15249 "of all sizes!"
15250 msgstr ""
15252 #. type: Content of: <book><chapter><sect1><para>
15253 #: ../en/ch13-hgext.xml:242
15254 msgid ""
15255 "If you like, you can manually start a status daemon using the <command role="
15256 "\"hg-ext-inotify\">inserve</command> command. This gives you slightly finer "
15257 "control over how the daemon ought to run. This command will of course only "
15258 "be available when the <literal role=\"hg-ext\">inotify</literal> extension is "
15259 "enabled."
15260 msgstr ""
15262 #. type: Content of: <book><chapter><sect1><para>
15263 #: ../en/ch13-hgext.xml:249
15264 msgid ""
15265 "When you're using the <literal role=\"hg-ext\">inotify</literal> extension, "
15266 "you should notice <emphasis>no difference at all</emphasis> in Mercurial's "
15267 "behaviour, with the sole exception of status-related commands running a whole "
15268 "lot faster than they used to. You should specifically expect that commands "
15269 "will not print different output; neither should they give different results. "
15270 "If either of these situations occurs, please report a bug."
15271 msgstr ""
15273 #. type: Content of: <book><chapter><sect1><title>
15274 #: ../en/ch13-hgext.xml:260
15275 msgid ""
15276 "Flexible diff support with the <literal role=\"hg-ext\">extdiff</literal> "
15277 "extension"
15278 msgstr "使用扩展 <literal role=\"hg-ext\">extdiff</literal> 以扩展差异支持"
15280 #. type: Content of: <book><chapter><sect1><para>
15281 #: ../en/ch13-hgext.xml:263
15282 msgid ""
15283 "Mercurial's built-in <command role=\"hg-cmd\">hg diff</command> command "
15284 "outputs plaintext unified diffs."
15285 msgstr ""
15286 "Mercurial 内置命令 <command role=\"hg-cmd\">hg diff</command> 的输出与统一差异"
15287 "不同。"
15289 #. type: Content of: <book><chapter><sect1><para>
15290 #: ../en/ch13-hgext.xml:268
15291 msgid ""
15292 "If you would like to use an external tool to display modifications, you'll "
15293 "want to use the <literal role=\"hg-ext\">extdiff</literal> extension. This "
15294 "will let you use, for example, a graphical diff tool."
15295 msgstr ""
15297 #. type: Content of: <book><chapter><sect1><para>
15298 #: ../en/ch13-hgext.xml:273
15299 msgid ""
15300 "The <literal role=\"hg-ext\">extdiff</literal> extension is bundled with "
15301 "Mercurial, so it's easy to set up. In the <literal role=\"rc-extensions"
15302 "\">extensions</literal> section of your <filename role=\"special\">~/.hgrc</"
15303 "filename>, simply add a one-line entry to enable the extension."
15304 msgstr ""
15306 #. type: Content of: <book><chapter><sect1><para>
15307 #: ../en/ch13-hgext.xml:280
15308 msgid ""
15309 "This introduces a command named <command role=\"hg-ext-extdiff\">extdiff</"
15310 "command>, which by default uses your system's <command>diff</command> command "
15311 "to generate a unified diff in the same form as the built-in <command role="
15312 "\"hg-cmd\">hg diff</command> command."
15313 msgstr ""
15315 #. type: Content of: <book><chapter><sect1><para>
15316 #: ../en/ch13-hgext.xml:288
15317 msgid ""
15318 "The result won't be exactly the same as with the built-in <command role=\"hg-"
15319 "cmd\">hg diff</command> variations, because the output of <command>diff</"
15320 "command> varies from one system to another, even when passed the same options."
15321 msgstr ""
15323 #. type: Content of: <book><chapter><sect1><para>
15324 #: ../en/ch13-hgext.xml:293
15325 msgid ""
15326 "As the <quote><literal>making snapshot</literal></quote> lines of output "
15327 "above imply, the <command role=\"hg-ext-extdiff\">extdiff</command> command "
15328 "works by creating two snapshots of your source tree. The first snapshot is "
15329 "of the source revision; the second, of the target revision or working "
15330 "directory. The <command role=\"hg-ext-extdiff\">extdiff</command> command "
15331 "generates these snapshots in a temporary directory, passes the name of each "
15332 "directory to an external diff viewer, then deletes the temporary directory. "
15333 "For efficiency, it only snapshots the directories and files that have changed "
15334 "between the two revisions."
15335 msgstr ""
15337 #. type: Content of: <book><chapter><sect1><para>
15338 #: ../en/ch13-hgext.xml:306
15339 msgid ""
15340 "Snapshot directory names have the same base name as your repository. If your "
15341 "repository path is <filename class=\"directory\">/quux/bar/foo</filename>, "
15342 "then <filename class=\"directory\">foo</filename> will be the name of each "
15343 "snapshot directory. Each snapshot directory name has its changeset ID "
15344 "appended, if appropriate. If a snapshot is of revision "
15345 "<literal>a631aca1083f</literal>, the directory will be named <filename class="
15346 "\"directory\">foo.a631aca1083f</filename>. A snapshot of the working "
15347 "directory won't have a changeset ID appended, so it would just be <filename "
15348 "class=\"directory\">foo</filename> in this example. To see what this looks "
15349 "like in practice, look again at the <command role=\"hg-ext-extdiff\">extdiff</"
15350 "command> example above. Notice that the diff has the snapshot directory "
15351 "names embedded in its header."
15352 msgstr ""
15354 #. type: Content of: <book><chapter><sect1><para>
15355 #: ../en/ch13-hgext.xml:322
15356 msgid ""
15357 "The <command role=\"hg-ext-extdiff\">extdiff</command> command accepts two "
15358 "important options. The <option role=\"hg-ext-extdiff-cmd-extdiff-opt\">hg -p</"
15359 "option> option lets you choose a program to view differences with, instead of "
15360 "<command>diff</command>. With the <option role=\"hg-ext-extdiff-cmd-extdiff-"
15361 "opt\">hg -o</option> option, you can change the options that <command role="
15362 "\"hg-ext-extdiff\">extdiff</command> passes to the program (by default, these "
15363 "options are <quote><literal>-Npru</literal></quote>, which only make sense if "
15364 "you're running <command>diff</command>). In other respects, the <command "
15365 "role=\"hg-ext-extdiff\">extdiff</command> command acts similarly to the built-"
15366 "in <command role=\"hg-cmd\">hg diff</command> command: you use the same "
15367 "option names, syntax, and arguments to specify the revisions you want, the "
15368 "files you want, and so on."
15369 msgstr ""
15372 #. type: Content of: <book><chapter><sect1><para>
15373 #: ../en/ch13-hgext.xml:339
15374 msgid ""
15375 "As an example, here's how to run the normal system <command>diff</command> "
15376 "command, getting it to generate context diffs (using the <option role=\"cmd-"
15377 "opt-diff\">-c</option> option) instead of unified diffs, and five lines of "
15378 "context instead of the default three (passing <literal>5</literal> as the "
15379 "argument to the <option role=\"cmd-opt-diff\">-C</option> option)."
15380 msgstr ""
15382 #. type: Content of: <book><chapter><sect1><para>
15383 #: ../en/ch13-hgext.xml:348
15384 msgid ""
15385 "Launching a visual diff tool is just as easy. Here's how to launch the "
15386 "<command>kdiff3</command> viewer."
15387 msgstr ""
15389 #. type: Content of: <book><chapter><sect1><para>
15390 #: ../en/ch13-hgext.xml:352
15391 msgid ""
15392 "If your diff viewing command can't deal with directories, you can easily work "
15393 "around this with a little scripting. For an example of such scripting in "
15394 "action with the <literal role=\"hg-ext\">mq</literal> extension and the "
15395 "<command>interdiff</command> command, see section <xref linkend=\"mq-collab."
15396 "tips.interdiff\"/>."
15397 msgstr ""
15399 #. type: Content of: <book><chapter><sect1><sect2><title>
15400 #: ../en/ch13-hgext.xml:360
15401 msgid "Defining command aliases"
15402 msgstr "定义命令的别名"
15404 #. type: Content of: <book><chapter><sect1><sect2><para>
15405 #: ../en/ch13-hgext.xml:362
15406 msgid ""
15407 "It can be cumbersome to remember the options to both the <command role=\"hg-"
15408 "ext-extdiff\">extdiff</command> command and the diff viewer you want to use, "
15409 "so the <literal role=\"hg-ext\">extdiff</literal> extension lets you define "
15410 "<emphasis>new</emphasis> commands that will invoke your diff viewer with "
15411 "exactly the right options."
15412 msgstr ""
15414 #. type: Content of: <book><chapter><sect1><sect2><para>
15415 #: ../en/ch13-hgext.xml:369
15416 msgid ""
15417 "All you need to do is edit your <filename role=\"special\">~/.hgrc</"
15418 "filename>, and add a section named <literal role=\"rc-extdiff\">extdiff</"
15419 "literal>. Inside this section, you can define multiple commands. Here's how "
15420 "to add a <literal>kdiff3</literal> command. Once you've defined this, you "
15421 "can type <quote><literal>hg kdiff3</literal></quote> and the <literal role="
15422 "\"hg-ext\">extdiff</literal> extension will run <command>kdiff3</command> for "
15423 "you."
15424 msgstr ""
15426 #. type: Content of: <book><chapter><sect1><sect2><para>
15427 #: ../en/ch13-hgext.xml:379
15428 msgid ""
15429 "If you leave the right hand side of the definition empty, as above, the "
15430 "<literal role=\"hg-ext\">extdiff</literal> extension uses the name of the "
15431 "command you defined as the name of the external program to run. But these "
15432 "names don't have to be the same. Here, we define a command named "
15433 "<quote><literal>hg wibble</literal></quote>, which runs <command>kdiff3</"
15434 "command>."
15435 msgstr ""
15437 #. type: Content of: <book><chapter><sect1><sect2><para>
15438 #: ../en/ch13-hgext.xml:389
15439 msgid ""
15440 "You can also specify the default options that you want to invoke your diff "
15441 "viewing program with. The prefix to use is <quote><literal>opts.</literal></"
15442 "quote>, followed by the name of the command to which the options apply. This "
15443 "example defines a <quote><literal>hg vimdiff</literal></quote> command that "
15444 "runs the <command>vim</command> editor's <literal>DirDiff</literal> extension."
15445 msgstr ""
15447 #. type: Content of: <book><chapter><sect1><title>
15448 #: ../en/ch13-hgext.xml:403
15449 msgid ""
15450 "Cherrypicking changes with the <literal role=\"hg-ext\">transplant</literal> "
15451 "extension"
15452 msgstr "使用扩展 <literal role=\"hg-ext\">transplant</literal> 以挑选修改"
15454 #. type: Content of: <book><chapter><sect1><para>
15455 #: ../en/ch13-hgext.xml:406
15456 msgid "Need to have a long chat with Brendan about this."
15457 msgstr ""
15459 #. type: Content of: <book><chapter><sect1><title>
15460 #: ../en/ch13-hgext.xml:410
15461 msgid ""
15462 "Send changes via email with the <literal role=\"hg-ext\">patchbomb</literal> "
15463 "extension"
15464 msgstr ""
15465 "使用扩展 <literal role=\"hg-ext\">patchbomb</literal> 通过 email 发送修改"
15467 #. type: Content of: <book><chapter><sect1><para>
15468 #: ../en/ch13-hgext.xml:413
15469 msgid ""
15470 "Many projects have a culture of <quote>change review</quote>, in which people "
15471 "send their modifications to a mailing list for others to read and comment on "
15472 "before they commit the final version to a shared repository. Some projects "
15473 "have people who act as gatekeepers; they apply changes from other people to a "
15474 "repository to which those others don't have access."
15475 msgstr ""
15477 #. type: Content of: <book><chapter><sect1><para>
15478 #: ../en/ch13-hgext.xml:421
15479 msgid ""
15480 "Mercurial makes it easy to send changes over email for review or application, "
15481 "via its <literal role=\"hg-ext\">patchbomb</literal> extension. The "
15482 "extension is so named because changes are formatted as patches, and it's "
15483 "usual to send one changeset per email message. Sending a long series of "
15484 "changes by email is thus much like <quote>bombing</quote> the recipient's "
15485 "inbox, hence <quote>patchbomb</quote>."
15486 msgstr ""
15488 #. type: Content of: <book><chapter><sect1><para>
15489 #: ../en/ch13-hgext.xml:429
15490 msgid ""
15491 "As usual, the basic configuration of the <literal role=\"hg-ext\">patchbomb</"
15492 "literal> extension takes just one or two lines in your <filename role="
15493 "\"special\"> /.hgrc</filename>."
15494 msgstr ""
15496 #. type: Content of: <book><chapter><sect1><para>
15497 #: ../en/ch13-hgext.xml:435
15498 msgid ""
15499 "Once you've enabled the extension, you will have a new command available, "
15500 "named <command role=\"hg-ext-patchbomb\">email</command>."
15501 msgstr ""
15503 #. type: Content of: <book><chapter><sect1><para>
15504 #: ../en/ch13-hgext.xml:439
15505 msgid ""
15506 "The safest and best way to invoke the <command role=\"hg-ext-patchbomb"
15507 "\">email</command> command is to <emphasis>always</emphasis> run it first "
15508 "with the <option role=\"hg-ext-patchbomb-cmd-email-opt\">hg -n</option> "
15509 "option. This will show you what the command <emphasis>would</emphasis> send, "
15510 "without actually sending anything. Once you've had a quick glance over the "
15511 "changes and verified that you are sending the right ones, you can rerun the "
15512 "same command, with the <option role=\"hg-ext-patchbomb-cmd-email-opt\">hg -n</"
15513 "option> option removed."
15514 msgstr ""
15516 #. type: Content of: <book><chapter><sect1><para>
15517 #: ../en/ch13-hgext.xml:450
15518 msgid ""
15519 "The <command role=\"hg-ext-patchbomb\">email</command> command accepts the "
15520 "same kind of revision syntax as every other Mercurial command. For example, "
15521 "this command will send every revision between 7 and <literal>tip</literal>, "
15522 "inclusive."
15523 msgstr ""
15525 #. type: Content of: <book><chapter><sect1><para>
15526 #: ../en/ch13-hgext.xml:455
15527 msgid ""
15528 "You can also specify a <emphasis>repository</emphasis> to compare with. If "
15529 "you provide a repository but no revisions, the <command role=\"hg-ext-"
15530 "patchbomb\">email</command> command will send all revisions in the local "
15531 "repository that are not present in the remote repository. If you "
15532 "additionally specify revisions or a branch name (the latter using the <option "
15533 "role=\"hg-ext-patchbomb-cmd-email-opt\">hg -b</option> option), this will "
15534 "constrain the revisions sent."
15535 msgstr ""
15537 #. type: Content of: <book><chapter><sect1><para>
15538 #: ../en/ch13-hgext.xml:464
15539 msgid ""
15540 "It's perfectly safe to run the <command role=\"hg-ext-patchbomb\">email</"
15541 "command> command without the names of the people you want to send to: if you "
15542 "do this, it will just prompt you for those values interactively. (If you're "
15543 "using a Linux or Unix-like system, you should have enhanced "
15544 "<literal>readline</literal>-style editing capabilities when entering those "
15545 "headers, too, which is useful.)"
15546 msgstr ""
15548 #. type: Content of: <book><chapter><sect1><para>
15549 #: ../en/ch13-hgext.xml:472
15550 msgid ""
15551 "When you are sending just one revision, the <command role=\"hg-ext-patchbomb"
15552 "\">email</command> command will by default use the first line of the "
15553 "changeset description as the subject of the single email message it sends."
15554 msgstr ""
15556 #. type: Content of: <book><chapter><sect1><para>
15557 #: ../en/ch13-hgext.xml:477
15558 msgid ""
15559 "If you send multiple revisions, the <command role=\"hg-ext-patchbomb\">email</"
15560 "command> command will usually send one message per changeset. It will "
15561 "preface the series with an introductory message, in which you should describe "
15562 "the purpose of the series of changes you're sending."
15563 msgstr ""
15565 #. type: Content of: <book><chapter><sect1><sect2><title>
15566 #: ../en/ch13-hgext.xml:484
15567 msgid "Changing the behaviour of patchbombs"
15568 msgstr "修改 patchbomb 的行为"
15570 #. type: Content of: <book><chapter><sect1><sect2><para>
15571 #: ../en/ch13-hgext.xml:486
15572 msgid ""
15573 "Not every project has exactly the same conventions for sending changes in "
15574 "email; the <literal role=\"hg-ext\">patchbomb</literal> extension tries to "
15575 "accommodate a number of variations through command line options."
15576 msgstr ""
15578 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15579 #: ../en/ch13-hgext.xml:492
15580 msgid ""
15581 "You can write a subject for the introductory message on the command line "
15582 "using the <option role=\"hg-ext-patchbomb-cmd-email-opt\">hg -s</option> "
15583 "option. This takes one argument, the text of the subject to use."
15584 msgstr ""
15586 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15587 #: ../en/ch13-hgext.xml:498
15588 msgid ""
15589 "To change the email address from which the messages originate, use the "
15590 "<option role=\"hg-ext-patchbomb-cmd-email-opt\">hg -f</option> option. This "
15591 "takes one argument, the email address to use."
15592 msgstr ""
15594 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15595 #: ../en/ch13-hgext.xml:504
15596 msgid ""
15597 "The default behaviour is to send unified diffs (see section <xref linkend="
15598 "\"sec.mq.patch\"/> for a description of the format), one per message. You "
15599 "can send a binary bundle instead with the <option role=\"hg-ext-patchbomb-cmd-"
15600 "email-opt\">hg -b</option> option."
15601 msgstr ""
15603 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15604 #: ../en/ch13-hgext.xml:512
15605 msgid ""
15606 "Unified diffs are normally prefaced with a metadata header. You can omit "
15607 "this, and send unadorned diffs, with the <option role=\"hg-ext-patchbomb-cmd-"
15608 "email-opt\">hg --plain</option> option."
15609 msgstr ""
15611 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15612 #: ../en/ch13-hgext.xml:518
15613 msgid ""
15614 "Diffs are normally sent <quote>inline</quote>, in the same body part as the "
15615 "description of a patch. This makes it easiest for the largest number of "
15616 "readers to quote and respond to parts of a diff, as some mail clients will "
15617 "only quote the first MIME body part in a message. If you'd prefer to send the "
15618 "description and the diff in separate body parts, use the <option role=\"hg-"
15619 "ext-patchbomb-cmd-email-opt\">hg -a</option> option."
15620 msgstr ""
15622 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15623 #: ../en/ch13-hgext.xml:528
15624 msgid ""
15625 "Instead of sending mail messages, you can write them to an <literal>mbox</"
15626 "literal>-format mail folder using the <option role=\"hg-ext-patchbomb-cmd-"
15627 "email-opt\">hg -m</option> option. That option takes one argument, the name "
15628 "of the file to write to."
15629 msgstr ""
15631 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15632 #: ../en/ch13-hgext.xml:535
15633 msgid ""
15634 "If you would like to add a <command>diffstat</command>-format summary to each "
15635 "patch, and one to the introductory message, use the <option role=\"hg-ext-"
15636 "patchbomb-cmd-email-opt\">hg -d</option> option. The <command>diffstat</"
15637 "command> command displays a table containing the name of each file patched, "
15638 "the number of lines affected, and a histogram showing how much each file is "
15639 "modified. This gives readers a qualitative glance at how complex a patch is."
15640 msgstr ""
15642 #~ msgid "Introduction"
15643 #~ msgstr "简介"
15645 #~ msgid "About revision control"
15646 #~ msgstr "关于版本控制"
15648 #~ msgid "Why use revision control?"
15649 #~ msgstr "为什么使用版本控制?"
15651 #~ msgid "The many names of revision control"
15652 #~ msgstr "版本控制的别名"
15654 #~ msgid "Revision control (RCS)"
15655 #~ msgstr "版本控制(RCS)"
15657 #~ msgid "Software configuration management (SCM), or configuration management"
15658 #~ msgstr "软件配置管理(SCM),或配置管理"
15660 #~ msgid "Source code management"
15661 #~ msgstr "源代码管理"
15663 #~ msgid "Source code control, or source control"
15664 #~ msgstr "源代码控制,或源控制"
15666 #~ msgid "Version control (VCS)"
15667 #~ msgstr "版本控制(VCS)"
15669 #~ msgid "A short history of revision control"
15670 #~ msgstr "版本控制简史"
15672 #~ msgid "Trends in revision control"
15673 #~ msgstr "版本控制的发展趋势"
15675 #~ msgid "A few of the advantages of distributed revision control"
15676 #~ msgstr "分布版本控制的优点"
15678 #~ msgid "Advantages for open source projects"
15679 #~ msgstr "开源项目的优点"
15681 #~ msgid "Advantages for commercial projects"
15682 #~ msgstr "商业项目的优点"
15684 #~ msgid "Why choose Mercurial?"
15685 #~ msgstr "为什么选择 Mercurial?"
15687 #~ msgid "Mercurial compared with other tools"
15688 #~ msgstr "Mercurial 与其它工具的比较"
15690 #~ msgid "Commercial tools"
15691 #~ msgstr "商业工具"
15693 #~ msgid "Choosing a revision control tool"
15694 #~ msgstr "选择版本控制工具"
15696 #~ msgid "Switching from another tool to Mercurial"
15697 #~ msgstr "从其它工具切换到 Mercurial"