hgbook

view po/zh.po @ 710:8613844dd2cf

Update po files with source xml files
author Dongsheng Song <songdongsheng@live.cn>
date Sat Apr 18 10:09:11 2009 +0800 (2009-04-18)
parents 55e2953f82d6
children 364d2ce9e055
line source
1 #
2 # Simplified Chinese translation for hgbook
3 # This file is distributed under the same license as the hgbook.
4 #
5 # Authors:
6 # Dongsheng Song <dongsheng.song@gmail.com>, 2009
7 #
8 # Check translation:
9 # msgfmt --statistics -c -o zh.mo zh.po
10 #
11 # Please format your translation before commit:
12 # msgcat --sort-by-file --width=80 -o zh_new.po zh.po
13 # mv -f zh_new.po zh.po
14 #
15 # Dictionary:
16 # blame 追溯
17 # branch 分支
18 # changes 修改
19 # changeset 修改集
20 # checkout 检出
21 # remove 移除(从版本库删除)
22 # delete 删除(只从文件系统删除)
23 # filelog 文件日志
24 # patchset 补丁集
25 # pushing to 推到
26 # pulling from 拉自,抓取
27 # rename 改名
28 # repository 版本库
29 # revert 恢复
30 # revision 版本
31 # revlog 版本日志
32 # tag 标签
33 # tip 顶点
34 # undo 撤销
35 # unversioned 未版本控制
36 # updated 更新到,同步到(适用于旧版本)
37 # versioned 受版本控制
38 # working copy 工作副本
39 # ...
40 #
41 msgid ""
42 msgstr ""
43 "Project-Id-Version: hgbook 1.2\n"
44 "POT-Creation-Date: 2009-04-18 10:05+0800\n"
45 "PO-Revision-Date: 2009-04-05 12:10+0800\n"
46 "Last-Translator: 宋冬生 <songdonogsheng@live.cn>\n"
47 "Language-Team: Simplified Chinese <i18n-zh@googlegroups.com >\n"
48 "MIME-Version: 1.0\n"
49 "Content-Type: text/plain; charset=UTF-8\n"
50 "Content-Transfer-Encoding: 8bit\n"
51 "X-Poedit-Language: Chinese\n"
52 "X-Poedit-Country: CHINA\n"
53 "X-Poedit-SourceCharset: utf-8\n"
55 #. type: Content of: <book><title>
56 #: ../en/00book.xml:41
57 msgid "Mercurial: The Definitive Guide"
58 msgstr "Mercurial 权威指南"
60 #. type: Content of: <book><subtitle>
61 #: ../en/00book.xml:46
62 msgid "Compiled from $rev_id$"
63 msgstr "编译自 $rev_id$"
65 #. type: Content of: <book><bookinfo>
66 #: ../en/00book.xml:48
67 msgid "<edition>1</edition> <isbn>9780596800673</isbn>"
68 msgstr "<edition>1</edition> <isbn>9780596800673</isbn>"
70 #. type: Content of: <book><bookinfo><authorgroup><author><firstname>
71 #: ../en/00book.xml:52
72 msgid "Bryan"
73 msgstr "Bryan"
75 #. type: Content of: <book><bookinfo><authorgroup><author><surname>
76 #: ../en/00book.xml:53
77 msgid "O'Sullivan"
78 msgstr "O'Sullivan"
80 #. type: Content of: <book><bookinfo>
81 #: ../en/00book.xml:57
82 msgid ""
83 "<editor> <firstname>Mike</firstname> <surname>Loukides</surname> </editor> "
84 "<copyright> <year>2006</year> <year>2007</year> <year>2008</year> <year>2009</"
85 "year> <holder>Bryan O'Sullivan</holder> </copyright>"
86 msgstr ""
87 "<editor> <firstname>Mike</firstname> <surname>Loukides</surname> </editor> "
88 "<copyright> <year>2006</year> <year>2007</year> <year>2008</year> <year>2009</"
89 "year> <holder>Bryan O'Sullivan</holder> </copyright>"
91 #. type: Content of: <book><appendix><title>
92 #: ../en/appB-mq-ref.xml:5
93 msgid "Mercurial Queues reference"
94 msgstr "Mercurial 队列参考"
96 #. type: Content of: <book><appendix><sect1><title>
97 #: ../en/appB-mq-ref.xml:8
98 msgid "MQ command reference"
99 msgstr "MQ 命令参考"
101 #. type: Content of: <book><appendix><sect1><para>
102 #: ../en/appB-mq-ref.xml:10
103 msgid ""
104 "For an overview of the commands provided by MQ, use the command <command role="
105 "\"hg-cmd\">hg help mq</command>."
106 msgstr ""
108 #. type: Content of: <book><appendix><sect1><sect2><title>
109 #: ../en/appB-mq-ref.xml:14
110 msgid ""
111 "<command role=\"hg-ext-mq\">qapplied</command>&emdash;print applied patches"
112 msgstr "<command role=\"hg-ext-mq\">qapplied</command>—显示已应用的补丁"
114 #. type: Content of: <book><appendix><sect1><sect2><para>
115 #: ../en/appB-mq-ref.xml:17
116 msgid ""
117 "The <command role=\"hg-ext-mq\">qapplied</command> command prints the current "
118 "stack of applied patches. Patches are printed in oldest-to-newest order, so "
119 "the last patch in the list is the <quote>top</quote> patch."
120 msgstr ""
122 #. type: Content of: <book><appendix><sect1><sect2><title>
123 #: ../en/appB-mq-ref.xml:24
124 msgid ""
125 "<command role=\"hg-ext-mq\">qcommit</command>&emdash;commit changes in the "
126 "queue repository"
127 msgstr "<command role=\"hg-ext-mq\">qcommit</command>—提交队列中的修改"
129 #. type: Content of: <book><appendix><sect1><sect2><para>
130 #: ../en/appB-mq-ref.xml:27
131 msgid ""
132 "The <command role=\"hg-ext-mq\">qcommit</command> command commits any "
133 "outstanding changes in the <filename role=\"special\" class=\"directory\">.hg/"
134 "patches</filename> repository. This command only works if the <filename role="
135 "\"special\" class=\"directory\">.hg/patches</filename> directory is a "
136 "repository, i.e. you created the directory using <command role=\"hg-cmd\">hg "
137 "qinit <option role=\"hg-ext-mq-cmd-qinit-opt\">-c</option></command> or ran "
138 "<command role=\"hg-cmd\">hg init</command> in the directory after running "
139 "<command role=\"hg-ext-mq\">qinit</command>."
140 msgstr ""
142 #. type: Content of: <book><appendix><sect1><sect2><para>
143 #: ../en/appB-mq-ref.xml:39
144 msgid ""
145 "This command is shorthand for <command role=\"hg-cmd\">hg commit --cwd .hg/"
146 "patches</command>."
147 msgstr ""
149 #. type: Content of: <book><appendix><sect1><sect2><title>
150 #: ../en/appB-mq-ref.xml:43
151 msgid ""
152 "<command role=\"hg-ext-mq\">qdelete</command>&emdash;delete a patch from the "
153 "<filename role=\"special\">series</filename> file"
154 msgstr ""
155 "<command role=\"hg-ext-mq\">qdelete</command>—从文件 <filename role=\"special"
156 "\">series</filename> 中删除补丁"
158 #. type: Content of: <book><appendix><sect1><sect2><para>
159 #: ../en/appB-mq-ref.xml:48
160 msgid ""
161 "The <command role=\"hg-ext-mq\">qdelete</command> command removes the entry "
162 "for a patch from the <filename role=\"special\">series</filename> file in the "
163 "<filename role=\"special\" class=\"directory\">.hg/patches</filename> "
164 "directory. It does not pop the patch if the patch is already applied. By "
165 "default, it does not delete the patch file; use the <option role=\"hg-ext-mq-"
166 "cmd-qdel-opt\">-f</option> option to do that."
167 msgstr ""
169 #. type: Content of: <book><appendix><sect1><sect2><para>
170 #: ../en/appB-mq-ref.xml:57 ../en/appB-mq-ref.xml:99 ../en/appB-mq-ref.xml:157
171 #: ../en/appB-mq-ref.xml:197 ../en/appB-mq-ref.xml:264
172 #: ../en/appB-mq-ref.xml:335 ../en/appB-mq-ref.xml:404
173 #: ../en/appB-mq-ref.xml:497
174 msgid "Options:"
175 msgstr "选项:"
177 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
178 #: ../en/appB-mq-ref.xml:59
179 msgid ""
180 "<option role=\"hg-ext-mq-cmd-qdel-opt\">-f</option>: Delete the patch file."
181 msgstr ""
183 #. type: Content of: <book><appendix><sect1><sect2><title>
184 #: ../en/appB-mq-ref.xml:66
185 msgid ""
186 "<command role=\"hg-ext-mq\">qdiff</command>&emdash;print a diff of the "
187 "topmost applied patch"
188 msgstr "<command role=\"hg-ext-mq\">qdiff</command>—显示最新应用补丁的差异"
190 #. type: Content of: <book><appendix><sect1><sect2><para>
191 #: ../en/appB-mq-ref.xml:69
192 msgid ""
193 "The <command role=\"hg-ext-mq\">qdiff</command> command prints a diff of the "
194 "topmost applied patch. It is equivalent to <command role=\"hg-cmd\">hg diff -"
195 "r-2:-1</command>."
196 msgstr ""
198 #. type: Content of: <book><appendix><sect1><sect2><title>
199 #: ../en/appB-mq-ref.xml:75
200 msgid ""
201 "<command role=\"hg-ext-mq\">qfold</command>&emdash;merge (<quote>fold</"
202 "quote>) several patches into one"
203 msgstr ""
204 "<command role=\"hg-ext-mq\">qfold</command>—将多个补丁合并(<quote>折叠</"
205 "quote>)成一个"
207 #. type: Content of: <book><appendix><sect1><sect2><para>
208 #: ../en/appB-mq-ref.xml:78
209 msgid ""
210 "The <command role=\"hg-ext-mq\">qfold</command> command merges multiple "
211 "patches into the topmost applied patch, so that the topmost applied patch "
212 "makes the union of all of the changes in the patches in question."
213 msgstr ""
215 #. type: Content of: <book><appendix><sect1><sect2><para>
216 #: ../en/appB-mq-ref.xml:83
217 msgid ""
218 "The patches to fold must not be applied; <command role=\"hg-ext-mq\">qfold</"
219 "command> will exit with an error if any is. The order in which patches are "
220 "folded is significant; <command role=\"hg-cmd\">hg qfold a b</command> means "
221 "<quote>apply the current topmost patch, followed by <literal>a</literal>, "
222 "followed by <literal>b</literal></quote>."
223 msgstr ""
225 #. type: Content of: <book><appendix><sect1><sect2><para>
226 #: ../en/appB-mq-ref.xml:91
227 msgid ""
228 "The comments from the folded patches are appended to the comments of the "
229 "destination patch, with each block of comments separated by three asterisk "
230 "(<quote><literal>*</literal></quote>) characters. Use the <option role=\"hg-"
231 "ext-mq-cmd-qfold-opt\">-e</option> option to edit the commit message for the "
232 "combined patch/changeset after the folding has completed."
233 msgstr ""
235 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
236 #: ../en/appB-mq-ref.xml:101
237 msgid ""
238 "<option role=\"hg-ext-mq-cmd-qfold-opt\">-e</option>: Edit the commit message "
239 "and patch description for the newly folded patch."
240 msgstr ""
242 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
243 #: ../en/appB-mq-ref.xml:106
244 msgid ""
245 "<option role=\"hg-ext-mq-cmd-qfold-opt\">-l</option>: Use the contents of the "
246 "given file as the new commit message and patch description for the folded "
247 "patch."
248 msgstr ""
250 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
251 #: ../en/appB-mq-ref.xml:111
252 msgid ""
253 "<option role=\"hg-ext-mq-cmd-qfold-opt\">-m</option>: Use the given text as "
254 "the new commit message and patch description for the folded patch."
255 msgstr ""
257 #. type: Content of: <book><appendix><sect1><sect2><title>
258 #: ../en/appB-mq-ref.xml:119
259 msgid ""
260 "<command role=\"hg-ext-mq\">qheader</command>&emdash;display the header/"
261 "description of a patch"
262 msgstr "<command role=\"hg-ext-mq\">qheader</command>—显示补丁头部描述"
264 #. type: Content of: <book><appendix><sect1><sect2><para>
265 #: ../en/appB-mq-ref.xml:123
266 msgid ""
267 "The <command role=\"hg-ext-mq\">qheader</command> command prints the header, "
268 "or description, of a patch. By default, it prints the header of the topmost "
269 "applied patch. Given an argument, it prints the header of the named patch."
270 msgstr ""
272 #. type: Content of: <book><appendix><sect1><sect2><title>
273 #: ../en/appB-mq-ref.xml:130
274 msgid ""
275 "<command role=\"hg-ext-mq\">qimport</command>&emdash;import a third-party "
276 "patch into the queue"
277 msgstr "<command role=\"hg-ext-mq\">qimport</command>—将第三方补丁导入队列"
279 #. type: Content of: <book><appendix><sect1><sect2><para>
280 #: ../en/appB-mq-ref.xml:133
281 msgid ""
282 "The <command role=\"hg-ext-mq\">qimport</command> command adds an entry for "
283 "an external patch to the <filename role=\"special\">series</filename> file, "
284 "and copies the patch into the <filename role=\"special\" class=\"directory\">."
285 "hg/patches</filename> directory. It adds the entry immediately after the "
286 "topmost applied patch, but does not push the patch."
287 msgstr ""
289 #. type: Content of: <book><appendix><sect1><sect2><para>
290 #: ../en/appB-mq-ref.xml:141
291 msgid ""
292 "If the <filename role=\"special\" class=\"directory\">.hg/patches</filename> "
293 "directory is a repository, <command role=\"hg-ext-mq\">qimport</command> "
294 "automatically does an <command role=\"hg-cmd\">hg add</command> of the "
295 "imported patch."
296 msgstr ""
298 #. type: Content of: <book><appendix><sect1><sect2><title>
299 #: ../en/appB-mq-ref.xml:149
300 msgid ""
301 "<command role=\"hg-ext-mq\">qinit</command>&emdash;prepare a repository to "
302 "work with MQ"
303 msgstr "<command role=\"hg-ext-mq\">qinit</command>—为使用 MQ 配置版本库"
305 #. type: Content of: <book><appendix><sect1><sect2><para>
306 #: ../en/appB-mq-ref.xml:152
307 msgid ""
308 "The <command role=\"hg-ext-mq\">qinit</command> command prepares a repository "
309 "to work with MQ. It creates a directory called <filename role=\"special\" "
310 "class=\"directory\">.hg/patches</filename>."
311 msgstr ""
313 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
314 #: ../en/appB-mq-ref.xml:159
315 msgid ""
316 "<option role=\"hg-ext-mq-cmd-qinit-opt\">-c</option>: Create <filename role="
317 "\"special\" class=\"directory\">.hg/patches</filename> as a repository in its "
318 "own right. Also creates a <filename role=\"special\">.hgignore</filename> "
319 "file that will ignore the <filename role=\"special\">status</filename> file."
320 msgstr ""
322 #. type: Content of: <book><appendix><sect1><sect2><para>
323 #: ../en/appB-mq-ref.xml:169
324 msgid ""
325 "When the <filename role=\"special\" class=\"directory\">.hg/patches</"
326 "filename> directory is a repository, the <command role=\"hg-ext-mq\">qimport</"
327 "command> and <command role=\"hg-ext-mq\">qnew</command> commands "
328 "automatically <command role=\"hg-cmd\">hg add</command> new patches."
329 msgstr ""
331 #. type: Content of: <book><appendix><sect1><sect2><title>
332 #: ../en/appB-mq-ref.xml:178
333 msgid "<command role=\"hg-ext-mq\">qnew</command>&emdash;create a new patch"
334 msgstr "<command role=\"hg-ext-mq\">qnew</command>—创建新补丁"
336 #. type: Content of: <book><appendix><sect1><sect2><para>
337 #: ../en/appB-mq-ref.xml:181
338 msgid ""
339 "The <command role=\"hg-ext-mq\">qnew</command> command creates a new patch. "
340 "It takes one mandatory argument, the name to use for the patch file. The "
341 "newly created patch is created empty by default. It is added to the "
342 "<filename role=\"special\">series</filename> file after the current topmost "
343 "applied patch, and is immediately pushed on top of that patch."
344 msgstr ""
346 #. type: Content of: <book><appendix><sect1><sect2><para>
347 #: ../en/appB-mq-ref.xml:189
348 msgid ""
349 "If <command role=\"hg-ext-mq\">qnew</command> finds modified files in the "
350 "working directory, it will refuse to create a new patch unless the <option "
351 "role=\"hg-ext-mq-cmd-qnew-opt\">-f</option> option is used (see below). This "
352 "behavior allows you to <command role=\"hg-ext-mq\">qrefresh</command> your "
353 "topmost applied patch before you apply a new patch on top of it."
354 msgstr ""
356 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
357 #: ../en/appB-mq-ref.xml:199
358 msgid ""
359 "<option role=\"hg-ext-mq-cmd-qnew-opt\">-f</option>: Create a new patch if "
360 "the contents of the working directory are modified. Any outstanding "
361 "modifications are added to the newly created patch, so after this command "
362 "completes, the working directory will no longer be modified."
363 msgstr ""
365 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
366 #: ../en/appB-mq-ref.xml:206
367 msgid ""
368 "<option role=\"hg-ext-mq-cmd-qnew-opt\">-m</option>: Use the given text as "
369 "the commit message. This text will be stored at the beginning of the patch "
370 "file, before the patch data."
371 msgstr ""
373 #. type: Content of: <book><appendix><sect1><sect2><title>
374 #: ../en/appB-mq-ref.xml:215
375 msgid ""
376 "<command role=\"hg-ext-mq\">qnext</command>&emdash;print the name of the next "
377 "patch"
378 msgstr "<command role=\"hg-ext-mq\">qnext</command>—显示下个补丁的名称"
380 #. type: Content of: <book><appendix><sect1><sect2><para>
381 #: ../en/appB-mq-ref.xml:218
382 msgid ""
383 "The <command role=\"hg-ext-mq\">qnext</command> command prints the name name "
384 "of the next patch in the <filename role=\"special\">series</filename> file "
385 "after the topmost applied patch. This patch will become the topmost applied "
386 "patch if you run <command role=\"hg-ext-mq\">qpush</command>."
387 msgstr ""
389 #. type: Content of: <book><appendix><sect1><sect2><title>
390 #: ../en/appB-mq-ref.xml:227
391 msgid ""
392 "<command role=\"hg-ext-mq\">qpop</command>&emdash;pop patches off the stack"
393 msgstr "<command role=\"hg-ext-mq\">qpop</command>—删除堆栈顶部的补丁"
395 #. type: Content of: <book><appendix><sect1><sect2><para>
396 #: ../en/appB-mq-ref.xml:230
397 msgid ""
398 "The <command role=\"hg-ext-mq\">qpop</command> command removes applied "
399 "patches from the top of the stack of applied patches. By default, it removes "
400 "only one patch."
401 msgstr ""
403 #. type: Content of: <book><appendix><sect1><sect2><para>
404 #: ../en/appB-mq-ref.xml:234
405 msgid ""
406 "This command removes the changesets that represent the popped patches from "
407 "the repository, and updates the working directory to undo the effects of the "
408 "patches."
409 msgstr ""
411 #. type: Content of: <book><appendix><sect1><sect2><para>
412 #: ../en/appB-mq-ref.xml:238
413 msgid ""
414 "This command takes an optional argument, which it uses as the name or index "
415 "of the patch to pop to. If given a name, it will pop patches until the named "
416 "patch is the topmost applied patch. If given a number, <command role=\"hg-"
417 "ext-mq\">qpop</command> treats the number as an index into the entries in the "
418 "series file, counting from zero (empty lines and lines containing only "
419 "comments do not count). It pops patches until the patch identified by the "
420 "given index is the topmost applied patch."
421 msgstr ""
423 #. type: Content of: <book><appendix><sect1><sect2><para>
424 #: ../en/appB-mq-ref.xml:248
425 msgid ""
426 "The <command role=\"hg-ext-mq\">qpop</command> command does not read or write "
427 "patches or the <filename role=\"special\">series</filename> file. It is thus "
428 "safe to <command role=\"hg-ext-mq\">qpop</command> a patch that you have "
429 "removed from the <filename role=\"special\">series</filename> file, or a "
430 "patch that you have renamed or deleted entirely. In the latter two cases, "
431 "use the name of the patch as it was when you applied it."
432 msgstr ""
434 #. type: Content of: <book><appendix><sect1><sect2><para>
435 #: ../en/appB-mq-ref.xml:257
436 msgid ""
437 "By default, the <command role=\"hg-ext-mq\">qpop</command> command will not "
438 "pop any patches if the working directory has been modified. You can override "
439 "this behavior using the <option role=\"hg-ext-mq-cmd-qpop-opt\">-f</option> "
440 "option, which reverts all modifications in the working directory."
441 msgstr ""
443 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
444 #: ../en/appB-mq-ref.xml:266
445 msgid ""
446 "<option role=\"hg-ext-mq-cmd-qpop-opt\">-a</option>: Pop all applied "
447 "patches. This returns the repository to its state before you applied any "
448 "patches."
449 msgstr ""
451 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
452 #: ../en/appB-mq-ref.xml:271
453 msgid ""
454 "<option role=\"hg-ext-mq-cmd-qpop-opt\">-f</option>: Forcibly revert any "
455 "modifications to the working directory when popping."
456 msgstr ""
458 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
459 #: ../en/appB-mq-ref.xml:276
460 msgid ""
461 "<option role=\"hg-ext-mq-cmd-qpop-opt\">-n</option>: Pop a patch from the "
462 "named queue."
463 msgstr ""
465 #. type: Content of: <book><appendix><sect1><sect2><para>
466 #: ../en/appB-mq-ref.xml:281
467 msgid ""
468 "The <command role=\"hg-ext-mq\">qpop</command> command removes one line from "
469 "the end of the <filename role=\"special\">status</filename> file for each "
470 "patch that it pops."
471 msgstr ""
473 #. type: Content of: <book><appendix><sect1><sect2><title>
474 #: ../en/appB-mq-ref.xml:288
475 msgid ""
476 "<command role=\"hg-ext-mq\">qprev</command>&emdash;print the name of the "
477 "previous patch"
478 msgstr "<command role=\"hg-ext-mq\">qprev</command>—显示上个补丁的名称"
480 #. type: Content of: <book><appendix><sect1><sect2><para>
481 #: ../en/appB-mq-ref.xml:291
482 msgid ""
483 "The <command role=\"hg-ext-mq\">qprev</command> command prints the name of "
484 "the patch in the <filename role=\"special\">series</filename> file that comes "
485 "before the topmost applied patch. This will become the topmost applied patch "
486 "if you run <command role=\"hg-ext-mq\">qpop</command>."
487 msgstr ""
489 #. type: Content of: <book><appendix><sect1><sect2><title>
490 #: ../en/appB-mq-ref.xml:300
491 msgid ""
492 "<command role=\"hg-ext-mq\">qpush</command>&emdash;push patches onto the stack"
493 msgstr "<command role=\"hg-ext-mq\">qpush</command>—增加补丁到堆栈"
495 #. type: Content of: <book><appendix><sect1><sect2><para>
496 #: ../en/appB-mq-ref.xml:303
497 msgid ""
498 "The <command role=\"hg-ext-mq\">qpush</command> command adds patches onto the "
499 "applied stack. By default, it adds only one patch."
500 msgstr ""
502 #. type: Content of: <book><appendix><sect1><sect2><para>
503 #: ../en/appB-mq-ref.xml:307
504 msgid ""
505 "This command creates a new changeset to represent each applied patch, and "
506 "updates the working directory to apply the effects of the patches."
507 msgstr ""
509 #. type: Content of: <book><appendix><sect1><sect2><para>
510 #: ../en/appB-mq-ref.xml:311
511 msgid "The default data used when creating a changeset are as follows:"
512 msgstr ""
514 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
515 #: ../en/appB-mq-ref.xml:314
516 msgid ""
517 "The commit date and time zone are the current date and time zone. Because "
518 "these data are used to compute the identity of a changeset, this means that "
519 "if you <command role=\"hg-ext-mq\">qpop</command> a patch and <command role="
520 "\"hg-ext-mq\">qpush</command> it again, the changeset that you push will have "
521 "a different identity than the changeset you popped."
522 msgstr ""
524 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
525 #: ../en/appB-mq-ref.xml:322
526 msgid ""
527 "The author is the same as the default used by the <command role=\"hg-cmd\">hg "
528 "commit</command> command."
529 msgstr ""
531 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
532 #: ../en/appB-mq-ref.xml:326
533 msgid ""
534 "The commit message is any text from the patch file that comes before the "
535 "first diff header. If there is no such text, a default commit message is "
536 "used that identifies the name of the patch."
537 msgstr ""
539 #. type: Content of: <book><appendix><sect1><sect2><para>
540 #: ../en/appB-mq-ref.xml:331
541 msgid ""
542 "If a patch contains a Mercurial patch header (XXX add link), the information "
543 "in the patch header overrides these defaults."
544 msgstr ""
546 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
547 #: ../en/appB-mq-ref.xml:337
548 msgid ""
549 "<option role=\"hg-ext-mq-cmd-qpush-opt\">-a</option>: Push all unapplied "
550 "patches from the <filename role=\"special\">series</filename> file until "
551 "there are none left to push."
552 msgstr ""
554 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
555 #: ../en/appB-mq-ref.xml:343
556 msgid ""
557 "<option role=\"hg-ext-mq-cmd-qpush-opt\">-l</option>: Add the name of the "
558 "patch to the end of the commit message."
559 msgstr ""
561 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
562 #: ../en/appB-mq-ref.xml:347
563 msgid ""
564 "<option role=\"hg-ext-mq-cmd-qpush-opt\">-m</option>: If a patch fails to "
565 "apply cleanly, use the entry for the patch in another saved queue to compute "
566 "the parameters for a three-way merge, and perform a three-way merge using the "
567 "normal Mercurial merge machinery. Use the resolution of the merge as the new "
568 "patch content."
569 msgstr ""
571 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
572 #: ../en/appB-mq-ref.xml:355
573 msgid ""
574 "<option role=\"hg-ext-mq-cmd-qpush-opt\">-n</option>: Use the named queue if "
575 "merging while pushing."
576 msgstr ""
578 #. type: Content of: <book><appendix><sect1><sect2><para>
579 #: ../en/appB-mq-ref.xml:360
580 msgid ""
581 "The <command role=\"hg-ext-mq\">qpush</command> command reads, but does not "
582 "modify, the <filename role=\"special\">series</filename> file. It appends "
583 "one line to the <command role=\"hg-cmd\">hg status</command> file for each "
584 "patch that it pushes."
585 msgstr ""
587 #. type: Content of: <book><appendix><sect1><sect2><title>
588 #: ../en/appB-mq-ref.xml:368
589 msgid ""
590 "<command role=\"hg-ext-mq\">qrefresh</command>&emdash;update the topmost "
591 "applied patch"
592 msgstr "<command role=\"hg-ext-mq\">qrefresh</command>—更新最新的补丁"
594 #. type: Content of: <book><appendix><sect1><sect2><para>
595 #: ../en/appB-mq-ref.xml:372
596 msgid ""
597 "The <command role=\"hg-ext-mq\">qrefresh</command> command updates the "
598 "topmost applied patch. It modifies the patch, removes the old changeset that "
599 "represented the patch, and creates a new changeset to represent the modified "
600 "patch."
601 msgstr ""
603 #. type: Content of: <book><appendix><sect1><sect2><para>
604 #: ../en/appB-mq-ref.xml:378
605 msgid ""
606 "The <command role=\"hg-ext-mq\">qrefresh</command> command looks for the "
607 "following modifications:"
608 msgstr ""
610 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
611 #: ../en/appB-mq-ref.xml:381
612 msgid ""
613 "Changes to the commit message, i.e. the text before the first diff header in "
614 "the patch file, are reflected in the new changeset that represents the patch."
615 msgstr ""
617 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
618 #: ../en/appB-mq-ref.xml:386
619 msgid ""
620 "Modifications to tracked files in the working directory are added to the "
621 "patch."
622 msgstr ""
624 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
625 #: ../en/appB-mq-ref.xml:389
626 msgid ""
627 "Changes to the files tracked using <command role=\"hg-cmd\">hg add</command>, "
628 "<command role=\"hg-cmd\">hg copy</command>, <command role=\"hg-cmd\">hg "
629 "remove</command>, or <command role=\"hg-cmd\">hg rename</command>. Added "
630 "files and copy and rename destinations are added to the patch, while removed "
631 "files and rename sources are removed."
632 msgstr ""
634 #. type: Content of: <book><appendix><sect1><sect2><para>
635 #: ../en/appB-mq-ref.xml:398
636 msgid ""
637 "Even if <command role=\"hg-ext-mq\">qrefresh</command> detects no changes, it "
638 "still recreates the changeset that represents the patch. This causes the "
639 "identity of the changeset to differ from the previous changeset that "
640 "identified the patch."
641 msgstr ""
643 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
644 #: ../en/appB-mq-ref.xml:406
645 msgid ""
646 "<option role=\"hg-ext-mq-cmd-qrefresh-opt\">-e</option>: Modify the commit "
647 "and patch description, using the preferred text editor."
648 msgstr ""
650 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
651 #: ../en/appB-mq-ref.xml:411
652 msgid ""
653 "<option role=\"hg-ext-mq-cmd-qrefresh-opt\">-m</option>: Modify the commit "
654 "message and patch description, using the given text."
655 msgstr ""
657 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
658 #: ../en/appB-mq-ref.xml:416
659 msgid ""
660 "<option role=\"hg-ext-mq-cmd-qrefresh-opt\">-l</option>: Modify the commit "
661 "message and patch description, using text from the given file."
662 msgstr ""
664 #. type: Content of: <book><appendix><sect1><sect2><title>
665 #: ../en/appB-mq-ref.xml:424
666 msgid "<command role=\"hg-ext-mq\">qrename</command>&emdash;rename a patch"
667 msgstr "<command role=\"hg-ext-mq\">qrename</command>—改名补丁"
669 #. type: Content of: <book><appendix><sect1><sect2><para>
670 #: ../en/appB-mq-ref.xml:427
671 msgid ""
672 "The <command role=\"hg-ext-mq\">qrename</command> command renames a patch, "
673 "and changes the entry for the patch in the <filename role=\"special\">series</"
674 "filename> file."
675 msgstr ""
677 #. type: Content of: <book><appendix><sect1><sect2><para>
678 #: ../en/appB-mq-ref.xml:431
679 msgid ""
680 "With a single argument, <command role=\"hg-ext-mq\">qrename</command> renames "
681 "the topmost applied patch. With two arguments, it renames its first argument "
682 "to its second."
683 msgstr ""
685 #. type: Content of: <book><appendix><sect1><sect2><title>
686 #: ../en/appB-mq-ref.xml:438
687 msgid ""
688 "<command role=\"hg-ext-mq\">qrestore</command>&emdash;restore saved queue "
689 "state"
690 msgstr "<command role=\"hg-ext-mq\">qrestore</command>—恢复保存的队列"
692 #. type: Content of: <book><appendix><sect1><sect2><para>
693 #: ../en/appB-mq-ref.xml:442
694 msgid "XXX No idea what this does."
695 msgstr ""
697 #. type: Content of: <book><appendix><sect1><sect2><title>
698 #: ../en/appB-mq-ref.xml:446
699 msgid ""
700 "<command role=\"hg-ext-mq\">qsave</command>&emdash;save current queue state"
701 msgstr "<command role=\"hg-ext-mq\">qsave</command>—保存当前的队列状态"
703 #. type: Content of: <book><appendix><sect1><sect2><para>
704 #: ../en/appB-mq-ref.xml:449
705 msgid "XXX Likewise."
706 msgstr ""
708 #. type: Content of: <book><appendix><sect1><sect2><title>
709 #: ../en/appB-mq-ref.xml:453
710 msgid ""
711 "<command role=\"hg-ext-mq\">qseries</command>&emdash;print the entire patch "
712 "series"
713 msgstr "<command role=\"hg-ext-mq\">qseries</command>—显示补丁序列"
715 #. type: Content of: <book><appendix><sect1><sect2><para>
716 #: ../en/appB-mq-ref.xml:456
717 msgid ""
718 "The <command role=\"hg-ext-mq\">qseries</command> command prints the entire "
719 "patch series from the <filename role=\"special\">series</filename> file. It "
720 "prints only patch names, not empty lines or comments. It prints in order "
721 "from first to be applied to last."
722 msgstr ""
724 #. type: Content of: <book><appendix><sect1><sect2><title>
725 #: ../en/appB-mq-ref.xml:464
726 msgid ""
727 "<command role=\"hg-ext-mq\">qtop</command>&emdash;print the name of the "
728 "current patch"
729 msgstr "<command role=\"hg-ext-mq\">qtop</command>—显示当前补丁的名称"
731 #. type: Content of: <book><appendix><sect1><sect2><para>
732 #: ../en/appB-mq-ref.xml:467
733 msgid ""
734 "The <command role=\"hg-ext-mq\">qtop</command> prints the name of the topmost "
735 "currently applied patch."
736 msgstr ""
738 #. type: Content of: <book><appendix><sect1><sect2><title>
739 #: ../en/appB-mq-ref.xml:472
740 msgid ""
741 "<command role=\"hg-ext-mq\">qunapplied</command>&emdash;print patches not yet "
742 "applied"
743 msgstr "<command role=\"hg-ext-mq\">qunapplied</command>—显示尚未应用的补丁"
745 #. type: Content of: <book><appendix><sect1><sect2><para>
746 #: ../en/appB-mq-ref.xml:476
747 msgid ""
748 "The <command role=\"hg-ext-mq\">qunapplied</command> command prints the names "
749 "of patches from the <filename role=\"special\">series</filename> file that "
750 "are not yet applied. It prints them in order from the next patch that will "
751 "be pushed to the last."
752 msgstr ""
754 #. type: Content of: <book><appendix><sect1><sect2><title>
755 #: ../en/appB-mq-ref.xml:484
756 msgid ""
757 "<command role=\"hg-cmd\">hg strip</command>&emdash;remove a revision and "
758 "descendants"
759 msgstr "<command role=\"hg-cmd\">hg strip</command>—删除一个版本及其后继"
761 #. type: Content of: <book><appendix><sect1><sect2><para>
762 #: ../en/appB-mq-ref.xml:487
763 msgid ""
764 "The <command role=\"hg-cmd\">hg strip</command> command removes a revision, "
765 "and all of its descendants, from the repository. It undoes the effects of "
766 "the removed revisions from the repository, and updates the working directory "
767 "to the first parent of the removed revision."
768 msgstr ""
770 #. type: Content of: <book><appendix><sect1><sect2><para>
771 #: ../en/appB-mq-ref.xml:493
772 msgid ""
773 "The <command role=\"hg-cmd\">hg strip</command> command saves a backup of the "
774 "removed changesets in a bundle, so that they can be reapplied if removed in "
775 "error."
776 msgstr ""
778 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
779 #: ../en/appB-mq-ref.xml:499
780 msgid ""
781 "<option role=\"hg-opt-strip\">-b</option>: Save unrelated changesets that are "
782 "intermixed with the stripped changesets in the backup bundle."
783 msgstr ""
785 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
786 #: ../en/appB-mq-ref.xml:503
787 msgid ""
788 "<option role=\"hg-opt-strip\">-f</option>: If a branch has multiple heads, "
789 "remove all heads. XXX This should be renamed, and use <literal>-f</literal> "
790 "to strip revs when there are pending changes."
791 msgstr ""
793 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
794 #: ../en/appB-mq-ref.xml:508
795 msgid "<option role=\"hg-opt-strip\">-n</option>: Do not save a backup bundle."
796 msgstr ""
798 #. type: Content of: <book><appendix><sect1><title>
799 #: ../en/appB-mq-ref.xml:515
800 msgid "MQ file reference"
801 msgstr "MQ 文件参考"
803 #. type: Content of: <book><appendix><sect1><sect2><title>
804 #: ../en/appB-mq-ref.xml:518
805 msgid "The <filename role=\"special\">series</filename> file"
806 msgstr "<filename role=\"special\">序列</filename>文件"
808 #. type: Content of: <book><appendix><sect1><sect2><para>
809 #: ../en/appB-mq-ref.xml:521
810 msgid ""
811 "The <filename role=\"special\">series</filename> file contains a list of the "
812 "names of all patches that MQ can apply. It is represented as a list of "
813 "names, with one name saved per line. Leading and trailing white space in "
814 "each line are ignored."
815 msgstr ""
817 #. type: Content of: <book><appendix><sect1><sect2><para>
818 #: ../en/appB-mq-ref.xml:527
819 msgid ""
820 "Lines may contain comments. A comment begins with the <quote><literal>#</"
821 "literal></quote> character, and extends to the end of the line. Empty lines, "
822 "and lines that contain only comments, are ignored."
823 msgstr ""
825 #. type: Content of: <book><appendix><sect1><sect2><para>
826 #: ../en/appB-mq-ref.xml:532
827 msgid ""
828 "You will often need to edit the <filename role=\"special\">series</filename> "
829 "file by hand, hence the support for comments and empty lines noted above. "
830 "For example, you can comment out a patch temporarily, and <command role=\"hg-"
831 "ext-mq\">qpush</command> will skip over that patch when applying patches. "
832 "You can also change the order in which patches are applied by reordering "
833 "their entries in the <filename role=\"special\">series</filename> file."
834 msgstr ""
836 #. type: Content of: <book><appendix><sect1><sect2><para>
837 #: ../en/appB-mq-ref.xml:541
838 msgid ""
839 "Placing the <filename role=\"special\">series</filename> file under revision "
840 "control is also supported; it is a good idea to place all of the patches that "
841 "it refers to under revision control, as well. If you create a patch "
842 "directory using the <option role=\"hg-ext-mq-cmd-qinit-opt\">-c</option> "
843 "option to <command role=\"hg-ext-mq\">qinit</command>, this will be done for "
844 "you automatically."
845 msgstr ""
847 #. type: Content of: <book><appendix><sect1><sect2><title>
848 #: ../en/appB-mq-ref.xml:551
849 msgid "The <filename role=\"special\">status</filename> file"
850 msgstr "<filename role=\"special\">状态</filename>文件"
852 #. type: Content of: <book><appendix><sect1><sect2><para>
853 #: ../en/appB-mq-ref.xml:554
854 msgid ""
855 "The <filename role=\"special\">status</filename> file contains the names and "
856 "changeset hashes of all patches that MQ currently has applied. Unlike the "
857 "<filename role=\"special\">series</filename> file, this file is not intended "
858 "for editing. You should not place this file under revision control, or "
859 "modify it in any way. It is used by MQ strictly for internal book-keeping."
860 msgstr ""
862 #. type: Content of: <book><appendix><title>
863 #: ../en/appC-srcinstall.xml:5
864 msgid "Installing Mercurial from source"
865 msgstr "从源代码安装 Mercurial"
867 #. type: Content of: <book><appendix><sect1><title>
868 #: ../en/appC-srcinstall.xml:8
869 msgid "On a Unix-like system"
870 msgstr "类 Unix 系统"
872 #. type: Content of: <book><appendix><sect1><para>
873 #: ../en/appC-srcinstall.xml:10
874 msgid ""
875 "If you are using a Unix-like system that has a sufficiently recent version of "
876 "Python (2.3 or newer) available, it is easy to install Mercurial from source."
877 msgstr ""
879 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
880 #: ../en/appC-srcinstall.xml:14
881 msgid ""
882 "Download a recent source tarball from <ulink url=\"http://www.selenic.com/"
883 "mercurial/download\">http://www.selenic.com/mercurial/download</ulink>."
884 msgstr ""
886 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
887 #: ../en/appC-srcinstall.xml:17
888 msgid "Unpack the tarball:"
889 msgstr ""
891 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
892 #: ../en/appC-srcinstall.xml:20
893 msgid ""
894 "Go into the source directory and run the installer script. This will build "
895 "Mercurial and install it in your home directory."
896 msgstr ""
898 #. type: Content of: <book><appendix><sect1><para>
899 #: ../en/appC-srcinstall.xml:27
900 msgid ""
901 "Once the install finishes, Mercurial will be in the <literal>bin</literal> "
902 "subdirectory of your home directory. Don't forget to make sure that this "
903 "directory is present in your shell's search path."
904 msgstr ""
906 #. type: Content of: <book><appendix><sect1><para>
907 #: ../en/appC-srcinstall.xml:32
908 msgid ""
909 "You will probably need to set the <envar>PYTHONPATH</envar> environment "
910 "variable so that the Mercurial executable can find the rest of the Mercurial "
911 "packages. For example, on my laptop, I have set it to <literal>/home/bos/lib/"
912 "python</literal>. The exact path that you will need to use depends on how "
913 "Python was built for your system, but should be easy to figure out. If "
914 "you're uncertain, look through the output of the installer script above, and "
915 "see where the contents of the <literal>mercurial</literal> directory were "
916 "installed to."
917 msgstr ""
919 #. type: Content of: <book><appendix><sect1><title>
920 #: ../en/appC-srcinstall.xml:44
921 msgid "On Windows"
922 msgstr "Windows 系统"
924 #. type: Content of: <book><appendix><sect1><para>
925 #: ../en/appC-srcinstall.xml:46
926 msgid ""
927 "Building and installing Mercurial on Windows requires a variety of tools, a "
928 "fair amount of technical knowledge, and considerable patience. I very much "
929 "<emphasis>do not recommend</emphasis> this route if you are a <quote>casual "
930 "user</quote>. Unless you intend to hack on Mercurial, I strongly suggest "
931 "that you use a binary package instead."
932 msgstr ""
934 #. type: Content of: <book><appendix><sect1><para>
935 #: ../en/appC-srcinstall.xml:53
936 msgid ""
937 "If you are intent on building Mercurial from source on Windows, follow the "
938 "<quote>hard way</quote> directions on the Mercurial wiki at <ulink url="
939 "\"http://www.selenic.com/mercurial/wiki/index.cgi/WindowsInstall\">http://www."
940 "selenic.com/mercurial/wiki/index.cgi/WindowsInstall</ulink>, and expect the "
941 "process to involve a lot of fiddly work."
942 msgstr ""
944 #. type: Content of: <book><appendix><title>
945 #: ../en/appD-license.xml:5
946 msgid "Open Publication License"
947 msgstr ""
949 #. type: Content of: <book><appendix><para>
950 #: ../en/appD-license.xml:7
951 msgid "Version 1.0, 8 June 1999"
952 msgstr ""
954 #. type: Content of: <book><appendix><sect1><title>
955 #: ../en/appD-license.xml:10
956 msgid "Requirements on both unmodified and modified versions"
957 msgstr ""
959 #. type: Content of: <book><appendix><sect1><para>
960 #: ../en/appD-license.xml:13
961 msgid ""
962 "The Open Publication works may be reproduced and distributed in whole or in "
963 "part, in any medium physical or electronic, provided that the terms of this "
964 "license are adhered to, and that this license or an incorporation of it by "
965 "reference (with any options elected by the author(s) and/or publisher) is "
966 "displayed in the reproduction."
967 msgstr ""
969 #. type: Content of: <book><appendix><sect1><para>
970 #: ../en/appD-license.xml:20
971 msgid "Proper form for an incorporation by reference is as follows:"
972 msgstr ""
974 #. type: Content of: <book><appendix><sect1><blockquote><para>
975 #: ../en/appD-license.xml:24
976 msgid ""
977 "Copyright (c) <emphasis>year</emphasis> by <emphasis>author's name or "
978 "designee</emphasis>. This material may be distributed only subject to the "
979 "terms and conditions set forth in the Open Publication License, v<emphasis>x."
980 "y</emphasis> or later (the latest version is presently available at <ulink "
981 "url=\"http://www.opencontent.org/openpub/\">http://www.opencontent.org/"
982 "openpub/</ulink>)."
983 msgstr ""
985 #. type: Content of: <book><appendix><sect1><para>
986 #: ../en/appD-license.xml:33
987 msgid ""
988 "The reference must be immediately followed with any options elected by the "
989 "author(s) and/or publisher of the document (see <xref linkend=\"sec:opl:"
990 "options\"/>)."
991 msgstr ""
993 #. type: Content of: <book><appendix><sect1><para>
994 #: ../en/appD-license.xml:37
995 msgid ""
996 "Commercial redistribution of Open Publication-licensed material is permitted."
997 msgstr ""
999 #. type: Content of: <book><appendix><sect1><para>
1000 #: ../en/appD-license.xml:40
1001 msgid ""
1002 "Any publication in standard (paper) book form shall require the citation of "
1003 "the original publisher and author. The publisher and author's names shall "
1004 "appear on all outer surfaces of the book. On all outer surfaces of the book "
1005 "the original publisher's name shall be as large as the title of the work and "
1006 "cited as possessive with respect to the title."
1007 msgstr ""
1009 #. type: Content of: <book><appendix><sect1><title>
1010 #: ../en/appD-license.xml:49
1011 msgid "Copyright"
1012 msgstr ""
1014 #. type: Content of: <book><appendix><sect1><para>
1015 #: ../en/appD-license.xml:51
1016 msgid ""
1017 "The copyright to each Open Publication is owned by its author(s) or designee."
1018 msgstr ""
1020 #. type: Content of: <book><appendix><sect1><title>
1021 #: ../en/appD-license.xml:56
1022 msgid "Scope of license"
1023 msgstr ""
1025 #. type: Content of: <book><appendix><sect1><para>
1026 #: ../en/appD-license.xml:58
1027 msgid ""
1028 "The following license terms apply to all Open Publication works, unless "
1029 "otherwise explicitly stated in the document."
1030 msgstr ""
1032 #. type: Content of: <book><appendix><sect1><para>
1033 #: ../en/appD-license.xml:62
1034 msgid ""
1035 "Mere aggregation of Open Publication works or a portion of an Open "
1036 "Publication work with other works or programs on the same media shall not "
1037 "cause this license to apply to those other works. The aggregate work shall "
1038 "contain a notice specifying the inclusion of the Open Publication material "
1039 "and appropriate copyright notice."
1040 msgstr ""
1042 #. type: Content of: <book><appendix><sect1><para>
1043 #: ../en/appD-license.xml:69
1044 msgid ""
1045 "<emphasis role=\"bold\">Severability</emphasis>. If any part of this license "
1046 "is found to be unenforceable in any jurisdiction, the remaining portions of "
1047 "the license remain in force."
1048 msgstr ""
1050 #. type: Content of: <book><appendix><sect1><para>
1051 #: ../en/appD-license.xml:74
1052 msgid ""
1053 "<emphasis role=\"bold\">No warranty</emphasis>. Open Publication works are "
1054 "licensed and provided <quote>as is</quote> without warranty of any kind, "
1055 "express or implied, including, but not limited to, the implied warranties of "
1056 "merchantability and fitness for a particular purpose or a warranty of non-"
1057 "infringement."
1058 msgstr ""
1060 #. type: Content of: <book><appendix><sect1><title>
1061 #: ../en/appD-license.xml:83
1062 msgid "Requirements on modified works"
1063 msgstr ""
1065 #. type: Content of: <book><appendix><sect1><para>
1066 #: ../en/appD-license.xml:85
1067 msgid ""
1068 "All modified versions of documents covered by this license, including "
1069 "translations, anthologies, compilations and partial documents, must meet the "
1070 "following requirements:"
1071 msgstr ""
1073 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1074 #: ../en/appD-license.xml:90
1075 msgid "The modified version must be labeled as such."
1076 msgstr ""
1078 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1079 #: ../en/appD-license.xml:93
1080 msgid ""
1081 "The person making the modifications must be identified and the modifications "
1082 "dated."
1083 msgstr ""
1085 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1086 #: ../en/appD-license.xml:96
1087 msgid ""
1088 "Acknowledgement of the original author and publisher if applicable must be "
1089 "retained according to normal academic citation practices."
1090 msgstr ""
1092 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1093 #: ../en/appD-license.xml:100
1094 msgid "The location of the original unmodified document must be identified."
1095 msgstr ""
1097 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1098 #: ../en/appD-license.xml:103
1099 msgid ""
1100 "The original author's (or authors') name(s) may not be used to assert or "
1101 "imply endorsement of the resulting document without the original author's (or "
1102 "authors') permission."
1103 msgstr ""
1105 #. type: Content of: <book><appendix><sect1><title>
1106 #: ../en/appD-license.xml:111
1107 msgid "Good-practice recommendations"
1108 msgstr ""
1110 #. type: Content of: <book><appendix><sect1><para>
1111 #: ../en/appD-license.xml:113
1112 msgid ""
1113 "In addition to the requirements of this license, it is requested from and "
1114 "strongly recommended of redistributors that:"
1115 msgstr ""
1117 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1118 #: ../en/appD-license.xml:118
1119 msgid ""
1120 "If you are distributing Open Publication works on hardcopy or CD-ROM, you "
1121 "provide email notification to the authors of your intent to redistribute at "
1122 "least thirty days before your manuscript or media freeze, to give the authors "
1123 "time to provide updated documents. This notification should describe "
1124 "modifications, if any, made to the document."
1125 msgstr ""
1127 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1128 #: ../en/appD-license.xml:125
1129 msgid ""
1130 "All substantive modifications (including deletions) be either clearly marked "
1131 "up in the document or else described in an attachment to the document."
1132 msgstr ""
1134 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1135 #: ../en/appD-license.xml:129
1136 msgid ""
1137 "Finally, while it is not mandatory under this license, it is considered good "
1138 "form to offer a free copy of any hardcopy and CD-ROM expression of an Open "
1139 "Publication-licensed work to its author(s)."
1140 msgstr ""
1142 #. type: Content of: <book><appendix><sect1><title>
1143 #: ../en/appD-license.xml:137
1144 msgid "License options"
1145 msgstr ""
1147 #. type: Content of: <book><appendix><sect1><para>
1148 #: ../en/appD-license.xml:139
1149 msgid ""
1150 "The author(s) and/or publisher of an Open Publication-licensed document may "
1151 "elect certain options by appending language to the reference to or copy of "
1152 "the license. These options are considered part of the license instance and "
1153 "must be included with the license (or its incorporation by reference) in "
1154 "derived works."
1155 msgstr ""
1157 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1158 #: ../en/appD-license.xml:147
1159 msgid ""
1160 "To prohibit distribution of substantively modified versions without the "
1161 "explicit permission of the author(s). <quote>Substantive modification</quote> "
1162 "is defined as a change to the semantic content of the document, and excludes "
1163 "mere changes in format or typographical corrections."
1164 msgstr ""
1166 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1167 #: ../en/appD-license.xml:154
1168 msgid ""
1169 "To accomplish this, add the phrase <quote>Distribution of substantively "
1170 "modified versions of this document is prohibited without the explicit "
1171 "permission of the copyright holder.</quote> to the license reference or copy."
1172 msgstr ""
1174 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1175 #: ../en/appD-license.xml:160
1176 msgid ""
1177 "To prohibit any publication of this work or derivative works in whole or in "
1178 "part in standard (paper) book form for commercial purposes is prohibited "
1179 "unless prior permission is obtained from the copyright holder."
1180 msgstr ""
1182 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1183 #: ../en/appD-license.xml:165
1184 msgid ""
1185 "To accomplish this, add the phrase <quote>Distribution of the work or "
1186 "derivative of the work in any standard (paper) book form is prohibited unless "
1187 "prior permission is obtained from the copyright holder.</quote> to the "
1188 "license reference or copy."
1189 msgstr ""
1191 #. type: Content of: <book><preface><title>
1192 #: ../en/ch00-preface.xml:5
1193 msgid "Preface"
1194 msgstr "序言"
1196 #. type: Content of: <book><preface><sect1><title>
1197 #: ../en/ch00-preface.xml:8
1198 msgid "Why revision control? Why Mercurial?"
1199 msgstr "为什么使用版本控制? 为什么使用 Mercurial?"
1201 #. type: Content of: <book><preface><sect1><para>
1202 #: ../en/ch00-preface.xml:10
1203 msgid ""
1204 "Revision control is the process of managing multiple versions of a piece of "
1205 "information. In its simplest form, this is something that many people do by "
1206 "hand: every time you modify a file, save it under a new name that contains a "
1207 "number, each one higher than the number of the preceding version."
1208 msgstr ""
1210 #. type: Content of: <book><preface><sect1><para>
1211 #: ../en/ch00-preface.xml:16
1212 msgid ""
1213 "Manually managing multiple versions of even a single file is an error-prone "
1214 "task, though, so software tools to help automate this process have long been "
1215 "available. The earliest automated revision control tools were intended to "
1216 "help a single user to manage revisions of a single file. Over the past few "
1217 "decades, the scope of revision control tools has expanded greatly; they now "
1218 "manage multiple files, and help multiple people to work together. The best "
1219 "modern revision control tools have no problem coping with thousands of people "
1220 "working together on projects that consist of hundreds of thousands of files."
1221 msgstr ""
1223 #. type: Content of: <book><preface><sect1><para>
1224 #: ../en/ch00-preface.xml:27
1225 msgid ""
1226 "The arrival of distributed revision control is relatively recent, and so far "
1227 "this new field has grown due to people's willingness to explore ill-charted "
1228 "territory."
1229 msgstr ""
1231 #. type: Content of: <book><preface><sect1><para>
1232 #: ../en/ch00-preface.xml:31
1233 msgid ""
1234 "I am writing a book about distributed revision control because I believe that "
1235 "it is an important subject that deserves a field guide. I chose to write "
1236 "about Mercurial because it is the easiest tool to learn the terrain with, and "
1237 "yet it scales to the demands of real, challenging environments where many "
1238 "other revision control tools buckle."
1239 msgstr ""
1241 #. type: Content of: <book><preface><sect1><sect2><title>
1242 #: ../en/ch00-preface.xml:39
1243 msgid "Why use revision control?"
1244 msgstr "为什么使用版本控制?"
1246 #. type: Content of: <book><preface><sect1><sect2><para>
1247 #: ../en/ch00-preface.xml:41
1248 msgid ""
1249 "There are a number of reasons why you or your team might want to use an "
1250 "automated revision control tool for a project."
1251 msgstr ""
1253 #. type: Content of: <book><preface><sect1><sect2><itemizedlist><listitem><para>
1254 #: ../en/ch00-preface.xml:46
1255 msgid ""
1256 "It will track the history and evolution of your project, so you don't have "
1257 "to. For every change, you'll have a log of <emphasis>who</emphasis> made it; "
1258 "<emphasis>why</emphasis> they made it; <emphasis>when</emphasis> they made "
1259 "it; and <emphasis>what</emphasis> the change was."
1260 msgstr ""
1262 #. type: Content of: <book><preface><sect1><sect2><itemizedlist><listitem><para>
1263 #: ../en/ch00-preface.xml:53
1264 msgid ""
1265 "When you're working with other people, revision control software makes it "
1266 "easier for you to collaborate. For example, when people more or less "
1267 "simultaneously make potentially incompatible changes, the software will help "
1268 "you to identify and resolve those conflicts."
1269 msgstr ""
1271 #. type: Content of: <book><preface><sect1><sect2><itemizedlist><listitem><para>
1272 #: ../en/ch00-preface.xml:59
1273 msgid ""
1274 "It can help you to recover from mistakes. If you make a change that later "
1275 "turns out to be in error, you can revert to an earlier version of one or more "
1276 "files. In fact, a <emphasis>really</emphasis> good revision control tool "
1277 "will even help you to efficiently figure out exactly when a problem was "
1278 "introduced (see <xref linkend=\"sec:undo:bisect\"/> for details)."
1279 msgstr ""
1281 #. type: Content of: <book><preface><sect1><sect2><itemizedlist><listitem><para>
1282 #: ../en/ch00-preface.xml:66
1283 msgid ""
1284 "It will help you to work simultaneously on, and manage the drift between, "
1285 "multiple versions of your project."
1286 msgstr ""
1288 #. type: Content of: <book><preface><sect1><sect2><para>
1289 #: ../en/ch00-preface.xml:71
1290 msgid ""
1291 "Most of these reasons are equally valid&emdash;at least in theory&emdash;"
1292 "whether you're working on a project by yourself, or with a hundred other "
1293 "people."
1294 msgstr ""
1296 #. type: Content of: <book><preface><sect1><sect2><para>
1297 #: ../en/ch00-preface.xml:76
1298 msgid ""
1299 "A key question about the practicality of revision control at these two "
1300 "different scales (<quote>lone hacker</quote> and <quote>huge team</quote>) is "
1301 "how its <emphasis>benefits</emphasis> compare to its <emphasis>costs</"
1302 "emphasis>. A revision control tool that's difficult to understand or use is "
1303 "going to impose a high cost."
1304 msgstr ""
1306 #. type: Content of: <book><preface><sect1><sect2><para>
1307 #: ../en/ch00-preface.xml:84
1308 msgid ""
1309 "A five-hundred-person project is likely to collapse under its own weight "
1310 "almost immediately without a revision control tool and process. In this case, "
1311 "the cost of using revision control might hardly seem worth considering, since "
1312 "<emphasis>without</emphasis> it, failure is almost guaranteed."
1313 msgstr ""
1315 #. type: Content of: <book><preface><sect1><sect2><para>
1316 #: ../en/ch00-preface.xml:91
1317 msgid ""
1318 "On the other hand, a one-person <quote>quick hack</quote> might seem like a "
1319 "poor place to use a revision control tool, because surely the cost of using "
1320 "one must be close to the overall cost of the project. Right?"
1321 msgstr ""
1323 #. type: Content of: <book><preface><sect1><sect2><para>
1324 #: ../en/ch00-preface.xml:96
1325 msgid ""
1326 "Mercurial uniquely supports <emphasis>both</emphasis> of these scales of "
1327 "development. You can learn the basics in just a few minutes, and due to its "
1328 "low overhead, you can apply revision control to the smallest of projects with "
1329 "ease. Its simplicity means you won't have a lot of abstruse concepts or "
1330 "command sequences competing for mental space with whatever you're "
1331 "<emphasis>really</emphasis> trying to do. At the same time, Mercurial's high "
1332 "performance and peer-to-peer nature let you scale painlessly to handle large "
1333 "projects."
1334 msgstr ""
1336 #. type: Content of: <book><preface><sect1><sect2><para>
1337 #: ../en/ch00-preface.xml:106
1338 msgid ""
1339 "No revision control tool can rescue a poorly run project, but a good choice "
1340 "of tools can make a huge difference to the fluidity with which you can work "
1341 "on a project."
1342 msgstr ""
1344 #. type: Content of: <book><preface><sect1><sect2><title>
1345 #: ../en/ch00-preface.xml:113
1346 msgid "The many names of revision control"
1347 msgstr "版本控制的别名"
1349 #. type: Content of: <book><preface><sect1><sect2><para>
1350 #: ../en/ch00-preface.xml:115
1351 msgid ""
1352 "Revision control is a diverse field, so much so that it is referred to by "
1353 "many names and acronyms. Here are a few of the more common variations you'll "
1354 "encounter:"
1355 msgstr ""
1357 #. type: Content of: <book><preface><sect1><sect2><itemizedlist><listitem><para>
1358 #: ../en/ch00-preface.xml:119
1359 msgid "Revision control (RCS)"
1360 msgstr "版本控制(RCS)"
1362 #. type: Content of: <book><preface><sect1><sect2><itemizedlist><listitem><para>
1363 #: ../en/ch00-preface.xml:120
1364 msgid "Software configuration management (SCM), or configuration management"
1365 msgstr "软件配置管理(SCM),或配置管理"
1367 #. type: Content of: <book><preface><sect1><sect2><itemizedlist><listitem><para>
1368 #: ../en/ch00-preface.xml:122
1369 msgid "Source code management"
1370 msgstr "源代码管理"
1372 #. type: Content of: <book><preface><sect1><sect2><itemizedlist><listitem><para>
1373 #: ../en/ch00-preface.xml:123
1374 msgid "Source code control, or source control"
1375 msgstr "源代码控制,或源控制"
1377 #. type: Content of: <book><preface><sect1><sect2><itemizedlist><listitem><para>
1378 #: ../en/ch00-preface.xml:125
1379 msgid "Version control (VCS)"
1380 msgstr "版本控制(VCS)"
1382 #. type: Content of: <book><preface><sect1><sect2><para>
1383 #: ../en/ch00-preface.xml:127
1384 msgid ""
1385 "Some people claim that these terms actually have different meanings, but in "
1386 "practice they overlap so much that there's no agreed or even useful way to "
1387 "tease them apart."
1388 msgstr ""
1390 #. type: Content of: <book><preface><sect1><title>
1391 #: ../en/ch00-preface.xml:135
1392 msgid "This book is a work in progress"
1393 msgstr "本书正在编写中"
1395 #. type: Content of: <book><preface><sect1><para>
1396 #: ../en/ch00-preface.xml:137
1397 msgid ""
1398 "I am releasing this book while I am still writing it, in the hope that it "
1399 "will prove useful to others. I am writing under an open license in the hope "
1400 "that you, my readers, will contribute feedback and perhaps content of your "
1401 "own."
1402 msgstr ""
1404 #. type: Content of: <book><preface><sect1><title>
1405 #: ../en/ch00-preface.xml:144
1406 msgid "About the examples in this book"
1407 msgstr "本书的例子"
1409 #. type: Content of: <book><preface><sect1><para>
1410 #: ../en/ch00-preface.xml:146
1411 msgid ""
1412 "This book takes an unusual approach to code samples. Every example is "
1413 "<quote>live</quote>&emdash;each one is actually the result of a shell script "
1414 "that executes the Mercurial commands you see. Every time an image of the "
1415 "book is built from its sources, all the example scripts are automatically "
1416 "run, and their current results compared against their expected results."
1417 msgstr ""
1419 #. type: Content of: <book><preface><sect1><para>
1420 #: ../en/ch00-preface.xml:153
1421 msgid ""
1422 "The advantage of this approach is that the examples are always accurate; they "
1423 "describe <emphasis>exactly</emphasis> the behavior of the version of "
1424 "Mercurial that's mentioned at the front of the book. If I update the version "
1425 "of Mercurial that I'm documenting, and the output of some command changes, "
1426 "the build fails."
1427 msgstr ""
1429 #. type: Content of: <book><preface><sect1><para>
1430 #: ../en/ch00-preface.xml:160
1431 msgid ""
1432 "There is a small disadvantage to this approach, which is that the dates and "
1433 "times you'll see in examples tend to be <quote>squashed</quote> together in a "
1434 "way that they wouldn't be if the same commands were being typed by a human. "
1435 "Where a human can issue no more than one command every few seconds, with any "
1436 "resulting timestamps correspondingly spread out, my automated example scripts "
1437 "run many commands in one second."
1438 msgstr ""
1440 #. type: Content of: <book><preface><sect1><para>
1441 #: ../en/ch00-preface.xml:168
1442 msgid ""
1443 "As an instance of this, several consecutive commits in an example can show up "
1444 "as having occurred during the same second. You can see this occur in the "
1445 "<literal role=\"hg-ext\">bisect</literal> example in <xref linkend=\"sec:undo:"
1446 "bisect\"/>, for instance."
1447 msgstr ""
1449 #. type: Content of: <book><preface><sect1><para>
1450 #: ../en/ch00-preface.xml:174
1451 msgid ""
1452 "So when you're reading examples, don't place too much weight on the dates or "
1453 "times you see in the output of commands. But <emphasis>do</emphasis> be "
1454 "confident that the behavior you're seeing is consistent and reproducible."
1455 msgstr ""
1457 #. type: Content of: <book><preface><sect1><title>
1458 #: ../en/ch00-preface.xml:182
1459 msgid "Trends in the field"
1460 msgstr "版本控制的发展趋势"
1462 #. type: Content of: <book><preface><sect1><para>
1463 #: ../en/ch00-preface.xml:184
1464 msgid ""
1465 "There has been an unmistakable trend in the development and use of revision "
1466 "control tools over the past four decades, as people have become familiar with "
1467 "the capabilities of their tools and constrained by their limitations."
1468 msgstr ""
1470 #. type: Content of: <book><preface><sect1><para>
1471 #: ../en/ch00-preface.xml:189
1472 msgid ""
1473 "The first generation began by managing single files on individual computers. "
1474 "Although these tools represented a huge advance over ad-hoc manual revision "
1475 "control, their locking model and reliance on a single computer limited them "
1476 "to small, tightly-knit teams."
1477 msgstr ""
1479 #. type: Content of: <book><preface><sect1><para>
1480 #: ../en/ch00-preface.xml:195
1481 msgid ""
1482 "The second generation loosened these constraints by moving to network-"
1483 "centered architectures, and managing entire projects at a time. As projects "
1484 "grew larger, they ran into new problems. With clients needing to talk to "
1485 "servers very frequently, server scaling became an issue for large projects. "
1486 "An unreliable network connection could prevent remote users from being able "
1487 "to talk to the server at all. As open source projects started making read-"
1488 "only access available anonymously to anyone, people without commit privileges "
1489 "found that they could not use the tools to interact with a project in a "
1490 "natural way, as they could not record their changes."
1491 msgstr ""
1493 #. type: Content of: <book><preface><sect1><para>
1494 #: ../en/ch00-preface.xml:207
1495 msgid ""
1496 "The current generation of revision control tools is peer-to-peer in nature. "
1497 "All of these systems have dropped the dependency on a single central server, "
1498 "and allow people to distribute their revision control data to where it's "
1499 "actually needed. Collaboration over the Internet has moved from constrained "
1500 "by technology to a matter of choice and consensus. Modern tools can operate "
1501 "offline indefinitely and autonomously, with a network connection only needed "
1502 "when syncing changes with another repository."
1503 msgstr ""
1505 #. type: Content of: <book><preface><sect1><title>
1506 #: ../en/ch00-preface.xml:219
1507 msgid "A few of the advantages of distributed revision control"
1508 msgstr "分布版本控制的优点"
1510 #. type: Content of: <book><preface><sect1><para>
1511 #: ../en/ch00-preface.xml:222
1512 msgid ""
1513 "Even though distributed revision control tools have for several years been as "
1514 "robust and usable as their previous-generation counterparts, people using "
1515 "older tools have not yet necessarily woken up to their advantages. There are "
1516 "a number of ways in which distributed tools shine relative to centralised "
1517 "ones."
1518 msgstr ""
1520 #. type: Content of: <book><preface><sect1><para>
1521 #: ../en/ch00-preface.xml:229
1522 msgid ""
1523 "For an individual developer, distributed tools are almost always much faster "
1524 "than centralised tools. This is for a simple reason: a centralised tool "
1525 "needs to talk over the network for many common operations, because most "
1526 "metadata is stored in a single copy on the central server. A distributed "
1527 "tool stores all of its metadata locally. All else being equal, talking over "
1528 "the network adds overhead to a centralised tool. Don't underestimate the "
1529 "value of a snappy, responsive tool: you're going to spend a lot of time "
1530 "interacting with your revision control software."
1531 msgstr ""
1533 #. type: Content of: <book><preface><sect1><para>
1534 #: ../en/ch00-preface.xml:240
1535 msgid ""
1536 "Distributed tools are indifferent to the vagaries of your server "
1537 "infrastructure, again because they replicate metadata to so many locations. "
1538 "If you use a centralised system and your server catches fire, you'd better "
1539 "hope that your backup media are reliable, and that your last backup was "
1540 "recent and actually worked. With a distributed tool, you have many backups "
1541 "available on every contributor's computer."
1542 msgstr ""
1544 #. type: Content of: <book><preface><sect1><para>
1545 #: ../en/ch00-preface.xml:248
1546 msgid ""
1547 "The reliability of your network will affect distributed tools far less than "
1548 "it will centralised tools. You can't even use a centralised tool without a "
1549 "network connection, except for a few highly constrained commands. With a "
1550 "distributed tool, if your network connection goes down while you're working, "
1551 "you may not even notice. The only thing you won't be able to do is talk to "
1552 "repositories on other computers, something that is relatively rare compared "
1553 "with local operations. If you have a far-flung team of collaborators, this "
1554 "may be significant."
1555 msgstr ""
1557 #. type: Content of: <book><preface><sect1><sect2><title>
1558 #: ../en/ch00-preface.xml:259
1559 msgid "Advantages for open source projects"
1560 msgstr "开源项目的优点"
1562 #. type: Content of: <book><preface><sect1><sect2><para>
1563 #: ../en/ch00-preface.xml:261
1564 msgid ""
1565 "If you take a shine to an open source project and decide that you would like "
1566 "to start hacking on it, and that project uses a distributed revision control "
1567 "tool, you are at once a peer with the people who consider themselves the "
1568 "<quote>core</quote> of that project. If they publish their repositories, you "
1569 "can immediately copy their project history, start making changes, and record "
1570 "your work, using the same tools in the same ways as insiders. By contrast, "
1571 "with a centralised tool, you must use the software in a <quote>read only</"
1572 "quote> mode unless someone grants you permission to commit changes to their "
1573 "central server. Until then, you won't be able to record changes, and your "
1574 "local modifications will be at risk of corruption any time you try to update "
1575 "your client's view of the repository."
1576 msgstr ""
1578 #. type: Content of: <book><preface><sect1><sect2><sect3><title>
1579 #: ../en/ch00-preface.xml:277
1580 msgid "The forking non-problem"
1581 msgstr "分叉不是问题"
1583 #. type: Content of: <book><preface><sect1><sect2><sect3><para>
1584 #: ../en/ch00-preface.xml:279
1585 msgid ""
1586 "It has been suggested that distributed revision control tools pose some sort "
1587 "of risk to open source projects because they make it easy to <quote>fork</"
1588 "quote> the development of a project. A fork happens when there are "
1589 "differences in opinion or attitude between groups of developers that cause "
1590 "them to decide that they can't work together any longer. Each side takes a "
1591 "more or less complete copy of the project's source code, and goes off in its "
1592 "own direction."
1593 msgstr ""
1595 #. type: Content of: <book><preface><sect1><sect2><sect3><para>
1596 #: ../en/ch00-preface.xml:289
1597 msgid ""
1598 "Sometimes the camps in a fork decide to reconcile their differences. With a "
1599 "centralised revision control system, the <emphasis>technical</emphasis> "
1600 "process of reconciliation is painful, and has to be performed largely by "
1601 "hand. You have to decide whose revision history is going to <quote>win</"
1602 "quote>, and graft the other team's changes into the tree somehow. This "
1603 "usually loses some or all of one side's revision history."
1604 msgstr ""
1606 #. type: Content of: <book><preface><sect1><sect2><sect3><para>
1607 #: ../en/ch00-preface.xml:298
1608 msgid ""
1609 "What distributed tools do with respect to forking is they make forking the "
1610 "<emphasis>only</emphasis> way to develop a project. Every single change that "
1611 "you make is potentially a fork point. The great strength of this approach is "
1612 "that a distributed revision control tool has to be really good at "
1613 "<emphasis>merging</emphasis> forks, because forks are absolutely fundamental: "
1614 "they happen all the time."
1615 msgstr ""
1617 #. type: Content of: <book><preface><sect1><sect2><sect3><para>
1618 #: ../en/ch00-preface.xml:307
1619 msgid ""
1620 "If every piece of work that everybody does, all the time, is framed in terms "
1621 "of forking and merging, then what the open source world refers to as a "
1622 "<quote>fork</quote> becomes <emphasis>purely</emphasis> a social issue. If "
1623 "anything, distributed tools <emphasis>lower</emphasis> the likelihood of a "
1624 "fork:"
1625 msgstr ""
1627 #. type: Content of: <book><preface><sect1><sect2><sect3><itemizedlist><listitem><para>
1628 #: ../en/ch00-preface.xml:314
1629 msgid ""
1630 "They eliminate the social distinction that centralised tools impose: that "
1631 "between insiders (people with commit access) and outsiders (people without)."
1632 msgstr ""
1634 #. type: Content of: <book><preface><sect1><sect2><sect3><itemizedlist><listitem><para>
1635 #: ../en/ch00-preface.xml:318
1636 msgid ""
1637 "They make it easier to reconcile after a social fork, because all that's "
1638 "involved from the perspective of the revision control software is just "
1639 "another merge."
1640 msgstr ""
1642 #. type: Content of: <book><preface><sect1><sect2><sect3><para>
1643 #: ../en/ch00-preface.xml:323
1644 msgid ""
1645 "Some people resist distributed tools because they want to retain tight "
1646 "control over their projects, and they believe that centralised tools give "
1647 "them this control. However, if you're of this belief, and you publish your "
1648 "CVS or Subversion repositories publicly, there are plenty of tools available "
1649 "that can pull out your entire project's history (albeit slowly) and recreate "
1650 "it somewhere that you don't control. So while your control in this case is "
1651 "illusory, you are forgoing the ability to fluidly collaborate with whatever "
1652 "people feel compelled to mirror and fork your history."
1653 msgstr ""
1655 #. type: Content of: <book><preface><sect1><sect2><title>
1656 #: ../en/ch00-preface.xml:338
1657 msgid "Advantages for commercial projects"
1658 msgstr "商业项目的优点"
1660 #. type: Content of: <book><preface><sect1><sect2><para>
1661 #: ../en/ch00-preface.xml:340
1662 msgid ""
1663 "Many commercial projects are undertaken by teams that are scattered across "
1664 "the globe. Contributors who are far from a central server will see slower "
1665 "command execution and perhaps less reliability. Commercial revision control "
1666 "systems attempt to ameliorate these problems with remote-site replication add-"
1667 "ons that are typically expensive to buy and cantankerous to administer. A "
1668 "distributed system doesn't suffer from these problems in the first place. "
1669 "Better yet, you can easily set up multiple authoritative servers, say one per "
1670 "site, so that there's no redundant communication between repositories over "
1671 "expensive long-haul network links."
1672 msgstr ""
1674 #. type: Content of: <book><preface><sect1><sect2><para>
1675 #: ../en/ch00-preface.xml:352
1676 msgid ""
1677 "Centralised revision control systems tend to have relatively low "
1678 "scalability. It's not unusual for an expensive centralised system to fall "
1679 "over under the combined load of just a few dozen concurrent users. Once "
1680 "again, the typical response tends to be an expensive and clunky replication "
1681 "facility. Since the load on a central server&emdash;if you have one at "
1682 "all&emdash;is many times lower with a distributed tool (because all of the "
1683 "data is replicated everywhere), a single cheap server can handle the needs of "
1684 "a much larger team, and replication to balance load becomes a simple matter "
1685 "of scripting."
1686 msgstr ""
1688 #. type: Content of: <book><preface><sect1><sect2><para>
1689 #: ../en/ch00-preface.xml:364
1690 msgid ""
1691 "If you have an employee in the field, troubleshooting a problem at a "
1692 "customer's site, they'll benefit from distributed revision control. The tool "
1693 "will let them generate custom builds, try different fixes in isolation from "
1694 "each other, and search efficiently through history for the sources of bugs "
1695 "and regressions in the customer's environment, all without needing to connect "
1696 "to your company's network."
1697 msgstr ""
1699 #. type: Content of: <book><preface><sect1><title>
1700 #: ../en/ch00-preface.xml:375
1701 msgid "Why choose Mercurial?"
1702 msgstr "为什么选择 Mercurial?"
1704 #. type: Content of: <book><preface><sect1><para>
1705 #: ../en/ch00-preface.xml:377
1706 msgid ""
1707 "Mercurial has a unique set of properties that make it a particularly good "
1708 "choice as a revision control system."
1709 msgstr ""
1711 #. type: Content of: <book><preface><sect1><itemizedlist><listitem><para>
1712 #: ../en/ch00-preface.xml:380
1713 msgid "It is easy to learn and use."
1714 msgstr ""
1716 #. type: Content of: <book><preface><sect1><itemizedlist><listitem><para>
1717 #: ../en/ch00-preface.xml:381
1718 msgid "It is lightweight."
1719 msgstr ""
1721 #. type: Content of: <book><preface><sect1><itemizedlist><listitem><para>
1722 #: ../en/ch00-preface.xml:382
1723 msgid "It scales excellently."
1724 msgstr ""
1726 #. type: Content of: <book><preface><sect1><itemizedlist><listitem><para>
1727 #: ../en/ch00-preface.xml:383
1728 msgid "It is easy to customise."
1729 msgstr ""
1731 #. type: Content of: <book><preface><sect1><para>
1732 #: ../en/ch00-preface.xml:386
1733 msgid ""
1734 "If you are at all familiar with revision control systems, you should be able "
1735 "to get up and running with Mercurial in less than five minutes. Even if not, "
1736 "it will take no more than a few minutes longer. Mercurial's command and "
1737 "feature sets are generally uniform and consistent, so you can keep track of a "
1738 "few general rules instead of a host of exceptions."
1739 msgstr ""
1741 #. type: Content of: <book><preface><sect1><para>
1742 #: ../en/ch00-preface.xml:393
1743 msgid ""
1744 "On a small project, you can start working with Mercurial in moments. Creating "
1745 "new changes and branches; transferring changes around (whether locally or "
1746 "over a network); and history and status operations are all fast. Mercurial "
1747 "attempts to stay nimble and largely out of your way by combining low "
1748 "cognitive overhead with blazingly fast operations."
1749 msgstr ""
1751 #. type: Content of: <book><preface><sect1><para>
1752 #: ../en/ch00-preface.xml:400
1753 msgid ""
1754 "The usefulness of Mercurial is not limited to small projects: it is used by "
1755 "projects with hundreds to thousands of contributors, each containing tens of "
1756 "thousands of files and hundreds of megabytes of source code."
1757 msgstr ""
1759 #. type: Content of: <book><preface><sect1><para>
1760 #: ../en/ch00-preface.xml:405
1761 msgid ""
1762 "If the core functionality of Mercurial is not enough for you, it's easy to "
1763 "build on. Mercurial is well suited to scripting tasks, and its clean "
1764 "internals and implementation in Python make it easy to add features in the "
1765 "form of extensions. There are a number of popular and useful extensions "
1766 "already available, ranging from helping to identify bugs to improving "
1767 "performance."
1768 msgstr ""
1770 #. type: Content of: <book><preface><sect1><title>
1771 #: ../en/ch00-preface.xml:415
1772 msgid "Mercurial compared with other tools"
1773 msgstr "Mercurial 与其它工具的比较"
1775 #. type: Content of: <book><preface><sect1><para>
1776 #: ../en/ch00-preface.xml:417
1777 msgid ""
1778 "Before you read on, please understand that this section necessarily reflects "
1779 "my own experiences, interests, and (dare I say it) biases. I have used every "
1780 "one of the revision control tools listed below, in most cases for several "
1781 "years at a time."
1782 msgstr ""
1784 #. type: Content of: <book><preface><sect1><itemizedlist><listitem><para>
1785 #: ../en/ch00-preface.xml:425 ../en/ch00-preface.xml:636
1786 msgid "Subversion"
1787 msgstr ""
1789 #. type: Content of: <book><preface><sect1><sect2><para>
1790 #: ../en/ch00-preface.xml:427
1791 msgid ""
1792 "Subversion is a popular revision control tool, developed to replace CVS. It "
1793 "has a centralised client/server architecture."
1794 msgstr ""
1796 #. type: Content of: <book><preface><sect1><sect2><para>
1797 #: ../en/ch00-preface.xml:431
1798 msgid ""
1799 "Subversion and Mercurial have similarly named commands for performing the "
1800 "same operations, so if you're familiar with one, it is easy to learn to use "
1801 "the other. Both tools are portable to all popular operating systems."
1802 msgstr ""
1804 #. type: Content of: <book><preface><sect1><sect2><para>
1805 #: ../en/ch00-preface.xml:436
1806 msgid ""
1807 "Prior to version 1.5, Subversion had no useful support for merges. At the "
1808 "time of writing, its merge tracking capability is new, and known to be <ulink "
1809 "url=\"http://svnbook.red-bean.com/nightly/en/svn.branchmerge.advanced."
1810 "html#svn.branchmerge.advanced.finalword\">complicated and buggy</ulink>."
1811 msgstr ""
1813 #. type: Content of: <book><preface><sect1><sect2><para>
1814 #: ../en/ch00-preface.xml:442
1815 msgid ""
1816 "Mercurial has a substantial performance advantage over Subversion on every "
1817 "revision control operation I have benchmarked. I have measured its advantage "
1818 "as ranging from a factor of two to a factor of six when compared with "
1819 "Subversion 1.4.3's <emphasis>ra_local</emphasis> file store, which is the "
1820 "fastest access method available. In more realistic deployments involving a "
1821 "network-based store, Subversion will be at a substantially larger "
1822 "disadvantage. Because many Subversion commands must talk to the server and "
1823 "Subversion does not have useful replication facilities, server capacity and "
1824 "network bandwidth become bottlenecks for modestly large projects."
1825 msgstr ""
1827 #. type: Content of: <book><preface><sect1><sect2><para>
1828 #: ../en/ch00-preface.xml:455
1829 msgid ""
1830 "Additionally, Subversion incurs substantial storage overhead to avoid network "
1831 "transactions for a few common operations, such as finding modified files "
1832 "(<literal>status</literal>) and displaying modifications against the current "
1833 "revision (<literal>diff</literal>). As a result, a Subversion working copy "
1834 "is often the same size as, or larger than, a Mercurial repository and working "
1835 "directory, even though the Mercurial repository contains a complete history "
1836 "of the project."
1837 msgstr ""
1839 #. type: Content of: <book><preface><sect1><sect2><para>
1840 #: ../en/ch00-preface.xml:465
1841 msgid ""
1842 "Subversion is widely supported by third party tools. Mercurial currently "
1843 "lags considerably in this area. This gap is closing, however, and indeed "
1844 "some of Mercurial's GUI tools now outshine their Subversion equivalents. "
1845 "Like Mercurial, Subversion has an excellent user manual."
1846 msgstr ""
1848 #. type: Content of: <book><preface><sect1><sect2><para>
1849 #: ../en/ch00-preface.xml:471
1850 msgid ""
1851 "Because Subversion doesn't store revision history on the client, it is well "
1852 "suited to managing projects that deal with lots of large, opaque binary "
1853 "files. If you check in fifty revisions to an incompressible 10MB file, "
1854 "Subversion's client-side space usage stays constant The space used by any "
1855 "distributed SCM will grow rapidly in proportion to the number of revisions, "
1856 "because the differences between each revision are large."
1857 msgstr ""
1859 #. type: Content of: <book><preface><sect1><sect2><para>
1860 #: ../en/ch00-preface.xml:480
1861 msgid ""
1862 "In addition, it's often difficult or, more usually, impossible to merge "
1863 "different versions of a binary file. Subversion's ability to let a user lock "
1864 "a file, so that they temporarily have the exclusive right to commit changes "
1865 "to it, can be a significant advantage to a project where binary files are "
1866 "widely used."
1867 msgstr ""
1869 #. type: Content of: <book><preface><sect1><sect2><para>
1870 #: ../en/ch00-preface.xml:487
1871 msgid ""
1872 "Mercurial can import revision history from a Subversion repository. It can "
1873 "also export revision history to a Subversion repository. This makes it easy "
1874 "to <quote>test the waters</quote> and use Mercurial and Subversion in "
1875 "parallel before deciding to switch. History conversion is incremental, so "
1876 "you can perform an initial conversion, then small additional conversions "
1877 "afterwards to bring in new changes."
1878 msgstr ""
1880 #. type: Content of: <book><preface><sect1><itemizedlist><listitem><para>
1881 #: ../en/ch00-preface.xml:499 ../en/ch00-preface.xml:638
1882 msgid "Git"
1883 msgstr "Git"
1885 #. type: Content of: <book><preface><sect1><sect2><para>
1886 #: ../en/ch00-preface.xml:501
1887 msgid ""
1888 "Git is a distributed revision control tool that was developed for managing "
1889 "the Linux kernel source tree. Like Mercurial, its early design was somewhat "
1890 "influenced by Monotone."
1891 msgstr ""
1893 #. type: Content of: <book><preface><sect1><sect2><para>
1894 #: ../en/ch00-preface.xml:506
1895 msgid ""
1896 "Git has a very large command set, with version 1.5.0 providing 139 individual "
1897 "commands. It has something of a reputation for being difficult to learn. "
1898 "Compared to Git, Mercurial has a strong focus on simplicity."
1899 msgstr ""
1901 #. type: Content of: <book><preface><sect1><sect2><para>
1902 #: ../en/ch00-preface.xml:511
1903 msgid ""
1904 "In terms of performance, Git is extremely fast. In several cases, it is "
1905 "faster than Mercurial, at least on Linux, while Mercurial performs better on "
1906 "other operations. However, on Windows, the performance and general level of "
1907 "support that Git provides is, at the time of writing, far behind that of "
1908 "Mercurial."
1909 msgstr ""
1911 #. type: Content of: <book><preface><sect1><sect2><para>
1912 #: ../en/ch00-preface.xml:518
1913 msgid ""
1914 "While a Mercurial repository needs no maintenance, a Git repository requires "
1915 "frequent manual <quote>repacks</quote> of its metadata. Without these, "
1916 "performance degrades, while space usage grows rapidly. A server that "
1917 "contains many Git repositories that are not rigorously and frequently "
1918 "repacked will become heavily disk-bound during backups, and there have been "
1919 "instances of daily backups taking far longer than 24 hours as a result. A "
1920 "freshly packed Git repository is slightly smaller than a Mercurial "
1921 "repository, but an unpacked repository is several orders of magnitude larger."
1922 msgstr ""
1924 #. type: Content of: <book><preface><sect1><sect2><para>
1925 #: ../en/ch00-preface.xml:529
1926 msgid ""
1927 "The core of Git is written in C. Many Git commands are implemented as shell "
1928 "or Perl scripts, and the quality of these scripts varies widely. I have "
1929 "encountered several instances where scripts charged along blindly in the "
1930 "presence of errors that should have been fatal."
1931 msgstr ""
1933 #. type: Content of: <book><preface><sect1><sect2><para>
1934 #: ../en/ch00-preface.xml:535
1935 msgid "Mercurial can import revision history from a Git repository."
1936 msgstr ""
1938 #. type: Content of: <book><preface><sect1><itemizedlist><listitem><para>
1939 #: ../en/ch00-preface.xml:541 ../en/ch00-preface.xml:637
1940 msgid "CVS"
1941 msgstr "CVS"
1943 #. type: Content of: <book><preface><sect1><sect2><para>
1944 #: ../en/ch00-preface.xml:543
1945 msgid ""
1946 "CVS is probably the most widely used revision control tool in the world. Due "
1947 "to its age and internal untidiness, it has been only lightly maintained for "
1948 "many years."
1949 msgstr ""
1951 #. type: Content of: <book><preface><sect1><sect2><para>
1952 #: ../en/ch00-preface.xml:547
1953 msgid ""
1954 "It has a centralised client/server architecture. It does not group related "
1955 "file changes into atomic commits, making it easy for people to <quote>break "
1956 "the build</quote>: one person can successfully commit part of a change and "
1957 "then be blocked by the need for a merge, causing other people to see only a "
1958 "portion of the work they intended to do. This also affects how you work with "
1959 "project history. If you want to see all of the modifications someone made as "
1960 "part of a task, you will need to manually inspect the descriptions and "
1961 "timestamps of the changes made to each file involved (if you even know what "
1962 "those files were)."
1963 msgstr ""
1965 #. type: Content of: <book><preface><sect1><sect2><para>
1966 #: ../en/ch00-preface.xml:559
1967 msgid ""
1968 "CVS has a muddled notion of tags and branches that I will not attempt to even "
1969 "describe. It does not support renaming of files or directories well, making "
1970 "it easy to corrupt a repository. It has almost no internal consistency "
1971 "checking capabilities, so it is usually not even possible to tell whether or "
1972 "how a repository is corrupt. I would not recommend CVS for any project, "
1973 "existing or new."
1974 msgstr ""
1976 #. type: Content of: <book><preface><sect1><sect2><para>
1977 #: ../en/ch00-preface.xml:567
1978 msgid ""
1979 "Mercurial can import CVS revision history. However, there are a few caveats "
1980 "that apply; these are true of every other revision control tool's CVS "
1981 "importer, too. Due to CVS's lack of atomic changes and unversioned "
1982 "filesystem hierarchy, it is not possible to reconstruct CVS history "
1983 "completely accurately; some guesswork is involved, and renames will usually "
1984 "not show up. Because a lot of advanced CVS administration has to be done by "
1985 "hand and is hence error-prone, it's common for CVS importers to run into "
1986 "multiple problems with corrupted repositories (completely bogus revision "
1987 "timestamps and files that have remained locked for over a decade are just two "
1988 "of the less interesting problems I can recall from personal experience)."
1989 msgstr ""
1991 #. type: Content of: <book><preface><sect1><sect2><para>
1992 #: ../en/ch00-preface.xml:581
1993 msgid "Mercurial can import revision history from a CVS repository."
1994 msgstr ""
1996 #. type: Content of: <book><preface><sect1><sect2><title>
1997 #: ../en/ch00-preface.xml:587
1998 msgid "Commercial tools"
1999 msgstr "商业工具"
2001 #. type: Content of: <book><preface><sect1><sect2><para>
2002 #: ../en/ch00-preface.xml:589
2003 msgid ""
2004 "Perforce has a centralised client/server architecture, with no client-side "
2005 "caching of any data. Unlike modern revision control tools, Perforce requires "
2006 "that a user run a command to inform the server about every file they intend "
2007 "to edit."
2008 msgstr ""
2010 #. type: Content of: <book><preface><sect1><sect2><para>
2011 #: ../en/ch00-preface.xml:595
2012 msgid ""
2013 "The performance of Perforce is quite good for small teams, but it falls off "
2014 "rapidly as the number of users grows beyond a few dozen. Modestly large "
2015 "Perforce installations require the deployment of proxies to cope with the "
2016 "load their users generate."
2017 msgstr ""
2019 #. type: Content of: <book><preface><sect1><sect2><title>
2020 #: ../en/ch00-preface.xml:604
2021 msgid "Choosing a revision control tool"
2022 msgstr "选择版本控制工具"
2024 #. type: Content of: <book><preface><sect1><sect2><para>
2025 #: ../en/ch00-preface.xml:606
2026 msgid ""
2027 "With the exception of CVS, all of the tools listed above have unique "
2028 "strengths that suit them to particular styles of work. There is no single "
2029 "revision control tool that is best in all situations."
2030 msgstr ""
2032 #. type: Content of: <book><preface><sect1><sect2><para>
2033 #: ../en/ch00-preface.xml:611
2034 msgid ""
2035 "As an example, Subversion is a good choice for working with frequently edited "
2036 "binary files, due to its centralised nature and support for file locking."
2037 msgstr ""
2039 #. type: Content of: <book><preface><sect1><sect2><para>
2040 #: ../en/ch00-preface.xml:615
2041 msgid ""
2042 "I personally find Mercurial's properties of simplicity, performance, and good "
2043 "merge support to be a compelling combination that has served me well for "
2044 "several years."
2045 msgstr ""
2047 #. type: Content of: <book><preface><sect1><title>
2048 #: ../en/ch00-preface.xml:623
2049 msgid "Switching from another tool to Mercurial"
2050 msgstr "从其它工具切换到 Mercurial"
2052 #. type: Content of: <book><preface><sect1><para>
2053 #: ../en/ch00-preface.xml:625
2054 msgid ""
2055 "Mercurial is bundled with an extension named <literal role=\"hg-ext"
2056 "\">convert</literal>, which can incrementally import revision history from "
2057 "several other revision control tools. By <quote>incremental</quote>, I mean "
2058 "that you can convert all of a project's history to date in one go, then rerun "
2059 "the conversion later to obtain new changes that happened after the initial "
2060 "conversion."
2061 msgstr ""
2063 #. type: Content of: <book><preface><sect1><para>
2064 #: ../en/ch00-preface.xml:633
2065 msgid ""
2066 "The revision control tools supported by <literal role=\"hg-ext\">convert</"
2067 "literal> are as follows:"
2068 msgstr "<literal role=\"hg-ext\">convert</literal> 支持的版本控制工具有:"
2070 #. type: Content of: <book><preface><sect1><itemizedlist><listitem><para>
2071 #: ../en/ch00-preface.xml:639
2072 msgid "Darcs"
2073 msgstr "Darcs"
2075 #. type: Content of: <book><preface><sect1><para>
2076 #: ../en/ch00-preface.xml:641
2077 msgid ""
2078 "In addition, <literal role=\"hg-ext\">convert</literal> can export changes "
2079 "from Mercurial to Subversion. This makes it possible to try Subversion and "
2080 "Mercurial in parallel before committing to a switchover, without risking the "
2081 "loss of any work."
2082 msgstr ""
2084 #. type: Content of: <book><preface><sect1><para>
2085 #: ../en/ch00-preface.xml:647
2086 msgid ""
2087 "The <command role=\"hg-ext-convert\">convert</command> command is easy to "
2088 "use. Simply point it at the path or URL of the source repository, optionally "
2089 "give it the name of the destination repository, and it will start working. "
2090 "After the initial conversion, just run the same command again to import new "
2091 "changes."
2092 msgstr ""
2094 #. type: Content of: <book><preface><sect1><title>
2095 #: ../en/ch00-preface.xml:656
2096 msgid "A short history of revision control"
2097 msgstr "版本控制简史"
2099 #. type: Content of: <book><preface><sect1><para>
2100 #: ../en/ch00-preface.xml:658
2101 msgid ""
2102 "The best known of the old-time revision control tools is SCCS (Source Code "
2103 "Control System), which Marc Rochkind wrote at Bell Labs, in the early 1970s. "
2104 "SCCS operated on individual files, and required every person working on a "
2105 "project to have access to a shared workspace on a single system. Only one "
2106 "person could modify a file at any time; arbitration for access to files was "
2107 "via locks. It was common for people to lock files, and later forget to "
2108 "unlock them, preventing anyone else from modifying those files without the "
2109 "help of an administrator."
2110 msgstr ""
2112 #. type: Content of: <book><preface><sect1><para>
2113 #: ../en/ch00-preface.xml:669
2114 msgid ""
2115 "Walter Tichy developed a free alternative to SCCS in the early 1980s; he "
2116 "called his program RCS (Revision Control System). Like SCCS, RCS required "
2117 "developers to work in a single shared workspace, and to lock files to prevent "
2118 "multiple people from modifying them simultaneously."
2119 msgstr ""
2121 #. type: Content of: <book><preface><sect1><para>
2122 #: ../en/ch00-preface.xml:675
2123 msgid ""
2124 "Later in the 1980s, Dick Grune used RCS as a building block for a set of "
2125 "shell scripts he initially called cmt, but then renamed to CVS (Concurrent "
2126 "Versions System). The big innovation of CVS was that it let developers work "
2127 "simultaneously and somewhat independently in their own personal workspaces. "
2128 "The personal workspaces prevented developers from stepping on each other's "
2129 "toes all the time, as was common with SCCS and RCS. Each developer had a copy "
2130 "of every project file, and could modify their copies independently. They had "
2131 "to merge their edits prior to committing changes to the central repository."
2132 msgstr ""
2134 #. type: Content of: <book><preface><sect1><para>
2135 #: ../en/ch00-preface.xml:686
2136 msgid ""
2137 "Brian Berliner took Grune's original scripts and rewrote them in C, releasing "
2138 "in 1989 the code that has since developed into the modern version of CVS. "
2139 "CVS subsequently acquired the ability to operate over a network connection, "
2140 "giving it a client/server architecture. CVS's architecture is centralised; "
2141 "only the server has a copy of the history of the project. Client workspaces "
2142 "just contain copies of recent versions of the project's files, and a little "
2143 "metadata to tell them where the server is. CVS has been enormously "
2144 "successful; it is probably the world's most widely used revision control "
2145 "system."
2146 msgstr ""
2148 #. type: Content of: <book><preface><sect1><para>
2149 #: ../en/ch00-preface.xml:697
2150 msgid ""
2151 "In the early 1990s, Sun Microsystems developed an early distributed revision "
2152 "control system, called TeamWare. A TeamWare workspace contains a complete "
2153 "copy of the project's history. TeamWare has no notion of a central "
2154 "repository. (CVS relied upon RCS for its history storage; TeamWare used "
2155 "SCCS.)"
2156 msgstr ""
2158 #. type: Content of: <book><preface><sect1><para>
2159 #: ../en/ch00-preface.xml:704
2160 msgid ""
2161 "As the 1990s progressed, awareness grew of a number of problems with CVS. It "
2162 "records simultaneous changes to multiple files individually, instead of "
2163 "grouping them together as a single logically atomic operation. It does not "
2164 "manage its file hierarchy well; it is easy to make a mess of a repository by "
2165 "renaming files and directories. Worse, its source code is difficult to read "
2166 "and maintain, which made the <quote>pain level</quote> of fixing these "
2167 "architectural problems prohibitive."
2168 msgstr ""
2170 #. type: Content of: <book><preface><sect1><para>
2171 #: ../en/ch00-preface.xml:714
2172 msgid ""
2173 "In 2001, Jim Blandy and Karl Fogel, two developers who had worked on CVS, "
2174 "started a project to replace it with a tool that would have a better "
2175 "architecture and cleaner code. The result, Subversion, does not stray from "
2176 "CVS's centralised client/server model, but it adds multi-file atomic commits, "
2177 "better namespace management, and a number of other features that make it a "
2178 "generally better tool than CVS. Since its initial release, it has rapidly "
2179 "grown in popularity."
2180 msgstr ""
2182 #. type: Content of: <book><preface><sect1><para>
2183 #: ../en/ch00-preface.xml:723
2184 msgid ""
2185 "More or less simultaneously, Graydon Hoare began working on an ambitious "
2186 "distributed revision control system that he named Monotone. While Monotone "
2187 "addresses many of CVS's design flaws and has a peer-to-peer architecture, it "
2188 "goes beyond earlier (and subsequent) revision control tools in a number of "
2189 "innovative ways. It uses cryptographic hashes as identifiers, and has an "
2190 "integral notion of <quote>trust</quote> for code from different sources."
2191 msgstr ""
2193 #. type: Content of: <book><preface><sect1><para>
2194 #: ../en/ch00-preface.xml:732
2195 msgid ""
2196 "Mercurial began life in 2005. While a few aspects of its design are "
2197 "influenced by Monotone, Mercurial focuses on ease of use, high performance, "
2198 "and scalability to very large projects."
2199 msgstr ""
2201 #. type: Content of: <book><preface><sect1><title>
2202 #: ../en/ch00-preface.xml:740
2203 msgid "Colophon&emdash;this book is Free"
2204 msgstr "后记—本书是自由的!"
2206 #. type: Content of: <book><preface><sect1><para>
2207 #: ../en/ch00-preface.xml:742
2208 msgid ""
2209 "This book is licensed under the Open Publication License, and is produced "
2210 "entirely using Free Software tools. It is typeset with DocBook XML. "
2211 "Illustrations are drawn and rendered with <ulink url=\"http://www.inkscape."
2212 "org/\">Inkscape</ulink>."
2213 msgstr ""
2215 #. type: Content of: <book><preface><sect1><para>
2216 #: ../en/ch00-preface.xml:747
2217 msgid ""
2218 "The complete source code for this book is published as a Mercurial "
2219 "repository, at <ulink url=\"http://hg.serpentine.com/mercurial/book\">http://"
2220 "hg.serpentine.com/mercurial/book</ulink>."
2221 msgstr ""
2223 #. type: Content of: <book><chapter><title>
2224 #: ../en/ch01-tour-basic.xml:5
2225 msgid "A tour of Mercurial: the basics"
2226 msgstr "Mercurial 教程: 基础知识"
2228 #. type: Content of: <book><chapter><sect1><title>
2229 #: ../en/ch01-tour-basic.xml:8
2230 msgid "Installing Mercurial on your system"
2231 msgstr "安装 Mercurial"
2233 #. type: Content of: <book><chapter><sect1><para>
2234 #: ../en/ch01-tour-basic.xml:10
2235 msgid ""
2236 "Prebuilt binary packages of Mercurial are available for every popular "
2237 "operating system. These make it easy to start using Mercurial on your "
2238 "computer immediately."
2239 msgstr ""
2240 "对于每种流行的操作系统,都有已经构建的二进制软件包。这让在你的计算机上开始使"
2241 "用 Mercurial 变得很容易。"
2243 #. type: Content of: <book><chapter><sect1><sect2><title>
2244 #: ../en/ch01-tour-basic.xml:15
2245 msgid "Windows"
2246 msgstr "Windows"
2248 #. type: Content of: <book><chapter><sect1><sect2><para>
2249 #: ../en/ch01-tour-basic.xml:17
2250 msgid ""
2251 "The best version of Mercurial for Windows is TortoiseHg, which can be found "
2252 "at <ulink url=\"http://bitbucket.org/tortoisehg/stable/wiki/Home\">http://"
2253 "bitbucket.org/tortoisehg/stable/wiki/Home</ulink>. This package has no "
2254 "external dependencies; it <quote>just works</quote>. It provides both "
2255 "command line and graphical user interfaces."
2256 msgstr ""
2258 #. type: Content of: <book><chapter><sect1><sect2><title>
2259 #: ../en/ch01-tour-basic.xml:27
2260 msgid "Mac OS X"
2261 msgstr "Mac OS X"
2263 #. type: Content of: <book><chapter><sect1><sect2><para>
2264 #: ../en/ch01-tour-basic.xml:29
2265 msgid ""
2266 "Lee Cantey publishes an installer of Mercurial for Mac OS X at <ulink url="
2267 "\"http://mercurial.berkwood.com\">http://mercurial.berkwood.com</ulink>."
2268 msgstr ""
2270 #. type: Content of: <book><chapter><sect1><sect2><title>
2271 #: ../en/ch01-tour-basic.xml:35
2272 msgid "Linux"
2273 msgstr "Linux"
2275 #. type: Content of: <book><chapter><sect1><sect2><para>
2276 #: ../en/ch01-tour-basic.xml:37
2277 msgid ""
2278 "Because each Linux distribution has its own packaging tools, policies, and "
2279 "rate of development, it's difficult to give a comprehensive set of "
2280 "instructions on how to install Mercurial binaries. The version of Mercurial "
2281 "that you will end up with can vary depending on how active the person is who "
2282 "maintains the package for your distribution."
2283 msgstr ""
2284 "由于每种 Linux 发行版都有自己的包管理工具,开发策略和进度,从而很难给出安装 "
2285 "Mercurial 二进制包的全面说明。你安装的 Mercurial 版本,在很大程度上依赖于你所"
2286 "使用的发行版的 Mercurial 维护者的活跃程度。"
2288 #. type: Content of: <book><chapter><sect1><sect2><para>
2289 #: ../en/ch01-tour-basic.xml:44
2290 msgid ""
2291 "To keep things simple, I will focus on installing Mercurial from the command "
2292 "line under the most popular Linux distributions. Most of these distributions "
2293 "provide graphical package managers that will let you install Mercurial with a "
2294 "single click; the package name to look for is <literal>mercurial</literal>."
2295 msgstr ""
2296 "为了让事情简单,我会致力于说明在最流行的 Linux 发行版中,从命令行安装 "
2297 "Mercurial 的方法。这些发行版都提供了图形界面的包管理器,让你通过点击鼠标安装 "
2298 "Mercurial;寻找的包名称是 <literal>mercurial</literal>。"
2300 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2301 #: ../en/ch01-tour-basic.xml:52
2302 msgid "Ubuntu and Debian:"
2303 msgstr "Ubuntu 与 Debian:"
2305 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2306 #: ../en/ch01-tour-basic.xml:54
2307 msgid "Fedora and OpenSUSE:"
2308 msgstr "Fedora and OpenSUSE:"
2310 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2311 #: ../en/ch01-tour-basic.xml:56
2312 msgid "Gentoo:"
2313 msgstr "Gentoo:"
2315 #. type: Content of: <book><chapter><sect1><sect2><title>
2316 #: ../en/ch01-tour-basic.xml:62
2317 msgid "Solaris"
2318 msgstr "Solaris"
2320 #. type: Content of: <book><chapter><sect1><sect2><para>
2321 #: ../en/ch01-tour-basic.xml:64
2322 msgid ""
2323 "SunFreeWare, at <ulink url=\"http://www.sunfreeware.com\">http://www."
2324 "sunfreeware.com</ulink>, provides prebuilt packages of Mercurial."
2325 msgstr ""
2326 "位于 <ulink url=\"http://www.sunfreeware.com\">http://www.sunfreeware.com</"
2327 "ulink> 的 SunFreeWare 提供了 Mercurial 的二进制安装包。"
2329 #. type: Content of: <book><chapter><sect1><title>
2330 #: ../en/ch01-tour-basic.xml:73
2331 msgid "Getting started"
2332 msgstr "开始"
2334 #. type: Content of: <book><chapter><sect1><para>
2335 #: ../en/ch01-tour-basic.xml:75
2336 msgid ""
2337 "To begin, we'll use the <command role=\"hg-cmd\">hg version</command> command "
2338 "to find out whether Mercurial is actually installed properly. The actual "
2339 "version information that it prints isn't so important; it's whether it prints "
2340 "anything at all that we care about."
2341 msgstr ""
2343 #. type: Content of: <book><chapter><sect1><sect2><title>
2344 #: ../en/ch01-tour-basic.xml:84
2345 msgid "Built-in help"
2346 msgstr "内置帮助"
2348 #. type: Content of: <book><chapter><sect1><sect2><para>
2349 #: ../en/ch01-tour-basic.xml:86
2350 msgid ""
2351 "Mercurial provides a built-in help system. This is invaluable for those "
2352 "times when you find yourself stuck trying to remember how to run a command. "
2353 "If you are completely stuck, simply run <command role=\"hg-cmd\">hg help</"
2354 "command>; it will print a brief list of commands, along with a description of "
2355 "what each does. If you ask for help on a specific command (as below), it "
2356 "prints more detailed information."
2357 msgstr ""
2359 #. type: Content of: <book><chapter><sect1><sect2><para>
2360 #: ../en/ch01-tour-basic.xml:97
2361 msgid ""
2362 "For a more impressive level of detail (which you won't usually need) run "
2363 "<command role=\"hg-cmd\">hg help <option role=\"hg-opt-global\">-v</option></"
2364 "command>. The <option role=\"hg-opt-global\">-v</option> option is short for "
2365 "<option role=\"hg-opt-global\">--verbose</option>, and tells Mercurial to "
2366 "print more information than it usually would."
2367 msgstr ""
2369 #. type: Content of: <book><chapter><sect1><title>
2370 #: ../en/ch01-tour-basic.xml:108
2371 msgid "Working with a repository"
2372 msgstr "使用版本库"
2374 #. type: Content of: <book><chapter><sect1><para>
2375 #: ../en/ch01-tour-basic.xml:110
2376 msgid ""
2377 "In Mercurial, everything happens inside a <emphasis>repository</emphasis>. "
2378 "The repository for a project contains all of the files that <quote>belong to</"
2379 "quote> that project, along with a historical record of the project's files."
2380 msgstr ""
2382 #. type: Content of: <book><chapter><sect1><para>
2383 #: ../en/ch01-tour-basic.xml:116
2384 msgid ""
2385 "There's nothing particularly magical about a repository; it is simply a "
2386 "directory tree in your filesystem that Mercurial treats as special. You can "
2387 "rename or delete a repository any time you like, using either the command "
2388 "line or your file browser."
2389 msgstr ""
2391 #. type: Content of: <book><chapter><sect1><sect2><title>
2392 #: ../en/ch01-tour-basic.xml:123
2393 msgid "Making a local copy of a repository"
2394 msgstr "创建版本库的工作副本"
2396 #. type: Content of: <book><chapter><sect1><sect2><para>
2397 #: ../en/ch01-tour-basic.xml:125
2398 msgid ""
2399 "<emphasis>Copying</emphasis> a repository is just a little bit special. "
2400 "While you could use a normal file copying command to make a copy of a "
2401 "repository, it's best to use a built-in command that Mercurial provides. "
2402 "This command is called <command role=\"hg-cmd\">hg clone</command>, because "
2403 "it makes an identical copy of an existing repository."
2404 msgstr ""
2406 #. type: Content of: <book><chapter><sect1><sect2><para>
2407 #: ../en/ch01-tour-basic.xml:134
2408 msgid ""
2409 "One advantage of using <command role=\"hg-cmd\">hg clone</command> is that, "
2410 "as we can see above, it lets us clone repositories over the network. Another "
2411 "is that it remembers where we cloned from, which we'll find useful soon when "
2412 "we want to fetch new changes from another repository."
2413 msgstr ""
2415 #. type: Content of: <book><chapter><sect1><sect2><para>
2416 #: ../en/ch01-tour-basic.xml:140
2417 msgid ""
2418 "If our clone succeeded, we should now have a local directory called <filename "
2419 "class=\"directory\">hello</filename>. This directory will contain some files."
2420 msgstr ""
2422 #. type: Content of: <book><chapter><sect1><sect2><para>
2423 #: ../en/ch01-tour-basic.xml:146
2424 msgid ""
2425 "These files have the same contents and history in our repository as they do "
2426 "in the repository we cloned."
2427 msgstr ""
2429 #. type: Content of: <book><chapter><sect1><sect2><para>
2430 #: ../en/ch01-tour-basic.xml:149
2431 msgid ""
2432 "Every Mercurial repository is complete, self-contained, and independent. It "
2433 "contains its own private copy of a project's files and history. As we just "
2434 "mentioned, a cloned repository remembers the location of the repository it "
2435 "was cloned from, but Mercurial will not communicate with that repository, or "
2436 "any other, unless you tell it to."
2437 msgstr ""
2439 #. type: Content of: <book><chapter><sect1><sect2><para>
2440 #: ../en/ch01-tour-basic.xml:156
2441 msgid ""
2442 "What this means for now is that we're free to experiment with our repository, "
2443 "safe in the knowledge that it's a private <quote>sandbox</quote> that won't "
2444 "affect anyone else."
2445 msgstr ""
2447 #. type: Content of: <book><chapter><sect1><sect2><title>
2448 #: ../en/ch01-tour-basic.xml:162
2449 msgid "What's in a repository?"
2450 msgstr "什么是版本库?"
2452 #. type: Content of: <book><chapter><sect1><sect2><para>
2453 #: ../en/ch01-tour-basic.xml:164
2454 msgid ""
2455 "When we take a more detailed look inside a repository, we can see that it "
2456 "contains a directory named <filename class=\"directory\">.hg</filename>. "
2457 "This is where Mercurial keeps all of its metadata for the repository."
2458 msgstr ""
2460 #. type: Content of: <book><chapter><sect1><sect2><para>
2461 #: ../en/ch01-tour-basic.xml:171
2462 msgid ""
2463 "The contents of the <filename class=\"directory\">.hg</filename> directory "
2464 "and its subdirectories are private to Mercurial. Every other file and "
2465 "directory in the repository is yours to do with as you please."
2466 msgstr ""
2468 #. type: Content of: <book><chapter><sect1><sect2><para>
2469 #: ../en/ch01-tour-basic.xml:177
2470 msgid ""
2471 "To introduce a little terminology, the <filename class=\"directory\">.hg</"
2472 "filename> directory is the <quote>real</quote> repository, and all of the "
2473 "files and directories that coexist with it are said to live in the "
2474 "<emphasis>working directory</emphasis>. An easy way to remember the "
2475 "distinction is that the <emphasis>repository</emphasis> contains the "
2476 "<emphasis>history</emphasis> of your project, while the <emphasis>working "
2477 "directory</emphasis> contains a <emphasis>snapshot</emphasis> of your project "
2478 "at a particular point in history."
2479 msgstr ""
2481 #. type: Content of: <book><chapter><sect1><title>
2482 #: ../en/ch01-tour-basic.xml:192
2483 msgid "A tour through history"
2484 msgstr "回溯历史"
2486 #. type: Content of: <book><chapter><sect1><para>
2487 #: ../en/ch01-tour-basic.xml:194
2488 msgid ""
2489 "One of the first things we might want to do with a new, unfamiliar repository "
2490 "is understand its history. The <command role=\"hg-cmd\">hg log</command> "
2491 "command gives us a view of the history of changes in the repository."
2492 msgstr ""
2494 #. type: Content of: <book><chapter><sect1><para>
2495 #: ../en/ch01-tour-basic.xml:201
2496 msgid ""
2497 "By default, this command prints a brief paragraph of output for each change "
2498 "to the project that was recorded. In Mercurial terminology, we call each of "
2499 "these recorded events a <emphasis>changeset</emphasis>, because it can "
2500 "contain a record of changes to several files."
2501 msgstr ""
2503 #. type: Content of: <book><chapter><sect1><para>
2504 #: ../en/ch01-tour-basic.xml:207
2505 msgid ""
2506 "The fields in a record of output from <command role=\"hg-cmd\">hg log</"
2507 "command> are as follows."
2508 msgstr ""
2510 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
2511 #: ../en/ch01-tour-basic.xml:211
2512 msgid ""
2513 "<literal>changeset</literal>: This field has the format of a number, followed "
2514 "by a colon, followed by a hexadecimal (or <emphasis>hex</emphasis>) string. "
2515 "These are <emphasis>identifiers</emphasis> for the changeset. The hex string "
2516 "is a unique identifier: the same hex string will always refer to the same "
2517 "changeset. The number is shorter and easier to type than the hex string, but "
2518 "it isn't unique: the same number in two different clones of a repository may "
2519 "identify different changesets. Why provide the number at all, then? For "
2520 "local convenience."
2521 msgstr ""
2523 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
2524 #: ../en/ch01-tour-basic.xml:223
2525 msgid ""
2526 "<literal>user</literal>: The identity of the person who created the "
2527 "changeset. This is a free-form field, but it most often contains a person's "
2528 "name and email address."
2529 msgstr ""
2531 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
2532 #: ../en/ch01-tour-basic.xml:227
2533 msgid ""
2534 "<literal>date</literal>: The date and time on which the changeset was "
2535 "created, and the timezone in which it was created. (The date and time are "
2536 "local to that timezone; they display what time and date it was for the person "
2537 "who created the changeset.)"
2538 msgstr ""
2540 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
2541 #: ../en/ch01-tour-basic.xml:232
2542 msgid ""
2543 "<literal>summary</literal>: The first line of the text message that the "
2544 "creator of the changeset entered to describe the changeset."
2545 msgstr ""
2547 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
2548 #: ../en/ch01-tour-basic.xml:236
2549 msgid ""
2550 "Some changesets, such as the first in the list above, have a <literal>tag</"
2551 "literal> field. A tag is another way to identify a changeset, by giving it "
2552 "an easy-to-remember name. (The tag named <literal>tip</literal> is special: "
2553 "it always refers to the newest change in a repository.)"
2554 msgstr ""
2556 #. type: Content of: <book><chapter><sect1><para>
2557 #: ../en/ch01-tour-basic.xml:244
2558 msgid ""
2559 "The default output printed by <command role=\"hg-cmd\">hg log</command> is "
2560 "purely a summary; it is missing a lot of detail."
2561 msgstr ""
2563 #. type: Content of: <book><chapter><sect1><para>
2564 #: ../en/ch01-tour-basic.xml:248
2565 msgid ""
2566 "<xref linkend=\"fig:tour-basic:history\"/> provides a graphical "
2567 "representation of the history of the <filename class=\"directory\">hello</"
2568 "filename> repository, to make it a little easier to see which direction "
2569 "history is <quote>flowing</quote> in. We'll be returning to this figure "
2570 "several times in this chapter and the chapter that follows."
2571 msgstr ""
2573 #. type: Content of: <book><chapter><sect1><figure><title>
2574 #: ../en/ch01-tour-basic.xml:257
2575 msgid ""
2576 "Graphical history of the <filename class=\"directory\">hello</filename> "
2577 "repository"
2578 msgstr "版本库 <filename class=\"directory\">hello</filename> 的历史图"
2580 #. type: Content of: <book><chapter><sect1><figure>
2581 #: ../en/ch01-tour-basic.xml:259 ../en/ch02-tour-merge.xml:50
2582 #: ../en/ch02-tour-merge.xml:188 ../en/ch03-concepts.xml:295
2583 msgid "<placeholder type=\"mediaobject\" id=\"0\"/>"
2584 msgstr ""
2586 #. type: Content of: <book><chapter><sect1><figure><mediaobject>
2587 #: ../en/ch01-tour-basic.xml:260
2588 msgid ""
2589 "<imageobject><imagedata fileref=\"figs/tour-history.png\"/></imageobject>"
2590 msgstr ""
2592 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject><textobject><phrase>
2593 #: ../en/ch01-tour-basic.xml:261 ../en/ch02-tour-merge.xml:52
2594 #: ../en/ch02-tour-merge.xml:82 ../en/ch02-tour-merge.xml:163
2595 #: ../en/ch02-tour-merge.xml:190 ../en/ch02-tour-merge.xml:260
2596 #: ../en/ch03-concepts.xml:59 ../en/ch03-concepts.xml:108
2597 #: ../en/ch03-concepts.xml:193 ../en/ch03-concepts.xml:297
2598 #: ../en/ch03-concepts.xml:348 ../en/ch03-concepts.xml:363
2599 #: ../en/ch03-concepts.xml:404 ../en/ch03-concepts.xml:424
2600 #: ../en/ch03-concepts.xml:467 ../en/ch05-collab.xml:322
2601 #: ../en/ch08-undo.xml:365 ../en/ch08-undo.xml:412 ../en/ch08-undo.xml:477
2602 #: ../en/ch08-undo.xml:515 ../en/ch11-mq.xml:412
2603 msgid "XXX add text"
2604 msgstr ""
2606 #. type: Content of: <book><chapter><sect1><sect2><title>
2607 #: ../en/ch01-tour-basic.xml:266
2608 msgid "Changesets, revisions, and talking to other people"
2609 msgstr "修改集,版本,与其它用户交互"
2611 #. type: Content of: <book><chapter><sect1><sect2><para>
2612 #: ../en/ch01-tour-basic.xml:269
2613 msgid ""
2614 "As English is a notoriously sloppy language, and computer science has a "
2615 "hallowed history of terminological confusion (why use one term when four will "
2616 "do?), revision control has a variety of words and phrases that mean the same "
2617 "thing. If you are talking about Mercurial history with other people, you "
2618 "will find that the word <quote>changeset</quote> is often compressed to "
2619 "<quote>change</quote> or (when written) <quote>cset</quote>, and sometimes a "
2620 "changeset is referred to as a <quote>revision</quote> or a <quote>rev</quote>."
2621 msgstr ""
2623 #. type: Content of: <book><chapter><sect1><sect2><para>
2624 #: ../en/ch01-tour-basic.xml:279
2625 msgid ""
2626 "While it doesn't matter what <emphasis>word</emphasis> you use to refer to "
2627 "the concept of <quote>a changeset</quote>, the <emphasis>identifier</"
2628 "emphasis> that you use to refer to <quote>a <emphasis>specific</emphasis> "
2629 "changeset</quote> is of great importance. Recall that the <literal>changeset</"
2630 "literal> field in the output from <command role=\"hg-cmd\">hg log</command> "
2631 "identifies a changeset using both a number and a hexadecimal string."
2632 msgstr ""
2634 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2635 #: ../en/ch01-tour-basic.xml:288
2636 msgid ""
2637 "The revision number is a handy notation that is <emphasis>only valid in that "
2638 "repository</emphasis>."
2639 msgstr ""
2641 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2642 #: ../en/ch01-tour-basic.xml:291
2643 msgid ""
2644 "The hexadecimal string is the <emphasis>permanent, unchanging identifier</"
2645 "emphasis> that will always identify that exact changeset in <emphasis>every</"
2646 "emphasis> copy of the repository."
2647 msgstr ""
2649 #. type: Content of: <book><chapter><sect1><sect2><para>
2650 #: ../en/ch01-tour-basic.xml:297
2651 msgid ""
2652 "This distinction is important. If you send someone an email talking about "
2653 "<quote>revision 33</quote>, there's a high likelihood that their revision 33 "
2654 "will <emphasis>not be the same</emphasis> as yours. The reason for this is "
2655 "that a revision number depends on the order in which changes arrived in a "
2656 "repository, and there is no guarantee that the same changes will happen in "
2657 "the same order in different repositories. Three changes <literal>a,b,c</"
2658 "literal> can easily appear in one repository as <literal>0,1,2</literal>, "
2659 "while in another as <literal>0,2,1</literal>."
2660 msgstr ""
2662 #. type: Content of: <book><chapter><sect1><sect2><para>
2663 #: ../en/ch01-tour-basic.xml:309
2664 msgid ""
2665 "Mercurial uses revision numbers purely as a convenient shorthand. If you "
2666 "need to discuss a changeset with someone, or make a record of a changeset for "
2667 "some other reason (for example, in a bug report), use the hexadecimal "
2668 "identifier."
2669 msgstr ""
2671 #. type: Content of: <book><chapter><sect1><sect2><title>
2672 #: ../en/ch01-tour-basic.xml:317
2673 msgid "Viewing specific revisions"
2674 msgstr "察看指定版本"
2676 #. type: Content of: <book><chapter><sect1><sect2><para>
2677 #: ../en/ch01-tour-basic.xml:319
2678 msgid ""
2679 "To narrow the output of <command role=\"hg-cmd\">hg log</command> down to a "
2680 "single revision, use the <option role=\"hg-opt-log\">-r</option> (or <option "
2681 "role=\"hg-opt-log\">--rev</option>) option. You can use either a revision "
2682 "number or a hexadecimal identifier, and you can provide as many revisions as "
2683 "you want."
2684 msgstr ""
2686 #. type: Content of: <book><chapter><sect1><sect2><para>
2687 #: ../en/ch01-tour-basic.xml:328
2688 msgid ""
2689 "If you want to see the history of several revisions without having to list "
2690 "each one, you can use <emphasis>range notation</emphasis>; this lets you "
2691 "express the idea <quote>I want all revisions between <literal>abc</literal> "
2692 "and <literal>def</literal>, inclusive</quote>."
2693 msgstr ""
2695 #. type: Content of: <book><chapter><sect1><sect2><para>
2696 #: ../en/ch01-tour-basic.xml:336
2697 msgid ""
2698 "Mercurial also honours the order in which you specify revisions, so <command "
2699 "role=\"hg-cmd\">hg log -r 2:4</command> prints 2, 3, and 4. while <command "
2700 "role=\"hg-cmd\">hg log -r 4:2</command> prints 4, 3, and 2."
2701 msgstr ""
2703 #. type: Content of: <book><chapter><sect1><sect2><title>
2704 #: ../en/ch01-tour-basic.xml:343
2705 msgid "More detailed information"
2706 msgstr "更详细的信息"
2708 #. type: Content of: <book><chapter><sect1><sect2><para>
2709 #: ../en/ch01-tour-basic.xml:345
2710 msgid ""
2711 "While the summary information printed by <command role=\"hg-cmd\">hg log</"
2712 "command> is useful if you already know what you're looking for, you may need "
2713 "to see a complete description of the change, or a list of the files changed, "
2714 "if you're trying to decide whether a changeset is the one you're looking for. "
2715 "The <command role=\"hg-cmd\">hg log</command> command's <option role=\"hg-opt-"
2716 "global\">-v</option> (or <option role=\"hg-opt-global\">--verbose</option>) "
2717 "option gives you this extra detail."
2718 msgstr ""
2720 #. type: Content of: <book><chapter><sect1><sect2><para>
2721 #: ../en/ch01-tour-basic.xml:357
2722 msgid ""
2723 "If you want to see both the description and content of a change, add the "
2724 "<option role=\"hg-opt-log\">-p</option> (or <option role=\"hg-opt-log\">--"
2725 "patch</option>) option. This displays the content of a change as a "
2726 "<emphasis>unified diff</emphasis> (if you've never seen a unified diff "
2727 "before, see <xref linkend=\"sec:mq:patch\"/> for an overview)."
2728 msgstr ""
2730 #. type: Content of: <book><chapter><sect1><sect2><para>
2731 #: ../en/ch01-tour-basic.xml:367
2732 msgid ""
2733 "The <option role=\"hg-opt-log\">-p</option> option is tremendously useful, so "
2734 "it's well worth remembering."
2735 msgstr ""
2737 #. type: Content of: <book><chapter><sect1><title>
2738 #: ../en/ch01-tour-basic.xml:374
2739 msgid "All about command options"
2740 msgstr "命令选项"
2742 #. type: Content of: <book><chapter><sect1><para>
2743 #: ../en/ch01-tour-basic.xml:376
2744 msgid ""
2745 "Let's take a brief break from exploring Mercurial commands to discuss a "
2746 "pattern in the way that they work; you may find this useful to keep in mind "
2747 "as we continue our tour."
2748 msgstr ""
2750 #. type: Content of: <book><chapter><sect1><para>
2751 #: ../en/ch01-tour-basic.xml:380
2752 msgid ""
2753 "Mercurial has a consistent and straightforward approach to dealing with the "
2754 "options that you can pass to commands. It follows the conventions for "
2755 "options that are common to modern Linux and Unix systems."
2756 msgstr ""
2758 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
2759 #: ../en/ch01-tour-basic.xml:387
2760 msgid ""
2761 "Every option has a long name. For example, as we've already seen, the "
2762 "<command role=\"hg-cmd\">hg log</command> command accepts a <option role=\"hg-"
2763 "opt-log\">--rev</option> option."
2764 msgstr ""
2766 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
2767 #: ../en/ch01-tour-basic.xml:393
2768 msgid ""
2769 "Most options have short names, too. Instead of <option role=\"hg-opt-log\">--"
2770 "rev</option>, we can use <option role=\"hg-opt-log\">-r</option>. (The "
2771 "reason that some options don't have short names is that the options in "
2772 "question are rarely used.)"
2773 msgstr ""
2775 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
2776 #: ../en/ch01-tour-basic.xml:400
2777 msgid ""
2778 "Long options start with two dashes (e.g. <option role=\"hg-opt-log\">--rev</"
2779 "option>), while short options start with one (e.g. <option role=\"hg-opt-log"
2780 "\">-r</option>)."
2781 msgstr ""
2783 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
2784 #: ../en/ch01-tour-basic.xml:406
2785 msgid ""
2786 "Option naming and usage is consistent across commands. For example, every "
2787 "command that lets you specify a changeset ID or revision number accepts both "
2788 "<option role=\"hg-opt-log\">-r</option> and <option role=\"hg-opt-log\">--"
2789 "rev</option> arguments."
2790 msgstr ""
2792 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
2793 #: ../en/ch01-tour-basic.xml:413
2794 msgid ""
2795 "If you are using short options, you can save typing by running them together. "
2796 "For example, the command <command role=\"hg-cmd\">hg log -v -p -r 2</command> "
2797 "can be written as <command role=\"hg-cmd\">hg log -vpr2</command>."
2798 msgstr ""
2800 #. type: Content of: <book><chapter><sect1><para>
2801 #: ../en/ch01-tour-basic.xml:420
2802 msgid ""
2803 "In the examples throughout this book, I use short options instead of long. "
2804 "This just reflects my own preference, so don't read anything significant into "
2805 "it."
2806 msgstr ""
2808 #. type: Content of: <book><chapter><sect1><para>
2809 #: ../en/ch01-tour-basic.xml:424
2810 msgid ""
2811 "Most commands that print output of some kind will print more output when "
2812 "passed a <option role=\"hg-opt-global\">-v</option> (or <option role=\"hg-opt-"
2813 "global\">--verbose</option>) option, and less when passed <option role=\"hg-"
2814 "opt-global\">-q</option> (or <option role=\"hg-opt-global\">--quiet</option>)."
2815 msgstr ""
2817 #. type: Content of: <book><chapter><sect1><note><title>
2818 #: ../en/ch01-tour-basic.xml:431
2819 msgid "Option naming consistency"
2820 msgstr ""
2822 #. type: Content of: <book><chapter><sect1><note><para>
2823 #: ../en/ch01-tour-basic.xml:433
2824 msgid ""
2825 "Almost always, Mercurial commands use consistent option names to refer to the "
2826 "same concepts. For instance, if a command deals with changesets, you'll "
2827 "always identify them with <option role=\"hg-opt-log\">--rev</option> or "
2828 "<option role=\"hg-opt-log\">-r</option>. This consistent use of option names "
2829 "makes it easier to remember what options a particular command takes."
2830 msgstr ""
2832 #. type: Content of: <book><chapter><sect1><title>
2833 #: ../en/ch01-tour-basic.xml:444
2834 msgid "Making and reviewing changes"
2835 msgstr "创建和复审修改"
2837 #. type: Content of: <book><chapter><sect1><para>
2838 #: ../en/ch01-tour-basic.xml:446
2839 msgid ""
2840 "Now that we have a grasp of viewing history in Mercurial, let's take a look "
2841 "at making some changes and examining them."
2842 msgstr ""
2844 #. type: Content of: <book><chapter><sect1><para>
2845 #: ../en/ch01-tour-basic.xml:450
2846 msgid ""
2847 "The first thing we'll do is isolate our experiment in a repository of its "
2848 "own. We use the <command role=\"hg-cmd\">hg clone</command> command, but we "
2849 "don't need to clone a copy of the remote repository. Since we already have a "
2850 "copy of it locally, we can just clone that instead. This is much faster than "
2851 "cloning over the network, and cloning a local repository uses less disk space "
2852 "in most cases, too<placeholder type=\"footnote\" id=\"0\"/>."
2853 msgstr ""
2855 #. type: Content of: <book><chapter><sect1><para><footnote><para>
2856 #: ../en/ch01-tour-basic.xml:457
2857 msgid ""
2858 "The saving of space arises when source and destination repositories are on "
2859 "the same filesystem, in which case Mercurial will use hardlinks to do copy-on-"
2860 "write sharing of its internal metadata. If that explanation meant nothing to "
2861 "you, don't worry: everything happens transparently and automatically, and you "
2862 "don't need to understand it."
2863 msgstr ""
2865 #. type: Content of: <book><chapter><sect1><para>
2866 #: ../en/ch01-tour-basic.xml:467
2867 msgid ""
2868 "As an aside, it's often good practice to keep a <quote>pristine</quote> copy "
2869 "of a remote repository around, which you can then make temporary clones of to "
2870 "create sandboxes for each task you want to work on. This lets you work on "
2871 "multiple tasks in parallel, each isolated from the others until it's complete "
2872 "and you're ready to integrate it back. Because local clones are so cheap, "
2873 "there's almost no overhead to cloning and destroying repositories whenever "
2874 "you want."
2875 msgstr ""
2877 #. type: Content of: <book><chapter><sect1><para>
2878 #: ../en/ch01-tour-basic.xml:476
2879 msgid ""
2880 "In our <filename class=\"directory\">my-hello</filename> repository, we have "
2881 "a file <filename>hello.c</filename> that contains the classic <quote>hello, "
2882 "world</quote> program."
2883 msgstr ""
2885 #. type: Content of: <book><chapter><sect1><para>
2886 #: ../en/ch01-tour-basic.xml:482
2887 msgid "Let's edit this file so that it prints a second line of output."
2888 msgstr ""
2890 #. type: Content of: <book><chapter><sect1><para>
2891 #: ../en/ch01-tour-basic.xml:487
2892 msgid ""
2893 "Mercurial's <command role=\"hg-cmd\">hg status</command> command will tell us "
2894 "what Mercurial knows about the files in the repository."
2895 msgstr ""
2897 #. type: Content of: <book><chapter><sect1><para>
2898 #: ../en/ch01-tour-basic.xml:493
2899 msgid ""
2900 "The <command role=\"hg-cmd\">hg status</command> command prints no output for "
2901 "some files, but a line starting with <quote><literal>M</literal></quote> for "
2902 "<filename>hello.c</filename>. Unless you tell it to, <command role=\"hg-cmd"
2903 "\">hg status</command> will not print any output for files that have not been "
2904 "modified."
2905 msgstr ""
2907 #. type: Content of: <book><chapter><sect1><para>
2908 #: ../en/ch01-tour-basic.xml:500
2909 msgid ""
2910 "The <quote><literal>M</literal></quote> indicates that Mercurial has noticed "
2911 "that we modified <filename>hello.c</filename>. We didn't need to "
2912 "<emphasis>inform</emphasis> Mercurial that we were going to modify the file "
2913 "before we started, or that we had modified the file after we were done; it "
2914 "was able to figure this out itself."
2915 msgstr ""
2917 #. type: Content of: <book><chapter><sect1><para>
2918 #: ../en/ch01-tour-basic.xml:508
2919 msgid ""
2920 "It's somewhat helpful to know that we've modified <filename>hello.c</"
2921 "filename>, but we might prefer to know exactly <emphasis>what</emphasis> "
2922 "changes we've made to it. To do this, we use the <command role=\"hg-cmd\">hg "
2923 "diff</command> command."
2924 msgstr ""
2926 #. type: Content of: <book><chapter><sect1><title>
2927 #: ../en/ch01-tour-basic.xml:517 ../en/ch11-mq.xml:187
2928 msgid "Understanding patches"
2929 msgstr "理解补丁"
2931 #. type: Content of: <book><chapter><sect1><tip><para>
2932 #: ../en/ch01-tour-basic.xml:519
2933 msgid ""
2934 "Remember to take a look at <xref linkend=\"sec:mq:patch\"/> if you don't know "
2935 "how to read output above."
2936 msgstr ""
2938 #. type: Content of: <book><chapter><sect1><title>
2939 #: ../en/ch01-tour-basic.xml:525
2940 msgid "Recording changes in a new changeset"
2941 msgstr "在新修改集中记录修改"
2943 #. type: Content of: <book><chapter><sect1><para>
2944 #: ../en/ch01-tour-basic.xml:527
2945 msgid ""
2946 "We can modify files, build and test our changes, and use <command role=\"hg-"
2947 "cmd\">hg status</command> and <command role=\"hg-cmd\">hg diff</command> to "
2948 "review our changes, until we're satisfied with what we've done and arrive at "
2949 "a natural stopping point where we want to record our work in a new changeset."
2950 msgstr ""
2952 #. type: Content of: <book><chapter><sect1><para>
2953 #: ../en/ch01-tour-basic.xml:534
2954 msgid ""
2955 "The <command role=\"hg-cmd\">hg commit</command> command lets us create a new "
2956 "changeset; we'll usually refer to this as <quote>making a commit</quote> or "
2957 "<quote>committing</quote>."
2958 msgstr ""
2960 #. type: Content of: <book><chapter><sect1><sect2><title>
2961 #: ../en/ch01-tour-basic.xml:540
2962 msgid "Setting up a username"
2963 msgstr "配置用户名称"
2965 #. type: Content of: <book><chapter><sect1><sect2><para>
2966 #: ../en/ch01-tour-basic.xml:542
2967 msgid ""
2968 "When you try to run <command role=\"hg-cmd\">hg commit</command> for the "
2969 "first time, it is not guaranteed to succeed. Mercurial records your name and "
2970 "address with each change that you commit, so that you and others will later "
2971 "be able to tell who made each change. Mercurial tries to automatically "
2972 "figure out a sensible username to commit the change with. It will attempt "
2973 "each of the following methods, in order:"
2974 msgstr ""
2976 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
2977 #: ../en/ch01-tour-basic.xml:551
2978 msgid ""
2979 "If you specify a <option role=\"hg-opt-commit\">-u</option> option to the "
2980 "<command role=\"hg-cmd\">hg commit</command> command on the command line, "
2981 "followed by a username, this is always given the highest precedence."
2982 msgstr ""
2984 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
2985 #: ../en/ch01-tour-basic.xml:556
2986 msgid ""
2987 "If you have set the <envar>HGUSER</envar> environment variable, this is "
2988 "checked next."
2989 msgstr ""
2991 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
2992 #: ../en/ch01-tour-basic.xml:559
2993 msgid ""
2994 "If you create a file in your home directory called <filename role=\"special"
2995 "\">.hgrc</filename>, with a <envar role=\"rc-item-ui\">username</envar> "
2996 "entry, that will be used next. To see what the contents of this file should "
2997 "look like, refer to <xref linkend=\"sec:tour-basic:username\"/> below."
2998 msgstr ""
3000 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
3001 #: ../en/ch01-tour-basic.xml:567
3002 msgid ""
3003 "If you have set the <envar>EMAIL</envar> environment variable, this will be "
3004 "used next."
3005 msgstr ""
3007 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
3008 #: ../en/ch01-tour-basic.xml:570
3009 msgid ""
3010 "Mercurial will query your system to find out your local user name and host "
3011 "name, and construct a username from these components. Since this often "
3012 "results in a username that is not very useful, it will print a warning if it "
3013 "has to do this."
3014 msgstr ""
3016 #. type: Content of: <book><chapter><sect1><sect2><para>
3017 #: ../en/ch01-tour-basic.xml:577
3018 msgid ""
3019 "If all of these mechanisms fail, Mercurial will fail, printing an error "
3020 "message. In this case, it will not let you commit until you set up a "
3021 "username."
3022 msgstr ""
3024 #. type: Content of: <book><chapter><sect1><sect2><para>
3025 #: ../en/ch01-tour-basic.xml:581
3026 msgid ""
3027 "You should think of the <envar>HGUSER</envar> environment variable and the "
3028 "<option role=\"hg-opt-commit\">-u</option> option to the <command role=\"hg-"
3029 "cmd\">hg commit</command> command as ways to <emphasis>override</emphasis> "
3030 "Mercurial's default selection of username. For normal use, the simplest and "
3031 "most robust way to set a username for yourself is by creating a <filename "
3032 "role=\"special\">.hgrc</filename> file; see below for details."
3033 msgstr ""
3035 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
3036 #: ../en/ch01-tour-basic.xml:590
3037 msgid "Creating a Mercurial configuration file"
3038 msgstr "创建 Mercurial 的配置文件"
3040 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
3041 #: ../en/ch01-tour-basic.xml:592
3042 msgid ""
3043 "To set a user name, use your favorite editor to create a file called "
3044 "<filename role=\"special\">.hgrc</filename> in your home directory. "
3045 "Mercurial will use this file to look up your personalised configuration "
3046 "settings. The initial contents of your <filename role=\"special\">.hgrc</"
3047 "filename> should look like this."
3048 msgstr ""
3050 #. type: Content of: <book><chapter><sect1><sect2><sect3><remark>
3051 #: ../en/ch01-tour-basic.xml:600
3052 msgid "Figure out what the appropriate directory is on Windows."
3053 msgstr ""
3055 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
3056 #: ../en/ch01-tour-basic.xml:607
3057 msgid ""
3058 "The <quote><literal>[ui]</literal></quote> line begins a <emphasis>section</"
3059 "emphasis> of the config file, so you can read the <quote><literal>username "
3060 "= ...</literal></quote> line as meaning <quote>set the value of the "
3061 "<literal>username</literal> item in the <literal>ui</literal> section</"
3062 "quote>. A section continues until a new section begins, or the end of the "
3063 "file. Mercurial ignores empty lines and treats any text from "
3064 "<quote><literal>#</literal></quote> to the end of a line as a comment."
3065 msgstr ""
3067 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
3068 #: ../en/ch01-tour-basic.xml:620
3069 msgid "Choosing a user name"
3070 msgstr "选择用户名称"
3072 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
3073 #: ../en/ch01-tour-basic.xml:622
3074 msgid ""
3075 "You can use any text you like as the value of the <literal>username</literal> "
3076 "config item, since this information is for reading by other people, but will "
3077 "not be interpreted by Mercurial. The convention that most people follow is "
3078 "to use their name and email address, as in the example above."
3079 msgstr ""
3081 #. type: Content of: <book><chapter><sect1><sect2><sect3><note><para>
3082 #: ../en/ch01-tour-basic.xml:629
3083 msgid ""
3084 "Mercurial's built-in web server obfuscates email addresses, to make it more "
3085 "difficult for the email harvesting tools that spammers use. This reduces the "
3086 "likelihood that you'll start receiving more junk email if you publish a "
3087 "Mercurial repository on the web."
3088 msgstr ""
3090 #. type: Content of: <book><chapter><sect1><sect2><title>
3091 #: ../en/ch01-tour-basic.xml:639
3092 msgid "Writing a commit message"
3093 msgstr "写提交日志"
3095 #. type: Content of: <book><chapter><sect1><sect2><para>
3096 #: ../en/ch01-tour-basic.xml:641
3097 msgid ""
3098 "When we commit a change, Mercurial drops us into a text editor, to enter a "
3099 "message that will describe the modifications we've made in this changeset. "
3100 "This is called the <emphasis>commit message</emphasis>. It will be a record "
3101 "for readers of what we did and why, and it will be printed by <command role="
3102 "\"hg-cmd\">hg log</command> after we've finished committing."
3103 msgstr ""
3105 #. type: Content of: <book><chapter><sect1><sect2><para>
3106 #: ../en/ch01-tour-basic.xml:651
3107 msgid ""
3108 "The editor that the <command role=\"hg-cmd\">hg commit</command> command "
3109 "drops us into will contain an empty line or two, followed by a number of "
3110 "lines starting with <quote><literal>HG:</literal></quote>."
3111 msgstr ""
3113 #. type: Content of: <book><chapter><sect1><sect2><para>
3114 #: ../en/ch01-tour-basic.xml:665
3115 msgid ""
3116 "Mercurial ignores the lines that start with <quote><literal>HG:</literal></"
3117 "quote>; it uses them only to tell us which files it's recording changes to. "
3118 "Modifying or deleting these lines has no effect."
3119 msgstr ""
3121 #. type: Content of: <book><chapter><sect1><sect2><title>
3122 #: ../en/ch01-tour-basic.xml:671
3123 msgid "Writing a good commit message"
3124 msgstr "写好提交日志"
3126 #. type: Content of: <book><chapter><sect1><sect2><para>
3127 #: ../en/ch01-tour-basic.xml:673
3128 msgid ""
3129 "Since <command role=\"hg-cmd\">hg log</command> only prints the first line of "
3130 "a commit message by default, it's best to write a commit message whose first "
3131 "line stands alone. Here's a real example of a commit message that "
3132 "<emphasis>doesn't</emphasis> follow this guideline, and hence has a summary "
3133 "that is not readable."
3134 msgstr ""
3136 #. type: Content of: <book><chapter><sect1><sect2><para>
3137 #: ../en/ch01-tour-basic.xml:687
3138 msgid ""
3139 "As far as the remainder of the contents of the commit message are concerned, "
3140 "there are no hard-and-fast rules. Mercurial itself doesn't interpret or care "
3141 "about the contents of the commit message, though your project may have "
3142 "policies that dictate a certain kind of formatting."
3143 msgstr ""
3145 #. type: Content of: <book><chapter><sect1><sect2><para>
3146 #: ../en/ch01-tour-basic.xml:693
3147 msgid ""
3148 "My personal preference is for short, but informative, commit messages that "
3149 "tell me something that I can't figure out with a quick glance at the output "
3150 "of <command role=\"hg-cmd\">hg log --patch</command>."
3151 msgstr ""
3153 #. type: Content of: <book><chapter><sect1><sect2><title>
3154 #: ../en/ch01-tour-basic.xml:700
3155 msgid "Aborting a commit"
3156 msgstr "终止提交"
3158 #. type: Content of: <book><chapter><sect1><sect2><para>
3159 #: ../en/ch01-tour-basic.xml:702
3160 msgid ""
3161 "If you decide that you don't want to commit while in the middle of editing a "
3162 "commit message, simply exit from your editor without saving the file that "
3163 "it's editing. This will cause nothing to happen to either the repository or "
3164 "the working directory."
3165 msgstr ""
3167 #. type: Content of: <book><chapter><sect1><sect2><para>
3168 #: ../en/ch01-tour-basic.xml:707
3169 msgid ""
3170 "If we run the <command role=\"hg-cmd\">hg commit</command> command without "
3171 "any arguments, it records all of the changes we've made, as reported by "
3172 "<command role=\"hg-cmd\">hg status</command> and <command role=\"hg-cmd\">hg "
3173 "diff</command>."
3174 msgstr ""
3176 #. type: Content of: <book><chapter><sect1><sect2><title>
3177 #: ../en/ch01-tour-basic.xml:714
3178 msgid "Admiring our new handiwork"
3179 msgstr "欣赏我们的成果"
3181 #. type: Content of: <book><chapter><sect1><sect2><para>
3182 #: ../en/ch01-tour-basic.xml:716
3183 msgid ""
3184 "Once we've finished the commit, we can use the <command role=\"hg-cmd\">hg "
3185 "tip</command> command to display the changeset we just created. This command "
3186 "produces output that is identical to <command role=\"hg-cmd\">hg log</"
3187 "command>, but it only displays the newest revision in the repository."
3188 msgstr ""
3190 #. type: Content of: <book><chapter><sect1><sect2><para>
3191 #: ../en/ch01-tour-basic.xml:725
3192 msgid ""
3193 "We refer to the newest revision in the repository as the <emphasis>tip "
3194 "revision</emphasis>, or simply the <emphasis>tip</emphasis>."
3195 msgstr ""
3197 #. type: Content of: <book><chapter><sect1><sect2><para>
3198 #: ../en/ch01-tour-basic.xml:729
3199 msgid ""
3200 "By the way, the <command role=\"hg-cmd\">hg tip</command> command accepts "
3201 "many of the same options as <command role=\"hg-cmd\">hg log</command>, so "
3202 "<option role=\"hg-opt-global\">-v</option> above indicates <quote>be verbose</"
3203 "quote>, <option role=\"hg-opt-tip\">-p</option> specifies <quote>print a "
3204 "patch</quote>. The use of <option role=\"hg-opt-tip\">-p</option> to print "
3205 "patches is another example of the consistent naming we mentioned earlier."
3206 msgstr ""
3208 #. type: Content of: <book><chapter><sect1><title>
3209 #: ../en/ch01-tour-basic.xml:741
3210 msgid "Sharing changes"
3211 msgstr "共享修改"
3213 #. type: Content of: <book><chapter><sect1><para>
3214 #: ../en/ch01-tour-basic.xml:743
3215 msgid ""
3216 "We mentioned earlier that repositories in Mercurial are self-contained. This "
3217 "means that the changeset we just created exists only in our <filename class="
3218 "\"directory\">my-hello</filename> repository. Let's look at a few ways that "
3219 "we can propagate this change into other repositories."
3220 msgstr ""
3222 #. type: Content of: <book><chapter><sect1><sect2><title>
3223 #: ../en/ch01-tour-basic.xml:751
3224 msgid "Pulling changes from another repository"
3225 msgstr "从其它版本库取得修改"
3227 #. type: Content of: <book><chapter><sect1><sect2><para>
3228 #: ../en/ch01-tour-basic.xml:752
3229 msgid ""
3230 "To get started, let's clone our original <filename class=\"directory\">hello</"
3231 "filename> repository, which does not contain the change we just committed. "
3232 "We'll call our temporary repository <filename class=\"directory\">hello-pull</"
3233 "filename>."
3234 msgstr ""
3236 #. type: Content of: <book><chapter><sect1><sect2><para>
3237 #: ../en/ch01-tour-basic.xml:760
3238 msgid ""
3239 "We'll use the <command role=\"hg-cmd\">hg pull</command> command to bring "
3240 "changes from <filename class=\"directory\">my-hello</filename> into <filename "
3241 "class=\"directory\">hello-pull</filename>. However, blindly pulling unknown "
3242 "changes into a repository is a somewhat scary prospect. Mercurial provides "
3243 "the <command role=\"hg-cmd\">hg incoming</command> command to tell us what "
3244 "changes the <command role=\"hg-cmd\">hg pull</command> command "
3245 "<emphasis>would</emphasis> pull into the repository, without actually pulling "
3246 "the changes in."
3247 msgstr ""
3249 #. type: Content of: <book><chapter><sect1><sect2><para>
3250 #: ../en/ch01-tour-basic.xml:773
3251 msgid ""
3252 "Suppose you're pulling changes from a repository on the network somewhere. "
3253 "While you are looking at the <command role=\"hg-cmd\">hg incoming</command> "
3254 "output, and before you pull those changes, someone might have committed "
3255 "something in the remote repository. This means that it's possible to pull "
3256 "more changes than you saw when using <command role=\"hg-cmd\">hg incoming</"
3257 "command>."
3258 msgstr ""
3260 #. type: Content of: <book><chapter><sect1><sect2><para>
3261 #: ../en/ch01-tour-basic.xml:781
3262 msgid ""
3263 "Bringing changes into a repository is a simple matter of running the <command "
3264 "role=\"hg-cmd\">hg pull</command> command, and telling it which repository to "
3265 "pull from."
3266 msgstr ""
3268 #. type: Content of: <book><chapter><sect1><sect2><para>
3269 #: ../en/ch01-tour-basic.xml:788
3270 msgid ""
3271 "As you can see from the before-and-after output of <command role=\"hg-cmd"
3272 "\">hg tip</command>, we have successfully pulled changes into our "
3273 "repository. There remains one step before we can see these changes in the "
3274 "working directory."
3275 msgstr ""
3277 #. type: Content of: <book><chapter><sect1><sect2><title>
3278 #: ../en/ch01-tour-basic.xml:796
3279 msgid "Updating the working directory"
3280 msgstr "更新工作目录"
3282 #. type: Content of: <book><chapter><sect1><sect2><para>
3283 #: ../en/ch01-tour-basic.xml:798
3284 msgid ""
3285 "We have so far glossed over the relationship between a repository and its "
3286 "working directory. The <command role=\"hg-cmd\">hg pull</command> command "
3287 "that we ran in <xref linkend=\"sec:tour:pull\"/> brought changes into the "
3288 "repository, but if we check, there's no sign of those changes in the working "
3289 "directory. This is because <command role=\"hg-cmd\">hg pull</command> does "
3290 "not (by default) touch the working directory. Instead, we use the <command "
3291 "role=\"hg-cmd\">hg update</command> command to do this."
3292 msgstr ""
3294 #. type: Content of: <book><chapter><sect1><sect2><para>
3295 #: ../en/ch01-tour-basic.xml:810
3296 msgid ""
3297 "It might seem a bit strange that <command role=\"hg-cmd\">hg pull</command> "
3298 "doesn't update the working directory automatically. There's actually a good "
3299 "reason for this: you can use <command role=\"hg-cmd\">hg update</command> to "
3300 "update the working directory to the state it was in at <emphasis>any "
3301 "revision</emphasis> in the history of the repository. If you had the working "
3302 "directory updated to an old revision&emdash;to hunt down the origin of a bug, "
3303 "say&emdash;and ran a <command role=\"hg-cmd\">hg pull</command> which "
3304 "automatically updated the working directory to a new revision, you might not "
3305 "be terribly happy."
3306 msgstr ""
3308 #. type: Content of: <book><chapter><sect1><sect2><para>
3309 #: ../en/ch01-tour-basic.xml:821
3310 msgid ""
3311 "However, since pull-then-update is such a common thing to do, Mercurial lets "
3312 "you combine the two by passing the <option role=\"hg-opt-pull\">-u</option> "
3313 "option to <command role=\"hg-cmd\">hg pull</command>."
3314 msgstr ""
3316 #. type: Content of: <book><chapter><sect1><sect2><para>
3317 #: ../en/ch01-tour-basic.xml:826
3318 msgid ""
3319 "If you look back at the output of <command role=\"hg-cmd\">hg pull</command> "
3320 "in <xref linkend=\"sec:tour:pull\"/> when we ran it without <option role=\"hg-"
3321 "opt-pull\">-u</option>, you can see that it printed a helpful reminder that "
3322 "we'd have to take an explicit step to update the working directory:"
3323 msgstr ""
3325 #. type: Content of: <book><chapter><sect1><sect2><para>
3326 #: ../en/ch01-tour-basic.xml:835
3327 msgid ""
3328 "To find out what revision the working directory is at, use the <command role="
3329 "\"hg-cmd\">hg parents</command> command."
3330 msgstr ""
3332 #. type: Content of: <book><chapter><sect1><sect2><para>
3333 #: ../en/ch01-tour-basic.xml:841
3334 msgid ""
3335 "If you look back at <xref linkend=\"fig:tour-basic:history\"/>, you'll see "
3336 "arrows connecting each changeset. The node that the arrow leads "
3337 "<emphasis>from</emphasis> in each case is a parent, and the node that the "
3338 "arrow leads <emphasis>to</emphasis> is its child. The working directory has "
3339 "a parent in just the same way; this is the changeset that the working "
3340 "directory currently contains."
3341 msgstr ""
3343 #. type: Content of: <book><chapter><sect1><sect2><para>
3344 #: ../en/ch01-tour-basic.xml:850
3345 msgid ""
3346 "To update the working directory to a particular revision, give a revision "
3347 "number or changeset ID to the <command role=\"hg-cmd\">hg update</command> "
3348 "command."
3349 msgstr ""
3351 #. type: Content of: <book><chapter><sect1><sect2><para>
3352 #: ../en/ch01-tour-basic.xml:857
3353 msgid ""
3354 "If you omit an explicit revision, <command role=\"hg-cmd\">hg update</"
3355 "command> will update to the tip revision, as shown by the second call to "
3356 "<command role=\"hg-cmd\">hg update</command> in the example above."
3357 msgstr ""
3359 #. type: Content of: <book><chapter><sect1><sect2><title>
3360 #: ../en/ch01-tour-basic.xml:865
3361 msgid "Pushing changes to another repository"
3362 msgstr "发布修改到其它版本库"
3364 #. type: Content of: <book><chapter><sect1><sect2><para>
3365 #: ../en/ch01-tour-basic.xml:867
3366 msgid ""
3367 "Mercurial lets us push changes to another repository, from the repository "
3368 "we're currently visiting. As with the example of <command role=\"hg-cmd\">hg "
3369 "pull</command> above, we'll create a temporary repository to push our changes "
3370 "into."
3371 msgstr ""
3373 #. type: Content of: <book><chapter><sect1><sect2><para>
3374 #: ../en/ch01-tour-basic.xml:875
3375 msgid ""
3376 "The <command role=\"hg-cmd\">hg outgoing</command> command tells us what "
3377 "changes would be pushed into another repository."
3378 msgstr ""
3380 #. type: Content of: <book><chapter><sect1><sect2><para>
3381 #: ../en/ch01-tour-basic.xml:881
3382 msgid ""
3383 "And the <command role=\"hg-cmd\">hg push</command> command does the actual "
3384 "push."
3385 msgstr ""
3387 #. type: Content of: <book><chapter><sect1><sect2><para>
3388 #: ../en/ch01-tour-basic.xml:887
3389 msgid ""
3390 "As with <command role=\"hg-cmd\">hg pull</command>, the <command role=\"hg-cmd"
3391 "\">hg push</command> command does not update the working directory in the "
3392 "repository that it's pushing changes into. Unlike <command role=\"hg-cmd\">hg "
3393 "pull</command>, <command role=\"hg-cmd\">hg push</command> does not provide a "
3394 "<literal>-u</literal> option that updates the other repository's working "
3395 "directory. This asymmetry is deliberate: the repository we're pushing to "
3396 "might be on a remote server and shared between several people. If we were to "
3397 "update its working directory while someone was working in it, their work "
3398 "would be disrupted."
3399 msgstr ""
3401 #. type: Content of: <book><chapter><sect1><sect2><para>
3402 #: ../en/ch01-tour-basic.xml:899
3403 msgid ""
3404 "What happens if we try to pull or push changes and the receiving repository "
3405 "already has those changes? Nothing too exciting."
3406 msgstr ""
3408 #. type: Content of: <book><chapter><sect1><sect2><title>
3409 #: ../en/ch01-tour-basic.xml:906
3410 msgid "Sharing changes over a network"
3411 msgstr "通过网络共享修改"
3413 #. type: Content of: <book><chapter><sect1><sect2><para>
3414 #: ../en/ch01-tour-basic.xml:908
3415 msgid ""
3416 "The commands we have covered in the previous few sections are not limited to "
3417 "working with local repositories. Each works in exactly the same fashion over "
3418 "a network connection; simply pass in a URL instead of a local path."
3419 msgstr ""
3421 #. type: Content of: <book><chapter><sect1><sect2><para>
3422 #: ../en/ch01-tour-basic.xml:916
3423 msgid ""
3424 "In this example, we can see what changes we could push to the remote "
3425 "repository, but the repository is understandably not set up to let anonymous "
3426 "users push to it."
3427 msgstr ""
3429 #. type: Content of: <book><chapter><title>
3430 #: ../en/ch02-tour-merge.xml:5
3431 msgid "A tour of Mercurial: merging work"
3432 msgstr "Mercurial 教程: 合并工作"
3434 #. type: Content of: <book><chapter><para>
3435 #: ../en/ch02-tour-merge.xml:7
3436 msgid ""
3437 "We've now covered cloning a repository, making changes in a repository, and "
3438 "pulling or pushing changes from one repository into another. Our next step "
3439 "is <emphasis>merging</emphasis> changes from separate repositories."
3440 msgstr ""
3442 #. type: Content of: <book><chapter><sect1><title>
3443 #: ../en/ch02-tour-merge.xml:13
3444 msgid "Merging streams of work"
3445 msgstr "合并的流程"
3447 #. type: Content of: <book><chapter><sect1><para>
3448 #: ../en/ch02-tour-merge.xml:15
3449 msgid ""
3450 "Merging is a fundamental part of working with a distributed revision control "
3451 "tool."
3452 msgstr ""
3454 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
3455 #: ../en/ch02-tour-merge.xml:18
3456 msgid ""
3457 "Alice and Bob each have a personal copy of a repository for a project they're "
3458 "collaborating on. Alice fixes a bug in her repository; Bob adds a new "
3459 "feature in his. They want the shared repository to contain both the bug fix "
3460 "and the new feature."
3461 msgstr ""
3463 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
3464 #: ../en/ch02-tour-merge.xml:24
3465 msgid ""
3466 "I frequently work on several different tasks for a single project at once, "
3467 "each safely isolated in its own repository. Working this way means that I "
3468 "often need to merge one piece of my own work with another."
3469 msgstr ""
3471 #. type: Content of: <book><chapter><sect1><para>
3472 #: ../en/ch02-tour-merge.xml:30
3473 msgid ""
3474 "Because merging is such a common thing to need to do, Mercurial makes it "
3475 "easy. Let's walk through the process. We'll begin by cloning yet another "
3476 "repository (see how often they spring up?) and making a change in it."
3477 msgstr ""
3479 #. type: Content of: <book><chapter><sect1><para>
3480 #: ../en/ch02-tour-merge.xml:37
3481 msgid ""
3482 "We should now have two copies of <filename>hello.c</filename> with different "
3483 "contents. The histories of the two repositories have also diverged, as "
3484 "illustrated in <xref linkend=\"fig:tour-merge:sep-repos\"/>."
3485 msgstr ""
3487 #. type: Content of: <book><chapter><sect1><figure><title>
3488 #: ../en/ch02-tour-merge.xml:46
3489 msgid ""
3490 "Divergent recent histories of the <filename class=\"directory\">my-hello</"
3491 "filename> and <filename class=\"directory\">my-new-hello</filename> "
3492 "repositories"
3493 msgstr ""
3494 "<filename class=\"directory\">my-hello</filename> 与 <filename class="
3495 "\"directory\">my-new-hello</filename> 最新的历史分叉"
3497 #. type: Content of: <book><chapter><sect1><figure><mediaobject>
3498 #: ../en/ch02-tour-merge.xml:51
3499 msgid ""
3500 "<imageobject><imagedata fileref=\"figs/tour-merge-sep-repos.png\"/></"
3501 "imageobject>"
3502 msgstr ""
3504 #. type: Content of: <book><chapter><sect1><para>
3505 #: ../en/ch02-tour-merge.xml:56
3506 msgid ""
3507 "We already know that pulling changes from our <filename class=\"directory"
3508 "\">my-hello</filename> repository will have no effect on the working "
3509 "directory."
3510 msgstr ""
3512 #. type: Content of: <book><chapter><sect1><para>
3513 #: ../en/ch02-tour-merge.xml:62
3514 msgid ""
3515 "However, the <command role=\"hg-cmd\">hg pull</command> command says "
3516 "something about <quote>heads</quote>."
3517 msgstr ""
3519 #. type: Content of: <book><chapter><sect1><sect2><title>
3520 #: ../en/ch02-tour-merge.xml:66
3521 msgid "Head changesets"
3522 msgstr "顶点修改集"
3524 #. type: Content of: <book><chapter><sect1><sect2><para>
3525 #: ../en/ch02-tour-merge.xml:68
3526 msgid ""
3527 "A head is a change that has no descendants, or children, as they're also "
3528 "known. The tip revision is thus a head, because the newest revision in a "
3529 "repository doesn't have any children, but a repository can contain more than "
3530 "one head."
3531 msgstr ""
3533 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
3534 #: ../en/ch02-tour-merge.xml:75
3535 msgid ""
3536 "Repository contents after pulling from <filename class=\"directory\">my-"
3537 "hello</filename> into <filename class=\"directory\">my-new-hello</filename>"
3538 msgstr ""
3539 "从 <filename class=\"directory\">my-hello</filename> 拉到 <filename class="
3540 "\"directory\">my-new-hello</filename> 之后版本库的内容"
3542 #. type: Content of: <book><chapter><sect1><sect2><figure>
3543 #: ../en/ch02-tour-merge.xml:78 ../en/ch02-tour-merge.xml:159
3544 #: ../en/ch02-tour-merge.xml:256 ../en/ch03-concepts.xml:57
3545 #: ../en/ch03-concepts.xml:106 ../en/ch03-concepts.xml:191
3546 #: ../en/ch03-concepts.xml:346 ../en/ch03-concepts.xml:361
3547 #: ../en/ch03-concepts.xml:402 ../en/ch03-concepts.xml:422
3548 #: ../en/ch03-concepts.xml:463 ../en/ch05-collab.xml:320
3549 #: ../en/ch08-undo.xml:363 ../en/ch08-undo.xml:410 ../en/ch08-undo.xml:475
3550 #: ../en/ch08-undo.xml:513 ../en/ch11-mq.xml:410
3551 msgid " <placeholder type=\"mediaobject\" id=\"0\"/>"
3552 msgstr ""
3554 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
3555 #: ../en/ch02-tour-merge.xml:79
3556 msgid ""
3557 "<imageobject> <imagedata fileref=\"figs/tour-merge-pull.png\"/> </imageobject>"
3558 msgstr ""
3560 #. type: Content of: <book><chapter><sect1><sect2><para>
3561 #: ../en/ch02-tour-merge.xml:86
3562 msgid ""
3563 "In <xref linkend=\"fig:tour-merge:pull\"/>, you can see the effect of the "
3564 "pull from <filename class=\"directory\">my-hello</filename> into <filename "
3565 "class=\"directory\">my-new-hello</filename>. The history that was already "
3566 "present in <filename class=\"directory\">my-new-hello</filename> is "
3567 "untouched, but a new revision has been added. By referring to <xref linkend="
3568 "\"fig:tour-merge:sep-repos\"/>, we can see that the <emphasis>changeset ID</"
3569 "emphasis> remains the same in the new repository, but the <emphasis>revision "
3570 "number</emphasis> has changed. (This, incidentally, is a fine example of why "
3571 "it's not safe to use revision numbers when discussing changesets.) We can "
3572 "view the heads in a repository using the <command role=\"hg-cmd\">hg heads</"
3573 "command> command."
3574 msgstr ""
3576 #. type: Content of: <book><chapter><sect1><sect2><title>
3577 #: ../en/ch02-tour-merge.xml:105
3578 msgid "Performing the merge"
3579 msgstr "执行合并"
3581 #. type: Content of: <book><chapter><sect1><sect2><para>
3582 #: ../en/ch02-tour-merge.xml:107
3583 msgid ""
3584 "What happens if we try to use the normal <command role=\"hg-cmd\">hg update</"
3585 "command> command to update to the new tip?"
3586 msgstr ""
3588 #. type: Content of: <book><chapter><sect1><sect2><para>
3589 #: ../en/ch02-tour-merge.xml:113
3590 msgid ""
3591 "Mercurial is telling us that the <command role=\"hg-cmd\">hg update</command> "
3592 "command won't do a merge; it won't update the working directory when it "
3593 "thinks we might want to do a merge, unless we force it to do so. Instead, we "
3594 "use the <command role=\"hg-cmd\">hg merge</command> command to merge the two "
3595 "heads."
3596 msgstr ""
3598 #. type: Content of: <book><chapter><sect1><sect2><para>
3599 #: ../en/ch02-tour-merge.xml:122
3600 msgid ""
3601 "This updates the working directory so that it contains changes from "
3602 "<emphasis>both</emphasis> heads, which is reflected in both the output of "
3603 "<command role=\"hg-cmd\">hg parents</command> and the contents of "
3604 "<filename>hello.c</filename>."
3605 msgstr ""
3607 #. type: Content of: <book><chapter><sect1><sect2><title>
3608 #: ../en/ch02-tour-merge.xml:132
3609 msgid "Committing the results of the merge"
3610 msgstr "提交合并结果"
3612 #. type: Content of: <book><chapter><sect1><sect2><para>
3613 #: ../en/ch02-tour-merge.xml:134
3614 msgid ""
3615 "Whenever we've done a merge, <command role=\"hg-cmd\">hg parents</command> "
3616 "will display two parents until we <command role=\"hg-cmd\">hg commit</"
3617 "command> the results of the merge."
3618 msgstr ""
3620 #. type: Content of: <book><chapter><sect1><sect2><para>
3621 #: ../en/ch02-tour-merge.xml:141
3622 msgid ""
3623 "We now have a new tip revision; notice that it has <emphasis>both</emphasis> "
3624 "of our former heads as its parents. These are the same revisions that were "
3625 "previously displayed by <command role=\"hg-cmd\">hg parents</command>."
3626 msgstr ""
3628 #. type: Content of: <book><chapter><sect1><sect2><para>
3629 #: ../en/ch02-tour-merge.xml:148
3630 msgid ""
3631 "In <xref linkend=\"fig:tour-merge:merge\"/>, you can see a representation of "
3632 "what happens to the working directory during the merge, and how this affects "
3633 "the repository when the commit happens. During the merge, the working "
3634 "directory has two parent changesets, and these become the parents of the new "
3635 "changeset."
3636 msgstr ""
3638 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
3639 #: ../en/ch02-tour-merge.xml:157
3640 msgid "Working directory and repository during merge, and following commit"
3641 msgstr "在合并期间,以及提交之后的工作目录与版本库"
3643 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
3644 #: ../en/ch02-tour-merge.xml:160
3645 msgid ""
3646 "<imageobject> <imagedata fileref=\"figs/tour-merge-merge.png\"/> </"
3647 "imageobject>"
3648 msgstr ""
3650 #. type: Content of: <book><chapter><sect1><sect2><para>
3651 #: ../en/ch02-tour-merge.xml:167
3652 msgid ""
3653 "We sometimes talk about a merge having <emphasis>sides</emphasis>: the left "
3654 "side is the first parent in the output of <command role=\"hg-cmd\">hg "
3655 "parents</command>, and the right side is the second. If the working "
3656 "directory was at e.g. revision 5 before we began a merge, that revision will "
3657 "become the left side of the merge."
3658 msgstr ""
3660 #. type: Content of: <book><chapter><sect1><title>
3661 #: ../en/ch02-tour-merge.xml:177
3662 msgid "Merging conflicting changes"
3663 msgstr "合并有冲突的改变"
3665 #. type: Content of: <book><chapter><sect1><para>
3666 #: ../en/ch02-tour-merge.xml:179
3667 msgid ""
3668 "Most merges are simple affairs, but sometimes you'll find yourself merging "
3669 "changes where each side modifies the same portions of the same files. Unless "
3670 "both modifications are identical, this results in a <emphasis>conflict</"
3671 "emphasis>, where you have to decide how to reconcile the different changes "
3672 "into something coherent."
3673 msgstr ""
3675 #. type: Content of: <book><chapter><sect1><figure><title>
3676 #: ../en/ch02-tour-merge.xml:187
3677 msgid "Conflicting changes to a document"
3678 msgstr "冲突的修改"
3680 #. type: Content of: <book><chapter><sect1><figure><mediaobject>
3681 #: ../en/ch02-tour-merge.xml:189
3682 msgid ""
3683 "<imageobject><imagedata fileref=\"figs/tour-merge-conflict.png\"/></"
3684 "imageobject>"
3685 msgstr ""
3687 #. type: Content of: <book><chapter><sect1><para>
3688 #: ../en/ch02-tour-merge.xml:194
3689 msgid ""
3690 "<xref linkend=\"fig:tour-merge:conflict\"/> illustrates an instance of two "
3691 "conflicting changes to a document. We started with a single version of the "
3692 "file; then we made some changes; while someone else made different changes to "
3693 "the same text. Our task in resolving the conflicting changes is to decide "
3694 "what the file should look like."
3695 msgstr ""
3697 #. type: Content of: <book><chapter><sect1><para>
3698 #: ../en/ch02-tour-merge.xml:201
3699 msgid ""
3700 "Mercurial doesn't have a built-in facility for handling conflicts. Instead, "
3701 "it runs an external program, usually one that displays some kind of graphical "
3702 "conflict resolution interface. By default, Mercurial tries to find one of "
3703 "several different merging tools that are likely to be installed on your "
3704 "system. It first tries a few fully automatic merging tools; if these don't "
3705 "succeed (because the resolution process requires human guidance) or aren't "
3706 "present, it tries a few different graphical merging tools."
3707 msgstr ""
3709 #. type: Content of: <book><chapter><sect1><para>
3710 #: ../en/ch02-tour-merge.xml:211
3711 msgid ""
3712 "It's also possible to get Mercurial to run another program or script instead "
3713 "of <command>hgmerge</command>, by setting the <envar>HGMERGE</envar> "
3714 "environment variable to the name of your preferred program."
3715 msgstr ""
3717 #. type: Content of: <book><chapter><sect1><sect2><title>
3718 #: ../en/ch02-tour-merge.xml:217
3719 msgid "Using a graphical merge tool"
3720 msgstr "使用图形合并工具"
3722 #. type: Content of: <book><chapter><sect1><sect2><para>
3723 #: ../en/ch02-tour-merge.xml:219
3724 msgid ""
3725 "My preferred graphical merge tool is <command>kdiff3</command>, which I'll "
3726 "use to describe the features that are common to graphical file merging "
3727 "tools. You can see a screenshot of <command>kdiff3</command> in action in "
3728 "<xref linkend=\"fig:tour-merge:kdiff3\"/>. The kind of merge it is "
3729 "performing is called a <emphasis>three-way merge</emphasis>, because there "
3730 "are three different versions of the file of interest to us. The tool thus "
3731 "splits the upper portion of the window into three panes:"
3732 msgstr ""
3734 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
3735 #: ../en/ch02-tour-merge.xml:229
3736 msgid ""
3737 "At the left is the <emphasis>base</emphasis> version of the file, i.e. the "
3738 "most recent version from which the two versions we're trying to merge are "
3739 "descended."
3740 msgstr ""
3742 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
3743 #: ../en/ch02-tour-merge.xml:234
3744 msgid ""
3745 "In the middle is <quote>our</quote> version of the file, with the contents "
3746 "that we modified."
3747 msgstr ""
3749 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
3750 #: ../en/ch02-tour-merge.xml:237
3751 msgid ""
3752 "On the right is <quote>their</quote> version of the file, the one that from "
3753 "the changeset that we're trying to merge with."
3754 msgstr ""
3756 #. type: Content of: <book><chapter><sect1><sect2><para>
3757 #: ../en/ch02-tour-merge.xml:241
3758 msgid ""
3759 "In the pane below these is the current <emphasis>result</emphasis> of the "
3760 "merge. Our task is to replace all of the red text, which indicates unresolved "
3761 "conflicts, with some sensible merger of the <quote>ours</quote> and "
3762 "<quote>theirs</quote> versions of the file."
3763 msgstr ""
3765 #. type: Content of: <book><chapter><sect1><sect2><para>
3766 #: ../en/ch02-tour-merge.xml:248
3767 msgid ""
3768 "All four of these panes are <emphasis>locked together</emphasis>; if we "
3769 "scroll vertically or horizontally in any of them, the others are updated to "
3770 "display the corresponding sections of their respective files."
3771 msgstr ""
3773 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
3774 #: ../en/ch02-tour-merge.xml:254
3775 msgid "Using <command>kdiff3</command> to merge versions of a file"
3776 msgstr "使用 <command>kdiff3</command> 合并文件的不同版本"
3778 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
3779 #: ../en/ch02-tour-merge.xml:257
3780 msgid ""
3781 "<imageobject> <imagedata width=\"100%\" fileref=\"figs/kdiff3.png\"/></"
3782 "imageobject>"
3783 msgstr ""
3785 #. type: Content of: <book><chapter><sect1><sect2><para>
3786 #: ../en/ch02-tour-merge.xml:265
3787 msgid ""
3788 "For each conflicting portion of the file, we can choose to resolve the "
3789 "conflict using some combination of text from the base version, ours, or "
3790 "theirs. We can also manually edit the merged file at any time, in case we "
3791 "need to make further modifications."
3792 msgstr ""
3794 #. type: Content of: <book><chapter><sect1><sect2><para>
3795 #: ../en/ch02-tour-merge.xml:271
3796 msgid ""
3797 "There are <emphasis>many</emphasis> file merging tools available, too many to "
3798 "cover here. They vary in which platforms they are available for, and in "
3799 "their particular strengths and weaknesses. Most are tuned for merging files "
3800 "containing plain text, while a few are aimed at specialised file formats "
3801 "(generally XML)."
3802 msgstr ""
3804 #. type: Content of: <book><chapter><sect1><sect2><title>
3805 #: ../en/ch02-tour-merge.xml:280
3806 msgid "A worked example"
3807 msgstr "合并实例"
3809 #. type: Content of: <book><chapter><sect1><sect2><para>
3810 #: ../en/ch02-tour-merge.xml:282
3811 msgid ""
3812 "In this example, we will reproduce the file modification history of <xref "
3813 "linkend=\"fig:tour-merge:conflict\"/> above. Let's begin by creating a "
3814 "repository with a base version of our document."
3815 msgstr ""
3817 #. type: Content of: <book><chapter><sect1><sect2><para>
3818 #: ../en/ch02-tour-merge.xml:289
3819 msgid "We'll clone the repository and make a change to the file."
3820 msgstr ""
3822 #. type: Content of: <book><chapter><sect1><sect2><para>
3823 #: ../en/ch02-tour-merge.xml:294
3824 msgid ""
3825 "And another clone, to simulate someone else making a change to the file. "
3826 "(This hints at the idea that it's not all that unusual to merge with yourself "
3827 "when you isolate tasks in separate repositories, and indeed to find and "
3828 "resolve conflicts while doing so.)"
3829 msgstr ""
3831 #. type: Content of: <book><chapter><sect1><sect2><para>
3832 #: ../en/ch02-tour-merge.xml:302
3833 msgid ""
3834 "Having created two different versions of the file, we'll set up an "
3835 "environment suitable for running our merge."
3836 msgstr ""
3838 #. type: Content of: <book><chapter><sect1><sect2><para>
3839 #: ../en/ch02-tour-merge.xml:308
3840 msgid ""
3841 "In this example, I'll set <envar>HGMERGE</envar> to tell Mercurial to use the "
3842 "non-interactive <command>merge</command> command. This is bundled with many "
3843 "Unix-like systems. (If you're following this example on your computer, don't "
3844 "bother setting <envar>HGMERGE</envar>.)"
3845 msgstr ""
3847 #. type: Content of: <book><chapter><sect1><sect2><para>
3848 #: ../en/ch02-tour-merge.xml:317
3849 msgid ""
3850 "Because <command>merge</command> can't resolve the conflicting changes, it "
3851 "leaves <emphasis>merge markers</emphasis> inside the file that has conflicts, "
3852 "indicating which lines have conflicts, and whether they came from our version "
3853 "of the file or theirs."
3854 msgstr ""
3856 #. type: Content of: <book><chapter><sect1><sect2><para>
3857 #: ../en/ch02-tour-merge.xml:323
3858 msgid ""
3859 "Mercurial can tell from the way <command>merge</command> exits that it wasn't "
3860 "able to merge successfully, so it tells us what commands we'll need to run if "
3861 "we want to redo the merging operation. This could be useful if, for example, "
3862 "we were running a graphical merge tool and quit because we were confused or "
3863 "realised we had made a mistake."
3864 msgstr ""
3866 #. type: Content of: <book><chapter><sect1><sect2><para>
3867 #: ../en/ch02-tour-merge.xml:330
3868 msgid ""
3869 "If automatic or manual merges fail, there's nothing to prevent us from "
3870 "<quote>fixing up</quote> the affected files ourselves, and committing the "
3871 "results of our merge:"
3872 msgstr ""
3874 #. type: Content of: <book><chapter><sect1><title>
3875 #: ../en/ch02-tour-merge.xml:339
3876 msgid "Simplifying the pull-merge-commit sequence"
3877 msgstr "简化拉-合并-提交程序"
3879 #. type: Content of: <book><chapter><sect1><para>
3880 #: ../en/ch02-tour-merge.xml:341
3881 msgid ""
3882 "The process of merging changes as outlined above is straightforward, but "
3883 "requires running three commands in sequence."
3884 msgstr ""
3886 #. type: Content of: <book><chapter><sect1><para>
3887 #: ../en/ch02-tour-merge.xml:347
3888 msgid ""
3889 "In the case of the final commit, you also need to enter a commit message, "
3890 "which is almost always going to be a piece of uninteresting "
3891 "<quote>boilerplate</quote> text."
3892 msgstr ""
3894 #. type: Content of: <book><chapter><sect1><para>
3895 #: ../en/ch02-tour-merge.xml:351
3896 msgid ""
3897 "It would be nice to reduce the number of steps needed, if this were "
3898 "possible. Indeed, Mercurial is distributed with an extension called <literal "
3899 "role=\"hg-ext\">fetch</literal> that does just this."
3900 msgstr ""
3902 #. type: Content of: <book><chapter><sect1><para>
3903 #: ../en/ch02-tour-merge.xml:356
3904 msgid ""
3905 "Mercurial provides a flexible extension mechanism that lets people extend its "
3906 "functionality, while keeping the core of Mercurial small and easy to deal "
3907 "with. Some extensions add new commands that you can use from the command "
3908 "line, while others work <quote>behind the scenes,</quote> for example adding "
3909 "capabilities to the server."
3910 msgstr ""
3912 #. type: Content of: <book><chapter><sect1><para>
3913 #: ../en/ch02-tour-merge.xml:363
3914 msgid ""
3915 "The <literal role=\"hg-ext\">fetch</literal> extension adds a new command "
3916 "called, not surprisingly, <command role=\"hg-cmd\">hg fetch</command>. This "
3917 "extension acts as a combination of <command role=\"hg-cmd\">hg pull -u</"
3918 "command>, <command role=\"hg-cmd\">hg merge</command> and <command role=\"hg-"
3919 "cmd\">hg commit</command>. It begins by pulling changes from another "
3920 "repository into the current repository. If it finds that the changes added a "
3921 "new head to the repository, it begins a merge, then (if the merge succeeded) "
3922 "commits the result of the merge with an automatically-generated commit "
3923 "message. If no new heads were added, it updates the working directory to the "
3924 "new tip changeset."
3925 msgstr ""
3927 #. type: Content of: <book><chapter><sect1><para>
3928 #: ../en/ch02-tour-merge.xml:376
3929 msgid ""
3930 "Enabling the <literal role=\"hg-ext\">fetch</literal> extension is easy. "
3931 "Edit the <filename role=\"special\">.hgrc</filename> file in your home "
3932 "directory, and either go to the <literal role=\"rc-extensions\">extensions</"
3933 "literal> section or create an <literal role=\"rc-extensions\">extensions</"
3934 "literal> section. Then add a line that simply reads <quote><literal>fetch=</"
3935 "literal></quote>."
3936 msgstr ""
3938 #. type: Content of: <book><chapter><sect1><para>
3939 #: ../en/ch02-tour-merge.xml:388
3940 msgid ""
3941 "(Normally, the right-hand side of the <quote><literal>=</literal></quote> "
3942 "would indicate where to find the extension, but since the <literal role=\"hg-"
3943 "ext\">fetch</literal> extension is in the standard distribution, Mercurial "
3944 "knows where to search for it.)"
3945 msgstr ""
3947 #. type: Content of: <book><chapter><title>
3948 #: ../en/ch03-concepts.xml:5
3949 msgid "Behind the scenes"
3950 msgstr "Mercurial 内幕"
3952 #. type: Content of: <book><chapter><para>
3953 #: ../en/ch03-concepts.xml:7
3954 msgid ""
3955 "Unlike many revision control systems, the concepts upon which Mercurial is "
3956 "built are simple enough that it's easy to understand how the software really "
3957 "works. Knowing these details certainly isn't necessary, so it is certainly "
3958 "safe to skip this chapter. However, I think you will get more out of the "
3959 "software with a <quote>mental model</quote> of what's going on."
3960 msgstr ""
3962 #. type: Content of: <book><chapter><para>
3963 #: ../en/ch03-concepts.xml:14
3964 msgid ""
3965 "Being able to understand what's going on behind the scenes gives me "
3966 "confidence that Mercurial has been carefully designed to be both "
3967 "<emphasis>safe</emphasis> and <emphasis>efficient</emphasis>. And just as "
3968 "importantly, if it's easy for me to retain a good idea of what the software "
3969 "is doing when I perform a revision control task, I'm less likely to be "
3970 "surprised by its behavior."
3971 msgstr ""
3973 #. type: Content of: <book><chapter><para>
3974 #: ../en/ch03-concepts.xml:22
3975 msgid ""
3976 "In this chapter, we'll initially cover the core concepts behind Mercurial's "
3977 "design, then continue to discuss some of the interesting details of its "
3978 "implementation."
3979 msgstr ""
3981 #. type: Content of: <book><chapter><sect1><title>
3982 #: ../en/ch03-concepts.xml:27
3983 msgid "Mercurial's historical record"
3984 msgstr "Mercurial 的历史记录"
3986 #. type: Content of: <book><chapter><sect1><sect2><title>
3987 #: ../en/ch03-concepts.xml:30
3988 msgid "Tracking the history of a single file"
3989 msgstr "跟踪单一文件的历史"
3991 #. type: Content of: <book><chapter><sect1><sect2><para>
3992 #: ../en/ch03-concepts.xml:32
3993 msgid ""
3994 "When Mercurial tracks modifications to a file, it stores the history of that "
3995 "file in a metadata object called a <emphasis>filelog</emphasis>. Each entry "
3996 "in the filelog contains enough information to reconstruct one revision of the "
3997 "file that is being tracked. Filelogs are stored as files in the <filename "
3998 "role=\"special\" class=\"directory\">.hg/store/data</filename> directory. A "
3999 "filelog contains two kinds of information: revision data, and an index to "
4000 "help Mercurial to find a revision efficiently."
4001 msgstr ""
4003 #. type: Content of: <book><chapter><sect1><sect2><para>
4004 #: ../en/ch03-concepts.xml:43
4005 msgid ""
4006 "A file that is large, or has a lot of history, has its filelog stored in "
4007 "separate data (<quote><literal>.d</literal></quote> suffix) and index "
4008 "(<quote><literal>.i</literal></quote> suffix) files. For small files without "
4009 "much history, the revision data and index are combined in a single "
4010 "<quote><literal>.i</literal></quote> file. The correspondence between a file "
4011 "in the working directory and the filelog that tracks its history in the "
4012 "repository is illustrated in <xref linkend=\"fig:concepts:filelog\"/>."
4013 msgstr ""
4015 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
4016 #: ../en/ch03-concepts.xml:55
4017 msgid ""
4018 "Relationships between files in working directory and filelogs in repository"
4019 msgstr "工作目录中的文件与版本库中的文件日志之间的关系"
4021 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
4022 #: ../en/ch03-concepts.xml:58
4023 msgid "<imageobject><imagedata fileref=\"figs/filelog.png\"/></imageobject>"
4024 msgstr ""
4026 #. type: Content of: <book><chapter><sect1><sect2><title>
4027 #: ../en/ch03-concepts.xml:65
4028 msgid "Managing tracked files"
4029 msgstr "管理跟踪的文件"
4031 #. type: Content of: <book><chapter><sect1><sect2><para>
4032 #: ../en/ch03-concepts.xml:67
4033 msgid ""
4034 "Mercurial uses a structure called a <emphasis>manifest</emphasis> to collect "
4035 "together information about the files that it tracks. Each entry in the "
4036 "manifest contains information about the files present in a single changeset. "
4037 "An entry records which files are present in the changeset, the revision of "
4038 "each file, and a few other pieces of file metadata."
4039 msgstr ""
4041 #. type: Content of: <book><chapter><sect1><sect2><title>
4042 #: ../en/ch03-concepts.xml:77
4043 msgid "Recording changeset information"
4044 msgstr "记录修改集信息"
4046 #. type: Content of: <book><chapter><sect1><sect2><para>
4047 #: ../en/ch03-concepts.xml:79
4048 msgid ""
4049 "The <emphasis>changelog</emphasis> contains information about each "
4050 "changeset. Each revision records who committed a change, the changeset "
4051 "comment, other pieces of changeset-related information, and the revision of "
4052 "the manifest to use."
4053 msgstr ""
4055 #. type: Content of: <book><chapter><sect1><sect2><title>
4056 #: ../en/ch03-concepts.xml:87
4057 msgid "Relationships between revisions"
4058 msgstr "版本之间的关系"
4060 #. type: Content of: <book><chapter><sect1><sect2><para>
4061 #: ../en/ch03-concepts.xml:89
4062 msgid ""
4063 "Within a changelog, a manifest, or a filelog, each revision stores a pointer "
4064 "to its immediate parent (or to its two parents, if it's a merge revision). "
4065 "As I mentioned above, there are also relationships between revisions "
4066 "<emphasis>across</emphasis> these structures, and they are hierarchical in "
4067 "nature."
4068 msgstr ""
4070 #. type: Content of: <book><chapter><sect1><sect2><para>
4071 #: ../en/ch03-concepts.xml:96
4072 msgid ""
4073 "For every changeset in a repository, there is exactly one revision stored in "
4074 "the changelog. Each revision of the changelog contains a pointer to a single "
4075 "revision of the manifest. A revision of the manifest stores a pointer to a "
4076 "single revision of each filelog tracked when that changeset was created. "
4077 "These relationships are illustrated in <xref linkend=\"fig:concepts:metadata"
4078 "\"/>."
4079 msgstr ""
4081 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
4082 #: ../en/ch03-concepts.xml:105
4083 msgid "Metadata relationships"
4084 msgstr "元数据之间的关系"
4086 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
4087 #: ../en/ch03-concepts.xml:107
4088 msgid "<imageobject><imagedata fileref=\"figs/metadata.png\"/></imageobject>"
4089 msgstr ""
4091 #. type: Content of: <book><chapter><sect1><sect2><para>
4092 #: ../en/ch03-concepts.xml:112
4093 msgid ""
4094 "As the illustration shows, there is <emphasis>not</emphasis> a <quote>one to "
4095 "one</quote> relationship between revisions in the changelog, manifest, or "
4096 "filelog. If the manifest hasn't changed between two changesets, the changelog "
4097 "entries for those changesets will point to the same revision of the "
4098 "manifest. If a file that Mercurial tracks hasn't changed between two "
4099 "changesets, the entry for that file in the two revisions of the manifest will "
4100 "point to the same revision of its filelog."
4101 msgstr ""
4103 #. type: Content of: <book><chapter><sect1><title>
4104 #: ../en/ch03-concepts.xml:125
4105 msgid "Safe, efficient storage"
4106 msgstr "安全,高效的存储"
4108 #. type: Content of: <book><chapter><sect1><para>
4109 #: ../en/ch03-concepts.xml:127
4110 msgid ""
4111 "The underpinnings of changelogs, manifests, and filelogs are provided by a "
4112 "single structure called the <emphasis>revlog</emphasis>."
4113 msgstr ""
4115 #. type: Content of: <book><chapter><sect1><sect2><title>
4116 #: ../en/ch03-concepts.xml:132
4117 msgid "Efficient storage"
4118 msgstr "高效存储"
4120 #. type: Content of: <book><chapter><sect1><sect2><para>
4121 #: ../en/ch03-concepts.xml:134
4122 msgid ""
4123 "The revlog provides efficient storage of revisions using a <emphasis>delta</"
4124 "emphasis> mechanism. Instead of storing a complete copy of a file for each "
4125 "revision, it stores the changes needed to transform an older revision into "
4126 "the new revision. For many kinds of file data, these deltas are typically a "
4127 "fraction of a percent of the size of a full copy of a file."
4128 msgstr ""
4130 #. type: Content of: <book><chapter><sect1><sect2><para>
4131 #: ../en/ch03-concepts.xml:142
4132 msgid ""
4133 "Some obsolete revision control systems can only work with deltas of text "
4134 "files. They must either store binary files as complete snapshots or encoded "
4135 "into a text representation, both of which are wasteful approaches. Mercurial "
4136 "can efficiently handle deltas of files with arbitrary binary contents; it "
4137 "doesn't need to treat text as special."
4138 msgstr ""
4140 #. type: Content of: <book><chapter><sect1><sect2><title>
4141 #: ../en/ch03-concepts.xml:151
4142 msgid "Safe operation"
4143 msgstr "安全操作"
4145 #. type: Content of: <book><chapter><sect1><sect2><para>
4146 #: ../en/ch03-concepts.xml:153
4147 msgid ""
4148 "Mercurial only ever <emphasis>appends</emphasis> data to the end of a revlog "
4149 "file. It never modifies a section of a file after it has written it. This is "
4150 "both more robust and efficient than schemes that need to modify or rewrite "
4151 "data."
4152 msgstr ""
4154 #. type: Content of: <book><chapter><sect1><sect2><para>
4155 #: ../en/ch03-concepts.xml:159
4156 msgid ""
4157 "In addition, Mercurial treats every write as part of a <emphasis>transaction</"
4158 "emphasis> that can span a number of files. A transaction is "
4159 "<emphasis>atomic</emphasis>: either the entire transaction succeeds and its "
4160 "effects are all visible to readers in one go, or the whole thing is undone. "
4161 "This guarantee of atomicity means that if you're running two copies of "
4162 "Mercurial, where one is reading data and one is writing it, the reader will "
4163 "never see a partially written result that might confuse it."
4164 msgstr ""
4166 #. type: Content of: <book><chapter><sect1><sect2><para>
4167 #: ../en/ch03-concepts.xml:169
4168 msgid ""
4169 "The fact that Mercurial only appends to files makes it easier to provide this "
4170 "transactional guarantee. The easier it is to do stuff like this, the more "
4171 "confident you should be that it's done correctly."
4172 msgstr ""
4174 #. type: Content of: <book><chapter><sect1><sect2><title>
4175 #: ../en/ch03-concepts.xml:176
4176 msgid "Fast retrieval"
4177 msgstr "快速检索"
4179 #. type: Content of: <book><chapter><sect1><sect2><para>
4180 #: ../en/ch03-concepts.xml:178
4181 msgid ""
4182 "Mercurial cleverly avoids a pitfall common to all earlier revision control "
4183 "systems: the problem of <emphasis>inefficient retrieval</emphasis>. Most "
4184 "revision control systems store the contents of a revision as an incremental "
4185 "series of modifications against a <quote>snapshot</quote>. To reconstruct a "
4186 "specific revision, you must first read the snapshot, and then every one of "
4187 "the revisions between the snapshot and your target revision. The more "
4188 "history that a file accumulates, the more revisions you must read, hence the "
4189 "longer it takes to reconstruct a particular revision."
4190 msgstr ""
4192 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
4193 #: ../en/ch03-concepts.xml:190
4194 msgid "Snapshot of a revlog, with incremental deltas"
4195 msgstr "版本日志的快照,以及增量差异"
4197 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
4198 #: ../en/ch03-concepts.xml:192
4199 msgid "<imageobject><imagedata fileref=\"figs/snapshot.png\"/></imageobject>"
4200 msgstr ""
4202 #. type: Content of: <book><chapter><sect1><sect2><para>
4203 #: ../en/ch03-concepts.xml:197
4204 msgid ""
4205 "The innovation that Mercurial applies to this problem is simple but "
4206 "effective. Once the cumulative amount of delta information stored since the "
4207 "last snapshot exceeds a fixed threshold, it stores a new snapshot "
4208 "(compressed, of course), instead of another delta. This makes it possible to "
4209 "reconstruct <emphasis>any</emphasis> revision of a file quickly. This "
4210 "approach works so well that it has since been copied by several other "
4211 "revision control systems."
4212 msgstr ""
4214 #. type: Content of: <book><chapter><sect1><sect2><para>
4215 #: ../en/ch03-concepts.xml:206
4216 msgid ""
4217 "<xref linkend=\"fig:concepts:snapshot\"/> illustrates the idea. In an entry "
4218 "in a revlog's index file, Mercurial stores the range of entries from the data "
4219 "file that it must read to reconstruct a particular revision."
4220 msgstr ""
4222 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
4223 #: ../en/ch03-concepts.xml:212
4224 msgid "Aside: the influence of video compression"
4225 msgstr "旁白: 视频压缩的影响"
4227 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
4228 #: ../en/ch03-concepts.xml:214
4229 msgid ""
4230 "If you're familiar with video compression or have ever watched a TV feed "
4231 "through a digital cable or satellite service, you may know that most video "
4232 "compression schemes store each frame of video as a delta against its "
4233 "predecessor frame. In addition, these schemes use <quote>lossy</quote> "
4234 "compression techniques to increase the compression ratio, so visual errors "
4235 "accumulate over the course of a number of inter-frame deltas."
4236 msgstr ""
4238 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
4239 #: ../en/ch03-concepts.xml:223
4240 msgid ""
4241 "Because it's possible for a video stream to <quote>drop out</quote> "
4242 "occasionally due to signal glitches, and to limit the accumulation of "
4243 "artefacts introduced by the lossy compression process, video encoders "
4244 "periodically insert a complete frame (called a <quote>key frame</quote>) into "
4245 "the video stream; the next delta is generated against that frame. This means "
4246 "that if the video signal gets interrupted, it will resume once the next key "
4247 "frame is received. Also, the accumulation of encoding errors restarts anew "
4248 "with each key frame."
4249 msgstr ""
4251 #. type: Content of: <book><chapter><sect1><sect2><title>
4252 #: ../en/ch03-concepts.xml:237
4253 msgid "Identification and strong integrity"
4254 msgstr "鉴别和强完整性"
4256 #. type: Content of: <book><chapter><sect1><sect2><para>
4257 #: ../en/ch03-concepts.xml:239
4258 msgid ""
4259 "Along with delta or snapshot information, a revlog entry contains a "
4260 "cryptographic hash of the data that it represents. This makes it difficult "
4261 "to forge the contents of a revision, and easy to detect accidental corruption."
4262 msgstr ""
4264 #. type: Content of: <book><chapter><sect1><sect2><para>
4265 #: ../en/ch03-concepts.xml:244
4266 msgid ""
4267 "Hashes provide more than a mere check against corruption; they are used as "
4268 "the identifiers for revisions. The changeset identification hashes that you "
4269 "see as an end user are from revisions of the changelog. Although filelogs "
4270 "and the manifest also use hashes, Mercurial only uses these behind the scenes."
4271 msgstr ""
4273 #. type: Content of: <book><chapter><sect1><sect2><para>
4274 #: ../en/ch03-concepts.xml:251
4275 msgid ""
4276 "Mercurial verifies that hashes are correct when it retrieves file revisions "
4277 "and when it pulls changes from another repository. If it encounters an "
4278 "integrity problem, it will complain and stop whatever it's doing."
4279 msgstr ""
4281 #. type: Content of: <book><chapter><sect1><sect2><para>
4282 #: ../en/ch03-concepts.xml:256
4283 msgid ""
4284 "In addition to the effect it has on retrieval efficiency, Mercurial's use of "
4285 "periodic snapshots makes it more robust against partial data corruption. If "
4286 "a revlog becomes partly corrupted due to a hardware error or system bug, it's "
4287 "often possible to reconstruct some or most revisions from the uncorrupted "
4288 "sections of the revlog, both before and after the corrupted section. This "
4289 "would not be possible with a delta-only storage model."
4290 msgstr ""
4292 #. type: Content of: <book><chapter><sect1><title>
4293 #: ../en/ch03-concepts.xml:268
4294 msgid "Revision history, branching, and merging"
4295 msgstr "修订历史,分支与合并"
4297 #. type: Content of: <book><chapter><sect1><para>
4298 #: ../en/ch03-concepts.xml:270
4299 msgid ""
4300 "Every entry in a Mercurial revlog knows the identity of its immediate "
4301 "ancestor revision, usually referred to as its <emphasis>parent</emphasis>. "
4302 "In fact, a revision contains room for not one parent, but two. Mercurial "
4303 "uses a special hash, called the <quote>null ID</quote>, to represent the idea "
4304 "<quote>there is no parent here</quote>. This hash is simply a string of "
4305 "zeroes."
4306 msgstr ""
4308 #. type: Content of: <book><chapter><sect1><para>
4309 #: ../en/ch03-concepts.xml:278
4310 msgid ""
4311 "In <xref linkend=\"fig:concepts:revlog\"/>, you can see an example of the "
4312 "conceptual structure of a revlog. Filelogs, manifests, and changelogs all "
4313 "have this same structure; they differ only in the kind of data stored in each "
4314 "delta or snapshot."
4315 msgstr ""
4317 #. type: Content of: <book><chapter><sect1><para>
4318 #: ../en/ch03-concepts.xml:284
4319 msgid ""
4320 "The first revision in a revlog (at the bottom of the image) has the null ID "
4321 "in both of its parent slots. For a <quote>normal</quote> revision, its first "
4322 "parent slot contains the ID of its parent revision, and its second contains "
4323 "the null ID, indicating that the revision has only one real parent. Any two "
4324 "revisions that have the same parent ID are branches. A revision that "
4325 "represents a merge between branches has two normal revision IDs in its parent "
4326 "slots."
4327 msgstr ""
4329 #. type: Content of: <book><chapter><sect1><figure><title>
4330 #: ../en/ch03-concepts.xml:294
4331 msgid "The conceptual structure of a revlog"
4332 msgstr "版本日志的设计结构"
4334 #. type: Content of: <book><chapter><sect1><figure><mediaobject>
4335 #: ../en/ch03-concepts.xml:296
4336 msgid "<imageobject><imagedata fileref=\"figs/revlog.png\"/></imageobject>"
4337 msgstr ""
4339 #. type: Content of: <book><chapter><sect1><title>
4340 #: ../en/ch03-concepts.xml:303
4341 msgid "The working directory"
4342 msgstr "工作目录"
4344 #. type: Content of: <book><chapter><sect1><para>
4345 #: ../en/ch03-concepts.xml:305
4346 msgid ""
4347 "In the working directory, Mercurial stores a snapshot of the files from the "
4348 "repository as of a particular changeset."
4349 msgstr ""
4351 #. type: Content of: <book><chapter><sect1><para>
4352 #: ../en/ch03-concepts.xml:308
4353 msgid ""
4354 "The working directory <quote>knows</quote> which changeset it contains. When "
4355 "you update the working directory to contain a particular changeset, Mercurial "
4356 "looks up the appropriate revision of the manifest to find out which files it "
4357 "was tracking at the time that changeset was committed, and which revision of "
4358 "each file was then current. It then recreates a copy of each of those files, "
4359 "with the same contents it had when the changeset was committed."
4360 msgstr ""
4362 #. type: Content of: <book><chapter><sect1><para>
4363 #: ../en/ch03-concepts.xml:317
4364 msgid ""
4365 "The <emphasis>dirstate</emphasis> contains Mercurial's knowledge of the "
4366 "working directory. This details which changeset the working directory is "
4367 "updated to, and all of the files that Mercurial is tracking in the working "
4368 "directory."
4369 msgstr ""
4371 #. type: Content of: <book><chapter><sect1><para>
4372 #: ../en/ch03-concepts.xml:323
4373 msgid ""
4374 "Just as a revision of a revlog has room for two parents, so that it can "
4375 "represent either a normal revision (with one parent) or a merge of two "
4376 "earlier revisions, the dirstate has slots for two parents. When you use the "
4377 "<command role=\"hg-cmd\">hg update</command> command, the changeset that you "
4378 "update to is stored in the <quote>first parent</quote> slot, and the null ID "
4379 "in the second. When you <command role=\"hg-cmd\">hg merge</command> with "
4380 "another changeset, the first parent remains unchanged, and the second parent "
4381 "is filled in with the changeset you're merging with. The <command role=\"hg-"
4382 "cmd\">hg parents</command> command tells you what the parents of the dirstate "
4383 "are."
4384 msgstr ""
4386 #. type: Content of: <book><chapter><sect1><sect2><title>
4387 #: ../en/ch03-concepts.xml:337
4388 msgid "What happens when you commit"
4389 msgstr "当你提交时发生的事情"
4391 #. type: Content of: <book><chapter><sect1><sect2><para>
4392 #: ../en/ch03-concepts.xml:339
4393 msgid ""
4394 "The dirstate stores parent information for more than just book-keeping "
4395 "purposes. Mercurial uses the parents of the dirstate as <emphasis>the "
4396 "parents of a new changeset</emphasis> when you perform a commit."
4397 msgstr ""
4399 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
4400 #: ../en/ch03-concepts.xml:345
4401 msgid "The working directory can have two parents"
4402 msgstr "工作目录可以有两个父亲"
4404 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
4405 #: ../en/ch03-concepts.xml:347
4406 msgid "<imageobject><imagedata fileref=\"figs/wdir.png\"/></imageobject>"
4407 msgstr ""
4409 #. type: Content of: <book><chapter><sect1><sect2><para>
4410 #: ../en/ch03-concepts.xml:352
4411 msgid ""
4412 "<xref linkend=\"fig:concepts:wdir\"/> shows the normal state of the working "
4413 "directory, where it has a single changeset as parent. That changeset is the "
4414 "<emphasis>tip</emphasis>, the newest changeset in the repository that has no "
4415 "children."
4416 msgstr ""
4418 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
4419 #: ../en/ch03-concepts.xml:359
4420 msgid "The working directory gains new parents after a commit"
4421 msgstr "提交之后,工作目录的父亲就改变了"
4423 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
4424 #: ../en/ch03-concepts.xml:362
4425 msgid ""
4426 "<imageobject><imagedata fileref=\"figs/wdir-after-commit.png\"/></imageobject>"
4427 msgstr ""
4429 #. type: Content of: <book><chapter><sect1><sect2><para>
4430 #: ../en/ch03-concepts.xml:367
4431 msgid ""
4432 "It's useful to think of the working directory as <quote>the changeset I'm "
4433 "about to commit</quote>. Any files that you tell Mercurial that you've "
4434 "added, removed, renamed, or copied will be reflected in that changeset, as "
4435 "will modifications to any files that Mercurial is already tracking; the new "
4436 "changeset will have the parents of the working directory as its parents."
4437 msgstr ""
4439 #. type: Content of: <book><chapter><sect1><sect2><para>
4440 #: ../en/ch03-concepts.xml:375
4441 msgid ""
4442 "After a commit, Mercurial will update the parents of the working directory, "
4443 "so that the first parent is the ID of the new changeset, and the second is "
4444 "the null ID. This is shown in <xref linkend=\"fig:concepts:wdir-after-commit"
4445 "\"/>. Mercurial doesn't touch any of the files in the working directory when "
4446 "you commit; it just modifies the dirstate to note its new parents."
4447 msgstr ""
4449 #. type: Content of: <book><chapter><sect1><sect2><title>
4450 #: ../en/ch03-concepts.xml:386
4451 msgid "Creating a new head"
4452 msgstr "创建新顶点"
4454 #. type: Content of: <book><chapter><sect1><sect2><para>
4455 #: ../en/ch03-concepts.xml:388
4456 msgid ""
4457 "It's perfectly normal to update the working directory to a changeset other "
4458 "than the current tip. For example, you might want to know what your project "
4459 "looked like last Tuesday, or you could be looking through changesets to see "
4460 "which one introduced a bug. In cases like this, the natural thing to do is "
4461 "update the working directory to the changeset you're interested in, and then "
4462 "examine the files in the working directory directly to see their contents as "
4463 "they were when you committed that changeset. The effect of this is shown in "
4464 "<xref linkend=\"fig:concepts:wdir-pre-branch\"/>."
4465 msgstr ""
4467 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
4468 #: ../en/ch03-concepts.xml:400
4469 msgid "The working directory, updated to an older changeset"
4470 msgstr "同步到旧修改集的工作目录"
4472 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
4473 #: ../en/ch03-concepts.xml:403
4474 msgid ""
4475 "<imageobject><imagedata fileref=\"figs/wdir-pre-branch.png\"/></imageobject>"
4476 msgstr ""
4478 #. type: Content of: <book><chapter><sect1><sect2><para>
4479 #: ../en/ch03-concepts.xml:408
4480 msgid ""
4481 "Having updated the working directory to an older changeset, what happens if "
4482 "you make some changes, and then commit? Mercurial behaves in the same way as "
4483 "I outlined above. The parents of the working directory become the parents of "
4484 "the new changeset. This new changeset has no children, so it becomes the new "
4485 "tip. And the repository now contains two changesets that have no children; "
4486 "we call these <emphasis>heads</emphasis>. You can see the structure that "
4487 "this creates in <xref linkend=\"fig:concepts:wdir-branch\"/>."
4488 msgstr ""
4490 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
4491 #: ../en/ch03-concepts.xml:420
4492 msgid "After a commit made while synced to an older changeset"
4493 msgstr "对同步到旧修改集的工作目录提交之后"
4495 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
4496 #: ../en/ch03-concepts.xml:423
4497 msgid "<imageobject><imagedata fileref=\"figs/wdir-branch.png\"/></imageobject>"
4498 msgstr ""
4500 #. type: Content of: <book><chapter><sect1><sect2><note><para>
4501 #: ../en/ch03-concepts.xml:429
4502 msgid ""
4503 "If you're new to Mercurial, you should keep in mind a common <quote>error</"
4504 "quote>, which is to use the <command role=\"hg-cmd\">hg pull</command> "
4505 "command without any options. By default, the <command role=\"hg-cmd\">hg "
4506 "pull</command> command <emphasis>does not</emphasis> update the working "
4507 "directory, so you'll bring new changesets into your repository, but the "
4508 "working directory will stay synced at the same changeset as before the pull. "
4509 "If you make some changes and commit afterwards, you'll thus create a new "
4510 "head, because your working directory isn't synced to whatever the current tip "
4511 "is."
4512 msgstr ""
4514 #. type: Content of: <book><chapter><sect1><sect2><note><para>
4515 #: ../en/ch03-concepts.xml:441
4516 msgid ""
4517 "I put the word <quote>error</quote> in quotes because all that you need to do "
4518 "to rectify this situation is <command role=\"hg-cmd\">hg merge</command>, "
4519 "then <command role=\"hg-cmd\">hg commit</command>. In other words, this "
4520 "almost never has negative consequences; it's just something of a surprise for "
4521 "newcomers. I'll discuss other ways to avoid this behavior, and why Mercurial "
4522 "behaves in this initially surprising way, later on."
4523 msgstr ""
4525 #. type: Content of: <book><chapter><sect1><sect2><title>
4526 #: ../en/ch03-concepts.xml:453
4527 #, fuzzy
4528 msgid "Merging changes"
4529 msgstr "共享修改"
4531 #. type: Content of: <book><chapter><sect1><sect2><para>
4532 #: ../en/ch03-concepts.xml:455
4533 msgid ""
4534 "When you run the <command role=\"hg-cmd\">hg merge</command> command, "
4535 "Mercurial leaves the first parent of the working directory unchanged, and "
4536 "sets the second parent to the changeset you're merging with, as shown in "
4537 "<xref linkend=\"fig:concepts:wdir-merge\"/>."
4538 msgstr ""
4540 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
4541 #: ../en/ch03-concepts.xml:462
4542 msgid "Merging two heads"
4543 msgstr "合并两个顶点"
4545 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
4546 #: ../en/ch03-concepts.xml:464
4547 msgid ""
4548 "<imageobject> <imagedata fileref=\"figs/wdir-merge.png\"/> </imageobject>"
4549 msgstr ""
4551 #. type: Content of: <book><chapter><sect1><sect2><para>
4552 #: ../en/ch03-concepts.xml:471
4553 msgid ""
4554 "Mercurial also has to modify the working directory, to merge the files "
4555 "managed in the two changesets. Simplified a little, the merging process goes "
4556 "like this, for every file in the manifests of both changesets."
4557 msgstr ""
4559 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
4560 #: ../en/ch03-concepts.xml:476
4561 msgid "If neither changeset has modified a file, do nothing with that file."
4562 msgstr ""
4564 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
4565 #: ../en/ch03-concepts.xml:479
4566 msgid ""
4567 "If one changeset has modified a file, and the other hasn't, create the "
4568 "modified copy of the file in the working directory."
4569 msgstr ""
4571 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
4572 #: ../en/ch03-concepts.xml:483
4573 msgid ""
4574 "If one changeset has removed a file, and the other hasn't (or has also "
4575 "deleted it), delete the file from the working directory."
4576 msgstr ""
4578 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
4579 #: ../en/ch03-concepts.xml:487
4580 msgid ""
4581 "If one changeset has removed a file, but the other has modified the file, ask "
4582 "the user what to do: keep the modified file, or remove it?"
4583 msgstr ""
4585 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
4586 #: ../en/ch03-concepts.xml:491
4587 msgid ""
4588 "If both changesets have modified a file, invoke an external merge program to "
4589 "choose the new contents for the merged file. This may require input from the "
4590 "user."
4591 msgstr ""
4593 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
4594 #: ../en/ch03-concepts.xml:496
4595 msgid ""
4596 "If one changeset has modified a file, and the other has renamed or copied the "
4597 "file, make sure that the changes follow the new name of the file."
4598 msgstr ""
4600 #. type: Content of: <book><chapter><sect1><sect2><para>
4601 #: ../en/ch03-concepts.xml:500
4602 msgid ""
4603 "There are more details&emdash;merging has plenty of corner cases&emdash;but "
4604 "these are the most common choices that are involved in a merge. As you can "
4605 "see, most cases are completely automatic, and indeed most merges finish "
4606 "automatically, without requiring your input to resolve any conflicts."
4607 msgstr ""
4609 #. type: Content of: <book><chapter><sect1><sect2><para>
4610 #: ../en/ch03-concepts.xml:507
4611 msgid ""
4612 "When you're thinking about what happens when you commit after a merge, once "
4613 "again the working directory is <quote>the changeset I'm about to commit</"
4614 "quote>. After the <command role=\"hg-cmd\">hg merge</command> command "
4615 "completes, the working directory has two parents; these will become the "
4616 "parents of the new changeset."
4617 msgstr ""
4619 #. type: Content of: <book><chapter><sect1><sect2><para>
4620 #: ../en/ch03-concepts.xml:514
4621 msgid ""
4622 "Mercurial lets you perform multiple merges, but you must commit the results "
4623 "of each individual merge as you go. This is necessary because Mercurial only "
4624 "tracks two parents for both revisions and the working directory. While it "
4625 "would be technically possible to merge multiple changesets at once, the "
4626 "prospect of user confusion and making a terrible mess of a merge immediately "
4627 "becomes overwhelming."
4628 msgstr ""
4630 #. type: Content of: <book><chapter><sect1><sect2><title>
4631 #: ../en/ch03-concepts.xml:525
4632 #, fuzzy
4633 msgid "Merging and renames"
4634 msgstr "合并顶点"
4636 #. type: Content of: <book><chapter><sect1><sect2><para>
4637 #: ../en/ch03-concepts.xml:527
4638 msgid ""
4639 "A surprising number of revision control systems pay little or no attention to "
4640 "a file's <emphasis>name</emphasis> over time. For instance, it used to be "
4641 "common that if a file got renamed on one side of a merge, the changes from "
4642 "the other side would be silently dropped."
4643 msgstr ""
4645 #. type: Content of: <book><chapter><sect1><sect2><para>
4646 #: ../en/ch03-concepts.xml:533
4647 msgid ""
4648 "Mercurial records metadata when you tell it to perform a rename or copy. It "
4649 "uses this metadata during a merge to do the right thing in the case of a "
4650 "merge. For instance, if I rename a file, and you edit it without renaming "
4651 "it, when we merge our work the file will be renamed and have your edits "
4652 "applied."
4653 msgstr ""
4655 #. type: Content of: <book><chapter><sect1><title>
4656 #: ../en/ch03-concepts.xml:543
4657 msgid "Other interesting design features"
4658 msgstr "其它有趣的设计特性"
4660 #. type: Content of: <book><chapter><sect1><para>
4661 #: ../en/ch03-concepts.xml:545
4662 msgid ""
4663 "In the sections above, I've tried to highlight some of the most important "
4664 "aspects of Mercurial's design, to illustrate that it pays careful attention "
4665 "to reliability and performance. However, the attention to detail doesn't "
4666 "stop there. There are a number of other aspects of Mercurial's construction "
4667 "that I personally find interesting. I'll detail a few of them here, separate "
4668 "from the <quote>big ticket</quote> items above, so that if you're interested, "
4669 "you can gain a better idea of the amount of thinking that goes into a well-"
4670 "designed system."
4671 msgstr ""
4673 #. type: Content of: <book><chapter><sect1><sect2><title>
4674 #: ../en/ch03-concepts.xml:556
4675 msgid "Clever compression"
4676 msgstr "智能压缩"
4678 #. type: Content of: <book><chapter><sect1><sect2><para>
4679 #: ../en/ch03-concepts.xml:558
4680 msgid ""
4681 "When appropriate, Mercurial will store both snapshots and deltas in "
4682 "compressed form. It does this by always <emphasis>trying to</emphasis> "
4683 "compress a snapshot or delta, but only storing the compressed version if it's "
4684 "smaller than the uncompressed version."
4685 msgstr ""
4687 #. type: Content of: <book><chapter><sect1><sect2><para>
4688 #: ../en/ch03-concepts.xml:564
4689 msgid ""
4690 "This means that Mercurial does <quote>the right thing</quote> when storing a "
4691 "file whose native form is compressed, such as a <literal>zip</literal> "
4692 "archive or a JPEG image. When these types of files are compressed a second "
4693 "time, the resulting file is usually bigger than the once-compressed form, and "
4694 "so Mercurial will store the plain <literal>zip</literal> or JPEG."
4695 msgstr ""
4697 #. type: Content of: <book><chapter><sect1><sect2><para>
4698 #: ../en/ch03-concepts.xml:572
4699 msgid ""
4700 "Deltas between revisions of a compressed file are usually larger than "
4701 "snapshots of the file, and Mercurial again does <quote>the right thing</"
4702 "quote> in these cases. It finds that such a delta exceeds the threshold at "
4703 "which it should store a complete snapshot of the file, so it stores the "
4704 "snapshot, again saving space compared to a naive delta-only approach."
4705 msgstr ""
4707 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
4708 #: ../en/ch03-concepts.xml:581
4709 msgid "Network recompression"
4710 msgstr "网络重新压缩"
4712 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
4713 #: ../en/ch03-concepts.xml:583
4714 msgid ""
4715 "When storing revisions on disk, Mercurial uses the <quote>deflate</quote> "
4716 "compression algorithm (the same one used by the popular <literal>zip</"
4717 "literal> archive format), which balances good speed with a respectable "
4718 "compression ratio. However, when transmitting revision data over a network "
4719 "connection, Mercurial uncompresses the compressed revision data."
4720 msgstr ""
4722 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
4723 #: ../en/ch03-concepts.xml:591
4724 msgid ""
4725 "If the connection is over HTTP, Mercurial recompresses the entire stream of "
4726 "data using a compression algorithm that gives a better compression ratio (the "
4727 "Burrows-Wheeler algorithm from the widely used <literal>bzip2</literal> "
4728 "compression package). This combination of algorithm and compression of the "
4729 "entire stream (instead of a revision at a time) substantially reduces the "
4730 "number of bytes to be transferred, yielding better network performance over "
4731 "most kinds of network."
4732 msgstr ""
4734 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
4735 #: ../en/ch03-concepts.xml:601
4736 msgid ""
4737 "(If the connection is over <command>ssh</command>, Mercurial "
4738 "<emphasis>doesn't</emphasis> recompress the stream, because <command>ssh</"
4739 "command> can already do this itself.)"
4740 msgstr ""
4742 #. type: Content of: <book><chapter><sect1><sect2><title>
4743 #: ../en/ch03-concepts.xml:609
4744 msgid "Read/write ordering and atomicity"
4745 msgstr "读写顺序与原子性"
4747 #. type: Content of: <book><chapter><sect1><sect2><para>
4748 #: ../en/ch03-concepts.xml:611
4749 msgid ""
4750 "Appending to files isn't the whole story when it comes to guaranteeing that a "
4751 "reader won't see a partial write. If you recall <xref linkend=\"fig:concepts:"
4752 "metadata\"/>, revisions in the changelog point to revisions in the manifest, "
4753 "and revisions in the manifest point to revisions in filelogs. This hierarchy "
4754 "is deliberate."
4755 msgstr ""
4757 #. type: Content of: <book><chapter><sect1><sect2><para>
4758 #: ../en/ch03-concepts.xml:619
4759 msgid ""
4760 "A writer starts a transaction by writing filelog and manifest data, and "
4761 "doesn't write any changelog data until those are finished. A reader starts "
4762 "by reading changelog data, then manifest data, followed by filelog data."
4763 msgstr ""
4765 #. type: Content of: <book><chapter><sect1><sect2><para>
4766 #: ../en/ch03-concepts.xml:624
4767 msgid ""
4768 "Since the writer has always finished writing filelog and manifest data before "
4769 "it writes to the changelog, a reader will never read a pointer to a partially "
4770 "written manifest revision from the changelog, and it will never read a "
4771 "pointer to a partially written filelog revision from the manifest."
4772 msgstr ""
4774 #. type: Content of: <book><chapter><sect1><sect2><title>
4775 #: ../en/ch03-concepts.xml:632
4776 msgid "Concurrent access"
4777 msgstr "并发访问"
4779 #. type: Content of: <book><chapter><sect1><sect2><para>
4780 #: ../en/ch03-concepts.xml:634
4781 msgid ""
4782 "The read/write ordering and atomicity guarantees mean that Mercurial never "
4783 "needs to <emphasis>lock</emphasis> a repository when it's reading data, even "
4784 "if the repository is being written to while the read is occurring. This has a "
4785 "big effect on scalability; you can have an arbitrary number of Mercurial "
4786 "processes safely reading data from a repository safely all at once, no matter "
4787 "whether it's being written to or not."
4788 msgstr ""
4790 #. type: Content of: <book><chapter><sect1><sect2><para>
4791 #: ../en/ch03-concepts.xml:643
4792 msgid ""
4793 "The lockless nature of reading means that if you're sharing a repository on a "
4794 "multi-user system, you don't need to grant other local users permission to "
4795 "<emphasis>write</emphasis> to your repository in order for them to be able to "
4796 "clone it or pull changes from it; they only need <emphasis>read</emphasis> "
4797 "permission. (This is <emphasis>not</emphasis> a common feature among "
4798 "revision control systems, so don't take it for granted! Most require readers "
4799 "to be able to lock a repository to access it safely, and this requires write "
4800 "permission on at least one directory, which of course makes for all kinds of "
4801 "nasty and annoying security and administrative problems.)"
4802 msgstr ""
4804 #. type: Content of: <book><chapter><sect1><sect2><para>
4805 #: ../en/ch03-concepts.xml:656
4806 msgid ""
4807 "Mercurial uses locks to ensure that only one process can write to a "
4808 "repository at a time (the locking mechanism is safe even over filesystems "
4809 "that are notoriously hostile to locking, such as NFS). If a repository is "
4810 "locked, a writer will wait for a while to retry if the repository becomes "
4811 "unlocked, but if the repository remains locked for too long, the process "
4812 "attempting to write will time out after a while. This means that your daily "
4813 "automated scripts won't get stuck forever and pile up if a system crashes "
4814 "unnoticed, for example. (Yes, the timeout is configurable, from zero to "
4815 "infinity.)"
4816 msgstr ""
4818 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
4819 #: ../en/ch03-concepts.xml:668
4820 msgid "Safe dirstate access"
4821 msgstr "安全的目录状态访问"
4823 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
4824 #: ../en/ch03-concepts.xml:670
4825 msgid ""
4826 "As with revision data, Mercurial doesn't take a lock to read the dirstate "
4827 "file; it does acquire a lock to write it. To avoid the possibility of "
4828 "reading a partially written copy of the dirstate file, Mercurial writes to a "
4829 "file with a unique name in the same directory as the dirstate file, then "
4830 "renames the temporary file atomically to <filename>dirstate</filename>. The "
4831 "file named <filename>dirstate</filename> is thus guaranteed to be complete, "
4832 "not partially written."
4833 msgstr ""
4835 #. type: Content of: <book><chapter><sect1><sect2><title>
4836 #: ../en/ch03-concepts.xml:683
4837 msgid "Avoiding seeks"
4838 msgstr "避免查找"
4840 #. type: Content of: <book><chapter><sect1><sect2><para>
4841 #: ../en/ch03-concepts.xml:685
4842 msgid ""
4843 "Critical to Mercurial's performance is the avoidance of seeks of the disk "
4844 "head, since any seek is far more expensive than even a comparatively large "
4845 "read operation."
4846 msgstr ""
4848 #. type: Content of: <book><chapter><sect1><sect2><para>
4849 #: ../en/ch03-concepts.xml:689
4850 msgid ""
4851 "This is why, for example, the dirstate is stored in a single file. If there "
4852 "were a dirstate file per directory that Mercurial tracked, the disk would "
4853 "seek once per directory. Instead, Mercurial reads the entire single dirstate "
4854 "file in one step."
4855 msgstr ""
4857 #. type: Content of: <book><chapter><sect1><sect2><para>
4858 #: ../en/ch03-concepts.xml:695
4859 msgid ""
4860 "Mercurial also uses a <quote>copy on write</quote> scheme when cloning a "
4861 "repository on local storage. Instead of copying every revlog file from the "
4862 "old repository into the new repository, it makes a <quote>hard link</quote>, "
4863 "which is a shorthand way to say <quote>these two names point to the same "
4864 "file</quote>. When Mercurial is about to write to one of a revlog's files, "
4865 "it checks to see if the number of names pointing at the file is greater than "
4866 "one. If it is, more than one repository is using the file, so Mercurial "
4867 "makes a new copy of the file that is private to this repository."
4868 msgstr ""
4870 #. type: Content of: <book><chapter><sect1><sect2><para>
4871 #: ../en/ch03-concepts.xml:706
4872 msgid ""
4873 "A few revision control developers have pointed out that this idea of making a "
4874 "complete private copy of a file is not very efficient in its use of storage. "
4875 "While this is true, storage is cheap, and this method gives the highest "
4876 "performance while deferring most book-keeping to the operating system. An "
4877 "alternative scheme would most likely reduce performance and increase the "
4878 "complexity of the software, each of which is much more important to the "
4879 "<quote>feel</quote> of day-to-day use."
4880 msgstr ""
4882 #. type: Content of: <book><chapter><sect1><sect2><title>
4883 #: ../en/ch03-concepts.xml:718
4884 msgid "Other contents of the dirstate"
4885 msgstr "目录状态的其它内容"
4887 #. type: Content of: <book><chapter><sect1><sect2><para>
4888 #: ../en/ch03-concepts.xml:720
4889 msgid ""
4890 "Because Mercurial doesn't force you to tell it when you're modifying a file, "
4891 "it uses the dirstate to store some extra information so it can determine "
4892 "efficiently whether you have modified a file. For each file in the working "
4893 "directory, it stores the time that it last modified the file itself, and the "
4894 "size of the file at that time."
4895 msgstr ""
4897 #. type: Content of: <book><chapter><sect1><sect2><para>
4898 #: ../en/ch03-concepts.xml:727
4899 msgid ""
4900 "When you explicitly <command role=\"hg-cmd\">hg add</command>, <command role="
4901 "\"hg-cmd\">hg remove</command>, <command role=\"hg-cmd\">hg rename</command> "
4902 "or <command role=\"hg-cmd\">hg copy</command> files, Mercurial updates the "
4903 "dirstate so that it knows what to do with those files when you commit."
4904 msgstr ""
4906 #. type: Content of: <book><chapter><sect1><sect2><para>
4907 #: ../en/ch03-concepts.xml:734
4908 msgid ""
4909 "When Mercurial is checking the states of files in the working directory, it "
4910 "first checks a file's modification time. If that has not changed, the file "
4911 "must not have been modified. If the file's size has changed, the file must "
4912 "have been modified. If the modification time has changed, but the size has "
4913 "not, only then does Mercurial need to read the actual contents of the file to "
4914 "see if they've changed. Storing these few extra pieces of information "
4915 "dramatically reduces the amount of data that Mercurial needs to read, which "
4916 "yields large performance improvements compared to other revision control "
4917 "systems."
4918 msgstr ""
4920 #. type: Content of: <book><chapter><title>
4921 #: ../en/ch04-daily.xml:5
4922 msgid "Mercurial in daily use"
4923 msgstr "Mercurial 的日常使用"
4925 #. type: Content of: <book><chapter><sect1><title>
4926 #: ../en/ch04-daily.xml:8
4927 msgid "Telling Mercurial which files to track"
4928 msgstr "告诉 Mercurial 要跟踪哪些文件"
4930 #. type: Content of: <book><chapter><sect1><para>
4931 #: ../en/ch04-daily.xml:10
4932 msgid ""
4933 "Mercurial does not work with files in your repository unless you tell it to "
4934 "manage them. The <command role=\"hg-cmd\">hg status</command> command will "
4935 "tell you which files Mercurial doesn't know about; it uses a <quote><literal>?"
4936 "</literal></quote> to display such files."
4937 msgstr ""
4940 #. type: Content of: <book><chapter><sect1><para>
4941 #: ../en/ch04-daily.xml:17
4942 msgid ""
4943 "To tell Mercurial to track a file, use the <command role=\"hg-cmd\">hg add</"
4944 "command> command. Once you have added a file, the entry in the output of "
4945 "<command role=\"hg-cmd\">hg status</command> for that file changes from "
4946 "<quote><literal>?</literal></quote> to <quote><literal>A</literal></quote>."
4947 msgstr ""
4949 #. type: Content of: <book><chapter><sect1><para>
4950 #: ../en/ch04-daily.xml:26
4951 msgid ""
4952 "After you run a <command role=\"hg-cmd\">hg commit</command>, the files that "
4953 "you added before the commit will no longer be listed in the output of "
4954 "<command role=\"hg-cmd\">hg status</command>. The reason for this is that by "
4955 "default, <command role=\"hg-cmd\">hg status</command> only tells you about "
4956 "<quote>interesting</quote> files&emdash;those that you have (for example) "
4957 "modified, removed, or renamed. If you have a repository that contains "
4958 "thousands of files, you will rarely want to know about files that Mercurial "
4959 "is tracking, but that have not changed. (You can still get this information; "
4960 "we'll return to this later.)"
4961 msgstr ""
4963 #. type: Content of: <book><chapter><sect1><para>
4964 #: ../en/ch04-daily.xml:38
4965 msgid ""
4966 "Once you add a file, Mercurial doesn't do anything with it immediately. "
4967 "Instead, it will take a snapshot of the file's state the next time you "
4968 "perform a commit. It will then continue to track the changes you make to the "
4969 "file every time you commit, until you remove the file."
4970 msgstr ""
4972 #. type: Content of: <book><chapter><sect1><sect2><title>
4973 #: ../en/ch04-daily.xml:45
4974 msgid "Explicit versus implicit file naming"
4975 msgstr "明确与隐含文件命名"
4977 #. type: Content of: <book><chapter><sect1><sect2><para>
4978 #: ../en/ch04-daily.xml:47
4979 msgid ""
4980 "A useful behavior that Mercurial has is that if you pass the name of a "
4981 "directory to a command, every Mercurial command will treat this as <quote>I "
4982 "want to operate on every file in this directory and its subdirectories</"
4983 "quote>."
4984 msgstr ""
4986 #. type: Content of: <book><chapter><sect1><sect2><para>
4987 #: ../en/ch04-daily.xml:54
4988 msgid ""
4989 "Notice in this example that Mercurial printed the names of the files it "
4990 "added, whereas it didn't do so when we added the file named <filename>myfile."
4991 "txt</filename> in the earlier example."
4992 msgstr ""
4994 #. type: Content of: <book><chapter><sect1><sect2><para>
4995 #: ../en/ch04-daily.xml:59
4996 msgid ""
4997 "What's going on is that in the former case, we explicitly named the file to "
4998 "add on the command line. The assumption that Mercurial makes in such cases "
4999 "is that we know what we are doing, and it doesn't print any output."
5000 msgstr ""
5002 #. type: Content of: <book><chapter><sect1><sect2><para>
5003 #: ../en/ch04-daily.xml:64
5004 msgid ""
5005 "However, when we <emphasis>imply</emphasis> the names of files by giving the "
5006 "name of a directory, Mercurial takes the extra step of printing the name of "
5007 "each file that it does something with. This makes it more clear what is "
5008 "happening, and reduces the likelihood of a silent and nasty surprise. This "
5009 "behavior is common to most Mercurial commands."
5010 msgstr ""
5012 #. type: Content of: <book><chapter><sect1><sect2><title>
5013 #: ../en/ch04-daily.xml:73
5014 #, fuzzy
5015 msgid "Mercurial tracks files, not directories"
5016 msgstr "旁白: Mercurial 只跟踪文件,不跟踪目录"
5018 #. type: Content of: <book><chapter><sect1><sect2><para>
5019 #: ../en/ch04-daily.xml:75
5020 msgid ""
5021 "Mercurial does not track directory information. Instead, it tracks the path "
5022 "to a file. Before creating a file, it first creates any missing directory "
5023 "components of the path. After it deletes a file, it then deletes any empty "
5024 "directories that were in the deleted file's path. This sounds like a trivial "
5025 "distinction, but it has one minor practical consequence: it is not possible "
5026 "to represent a completely empty directory in Mercurial."
5027 msgstr ""
5029 #. type: Content of: <book><chapter><sect1><sect2><para>
5030 #: ../en/ch04-daily.xml:84
5031 msgid ""
5032 "Empty directories are rarely useful, and there are unintrusive workarounds "
5033 "that you can use to achieve an appropriate effect. The developers of "
5034 "Mercurial thus felt that the complexity that would be required to manage "
5035 "empty directories was not worth the limited benefit this feature would bring."
5036 msgstr ""
5038 #. type: Content of: <book><chapter><sect1><sect2><para>
5039 #: ../en/ch04-daily.xml:91
5040 msgid ""
5041 "If you need an empty directory in your repository, there are a few ways to "
5042 "achieve this. One is to create a directory, then <command role=\"hg-cmd\">hg "
5043 "add</command> a <quote>hidden</quote> file to that directory. On Unix-like "
5044 "systems, any file name that begins with a period (<quote><literal>.</"
5045 "literal></quote>) is treated as hidden by most commands and GUI tools. This "
5046 "approach is illustrated below."
5047 msgstr ""
5049 #. type: Content of: <book><chapter><sect1><sect2><para>
5050 #: ../en/ch04-daily.xml:102
5051 msgid ""
5052 "Another way to tackle a need for an empty directory is to simply create one "
5053 "in your automated build scripts before they will need it."
5054 msgstr ""
5056 #. type: Content of: <book><chapter><sect1><title>
5057 #: ../en/ch04-daily.xml:109
5058 msgid "How to stop tracking a file"
5059 msgstr "如何停止跟踪文件"
5061 #. type: Content of: <book><chapter><sect1><para>
5062 #: ../en/ch04-daily.xml:111
5063 msgid ""
5064 "Once you decide that a file no longer belongs in your repository, use the "
5065 "<command role=\"hg-cmd\">hg remove</command> command. This deletes the file, "
5066 "and tells Mercurial to stop tracking it. A removed file is represented in "
5067 "the output of <command role=\"hg-cmd\">hg status</command> with a "
5068 "<quote><literal>R</literal></quote>."
5069 msgstr ""
5071 #. type: Content of: <book><chapter><sect1><para>
5072 #: ../en/ch04-daily.xml:120
5073 msgid ""
5074 "After you <command role=\"hg-cmd\">hg remove</command> a file, Mercurial will "
5075 "no longer track changes to that file, even if you recreate a file with the "
5076 "same name in your working directory. If you do recreate a file with the same "
5077 "name and want Mercurial to track the new file, simply <command role=\"hg-cmd"
5078 "\">hg add</command> it. Mercurial will know that the newly added file is not "
5079 "related to the old file of the same name."
5080 msgstr ""
5082 #. type: Content of: <book><chapter><sect1><sect2><title>
5083 #: ../en/ch04-daily.xml:129
5084 msgid "Removing a file does not affect its history"
5085 msgstr "删除文件不影响历史"
5087 #. type: Content of: <book><chapter><sect1><sect2><para>
5088 #: ../en/ch04-daily.xml:131
5089 msgid "It is important to understand that removing a file has only two effects."
5090 msgstr ""
5092 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
5093 #: ../en/ch04-daily.xml:134
5094 msgid "It removes the current version of the file from the working directory."
5095 msgstr ""
5097 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
5098 #: ../en/ch04-daily.xml:137
5099 msgid ""
5100 "It stops Mercurial from tracking changes to the file, from the time of the "
5101 "next commit."
5102 msgstr ""
5104 #. type: Content of: <book><chapter><sect1><sect2><para>
5105 #: ../en/ch04-daily.xml:140
5106 msgid ""
5107 "Removing a file <emphasis>does not</emphasis> in any way alter the "
5108 "<emphasis>history</emphasis> of the file."
5109 msgstr ""
5111 #. type: Content of: <book><chapter><sect1><sect2><para>
5112 #: ../en/ch04-daily.xml:143
5113 msgid ""
5114 "If you update the working directory to a changeset that was committed when it "
5115 "was still tracking a file that you later removed, the file will reappear in "
5116 "the working directory, with the contents it had when you committed that "
5117 "changeset. If you then update the working directory to a later changeset, in "
5118 "which the file had been removed, Mercurial will once again remove the file "
5119 "from the working directory."
5120 msgstr ""
5122 #. type: Content of: <book><chapter><sect1><sect2><title>
5123 #: ../en/ch04-daily.xml:154
5124 msgid "Missing files"
5125 msgstr "丢失的文件"
5127 #. type: Content of: <book><chapter><sect1><sect2><para>
5128 #: ../en/ch04-daily.xml:156
5129 msgid ""
5130 "Mercurial considers a file that you have deleted, but not used <command role="
5131 "\"hg-cmd\">hg remove</command> to delete, to be <emphasis>missing</"
5132 "emphasis>. A missing file is represented with <quote><literal>!</literal></"
5133 "quote> in the output of <command role=\"hg-cmd\">hg status</command>. "
5134 "Mercurial commands will not generally do anything with missing files."
5135 msgstr ""
5137 #. type: Content of: <book><chapter><sect1><sect2><para>
5138 #: ../en/ch04-daily.xml:166
5139 msgid ""
5140 "If your repository contains a file that <command role=\"hg-cmd\">hg status</"
5141 "command> reports as missing, and you want the file to stay gone, you can run "
5142 "<command role=\"hg-cmd\">hg remove <option role=\"hg-opt-remove\">--after</"
5143 "option></command> at any time later on, to tell Mercurial that you really did "
5144 "mean to remove the file."
5145 msgstr ""
5147 #. type: Content of: <book><chapter><sect1><sect2><para>
5148 #: ../en/ch04-daily.xml:176
5149 msgid ""
5150 "On the other hand, if you deleted the missing file by accident, give <command "
5151 "role=\"hg-cmd\">hg revert</command> the name of the file to recover. It will "
5152 "reappear, in unmodified form."
5153 msgstr ""
5155 #. type: Content of: <book><chapter><sect1><sect2><title>
5156 #: ../en/ch04-daily.xml:185
5157 msgid "Aside: why tell Mercurial explicitly to remove a file?"
5158 msgstr "旁白: 为什么要明确告诉 Mercurial 删除文件?"
5160 #. type: Content of: <book><chapter><sect1><sect2><para>
5161 #: ../en/ch04-daily.xml:188
5162 msgid ""
5163 "You might wonder why Mercurial requires you to explicitly tell it that you "
5164 "are deleting a file. Early during the development of Mercurial, it let you "
5165 "delete a file however you pleased; Mercurial would notice the absence of the "
5166 "file automatically when you next ran a <command role=\"hg-cmd\">hg commit</"
5167 "command>, and stop tracking the file. In practice, this made it too easy to "
5168 "accidentally remove a file without noticing."
5169 msgstr ""
5171 #. type: Content of: <book><chapter><sect1><sect2><title>
5172 #: ../en/ch04-daily.xml:199
5173 msgid "Useful shorthand&emdash;adding and removing files in one step"
5174 msgstr "有用的速记—一个步骤添加和删除文件"
5176 #. type: Content of: <book><chapter><sect1><sect2><para>
5177 #: ../en/ch04-daily.xml:202
5178 msgid ""
5179 "Mercurial offers a combination command, <command role=\"hg-cmd\">hg "
5180 "addremove</command>, that adds untracked files and marks missing files as "
5181 "removed."
5182 msgstr ""
5184 #. type: Content of: <book><chapter><sect1><sect2><para>
5185 #: ../en/ch04-daily.xml:208
5186 msgid ""
5187 "The <command role=\"hg-cmd\">hg commit</command> command also provides a "
5188 "<option role=\"hg-opt-commit\">-A</option> option that performs this same add-"
5189 "and-remove, immediately followed by a commit."
5190 msgstr ""
5192 #. type: Content of: <book><chapter><sect1><title>
5193 #: ../en/ch04-daily.xml:218
5194 msgid "Copying files"
5195 msgstr "复制文件"
5197 #. type: Content of: <book><chapter><sect1><para>
5198 #: ../en/ch04-daily.xml:220
5199 msgid ""
5200 "Mercurial provides a <command role=\"hg-cmd\">hg copy</command> command that "
5201 "lets you make a new copy of a file. When you copy a file using this command, "
5202 "Mercurial makes a record of the fact that the new file is a copy of the "
5203 "original file. It treats these copied files specially when you merge your "
5204 "work with someone else's."
5205 msgstr ""
5207 #. type: Content of: <book><chapter><sect1><sect2><title>
5208 #: ../en/ch04-daily.xml:228
5209 msgid "The results of copying during a merge"
5210 msgstr "合并期间的复制结果"
5212 #. type: Content of: <book><chapter><sect1><sect2><para>
5213 #: ../en/ch04-daily.xml:230
5214 msgid ""
5215 "What happens during a merge is that changes <quote>follow</quote> a copy. To "
5216 "best illustrate what this means, let's create an example. We'll start with "
5217 "the usual tiny repository that contains a single file."
5218 msgstr ""
5220 #. type: Content of: <book><chapter><sect1><sect2><para>
5221 #: ../en/ch04-daily.xml:237
5222 msgid ""
5223 "We need to do some work in parallel, so that we'll have something to merge. "
5224 "So let's clone our repository."
5225 msgstr ""
5227 #. type: Content of: <book><chapter><sect1><sect2><para>
5228 #: ../en/ch04-daily.xml:243
5229 msgid ""
5230 "Back in our initial repository, let's use the <command role=\"hg-cmd\">hg "
5231 "copy</command> command to make a copy of the first file we created."
5232 msgstr ""
5234 #. type: Content of: <book><chapter><sect1><sect2><para>
5235 #: ../en/ch04-daily.xml:249
5236 msgid ""
5237 "If we look at the output of the <command role=\"hg-cmd\">hg status</command> "
5238 "command afterwards, the copied file looks just like a normal added file."
5239 msgstr ""
5241 #. type: Content of: <book><chapter><sect1><sect2><para>
5242 #: ../en/ch04-daily.xml:255
5243 msgid ""
5244 "But if we pass the <option role=\"hg-opt-status\">-C</option> option to "
5245 "<command role=\"hg-cmd\">hg status</command>, it prints another line of "
5246 "output: this is the file that our newly-added file was copied <emphasis>from</"
5247 "emphasis>."
5248 msgstr ""
5250 #. type: Content of: <book><chapter><sect1><sect2><para>
5251 #: ../en/ch04-daily.xml:263
5252 msgid ""
5253 "Now, back in the repository we cloned, let's make a change in parallel. "
5254 "We'll add a line of content to the original file that we created."
5255 msgstr ""
5257 #. type: Content of: <book><chapter><sect1><sect2><para>
5258 #: ../en/ch04-daily.xml:269
5259 msgid ""
5260 "Now we have a modified <filename>file</filename> in this repository. When we "
5261 "pull the changes from the first repository, and merge the two heads, "
5262 "Mercurial will propagate the changes that we made locally to <filename>file</"
5263 "filename> into its copy, <filename>new-file</filename>."
5264 msgstr ""
5266 #. type: Content of: <book><chapter><sect1><sect2><title>
5267 #: ../en/ch04-daily.xml:279
5268 msgid "Why should changes follow copies?"
5269 msgstr "为什么复制后需要后续修改?"
5271 #. type: Content of: <book><chapter><sect1><sect2><para>
5272 #: ../en/ch04-daily.xml:281
5273 msgid ""
5274 "This behavior&emdash;of changes to a file propagating out to copies of the "
5275 "file&emdash;might seem esoteric, but in most cases it's highly desirable."
5276 msgstr ""
5278 #. type: Content of: <book><chapter><sect1><sect2><para>
5279 #: ../en/ch04-daily.xml:285
5280 msgid ""
5281 "First of all, remember that this propagation <emphasis>only</emphasis> "
5282 "happens when you merge. So if you <command role=\"hg-cmd\">hg copy</command> "
5283 "a file, and subsequently modify the original file during the normal course of "
5284 "your work, nothing will happen."
5285 msgstr ""
5287 #. type: Content of: <book><chapter><sect1><sect2><para>
5288 #: ../en/ch04-daily.xml:291
5289 msgid ""
5290 "The second thing to know is that modifications will only propagate across a "
5291 "copy as long as the changeset that you're merging changes from "
5292 "<emphasis>hasn't yet seen</emphasis> the copy."
5293 msgstr ""
5295 #. type: Content of: <book><chapter><sect1><sect2><para>
5296 #: ../en/ch04-daily.xml:296
5297 msgid ""
5298 "The reason that Mercurial does this is as follows. Let's say I make an "
5299 "important bug fix in a source file, and commit my changes. Meanwhile, you've "
5300 "decided to <command role=\"hg-cmd\">hg copy</command> the file in your "
5301 "repository, without knowing about the bug or having seen the fix, and you "
5302 "have started hacking on your copy of the file."
5303 msgstr ""
5305 #. type: Content of: <book><chapter><sect1><sect2><para>
5306 #: ../en/ch04-daily.xml:303
5307 msgid ""
5308 "If you pulled and merged my changes, and Mercurial <emphasis>didn't</"
5309 "emphasis> propagate changes across copies, your new source file would now "
5310 "contain the bug, and unless you knew to propagate the bug fix by hand, the "
5311 "bug would <emphasis>remain</emphasis> in your copy of the file."
5312 msgstr ""
5314 #. type: Content of: <book><chapter><sect1><sect2><para>
5315 #: ../en/ch04-daily.xml:309
5316 msgid ""
5317 "By automatically propagating the change that fixed the bug from the original "
5318 "file to the copy, Mercurial prevents this class of problem. To my knowledge, "
5319 "Mercurial is the <emphasis>only</emphasis> revision control system that "
5320 "propagates changes across copies like this."
5321 msgstr ""
5323 #. type: Content of: <book><chapter><sect1><sect2><para>
5324 #: ../en/ch04-daily.xml:315
5325 msgid ""
5326 "Once your change history has a record that the copy and subsequent merge "
5327 "occurred, there's usually no further need to propagate changes from the "
5328 "original file to the copied file, and that's why Mercurial only propagates "
5329 "changes across copies at the first merge, and not afterwards."
5330 msgstr ""
5332 #. type: Content of: <book><chapter><sect1><sect2><title>
5333 #: ../en/ch04-daily.xml:323
5334 msgid "How to make changes <emphasis>not</emphasis> follow a copy"
5335 msgstr "如何让复制后<emphasis>不</emphasis>修改?"
5337 #. type: Content of: <book><chapter><sect1><sect2><para>
5338 #: ../en/ch04-daily.xml:326
5339 msgid ""
5340 "If, for some reason, you decide that this business of automatically "
5341 "propagating changes across copies is not for you, simply use your system's "
5342 "normal file copy command (on Unix-like systems, that's <command>cp</command>) "
5343 "to make a copy of a file, then <command role=\"hg-cmd\">hg add</command> the "
5344 "new copy by hand. Before you do so, though, please do reread <xref linkend="
5345 "\"sec:daily:why-copy\"/>, and make an informed decision that this behavior is "
5346 "not appropriate to your specific case."
5347 msgstr ""
5349 #. type: Content of: <book><chapter><sect1><sect2><title>
5350 #: ../en/ch04-daily.xml:339
5351 #, fuzzy
5352 msgid "Behavior of the <command role=\"hg-cmd\">hg copy</command> command"
5353 msgstr "命令 <command role=\"hg-cmd\">hg copy</command> 的特性"
5355 #. type: Content of: <book><chapter><sect1><sect2><para>
5356 #: ../en/ch04-daily.xml:342
5357 msgid ""
5358 "When you use the <command role=\"hg-cmd\">hg copy</command> command, "
5359 "Mercurial makes a copy of each source file as it currently stands in the "
5360 "working directory. This means that if you make some modifications to a file, "
5361 "then <command role=\"hg-cmd\">hg copy</command> it without first having "
5362 "committed those changes, the new copy will also contain the modifications you "
5363 "have made up until that point. (I find this behavior a little "
5364 "counterintuitive, which is why I mention it here.)"
5365 msgstr ""
5367 #. type: Content of: <book><chapter><sect1><sect2><para>
5368 #: ../en/ch04-daily.xml:352
5369 msgid ""
5370 "The <command role=\"hg-cmd\">hg copy</command> command acts similarly to the "
5371 "Unix <command>cp</command> command (you can use the <command role=\"hg-cmd"
5372 "\">hg cp</command> alias if you prefer). We must supply two or more "
5373 "arguments, of which the last is treated as the <emphasis>destination</"
5374 "emphasis>, and all others are <emphasis>sources</emphasis>."
5375 msgstr ""
5377 #. type: Content of: <book><chapter><sect1><sect2><para>
5378 #: ../en/ch04-daily.xml:360
5379 msgid ""
5380 "If you pass <command role=\"hg-cmd\">hg copy</command> a single file as the "
5381 "source, and the destination does not exist, it creates a new file with that "
5382 "name."
5383 msgstr ""
5385 #. type: Content of: <book><chapter><sect1><sect2><para>
5386 #: ../en/ch04-daily.xml:366
5387 msgid ""
5388 "If the destination is a directory, Mercurial copies its sources into that "
5389 "directory."
5390 msgstr ""
5392 #. type: Content of: <book><chapter><sect1><sect2><para>
5393 #: ../en/ch04-daily.xml:371
5394 msgid ""
5395 "Copying a directory is recursive, and preserves the directory structure of "
5396 "the source."
5397 msgstr ""
5399 #. type: Content of: <book><chapter><sect1><sect2><para>
5400 #: ../en/ch04-daily.xml:377
5401 msgid ""
5402 "If the source and destination are both directories, the source tree is "
5403 "recreated in the destination directory."
5404 msgstr ""
5406 #. type: Content of: <book><chapter><sect1><sect2><para>
5407 #: ../en/ch04-daily.xml:382
5408 msgid ""
5409 "As with the <command role=\"hg-cmd\">hg remove</command> command, if you copy "
5410 "a file manually and then want Mercurial to know that you've copied the file, "
5411 "simply use the <option role=\"hg-opt-copy\">--after</option> option to "
5412 "<command role=\"hg-cmd\">hg copy</command>."
5413 msgstr ""
5415 #. type: Content of: <book><chapter><sect1><title>
5416 #: ../en/ch04-daily.xml:393
5417 msgid "Renaming files"
5418 msgstr "改名文件"
5420 #. type: Content of: <book><chapter><sect1><para>
5421 #: ../en/ch04-daily.xml:395
5422 msgid ""
5423 "It's rather more common to need to rename a file than to make a copy of it. "
5424 "The reason I discussed the <command role=\"hg-cmd\">hg copy</command> command "
5425 "before talking about renaming files is that Mercurial treats a rename in "
5426 "essentially the same way as a copy. Therefore, knowing what Mercurial does "
5427 "when you copy a file tells you what to expect when you rename a file."
5428 msgstr ""
5430 #. type: Content of: <book><chapter><sect1><para>
5431 #: ../en/ch04-daily.xml:403
5432 msgid ""
5433 "When you use the <command role=\"hg-cmd\">hg rename</command> command, "
5434 "Mercurial makes a copy of each source file, then deletes it and marks the "
5435 "file as removed."
5436 msgstr ""
5438 #. type: Content of: <book><chapter><sect1><para>
5439 #: ../en/ch04-daily.xml:409
5440 msgid ""
5441 "The <command role=\"hg-cmd\">hg status</command> command shows the newly "
5442 "copied file as added, and the copied-from file as removed."
5443 msgstr ""
5445 #. type: Content of: <book><chapter><sect1><para>
5446 #: ../en/ch04-daily.xml:415
5447 msgid ""
5448 "As with the results of a <command role=\"hg-cmd\">hg copy</command>, we must "
5449 "use the <option role=\"hg-opt-status\">-C</option> option to <command role="
5450 "\"hg-cmd\">hg status</command> to see that the added file is really being "
5451 "tracked by Mercurial as a copy of the original, now removed, file."
5452 msgstr ""
5454 #. type: Content of: <book><chapter><sect1><para>
5455 #: ../en/ch04-daily.xml:424
5456 msgid ""
5457 "As with <command role=\"hg-cmd\">hg remove</command> and <command role=\"hg-"
5458 "cmd\">hg copy</command>, you can tell Mercurial about a rename after the fact "
5459 "using the <option role=\"hg-opt-rename\">--after</option> option. In most "
5460 "other respects, the behavior of the <command role=\"hg-cmd\">hg rename</"
5461 "command> command, and the options it accepts, are similar to the <command "
5462 "role=\"hg-cmd\">hg copy</command> command."
5463 msgstr ""
5465 #. type: Content of: <book><chapter><sect1><para>
5466 #: ../en/ch04-daily.xml:433
5467 msgid ""
5468 "If you're familiar with the Unix command line, you'll be glad to know that "
5469 "<command role=\"hg-cmd\">hg rename</command> command can be invoked as "
5470 "<command role=\"hg-cmd\">hg mv</command>."
5471 msgstr ""
5473 #. type: Content of: <book><chapter><sect1><sect2><title>
5474 #: ../en/ch04-daily.xml:439
5475 msgid "Renaming files and merging changes"
5476 msgstr "改名文件与合并修改"
5478 #. type: Content of: <book><chapter><sect1><sect2><para>
5479 #: ../en/ch04-daily.xml:441
5480 msgid ""
5481 "Since Mercurial's rename is implemented as copy-and-remove, the same "
5482 "propagation of changes happens when you merge after a rename as after a copy."
5483 msgstr ""
5485 #. type: Content of: <book><chapter><sect1><sect2><para>
5486 #: ../en/ch04-daily.xml:445
5487 msgid ""
5488 "If I modify a file, and you rename it to a new name, and then we merge our "
5489 "respective changes, my modifications to the file under its original name will "
5490 "be propagated into the file under its new name. (This is something you might "
5491 "expect to <quote>simply work,</quote> but not all revision control systems "
5492 "actually do this.)"
5493 msgstr ""
5495 #. type: Content of: <book><chapter><sect1><sect2><para>
5496 #: ../en/ch04-daily.xml:452
5497 msgid ""
5498 "Whereas having changes follow a copy is a feature where you can perhaps nod "
5499 "and say <quote>yes, that might be useful,</quote> it should be clear that "
5500 "having them follow a rename is definitely important. Without this facility, "
5501 "it would simply be too easy for changes to become orphaned when files are "
5502 "renamed."
5503 msgstr ""
5505 #. type: Content of: <book><chapter><sect1><sect2><title>
5506 #: ../en/ch04-daily.xml:461
5507 msgid "Divergent renames and merging"
5508 msgstr "改名与合并的分歧"
5510 #. type: Content of: <book><chapter><sect1><sect2><para>
5511 #: ../en/ch04-daily.xml:463
5512 msgid ""
5513 "The case of diverging names occurs when two developers start with a "
5514 "file&emdash;let's call it <filename>foo</filename>&emdash;in their respective "
5515 "repositories."
5516 msgstr ""
5518 #. type: Content of: <book><chapter><sect1><sect2><para>
5519 #: ../en/ch04-daily.xml:470
5520 msgid "Anne renames the file to <filename>bar</filename>."
5521 msgstr ""
5523 #. type: Content of: <book><chapter><sect1><sect2><para>
5524 #: ../en/ch04-daily.xml:474
5525 msgid ""
5526 "Meanwhile, Bob renames it to <filename>quux</filename>. (Remember that "
5527 "<command role=\"hg-cmd\">hg mv</command> is an alias for <command role=\"hg-"
5528 "cmd\">hg rename</command>.)"
5529 msgstr ""
5531 #. type: Content of: <book><chapter><sect1><sect2><para>
5532 #: ../en/ch04-daily.xml:481
5533 msgid ""
5534 "I like to think of this as a conflict because each developer has expressed "
5535 "different intentions about what the file ought to be named."
5536 msgstr ""
5538 #. type: Content of: <book><chapter><sect1><sect2><para>
5539 #: ../en/ch04-daily.xml:485
5540 msgid ""
5541 "What do you think should happen when they merge their work? Mercurial's "
5542 "actual behavior is that it always preserves <emphasis>both</emphasis> names "
5543 "when it merges changesets that contain divergent renames."
5544 msgstr ""
5546 #. type: Content of: <book><chapter><sect1><sect2><para>
5547 #: ../en/ch04-daily.xml:492
5548 msgid ""
5549 "Notice that while Mercurial warns about the divergent renames, it leaves it "
5550 "up to you to do something about the divergence after the merge."
5551 msgstr ""
5553 #. type: Content of: <book><chapter><sect1><sect2><title>
5554 #: ../en/ch04-daily.xml:498
5555 msgid "Convergent renames and merging"
5556 msgstr "收敛改名与合并"
5558 #. type: Content of: <book><chapter><sect1><sect2><para>
5559 #: ../en/ch04-daily.xml:500
5560 msgid ""
5561 "Another kind of rename conflict occurs when two people choose to rename "
5562 "different <emphasis>source</emphasis> files to the same "
5563 "<emphasis>destination</emphasis>. In this case, Mercurial runs its normal "
5564 "merge machinery, and lets you guide it to a suitable resolution."
5565 msgstr ""
5567 #. type: Content of: <book><chapter><sect1><sect2><title>
5568 #: ../en/ch04-daily.xml:508
5569 msgid "Other name-related corner cases"
5570 msgstr "其它名称相关的角落"
5572 #. type: Content of: <book><chapter><sect1><sect2><para>
5573 #: ../en/ch04-daily.xml:510
5574 msgid ""
5575 "Mercurial has a longstanding bug in which it fails to handle a merge where "
5576 "one side has a file with a given name, while another has a directory with the "
5577 "same name. This is documented as <ulink role=\"hg-bug\" url=\"http://www."
5578 "selenic.com/mercurial/bts/issue29\">issue 29</ulink>."
5579 msgstr ""
5581 #. type: Content of: <book><chapter><sect1><title>
5582 #: ../en/ch04-daily.xml:523
5583 msgid "Recovering from mistakes"
5584 msgstr "从错误恢复"
5586 #. type: Content of: <book><chapter><sect1><para>
5587 #: ../en/ch04-daily.xml:525
5588 msgid ""
5589 "Mercurial has some useful commands that will help you to recover from some "
5590 "common mistakes."
5591 msgstr ""
5593 #. type: Content of: <book><chapter><sect1><para>
5594 #: ../en/ch04-daily.xml:528
5595 msgid ""
5596 "The <command role=\"hg-cmd\">hg revert</command> command lets you undo "
5597 "changes that you have made to your working directory. For example, if you "
5598 "<command role=\"hg-cmd\">hg add</command> a file by accident, just run "
5599 "<command role=\"hg-cmd\">hg revert</command> with the name of the file you "
5600 "added, and while the file won't be touched in any way, it won't be tracked "
5601 "for adding by Mercurial any longer, either. You can also use <command role="
5602 "\"hg-cmd\">hg revert</command> to get rid of erroneous changes to a file."
5603 msgstr ""
5605 #. type: Content of: <book><chapter><sect1><para>
5606 #: ../en/ch04-daily.xml:538
5607 msgid ""
5608 "It's good to remember that the <command role=\"hg-cmd\">hg revert</command> "
5609 "command is useful for changes that you have not yet committed. Once you've "
5610 "committed a change, if you decide it was a mistake, you can still do "
5611 "something about it, though your options may be more limited."
5612 msgstr ""
5614 #. type: Content of: <book><chapter><sect1><para>
5615 #: ../en/ch04-daily.xml:544
5616 msgid ""
5617 "For more information about the <command role=\"hg-cmd\">hg revert</command> "
5618 "command, and details about how to deal with changes you have already "
5619 "committed, see <xref linkend=\"chap:undo\"/>."
5620 msgstr ""
5622 #. type: Content of: <book><chapter><sect1><title>
5623 #: ../en/ch04-daily.xml:551
5624 #, fuzzy
5625 msgid "Dealing with tricky merges"
5626 msgstr "处理已经提交的修改"
5628 #. type: Content of: <book><chapter><sect1><para>
5629 #: ../en/ch04-daily.xml:553
5630 msgid ""
5631 "In a complicated or large project, it's not unusual for a merge of two "
5632 "changesets to result in some headaches. Suppose there's a big source file "
5633 "that's been extensively edited by each side of a merge: this is almost "
5634 "inevitably going to result in conflicts, some of which can take a few tries "
5635 "to sort out."
5636 msgstr ""
5638 #. type: Content of: <book><chapter><sect1><para>
5639 #: ../en/ch04-daily.xml:560
5640 msgid ""
5641 "Let's develop a simple case of this and see how to deal with it. We'll start "
5642 "off with a repository containing one file, and clone it twice."
5643 msgstr ""
5645 #. type: Content of: <book><chapter><sect1><para>
5646 #: ../en/ch04-daily.xml:566
5647 msgid "In one clone, we'll modify the file in one way."
5648 msgstr ""
5650 #. type: Content of: <book><chapter><sect1><para>
5651 #: ../en/ch04-daily.xml:570
5652 msgid "In another, we'll modify the file differently."
5653 msgstr ""
5655 #. type: Content of: <book><chapter><sect1><para>
5656 #: ../en/ch04-daily.xml:574
5657 msgid "Next, we'll pull each set of changes into our original repo."
5658 msgstr ""
5660 #. type: Content of: <book><chapter><sect1><para>
5661 #: ../en/ch04-daily.xml:579
5662 msgid "We expect our repository to now contain two heads."
5663 msgstr ""
5665 #. type: Content of: <book><chapter><sect1><para>
5666 #: ../en/ch04-daily.xml:583
5667 msgid ""
5668 "Normally, if we run <command role=\"hg-cmd\">hg merge</command> at this "
5669 "point, it will drop us into a GUI that will let us manually resolve the "
5670 "conflicting edits to <filename>myfile.txt</filename>. However, to simplify "
5671 "things for presentation here, we'd like the merge to fail immediately "
5672 "instead. Here's one way we can do so."
5673 msgstr ""
5675 #. type: Content of: <book><chapter><sect1><para>
5676 #: ../en/ch04-daily.xml:592
5677 msgid ""
5678 "We've told Mercurial's merge machinery to run the command <command>false</"
5679 "command> (which, as we desire, fails immediately) if it detects a merge that "
5680 "it can't sort out automatically."
5681 msgstr ""
5683 #. type: Content of: <book><chapter><sect1><para>
5684 #: ../en/ch04-daily.xml:597
5685 msgid ""
5686 "If we now fire up <command role=\"hg-cmd\">hg merge</command>, it should "
5687 "grind to a halt and report a failure."
5688 msgstr ""
5690 #. type: Content of: <book><chapter><sect1><para>
5691 #: ../en/ch04-daily.xml:603
5692 msgid ""
5693 "Even if we don't notice that the merge failed, Mercurial will prevent us from "
5694 "accidentally committing the result of a failed merge."
5695 msgstr ""
5697 #. type: Content of: <book><chapter><sect1><para>
5698 #: ../en/ch04-daily.xml:609
5699 msgid ""
5700 "When <command role=\"hg-cmd\">hg commit</command> fails in this case, it "
5701 "suggests that we use the unfamiliar <command role=\"hg-cmd\">hg resolve</"
5702 "command> command. As usual, <command role=\"hg-cmd\">hg help resolve</"
5703 "command> will print a helpful synopsis."
5704 msgstr ""
5706 #. type: Content of: <book><chapter><sect1><sect2><title>
5707 #: ../en/ch04-daily.xml:616
5708 msgid "File resolution states"
5709 msgstr ""
5711 #. type: Content of: <book><chapter><sect1><sect2><para>
5712 #: ../en/ch04-daily.xml:618
5713 msgid ""
5714 "When a merge occurs, most files will usually remain unmodified. For each "
5715 "file where Mercurial has to do something, it tracks the state of the file."
5716 msgstr ""
5718 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
5719 #: ../en/ch04-daily.xml:624
5720 msgid ""
5721 "A <emphasis>resolved</emphasis> file has been successfully merged, either "
5722 "automatically by Mercurial or manually with human intervention."
5723 msgstr ""
5725 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
5726 #: ../en/ch04-daily.xml:629
5727 msgid ""
5728 "An <emphasis>unresolved</emphasis> file was not merged successfully, and "
5729 "needs more attention."
5730 msgstr ""
5732 #. type: Content of: <book><chapter><sect1><sect2><para>
5733 #: ../en/ch04-daily.xml:634
5734 msgid ""
5735 "If Mercurial sees <emphasis>any</emphasis> file in the unresolved state after "
5736 "a merge, it considers the merge to have failed. Fortunately, we do not need "
5737 "to restart the entire merge from scratch."
5738 msgstr ""
5740 #. type: Content of: <book><chapter><sect1><sect2><para>
5741 #: ../en/ch04-daily.xml:639
5742 msgid ""
5743 "The <option role=\"hg-opt-resolve\">--list</option> or <option role=\"hg-opt-"
5744 "resolve\">-l</option> option to <command role=\"hg-cmd\">hg resolve</command> "
5745 "prints out the state of each merged file."
5746 msgstr ""
5748 #. type: Content of: <book><chapter><sect1><sect2><para>
5749 #: ../en/ch04-daily.xml:646
5750 msgid ""
5751 "In the output from <command role=\"hg-cmd\">hg resolve</command>, a resolved "
5752 "file is marked with <literal>R</literal>, while an unresolved file is marked "
5753 "with <literal>U</literal>. If any files are listed with <literal>U</"
5754 "literal>, we know that an attempt to commit the results of the merge will "
5755 "fail."
5756 msgstr ""
5758 #. type: Content of: <book><chapter><sect1><sect2><title>
5759 #: ../en/ch04-daily.xml:655
5760 #, fuzzy
5761 msgid "Resolving a file merge"
5762 msgstr "执行合并"
5764 #. type: Content of: <book><chapter><sect1><sect2><para>
5765 #: ../en/ch04-daily.xml:657
5766 msgid ""
5767 "We have several options to move a file from the unresolved into the resolved "
5768 "state. By far the most common is to rerun <command role=\"hg-cmd\">hg "
5769 "resolve</command>. If we pass the names of individual files or directories, "
5770 "it will retry the merges of any unresolved files present in those locations. "
5771 "We can also pass the <option role=\"hg-opt-resolve\">--all</option> or "
5772 "<option role=\"hg-opt-resolve\">-a</option> option, which will retry the "
5773 "merges of <emphasis>all</emphasis> unresolved files."
5774 msgstr ""
5776 #. type: Content of: <book><chapter><sect1><sect2><para>
5777 #: ../en/ch04-daily.xml:667
5778 msgid ""
5779 "Mercurial also lets us modify the resolution state of a file directly. We "
5780 "can manually mark a file as resolved using the <option role=\"hg-opt-resolve"
5781 "\">--mark</option> option, or as unresolved using the <option role=\"hg-opt-"
5782 "resolve\">--unmark</option> option. This allows us to clean up a "
5783 "particularly messy merge by hand, and to keep track of our progress with each "
5784 "file as we go."
5785 msgstr ""
5787 #. type: Content of: <book><chapter><title>
5788 #: ../en/ch05-collab.xml:5
5789 msgid "Collaborating with other people"
5790 msgstr "团体协作"
5792 #. type: Content of: <book><chapter><para>
5793 #: ../en/ch05-collab.xml:7
5794 msgid ""
5795 "As a completely decentralised tool, Mercurial doesn't impose any policy on "
5796 "how people ought to work with each other. However, if you're new to "
5797 "distributed revision control, it helps to have some tools and examples in "
5798 "mind when you're thinking about possible workflow models."
5799 msgstr ""
5801 #. type: Content of: <book><chapter><sect1><title>
5802 #: ../en/ch05-collab.xml:14
5803 msgid "Mercurial's web interface"
5804 msgstr "Mercurial 的 web 接口"
5806 #. type: Content of: <book><chapter><sect1><para>
5807 #: ../en/ch05-collab.xml:16
5808 msgid ""
5809 "Mercurial has a powerful web interface that provides several useful "
5810 "capabilities."
5811 msgstr ""
5813 #. type: Content of: <book><chapter><sect1><para>
5814 #: ../en/ch05-collab.xml:19
5815 msgid ""
5816 "For interactive use, the web interface lets you browse a single repository or "
5817 "a collection of repositories. You can view the history of a repository, "
5818 "examine each change (comments and diffs), and view the contents of each "
5819 "directory and file. You can even get a view of history that gives a "
5820 "graphical view of the relationships between individual changes and merges."
5821 msgstr ""
5823 #. type: Content of: <book><chapter><sect1><para>
5824 #: ../en/ch05-collab.xml:26
5825 msgid ""
5826 "Also for human consumption, the web interface provides Atom and RSS feeds of "
5827 "the changes in a repository. This lets you <quote>subscribe</quote> to a "
5828 "repository using your favorite feed reader, and be automatically notified of "
5829 "activity in that repository as soon as it happens. I find this capability "
5830 "much more convenient than the model of subscribing to a mailing list to which "
5831 "notifications are sent, as it requires no additional configuration on the "
5832 "part of whoever is serving the repository."
5833 msgstr ""
5835 #. type: Content of: <book><chapter><sect1><para>
5836 #: ../en/ch05-collab.xml:36
5837 msgid ""
5838 "The web interface also lets remote users clone a repository, pull changes "
5839 "from it, and (when the server is configured to permit it) push changes back "
5840 "to it. Mercurial's HTTP tunneling protocol aggressively compresses data, so "
5841 "that it works efficiently even over low-bandwidth network connections."
5842 msgstr ""
5844 #. type: Content of: <book><chapter><sect1><para>
5845 #: ../en/ch05-collab.xml:42
5846 msgid ""
5847 "The easiest way to get started with the web interface is to use your web "
5848 "browser to visit an existing repository, such as the master Mercurial "
5849 "repository at <ulink url=\"http://www.selenic.com/repo/hg\">http://www."
5850 "selenic.com/repo/hg</ulink>."
5851 msgstr ""
5853 #. type: Content of: <book><chapter><sect1><para>
5854 #: ../en/ch05-collab.xml:47
5855 msgid ""
5856 "If you're interested in providing a web interface to your own repositories, "
5857 "there are several good ways to do this."
5858 msgstr ""
5860 #. type: Content of: <book><chapter><sect1><para>
5861 #: ../en/ch05-collab.xml:51
5862 msgid ""
5863 "The easiest and fastest way to get started in an informal environment is to "
5864 "use the <command role=\"hg-cmd\">hg serve</command> command, which is best "
5865 "suited to short-term <quote>lightweight</quote> serving. See <xref linkend="
5866 "\"sec:collab:serve\"/> below for details of how to use this command."
5867 msgstr ""
5869 #. type: Content of: <book><chapter><sect1><para>
5870 #: ../en/ch05-collab.xml:58
5871 msgid ""
5872 "For longer-lived repositories that you'd like to have permanently available, "
5873 "there are several public hosting services available."
5874 msgstr ""
5876 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
5877 #: ../en/ch05-collab.xml:64
5878 msgid ""
5879 "Bitbucket, at <ulink url=\"http://bitbucket.org/\">http://bitbucket.org/</"
5880 "ulink>, provides free hosting for open source projects, and paid hosting for "
5881 "commercial projects."
5882 msgstr ""
5884 #. type: Content of: <book><chapter><sect1><para>
5885 #: ../en/ch05-collab.xml:71
5886 msgid ""
5887 "If you would prefer to host your own repositories, Mercurial has built-in "
5888 "support for several popular hosting technologies, most notably CGI (Common "
5889 "Gateway Interface), and WSGI (Web Services Gateway Interface). See <xref "
5890 "linkend=\"sec:collab:cgi\"/> for details of CGI and WSGI configuration."
5891 msgstr ""
5893 #. type: Content of: <book><chapter><sect1><title>
5894 #: ../en/ch05-collab.xml:80
5895 msgid "Collaboration models"
5896 msgstr "协作模型"
5898 #. type: Content of: <book><chapter><sect1><para>
5899 #: ../en/ch05-collab.xml:82
5900 msgid ""
5901 "With a suitably flexible tool, making decisions about workflow is much more "
5902 "of a social engineering challenge than a technical one. Mercurial imposes few "
5903 "limitations on how you can structure the flow of work in a project, so it's "
5904 "up to you and your group to set up and live with a model that matches your "
5905 "own particular needs."
5906 msgstr ""
5908 #. type: Content of: <book><chapter><sect1><sect2><title>
5909 #: ../en/ch05-collab.xml:90
5910 msgid "Factors to keep in mind"
5911 msgstr "要牢记的因素"
5913 #. type: Content of: <book><chapter><sect1><sect2><para>
5914 #: ../en/ch05-collab.xml:92
5915 msgid ""
5916 "The most important aspect of any model that you must keep in mind is how well "
5917 "it matches the needs and capabilities of the people who will be using it. "
5918 "This might seem self-evident; even so, you still can't afford to forget it "
5919 "for a moment."
5920 msgstr ""
5922 #. type: Content of: <book><chapter><sect1><sect2><para>
5923 #: ../en/ch05-collab.xml:98
5924 msgid ""
5925 "I once put together a workflow model that seemed to make perfect sense to me, "
5926 "but that caused a considerable amount of consternation and strife within my "
5927 "development team. In spite of my attempts to explain why we needed a complex "
5928 "set of branches, and how changes ought to flow between them, a few team "
5929 "members revolted. Even though they were smart people, they didn't want to "
5930 "pay attention to the constraints we were operating under, or face the "
5931 "consequences of those constraints in the details of the model that I was "
5932 "advocating."
5933 msgstr ""
5935 #. type: Content of: <book><chapter><sect1><sect2><para>
5936 #: ../en/ch05-collab.xml:108
5937 msgid ""
5938 "Don't sweep foreseeable social or technical problems under the rug. Whatever "
5939 "scheme you put into effect, you should plan for mistakes and problem "
5940 "scenarios. Consider adding automated machinery to prevent, or quickly "
5941 "recover from, trouble that you can anticipate. As an example, if you intend "
5942 "to have a branch with not-for-release changes in it, you'd do well to think "
5943 "early about the possibility that someone might accidentally merge those "
5944 "changes into a release branch. You could avoid this particular problem by "
5945 "writing a hook that prevents changes from being merged from an inappropriate "
5946 "branch."
5947 msgstr ""
5949 #. type: Content of: <book><chapter><sect1><sect2><title>
5950 #: ../en/ch05-collab.xml:122
5951 msgid "Informal anarchy"
5952 msgstr "无政府状态"
5954 #. type: Content of: <book><chapter><sect1><sect2><para>
5955 #: ../en/ch05-collab.xml:124
5956 msgid ""
5957 "I wouldn't suggest an <quote>anything goes</quote> approach as something "
5958 "sustainable, but it's a model that's easy to grasp, and it works perfectly "
5959 "well in a few unusual situations."
5960 msgstr ""
5962 #. type: Content of: <book><chapter><sect1><sect2><para>
5963 #: ../en/ch05-collab.xml:129
5964 msgid ""
5965 "As one example, many projects have a loose-knit group of collaborators who "
5966 "rarely physically meet each other. Some groups like to overcome the "
5967 "isolation of working at a distance by organizing occasional <quote>sprints</"
5968 "quote>. In a sprint, a number of people get together in a single location (a "
5969 "company's conference room, a hotel meeting room, that kind of place) and "
5970 "spend several days more or less locked in there, hacking intensely on a "
5971 "handful of projects."
5972 msgstr ""
5974 #. type: Content of: <book><chapter><sect1><sect2><para>
5975 #: ../en/ch05-collab.xml:138
5976 msgid ""
5977 "A sprint or a hacking session in a coffee shop are the perfect places to use "
5978 "the <command role=\"hg-cmd\">hg serve</command> command, since <command role="
5979 "\"hg-cmd\">hg serve</command> does not require any fancy server "
5980 "infrastructure. You can get started with <command role=\"hg-cmd\">hg serve</"
5981 "command> in moments, by reading <xref linkend=\"sec:collab:serve\"/> below. "
5982 "Then simply tell the person next to you that you're running a server, send "
5983 "the URL to them in an instant message, and you immediately have a quick-"
5984 "turnaround way to work together. They can type your URL into their web "
5985 "browser and quickly review your changes; or they can pull a bugfix from you "
5986 "and verify it; or they can clone a branch containing a new feature and try it "
5987 "out."
5988 msgstr ""
5990 #. type: Content of: <book><chapter><sect1><sect2><para>
5991 #: ../en/ch05-collab.xml:152
5992 msgid ""
5993 "The charm, and the problem, with doing things in an ad hoc fashion like this "
5994 "is that only people who know about your changes, and where they are, can see "
5995 "them. Such an informal approach simply doesn't scale beyond a handful "
5996 "people, because each individual needs to know about <emphasis>n</emphasis> "
5997 "different repositories to pull from."
5998 msgstr ""
6000 #. type: Content of: <book><chapter><sect1><sect2><title>
6001 #: ../en/ch05-collab.xml:162
6002 msgid "A single central repository"
6003 msgstr "单一中央版本库"
6005 #. type: Content of: <book><chapter><sect1><sect2><para>
6006 #: ../en/ch05-collab.xml:164
6007 msgid ""
6008 "For smaller projects migrating from a centralised revision control tool, "
6009 "perhaps the easiest way to get started is to have changes flow through a "
6010 "single shared central repository. This is also the most common "
6011 "<quote>building block</quote> for more ambitious workflow schemes."
6012 msgstr ""
6014 #. type: Content of: <book><chapter><sect1><sect2><para>
6015 #: ../en/ch05-collab.xml:170
6016 msgid ""
6017 "Contributors start by cloning a copy of this repository. They can pull "
6018 "changes from it whenever they need to, and some (perhaps all) developers have "
6019 "permission to push a change back when they're ready for other people to see "
6020 "it."
6021 msgstr ""
6023 #. type: Content of: <book><chapter><sect1><sect2><para>
6024 #: ../en/ch05-collab.xml:175
6025 msgid ""
6026 "Under this model, it can still often make sense for people to pull changes "
6027 "directly from each other, without going through the central repository. "
6028 "Consider a case in which I have a tentative bug fix, but I am worried that if "
6029 "I were to publish it to the central repository, it might subsequently break "
6030 "everyone else's trees as they pull it. To reduce the potential for damage, I "
6031 "can ask you to clone my repository into a temporary repository of your own "
6032 "and test it. This lets us put off publishing the potentially unsafe change "
6033 "until it has had a little testing."
6034 msgstr ""
6036 #. type: Content of: <book><chapter><sect1><sect2><para>
6037 #: ../en/ch05-collab.xml:186
6038 msgid ""
6039 "If a team is hosting its own repository in this kind of scenario, people will "
6040 "usually use the <command>ssh</command> protocol to securely push changes to "
6041 "the central repository, as documented in <xref linkend=\"sec:collab:ssh\"/>. "
6042 "It's also usual to publish a read-only copy of the repository over HTTP, as "
6043 "in <xref linkend=\"sec:collab:cgi\"/>. Publishing over HTTP satisfies the "
6044 "needs of people who don't have push access, and those who want to use web "
6045 "browsers to browse the repository's history."
6046 msgstr ""
6048 #. type: Content of: <book><chapter><sect1><sect2><title>
6049 #: ../en/ch05-collab.xml:199
6050 #, fuzzy
6051 msgid "A hosted central repository"
6052 msgstr "单一中央版本库"
6054 #. type: Content of: <book><chapter><sect1><sect2><para>
6055 #: ../en/ch05-collab.xml:201
6056 msgid ""
6057 "A wonderful thing about public hosting services like <ulink url=\"http://"
6058 "bitbucket.org/\">Bitbucket</ulink> is that not only do they handle the fiddly "
6059 "server configuration details, such as user accounts, authentication, and "
6060 "secure wire protocols, they provide additional infrastructure to make this "
6061 "model work well."
6062 msgstr ""
6064 #. type: Content of: <book><chapter><sect1><sect2><para>
6065 #: ../en/ch05-collab.xml:208
6066 msgid ""
6067 "For instance, a well-engineered hosting service will let people clone their "
6068 "own copies of a repository with a single click. This lets people work in "
6069 "separate spaces and share their changes when they're ready."
6070 msgstr ""
6072 #. type: Content of: <book><chapter><sect1><sect2><para>
6073 #: ../en/ch05-collab.xml:213
6074 msgid ""
6075 "In addition, a good hosting service will let people communicate with each "
6076 "other, for instance to say <quote>there are changes ready for you to review "
6077 "in this tree</quote>."
6078 msgstr ""
6080 #. type: Content of: <book><chapter><sect1><sect2><title>
6081 #: ../en/ch05-collab.xml:220
6082 msgid "Working with multiple branches"
6083 msgstr "使用多个分支工作"
6085 #. type: Content of: <book><chapter><sect1><sect2><para>
6086 #: ../en/ch05-collab.xml:222
6087 msgid ""
6088 "Projects of any significant size naturally tend to make progress on several "
6089 "fronts simultaneously. In the case of software, it's common for a project to "
6090 "go through periodic official releases. A release might then go into "
6091 "<quote>maintenance mode</quote> for a while after its first publication; "
6092 "maintenance releases tend to contain only bug fixes, not new features. In "
6093 "parallel with these maintenance releases, one or more future releases may be "
6094 "under development. People normally use the word <quote>branch</quote> to "
6095 "refer to one of these many slightly different directions in which development "
6096 "is proceeding."
6097 msgstr ""
6099 #. type: Content of: <book><chapter><sect1><sect2><para>
6100 #: ../en/ch05-collab.xml:235
6101 msgid ""
6102 "Mercurial is particularly well suited to managing a number of simultaneous, "
6103 "but not identical, branches. Each <quote>development direction</quote> can "
6104 "live in its own central repository, and you can merge changes from one to "
6105 "another as the need arises. Because repositories are independent of each "
6106 "other, unstable changes in a development branch will never affect a stable "
6107 "branch unless someone explicitly merges those changes into the stable branch."
6108 msgstr ""
6110 #. type: Content of: <book><chapter><sect1><sect2><para>
6111 #: ../en/ch05-collab.xml:244
6112 msgid ""
6113 "Here's an example of how this can work in practice. Let's say you have one "
6114 "<quote>main branch</quote> on a central server."
6115 msgstr ""
6117 #. type: Content of: <book><chapter><sect1><sect2><para>
6118 #: ../en/ch05-collab.xml:250
6119 msgid "People clone it, make changes locally, test them, and push them back."
6120 msgstr ""
6122 #. type: Content of: <book><chapter><sect1><sect2><para>
6123 #: ../en/ch05-collab.xml:253
6124 msgid ""
6125 "Once the main branch reaches a release milestone, you can use the <command "
6126 "role=\"hg-cmd\">hg tag</command> command to give a permanent name to the "
6127 "milestone revision."
6128 msgstr ""
6130 #. type: Content of: <book><chapter><sect1><sect2><para>
6131 #: ../en/ch05-collab.xml:259
6132 msgid "Let's say some ongoing development occurs on the main branch."
6133 msgstr ""
6135 #. type: Content of: <book><chapter><sect1><sect2><para>
6136 #: ../en/ch05-collab.xml:264
6137 msgid ""
6138 "Using the tag that was recorded at the milestone, people who clone that "
6139 "repository at any time in the future can use <command role=\"hg-cmd\">hg "
6140 "update</command> to get a copy of the working directory exactly as it was "
6141 "when that tagged revision was committed."
6142 msgstr ""
6144 #. type: Content of: <book><chapter><sect1><sect2><para>
6145 #: ../en/ch05-collab.xml:272
6146 msgid ""
6147 "In addition, immediately after the main branch is tagged, we can then clone "
6148 "the main branch on the server to a new <quote>stable</quote> branch, also on "
6149 "the server."
6150 msgstr ""
6152 #. type: Content of: <book><chapter><sect1><sect2><para>
6153 #: ../en/ch05-collab.xml:278
6154 msgid ""
6155 "If we need to make a change to the stable branch, we can then clone "
6156 "<emphasis>that</emphasis> repository, make our changes, commit, and push our "
6157 "changes back there."
6158 msgstr ""
6160 #. type: Content of: <book><chapter><sect1><sect2><para>
6161 #: ../en/ch05-collab.xml:285
6162 msgid ""
6163 "Because Mercurial repositories are independent, and Mercurial doesn't move "
6164 "changes around automatically, the stable and main branches are "
6165 "<emphasis>isolated</emphasis> from each other. The changes that we made on "
6166 "the main branch don't <quote>leak</quote> to the stable branch, and vice "
6167 "versa."
6168 msgstr ""
6170 #. type: Content of: <book><chapter><sect1><sect2><para>
6171 #: ../en/ch05-collab.xml:292
6172 msgid ""
6173 "We'll often want all of our bugfixes on the stable branch to show up on the "
6174 "main branch, too. Rather than rewrite a bugfix on the main branch, we can "
6175 "simply pull and merge changes from the stable to the main branch, and "
6176 "Mercurial will bring those bugfixes in for us."
6177 msgstr ""
6179 #. type: Content of: <book><chapter><sect1><sect2><para>
6180 #: ../en/ch05-collab.xml:300
6181 msgid ""
6182 "The main branch will still contain changes that are not on the stable branch, "
6183 "but it will also contain all of the bugfixes from the stable branch. The "
6184 "stable branch remains unaffected by these changes, since changes are only "
6185 "flowing from the stable to the main branch, and not the other way."
6186 msgstr ""
6188 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
6189 #: ../en/ch05-collab.xml:309 ../en/ch05-collab.xml:319
6190 msgid "Feature branches"
6191 msgstr "特性分支"
6193 #. type: Content of: <book><chapter><sect1><sect2><para>
6194 #: ../en/ch05-collab.xml:311
6195 msgid ""
6196 "For larger projects, an effective way to manage change is to break up a team "
6197 "into smaller groups. Each group has a shared branch of its own, cloned from "
6198 "a single <quote>master</quote> branch used by the entire project. People "
6199 "working on an individual branch are typically quite isolated from "
6200 "developments on other branches."
6201 msgstr ""
6203 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
6204 #: ../en/ch05-collab.xml:321
6205 msgid ""
6206 "<imageobject><imagedata width=\"100%\" fileref=\"figs/feature-branches.png\"/"
6207 "></imageobject>"
6208 msgstr ""
6210 #. type: Content of: <book><chapter><sect1><sect2><para>
6211 #: ../en/ch05-collab.xml:326
6212 msgid ""
6213 "When a particular feature is deemed to be in suitable shape, someone on that "
6214 "feature team pulls and merges from the master branch into the feature branch, "
6215 "then pushes back up to the master branch."
6216 msgstr ""
6218 #. type: Content of: <book><chapter><sect1><sect2><title>
6219 #: ../en/ch05-collab.xml:333
6220 msgid "The release train"
6221 msgstr "发布列车"
6223 #. type: Content of: <book><chapter><sect1><sect2><para>
6224 #: ../en/ch05-collab.xml:335
6225 msgid ""
6226 "Some projects are organized on a <quote>train</quote> basis: a release is "
6227 "scheduled to happen every few months, and whatever features are ready when "
6228 "the <quote>train</quote> is ready to leave are allowed in."
6229 msgstr ""
6231 #. type: Content of: <book><chapter><sect1><sect2><para>
6232 #: ../en/ch05-collab.xml:340
6233 msgid ""
6234 "This model resembles working with feature branches. The difference is that "
6235 "when a feature branch misses a train, someone on the feature team pulls and "
6236 "merges the changes that went out on that train release into the feature "
6237 "branch, and the team continues its work on top of that release so that their "
6238 "feature can make the next release."
6239 msgstr ""
6241 #. type: Content of: <book><chapter><sect1><sect2><title>
6242 #: ../en/ch05-collab.xml:349
6243 msgid "The Linux kernel model"
6244 msgstr "Linux 内核模型"
6246 #. type: Content of: <book><chapter><sect1><sect2><para>
6247 #: ../en/ch05-collab.xml:351
6248 msgid ""
6249 "The development of the Linux kernel has a shallow hierarchical structure, "
6250 "surrounded by a cloud of apparent chaos. Because most Linux developers use "
6251 "<command>git</command>, a distributed revision control tool with capabilities "
6252 "similar to Mercurial, it's useful to describe the way work flows in that "
6253 "environment; if you like the ideas, the approach translates well across tools."
6254 msgstr ""
6256 #. type: Content of: <book><chapter><sect1><sect2><para>
6257 #: ../en/ch05-collab.xml:359
6258 msgid ""
6259 "At the center of the community sits Linus Torvalds, the creator of Linux. He "
6260 "publishes a single source repository that is considered the "
6261 "<quote>authoritative</quote> current tree by the entire developer community. "
6262 "Anyone can clone Linus's tree, but he is very choosy about whose trees he "
6263 "pulls from."
6264 msgstr ""
6266 #. type: Content of: <book><chapter><sect1><sect2><para>
6267 #: ../en/ch05-collab.xml:366
6268 msgid ""
6269 "Linus has a number of <quote>trusted lieutenants</quote>. As a general rule, "
6270 "he pulls whatever changes they publish, in most cases without even reviewing "
6271 "those changes. Some of those lieutenants are generally agreed to be "
6272 "<quote>maintainers</quote>, responsible for specific subsystems within the "
6273 "kernel. If a random kernel hacker wants to make a change to a subsystem that "
6274 "they want to end up in Linus's tree, they must find out who the subsystem's "
6275 "maintainer is, and ask that maintainer to take their change. If the "
6276 "maintainer reviews their changes and agrees to take them, they'll pass them "
6277 "along to Linus in due course."
6278 msgstr ""
6280 #. type: Content of: <book><chapter><sect1><sect2><para>
6281 #: ../en/ch05-collab.xml:378
6282 msgid ""
6283 "Individual lieutenants have their own approaches to reviewing, accepting, and "
6284 "publishing changes; and for deciding when to feed them to Linus. In "
6285 "addition, there are several well known branches that people use for different "
6286 "purposes. For example, a few people maintain <quote>stable</quote> "
6287 "repositories of older versions of the kernel, to which they apply critical "
6288 "fixes as needed. Some maintainers publish multiple trees: one for "
6289 "experimental changes; one for changes that they are about to feed upstream; "
6290 "and so on. Others just publish a single tree."
6291 msgstr ""
6293 #. type: Content of: <book><chapter><sect1><sect2><para>
6294 #: ../en/ch05-collab.xml:389
6295 msgid ""
6296 "This model has two notable features. The first is that it's <quote>pull "
6297 "only</quote>. You have to ask, convince, or beg another developer to take a "
6298 "change from you, because there are almost no trees to which more than one "
6299 "person can push, and there's no way to push changes into a tree that someone "
6300 "else controls."
6301 msgstr ""
6303 #. type: Content of: <book><chapter><sect1><sect2><para>
6304 #: ../en/ch05-collab.xml:396
6305 msgid ""
6306 "The second is that it's based on reputation and acclaim. If you're an "
6307 "unknown, Linus will probably ignore changes from you without even "
6308 "responding. But a subsystem maintainer will probably review them, and will "
6309 "likely take them if they pass their criteria for suitability. The more "
6310 "<quote>good</quote> changes you contribute to a maintainer, the more likely "
6311 "they are to trust your judgment and accept your changes. If you're well-"
6312 "known and maintain a long-lived branch for something Linus hasn't yet "
6313 "accepted, people with similar interests may pull your changes regularly to "
6314 "keep up with your work."
6315 msgstr ""
6317 #. type: Content of: <book><chapter><sect1><sect2><para>
6318 #: ../en/ch05-collab.xml:407
6319 msgid ""
6320 "Reputation and acclaim don't necessarily cross subsystem or <quote>people</"
6321 "quote> boundaries. If you're a respected but specialised storage hacker, and "
6322 "you try to fix a networking bug, that change will receive a level of scrutiny "
6323 "from a network maintainer comparable to a change from a complete stranger."
6324 msgstr ""
6326 #. type: Content of: <book><chapter><sect1><sect2><para>
6327 #: ../en/ch05-collab.xml:414
6328 msgid ""
6329 "To people who come from more orderly project backgrounds, the comparatively "
6330 "chaotic Linux kernel development process often seems completely insane. It's "
6331 "subject to the whims of individuals; people make sweeping changes whenever "
6332 "they deem it appropriate; and the pace of development is astounding. And yet "
6333 "Linux is a highly successful, well-regarded piece of software."
6334 msgstr ""
6336 #. type: Content of: <book><chapter><sect1><sect2><title>
6337 #: ../en/ch05-collab.xml:424
6338 msgid "Pull-only versus shared-push collaboration"
6339 msgstr "只读与共享写协作"
6341 #. type: Content of: <book><chapter><sect1><sect2><para>
6342 #: ../en/ch05-collab.xml:426
6343 msgid ""
6344 "A perpetual source of heat in the open source community is whether a "
6345 "development model in which people only ever pull changes from others is "
6346 "<quote>better than</quote> one in which multiple people can push changes to a "
6347 "shared repository."
6348 msgstr ""
6350 #. type: Content of: <book><chapter><sect1><sect2><para>
6351 #: ../en/ch05-collab.xml:432
6352 msgid ""
6353 "Typically, the backers of the shared-push model use tools that actively "
6354 "enforce this approach. If you're using a centralised revision control tool "
6355 "such as Subversion, there's no way to make a choice over which model you'll "
6356 "use: the tool gives you shared-push, and if you want to do anything else, "
6357 "you'll have to roll your own approach on top (such as applying a patch by "
6358 "hand)."
6359 msgstr ""
6361 #. type: Content of: <book><chapter><sect1><sect2><para>
6362 #: ../en/ch05-collab.xml:440
6363 msgid ""
6364 "A good distributed revision control tool will support both models. You and "
6365 "your collaborators can then structure how you work together based on your own "
6366 "needs and preferences, not on what contortions your tools force you into."
6367 msgstr ""
6369 #. type: Content of: <book><chapter><sect1><sect2><title>
6370 #: ../en/ch05-collab.xml:447
6371 msgid "Where collaboration meets branch management"
6372 msgstr "协作与分支管理"
6374 #. type: Content of: <book><chapter><sect1><sect2><para>
6375 #: ../en/ch05-collab.xml:449
6376 msgid ""
6377 "Once you and your team set up some shared repositories and start propagating "
6378 "changes back and forth between local and shared repos, you begin to face a "
6379 "related, but slightly different challenge: that of managing the multiple "
6380 "directions in which your team may be moving at once. Even though this "
6381 "subject is intimately related to how your team collaborates, it's dense "
6382 "enough to merit treatment of its own, in <xref linkend=\"chap:branch\"/>."
6383 msgstr ""
6385 #. type: Content of: <book><chapter><sect1><title>
6386 #: ../en/ch05-collab.xml:461
6387 msgid "The technical side of sharing"
6388 msgstr "共享的技术因素"
6390 #. type: Content of: <book><chapter><sect1><para>
6391 #: ../en/ch05-collab.xml:463
6392 msgid ""
6393 "The remainder of this chapter is devoted to the question of sharing changes "
6394 "with your collaborators."
6395 msgstr ""
6397 #. type: Content of: <book><chapter><sect1><title>
6398 #: ../en/ch05-collab.xml:468
6399 msgid "Informal sharing with <command role=\"hg-cmd\">hg serve</command>"
6400 msgstr "使用 <command role=\"hg-cmd\">hg serve</command> 进行非正式共享"
6402 #. type: Content of: <book><chapter><sect1><para>
6403 #: ../en/ch05-collab.xml:471
6404 msgid ""
6405 "Mercurial's <command role=\"hg-cmd\">hg serve</command> command is "
6406 "wonderfully suited to small, tight-knit, and fast-paced group environments. "
6407 "It also provides a great way to get a feel for using Mercurial commands over "
6408 "a network."
6409 msgstr ""
6411 #. type: Content of: <book><chapter><sect1><para>
6412 #: ../en/ch05-collab.xml:476
6413 msgid ""
6414 "Run <command role=\"hg-cmd\">hg serve</command> inside a repository, and in "
6415 "under a second it will bring up a specialised HTTP server; this will accept "
6416 "connections from any client, and serve up data for that repository until you "
6417 "terminate it. Anyone who knows the URL of the server you just started, and "
6418 "can talk to your computer over the network, can then use a web browser or "
6419 "Mercurial to read data from that repository. A URL for a <command role=\"hg-"
6420 "cmd\">hg serve</command> instance running on a laptop is likely to look "
6421 "something like <literal>http://my-laptop.local:8000/</literal>."
6422 msgstr ""
6424 #. type: Content of: <book><chapter><sect1><para>
6425 #: ../en/ch05-collab.xml:487
6426 msgid ""
6427 "The <command role=\"hg-cmd\">hg serve</command> command is <emphasis>not</"
6428 "emphasis> a general-purpose web server. It can do only two things:"
6429 msgstr ""
6431 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
6432 #: ../en/ch05-collab.xml:491
6433 msgid ""
6434 "Allow people to browse the history of the repository it's serving, from their "
6435 "normal web browsers."
6436 msgstr ""
6438 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
6439 #: ../en/ch05-collab.xml:495
6440 msgid ""
6441 "Speak Mercurial's wire protocol, so that people can <command role=\"hg-cmd"
6442 "\">hg clone</command> or <command role=\"hg-cmd\">hg pull</command> changes "
6443 "from that repository."
6444 msgstr ""
6446 #. type: Content of: <book><chapter><sect1><para>
6447 #: ../en/ch05-collab.xml:500
6448 msgid ""
6449 "In particular, <command role=\"hg-cmd\">hg serve</command> won't allow remote "
6450 "users to <emphasis>modify</emphasis> your repository. It's intended for read-"
6451 "only use."
6452 msgstr ""
6454 #. type: Content of: <book><chapter><sect1><para>
6455 #: ../en/ch05-collab.xml:504
6456 msgid ""
6457 "If you're getting started with Mercurial, there's nothing to prevent you from "
6458 "using <command role=\"hg-cmd\">hg serve</command> to serve up a repository on "
6459 "your own computer, then use commands like <command role=\"hg-cmd\">hg clone</"
6460 "command>, <command role=\"hg-cmd\">hg incoming</command>, and so on to talk "
6461 "to that server as if the repository was hosted remotely. This can help you to "
6462 "quickly get acquainted with using commands on network-hosted repositories."
6463 msgstr ""
6465 #. type: Content of: <book><chapter><sect1><sect2><title>
6466 #: ../en/ch05-collab.xml:514
6467 msgid "A few things to keep in mind"
6468 msgstr "要牢记的几件事"
6470 #. type: Content of: <book><chapter><sect1><sect2><para>
6471 #: ../en/ch05-collab.xml:516
6472 msgid ""
6473 "Because it provides unauthenticated read access to all clients, you should "
6474 "only use <command role=\"hg-cmd\">hg serve</command> in an environment where "
6475 "you either don't care, or have complete control over, who can access your "
6476 "network and pull data from your repository."
6477 msgstr ""
6479 #. type: Content of: <book><chapter><sect1><sect2><para>
6480 #: ../en/ch05-collab.xml:522
6481 msgid ""
6482 "The <command role=\"hg-cmd\">hg serve</command> command knows nothing about "
6483 "any firewall software you might have installed on your system or network. It "
6484 "cannot detect or control your firewall software. If other people are unable "
6485 "to talk to a running <command role=\"hg-cmd\">hg serve</command> instance, "
6486 "the second thing you should do (<emphasis>after</emphasis> you make sure that "
6487 "they're using the correct URL) is check your firewall configuration."
6488 msgstr ""
6490 #. type: Content of: <book><chapter><sect1><sect2><para>
6491 #: ../en/ch05-collab.xml:531
6492 msgid ""
6493 "By default, <command role=\"hg-cmd\">hg serve</command> listens for incoming "
6494 "connections on port 8000. If another process is already listening on the "
6495 "port you want to use, you can specify a different port to listen on using the "
6496 "<option role=\"hg-opt-serve\">-p</option> option."
6497 msgstr ""
6499 #. type: Content of: <book><chapter><sect1><sect2><para>
6500 #: ../en/ch05-collab.xml:537
6501 msgid ""
6502 "Normally, when <command role=\"hg-cmd\">hg serve</command> starts, it prints "
6503 "no output, which can be a bit unnerving. If you'd like to confirm that it is "
6504 "indeed running correctly, and find out what URL you should send to your "
6505 "collaborators, start it with the <option role=\"hg-opt-global\">-v</option> "
6506 "option."
6507 msgstr ""
6509 #. type: Content of: <book><chapter><sect1><title>
6510 #: ../en/ch05-collab.xml:547
6511 msgid "Using the Secure Shell (ssh) protocol"
6512 msgstr "使用 ssh 协议"
6514 #. type: Content of: <book><chapter><sect1><para>
6515 #: ../en/ch05-collab.xml:549
6516 msgid ""
6517 "You can pull and push changes securely over a network connection using the "
6518 "Secure Shell (<literal>ssh</literal>) protocol. To use this successfully, "
6519 "you may have to do a little bit of configuration on the client or server "
6520 "sides."
6521 msgstr ""
6523 #. type: Content of: <book><chapter><sect1><para>
6524 #: ../en/ch05-collab.xml:554
6525 msgid ""
6526 "If you're not familiar with ssh, it's the name of both a command and a "
6527 "network protocol that let you securely communicate with another computer. To "
6528 "use it with Mercurial, you'll be setting up one or more user accounts on a "
6529 "server so that remote users can log in and execute commands."
6530 msgstr ""
6532 #. type: Content of: <book><chapter><sect1><para>
6533 #: ../en/ch05-collab.xml:560
6534 msgid ""
6535 "(If you <emphasis>are</emphasis> familiar with ssh, you'll probably find some "
6536 "of the material that follows to be elementary in nature.)"
6537 msgstr ""
6539 #. type: Content of: <book><chapter><sect1><sect2><title>
6540 #: ../en/ch05-collab.xml:565
6541 msgid "How to read and write ssh URLs"
6542 msgstr "如何读写 ssh 路径"
6544 #. type: Content of: <book><chapter><sect1><sect2><para>
6545 #: ../en/ch05-collab.xml:567
6546 msgid "An ssh URL tends to look like this:"
6547 msgstr ""
6549 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
6550 #: ../en/ch05-collab.xml:570
6551 msgid ""
6552 "The <quote><literal>ssh://</literal></quote> part tells Mercurial to use the "
6553 "ssh protocol."
6554 msgstr ""
6556 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
6557 #: ../en/ch05-collab.xml:573
6558 msgid ""
6559 "The <quote><literal>bos@</literal></quote> component indicates what username "
6560 "to log into the server as. You can leave this out if the remote username is "
6561 "the same as your local username."
6562 msgstr ""
6564 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
6565 #: ../en/ch05-collab.xml:578
6566 msgid ""
6567 "The <quote><literal>hg.serpentine.com</literal></quote> gives the hostname of "
6568 "the server to log into."
6569 msgstr ""
6571 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
6572 #: ../en/ch05-collab.xml:582
6573 msgid ""
6574 "The <quote>:22</quote> identifies the port number to connect to the server "
6575 "on. The default port is 22, so you only need to specify a colon and port "
6576 "number if you're <emphasis>not</emphasis> using port 22."
6577 msgstr ""
6579 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
6580 #: ../en/ch05-collab.xml:587
6581 msgid ""
6582 "The remainder of the URL is the local path to the repository on the server."
6583 msgstr ""
6585 #. type: Content of: <book><chapter><sect1><sect2><para>
6586 #: ../en/ch05-collab.xml:591
6587 msgid ""
6588 "There's plenty of scope for confusion with the path component of ssh URLs, as "
6589 "there is no standard way for tools to interpret it. Some programs behave "
6590 "differently than others when dealing with these paths. This isn't an ideal "
6591 "situation, but it's unlikely to change. Please read the following paragraphs "
6592 "carefully."
6593 msgstr ""
6595 #. type: Content of: <book><chapter><sect1><sect2><para>
6596 #: ../en/ch05-collab.xml:598
6597 msgid ""
6598 "Mercurial treats the path to a repository on the server as relative to the "
6599 "remote user's home directory. For example, if user <literal>foo</literal> on "
6600 "the server has a home directory of <filename class=\"directory\">/home/foo</"
6601 "filename>, then an ssh URL that contains a path component of <filename class="
6602 "\"directory\">bar</filename> <emphasis>really</emphasis> refers to the "
6603 "directory <filename class=\"directory\">/home/foo/bar</filename>."
6604 msgstr ""
6606 #. type: Content of: <book><chapter><sect1><sect2><para>
6607 #: ../en/ch05-collab.xml:607
6608 msgid ""
6609 "If you want to specify a path relative to another user's home directory, you "
6610 "can use a path that starts with a tilde character followed by the user's name "
6611 "(let's call them <literal>otheruser</literal>), like this."
6612 msgstr ""
6614 #. type: Content of: <book><chapter><sect1><sect2><para>
6615 #: ../en/ch05-collab.xml:613
6616 msgid ""
6617 "And if you really want to specify an <emphasis>absolute</emphasis> path on "
6618 "the server, begin the path component with two slashes, as in this example."
6619 msgstr ""
6621 #. type: Content of: <book><chapter><sect1><sect2><title>
6622 #: ../en/ch05-collab.xml:620
6623 msgid "Finding an ssh client for your system"
6624 msgstr "为你的系统寻找 ssh 客户端"
6626 #. type: Content of: <book><chapter><sect1><sect2><para>
6627 #: ../en/ch05-collab.xml:622
6628 msgid ""
6629 "Almost every Unix-like system comes with OpenSSH preinstalled. If you're "
6630 "using such a system, run <literal>which ssh</literal> to find out if the "
6631 "<command>ssh</command> command is installed (it's usually in <filename class="
6632 "\"directory\">/usr/bin</filename>). In the unlikely event that it isn't "
6633 "present, take a look at your system documentation to figure out how to "
6634 "install it."
6635 msgstr ""
6637 #. type: Content of: <book><chapter><sect1><sect2><para>
6638 #: ../en/ch05-collab.xml:630
6639 msgid ""
6640 "On Windows, the TortoiseHg package is bundled with a version of Simon "
6641 "Tatham's excellent <command>plink</command> command, and you should not need "
6642 "to do any further configuration."
6643 msgstr ""
6645 #. type: Content of: <book><chapter><sect1><sect2><title>
6646 #: ../en/ch05-collab.xml:637
6647 msgid "Generating a key pair"
6648 msgstr "产生密钥对"
6650 #. type: Content of: <book><chapter><sect1><sect2><para>
6651 #: ../en/ch05-collab.xml:639
6652 msgid ""
6653 "To avoid the need to repetitively type a password every time you need to use "
6654 "your ssh client, I recommend generating a key pair."
6655 msgstr ""
6657 #. type: Content of: <book><chapter><sect1><sect2><tip><title>
6658 #: ../en/ch05-collab.xml:644
6659 msgid "Key pairs are not mandatory"
6660 msgstr ""
6662 #. type: Content of: <book><chapter><sect1><sect2><tip><para>
6663 #: ../en/ch05-collab.xml:646
6664 msgid ""
6665 "Mercurial knows nothing about ssh authentication or key pairs. You can, if "
6666 "you like, safely ignore this section and the one that follows until you grow "
6667 "tired of repeatedly typing ssh passwords."
6668 msgstr ""
6670 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6671 #: ../en/ch05-collab.xml:654
6672 msgid ""
6673 "On a Unix-like system, the <command>ssh-keygen</command> command will do the "
6674 "trick."
6675 msgstr ""
6677 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6678 #: ../en/ch05-collab.xml:657
6679 msgid ""
6680 "On Windows, if you're using TortoiseHg, you may need to download a command "
6681 "named <command>puttygen</command> from <ulink url=\"http://www.chiark."
6682 "greenend.org.uk/~sgtatham/putty\">the PuTTY web site</ulink> to generate a "
6683 "key pair. See <ulink url=\"http://the.earth.li/~sgtatham/putty/0.60/htmldoc/"
6684 "Chapter8.html#pubkey-puttygen\">the <command>puttygen</command> "
6685 "documentation</ulink> for details of how use the command."
6686 msgstr ""
6688 #. type: Content of: <book><chapter><sect1><sect2><para>
6689 #: ../en/ch05-collab.xml:669
6690 msgid ""
6691 "When you generate a key pair, it's usually <emphasis>highly</emphasis> "
6692 "advisable to protect it with a passphrase. (The only time that you might not "
6693 "want to do this is when you're using the ssh protocol for automated tasks on "
6694 "a secure network.)"
6695 msgstr ""
6697 #. type: Content of: <book><chapter><sect1><sect2><para>
6698 #: ../en/ch05-collab.xml:675
6699 msgid ""
6700 "Simply generating a key pair isn't enough, however. You'll need to add the "
6701 "public key to the set of authorised keys for whatever user you're logging in "
6702 "remotely as. For servers using OpenSSH (the vast majority), this will mean "
6703 "adding the public key to a list in a file called <filename role=\"special"
6704 "\">authorized_keys</filename> in their <filename role=\"special\" class="
6705 "\"directory\">.ssh</filename> directory."
6706 msgstr ""
6708 #. type: Content of: <book><chapter><sect1><sect2><para>
6709 #: ../en/ch05-collab.xml:684
6710 msgid ""
6711 "On a Unix-like system, your public key will have a <filename>.pub</filename> "
6712 "extension. If you're using <command>puttygen</command> on Windows, you can "
6713 "save the public key to a file of your choosing, or paste it from the window "
6714 "it's displayed in straight into the <filename role=\"special"
6715 "\">authorized_keys</filename> file."
6716 msgstr ""
6718 #. type: Content of: <book><chapter><sect1><sect2><title>
6719 #: ../en/ch05-collab.xml:692
6720 msgid "Using an authentication agent"
6721 msgstr "使用认证代理"
6723 #. type: Content of: <book><chapter><sect1><sect2><para>
6724 #: ../en/ch05-collab.xml:694
6725 msgid ""
6726 "An authentication agent is a daemon that stores passphrases in memory (so it "
6727 "will forget passphrases if you log out and log back in again). An ssh client "
6728 "will notice if it's running, and query it for a passphrase. If there's no "
6729 "authentication agent running, or the agent doesn't store the necessary "
6730 "passphrase, you'll have to type your passphrase every time Mercurial tries to "
6731 "communicate with a server on your behalf (e.g. whenever you pull or push "
6732 "changes)."
6733 msgstr ""
6735 #. type: Content of: <book><chapter><sect1><sect2><para>
6736 #: ../en/ch05-collab.xml:703
6737 msgid ""
6738 "The downside of storing passphrases in an agent is that it's possible for a "
6739 "well-prepared attacker to recover the plain text of your passphrases, in some "
6740 "cases even if your system has been power-cycled. You should make your own "
6741 "judgment as to whether this is an acceptable risk. It certainly saves a lot "
6742 "of repeated typing."
6743 msgstr ""
6745 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6746 #: ../en/ch05-collab.xml:712
6747 msgid ""
6748 "On Unix-like systems, the agent is called <command>ssh-agent</command>, and "
6749 "it's often run automatically for you when you log in. You'll need to use the "
6750 "<command>ssh-add</command> command to add passphrases to the agent's store."
6751 msgstr ""
6753 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6754 #: ../en/ch05-collab.xml:719
6755 msgid ""
6756 "On Windows, if you're using TortoiseHg, the <command>pageant</command> "
6757 "command acts as the agent. As with <command>puttygen</command>, you'll need "
6758 "to <ulink url=\"http://www.chiark.greenend.org.uk/%7Esgtatham/putty/download."
6759 "html\">download <command>pageant</command></ulink> from the PuTTY web site "
6760 "and read <ulink url=\"http://the.earth.li/~sgtatham/putty/0.60/htmldoc/"
6761 "Chapter9.html#pageant\">its documentation</ulink>. The <command>pageant</"
6762 "command> command adds an icon to your system tray that will let you manage "
6763 "stored passphrases."
6764 msgstr ""
6766 #. type: Content of: <book><chapter><sect1><sect2><title>
6767 #: ../en/ch05-collab.xml:734
6768 msgid "Configuring the server side properly"
6769 msgstr "正确配置服务器端"
6771 #. type: Content of: <book><chapter><sect1><sect2><para>
6772 #: ../en/ch05-collab.xml:736
6773 msgid ""
6774 "Because ssh can be fiddly to set up if you're new to it, a variety of things "
6775 "can go wrong. Add Mercurial on top, and there's plenty more scope for head-"
6776 "scratching. Most of these potential problems occur on the server side, not "
6777 "the client side. The good news is that once you've gotten a configuration "
6778 "working, it will usually continue to work indefinitely."
6779 msgstr ""
6781 #. type: Content of: <book><chapter><sect1><sect2><para>
6782 #: ../en/ch05-collab.xml:744
6783 msgid ""
6784 "Before you try using Mercurial to talk to an ssh server, it's best to make "
6785 "sure that you can use the normal <command>ssh</command> or <command>putty</"
6786 "command> command to talk to the server first. If you run into problems with "
6787 "using these commands directly, Mercurial surely won't work. Worse, it will "
6788 "obscure the underlying problem. Any time you want to debug ssh-related "
6789 "Mercurial problems, you should drop back to making sure that plain ssh client "
6790 "commands work first, <emphasis>before</emphasis> you worry about whether "
6791 "there's a problem with Mercurial."
6792 msgstr ""
6794 #. type: Content of: <book><chapter><sect1><sect2><para>
6795 #: ../en/ch05-collab.xml:755
6796 msgid ""
6797 "The first thing to be sure of on the server side is that you can actually log "
6798 "in from another machine at all. If you can't use <command>ssh</command> or "
6799 "<command>putty</command> to log in, the error message you get may give you a "
6800 "few hints as to what's wrong. The most common problems are as follows."
6801 msgstr ""
6803 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6804 #: ../en/ch05-collab.xml:762
6805 msgid ""
6806 "If you get a <quote>connection refused</quote> error, either there isn't an "
6807 "SSH daemon running on the server at all, or it's inaccessible due to firewall "
6808 "configuration."
6809 msgstr ""
6811 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6812 #: ../en/ch05-collab.xml:767
6813 msgid ""
6814 "If you get a <quote>no route to host</quote> error, you either have an "
6815 "incorrect address for the server or a seriously locked down firewall that "
6816 "won't admit its existence at all."
6817 msgstr ""
6819 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6820 #: ../en/ch05-collab.xml:772
6821 msgid ""
6822 "If you get a <quote>permission denied</quote> error, you may have mistyped "
6823 "the username on the server, or you could have mistyped your key's passphrase "
6824 "or the remote user's password."
6825 msgstr ""
6827 #. type: Content of: <book><chapter><sect1><sect2><para>
6828 #: ../en/ch05-collab.xml:777
6829 msgid ""
6830 "In summary, if you're having trouble talking to the server's ssh daemon, "
6831 "first make sure that one is running at all. On many systems it will be "
6832 "installed, but disabled, by default. Once you're done with this step, you "
6833 "should then check that the server's firewall is configured to allow incoming "
6834 "connections on the port the ssh daemon is listening on (usually 22). Don't "
6835 "worry about more exotic possibilities for misconfiguration until you've "
6836 "checked these two first."
6837 msgstr ""
6839 #. type: Content of: <book><chapter><sect1><sect2><para>
6840 #: ../en/ch05-collab.xml:787
6841 msgid ""
6842 "If you're using an authentication agent on the client side to store "
6843 "passphrases for your keys, you ought to be able to log into the server "
6844 "without being prompted for a passphrase or a password. If you're prompted "
6845 "for a passphrase, there are a few possible culprits."
6846 msgstr ""
6848 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6849 #: ../en/ch05-collab.xml:793
6850 msgid ""
6851 "You might have forgotten to use <command>ssh-add</command> or "
6852 "<command>pageant</command> to store the passphrase."
6853 msgstr ""
6855 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6856 #: ../en/ch05-collab.xml:797
6857 msgid "You might have stored the passphrase for the wrong key."
6858 msgstr ""
6860 #. type: Content of: <book><chapter><sect1><sect2><para>
6861 #: ../en/ch05-collab.xml:800
6862 msgid ""
6863 "If you're being prompted for the remote user's password, there are another "
6864 "few possible problems to check."
6865 msgstr ""
6867 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6868 #: ../en/ch05-collab.xml:803
6869 msgid ""
6870 "Either the user's home directory or their <filename role=\"special\" class="
6871 "\"directory\">.ssh</filename> directory might have excessively liberal "
6872 "permissions. As a result, the ssh daemon will not trust or read their "
6873 "<filename role=\"special\">authorized_keys</filename> file. For example, a "
6874 "group-writable home or <filename role=\"special\" class=\"directory\">.ssh</"
6875 "filename> directory will often cause this symptom."
6876 msgstr ""
6878 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6879 #: ../en/ch05-collab.xml:812
6880 msgid ""
6881 "The user's <filename role=\"special\">authorized_keys</filename> file may "
6882 "have a problem. If anyone other than the user owns or can write to that file, "
6883 "the ssh daemon will not trust or read it."
6884 msgstr ""
6886 #. type: Content of: <book><chapter><sect1><sect2><para>
6887 #: ../en/ch05-collab.xml:819
6888 msgid ""
6889 "In the ideal world, you should be able to run the following command "
6890 "successfully, and it should print exactly one line of output, the current "
6891 "date and time."
6892 msgstr ""
6894 #. type: Content of: <book><chapter><sect1><sect2><para>
6895 #: ../en/ch05-collab.xml:824
6896 msgid ""
6897 "If, on your server, you have login scripts that print banners or other junk "
6898 "even when running non-interactive commands like this, you should fix them "
6899 "before you continue, so that they only print output if they're run "
6900 "interactively. Otherwise these banners will at least clutter up Mercurial's "
6901 "output. Worse, they could potentially cause problems with running Mercurial "
6902 "commands remotely. Mercurial makes tries to detect and ignore banners in non-"
6903 "interactive <command>ssh</command> sessions, but it is not foolproof. (If "
6904 "you're editing your login scripts on your server, the usual way to see if a "
6905 "login script is running in an interactive shell is to check the return code "
6906 "from the command <literal>tty -s</literal>.)"
6907 msgstr ""
6909 #. type: Content of: <book><chapter><sect1><sect2><para>
6910 #: ../en/ch05-collab.xml:838
6911 msgid ""
6912 "Once you've verified that plain old ssh is working with your server, the next "
6913 "step is to ensure that Mercurial runs on the server. The following command "
6914 "should run successfully:"
6915 msgstr ""
6917 #. type: Content of: <book><chapter><sect1><sect2><para>
6918 #: ../en/ch05-collab.xml:845
6919 msgid ""
6920 "If you see an error message instead of normal <command role=\"hg-cmd\">hg "
6921 "version</command> output, this is usually because you haven't installed "
6922 "Mercurial to <filename class=\"directory\">/usr/bin</filename>. Don't worry "
6923 "if this is the case; you don't need to do that. But you should check for a "
6924 "few possible problems."
6925 msgstr ""
6927 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6928 #: ../en/ch05-collab.xml:852
6929 msgid ""
6930 "Is Mercurial really installed on the server at all? I know this sounds "
6931 "trivial, but it's worth checking!"
6932 msgstr ""
6934 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6935 #: ../en/ch05-collab.xml:856
6936 msgid ""
6937 "Maybe your shell's search path (usually set via the <envar>PATH</envar> "
6938 "environment variable) is simply misconfigured."
6939 msgstr ""
6941 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6942 #: ../en/ch05-collab.xml:860
6943 msgid ""
6944 "Perhaps your <envar>PATH</envar> environment variable is only being set to "
6945 "point to the location of the <command>hg</command> executable if the login "
6946 "session is interactive. This can happen if you're setting the path in the "
6947 "wrong shell login script. See your shell's documentation for details."
6948 msgstr ""
6950 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6951 #: ../en/ch05-collab.xml:867
6952 msgid ""
6953 "The <envar>PYTHONPATH</envar> environment variable may need to contain the "
6954 "path to the Mercurial Python modules. It might not be set at all; it could "
6955 "be incorrect; or it may be set only if the login is interactive."
6956 msgstr ""
6958 #. type: Content of: <book><chapter><sect1><sect2><para>
6959 #: ../en/ch05-collab.xml:874
6960 msgid ""
6961 "If you can run <command role=\"hg-cmd\">hg version</command> over an ssh "
6962 "connection, well done! You've got the server and client sorted out. You "
6963 "should now be able to use Mercurial to access repositories hosted by that "
6964 "username on that server. If you run into problems with Mercurial and ssh at "
6965 "this point, try using the <option role=\"hg-opt-global\">--debug</option> "
6966 "option to get a clearer picture of what's going on."
6967 msgstr ""
6969 #. type: Content of: <book><chapter><sect1><sect2><title>
6970 #: ../en/ch05-collab.xml:883
6971 msgid "Using compression with ssh"
6972 msgstr "通过 ssh 使用压缩"
6974 #. type: Content of: <book><chapter><sect1><sect2><para>
6975 #: ../en/ch05-collab.xml:885
6976 msgid ""
6977 "Mercurial does not compress data when it uses the ssh protocol, because the "
6978 "ssh protocol can transparently compress data. However, the default behavior "
6979 "of ssh clients is <emphasis>not</emphasis> to request compression."
6980 msgstr ""
6982 #. type: Content of: <book><chapter><sect1><sect2><para>
6983 #: ../en/ch05-collab.xml:890
6984 msgid ""
6985 "Over any network other than a fast LAN (even a wireless network), using "
6986 "compression is likely to significantly speed up Mercurial's network "
6987 "operations. For example, over a WAN, someone measured compression as "
6988 "reducing the amount of time required to clone a particularly large repository "
6989 "from 51 minutes to 17 minutes."
6990 msgstr ""
6992 #. type: Content of: <book><chapter><sect1><sect2><para>
6993 #: ../en/ch05-collab.xml:897
6994 msgid ""
6995 "Both <command>ssh</command> and <command>plink</command> accept a <option "
6996 "role=\"cmd-opt-ssh\">-C</option> option which turns on compression. You can "
6997 "easily edit your <filename role=\"special\">~/.hgrc</filename> to enable "
6998 "compression for all of Mercurial's uses of the ssh protocol. Here is how to "
6999 "do so for regular <command>ssh</command> on Unix-like systems, for example."
7000 msgstr ""
7002 #. type: Content of: <book><chapter><sect1><sect2><para>
7003 #: ../en/ch05-collab.xml:907
7004 msgid ""
7005 "If you use <command>ssh</command> on a Unix-like system, you can configure it "
7006 "to always use compression when talking to your server. To do this, edit your "
7007 "<filename role=\"special\">.ssh/config</filename> file (which may not yet "
7008 "exist), as follows."
7009 msgstr ""
7011 #. type: Content of: <book><chapter><sect1><sect2><para>
7012 #: ../en/ch05-collab.xml:917
7013 msgid ""
7014 "This defines a hostname alias, <literal>hg</literal>. When you use that "
7015 "hostname on the <command>ssh</command> command line or in a Mercurial "
7016 "<literal>ssh</literal>-protocol URL, it will cause <command>ssh</command> to "
7017 "connect to <literal>hg.example.com</literal> and use compression. This gives "
7018 "you both a shorter name to type and compression, each of which is a good "
7019 "thing in its own right."
7020 msgstr ""
7022 #. type: Content of: <book><chapter><sect1><title>
7023 #: ../en/ch05-collab.xml:929
7024 msgid "Serving over HTTP using CGI"
7025 msgstr "使用 CGI 通过 HTTP 提供服务"
7027 #. type: Content of: <book><chapter><sect1><para>
7028 #: ../en/ch05-collab.xml:931
7029 msgid ""
7030 "The simplest way to host one or more repositories in a permanent way is to "
7031 "use a web server and Mercurial's CGI support."
7032 msgstr ""
7034 #. type: Content of: <book><chapter><sect1><para>
7035 #: ../en/ch05-collab.xml:935
7036 msgid ""
7037 "Depending on how ambitious you are, configuring Mercurial's CGI interface can "
7038 "take anything from a few moments to several hours."
7039 msgstr ""
7041 #. type: Content of: <book><chapter><sect1><para>
7042 #: ../en/ch05-collab.xml:939
7043 msgid ""
7044 "We'll begin with the simplest of examples, and work our way towards a more "
7045 "complex configuration. Even for the most basic case, you're almost certainly "
7046 "going to need to read and modify your web server's configuration."
7047 msgstr ""
7049 #. type: Content of: <book><chapter><sect1><note><title>
7050 #: ../en/ch05-collab.xml:945
7051 msgid "High pain tolerance required"
7052 msgstr ""
7054 #. type: Content of: <book><chapter><sect1><note><para>
7055 #: ../en/ch05-collab.xml:947
7056 msgid ""
7057 "Configuring a web server is a complex, fiddly, and highly system-dependent "
7058 "activity. I can't possibly give you instructions that will cover anything "
7059 "like all of the cases you will encounter. Please use your discretion and "
7060 "judgment in following the sections below. Be prepared to make plenty of "
7061 "mistakes, and to spend a lot of time reading your server's error logs."
7062 msgstr ""
7064 #. type: Content of: <book><chapter><sect1><note><para>
7065 #: ../en/ch05-collab.xml:955
7066 msgid ""
7067 "If you don't have a strong stomach for tweaking configurations over and over, "
7068 "or a compelling need to host your own services, you might want to try one of "
7069 "the public hosting services that I mentioned earlier."
7070 msgstr ""
7072 #. type: Content of: <book><chapter><sect1><sect2><title>
7073 #: ../en/ch05-collab.xml:962
7074 msgid "Web server configuration checklist"
7075 msgstr "Web 服务器配置检查表"
7077 #. type: Content of: <book><chapter><sect1><sect2><para>
7078 #: ../en/ch05-collab.xml:964
7079 msgid ""
7080 "Before you continue, do take a few moments to check a few aspects of your "
7081 "system's setup."
7082 msgstr ""
7084 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
7085 #: ../en/ch05-collab.xml:968
7086 msgid ""
7087 "Do you have a web server installed at all? Mac OS X and some Linux "
7088 "distributions ship with Apache, but many other systems may not have a web "
7089 "server installed."
7090 msgstr ""
7092 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
7093 #: ../en/ch05-collab.xml:973
7094 msgid ""
7095 "If you have a web server installed, is it actually running? On most systems, "
7096 "even if one is present, it will be disabled by default."
7097 msgstr ""
7099 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
7100 #: ../en/ch05-collab.xml:977
7101 msgid ""
7102 "Is your server configured to allow you to run CGI programs in the directory "
7103 "where you plan to do so? Most servers default to explicitly disabling the "
7104 "ability to run CGI programs."
7105 msgstr ""
7107 #. type: Content of: <book><chapter><sect1><sect2><para>
7108 #: ../en/ch05-collab.xml:983
7109 msgid ""
7110 "If you don't have a web server installed, and don't have substantial "
7111 "experience configuring Apache, you should consider using the "
7112 "<literal>lighttpd</literal> web server instead of Apache. Apache has a well-"
7113 "deserved reputation for baroque and confusing configuration. While "
7114 "<literal>lighttpd</literal> is less capable in some ways than Apache, most of "
7115 "these capabilities are not relevant to serving Mercurial repositories. And "
7116 "<literal>lighttpd</literal> is undeniably <emphasis>much</emphasis> easier to "
7117 "get started with than Apache."
7118 msgstr ""
7120 #. type: Content of: <book><chapter><sect1><sect2><title>
7121 #: ../en/ch05-collab.xml:996
7122 msgid "Basic CGI configuration"
7123 msgstr "基本 CGI 配置"
7125 #. type: Content of: <book><chapter><sect1><sect2><para>
7126 #: ../en/ch05-collab.xml:998
7127 msgid ""
7128 "On Unix-like systems, it's common for users to have a subdirectory named "
7129 "something like <filename class=\"directory\">public_html</filename> in their "
7130 "home directory, from which they can serve up web pages. A file named "
7131 "<filename>foo</filename> in this directory will be accessible at a URL of the "
7132 "form <literal>http://www.example.com/username/foo</literal>."
7133 msgstr ""
7135 #. type: Content of: <book><chapter><sect1><sect2><para>
7136 #: ../en/ch05-collab.xml:1006
7137 msgid ""
7138 "To get started, find the <filename role=\"special\">hgweb.cgi</filename> "
7139 "script that should be present in your Mercurial installation. If you can't "
7140 "quickly find a local copy on your system, simply download one from the master "
7141 "Mercurial repository at <ulink url=\"http://www.selenic.com/repo/hg/raw-file/"
7142 "tip/hgweb.cgi\">http://www.selenic.com/repo/hg/raw-file/tip/hgweb.cgi</ulink>."
7143 msgstr ""
7145 #. type: Content of: <book><chapter><sect1><sect2><para>
7146 #: ../en/ch05-collab.xml:1013 ../en/ch05-collab.xml:1182
7147 msgid ""
7148 "You'll need to copy this script into your <filename class=\"directory"
7149 "\">public_html</filename> directory, and ensure that it's executable."
7150 msgstr ""
7152 #. type: Content of: <book><chapter><sect1><sect2><para>
7153 #: ../en/ch05-collab.xml:1018
7154 msgid ""
7155 "The <literal>755</literal> argument to <command>chmod</command> is a little "
7156 "more general than just making the script executable: it ensures that the "
7157 "script is executable by anyone, and that <quote>group</quote> and "
7158 "<quote>other</quote> write permissions are <emphasis>not</emphasis> set. If "
7159 "you were to leave those write permissions enabled, Apache's <literal>suexec</"
7160 "literal> subsystem would likely refuse to execute the script. In fact, "
7161 "<literal>suexec</literal> also insists that the <emphasis>directory</"
7162 "emphasis> in which the script resides must not be writable by others."
7163 msgstr ""
7165 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
7166 #: ../en/ch05-collab.xml:1032
7167 msgid "What could <emphasis>possibly</emphasis> go wrong?"
7168 msgstr "什么<emphasis>可能</emphasis>会出错?"
7170 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7171 #: ../en/ch05-collab.xml:1035
7172 msgid ""
7173 "Once you've copied the CGI script into place, go into a web browser, and try "
7174 "to open the URL <ulink url=\"http://myhostname/ myuser/hgweb.cgi\">http://"
7175 "myhostname/ myuser/hgweb.cgi</ulink>, <emphasis>but</emphasis> brace yourself "
7176 "for instant failure. There's a high probability that trying to visit this "
7177 "URL will fail, and there are many possible reasons for this. In fact, you're "
7178 "likely to stumble over almost every one of the possible errors below, so "
7179 "please read carefully. The following are all of the problems I ran into on a "
7180 "system running Fedora 7, with a fresh installation of Apache, and a user "
7181 "account that I created specially to perform this exercise."
7182 msgstr ""
7184 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7185 #: ../en/ch05-collab.xml:1049
7186 msgid ""
7187 "Your web server may have per-user directories disabled. If you're using "
7188 "Apache, search your config file for a <literal>UserDir</literal> directive. "
7189 "If there's none present, per-user directories will be disabled. If one "
7190 "exists, but its value is <literal>disabled</literal>, then per-user "
7191 "directories will be disabled. Otherwise, the string after <literal>UserDir</"
7192 "literal> gives the name of the subdirectory that Apache will look in under "
7193 "your home directory, for example <filename class=\"directory\">public_html</"
7194 "filename>."
7195 msgstr ""
7197 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7198 #: ../en/ch05-collab.xml:1060
7199 msgid ""
7200 "Your file access permissions may be too restrictive. The web server must be "
7201 "able to traverse your home directory and directories under your <filename "
7202 "class=\"directory\">public_html</filename> directory, and read files under "
7203 "the latter too. Here's a quick recipe to help you to make your permissions "
7204 "more appropriate."
7205 msgstr ""
7207 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7208 #: ../en/ch05-collab.xml:1070
7209 msgid ""
7210 "The other possibility with permissions is that you might get a completely "
7211 "empty window when you try to load the script. In this case, it's likely that "
7212 "your access permissions are <emphasis>too permissive</emphasis>. Apache's "
7213 "<literal>suexec</literal> subsystem won't execute a script that's group- or "
7214 "world-writable, for example."
7215 msgstr ""
7217 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7218 #: ../en/ch05-collab.xml:1077
7219 msgid ""
7220 "Your web server may be configured to disallow execution of CGI programs in "
7221 "your per-user web directory. Here's Apache's default per-user configuration "
7222 "from my Fedora system."
7223 msgstr ""
7225 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7226 #: ../en/ch05-collab.xml:1084
7227 msgid ""
7228 "If you find a similar-looking <literal>Directory</literal> group in your "
7229 "Apache configuration, the directive to look at inside it is <literal>Options</"
7230 "literal>. Add <literal>ExecCGI</literal> to the end of this list if it's "
7231 "missing, and restart the web server."
7232 msgstr ""
7234 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7235 #: ../en/ch05-collab.xml:1091
7236 msgid ""
7237 "If you find that Apache serves you the text of the CGI script instead of "
7238 "executing it, you may need to either uncomment (if already present) or add a "
7239 "directive like this."
7240 msgstr ""
7242 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7243 #: ../en/ch05-collab.xml:1097
7244 msgid ""
7245 "The next possibility is that you might be served with a colourful Python "
7246 "backtrace claiming that it can't import a <literal>mercurial</literal>-"
7247 "related module. This is actually progress! The server is now capable of "
7248 "executing your CGI script. This error is only likely to occur if you're "
7249 "running a private installation of Mercurial, instead of a system-wide "
7250 "version. Remember that the web server runs the CGI program without any of "
7251 "the environment variables that you take for granted in an interactive "
7252 "session. If this error happens to you, edit your copy of <filename role="
7253 "\"special\">hgweb.cgi</filename> and follow the directions inside it to "
7254 "correctly set your <envar>PYTHONPATH</envar> environment variable."
7255 msgstr ""
7257 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7258 #: ../en/ch05-collab.xml:1111
7259 msgid ""
7260 "Finally, you are <emphasis>certain</emphasis> to by served with another "
7261 "colourful Python backtrace: this one will complain that it can't find "
7262 "<filename class=\"directory\">/path/to/repository</filename>. Edit your "
7263 "<filename role=\"special\">hgweb.cgi</filename> script and replace the "
7264 "<filename class=\"directory\">/path/to/repository</filename> string with the "
7265 "complete path to the repository you want to serve up."
7266 msgstr ""
7268 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7269 #: ../en/ch05-collab.xml:1121
7270 msgid ""
7271 "At this point, when you try to reload the page, you should be presented with "
7272 "a nice HTML view of your repository's history. Whew!"
7273 msgstr ""
7275 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
7276 #: ../en/ch05-collab.xml:1127
7277 msgid "Configuring lighttpd"
7278 msgstr "配置 lighttpd"
7280 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7281 #: ../en/ch05-collab.xml:1129
7282 msgid ""
7283 "To be exhaustive in my experiments, I tried configuring the increasingly "
7284 "popular <literal>lighttpd</literal> web server to serve the same repository "
7285 "as I described with Apache above. I had already overcome all of the problems "
7286 "I outlined with Apache, many of which are not server-specific. As a result, "
7287 "I was fairly sure that my file and directory permissions were good, and that "
7288 "my <filename role=\"special\">hgweb.cgi</filename> script was properly edited."
7289 msgstr ""
7291 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7292 #: ../en/ch05-collab.xml:1139
7293 msgid ""
7294 "Once I had Apache running, getting <literal>lighttpd</literal> to serve the "
7295 "repository was a snap (in other words, even if you're trying to use "
7296 "<literal>lighttpd</literal>, you should read the Apache section). I first "
7297 "had to edit the <literal>mod_access</literal> section of its config file to "
7298 "enable <literal>mod_cgi</literal> and <literal>mod_userdir</literal>, both of "
7299 "which were disabled by default on my system. I then added a few lines to the "
7300 "end of the config file, to configure these modules."
7301 msgstr ""
7303 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7304 #: ../en/ch05-collab.xml:1151
7305 msgid ""
7306 "With this done, <literal>lighttpd</literal> ran immediately for me. If I had "
7307 "configured <literal>lighttpd</literal> before Apache, I'd almost certainly "
7308 "have run into many of the same system-level configuration problems as I did "
7309 "with Apache. However, I found <literal>lighttpd</literal> to be noticeably "
7310 "easier to configure than Apache, even though I've used Apache for over a "
7311 "decade, and this was my first exposure to <literal>lighttpd</literal>."
7312 msgstr ""
7314 #. type: Content of: <book><chapter><sect1><sect2><title>
7315 #: ../en/ch05-collab.xml:1164
7316 msgid "Sharing multiple repositories with one CGI script"
7317 msgstr "使用一个 CGI 脚本共享多个版本库"
7319 #. type: Content of: <book><chapter><sect1><sect2><para>
7320 #: ../en/ch05-collab.xml:1166
7321 msgid ""
7322 "The <filename role=\"special\">hgweb.cgi</filename> script only lets you "
7323 "publish a single repository, which is an annoying restriction. If you want "
7324 "to publish more than one without wracking yourself with multiple copies of "
7325 "the same script, each with different names, a better choice is to use the "
7326 "<filename role=\"special\">hgwebdir.cgi</filename> script."
7327 msgstr ""
7329 #. type: Content of: <book><chapter><sect1><sect2><para>
7330 #: ../en/ch05-collab.xml:1174
7331 msgid ""
7332 "The procedure to configure <filename role=\"special\">hgwebdir.cgi</filename> "
7333 "is only a little more involved than for <filename role=\"special\">hgweb.cgi</"
7334 "filename>. First, you must obtain a copy of the script. If you don't have "
7335 "one handy, you can download a copy from the master Mercurial repository at "
7336 "<ulink url=\"http://www.selenic.com/repo/hg/raw-file/tip/hgwebdir.cgi"
7337 "\">http://www.selenic.com/repo/hg/raw-file/tip/hgwebdir.cgi</ulink>."
7338 msgstr ""
7340 #. type: Content of: <book><chapter><sect1><sect2><para>
7341 #: ../en/ch05-collab.xml:1189
7342 msgid ""
7343 "With basic configuration out of the way, try to visit <ulink url=\"http://"
7344 "myhostname/ myuser/hgwebdir.cgi\">http://myhostname/ myuser/hgwebdir.cgi</"
7345 "ulink> in your browser. It should display an empty list of repositories. If "
7346 "you get a blank window or error message, try walking through the list of "
7347 "potential problems in <xref linkend=\"sec:collab:wtf\"/>."
7348 msgstr ""
7350 #. type: Content of: <book><chapter><sect1><sect2><para>
7351 #: ../en/ch05-collab.xml:1198
7352 msgid ""
7353 "The <filename role=\"special\">hgwebdir.cgi</filename> script relies on an "
7354 "external configuration file. By default, it searches for a file named "
7355 "<filename role=\"special\">hgweb.config</filename> in the same directory as "
7356 "itself. You'll need to create this file, and make it world-readable. The "
7357 "format of the file is similar to a Windows <quote>ini</quote> file, as "
7358 "understood by Python's <literal>ConfigParser</literal> <citation>web:"
7359 "configparser</citation> module."
7360 msgstr ""
7362 #. type: Content of: <book><chapter><sect1><sect2><para>
7363 #: ../en/ch05-collab.xml:1208
7364 msgid ""
7365 "The easiest way to configure <filename role=\"special\">hgwebdir.cgi</"
7366 "filename> is with a section named <literal>collections</literal>. This will "
7367 "automatically publish <emphasis>every</emphasis> repository under the "
7368 "directories you name. The section should look like this:"
7369 msgstr ""
7371 #. type: Content of: <book><chapter><sect1><sect2><para>
7372 #: ../en/ch05-collab.xml:1216
7373 msgid ""
7374 "Mercurial interprets this by looking at the directory name on the "
7375 "<emphasis>right</emphasis> hand side of the <quote><literal>=</literal></"
7376 "quote> sign; finding repositories in that directory hierarchy; and using the "
7377 "text on the <emphasis>left</emphasis> to strip off matching text from the "
7378 "names it will actually list in the web interface. The remaining component of "
7379 "a path after this stripping has occurred is called a <quote>virtual path</"
7380 "quote>."
7381 msgstr ""
7383 #. type: Content of: <book><chapter><sect1><sect2><para>
7384 #: ../en/ch05-collab.xml:1225
7385 msgid ""
7386 "Given the example above, if we have a repository whose local path is "
7387 "<filename class=\"directory\">/my/root/this/repo</filename>, the CGI script "
7388 "will strip the leading <filename class=\"directory\">/my/root</filename> from "
7389 "the name, and publish the repository with a virtual path of <filename class="
7390 "\"directory\">this/repo</filename>. If the base URL for our CGI script is "
7391 "<ulink url=\"http://myhostname/ myuser/hgwebdir.cgi\">http://myhostname/ "
7392 "myuser/hgwebdir.cgi</ulink>, the complete URL for that repository will be "
7393 "<ulink url=\"http://myhostname/ myuser/hgwebdir.cgi/this/repo\">http://"
7394 "myhostname/ myuser/hgwebdir.cgi/this/repo</ulink>."
7395 msgstr ""
7397 #. type: Content of: <book><chapter><sect1><sect2><para>
7398 #: ../en/ch05-collab.xml:1239
7399 msgid ""
7400 "If we replace <filename class=\"directory\">/my/root</filename> on the left "
7401 "hand side of this example with <filename class=\"directory\">/my</filename>, "
7402 "then <filename role=\"special\">hgwebdir.cgi</filename> will only strip off "
7403 "<filename class=\"directory\">/my</filename> from the repository name, and "
7404 "will give us a virtual path of <filename class=\"directory\">root/this/repo</"
7405 "filename> instead of <filename class=\"directory\">this/repo</filename>."
7406 msgstr ""
7408 #. type: Content of: <book><chapter><sect1><sect2><para>
7409 #: ../en/ch05-collab.xml:1249
7410 msgid ""
7411 "The <filename role=\"special\">hgwebdir.cgi</filename> script will "
7412 "recursively search each directory listed in the <literal>collections</"
7413 "literal> section of its configuration file, but it will <literal>not</"
7414 "literal> recurse into the repositories it finds."
7415 msgstr ""
7417 #. type: Content of: <book><chapter><sect1><sect2><para>
7418 #: ../en/ch05-collab.xml:1255
7419 msgid ""
7420 "The <literal>collections</literal> mechanism makes it easy to publish many "
7421 "repositories in a <quote>fire and forget</quote> manner. You only need to "
7422 "set up the CGI script and configuration file one time. Afterwards, you can "
7423 "publish or unpublish a repository at any time by simply moving it into, or "
7424 "out of, the directory hierarchy in which you've configured <filename role="
7425 "\"special\">hgwebdir.cgi</filename> to look."
7426 msgstr ""
7428 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
7429 #: ../en/ch05-collab.xml:1265
7430 msgid "Explicitly specifying which repositories to publish"
7431 msgstr "明确指出要发布的版本库"
7433 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7434 #: ../en/ch05-collab.xml:1268
7435 msgid ""
7436 "In addition to the <literal>collections</literal> mechanism, the <filename "
7437 "role=\"special\">hgwebdir.cgi</filename> script allows you to publish a "
7438 "specific list of repositories. To do so, create a <literal>paths</literal> "
7439 "section, with contents of the following form."
7440 msgstr ""
7442 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7443 #: ../en/ch05-collab.xml:1277
7444 msgid ""
7445 "In this case, the virtual path (the component that will appear in a URL) is "
7446 "on the left hand side of each definition, while the path to the repository is "
7447 "on the right. Notice that there does not need to be any relationship between "
7448 "the virtual path you choose and the location of a repository in your "
7449 "filesystem."
7450 msgstr ""
7452 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7453 #: ../en/ch05-collab.xml:1284
7454 msgid ""
7455 "If you wish, you can use both the <literal>collections</literal> and "
7456 "<literal>paths</literal> mechanisms simultaneously in a single configuration "
7457 "file."
7458 msgstr ""
7460 #. type: Content of: <book><chapter><sect1><sect2><sect3><note><title>
7461 #: ../en/ch05-collab.xml:1290
7462 msgid "Beware duplicate virtual paths"
7463 msgstr ""
7465 #. type: Content of: <book><chapter><sect1><sect2><sect3><note><para>
7466 #: ../en/ch05-collab.xml:1292
7467 msgid ""
7468 "If several repositories have the same virtual path, <filename role=\"special"
7469 "\">hgwebdir.cgi</filename> will not report an error. Instead, it will behave "
7470 "unpredictably."
7471 msgstr ""
7473 #. type: Content of: <book><chapter><sect1><sect2><title>
7474 #: ../en/ch05-collab.xml:1301
7475 msgid "Downloading source archives"
7476 msgstr "下载源代码档案包"
7478 #. type: Content of: <book><chapter><sect1><sect2><para>
7479 #: ../en/ch05-collab.xml:1303
7480 msgid ""
7481 "Mercurial's web interface lets users download an archive of any revision. "
7482 "This archive will contain a snapshot of the working directory as of that "
7483 "revision, but it will not contain a copy of the repository data."
7484 msgstr ""
7486 #. type: Content of: <book><chapter><sect1><sect2><para>
7487 #: ../en/ch05-collab.xml:1308
7488 msgid ""
7489 "By default, this feature is not enabled. To enable it, you'll need to add an "
7490 "<envar role=\"rc-item-web\">allow_archive</envar> item to the <literal role="
7491 "\"rc-web\">web</literal> section of your <filename role=\"special\">~/.hgrc</"
7492 "filename>; see below for details."
7493 msgstr ""
7495 #. type: Content of: <book><chapter><sect1><sect2><title>
7496 #: ../en/ch05-collab.xml:1315
7497 msgid "Web configuration options"
7498 msgstr "Web 配置选项"
7500 #. type: Content of: <book><chapter><sect1><sect2><para>
7501 #: ../en/ch05-collab.xml:1317
7502 msgid ""
7503 "Mercurial's web interfaces (the <command role=\"hg-cmd\">hg serve</command> "
7504 "command, and the <filename role=\"special\">hgweb.cgi</filename> and "
7505 "<filename role=\"special\">hgwebdir.cgi</filename> scripts) have a number of "
7506 "configuration options that you can set. These belong in a section named "
7507 "<literal role=\"rc-web\">web</literal>."
7508 msgstr ""
7510 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
7511 #: ../en/ch05-collab.xml:1325
7512 msgid ""
7513 "<envar role=\"rc-item-web\">allow_archive</envar>: Determines which (if any) "
7514 "archive download mechanisms Mercurial supports. If you enable this feature, "
7515 "users of the web interface will be able to download an archive of whatever "
7516 "revision of a repository they are viewing. To enable the archive feature, "
7517 "this item must take the form of a sequence of words drawn from the list below."
7518 msgstr ""
7520 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
7521 #: ../en/ch05-collab.xml:1334
7522 msgid ""
7523 "<literal>bz2</literal>: A <command>tar</command> archive, compressed using "
7524 "<literal>bzip2</literal> compression. This has the best compression ratio, "
7525 "but uses the most CPU time on the server."
7526 msgstr ""
7528 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
7529 #: ../en/ch05-collab.xml:1340
7530 msgid ""
7531 "<literal>gz</literal>: A <command>tar</command> archive, compressed using "
7532 "<literal>gzip</literal> compression."
7533 msgstr ""
7535 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
7536 #: ../en/ch05-collab.xml:1344
7537 msgid ""
7538 "<literal>zip</literal>: A <command>zip</command> archive, compressed using "
7539 "LZW compression. This format has the worst compression ratio, but is widely "
7540 "used in the Windows world."
7541 msgstr ""
7543 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
7544 #: ../en/ch05-collab.xml:1350
7545 msgid ""
7546 "If you provide an empty list, or don't have an <envar role=\"rc-item-web"
7547 "\">allow_archive</envar> entry at all, this feature will be disabled. Here "
7548 "is an example of how to enable all three supported formats."
7549 msgstr ""
7551 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
7552 #: ../en/ch05-collab.xml:1357
7553 msgid ""
7554 "<envar role=\"rc-item-web\">allowpull</envar>: Boolean. Determines whether "
7555 "the web interface allows remote users to <command role=\"hg-cmd\">hg pull</"
7556 "command> and <command role=\"hg-cmd\">hg clone</command> this repository over "
7557 "HTTP. If set to <literal>no</literal> or <literal>false</literal>, only the "
7558 "<quote>human-oriented</quote> portion of the web interface is available."
7559 msgstr ""
7561 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
7562 #: ../en/ch05-collab.xml:1366
7563 msgid ""
7564 "<envar role=\"rc-item-web\">contact</envar>: String. A free-form (but "
7565 "preferably brief) string identifying the person or group in charge of the "
7566 "repository. This often contains the name and email address of a person or "
7567 "mailing list. It often makes sense to place this entry in a repository's own "
7568 "<filename role=\"special\">.hg/hgrc</filename> file, but it can make sense to "
7569 "use in a global <filename role=\"special\">~/.hgrc</filename> if every "
7570 "repository has a single maintainer."
7571 msgstr ""
7573 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
7574 #: ../en/ch05-collab.xml:1377
7575 msgid ""
7576 "<envar role=\"rc-item-web\">maxchanges</envar>: Integer. The default maximum "
7577 "number of changesets to display in a single page of output."
7578 msgstr ""
7580 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
7581 #: ../en/ch05-collab.xml:1381
7582 msgid ""
7583 "<envar role=\"rc-item-web\">maxfiles</envar>: Integer. The default maximum "
7584 "number of modified files to display in a single page of output."
7585 msgstr ""
7587 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
7588 #: ../en/ch05-collab.xml:1385
7589 msgid ""
7590 "<envar role=\"rc-item-web\">stripes</envar>: Integer. If the web interface "
7591 "displays alternating <quote>stripes</quote> to make it easier to visually "
7592 "align rows when you are looking at a table, this number controls the number "
7593 "of rows in each stripe."
7594 msgstr ""
7596 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
7597 #: ../en/ch05-collab.xml:1391
7598 msgid ""
7599 "<envar role=\"rc-item-web\">style</envar>: Controls the template Mercurial "
7600 "uses to display the web interface. Mercurial ships with several web "
7601 "templates."
7602 msgstr ""
7604 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
7605 #: ../en/ch05-collab.xml:1397
7606 msgid "<literal>coal</literal> is monochromatic."
7607 msgstr ""
7609 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
7610 #: ../en/ch05-collab.xml:1400
7611 msgid ""
7612 "<literal>gitweb</literal> emulates the visual style of git's web interface."
7613 msgstr ""
7615 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
7616 #: ../en/ch05-collab.xml:1404
7617 msgid "<literal>monoblue</literal> uses solid blues and greys."
7618 msgstr ""
7620 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
7621 #: ../en/ch05-collab.xml:1408
7622 msgid "<literal>paper</literal> is the default."
7623 msgstr ""
7625 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
7626 #: ../en/ch05-collab.xml:1411
7627 msgid "<literal>spartan</literal> was the default for a long time."
7628 msgstr ""
7630 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
7631 #: ../en/ch05-collab.xml:1415
7632 msgid ""
7633 "You can also specify a custom template of your own; see <xref linkend=\"chap:"
7634 "template\"/> for details. Here, you can see how to enable the "
7635 "<literal>gitweb</literal> style."
7636 msgstr ""
7638 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
7639 #: ../en/ch05-collab.xml:1423
7640 msgid ""
7641 "<envar role=\"rc-item-web\">templates</envar>: Path. The directory in which "
7642 "to search for template files. By default, Mercurial searches in the "
7643 "directory in which it was installed."
7644 msgstr ""
7646 #. type: Content of: <book><chapter><sect1><sect2><para>
7647 #: ../en/ch05-collab.xml:1428
7648 msgid ""
7649 "If you are using <filename role=\"special\">hgwebdir.cgi</filename>, you can "
7650 "place a few configuration items in a <literal role=\"rc-web\">web</literal> "
7651 "section of the <filename role=\"special\">hgweb.config</filename> file "
7652 "instead of a <filename role=\"special\">~/.hgrc</filename> file, for "
7653 "convenience. These items are <envar role=\"rc-item-web\">motd</envar> and "
7654 "<envar role=\"rc-item-web\">style</envar>."
7655 msgstr ""
7657 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
7658 #: ../en/ch05-collab.xml:1439
7659 msgid "Options specific to an individual repository"
7660 msgstr "针对单个版本库的选项"
7662 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7663 #: ../en/ch05-collab.xml:1441
7664 msgid ""
7665 "A few <literal role=\"rc-web\">web</literal> configuration items ought to be "
7666 "placed in a repository's local <filename role=\"special\">.hg/hgrc</"
7667 "filename>, rather than a user's or global <filename role=\"special\">~/.hgrc</"
7668 "filename>."
7669 msgstr ""
7671 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
7672 #: ../en/ch05-collab.xml:1446
7673 msgid ""
7674 "<envar role=\"rc-item-web\">description</envar>: String. A free-form (but "
7675 "preferably brief) string that describes the contents or purpose of the "
7676 "repository."
7677 msgstr ""
7679 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
7680 #: ../en/ch05-collab.xml:1451
7681 msgid ""
7682 "<envar role=\"rc-item-web\">name</envar>: String. The name to use for the "
7683 "repository in the web interface. This overrides the default name, which is "
7684 "the last component of the repository's path."
7685 msgstr ""
7687 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
7688 #: ../en/ch05-collab.xml:1459
7689 msgid ""
7690 "Options specific to the <command role=\"hg-cmd\">hg serve</command> command"
7691 msgstr "命令 <command role=\"hg-cmd\">hg serve</command> 的选项"
7693 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7694 #: ../en/ch05-collab.xml:1462
7695 msgid ""
7696 "Some of the items in the <literal role=\"rc-web\">web</literal> section of a "
7697 "<filename role=\"special\">~/.hgrc</filename> file are only for use with the "
7698 "<command role=\"hg-cmd\">hg serve</command> command."
7699 msgstr ""
7701 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
7702 #: ../en/ch05-collab.xml:1468
7703 msgid ""
7704 "<envar role=\"rc-item-web\">accesslog</envar>: Path. The name of a file into "
7705 "which to write an access log. By default, the <command role=\"hg-cmd\">hg "
7706 "serve</command> command writes this information to standard output, not to a "
7707 "file. Log entries are written in the standard <quote>combined</quote> file "
7708 "format used by almost all web servers."
7709 msgstr ""
7711 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
7712 #: ../en/ch05-collab.xml:1476
7713 msgid ""
7714 "<envar role=\"rc-item-web\">address</envar>: String. The local address on "
7715 "which the server should listen for incoming connections. By default, the "
7716 "server listens on all addresses."
7717 msgstr ""
7719 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
7720 #: ../en/ch05-collab.xml:1481
7721 msgid ""
7722 "<envar role=\"rc-item-web\">errorlog</envar>: Path. The name of a file into "
7723 "which to write an error log. By default, the <command role=\"hg-cmd\">hg "
7724 "serve</command> command writes this information to standard error, not to a "
7725 "file."
7726 msgstr ""
7728 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
7729 #: ../en/ch05-collab.xml:1487
7730 msgid ""
7731 "<envar role=\"rc-item-web\">ipv6</envar>: Boolean. Whether to use the IPv6 "
7732 "protocol. By default, IPv6 is not used."
7733 msgstr ""
7735 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
7736 #: ../en/ch05-collab.xml:1491
7737 msgid ""
7738 "<envar role=\"rc-item-web\">port</envar>: Integer. The TCP port number on "
7739 "which the server should listen. The default port number used is 8000."
7740 msgstr ""
7742 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
7743 #: ../en/ch05-collab.xml:1498
7744 msgid ""
7745 "Choosing the right <filename role=\"special\">~/.hgrc</filename> file to add "
7746 "<literal role=\"rc-web\">web</literal> items to"
7747 msgstr ""
7748 "选择正确的 <filename role=\"special\"> ~/.hgrc</filename> 文件增加到 <literal "
7749 "role=\"rc-web\">web</literal> 条目"
7751 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7752 #: ../en/ch05-collab.xml:1502
7753 msgid ""
7754 "It is important to remember that a web server like Apache or "
7755 "<literal>lighttpd</literal> will run under a user ID that is different to "
7756 "yours. CGI scripts run by your server, such as <filename role=\"special"
7757 "\">hgweb.cgi</filename>, will usually also run under that user ID."
7758 msgstr ""
7760 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7761 #: ../en/ch05-collab.xml:1509
7762 msgid ""
7763 "If you add <literal role=\"rc-web\">web</literal> items to your own personal "
7764 "<filename role=\"special\">~/.hgrc</filename> file, CGI scripts won't read "
7765 "that <filename role=\"special\">~/.hgrc</filename> file. Those settings will "
7766 "thus only affect the behavior of the <command role=\"hg-cmd\">hg serve</"
7767 "command> command when you run it. To cause CGI scripts to see your settings, "
7768 "either create a <filename role=\"special\">~/.hgrc</filename> file in the "
7769 "home directory of the user ID that runs your web server, or add those "
7770 "settings to a system-wide <filename role=\"special\">hgrc</filename> file."
7771 msgstr ""
7773 #. type: Content of: <book><chapter><sect1><title>
7774 #: ../en/ch05-collab.xml:1524
7775 #, fuzzy
7776 msgid "System-wide configuration"
7777 msgstr "基本 CGI 配置"
7779 #. type: Content of: <book><chapter><sect1><para>
7780 #: ../en/ch05-collab.xml:1526
7781 msgid ""
7782 "On Unix-like systems shared by multiple users (such as a server to which "
7783 "people publish changes), it often makes sense to set up some global default "
7784 "behaviors, such as what theme to use in web interfaces."
7785 msgstr ""
7787 #. type: Content of: <book><chapter><sect1><para>
7788 #: ../en/ch05-collab.xml:1531
7789 msgid ""
7790 "If a file named <filename>/etc/mercurial/hgrc</filename> exists, Mercurial "
7791 "will read it at startup time and apply any configuration settings it finds in "
7792 "that file. It will also look for files ending in a <literal>.rc</literal> "
7793 "extension in a directory named <filename>/etc/mercurial/hgrc.d</filename>, "
7794 "and apply any configuration settings it finds in each of those files."
7795 msgstr ""
7797 #. type: Content of: <book><chapter><sect1><sect2><title>
7798 #: ../en/ch05-collab.xml:1540
7799 #, fuzzy
7800 msgid "Making Mercurial more trusting"
7801 msgstr "安装 Mercurial"
7803 #. type: Content of: <book><chapter><sect1><sect2><para>
7804 #: ../en/ch05-collab.xml:1542
7805 msgid ""
7806 "One situation in which a global <filename>hgrc</filename> can be useful is if "
7807 "users are pulling changes owned by other users. By default, Mercurial will "
7808 "not trust most of the configuration items in a <filename>.hg/hgrc</filename> "
7809 "file inside a repository that is owned by a different user. If we clone or "
7810 "pull changes from such a repository, Mercurial will print a warning stating "
7811 "that it does not trust their <filename>.hg/hgrc</filename>."
7812 msgstr ""
7814 #. type: Content of: <book><chapter><sect1><sect2><para>
7815 #: ../en/ch05-collab.xml:1551
7816 msgid ""
7817 "If everyone in a particular Unix group is on the same team and "
7818 "<emphasis>should</emphasis> trust each other's configuration settings, or we "
7819 "want to trust particular users, we can override Mercurial's skeptical "
7820 "defaults by creating a system-wide <filename>hgrc</filename> file such as the "
7821 "following:"
7822 msgstr ""
7824 #. type: Content of: <book><chapter><title>
7825 #: ../en/ch06-filenames.xml:5
7826 msgid "File names and pattern matching"
7827 msgstr "文件名称与模式匹配"
7829 #. type: Content of: <book><chapter><para>
7830 #: ../en/ch06-filenames.xml:7
7831 msgid ""
7832 "Mercurial provides mechanisms that let you work with file names in a "
7833 "consistent and expressive way."
7834 msgstr ""
7836 #. type: Content of: <book><chapter><sect1><title>
7837 #: ../en/ch06-filenames.xml:11
7838 msgid "Simple file naming"
7839 msgstr "简单文件名称"
7841 #. type: Content of: <book><chapter><sect1><para>
7842 #: ../en/ch06-filenames.xml:13
7843 msgid ""
7844 "Mercurial uses a unified piece of machinery <quote>under the hood</quote> to "
7845 "handle file names. Every command behaves uniformly with respect to file "
7846 "names. The way in which commands work with file names is as follows."
7847 msgstr ""
7849 #. type: Content of: <book><chapter><sect1><para>
7850 #: ../en/ch06-filenames.xml:18
7851 msgid ""
7852 "If you explicitly name real files on the command line, Mercurial works with "
7853 "exactly those files, as you would expect. &interaction.filenames.files;"
7854 msgstr ""
7857 #. type: Content of: <book><chapter><sect1><para>
7858 #: ../en/ch06-filenames.xml:22
7859 msgid ""
7860 "When you provide a directory name, Mercurial will interpret this as "
7861 "<quote>operate on every file in this directory and its subdirectories</"
7862 "quote>. Mercurial traverses the files and subdirectories in a directory in "
7863 "alphabetical order. When it encounters a subdirectory, it will traverse that "
7864 "subdirectory before continuing with the current directory."
7865 msgstr ""
7867 #. type: Content of: <book><chapter><sect1><title>
7868 #: ../en/ch06-filenames.xml:33
7869 msgid "Running commands without any file names"
7870 msgstr "不提供文件名称的执行命令"
7872 #. type: Content of: <book><chapter><sect1><para>
7873 #: ../en/ch06-filenames.xml:35
7874 msgid ""
7875 "Mercurial's commands that work with file names have useful default behaviors "
7876 "when you invoke them without providing any file names or patterns. What kind "
7877 "of behavior you should expect depends on what the command does. Here are a "
7878 "few rules of thumb you can use to predict what a command is likely to do if "
7879 "you don't give it any names to work with."
7880 msgstr ""
7882 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
7883 #: ../en/ch06-filenames.xml:42
7884 msgid ""
7885 "Most commands will operate on the entire working directory. This is what the "
7886 "<command role=\"hg-cmd\">hg add</command> command does, for example."
7887 msgstr ""
7889 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
7890 #: ../en/ch06-filenames.xml:46
7891 msgid ""
7892 "If the command has effects that are difficult or impossible to reverse, it "
7893 "will force you to explicitly provide at least one name or pattern (see "
7894 "below). This protects you from accidentally deleting files by running "
7895 "<command role=\"hg-cmd\">hg remove</command> with no arguments, for example."
7896 msgstr ""
7898 #. type: Content of: <book><chapter><sect1><para>
7899 #: ../en/ch06-filenames.xml:54
7900 msgid ""
7901 "It's easy to work around these default behaviors if they don't suit you. If "
7902 "a command normally operates on the whole working directory, you can invoke it "
7903 "on just the current directory and its subdirectories by giving it the name "
7904 "<quote><filename class=\"directory\">.</filename></quote>."
7905 msgstr ""
7908 #. type: Content of: <book><chapter><sect1><para>
7909 #: ../en/ch06-filenames.xml:62
7910 msgid ""
7911 "Along the same lines, some commands normally print file names relative to the "
7912 "root of the repository, even if you're invoking them from a subdirectory. "
7913 "Such a command will print file names relative to your subdirectory if you "
7914 "give it explicit names. Here, we're going to run <command role=\"hg-cmd\">hg "
7915 "status</command> from a subdirectory, and get it to operate on the entire "
7916 "working directory while printing file names relative to our subdirectory, by "
7917 "passing it the output of the <command role=\"hg-cmd\">hg root</command> "
7918 "command."
7919 msgstr ""
7921 #. type: Content of: <book><chapter><sect1><title>
7922 #: ../en/ch06-filenames.xml:76
7923 msgid "Telling you what's going on"
7924 msgstr "告诉你正在做什么"
7926 #. type: Content of: <book><chapter><sect1><para>
7927 #: ../en/ch06-filenames.xml:78
7928 msgid ""
7929 "The <command role=\"hg-cmd\">hg add</command> example in the preceding "
7930 "section illustrates something else that's helpful about Mercurial commands. "
7931 "If a command operates on a file that you didn't name explicitly on the "
7932 "command line, it will usually print the name of the file, so that you will "
7933 "not be surprised what's going on."
7934 msgstr ""
7936 #. type: Content of: <book><chapter><sect1><para>
7937 #: ../en/ch06-filenames.xml:85
7938 msgid ""
7939 "The principle here is of <emphasis>least surprise</emphasis>. If you've "
7940 "exactly named a file on the command line, there's no point in repeating it "
7941 "back at you. If Mercurial is acting on a file <emphasis>implicitly</"
7942 "emphasis>, e.g. because you provided no names, or a directory, or a pattern "
7943 "(see below), it is safest to tell you what files it's operating on."
7944 msgstr ""
7946 #. type: Content of: <book><chapter><sect1><para>
7947 #: ../en/ch06-filenames.xml:92
7948 msgid ""
7949 "For commands that behave this way, you can silence them using the <option "
7950 "role=\"hg-opt-global\">-q</option> option. You can also get them to print "
7951 "the name of every file, even those you've named explicitly, using the <option "
7952 "role=\"hg-opt-global\">-v</option> option."
7953 msgstr ""
7955 #. type: Content of: <book><chapter><sect1><title>
7956 #: ../en/ch06-filenames.xml:100
7957 msgid "Using patterns to identify files"
7958 msgstr "使用模式标识文件"
7960 #. type: Content of: <book><chapter><sect1><para>
7961 #: ../en/ch06-filenames.xml:102
7962 msgid ""
7963 "In addition to working with file and directory names, Mercurial lets you use "
7964 "<emphasis>patterns</emphasis> to identify files. Mercurial's pattern "
7965 "handling is expressive."
7966 msgstr ""
7968 #. type: Content of: <book><chapter><sect1><para>
7969 #: ../en/ch06-filenames.xml:106
7970 msgid ""
7971 "On Unix-like systems (Linux, MacOS, etc.), the job of matching file names to "
7972 "patterns normally falls to the shell. On these systems, you must explicitly "
7973 "tell Mercurial that a name is a pattern. On Windows, the shell does not "
7974 "expand patterns, so Mercurial will automatically identify names that are "
7975 "patterns, and expand them for you."
7976 msgstr ""
7978 #. type: Content of: <book><chapter><sect1><para>
7979 #: ../en/ch06-filenames.xml:113
7980 msgid ""
7981 "To provide a pattern in place of a regular name on the command line, the "
7982 "mechanism is simple:"
7983 msgstr ""
7985 #. type: Content of: <book><chapter><sect1><para>
7986 #: ../en/ch06-filenames.xml:116
7987 msgid ""
7988 "That is, a pattern is identified by a short text string that says what kind "
7989 "of pattern this is, followed by a colon, followed by the actual pattern."
7990 msgstr ""
7992 #. type: Content of: <book><chapter><sect1><para>
7993 #: ../en/ch06-filenames.xml:120
7994 msgid ""
7995 "Mercurial supports two kinds of pattern syntax. The most frequently used is "
7996 "called <literal>glob</literal>; this is the same kind of pattern matching "
7997 "used by the Unix shell, and should be familiar to Windows command prompt "
7998 "users, too."
7999 msgstr ""
8001 #. type: Content of: <book><chapter><sect1><para>
8002 #: ../en/ch06-filenames.xml:125
8003 msgid ""
8004 "When Mercurial does automatic pattern matching on Windows, it uses "
8005 "<literal>glob</literal> syntax. You can thus omit the <quote><literal>glob:</"
8006 "literal></quote> prefix on Windows, but it's safe to use it, too."
8007 msgstr ""
8009 #. type: Content of: <book><chapter><sect1><para>
8010 #: ../en/ch06-filenames.xml:130
8011 msgid ""
8012 "The <literal>re</literal> syntax is more powerful; it lets you specify "
8013 "patterns using regular expressions, also known as regexps."
8014 msgstr ""
8016 #. type: Content of: <book><chapter><sect1><para>
8017 #: ../en/ch06-filenames.xml:134
8018 msgid ""
8019 "By the way, in the examples that follow, notice that I'm careful to wrap all "
8020 "of my patterns in quote characters, so that they won't get expanded by the "
8021 "shell before Mercurial sees them."
8022 msgstr ""
8024 #. type: Content of: <book><chapter><sect1><sect2><title>
8025 #: ../en/ch06-filenames.xml:140
8026 msgid "Shell-style <literal>glob</literal> patterns"
8027 msgstr "外壳风格的 <literal>glob</literal> 模式"
8029 #. type: Content of: <book><chapter><sect1><sect2><para>
8030 #: ../en/ch06-filenames.xml:142
8031 msgid ""
8032 "This is an overview of the kinds of patterns you can use when you're matching "
8033 "on glob patterns."
8034 msgstr ""
8037 #. type: Content of: <book><chapter><sect1><sect2><para>
8038 #: ../en/ch06-filenames.xml:145
8039 msgid ""
8040 "The <quote><literal>*</literal></quote> character matches any string, within "
8041 "a single directory."
8042 msgstr ""
8045 #. type: Content of: <book><chapter><sect1><sect2><para>
8046 #: ../en/ch06-filenames.xml:150
8047 msgid ""
8048 "The <quote><literal>**</literal></quote> pattern matches any string, and "
8049 "crosses directory boundaries. It's not a standard Unix glob token, but it's "
8050 "accepted by several popular Unix shells, and is very useful."
8051 msgstr ""
8054 #. type: Content of: <book><chapter><sect1><sect2><para>
8055 #: ../en/ch06-filenames.xml:157
8056 msgid ""
8057 "The <quote><literal>?</literal></quote> pattern matches any single character."
8058 msgstr ""
8060 #. type: Content of: <book><chapter><sect1><sect2><para>
8061 #: ../en/ch06-filenames.xml:162
8062 msgid ""
8063 "The <quote><literal>[</literal></quote> character begins a "
8064 "<emphasis>character class</emphasis>. This matches any single character "
8065 "within the class. The class ends with a <quote><literal>]</literal></quote> "
8066 "character. A class may contain multiple <emphasis>range</emphasis>s of the "
8067 "form <quote><literal>a-f</literal></quote>, which is shorthand for "
8068 "<quote><literal>abcdef</literal></quote>."
8069 msgstr ""
8071 #. type: Content of: <book><chapter><sect1><sect2><para>
8072 #: ../en/ch06-filenames.xml:172
8073 msgid ""
8074 "If the first character after the <quote><literal>[</literal></quote> in a "
8075 "character class is a <quote><literal>!</literal></quote>, it "
8076 "<emphasis>negates</emphasis> the class, making it match any single character "
8077 "not in the class."
8078 msgstr ""
8080 #. type: Content of: <book><chapter><sect1><sect2><para>
8081 #: ../en/ch06-filenames.xml:178
8082 msgid ""
8083 "A <quote><literal>{</literal></quote> begins a group of subpatterns, where "
8084 "the whole group matches if any subpattern in the group matches. The "
8085 "<quote><literal>,</literal></quote> character separates subpatterns, and "
8086 "<quote><literal>}</literal></quote> ends the group."
8087 msgstr ""
8089 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
8090 #: ../en/ch06-filenames.xml:187
8091 msgid "Watch out!"
8092 msgstr "千万小心!"
8095 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
8096 #: ../en/ch06-filenames.xml:189
8097 msgid ""
8098 "Don't forget that if you want to match a pattern in any directory, you should "
8099 "not be using the <quote><literal>*</literal></quote> match-any token, as this "
8100 "will only match within one directory. Instead, use the <quote><literal>**</"
8101 "literal></quote> token. This small example illustrates the difference "
8102 "between the two."
8103 msgstr ""
8105 #. type: Content of: <book><chapter><sect1><sect2><title>
8106 #: ../en/ch06-filenames.xml:201
8107 msgid "Regular expression matching with <literal>re</literal> patterns"
8108 msgstr "使用 <literal>re</literal> 模式的正则表达式匹配"
8110 #. type: Content of: <book><chapter><sect1><sect2><para>
8111 #: ../en/ch06-filenames.xml:204
8112 msgid ""
8113 "Mercurial accepts the same regular expression syntax as the Python "
8114 "programming language (it uses Python's regexp engine internally). This is "
8115 "based on the Perl language's regexp syntax, which is the most popular dialect "
8116 "in use (it's also used in Java, for example)."
8117 msgstr ""
8119 #. type: Content of: <book><chapter><sect1><sect2><para>
8120 #: ../en/ch06-filenames.xml:210
8121 msgid ""
8122 "I won't discuss Mercurial's regexp dialect in any detail here, as regexps are "
8123 "not often used. Perl-style regexps are in any case already exhaustively "
8124 "documented on a multitude of web sites, and in many books. Instead, I will "
8125 "focus here on a few things you should know if you find yourself needing to "
8126 "use regexps with Mercurial."
8127 msgstr ""
8129 #. type: Content of: <book><chapter><sect1><sect2><para>
8130 #: ../en/ch06-filenames.xml:217
8131 msgid ""
8132 "A regexp is matched against an entire file name, relative to the root of the "
8133 "repository. In other words, even if you're already in subbdirectory "
8134 "<filename class=\"directory\">foo</filename>, if you want to match files "
8135 "under this directory, your pattern must start with <quote><literal>foo/</"
8136 "literal></quote>."
8137 msgstr ""
8139 #. type: Content of: <book><chapter><sect1><sect2><para>
8140 #: ../en/ch06-filenames.xml:224
8141 msgid ""
8142 "One thing to note, if you're familiar with Perl-style regexps, is that "
8143 "Mercurial's are <emphasis>rooted</emphasis>. That is, a regexp starts "
8144 "matching against the beginning of a string; it doesn't look for a match "
8145 "anywhere within the string. To match anywhere in a string, start your "
8146 "pattern with <quote><literal>.*</literal></quote>."
8147 msgstr ""
8149 #. type: Content of: <book><chapter><sect1><title>
8150 #: ../en/ch06-filenames.xml:234
8151 msgid "Filtering files"
8152 msgstr "过滤文件"
8154 #. type: Content of: <book><chapter><sect1><para>
8155 #: ../en/ch06-filenames.xml:236
8156 msgid ""
8157 "Not only does Mercurial give you a variety of ways to specify files; it lets "
8158 "you further winnow those files using <emphasis>filters</emphasis>. Commands "
8159 "that work with file names accept two filtering options."
8160 msgstr ""
8162 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8163 #: ../en/ch06-filenames.xml:241
8164 msgid ""
8165 "<option role=\"hg-opt-global\">-I</option>, or <option role=\"hg-opt-global"
8166 "\">--include</option>, lets you specify a pattern that file names must match "
8167 "in order to be processed."
8168 msgstr ""
8170 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8171 #: ../en/ch06-filenames.xml:246
8172 msgid ""
8173 "<option role=\"hg-opt-global\">-X</option>, or <option role=\"hg-opt-global"
8174 "\">--exclude</option>, gives you a way to <emphasis>avoid</emphasis> "
8175 "processing files, if they match this pattern."
8176 msgstr ""
8178 #. type: Content of: <book><chapter><sect1><para>
8179 #: ../en/ch06-filenames.xml:251
8180 msgid ""
8181 "You can provide multiple <option role=\"hg-opt-global\">-I</option> and "
8182 "<option role=\"hg-opt-global\">-X</option> options on the command line, and "
8183 "intermix them as you please. Mercurial interprets the patterns you provide "
8184 "using glob syntax by default (but you can use regexps if you need to)."
8185 msgstr ""
8187 #. type: Content of: <book><chapter><sect1><para>
8188 #: ../en/ch06-filenames.xml:258
8189 msgid ""
8190 "You can read a <option role=\"hg-opt-global\">-I</option> filter as "
8191 "<quote>process only the files that match this filter</quote>."
8192 msgstr ""
8194 #. type: Content of: <book><chapter><sect1><para>
8195 #: ../en/ch06-filenames.xml:264
8196 msgid ""
8197 "The <option role=\"hg-opt-global\">-X</option> filter is best read as "
8198 "<quote>process only the files that don't match this pattern</quote>."
8199 msgstr ""
8201 #. type: Content of: <book><chapter><sect1><title>
8202 #: ../en/ch06-filenames.xml:272
8203 #, fuzzy
8204 msgid "Permanently ignoring unwanted files and directories"
8205 msgstr "忽略不需要的文件和目录"
8207 #. type: Content of: <book><chapter><sect1><para>
8208 #: ../en/ch06-filenames.xml:274
8209 msgid ""
8210 "When you create a new repository, the chances are that over time it will grow "
8211 "to contain files that ought to <emphasis>not</emphasis> be managed by "
8212 "Mercurial, but which you don't want to see listed every time you run "
8213 "<command>hg status</command>. For instance, <quote>build products</quote> "
8214 "are files that are created as part of a build but which should not be managed "
8215 "by a revision control system. The most common build products are output "
8216 "files produced by software tools such as compilers. As another example, many "
8217 "text editors litter a directory with lock files, temporary working files, and "
8218 "backup files, which it also makes no sense to manage."
8219 msgstr ""
8221 #. type: Content of: <book><chapter><sect1><para>
8222 #: ../en/ch06-filenames.xml:286
8223 msgid ""
8224 "To have Mercurial permanently ignore such files, create a file named "
8225 "<filename>.hgignore</filename> in the root of your repository. You "
8226 "<emphasis>should</emphasis> <command>hg add</command> this file so that it "
8227 "gets tracked with the rest of your repository contents, since your "
8228 "collaborators will probably find it useful too."
8229 msgstr ""
8231 #. type: Content of: <book><chapter><sect1><para>
8232 #: ../en/ch06-filenames.xml:293
8233 msgid ""
8234 "By default, the <filename>.hgignore</filename> file should contain a list of "
8235 "regular expressions, one per line. Empty lines are skipped. Most people "
8236 "prefer to describe the files they want to ignore using the <quote>glob</"
8237 "quote> syntax that we described above, so a typical <filename>.hgignore</"
8238 "filename> file will start with this directive:"
8239 msgstr ""
8241 #. type: Content of: <book><chapter><sect1><para>
8242 #: ../en/ch06-filenames.xml:302
8243 msgid ""
8244 "This tells Mercurial to interpret the lines that follow as glob patterns, not "
8245 "regular expressions."
8246 msgstr ""
8248 #. type: Content of: <book><chapter><sect1><para>
8249 #: ../en/ch06-filenames.xml:305
8250 msgid "Here is a typical-looking <filename>.hgignore</filename> file."
8251 msgstr ""
8253 #. type: Content of: <book><chapter><sect1><title>
8254 #: ../en/ch06-filenames.xml:329
8255 msgid "Case sensitivity"
8256 msgstr "大小写敏感性"
8258 #. type: Content of: <book><chapter><sect1><para>
8259 #: ../en/ch06-filenames.xml:331
8260 msgid ""
8261 "If you're working in a mixed development environment that contains both Linux "
8262 "(or other Unix) systems and Macs or Windows systems, you should keep in the "
8263 "back of your mind the knowledge that they treat the case (<quote>N</quote> "
8264 "versus <quote>n</quote>) of file names in incompatible ways. This is not "
8265 "very likely to affect you, and it's easy to deal with if it does, but it "
8266 "could surprise you if you don't know about it."
8267 msgstr ""
8269 #. type: Content of: <book><chapter><sect1><para>
8270 #: ../en/ch06-filenames.xml:340
8271 msgid ""
8272 "Operating systems and filesystems differ in the way they handle the "
8273 "<emphasis>case</emphasis> of characters in file and directory names. There "
8274 "are three common ways to handle case in names."
8275 msgstr ""
8277 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8278 #: ../en/ch06-filenames.xml:345
8279 msgid ""
8280 "Completely case insensitive. Uppercase and lowercase versions of a letter "
8281 "are treated as identical, both when creating a file and during subsequent "
8282 "accesses. This is common on older DOS-based systems."
8283 msgstr ""
8285 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8286 #: ../en/ch06-filenames.xml:350
8287 msgid ""
8288 "Case preserving, but insensitive. When a file or directory is created, the "
8289 "case of its name is stored, and can be retrieved and displayed by the "
8290 "operating system. When an existing file is being looked up, its case is "
8291 "ignored. This is the standard arrangement on Windows and MacOS. The names "
8292 "<filename>foo</filename> and <filename>FoO</filename> identify the same "
8293 "file. This treatment of uppercase and lowercase letters as interchangeable "
8294 "is also referred to as <emphasis>case folding</emphasis>."
8295 msgstr ""
8297 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8298 #: ../en/ch06-filenames.xml:361
8299 msgid ""
8300 "Case sensitive. The case of a name is significant at all times. The names "
8301 "<filename>foo</filename> and {FoO} identify different files. This is the way "
8302 "Linux and Unix systems normally work."
8303 msgstr ""
8305 #. type: Content of: <book><chapter><sect1><para>
8306 #: ../en/ch06-filenames.xml:367
8307 msgid ""
8308 "On Unix-like systems, it is possible to have any or all of the above ways of "
8309 "handling case in action at once. For example, if you use a USB thumb drive "
8310 "formatted with a FAT32 filesystem on a Linux system, Linux will handle names "
8311 "on that filesystem in a case preserving, but insensitive, way."
8312 msgstr ""
8314 #. type: Content of: <book><chapter><sect1><sect2><title>
8315 #: ../en/ch06-filenames.xml:374
8316 msgid "Safe, portable repository storage"
8317 msgstr "安全,可移植的版本库存储"
8319 #. type: Content of: <book><chapter><sect1><sect2><para>
8320 #: ../en/ch06-filenames.xml:376
8321 msgid ""
8322 "Mercurial's repository storage mechanism is <emphasis>case safe</emphasis>. "
8323 "It translates file names so that they can be safely stored on both case "
8324 "sensitive and case insensitive filesystems. This means that you can use "
8325 "normal file copying tools to transfer a Mercurial repository onto, for "
8326 "example, a USB thumb drive, and safely move that drive and repository back "
8327 "and forth between a Mac, a PC running Windows, and a Linux box."
8328 msgstr ""
8330 #. type: Content of: <book><chapter><sect1><sect2><title>
8331 #: ../en/ch06-filenames.xml:387
8332 msgid "Detecting case conflicts"
8333 msgstr "检测大小写冲突"
8335 #. type: Content of: <book><chapter><sect1><sect2><para>
8336 #: ../en/ch06-filenames.xml:389
8337 msgid ""
8338 "When operating in the working directory, Mercurial honours the naming policy "
8339 "of the filesystem where the working directory is located. If the filesystem "
8340 "is case preserving, but insensitive, Mercurial will treat names that differ "
8341 "only in case as the same."
8342 msgstr ""
8344 #. type: Content of: <book><chapter><sect1><sect2><para>
8345 #: ../en/ch06-filenames.xml:395
8346 msgid ""
8347 "An important aspect of this approach is that it is possible to commit a "
8348 "changeset on a case sensitive (typically Linux or Unix) filesystem that will "
8349 "cause trouble for users on case insensitive (usually Windows and MacOS) "
8350 "users. If a Linux user commits changes to two files, one named "
8351 "<filename>myfile.c</filename> and the other named <filename>MyFile.C</"
8352 "filename>, they will be stored correctly in the repository. And in the "
8353 "working directories of other Linux users, they will be correctly represented "
8354 "as separate files."
8355 msgstr ""
8357 #. type: Content of: <book><chapter><sect1><sect2><para>
8358 #: ../en/ch06-filenames.xml:406
8359 msgid ""
8360 "If a Windows or Mac user pulls this change, they will not initially have a "
8361 "problem, because Mercurial's repository storage mechanism is case safe. "
8362 "However, once they try to <command role=\"hg-cmd\">hg update</command> the "
8363 "working directory to that changeset, or <command role=\"hg-cmd\">hg merge</"
8364 "command> with that changeset, Mercurial will spot the conflict between the "
8365 "two file names that the filesystem would treat as the same, and forbid the "
8366 "update or merge from occurring."
8367 msgstr ""
8369 #. type: Content of: <book><chapter><sect1><sect2><title>
8370 #: ../en/ch06-filenames.xml:418
8371 msgid "Fixing a case conflict"
8372 msgstr "修正大小写冲突"
8374 #. type: Content of: <book><chapter><sect1><sect2><para>
8375 #: ../en/ch06-filenames.xml:420
8376 msgid ""
8377 "If you are using Windows or a Mac in a mixed environment where some of your "
8378 "collaborators are using Linux or Unix, and Mercurial reports a case folding "
8379 "conflict when you try to <command role=\"hg-cmd\">hg update</command> or "
8380 "<command role=\"hg-cmd\">hg merge</command>, the procedure to fix the problem "
8381 "is simple."
8382 msgstr ""
8384 #. type: Content of: <book><chapter><sect1><sect2><para>
8385 #: ../en/ch06-filenames.xml:427
8386 msgid ""
8387 "Just find a nearby Linux or Unix box, clone the problem repository onto it, "
8388 "and use Mercurial's <command role=\"hg-cmd\">hg rename</command> command to "
8389 "change the names of any offending files or directories so that they will no "
8390 "longer cause case folding conflicts. Commit this change, <command role=\"hg-"
8391 "cmd\">hg pull</command> or <command role=\"hg-cmd\">hg push</command> it "
8392 "across to your Windows or MacOS system, and <command role=\"hg-cmd\">hg "
8393 "update</command> to the revision with the non-conflicting names."
8394 msgstr ""
8396 #. type: Content of: <book><chapter><sect1><sect2><para>
8397 #: ../en/ch06-filenames.xml:437
8398 msgid ""
8399 "The changeset with case-conflicting names will remain in your project's "
8400 "history, and you still won't be able to <command role=\"hg-cmd\">hg update</"
8401 "command> your working directory to that changeset on a Windows or MacOS "
8402 "system, but you can continue development unimpeded."
8403 msgstr ""
8405 #. type: Content of: <book><chapter><title>
8406 #: ../en/ch07-branch.xml:5
8407 msgid "Managing releases and branchy development"
8408 msgstr "发布管理与分支开发"
8410 #. type: Content of: <book><chapter><para>
8411 #: ../en/ch07-branch.xml:7
8412 msgid ""
8413 "Mercurial provides several mechanisms for you to manage a project that is "
8414 "making progress on multiple fronts at once. To understand these mechanisms, "
8415 "let's first take a brief look at a fairly normal software project structure."
8416 msgstr ""
8418 #. type: Content of: <book><chapter><para>
8419 #: ../en/ch07-branch.xml:12
8420 msgid ""
8421 "Many software projects issue periodic <quote>major</quote> releases that "
8422 "contain substantial new features. In parallel, they may issue <quote>minor</"
8423 "quote> releases. These are usually identical to the major releases off which "
8424 "they're based, but with a few bugs fixed."
8425 msgstr ""
8427 #. type: Content of: <book><chapter><para>
8428 #: ../en/ch07-branch.xml:18
8429 msgid ""
8430 "In this chapter, we'll start by talking about how to keep records of project "
8431 "milestones such as releases. We'll then continue on to talk about the flow "
8432 "of work between different phases of a project, and how Mercurial can help you "
8433 "to isolate and manage this work."
8434 msgstr ""
8436 #. type: Content of: <book><chapter><sect1><title>
8437 #: ../en/ch07-branch.xml:25
8438 msgid "Giving a persistent name to a revision"
8439 msgstr "给版本指定一个永久的名称"
8441 #. type: Content of: <book><chapter><sect1><para>
8442 #: ../en/ch07-branch.xml:27
8443 msgid ""
8444 "Once you decide that you'd like to call a particular revision a "
8445 "<quote>release</quote>, it's a good idea to record the identity of that "
8446 "revision. This will let you reproduce that release at a later date, for "
8447 "whatever purpose you might need at the time (reproducing a bug, porting to a "
8448 "new platform, etc). &interaction.tag.init;"
8449 msgstr ""
8452 #. type: Content of: <book><chapter><sect1><para>
8453 #: ../en/ch07-branch.xml:34
8454 msgid ""
8455 "Mercurial lets you give a permanent name to any revision using the <command "
8456 "role=\"hg-cmd\">hg tag</command> command. Not surprisingly, these names are "
8457 "called <quote>tags</quote>."
8458 msgstr ""
8460 #. type: Content of: <book><chapter><sect1><para>
8461 #: ../en/ch07-branch.xml:40
8462 msgid ""
8463 "A tag is nothing more than a <quote>symbolic name</quote> for a revision. "
8464 "Tags exist purely for your convenience, so that you have a handy permanent "
8465 "way to refer to a revision; Mercurial doesn't interpret the tag names you use "
8466 "in any way. Neither does Mercurial place any restrictions on the name of a "
8467 "tag, beyond a few that are necessary to ensure that a tag can be parsed "
8468 "unambiguously. A tag name cannot contain any of the following characters:"
8469 msgstr ""
8471 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8472 #: ../en/ch07-branch.xml:49
8473 msgid "Colon (ASCII 58, <quote><literal>:</literal></quote>)"
8474 msgstr ""
8476 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8477 #: ../en/ch07-branch.xml:52
8478 msgid "Carriage return (ASCII 13, <quote><literal>\\r</literal></quote>)"
8479 msgstr ""
8481 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8482 #: ../en/ch07-branch.xml:55
8483 msgid "Newline (ASCII 10, <quote><literal>\\n</literal></quote>)"
8484 msgstr ""
8486 #. type: Content of: <book><chapter><sect1><para>
8487 #: ../en/ch07-branch.xml:59
8488 msgid ""
8489 "You can use the <command role=\"hg-cmd\">hg tags</command> command to display "
8490 "the tags present in your repository. In the output, each tagged revision is "
8491 "identified first by its name, then by revision number, and finally by the "
8492 "unique hash of the revision."
8493 msgstr ""
8495 #. type: Content of: <book><chapter><sect1><para>
8496 #: ../en/ch07-branch.xml:67
8497 msgid ""
8498 "Notice that <literal>tip</literal> is listed in the output of <command role="
8499 "\"hg-cmd\">hg tags</command>. The <literal>tip</literal> tag is a special "
8500 "<quote>floating</quote> tag, which always identifies the newest revision in "
8501 "the repository."
8502 msgstr ""
8504 #. type: Content of: <book><chapter><sect1><para>
8505 #: ../en/ch07-branch.xml:73
8506 msgid ""
8507 "In the output of the <command role=\"hg-cmd\">hg tags</command> command, tags "
8508 "are listed in reverse order, by revision number. This usually means that "
8509 "recent tags are listed before older tags. It also means that <literal>tip</"
8510 "literal> is always going to be the first tag listed in the output of <command "
8511 "role=\"hg-cmd\">hg tags</command>."
8512 msgstr ""
8514 #. type: Content of: <book><chapter><sect1><para>
8515 #: ../en/ch07-branch.xml:80
8516 msgid ""
8517 "When you run <command role=\"hg-cmd\">hg log</command>, if it displays a "
8518 "revision that has tags associated with it, it will print those tags."
8519 msgstr ""
8522 #. type: Content of: <book><chapter><sect1><para>
8523 #: ../en/ch07-branch.xml:86
8524 msgid ""
8525 "Any time you need to provide a revision ID to a Mercurial command, the "
8526 "command will accept a tag name in its place. Internally, Mercurial will "
8527 "translate your tag name into the corresponding revision ID, then use that."
8528 msgstr ""
8530 #. type: Content of: <book><chapter><sect1><para>
8531 #: ../en/ch07-branch.xml:93
8532 msgid ""
8533 "There's no limit on the number of tags you can have in a repository, or on "
8534 "the number of tags that a single revision can have. As a practical matter, "
8535 "it's not a great idea to have <quote>too many</quote> (a number which will "
8536 "vary from project to project), simply because tags are supposed to help you "
8537 "to find revisions. If you have lots of tags, the ease of using them to "
8538 "identify revisions diminishes rapidly."
8539 msgstr ""
8541 #. type: Content of: <book><chapter><sect1><para>
8542 #: ../en/ch07-branch.xml:101
8543 msgid ""
8544 "For example, if your project has milestones as frequent as every few days, "
8545 "it's perfectly reasonable to tag each one of those. But if you have a "
8546 "continuous build system that makes sure every revision can be built cleanly, "
8547 "you'd be introducing a lot of noise if you were to tag every clean build. "
8548 "Instead, you could tag failed builds (on the assumption that they're rare!), "
8549 "or simply not use tags to track buildability."
8550 msgstr ""
8552 #. type: Content of: <book><chapter><sect1><para>
8553 #: ../en/ch07-branch.xml:109
8554 msgid ""
8555 "If you want to remove a tag that you no longer want, use <command role=\"hg-"
8556 "cmd\">hg tag --remove</command>."
8557 msgstr ""
8559 #. type: Content of: <book><chapter><sect1><para>
8560 #: ../en/ch07-branch.xml:114
8561 msgid ""
8562 "You can also modify a tag at any time, so that it identifies a different "
8563 "revision, by simply issuing a new <command role=\"hg-cmd\">hg tag</command> "
8564 "command. You'll have to use the <option role=\"hg-opt-tag\">-f</option> "
8565 "option to tell Mercurial that you <emphasis>really</emphasis> want to update "
8566 "the tag."
8567 msgstr ""
8569 #. type: Content of: <book><chapter><sect1><para>
8570 #: ../en/ch07-branch.xml:123
8571 msgid ""
8572 "There will still be a permanent record of the previous identity of the tag, "
8573 "but Mercurial will no longer use it. There's thus no penalty to tagging the "
8574 "wrong revision; all you have to do is turn around and tag the correct "
8575 "revision once you discover your error."
8576 msgstr ""
8578 #. type: Content of: <book><chapter><sect1><para>
8579 #: ../en/ch07-branch.xml:129
8580 msgid ""
8581 "Mercurial stores tags in a normal revision-controlled file in your "
8582 "repository. If you've created any tags, you'll find them in a file in the "
8583 "root of your repository named <filename role=\"special\">.hgtags</filename>. "
8584 "When you run the <command role=\"hg-cmd\">hg tag</command> command, Mercurial "
8585 "modifies this file, then automatically commits the change to it. This means "
8586 "that every time you run <command role=\"hg-cmd\">hg tag</command>, you'll see "
8587 "a corresponding changeset in the output of <command role=\"hg-cmd\">hg log</"
8588 "command>."
8589 msgstr ""
8591 #. type: Content of: <book><chapter><sect1><sect2><title>
8592 #: ../en/ch07-branch.xml:142
8593 msgid "Handling tag conflicts during a merge"
8594 msgstr "在合并期间处理标签冲突"
8596 #. type: Content of: <book><chapter><sect1><sect2><para>
8597 #: ../en/ch07-branch.xml:144
8598 msgid ""
8599 "You won't often need to care about the <filename role=\"special\">.hgtags</"
8600 "filename> file, but it sometimes makes its presence known during a merge. "
8601 "The format of the file is simple: it consists of a series of lines. Each "
8602 "line starts with a changeset hash, followed by a space, followed by the name "
8603 "of a tag."
8604 msgstr ""
8606 #. type: Content of: <book><chapter><sect1><sect2><para>
8607 #: ../en/ch07-branch.xml:151
8608 msgid ""
8609 "If you're resolving a conflict in the <filename role=\"special\">.hgtags</"
8610 "filename> file during a merge, there's one twist to modifying the <filename "
8611 "role=\"special\">.hgtags</filename> file: when Mercurial is parsing the tags "
8612 "in a repository, it <emphasis>never</emphasis> reads the working copy of the "
8613 "<filename role=\"special\">.hgtags</filename> file. Instead, it reads the "
8614 "<emphasis>most recently committed</emphasis> revision of the file."
8615 msgstr ""
8617 #. type: Content of: <book><chapter><sect1><sect2><para>
8618 #: ../en/ch07-branch.xml:161
8619 msgid ""
8620 "An unfortunate consequence of this design is that you can't actually verify "
8621 "that your merged <filename role=\"special\">.hgtags</filename> file is "
8622 "correct until <emphasis>after</emphasis> you've committed a change. So if "
8623 "you find yourself resolving a conflict on <filename role=\"special\">.hgtags</"
8624 "filename> during a merge, be sure to run <command role=\"hg-cmd\">hg tags</"
8625 "command> after you commit. If it finds an error in the <filename role="
8626 "\"special\">.hgtags</filename> file, it will report the location of the "
8627 "error, which you can then fix and commit. You should then run <command role="
8628 "\"hg-cmd\">hg tags</command> again, just to be sure that your fix is correct."
8629 msgstr ""
8631 #. type: Content of: <book><chapter><sect1><sect2><title>
8632 #: ../en/ch07-branch.xml:176
8633 msgid "Tags and cloning"
8634 msgstr "标签与克隆"
8636 #. type: Content of: <book><chapter><sect1><sect2><para>
8637 #: ../en/ch07-branch.xml:178
8638 msgid ""
8639 "You may have noticed that the <command role=\"hg-cmd\">hg clone</command> "
8640 "command has a <option role=\"hg-opt-clone\">-r</option> option that lets you "
8641 "clone an exact copy of the repository as of a particular changeset. The new "
8642 "clone will not contain any project history that comes after the revision you "
8643 "specified. This has an interaction with tags that can surprise the unwary."
8644 msgstr ""
8646 #. type: Content of: <book><chapter><sect1><sect2><para>
8647 #: ../en/ch07-branch.xml:186
8648 msgid ""
8649 "Recall that a tag is stored as a revision to the <filename role=\"special\">."
8650 "hgtags</filename> file, so that when you create a tag, the changeset in which "
8651 "it's recorded necessarily refers to an older changeset. When you run "
8652 "<command role=\"hg-cmd\">hg clone -r foo</command> to clone a repository as "
8653 "of tag <literal>foo</literal>, the new clone <emphasis>will not contain the "
8654 "history that created the tag</emphasis> that you used to clone the "
8655 "repository. The result is that you'll get exactly the right subset of the "
8656 "project's history in the new repository, but <emphasis>not</emphasis> the tag "
8657 "you might have expected."
8658 msgstr ""
8660 #. type: Content of: <book><chapter><sect1><sect2><title>
8661 #: ../en/ch07-branch.xml:201
8662 msgid "When permanent tags are too much"
8663 msgstr "当永久标签太多的时候"
8665 #. type: Content of: <book><chapter><sect1><sect2><para>
8666 #: ../en/ch07-branch.xml:203
8667 msgid ""
8668 "Since Mercurial's tags are revision controlled and carried around with a "
8669 "project's history, everyone you work with will see the tags you create. But "
8670 "giving names to revisions has uses beyond simply noting that revision "
8671 "<literal>4237e45506ee</literal> is really <literal>v2.0.2</literal>. If "
8672 "you're trying to track down a subtle bug, you might want a tag to remind you "
8673 "of something like <quote>Anne saw the symptoms with this revision</quote>."
8674 msgstr ""
8676 #. type: Content of: <book><chapter><sect1><sect2><para>
8677 #: ../en/ch07-branch.xml:213
8678 msgid ""
8679 "For cases like this, what you might want to use are <emphasis>local</"
8680 "emphasis> tags. You can create a local tag with the <option role=\"hg-opt-tag"
8681 "\">-l</option> option to the <command role=\"hg-cmd\">hg tag</command> "
8682 "command. This will store the tag in a file called <filename role=\"special"
8683 "\">.hg/localtags</filename>. Unlike <filename role=\"special\">.hgtags</"
8684 "filename>, <filename role=\"special\">.hg/localtags</filename> is not "
8685 "revision controlled. Any tags you create using <option role=\"hg-opt-tag\">-"
8686 "l</option> remain strictly local to the repository you're currently working "
8687 "in."
8688 msgstr ""
8690 #. type: Content of: <book><chapter><sect1><title>
8691 #: ../en/ch07-branch.xml:228
8692 msgid "The flow of changes&emdash;big picture vs. little"
8693 msgstr "修改流程—宏观与微观"
8695 #. type: Content of: <book><chapter><sect1><para>
8696 #: ../en/ch07-branch.xml:230
8697 msgid ""
8698 "To return to the outline I sketched at the beginning of a chapter, let's "
8699 "think about a project that has multiple concurrent pieces of work under "
8700 "development at once."
8701 msgstr ""
8703 #. type: Content of: <book><chapter><sect1><para>
8704 #: ../en/ch07-branch.xml:234
8705 msgid ""
8706 "There might be a push for a new <quote>main</quote> release; a new minor "
8707 "bugfix release to the last main release; and an unexpected <quote>hot fix</"
8708 "quote> to an old release that is now in maintenance mode."
8709 msgstr ""
8711 #. type: Content of: <book><chapter><sect1><para>
8712 #: ../en/ch07-branch.xml:239
8713 msgid ""
8714 "The usual way people refer to these different concurrent directions of "
8715 "development is as <quote>branches</quote>. However, we've already seen "
8716 "numerous times that Mercurial treats <emphasis>all of history</emphasis> as a "
8717 "series of branches and merges. Really, what we have here is two ideas that "
8718 "are peripherally related, but which happen to share a name."
8719 msgstr ""
8721 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8722 #: ../en/ch07-branch.xml:246
8723 msgid ""
8724 "<quote>Big picture</quote> branches represent the sweep of a project's "
8725 "evolution; people give them names, and talk about them in conversation."
8726 msgstr ""
8728 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8729 #: ../en/ch07-branch.xml:250
8730 msgid ""
8731 "<quote>Little picture</quote> branches are artefacts of the day-to-day "
8732 "activity of developing and merging changes. They expose the narrative of how "
8733 "the code was developed."
8734 msgstr ""
8736 #. type: Content of: <book><chapter><sect1><title>
8737 #: ../en/ch07-branch.xml:258
8738 msgid "Managing big-picture branches in repositories"
8739 msgstr "在版本库中管理分支"
8741 #. type: Content of: <book><chapter><sect1><para>
8742 #: ../en/ch07-branch.xml:260
8743 msgid ""
8744 "The easiest way to isolate a <quote>big picture</quote> branch in Mercurial "
8745 "is in a dedicated repository. If you have an existing shared "
8746 "repository&emdash;let's call it <literal>myproject</literal>&emdash;that "
8747 "reaches a <quote>1.0</quote> milestone, you can start to prepare for future "
8748 "maintenance releases on top of version 1.0 by tagging the revision from which "
8749 "you prepared the 1.0 release."
8750 msgstr ""
8752 #. type: Content of: <book><chapter><sect1><para>
8753 #: ../en/ch07-branch.xml:270
8754 msgid ""
8755 "You can then clone a new shared <literal>myproject-1.0.1</literal> repository "
8756 "as of that tag."
8757 msgstr ""
8759 #. type: Content of: <book><chapter><sect1><para>
8760 #: ../en/ch07-branch.xml:276
8761 msgid ""
8762 "Afterwards, if someone needs to work on a bug fix that ought to go into an "
8763 "upcoming 1.0.1 minor release, they clone the <literal>myproject-1.0.1</"
8764 "literal> repository, make their changes, and push them back."
8765 msgstr ""
8767 #. type: Content of: <book><chapter><sect1><para>
8768 #: ../en/ch07-branch.xml:283
8769 msgid ""
8770 "Meanwhile, development for the next major release can continue, isolated and "
8771 "unabated, in the <literal>myproject</literal> repository."
8772 msgstr ""
8774 #. type: Content of: <book><chapter><sect1><title>
8775 #: ../en/ch07-branch.xml:291
8776 msgid "Don't repeat yourself: merging across branches"
8777 msgstr "不要重复劳动:在分支间合并"
8779 #. type: Content of: <book><chapter><sect1><para>
8780 #: ../en/ch07-branch.xml:293
8781 msgid ""
8782 "In many cases, if you have a bug to fix on a maintenance branch, the chances "
8783 "are good that the bug exists on your project's main branch (and possibly "
8784 "other maintenance branches, too). It's a rare developer who wants to fix the "
8785 "same bug multiple times, so let's look at a few ways that Mercurial can help "
8786 "you to manage these bugfixes without duplicating your work."
8787 msgstr ""
8789 #. type: Content of: <book><chapter><sect1><para>
8790 #: ../en/ch07-branch.xml:301
8791 msgid ""
8792 "In the simplest instance, all you need to do is pull changes from your "
8793 "maintenance branch into your local clone of the target branch."
8794 msgstr ""
8796 #. type: Content of: <book><chapter><sect1><para>
8797 #: ../en/ch07-branch.xml:307
8798 msgid ""
8799 "You'll then need to merge the heads of the two branches, and push back to the "
8800 "main branch."
8801 msgstr ""
8803 #. type: Content of: <book><chapter><sect1><title>
8804 #: ../en/ch07-branch.xml:314
8805 msgid "Naming branches within one repository"
8806 msgstr "版本库中的命名分支"
8808 #. type: Content of: <book><chapter><sect1><para>
8809 #: ../en/ch07-branch.xml:316
8810 msgid ""
8811 "In most instances, isolating branches in repositories is the right approach. "
8812 "Its simplicity makes it easy to understand; and so it's hard to make "
8813 "mistakes. There's a one-to-one relationship between branches you're working "
8814 "in and directories on your system. This lets you use normal (non-Mercurial-"
8815 "aware) tools to work on files within a branch/repository."
8816 msgstr ""
8818 #. type: Content of: <book><chapter><sect1><para>
8819 #: ../en/ch07-branch.xml:323
8820 msgid ""
8821 "If you're more in the <quote>power user</quote> category (<emphasis>and</"
8822 "emphasis> your collaborators are too), there is an alternative way of "
8823 "handling branches that you can consider. I've already mentioned the human-"
8824 "level distinction between <quote>small picture</quote> and <quote>big "
8825 "picture</quote> branches. While Mercurial works with multiple <quote>small "
8826 "picture</quote> branches in a repository all the time (for example after you "
8827 "pull changes in, but before you merge them), it can <emphasis>also</emphasis> "
8828 "work with multiple <quote>big picture</quote> branches."
8829 msgstr ""
8831 #. type: Content of: <book><chapter><sect1><para>
8832 #: ../en/ch07-branch.xml:334
8833 msgid ""
8834 "The key to working this way is that Mercurial lets you assign a persistent "
8835 "<emphasis>name</emphasis> to a branch. There always exists a branch named "
8836 "<literal>default</literal>. Even before you start naming branches yourself, "
8837 "you can find traces of the <literal>default</literal> branch if you look for "
8838 "them."
8839 msgstr ""
8841 #. type: Content of: <book><chapter><sect1><para>
8842 #: ../en/ch07-branch.xml:341
8843 msgid ""
8844 "As an example, when you run the <command role=\"hg-cmd\">hg commit</command> "
8845 "command, and it pops up your editor so that you can enter a commit message, "
8846 "look for a line that contains the text <quote><literal>HG: branch default</"
8847 "literal></quote> at the bottom. This is telling you that your commit will "
8848 "occur on the branch named <literal>default</literal>."
8849 msgstr ""
8851 #. type: Content of: <book><chapter><sect1><para>
8852 #: ../en/ch07-branch.xml:348
8853 msgid ""
8854 "To start working with named branches, use the <command role=\"hg-cmd\">hg "
8855 "branches</command> command. This command lists the named branches already "
8856 "present in your repository, telling you which changeset is the tip of each."
8857 msgstr ""
8859 #. type: Content of: <book><chapter><sect1><para>
8860 #: ../en/ch07-branch.xml:355
8861 msgid ""
8862 "Since you haven't created any named branches yet, the only one that exists is "
8863 "<literal>default</literal>."
8864 msgstr ""
8866 #. type: Content of: <book><chapter><sect1><para>
8867 #: ../en/ch07-branch.xml:358
8868 msgid ""
8869 "To find out what the <quote>current</quote> branch is, run the <command role="
8870 "\"hg-cmd\">hg branch</command> command, giving it no arguments. This tells "
8871 "you what branch the parent of the current changeset is on."
8872 msgstr ""
8875 #. type: Content of: <book><chapter><sect1><para>
8876 #: ../en/ch07-branch.xml:365
8877 msgid ""
8878 "To create a new branch, run the <command role=\"hg-cmd\">hg branch</command> "
8879 "command again. This time, give it one argument: the name of the branch you "
8880 "want to create."
8881 msgstr ""
8883 #. type: Content of: <book><chapter><sect1><para>
8884 #: ../en/ch07-branch.xml:371
8885 msgid ""
8886 "After you've created a branch, you might wonder what effect the <command role="
8887 "\"hg-cmd\">hg branch</command> command has had. What do the <command role="
8888 "\"hg-cmd\">hg status</command> and <command role=\"hg-cmd\">hg tip</command> "
8889 "commands report?"
8890 msgstr ""
8892 #. type: Content of: <book><chapter><sect1><para>
8893 #: ../en/ch07-branch.xml:378
8894 msgid ""
8895 "Nothing has changed in the working directory, and there's been no new history "
8896 "created. As this suggests, running the <command role=\"hg-cmd\">hg branch</"
8897 "command> command has no permanent effect; it only tells Mercurial what branch "
8898 "name to use the <emphasis>next</emphasis> time you commit a changeset."
8899 msgstr ""
8901 #. type: Content of: <book><chapter><sect1><para>
8902 #: ../en/ch07-branch.xml:385
8903 msgid ""
8904 "When you commit a change, Mercurial records the name of the branch on which "
8905 "you committed. Once you've switched from the <literal>default</literal> "
8906 "branch to another and committed, you'll see the name of the new branch show "
8907 "up in the output of <command role=\"hg-cmd\">hg log</command>, <command role="
8908 "\"hg-cmd\">hg tip</command>, and other commands that display the same kind of "
8909 "output."
8910 msgstr ""
8912 #. type: Content of: <book><chapter><sect1><para>
8913 #: ../en/ch07-branch.xml:395
8914 msgid ""
8915 "The <command role=\"hg-cmd\">hg log</command>-like commands will print the "
8916 "branch name of every changeset that's not on the <literal>default</literal> "
8917 "branch. As a result, if you never use named branches, you'll never see this "
8918 "information."
8919 msgstr ""
8921 #. type: Content of: <book><chapter><sect1><para>
8922 #: ../en/ch07-branch.xml:400
8923 msgid ""
8924 "Once you've named a branch and committed a change with that name, every "
8925 "subsequent commit that descends from that change will inherit the same branch "
8926 "name. You can change the name of a branch at any time, using the <command "
8927 "role=\"hg-cmd\">hg branch</command> command."
8928 msgstr ""
8930 #. type: Content of: <book><chapter><sect1><para>
8931 #: ../en/ch07-branch.xml:408
8932 msgid ""
8933 "In practice, this is something you won't do very often, as branch names tend "
8934 "to have fairly long lifetimes. (This isn't a rule, just an observation.)"
8935 msgstr ""
8937 #. type: Content of: <book><chapter><sect1><title>
8938 #: ../en/ch07-branch.xml:414
8939 msgid "Dealing with multiple named branches in a repository"
8940 msgstr "在版本库中处理多个命名分支"
8942 #. type: Content of: <book><chapter><sect1><para>
8943 #: ../en/ch07-branch.xml:417
8944 msgid ""
8945 "If you have more than one named branch in a repository, Mercurial will "
8946 "remember the branch that your working directory on when you start a command "
8947 "like <command role=\"hg-cmd\">hg update</command> or <command role=\"hg-cmd"
8948 "\">hg pull -u</command>. It will update the working directory to the tip of "
8949 "this branch, no matter what the <quote>repo-wide</quote> tip is. To update "
8950 "to a revision that's on a different named branch, you may need to use the "
8951 "<option role=\"hg-opt-update\">-C</option> option to <command role=\"hg-cmd"
8952 "\">hg update</command>."
8953 msgstr ""
8955 #. type: Content of: <book><chapter><sect1><para>
8956 #: ../en/ch07-branch.xml:427
8957 msgid ""
8958 "This behavior is a little subtle, so let's see it in action. First, let's "
8959 "remind ourselves what branch we're currently on, and what branches are in our "
8960 "repository."
8961 msgstr ""
8963 #. type: Content of: <book><chapter><sect1><para>
8964 #: ../en/ch07-branch.xml:433
8965 msgid ""
8966 "We're on the <literal>bar</literal> branch, but there also exists an older "
8967 "<command role=\"hg-cmd\">hg foo</command> branch."
8968 msgstr ""
8970 #. type: Content of: <book><chapter><sect1><para>
8971 #: ../en/ch07-branch.xml:437
8972 msgid ""
8973 "We can <command role=\"hg-cmd\">hg update</command> back and forth between "
8974 "the tips of the <literal>foo</literal> and <literal>bar</literal> branches "
8975 "without needing to use the <option role=\"hg-opt-update\">-C</option> option, "
8976 "because this only involves going backwards and forwards linearly through our "
8977 "change history."
8978 msgstr ""
8981 #. type: Content of: <book><chapter><sect1><para>
8982 #: ../en/ch07-branch.xml:446
8983 msgid ""
8984 "If we go back to the <literal>foo</literal> branch and then run <command role="
8985 "\"hg-cmd\">hg update</command>, it will keep us on <literal>foo</literal>, "
8986 "not move us to the tip of <literal>bar</literal>."
8987 msgstr ""
8990 #. type: Content of: <book><chapter><sect1><para>
8991 #: ../en/ch07-branch.xml:453
8992 msgid ""
8993 "Committing a new change on the <literal>foo</literal> branch introduces a new "
8994 "head."
8995 msgstr ""
8997 #. type: Content of: <book><chapter><sect1><title>
8998 #: ../en/ch07-branch.xml:460
8999 msgid "Branch names and merging"
9000 msgstr "分支名称与合并"
9002 #. type: Content of: <book><chapter><sect1><para>
9003 #: ../en/ch07-branch.xml:462
9004 msgid ""
9005 "As you've probably noticed, merges in Mercurial are not symmetrical. Let's "
9006 "say our repository has two heads, 17 and 23. If I <command role=\"hg-cmd"
9007 "\">hg update</command> to 17 and then <command role=\"hg-cmd\">hg merge</"
9008 "command> with 23, Mercurial records 17 as the first parent of the merge, and "
9009 "23 as the second. Whereas if I <command role=\"hg-cmd\">hg update</command> "
9010 "to 23 and then <command role=\"hg-cmd\">hg merge</command> with 17, it "
9011 "records 23 as the first parent, and 17 as the second."
9012 msgstr ""
9014 #. type: Content of: <book><chapter><sect1><para>
9015 #: ../en/ch07-branch.xml:472
9016 msgid ""
9017 "This affects Mercurial's choice of branch name when you merge. After a "
9018 "merge, Mercurial will retain the branch name of the first parent when you "
9019 "commit the result of the merge. If your first parent's branch name is "
9020 "<literal>foo</literal>, and you merge with <literal>bar</literal>, the branch "
9021 "name will still be <literal>foo</literal> after you merge."
9022 msgstr ""
9024 #. type: Content of: <book><chapter><sect1><para>
9025 #: ../en/ch07-branch.xml:479
9026 msgid ""
9027 "It's not unusual for a repository to contain multiple heads, each with the "
9028 "same branch name. Let's say I'm working on the <literal>foo</literal> "
9029 "branch, and so are you. We commit different changes; I pull your changes; I "
9030 "now have two heads, each claiming to be on the <literal>foo</literal> "
9031 "branch. The result of a merge will be a single head on the <literal>foo</"
9032 "literal> branch, as you might hope."
9033 msgstr ""
9036 #. type: Content of: <book><chapter><sect1><para>
9037 #: ../en/ch07-branch.xml:487
9038 msgid ""
9039 "But if I'm working on the <literal>bar</literal> branch, and I merge work "
9040 "from the <literal>foo</literal> branch, the result will remain on the "
9041 "<literal>bar</literal> branch."
9042 msgstr ""
9044 #. type: Content of: <book><chapter><sect1><para>
9045 #: ../en/ch07-branch.xml:493
9046 msgid ""
9047 "To give a more concrete example, if I'm working on the <literal>bleeding-"
9048 "edge</literal> branch, and I want to bring in the latest fixes from the "
9049 "<literal>stable</literal> branch, Mercurial will choose the <quote>right</"
9050 "quote> (<literal>bleeding-edge</literal>) branch name when I pull and merge "
9051 "from <literal>stable</literal>."
9052 msgstr ""
9054 #. type: Content of: <book><chapter><sect1><title>
9055 #: ../en/ch07-branch.xml:502
9056 msgid "Branch naming is generally useful"
9057 msgstr "分支名称通常都很有用"
9059 #. type: Content of: <book><chapter><sect1><para>
9060 #: ../en/ch07-branch.xml:504
9061 msgid ""
9062 "You shouldn't think of named branches as applicable only to situations where "
9063 "you have multiple long-lived branches cohabiting in a single repository. "
9064 "They're very useful even in the one-branch-per-repository case."
9065 msgstr ""
9067 #. type: Content of: <book><chapter><sect1><para>
9068 #: ../en/ch07-branch.xml:509
9069 msgid ""
9070 "In the simplest case, giving a name to each branch gives you a permanent "
9071 "record of which branch a changeset originated on. This gives you more "
9072 "context when you're trying to follow the history of a long-lived branchy "
9073 "project."
9074 msgstr ""
9076 #. type: Content of: <book><chapter><sect1><para>
9077 #: ../en/ch07-branch.xml:514
9078 msgid ""
9079 "If you're working with shared repositories, you can set up a <literal role="
9080 "\"hook\">pretxnchangegroup</literal> hook on each that will block incoming "
9081 "changes that have the <quote>wrong</quote> branch name. This provides a "
9082 "simple, but effective, defence against people accidentally pushing changes "
9083 "from a <quote>bleeding edge</quote> branch to a <quote>stable</quote> "
9084 "branch. Such a hook might look like this inside the shared repo's <filename "
9085 "role=\"special\"> /.hgrc</filename>."
9086 msgstr ""
9088 #. type: Content of: <book><chapter><title>
9089 #: ../en/ch08-undo.xml:5
9090 msgid "Finding and fixing mistakes"
9091 msgstr "查找和修改错误"
9093 #. type: Content of: <book><chapter><para>
9094 #: ../en/ch08-undo.xml:7
9095 msgid ""
9096 "To err might be human, but to really handle the consequences well takes a top-"
9097 "notch revision control system. In this chapter, we'll discuss some of the "
9098 "techniques you can use when you find that a problem has crept into your "
9099 "project. Mercurial has some highly capable features that will help you to "
9100 "isolate the sources of problems, and to handle them appropriately."
9101 msgstr ""
9103 #. type: Content of: <book><chapter><sect1><title>
9104 #: ../en/ch08-undo.xml:15
9105 msgid "Erasing local history"
9106 msgstr "销毁本地历史"
9108 #. type: Content of: <book><chapter><sect1><sect2><title>
9109 #: ../en/ch08-undo.xml:18
9110 msgid "The accidental commit"
9111 msgstr "意外的提交"
9113 #. type: Content of: <book><chapter><sect1><sect2><para>
9114 #: ../en/ch08-undo.xml:20
9115 msgid ""
9116 "I have the occasional but persistent problem of typing rather more quickly "
9117 "than I can think, which sometimes results in me committing a changeset that "
9118 "is either incomplete or plain wrong. In my case, the usual kind of "
9119 "incomplete changeset is one in which I've created a new source file, but "
9120 "forgotten to <command role=\"hg-cmd\">hg add</command> it. A <quote>plain "
9121 "wrong</quote> changeset is not as common, but no less annoying."
9122 msgstr ""
9124 #. type: Content of: <book><chapter><sect1><sect2><title>
9125 #: ../en/ch08-undo.xml:31
9126 msgid "Rolling back a transaction"
9127 msgstr "回滚一个事务"
9129 #. type: Content of: <book><chapter><sect1><sect2><para>
9130 #: ../en/ch08-undo.xml:33
9131 msgid ""
9132 "In <xref linkend=\"sec:concepts:txn\"/>, I mentioned that Mercurial treats "
9133 "each modification of a repository as a <emphasis>transaction</emphasis>. "
9134 "Every time you commit a changeset or pull changes from another repository, "
9135 "Mercurial remembers what you did. You can undo, or <emphasis>roll back</"
9136 "emphasis>, exactly one of these actions using the <command role=\"hg-cmd\">hg "
9137 "rollback</command> command. (See <xref linkend=\"sec:undo:rollback-after-push"
9138 "\"/> for an important caveat about the use of this command.)"
9139 msgstr ""
9141 #. type: Content of: <book><chapter><sect1><sect2><para>
9142 #: ../en/ch08-undo.xml:43
9143 msgid ""
9144 "Here's a mistake that I often find myself making: committing a change in "
9145 "which I've created a new file, but forgotten to <command role=\"hg-cmd\">hg "
9146 "add</command> it."
9147 msgstr ""
9149 #. type: Content of: <book><chapter><sect1><sect2><para>
9150 #: ../en/ch08-undo.xml:50
9151 msgid ""
9152 "Looking at the output of <command role=\"hg-cmd\">hg status</command> after "
9153 "the commit immediately confirms the error."
9154 msgstr ""
9156 #. type: Content of: <book><chapter><sect1><sect2><para>
9157 #: ../en/ch08-undo.xml:56
9158 msgid ""
9159 "The commit captured the changes to the file <filename>a</filename>, but not "
9160 "the new file <filename>b</filename>. If I were to push this changeset to a "
9161 "repository that I shared with a colleague, the chances are high that "
9162 "something in <filename>a</filename> would refer to <filename>b</filename>, "
9163 "which would not be present in their repository when they pulled my changes. "
9164 "I would thus become the object of some indignation."
9165 msgstr ""
9167 #. type: Content of: <book><chapter><sect1><sect2><para>
9168 #: ../en/ch08-undo.xml:65
9169 msgid ""
9170 "However, luck is with me&emdash;I've caught my error before I pushed the "
9171 "changeset. I use the <command role=\"hg-cmd\">hg rollback</command> command, "
9172 "and Mercurial makes that last changeset vanish."
9173 msgstr ""
9175 #. type: Content of: <book><chapter><sect1><sect2><para>
9176 #: ../en/ch08-undo.xml:72
9177 msgid ""
9178 "Notice that the changeset is no longer present in the repository's history, "
9179 "and the working directory once again thinks that the file <filename>a</"
9180 "filename> is modified. The commit and rollback have left the working "
9181 "directory exactly as it was prior to the commit; the changeset has been "
9182 "completely erased. I can now safely <command role=\"hg-cmd\">hg add</"
9183 "command> the file <filename>b</filename>, and rerun my commit."
9184 msgstr ""
9186 #. type: Content of: <book><chapter><sect1><sect2><title>
9187 #: ../en/ch08-undo.xml:85
9188 msgid "The erroneous pull"
9189 msgstr "错误的抓取"
9191 #. type: Content of: <book><chapter><sect1><sect2><para>
9192 #: ../en/ch08-undo.xml:87
9193 msgid ""
9194 "It's common practice with Mercurial to maintain separate development branches "
9195 "of a project in different repositories. Your development team might have one "
9196 "shared repository for your project's <quote>0.9</quote> release, and another, "
9197 "containing different changes, for the <quote>1.0</quote> release."
9198 msgstr ""
9200 #. type: Content of: <book><chapter><sect1><sect2><para>
9201 #: ../en/ch08-undo.xml:94
9202 msgid ""
9203 "Given this, you can imagine that the consequences could be messy if you had a "
9204 "local <quote>0.9</quote> repository, and accidentally pulled changes from the "
9205 "shared <quote>1.0</quote> repository into it. At worst, you could be paying "
9206 "insufficient attention, and push those changes into the shared <quote>0.9</"
9207 "quote> tree, confusing your entire team (but don't worry, we'll return to "
9208 "this horror scenario later). However, it's more likely that you'll notice "
9209 "immediately, because Mercurial will display the URL it's pulling from, or you "
9210 "will see it pull a suspiciously large number of changes into the repository."
9211 msgstr ""
9213 #. type: Content of: <book><chapter><sect1><sect2><para>
9214 #: ../en/ch08-undo.xml:106
9215 msgid ""
9216 "The <command role=\"hg-cmd\">hg rollback</command> command will work nicely "
9217 "to expunge all of the changesets that you just pulled. Mercurial groups all "
9218 "changes from one <command role=\"hg-cmd\">hg pull</command> into a single "
9219 "transaction, so one <command role=\"hg-cmd\">hg rollback</command> is all you "
9220 "need to undo this mistake."
9221 msgstr ""
9223 #. type: Content of: <book><chapter><sect1><sect2><title>
9224 #: ../en/ch08-undo.xml:115
9225 msgid "Rolling back is useless once you've pushed"
9226 msgstr "当完成推送后,回滚是无效的"
9228 #. type: Content of: <book><chapter><sect1><sect2><para>
9229 #: ../en/ch08-undo.xml:117
9230 msgid ""
9231 "The value of the <command role=\"hg-cmd\">hg rollback</command> command drops "
9232 "to zero once you've pushed your changes to another repository. Rolling back "
9233 "a change makes it disappear entirely, but <emphasis>only</emphasis> in the "
9234 "repository in which you perform the <command role=\"hg-cmd\">hg rollback</"
9235 "command>. Because a rollback eliminates history, there's no way for the "
9236 "disappearance of a change to propagate between repositories."
9237 msgstr ""
9239 #. type: Content of: <book><chapter><sect1><sect2><para>
9240 #: ../en/ch08-undo.xml:126
9241 msgid ""
9242 "If you've pushed a change to another repository&emdash;particularly if it's a "
9243 "shared repository&emdash;it has essentially <quote>escaped into the wild,</"
9244 "quote> and you'll have to recover from your mistake in a different way. What "
9245 "will happen if you push a changeset somewhere, then roll it back, then pull "
9246 "from the repository you pushed to, is that the changeset will reappear in "
9247 "your repository."
9248 msgstr ""
9250 #. type: Content of: <book><chapter><sect1><sect2><para>
9251 #: ../en/ch08-undo.xml:135
9252 msgid ""
9253 "(If you absolutely know for sure that the change you want to roll back is the "
9254 "most recent change in the repository that you pushed to, <emphasis>and</"
9255 "emphasis> you know that nobody else could have pulled it from that "
9256 "repository, you can roll back the changeset there, too, but you really should "
9257 "really not rely on this working reliably. If you do this, sooner or later a "
9258 "change really will make it into a repository that you don't directly control "
9259 "(or have forgotten about), and come back to bite you.)"
9260 msgstr ""
9262 #. type: Content of: <book><chapter><sect1><sect2><title>
9263 #: ../en/ch08-undo.xml:147
9264 msgid "You can only roll back once"
9265 msgstr "你只能回滚一次"
9267 #. type: Content of: <book><chapter><sect1><sect2><para>
9268 #: ../en/ch08-undo.xml:149
9269 msgid ""
9270 "Mercurial stores exactly one transaction in its transaction log; that "
9271 "transaction is the most recent one that occurred in the repository. This "
9272 "means that you can only roll back one transaction. If you expect to be able "
9273 "to roll back one transaction, then its predecessor, this is not the behavior "
9274 "you will get."
9275 msgstr ""
9277 #. type: Content of: <book><chapter><sect1><sect2><para>
9278 #: ../en/ch08-undo.xml:158
9279 msgid ""
9280 "Once you've rolled back one transaction in a repository, you can't roll back "
9281 "again in that repository until you perform another commit or pull."
9282 msgstr ""
9284 #. type: Content of: <book><chapter><sect1><title>
9285 #: ../en/ch08-undo.xml:165
9286 msgid "Reverting the mistaken change"
9287 msgstr "撤销错误的修改"
9289 #. type: Content of: <book><chapter><sect1><para>
9290 #: ../en/ch08-undo.xml:167
9291 msgid ""
9292 "If you make a modification to a file, and decide that you really didn't want "
9293 "to change the file at all, and you haven't yet committed your changes, the "
9294 "<command role=\"hg-cmd\">hg revert</command> command is the one you'll need. "
9295 "It looks at the changeset that's the parent of the working directory, and "
9296 "restores the contents of the file to their state as of that changeset. "
9297 "(That's a long-winded way of saying that, in the normal case, it undoes your "
9298 "modifications.)"
9299 msgstr ""
9301 #. type: Content of: <book><chapter><sect1><para>
9302 #: ../en/ch08-undo.xml:176
9303 msgid ""
9304 "Let's illustrate how the <command role=\"hg-cmd\">hg revert</command> command "
9305 "works with yet another small example. We'll begin by modifying a file that "
9306 "Mercurial is already tracking."
9307 msgstr ""
9309 #. type: Content of: <book><chapter><sect1><para>
9310 #: ../en/ch08-undo.xml:183
9311 msgid ""
9312 "If we don't want that change, we can simply <command role=\"hg-cmd\">hg "
9313 "revert</command> the file."
9314 msgstr ""
9316 #. type: Content of: <book><chapter><sect1><para>
9317 #: ../en/ch08-undo.xml:189
9318 msgid ""
9319 "The <command role=\"hg-cmd\">hg revert</command> command provides us with an "
9320 "extra degree of safety by saving our modified file with a <filename>.orig</"
9321 "filename> extension."
9322 msgstr ""
9324 #. type: Content of: <book><chapter><sect1><para>
9325 #: ../en/ch08-undo.xml:196
9326 msgid ""
9327 "Here is a summary of the cases that the <command role=\"hg-cmd\">hg revert</"
9328 "command> command can deal with. We will describe each of these in more "
9329 "detail in the section that follows."
9330 msgstr ""
9332 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
9333 #: ../en/ch08-undo.xml:201
9334 msgid "If you modify a file, it will restore the file to its unmodified state."
9335 msgstr ""
9337 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
9338 #: ../en/ch08-undo.xml:204
9339 msgid ""
9340 "If you <command role=\"hg-cmd\">hg add</command> a file, it will undo the "
9341 "<quote>added</quote> state of the file, but leave the file itself untouched."
9342 msgstr ""
9344 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
9345 #: ../en/ch08-undo.xml:208
9346 msgid ""
9347 "If you delete a file without telling Mercurial, it will restore the file to "
9348 "its unmodified contents."
9349 msgstr ""
9351 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
9352 #: ../en/ch08-undo.xml:211
9353 msgid ""
9354 "If you use the <command role=\"hg-cmd\">hg remove</command> command to remove "
9355 "a file, it will undo the <quote>removed</quote> state of the file, and "
9356 "restore the file to its unmodified contents."
9357 msgstr ""
9359 #. type: Content of: <book><chapter><sect1><sect2><title>
9360 #: ../en/ch08-undo.xml:218
9361 msgid "File management errors"
9362 msgstr "文件管理错误"
9364 #. type: Content of: <book><chapter><sect1><sect2><para>
9365 #: ../en/ch08-undo.xml:220
9366 msgid ""
9367 "The <command role=\"hg-cmd\">hg revert</command> command is useful for more "
9368 "than just modified files. It lets you reverse the results of all of "
9369 "Mercurial's file management commands&emdash;<command role=\"hg-cmd\">hg add</"
9370 "command>, <command role=\"hg-cmd\">hg remove</command>, and so on."
9371 msgstr ""
9374 #. type: Content of: <book><chapter><sect1><sect2><para>
9375 #: ../en/ch08-undo.xml:226
9376 msgid ""
9377 "If you <command role=\"hg-cmd\">hg add</command> a file, then decide that in "
9378 "fact you don't want Mercurial to track it, use <command role=\"hg-cmd\">hg "
9379 "revert</command> to undo the add. Don't worry; Mercurial will not modify the "
9380 "file in any way. It will just <quote>unmark</quote> the file."
9381 msgstr ""
9383 #. type: Content of: <book><chapter><sect1><sect2><para>
9384 #: ../en/ch08-undo.xml:234
9385 msgid ""
9386 "Similarly, if you ask Mercurial to <command role=\"hg-cmd\">hg remove</"
9387 "command> a file, you can use <command role=\"hg-cmd\">hg revert</command> to "
9388 "restore it to the contents it had as of the parent of the working directory. "
9389 "&interaction.daily.revert.remove; This works just as well for a file that you "
9390 "deleted by hand, without telling Mercurial (recall that in Mercurial "
9391 "terminology, this kind of file is called <quote>missing</quote>)."
9392 msgstr ""
9395 #. type: Content of: <book><chapter><sect1><sect2><para>
9396 #: ../en/ch08-undo.xml:245
9397 msgid ""
9398 "If you revert a <command role=\"hg-cmd\">hg copy</command>, the copied-to "
9399 "file remains in your working directory afterwards, untracked. Since a copy "
9400 "doesn't affect the copied-from file in any way, Mercurial doesn't do anything "
9401 "with the copied-from file."
9402 msgstr ""
9404 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
9405 #: ../en/ch08-undo.xml:254
9406 msgid "A slightly special case: reverting a rename"
9407 msgstr "一个稍微特别的案例:撤销改名"
9409 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9410 #: ../en/ch08-undo.xml:256
9411 msgid ""
9412 "If you <command role=\"hg-cmd\">hg rename</command> a file, there is one "
9413 "small detail that you should remember. When you <command role=\"hg-cmd\">hg "
9414 "revert</command> a rename, it's not enough to provide the name of the renamed-"
9415 "to file, as you can see here."
9416 msgstr ""
9418 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9419 #: ../en/ch08-undo.xml:264
9420 msgid ""
9421 "As you can see from the output of <command role=\"hg-cmd\">hg status</"
9422 "command>, the renamed-to file is no longer identified as added, but the "
9423 "renamed-<emphasis>from</emphasis> file is still removed! This is counter-"
9424 "intuitive (at least to me), but at least it's easy to deal with."
9425 msgstr ""
9427 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9428 #: ../en/ch08-undo.xml:273
9429 msgid ""
9430 "So remember, to revert a <command role=\"hg-cmd\">hg rename</command>, you "
9431 "must provide <emphasis>both</emphasis> the source and destination names."
9432 msgstr ""
9434 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9435 #: ../en/ch08-undo.xml:278
9436 msgid "% TODO: the output doesn't look like it will be removed!"
9437 msgstr ""
9439 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9440 #: ../en/ch08-undo.xml:281
9441 msgid ""
9442 "(By the way, if you rename a file, then modify the renamed-to file, then "
9443 "revert both components of the rename, when Mercurial restores the file that "
9444 "was removed as part of the rename, it will be unmodified. If you need the "
9445 "modifications in the renamed-to file to show up in the renamed-from file, "
9446 "don't forget to copy them over.)"
9447 msgstr ""
9449 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9450 #: ../en/ch08-undo.xml:288
9451 msgid ""
9452 "These fiddly aspects of reverting a rename arguably constitute a small bug in "
9453 "Mercurial."
9454 msgstr ""
9456 #. type: Content of: <book><chapter><sect1><title>
9457 #: ../en/ch08-undo.xml:295
9458 msgid "Dealing with committed changes"
9459 msgstr "处理已经提交的修改"
9461 #. type: Content of: <book><chapter><sect1><para>
9462 #: ../en/ch08-undo.xml:297
9463 msgid ""
9464 "Consider a case where you have committed a change $a$, and another change $b$ "
9465 "on top of it; you then realise that change $a$ was incorrect. Mercurial lets "
9466 "you <quote>back out</quote> an entire changeset automatically, and building "
9467 "blocks that let you reverse part of a changeset by hand."
9468 msgstr ""
9470 #. type: Content of: <book><chapter><sect1><para>
9471 #: ../en/ch08-undo.xml:303
9472 msgid ""
9473 "Before you read this section, here's something to keep in mind: the <command "
9474 "role=\"hg-cmd\">hg backout</command> command undoes changes by "
9475 "<emphasis>adding</emphasis> history, not by modifying or erasing it. It's "
9476 "the right tool to use if you're fixing bugs, but not if you're trying to undo "
9477 "some change that has catastrophic consequences. To deal with those, see "
9478 "<xref linkend=\"sec:undo:aaaiiieee\"/>."
9479 msgstr ""
9481 #. type: Content of: <book><chapter><sect1><sect2><title>
9482 #: ../en/ch08-undo.xml:312
9483 msgid "Backing out a changeset"
9484 msgstr "恢复一个修改集"
9486 #. type: Content of: <book><chapter><sect1><sect2><para>
9487 #: ../en/ch08-undo.xml:314
9488 msgid ""
9489 "The <command role=\"hg-cmd\">hg backout</command> command lets you "
9490 "<quote>undo</quote> the effects of an entire changeset in an automated "
9491 "fashion. Because Mercurial's history is immutable, this command "
9492 "<emphasis>does not</emphasis> get rid of the changeset you want to undo. "
9493 "Instead, it creates a new changeset that <emphasis>reverses</emphasis> the "
9494 "effect of the to-be-undone changeset."
9495 msgstr ""
9498 #. type: Content of: <book><chapter><sect1><sect2><para>
9499 #: ../en/ch08-undo.xml:323
9500 msgid ""
9501 "The operation of the <command role=\"hg-cmd\">hg backout</command> command is "
9502 "a little intricate, so let's illustrate it with some examples. First, we'll "
9503 "create a repository with some simple changes."
9504 msgstr ""
9506 #. type: Content of: <book><chapter><sect1><sect2><para>
9507 #: ../en/ch08-undo.xml:330
9508 msgid ""
9509 "The <command role=\"hg-cmd\">hg backout</command> command takes a single "
9510 "changeset ID as its argument; this is the changeset to back out. Normally, "
9511 "<command role=\"hg-cmd\">hg backout</command> will drop you into a text "
9512 "editor to write a commit message, so you can record why you're backing the "
9513 "change out. In this example, we provide a commit message on the command line "
9514 "using the <option role=\"hg-opt-backout\">-m</option> option."
9515 msgstr ""
9517 #. type: Content of: <book><chapter><sect1><sect2><title>
9518 #: ../en/ch08-undo.xml:341
9519 msgid "Backing out the tip changeset"
9520 msgstr "恢复顶点修改集"
9522 #. type: Content of: <book><chapter><sect1><sect2><para>
9523 #: ../en/ch08-undo.xml:343
9524 msgid "We're going to start by backing out the last changeset we committed."
9525 msgstr ""
9527 #. type: Content of: <book><chapter><sect1><sect2><para>
9528 #: ../en/ch08-undo.xml:348
9529 msgid ""
9530 "You can see that the second line from <filename>myfile</filename> is no "
9531 "longer present. Taking a look at the output of <command role=\"hg-cmd\">hg "
9532 "log</command> gives us an idea of what the <command role=\"hg-cmd\">hg "
9533 "backout</command> command has done. &interaction.backout.simple.log; Notice "
9534 "that the new changeset that <command role=\"hg-cmd\">hg backout</command> has "
9535 "created is a child of the changeset we backed out. It's easier to see this "
9536 "in <xref linkend=\"fig:undo:backout\"/>, which presents a graphical view of "
9537 "the change history. As you can see, the history is nice and linear."
9538 msgstr ""
9540 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
9541 #: ../en/ch08-undo.xml:361 ../en/ch08-undo.xml:473
9542 msgid ""
9543 "Backing out a change using the <command role=\"hg-cmd\">hg backout</command> "
9544 "command"
9545 msgstr "使用 <command role=\"hg-cmd\">hg backout</command> 恢复一个修改"
9547 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
9548 #: ../en/ch08-undo.xml:364
9549 msgid "<imageobject><imagedata fileref=\"figs/undo-simple.png\"/></imageobject>"
9550 msgstr ""
9552 #. type: Content of: <book><chapter><sect1><sect2><title>
9553 #: ../en/ch08-undo.xml:371
9554 msgid "Backing out a non-tip change"
9555 msgstr "恢复非顶点的修改"
9557 #. type: Content of: <book><chapter><sect1><sect2><para>
9558 #: ../en/ch08-undo.xml:373
9559 msgid ""
9560 "If you want to back out a change other than the last one you committed, pass "
9561 "the <option role=\"hg-opt-backout\">--merge</option> option to the <command "
9562 "role=\"hg-cmd\">hg backout</command> command."
9563 msgstr ""
9565 #. type: Content of: <book><chapter><sect1><sect2><para>
9566 #: ../en/ch08-undo.xml:380
9567 msgid ""
9568 "This makes backing out any changeset a <quote>one-shot</quote> operation "
9569 "that's usually simple and fast."
9570 msgstr ""
9572 #. type: Content of: <book><chapter><sect1><sect2><para>
9573 #: ../en/ch08-undo.xml:386
9574 msgid ""
9575 "If you take a look at the contents of <filename>myfile</filename> after the "
9576 "backout finishes, you'll see that the first and third changes are present, "
9577 "but not the second."
9578 msgstr ""
9580 #. type: Content of: <book><chapter><sect1><sect2><para>
9581 #: ../en/ch08-undo.xml:393
9582 msgid ""
9583 "As the graphical history in <xref linkend=\"fig:undo:backout-non-tip\"/> "
9584 "illustrates, Mercurial actually commits <emphasis>two</emphasis> changes in "
9585 "this kind of situation (the box-shaped nodes are the ones that Mercurial "
9586 "commits automatically). Before Mercurial begins the backout process, it "
9587 "first remembers what the current parent of the working directory is. It then "
9588 "backs out the target changeset, and commits that as a changeset. Finally, it "
9589 "merges back to the previous parent of the working directory, and commits the "
9590 "result of the merge."
9591 msgstr ""
9593 #. type: Content of: <book><chapter><sect1><sect2><para>
9594 #: ../en/ch08-undo.xml:404
9595 msgid ""
9596 "% TODO: to me it looks like mercurial doesn't commit the second merge "
9597 "automatically!"
9598 msgstr ""
9600 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
9601 #: ../en/ch08-undo.xml:408
9602 msgid ""
9603 "Automated backout of a non-tip change using the <command role=\"hg-cmd\">hg "
9604 "backout</command> command"
9605 msgstr "使用 <command role=\"hg-cmd\">hg backout</command> 自动恢复非顶点的修改"
9607 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
9608 #: ../en/ch08-undo.xml:411
9609 msgid ""
9610 "<imageobject><imagedata fileref=\"figs/undo-non-tip.png\"/></imageobject>"
9611 msgstr ""
9613 #. type: Content of: <book><chapter><sect1><sect2><para>
9614 #: ../en/ch08-undo.xml:416
9615 msgid ""
9616 "The result is that you end up <quote>back where you were</quote>, only with "
9617 "some extra history that undoes the effect of the changeset you wanted to back "
9618 "out."
9619 msgstr ""
9621 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
9622 #: ../en/ch08-undo.xml:421
9623 msgid "Always use the <option role=\"hg-opt-backout\">--merge</option> option"
9624 msgstr "始终使用选项 <option role=\"hg-opt-backout\">--merge</option>"
9626 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9627 #: ../en/ch08-undo.xml:424
9628 msgid ""
9629 "In fact, since the <option role=\"hg-opt-backout\">--merge</option> option "
9630 "will do the <quote>right thing</quote> whether or not the changeset you're "
9631 "backing out is the tip (i.e. it won't try to merge if it's backing out the "
9632 "tip, since there's no need), you should <emphasis>always</emphasis> use this "
9633 "option when you run the <command role=\"hg-cmd\">hg backout</command> command."
9634 msgstr ""
9636 #. type: Content of: <book><chapter><sect1><sect2><title>
9637 #: ../en/ch08-undo.xml:435
9638 msgid "Gaining more control of the backout process"
9639 msgstr "在恢复处理中获得更多控制"
9641 #. type: Content of: <book><chapter><sect1><sect2><para>
9642 #: ../en/ch08-undo.xml:437
9643 msgid ""
9644 "While I've recommended that you always use the <option role=\"hg-opt-backout"
9645 "\">--merge</option> option when backing out a change, the <command role=\"hg-"
9646 "cmd\">hg backout</command> command lets you decide how to merge a backout "
9647 "changeset. Taking control of the backout process by hand is something you "
9648 "will rarely need to do, but it can be useful to understand what the <command "
9649 "role=\"hg-cmd\">hg backout</command> command is doing for you automatically. "
9650 "To illustrate this, let's clone our first repository, but omit the backout "
9651 "change that it contains."
9652 msgstr ""
9654 #. type: Content of: <book><chapter><sect1><sect2><para>
9655 #: ../en/ch08-undo.xml:450
9656 msgid ""
9657 "As with our earlier example, We'll commit a third changeset, then back out "
9658 "its parent, and see what happens."
9659 msgstr ""
9661 #. type: Content of: <book><chapter><sect1><sect2><para>
9662 #: ../en/ch08-undo.xml:456
9663 msgid ""
9664 "Our new changeset is again a descendant of the changeset we backout out; it's "
9665 "thus a new head, <emphasis>not</emphasis> a descendant of the changeset that "
9666 "was the tip. The <command role=\"hg-cmd\">hg backout</command> command was "
9667 "quite explicit in telling us this."
9668 msgstr ""
9670 #. type: Content of: <book><chapter><sect1><sect2><para>
9671 #: ../en/ch08-undo.xml:464
9672 msgid ""
9673 "Again, it's easier to see what has happened by looking at a graph of the "
9674 "revision history, in <xref linkend=\"fig:undo:backout-manual\"/>. This makes "
9675 "it clear that when we use <command role=\"hg-cmd\">hg backout</command> to "
9676 "back out a change other than the tip, Mercurial adds a new head to the "
9677 "repository (the change it committed is box-shaped)."
9678 msgstr ""
9680 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
9681 #: ../en/ch08-undo.xml:476
9682 msgid "<imageobject><imagedata fileref=\"figs/undo-manual.png\"/></imageobject>"
9683 msgstr ""
9685 #. type: Content of: <book><chapter><sect1><sect2><para>
9686 #: ../en/ch08-undo.xml:481
9687 msgid ""
9688 "After the <command role=\"hg-cmd\">hg backout</command> command has "
9689 "completed, it leaves the new <quote>backout</quote> changeset as the parent "
9690 "of the working directory."
9691 msgstr ""
9693 #. type: Content of: <book><chapter><sect1><sect2><para>
9694 #: ../en/ch08-undo.xml:488
9695 msgid "Now we have two isolated sets of changes."
9696 msgstr ""
9698 #. type: Content of: <book><chapter><sect1><sect2><para>
9699 #: ../en/ch08-undo.xml:492
9700 msgid ""
9701 "Let's think about what we expect to see as the contents of <filename>myfile</"
9702 "filename> now. The first change should be present, because we've never "
9703 "backed it out. The second change should be missing, as that's the change we "
9704 "backed out. Since the history graph shows the third change as a separate "
9705 "head, we <emphasis>don't</emphasis> expect to see the third change present in "
9706 "<filename>myfile</filename>."
9707 msgstr ""
9709 #. type: Content of: <book><chapter><sect1><sect2><para>
9710 #: ../en/ch08-undo.xml:502
9711 msgid ""
9712 "To get the third change back into the file, we just do a normal merge of our "
9713 "two heads."
9714 msgstr ""
9716 #. type: Content of: <book><chapter><sect1><sect2><para>
9717 #: ../en/ch08-undo.xml:507
9718 msgid ""
9719 "Afterwards, the graphical history of our repository looks like <xref linkend="
9720 "\"fig:undo:backout-manual-merge\"/>."
9721 msgstr ""
9723 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
9724 #: ../en/ch08-undo.xml:512
9725 msgid "Manually merging a backout change"
9726 msgstr "手工合并恢复修改"
9728 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
9729 #: ../en/ch08-undo.xml:514
9730 msgid ""
9731 "<imageobject><imagedata fileref=\"figs/undo-manual-merge.png\"/></imageobject>"
9732 msgstr ""
9734 #. type: Content of: <book><chapter><sect1><sect2><title>
9735 #: ../en/ch08-undo.xml:521
9736 msgid "Why <command role=\"hg-cmd\">hg backout</command> works as it does"
9737 msgstr "<command role=\"hg-cmd\">hg backout</command> 的内幕"
9739 #. type: Content of: <book><chapter><sect1><sect2><para>
9740 #: ../en/ch08-undo.xml:524
9741 msgid ""
9742 "Here's a brief description of how the <command role=\"hg-cmd\">hg backout</"
9743 "command> command works."
9744 msgstr ""
9746 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
9747 #: ../en/ch08-undo.xml:527
9748 msgid ""
9749 "It ensures that the working directory is <quote>clean</quote>, i.e. that the "
9750 "output of <command role=\"hg-cmd\">hg status</command> would be empty."
9751 msgstr ""
9753 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
9754 #: ../en/ch08-undo.xml:531
9755 msgid ""
9756 "It remembers the current parent of the working directory. Let's call this "
9757 "changeset <literal>orig</literal>"
9758 msgstr ""
9760 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
9761 #: ../en/ch08-undo.xml:535
9762 msgid ""
9763 "It does the equivalent of a <command role=\"hg-cmd\">hg update</command> to "
9764 "sync the working directory to the changeset you want to back out. Let's call "
9765 "this changeset <literal>backout</literal>"
9766 msgstr ""
9768 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
9769 #: ../en/ch08-undo.xml:540
9770 msgid ""
9771 "It finds the parent of that changeset. Let's call that changeset "
9772 "<literal>parent</literal>."
9773 msgstr ""
9775 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
9776 #: ../en/ch08-undo.xml:543
9777 msgid ""
9778 "For each file that the <literal>backout</literal> changeset affected, it does "
9779 "the equivalent of a <command role=\"hg-cmd\">hg revert -r parent</command> on "
9780 "that file, to restore it to the contents it had before that changeset was "
9781 "committed."
9782 msgstr ""
9784 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
9785 #: ../en/ch08-undo.xml:550
9786 msgid ""
9787 "It commits the result as a new changeset. This changeset has "
9788 "<literal>backout</literal> as its parent."
9789 msgstr ""
9791 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
9792 #: ../en/ch08-undo.xml:554
9793 msgid ""
9794 "If you specify <option role=\"hg-opt-backout\">--merge</option> on the "
9795 "command line, it merges with <literal>orig</literal>, and commits the result "
9796 "of the merge."
9797 msgstr ""
9799 #. type: Content of: <book><chapter><sect1><sect2><para>
9800 #: ../en/ch08-undo.xml:560
9801 msgid ""
9802 "An alternative way to implement the <command role=\"hg-cmd\">hg backout</"
9803 "command> command would be to <command role=\"hg-cmd\">hg export</command> the "
9804 "to-be-backed-out changeset as a diff, then use the <option role=\"cmd-opt-"
9805 "patch\">--reverse</option> option to the <command>patch</command> command to "
9806 "reverse the effect of the change without fiddling with the working "
9807 "directory. This sounds much simpler, but it would not work nearly as well."
9808 msgstr ""
9810 #. type: Content of: <book><chapter><sect1><sect2><para>
9811 #: ../en/ch08-undo.xml:570
9812 msgid ""
9813 "The reason that <command role=\"hg-cmd\">hg backout</command> does an update, "
9814 "a commit, a merge, and another commit is to give the merge machinery the best "
9815 "chance to do a good job when dealing with all the changes <emphasis>between</"
9816 "emphasis> the change you're backing out and the current tip."
9817 msgstr ""
9819 #. type: Content of: <book><chapter><sect1><sect2><para>
9820 #: ../en/ch08-undo.xml:577
9821 msgid ""
9822 "If you're backing out a changeset that's 100 revisions back in your project's "
9823 "history, the chances that the <command>patch</command> command will be able "
9824 "to apply a reverse diff cleanly are not good, because intervening changes are "
9825 "likely to have <quote>broken the context</quote> that <command>patch</"
9826 "command> uses to determine whether it can apply a patch (if this sounds like "
9827 "gibberish, see <xref linkend=\"sec:mq:patch\"/> for a discussion of the "
9828 "<command>patch</command> command). Also, Mercurial's merge machinery will "
9829 "handle files and directories being renamed, permission changes, and "
9830 "modifications to binary files, none of which <command>patch</command> can "
9831 "deal with."
9832 msgstr ""
9834 #. type: Content of: <book><chapter><sect1><title>
9835 #: ../en/ch08-undo.xml:594
9836 msgid "Changes that should never have been"
9837 msgstr "不该发生的修改"
9839 #. type: Content of: <book><chapter><sect1><para>
9840 #: ../en/ch08-undo.xml:596
9841 msgid ""
9842 "Most of the time, the <command role=\"hg-cmd\">hg backout</command> command "
9843 "is exactly what you need if you want to undo the effects of a change. It "
9844 "leaves a permanent record of exactly what you did, both when committing the "
9845 "original changeset and when you cleaned up after it."
9846 msgstr ""
9848 #. type: Content of: <book><chapter><sect1><para>
9849 #: ../en/ch08-undo.xml:602
9850 msgid ""
9851 "On rare occasions, though, you may find that you've committed a change that "
9852 "really should not be present in the repository at all. For example, it would "
9853 "be very unusual, and usually considered a mistake, to commit a software "
9854 "project's object files as well as its source files. Object files have almost "
9855 "no intrinsic value, and they're <emphasis>big</emphasis>, so they increase "
9856 "the size of the repository and the amount of time it takes to clone or pull "
9857 "changes."
9858 msgstr ""
9860 #. type: Content of: <book><chapter><sect1><para>
9861 #: ../en/ch08-undo.xml:611
9862 msgid ""
9863 "Before I discuss the options that you have if you commit a <quote>brown paper "
9864 "bag</quote> change (the kind that's so bad that you want to pull a brown "
9865 "paper bag over your head), let me first discuss some approaches that probably "
9866 "won't work."
9867 msgstr ""
9869 #. type: Content of: <book><chapter><sect1><para>
9870 #: ../en/ch08-undo.xml:616
9871 msgid ""
9872 "Since Mercurial treats history as accumulative&emdash;every change builds on "
9873 "top of all changes that preceded it&emdash;you generally can't just make "
9874 "disastrous changes disappear. The one exception is when you've just "
9875 "committed a change, and it hasn't been pushed or pulled into another "
9876 "repository. That's when you can safely use the <command role=\"hg-cmd\">hg "
9877 "rollback</command> command, as I detailed in <xref linkend=\"sec:undo:rollback"
9878 "\"/>."
9879 msgstr ""
9881 #. type: Content of: <book><chapter><sect1><para>
9882 #: ../en/ch08-undo.xml:625
9883 msgid ""
9884 "After you've pushed a bad change to another repository, you <emphasis>could</"
9885 "emphasis> still use <command role=\"hg-cmd\">hg rollback</command> to make "
9886 "your local copy of the change disappear, but it won't have the consequences "
9887 "you want. The change will still be present in the remote repository, so it "
9888 "will reappear in your local repository the next time you pull."
9889 msgstr ""
9891 #. type: Content of: <book><chapter><sect1><para>
9892 #: ../en/ch08-undo.xml:633
9893 msgid ""
9894 "If a situation like this arises, and you know which repositories your bad "
9895 "change has propagated into, you can <emphasis>try</emphasis> to get rid of "
9896 "the changeefrom <emphasis>every</emphasis> one of those repositories. This "
9897 "is, of course, not a satisfactory solution: if you miss even a single "
9898 "repository while you're expunging, the change is still <quote>in the wild</"
9899 "quote>, and could propagate further."
9900 msgstr ""
9902 #. type: Content of: <book><chapter><sect1><para>
9903 #: ../en/ch08-undo.xml:641
9904 msgid ""
9905 "If you've committed one or more changes <emphasis>after</emphasis> the change "
9906 "that you'd like to see disappear, your options are further reduced. Mercurial "
9907 "doesn't provide a way to <quote>punch a hole</quote> in history, leaving "
9908 "changesets intact."
9909 msgstr ""
9911 #. type: Content of: <book><chapter><sect1><para>
9912 #: ../en/ch08-undo.xml:647
9913 msgid ""
9914 "XXX This needs filling out. The <literal>hg-replay</literal> script in the "
9915 "<literal>examples</literal> directory works, but doesn't handle merge "
9916 "changesets. Kind of an important omission."
9917 msgstr ""
9919 #. type: Content of: <book><chapter><sect1><sect2><title>
9920 #: ../en/ch08-undo.xml:653
9921 msgid "Protect yourself from <quote>escaped</quote> changes"
9922 msgstr "使用<quote>校验</quote>修改来保护你自己"
9924 #. type: Content of: <book><chapter><sect1><sect2><para>
9925 #: ../en/ch08-undo.xml:656
9926 msgid ""
9927 "If you've committed some changes to your local repository and they've been "
9928 "pushed or pulled somewhere else, this isn't necessarily a disaster. You can "
9929 "protect yourself ahead of time against some classes of bad changeset. This "
9930 "is particularly easy if your team usually pulls changes from a central "
9931 "repository."
9932 msgstr ""
9934 #. type: Content of: <book><chapter><sect1><sect2><para>
9935 #: ../en/ch08-undo.xml:663
9936 msgid ""
9937 "By configuring some hooks on that repository to validate incoming changesets "
9938 "(see chapter <xref linkend=\"chap:hook\"/>), you can automatically prevent "
9939 "some kinds of bad changeset from being pushed to the central repository at "
9940 "all. With such a configuration in place, some kinds of bad changeset will "
9941 "naturally tend to <quote>die out</quote> because they can't propagate into "
9942 "the central repository. Better yet, this happens without any need for "
9943 "explicit intervention."
9944 msgstr ""
9946 #. type: Content of: <book><chapter><sect1><sect2><para>
9947 #: ../en/ch08-undo.xml:673
9948 msgid ""
9949 "For instance, an incoming change hook that verifies that a changeset will "
9950 "actually compile can prevent people from inadvertantly <quote>breaking the "
9951 "build</quote>."
9952 msgstr ""
9954 #. type: Content of: <book><chapter><sect1><title>
9955 #: ../en/ch08-undo.xml:680
9956 msgid "Finding the source of a bug"
9957 msgstr "查找问题的根源"
9959 #. type: Content of: <book><chapter><sect1><para>
9960 #: ../en/ch08-undo.xml:682
9961 msgid ""
9962 "While it's all very well to be able to back out a changeset that introduced a "
9963 "bug, this requires that you know which changeset to back out. Mercurial "
9964 "provides an invaluable command, called <command role=\"hg-cmd\">hg bisect</"
9965 "command>, that helps you to automate this process and accomplish it very "
9966 "efficiently."
9967 msgstr ""
9969 #. type: Content of: <book><chapter><sect1><para>
9970 #: ../en/ch08-undo.xml:689
9971 msgid ""
9972 "The idea behind the <command role=\"hg-cmd\">hg bisect</command> command is "
9973 "that a changeset has introduced some change of behavior that you can identify "
9974 "with a simple binary test. You don't know which piece of code introduced the "
9975 "change, but you know how to test for the presence of the bug. The <command "
9976 "role=\"hg-cmd\">hg bisect</command> command uses your test to direct its "
9977 "search for the changeset that introduced the code that caused the bug."
9978 msgstr ""
9980 #. type: Content of: <book><chapter><sect1><para>
9981 #: ../en/ch08-undo.xml:698
9982 msgid ""
9983 "Here are a few scenarios to help you understand how you might apply this "
9984 "command."
9985 msgstr ""
9987 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
9988 #: ../en/ch08-undo.xml:701
9989 msgid ""
9990 "The most recent version of your software has a bug that you remember wasn't "
9991 "present a few weeks ago, but you don't know when it was introduced. Here, "
9992 "your binary test checks for the presence of that bug."
9993 msgstr ""
9995 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
9996 #: ../en/ch08-undo.xml:706
9997 msgid ""
9998 "You fixed a bug in a rush, and now it's time to close the entry in your "
9999 "team's bug database. The bug database requires a changeset ID when you close "
10000 "an entry, but you don't remember which changeset you fixed the bug in. Once "
10001 "again, your binary test checks for the presence of the bug."
10002 msgstr ""
10004 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10005 #: ../en/ch08-undo.xml:713
10006 msgid ""
10007 "Your software works correctly, but runs 15% slower than the last time you "
10008 "measured it. You want to know which changeset introduced the performance "
10009 "regression. In this case, your binary test measures the performance of your "
10010 "software, to see whether it's <quote>fast</quote> or <quote>slow</quote>."
10011 msgstr ""
10013 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10014 #: ../en/ch08-undo.xml:720
10015 msgid ""
10016 "The sizes of the components of your project that you ship exploded recently, "
10017 "and you suspect that something changed in the way you build your project."
10018 msgstr ""
10020 #. type: Content of: <book><chapter><sect1><para>
10021 #: ../en/ch08-undo.xml:725
10022 msgid ""
10023 "From these examples, it should be clear that the <command role=\"hg-cmd\">hg "
10024 "bisect</command> command is not useful only for finding the sources of bugs. "
10025 "You can use it to find any <quote>emergent property</quote> of a repository "
10026 "(anything that you can't find from a simple text search of the files in the "
10027 "tree) for which you can write a binary test."
10028 msgstr ""
10030 #. type: Content of: <book><chapter><sect1><para>
10031 #: ../en/ch08-undo.xml:732
10032 msgid ""
10033 "We'll introduce a little bit of terminology here, just to make it clear which "
10034 "parts of the search process are your responsibility, and which are "
10035 "Mercurial's. A <emphasis>test</emphasis> is something that <emphasis>you</"
10036 "emphasis> run when <command role=\"hg-cmd\">hg bisect</command> chooses a "
10037 "changeset. A <emphasis>probe</emphasis> is what <command role=\"hg-cmd\">hg "
10038 "bisect</command> runs to tell whether a revision is good. Finally, we'll use "
10039 "the word <quote>bisect</quote>, as both a noun and a verb, to stand in for "
10040 "the phrase <quote>search using the <command role=\"hg-cmd\">hg bisect</"
10041 "command> command</quote>."
10042 msgstr ""
10044 #. type: Content of: <book><chapter><sect1><para>
10045 #: ../en/ch08-undo.xml:745
10046 msgid ""
10047 "One simple way to automate the searching process would be simply to probe "
10048 "every changeset. However, this scales poorly. If it took ten minutes to "
10049 "test a single changeset, and you had 10,000 changesets in your repository, "
10050 "the exhaustive approach would take on average 35 <emphasis>days</emphasis> to "
10051 "find the changeset that introduced a bug. Even if you knew that the bug was "
10052 "introduced by one of the last 500 changesets, and limited your search to "
10053 "those, you'd still be looking at over 40 hours to find the changeset that "
10054 "introduced your bug."
10055 msgstr ""
10057 #. type: Content of: <book><chapter><sect1><para>
10058 #: ../en/ch08-undo.xml:755
10059 msgid ""
10060 "What the <command role=\"hg-cmd\">hg bisect</command> command does is use its "
10061 "knowledge of the <quote>shape</quote> of your project's revision history to "
10062 "perform a search in time proportional to the <emphasis>logarithm</emphasis> "
10063 "of the number of changesets to check (the kind of search it performs is "
10064 "called a dichotomic search). With this approach, searching through 10,000 "
10065 "changesets will take less than three hours, even at ten minutes per test (the "
10066 "search will require about 14 tests). Limit your search to the last hundred "
10067 "changesets, and it will take only about an hour (roughly seven tests)."
10068 msgstr ""
10070 #. type: Content of: <book><chapter><sect1><para>
10071 #: ../en/ch08-undo.xml:766
10072 msgid ""
10073 "The <command role=\"hg-cmd\">hg bisect</command> command is aware of the "
10074 "<quote>branchy</quote> nature of a Mercurial project's revision history, so "
10075 "it has no problems dealing with branches, merges, or multiple heads in a "
10076 "repository. It can prune entire branches of history with a single probe, "
10077 "which is how it operates so efficiently."
10078 msgstr ""
10080 #. type: Content of: <book><chapter><sect1><sect2><title>
10081 #: ../en/ch08-undo.xml:774
10082 msgid "Using the <command role=\"hg-cmd\">hg bisect</command> command"
10083 msgstr "使用命令 <command role=\"hg-cmd\">hg bisect</command>"
10085 #. type: Content of: <book><chapter><sect1><sect2><para>
10086 #: ../en/ch08-undo.xml:777
10087 msgid ""
10088 "Here's an example of <command role=\"hg-cmd\">hg bisect</command> in action."
10089 msgstr ""
10091 #. type: Content of: <book><chapter><sect1><sect2><note><para>
10092 #: ../en/ch08-undo.xml:781
10093 msgid ""
10094 "In versions 0.9.5 and earlier of Mercurial, <command role=\"hg-cmd\">hg "
10095 "bisect</command> was not a core command: it was distributed with Mercurial as "
10096 "an extension. This section describes the built-in command, not the old "
10097 "extension."
10098 msgstr ""
10100 #. type: Content of: <book><chapter><sect1><sect2><para>
10101 #: ../en/ch08-undo.xml:788
10102 msgid ""
10103 "Now let's create a repository, so that we can try out the <command role=\"hg-"
10104 "cmd\">hg bisect</command> command in isolation."
10105 msgstr ""
10107 #. type: Content of: <book><chapter><sect1><sect2><para>
10108 #: ../en/ch08-undo.xml:794
10109 msgid ""
10110 "We'll simulate a project that has a bug in it in a simple-minded way: create "
10111 "trivial changes in a loop, and nominate one specific change that will have "
10112 "the <quote>bug</quote>. This loop creates 35 changesets, each adding a "
10113 "single file to the repository. We'll represent our <quote>bug</quote> with a "
10114 "file that contains the text <quote>i have a gub</quote>."
10115 msgstr ""
10117 #. type: Content of: <book><chapter><sect1><sect2><para>
10118 #: ../en/ch08-undo.xml:804
10119 msgid ""
10120 "The next thing that we'd like to do is figure out how to use the <command "
10121 "role=\"hg-cmd\">hg bisect</command> command. We can use Mercurial's normal "
10122 "built-in help mechanism for this."
10123 msgstr ""
10125 #. type: Content of: <book><chapter><sect1><sect2><para>
10126 #: ../en/ch08-undo.xml:811
10127 msgid ""
10128 "The <command role=\"hg-cmd\">hg bisect</command> command works in steps. "
10129 "Each step proceeds as follows."
10130 msgstr ""
10132 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
10133 #: ../en/ch08-undo.xml:814
10134 msgid "You run your binary test."
10135 msgstr ""
10137 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><itemizedlist><listitem><para>
10138 #: ../en/ch08-undo.xml:816
10139 msgid ""
10140 "If the test succeeded, you tell <command role=\"hg-cmd\">hg bisect</command> "
10141 "by running the <command role=\"hg-cmd\">hg bisect good</command> command."
10142 msgstr ""
10144 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><itemizedlist><listitem><para>
10145 #: ../en/ch08-undo.xml:821
10146 msgid ""
10147 "If it failed, run the <command role=\"hg-cmd\">hg bisect bad</command> "
10148 "command."
10149 msgstr ""
10151 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
10152 #: ../en/ch08-undo.xml:825
10153 msgid ""
10154 "The command uses your information to decide which changeset to test next."
10155 msgstr ""
10157 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
10158 #: ../en/ch08-undo.xml:828
10159 msgid ""
10160 "It updates the working directory to that changeset, and the process begins "
10161 "again."
10162 msgstr ""
10164 #. type: Content of: <book><chapter><sect1><sect2><para>
10165 #: ../en/ch08-undo.xml:831
10166 msgid ""
10167 "The process ends when <command role=\"hg-cmd\">hg bisect</command> identifies "
10168 "a unique changeset that marks the point where your test transitioned from "
10169 "<quote>succeeding</quote> to <quote>failing</quote>."
10170 msgstr ""
10173 #. type: Content of: <book><chapter><sect1><sect2><para>
10174 #: ../en/ch08-undo.xml:836
10175 msgid ""
10176 "To start the search, we must run the <command role=\"hg-cmd\">hg bisect --"
10177 "reset</command> command."
10178 msgstr ""
10180 #. type: Content of: <book><chapter><sect1><sect2><para>
10181 #: ../en/ch08-undo.xml:841
10182 msgid ""
10183 "In our case, the binary test we use is simple: we check to see if any file in "
10184 "the repository contains the string <quote>i have a gub</quote>. If it does, "
10185 "this changeset contains the change that <quote>caused the bug</quote>. By "
10186 "convention, a changeset that has the property we're searching for is "
10187 "<quote>bad</quote>, while one that doesn't is <quote>good</quote>."
10188 msgstr ""
10190 #. type: Content of: <book><chapter><sect1><sect2><para>
10191 #: ../en/ch08-undo.xml:849
10192 msgid ""
10193 "Most of the time, the revision to which the working directory is synced "
10194 "(usually the tip) already exhibits the problem introduced by the buggy "
10195 "change, so we'll mark it as <quote>bad</quote>."
10196 msgstr ""
10199 #. type: Content of: <book><chapter><sect1><sect2><para>
10200 #: ../en/ch08-undo.xml:856
10201 msgid ""
10202 "Our next task is to nominate a changeset that we know <emphasis>doesn't</"
10203 "emphasis> have the bug; the <command role=\"hg-cmd\">hg bisect</command> "
10204 "command will <quote>bracket</quote> its search between the first pair of good "
10205 "and bad changesets. In our case, we know that revision 10 didn't have the "
10206 "bug. (I'll have more words about choosing the first <quote>good</quote> "
10207 "changeset later.)"
10208 msgstr ""
10210 #. type: Content of: <book><chapter><sect1><sect2><para>
10211 #: ../en/ch08-undo.xml:866
10212 msgid "Notice that this command printed some output."
10213 msgstr ""
10215 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
10216 #: ../en/ch08-undo.xml:868
10217 msgid ""
10218 "It told us how many changesets it must consider before it can identify the "
10219 "one that introduced the bug, and how many tests that will require."
10220 msgstr ""
10222 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
10223 #: ../en/ch08-undo.xml:872
10224 msgid ""
10225 "It updated the working directory to the next changeset to test, and told us "
10226 "which changeset it's testing."
10227 msgstr ""
10229 #. type: Content of: <book><chapter><sect1><sect2><para>
10230 #: ../en/ch08-undo.xml:877
10231 msgid ""
10232 "We now run our test in the working directory. We use the <command>grep</"
10233 "command> command to see if our <quote>bad</quote> file is present in the "
10234 "working directory. If it is, this revision is bad; if not, this revision is "
10235 "good. &interaction.bisect.search.step1;"
10236 msgstr ""
10238 #. type: Content of: <book><chapter><sect1><sect2><para>
10239 #: ../en/ch08-undo.xml:883
10240 msgid ""
10241 "This test looks like a perfect candidate for automation, so let's turn it "
10242 "into a shell function."
10243 msgstr ""
10245 #. type: Content of: <book><chapter><sect1><sect2><para>
10246 #: ../en/ch08-undo.xml:887
10247 msgid ""
10248 "We can now run an entire test step with a single command, <literal>mytest</"
10249 "literal>."
10250 msgstr ""
10252 #. type: Content of: <book><chapter><sect1><sect2><para>
10253 #: ../en/ch08-undo.xml:892
10254 msgid "A few more invocations of our canned test step command, and we're done."
10255 msgstr ""
10257 #. type: Content of: <book><chapter><sect1><sect2><para>
10258 #: ../en/ch08-undo.xml:897
10259 msgid ""
10260 "Even though we had 40 changesets to search through, the <command role=\"hg-cmd"
10261 "\">hg bisect</command> command let us find the changeset that introduced our "
10262 "<quote>bug</quote> with only five tests. Because the number of tests that "
10263 "the <command role=\"hg-cmd\">hg bisect</command> command performs grows "
10264 "logarithmically with the number of changesets to search, the advantage that "
10265 "it has over the <quote>brute force</quote> search approach increases with "
10266 "every changeset you add."
10267 msgstr ""
10269 #. type: Content of: <book><chapter><sect1><sect2><title>
10270 #: ../en/ch08-undo.xml:908
10271 msgid "Cleaning up after your search"
10272 msgstr "搜索后的清理"
10275 #. type: Content of: <book><chapter><sect1><sect2><para>
10276 #: ../en/ch08-undo.xml:910
10277 msgid ""
10278 "When you're finished using the <command role=\"hg-cmd\">hg bisect</command> "
10279 "command in a repository, you can use the <command role=\"hg-cmd\">hg bisect "
10280 "reset</command> command to drop the information it was using to drive your "
10281 "search. The command doesn't use much space, so it doesn't matter if you "
10282 "forget to run this command. However, <command role=\"hg-cmd\">hg bisect</"
10283 "command> won't let you start a new search in that repository until you do a "
10284 "<command role=\"hg-cmd\">hg bisect reset</command>."
10285 msgstr ""
10287 #. type: Content of: <book><chapter><sect1><title>
10288 #: ../en/ch08-undo.xml:925
10289 msgid "Tips for finding bugs effectively"
10290 msgstr "有效查找问题的技巧"
10292 #. type: Content of: <book><chapter><sect1><sect2><title>
10293 #: ../en/ch08-undo.xml:928
10294 msgid "Give consistent input"
10295 msgstr "给出一致的输入"
10297 #. type: Content of: <book><chapter><sect1><sect2><para>
10298 #: ../en/ch08-undo.xml:930
10299 msgid ""
10300 "The <command role=\"hg-cmd\">hg bisect</command> command requires that you "
10301 "correctly report the result of every test you perform. If you tell it that a "
10302 "test failed when it really succeeded, it <emphasis>might</emphasis> be able "
10303 "to detect the inconsistency. If it can identify an inconsistency in your "
10304 "reports, it will tell you that a particular changeset is both good and bad. "
10305 "However, it can't do this perfectly; it's about as likely to report the wrong "
10306 "changeset as the source of the bug."
10307 msgstr ""
10309 #. type: Content of: <book><chapter><sect1><sect2><title>
10310 #: ../en/ch08-undo.xml:942
10311 msgid "Automate as much as possible"
10312 msgstr "尽量自动"
10314 #. type: Content of: <book><chapter><sect1><sect2><para>
10315 #: ../en/ch08-undo.xml:944
10316 msgid ""
10317 "When I started using the <command role=\"hg-cmd\">hg bisect</command> "
10318 "command, I tried a few times to run my tests by hand, on the command line. "
10319 "This is an approach that I, at least, am not suited to. After a few tries, I "
10320 "found that I was making enough mistakes that I was having to restart my "
10321 "searches several times before finally getting correct results."
10322 msgstr ""
10324 #. type: Content of: <book><chapter><sect1><sect2><para>
10325 #: ../en/ch08-undo.xml:952
10326 msgid ""
10327 "My initial problems with driving the <command role=\"hg-cmd\">hg bisect</"
10328 "command> command by hand occurred even with simple searches on small "
10329 "repositories; if the problem you're looking for is more subtle, or the number "
10330 "of tests that <command role=\"hg-cmd\">hg bisect</command> must perform "
10331 "increases, the likelihood of operator error ruining the search is much "
10332 "higher. Once I started automating my tests, I had much better results."
10333 msgstr ""
10335 #. type: Content of: <book><chapter><sect1><sect2><para>
10336 #: ../en/ch08-undo.xml:961
10337 msgid "The key to automated testing is twofold:"
10338 msgstr ""
10340 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
10341 #: ../en/ch08-undo.xml:963
10342 msgid "always test for the same symptom, and"
10343 msgstr ""
10345 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
10346 #: ../en/ch08-undo.xml:965
10347 msgid ""
10348 "always feed consistent input to the <command role=\"hg-cmd\">hg bisect</"
10349 "command> command."
10350 msgstr ""
10352 #. type: Content of: <book><chapter><sect1><sect2><para>
10353 #: ../en/ch08-undo.xml:968
10354 msgid ""
10355 "In my tutorial example above, the <command>grep</command> command tests for "
10356 "the symptom, and the <literal>if</literal> statement takes the result of this "
10357 "check and ensures that we always feed the same input to the <command role="
10358 "\"hg-cmd\">hg bisect</command> command. The <literal>mytest</literal> "
10359 "function marries these together in a reproducible way, so that every test is "
10360 "uniform and consistent."
10361 msgstr ""
10363 #. type: Content of: <book><chapter><sect1><sect2><title>
10364 #: ../en/ch08-undo.xml:978
10365 msgid "Check your results"
10366 msgstr "检查你的结果"
10368 #. type: Content of: <book><chapter><sect1><sect2><para>
10369 #: ../en/ch08-undo.xml:980
10370 msgid ""
10371 "Because the output of a <command role=\"hg-cmd\">hg bisect</command> search "
10372 "is only as good as the input you give it, don't take the changeset it reports "
10373 "as the absolute truth. A simple way to cross-check its report is to manually "
10374 "run your test at each of the following changesets:"
10375 msgstr ""
10377 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
10378 #: ../en/ch08-undo.xml:986
10379 msgid ""
10380 "The changeset that it reports as the first bad revision. Your test should "
10381 "still report this as bad."
10382 msgstr ""
10384 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
10385 #: ../en/ch08-undo.xml:990
10386 msgid ""
10387 "The parent of that changeset (either parent, if it's a merge). Your test "
10388 "should report this changeset as good."
10389 msgstr ""
10391 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
10392 #: ../en/ch08-undo.xml:994
10393 msgid ""
10394 "A child of that changeset. Your test should report this changeset as bad."
10395 msgstr ""
10397 #. type: Content of: <book><chapter><sect1><sect2><title>
10398 #: ../en/ch08-undo.xml:1000
10399 msgid "Beware interference between bugs"
10400 msgstr "谨防问题之间的冲突"
10402 #. type: Content of: <book><chapter><sect1><sect2><para>
10403 #: ../en/ch08-undo.xml:1002
10404 msgid ""
10405 "It's possible that your search for one bug could be disrupted by the presence "
10406 "of another. For example, let's say your software crashes at revision 100, "
10407 "and worked correctly at revision 50. Unknown to you, someone else introduced "
10408 "a different crashing bug at revision 60, and fixed it at revision 80. This "
10409 "could distort your results in one of several ways."
10410 msgstr ""
10412 #. type: Content of: <book><chapter><sect1><sect2><para>
10413 #: ../en/ch08-undo.xml:1010
10414 msgid ""
10415 "It is possible that this other bug completely <quote>masks</quote> yours, "
10416 "which is to say that it occurs before your bug has a chance to manifest "
10417 "itself. If you can't avoid that other bug (for example, it prevents your "
10418 "project from building), and so can't tell whether your bug is present in a "
10419 "particular changeset, the <command role=\"hg-cmd\">hg bisect</command> "
10420 "command cannot help you directly. Instead, you can mark a changeset as "
10421 "untested by running <command role=\"hg-cmd\">hg bisect --skip</command>."
10422 msgstr ""
10424 #. type: Content of: <book><chapter><sect1><sect2><para>
10425 #: ../en/ch08-undo.xml:1020
10426 msgid ""
10427 "A different problem could arise if your test for a bug's presence is not "
10428 "specific enough. If you check for <quote>my program crashes</quote>, then "
10429 "both your crashing bug and an unrelated crashing bug that masks it will look "
10430 "like the same thing, and mislead <command role=\"hg-cmd\">hg bisect</command>."
10431 msgstr ""
10433 #. type: Content of: <book><chapter><sect1><sect2><para>
10434 #: ../en/ch08-undo.xml:1027
10435 msgid ""
10436 "Another useful situation in which to use <command role=\"hg-cmd\">hg bisect --"
10437 "skip</command> is if you can't test a revision because your project was in a "
10438 "broken and hence untestable state at that revision, perhaps because someone "
10439 "checked in a change that prevented the project from building."
10440 msgstr ""
10442 #. type: Content of: <book><chapter><sect1><sect2><title>
10443 #: ../en/ch08-undo.xml:1036
10444 msgid "Bracket your search lazily"
10445 msgstr "减少你的查找工作"
10447 #. type: Content of: <book><chapter><sect1><sect2><para>
10448 #: ../en/ch08-undo.xml:1038
10449 msgid ""
10450 "Choosing the first <quote>good</quote> and <quote>bad</quote> changesets that "
10451 "will mark the end points of your search is often easy, but it bears a little "
10452 "discussion nevertheless. From the perspective of <command role=\"hg-cmd\">hg "
10453 "bisect</command>, the <quote>newest</quote> changeset is conventionally "
10454 "<quote>bad</quote>, and the older changeset is <quote>good</quote>."
10455 msgstr ""
10457 #. type: Content of: <book><chapter><sect1><sect2><para>
10458 #: ../en/ch08-undo.xml:1046
10459 msgid ""
10460 "If you're having trouble remembering when a suitable <quote>good</quote> "
10461 "change was, so that you can tell <command role=\"hg-cmd\">hg bisect</"
10462 "command>, you could do worse than testing changesets at random. Just "
10463 "remember to eliminate contenders that can't possibly exhibit the bug (perhaps "
10464 "because the feature with the bug isn't present yet) and those where another "
10465 "problem masks the bug (as I discussed above)."
10466 msgstr ""
10468 #. type: Content of: <book><chapter><sect1><sect2><para>
10469 #: ../en/ch08-undo.xml:1055
10470 msgid ""
10471 "Even if you end up <quote>early</quote> by thousands of changesets or months "
10472 "of history, you will only add a handful of tests to the total number that "
10473 "<command role=\"hg-cmd\">hg bisect</command> must perform, thanks to its "
10474 "logarithmic behavior."
10475 msgstr ""
10477 #. type: Content of: <book><chapter><title>
10478 #: ../en/ch09-hook.xml:5
10479 msgid "Handling repository events with hooks"
10480 msgstr "使用钩子处理版本库事件"
10482 #. type: Content of: <book><chapter><para>
10483 #: ../en/ch09-hook.xml:7
10484 msgid ""
10485 "Mercurial offers a powerful mechanism to let you perform automated actions in "
10486 "response to events that occur in a repository. In some cases, you can even "
10487 "control Mercurial's response to those events."
10488 msgstr ""
10490 #. type: Content of: <book><chapter><para>
10491 #: ../en/ch09-hook.xml:12
10492 msgid ""
10493 "The name Mercurial uses for one of these actions is a <emphasis>hook</"
10494 "emphasis>. Hooks are called <quote>triggers</quote> in some revision control "
10495 "systems, but the two names refer to the same idea."
10496 msgstr ""
10498 #. type: Content of: <book><chapter><sect1><title>
10499 #: ../en/ch09-hook.xml:18
10500 msgid "An overview of hooks in Mercurial"
10501 msgstr "Mercurial 钩子概述"
10503 #. type: Content of: <book><chapter><sect1><para>
10504 #: ../en/ch09-hook.xml:20
10505 msgid ""
10506 "Here is a brief list of the hooks that Mercurial supports. We will revisit "
10507 "each of these hooks in more detail later, in <xref linkend=\"sec:hook:ref\"/>."
10508 msgstr ""
10510 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10511 #: ../en/ch09-hook.xml:25
10512 msgid ""
10513 "<literal role=\"hook\">changegroup</literal>: This is run after a group of "
10514 "changesets has been brought into the repository from elsewhere."
10515 msgstr ""
10517 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10518 #: ../en/ch09-hook.xml:29
10519 msgid ""
10520 "<literal role=\"hook\">commit</literal>: This is run after a new changeset "
10521 "has been created in the local repository."
10522 msgstr ""
10524 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10525 #: ../en/ch09-hook.xml:33
10526 msgid ""
10527 "<literal role=\"hook\">incoming</literal>: This is run once for each new "
10528 "changeset that is brought into the repository from elsewhere. Notice the "
10529 "difference from <literal role=\"hook\">changegroup</literal>, which is run "
10530 "once per <emphasis>group</emphasis> of changesets brought in."
10531 msgstr ""
10533 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10534 #: ../en/ch09-hook.xml:40
10535 msgid ""
10536 "<literal role=\"hook\">outgoing</literal>: This is run after a group of "
10537 "changesets has been transmitted from this repository."
10538 msgstr ""
10540 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10541 #: ../en/ch09-hook.xml:44
10542 msgid ""
10543 "<literal role=\"hook\">prechangegroup</literal>: This is run before starting "
10544 "to bring a group of changesets into the repository."
10545 msgstr ""
10547 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10548 #: ../en/ch09-hook.xml:49
10549 msgid ""
10550 "<literal role=\"hook\">precommit</literal>: Controlling. This is run before "
10551 "starting a commit."
10552 msgstr ""
10554 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10555 #: ../en/ch09-hook.xml:53
10556 msgid ""
10557 "<literal role=\"hook\">preoutgoing</literal>: Controlling. This is run before "
10558 "starting to transmit a group of changesets from this repository."
10559 msgstr ""
10561 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10562 #: ../en/ch09-hook.xml:58
10563 msgid ""
10564 "<literal role=\"hook\">pretag</literal>: Controlling. This is run before "
10565 "creating a tag."
10566 msgstr ""
10568 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10569 #: ../en/ch09-hook.xml:62
10570 msgid ""
10571 "<literal role=\"hook\">pretxnchangegroup</literal>: Controlling. This is run "
10572 "after a group of changesets has been brought into the local repository from "
10573 "another, but before the transaction completes that will make the changes "
10574 "permanent in the repository."
10575 msgstr ""
10577 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10578 #: ../en/ch09-hook.xml:70
10579 msgid ""
10580 "<literal role=\"hook\">pretxncommit</literal>: Controlling. This is run after "
10581 "a new changeset has been created in the local repository, but before the "
10582 "transaction completes that will make it permanent."
10583 msgstr ""
10585 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10586 #: ../en/ch09-hook.xml:76
10587 msgid ""
10588 "<literal role=\"hook\">preupdate</literal>: Controlling. This is run before "
10589 "starting an update or merge of the working directory."
10590 msgstr ""
10592 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10593 #: ../en/ch09-hook.xml:81
10594 msgid ""
10595 "<literal role=\"hook\">tag</literal>: This is run after a tag is created."
10596 msgstr ""
10598 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10599 #: ../en/ch09-hook.xml:85
10600 msgid ""
10601 "<literal role=\"hook\">update</literal>: This is run after an update or merge "
10602 "of the working directory has finished."
10603 msgstr ""
10605 #. type: Content of: <book><chapter><sect1><para>
10606 #: ../en/ch09-hook.xml:90
10607 msgid ""
10608 "Each of the hooks whose description begins with the word <quote>Controlling</"
10609 "quote> has the ability to determine whether an activity can proceed. If the "
10610 "hook succeeds, the activity may proceed; if it fails, the activity is either "
10611 "not permitted or undone, depending on the hook."
10612 msgstr ""
10614 #. type: Content of: <book><chapter><sect1><title>
10615 #: ../en/ch09-hook.xml:99
10616 msgid "Hooks and security"
10617 msgstr "钩子与安全性"
10619 #. type: Content of: <book><chapter><sect1><sect2><title>
10620 #: ../en/ch09-hook.xml:102
10621 msgid "Hooks are run with your privileges"
10622 msgstr "钩子以你的特权执行"
10624 #. type: Content of: <book><chapter><sect1><sect2><para>
10625 #: ../en/ch09-hook.xml:104
10626 msgid ""
10627 "When you run a Mercurial command in a repository, and the command causes a "
10628 "hook to run, that hook runs on <emphasis>your</emphasis> system, under "
10629 "<emphasis>your</emphasis> user account, with <emphasis>your</emphasis> "
10630 "privilege level. Since hooks are arbitrary pieces of executable code, you "
10631 "should treat them with an appropriate level of suspicion. Do not install a "
10632 "hook unless you are confident that you know who created it and what it does."
10633 msgstr ""
10635 #. type: Content of: <book><chapter><sect1><sect2><para>
10636 #: ../en/ch09-hook.xml:115
10637 msgid ""
10638 "In some cases, you may be exposed to hooks that you did not install "
10639 "yourself. If you work with Mercurial on an unfamiliar system, Mercurial will "
10640 "run hooks defined in that system's global <filename role=\"special\">~/.hgrc</"
10641 "filename> file."
10642 msgstr ""
10644 #. type: Content of: <book><chapter><sect1><sect2><para>
10645 #: ../en/ch09-hook.xml:122
10646 msgid ""
10647 "If you are working with a repository owned by another user, Mercurial can run "
10648 "hooks defined in that user's repository, but it will still run them as "
10649 "<quote>you</quote>. For example, if you <command role=\"hg-cmd\">hg pull</"
10650 "command> from that repository, and its <filename role=\"special\">.hg/hgrc</"
10651 "filename> defines a local <literal role=\"hook\">outgoing</literal> hook, "
10652 "that hook will run under your user account, even though you don't own that "
10653 "repository."
10654 msgstr ""
10656 #. type: Content of: <book><chapter><sect1><sect2><note><para>
10657 #: ../en/ch09-hook.xml:134
10658 msgid ""
10659 "This only applies if you are pulling from a repository on a local or network "
10660 "filesystem. If you're pulling over http or ssh, any <literal role=\"hook"
10661 "\">outgoing</literal> hook will run under whatever account is executing the "
10662 "server process, on the server."
10663 msgstr ""
10665 #. type: Content of: <book><chapter><sect1><sect2><para>
10666 #: ../en/ch09-hook.xml:142
10667 msgid ""
10668 "XXX To see what hooks are defined in a repository, use the <command role=\"hg-"
10669 "cmd\">hg config hooks</command> command. If you are working in one "
10670 "repository, but talking to another that you do not own (e.g. using <command "
10671 "role=\"hg-cmd\">hg pull</command> or <command role=\"hg-cmd\">hg incoming</"
10672 "command>), remember that it is the other repository's hooks you should be "
10673 "checking, not your own."
10674 msgstr ""
10676 #. type: Content of: <book><chapter><sect1><sect2><title>
10677 #: ../en/ch09-hook.xml:153
10678 msgid "Hooks do not propagate"
10679 msgstr "钩子不会传播"
10681 #. type: Content of: <book><chapter><sect1><sect2><para>
10682 #: ../en/ch09-hook.xml:155
10683 msgid ""
10684 "In Mercurial, hooks are not revision controlled, and do not propagate when "
10685 "you clone, or pull from, a repository. The reason for this is simple: a hook "
10686 "is a completely arbitrary piece of executable code. It runs under your user "
10687 "identity, with your privilege level, on your machine."
10688 msgstr ""
10690 #. type: Content of: <book><chapter><sect1><sect2><para>
10691 #: ../en/ch09-hook.xml:162
10692 msgid ""
10693 "It would be extremely reckless for any distributed revision control system to "
10694 "implement revision-controlled hooks, as this would offer an easily "
10695 "exploitable way to subvert the accounts of users of the revision control "
10696 "system."
10697 msgstr ""
10699 #. type: Content of: <book><chapter><sect1><sect2><para>
10700 #: ../en/ch09-hook.xml:168
10701 msgid ""
10702 "Since Mercurial does not propagate hooks, if you are collaborating with other "
10703 "people on a common project, you should not assume that they are using the "
10704 "same Mercurial hooks as you are, or that theirs are correctly configured. "
10705 "You should document the hooks you expect people to use."
10706 msgstr ""
10708 #. type: Content of: <book><chapter><sect1><sect2><para>
10709 #: ../en/ch09-hook.xml:175
10710 msgid ""
10711 "In a corporate intranet, this is somewhat easier to control, as you can for "
10712 "example provide a <quote>standard</quote> installation of Mercurial on an NFS "
10713 "filesystem, and use a site-wide <filename role=\"special\">~/.hgrc</filename> "
10714 "file to define hooks that all users will see. However, this too has its "
10715 "limits; see below."
10716 msgstr ""
10718 #. type: Content of: <book><chapter><sect1><sect2><title>
10719 #: ../en/ch09-hook.xml:184
10720 msgid "Hooks can be overridden"
10721 msgstr "钩子可以被覆盖"
10723 #. type: Content of: <book><chapter><sect1><sect2><para>
10724 #: ../en/ch09-hook.xml:186
10725 msgid ""
10726 "Mercurial allows you to override a hook definition by redefining the hook. "
10727 "You can disable it by setting its value to the empty string, or change its "
10728 "behavior as you wish."
10729 msgstr ""
10731 #. type: Content of: <book><chapter><sect1><sect2><para>
10732 #: ../en/ch09-hook.xml:191
10733 msgid ""
10734 "If you deploy a system- or site-wide <filename role=\"special\">~/.hgrc</"
10735 "filename> file that defines some hooks, you should thus understand that your "
10736 "users can disable or override those hooks."
10737 msgstr ""
10739 #. type: Content of: <book><chapter><sect1><sect2><title>
10740 #: ../en/ch09-hook.xml:199
10741 msgid "Ensuring that critical hooks are run"
10742 msgstr "确保关键钩子的执行"
10744 #. type: Content of: <book><chapter><sect1><sect2><para>
10745 #: ../en/ch09-hook.xml:201
10746 msgid ""
10747 "Sometimes you may want to enforce a policy that you do not want others to be "
10748 "able to work around. For example, you may have a requirement that every "
10749 "changeset must pass a rigorous set of tests. Defining this requirement via a "
10750 "hook in a site-wide <filename role=\"special\">~/.hgrc</filename> won't work "
10751 "for remote users on laptops, and of course local users can subvert it at will "
10752 "by overriding the hook."
10753 msgstr ""
10755 #. type: Content of: <book><chapter><sect1><sect2><para>
10756 #: ../en/ch09-hook.xml:210
10757 msgid ""
10758 "Instead, you can set up your policies for use of Mercurial so that people are "
10759 "expected to propagate changes through a well-known <quote>canonical</quote> "
10760 "server that you have locked down and configured appropriately."
10761 msgstr ""
10763 #. type: Content of: <book><chapter><sect1><sect2><para>
10764 #: ../en/ch09-hook.xml:216
10765 msgid ""
10766 "One way to do this is via a combination of social engineering and "
10767 "technology. Set up a restricted-access account; users can push changes over "
10768 "the network to repositories managed by this account, but they cannot log into "
10769 "the account and run normal shell commands. In this scenario, a user can "
10770 "commit a changeset that contains any old garbage they want."
10771 msgstr ""
10773 #. type: Content of: <book><chapter><sect1><sect2><para>
10774 #: ../en/ch09-hook.xml:225
10775 msgid ""
10776 "When someone pushes a changeset to the server that everyone pulls from, the "
10777 "server will test the changeset before it accepts it as permanent, and reject "
10778 "it if it fails to pass the test suite. If people only pull changes from this "
10779 "filtering server, it will serve to ensure that all changes that people pull "
10780 "have been automatically vetted."
10781 msgstr ""
10783 #. type: Content of: <book><chapter><sect1><title>
10784 #: ../en/ch09-hook.xml:236
10785 msgid "Care with <literal>pretxn</literal> hooks in a shared-access repository"
10786 msgstr "在共享版本库中注意 <literal>pretxn</literal> 钩子"
10788 #. type: Content of: <book><chapter><sect1><para>
10789 #: ../en/ch09-hook.xml:239
10790 msgid ""
10791 "If you want to use hooks to do some automated work in a repository that a "
10792 "number of people have shared access to, you need to be careful in how you do "
10793 "this."
10794 msgstr ""
10796 #. type: Content of: <book><chapter><sect1><para>
10797 #: ../en/ch09-hook.xml:244
10798 msgid ""
10799 "Mercurial only locks a repository when it is writing to the repository, and "
10800 "only the parts of Mercurial that write to the repository pay attention to "
10801 "locks. Write locks are necessary to prevent multiple simultaneous writers "
10802 "from scribbling on each other's work, corrupting the repository."
10803 msgstr ""
10805 #. type: Content of: <book><chapter><sect1><para>
10806 #: ../en/ch09-hook.xml:251
10807 msgid ""
10808 "Because Mercurial is careful with the order in which it reads and writes "
10809 "data, it does not need to acquire a lock when it wants to read data from the "
10810 "repository. The parts of Mercurial that read from the repository never pay "
10811 "attention to locks. This lockless reading scheme greatly increases "
10812 "performance and concurrency."
10813 msgstr ""
10815 #. type: Content of: <book><chapter><sect1><para>
10816 #: ../en/ch09-hook.xml:259
10817 msgid ""
10818 "With great performance comes a trade-off, though, one which has the potential "
10819 "to cause you trouble unless you're aware of it. To describe this requires a "
10820 "little detail about how Mercurial adds changesets to a repository and reads "
10821 "those changes."
10822 msgstr ""
10824 #. type: Content of: <book><chapter><sect1><para>
10825 #: ../en/ch09-hook.xml:266
10826 msgid ""
10827 "When Mercurial <emphasis>writes</emphasis> metadata, it writes it straight "
10828 "into the destination file. It writes file data first, then manifest data "
10829 "(which contains pointers to the new file data), then changelog data (which "
10830 "contains pointers to the new manifest data). Before the first write to each "
10831 "file, it stores a record of where the end of the file was in its transaction "
10832 "log. If the transaction must be rolled back, Mercurial simply truncates each "
10833 "file back to the size it was before the transaction began."
10834 msgstr ""
10836 #. type: Content of: <book><chapter><sect1><para>
10837 #: ../en/ch09-hook.xml:277
10838 msgid ""
10839 "When Mercurial <emphasis>reads</emphasis> metadata, it reads the changelog "
10840 "first, then everything else. Since a reader will only access parts of the "
10841 "manifest or file metadata that it can see in the changelog, it can never see "
10842 "partially written data."
10843 msgstr ""
10845 #. type: Content of: <book><chapter><sect1><para>
10846 #: ../en/ch09-hook.xml:283
10847 msgid ""
10848 "Some controlling hooks (<literal role=\"hook\">pretxncommit</literal> and "
10849 "<literal role=\"hook\">pretxnchangegroup</literal>) run when a transaction is "
10850 "almost complete. All of the metadata has been written, but Mercurial can "
10851 "still roll the transaction back and cause the newly-written data to disappear."
10852 msgstr ""
10854 #. type: Content of: <book><chapter><sect1><para>
10855 #: ../en/ch09-hook.xml:291
10856 msgid ""
10857 "If one of these hooks runs for long, it opens a window of time during which a "
10858 "reader can see the metadata for changesets that are not yet permanent, and "
10859 "should not be thought of as <quote>really there</quote>. The longer the hook "
10860 "runs, the longer that window is open."
10861 msgstr ""
10863 #. type: Content of: <book><chapter><sect1><sect2><title>
10864 #: ../en/ch09-hook.xml:299
10865 msgid "The problem illustrated"
10866 msgstr "问题的演示"
10868 #. type: Content of: <book><chapter><sect1><sect2><para>
10869 #: ../en/ch09-hook.xml:301
10870 msgid ""
10871 "In principle, a good use for the <literal role=\"hook\">pretxnchangegroup</"
10872 "literal> hook would be to automatically build and test incoming changes "
10873 "before they are accepted into a central repository. This could let you "
10874 "guarantee that nobody can push changes to this repository that <quote>break "
10875 "the build</quote>. But if a client can pull changes while they're being "
10876 "tested, the usefulness of the test is zero; an unsuspecting someone can pull "
10877 "untested changes, potentially breaking their build."
10878 msgstr ""
10880 #. type: Content of: <book><chapter><sect1><sect2><para>
10881 #: ../en/ch09-hook.xml:312
10882 msgid ""
10883 "The safest technological answer to this challenge is to set up such a "
10884 "<quote>gatekeeper</quote> repository as <emphasis>unidirectional</emphasis>. "
10885 "Let it take changes pushed in from the outside, but do not allow anyone to "
10886 "pull changes from it (use the <literal role=\"hook\">preoutgoing</literal> "
10887 "hook to lock it down). Configure a <literal role=\"hook\">changegroup</"
10888 "literal> hook so that if a build or test succeeds, the hook will push the new "
10889 "changes out to another repository that people <emphasis>can</emphasis> pull "
10890 "from."
10891 msgstr ""
10893 #. type: Content of: <book><chapter><sect1><sect2><para>
10894 #: ../en/ch09-hook.xml:324
10895 msgid ""
10896 "In practice, putting a centralised bottleneck like this in place is not often "
10897 "a good idea, and transaction visibility has nothing to do with the problem. "
10898 "As the size of a project&emdash;and the time it takes to build and "
10899 "test&emdash;grows, you rapidly run into a wall with this <quote>try before "
10900 "you buy</quote> approach, where you have more changesets to test than time in "
10901 "which to deal with them. The inevitable result is frustration on the part of "
10902 "all involved."
10903 msgstr ""
10905 #. type: Content of: <book><chapter><sect1><sect2><para>
10906 #: ../en/ch09-hook.xml:335
10907 msgid ""
10908 "An approach that scales better is to get people to build and test before they "
10909 "push, then run automated builds and tests centrally <emphasis>after</"
10910 "emphasis> a push, to be sure all is well. The advantage of this approach is "
10911 "that it does not impose a limit on the rate at which the repository can "
10912 "accept changes."
10913 msgstr ""
10915 #. type: Content of: <book><chapter><sect1><title>
10916 #: ../en/ch09-hook.xml:346
10917 msgid "A short tutorial on using hooks"
10918 msgstr "使用钩子的简短指南"
10920 #. type: Content of: <book><chapter><sect1><para>
10921 #: ../en/ch09-hook.xml:348
10922 msgid ""
10923 "It is easy to write a Mercurial hook. Let's start with a hook that runs when "
10924 "you finish a <command role=\"hg-cmd\">hg commit</command>, and simply prints "
10925 "the hash of the changeset you just created. The hook is called <literal role="
10926 "\"hook\">commit</literal>."
10927 msgstr ""
10929 #. type: Content of: <book><chapter><sect1><para>
10930 #: ../en/ch09-hook.xml:355
10931 msgid "All hooks follow the pattern in this example."
10932 msgstr ""
10934 #. type: Content of: <book><chapter><sect1><para>
10935 #: ../en/ch09-hook.xml:359
10936 msgid ""
10937 "You add an entry to the <literal role=\"rc-hooks\">hooks</literal> section of "
10938 "your <filename role=\"special\">~/.hgrc</filename>. On the left is the name "
10939 "of the event to trigger on; on the right is the action to take. As you can "
10940 "see, you can run an arbitrary shell command in a hook. Mercurial passes "
10941 "extra information to the hook using environment variables (look for "
10942 "<envar>HG_NODE</envar> in the example)."
10943 msgstr ""
10945 #. type: Content of: <book><chapter><sect1><sect2><title>
10946 #: ../en/ch09-hook.xml:369
10947 msgid "Performing multiple actions per event"
10948 msgstr "每个事件执行多个操作"
10950 #. type: Content of: <book><chapter><sect1><sect2><para>
10951 #: ../en/ch09-hook.xml:371
10952 msgid ""
10953 "Quite often, you will want to define more than one hook for a particular kind "
10954 "of event, as shown below."
10955 msgstr ""
10957 #. type: Content of: <book><chapter><sect1><sect2><para>
10958 #: ../en/ch09-hook.xml:376
10959 msgid ""
10960 "Mercurial lets you do this by adding an <emphasis>extension</emphasis> to the "
10961 "end of a hook's name. You extend a hook's name by giving the name of the "
10962 "hook, followed by a full stop (the <quote><literal>.</literal></quote> "
10963 "character), followed by some more text of your choosing. For example, "
10964 "Mercurial will run both <literal>commit.foo</literal> and <literal>commit."
10965 "bar</literal> when the <literal>commit</literal> event occurs."
10966 msgstr ""
10968 #. type: Content of: <book><chapter><sect1><sect2><para>
10969 #: ../en/ch09-hook.xml:387
10970 msgid ""
10971 "To give a well-defined order of execution when there are multiple hooks "
10972 "defined for an event, Mercurial sorts hooks by extension, and executes the "
10973 "hook commands in this sorted order. In the above example, it will execute "
10974 "<literal>commit.bar</literal> before <literal>commit.foo</literal>, and "
10975 "<literal>commit</literal> before both."
10976 msgstr ""
10978 #. type: Content of: <book><chapter><sect1><sect2><para>
10979 #: ../en/ch09-hook.xml:396
10980 msgid ""
10981 "It is a good idea to use a somewhat descriptive extension when you define a "
10982 "new hook. This will help you to remember what the hook was for. If the hook "
10983 "fails, you'll get an error message that contains the hook name and extension, "
10984 "so using a descriptive extension could give you an immediate hint as to why "
10985 "the hook failed (see <xref linkend=\"sec:hook:perm\"/> for an example)."
10986 msgstr ""
10988 #. type: Content of: <book><chapter><sect1><sect2><title>
10989 #: ../en/ch09-hook.xml:407
10990 msgid "Controlling whether an activity can proceed"
10991 msgstr "控制处理的活动"
10993 #. type: Content of: <book><chapter><sect1><sect2><para>
10994 #: ../en/ch09-hook.xml:409
10995 msgid ""
10996 "In our earlier examples, we used the <literal role=\"hook\">commit</literal> "
10997 "hook, which is run after a commit has completed. This is one of several "
10998 "Mercurial hooks that run after an activity finishes. Such hooks have no way "
10999 "of influencing the activity itself."
11000 msgstr ""
11002 #. type: Content of: <book><chapter><sect1><sect2><para>
11003 #: ../en/ch09-hook.xml:416
11004 msgid ""
11005 "Mercurial defines a number of events that occur before an activity starts; or "
11006 "after it starts, but before it finishes. Hooks that trigger on these events "
11007 "have the added ability to choose whether the activity can continue, or will "
11008 "abort."
11009 msgstr ""
11011 #. type: Content of: <book><chapter><sect1><sect2><para>
11012 #: ../en/ch09-hook.xml:422
11013 msgid ""
11014 "The <literal role=\"hook\">pretxncommit</literal> hook runs after a commit "
11015 "has all but completed. In other words, the metadata representing the "
11016 "changeset has been written out to disk, but the transaction has not yet been "
11017 "allowed to complete. The <literal role=\"hook\">pretxncommit</literal> hook "
11018 "has the ability to decide whether the transaction can complete, or must be "
11019 "rolled back."
11020 msgstr ""
11022 #. type: Content of: <book><chapter><sect1><sect2><para>
11023 #: ../en/ch09-hook.xml:431
11024 msgid ""
11025 "If the <literal role=\"hook\">pretxncommit</literal> hook exits with a status "
11026 "code of zero, the transaction is allowed to complete; the commit finishes; "
11027 "and the <literal role=\"hook\">commit</literal> hook is run. If the <literal "
11028 "role=\"hook\">pretxncommit</literal> hook exits with a non-zero status code, "
11029 "the transaction is rolled back; the metadata representing the changeset is "
11030 "erased; and the <literal role=\"hook\">commit</literal> hook is not run."
11031 msgstr ""
11033 #. type: Content of: <book><chapter><sect1><sect2><para>
11034 #: ../en/ch09-hook.xml:443
11035 msgid ""
11036 "The hook in the example above checks that a commit comment contains a bug "
11037 "ID. If it does, the commit can complete. If not, the commit is rolled back."
11038 msgstr ""
11040 #. type: Content of: <book><chapter><sect1><title>
11041 #: ../en/ch09-hook.xml:451
11042 msgid "Writing your own hooks"
11043 msgstr "编写钩子"
11045 #. type: Content of: <book><chapter><sect1><para>
11046 #: ../en/ch09-hook.xml:453
11047 msgid ""
11048 "When you are writing a hook, you might find it useful to run Mercurial either "
11049 "with the <option role=\"hg-opt-global\">-v</option> option, or the <envar "
11050 "role=\"rc-item-ui\">verbose</envar> config item set to <quote>true</quote>. "
11051 "When you do so, Mercurial will print a message before it calls each hook."
11052 msgstr ""
11054 #. type: Content of: <book><chapter><sect1><sect2><title>
11055 #: ../en/ch09-hook.xml:462
11056 msgid "Choosing how your hook should run"
11057 msgstr "选择钩子的执行方式"
11059 #. type: Content of: <book><chapter><sect1><sect2><para>
11060 #: ../en/ch09-hook.xml:464
11061 msgid ""
11062 "You can write a hook either as a normal program&emdash;typically a shell "
11063 "script&emdash;or as a Python function that is executed within the Mercurial "
11064 "process."
11065 msgstr ""
11067 #. type: Content of: <book><chapter><sect1><sect2><para>
11068 #: ../en/ch09-hook.xml:469
11069 msgid ""
11070 "Writing a hook as an external program has the advantage that it requires no "
11071 "knowledge of Mercurial's internals. You can call normal Mercurial commands "
11072 "to get any added information you need. The trade-off is that external hooks "
11073 "are slower than in-process hooks."
11074 msgstr ""
11076 #. type: Content of: <book><chapter><sect1><sect2><para>
11077 #: ../en/ch09-hook.xml:476
11078 msgid ""
11079 "An in-process Python hook has complete access to the Mercurial API, and does "
11080 "not <quote>shell out</quote> to another process, so it is inherently faster "
11081 "than an external hook. It is also easier to obtain much of the information "
11082 "that a hook requires by using the Mercurial API than by running Mercurial "
11083 "commands."
11084 msgstr ""
11086 #. type: Content of: <book><chapter><sect1><sect2><para>
11087 #: ../en/ch09-hook.xml:484
11088 msgid ""
11089 "If you are comfortable with Python, or require high performance, writing your "
11090 "hooks in Python may be a good choice. However, when you have a "
11091 "straightforward hook to write and you don't need to care about performance "
11092 "(probably the majority of hooks), a shell script is perfectly fine."
11093 msgstr ""
11095 #. type: Content of: <book><chapter><sect1><sect2><title>
11096 #: ../en/ch09-hook.xml:493
11097 msgid "Hook parameters"
11098 msgstr "钩子的参数"
11100 #. type: Content of: <book><chapter><sect1><sect2><para>
11101 #: ../en/ch09-hook.xml:495
11102 msgid ""
11103 "Mercurial calls each hook with a set of well-defined parameters. In Python, "
11104 "a parameter is passed as a keyword argument to your hook function. For an "
11105 "external program, a parameter is passed as an environment variable."
11106 msgstr ""
11108 #. type: Content of: <book><chapter><sect1><sect2><para>
11109 #: ../en/ch09-hook.xml:501
11110 msgid ""
11111 "Whether your hook is written in Python or as a shell script, the hook-"
11112 "specific parameter names and values will be the same. A boolean parameter "
11113 "will be represented as a boolean value in Python, but as the number 1 (for "
11114 "<quote>true</quote>) or 0 (for <quote>false</quote>) as an environment "
11115 "variable for an external hook. If a hook parameter is named <literal>foo</"
11116 "literal>, the keyword argument for a Python hook will also be named "
11117 "<literal>foo</literal>, while the environment variable for an external hook "
11118 "will be named <literal>HG_FOO</literal>."
11119 msgstr ""
11121 #. type: Content of: <book><chapter><sect1><sect2><title>
11122 #: ../en/ch09-hook.xml:515
11123 msgid "Hook return values and activity control"
11124 msgstr "钩子的返回值与活动控制"
11126 #. type: Content of: <book><chapter><sect1><sect2><para>
11127 #: ../en/ch09-hook.xml:517
11128 msgid ""
11129 "A hook that executes successfully must exit with a status of zero if "
11130 "external, or return boolean <quote>false</quote> if in-process. Failure is "
11131 "indicated with a non-zero exit status from an external hook, or an in-process "
11132 "hook returning boolean <quote>true</quote>. If an in-process hook raises an "
11133 "exception, the hook is considered to have failed."
11134 msgstr ""
11136 #. type: Content of: <book><chapter><sect1><sect2><para>
11137 #: ../en/ch09-hook.xml:525
11138 msgid ""
11139 "For a hook that controls whether an activity can proceed, zero/false means "
11140 "<quote>allow</quote>, while non-zero/true/exception means <quote>deny</quote>."
11141 msgstr ""
11143 #. type: Content of: <book><chapter><sect1><sect2><title>
11144 #: ../en/ch09-hook.xml:532
11145 msgid "Writing an external hook"
11146 msgstr "编写外部钩子"
11148 #. type: Content of: <book><chapter><sect1><sect2><para>
11149 #: ../en/ch09-hook.xml:534
11150 msgid ""
11151 "When you define an external hook in your <filename role=\"special\">~/.hgrc</"
11152 "filename> and the hook is run, its value is passed to your shell, which "
11153 "interprets it. This means that you can use normal shell constructs in the "
11154 "body of the hook."
11155 msgstr ""
11157 #. type: Content of: <book><chapter><sect1><sect2><para>
11158 #: ../en/ch09-hook.xml:541
11159 msgid ""
11160 "An executable hook is always run with its current directory set to a "
11161 "repository's root directory."
11162 msgstr ""
11164 #. type: Content of: <book><chapter><sect1><sect2><para>
11165 #: ../en/ch09-hook.xml:545
11166 msgid ""
11167 "Each hook parameter is passed in as an environment variable; the name is "
11168 "upper-cased, and prefixed with the string <quote><literal>HG_</literal></"
11169 "quote>."
11170 msgstr ""
11172 #. type: Content of: <book><chapter><sect1><sect2><para>
11173 #: ../en/ch09-hook.xml:550
11174 msgid ""
11175 "With the exception of hook parameters, Mercurial does not set or modify any "
11176 "environment variables when running a hook. This is useful to remember if you "
11177 "are writing a site-wide hook that may be run by a number of different users "
11178 "with differing environment variables set. In multi-user situations, you "
11179 "should not rely on environment variables being set to the values you have in "
11180 "your environment when testing the hook."
11181 msgstr ""
11183 #. type: Content of: <book><chapter><sect1><sect2><title>
11184 #: ../en/ch09-hook.xml:561
11185 msgid "Telling Mercurial to use an in-process hook"
11186 msgstr "让 Mercurial 使用进程内钩子"
11188 #. type: Content of: <book><chapter><sect1><sect2><para>
11189 #: ../en/ch09-hook.xml:563
11190 msgid ""
11191 "The <filename role=\"special\">~/.hgrc</filename> syntax for defining an in-"
11192 "process hook is slightly different than for an executable hook. The value of "
11193 "the hook must start with the text <quote><literal>python:</literal></quote>, "
11194 "and continue with the fully-qualified name of a callable object to use as the "
11195 "hook's value."
11196 msgstr ""
11198 #. type: Content of: <book><chapter><sect1><sect2><para>
11199 #: ../en/ch09-hook.xml:571
11200 msgid ""
11201 "The module in which a hook lives is automatically imported when a hook is "
11202 "run. So long as you have the module name and <envar>PYTHONPATH</envar> "
11203 "right, it should <quote>just work</quote>."
11204 msgstr ""
11206 #. type: Content of: <book><chapter><sect1><sect2><para>
11207 #: ../en/ch09-hook.xml:577
11208 msgid ""
11209 "The following <filename role=\"special\">~/.hgrc</filename> example snippet "
11210 "illustrates the syntax and meaning of the notions we just described."
11211 msgstr ""
11213 #. type: Content of: <book><chapter><sect1><sect2><para>
11214 #: ../en/ch09-hook.xml:583
11215 msgid ""
11216 "When Mercurial runs the <literal>commit.example</literal> hook, it imports "
11217 "<literal>mymodule.submodule</literal>, looks for the callable object named "
11218 "<literal>myhook</literal>, and calls it."
11219 msgstr ""
11221 #. type: Content of: <book><chapter><sect1><sect2><title>
11222 #: ../en/ch09-hook.xml:591
11223 msgid "Writing an in-process hook"
11224 msgstr "编写进程内钩子"
11226 #. type: Content of: <book><chapter><sect1><sect2><para>
11227 #: ../en/ch09-hook.xml:593
11228 msgid ""
11229 "The simplest in-process hook does nothing, but illustrates the basic shape of "
11230 "the hook API:"
11231 msgstr ""
11233 #. type: Content of: <book><chapter><sect1><sect2><para>
11234 #: ../en/ch09-hook.xml:598
11235 msgid ""
11236 "The first argument to a Python hook is always a <literal role=\"py-mod-"
11237 "mercurial.ui\">ui</literal> object. The second is a repository object; at "
11238 "the moment, it is always an instance of <literal role=\"py-mod-mercurial."
11239 "localrepo\">localrepository</literal>. Following these two arguments are "
11240 "other keyword arguments. Which ones are passed in depends on the hook being "
11241 "called, but a hook can ignore arguments it doesn't care about by dropping "
11242 "them into a keyword argument dict, as with <literal>**kwargs</literal> above."
11243 msgstr ""
11245 #. type: Content of: <book><chapter><sect1><title>
11246 #: ../en/ch09-hook.xml:613
11247 msgid "Some hook examples"
11248 msgstr "钩子样例"
11250 #. type: Content of: <book><chapter><sect1><sect2><title>
11251 #: ../en/ch09-hook.xml:616
11252 msgid "Writing meaningful commit messages"
11253 msgstr "编写有意义的提交日志"
11255 #. type: Content of: <book><chapter><sect1><sect2><para>
11256 #: ../en/ch09-hook.xml:618
11257 msgid ""
11258 "It's hard to imagine a useful commit message being very short. The simple "
11259 "<literal role=\"hook\">pretxncommit</literal> hook of the example below will "
11260 "prevent you from committing a changeset with a message that is less than ten "
11261 "bytes long."
11262 msgstr ""
11264 #. type: Content of: <book><chapter><sect1><sect2><title>
11265 #: ../en/ch09-hook.xml:628
11266 msgid "Checking for trailing whitespace"
11267 msgstr "检查行尾空格"
11269 #. type: Content of: <book><chapter><sect1><sect2><para>
11270 #: ../en/ch09-hook.xml:630
11271 msgid ""
11272 "An interesting use of a commit-related hook is to help you to write cleaner "
11273 "code. A simple example of <quote>cleaner code</quote> is the dictum that a "
11274 "change should not add any new lines of text that contain <quote>trailing "
11275 "whitespace</quote>. Trailing whitespace is a series of space and tab "
11276 "characters at the end of a line of text. In most cases, trailing whitespace "
11277 "is unnecessary, invisible noise, but it is occasionally problematic, and "
11278 "people often prefer to get rid of it."
11279 msgstr ""
11281 #. type: Content of: <book><chapter><sect1><sect2><para>
11282 #: ../en/ch09-hook.xml:641
11283 msgid ""
11284 "You can use either the <literal role=\"hook\">precommit</literal> or <literal "
11285 "role=\"hook\">pretxncommit</literal> hook to tell whether you have a trailing "
11286 "whitespace problem. If you use the <literal role=\"hook\">precommit</"
11287 "literal> hook, the hook will not know which files you are committing, so it "
11288 "will have to check every modified file in the repository for trailing white "
11289 "space. If you want to commit a change to just the file <filename>foo</"
11290 "filename>, but the file <filename>bar</filename> contains trailing "
11291 "whitespace, doing a check in the <literal role=\"hook\">precommit</literal> "
11292 "hook will prevent you from committing <filename>foo</filename> due to the "
11293 "problem with <filename>bar</filename>. This doesn't seem right."
11294 msgstr ""
11296 #. type: Content of: <book><chapter><sect1><sect2><para>
11297 #: ../en/ch09-hook.xml:657
11298 msgid ""
11299 "Should you choose the <literal role=\"hook\">pretxncommit</literal> hook, the "
11300 "check won't occur until just before the transaction for the commit "
11301 "completes. This will allow you to check for problems only the exact files "
11302 "that are being committed. However, if you entered the commit message "
11303 "interactively and the hook fails, the transaction will roll back; you'll have "
11304 "to re-enter the commit message after you fix the trailing whitespace and run "
11305 "<command role=\"hg-cmd\">hg commit</command> again."
11306 msgstr ""
11308 #. type: Content of: <book><chapter><sect1><sect2><para>
11309 #: ../en/ch09-hook.xml:670
11310 msgid ""
11311 "In this example, we introduce a simple <literal role=\"hook\">pretxncommit</"
11312 "literal> hook that checks for trailing whitespace. This hook is short, but "
11313 "not very helpful. It exits with an error status if a change adds a line with "
11314 "trailing whitespace to any file, but does not print any information that "
11315 "might help us to identify the offending file or line. It also has the nice "
11316 "property of not paying attention to unmodified lines; only lines that "
11317 "introduce new trailing whitespace cause problems."
11318 msgstr ""
11320 #. type: Content of: <book><chapter><sect1><sect2><para>
11321 #: ../en/ch09-hook.xml:681
11322 msgid ""
11323 "The above version is much more complex, but also more useful. It parses a "
11324 "unified diff to see if any lines add trailing whitespace, and prints the name "
11325 "of the file and the line number of each such occurrence. Even better, if the "
11326 "change adds trailing whitespace, this hook saves the commit comment and "
11327 "prints the name of the save file before exiting and telling Mercurial to roll "
11328 "the transaction back, so you can use the <option role=\"hg-opt-commit\">-l "
11329 "filename</option> option to <command role=\"hg-cmd\">hg commit</command> to "
11330 "reuse the saved commit message once you've corrected the problem."
11331 msgstr ""
11333 #. type: Content of: <book><chapter><sect1><sect2><para>
11334 #: ../en/ch09-hook.xml:695
11335 msgid ""
11336 "As a final aside, note in the example above the use of <command>perl</"
11337 "command>'s in-place editing feature to get rid of trailing whitespace from a "
11338 "file. This is concise and useful enough that I will reproduce it here."
11339 msgstr ""
11341 #. type: Content of: <book><chapter><sect1><title>
11342 #: ../en/ch09-hook.xml:705
11343 msgid "Bundled hooks"
11344 msgstr "内置的钩子"
11346 #. type: Content of: <book><chapter><sect1><para>
11347 #: ../en/ch09-hook.xml:707
11348 msgid ""
11349 "Mercurial ships with several bundled hooks. You can find them in the "
11350 "<filename class=\"directory\">hgext</filename> directory of a Mercurial "
11351 "source tree. If you are using a Mercurial binary package, the hooks will be "
11352 "located in the <filename class=\"directory\">hgext</filename> directory of "
11353 "wherever your package installer put Mercurial."
11354 msgstr ""
11356 #. type: Content of: <book><chapter><sect1><sect2><title>
11357 #: ../en/ch09-hook.xml:716
11358 msgid ""
11359 "<literal role=\"hg-ext\">acl</literal>&emdash;access control for parts of a "
11360 "repository"
11361 msgstr "<literal role=\"hg-ext\">acl</literal>—版本库的访问控制"
11363 #. type: Content of: <book><chapter><sect1><sect2><para>
11364 #: ../en/ch09-hook.xml:719
11365 msgid ""
11366 "The <literal role=\"hg-ext\">acl</literal> extension lets you control which "
11367 "remote users are allowed to push changesets to a networked server. You can "
11368 "protect any portion of a repository (including the entire repo), so that a "
11369 "specific remote user can push changes that do not affect the protected "
11370 "portion."
11371 msgstr ""
11373 #. type: Content of: <book><chapter><sect1><sect2><para>
11374 #: ../en/ch09-hook.xml:727
11375 msgid ""
11376 "This extension implements access control based on the identity of the user "
11377 "performing a push, <emphasis>not</emphasis> on who committed the changesets "
11378 "they're pushing. It makes sense to use this hook only if you have a locked-"
11379 "down server environment that authenticates remote users, and you want to be "
11380 "sure that only specific users are allowed to push changes to that server."
11381 msgstr ""
11383 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
11384 #: ../en/ch09-hook.xml:737
11385 msgid "Configuring the <literal role=\"hook\">acl</literal> hook"
11386 msgstr "配置 <literal role=\"hook\">acl</literal> 钩子"
11388 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11389 #: ../en/ch09-hook.xml:740
11390 msgid ""
11391 "In order to manage incoming changesets, the <literal role=\"hg-ext\">acl</"
11392 "literal> hook must be used as a <literal role=\"hook\">pretxnchangegroup</"
11393 "literal> hook. This lets it see which files are modified by each incoming "
11394 "changeset, and roll back a group of changesets if they modify "
11395 "<quote>forbidden</quote> files. Example:"
11396 msgstr ""
11398 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11399 #: ../en/ch09-hook.xml:750
11400 msgid ""
11401 "The <literal role=\"hg-ext\">acl</literal> extension is configured using "
11402 "three sections."
11403 msgstr ""
11405 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11406 #: ../en/ch09-hook.xml:754
11407 msgid ""
11408 "The <literal role=\"rc-acl\">acl</literal> section has only one entry, <envar "
11409 "role=\"rc-item-acl\">sources</envar>, which lists the sources of incoming "
11410 "changesets that the hook should pay attention to. You don't normally need to "
11411 "configure this section."
11412 msgstr ""
11414 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11415 #: ../en/ch09-hook.xml:761
11416 msgid ""
11417 "<envar role=\"rc-item-acl\">serve</envar>: Control incoming changesets that "
11418 "are arriving from a remote repository over http or ssh. This is the default "
11419 "value of <envar role=\"rc-item-acl\">sources</envar>, and usually the only "
11420 "setting you'll need for this configuration item."
11421 msgstr ""
11423 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11424 #: ../en/ch09-hook.xml:769
11425 msgid ""
11426 "<envar role=\"rc-item-acl\">pull</envar>: Control incoming changesets that "
11427 "are arriving via a pull from a local repository."
11428 msgstr ""
11430 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11431 #: ../en/ch09-hook.xml:774
11432 msgid ""
11433 "<envar role=\"rc-item-acl\">push</envar>: Control incoming changesets that "
11434 "are arriving via a push from a local repository."
11435 msgstr ""
11437 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11438 #: ../en/ch09-hook.xml:779
11439 msgid ""
11440 "<envar role=\"rc-item-acl\">bundle</envar>: Control incoming changesets that "
11441 "are arriving from another repository via a bundle."
11442 msgstr ""
11444 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11445 #: ../en/ch09-hook.xml:785
11446 msgid ""
11447 "The <literal role=\"rc-acl.allow\">acl.allow</literal> section controls the "
11448 "users that are allowed to add changesets to the repository. If this section "
11449 "is not present, all users that are not explicitly denied are allowed. If "
11450 "this section is present, all users that are not explicitly allowed are denied "
11451 "(so an empty section means that all users are denied)."
11452 msgstr ""
11454 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11455 #: ../en/ch09-hook.xml:794
11456 msgid ""
11457 "The <literal role=\"rc-acl.deny\">acl.deny</literal> section determines which "
11458 "users are denied from adding changesets to the repository. If this section "
11459 "is not present or is empty, no users are denied."
11460 msgstr ""
11462 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11463 #: ../en/ch09-hook.xml:800
11464 msgid ""
11465 "The syntaxes for the <literal role=\"rc-acl.allow\">acl.allow</literal> and "
11466 "<literal role=\"rc-acl.deny\">acl.deny</literal> sections are identical. On "
11467 "the left of each entry is a glob pattern that matches files or directories, "
11468 "relative to the root of the repository; on the right, a user name."
11469 msgstr ""
11471 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11472 #: ../en/ch09-hook.xml:808
11473 msgid ""
11474 "In the following example, the user <literal>docwriter</literal> can only push "
11475 "changes to the <filename class=\"directory\">docs</filename> subtree of the "
11476 "repository, while <literal>intern</literal> can push changes to any file or "
11477 "directory except <filename class=\"directory\">source/sensitive</filename>."
11478 msgstr ""
11480 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
11481 #: ../en/ch09-hook.xml:822 ../en/ch09-hook.xml:1089 ../en/ch09-hook.xml:1279
11482 msgid "Testing and troubleshooting"
11483 msgstr "测试与问题处理"
11485 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11486 #: ../en/ch09-hook.xml:824
11487 msgid ""
11488 "If you want to test the <literal role=\"hg-ext\">acl</literal> hook, run it "
11489 "with Mercurial's debugging output enabled. Since you'll probably be running "
11490 "it on a server where it's not convenient (or sometimes possible) to pass in "
11491 "the <option role=\"hg-opt-global\">--debug</option> option, don't forget that "
11492 "you can enable debugging output in your <filename role=\"special\">~/.hgrc</"
11493 "filename>:"
11494 msgstr ""
11496 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11497 #: ../en/ch09-hook.xml:835
11498 msgid ""
11499 "With this enabled, the <literal role=\"hg-ext\">acl</literal> hook will print "
11500 "enough information to let you figure out why it is allowing or forbidding "
11501 "pushes from specific users."
11502 msgstr ""
11504 #. type: Content of: <book><chapter><sect1><sect2><title>
11505 #: ../en/ch09-hook.xml:844
11506 msgid ""
11507 "<literal role=\"hg-ext\">bugzilla</literal>&emdash;integration with Bugzilla"
11508 msgstr "<literal role=\"hg-ext\">bugzilla</literal>—与 Bugzilla 的集成"
11510 #. type: Content of: <book><chapter><sect1><sect2><para>
11511 #: ../en/ch09-hook.xml:848
11512 msgid ""
11513 "The <literal role=\"hg-ext\">bugzilla</literal> extension adds a comment to a "
11514 "Bugzilla bug whenever it finds a reference to that bug ID in a commit "
11515 "comment. You can install this hook on a shared server, so that any time a "
11516 "remote user pushes changes to this server, the hook gets run."
11517 msgstr ""
11519 #. type: Content of: <book><chapter><sect1><sect2><para>
11520 #: ../en/ch09-hook.xml:855
11521 msgid ""
11522 "It adds a comment to the bug that looks like this (you can configure the "
11523 "contents of the comment&emdash;see below):"
11524 msgstr ""
11526 #. type: Content of: <book><chapter><sect1><sect2><para>
11527 #: ../en/ch09-hook.xml:864
11528 msgid ""
11529 "The value of this hook is that it automates the process of updating a bug any "
11530 "time a changeset refers to it. If you configure the hook properly, it makes "
11531 "it easy for people to browse straight from a Bugzilla bug to a changeset that "
11532 "refers to that bug."
11533 msgstr ""
11535 #. type: Content of: <book><chapter><sect1><sect2><para>
11536 #: ../en/ch09-hook.xml:871
11537 msgid ""
11538 "You can use the code in this hook as a starting point for some more exotic "
11539 "Bugzilla integration recipes. Here are a few possibilities:"
11540 msgstr ""
11542 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
11543 #: ../en/ch09-hook.xml:876
11544 msgid ""
11545 "Require that every changeset pushed to the server have a valid bug ID in its "
11546 "commit comment. In this case, you'd want to configure the hook as a <literal "
11547 "role=\"hook\">pretxncommit</literal> hook. This would allow the hook to "
11548 "reject changes that didn't contain bug IDs."
11549 msgstr ""
11551 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
11552 #: ../en/ch09-hook.xml:884
11553 msgid ""
11554 "Allow incoming changesets to automatically modify the <emphasis>state</"
11555 "emphasis> of a bug, as well as simply adding a comment. For example, the "
11556 "hook could recognise the string <quote>fixed bug 31337</quote> as indicating "
11557 "that it should update the state of bug 31337 to <quote>requires testing</"
11558 "quote>."
11559 msgstr ""
11561 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
11562 #: ../en/ch09-hook.xml:894
11563 msgid "Configuring the <literal role=\"hook\">bugzilla</literal> hook"
11564 msgstr "配置 <literal role=\"hook\">bugzilla</literal> 钩子"
11566 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11567 #: ../en/ch09-hook.xml:897
11568 msgid ""
11569 "You should configure this hook in your server's <filename role=\"special\">~/."
11570 "hgrc</filename> as an <literal role=\"hook\">incoming</literal> hook, for "
11571 "example as follows:"
11572 msgstr ""
11574 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11575 #: ../en/ch09-hook.xml:905
11576 msgid ""
11577 "Because of the specialised nature of this hook, and because Bugzilla was not "
11578 "written with this kind of integration in mind, configuring this hook is a "
11579 "somewhat involved process."
11580 msgstr ""
11582 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11583 #: ../en/ch09-hook.xml:911
11584 msgid ""
11585 "Before you begin, you must install the MySQL bindings for Python on the host"
11586 "(s) where you'll be running the hook. If this is not available as a binary "
11587 "package for your system, you can download it from <citation>web:mysql-python</"
11588 "citation>."
11589 msgstr ""
11591 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11592 #: ../en/ch09-hook.xml:918
11593 msgid ""
11594 "Configuration information for this hook lives in the <literal role=\"rc-"
11595 "bugzilla\">bugzilla</literal> section of your <filename role=\"special\">~/."
11596 "hgrc</filename>."
11597 msgstr ""
11599 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11600 #: ../en/ch09-hook.xml:923
11601 msgid ""
11602 "<envar role=\"rc-item-bugzilla\">version</envar>: The version of Bugzilla "
11603 "installed on the server. The database schema that Bugzilla uses changes "
11604 "occasionally, so this hook has to know exactly which schema to use. At the "
11605 "moment, the only version supported is <literal>2.16</literal>."
11606 msgstr ""
11608 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11609 #: ../en/ch09-hook.xml:932
11610 msgid ""
11611 "<envar role=\"rc-item-bugzilla\">host</envar>: The hostname of the MySQL "
11612 "server that stores your Bugzilla data. The database must be configured to "
11613 "allow connections from whatever host you are running the <literal role=\"hook"
11614 "\">bugzilla</literal> hook on."
11615 msgstr ""
11617 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11618 #: ../en/ch09-hook.xml:939
11619 msgid ""
11620 "<envar role=\"rc-item-bugzilla\">user</envar>: The username with which to "
11621 "connect to the MySQL server. The database must be configured to allow this "
11622 "user to connect from whatever host you are running the <literal role=\"hook"
11623 "\">bugzilla</literal> hook on. This user must be able to access and modify "
11624 "Bugzilla tables. The default value of this item is <literal>bugs</literal>, "
11625 "which is the standard name of the Bugzilla user in a MySQL database."
11626 msgstr ""
11628 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11629 #: ../en/ch09-hook.xml:950
11630 msgid ""
11631 "<envar role=\"rc-item-bugzilla\">password</envar>: The MySQL password for the "
11632 "user you configured above. This is stored as plain text, so you should make "
11633 "sure that unauthorised users cannot read the <filename role=\"special\">~/."
11634 "hgrc</filename> file where you store this information."
11635 msgstr ""
11637 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11638 #: ../en/ch09-hook.xml:959
11639 msgid ""
11640 "<envar role=\"rc-item-bugzilla\">db</envar>: The name of the Bugzilla "
11641 "database on the MySQL server. The default value of this item is "
11642 "<literal>bugs</literal>, which is the standard name of the MySQL database "
11643 "where Bugzilla stores its data."
11644 msgstr ""
11646 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11647 #: ../en/ch09-hook.xml:966
11648 msgid ""
11649 "<envar role=\"rc-item-bugzilla\">notify</envar>: If you want Bugzilla to send "
11650 "out a notification email to subscribers after this hook has added a comment "
11651 "to a bug, you will need this hook to run a command whenever it updates the "
11652 "database. The command to run depends on where you have installed Bugzilla, "
11653 "but it will typically look something like this, if you have Bugzilla "
11654 "installed in <filename class=\"directory\">/var/www/html/bugzilla</filename>:"
11655 msgstr ""
11657 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11658 #: ../en/ch09-hook.xml:979
11659 msgid ""
11660 "The Bugzilla <literal>processmail</literal> program expects to be given a bug "
11661 "ID (the hook replaces <quote><literal>%s</literal></quote> with the bug ID) "
11662 "and an email address. It also expects to be able to write to some files in "
11663 "the directory that it runs in. If Bugzilla and this hook are not installed "
11664 "on the same machine, you will need to find a way to run <literal>processmail</"
11665 "literal> on the server where Bugzilla is installed."
11666 msgstr ""
11668 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
11669 #: ../en/ch09-hook.xml:994
11670 msgid "Mapping committer names to Bugzilla user names"
11671 msgstr "提交者的名称与 Bugzilla 用户名称的映射"
11673 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11674 #: ../en/ch09-hook.xml:996
11675 msgid ""
11676 "By default, the <literal role=\"hg-ext\">bugzilla</literal> hook tries to use "
11677 "the email address of a changeset's committer as the Bugzilla user name with "
11678 "which to update a bug. If this does not suit your needs, you can map "
11679 "committer email addresses to Bugzilla user names using a <literal role=\"rc-"
11680 "usermap\">usermap</literal> section."
11681 msgstr ""
11683 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11684 #: ../en/ch09-hook.xml:1005
11685 msgid ""
11686 "Each item in the <literal role=\"rc-usermap\">usermap</literal> section "
11687 "contains an email address on the left, and a Bugzilla user name on the right."
11688 msgstr ""
11690 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11691 #: ../en/ch09-hook.xml:1012
11692 msgid ""
11693 "You can either keep the <literal role=\"rc-usermap\">usermap</literal> data "
11694 "in a normal <filename role=\"special\">~/.hgrc</filename>, or tell the "
11695 "<literal role=\"hg-ext\">bugzilla</literal> hook to read the information from "
11696 "an external <filename>usermap</filename> file. In the latter case, you can "
11697 "store <filename>usermap</filename> data by itself in (for example) a user-"
11698 "modifiable repository. This makes it possible to let your users maintain "
11699 "their own <envar role=\"rc-item-bugzilla\">usermap</envar> entries. The main "
11700 "<filename role=\"special\">~/.hgrc</filename> file might look like this:"
11701 msgstr ""
11703 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11704 #: ../en/ch09-hook.xml:1028
11705 msgid ""
11706 "While the <filename>usermap</filename> file that it refers to might look like "
11707 "this:"
11708 msgstr ""
11710 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
11711 #: ../en/ch09-hook.xml:1036
11712 msgid "Configuring the text that gets added to a bug"
11713 msgstr "配置增加到问题中的正文"
11715 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11716 #: ../en/ch09-hook.xml:1038
11717 msgid ""
11718 "You can configure the text that this hook adds as a comment; you specify it "
11719 "in the form of a Mercurial template. Several <filename role=\"special\">~/."
11720 "hgrc</filename> entries (still in the <literal role=\"rc-bugzilla\">bugzilla</"
11721 "literal> section) control this behavior."
11722 msgstr ""
11724 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11725 #: ../en/ch09-hook.xml:1045
11726 msgid ""
11727 "<literal>strip</literal>: The number of leading path elements to strip from a "
11728 "repository's path name to construct a partial path for a URL. For example, if "
11729 "the repositories on your server live under <filename class=\"directory\">/"
11730 "home/hg/repos</filename>, and you have a repository whose path is <filename "
11731 "class=\"directory\">/home/hg/repos/app/tests</filename>, then setting "
11732 "<literal>strip</literal> to <literal>4</literal> will give a partial path of "
11733 "<filename class=\"directory\">app/tests</filename>. The hook will make this "
11734 "partial path available when expanding a template, as <literal>webroot</"
11735 "literal>."
11736 msgstr ""
11738 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11739 #: ../en/ch09-hook.xml:1059
11740 msgid ""
11741 "<literal>template</literal>: The text of the template to use. In addition to "
11742 "the usual changeset-related variables, this template can use <literal>hgweb</"
11743 "literal> (the value of the <literal>hgweb</literal> configuration item above) "
11744 "and <literal>webroot</literal> (the path constructed using <literal>strip</"
11745 "literal> above)."
11746 msgstr ""
11748 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11749 #: ../en/ch09-hook.xml:1069
11750 msgid ""
11751 "In addition, you can add a <envar role=\"rc-item-web\">baseurl</envar> item "
11752 "to the <literal role=\"rc-web\">web</literal> section of your <filename role="
11753 "\"special\">~/.hgrc</filename>. The <literal role=\"hg-ext\">bugzilla</"
11754 "literal> hook will make this available when expanding a template, as the base "
11755 "string to use when constructing a URL that will let users browse from a "
11756 "Bugzilla comment to view a changeset. Example:"
11757 msgstr ""
11759 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11760 #: ../en/ch09-hook.xml:1081
11761 msgid ""
11762 "Here is an example set of <literal role=\"hg-ext\">bugzilla</literal> hook "
11763 "config information."
11764 msgstr ""
11766 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11767 #: ../en/ch09-hook.xml:1091
11768 msgid ""
11769 "The most common problems with configuring the <literal role=\"hg-ext"
11770 "\">bugzilla</literal> hook relate to running Bugzilla's "
11771 "<filename>processmail</filename> script and mapping committer names to user "
11772 "names."
11773 msgstr ""
11775 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11776 #: ../en/ch09-hook.xml:1097
11777 msgid ""
11778 "Recall from <xref linkend=\"sec:hook:bugzilla:config\"/> above that the user "
11779 "that runs the Mercurial process on the server is also the one that will run "
11780 "the <filename>processmail</filename> script. The <filename>processmail</"
11781 "filename> script sometimes causes Bugzilla to write to files in its "
11782 "configuration directory, and Bugzilla's configuration files are usually owned "
11783 "by the user that your web server runs under."
11784 msgstr ""
11786 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11787 #: ../en/ch09-hook.xml:1108
11788 msgid ""
11789 "You can cause <filename>processmail</filename> to be run with the suitable "
11790 "user's identity using the <command>sudo</command> command. Here is an "
11791 "example entry for a <filename>sudoers</filename> file."
11792 msgstr ""
11794 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11795 #: ../en/ch09-hook.xml:1115
11796 msgid ""
11797 "This allows the <literal>hg_user</literal> user to run a "
11798 "<filename>processmail-wrapper</filename> program under the identity of "
11799 "<literal>httpd_user</literal>."
11800 msgstr ""
11802 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11803 #: ../en/ch09-hook.xml:1120
11804 msgid ""
11805 "This indirection through a wrapper script is necessary, because "
11806 "<filename>processmail</filename> expects to be run with its current directory "
11807 "set to wherever you installed Bugzilla; you can't specify that kind of "
11808 "constraint in a <filename>sudoers</filename> file. The contents of the "
11809 "wrapper script are simple:"
11810 msgstr ""
11812 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11813 #: ../en/ch09-hook.xml:1129
11814 msgid ""
11815 "It doesn't seem to matter what email address you pass to "
11816 "<filename>processmail</filename>."
11817 msgstr ""
11819 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11820 #: ../en/ch09-hook.xml:1133
11821 msgid ""
11822 "If your <literal role=\"rc-usermap\">usermap</literal> is not set up "
11823 "correctly, users will see an error message from the <literal role=\"hg-ext"
11824 "\">bugzilla</literal> hook when they push changes to the server. The error "
11825 "message will look like this:"
11826 msgstr ""
11828 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11829 #: ../en/ch09-hook.xml:1140
11830 msgid ""
11831 "What this means is that the committer's address, <literal>john.q."
11832 "public@example.com</literal>, is not a valid Bugzilla user name, nor does it "
11833 "have an entry in your <literal role=\"rc-usermap\">usermap</literal> that "
11834 "maps it to a valid Bugzilla user name."
11835 msgstr ""
11837 #. type: Content of: <book><chapter><sect1><sect2><title>
11838 #: ../en/ch09-hook.xml:1150
11839 msgid ""
11840 "<literal role=\"hg-ext\">notify</literal>&emdash;send email notifications"
11841 msgstr "<literal role=\"hg-ext\">notify</literal>—邮件通知"
11843 #. type: Content of: <book><chapter><sect1><sect2><para>
11844 #: ../en/ch09-hook.xml:1153
11845 msgid ""
11846 "Although Mercurial's built-in web server provides RSS feeds of changes in "
11847 "every repository, many people prefer to receive change notifications via "
11848 "email. The <literal role=\"hg-ext\">notify</literal> hook lets you send out "
11849 "notifications to a set of email addresses whenever changesets arrive that "
11850 "those subscribers are interested in."
11851 msgstr ""
11853 #. type: Content of: <book><chapter><sect1><sect2><para>
11854 #: ../en/ch09-hook.xml:1161
11855 msgid ""
11856 "As with the <literal role=\"hg-ext\">bugzilla</literal> hook, the <literal "
11857 "role=\"hg-ext\">notify</literal> hook is template-driven, so you can "
11858 "customise the contents of the notification messages that it sends."
11859 msgstr ""
11861 #. type: Content of: <book><chapter><sect1><sect2><para>
11862 #: ../en/ch09-hook.xml:1167
11863 msgid ""
11864 "By default, the <literal role=\"hg-ext\">notify</literal> hook includes a "
11865 "diff of every changeset that it sends out; you can limit the size of the "
11866 "diff, or turn this feature off entirely. It is useful for letting "
11867 "subscribers review changes immediately, rather than clicking to follow a URL."
11868 msgstr ""
11870 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
11871 #: ../en/ch09-hook.xml:1175
11872 msgid "Configuring the <literal role=\"hg-ext\">notify</literal> hook"
11873 msgstr "配置 <literal role=\"hg-ext\">notify</literal> 钩子"
11875 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11876 #: ../en/ch09-hook.xml:1178
11877 msgid ""
11878 "You can set up the <literal role=\"hg-ext\">notify</literal> hook to send one "
11879 "email message per incoming changeset, or one per incoming group of changesets "
11880 "(all those that arrived in a single pull or push)."
11881 msgstr ""
11883 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11884 #: ../en/ch09-hook.xml:1190
11885 msgid ""
11886 "Configuration information for this hook lives in the <literal role=\"rc-notify"
11887 "\">notify</literal> section of a <filename role=\"special\">~/.hgrc</"
11888 "filename> file."
11889 msgstr ""
11891 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11892 #: ../en/ch09-hook.xml:1195
11893 msgid ""
11894 "<envar role=\"rc-item-notify\">test</envar>: By default, this hook does not "
11895 "send out email at all; instead, it prints the message that it "
11896 "<emphasis>would</emphasis> send. Set this item to <literal>false</literal> "
11897 "to allow email to be sent. The reason that sending of email is turned off by "
11898 "default is that it takes several tries to configure this extension exactly as "
11899 "you would like, and it would be bad form to spam subscribers with a number of "
11900 "<quote>broken</quote> notifications while you debug your configuration."
11901 msgstr ""
11903 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11904 #: ../en/ch09-hook.xml:1207
11905 msgid ""
11906 "<envar role=\"rc-item-notify\">config</envar>: The path to a configuration "
11907 "file that contains subscription information. This is kept separate from the "
11908 "main <filename role=\"special\">~/.hgrc</filename> so that you can maintain "
11909 "it in a repository of its own. People can then clone that repository, update "
11910 "their subscriptions, and push the changes back to your server."
11911 msgstr ""
11913 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11914 #: ../en/ch09-hook.xml:1216
11915 msgid ""
11916 "<envar role=\"rc-item-notify\">strip</envar>: The number of leading path "
11917 "separator characters to strip from a repository's path, when deciding whether "
11918 "a repository has subscribers. For example, if the repositories on your "
11919 "server live in <filename class=\"directory\">/home/hg/repos</filename>, and "
11920 "<literal role=\"hg-ext\">notify</literal> is considering a repository named "
11921 "<filename class=\"directory\">/home/hg/repos/shared/test</filename>, setting "
11922 "<envar role=\"rc-item-notify\">strip</envar> to <literal>4</literal> will "
11923 "cause <literal role=\"hg-ext\">notify</literal> to trim the path it considers "
11924 "down to <filename class=\"directory\">shared/test</filename>, and it will "
11925 "match subscribers against that."
11926 msgstr ""
11928 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11929 #: ../en/ch09-hook.xml:1233
11930 msgid ""
11931 "<envar role=\"rc-item-notify\">template</envar>: The template text to use "
11932 "when sending messages. This specifies both the contents of the message "
11933 "header and its body."
11934 msgstr ""
11936 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11937 #: ../en/ch09-hook.xml:1239
11938 msgid ""
11939 "<envar role=\"rc-item-notify\">maxdiff</envar>: The maximum number of lines "
11940 "of diff data to append to the end of a message. If a diff is longer than "
11941 "this, it is truncated. By default, this is set to 300. Set this to "
11942 "<literal>0</literal> to omit diffs from notification emails."
11943 msgstr ""
11945 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11946 #: ../en/ch09-hook.xml:1248
11947 msgid ""
11948 "<envar role=\"rc-item-notify\">sources</envar>: A list of sources of "
11949 "changesets to consider. This lets you limit <literal role=\"hg-ext\">notify</"
11950 "literal> to only sending out email about changes that remote users pushed "
11951 "into this repository via a server, for example. See <xref linkend=\"sec:hook:"
11952 "sources\"/> for the sources you can specify here."
11953 msgstr ""
11955 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11956 #: ../en/ch09-hook.xml:1259
11957 msgid ""
11958 "If you set the <envar role=\"rc-item-web\">baseurl</envar> item in the "
11959 "<literal role=\"rc-web\">web</literal> section, you can use it in a template; "
11960 "it will be available as <literal>webroot</literal>."
11961 msgstr ""
11963 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11964 #: ../en/ch09-hook.xml:1265
11965 msgid ""
11966 "Here is an example set of <literal role=\"hg-ext\">notify</literal> "
11967 "configuration information."
11968 msgstr ""
11970 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11971 #: ../en/ch09-hook.xml:1271
11972 msgid "This will produce a message that looks like the following:"
11973 msgstr ""
11975 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11976 #: ../en/ch09-hook.xml:1281
11977 msgid ""
11978 "Do not forget that by default, the <literal role=\"hg-ext\">notify</literal> "
11979 "extension <emphasis>will not send any mail</emphasis> until you explicitly "
11980 "configure it to do so, by setting <envar role=\"rc-item-notify\">test</envar> "
11981 "to <literal>false</literal>. Until you do that, it simply prints the message "
11982 "it <emphasis>would</emphasis> send."
11983 msgstr ""
11985 #. type: Content of: <book><chapter><sect1><title>
11986 #: ../en/ch09-hook.xml:1293
11987 msgid "Information for writers of hooks"
11988 msgstr "编写钩子的信息"
11990 #. type: Content of: <book><chapter><sect1><sect2><title>
11991 #: ../en/ch09-hook.xml:1296
11992 msgid "In-process hook execution"
11993 msgstr "进程内钩子的执行"
11995 #. type: Content of: <book><chapter><sect1><sect2><para>
11996 #: ../en/ch09-hook.xml:1298
11997 msgid "An in-process hook is called with arguments of the following form:"
11998 msgstr ""
12000 #. type: Content of: <book><chapter><sect1><sect2><para>
12001 #: ../en/ch09-hook.xml:1302
12002 msgid ""
12003 "The <literal>ui</literal> parameter is a <literal role=\"py-mod-mercurial.ui"
12004 "\">ui</literal> object. The <literal>repo</literal> parameter is a <literal "
12005 "role=\"py-mod-mercurial.localrepo\">localrepository</literal> object. The "
12006 "names and values of the <literal>**kwargs</literal> parameters depend on the "
12007 "hook being invoked, with the following common features:"
12008 msgstr ""
12010 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12011 #: ../en/ch09-hook.xml:1311
12012 msgid ""
12013 "If a parameter is named <literal>node</literal> or <literal>parentN</"
12014 "literal>, it will contain a hexadecimal changeset ID. The empty string is "
12015 "used to represent <quote>null changeset ID</quote> instead of a string of "
12016 "zeroes."
12017 msgstr ""
12019 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12020 #: ../en/ch09-hook.xml:1318
12021 msgid ""
12022 "If a parameter is named <literal>url</literal>, it will contain the URL of a "
12023 "remote repository, if that can be determined."
12024 msgstr ""
12026 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12027 #: ../en/ch09-hook.xml:1323
12028 msgid ""
12029 "Boolean-valued parameters are represented as Python <literal>bool</literal> "
12030 "objects."
12031 msgstr ""
12033 #. type: Content of: <book><chapter><sect1><sect2><para>
12034 #: ../en/ch09-hook.xml:1328
12035 msgid ""
12036 "An in-process hook is called without a change to the process's working "
12037 "directory (unlike external hooks, which are run in the root of the "
12038 "repository). It must not change the process's working directory, or it will "
12039 "cause any calls it makes into the Mercurial API to fail."
12040 msgstr ""
12042 #. type: Content of: <book><chapter><sect1><sect2><para>
12043 #: ../en/ch09-hook.xml:1335
12044 msgid ""
12045 "If a hook returns a boolean <quote>false</quote> value, it is considered to "
12046 "have succeeded. If it returns a boolean <quote>true</quote> value or raises "
12047 "an exception, it is considered to have failed. A useful way to think of the "
12048 "calling convention is <quote>tell me if you fail</quote>."
12049 msgstr ""
12051 #. type: Content of: <book><chapter><sect1><sect2><para>
12052 #: ../en/ch09-hook.xml:1342
12053 msgid ""
12054 "Note that changeset IDs are passed into Python hooks as hexadecimal strings, "
12055 "not the binary hashes that Mercurial's APIs normally use. To convert a hash "
12056 "from hex to binary, use the <literal>bin</literal> function."
12057 msgstr ""
12059 #. type: Content of: <book><chapter><sect1><sect2><title>
12060 #: ../en/ch09-hook.xml:1350
12061 msgid "External hook execution"
12062 msgstr "外部钩子的执行"
12064 #. type: Content of: <book><chapter><sect1><sect2><para>
12065 #: ../en/ch09-hook.xml:1352
12066 msgid ""
12067 "An external hook is passed to the shell of the user running Mercurial. "
12068 "Features of that shell, such as variable substitution and command "
12069 "redirection, are available. The hook is run in the root directory of the "
12070 "repository (unlike in-process hooks, which are run in the same directory that "
12071 "Mercurial was run in)."
12072 msgstr ""
12074 #. type: Content of: <book><chapter><sect1><sect2><para>
12075 #: ../en/ch09-hook.xml:1360
12076 msgid ""
12077 "Hook parameters are passed to the hook as environment variables. Each "
12078 "environment variable's name is converted in upper case and prefixed with the "
12079 "string <quote><literal>HG_</literal></quote>. For example, if the name of a "
12080 "parameter is <quote><literal>node</literal></quote>, the name of the "
12081 "environment variable representing that parameter will be "
12082 "<quote><literal>HG_NODE</literal></quote>."
12083 msgstr ""
12085 #. type: Content of: <book><chapter><sect1><sect2><para>
12086 #: ../en/ch09-hook.xml:1369
12087 msgid ""
12088 "A boolean parameter is represented as the string <quote><literal>1</literal></"
12089 "quote> for <quote>true</quote>, <quote><literal>0</literal></quote> for "
12090 "<quote>false</quote>. If an environment variable is named <envar>HG_NODE</"
12091 "envar>, <envar>HG_PARENT1</envar> or <envar>HG_PARENT2</envar>, it contains a "
12092 "changeset ID represented as a hexadecimal string. The empty string is used "
12093 "to represent <quote>null changeset ID</quote> instead of a string of zeroes. "
12094 "If an environment variable is named <envar>HG_URL</envar>, it will contain "
12095 "the URL of a remote repository, if that can be determined."
12096 msgstr ""
12098 #. type: Content of: <book><chapter><sect1><sect2><para>
12099 #: ../en/ch09-hook.xml:1381
12100 msgid ""
12101 "If a hook exits with a status of zero, it is considered to have succeeded. "
12102 "If it exits with a non-zero status, it is considered to have failed."
12103 msgstr ""
12105 #. type: Content of: <book><chapter><sect1><sect2><title>
12106 #: ../en/ch09-hook.xml:1388
12107 msgid "Finding out where changesets come from"
12108 msgstr "检查修改集来自何处"
12110 #. type: Content of: <book><chapter><sect1><sect2><para>
12111 #: ../en/ch09-hook.xml:1390
12112 msgid ""
12113 "A hook that involves the transfer of changesets between a local repository "
12114 "and another may be able to find out information about the <quote>far side</"
12115 "quote>. Mercurial knows <emphasis>how</emphasis> changes are being "
12116 "transferred, and in many cases <emphasis>where</emphasis> they are being "
12117 "transferred to or from."
12118 msgstr ""
12120 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
12121 #: ../en/ch09-hook.xml:1399
12122 msgid "Sources of changesets"
12123 msgstr "修改集的来源"
12125 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
12126 #: ../en/ch09-hook.xml:1401
12127 msgid ""
12128 "Mercurial will tell a hook what means are, or were, used to transfer "
12129 "changesets between repositories. This is provided by Mercurial in a Python "
12130 "parameter named <literal>source</literal>, or an environment variable named "
12131 "<envar>HG_SOURCE</envar>."
12132 msgstr ""
12134 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
12135 #: ../en/ch09-hook.xml:1409
12136 msgid ""
12137 "<literal>serve</literal>: Changesets are transferred to or from a remote "
12138 "repository over http or ssh."
12139 msgstr ""
12141 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
12142 #: ../en/ch09-hook.xml:1414
12143 msgid ""
12144 "<literal>pull</literal>: Changesets are being transferred via a pull from one "
12145 "repository into another."
12146 msgstr ""
12148 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
12149 #: ../en/ch09-hook.xml:1419
12150 msgid ""
12151 "<literal>push</literal>: Changesets are being transferred via a push from one "
12152 "repository into another."
12153 msgstr ""
12155 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
12156 #: ../en/ch09-hook.xml:1424
12157 msgid ""
12158 "<literal>bundle</literal>: Changesets are being transferred to or from a "
12159 "bundle."
12160 msgstr ""
12162 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
12163 #: ../en/ch09-hook.xml:1431
12164 msgid "Where changes are going&emdash;remote repository URLs"
12165 msgstr "修改集要到哪里—远程版本库的地址"
12167 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
12168 #: ../en/ch09-hook.xml:1434
12169 msgid ""
12170 "When possible, Mercurial will tell a hook the location of the <quote>far "
12171 "side</quote> of an activity that transfers changeset data between "
12172 "repositories. This is provided by Mercurial in a Python parameter named "
12173 "<literal>url</literal>, or an environment variable named <envar>HG_URL</"
12174 "envar>."
12175 msgstr ""
12177 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
12178 #: ../en/ch09-hook.xml:1442
12179 msgid ""
12180 "This information is not always known. If a hook is invoked in a repository "
12181 "that is being served via http or ssh, Mercurial cannot tell where the remote "
12182 "repository is, but it may know where the client is connecting from. In such "
12183 "cases, the URL will take one of the following forms:"
12184 msgstr ""
12186 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
12187 #: ../en/ch09-hook.xml:1449
12188 msgid ""
12189 "<literal>remote:ssh:1.2.3.4</literal>&emdash;remote ssh client, at the IP "
12190 "address <literal>1.2.3.4</literal>."
12191 msgstr ""
12193 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
12194 #: ../en/ch09-hook.xml:1454
12195 msgid ""
12196 "<literal>remote:http:1.2.3.4</literal>&emdash;remote http client, at the IP "
12197 "address <literal>1.2.3.4</literal>. If the client is using SSL, this will be "
12198 "of the form <literal>remote:https:1.2.3.4</literal>."
12199 msgstr ""
12201 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
12202 #: ../en/ch09-hook.xml:1461
12203 msgid "Empty&emdash;no information could be discovered about the remote client."
12204 msgstr ""
12206 #. type: Content of: <book><chapter><sect1><title>
12207 #: ../en/ch09-hook.xml:1470
12208 msgid "Hook reference"
12209 msgstr "钩子参考"
12211 #. type: Content of: <book><chapter><sect1><sect2><title>
12212 #: ../en/ch09-hook.xml:1473
12213 msgid ""
12214 "<literal role=\"hook\">changegroup</literal>&emdash;after remote changesets "
12215 "added"
12216 msgstr "<literal role=\"hook\">changegroup</literal>—增加远程修改集之后"
12218 #. type: Content of: <book><chapter><sect1><sect2><para>
12219 #: ../en/ch09-hook.xml:1476
12220 msgid ""
12221 "This hook is run after a group of pre-existing changesets has been added to "
12222 "the repository, for example via a <command role=\"hg-cmd\">hg pull</command> "
12223 "or <command role=\"hg-cmd\">hg unbundle</command>. This hook is run once per "
12224 "operation that added one or more changesets. This is in contrast to the "
12225 "<literal role=\"hook\">incoming</literal> hook, which is run once per "
12226 "changeset, regardless of whether the changesets arrive in a group."
12227 msgstr ""
12229 #. type: Content of: <book><chapter><sect1><sect2><para>
12230 #: ../en/ch09-hook.xml:1486
12231 msgid ""
12232 "Some possible uses for this hook include kicking off an automated build or "
12233 "test of the added changesets, updating a bug database, or notifying "
12234 "subscribers that a repository contains new changes."
12235 msgstr ""
12237 #. type: Content of: <book><chapter><sect1><sect2><para>
12238 #: ../en/ch09-hook.xml:1492 ../en/ch09-hook.xml:1532 ../en/ch09-hook.xml:1576
12239 #: ../en/ch09-hook.xml:1618 ../en/ch09-hook.xml:1673 ../en/ch09-hook.xml:1713
12240 #: ../en/ch09-hook.xml:1749 ../en/ch09-hook.xml:1783 ../en/ch09-hook.xml:1846
12241 #: ../en/ch09-hook.xml:1904 ../en/ch09-hook.xml:1940 ../en/ch09-hook.xml:1967
12242 msgid "Parameters to this hook:"
12243 msgstr ""
12245 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12246 #: ../en/ch09-hook.xml:1495 ../en/ch09-hook.xml:1849
12247 msgid ""
12248 "<literal>node</literal>: A changeset ID. The changeset ID of the first "
12249 "changeset in the group that was added. All changesets between this and "
12250 "<literal role=\"tag\">tip</literal>, inclusive, were added by a single "
12251 "<command role=\"hg-cmd\">hg pull</command>, <command role=\"hg-cmd\">hg push</"
12252 "command> or <command role=\"hg-cmd\">hg unbundle</command>."
12253 msgstr ""
12255 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12256 #: ../en/ch09-hook.xml:1504 ../en/ch09-hook.xml:1583 ../en/ch09-hook.xml:1676
12257 #: ../en/ch09-hook.xml:1859
12258 msgid ""
12259 "<literal>source</literal>: A string. The source of these changes. See <xref "
12260 "linkend=\"sec:hook:sources\"/> for details."
12261 msgstr ""
12263 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12264 #: ../en/ch09-hook.xml:1509 ../en/ch09-hook.xml:1588 ../en/ch09-hook.xml:1639
12265 #: ../en/ch09-hook.xml:1681 ../en/ch09-hook.xml:1762 ../en/ch09-hook.xml:1864
12266 msgid ""
12267 "<literal>url</literal>: A URL. The location of the remote repository, if "
12268 "known. See <xref linkend=\"sec:hook:url\"/> for more information."
12269 msgstr ""
12271 #. type: Content of: <book><chapter><sect1><sect2><para>
12272 #: ../en/ch09-hook.xml:1515
12273 msgid ""
12274 "See also: <literal role=\"hook\">incoming</literal> (<xref linkend=\"sec:hook:"
12275 "incoming\"/>), <literal role=\"hook\">prechangegroup</literal> (<xref linkend="
12276 "\"sec:hook:prechangegroup\"/>), <literal role=\"hook\">pretxnchangegroup</"
12277 "literal> (<xref linkend=\"sec:hook:pretxnchangegroup\"/>)"
12278 msgstr ""
12280 #. type: Content of: <book><chapter><sect1><sect2><title>
12281 #: ../en/ch09-hook.xml:1526
12282 msgid ""
12283 "<literal role=\"hook\">commit</literal>&emdash;after a new changeset is "
12284 "created"
12285 msgstr "<literal role=\"hook\">commit</literal>—创建新修改集之后"
12287 #. type: Content of: <book><chapter><sect1><sect2><para>
12288 #: ../en/ch09-hook.xml:1529
12289 msgid "This hook is run after a new changeset has been created."
12290 msgstr ""
12292 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12293 #: ../en/ch09-hook.xml:1535 ../en/ch09-hook.xml:1907
12294 msgid ""
12295 "<literal>node</literal>: A changeset ID. The changeset ID of the newly "
12296 "committed changeset."
12297 msgstr ""
12299 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12300 #: ../en/ch09-hook.xml:1539 ../en/ch09-hook.xml:1911
12301 msgid ""
12302 "<literal>parent1</literal>: A changeset ID. The changeset ID of the first "
12303 "parent of the newly committed changeset."
12304 msgstr ""
12306 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12307 #: ../en/ch09-hook.xml:1544 ../en/ch09-hook.xml:1916
12308 msgid ""
12309 "<literal>parent2</literal>: A changeset ID. The changeset ID of the second "
12310 "parent of the newly committed changeset."
12311 msgstr ""
12313 #. type: Content of: <book><chapter><sect1><sect2><para>
12314 #: ../en/ch09-hook.xml:1550
12315 msgid ""
12316 "See also: <literal role=\"hook\">precommit</literal> (<xref linkend=\"sec:"
12317 "hook:precommit\"/>), <literal role=\"hook\">pretxncommit</literal> (<xref "
12318 "linkend=\"sec:hook:pretxncommit\"/>)"
12319 msgstr ""
12321 #. type: Content of: <book><chapter><sect1><sect2><title>
12322 #: ../en/ch09-hook.xml:1559
12323 msgid ""
12324 "<literal role=\"hook\">incoming</literal>&emdash;after one remote changeset "
12325 "is added"
12326 msgstr "<literal role=\"hook\">incoming</literal>—增加远程修改集之后"
12328 #. type: Content of: <book><chapter><sect1><sect2><para>
12329 #: ../en/ch09-hook.xml:1562
12330 msgid ""
12331 "This hook is run after a pre-existing changeset has been added to the "
12332 "repository, for example via a <command role=\"hg-cmd\">hg push</command>. If "
12333 "a group of changesets was added in a single operation, this hook is called "
12334 "once for each added changeset."
12335 msgstr ""
12337 #. type: Content of: <book><chapter><sect1><sect2><para>
12338 #: ../en/ch09-hook.xml:1569
12339 msgid ""
12340 "You can use this hook for the same purposes as the <literal role=\"hook"
12341 "\">changegroup</literal> hook (<xref linkend=\"sec:hook:changegroup\"/>); "
12342 "it's simply more convenient sometimes to run a hook once per group of "
12343 "changesets, while other times it's handier once per changeset."
12344 msgstr ""
12346 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12347 #: ../en/ch09-hook.xml:1579
12348 msgid ""
12349 "<literal>node</literal>: A changeset ID. The ID of the newly added changeset."
12350 msgstr ""
12352 #. type: Content of: <book><chapter><sect1><sect2><para>
12353 #: ../en/ch09-hook.xml:1594
12354 msgid ""
12355 "See also: <literal role=\"hook\">changegroup</literal> (<xref linkend=\"sec:"
12356 "hook:changegroup\"/>) <literal role=\"hook\">prechangegroup</literal> (<xref "
12357 "linkend=\"sec:hook:prechangegroup\"/>), <literal role=\"hook"
12358 "\">pretxnchangegroup</literal> (<xref linkend=\"sec:hook:pretxnchangegroup\"/"
12359 ">)"
12360 msgstr ""
12362 #. type: Content of: <book><chapter><sect1><sect2><title>
12363 #: ../en/ch09-hook.xml:1605
12364 msgid ""
12365 "<literal role=\"hook\">outgoing</literal>&emdash;after changesets are "
12366 "propagated"
12367 msgstr "<literal role=\"hook\">outgoing</literal>—传播修改集之后"
12369 #. type: Content of: <book><chapter><sect1><sect2><para>
12370 #: ../en/ch09-hook.xml:1608
12371 msgid ""
12372 "This hook is run after a group of changesets has been propagated out of this "
12373 "repository, for example by a <command role=\"hg-cmd\">hg push</command> or "
12374 "<command role=\"hg-cmd\">hg bundle</command> command."
12375 msgstr ""
12377 #. type: Content of: <book><chapter><sect1><sect2><para>
12378 #: ../en/ch09-hook.xml:1614
12379 msgid ""
12380 "One possible use for this hook is to notify administrators that changes have "
12381 "been pulled."
12382 msgstr ""
12384 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12385 #: ../en/ch09-hook.xml:1621
12386 msgid ""
12387 "<literal>node</literal>: A changeset ID. The changeset ID of the first "
12388 "changeset of the group that was sent."
12389 msgstr ""
12391 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12392 #: ../en/ch09-hook.xml:1626
12393 msgid ""
12394 "<literal>source</literal>: A string. The source of the of the operation (see "
12395 "<xref linkend=\"sec:hook:sources\"/>). If a remote client pulled changes "
12396 "from this repository, <literal>source</literal> will be <literal>serve</"
12397 "literal>. If the client that obtained changes from this repository was "
12398 "local, <literal>source</literal> will be <literal>bundle</literal>, "
12399 "<literal>pull</literal>, or <literal>push</literal>, depending on the "
12400 "operation the client performed."
12401 msgstr ""
12403 #. type: Content of: <book><chapter><sect1><sect2><para>
12404 #: ../en/ch09-hook.xml:1645
12405 msgid ""
12406 "See also: <literal role=\"hook\">preoutgoing</literal> (<xref linkend=\"sec:"
12407 "hook:preoutgoing\"/>)"
12408 msgstr ""
12410 #. type: Content of: <book><chapter><sect1><sect2><title>
12411 #: ../en/ch09-hook.xml:1652
12412 msgid ""
12413 "<literal role=\"hook\">prechangegroup</literal>&emdash;before starting to add "
12414 "remote changesets"
12415 msgstr "<literal role=\"hook\">prechangegroup</literal>—增加远程修改集之前"
12417 #. type: Content of: <book><chapter><sect1><sect2><para>
12418 #: ../en/ch09-hook.xml:1656
12419 msgid ""
12420 "This controlling hook is run before Mercurial begins to add a group of "
12421 "changesets from another repository."
12422 msgstr ""
12424 #. type: Content of: <book><chapter><sect1><sect2><para>
12425 #: ../en/ch09-hook.xml:1660
12426 msgid ""
12427 "This hook does not have any information about the changesets to be added, "
12428 "because it is run before transmission of those changesets is allowed to "
12429 "begin. If this hook fails, the changesets will not be transmitted."
12430 msgstr ""
12432 #. type: Content of: <book><chapter><sect1><sect2><para>
12433 #: ../en/ch09-hook.xml:1666
12434 msgid ""
12435 "One use for this hook is to prevent external changes from being added to a "
12436 "repository. For example, you could use this to <quote>freeze</quote> a "
12437 "server-hosted branch temporarily or permanently so that users cannot push to "
12438 "it, while still allowing a local administrator to modify the repository."
12439 msgstr ""
12441 #. type: Content of: <book><chapter><sect1><sect2><para>
12442 #: ../en/ch09-hook.xml:1687
12443 msgid ""
12444 "See also: <literal role=\"hook\">changegroup</literal> (<xref linkend=\"sec:"
12445 "hook:changegroup\"/>), <literal role=\"hook\">incoming</literal> (<xref "
12446 "linkend=\"sec:hook:incoming\"/>), <literal role=\"hook\">pretxnchangegroup</"
12447 "literal> (<xref linkend=\"sec:hook:pretxnchangegroup\"/>)"
12448 msgstr ""
12450 #. type: Content of: <book><chapter><sect1><sect2><title>
12451 #: ../en/ch09-hook.xml:1698
12452 msgid ""
12453 "<literal role=\"hook\">precommit</literal>&emdash;before starting to commit a "
12454 "changeset"
12455 msgstr "<literal role=\"hook\">precommit</literal>—提交修改集之前"
12457 #. type: Content of: <book><chapter><sect1><sect2><para>
12458 #: ../en/ch09-hook.xml:1701
12459 msgid ""
12460 "This hook is run before Mercurial begins to commit a new changeset. It is run "
12461 "before Mercurial has any of the metadata for the commit, such as the files to "
12462 "be committed, the commit message, or the commit date."
12463 msgstr ""
12465 #. type: Content of: <book><chapter><sect1><sect2><para>
12466 #: ../en/ch09-hook.xml:1707
12467 msgid ""
12468 "One use for this hook is to disable the ability to commit new changesets, "
12469 "while still allowing incoming changesets. Another is to run a build or test, "
12470 "and only allow the commit to begin if the build or test succeeds."
12471 msgstr ""
12473 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12474 #: ../en/ch09-hook.xml:1716
12475 msgid ""
12476 "<literal>parent1</literal>: A changeset ID. The changeset ID of the first "
12477 "parent of the working directory."
12478 msgstr ""
12480 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12481 #: ../en/ch09-hook.xml:1721
12482 msgid ""
12483 "<literal>parent2</literal>: A changeset ID. The changeset ID of the second "
12484 "parent of the working directory."
12485 msgstr ""
12487 #. type: Content of: <book><chapter><sect1><sect2><para>
12488 #: ../en/ch09-hook.xml:1726
12489 msgid ""
12490 "If the commit proceeds, the parents of the working directory will become the "
12491 "parents of the new changeset."
12492 msgstr ""
12494 #. type: Content of: <book><chapter><sect1><sect2><para>
12495 #: ../en/ch09-hook.xml:1730
12496 msgid ""
12497 "See also: <literal role=\"hook\">commit</literal> (<xref linkend=\"sec:hook:"
12498 "commit\"/>), <literal role=\"hook\">pretxncommit</literal> (<xref linkend="
12499 "\"sec:hook:pretxncommit\"/>)"
12500 msgstr ""
12502 #. type: Content of: <book><chapter><sect1><sect2><title>
12503 #: ../en/ch09-hook.xml:1738
12504 msgid ""
12505 "<literal role=\"hook\">preoutgoing</literal>&emdash;before starting to "
12506 "propagate changesets"
12507 msgstr "<literal role=\"hook\">preoutgoing</literal>—传播修改集之前"
12509 #. type: Content of: <book><chapter><sect1><sect2><para>
12510 #: ../en/ch09-hook.xml:1741
12511 msgid ""
12512 "This hook is invoked before Mercurial knows the identities of the changesets "
12513 "to be transmitted."
12514 msgstr ""
12516 #. type: Content of: <book><chapter><sect1><sect2><para>
12517 #: ../en/ch09-hook.xml:1745
12518 msgid ""
12519 "One use for this hook is to prevent changes from being transmitted to another "
12520 "repository."
12521 msgstr ""
12523 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12524 #: ../en/ch09-hook.xml:1752
12525 msgid ""
12526 "<literal>source</literal>: A string. The source of the operation that is "
12527 "attempting to obtain changes from this repository (see <xref linkend=\"sec:"
12528 "hook:sources\"/>). See the documentation for the <literal>source</literal> "
12529 "parameter to the <literal role=\"hook\">outgoing</literal> hook, in <xref "
12530 "linkend=\"sec:hook:outgoing\"/>, for possible values of this parameter."
12531 msgstr ""
12533 #. type: Content of: <book><chapter><sect1><sect2><para>
12534 #: ../en/ch09-hook.xml:1768
12535 msgid ""
12536 "See also: <literal role=\"hook\">outgoing</literal> (<xref linkend=\"sec:hook:"
12537 "outgoing\"/>)"
12538 msgstr ""
12540 #. type: Content of: <book><chapter><sect1><sect2><title>
12541 #: ../en/ch09-hook.xml:1775
12542 msgid ""
12543 "<literal role=\"hook\">pretag</literal>&emdash;before tagging a changeset"
12544 msgstr "<literal role=\"hook\">pretag</literal>—创建标签之前"
12546 #. type: Content of: <book><chapter><sect1><sect2><para>
12547 #: ../en/ch09-hook.xml:1778
12548 msgid ""
12549 "This controlling hook is run before a tag is created. If the hook succeeds, "
12550 "creation of the tag proceeds. If the hook fails, the tag is not created."
12551 msgstr ""
12553 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12554 #: ../en/ch09-hook.xml:1786
12555 msgid ""
12556 "<literal>local</literal>: A boolean. Whether the tag is local to this "
12557 "repository instance (i.e. stored in <filename role=\"special\">.hg/localtags</"
12558 "filename>) or managed by Mercurial (stored in <filename role=\"special\">."
12559 "hgtags</filename>)."
12560 msgstr ""
12562 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12563 #: ../en/ch09-hook.xml:1793
12564 msgid ""
12565 "<literal>node</literal>: A changeset ID. The ID of the changeset to be "
12566 "tagged."
12567 msgstr ""
12569 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12570 #: ../en/ch09-hook.xml:1797
12571 msgid "<literal>tag</literal>: A string. The name of the tag to be created."
12572 msgstr ""
12574 #. type: Content of: <book><chapter><sect1><sect2><para>
12575 #: ../en/ch09-hook.xml:1802
12576 msgid ""
12577 "If the tag to be created is revision-controlled, the <literal role=\"hook"
12578 "\">precommit</literal> and <literal role=\"hook\">pretxncommit</literal> "
12579 "hooks (<xref linkend=\"sec:hook:commit\"/> and <xref linkend=\"sec:hook:"
12580 "pretxncommit\"/>) will also be run."
12581 msgstr ""
12583 #. type: Content of: <book><chapter><sect1><sect2><para>
12584 #: ../en/ch09-hook.xml:1810
12585 msgid ""
12586 "See also: <literal role=\"hook\">tag</literal> (<xref linkend=\"sec:hook:tag"
12587 "\"/>)"
12588 msgstr ""
12590 #. type: Content of: <book><chapter><sect1><sect2><title>
12591 #: ../en/ch09-hook.xml:1815
12592 msgid ""
12593 "<literal role=\"hook\">pretxnchangegroup</literal>&emdash;before completing "
12594 "addition of remote changesets"
12595 msgstr ""
12596 "<literal role=\"hook\">pretxnchangegroup</literal>—完成增加远程修改集之前"
12598 #. type: Content of: <book><chapter><sect1><sect2><para>
12599 #: ../en/ch09-hook.xml:1819
12600 msgid ""
12601 "This controlling hook is run before a transaction&emdash;that manages the "
12602 "addition of a group of new changesets from outside the repository&emdash;"
12603 "completes. If the hook succeeds, the transaction completes, and all of the "
12604 "changesets become permanent within this repository. If the hook fails, the "
12605 "transaction is rolled back, and the data for the changesets is erased."
12606 msgstr ""
12608 #. type: Content of: <book><chapter><sect1><sect2><para>
12609 #: ../en/ch09-hook.xml:1828
12610 msgid ""
12611 "This hook can access the metadata associated with the almost-added "
12612 "changesets, but it should not do anything permanent with this data. It must "
12613 "also not modify the working directory."
12614 msgstr ""
12616 #. type: Content of: <book><chapter><sect1><sect2><para>
12617 #: ../en/ch09-hook.xml:1834
12618 msgid ""
12619 "While this hook is running, if other Mercurial processes access this "
12620 "repository, they will be able to see the almost-added changesets as if they "
12621 "are permanent. This may lead to race conditions if you do not take steps to "
12622 "avoid them."
12623 msgstr ""
12625 #. type: Content of: <book><chapter><sect1><sect2><para>
12626 #: ../en/ch09-hook.xml:1841
12627 msgid ""
12628 "This hook can be used to automatically vet a group of changesets. If the "
12629 "hook fails, all of the changesets are <quote>rejected</quote> when the "
12630 "transaction rolls back."
12631 msgstr ""
12633 #. type: Content of: <book><chapter><sect1><sect2><para>
12634 #: ../en/ch09-hook.xml:1870
12635 msgid ""
12636 "See also: <literal role=\"hook\">changegroup</literal> (<xref linkend=\"sec:"
12637 "hook:changegroup\"/>), <literal role=\"hook\">incoming</literal> (<xref "
12638 "linkend=\"sec:hook:incoming\"/>), <literal role=\"hook\">prechangegroup</"
12639 "literal> (<xref linkend=\"sec:hook:prechangegroup\"/>)"
12640 msgstr ""
12642 #. type: Content of: <book><chapter><sect1><sect2><title>
12643 #: ../en/ch09-hook.xml:1881
12644 msgid ""
12645 "<literal role=\"hook\">pretxncommit</literal>&emdash;before completing commit "
12646 "of new changeset"
12647 msgstr "<literal role=\"hook\">pretxncommit</literal>—完成提交之前"
12649 #. type: Content of: <book><chapter><sect1><sect2><para>
12650 #: ../en/ch09-hook.xml:1884
12651 msgid ""
12652 "This controlling hook is run before a transaction&emdash;that manages a new "
12653 "commit&emdash;completes. If the hook succeeds, the transaction completes and "
12654 "the changeset becomes permanent within this repository. If the hook fails, "
12655 "the transaction is rolled back, and the commit data is erased."
12656 msgstr ""
12658 #. type: Content of: <book><chapter><sect1><sect2><para>
12659 #: ../en/ch09-hook.xml:1892
12660 msgid ""
12661 "This hook can access the metadata associated with the almost-new changeset, "
12662 "but it should not do anything permanent with this data. It must also not "
12663 "modify the working directory."
12664 msgstr ""
12666 #. type: Content of: <book><chapter><sect1><sect2><para>
12667 #: ../en/ch09-hook.xml:1898
12668 msgid ""
12669 "While this hook is running, if other Mercurial processes access this "
12670 "repository, they will be able to see the almost-new changeset as if it is "
12671 "permanent. This may lead to race conditions if you do not take steps to "
12672 "avoid them."
12673 msgstr ""
12675 #. type: Content of: <book><chapter><sect1><sect2><para>
12676 #: ../en/ch09-hook.xml:1922
12677 msgid ""
12678 "See also: <literal role=\"hook\">precommit</literal> (<xref linkend=\"sec:"
12679 "hook:precommit\"/>)"
12680 msgstr ""
12681 "参见: <literal role=\"hook\">precommit</literal> (<xref linkend=\"sec:hook:"
12682 "precommit\"/>)"
12684 #. type: Content of: <book><chapter><sect1><sect2><title>
12685 #: ../en/ch09-hook.xml:1929
12686 msgid ""
12687 "<literal role=\"hook\">preupdate</literal>&emdash;before updating or merging "
12688 "working directory"
12689 msgstr "<literal role=\"hook\">preupdate</literal>—更新或合并工作目录之前"
12691 #. type: Content of: <book><chapter><sect1><sect2><para>
12692 #: ../en/ch09-hook.xml:1932
12693 msgid ""
12694 "This controlling hook is run before an update or merge of the working "
12695 "directory begins. It is run only if Mercurial's normal pre-update checks "
12696 "determine that the update or merge can proceed. If the hook succeeds, the "
12697 "update or merge may proceed; if it fails, the update or merge does not start."
12698 msgstr ""
12700 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12701 #: ../en/ch09-hook.xml:1943
12702 msgid ""
12703 "<literal>parent1</literal>: A changeset ID. The ID of the parent that the "
12704 "working directory is to be updated to. If the working directory is being "
12705 "merged, it will not change this parent."
12706 msgstr ""
12708 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12709 #: ../en/ch09-hook.xml:1949
12710 msgid ""
12711 "<literal>parent2</literal>: A changeset ID. Only set if the working directory "
12712 "is being merged. The ID of the revision that the working directory is being "
12713 "merged with."
12714 msgstr ""
12716 #. type: Content of: <book><chapter><sect1><sect2><para>
12717 #: ../en/ch09-hook.xml:1956
12718 msgid ""
12719 "See also: <literal role=\"hook\">update</literal> (<xref linkend=\"sec:hook:"
12720 "update\"/>)"
12721 msgstr ""
12723 #. type: Content of: <book><chapter><sect1><sect2><title>
12724 #: ../en/ch09-hook.xml:1961
12725 msgid "<literal role=\"hook\">tag</literal>&emdash;after tagging a changeset"
12726 msgstr "<literal role=\"hook\">tag</literal>—创建标签之后"
12728 #. type: Content of: <book><chapter><sect1><sect2><para>
12729 #: ../en/ch09-hook.xml:1964
12730 msgid "This hook is run after a tag has been created."
12731 msgstr ""
12733 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12734 #: ../en/ch09-hook.xml:1970
12735 msgid ""
12736 "<literal>local</literal>: A boolean. Whether the new tag is local to this "
12737 "repository instance (i.e. stored in <filename role=\"special\">.hg/"
12738 "localtags</filename>) or managed by Mercurial (stored in <filename role="
12739 "\"special\">.hgtags</filename>)."
12740 msgstr ""
12742 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12743 #: ../en/ch09-hook.xml:1978
12744 msgid ""
12745 "<literal>node</literal>: A changeset ID. The ID of the changeset that was "
12746 "tagged."
12747 msgstr ""
12749 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12750 #: ../en/ch09-hook.xml:1982
12751 msgid "<literal>tag</literal>: A string. The name of the tag that was created."
12752 msgstr ""
12754 #. type: Content of: <book><chapter><sect1><sect2><para>
12755 #: ../en/ch09-hook.xml:1987
12756 msgid ""
12757 "If the created tag is revision-controlled, the <literal role=\"hook\">commit</"
12758 "literal> hook (section <xref linkend=\"sec:hook:commit\"/>) is run before "
12759 "this hook."
12760 msgstr ""
12762 #. type: Content of: <book><chapter><sect1><sect2><para>
12763 #: ../en/ch09-hook.xml:1992
12764 msgid ""
12765 "See also: <literal role=\"hook\">pretag</literal> (<xref linkend=\"sec:hook:"
12766 "pretag\"/>)"
12767 msgstr ""
12768 "参见: <literal role=\"hook\">pretag</literal> (<xref linkend=\"sec:hook:pretag"
12769 "\"/>)"
12771 #. type: Content of: <book><chapter><sect1><sect2><title>
12772 #: ../en/ch09-hook.xml:1998
12773 msgid ""
12774 "<literal role=\"hook\">update</literal>&emdash;after updating or merging "
12775 "working directory"
12776 msgstr "<literal role=\"hook\">update</literal>—更新或合并工作目录之后"
12778 #. type: Content of: <book><chapter><sect1><sect2><para>
12779 #: ../en/ch09-hook.xml:2001
12780 msgid ""
12781 "This hook is run after an update or merge of the working directory "
12782 "completes. Since a merge can fail (if the external <command>hgmerge</"
12783 "command> command fails to resolve conflicts in a file), this hook "
12784 "communicates whether the update or merge completed cleanly."
12785 msgstr ""
12787 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12788 #: ../en/ch09-hook.xml:2009
12789 msgid ""
12790 "<literal>error</literal>: A boolean. Indicates whether the update or merge "
12791 "completed successfully."
12792 msgstr ""
12794 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12795 #: ../en/ch09-hook.xml:2014
12796 msgid ""
12797 "<literal>parent1</literal>: A changeset ID. The ID of the parent that the "
12798 "working directory was updated to. If the working directory was merged, it "
12799 "will not have changed this parent."
12800 msgstr ""
12802 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12803 #: ../en/ch09-hook.xml:2020
12804 msgid ""
12805 "<literal>parent2</literal>: A changeset ID. Only set if the working "
12806 "directory was merged. The ID of the revision that the working directory was "
12807 "merged with."
12808 msgstr ""
12810 #. type: Content of: <book><chapter><sect1><sect2><para>
12811 #: ../en/ch09-hook.xml:2026
12812 msgid ""
12813 "See also: <literal role=\"hook\">preupdate</literal> (<xref linkend=\"sec:"
12814 "hook:preupdate\"/>)"
12815 msgstr ""
12817 #. type: Content of: <book><chapter><title>
12818 #: ../en/ch10-template.xml:5
12819 msgid "Customising the output of Mercurial"
12820 msgstr "定制 Mercurial 的输出"
12822 #. type: Content of: <book><chapter><para>
12823 #: ../en/ch10-template.xml:7
12824 msgid ""
12825 "Mercurial provides a powerful mechanism to let you control how it displays "
12826 "information. The mechanism is based on templates. You can use templates to "
12827 "generate specific output for a single command, or to customise the entire "
12828 "appearance of the built-in web interface."
12829 msgstr ""
12831 #. type: Content of: <book><chapter><sect1><title>
12832 #: ../en/ch10-template.xml:14
12833 msgid "Using precanned output styles"
12834 msgstr "使用预定义的输出样式"
12836 #. type: Content of: <book><chapter><sect1><para>
12837 #: ../en/ch10-template.xml:16
12838 msgid ""
12839 "Packaged with Mercurial are some output styles that you can use immediately. "
12840 "A style is simply a precanned template that someone wrote and installed "
12841 "somewhere that Mercurial can find."
12842 msgstr ""
12844 #. type: Content of: <book><chapter><sect1><para>
12845 #: ../en/ch10-template.xml:21
12846 msgid ""
12847 "Before we take a look at Mercurial's bundled styles, let's review its normal "
12848 "output."
12849 msgstr ""
12851 #. type: Content of: <book><chapter><sect1><para>
12852 #: ../en/ch10-template.xml:26
12853 msgid ""
12854 "This is somewhat informative, but it takes up a lot of space&emdash;five "
12855 "lines of output per changeset. The <literal>compact</literal> style reduces "
12856 "this to three lines, presented in a sparse manner."
12857 msgstr ""
12859 #. type: Content of: <book><chapter><sect1><para>
12860 #: ../en/ch10-template.xml:33
12861 msgid ""
12862 "The <literal>changelog</literal> style hints at the expressive power of "
12863 "Mercurial's templating engine. This style attempts to follow the GNU "
12864 "Project's changelog guidelines<citation>web:changelog</citation>."
12865 msgstr ""
12867 #. type: Content of: <book><chapter><sect1><para>
12868 #: ../en/ch10-template.xml:40
12869 msgid ""
12870 "You will not be shocked to learn that Mercurial's default output style is "
12871 "named <literal>default</literal>."
12872 msgstr ""
12874 #. type: Content of: <book><chapter><sect1><sect2><title>
12875 #: ../en/ch10-template.xml:44
12876 msgid "Setting a default style"
12877 msgstr "设置默认样式"
12879 #. type: Content of: <book><chapter><sect1><sect2><para>
12880 #: ../en/ch10-template.xml:46
12881 msgid ""
12882 "You can modify the output style that Mercurial will use for every command by "
12883 "editing your <filename role=\"special\">~/.hgrc</filename> file, naming the "
12884 "style you would prefer to use."
12885 msgstr ""
12887 #. type: Content of: <book><chapter><sect1><sect2><para>
12888 #: ../en/ch10-template.xml:54
12889 msgid ""
12890 "If you write a style of your own, you can use it by either providing the path "
12891 "to your style file, or copying your style file into a location where "
12892 "Mercurial can find it (typically the <literal>templates</literal> "
12893 "subdirectory of your Mercurial install directory)."
12894 msgstr ""
12896 #. type: Content of: <book><chapter><sect1><title>
12897 #: ../en/ch10-template.xml:63
12898 msgid "Commands that support styles and templates"
12899 msgstr "支持样式和模版的命令"
12901 #. type: Content of: <book><chapter><sect1><para>
12902 #: ../en/ch10-template.xml:65
12903 msgid ""
12904 "All of Mercurial's <quote><literal>log</literal>-like</quote> commands let "
12905 "you use styles and templates: <command role=\"hg-cmd\">hg incoming</command>, "
12906 "<command role=\"hg-cmd\">hg log</command>, <command role=\"hg-cmd\">hg "
12907 "outgoing</command>, and <command role=\"hg-cmd\">hg tip</command>."
12908 msgstr ""
12910 #. type: Content of: <book><chapter><sect1><para>
12911 #: ../en/ch10-template.xml:72
12912 msgid ""
12913 "As I write this manual, these are so far the only commands that support "
12914 "styles and templates. Since these are the most important commands that need "
12915 "customisable output, there has been little pressure from the Mercurial user "
12916 "community to add style and template support to other commands."
12917 msgstr ""
12919 #. type: Content of: <book><chapter><sect1><title>
12920 #: ../en/ch10-template.xml:80
12921 msgid "The basics of templating"
12922 msgstr "模版基础"
12924 #. type: Content of: <book><chapter><sect1><para>
12925 #: ../en/ch10-template.xml:82
12926 msgid ""
12927 "At its simplest, a Mercurial template is a piece of text. Some of the text "
12928 "never changes, while other parts are <emphasis>expanded</emphasis>, or "
12929 "replaced with new text, when necessary."
12930 msgstr ""
12932 #. type: Content of: <book><chapter><sect1><para>
12933 #: ../en/ch10-template.xml:87
12934 msgid ""
12935 "Before we continue, let's look again at a simple example of Mercurial's "
12936 "normal output."
12937 msgstr ""
12939 #. type: Content of: <book><chapter><sect1><para>
12940 #: ../en/ch10-template.xml:92
12941 msgid ""
12942 "Now, let's run the same command, but using a template to change its output."
12943 msgstr ""
12945 #. type: Content of: <book><chapter><sect1><para>
12946 #: ../en/ch10-template.xml:97
12947 msgid ""
12948 "The example above illustrates the simplest possible template; it's just a "
12949 "piece of static text, printed once for each changeset. The <option role=\"hg-"
12950 "opt-log\">--template</option> option to the <command role=\"hg-cmd\">hg log</"
12951 "command> command tells Mercurial to use the given text as the template when "
12952 "printing each changeset."
12953 msgstr ""
12955 #. type: Content of: <book><chapter><sect1><para>
12956 #: ../en/ch10-template.xml:105
12957 msgid ""
12958 "Notice that the template string above ends with the text <quote><literal>\\n</"
12959 "literal></quote>. This is an <emphasis>escape sequence</emphasis>, telling "
12960 "Mercurial to print a newline at the end of each template item. If you omit "
12961 "this newline, Mercurial will run each piece of output together. See <xref "
12962 "linkend=\"sec:template:escape\"/> for more details of escape sequences."
12963 msgstr ""
12965 #. type: Content of: <book><chapter><sect1><para>
12966 #: ../en/ch10-template.xml:113
12967 msgid ""
12968 "A template that prints a fixed string of text all the time isn't very useful; "
12969 "let's try something a bit more complex."
12970 msgstr ""
12972 #. type: Content of: <book><chapter><sect1><para>
12973 #: ../en/ch10-template.xml:119
12974 msgid ""
12975 "As you can see, the string <quote><literal>{desc}</literal></quote> in the "
12976 "template has been replaced in the output with the description of each "
12977 "changeset. Every time Mercurial finds text enclosed in curly braces "
12978 "(<quote><literal>{</literal></quote> and <quote><literal>}</literal></"
12979 "quote>), it will try to replace the braces and text with the expansion of "
12980 "whatever is inside. To print a literal curly brace, you must escape it, as "
12981 "described in <xref linkend=\"sec:template:escape\"/>."
12982 msgstr ""
12984 #. type: Content of: <book><chapter><sect1><title>
12985 #: ../en/ch10-template.xml:131
12986 msgid "Common template keywords"
12987 msgstr "模版关键字"
12989 #. type: Content of: <book><chapter><sect1><para>
12990 #: ../en/ch10-template.xml:133
12991 msgid ""
12992 "You can start writing simple templates immediately using the keywords below."
12993 msgstr ""
12995 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12996 #: ../en/ch10-template.xml:137
12997 msgid ""
12998 "<literal role=\"template-keyword\">author</literal>: String. The unmodified "
12999 "author of the changeset."
13000 msgstr ""
13002 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13003 #: ../en/ch10-template.xml:141
13004 msgid ""
13005 "<literal role=\"template-keyword\">branches</literal>: String. The name of "
13006 "the branch on which the changeset was committed. Will be empty if the branch "
13007 "name was <literal>default</literal>."
13008 msgstr ""
13010 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13011 #: ../en/ch10-template.xml:147
13012 msgid ""
13013 "<literal role=\"template-keyword\">date</literal>: Date information. The "
13014 "date when the changeset was committed. This is <emphasis>not</emphasis> "
13015 "human-readable; you must pass it through a filter that will render it "
13016 "appropriately. See <xref linkend=\"sec:template:filter\"/> for more "
13017 "information on filters. The date is expressed as a pair of numbers. The "
13018 "first number is a Unix UTC timestamp (seconds since January 1, 1970); the "
13019 "second is the offset of the committer's timezone from UTC, in seconds."
13020 msgstr ""
13022 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13023 #: ../en/ch10-template.xml:158
13024 msgid ""
13025 "<literal role=\"template-keyword\">desc</literal>: String. The text of the "
13026 "changeset description."
13027 msgstr ""
13029 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13030 #: ../en/ch10-template.xml:161
13031 msgid ""
13032 "<literal role=\"template-keyword\">files</literal>: List of strings. All "
13033 "files modified, added, or removed by this changeset."
13034 msgstr ""
13036 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13037 #: ../en/ch10-template.xml:166
13038 msgid ""
13039 "<literal role=\"template-keyword\">file_adds</literal>: List of strings. "
13040 "Files added by this changeset."
13041 msgstr ""
13043 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13044 #: ../en/ch10-template.xml:170
13045 msgid ""
13046 "<literal role=\"template-keyword\">file_dels</literal>: List of strings. "
13047 "Files removed by this changeset."
13048 msgstr ""
13050 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13051 #: ../en/ch10-template.xml:174
13052 msgid ""
13053 "<literal role=\"template-keyword\">node</literal>: String. The changeset "
13054 "identification hash, as a 40-character hexadecimal string."
13055 msgstr ""
13057 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13058 #: ../en/ch10-template.xml:178
13059 msgid ""
13060 "<literal role=\"template-keyword\">parents</literal>: List of strings. The "
13061 "parents of the changeset."
13062 msgstr ""
13064 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13065 #: ../en/ch10-template.xml:182
13066 msgid ""
13067 "<literal role=\"template-keyword\">rev</literal>: Integer. The repository-"
13068 "local changeset revision number."
13069 msgstr ""
13071 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13072 #: ../en/ch10-template.xml:186
13073 msgid ""
13074 "<literal role=\"template-keyword\">tags</literal>: List of strings. Any tags "
13075 "associated with the changeset."
13076 msgstr ""
13078 #. type: Content of: <book><chapter><sect1><para>
13079 #: ../en/ch10-template.xml:191
13080 msgid ""
13081 "A few simple experiments will show us what to expect when we use these "
13082 "keywords; you can see the results below."
13083 msgstr ""
13085 #. type: Content of: <book><chapter><sect1><para>
13086 #: ../en/ch10-template.xml:196
13087 msgid ""
13088 "As we noted above, the date keyword does not produce human-readable output, "
13089 "so we must treat it specially. This involves using a <emphasis>filter</"
13090 "emphasis>, about which more in <xref linkend=\"sec:template:filter\"/>."
13091 msgstr ""
13093 #. type: Content of: <book><chapter><sect1><title>
13094 #: ../en/ch10-template.xml:205
13095 msgid "Escape sequences"
13096 msgstr "转义序列"
13098 #. type: Content of: <book><chapter><sect1><para>
13099 #: ../en/ch10-template.xml:207
13100 msgid ""
13101 "Mercurial's templating engine recognises the most commonly used escape "
13102 "sequences in strings. When it sees a backslash (<quote><literal>\\</"
13103 "literal></quote>) character, it looks at the following character and "
13104 "substitutes the two characters with a single replacement, as described below."
13105 msgstr ""
13107 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13108 #: ../en/ch10-template.xml:214
13109 msgid ""
13110 "<literal>\\</literal>: Backslash, <quote><literal>\\</literal></quote>, ASCII "
13111 "134."
13112 msgstr ""
13114 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13115 #: ../en/ch10-template.xml:218
13116 msgid "<literal>\\n</literal>: Newline, ASCII 12."
13117 msgstr ""
13119 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13120 #: ../en/ch10-template.xml:221
13121 msgid "<literal>\\r</literal>: Carriage return, ASCII 15."
13122 msgstr ""
13124 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13125 #: ../en/ch10-template.xml:224
13126 msgid "<literal>\\t</literal>: Tab, ASCII 11."
13127 msgstr ""
13129 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13130 #: ../en/ch10-template.xml:227
13131 msgid "<literal>\\v</literal>: Vertical tab, ASCII 13."
13132 msgstr ""
13134 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13135 #: ../en/ch10-template.xml:230
13136 msgid ""
13137 "<literal>{</literal>: Open curly brace, <quote><literal>{</literal></quote>, "
13138 "ASCII 173."
13139 msgstr ""
13141 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13142 #: ../en/ch10-template.xml:234
13143 msgid ""
13144 "<literal>}</literal>: Close curly brace, <quote><literal>}</literal></quote>, "
13145 "ASCII 175."
13146 msgstr ""
13148 #. type: Content of: <book><chapter><sect1><para>
13149 #: ../en/ch10-template.xml:239
13150 msgid ""
13151 "As indicated above, if you want the expansion of a template to contain a "
13152 "literal <quote><literal>\\</literal></quote>, <quote><literal>{</literal></"
13153 "quote>, or <quote><literal>{</literal></quote> character, you must escape it."
13154 msgstr ""
13156 #. type: Content of: <book><chapter><sect1><title>
13157 #: ../en/ch10-template.xml:247
13158 msgid "Filtering keywords to change their results"
13159 msgstr "通过过滤关键字来修改输出结果"
13161 #. type: Content of: <book><chapter><sect1><para>
13162 #: ../en/ch10-template.xml:249
13163 msgid ""
13164 "Some of the results of template expansion are not immediately easy to use. "
13165 "Mercurial lets you specify an optional chain of <emphasis>filters</emphasis> "
13166 "to modify the result of expanding a keyword. You have already seen a common "
13167 "filter, <literal role=\"template-kw-filt-date\">isodate</literal>, in action "
13168 "above, to make a date readable."
13169 msgstr ""
13171 #. type: Content of: <book><chapter><sect1><para>
13172 #: ../en/ch10-template.xml:256
13173 msgid ""
13174 "Below is a list of the most commonly used filters that Mercurial supports. "
13175 "While some filters can be applied to any text, others can only be used in "
13176 "specific circumstances. The name of each filter is followed first by an "
13177 "indication of where it can be used, then a description of its effect."
13178 msgstr ""
13180 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13181 #: ../en/ch10-template.xml:263
13182 msgid ""
13183 "<literal role=\"template-filter\">addbreaks</literal>: Any text. Add an XHTML "
13184 "<quote><literal>&lt;br/&gt;</literal></quote> tag before the end of every "
13185 "line except the last. For example, <quote><literal>foo\\nbar</literal></"
13186 "quote> becomes <quote><literal>foo&lt;br/&gt;\\nbar</literal></quote>."
13187 msgstr ""
13189 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13190 #: ../en/ch10-template.xml:270
13191 msgid ""
13192 "<literal role=\"template-kw-filt-date\">age</literal>: <literal role="
13193 "\"template-keyword\">date</literal> keyword. Render the age of the date, "
13194 "relative to the current time. Yields a string like <quote><literal>10 "
13195 "minutes</literal></quote>."
13196 msgstr ""
13198 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13199 #: ../en/ch10-template.xml:277
13200 msgid ""
13201 "<literal role=\"template-filter\">basename</literal>: Any text, but most "
13202 "useful for the <literal role=\"template-keyword\">files</literal> keyword and "
13203 "its relatives. Treat the text as a path, and return the basename. For "
13204 "example, <quote><literal>foo/bar/baz</literal></quote> becomes "
13205 "<quote><literal>baz</literal></quote>."
13206 msgstr ""
13208 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13209 #: ../en/ch10-template.xml:286
13210 msgid ""
13211 "<literal role=\"template-kw-filt-date\">date</literal>: <literal role="
13212 "\"template-keyword\">date</literal> keyword. Render a date in a similar "
13213 "format to the Unix <literal role=\"template-keyword\">date</literal> command, "
13214 "but with timezone included. Yields a string like <quote><literal>Mon Sep 04 "
13215 "15:13:13 2006 -0700</literal></quote>."
13216 msgstr ""
13218 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13219 #: ../en/ch10-template.xml:294
13220 msgid ""
13221 "<literal role=\"template-kw-filt-author\">domain</literal>: Any text, but "
13222 "most useful for the <literal role=\"template-keyword\">author</literal> "
13223 "keyword. Finds the first string that looks like an email address, and "
13224 "extract just the domain component. For example, <quote><literal>Bryan "
13225 "O'Sullivan &lt;bos@serpentine.com&gt;</literal></quote> becomes "
13226 "<quote><literal>serpentine.com</literal></quote>."
13227 msgstr ""
13229 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13230 #: ../en/ch10-template.xml:304
13231 msgid ""
13232 "<literal role=\"template-kw-filt-author\">email</literal>: Any text, but most "
13233 "useful for the <literal role=\"template-keyword\">author</literal> keyword. "
13234 "Extract the first string that looks like an email address. For example, "
13235 "<quote><literal>Bryan O'Sullivan &lt;bos@serpentine.com&gt;</literal></quote> "
13236 "becomes <quote><literal>bos@serpentine.com</literal></quote>."
13237 msgstr ""
13239 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13240 #: ../en/ch10-template.xml:313
13241 msgid ""
13242 "<literal role=\"template-filter\">escape</literal>: Any text. Replace the "
13243 "special XML/XHTML characters <quote><literal>&amp;</literal></quote>, "
13244 "<quote><literal>&lt;</literal></quote> and <quote><literal>&gt;</literal></"
13245 "quote> with XML entities."
13246 msgstr ""
13248 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13249 #: ../en/ch10-template.xml:321
13250 msgid ""
13251 "<literal role=\"template-filter\">fill68</literal>: Any text. Wrap the text "
13252 "to fit in 68 columns. This is useful before you pass text through the "
13253 "<literal role=\"template-filter\">tabindent</literal> filter, and still want "
13254 "it to fit in an 80-column fixed-font window."
13255 msgstr ""
13257 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13258 #: ../en/ch10-template.xml:329
13259 msgid ""
13260 "<literal role=\"template-filter\">fill76</literal>: Any text. Wrap the text "
13261 "to fit in 76 columns."
13262 msgstr ""
13264 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13265 #: ../en/ch10-template.xml:333
13266 msgid ""
13267 "<literal role=\"template-filter\">firstline</literal>: Any text. Yield the "
13268 "first line of text, without any trailing newlines."
13269 msgstr ""
13271 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13272 #: ../en/ch10-template.xml:338
13273 msgid ""
13274 "<literal role=\"template-kw-filt-date\">hgdate</literal>: <literal role="
13275 "\"template-keyword\">date</literal> keyword. Render the date as a pair of "
13276 "readable numbers. Yields a string like <quote><literal>1157407993 25200</"
13277 "literal></quote>."
13278 msgstr ""
13280 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13281 #: ../en/ch10-template.xml:345
13282 msgid ""
13283 "<literal role=\"template-kw-filt-date\">isodate</literal>: <literal role="
13284 "\"template-keyword\">date</literal> keyword. Render the date as a text "
13285 "string in ISO 8601 format. Yields a string like <quote><literal>2006-09-04 "
13286 "15:13:13 -0700</literal></quote>."
13287 msgstr ""
13289 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13290 #: ../en/ch10-template.xml:352
13291 msgid ""
13292 "<literal role=\"template-filter\">obfuscate</literal>: Any text, but most "
13293 "useful for the <literal role=\"template-keyword\">author</literal> keyword. "
13294 "Yield the input text rendered as a sequence of XML entities. This helps to "
13295 "defeat some particularly stupid screen-scraping email harvesting spambots."
13296 msgstr ""
13298 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13299 #: ../en/ch10-template.xml:360
13300 msgid ""
13301 "<literal role=\"template-kw-filt-author\">person</literal>: Any text, but "
13302 "most useful for the <literal role=\"template-keyword\">author</literal> "
13303 "keyword. Yield the text before an email address. For example, "
13304 "<quote><literal>Bryan O'Sullivan &lt;bos@serpentine.com&gt;</literal></quote> "
13305 "becomes <quote><literal>Bryan O'Sullivan</literal></quote>."
13306 msgstr ""
13308 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13309 #: ../en/ch10-template.xml:369
13310 msgid ""
13311 "<literal role=\"template-kw-filt-date\">rfc822date</literal>: <literal role="
13312 "\"template-keyword\">date</literal> keyword. Render a date using the same "
13313 "format used in email headers. Yields a string like <quote><literal>Mon, 04 "
13314 "Sep 2006 15:13:13 -0700</literal></quote>."
13315 msgstr ""
13317 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13318 #: ../en/ch10-template.xml:376
13319 msgid ""
13320 "<literal role=\"template-kw-filt-node\">short</literal>: Changeset hash. "
13321 "Yield the short form of a changeset hash, i.e. a 12-character hexadecimal "
13322 "string."
13323 msgstr ""
13325 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13326 #: ../en/ch10-template.xml:381
13327 msgid ""
13328 "<literal role=\"template-kw-filt-date\">shortdate</literal>: <literal role="
13329 "\"template-keyword\">date</literal> keyword. Render the year, month, and day "
13330 "of the date. Yields a string like <quote><literal>2006-09-04</literal></"
13331 "quote>."
13332 msgstr ""
13334 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13335 #: ../en/ch10-template.xml:387
13336 msgid ""
13337 "<literal role=\"template-filter\">strip</literal>: Any text. Strip all "
13338 "leading and trailing whitespace from the string."
13339 msgstr ""
13341 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13342 #: ../en/ch10-template.xml:391
13343 msgid ""
13344 "<literal role=\"template-filter\">tabindent</literal>: Any text. Yield the "
13345 "text, with every line except the first starting with a tab character."
13346 msgstr ""
13348 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13349 #: ../en/ch10-template.xml:396
13350 msgid ""
13351 "<literal role=\"template-filter\">urlescape</literal>: Any text. Escape all "
13352 "characters that are considered <quote>special</quote> by URL parsers. For "
13353 "example, <literal>foo bar</literal> becomes <literal>foo%20bar</literal>."
13354 msgstr ""
13356 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13357 #: ../en/ch10-template.xml:403
13358 msgid ""
13359 "<literal role=\"template-kw-filt-author\">user</literal>: Any text, but most "
13360 "useful for the <literal role=\"template-keyword\">author</literal> keyword. "
13361 "Return the <quote>user</quote> portion of an email address. For example, "
13362 "<quote><literal>Bryan O'Sullivan &lt;bos@serpentine.com&gt;</literal></quote> "
13363 "becomes <quote><literal>bos</literal></quote>."
13364 msgstr ""
13366 #. type: Content of: <book><chapter><sect1><note><para>
13367 #: ../en/ch10-template.xml:416
13368 msgid ""
13369 "If you try to apply a filter to a piece of data that it cannot process, "
13370 "Mercurial will fail and print a Python exception. For example, trying to run "
13371 "the output of the <literal role=\"template-keyword\">desc</literal> keyword "
13372 "into the <literal role=\"template-kw-filt-date\">isodate</literal> filter is "
13373 "not a good idea."
13374 msgstr ""
13376 #. type: Content of: <book><chapter><sect1><sect2><title>
13377 #: ../en/ch10-template.xml:425
13378 msgid "Combining filters"
13379 msgstr "组合过滤器"
13381 #. type: Content of: <book><chapter><sect1><sect2><para>
13382 #: ../en/ch10-template.xml:427
13383 msgid ""
13384 "It is easy to combine filters to yield output in the form you would like. "
13385 "The following chain of filters tidies up a description, then makes sure that "
13386 "it fits cleanly into 68 columns, then indents it by a further 8 characters "
13387 "(at least on Unix-like systems, where a tab is conventionally 8 characters "
13388 "wide)."
13389 msgstr ""
13391 #. type: Content of: <book><chapter><sect1><sect2><para>
13392 #: ../en/ch10-template.xml:436
13393 msgid ""
13394 "Note the use of <quote><literal>\\t</literal></quote> (a tab character) in "
13395 "the template to force the first line to be indented; this is necessary since "
13396 "<literal role=\"template-keyword\">tabindent</literal> indents all lines "
13397 "<emphasis>except</emphasis> the first."
13398 msgstr ""
13400 #. type: Content of: <book><chapter><sect1><sect2><para>
13401 #: ../en/ch10-template.xml:442
13402 msgid ""
13403 "Keep in mind that the order of filters in a chain is significant. The first "
13404 "filter is applied to the result of the keyword; the second to the result of "
13405 "the first filter; and so on. For example, using <literal>fill68|tabindent</"
13406 "literal> gives very different results from <literal>tabindent|fill68</"
13407 "literal>."
13408 msgstr ""
13410 #. type: Content of: <book><chapter><sect1><title>
13411 #: ../en/ch10-template.xml:453
13412 msgid "From templates to styles"
13413 msgstr "从模版到样式"
13415 #. type: Content of: <book><chapter><sect1><para>
13416 #: ../en/ch10-template.xml:455
13417 msgid ""
13418 "A command line template provides a quick and simple way to format some "
13419 "output. Templates can become verbose, though, and it's useful to be able to "
13420 "give a template a name. A style file is a template with a name, stored in a "
13421 "file."
13422 msgstr ""
13424 #. type: Content of: <book><chapter><sect1><para>
13425 #: ../en/ch10-template.xml:460
13426 msgid ""
13427 "More than that, using a style file unlocks the power of Mercurial's "
13428 "templating engine in ways that are not possible using the command line "
13429 "<option role=\"hg-opt-log\">--template</option> option."
13430 msgstr ""
13432 #. type: Content of: <book><chapter><sect1><sect2><title>
13433 #: ../en/ch10-template.xml:466
13434 msgid "The simplest of style files"
13435 msgstr "最简单的样式文件"
13437 #. type: Content of: <book><chapter><sect1><sect2><para>
13438 #: ../en/ch10-template.xml:468
13439 msgid "Our simple style file contains just one line:"
13440 msgstr ""
13442 #. type: Content of: <book><chapter><sect1><sect2><para>
13443 #: ../en/ch10-template.xml:472
13444 msgid ""
13445 "This tells Mercurial, <quote>if you're printing a changeset, use the text on "
13446 "the right as the template</quote>."
13447 msgstr ""
13449 #. type: Content of: <book><chapter><sect1><sect2><title>
13450 #: ../en/ch10-template.xml:478
13451 msgid "Style file syntax"
13452 msgstr "样式文件语法"
13454 #. type: Content of: <book><chapter><sect1><sect2><para>
13455 #: ../en/ch10-template.xml:480
13456 msgid "The syntax rules for a style file are simple."
13457 msgstr ""
13459 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13460 #: ../en/ch10-template.xml:483
13461 msgid "The file is processed one line at a time."
13462 msgstr ""
13464 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13465 #: ../en/ch10-template.xml:486
13466 msgid "Leading and trailing white space are ignored."
13467 msgstr ""
13469 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13470 #: ../en/ch10-template.xml:489
13471 msgid "Empty lines are skipped."
13472 msgstr ""
13474 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13475 #: ../en/ch10-template.xml:491
13476 msgid ""
13477 "If a line starts with either of the characters <quote><literal>#</literal></"
13478 "quote> or <quote><literal>;</literal></quote>, the entire line is treated as "
13479 "a comment, and skipped as if empty."
13480 msgstr ""
13482 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13483 #: ../en/ch10-template.xml:496
13484 msgid ""
13485 "A line starts with a keyword. This must start with an alphabetic character "
13486 "or underscore, and can subsequently contain any alphanumeric character or "
13487 "underscore. (In regexp notation, a keyword must match <literal>[A-Za-z_][A-"
13488 "Za-z0-9_]*</literal>.)"
13489 msgstr ""
13491 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13492 #: ../en/ch10-template.xml:502
13493 msgid ""
13494 "The next element must be an <quote><literal>=</literal></quote> character, "
13495 "which can be preceded or followed by an arbitrary amount of white space."
13496 msgstr ""
13498 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13499 #: ../en/ch10-template.xml:507
13500 msgid ""
13501 "If the rest of the line starts and ends with matching quote characters "
13502 "(either single or double quote), it is treated as a template body."
13503 msgstr ""
13505 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13506 #: ../en/ch10-template.xml:511
13507 msgid ""
13508 "If the rest of the line <emphasis>does not</emphasis> start with a quote "
13509 "character, it is treated as the name of a file; the contents of this file "
13510 "will be read and used as a template body."
13511 msgstr ""
13513 #. type: Content of: <book><chapter><sect1><title>
13514 #: ../en/ch10-template.xml:520
13515 msgid "Style files by example"
13516 msgstr "样式文件例子"
13518 #. type: Content of: <book><chapter><sect1><para>
13519 #: ../en/ch10-template.xml:522
13520 msgid ""
13521 "To illustrate how to write a style file, we will construct a few by example. "
13522 "Rather than provide a complete style file and walk through it, we'll mirror "
13523 "the usual process of developing a style file by starting with something very "
13524 "simple, and walking through a series of successively more complete examples."
13525 msgstr ""
13527 #. type: Content of: <book><chapter><sect1><sect2><title>
13528 #: ../en/ch10-template.xml:529
13529 msgid "Identifying mistakes in style files"
13530 msgstr "在样式文件中定位错误"
13532 #. type: Content of: <book><chapter><sect1><sect2><para>
13533 #: ../en/ch10-template.xml:531
13534 msgid ""
13535 "If Mercurial encounters a problem in a style file you are working on, it "
13536 "prints a terse error message that, once you figure out what it means, is "
13537 "actually quite useful."
13538 msgstr ""
13540 #. type: Content of: <book><chapter><sect1><sect2><para>
13541 #: ../en/ch10-template.xml:537
13542 msgid ""
13543 "Notice that <filename>broken.style</filename> attempts to define a "
13544 "<literal>changeset</literal> keyword, but forgets to give any content for it. "
13545 "When instructed to use this style file, Mercurial promptly complains."
13546 msgstr ""
13548 #. type: Content of: <book><chapter><sect1><sect2><para>
13549 #: ../en/ch10-template.xml:544
13550 msgid "This error message looks intimidating, but it is not too hard to follow."
13551 msgstr ""
13553 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13554 #: ../en/ch10-template.xml:548
13555 msgid ""
13556 "The first component is simply Mercurial's way of saying <quote>I am giving "
13557 "up</quote>."
13558 msgstr ""
13560 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13561 #: ../en/ch10-template.xml:552
13562 msgid "Next comes the name of the style file that contains the error."
13563 msgstr ""
13565 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13566 #: ../en/ch10-template.xml:556
13567 msgid ""
13568 "Following the file name is the line number where the error was encountered."
13569 msgstr ""
13571 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13572 #: ../en/ch10-template.xml:560
13573 msgid "Finally, a description of what went wrong."
13574 msgstr ""
13576 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13577 #: ../en/ch10-template.xml:564
13578 msgid ""
13579 "The description of the problem is not always clear (as in this case), but "
13580 "even when it is cryptic, it is almost always trivial to visually inspect the "
13581 "offending line in the style file and see what is wrong."
13582 msgstr ""
13584 #. type: Content of: <book><chapter><sect1><sect2><title>
13585 #: ../en/ch10-template.xml:572
13586 msgid "Uniquely identifying a repository"
13587 msgstr "版本库的唯一标识"
13589 #. type: Content of: <book><chapter><sect1><sect2><para>
13590 #: ../en/ch10-template.xml:574
13591 msgid ""
13592 "If you would like to be able to identify a Mercurial repository <quote>fairly "
13593 "uniquely</quote> using a short string as an identifier, you can use the first "
13594 "revision in the repository."
13595 msgstr ""
13597 #. type: Content of: <book><chapter><sect1><sect2><para>
13598 #: ../en/ch10-template.xml:581
13599 msgid ""
13600 "This is not guaranteed to be unique, but it is nevertheless useful in many "
13601 "cases."
13602 msgstr ""
13604 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13605 #: ../en/ch10-template.xml:584
13606 msgid ""
13607 "It will not work in a completely empty repository, because such a repository "
13608 "does not have a revision zero."
13609 msgstr ""
13611 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13612 #: ../en/ch10-template.xml:588
13613 msgid ""
13614 "Neither will it work in the (extremely rare) case where a repository is a "
13615 "merge of two or more formerly independent repositories, and you still have "
13616 "those repositories around."
13617 msgstr ""
13619 #. type: Content of: <book><chapter><sect1><sect2><para>
13620 #: ../en/ch10-template.xml:593
13621 msgid "Here are some uses to which you could put this identifier:"
13622 msgstr ""
13624 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13625 #: ../en/ch10-template.xml:596
13626 msgid ""
13627 "As a key into a table for a database that manages repositories on a server."
13628 msgstr ""
13630 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13631 #: ../en/ch10-template.xml:599
13632 msgid ""
13633 "As half of a {<emphasis>repository ID</emphasis>, <emphasis>revision ID</"
13634 "emphasis>} tuple. Save this information away when you run an automated build "
13635 "or other activity, so that you can <quote>replay</quote> the build later if "
13636 "necessary."
13637 msgstr ""
13639 #. type: Content of: <book><chapter><sect1><sect2><title>
13640 #: ../en/ch10-template.xml:608
13641 msgid "Mimicking Subversion's output"
13642 msgstr "模仿 Subversion 的输出"
13645 #. type: Content of: <book><chapter><sect1><sect2><para>
13646 #: ../en/ch10-template.xml:610
13647 msgid ""
13648 "Let's try to emulate the default output format used by another revision "
13649 "control tool, Subversion."
13650 msgstr ""
13653 #. type: Content of: <book><chapter><sect1><sect2><para>
13654 #: ../en/ch10-template.xml:615
13655 msgid ""
13656 "Since Subversion's output style is fairly simple, it is easy to copy-and-"
13657 "paste a hunk of its output into a file, and replace the text produced above "
13658 "by Subversion with the template values we'd like to see expanded."
13659 msgstr ""
13661 #. type: Content of: <book><chapter><sect1><sect2><para>
13662 #: ../en/ch10-template.xml:622
13663 msgid ""
13664 "There are a few small ways in which this template deviates from the output "
13665 "produced by Subversion."
13666 msgstr ""
13668 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13669 #: ../en/ch10-template.xml:625
13670 msgid ""
13671 "Subversion prints a <quote>readable</quote> date (the <quote><literal>Wed, 27 "
13672 "Sep 2006</literal></quote> in the example output above) in parentheses. "
13673 "Mercurial's templating engine does not provide a way to display a date in "
13674 "this format without also printing the time and time zone."
13675 msgstr ""
13677 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13678 #: ../en/ch10-template.xml:632
13679 msgid ""
13680 "We emulate Subversion's printing of <quote>separator</quote> lines full of "
13681 "<quote><literal>-</literal></quote> characters by ending the template with "
13682 "such a line. We use the templating engine's <literal role=\"template-keyword"
13683 "\">header</literal> keyword to print a separator line as the first line of "
13684 "output (see below), thus achieving similar output to Subversion."
13685 msgstr ""
13687 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13688 #: ../en/ch10-template.xml:641
13689 msgid ""
13690 "Subversion's output includes a count in the header of the number of lines in "
13691 "the commit message. We cannot replicate this in Mercurial; the templating "
13692 "engine does not currently provide a filter that counts the number of lines "
13693 "the template generates."
13694 msgstr ""
13697 #. type: Content of: <book><chapter><sect1><sect2><para>
13698 #: ../en/ch10-template.xml:647
13699 msgid ""
13700 "It took me no more than a minute or two of work to replace literal text from "
13701 "an example of Subversion's output with some keywords and filters to give the "
13702 "template above. The style file simply refers to the template."
13703 msgstr ""
13705 #. type: Content of: <book><chapter><sect1><sect2><para>
13706 #: ../en/ch10-template.xml:654
13707 msgid ""
13708 "We could have included the text of the template file directly in the style "
13709 "file by enclosing it in quotes and replacing the newlines with "
13710 "<quote><literal>\\n</literal></quote> sequences, but it would have made the "
13711 "style file too difficult to read. Readability is a good guide when you're "
13712 "trying to decide whether some text belongs in a style file, or in a template "
13713 "file that the style file points to. If the style file will look too big or "
13714 "cluttered if you insert a literal piece of text, drop it into a template "
13715 "instead."
13716 msgstr ""
13718 #. type: Content of: <book><chapter><title>
13719 #: ../en/ch11-mq.xml:5
13720 msgid "Managing change with Mercurial Queues"
13721 msgstr "使用 MQ 管理修改"
13723 #. type: Content of: <book><chapter><sect1><title>
13724 #: ../en/ch11-mq.xml:8
13725 msgid "The patch management problem"
13726 msgstr "补丁的管理问题"
13728 #. type: Content of: <book><chapter><sect1><para>
13729 #: ../en/ch11-mq.xml:10
13730 msgid ""
13731 "Here is a common scenario: you need to install a software package from "
13732 "source, but you find a bug that you must fix in the source before you can "
13733 "start using the package. You make your changes, forget about the package for "
13734 "a while, and a few months later you need to upgrade to a newer version of the "
13735 "package. If the newer version of the package still has the bug, you must "
13736 "extract your fix from the older source tree and apply it against the newer "
13737 "version. This is a tedious task, and it's easy to make mistakes."
13738 msgstr ""
13740 #. type: Content of: <book><chapter><sect1><para>
13741 #: ../en/ch11-mq.xml:20
13742 msgid ""
13743 "This is a simple case of the <quote>patch management</quote> problem. You "
13744 "have an <quote>upstream</quote> source tree that you can't change; you need "
13745 "to make some local changes on top of the upstream tree; and you'd like to be "
13746 "able to keep those changes separate, so that you can apply them to newer "
13747 "versions of the upstream source."
13748 msgstr ""
13750 #. type: Content of: <book><chapter><sect1><para>
13751 #: ../en/ch11-mq.xml:27
13752 msgid ""
13753 "The patch management problem arises in many situations. Probably the most "
13754 "visible is that a user of an open source software project will contribute a "
13755 "bug fix or new feature to the project's maintainers in the form of a patch."
13756 msgstr ""
13758 #. type: Content of: <book><chapter><sect1><para>
13759 #: ../en/ch11-mq.xml:32
13760 msgid ""
13761 "Distributors of operating systems that include open source software often "
13762 "need to make changes to the packages they distribute so that they will build "
13763 "properly in their environments."
13764 msgstr ""
13766 #. type: Content of: <book><chapter><sect1><para>
13767 #: ../en/ch11-mq.xml:37
13768 msgid ""
13769 "When you have few changes to maintain, it is easy to manage a single patch "
13770 "using the standard <command>diff</command> and <command>patch</command> "
13771 "programs (see <xref linkend=\"sec:mq:patch\"/> for a discussion of these "
13772 "tools). Once the number of changes grows, it starts to make sense to maintain "
13773 "patches as discrete <quote>chunks of work,</quote> so that for example a "
13774 "single patch will contain only one bug fix (the patch might modify several "
13775 "files, but it's doing <quote>only one thing</quote>), and you may have a "
13776 "number of such patches for different bugs you need fixed and local changes "
13777 "you require. In this situation, if you submit a bug fix patch to the "
13778 "upstream maintainers of a package and they include your fix in a subsequent "
13779 "release, you can simply drop that single patch when you're updating to the "
13780 "newer release."
13781 msgstr ""
13783 #. type: Content of: <book><chapter><sect1><para>
13784 #: ../en/ch11-mq.xml:52
13785 msgid ""
13786 "Maintaining a single patch against an upstream tree is a little tedious and "
13787 "error-prone, but not difficult. However, the complexity of the problem grows "
13788 "rapidly as the number of patches you have to maintain increases. With more "
13789 "than a tiny number of patches in hand, understanding which ones you have "
13790 "applied and maintaining them moves from messy to overwhelming."
13791 msgstr ""
13793 #. type: Content of: <book><chapter><sect1><para>
13794 #: ../en/ch11-mq.xml:59
13795 msgid ""
13796 "Fortunately, Mercurial includes a powerful extension, Mercurial Queues (or "
13797 "simply <quote>MQ</quote>), that massively simplifies the patch management "
13798 "problem."
13799 msgstr ""
13801 #. type: Content of: <book><chapter><sect1><title>
13802 #: ../en/ch11-mq.xml:65
13803 msgid "The prehistory of Mercurial Queues"
13804 msgstr "MQ 的历史"
13806 #. type: Content of: <book><chapter><sect1><para>
13807 #: ../en/ch11-mq.xml:67
13808 msgid ""
13809 "During the late 1990s, several Linux kernel developers started to maintain "
13810 "<quote>patch series</quote> that modified the behavior of the Linux kernel. "
13811 "Some of these series were focused on stability, some on feature coverage, and "
13812 "others were more speculative."
13813 msgstr ""
13815 #. type: Content of: <book><chapter><sect1><para>
13816 #: ../en/ch11-mq.xml:73
13817 msgid ""
13818 "The sizes of these patch series grew rapidly. In 2002, Andrew Morton "
13819 "published some shell scripts he had been using to automate the task of "
13820 "managing his patch queues. Andrew was successfully using these scripts to "
13821 "manage hundreds (sometimes thousands) of patches on top of the Linux kernel."
13822 msgstr ""
13824 #. type: Content of: <book><chapter><sect1><sect2><title>
13825 #: ../en/ch11-mq.xml:80
13826 msgid "A patchwork quilt"
13827 msgstr ""
13829 #. type: Content of: <book><chapter><sect1><sect2><para>
13830 #: ../en/ch11-mq.xml:82
13831 msgid ""
13832 "In early 2003, Andreas Gruenbacher and Martin Quinson borrowed the approach "
13833 "of Andrew's scripts and published a tool called <quote>patchwork quilt</"
13834 "quote> <citation>web:quilt</citation>, or simply <quote>quilt</quote> (see "
13835 "<citation>gruenbacher:2005</citation> for a paper describing it). Because "
13836 "quilt substantially automated patch management, it rapidly gained a large "
13837 "following among open source software developers."
13838 msgstr ""
13840 #. type: Content of: <book><chapter><sect1><sect2><para>
13841 #: ../en/ch11-mq.xml:91
13842 msgid ""
13843 "Quilt manages a <emphasis>stack of patches</emphasis> on top of a directory "
13844 "tree. To begin, you tell quilt to manage a directory tree, and tell it which "
13845 "files you want to manage; it stores away the names and contents of those "
13846 "files. To fix a bug, you create a new patch (using a single command), edit "
13847 "the files you need to fix, then <quote>refresh</quote> the patch."
13848 msgstr ""
13850 #. type: Content of: <book><chapter><sect1><sect2><para>
13851 #: ../en/ch11-mq.xml:99
13852 msgid ""
13853 "The refresh step causes quilt to scan the directory tree; it updates the "
13854 "patch with all of the changes you have made. You can create another patch on "
13855 "top of the first, which will track the changes required to modify the tree "
13856 "from <quote>tree with one patch applied</quote> to <quote>tree with two "
13857 "patches applied</quote>."
13858 msgstr ""
13860 #. type: Content of: <book><chapter><sect1><sect2><para>
13861 #: ../en/ch11-mq.xml:106
13862 msgid ""
13863 "You can <emphasis>change</emphasis> which patches are applied to the tree. "
13864 "If you <quote>pop</quote> a patch, the changes made by that patch will vanish "
13865 "from the directory tree. Quilt remembers which patches you have popped, "
13866 "though, so you can <quote>push</quote> a popped patch again, and the "
13867 "directory tree will be restored to contain the modifications in the patch. "
13868 "Most importantly, you can run the <quote>refresh</quote> command at any time, "
13869 "and the topmost applied patch will be updated. This means that you can, at "
13870 "any time, change both which patches are applied and what modifications those "
13871 "patches make."
13872 msgstr ""
13874 #. type: Content of: <book><chapter><sect1><sect2><para>
13875 #: ../en/ch11-mq.xml:118
13876 msgid ""
13877 "Quilt knows nothing about revision control tools, so it works equally well on "
13878 "top of an unpacked tarball or a Subversion working copy."
13879 msgstr ""
13881 #. type: Content of: <book><chapter><sect1><sect2><title>
13882 #: ../en/ch11-mq.xml:124
13883 msgid "From patchwork quilt to Mercurial Queues"
13884 msgstr "从 patchwork quilt 到 MQ"
13886 #. type: Content of: <book><chapter><sect1><sect2><para>
13887 #: ../en/ch11-mq.xml:126
13888 msgid ""
13889 "In mid-2005, Chris Mason took the features of quilt and wrote an extension "
13890 "that he called Mercurial Queues, which added quilt-like behavior to Mercurial."
13891 msgstr ""
13893 #. type: Content of: <book><chapter><sect1><sect2><para>
13894 #: ../en/ch11-mq.xml:130
13895 msgid ""
13896 "The key difference between quilt and MQ is that quilt knows nothing about "
13897 "revision control systems, while MQ is <emphasis>integrated</emphasis> into "
13898 "Mercurial. Each patch that you push is represented as a Mercurial "
13899 "changeset. Pop a patch, and the changeset goes away."
13900 msgstr ""
13902 #. type: Content of: <book><chapter><sect1><sect2><para>
13903 #: ../en/ch11-mq.xml:136
13904 msgid ""
13905 "Because quilt does not care about revision control tools, it is still a "
13906 "tremendously useful piece of software to know about for situations where you "
13907 "cannot use Mercurial and MQ."
13908 msgstr ""
13910 #. type: Content of: <book><chapter><sect1><title>
13911 #: ../en/ch11-mq.xml:144
13912 msgid "The huge advantage of MQ"
13913 msgstr "MQ 的巨大优势"
13915 #. type: Content of: <book><chapter><sect1><para>
13916 #: ../en/ch11-mq.xml:146
13917 msgid ""
13918 "I cannot overstate the value that MQ offers through the unification of "
13919 "patches and revision control."
13920 msgstr ""
13922 #. type: Content of: <book><chapter><sect1><para>
13923 #: ../en/ch11-mq.xml:149
13924 msgid ""
13925 "A major reason that patches have persisted in the free software and open "
13926 "source world&emdash;in spite of the availability of increasingly capable "
13927 "revision control tools over the years&emdash;is the <emphasis>agility</"
13928 "emphasis> they offer."
13929 msgstr ""
13931 #. type: Content of: <book><chapter><sect1><para>
13932 #: ../en/ch11-mq.xml:155
13933 msgid ""
13934 "Traditional revision control tools make a permanent, irreversible record of "
13935 "everything that you do. While this has great value, it's also somewhat "
13936 "stifling. If you want to perform a wild-eyed experiment, you have to be "
13937 "careful in how you go about it, or you risk leaving unneeded&emdash;or worse, "
13938 "misleading or destabilising&emdash;traces of your missteps and errors in the "
13939 "permanent revision record."
13940 msgstr ""
13942 #. type: Content of: <book><chapter><sect1><para>
13943 #: ../en/ch11-mq.xml:163
13944 msgid ""
13945 "By contrast, MQ's marriage of distributed revision control with patches makes "
13946 "it much easier to isolate your work. Your patches live on top of normal "
13947 "revision history, and you can make them disappear or reappear at will. If "
13948 "you don't like a patch, you can drop it. If a patch isn't quite as you want "
13949 "it to be, simply fix it&emdash;as many times as you need to, until you have "
13950 "refined it into the form you desire."
13951 msgstr ""
13953 #. type: Content of: <book><chapter><sect1><para>
13954 #: ../en/ch11-mq.xml:171
13955 msgid ""
13956 "As an example, the integration of patches with revision control makes "
13957 "understanding patches and debugging their effects&emdash;and their interplay "
13958 "with the code they're based on&emdash;<emphasis>enormously</emphasis> easier. "
13959 "Since every applied patch has an associated changeset, you can give <command "
13960 "role=\"hg-cmd\">hg log</command> a file name to see which changesets and "
13961 "patches affected the file. You can use the <command role=\"hg-cmd\">hg "
13962 "bisect</command> command to binary-search through all changesets and applied "
13963 "patches to see where a bug got introduced or fixed. You can use the <command "
13964 "role=\"hg-cmd\">hg annotate</command> command to see which changeset or patch "
13965 "modified a particular line of a source file. And so on."
13966 msgstr ""
13968 #. type: Content of: <book><chapter><sect1><para>
13969 #: ../en/ch11-mq.xml:189
13970 msgid ""
13971 "Because MQ doesn't hide its patch-oriented nature, it is helpful to "
13972 "understand what patches are, and a little about the tools that work with them."
13973 msgstr ""
13975 #. type: Content of: <book><chapter><sect1><para>
13976 #: ../en/ch11-mq.xml:193
13977 msgid ""
13978 "The traditional Unix <command>diff</command> command compares two files, and "
13979 "prints a list of differences between them. The <command>patch</command> "
13980 "command understands these differences as <emphasis>modifications</emphasis> "
13981 "to make to a file. Take a look below for a simple example of these commands "
13982 "in action."
13983 msgstr ""
13985 #. type: Content of: <book><chapter><sect1><para>
13986 #: ../en/ch11-mq.xml:202
13987 msgid ""
13988 "The type of file that <command>diff</command> generates (and <command>patch</"
13989 "command> takes as input) is called a <quote>patch</quote> or a <quote>diff</"
13990 "quote>; there is no difference between a patch and a diff. (We'll use the "
13991 "term <quote>patch</quote>, since it's more commonly used.)"
13992 msgstr ""
13994 #. type: Content of: <book><chapter><sect1><para>
13995 #: ../en/ch11-mq.xml:208
13996 msgid ""
13997 "A patch file can start with arbitrary text; the <command>patch</command> "
13998 "command ignores this text, but MQ uses it as the commit message when creating "
13999 "changesets. To find the beginning of the patch content, <command>patch</"
14000 "command> searches for the first line that starts with the string "
14001 "<quote><literal>diff -</literal></quote>."
14002 msgstr ""
14004 #. type: Content of: <book><chapter><sect1><para>
14005 #: ../en/ch11-mq.xml:215
14006 msgid ""
14007 "MQ works with <emphasis>unified</emphasis> diffs (<command>patch</command> "
14008 "can accept several other diff formats, but MQ doesn't). A unified diff "
14009 "contains two kinds of header. The <emphasis>file header</emphasis> describes "
14010 "the file being modified; it contains the name of the file to modify. When "
14011 "<command>patch</command> sees a new file header, it looks for a file with "
14012 "that name to start modifying."
14013 msgstr ""
14015 #. type: Content of: <book><chapter><sect1><para>
14016 #: ../en/ch11-mq.xml:223
14017 msgid ""
14018 "After the file header comes a series of <emphasis>hunks</emphasis>. Each "
14019 "hunk starts with a header; this identifies the range of line numbers within "
14020 "the file that the hunk should modify. Following the header, a hunk starts "
14021 "and ends with a few (usually three) lines of text from the unmodified file; "
14022 "these are called the <emphasis>context</emphasis> for the hunk. If there's "
14023 "only a small amount of context between successive hunks, <command>diff</"
14024 "command> doesn't print a new hunk header; it just runs the hunks together, "
14025 "with a few lines of context between modifications."
14026 msgstr ""
14028 #. type: Content of: <book><chapter><sect1><para>
14029 #: ../en/ch11-mq.xml:235
14030 msgid ""
14031 "Each line of context begins with a space character. Within the hunk, a line "
14032 "that begins with <quote><literal>-</literal></quote> means <quote>remove this "
14033 "line,</quote> while a line that begins with <quote><literal>+</literal></"
14034 "quote> means <quote>insert this line.</quote> For example, a line that is "
14035 "modified is represented by one deletion and one insertion."
14036 msgstr ""
14038 #. type: Content of: <book><chapter><sect1><para>
14039 #: ../en/ch11-mq.xml:243
14040 msgid ""
14041 "We will return to some of the more subtle aspects of patches later (in <xref "
14042 "linkend=\"sec:mq:adv-patch\"/>), but you should have enough information now "
14043 "to use MQ."
14044 msgstr ""
14046 #. type: Content of: <book><chapter><sect1><title>
14047 #: ../en/ch11-mq.xml:250
14048 msgid "Getting started with Mercurial Queues"
14049 msgstr "开始使用 MQ"
14051 #. type: Content of: <book><chapter><sect1><para>
14052 #: ../en/ch11-mq.xml:252
14053 msgid ""
14054 "Because MQ is implemented as an extension, you must explicitly enable before "
14055 "you can use it. (You don't need to download anything; MQ ships with the "
14056 "standard Mercurial distribution.) To enable MQ, edit your <filename role="
14057 "\"home\">~/.hgrc</filename> file, and add the lines below."
14058 msgstr ""
14060 #. type: Content of: <book><chapter><sect1><para>
14061 #: ../en/ch11-mq.xml:262
14062 msgid ""
14063 "Once the extension is enabled, it will make a number of new commands "
14064 "available. To verify that the extension is working, you can use <command "
14065 "role=\"hg-cmd\">hg help</command> to see if the <command role=\"hg-ext-mq"
14066 "\">qinit</command> command is now available."
14067 msgstr ""
14069 #. type: Content of: <book><chapter><sect1><para>
14070 #: ../en/ch11-mq.xml:270
14071 msgid ""
14072 "You can use MQ with <emphasis>any</emphasis> Mercurial repository, and its "
14073 "commands only operate within that repository. To get started, simply prepare "
14074 "the repository using the <command role=\"hg-ext-mq\">qinit</command> command."
14075 msgstr ""
14077 #. type: Content of: <book><chapter><sect1><para>
14078 #: ../en/ch11-mq.xml:277
14079 msgid ""
14080 "This command creates an empty directory called <filename role=\"special\" "
14081 "class=\"directory\">.hg/patches</filename>, where MQ will keep its metadata. "
14082 "As with many Mercurial commands, the <command role=\"hg-ext-mq\">qinit</"
14083 "command> command prints nothing if it succeeds."
14084 msgstr ""
14086 #. type: Content of: <book><chapter><sect1><sect2><title>
14087 #: ../en/ch11-mq.xml:284
14088 msgid "Creating a new patch"
14089 msgstr "创建新补丁"
14091 #. type: Content of: <book><chapter><sect1><sect2><para>
14092 #: ../en/ch11-mq.xml:286
14093 msgid ""
14094 "To begin work on a new patch, use the <command role=\"hg-ext-mq\">qnew</"
14095 "command> command. This command takes one argument, the name of the patch to "
14096 "create."
14097 msgstr ""
14099 #. type: Content of: <book><chapter><sect1><sect2><para>
14100 #: ../en/ch11-mq.xml:290
14101 msgid ""
14102 "MQ will use this as the name of an actual file in the <filename role=\"special"
14103 "\" class=\"directory\">.hg/patches</filename> directory, as you can see below."
14104 msgstr ""
14106 #. type: Content of: <book><chapter><sect1><sect2><para>
14107 #: ../en/ch11-mq.xml:297
14108 msgid ""
14109 "Also newly present in the <filename role=\"special\" class=\"directory\">.hg/"
14110 "patches</filename> directory are two other files, <filename role=\"special"
14111 "\">series</filename> and <filename role=\"special\">status</filename>. The "
14112 "<filename role=\"special\">series</filename> file lists all of the patches "
14113 "that MQ knows about for this repository, with one patch per line. Mercurial "
14114 "uses the <filename role=\"special\">status</filename> file for internal book-"
14115 "keeping; it tracks all of the patches that MQ has <emphasis>applied</"
14116 "emphasis> in this repository."
14117 msgstr ""
14119 #. type: Content of: <book><chapter><sect1><sect2><note><para>
14120 #: ../en/ch11-mq.xml:309
14121 msgid ""
14122 "You may sometimes want to edit the <filename role=\"special\">series</"
14123 "filename> file by hand; for example, to change the sequence in which some "
14124 "patches are applied. However, manually editing the <filename role=\"special"
14125 "\">status</filename> file is almost always a bad idea, as it's easy to "
14126 "corrupt MQ's idea of what is happening."
14127 msgstr ""
14129 #. type: Content of: <book><chapter><sect1><sect2><para>
14130 #: ../en/ch11-mq.xml:318
14131 msgid ""
14132 "Once you have created your new patch, you can edit files in the working "
14133 "directory as you usually would. All of the normal Mercurial commands, such "
14134 "as <command role=\"hg-cmd\">hg diff</command> and <command role=\"hg-cmd\">hg "
14135 "annotate</command>, work exactly as they did before."
14136 msgstr ""
14138 #. type: Content of: <book><chapter><sect1><sect2><title>
14139 #: ../en/ch11-mq.xml:326
14140 msgid "Refreshing a patch"
14141 msgstr "刷新补丁"
14143 #. type: Content of: <book><chapter><sect1><sect2><para>
14144 #: ../en/ch11-mq.xml:328
14145 msgid ""
14146 "When you reach a point where you want to save your work, use the <command "
14147 "role=\"hg-ext-mq\">qrefresh</command> command to update the patch you are "
14148 "working on."
14149 msgstr ""
14151 #. type: Content of: <book><chapter><sect1><sect2><para>
14152 #: ../en/ch11-mq.xml:334
14153 msgid ""
14154 "This command folds the changes you have made in the working directory into "
14155 "your patch, and updates its corresponding changeset to contain those changes."
14156 msgstr ""
14158 #. type: Content of: <book><chapter><sect1><sect2><para>
14159 #: ../en/ch11-mq.xml:338
14160 msgid ""
14161 "You can run <command role=\"hg-ext-mq\">qrefresh</command> as often as you "
14162 "like, so it's a good way to <quote>checkpoint</quote> your work. Refresh "
14163 "your patch at an opportune time; try an experiment; and if the experiment "
14164 "doesn't work out, <command role=\"hg-cmd\">hg revert</command> your "
14165 "modifications back to the last time you refreshed."
14166 msgstr ""
14168 #. type: Content of: <book><chapter><sect1><sect2><title>
14169 #: ../en/ch11-mq.xml:349
14170 msgid "Stacking and tracking patches"
14171 msgstr "堆叠和跟踪补丁"
14173 #. type: Content of: <book><chapter><sect1><sect2><para>
14174 #: ../en/ch11-mq.xml:351
14175 msgid ""
14176 "Once you have finished working on a patch, or need to work on another, you "
14177 "can use the <command role=\"hg-ext-mq\">qnew</command> command again to "
14178 "create a new patch. Mercurial will apply this patch on top of your existing "
14179 "patch."
14180 msgstr ""
14182 #. type: Content of: <book><chapter><sect1><sect2><para>
14183 #: ../en/ch11-mq.xml:358
14184 msgid ""
14185 "Notice that the patch contains the changes in our prior patch as part of its "
14186 "context (you can see this more clearly in the output of <command role=\"hg-cmd"
14187 "\">hg annotate</command>)."
14188 msgstr ""
14190 #. type: Content of: <book><chapter><sect1><sect2><para>
14191 #: ../en/ch11-mq.xml:363
14192 msgid ""
14193 "So far, with the exception of <command role=\"hg-ext-mq\">qnew</command> and "
14194 "<command role=\"hg-ext-mq\">qrefresh</command>, we've been careful to only "
14195 "use regular Mercurial commands. However, MQ provides many commands that are "
14196 "easier to use when you are thinking about patches, as illustrated below."
14197 msgstr ""
14199 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14200 #: ../en/ch11-mq.xml:373
14201 msgid ""
14202 "The <command role=\"hg-ext-mq\">qseries</command> command lists every patch "
14203 "that MQ knows about in this repository, from oldest to newest (most recently "
14204 "<emphasis>created</emphasis>)."
14205 msgstr ""
14207 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14208 #: ../en/ch11-mq.xml:379
14209 msgid ""
14210 "The <command role=\"hg-ext-mq\">qapplied</command> command lists every patch "
14211 "that MQ has <emphasis>applied</emphasis> in this repository, again from "
14212 "oldest to newest (most recently applied)."
14213 msgstr ""
14215 #. type: Content of: <book><chapter><sect1><sect2><title>
14216 #: ../en/ch11-mq.xml:388
14217 msgid "Manipulating the patch stack"
14218 msgstr "操作补丁堆栈"
14220 #. type: Content of: <book><chapter><sect1><sect2><para>
14221 #: ../en/ch11-mq.xml:390
14222 msgid ""
14223 "The previous discussion implied that there must be a difference between "
14224 "<quote>known</quote> and <quote>applied</quote> patches, and there is. MQ "
14225 "can manage a patch without it being applied in the repository."
14226 msgstr ""
14228 #. type: Content of: <book><chapter><sect1><sect2><para>
14229 #: ../en/ch11-mq.xml:395
14230 msgid ""
14231 "An <emphasis>applied</emphasis> patch has a corresponding changeset in the "
14232 "repository, and the effects of the patch and changeset are visible in the "
14233 "working directory. You can undo the application of a patch using the "
14234 "<command role=\"hg-ext-mq\">qpop</command> command. MQ still <emphasis>knows "
14235 "about</emphasis>, or manages, a popped patch, but the patch no longer has a "
14236 "corresponding changeset in the repository, and the working directory does not "
14237 "contain the changes made by the patch. <xref linkend=\"fig:mq:stack\"/> "
14238 "illustrates the difference between applied and tracked patches."
14239 msgstr ""
14241 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
14242 #: ../en/ch11-mq.xml:408
14243 msgid "Applied and unapplied patches in the MQ patch stack"
14244 msgstr "在 MQ 补丁堆栈中应用和撤销补丁"
14246 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
14247 #: ../en/ch11-mq.xml:411
14248 msgid "<imageobject><imagedata fileref=\"figs/mq-stack.png\"/></imageobject>"
14249 msgstr ""
14251 #. type: Content of: <book><chapter><sect1><sect2><para>
14252 #: ../en/ch11-mq.xml:416
14253 msgid ""
14254 "You can reapply an unapplied, or popped, patch using the <command role=\"hg-"
14255 "ext-mq\">qpush</command> command. This creates a new changeset to correspond "
14256 "to the patch, and the patch's changes once again become present in the "
14257 "working directory. See below for examples of <command role=\"hg-ext-mq"
14258 "\">qpop</command> and <command role=\"hg-ext-mq\">qpush</command> in action."
14259 msgstr ""
14261 #. type: Content of: <book><chapter><sect1><sect2><para>
14262 #: ../en/ch11-mq.xml:425
14263 msgid ""
14264 "Notice that once we have popped a patch or two patches, the output of "
14265 "<command role=\"hg-ext-mq\">qseries</command> remains the same, while that of "
14266 "<command role=\"hg-ext-mq\">qapplied</command> has changed."
14267 msgstr ""
14269 #. type: Content of: <book><chapter><sect1><sect2><title>
14270 #: ../en/ch11-mq.xml:433
14271 msgid "Pushing and popping many patches"
14272 msgstr "压入或弹出多个补丁"
14274 #. type: Content of: <book><chapter><sect1><sect2><para>
14275 #: ../en/ch11-mq.xml:435
14276 msgid ""
14277 "While <command role=\"hg-ext-mq\">qpush</command> and <command role=\"hg-ext-"
14278 "mq\">qpop</command> each operate on a single patch at a time by default, you "
14279 "can push and pop many patches in one go. The <option role=\"hg-ext-mq-cmd-"
14280 "qpush-opt\">hg -a</option> option to <command role=\"hg-ext-mq\">qpush</"
14281 "command> causes it to push all unapplied patches, while the <option role=\"hg-"
14282 "ext-mq-cmd-qpop-opt\">-a</option> option to <command role=\"hg-ext-mq\">qpop</"
14283 "command> causes it to pop all applied patches. (For some more ways to push "
14284 "and pop many patches, see <xref linkend=\"sec:mq:perf\"/> below.)"
14285 msgstr ""
14287 #. type: Content of: <book><chapter><sect1><sect2><title>
14288 #: ../en/ch11-mq.xml:451
14289 msgid "Safety checks, and overriding them"
14290 msgstr "安全的检查,然后覆盖它们"
14292 #. type: Content of: <book><chapter><sect1><sect2><para>
14293 #: ../en/ch11-mq.xml:453
14294 msgid ""
14295 "Several MQ commands check the working directory before they do anything, and "
14296 "fail if they find any modifications. They do this to ensure that you won't "
14297 "lose any changes that you have made, but not yet incorporated into a patch. "
14298 "The example below illustrates this; the <command role=\"hg-ext-mq\">qnew</"
14299 "command> command will not create a new patch if there are outstanding "
14300 "changes, caused in this case by the <command role=\"hg-cmd\">hg add</command> "
14301 "of <filename>file3</filename>."
14302 msgstr ""
14304 #. type: Content of: <book><chapter><sect1><sect2><para>
14305 #: ../en/ch11-mq.xml:465
14306 msgid ""
14307 "Commands that check the working directory all take an <quote>I know what I'm "
14308 "doing</quote> option, which is always named <option>-f</option>. The exact "
14309 "meaning of <option>-f</option> depends on the command. For example, <command "
14310 "role=\"hg-cmd\">hg qnew <option role=\"hg-ext-mq-cmd-qnew-opt\">hg -f</"
14311 "option></command> will incorporate any outstanding changes into the new patch "
14312 "it creates, but <command role=\"hg-cmd\">hg qpop <option role=\"hg-ext-mq-cmd-"
14313 "qpop-opt\">hg -f</option></command> will revert modifications to any files "
14314 "affected by the patch that it is popping. Be sure to read the documentation "
14315 "for a command's <option>-f</option> option before you use it!"
14316 msgstr ""
14318 #. type: Content of: <book><chapter><sect1><sect2><title>
14319 #: ../en/ch11-mq.xml:480
14320 msgid "Working on several patches at once"
14321 msgstr "同时处理多个补丁"
14323 #. type: Content of: <book><chapter><sect1><sect2><para>
14324 #: ../en/ch11-mq.xml:482
14325 msgid ""
14326 "The <command role=\"hg-ext-mq\">qrefresh</command> command always refreshes "
14327 "the <emphasis>topmost</emphasis> applied patch. This means that you can "
14328 "suspend work on one patch (by refreshing it), pop or push to make a different "
14329 "patch the top, and work on <emphasis>that</emphasis> patch for a while."
14330 msgstr ""
14332 #. type: Content of: <book><chapter><sect1><sect2><para>
14333 #: ../en/ch11-mq.xml:489
14334 msgid ""
14335 "Here's an example that illustrates how you can use this ability. Let's say "
14336 "you're developing a new feature as two patches. The first is a change to the "
14337 "core of your software, and the second&emdash;layered on top of the "
14338 "first&emdash;changes the user interface to use the code you just added to the "
14339 "core. If you notice a bug in the core while you're working on the UI patch, "
14340 "it's easy to fix the core. Simply <command role=\"hg-ext-mq\">qrefresh</"
14341 "command> the UI patch to save your in-progress changes, and <command role="
14342 "\"hg-ext-mq\">qpop</command> down to the core patch. Fix the core bug, "
14343 "<command role=\"hg-ext-mq\">qrefresh</command> the core patch, and <command "
14344 "role=\"hg-ext-mq\">qpush</command> back to the UI patch to continue where you "
14345 "left off."
14346 msgstr ""
14348 #. type: Content of: <book><chapter><sect1><title>
14349 #: ../en/ch11-mq.xml:506
14350 msgid "More about patches"
14351 msgstr "关于补丁的更多信息"
14353 #. type: Content of: <book><chapter><sect1><para>
14354 #: ../en/ch11-mq.xml:508
14355 msgid ""
14356 "MQ uses the GNU <command>patch</command> command to apply patches, so it's "
14357 "helpful to know a few more detailed aspects of how <command>patch</command> "
14358 "works, and about patches themselves."
14359 msgstr ""
14361 #. type: Content of: <book><chapter><sect1><sect2><title>
14362 #: ../en/ch11-mq.xml:514
14363 msgid "The strip count"
14364 msgstr "修剪计数"
14366 #. type: Content of: <book><chapter><sect1><sect2><para>
14367 #: ../en/ch11-mq.xml:516
14368 msgid ""
14369 "If you look at the file headers in a patch, you will notice that the "
14370 "pathnames usually have an extra component on the front that isn't present in "
14371 "the actual path name. This is a holdover from the way that people used to "
14372 "generate patches (people still do this, but it's somewhat rare with modern "
14373 "revision control tools)."
14374 msgstr ""
14376 #. type: Content of: <book><chapter><sect1><sect2><para>
14377 #: ../en/ch11-mq.xml:523
14378 msgid ""
14379 "Alice would unpack a tarball, edit her files, then decide that she wanted to "
14380 "create a patch. So she'd rename her working directory, unpack the tarball "
14381 "again (hence the need for the rename), and use the <option role=\"cmd-opt-diff"
14382 "\">-r</option> and <option role=\"cmd-opt-diff\">-N</option> options to "
14383 "<command>diff</command> to recursively generate a patch between the "
14384 "unmodified directory and the modified one. The result would be that the name "
14385 "of the unmodified directory would be at the front of the left-hand path in "
14386 "every file header, and the name of the modified directory would be at the "
14387 "front of the right-hand path."
14388 msgstr ""
14390 #. type: Content of: <book><chapter><sect1><sect2><para>
14391 #: ../en/ch11-mq.xml:536
14392 msgid ""
14393 "Since someone receiving a patch from the Alices of the net would be unlikely "
14394 "to have unmodified and modified directories with exactly the same names, the "
14395 "<command>patch</command> command has a <option role=\"cmd-opt-patch\">-p</"
14396 "option> option that indicates the number of leading path name components to "
14397 "strip when trying to apply a patch. This number is called the "
14398 "<emphasis>strip count</emphasis>."
14399 msgstr ""
14401 #. type: Content of: <book><chapter><sect1><sect2><para>
14402 #: ../en/ch11-mq.xml:544
14403 msgid ""
14404 "An option of <quote><literal>-p1</literal></quote> means <quote>use a strip "
14405 "count of one</quote>. If <command>patch</command> sees a file name "
14406 "<filename>foo/bar/baz</filename> in a file header, it will strip "
14407 "<filename>foo</filename> and try to patch a file named <filename>bar/baz</"
14408 "filename>. (Strictly speaking, the strip count refers to the number of "
14409 "<emphasis>path separators</emphasis> (and the components that go with them ) "
14410 "to strip. A strip count of one will turn <filename>foo/bar</filename> into "
14411 "<filename>bar</filename>, but <filename>/foo/bar</filename> (notice the extra "
14412 "leading slash) into <filename>foo/bar</filename>.)"
14413 msgstr ""
14415 #. type: Content of: <book><chapter><sect1><sect2><para>
14416 #: ../en/ch11-mq.xml:557
14417 msgid ""
14418 "The <quote>standard</quote> strip count for patches is one; almost all "
14419 "patches contain one leading path name component that needs to be stripped. "
14420 "Mercurial's <command role=\"hg-cmd\">hg diff</command> command generates path "
14421 "names in this form, and the <command role=\"hg-cmd\">hg import</command> "
14422 "command and MQ expect patches to have a strip count of one."
14423 msgstr ""
14425 #. type: Content of: <book><chapter><sect1><sect2><para>
14426 #: ../en/ch11-mq.xml:565
14427 msgid ""
14428 "If you receive a patch from someone that you want to add to your patch queue, "
14429 "and the patch needs a strip count other than one, you cannot just <command "
14430 "role=\"hg-ext-mq\">qimport</command> the patch, because <command role=\"hg-"
14431 "ext-mq\">qimport</command> does not yet have a <literal>-p</literal> option "
14432 "(see <ulink role=\"hg-bug\" url=\"http://www.selenic.com/mercurial/bts/"
14433 "issue311\">issue 311</ulink>). Your best bet is to <command role=\"hg-ext-mq"
14434 "\">qnew</command> a patch of your own, then use <command>patch -pN</command> "
14435 "to apply their patch, followed by <command role=\"hg-cmd\">hg addremove</"
14436 "command> to pick up any files added or removed by the patch, followed by "
14437 "<command role=\"hg-ext-mq\">hg qrefresh</command>. This complexity may become "
14438 "unnecessary; see <ulink role=\"hg-bug\" url=\"http://www.selenic.com/"
14439 "mercurial/bts/issue311\">issue 311</ulink> for details."
14440 msgstr ""
14442 #. type: Content of: <book><chapter><sect1><sect2><title>
14443 #: ../en/ch11-mq.xml:584
14444 msgid "Strategies for applying a patch"
14445 msgstr "应用补丁的策略"
14447 #. type: Content of: <book><chapter><sect1><sect2><para>
14448 #: ../en/ch11-mq.xml:586
14449 msgid ""
14450 "When <command>patch</command> applies a hunk, it tries a handful of "
14451 "successively less accurate strategies to try to make the hunk apply. This "
14452 "falling-back technique often makes it possible to take a patch that was "
14453 "generated against an old version of a file, and apply it against a newer "
14454 "version of that file."
14455 msgstr ""
14457 #. type: Content of: <book><chapter><sect1><sect2><para>
14458 #: ../en/ch11-mq.xml:593
14459 msgid ""
14460 "First, <command>patch</command> tries an exact match, where the line numbers, "
14461 "the context, and the text to be modified must apply exactly. If it cannot "
14462 "make an exact match, it tries to find an exact match for the context, without "
14463 "honouring the line numbering information. If this succeeds, it prints a line "
14464 "of output saying that the hunk was applied, but at some <emphasis>offset</"
14465 "emphasis> from the original line number."
14466 msgstr ""
14468 #. type: Content of: <book><chapter><sect1><sect2><para>
14469 #: ../en/ch11-mq.xml:602
14470 msgid ""
14471 "If a context-only match fails, <command>patch</command> removes the first and "
14472 "last lines of the context, and tries a <emphasis>reduced</emphasis> context-"
14473 "only match. If the hunk with reduced context succeeds, it prints a message "
14474 "saying that it applied the hunk with a <emphasis>fuzz factor</emphasis> (the "
14475 "number after the fuzz factor indicates how many lines of context "
14476 "<command>patch</command> had to trim before the patch applied)."
14477 msgstr ""
14479 #. type: Content of: <book><chapter><sect1><sect2><para>
14480 #: ../en/ch11-mq.xml:611
14481 msgid ""
14482 "When neither of these techniques works, <command>patch</command> prints a "
14483 "message saying that the hunk in question was rejected. It saves rejected "
14484 "hunks (also simply called <quote>rejects</quote>) to a file with the same "
14485 "name, and an added <filename role=\"special\">.rej</filename> extension. It "
14486 "also saves an unmodified copy of the file with a <filename role=\"special\">."
14487 "orig</filename> extension; the copy of the file without any extensions will "
14488 "contain any changes made by hunks that <emphasis>did</emphasis> apply "
14489 "cleanly. If you have a patch that modifies <filename>foo</filename> with six "
14490 "hunks, and one of them fails to apply, you will have: an unmodified "
14491 "<filename>foo.orig</filename>, a <filename>foo.rej</filename> containing one "
14492 "hunk, and <filename>foo</filename>, containing the changes made by the five "
14493 "successful hunks."
14494 msgstr ""
14496 #. type: Content of: <book><chapter><sect1><sect2><title>
14497 #: ../en/ch11-mq.xml:629
14498 msgid "Some quirks of patch representation"
14499 msgstr "补丁的一些特性"
14501 #. type: Content of: <book><chapter><sect1><sect2><para>
14502 #: ../en/ch11-mq.xml:631
14503 msgid ""
14504 "There are a few useful things to know about how <command>patch</command> "
14505 "works with files."
14506 msgstr ""
14508 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14509 #: ../en/ch11-mq.xml:634
14510 msgid ""
14511 "This should already be obvious, but <command>patch</command> cannot handle "
14512 "binary files."
14513 msgstr ""
14515 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14516 #: ../en/ch11-mq.xml:638
14517 msgid ""
14518 "Neither does it care about the executable bit; it creates new files as "
14519 "readable, but not executable."
14520 msgstr ""
14522 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14523 #: ../en/ch11-mq.xml:642
14524 msgid ""
14525 "<command>patch</command> treats the removal of a file as a diff between the "
14526 "file to be removed and the empty file. So your idea of <quote>I deleted this "
14527 "file</quote> looks like <quote>every line of this file was deleted</quote> in "
14528 "a patch."
14529 msgstr ""
14531 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14532 #: ../en/ch11-mq.xml:648
14533 msgid ""
14534 "It treats the addition of a file as a diff between the empty file and the "
14535 "file to be added. So in a patch, your idea of <quote>I added this file</"
14536 "quote> looks like <quote>every line of this file was added</quote>."
14537 msgstr ""
14539 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14540 #: ../en/ch11-mq.xml:654
14541 msgid ""
14542 "It treats a renamed file as the removal of the old name, and the addition of "
14543 "the new name. This means that renamed files have a big footprint in "
14544 "patches. (Note also that Mercurial does not currently try to infer when "
14545 "files have been renamed or copied in a patch.)"
14546 msgstr ""
14548 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14549 #: ../en/ch11-mq.xml:660
14550 msgid ""
14551 "<command>patch</command> cannot represent empty files, so you cannot use a "
14552 "patch to represent the notion <quote>I added this empty file to the tree</"
14553 "quote>."
14554 msgstr ""
14556 #. type: Content of: <book><chapter><sect1><sect2><title>
14557 #: ../en/ch11-mq.xml:667
14558 msgid "Beware the fuzz"
14559 msgstr "当心毛刺"
14561 #. type: Content of: <book><chapter><sect1><sect2><para>
14562 #: ../en/ch11-mq.xml:669
14563 msgid ""
14564 "While applying a hunk at an offset, or with a fuzz factor, will often be "
14565 "completely successful, these inexact techniques naturally leave open the "
14566 "possibility of corrupting the patched file. The most common cases typically "
14567 "involve applying a patch twice, or at an incorrect location in the file. If "
14568 "<command>patch</command> or <command role=\"hg-ext-mq\">qpush</command> ever "
14569 "mentions an offset or fuzz factor, you should make sure that the modified "
14570 "files are correct afterwards."
14571 msgstr ""
14573 #. type: Content of: <book><chapter><sect1><sect2><para>
14574 #: ../en/ch11-mq.xml:679
14575 msgid ""
14576 "It's often a good idea to refresh a patch that has applied with an offset or "
14577 "fuzz factor; refreshing the patch generates new context information that will "
14578 "make it apply cleanly. I say <quote>often,</quote> not <quote>always,</"
14579 "quote> because sometimes refreshing a patch will make it fail to apply "
14580 "against a different revision of the underlying files. In some cases, such as "
14581 "when you're maintaining a patch that must sit on top of multiple versions of "
14582 "a source tree, it's acceptable to have a patch apply with some fuzz, provided "
14583 "you've verified the results of the patching process in such cases."
14584 msgstr ""
14586 #. type: Content of: <book><chapter><sect1><sect2><title>
14587 #: ../en/ch11-mq.xml:692
14588 msgid "Handling rejection"
14589 msgstr "处理拒绝"
14591 #. type: Content of: <book><chapter><sect1><sect2><para>
14592 #: ../en/ch11-mq.xml:694
14593 msgid ""
14594 "If <command role=\"hg-ext-mq\">qpush</command> fails to apply a patch, it "
14595 "will print an error message and exit. If it has left <filename role=\"special"
14596 "\">.rej</filename> files behind, it is usually best to fix up the rejected "
14597 "hunks before you push more patches or do any further work."
14598 msgstr ""
14600 #. type: Content of: <book><chapter><sect1><sect2><para>
14601 #: ../en/ch11-mq.xml:700
14602 msgid ""
14603 "If your patch <emphasis>used to</emphasis> apply cleanly, and no longer does "
14604 "because you've changed the underlying code that your patches are based on, "
14605 "Mercurial Queues can help; see <xref linkend=\"sec:mq:merge\"/> for details."
14606 msgstr ""
14608 #. type: Content of: <book><chapter><sect1><sect2><para>
14609 #: ../en/ch11-mq.xml:705
14610 msgid ""
14611 "Unfortunately, there aren't any great techniques for dealing with rejected "
14612 "hunks. Most often, you'll need to view the <filename role=\"special\">.rej</"
14613 "filename> file and edit the target file, applying the rejected hunks by hand."
14614 msgstr ""
14616 #. type: Content of: <book><chapter><sect1><sect2><para>
14617 #: ../en/ch11-mq.xml:710
14618 msgid ""
14619 "If you're feeling adventurous, Neil Brown, a Linux kernel hacker, wrote a "
14620 "tool called <command>wiggle</command> <citation>web:wiggle</citation>, which "
14621 "is more vigorous than <command>patch</command> in its attempts to make a "
14622 "patch apply."
14623 msgstr ""
14625 #. type: Content of: <book><chapter><sect1><sect2><para>
14626 #: ../en/ch11-mq.xml:716
14627 msgid ""
14628 "Another Linux kernel hacker, Chris Mason (the author of Mercurial Queues), "
14629 "wrote a similar tool called <command>mpatch</command> <citation>web:mpatch</"
14630 "citation>, which takes a simple approach to automating the application of "
14631 "hunks rejected by <command>patch</command>. The <command>mpatch</command> "
14632 "command can help with four common reasons that a hunk may be rejected:"
14633 msgstr ""
14635 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14636 #: ../en/ch11-mq.xml:725
14637 msgid "The context in the middle of a hunk has changed."
14638 msgstr ""
14640 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14641 #: ../en/ch11-mq.xml:728
14642 msgid "A hunk is missing some context at the beginning or end."
14643 msgstr ""
14645 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14646 #: ../en/ch11-mq.xml:731
14647 msgid ""
14648 "A large hunk might apply better&emdash;either entirely or in part&emdash;if "
14649 "it was broken up into smaller hunks."
14650 msgstr ""
14652 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14653 #: ../en/ch11-mq.xml:735
14654 msgid ""
14655 "A hunk removes lines with slightly different content than those currently "
14656 "present in the file."
14657 msgstr ""
14659 #. type: Content of: <book><chapter><sect1><sect2><para>
14660 #: ../en/ch11-mq.xml:739
14661 msgid ""
14662 "If you use <command>wiggle</command> or <command>mpatch</command>, you should "
14663 "be doubly careful to check your results when you're done. In fact, "
14664 "<command>mpatch</command> enforces this method of double-checking the tool's "
14665 "output, by automatically dropping you into a merge program when it has done "
14666 "its job, so that you can verify its work and finish off any remaining merges."
14667 msgstr ""
14669 #. type: Content of: <book><chapter><sect1><title>
14670 #: ../en/ch11-mq.xml:751
14671 msgid "Getting the best performance out of MQ"
14672 msgstr "MQ 的性能"
14674 #. type: Content of: <book><chapter><sect1><para>
14675 #: ../en/ch11-mq.xml:753
14676 msgid ""
14677 "MQ is very efficient at handling a large number of patches. I ran some "
14678 "performance experiments in mid-2006 for a talk that I gave at the 2006 "
14679 "EuroPython conference <citation>web:europython</citation>. I used as my data "
14680 "set the Linux 2.6.17-mm1 patch series, which consists of 1,738 patches. I "
14681 "applied these on top of a Linux kernel repository containing all 27,472 "
14682 "revisions between Linux 2.6.12-rc2 and Linux 2.6.17."
14683 msgstr ""
14685 #. type: Content of: <book><chapter><sect1><para>
14686 #: ../en/ch11-mq.xml:762
14687 msgid ""
14688 "On my old, slow laptop, I was able to <command role=\"hg-cmd\">hg qpush "
14689 "<option role=\"hg-ext-mq-cmd-qpush-opt\">hg -a</option></command> all 1,738 "
14690 "patches in 3.5 minutes, and <command role=\"hg-cmd\">hg qpop <option role="
14691 "\"hg-ext-mq-cmd-qpop-opt\">hg -a</option></command> them all in 30 seconds. "
14692 "(On a newer laptop, the time to push all patches dropped to two minutes.) I "
14693 "could <command role=\"hg-ext-mq\">qrefresh</command> one of the biggest "
14694 "patches (which made 22,779 lines of changes to 287 files) in 6.6 seconds."
14695 msgstr ""
14697 #. type: Content of: <book><chapter><sect1><para>
14698 #: ../en/ch11-mq.xml:773
14699 msgid ""
14700 "Clearly, MQ is well suited to working in large trees, but there are a few "
14701 "tricks you can use to get the best performance of it."
14702 msgstr ""
14704 #. type: Content of: <book><chapter><sect1><para>
14705 #: ../en/ch11-mq.xml:777
14706 msgid ""
14707 "First of all, try to <quote>batch</quote> operations together. Every time "
14708 "you run <command role=\"hg-ext-mq\">qpush</command> or <command role=\"hg-ext-"
14709 "mq\">qpop</command>, these commands scan the working directory once to make "
14710 "sure you haven't made some changes and then forgotten to run <command role="
14711 "\"hg-ext-mq\">qrefresh</command>. On a small tree, the time that this scan "
14712 "takes is unnoticeable. However, on a medium-sized tree (containing tens of "
14713 "thousands of files), it can take a second or more."
14714 msgstr ""
14716 #. type: Content of: <book><chapter><sect1><para>
14717 #: ../en/ch11-mq.xml:788
14718 msgid ""
14719 "The <command role=\"hg-ext-mq\">qpush</command> and <command role=\"hg-ext-mq"
14720 "\">qpop</command> commands allow you to push and pop multiple patches at a "
14721 "time. You can identify the <quote>destination patch</quote> that you want to "
14722 "end up at. When you <command role=\"hg-ext-mq\">qpush</command> with a "
14723 "destination specified, it will push patches until that patch is at the top of "
14724 "the applied stack. When you <command role=\"hg-ext-mq\">qpop</command> to a "
14725 "destination, MQ will pop patches until the destination patch is at the top."
14726 msgstr ""
14728 #. type: Content of: <book><chapter><sect1><para>
14729 #: ../en/ch11-mq.xml:798
14730 msgid ""
14731 "You can identify a destination patch using either the name of the patch, or "
14732 "by number. If you use numeric addressing, patches are counted from zero; "
14733 "this means that the first patch is zero, the second is one, and so on."
14734 msgstr ""
14736 #. type: Content of: <book><chapter><sect1><title>
14737 #: ../en/ch11-mq.xml:805
14738 msgid "Updating your patches when the underlying code changes"
14739 msgstr "当基础代码改变时,更新补丁的方法"
14741 #. type: Content of: <book><chapter><sect1><para>
14742 #: ../en/ch11-mq.xml:808
14743 msgid ""
14744 "It's common to have a stack of patches on top of an underlying repository "
14745 "that you don't modify directly. If you're working on changes to third-party "
14746 "code, or on a feature that is taking longer to develop than the rate of "
14747 "change of the code beneath, you will often need to sync up with the "
14748 "underlying code, and fix up any hunks in your patches that no longer apply. "
14749 "This is called <emphasis>rebasing</emphasis> your patch series."
14750 msgstr ""
14752 #. type: Content of: <book><chapter><sect1><para>
14753 #: ../en/ch11-mq.xml:817
14754 msgid ""
14755 "The simplest way to do this is to <command role=\"hg-cmd\">hg qpop <option "
14756 "role=\"hg-ext-mq-cmd-qpop-opt\">hg -a</option></command> your patches, then "
14757 "<command role=\"hg-cmd\">hg pull</command> changes into the underlying "
14758 "repository, and finally <command role=\"hg-cmd\">hg qpush <option role=\"hg-"
14759 "ext-mq-cmd-qpop-opt\">hg -a</option></command> your patches again. MQ will "
14760 "stop pushing any time it runs across a patch that fails to apply during "
14761 "conflicts, allowing you to fix your conflicts, <command role=\"hg-ext-mq"
14762 "\">qrefresh</command> the affected patch, and continue pushing until you have "
14763 "fixed your entire stack."
14764 msgstr ""
14766 #. type: Content of: <book><chapter><sect1><para>
14767 #: ../en/ch11-mq.xml:829
14768 msgid ""
14769 "This approach is easy to use and works well if you don't expect changes to "
14770 "the underlying code to affect how well your patches apply. If your patch "
14771 "stack touches code that is modified frequently or invasively in the "
14772 "underlying repository, however, fixing up rejected hunks by hand quickly "
14773 "becomes tiresome."
14774 msgstr ""
14776 #. type: Content of: <book><chapter><sect1><para>
14777 #: ../en/ch11-mq.xml:836
14778 msgid ""
14779 "It's possible to partially automate the rebasing process. If your patches "
14780 "apply cleanly against some revision of the underlying repo, MQ can use this "
14781 "information to help you to resolve conflicts between your patches and a "
14782 "different revision."
14783 msgstr ""
14785 #. type: Content of: <book><chapter><sect1><para>
14786 #: ../en/ch11-mq.xml:842
14787 msgid "The process is a little involved."
14788 msgstr ""
14790 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
14791 #: ../en/ch11-mq.xml:844
14792 msgid ""
14793 "To begin, <command role=\"hg-cmd\">hg qpush -a</command> all of your patches "
14794 "on top of the revision where you know that they apply cleanly."
14795 msgstr ""
14797 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
14798 #: ../en/ch11-mq.xml:848
14799 msgid ""
14800 "Save a backup copy of your patch directory using <command role=\"hg-cmd\">hg "
14801 "qsave <option role=\"hg-ext-mq-cmd-qsave-opt\">hg -e</option> <option role="
14802 "\"hg-ext-mq-cmd-qsave-opt\">hg -c</option></command>. This prints the name "
14803 "of the directory that it has saved the patches in. It will save the patches "
14804 "to a directory called <filename role=\"special\" class=\"directory\">.hg/"
14805 "patches.N</filename>, where <literal>N</literal> is a small integer. It also "
14806 "commits a <quote>save changeset</quote> on top of your applied patches; this "
14807 "is for internal book-keeping, and records the states of the <filename role="
14808 "\"special\">series</filename> and <filename role=\"special\">status</"
14809 "filename> files."
14810 msgstr ""
14812 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
14813 #: ../en/ch11-mq.xml:862
14814 msgid ""
14815 "Use <command role=\"hg-cmd\">hg pull</command> to bring new changes into the "
14816 "underlying repository. (Don't run <command role=\"hg-cmd\">hg pull -u</"
14817 "command>; see below for why.)"
14818 msgstr ""
14820 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
14821 #: ../en/ch11-mq.xml:867
14822 msgid ""
14823 "Update to the new tip revision, using <command role=\"hg-cmd\">hg update "
14824 "<option role=\"hg-opt-update\">-C</option></command> to override the patches "
14825 "you have pushed."
14826 msgstr ""
14828 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
14829 #: ../en/ch11-mq.xml:872
14830 msgid ""
14831 "Merge all patches using <command>hg qpush -m -a</command>. The <option role="
14832 "\"hg-ext-mq-cmd-qpush-opt\">-m</option> option to <command role=\"hg-ext-mq"
14833 "\">qpush</command> tells MQ to perform a three-way merge if the patch fails "
14834 "to apply."
14835 msgstr ""
14837 #. type: Content of: <book><chapter><sect1><para>
14838 #: ../en/ch11-mq.xml:880
14839 msgid ""
14840 "During the <command role=\"hg-cmd\">hg qpush <option role=\"hg-ext-mq-cmd-"
14841 "qpush-opt\">hg -m</option></command>, each patch in the <filename role="
14842 "\"special\">series</filename> file is applied normally. If a patch applies "
14843 "with fuzz or rejects, MQ looks at the queue you <command role=\"hg-ext-mq"
14844 "\">qsave</command>d, and performs a three-way merge with the corresponding "
14845 "changeset. This merge uses Mercurial's normal merge machinery, so it may pop "
14846 "up a GUI merge tool to help you to resolve problems."
14847 msgstr ""
14849 #. type: Content of: <book><chapter><sect1><para>
14850 #: ../en/ch11-mq.xml:890
14851 msgid ""
14852 "When you finish resolving the effects of a patch, MQ refreshes your patch "
14853 "based on the result of the merge."
14854 msgstr ""
14856 #. type: Content of: <book><chapter><sect1><para>
14857 #: ../en/ch11-mq.xml:893
14858 msgid ""
14859 "At the end of this process, your repository will have one extra head from the "
14860 "old patch queue, and a copy of the old patch queue will be in <filename role="
14861 "\"special\" class=\"directory\">.hg/patches.N</filename>. You can remove the "
14862 "extra head using <command role=\"hg-cmd\">hg qpop -a -n patches.N</command> "
14863 "or <command role=\"hg-cmd\">hg strip</command>. You can delete <filename "
14864 "role=\"special\" class=\"directory\">.hg/patches.N</filename> once you are "
14865 "sure that you no longer need it as a backup."
14866 msgstr ""
14868 #. type: Content of: <book><chapter><sect1><title>
14869 #: ../en/ch11-mq.xml:905
14870 msgid "Identifying patches"
14871 msgstr "标识补丁"
14873 #. type: Content of: <book><chapter><sect1><para>
14874 #: ../en/ch11-mq.xml:907
14875 msgid ""
14876 "MQ commands that work with patches let you refer to a patch either by using "
14877 "its name or by a number. By name is obvious enough; pass the name "
14878 "<filename>foo.patch</filename> to <command role=\"hg-ext-mq\">qpush</"
14879 "command>, for example, and it will push patches until <filename>foo.patch</"
14880 "filename> is applied."
14881 msgstr ""
14883 #. type: Content of: <book><chapter><sect1><para>
14884 #: ../en/ch11-mq.xml:914
14885 msgid ""
14886 "As a shortcut, you can refer to a patch using both a name and a numeric "
14887 "offset; <literal>foo.patch-2</literal> means <quote>two patches before "
14888 "<literal>foo.patch</literal></quote>, while <literal>bar.patch+4</literal> "
14889 "means <quote>four patches after <literal>bar.patch</literal></quote>."
14890 msgstr ""
14892 #. type: Content of: <book><chapter><sect1><para>
14893 #: ../en/ch11-mq.xml:920
14894 msgid ""
14895 "Referring to a patch by index isn't much different. The first patch printed "
14896 "in the output of <command role=\"hg-ext-mq\">qseries</command> is patch zero "
14897 "(yes, it's one of those start-at-zero counting systems); the second is patch "
14898 "one; and so on."
14899 msgstr ""
14901 #. type: Content of: <book><chapter><sect1><para>
14902 #: ../en/ch11-mq.xml:926
14903 msgid ""
14904 "MQ also makes it easy to work with patches when you are using normal "
14905 "Mercurial commands. Every command that accepts a changeset ID will also "
14906 "accept the name of an applied patch. MQ augments the tags normally in the "
14907 "repository with an eponymous one for each applied patch. In addition, the "
14908 "special tags <literal role=\"tag\">qbase</literal> and <literal role=\"tag"
14909 "\">qtip</literal> identify the <quote>bottom-most</quote> and topmost applied "
14910 "patches, respectively."
14911 msgstr ""
14913 #. type: Content of: <book><chapter><sect1><para>
14914 #: ../en/ch11-mq.xml:936
14915 msgid ""
14916 "These additions to Mercurial's normal tagging capabilities make dealing with "
14917 "patches even more of a breeze."
14918 msgstr ""
14920 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14921 #: ../en/ch11-mq.xml:939
14922 msgid "Want to patchbomb a mailing list with your latest series of changes?"
14923 msgstr ""
14925 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14926 #: ../en/ch11-mq.xml:942
14927 msgid ""
14928 "(Don't know what <quote>patchbombing</quote> is? See <xref linkend=\"sec:"
14929 "hgext:patchbomb\"/>.)"
14930 msgstr ""
14932 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14933 #: ../en/ch11-mq.xml:945
14934 msgid ""
14935 "Need to see all of the patches since <literal>foo.patch</literal> that have "
14936 "touched files in a subdirectory of your tree?"
14937 msgstr ""
14939 #. type: Content of: <book><chapter><sect1><para>
14940 #: ../en/ch11-mq.xml:952
14941 msgid ""
14942 "Because MQ makes the names of patches available to the rest of Mercurial "
14943 "through its normal internal tag machinery, you don't need to type in the "
14944 "entire name of a patch when you want to identify it by name."
14945 msgstr ""
14947 #. type: Content of: <book><chapter><sect1><para>
14948 #: ../en/ch11-mq.xml:957
14949 msgid ""
14950 "Another nice consequence of representing patch names as tags is that when you "
14951 "run the <command role=\"hg-cmd\">hg log</command> command, it will display a "
14952 "patch's name as a tag, simply as part of its normal output. This makes it "
14953 "easy to visually distinguish applied patches from underlying <quote>normal</"
14954 "quote> revisions. The following example shows a few normal Mercurial "
14955 "commands in use with applied patches."
14956 msgstr ""
14958 #. type: Content of: <book><chapter><sect1><title>
14959 #: ../en/ch11-mq.xml:970
14960 msgid "Useful things to know about"
14961 msgstr "其它需要了解的东西"
14963 #. type: Content of: <book><chapter><sect1><para>
14964 #: ../en/ch11-mq.xml:972
14965 msgid ""
14966 "There are a number of aspects of MQ usage that don't fit tidily into sections "
14967 "of their own, but that are good to know. Here they are, in one place."
14968 msgstr ""
14970 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14971 #: ../en/ch11-mq.xml:977
14972 msgid ""
14973 "Normally, when you <command role=\"hg-ext-mq\">qpop</command> a patch and "
14974 "<command role=\"hg-ext-mq\">qpush</command> it again, the changeset that "
14975 "represents the patch after the pop/push will have a <emphasis>different "
14976 "identity</emphasis> than the changeset that represented the hash beforehand. "
14977 "See <xref linkend=\"sec:mqref:cmd:qpush\"/> for information as to why this is."
14978 msgstr ""
14980 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14981 #: ../en/ch11-mq.xml:986
14982 msgid ""
14983 "It's not a good idea to <command role=\"hg-cmd\">hg merge</command> changes "
14984 "from another branch with a patch changeset, at least if you want to maintain "
14985 "the <quote>patchiness</quote> of that changeset and changesets below it on "
14986 "the patch stack. If you try to do this, it will appear to succeed, but MQ "
14987 "will become confused."
14988 msgstr ""
14990 #. type: Content of: <book><chapter><sect1><title>
14991 #: ../en/ch11-mq.xml:997
14992 msgid "Managing patches in a repository"
14993 msgstr "在版本库管理补丁"
14995 #. type: Content of: <book><chapter><sect1><para>
14996 #: ../en/ch11-mq.xml:999
14997 msgid ""
14998 "Because MQ's <filename role=\"special\" class=\"directory\">.hg/patches</"
14999 "filename> directory resides outside a Mercurial repository's working "
15000 "directory, the <quote>underlying</quote> Mercurial repository knows nothing "
15001 "about the management or presence of patches."
15002 msgstr ""
15004 #. type: Content of: <book><chapter><sect1><para>
15005 #: ../en/ch11-mq.xml:1005
15006 msgid ""
15007 "This presents the interesting possibility of managing the contents of the "
15008 "patch directory as a Mercurial repository in its own right. This can be a "
15009 "useful way to work. For example, you can work on a patch for a while, "
15010 "<command role=\"hg-ext-mq\">qrefresh</command> it, then <command role=\"hg-cmd"
15011 "\">hg commit</command> the current state of the patch. This lets you "
15012 "<quote>roll back</quote> to that version of the patch later on."
15013 msgstr ""
15015 #. type: Content of: <book><chapter><sect1><para>
15016 #: ../en/ch11-mq.xml:1014
15017 msgid ""
15018 "You can then share different versions of the same patch stack among multiple "
15019 "underlying repositories. I use this when I am developing a Linux kernel "
15020 "feature. I have a pristine copy of my kernel sources for each of several CPU "
15021 "architectures, and a cloned repository under each that contains the patches I "
15022 "am working on. When I want to test a change on a different architecture, I "
15023 "push my current patches to the patch repository associated with that kernel "
15024 "tree, pop and push all of my patches, and build and test that kernel."
15025 msgstr ""
15027 #. type: Content of: <book><chapter><sect1><para>
15028 #: ../en/ch11-mq.xml:1024
15029 msgid ""
15030 "Managing patches in a repository makes it possible for multiple developers to "
15031 "work on the same patch series without colliding with each other, all on top "
15032 "of an underlying source base that they may or may not control."
15033 msgstr ""
15035 #. type: Content of: <book><chapter><sect1><sect2><title>
15036 #: ../en/ch11-mq.xml:1030
15037 msgid "MQ support for patch repositories"
15038 msgstr "MQ 支持补丁版本库"
15040 #. type: Content of: <book><chapter><sect1><sect2><para>
15041 #: ../en/ch11-mq.xml:1032
15042 msgid ""
15043 "MQ helps you to work with the <filename role=\"special\" class=\"directory\">."
15044 "hg/patches</filename> directory as a repository; when you prepare a "
15045 "repository for working with patches using <command role=\"hg-ext-mq\">qinit</"
15046 "command>, you can pass the <option role=\"hg-ext-mq-cmd-qinit-opt\">hg -c</"
15047 "option> option to create the <filename role=\"special\" class=\"directory\">."
15048 "hg/patches</filename> directory as a Mercurial repository."
15049 msgstr ""
15051 #. type: Content of: <book><chapter><sect1><sect2><note><para>
15052 #: ../en/ch11-mq.xml:1042
15053 msgid ""
15054 "If you forget to use the <option role=\"hg-ext-mq-cmd-qinit-opt\">hg -c</"
15055 "option> option, you can simply go into the <filename role=\"special\" class="
15056 "\"directory\">.hg/patches</filename> directory at any time and run <command "
15057 "role=\"hg-cmd\">hg init</command>. Don't forget to add an entry for the "
15058 "<filename role=\"special\">status</filename> file to the <filename role="
15059 "\"special\">.hgignore</filename> file, though"
15060 msgstr ""
15062 #. type: Content of: <book><chapter><sect1><sect2><note><para>
15063 #: ../en/ch11-mq.xml:1051
15064 msgid ""
15065 "(<command role=\"hg-cmd\">hg qinit <option role=\"hg-ext-mq-cmd-qinit-opt"
15066 "\">hg -c</option></command> does this for you automatically); you "
15067 "<emphasis>really</emphasis> don't want to manage the <filename role=\"special"
15068 "\">status</filename> file."
15069 msgstr ""
15071 #. type: Content of: <book><chapter><sect1><sect2><para>
15072 #: ../en/ch11-mq.xml:1058
15073 msgid ""
15074 "As a convenience, if MQ notices that the <filename class=\"directory\">.hg/"
15075 "patches</filename> directory is a repository, it will automatically <command "
15076 "role=\"hg-cmd\">hg add</command> every patch that you create and import."
15077 msgstr ""
15079 #. type: Content of: <book><chapter><sect1><sect2><para>
15080 #: ../en/ch11-mq.xml:1063
15081 msgid ""
15082 "MQ provides a shortcut command, <command role=\"hg-ext-mq\">qcommit</"
15083 "command>, that runs <command role=\"hg-cmd\">hg commit</command> in the "
15084 "<filename role=\"special\" class=\"directory\">.hg/patches</filename> "
15085 "directory. This saves some bothersome typing."
15086 msgstr ""
15088 #. type: Content of: <book><chapter><sect1><sect2><para>
15089 #: ../en/ch11-mq.xml:1069
15090 msgid ""
15091 "Finally, as a convenience to manage the patch directory, you can define the "
15092 "alias <command>mq</command> on Unix systems. For example, on Linux systems "
15093 "using the <command>bash</command> shell, you can include the following "
15094 "snippet in your <filename role=\"home\">~/.bashrc</filename>."
15095 msgstr ""
15097 #. type: Content of: <book><chapter><sect1><sect2><para>
15098 #: ../en/ch11-mq.xml:1078
15099 msgid ""
15100 "You can then issue commands of the form <command>mq pull</command> from the "
15101 "main repository."
15102 msgstr ""
15104 #. type: Content of: <book><chapter><sect1><sect2><title>
15105 #: ../en/ch11-mq.xml:1083
15106 msgid "A few things to watch out for"
15107 msgstr "需要注意的事情"
15109 #. type: Content of: <book><chapter><sect1><sect2><para>
15110 #: ../en/ch11-mq.xml:1085
15111 msgid ""
15112 "MQ's support for working with a repository full of patches is limited in a "
15113 "few small respects."
15114 msgstr ""
15116 #. type: Content of: <book><chapter><sect1><sect2><para>
15117 #: ../en/ch11-mq.xml:1088
15118 msgid ""
15119 "MQ cannot automatically detect changes that you make to the patch directory. "
15120 "If you <command role=\"hg-cmd\">hg pull</command>, manually edit, or <command "
15121 "role=\"hg-cmd\">hg update</command> changes to patches or the <filename role="
15122 "\"special\">series</filename> file, you will have to <command role=\"hg-cmd"
15123 "\">hg qpop <option role=\"hg-ext-mq-cmd-qpop-opt\">hg -a</option></command> "
15124 "and then <command role=\"hg-cmd\">hg qpush <option role=\"hg-ext-mq-cmd-qpush-"
15125 "opt\">hg -a</option></command> in the underlying repository to see those "
15126 "changes show up there. If you forget to do this, you can confuse MQ's idea "
15127 "of which patches are applied."
15128 msgstr ""
15130 #. type: Content of: <book><chapter><sect1><title>
15131 #: ../en/ch11-mq.xml:1104
15132 msgid "Third party tools for working with patches"
15133 msgstr "操作补丁的第三方工具"
15135 #. type: Content of: <book><chapter><sect1><para>
15136 #: ../en/ch11-mq.xml:1106
15137 msgid ""
15138 "Once you've been working with patches for a while, you'll find yourself "
15139 "hungry for tools that will help you to understand and manipulate the patches "
15140 "you're dealing with."
15141 msgstr ""
15143 #. type: Content of: <book><chapter><sect1><para>
15144 #: ../en/ch11-mq.xml:1110
15145 msgid ""
15146 "The <command>diffstat</command> command <citation>web:diffstat</citation> "
15147 "generates a histogram of the modifications made to each file in a patch. It "
15148 "provides a good way to <quote>get a sense of</quote> a patch&emdash;which "
15149 "files it affects, and how much change it introduces to each file and as a "
15150 "whole. (I find that it's a good idea to use <command>diffstat</command>'s "
15151 "<option role=\"cmd-opt-diffstat\">-p</option> option as a matter of course, "
15152 "as otherwise it will try to do clever things with prefixes of file names that "
15153 "inevitably confuse at least me.)"
15154 msgstr ""
15156 #. type: Content of: <book><chapter><sect1><para>
15157 #: ../en/ch11-mq.xml:1124
15158 msgid ""
15159 "The <literal role=\"package\">patchutils</literal> package <citation>web:"
15160 "patchutils</citation> is invaluable. It provides a set of small utilities "
15161 "that follow the <quote>Unix philosophy;</quote> each does one useful thing "
15162 "with a patch. The <literal role=\"package\">patchutils</literal> command I "
15163 "use most is <command>filterdiff</command>, which extracts subsets from a "
15164 "patch file. For example, given a patch that modifies hundreds of files "
15165 "across dozens of directories, a single invocation of <command>filterdiff</"
15166 "command> can generate a smaller patch that only touches files whose names "
15167 "match a particular glob pattern. See <xref linkend=\"mq-collab:tips:interdiff"
15168 "\"/> for another example."
15169 msgstr ""
15171 #. type: Content of: <book><chapter><sect1><title>
15172 #: ../en/ch11-mq.xml:1140
15173 msgid "Good ways to work with patches"
15174 msgstr "操作补丁的好习惯"
15176 #. type: Content of: <book><chapter><sect1><para>
15177 #: ../en/ch11-mq.xml:1142
15178 msgid ""
15179 "Whether you are working on a patch series to submit to a free software or "
15180 "open source project, or a series that you intend to treat as a sequence of "
15181 "regular changesets when you're done, you can use some simple techniques to "
15182 "keep your work well organized."
15183 msgstr ""
15185 #. type: Content of: <book><chapter><sect1><para>
15186 #: ../en/ch11-mq.xml:1148
15187 msgid ""
15188 "Give your patches descriptive names. A good name for a patch might be "
15189 "<filename>rework-device-alloc.patch</filename>, because it will immediately "
15190 "give you a hint what the purpose of the patch is. Long names shouldn't be a "
15191 "problem; you won't be typing the names often, but you <emphasis>will</"
15192 "emphasis> be running commands like <command role=\"hg-ext-mq\">qapplied</"
15193 "command> and <command role=\"hg-ext-mq\">qtop</command> over and over. Good "
15194 "naming becomes especially important when you have a number of patches to work "
15195 "with, or if you are juggling a number of different tasks and your patches "
15196 "only get a fraction of your attention."
15197 msgstr ""
15199 #. type: Content of: <book><chapter><sect1><para>
15200 #: ../en/ch11-mq.xml:1160
15201 msgid ""
15202 "Be aware of what patch you're working on. Use the <command role=\"hg-ext-mq"
15203 "\">qtop</command> command and skim over the text of your patches "
15204 "frequently&emdash;for example, using <command role=\"hg-cmd\">hg tip <option "
15205 "role=\"hg-opt-tip\">-p</option></command>)&emdash;to be sure of where you "
15206 "stand. I have several times worked on and <command role=\"hg-ext-mq"
15207 "\">qrefresh</command>ed a patch other than the one I intended, and it's often "
15208 "tricky to migrate changes into the right patch after making them in the wrong "
15209 "one."
15210 msgstr ""
15212 #. type: Content of: <book><chapter><sect1><para>
15213 #: ../en/ch11-mq.xml:1170
15214 msgid ""
15215 "For this reason, it is very much worth investing a little time to learn how "
15216 "to use some of the third-party tools I described in <xref linkend=\"sec:mq:"
15217 "tools\"/>, particularly <command>diffstat</command> and <command>filterdiff</"
15218 "command>. The former will give you a quick idea of what changes your patch "
15219 "is making, while the latter makes it easy to splice hunks selectively out of "
15220 "one patch and into another."
15221 msgstr ""
15223 #. type: Content of: <book><chapter><sect1><title>
15224 #: ../en/ch11-mq.xml:1181
15225 msgid "MQ cookbook"
15226 msgstr "MQ 手册"
15228 #. type: Content of: <book><chapter><sect1><sect2><title>
15229 #: ../en/ch11-mq.xml:1184
15230 msgid "Manage <quote>trivial</quote> patches"
15231 msgstr "管理<quote>琐碎的</quote>补丁"
15233 #. type: Content of: <book><chapter><sect1><sect2><para>
15234 #: ../en/ch11-mq.xml:1186
15235 msgid ""
15236 "Because the overhead of dropping files into a new Mercurial repository is so "
15237 "low, it makes a lot of sense to manage patches this way even if you simply "
15238 "want to make a few changes to a source tarball that you downloaded."
15239 msgstr ""
15242 #. type: Content of: <book><chapter><sect1><sect2><para>
15243 #: ../en/ch11-mq.xml:1191
15244 msgid ""
15245 "Begin by downloading and unpacking the source tarball, and turning it into a "
15246 "Mercurial repository."
15247 msgstr ""
15249 #. type: Content of: <book><chapter><sect1><sect2><para>
15250 #: ../en/ch11-mq.xml:1196
15251 msgid "Continue by creating a patch stack and making your changes."
15252 msgstr ""
15254 #. type: Content of: <book><chapter><sect1><sect2><para>
15255 #: ../en/ch11-mq.xml:1201
15256 msgid ""
15257 "Let's say a few weeks or months pass, and your package author releases a new "
15258 "version. First, bring their changes into the repository."
15259 msgstr ""
15261 #. type: Content of: <book><chapter><sect1><sect2><para>
15262 #: ../en/ch11-mq.xml:1207
15263 msgid ""
15264 "The pipeline starting with <command role=\"hg-cmd\">hg locate</command> above "
15265 "deletes all files in the working directory, so that <command role=\"hg-cmd"
15266 "\">hg commit</command>'s <option role=\"hg-opt-commit\">--addremove</option> "
15267 "option can actually tell which files have really been removed in the newer "
15268 "version of the source."
15269 msgstr ""
15271 #. type: Content of: <book><chapter><sect1><sect2><para>
15272 #: ../en/ch11-mq.xml:1215
15273 msgid "Finally, you can apply your patches on top of the new tree."
15274 msgstr ""
15276 #. type: Content of: <book><chapter><sect1><sect2><title>
15277 #: ../en/ch11-mq.xml:1222
15278 msgid "Combining entire patches"
15279 msgstr "组合全部的补丁"
15281 #. type: Content of: <book><chapter><sect1><sect2><para>
15282 #: ../en/ch11-mq.xml:1224
15283 msgid ""
15284 "MQ provides a command, <command role=\"hg-ext-mq\">qfold</command> that lets "
15285 "you combine entire patches. This <quote>folds</quote> the patches you name, "
15286 "in the order you name them, into the topmost applied patch, and concatenates "
15287 "their descriptions onto the end of its description. The patches that you "
15288 "fold must be unapplied before you fold them."
15289 msgstr ""
15291 #. type: Content of: <book><chapter><sect1><sect2><para>
15292 #: ../en/ch11-mq.xml:1232
15293 msgid ""
15294 "The order in which you fold patches matters. If your topmost applied patch "
15295 "is <literal>foo</literal>, and you <command role=\"hg-ext-mq\">qfold</"
15296 "command> <literal>bar</literal> and <literal>quux</literal> into it, you will "
15297 "end up with a patch that has the same effect as if you applied first "
15298 "<literal>foo</literal>, then <literal>bar</literal>, followed by "
15299 "<literal>quux</literal>."
15300 msgstr ""
15302 #. type: Content of: <book><chapter><sect1><sect2><title>
15303 #: ../en/ch11-mq.xml:1243
15304 msgid "Merging part of one patch into another"
15305 msgstr "合并补丁的部分内容到其它补丁"
15307 #. type: Content of: <book><chapter><sect1><sect2><para>
15308 #: ../en/ch11-mq.xml:1245
15309 msgid ""
15310 "Merging <emphasis>part</emphasis> of one patch into another is more difficult "
15311 "than combining entire patches."
15312 msgstr ""
15314 #. type: Content of: <book><chapter><sect1><sect2><para>
15315 #: ../en/ch11-mq.xml:1249
15316 msgid ""
15317 "If you want to move changes to entire files, you can use <command>filterdiff</"
15318 "command>'s <option role=\"cmd-opt-filterdiff\">-i</option> and <option role="
15319 "\"cmd-opt-filterdiff\">-x</option> options to choose the modifications to "
15320 "snip out of one patch, concatenating its output onto the end of the patch you "
15321 "want to merge into. You usually won't need to modify the patch you've merged "
15322 "the changes from. Instead, MQ will report some rejected hunks when you "
15323 "<command role=\"hg-ext-mq\">qpush</command> it (from the hunks you moved into "
15324 "the other patch), and you can simply <command role=\"hg-ext-mq\">qrefresh</"
15325 "command> the patch to drop the duplicate hunks."
15326 msgstr ""
15328 #. type: Content of: <book><chapter><sect1><sect2><para>
15329 #: ../en/ch11-mq.xml:1262
15330 msgid ""
15331 "If you have a patch that has multiple hunks modifying a file, and you only "
15332 "want to move a few of those hunks, the job becomes more messy, but you can "
15333 "still partly automate it. Use <command>lsdiff -nvv</command> to print some "
15334 "metadata about the patch."
15335 msgstr ""
15337 #. type: Content of: <book><chapter><sect1><sect2><para>
15338 #: ../en/ch11-mq.xml:1270
15339 msgid "This command prints three different kinds of number:"
15340 msgstr ""
15342 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15343 #: ../en/ch11-mq.xml:1273
15344 msgid ""
15345 "(in the first column) a <emphasis>file number</emphasis> to identify each "
15346 "file modified in the patch;"
15347 msgstr ""
15349 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15350 #: ../en/ch11-mq.xml:1277
15351 msgid ""
15352 "(on the next line, indented) the line number within a modified file where a "
15353 "hunk starts; and"
15354 msgstr ""
15356 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15357 #: ../en/ch11-mq.xml:1280
15358 msgid ""
15359 "(on the same line) a <emphasis>hunk number</emphasis> to identify that hunk."
15360 msgstr ""
15362 #. type: Content of: <book><chapter><sect1><sect2><para>
15363 #: ../en/ch11-mq.xml:1284
15364 msgid ""
15365 "You'll have to use some visual inspection, and reading of the patch, to "
15366 "identify the file and hunk numbers you'll want, but you can then pass them to "
15367 "to <command>filterdiff</command>'s <option role=\"cmd-opt-filterdiff\">--"
15368 "files</option> and <option role=\"cmd-opt-filterdiff\">--hunks</option> "
15369 "options, to select exactly the file and hunk you want to extract."
15370 msgstr ""
15372 #. type: Content of: <book><chapter><sect1><sect2><para>
15373 #: ../en/ch11-mq.xml:1292
15374 msgid ""
15375 "Once you have this hunk, you can concatenate it onto the end of your "
15376 "destination patch and continue with the remainder of <xref linkend=\"sec:mq:"
15377 "combine\"/>."
15378 msgstr ""
15380 #. type: Content of: <book><chapter><sect1><title>
15381 #: ../en/ch11-mq.xml:1299
15382 msgid "Differences between quilt and MQ"
15383 msgstr "MQ 与 quilt 的区别"
15385 #. type: Content of: <book><chapter><sect1><para>
15386 #: ../en/ch11-mq.xml:1301
15387 msgid ""
15388 "If you are already familiar with quilt, MQ provides a similar command set. "
15389 "There are a few differences in the way that it works."
15390 msgstr ""
15392 #. type: Content of: <book><chapter><sect1><para>
15393 #: ../en/ch11-mq.xml:1305
15394 msgid ""
15395 "You will already have noticed that most quilt commands have MQ counterparts "
15396 "that simply begin with a <quote><literal>q</literal></quote>. The exceptions "
15397 "are quilt's <literal>add</literal> and <literal>remove</literal> commands, "
15398 "the counterparts for which are the normal Mercurial <command role=\"hg-cmd"
15399 "\">hg add</command> and <command role=\"hg-cmd\">hg remove</command> "
15400 "commands. There is no MQ equivalent of the quilt <literal>edit</literal> "
15401 "command."
15402 msgstr ""
15404 #. type: Content of: <book><chapter><title>
15405 #: ../en/ch12-mq-collab.xml:5
15406 msgid "Advanced uses of Mercurial Queues"
15407 msgstr "MQ 的高级用法"
15409 #. type: Content of: <book><chapter><para>
15410 #: ../en/ch12-mq-collab.xml:7
15411 msgid ""
15412 "While it's easy to pick up straightforward uses of Mercurial Queues, use of a "
15413 "little discipline and some of MQ's less frequently used capabilities makes it "
15414 "possible to work in complicated development environments."
15415 msgstr ""
15417 #. type: Content of: <book><chapter><para>
15418 #: ../en/ch12-mq-collab.xml:12
15419 msgid ""
15420 "In this chapter, I will use as an example a technique I have used to manage "
15421 "the development of an Infiniband device driver for the Linux kernel. The "
15422 "driver in question is large (at least as drivers go), with 25,000 lines of "
15423 "code spread across 35 source files. It is maintained by a small team of "
15424 "developers."
15425 msgstr ""
15427 #. type: Content of: <book><chapter><para>
15428 #: ../en/ch12-mq-collab.xml:18
15429 msgid ""
15430 "While much of the material in this chapter is specific to Linux, the same "
15431 "principles apply to any code base for which you're not the primary owner, and "
15432 "upon which you need to do a lot of development."
15433 msgstr ""
15435 #. type: Content of: <book><chapter><sect1><title>
15436 #: ../en/ch12-mq-collab.xml:24
15437 msgid "The problem of many targets"
15438 msgstr "多个目标的问题"
15440 #. type: Content of: <book><chapter><sect1><para>
15441 #: ../en/ch12-mq-collab.xml:26
15442 msgid ""
15443 "The Linux kernel changes rapidly, and has never been internally stable; "
15444 "developers frequently make drastic changes between releases. This means that "
15445 "a version of the driver that works well with a particular released version of "
15446 "the kernel will not even <emphasis>compile</emphasis> correctly against, "
15447 "typically, any other version."
15448 msgstr ""
15450 #. type: Content of: <book><chapter><sect1><para>
15451 #: ../en/ch12-mq-collab.xml:33
15452 msgid ""
15453 "To maintain a driver, we have to keep a number of distinct versions of Linux "
15454 "in mind."
15455 msgstr ""
15457 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15458 #: ../en/ch12-mq-collab.xml:36
15459 msgid ""
15460 "One target is the main Linux kernel development tree. Maintenance of the code "
15461 "is in this case partly shared by other developers in the kernel community, "
15462 "who make <quote>drive-by</quote> modifications to the driver as they develop "
15463 "and refine kernel subsystems."
15464 msgstr ""
15466 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15467 #: ../en/ch12-mq-collab.xml:42
15468 msgid ""
15469 "We also maintain a number of <quote>backports</quote> to older versions of "
15470 "the Linux kernel, to support the needs of customers who are running older "
15471 "Linux distributions that do not incorporate our drivers. (To "
15472 "<emphasis>backport</emphasis> a piece of code is to modify it to work in an "
15473 "older version of its target environment than the version it was developed "
15474 "for.)"
15475 msgstr ""
15477 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15478 #: ../en/ch12-mq-collab.xml:50
15479 msgid ""
15480 "Finally, we make software releases on a schedule that is necessarily not "
15481 "aligned with those used by Linux distributors and kernel developers, so that "
15482 "we can deliver new features to customers without forcing them to upgrade "
15483 "their entire kernels or distributions."
15484 msgstr ""
15486 #. type: Content of: <book><chapter><sect1><sect2><title>
15487 #: ../en/ch12-mq-collab.xml:58
15488 msgid "Tempting approaches that don't work well"
15489 msgstr "工作不好的诱人方法"
15491 #. type: Content of: <book><chapter><sect1><sect2><para>
15492 #: ../en/ch12-mq-collab.xml:60
15493 msgid ""
15494 "There are two <quote>standard</quote> ways to maintain a piece of software "
15495 "that has to target many different environments."
15496 msgstr ""
15498 #. type: Content of: <book><chapter><sect1><sect2><para>
15499 #: ../en/ch12-mq-collab.xml:64
15500 msgid ""
15501 "The first is to maintain a number of branches, each intended for a single "
15502 "target. The trouble with this approach is that you must maintain iron "
15503 "discipline in the flow of changes between repositories. A new feature or bug "
15504 "fix must start life in a <quote>pristine</quote> repository, then percolate "
15505 "out to every backport repository. Backport changes are more limited in the "
15506 "branches they should propagate to; a backport change that is applied to a "
15507 "branch where it doesn't belong will probably stop the driver from compiling."
15508 msgstr ""
15510 #. type: Content of: <book><chapter><sect1><sect2><para>
15511 #: ../en/ch12-mq-collab.xml:74
15512 msgid ""
15513 "The second is to maintain a single source tree filled with conditional "
15514 "statements that turn chunks of code on or off depending on the intended "
15515 "target. Because these <quote>ifdefs</quote> are not allowed in the Linux "
15516 "kernel tree, a manual or automatic process must be followed to strip them out "
15517 "and yield a clean tree. A code base maintained in this fashion rapidly "
15518 "becomes a rat's nest of conditional blocks that are difficult to understand "
15519 "and maintain."
15520 msgstr ""
15522 #. type: Content of: <book><chapter><sect1><sect2><para>
15523 #: ../en/ch12-mq-collab.xml:83
15524 msgid ""
15525 "Neither of these approaches is well suited to a situation where you don't "
15526 "<quote>own</quote> the canonical copy of a source tree. In the case of a "
15527 "Linux driver that is distributed with the standard kernel, Linus's tree "
15528 "contains the copy of the code that will be treated by the world as "
15529 "canonical. The upstream version of <quote>my</quote> driver can be modified "
15530 "by people I don't know, without me even finding out about it until after the "
15531 "changes show up in Linus's tree."
15532 msgstr ""
15534 #. type: Content of: <book><chapter><sect1><sect2><para>
15535 #: ../en/ch12-mq-collab.xml:93
15536 msgid ""
15537 "These approaches have the added weakness of making it difficult to generate "
15538 "well-formed patches to submit upstream."
15539 msgstr ""
15541 #. type: Content of: <book><chapter><sect1><sect2><para>
15542 #: ../en/ch12-mq-collab.xml:97
15543 msgid ""
15544 "In principle, Mercurial Queues seems like a good candidate to manage a "
15545 "development scenario such as the above. While this is indeed the case, MQ "
15546 "contains a few added features that make the job more pleasant."
15547 msgstr ""
15549 #. type: Content of: <book><chapter><sect1><title>
15550 #: ../en/ch12-mq-collab.xml:105
15551 msgid "Conditionally applying patches with guards"
15552 msgstr "有条件的应用补丁"
15554 #. type: Content of: <book><chapter><sect1><para>
15555 #: ../en/ch12-mq-collab.xml:107
15556 msgid ""
15557 "Perhaps the best way to maintain sanity with so many targets is to be able to "
15558 "choose specific patches to apply for a given situation. MQ provides a "
15559 "feature called <quote>guards</quote> (which originates with quilt's "
15560 "<literal>guards</literal> command) that does just this. To start off, let's "
15561 "create a simple repository for experimenting in."
15562 msgstr ""
15564 #. type: Content of: <book><chapter><sect1><para>
15565 #: ../en/ch12-mq-collab.xml:116
15566 msgid ""
15567 "This gives us a tiny repository that contains two patches that don't have any "
15568 "dependencies on each other, because they touch different files."
15569 msgstr ""
15571 #. type: Content of: <book><chapter><sect1><para>
15572 #: ../en/ch12-mq-collab.xml:120
15573 msgid ""
15574 "The idea behind conditional application is that you can <quote>tag</quote> a "
15575 "patch with a <emphasis>guard</emphasis>, which is simply a text string of "
15576 "your choosing, then tell MQ to select specific guards to use when applying "
15577 "patches. MQ will then either apply, or skip over, a guarded patch, depending "
15578 "on the guards that you have selected."
15579 msgstr ""
15581 #. type: Content of: <book><chapter><sect1><para>
15582 #: ../en/ch12-mq-collab.xml:127
15583 msgid ""
15584 "A patch can have an arbitrary number of guards; each one is "
15585 "<emphasis>positive</emphasis> (<quote>apply this patch if this guard is "
15586 "selected</quote>) or <emphasis>negative</emphasis> (<quote>skip this patch if "
15587 "this guard is selected</quote>). A patch with no guards is always applied."
15588 msgstr ""
15590 #. type: Content of: <book><chapter><sect1><title>
15591 #: ../en/ch12-mq-collab.xml:135
15592 msgid "Controlling the guards on a patch"
15593 msgstr "控制补丁的应用条件"
15595 #. type: Content of: <book><chapter><sect1><para>
15596 #: ../en/ch12-mq-collab.xml:137
15597 msgid ""
15598 "The <command role=\"hg-ext-mq\">qguard</command> command lets you determine "
15599 "which guards should apply to a patch, or display the guards that are already "
15600 "in effect. Without any arguments, it displays the guards on the current "
15601 "topmost patch."
15602 msgstr ""
15604 #. type: Content of: <book><chapter><sect1><para>
15605 #: ../en/ch12-mq-collab.xml:144
15606 msgid ""
15607 "To set a positive guard on a patch, prefix the name of the guard with a "
15608 "<quote><literal>+</literal></quote>."
15609 msgstr ""
15611 #. type: Content of: <book><chapter><sect1><para>
15612 #: ../en/ch12-mq-collab.xml:149
15613 msgid ""
15614 "To set a negative guard on a patch, prefix the name of the guard with a "
15615 "<quote><literal>-</literal></quote>."
15616 msgstr ""
15618 #. type: Content of: <book><chapter><sect1><note><para>
15619 #: ../en/ch12-mq-collab.xml:156
15620 msgid ""
15621 "The <command role=\"hg-ext-mq\">qguard</command> command <emphasis>sets</"
15622 "emphasis> the guards on a patch; it doesn't <emphasis>modify</emphasis> "
15623 "them. What this means is that if you run <command role=\"hg-cmd\">hg qguard "
15624 "+a +b</command> on a patch, then <command role=\"hg-cmd\">hg qguard +c</"
15625 "command> on the same patch, the <emphasis>only</emphasis> guard that will be "
15626 "set on it afterwards is <literal>+c</literal>."
15627 msgstr ""
15630 #. type: Content of: <book><chapter><sect1><para>
15631 #: ../en/ch12-mq-collab.xml:165
15632 msgid ""
15633 "Mercurial stores guards in the <filename role=\"special\">series</filename> "
15634 "file; the form in which they are stored is easy both to understand and to "
15635 "edit by hand. (In other words, you don't have to use the <command role=\"hg-"
15636 "ext-mq\">qguard</command> command if you don't want to; it's okay to simply "
15637 "edit the <filename role=\"special\">series</filename> file.)"
15638 msgstr ""
15640 #. type: Content of: <book><chapter><sect1><title>
15641 #: ../en/ch12-mq-collab.xml:177
15642 msgid "Selecting the guards to use"
15643 msgstr "选择使用的条件"
15645 #. type: Content of: <book><chapter><sect1><para>
15646 #: ../en/ch12-mq-collab.xml:179
15647 msgid ""
15648 "The <command role=\"hg-ext-mq\">qselect</command> command determines which "
15649 "guards are active at a given time. The effect of this is to determine which "
15650 "patches MQ will apply the next time you run <command role=\"hg-ext-mq"
15651 "\">qpush</command>. It has no other effect; in particular, it doesn't do "
15652 "anything to patches that are already applied."
15653 msgstr ""
15655 #. type: Content of: <book><chapter><sect1><para>
15656 #: ../en/ch12-mq-collab.xml:186
15657 msgid ""
15658 "With no arguments, the <command role=\"hg-ext-mq\">qselect</command> command "
15659 "lists the guards currently in effect, one per line of output. Each argument "
15660 "is treated as the name of a guard to apply."
15661 msgstr ""
15663 #. type: Content of: <book><chapter><sect1><para>
15664 #: ../en/ch12-mq-collab.xml:193
15665 msgid ""
15666 "In case you're interested, the currently selected guards are stored in the "
15667 "<filename role=\"special\">guards</filename> file."
15668 msgstr ""
15670 #. type: Content of: <book><chapter><sect1><para>
15671 #: ../en/ch12-mq-collab.xml:198
15672 msgid ""
15673 "We can see the effect the selected guards have when we run <command role=\"hg-"
15674 "ext-mq\">qpush</command>."
15675 msgstr ""
15677 #. type: Content of: <book><chapter><sect1><para>
15678 #: ../en/ch12-mq-collab.xml:203
15679 msgid ""
15680 "A guard cannot start with a <quote><literal>+</literal></quote> or "
15681 "<quote><literal>-</literal></quote> character. The name of a guard must not "
15682 "contain white space, but most other characters are acceptable. If you try to "
15683 "use a guard with an invalid name, MQ will complain:"
15684 msgstr ""
15686 #. type: Content of: <book><chapter><sect1><para>
15687 #: ../en/ch12-mq-collab.xml:212
15688 msgid "Changing the selected guards changes the patches that are applied."
15689 msgstr ""
15691 #. type: Content of: <book><chapter><sect1><para>
15692 #: ../en/ch12-mq-collab.xml:217
15693 msgid ""
15694 "You can see in the example below that negative guards take precedence over "
15695 "positive guards."
15696 msgstr ""
15698 #. type: Content of: <book><chapter><sect1><title>
15699 #: ../en/ch12-mq-collab.xml:224
15700 msgid "MQ's rules for applying patches"
15701 msgstr "MQ 应用补丁的规则"
15703 #. type: Content of: <book><chapter><sect1><para>
15704 #: ../en/ch12-mq-collab.xml:226
15705 msgid ""
15706 "The rules that MQ uses when deciding whether to apply a patch are as follows."
15707 msgstr ""
15709 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15710 #: ../en/ch12-mq-collab.xml:229
15711 msgid "A patch that has no guards is always applied."
15712 msgstr ""
15714 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15715 #: ../en/ch12-mq-collab.xml:232
15716 msgid ""
15717 "If the patch has any negative guard that matches any currently selected "
15718 "guard, the patch is skipped."
15719 msgstr ""
15721 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15722 #: ../en/ch12-mq-collab.xml:235
15723 msgid ""
15724 "If the patch has any positive guard that matches any currently selected "
15725 "guard, the patch is applied."
15726 msgstr ""
15728 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15729 #: ../en/ch12-mq-collab.xml:238
15730 msgid ""
15731 "If the patch has positive or negative guards, but none matches any currently "
15732 "selected guard, the patch is skipped."
15733 msgstr ""
15735 #. type: Content of: <book><chapter><sect1><title>
15736 #: ../en/ch12-mq-collab.xml:245
15737 msgid "Trimming the work environment"
15738 msgstr "修剪工作环境"
15740 #. type: Content of: <book><chapter><sect1><para>
15741 #: ../en/ch12-mq-collab.xml:247
15742 msgid ""
15743 "In working on the device driver I mentioned earlier, I don't apply the "
15744 "patches to a normal Linux kernel tree. Instead, I use a repository that "
15745 "contains only a snapshot of the source files and headers that are relevant to "
15746 "Infiniband development. This repository is 1% the size of a kernel "
15747 "repository, so it's easier to work with."
15748 msgstr ""
15750 #. type: Content of: <book><chapter><sect1><para>
15751 #: ../en/ch12-mq-collab.xml:254
15752 msgid ""
15753 "I then choose a <quote>base</quote> version on top of which the patches are "
15754 "applied. This is a snapshot of the Linux kernel tree as of a revision of my "
15755 "choosing. When I take the snapshot, I record the changeset ID from the "
15756 "kernel repository in the commit message. Since the snapshot preserves the "
15757 "<quote>shape</quote> and content of the relevant parts of the kernel tree, I "
15758 "can apply my patches on top of either my tiny repository or a normal kernel "
15759 "tree."
15760 msgstr ""
15762 #. type: Content of: <book><chapter><sect1><para>
15763 #: ../en/ch12-mq-collab.xml:263
15764 msgid ""
15765 "Normally, the base tree atop which the patches apply should be a snapshot of "
15766 "a very recent upstream tree. This best facilitates the development of "
15767 "patches that can easily be submitted upstream with few or no modifications."
15768 msgstr ""
15770 #. type: Content of: <book><chapter><sect1><title>
15771 #: ../en/ch12-mq-collab.xml:270
15772 msgid "Dividing up the <filename role=\"special\">series</filename> file"
15773 msgstr "分类补丁<filename role=\"special\">系列</filename>"
15775 #. type: Content of: <book><chapter><sect1><para>
15776 #: ../en/ch12-mq-collab.xml:273
15777 msgid ""
15778 "I categorise the patches in the <filename role=\"special\">series</filename> "
15779 "file into a number of logical groups. Each section of like patches begins "
15780 "with a block of comments that describes the purpose of the patches that "
15781 "follow."
15782 msgstr ""
15784 #. type: Content of: <book><chapter><sect1><para>
15785 #: ../en/ch12-mq-collab.xml:279
15786 msgid ""
15787 "The sequence of patch groups that I maintain follows. The ordering of these "
15788 "groups is important; I'll describe why after I introduce the groups."
15789 msgstr ""
15791 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15792 #: ../en/ch12-mq-collab.xml:283
15793 msgid ""
15794 "The <quote>accepted</quote> group. Patches that the development team has "
15795 "submitted to the maintainer of the Infiniband subsystem, and which he has "
15796 "accepted, but which are not present in the snapshot that the tiny repository "
15797 "is based on. These are <quote>read only</quote> patches, present only to "
15798 "transform the tree into a similar state as it is in the upstream maintainer's "
15799 "repository."
15800 msgstr ""
15802 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15803 #: ../en/ch12-mq-collab.xml:291
15804 msgid ""
15805 "The <quote>rework</quote> group. Patches that I have submitted, but that the "
15806 "upstream maintainer has requested modifications to before he will accept them."
15807 msgstr ""
15809 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15810 #: ../en/ch12-mq-collab.xml:296
15811 msgid ""
15812 "The <quote>pending</quote> group. Patches that I have not yet submitted to "
15813 "the upstream maintainer, but which we have finished working on. These will be "
15814 "<quote>read only</quote> for a while. If the upstream maintainer accepts "
15815 "them upon submission, I'll move them to the end of the <quote>accepted</"
15816 "quote> group. If he requests that I modify any, I'll move them to the "
15817 "beginning of the <quote>rework</quote> group."
15818 msgstr ""
15820 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15821 #: ../en/ch12-mq-collab.xml:305
15822 msgid ""
15823 "The <quote>in progress</quote> group. Patches that are actively being "
15824 "developed, and should not be submitted anywhere yet."
15825 msgstr ""
15827 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15828 #: ../en/ch12-mq-collab.xml:309
15829 msgid ""
15830 "The <quote>backport</quote> group. Patches that adapt the source tree to "
15831 "older versions of the kernel tree."
15832 msgstr ""
15834 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15835 #: ../en/ch12-mq-collab.xml:313
15836 msgid ""
15837 "The <quote>do not ship</quote> group. Patches that for some reason should "
15838 "never be submitted upstream. For example, one such patch might change "
15839 "embedded driver identification strings to make it easier to distinguish, in "
15840 "the field, between an out-of-tree version of the driver and a version shipped "
15841 "by a distribution vendor."
15842 msgstr ""
15844 #. type: Content of: <book><chapter><sect1><para>
15845 #: ../en/ch12-mq-collab.xml:321
15846 msgid ""
15847 "Now to return to the reasons for ordering groups of patches in this way. We "
15848 "would like the lowest patches in the stack to be as stable as possible, so "
15849 "that we will not need to rework higher patches due to changes in context. "
15850 "Putting patches that will never be changed first in the <filename role="
15851 "\"special\">series</filename> file serves this purpose."
15852 msgstr ""
15854 #. type: Content of: <book><chapter><sect1><para>
15855 #: ../en/ch12-mq-collab.xml:329
15856 msgid ""
15857 "We would also like the patches that we know we'll need to modify to be "
15858 "applied on top of a source tree that resembles the upstream tree as closely "
15859 "as possible. This is why we keep accepted patches around for a while."
15860 msgstr ""
15862 #. type: Content of: <book><chapter><sect1><para>
15863 #: ../en/ch12-mq-collab.xml:334
15864 msgid ""
15865 "The <quote>backport</quote> and <quote>do not ship</quote> patches float at "
15866 "the end of the <filename role=\"special\">series</filename> file. The "
15867 "backport patches must be applied on top of all other patches, and the "
15868 "<quote>do not ship</quote> patches might as well stay out of harm's way."
15869 msgstr ""
15871 #. type: Content of: <book><chapter><sect1><title>
15872 #: ../en/ch12-mq-collab.xml:343
15873 msgid "Maintaining the patch series"
15874 msgstr "维护补丁系列"
15876 #. type: Content of: <book><chapter><sect1><para>
15877 #: ../en/ch12-mq-collab.xml:345
15878 msgid ""
15879 "In my work, I use a number of guards to control which patches are to be "
15880 "applied."
15881 msgstr ""
15883 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15884 #: ../en/ch12-mq-collab.xml:349
15885 msgid ""
15886 "<quote>Accepted</quote> patches are guarded with <literal>accepted</"
15887 "literal>. I enable this guard most of the time. When I'm applying the "
15888 "patches on top of a tree where the patches are already present, I can turn "
15889 "this patch off, and the patches that follow it will apply cleanly."
15890 msgstr ""
15892 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15893 #: ../en/ch12-mq-collab.xml:356
15894 msgid ""
15895 "Patches that are <quote>finished</quote>, but not yet submitted, have no "
15896 "guards. If I'm applying the patch stack to a copy of the upstream tree, I "
15897 "don't need to enable any guards in order to get a reasonably safe source tree."
15898 msgstr ""
15900 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15901 #: ../en/ch12-mq-collab.xml:362
15902 msgid ""
15903 "Those patches that need reworking before being resubmitted are guarded with "
15904 "<literal>rework</literal>."
15905 msgstr ""
15907 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15908 #: ../en/ch12-mq-collab.xml:366
15909 msgid ""
15910 "For those patches that are still under development, I use <literal>devel</"
15911 "literal>."
15912 msgstr ""
15914 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15915 #: ../en/ch12-mq-collab.xml:369
15916 msgid ""
15917 "A backport patch may have several guards, one for each version of the kernel "
15918 "to which it applies. For example, a patch that backports a piece of code to "
15919 "2.6.9 will have a <literal>2.6.9</literal> guard."
15920 msgstr ""
15922 #. type: Content of: <book><chapter><sect1><para>
15923 #: ../en/ch12-mq-collab.xml:374
15924 msgid ""
15925 "This variety of guards gives me considerable flexibility in determining what "
15926 "kind of source tree I want to end up with. For most situations, the "
15927 "selection of appropriate guards is automated during the build process, but I "
15928 "can manually tune the guards to use for less common circumstances."
15929 msgstr ""
15931 #. type: Content of: <book><chapter><sect1><sect2><title>
15932 #: ../en/ch12-mq-collab.xml:381
15933 msgid "The art of writing backport patches"
15934 msgstr "编写向后移植补丁的艺术"
15936 #. type: Content of: <book><chapter><sect1><sect2><para>
15937 #: ../en/ch12-mq-collab.xml:383
15938 msgid ""
15939 "Using MQ, writing a backport patch is a simple process. All such a patch has "
15940 "to do is modify a piece of code that uses a kernel feature not present in the "
15941 "older version of the kernel, so that the driver continues to work correctly "
15942 "under that older version."
15943 msgstr ""
15945 #. type: Content of: <book><chapter><sect1><sect2><para>
15946 #: ../en/ch12-mq-collab.xml:389
15947 msgid ""
15948 "A useful goal when writing a good backport patch is to make your code look as "
15949 "if it was written for the older version of the kernel you're targeting. The "
15950 "less obtrusive the patch, the easier it will be to understand and maintain. "
15951 "If you're writing a collection of backport patches to avoid the <quote>rat's "
15952 "nest</quote> effect of lots of <literal>#ifdef</literal>s (hunks of source "
15953 "code that are only used conditionally) in your code, don't introduce version-"
15954 "dependent <literal>#ifdef</literal>s into the patches. Instead, write "
15955 "several patches, each of which makes unconditional changes, and control their "
15956 "application using guards."
15957 msgstr ""
15959 #. type: Content of: <book><chapter><sect1><sect2><para>
15960 #: ../en/ch12-mq-collab.xml:402
15961 msgid ""
15962 "There are two reasons to divide backport patches into a distinct group, away "
15963 "from the <quote>regular</quote> patches whose effects they modify. The first "
15964 "is that intermingling the two makes it more difficult to use a tool like the "
15965 "<literal role=\"hg-ext\">patchbomb</literal> extension to automate the "
15966 "process of submitting the patches to an upstream maintainer. The second is "
15967 "that a backport patch could perturb the context in which a subsequent regular "
15968 "patch is applied, making it impossible to apply the regular patch cleanly "
15969 "<emphasis>without</emphasis> the earlier backport patch already being applied."
15970 msgstr ""
15972 #. type: Content of: <book><chapter><sect1><title>
15973 #: ../en/ch12-mq-collab.xml:417
15974 msgid "Useful tips for developing with MQ"
15975 msgstr "使用 MQ 开发的技巧"
15977 #. type: Content of: <book><chapter><sect1><sect2><title>
15978 #: ../en/ch12-mq-collab.xml:420
15979 msgid "Organising patches in directories"
15980 msgstr "将补丁放到几个目录中"
15982 #. type: Content of: <book><chapter><sect1><sect2><para>
15983 #: ../en/ch12-mq-collab.xml:422
15984 msgid ""
15985 "If you're working on a substantial project with MQ, it's not difficult to "
15986 "accumulate a large number of patches. For example, I have one patch "
15987 "repository that contains over 250 patches."
15988 msgstr ""
15990 #. type: Content of: <book><chapter><sect1><sect2><para>
15991 #: ../en/ch12-mq-collab.xml:427
15992 msgid ""
15993 "If you can group these patches into separate logical categories, you can if "
15994 "you like store them in different directories; MQ has no problems with patch "
15995 "names that contain path separators."
15996 msgstr ""
15998 #. type: Content of: <book><chapter><sect1><sect2><title>
15999 #: ../en/ch12-mq-collab.xml:434
16000 msgid "Viewing the history of a patch"
16001 msgstr "察看补丁的历史"
16003 #. type: Content of: <book><chapter><sect1><sect2><para>
16004 #: ../en/ch12-mq-collab.xml:436
16005 msgid ""
16006 "If you're developing a set of patches over a long time, it's a good idea to "
16007 "maintain them in a repository, as discussed in <xref linkend=\"sec:mq:repo\"/"
16008 ">. If you do so, you'll quickly discover that using the <command role=\"hg-"
16009 "cmd\">hg diff</command> command to look at the history of changes to a patch "
16010 "is unworkable. This is in part because you're looking at the second "
16011 "derivative of the real code (a diff of a diff), but also because MQ adds "
16012 "noise to the process by modifying time stamps and directory names when it "
16013 "updates a patch."
16014 msgstr ""
16016 #. type: Content of: <book><chapter><sect1><sect2><para>
16017 #: ../en/ch12-mq-collab.xml:448
16018 msgid ""
16019 "However, you can use the <literal role=\"hg-ext\">extdiff</literal> "
16020 "extension, which is bundled with Mercurial, to turn a diff of two versions of "
16021 "a patch into something readable. To do this, you will need a third-party "
16022 "package called <literal role=\"package\">patchutils</literal> <citation>web:"
16023 "patchutils</citation>. This provides a command named <command>interdiff</"
16024 "command>, which shows the differences between two diffs as a diff. Used on "
16025 "two versions of the same diff, it generates a diff that represents the diff "
16026 "from the first to the second version."
16027 msgstr ""
16029 #. type: Content of: <book><chapter><sect1><sect2><para>
16030 #: ../en/ch12-mq-collab.xml:459
16031 msgid ""
16032 "You can enable the <literal role=\"hg-ext\">extdiff</literal> extension in "
16033 "the usual way, by adding a line to the <literal role=\"rc-extensions"
16034 "\">extensions</literal> section of your <filename role=\"special\">~/.hgrc</"
16035 "filename>."
16036 msgstr ""
16039 #. &example.hg-interdiff;
16040 #. type: Content of: <book><chapter><sect1><sect2><para>
16041 #: ../en/ch12-mq-collab.xml:466
16042 msgid ""
16043 "The <command>interdiff</command> command expects to be passed the names of "
16044 "two files, but the <literal role=\"hg-ext\">extdiff</literal> extension "
16045 "passes the program it runs a pair of directories, each of which can contain "
16046 "an arbitrary number of files. We thus need a small program that will run "
16047 "<command>interdiff</command> on each pair of files in these two directories. "
16048 "This program is available as <filename role=\"special\">hg-interdiff</"
16049 "filename> in the <filename class=\"directory\">examples</filename> directory "
16050 "of the source code repository that accompanies this book."
16051 msgstr ""
16053 #. type: Content of: <book><chapter><sect1><sect2><para>
16054 #: ../en/ch12-mq-collab.xml:478
16055 msgid ""
16056 "With the <filename role=\"special\">hg-interdiff</filename> program in your "
16057 "shell's search path, you can run it as follows, from inside an MQ patch "
16058 "directory:"
16059 msgstr ""
16061 #. type: Content of: <book><chapter><sect1><sect2><para>
16062 #: ../en/ch12-mq-collab.xml:482
16063 msgid ""
16064 "Since you'll probably want to use this long-winded command a lot, you can get "
16065 "<literal role=\"hg-ext\">hgext</literal> to make it available as a normal "
16066 "Mercurial command, again by editing your <filename role=\"special\">~/.hgrc</"
16067 "filename>."
16068 msgstr ""
16070 #. type: Content of: <book><chapter><sect1><sect2><para>
16071 #: ../en/ch12-mq-collab.xml:489
16072 msgid ""
16073 "This directs <literal role=\"hg-ext\">hgext</literal> to make an "
16074 "<literal>interdiff</literal> command available, so you can now shorten the "
16075 "previous invocation of <command role=\"hg-ext-extdiff\">extdiff</command> to "
16076 "something a little more wieldy."
16077 msgstr ""
16079 #. type: Content of: <book><chapter><sect1><sect2><note><para>
16080 #: ../en/ch12-mq-collab.xml:497
16081 msgid ""
16082 "The <command>interdiff</command> command works well only if the underlying "
16083 "files against which versions of a patch are generated remain the same. If "
16084 "you create a patch, modify the underlying files, and then regenerate the "
16085 "patch, <command>interdiff</command> may not produce useful output."
16086 msgstr ""
16088 #. type: Content of: <book><chapter><sect1><sect2><para>
16089 #: ../en/ch12-mq-collab.xml:505
16090 msgid ""
16091 "The <literal role=\"hg-ext\">extdiff</literal> extension is useful for more "
16092 "than merely improving the presentation of MQ patches. To read more about it, "
16093 "go to <xref linkend=\"sec:hgext:extdiff\"/>."
16094 msgstr ""
16096 #. type: Content of: <book><chapter><title>
16097 #: ../en/ch13-hgext.xml:5
16098 msgid "Adding functionality with extensions"
16099 msgstr "使用扩展增加功能"
16101 #. type: Content of: <book><chapter><para>
16102 #: ../en/ch13-hgext.xml:7
16103 msgid ""
16104 "While the core of Mercurial is quite complete from a functionality "
16105 "standpoint, it's deliberately shorn of fancy features. This approach of "
16106 "preserving simplicity keeps the software easy to deal with for both "
16107 "maintainers and users."
16108 msgstr ""
16110 #. type: Content of: <book><chapter><para>
16111 #: ../en/ch13-hgext.xml:12
16112 msgid ""
16113 "However, Mercurial doesn't box you in with an inflexible command set: you can "
16114 "add features to it as <emphasis>extensions</emphasis> (sometimes known as "
16115 "<emphasis>plugins</emphasis>). We've already discussed a few of these "
16116 "extensions in earlier chapters."
16117 msgstr ""
16119 #. type: Content of: <book><chapter><itemizedlist><listitem><para>
16120 #: ../en/ch13-hgext.xml:18
16121 msgid ""
16122 "<xref linkend=\"sec:tour-merge:fetch\"/> covers the <literal role=\"hg-ext"
16123 "\">fetch</literal> extension; this combines pulling new changes and merging "
16124 "them with local changes into a single command, <command role=\"hg-ext-fetch"
16125 "\">fetch</command>."
16126 msgstr ""
16128 #. type: Content of: <book><chapter><itemizedlist><listitem><para>
16129 #: ../en/ch13-hgext.xml:24
16130 msgid ""
16131 "In <xref linkend=\"chap:hook\"/>, we covered several extensions that are "
16132 "useful for hook-related functionality: <literal role=\"hg-ext\">acl</literal> "
16133 "adds access control lists; <literal role=\"hg-ext\">bugzilla</literal> adds "
16134 "integration with the Bugzilla bug tracking system; and <literal role=\"hg-ext"
16135 "\">notify</literal> sends notification emails on new changes."
16136 msgstr ""
16138 #. type: Content of: <book><chapter><itemizedlist><listitem><para>
16139 #: ../en/ch13-hgext.xml:33
16140 msgid ""
16141 "The Mercurial Queues patch management extension is so invaluable that it "
16142 "merits two chapters and an appendix all to itself. <xref linkend=\"chap:mq\"/"
16143 "> covers the basics; <xref linkend=\"chap:mq-collab\"/> discusses advanced "
16144 "topics; and <xref linkend=\"chap:mqref\"/> goes into detail on each command."
16145 msgstr ""
16147 #. type: Content of: <book><chapter><para>
16148 #: ../en/ch13-hgext.xml:43
16149 msgid ""
16150 "In this chapter, we'll cover some of the other extensions that are available "
16151 "for Mercurial, and briefly touch on some of the machinery you'll need to know "
16152 "about if you want to write an extension of your own."
16153 msgstr ""
16155 #. type: Content of: <book><chapter><itemizedlist><listitem><para>
16156 #: ../en/ch13-hgext.xml:48
16157 msgid ""
16158 "In <xref linkend=\"sec:hgext:inotify\"/>, we'll discuss the possibility of "
16159 "<emphasis>huge</emphasis> performance improvements using the <literal role="
16160 "\"hg-ext\">inotify</literal> extension."
16161 msgstr ""
16163 #. type: Content of: <book><chapter><sect1><title>
16164 #: ../en/ch13-hgext.xml:55
16165 msgid ""
16166 "Improve performance with the <literal role=\"hg-ext\">inotify</literal> "
16167 "extension"
16168 msgstr "使用扩展 <literal role=\"hg-ext\">inotify</literal> 以提高性能"
16170 #. type: Content of: <book><chapter><sect1><para>
16171 #: ../en/ch13-hgext.xml:58
16172 msgid ""
16173 "Are you interested in having some of the most common Mercurial operations run "
16174 "as much as a hundred times faster? Read on!"
16175 msgstr ""
16177 #. type: Content of: <book><chapter><sect1><para>
16178 #: ../en/ch13-hgext.xml:62
16179 msgid ""
16180 "Mercurial has great performance under normal circumstances. For example, "
16181 "when you run the <command role=\"hg-cmd\">hg status</command> command, "
16182 "Mercurial has to scan almost every directory and file in your repository so "
16183 "that it can display file status. Many other Mercurial commands need to do "
16184 "the same work behind the scenes; for example, the <command role=\"hg-cmd\">hg "
16185 "diff</command> command uses the status machinery to avoid doing an expensive "
16186 "comparison operation on files that obviously haven't changed."
16187 msgstr ""
16189 #. type: Content of: <book><chapter><sect1><para>
16190 #: ../en/ch13-hgext.xml:72
16191 msgid ""
16192 "Because obtaining file status is crucial to good performance, the authors of "
16193 "Mercurial have optimised this code to within an inch of its life. However, "
16194 "there's no avoiding the fact that when you run <command role=\"hg-cmd\">hg "
16195 "status</command>, Mercurial is going to have to perform at least one "
16196 "expensive system call for each managed file to determine whether it's changed "
16197 "since the last time Mercurial checked. For a sufficiently large repository, "
16198 "this can take a long time."
16199 msgstr ""
16201 #. type: Content of: <book><chapter><sect1><para>
16202 #: ../en/ch13-hgext.xml:82
16203 msgid ""
16204 "To put a number on the magnitude of this effect, I created a repository "
16205 "containing 150,000 managed files. I timed <command role=\"hg-cmd\">hg "
16206 "status</command> as taking ten seconds to run, even when <emphasis>none</"
16207 "emphasis> of those files had been modified."
16208 msgstr ""
16210 #. type: Content of: <book><chapter><sect1><para>
16211 #: ../en/ch13-hgext.xml:88
16212 msgid ""
16213 "Many modern operating systems contain a file notification facility. If a "
16214 "program signs up to an appropriate service, the operating system will notify "
16215 "it every time a file of interest is created, modified, or deleted. On Linux "
16216 "systems, the kernel component that does this is called <literal>inotify</"
16217 "literal>."
16218 msgstr ""
16220 #. type: Content of: <book><chapter><sect1><para>
16221 #: ../en/ch13-hgext.xml:95
16222 msgid ""
16223 "Mercurial's <literal role=\"hg-ext\">inotify</literal> extension talks to the "
16224 "kernel's <literal>inotify</literal> component to optimise <command role=\"hg-"
16225 "cmd\">hg status</command> commands. The extension has two components. A "
16226 "daemon sits in the background and receives notifications from the "
16227 "<literal>inotify</literal> subsystem. It also listens for connections from a "
16228 "regular Mercurial command. The extension modifies Mercurial's behavior so "
16229 "that instead of scanning the filesystem, it queries the daemon. Since the "
16230 "daemon has perfect information about the state of the repository, it can "
16231 "respond with a result instantaneously, avoiding the need to scan every "
16232 "directory and file in the repository."
16233 msgstr ""
16235 #. type: Content of: <book><chapter><sect1><para>
16236 #: ../en/ch13-hgext.xml:108
16237 msgid ""
16238 "Recall the ten seconds that I measured plain Mercurial as taking to run "
16239 "<command role=\"hg-cmd\">hg status</command> on a 150,000 file repository. "
16240 "With the <literal role=\"hg-ext\">inotify</literal> extension enabled, the "
16241 "time dropped to 0.1 seconds, a factor of <emphasis>one hundred</emphasis> "
16242 "faster."
16243 msgstr ""
16245 #. type: Content of: <book><chapter><sect1><para>
16246 #: ../en/ch13-hgext.xml:115
16247 msgid "Before we continue, please pay attention to some caveats."
16248 msgstr ""
16250 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
16251 #: ../en/ch13-hgext.xml:118
16252 msgid ""
16253 "The <literal role=\"hg-ext\">inotify</literal> extension is Linux-specific. "
16254 "Because it interfaces directly to the Linux kernel's <literal>inotify</"
16255 "literal> subsystem, it does not work on other operating systems."
16256 msgstr ""
16258 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
16259 #: ../en/ch13-hgext.xml:123
16260 msgid ""
16261 "It should work on any Linux distribution that was released after early 2005. "
16262 "Older distributions are likely to have a kernel that lacks <literal>inotify</"
16263 "literal>, or a version of <literal>glibc</literal> that does not have the "
16264 "necessary interfacing support."
16265 msgstr ""
16267 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
16268 #: ../en/ch13-hgext.xml:130
16269 msgid ""
16270 "Not all filesystems are suitable for use with the <literal role=\"hg-ext"
16271 "\">inotify</literal> extension. Network filesystems such as NFS are a non-"
16272 "starter, for example, particularly if you're running Mercurial on several "
16273 "systems, all mounting the same network filesystem. The kernel's "
16274 "<literal>inotify</literal> system has no way of knowing about changes made on "
16275 "another system. Most local filesystems (e.g. ext3, XFS, ReiserFS) should "
16276 "work fine."
16277 msgstr ""
16279 #. type: Content of: <book><chapter><sect1><para>
16280 #: ../en/ch13-hgext.xml:141
16281 msgid ""
16282 "The <literal role=\"hg-ext\">inotify</literal> extension is not yet shipped "
16283 "with Mercurial as of May 2007, so it's a little more involved to set up than "
16284 "other extensions. But the performance improvement is worth it!"
16285 msgstr ""
16287 #. type: Content of: <book><chapter><sect1><para>
16288 #: ../en/ch13-hgext.xml:146
16289 msgid ""
16290 "The extension currently comes in two parts: a set of patches to the Mercurial "
16291 "source code, and a library of Python bindings to the <literal>inotify</"
16292 "literal> subsystem."
16293 msgstr ""
16295 #. type: Content of: <book><chapter><sect1><note><para>
16296 #: ../en/ch13-hgext.xml:150
16297 msgid ""
16298 "There are <emphasis>two</emphasis> Python <literal>inotify</literal> binding "
16299 "libraries. One of them is called <literal>pyinotify</literal>, and is "
16300 "packaged by some Linux distributions as <literal>python-inotify</literal>. "
16301 "This is <emphasis>not</emphasis> the one you'll need, as it is too buggy and "
16302 "inefficient to be practical."
16303 msgstr ""
16305 #. type: Content of: <book><chapter><sect1><para>
16306 #: ../en/ch13-hgext.xml:157
16307 msgid ""
16308 "To get going, it's best to already have a functioning copy of Mercurial "
16309 "installed."
16310 msgstr ""
16312 #. type: Content of: <book><chapter><sect1><note><para>
16313 #: ../en/ch13-hgext.xml:160
16314 msgid ""
16315 "If you follow the instructions below, you'll be <emphasis>replacing</"
16316 "emphasis> and overwriting any existing installation of Mercurial that you "
16317 "might already have, using the latest <quote>bleeding edge</quote> Mercurial "
16318 "code. Don't say you weren't warned!"
16319 msgstr ""
16321 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
16322 #: ../en/ch13-hgext.xml:167
16323 msgid ""
16324 "Clone the Python <literal>inotify</literal> binding repository. Build and "
16325 "install it."
16326 msgstr ""
16328 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
16329 #: ../en/ch13-hgext.xml:174
16330 msgid ""
16331 "Clone the <filename class=\"directory\">crew</filename> Mercurial "
16332 "repository. Clone the <literal role=\"hg-ext\">inotify</literal> patch "
16333 "repository so that Mercurial Queues will be able to apply patches to your "
16334 "cope of the <filename class=\"directory\">crew</filename> repository."
16335 msgstr ""
16337 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
16338 #: ../en/ch13-hgext.xml:184
16339 msgid ""
16340 "Make sure that you have the Mercurial Queues extension, <literal role=\"hg-ext"
16341 "\">mq</literal>, enabled. If you've never used MQ, read <xref linkend=\"sec:"
16342 "mq:start\"/> to get started quickly."
16343 msgstr ""
16345 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
16346 #: ../en/ch13-hgext.xml:190
16347 msgid ""
16348 "Go into the <filename class=\"directory\">inotify</filename> repo, and apply "
16349 "all of the <literal role=\"hg-ext\">inotify</literal> patches using the "
16350 "<option role=\"hg-ext-mq-cmd-qpush-opt\">hg -a</option> option to the "
16351 "<command role=\"hg-ext-mq\">qpush</command> command."
16352 msgstr ""
16354 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
16355 #: ../en/ch13-hgext.xml:199
16356 msgid ""
16357 "If you get an error message from <command role=\"hg-ext-mq\">qpush</command>, "
16358 "you should not continue. Instead, ask for help."
16359 msgstr ""
16361 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
16362 #: ../en/ch13-hgext.xml:203
16363 msgid "Build and install the patched version of Mercurial."
16364 msgstr ""
16366 #. type: Content of: <book><chapter><sect1><para>
16367 #: ../en/ch13-hgext.xml:209
16368 msgid ""
16369 "Once you've build a suitably patched version of Mercurial, all you need to do "
16370 "to enable the <literal role=\"hg-ext\">inotify</literal> extension is add an "
16371 "entry to your <filename role=\"special\">~/.hgrc</filename>."
16372 msgstr ""
16374 #. type: Content of: <book><chapter><sect1><para>
16375 #: ../en/ch13-hgext.xml:214
16376 msgid ""
16377 "When the <literal role=\"hg-ext\">inotify</literal> extension is enabled, "
16378 "Mercurial will automatically and transparently start the status daemon the "
16379 "first time you run a command that needs status in a repository. It runs one "
16380 "status daemon per repository."
16381 msgstr ""
16383 #. type: Content of: <book><chapter><sect1><para>
16384 #: ../en/ch13-hgext.xml:220
16385 msgid ""
16386 "The status daemon is started silently, and runs in the background. If you "
16387 "look at a list of running processes after you've enabled the <literal role="
16388 "\"hg-ext\">inotify</literal> extension and run a few commands in different "
16389 "repositories, you'll thus see a few <literal>hg</literal> processes sitting "
16390 "around, waiting for updates from the kernel and queries from Mercurial."
16391 msgstr ""
16393 #. type: Content of: <book><chapter><sect1><para>
16394 #: ../en/ch13-hgext.xml:228
16395 msgid ""
16396 "The first time you run a Mercurial command in a repository when you have the "
16397 "<literal role=\"hg-ext\">inotify</literal> extension enabled, it will run "
16398 "with about the same performance as a normal Mercurial command. This is "
16399 "because the status daemon needs to perform a normal status scan so that it "
16400 "has a baseline against which to apply later updates from the kernel. "
16401 "However, <emphasis>every</emphasis> subsequent command that does any kind of "
16402 "status check should be noticeably faster on repositories of even fairly "
16403 "modest size. Better yet, the bigger your repository is, the greater a "
16404 "performance advantage you'll see. The <literal role=\"hg-ext\">inotify</"
16405 "literal> daemon makes status operations almost instantaneous on repositories "
16406 "of all sizes!"
16407 msgstr ""
16409 #. type: Content of: <book><chapter><sect1><para>
16410 #: ../en/ch13-hgext.xml:242
16411 msgid ""
16412 "If you like, you can manually start a status daemon using the <command role="
16413 "\"hg-ext-inotify\">inserve</command> command. This gives you slightly finer "
16414 "control over how the daemon ought to run. This command will of course only "
16415 "be available when the <literal role=\"hg-ext\">inotify</literal> extension is "
16416 "enabled."
16417 msgstr ""
16419 #. type: Content of: <book><chapter><sect1><para>
16420 #: ../en/ch13-hgext.xml:249
16421 msgid ""
16422 "When you're using the <literal role=\"hg-ext\">inotify</literal> extension, "
16423 "you should notice <emphasis>no difference at all</emphasis> in Mercurial's "
16424 "behavior, with the sole exception of status-related commands running a whole "
16425 "lot faster than they used to. You should specifically expect that commands "
16426 "will not print different output; neither should they give different results. "
16427 "If either of these situations occurs, please report a bug."
16428 msgstr ""
16430 #. type: Content of: <book><chapter><sect1><title>
16431 #: ../en/ch13-hgext.xml:260
16432 msgid ""
16433 "Flexible diff support with the <literal role=\"hg-ext\">extdiff</literal> "
16434 "extension"
16435 msgstr "使用扩展 <literal role=\"hg-ext\">extdiff</literal> 以扩展差异支持"
16437 #. type: Content of: <book><chapter><sect1><para>
16438 #: ../en/ch13-hgext.xml:263
16439 msgid ""
16440 "Mercurial's built-in <command role=\"hg-cmd\">hg diff</command> command "
16441 "outputs plaintext unified diffs."
16442 msgstr ""
16443 "Mercurial 内置命令 <command role=\"hg-cmd\">hg diff</command> 的输出与统一差异"
16444 "不同。"
16446 #. type: Content of: <book><chapter><sect1><para>
16447 #: ../en/ch13-hgext.xml:268
16448 msgid ""
16449 "If you would like to use an external tool to display modifications, you'll "
16450 "want to use the <literal role=\"hg-ext\">extdiff</literal> extension. This "
16451 "will let you use, for example, a graphical diff tool."
16452 msgstr ""
16454 #. type: Content of: <book><chapter><sect1><para>
16455 #: ../en/ch13-hgext.xml:273
16456 msgid ""
16457 "The <literal role=\"hg-ext\">extdiff</literal> extension is bundled with "
16458 "Mercurial, so it's easy to set up. In the <literal role=\"rc-extensions"
16459 "\">extensions</literal> section of your <filename role=\"special\">~/.hgrc</"
16460 "filename>, simply add a one-line entry to enable the extension."
16461 msgstr ""
16463 #. type: Content of: <book><chapter><sect1><para>
16464 #: ../en/ch13-hgext.xml:280
16465 msgid ""
16466 "This introduces a command named <command role=\"hg-ext-extdiff\">extdiff</"
16467 "command>, which by default uses your system's <command>diff</command> command "
16468 "to generate a unified diff in the same form as the built-in <command role="
16469 "\"hg-cmd\">hg diff</command> command."
16470 msgstr ""
16472 #. type: Content of: <book><chapter><sect1><para>
16473 #: ../en/ch13-hgext.xml:288
16474 msgid ""
16475 "The result won't be exactly the same as with the built-in <command role=\"hg-"
16476 "cmd\">hg diff</command> variations, because the output of <command>diff</"
16477 "command> varies from one system to another, even when passed the same options."
16478 msgstr ""
16480 #. type: Content of: <book><chapter><sect1><para>
16481 #: ../en/ch13-hgext.xml:293
16482 msgid ""
16483 "As the <quote><literal>making snapshot</literal></quote> lines of output "
16484 "above imply, the <command role=\"hg-ext-extdiff\">extdiff</command> command "
16485 "works by creating two snapshots of your source tree. The first snapshot is "
16486 "of the source revision; the second, of the target revision or working "
16487 "directory. The <command role=\"hg-ext-extdiff\">extdiff</command> command "
16488 "generates these snapshots in a temporary directory, passes the name of each "
16489 "directory to an external diff viewer, then deletes the temporary directory. "
16490 "For efficiency, it only snapshots the directories and files that have changed "
16491 "between the two revisions."
16492 msgstr ""
16494 #. type: Content of: <book><chapter><sect1><para>
16495 #: ../en/ch13-hgext.xml:306
16496 msgid ""
16497 "Snapshot directory names have the same base name as your repository. If your "
16498 "repository path is <filename class=\"directory\">/quux/bar/foo</filename>, "
16499 "then <filename class=\"directory\">foo</filename> will be the name of each "
16500 "snapshot directory. Each snapshot directory name has its changeset ID "
16501 "appended, if appropriate. If a snapshot is of revision "
16502 "<literal>a631aca1083f</literal>, the directory will be named <filename class="
16503 "\"directory\">foo.a631aca1083f</filename>. A snapshot of the working "
16504 "directory won't have a changeset ID appended, so it would just be <filename "
16505 "class=\"directory\">foo</filename> in this example. To see what this looks "
16506 "like in practice, look again at the <command role=\"hg-ext-extdiff\">extdiff</"
16507 "command> example above. Notice that the diff has the snapshot directory "
16508 "names embedded in its header."
16509 msgstr ""
16511 #. type: Content of: <book><chapter><sect1><para>
16512 #: ../en/ch13-hgext.xml:322
16513 msgid ""
16514 "The <command role=\"hg-ext-extdiff\">extdiff</command> command accepts two "
16515 "important options. The <option role=\"hg-ext-extdiff-cmd-extdiff-opt\">hg -p</"
16516 "option> option lets you choose a program to view differences with, instead of "
16517 "<command>diff</command>. With the <option role=\"hg-ext-extdiff-cmd-extdiff-"
16518 "opt\">hg -o</option> option, you can change the options that <command role="
16519 "\"hg-ext-extdiff\">extdiff</command> passes to the program (by default, these "
16520 "options are <quote><literal>-Npru</literal></quote>, which only make sense if "
16521 "you're running <command>diff</command>). In other respects, the <command "
16522 "role=\"hg-ext-extdiff\">extdiff</command> command acts similarly to the built-"
16523 "in <command role=\"hg-cmd\">hg diff</command> command: you use the same "
16524 "option names, syntax, and arguments to specify the revisions you want, the "
16525 "files you want, and so on."
16526 msgstr ""
16529 #. type: Content of: <book><chapter><sect1><para>
16530 #: ../en/ch13-hgext.xml:339
16531 msgid ""
16532 "As an example, here's how to run the normal system <command>diff</command> "
16533 "command, getting it to generate context diffs (using the <option role=\"cmd-"
16534 "opt-diff\">-c</option> option) instead of unified diffs, and five lines of "
16535 "context instead of the default three (passing <literal>5</literal> as the "
16536 "argument to the <option role=\"cmd-opt-diff\">-C</option> option)."
16537 msgstr ""
16539 #. type: Content of: <book><chapter><sect1><para>
16540 #: ../en/ch13-hgext.xml:348
16541 msgid ""
16542 "Launching a visual diff tool is just as easy. Here's how to launch the "
16543 "<command>kdiff3</command> viewer."
16544 msgstr ""
16546 #. type: Content of: <book><chapter><sect1><para>
16547 #: ../en/ch13-hgext.xml:352
16548 msgid ""
16549 "If your diff viewing command can't deal with directories, you can easily work "
16550 "around this with a little scripting. For an example of such scripting in "
16551 "action with the <literal role=\"hg-ext\">mq</literal> extension and the "
16552 "<command>interdiff</command> command, see <xref linkend=\"mq-collab:tips:"
16553 "interdiff\"/>."
16554 msgstr ""
16556 #. type: Content of: <book><chapter><sect1><sect2><title>
16557 #: ../en/ch13-hgext.xml:360
16558 msgid "Defining command aliases"
16559 msgstr "定义命令的别名"
16561 #. type: Content of: <book><chapter><sect1><sect2><para>
16562 #: ../en/ch13-hgext.xml:362
16563 msgid ""
16564 "It can be cumbersome to remember the options to both the <command role=\"hg-"
16565 "ext-extdiff\">extdiff</command> command and the diff viewer you want to use, "
16566 "so the <literal role=\"hg-ext\">extdiff</literal> extension lets you define "
16567 "<emphasis>new</emphasis> commands that will invoke your diff viewer with "
16568 "exactly the right options."
16569 msgstr ""
16571 #. type: Content of: <book><chapter><sect1><sect2><para>
16572 #: ../en/ch13-hgext.xml:369
16573 msgid ""
16574 "All you need to do is edit your <filename role=\"special\">~/.hgrc</"
16575 "filename>, and add a section named <literal role=\"rc-extdiff\">extdiff</"
16576 "literal>. Inside this section, you can define multiple commands. Here's how "
16577 "to add a <literal>kdiff3</literal> command. Once you've defined this, you "
16578 "can type <quote><literal>hg kdiff3</literal></quote> and the <literal role="
16579 "\"hg-ext\">extdiff</literal> extension will run <command>kdiff3</command> for "
16580 "you."
16581 msgstr ""
16583 #. type: Content of: <book><chapter><sect1><sect2><para>
16584 #: ../en/ch13-hgext.xml:379
16585 msgid ""
16586 "If you leave the right hand side of the definition empty, as above, the "
16587 "<literal role=\"hg-ext\">extdiff</literal> extension uses the name of the "
16588 "command you defined as the name of the external program to run. But these "
16589 "names don't have to be the same. Here, we define a command named "
16590 "<quote><literal>hg wibble</literal></quote>, which runs <command>kdiff3</"
16591 "command>."
16592 msgstr ""
16594 #. type: Content of: <book><chapter><sect1><sect2><para>
16595 #: ../en/ch13-hgext.xml:389
16596 msgid ""
16597 "You can also specify the default options that you want to invoke your diff "
16598 "viewing program with. The prefix to use is <quote><literal>opts.</literal></"
16599 "quote>, followed by the name of the command to which the options apply. This "
16600 "example defines a <quote><literal>hg vimdiff</literal></quote> command that "
16601 "runs the <command>vim</command> editor's <literal>DirDiff</literal> extension."
16602 msgstr ""
16604 #. type: Content of: <book><chapter><sect1><title>
16605 #: ../en/ch13-hgext.xml:403
16606 msgid ""
16607 "Cherrypicking changes with the <literal role=\"hg-ext\">transplant</literal> "
16608 "extension"
16609 msgstr "使用扩展 <literal role=\"hg-ext\">transplant</literal> 以挑选修改"
16611 #. type: Content of: <book><chapter><sect1><para>
16612 #: ../en/ch13-hgext.xml:406
16613 msgid "Need to have a long chat with Brendan about this."
16614 msgstr ""
16616 #. type: Content of: <book><chapter><sect1><title>
16617 #: ../en/ch13-hgext.xml:410
16618 msgid ""
16619 "Send changes via email with the <literal role=\"hg-ext\">patchbomb</literal> "
16620 "extension"
16621 msgstr ""
16622 "使用扩展 <literal role=\"hg-ext\">patchbomb</literal> 通过 email 发送修改"
16624 #. type: Content of: <book><chapter><sect1><para>
16625 #: ../en/ch13-hgext.xml:413
16626 msgid ""
16627 "Many projects have a culture of <quote>change review</quote>, in which people "
16628 "send their modifications to a mailing list for others to read and comment on "
16629 "before they commit the final version to a shared repository. Some projects "
16630 "have people who act as gatekeepers; they apply changes from other people to a "
16631 "repository to which those others don't have access."
16632 msgstr ""
16634 #. type: Content of: <book><chapter><sect1><para>
16635 #: ../en/ch13-hgext.xml:421
16636 msgid ""
16637 "Mercurial makes it easy to send changes over email for review or application, "
16638 "via its <literal role=\"hg-ext\">patchbomb</literal> extension. The "
16639 "extension is so named because changes are formatted as patches, and it's "
16640 "usual to send one changeset per email message. Sending a long series of "
16641 "changes by email is thus much like <quote>bombing</quote> the recipient's "
16642 "inbox, hence <quote>patchbomb</quote>."
16643 msgstr ""
16645 #. type: Content of: <book><chapter><sect1><para>
16646 #: ../en/ch13-hgext.xml:429
16647 msgid ""
16648 "As usual, the basic configuration of the <literal role=\"hg-ext\">patchbomb</"
16649 "literal> extension takes just one or two lines in your <filename role="
16650 "\"special\"> /.hgrc</filename>."
16651 msgstr ""
16653 #. type: Content of: <book><chapter><sect1><para>
16654 #: ../en/ch13-hgext.xml:435
16655 msgid ""
16656 "Once you've enabled the extension, you will have a new command available, "
16657 "named <command role=\"hg-ext-patchbomb\">email</command>."
16658 msgstr ""
16660 #. type: Content of: <book><chapter><sect1><para>
16661 #: ../en/ch13-hgext.xml:439
16662 msgid ""
16663 "The safest and best way to invoke the <command role=\"hg-ext-patchbomb"
16664 "\">email</command> command is to <emphasis>always</emphasis> run it first "
16665 "with the <option role=\"hg-ext-patchbomb-cmd-email-opt\">hg -n</option> "
16666 "option. This will show you what the command <emphasis>would</emphasis> send, "
16667 "without actually sending anything. Once you've had a quick glance over the "
16668 "changes and verified that you are sending the right ones, you can rerun the "
16669 "same command, with the <option role=\"hg-ext-patchbomb-cmd-email-opt\">hg -n</"
16670 "option> option removed."
16671 msgstr ""
16673 #. type: Content of: <book><chapter><sect1><para>
16674 #: ../en/ch13-hgext.xml:450
16675 msgid ""
16676 "The <command role=\"hg-ext-patchbomb\">email</command> command accepts the "
16677 "same kind of revision syntax as every other Mercurial command. For example, "
16678 "this command will send every revision between 7 and <literal>tip</literal>, "
16679 "inclusive."
16680 msgstr ""
16682 #. type: Content of: <book><chapter><sect1><para>
16683 #: ../en/ch13-hgext.xml:455
16684 msgid ""
16685 "You can also specify a <emphasis>repository</emphasis> to compare with. If "
16686 "you provide a repository but no revisions, the <command role=\"hg-ext-"
16687 "patchbomb\">email</command> command will send all revisions in the local "
16688 "repository that are not present in the remote repository. If you "
16689 "additionally specify revisions or a branch name (the latter using the <option "
16690 "role=\"hg-ext-patchbomb-cmd-email-opt\">hg -b</option> option), this will "
16691 "constrain the revisions sent."
16692 msgstr ""
16694 #. type: Content of: <book><chapter><sect1><para>
16695 #: ../en/ch13-hgext.xml:464
16696 msgid ""
16697 "It's perfectly safe to run the <command role=\"hg-ext-patchbomb\">email</"
16698 "command> command without the names of the people you want to send to: if you "
16699 "do this, it will just prompt you for those values interactively. (If you're "
16700 "using a Linux or Unix-like system, you should have enhanced "
16701 "<literal>readline</literal>-style editing capabilities when entering those "
16702 "headers, too, which is useful.)"
16703 msgstr ""
16705 #. type: Content of: <book><chapter><sect1><para>
16706 #: ../en/ch13-hgext.xml:472
16707 msgid ""
16708 "When you are sending just one revision, the <command role=\"hg-ext-patchbomb"
16709 "\">email</command> command will by default use the first line of the "
16710 "changeset description as the subject of the single email message it sends."
16711 msgstr ""
16713 #. type: Content of: <book><chapter><sect1><para>
16714 #: ../en/ch13-hgext.xml:477
16715 msgid ""
16716 "If you send multiple revisions, the <command role=\"hg-ext-patchbomb\">email</"
16717 "command> command will usually send one message per changeset. It will "
16718 "preface the series with an introductory message, in which you should describe "
16719 "the purpose of the series of changes you're sending."
16720 msgstr ""
16722 #. type: Content of: <book><chapter><sect1><sect2><title>
16723 #: ../en/ch13-hgext.xml:484
16724 #, fuzzy
16725 msgid "Changing the behavior of patchbombs"
16726 msgstr "修改 patchbomb 的行为"
16728 #. type: Content of: <book><chapter><sect1><sect2><para>
16729 #: ../en/ch13-hgext.xml:486
16730 msgid ""
16731 "Not every project has exactly the same conventions for sending changes in "
16732 "email; the <literal role=\"hg-ext\">patchbomb</literal> extension tries to "
16733 "accommodate a number of variations through command line options."
16734 msgstr ""
16736 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16737 #: ../en/ch13-hgext.xml:492
16738 msgid ""
16739 "You can write a subject for the introductory message on the command line "
16740 "using the <option role=\"hg-ext-patchbomb-cmd-email-opt\">hg -s</option> "
16741 "option. This takes one argument, the text of the subject to use."
16742 msgstr ""
16744 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16745 #: ../en/ch13-hgext.xml:498
16746 msgid ""
16747 "To change the email address from which the messages originate, use the "
16748 "<option role=\"hg-ext-patchbomb-cmd-email-opt\">hg -f</option> option. This "
16749 "takes one argument, the email address to use."
16750 msgstr ""
16752 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16753 #: ../en/ch13-hgext.xml:504
16754 msgid ""
16755 "The default behavior is to send unified diffs (see <xref linkend=\"sec:mq:"
16756 "patch\"/> for a description of the format), one per message. You can send a "
16757 "binary bundle instead with the <option role=\"hg-ext-patchbomb-cmd-email-opt"
16758 "\">hg -b</option> option."
16759 msgstr ""
16761 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16762 #: ../en/ch13-hgext.xml:512
16763 msgid ""
16764 "Unified diffs are normally prefaced with a metadata header. You can omit "
16765 "this, and send unadorned diffs, with the <option role=\"hg-ext-patchbomb-cmd-"
16766 "email-opt\">hg --plain</option> option."
16767 msgstr ""
16769 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16770 #: ../en/ch13-hgext.xml:518
16771 msgid ""
16772 "Diffs are normally sent <quote>inline</quote>, in the same body part as the "
16773 "description of a patch. This makes it easiest for the largest number of "
16774 "readers to quote and respond to parts of a diff, as some mail clients will "
16775 "only quote the first MIME body part in a message. If you'd prefer to send the "
16776 "description and the diff in separate body parts, use the <option role=\"hg-"
16777 "ext-patchbomb-cmd-email-opt\">hg -a</option> option."
16778 msgstr ""
16780 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16781 #: ../en/ch13-hgext.xml:528
16782 msgid ""
16783 "Instead of sending mail messages, you can write them to an <literal>mbox</"
16784 "literal>-format mail folder using the <option role=\"hg-ext-patchbomb-cmd-"
16785 "email-opt\">hg -m</option> option. That option takes one argument, the name "
16786 "of the file to write to."
16787 msgstr ""
16789 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16790 #: ../en/ch13-hgext.xml:535
16791 msgid ""
16792 "If you would like to add a <command>diffstat</command>-format summary to each "
16793 "patch, and one to the introductory message, use the <option role=\"hg-ext-"
16794 "patchbomb-cmd-email-opt\">hg -d</option> option. The <command>diffstat</"
16795 "command> command displays a table containing the name of each file patched, "
16796 "the number of lines affected, and a histogram showing how much each file is "
16797 "modified. This gives readers a qualitative glance at how complex a patch is."
16798 msgstr ""