hgbook

view po/zh.po @ 1070:3dec81dc4543

2.4 partly zh translated
author Zhaoping Sun <zhaopingsun@gmail.com>
date Wed Nov 11 21:25:10 2009 -0500 (2009-11-11)
parents 95fd40da8f34
children 9f19da74ac3a
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 # identifiers 标识符
40 # ...
41 #
42 msgid ""
43 msgstr ""
44 "Project-Id-Version: hgbook 1.2\n"
45 "POT-Creation-Date: 2009-11-04 14:06+0800\n"
46 "PO-Revision-Date: 2009-10-21 16:42+0800\n"
47 "Last-Translator: 宋冬生 <songdonogsheng@live.cn>\n"
48 "Language-Team: Simplified Chinese <i18n-zh@googlegroups.com >\n"
49 "MIME-Version: 1.0\n"
50 "Content-Type: text/plain; charset=UTF-8\n"
51 "Content-Transfer-Encoding: 8bit\n"
52 "X-Poedit-Language: Chinese\n"
53 "X-Poedit-Country: CHINA\n"
54 "X-Poedit-SourceCharset: utf-8\n"
56 #. type: Content of: <book><title>
57 #: ../en/00book.xml:42
58 msgid "Mercurial: The Definitive Guide"
59 msgstr "Mercurial 权威指南"
61 #. type: Content of: <book><subtitle>
62 #: ../en/00book.xml:47
63 msgid "Compiled from $rev_id$"
64 msgstr "编译自 $rev_id$"
66 #. type: Content of: <book><bookinfo>
67 #: ../en/00book.xml:49
68 msgid "<edition>1</edition> <isbn>9780596800673</isbn>"
69 msgstr "<edition>1</edition> <isbn>9780596800673</isbn>"
71 #. type: Content of: <book><bookinfo><authorgroup><author><firstname>
72 #: ../en/00book.xml:53
73 msgid "Bryan"
74 msgstr "Bryan"
76 #. type: Content of: <book><bookinfo><authorgroup><author><surname>
77 #: ../en/00book.xml:54
78 msgid "O'Sullivan"
79 msgstr "O'Sullivan"
81 #. type: Content of: <book><bookinfo>
82 #: ../en/00book.xml:58
83 msgid ""
84 "<editor> <firstname>Mike</firstname> <surname>Loukides</surname> </editor> "
85 "<copyright> <year>2006</year> <year>2007</year> <year>2008</year> <year>2009</"
86 "year> <holder>Bryan O'Sullivan</holder> </copyright>"
87 msgstr ""
88 "<editor> <firstname>Mike</firstname> <surname>Loukides</surname> </editor> "
89 "<copyright> <year>2006</year> <year>2007</year> <year>2008</year> <year>2009</"
90 "year> <holder>Bryan O'Sullivan</holder> </copyright>"
92 #. type: Content of: <book><appendix><title>
93 #: ../en/appA-svn.xml:5
94 msgid "Migrating to Mercurial"
95 msgstr "迁移到 Mercurial"
97 #. type: Content of: <book><appendix><para>
98 #: ../en/appA-svn.xml:7
99 msgid ""
100 "A common way to test the waters with a new revision control tool is to "
101 "experiment with switching an existing project, rather than starting a new "
102 "project from scratch."
103 msgstr ""
105 #. type: Content of: <book><appendix><para>
106 #: ../en/appA-svn.xml:11
107 msgid ""
108 "In this appendix, we discuss how to import a project's history into "
109 "Mercurial, and what to look out for if you are used to a different revision "
110 "control system."
111 msgstr ""
113 #. type: Content of: <book><appendix><sect1><title>
114 #: ../en/appA-svn.xml:16
115 msgid "Importing history from another system"
116 msgstr "从其它版本控制系统导入历史"
118 #. type: Content of: <book><appendix><sect1><para>
119 #: ../en/appA-svn.xml:18
120 msgid ""
121 "Mercurial ships with an extension named <literal>convert</literal>, which can "
122 "import project history from most popular revision control systems. At the "
123 "time this book was written, it could import history from the following "
124 "systems:"
125 msgstr ""
127 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><thead><row><entry>
128 #: ../en/appA-svn.xml:25 ../en/appA-svn.xml:369 ../en/ch01-intro.xml:416
129 #: ../en/ch01-intro.xml:627
130 msgid "Subversion"
131 msgstr "Subversion"
133 #. type: Content of: <book><appendix><sect1><itemizedlist><listitem><para>
134 #: ../en/appA-svn.xml:28 ../en/ch01-intro.xml:532 ../en/ch01-intro.xml:628
135 msgid "CVS"
136 msgstr "CVS"
138 #. type: Content of: <book><appendix><sect1><itemizedlist><listitem><para>
139 #: ../en/appA-svn.xml:31
140 msgid "git"
141 msgstr "git"
143 #. type: Content of: <book><appendix><sect1><itemizedlist><listitem><para>
144 #: ../en/appA-svn.xml:34 ../en/ch01-intro.xml:630
145 msgid "Darcs"
146 msgstr "Darcs"
148 #. type: Content of: <book><appendix><sect1><itemizedlist><listitem><para>
149 #: ../en/appA-svn.xml:37
150 msgid "Bazaar"
151 msgstr "Bazaar"
153 #. type: Content of: <book><appendix><sect1><itemizedlist><listitem><para>
154 #: ../en/appA-svn.xml:40
155 msgid "Monotone"
156 msgstr "Monotone"
158 #. type: Content of: <book><appendix><sect1><itemizedlist><listitem><para>
159 #: ../en/appA-svn.xml:43
160 msgid "GNU Arch"
161 msgstr "GNU Arch"
163 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><thead><row><entry>
164 #: ../en/appA-svn.xml:46 ../en/appA-svn.xml:370
165 msgid "Mercurial"
166 msgstr "Mercurial"
168 #. type: Content of: <book><appendix><sect1><para>
169 #: ../en/appA-svn.xml:50
170 msgid ""
171 "(To see why Mercurial itself is supported as a source, see <xref linkend="
172 "\"svn.filemap\"/>.)"
173 msgstr ""
175 #. type: Content of: <book><appendix><sect1><para>
176 #: ../en/appA-svn.xml:53
177 msgid ""
178 "You can enable the extension in the usual way, by editing your <filename>~/."
179 "hgrc</filename> file."
180 msgstr ""
181 "你可以通过常用的方式,编辑<filename>~./hgrc</filename>文件来使用这个扩展。"
183 #. type: Content of: <book><appendix><sect1><para>
184 #: ../en/appA-svn.xml:59
185 msgid ""
186 "This will make a <command>hg convert</command> command available. The "
187 "command is easy to use. For instance, this command will import the "
188 "Subversion history for the Nose unit testing framework into Mercurial."
189 msgstr ""
191 #. type: Content of: <book><appendix><sect1><screen><prompt>
192 #: ../en/appA-svn.xml:64 ../en/appA-svn.xml:207 ../en/appA-svn.xml:212
193 #: ../en/appA-svn.xml:213 ../en/appA-svn.xml:218 ../en/appA-svn.xml:224
194 #: ../en/appA-svn.xml:229 ../en/appA-svn.xml:532
195 msgid "$"
196 msgstr "$"
198 #. type: Content of: <book><appendix><sect1><screen><userinput>
199 #: ../en/appA-svn.xml:64
200 msgid "hg convert http://python-nose.googlecode.com/svn/trunk"
201 msgstr ""
203 #. type: Content of: <book><appendix><sect1><para>
204 #: ../en/appA-svn.xml:66
205 msgid ""
206 "The <literal>convert</literal> extension operates incrementally. In other "
207 "words, after you have run <command>hg convert</command> once, running it "
208 "again will import any new revisions committed after the first run began. "
209 "Incremental conversion will only work if you run <command>hg convert</"
210 "command> in the same Mercurial repository that you originally used, because "
211 "the <literal>convert</literal> extension saves some private metadata in a non-"
212 "revision-controlled file named <filename>.hg/shamap</filename> inside the "
213 "target repository."
214 msgstr ""
216 #. type: Content of: <book><appendix><sect1><para>
217 #: ../en/appA-svn.xml:78
218 msgid ""
219 "When you want to start making changes using Mercurial, it's best to clone the "
220 "tree in which you are doing your conversions, and leave the original tree for "
221 "future incremental conversions. This is the safest way to let you pull and "
222 "merge future commits from the source revision control system into your newly "
223 "active Mercurial project."
224 msgstr ""
226 #. type: Content of: <book><appendix><sect1><sect2><title>
227 #: ../en/appA-svn.xml:86
228 msgid "Converting multiple branches"
229 msgstr "转换多个分支"
231 #. type: Content of: <book><appendix><sect1><sect2><para>
232 #: ../en/appA-svn.xml:88
233 msgid ""
234 "The <command>hg convert</command> command given above converts only the "
235 "history of the <literal>trunk</literal> branch of the Subversion repository. "
236 "If we instead use the URL <literal>http://python-nose.googlecode.com/svn</"
237 "literal>, Mercurial will automatically detect the <literal>trunk</literal>, "
238 "<literal>tags</literal> and <literal>branches</literal> layout that "
239 "Subversion projects usually use, and it will import each as a separate "
240 "Mercurial branch."
241 msgstr ""
243 #. type: Content of: <book><appendix><sect1><sect2><para>
244 #: ../en/appA-svn.xml:98
245 msgid ""
246 "By default, each Subversion branch imported into Mercurial is given a branch "
247 "name. After the conversion completes, you can get a list of the active "
248 "branch names in the Mercurial repository using <command>hg branches -a</"
249 "command>. If you would prefer to import the Subversion branches without "
250 "names, pass the <option>--config convert.hg.usebranchnames=false</option> "
251 "option to <command>hg convert</command>."
252 msgstr ""
254 #. type: Content of: <book><appendix><sect1><sect2><para>
255 #: ../en/appA-svn.xml:107
256 msgid ""
257 "Once you have converted your tree, if you want to follow the usual Mercurial "
258 "practice of working in a tree that contains a single branch, you can clone "
259 "that single branch using <command>hg clone -r mybranchname</command>."
260 msgstr ""
262 #. type: Content of: <book><appendix><sect1><sect2><title>
263 #: ../en/appA-svn.xml:114
264 msgid "Mapping user names"
265 msgstr "映射用户名称"
267 #. type: Content of: <book><appendix><sect1><sect2><para>
268 #: ../en/appA-svn.xml:116
269 msgid ""
270 "Some revision control tools save only short usernames with commits, and these "
271 "can be difficult to interpret. The norm with Mercurial is to save a "
272 "committer's name and email address, which is much more useful for talking to "
273 "them after the fact."
274 msgstr ""
276 #. type: Content of: <book><appendix><sect1><sect2><para>
277 #: ../en/appA-svn.xml:122
278 msgid ""
279 "If you are converting a tree from a revision control system that uses short "
280 "names, you can map those names to longer equivalents by passing a <option>--"
281 "authors</option> option to <command>hg convert</command>. This option "
282 "accepts a file name that should contain entries of the following form."
283 msgstr ""
285 #. type: Content of: <book><appendix><sect1><sect2><para>
286 #: ../en/appA-svn.xml:132
287 msgid ""
288 "Whenever <literal>convert</literal> encounters a commit with the username "
289 "<literal>arist</literal> in the source repository, it will use the name "
290 "<literal>Aristotle &lt;aristotle@phil.example.gr&gt;</literal> in the "
291 "converted Mercurial revision. If no match is found for a name, it is used "
292 "verbatim."
293 msgstr ""
295 #. type: Content of: <book><appendix><sect1><sect2><title>
296 #: ../en/appA-svn.xml:141
297 msgid "Tidying up the tree"
298 msgstr "清理目录树"
300 #. type: Content of: <book><appendix><sect1><sect2><para>
301 #: ../en/appA-svn.xml:143
302 msgid ""
303 "Not all projects have pristine history. There may be a directory that should "
304 "never have been checked in, a file that is too big, or a whole hierarchy that "
305 "needs to be refactored."
306 msgstr ""
308 #. type: Content of: <book><appendix><sect1><sect2><para>
309 #: ../en/appA-svn.xml:148
310 msgid ""
311 "The <literal>convert</literal> extension supports the idea of a <quote>file "
312 "map</quote> that can reorganize the files and directories in a project as it "
313 "imports the project's history. This is useful not only when importing "
314 "history from other revision control systems, but also to prune or refactor a "
315 "Mercurial tree."
316 msgstr ""
318 #. type: Content of: <book><appendix><sect1><sect2><para>
319 #: ../en/appA-svn.xml:155
320 msgid ""
321 "To specify a file map, use the <option>--filemap</option> option and supply a "
322 "file name. A file map contains lines of the following forms."
323 msgstr ""
325 #. type: Content of: <book><appendix><sect1><sect2><para>
326 #: ../en/appA-svn.xml:169
327 msgid ""
328 "The <literal>include</literal> directive causes a file, or all files under a "
329 "directory, to be included in the destination repository. This also excludes "
330 "all other files and dirs not explicitely included. The <literal>exclude</"
331 "literal> directive causes files or directories to be omitted, and others not "
332 "explicitly mentioned to be included."
333 msgstr ""
335 #. type: Content of: <book><appendix><sect1><sect2><para>
336 #: ../en/appA-svn.xml:176
337 msgid ""
338 "To move a file or directory from one location to another, use the "
339 "<literal>rename</literal> directive. If you need to move a file or directory "
340 "from a subdirectory into the root of the repository, use <literal>.</literal> "
341 "as the second argument to the <literal>rename</literal> directive."
342 msgstr ""
344 #. type: Content of: <book><appendix><sect1><sect2><title>
345 #: ../en/appA-svn.xml:184
346 msgid "Improving Subversion conversion performance"
347 msgstr "改进 Subversion 的转换性能"
349 #. type: Content of: <book><appendix><sect1><sect2><para>
350 #: ../en/appA-svn.xml:186
351 msgid ""
352 "You will often need several attempts before you hit the perfect combination "
353 "of user map, file map, and other conversion parameters. Converting a "
354 "Subversion repository over an access protocol like <literal>ssh</literal> or "
355 "<literal>http</literal> can proceed thousands of times more slowly than "
356 "Mercurial is capable of actually operating, due to network delays. This can "
357 "make tuning that perfect conversion recipe very painful."
358 msgstr ""
360 #. type: Content of: <book><appendix><sect1><sect2><para>
361 #: ../en/appA-svn.xml:195
362 msgid ""
363 "The <ulink url=\"http://svn.collab.net/repos/svn/trunk/notes/svnsync.txt"
364 "\"><command>svnsync</command></ulink> command can greatly speed up the "
365 "conversion of a Subversion repository. It is a read-only mirroring program "
366 "for Subversion repositories. The idea is that you create a local mirror of "
367 "your Subversion tree, then convert the mirror into a Mercurial repository."
368 msgstr ""
370 #. type: Content of: <book><appendix><sect1><sect2><para>
371 #: ../en/appA-svn.xml:203
372 msgid ""
373 "Suppose we want to convert the Subversion repository for the popular "
374 "Memcached project into a Mercurial tree. First, we create a local Subversion "
375 "repository."
376 msgstr ""
378 #. type: Content of: <book><appendix><sect1><sect2><screen><userinput>
379 #: ../en/appA-svn.xml:207
380 msgid "svnadmin create memcached-mirror"
381 msgstr "svnadmin create memcached-mirror"
383 #. type: Content of: <book><appendix><sect1><sect2><para>
384 #: ../en/appA-svn.xml:209
385 msgid "Next, we set up a Subversion hook that <command>svnsync</command> needs."
386 msgstr ""
388 #. type: Content of: <book><appendix><sect1><sect2><screen><userinput>
389 #: ../en/appA-svn.xml:212
390 msgid "echo '#!/bin/sh' > memcached-mirror/hooks/pre-revprop-change"
391 msgstr "echo '#!/bin/sh' > memcached-mirror/hooks/pre-revprop-change"
393 #. type: Content of: <book><appendix><sect1><sect2><screen><userinput>
394 #: ../en/appA-svn.xml:213
395 msgid "chmod +x memcached-mirror/hooks/pre-revprop-change"
396 msgstr "chmod +x memcached-mirror/hooks/pre-revprop-change"
398 #. type: Content of: <book><appendix><sect1><sect2><para>
399 #: ../en/appA-svn.xml:215
400 msgid "We then initialize <command>svnsync</command> in this repository."
401 msgstr ""
403 #. type: Content of: <book><appendix><sect1><sect2><screen><userinput>
404 #: ../en/appA-svn.xml:218
405 msgid ""
406 "svnsync --init file://`pwd`/memcached-mirror \\ http://code.sixapart.com/svn/"
407 "memcached"
408 msgstr ""
409 "svnsync --init file://`pwd`/memcached-mirror \\ http://code.sixapart.com/svn/"
410 "memcached"
412 #. type: Content of: <book><appendix><sect1><sect2><para>
413 #: ../en/appA-svn.xml:221
414 msgid ""
415 "Our next step is to begin the <command>svnsync</command> mirroring process."
416 msgstr ""
418 #. type: Content of: <book><appendix><sect1><sect2><screen><userinput>
419 #: ../en/appA-svn.xml:224
420 msgid "svnsync sync file://`pwd`/memcached-mirror"
421 msgstr "svnsync sync file://`pwd`/memcached-mirror"
423 #. type: Content of: <book><appendix><sect1><sect2><para>
424 #: ../en/appA-svn.xml:226
425 msgid ""
426 "Finally, we import the history of our local Subversion mirror into Mercurial."
427 msgstr ""
429 #. type: Content of: <book><appendix><sect1><sect2><screen><userinput>
430 #: ../en/appA-svn.xml:229
431 msgid "hg convert memcached-mirror"
432 msgstr ""
434 #. type: Content of: <book><appendix><sect1><sect2><para>
435 #: ../en/appA-svn.xml:231
436 msgid ""
437 "We can use this process incrementally if the Subversion repository is still "
438 "in use. We run <command>svnsync</command> to pull new changes into our "
439 "mirror, then <command>hg convert</command> to import them into our Mercurial "
440 "tree."
441 msgstr ""
443 #. type: Content of: <book><appendix><sect1><sect2><para>
444 #: ../en/appA-svn.xml:237
445 msgid ""
446 "There are two advantages to doing a two-stage import with <command>svnsync</"
447 "command>. The first is that it uses more efficient Subversion network "
448 "syncing code than <command>hg convert</command>, so it transfers less data "
449 "over the network. The second is that the import from a local Subversion tree "
450 "is so fast that you can tweak your conversion setup repeatedly without having "
451 "to sit through a painfully slow network-based conversion process each time."
452 msgstr ""
454 #. type: Content of: <book><appendix><sect1><title>
455 #: ../en/appA-svn.xml:249
456 msgid "Migrating from Subversion"
457 msgstr "从 Subversion 迁移"
459 #. type: Content of: <book><appendix><sect1><para>
460 #: ../en/appA-svn.xml:251
461 msgid ""
462 "Subversion is currently the most popular open source revision control system. "
463 "Although there are many differences between Mercurial and Subversion, making "
464 "the transition from Subversion to Mercurial is not particularly difficult. "
465 "The two have similar command sets and generally uniform interfaces."
466 msgstr ""
468 #. type: Content of: <book><appendix><sect1><sect2><title>
469 #: ../en/appA-svn.xml:259
470 msgid "Philosophical differences"
471 msgstr "哲学的差别"
473 #. type: Content of: <book><appendix><sect1><sect2><para>
474 #: ../en/appA-svn.xml:261
475 msgid ""
476 "The fundamental difference between Subversion and Mercurial is of course that "
477 "Subversion is centralized, while Mercurial is distributed. Since Mercurial "
478 "stores all of a project's history on your local drive, it only needs to "
479 "perform a network access when you want to explicitly communicate with another "
480 "repository. In contrast, Subversion stores very little information locally, "
481 "and the client must thus contact its server for many common operations."
482 msgstr ""
484 #. type: Content of: <book><appendix><sect1><sect2><para>
485 #: ../en/appA-svn.xml:270
486 msgid ""
487 "Subversion more or less gets away without a well-defined notion of a branch: "
488 "which portion of a server's namespace qualifies as a branch is a matter of "
489 "convention, with the software providing no enforcement. Mercurial treats a "
490 "repository as the unit of branch management."
491 msgstr ""
493 #. type: Content of: <book><appendix><sect1><sect2><sect3><title>
494 #: ../en/appA-svn.xml:277
495 msgid "Scope of commands"
496 msgstr "命令作用域"
498 #. type: Content of: <book><appendix><sect1><sect2><sect3><para>
499 #: ../en/appA-svn.xml:279
500 msgid ""
501 "Since Subversion doesn't know what parts of its namespace are really "
502 "branches, it treats most commands as requests to operate at and below "
503 "whatever directory you are currently visiting. For instance, if you run "
504 "<command>svn log</command>, you'll get the history of whatever part of the "
505 "tree you're looking at, not the tree as a whole."
506 msgstr ""
508 #. type: Content of: <book><appendix><sect1><sect2><sect3><para>
509 #: ../en/appA-svn.xml:286
510 msgid ""
511 "Mercurial's commands behave differently, by defaulting to operating over an "
512 "entire repository. Run <command>hg log</command> and it will tell you the "
513 "history of the entire tree, no matter what part of the working directory "
514 "you're visiting at the time. If you want the history of just a particular "
515 "file or directory, simply supply it by name, e.g. <command>hg log src</"
516 "command>."
517 msgstr ""
519 #. type: Content of: <book><appendix><sect1><sect2><sect3><para>
520 #: ../en/appA-svn.xml:294
521 msgid ""
522 "From my own experience, this difference in default behaviors is probably the "
523 "most likely to trip you up if you have to switch back and forth frequently "
524 "between the two tools."
525 msgstr ""
527 #. type: Content of: <book><appendix><sect1><sect2><sect3><title>
528 #: ../en/appA-svn.xml:301
529 msgid "Multi-user operation and safety"
530 msgstr "多用户操作与安全"
532 #. type: Content of: <book><appendix><sect1><sect2><sect3><para>
533 #: ../en/appA-svn.xml:303
534 msgid ""
535 "With Subversion, it is normal (though slightly frowned upon) for multiple "
536 "people to collaborate in a single branch. If Alice and Bob are working "
537 "together, and Alice commits some changes to their shared branch, Bob must "
538 "update his client's view of the branch before he can commit. Since at this "
539 "time he has no permanent record of the changes he has made, he can corrupt or "
540 "lose his modifications during and after his update."
541 msgstr ""
543 #. type: Content of: <book><appendix><sect1><sect2><sect3><para>
544 #: ../en/appA-svn.xml:312
545 msgid ""
546 "Mercurial encourages a commit-then-merge model instead. Bob commits his "
547 "changes locally before pulling changes from, or pushing them to, the server "
548 "that he shares with Alice. If Alice pushed her changes before Bob tries to "
549 "push his, he will not be able to push his changes until he pulls hers, merges "
550 "with them, and commits the result of the merge. If he makes a mistake during "
551 "the merge, he still has the option of reverting to the commit that recorded "
552 "his changes."
553 msgstr ""
555 #. type: Content of: <book><appendix><sect1><sect2><sect3><para>
556 #: ../en/appA-svn.xml:321
557 msgid ""
558 "It is worth emphasizing that these are the common ways of working with these "
559 "tools. Subversion supports a safer work-in-your-own-branch model, but it is "
560 "cumbersome enough in practice to not be widely used. Mercurial can support "
561 "the less safe mode of allowing changes to be pulled in and merged on top of "
562 "uncommitted edits, but this is considered highly unusual."
563 msgstr ""
565 #. type: Content of: <book><appendix><sect1><sect2><sect3><title>
566 #: ../en/appA-svn.xml:331
567 msgid "Published vs local changes"
568 msgstr "已发布的修改与本地修改"
570 #. type: Content of: <book><appendix><sect1><sect2><sect3><para>
571 #: ../en/appA-svn.xml:333
572 msgid ""
573 "A Subversion <command>svn commit</command> command immediately publishes "
574 "changes to a server, where they can be seen by everyone who has read access."
575 msgstr ""
577 #. type: Content of: <book><appendix><sect1><sect2><sect3><para>
578 #: ../en/appA-svn.xml:337
579 msgid ""
580 "With Mercurial, commits are always local, and must be published via a "
581 "<command>hg push</command> command afterwards."
582 msgstr ""
584 #. type: Content of: <book><appendix><sect1><sect2><sect3><para>
585 #: ../en/appA-svn.xml:341
586 msgid ""
587 "Each approach has its advantages and disadvantages. The Subversion model "
588 "means that changes are published, and hence reviewable and usable, "
589 "immediately. On the other hand, this means that a user must have commit "
590 "access to a repository in order to use the software in a normal way, and "
591 "commit access is not lightly given out by most open source projects."
592 msgstr ""
594 #. type: Content of: <book><appendix><sect1><sect2><sect3><para>
595 #: ../en/appA-svn.xml:349
596 msgid ""
597 "The Mercurial approach allows anyone who can clone a repository to commit "
598 "changes without the need for someone else's permission, and they can then "
599 "publish their changes and continue to participate however they see fit. The "
600 "distinction between committing and pushing does open up the possibility of "
601 "someone committing changes to their laptop and walking away for a few days "
602 "having forgotten to push them, which in rare cases might leave collaborators "
603 "temporarily stuck."
604 msgstr ""
606 #. type: Content of: <book><appendix><sect1><sect2><title>
607 #: ../en/appA-svn.xml:362
608 msgid "Quick reference"
609 msgstr "快速参考"
611 #. type: Content of: <book><appendix><sect1><sect2><table><title>
612 #: ../en/appA-svn.xml:365
613 msgid "Subversion commands and Mercurial equivalents"
614 msgstr "Subversion 命令与 Mercurial 对照表"
616 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><thead><row><entry>
617 #: ../en/appA-svn.xml:371
618 msgid "Notes"
619 msgstr "备注"
621 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
622 #: ../en/appA-svn.xml:376
623 msgid "<command>svn add</command>"
624 msgstr "<command>svn add</command>"
626 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
627 #: ../en/appA-svn.xml:377
628 msgid "<command>hg add</command>"
629 msgstr "<command>hg add</command>"
631 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
632 #: ../en/appA-svn.xml:381
633 msgid "<command>svn blame</command>"
634 msgstr "<command>svn blame</command>"
636 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
637 #: ../en/appA-svn.xml:382
638 msgid "<command>hg annotate</command>"
639 msgstr "<command>hg annotate</command>"
641 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
642 #: ../en/appA-svn.xml:386
643 msgid "<command>svn cat</command>"
644 msgstr "<command>svn cat</command>"
646 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
647 #: ../en/appA-svn.xml:387
648 msgid "<command>hg cat</command>"
649 msgstr "<command>hg cat</command>"
651 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
652 #: ../en/appA-svn.xml:391
653 msgid "<command>svn checkout</command>"
654 msgstr "<command>svn checkout</command>"
656 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
657 #: ../en/appA-svn.xml:392 ../en/appA-svn.xml:409
658 msgid "<command>hg clone</command>"
659 msgstr "<command>hg clone</command>"
661 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
662 #: ../en/appA-svn.xml:396
663 msgid "<command>svn cleanup</command>"
664 msgstr "<command>svn cleanup</command>"
666 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
667 #: ../en/appA-svn.xml:397 ../en/appA-svn.xml:472
668 msgid "n/a"
669 msgstr "n/a"
671 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
672 #: ../en/appA-svn.xml:398
673 msgid "No cleanup needed"
674 msgstr "不需要清理"
676 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
677 #: ../en/appA-svn.xml:401
678 msgid "<command>svn commit</command>"
679 msgstr "<command>svn commit</command>"
681 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
682 #: ../en/appA-svn.xml:402
683 msgid "<command>hg commit</command>; <command>hg push</command>"
684 msgstr "<command>hg commit</command>; <command>hg push</command>"
686 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
687 #: ../en/appA-svn.xml:404
688 msgid "<command>hg push</command> publishes after commit"
689 msgstr "提交后使用 <command>hg push</command> 发布"
691 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
692 #: ../en/appA-svn.xml:408 ../en/appA-svn.xml:413
693 msgid "<command>svn copy</command>"
694 msgstr "<command>svn copy</command>"
696 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
697 #: ../en/appA-svn.xml:410
698 msgid "To create a new branch"
699 msgstr "创建新补丁"
701 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
702 #: ../en/appA-svn.xml:414
703 msgid "<command>hg copy</command>"
704 msgstr "<command>hg copy</command>"
706 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
707 #: ../en/appA-svn.xml:415
708 msgid "To copy files or directories"
709 msgstr "复制文件或目录"
711 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
712 #: ../en/appA-svn.xml:418
713 msgid "<command>svn delete</command> (<command>svn remove</command>)"
714 msgstr "<command>svn delete</command> (<command>svn remove</command>)"
716 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
717 #: ../en/appA-svn.xml:420
718 msgid "<command>hg remove</command>"
719 msgstr "<command>hg remove</command>"
721 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
722 #: ../en/appA-svn.xml:424
723 msgid "<command>svn diff</command>"
724 msgstr "<command>svn diff</command>"
726 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
727 #: ../en/appA-svn.xml:425
728 msgid "<command>hg diff</command>"
729 msgstr "<command>hg diff</command>"
731 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
732 #: ../en/appA-svn.xml:429
733 msgid "<command>svn export</command>"
734 msgstr "<command>svn export</command>"
736 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
737 #: ../en/appA-svn.xml:430
738 msgid "<command>hg archive</command>"
739 msgstr "<command>hg archive</command>"
741 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
742 #: ../en/appA-svn.xml:434
743 msgid "<command>svn help</command>"
744 msgstr "<command>svn help</command>"
746 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
747 #: ../en/appA-svn.xml:435
748 msgid "<command>hg help</command>"
749 msgstr "<command>hg help</command>"
751 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
752 #: ../en/appA-svn.xml:439
753 msgid "<command>svn import</command>"
754 msgstr "<command>svn import</command>"
756 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
757 #: ../en/appA-svn.xml:440
758 msgid "<command>hg addremove</command>; <command>hg commit</command>"
759 msgstr "<command>hg addremove</command>; <command>hg commit</command>"
761 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
762 #: ../en/appA-svn.xml:445 ../en/appA-svn.xml:450
763 msgid "<command>svn info</command>"
764 msgstr "<command>svn info</command>"
766 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
767 #: ../en/appA-svn.xml:446
768 msgid "<command>hg parents</command>"
769 msgstr "<command>hg parents</command>"
771 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
772 #: ../en/appA-svn.xml:447
773 msgid "Shows what revision is checked out"
774 msgstr "显示检出的版本信息"
776 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
777 #: ../en/appA-svn.xml:451
778 msgid "<command>hg showconfig paths.parent</command>"
779 msgstr "<command>hg showconfig paths.parent</command>"
781 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
782 #: ../en/appA-svn.xml:453
783 msgid "Shows what URL is checked out"
784 msgstr "显示检出的 URL"
786 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
787 #: ../en/appA-svn.xml:456
788 msgid "<command>svn list</command>"
789 msgstr "<command>svn list</command>"
791 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
792 #: ../en/appA-svn.xml:457
793 msgid "<command>hg manifest</command>"
794 msgstr "<command>hg manifest</command>"
796 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
797 #: ../en/appA-svn.xml:461
798 msgid "<command>svn log</command>"
799 msgstr "<command>svn log</command>"
801 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
802 #: ../en/appA-svn.xml:462
803 msgid "<command>hg log</command>"
804 msgstr "<command>hg log</command>"
806 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
807 #: ../en/appA-svn.xml:466
808 msgid "<command>svn merge</command>"
809 msgstr ""
811 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
812 #: ../en/appA-svn.xml:467
813 msgid "<command>hg merge</command>"
814 msgstr "<command>hg merge</command>"
816 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
817 #: ../en/appA-svn.xml:471
818 msgid "<command>svn mkdir</command>"
819 msgstr "<command>svn mkdir</command>"
821 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
822 #: ../en/appA-svn.xml:473
823 msgid "Mercurial does not track directories"
824 msgstr "Mercurial 不跟踪目录"
826 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
827 #: ../en/appA-svn.xml:476
828 msgid "<command>svn move</command> (<command>svn rename</command>)"
829 msgstr "<command>svn move</command> (<command>svn rename</command>)"
831 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
832 #: ../en/appA-svn.xml:478
833 msgid "<command>hg rename</command>"
834 msgstr "<command>hg rename</command>"
836 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
837 #: ../en/appA-svn.xml:482
838 msgid "<command>svn resolved</command>"
839 msgstr "<command>svn resolved</command>"
841 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
842 #: ../en/appA-svn.xml:483
843 msgid "<command>hg resolve -m</command>"
844 msgstr "<command>hg resolve -m</command>"
846 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
847 #: ../en/appA-svn.xml:487
848 msgid "<command>svn revert</command>"
849 msgstr "<command>svn revert</command>"
851 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
852 #: ../en/appA-svn.xml:488
853 msgid "<command>hg revert</command>"
854 msgstr "<command>hg revert</command>"
856 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
857 #: ../en/appA-svn.xml:492
858 msgid "<command>svn status</command>"
859 msgstr "<command>svn status</command>"
861 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
862 #: ../en/appA-svn.xml:493
863 msgid "<command>hg status</command>"
864 msgstr "<command>hg status</command>"
866 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
867 #: ../en/appA-svn.xml:497
868 msgid "<command>svn update</command>"
869 msgstr "<command>svn update</command>"
871 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
872 #: ../en/appA-svn.xml:498
873 msgid "<command>hg pull -u</command>"
874 msgstr "<command>hg pull -u</command>"
876 #. type: Content of: <book><appendix><sect1><title>
877 #: ../en/appA-svn.xml:508
878 msgid "Useful tips for newcomers"
879 msgstr "新手需要了解的技巧"
881 #. type: Content of: <book><appendix><sect1><para>
882 #: ../en/appA-svn.xml:510
883 msgid ""
884 "Under some revision control systems, printing a diff for a single committed "
885 "revision can be painful. For instance, with Subversion, to see what changed "
886 "in revision 104654, you must type <command>svn diff -r104653:104654</"
887 "command>. Mercurial eliminates the need to type the revision ID twice in this "
888 "common case. For a plain diff, <command>hg export 104654</command>. For a log "
889 "message followed by a diff, <command>hg log -r104654 -p</command>."
890 msgstr ""
892 #. type: Content of: <book><appendix><sect1><para>
893 #: ../en/appA-svn.xml:519
894 msgid ""
895 "When you run <command>hg status</command> without any arguments, it prints "
896 "the status of the entire tree, with paths relative to the root of the "
897 "repository. This makes it tricky to copy a file name from the output of "
898 "<command>hg status</command> into the command line. If you supply a file or "
899 "directory name to <command>hg status</command>, it will print paths relative "
900 "to your current location instead. So to get tree-wide status from "
901 "<command>hg status</command>, with paths that are relative to your current "
902 "directory and not the root of the repository, feed the output of <command>hg "
903 "root</command> into <command>hg status</command>. You can easily do this as "
904 "follows on a Unix-like system:"
905 msgstr ""
907 #. type: Content of: <book><appendix><sect1><screen><userinput>
908 #: ../en/appA-svn.xml:532
909 msgid "hg status `hg root`"
910 msgstr "hg status `hg root`"
912 #. type: Content of: <book><appendix><title>
913 #: ../en/appB-mq-ref.xml:5
914 msgid "Mercurial Queues reference"
915 msgstr "Mercurial 队列参考"
917 #. type: Content of: <book><appendix><sect1><title>
918 #: ../en/appB-mq-ref.xml:8
919 msgid "MQ command reference"
920 msgstr "MQ 命令参考"
922 #. type: Content of: <book><appendix><sect1><para>
923 #: ../en/appB-mq-ref.xml:10
924 msgid ""
925 "For an overview of the commands provided by MQ, use the command <command role="
926 "\"hg-cmd\">hg help mq</command>."
927 msgstr ""
929 #. type: Content of: <book><appendix><sect1><sect2><title>
930 #: ../en/appB-mq-ref.xml:14
931 msgid ""
932 "<command role=\"hg-ext-mq\">qapplied</command>&emdash;print applied patches"
933 msgstr "<command role=\"hg-ext-mq\">qapplied</command>—显示已应用的补丁"
935 #. type: Content of: <book><appendix><sect1><sect2><para>
936 #: ../en/appB-mq-ref.xml:17
937 msgid ""
938 "The <command role=\"hg-ext-mq\">qapplied</command> command prints the current "
939 "stack of applied patches. Patches are printed in oldest-to-newest order, so "
940 "the last patch in the list is the <quote>top</quote> patch."
941 msgstr ""
943 #. type: Content of: <book><appendix><sect1><sect2><title>
944 #: ../en/appB-mq-ref.xml:24
945 msgid ""
946 "<command role=\"hg-ext-mq\">qcommit</command>&emdash;commit changes in the "
947 "queue repository"
948 msgstr "<command role=\"hg-ext-mq\">qcommit</command>—提交队列中的修改"
950 #. type: Content of: <book><appendix><sect1><sect2><para>
951 #: ../en/appB-mq-ref.xml:27
952 msgid ""
953 "The <command role=\"hg-ext-mq\">qcommit</command> command commits any "
954 "outstanding changes in the <filename role=\"special\" class=\"directory\">.hg/"
955 "patches</filename> repository. This command only works if the <filename role="
956 "\"special\" class=\"directory\">.hg/patches</filename> directory is a "
957 "repository, i.e. you created the directory using <command role=\"hg-cmd\">hg "
958 "qinit <option role=\"hg-ext-mq-cmd-qinit-opt\">-c</option></command> or ran "
959 "<command role=\"hg-cmd\">hg init</command> in the directory after running "
960 "<command role=\"hg-ext-mq\">qinit</command>."
961 msgstr ""
963 #. type: Content of: <book><appendix><sect1><sect2><para>
964 #: ../en/appB-mq-ref.xml:39
965 msgid ""
966 "This command is shorthand for <command role=\"hg-cmd\">hg commit --cwd .hg/"
967 "patches</command>."
968 msgstr ""
970 #. type: Content of: <book><appendix><sect1><sect2><title>
971 #: ../en/appB-mq-ref.xml:43
972 msgid ""
973 "<command role=\"hg-ext-mq\">qdelete</command>&emdash;delete a patch from the "
974 "<filename role=\"special\">series</filename> file"
975 msgstr ""
976 "<command role=\"hg-ext-mq\">qdelete</command>—从文件 <filename role=\"special"
977 "\">series</filename> 中删除补丁"
979 #. type: Content of: <book><appendix><sect1><sect2><para>
980 #: ../en/appB-mq-ref.xml:48
981 msgid ""
982 "The <command role=\"hg-ext-mq\">qdelete</command> command removes the entry "
983 "for a patch from the <filename role=\"special\">series</filename> file in the "
984 "<filename role=\"special\" class=\"directory\">.hg/patches</filename> "
985 "directory. It does not pop the patch if the patch is already applied. By "
986 "default, it does not delete the patch file; use the <option role=\"hg-ext-mq-"
987 "cmd-qdel-opt\">-f</option> option to do that."
988 msgstr ""
990 #. type: Content of: <book><appendix><sect1><sect2><para>
991 #: ../en/appB-mq-ref.xml:57 ../en/appB-mq-ref.xml:109 ../en/appB-mq-ref.xml:167
992 #: ../en/appB-mq-ref.xml:207 ../en/appB-mq-ref.xml:274
993 #: ../en/appB-mq-ref.xml:345 ../en/appB-mq-ref.xml:414
994 #: ../en/appB-mq-ref.xml:492
995 msgid "Options:"
996 msgstr "选项:"
998 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
999 #: ../en/appB-mq-ref.xml:59
1000 msgid ""
1001 "<option role=\"hg-ext-mq-cmd-qdel-opt\">-f</option>: Delete the patch file."
1002 msgstr ""
1004 #. type: Content of: <book><appendix><sect1><sect2><title>
1005 #: ../en/appB-mq-ref.xml:66
1006 msgid ""
1007 "<command role=\"hg-ext-mq\">qdiff</command>&emdash;print a diff of the "
1008 "topmost applied patch"
1009 msgstr "<command role=\"hg-ext-mq\">qdiff</command>—显示最新应用补丁的差异"
1011 #. type: Content of: <book><appendix><sect1><sect2><para>
1012 #: ../en/appB-mq-ref.xml:69
1013 msgid ""
1014 "The <command role=\"hg-ext-mq\">qdiff</command> command prints a diff of the "
1015 "topmost applied patch. It is equivalent to <command role=\"hg-cmd\">hg diff -"
1016 "r-2:-1</command>."
1017 msgstr ""
1019 #. type: Content of: <book><appendix><sect1><sect2><title>
1020 #: ../en/appB-mq-ref.xml:75
1021 msgid ""
1022 "<command role=\"hg-ext-mq\">qfold</command>&emdash;move applied patches into "
1023 "repository history"
1024 msgstr ""
1025 "<command role=\"hg-ext-mq\">qfold</command>&emdash;将已应用的补丁提交到版本库"
1027 #. type: Content of: <book><appendix><sect1><sect2><para>
1028 #: ../en/appB-mq-ref.xml:78
1029 msgid ""
1030 "The <command>hg qfinish</command> command converts the specified applied "
1031 "patches into permanent changes by moving them out of MQ's control so that "
1032 "they will be treated as normal repository history."
1033 msgstr ""
1035 #. type: Content of: <book><appendix><sect1><sect2><title>
1036 #: ../en/appB-mq-ref.xml:85
1037 msgid ""
1038 "<command role=\"hg-ext-mq\">qfold</command>&emdash;merge (<quote>fold</"
1039 "quote>) several patches into one"
1040 msgstr ""
1041 "<command role=\"hg-ext-mq\">qfold</command>—将多个补丁合并(<quote>折叠</"
1042 "quote>)成一个"
1044 #. type: Content of: <book><appendix><sect1><sect2><para>
1045 #: ../en/appB-mq-ref.xml:88
1046 msgid ""
1047 "The <command role=\"hg-ext-mq\">qfold</command> command merges multiple "
1048 "patches into the topmost applied patch, so that the topmost applied patch "
1049 "makes the union of all of the changes in the patches in question."
1050 msgstr ""
1052 #. type: Content of: <book><appendix><sect1><sect2><para>
1053 #: ../en/appB-mq-ref.xml:93
1054 msgid ""
1055 "The patches to fold must not be applied; <command role=\"hg-ext-mq\">qfold</"
1056 "command> will exit with an error if any is. The order in which patches are "
1057 "folded is significant; <command role=\"hg-cmd\">hg qfold a b</command> means "
1058 "<quote>apply the current topmost patch, followed by <literal>a</literal>, "
1059 "followed by <literal>b</literal></quote>."
1060 msgstr ""
1062 #. type: Content of: <book><appendix><sect1><sect2><para>
1063 #: ../en/appB-mq-ref.xml:101
1064 msgid ""
1065 "The comments from the folded patches are appended to the comments of the "
1066 "destination patch, with each block of comments separated by three asterisk "
1067 "(<quote><literal>*</literal></quote>) characters. Use the <option role=\"hg-"
1068 "ext-mq-cmd-qfold-opt\">-e</option> option to edit the commit message for the "
1069 "combined patch/changeset after the folding has completed."
1070 msgstr ""
1072 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1073 #: ../en/appB-mq-ref.xml:111
1074 msgid ""
1075 "<option role=\"hg-ext-mq-cmd-qfold-opt\">-e</option>: Edit the commit message "
1076 "and patch description for the newly folded patch."
1077 msgstr ""
1078 "<option role=\"hg-ext-mq-cmd-qfold-opt\">-e</option>:为新创建的补丁编辑提交信"
1079 "息和补丁说明。"
1081 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1082 #: ../en/appB-mq-ref.xml:116
1083 msgid ""
1084 "<option role=\"hg-ext-mq-cmd-qfold-opt\">-l</option>: Use the contents of the "
1085 "given file as the new commit message and patch description for the folded "
1086 "patch."
1087 msgstr ""
1088 "<option role=\"hg-ext-mq-cmd-qfold-opt\">-l</option>: 使用给定文件的内容作为创"
1089 "建补丁新的提交信息和补丁说明。"
1091 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1092 #: ../en/appB-mq-ref.xml:121
1093 msgid ""
1094 "<option role=\"hg-ext-mq-cmd-qfold-opt\">-m</option>: Use the given text as "
1095 "the new commit message and patch description for the folded patch."
1096 msgstr ""
1098 #. type: Content of: <book><appendix><sect1><sect2><title>
1099 #: ../en/appB-mq-ref.xml:129
1100 msgid ""
1101 "<command role=\"hg-ext-mq\">qheader</command>&emdash;display the header/"
1102 "description of a patch"
1103 msgstr "<command role=\"hg-ext-mq\">qheader</command>—显示补丁头部描述"
1105 #. type: Content of: <book><appendix><sect1><sect2><para>
1106 #: ../en/appB-mq-ref.xml:133
1107 msgid ""
1108 "The <command role=\"hg-ext-mq\">qheader</command> command prints the header, "
1109 "or description, of a patch. By default, it prints the header of the topmost "
1110 "applied patch. Given an argument, it prints the header of the named patch."
1111 msgstr ""
1113 #. type: Content of: <book><appendix><sect1><sect2><title>
1114 #: ../en/appB-mq-ref.xml:140
1115 msgid ""
1116 "<command role=\"hg-ext-mq\">qimport</command>&emdash;import a third-party "
1117 "patch into the queue"
1118 msgstr "<command role=\"hg-ext-mq\">qimport</command>—将第三方补丁导入队列"
1120 #. type: Content of: <book><appendix><sect1><sect2><para>
1121 #: ../en/appB-mq-ref.xml:143
1122 msgid ""
1123 "The <command role=\"hg-ext-mq\">qimport</command> command adds an entry for "
1124 "an external patch to the <filename role=\"special\">series</filename> file, "
1125 "and copies the patch into the <filename role=\"special\" class=\"directory\">."
1126 "hg/patches</filename> directory. It adds the entry immediately after the "
1127 "topmost applied patch, but does not push the patch."
1128 msgstr ""
1130 #. type: Content of: <book><appendix><sect1><sect2><para>
1131 #: ../en/appB-mq-ref.xml:151
1132 msgid ""
1133 "If the <filename role=\"special\" class=\"directory\">.hg/patches</filename> "
1134 "directory is a repository, <command role=\"hg-ext-mq\">qimport</command> "
1135 "automatically does an <command role=\"hg-cmd\">hg add</command> of the "
1136 "imported patch."
1137 msgstr ""
1139 #. type: Content of: <book><appendix><sect1><sect2><title>
1140 #: ../en/appB-mq-ref.xml:159
1141 msgid ""
1142 "<command role=\"hg-ext-mq\">qinit</command>&emdash;prepare a repository to "
1143 "work with MQ"
1144 msgstr "<command role=\"hg-ext-mq\">qinit</command>—为使用 MQ 配置版本库"
1146 #. type: Content of: <book><appendix><sect1><sect2><para>
1147 #: ../en/appB-mq-ref.xml:162
1148 msgid ""
1149 "The <command role=\"hg-ext-mq\">qinit</command> command prepares a repository "
1150 "to work with MQ. It creates a directory called <filename role=\"special\" "
1151 "class=\"directory\">.hg/patches</filename>."
1152 msgstr ""
1154 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1155 #: ../en/appB-mq-ref.xml:169
1156 msgid ""
1157 "<option role=\"hg-ext-mq-cmd-qinit-opt\">-c</option>: Create <filename role="
1158 "\"special\" class=\"directory\">.hg/patches</filename> as a repository in its "
1159 "own right. Also creates a <filename role=\"special\">.hgignore</filename> "
1160 "file that will ignore the <filename role=\"special\">status</filename> file."
1161 msgstr ""
1163 #. type: Content of: <book><appendix><sect1><sect2><para>
1164 #: ../en/appB-mq-ref.xml:179
1165 msgid ""
1166 "When the <filename role=\"special\" class=\"directory\">.hg/patches</"
1167 "filename> directory is a repository, the <command role=\"hg-ext-mq\">qimport</"
1168 "command> and <command role=\"hg-ext-mq\">qnew</command> commands "
1169 "automatically <command role=\"hg-cmd\">hg add</command> new patches."
1170 msgstr ""
1172 #. type: Content of: <book><appendix><sect1><sect2><title>
1173 #: ../en/appB-mq-ref.xml:188
1174 msgid "<command role=\"hg-ext-mq\">qnew</command>&emdash;create a new patch"
1175 msgstr "<command role=\"hg-ext-mq\">qnew</command>—创建新补丁"
1177 #. type: Content of: <book><appendix><sect1><sect2><para>
1178 #: ../en/appB-mq-ref.xml:191
1179 msgid ""
1180 "The <command role=\"hg-ext-mq\">qnew</command> command creates a new patch. "
1181 "It takes one mandatory argument, the name to use for the patch file. The "
1182 "newly created patch is created empty by default. It is added to the "
1183 "<filename role=\"special\">series</filename> file after the current topmost "
1184 "applied patch, and is immediately pushed on top of that patch."
1185 msgstr ""
1187 #. type: Content of: <book><appendix><sect1><sect2><para>
1188 #: ../en/appB-mq-ref.xml:199
1189 msgid ""
1190 "If <command role=\"hg-ext-mq\">qnew</command> finds modified files in the "
1191 "working directory, it will refuse to create a new patch unless the <option "
1192 "role=\"hg-ext-mq-cmd-qnew-opt\">-f</option> option is used (see below). This "
1193 "behavior allows you to <command role=\"hg-ext-mq\">qrefresh</command> your "
1194 "topmost applied patch before you apply a new patch on top of it."
1195 msgstr ""
1197 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1198 #: ../en/appB-mq-ref.xml:209
1199 msgid ""
1200 "<option role=\"hg-ext-mq-cmd-qnew-opt\">-f</option>: Create a new patch if "
1201 "the contents of the working directory are modified. Any outstanding "
1202 "modifications are added to the newly created patch, so after this command "
1203 "completes, the working directory will no longer be modified."
1204 msgstr ""
1206 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1207 #: ../en/appB-mq-ref.xml:216
1208 msgid ""
1209 "<option role=\"hg-ext-mq-cmd-qnew-opt\">-m</option>: Use the given text as "
1210 "the commit message. This text will be stored at the beginning of the patch "
1211 "file, before the patch data."
1212 msgstr ""
1214 #. type: Content of: <book><appendix><sect1><sect2><title>
1215 #: ../en/appB-mq-ref.xml:225
1216 msgid ""
1217 "<command role=\"hg-ext-mq\">qnext</command>&emdash;print the name of the next "
1218 "patch"
1219 msgstr "<command role=\"hg-ext-mq\">qnext</command>—显示下个补丁的名称"
1221 #. type: Content of: <book><appendix><sect1><sect2><para>
1222 #: ../en/appB-mq-ref.xml:228
1223 msgid ""
1224 "The <command role=\"hg-ext-mq\">qnext</command> command prints the name name "
1225 "of the next patch in the <filename role=\"special\">series</filename> file "
1226 "after the topmost applied patch. This patch will become the topmost applied "
1227 "patch if you run <command role=\"hg-ext-mq\">qpush</command>."
1228 msgstr ""
1230 #. type: Content of: <book><appendix><sect1><sect2><title>
1231 #: ../en/appB-mq-ref.xml:237
1232 msgid ""
1233 "<command role=\"hg-ext-mq\">qpop</command>&emdash;pop patches off the stack"
1234 msgstr "<command role=\"hg-ext-mq\">qpop</command>—删除堆栈顶部的补丁"
1236 #. type: Content of: <book><appendix><sect1><sect2><para>
1237 #: ../en/appB-mq-ref.xml:240
1238 msgid ""
1239 "The <command role=\"hg-ext-mq\">qpop</command> command removes applied "
1240 "patches from the top of the stack of applied patches. By default, it removes "
1241 "only one patch."
1242 msgstr ""
1244 #. type: Content of: <book><appendix><sect1><sect2><para>
1245 #: ../en/appB-mq-ref.xml:244
1246 msgid ""
1247 "This command removes the changesets that represent the popped patches from "
1248 "the repository, and updates the working directory to undo the effects of the "
1249 "patches."
1250 msgstr ""
1252 #. type: Content of: <book><appendix><sect1><sect2><para>
1253 #: ../en/appB-mq-ref.xml:248
1254 msgid ""
1255 "This command takes an optional argument, which it uses as the name or index "
1256 "of the patch to pop to. If given a name, it will pop patches until the named "
1257 "patch is the topmost applied patch. If given a number, <command role=\"hg-"
1258 "ext-mq\">qpop</command> treats the number as an index into the entries in the "
1259 "series file, counting from zero (empty lines and lines containing only "
1260 "comments do not count). It pops patches until the patch identified by the "
1261 "given index is the topmost applied patch."
1262 msgstr ""
1264 #. type: Content of: <book><appendix><sect1><sect2><para>
1265 #: ../en/appB-mq-ref.xml:258
1266 msgid ""
1267 "The <command role=\"hg-ext-mq\">qpop</command> command does not read or write "
1268 "patches or the <filename role=\"special\">series</filename> file. It is thus "
1269 "safe to <command role=\"hg-ext-mq\">qpop</command> a patch that you have "
1270 "removed from the <filename role=\"special\">series</filename> file, or a "
1271 "patch that you have renamed or deleted entirely. In the latter two cases, "
1272 "use the name of the patch as it was when you applied it."
1273 msgstr ""
1275 #. type: Content of: <book><appendix><sect1><sect2><para>
1276 #: ../en/appB-mq-ref.xml:267
1277 msgid ""
1278 "By default, the <command role=\"hg-ext-mq\">qpop</command> command will not "
1279 "pop any patches if the working directory has been modified. You can override "
1280 "this behavior using the <option role=\"hg-ext-mq-cmd-qpop-opt\">-f</option> "
1281 "option, which reverts all modifications in the working directory."
1282 msgstr ""
1284 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1285 #: ../en/appB-mq-ref.xml:276
1286 msgid ""
1287 "<option role=\"hg-ext-mq-cmd-qpop-opt\">-a</option>: Pop all applied "
1288 "patches. This returns the repository to its state before you applied any "
1289 "patches."
1290 msgstr ""
1292 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1293 #: ../en/appB-mq-ref.xml:281
1294 msgid ""
1295 "<option role=\"hg-ext-mq-cmd-qpop-opt\">-f</option>: Forcibly revert any "
1296 "modifications to the working directory when popping."
1297 msgstr ""
1299 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1300 #: ../en/appB-mq-ref.xml:286
1301 msgid ""
1302 "<option role=\"hg-ext-mq-cmd-qpop-opt\">-n</option>: Pop a patch from the "
1303 "named queue."
1304 msgstr ""
1306 #. type: Content of: <book><appendix><sect1><sect2><para>
1307 #: ../en/appB-mq-ref.xml:291
1308 msgid ""
1309 "The <command role=\"hg-ext-mq\">qpop</command> command removes one line from "
1310 "the end of the <filename role=\"special\">status</filename> file for each "
1311 "patch that it pops."
1312 msgstr ""
1314 #. type: Content of: <book><appendix><sect1><sect2><title>
1315 #: ../en/appB-mq-ref.xml:298
1316 msgid ""
1317 "<command role=\"hg-ext-mq\">qprev</command>&emdash;print the name of the "
1318 "previous patch"
1319 msgstr "<command role=\"hg-ext-mq\">qprev</command>—显示上个补丁的名称"
1321 #. type: Content of: <book><appendix><sect1><sect2><para>
1322 #: ../en/appB-mq-ref.xml:301
1323 msgid ""
1324 "The <command role=\"hg-ext-mq\">qprev</command> command prints the name of "
1325 "the patch in the <filename role=\"special\">series</filename> file that comes "
1326 "before the topmost applied patch. This will become the topmost applied patch "
1327 "if you run <command role=\"hg-ext-mq\">qpop</command>."
1328 msgstr ""
1330 #. type: Content of: <book><appendix><sect1><sect2><title>
1331 #: ../en/appB-mq-ref.xml:310
1332 msgid ""
1333 "<command role=\"hg-ext-mq\">qpush</command>&emdash;push patches onto the stack"
1334 msgstr "<command role=\"hg-ext-mq\">qpush</command>—增加补丁到堆栈"
1336 #. type: Content of: <book><appendix><sect1><sect2><para>
1337 #: ../en/appB-mq-ref.xml:313
1338 msgid ""
1339 "The <command role=\"hg-ext-mq\">qpush</command> command adds patches onto the "
1340 "applied stack. By default, it adds only one patch."
1341 msgstr ""
1343 #. type: Content of: <book><appendix><sect1><sect2><para>
1344 #: ../en/appB-mq-ref.xml:317
1345 msgid ""
1346 "This command creates a new changeset to represent each applied patch, and "
1347 "updates the working directory to apply the effects of the patches."
1348 msgstr ""
1350 #. type: Content of: <book><appendix><sect1><sect2><para>
1351 #: ../en/appB-mq-ref.xml:321
1352 msgid "The default data used when creating a changeset are as follows:"
1353 msgstr ""
1355 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1356 #: ../en/appB-mq-ref.xml:324
1357 msgid ""
1358 "The commit date and time zone are the current date and time zone. Because "
1359 "these data are used to compute the identity of a changeset, this means that "
1360 "if you <command role=\"hg-ext-mq\">qpop</command> a patch and <command role="
1361 "\"hg-ext-mq\">qpush</command> it again, the changeset that you push will have "
1362 "a different identity than the changeset you popped."
1363 msgstr ""
1365 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1366 #: ../en/appB-mq-ref.xml:332
1367 msgid ""
1368 "The author is the same as the default used by the <command role=\"hg-cmd\">hg "
1369 "commit</command> command."
1370 msgstr ""
1372 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1373 #: ../en/appB-mq-ref.xml:336
1374 msgid ""
1375 "The commit message is any text from the patch file that comes before the "
1376 "first diff header. If there is no such text, a default commit message is "
1377 "used that identifies the name of the patch."
1378 msgstr ""
1380 #. type: Content of: <book><appendix><sect1><sect2><para>
1381 #: ../en/appB-mq-ref.xml:341
1382 msgid ""
1383 "If a patch contains a Mercurial patch header, the information in the patch "
1384 "header overrides these defaults."
1385 msgstr ""
1387 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1388 #: ../en/appB-mq-ref.xml:347
1389 msgid ""
1390 "<option role=\"hg-ext-mq-cmd-qpush-opt\">-a</option>: Push all unapplied "
1391 "patches from the <filename role=\"special\">series</filename> file until "
1392 "there are none left to push."
1393 msgstr ""
1395 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1396 #: ../en/appB-mq-ref.xml:353
1397 msgid ""
1398 "<option role=\"hg-ext-mq-cmd-qpush-opt\">-l</option>: Add the name of the "
1399 "patch to the end of the commit message."
1400 msgstr ""
1402 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1403 #: ../en/appB-mq-ref.xml:357
1404 msgid ""
1405 "<option role=\"hg-ext-mq-cmd-qpush-opt\">-m</option>: If a patch fails to "
1406 "apply cleanly, use the entry for the patch in another saved queue to compute "
1407 "the parameters for a three-way merge, and perform a three-way merge using the "
1408 "normal Mercurial merge machinery. Use the resolution of the merge as the new "
1409 "patch content."
1410 msgstr ""
1412 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1413 #: ../en/appB-mq-ref.xml:365
1414 msgid ""
1415 "<option role=\"hg-ext-mq-cmd-qpush-opt\">-n</option>: Use the named queue if "
1416 "merging while pushing."
1417 msgstr ""
1419 #. type: Content of: <book><appendix><sect1><sect2><para>
1420 #: ../en/appB-mq-ref.xml:370
1421 msgid ""
1422 "The <command role=\"hg-ext-mq\">qpush</command> command reads, but does not "
1423 "modify, the <filename role=\"special\">series</filename> file. It appends "
1424 "one line to the <command role=\"hg-cmd\">hg status</command> file for each "
1425 "patch that it pushes."
1426 msgstr ""
1428 #. type: Content of: <book><appendix><sect1><sect2><title>
1429 #: ../en/appB-mq-ref.xml:378
1430 msgid ""
1431 "<command role=\"hg-ext-mq\">qrefresh</command>&emdash;update the topmost "
1432 "applied patch"
1433 msgstr "<command role=\"hg-ext-mq\">qrefresh</command>—更新最新的补丁"
1435 #. type: Content of: <book><appendix><sect1><sect2><para>
1436 #: ../en/appB-mq-ref.xml:382
1437 msgid ""
1438 "The <command role=\"hg-ext-mq\">qrefresh</command> command updates the "
1439 "topmost applied patch. It modifies the patch, removes the old changeset that "
1440 "represented the patch, and creates a new changeset to represent the modified "
1441 "patch."
1442 msgstr ""
1444 #. type: Content of: <book><appendix><sect1><sect2><para>
1445 #: ../en/appB-mq-ref.xml:388
1446 msgid ""
1447 "The <command role=\"hg-ext-mq\">qrefresh</command> command looks for the "
1448 "following modifications:"
1449 msgstr ""
1451 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1452 #: ../en/appB-mq-ref.xml:391
1453 msgid ""
1454 "Changes to the commit message, i.e. the text before the first diff header in "
1455 "the patch file, are reflected in the new changeset that represents the patch."
1456 msgstr ""
1458 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1459 #: ../en/appB-mq-ref.xml:396
1460 msgid ""
1461 "Modifications to tracked files in the working directory are added to the "
1462 "patch."
1463 msgstr ""
1465 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1466 #: ../en/appB-mq-ref.xml:399
1467 msgid ""
1468 "Changes to the files tracked using <command role=\"hg-cmd\">hg add</command>, "
1469 "<command role=\"hg-cmd\">hg copy</command>, <command role=\"hg-cmd\">hg "
1470 "remove</command>, or <command role=\"hg-cmd\">hg rename</command>. Added "
1471 "files and copy and rename destinations are added to the patch, while removed "
1472 "files and rename sources are removed."
1473 msgstr ""
1475 #. type: Content of: <book><appendix><sect1><sect2><para>
1476 #: ../en/appB-mq-ref.xml:408
1477 msgid ""
1478 "Even if <command role=\"hg-ext-mq\">qrefresh</command> detects no changes, it "
1479 "still recreates the changeset that represents the patch. This causes the "
1480 "identity of the changeset to differ from the previous changeset that "
1481 "identified the patch."
1482 msgstr ""
1484 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1485 #: ../en/appB-mq-ref.xml:416
1486 msgid ""
1487 "<option role=\"hg-ext-mq-cmd-qrefresh-opt\">-e</option>: Modify the commit "
1488 "and patch description, using the preferred text editor."
1489 msgstr ""
1491 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1492 #: ../en/appB-mq-ref.xml:421
1493 msgid ""
1494 "<option role=\"hg-ext-mq-cmd-qrefresh-opt\">-m</option>: Modify the commit "
1495 "message and patch description, using the given text."
1496 msgstr ""
1498 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1499 #: ../en/appB-mq-ref.xml:426
1500 msgid ""
1501 "<option role=\"hg-ext-mq-cmd-qrefresh-opt\">-l</option>: Modify the commit "
1502 "message and patch description, using text from the given file."
1503 msgstr ""
1505 #. type: Content of: <book><appendix><sect1><sect2><title>
1506 #: ../en/appB-mq-ref.xml:434
1507 msgid "<command role=\"hg-ext-mq\">qrename</command>&emdash;rename a patch"
1508 msgstr "<command role=\"hg-ext-mq\">qrename</command>—改名补丁"
1510 #. type: Content of: <book><appendix><sect1><sect2><para>
1511 #: ../en/appB-mq-ref.xml:437
1512 msgid ""
1513 "The <command role=\"hg-ext-mq\">qrename</command> command renames a patch, "
1514 "and changes the entry for the patch in the <filename role=\"special\">series</"
1515 "filename> file."
1516 msgstr ""
1518 #. type: Content of: <book><appendix><sect1><sect2><para>
1519 #: ../en/appB-mq-ref.xml:441
1520 msgid ""
1521 "With a single argument, <command role=\"hg-ext-mq\">qrename</command> renames "
1522 "the topmost applied patch. With two arguments, it renames its first argument "
1523 "to its second."
1524 msgstr ""
1526 #. type: Content of: <book><appendix><sect1><sect2><title>
1527 #: ../en/appB-mq-ref.xml:448
1528 msgid ""
1529 "<command role=\"hg-ext-mq\">qseries</command>&emdash;print the entire patch "
1530 "series"
1531 msgstr "<command role=\"hg-ext-mq\">qseries</command>—显示补丁序列"
1533 #. type: Content of: <book><appendix><sect1><sect2><para>
1534 #: ../en/appB-mq-ref.xml:451
1535 msgid ""
1536 "The <command role=\"hg-ext-mq\">qseries</command> command prints the entire "
1537 "patch series from the <filename role=\"special\">series</filename> file. It "
1538 "prints only patch names, not empty lines or comments. It prints in order "
1539 "from first to be applied to last."
1540 msgstr ""
1542 #. type: Content of: <book><appendix><sect1><sect2><title>
1543 #: ../en/appB-mq-ref.xml:459
1544 msgid ""
1545 "<command role=\"hg-ext-mq\">qtop</command>&emdash;print the name of the "
1546 "current patch"
1547 msgstr "<command role=\"hg-ext-mq\">qtop</command>—显示当前补丁的名称"
1549 #. type: Content of: <book><appendix><sect1><sect2><para>
1550 #: ../en/appB-mq-ref.xml:462
1551 msgid ""
1552 "The <command role=\"hg-ext-mq\">qtop</command> prints the name of the topmost "
1553 "currently applied patch."
1554 msgstr ""
1556 #. type: Content of: <book><appendix><sect1><sect2><title>
1557 #: ../en/appB-mq-ref.xml:467
1558 msgid ""
1559 "<command role=\"hg-ext-mq\">qunapplied</command>&emdash;print patches not yet "
1560 "applied"
1561 msgstr "<command role=\"hg-ext-mq\">qunapplied</command>—显示尚未应用的补丁"
1563 #. type: Content of: <book><appendix><sect1><sect2><para>
1564 #: ../en/appB-mq-ref.xml:471
1565 msgid ""
1566 "The <command role=\"hg-ext-mq\">qunapplied</command> command prints the names "
1567 "of patches from the <filename role=\"special\">series</filename> file that "
1568 "are not yet applied. It prints them in order from the next patch that will "
1569 "be pushed to the last."
1570 msgstr ""
1572 #. type: Content of: <book><appendix><sect1><sect2><title>
1573 #: ../en/appB-mq-ref.xml:479
1574 msgid ""
1575 "<command role=\"hg-cmd\">hg strip</command>&emdash;remove a revision and "
1576 "descendants"
1577 msgstr "<command role=\"hg-cmd\">hg strip</command>—删除一个版本及其后继"
1579 #. type: Content of: <book><appendix><sect1><sect2><para>
1580 #: ../en/appB-mq-ref.xml:482
1581 msgid ""
1582 "The <command role=\"hg-cmd\">hg strip</command> command removes a revision, "
1583 "and all of its descendants, from the repository. It undoes the effects of "
1584 "the removed revisions from the repository, and updates the working directory "
1585 "to the first parent of the removed revision."
1586 msgstr ""
1588 #. type: Content of: <book><appendix><sect1><sect2><para>
1589 #: ../en/appB-mq-ref.xml:488
1590 msgid ""
1591 "The <command role=\"hg-cmd\">hg strip</command> command saves a backup of the "
1592 "removed changesets in a bundle, so that they can be reapplied if removed in "
1593 "error."
1594 msgstr ""
1596 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1597 #: ../en/appB-mq-ref.xml:494
1598 msgid ""
1599 "<option role=\"hg-opt-strip\">-b</option>: Save unrelated changesets that are "
1600 "intermixed with the stripped changesets in the backup bundle."
1601 msgstr ""
1603 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1604 #: ../en/appB-mq-ref.xml:498
1605 msgid ""
1606 "<option role=\"hg-opt-strip\">-f</option>: If a branch has multiple heads, "
1607 "remove all heads."
1608 msgstr ""
1610 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1611 #: ../en/appB-mq-ref.xml:501
1612 msgid "<option role=\"hg-opt-strip\">-n</option>: Do not save a backup bundle."
1613 msgstr ""
1615 #. type: Content of: <book><appendix><sect1><title>
1616 #: ../en/appB-mq-ref.xml:508
1617 msgid "MQ file reference"
1618 msgstr "MQ 文件参考"
1620 #. type: Content of: <book><appendix><sect1><sect2><title>
1621 #: ../en/appB-mq-ref.xml:511
1622 msgid "The <filename role=\"special\">series</filename> file"
1623 msgstr "<filename role=\"special\">序列</filename>文件"
1625 #. type: Content of: <book><appendix><sect1><sect2><para>
1626 #: ../en/appB-mq-ref.xml:514
1627 msgid ""
1628 "The <filename role=\"special\">series</filename> file contains a list of the "
1629 "names of all patches that MQ can apply. It is represented as a list of "
1630 "names, with one name saved per line. Leading and trailing white space in "
1631 "each line are ignored."
1632 msgstr ""
1634 #. type: Content of: <book><appendix><sect1><sect2><para>
1635 #: ../en/appB-mq-ref.xml:520
1636 msgid ""
1637 "Lines may contain comments. A comment begins with the <quote><literal>#</"
1638 "literal></quote> character, and extends to the end of the line. Empty lines, "
1639 "and lines that contain only comments, are ignored."
1640 msgstr ""
1642 #. type: Content of: <book><appendix><sect1><sect2><para>
1643 #: ../en/appB-mq-ref.xml:525
1644 msgid ""
1645 "You will often need to edit the <filename role=\"special\">series</filename> "
1646 "file by hand, hence the support for comments and empty lines noted above. "
1647 "For example, you can comment out a patch temporarily, and <command role=\"hg-"
1648 "ext-mq\">qpush</command> will skip over that patch when applying patches. "
1649 "You can also change the order in which patches are applied by reordering "
1650 "their entries in the <filename role=\"special\">series</filename> file."
1651 msgstr ""
1653 #. type: Content of: <book><appendix><sect1><sect2><para>
1654 #: ../en/appB-mq-ref.xml:534
1655 msgid ""
1656 "Placing the <filename role=\"special\">series</filename> file under revision "
1657 "control is also supported; it is a good idea to place all of the patches that "
1658 "it refers to under revision control, as well. If you create a patch "
1659 "directory using the <option role=\"hg-ext-mq-cmd-qinit-opt\">-c</option> "
1660 "option to <command role=\"hg-ext-mq\">qinit</command>, this will be done for "
1661 "you automatically."
1662 msgstr ""
1664 #. type: Content of: <book><appendix><sect1><sect2><title>
1665 #: ../en/appB-mq-ref.xml:544
1666 msgid "The <filename role=\"special\">status</filename> file"
1667 msgstr "<filename role=\"special\">状态</filename>文件"
1669 #. type: Content of: <book><appendix><sect1><sect2><para>
1670 #: ../en/appB-mq-ref.xml:547
1671 msgid ""
1672 "The <filename role=\"special\">status</filename> file contains the names and "
1673 "changeset hashes of all patches that MQ currently has applied. Unlike the "
1674 "<filename role=\"special\">series</filename> file, this file is not intended "
1675 "for editing. You should not place this file under revision control, or "
1676 "modify it in any way. It is used by MQ strictly for internal book-keeping."
1677 msgstr ""
1679 #. type: Content of: <book><appendix><title>
1680 #: ../en/appC-srcinstall.xml:5
1681 msgid "Installing Mercurial from source"
1682 msgstr "从源代码安装 Mercurial"
1684 #. type: Content of: <book><appendix><sect1><title>
1685 #: ../en/appC-srcinstall.xml:8
1686 msgid "On a Unix-like system"
1687 msgstr "类 Unix 系统"
1689 #. type: Content of: <book><appendix><sect1><para>
1690 #: ../en/appC-srcinstall.xml:10
1691 msgid ""
1692 "If you are using a Unix-like system that has a sufficiently recent version of "
1693 "Python (2.3 or newer) available, it is easy to install Mercurial from source."
1694 msgstr ""
1695 "如果你使用类 Unix 系统,并且有足够新的 Python (2.3 更新),从源代码安装 "
1696 "Mercurial 就很容易了。"
1698 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1699 #: ../en/appC-srcinstall.xml:14
1700 msgid ""
1701 "Download a recent source tarball from <ulink url=\"http://www.selenic.com/"
1702 "mercurial/download\">http://www.selenic.com/mercurial/download</ulink>."
1703 msgstr ""
1704 "从 <ulink url=\"http://www.selenic.com/mercurial/download\">http://www."
1705 "selenic.com/mercurial/download</ulink> 下载最新的源代码。"
1707 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1708 #: ../en/appC-srcinstall.xml:17
1709 msgid "Unpack the tarball:"
1710 msgstr "解压:"
1712 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1713 #: ../en/appC-srcinstall.xml:20
1714 msgid ""
1715 "Go into the source directory and run the installer script. This will build "
1716 "Mercurial and install it in your home directory."
1717 msgstr "进入源代码目录,执行安装教本。这会构建 Mercurial,安装到你的家目录。"
1719 #. type: Content of: <book><appendix><sect1><para>
1720 #: ../en/appC-srcinstall.xml:27
1721 msgid ""
1722 "Once the install finishes, Mercurial will be in the <literal>bin</literal> "
1723 "subdirectory of your home directory. Don't forget to make sure that this "
1724 "directory is present in your shell's search path."
1725 msgstr ""
1726 "安装完成后,Mercurial 就位于家目录的 <literal>bin</literal> 子目录。不要忘记将"
1727 "这个目录加入到你的可执行文件搜索路径中。"
1729 #. type: Content of: <book><appendix><sect1><para>
1730 #: ../en/appC-srcinstall.xml:32
1731 msgid ""
1732 "You will probably need to set the <envar>PYTHONPATH</envar> environment "
1733 "variable so that the Mercurial executable can find the rest of the Mercurial "
1734 "packages. For example, on my laptop, I have set it to <literal>/home/bos/lib/"
1735 "python</literal>. The exact path that you will need to use depends on how "
1736 "Python was built for your system, but should be easy to figure out. If "
1737 "you're uncertain, look through the output of the installer script above, and "
1738 "see where the contents of the <literal>mercurial</literal> directory were "
1739 "installed to."
1740 msgstr ""
1741 "你可能需要设置环境变量 <envar>PYTHONPATH</envar>,以便 Mercurial 可执行文件能"
1742 "找到 Mercurial 包。例如,在我的笔记本电脑中,必须设置为 <literal>/home/bos/"
1743 "lib/python</literal>。你需要使用的路径依赖于 Python 的构建方式,这很容易找出"
1744 "来。如果你不确定,仔细察看上面的安装脚本输出,检查包含 <literal>mercurial</"
1745 "literal> 目录的内容的安装位置。"
1747 #. type: Content of: <book><appendix><sect1><title>
1748 #: ../en/appC-srcinstall.xml:44
1749 msgid "On Windows"
1750 msgstr "Windows 系统"
1752 #. type: Content of: <book><appendix><sect1><para>
1753 #: ../en/appC-srcinstall.xml:46
1754 msgid ""
1755 "Building and installing Mercurial on Windows requires a variety of tools, a "
1756 "fair amount of technical knowledge, and considerable patience. I very much "
1757 "<emphasis>do not recommend</emphasis> this route if you are a <quote>casual "
1758 "user</quote>. Unless you intend to hack on Mercurial, I strongly suggest "
1759 "that you use a binary package instead."
1760 msgstr ""
1761 "在 Windows 中构建和安装 Mercurial 需要各种工具,相当多的技术背景,以及足够的耐"
1762 "心。如果你是一个<quote>初级用户</quote>,我<emphasis>很不赞成</emphasis>这个方"
1763 "法。我强烈建议你使用二进制安装包,除非你想深入研究 Mercurial 本身。"
1765 #. type: Content of: <book><appendix><sect1><para>
1766 #: ../en/appC-srcinstall.xml:53
1767 msgid ""
1768 "If you are intent on building Mercurial from source on Windows, follow the "
1769 "<quote>hard way</quote> directions on the Mercurial wiki at <ulink url="
1770 "\"http://www.selenic.com/mercurial/wiki/index.cgi/WindowsInstall\">http://www."
1771 "selenic.com/mercurial/wiki/index.cgi/WindowsInstall</ulink>, and expect the "
1772 "process to involve a lot of fiddly work."
1773 msgstr ""
1774 "If you are intent on building Mercurial from source on Windows, follow the "
1775 "<quote>hard way</quote> directions on the Mercurial wiki at <ulink url="
1776 "\"http://www.selenic.com/mercurial/wiki/index.cgi/WindowsInstall\">http://www."
1777 "selenic.com/mercurial/wiki/index.cgi/WindowsInstall</ulink>, and expect the "
1778 "process to involve a lot of fiddly work."
1780 #. type: Content of: <book><appendix><title>
1781 #: ../en/appD-license.xml:5
1782 msgid "Open Publication License"
1783 msgstr "开放出版协议"
1785 #. type: Content of: <book><appendix><para>
1786 #: ../en/appD-license.xml:7
1787 msgid "Version 1.0, 8 June 1999"
1788 msgstr "版本 1.0,1999 年 6 月 8 日。"
1790 #. type: Content of: <book><appendix><sect1><title>
1791 #: ../en/appD-license.xml:10
1792 msgid "Requirements on both unmodified and modified versions"
1793 msgstr ""
1795 #. type: Content of: <book><appendix><sect1><para>
1796 #: ../en/appD-license.xml:13
1797 msgid ""
1798 "The Open Publication works may be reproduced and distributed in whole or in "
1799 "part, in any medium physical or electronic, provided that the terms of this "
1800 "license are adhered to, and that this license or an incorporation of it by "
1801 "reference (with any options elected by the author(s) and/or publisher) is "
1802 "displayed in the reproduction."
1803 msgstr ""
1805 #. type: Content of: <book><appendix><sect1><para>
1806 #: ../en/appD-license.xml:20
1807 msgid "Proper form for an incorporation by reference is as follows:"
1808 msgstr ""
1810 #. type: Content of: <book><appendix><sect1><blockquote><para>
1811 #: ../en/appD-license.xml:24
1812 msgid ""
1813 "Copyright (c) <emphasis>year</emphasis> by <emphasis>author's name or "
1814 "designee</emphasis>. This material may be distributed only subject to the "
1815 "terms and conditions set forth in the Open Publication License, v<emphasis>x."
1816 "y</emphasis> or later (the latest version is presently available at <ulink "
1817 "url=\"http://www.opencontent.org/openpub/\">http://www.opencontent.org/"
1818 "openpub/</ulink>)."
1819 msgstr ""
1821 #. type: Content of: <book><appendix><sect1><para>
1822 #: ../en/appD-license.xml:33
1823 msgid ""
1824 "The reference must be immediately followed with any options elected by the "
1825 "author(s) and/or publisher of the document (see <xref linkend=\"sec:opl:"
1826 "options\"/>)."
1827 msgstr ""
1829 #. type: Content of: <book><appendix><sect1><para>
1830 #: ../en/appD-license.xml:37
1831 msgid ""
1832 "Commercial redistribution of Open Publication-licensed material is permitted."
1833 msgstr ""
1835 #. type: Content of: <book><appendix><sect1><para>
1836 #: ../en/appD-license.xml:40
1837 msgid ""
1838 "Any publication in standard (paper) book form shall require the citation of "
1839 "the original publisher and author. The publisher and author's names shall "
1840 "appear on all outer surfaces of the book. On all outer surfaces of the book "
1841 "the original publisher's name shall be as large as the title of the work and "
1842 "cited as possessive with respect to the title."
1843 msgstr ""
1845 #. type: Content of: <book><appendix><sect1><title>
1846 #: ../en/appD-license.xml:49
1847 msgid "Copyright"
1848 msgstr ""
1850 #. type: Content of: <book><appendix><sect1><para>
1851 #: ../en/appD-license.xml:51
1852 msgid ""
1853 "The copyright to each Open Publication is owned by its author(s) or designee."
1854 msgstr ""
1856 #. type: Content of: <book><appendix><sect1><title>
1857 #: ../en/appD-license.xml:56
1858 msgid "Scope of license"
1859 msgstr ""
1861 #. type: Content of: <book><appendix><sect1><para>
1862 #: ../en/appD-license.xml:58
1863 msgid ""
1864 "The following license terms apply to all Open Publication works, unless "
1865 "otherwise explicitly stated in the document."
1866 msgstr ""
1868 #. type: Content of: <book><appendix><sect1><para>
1869 #: ../en/appD-license.xml:62
1870 msgid ""
1871 "Mere aggregation of Open Publication works or a portion of an Open "
1872 "Publication work with other works or programs on the same media shall not "
1873 "cause this license to apply to those other works. The aggregate work shall "
1874 "contain a notice specifying the inclusion of the Open Publication material "
1875 "and appropriate copyright notice."
1876 msgstr ""
1878 #. type: Content of: <book><appendix><sect1><para>
1879 #: ../en/appD-license.xml:69
1880 msgid ""
1881 "<emphasis role=\"bold\">Severability</emphasis>. If any part of this license "
1882 "is found to be unenforceable in any jurisdiction, the remaining portions of "
1883 "the license remain in force."
1884 msgstr ""
1886 #. type: Content of: <book><appendix><sect1><para>
1887 #: ../en/appD-license.xml:74
1888 msgid ""
1889 "<emphasis role=\"bold\">No warranty</emphasis>. Open Publication works are "
1890 "licensed and provided <quote>as is</quote> without warranty of any kind, "
1891 "express or implied, including, but not limited to, the implied warranties of "
1892 "merchantability and fitness for a particular purpose or a warranty of non-"
1893 "infringement."
1894 msgstr ""
1896 #. type: Content of: <book><appendix><sect1><title>
1897 #: ../en/appD-license.xml:83
1898 msgid "Requirements on modified works"
1899 msgstr ""
1901 #. type: Content of: <book><appendix><sect1><para>
1902 #: ../en/appD-license.xml:85
1903 msgid ""
1904 "All modified versions of documents covered by this license, including "
1905 "translations, anthologies, compilations and partial documents, must meet the "
1906 "following requirements:"
1907 msgstr ""
1909 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1910 #: ../en/appD-license.xml:90
1911 msgid "The modified version must be labeled as such."
1912 msgstr ""
1914 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1915 #: ../en/appD-license.xml:93
1916 msgid ""
1917 "The person making the modifications must be identified and the modifications "
1918 "dated."
1919 msgstr ""
1921 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1922 #: ../en/appD-license.xml:96
1923 msgid ""
1924 "Acknowledgement of the original author and publisher if applicable must be "
1925 "retained according to normal academic citation practices."
1926 msgstr ""
1928 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1929 #: ../en/appD-license.xml:100
1930 msgid "The location of the original unmodified document must be identified."
1931 msgstr ""
1933 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1934 #: ../en/appD-license.xml:103
1935 msgid ""
1936 "The original author's (or authors') name(s) may not be used to assert or "
1937 "imply endorsement of the resulting document without the original author's (or "
1938 "authors') permission."
1939 msgstr ""
1941 #. type: Content of: <book><appendix><sect1><title>
1942 #: ../en/appD-license.xml:111
1943 msgid "Good-practice recommendations"
1944 msgstr ""
1946 #. type: Content of: <book><appendix><sect1><para>
1947 #: ../en/appD-license.xml:113
1948 msgid ""
1949 "In addition to the requirements of this license, it is requested from and "
1950 "strongly recommended of redistributors that:"
1951 msgstr ""
1953 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1954 #: ../en/appD-license.xml:118
1955 msgid ""
1956 "If you are distributing Open Publication works on hardcopy or CD-ROM, you "
1957 "provide email notification to the authors of your intent to redistribute at "
1958 "least thirty days before your manuscript or media freeze, to give the authors "
1959 "time to provide updated documents. This notification should describe "
1960 "modifications, if any, made to the document."
1961 msgstr ""
1963 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1964 #: ../en/appD-license.xml:125
1965 msgid ""
1966 "All substantive modifications (including deletions) be either clearly marked "
1967 "up in the document or else described in an attachment to the document."
1968 msgstr ""
1970 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1971 #: ../en/appD-license.xml:129
1972 msgid ""
1973 "Finally, while it is not mandatory under this license, it is considered good "
1974 "form to offer a free copy of any hardcopy and CD-ROM expression of an Open "
1975 "Publication-licensed work to its author(s)."
1976 msgstr ""
1978 #. type: Content of: <book><appendix><sect1><title>
1979 #: ../en/appD-license.xml:137
1980 msgid "License options"
1981 msgstr ""
1983 #. type: Content of: <book><appendix><sect1><para>
1984 #: ../en/appD-license.xml:139
1985 msgid ""
1986 "The author(s) and/or publisher of an Open Publication-licensed document may "
1987 "elect certain options by appending language to the reference to or copy of "
1988 "the license. These options are considered part of the license instance and "
1989 "must be included with the license (or its incorporation by reference) in "
1990 "derived works."
1991 msgstr ""
1993 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1994 #: ../en/appD-license.xml:147
1995 msgid ""
1996 "To prohibit distribution of substantively modified versions without the "
1997 "explicit permission of the author(s). <quote>Substantive modification</quote> "
1998 "is defined as a change to the semantic content of the document, and excludes "
1999 "mere changes in format or typographical corrections."
2000 msgstr ""
2002 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
2003 #: ../en/appD-license.xml:154
2004 msgid ""
2005 "To accomplish this, add the phrase <quote>Distribution of substantively "
2006 "modified versions of this document is prohibited without the explicit "
2007 "permission of the copyright holder.</quote> to the license reference or copy."
2008 msgstr ""
2010 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
2011 #: ../en/appD-license.xml:160
2012 msgid ""
2013 "To prohibit any publication of this work or derivative works in whole or in "
2014 "part in standard (paper) book form for commercial purposes is prohibited "
2015 "unless prior permission is obtained from the copyright holder."
2016 msgstr ""
2018 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
2019 #: ../en/appD-license.xml:165
2020 msgid ""
2021 "To accomplish this, add the phrase <quote>Distribution of the work or "
2022 "derivative of the work in any standard (paper) book form is prohibited unless "
2023 "prior permission is obtained from the copyright holder.</quote> to the "
2024 "license reference or copy."
2025 msgstr ""
2027 #. type: Content of: <book><preface><title>
2028 #: ../en/ch00-preface.xml:5
2029 msgid "Preface"
2030 msgstr "序言"
2032 #. type: Content of: <book><preface><sect1><title>
2033 #: ../en/ch00-preface.xml:8
2034 msgid "Technical storytelling"
2035 msgstr "技术背景"
2037 #. type: Content of: <book><preface><sect1><para>
2038 #: ../en/ch00-preface.xml:10
2039 msgid ""
2040 "A few years ago, when I wanted to explain why I believed that distributed "
2041 "revision control is important, the field was then so new that there was "
2042 "almost no published literature to refer people to."
2043 msgstr ""
2044 "数年之前,当我想解释为什么我相信分布式版本控制非常重要的时候,这个领域实在太新"
2045 "了,几乎没有公开的文献供人们参考。"
2047 #. type: Content of: <book><preface><sect1><para>
2048 #: ../en/ch00-preface.xml:15
2049 msgid ""
2050 "Although at that time I spent some time working on the internals of Mercurial "
2051 "itself, I switched to writing this book because that seemed like the most "
2052 "effective way to help the software to reach a wide audience, along with the "
2053 "idea that revision control ought to be distributed in nature. I publish the "
2054 "book online under a liberal license for the same reason: to get the word out."
2055 msgstr ""
2056 "虽然在那个时候,我已经在Mercurial的内核上花了一些时间,我转而写这本书是因为我"
2057 "发现这可能是帮助软件吸引更多用户,和让大家接受版本控制本质上就应该是分布式的最"
2058 "有效的方式,我把这本书在网上以自由许可的方式发布也是基于同样的原因:让大家都了"
2059 "解。"
2061 #. type: Content of: <book><preface><sect1><para>
2062 #: ../en/ch00-preface.xml:23
2063 msgid ""
2064 "There's a familiar rhythm to a good software book that closely resembles "
2065 "telling a story: What is this thing? Why does it matter? How will it help me? "
2066 "How do I use it? In this book, I try to answer those questions for "
2067 "distributed revision control in general, and for Mercurial in particular."
2068 msgstr ""
2069 "一本好的关于软件的书应该和讲故事类似:这是个什么东西?为什么需要它?它会怎样帮"
2070 "助我?我怎么使用它?本书中,我会为分布式版本控制回答这些问题,特别是"
2071 "Mercurial。"
2073 #. type: Content of: <book><preface><sect1><title>
2074 #: ../en/ch00-preface.xml:31
2075 msgid "Thank you for supporting Mercurial"
2076 msgstr "谢谢你支持 Mercurial"
2078 #. type: Content of: <book><preface><sect1><para>
2079 #: ../en/ch00-preface.xml:33
2080 msgid ""
2081 "By purchasing a copy of this book, you are supporting the continued "
2082 "development and freedom of Mercurial in particular, and of open source and "
2083 "free software in general. O'Reilly Media and I are donating my royalties on "
2084 "the sales of this book to the Software Freedom Conservancy (<ulink url="
2085 "\"http://www.softwarefreedom.org/\">http://www.softwarefreedom.org/</ulink>) "
2086 "which provides clerical and legal support to Mercurial and a number of other "
2087 "prominent and worthy open source software projects."
2088 msgstr ""
2089 "通过购买此书,你支持了开源和自由软件的持续发展和自由,特别是Mercurial。"
2090 "O'Reilly Media和我将本书的收入捐献给Software Freedom Conservancy (<ulink url="
2091 "\"http://www.softwarefreedom.org/\">http://www.softwarefreedom.org/</ulink>) ,"
2092 "这个组织为Mercurial和其他一些有潜力和价值的开源软件项目提供了办公和法律支持。"
2094 #. type: Content of: <book><preface><sect1><title>
2095 #: ../en/ch00-preface.xml:45
2096 msgid "Acknowledgments"
2097 msgstr "致谢"
2099 #. type: Content of: <book><preface><sect1><para>
2100 #: ../en/ch00-preface.xml:47
2101 msgid ""
2102 "This book would not exist were it not for the efforts of Matt Mackall, the "
2103 "author and project lead of Mercurial. He is ably assisted by hundreds of "
2104 "volunteer contributors across the world."
2105 msgstr ""
2106 "没有Matt Mackall,Mercurial项目的开发者和领导的努力,这本书不可能存在。他得到"
2107 "了全球数以百计的志愿者的帮助。"
2109 #. type: Content of: <book><preface><sect1><para>
2110 #: ../en/ch00-preface.xml:52
2111 msgid ""
2112 "My children, Cian and Ruairi, always stood ready to help me to unwind with "
2113 "wonderful, madcap little-boy games. I'd also like to thank my ex-wife, "
2114 "Shannon, for her support."
2115 msgstr ""
2117 #. type: Content of: <book><preface><sect1><para>
2118 #: ../en/ch00-preface.xml:56
2119 msgid ""
2120 "My colleagues and friends provided help and support in innumerable ways. "
2121 "This list of people is necessarily very incomplete: Stephen Hahn, Karyn "
2122 "Ritter, Bonnie Corwin, James Vasile, Matt Norwood, Eben Moglen, Bradley Kuhn, "
2123 "Robert Walsh, Jeremy Fitzhardinge, Rachel Chalmers."
2124 msgstr ""
2125 "我的同事和朋友以各种方式提供了帮助和支持,这里的名单非常不全:Stephen Hahn, "
2126 "Karyn Ritter, Bonnie Corwin, James Vasile, Matt Norwood, Eben Moglen, Bradley "
2127 "Kuhn, Robert Walsh, Jeremy Fitzhardinge, Rachel Chalmers."
2129 #. type: Content of: <book><preface><sect1><para>
2130 #: ../en/ch00-preface.xml:62
2131 msgid ""
2132 "I developed this book in the open, posting drafts of chapters to the book web "
2133 "site as I completed them. Readers then submitted feedback using a web "
2134 "application that I developed. By the time I finished writing the book, more "
2135 "than 100 people had submitted comments, an amazing number considering that "
2136 "the comment system was live for only about two months towards the end of the "
2137 "writing process."
2138 msgstr ""
2139 "我以开放的方式完成了本书,当我完成各章的草稿后,就将其放在了网上。读者可以使用"
2140 "我开发的一个网络程序提交反馈。到我完成本书时,有100多人提交了评论。考虑到评论"
2141 "系统是在写作完成之前两个月才开放的,这是一个惊人的数字。"
2143 #. type: Content of: <book><preface><sect1><para>
2144 #: ../en/ch00-preface.xml:70
2145 msgid ""
2146 "I would particularly like to recognize the following people, who between them "
2147 "contributed over a third of the total number of comments. I would like to "
2148 "thank them for their care and effort in providing so much detailed feedback."
2149 msgstr ""
2150 "我特别希望认识以下人员,他们中有的人提交了超过总数三分之一的评论。我要感谢他们"
2151 "的关心和努力,提供了那么多详细的反馈。"
2153 #. type: Content of: <book><preface><sect1><para>
2154 #: ../en/ch00-preface.xml:75
2155 msgid ""
2156 "Martin Geisler, Damien Cassou, Alexey Bakhirkin, Till Plewe, Dan Himes, Paul "
2157 "Sargent, Gokberk Hamurcu, Matthijs van der Vleuten, Michael Chermside, John "
2158 "Mulligan, Jordi Fita, Jon Parise."
2159 msgstr ""
2161 #. type: Content of: <book><preface><sect1><para>
2162 #: ../en/ch00-preface.xml:80
2163 msgid ""
2164 "I also want to acknowledge the help of the many people who caught errors and "
2165 "provided helpful suggestions throughout the book."
2166 msgstr "我同样要感谢许多在书中找出错误和提供了有帮助的建议的人。"
2168 #. type: Content of: <book><preface><sect1><para>
2169 #: ../en/ch00-preface.xml:84
2170 msgid ""
2171 "Jeremy W. Sherman, Brian Mearns, Vincent Furia, Iwan Luijks, Billy Edwards, "
2172 "Andreas Sliwka, Paweł Sołyga, Eric Hanchrow, Steve Nicolai, Michał Masłowski, "
2173 "Kevin Fitch, Johan Holmberg, Hal Wine, Volker Simonis, Thomas P Jakobsen, Ted "
2174 "Stresen-Reuter, Stephen Rasku, Raphael Das Gupta, Ned Batchelder, Lou Keeble, "
2175 "Li Linxiao, Kao Cardoso Félix, Joseph Wecker, Jon Prescot, Jon Maken, John "
2176 "Yeary, Jason Harris, Geoffrey Zheng, Fredrik Jonson, Ed Davies, David "
2177 "Zumbrunnen, David Mercer, David Cabana, Ben Karel, Alan Franzoni, Yousry "
2178 "Abdallah, Whitney Young, Vinay Sajip, Tom Towle, Tim Ottinger, Thomas "
2179 "Schraitle, Tero Saarni, Ted Mielczarek, Svetoslav Agafonkin, Shaun Rowland, "
2180 "Rocco Rutte, Polo-Francois Poli, Philip Jenvey, Petr Tesałék, Peter R. "
2181 "Annema, Paul Bonser, Olivier Scherler, Olivier Fournier, Nick Parker, Nick "
2182 "Fabry, Nicholas Guarracino, Mike Driscoll, Mike Coleman, Mietek Bák, Michael "
2183 "Maloney, László Nagy, Kent Johnson, Julio Nobrega, Jord Fita, Jonathan March, "
2184 "Jonas Nockert, Jim Tittsler, Jeduan Cornejo Legorreta, Jan Larres, James "
2185 "Murphy, Henri Wiechers, Hagen Möbius, Gábor Farkas, Fabien Engels, Evert Rol, "
2186 "Evan Willms, Eduardo Felipe Castegnaro, Dennis Decker Jensen, Deniz Dogan, "
2187 "David Smith, Daed Lee, Christine Slotty, Charles Merriam, Guillaume Catto, "
2188 "Brian Dorsey, Bob Nystrom, Benoit Boissinot, Avi Rosenschein, Andrew Watts, "
2189 "Andrew Donkin, Alexey Rodriguez, Ahmed Chaudhary."
2190 msgstr ""
2192 #. type: Content of: <book><preface><sect1><title>
2193 #: ../en/ch00-preface.xml:111
2194 msgid "Conventions Used in This Book"
2195 msgstr "本书的约定"
2197 #. type: Content of: <book><preface><sect1><para>
2198 #: ../en/ch00-preface.xml:113
2199 msgid "The following typographical conventions are used in this book:"
2200 msgstr "本书使用如下的印刷约定:"
2202 #. type: Content of: <book><preface><sect1><variablelist><varlistentry><term>
2203 #: ../en/ch00-preface.xml:118
2204 msgid "Italic"
2205 msgstr "斜体"
2207 #. type: Content of: <book><preface><sect1><variablelist><varlistentry><listitem><para>
2208 #: ../en/ch00-preface.xml:121
2209 msgid ""
2210 "Indicates new terms, URLs, email addresses, filenames, and file extensions."
2211 msgstr "标识新术语,URL,电子邮件地址,文件名称与扩展名。"
2213 #. type: Content of: <book><preface><sect1><variablelist><varlistentry><term>
2214 #: ../en/ch00-preface.xml:127
2215 msgid "<literal>Constant width</literal>"
2216 msgstr "<literal>等宽</literal>"
2218 #. type: Content of: <book><preface><sect1><variablelist><varlistentry><listitem><para>
2219 #: ../en/ch00-preface.xml:130
2220 msgid ""
2221 "Used for program listings, as well as within paragraphs to refer to program "
2222 "elements such as variable or function names, databases, data types, "
2223 "environment variables, statements, and keywords."
2224 msgstr ""
2225 "用于程序列表,以及段内引用的程序元素,例如变量、函数名称、数据库、数据类型、环"
2226 "境变量、声明和关键字。"
2228 #. type: Content of: <book><preface><sect1><variablelist><varlistentry><term>
2229 #: ../en/ch00-preface.xml:138
2230 msgid "<userinput>Constant width bold</userinput>"
2231 msgstr "<userinput>等宽粗体</userinput>"
2233 #. type: Content of: <book><preface><sect1><variablelist><varlistentry><listitem><para>
2234 #: ../en/ch00-preface.xml:141
2235 msgid "Shows commands or other text that should be typed literally by the user."
2236 msgstr "标识命令或者其它用户应该逐字输入的文本。"
2238 #. type: Content of: <book><preface><sect1><variablelist><varlistentry><term>
2239 #: ../en/ch00-preface.xml:147
2240 msgid "<replaceable>Constant width italic</replaceable>"
2241 msgstr "<replaceable>等宽斜体</replaceable>"
2243 #. type: Content of: <book><preface><sect1><variablelist><varlistentry><listitem><para>
2244 #: ../en/ch00-preface.xml:150
2245 msgid ""
2246 "Shows text that should be replaced with user-supplied values or by values "
2247 "determined by context."
2248 msgstr "标识应该被用户提供的值或者取决于上下文的值替换的文本。"
2250 #. type: Content of: <book><preface><sect1><tip><para>
2251 #: ../en/ch00-preface.xml:157
2252 msgid "This icon signifies a tip, suggestion, or general note."
2253 msgstr "此图标表示提示,建议或者一般的的注释。"
2255 #. type: Content of: <book><preface><sect1><caution><para>
2256 #: ../en/ch00-preface.xml:162
2257 msgid "This icon indicates a warning or caution."
2258 msgstr "此图标表示警告。"
2260 #. type: Content of: <book><preface><sect1><title>
2261 #: ../en/ch00-preface.xml:167
2262 msgid "Using Code Examples"
2263 msgstr "使用样例代码"
2265 #. type: Content of: <book><preface><sect1><para>
2266 #: ../en/ch00-preface.xml:169
2267 msgid ""
2268 "This book is here to help you get your job done. In general, you may use the "
2269 "code in this book in your programs and documentation. You do not need to "
2270 "contact us for permission unless you’re reproducing a significant portion of "
2271 "the code. For example, writing a program that uses several chunks of code "
2272 "from this book does not require permission. Selling or distributing a CD-ROM "
2273 "of examples from O’Reilly books does require permission. Answering a "
2274 "question by citing this book and quoting example code does not require "
2275 "permission. Incorporating a significant amount of example code from this book "
2276 "into your product’s documentation does require permission."
2277 msgstr ""
2279 #. type: Content of: <book><preface><sect1><para>
2280 #: ../en/ch00-preface.xml:181
2281 msgid ""
2282 "We appreciate, but do not require, attribution. An attribution usually "
2283 "includes the title, author, publisher, and ISBN. For example: “<emphasis>Book "
2284 "Title</emphasis> by Some Author. Copyright 2008 O’Reilly Media, Inc., 978-0-"
2285 "596-xxxx-x.”"
2286 msgstr ""
2288 #. type: Content of: <book><preface><sect1><para>
2289 #: ../en/ch00-preface.xml:187
2290 msgid ""
2291 "If you feel your use of code examples falls outside fair use or the "
2292 "permission given above, feel free to contact us at <email>permissions@oreilly."
2293 "com</email>."
2294 msgstr ""
2296 #. type: Content of: <book><preface><sect1><title>
2297 #: ../en/ch00-preface.xml:193
2298 msgid "Safari® Books Online"
2299 msgstr "Safari® 在线书库"
2301 #. type: Content of: <book><preface><sect1><note><para>
2302 #: ../en/ch00-preface.xml:196
2303 msgid ""
2304 "When you see a Safari® Books Online icon on the cover of your favorite "
2305 "technology book, that means the book is available online through the O’Reilly "
2306 "Network Safari Bookshelf."
2307 msgstr ""
2309 #. type: Content of: <book><preface><sect1><para>
2310 #: ../en/ch00-preface.xml:202
2311 msgid ""
2312 "Safari offers a solution that’s better than e-books. It’s a virtual library "
2313 "that lets you easily search thousands of top tech books, cut and paste code "
2314 "samples, download chapters, and find quick answers when you need the most "
2315 "accurate, current information. Try it for free at <ulink role=\"orm:hideurl:"
2316 "ital\" url=\"http://my.safaribooksonline.com/?portal=oreilly\">http://my."
2317 "safaribooksonline.com</ulink>."
2318 msgstr ""
2320 #. type: Content of: <book><preface><sect1><title>
2321 #: ../en/ch00-preface.xml:211
2322 msgid "How to Contact Us"
2323 msgstr "联系我们"
2325 #. type: Content of: <book><preface><sect1><para>
2326 #: ../en/ch00-preface.xml:213
2327 msgid ""
2328 "Please address comments and questions concerning this book to the publisher:"
2329 msgstr ""
2331 #. type: Content of: <book><preface><sect1><simplelist><member>
2332 #: ../en/ch00-preface.xml:217
2333 msgid "O’Reilly Media, Inc."
2334 msgstr ""
2336 #. type: Content of: <book><preface><sect1><simplelist><member>
2337 #: ../en/ch00-preface.xml:219
2338 msgid "1005 Gravenstein Highway North"
2339 msgstr ""
2341 #. type: Content of: <book><preface><sect1><simplelist><member>
2342 #: ../en/ch00-preface.xml:221
2343 msgid "Sebastopol, CA 95472"
2344 msgstr ""
2346 #. type: Content of: <book><preface><sect1><simplelist><member>
2347 #: ../en/ch00-preface.xml:223
2348 msgid "800-998-9938 (in the United States or Canada)"
2349 msgstr ""
2351 #. type: Content of: <book><preface><sect1><simplelist><member>
2352 #: ../en/ch00-preface.xml:225
2353 msgid "707-829-0515 (international or local)"
2354 msgstr ""
2356 #. type: Content of: <book><preface><sect1><simplelist><member>
2357 #: ../en/ch00-preface.xml:227
2358 msgid "707 829-0104 (fax)"
2359 msgstr ""
2361 #. type: Content of: <book><preface><sect1><para>
2362 #: ../en/ch00-preface.xml:230
2363 msgid ""
2364 "We have a web page for this book, where we list errata, examples, and any "
2365 "additional information. You can access this page at:"
2366 msgstr ""
2368 #. type: Content of: <book><preface><sect1><simplelist><member>
2369 #: ../en/ch00-preface.xml:235
2370 msgid ""
2371 "<ulink url=\"http://www.oreilly.com/catalog/&lt;catalog page&gt;\"></ulink>"
2372 msgstr ""
2374 #. type: Content of: <book><preface><sect1><remark>
2375 #: ../en/ch00-preface.xml:239
2376 msgid "Don’t forget to update the &lt;url&gt; attribute, too."
2377 msgstr ""
2379 #. type: Content of: <book><preface><sect1><para>
2380 #: ../en/ch00-preface.xml:242
2381 msgid "To comment or ask technical questions about this book, send email to:"
2382 msgstr ""
2384 #. type: Content of: <book><preface><sect1><simplelist><member>
2385 #: ../en/ch00-preface.xml:246
2386 msgid "<email>bookquestions@oreilly.com</email>"
2387 msgstr "<email>bookquestions@oreilly.com</email>"
2389 #. type: Content of: <book><preface><sect1><para>
2390 #: ../en/ch00-preface.xml:249
2391 msgid ""
2392 "For more information about our books, conferences, Resource Centers, and the "
2393 "O’Reilly Network, see our web site at:"
2394 msgstr ""
2396 #. type: Content of: <book><preface><sect1><simplelist><member>
2397 #: ../en/ch00-preface.xml:253
2398 msgid "<ulink url=\"http://www.oreilly.com\"></ulink>"
2399 msgstr "<ulink url=\"http://www.oreilly.com\"></ulink>"
2401 #. type: Content of: <book><chapter><title>
2402 #: ../en/ch01-intro.xml:5
2403 msgid "How did we get here?"
2404 msgstr "写在前面"
2406 #. type: Content of: <book><chapter><sect1><title>
2407 #: ../en/ch01-intro.xml:8
2408 msgid "Why revision control? Why Mercurial?"
2409 msgstr "为什么使用版本控制? 为什么使用 Mercurial?"
2411 #. type: Content of: <book><chapter><sect1><para>
2412 #: ../en/ch01-intro.xml:10
2413 msgid ""
2414 "Revision control is the process of managing multiple versions of a piece of "
2415 "information. In its simplest form, this is something that many people do by "
2416 "hand: every time you modify a file, save it under a new name that contains a "
2417 "number, each one higher than the number of the preceding version."
2418 msgstr ""
2419 "版本控制是管理一些信息的多个版本的过程。它最简单的形式莫过于:每次你修改一个文"
2420 "件后都重新命名保存,文件名中包含一个数字,每次修改后这个数字都增加。这通常是许"
2421 "多人手工完成的。"
2423 #. type: Content of: <book><chapter><sect1><para>
2424 #: ../en/ch01-intro.xml:16
2425 msgid ""
2426 "Manually managing multiple versions of even a single file is an error-prone "
2427 "task, though, so software tools to help automate this process have long been "
2428 "available. The earliest automated revision control tools were intended to "
2429 "help a single user to manage revisions of a single file. Over the past few "
2430 "decades, the scope of revision control tools has expanded greatly; they now "
2431 "manage multiple files, and help multiple people to work together. The best "
2432 "modern revision control tools have no problem coping with thousands of people "
2433 "working together on projects that consist of hundreds of thousands of files."
2434 msgstr ""
2435 "然而,手工管理即使是一个文件的多个版本也是很容易出错的,所以很早就有软件工具来"
2436 "使这个过程自动化。最早的自动化软件管理工具的目标是帮助一个用户管理一个文件的版"
2437 "本。在过去的几十年里,版本控制工具的范围得到极大扩展;现在它们可以管理多个文"
2438 "件,帮助许多人一起工作。最新的版本控制工具可以支持上包含成数十万个文件,几千个"
2439 "人一起工作的项目。"
2441 #. type: Content of: <book><chapter><sect1><para>
2442 #: ../en/ch01-intro.xml:27
2443 msgid ""
2444 "The arrival of distributed revision control is relatively recent, and so far "
2445 "this new field has grown due to people's willingness to explore ill-charted "
2446 "territory."
2447 msgstr ""
2448 "分布式版本控制是最近才出现的,但是由于人们愿意探索新的疆域,目前这一新的领域已"
2449 "经得到了长足的发展"
2451 #. type: Content of: <book><chapter><sect1><para>
2452 #: ../en/ch01-intro.xml:31
2453 msgid ""
2454 "I am writing a book about distributed revision control because I believe that "
2455 "it is an important subject that deserves a field guide. I chose to write "
2456 "about Mercurial because it is the easiest tool to learn the terrain with, and "
2457 "yet it scales to the demands of real, challenging environments where many "
2458 "other revision control tools buckle."
2459 msgstr ""
2460 "我写这本关于分布式版本控制的书是因为我相信这个领域应该有一个指南。我选择"
2461 "Mercurial是因为它是在这个领域中学习最容易上手的工具,并且它能够满足真实的,挑"
2462 "战性的环境的要求,而其他版本控制工具只能望而兴叹。"
2464 #. type: Content of: <book><chapter><sect1><sect2><title>
2465 #: ../en/ch01-intro.xml:39
2466 msgid "Why use revision control?"
2467 msgstr "为什么使用版本控制?"
2469 #. type: Content of: <book><chapter><sect1><sect2><para>
2470 #: ../en/ch01-intro.xml:41
2471 msgid ""
2472 "There are a number of reasons why you or your team might want to use an "
2473 "automated revision control tool for a project."
2474 msgstr ""
2475 "为什么你或者你的团队可能需要在项目中使用自动化版本控制工具呢?有很多理由。"
2477 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2478 #: ../en/ch01-intro.xml:46
2479 msgid ""
2480 "It will track the history and evolution of your project, so you don't have "
2481 "to. For every change, you'll have a log of <emphasis>who</emphasis> made it; "
2482 "<emphasis>why</emphasis> they made it; <emphasis>when</emphasis> they made "
2483 "it; and <emphasis>what</emphasis> the change was."
2484 msgstr ""
2485 "因为它能记录你的项目的历史和演化,所以你不必再给每个变更都记录日志,<emphasis>"
2486 "谁</emphasis>做的;<emphasis>为什么</emphasis>他们这样做;<emphasis>什么时候</"
2487 "emphasis>做的;做了<emphasis>什么</emphasis>修改。"
2489 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2490 #: ../en/ch01-intro.xml:53
2491 msgid ""
2492 "When you're working with other people, revision control software makes it "
2493 "easier for you to collaborate. For example, when people more or less "
2494 "simultaneously make potentially incompatible changes, the software will help "
2495 "you to identify and resolve those conflicts."
2496 msgstr ""
2497 "当你和其他人一起工作的时候,版本控制工具让你合作的更容易。例如,当许多人或多或"
2498 "少的同时进行有可能冲突的修改的时候,软件可以帮助你确定和解决这些冲突。"
2500 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2501 #: ../en/ch01-intro.xml:59
2502 msgid ""
2503 "It can help you to recover from mistakes. If you make a change that later "
2504 "turns out to be in error, you can revert to an earlier version of one or more "
2505 "files. In fact, a <emphasis>really</emphasis> good revision control tool "
2506 "will even help you to efficiently figure out exactly when a problem was "
2507 "introduced (see <xref linkend=\"sec:undo:bisect\"/> for details)."
2508 msgstr ""
2509 "它能帮助你修正错误。如果你做了一个修改,但是后来发现这是个错误,你能恢复到一个"
2510 "或者多个文件以前的版本。实际上,一个<emphasis>相当</emphasis>好的版本控制工具"
2511 "甚至会帮助你找出什么什么是时候引入的这个问题(详细信息参考<xref linkend=\"sec:"
2512 "undo:bisect\"/>)。 "
2514 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2515 #: ../en/ch01-intro.xml:66
2516 msgid ""
2517 "It will help you to work simultaneously on, and manage the drift between, "
2518 "multiple versions of your project."
2519 msgstr "它能帮助你同时工作于项目的多个版本,并管理它们的差异。"
2521 #. type: Content of: <book><chapter><sect1><sect2><para>
2522 #: ../en/ch01-intro.xml:71
2523 msgid ""
2524 "Most of these reasons are equally valid&emdash;at least in theory&emdash;"
2525 "whether you're working on a project by yourself, or with a hundred other "
2526 "people."
2527 msgstr ""
2528 "大多数这些理由都是等效的&emdash;至少在理论上&emdash;不管你是一个人做项目还是和"
2529 "几百个人一起。"
2531 #. type: Content of: <book><chapter><sect1><sect2><para>
2532 #: ../en/ch01-intro.xml:76
2533 msgid ""
2534 "A key question about the practicality of revision control at these two "
2535 "different scales (<quote>lone hacker</quote> and <quote>huge team</quote>) is "
2536 "how its <emphasis>benefits</emphasis> compare to its <emphasis>costs</"
2537 "emphasis>. A revision control tool that's difficult to understand or use is "
2538 "going to impose a high cost."
2539 msgstr ""
2540 "版本控制在在不同尺度上(<quote>单个黑客</quote>和<quote>一个大项目组</quote>)"
2541 "实践的一个关键问题是它的<emphasis>性价</emphasis>比怎么样。一个很难理解和使用"
2542 "的版本控制工具会让你的代价很高。"
2544 #. type: Content of: <book><chapter><sect1><sect2><para>
2545 #: ../en/ch01-intro.xml:84
2546 msgid ""
2547 "A five-hundred-person project is likely to collapse under its own weight "
2548 "almost immediately without a revision control tool and process. In this case, "
2549 "the cost of using revision control might hardly seem worth considering, since "
2550 "<emphasis>without</emphasis> it, failure is almost guaranteed."
2551 msgstr ""
2552 "如果没有版本控制工具和过程,一个五百人的项目很快就可能就将自己压垮。在这种情况"
2553 "下,版本控制的代价基本上不用考虑,因为没有它,失败几乎是一定的。"
2555 #. type: Content of: <book><chapter><sect1><sect2><para>
2556 #: ../en/ch01-intro.xml:91
2557 msgid ""
2558 "On the other hand, a one-person <quote>quick hack</quote> might seem like a "
2559 "poor place to use a revision control tool, because surely the cost of using "
2560 "one must be close to the overall cost of the project. Right?"
2561 msgstr ""
2562 "另一方面,一个人的<quote>快速编程</quote>看起来并不适合使用版本控制工具,因为"
2563 "使用一个版本控制工具的代价就是整个项目的代价,对吧?"
2565 #. type: Content of: <book><chapter><sect1><sect2><para>
2566 #: ../en/ch01-intro.xml:96
2567 msgid ""
2568 "Mercurial uniquely supports <emphasis>both</emphasis> of these scales of "
2569 "development. You can learn the basics in just a few minutes, and due to its "
2570 "low overhead, you can apply revision control to the smallest of projects with "
2571 "ease. Its simplicity means you won't have a lot of abstruse concepts or "
2572 "command sequences competing for mental space with whatever you're "
2573 "<emphasis>really</emphasis> trying to do. At the same time, Mercurial's high "
2574 "performance and peer-to-peer nature let you scale painlessly to handle large "
2575 "projects."
2576 msgstr ""
2577 "Mercurial的独特之处就是它<emphasis>同时</emphasis>支持这两种尺度的开发。你可以"
2578 "在几分钟之内学会基本的使用,因为代价很小,你可以很方便的在最小的项目上应用版本"
2579 "管理。它的简洁性意味着不会有很多艰深的概念和命令干扰你<emphasis>真正</"
2580 "emphasis>的工作。同时,Mercurial高性能和点对点的特性可以让你轻易的应对大的项"
2581 "目。"
2583 #. type: Content of: <book><chapter><sect1><sect2><para>
2584 #: ../en/ch01-intro.xml:106
2585 msgid ""
2586 "No revision control tool can rescue a poorly run project, but a good choice "
2587 "of tools can make a huge difference to the fluidity with which you can work "
2588 "on a project."
2589 msgstr ""
2590 "没有一个版本控制工具能拯救一个糟糕的项目,但是在项目中选择好的工具会大大的提高"
2591 "效率,正是工欲善其事,必先利其器。"
2593 #. type: Content of: <book><chapter><sect1><sect2><title>
2594 #: ../en/ch01-intro.xml:113
2595 msgid "The many names of revision control"
2596 msgstr "版本控制的别名"
2598 #. type: Content of: <book><chapter><sect1><sect2><para>
2599 #: ../en/ch01-intro.xml:115
2600 msgid ""
2601 "Revision control is a diverse field, so much so that it is referred to by "
2602 "many names and acronyms. Here are a few of the more common variations you'll "
2603 "encounter:"
2604 msgstr ""
2605 "版本控制是一个各自为政的领域,以至于有很多名称和缩略语,下面是你可能遇到的一些"
2606 "常用的术语:"
2608 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2609 #: ../en/ch01-intro.xml:119
2610 msgid "Revision control (RCS)"
2611 msgstr "版本控制(RCS)"
2613 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2614 #: ../en/ch01-intro.xml:120
2615 msgid "Software configuration management (SCM), or configuration management"
2616 msgstr "软件配置管理(SCM),或配置管理"
2618 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2619 #: ../en/ch01-intro.xml:122
2620 msgid "Source code management"
2621 msgstr "源代码管理"
2623 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2624 #: ../en/ch01-intro.xml:123
2625 msgid "Source code control, or source control"
2626 msgstr "源代码控制,或源控制"
2628 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2629 #: ../en/ch01-intro.xml:125
2630 msgid "Version control (VCS)"
2631 msgstr "版本控制(VCS)"
2633 #. type: Content of: <book><chapter><sect1><sect2><para>
2634 #: ../en/ch01-intro.xml:127
2635 msgid ""
2636 "Some people claim that these terms actually have different meanings, but in "
2637 "practice they overlap so much that there's no agreed or even useful way to "
2638 "tease them apart."
2639 msgstr ""
2640 "有些人声称这些术语有不同的含义,但实际上它们的含义太重叠了,根本没有一致的,甚"
2641 "至有用的方式来区别它们。"
2643 #. type: Content of: <book><chapter><sect1><title>
2644 #: ../en/ch01-intro.xml:135
2645 msgid "About the examples in this book"
2646 msgstr "本书的例子"
2648 #. type: Content of: <book><chapter><sect1><para>
2649 #: ../en/ch01-intro.xml:137
2650 msgid ""
2651 "This book takes an unusual approach to code samples. Every example is "
2652 "<quote>live</quote>&emdash;each one is actually the result of a shell script "
2653 "that executes the Mercurial commands you see. Every time an image of the "
2654 "book is built from its sources, all the example scripts are automatically "
2655 "run, and their current results compared against their expected results."
2656 msgstr ""
2658 #. type: Content of: <book><chapter><sect1><para>
2659 #: ../en/ch01-intro.xml:144
2660 msgid ""
2661 "The advantage of this approach is that the examples are always accurate; they "
2662 "describe <emphasis>exactly</emphasis> the behavior of the version of "
2663 "Mercurial that's mentioned at the front of the book. If I update the version "
2664 "of Mercurial that I'm documenting, and the output of some command changes, "
2665 "the build fails."
2666 msgstr ""
2668 #. type: Content of: <book><chapter><sect1><para>
2669 #: ../en/ch01-intro.xml:151
2670 msgid ""
2671 "There is a small disadvantage to this approach, which is that the dates and "
2672 "times you'll see in examples tend to be <quote>squashed</quote> together in a "
2673 "way that they wouldn't be if the same commands were being typed by a human. "
2674 "Where a human can issue no more than one command every few seconds, with any "
2675 "resulting timestamps correspondingly spread out, my automated example scripts "
2676 "run many commands in one second."
2677 msgstr ""
2679 #. type: Content of: <book><chapter><sect1><para>
2680 #: ../en/ch01-intro.xml:159
2681 msgid ""
2682 "As an instance of this, several consecutive commits in an example can show up "
2683 "as having occurred during the same second. You can see this occur in the "
2684 "<literal role=\"hg-ext\">bisect</literal> example in <xref linkend=\"sec:undo:"
2685 "bisect\"/>, for instance."
2686 msgstr ""
2688 #. type: Content of: <book><chapter><sect1><para>
2689 #: ../en/ch01-intro.xml:165
2690 msgid ""
2691 "So when you're reading examples, don't place too much weight on the dates or "
2692 "times you see in the output of commands. But <emphasis>do</emphasis> be "
2693 "confident that the behavior you're seeing is consistent and reproducible."
2694 msgstr ""
2695 "所以当你研究这些例子的时候,不要太注意命令输出的日期和时间。但是<emphasis>要</"
2696 "emphasis>保证你看到的行为是一致的和可以再现的。"
2698 #. type: Content of: <book><chapter><sect1><title>
2699 #: ../en/ch01-intro.xml:173
2700 msgid "Trends in the field"
2701 msgstr "版本控制的发展趋势"
2703 #. type: Content of: <book><chapter><sect1><para>
2704 #: ../en/ch01-intro.xml:175
2705 msgid ""
2706 "There has been an unmistakable trend in the development and use of revision "
2707 "control tools over the past four decades, as people have become familiar with "
2708 "the capabilities of their tools and constrained by their limitations."
2709 msgstr ""
2710 "在过去的四十年中,随着人们越来越熟悉他们的工具的能力和限制,开发和使用版本控制"
2711 "工具出现了明确的趋势。 "
2713 #. type: Content of: <book><chapter><sect1><para>
2714 #: ../en/ch01-intro.xml:180
2715 msgid ""
2716 "The first generation began by managing single files on individual computers. "
2717 "Although these tools represented a huge advance over ad-hoc manual revision "
2718 "control, their locking model and reliance on a single computer limited them "
2719 "to small, tightly-knit teams."
2720 msgstr ""
2721 "在第一代软件开始于在个人计算机上管理单个文件。虽然这些工具比手工管理版本有了巨"
2722 "大的飞跃。但是加锁模型和依赖于单个计算机限制了他们之能用于小的,组织严密的团"
2723 "队。"
2725 #. type: Content of: <book><chapter><sect1><para>
2726 #: ../en/ch01-intro.xml:186
2727 msgid ""
2728 "The second generation loosened these constraints by moving to network-"
2729 "centered architectures, and managing entire projects at a time. As projects "
2730 "grew larger, they ran into new problems. With clients needing to talk to "
2731 "servers very frequently, server scaling became an issue for large projects. "
2732 "An unreliable network connection could prevent remote users from being able "
2733 "to talk to the server at all. As open source projects started making read-"
2734 "only access available anonymously to anyone, people without commit privileges "
2735 "found that they could not use the tools to interact with a project in a "
2736 "natural way, as they could not record their changes."
2737 msgstr ""
2738 "第二代软件因为采用以网络为中心的结构,一次性管理整个项目而放松了这些限制。随着"
2739 "项目增长,又出现了新的问题。客户需要频繁的和服务器交互,服务器的可伸缩性成为大"
2740 "项目的主要问题。不可靠的网络会妨碍客户和服务器的交互。随着开源项目开始开放只读"
2741 "权限给匿名用户,没有提交权限的用户发现他们不能以自然的方式使用工具和项目交互,"
2742 "因为他们不能记录他们的修改。"
2744 #. type: Content of: <book><chapter><sect1><para>
2745 #: ../en/ch01-intro.xml:198
2746 msgid ""
2747 "The current generation of revision control tools is peer-to-peer in nature. "
2748 "All of these systems have dropped the dependency on a single central server, "
2749 "and allow people to distribute their revision control data to where it's "
2750 "actually needed. Collaboration over the Internet has moved from constrained "
2751 "by technology to a matter of choice and consensus. Modern tools can operate "
2752 "offline indefinitely and autonomously, with a network connection only needed "
2753 "when syncing changes with another repository."
2754 msgstr ""
2755 "新一代的版本控制工具本质上是点对点的。所有的这些系统都抛弃了对单个中央服务器的"
2756 "依赖,允许用户发布他们的版本控制数据到任何需要的地方。通过互联网的协作摆脱了技"
2757 "术的限制,走向选择和审查。现代的工具可以进行自治的,不受限制的离线操作。只需要"
2758 "在有网络的时候和其他的版本库同步即可。"
2760 #. type: Content of: <book><chapter><sect1><title>
2761 #: ../en/ch01-intro.xml:210
2762 msgid "A few of the advantages of distributed revision control"
2763 msgstr "分布版本控制的优点"
2765 #. type: Content of: <book><chapter><sect1><para>
2766 #: ../en/ch01-intro.xml:213
2767 msgid ""
2768 "Even though distributed revision control tools have for several years been as "
2769 "robust and usable as their previous-generation counterparts, people using "
2770 "older tools have not yet necessarily woken up to their advantages. There are "
2771 "a number of ways in which distributed tools shine relative to centralised "
2772 "ones."
2773 msgstr ""
2774 "与他们的上一代竞争者相比,虽然分布式版本控制工具多年来已经很稳定和实用了,但是"
2775 "使用旧的工具的人们还没有完全了解它们的优点,分布式的工具在很多方面明显由于集中"
2776 "式的工具。"
2778 #. type: Content of: <book><chapter><sect1><para>
2779 #: ../en/ch01-intro.xml:220
2780 msgid ""
2781 "For an individual developer, distributed tools are almost always much faster "
2782 "than centralised tools. This is for a simple reason: a centralised tool "
2783 "needs to talk over the network for many common operations, because most "
2784 "metadata is stored in a single copy on the central server. A distributed "
2785 "tool stores all of its metadata locally. All else being equal, talking over "
2786 "the network adds overhead to a centralised tool. Don't underestimate the "
2787 "value of a snappy, responsive tool: you're going to spend a lot of time "
2788 "interacting with your revision control software."
2789 msgstr ""
2790 "对于个人开发者,分布式工具几乎永远比集中式工具快的多。原因很简单:集中式工具的"
2791 "很多操作需要网络交互,因为大部分元数据都只在中央服务器上有一份拷贝。而一个分布"
2792 "式工具将所有的元数据保存在本地。其他的相同,通过网络的交互增加了集中式工具的负"
2793 "担。不要低估了反应迅速的工具的价值:你要花很多时间和你的版本控制软件交互。"
2795 #. type: Content of: <book><chapter><sect1><para>
2796 #: ../en/ch01-intro.xml:231
2797 msgid ""
2798 "Distributed tools are indifferent to the vagaries of your server "
2799 "infrastructure, again because they replicate metadata to so many locations. "
2800 "If you use a centralised system and your server catches fire, you'd better "
2801 "hope that your backup media are reliable, and that your last backup was "
2802 "recent and actually worked. With a distributed tool, you have many backups "
2803 "available on every contributor's computer."
2804 msgstr ""
2805 "分布式工具对你的服务器结构并不感冒,因为他们在将元数据复制到很多地方。如果你的"
2806 "集中式系统和你的服务器着火了,你最好希望你的备份介质是可靠的,同时你最后的备份"
2807 "是最近的,而且还能用。而对于分布式工具,你在贡献者的计算机上有很多备份。"
2809 #. type: Content of: <book><chapter><sect1><para>
2810 #: ../en/ch01-intro.xml:239
2811 msgid ""
2812 "The reliability of your network will affect distributed tools far less than "
2813 "it will centralised tools. You can't even use a centralised tool without a "
2814 "network connection, except for a few highly constrained commands. With a "
2815 "distributed tool, if your network connection goes down while you're working, "
2816 "you may not even notice. The only thing you won't be able to do is talk to "
2817 "repositories on other computers, something that is relatively rare compared "
2818 "with local operations. If you have a far-flung team of collaborators, this "
2819 "may be significant."
2820 msgstr ""
2821 "网络的可靠性对分布式工具的影响要远远小于集中式工具。如果没有网络你根本不能使用"
2822 "集中式工具,除了少数几个功能有限命令。而对于分布式工具,即使在你工作的时候网络"
2823 "瘫痪了,你可能根本不会注意到。你不能做的事情仅仅是不能和其它计算机上的版本库交"
2824 "互了,这种事在本地操作相当罕见。而如果你的团队有异地的人员,那这就很有可能了。"
2826 #. type: Content of: <book><chapter><sect1><sect2><title>
2827 #: ../en/ch01-intro.xml:250
2828 msgid "Advantages for open source projects"
2829 msgstr "开源项目的优点"
2831 #. type: Content of: <book><chapter><sect1><sect2><para>
2832 #: ../en/ch01-intro.xml:252
2833 msgid ""
2834 "If you take a shine to an open source project and decide that you would like "
2835 "to start hacking on it, and that project uses a distributed revision control "
2836 "tool, you are at once a peer with the people who consider themselves the "
2837 "<quote>core</quote> of that project. If they publish their repositories, you "
2838 "can immediately copy their project history, start making changes, and record "
2839 "your work, using the same tools in the same ways as insiders. By contrast, "
2840 "with a centralised tool, you must use the software in a <quote>read only</"
2841 "quote> mode unless someone grants you permission to commit changes to their "
2842 "central server. Until then, you won't be able to record changes, and your "
2843 "local modifications will be at risk of corruption any time you try to update "
2844 "your client's view of the repository."
2845 msgstr ""
2846 "如果你喜欢一个开源项目并且决定准备开始改进它,同时这个项目使用分布式版本控制工"
2847 "具的话,你立刻可以和其他人一样认为自己成为项目的<quote>核心</quote>。如果他们"
2848 "发布了他们的版本库,你可以立即拷贝他们的项目。开始修改,记录你自己的工作,和内"
2849 "部人员一样使用同样的工具。相比之下,如果使用集中式工具,除非有人给你向中央服务"
2850 "器提交修改的权限,你只能用只读的方式使用软件。这样,你就不能记录你的修改,而且"
2851 "当你从版本库更新的时候,本地的修改随时有崩溃的可能。 "
2853 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
2854 #: ../en/ch01-intro.xml:268
2855 msgid "The forking non-problem"
2856 msgstr "分叉不是问题"
2858 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
2859 #: ../en/ch01-intro.xml:270
2860 msgid ""
2861 "It has been suggested that distributed revision control tools pose some sort "
2862 "of risk to open source projects because they make it easy to <quote>fork</"
2863 "quote> the development of a project. A fork happens when there are "
2864 "differences in opinion or attitude between groups of developers that cause "
2865 "them to decide that they can't work together any longer. Each side takes a "
2866 "more or less complete copy of the project's source code, and goes off in its "
2867 "own direction."
2868 msgstr ""
2870 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
2871 #: ../en/ch01-intro.xml:280
2872 msgid ""
2873 "Sometimes the camps in a fork decide to reconcile their differences. With a "
2874 "centralised revision control system, the <emphasis>technical</emphasis> "
2875 "process of reconciliation is painful, and has to be performed largely by "
2876 "hand. You have to decide whose revision history is going to <quote>win</"
2877 "quote>, and graft the other team's changes into the tree somehow. This "
2878 "usually loses some or all of one side's revision history."
2879 msgstr ""
2881 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
2882 #: ../en/ch01-intro.xml:289
2883 msgid ""
2884 "What distributed tools do with respect to forking is they make forking the "
2885 "<emphasis>only</emphasis> way to develop a project. Every single change that "
2886 "you make is potentially a fork point. The great strength of this approach is "
2887 "that a distributed revision control tool has to be really good at "
2888 "<emphasis>merging</emphasis> forks, because forks are absolutely fundamental: "
2889 "they happen all the time."
2890 msgstr ""
2892 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
2893 #: ../en/ch01-intro.xml:298
2894 msgid ""
2895 "If every piece of work that everybody does, all the time, is framed in terms "
2896 "of forking and merging, then what the open source world refers to as a "
2897 "<quote>fork</quote> becomes <emphasis>purely</emphasis> a social issue. If "
2898 "anything, distributed tools <emphasis>lower</emphasis> the likelihood of a "
2899 "fork:"
2900 msgstr ""
2902 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
2903 #: ../en/ch01-intro.xml:305
2904 msgid ""
2905 "They eliminate the social distinction that centralised tools impose: that "
2906 "between insiders (people with commit access) and outsiders (people without)."
2907 msgstr ""
2909 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
2910 #: ../en/ch01-intro.xml:309
2911 msgid ""
2912 "They make it easier to reconcile after a social fork, because all that's "
2913 "involved from the perspective of the revision control software is just "
2914 "another merge."
2915 msgstr ""
2917 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
2918 #: ../en/ch01-intro.xml:314
2919 msgid ""
2920 "Some people resist distributed tools because they want to retain tight "
2921 "control over their projects, and they believe that centralised tools give "
2922 "them this control. However, if you're of this belief, and you publish your "
2923 "CVS or Subversion repositories publicly, there are plenty of tools available "
2924 "that can pull out your entire project's history (albeit slowly) and recreate "
2925 "it somewhere that you don't control. So while your control in this case is "
2926 "illusory, you are forgoing the ability to fluidly collaborate with whatever "
2927 "people feel compelled to mirror and fork your history."
2928 msgstr ""
2929 "有些人拒绝分布式工具因为他们想保持对项目的控制,他们相信集中式工具会给他们这种"
2930 "控制。如果你这种想法,并你将CVS或者Subversion版本库向大众发布了,那么别人可用"
2931 "现有的很多工具将整个项目的历史抓取出来(可能很慢),在其它你控制不了的地方重建"
2932 "版本库。这时你的控制只不过是一种幻觉罢了,一些人被迫从你的版本库创建映像和分"
2933 "支,而你失去了和他们协作的机会。"
2935 #. type: Content of: <book><chapter><sect1><sect2><title>
2936 #: ../en/ch01-intro.xml:329
2937 msgid "Advantages for commercial projects"
2938 msgstr "商业项目的优点"
2940 #. type: Content of: <book><chapter><sect1><sect2><para>
2941 #: ../en/ch01-intro.xml:331
2942 msgid ""
2943 "Many commercial projects are undertaken by teams that are scattered across "
2944 "the globe. Contributors who are far from a central server will see slower "
2945 "command execution and perhaps less reliability. Commercial revision control "
2946 "systems attempt to ameliorate these problems with remote-site replication add-"
2947 "ons that are typically expensive to buy and cantankerous to administer. A "
2948 "distributed system doesn't suffer from these problems in the first place. "
2949 "Better yet, you can easily set up multiple authoritative servers, say one per "
2950 "site, so that there's no redundant communication between repositories over "
2951 "expensive long-haul network links."
2952 msgstr ""
2953 "遍布全球的团队正在进行许多商业项目。远离中央服务器的贡献者会发现执行命令速度很"
2954 "慢同时不怎么可靠。商业的版本控制系统改善这个问题的办法就是让你购买远程复制插"
2955 "件,这通常很昂贵,并且很难管理。分布式系统首先不会有这样的问题。其次,你可以很"
2956 "容易的建立多个授权服务器,假设每个站点一个,这样可以避免在昂贵的长途线路上的冗"
2957 "余的通讯。"
2959 #. type: Content of: <book><chapter><sect1><sect2><para>
2960 #: ../en/ch01-intro.xml:343
2961 msgid ""
2962 "Centralised revision control systems tend to have relatively low "
2963 "scalability. It's not unusual for an expensive centralised system to fall "
2964 "over under the combined load of just a few dozen concurrent users. Once "
2965 "again, the typical response tends to be an expensive and clunky replication "
2966 "facility. Since the load on a central server&emdash;if you have one at "
2967 "all&emdash;is many times lower with a distributed tool (because all of the "
2968 "data is replicated everywhere), a single cheap server can handle the needs of "
2969 "a much larger team, and replication to balance load becomes a simple matter "
2970 "of scripting."
2971 msgstr ""
2972 "集中式的版本控制系统的扩展性相对较低。只要不多的并行用户的组合负载就可以将一个"
2973 "昂贵的中央服务器压垮。同样,典型的反应就是昂贵笨重的复制设备。因为中央服务器的"
2974 "最大负载&emdash;如果你有的话&emdash;比分布式工具低很多(因为所有的数据要北复制"
2975 "到其它地方),一个廉价的服务器就可以满足一个相当大的团队的要求,为平衡负载而进"
2976 "行的复制只需要简单的脚本就够了。"
2978 #. type: Content of: <book><chapter><sect1><sect2><para>
2979 #: ../en/ch01-intro.xml:355
2980 msgid ""
2981 "If you have an employee in the field, troubleshooting a problem at a "
2982 "customer's site, they'll benefit from distributed revision control. The tool "
2983 "will let them generate custom builds, try different fixes in isolation from "
2984 "each other, and search efficiently through history for the sources of bugs "
2985 "and regressions in the customer's environment, all without needing to connect "
2986 "to your company's network."
2987 msgstr ""
2988 "如果你有员工需要在客户方解决问题,那么他们会受益于分布式版本控制。工具允许他们"
2989 "创建定制的环境,互相独立的尝试不同的解决方案。并且可以高效的从历史代码中查找"
2990 "bug的根源,在客户环境中进行回归,所有的这些都不需要连接公司的网络。"
2992 #. type: Content of: <book><chapter><sect1><title>
2993 #: ../en/ch01-intro.xml:366
2994 msgid "Why choose Mercurial?"
2995 msgstr "为什么选择 Mercurial?"
2997 #. type: Content of: <book><chapter><sect1><para>
2998 #: ../en/ch01-intro.xml:368
2999 msgid ""
3000 "Mercurial has a unique set of properties that make it a particularly good "
3001 "choice as a revision control system."
3002 msgstr "Mercurial是一个非常好的版本控制系统,因为它有很多独一无二的特点。"
3004 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
3005 #: ../en/ch01-intro.xml:371
3006 msgid "It is easy to learn and use."
3007 msgstr "它易学易用。"
3009 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
3010 #: ../en/ch01-intro.xml:372
3011 msgid "It is lightweight."
3012 msgstr "它轻量级。"
3014 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
3015 #: ../en/ch01-intro.xml:373
3016 msgid "It scales excellently."
3017 msgstr "它扩展性很好。"
3019 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
3020 #: ../en/ch01-intro.xml:374
3021 msgid "It is easy to customise."
3022 msgstr "它很容易定制。"
3024 #. type: Content of: <book><chapter><sect1><para>
3025 #: ../en/ch01-intro.xml:377
3026 msgid ""
3027 "If you are at all familiar with revision control systems, you should be able "
3028 "to get up and running with Mercurial in less than five minutes. Even if not, "
3029 "it will take no more than a few minutes longer. Mercurial's command and "
3030 "feature sets are generally uniform and consistent, so you can keep track of a "
3031 "few general rules instead of a host of exceptions."
3032 msgstr ""
3033 "如果你熟悉版本控制系统,你在五分钟之内只能就可以使用Mercurial工作了。即使你不"
3034 "熟悉,也不过是再多花几分钟。Mercurial的命令和功能集非常统一一致,你只要遵守几"
3035 "个通用的规则就够了,很少有例外。"
3037 #. type: Content of: <book><chapter><sect1><para>
3038 #: ../en/ch01-intro.xml:384
3039 msgid ""
3040 "On a small project, you can start working with Mercurial in moments. Creating "
3041 "new changes and branches; transferring changes around (whether locally or "
3042 "over a network); and history and status operations are all fast. Mercurial "
3043 "attempts to stay nimble and largely out of your way by combining low "
3044 "cognitive overhead with blazingly fast operations."
3045 msgstr ""
3046 "在很小的项目上,你马上就可以使用Mercurial开始工作。创建新的修改和分支;到处交"
3047 "换修改(不管本机还是通过网络);获取历史和状态数据非常快。Mercurial努力保持小"
3048 "巧灵活,在眨眼之间就能完成操作。"
3050 #. type: Content of: <book><chapter><sect1><para>
3051 #: ../en/ch01-intro.xml:391
3052 msgid ""
3053 "The usefulness of Mercurial is not limited to small projects: it is used by "
3054 "projects with hundreds to thousands of contributors, each containing tens of "
3055 "thousands of files and hundreds of megabytes of source code."
3056 msgstr ""
3057 "不仅小的项目可以使用Mercurial:有成百上千的贡献者的项目也在使用它,这些项目每"
3058 "个都有上万个文件和几百兆的源码。"
3060 #. type: Content of: <book><chapter><sect1><para>
3061 #: ../en/ch01-intro.xml:396
3062 msgid ""
3063 "If the core functionality of Mercurial is not enough for you, it's easy to "
3064 "build on. Mercurial is well suited to scripting tasks, and its clean "
3065 "internals and implementation in Python make it easy to add features in the "
3066 "form of extensions. There are a number of popular and useful extensions "
3067 "already available, ranging from helping to identify bugs to improving "
3068 "performance."
3069 msgstr ""
3070 "如果觉得Mercurial的核心功能不能满足要求,你很容易在现有基础上开发。Mercurial非"
3071 "常适合于脚本任务,它的核心简洁,并且用Python实现,用扩展的方式增加新的功能非常"
3072 "方便,现在已经有很多流行和有用的扩展了,像帮助你确定bug或者提高性能等。"
3074 #. type: Content of: <book><chapter><sect1><title>
3075 #: ../en/ch01-intro.xml:406
3076 msgid "Mercurial compared with other tools"
3077 msgstr "Mercurial 与其它工具的比较"
3079 #. type: Content of: <book><chapter><sect1><para>
3080 #: ../en/ch01-intro.xml:408
3081 msgid ""
3082 "Before you read on, please understand that this section necessarily reflects "
3083 "my own experiences, interests, and (dare I say it) biases. I have used every "
3084 "one of the revision control tools listed below, in most cases for several "
3085 "years at a time."
3086 msgstr ""
3087 "在你继续阅读之前,请理解本节完全反映了我的个人经验,兴趣,和偏好(我敢说)。下"
3088 "面列的每个版本控制工具我都使用过,大多数情况下都用过好几年。"
3090 #. type: Content of: <book><chapter><sect1><sect2><para>
3091 #: ../en/ch01-intro.xml:418
3092 msgid ""
3093 "Subversion is a popular revision control tool, developed to replace CVS. It "
3094 "has a centralised client/server architecture."
3095 msgstr ""
3096 "Subversion是一个流行的版本控制工具,是用来替代CVS的,它采用的是集中式的客户/服"
3097 "务器结构。"
3099 #. type: Content of: <book><chapter><sect1><sect2><para>
3100 #: ../en/ch01-intro.xml:422
3101 msgid ""
3102 "Subversion and Mercurial have similarly named commands for performing the "
3103 "same operations, so if you're familiar with one, it is easy to learn to use "
3104 "the other. Both tools are portable to all popular operating systems."
3105 msgstr ""
3106 "Subversion和Mercurial相同操作的命令的命名上非常相似,所以如果你熟悉一个,很容"
3107 "易学会另外一个,两个工具都可以在大多数平台上运行。"
3109 #. type: Content of: <book><chapter><sect1><sect2><para>
3110 #: ../en/ch01-intro.xml:427
3111 msgid ""
3112 "Prior to version 1.5, Subversion had no useful support for merges. At the "
3113 "time of writing, its merge tracking capability is new, and known to be <ulink "
3114 "url=\"http://svnbook.red-bean.com/nightly/en/svn.branchmerge.advanced."
3115 "html#svn.branchmerge.advanced.finalword\">complicated and buggy</ulink>."
3116 msgstr ""
3117 "在1.5版之前,Subversion对合并的支持并不好。在我写本书的时候,它刚新增了并跟踪"
3118 "的功能,出名的<ulink url=\"http://svnbook.red-bean.com/nightly/en/svn."
3119 "branchmerge.advanced.html#svn.branchmerge.advanced.finalword\">复杂和容易出错"
3120 "</ulink>。"
3122 #. type: Content of: <book><chapter><sect1><sect2><para>
3123 #: ../en/ch01-intro.xml:433
3124 msgid ""
3125 "Mercurial has a substantial performance advantage over Subversion on every "
3126 "revision control operation I have benchmarked. I have measured its advantage "
3127 "as ranging from a factor of two to a factor of six when compared with "
3128 "Subversion 1.4.3's <emphasis>ra_local</emphasis> file store, which is the "
3129 "fastest access method available. In more realistic deployments involving a "
3130 "network-based store, Subversion will be at a substantially larger "
3131 "disadvantage. Because many Subversion commands must talk to the server and "
3132 "Subversion does not have useful replication facilities, server capacity and "
3133 "network bandwidth become bottlenecks for modestly large projects."
3134 msgstr ""
3135 "在我测量过的每个版本控制操作上Mercurial都比Subversion有很大的性能优势。差距从"
3136 "两个数量级到六个数量级不等,我用的是Subversion 1.4.3的<emphasis>ra_local</"
3137 "emphasis>文件存储方式,这是已知的最快的存取方式了。在实际的部署中包括网络存"
3138 "储,那么Subversion的劣势更大。因为很多Subversion命令必须和主机交互,并且因为"
3139 "Subversion没有好的复制机制,使得对于中的等大小的项目而言,服务器容量和网络带宽"
3140 "成为主要瓶颈。"
3142 #. type: Content of: <book><chapter><sect1><sect2><para>
3143 #: ../en/ch01-intro.xml:446
3144 msgid ""
3145 "Additionally, Subversion incurs substantial storage overhead to avoid network "
3146 "transactions for a few common operations, such as finding modified files "
3147 "(<literal>status</literal>) and displaying modifications against the current "
3148 "revision (<literal>diff</literal>). As a result, a Subversion working copy "
3149 "is often the same size as, or larger than, a Mercurial repository and working "
3150 "directory, even though the Mercurial repository contains a complete history "
3151 "of the project."
3152 msgstr ""
3153 "另外,Subversion以在客户端使用了更多存储空间的方法,换取降低几个常用操作的网络"
3154 "负载,例如查找修改过的文件(<literal>status</literal>)和显示对于当前版本的更"
3155 "改(<literal>diff</literal>)。结果Subversion的工作副本经常和Mercurial的版本库"
3156 "和工作目录一样大,或者更大,虽然Mercurial的版本库包括了项目的完整历史。"
3158 #. type: Content of: <book><chapter><sect1><sect2><para>
3159 #: ../en/ch01-intro.xml:456
3160 msgid ""
3161 "Subversion is widely supported by third party tools. Mercurial currently "
3162 "lags considerably in this area. This gap is closing, however, and indeed "
3163 "some of Mercurial's GUI tools now outshine their Subversion equivalents. "
3164 "Like Mercurial, Subversion has an excellent user manual."
3165 msgstr ""
3166 "Subversion有很多的第三方工具支持。Mercurial现在在这方面稍微欠缺。然而差距正在"
3167 "逐渐缩小,实际上一些有Mercurial的GUI工具比Subversion类似工具还略胜一筹。和"
3168 "Mercurial一样,Subversion也有完善的用户手册。"
3170 #. type: Content of: <book><chapter><sect1><sect2><para>
3171 #: ../en/ch01-intro.xml:462
3172 msgid ""
3173 "Because Subversion doesn't store revision history on the client, it is well "
3174 "suited to managing projects that deal with lots of large, opaque binary "
3175 "files. If you check in fifty revisions to an incompressible 10MB file, "
3176 "Subversion's client-side space usage stays constant The space used by any "
3177 "distributed SCM will grow rapidly in proportion to the number of revisions, "
3178 "because the differences between each revision are large."
3179 msgstr ""
3180 "Subversion并不在客户端存储版本历史,所以它很适合管理那些有很多大的二进制文件的"
3181 "项目。如果你对一个未压缩的10MB文件检入了五十次,Subversion客户端的占用的磁盘空"
3182 "间基本上保持不变。而对于分布式SCM软件,磁盘空间会随着版本数量的增加成而迅速增"
3183 "长,因为每个版本之间的差异非常大。"
3185 #. type: Content of: <book><chapter><sect1><sect2><para>
3186 #: ../en/ch01-intro.xml:471
3187 msgid ""
3188 "In addition, it's often difficult or, more usually, impossible to merge "
3189 "different versions of a binary file. Subversion's ability to let a user lock "
3190 "a file, so that they temporarily have the exclusive right to commit changes "
3191 "to it, can be a significant advantage to a project where binary files are "
3192 "widely used."
3193 msgstr ""
3194 "另外,合并不同版本的二进制文件非常困难,换句话说,基本上不可能。Subversion提供"
3195 "了锁定功能,用户可以锁定一个文件,这样他就取得了对这个文件临时的独占的提交权,"
3196 "这对于广泛使用二进制文件的项目而言是个明显优势。"
3198 #. type: Content of: <book><chapter><sect1><sect2><para>
3199 #: ../en/ch01-intro.xml:478
3200 msgid ""
3201 "Mercurial can import revision history from a Subversion repository. It can "
3202 "also export revision history to a Subversion repository. This makes it easy "
3203 "to <quote>test the waters</quote> and use Mercurial and Subversion in "
3204 "parallel before deciding to switch. History conversion is incremental, so "
3205 "you can perform an initial conversion, then small additional conversions "
3206 "afterwards to bring in new changes."
3207 msgstr ""
3208 "Mercurial可以从Subversion的版本库中导入历史版本。它也可以向Subversion的版本库"
3209 "输出历史版本。这样在决定转换之前很容易先<quote>试一下水</quote>,同时并行的使"
3210 "用Mercurial和Subversion。版本史的转换是递增的,你可以先构造一个初始版本,每次"
3211 "有了新的更改后加入一个小的转换。"
3213 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
3214 #: ../en/ch01-intro.xml:490 ../en/ch01-intro.xml:629
3215 msgid "Git"
3216 msgstr "Git"
3218 #. type: Content of: <book><chapter><sect1><sect2><para>
3219 #: ../en/ch01-intro.xml:492
3220 msgid ""
3221 "Git is a distributed revision control tool that was developed for managing "
3222 "the Linux kernel source tree. Like Mercurial, its early design was somewhat "
3223 "influenced by Monotone."
3224 msgstr ""
3225 "Git是为了管理Linux内核代码而开发的一个分布式版本控制工具。它和Mercurial一样在"
3226 "设计上受了Monotone的影响。"
3228 #. type: Content of: <book><chapter><sect1><sect2><para>
3229 #: ../en/ch01-intro.xml:497
3230 msgid ""
3231 "Git has a very large command set, with version 1.5.0 providing 139 individual "
3232 "commands. It has something of a reputation for being difficult to learn. "
3233 "Compared to Git, Mercurial has a strong focus on simplicity."
3234 msgstr ""
3235 "Git有非常大的命令集,1.5.0版本提供了139个单独的命令。它以难学而闻名于世。与Git"
3236 "相比,Mercurial力求简洁。"
3238 #. type: Content of: <book><chapter><sect1><sect2><para>
3239 #: ../en/ch01-intro.xml:502
3240 msgid ""
3241 "In terms of performance, Git is extremely fast. In several cases, it is "
3242 "faster than Mercurial, at least on Linux, while Mercurial performs better on "
3243 "other operations. However, on Windows, the performance and general level of "
3244 "support that Git provides is, at the time of writing, far behind that of "
3245 "Mercurial."
3246 msgstr ""
3247 "就性能而言,Git非常快。在很多情况下它都比Mercurial快,至少是在Linux上,但"
3248 "Mercurial在其它操作上有优势。而在Windows上,Git不管是性能还是提供的支持,都比"
3249 "Mercurial差很多,至少在本书写作的时候是这样。"
3251 #. type: Content of: <book><chapter><sect1><sect2><para>
3252 #: ../en/ch01-intro.xml:509
3253 msgid ""
3254 "While a Mercurial repository needs no maintenance, a Git repository requires "
3255 "frequent manual <quote>repacks</quote> of its metadata. Without these, "
3256 "performance degrades, while space usage grows rapidly. A server that "
3257 "contains many Git repositories that are not rigorously and frequently "
3258 "repacked will become heavily disk-bound during backups, and there have been "
3259 "instances of daily backups taking far longer than 24 hours as a result. A "
3260 "freshly packed Git repository is slightly smaller than a Mercurial "
3261 "repository, but an unpacked repository is several orders of magnitude larger."
3262 msgstr ""
3263 "Mercurial的版本库不需要维护,但Git的版本库需要频繁的手工维护,将其元数据"
3264 "<quote>repacks</quote>,如果不这样做,性能就会下降,磁盘空间也会迅速增加。有多"
3265 "个Git版本库的服务器需要严格和频繁的重新打包,否则在备份的时候就会成为严重的瓶"
3266 "颈,曾经有过运行每日备份超过24小时的例子。一个新打包的Git版本库比Mercurial稍小"
3267 "一些,但是未打包的版本库则会大几个数量级。"
3269 #. type: Content of: <book><chapter><sect1><sect2><para>
3270 #: ../en/ch01-intro.xml:520
3271 msgid ""
3272 "The core of Git is written in C. Many Git commands are implemented as shell "
3273 "or Perl scripts, and the quality of these scripts varies widely. I have "
3274 "encountered several instances where scripts charged along blindly in the "
3275 "presence of errors that should have been fatal."
3276 msgstr ""
3277 "Git的核心由C语言编写,许多Git命令是用shell或者perl脚本实现的,这些脚本的质量差"
3278 "别很大。我碰到过好几次这样的情况,明明已经出现了致命错误了,脚本还在盲目的执"
3279 "行。"
3281 #. type: Content of: <book><chapter><sect1><sect2><para>
3282 #: ../en/ch01-intro.xml:526
3283 msgid "Mercurial can import revision history from a Git repository."
3284 msgstr "Mercurial可以从Git的版本库中导入版本历史。"
3286 #. type: Content of: <book><chapter><sect1><sect2><para>
3287 #: ../en/ch01-intro.xml:534
3288 msgid ""
3289 "CVS is probably the most widely used revision control tool in the world. Due "
3290 "to its age and internal untidiness, it has been only lightly maintained for "
3291 "many years."
3292 msgstr ""
3293 "CVS可能是世界上使用最广泛的版本控制工具。因为它是太古老和内部实现很混乱,许多"
3294 "年来都处于维护状态。"
3296 #. type: Content of: <book><chapter><sect1><sect2><para>
3297 #: ../en/ch01-intro.xml:538
3298 msgid ""
3299 "It has a centralised client/server architecture. It does not group related "
3300 "file changes into atomic commits, making it easy for people to <quote>break "
3301 "the build</quote>: one person can successfully commit part of a change and "
3302 "then be blocked by the need for a merge, causing other people to see only a "
3303 "portion of the work they intended to do. This also affects how you work with "
3304 "project history. If you want to see all of the modifications someone made as "
3305 "part of a task, you will need to manually inspect the descriptions and "
3306 "timestamps of the changes made to each file involved (if you even know what "
3307 "those files were)."
3308 msgstr ""
3309 "CVS采用的是集中式客户/服务器结构。它不会将相关的文件变更一起作为原子提交,这使"
3310 "得它很容易<quote>破坏构建</quote>:一个人成功的提交了一部分更改,然后要停下来"
3311 "处理合并,这使得其他人只能看见他们的部分工作。这样也会影响你和项目历史的工作方"
3312 "式。如果你想看到其他人针对他的那部分任务做的全部修改,你必须手动检查每个受影响"
3313 "的文件的变更描述和时间戳(假如你知道是哪些文件)。"
3315 #. type: Content of: <book><chapter><sect1><sect2><para>
3316 #: ../en/ch01-intro.xml:550
3317 msgid ""
3318 "CVS has a muddled notion of tags and branches that I will not attempt to even "
3319 "describe. It does not support renaming of files or directories well, making "
3320 "it easy to corrupt a repository. It has almost no internal consistency "
3321 "checking capabilities, so it is usually not even possible to tell whether or "
3322 "how a repository is corrupt. I would not recommend CVS for any project, "
3323 "existing or new."
3324 msgstr ""
3325 "CVS的分支和标签的概念实在是太混乱了,我都不想给你介绍。它也不支持文件和目录的"
3326 "重命名。这使得版本库非常容易崩溃。它几乎没任何的内部一致性检查功能,所以通常你"
3327 "不可能知道版本库是不是崩溃了。不管是新项目还是老项目,我都不推荐使用CVS。"
3329 #. type: Content of: <book><chapter><sect1><sect2><para>
3330 #: ../en/ch01-intro.xml:558
3331 msgid ""
3332 "Mercurial can import CVS revision history. However, there are a few caveats "
3333 "that apply; these are true of every other revision control tool's CVS "
3334 "importer, too. Due to CVS's lack of atomic changes and unversioned "
3335 "filesystem hierarchy, it is not possible to reconstruct CVS history "
3336 "completely accurately; some guesswork is involved, and renames will usually "
3337 "not show up. Because a lot of advanced CVS administration has to be done by "
3338 "hand and is hence error-prone, it's common for CVS importers to run into "
3339 "multiple problems with corrupted repositories (completely bogus revision "
3340 "timestamps and files that have remained locked for over a decade are just two "
3341 "of the less interesting problems I can recall from personal experience)."
3342 msgstr ""
3343 "Mercurial可以导入CVS的版本历史。然而,这里面有很多限制;对其版本控制工具的CVS"
3344 "导入程序也是一样。因为CVS缺少原子更改并且不支持文件系统层次的版本控制,所以不"
3345 "可能完全精确的重建CVS的历史。有些需要猜测,重命名通常发现不了。因为CVS的很多的"
3346 "高级管理功能必须手动完成,因此非常容易出错。碰到崩溃的版本库,CVS导入程序通常"
3347 "会出现很多问题(完全伪造的版本时间戳,若干文件被锁定十多年,这是我个人经历的两"
3348 "个不太有趣的问题)。"
3350 #. type: Content of: <book><chapter><sect1><sect2><para>
3351 #: ../en/ch01-intro.xml:572
3352 msgid "Mercurial can import revision history from a CVS repository."
3353 msgstr "Mercurial可以从CVS版本库导入版本历史。"
3355 #. type: Content of: <book><chapter><sect1><sect2><title>
3356 #: ../en/ch01-intro.xml:578
3357 msgid "Commercial tools"
3358 msgstr "商业工具"
3360 #. type: Content of: <book><chapter><sect1><sect2><para>
3361 #: ../en/ch01-intro.xml:580
3362 msgid ""
3363 "Perforce has a centralised client/server architecture, with no client-side "
3364 "caching of any data. Unlike modern revision control tools, Perforce requires "
3365 "that a user run a command to inform the server about every file they intend "
3366 "to edit."
3367 msgstr ""
3368 "Perforce采用的是集中式客户/服务器结构,客户端不缓存任何数据。和现代的版本控制"
3369 "工具不同,每次想要编辑的一个文件,用户必须运行一个命令通知Perforce服务器。"
3371 #. type: Content of: <book><chapter><sect1><sect2><para>
3372 #: ../en/ch01-intro.xml:586
3373 msgid ""
3374 "The performance of Perforce is quite good for small teams, but it falls off "
3375 "rapidly as the number of users grows beyond a few dozen. Modestly large "
3376 "Perforce installations require the deployment of proxies to cope with the "
3377 "load their users generate."
3378 msgstr ""
3379 "对于小的团队而言,Perforce相当好,但是当用户数目超过数十个以后,性能急剧下降。"
3380 "中等大小Perforce安装需要部署代理来处理用户产生的负载。"
3382 #. type: Content of: <book><chapter><sect1><sect2><title>
3383 #: ../en/ch01-intro.xml:595
3384 msgid "Choosing a revision control tool"
3385 msgstr "选择版本控制工具"
3387 #. type: Content of: <book><chapter><sect1><sect2><para>
3388 #: ../en/ch01-intro.xml:597
3389 msgid ""
3390 "With the exception of CVS, all of the tools listed above have unique "
3391 "strengths that suit them to particular styles of work. There is no single "
3392 "revision control tool that is best in all situations."
3393 msgstr ""
3394 "除了CVS之外,以上列出的所有工具都各有所长,没有一个版本控制工具适合所有情况。"
3396 #. type: Content of: <book><chapter><sect1><sect2><para>
3397 #: ../en/ch01-intro.xml:602
3398 msgid ""
3399 "As an example, Subversion is a good choice for working with frequently edited "
3400 "binary files, due to its centralised nature and support for file locking."
3401 msgstr ""
3402 "比如说,因为采用集中式的结构并且支持文件锁定,Subversion非常适合频繁编辑二进制"
3403 "文件的场合。"
3405 #. type: Content of: <book><chapter><sect1><sect2><para>
3406 #: ../en/ch01-intro.xml:606
3407 msgid ""
3408 "I personally find Mercurial's properties of simplicity, performance, and good "
3409 "merge support to be a compelling combination that has served me well for "
3410 "several years."
3411 msgstr ""
3412 "我已经使用Mercurial很多年了,个人认为它有简洁,高性能,良好的合并支持诸多特"
3413 "点。"
3415 #. type: Content of: <book><chapter><sect1><title>
3416 #: ../en/ch01-intro.xml:614
3417 msgid "Switching from another tool to Mercurial"
3418 msgstr "从其它工具切换到 Mercurial"
3420 #. type: Content of: <book><chapter><sect1><para>
3421 #: ../en/ch01-intro.xml:616
3422 msgid ""
3423 "Mercurial is bundled with an extension named <literal role=\"hg-ext"
3424 "\">convert</literal>, which can incrementally import revision history from "
3425 "several other revision control tools. By <quote>incremental</quote>, I mean "
3426 "that you can convert all of a project's history to date in one go, then rerun "
3427 "the conversion later to obtain new changes that happened after the initial "
3428 "conversion."
3429 msgstr ""
3430 "Mercurial包括一个叫<literal role=\"hg-ext\">convert</literal>的扩展,它可以递"
3431 "增的从几个其他的版本控制工具导入版本历史。 <quote>增量</quote>的意思是你可以在"
3432 "某天将整个项目历史转换,以后再次进行转换获得初始版本以后新增的变更。"
3434 #. type: Content of: <book><chapter><sect1><para>
3435 #: ../en/ch01-intro.xml:624
3436 msgid ""
3437 "The revision control tools supported by <literal role=\"hg-ext\">convert</"
3438 "literal> are as follows:"
3439 msgstr "<literal role=\"hg-ext\">convert</literal> 支持的版本控制工具有:"
3441 #. type: Content of: <book><chapter><sect1><para>
3442 #: ../en/ch01-intro.xml:632
3443 msgid ""
3444 "In addition, <literal role=\"hg-ext\">convert</literal> can export changes "
3445 "from Mercurial to Subversion. This makes it possible to try Subversion and "
3446 "Mercurial in parallel before committing to a switchover, without risking the "
3447 "loss of any work."
3448 msgstr ""
3449 "另外<literal role=\"hg-ext\">convert</literal>可以从Mercurial向Subversion导出"
3450 "历史,这可以让你在切换之前让Mercurial和Subversion并行工作,而不会丢失任何工"
3451 "作。"
3453 #. type: Content of: <book><chapter><sect1><para>
3454 #: ../en/ch01-intro.xml:638
3455 msgid ""
3456 "The <command role=\"hg-ext-convert\">convert</command> command is easy to "
3457 "use. Simply point it at the path or URL of the source repository, optionally "
3458 "give it the name of the destination repository, and it will start working. "
3459 "After the initial conversion, just run the same command again to import new "
3460 "changes."
3461 msgstr ""
3462 "<command role=\"hg-ext-convert\">convert</command>命令非常简单。只要给出源版本"
3463 "库的URL或者路径,给出目标版本库的名称(可选),它就开始工作了。第一次转换之"
3464 "后,只要运行同样的命令就可以导入新的变更。"
3466 #. type: Content of: <book><chapter><sect1><title>
3467 #: ../en/ch01-intro.xml:647
3468 msgid "A short history of revision control"
3469 msgstr "版本控制简史"
3471 #. type: Content of: <book><chapter><sect1><para>
3472 #: ../en/ch01-intro.xml:649
3473 msgid ""
3474 "The best known of the old-time revision control tools is SCCS (Source Code "
3475 "Control System), which Marc Rochkind wrote at Bell Labs, in the early 1970s. "
3476 "SCCS operated on individual files, and required every person working on a "
3477 "project to have access to a shared workspace on a single system. Only one "
3478 "person could modify a file at any time; arbitration for access to files was "
3479 "via locks. It was common for people to lock files, and later forget to "
3480 "unlock them, preventing anyone else from modifying those files without the "
3481 "help of an administrator."
3482 msgstr ""
3483 "最有名史前的版本控制工具是SCCS(源代码控制系统),它是由Marc Rochkind于七十年"
3484 "代在贝尔实验室完成的。SCCS只能控制单个文件,这就要求项目组人员只能使用一个系统"
3485 "上的共享工作空间。任何时候一个文件只能由一个人修改;通过加锁来保证。人们很容易"
3486 "锁定一个文件,然后忘了解锁,没有管理员的帮助,任何人都不能修改那些文件。"
3488 #. type: Content of: <book><chapter><sect1><para>
3489 #: ../en/ch01-intro.xml:660
3490 msgid ""
3491 "Walter Tichy developed a free alternative to SCCS in the early 1980s; he "
3492 "called his program RCS (Revision Control System). Like SCCS, RCS required "
3493 "developers to work in a single shared workspace, and to lock files to prevent "
3494 "multiple people from modifying them simultaneously."
3495 msgstr ""
3496 "Walter Tichy在八十年代早期开发了一个开源的SCCS替代软件;他称之RCS(版本控制系"
3497 "统)。和SCCS一样,RCS要求开发人员在一个共享的工作空间工作,同时锁定文件,以防"
3498 "止多个人他同时修改。"
3500 #. type: Content of: <book><chapter><sect1><para>
3501 #: ../en/ch01-intro.xml:666
3502 msgid ""
3503 "Later in the 1980s, Dick Grune used RCS as a building block for a set of "
3504 "shell scripts he initially called cmt, but then renamed to CVS (Concurrent "
3505 "Versions System). The big innovation of CVS was that it let developers work "
3506 "simultaneously and somewhat independently in their own personal workspaces. "
3507 "The personal workspaces prevented developers from stepping on each other's "
3508 "toes all the time, as was common with SCCS and RCS. Each developer had a copy "
3509 "of every project file, and could modify their copies independently. They had "
3510 "to merge their edits prior to committing changes to the central repository."
3511 msgstr ""
3512 "八十年代后期,Dick Grune在RCS的基础上开发了一套脚本,他开始称之为cmt,后来又改"
3513 "名为CVS(并行版本系统)。CVS的最大的创新在于让开发人员可以在自己的工作空间里同"
3514 "时而且独立的工作。私人的工作空间防止了开发人员总是互相干扰,这在SCCS和RCS的使"
3515 "用中很常见。项目中的每个文件,开发者都有自己的拷贝,可以独立的修改自己的拷贝。"
3516 "他们可以在提交到中央版本库之前合并更改。"
3518 #. type: Content of: <book><chapter><sect1><para>
3519 #: ../en/ch01-intro.xml:677
3520 msgid ""
3521 "Brian Berliner took Grune's original scripts and rewrote them in C, releasing "
3522 "in 1989 the code that has since developed into the modern version of CVS. "
3523 "CVS subsequently acquired the ability to operate over a network connection, "
3524 "giving it a client/server architecture. CVS's architecture is centralised; "
3525 "only the server has a copy of the history of the project. Client workspaces "
3526 "just contain copies of recent versions of the project's files, and a little "
3527 "metadata to tell them where the server is. CVS has been enormously "
3528 "successful; it is probably the world's most widely used revision control "
3529 "system."
3530 msgstr ""
3531 "Brian Berliner接管了Grune的脚本,用C重写了一遍,并在1989年发布了这些代码,现在"
3532 "的CVS就是从那时逐渐发展起来的。CVS随后增加了网络的功能,形成了客户/服务器结"
3533 "构。CVS的结构是集中式的;仅在服务器上保存一份项目的历史拷贝。客户工作空间仅包"
3534 "含项目中的文件的最近版本的拷贝,一些元数据告诉它们服务器的地址。CVS获得了极大"
3535 "成功;它可能是世界上应用最广泛的版本控制系统。"
3537 #. type: Content of: <book><chapter><sect1><para>
3538 #: ../en/ch01-intro.xml:688
3539 msgid ""
3540 "In the early 1990s, Sun Microsystems developed an early distributed revision "
3541 "control system, called TeamWare. A TeamWare workspace contains a complete "
3542 "copy of the project's history. TeamWare has no notion of a central "
3543 "repository. (CVS relied upon RCS for its history storage; TeamWare used "
3544 "SCCS.)"
3545 msgstr ""
3546 "90年代早期,Sun公司开发了一个早期的分布式版本控制系统,叫做TeamWeare。TeamWare"
3547 "的工作空间包括项目历史的完整拷贝。TeamWare没有中央版本库的概念。(CVS使用RCS存"
3548 "储其历史,TeamWare使用SCCS。"
3550 #. type: Content of: <book><chapter><sect1><para>
3551 #: ../en/ch01-intro.xml:695
3552 msgid ""
3553 "As the 1990s progressed, awareness grew of a number of problems with CVS. It "
3554 "records simultaneous changes to multiple files individually, instead of "
3555 "grouping them together as a single logically atomic operation. It does not "
3556 "manage its file hierarchy well; it is easy to make a mess of a repository by "
3557 "renaming files and directories. Worse, its source code is difficult to read "
3558 "and maintain, which made the <quote>pain level</quote> of fixing these "
3559 "architectural problems prohibitive."
3560 msgstr ""
3561 "在90年代中,随着时间的流逝,CVS逐渐暴露出很多问题。它对多个文件同时发生的变更"
3562 "不能一起记录,不能按照层次管理文件;对目录和文件的重命名很容易破坏版本库。更糟"
3563 "的是,它的源代码很难阅读和维护,修复这些架构上的问题的非常困难。"
3565 #. type: Content of: <book><chapter><sect1><para>
3566 #: ../en/ch01-intro.xml:705
3567 msgid ""
3568 "In 2001, Jim Blandy and Karl Fogel, two developers who had worked on CVS, "
3569 "started a project to replace it with a tool that would have a better "
3570 "architecture and cleaner code. The result, Subversion, does not stray from "
3571 "CVS's centralised client/server model, but it adds multi-file atomic commits, "
3572 "better namespace management, and a number of other features that make it a "
3573 "generally better tool than CVS. Since its initial release, it has rapidly "
3574 "grown in popularity."
3575 msgstr ""
3576 "2001年,原来维护过CVS的两个开发者Jim Blandy和Karl Fogel,开始了一个新项目,其"
3577 "目标是替代CVS,新的软件将采用更好的架构和更整洁的代码。于是Subversion诞生了,"
3578 "它并保留了CVS集中式的客户/服务器模型,但是增加了多文件原子提交,更好的命名空间"
3579 "管理,和其他一些功能。总而言之,它比CVS好的多。Subversion在发布后迅速流行起"
3580 "来。"
3582 #. type: Content of: <book><chapter><sect1><para>
3583 #: ../en/ch01-intro.xml:714
3584 msgid ""
3585 "More or less simultaneously, Graydon Hoare began working on an ambitious "
3586 "distributed revision control system that he named Monotone. While Monotone "
3587 "addresses many of CVS's design flaws and has a peer-to-peer architecture, it "
3588 "goes beyond earlier (and subsequent) revision control tools in a number of "
3589 "innovative ways. It uses cryptographic hashes as identifiers, and has an "
3590 "integral notion of <quote>trust</quote> for code from different sources."
3591 msgstr ""
3592 "大概相同时间,Graydon Hoare开始了一个野心勃勃的分布式版本控制项目,他称之为"
3593 "Monotone。Monotone解决了很多CVS设计上的漏洞并且采用了点对点的架构,它在创新方"
3594 "面比以前(和以后)的版本控制系统走的更远。它使用加密哈希作为标识符,并且对于不"
3595 "同源的代码有了完整的 <quote>信任</quote>概念。"
3597 #. type: Content of: <book><chapter><sect1><para>
3598 #: ../en/ch01-intro.xml:723
3599 msgid ""
3600 "Mercurial began life in 2005. While a few aspects of its design are "
3601 "influenced by Monotone, Mercurial focuses on ease of use, high performance, "
3602 "and scalability to very large projects."
3603 msgstr ""
3604 "Mercurial诞生于2005年。设计方面受了Monotone的一些影响,Mercurial的目标是易用,"
3605 "高性能,对大的项目的良好扩展性。"
3607 #. type: Content of: <book><chapter><title>
3608 #: ../en/ch02-tour-basic.xml:5
3609 msgid "A tour of Mercurial: the basics"
3610 msgstr "Mercurial 教程: 基础知识"
3612 #. type: Content of: <book><chapter><sect1><title>
3613 #: ../en/ch02-tour-basic.xml:8
3614 msgid "Installing Mercurial on your system"
3615 msgstr "安装 Mercurial"
3617 #. type: Content of: <book><chapter><sect1><para>
3618 #: ../en/ch02-tour-basic.xml:10
3619 msgid ""
3620 "Prebuilt binary packages of Mercurial are available for every popular "
3621 "operating system. These make it easy to start using Mercurial on your "
3622 "computer immediately."
3623 msgstr ""
3624 "对于每种流行的操作系统,都有已经构建的二进制软件包。这让在你的计算机上开始使"
3625 "用 Mercurial 变得很容易。"
3627 #. type: Content of: <book><chapter><sect1><sect2><title>
3628 #: ../en/ch02-tour-basic.xml:15
3629 msgid "Windows"
3630 msgstr "Windows"
3632 #. type: Content of: <book><chapter><sect1><sect2><para>
3633 #: ../en/ch02-tour-basic.xml:17
3634 msgid ""
3635 "The best version of Mercurial for Windows is TortoiseHg, which can be found "
3636 "at <ulink url=\"http://bitbucket.org/tortoisehg/stable/wiki/Home\">http://"
3637 "bitbucket.org/tortoisehg/stable/wiki/Home</ulink>. This package has no "
3638 "external dependencies; it <quote>just works</quote>. It provides both "
3639 "command line and graphical user interfaces."
3640 msgstr ""
3641 "Windows 中最好的 Mercurial 版本是TortoiseHg,它的主页地址是 <ulink url="
3642 "\"http://bitbucket.org/tortoisehg/stable/wiki/Home\">http://bitbucket.org/"
3643 "tortoisehg/stable/wiki/Home</ulink>。这个软件没有外部依赖,它可以<quote>独立工"
3644 "作</quote>,同时提供了命令行和图形用户界面。"
3646 #. type: Content of: <book><chapter><sect1><sect2><title>
3647 #: ../en/ch02-tour-basic.xml:27
3648 msgid "Mac OS X"
3649 msgstr "Mac OS X"
3651 #. type: Content of: <book><chapter><sect1><sect2><para>
3652 #: ../en/ch02-tour-basic.xml:29
3653 msgid ""
3654 "Lee Cantey publishes an installer of Mercurial for Mac OS X at <ulink url="
3655 "\"http://mercurial.berkwood.com\">http://mercurial.berkwood.com</ulink>."
3656 msgstr ""
3657 "Lee Cantey 为 Mac OS X 在 <ulink url=\"http://mercurial.berkwood.com"
3658 "\">http://mercurial.berkwood.com</ulink> 发布了 Mercurial 安装程序。"
3660 #. type: Content of: <book><chapter><sect1><sect2><title>
3661 #: ../en/ch02-tour-basic.xml:35
3662 msgid "Linux"
3663 msgstr "Linux"
3665 #. type: Content of: <book><chapter><sect1><sect2><para>
3666 #: ../en/ch02-tour-basic.xml:37
3667 msgid ""
3668 "Because each Linux distribution has its own packaging tools, policies, and "
3669 "rate of development, it's difficult to give a comprehensive set of "
3670 "instructions on how to install Mercurial binaries. The version of Mercurial "
3671 "that you will end up with can vary depending on how active the person is who "
3672 "maintains the package for your distribution."
3673 msgstr ""
3674 "由于每种 Linux 发行版都有自己的包管理工具,开发策略和进度,从而很难给出安装 "
3675 "Mercurial 二进制包的全面说明。你安装的 Mercurial 版本,在很大程度上依赖于你所"
3676 "使用的发行版的 Mercurial 维护者的活跃程度。"
3678 #. type: Content of: <book><chapter><sect1><sect2><para>
3679 #: ../en/ch02-tour-basic.xml:44
3680 msgid ""
3681 "To keep things simple, I will focus on installing Mercurial from the command "
3682 "line under the most popular Linux distributions. Most of these distributions "
3683 "provide graphical package managers that will let you install Mercurial with a "
3684 "single click; the package name to look for is <literal>mercurial</literal>."
3685 msgstr ""
3686 "为了让事情简单,我会致力于说明在最流行的 Linux 发行版中,从命令行安装 "
3687 "Mercurial 的方法。这些发行版都提供了图形界面的包管理器,让你通过点击鼠标安装 "
3688 "Mercurial;寻找的包名称是 <literal>mercurial</literal>。"
3690 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
3691 #: ../en/ch02-tour-basic.xml:52
3692 msgid "Ubuntu and Debian:"
3693 msgstr "Ubuntu 与 Debian:"
3695 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
3696 #: ../en/ch02-tour-basic.xml:54
3697 msgid "Fedora:"
3698 msgstr "Fedora:"
3700 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
3701 #: ../en/ch02-tour-basic.xml:56
3702 msgid "OpenSUSE:"
3703 msgstr "OpenSUSE:"
3705 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
3706 #: ../en/ch02-tour-basic.xml:58
3707 msgid "Gentoo:"
3708 msgstr "Gentoo:"
3710 #. type: Content of: <book><chapter><sect1><sect2><title>
3711 #: ../en/ch02-tour-basic.xml:64
3712 msgid "Solaris"
3713 msgstr "Solaris"
3715 #. type: Content of: <book><chapter><sect1><sect2><para>
3716 #: ../en/ch02-tour-basic.xml:66
3717 msgid ""
3718 "SunFreeWare, at <ulink url=\"http://www.sunfreeware.com\">http://www."
3719 "sunfreeware.com</ulink>, provides prebuilt packages of Mercurial."
3720 msgstr ""
3721 "位于 <ulink url=\"http://www.sunfreeware.com\">http://www.sunfreeware.com</"
3722 "ulink> 的 SunFreeWare 提供了 Mercurial 的二进制安装包。"
3724 #. type: Content of: <book><chapter><sect1><title>
3725 #: ../en/ch02-tour-basic.xml:75
3726 msgid "Getting started"
3727 msgstr "开始"
3729 #. type: Content of: <book><chapter><sect1><para>
3730 #: ../en/ch02-tour-basic.xml:77
3731 msgid ""
3732 "To begin, we'll use the <command role=\"hg-cmd\">hg version</command> command "
3733 "to find out whether Mercurial is installed properly. The actual version "
3734 "information that it prints isn't so important; we simply care whether the "
3735 "command runs and prints anything at all."
3736 msgstr ""
3737 "首先,我们使用 <command role=\"hg-cmd\">hg version</command> 命令检查 "
3738 "Mercurial 是否已经正确安装。它打印出来的实际版本信息并不重要;我们只关心它是否"
3739 "能够运行,打印出信息。"
3741 #. type: Content of: <book><chapter><sect1><sect2><title>
3742 #: ../en/ch02-tour-basic.xml:86
3743 msgid "Built-in help"
3744 msgstr "内置帮助"
3746 #. type: Content of: <book><chapter><sect1><sect2><para>
3747 #: ../en/ch02-tour-basic.xml:88
3748 msgid ""
3749 "Mercurial provides a built-in help system. This is invaluable for those "
3750 "times when you find yourself stuck trying to remember how to run a command. "
3751 "If you are completely stuck, simply run <command role=\"hg-cmd\">hg help</"
3752 "command>; it will print a brief list of commands, along with a description of "
3753 "what each does. If you ask for help on a specific command (as below), it "
3754 "prints more detailed information."
3755 msgstr ""
3756 "Mercurial 内置了帮助系统。当你不记得如何执行一个命令时,它会给你重要的帮助。如"
3757 "果你完全没有头绪,那就直接运行 <command role=\"hg-cmd\">hg help</command>;它"
3758 "会给出命令的简短列表,还描述了每个命令的作用。如果你需要具体命令的帮助(下述),"
3759 "它会给出更详细的信息。"
3761 #. type: Content of: <book><chapter><sect1><sect2><para>
3762 #: ../en/ch02-tour-basic.xml:99
3763 msgid ""
3764 "For a more impressive level of detail (which you won't usually need) run "
3765 "<command role=\"hg-cmd\">hg help <option role=\"hg-opt-global\">-v</option></"
3766 "command>. The <option role=\"hg-opt-global\">-v</option> option is short for "
3767 "<option role=\"hg-opt-global\">--verbose</option>, and tells Mercurial to "
3768 "print more information than it usually would."
3769 msgstr ""
3770 "要获得更多的详细信息(通常不需要),可以执行 <command role=\"hg-cmd\">hg help "
3771 "<option role=\"hg-opt-global\">-v</option></command>。选项 <option role=\"hg-"
3772 "opt-global\">-v</option> 是 <option role=\"hg-opt-global\">--verbose</option> "
3773 "的短格式,告诉 Mercurial 要打印通常不需要的更多信息。"
3775 #. type: Content of: <book><chapter><sect1><title>
3776 #: ../en/ch02-tour-basic.xml:110
3777 msgid "Working with a repository"
3778 msgstr "使用版本库"
3780 #. type: Content of: <book><chapter><sect1><para>
3781 #: ../en/ch02-tour-basic.xml:112
3782 msgid ""
3783 "In Mercurial, everything happens inside a <emphasis>repository</emphasis>. "
3784 "The repository for a project contains all of the files that <quote>belong to</"
3785 "quote> that project, along with a historical record of the project's files."
3786 msgstr "在Mercurial中,所有的操作都在<emphasis>版本库</emphasis>中进行。"
3787 "项目的版本库包括了属于该项目的所有文件和这些文件的历史记录。"
3789 #. type: Content of: <book><chapter><sect1><para>
3790 #: ../en/ch02-tour-basic.xml:118
3791 msgid ""
3792 "There's nothing particularly magical about a repository; it is simply a "
3793 "directory tree in your filesystem that Mercurial treats as special. You can "
3794 "rename or delete a repository any time you like, using either the command "
3795 "line or your file browser."
3796 msgstr "版本库没有什么神秘的地方;仅仅是你系统中的一个目录树,Mercurial会将它们特殊处理。"
3797 "你可以在任何喜欢的时候使用命令行或者文件浏览器删除版本库或者给它改名。"
3799 #. type: Content of: <book><chapter><sect1><sect2><title>
3800 #: ../en/ch02-tour-basic.xml:125
3801 msgid "Making a local copy of a repository"
3802 msgstr "创建版本库的工作副本"
3804 #. type: Content of: <book><chapter><sect1><sect2><para>
3805 #: ../en/ch02-tour-basic.xml:127
3806 msgid ""
3807 "<emphasis>Copying</emphasis> a repository is just a little bit special. "
3808 "While you could use a normal file copying command to make a copy of a "
3809 "repository, it's best to use a built-in command that Mercurial provides. "
3810 "This command is called <command role=\"hg-cmd\">hg clone</command>, because "
3811 "it makes an identical copy of an existing repository."
3812 msgstr "<emphasis>拷贝</emphasis>版本库有点特殊。虽然你可以使用文件拷贝命令来复制"
3813 "一般版本库,最好还是用Mercurial内置的命令。这个命令叫做 <command role=\"hg-cmd\">hg clone</command>"
3814 ",因为它创建了一个原来版本库的拷贝。"
3816 #. type: Content of: <book><chapter><sect1><sect2><para>
3817 #: ../en/ch02-tour-basic.xml:136
3818 msgid ""
3819 "One advantage of using <command role=\"hg-cmd\">hg clone</command> is that, "
3820 "as we can see above, it lets us clone repositories over the network. Another "
3821 "is that it remembers where we cloned from, which we'll find useful soon when "
3822 "we want to fetch new changes from another repository."
3823 msgstr "如上所示,使用<command role=\"hg-cmd\">hg clone</command>的好处在于它能够让你"
3824 "通过网络克隆版本库。另外一个好处你它会记得这个版本库是从哪里克隆的,稍后会看到,当"
3825 "我们想从其他的版本库获取新的变更的时候这点这会非常有用。"
3827 #. type: Content of: <book><chapter><sect1><sect2><para>
3828 #: ../en/ch02-tour-basic.xml:142
3829 msgid ""
3830 "If our clone succeeded, we should now have a local directory called <filename "
3831 "class=\"directory\">hello</filename>. This directory will contain some files."
3832 msgstr "如果我们克隆成功,我们会得到一个本地目录,叫做 <filename "
3833 "class=\"directory\">hello</filename>。这个目录会包括一些文件。"
3835 #. type: Content of: <book><chapter><sect1><sect2><para>
3836 #: ../en/ch02-tour-basic.xml:148
3837 msgid ""
3838 "These files have the same contents and history in our repository as they do "
3839 "in the repository we cloned."
3840 msgstr "这个版本库中的文件和我们刚才克隆的版本库中的文件相同的内容和版本历史"
3842 #. type: Content of: <book><chapter><sect1><sect2><para>
3843 #: ../en/ch02-tour-basic.xml:151
3844 msgid ""
3845 "Every Mercurial repository is complete, self-contained, and independent. It "
3846 "contains its own private copy of a project's files and history. As we just "
3847 "mentioned, a cloned repository remembers the location of the repository it "
3848 "was cloned from, but Mercurial will not communicate with that repository, or "
3849 "any other, unless you tell it to."
3850 msgstr "每个Mercurial版本库都是完整的,自包含的,独立的。它包含了项目文件的一份私有"
3851 "拷贝和全部历史。我们刚才已经提到,克隆的版本库会记住它克隆的那个版本库的地址,但是"
3852 "Mercurial不会和那个或者其他任何一个版本库通信,除非你给它命令。"
3854 #. type: Content of: <book><chapter><sect1><sect2><para>
3855 #: ../en/ch02-tour-basic.xml:158
3856 msgid ""
3857 "What this means for now is that we're free to experiment with our repository, "
3858 "safe in the knowledge that it's a private <quote>sandbox</quote> that won't "
3859 "affect anyone else."
3860 msgstr "这意味着,我们可以随意的在我们的版本库中做实验,非常安全,因为它是一个私有的"
3861 "<quote>沙盒</quote>,不会影响任何人。"
3863 #. type: Content of: <book><chapter><sect1><sect2><title>
3864 #: ../en/ch02-tour-basic.xml:164
3865 msgid "What's in a repository?"
3866 msgstr "什么是版本库?"
3868 #. type: Content of: <book><chapter><sect1><sect2><para>
3869 #: ../en/ch02-tour-basic.xml:166
3870 msgid ""
3871 "When we take a more detailed look inside a repository, we can see that it "
3872 "contains a directory named <filename class=\"directory\">.hg</filename>. "
3873 "This is where Mercurial keeps all of its metadata for the repository."
3874 msgstr "当我们仔细观察版本库内部时,我们会发现它有一个叫"
3875 "<filename class=\"directory\">.hg</filename>的目录。"
3876 "这就是Mercurial为版本库保存所有元数据的地方。"
3878 #. type: Content of: <book><chapter><sect1><sect2><para>
3879 #: ../en/ch02-tour-basic.xml:173
3880 msgid ""
3881 "The contents of the <filename class=\"directory\">.hg</filename> directory "
3882 "and its subdirectories are private to Mercurial. Every other file and "
3883 "directory in the repository is yours to do with as you please."
3884 msgstr "目录<filename class=\"directory\">.hg</filename>"
3885 "中的内容和其子目录是Mercurial私有的。版本库中的其他任何文件和目录你都可以随意操作。"
3887 #. type: Content of: <book><chapter><sect1><sect2><para>
3888 #: ../en/ch02-tour-basic.xml:179
3889 msgid ""
3890 "To introduce a little terminology, the <filename class=\"directory\">.hg</"
3891 "filename> directory is the <quote>real</quote> repository, and all of the "
3892 "files and directories that coexist with it are said to live in the "
3893 "<emphasis>working directory</emphasis>. An easy way to remember the "
3894 "distinction is that the <emphasis>repository</emphasis> contains the "
3895 "<emphasis>history</emphasis> of your project, while the <emphasis>working "
3896 "directory</emphasis> contains a <emphasis>snapshot</emphasis> of your project "
3897 "at a particular point in history."
3898 msgstr "介绍一点术语, <filename class=\"directory\">.hg</filename>目录是"
3899 "<quote>真正的</quote>版本库,所有其他的文件和目录称为<emphasis>工作目录</emphasis>"
3900 "一个简单的区分的方法就是<emphasis>版本库</emphasis>中包含了项目的<emphasis>历史</emphasis>"
3901 ",而 <emphasis>工作目录</emphasis>则是项目组一个特定历史点上的<emphasis>快照</emphasis>。"
3902 #. type: Content of: <book><chapter><sect1><title>
3903 #: ../en/ch02-tour-basic.xml:194
3904 msgid "A tour through history"
3905 msgstr "回溯历史"
3907 #. type: Content of: <book><chapter><sect1><para>
3908 #: ../en/ch02-tour-basic.xml:196
3909 msgid ""
3910 "One of the first things we might want to do with a new, unfamiliar repository "
3911 "is understand its history. The <command role=\"hg-cmd\">hg log</command> "
3912 "command gives us a view of the history of changes in the repository."
3913 msgstr "对于一个新的,我们不熟悉的版本库,我们想做的第一件事就是了解它的历史。"
3914 "命令<command role=\"hg-cmd\">hg log</command>可以让我们浏览版本库中的历史变更。"
3916 #. type: Content of: <book><chapter><sect1><para>
3917 #: ../en/ch02-tour-basic.xml:203
3918 msgid ""
3919 "By default, this command prints a brief paragraph of output for each change "
3920 "to the project that was recorded. In Mercurial terminology, we call each of "
3921 "these recorded events a <emphasis>changeset</emphasis>, because it can "
3922 "contain a record of changes to several files."
3923 msgstr "缺省情况下,这个命令对项目中记录的每个变更都输出一段简介,在Mercurial"
3924 "的术语中,我们将这些记录的事件成为<emphasis>变更集</emphasis>,因为每个记录都"
3925 "可能包括几个文件的变更。"
3927 #. type: Content of: <book><chapter><sect1><para>
3928 #: ../en/ch02-tour-basic.xml:209
3929 msgid ""
3930 "The fields in a record of output from <command role=\"hg-cmd\">hg log</"
3931 "command> are as follows."
3932 msgstr " <command role=\"hg-cmd\">hg log</command>输出记录的各个字段的意义如下。"
3934 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
3935 #: ../en/ch02-tour-basic.xml:213
3936 msgid ""
3937 "<literal>changeset</literal>: This field has the format of a number, followed "
3938 "by a colon, followed by a hexadecimal (or <emphasis>hex</emphasis>) string. "
3939 "These are <emphasis>identifiers</emphasis> for the changeset. The hex string "
3940 "is a unique identifier: the same hex string will always refer to the same "
3941 "changeset in every copy of this repository. The number is shorter and easier "
3942 "to type than the hex string, but it isn't unique: the same number in two "
3943 "different clones of a repository may identify different changesets."
3944 msgstr "<literal>changeset</literal>:这个字段包括一个数字,接着一个冒号,然后是"
3945 "是一个十六进制字符串。这是这个变更的<emphasis>标识符</emphasis>。十六进制字符串"
3946 "是唯一标识符:在这个版本库的每个拷贝中,同一个字符串总是对应同一个变更集。数字更简单"
3947 "并且比十六进制字符串更容易书写,但它不是唯一的:一个版本库的两个不同的的克隆中的"
3948 "同一个数字可能对应不同的变更集。"
3950 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
3951 #: ../en/ch02-tour-basic.xml:224
3952 msgid ""
3953 "<literal>user</literal>: The identity of the person who created the "
3954 "changeset. This is a free-form field, but it most often contains a person's "
3955 "name and email address."
3956 msgstr "<literal>user</literal>:这个字段标识是谁创建了这个变更集。这个字段格式可以自由定义,"
3957 "通常是一个人的姓名加上电子邮件地址。"
3959 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
3960 #: ../en/ch02-tour-basic.xml:228
3961 msgid ""
3962 "<literal>date</literal>: The date and time on which the changeset was "
3963 "created, and the timezone in which it was created. (The date and time are "
3964 "local to that timezone; they display what time and date it was for the person "
3965 "who created the changeset.)"
3966 msgstr "这个变更集创建的日期和时间,还有时区。(日期和时间是相对于时区的;"
3967 ""他们现实了创建变更的人的日期和时间。)
3968 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
3969 #: ../en/ch02-tour-basic.xml:233
3970 msgid ""
3971 "<literal>summary</literal>: The first line of the text message that the "
3972 "creator of the changeset entered to describe the changeset."
3973 msgstr ""
3975 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
3976 #: ../en/ch02-tour-basic.xml:237
3977 msgid ""
3978 "Some changesets, such as the first in the list above, have a <literal>tag</"
3979 "literal> field. A tag is another way to identify a changeset, by giving it "
3980 "an easy-to-remember name. (The tag named <literal>tip</literal> is special: "
3981 "it always refers to the newest change in a repository.)"
3982 msgstr ""
3984 #. type: Content of: <book><chapter><sect1><para>
3985 #: ../en/ch02-tour-basic.xml:245
3986 msgid ""
3987 "The default output printed by <command role=\"hg-cmd\">hg log</command> is "
3988 "purely a summary; it is missing a lot of detail."
3989 msgstr ""
3991 #. type: Content of: <book><chapter><sect1><para>
3992 #: ../en/ch02-tour-basic.xml:249
3993 msgid ""
3994 "<xref linkend=\"fig:tour-basic:history\"/> provides a graphical "
3995 "representation of the history of the <filename class=\"directory\">hello</"
3996 "filename> repository, to make it a little easier to see which direction "
3997 "history is <quote>flowing</quote> in. We'll be returning to this figure "
3998 "several times in this chapter and the chapter that follows."
3999 msgstr ""
4001 #. type: Content of: <book><chapter><sect1><figure><title>
4002 #: ../en/ch02-tour-basic.xml:258
4003 msgid ""
4004 "Graphical history of the <filename class=\"directory\">hello</filename> "
4005 "repository"
4006 msgstr "版本库 <filename class=\"directory\">hello</filename> 的历史图"
4008 #. type: Content of: <book><chapter><sect1><figure>
4009 #: ../en/ch02-tour-basic.xml:260 ../en/ch03-tour-merge.xml:61
4010 #: ../en/ch03-tour-merge.xml:207 ../en/ch04-concepts.xml:290
4011 msgid "<placeholder type=\"mediaobject\" id=\"0\"/>"
4012 msgstr ""
4014 #. type: Content of: <book><chapter><sect1><figure><mediaobject>
4015 #: ../en/ch02-tour-basic.xml:261
4016 msgid ""
4017 "<imageobject><imagedata fileref=\"figs/tour-history.png\"/></imageobject>"
4018 msgstr ""
4020 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject><textobject><phrase>
4021 #: ../en/ch02-tour-basic.xml:262 ../en/ch03-tour-merge.xml:63
4022 #: ../en/ch03-tour-merge.xml:95 ../en/ch03-tour-merge.xml:182
4023 #: ../en/ch03-tour-merge.xml:209 ../en/ch03-tour-merge.xml:279
4024 #: ../en/ch04-concepts.xml:59 ../en/ch04-concepts.xml:108
4025 #: ../en/ch04-concepts.xml:198 ../en/ch04-concepts.xml:292
4026 #: ../en/ch04-concepts.xml:347 ../en/ch04-concepts.xml:362
4027 #: ../en/ch04-concepts.xml:403 ../en/ch04-concepts.xml:423
4028 #: ../en/ch04-concepts.xml:469 ../en/ch06-collab.xml:316
4029 #: ../en/ch09-undo.xml:344 ../en/ch09-undo.xml:391 ../en/ch09-undo.xml:464
4030 #: ../en/ch09-undo.xml:502 ../en/ch09-undo.xml:658 ../en/ch09-undo.xml:682
4031 #: ../en/ch09-undo.xml:700 ../en/ch09-undo.xml:714 ../en/ch09-undo.xml:727
4032 #: ../en/ch12-mq.xml:413
4033 msgid "XXX add text"
4034 msgstr ""
4036 #. type: Content of: <book><chapter><sect1><sect2><title>
4037 #: ../en/ch02-tour-basic.xml:267
4038 msgid "Changesets, revisions, and talking to other people"
4039 msgstr "修改集,版本,与其它用户交互"
4041 #. type: Content of: <book><chapter><sect1><sect2><para>
4042 #: ../en/ch02-tour-basic.xml:270
4043 msgid ""
4044 "As English is a notoriously sloppy language, and computer science has a "
4045 "hallowed history of terminological confusion (why use one term when four will "
4046 "do?), revision control has a variety of words and phrases that mean the same "
4047 "thing. If you are talking about Mercurial history with other people, you "
4048 "will find that the word <quote>changeset</quote> is often compressed to "
4049 "<quote>change</quote> or (when written) <quote>cset</quote>, and sometimes a "
4050 "changeset is referred to as a <quote>revision</quote> or a <quote>rev</quote>."
4051 msgstr ""
4053 #. type: Content of: <book><chapter><sect1><sect2><para>
4054 #: ../en/ch02-tour-basic.xml:280
4055 msgid ""
4056 "While it doesn't matter what <emphasis>word</emphasis> you use to refer to "
4057 "the concept of <quote>a changeset</quote>, the <emphasis>identifier</"
4058 "emphasis> that you use to refer to <quote>a <emphasis>specific</emphasis> "
4059 "changeset</quote> is of great importance. Recall that the <literal>changeset</"
4060 "literal> field in the output from <command role=\"hg-cmd\">hg log</command> "
4061 "identifies a changeset using both a number and a hexadecimal string."
4062 msgstr ""
4064 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
4065 #: ../en/ch02-tour-basic.xml:289
4066 msgid ""
4067 "The revision number is a handy notation that is <emphasis>only valid in that "
4068 "repository</emphasis>."
4069 msgstr ""
4071 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
4072 #: ../en/ch02-tour-basic.xml:292
4073 msgid ""
4074 "The hexadecimal string is the <emphasis>permanent, unchanging identifier</"
4075 "emphasis> that will always identify that exact changeset in <emphasis>every</"
4076 "emphasis> copy of the repository."
4077 msgstr ""
4079 #. type: Content of: <book><chapter><sect1><sect2><para>
4080 #: ../en/ch02-tour-basic.xml:298
4081 msgid ""
4082 "This distinction is important. If you send someone an email talking about "
4083 "<quote>revision 33</quote>, there's a high likelihood that their revision 33 "
4084 "will <emphasis>not be the same</emphasis> as yours. The reason for this is "
4085 "that a revision number depends on the order in which changes arrived in a "
4086 "repository, and there is no guarantee that the same changes will happen in "
4087 "the same order in different repositories. Three changes <literal>a,b,c</"
4088 "literal> can easily appear in one repository as <literal>0,1,2</literal>, "
4089 "while in another as <literal>0,2,1</literal>."
4090 msgstr ""
4092 #. type: Content of: <book><chapter><sect1><sect2><para>
4093 #: ../en/ch02-tour-basic.xml:310
4094 msgid ""
4095 "Mercurial uses revision numbers purely as a convenient shorthand. If you "
4096 "need to discuss a changeset with someone, or make a record of a changeset for "
4097 "some other reason (for example, in a bug report), use the hexadecimal "
4098 "identifier."
4099 msgstr ""
4101 #. type: Content of: <book><chapter><sect1><sect2><title>
4102 #: ../en/ch02-tour-basic.xml:318
4103 msgid "Viewing specific revisions"
4104 msgstr "察看指定版本"
4106 #. type: Content of: <book><chapter><sect1><sect2><para>
4107 #: ../en/ch02-tour-basic.xml:320
4108 msgid ""
4109 "To narrow the output of <command role=\"hg-cmd\">hg log</command> down to a "
4110 "single revision, use the <option role=\"hg-opt-log\">-r</option> (or <option "
4111 "role=\"hg-opt-log\">--rev</option>) option. You can use either a revision "
4112 "number or a hexadecimal identifier, and you can provide as many revisions as "
4113 "you want."
4114 msgstr ""
4116 #. type: Content of: <book><chapter><sect1><sect2><para>
4117 #: ../en/ch02-tour-basic.xml:329
4118 msgid ""
4119 "If you want to see the history of several revisions without having to list "
4120 "each one, you can use <emphasis>range notation</emphasis>; this lets you "
4121 "express the idea <quote>I want all revisions between <literal>abc</literal> "
4122 "and <literal>def</literal>, inclusive</quote>."
4123 msgstr ""
4125 #. type: Content of: <book><chapter><sect1><sect2><para>
4126 #: ../en/ch02-tour-basic.xml:337
4127 msgid ""
4128 "Mercurial also honours the order in which you specify revisions, so <command "
4129 "role=\"hg-cmd\">hg log -r 2:4</command> prints 2, 3, and 4. while <command "
4130 "role=\"hg-cmd\">hg log -r 4:2</command> prints 4, 3, and 2."
4131 msgstr ""
4133 #. type: Content of: <book><chapter><sect1><sect2><title>
4134 #: ../en/ch02-tour-basic.xml:344
4135 msgid "More detailed information"
4136 msgstr "更详细的信息"
4138 #. type: Content of: <book><chapter><sect1><sect2><para>
4139 #: ../en/ch02-tour-basic.xml:346
4140 msgid ""
4141 "While the summary information printed by <command role=\"hg-cmd\">hg log</"
4142 "command> is useful if you already know what you're looking for, you may need "
4143 "to see a complete description of the change, or a list of the files changed, "
4144 "if you're trying to decide whether a changeset is the one you're looking for. "
4145 "The <command role=\"hg-cmd\">hg log</command> command's <option role=\"hg-opt-"
4146 "global\">-v</option> (or <option role=\"hg-opt-global\">--verbose</option>) "
4147 "option gives you this extra detail."
4148 msgstr ""
4150 #. type: Content of: <book><chapter><sect1><sect2><para>
4151 #: ../en/ch02-tour-basic.xml:358
4152 msgid ""
4153 "If you want to see both the description and content of a change, add the "
4154 "<option role=\"hg-opt-log\">-p</option> (or <option role=\"hg-opt-log\">--"
4155 "patch</option>) option. This displays the content of a change as a "
4156 "<emphasis>unified diff</emphasis> (if you've never seen a unified diff "
4157 "before, see <xref linkend=\"sec:mq:patch\"/> for an overview)."
4158 msgstr ""
4160 #. type: Content of: <book><chapter><sect1><sect2><para>
4161 #: ../en/ch02-tour-basic.xml:368
4162 msgid ""
4163 "The <option role=\"hg-opt-log\">-p</option> option is tremendously useful, so "
4164 "it's well worth remembering."
4165 msgstr ""
4167 #. type: Content of: <book><chapter><sect1><title>
4168 #: ../en/ch02-tour-basic.xml:375
4169 msgid "All about command options"
4170 msgstr "命令选项"
4172 #. type: Content of: <book><chapter><sect1><para>
4173 #: ../en/ch02-tour-basic.xml:377
4174 msgid ""
4175 "Let's take a brief break from exploring Mercurial commands to discuss a "
4176 "pattern in the way that they work; you may find this useful to keep in mind "
4177 "as we continue our tour."
4178 msgstr ""
4180 #. type: Content of: <book><chapter><sect1><para>
4181 #: ../en/ch02-tour-basic.xml:381
4182 msgid ""
4183 "Mercurial has a consistent and straightforward approach to dealing with the "
4184 "options that you can pass to commands. It follows the conventions for "
4185 "options that are common to modern Linux and Unix systems."
4186 msgstr ""
4188 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
4189 #: ../en/ch02-tour-basic.xml:388
4190 msgid ""
4191 "Every option has a long name. For example, as we've already seen, the "
4192 "<command role=\"hg-cmd\">hg log</command> command accepts a <option role=\"hg-"
4193 "opt-log\">--rev</option> option."
4194 msgstr ""
4196 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
4197 #: ../en/ch02-tour-basic.xml:394
4198 msgid ""
4199 "Most options have short names, too. Instead of <option role=\"hg-opt-log\">--"
4200 "rev</option>, we can use <option role=\"hg-opt-log\">-r</option>. (The "
4201 "reason that some options don't have short names is that the options in "
4202 "question are rarely used.)"
4203 msgstr ""
4205 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
4206 #: ../en/ch02-tour-basic.xml:401
4207 msgid ""
4208 "Long options start with two dashes (e.g. <option role=\"hg-opt-log\">--rev</"
4209 "option>), while short options start with one (e.g. <option role=\"hg-opt-log"
4210 "\">-r</option>)."
4211 msgstr ""
4213 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
4214 #: ../en/ch02-tour-basic.xml:407
4215 msgid ""
4216 "Option naming and usage is consistent across commands. For example, every "
4217 "command that lets you specify a changeset ID or revision number accepts both "
4218 "<option role=\"hg-opt-log\">-r</option> and <option role=\"hg-opt-log\">--"
4219 "rev</option> arguments."
4220 msgstr ""
4222 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
4223 #: ../en/ch02-tour-basic.xml:414
4224 msgid ""
4225 "If you are using short options, you can save typing by running them together. "
4226 "For example, the command <command role=\"hg-cmd\">hg log -v -p -r 2</command> "
4227 "can be written as <command role=\"hg-cmd\">hg log -vpr2</command>."
4228 msgstr ""
4230 #. type: Content of: <book><chapter><sect1><para>
4231 #: ../en/ch02-tour-basic.xml:421
4232 msgid ""
4233 "In the examples throughout this book, I usually use short options instead of "
4234 "long. This simply reflects my own preference, so don't read anything "
4235 "significant into it."
4236 msgstr ""
4238 #. type: Content of: <book><chapter><sect1><para>
4239 #: ../en/ch02-tour-basic.xml:425
4240 msgid ""
4241 "Most commands that print output of some kind will print more output when "
4242 "passed a <option role=\"hg-opt-global\">-v</option> (or <option role=\"hg-opt-"
4243 "global\">--verbose</option>) option, and less when passed <option role=\"hg-"
4244 "opt-global\">-q</option> (or <option role=\"hg-opt-global\">--quiet</option>)."
4245 msgstr ""
4247 #. type: Content of: <book><chapter><sect1><note><title>
4248 #: ../en/ch02-tour-basic.xml:432
4249 msgid "Option naming consistency"
4250 msgstr ""
4252 #. type: Content of: <book><chapter><sect1><note><para>
4253 #: ../en/ch02-tour-basic.xml:434
4254 msgid ""
4255 "Almost always, Mercurial commands use consistent option names to refer to the "
4256 "same concepts. For instance, if a command deals with changesets, you'll "
4257 "always identify them with <option role=\"hg-opt-log\">--rev</option> or "
4258 "<option role=\"hg-opt-log\">-r</option>. This consistent use of option names "
4259 "makes it easier to remember what options a particular command takes."
4260 msgstr ""
4262 #. type: Content of: <book><chapter><sect1><title>
4263 #: ../en/ch02-tour-basic.xml:445
4264 msgid "Making and reviewing changes"
4265 msgstr "创建和复审修改"
4267 #. type: Content of: <book><chapter><sect1><para>
4268 #: ../en/ch02-tour-basic.xml:447
4269 msgid ""
4270 "Now that we have a grasp of viewing history in Mercurial, let's take a look "
4271 "at making some changes and examining them."
4272 msgstr ""
4274 #. type: Content of: <book><chapter><sect1><para>
4275 #: ../en/ch02-tour-basic.xml:451
4276 msgid ""
4277 "The first thing we'll do is isolate our experiment in a repository of its "
4278 "own. We use the <command role=\"hg-cmd\">hg clone</command> command, but we "
4279 "don't need to clone a copy of the remote repository. Since we already have a "
4280 "copy of it locally, we can just clone that instead. This is much faster than "
4281 "cloning over the network, and cloning a local repository uses less disk space "
4282 "in most cases, too<placeholder type=\"footnote\" id=\"0\"/>."
4283 msgstr ""
4285 #. type: Content of: <book><chapter><sect1><para><footnote><para>
4286 #: ../en/ch02-tour-basic.xml:458
4287 msgid ""
4288 "The saving of space arises when source and destination repositories are on "
4289 "the same filesystem, in which case Mercurial will use hardlinks to do copy-on-"
4290 "write sharing of its internal metadata. If that explanation meant nothing to "
4291 "you, don't worry: everything happens transparently and automatically, and you "
4292 "don't need to understand it."
4293 msgstr ""
4295 #. type: Content of: <book><chapter><sect1><para>
4296 #: ../en/ch02-tour-basic.xml:468
4297 msgid ""
4298 "As an aside, it's often good practice to keep a <quote>pristine</quote> copy "
4299 "of a remote repository around, which you can then make temporary clones of to "
4300 "create sandboxes for each task you want to work on. This lets you work on "
4301 "multiple tasks in parallel, each isolated from the others until it's complete "
4302 "and you're ready to integrate it back. Because local clones are so cheap, "
4303 "there's almost no overhead to cloning and destroying repositories whenever "
4304 "you want."
4305 msgstr ""
4307 #. type: Content of: <book><chapter><sect1><para>
4308 #: ../en/ch02-tour-basic.xml:477
4309 msgid ""
4310 "In our <filename class=\"directory\">my-hello</filename> repository, we have "
4311 "a file <filename>hello.c</filename> that contains the classic <quote>hello, "
4312 "world</quote> program."
4313 msgstr ""
4315 #. type: Content of: <book><chapter><sect1><para>
4316 #: ../en/ch02-tour-basic.xml:483
4317 msgid "Let's edit this file so that it prints a second line of output."
4318 msgstr ""
4320 #. type: Content of: <book><chapter><sect1><para>
4321 #: ../en/ch02-tour-basic.xml:488
4322 msgid ""
4323 "Mercurial's <command role=\"hg-cmd\">hg status</command> command will tell us "
4324 "what Mercurial knows about the files in the repository."
4325 msgstr ""
4327 #. type: Content of: <book><chapter><sect1><para>
4328 #: ../en/ch02-tour-basic.xml:494
4329 msgid ""
4330 "The <command role=\"hg-cmd\">hg status</command> command prints no output for "
4331 "some files, but a line starting with <quote><literal>M</literal></quote> for "
4332 "<filename>hello.c</filename>. Unless you tell it to, <command role=\"hg-cmd"
4333 "\">hg status</command> will not print any output for files that have not been "
4334 "modified."
4335 msgstr ""
4337 #. type: Content of: <book><chapter><sect1><para>
4338 #: ../en/ch02-tour-basic.xml:501
4339 msgid ""
4340 "The <quote><literal>M</literal></quote> indicates that Mercurial has noticed "
4341 "that we modified <filename>hello.c</filename>. We didn't need to "
4342 "<emphasis>inform</emphasis> Mercurial that we were going to modify the file "
4343 "before we started, or that we had modified the file after we were done; it "
4344 "was able to figure this out itself."
4345 msgstr ""
4347 #. type: Content of: <book><chapter><sect1><para>
4348 #: ../en/ch02-tour-basic.xml:509
4349 msgid ""
4350 "It's somewhat helpful to know that we've modified <filename>hello.c</"
4351 "filename>, but we might prefer to know exactly <emphasis>what</emphasis> "
4352 "changes we've made to it. To do this, we use the <command role=\"hg-cmd\">hg "
4353 "diff</command> command."
4354 msgstr ""
4356 #. type: Content of: <book><chapter><sect1><title>
4357 #: ../en/ch02-tour-basic.xml:518 ../en/ch12-mq.xml:187
4358 msgid "Understanding patches"
4359 msgstr "理解补丁"
4361 #. type: Content of: <book><chapter><sect1><tip><para>
4362 #: ../en/ch02-tour-basic.xml:520
4363 msgid ""
4364 "Remember to take a look at <xref linkend=\"sec:mq:patch\"/> if you don't know "
4365 "how to read output above."
4366 msgstr ""
4368 #. type: Content of: <book><chapter><sect1><title>
4369 #: ../en/ch02-tour-basic.xml:526
4370 msgid "Recording changes in a new changeset"
4371 msgstr "在新修改集中记录修改"
4373 #. type: Content of: <book><chapter><sect1><para>
4374 #: ../en/ch02-tour-basic.xml:528
4375 msgid ""
4376 "We can modify files, build and test our changes, and use <command role=\"hg-"
4377 "cmd\">hg status</command> and <command role=\"hg-cmd\">hg diff</command> to "
4378 "review our changes, until we're satisfied with what we've done and arrive at "
4379 "a natural stopping point where we want to record our work in a new changeset."
4380 msgstr ""
4382 #. type: Content of: <book><chapter><sect1><para>
4383 #: ../en/ch02-tour-basic.xml:535
4384 msgid ""
4385 "The <command role=\"hg-cmd\">hg commit</command> command lets us create a new "
4386 "changeset; we'll usually refer to this as <quote>making a commit</quote> or "
4387 "<quote>committing</quote>."
4388 msgstr ""
4390 #. type: Content of: <book><chapter><sect1><sect2><title>
4391 #: ../en/ch02-tour-basic.xml:541
4392 msgid "Setting up a username"
4393 msgstr "配置用户名称"
4395 #. type: Content of: <book><chapter><sect1><sect2><para>
4396 #: ../en/ch02-tour-basic.xml:543
4397 msgid ""
4398 "When you try to run <command role=\"hg-cmd\">hg commit</command> for the "
4399 "first time, it is not guaranteed to succeed. Mercurial records your name and "
4400 "address with each change that you commit, so that you and others will later "
4401 "be able to tell who made each change. Mercurial tries to automatically "
4402 "figure out a sensible username to commit the change with. It will attempt "
4403 "each of the following methods, in order:"
4404 msgstr ""
4406 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
4407 #: ../en/ch02-tour-basic.xml:552
4408 msgid ""
4409 "If you specify a <option role=\"hg-opt-commit\">-u</option> option to the "
4410 "<command role=\"hg-cmd\">hg commit</command> command on the command line, "
4411 "followed by a username, this is always given the highest precedence."
4412 msgstr ""
4414 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
4415 #: ../en/ch02-tour-basic.xml:557
4416 msgid ""
4417 "If you have set the <envar>HGUSER</envar> environment variable, this is "
4418 "checked next."
4419 msgstr ""
4421 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
4422 #: ../en/ch02-tour-basic.xml:560
4423 msgid ""
4424 "If you create a file in your home directory called <filename role=\"special"
4425 "\">.hgrc</filename>, with a <envar role=\"rc-item-ui\">username</envar> "
4426 "entry, that will be used next. To see what the contents of this file should "
4427 "look like, refer to <xref linkend=\"sec:tour-basic:username\"/> below."
4428 msgstr ""
4430 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
4431 #: ../en/ch02-tour-basic.xml:568
4432 msgid ""
4433 "If you have set the <envar>EMAIL</envar> environment variable, this will be "
4434 "used next."
4435 msgstr ""
4437 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
4438 #: ../en/ch02-tour-basic.xml:571
4439 msgid ""
4440 "Mercurial will query your system to find out your local user name and host "
4441 "name, and construct a username from these components. Since this often "
4442 "results in a username that is not very useful, it will print a warning if it "
4443 "has to do this."
4444 msgstr ""
4446 #. type: Content of: <book><chapter><sect1><sect2><para>
4447 #: ../en/ch02-tour-basic.xml:578
4448 msgid ""
4449 "If all of these mechanisms fail, Mercurial will fail, printing an error "
4450 "message. In this case, it will not let you commit until you set up a "
4451 "username."
4452 msgstr ""
4454 #. type: Content of: <book><chapter><sect1><sect2><para>
4455 #: ../en/ch02-tour-basic.xml:582
4456 msgid ""
4457 "You should think of the <envar>HGUSER</envar> environment variable and the "
4458 "<option role=\"hg-opt-commit\">-u</option> option to the <command role=\"hg-"
4459 "cmd\">hg commit</command> command as ways to <emphasis>override</emphasis> "
4460 "Mercurial's default selection of username. For normal use, the simplest and "
4461 "most robust way to set a username for yourself is by creating a <filename "
4462 "role=\"special\">.hgrc</filename> file; see below for details."
4463 msgstr ""
4465 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
4466 #: ../en/ch02-tour-basic.xml:591
4467 msgid "Creating a Mercurial configuration file"
4468 msgstr "创建 Mercurial 的配置文件"
4470 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
4471 #: ../en/ch02-tour-basic.xml:593
4472 msgid ""
4473 "To set a user name, use your favorite editor to create a file called "
4474 "<filename role=\"special\">.hgrc</filename> in your home directory. "
4475 "Mercurial will use this file to look up your personalised configuration "
4476 "settings. The initial contents of your <filename role=\"special\">.hgrc</"
4477 "filename> should look like this."
4478 msgstr ""
4480 #. type: Content of: <book><chapter><sect1><sect2><sect3><tip><title>
4481 #: ../en/ch02-tour-basic.xml:602
4482 msgid "<quote>Home directory</quote> on Windows"
4483 msgstr ""
4485 #. type: Content of: <book><chapter><sect1><sect2><sect3><tip><para>
4486 #: ../en/ch02-tour-basic.xml:604
4487 msgid ""
4488 "When we refer to your home directory, on an English language installation of "
4489 "Windows this will usually be a folder named after your user name in "
4490 "<filename>C:\\Documents and Settings</filename>. You can find out the exact "
4491 "name of your home directory by opening a command prompt window and running "
4492 "the following command."
4493 msgstr ""
4495 #. type: Content of: <book><chapter><sect1><sect2><sect3><tip><screen><prompt>
4496 #: ../en/ch02-tour-basic.xml:612
4497 msgid "C:\\>"
4498 msgstr "C:\\>"
4500 #. type: Content of: <book><chapter><sect1><sect2><sect3><tip><screen><userinput>
4501 #: ../en/ch02-tour-basic.xml:612
4502 msgid "echo %UserProfile%"
4503 msgstr "echo %UserProfile%"
4505 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
4506 #: ../en/ch02-tour-basic.xml:619
4507 msgid ""
4508 "The <quote><literal>[ui]</literal></quote> line begins a <emphasis>section</"
4509 "emphasis> of the config file, so you can read the <quote><literal>username "
4510 "= ...</literal></quote> line as meaning <quote>set the value of the "
4511 "<literal>username</literal> item in the <literal>ui</literal> section</"
4512 "quote>. A section continues until a new section begins, or the end of the "
4513 "file. Mercurial ignores empty lines and treats any text from "
4514 "<quote><literal>#</literal></quote> to the end of a line as a comment."
4515 msgstr ""
4517 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
4518 #: ../en/ch02-tour-basic.xml:632
4519 msgid "Choosing a user name"
4520 msgstr "选择用户名称"
4522 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
4523 #: ../en/ch02-tour-basic.xml:634
4524 msgid ""
4525 "You can use any text you like as the value of the <literal>username</literal> "
4526 "config item, since this information is for reading by other people, but will "
4527 "not be interpreted by Mercurial. The convention that most people follow is "
4528 "to use their name and email address, as in the example above."
4529 msgstr ""
4531 #. type: Content of: <book><chapter><sect1><sect2><sect3><note><para>
4532 #: ../en/ch02-tour-basic.xml:641
4533 msgid ""
4534 "Mercurial's built-in web server obfuscates email addresses, to make it more "
4535 "difficult for the email harvesting tools that spammers use. This reduces the "
4536 "likelihood that you'll start receiving more junk email if you publish a "
4537 "Mercurial repository on the web."
4538 msgstr ""
4540 #. type: Content of: <book><chapter><sect1><sect2><title>
4541 #: ../en/ch02-tour-basic.xml:650
4542 msgid "Writing a commit message"
4543 msgstr "写提交日志"
4545 #. type: Content of: <book><chapter><sect1><sect2><para>
4546 #: ../en/ch02-tour-basic.xml:652
4547 msgid ""
4548 "When we commit a change, Mercurial drops us into a text editor, to enter a "
4549 "message that will describe the modifications we've made in this changeset. "
4550 "This is called the <emphasis>commit message</emphasis>. It will be a record "
4551 "for readers of what we did and why, and it will be printed by <command role="
4552 "\"hg-cmd\">hg log</command> after we've finished committing."
4553 msgstr ""
4555 #. type: Content of: <book><chapter><sect1><sect2><para>
4556 #: ../en/ch02-tour-basic.xml:662
4557 msgid ""
4558 "The editor that the <command role=\"hg-cmd\">hg commit</command> command "
4559 "drops us into will contain an empty line or two, followed by a number of "
4560 "lines starting with <quote><literal>HG:</literal></quote>."
4561 msgstr ""
4563 #. type: Content of: <book><chapter><sect1><sect2><para>
4564 #: ../en/ch02-tour-basic.xml:676
4565 msgid ""
4566 "Mercurial ignores the lines that start with <quote><literal>HG:</literal></"
4567 "quote>; it uses them only to tell us which files it's recording changes to. "
4568 "Modifying or deleting these lines has no effect."
4569 msgstr ""
4571 #. type: Content of: <book><chapter><sect1><sect2><title>
4572 #: ../en/ch02-tour-basic.xml:682
4573 msgid "Writing a good commit message"
4574 msgstr "写好提交日志"
4576 #. type: Content of: <book><chapter><sect1><sect2><para>
4577 #: ../en/ch02-tour-basic.xml:684
4578 msgid ""
4579 "Since <command role=\"hg-cmd\">hg log</command> only prints the first line of "
4580 "a commit message by default, it's best to write a commit message whose first "
4581 "line stands alone. Here's a real example of a commit message that "
4582 "<emphasis>doesn't</emphasis> follow this guideline, and hence has a summary "
4583 "that is not readable."
4584 msgstr ""
4586 #. type: Content of: <book><chapter><sect1><sect2><para>
4587 #: ../en/ch02-tour-basic.xml:697
4588 msgid ""
4589 "As far as the remainder of the contents of the commit message are concerned, "
4590 "there are no hard-and-fast rules. Mercurial itself doesn't interpret or care "
4591 "about the contents of the commit message, though your project may have "
4592 "policies that dictate a certain kind of formatting."
4593 msgstr ""
4595 #. type: Content of: <book><chapter><sect1><sect2><para>
4596 #: ../en/ch02-tour-basic.xml:702
4597 msgid ""
4598 "My personal preference is for short, but informative, commit messages that "
4599 "tell me something that I can't figure out with a quick glance at the output "
4600 "of <command role=\"hg-cmd\">hg log --patch</command>."
4601 msgstr ""
4603 #. type: Content of: <book><chapter><sect1><sect2><para>
4604 #: ../en/ch02-tour-basic.xml:706
4605 msgid ""
4606 "If we run the <command role=\"hg-cmd\">hg commit</command> command without "
4607 "any arguments, it records all of the changes we've made, as reported by "
4608 "<command role=\"hg-cmd\">hg status</command> and <command role=\"hg-cmd\">hg "
4609 "diff</command>."
4610 msgstr ""
4612 #. type: Content of: <book><chapter><sect1><sect2><note><title>
4613 #: ../en/ch02-tour-basic.xml:713
4614 msgid "A surprise for Subversion users"
4615 msgstr ""
4617 #. type: Content of: <book><chapter><sect1><sect2><note><para>
4618 #: ../en/ch02-tour-basic.xml:715
4619 msgid ""
4620 "Like other Mercurial commands, if we don't supply explicit names to commit to "
4621 "the <command role=\"hg-cmd\">hg commit</command>, it will operate across a "
4622 "repository's entire working directory. Be wary of this if you're coming from "
4623 "the Subversion or CVS world, since you might expect it to operate only on the "
4624 "current directory that you happen to be visiting and its subdirectories."
4625 msgstr ""
4627 #. type: Content of: <book><chapter><sect1><sect2><title>
4628 #: ../en/ch02-tour-basic.xml:726
4629 msgid "Aborting a commit"
4630 msgstr "终止提交"
4632 #. type: Content of: <book><chapter><sect1><sect2><para>
4633 #: ../en/ch02-tour-basic.xml:728
4634 msgid ""
4635 "If you decide that you don't want to commit while in the middle of editing a "
4636 "commit message, simply exit from your editor without saving the file that "
4637 "it's editing. This will cause nothing to happen to either the repository or "
4638 "the working directory."
4639 msgstr ""
4641 #. type: Content of: <book><chapter><sect1><sect2><title>
4642 #: ../en/ch02-tour-basic.xml:736
4643 msgid "Admiring our new handiwork"
4644 msgstr "欣赏我们的成果"
4646 #. type: Content of: <book><chapter><sect1><sect2><para>
4647 #: ../en/ch02-tour-basic.xml:738
4648 msgid ""
4649 "Once we've finished the commit, we can use the <command role=\"hg-cmd\">hg "
4650 "tip</command> command to display the changeset we just created. This command "
4651 "produces output that is identical to <command role=\"hg-cmd\">hg log</"
4652 "command>, but it only displays the newest revision in the repository."
4653 msgstr ""
4655 #. type: Content of: <book><chapter><sect1><sect2><para>
4656 #: ../en/ch02-tour-basic.xml:746
4657 msgid ""
4658 "We refer to the newest revision in the repository as the <emphasis>tip "
4659 "revision</emphasis>, or simply the <emphasis>tip</emphasis>."
4660 msgstr ""
4662 #. type: Content of: <book><chapter><sect1><sect2><para>
4663 #: ../en/ch02-tour-basic.xml:750
4664 msgid ""
4665 "By the way, the <command role=\"hg-cmd\">hg tip</command> command accepts "
4666 "many of the same options as <command role=\"hg-cmd\">hg log</command>, so "
4667 "<option role=\"hg-opt-global\">-v</option> above indicates <quote>be verbose</"
4668 "quote>, <option role=\"hg-opt-tip\">-p</option> specifies <quote>print a "
4669 "patch</quote>. The use of <option role=\"hg-opt-tip\">-p</option> to print "
4670 "patches is another example of the consistent naming we mentioned earlier."
4671 msgstr ""
4673 #. type: Content of: <book><chapter><sect1><title>
4674 #: ../en/ch02-tour-basic.xml:762
4675 msgid "Sharing changes"
4676 msgstr "共享修改"
4678 #. type: Content of: <book><chapter><sect1><para>
4679 #: ../en/ch02-tour-basic.xml:764
4680 msgid ""
4681 "We mentioned earlier that repositories in Mercurial are self-contained. This "
4682 "means that the changeset we just created exists only in our <filename class="
4683 "\"directory\">my-hello</filename> repository. Let's look at a few ways that "
4684 "we can propagate this change into other repositories."
4685 msgstr ""
4687 #. type: Content of: <book><chapter><sect1><sect2><title>
4688 #: ../en/ch02-tour-basic.xml:772
4689 msgid "Pulling changes from another repository"
4690 msgstr "从其它版本库取得修改"
4692 #. type: Content of: <book><chapter><sect1><sect2><para>
4693 #: ../en/ch02-tour-basic.xml:774
4694 msgid ""
4695 "To get started, let's clone our original <filename class=\"directory\">hello</"
4696 "filename> repository, which does not contain the change we just committed. "
4697 "We'll call our temporary repository <filename class=\"directory\">hello-pull</"
4698 "filename>."
4699 msgstr ""
4701 #. type: Content of: <book><chapter><sect1><sect2><para>
4702 #: ../en/ch02-tour-basic.xml:782
4703 msgid ""
4704 "We'll use the <command role=\"hg-cmd\">hg pull</command> command to bring "
4705 "changes from <filename class=\"directory\">my-hello</filename> into <filename "
4706 "class=\"directory\">hello-pull</filename>. However, blindly pulling unknown "
4707 "changes into a repository is a somewhat scary prospect. Mercurial provides "
4708 "the <command role=\"hg-cmd\">hg incoming</command> command to tell us what "
4709 "changes the <command role=\"hg-cmd\">hg pull</command> command "
4710 "<emphasis>would</emphasis> pull into the repository, without actually pulling "
4711 "the changes in."
4712 msgstr ""
4714 #. type: Content of: <book><chapter><sect1><sect2><para>
4715 #: ../en/ch02-tour-basic.xml:795
4716 msgid ""
4717 "Bringing changes into a repository is a simple matter of running the <command "
4718 "role=\"hg-cmd\">hg pull</command> command, and optionally telling it which "
4719 "repository to pull from."
4720 msgstr ""
4722 #. type: Content of: <book><chapter><sect1><sect2><para>
4723 #: ../en/ch02-tour-basic.xml:801
4724 msgid ""
4725 "As you can see from the before-and-after output of <command role=\"hg-cmd"
4726 "\">hg tip</command>, we have successfully pulled changes into our "
4727 "repository. However, Mercurial separates pulling changes in from updating "
4728 "the working directory. There remains one step before we will see the changes "
4729 "that we just pulled appear in the working directory."
4730 msgstr ""
4732 #. type: Content of: <book><chapter><sect1><sect2><tip><title>
4733 #: ../en/ch02-tour-basic.xml:810
4734 msgid "Pulling specific changes"
4735 msgstr "提取指定的修改"
4737 #. type: Content of: <book><chapter><sect1><sect2><tip><para>
4738 #: ../en/ch02-tour-basic.xml:812
4739 msgid ""
4740 "It is possible that due to the delay between running <command role=\"hg-cmd"
4741 "\">hg incoming</command> and <command role=\"hg-cmd\">hg pull</command>, you "
4742 "may not see all changesets that will be brought from the other repository. "
4743 "Suppose you're pulling changes from a repository on the network somewhere. "
4744 "While you are looking at the <command role=\"hg-cmd\">hg incoming</command> "
4745 "output, and before you pull those changes, someone might have committed "
4746 "something in the remote repository. This means that it's possible to pull "
4747 "more changes than you saw when using <command role=\"hg-cmd\">hg incoming</"
4748 "command>."
4749 msgstr ""
4751 #. type: Content of: <book><chapter><sect1><sect2><tip><para>
4752 #: ../en/ch02-tour-basic.xml:824
4753 msgid ""
4754 "If you only want to pull precisely the changes that were listed by <command "
4755 "role=\"hg-cmd\">hg incoming</command>, or you have some other reason to pull "
4756 "a subset of changes, simply identify the change that you want to pull by its "
4757 "changeset ID, e.g. <command>hg pull -r7e95bb</command>."
4758 msgstr ""
4760 #. type: Content of: <book><chapter><sect1><sect2><title>
4761 #: ../en/ch02-tour-basic.xml:834
4762 msgid "Updating the working directory"
4763 msgstr "更新工作目录"
4765 #. type: Content of: <book><chapter><sect1><sect2><para>
4766 #: ../en/ch02-tour-basic.xml:836
4767 msgid ""
4768 "We have so far glossed over the relationship between a repository and its "
4769 "working directory. The <command role=\"hg-cmd\">hg pull</command> command "
4770 "that we ran in <xref linkend=\"sec:tour:pull\"/> brought changes into the "
4771 "repository, but if we check, there's no sign of those changes in the working "
4772 "directory. This is because <command role=\"hg-cmd\">hg pull</command> does "
4773 "not (by default) touch the working directory. Instead, we use the <command "
4774 "role=\"hg-cmd\">hg update</command> command to do this."
4775 msgstr ""
4777 #. type: Content of: <book><chapter><sect1><sect2><para>
4778 #: ../en/ch02-tour-basic.xml:848
4779 msgid ""
4780 "It might seem a bit strange that <command role=\"hg-cmd\">hg pull</command> "
4781 "doesn't update the working directory automatically. There's actually a good "
4782 "reason for this: you can use <command role=\"hg-cmd\">hg update</command> to "
4783 "update the working directory to the state it was in at <emphasis>any "
4784 "revision</emphasis> in the history of the repository. If you had the working "
4785 "directory updated to an old revision&emdash;to hunt down the origin of a bug, "
4786 "say&emdash;and ran a <command role=\"hg-cmd\">hg pull</command> which "
4787 "automatically updated the working directory to a new revision, you might not "
4788 "be terribly happy."
4789 msgstr ""
4791 #. type: Content of: <book><chapter><sect1><sect2><para>
4792 #: ../en/ch02-tour-basic.xml:860
4793 msgid ""
4794 "Since pull-then-update is such a common sequence of operations, Mercurial "
4795 "lets you combine the two by passing the <option role=\"hg-opt-pull\">-u</"
4796 "option> option to <command role=\"hg-cmd\">hg pull</command>."
4797 msgstr ""
4799 #. type: Content of: <book><chapter><sect1><sect2><para>
4800 #: ../en/ch02-tour-basic.xml:865
4801 msgid ""
4802 "If you look back at the output of <command role=\"hg-cmd\">hg pull</command> "
4803 "in <xref linkend=\"sec:tour:pull\"/> when we ran it without <option role=\"hg-"
4804 "opt-pull\">-u</option>, you can see that it printed a helpful reminder that "
4805 "we'd have to take an explicit step to update the working directory."
4806 msgstr ""
4808 #. type: Content of: <book><chapter><sect1><sect2><para>
4809 #: ../en/ch02-tour-basic.xml:872
4810 msgid ""
4811 "To find out what revision the working directory is at, use the <command role="
4812 "\"hg-cmd\">hg parents</command> command."
4813 msgstr ""
4815 #. type: Content of: <book><chapter><sect1><sect2><para>
4816 #: ../en/ch02-tour-basic.xml:878
4817 msgid ""
4818 "If you look back at <xref linkend=\"fig:tour-basic:history\"/>, you'll see "
4819 "arrows connecting each changeset. The node that the arrow leads "
4820 "<emphasis>from</emphasis> in each case is a parent, and the node that the "
4821 "arrow leads <emphasis>to</emphasis> is its child. The working directory has "
4822 "a parent in just the same way; this is the changeset that the working "
4823 "directory currently contains."
4824 msgstr ""
4826 #. type: Content of: <book><chapter><sect1><sect2><para>
4827 #: ../en/ch02-tour-basic.xml:887
4828 msgid ""
4829 "To update the working directory to a particular revision, give a revision "
4830 "number or changeset ID to the <command role=\"hg-cmd\">hg update</command> "
4831 "command."
4832 msgstr ""
4834 #. type: Content of: <book><chapter><sect1><sect2><para>
4835 #: ../en/ch02-tour-basic.xml:893
4836 msgid ""
4837 "If you omit an explicit revision, <command role=\"hg-cmd\">hg update</"
4838 "command> will update to the tip revision, as shown by the second call to "
4839 "<command role=\"hg-cmd\">hg update</command> in the example above."
4840 msgstr ""
4842 #. type: Content of: <book><chapter><sect1><sect2><title>
4843 #: ../en/ch02-tour-basic.xml:901
4844 msgid "Pushing changes to another repository"
4845 msgstr "发布修改到其它版本库"
4847 #. type: Content of: <book><chapter><sect1><sect2><para>
4848 #: ../en/ch02-tour-basic.xml:903
4849 msgid ""
4850 "Mercurial lets us push changes to another repository, from the repository "
4851 "we're currently visiting. As with the example of <command role=\"hg-cmd\">hg "
4852 "pull</command> above, we'll create a temporary repository to push our changes "
4853 "into."
4854 msgstr ""
4856 #. type: Content of: <book><chapter><sect1><sect2><para>
4857 #: ../en/ch02-tour-basic.xml:911
4858 msgid ""
4859 "The <command role=\"hg-cmd\">hg outgoing</command> command tells us what "
4860 "changes would be pushed into another repository."
4861 msgstr ""
4863 #. type: Content of: <book><chapter><sect1><sect2><para>
4864 #: ../en/ch02-tour-basic.xml:917
4865 msgid ""
4866 "And the <command role=\"hg-cmd\">hg push</command> command does the actual "
4867 "push."
4868 msgstr ""
4870 #. type: Content of: <book><chapter><sect1><sect2><para>
4871 #: ../en/ch02-tour-basic.xml:922
4872 msgid ""
4873 "As with <command role=\"hg-cmd\">hg pull</command>, the <command role=\"hg-cmd"
4874 "\">hg push</command> command does not update the working directory in the "
4875 "repository that it's pushing changes into. Unlike <command role=\"hg-cmd\">hg "
4876 "pull</command>, <command role=\"hg-cmd\">hg push</command> does not provide a "
4877 "<literal>-u</literal> option that updates the other repository's working "
4878 "directory. This asymmetry is deliberate: the repository we're pushing to "
4879 "might be on a remote server and shared between several people. If we were to "
4880 "update its working directory while someone was working in it, their work "
4881 "would be disrupted."
4882 msgstr ""
4884 #. type: Content of: <book><chapter><sect1><sect2><para>
4885 #: ../en/ch02-tour-basic.xml:934
4886 msgid ""
4887 "What happens if we try to pull or push changes and the receiving repository "
4888 "already has those changes? Nothing too exciting."
4889 msgstr ""
4891 #. type: Content of: <book><chapter><sect1><sect2><title>
4892 #: ../en/ch02-tour-basic.xml:942
4893 msgid "Default locations"
4894 msgstr "默认位置"
4896 #. type: Content of: <book><chapter><sect1><sect2><para>
4897 #: ../en/ch02-tour-basic.xml:944
4898 msgid ""
4899 "When we clone a repository, Mercurial records the location of the repository "
4900 "we cloned in the <filename>.hg/hgrc</filename> file of the new repository. "
4901 "If we don't supply a location to <command>hg pull</command> from or "
4902 "<command>hg push</command> to, those commands will use this location as a "
4903 "default. The <command>hg incoming</command> and <command>hg outgoing</"
4904 "command> commands do so too."
4905 msgstr ""
4907 #. type: Content of: <book><chapter><sect1><sect2><para>
4908 #: ../en/ch02-tour-basic.xml:952
4909 msgid ""
4910 "If you open a repository's <filename>.hg/hgrc</filename> file in a text "
4911 "editor, you will see contents like the following."
4912 msgstr ""
4914 #. type: Content of: <book><chapter><sect1><sect2><para>
4915 #: ../en/ch02-tour-basic.xml:959
4916 msgid ""
4917 "It is possible&emdash;and often useful&emdash;to have the default location "
4918 "for <command>hg push</command> and <command>hg outgoing</command> be "
4919 "different from those for <command>hg pull</command> and <command>hg incoming</"
4920 "command>. We can do this by adding a <literal>default-push</literal> entry "
4921 "to the <literal>[paths]</literal> section of the <filename>.hg/hgrc</"
4922 "filename> file, as follows."
4923 msgstr ""
4925 #. type: Content of: <book><chapter><sect1><sect2><title>
4926 #: ../en/ch02-tour-basic.xml:973
4927 msgid "Sharing changes over a network"
4928 msgstr "通过网络共享修改"
4930 #. type: Content of: <book><chapter><sect1><sect2><para>
4931 #: ../en/ch02-tour-basic.xml:975
4932 msgid ""
4933 "The commands we have covered in the previous few sections are not limited to "
4934 "working with local repositories. Each works in exactly the same fashion over "
4935 "a network connection; simply pass in a URL instead of a local path."
4936 msgstr ""
4938 #. type: Content of: <book><chapter><sect1><sect2><para>
4939 #: ../en/ch02-tour-basic.xml:983
4940 msgid ""
4941 "In this example, we can see what changes we could push to the remote "
4942 "repository, but the repository is understandably not set up to let anonymous "
4943 "users push to it."
4944 msgstr ""
4946 #. type: Content of: <book><chapter><sect1><title>
4947 #: ../en/ch02-tour-basic.xml:993
4948 msgid "Starting a new project"
4949 msgstr "开始新项目"
4951 #. type: Content of: <book><chapter><sect1><para>
4952 #: ../en/ch02-tour-basic.xml:995
4953 msgid ""
4954 "It is just as easy to begin a new project as to work on one that already "
4955 "exists. The <command>hg init</command> command creates a new, empty "
4956 "Mercurial repository."
4957 msgstr ""
4959 #. type: Content of: <book><chapter><sect1><para>
4960 #: ../en/ch02-tour-basic.xml:1001
4961 msgid ""
4962 "This simply creates a repository named <filename>myproject</filename> in the "
4963 "current directory."
4964 msgstr ""
4966 #. type: Content of: <book><chapter><sect1><para>
4967 #: ../en/ch02-tour-basic.xml:1006
4968 msgid ""
4969 "We can tell that <filename>myproject</filename> is a Mercurial repository, "
4970 "because it contains a <filename>.hg</filename> directory."
4971 msgstr ""
4973 #. type: Content of: <book><chapter><sect1><para>
4974 #: ../en/ch02-tour-basic.xml:1012
4975 msgid ""
4976 "If we want to add some pre-existing files to the repository, we copy them "
4977 "into place, and tell Mercurial to start tracking them using the <command>hg "
4978 "add</command> command."
4979 msgstr ""
4981 #. type: Content of: <book><chapter><sect1><para>
4982 #: ../en/ch02-tour-basic.xml:1018
4983 msgid ""
4984 "Once we are satisfied that our project looks right, we commit our changes."
4985 msgstr ""
4987 #. type: Content of: <book><chapter><sect1><para>
4988 #: ../en/ch02-tour-basic.xml:1023
4989 msgid ""
4990 "It takes just a few moments to start using Mercurial on a new project, which "
4991 "is part of its appeal. Revision control is now so easy to work with, we can "
4992 "use it on the smallest of projects that we might not have considered with a "
4993 "more complicated tool."
4994 msgstr ""
4996 #. type: Content of: <book><chapter><title>
4997 #: ../en/ch03-tour-merge.xml:5
4998 msgid "A tour of Mercurial: merging work"
4999 msgstr "Mercurial 教程: 合并工作"
5001 #. type: Content of: <book><chapter><para>
5002 #: ../en/ch03-tour-merge.xml:7
5003 msgid ""
5004 "We've now covered cloning a repository, making changes in a repository, and "
5005 "pulling or pushing changes from one repository into another. Our next step "
5006 "is <emphasis>merging</emphasis> changes from separate repositories."
5007 msgstr ""
5009 #. type: Content of: <book><chapter><sect1><title>
5010 #: ../en/ch03-tour-merge.xml:13
5011 msgid "Merging streams of work"
5012 msgstr "合并的流程"
5014 #. type: Content of: <book><chapter><sect1><para>
5015 #: ../en/ch03-tour-merge.xml:15
5016 msgid ""
5017 "Merging is a fundamental part of working with a distributed revision control "
5018 "tool. Here are a few cases in which the need to merge work arises."
5019 msgstr ""
5021 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
5022 #: ../en/ch03-tour-merge.xml:20
5023 msgid ""
5024 "Alice and Bob each have a personal copy of a repository for a project they're "
5025 "collaborating on. Alice fixes a bug in her repository; Bob adds a new "
5026 "feature in his. They want the shared repository to contain both the bug fix "
5027 "and the new feature."
5028 msgstr ""
5030 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
5031 #: ../en/ch03-tour-merge.xml:27
5032 msgid ""
5033 "Cynthia frequently works on several different tasks for a single project at "
5034 "once, each safely isolated in its own repository. Working this way means that "
5035 "she often needs to merge one piece of her own work with another."
5036 msgstr ""
5038 #. type: Content of: <book><chapter><sect1><para>
5039 #: ../en/ch03-tour-merge.xml:35
5040 msgid ""
5041 "Because we need to merge often, Mercurial makes the process easy. Let's walk "
5042 "through a merge. We'll begin by cloning yet another repository (see how "
5043 "often they spring up?) and making a change in it."
5044 msgstr ""
5046 #. type: Content of: <book><chapter><sect1><para>
5047 #: ../en/ch03-tour-merge.xml:42
5048 msgid ""
5049 "We should now have two copies of <filename>hello.c</filename> with different "
5050 "contents. The histories of the two repositories have also diverged, as "
5051 "illustrated in <xref linkend=\"fig:tour-merge:sep-repos\"/>. Here is a copy "
5052 "of our file from one repository."
5053 msgstr ""
5055 #. type: Content of: <book><chapter><sect1><para>
5056 #: ../en/ch03-tour-merge.xml:51
5057 msgid "And here is our slightly different version from the other repository."
5058 msgstr ""
5060 #. type: Content of: <book><chapter><sect1><figure><title>
5061 #: ../en/ch03-tour-merge.xml:57
5062 msgid ""
5063 "Divergent recent histories of the <filename class=\"directory\">my-hello</"
5064 "filename> and <filename class=\"directory\">my-new-hello</filename> "
5065 "repositories"
5066 msgstr ""
5067 "<filename class=\"directory\">my-hello</filename> 与 <filename class="
5068 "\"directory\">my-new-hello</filename> 最新的历史分叉"
5070 #. type: Content of: <book><chapter><sect1><figure><mediaobject>
5071 #: ../en/ch03-tour-merge.xml:62
5072 msgid ""
5073 "<imageobject><imagedata fileref=\"figs/tour-merge-sep-repos.png\"/></"
5074 "imageobject>"
5075 msgstr ""
5077 #. type: Content of: <book><chapter><sect1><para>
5078 #: ../en/ch03-tour-merge.xml:67
5079 msgid ""
5080 "We already know that pulling changes from our <filename class=\"directory"
5081 "\">my-hello</filename> repository will have no effect on the working "
5082 "directory."
5083 msgstr ""
5085 #. type: Content of: <book><chapter><sect1><para>
5086 #: ../en/ch03-tour-merge.xml:73
5087 msgid ""
5088 "However, the <command role=\"hg-cmd\">hg pull</command> command says "
5089 "something about <quote>heads</quote>."
5090 msgstr ""
5092 #. type: Content of: <book><chapter><sect1><sect2><title>
5093 #: ../en/ch03-tour-merge.xml:77
5094 msgid "Head changesets"
5095 msgstr "顶点修改集"
5097 #. type: Content of: <book><chapter><sect1><sect2><para>
5098 #: ../en/ch03-tour-merge.xml:79
5099 msgid ""
5100 "Remember that Mercurial records what the parent of each change is. If a "
5101 "change has a parent, we call it a child or descendant of the parent. A head "
5102 "is a change that has no children. The tip revision is thus a head, because "
5103 "the newest revision in a repository doesn't have any children. There are "
5104 "times when a repository can contain more than one head."
5105 msgstr ""
5107 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
5108 #: ../en/ch03-tour-merge.xml:88
5109 msgid ""
5110 "Repository contents after pulling from <filename class=\"directory\">my-"
5111 "hello</filename> into <filename class=\"directory\">my-new-hello</filename>"
5112 msgstr ""
5113 "从 <filename class=\"directory\">my-hello</filename> 拉到 <filename class="
5114 "\"directory\">my-new-hello</filename> 之后版本库的内容"
5116 #. type: Content of: <book><chapter><sect1><sect2><figure>
5117 #: ../en/ch03-tour-merge.xml:91 ../en/ch03-tour-merge.xml:178
5118 #: ../en/ch03-tour-merge.xml:275 ../en/ch04-concepts.xml:57
5119 #: ../en/ch04-concepts.xml:106 ../en/ch04-concepts.xml:196
5120 #: ../en/ch04-concepts.xml:345 ../en/ch04-concepts.xml:360
5121 #: ../en/ch04-concepts.xml:401 ../en/ch04-concepts.xml:421
5122 #: ../en/ch04-concepts.xml:465 ../en/ch06-collab.xml:314
5123 #: ../en/ch09-undo.xml:342 ../en/ch09-undo.xml:389 ../en/ch09-undo.xml:462
5124 #: ../en/ch09-undo.xml:500 ../en/ch09-undo.xml:656 ../en/ch09-undo.xml:680
5125 #: ../en/ch09-undo.xml:698 ../en/ch09-undo.xml:712 ../en/ch09-undo.xml:725
5126 #: ../en/ch12-mq.xml:411
5127 msgid " <placeholder type=\"mediaobject\" id=\"0\"/>"
5128 msgstr ""
5130 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
5131 #: ../en/ch03-tour-merge.xml:92
5132 msgid ""
5133 "<imageobject> <imagedata fileref=\"figs/tour-merge-pull.png\"/> </imageobject>"
5134 msgstr ""
5136 #. type: Content of: <book><chapter><sect1><sect2><para>
5137 #: ../en/ch03-tour-merge.xml:99
5138 msgid ""
5139 "In <xref linkend=\"fig:tour-merge:pull\"/>, you can see the effect of the "
5140 "pull from <filename class=\"directory\">my-hello</filename> into <filename "
5141 "class=\"directory\">my-new-hello</filename>. The history that was already "
5142 "present in <filename class=\"directory\">my-new-hello</filename> is "
5143 "untouched, but a new revision has been added. By referring to <xref linkend="
5144 "\"fig:tour-merge:sep-repos\"/>, we can see that the <emphasis>changeset ID</"
5145 "emphasis> remains the same in the new repository, but the <emphasis>revision "
5146 "number</emphasis> has changed. (This, incidentally, is a fine example of why "
5147 "it's not safe to use revision numbers when discussing changesets.) We can "
5148 "view the heads in a repository using the <command role=\"hg-cmd\">hg heads</"
5149 "command> command."
5150 msgstr ""
5152 #. type: Content of: <book><chapter><sect1><sect2><title>
5153 #: ../en/ch03-tour-merge.xml:118
5154 msgid "Performing the merge"
5155 msgstr "执行合并"
5157 #. type: Content of: <book><chapter><sect1><sect2><para>
5158 #: ../en/ch03-tour-merge.xml:120
5159 msgid ""
5160 "What happens if we try to use the normal <command role=\"hg-cmd\">hg update</"
5161 "command> command to update to the new tip?"
5162 msgstr ""
5164 #. type: Content of: <book><chapter><sect1><sect2><para>
5165 #: ../en/ch03-tour-merge.xml:126
5166 msgid ""
5167 "Mercurial is telling us that the <command role=\"hg-cmd\">hg update</command> "
5168 "command won't do a merge; it won't update the working directory when it "
5169 "thinks we might want to do a merge, unless we force it to do so. "
5170 "(Incidentally, forcing the update with <command>hg update -C</command> would "
5171 "revert any uncommitted changes in the working directory.)"
5172 msgstr ""
5174 #. type: Content of: <book><chapter><sect1><sect2><para>
5175 #: ../en/ch03-tour-merge.xml:134
5176 msgid ""
5177 "To start a merge between the two heads, we use the <command role=\"hg-cmd"
5178 "\">hg merge</command> command."
5179 msgstr ""
5180 "我们使用 <command role=\"hg-cmd\">hg merge</command> 命令来合并两个顶点。"
5182 #. type: Content of: <book><chapter><sect1><sect2><para>
5183 #: ../en/ch03-tour-merge.xml:139
5184 msgid ""
5185 "We resolve the contents of <filename>hello.c</filename> This updates the "
5186 "working directory so that it contains changes from <emphasis>both</emphasis> "
5187 "heads, which is reflected in both the output of <command role=\"hg-cmd\">hg "
5188 "parents</command> and the contents of <filename>hello.c</filename>."
5189 msgstr ""
5191 #. type: Content of: <book><chapter><sect1><sect2><title>
5192 #: ../en/ch03-tour-merge.xml:151
5193 msgid "Committing the results of the merge"
5194 msgstr "提交合并结果"
5196 #. type: Content of: <book><chapter><sect1><sect2><para>
5197 #: ../en/ch03-tour-merge.xml:153
5198 msgid ""
5199 "Whenever we've done a merge, <command role=\"hg-cmd\">hg parents</command> "
5200 "will display two parents until we <command role=\"hg-cmd\">hg commit</"
5201 "command> the results of the merge."
5202 msgstr ""
5204 #. type: Content of: <book><chapter><sect1><sect2><para>
5205 #: ../en/ch03-tour-merge.xml:160
5206 msgid ""
5207 "We now have a new tip revision; notice that it has <emphasis>both</emphasis> "
5208 "of our former heads as its parents. These are the same revisions that were "
5209 "previously displayed by <command role=\"hg-cmd\">hg parents</command>."
5210 msgstr ""
5212 #. type: Content of: <book><chapter><sect1><sect2><para>
5213 #: ../en/ch03-tour-merge.xml:167
5214 msgid ""
5215 "In <xref linkend=\"fig:tour-merge:merge\"/>, you can see a representation of "
5216 "what happens to the working directory during the merge, and how this affects "
5217 "the repository when the commit happens. During the merge, the working "
5218 "directory has two parent changesets, and these become the parents of the new "
5219 "changeset."
5220 msgstr ""
5222 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
5223 #: ../en/ch03-tour-merge.xml:176
5224 msgid "Working directory and repository during merge, and following commit"
5225 msgstr "在合并期间,以及提交之后的工作目录与版本库"
5227 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
5228 #: ../en/ch03-tour-merge.xml:179
5229 msgid ""
5230 "<imageobject> <imagedata fileref=\"figs/tour-merge-merge.png\"/> </"
5231 "imageobject>"
5232 msgstr ""
5234 #. type: Content of: <book><chapter><sect1><sect2><para>
5235 #: ../en/ch03-tour-merge.xml:186
5236 msgid ""
5237 "We sometimes talk about a merge having <emphasis>sides</emphasis>: the left "
5238 "side is the first parent in the output of <command role=\"hg-cmd\">hg "
5239 "parents</command>, and the right side is the second. If the working "
5240 "directory was at e.g. revision 5 before we began a merge, that revision will "
5241 "become the left side of the merge."
5242 msgstr ""
5244 #. type: Content of: <book><chapter><sect1><title>
5245 #: ../en/ch03-tour-merge.xml:196
5246 msgid "Merging conflicting changes"
5247 msgstr "合并有冲突的改变"
5249 #. type: Content of: <book><chapter><sect1><para>
5250 #: ../en/ch03-tour-merge.xml:198
5251 msgid ""
5252 "Most merges are simple affairs, but sometimes you'll find yourself merging "
5253 "changes where each side modifies the same portions of the same files. Unless "
5254 "both modifications are identical, this results in a <emphasis>conflict</"
5255 "emphasis>, where you have to decide how to reconcile the different changes "
5256 "into something coherent."
5257 msgstr ""
5259 #. type: Content of: <book><chapter><sect1><figure><title>
5260 #: ../en/ch03-tour-merge.xml:206
5261 msgid "Conflicting changes to a document"
5262 msgstr "冲突的修改"
5264 #. type: Content of: <book><chapter><sect1><figure><mediaobject>
5265 #: ../en/ch03-tour-merge.xml:208
5266 msgid ""
5267 "<imageobject><imagedata fileref=\"figs/tour-merge-conflict.png\"/></"
5268 "imageobject>"
5269 msgstr ""
5271 #. type: Content of: <book><chapter><sect1><para>
5272 #: ../en/ch03-tour-merge.xml:213
5273 msgid ""
5274 "<xref linkend=\"fig:tour-merge:conflict\"/> illustrates an instance of two "
5275 "conflicting changes to a document. We started with a single version of the "
5276 "file; then we made some changes; while someone else made different changes to "
5277 "the same text. Our task in resolving the conflicting changes is to decide "
5278 "what the file should look like."
5279 msgstr ""
5281 #. type: Content of: <book><chapter><sect1><para>
5282 #: ../en/ch03-tour-merge.xml:220
5283 msgid ""
5284 "Mercurial doesn't have a built-in facility for handling conflicts. Instead, "
5285 "it runs an external program, usually one that displays some kind of graphical "
5286 "conflict resolution interface. By default, Mercurial tries to find one of "
5287 "several different merging tools that are likely to be installed on your "
5288 "system. It first tries a few fully automatic merging tools; if these don't "
5289 "succeed (because the resolution process requires human guidance) or aren't "
5290 "present, it tries a few different graphical merging tools."
5291 msgstr ""
5293 #. type: Content of: <book><chapter><sect1><para>
5294 #: ../en/ch03-tour-merge.xml:230
5295 msgid ""
5296 "It's also possible to get Mercurial to run a specific program or script, by "
5297 "setting the <envar>HGMERGE</envar> environment variable to the name of your "
5298 "preferred program."
5299 msgstr ""
5301 #. type: Content of: <book><chapter><sect1><sect2><title>
5302 #: ../en/ch03-tour-merge.xml:236
5303 msgid "Using a graphical merge tool"
5304 msgstr "使用图形合并工具"
5306 #. type: Content of: <book><chapter><sect1><sect2><para>
5307 #: ../en/ch03-tour-merge.xml:238
5308 msgid ""
5309 "My preferred graphical merge tool is <command>kdiff3</command>, which I'll "
5310 "use to describe the features that are common to graphical file merging "
5311 "tools. You can see a screenshot of <command>kdiff3</command> in action in "
5312 "<xref linkend=\"fig:tour-merge:kdiff3\"/>. The kind of merge it is "
5313 "performing is called a <emphasis>three-way merge</emphasis>, because there "
5314 "are three different versions of the file of interest to us. The tool thus "
5315 "splits the upper portion of the window into three panes:"
5316 msgstr ""
5318 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
5319 #: ../en/ch03-tour-merge.xml:248
5320 msgid ""
5321 "At the left is the <emphasis>base</emphasis> version of the file, i.e. the "
5322 "most recent version from which the two versions we're trying to merge are "
5323 "descended."
5324 msgstr ""
5326 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
5327 #: ../en/ch03-tour-merge.xml:253
5328 msgid ""
5329 "In the middle is <quote>our</quote> version of the file, with the contents "
5330 "that we modified."
5331 msgstr ""
5333 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
5334 #: ../en/ch03-tour-merge.xml:256
5335 msgid ""
5336 "On the right is <quote>their</quote> version of the file, the one that from "
5337 "the changeset that we're trying to merge with."
5338 msgstr ""
5340 #. type: Content of: <book><chapter><sect1><sect2><para>
5341 #: ../en/ch03-tour-merge.xml:260
5342 msgid ""
5343 "In the pane below these is the current <emphasis>result</emphasis> of the "
5344 "merge. Our task is to replace all of the red text, which indicates unresolved "
5345 "conflicts, with some sensible merger of the <quote>ours</quote> and "
5346 "<quote>theirs</quote> versions of the file."
5347 msgstr ""
5349 #. type: Content of: <book><chapter><sect1><sect2><para>
5350 #: ../en/ch03-tour-merge.xml:267
5351 msgid ""
5352 "All four of these panes are <emphasis>locked together</emphasis>; if we "
5353 "scroll vertically or horizontally in any of them, the others are updated to "
5354 "display the corresponding sections of their respective files."
5355 msgstr ""
5357 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
5358 #: ../en/ch03-tour-merge.xml:273
5359 msgid "Using <command>kdiff3</command> to merge versions of a file"
5360 msgstr "使用 <command>kdiff3</command> 合并文件的不同版本"
5362 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
5363 #: ../en/ch03-tour-merge.xml:276
5364 msgid ""
5365 "<imageobject> <imagedata width=\"100%\" fileref=\"figs/kdiff3.png\"/></"
5366 "imageobject>"
5367 msgstr ""
5369 #. type: Content of: <book><chapter><sect1><sect2><para>
5370 #: ../en/ch03-tour-merge.xml:284
5371 msgid ""
5372 "For each conflicting portion of the file, we can choose to resolve the "
5373 "conflict using some combination of text from the base version, ours, or "
5374 "theirs. We can also manually edit the merged file at any time, in case we "
5375 "need to make further modifications."
5376 msgstr ""
5378 #. type: Content of: <book><chapter><sect1><sect2><para>
5379 #: ../en/ch03-tour-merge.xml:290
5380 msgid ""
5381 "There are <emphasis>many</emphasis> file merging tools available, too many to "
5382 "cover here. They vary in which platforms they are available for, and in "
5383 "their particular strengths and weaknesses. Most are tuned for merging files "
5384 "containing plain text, while a few are aimed at specialised file formats "
5385 "(generally XML)."
5386 msgstr ""
5388 #. type: Content of: <book><chapter><sect1><sect2><title>
5389 #: ../en/ch03-tour-merge.xml:299
5390 msgid "A worked example"
5391 msgstr "合并实例"
5393 #. type: Content of: <book><chapter><sect1><sect2><para>
5394 #: ../en/ch03-tour-merge.xml:301
5395 msgid ""
5396 "In this example, we will reproduce the file modification history of <xref "
5397 "linkend=\"fig:tour-merge:conflict\"/> above. Let's begin by creating a "
5398 "repository with a base version of our document."
5399 msgstr ""
5401 #. type: Content of: <book><chapter><sect1><sect2><para>
5402 #: ../en/ch03-tour-merge.xml:308
5403 msgid "We'll clone the repository and make a change to the file."
5404 msgstr ""
5406 #. type: Content of: <book><chapter><sect1><sect2><para>
5407 #: ../en/ch03-tour-merge.xml:313
5408 msgid ""
5409 "And another clone, to simulate someone else making a change to the file. "
5410 "(This hints at the idea that it's not all that unusual to merge with yourself "
5411 "when you isolate tasks in separate repositories, and indeed to find and "
5412 "resolve conflicts while doing so.)"
5413 msgstr ""
5415 #. type: Content of: <book><chapter><sect1><sect2><para>
5416 #: ../en/ch03-tour-merge.xml:321
5417 msgid ""
5418 "Having created two different versions of the file, we'll set up an "
5419 "environment suitable for running our merge."
5420 msgstr ""
5422 #. type: Content of: <book><chapter><sect1><sect2><para>
5423 #: ../en/ch03-tour-merge.xml:327
5424 msgid ""
5425 "In this example, I'll set <envar>HGMERGE</envar> to tell Mercurial to use the "
5426 "non-interactive <command>merge</command> command. This is bundled with many "
5427 "Unix-like systems. (If you're following this example on your computer, don't "
5428 "bother setting <envar>HGMERGE</envar>. You'll get dropped into a GUI file "
5429 "merge tool instead, which is much preferable.)"
5430 msgstr ""
5432 #. type: Content of: <book><chapter><sect1><sect2><para>
5433 #: ../en/ch03-tour-merge.xml:337
5434 msgid ""
5435 "Because <command>merge</command> can't resolve the conflicting changes, it "
5436 "leaves <emphasis>merge markers</emphasis> inside the file that has conflicts, "
5437 "indicating which lines have conflicts, and whether they came from our version "
5438 "of the file or theirs."
5439 msgstr ""
5441 #. type: Content of: <book><chapter><sect1><sect2><para>
5442 #: ../en/ch03-tour-merge.xml:343
5443 msgid ""
5444 "Mercurial can tell from the way <command>merge</command> exits that it wasn't "
5445 "able to merge successfully, so it tells us what commands we'll need to run if "
5446 "we want to redo the merging operation. This could be useful if, for example, "
5447 "we were running a graphical merge tool and quit because we were confused or "
5448 "realised we had made a mistake."
5449 msgstr ""
5451 #. type: Content of: <book><chapter><sect1><sect2><para>
5452 #: ../en/ch03-tour-merge.xml:350
5453 msgid ""
5454 "If automatic or manual merges fail, there's nothing to prevent us from "
5455 "<quote>fixing up</quote> the affected files ourselves, and committing the "
5456 "results of our merge:"
5457 msgstr ""
5459 #. type: Content of: <book><chapter><sect1><sect2><note><title>
5460 #: ../en/ch03-tour-merge.xml:357
5461 msgid "Where is the <command>hg resolve</command> command?"
5462 msgstr "在哪里能找到 <command role=\"hg-cmd\">hg resolve</command> 命令?"
5464 #. type: Content of: <book><chapter><sect1><sect2><note><para>
5465 #: ../en/ch03-tour-merge.xml:359
5466 msgid ""
5467 "The <command>hg resolve</command> command was introduced in Mercurial 1.1, "
5468 "which was released in December 2008. If you are using an older version of "
5469 "Mercurial (run <command>hg version</command> to see), this command will not "
5470 "be present. If your version of Mercurial is older than 1.1, you should "
5471 "strongly consider upgrading to a newer version before trying to tackle "
5472 "complicated merges."
5473 msgstr ""
5475 #. type: Content of: <book><chapter><sect1><title>
5476 #: ../en/ch03-tour-merge.xml:371
5477 msgid "Simplifying the pull-merge-commit sequence"
5478 msgstr "简化拉-合并-提交程序"
5480 #. type: Content of: <book><chapter><sect1><para>
5481 #: ../en/ch03-tour-merge.xml:373
5482 msgid ""
5483 "The process of merging changes as outlined above is straightforward, but "
5484 "requires running three commands in sequence."
5485 msgstr ""
5487 #. type: Content of: <book><chapter><sect1><para>
5488 #: ../en/ch03-tour-merge.xml:379
5489 msgid ""
5490 "In the case of the final commit, you also need to enter a commit message, "
5491 "which is almost always going to be a piece of uninteresting "
5492 "<quote>boilerplate</quote> text."
5493 msgstr ""
5495 #. type: Content of: <book><chapter><sect1><para>
5496 #: ../en/ch03-tour-merge.xml:383
5497 msgid ""
5498 "It would be nice to reduce the number of steps needed, if this were "
5499 "possible. Indeed, Mercurial is distributed with an extension called <literal "
5500 "role=\"hg-ext\">fetch</literal> that does just this."
5501 msgstr ""
5503 #. type: Content of: <book><chapter><sect1><para>
5504 #: ../en/ch03-tour-merge.xml:388
5505 msgid ""
5506 "Mercurial provides a flexible extension mechanism that lets people extend its "
5507 "functionality, while keeping the core of Mercurial small and easy to deal "
5508 "with. Some extensions add new commands that you can use from the command "
5509 "line, while others work <quote>behind the scenes,</quote> for example adding "
5510 "capabilities to Mercurial's built-in server mode."
5511 msgstr ""
5513 #. type: Content of: <book><chapter><sect1><para>
5514 #: ../en/ch03-tour-merge.xml:395
5515 msgid ""
5516 "The <literal role=\"hg-ext\">fetch</literal> extension adds a new command "
5517 "called, not surprisingly, <command role=\"hg-cmd\">hg fetch</command>. This "
5518 "extension acts as a combination of <command role=\"hg-cmd\">hg pull -u</"
5519 "command>, <command role=\"hg-cmd\">hg merge</command> and <command role=\"hg-"
5520 "cmd\">hg commit</command>. It begins by pulling changes from another "
5521 "repository into the current repository. If it finds that the changes added a "
5522 "new head to the repository, it updates to the new head, begins a merge, then "
5523 "(if the merge succeeded) commits the result of the merge with an "
5524 "automatically-generated commit message. If no new heads were added, it "
5525 "updates the working directory to the new tip changeset."
5526 msgstr ""
5528 #. type: Content of: <book><chapter><sect1><para>
5529 #: ../en/ch03-tour-merge.xml:409
5530 msgid ""
5531 "Enabling the <literal role=\"hg-ext\">fetch</literal> extension is easy. "
5532 "Edit the <filename role=\"special\">.hgrc</filename> file in your home "
5533 "directory, and either go to the <literal role=\"rc-extensions\">extensions</"
5534 "literal> section or create an <literal role=\"rc-extensions\">extensions</"
5535 "literal> section. Then add a line that simply reads <quote><literal>fetch=</"
5536 "literal></quote>."
5537 msgstr ""
5539 #. type: Content of: <book><chapter><sect1><para>
5540 #: ../en/ch03-tour-merge.xml:421
5541 msgid ""
5542 "(Normally, the right-hand side of the <quote><literal>=</literal></quote> "
5543 "would indicate where to find the extension, but since the <literal role=\"hg-"
5544 "ext\">fetch</literal> extension is in the standard distribution, Mercurial "
5545 "knows where to search for it.)"
5546 msgstr ""
5548 #. type: Content of: <book><chapter><sect1><title>
5549 #: ../en/ch03-tour-merge.xml:429
5550 msgid "Renaming, copying, and merging"
5551 msgstr "改名,复制与合并"
5553 #. type: Content of: <book><chapter><sect1><para>
5554 #: ../en/ch03-tour-merge.xml:431
5555 msgid ""
5556 "During the life of a project, we will often want to change the layout of its "
5557 "files and directories. This can be as simple as renaming a single file, or as "
5558 "complex as restructuring the entire hierarchy of files within the project."
5559 msgstr ""
5561 #. type: Content of: <book><chapter><sect1><para>
5562 #: ../en/ch03-tour-merge.xml:436
5563 msgid ""
5564 "Mercurial supports these kinds of complex changes fluently, provided we tell "
5565 "it what we're doing. If we want to rename a file, we should use the "
5566 "<command>hg rename</command><placeholder type=\"footnote\" id=\"0\"/> command "
5567 "to rename it, so that Mercurial can do the right thing later when we merge."
5568 msgstr ""
5570 #. type: Content of: <book><chapter><sect1><para><footnote><para>
5571 #: ../en/ch03-tour-merge.xml:439
5572 msgid ""
5573 "If you're a Unix user, you'll be glad to know that the <command>hg rename</"
5574 "command> command can be abbreviated as <command>hg mv</command>."
5575 msgstr ""
5577 #. type: Content of: <book><chapter><sect1><para>
5578 #: ../en/ch03-tour-merge.xml:445
5579 msgid ""
5580 "We will cover the use of these commands in more detail in <xref linkend="
5581 "\"chap:daily.copy\"/>."
5582 msgstr ""
5584 #. type: Content of: <book><chapter><title>
5585 #: ../en/ch04-concepts.xml:5
5586 msgid "Behind the scenes"
5587 msgstr "Mercurial 内幕"
5589 #. type: Content of: <book><chapter><para>
5590 #: ../en/ch04-concepts.xml:7
5591 msgid ""
5592 "Unlike many revision control systems, the concepts upon which Mercurial is "
5593 "built are simple enough that it's easy to understand how the software really "
5594 "works. Knowing these details certainly isn't necessary, so it is certainly "
5595 "safe to skip this chapter. However, I think you will get more out of the "
5596 "software with a <quote>mental model</quote> of what's going on."
5597 msgstr ""
5599 #. type: Content of: <book><chapter><para>
5600 #: ../en/ch04-concepts.xml:14
5601 msgid ""
5602 "Being able to understand what's going on behind the scenes gives me "
5603 "confidence that Mercurial has been carefully designed to be both "
5604 "<emphasis>safe</emphasis> and <emphasis>efficient</emphasis>. And just as "
5605 "importantly, if it's easy for me to retain a good idea of what the software "
5606 "is doing when I perform a revision control task, I'm less likely to be "
5607 "surprised by its behavior."
5608 msgstr ""
5610 #. type: Content of: <book><chapter><para>
5611 #: ../en/ch04-concepts.xml:22
5612 msgid ""
5613 "In this chapter, we'll initially cover the core concepts behind Mercurial's "
5614 "design, then continue to discuss some of the interesting details of its "
5615 "implementation."
5616 msgstr ""
5618 #. type: Content of: <book><chapter><sect1><title>
5619 #: ../en/ch04-concepts.xml:27
5620 msgid "Mercurial's historical record"
5621 msgstr "Mercurial 的历史记录"
5623 #. type: Content of: <book><chapter><sect1><sect2><title>
5624 #: ../en/ch04-concepts.xml:30
5625 msgid "Tracking the history of a single file"
5626 msgstr "跟踪单一文件的历史"
5628 #. type: Content of: <book><chapter><sect1><sect2><para>
5629 #: ../en/ch04-concepts.xml:32
5630 msgid ""
5631 "When Mercurial tracks modifications to a file, it stores the history of that "
5632 "file in a metadata object called a <emphasis>filelog</emphasis>. Each entry "
5633 "in the filelog contains enough information to reconstruct one revision of the "
5634 "file that is being tracked. Filelogs are stored as files in the <filename "
5635 "role=\"special\" class=\"directory\">.hg/store/data</filename> directory. A "
5636 "filelog contains two kinds of information: revision data, and an index to "
5637 "help Mercurial to find a revision efficiently."
5638 msgstr ""
5640 #. type: Content of: <book><chapter><sect1><sect2><para>
5641 #: ../en/ch04-concepts.xml:43
5642 msgid ""
5643 "A file that is large, or has a lot of history, has its filelog stored in "
5644 "separate data (<quote><literal>.d</literal></quote> suffix) and index "
5645 "(<quote><literal>.i</literal></quote> suffix) files. For small files without "
5646 "much history, the revision data and index are combined in a single "
5647 "<quote><literal>.i</literal></quote> file. The correspondence between a file "
5648 "in the working directory and the filelog that tracks its history in the "
5649 "repository is illustrated in <xref linkend=\"fig:concepts:filelog\"/>."
5650 msgstr ""
5652 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
5653 #: ../en/ch04-concepts.xml:55
5654 msgid ""
5655 "Relationships between files in working directory and filelogs in repository"
5656 msgstr "工作目录中的文件与版本库中的文件日志之间的关系"
5658 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
5659 #: ../en/ch04-concepts.xml:58
5660 msgid "<imageobject><imagedata fileref=\"figs/filelog.png\"/></imageobject>"
5661 msgstr ""
5663 #. type: Content of: <book><chapter><sect1><sect2><title>
5664 #: ../en/ch04-concepts.xml:65
5665 msgid "Managing tracked files"
5666 msgstr "管理跟踪的文件"
5668 #. type: Content of: <book><chapter><sect1><sect2><para>
5669 #: ../en/ch04-concepts.xml:67
5670 msgid ""
5671 "Mercurial uses a structure called a <emphasis>manifest</emphasis> to collect "
5672 "together information about the files that it tracks. Each entry in the "
5673 "manifest contains information about the files present in a single changeset. "
5674 "An entry records which files are present in the changeset, the revision of "
5675 "each file, and a few other pieces of file metadata."
5676 msgstr ""
5678 #. type: Content of: <book><chapter><sect1><sect2><title>
5679 #: ../en/ch04-concepts.xml:77
5680 msgid "Recording changeset information"
5681 msgstr "记录修改集信息"
5683 #. type: Content of: <book><chapter><sect1><sect2><para>
5684 #: ../en/ch04-concepts.xml:79
5685 msgid ""
5686 "The <emphasis>changelog</emphasis> contains information about each "
5687 "changeset. Each revision records who committed a change, the changeset "
5688 "comment, other pieces of changeset-related information, and the revision of "
5689 "the manifest to use."
5690 msgstr ""
5692 #. type: Content of: <book><chapter><sect1><sect2><title>
5693 #: ../en/ch04-concepts.xml:87
5694 msgid "Relationships between revisions"
5695 msgstr "版本之间的关系"
5697 #. type: Content of: <book><chapter><sect1><sect2><para>
5698 #: ../en/ch04-concepts.xml:89
5699 msgid ""
5700 "Within a changelog, a manifest, or a filelog, each revision stores a pointer "
5701 "to its immediate parent (or to its two parents, if it's a merge revision). "
5702 "As I mentioned above, there are also relationships between revisions "
5703 "<emphasis>across</emphasis> these structures, and they are hierarchical in "
5704 "nature."
5705 msgstr ""
5707 #. type: Content of: <book><chapter><sect1><sect2><para>
5708 #: ../en/ch04-concepts.xml:96
5709 msgid ""
5710 "For every changeset in a repository, there is exactly one revision stored in "
5711 "the changelog. Each revision of the changelog contains a pointer to a single "
5712 "revision of the manifest. A revision of the manifest stores a pointer to a "
5713 "single revision of each filelog tracked when that changeset was created. "
5714 "These relationships are illustrated in <xref linkend=\"fig:concepts:metadata"
5715 "\"/>."
5716 msgstr ""
5718 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
5719 #: ../en/ch04-concepts.xml:105
5720 msgid "Metadata relationships"
5721 msgstr "元数据之间的关系"
5723 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
5724 #: ../en/ch04-concepts.xml:107
5725 msgid "<imageobject><imagedata fileref=\"figs/metadata.png\"/></imageobject>"
5726 msgstr ""
5728 #. type: Content of: <book><chapter><sect1><sect2><para>
5729 #: ../en/ch04-concepts.xml:112
5730 msgid ""
5731 "As the illustration shows, there is <emphasis>not</emphasis> a <quote>one to "
5732 "one</quote> relationship between revisions in the changelog, manifest, or "
5733 "filelog. If a file that Mercurial tracks hasn't changed between two "
5734 "changesets, the entry for that file in the two revisions of the manifest will "
5735 "point to the same revision of its filelog<placeholder type=\"footnote\" id=\"0"
5736 "\"/>."
5737 msgstr ""
5739 #. type: Content of: <book><chapter><sect1><sect2><para><footnote><para>
5740 #: ../en/ch04-concepts.xml:119
5741 msgid ""
5742 "It is possible (though unusual) for the manifest to remain the same between "
5743 "two changesets, in which case the changelog entries for those changesets will "
5744 "point to the same revision of the manifest."
5745 msgstr ""
5747 #. type: Content of: <book><chapter><sect1><title>
5748 #: ../en/ch04-concepts.xml:128
5749 msgid "Safe, efficient storage"
5750 msgstr "安全,高效的存储"
5752 #. type: Content of: <book><chapter><sect1><para>
5753 #: ../en/ch04-concepts.xml:130
5754 msgid ""
5755 "The underpinnings of changelogs, manifests, and filelogs are provided by a "
5756 "single structure called the <emphasis>revlog</emphasis>."
5757 msgstr ""
5759 #. type: Content of: <book><chapter><sect1><sect2><title>
5760 #: ../en/ch04-concepts.xml:135
5761 msgid "Efficient storage"
5762 msgstr "高效存储"
5764 #. type: Content of: <book><chapter><sect1><sect2><para>
5765 #: ../en/ch04-concepts.xml:137
5766 msgid ""
5767 "The revlog provides efficient storage of revisions using a <emphasis>delta</"
5768 "emphasis> mechanism. Instead of storing a complete copy of a file for each "
5769 "revision, it stores the changes needed to transform an older revision into "
5770 "the new revision. For many kinds of file data, these deltas are typically a "
5771 "fraction of a percent of the size of a full copy of a file."
5772 msgstr ""
5774 #. type: Content of: <book><chapter><sect1><sect2><para>
5775 #: ../en/ch04-concepts.xml:145
5776 msgid ""
5777 "Some obsolete revision control systems can only work with deltas of text "
5778 "files. They must either store binary files as complete snapshots or encoded "
5779 "into a text representation, both of which are wasteful approaches. Mercurial "
5780 "can efficiently handle deltas of files with arbitrary binary contents; it "
5781 "doesn't need to treat text as special."
5782 msgstr ""
5784 #. type: Content of: <book><chapter><sect1><sect2><title>
5785 #: ../en/ch04-concepts.xml:154
5786 msgid "Safe operation"
5787 msgstr "安全操作"
5789 #. type: Content of: <book><chapter><sect1><sect2><para>
5790 #: ../en/ch04-concepts.xml:156
5791 msgid ""
5792 "Mercurial only ever <emphasis>appends</emphasis> data to the end of a revlog "
5793 "file. It never modifies a section of a file after it has written it. This is "
5794 "both more robust and efficient than schemes that need to modify or rewrite "
5795 "data."
5796 msgstr ""
5798 #. type: Content of: <book><chapter><sect1><sect2><para>
5799 #: ../en/ch04-concepts.xml:162
5800 msgid ""
5801 "In addition, Mercurial treats every write as part of a <emphasis>transaction</"
5802 "emphasis> that can span a number of files. A transaction is "
5803 "<emphasis>atomic</emphasis>: either the entire transaction succeeds and its "
5804 "effects are all visible to readers in one go, or the whole thing is undone. "
5805 "This guarantee of atomicity means that if you're running two copies of "
5806 "Mercurial, where one is reading data and one is writing it, the reader will "
5807 "never see a partially written result that might confuse it."
5808 msgstr ""
5810 #. type: Content of: <book><chapter><sect1><sect2><para>
5811 #: ../en/ch04-concepts.xml:172
5812 msgid ""
5813 "The fact that Mercurial only appends to files makes it easier to provide this "
5814 "transactional guarantee. The easier it is to do stuff like this, the more "
5815 "confident you should be that it's done correctly."
5816 msgstr ""
5818 #. type: Content of: <book><chapter><sect1><sect2><title>
5819 #: ../en/ch04-concepts.xml:179
5820 msgid "Fast retrieval"
5821 msgstr "快速检索"
5823 #. type: Content of: <book><chapter><sect1><sect2><para>
5824 #: ../en/ch04-concepts.xml:181
5825 msgid ""
5826 "Mercurial cleverly avoids a pitfall common to all earlier revision control "
5827 "systems: the problem of <emphasis>inefficient retrieval</emphasis>. Most "
5828 "revision control systems store the contents of a revision as an incremental "
5829 "series of modifications against a <quote>snapshot</quote>. (Some base the "
5830 "snapshot on the oldest revision, others on the newest.) To reconstruct a "
5831 "specific revision, you must first read the snapshot, and then every one of "
5832 "the revisions between the snapshot and your target revision. The more "
5833 "history that a file accumulates, the more revisions you must read, hence the "
5834 "longer it takes to reconstruct a particular revision."
5835 msgstr ""
5837 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
5838 #: ../en/ch04-concepts.xml:195
5839 msgid "Snapshot of a revlog, with incremental deltas"
5840 msgstr "版本日志的快照,以及增量差异"
5842 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
5843 #: ../en/ch04-concepts.xml:197
5844 msgid "<imageobject><imagedata fileref=\"figs/snapshot.png\"/></imageobject>"
5845 msgstr ""
5847 #. type: Content of: <book><chapter><sect1><sect2><para>
5848 #: ../en/ch04-concepts.xml:202
5849 msgid ""
5850 "The innovation that Mercurial applies to this problem is simple but "
5851 "effective. Once the cumulative amount of delta information stored since the "
5852 "last snapshot exceeds a fixed threshold, it stores a new snapshot "
5853 "(compressed, of course), instead of another delta. This makes it possible to "
5854 "reconstruct <emphasis>any</emphasis> revision of a file quickly. This "
5855 "approach works so well that it has since been copied by several other "
5856 "revision control systems."
5857 msgstr ""
5859 #. type: Content of: <book><chapter><sect1><sect2><para>
5860 #: ../en/ch04-concepts.xml:211
5861 msgid ""
5862 "<xref linkend=\"fig:concepts:snapshot\"/> illustrates the idea. In an entry "
5863 "in a revlog's index file, Mercurial stores the range of entries from the data "
5864 "file that it must read to reconstruct a particular revision."
5865 msgstr ""
5867 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
5868 #: ../en/ch04-concepts.xml:217
5869 msgid "Aside: the influence of video compression"
5870 msgstr "旁白: 视频压缩的影响"
5872 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
5873 #: ../en/ch04-concepts.xml:219
5874 msgid ""
5875 "If you're familiar with video compression or have ever watched a TV feed "
5876 "through a digital cable or satellite service, you may know that most video "
5877 "compression schemes store each frame of video as a delta against its "
5878 "predecessor frame."
5879 msgstr ""
5881 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
5882 #: ../en/ch04-concepts.xml:225
5883 msgid ""
5884 "Mercurial borrows this idea to make it possible to reconstruct a revision "
5885 "from a snapshot and a small number of deltas."
5886 msgstr ""
5888 #. type: Content of: <book><chapter><sect1><sect2><title>
5889 #: ../en/ch04-concepts.xml:232
5890 msgid "Identification and strong integrity"
5891 msgstr "鉴别和强完整性"
5893 #. type: Content of: <book><chapter><sect1><sect2><para>
5894 #: ../en/ch04-concepts.xml:234
5895 msgid ""
5896 "Along with delta or snapshot information, a revlog entry contains a "
5897 "cryptographic hash of the data that it represents. This makes it difficult "
5898 "to forge the contents of a revision, and easy to detect accidental corruption."
5899 msgstr ""
5901 #. type: Content of: <book><chapter><sect1><sect2><para>
5902 #: ../en/ch04-concepts.xml:239
5903 msgid ""
5904 "Hashes provide more than a mere check against corruption; they are used as "
5905 "the identifiers for revisions. The changeset identification hashes that you "
5906 "see as an end user are from revisions of the changelog. Although filelogs "
5907 "and the manifest also use hashes, Mercurial only uses these behind the scenes."
5908 msgstr ""
5910 #. type: Content of: <book><chapter><sect1><sect2><para>
5911 #: ../en/ch04-concepts.xml:246
5912 msgid ""
5913 "Mercurial verifies that hashes are correct when it retrieves file revisions "
5914 "and when it pulls changes from another repository. If it encounters an "
5915 "integrity problem, it will complain and stop whatever it's doing."
5916 msgstr ""
5918 #. type: Content of: <book><chapter><sect1><sect2><para>
5919 #: ../en/ch04-concepts.xml:251
5920 msgid ""
5921 "In addition to the effect it has on retrieval efficiency, Mercurial's use of "
5922 "periodic snapshots makes it more robust against partial data corruption. If "
5923 "a revlog becomes partly corrupted due to a hardware error or system bug, it's "
5924 "often possible to reconstruct some or most revisions from the uncorrupted "
5925 "sections of the revlog, both before and after the corrupted section. This "
5926 "would not be possible with a delta-only storage model."
5927 msgstr ""
5929 #. type: Content of: <book><chapter><sect1><title>
5930 #: ../en/ch04-concepts.xml:263
5931 msgid "Revision history, branching, and merging"
5932 msgstr "修订历史,分支与合并"
5934 #. type: Content of: <book><chapter><sect1><para>
5935 #: ../en/ch04-concepts.xml:265
5936 msgid ""
5937 "Every entry in a Mercurial revlog knows the identity of its immediate "
5938 "ancestor revision, usually referred to as its <emphasis>parent</emphasis>. "
5939 "In fact, a revision contains room for not one parent, but two. Mercurial "
5940 "uses a special hash, called the <quote>null ID</quote>, to represent the idea "
5941 "<quote>there is no parent here</quote>. This hash is simply a string of "
5942 "zeroes."
5943 msgstr ""
5945 #. type: Content of: <book><chapter><sect1><para>
5946 #: ../en/ch04-concepts.xml:273
5947 msgid ""
5948 "In <xref linkend=\"fig:concepts:revlog\"/>, you can see an example of the "
5949 "conceptual structure of a revlog. Filelogs, manifests, and changelogs all "
5950 "have this same structure; they differ only in the kind of data stored in each "
5951 "delta or snapshot."
5952 msgstr ""
5954 #. type: Content of: <book><chapter><sect1><para>
5955 #: ../en/ch04-concepts.xml:279
5956 msgid ""
5957 "The first revision in a revlog (at the bottom of the image) has the null ID "
5958 "in both of its parent slots. For a <quote>normal</quote> revision, its first "
5959 "parent slot contains the ID of its parent revision, and its second contains "
5960 "the null ID, indicating that the revision has only one real parent. Any two "
5961 "revisions that have the same parent ID are branches. A revision that "
5962 "represents a merge between branches has two normal revision IDs in its parent "
5963 "slots."
5964 msgstr ""
5966 #. type: Content of: <book><chapter><sect1><figure><title>
5967 #: ../en/ch04-concepts.xml:289
5968 msgid "The conceptual structure of a revlog"
5969 msgstr "版本日志的设计结构"
5971 #. type: Content of: <book><chapter><sect1><figure><mediaobject>
5972 #: ../en/ch04-concepts.xml:291
5973 msgid "<imageobject><imagedata fileref=\"figs/revlog.png\"/></imageobject>"
5974 msgstr ""
5976 #. type: Content of: <book><chapter><sect1><title>
5977 #: ../en/ch04-concepts.xml:298
5978 msgid "The working directory"
5979 msgstr "工作目录"
5981 #. type: Content of: <book><chapter><sect1><para>
5982 #: ../en/ch04-concepts.xml:300
5983 msgid ""
5984 "In the working directory, Mercurial stores a snapshot of the files from the "
5985 "repository as of a particular changeset."
5986 msgstr ""
5988 #. type: Content of: <book><chapter><sect1><para>
5989 #: ../en/ch04-concepts.xml:303
5990 msgid ""
5991 "The working directory <quote>knows</quote> which changeset it contains. When "
5992 "you update the working directory to contain a particular changeset, Mercurial "
5993 "looks up the appropriate revision of the manifest to find out which files it "
5994 "was tracking at the time that changeset was committed, and which revision of "
5995 "each file was then current. It then recreates a copy of each of those files, "
5996 "with the same contents it had when the changeset was committed."
5997 msgstr ""
5999 #. type: Content of: <book><chapter><sect1><para>
6000 #: ../en/ch04-concepts.xml:312
6001 msgid ""
6002 "The <emphasis>dirstate</emphasis> is a special structure that contains "
6003 "Mercurial's knowledge of the working directory. It is maintained as a file "
6004 "named <filename>.hg/dirstate</filename> inside a repository. The dirstate "
6005 "details which changeset the working directory is updated to, and all of the "
6006 "files that Mercurial is tracking in the working directory. It also lets "
6007 "Mercurial quickly notice changed files, by recording their checkout times and "
6008 "sizes."
6009 msgstr ""
6011 #. type: Content of: <book><chapter><sect1><para>
6012 #: ../en/ch04-concepts.xml:322
6013 msgid ""
6014 "Just as a revision of a revlog has room for two parents, so that it can "
6015 "represent either a normal revision (with one parent) or a merge of two "
6016 "earlier revisions, the dirstate has slots for two parents. When you use the "
6017 "<command role=\"hg-cmd\">hg update</command> command, the changeset that you "
6018 "update to is stored in the <quote>first parent</quote> slot, and the null ID "
6019 "in the second. When you <command role=\"hg-cmd\">hg merge</command> with "
6020 "another changeset, the first parent remains unchanged, and the second parent "
6021 "is filled in with the changeset you're merging with. The <command role=\"hg-"
6022 "cmd\">hg parents</command> command tells you what the parents of the dirstate "
6023 "are."
6024 msgstr ""
6026 #. type: Content of: <book><chapter><sect1><sect2><title>
6027 #: ../en/ch04-concepts.xml:336
6028 msgid "What happens when you commit"
6029 msgstr "当你提交时发生的事情"
6031 #. type: Content of: <book><chapter><sect1><sect2><para>
6032 #: ../en/ch04-concepts.xml:338
6033 msgid ""
6034 "The dirstate stores parent information for more than just book-keeping "
6035 "purposes. Mercurial uses the parents of the dirstate as <emphasis>the "
6036 "parents of a new changeset</emphasis> when you perform a commit."
6037 msgstr ""
6039 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
6040 #: ../en/ch04-concepts.xml:344
6041 msgid "The working directory can have two parents"
6042 msgstr "工作目录可以有两个父亲"
6044 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
6045 #: ../en/ch04-concepts.xml:346
6046 msgid "<imageobject><imagedata fileref=\"figs/wdir.png\"/></imageobject>"
6047 msgstr ""
6049 #. type: Content of: <book><chapter><sect1><sect2><para>
6050 #: ../en/ch04-concepts.xml:351
6051 msgid ""
6052 "<xref linkend=\"fig:concepts:wdir\"/> shows the normal state of the working "
6053 "directory, where it has a single changeset as parent. That changeset is the "
6054 "<emphasis>tip</emphasis>, the newest changeset in the repository that has no "
6055 "children."
6056 msgstr ""
6058 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
6059 #: ../en/ch04-concepts.xml:358
6060 msgid "The working directory gains new parents after a commit"
6061 msgstr "提交之后,工作目录的父亲就改变了"
6063 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
6064 #: ../en/ch04-concepts.xml:361
6065 msgid ""
6066 "<imageobject><imagedata fileref=\"figs/wdir-after-commit.png\"/></imageobject>"
6067 msgstr ""
6069 #. type: Content of: <book><chapter><sect1><sect2><para>
6070 #: ../en/ch04-concepts.xml:366
6071 msgid ""
6072 "It's useful to think of the working directory as <quote>the changeset I'm "
6073 "about to commit</quote>. Any files that you tell Mercurial that you've "
6074 "added, removed, renamed, or copied will be reflected in that changeset, as "
6075 "will modifications to any files that Mercurial is already tracking; the new "
6076 "changeset will have the parents of the working directory as its parents."
6077 msgstr ""
6079 #. type: Content of: <book><chapter><sect1><sect2><para>
6080 #: ../en/ch04-concepts.xml:374
6081 msgid ""
6082 "After a commit, Mercurial will update the parents of the working directory, "
6083 "so that the first parent is the ID of the new changeset, and the second is "
6084 "the null ID. This is shown in <xref linkend=\"fig:concepts:wdir-after-commit"
6085 "\"/>. Mercurial doesn't touch any of the files in the working directory when "
6086 "you commit; it just modifies the dirstate to note its new parents."
6087 msgstr ""
6089 #. type: Content of: <book><chapter><sect1><sect2><title>
6090 #: ../en/ch04-concepts.xml:385
6091 msgid "Creating a new head"
6092 msgstr "创建新顶点"
6094 #. type: Content of: <book><chapter><sect1><sect2><para>
6095 #: ../en/ch04-concepts.xml:387
6096 msgid ""
6097 "It's perfectly normal to update the working directory to a changeset other "
6098 "than the current tip. For example, you might want to know what your project "
6099 "looked like last Tuesday, or you could be looking through changesets to see "
6100 "which one introduced a bug. In cases like this, the natural thing to do is "
6101 "update the working directory to the changeset you're interested in, and then "
6102 "examine the files in the working directory directly to see their contents as "
6103 "they were when you committed that changeset. The effect of this is shown in "
6104 "<xref linkend=\"fig:concepts:wdir-pre-branch\"/>."
6105 msgstr ""
6107 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
6108 #: ../en/ch04-concepts.xml:399
6109 msgid "The working directory, updated to an older changeset"
6110 msgstr "同步到旧修改集的工作目录"
6112 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
6113 #: ../en/ch04-concepts.xml:402
6114 msgid ""
6115 "<imageobject><imagedata fileref=\"figs/wdir-pre-branch.png\"/></imageobject>"
6116 msgstr ""
6118 #. type: Content of: <book><chapter><sect1><sect2><para>
6119 #: ../en/ch04-concepts.xml:407
6120 msgid ""
6121 "Having updated the working directory to an older changeset, what happens if "
6122 "you make some changes, and then commit? Mercurial behaves in the same way as "
6123 "I outlined above. The parents of the working directory become the parents of "
6124 "the new changeset. This new changeset has no children, so it becomes the new "
6125 "tip. And the repository now contains two changesets that have no children; "
6126 "we call these <emphasis>heads</emphasis>. You can see the structure that "
6127 "this creates in <xref linkend=\"fig:concepts:wdir-branch\"/>."
6128 msgstr ""
6130 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
6131 #: ../en/ch04-concepts.xml:419
6132 msgid "After a commit made while synced to an older changeset"
6133 msgstr "对同步到旧修改集的工作目录提交之后"
6135 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
6136 #: ../en/ch04-concepts.xml:422
6137 msgid "<imageobject><imagedata fileref=\"figs/wdir-branch.png\"/></imageobject>"
6138 msgstr ""
6140 #. type: Content of: <book><chapter><sect1><sect2><note><para>
6141 #: ../en/ch04-concepts.xml:428
6142 msgid ""
6143 "If you're new to Mercurial, you should keep in mind a common <quote>error</"
6144 "quote>, which is to use the <command role=\"hg-cmd\">hg pull</command> "
6145 "command without any options. By default, the <command role=\"hg-cmd\">hg "
6146 "pull</command> command <emphasis>does not</emphasis> update the working "
6147 "directory, so you'll bring new changesets into your repository, but the "
6148 "working directory will stay synced at the same changeset as before the pull. "
6149 "If you make some changes and commit afterwards, you'll thus create a new "
6150 "head, because your working directory isn't synced to whatever the current tip "
6151 "is. To combine the operation of a pull, followed by an update, run "
6152 "<command>hg pull -u</command>."
6153 msgstr ""
6155 #. type: Content of: <book><chapter><sect1><sect2><note><para>
6156 #: ../en/ch04-concepts.xml:442
6157 msgid ""
6158 "I put the word <quote>error</quote> in quotes because all that you need to do "
6159 "to rectify the situation where you created a new head by accident is <command "
6160 "role=\"hg-cmd\">hg merge</command>, then <command role=\"hg-cmd\">hg commit</"
6161 "command>. In other words, this almost never has negative consequences; it's "
6162 "just something of a surprise for newcomers. I'll discuss other ways to avoid "
6163 "this behavior, and why Mercurial behaves in this initially surprising way, "
6164 "later on."
6165 msgstr ""
6167 #. type: Content of: <book><chapter><sect1><sect2><title>
6168 #: ../en/ch04-concepts.xml:455
6169 msgid "Merging changes"
6170 msgstr "合并修改"
6172 #. type: Content of: <book><chapter><sect1><sect2><para>
6173 #: ../en/ch04-concepts.xml:457
6174 msgid ""
6175 "When you run the <command role=\"hg-cmd\">hg merge</command> command, "
6176 "Mercurial leaves the first parent of the working directory unchanged, and "
6177 "sets the second parent to the changeset you're merging with, as shown in "
6178 "<xref linkend=\"fig:concepts:wdir-merge\"/>."
6179 msgstr ""
6181 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
6182 #: ../en/ch04-concepts.xml:464
6183 msgid "Merging two heads"
6184 msgstr "合并两个顶点"
6186 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
6187 #: ../en/ch04-concepts.xml:466
6188 msgid ""
6189 "<imageobject> <imagedata fileref=\"figs/wdir-merge.png\"/> </imageobject>"
6190 msgstr ""
6192 #. type: Content of: <book><chapter><sect1><sect2><para>
6193 #: ../en/ch04-concepts.xml:473
6194 msgid ""
6195 "Mercurial also has to modify the working directory, to merge the files "
6196 "managed in the two changesets. Simplified a little, the merging process goes "
6197 "like this, for every file in the manifests of both changesets."
6198 msgstr ""
6200 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6201 #: ../en/ch04-concepts.xml:478
6202 msgid "If neither changeset has modified a file, do nothing with that file."
6203 msgstr ""
6205 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6206 #: ../en/ch04-concepts.xml:481
6207 msgid ""
6208 "If one changeset has modified a file, and the other hasn't, create the "
6209 "modified copy of the file in the working directory."
6210 msgstr ""
6212 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6213 #: ../en/ch04-concepts.xml:485
6214 msgid ""
6215 "If one changeset has removed a file, and the other hasn't (or has also "
6216 "deleted it), delete the file from the working directory."
6217 msgstr ""
6219 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6220 #: ../en/ch04-concepts.xml:489
6221 msgid ""
6222 "If one changeset has removed a file, but the other has modified the file, ask "
6223 "the user what to do: keep the modified file, or remove it?"
6224 msgstr ""
6226 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6227 #: ../en/ch04-concepts.xml:493
6228 msgid ""
6229 "If both changesets have modified a file, invoke an external merge program to "
6230 "choose the new contents for the merged file. This may require input from the "
6231 "user."
6232 msgstr ""
6234 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6235 #: ../en/ch04-concepts.xml:498
6236 msgid ""
6237 "If one changeset has modified a file, and the other has renamed or copied the "
6238 "file, make sure that the changes follow the new name of the file."
6239 msgstr ""
6241 #. type: Content of: <book><chapter><sect1><sect2><para>
6242 #: ../en/ch04-concepts.xml:502
6243 msgid ""
6244 "There are more details&emdash;merging has plenty of corner cases&emdash;but "
6245 "these are the most common choices that are involved in a merge. As you can "
6246 "see, most cases are completely automatic, and indeed most merges finish "
6247 "automatically, without requiring your input to resolve any conflicts."
6248 msgstr ""
6250 #. type: Content of: <book><chapter><sect1><sect2><para>
6251 #: ../en/ch04-concepts.xml:509
6252 msgid ""
6253 "When you're thinking about what happens when you commit after a merge, once "
6254 "again the working directory is <quote>the changeset I'm about to commit</"
6255 "quote>. After the <command role=\"hg-cmd\">hg merge</command> command "
6256 "completes, the working directory has two parents; these will become the "
6257 "parents of the new changeset."
6258 msgstr ""
6260 #. type: Content of: <book><chapter><sect1><sect2><para>
6261 #: ../en/ch04-concepts.xml:516
6262 msgid ""
6263 "Mercurial lets you perform multiple merges, but you must commit the results "
6264 "of each individual merge as you go. This is necessary because Mercurial only "
6265 "tracks two parents for both revisions and the working directory. While it "
6266 "would be technically feasible to merge multiple changesets at once, Mercurial "
6267 "avoids this for simplicity. With multi-way merges, the risks of user "
6268 "confusion, nasty conflict resolution, and making a terrible mess of a merge "
6269 "would grow intolerable."
6270 msgstr ""
6272 #. type: Content of: <book><chapter><sect1><sect2><title>
6273 #: ../en/ch04-concepts.xml:529
6274 msgid "Merging and renames"
6275 msgstr "合并与改名"
6277 #. type: Content of: <book><chapter><sect1><sect2><para>
6278 #: ../en/ch04-concepts.xml:531
6279 msgid ""
6280 "A surprising number of revision control systems pay little or no attention to "
6281 "a file's <emphasis>name</emphasis> over time. For instance, it used to be "
6282 "common that if a file got renamed on one side of a merge, the changes from "
6283 "the other side would be silently dropped."
6284 msgstr ""
6286 #. type: Content of: <book><chapter><sect1><sect2><para>
6287 #: ../en/ch04-concepts.xml:537
6288 msgid ""
6289 "Mercurial records metadata when you tell it to perform a rename or copy. It "
6290 "uses this metadata during a merge to do the right thing in the case of a "
6291 "merge. For instance, if I rename a file, and you edit it without renaming "
6292 "it, when we merge our work the file will be renamed and have your edits "
6293 "applied."
6294 msgstr ""
6296 #. type: Content of: <book><chapter><sect1><title>
6297 #: ../en/ch04-concepts.xml:547
6298 msgid "Other interesting design features"
6299 msgstr "其它有趣的设计特性"
6301 #. type: Content of: <book><chapter><sect1><para>
6302 #: ../en/ch04-concepts.xml:549
6303 msgid ""
6304 "In the sections above, I've tried to highlight some of the most important "
6305 "aspects of Mercurial's design, to illustrate that it pays careful attention "
6306 "to reliability and performance. However, the attention to detail doesn't "
6307 "stop there. There are a number of other aspects of Mercurial's construction "
6308 "that I personally find interesting. I'll detail a few of them here, separate "
6309 "from the <quote>big ticket</quote> items above, so that if you're interested, "
6310 "you can gain a better idea of the amount of thinking that goes into a well-"
6311 "designed system."
6312 msgstr ""
6314 #. type: Content of: <book><chapter><sect1><sect2><title>
6315 #: ../en/ch04-concepts.xml:560
6316 msgid "Clever compression"
6317 msgstr "智能压缩"
6319 #. type: Content of: <book><chapter><sect1><sect2><para>
6320 #: ../en/ch04-concepts.xml:562
6321 msgid ""
6322 "When appropriate, Mercurial will store both snapshots and deltas in "
6323 "compressed form. It does this by always <emphasis>trying to</emphasis> "
6324 "compress a snapshot or delta, but only storing the compressed version if it's "
6325 "smaller than the uncompressed version."
6326 msgstr ""
6328 #. type: Content of: <book><chapter><sect1><sect2><para>
6329 #: ../en/ch04-concepts.xml:568
6330 msgid ""
6331 "This means that Mercurial does <quote>the right thing</quote> when storing a "
6332 "file whose native form is compressed, such as a <literal>zip</literal> "
6333 "archive or a JPEG image. When these types of files are compressed a second "
6334 "time, the resulting file is usually bigger than the once-compressed form, and "
6335 "so Mercurial will store the plain <literal>zip</literal> or JPEG."
6336 msgstr ""
6338 #. type: Content of: <book><chapter><sect1><sect2><para>
6339 #: ../en/ch04-concepts.xml:576
6340 msgid ""
6341 "Deltas between revisions of a compressed file are usually larger than "
6342 "snapshots of the file, and Mercurial again does <quote>the right thing</"
6343 "quote> in these cases. It finds that such a delta exceeds the threshold at "
6344 "which it should store a complete snapshot of the file, so it stores the "
6345 "snapshot, again saving space compared to a naive delta-only approach."
6346 msgstr ""
6348 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
6349 #: ../en/ch04-concepts.xml:585
6350 msgid "Network recompression"
6351 msgstr "网络重新压缩"
6353 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
6354 #: ../en/ch04-concepts.xml:587
6355 msgid ""
6356 "When storing revisions on disk, Mercurial uses the <quote>deflate</quote> "
6357 "compression algorithm (the same one used by the popular <literal>zip</"
6358 "literal> archive format), which balances good speed with a respectable "
6359 "compression ratio. However, when transmitting revision data over a network "
6360 "connection, Mercurial uncompresses the compressed revision data."
6361 msgstr ""
6363 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
6364 #: ../en/ch04-concepts.xml:595
6365 msgid ""
6366 "If the connection is over HTTP, Mercurial recompresses the entire stream of "
6367 "data using a compression algorithm that gives a better compression ratio (the "
6368 "Burrows-Wheeler algorithm from the widely used <literal>bzip2</literal> "
6369 "compression package). This combination of algorithm and compression of the "
6370 "entire stream (instead of a revision at a time) substantially reduces the "
6371 "number of bytes to be transferred, yielding better network performance over "
6372 "most kinds of network."
6373 msgstr ""
6375 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
6376 #: ../en/ch04-concepts.xml:605
6377 msgid ""
6378 "If the connection is over <command>ssh</command>, Mercurial "
6379 "<emphasis>doesn't</emphasis> recompress the stream, because <command>ssh</"
6380 "command> can already do this itself. You can tell Mercurial to always use "
6381 "<command>ssh</command>'s compression feature by editing the <filename>.hgrc</"
6382 "filename> file in your home directory as follows."
6383 msgstr ""
6385 #. type: Content of: <book><chapter><sect1><sect2><title>
6386 #: ../en/ch04-concepts.xml:620
6387 msgid "Read/write ordering and atomicity"
6388 msgstr "读写顺序与原子性"
6390 #. type: Content of: <book><chapter><sect1><sect2><para>
6391 #: ../en/ch04-concepts.xml:622
6392 msgid ""
6393 "Appending to files isn't the whole story when it comes to guaranteeing that a "
6394 "reader won't see a partial write. If you recall <xref linkend=\"fig:concepts:"
6395 "metadata\"/>, revisions in the changelog point to revisions in the manifest, "
6396 "and revisions in the manifest point to revisions in filelogs. This hierarchy "
6397 "is deliberate."
6398 msgstr ""
6400 #. type: Content of: <book><chapter><sect1><sect2><para>
6401 #: ../en/ch04-concepts.xml:629
6402 msgid ""
6403 "A writer starts a transaction by writing filelog and manifest data, and "
6404 "doesn't write any changelog data until those are finished. A reader starts "
6405 "by reading changelog data, then manifest data, followed by filelog data."
6406 msgstr ""
6408 #. type: Content of: <book><chapter><sect1><sect2><para>
6409 #: ../en/ch04-concepts.xml:634
6410 msgid ""
6411 "Since the writer has always finished writing filelog and manifest data before "
6412 "it writes to the changelog, a reader will never read a pointer to a partially "
6413 "written manifest revision from the changelog, and it will never read a "
6414 "pointer to a partially written filelog revision from the manifest."
6415 msgstr ""
6417 #. type: Content of: <book><chapter><sect1><sect2><title>
6418 #: ../en/ch04-concepts.xml:642
6419 msgid "Concurrent access"
6420 msgstr "并发访问"
6422 #. type: Content of: <book><chapter><sect1><sect2><para>
6423 #: ../en/ch04-concepts.xml:644
6424 msgid ""
6425 "The read/write ordering and atomicity guarantees mean that Mercurial never "
6426 "needs to <emphasis>lock</emphasis> a repository when it's reading data, even "
6427 "if the repository is being written to while the read is occurring. This has a "
6428 "big effect on scalability; you can have an arbitrary number of Mercurial "
6429 "processes safely reading data from a repository all at once, no matter "
6430 "whether it's being written to or not."
6431 msgstr ""
6433 #. type: Content of: <book><chapter><sect1><sect2><para>
6434 #: ../en/ch04-concepts.xml:653
6435 msgid ""
6436 "The lockless nature of reading means that if you're sharing a repository on a "
6437 "multi-user system, you don't need to grant other local users permission to "
6438 "<emphasis>write</emphasis> to your repository in order for them to be able to "
6439 "clone it or pull changes from it; they only need <emphasis>read</emphasis> "
6440 "permission. (This is <emphasis>not</emphasis> a common feature among "
6441 "revision control systems, so don't take it for granted! Most require readers "
6442 "to be able to lock a repository to access it safely, and this requires write "
6443 "permission on at least one directory, which of course makes for all kinds of "
6444 "nasty and annoying security and administrative problems.)"
6445 msgstr ""
6447 #. type: Content of: <book><chapter><sect1><sect2><para>
6448 #: ../en/ch04-concepts.xml:666
6449 msgid ""
6450 "Mercurial uses locks to ensure that only one process can write to a "
6451 "repository at a time (the locking mechanism is safe even over filesystems "
6452 "that are notoriously hostile to locking, such as NFS). If a repository is "
6453 "locked, a writer will wait for a while to retry if the repository becomes "
6454 "unlocked, but if the repository remains locked for too long, the process "
6455 "attempting to write will time out after a while. This means that your daily "
6456 "automated scripts won't get stuck forever and pile up if a system crashes "
6457 "unnoticed, for example. (Yes, the timeout is configurable, from zero to "
6458 "infinity.)"
6459 msgstr ""
6461 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
6462 #: ../en/ch04-concepts.xml:678
6463 msgid "Safe dirstate access"
6464 msgstr "安全的目录状态访问"
6466 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
6467 #: ../en/ch04-concepts.xml:680
6468 msgid ""
6469 "As with revision data, Mercurial doesn't take a lock to read the dirstate "
6470 "file; it does acquire a lock to write it. To avoid the possibility of "
6471 "reading a partially written copy of the dirstate file, Mercurial writes to a "
6472 "file with a unique name in the same directory as the dirstate file, then "
6473 "renames the temporary file atomically to <filename>dirstate</filename>. The "
6474 "file named <filename>dirstate</filename> is thus guaranteed to be complete, "
6475 "not partially written."
6476 msgstr ""
6478 #. type: Content of: <book><chapter><sect1><sect2><title>
6479 #: ../en/ch04-concepts.xml:693
6480 msgid "Avoiding seeks"
6481 msgstr "避免查找"
6483 #. type: Content of: <book><chapter><sect1><sect2><para>
6484 #: ../en/ch04-concepts.xml:695
6485 msgid ""
6486 "Critical to Mercurial's performance is the avoidance of seeks of the disk "
6487 "head, since any seek is far more expensive than even a comparatively large "
6488 "read operation."
6489 msgstr ""
6491 #. type: Content of: <book><chapter><sect1><sect2><para>
6492 #: ../en/ch04-concepts.xml:699
6493 msgid ""
6494 "This is why, for example, the dirstate is stored in a single file. If there "
6495 "were a dirstate file per directory that Mercurial tracked, the disk would "
6496 "seek once per directory. Instead, Mercurial reads the entire single dirstate "
6497 "file in one step."
6498 msgstr ""
6500 #. type: Content of: <book><chapter><sect1><sect2><para>
6501 #: ../en/ch04-concepts.xml:705
6502 msgid ""
6503 "Mercurial also uses a <quote>copy on write</quote> scheme when cloning a "
6504 "repository on local storage. Instead of copying every revlog file from the "
6505 "old repository into the new repository, it makes a <quote>hard link</quote>, "
6506 "which is a shorthand way to say <quote>these two names point to the same "
6507 "file</quote>. When Mercurial is about to write to one of a revlog's files, "
6508 "it checks to see if the number of names pointing at the file is greater than "
6509 "one. If it is, more than one repository is using the file, so Mercurial "
6510 "makes a new copy of the file that is private to this repository."
6511 msgstr ""
6513 #. type: Content of: <book><chapter><sect1><sect2><para>
6514 #: ../en/ch04-concepts.xml:716
6515 msgid ""
6516 "A few revision control developers have pointed out that this idea of making a "
6517 "complete private copy of a file is not very efficient in its use of storage. "
6518 "While this is true, storage is cheap, and this method gives the highest "
6519 "performance while deferring most book-keeping to the operating system. An "
6520 "alternative scheme would most likely reduce performance and increase the "
6521 "complexity of the software, but speed and simplicity are key to the "
6522 "<quote>feel</quote> of day-to-day use."
6523 msgstr ""
6525 #. type: Content of: <book><chapter><sect1><sect2><title>
6526 #: ../en/ch04-concepts.xml:728
6527 msgid "Other contents of the dirstate"
6528 msgstr "目录状态的其它内容"
6530 #. type: Content of: <book><chapter><sect1><sect2><para>
6531 #: ../en/ch04-concepts.xml:730
6532 msgid ""
6533 "Because Mercurial doesn't force you to tell it when you're modifying a file, "
6534 "it uses the dirstate to store some extra information so it can determine "
6535 "efficiently whether you have modified a file. For each file in the working "
6536 "directory, it stores the time that it last modified the file itself, and the "
6537 "size of the file at that time."
6538 msgstr ""
6540 #. type: Content of: <book><chapter><sect1><sect2><para>
6541 #: ../en/ch04-concepts.xml:737
6542 msgid ""
6543 "When you explicitly <command role=\"hg-cmd\">hg add</command>, <command role="
6544 "\"hg-cmd\">hg remove</command>, <command role=\"hg-cmd\">hg rename</command> "
6545 "or <command role=\"hg-cmd\">hg copy</command> files, Mercurial updates the "
6546 "dirstate so that it knows what to do with those files when you commit."
6547 msgstr ""
6549 #. type: Content of: <book><chapter><sect1><sect2><para>
6550 #: ../en/ch04-concepts.xml:744
6551 msgid ""
6552 "The dirstate helps Mercurial to efficiently check the status of files in a "
6553 "repository."
6554 msgstr ""
6556 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6557 #: ../en/ch04-concepts.xml:749
6558 msgid ""
6559 "When Mercurial checks the state of a file in the working directory, it first "
6560 "checks a file's modification time against the time in the dirstate that "
6561 "records when Mercurial last wrote the file. If the last modified time is the "
6562 "same as the time when Mercurial wrote the file, the file must not have been "
6563 "modified, so Mercurial does not need to check any further."
6564 msgstr ""
6566 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6567 #: ../en/ch04-concepts.xml:758
6568 msgid ""
6569 "If the file's size has changed, the file must have been modified. If the "
6570 "modification time has changed, but the size has not, only then does Mercurial "
6571 "need to actually read the contents of the file to see if it has changed."
6572 msgstr ""
6574 #. type: Content of: <book><chapter><sect1><sect2><para>
6575 #: ../en/ch04-concepts.xml:766
6576 msgid ""
6577 "Storing the modification time and size dramatically reduces the number of "
6578 "read operations that Mercurial needs to perform when we run commands like "
6579 "<command>hg status</command>. This results in large performance improvements."
6580 msgstr ""
6582 #. type: Content of: <book><chapter><title>
6583 #: ../en/ch05-daily.xml:5
6584 msgid "Mercurial in daily use"
6585 msgstr "Mercurial 的日常使用"
6587 #. type: Content of: <book><chapter><sect1><title>
6588 #: ../en/ch05-daily.xml:8
6589 msgid "Telling Mercurial which files to track"
6590 msgstr "告诉 Mercurial 要跟踪哪些文件"
6592 #. type: Content of: <book><chapter><sect1><para>
6593 #: ../en/ch05-daily.xml:10
6594 msgid ""
6595 "Mercurial does not work with files in your repository unless you tell it to "
6596 "manage them. The <command role=\"hg-cmd\">hg status</command> command will "
6597 "tell you which files Mercurial doesn't know about; it uses a <quote><literal>?"
6598 "</literal></quote> to display such files."
6599 msgstr ""
6602 #. type: Content of: <book><chapter><sect1><para>
6603 #: ../en/ch05-daily.xml:17
6604 msgid ""
6605 "To tell Mercurial to track a file, use the <command role=\"hg-cmd\">hg add</"
6606 "command> command. Once you have added a file, the entry in the output of "
6607 "<command role=\"hg-cmd\">hg status</command> for that file changes from "
6608 "<quote><literal>?</literal></quote> to <quote><literal>A</literal></quote>."
6609 msgstr ""
6611 #. type: Content of: <book><chapter><sect1><para>
6612 #: ../en/ch05-daily.xml:26
6613 msgid ""
6614 "After you run a <command role=\"hg-cmd\">hg commit</command>, the files that "
6615 "you added before the commit will no longer be listed in the output of "
6616 "<command role=\"hg-cmd\">hg status</command>. The reason for this is that by "
6617 "default, <command role=\"hg-cmd\">hg status</command> only tells you about "
6618 "<quote>interesting</quote> files&emdash;those that you have (for example) "
6619 "modified, removed, or renamed. If you have a repository that contains "
6620 "thousands of files, you will rarely want to know about files that Mercurial "
6621 "is tracking, but that have not changed. (You can still get this information; "
6622 "we'll return to this later.)"
6623 msgstr ""
6625 #. type: Content of: <book><chapter><sect1><para>
6626 #: ../en/ch05-daily.xml:38
6627 msgid ""
6628 "Once you add a file, Mercurial doesn't do anything with it immediately. "
6629 "Instead, it will take a snapshot of the file's state the next time you "
6630 "perform a commit. It will then continue to track the changes you make to the "
6631 "file every time you commit, until you remove the file."
6632 msgstr ""
6634 #. type: Content of: <book><chapter><sect1><sect2><title>
6635 #: ../en/ch05-daily.xml:45
6636 msgid "Explicit versus implicit file naming"
6637 msgstr "明确与隐含文件命名"
6639 #. type: Content of: <book><chapter><sect1><sect2><para>
6640 #: ../en/ch05-daily.xml:47
6641 msgid ""
6642 "A useful behavior that Mercurial has is that if you pass the name of a "
6643 "directory to a command, every Mercurial command will treat this as <quote>I "
6644 "want to operate on every file in this directory and its subdirectories</"
6645 "quote>."
6646 msgstr ""
6648 #. type: Content of: <book><chapter><sect1><sect2><para>
6649 #: ../en/ch05-daily.xml:54
6650 msgid ""
6651 "Notice in this example that Mercurial printed the names of the files it "
6652 "added, whereas it didn't do so when we added the file named <filename>myfile."
6653 "txt</filename> in the earlier example."
6654 msgstr ""
6656 #. type: Content of: <book><chapter><sect1><sect2><para>
6657 #: ../en/ch05-daily.xml:59
6658 msgid ""
6659 "What's going on is that in the former case, we explicitly named the file to "
6660 "add on the command line. The assumption that Mercurial makes in such cases "
6661 "is that we know what we are doing, and it doesn't print any output."
6662 msgstr ""
6664 #. type: Content of: <book><chapter><sect1><sect2><para>
6665 #: ../en/ch05-daily.xml:64
6666 msgid ""
6667 "However, when we <emphasis>imply</emphasis> the names of files by giving the "
6668 "name of a directory, Mercurial takes the extra step of printing the name of "
6669 "each file that it does something with. This makes it more clear what is "
6670 "happening, and reduces the likelihood of a silent and nasty surprise. This "
6671 "behavior is common to most Mercurial commands."
6672 msgstr ""
6674 #. type: Content of: <book><chapter><sect1><sect2><title>
6675 #: ../en/ch05-daily.xml:73
6676 msgid "Mercurial tracks files, not directories"
6677 msgstr "Mercurial 只跟踪文件,不跟踪目录"
6679 #. type: Content of: <book><chapter><sect1><sect2><para>
6680 #: ../en/ch05-daily.xml:75
6681 msgid ""
6682 "Mercurial does not track directory information. Instead, it tracks the path "
6683 "to a file. Before creating a file, it first creates any missing directory "
6684 "components of the path. After it deletes a file, it then deletes any empty "
6685 "directories that were in the deleted file's path. This sounds like a trivial "
6686 "distinction, but it has one minor practical consequence: it is not possible "
6687 "to represent a completely empty directory in Mercurial."
6688 msgstr ""
6690 #. type: Content of: <book><chapter><sect1><sect2><para>
6691 #: ../en/ch05-daily.xml:84
6692 msgid ""
6693 "Empty directories are rarely useful, and there are unintrusive workarounds "
6694 "that you can use to achieve an appropriate effect. The developers of "
6695 "Mercurial thus felt that the complexity that would be required to manage "
6696 "empty directories was not worth the limited benefit this feature would bring."
6697 msgstr ""
6699 #. type: Content of: <book><chapter><sect1><sect2><para>
6700 #: ../en/ch05-daily.xml:91
6701 msgid ""
6702 "If you need an empty directory in your repository, there are a few ways to "
6703 "achieve this. One is to create a directory, then <command role=\"hg-cmd\">hg "
6704 "add</command> a <quote>hidden</quote> file to that directory. On Unix-like "
6705 "systems, any file name that begins with a period (<quote><literal>.</"
6706 "literal></quote>) is treated as hidden by most commands and GUI tools. This "
6707 "approach is illustrated below."
6708 msgstr ""
6710 #. type: Content of: <book><chapter><sect1><sect2><para>
6711 #: ../en/ch05-daily.xml:102
6712 msgid ""
6713 "Another way to tackle a need for an empty directory is to simply create one "
6714 "in your automated build scripts before they will need it."
6715 msgstr ""
6717 #. type: Content of: <book><chapter><sect1><title>
6718 #: ../en/ch05-daily.xml:109
6719 msgid "How to stop tracking a file"
6720 msgstr "如何停止跟踪文件"
6722 #. type: Content of: <book><chapter><sect1><para>
6723 #: ../en/ch05-daily.xml:111
6724 msgid ""
6725 "Once you decide that a file no longer belongs in your repository, use the "
6726 "<command role=\"hg-cmd\">hg remove</command> command. This deletes the file, "
6727 "and tells Mercurial to stop tracking it (which will occur at the next "
6728 "commit). A removed file is represented in the output of <command role=\"hg-"
6729 "cmd\">hg status</command> with a <quote><literal>R</literal></quote>."
6730 msgstr ""
6732 #. type: Content of: <book><chapter><sect1><para>
6733 #: ../en/ch05-daily.xml:121
6734 msgid ""
6735 "After you <command role=\"hg-cmd\">hg remove</command> a file, Mercurial will "
6736 "no longer track changes to that file, even if you recreate a file with the "
6737 "same name in your working directory. If you do recreate a file with the same "
6738 "name and want Mercurial to track the new file, simply <command role=\"hg-cmd"
6739 "\">hg add</command> it. Mercurial will know that the newly added file is not "
6740 "related to the old file of the same name."
6741 msgstr ""
6743 #. type: Content of: <book><chapter><sect1><sect2><title>
6744 #: ../en/ch05-daily.xml:130
6745 msgid "Removing a file does not affect its history"
6746 msgstr "删除文件不影响历史"
6748 #. type: Content of: <book><chapter><sect1><sect2><para>
6749 #: ../en/ch05-daily.xml:132
6750 msgid "It is important to understand that removing a file has only two effects."
6751 msgstr ""
6753 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6754 #: ../en/ch05-daily.xml:135
6755 msgid "It removes the current version of the file from the working directory."
6756 msgstr ""
6758 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6759 #: ../en/ch05-daily.xml:138
6760 msgid ""
6761 "It stops Mercurial from tracking changes to the file, from the time of the "
6762 "next commit."
6763 msgstr ""
6765 #. type: Content of: <book><chapter><sect1><sect2><para>
6766 #: ../en/ch05-daily.xml:141
6767 msgid ""
6768 "Removing a file <emphasis>does not</emphasis> in any way alter the "
6769 "<emphasis>history</emphasis> of the file."
6770 msgstr ""
6772 #. type: Content of: <book><chapter><sect1><sect2><para>
6773 #: ../en/ch05-daily.xml:144
6774 msgid ""
6775 "If you update the working directory to a changeset that was committed when it "
6776 "was still tracking a file that you later removed, the file will reappear in "
6777 "the working directory, with the contents it had when you committed that "
6778 "changeset. If you then update the working directory to a later changeset, in "
6779 "which the file had been removed, Mercurial will once again remove the file "
6780 "from the working directory."
6781 msgstr ""
6783 #. type: Content of: <book><chapter><sect1><sect2><title>
6784 #: ../en/ch05-daily.xml:155
6785 msgid "Missing files"
6786 msgstr "丢失的文件"
6788 #. type: Content of: <book><chapter><sect1><sect2><para>
6789 #: ../en/ch05-daily.xml:157
6790 msgid ""
6791 "Mercurial considers a file that you have deleted, but not used <command role="
6792 "\"hg-cmd\">hg remove</command> to delete, to be <emphasis>missing</"
6793 "emphasis>. A missing file is represented with <quote><literal>!</literal></"
6794 "quote> in the output of <command role=\"hg-cmd\">hg status</command>. "
6795 "Mercurial commands will not generally do anything with missing files."
6796 msgstr ""
6798 #. type: Content of: <book><chapter><sect1><sect2><para>
6799 #: ../en/ch05-daily.xml:167
6800 msgid ""
6801 "If your repository contains a file that <command role=\"hg-cmd\">hg status</"
6802 "command> reports as missing, and you want the file to stay gone, you can run "
6803 "<command role=\"hg-cmd\">hg remove <option role=\"hg-opt-remove\">--after</"
6804 "option></command> at any time later on, to tell Mercurial that you really did "
6805 "mean to remove the file."
6806 msgstr ""
6808 #. type: Content of: <book><chapter><sect1><sect2><para>
6809 #: ../en/ch05-daily.xml:177
6810 msgid ""
6811 "On the other hand, if you deleted the missing file by accident, give <command "
6812 "role=\"hg-cmd\">hg revert</command> the name of the file to recover. It will "
6813 "reappear, in unmodified form."
6814 msgstr ""
6816 #. type: Content of: <book><chapter><sect1><sect2><title>
6817 #: ../en/ch05-daily.xml:186
6818 msgid "Aside: why tell Mercurial explicitly to remove a file?"
6819 msgstr "旁白: 为什么要明确告诉 Mercurial 删除文件?"
6821 #. type: Content of: <book><chapter><sect1><sect2><para>
6822 #: ../en/ch05-daily.xml:189
6823 msgid ""
6824 "You might wonder why Mercurial requires you to explicitly tell it that you "
6825 "are deleting a file. Early during the development of Mercurial, it let you "
6826 "delete a file however you pleased; Mercurial would notice the absence of the "
6827 "file automatically when you next ran a <command role=\"hg-cmd\">hg commit</"
6828 "command>, and stop tracking the file. In practice, this made it too easy to "
6829 "accidentally remove a file without noticing."
6830 msgstr ""
6832 #. type: Content of: <book><chapter><sect1><sect2><title>
6833 #: ../en/ch05-daily.xml:200
6834 msgid "Useful shorthand&emdash;adding and removing files in one step"
6835 msgstr "有用的速记—一个步骤添加和删除文件"
6837 #. type: Content of: <book><chapter><sect1><sect2><para>
6838 #: ../en/ch05-daily.xml:203
6839 msgid ""
6840 "Mercurial offers a combination command, <command role=\"hg-cmd\">hg "
6841 "addremove</command>, that adds untracked files and marks missing files as "
6842 "removed."
6843 msgstr ""
6845 #. type: Content of: <book><chapter><sect1><sect2><para>
6846 #: ../en/ch05-daily.xml:209
6847 msgid ""
6848 "The <command role=\"hg-cmd\">hg commit</command> command also provides a "
6849 "<option role=\"hg-opt-commit\">-A</option> option that performs this same add-"
6850 "and-remove, immediately followed by a commit."
6851 msgstr ""
6853 #. type: Content of: <book><chapter><sect1><title>
6854 #: ../en/ch05-daily.xml:219
6855 msgid "Copying files"
6856 msgstr "复制文件"
6858 #. type: Content of: <book><chapter><sect1><para>
6859 #: ../en/ch05-daily.xml:221
6860 msgid ""
6861 "Mercurial provides a <command role=\"hg-cmd\">hg copy</command> command that "
6862 "lets you make a new copy of a file. When you copy a file using this command, "
6863 "Mercurial makes a record of the fact that the new file is a copy of the "
6864 "original file. It treats these copied files specially when you merge your "
6865 "work with someone else's."
6866 msgstr ""
6868 #. type: Content of: <book><chapter><sect1><sect2><title>
6869 #: ../en/ch05-daily.xml:229
6870 msgid "The results of copying during a merge"
6871 msgstr "合并期间的复制结果"
6873 #. type: Content of: <book><chapter><sect1><sect2><para>
6874 #: ../en/ch05-daily.xml:231
6875 msgid ""
6876 "What happens during a merge is that changes <quote>follow</quote> a copy. To "
6877 "best illustrate what this means, let's create an example. We'll start with "
6878 "the usual tiny repository that contains a single file."
6879 msgstr ""
6881 #. type: Content of: <book><chapter><sect1><sect2><para>
6882 #: ../en/ch05-daily.xml:238
6883 msgid ""
6884 "We need to do some work in parallel, so that we'll have something to merge. "
6885 "So let's clone our repository."
6886 msgstr ""
6888 #. type: Content of: <book><chapter><sect1><sect2><para>
6889 #: ../en/ch05-daily.xml:244
6890 msgid ""
6891 "Back in our initial repository, let's use the <command role=\"hg-cmd\">hg "
6892 "copy</command> command to make a copy of the first file we created."
6893 msgstr ""
6895 #. type: Content of: <book><chapter><sect1><sect2><para>
6896 #: ../en/ch05-daily.xml:250
6897 msgid ""
6898 "If we look at the output of the <command role=\"hg-cmd\">hg status</command> "
6899 "command afterwards, the copied file looks just like a normal added file."
6900 msgstr ""
6902 #. type: Content of: <book><chapter><sect1><sect2><para>
6903 #: ../en/ch05-daily.xml:256
6904 msgid ""
6905 "But if we pass the <option role=\"hg-opt-status\">-C</option> option to "
6906 "<command role=\"hg-cmd\">hg status</command>, it prints another line of "
6907 "output: this is the file that our newly-added file was copied <emphasis>from</"
6908 "emphasis>."
6909 msgstr ""
6911 #. type: Content of: <book><chapter><sect1><sect2><para>
6912 #: ../en/ch05-daily.xml:264
6913 msgid ""
6914 "Now, back in the repository we cloned, let's make a change in parallel. "
6915 "We'll add a line of content to the original file that we created."
6916 msgstr ""
6918 #. type: Content of: <book><chapter><sect1><sect2><para>
6919 #: ../en/ch05-daily.xml:270
6920 msgid ""
6921 "Now we have a modified <filename>file</filename> in this repository. When we "
6922 "pull the changes from the first repository, and merge the two heads, "
6923 "Mercurial will propagate the changes that we made locally to <filename>file</"
6924 "filename> into its copy, <filename>new-file</filename>."
6925 msgstr ""
6927 #. type: Content of: <book><chapter><sect1><sect2><title>
6928 #: ../en/ch05-daily.xml:280
6929 msgid "Why should changes follow copies?"
6930 msgstr "为什么复制后需要后续修改?"
6932 #. type: Content of: <book><chapter><sect1><sect2><para>
6933 #: ../en/ch05-daily.xml:282
6934 msgid ""
6935 "This behavior&emdash;of changes to a file propagating out to copies of the "
6936 "file&emdash;might seem esoteric, but in most cases it's highly desirable."
6937 msgstr ""
6939 #. type: Content of: <book><chapter><sect1><sect2><para>
6940 #: ../en/ch05-daily.xml:286
6941 msgid ""
6942 "First of all, remember that this propagation <emphasis>only</emphasis> "
6943 "happens when you merge. So if you <command role=\"hg-cmd\">hg copy</command> "
6944 "a file, and subsequently modify the original file during the normal course of "
6945 "your work, nothing will happen."
6946 msgstr ""
6948 #. type: Content of: <book><chapter><sect1><sect2><para>
6949 #: ../en/ch05-daily.xml:292
6950 msgid ""
6951 "The second thing to know is that modifications will only propagate across a "
6952 "copy as long as the changeset that you're merging changes from "
6953 "<emphasis>hasn't yet seen</emphasis> the copy."
6954 msgstr ""
6956 #. type: Content of: <book><chapter><sect1><sect2><para>
6957 #: ../en/ch05-daily.xml:297
6958 msgid ""
6959 "The reason that Mercurial does this is as follows. Let's say I make an "
6960 "important bug fix in a source file, and commit my changes. Meanwhile, you've "
6961 "decided to <command role=\"hg-cmd\">hg copy</command> the file in your "
6962 "repository, without knowing about the bug or having seen the fix, and you "
6963 "have started hacking on your copy of the file."
6964 msgstr ""
6966 #. type: Content of: <book><chapter><sect1><sect2><para>
6967 #: ../en/ch05-daily.xml:304
6968 msgid ""
6969 "If you pulled and merged my changes, and Mercurial <emphasis>didn't</"
6970 "emphasis> propagate changes across copies, your new source file would now "
6971 "contain the bug, and unless you knew to propagate the bug fix by hand, the "
6972 "bug would <emphasis>remain</emphasis> in your copy of the file."
6973 msgstr ""
6975 #. type: Content of: <book><chapter><sect1><sect2><para>
6976 #: ../en/ch05-daily.xml:310
6977 msgid ""
6978 "By automatically propagating the change that fixed the bug from the original "
6979 "file to the copy, Mercurial prevents this class of problem. To my knowledge, "
6980 "Mercurial is the <emphasis>only</emphasis> revision control system that "
6981 "propagates changes across copies like this."
6982 msgstr ""
6984 #. type: Content of: <book><chapter><sect1><sect2><para>
6985 #: ../en/ch05-daily.xml:316
6986 msgid ""
6987 "Once your change history has a record that the copy and subsequent merge "
6988 "occurred, there's usually no further need to propagate changes from the "
6989 "original file to the copied file, and that's why Mercurial only propagates "
6990 "changes across copies at the first merge, and not afterwards."
6991 msgstr ""
6993 #. type: Content of: <book><chapter><sect1><sect2><title>
6994 #: ../en/ch05-daily.xml:324
6995 msgid "How to make changes <emphasis>not</emphasis> follow a copy"
6996 msgstr "如何让复制后<emphasis>不</emphasis>修改?"
6998 #. type: Content of: <book><chapter><sect1><sect2><para>
6999 #: ../en/ch05-daily.xml:327
7000 msgid ""
7001 "If, for some reason, you decide that this business of automatically "
7002 "propagating changes across copies is not for you, simply use your system's "
7003 "normal file copy command (on Unix-like systems, that's <command>cp</command>) "
7004 "to make a copy of a file, then <command role=\"hg-cmd\">hg add</command> the "
7005 "new copy by hand. Before you do so, though, please do reread <xref linkend="
7006 "\"sec:daily:why-copy\"/>, and make an informed decision that this behavior is "
7007 "not appropriate to your specific case."
7008 msgstr ""
7010 #. type: Content of: <book><chapter><sect1><sect2><title>
7011 #: ../en/ch05-daily.xml:340
7012 msgid "Behavior of the <command role=\"hg-cmd\">hg copy</command> command"
7013 msgstr "命令 <command role=\"hg-cmd\">hg copy</command> 的特性"
7015 #. type: Content of: <book><chapter><sect1><sect2><para>
7016 #: ../en/ch05-daily.xml:343
7017 msgid ""
7018 "When you use the <command role=\"hg-cmd\">hg copy</command> command, "
7019 "Mercurial makes a copy of each source file as it currently stands in the "
7020 "working directory. This means that if you make some modifications to a file, "
7021 "then <command role=\"hg-cmd\">hg copy</command> it without first having "
7022 "committed those changes, the new copy will also contain the modifications you "
7023 "have made up until that point. (I find this behavior a little "
7024 "counterintuitive, which is why I mention it here.)"
7025 msgstr ""
7027 #. type: Content of: <book><chapter><sect1><sect2><para>
7028 #: ../en/ch05-daily.xml:353
7029 msgid ""
7030 "The <command role=\"hg-cmd\">hg copy</command> command acts similarly to the "
7031 "Unix <command>cp</command> command (you can use the <command role=\"hg-cmd"
7032 "\">hg cp</command> alias if you prefer). We must supply two or more "
7033 "arguments, of which the last is treated as the <emphasis>destination</"
7034 "emphasis>, and all others are <emphasis>sources</emphasis>."
7035 msgstr ""
7037 #. type: Content of: <book><chapter><sect1><sect2><para>
7038 #: ../en/ch05-daily.xml:361
7039 msgid ""
7040 "If you pass <command role=\"hg-cmd\">hg copy</command> a single file as the "
7041 "source, and the destination does not exist, it creates a new file with that "
7042 "name."
7043 msgstr ""
7045 #. type: Content of: <book><chapter><sect1><sect2><para>
7046 #: ../en/ch05-daily.xml:367
7047 msgid ""
7048 "If the destination is a directory, Mercurial copies its sources into that "
7049 "directory."
7050 msgstr ""
7052 #. type: Content of: <book><chapter><sect1><sect2><para>
7053 #: ../en/ch05-daily.xml:372
7054 msgid ""
7055 "Copying a directory is recursive, and preserves the directory structure of "
7056 "the source."
7057 msgstr ""
7059 #. type: Content of: <book><chapter><sect1><sect2><para>
7060 #: ../en/ch05-daily.xml:378
7061 msgid ""
7062 "If the source and destination are both directories, the source tree is "
7063 "recreated in the destination directory."
7064 msgstr ""
7066 #. type: Content of: <book><chapter><sect1><sect2><para>
7067 #: ../en/ch05-daily.xml:383
7068 msgid ""
7069 "As with the <command role=\"hg-cmd\">hg remove</command> command, if you copy "
7070 "a file manually and then want Mercurial to know that you've copied the file, "
7071 "simply use the <option role=\"hg-opt-copy\">--after</option> option to "
7072 "<command role=\"hg-cmd\">hg copy</command>."
7073 msgstr ""
7075 #. type: Content of: <book><chapter><sect1><title>
7076 #: ../en/ch05-daily.xml:394
7077 msgid "Renaming files"
7078 msgstr "改名文件"
7080 #. type: Content of: <book><chapter><sect1><para>
7081 #: ../en/ch05-daily.xml:396
7082 msgid ""
7083 "It's rather more common to need to rename a file than to make a copy of it. "
7084 "The reason I discussed the <command role=\"hg-cmd\">hg copy</command> command "
7085 "before talking about renaming files is that Mercurial treats a rename in "
7086 "essentially the same way as a copy. Therefore, knowing what Mercurial does "
7087 "when you copy a file tells you what to expect when you rename a file."
7088 msgstr ""
7090 #. type: Content of: <book><chapter><sect1><para>
7091 #: ../en/ch05-daily.xml:404
7092 msgid ""
7093 "When you use the <command role=\"hg-cmd\">hg rename</command> command, "
7094 "Mercurial makes a copy of each source file, then deletes it and marks the "
7095 "file as removed."
7096 msgstr ""
7098 #. type: Content of: <book><chapter><sect1><para>
7099 #: ../en/ch05-daily.xml:410
7100 msgid ""
7101 "The <command role=\"hg-cmd\">hg status</command> command shows the newly "
7102 "copied file as added, and the copied-from file as removed."
7103 msgstr ""
7105 #. type: Content of: <book><chapter><sect1><para>
7106 #: ../en/ch05-daily.xml:416
7107 msgid ""
7108 "As with the results of a <command role=\"hg-cmd\">hg copy</command>, we must "
7109 "use the <option role=\"hg-opt-status\">-C</option> option to <command role="
7110 "\"hg-cmd\">hg status</command> to see that the added file is really being "
7111 "tracked by Mercurial as a copy of the original, now removed, file."
7112 msgstr ""
7114 #. type: Content of: <book><chapter><sect1><para>
7115 #: ../en/ch05-daily.xml:425
7116 msgid ""
7117 "As with <command role=\"hg-cmd\">hg remove</command> and <command role=\"hg-"
7118 "cmd\">hg copy</command>, you can tell Mercurial about a rename after the fact "
7119 "using the <option role=\"hg-opt-rename\">--after</option> option. In most "
7120 "other respects, the behavior of the <command role=\"hg-cmd\">hg rename</"
7121 "command> command, and the options it accepts, are similar to the <command "
7122 "role=\"hg-cmd\">hg copy</command> command."
7123 msgstr ""
7125 #. type: Content of: <book><chapter><sect1><para>
7126 #: ../en/ch05-daily.xml:434
7127 msgid ""
7128 "If you're familiar with the Unix command line, you'll be glad to know that "
7129 "<command role=\"hg-cmd\">hg rename</command> command can be invoked as "
7130 "<command role=\"hg-cmd\">hg mv</command>."
7131 msgstr ""
7133 #. type: Content of: <book><chapter><sect1><sect2><title>
7134 #: ../en/ch05-daily.xml:440
7135 msgid "Renaming files and merging changes"
7136 msgstr "改名文件与合并修改"
7138 #. type: Content of: <book><chapter><sect1><sect2><para>
7139 #: ../en/ch05-daily.xml:442
7140 msgid ""
7141 "Since Mercurial's rename is implemented as copy-and-remove, the same "
7142 "propagation of changes happens when you merge after a rename as after a copy."
7143 msgstr ""
7145 #. type: Content of: <book><chapter><sect1><sect2><para>
7146 #: ../en/ch05-daily.xml:446
7147 msgid ""
7148 "If I modify a file, and you rename it to a new name, and then we merge our "
7149 "respective changes, my modifications to the file under its original name will "
7150 "be propagated into the file under its new name. (This is something you might "
7151 "expect to <quote>simply work,</quote> but not all revision control systems "
7152 "actually do this.)"
7153 msgstr ""
7155 #. type: Content of: <book><chapter><sect1><sect2><para>
7156 #: ../en/ch05-daily.xml:453
7157 msgid ""
7158 "Whereas having changes follow a copy is a feature where you can perhaps nod "
7159 "and say <quote>yes, that might be useful,</quote> it should be clear that "
7160 "having them follow a rename is definitely important. Without this facility, "
7161 "it would simply be too easy for changes to become orphaned when files are "
7162 "renamed."
7163 msgstr ""
7165 #. type: Content of: <book><chapter><sect1><sect2><title>
7166 #: ../en/ch05-daily.xml:462
7167 msgid "Divergent renames and merging"
7168 msgstr "改名与合并的分歧"
7170 #. type: Content of: <book><chapter><sect1><sect2><para>
7171 #: ../en/ch05-daily.xml:464
7172 msgid ""
7173 "The case of diverging names occurs when two developers start with a "
7174 "file&emdash;let's call it <filename>foo</filename>&emdash;in their respective "
7175 "repositories."
7176 msgstr ""
7178 #. type: Content of: <book><chapter><sect1><sect2><para>
7179 #: ../en/ch05-daily.xml:471
7180 msgid "Anne renames the file to <filename>bar</filename>."
7181 msgstr ""
7183 #. type: Content of: <book><chapter><sect1><sect2><para>
7184 #: ../en/ch05-daily.xml:475
7185 msgid ""
7186 "Meanwhile, Bob renames it to <filename>quux</filename>. (Remember that "
7187 "<command role=\"hg-cmd\">hg mv</command> is an alias for <command role=\"hg-"
7188 "cmd\">hg rename</command>.)"
7189 msgstr ""
7191 #. type: Content of: <book><chapter><sect1><sect2><para>
7192 #: ../en/ch05-daily.xml:482
7193 msgid ""
7194 "I like to think of this as a conflict because each developer has expressed "
7195 "different intentions about what the file ought to be named."
7196 msgstr ""
7198 #. type: Content of: <book><chapter><sect1><sect2><para>
7199 #: ../en/ch05-daily.xml:486
7200 msgid ""
7201 "What do you think should happen when they merge their work? Mercurial's "
7202 "actual behavior is that it always preserves <emphasis>both</emphasis> names "
7203 "when it merges changesets that contain divergent renames."
7204 msgstr ""
7206 #. type: Content of: <book><chapter><sect1><sect2><para>
7207 #: ../en/ch05-daily.xml:493
7208 msgid ""
7209 "Notice that while Mercurial warns about the divergent renames, it leaves it "
7210 "up to you to do something about the divergence after the merge."
7211 msgstr ""
7213 #. type: Content of: <book><chapter><sect1><sect2><title>
7214 #: ../en/ch05-daily.xml:499
7215 msgid "Convergent renames and merging"
7216 msgstr "收敛改名与合并"
7218 #. type: Content of: <book><chapter><sect1><sect2><para>
7219 #: ../en/ch05-daily.xml:501
7220 msgid ""
7221 "Another kind of rename conflict occurs when two people choose to rename "
7222 "different <emphasis>source</emphasis> files to the same "
7223 "<emphasis>destination</emphasis>. In this case, Mercurial runs its normal "
7224 "merge machinery, and lets you guide it to a suitable resolution."
7225 msgstr ""
7227 #. type: Content of: <book><chapter><sect1><sect2><title>
7228 #: ../en/ch05-daily.xml:509
7229 msgid "Other name-related corner cases"
7230 msgstr "其它名称相关的角落"
7232 #. type: Content of: <book><chapter><sect1><sect2><para>
7233 #: ../en/ch05-daily.xml:511
7234 msgid ""
7235 "Mercurial has a longstanding bug in which it fails to handle a merge where "
7236 "one side has a file with a given name, while another has a directory with the "
7237 "same name. This is documented as <ulink role=\"hg-bug\" url=\"http://www."
7238 "selenic.com/mercurial/bts/issue29\">issue 29</ulink>."
7239 msgstr ""
7241 #. type: Content of: <book><chapter><sect1><title>
7242 #: ../en/ch05-daily.xml:524
7243 msgid "Recovering from mistakes"
7244 msgstr "从错误恢复"
7246 #. type: Content of: <book><chapter><sect1><para>
7247 #: ../en/ch05-daily.xml:526
7248 msgid ""
7249 "Mercurial has some useful commands that will help you to recover from some "
7250 "common mistakes."
7251 msgstr ""
7253 #. type: Content of: <book><chapter><sect1><para>
7254 #: ../en/ch05-daily.xml:529
7255 msgid ""
7256 "The <command role=\"hg-cmd\">hg revert</command> command lets you undo "
7257 "changes that you have made to your working directory. For example, if you "
7258 "<command role=\"hg-cmd\">hg add</command> a file by accident, just run "
7259 "<command role=\"hg-cmd\">hg revert</command> with the name of the file you "
7260 "added, and while the file won't be touched in any way, it won't be tracked "
7261 "for adding by Mercurial any longer, either. You can also use <command role="
7262 "\"hg-cmd\">hg revert</command> to get rid of erroneous changes to a file."
7263 msgstr ""
7265 #. type: Content of: <book><chapter><sect1><para>
7266 #: ../en/ch05-daily.xml:539
7267 msgid ""
7268 "It is helpful to remember that the <command role=\"hg-cmd\">hg revert</"
7269 "command> command is useful for changes that you have not yet committed. Once "
7270 "you've committed a change, if you decide it was a mistake, you can still do "
7271 "something about it, though your options may be more limited."
7272 msgstr ""
7274 #. type: Content of: <book><chapter><sect1><para>
7275 #: ../en/ch05-daily.xml:546
7276 msgid ""
7277 "For more information about the <command role=\"hg-cmd\">hg revert</command> "
7278 "command, and details about how to deal with changes you have already "
7279 "committed, see <xref linkend=\"chap:undo\"/>."
7280 msgstr ""
7282 #. type: Content of: <book><chapter><sect1><title>
7283 #: ../en/ch05-daily.xml:553
7284 msgid "Dealing with tricky merges"
7285 msgstr "合并的技巧"
7287 #. type: Content of: <book><chapter><sect1><para>
7288 #: ../en/ch05-daily.xml:555
7289 msgid ""
7290 "In a complicated or large project, it's not unusual for a merge of two "
7291 "changesets to result in some headaches. Suppose there's a big source file "
7292 "that's been extensively edited by each side of a merge: this is almost "
7293 "inevitably going to result in conflicts, some of which can take a few tries "
7294 "to sort out."
7295 msgstr ""
7297 #. type: Content of: <book><chapter><sect1><para>
7298 #: ../en/ch05-daily.xml:562
7299 msgid ""
7300 "Let's develop a simple case of this and see how to deal with it. We'll start "
7301 "off with a repository containing one file, and clone it twice."
7302 msgstr ""
7304 #. type: Content of: <book><chapter><sect1><para>
7305 #: ../en/ch05-daily.xml:568
7306 msgid "In one clone, we'll modify the file in one way."
7307 msgstr ""
7309 #. type: Content of: <book><chapter><sect1><para>
7310 #: ../en/ch05-daily.xml:572
7311 msgid "In another, we'll modify the file differently."
7312 msgstr ""
7314 #. type: Content of: <book><chapter><sect1><para>
7315 #: ../en/ch05-daily.xml:576
7316 msgid "Next, we'll pull each set of changes into our original repo."
7317 msgstr ""
7319 #. type: Content of: <book><chapter><sect1><para>
7320 #: ../en/ch05-daily.xml:581
7321 msgid "We expect our repository to now contain two heads."
7322 msgstr ""
7324 #. type: Content of: <book><chapter><sect1><para>
7325 #: ../en/ch05-daily.xml:585
7326 msgid ""
7327 "Normally, if we run <command role=\"hg-cmd\">hg merge</command> at this "
7328 "point, it will drop us into a GUI that will let us manually resolve the "
7329 "conflicting edits to <filename>myfile.txt</filename>. However, to simplify "
7330 "things for presentation here, we'd like the merge to fail immediately "
7331 "instead. Here's one way we can do so."
7332 msgstr ""
7334 #. type: Content of: <book><chapter><sect1><para>
7335 #: ../en/ch05-daily.xml:594
7336 msgid ""
7337 "We've told Mercurial's merge machinery to run the command <command>false</"
7338 "command> (which, as we desire, fails immediately) if it detects a merge that "
7339 "it can't sort out automatically."
7340 msgstr ""
7342 #. type: Content of: <book><chapter><sect1><para>
7343 #: ../en/ch05-daily.xml:599
7344 msgid ""
7345 "If we now fire up <command role=\"hg-cmd\">hg merge</command>, it should "
7346 "grind to a halt and report a failure."
7347 msgstr ""
7349 #. type: Content of: <book><chapter><sect1><para>
7350 #: ../en/ch05-daily.xml:605
7351 msgid ""
7352 "Even if we don't notice that the merge failed, Mercurial will prevent us from "
7353 "accidentally committing the result of a failed merge."
7354 msgstr ""
7356 #. type: Content of: <book><chapter><sect1><para>
7357 #: ../en/ch05-daily.xml:611
7358 msgid ""
7359 "When <command role=\"hg-cmd\">hg commit</command> fails in this case, it "
7360 "suggests that we use the unfamiliar <command role=\"hg-cmd\">hg resolve</"
7361 "command> command. As usual, <command role=\"hg-cmd\">hg help resolve</"
7362 "command> will print a helpful synopsis."
7363 msgstr ""
7365 #. type: Content of: <book><chapter><sect1><sect2><title>
7366 #: ../en/ch05-daily.xml:618
7367 msgid "File resolution states"
7368 msgstr "文件的解决状态"
7370 #. type: Content of: <book><chapter><sect1><sect2><para>
7371 #: ../en/ch05-daily.xml:620
7372 msgid ""
7373 "When a merge occurs, most files will usually remain unmodified. For each "
7374 "file where Mercurial has to do something, it tracks the state of the file."
7375 msgstr ""
7377 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
7378 #: ../en/ch05-daily.xml:626
7379 msgid ""
7380 "A <emphasis>resolved</emphasis> file has been successfully merged, either "
7381 "automatically by Mercurial or manually with human intervention."
7382 msgstr ""
7384 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
7385 #: ../en/ch05-daily.xml:631
7386 msgid ""
7387 "An <emphasis>unresolved</emphasis> file was not merged successfully, and "
7388 "needs more attention."
7389 msgstr ""
7391 #. type: Content of: <book><chapter><sect1><sect2><para>
7392 #: ../en/ch05-daily.xml:636
7393 msgid ""
7394 "If Mercurial sees <emphasis>any</emphasis> file in the unresolved state after "
7395 "a merge, it considers the merge to have failed. Fortunately, we do not need "
7396 "to restart the entire merge from scratch."
7397 msgstr ""
7399 #. type: Content of: <book><chapter><sect1><sect2><para>
7400 #: ../en/ch05-daily.xml:641
7401 msgid ""
7402 "The <option role=\"hg-opt-resolve\">--list</option> or <option role=\"hg-opt-"
7403 "resolve\">-l</option> option to <command role=\"hg-cmd\">hg resolve</command> "
7404 "prints out the state of each merged file."
7405 msgstr ""
7407 #. type: Content of: <book><chapter><sect1><sect2><para>
7408 #: ../en/ch05-daily.xml:648
7409 msgid ""
7410 "In the output from <command role=\"hg-cmd\">hg resolve</command>, a resolved "
7411 "file is marked with <literal>R</literal>, while an unresolved file is marked "
7412 "with <literal>U</literal>. If any files are listed with <literal>U</"
7413 "literal>, we know that an attempt to commit the results of the merge will "
7414 "fail."
7415 msgstr ""
7417 #. type: Content of: <book><chapter><sect1><sect2><title>
7418 #: ../en/ch05-daily.xml:657
7419 msgid "Resolving a file merge"
7420 msgstr "合并文件"
7422 #. type: Content of: <book><chapter><sect1><sect2><para>
7423 #: ../en/ch05-daily.xml:659
7424 msgid ""
7425 "We have several options to move a file from the unresolved into the resolved "
7426 "state. By far the most common is to rerun <command role=\"hg-cmd\">hg "
7427 "resolve</command>. If we pass the names of individual files or directories, "
7428 "it will retry the merges of any unresolved files present in those locations. "
7429 "We can also pass the <option role=\"hg-opt-resolve\">--all</option> or "
7430 "<option role=\"hg-opt-resolve\">-a</option> option, which will retry the "
7431 "merges of <emphasis>all</emphasis> unresolved files."
7432 msgstr ""
7434 #. type: Content of: <book><chapter><sect1><sect2><para>
7435 #: ../en/ch05-daily.xml:669
7436 msgid ""
7437 "Mercurial also lets us modify the resolution state of a file directly. We "
7438 "can manually mark a file as resolved using the <option role=\"hg-opt-resolve"
7439 "\">--mark</option> option, or as unresolved using the <option role=\"hg-opt-"
7440 "resolve\">--unmark</option> option. This allows us to clean up a "
7441 "particularly messy merge by hand, and to keep track of our progress with each "
7442 "file as we go."
7443 msgstr ""
7445 #. type: Content of: <book><chapter><sect1><title>
7446 #: ../en/ch05-daily.xml:680
7447 msgid "More useful diffs"
7448 msgstr "更有用的差异"
7450 #. type: Content of: <book><chapter><sect1><para>
7451 #: ../en/ch05-daily.xml:682
7452 msgid ""
7453 "The default output of the <command role=\"hg-cmd\">hg diff</command> command "
7454 "is backwards compatible with the regular <command>diff</command> command, but "
7455 "this has some drawbacks."
7456 msgstr ""
7458 #. type: Content of: <book><chapter><sect1><para>
7459 #: ../en/ch05-daily.xml:687
7460 msgid ""
7461 "Consider the case where we use <command role=\"hg-cmd\">hg rename</command> "
7462 "to rename a file."
7463 msgstr ""
7464 "设想我们使用 <command role=\"hg-cmd\">hg rename</command> 命令来改名文件。"
7466 #. type: Content of: <book><chapter><sect1><para>
7467 #: ../en/ch05-daily.xml:692
7468 msgid ""
7469 "The output of <command role=\"hg-cmd\">hg diff</command> above obscures the "
7470 "fact that we simply renamed a file. The <command role=\"hg-cmd\">hg diff</"
7471 "command> command accepts an option, <option>--git</option> or <option>-g</"
7472 "option>, to use a newer diff format that displays such information in a more "
7473 "readable form."
7474 msgstr ""
7476 #. type: Content of: <book><chapter><sect1><para>
7477 #: ../en/ch05-daily.xml:701
7478 msgid ""
7479 "This option also helps with a case that can otherwise be confusing: a file "
7480 "that appears to be modified according to <command role=\"hg-cmd\">hg status</"
7481 "command>, but for which <command role=\"hg-cmd\">hg diff</command> prints "
7482 "nothing. This situation can arise if we change the file's execute permissions."
7483 msgstr ""
7485 #. type: Content of: <book><chapter><sect1><para>
7486 #: ../en/ch05-daily.xml:710
7487 msgid ""
7488 "The normal <command>diff</command> command pays no attention to file "
7489 "permissions, which is why <command role=\"hg-cmd\">hg diff</command> prints "
7490 "nothing by default. If we supply it with the <option>-g</option> option, it "
7491 "tells us what really happened."
7492 msgstr ""
7494 #. type: Content of: <book><chapter><sect1><title>
7495 #: ../en/ch05-daily.xml:720
7496 msgid "Which files to manage, and which to avoid"
7497 msgstr "需要管理哪些文件,应该避免的事情"
7499 #. type: Content of: <book><chapter><sect1><para>
7500 #: ../en/ch05-daily.xml:722
7501 msgid ""
7502 "Revision control systems are generally best at managing text files that are "
7503 "written by humans, such as source code, where the files do not change much "
7504 "from one revision to the next. Some centralized revision control systems can "
7505 "also deal tolerably well with binary files, such as bitmap images."
7506 msgstr ""
7508 #. type: Content of: <book><chapter><sect1><para>
7509 #: ../en/ch05-daily.xml:728
7510 msgid ""
7511 "For instance, a game development team will typically manage both its source "
7512 "code and all of its binary assets (e.g. geometry data, textures, map layouts) "
7513 "in a revision control system."
7514 msgstr ""
7516 #. type: Content of: <book><chapter><sect1><para>
7517 #: ../en/ch05-daily.xml:733
7518 msgid ""
7519 "Because it is usually impossible to merge two conflicting modifications to a "
7520 "binary file, centralized systems often provide a file locking mechanism that "
7521 "allow a user to say <quote>I am the only person who can edit this file</"
7522 "quote>."
7523 msgstr ""
7525 #. type: Content of: <book><chapter><sect1><para>
7526 #: ../en/ch05-daily.xml:739
7527 msgid ""
7528 "Compared to a centralized system, a distributed revision control system "
7529 "changes some of the factors that guide decisions over which files to manage "
7530 "and how."
7531 msgstr ""
7533 #. type: Content of: <book><chapter><sect1><para>
7534 #: ../en/ch05-daily.xml:743
7535 msgid ""
7536 "For instance, a distributed revision control system cannot, by its nature, "
7537 "offer a file locking facility. There is thus no built-in mechanism to "
7538 "prevent two people from making conflicting changes to a binary file. If you "
7539 "have a team where several people may be editing binary files frequently, it "
7540 "may not be a good idea to use Mercurial&emdash;or any other distributed "
7541 "revision control system&emdash;to manage those files."
7542 msgstr ""
7544 #. type: Content of: <book><chapter><sect1><para>
7545 #: ../en/ch05-daily.xml:751
7546 msgid ""
7547 "When storing modifications to a file, Mercurial usually saves only the "
7548 "differences between the previous and current versions of the file. For most "
7549 "text files, this is extremely efficient. However, some files (particularly "
7550 "binary files) are laid out in such a way that even a small change to a file's "
7551 "logical content results in many or most of the bytes inside the file "
7552 "changing. For instance, compressed files are particularly susceptible to "
7553 "this. If the differences between each successive version of a file are always "
7554 "large, Mercurial will not be able to store the file's revision history very "
7555 "efficiently. This can affect both local storage needs and the amount of time "
7556 "it takes to clone a repository."
7557 msgstr ""
7559 #. type: Content of: <book><chapter><sect1><para>
7560 #: ../en/ch05-daily.xml:764
7561 msgid ""
7562 "To get an idea of how this could affect you in practice, suppose you want to "
7563 "use Mercurial to manage an OpenOffice document. OpenOffice stores documents "
7564 "on disk as compressed zip files. Edit even a single letter of your document "
7565 "in OpenOffice, and almost every byte in the entire file will change when you "
7566 "save it. Now suppose that file is 2MB in size. Because most of the file "
7567 "changes every time you save, Mercurial will have to store all 2MB of the file "
7568 "every time you commit, even though from your perspective, perhaps only a few "
7569 "words are changing each time. A single frequently-edited file that is not "
7570 "friendly to Mercurial's storage assumptions can easily have an outsized "
7571 "effect on the size of the repository."
7572 msgstr ""
7574 #. type: Content of: <book><chapter><sect1><para>
7575 #: ../en/ch05-daily.xml:777
7576 msgid ""
7577 "Even worse, if both you and someone else edit the OpenOffice document you're "
7578 "working on, there is no useful way to merge your work. In fact, there isn't "
7579 "even a good way to tell what the differences are between your respective "
7580 "changes."
7581 msgstr ""
7583 #. type: Content of: <book><chapter><sect1><para>
7584 #: ../en/ch05-daily.xml:782
7585 msgid ""
7586 "There are thus a few clear recommendations about specific kinds of files to "
7587 "be very careful with."
7588 msgstr ""
7590 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
7591 #: ../en/ch05-daily.xml:787
7592 msgid ""
7593 "Files that are very large and incompressible, e.g. ISO CD-ROM images, will by "
7594 "virtue of sheer size make clones over a network very slow."
7595 msgstr ""
7597 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
7598 #: ../en/ch05-daily.xml:792
7599 msgid ""
7600 "Files that change a lot from one revision to the next may be expensive to "
7601 "store if you edit them frequently, and conflicts due to concurrent edits may "
7602 "be difficult to resolve."
7603 msgstr ""
7605 #. type: Content of: <book><chapter><sect1><title>
7606 #: ../en/ch05-daily.xml:801
7607 msgid "Backups and mirroring"
7608 msgstr "备份与镜像"
7610 #. type: Content of: <book><chapter><sect1><para>
7611 #: ../en/ch05-daily.xml:803
7612 msgid ""
7613 "Since Mercurial maintains a complete copy of history in each clone, everyone "
7614 "who uses Mercurial to collaborate on a project can potentially act as a "
7615 "source of backups in the event of a catastrophe. If a central repository "
7616 "becomes unavailable, you can construct a replacement simply by cloning a copy "
7617 "of the repository from one contributor, and pulling any changes they may not "
7618 "have seen from others."
7619 msgstr ""
7621 #. type: Content of: <book><chapter><sect1><para>
7622 #: ../en/ch05-daily.xml:811
7623 msgid ""
7624 "It is simple to use Mercurial to perform off-site backups and remote "
7625 "mirrors. Set up a periodic job (e.g. via the <command>cron</command> "
7626 "command) on a remote server to pull changes from your master repositories "
7627 "every hour. This will only be tricky in the unlikely case that the number of "
7628 "master repositories you maintain changes frequently, in which case you'll "
7629 "need to do a little scripting to refresh the list of repositories to back up."
7630 msgstr ""
7632 #. type: Content of: <book><chapter><sect1><para>
7633 #: ../en/ch05-daily.xml:820
7634 msgid ""
7635 "If you perform traditional backups of your master repositories to tape or "
7636 "disk, and you want to back up a repository named <filename>myrepo</filename>, "
7637 "use <command>hg clone -U myrepo myrepo.bak</command> to create a clone of "
7638 "<filename>myrepo</filename> before you start your backups. The <option>-U</"
7639 "option> option doesn't check out a working directory after the clone "
7640 "completes, since that would be superfluous and make the backup take longer."
7641 msgstr ""
7643 #. type: Content of: <book><chapter><sect1><para>
7644 #: ../en/ch05-daily.xml:829
7645 msgid ""
7646 "If you then back up <filename>myrepo.bak</filename> instead of "
7647 "<filename>myrepo</filename>, you will be guaranteed to have a consistent "
7648 "snapshot of your repository that won't be pushed to by an insomniac developer "
7649 "in mid-backup."
7650 msgstr ""
7652 #. type: Content of: <book><chapter><title>
7653 #: ../en/ch06-collab.xml:5
7654 msgid "Collaborating with other people"
7655 msgstr "团体协作"
7657 #. type: Content of: <book><chapter><para>
7658 #: ../en/ch06-collab.xml:7
7659 msgid ""
7660 "As a completely decentralised tool, Mercurial doesn't impose any policy on "
7661 "how people ought to work with each other. However, if you're new to "
7662 "distributed revision control, it helps to have some tools and examples in "
7663 "mind when you're thinking about possible workflow models."
7664 msgstr ""
7666 #. type: Content of: <book><chapter><sect1><title>
7667 #: ../en/ch06-collab.xml:14
7668 msgid "Mercurial's web interface"
7669 msgstr "Mercurial 的 web 接口"
7671 #. type: Content of: <book><chapter><sect1><para>
7672 #: ../en/ch06-collab.xml:16
7673 msgid ""
7674 "Mercurial has a powerful web interface that provides several useful "
7675 "capabilities."
7676 msgstr ""
7678 #. type: Content of: <book><chapter><sect1><para>
7679 #: ../en/ch06-collab.xml:19
7680 msgid ""
7681 "For interactive use, the web interface lets you browse a single repository or "
7682 "a collection of repositories. You can view the history of a repository, "
7683 "examine each change (comments and diffs), and view the contents of each "
7684 "directory and file. You can even get a view of history that gives a "
7685 "graphical view of the relationships between individual changes and merges."
7686 msgstr ""
7688 #. type: Content of: <book><chapter><sect1><para>
7689 #: ../en/ch06-collab.xml:26
7690 msgid ""
7691 "Also for human consumption, the web interface provides Atom and RSS feeds of "
7692 "the changes in a repository. This lets you <quote>subscribe</quote> to a "
7693 "repository using your favorite feed reader, and be automatically notified of "
7694 "activity in that repository as soon as it happens. I find this capability "
7695 "much more convenient than the model of subscribing to a mailing list to which "
7696 "notifications are sent, as it requires no additional configuration on the "
7697 "part of whoever is serving the repository."
7698 msgstr ""
7700 #. type: Content of: <book><chapter><sect1><para>
7701 #: ../en/ch06-collab.xml:36
7702 msgid ""
7703 "The web interface also lets remote users clone a repository, pull changes "
7704 "from it, and (when the server is configured to permit it) push changes back "
7705 "to it. Mercurial's HTTP tunneling protocol aggressively compresses data, so "
7706 "that it works efficiently even over low-bandwidth network connections."
7707 msgstr ""
7709 #. type: Content of: <book><chapter><sect1><para>
7710 #: ../en/ch06-collab.xml:42
7711 msgid ""
7712 "The easiest way to get started with the web interface is to use your web "
7713 "browser to visit an existing repository, such as the master Mercurial "
7714 "repository at <ulink url=\"http://www.selenic.com/repo/hg\">http://www."
7715 "selenic.com/repo/hg</ulink>."
7716 msgstr ""
7718 #. type: Content of: <book><chapter><sect1><para>
7719 #: ../en/ch06-collab.xml:47
7720 msgid ""
7721 "If you're interested in providing a web interface to your own repositories, "
7722 "there are several good ways to do this."
7723 msgstr ""
7725 #. type: Content of: <book><chapter><sect1><para>
7726 #: ../en/ch06-collab.xml:51
7727 msgid ""
7728 "The easiest and fastest way to get started in an informal environment is to "
7729 "use the <command role=\"hg-cmd\">hg serve</command> command, which is best "
7730 "suited to short-term <quote>lightweight</quote> serving. See <xref linkend="
7731 "\"sec:collab:serve\"/> below for details of how to use this command."
7732 msgstr ""
7734 #. type: Content of: <book><chapter><sect1><para>
7735 #: ../en/ch06-collab.xml:58
7736 msgid ""
7737 "For longer-lived repositories that you'd like to have permanently available, "
7738 "there are several public hosting services available. Some are free to open "
7739 "source projects, while others offer paid commercial hosting. An up-to-date "
7740 "list is available at <ulink url=\"http://www.selenic.com/mercurial/wiki/index."
7741 "cgi/MercurialHosting\">http://www.selenic.com/mercurial/wiki/index.cgi/"
7742 "MercurialHosting</ulink>."
7743 msgstr ""
7745 #. type: Content of: <book><chapter><sect1><para>
7746 #: ../en/ch06-collab.xml:65
7747 msgid ""
7748 "If you would prefer to host your own repositories, Mercurial has built-in "
7749 "support for several popular hosting technologies, most notably CGI (Common "
7750 "Gateway Interface), and WSGI (Web Services Gateway Interface). See <xref "
7751 "linkend=\"sec:collab:cgi\"/> for details of CGI and WSGI configuration."
7752 msgstr ""
7754 #. type: Content of: <book><chapter><sect1><title>
7755 #: ../en/ch06-collab.xml:74
7756 msgid "Collaboration models"
7757 msgstr "协作模型"
7759 #. type: Content of: <book><chapter><sect1><para>
7760 #: ../en/ch06-collab.xml:76
7761 msgid ""
7762 "With a suitably flexible tool, making decisions about workflow is much more "
7763 "of a social engineering challenge than a technical one. Mercurial imposes few "
7764 "limitations on how you can structure the flow of work in a project, so it's "
7765 "up to you and your group to set up and live with a model that matches your "
7766 "own particular needs."
7767 msgstr ""
7769 #. type: Content of: <book><chapter><sect1><sect2><title>
7770 #: ../en/ch06-collab.xml:84
7771 msgid "Factors to keep in mind"
7772 msgstr "要牢记的因素"
7774 #. type: Content of: <book><chapter><sect1><sect2><para>
7775 #: ../en/ch06-collab.xml:86
7776 msgid ""
7777 "The most important aspect of any model that you must keep in mind is how well "
7778 "it matches the needs and capabilities of the people who will be using it. "
7779 "This might seem self-evident; even so, you still can't afford to forget it "
7780 "for a moment."
7781 msgstr ""
7783 #. type: Content of: <book><chapter><sect1><sect2><para>
7784 #: ../en/ch06-collab.xml:92
7785 msgid ""
7786 "I once put together a workflow model that seemed to make perfect sense to me, "
7787 "but that caused a considerable amount of consternation and strife within my "
7788 "development team. In spite of my attempts to explain why we needed a complex "
7789 "set of branches, and how changes ought to flow between them, a few team "
7790 "members revolted. Even though they were smart people, they didn't want to "
7791 "pay attention to the constraints we were operating under, or face the "
7792 "consequences of those constraints in the details of the model that I was "
7793 "advocating."
7794 msgstr ""
7796 #. type: Content of: <book><chapter><sect1><sect2><para>
7797 #: ../en/ch06-collab.xml:102
7798 msgid ""
7799 "Don't sweep foreseeable social or technical problems under the rug. Whatever "
7800 "scheme you put into effect, you should plan for mistakes and problem "
7801 "scenarios. Consider adding automated machinery to prevent, or quickly "
7802 "recover from, trouble that you can anticipate. As an example, if you intend "
7803 "to have a branch with not-for-release changes in it, you'd do well to think "
7804 "early about the possibility that someone might accidentally merge those "
7805 "changes into a release branch. You could avoid this particular problem by "
7806 "writing a hook that prevents changes from being merged from an inappropriate "
7807 "branch."
7808 msgstr ""
7810 #. type: Content of: <book><chapter><sect1><sect2><title>
7811 #: ../en/ch06-collab.xml:116
7812 msgid "Informal anarchy"
7813 msgstr "无政府状态"
7815 #. type: Content of: <book><chapter><sect1><sect2><para>
7816 #: ../en/ch06-collab.xml:118
7817 msgid ""
7818 "I wouldn't suggest an <quote>anything goes</quote> approach as something "
7819 "sustainable, but it's a model that's easy to grasp, and it works perfectly "
7820 "well in a few unusual situations."
7821 msgstr ""
7823 #. type: Content of: <book><chapter><sect1><sect2><para>
7824 #: ../en/ch06-collab.xml:123
7825 msgid ""
7826 "As one example, many projects have a loose-knit group of collaborators who "
7827 "rarely physically meet each other. Some groups like to overcome the "
7828 "isolation of working at a distance by organizing occasional <quote>sprints</"
7829 "quote>. In a sprint, a number of people get together in a single location (a "
7830 "company's conference room, a hotel meeting room, that kind of place) and "
7831 "spend several days more or less locked in there, hacking intensely on a "
7832 "handful of projects."
7833 msgstr ""
7835 #. type: Content of: <book><chapter><sect1><sect2><para>
7836 #: ../en/ch06-collab.xml:132
7837 msgid ""
7838 "A sprint or a hacking session in a coffee shop are the perfect places to use "
7839 "the <command role=\"hg-cmd\">hg serve</command> command, since <command role="
7840 "\"hg-cmd\">hg serve</command> does not require any fancy server "
7841 "infrastructure. You can get started with <command role=\"hg-cmd\">hg serve</"
7842 "command> in moments, by reading <xref linkend=\"sec:collab:serve\"/> below. "
7843 "Then simply tell the person next to you that you're running a server, send "
7844 "the URL to them in an instant message, and you immediately have a quick-"
7845 "turnaround way to work together. They can type your URL into their web "
7846 "browser and quickly review your changes; or they can pull a bugfix from you "
7847 "and verify it; or they can clone a branch containing a new feature and try it "
7848 "out."
7849 msgstr ""
7851 #. type: Content of: <book><chapter><sect1><sect2><para>
7852 #: ../en/ch06-collab.xml:146
7853 msgid ""
7854 "The charm, and the problem, with doing things in an ad hoc fashion like this "
7855 "is that only people who know about your changes, and where they are, can see "
7856 "them. Such an informal approach simply doesn't scale beyond a handful "
7857 "people, because each individual needs to know about <emphasis>n</emphasis> "
7858 "different repositories to pull from."
7859 msgstr ""
7861 #. type: Content of: <book><chapter><sect1><sect2><title>
7862 #: ../en/ch06-collab.xml:156
7863 msgid "A single central repository"
7864 msgstr "单一中央版本库"
7866 #. type: Content of: <book><chapter><sect1><sect2><para>
7867 #: ../en/ch06-collab.xml:158
7868 msgid ""
7869 "For smaller projects migrating from a centralised revision control tool, "
7870 "perhaps the easiest way to get started is to have changes flow through a "
7871 "single shared central repository. This is also the most common "
7872 "<quote>building block</quote> for more ambitious workflow schemes."
7873 msgstr ""
7875 #. type: Content of: <book><chapter><sect1><sect2><para>
7876 #: ../en/ch06-collab.xml:164
7877 msgid ""
7878 "Contributors start by cloning a copy of this repository. They can pull "
7879 "changes from it whenever they need to, and some (perhaps all) developers have "
7880 "permission to push a change back when they're ready for other people to see "
7881 "it."
7882 msgstr ""
7884 #. type: Content of: <book><chapter><sect1><sect2><para>
7885 #: ../en/ch06-collab.xml:169
7886 msgid ""
7887 "Under this model, it can still often make sense for people to pull changes "
7888 "directly from each other, without going through the central repository. "
7889 "Consider a case in which I have a tentative bug fix, but I am worried that if "
7890 "I were to publish it to the central repository, it might subsequently break "
7891 "everyone else's trees as they pull it. To reduce the potential for damage, I "
7892 "can ask you to clone my repository into a temporary repository of your own "
7893 "and test it. This lets us put off publishing the potentially unsafe change "
7894 "until it has had a little testing."
7895 msgstr ""
7897 #. type: Content of: <book><chapter><sect1><sect2><para>
7898 #: ../en/ch06-collab.xml:180
7899 msgid ""
7900 "If a team is hosting its own repository in this kind of scenario, people will "
7901 "usually use the <command>ssh</command> protocol to securely push changes to "
7902 "the central repository, as documented in <xref linkend=\"sec:collab:ssh\"/>. "
7903 "It's also usual to publish a read-only copy of the repository over HTTP, as "
7904 "in <xref linkend=\"sec:collab:cgi\"/>. Publishing over HTTP satisfies the "
7905 "needs of people who don't have push access, and those who want to use web "
7906 "browsers to browse the repository's history."
7907 msgstr ""
7909 #. type: Content of: <book><chapter><sect1><sect2><title>
7910 #: ../en/ch06-collab.xml:193
7911 msgid "A hosted central repository"
7912 msgstr "托管的中央版本库"
7914 #. type: Content of: <book><chapter><sect1><sect2><para>
7915 #: ../en/ch06-collab.xml:195
7916 msgid ""
7917 "A wonderful thing about public hosting services like <ulink url=\"http://"
7918 "bitbucket.org/\">Bitbucket</ulink> is that not only do they handle the fiddly "
7919 "server configuration details, such as user accounts, authentication, and "
7920 "secure wire protocols, they provide additional infrastructure to make this "
7921 "model work well."
7922 msgstr ""
7924 #. type: Content of: <book><chapter><sect1><sect2><para>
7925 #: ../en/ch06-collab.xml:202
7926 msgid ""
7927 "For instance, a well-engineered hosting service will let people clone their "
7928 "own copies of a repository with a single click. This lets people work in "
7929 "separate spaces and share their changes when they're ready."
7930 msgstr ""
7932 #. type: Content of: <book><chapter><sect1><sect2><para>
7933 #: ../en/ch06-collab.xml:207
7934 msgid ""
7935 "In addition, a good hosting service will let people communicate with each "
7936 "other, for instance to say <quote>there are changes ready for you to review "
7937 "in this tree</quote>."
7938 msgstr ""
7940 #. type: Content of: <book><chapter><sect1><sect2><title>
7941 #: ../en/ch06-collab.xml:214
7942 msgid "Working with multiple branches"
7943 msgstr "使用多个分支工作"
7945 #. type: Content of: <book><chapter><sect1><sect2><para>
7946 #: ../en/ch06-collab.xml:216
7947 msgid ""
7948 "Projects of any significant size naturally tend to make progress on several "
7949 "fronts simultaneously. In the case of software, it's common for a project to "
7950 "go through periodic official releases. A release might then go into "
7951 "<quote>maintenance mode</quote> for a while after its first publication; "
7952 "maintenance releases tend to contain only bug fixes, not new features. In "
7953 "parallel with these maintenance releases, one or more future releases may be "
7954 "under development. People normally use the word <quote>branch</quote> to "
7955 "refer to one of these many slightly different directions in which development "
7956 "is proceeding."
7957 msgstr ""
7959 #. type: Content of: <book><chapter><sect1><sect2><para>
7960 #: ../en/ch06-collab.xml:229
7961 msgid ""
7962 "Mercurial is particularly well suited to managing a number of simultaneous, "
7963 "but not identical, branches. Each <quote>development direction</quote> can "
7964 "live in its own central repository, and you can merge changes from one to "
7965 "another as the need arises. Because repositories are independent of each "
7966 "other, unstable changes in a development branch will never affect a stable "
7967 "branch unless someone explicitly merges those changes into the stable branch."
7968 msgstr ""
7970 #. type: Content of: <book><chapter><sect1><sect2><para>
7971 #: ../en/ch06-collab.xml:238
7972 msgid ""
7973 "Here's an example of how this can work in practice. Let's say you have one "
7974 "<quote>main branch</quote> on a central server."
7975 msgstr ""
7977 #. type: Content of: <book><chapter><sect1><sect2><para>
7978 #: ../en/ch06-collab.xml:244
7979 msgid "People clone it, make changes locally, test them, and push them back."
7980 msgstr ""
7982 #. type: Content of: <book><chapter><sect1><sect2><para>
7983 #: ../en/ch06-collab.xml:247
7984 msgid ""
7985 "Once the main branch reaches a release milestone, you can use the <command "
7986 "role=\"hg-cmd\">hg tag</command> command to give a permanent name to the "
7987 "milestone revision."
7988 msgstr ""
7990 #. type: Content of: <book><chapter><sect1><sect2><para>
7991 #: ../en/ch06-collab.xml:253
7992 msgid "Let's say some ongoing development occurs on the main branch."
7993 msgstr ""
7995 #. type: Content of: <book><chapter><sect1><sect2><para>
7996 #: ../en/ch06-collab.xml:258
7997 msgid ""
7998 "Using the tag that was recorded at the milestone, people who clone that "
7999 "repository at any time in the future can use <command role=\"hg-cmd\">hg "
8000 "update</command> to get a copy of the working directory exactly as it was "
8001 "when that tagged revision was committed."
8002 msgstr ""
8004 #. type: Content of: <book><chapter><sect1><sect2><para>
8005 #: ../en/ch06-collab.xml:266
8006 msgid ""
8007 "In addition, immediately after the main branch is tagged, we can then clone "
8008 "the main branch on the server to a new <quote>stable</quote> branch, also on "
8009 "the server."
8010 msgstr ""
8012 #. type: Content of: <book><chapter><sect1><sect2><para>
8013 #: ../en/ch06-collab.xml:272
8014 msgid ""
8015 "If we need to make a change to the stable branch, we can then clone "
8016 "<emphasis>that</emphasis> repository, make our changes, commit, and push our "
8017 "changes back there."
8018 msgstr ""
8020 #. type: Content of: <book><chapter><sect1><sect2><para>
8021 #: ../en/ch06-collab.xml:279
8022 msgid ""
8023 "Because Mercurial repositories are independent, and Mercurial doesn't move "
8024 "changes around automatically, the stable and main branches are "
8025 "<emphasis>isolated</emphasis> from each other. The changes that we made on "
8026 "the main branch don't <quote>leak</quote> to the stable branch, and vice "
8027 "versa."
8028 msgstr ""
8030 #. type: Content of: <book><chapter><sect1><sect2><para>
8031 #: ../en/ch06-collab.xml:286
8032 msgid ""
8033 "We'll often want all of our bugfixes on the stable branch to show up on the "
8034 "main branch, too. Rather than rewrite a bugfix on the main branch, we can "
8035 "simply pull and merge changes from the stable to the main branch, and "
8036 "Mercurial will bring those bugfixes in for us."
8037 msgstr ""
8039 #. type: Content of: <book><chapter><sect1><sect2><para>
8040 #: ../en/ch06-collab.xml:294
8041 msgid ""
8042 "The main branch will still contain changes that are not on the stable branch, "
8043 "but it will also contain all of the bugfixes from the stable branch. The "
8044 "stable branch remains unaffected by these changes, since changes are only "
8045 "flowing from the stable to the main branch, and not the other way."
8046 msgstr ""
8048 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
8049 #: ../en/ch06-collab.xml:303 ../en/ch06-collab.xml:313
8050 msgid "Feature branches"
8051 msgstr "特性分支"
8053 #. type: Content of: <book><chapter><sect1><sect2><para>
8054 #: ../en/ch06-collab.xml:305
8055 msgid ""
8056 "For larger projects, an effective way to manage change is to break up a team "
8057 "into smaller groups. Each group has a shared branch of its own, cloned from "
8058 "a single <quote>master</quote> branch used by the entire project. People "
8059 "working on an individual branch are typically quite isolated from "
8060 "developments on other branches."
8061 msgstr ""
8063 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
8064 #: ../en/ch06-collab.xml:315
8065 msgid ""
8066 "<imageobject><imagedata width=\"100%\" fileref=\"figs/feature-branches.png\"/"
8067 "></imageobject>"
8068 msgstr ""
8070 #. type: Content of: <book><chapter><sect1><sect2><para>
8071 #: ../en/ch06-collab.xml:320
8072 msgid ""
8073 "When a particular feature is deemed to be in suitable shape, someone on that "
8074 "feature team pulls and merges from the master branch into the feature branch, "
8075 "then pushes back up to the master branch."
8076 msgstr ""
8078 #. type: Content of: <book><chapter><sect1><sect2><title>
8079 #: ../en/ch06-collab.xml:327
8080 msgid "The release train"
8081 msgstr "发布列车"
8083 #. type: Content of: <book><chapter><sect1><sect2><para>
8084 #: ../en/ch06-collab.xml:329
8085 msgid ""
8086 "Some projects are organized on a <quote>train</quote> basis: a release is "
8087 "scheduled to happen every few months, and whatever features are ready when "
8088 "the <quote>train</quote> is ready to leave are allowed in."
8089 msgstr ""
8091 #. type: Content of: <book><chapter><sect1><sect2><para>
8092 #: ../en/ch06-collab.xml:334
8093 msgid ""
8094 "This model resembles working with feature branches. The difference is that "
8095 "when a feature branch misses a train, someone on the feature team pulls and "
8096 "merges the changes that went out on that train release into the feature "
8097 "branch, and the team continues its work on top of that release so that their "
8098 "feature can make the next release."
8099 msgstr ""
8101 #. type: Content of: <book><chapter><sect1><sect2><title>
8102 #: ../en/ch06-collab.xml:343
8103 msgid "The Linux kernel model"
8104 msgstr "Linux 内核模型"
8106 #. type: Content of: <book><chapter><sect1><sect2><para>
8107 #: ../en/ch06-collab.xml:345
8108 msgid ""
8109 "The development of the Linux kernel has a shallow hierarchical structure, "
8110 "surrounded by a cloud of apparent chaos. Because most Linux developers use "
8111 "<command>git</command>, a distributed revision control tool with capabilities "
8112 "similar to Mercurial, it's useful to describe the way work flows in that "
8113 "environment; if you like the ideas, the approach translates well across tools."
8114 msgstr ""
8116 #. type: Content of: <book><chapter><sect1><sect2><para>
8117 #: ../en/ch06-collab.xml:353
8118 msgid ""
8119 "At the center of the community sits Linus Torvalds, the creator of Linux. He "
8120 "publishes a single source repository that is considered the "
8121 "<quote>authoritative</quote> current tree by the entire developer community. "
8122 "Anyone can clone Linus's tree, but he is very choosy about whose trees he "
8123 "pulls from."
8124 msgstr ""
8126 #. type: Content of: <book><chapter><sect1><sect2><para>
8127 #: ../en/ch06-collab.xml:360
8128 msgid ""
8129 "Linus has a number of <quote>trusted lieutenants</quote>. As a general rule, "
8130 "he pulls whatever changes they publish, in most cases without even reviewing "
8131 "those changes. Some of those lieutenants are generally agreed to be "
8132 "<quote>maintainers</quote>, responsible for specific subsystems within the "
8133 "kernel. If a random kernel hacker wants to make a change to a subsystem that "
8134 "they want to end up in Linus's tree, they must find out who the subsystem's "
8135 "maintainer is, and ask that maintainer to take their change. If the "
8136 "maintainer reviews their changes and agrees to take them, they'll pass them "
8137 "along to Linus in due course."
8138 msgstr ""
8140 #. type: Content of: <book><chapter><sect1><sect2><para>
8141 #: ../en/ch06-collab.xml:372
8142 msgid ""
8143 "Individual lieutenants have their own approaches to reviewing, accepting, and "
8144 "publishing changes; and for deciding when to feed them to Linus. In "
8145 "addition, there are several well known branches that people use for different "
8146 "purposes. For example, a few people maintain <quote>stable</quote> "
8147 "repositories of older versions of the kernel, to which they apply critical "
8148 "fixes as needed. Some maintainers publish multiple trees: one for "
8149 "experimental changes; one for changes that they are about to feed upstream; "
8150 "and so on. Others just publish a single tree."
8151 msgstr ""
8153 #. type: Content of: <book><chapter><sect1><sect2><para>
8154 #: ../en/ch06-collab.xml:383
8155 msgid ""
8156 "This model has two notable features. The first is that it's <quote>pull "
8157 "only</quote>. You have to ask, convince, or beg another developer to take a "
8158 "change from you, because there are almost no trees to which more than one "
8159 "person can push, and there's no way to push changes into a tree that someone "
8160 "else controls."
8161 msgstr ""
8163 #. type: Content of: <book><chapter><sect1><sect2><para>
8164 #: ../en/ch06-collab.xml:390
8165 msgid ""
8166 "The second is that it's based on reputation and acclaim. If you're an "
8167 "unknown, Linus will probably ignore changes from you without even "
8168 "responding. But a subsystem maintainer will probably review them, and will "
8169 "likely take them if they pass their criteria for suitability. The more "
8170 "<quote>good</quote> changes you contribute to a maintainer, the more likely "
8171 "they are to trust your judgment and accept your changes. If you're well-"
8172 "known and maintain a long-lived branch for something Linus hasn't yet "
8173 "accepted, people with similar interests may pull your changes regularly to "
8174 "keep up with your work."
8175 msgstr ""
8177 #. type: Content of: <book><chapter><sect1><sect2><para>
8178 #: ../en/ch06-collab.xml:401
8179 msgid ""
8180 "Reputation and acclaim don't necessarily cross subsystem or <quote>people</"
8181 "quote> boundaries. If you're a respected but specialised storage hacker, and "
8182 "you try to fix a networking bug, that change will receive a level of scrutiny "
8183 "from a network maintainer comparable to a change from a complete stranger."
8184 msgstr ""
8186 #. type: Content of: <book><chapter><sect1><sect2><para>
8187 #: ../en/ch06-collab.xml:408
8188 msgid ""
8189 "To people who come from more orderly project backgrounds, the comparatively "
8190 "chaotic Linux kernel development process often seems completely insane. It's "
8191 "subject to the whims of individuals; people make sweeping changes whenever "
8192 "they deem it appropriate; and the pace of development is astounding. And yet "
8193 "Linux is a highly successful, well-regarded piece of software."
8194 msgstr ""
8196 #. type: Content of: <book><chapter><sect1><sect2><title>
8197 #: ../en/ch06-collab.xml:418
8198 msgid "Pull-only versus shared-push collaboration"
8199 msgstr "只读与共享写协作"
8201 #. type: Content of: <book><chapter><sect1><sect2><para>
8202 #: ../en/ch06-collab.xml:420
8203 msgid ""
8204 "A perpetual source of heat in the open source community is whether a "
8205 "development model in which people only ever pull changes from others is "
8206 "<quote>better than</quote> one in which multiple people can push changes to a "
8207 "shared repository."
8208 msgstr ""
8210 #. type: Content of: <book><chapter><sect1><sect2><para>
8211 #: ../en/ch06-collab.xml:426
8212 msgid ""
8213 "Typically, the backers of the shared-push model use tools that actively "
8214 "enforce this approach. If you're using a centralised revision control tool "
8215 "such as Subversion, there's no way to make a choice over which model you'll "
8216 "use: the tool gives you shared-push, and if you want to do anything else, "
8217 "you'll have to roll your own approach on top (such as applying a patch by "
8218 "hand)."
8219 msgstr ""
8221 #. type: Content of: <book><chapter><sect1><sect2><para>
8222 #: ../en/ch06-collab.xml:434
8223 msgid ""
8224 "A good distributed revision control tool will support both models. You and "
8225 "your collaborators can then structure how you work together based on your own "
8226 "needs and preferences, not on what contortions your tools force you into."
8227 msgstr ""
8229 #. type: Content of: <book><chapter><sect1><sect2><title>
8230 #: ../en/ch06-collab.xml:441
8231 msgid "Where collaboration meets branch management"
8232 msgstr "协作与分支管理"
8234 #. type: Content of: <book><chapter><sect1><sect2><para>
8235 #: ../en/ch06-collab.xml:443
8236 msgid ""
8237 "Once you and your team set up some shared repositories and start propagating "
8238 "changes back and forth between local and shared repos, you begin to face a "
8239 "related, but slightly different challenge: that of managing the multiple "
8240 "directions in which your team may be moving at once. Even though this "
8241 "subject is intimately related to how your team collaborates, it's dense "
8242 "enough to merit treatment of its own, in <xref linkend=\"chap:branch\"/>."
8243 msgstr ""
8245 #. type: Content of: <book><chapter><sect1><title>
8246 #: ../en/ch06-collab.xml:455
8247 msgid "The technical side of sharing"
8248 msgstr "共享的技术因素"
8250 #. type: Content of: <book><chapter><sect1><para>
8251 #: ../en/ch06-collab.xml:457
8252 msgid ""
8253 "The remainder of this chapter is devoted to the question of sharing changes "
8254 "with your collaborators."
8255 msgstr ""
8257 #. type: Content of: <book><chapter><sect1><title>
8258 #: ../en/ch06-collab.xml:462
8259 msgid "Informal sharing with <command role=\"hg-cmd\">hg serve</command>"
8260 msgstr "使用 <command role=\"hg-cmd\">hg serve</command> 进行非正式共享"
8262 #. type: Content of: <book><chapter><sect1><para>
8263 #: ../en/ch06-collab.xml:465
8264 msgid ""
8265 "Mercurial's <command role=\"hg-cmd\">hg serve</command> command is "
8266 "wonderfully suited to small, tight-knit, and fast-paced group environments. "
8267 "It also provides a great way to get a feel for using Mercurial commands over "
8268 "a network."
8269 msgstr ""
8271 #. type: Content of: <book><chapter><sect1><para>
8272 #: ../en/ch06-collab.xml:470
8273 msgid ""
8274 "Run <command role=\"hg-cmd\">hg serve</command> inside a repository, and in "
8275 "under a second it will bring up a specialised HTTP server; this will accept "
8276 "connections from any client, and serve up data for that repository until you "
8277 "terminate it. Anyone who knows the URL of the server you just started, and "
8278 "can talk to your computer over the network, can then use a web browser or "
8279 "Mercurial to read data from that repository. A URL for a <command role=\"hg-"
8280 "cmd\">hg serve</command> instance running on a laptop is likely to look "
8281 "something like <literal>http://my-laptop.local:8000/</literal>."
8282 msgstr ""
8284 #. type: Content of: <book><chapter><sect1><para>
8285 #: ../en/ch06-collab.xml:481
8286 msgid ""
8287 "The <command role=\"hg-cmd\">hg serve</command> command is <emphasis>not</"
8288 "emphasis> a general-purpose web server. It can do only two things:"
8289 msgstr ""
8291 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8292 #: ../en/ch06-collab.xml:485
8293 msgid ""
8294 "Allow people to browse the history of the repository it's serving, from their "
8295 "normal web browsers."
8296 msgstr ""
8298 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8299 #: ../en/ch06-collab.xml:489
8300 msgid ""
8301 "Speak Mercurial's wire protocol, so that people can <command role=\"hg-cmd"
8302 "\">hg clone</command> or <command role=\"hg-cmd\">hg pull</command> changes "
8303 "from that repository."
8304 msgstr ""
8306 #. type: Content of: <book><chapter><sect1><para>
8307 #: ../en/ch06-collab.xml:494
8308 msgid ""
8309 "In particular, <command role=\"hg-cmd\">hg serve</command> won't allow remote "
8310 "users to <emphasis>modify</emphasis> your repository. It's intended for read-"
8311 "only use."
8312 msgstr ""
8314 #. type: Content of: <book><chapter><sect1><para>
8315 #: ../en/ch06-collab.xml:498
8316 msgid ""
8317 "If you're getting started with Mercurial, there's nothing to prevent you from "
8318 "using <command role=\"hg-cmd\">hg serve</command> to serve up a repository on "
8319 "your own computer, then use commands like <command role=\"hg-cmd\">hg clone</"
8320 "command>, <command role=\"hg-cmd\">hg incoming</command>, and so on to talk "
8321 "to that server as if the repository was hosted remotely. This can help you to "
8322 "quickly get acquainted with using commands on network-hosted repositories."
8323 msgstr ""
8325 #. type: Content of: <book><chapter><sect1><sect2><title>
8326 #: ../en/ch06-collab.xml:508
8327 msgid "A few things to keep in mind"
8328 msgstr "要牢记的几件事"
8330 #. type: Content of: <book><chapter><sect1><sect2><para>
8331 #: ../en/ch06-collab.xml:510
8332 msgid ""
8333 "Because it provides unauthenticated read access to all clients, you should "
8334 "only use <command role=\"hg-cmd\">hg serve</command> in an environment where "
8335 "you either don't care, or have complete control over, who can access your "
8336 "network and pull data from your repository."
8337 msgstr ""
8339 #. type: Content of: <book><chapter><sect1><sect2><para>
8340 #: ../en/ch06-collab.xml:516
8341 msgid ""
8342 "The <command role=\"hg-cmd\">hg serve</command> command knows nothing about "
8343 "any firewall software you might have installed on your system or network. It "
8344 "cannot detect or control your firewall software. If other people are unable "
8345 "to talk to a running <command role=\"hg-cmd\">hg serve</command> instance, "
8346 "the second thing you should do (<emphasis>after</emphasis> you make sure that "
8347 "they're using the correct URL) is check your firewall configuration."
8348 msgstr ""
8350 #. type: Content of: <book><chapter><sect1><sect2><para>
8351 #: ../en/ch06-collab.xml:525
8352 msgid ""
8353 "By default, <command role=\"hg-cmd\">hg serve</command> listens for incoming "
8354 "connections on port 8000. If another process is already listening on the "
8355 "port you want to use, you can specify a different port to listen on using the "
8356 "<option role=\"hg-opt-serve\">-p</option> option."
8357 msgstr ""
8359 #. type: Content of: <book><chapter><sect1><sect2><para>
8360 #: ../en/ch06-collab.xml:531
8361 msgid ""
8362 "Normally, when <command role=\"hg-cmd\">hg serve</command> starts, it prints "
8363 "no output, which can be a bit unnerving. If you'd like to confirm that it is "
8364 "indeed running correctly, and find out what URL you should send to your "
8365 "collaborators, start it with the <option role=\"hg-opt-global\">-v</option> "
8366 "option."
8367 msgstr ""
8369 #. type: Content of: <book><chapter><sect1><title>
8370 #: ../en/ch06-collab.xml:541
8371 msgid "Using the Secure Shell (ssh) protocol"
8372 msgstr "使用 ssh 协议"
8374 #. type: Content of: <book><chapter><sect1><para>
8375 #: ../en/ch06-collab.xml:543
8376 msgid ""
8377 "You can pull and push changes securely over a network connection using the "
8378 "Secure Shell (<literal>ssh</literal>) protocol. To use this successfully, "
8379 "you may have to do a little bit of configuration on the client or server "
8380 "sides."
8381 msgstr ""
8383 #. type: Content of: <book><chapter><sect1><para>
8384 #: ../en/ch06-collab.xml:548
8385 msgid ""
8386 "If you're not familiar with ssh, it's the name of both a command and a "
8387 "network protocol that let you securely communicate with another computer. To "
8388 "use it with Mercurial, you'll be setting up one or more user accounts on a "
8389 "server so that remote users can log in and execute commands."
8390 msgstr ""
8392 #. type: Content of: <book><chapter><sect1><para>
8393 #: ../en/ch06-collab.xml:554
8394 msgid ""
8395 "(If you <emphasis>are</emphasis> familiar with ssh, you'll probably find some "
8396 "of the material that follows to be elementary in nature.)"
8397 msgstr ""
8399 #. type: Content of: <book><chapter><sect1><sect2><title>
8400 #: ../en/ch06-collab.xml:559
8401 msgid "How to read and write ssh URLs"
8402 msgstr "如何读写 ssh 路径"
8404 #. type: Content of: <book><chapter><sect1><sect2><para>
8405 #: ../en/ch06-collab.xml:561
8406 msgid "An ssh URL tends to look like this:"
8407 msgstr ""
8409 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
8410 #: ../en/ch06-collab.xml:564
8411 msgid ""
8412 "The <quote><literal>ssh://</literal></quote> part tells Mercurial to use the "
8413 "ssh protocol."
8414 msgstr ""
8416 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
8417 #: ../en/ch06-collab.xml:567
8418 msgid ""
8419 "The <quote><literal>bos@</literal></quote> component indicates what username "
8420 "to log into the server as. You can leave this out if the remote username is "
8421 "the same as your local username."
8422 msgstr ""
8424 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
8425 #: ../en/ch06-collab.xml:572
8426 msgid ""
8427 "The <quote><literal>hg.serpentine.com</literal></quote> gives the hostname of "
8428 "the server to log into."
8429 msgstr ""
8431 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
8432 #: ../en/ch06-collab.xml:576
8433 msgid ""
8434 "The <quote>:22</quote> identifies the port number to connect to the server "
8435 "on. The default port is 22, so you only need to specify a colon and port "
8436 "number if you're <emphasis>not</emphasis> using port 22."
8437 msgstr ""
8439 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
8440 #: ../en/ch06-collab.xml:581
8441 msgid ""
8442 "The remainder of the URL is the local path to the repository on the server."
8443 msgstr ""
8445 #. type: Content of: <book><chapter><sect1><sect2><para>
8446 #: ../en/ch06-collab.xml:585
8447 msgid ""
8448 "There's plenty of scope for confusion with the path component of ssh URLs, as "
8449 "there is no standard way for tools to interpret it. Some programs behave "
8450 "differently than others when dealing with these paths. This isn't an ideal "
8451 "situation, but it's unlikely to change. Please read the following paragraphs "
8452 "carefully."
8453 msgstr ""
8455 #. type: Content of: <book><chapter><sect1><sect2><para>
8456 #: ../en/ch06-collab.xml:592
8457 msgid ""
8458 "Mercurial treats the path to a repository on the server as relative to the "
8459 "remote user's home directory. For example, if user <literal>foo</literal> on "
8460 "the server has a home directory of <filename class=\"directory\">/home/foo</"
8461 "filename>, then an ssh URL that contains a path component of <filename class="
8462 "\"directory\">bar</filename> <emphasis>really</emphasis> refers to the "
8463 "directory <filename class=\"directory\">/home/foo/bar</filename>."
8464 msgstr ""
8466 #. type: Content of: <book><chapter><sect1><sect2><para>
8467 #: ../en/ch06-collab.xml:601
8468 msgid ""
8469 "If you want to specify a path relative to another user's home directory, you "
8470 "can use a path that starts with a tilde character followed by the user's name "
8471 "(let's call them <literal>otheruser</literal>), like this."
8472 msgstr ""
8474 #. type: Content of: <book><chapter><sect1><sect2><para>
8475 #: ../en/ch06-collab.xml:607
8476 msgid ""
8477 "And if you really want to specify an <emphasis>absolute</emphasis> path on "
8478 "the server, begin the path component with two slashes, as in this example."
8479 msgstr ""
8481 #. type: Content of: <book><chapter><sect1><sect2><title>
8482 #: ../en/ch06-collab.xml:614
8483 msgid "Finding an ssh client for your system"
8484 msgstr "为你的系统寻找 ssh 客户端"
8486 #. type: Content of: <book><chapter><sect1><sect2><para>
8487 #: ../en/ch06-collab.xml:616
8488 msgid ""
8489 "Almost every Unix-like system comes with OpenSSH preinstalled. If you're "
8490 "using such a system, run <literal>which ssh</literal> to find out if the "
8491 "<command>ssh</command> command is installed (it's usually in <filename class="
8492 "\"directory\">/usr/bin</filename>). In the unlikely event that it isn't "
8493 "present, take a look at your system documentation to figure out how to "
8494 "install it."
8495 msgstr ""
8497 #. type: Content of: <book><chapter><sect1><sect2><para>
8498 #: ../en/ch06-collab.xml:624
8499 msgid ""
8500 "On Windows, the TortoiseHg package is bundled with a version of Simon "
8501 "Tatham's excellent <command>plink</command> command, and you should not need "
8502 "to do any further configuration."
8503 msgstr ""
8505 #. type: Content of: <book><chapter><sect1><sect2><title>
8506 #: ../en/ch06-collab.xml:631
8507 msgid "Generating a key pair"
8508 msgstr "产生密钥对"
8510 #. type: Content of: <book><chapter><sect1><sect2><para>
8511 #: ../en/ch06-collab.xml:633
8512 msgid ""
8513 "To avoid the need to repetitively type a password every time you need to use "
8514 "your ssh client, I recommend generating a key pair."
8515 msgstr ""
8517 #. type: Content of: <book><chapter><sect1><sect2><tip><title>
8518 #: ../en/ch06-collab.xml:638
8519 msgid "Key pairs are not mandatory"
8520 msgstr ""
8522 #. type: Content of: <book><chapter><sect1><sect2><tip><para>
8523 #: ../en/ch06-collab.xml:640
8524 msgid ""
8525 "Mercurial knows nothing about ssh authentication or key pairs. You can, if "
8526 "you like, safely ignore this section and the one that follows until you grow "
8527 "tired of repeatedly typing ssh passwords."
8528 msgstr ""
8530 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8531 #: ../en/ch06-collab.xml:648
8532 msgid ""
8533 "On a Unix-like system, the <command>ssh-keygen</command> command will do the "
8534 "trick."
8535 msgstr ""
8537 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8538 #: ../en/ch06-collab.xml:651
8539 msgid ""
8540 "On Windows, if you're using TortoiseHg, you may need to download a command "
8541 "named <command>puttygen</command> from <ulink url=\"http://www.chiark."
8542 "greenend.org.uk/~sgtatham/putty\">the PuTTY web site</ulink> to generate a "
8543 "key pair. See <ulink url=\"http://the.earth.li/~sgtatham/putty/0.60/htmldoc/"
8544 "Chapter8.html#pubkey-puttygen\">the <command>puttygen</command> "
8545 "documentation</ulink> for details of how use the command."
8546 msgstr ""
8548 #. type: Content of: <book><chapter><sect1><sect2><para>
8549 #: ../en/ch06-collab.xml:663
8550 msgid ""
8551 "When you generate a key pair, it's usually <emphasis>highly</emphasis> "
8552 "advisable to protect it with a passphrase. (The only time that you might not "
8553 "want to do this is when you're using the ssh protocol for automated tasks on "
8554 "a secure network.)"
8555 msgstr ""
8557 #. type: Content of: <book><chapter><sect1><sect2><para>
8558 #: ../en/ch06-collab.xml:669
8559 msgid ""
8560 "Simply generating a key pair isn't enough, however. You'll need to add the "
8561 "public key to the set of authorised keys for whatever user you're logging in "
8562 "remotely as. For servers using OpenSSH (the vast majority), this will mean "
8563 "adding the public key to a list in a file called <filename role=\"special"
8564 "\">authorized_keys</filename> in their <filename role=\"special\" class="
8565 "\"directory\">.ssh</filename> directory."
8566 msgstr ""
8568 #. type: Content of: <book><chapter><sect1><sect2><para>
8569 #: ../en/ch06-collab.xml:678
8570 msgid ""
8571 "On a Unix-like system, your public key will have a <filename>.pub</filename> "
8572 "extension. If you're using <command>puttygen</command> on Windows, you can "
8573 "save the public key to a file of your choosing, or paste it from the window "
8574 "it's displayed in straight into the <filename role=\"special"
8575 "\">authorized_keys</filename> file."
8576 msgstr ""
8578 #. type: Content of: <book><chapter><sect1><sect2><title>
8579 #: ../en/ch06-collab.xml:686
8580 msgid "Using an authentication agent"
8581 msgstr "使用认证代理"
8583 #. type: Content of: <book><chapter><sect1><sect2><para>
8584 #: ../en/ch06-collab.xml:688
8585 msgid ""
8586 "An authentication agent is a daemon that stores passphrases in memory (so it "
8587 "will forget passphrases if you log out and log back in again). An ssh client "
8588 "will notice if it's running, and query it for a passphrase. If there's no "
8589 "authentication agent running, or the agent doesn't store the necessary "
8590 "passphrase, you'll have to type your passphrase every time Mercurial tries to "
8591 "communicate with a server on your behalf (e.g. whenever you pull or push "
8592 "changes)."
8593 msgstr ""
8595 #. type: Content of: <book><chapter><sect1><sect2><para>
8596 #: ../en/ch06-collab.xml:697
8597 msgid ""
8598 "The downside of storing passphrases in an agent is that it's possible for a "
8599 "well-prepared attacker to recover the plain text of your passphrases, in some "
8600 "cases even if your system has been power-cycled. You should make your own "
8601 "judgment as to whether this is an acceptable risk. It certainly saves a lot "
8602 "of repeated typing."
8603 msgstr ""
8605 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8606 #: ../en/ch06-collab.xml:706
8607 msgid ""
8608 "On Unix-like systems, the agent is called <command>ssh-agent</command>, and "
8609 "it's often run automatically for you when you log in. You'll need to use the "
8610 "<command>ssh-add</command> command to add passphrases to the agent's store."
8611 msgstr ""
8613 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8614 #: ../en/ch06-collab.xml:713
8615 msgid ""
8616 "On Windows, if you're using TortoiseHg, the <command>pageant</command> "
8617 "command acts as the agent. As with <command>puttygen</command>, you'll need "
8618 "to <ulink url=\"http://www.chiark.greenend.org.uk/%7Esgtatham/putty/download."
8619 "html\">download <command>pageant</command></ulink> from the PuTTY web site "
8620 "and read <ulink url=\"http://the.earth.li/~sgtatham/putty/0.60/htmldoc/"
8621 "Chapter9.html#pageant\">its documentation</ulink>. The <command>pageant</"
8622 "command> command adds an icon to your system tray that will let you manage "
8623 "stored passphrases."
8624 msgstr ""
8626 #. type: Content of: <book><chapter><sect1><sect2><title>
8627 #: ../en/ch06-collab.xml:728
8628 msgid "Configuring the server side properly"
8629 msgstr "正确配置服务器端"
8631 #. type: Content of: <book><chapter><sect1><sect2><para>
8632 #: ../en/ch06-collab.xml:730
8633 msgid ""
8634 "Because ssh can be fiddly to set up if you're new to it, a variety of things "
8635 "can go wrong. Add Mercurial on top, and there's plenty more scope for head-"
8636 "scratching. Most of these potential problems occur on the server side, not "
8637 "the client side. The good news is that once you've gotten a configuration "
8638 "working, it will usually continue to work indefinitely."
8639 msgstr ""
8641 #. type: Content of: <book><chapter><sect1><sect2><para>
8642 #: ../en/ch06-collab.xml:738
8643 msgid ""
8644 "Before you try using Mercurial to talk to an ssh server, it's best to make "
8645 "sure that you can use the normal <command>ssh</command> or <command>putty</"
8646 "command> command to talk to the server first. If you run into problems with "
8647 "using these commands directly, Mercurial surely won't work. Worse, it will "
8648 "obscure the underlying problem. Any time you want to debug ssh-related "
8649 "Mercurial problems, you should drop back to making sure that plain ssh client "
8650 "commands work first, <emphasis>before</emphasis> you worry about whether "
8651 "there's a problem with Mercurial."
8652 msgstr ""
8654 #. type: Content of: <book><chapter><sect1><sect2><para>
8655 #: ../en/ch06-collab.xml:749
8656 msgid ""
8657 "The first thing to be sure of on the server side is that you can actually log "
8658 "in from another machine at all. If you can't use <command>ssh</command> or "
8659 "<command>putty</command> to log in, the error message you get may give you a "
8660 "few hints as to what's wrong. The most common problems are as follows."
8661 msgstr ""
8663 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8664 #: ../en/ch06-collab.xml:756
8665 msgid ""
8666 "If you get a <quote>connection refused</quote> error, either there isn't an "
8667 "SSH daemon running on the server at all, or it's inaccessible due to firewall "
8668 "configuration."
8669 msgstr ""
8671 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8672 #: ../en/ch06-collab.xml:761
8673 msgid ""
8674 "If you get a <quote>no route to host</quote> error, you either have an "
8675 "incorrect address for the server or a seriously locked down firewall that "
8676 "won't admit its existence at all."
8677 msgstr ""
8679 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8680 #: ../en/ch06-collab.xml:766
8681 msgid ""
8682 "If you get a <quote>permission denied</quote> error, you may have mistyped "
8683 "the username on the server, or you could have mistyped your key's passphrase "
8684 "or the remote user's password."
8685 msgstr ""
8687 #. type: Content of: <book><chapter><sect1><sect2><para>
8688 #: ../en/ch06-collab.xml:771
8689 msgid ""
8690 "In summary, if you're having trouble talking to the server's ssh daemon, "
8691 "first make sure that one is running at all. On many systems it will be "
8692 "installed, but disabled, by default. Once you're done with this step, you "
8693 "should then check that the server's firewall is configured to allow incoming "
8694 "connections on the port the ssh daemon is listening on (usually 22). Don't "
8695 "worry about more exotic possibilities for misconfiguration until you've "
8696 "checked these two first."
8697 msgstr ""
8699 #. type: Content of: <book><chapter><sect1><sect2><para>
8700 #: ../en/ch06-collab.xml:781
8701 msgid ""
8702 "If you're using an authentication agent on the client side to store "
8703 "passphrases for your keys, you ought to be able to log into the server "
8704 "without being prompted for a passphrase or a password. If you're prompted "
8705 "for a passphrase, there are a few possible culprits."
8706 msgstr ""
8708 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8709 #: ../en/ch06-collab.xml:787
8710 msgid ""
8711 "You might have forgotten to use <command>ssh-add</command> or "
8712 "<command>pageant</command> to store the passphrase."
8713 msgstr ""
8715 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8716 #: ../en/ch06-collab.xml:791
8717 msgid "You might have stored the passphrase for the wrong key."
8718 msgstr ""
8720 #. type: Content of: <book><chapter><sect1><sect2><para>
8721 #: ../en/ch06-collab.xml:794
8722 msgid ""
8723 "If you're being prompted for the remote user's password, there are another "
8724 "few possible problems to check."
8725 msgstr ""
8727 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8728 #: ../en/ch06-collab.xml:797
8729 msgid ""
8730 "Either the user's home directory or their <filename role=\"special\" class="
8731 "\"directory\">.ssh</filename> directory might have excessively liberal "
8732 "permissions. As a result, the ssh daemon will not trust or read their "
8733 "<filename role=\"special\">authorized_keys</filename> file. For example, a "
8734 "group-writable home or <filename role=\"special\" class=\"directory\">.ssh</"
8735 "filename> directory will often cause this symptom."
8736 msgstr ""
8738 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8739 #: ../en/ch06-collab.xml:806
8740 msgid ""
8741 "The user's <filename role=\"special\">authorized_keys</filename> file may "
8742 "have a problem. If anyone other than the user owns or can write to that file, "
8743 "the ssh daemon will not trust or read it."
8744 msgstr ""
8746 #. type: Content of: <book><chapter><sect1><sect2><para>
8747 #: ../en/ch06-collab.xml:813
8748 msgid ""
8749 "In the ideal world, you should be able to run the following command "
8750 "successfully, and it should print exactly one line of output, the current "
8751 "date and time."
8752 msgstr ""
8754 #. type: Content of: <book><chapter><sect1><sect2><para>
8755 #: ../en/ch06-collab.xml:818
8756 msgid ""
8757 "If, on your server, you have login scripts that print banners or other junk "
8758 "even when running non-interactive commands like this, you should fix them "
8759 "before you continue, so that they only print output if they're run "
8760 "interactively. Otherwise these banners will at least clutter up Mercurial's "
8761 "output. Worse, they could potentially cause problems with running Mercurial "
8762 "commands remotely. Mercurial tries to detect and ignore banners in non-"
8763 "interactive <command>ssh</command> sessions, but it is not foolproof. (If "
8764 "you're editing your login scripts on your server, the usual way to see if a "
8765 "login script is running in an interactive shell is to check the return code "
8766 "from the command <literal>tty -s</literal>.)"
8767 msgstr ""
8769 #. type: Content of: <book><chapter><sect1><sect2><para>
8770 #: ../en/ch06-collab.xml:832
8771 msgid ""
8772 "Once you've verified that plain old ssh is working with your server, the next "
8773 "step is to ensure that Mercurial runs on the server. The following command "
8774 "should run successfully:"
8775 msgstr ""
8777 #. type: Content of: <book><chapter><sect1><sect2><para>
8778 #: ../en/ch06-collab.xml:839
8779 msgid ""
8780 "If you see an error message instead of normal <command role=\"hg-cmd\">hg "
8781 "version</command> output, this is usually because you haven't installed "
8782 "Mercurial to <filename class=\"directory\">/usr/bin</filename>. Don't worry "
8783 "if this is the case; you don't need to do that. But you should check for a "
8784 "few possible problems."
8785 msgstr ""
8787 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8788 #: ../en/ch06-collab.xml:846
8789 msgid ""
8790 "Is Mercurial really installed on the server at all? I know this sounds "
8791 "trivial, but it's worth checking!"
8792 msgstr ""
8794 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8795 #: ../en/ch06-collab.xml:850
8796 msgid ""
8797 "Maybe your shell's search path (usually set via the <envar>PATH</envar> "
8798 "environment variable) is simply misconfigured."
8799 msgstr ""
8801 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8802 #: ../en/ch06-collab.xml:854
8803 msgid ""
8804 "Perhaps your <envar>PATH</envar> environment variable is only being set to "
8805 "point to the location of the <command>hg</command> executable if the login "
8806 "session is interactive. This can happen if you're setting the path in the "
8807 "wrong shell login script. See your shell's documentation for details."
8808 msgstr ""
8810 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8811 #: ../en/ch06-collab.xml:861
8812 msgid ""
8813 "The <envar>PYTHONPATH</envar> environment variable may need to contain the "
8814 "path to the Mercurial Python modules. It might not be set at all; it could "
8815 "be incorrect; or it may be set only if the login is interactive."
8816 msgstr ""
8818 #. type: Content of: <book><chapter><sect1><sect2><para>
8819 #: ../en/ch06-collab.xml:868
8820 msgid ""
8821 "If you can run <command role=\"hg-cmd\">hg version</command> over an ssh "
8822 "connection, well done! You've got the server and client sorted out. You "
8823 "should now be able to use Mercurial to access repositories hosted by that "
8824 "username on that server. If you run into problems with Mercurial and ssh at "
8825 "this point, try using the <option role=\"hg-opt-global\">--debug</option> "
8826 "option to get a clearer picture of what's going on."
8827 msgstr ""
8829 #. type: Content of: <book><chapter><sect1><sect2><title>
8830 #: ../en/ch06-collab.xml:877
8831 msgid "Using compression with ssh"
8832 msgstr "通过 ssh 使用压缩"
8834 #. type: Content of: <book><chapter><sect1><sect2><para>
8835 #: ../en/ch06-collab.xml:879
8836 msgid ""
8837 "Mercurial does not compress data when it uses the ssh protocol, because the "
8838 "ssh protocol can transparently compress data. However, the default behavior "
8839 "of ssh clients is <emphasis>not</emphasis> to request compression."
8840 msgstr ""
8842 #. type: Content of: <book><chapter><sect1><sect2><para>
8843 #: ../en/ch06-collab.xml:884
8844 msgid ""
8845 "Over any network other than a fast LAN (even a wireless network), using "
8846 "compression is likely to significantly speed up Mercurial's network "
8847 "operations. For example, over a WAN, someone measured compression as "
8848 "reducing the amount of time required to clone a particularly large repository "
8849 "from 51 minutes to 17 minutes."
8850 msgstr ""
8852 #. type: Content of: <book><chapter><sect1><sect2><para>
8853 #: ../en/ch06-collab.xml:891
8854 msgid ""
8855 "Both <command>ssh</command> and <command>plink</command> accept a <option "
8856 "role=\"cmd-opt-ssh\">-C</option> option which turns on compression. You can "
8857 "easily edit your <filename role=\"special\">~/.hgrc</filename> to enable "
8858 "compression for all of Mercurial's uses of the ssh protocol. Here is how to "
8859 "do so for regular <command>ssh</command> on Unix-like systems, for example."
8860 msgstr ""
8862 #. type: Content of: <book><chapter><sect1><sect2><para>
8863 #: ../en/ch06-collab.xml:901
8864 msgid ""
8865 "If you use <command>ssh</command> on a Unix-like system, you can configure it "
8866 "to always use compression when talking to your server. To do this, edit your "
8867 "<filename role=\"special\">.ssh/config</filename> file (which may not yet "
8868 "exist), as follows."
8869 msgstr ""
8871 #. type: Content of: <book><chapter><sect1><sect2><para>
8872 #: ../en/ch06-collab.xml:911
8873 msgid ""
8874 "This defines a hostname alias, <literal>hg</literal>. When you use that "
8875 "hostname on the <command>ssh</command> command line or in a Mercurial "
8876 "<literal>ssh</literal>-protocol URL, it will cause <command>ssh</command> to "
8877 "connect to <literal>hg.example.com</literal> and use compression. This gives "
8878 "you both a shorter name to type and compression, each of which is a good "
8879 "thing in its own right."
8880 msgstr ""
8882 #. type: Content of: <book><chapter><sect1><title>
8883 #: ../en/ch06-collab.xml:923
8884 msgid "Serving over HTTP using CGI"
8885 msgstr "使用 CGI 通过 HTTP 提供服务"
8887 #. type: Content of: <book><chapter><sect1><para>
8888 #: ../en/ch06-collab.xml:925
8889 msgid ""
8890 "The simplest way to host one or more repositories in a permanent way is to "
8891 "use a web server and Mercurial's CGI support."
8892 msgstr ""
8894 #. type: Content of: <book><chapter><sect1><para>
8895 #: ../en/ch06-collab.xml:929
8896 msgid ""
8897 "Depending on how ambitious you are, configuring Mercurial's CGI interface can "
8898 "take anything from a few moments to several hours."
8899 msgstr ""
8901 #. type: Content of: <book><chapter><sect1><para>
8902 #: ../en/ch06-collab.xml:933
8903 msgid ""
8904 "We'll begin with the simplest of examples, and work our way towards a more "
8905 "complex configuration. Even for the most basic case, you're almost certainly "
8906 "going to need to read and modify your web server's configuration."
8907 msgstr ""
8909 #. type: Content of: <book><chapter><sect1><note><title>
8910 #: ../en/ch06-collab.xml:939
8911 msgid "High pain tolerance required"
8912 msgstr ""
8914 #. type: Content of: <book><chapter><sect1><note><para>
8915 #: ../en/ch06-collab.xml:941
8916 msgid ""
8917 "Configuring a web server is a complex, fiddly, and highly system-dependent "
8918 "activity. I can't possibly give you instructions that will cover anything "
8919 "like all of the cases you will encounter. Please use your discretion and "
8920 "judgment in following the sections below. Be prepared to make plenty of "
8921 "mistakes, and to spend a lot of time reading your server's error logs."
8922 msgstr ""
8924 #. type: Content of: <book><chapter><sect1><note><para>
8925 #: ../en/ch06-collab.xml:949
8926 msgid ""
8927 "If you don't have a strong stomach for tweaking configurations over and over, "
8928 "or a compelling need to host your own services, you might want to try one of "
8929 "the public hosting services that I mentioned earlier."
8930 msgstr ""
8932 #. type: Content of: <book><chapter><sect1><sect2><title>
8933 #: ../en/ch06-collab.xml:956
8934 msgid "Web server configuration checklist"
8935 msgstr "Web 服务器配置检查表"
8937 #. type: Content of: <book><chapter><sect1><sect2><para>
8938 #: ../en/ch06-collab.xml:958
8939 msgid ""
8940 "Before you continue, do take a few moments to check a few aspects of your "
8941 "system's setup."
8942 msgstr ""
8944 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
8945 #: ../en/ch06-collab.xml:962
8946 msgid ""
8947 "Do you have a web server installed at all? Mac OS X and some Linux "
8948 "distributions ship with Apache, but many other systems may not have a web "
8949 "server installed."
8950 msgstr ""
8952 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
8953 #: ../en/ch06-collab.xml:967
8954 msgid ""
8955 "If you have a web server installed, is it actually running? On most systems, "
8956 "even if one is present, it will be disabled by default."
8957 msgstr ""
8959 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
8960 #: ../en/ch06-collab.xml:971
8961 msgid ""
8962 "Is your server configured to allow you to run CGI programs in the directory "
8963 "where you plan to do so? Most servers default to explicitly disabling the "
8964 "ability to run CGI programs."
8965 msgstr ""
8967 #. type: Content of: <book><chapter><sect1><sect2><para>
8968 #: ../en/ch06-collab.xml:977
8969 msgid ""
8970 "If you don't have a web server installed, and don't have substantial "
8971 "experience configuring Apache, you should consider using the "
8972 "<literal>lighttpd</literal> web server instead of Apache. Apache has a well-"
8973 "deserved reputation for baroque and confusing configuration. While "
8974 "<literal>lighttpd</literal> is less capable in some ways than Apache, most of "
8975 "these capabilities are not relevant to serving Mercurial repositories. And "
8976 "<literal>lighttpd</literal> is undeniably <emphasis>much</emphasis> easier to "
8977 "get started with than Apache."
8978 msgstr ""
8980 #. type: Content of: <book><chapter><sect1><sect2><title>
8981 #: ../en/ch06-collab.xml:990
8982 msgid "Basic CGI configuration"
8983 msgstr "基本 CGI 配置"
8985 #. type: Content of: <book><chapter><sect1><sect2><para>
8986 #: ../en/ch06-collab.xml:992
8987 msgid ""
8988 "On Unix-like systems, it's common for users to have a subdirectory named "
8989 "something like <filename class=\"directory\">public_html</filename> in their "
8990 "home directory, from which they can serve up web pages. A file named "
8991 "<filename>foo</filename> in this directory will be accessible at a URL of the "
8992 "form <literal>http://www.example.com/username/foo</literal>."
8993 msgstr ""
8995 #. type: Content of: <book><chapter><sect1><sect2><para>
8996 #: ../en/ch06-collab.xml:1000
8997 msgid ""
8998 "To get started, find the <filename role=\"special\">hgweb.cgi</filename> "
8999 "script that should be present in your Mercurial installation. If you can't "
9000 "quickly find a local copy on your system, simply download one from the master "
9001 "Mercurial repository at <ulink url=\"http://www.selenic.com/repo/hg/raw-file/"
9002 "tip/hgweb.cgi\">http://www.selenic.com/repo/hg/raw-file/tip/hgweb.cgi</ulink>."
9003 msgstr ""
9005 #. type: Content of: <book><chapter><sect1><sect2><para>
9006 #: ../en/ch06-collab.xml:1007 ../en/ch06-collab.xml:1175
9007 msgid ""
9008 "You'll need to copy this script into your <filename class=\"directory"
9009 "\">public_html</filename> directory, and ensure that it's executable."
9010 msgstr ""
9012 #. type: Content of: <book><chapter><sect1><sect2><para>
9013 #: ../en/ch06-collab.xml:1012
9014 msgid ""
9015 "The <literal>755</literal> argument to <command>chmod</command> is a little "
9016 "more general than just making the script executable: it ensures that the "
9017 "script is executable by anyone, and that <quote>group</quote> and "
9018 "<quote>other</quote> write permissions are <emphasis>not</emphasis> set. If "
9019 "you were to leave those write permissions enabled, Apache's <literal>suexec</"
9020 "literal> subsystem would likely refuse to execute the script. In fact, "
9021 "<literal>suexec</literal> also insists that the <emphasis>directory</"
9022 "emphasis> in which the script resides must not be writable by others."
9023 msgstr ""
9025 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
9026 #: ../en/ch06-collab.xml:1026
9027 msgid "What could <emphasis>possibly</emphasis> go wrong?"
9028 msgstr "什么<emphasis>可能</emphasis>会出错?"
9030 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9031 #: ../en/ch06-collab.xml:1029
9032 msgid ""
9033 "Once you've copied the CGI script into place, go into a web browser, and try "
9034 "to open the URL <literal>http://myhostname/~myuser/hgweb.cgi</literal>, "
9035 "<emphasis>but</emphasis> brace yourself for instant failure. There's a high "
9036 "probability that trying to visit this URL will fail, and there are many "
9037 "possible reasons for this. In fact, you're likely to stumble over almost "
9038 "every one of the possible errors below, so please read carefully. The "
9039 "following are all of the problems I ran into on a system running Fedora 7, "
9040 "with a fresh installation of Apache, and a user account that I created "
9041 "specially to perform this exercise."
9042 msgstr ""
9044 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9045 #: ../en/ch06-collab.xml:1042
9046 msgid ""
9047 "Your web server may have per-user directories disabled. If you're using "
9048 "Apache, search your config file for a <literal>UserDir</literal> directive. "
9049 "If there's none present, per-user directories will be disabled. If one "
9050 "exists, but its value is <literal>disabled</literal>, then per-user "
9051 "directories will be disabled. Otherwise, the string after <literal>UserDir</"
9052 "literal> gives the name of the subdirectory that Apache will look in under "
9053 "your home directory, for example <filename class=\"directory\">public_html</"
9054 "filename>."
9055 msgstr ""
9057 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9058 #: ../en/ch06-collab.xml:1053
9059 msgid ""
9060 "Your file access permissions may be too restrictive. The web server must be "
9061 "able to traverse your home directory and directories under your <filename "
9062 "class=\"directory\">public_html</filename> directory, and read files under "
9063 "the latter too. Here's a quick recipe to help you to make your permissions "
9064 "more appropriate."
9065 msgstr ""
9067 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9068 #: ../en/ch06-collab.xml:1063
9069 msgid ""
9070 "The other possibility with permissions is that you might get a completely "
9071 "empty window when you try to load the script. In this case, it's likely that "
9072 "your access permissions are <emphasis>too permissive</emphasis>. Apache's "
9073 "<literal>suexec</literal> subsystem won't execute a script that's group- or "
9074 "world-writable, for example."
9075 msgstr ""
9077 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9078 #: ../en/ch06-collab.xml:1070
9079 msgid ""
9080 "Your web server may be configured to disallow execution of CGI programs in "
9081 "your per-user web directory. Here's Apache's default per-user configuration "
9082 "from my Fedora system."
9083 msgstr ""
9085 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9086 #: ../en/ch06-collab.xml:1077
9087 msgid ""
9088 "If you find a similar-looking <literal>Directory</literal> group in your "
9089 "Apache configuration, the directive to look at inside it is <literal>Options</"
9090 "literal>. Add <literal>ExecCGI</literal> to the end of this list if it's "
9091 "missing, and restart the web server."
9092 msgstr ""
9094 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9095 #: ../en/ch06-collab.xml:1084
9096 msgid ""
9097 "If you find that Apache serves you the text of the CGI script instead of "
9098 "executing it, you may need to either uncomment (if already present) or add a "
9099 "directive like this."
9100 msgstr ""
9102 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9103 #: ../en/ch06-collab.xml:1090
9104 msgid ""
9105 "The next possibility is that you might be served with a colourful Python "
9106 "backtrace claiming that it can't import a <literal>mercurial</literal>-"
9107 "related module. This is actually progress! The server is now capable of "
9108 "executing your CGI script. This error is only likely to occur if you're "
9109 "running a private installation of Mercurial, instead of a system-wide "
9110 "version. Remember that the web server runs the CGI program without any of "
9111 "the environment variables that you take for granted in an interactive "
9112 "session. If this error happens to you, edit your copy of <filename role="
9113 "\"special\">hgweb.cgi</filename> and follow the directions inside it to "
9114 "correctly set your <envar>PYTHONPATH</envar> environment variable."
9115 msgstr ""
9117 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9118 #: ../en/ch06-collab.xml:1104
9119 msgid ""
9120 "Finally, you are <emphasis>certain</emphasis> to be served with another "
9121 "colourful Python backtrace: this one will complain that it can't find "
9122 "<filename class=\"directory\">/path/to/repository</filename>. Edit your "
9123 "<filename role=\"special\">hgweb.cgi</filename> script and replace the "
9124 "<filename class=\"directory\">/path/to/repository</filename> string with the "
9125 "complete path to the repository you want to serve up."
9126 msgstr ""
9128 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9129 #: ../en/ch06-collab.xml:1114
9130 msgid ""
9131 "At this point, when you try to reload the page, you should be presented with "
9132 "a nice HTML view of your repository's history. Whew!"
9133 msgstr ""
9135 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
9136 #: ../en/ch06-collab.xml:1120
9137 msgid "Configuring lighttpd"
9138 msgstr "配置 lighttpd"
9140 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9141 #: ../en/ch06-collab.xml:1122
9142 msgid ""
9143 "To be exhaustive in my experiments, I tried configuring the increasingly "
9144 "popular <literal>lighttpd</literal> web server to serve the same repository "
9145 "as I described with Apache above. I had already overcome all of the problems "
9146 "I outlined with Apache, many of which are not server-specific. As a result, "
9147 "I was fairly sure that my file and directory permissions were good, and that "
9148 "my <filename role=\"special\">hgweb.cgi</filename> script was properly edited."
9149 msgstr ""
9151 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9152 #: ../en/ch06-collab.xml:1132
9153 msgid ""
9154 "Once I had Apache running, getting <literal>lighttpd</literal> to serve the "
9155 "repository was a snap (in other words, even if you're trying to use "
9156 "<literal>lighttpd</literal>, you should read the Apache section). I first "
9157 "had to edit the <literal>mod_access</literal> section of its config file to "
9158 "enable <literal>mod_cgi</literal> and <literal>mod_userdir</literal>, both of "
9159 "which were disabled by default on my system. I then added a few lines to the "
9160 "end of the config file, to configure these modules."
9161 msgstr ""
9163 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9164 #: ../en/ch06-collab.xml:1144
9165 msgid ""
9166 "With this done, <literal>lighttpd</literal> ran immediately for me. If I had "
9167 "configured <literal>lighttpd</literal> before Apache, I'd almost certainly "
9168 "have run into many of the same system-level configuration problems as I did "
9169 "with Apache. However, I found <literal>lighttpd</literal> to be noticeably "
9170 "easier to configure than Apache, even though I've used Apache for over a "
9171 "decade, and this was my first exposure to <literal>lighttpd</literal>."
9172 msgstr ""
9174 #. type: Content of: <book><chapter><sect1><sect2><title>
9175 #: ../en/ch06-collab.xml:1157
9176 msgid "Sharing multiple repositories with one CGI script"
9177 msgstr "使用一个 CGI 脚本共享多个版本库"
9179 #. type: Content of: <book><chapter><sect1><sect2><para>
9180 #: ../en/ch06-collab.xml:1159
9181 msgid ""
9182 "The <filename role=\"special\">hgweb.cgi</filename> script only lets you "
9183 "publish a single repository, which is an annoying restriction. If you want "
9184 "to publish more than one without wracking yourself with multiple copies of "
9185 "the same script, each with different names, a better choice is to use the "
9186 "<filename role=\"special\">hgwebdir.cgi</filename> script."
9187 msgstr ""
9189 #. type: Content of: <book><chapter><sect1><sect2><para>
9190 #: ../en/ch06-collab.xml:1167
9191 msgid ""
9192 "The procedure to configure <filename role=\"special\">hgwebdir.cgi</filename> "
9193 "is only a little more involved than for <filename role=\"special\">hgweb.cgi</"
9194 "filename>. First, you must obtain a copy of the script. If you don't have "
9195 "one handy, you can download a copy from the master Mercurial repository at "
9196 "<ulink url=\"http://www.selenic.com/repo/hg/raw-file/tip/hgwebdir.cgi"
9197 "\">http://www.selenic.com/repo/hg/raw-file/tip/hgwebdir.cgi</ulink>."
9198 msgstr ""
9200 #. type: Content of: <book><chapter><sect1><sect2><para>
9201 #: ../en/ch06-collab.xml:1182
9202 msgid ""
9203 "With basic configuration out of the way, try to visit <literal>http://"
9204 "myhostname/~myuser/hgwebdir.cgi</literal> in your\tbrowser. It should "
9205 "display an empty list of repositories. If you get a blank window or error "
9206 "message, try walking through the list of potential problems in <xref linkend="
9207 "\"sec:collab:wtf\"/>."
9208 msgstr ""
9210 #. type: Content of: <book><chapter><sect1><sect2><para>
9211 #: ../en/ch06-collab.xml:1190
9212 msgid ""
9213 "The <filename role=\"special\">hgwebdir.cgi</filename> script relies on an "
9214 "external configuration file. By default, it searches for a file named "
9215 "<filename role=\"special\">hgweb.config</filename> in the same directory as "
9216 "itself. You'll need to create this file, and make it world-readable. The "
9217 "format of the file is similar to a Windows <quote>ini</quote> file, as "
9218 "understood by Python's <literal>ConfigParser</literal> <citation>web:"
9219 "configparser</citation> module."
9220 msgstr ""
9222 #. type: Content of: <book><chapter><sect1><sect2><para>
9223 #: ../en/ch06-collab.xml:1200
9224 msgid ""
9225 "The easiest way to configure <filename role=\"special\">hgwebdir.cgi</"
9226 "filename> is with a section named <literal>collections</literal>. This will "
9227 "automatically publish <emphasis>every</emphasis> repository under the "
9228 "directories you name. The section should look like this:"
9229 msgstr ""
9231 #. type: Content of: <book><chapter><sect1><sect2><para>
9232 #: ../en/ch06-collab.xml:1208
9233 msgid ""
9234 "Mercurial interprets this by looking at the directory name on the "
9235 "<emphasis>right</emphasis> hand side of the <quote><literal>=</literal></"
9236 "quote> sign; finding repositories in that directory hierarchy; and using the "
9237 "text on the <emphasis>left</emphasis> to strip off matching text from the "
9238 "names it will actually list in the web interface. The remaining component of "
9239 "a path after this stripping has occurred is called a <quote>virtual path</"
9240 "quote>."
9241 msgstr ""
9243 #. type: Content of: <book><chapter><sect1><sect2><para>
9244 #: ../en/ch06-collab.xml:1217
9245 msgid ""
9246 "Given the example above, if we have a repository whose local path is "
9247 "<filename class=\"directory\">/my/root/this/repo</filename>, the CGI script "
9248 "will strip the leading <filename class=\"directory\">/my/root</filename> from "
9249 "the name, and publish the repository with a virtual path of <filename class="
9250 "\"directory\">this/repo</filename>. If the base URL for our CGI script is "
9251 "<literal>http://myhostname/~myuser/hgwebdir.cgi</literal>, the complete URL "
9252 "for that repository will be <literal>http://myhostname/~myuser/hgwebdir.cgi/"
9253 "this/repo</literal>."
9254 msgstr ""
9256 #. type: Content of: <book><chapter><sect1><sect2><para>
9257 #: ../en/ch06-collab.xml:1229
9258 msgid ""
9259 "If we replace <filename class=\"directory\">/my/root</filename> on the left "
9260 "hand side of this example with <filename class=\"directory\">/my</filename>, "
9261 "then <filename role=\"special\">hgwebdir.cgi</filename> will only strip off "
9262 "<filename class=\"directory\">/my</filename> from the repository name, and "
9263 "will give us a virtual path of <filename class=\"directory\">root/this/repo</"
9264 "filename> instead of <filename class=\"directory\">this/repo</filename>."
9265 msgstr ""
9267 #. type: Content of: <book><chapter><sect1><sect2><para>
9268 #: ../en/ch06-collab.xml:1239
9269 msgid ""
9270 "The <filename role=\"special\">hgwebdir.cgi</filename> script will "
9271 "recursively search each directory listed in the <literal>collections</"
9272 "literal> section of its configuration file, but it will <literal>not</"
9273 "literal> recurse into the repositories it finds."
9274 msgstr ""
9276 #. type: Content of: <book><chapter><sect1><sect2><para>
9277 #: ../en/ch06-collab.xml:1245
9278 msgid ""
9279 "The <literal>collections</literal> mechanism makes it easy to publish many "
9280 "repositories in a <quote>fire and forget</quote> manner. You only need to "
9281 "set up the CGI script and configuration file one time. Afterwards, you can "
9282 "publish or unpublish a repository at any time by simply moving it into, or "
9283 "out of, the directory hierarchy in which you've configured <filename role="
9284 "\"special\">hgwebdir.cgi</filename> to look."
9285 msgstr ""
9287 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
9288 #: ../en/ch06-collab.xml:1255
9289 msgid "Explicitly specifying which repositories to publish"
9290 msgstr "明确指出要发布的版本库"
9292 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9293 #: ../en/ch06-collab.xml:1258
9294 msgid ""
9295 "In addition to the <literal>collections</literal> mechanism, the <filename "
9296 "role=\"special\">hgwebdir.cgi</filename> script allows you to publish a "
9297 "specific list of repositories. To do so, create a <literal>paths</literal> "
9298 "section, with contents of the following form."
9299 msgstr ""
9301 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9302 #: ../en/ch06-collab.xml:1267
9303 msgid ""
9304 "In this case, the virtual path (the component that will appear in a URL) is "
9305 "on the left hand side of each definition, while the path to the repository is "
9306 "on the right. Notice that there does not need to be any relationship between "
9307 "the virtual path you choose and the location of a repository in your "
9308 "filesystem."
9309 msgstr ""
9311 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9312 #: ../en/ch06-collab.xml:1274
9313 msgid ""
9314 "If you wish, you can use both the <literal>collections</literal> and "
9315 "<literal>paths</literal> mechanisms simultaneously in a single configuration "
9316 "file."
9317 msgstr ""
9319 #. type: Content of: <book><chapter><sect1><sect2><sect3><note><title>
9320 #: ../en/ch06-collab.xml:1280
9321 msgid "Beware duplicate virtual paths"
9322 msgstr ""
9324 #. type: Content of: <book><chapter><sect1><sect2><sect3><note><para>
9325 #: ../en/ch06-collab.xml:1282
9326 msgid ""
9327 "If several repositories have the same virtual path, <filename role=\"special"
9328 "\">hgwebdir.cgi</filename> will not report an error. Instead, it will behave "
9329 "unpredictably."
9330 msgstr ""
9332 #. type: Content of: <book><chapter><sect1><sect2><title>
9333 #: ../en/ch06-collab.xml:1291
9334 msgid "Downloading source archives"
9335 msgstr "下载源代码档案包"
9337 #. type: Content of: <book><chapter><sect1><sect2><para>
9338 #: ../en/ch06-collab.xml:1293
9339 msgid ""
9340 "Mercurial's web interface lets users download an archive of any revision. "
9341 "This archive will contain a snapshot of the working directory as of that "
9342 "revision, but it will not contain a copy of the repository data."
9343 msgstr ""
9345 #. type: Content of: <book><chapter><sect1><sect2><para>
9346 #: ../en/ch06-collab.xml:1298
9347 msgid ""
9348 "By default, this feature is not enabled. To enable it, you'll need to add an "
9349 "<envar role=\"rc-item-web\">allow_archive</envar> item to the <literal role="
9350 "\"rc-web\">web</literal> section of your <filename role=\"special\">~/.hgrc</"
9351 "filename>; see below for details."
9352 msgstr ""
9354 #. type: Content of: <book><chapter><sect1><sect2><title>
9355 #: ../en/ch06-collab.xml:1305
9356 msgid "Web configuration options"
9357 msgstr "Web 配置选项"
9359 #. type: Content of: <book><chapter><sect1><sect2><para>
9360 #: ../en/ch06-collab.xml:1307
9361 msgid ""
9362 "Mercurial's web interfaces (the <command role=\"hg-cmd\">hg serve</command> "
9363 "command, and the <filename role=\"special\">hgweb.cgi</filename> and "
9364 "<filename role=\"special\">hgwebdir.cgi</filename> scripts) have a number of "
9365 "configuration options that you can set. These belong in a section named "
9366 "<literal role=\"rc-web\">web</literal>."
9367 msgstr ""
9369 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9370 #: ../en/ch06-collab.xml:1315
9371 msgid ""
9372 "<envar role=\"rc-item-web\">allow_archive</envar>: Determines which (if any) "
9373 "archive download mechanisms Mercurial supports. If you enable this feature, "
9374 "users of the web interface will be able to download an archive of whatever "
9375 "revision of a repository they are viewing. To enable the archive feature, "
9376 "this item must take the form of a sequence of words drawn from the list below."
9377 msgstr ""
9379 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
9380 #: ../en/ch06-collab.xml:1324
9381 msgid ""
9382 "<literal>bz2</literal>: A <command>tar</command> archive, compressed using "
9383 "<literal>bzip2</literal> compression. This has the best compression ratio, "
9384 "but uses the most CPU time on the server."
9385 msgstr ""
9387 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
9388 #: ../en/ch06-collab.xml:1330
9389 msgid ""
9390 "<literal>gz</literal>: A <command>tar</command> archive, compressed using "
9391 "<literal>gzip</literal> compression."
9392 msgstr ""
9394 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
9395 #: ../en/ch06-collab.xml:1334
9396 msgid ""
9397 "<literal>zip</literal>: A <command>zip</command> archive, compressed using "
9398 "LZW compression. This format has the worst compression ratio, but is widely "
9399 "used in the Windows world."
9400 msgstr ""
9402 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9403 #: ../en/ch06-collab.xml:1340
9404 msgid ""
9405 "If you provide an empty list, or don't have an <envar role=\"rc-item-web"
9406 "\">allow_archive</envar> entry at all, this feature will be disabled. Here "
9407 "is an example of how to enable all three supported formats."
9408 msgstr ""
9410 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9411 #: ../en/ch06-collab.xml:1347
9412 msgid ""
9413 "<envar role=\"rc-item-web\">allowpull</envar>: Boolean. Determines whether "
9414 "the web interface allows remote users to <command role=\"hg-cmd\">hg pull</"
9415 "command> and <command role=\"hg-cmd\">hg clone</command> this repository over "
9416 "HTTP. If set to <literal>no</literal> or <literal>false</literal>, only the "
9417 "<quote>human-oriented</quote> portion of the web interface is available."
9418 msgstr ""
9420 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9421 #: ../en/ch06-collab.xml:1356
9422 msgid ""
9423 "<envar role=\"rc-item-web\">contact</envar>: String. A free-form (but "
9424 "preferably brief) string identifying the person or group in charge of the "
9425 "repository. This often contains the name and email address of a person or "
9426 "mailing list. It often makes sense to place this entry in a repository's own "
9427 "<filename role=\"special\">.hg/hgrc</filename> file, but it can make sense to "
9428 "use in a global <filename role=\"special\">~/.hgrc</filename> if every "
9429 "repository has a single maintainer."
9430 msgstr ""
9432 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9433 #: ../en/ch06-collab.xml:1367
9434 msgid ""
9435 "<envar role=\"rc-item-web\">maxchanges</envar>: Integer. The default maximum "
9436 "number of changesets to display in a single page of output."
9437 msgstr ""
9439 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9440 #: ../en/ch06-collab.xml:1371
9441 msgid ""
9442 "<envar role=\"rc-item-web\">maxfiles</envar>: Integer. The default maximum "
9443 "number of modified files to display in a single page of output."
9444 msgstr ""
9446 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9447 #: ../en/ch06-collab.xml:1375
9448 msgid ""
9449 "<envar role=\"rc-item-web\">stripes</envar>: Integer. If the web interface "
9450 "displays alternating <quote>stripes</quote> to make it easier to visually "
9451 "align rows when you are looking at a table, this number controls the number "
9452 "of rows in each stripe."
9453 msgstr ""
9455 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9456 #: ../en/ch06-collab.xml:1381
9457 msgid ""
9458 "<envar role=\"rc-item-web\">style</envar>: Controls the template Mercurial "
9459 "uses to display the web interface. Mercurial ships with several web "
9460 "templates."
9461 msgstr ""
9463 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
9464 #: ../en/ch06-collab.xml:1387
9465 msgid "<literal>coal</literal> is monochromatic."
9466 msgstr ""
9468 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
9469 #: ../en/ch06-collab.xml:1390
9470 msgid ""
9471 "<literal>gitweb</literal> emulates the visual style of git's web interface."
9472 msgstr ""
9474 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
9475 #: ../en/ch06-collab.xml:1394
9476 msgid "<literal>monoblue</literal> uses solid blues and greys."
9477 msgstr ""
9479 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
9480 #: ../en/ch06-collab.xml:1398
9481 msgid "<literal>paper</literal> is the default."
9482 msgstr ""
9484 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
9485 #: ../en/ch06-collab.xml:1401
9486 msgid "<literal>spartan</literal> was the default for a long time."
9487 msgstr ""
9489 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9490 #: ../en/ch06-collab.xml:1405
9491 msgid ""
9492 "You can also specify a custom template of your own; see <xref linkend=\"chap:"
9493 "template\"/> for details. Here, you can see how to enable the "
9494 "<literal>gitweb</literal> style."
9495 msgstr ""
9497 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9498 #: ../en/ch06-collab.xml:1413
9499 msgid ""
9500 "<envar role=\"rc-item-web\">templates</envar>: Path. The directory in which "
9501 "to search for template files. By default, Mercurial searches in the "
9502 "directory in which it was installed."
9503 msgstr ""
9505 #. type: Content of: <book><chapter><sect1><sect2><para>
9506 #: ../en/ch06-collab.xml:1418
9507 msgid ""
9508 "If you are using <filename role=\"special\">hgwebdir.cgi</filename>, you can "
9509 "place a few configuration items in a <literal role=\"rc-web\">web</literal> "
9510 "section of the <filename role=\"special\">hgweb.config</filename> file "
9511 "instead of a <filename role=\"special\">~/.hgrc</filename> file, for "
9512 "convenience. These items are <envar role=\"rc-item-web\">motd</envar> and "
9513 "<envar role=\"rc-item-web\">style</envar>."
9514 msgstr ""
9516 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
9517 #: ../en/ch06-collab.xml:1429
9518 msgid "Options specific to an individual repository"
9519 msgstr "针对单个版本库的选项"
9521 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9522 #: ../en/ch06-collab.xml:1431
9523 msgid ""
9524 "A few <literal role=\"rc-web\">web</literal> configuration items ought to be "
9525 "placed in a repository's local <filename role=\"special\">.hg/hgrc</"
9526 "filename>, rather than a user's or global <filename role=\"special\">~/.hgrc</"
9527 "filename>."
9528 msgstr ""
9530 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
9531 #: ../en/ch06-collab.xml:1436
9532 msgid ""
9533 "<envar role=\"rc-item-web\">description</envar>: String. A free-form (but "
9534 "preferably brief) string that describes the contents or purpose of the "
9535 "repository."
9536 msgstr ""
9538 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
9539 #: ../en/ch06-collab.xml:1441
9540 msgid ""
9541 "<envar role=\"rc-item-web\">name</envar>: String. The name to use for the "
9542 "repository in the web interface. This overrides the default name, which is "
9543 "the last component of the repository's path."
9544 msgstr ""
9546 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
9547 #: ../en/ch06-collab.xml:1449
9548 msgid ""
9549 "Options specific to the <command role=\"hg-cmd\">hg serve</command> command"
9550 msgstr "命令 <command role=\"hg-cmd\">hg serve</command> 的选项"
9552 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9553 #: ../en/ch06-collab.xml:1452
9554 msgid ""
9555 "Some of the items in the <literal role=\"rc-web\">web</literal> section of a "
9556 "<filename role=\"special\">~/.hgrc</filename> file are only for use with the "
9557 "<command role=\"hg-cmd\">hg serve</command> command."
9558 msgstr ""
9560 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
9561 #: ../en/ch06-collab.xml:1458
9562 msgid ""
9563 "<envar role=\"rc-item-web\">accesslog</envar>: Path. The name of a file into "
9564 "which to write an access log. By default, the <command role=\"hg-cmd\">hg "
9565 "serve</command> command writes this information to standard output, not to a "
9566 "file. Log entries are written in the standard <quote>combined</quote> file "
9567 "format used by almost all web servers."
9568 msgstr ""
9570 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
9571 #: ../en/ch06-collab.xml:1466
9572 msgid ""
9573 "<envar role=\"rc-item-web\">address</envar>: String. The local address on "
9574 "which the server should listen for incoming connections. By default, the "
9575 "server listens on all addresses."
9576 msgstr ""
9578 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
9579 #: ../en/ch06-collab.xml:1471
9580 msgid ""
9581 "<envar role=\"rc-item-web\">errorlog</envar>: Path. The name of a file into "
9582 "which to write an error log. By default, the <command role=\"hg-cmd\">hg "
9583 "serve</command> command writes this information to standard error, not to a "
9584 "file."
9585 msgstr ""
9587 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
9588 #: ../en/ch06-collab.xml:1477
9589 msgid ""
9590 "<envar role=\"rc-item-web\">ipv6</envar>: Boolean. Whether to use the IPv6 "
9591 "protocol. By default, IPv6 is not used."
9592 msgstr ""
9594 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
9595 #: ../en/ch06-collab.xml:1481
9596 msgid ""
9597 "<envar role=\"rc-item-web\">port</envar>: Integer. The TCP port number on "
9598 "which the server should listen. The default port number used is 8000."
9599 msgstr ""
9601 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
9602 #: ../en/ch06-collab.xml:1488
9603 msgid ""
9604 "Choosing the right <filename role=\"special\">~/.hgrc</filename> file to add "
9605 "<literal role=\"rc-web\">web</literal> items to"
9606 msgstr ""
9607 "选择正确的 <filename role=\"special\"> ~/.hgrc</filename> 文件增加到 <literal "
9608 "role=\"rc-web\">web</literal> 条目"
9610 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9611 #: ../en/ch06-collab.xml:1492
9612 msgid ""
9613 "It is important to remember that a web server like Apache or "
9614 "<literal>lighttpd</literal> will run under a user ID that is different to "
9615 "yours. CGI scripts run by your server, such as <filename role=\"special"
9616 "\">hgweb.cgi</filename>, will usually also run under that user ID."
9617 msgstr ""
9619 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9620 #: ../en/ch06-collab.xml:1499
9621 msgid ""
9622 "If you add <literal role=\"rc-web\">web</literal> items to your own personal "
9623 "<filename role=\"special\">~/.hgrc</filename> file, CGI scripts won't read "
9624 "that <filename role=\"special\">~/.hgrc</filename> file. Those settings will "
9625 "thus only affect the behavior of the <command role=\"hg-cmd\">hg serve</"
9626 "command> command when you run it. To cause CGI scripts to see your settings, "
9627 "either create a <filename role=\"special\">~/.hgrc</filename> file in the "
9628 "home directory of the user ID that runs your web server, or add those "
9629 "settings to a system-wide <filename role=\"special\">hgrc</filename> file."
9630 msgstr ""
9632 #. type: Content of: <book><chapter><sect1><title>
9633 #: ../en/ch06-collab.xml:1514
9634 msgid "System-wide configuration"
9635 msgstr "全局配置"
9637 #. type: Content of: <book><chapter><sect1><para>
9638 #: ../en/ch06-collab.xml:1516
9639 msgid ""
9640 "On Unix-like systems shared by multiple users (such as a server to which "
9641 "people publish changes), it often makes sense to set up some global default "
9642 "behaviors, such as what theme to use in web interfaces."
9643 msgstr ""
9645 #. type: Content of: <book><chapter><sect1><para>
9646 #: ../en/ch06-collab.xml:1521
9647 msgid ""
9648 "If a file named <filename>/etc/mercurial/hgrc</filename> exists, Mercurial "
9649 "will read it at startup time and apply any configuration settings it finds in "
9650 "that file. It will also look for files ending in a <literal>.rc</literal> "
9651 "extension in a directory named <filename>/etc/mercurial/hgrc.d</filename>, "
9652 "and apply any configuration settings it finds in each of those files."
9653 msgstr ""
9655 #. type: Content of: <book><chapter><sect1><sect2><title>
9656 #: ../en/ch06-collab.xml:1530
9657 msgid "Making Mercurial more trusting"
9658 msgstr "让 Mercurial 更可信"
9660 #. type: Content of: <book><chapter><sect1><sect2><para>
9661 #: ../en/ch06-collab.xml:1532
9662 msgid ""
9663 "One situation in which a global <filename>hgrc</filename> can be useful is if "
9664 "users are pulling changes owned by other users. By default, Mercurial will "
9665 "not trust most of the configuration items in a <filename>.hg/hgrc</filename> "
9666 "file inside a repository that is owned by a different user. If we clone or "
9667 "pull changes from such a repository, Mercurial will print a warning stating "
9668 "that it does not trust their <filename>.hg/hgrc</filename>."
9669 msgstr ""
9671 #. type: Content of: <book><chapter><sect1><sect2><para>
9672 #: ../en/ch06-collab.xml:1541
9673 msgid ""
9674 "If everyone in a particular Unix group is on the same team and "
9675 "<emphasis>should</emphasis> trust each other's configuration settings, or we "
9676 "want to trust particular users, we can override Mercurial's skeptical "
9677 "defaults by creating a system-wide <filename>hgrc</filename> file such as the "
9678 "following:"
9679 msgstr ""
9681 #. type: Content of: <book><chapter><title>
9682 #: ../en/ch07-filenames.xml:5
9683 msgid "File names and pattern matching"
9684 msgstr "文件名称与模式匹配"
9686 #. type: Content of: <book><chapter><para>
9687 #: ../en/ch07-filenames.xml:7
9688 msgid ""
9689 "Mercurial provides mechanisms that let you work with file names in a "
9690 "consistent and expressive way."
9691 msgstr ""
9693 #. type: Content of: <book><chapter><sect1><title>
9694 #: ../en/ch07-filenames.xml:11
9695 msgid "Simple file naming"
9696 msgstr "简单文件名称"
9698 #. type: Content of: <book><chapter><sect1><para>
9699 #: ../en/ch07-filenames.xml:13
9700 msgid ""
9701 "Mercurial uses a unified piece of machinery <quote>under the hood</quote> to "
9702 "handle file names. Every command behaves uniformly with respect to file "
9703 "names. The way in which commands work with file names is as follows."
9704 msgstr ""
9706 #. type: Content of: <book><chapter><sect1><para>
9707 #: ../en/ch07-filenames.xml:18
9708 msgid ""
9709 "If you explicitly name real files on the command line, Mercurial works with "
9710 "exactly those files, as you would expect. &interaction.filenames.files;"
9711 msgstr ""
9714 #. type: Content of: <book><chapter><sect1><para>
9715 #: ../en/ch07-filenames.xml:22
9716 msgid ""
9717 "When you provide a directory name, Mercurial will interpret this as "
9718 "<quote>operate on every file in this directory and its subdirectories</"
9719 "quote>. Mercurial traverses the files and subdirectories in a directory in "
9720 "alphabetical order. When it encounters a subdirectory, it will traverse that "
9721 "subdirectory before continuing with the current directory."
9722 msgstr ""
9724 #. type: Content of: <book><chapter><sect1><title>
9725 #: ../en/ch07-filenames.xml:33
9726 msgid "Running commands without any file names"
9727 msgstr "不提供文件名称的执行命令"
9729 #. type: Content of: <book><chapter><sect1><para>
9730 #: ../en/ch07-filenames.xml:35
9731 msgid ""
9732 "Mercurial's commands that work with file names have useful default behaviors "
9733 "when you invoke them without providing any file names or patterns. What kind "
9734 "of behavior you should expect depends on what the command does. Here are a "
9735 "few rules of thumb you can use to predict what a command is likely to do if "
9736 "you don't give it any names to work with."
9737 msgstr ""
9739 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
9740 #: ../en/ch07-filenames.xml:42
9741 msgid ""
9742 "Most commands will operate on the entire working directory. This is what the "
9743 "<command role=\"hg-cmd\">hg add</command> command does, for example."
9744 msgstr ""
9746 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
9747 #: ../en/ch07-filenames.xml:46
9748 msgid ""
9749 "If the command has effects that are difficult or impossible to reverse, it "
9750 "will force you to explicitly provide at least one name or pattern (see "
9751 "below). This protects you from accidentally deleting files by running "
9752 "<command role=\"hg-cmd\">hg remove</command> with no arguments, for example."
9753 msgstr ""
9755 #. type: Content of: <book><chapter><sect1><para>
9756 #: ../en/ch07-filenames.xml:54
9757 msgid ""
9758 "It's easy to work around these default behaviors if they don't suit you. If "
9759 "a command normally operates on the whole working directory, you can invoke it "
9760 "on just the current directory and its subdirectories by giving it the name "
9761 "<quote><filename class=\"directory\">.</filename></quote>."
9762 msgstr ""
9765 #. type: Content of: <book><chapter><sect1><para>
9766 #: ../en/ch07-filenames.xml:62
9767 msgid ""
9768 "Along the same lines, some commands normally print file names relative to the "
9769 "root of the repository, even if you're invoking them from a subdirectory. "
9770 "Such a command will print file names relative to your subdirectory if you "
9771 "give it explicit names. Here, we're going to run <command role=\"hg-cmd\">hg "
9772 "status</command> from a subdirectory, and get it to operate on the entire "
9773 "working directory while printing file names relative to our subdirectory, by "
9774 "passing it the output of the <command role=\"hg-cmd\">hg root</command> "
9775 "command."
9776 msgstr ""
9778 #. type: Content of: <book><chapter><sect1><title>
9779 #: ../en/ch07-filenames.xml:76
9780 msgid "Telling you what's going on"
9781 msgstr "告诉你正在做什么"
9783 #. type: Content of: <book><chapter><sect1><para>
9784 #: ../en/ch07-filenames.xml:78
9785 msgid ""
9786 "The <command role=\"hg-cmd\">hg add</command> example in the preceding "
9787 "section illustrates something else that's helpful about Mercurial commands. "
9788 "If a command operates on a file that you didn't name explicitly on the "
9789 "command line, it will usually print the name of the file, so that you will "
9790 "not be surprised what's going on."
9791 msgstr ""
9793 #. type: Content of: <book><chapter><sect1><para>
9794 #: ../en/ch07-filenames.xml:85
9795 msgid ""
9796 "The principle here is of <emphasis>least surprise</emphasis>. If you've "
9797 "exactly named a file on the command line, there's no point in repeating it "
9798 "back at you. If Mercurial is acting on a file <emphasis>implicitly</"
9799 "emphasis>, e.g. because you provided no names, or a directory, or a pattern "
9800 "(see below), it is safest to tell you what files it's operating on."
9801 msgstr ""
9803 #. type: Content of: <book><chapter><sect1><para>
9804 #: ../en/ch07-filenames.xml:92
9805 msgid ""
9806 "For commands that behave this way, you can silence them using the <option "
9807 "role=\"hg-opt-global\">-q</option> option. You can also get them to print "
9808 "the name of every file, even those you've named explicitly, using the <option "
9809 "role=\"hg-opt-global\">-v</option> option."
9810 msgstr ""
9812 #. type: Content of: <book><chapter><sect1><title>
9813 #: ../en/ch07-filenames.xml:100
9814 msgid "Using patterns to identify files"
9815 msgstr "使用模式标识文件"
9817 #. type: Content of: <book><chapter><sect1><para>
9818 #: ../en/ch07-filenames.xml:102
9819 msgid ""
9820 "In addition to working with file and directory names, Mercurial lets you use "
9821 "<emphasis>patterns</emphasis> to identify files. Mercurial's pattern "
9822 "handling is expressive."
9823 msgstr ""
9825 #. type: Content of: <book><chapter><sect1><para>
9826 #: ../en/ch07-filenames.xml:106
9827 msgid ""
9828 "On Unix-like systems (Linux, MacOS, etc.), the job of matching file names to "
9829 "patterns normally falls to the shell. On these systems, you must explicitly "
9830 "tell Mercurial that a name is a pattern. On Windows, the shell does not "
9831 "expand patterns, so Mercurial will automatically identify names that are "
9832 "patterns, and expand them for you."
9833 msgstr ""
9835 #. type: Content of: <book><chapter><sect1><para>
9836 #: ../en/ch07-filenames.xml:113
9837 msgid ""
9838 "To provide a pattern in place of a regular name on the command line, the "
9839 "mechanism is simple:"
9840 msgstr ""
9842 #. type: Content of: <book><chapter><sect1><para>
9843 #: ../en/ch07-filenames.xml:116
9844 msgid ""
9845 "That is, a pattern is identified by a short text string that says what kind "
9846 "of pattern this is, followed by a colon, followed by the actual pattern."
9847 msgstr ""
9849 #. type: Content of: <book><chapter><sect1><para>
9850 #: ../en/ch07-filenames.xml:120
9851 msgid ""
9852 "Mercurial supports two kinds of pattern syntax. The most frequently used is "
9853 "called <literal>glob</literal>; this is the same kind of pattern matching "
9854 "used by the Unix shell, and should be familiar to Windows command prompt "
9855 "users, too."
9856 msgstr ""
9858 #. type: Content of: <book><chapter><sect1><para>
9859 #: ../en/ch07-filenames.xml:125
9860 msgid ""
9861 "When Mercurial does automatic pattern matching on Windows, it uses "
9862 "<literal>glob</literal> syntax. You can thus omit the <quote><literal>glob:</"
9863 "literal></quote> prefix on Windows, but it's safe to use it, too."
9864 msgstr ""
9866 #. type: Content of: <book><chapter><sect1><para>
9867 #: ../en/ch07-filenames.xml:130
9868 msgid ""
9869 "The <literal>re</literal> syntax is more powerful; it lets you specify "
9870 "patterns using regular expressions, also known as regexps."
9871 msgstr ""
9873 #. type: Content of: <book><chapter><sect1><para>
9874 #: ../en/ch07-filenames.xml:134
9875 msgid ""
9876 "By the way, in the examples that follow, notice that I'm careful to wrap all "
9877 "of my patterns in quote characters, so that they won't get expanded by the "
9878 "shell before Mercurial sees them."
9879 msgstr ""
9881 #. type: Content of: <book><chapter><sect1><sect2><title>
9882 #: ../en/ch07-filenames.xml:140
9883 msgid "Shell-style <literal>glob</literal> patterns"
9884 msgstr "外壳风格的 <literal>glob</literal> 模式"
9886 #. type: Content of: <book><chapter><sect1><sect2><para>
9887 #: ../en/ch07-filenames.xml:142
9888 msgid ""
9889 "This is an overview of the kinds of patterns you can use when you're matching "
9890 "on glob patterns."
9891 msgstr ""
9894 #. type: Content of: <book><chapter><sect1><sect2><para>
9895 #: ../en/ch07-filenames.xml:145
9896 msgid ""
9897 "The <quote><literal>*</literal></quote> character matches any string, within "
9898 "a single directory."
9899 msgstr ""
9902 #. type: Content of: <book><chapter><sect1><sect2><para>
9903 #: ../en/ch07-filenames.xml:150
9904 msgid ""
9905 "The <quote><literal>**</literal></quote> pattern matches any string, and "
9906 "crosses directory boundaries. It's not a standard Unix glob token, but it's "
9907 "accepted by several popular Unix shells, and is very useful."
9908 msgstr ""
9911 #. type: Content of: <book><chapter><sect1><sect2><para>
9912 #: ../en/ch07-filenames.xml:157
9913 msgid ""
9914 "The <quote><literal>?</literal></quote> pattern matches any single character."
9915 msgstr ""
9917 #. type: Content of: <book><chapter><sect1><sect2><para>
9918 #: ../en/ch07-filenames.xml:162
9919 msgid ""
9920 "The <quote><literal>[</literal></quote> character begins a "
9921 "<emphasis>character class</emphasis>. This matches any single character "
9922 "within the class. The class ends with a <quote><literal>]</literal></quote> "
9923 "character. A class may contain multiple <emphasis>range</emphasis>s of the "
9924 "form <quote><literal>a-f</literal></quote>, which is shorthand for "
9925 "<quote><literal>abcdef</literal></quote>."
9926 msgstr ""
9928 #. type: Content of: <book><chapter><sect1><sect2><para>
9929 #: ../en/ch07-filenames.xml:172
9930 msgid ""
9931 "If the first character after the <quote><literal>[</literal></quote> in a "
9932 "character class is a <quote><literal>!</literal></quote>, it "
9933 "<emphasis>negates</emphasis> the class, making it match any single character "
9934 "not in the class."
9935 msgstr ""
9937 #. type: Content of: <book><chapter><sect1><sect2><para>
9938 #: ../en/ch07-filenames.xml:178
9939 msgid ""
9940 "A <quote><literal>{</literal></quote> begins a group of subpatterns, where "
9941 "the whole group matches if any subpattern in the group matches. The "
9942 "<quote><literal>,</literal></quote> character separates subpatterns, and "
9943 "<quote><literal>}</literal></quote> ends the group."
9944 msgstr ""
9946 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
9947 #: ../en/ch07-filenames.xml:187
9948 msgid "Watch out!"
9949 msgstr "千万小心!"
9952 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9953 #: ../en/ch07-filenames.xml:189
9954 msgid ""
9955 "Don't forget that if you want to match a pattern in any directory, you should "
9956 "not be using the <quote><literal>*</literal></quote> match-any token, as this "
9957 "will only match within one directory. Instead, use the <quote><literal>**</"
9958 "literal></quote> token. This small example illustrates the difference "
9959 "between the two."
9960 msgstr ""
9962 #. type: Content of: <book><chapter><sect1><sect2><title>
9963 #: ../en/ch07-filenames.xml:201
9964 msgid "Regular expression matching with <literal>re</literal> patterns"
9965 msgstr "使用 <literal>re</literal> 模式的正则表达式匹配"
9967 #. type: Content of: <book><chapter><sect1><sect2><para>
9968 #: ../en/ch07-filenames.xml:204
9969 msgid ""
9970 "Mercurial accepts the same regular expression syntax as the Python "
9971 "programming language (it uses Python's regexp engine internally). This is "
9972 "based on the Perl language's regexp syntax, which is the most popular dialect "
9973 "in use (it's also used in Java, for example)."
9974 msgstr ""
9976 #. type: Content of: <book><chapter><sect1><sect2><para>
9977 #: ../en/ch07-filenames.xml:210
9978 msgid ""
9979 "I won't discuss Mercurial's regexp dialect in any detail here, as regexps are "
9980 "not often used. Perl-style regexps are in any case already exhaustively "
9981 "documented on a multitude of web sites, and in many books. Instead, I will "
9982 "focus here on a few things you should know if you find yourself needing to "
9983 "use regexps with Mercurial."
9984 msgstr ""
9986 #. type: Content of: <book><chapter><sect1><sect2><para>
9987 #: ../en/ch07-filenames.xml:217
9988 msgid ""
9989 "A regexp is matched against an entire file name, relative to the root of the "
9990 "repository. In other words, even if you're already in subbdirectory "
9991 "<filename class=\"directory\">foo</filename>, if you want to match files "
9992 "under this directory, your pattern must start with <quote><literal>foo/</"
9993 "literal></quote>."
9994 msgstr ""
9996 #. type: Content of: <book><chapter><sect1><sect2><para>
9997 #: ../en/ch07-filenames.xml:224
9998 msgid ""
9999 "One thing to note, if you're familiar with Perl-style regexps, is that "
10000 "Mercurial's are <emphasis>rooted</emphasis>. That is, a regexp starts "
10001 "matching against the beginning of a string; it doesn't look for a match "
10002 "anywhere within the string. To match anywhere in a string, start your "
10003 "pattern with <quote><literal>.*</literal></quote>."
10004 msgstr ""
10006 #. type: Content of: <book><chapter><sect1><title>
10007 #: ../en/ch07-filenames.xml:234
10008 msgid "Filtering files"
10009 msgstr "过滤文件"
10011 #. type: Content of: <book><chapter><sect1><para>
10012 #: ../en/ch07-filenames.xml:236
10013 msgid ""
10014 "Not only does Mercurial give you a variety of ways to specify files; it lets "
10015 "you further winnow those files using <emphasis>filters</emphasis>. Commands "
10016 "that work with file names accept two filtering options."
10017 msgstr ""
10019 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10020 #: ../en/ch07-filenames.xml:241
10021 msgid ""
10022 "<option role=\"hg-opt-global\">-I</option>, or <option role=\"hg-opt-global"
10023 "\">--include</option>, lets you specify a pattern that file names must match "
10024 "in order to be processed."
10025 msgstr ""
10027 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10028 #: ../en/ch07-filenames.xml:246
10029 msgid ""
10030 "<option role=\"hg-opt-global\">-X</option>, or <option role=\"hg-opt-global"
10031 "\">--exclude</option>, gives you a way to <emphasis>avoid</emphasis> "
10032 "processing files, if they match this pattern."
10033 msgstr ""
10035 #. type: Content of: <book><chapter><sect1><para>
10036 #: ../en/ch07-filenames.xml:251
10037 msgid ""
10038 "You can provide multiple <option role=\"hg-opt-global\">-I</option> and "
10039 "<option role=\"hg-opt-global\">-X</option> options on the command line, and "
10040 "intermix them as you please. Mercurial interprets the patterns you provide "
10041 "using glob syntax by default (but you can use regexps if you need to)."
10042 msgstr ""
10044 #. type: Content of: <book><chapter><sect1><para>
10045 #: ../en/ch07-filenames.xml:258
10046 msgid ""
10047 "You can read a <option role=\"hg-opt-global\">-I</option> filter as "
10048 "<quote>process only the files that match this filter</quote>."
10049 msgstr ""
10051 #. type: Content of: <book><chapter><sect1><para>
10052 #: ../en/ch07-filenames.xml:264
10053 msgid ""
10054 "The <option role=\"hg-opt-global\">-X</option> filter is best read as "
10055 "<quote>process only the files that don't match this pattern</quote>."
10056 msgstr ""
10058 #. type: Content of: <book><chapter><sect1><title>
10059 #: ../en/ch07-filenames.xml:272
10060 msgid "Permanently ignoring unwanted files and directories"
10061 msgstr "始终忽略不需要的文件和目录"
10063 #. type: Content of: <book><chapter><sect1><para>
10064 #: ../en/ch07-filenames.xml:274
10065 msgid ""
10066 "When you create a new repository, the chances are that over time it will grow "
10067 "to contain files that ought to <emphasis>not</emphasis> be managed by "
10068 "Mercurial, but which you don't want to see listed every time you run "
10069 "<command>hg status</command>. For instance, <quote>build products</quote> "
10070 "are files that are created as part of a build but which should not be managed "
10071 "by a revision control system. The most common build products are output "
10072 "files produced by software tools such as compilers. As another example, many "
10073 "text editors litter a directory with lock files, temporary working files, and "
10074 "backup files, which it also makes no sense to manage."
10075 msgstr ""
10077 #. type: Content of: <book><chapter><sect1><para>
10078 #: ../en/ch07-filenames.xml:286
10079 msgid ""
10080 "To have Mercurial permanently ignore such files, create a file named "
10081 "<filename>.hgignore</filename> in the root of your repository. You "
10082 "<emphasis>should</emphasis> <command>hg add</command> this file so that it "
10083 "gets tracked with the rest of your repository contents, since your "
10084 "collaborators will probably find it useful too."
10085 msgstr ""
10087 #. type: Content of: <book><chapter><sect1><para>
10088 #: ../en/ch07-filenames.xml:293
10089 msgid ""
10090 "By default, the <filename>.hgignore</filename> file should contain a list of "
10091 "regular expressions, one per line. Empty lines are skipped. Most people "
10092 "prefer to describe the files they want to ignore using the <quote>glob</"
10093 "quote> syntax that we described above, so a typical <filename>.hgignore</"
10094 "filename> file will start with this directive:"
10095 msgstr ""
10097 #. type: Content of: <book><chapter><sect1><para>
10098 #: ../en/ch07-filenames.xml:302
10099 msgid ""
10100 "This tells Mercurial to interpret the lines that follow as glob patterns, not "
10101 "regular expressions."
10102 msgstr ""
10104 #. type: Content of: <book><chapter><sect1><para>
10105 #: ../en/ch07-filenames.xml:305
10106 msgid "Here is a typical-looking <filename>.hgignore</filename> file."
10107 msgstr ""
10109 #. type: Content of: <book><chapter><sect1><title>
10110 #: ../en/ch07-filenames.xml:329
10111 msgid "Case sensitivity"
10112 msgstr "大小写敏感性"
10114 #. type: Content of: <book><chapter><sect1><para>
10115 #: ../en/ch07-filenames.xml:331
10116 msgid ""
10117 "If you're working in a mixed development environment that contains both Linux "
10118 "(or other Unix) systems and Macs or Windows systems, you should keep in the "
10119 "back of your mind the knowledge that they treat the case (<quote>N</quote> "
10120 "versus <quote>n</quote>) of file names in incompatible ways. This is not "
10121 "very likely to affect you, and it's easy to deal with if it does, but it "
10122 "could surprise you if you don't know about it."
10123 msgstr ""
10125 #. type: Content of: <book><chapter><sect1><para>
10126 #: ../en/ch07-filenames.xml:340
10127 msgid ""
10128 "Operating systems and filesystems differ in the way they handle the "
10129 "<emphasis>case</emphasis> of characters in file and directory names. There "
10130 "are three common ways to handle case in names."
10131 msgstr ""
10133 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10134 #: ../en/ch07-filenames.xml:345
10135 msgid ""
10136 "Completely case insensitive. Uppercase and lowercase versions of a letter "
10137 "are treated as identical, both when creating a file and during subsequent "
10138 "accesses. This is common on older DOS-based systems."
10139 msgstr ""
10141 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10142 #: ../en/ch07-filenames.xml:350
10143 msgid ""
10144 "Case preserving, but insensitive. When a file or directory is created, the "
10145 "case of its name is stored, and can be retrieved and displayed by the "
10146 "operating system. When an existing file is being looked up, its case is "
10147 "ignored. This is the standard arrangement on Windows and MacOS. The names "
10148 "<filename>foo</filename> and <filename>FoO</filename> identify the same "
10149 "file. This treatment of uppercase and lowercase letters as interchangeable "
10150 "is also referred to as <emphasis>case folding</emphasis>."
10151 msgstr ""
10153 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10154 #: ../en/ch07-filenames.xml:361
10155 msgid ""
10156 "Case sensitive. The case of a name is significant at all times. The names "
10157 "<filename>foo</filename> and <filename>FoO</filename> identify different "
10158 "files. This is the way Linux and Unix systems normally work."
10159 msgstr ""
10161 #. type: Content of: <book><chapter><sect1><para>
10162 #: ../en/ch07-filenames.xml:368
10163 msgid ""
10164 "On Unix-like systems, it is possible to have any or all of the above ways of "
10165 "handling case in action at once. For example, if you use a USB thumb drive "
10166 "formatted with a FAT32 filesystem on a Linux system, Linux will handle names "
10167 "on that filesystem in a case preserving, but insensitive, way."
10168 msgstr ""
10170 #. type: Content of: <book><chapter><sect1><sect2><title>
10171 #: ../en/ch07-filenames.xml:375
10172 msgid "Safe, portable repository storage"
10173 msgstr "安全,可移植的版本库存储"
10175 #. type: Content of: <book><chapter><sect1><sect2><para>
10176 #: ../en/ch07-filenames.xml:377
10177 msgid ""
10178 "Mercurial's repository storage mechanism is <emphasis>case safe</emphasis>. "
10179 "It translates file names so that they can be safely stored on both case "
10180 "sensitive and case insensitive filesystems. This means that you can use "
10181 "normal file copying tools to transfer a Mercurial repository onto, for "
10182 "example, a USB thumb drive, and safely move that drive and repository back "
10183 "and forth between a Mac, a PC running Windows, and a Linux box."
10184 msgstr ""
10186 #. type: Content of: <book><chapter><sect1><sect2><title>
10187 #: ../en/ch07-filenames.xml:388
10188 msgid "Detecting case conflicts"
10189 msgstr "检测大小写冲突"
10191 #. type: Content of: <book><chapter><sect1><sect2><para>
10192 #: ../en/ch07-filenames.xml:390
10193 msgid ""
10194 "When operating in the working directory, Mercurial honours the naming policy "
10195 "of the filesystem where the working directory is located. If the filesystem "
10196 "is case preserving, but insensitive, Mercurial will treat names that differ "
10197 "only in case as the same."
10198 msgstr ""
10200 #. type: Content of: <book><chapter><sect1><sect2><para>
10201 #: ../en/ch07-filenames.xml:396
10202 msgid ""
10203 "An important aspect of this approach is that it is possible to commit a "
10204 "changeset on a case sensitive (typically Linux or Unix) filesystem that will "
10205 "cause trouble for users on case insensitive (usually Windows and MacOS) "
10206 "users. If a Linux user commits changes to two files, one named "
10207 "<filename>myfile.c</filename> and the other named <filename>MyFile.C</"
10208 "filename>, they will be stored correctly in the repository. And in the "
10209 "working directories of other Linux users, they will be correctly represented "
10210 "as separate files."
10211 msgstr ""
10213 #. type: Content of: <book><chapter><sect1><sect2><para>
10214 #: ../en/ch07-filenames.xml:407
10215 msgid ""
10216 "If a Windows or Mac user pulls this change, they will not initially have a "
10217 "problem, because Mercurial's repository storage mechanism is case safe. "
10218 "However, once they try to <command role=\"hg-cmd\">hg update</command> the "
10219 "working directory to that changeset, or <command role=\"hg-cmd\">hg merge</"
10220 "command> with that changeset, Mercurial will spot the conflict between the "
10221 "two file names that the filesystem would treat as the same, and forbid the "
10222 "update or merge from occurring."
10223 msgstr ""
10225 #. type: Content of: <book><chapter><sect1><sect2><title>
10226 #: ../en/ch07-filenames.xml:419
10227 msgid "Fixing a case conflict"
10228 msgstr "修正大小写冲突"
10230 #. type: Content of: <book><chapter><sect1><sect2><para>
10231 #: ../en/ch07-filenames.xml:421
10232 msgid ""
10233 "If you are using Windows or a Mac in a mixed environment where some of your "
10234 "collaborators are using Linux or Unix, and Mercurial reports a case folding "
10235 "conflict when you try to <command role=\"hg-cmd\">hg update</command> or "
10236 "<command role=\"hg-cmd\">hg merge</command>, the procedure to fix the problem "
10237 "is simple."
10238 msgstr ""
10240 #. type: Content of: <book><chapter><sect1><sect2><para>
10241 #: ../en/ch07-filenames.xml:428
10242 msgid ""
10243 "Just find a nearby Linux or Unix box, clone the problem repository onto it, "
10244 "and use Mercurial's <command role=\"hg-cmd\">hg rename</command> command to "
10245 "change the names of any offending files or directories so that they will no "
10246 "longer cause case folding conflicts. Commit this change, <command role=\"hg-"
10247 "cmd\">hg pull</command> or <command role=\"hg-cmd\">hg push</command> it "
10248 "across to your Windows or MacOS system, and <command role=\"hg-cmd\">hg "
10249 "update</command> to the revision with the non-conflicting names."
10250 msgstr ""
10252 #. type: Content of: <book><chapter><sect1><sect2><para>
10253 #: ../en/ch07-filenames.xml:438
10254 msgid ""
10255 "The changeset with case-conflicting names will remain in your project's "
10256 "history, and you still won't be able to <command role=\"hg-cmd\">hg update</"
10257 "command> your working directory to that changeset on a Windows or MacOS "
10258 "system, but you can continue development unimpeded."
10259 msgstr ""
10261 #. type: Content of: <book><chapter><title>
10262 #: ../en/ch08-branch.xml:5
10263 msgid "Managing releases and branchy development"
10264 msgstr "发布管理与分支开发"
10266 #. type: Content of: <book><chapter><para>
10267 #: ../en/ch08-branch.xml:7
10268 msgid ""
10269 "Mercurial provides several mechanisms for you to manage a project that is "
10270 "making progress on multiple fronts at once. To understand these mechanisms, "
10271 "let's first take a brief look at a fairly normal software project structure."
10272 msgstr ""
10274 #. type: Content of: <book><chapter><para>
10275 #: ../en/ch08-branch.xml:12
10276 msgid ""
10277 "Many software projects issue periodic <quote>major</quote> releases that "
10278 "contain substantial new features. In parallel, they may issue <quote>minor</"
10279 "quote> releases. These are usually identical to the major releases off which "
10280 "they're based, but with a few bugs fixed."
10281 msgstr ""
10283 #. type: Content of: <book><chapter><para>
10284 #: ../en/ch08-branch.xml:18
10285 msgid ""
10286 "In this chapter, we'll start by talking about how to keep records of project "
10287 "milestones such as releases. We'll then continue on to talk about the flow "
10288 "of work between different phases of a project, and how Mercurial can help you "
10289 "to isolate and manage this work."
10290 msgstr ""
10292 #. type: Content of: <book><chapter><sect1><title>
10293 #: ../en/ch08-branch.xml:25
10294 msgid "Giving a persistent name to a revision"
10295 msgstr "给版本指定一个永久的名称"
10297 #. type: Content of: <book><chapter><sect1><para>
10298 #: ../en/ch08-branch.xml:27
10299 msgid ""
10300 "Once you decide that you'd like to call a particular revision a "
10301 "<quote>release</quote>, it's a good idea to record the identity of that "
10302 "revision. This will let you reproduce that release at a later date, for "
10303 "whatever purpose you might need at the time (reproducing a bug, porting to a "
10304 "new platform, etc). &interaction.tag.init;"
10305 msgstr ""
10308 #. type: Content of: <book><chapter><sect1><para>
10309 #: ../en/ch08-branch.xml:34
10310 msgid ""
10311 "Mercurial lets you give a permanent name to any revision using the <command "
10312 "role=\"hg-cmd\">hg tag</command> command. Not surprisingly, these names are "
10313 "called <quote>tags</quote>."
10314 msgstr ""
10316 #. type: Content of: <book><chapter><sect1><para>
10317 #: ../en/ch08-branch.xml:40
10318 msgid ""
10319 "A tag is nothing more than a <quote>symbolic name</quote> for a revision. "
10320 "Tags exist purely for your convenience, so that you have a handy permanent "
10321 "way to refer to a revision; Mercurial doesn't interpret the tag names you use "
10322 "in any way. Neither does Mercurial place any restrictions on the name of a "
10323 "tag, beyond a few that are necessary to ensure that a tag can be parsed "
10324 "unambiguously. A tag name cannot contain any of the following characters:"
10325 msgstr ""
10327 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10328 #: ../en/ch08-branch.xml:49
10329 msgid "Colon (ASCII 58, <quote><literal>:</literal></quote>)"
10330 msgstr ""
10332 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10333 #: ../en/ch08-branch.xml:52
10334 msgid "Carriage return (ASCII 13, <quote><literal>\\r</literal></quote>)"
10335 msgstr ""
10337 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10338 #: ../en/ch08-branch.xml:55
10339 msgid "Newline (ASCII 10, <quote><literal>\\n</literal></quote>)"
10340 msgstr ""
10342 #. type: Content of: <book><chapter><sect1><para>
10343 #: ../en/ch08-branch.xml:59
10344 msgid ""
10345 "You can use the <command role=\"hg-cmd\">hg tags</command> command to display "
10346 "the tags present in your repository. In the output, each tagged revision is "
10347 "identified first by its name, then by revision number, and finally by the "
10348 "unique hash of the revision."
10349 msgstr ""
10351 #. type: Content of: <book><chapter><sect1><para>
10352 #: ../en/ch08-branch.xml:67
10353 msgid ""
10354 "Notice that <literal>tip</literal> is listed in the output of <command role="
10355 "\"hg-cmd\">hg tags</command>. The <literal>tip</literal> tag is a special "
10356 "<quote>floating</quote> tag, which always identifies the newest revision in "
10357 "the repository."
10358 msgstr ""
10360 #. type: Content of: <book><chapter><sect1><para>
10361 #: ../en/ch08-branch.xml:73
10362 msgid ""
10363 "In the output of the <command role=\"hg-cmd\">hg tags</command> command, tags "
10364 "are listed in reverse order, by revision number. This usually means that "
10365 "recent tags are listed before older tags. It also means that <literal>tip</"
10366 "literal> is always going to be the first tag listed in the output of <command "
10367 "role=\"hg-cmd\">hg tags</command>."
10368 msgstr ""
10370 #. type: Content of: <book><chapter><sect1><para>
10371 #: ../en/ch08-branch.xml:80
10372 msgid ""
10373 "When you run <command role=\"hg-cmd\">hg log</command>, if it displays a "
10374 "revision that has tags associated with it, it will print those tags."
10375 msgstr ""
10378 #. type: Content of: <book><chapter><sect1><para>
10379 #: ../en/ch08-branch.xml:86
10380 msgid ""
10381 "Any time you need to provide a revision ID to a Mercurial command, the "
10382 "command will accept a tag name in its place. Internally, Mercurial will "
10383 "translate your tag name into the corresponding revision ID, then use that."
10384 msgstr ""
10386 #. type: Content of: <book><chapter><sect1><para>
10387 #: ../en/ch08-branch.xml:93
10388 msgid ""
10389 "There's no limit on the number of tags you can have in a repository, or on "
10390 "the number of tags that a single revision can have. As a practical matter, "
10391 "it's not a great idea to have <quote>too many</quote> (a number which will "
10392 "vary from project to project), simply because tags are supposed to help you "
10393 "to find revisions. If you have lots of tags, the ease of using them to "
10394 "identify revisions diminishes rapidly."
10395 msgstr ""
10397 #. type: Content of: <book><chapter><sect1><para>
10398 #: ../en/ch08-branch.xml:101
10399 msgid ""
10400 "For example, if your project has milestones as frequent as every few days, "
10401 "it's perfectly reasonable to tag each one of those. But if you have a "
10402 "continuous build system that makes sure every revision can be built cleanly, "
10403 "you'd be introducing a lot of noise if you were to tag every clean build. "
10404 "Instead, you could tag failed builds (on the assumption that they're rare!), "
10405 "or simply not use tags to track buildability."
10406 msgstr ""
10408 #. type: Content of: <book><chapter><sect1><para>
10409 #: ../en/ch08-branch.xml:109
10410 msgid ""
10411 "If you want to remove a tag that you no longer want, use <command role=\"hg-"
10412 "cmd\">hg tag --remove</command>."
10413 msgstr ""
10415 #. type: Content of: <book><chapter><sect1><para>
10416 #: ../en/ch08-branch.xml:114
10417 msgid ""
10418 "You can also modify a tag at any time, so that it identifies a different "
10419 "revision, by simply issuing a new <command role=\"hg-cmd\">hg tag</command> "
10420 "command. You'll have to use the <option role=\"hg-opt-tag\">-f</option> "
10421 "option to tell Mercurial that you <emphasis>really</emphasis> want to update "
10422 "the tag."
10423 msgstr ""
10425 #. type: Content of: <book><chapter><sect1><para>
10426 #: ../en/ch08-branch.xml:123
10427 msgid ""
10428 "There will still be a permanent record of the previous identity of the tag, "
10429 "but Mercurial will no longer use it. There's thus no penalty to tagging the "
10430 "wrong revision; all you have to do is turn around and tag the correct "
10431 "revision once you discover your error."
10432 msgstr ""
10434 #. type: Content of: <book><chapter><sect1><para>
10435 #: ../en/ch08-branch.xml:129
10436 msgid ""
10437 "Mercurial stores tags in a normal revision-controlled file in your "
10438 "repository. If you've created any tags, you'll find them in a file in the "
10439 "root of your repository named <filename role=\"special\">.hgtags</filename>. "
10440 "When you run the <command role=\"hg-cmd\">hg tag</command> command, Mercurial "
10441 "modifies this file, then automatically commits the change to it. This means "
10442 "that every time you run <command role=\"hg-cmd\">hg tag</command>, you'll see "
10443 "a corresponding changeset in the output of <command role=\"hg-cmd\">hg log</"
10444 "command>."
10445 msgstr ""
10447 #. type: Content of: <book><chapter><sect1><sect2><title>
10448 #: ../en/ch08-branch.xml:142
10449 msgid "Handling tag conflicts during a merge"
10450 msgstr "在合并期间处理标签冲突"
10452 #. type: Content of: <book><chapter><sect1><sect2><para>
10453 #: ../en/ch08-branch.xml:144
10454 msgid ""
10455 "You won't often need to care about the <filename role=\"special\">.hgtags</"
10456 "filename> file, but it sometimes makes its presence known during a merge. "
10457 "The format of the file is simple: it consists of a series of lines. Each "
10458 "line starts with a changeset hash, followed by a space, followed by the name "
10459 "of a tag."
10460 msgstr ""
10462 #. type: Content of: <book><chapter><sect1><sect2><para>
10463 #: ../en/ch08-branch.xml:151
10464 msgid ""
10465 "If you're resolving a conflict in the <filename role=\"special\">.hgtags</"
10466 "filename> file during a merge, there's one twist to modifying the <filename "
10467 "role=\"special\">.hgtags</filename> file: when Mercurial is parsing the tags "
10468 "in a repository, it <emphasis>never</emphasis> reads the working copy of the "
10469 "<filename role=\"special\">.hgtags</filename> file. Instead, it reads the "
10470 "<emphasis>most recently committed</emphasis> revision of the file."
10471 msgstr ""
10473 #. type: Content of: <book><chapter><sect1><sect2><para>
10474 #: ../en/ch08-branch.xml:161
10475 msgid ""
10476 "An unfortunate consequence of this design is that you can't actually verify "
10477 "that your merged <filename role=\"special\">.hgtags</filename> file is "
10478 "correct until <emphasis>after</emphasis> you've committed a change. So if "
10479 "you find yourself resolving a conflict on <filename role=\"special\">.hgtags</"
10480 "filename> during a merge, be sure to run <command role=\"hg-cmd\">hg tags</"
10481 "command> after you commit. If it finds an error in the <filename role="
10482 "\"special\">.hgtags</filename> file, it will report the location of the "
10483 "error, which you can then fix and commit. You should then run <command role="
10484 "\"hg-cmd\">hg tags</command> again, just to be sure that your fix is correct."
10485 msgstr ""
10487 #. type: Content of: <book><chapter><sect1><sect2><title>
10488 #: ../en/ch08-branch.xml:176
10489 msgid "Tags and cloning"
10490 msgstr "标签与克隆"
10492 #. type: Content of: <book><chapter><sect1><sect2><para>
10493 #: ../en/ch08-branch.xml:178
10494 msgid ""
10495 "You may have noticed that the <command role=\"hg-cmd\">hg clone</command> "
10496 "command has a <option role=\"hg-opt-clone\">-r</option> option that lets you "
10497 "clone an exact copy of the repository as of a particular changeset. The new "
10498 "clone will not contain any project history that comes after the revision you "
10499 "specified. This has an interaction with tags that can surprise the unwary."
10500 msgstr ""
10502 #. type: Content of: <book><chapter><sect1><sect2><para>
10503 #: ../en/ch08-branch.xml:186
10504 msgid ""
10505 "Recall that a tag is stored as a revision to the <filename role=\"special\">."
10506 "hgtags</filename> file. When you create a tag, the changeset in which its "
10507 "recorded refers to an older changeset. When you run <command role=\"hg-cmd"
10508 "\">hg clone -r foo</command> to clone a repository as of tag <literal>foo</"
10509 "literal>, the new clone <emphasis>will not contain any revision newer than "
10510 "the one the tag refers to, including the revision where the tag was created</"
10511 "emphasis>. The result is that you'll get exactly the right subset of the "
10512 "project's history in the new repository, but <emphasis>not</emphasis> the tag "
10513 "you might have expected."
10514 msgstr ""
10516 #. type: Content of: <book><chapter><sect1><sect2><title>
10517 #: ../en/ch08-branch.xml:201
10518 msgid "When permanent tags are too much"
10519 msgstr "当永久标签太多的时候"
10521 #. type: Content of: <book><chapter><sect1><sect2><para>
10522 #: ../en/ch08-branch.xml:203
10523 msgid ""
10524 "Since Mercurial's tags are revision controlled and carried around with a "
10525 "project's history, everyone you work with will see the tags you create. But "
10526 "giving names to revisions has uses beyond simply noting that revision "
10527 "<literal>4237e45506ee</literal> is really <literal>v2.0.2</literal>. If "
10528 "you're trying to track down a subtle bug, you might want a tag to remind you "
10529 "of something like <quote>Anne saw the symptoms with this revision</quote>."
10530 msgstr ""
10532 #. type: Content of: <book><chapter><sect1><sect2><para>
10533 #: ../en/ch08-branch.xml:213
10534 msgid ""
10535 "For cases like this, what you might want to use are <emphasis>local</"
10536 "emphasis> tags. You can create a local tag with the <option role=\"hg-opt-tag"
10537 "\">-l</option> option to the <command role=\"hg-cmd\">hg tag</command> "
10538 "command. This will store the tag in a file called <filename role=\"special"
10539 "\">.hg/localtags</filename>. Unlike <filename role=\"special\">.hgtags</"
10540 "filename>, <filename role=\"special\">.hg/localtags</filename> is not "
10541 "revision controlled. Any tags you create using <option role=\"hg-opt-tag\">-"
10542 "l</option> remain strictly local to the repository you're currently working "
10543 "in."
10544 msgstr ""
10546 #. type: Content of: <book><chapter><sect1><title>
10547 #: ../en/ch08-branch.xml:228
10548 msgid "The flow of changes&emdash;big picture vs. little"
10549 msgstr "修改流程—宏观与微观"
10551 #. type: Content of: <book><chapter><sect1><para>
10552 #: ../en/ch08-branch.xml:230
10553 msgid ""
10554 "To return to the outline I sketched at the beginning of the chapter, let's "
10555 "think about a project that has multiple concurrent pieces of work under "
10556 "development at once."
10557 msgstr ""
10559 #. type: Content of: <book><chapter><sect1><para>
10560 #: ../en/ch08-branch.xml:235
10561 msgid ""
10562 "There might be a push for a new <quote>main</quote> release; a new minor "
10563 "bugfix release to the last main release; and an unexpected <quote>hot fix</"
10564 "quote> to an old release that is now in maintenance mode."
10565 msgstr ""
10567 #. type: Content of: <book><chapter><sect1><para>
10568 #: ../en/ch08-branch.xml:240
10569 msgid ""
10570 "The usual way people refer to these different concurrent directions of "
10571 "development is as <quote>branches</quote>. However, we've already seen "
10572 "numerous times that Mercurial treats <emphasis>all of history</emphasis> as a "
10573 "series of branches and merges. Really, what we have here is two ideas that "
10574 "are peripherally related, but which happen to share a name."
10575 msgstr ""
10577 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10578 #: ../en/ch08-branch.xml:247
10579 msgid ""
10580 "<quote>Big picture</quote> branches represent the sweep of a project's "
10581 "evolution; people give them names, and talk about them in conversation."
10582 msgstr ""
10584 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10585 #: ../en/ch08-branch.xml:251
10586 msgid ""
10587 "<quote>Little picture</quote> branches are artefacts of the day-to-day "
10588 "activity of developing and merging changes. They expose the narrative of how "
10589 "the code was developed."
10590 msgstr ""
10592 #. type: Content of: <book><chapter><sect1><title>
10593 #: ../en/ch08-branch.xml:259
10594 msgid "Managing big-picture branches in repositories"
10595 msgstr "在版本库中管理分支"
10597 #. type: Content of: <book><chapter><sect1><para>
10598 #: ../en/ch08-branch.xml:261
10599 msgid ""
10600 "The easiest way to isolate a <quote>big picture</quote> branch in Mercurial "
10601 "is in a dedicated repository. If you have an existing shared "
10602 "repository&emdash;let's call it <literal>myproject</literal>&emdash;that "
10603 "reaches a <quote>1.0</quote> milestone, you can start to prepare for future "
10604 "maintenance releases on top of version 1.0 by tagging the revision from which "
10605 "you prepared the 1.0 release."
10606 msgstr ""
10608 #. type: Content of: <book><chapter><sect1><para>
10609 #: ../en/ch08-branch.xml:271
10610 msgid ""
10611 "You can then clone a new shared <literal>myproject-1.0.1</literal> repository "
10612 "as of that tag."
10613 msgstr ""
10615 #. type: Content of: <book><chapter><sect1><para>
10616 #: ../en/ch08-branch.xml:277
10617 msgid ""
10618 "Afterwards, if someone needs to work on a bug fix that ought to go into an "
10619 "upcoming 1.0.1 minor release, they clone the <literal>myproject-1.0.1</"
10620 "literal> repository, make their changes, and push them back."
10621 msgstr ""
10623 #. type: Content of: <book><chapter><sect1><para>
10624 #: ../en/ch08-branch.xml:284
10625 msgid ""
10626 "Meanwhile, development for the next major release can continue, isolated and "
10627 "unabated, in the <literal>myproject</literal> repository."
10628 msgstr ""
10630 #. type: Content of: <book><chapter><sect1><title>
10631 #: ../en/ch08-branch.xml:292
10632 msgid "Don't repeat yourself: merging across branches"
10633 msgstr "不要重复劳动:在分支间合并"
10635 #. type: Content of: <book><chapter><sect1><para>
10636 #: ../en/ch08-branch.xml:294
10637 msgid ""
10638 "In many cases, if you have a bug to fix on a maintenance branch, the chances "
10639 "are good that the bug exists on your project's main branch (and possibly "
10640 "other maintenance branches, too). It's a rare developer who wants to fix the "
10641 "same bug multiple times, so let's look at a few ways that Mercurial can help "
10642 "you to manage these bugfixes without duplicating your work."
10643 msgstr ""
10645 #. type: Content of: <book><chapter><sect1><para>
10646 #: ../en/ch08-branch.xml:302
10647 msgid ""
10648 "In the simplest instance, all you need to do is pull changes from your "
10649 "maintenance branch into your local clone of the target branch."
10650 msgstr ""
10652 #. type: Content of: <book><chapter><sect1><para>
10653 #: ../en/ch08-branch.xml:308
10654 msgid ""
10655 "You'll then need to merge the heads of the two branches, and push back to the "
10656 "main branch."
10657 msgstr ""
10659 #. type: Content of: <book><chapter><sect1><title>
10660 #: ../en/ch08-branch.xml:315
10661 msgid "Naming branches within one repository"
10662 msgstr "版本库中的命名分支"
10664 #. type: Content of: <book><chapter><sect1><para>
10665 #: ../en/ch08-branch.xml:317
10666 msgid ""
10667 "In most instances, isolating branches in repositories is the right approach. "
10668 "Its simplicity makes it easy to understand; and so it's hard to make "
10669 "mistakes. There's a one-to-one relationship between branches you're working "
10670 "in and directories on your system. This lets you use normal (non-Mercurial-"
10671 "aware) tools to work on files within a branch/repository."
10672 msgstr ""
10674 #. type: Content of: <book><chapter><sect1><para>
10675 #: ../en/ch08-branch.xml:324
10676 msgid ""
10677 "If you're more in the <quote>power user</quote> category (<emphasis>and</"
10678 "emphasis> your collaborators are too), there is an alternative way of "
10679 "handling branches that you can consider. I've already mentioned the human-"
10680 "level distinction between <quote>small picture</quote> and <quote>big "
10681 "picture</quote> branches. While Mercurial works with multiple <quote>small "
10682 "picture</quote> branches in a repository all the time (for example after you "
10683 "pull changes in, but before you merge them), it can <emphasis>also</emphasis> "
10684 "work with multiple <quote>big picture</quote> branches."
10685 msgstr ""
10687 #. type: Content of: <book><chapter><sect1><para>
10688 #: ../en/ch08-branch.xml:335
10689 msgid ""
10690 "The key to working this way is that Mercurial lets you assign a persistent "
10691 "<emphasis>name</emphasis> to a branch. There always exists a branch named "
10692 "<literal>default</literal>. Even before you start naming branches yourself, "
10693 "you can find traces of the <literal>default</literal> branch if you look for "
10694 "them."
10695 msgstr ""
10697 #. type: Content of: <book><chapter><sect1><para>
10698 #: ../en/ch08-branch.xml:342
10699 msgid ""
10700 "As an example, when you run the <command role=\"hg-cmd\">hg commit</command> "
10701 "command, and it pops up your editor so that you can enter a commit message, "
10702 "look for a line that contains the text <quote><literal>HG: branch default</"
10703 "literal></quote> at the bottom. This is telling you that your commit will "
10704 "occur on the branch named <literal>default</literal>."
10705 msgstr ""
10707 #. type: Content of: <book><chapter><sect1><para>
10708 #: ../en/ch08-branch.xml:349
10709 msgid ""
10710 "To start working with named branches, use the <command role=\"hg-cmd\">hg "
10711 "branches</command> command. This command lists the named branches already "
10712 "present in your repository, telling you which changeset is the tip of each."
10713 msgstr ""
10715 #. type: Content of: <book><chapter><sect1><para>
10716 #: ../en/ch08-branch.xml:356
10717 msgid ""
10718 "Since you haven't created any named branches yet, the only one that exists is "
10719 "<literal>default</literal>."
10720 msgstr ""
10722 #. type: Content of: <book><chapter><sect1><para>
10723 #: ../en/ch08-branch.xml:359
10724 msgid ""
10725 "To find out what the <quote>current</quote> branch is, run the <command role="
10726 "\"hg-cmd\">hg branch</command> command, giving it no arguments. This tells "
10727 "you what branch the parent of the current changeset is on."
10728 msgstr ""
10731 #. type: Content of: <book><chapter><sect1><para>
10732 #: ../en/ch08-branch.xml:366
10733 msgid ""
10734 "To create a new branch, run the <command role=\"hg-cmd\">hg branch</command> "
10735 "command again. This time, give it one argument: the name of the branch you "
10736 "want to create."
10737 msgstr ""
10739 #. type: Content of: <book><chapter><sect1><para>
10740 #: ../en/ch08-branch.xml:372
10741 msgid ""
10742 "After you've created a branch, you might wonder what effect the <command role="
10743 "\"hg-cmd\">hg branch</command> command has had. What do the <command role="
10744 "\"hg-cmd\">hg status</command> and <command role=\"hg-cmd\">hg tip</command> "
10745 "commands report?"
10746 msgstr ""
10748 #. type: Content of: <book><chapter><sect1><para>
10749 #: ../en/ch08-branch.xml:379
10750 msgid ""
10751 "Nothing has changed in the working directory, and there's been no new history "
10752 "created. As this suggests, running the <command role=\"hg-cmd\">hg branch</"
10753 "command> command has no permanent effect; it only tells Mercurial what branch "
10754 "name to use the <emphasis>next</emphasis> time you commit a changeset."
10755 msgstr ""
10757 #. type: Content of: <book><chapter><sect1><para>
10758 #: ../en/ch08-branch.xml:386
10759 msgid ""
10760 "When you commit a change, Mercurial records the name of the branch on which "
10761 "you committed. Once you've switched from the <literal>default</literal> "
10762 "branch to another and committed, you'll see the name of the new branch show "
10763 "up in the output of <command role=\"hg-cmd\">hg log</command>, <command role="
10764 "\"hg-cmd\">hg tip</command>, and other commands that display the same kind of "
10765 "output."
10766 msgstr ""
10768 #. type: Content of: <book><chapter><sect1><para>
10769 #: ../en/ch08-branch.xml:396
10770 msgid ""
10771 "The <command role=\"hg-cmd\">hg log</command>-like commands will print the "
10772 "branch name of every changeset that's not on the <literal>default</literal> "
10773 "branch. As a result, if you never use named branches, you'll never see this "
10774 "information."
10775 msgstr ""
10777 #. type: Content of: <book><chapter><sect1><para>
10778 #: ../en/ch08-branch.xml:401
10779 msgid ""
10780 "Once you've named a branch and committed a change with that name, every "
10781 "subsequent commit that descends from that change will inherit the same branch "
10782 "name. You can change the name of a branch at any time, using the <command "
10783 "role=\"hg-cmd\">hg branch</command> command."
10784 msgstr ""
10786 #. type: Content of: <book><chapter><sect1><para>
10787 #: ../en/ch08-branch.xml:409
10788 msgid ""
10789 "In practice, this is something you won't do very often, as branch names tend "
10790 "to have fairly long lifetimes. (This isn't a rule, just an observation.)"
10791 msgstr ""
10793 #. type: Content of: <book><chapter><sect1><title>
10794 #: ../en/ch08-branch.xml:415
10795 msgid "Dealing with multiple named branches in a repository"
10796 msgstr "在版本库中处理多个命名分支"
10798 #. type: Content of: <book><chapter><sect1><para>
10799 #: ../en/ch08-branch.xml:418
10800 msgid ""
10801 "If you have more than one named branch in a repository, Mercurial will "
10802 "remember the branch that your working directory is on when you start a "
10803 "command like <command role=\"hg-cmd\">hg update</command> or <command role="
10804 "\"hg-cmd\">hg pull -u</command>. It will update the working directory to the "
10805 "tip of this branch, no matter what the <quote>repo-wide</quote> tip is. To "
10806 "update to a revision that's on a different named branch, you may need to use "
10807 "the <option role=\"hg-opt-update\">-C</option> option to <command role=\"hg-"
10808 "cmd\">hg update</command>."
10809 msgstr ""
10811 #. type: Content of: <book><chapter><sect1><para>
10812 #: ../en/ch08-branch.xml:428
10813 msgid ""
10814 "This behavior is a little subtle, so let's see it in action. First, let's "
10815 "remind ourselves what branch we're currently on, and what branches are in our "
10816 "repository."
10817 msgstr ""
10819 #. type: Content of: <book><chapter><sect1><para>
10820 #: ../en/ch08-branch.xml:434
10821 msgid ""
10822 "We're on the <literal>bar</literal> branch, but there also exists an older "
10823 "<command role=\"hg-cmd\">hg foo</command> branch."
10824 msgstr ""
10826 #. type: Content of: <book><chapter><sect1><para>
10827 #: ../en/ch08-branch.xml:438
10828 msgid ""
10829 "We can <command role=\"hg-cmd\">hg update</command> back and forth between "
10830 "the tips of the <literal>foo</literal> and <literal>bar</literal> branches "
10831 "without needing to use the <option role=\"hg-opt-update\">-C</option> option, "
10832 "because this only involves going backwards and forwards linearly through our "
10833 "change history."
10834 msgstr ""
10837 #. type: Content of: <book><chapter><sect1><para>
10838 #: ../en/ch08-branch.xml:447
10839 msgid ""
10840 "If we go back to the <literal>foo</literal> branch and then run <command role="
10841 "\"hg-cmd\">hg update</command>, it will keep us on <literal>foo</literal>, "
10842 "not move us to the tip of <literal>bar</literal>."
10843 msgstr ""
10846 #. type: Content of: <book><chapter><sect1><para>
10847 #: ../en/ch08-branch.xml:454
10848 msgid ""
10849 "Committing a new change on the <literal>foo</literal> branch introduces a new "
10850 "head."
10851 msgstr ""
10853 #. type: Content of: <book><chapter><sect1><title>
10854 #: ../en/ch08-branch.xml:461
10855 msgid "Branch names and merging"
10856 msgstr "分支名称与合并"
10858 #. type: Content of: <book><chapter><sect1><para>
10859 #: ../en/ch08-branch.xml:463
10860 msgid ""
10861 "As you've probably noticed, merges in Mercurial are not symmetrical. Let's "
10862 "say our repository has two heads, 17 and 23. If I <command role=\"hg-cmd"
10863 "\">hg update</command> to 17 and then <command role=\"hg-cmd\">hg merge</"
10864 "command> with 23, Mercurial records 17 as the first parent of the merge, and "
10865 "23 as the second. Whereas if I <command role=\"hg-cmd\">hg update</command> "
10866 "to 23 and then <command role=\"hg-cmd\">hg merge</command> with 17, it "
10867 "records 23 as the first parent, and 17 as the second."
10868 msgstr ""
10870 #. type: Content of: <book><chapter><sect1><para>
10871 #: ../en/ch08-branch.xml:473
10872 msgid ""
10873 "This affects Mercurial's choice of branch name when you merge. After a "
10874 "merge, Mercurial will retain the branch name of the first parent when you "
10875 "commit the result of the merge. If your first parent's branch name is "
10876 "<literal>foo</literal>, and you merge with <literal>bar</literal>, the branch "
10877 "name will still be <literal>foo</literal> after you merge."
10878 msgstr ""
10880 #. type: Content of: <book><chapter><sect1><para>
10881 #: ../en/ch08-branch.xml:480
10882 msgid ""
10883 "It's not unusual for a repository to contain multiple heads, each with the "
10884 "same branch name. Let's say I'm working on the <literal>foo</literal> "
10885 "branch, and so are you. We commit different changes; I pull your changes; I "
10886 "now have two heads, each claiming to be on the <literal>foo</literal> "
10887 "branch. The result of a merge will be a single head on the <literal>foo</"
10888 "literal> branch, as you might hope."
10889 msgstr ""
10892 #. type: Content of: <book><chapter><sect1><para>
10893 #: ../en/ch08-branch.xml:488
10894 msgid ""
10895 "But if I'm working on the <literal>bar</literal> branch, and I merge work "
10896 "from the <literal>foo</literal> branch, the result will remain on the "
10897 "<literal>bar</literal> branch."
10898 msgstr ""
10900 #. type: Content of: <book><chapter><sect1><para>
10901 #: ../en/ch08-branch.xml:494
10902 msgid ""
10903 "To give a more concrete example, if I'm working on the <literal>bleeding-"
10904 "edge</literal> branch, and I want to bring in the latest fixes from the "
10905 "<literal>stable</literal> branch, Mercurial will choose the <quote>right</"
10906 "quote> (<literal>bleeding-edge</literal>) branch name when I pull and merge "
10907 "from <literal>stable</literal>."
10908 msgstr ""
10910 #. type: Content of: <book><chapter><sect1><title>
10911 #: ../en/ch08-branch.xml:503
10912 msgid "Branch naming is generally useful"
10913 msgstr "分支名称通常都很有用"
10915 #. type: Content of: <book><chapter><sect1><para>
10916 #: ../en/ch08-branch.xml:505
10917 msgid ""
10918 "You shouldn't think of named branches as applicable only to situations where "
10919 "you have multiple long-lived branches cohabiting in a single repository. "
10920 "They're very useful even in the one-branch-per-repository case."
10921 msgstr ""
10923 #. type: Content of: <book><chapter><sect1><para>
10924 #: ../en/ch08-branch.xml:510
10925 msgid ""
10926 "In the simplest case, giving a name to each branch gives you a permanent "
10927 "record of which branch a changeset originated on. This gives you more "
10928 "context when you're trying to follow the history of a long-lived branchy "
10929 "project."
10930 msgstr ""
10932 #. type: Content of: <book><chapter><sect1><para>
10933 #: ../en/ch08-branch.xml:515
10934 msgid ""
10935 "If you're working with shared repositories, you can set up a <literal role="
10936 "\"hook\">pretxnchangegroup</literal> hook on each that will block incoming "
10937 "changes that have the <quote>wrong</quote> branch name. This provides a "
10938 "simple, but effective, defence against people accidentally pushing changes "
10939 "from a <quote>bleeding edge</quote> branch to a <quote>stable</quote> "
10940 "branch. Such a hook might look like this inside the shared repo's <filename "
10941 "role=\"special\"> /.hgrc</filename>."
10942 msgstr ""
10944 #. type: Content of: <book><chapter><title>
10945 #: ../en/ch09-undo.xml:5
10946 msgid "Finding and fixing mistakes"
10947 msgstr "查找和修改错误"
10949 #. type: Content of: <book><chapter><para>
10950 #: ../en/ch09-undo.xml:7
10951 msgid ""
10952 "To err might be human, but to really handle the consequences well takes a top-"
10953 "notch revision control system. In this chapter, we'll discuss some of the "
10954 "techniques you can use when you find that a problem has crept into your "
10955 "project. Mercurial has some highly capable features that will help you to "
10956 "isolate the sources of problems, and to handle them appropriately."
10957 msgstr ""
10959 #. type: Content of: <book><chapter><sect1><title>
10960 #: ../en/ch09-undo.xml:15
10961 msgid "Erasing local history"
10962 msgstr "销毁本地历史"
10964 #. type: Content of: <book><chapter><sect1><sect2><title>
10965 #: ../en/ch09-undo.xml:18
10966 msgid "The accidental commit"
10967 msgstr "意外的提交"
10969 #. type: Content of: <book><chapter><sect1><sect2><para>
10970 #: ../en/ch09-undo.xml:20
10971 msgid ""
10972 "I have the occasional but persistent problem of typing rather more quickly "
10973 "than I can think, which sometimes results in me committing a changeset that "
10974 "is either incomplete or plain wrong. In my case, the usual kind of "
10975 "incomplete changeset is one in which I've created a new source file, but "
10976 "forgotten to <command role=\"hg-cmd\">hg add</command> it. A <quote>plain "
10977 "wrong</quote> changeset is not as common, but no less annoying."
10978 msgstr ""
10980 #. type: Content of: <book><chapter><sect1><sect2><title>
10981 #: ../en/ch09-undo.xml:31
10982 msgid "Rolling back a transaction"
10983 msgstr "回滚一个事务"
10985 #. type: Content of: <book><chapter><sect1><sect2><para>
10986 #: ../en/ch09-undo.xml:33
10987 msgid ""
10988 "In <xref linkend=\"sec:concepts:txn\"/>, I mentioned that Mercurial treats "
10989 "each modification of a repository as a <emphasis>transaction</emphasis>. "
10990 "Every time you commit a changeset or pull changes from another repository, "
10991 "Mercurial remembers what you did. You can undo, or <emphasis>roll back</"
10992 "emphasis>, exactly one of these actions using the <command role=\"hg-cmd\">hg "
10993 "rollback</command> command. (See <xref linkend=\"sec:undo:rollback-after-push"
10994 "\"/> for an important caveat about the use of this command.)"
10995 msgstr ""
10997 #. type: Content of: <book><chapter><sect1><sect2><para>
10998 #: ../en/ch09-undo.xml:43
10999 msgid ""
11000 "Here's a mistake that I often find myself making: committing a change in "
11001 "which I've created a new file, but forgotten to <command role=\"hg-cmd\">hg "
11002 "add</command> it."
11003 msgstr ""
11005 #. type: Content of: <book><chapter><sect1><sect2><para>
11006 #: ../en/ch09-undo.xml:50
11007 msgid ""
11008 "Looking at the output of <command role=\"hg-cmd\">hg status</command> after "
11009 "the commit immediately confirms the error."
11010 msgstr ""
11012 #. type: Content of: <book><chapter><sect1><sect2><para>
11013 #: ../en/ch09-undo.xml:56
11014 msgid ""
11015 "The commit captured the changes to the file <filename>a</filename>, but not "
11016 "the new file <filename>b</filename>. If I were to push this changeset to a "
11017 "repository that I shared with a colleague, the chances are high that "
11018 "something in <filename>a</filename> would refer to <filename>b</filename>, "
11019 "which would not be present in their repository when they pulled my changes. "
11020 "I would thus become the object of some indignation."
11021 msgstr ""
11023 #. type: Content of: <book><chapter><sect1><sect2><para>
11024 #: ../en/ch09-undo.xml:65
11025 msgid ""
11026 "However, luck is with me&emdash;I've caught my error before I pushed the "
11027 "changeset. I use the <command role=\"hg-cmd\">hg rollback</command> command, "
11028 "and Mercurial makes that last changeset vanish."
11029 msgstr ""
11031 #. type: Content of: <book><chapter><sect1><sect2><para>
11032 #: ../en/ch09-undo.xml:72
11033 msgid ""
11034 "Notice that the changeset is no longer present in the repository's history, "
11035 "and the working directory once again thinks that the file <filename>a</"
11036 "filename> is modified. The commit and rollback have left the working "
11037 "directory exactly as it was prior to the commit; the changeset has been "
11038 "completely erased. I can now safely <command role=\"hg-cmd\">hg add</"
11039 "command> the file <filename>b</filename>, and rerun my commit."
11040 msgstr ""
11042 #. type: Content of: <book><chapter><sect1><sect2><title>
11043 #: ../en/ch09-undo.xml:85
11044 msgid "The erroneous pull"
11045 msgstr "错误的抓取"
11047 #. type: Content of: <book><chapter><sect1><sect2><para>
11048 #: ../en/ch09-undo.xml:87
11049 msgid ""
11050 "It's common practice with Mercurial to maintain separate development branches "
11051 "of a project in different repositories. Your development team might have one "
11052 "shared repository for your project's <quote>0.9</quote> release, and another, "
11053 "containing different changes, for the <quote>1.0</quote> release."
11054 msgstr ""
11056 #. type: Content of: <book><chapter><sect1><sect2><para>
11057 #: ../en/ch09-undo.xml:94
11058 msgid ""
11059 "Given this, you can imagine that the consequences could be messy if you had a "
11060 "local <quote>0.9</quote> repository, and accidentally pulled changes from the "
11061 "shared <quote>1.0</quote> repository into it. At worst, you could be paying "
11062 "insufficient attention, and push those changes into the shared <quote>0.9</"
11063 "quote> tree, confusing your entire team (but don't worry, we'll return to "
11064 "this horror scenario later). However, it's more likely that you'll notice "
11065 "immediately, because Mercurial will display the URL it's pulling from, or you "
11066 "will see it pull a suspiciously large number of changes into the repository."
11067 msgstr ""
11069 #. type: Content of: <book><chapter><sect1><sect2><para>
11070 #: ../en/ch09-undo.xml:106
11071 msgid ""
11072 "The <command role=\"hg-cmd\">hg rollback</command> command will work nicely "
11073 "to expunge all of the changesets that you just pulled. Mercurial groups all "
11074 "changes from one <command role=\"hg-cmd\">hg pull</command> into a single "
11075 "transaction, so one <command role=\"hg-cmd\">hg rollback</command> is all you "
11076 "need to undo this mistake."
11077 msgstr ""
11079 #. type: Content of: <book><chapter><sect1><sect2><title>
11080 #: ../en/ch09-undo.xml:115
11081 msgid "Rolling back is useless once you've pushed"
11082 msgstr "当完成推送后,回滚是无效的"
11084 #. type: Content of: <book><chapter><sect1><sect2><para>
11085 #: ../en/ch09-undo.xml:117
11086 msgid ""
11087 "The value of the <command role=\"hg-cmd\">hg rollback</command> command drops "
11088 "to zero once you've pushed your changes to another repository. Rolling back "
11089 "a change makes it disappear entirely, but <emphasis>only</emphasis> in the "
11090 "repository in which you perform the <command role=\"hg-cmd\">hg rollback</"
11091 "command>. Because a rollback eliminates history, there's no way for the "
11092 "disappearance of a change to propagate between repositories."
11093 msgstr ""
11095 #. type: Content of: <book><chapter><sect1><sect2><para>
11096 #: ../en/ch09-undo.xml:126
11097 msgid ""
11098 "If you've pushed a change to another repository&emdash;particularly if it's a "
11099 "shared repository&emdash;it has essentially <quote>escaped into the wild,</"
11100 "quote> and you'll have to recover from your mistake in a different way. If "
11101 "you push a changeset somewhere, then roll it back, then pull from the "
11102 "repository you pushed to, the changeset you thought you'd gotten rid of will "
11103 "simply reappear in your repository."
11104 msgstr ""
11106 #. type: Content of: <book><chapter><sect1><sect2><para>
11107 #: ../en/ch09-undo.xml:135
11108 msgid ""
11109 "(If you absolutely know for sure that the change you want to roll back is the "
11110 "most recent change in the repository that you pushed to, <emphasis>and</"
11111 "emphasis> you know that nobody else could have pulled it from that "
11112 "repository, you can roll back the changeset there, too, but you really should "
11113 "not expect this to work reliably. Sooner or later a change really will make "
11114 "it into a repository that you don't directly control (or have forgotten "
11115 "about), and come back to bite you.)"
11116 msgstr ""
11118 #. type: Content of: <book><chapter><sect1><sect2><title>
11119 #: ../en/ch09-undo.xml:147
11120 msgid "You can only roll back once"
11121 msgstr "你只能回滚一次"
11123 #. type: Content of: <book><chapter><sect1><sect2><para>
11124 #: ../en/ch09-undo.xml:149
11125 msgid ""
11126 "Mercurial stores exactly one transaction in its transaction log; that "
11127 "transaction is the most recent one that occurred in the repository. This "
11128 "means that you can only roll back one transaction. If you expect to be able "
11129 "to roll back one transaction, then its predecessor, this is not the behavior "
11130 "you will get."
11131 msgstr ""
11133 #. type: Content of: <book><chapter><sect1><sect2><para>
11134 #: ../en/ch09-undo.xml:158
11135 msgid ""
11136 "Once you've rolled back one transaction in a repository, you can't roll back "
11137 "again in that repository until you perform another commit or pull."
11138 msgstr ""
11140 #. type: Content of: <book><chapter><sect1><title>
11141 #: ../en/ch09-undo.xml:165
11142 msgid "Reverting the mistaken change"
11143 msgstr "撤销错误的修改"
11145 #. type: Content of: <book><chapter><sect1><para>
11146 #: ../en/ch09-undo.xml:167
11147 msgid ""
11148 "If you make a modification to a file, and decide that you really didn't want "
11149 "to change the file at all, and you haven't yet committed your changes, the "
11150 "<command role=\"hg-cmd\">hg revert</command> command is the one you'll need. "
11151 "It looks at the changeset that's the parent of the working directory, and "
11152 "restores the contents of the file to their state as of that changeset. "
11153 "(That's a long-winded way of saying that, in the normal case, it undoes your "
11154 "modifications.)"
11155 msgstr ""
11157 #. type: Content of: <book><chapter><sect1><para>
11158 #: ../en/ch09-undo.xml:176
11159 msgid ""
11160 "Let's illustrate how the <command role=\"hg-cmd\">hg revert</command> command "
11161 "works with yet another small example. We'll begin by modifying a file that "
11162 "Mercurial is already tracking."
11163 msgstr ""
11165 #. type: Content of: <book><chapter><sect1><para>
11166 #: ../en/ch09-undo.xml:183
11167 msgid ""
11168 "If we don't want that change, we can simply <command role=\"hg-cmd\">hg "
11169 "revert</command> the file."
11170 msgstr ""
11172 #. type: Content of: <book><chapter><sect1><para>
11173 #: ../en/ch09-undo.xml:189
11174 msgid ""
11175 "The <command role=\"hg-cmd\">hg revert</command> command provides us with an "
11176 "extra degree of safety by saving our modified file with a <filename>.orig</"
11177 "filename> extension."
11178 msgstr ""
11180 #. type: Content of: <book><chapter><sect1><tip><title>
11181 #: ../en/ch09-undo.xml:197
11182 msgid "Be careful with <filename>.orig</filename> files"
11183 msgstr "小心 <filename>.orig</filename> 文件"
11185 #. type: Content of: <book><chapter><sect1><tip><para>
11186 #: ../en/ch09-undo.xml:199
11187 msgid ""
11188 "It's extremely unlikely that you are either using Mercurial to manage files "
11189 "with <filename>.orig</filename> extensions or that you even care about the "
11190 "contents of such files. Just in case, though, it's useful to remember that "
11191 "<command role=\"hg-cmd\">hg revert</command> will unconditionally overwrite "
11192 "an existing file with a <filename>.orig</filename> extension. For instance, "
11193 "if you already have a file named <filename>foo.orig</filename> when you "
11194 "revert <filename>foo</filename>, the contents of <filename>foo.orig</"
11195 "filename> will be clobbered."
11196 msgstr ""
11198 #. type: Content of: <book><chapter><sect1><para>
11199 #: ../en/ch09-undo.xml:211
11200 msgid ""
11201 "Here is a summary of the cases that the <command role=\"hg-cmd\">hg revert</"
11202 "command> command can deal with. We will describe each of these in more "
11203 "detail in the section that follows."
11204 msgstr ""
11206 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
11207 #: ../en/ch09-undo.xml:216
11208 msgid "If you modify a file, it will restore the file to its unmodified state."
11209 msgstr ""
11211 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
11212 #: ../en/ch09-undo.xml:219
11213 msgid ""
11214 "If you <command role=\"hg-cmd\">hg add</command> a file, it will undo the "
11215 "<quote>added</quote> state of the file, but leave the file itself untouched."
11216 msgstr ""
11218 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
11219 #: ../en/ch09-undo.xml:223
11220 msgid ""
11221 "If you delete a file without telling Mercurial, it will restore the file to "
11222 "its unmodified contents."
11223 msgstr ""
11225 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
11226 #: ../en/ch09-undo.xml:226
11227 msgid ""
11228 "If you use the <command role=\"hg-cmd\">hg remove</command> command to remove "
11229 "a file, it will undo the <quote>removed</quote> state of the file, and "
11230 "restore the file to its unmodified contents."
11231 msgstr ""
11233 #. type: Content of: <book><chapter><sect1><sect2><title>
11234 #: ../en/ch09-undo.xml:233
11235 msgid "File management errors"
11236 msgstr "文件管理错误"
11238 #. type: Content of: <book><chapter><sect1><sect2><para>
11239 #: ../en/ch09-undo.xml:235
11240 msgid ""
11241 "The <command role=\"hg-cmd\">hg revert</command> command is useful for more "
11242 "than just modified files. It lets you reverse the results of all of "
11243 "Mercurial's file management commands&emdash;<command role=\"hg-cmd\">hg add</"
11244 "command>, <command role=\"hg-cmd\">hg remove</command>, and so on."
11245 msgstr ""
11248 #. type: Content of: <book><chapter><sect1><sect2><para>
11249 #: ../en/ch09-undo.xml:241
11250 msgid ""
11251 "If you <command role=\"hg-cmd\">hg add</command> a file, then decide that in "
11252 "fact you don't want Mercurial to track it, use <command role=\"hg-cmd\">hg "
11253 "revert</command> to undo the add. Don't worry; Mercurial will not modify the "
11254 "file in any way. It will just <quote>unmark</quote> the file."
11255 msgstr ""
11257 #. type: Content of: <book><chapter><sect1><sect2><para>
11258 #: ../en/ch09-undo.xml:249
11259 msgid ""
11260 "Similarly, if you ask Mercurial to <command role=\"hg-cmd\">hg remove</"
11261 "command> a file, you can use <command role=\"hg-cmd\">hg revert</command> to "
11262 "restore it to the contents it had as of the parent of the working directory. "
11263 "&interaction.daily.revert.remove; This works just as well for a file that you "
11264 "deleted by hand, without telling Mercurial (recall that in Mercurial "
11265 "terminology, this kind of file is called <quote>missing</quote>)."
11266 msgstr ""
11269 #. type: Content of: <book><chapter><sect1><sect2><para>
11270 #: ../en/ch09-undo.xml:260
11271 msgid ""
11272 "If you revert a <command role=\"hg-cmd\">hg copy</command>, the copied-to "
11273 "file remains in your working directory afterwards, untracked. Since a copy "
11274 "doesn't affect the copied-from file in any way, Mercurial doesn't do anything "
11275 "with the copied-from file."
11276 msgstr ""
11278 #. type: Content of: <book><chapter><sect1><title>
11279 #: ../en/ch09-undo.xml:271
11280 msgid "Dealing with committed changes"
11281 msgstr "处理已经提交的修改"
11283 #. type: Content of: <book><chapter><sect1><para>
11284 #: ../en/ch09-undo.xml:273
11285 msgid ""
11286 "Consider a case where you have committed a change <emphasis>a</emphasis>, and "
11287 "another change <emphasis>b</emphasis> on top of it; you then realise that "
11288 "change <emphasis>a</emphasis> was incorrect. Mercurial lets you <quote>back "
11289 "out</quote> an entire changeset automatically, and building blocks that let "
11290 "you reverse part of a changeset by hand."
11291 msgstr ""
11293 #. type: Content of: <book><chapter><sect1><para>
11294 #: ../en/ch09-undo.xml:281
11295 msgid ""
11296 "Before you read this section, here's something to keep in mind: the <command "
11297 "role=\"hg-cmd\">hg backout</command> command undoes the effect of a change by "
11298 "<emphasis>adding</emphasis> to your repository's history, not by modifying or "
11299 "erasing it. It's the right tool to use if you're fixing bugs, but not if "
11300 "you're trying to undo some change that has catastrophic consequences. To "
11301 "deal with those, see <xref linkend=\"sec:undo:aaaiiieee\"/>."
11302 msgstr ""
11304 #. type: Content of: <book><chapter><sect1><sect2><title>
11305 #: ../en/ch09-undo.xml:291
11306 msgid "Backing out a changeset"
11307 msgstr "恢复一个修改集"
11309 #. type: Content of: <book><chapter><sect1><sect2><para>
11310 #: ../en/ch09-undo.xml:293
11311 msgid ""
11312 "The <command role=\"hg-cmd\">hg backout</command> command lets you "
11313 "<quote>undo</quote> the effects of an entire changeset in an automated "
11314 "fashion. Because Mercurial's history is immutable, this command "
11315 "<emphasis>does not</emphasis> get rid of the changeset you want to undo. "
11316 "Instead, it creates a new changeset that <emphasis>reverses</emphasis> the "
11317 "effect of the to-be-undone changeset."
11318 msgstr ""
11321 #. type: Content of: <book><chapter><sect1><sect2><para>
11322 #: ../en/ch09-undo.xml:302
11323 msgid ""
11324 "The operation of the <command role=\"hg-cmd\">hg backout</command> command is "
11325 "a little intricate, so let's illustrate it with some examples. First, we'll "
11326 "create a repository with some simple changes."
11327 msgstr ""
11329 #. type: Content of: <book><chapter><sect1><sect2><para>
11330 #: ../en/ch09-undo.xml:309
11331 msgid ""
11332 "The <command role=\"hg-cmd\">hg backout</command> command takes a single "
11333 "changeset ID as its argument; this is the changeset to back out. Normally, "
11334 "<command role=\"hg-cmd\">hg backout</command> will drop you into a text "
11335 "editor to write a commit message, so you can record why you're backing the "
11336 "change out. In this example, we provide a commit message on the command line "
11337 "using the <option role=\"hg-opt-backout\">-m</option> option."
11338 msgstr ""
11340 #. type: Content of: <book><chapter><sect1><sect2><title>
11341 #: ../en/ch09-undo.xml:320
11342 msgid "Backing out the tip changeset"
11343 msgstr "恢复顶点修改集"
11345 #. type: Content of: <book><chapter><sect1><sect2><para>
11346 #: ../en/ch09-undo.xml:322
11347 msgid "We're going to start by backing out the last changeset we committed."
11348 msgstr ""
11350 #. type: Content of: <book><chapter><sect1><sect2><para>
11351 #: ../en/ch09-undo.xml:327
11352 msgid ""
11353 "You can see that the second line from <filename>myfile</filename> is no "
11354 "longer present. Taking a look at the output of <command role=\"hg-cmd\">hg "
11355 "log</command> gives us an idea of what the <command role=\"hg-cmd\">hg "
11356 "backout</command> command has done. &interaction.backout.simple.log; Notice "
11357 "that the new changeset that <command role=\"hg-cmd\">hg backout</command> has "
11358 "created is a child of the changeset we backed out. It's easier to see this "
11359 "in <xref linkend=\"fig:undo:backout\"/>, which presents a graphical view of "
11360 "the change history. As you can see, the history is nice and linear."
11361 msgstr ""
11363 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
11364 #: ../en/ch09-undo.xml:340 ../en/ch09-undo.xml:460
11365 msgid ""
11366 "Backing out a change using the <command role=\"hg-cmd\">hg backout</command> "
11367 "command"
11368 msgstr "使用 <command role=\"hg-cmd\">hg backout</command> 恢复一个修改"
11370 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
11371 #: ../en/ch09-undo.xml:343
11372 msgid "<imageobject><imagedata fileref=\"figs/undo-simple.png\"/></imageobject>"
11373 msgstr ""
11375 #. type: Content of: <book><chapter><sect1><sect2><title>
11376 #: ../en/ch09-undo.xml:350
11377 msgid "Backing out a non-tip change"
11378 msgstr "恢复非顶点的修改"
11380 #. type: Content of: <book><chapter><sect1><sect2><para>
11381 #: ../en/ch09-undo.xml:352
11382 msgid ""
11383 "If you want to back out a change other than the last one you committed, pass "
11384 "the <option role=\"hg-opt-backout\">--merge</option> option to the <command "
11385 "role=\"hg-cmd\">hg backout</command> command."
11386 msgstr ""
11388 #. type: Content of: <book><chapter><sect1><sect2><para>
11389 #: ../en/ch09-undo.xml:359
11390 msgid ""
11391 "This makes backing out any changeset a <quote>one-shot</quote> operation "
11392 "that's usually simple and fast."
11393 msgstr ""
11395 #. type: Content of: <book><chapter><sect1><sect2><para>
11396 #: ../en/ch09-undo.xml:365
11397 msgid ""
11398 "If you take a look at the contents of <filename>myfile</filename> after the "
11399 "backout finishes, you'll see that the first and third changes are present, "
11400 "but not the second."
11401 msgstr ""
11403 #. type: Content of: <book><chapter><sect1><sect2><para>
11404 #: ../en/ch09-undo.xml:372
11405 msgid ""
11406 "As the graphical history in <xref linkend=\"fig:undo:backout-non-tip\"/> "
11407 "illustrates, Mercurial still commits one change in this kind of situation "
11408 "(the box-shaped node is the ones that Mercurial commits automatically), but "
11409 "the revision graph now looks different. Before Mercurial begins the backout "
11410 "process, it first remembers what the current parent of the working directory "
11411 "is. It then backs out the target changeset, and commits that as a "
11412 "changeset. Finally, it merges back to the previous parent of the working "
11413 "directory, but notice that it <emphasis>does not commit</emphasis> the result "
11414 "of the merge. The repository now contains two heads, and the working "
11415 "directory is in a merge state."
11416 msgstr ""
11418 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
11419 #: ../en/ch09-undo.xml:387
11420 msgid ""
11421 "Automated backout of a non-tip change using the <command role=\"hg-cmd\">hg "
11422 "backout</command> command"
11423 msgstr "使用 <command role=\"hg-cmd\">hg backout</command> 自动恢复非顶点的修改"
11425 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
11426 #: ../en/ch09-undo.xml:390
11427 msgid ""
11428 "<imageobject><imagedata fileref=\"figs/undo-non-tip.png\"/></imageobject>"
11429 msgstr ""
11431 #. type: Content of: <book><chapter><sect1><sect2><para>
11432 #: ../en/ch09-undo.xml:395
11433 msgid ""
11434 "The result is that you end up <quote>back where you were</quote>, only with "
11435 "some extra history that undoes the effect of the changeset you wanted to back "
11436 "out."
11437 msgstr ""
11439 #. type: Content of: <book><chapter><sect1><sect2><para>
11440 #: ../en/ch09-undo.xml:399
11441 msgid ""
11442 "You might wonder why Mercurial does not commit the result of the merge that "
11443 "it performed. The reason lies in Mercurial behaving conservatively: a merge "
11444 "naturally has more scope for error than simply undoing the effect of the tip "
11445 "changeset, so your work will be safest if you first inspect (and test!) the "
11446 "result of the merge, <emphasis>then</emphasis> commit it."
11447 msgstr ""
11449 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
11450 #: ../en/ch09-undo.xml:408
11451 msgid "Always use the <option role=\"hg-opt-backout\">--merge</option> option"
11452 msgstr "始终使用选项 <option role=\"hg-opt-backout\">--merge</option>"
11454 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11455 #: ../en/ch09-undo.xml:411
11456 msgid ""
11457 "In fact, since the <option role=\"hg-opt-backout\">--merge</option> option "
11458 "will do the <quote>right thing</quote> whether or not the changeset you're "
11459 "backing out is the tip (i.e. it won't try to merge if it's backing out the "
11460 "tip, since there's no need), you should <emphasis>always</emphasis> use this "
11461 "option when you run the <command role=\"hg-cmd\">hg backout</command> command."
11462 msgstr ""
11464 #. type: Content of: <book><chapter><sect1><sect2><title>
11465 #: ../en/ch09-undo.xml:422
11466 msgid "Gaining more control of the backout process"
11467 msgstr "在恢复处理中获得更多控制"
11469 #. type: Content of: <book><chapter><sect1><sect2><para>
11470 #: ../en/ch09-undo.xml:424
11471 msgid ""
11472 "While I've recommended that you always use the <option role=\"hg-opt-backout"
11473 "\">--merge</option> option when backing out a change, the <command role=\"hg-"
11474 "cmd\">hg backout</command> command lets you decide how to merge a backout "
11475 "changeset. Taking control of the backout process by hand is something you "
11476 "will rarely need to do, but it can be useful to understand what the <command "
11477 "role=\"hg-cmd\">hg backout</command> command is doing for you automatically. "
11478 "To illustrate this, let's clone our first repository, but omit the backout "
11479 "change that it contains."
11480 msgstr ""
11482 #. type: Content of: <book><chapter><sect1><sect2><para>
11483 #: ../en/ch09-undo.xml:437
11484 msgid ""
11485 "As with our earlier example, We'll commit a third changeset, then back out "
11486 "its parent, and see what happens."
11487 msgstr ""
11489 #. type: Content of: <book><chapter><sect1><sect2><para>
11490 #: ../en/ch09-undo.xml:443
11491 msgid ""
11492 "Our new changeset is again a descendant of the changeset we backout out; it's "
11493 "thus a new head, <emphasis>not</emphasis> a descendant of the changeset that "
11494 "was the tip. The <command role=\"hg-cmd\">hg backout</command> command was "
11495 "quite explicit in telling us this."
11496 msgstr ""
11498 #. type: Content of: <book><chapter><sect1><sect2><para>
11499 #: ../en/ch09-undo.xml:451
11500 msgid ""
11501 "Again, it's easier to see what has happened by looking at a graph of the "
11502 "revision history, in <xref linkend=\"fig:undo:backout-manual\"/>. This makes "
11503 "it clear that when we use <command role=\"hg-cmd\">hg backout</command> to "
11504 "back out a change other than the tip, Mercurial adds a new head to the "
11505 "repository (the change it committed is box-shaped)."
11506 msgstr ""
11508 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
11509 #: ../en/ch09-undo.xml:463
11510 msgid "<imageobject><imagedata fileref=\"figs/undo-manual.png\"/></imageobject>"
11511 msgstr ""
11513 #. type: Content of: <book><chapter><sect1><sect2><para>
11514 #: ../en/ch09-undo.xml:468
11515 msgid ""
11516 "After the <command role=\"hg-cmd\">hg backout</command> command has "
11517 "completed, it leaves the new <quote>backout</quote> changeset as the parent "
11518 "of the working directory."
11519 msgstr ""
11521 #. type: Content of: <book><chapter><sect1><sect2><para>
11522 #: ../en/ch09-undo.xml:475
11523 msgid "Now we have two isolated sets of changes."
11524 msgstr ""
11526 #. type: Content of: <book><chapter><sect1><sect2><para>
11527 #: ../en/ch09-undo.xml:479
11528 msgid ""
11529 "Let's think about what we expect to see as the contents of <filename>myfile</"
11530 "filename> now. The first change should be present, because we've never "
11531 "backed it out. The second change should be missing, as that's the change we "
11532 "backed out. Since the history graph shows the third change as a separate "
11533 "head, we <emphasis>don't</emphasis> expect to see the third change present in "
11534 "<filename>myfile</filename>."
11535 msgstr ""
11537 #. type: Content of: <book><chapter><sect1><sect2><para>
11538 #: ../en/ch09-undo.xml:489
11539 msgid ""
11540 "To get the third change back into the file, we just do a normal merge of our "
11541 "two heads."
11542 msgstr ""
11544 #. type: Content of: <book><chapter><sect1><sect2><para>
11545 #: ../en/ch09-undo.xml:494
11546 msgid ""
11547 "Afterwards, the graphical history of our repository looks like <xref linkend="
11548 "\"fig:undo:backout-manual-merge\"/>."
11549 msgstr ""
11551 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
11552 #: ../en/ch09-undo.xml:499
11553 msgid "Manually merging a backout change"
11554 msgstr "手工合并恢复修改"
11556 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
11557 #: ../en/ch09-undo.xml:501
11558 msgid ""
11559 "<imageobject><imagedata fileref=\"figs/undo-manual-merge.png\"/></imageobject>"
11560 msgstr ""
11562 #. type: Content of: <book><chapter><sect1><sect2><title>
11563 #: ../en/ch09-undo.xml:508
11564 msgid "Why <command role=\"hg-cmd\">hg backout</command> works as it does"
11565 msgstr "<command role=\"hg-cmd\">hg backout</command> 的内幕"
11567 #. type: Content of: <book><chapter><sect1><sect2><para>
11568 #: ../en/ch09-undo.xml:511
11569 msgid ""
11570 "Here's a brief description of how the <command role=\"hg-cmd\">hg backout</"
11571 "command> command works."
11572 msgstr ""
11574 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
11575 #: ../en/ch09-undo.xml:514
11576 msgid ""
11577 "It ensures that the working directory is <quote>clean</quote>, i.e. that the "
11578 "output of <command role=\"hg-cmd\">hg status</command> would be empty."
11579 msgstr ""
11581 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
11582 #: ../en/ch09-undo.xml:518
11583 msgid ""
11584 "It remembers the current parent of the working directory. Let's call this "
11585 "changeset <literal>orig</literal>."
11586 msgstr ""
11588 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
11589 #: ../en/ch09-undo.xml:522
11590 msgid ""
11591 "It does the equivalent of a <command role=\"hg-cmd\">hg update</command> to "
11592 "sync the working directory to the changeset you want to back out. Let's call "
11593 "this changeset <literal>backout</literal>."
11594 msgstr ""
11596 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
11597 #: ../en/ch09-undo.xml:527
11598 msgid ""
11599 "It finds the parent of that changeset. Let's call that changeset "
11600 "<literal>parent</literal>."
11601 msgstr ""
11603 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
11604 #: ../en/ch09-undo.xml:530
11605 msgid ""
11606 "For each file that the <literal>backout</literal> changeset affected, it does "
11607 "the equivalent of a <command role=\"hg-cmd\">hg revert -r parent</command> on "
11608 "that file, to restore it to the contents it had before that changeset was "
11609 "committed."
11610 msgstr ""
11612 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
11613 #: ../en/ch09-undo.xml:537
11614 msgid ""
11615 "It commits the result as a new changeset. This changeset has "
11616 "<literal>backout</literal> as its parent."
11617 msgstr ""
11619 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
11620 #: ../en/ch09-undo.xml:541
11621 msgid ""
11622 "If you specify <option role=\"hg-opt-backout\">--merge</option> on the "
11623 "command line, it merges with <literal>orig</literal>, and commits the result "
11624 "of the merge."
11625 msgstr ""
11627 #. type: Content of: <book><chapter><sect1><sect2><para>
11628 #: ../en/ch09-undo.xml:547
11629 msgid ""
11630 "An alternative way to implement the <command role=\"hg-cmd\">hg backout</"
11631 "command> command would be to <command role=\"hg-cmd\">hg export</command> the "
11632 "to-be-backed-out changeset as a diff, then use the <option role=\"cmd-opt-"
11633 "patch\">--reverse</option> option to the <command>patch</command> command to "
11634 "reverse the effect of the change without fiddling with the working "
11635 "directory. This sounds much simpler, but it would not work nearly as well."
11636 msgstr ""
11638 #. type: Content of: <book><chapter><sect1><sect2><para>
11639 #: ../en/ch09-undo.xml:557
11640 msgid ""
11641 "The reason that <command role=\"hg-cmd\">hg backout</command> does an update, "
11642 "a commit, a merge, and another commit is to give the merge machinery the best "
11643 "chance to do a good job when dealing with all the changes <emphasis>between</"
11644 "emphasis> the change you're backing out and the current tip."
11645 msgstr ""
11647 #. type: Content of: <book><chapter><sect1><sect2><para>
11648 #: ../en/ch09-undo.xml:564
11649 msgid ""
11650 "If you're backing out a changeset that's 100 revisions back in your project's "
11651 "history, the chances that the <command>patch</command> command will be able "
11652 "to apply a reverse diff cleanly are not good, because intervening changes are "
11653 "likely to have <quote>broken the context</quote> that <command>patch</"
11654 "command> uses to determine whether it can apply a patch (if this sounds like "
11655 "gibberish, see <xref linkend=\"sec:mq:patch\"/> for a discussion of the "
11656 "<command>patch</command> command). Also, Mercurial's merge machinery will "
11657 "handle files and directories being renamed, permission changes, and "
11658 "modifications to binary files, none of which <command>patch</command> can "
11659 "deal with."
11660 msgstr ""
11662 #. type: Content of: <book><chapter><sect1><title>
11663 #: ../en/ch09-undo.xml:581
11664 msgid "Changes that should never have been"
11665 msgstr "不该发生的修改"
11667 #. type: Content of: <book><chapter><sect1><para>
11668 #: ../en/ch09-undo.xml:583
11669 msgid ""
11670 "Most of the time, the <command role=\"hg-cmd\">hg backout</command> command "
11671 "is exactly what you need if you want to undo the effects of a change. It "
11672 "leaves a permanent record of exactly what you did, both when committing the "
11673 "original changeset and when you cleaned up after it."
11674 msgstr ""
11676 #. type: Content of: <book><chapter><sect1><para>
11677 #: ../en/ch09-undo.xml:589
11678 msgid ""
11679 "On rare occasions, though, you may find that you've committed a change that "
11680 "really should not be present in the repository at all. For example, it would "
11681 "be very unusual, and usually considered a mistake, to commit a software "
11682 "project's object files as well as its source files. Object files have almost "
11683 "no intrinsic value, and they're <emphasis>big</emphasis>, so they increase "
11684 "the size of the repository and the amount of time it takes to clone or pull "
11685 "changes."
11686 msgstr ""
11688 #. type: Content of: <book><chapter><sect1><para>
11689 #: ../en/ch09-undo.xml:598
11690 msgid ""
11691 "Before I discuss the options that you have if you commit a <quote>brown paper "
11692 "bag</quote> change (the kind that's so bad that you want to pull a brown "
11693 "paper bag over your head), let me first discuss some approaches that probably "
11694 "won't work."
11695 msgstr ""
11697 #. type: Content of: <book><chapter><sect1><para>
11698 #: ../en/ch09-undo.xml:603
11699 msgid ""
11700 "Since Mercurial treats history as accumulative&emdash;every change builds on "
11701 "top of all changes that preceded it&emdash;you generally can't just make "
11702 "disastrous changes disappear. The one exception is when you've just "
11703 "committed a change, and it hasn't been pushed or pulled into another "
11704 "repository. That's when you can safely use the <command role=\"hg-cmd\">hg "
11705 "rollback</command> command, as I detailed in <xref linkend=\"sec:undo:rollback"
11706 "\"/>."
11707 msgstr ""
11709 #. type: Content of: <book><chapter><sect1><para>
11710 #: ../en/ch09-undo.xml:612
11711 msgid ""
11712 "After you've pushed a bad change to another repository, you <emphasis>could</"
11713 "emphasis> still use <command role=\"hg-cmd\">hg rollback</command> to make "
11714 "your local copy of the change disappear, but it won't have the consequences "
11715 "you want. The change will still be present in the remote repository, so it "
11716 "will reappear in your local repository the next time you pull."
11717 msgstr ""
11719 #. type: Content of: <book><chapter><sect1><para>
11720 #: ../en/ch09-undo.xml:620
11721 msgid ""
11722 "If a situation like this arises, and you know which repositories your bad "
11723 "change has propagated into, you can <emphasis>try</emphasis> to get rid of "
11724 "the change from <emphasis>every</emphasis> one of those repositories. This "
11725 "is, of course, not a satisfactory solution: if you miss even a single "
11726 "repository while you're expunging, the change is still <quote>in the wild</"
11727 "quote>, and could propagate further."
11728 msgstr ""
11730 #. type: Content of: <book><chapter><sect1><para>
11731 #: ../en/ch09-undo.xml:628
11732 msgid ""
11733 "If you've committed one or more changes <emphasis>after</emphasis> the change "
11734 "that you'd like to see disappear, your options are further reduced. Mercurial "
11735 "doesn't provide a way to <quote>punch a hole</quote> in history, leaving "
11736 "changesets intact."
11737 msgstr ""
11739 #. type: Content of: <book><chapter><sect1><sect2><title>
11740 #: ../en/ch09-undo.xml:635
11741 msgid "Backing out a merge"
11742 msgstr "撤销一个合并"
11744 #. type: Content of: <book><chapter><sect1><sect2><para>
11745 #: ../en/ch09-undo.xml:637
11746 msgid ""
11747 "Since merges are often complicated, it is not unheard of for a merge to be "
11748 "mangled badly, but committed erroneously. Mercurial provides an important "
11749 "safeguard against bad merges by refusing to commit unresolved files, but "
11750 "human ingenuity guarantees that it is still possible to mess a merge up and "
11751 "commit it."
11752 msgstr ""
11754 #. type: Content of: <book><chapter><sect1><sect2><para>
11755 #: ../en/ch09-undo.xml:644
11756 msgid ""
11757 "Given a bad merge that has been committed, usually the best way to approach "
11758 "it is to simply try to repair the damage by hand. A complete disaster that "
11759 "cannot be easily fixed up by hand ought to be very rare, but the <command "
11760 "role=\"hg-cmd\">hg backout</command> command may help in making the cleanup "
11761 "easier. It offers a <option role=\"hg-opt-backout\">--parent</option> option, "
11762 "which lets you specify which parent to revert to when backing out a merge."
11763 msgstr ""
11765 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
11766 #: ../en/ch09-undo.xml:655
11767 msgid "A bad merge"
11768 msgstr "错误的合并"
11770 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
11771 #: ../en/ch09-undo.xml:657
11772 msgid "<imageobject><imagedata fileref=\"figs/bad-merge-1.png\"/></imageobject>"
11773 msgstr ""
11775 #. type: Content of: <book><chapter><sect1><sect2><para>
11776 #: ../en/ch09-undo.xml:662
11777 msgid ""
11778 "Suppose we have a revision graph like that in <xref linkend=\"fig:undo:bad-"
11779 "merge-1\"/>. What we'd like is to <emphasis>redo</emphasis> the merge of "
11780 "revisions 2 and 3."
11781 msgstr ""
11783 #. type: Content of: <book><chapter><sect1><sect2><para>
11784 #: ../en/ch09-undo.xml:667
11785 msgid "One way to do so would be as follows."
11786 msgstr ""
11788 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
11789 #: ../en/ch09-undo.xml:671
11790 msgid ""
11791 "Call <command role=\"hg-cmd\">hg backout --rev=4 --parent=2</command>. This "
11792 "tells <command role=\"hg-cmd\">hg backout</command> to back out revision 4, "
11793 "which is the bad merge, and to when deciding which revision to prefer, to "
11794 "choose parent 2, one of the parents of the merge. The effect can be seen in "
11795 "<xref linkend=\"fig:undo:bad-merge-2\"/>."
11796 msgstr ""
11798 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><figure><title>
11799 #: ../en/ch09-undo.xml:679
11800 msgid "Backing out the merge, favoring one parent"
11801 msgstr "拆除合并,关注一个父亲"
11803 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><figure><mediaobject>
11804 #: ../en/ch09-undo.xml:681
11805 msgid "<imageobject><imagedata fileref=\"figs/bad-merge-2.png\"/></imageobject>"
11806 msgstr ""
11807 "<imageobject><imagedata fileref=\"figs/bad-merge-2.png\"/></imageobject>"
11809 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
11810 #: ../en/ch09-undo.xml:688
11811 msgid ""
11812 "Call <command role=\"hg-cmd\">hg backout --rev=4 --parent=3</command>. This "
11813 "tells <command role=\"hg-cmd\">hg backout</command> to back out revision 4 "
11814 "again, but this time to choose parent 3, the other parent of the merge. The "
11815 "result is visible in <xref linkend=\"fig:undo:bad-merge-3\"/>, in which the "
11816 "repository now contains three heads."
11817 msgstr ""
11819 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><figure><title>
11820 #: ../en/ch09-undo.xml:696
11821 msgid "Backing out the merge, favoring the other parent"
11822 msgstr "拆除合并,关注其它父亲"
11824 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><figure><mediaobject>
11825 #: ../en/ch09-undo.xml:699
11826 msgid "<imageobject><imagedata fileref=\"figs/bad-merge-3.png\"/></imageobject>"
11827 msgstr ""
11828 "<imageobject><imagedata fileref=\"figs/bad-merge-3.png\"/></imageobject>"
11830 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
11831 #: ../en/ch09-undo.xml:706
11832 msgid ""
11833 "Redo the bad merge by merging the two backout heads, which reduces the number "
11834 "of heads in the repository to two, as can be seen in <xref linkend=\"fig:undo:"
11835 "bad-merge-4\"/>."
11836 msgstr ""
11838 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><figure><title>
11839 #: ../en/ch09-undo.xml:711 ../en/ch09-undo.xml:724
11840 msgid "Merging the backouts"
11841 msgstr "合并拆除"
11843 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><figure><mediaobject>
11844 #: ../en/ch09-undo.xml:713
11845 msgid "<imageobject><imagedata fileref=\"figs/bad-merge-4.png\"/></imageobject>"
11846 msgstr ""
11847 "<imageobject><imagedata fileref=\"figs/bad-merge-4.png\"/></imageobject>"
11849 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
11850 #: ../en/ch09-undo.xml:720
11851 msgid ""
11852 "Merge with the commit that was made after the bad merge, as shown in <xref "
11853 "linkend=\"fig:undo:bad-merge-5\"/>."
11854 msgstr ""
11856 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><figure><mediaobject>
11857 #: ../en/ch09-undo.xml:726
11858 msgid "<imageobject><imagedata fileref=\"figs/bad-merge-5.png\"/></imageobject>"
11859 msgstr ""
11861 #. type: Content of: <book><chapter><sect1><sect2><title>
11862 #: ../en/ch09-undo.xml:735
11863 msgid "Protect yourself from <quote>escaped</quote> changes"
11864 msgstr "使用<quote>校验</quote>修改来保护你自己"
11866 #. type: Content of: <book><chapter><sect1><sect2><para>
11867 #: ../en/ch09-undo.xml:738
11868 msgid ""
11869 "If you've committed some changes to your local repository and they've been "
11870 "pushed or pulled somewhere else, this isn't necessarily a disaster. You can "
11871 "protect yourself ahead of time against some classes of bad changeset. This "
11872 "is particularly easy if your team usually pulls changes from a central "
11873 "repository."
11874 msgstr ""
11876 #. type: Content of: <book><chapter><sect1><sect2><para>
11877 #: ../en/ch09-undo.xml:745
11878 msgid ""
11879 "By configuring some hooks on that repository to validate incoming changesets "
11880 "(see chapter <xref linkend=\"chap:hook\"/>), you can automatically prevent "
11881 "some kinds of bad changeset from being pushed to the central repository at "
11882 "all. With such a configuration in place, some kinds of bad changeset will "
11883 "naturally tend to <quote>die out</quote> because they can't propagate into "
11884 "the central repository. Better yet, this happens without any need for "
11885 "explicit intervention."
11886 msgstr ""
11888 #. type: Content of: <book><chapter><sect1><sect2><para>
11889 #: ../en/ch09-undo.xml:755
11890 msgid ""
11891 "For instance, an incoming change hook that verifies that a changeset will "
11892 "actually compile can prevent people from inadvertently <quote>breaking the "
11893 "build</quote>."
11894 msgstr ""
11896 #. type: Content of: <book><chapter><sect1><sect2><title>
11897 #: ../en/ch09-undo.xml:762
11898 msgid "What to do about sensitive changes that escape"
11899 msgstr "处理敏感信息泄漏的方法"
11901 #. type: Content of: <book><chapter><sect1><sect2><para>
11902 #: ../en/ch09-undo.xml:764
11903 msgid ""
11904 "Even a carefully run project can suffer an unfortunate event such as the "
11905 "committing and uncontrolled propagation of a file that contains important "
11906 "passwords."
11907 msgstr ""
11909 #. type: Content of: <book><chapter><sect1><sect2><para>
11910 #: ../en/ch09-undo.xml:768
11911 msgid ""
11912 "If something like this happens to you, and the information that gets "
11913 "accidentally propagated is truly sensitive, your first step should be to "
11914 "mitigate the effect of the leak without trying to control the leak itself. If "
11915 "you are not 100% certain that you know exactly who could have seen the "
11916 "changes, you should immediately change passwords, cancel credit cards, or "
11917 "find some other way to make sure that the information that has leaked is no "
11918 "longer useful. In other words, assume that the change has propagated far and "
11919 "wide, and that there's nothing more you can do."
11920 msgstr ""
11922 #. type: Content of: <book><chapter><sect1><sect2><para>
11923 #: ../en/ch09-undo.xml:779
11924 msgid ""
11925 "You might hope that there would be mechanisms you could use to either figure "
11926 "out who has seen a change or to erase the change permanently everywhere, but "
11927 "there are good reasons why these are not possible."
11928 msgstr ""
11930 #. type: Content of: <book><chapter><sect1><sect2><para>
11931 #: ../en/ch09-undo.xml:784
11932 msgid ""
11933 "Mercurial does not provide an audit trail of who has pulled changes from a "
11934 "repository, because it is usually either impossible to record such "
11935 "information or trivial to spoof it. In a multi-user or networked "
11936 "environment, you should thus be extremely skeptical of yourself if you think "
11937 "that you have identified every place that a sensitive changeset has "
11938 "propagated to. Don't forget that people can and will send bundles by email, "
11939 "have their backup software save data offsite, carry repositories on USB "
11940 "sticks, and find other completely innocent ways to confound your attempts to "
11941 "track down every copy of a problematic change."
11942 msgstr ""
11944 #. type: Content of: <book><chapter><sect1><sect2><para>
11945 #: ../en/ch09-undo.xml:796
11946 msgid ""
11947 "Mercurial also does not provide a way to make a file or changeset completely "
11948 "disappear from history, because there is no way to enforce its disappearance; "
11949 "someone could easily modify their copy of Mercurial to ignore such "
11950 "directives. In addition, even if Mercurial provided such a capability, "
11951 "someone who simply hadn't pulled a <quote>make this file disappear</quote> "
11952 "changeset wouldn't be affected by it, nor would web crawlers visiting at the "
11953 "wrong time, disk backups, or other mechanisms. Indeed, no distributed "
11954 "revision control system can make data reliably vanish. Providing the illusion "
11955 "of such control could easily give a false sense of security, and be worse "
11956 "than not providing it at all."
11957 msgstr ""
11959 #. type: Content of: <book><chapter><sect1><title>
11960 #: ../en/ch09-undo.xml:812
11961 msgid "Finding the source of a bug"
11962 msgstr "查找问题的根源"
11964 #. type: Content of: <book><chapter><sect1><para>
11965 #: ../en/ch09-undo.xml:814
11966 msgid ""
11967 "While it's all very well to be able to back out a changeset that introduced a "
11968 "bug, this requires that you know which changeset to back out. Mercurial "
11969 "provides an invaluable command, called <command role=\"hg-cmd\">hg bisect</"
11970 "command>, that helps you to automate this process and accomplish it very "
11971 "efficiently."
11972 msgstr ""
11974 #. type: Content of: <book><chapter><sect1><para>
11975 #: ../en/ch09-undo.xml:821
11976 msgid ""
11977 "The idea behind the <command role=\"hg-cmd\">hg bisect</command> command is "
11978 "that a changeset has introduced some change of behavior that you can identify "
11979 "with a simple pass/fail test. You don't know which piece of code introduced "
11980 "the change, but you know how to test for the presence of the bug. The "
11981 "<command role=\"hg-cmd\">hg bisect</command> command uses your test to direct "
11982 "its search for the changeset that introduced the code that caused the bug."
11983 msgstr ""
11985 #. type: Content of: <book><chapter><sect1><para>
11986 #: ../en/ch09-undo.xml:830
11987 msgid ""
11988 "Here are a few scenarios to help you understand how you might apply this "
11989 "command."
11990 msgstr ""
11992 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
11993 #: ../en/ch09-undo.xml:833
11994 msgid ""
11995 "The most recent version of your software has a bug that you remember wasn't "
11996 "present a few weeks ago, but you don't know when it was introduced. Here, "
11997 "your binary test checks for the presence of that bug."
11998 msgstr ""
12000 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12001 #: ../en/ch09-undo.xml:838
12002 msgid ""
12003 "You fixed a bug in a rush, and now it's time to close the entry in your "
12004 "team's bug database. The bug database requires a changeset ID when you close "
12005 "an entry, but you don't remember which changeset you fixed the bug in. Once "
12006 "again, your binary test checks for the presence of the bug."
12007 msgstr ""
12009 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12010 #: ../en/ch09-undo.xml:845
12011 msgid ""
12012 "Your software works correctly, but runs 15% slower than the last time you "
12013 "measured it. You want to know which changeset introduced the performance "
12014 "regression. In this case, your binary test measures the performance of your "
12015 "software, to see whether it's <quote>fast</quote> or <quote>slow</quote>."
12016 msgstr ""
12018 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12019 #: ../en/ch09-undo.xml:852
12020 msgid ""
12021 "The sizes of the components of your project that you ship exploded recently, "
12022 "and you suspect that something changed in the way you build your project."
12023 msgstr ""
12025 #. type: Content of: <book><chapter><sect1><para>
12026 #: ../en/ch09-undo.xml:857
12027 msgid ""
12028 "From these examples, it should be clear that the <command role=\"hg-cmd\">hg "
12029 "bisect</command> command is not useful only for finding the sources of bugs. "
12030 "You can use it to find any <quote>emergent property</quote> of a repository "
12031 "(anything that you can't find from a simple text search of the files in the "
12032 "tree) for which you can write a binary test."
12033 msgstr ""
12035 #. type: Content of: <book><chapter><sect1><para>
12036 #: ../en/ch09-undo.xml:864
12037 msgid ""
12038 "We'll introduce a little bit of terminology here, just to make it clear which "
12039 "parts of the search process are your responsibility, and which are "
12040 "Mercurial's. A <emphasis>test</emphasis> is something that <emphasis>you</"
12041 "emphasis> run when <command role=\"hg-cmd\">hg bisect</command> chooses a "
12042 "changeset. A <emphasis>probe</emphasis> is what <command role=\"hg-cmd\">hg "
12043 "bisect</command> runs to tell whether a revision is good. Finally, we'll use "
12044 "the word <quote>bisect</quote>, as both a noun and a verb, to stand in for "
12045 "the phrase <quote>search using the <command role=\"hg-cmd\">hg bisect</"
12046 "command> command</quote>."
12047 msgstr ""
12049 #. type: Content of: <book><chapter><sect1><para>
12050 #: ../en/ch09-undo.xml:877
12051 msgid ""
12052 "One simple way to automate the searching process would be simply to probe "
12053 "every changeset. However, this scales poorly. If it took ten minutes to "
12054 "test a single changeset, and you had 10,000 changesets in your repository, "
12055 "the exhaustive approach would take on average 35 <emphasis>days</emphasis> to "
12056 "find the changeset that introduced a bug. Even if you knew that the bug was "
12057 "introduced by one of the last 500 changesets, and limited your search to "
12058 "those, you'd still be looking at over 40 hours to find the changeset that "
12059 "introduced your bug."
12060 msgstr ""
12062 #. type: Content of: <book><chapter><sect1><para>
12063 #: ../en/ch09-undo.xml:887
12064 msgid ""
12065 "What the <command role=\"hg-cmd\">hg bisect</command> command does is use its "
12066 "knowledge of the <quote>shape</quote> of your project's revision history to "
12067 "perform a search in time proportional to the <emphasis>logarithm</emphasis> "
12068 "of the number of changesets to check (the kind of search it performs is "
12069 "called a dichotomic search). With this approach, searching through 10,000 "
12070 "changesets will take less than three hours, even at ten minutes per test (the "
12071 "search will require about 14 tests). Limit your search to the last hundred "
12072 "changesets, and it will take only about an hour (roughly seven tests)."
12073 msgstr ""
12075 #. type: Content of: <book><chapter><sect1><para>
12076 #: ../en/ch09-undo.xml:898
12077 msgid ""
12078 "The <command role=\"hg-cmd\">hg bisect</command> command is aware of the "
12079 "<quote>branchy</quote> nature of a Mercurial project's revision history, so "
12080 "it has no problems dealing with branches, merges, or multiple heads in a "
12081 "repository. It can prune entire branches of history with a single probe, "
12082 "which is how it operates so efficiently."
12083 msgstr ""
12085 #. type: Content of: <book><chapter><sect1><sect2><title>
12086 #: ../en/ch09-undo.xml:906
12087 msgid "Using the <command role=\"hg-cmd\">hg bisect</command> command"
12088 msgstr "使用命令 <command role=\"hg-cmd\">hg bisect</command>"
12090 #. type: Content of: <book><chapter><sect1><sect2><para>
12091 #: ../en/ch09-undo.xml:909
12092 msgid ""
12093 "Here's an example of <command role=\"hg-cmd\">hg bisect</command> in action."
12094 msgstr ""
12096 #. type: Content of: <book><chapter><sect1><sect2><note><para>
12097 #: ../en/ch09-undo.xml:913
12098 msgid ""
12099 "In versions 0.9.5 and earlier of Mercurial, <command role=\"hg-cmd\">hg "
12100 "bisect</command> was not a core command: it was distributed with Mercurial as "
12101 "an extension. This section describes the built-in command, not the old "
12102 "extension."
12103 msgstr ""
12105 #. type: Content of: <book><chapter><sect1><sect2><para>
12106 #: ../en/ch09-undo.xml:920
12107 msgid ""
12108 "Now let's create a repository, so that we can try out the <command role=\"hg-"
12109 "cmd\">hg bisect</command> command in isolation."
12110 msgstr ""
12112 #. type: Content of: <book><chapter><sect1><sect2><para>
12113 #: ../en/ch09-undo.xml:926
12114 msgid ""
12115 "We'll simulate a project that has a bug in it in a simple-minded way: create "
12116 "trivial changes in a loop, and nominate one specific change that will have "
12117 "the <quote>bug</quote>. This loop creates 35 changesets, each adding a "
12118 "single file to the repository. We'll represent our <quote>bug</quote> with a "
12119 "file that contains the text <quote>i have a gub</quote>."
12120 msgstr ""
12122 #. type: Content of: <book><chapter><sect1><sect2><para>
12123 #: ../en/ch09-undo.xml:936
12124 msgid ""
12125 "The next thing that we'd like to do is figure out how to use the <command "
12126 "role=\"hg-cmd\">hg bisect</command> command. We can use Mercurial's normal "
12127 "built-in help mechanism for this."
12128 msgstr ""
12130 #. type: Content of: <book><chapter><sect1><sect2><para>
12131 #: ../en/ch09-undo.xml:943
12132 msgid ""
12133 "The <command role=\"hg-cmd\">hg bisect</command> command works in steps. "
12134 "Each step proceeds as follows."
12135 msgstr ""
12137 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
12138 #: ../en/ch09-undo.xml:946
12139 msgid "You run your binary test."
12140 msgstr ""
12142 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><itemizedlist><listitem><para>
12143 #: ../en/ch09-undo.xml:948
12144 msgid ""
12145 "If the test succeeded, you tell <command role=\"hg-cmd\">hg bisect</command> "
12146 "by running the <command role=\"hg-cmd\">hg bisect --good</command> command."
12147 msgstr ""
12148 "当测试成功后,使用 <command role=\"hg-cmd\">hg bisect --good</command> 命令告"
12149 "诉 <command role=\"hg-cmd\">hg bisect</command> 命令。"
12151 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><itemizedlist><listitem><para>
12152 #: ../en/ch09-undo.xml:953
12153 msgid ""
12154 "If it failed, run the <command role=\"hg-cmd\">hg bisect --bad</command> "
12155 "command."
12156 msgstr ""
12157 "如果失败,执行 <command role=\"hg-cmd\">hg bisect --bad</command> 命令。"
12159 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
12160 #: ../en/ch09-undo.xml:957
12161 msgid ""
12162 "The command uses your information to decide which changeset to test next."
12163 msgstr ""
12165 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
12166 #: ../en/ch09-undo.xml:960
12167 msgid ""
12168 "It updates the working directory to that changeset, and the process begins "
12169 "again."
12170 msgstr ""
12172 #. type: Content of: <book><chapter><sect1><sect2><para>
12173 #: ../en/ch09-undo.xml:963
12174 msgid ""
12175 "The process ends when <command role=\"hg-cmd\">hg bisect</command> identifies "
12176 "a unique changeset that marks the point where your test transitioned from "
12177 "<quote>succeeding</quote> to <quote>failing</quote>."
12178 msgstr ""
12181 #. type: Content of: <book><chapter><sect1><sect2><para>
12182 #: ../en/ch09-undo.xml:968
12183 msgid ""
12184 "To start the search, we must run the <command role=\"hg-cmd\">hg bisect --"
12185 "reset</command> command."
12186 msgstr ""
12188 #. type: Content of: <book><chapter><sect1><sect2><para>
12189 #: ../en/ch09-undo.xml:973
12190 msgid ""
12191 "In our case, the binary test we use is simple: we check to see if any file in "
12192 "the repository contains the string <quote>i have a gub</quote>. If it does, "
12193 "this changeset contains the change that <quote>caused the bug</quote>. By "
12194 "convention, a changeset that has the property we're searching for is "
12195 "<quote>bad</quote>, while one that doesn't is <quote>good</quote>."
12196 msgstr ""
12198 #. type: Content of: <book><chapter><sect1><sect2><para>
12199 #: ../en/ch09-undo.xml:981
12200 msgid ""
12201 "Most of the time, the revision to which the working directory is synced "
12202 "(usually the tip) already exhibits the problem introduced by the buggy "
12203 "change, so we'll mark it as <quote>bad</quote>."
12204 msgstr ""
12207 #. type: Content of: <book><chapter><sect1><sect2><para>
12208 #: ../en/ch09-undo.xml:988
12209 msgid ""
12210 "Our next task is to nominate a changeset that we know <emphasis>doesn't</"
12211 "emphasis> have the bug; the <command role=\"hg-cmd\">hg bisect</command> "
12212 "command will <quote>bracket</quote> its search between the first pair of good "
12213 "and bad changesets. In our case, we know that revision 10 didn't have the "
12214 "bug. (I'll have more words about choosing the first <quote>good</quote> "
12215 "changeset later.)"
12216 msgstr ""
12218 #. type: Content of: <book><chapter><sect1><sect2><para>
12219 #: ../en/ch09-undo.xml:998
12220 msgid "Notice that this command printed some output."
12221 msgstr ""
12223 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12224 #: ../en/ch09-undo.xml:1000
12225 msgid ""
12226 "It told us how many changesets it must consider before it can identify the "
12227 "one that introduced the bug, and how many tests that will require."
12228 msgstr ""
12230 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12231 #: ../en/ch09-undo.xml:1004
12232 msgid ""
12233 "It updated the working directory to the next changeset to test, and told us "
12234 "which changeset it's testing."
12235 msgstr ""
12237 #. type: Content of: <book><chapter><sect1><sect2><para>
12238 #: ../en/ch09-undo.xml:1009
12239 msgid ""
12240 "We now run our test in the working directory. We use the <command>grep</"
12241 "command> command to see if our <quote>bad</quote> file is present in the "
12242 "working directory. If it is, this revision is bad; if not, this revision is "
12243 "good. &interaction.bisect.search.step1;"
12244 msgstr ""
12246 #. type: Content of: <book><chapter><sect1><sect2><para>
12247 #: ../en/ch09-undo.xml:1015
12248 msgid ""
12249 "This test looks like a perfect candidate for automation, so let's turn it "
12250 "into a shell function."
12251 msgstr ""
12253 #. type: Content of: <book><chapter><sect1><sect2><para>
12254 #: ../en/ch09-undo.xml:1019
12255 msgid ""
12256 "We can now run an entire test step with a single command, <literal>mytest</"
12257 "literal>."
12258 msgstr ""
12260 #. type: Content of: <book><chapter><sect1><sect2><para>
12261 #: ../en/ch09-undo.xml:1024
12262 msgid "A few more invocations of our canned test step command, and we're done."
12263 msgstr ""
12265 #. type: Content of: <book><chapter><sect1><sect2><para>
12266 #: ../en/ch09-undo.xml:1029
12267 msgid ""
12268 "Even though we had 40 changesets to search through, the <command role=\"hg-cmd"
12269 "\">hg bisect</command> command let us find the changeset that introduced our "
12270 "<quote>bug</quote> with only five tests. Because the number of tests that "
12271 "the <command role=\"hg-cmd\">hg bisect</command> command performs grows "
12272 "logarithmically with the number of changesets to search, the advantage that "
12273 "it has over the <quote>brute force</quote> search approach increases with "
12274 "every changeset you add."
12275 msgstr ""
12277 #. type: Content of: <book><chapter><sect1><sect2><title>
12278 #: ../en/ch09-undo.xml:1040
12279 msgid "Cleaning up after your search"
12280 msgstr "搜索后的清理"
12282 #. type: Content of: <book><chapter><sect1><sect2><para>
12283 #: ../en/ch09-undo.xml:1042
12284 msgid ""
12285 "When you're finished using the <command role=\"hg-cmd\">hg bisect</command> "
12286 "command in a repository, you can use the <command role=\"hg-cmd\">hg bisect --"
12287 "reset</command> command to drop the information it was using to drive your "
12288 "search. The command doesn't use much space, so it doesn't matter if you "
12289 "forget to run this command. However, <command role=\"hg-cmd\">hg bisect</"
12290 "command> won't let you start a new search in that repository until you do a "
12291 "<command role=\"hg-cmd\">hg bisect --reset</command>."
12292 msgstr ""
12294 #. type: Content of: <book><chapter><sect1><title>
12295 #: ../en/ch09-undo.xml:1057
12296 msgid "Tips for finding bugs effectively"
12297 msgstr "有效查找问题的技巧"
12299 #. type: Content of: <book><chapter><sect1><sect2><title>
12300 #: ../en/ch09-undo.xml:1060
12301 msgid "Give consistent input"
12302 msgstr "给出一致的输入"
12304 #. type: Content of: <book><chapter><sect1><sect2><para>
12305 #: ../en/ch09-undo.xml:1062
12306 msgid ""
12307 "The <command role=\"hg-cmd\">hg bisect</command> command requires that you "
12308 "correctly report the result of every test you perform. If you tell it that a "
12309 "test failed when it really succeeded, it <emphasis>might</emphasis> be able "
12310 "to detect the inconsistency. If it can identify an inconsistency in your "
12311 "reports, it will tell you that a particular changeset is both good and bad. "
12312 "However, it can't do this perfectly; it's about as likely to report the wrong "
12313 "changeset as the source of the bug."
12314 msgstr ""
12316 #. type: Content of: <book><chapter><sect1><sect2><title>
12317 #: ../en/ch09-undo.xml:1074
12318 msgid "Automate as much as possible"
12319 msgstr "尽量自动"
12321 #. type: Content of: <book><chapter><sect1><sect2><para>
12322 #: ../en/ch09-undo.xml:1076
12323 msgid ""
12324 "When I started using the <command role=\"hg-cmd\">hg bisect</command> "
12325 "command, I tried a few times to run my tests by hand, on the command line. "
12326 "This is an approach that I, at least, am not suited to. After a few tries, I "
12327 "found that I was making enough mistakes that I was having to restart my "
12328 "searches several times before finally getting correct results."
12329 msgstr ""
12331 #. type: Content of: <book><chapter><sect1><sect2><para>
12332 #: ../en/ch09-undo.xml:1084
12333 msgid ""
12334 "My initial problems with driving the <command role=\"hg-cmd\">hg bisect</"
12335 "command> command by hand occurred even with simple searches on small "
12336 "repositories; if the problem you're looking for is more subtle, or the number "
12337 "of tests that <command role=\"hg-cmd\">hg bisect</command> must perform "
12338 "increases, the likelihood of operator error ruining the search is much "
12339 "higher. Once I started automating my tests, I had much better results."
12340 msgstr ""
12342 #. type: Content of: <book><chapter><sect1><sect2><para>
12343 #: ../en/ch09-undo.xml:1093
12344 msgid "The key to automated testing is twofold:"
12345 msgstr ""
12347 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12348 #: ../en/ch09-undo.xml:1095
12349 msgid "always test for the same symptom, and"
12350 msgstr ""
12352 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12353 #: ../en/ch09-undo.xml:1097
12354 msgid ""
12355 "always feed consistent input to the <command role=\"hg-cmd\">hg bisect</"
12356 "command> command."
12357 msgstr ""
12359 #. type: Content of: <book><chapter><sect1><sect2><para>
12360 #: ../en/ch09-undo.xml:1100
12361 msgid ""
12362 "In my tutorial example above, the <command>grep</command> command tests for "
12363 "the symptom, and the <literal>if</literal> statement takes the result of this "
12364 "check and ensures that we always feed the same input to the <command role="
12365 "\"hg-cmd\">hg bisect</command> command. The <literal>mytest</literal> "
12366 "function marries these together in a reproducible way, so that every test is "
12367 "uniform and consistent."
12368 msgstr ""
12370 #. type: Content of: <book><chapter><sect1><sect2><title>
12371 #: ../en/ch09-undo.xml:1110
12372 msgid "Check your results"
12373 msgstr "检查你的结果"
12375 #. type: Content of: <book><chapter><sect1><sect2><para>
12376 #: ../en/ch09-undo.xml:1112
12377 msgid ""
12378 "Because the output of a <command role=\"hg-cmd\">hg bisect</command> search "
12379 "is only as good as the input you give it, don't take the changeset it reports "
12380 "as the absolute truth. A simple way to cross-check its report is to manually "
12381 "run your test at each of the following changesets:"
12382 msgstr ""
12384 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12385 #: ../en/ch09-undo.xml:1118
12386 msgid ""
12387 "The changeset that it reports as the first bad revision. Your test should "
12388 "still report this as bad."
12389 msgstr ""
12391 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12392 #: ../en/ch09-undo.xml:1122
12393 msgid ""
12394 "The parent of that changeset (either parent, if it's a merge). Your test "
12395 "should report this changeset as good."
12396 msgstr ""
12398 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12399 #: ../en/ch09-undo.xml:1126
12400 msgid ""
12401 "A child of that changeset. Your test should report this changeset as bad."
12402 msgstr ""
12404 #. type: Content of: <book><chapter><sect1><sect2><title>
12405 #: ../en/ch09-undo.xml:1132
12406 msgid "Beware interference between bugs"
12407 msgstr "谨防问题之间的冲突"
12409 #. type: Content of: <book><chapter><sect1><sect2><para>
12410 #: ../en/ch09-undo.xml:1134
12411 msgid ""
12412 "It's possible that your search for one bug could be disrupted by the presence "
12413 "of another. For example, let's say your software crashes at revision 100, "
12414 "and worked correctly at revision 50. Unknown to you, someone else introduced "
12415 "a different crashing bug at revision 60, and fixed it at revision 80. This "
12416 "could distort your results in one of several ways."
12417 msgstr ""
12419 #. type: Content of: <book><chapter><sect1><sect2><para>
12420 #: ../en/ch09-undo.xml:1142
12421 msgid ""
12422 "It is possible that this other bug completely <quote>masks</quote> yours, "
12423 "which is to say that it occurs before your bug has a chance to manifest "
12424 "itself. If you can't avoid that other bug (for example, it prevents your "
12425 "project from building), and so can't tell whether your bug is present in a "
12426 "particular changeset, the <command role=\"hg-cmd\">hg bisect</command> "
12427 "command cannot help you directly. Instead, you can mark a changeset as "
12428 "untested by running <command role=\"hg-cmd\">hg bisect --skip</command>."
12429 msgstr ""
12431 #. type: Content of: <book><chapter><sect1><sect2><para>
12432 #: ../en/ch09-undo.xml:1152
12433 msgid ""
12434 "A different problem could arise if your test for a bug's presence is not "
12435 "specific enough. If you check for <quote>my program crashes</quote>, then "
12436 "both your crashing bug and an unrelated crashing bug that masks it will look "
12437 "like the same thing, and mislead <command role=\"hg-cmd\">hg bisect</command>."
12438 msgstr ""
12440 #. type: Content of: <book><chapter><sect1><sect2><para>
12441 #: ../en/ch09-undo.xml:1159
12442 msgid ""
12443 "Another useful situation in which to use <command role=\"hg-cmd\">hg bisect --"
12444 "skip</command> is if you can't test a revision because your project was in a "
12445 "broken and hence untestable state at that revision, perhaps because someone "
12446 "checked in a change that prevented the project from building."
12447 msgstr ""
12449 #. type: Content of: <book><chapter><sect1><sect2><title>
12450 #: ../en/ch09-undo.xml:1168
12451 msgid "Bracket your search lazily"
12452 msgstr "减少你的查找工作"
12454 #. type: Content of: <book><chapter><sect1><sect2><para>
12455 #: ../en/ch09-undo.xml:1170
12456 msgid ""
12457 "Choosing the first <quote>good</quote> and <quote>bad</quote> changesets that "
12458 "will mark the end points of your search is often easy, but it bears a little "
12459 "discussion nevertheless. From the perspective of <command role=\"hg-cmd\">hg "
12460 "bisect</command>, the <quote>newest</quote> changeset is conventionally "
12461 "<quote>bad</quote>, and the older changeset is <quote>good</quote>."
12462 msgstr ""
12464 #. type: Content of: <book><chapter><sect1><sect2><para>
12465 #: ../en/ch09-undo.xml:1178
12466 msgid ""
12467 "If you're having trouble remembering when a suitable <quote>good</quote> "
12468 "change was, so that you can tell <command role=\"hg-cmd\">hg bisect</"
12469 "command>, you could do worse than testing changesets at random. Just "
12470 "remember to eliminate contenders that can't possibly exhibit the bug (perhaps "
12471 "because the feature with the bug isn't present yet) and those where another "
12472 "problem masks the bug (as I discussed above)."
12473 msgstr ""
12475 #. type: Content of: <book><chapter><sect1><sect2><para>
12476 #: ../en/ch09-undo.xml:1187
12477 msgid ""
12478 "Even if you end up <quote>early</quote> by thousands of changesets or months "
12479 "of history, you will only add a handful of tests to the total number that "
12480 "<command role=\"hg-cmd\">hg bisect</command> must perform, thanks to its "
12481 "logarithmic behavior."
12482 msgstr ""
12484 #. type: Content of: <book><chapter><title>
12485 #: ../en/ch10-hook.xml:5
12486 msgid "Handling repository events with hooks"
12487 msgstr "使用钩子处理版本库事件"
12489 #. type: Content of: <book><chapter><para>
12490 #: ../en/ch10-hook.xml:7
12491 msgid ""
12492 "Mercurial offers a powerful mechanism to let you perform automated actions in "
12493 "response to events that occur in a repository. In some cases, you can even "
12494 "control Mercurial's response to those events."
12495 msgstr ""
12497 #. type: Content of: <book><chapter><para>
12498 #: ../en/ch10-hook.xml:12
12499 msgid ""
12500 "The name Mercurial uses for one of these actions is a <emphasis>hook</"
12501 "emphasis>. Hooks are called <quote>triggers</quote> in some revision control "
12502 "systems, but the two names refer to the same idea."
12503 msgstr ""
12505 #. type: Content of: <book><chapter><sect1><title>
12506 #: ../en/ch10-hook.xml:18
12507 msgid "An overview of hooks in Mercurial"
12508 msgstr "Mercurial 钩子概述"
12510 #. type: Content of: <book><chapter><sect1><para>
12511 #: ../en/ch10-hook.xml:20
12512 msgid ""
12513 "Here is a brief list of the hooks that Mercurial supports. We will revisit "
12514 "each of these hooks in more detail later, in <xref linkend=\"sec:hook:ref\"/>."
12515 msgstr ""
12517 #. type: Content of: <book><chapter><sect1><para>
12518 #: ../en/ch10-hook.xml:24
12519 msgid ""
12520 "Each of the hooks whose description begins with the word <quote>Controlling</"
12521 "quote> has the ability to determine whether an activity can proceed. If the "
12522 "hook succeeds, the activity may proceed; if it fails, the activity is either "
12523 "not permitted or undone, depending on the hook."
12524 msgstr ""
12526 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12527 #: ../en/ch10-hook.xml:31
12528 msgid ""
12529 "<literal role=\"hook\">changegroup</literal>: This is run after a group of "
12530 "changesets has been brought into the repository from elsewhere."
12531 msgstr ""
12533 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12534 #: ../en/ch10-hook.xml:35
12535 msgid ""
12536 "<literal role=\"hook\">commit</literal>: This is run after a new changeset "
12537 "has been created in the local repository."
12538 msgstr ""
12540 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12541 #: ../en/ch10-hook.xml:39
12542 msgid ""
12543 "<literal role=\"hook\">incoming</literal>: This is run once for each new "
12544 "changeset that is brought into the repository from elsewhere. Notice the "
12545 "difference from <literal role=\"hook\">changegroup</literal>, which is run "
12546 "once per <emphasis>group</emphasis> of changesets brought in."
12547 msgstr ""
12549 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12550 #: ../en/ch10-hook.xml:46
12551 msgid ""
12552 "<literal role=\"hook\">outgoing</literal>: This is run after a group of "
12553 "changesets has been transmitted from this repository."
12554 msgstr ""
12556 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12557 #: ../en/ch10-hook.xml:50
12558 msgid ""
12559 "<literal role=\"hook\">prechangegroup</literal>: This is run before starting "
12560 "to bring a group of changesets into the repository."
12561 msgstr ""
12563 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12564 #: ../en/ch10-hook.xml:55
12565 msgid ""
12566 "<literal role=\"hook\">precommit</literal>: Controlling. This is run before "
12567 "starting a commit."
12568 msgstr ""
12570 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12571 #: ../en/ch10-hook.xml:59
12572 msgid ""
12573 "<literal role=\"hook\">preoutgoing</literal>: Controlling. This is run before "
12574 "starting to transmit a group of changesets from this repository."
12575 msgstr ""
12577 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12578 #: ../en/ch10-hook.xml:64
12579 msgid ""
12580 "<literal role=\"hook\">pretag</literal>: Controlling. This is run before "
12581 "creating a tag."
12582 msgstr ""
12584 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12585 #: ../en/ch10-hook.xml:68
12586 msgid ""
12587 "<literal role=\"hook\">pretxnchangegroup</literal>: Controlling. This is run "
12588 "after a group of changesets has been brought into the local repository from "
12589 "another, but before the transaction completes that will make the changes "
12590 "permanent in the repository."
12591 msgstr ""
12593 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12594 #: ../en/ch10-hook.xml:76
12595 msgid ""
12596 "<literal role=\"hook\">pretxncommit</literal>: Controlling. This is run after "
12597 "a new changeset has been created in the local repository, but before the "
12598 "transaction completes that will make it permanent."
12599 msgstr ""
12601 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12602 #: ../en/ch10-hook.xml:82
12603 msgid ""
12604 "<literal role=\"hook\">preupdate</literal>: Controlling. This is run before "
12605 "starting an update or merge of the working directory."
12606 msgstr ""
12608 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12609 #: ../en/ch10-hook.xml:87
12610 msgid ""
12611 "<literal role=\"hook\">tag</literal>: This is run after a tag is created."
12612 msgstr ""
12614 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12615 #: ../en/ch10-hook.xml:91
12616 msgid ""
12617 "<literal role=\"hook\">update</literal>: This is run after an update or merge "
12618 "of the working directory has finished."
12619 msgstr ""
12621 #. type: Content of: <book><chapter><sect1><title>
12622 #: ../en/ch10-hook.xml:99
12623 msgid "Hooks and security"
12624 msgstr "钩子与安全性"
12626 #. type: Content of: <book><chapter><sect1><sect2><title>
12627 #: ../en/ch10-hook.xml:102
12628 msgid "Hooks are run with your privileges"
12629 msgstr "钩子以你的特权执行"
12631 #. type: Content of: <book><chapter><sect1><sect2><para>
12632 #: ../en/ch10-hook.xml:104
12633 msgid ""
12634 "When you run a Mercurial command in a repository, and the command causes a "
12635 "hook to run, that hook runs on <emphasis>your</emphasis> system, under "
12636 "<emphasis>your</emphasis> user account, with <emphasis>your</emphasis> "
12637 "privilege level. Since hooks are arbitrary pieces of executable code, you "
12638 "should treat them with an appropriate level of suspicion. Do not install a "
12639 "hook unless you are confident that you know who created it and what it does."
12640 msgstr ""
12642 #. type: Content of: <book><chapter><sect1><sect2><para>
12643 #: ../en/ch10-hook.xml:115
12644 msgid ""
12645 "In some cases, you may be exposed to hooks that you did not install "
12646 "yourself. If you work with Mercurial on an unfamiliar system, Mercurial will "
12647 "run hooks defined in that system's global <filename role=\"special\">~/.hgrc</"
12648 "filename> file."
12649 msgstr ""
12651 #. type: Content of: <book><chapter><sect1><sect2><para>
12652 #: ../en/ch10-hook.xml:122
12653 msgid ""
12654 "If you are working with a repository owned by another user, Mercurial can run "
12655 "hooks defined in that user's repository, but it will still run them as "
12656 "<quote>you</quote>. For example, if you <command role=\"hg-cmd\">hg pull</"
12657 "command> from that repository, and its <filename role=\"special\">.hg/hgrc</"
12658 "filename> defines a local <literal role=\"hook\">outgoing</literal> hook, "
12659 "that hook will run under your user account, even though you don't own that "
12660 "repository."
12661 msgstr ""
12663 #. type: Content of: <book><chapter><sect1><sect2><note><para>
12664 #: ../en/ch10-hook.xml:134
12665 msgid ""
12666 "This only applies if you are pulling from a repository on a local or network "
12667 "filesystem. If you're pulling over http or ssh, any <literal role=\"hook"
12668 "\">outgoing</literal> hook will run under whatever account is executing the "
12669 "server process, on the server."
12670 msgstr ""
12672 #. type: Content of: <book><chapter><sect1><sect2><para>
12673 #: ../en/ch10-hook.xml:142
12674 msgid ""
12675 "To see what hooks are defined in a repository, use the <command role=\"hg-cmd"
12676 "\">hg showconfig hooks</command> command. If you are working in one "
12677 "repository, but talking to another that you do not own (e.g. using <command "
12678 "role=\"hg-cmd\">hg pull</command> or <command role=\"hg-cmd\">hg incoming</"
12679 "command>), remember that it is the other repository's hooks you should be "
12680 "checking, not your own."
12681 msgstr ""
12683 #. type: Content of: <book><chapter><sect1><sect2><title>
12684 #: ../en/ch10-hook.xml:153
12685 msgid "Hooks do not propagate"
12686 msgstr "钩子不会传播"
12688 #. type: Content of: <book><chapter><sect1><sect2><para>
12689 #: ../en/ch10-hook.xml:155
12690 msgid ""
12691 "In Mercurial, hooks are not revision controlled, and do not propagate when "
12692 "you clone, or pull from, a repository. The reason for this is simple: a hook "
12693 "is a completely arbitrary piece of executable code. It runs under your user "
12694 "identity, with your privilege level, on your machine."
12695 msgstr ""
12697 #. type: Content of: <book><chapter><sect1><sect2><para>
12698 #: ../en/ch10-hook.xml:162
12699 msgid ""
12700 "It would be extremely reckless for any distributed revision control system to "
12701 "implement revision-controlled hooks, as this would offer an easily "
12702 "exploitable way to subvert the accounts of users of the revision control "
12703 "system."
12704 msgstr ""
12706 #. type: Content of: <book><chapter><sect1><sect2><para>
12707 #: ../en/ch10-hook.xml:168
12708 msgid ""
12709 "Since Mercurial does not propagate hooks, if you are collaborating with other "
12710 "people on a common project, you should not assume that they are using the "
12711 "same Mercurial hooks as you are, or that theirs are correctly configured. "
12712 "You should document the hooks you expect people to use."
12713 msgstr ""
12715 #. type: Content of: <book><chapter><sect1><sect2><para>
12716 #: ../en/ch10-hook.xml:175
12717 msgid ""
12718 "In a corporate intranet, this is somewhat easier to control, as you can for "
12719 "example provide a <quote>standard</quote> installation of Mercurial on an NFS "
12720 "filesystem, and use a site-wide <filename role=\"special\">~/.hgrc</filename> "
12721 "file to define hooks that all users will see. However, this too has its "
12722 "limits; see below."
12723 msgstr ""
12725 #. type: Content of: <book><chapter><sect1><sect2><title>
12726 #: ../en/ch10-hook.xml:184
12727 msgid "Hooks can be overridden"
12728 msgstr "钩子可以被覆盖"
12730 #. type: Content of: <book><chapter><sect1><sect2><para>
12731 #: ../en/ch10-hook.xml:186
12732 msgid ""
12733 "Mercurial allows you to override a hook definition by redefining the hook. "
12734 "You can disable it by setting its value to the empty string, or change its "
12735 "behavior as you wish."
12736 msgstr ""
12738 #. type: Content of: <book><chapter><sect1><sect2><para>
12739 #: ../en/ch10-hook.xml:191
12740 msgid ""
12741 "If you deploy a system- or site-wide <filename role=\"special\">~/.hgrc</"
12742 "filename> file that defines some hooks, you should thus understand that your "
12743 "users can disable or override those hooks."
12744 msgstr ""
12746 #. type: Content of: <book><chapter><sect1><sect2><title>
12747 #: ../en/ch10-hook.xml:199
12748 msgid "Ensuring that critical hooks are run"
12749 msgstr "确保关键钩子的执行"
12751 #. type: Content of: <book><chapter><sect1><sect2><para>
12752 #: ../en/ch10-hook.xml:201
12753 msgid ""
12754 "Sometimes you may want to enforce a policy that you do not want others to be "
12755 "able to work around. For example, you may have a requirement that every "
12756 "changeset must pass a rigorous set of tests. Defining this requirement via a "
12757 "hook in a site-wide <filename role=\"special\">~/.hgrc</filename> won't work "
12758 "for remote users on laptops, and of course local users can subvert it at will "
12759 "by overriding the hook."
12760 msgstr ""
12762 #. type: Content of: <book><chapter><sect1><sect2><para>
12763 #: ../en/ch10-hook.xml:210
12764 msgid ""
12765 "Instead, you can set up your policies for use of Mercurial so that people are "
12766 "expected to propagate changes through a well-known <quote>canonical</quote> "
12767 "server that you have locked down and configured appropriately."
12768 msgstr ""
12770 #. type: Content of: <book><chapter><sect1><sect2><para>
12771 #: ../en/ch10-hook.xml:216
12772 msgid ""
12773 "One way to do this is via a combination of social engineering and "
12774 "technology. Set up a restricted-access account; users can push changes over "
12775 "the network to repositories managed by this account, but they cannot log into "
12776 "the account and run normal shell commands. In this scenario, a user can "
12777 "commit a changeset that contains any old garbage they want."
12778 msgstr ""
12780 #. type: Content of: <book><chapter><sect1><sect2><para>
12781 #: ../en/ch10-hook.xml:225
12782 msgid ""
12783 "When someone pushes a changeset to the server that everyone pulls from, the "
12784 "server will test the changeset before it accepts it as permanent, and reject "
12785 "it if it fails to pass the test suite. If people only pull changes from this "
12786 "filtering server, it will serve to ensure that all changes that people pull "
12787 "have been automatically vetted."
12788 msgstr ""
12790 #. type: Content of: <book><chapter><sect1><title>
12791 #: ../en/ch10-hook.xml:237
12792 msgid "A short tutorial on using hooks"
12793 msgstr "使用钩子的简短指南"
12795 #. type: Content of: <book><chapter><sect1><para>
12796 #: ../en/ch10-hook.xml:239
12797 msgid ""
12798 "It is easy to write a Mercurial hook. Let's start with a hook that runs when "
12799 "you finish a <command role=\"hg-cmd\">hg commit</command>, and simply prints "
12800 "the hash of the changeset you just created. The hook is called <literal role="
12801 "\"hook\">commit</literal>."
12802 msgstr ""
12804 #. type: Content of: <book><chapter><sect1><para>
12805 #: ../en/ch10-hook.xml:246
12806 msgid "All hooks follow the pattern in this example."
12807 msgstr ""
12809 #. type: Content of: <book><chapter><sect1><para>
12810 #: ../en/ch10-hook.xml:250
12811 msgid ""
12812 "You add an entry to the <literal role=\"rc-hooks\">hooks</literal> section of "
12813 "your <filename role=\"special\">~/.hgrc</filename>. On the left is the name "
12814 "of the event to trigger on; on the right is the action to take. As you can "
12815 "see, you can run an arbitrary shell command in a hook. Mercurial passes "
12816 "extra information to the hook using environment variables (look for "
12817 "<envar>HG_NODE</envar> in the example)."
12818 msgstr ""
12820 #. type: Content of: <book><chapter><sect1><sect2><title>
12821 #: ../en/ch10-hook.xml:260
12822 msgid "Performing multiple actions per event"
12823 msgstr "每个事件执行多个操作"
12825 #. type: Content of: <book><chapter><sect1><sect2><para>
12826 #: ../en/ch10-hook.xml:262
12827 msgid ""
12828 "Quite often, you will want to define more than one hook for a particular kind "
12829 "of event, as shown below."
12830 msgstr ""
12832 #. type: Content of: <book><chapter><sect1><sect2><para>
12833 #: ../en/ch10-hook.xml:267
12834 msgid ""
12835 "Mercurial lets you do this by adding an <emphasis>extension</emphasis> to the "
12836 "end of a hook's name. You extend a hook's name by giving the name of the "
12837 "hook, followed by a full stop (the <quote><literal>.</literal></quote> "
12838 "character), followed by some more text of your choosing. For example, "
12839 "Mercurial will run both <literal>commit.foo</literal> and <literal>commit."
12840 "bar</literal> when the <literal>commit</literal> event occurs."
12841 msgstr ""
12843 #. type: Content of: <book><chapter><sect1><sect2><para>
12844 #: ../en/ch10-hook.xml:278
12845 msgid ""
12846 "To give a well-defined order of execution when there are multiple hooks "
12847 "defined for an event, Mercurial sorts hooks by extension, and executes the "
12848 "hook commands in this sorted order. In the above example, it will execute "
12849 "<literal>commit.bar</literal> before <literal>commit.foo</literal>, and "
12850 "<literal>commit</literal> before both."
12851 msgstr ""
12853 #. type: Content of: <book><chapter><sect1><sect2><para>
12854 #: ../en/ch10-hook.xml:287
12855 msgid ""
12856 "It is a good idea to use a somewhat descriptive extension when you define a "
12857 "new hook. This will help you to remember what the hook was for. If the hook "
12858 "fails, you'll get an error message that contains the hook name and extension, "
12859 "so using a descriptive extension could give you an immediate hint as to why "
12860 "the hook failed (see <xref linkend=\"sec:hook:perm\"/> for an example)."
12861 msgstr ""
12863 #. type: Content of: <book><chapter><sect1><sect2><title>
12864 #: ../en/ch10-hook.xml:298
12865 msgid "Controlling whether an activity can proceed"
12866 msgstr "控制处理的活动"
12868 #. type: Content of: <book><chapter><sect1><sect2><para>
12869 #: ../en/ch10-hook.xml:300
12870 msgid ""
12871 "In our earlier examples, we used the <literal role=\"hook\">commit</literal> "
12872 "hook, which is run after a commit has completed. This is one of several "
12873 "Mercurial hooks that run after an activity finishes. Such hooks have no way "
12874 "of influencing the activity itself."
12875 msgstr ""
12877 #. type: Content of: <book><chapter><sect1><sect2><para>
12878 #: ../en/ch10-hook.xml:307
12879 msgid ""
12880 "Mercurial defines a number of events that occur before an activity starts; or "
12881 "after it starts, but before it finishes. Hooks that trigger on these events "
12882 "have the added ability to choose whether the activity can continue, or will "
12883 "abort."
12884 msgstr ""
12886 #. type: Content of: <book><chapter><sect1><sect2><para>
12887 #: ../en/ch10-hook.xml:313
12888 msgid ""
12889 "The <literal role=\"hook\">pretxncommit</literal> hook runs after a commit "
12890 "has all but completed. In other words, the metadata representing the "
12891 "changeset has been written out to disk, but the transaction has not yet been "
12892 "allowed to complete. The <literal role=\"hook\">pretxncommit</literal> hook "
12893 "has the ability to decide whether the transaction can complete, or must be "
12894 "rolled back."
12895 msgstr ""
12897 #. type: Content of: <book><chapter><sect1><sect2><para>
12898 #: ../en/ch10-hook.xml:322
12899 msgid ""
12900 "If the <literal role=\"hook\">pretxncommit</literal> hook exits with a status "
12901 "code of zero, the transaction is allowed to complete; the commit finishes; "
12902 "and the <literal role=\"hook\">commit</literal> hook is run. If the <literal "
12903 "role=\"hook\">pretxncommit</literal> hook exits with a non-zero status code, "
12904 "the transaction is rolled back; the metadata representing the changeset is "
12905 "erased; and the <literal role=\"hook\">commit</literal> hook is not run."
12906 msgstr ""
12908 #. type: Content of: <book><chapter><sect1><sect2><para>
12909 #: ../en/ch10-hook.xml:334
12910 msgid ""
12911 "The hook in the example above checks that a commit comment contains a bug "
12912 "ID. If it does, the commit can complete. If not, the commit is rolled back."
12913 msgstr ""
12915 #. type: Content of: <book><chapter><sect1><title>
12916 #: ../en/ch10-hook.xml:342
12917 msgid "Writing your own hooks"
12918 msgstr "编写钩子"
12920 #. type: Content of: <book><chapter><sect1><para>
12921 #: ../en/ch10-hook.xml:344
12922 msgid ""
12923 "When you are writing a hook, you might find it useful to run Mercurial either "
12924 "with the <option role=\"hg-opt-global\">-v</option> option, or the <envar "
12925 "role=\"rc-item-ui\">verbose</envar> config item set to <quote>true</quote>. "
12926 "When you do so, Mercurial will print a message before it calls each hook."
12927 msgstr ""
12929 #. type: Content of: <book><chapter><sect1><sect2><title>
12930 #: ../en/ch10-hook.xml:353
12931 msgid "Choosing how your hook should run"
12932 msgstr "选择钩子的执行方式"
12934 #. type: Content of: <book><chapter><sect1><sect2><para>
12935 #: ../en/ch10-hook.xml:355
12936 msgid ""
12937 "You can write a hook either as a normal program&emdash;typically a shell "
12938 "script&emdash;or as a Python function that is executed within the Mercurial "
12939 "process."
12940 msgstr ""
12942 #. type: Content of: <book><chapter><sect1><sect2><para>
12943 #: ../en/ch10-hook.xml:360
12944 msgid ""
12945 "Writing a hook as an external program has the advantage that it requires no "
12946 "knowledge of Mercurial's internals. You can call normal Mercurial commands "
12947 "to get any added information you need. The trade-off is that external hooks "
12948 "are slower than in-process hooks."
12949 msgstr ""
12951 #. type: Content of: <book><chapter><sect1><sect2><para>
12952 #: ../en/ch10-hook.xml:367
12953 msgid ""
12954 "An in-process Python hook has complete access to the Mercurial API, and does "
12955 "not <quote>shell out</quote> to another process, so it is inherently faster "
12956 "than an external hook. It is also easier to obtain much of the information "
12957 "that a hook requires by using the Mercurial API than by running Mercurial "
12958 "commands."
12959 msgstr ""
12961 #. type: Content of: <book><chapter><sect1><sect2><para>
12962 #: ../en/ch10-hook.xml:375
12963 msgid ""
12964 "If you are comfortable with Python, or require high performance, writing your "
12965 "hooks in Python may be a good choice. However, when you have a "
12966 "straightforward hook to write and you don't need to care about performance "
12967 "(probably the majority of hooks), a shell script is perfectly fine."
12968 msgstr ""
12970 #. type: Content of: <book><chapter><sect1><sect2><title>
12971 #: ../en/ch10-hook.xml:384
12972 msgid "Hook parameters"
12973 msgstr "钩子的参数"
12975 #. type: Content of: <book><chapter><sect1><sect2><para>
12976 #: ../en/ch10-hook.xml:386
12977 msgid ""
12978 "Mercurial calls each hook with a set of well-defined parameters. In Python, "
12979 "a parameter is passed as a keyword argument to your hook function. For an "
12980 "external program, a parameter is passed as an environment variable."
12981 msgstr ""
12983 #. type: Content of: <book><chapter><sect1><sect2><para>
12984 #: ../en/ch10-hook.xml:392
12985 msgid ""
12986 "Whether your hook is written in Python or as a shell script, the hook-"
12987 "specific parameter names and values will be the same. A boolean parameter "
12988 "will be represented as a boolean value in Python, but as the number 1 (for "
12989 "<quote>true</quote>) or 0 (for <quote>false</quote>) as an environment "
12990 "variable for an external hook. If a hook parameter is named <literal>foo</"
12991 "literal>, the keyword argument for a Python hook will also be named "
12992 "<literal>foo</literal>, while the environment variable for an external hook "
12993 "will be named <literal>HG_FOO</literal>."
12994 msgstr ""
12996 #. type: Content of: <book><chapter><sect1><sect2><title>
12997 #: ../en/ch10-hook.xml:406
12998 msgid "Hook return values and activity control"
12999 msgstr "钩子的返回值与活动控制"
13001 #. type: Content of: <book><chapter><sect1><sect2><para>
13002 #: ../en/ch10-hook.xml:408
13003 msgid ""
13004 "A hook that executes successfully must exit with a status of zero if "
13005 "external, or return boolean <quote>false</quote> if in-process. Failure is "
13006 "indicated with a non-zero exit status from an external hook, or an in-process "
13007 "hook returning boolean <quote>true</quote>. If an in-process hook raises an "
13008 "exception, the hook is considered to have failed."
13009 msgstr ""
13011 #. type: Content of: <book><chapter><sect1><sect2><para>
13012 #: ../en/ch10-hook.xml:416
13013 msgid ""
13014 "For a hook that controls whether an activity can proceed, zero/false means "
13015 "<quote>allow</quote>, while non-zero/true/exception means <quote>deny</quote>."
13016 msgstr ""
13018 #. type: Content of: <book><chapter><sect1><sect2><title>
13019 #: ../en/ch10-hook.xml:423
13020 msgid "Writing an external hook"
13021 msgstr "编写外部钩子"
13023 #. type: Content of: <book><chapter><sect1><sect2><para>
13024 #: ../en/ch10-hook.xml:425
13025 msgid ""
13026 "When you define an external hook in your <filename role=\"special\">~/.hgrc</"
13027 "filename> and the hook is run, its value is passed to your shell, which "
13028 "interprets it. This means that you can use normal shell constructs in the "
13029 "body of the hook."
13030 msgstr ""
13032 #. type: Content of: <book><chapter><sect1><sect2><para>
13033 #: ../en/ch10-hook.xml:432
13034 msgid ""
13035 "An executable hook is always run with its current directory set to a "
13036 "repository's root directory."
13037 msgstr ""
13039 #. type: Content of: <book><chapter><sect1><sect2><para>
13040 #: ../en/ch10-hook.xml:436
13041 msgid ""
13042 "Each hook parameter is passed in as an environment variable; the name is "
13043 "upper-cased, and prefixed with the string <quote><literal>HG_</literal></"
13044 "quote>."
13045 msgstr ""
13047 #. type: Content of: <book><chapter><sect1><sect2><para>
13048 #: ../en/ch10-hook.xml:441
13049 msgid ""
13050 "With the exception of hook parameters, Mercurial does not set or modify any "
13051 "environment variables when running a hook. This is useful to remember if you "
13052 "are writing a site-wide hook that may be run by a number of different users "
13053 "with differing environment variables set. In multi-user situations, you "
13054 "should not rely on environment variables being set to the values you have in "
13055 "your environment when testing the hook."
13056 msgstr ""
13058 #. type: Content of: <book><chapter><sect1><sect2><title>
13059 #: ../en/ch10-hook.xml:452
13060 msgid "Telling Mercurial to use an in-process hook"
13061 msgstr "让 Mercurial 使用进程内钩子"
13063 #. type: Content of: <book><chapter><sect1><sect2><para>
13064 #: ../en/ch10-hook.xml:454
13065 msgid ""
13066 "The <filename role=\"special\">~/.hgrc</filename> syntax for defining an in-"
13067 "process hook is slightly different than for an executable hook. The value of "
13068 "the hook must start with the text <quote><literal>python:</literal></quote>, "
13069 "and continue with the fully-qualified name of a callable object to use as the "
13070 "hook's value."
13071 msgstr ""
13073 #. type: Content of: <book><chapter><sect1><sect2><para>
13074 #: ../en/ch10-hook.xml:462
13075 msgid ""
13076 "The module in which a hook lives is automatically imported when a hook is "
13077 "run. So long as you have the module name and <envar>PYTHONPATH</envar> "
13078 "right, it should <quote>just work</quote>."
13079 msgstr ""
13081 #. type: Content of: <book><chapter><sect1><sect2><para>
13082 #: ../en/ch10-hook.xml:468
13083 msgid ""
13084 "The following <filename role=\"special\">~/.hgrc</filename> example snippet "
13085 "illustrates the syntax and meaning of the notions we just described."
13086 msgstr ""
13088 #. type: Content of: <book><chapter><sect1><sect2><para>
13089 #: ../en/ch10-hook.xml:474
13090 msgid ""
13091 "When Mercurial runs the <literal>commit.example</literal> hook, it imports "
13092 "<literal>mymodule.submodule</literal>, looks for the callable object named "
13093 "<literal>myhook</literal>, and calls it."
13094 msgstr ""
13096 #. type: Content of: <book><chapter><sect1><sect2><title>
13097 #: ../en/ch10-hook.xml:482
13098 msgid "Writing an in-process hook"
13099 msgstr "编写进程内钩子"
13101 #. type: Content of: <book><chapter><sect1><sect2><para>
13102 #: ../en/ch10-hook.xml:484
13103 msgid ""
13104 "The simplest in-process hook does nothing, but illustrates the basic shape of "
13105 "the hook API:"
13106 msgstr ""
13108 #. type: Content of: <book><chapter><sect1><sect2><para>
13109 #: ../en/ch10-hook.xml:489
13110 msgid ""
13111 "The first argument to a Python hook is always a <literal role=\"py-mod-"
13112 "mercurial.ui\">ui</literal> object. The second is a repository object; at "
13113 "the moment, it is always an instance of <literal role=\"py-mod-mercurial."
13114 "localrepo\">localrepository</literal>. Following these two arguments are "
13115 "other keyword arguments. Which ones are passed in depends on the hook being "
13116 "called, but a hook can ignore arguments it doesn't care about by dropping "
13117 "them into a keyword argument dict, as with <literal>**kwargs</literal> above."
13118 msgstr ""
13120 #. type: Content of: <book><chapter><sect1><title>
13121 #: ../en/ch10-hook.xml:504
13122 msgid "Some hook examples"
13123 msgstr "钩子样例"
13125 #. type: Content of: <book><chapter><sect1><sect2><title>
13126 #: ../en/ch10-hook.xml:507
13127 msgid "Writing meaningful commit messages"
13128 msgstr "编写有意义的提交日志"
13130 #. type: Content of: <book><chapter><sect1><sect2><para>
13131 #: ../en/ch10-hook.xml:509
13132 msgid ""
13133 "It's hard to imagine a useful commit message being very short. The simple "
13134 "<literal role=\"hook\">pretxncommit</literal> hook of the example below will "
13135 "prevent you from committing a changeset with a message that is less than ten "
13136 "bytes long."
13137 msgstr ""
13139 #. type: Content of: <book><chapter><sect1><sect2><title>
13140 #: ../en/ch10-hook.xml:519
13141 msgid "Checking for trailing whitespace"
13142 msgstr "检查行尾空格"
13144 #. type: Content of: <book><chapter><sect1><sect2><para>
13145 #: ../en/ch10-hook.xml:521
13146 msgid ""
13147 "An interesting use of a commit-related hook is to help you to write cleaner "
13148 "code. A simple example of <quote>cleaner code</quote> is the dictum that a "
13149 "change should not add any new lines of text that contain <quote>trailing "
13150 "whitespace</quote>. Trailing whitespace is a series of space and tab "
13151 "characters at the end of a line of text. In most cases, trailing whitespace "
13152 "is unnecessary, invisible noise, but it is occasionally problematic, and "
13153 "people often prefer to get rid of it."
13154 msgstr ""
13156 #. type: Content of: <book><chapter><sect1><sect2><para>
13157 #: ../en/ch10-hook.xml:532
13158 msgid ""
13159 "You can use either the <literal role=\"hook\">precommit</literal> or <literal "
13160 "role=\"hook\">pretxncommit</literal> hook to tell whether you have a trailing "
13161 "whitespace problem. If you use the <literal role=\"hook\">precommit</"
13162 "literal> hook, the hook will not know which files you are committing, so it "
13163 "will have to check every modified file in the repository for trailing white "
13164 "space. If you want to commit a change to just the file <filename>foo</"
13165 "filename>, but the file <filename>bar</filename> contains trailing "
13166 "whitespace, doing a check in the <literal role=\"hook\">precommit</literal> "
13167 "hook will prevent you from committing <filename>foo</filename> due to the "
13168 "problem with <filename>bar</filename>. This doesn't seem right."
13169 msgstr ""
13171 #. type: Content of: <book><chapter><sect1><sect2><para>
13172 #: ../en/ch10-hook.xml:548
13173 msgid ""
13174 "Should you choose the <literal role=\"hook\">pretxncommit</literal> hook, the "
13175 "check won't occur until just before the transaction for the commit "
13176 "completes. This will allow you to check for problems only the exact files "
13177 "that are being committed. However, if you entered the commit message "
13178 "interactively and the hook fails, the transaction will roll back; you'll have "
13179 "to re-enter the commit message after you fix the trailing whitespace and run "
13180 "<command role=\"hg-cmd\">hg commit</command> again."
13181 msgstr ""
13183 #. type: Content of: <book><chapter><sect1><sect2><para>
13184 #: ../en/ch10-hook.xml:561
13185 msgid ""
13186 "In this example, we introduce a simple <literal role=\"hook\">pretxncommit</"
13187 "literal> hook that checks for trailing whitespace. This hook is short, but "
13188 "not very helpful. It exits with an error status if a change adds a line with "
13189 "trailing whitespace to any file, but does not print any information that "
13190 "might help us to identify the offending file or line. It also has the nice "
13191 "property of not paying attention to unmodified lines; only lines that "
13192 "introduce new trailing whitespace cause problems."
13193 msgstr ""
13195 #. type: Content of: <book><chapter><sect1><sect2><para>
13196 #: ../en/ch10-hook.xml:574
13197 msgid ""
13198 "The above version is much more complex, but also more useful. It parses a "
13199 "unified diff to see if any lines add trailing whitespace, and prints the name "
13200 "of the file and the line number of each such occurrence. Even better, if the "
13201 "change adds trailing whitespace, this hook saves the commit comment and "
13202 "prints the name of the save file before exiting and telling Mercurial to roll "
13203 "the transaction back, so you can use the <option role=\"hg-opt-commit\">-l "
13204 "filename</option> option to <command role=\"hg-cmd\">hg commit</command> to "
13205 "reuse the saved commit message once you've corrected the problem."
13206 msgstr ""
13208 #. type: Content of: <book><chapter><sect1><sect2><para>
13209 #: ../en/ch10-hook.xml:588
13210 msgid ""
13211 "As a final aside, note in the example above the use of <command>sed</"
13212 "command>'s in-place editing feature to get rid of trailing whitespace from a "
13213 "file. This is concise and useful enough that I will reproduce it here (using "
13214 "<command>perl</command> for good measure)."
13215 msgstr ""
13217 #. type: Content of: <book><chapter><sect1><title>
13218 #: ../en/ch10-hook.xml:598
13219 msgid "Bundled hooks"
13220 msgstr "内置的钩子"
13222 #. type: Content of: <book><chapter><sect1><para>
13223 #: ../en/ch10-hook.xml:600
13224 msgid ""
13225 "Mercurial ships with several bundled hooks. You can find them in the "
13226 "<filename class=\"directory\">hgext</filename> directory of a Mercurial "
13227 "source tree. If you are using a Mercurial binary package, the hooks will be "
13228 "located in the <filename class=\"directory\">hgext</filename> directory of "
13229 "wherever your package installer put Mercurial."
13230 msgstr ""
13232 #. type: Content of: <book><chapter><sect1><sect2><title>
13233 #: ../en/ch10-hook.xml:609
13234 msgid ""
13235 "<literal role=\"hg-ext\">acl</literal>&emdash;access control for parts of a "
13236 "repository"
13237 msgstr "<literal role=\"hg-ext\">acl</literal>—版本库的访问控制"
13239 #. type: Content of: <book><chapter><sect1><sect2><para>
13240 #: ../en/ch10-hook.xml:612
13241 msgid ""
13242 "The <literal role=\"hg-ext\">acl</literal> extension lets you control which "
13243 "remote users are allowed to push changesets to a networked server. You can "
13244 "protect any portion of a repository (including the entire repo), so that a "
13245 "specific remote user can push changes that do not affect the protected "
13246 "portion."
13247 msgstr ""
13249 #. type: Content of: <book><chapter><sect1><sect2><para>
13250 #: ../en/ch10-hook.xml:620
13251 msgid ""
13252 "This extension implements access control based on the identity of the user "
13253 "performing a push, <emphasis>not</emphasis> on who committed the changesets "
13254 "they're pushing. It makes sense to use this hook only if you have a locked-"
13255 "down server environment that authenticates remote users, and you want to be "
13256 "sure that only specific users are allowed to push changes to that server."
13257 msgstr ""
13259 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
13260 #: ../en/ch10-hook.xml:630
13261 msgid "Configuring the <literal role=\"hook\">acl</literal> hook"
13262 msgstr "配置 <literal role=\"hook\">acl</literal> 钩子"
13264 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13265 #: ../en/ch10-hook.xml:633
13266 msgid ""
13267 "In order to manage incoming changesets, the <literal role=\"hg-ext\">acl</"
13268 "literal> hook must be used as a <literal role=\"hook\">pretxnchangegroup</"
13269 "literal> hook. This lets it see which files are modified by each incoming "
13270 "changeset, and roll back a group of changesets if they modify "
13271 "<quote>forbidden</quote> files. Example:"
13272 msgstr ""
13274 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13275 #: ../en/ch10-hook.xml:643
13276 msgid ""
13277 "The <literal role=\"hg-ext\">acl</literal> extension is configured using "
13278 "three sections."
13279 msgstr ""
13281 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13282 #: ../en/ch10-hook.xml:647
13283 msgid ""
13284 "The <literal role=\"rc-acl\">acl</literal> section has only one entry, <envar "
13285 "role=\"rc-item-acl\">sources</envar>, which lists the sources of incoming "
13286 "changesets that the hook should pay attention to. You don't normally need to "
13287 "configure this section."
13288 msgstr ""
13290 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13291 #: ../en/ch10-hook.xml:654
13292 msgid ""
13293 "<envar role=\"rc-item-acl\">serve</envar>: Control incoming changesets that "
13294 "are arriving from a remote repository over http or ssh. This is the default "
13295 "value of <envar role=\"rc-item-acl\">sources</envar>, and usually the only "
13296 "setting you'll need for this configuration item."
13297 msgstr ""
13299 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13300 #: ../en/ch10-hook.xml:662
13301 msgid ""
13302 "<envar role=\"rc-item-acl\">pull</envar>: Control incoming changesets that "
13303 "are arriving via a pull from a local repository."
13304 msgstr ""
13306 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13307 #: ../en/ch10-hook.xml:667
13308 msgid ""
13309 "<envar role=\"rc-item-acl\">push</envar>: Control incoming changesets that "
13310 "are arriving via a push from a local repository."
13311 msgstr ""
13313 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13314 #: ../en/ch10-hook.xml:672
13315 msgid ""
13316 "<envar role=\"rc-item-acl\">bundle</envar>: Control incoming changesets that "
13317 "are arriving from another repository via a bundle."
13318 msgstr ""
13320 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13321 #: ../en/ch10-hook.xml:678
13322 msgid ""
13323 "The <literal role=\"rc-acl.allow\">acl.allow</literal> section controls the "
13324 "users that are allowed to add changesets to the repository. If this section "
13325 "is not present, all users that are not explicitly denied are allowed. If "
13326 "this section is present, all users that are not explicitly allowed are denied "
13327 "(so an empty section means that all users are denied)."
13328 msgstr ""
13330 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13331 #: ../en/ch10-hook.xml:687
13332 msgid ""
13333 "The <literal role=\"rc-acl.deny\">acl.deny</literal> section determines which "
13334 "users are denied from adding changesets to the repository. If this section "
13335 "is not present or is empty, no users are denied."
13336 msgstr ""
13338 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13339 #: ../en/ch10-hook.xml:693
13340 msgid ""
13341 "The syntaxes for the <literal role=\"rc-acl.allow\">acl.allow</literal> and "
13342 "<literal role=\"rc-acl.deny\">acl.deny</literal> sections are identical. On "
13343 "the left of each entry is a glob pattern that matches files or directories, "
13344 "relative to the root of the repository; on the right, a user name."
13345 msgstr ""
13347 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13348 #: ../en/ch10-hook.xml:701
13349 msgid ""
13350 "In the following example, the user <literal>docwriter</literal> can only push "
13351 "changes to the <filename class=\"directory\">docs</filename> subtree of the "
13352 "repository, while <literal>intern</literal> can push changes to any file or "
13353 "directory except <filename class=\"directory\">source/sensitive</filename>."
13354 msgstr ""
13356 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
13357 #: ../en/ch10-hook.xml:715 ../en/ch10-hook.xml:979 ../en/ch10-hook.xml:1169
13358 msgid "Testing and troubleshooting"
13359 msgstr "测试与问题处理"
13361 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13362 #: ../en/ch10-hook.xml:717
13363 msgid ""
13364 "If you want to test the <literal role=\"hg-ext\">acl</literal> hook, run it "
13365 "with Mercurial's debugging output enabled. Since you'll probably be running "
13366 "it on a server where it's not convenient (or sometimes possible) to pass in "
13367 "the <option role=\"hg-opt-global\">--debug</option> option, don't forget that "
13368 "you can enable debugging output in your <filename role=\"special\">~/.hgrc</"
13369 "filename>:"
13370 msgstr ""
13372 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13373 #: ../en/ch10-hook.xml:728
13374 msgid ""
13375 "With this enabled, the <literal role=\"hg-ext\">acl</literal> hook will print "
13376 "enough information to let you figure out why it is allowing or forbidding "
13377 "pushes from specific users."
13378 msgstr ""
13380 #. type: Content of: <book><chapter><sect1><sect2><title>
13381 #: ../en/ch10-hook.xml:737
13382 msgid ""
13383 "<literal role=\"hg-ext\">bugzilla</literal>&emdash;integration with Bugzilla"
13384 msgstr "<literal role=\"hg-ext\">bugzilla</literal>—与 Bugzilla 的集成"
13386 #. type: Content of: <book><chapter><sect1><sect2><para>
13387 #: ../en/ch10-hook.xml:741
13388 msgid ""
13389 "The <literal role=\"hg-ext\">bugzilla</literal> extension adds a comment to a "
13390 "Bugzilla bug whenever it finds a reference to that bug ID in a commit "
13391 "comment. You can install this hook on a shared server, so that any time a "
13392 "remote user pushes changes to this server, the hook gets run."
13393 msgstr ""
13395 #. type: Content of: <book><chapter><sect1><sect2><para>
13396 #: ../en/ch10-hook.xml:748
13397 msgid ""
13398 "It adds a comment to the bug that looks like this (you can configure the "
13399 "contents of the comment&emdash;see below):"
13400 msgstr ""
13402 #. type: Content of: <book><chapter><sect1><sect2><para>
13403 #: ../en/ch10-hook.xml:757
13404 msgid ""
13405 "The value of this hook is that it automates the process of updating a bug any "
13406 "time a changeset refers to it. If you configure the hook properly, it makes "
13407 "it easy for people to browse straight from a Bugzilla bug to a changeset that "
13408 "refers to that bug."
13409 msgstr ""
13411 #. type: Content of: <book><chapter><sect1><sect2><para>
13412 #: ../en/ch10-hook.xml:764
13413 msgid ""
13414 "You can use the code in this hook as a starting point for some more exotic "
13415 "Bugzilla integration recipes. Here are a few possibilities:"
13416 msgstr ""
13418 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13419 #: ../en/ch10-hook.xml:769
13420 msgid ""
13421 "Require that every changeset pushed to the server have a valid bug ID in its "
13422 "commit comment. In this case, you'd want to configure the hook as a <literal "
13423 "role=\"hook\">pretxncommit</literal> hook. This would allow the hook to "
13424 "reject changes that didn't contain bug IDs."
13425 msgstr ""
13427 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13428 #: ../en/ch10-hook.xml:777
13429 msgid ""
13430 "Allow incoming changesets to automatically modify the <emphasis>state</"
13431 "emphasis> of a bug, as well as simply adding a comment. For example, the "
13432 "hook could recognise the string <quote>fixed bug 31337</quote> as indicating "
13433 "that it should update the state of bug 31337 to <quote>requires testing</"
13434 "quote>."
13435 msgstr ""
13437 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
13438 #: ../en/ch10-hook.xml:787
13439 msgid "Configuring the <literal role=\"hook\">bugzilla</literal> hook"
13440 msgstr "配置 <literal role=\"hook\">bugzilla</literal> 钩子"
13442 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13443 #: ../en/ch10-hook.xml:790
13444 msgid ""
13445 "You should configure this hook in your server's <filename role=\"special\">~/."
13446 "hgrc</filename> as an <literal role=\"hook\">incoming</literal> hook, for "
13447 "example as follows:"
13448 msgstr ""
13450 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13451 #: ../en/ch10-hook.xml:798
13452 msgid ""
13453 "Because of the specialised nature of this hook, and because Bugzilla was not "
13454 "written with this kind of integration in mind, configuring this hook is a "
13455 "somewhat involved process."
13456 msgstr ""
13458 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13459 #: ../en/ch10-hook.xml:804
13460 msgid ""
13461 "Before you begin, you must install the MySQL bindings for Python on the host"
13462 "(s) where you'll be running the hook. If this is not available as a binary "
13463 "package for your system, you can download it from <citation>web:mysql-python</"
13464 "citation>."
13465 msgstr ""
13467 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13468 #: ../en/ch10-hook.xml:811
13469 msgid ""
13470 "Configuration information for this hook lives in the <literal role=\"rc-"
13471 "bugzilla\">bugzilla</literal> section of your <filename role=\"special\">~/."
13472 "hgrc</filename>."
13473 msgstr ""
13475 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13476 #: ../en/ch10-hook.xml:816
13477 msgid ""
13478 "<envar role=\"rc-item-bugzilla\">version</envar>: The version of Bugzilla "
13479 "installed on the server. The database schema that Bugzilla uses changes "
13480 "occasionally, so this hook has to know exactly which schema to use."
13481 msgstr ""
13483 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13484 #: ../en/ch10-hook.xml:822
13485 msgid ""
13486 "<envar role=\"rc-item-bugzilla\">host</envar>: The hostname of the MySQL "
13487 "server that stores your Bugzilla data. The database must be configured to "
13488 "allow connections from whatever host you are running the <literal role=\"hook"
13489 "\">bugzilla</literal> hook on."
13490 msgstr ""
13492 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13493 #: ../en/ch10-hook.xml:829
13494 msgid ""
13495 "<envar role=\"rc-item-bugzilla\">user</envar>: The username with which to "
13496 "connect to the MySQL server. The database must be configured to allow this "
13497 "user to connect from whatever host you are running the <literal role=\"hook"
13498 "\">bugzilla</literal> hook on. This user must be able to access and modify "
13499 "Bugzilla tables. The default value of this item is <literal>bugs</literal>, "
13500 "which is the standard name of the Bugzilla user in a MySQL database."
13501 msgstr ""
13503 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13504 #: ../en/ch10-hook.xml:840
13505 msgid ""
13506 "<envar role=\"rc-item-bugzilla\">password</envar>: The MySQL password for the "
13507 "user you configured above. This is stored as plain text, so you should make "
13508 "sure that unauthorised users cannot read the <filename role=\"special\">~/."
13509 "hgrc</filename> file where you store this information."
13510 msgstr ""
13512 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13513 #: ../en/ch10-hook.xml:849
13514 msgid ""
13515 "<envar role=\"rc-item-bugzilla\">db</envar>: The name of the Bugzilla "
13516 "database on the MySQL server. The default value of this item is "
13517 "<literal>bugs</literal>, which is the standard name of the MySQL database "
13518 "where Bugzilla stores its data."
13519 msgstr ""
13521 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13522 #: ../en/ch10-hook.xml:856
13523 msgid ""
13524 "<envar role=\"rc-item-bugzilla\">notify</envar>: If you want Bugzilla to send "
13525 "out a notification email to subscribers after this hook has added a comment "
13526 "to a bug, you will need this hook to run a command whenever it updates the "
13527 "database. The command to run depends on where you have installed Bugzilla, "
13528 "but it will typically look something like this, if you have Bugzilla "
13529 "installed in <filename class=\"directory\">/var/www/html/bugzilla</filename>:"
13530 msgstr ""
13532 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13533 #: ../en/ch10-hook.xml:869
13534 msgid ""
13535 "The Bugzilla <literal>processmail</literal> program expects to be given a bug "
13536 "ID (the hook replaces <quote><literal>%s</literal></quote> with the bug ID) "
13537 "and an email address. It also expects to be able to write to some files in "
13538 "the directory that it runs in. If Bugzilla and this hook are not installed "
13539 "on the same machine, you will need to find a way to run <literal>processmail</"
13540 "literal> on the server where Bugzilla is installed."
13541 msgstr ""
13543 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
13544 #: ../en/ch10-hook.xml:884
13545 msgid "Mapping committer names to Bugzilla user names"
13546 msgstr "提交者的名称与 Bugzilla 用户名称的映射"
13548 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13549 #: ../en/ch10-hook.xml:886
13550 msgid ""
13551 "By default, the <literal role=\"hg-ext\">bugzilla</literal> hook tries to use "
13552 "the email address of a changeset's committer as the Bugzilla user name with "
13553 "which to update a bug. If this does not suit your needs, you can map "
13554 "committer email addresses to Bugzilla user names using a <literal role=\"rc-"
13555 "usermap\">usermap</literal> section."
13556 msgstr ""
13558 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13559 #: ../en/ch10-hook.xml:895
13560 msgid ""
13561 "Each item in the <literal role=\"rc-usermap\">usermap</literal> section "
13562 "contains an email address on the left, and a Bugzilla user name on the right."
13563 msgstr ""
13565 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13566 #: ../en/ch10-hook.xml:902
13567 msgid ""
13568 "You can either keep the <literal role=\"rc-usermap\">usermap</literal> data "
13569 "in a normal <filename role=\"special\">~/.hgrc</filename>, or tell the "
13570 "<literal role=\"hg-ext\">bugzilla</literal> hook to read the information from "
13571 "an external <filename>usermap</filename> file. In the latter case, you can "
13572 "store <filename>usermap</filename> data by itself in (for example) a user-"
13573 "modifiable repository. This makes it possible to let your users maintain "
13574 "their own <envar role=\"rc-item-bugzilla\">usermap</envar> entries. The main "
13575 "<filename role=\"special\">~/.hgrc</filename> file might look like this:"
13576 msgstr ""
13578 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13579 #: ../en/ch10-hook.xml:918
13580 msgid ""
13581 "While the <filename>usermap</filename> file that it refers to might look like "
13582 "this:"
13583 msgstr ""
13585 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
13586 #: ../en/ch10-hook.xml:926
13587 msgid "Configuring the text that gets added to a bug"
13588 msgstr "配置增加到问题中的正文"
13590 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13591 #: ../en/ch10-hook.xml:928
13592 msgid ""
13593 "You can configure the text that this hook adds as a comment; you specify it "
13594 "in the form of a Mercurial template. Several <filename role=\"special\">~/."
13595 "hgrc</filename> entries (still in the <literal role=\"rc-bugzilla\">bugzilla</"
13596 "literal> section) control this behavior."
13597 msgstr ""
13599 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13600 #: ../en/ch10-hook.xml:935
13601 msgid ""
13602 "<literal>strip</literal>: The number of leading path elements to strip from a "
13603 "repository's path name to construct a partial path for a URL. For example, if "
13604 "the repositories on your server live under <filename class=\"directory\">/"
13605 "home/hg/repos</filename>, and you have a repository whose path is <filename "
13606 "class=\"directory\">/home/hg/repos/app/tests</filename>, then setting "
13607 "<literal>strip</literal> to <literal>4</literal> will give a partial path of "
13608 "<filename class=\"directory\">app/tests</filename>. The hook will make this "
13609 "partial path available when expanding a template, as <literal>webroot</"
13610 "literal>."
13611 msgstr ""
13613 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13614 #: ../en/ch10-hook.xml:949
13615 msgid ""
13616 "<literal>template</literal>: The text of the template to use. In addition to "
13617 "the usual changeset-related variables, this template can use <literal>hgweb</"
13618 "literal> (the value of the <literal>hgweb</literal> configuration item above) "
13619 "and <literal>webroot</literal> (the path constructed using <literal>strip</"
13620 "literal> above)."
13621 msgstr ""
13623 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13624 #: ../en/ch10-hook.xml:959
13625 msgid ""
13626 "In addition, you can add a <envar role=\"rc-item-web\">baseurl</envar> item "
13627 "to the <literal role=\"rc-web\">web</literal> section of your <filename role="
13628 "\"special\">~/.hgrc</filename>. The <literal role=\"hg-ext\">bugzilla</"
13629 "literal> hook will make this available when expanding a template, as the base "
13630 "string to use when constructing a URL that will let users browse from a "
13631 "Bugzilla comment to view a changeset. Example:"
13632 msgstr ""
13634 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13635 #: ../en/ch10-hook.xml:971
13636 msgid ""
13637 "Here is an example set of <literal role=\"hg-ext\">bugzilla</literal> hook "
13638 "config information."
13639 msgstr ""
13641 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13642 #: ../en/ch10-hook.xml:981
13643 msgid ""
13644 "The most common problems with configuring the <literal role=\"hg-ext"
13645 "\">bugzilla</literal> hook relate to running Bugzilla's "
13646 "<filename>processmail</filename> script and mapping committer names to user "
13647 "names."
13648 msgstr ""
13650 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13651 #: ../en/ch10-hook.xml:987
13652 msgid ""
13653 "Recall from <xref linkend=\"sec:hook:bugzilla:config\"/> above that the user "
13654 "that runs the Mercurial process on the server is also the one that will run "
13655 "the <filename>processmail</filename> script. The <filename>processmail</"
13656 "filename> script sometimes causes Bugzilla to write to files in its "
13657 "configuration directory, and Bugzilla's configuration files are usually owned "
13658 "by the user that your web server runs under."
13659 msgstr ""
13661 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13662 #: ../en/ch10-hook.xml:998
13663 msgid ""
13664 "You can cause <filename>processmail</filename> to be run with the suitable "
13665 "user's identity using the <command>sudo</command> command. Here is an "
13666 "example entry for a <filename>sudoers</filename> file."
13667 msgstr ""
13669 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13670 #: ../en/ch10-hook.xml:1005
13671 msgid ""
13672 "This allows the <literal>hg_user</literal> user to run a "
13673 "<filename>processmail-wrapper</filename> program under the identity of "
13674 "<literal>httpd_user</literal>."
13675 msgstr ""
13677 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13678 #: ../en/ch10-hook.xml:1010
13679 msgid ""
13680 "This indirection through a wrapper script is necessary, because "
13681 "<filename>processmail</filename> expects to be run with its current directory "
13682 "set to wherever you installed Bugzilla; you can't specify that kind of "
13683 "constraint in a <filename>sudoers</filename> file. The contents of the "
13684 "wrapper script are simple:"
13685 msgstr ""
13687 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13688 #: ../en/ch10-hook.xml:1019
13689 msgid ""
13690 "It doesn't seem to matter what email address you pass to "
13691 "<filename>processmail</filename>."
13692 msgstr ""
13694 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13695 #: ../en/ch10-hook.xml:1023
13696 msgid ""
13697 "If your <literal role=\"rc-usermap\">usermap</literal> is not set up "
13698 "correctly, users will see an error message from the <literal role=\"hg-ext"
13699 "\">bugzilla</literal> hook when they push changes to the server. The error "
13700 "message will look like this:"
13701 msgstr ""
13703 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13704 #: ../en/ch10-hook.xml:1030
13705 msgid ""
13706 "What this means is that the committer's address, <literal>john.q."
13707 "public@example.com</literal>, is not a valid Bugzilla user name, nor does it "
13708 "have an entry in your <literal role=\"rc-usermap\">usermap</literal> that "
13709 "maps it to a valid Bugzilla user name."
13710 msgstr ""
13712 #. type: Content of: <book><chapter><sect1><sect2><title>
13713 #: ../en/ch10-hook.xml:1040
13714 msgid ""
13715 "<literal role=\"hg-ext\">notify</literal>&emdash;send email notifications"
13716 msgstr "<literal role=\"hg-ext\">notify</literal>—邮件通知"
13718 #. type: Content of: <book><chapter><sect1><sect2><para>
13719 #: ../en/ch10-hook.xml:1043
13720 msgid ""
13721 "Although Mercurial's built-in web server provides RSS feeds of changes in "
13722 "every repository, many people prefer to receive change notifications via "
13723 "email. The <literal role=\"hg-ext\">notify</literal> hook lets you send out "
13724 "notifications to a set of email addresses whenever changesets arrive that "
13725 "those subscribers are interested in."
13726 msgstr ""
13728 #. type: Content of: <book><chapter><sect1><sect2><para>
13729 #: ../en/ch10-hook.xml:1051
13730 msgid ""
13731 "As with the <literal role=\"hg-ext\">bugzilla</literal> hook, the <literal "
13732 "role=\"hg-ext\">notify</literal> hook is template-driven, so you can "
13733 "customise the contents of the notification messages that it sends."
13734 msgstr ""
13736 #. type: Content of: <book><chapter><sect1><sect2><para>
13737 #: ../en/ch10-hook.xml:1057
13738 msgid ""
13739 "By default, the <literal role=\"hg-ext\">notify</literal> hook includes a "
13740 "diff of every changeset that it sends out; you can limit the size of the "
13741 "diff, or turn this feature off entirely. It is useful for letting "
13742 "subscribers review changes immediately, rather than clicking to follow a URL."
13743 msgstr ""
13745 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
13746 #: ../en/ch10-hook.xml:1065
13747 msgid "Configuring the <literal role=\"hg-ext\">notify</literal> hook"
13748 msgstr "配置 <literal role=\"hg-ext\">notify</literal> 钩子"
13750 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13751 #: ../en/ch10-hook.xml:1068
13752 msgid ""
13753 "You can set up the <literal role=\"hg-ext\">notify</literal> hook to send one "
13754 "email message per incoming changeset, or one per incoming group of changesets "
13755 "(all those that arrived in a single pull or push)."
13756 msgstr ""
13758 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13759 #: ../en/ch10-hook.xml:1080
13760 msgid ""
13761 "Configuration information for this hook lives in the <literal role=\"rc-notify"
13762 "\">notify</literal> section of a <filename role=\"special\">~/.hgrc</"
13763 "filename> file."
13764 msgstr ""
13766 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13767 #: ../en/ch10-hook.xml:1085
13768 msgid ""
13769 "<envar role=\"rc-item-notify\">test</envar>: By default, this hook does not "
13770 "send out email at all; instead, it prints the message that it "
13771 "<emphasis>would</emphasis> send. Set this item to <literal>false</literal> "
13772 "to allow email to be sent. The reason that sending of email is turned off by "
13773 "default is that it takes several tries to configure this extension exactly as "
13774 "you would like, and it would be bad form to spam subscribers with a number of "
13775 "<quote>broken</quote> notifications while you debug your configuration."
13776 msgstr ""
13778 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13779 #: ../en/ch10-hook.xml:1097
13780 msgid ""
13781 "<envar role=\"rc-item-notify\">config</envar>: The path to a configuration "
13782 "file that contains subscription information. This is kept separate from the "
13783 "main <filename role=\"special\">~/.hgrc</filename> so that you can maintain "
13784 "it in a repository of its own. People can then clone that repository, update "
13785 "their subscriptions, and push the changes back to your server."
13786 msgstr ""
13788 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13789 #: ../en/ch10-hook.xml:1106
13790 msgid ""
13791 "<envar role=\"rc-item-notify\">strip</envar>: The number of leading path "
13792 "separator characters to strip from a repository's path, when deciding whether "
13793 "a repository has subscribers. For example, if the repositories on your "
13794 "server live in <filename class=\"directory\">/home/hg/repos</filename>, and "
13795 "<literal role=\"hg-ext\">notify</literal> is considering a repository named "
13796 "<filename class=\"directory\">/home/hg/repos/shared/test</filename>, setting "
13797 "<envar role=\"rc-item-notify\">strip</envar> to <literal>4</literal> will "
13798 "cause <literal role=\"hg-ext\">notify</literal> to trim the path it considers "
13799 "down to <filename class=\"directory\">shared/test</filename>, and it will "
13800 "match subscribers against that."
13801 msgstr ""
13803 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13804 #: ../en/ch10-hook.xml:1123
13805 msgid ""
13806 "<envar role=\"rc-item-notify\">template</envar>: The template text to use "
13807 "when sending messages. This specifies both the contents of the message "
13808 "header and its body."
13809 msgstr ""
13811 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13812 #: ../en/ch10-hook.xml:1129
13813 msgid ""
13814 "<envar role=\"rc-item-notify\">maxdiff</envar>: The maximum number of lines "
13815 "of diff data to append to the end of a message. If a diff is longer than "
13816 "this, it is truncated. By default, this is set to 300. Set this to "
13817 "<literal>0</literal> to omit diffs from notification emails."
13818 msgstr ""
13820 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13821 #: ../en/ch10-hook.xml:1138
13822 msgid ""
13823 "<envar role=\"rc-item-notify\">sources</envar>: A list of sources of "
13824 "changesets to consider. This lets you limit <literal role=\"hg-ext\">notify</"
13825 "literal> to only sending out email about changes that remote users pushed "
13826 "into this repository via a server, for example. See <xref linkend=\"sec:hook:"
13827 "sources\"/> for the sources you can specify here."
13828 msgstr ""
13830 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13831 #: ../en/ch10-hook.xml:1149
13832 msgid ""
13833 "If you set the <envar role=\"rc-item-web\">baseurl</envar> item in the "
13834 "<literal role=\"rc-web\">web</literal> section, you can use it in a template; "
13835 "it will be available as <literal>webroot</literal>."
13836 msgstr ""
13838 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13839 #: ../en/ch10-hook.xml:1155
13840 msgid ""
13841 "Here is an example set of <literal role=\"hg-ext\">notify</literal> "
13842 "configuration information."
13843 msgstr ""
13845 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13846 #: ../en/ch10-hook.xml:1161
13847 msgid "This will produce a message that looks like the following:"
13848 msgstr ""
13850 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13851 #: ../en/ch10-hook.xml:1171
13852 msgid ""
13853 "Do not forget that by default, the <literal role=\"hg-ext\">notify</literal> "
13854 "extension <emphasis>will not send any mail</emphasis> until you explicitly "
13855 "configure it to do so, by setting <envar role=\"rc-item-notify\">test</envar> "
13856 "to <literal>false</literal>. Until you do that, it simply prints the message "
13857 "it <emphasis>would</emphasis> send."
13858 msgstr ""
13860 #. type: Content of: <book><chapter><sect1><title>
13861 #: ../en/ch10-hook.xml:1183
13862 msgid "Information for writers of hooks"
13863 msgstr "编写钩子的信息"
13865 #. type: Content of: <book><chapter><sect1><sect2><title>
13866 #: ../en/ch10-hook.xml:1186
13867 msgid "In-process hook execution"
13868 msgstr "进程内钩子的执行"
13870 #. type: Content of: <book><chapter><sect1><sect2><para>
13871 #: ../en/ch10-hook.xml:1188
13872 msgid "An in-process hook is called with arguments of the following form:"
13873 msgstr ""
13875 #. type: Content of: <book><chapter><sect1><sect2><para>
13876 #: ../en/ch10-hook.xml:1192
13877 msgid ""
13878 "The <literal>ui</literal> parameter is a <literal role=\"py-mod-mercurial.ui"
13879 "\">ui</literal> object. The <literal>repo</literal> parameter is a <literal "
13880 "role=\"py-mod-mercurial.localrepo\">localrepository</literal> object. The "
13881 "names and values of the <literal>**kwargs</literal> parameters depend on the "
13882 "hook being invoked, with the following common features:"
13883 msgstr ""
13885 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13886 #: ../en/ch10-hook.xml:1201
13887 msgid ""
13888 "If a parameter is named <literal>node</literal> or <literal>parentN</"
13889 "literal>, it will contain a hexadecimal changeset ID. The empty string is "
13890 "used to represent <quote>null changeset ID</quote> instead of a string of "
13891 "zeroes."
13892 msgstr ""
13894 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13895 #: ../en/ch10-hook.xml:1208
13896 msgid ""
13897 "If a parameter is named <literal>url</literal>, it will contain the URL of a "
13898 "remote repository, if that can be determined."
13899 msgstr ""
13901 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13902 #: ../en/ch10-hook.xml:1213
13903 msgid ""
13904 "Boolean-valued parameters are represented as Python <literal>bool</literal> "
13905 "objects."
13906 msgstr ""
13908 #. type: Content of: <book><chapter><sect1><sect2><para>
13909 #: ../en/ch10-hook.xml:1218
13910 msgid ""
13911 "An in-process hook is called without a change to the process's working "
13912 "directory (unlike external hooks, which are run in the root of the "
13913 "repository). It must not change the process's working directory, or it will "
13914 "cause any calls it makes into the Mercurial API to fail."
13915 msgstr ""
13917 #. type: Content of: <book><chapter><sect1><sect2><para>
13918 #: ../en/ch10-hook.xml:1225
13919 msgid ""
13920 "If a hook returns a boolean <quote>false</quote> value, it is considered to "
13921 "have succeeded. If it returns a boolean <quote>true</quote> value or raises "
13922 "an exception, it is considered to have failed. A useful way to think of the "
13923 "calling convention is <quote>tell me if you fail</quote>."
13924 msgstr ""
13926 #. type: Content of: <book><chapter><sect1><sect2><para>
13927 #: ../en/ch10-hook.xml:1232
13928 msgid ""
13929 "Note that changeset IDs are passed into Python hooks as hexadecimal strings, "
13930 "not the binary hashes that Mercurial's APIs normally use. To convert a hash "
13931 "from hex to binary, use the <literal>bin</literal> function."
13932 msgstr ""
13934 #. type: Content of: <book><chapter><sect1><sect2><title>
13935 #: ../en/ch10-hook.xml:1240
13936 msgid "External hook execution"
13937 msgstr "外部钩子的执行"
13939 #. type: Content of: <book><chapter><sect1><sect2><para>
13940 #: ../en/ch10-hook.xml:1242
13941 msgid ""
13942 "An external hook is passed to the shell of the user running Mercurial. "
13943 "Features of that shell, such as variable substitution and command "
13944 "redirection, are available. The hook is run in the root directory of the "
13945 "repository (unlike in-process hooks, which are run in the same directory that "
13946 "Mercurial was run in)."
13947 msgstr ""
13949 #. type: Content of: <book><chapter><sect1><sect2><para>
13950 #: ../en/ch10-hook.xml:1250
13951 msgid ""
13952 "Hook parameters are passed to the hook as environment variables. Each "
13953 "environment variable's name is converted in upper case and prefixed with the "
13954 "string <quote><literal>HG_</literal></quote>. For example, if the name of a "
13955 "parameter is <quote><literal>node</literal></quote>, the name of the "
13956 "environment variable representing that parameter will be "
13957 "<quote><literal>HG_NODE</literal></quote>."
13958 msgstr ""
13960 #. type: Content of: <book><chapter><sect1><sect2><para>
13961 #: ../en/ch10-hook.xml:1259
13962 msgid ""
13963 "A boolean parameter is represented as the string <quote><literal>1</literal></"
13964 "quote> for <quote>true</quote>, <quote><literal>0</literal></quote> for "
13965 "<quote>false</quote>. If an environment variable is named <envar>HG_NODE</"
13966 "envar>, <envar>HG_PARENT1</envar> or <envar>HG_PARENT2</envar>, it contains a "
13967 "changeset ID represented as a hexadecimal string. The empty string is used "
13968 "to represent <quote>null changeset ID</quote> instead of a string of zeroes. "
13969 "If an environment variable is named <envar>HG_URL</envar>, it will contain "
13970 "the URL of a remote repository, if that can be determined."
13971 msgstr ""
13973 #. type: Content of: <book><chapter><sect1><sect2><para>
13974 #: ../en/ch10-hook.xml:1271
13975 msgid ""
13976 "If a hook exits with a status of zero, it is considered to have succeeded. "
13977 "If it exits with a non-zero status, it is considered to have failed."
13978 msgstr ""
13980 #. type: Content of: <book><chapter><sect1><sect2><title>
13981 #: ../en/ch10-hook.xml:1278
13982 msgid "Finding out where changesets come from"
13983 msgstr "检查修改集来自何处"
13985 #. type: Content of: <book><chapter><sect1><sect2><para>
13986 #: ../en/ch10-hook.xml:1280
13987 msgid ""
13988 "A hook that involves the transfer of changesets between a local repository "
13989 "and another may be able to find out information about the <quote>far side</"
13990 "quote>. Mercurial knows <emphasis>how</emphasis> changes are being "
13991 "transferred, and in many cases <emphasis>where</emphasis> they are being "
13992 "transferred to or from."
13993 msgstr ""
13995 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
13996 #: ../en/ch10-hook.xml:1289
13997 msgid "Sources of changesets"
13998 msgstr "修改集的来源"
14000 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
14001 #: ../en/ch10-hook.xml:1291
14002 msgid ""
14003 "Mercurial will tell a hook what means are, or were, used to transfer "
14004 "changesets between repositories. This is provided by Mercurial in a Python "
14005 "parameter named <literal>source</literal>, or an environment variable named "
14006 "<envar>HG_SOURCE</envar>."
14007 msgstr ""
14009 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
14010 #: ../en/ch10-hook.xml:1299
14011 msgid ""
14012 "<literal>serve</literal>: Changesets are transferred to or from a remote "
14013 "repository over http or ssh."
14014 msgstr ""
14016 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
14017 #: ../en/ch10-hook.xml:1304
14018 msgid ""
14019 "<literal>pull</literal>: Changesets are being transferred via a pull from one "
14020 "repository into another."
14021 msgstr ""
14023 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
14024 #: ../en/ch10-hook.xml:1309
14025 msgid ""
14026 "<literal>push</literal>: Changesets are being transferred via a push from one "
14027 "repository into another."
14028 msgstr ""
14030 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
14031 #: ../en/ch10-hook.xml:1314
14032 msgid ""
14033 "<literal>bundle</literal>: Changesets are being transferred to or from a "
14034 "bundle."
14035 msgstr ""
14037 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
14038 #: ../en/ch10-hook.xml:1321
14039 msgid "Where changes are going&emdash;remote repository URLs"
14040 msgstr "修改集要到哪里—远程版本库的地址"
14042 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
14043 #: ../en/ch10-hook.xml:1324
14044 msgid ""
14045 "When possible, Mercurial will tell a hook the location of the <quote>far "
14046 "side</quote> of an activity that transfers changeset data between "
14047 "repositories. This is provided by Mercurial in a Python parameter named "
14048 "<literal>url</literal>, or an environment variable named <envar>HG_URL</"
14049 "envar>."
14050 msgstr ""
14052 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
14053 #: ../en/ch10-hook.xml:1332
14054 msgid ""
14055 "This information is not always known. If a hook is invoked in a repository "
14056 "that is being served via http or ssh, Mercurial cannot tell where the remote "
14057 "repository is, but it may know where the client is connecting from. In such "
14058 "cases, the URL will take one of the following forms:"
14059 msgstr ""
14061 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
14062 #: ../en/ch10-hook.xml:1339
14063 msgid ""
14064 "<literal>remote:ssh:1.2.3.4</literal>&emdash;remote ssh client, at the IP "
14065 "address <literal>1.2.3.4</literal>."
14066 msgstr ""
14068 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
14069 #: ../en/ch10-hook.xml:1344
14070 msgid ""
14071 "<literal>remote:http:1.2.3.4</literal>&emdash;remote http client, at the IP "
14072 "address <literal>1.2.3.4</literal>. If the client is using SSL, this will be "
14073 "of the form <literal>remote:https:1.2.3.4</literal>."
14074 msgstr ""
14076 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
14077 #: ../en/ch10-hook.xml:1351
14078 msgid "Empty&emdash;no information could be discovered about the remote client."
14079 msgstr ""
14081 #. type: Content of: <book><chapter><sect1><title>
14082 #: ../en/ch10-hook.xml:1359
14083 msgid "Hook reference"
14084 msgstr "钩子参考"
14086 #. type: Content of: <book><chapter><sect1><sect2><title>
14087 #: ../en/ch10-hook.xml:1362
14088 msgid ""
14089 "<literal role=\"hook\">changegroup</literal>&emdash;after remote changesets "
14090 "added"
14091 msgstr "<literal role=\"hook\">changegroup</literal>—增加远程修改集之后"
14093 #. type: Content of: <book><chapter><sect1><sect2><para>
14094 #: ../en/ch10-hook.xml:1365
14095 msgid ""
14096 "This hook is run after a group of pre-existing changesets has been added to "
14097 "the repository, for example via a <command role=\"hg-cmd\">hg pull</command> "
14098 "or <command role=\"hg-cmd\">hg unbundle</command>. This hook is run once per "
14099 "operation that added one or more changesets. This is in contrast to the "
14100 "<literal role=\"hook\">incoming</literal> hook, which is run once per "
14101 "changeset, regardless of whether the changesets arrive in a group."
14102 msgstr ""
14104 #. type: Content of: <book><chapter><sect1><sect2><para>
14105 #: ../en/ch10-hook.xml:1375
14106 msgid ""
14107 "Some possible uses for this hook include kicking off an automated build or "
14108 "test of the added changesets, updating a bug database, or notifying "
14109 "subscribers that a repository contains new changes."
14110 msgstr ""
14112 #. type: Content of: <book><chapter><sect1><sect2><para>
14113 #: ../en/ch10-hook.xml:1381 ../en/ch10-hook.xml:1421 ../en/ch10-hook.xml:1465
14114 #: ../en/ch10-hook.xml:1507 ../en/ch10-hook.xml:1562 ../en/ch10-hook.xml:1602
14115 #: ../en/ch10-hook.xml:1638 ../en/ch10-hook.xml:1672 ../en/ch10-hook.xml:1736
14116 #: ../en/ch10-hook.xml:1794 ../en/ch10-hook.xml:1830 ../en/ch10-hook.xml:1857
14117 msgid "Parameters to this hook:"
14118 msgstr ""
14120 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14121 #: ../en/ch10-hook.xml:1384 ../en/ch10-hook.xml:1739
14122 msgid ""
14123 "<literal>node</literal>: A changeset ID. The changeset ID of the first "
14124 "changeset in the group that was added. All changesets between this and "
14125 "<literal role=\"tag\">tip</literal>, inclusive, were added by a single "
14126 "<command role=\"hg-cmd\">hg pull</command>, <command role=\"hg-cmd\">hg push</"
14127 "command> or <command role=\"hg-cmd\">hg unbundle</command>."
14128 msgstr ""
14130 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14131 #: ../en/ch10-hook.xml:1393 ../en/ch10-hook.xml:1472 ../en/ch10-hook.xml:1565
14132 #: ../en/ch10-hook.xml:1749
14133 msgid ""
14134 "<literal>source</literal>: A string. The source of these changes. See <xref "
14135 "linkend=\"sec:hook:sources\"/> for details."
14136 msgstr ""
14138 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14139 #: ../en/ch10-hook.xml:1398 ../en/ch10-hook.xml:1477 ../en/ch10-hook.xml:1528
14140 #: ../en/ch10-hook.xml:1570 ../en/ch10-hook.xml:1651 ../en/ch10-hook.xml:1754
14141 msgid ""
14142 "<literal>url</literal>: A URL. The location of the remote repository, if "
14143 "known. See <xref linkend=\"sec:hook:url\"/> for more information."
14144 msgstr ""
14146 #. type: Content of: <book><chapter><sect1><sect2><para>
14147 #: ../en/ch10-hook.xml:1404
14148 msgid ""
14149 "See also: <literal role=\"hook\">incoming</literal> (<xref linkend=\"sec:hook:"
14150 "incoming\"/>), <literal role=\"hook\">prechangegroup</literal> (<xref linkend="
14151 "\"sec:hook:prechangegroup\"/>), <literal role=\"hook\">pretxnchangegroup</"
14152 "literal> (<xref linkend=\"sec:hook:pretxnchangegroup\"/>)"
14153 msgstr ""
14155 #. type: Content of: <book><chapter><sect1><sect2><title>
14156 #: ../en/ch10-hook.xml:1415
14157 msgid ""
14158 "<literal role=\"hook\">commit</literal>&emdash;after a new changeset is "
14159 "created"
14160 msgstr "<literal role=\"hook\">commit</literal>—创建新修改集之后"
14162 #. type: Content of: <book><chapter><sect1><sect2><para>
14163 #: ../en/ch10-hook.xml:1418
14164 msgid "This hook is run after a new changeset has been created."
14165 msgstr ""
14167 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14168 #: ../en/ch10-hook.xml:1424 ../en/ch10-hook.xml:1797
14169 msgid ""
14170 "<literal>node</literal>: A changeset ID. The changeset ID of the newly "
14171 "committed changeset."
14172 msgstr ""
14174 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14175 #: ../en/ch10-hook.xml:1428 ../en/ch10-hook.xml:1801
14176 msgid ""
14177 "<literal>parent1</literal>: A changeset ID. The changeset ID of the first "
14178 "parent of the newly committed changeset."
14179 msgstr ""
14181 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14182 #: ../en/ch10-hook.xml:1433 ../en/ch10-hook.xml:1806
14183 msgid ""
14184 "<literal>parent2</literal>: A changeset ID. The changeset ID of the second "
14185 "parent of the newly committed changeset."
14186 msgstr ""
14188 #. type: Content of: <book><chapter><sect1><sect2><para>
14189 #: ../en/ch10-hook.xml:1439
14190 msgid ""
14191 "See also: <literal role=\"hook\">precommit</literal> (<xref linkend=\"sec:"
14192 "hook:precommit\"/>), <literal role=\"hook\">pretxncommit</literal> (<xref "
14193 "linkend=\"sec:hook:pretxncommit\"/>)"
14194 msgstr ""
14196 #. type: Content of: <book><chapter><sect1><sect2><title>
14197 #: ../en/ch10-hook.xml:1448
14198 msgid ""
14199 "<literal role=\"hook\">incoming</literal>&emdash;after one remote changeset "
14200 "is added"
14201 msgstr "<literal role=\"hook\">incoming</literal>—增加远程修改集之后"
14203 #. type: Content of: <book><chapter><sect1><sect2><para>
14204 #: ../en/ch10-hook.xml:1451
14205 msgid ""
14206 "This hook is run after a pre-existing changeset has been added to the "
14207 "repository, for example via a <command role=\"hg-cmd\">hg push</command>. If "
14208 "a group of changesets was added in a single operation, this hook is called "
14209 "once for each added changeset."
14210 msgstr ""
14212 #. type: Content of: <book><chapter><sect1><sect2><para>
14213 #: ../en/ch10-hook.xml:1458
14214 msgid ""
14215 "You can use this hook for the same purposes as the <literal role=\"hook"
14216 "\">changegroup</literal> hook (<xref linkend=\"sec:hook:changegroup\"/>); "
14217 "it's simply more convenient sometimes to run a hook once per group of "
14218 "changesets, while other times it's handier once per changeset."
14219 msgstr ""
14221 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14222 #: ../en/ch10-hook.xml:1468
14223 msgid ""
14224 "<literal>node</literal>: A changeset ID. The ID of the newly added changeset."
14225 msgstr ""
14227 #. type: Content of: <book><chapter><sect1><sect2><para>
14228 #: ../en/ch10-hook.xml:1483
14229 msgid ""
14230 "See also: <literal role=\"hook\">changegroup</literal> (<xref linkend=\"sec:"
14231 "hook:changegroup\"/>) <literal role=\"hook\">prechangegroup</literal> (<xref "
14232 "linkend=\"sec:hook:prechangegroup\"/>), <literal role=\"hook"
14233 "\">pretxnchangegroup</literal> (<xref linkend=\"sec:hook:pretxnchangegroup\"/"
14234 ">)"
14235 msgstr ""
14237 #. type: Content of: <book><chapter><sect1><sect2><title>
14238 #: ../en/ch10-hook.xml:1494
14239 msgid ""
14240 "<literal role=\"hook\">outgoing</literal>&emdash;after changesets are "
14241 "propagated"
14242 msgstr "<literal role=\"hook\">outgoing</literal>—传播修改集之后"
14244 #. type: Content of: <book><chapter><sect1><sect2><para>
14245 #: ../en/ch10-hook.xml:1497
14246 msgid ""
14247 "This hook is run after a group of changesets has been propagated out of this "
14248 "repository, for example by a <command role=\"hg-cmd\">hg push</command> or "
14249 "<command role=\"hg-cmd\">hg bundle</command> command."
14250 msgstr ""
14252 #. type: Content of: <book><chapter><sect1><sect2><para>
14253 #: ../en/ch10-hook.xml:1503
14254 msgid ""
14255 "One possible use for this hook is to notify administrators that changes have "
14256 "been pulled."
14257 msgstr ""
14259 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14260 #: ../en/ch10-hook.xml:1510
14261 msgid ""
14262 "<literal>node</literal>: A changeset ID. The changeset ID of the first "
14263 "changeset of the group that was sent."
14264 msgstr ""
14266 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14267 #: ../en/ch10-hook.xml:1515
14268 msgid ""
14269 "<literal>source</literal>: A string. The source of the of the operation (see "
14270 "<xref linkend=\"sec:hook:sources\"/>). If a remote client pulled changes "
14271 "from this repository, <literal>source</literal> will be <literal>serve</"
14272 "literal>. If the client that obtained changes from this repository was "
14273 "local, <literal>source</literal> will be <literal>bundle</literal>, "
14274 "<literal>pull</literal>, or <literal>push</literal>, depending on the "
14275 "operation the client performed."
14276 msgstr ""
14278 #. type: Content of: <book><chapter><sect1><sect2><para>
14279 #: ../en/ch10-hook.xml:1534
14280 msgid ""
14281 "See also: <literal role=\"hook\">preoutgoing</literal> (<xref linkend=\"sec:"
14282 "hook:preoutgoing\"/>)"
14283 msgstr ""
14285 #. type: Content of: <book><chapter><sect1><sect2><title>
14286 #: ../en/ch10-hook.xml:1541
14287 msgid ""
14288 "<literal role=\"hook\">prechangegroup</literal>&emdash;before starting to add "
14289 "remote changesets"
14290 msgstr "<literal role=\"hook\">prechangegroup</literal>—增加远程修改集之前"
14292 #. type: Content of: <book><chapter><sect1><sect2><para>
14293 #: ../en/ch10-hook.xml:1545
14294 msgid ""
14295 "This controlling hook is run before Mercurial begins to add a group of "
14296 "changesets from another repository."
14297 msgstr ""
14299 #. type: Content of: <book><chapter><sect1><sect2><para>
14300 #: ../en/ch10-hook.xml:1549
14301 msgid ""
14302 "This hook does not have any information about the changesets to be added, "
14303 "because it is run before transmission of those changesets is allowed to "
14304 "begin. If this hook fails, the changesets will not be transmitted."
14305 msgstr ""
14307 #. type: Content of: <book><chapter><sect1><sect2><para>
14308 #: ../en/ch10-hook.xml:1555
14309 msgid ""
14310 "One use for this hook is to prevent external changes from being added to a "
14311 "repository. For example, you could use this to <quote>freeze</quote> a "
14312 "server-hosted branch temporarily or permanently so that users cannot push to "
14313 "it, while still allowing a local administrator to modify the repository."
14314 msgstr ""
14316 #. type: Content of: <book><chapter><sect1><sect2><para>
14317 #: ../en/ch10-hook.xml:1576
14318 msgid ""
14319 "See also: <literal role=\"hook\">changegroup</literal> (<xref linkend=\"sec:"
14320 "hook:changegroup\"/>), <literal role=\"hook\">incoming</literal> (<xref "
14321 "linkend=\"sec:hook:incoming\"/>), <literal role=\"hook\">pretxnchangegroup</"
14322 "literal> (<xref linkend=\"sec:hook:pretxnchangegroup\"/>)"
14323 msgstr ""
14325 #. type: Content of: <book><chapter><sect1><sect2><title>
14326 #: ../en/ch10-hook.xml:1587
14327 msgid ""
14328 "<literal role=\"hook\">precommit</literal>&emdash;before starting to commit a "
14329 "changeset"
14330 msgstr "<literal role=\"hook\">precommit</literal>—提交修改集之前"
14332 #. type: Content of: <book><chapter><sect1><sect2><para>
14333 #: ../en/ch10-hook.xml:1590
14334 msgid ""
14335 "This hook is run before Mercurial begins to commit a new changeset. It is run "
14336 "before Mercurial has any of the metadata for the commit, such as the files to "
14337 "be committed, the commit message, or the commit date."
14338 msgstr ""
14340 #. type: Content of: <book><chapter><sect1><sect2><para>
14341 #: ../en/ch10-hook.xml:1596
14342 msgid ""
14343 "One use for this hook is to disable the ability to commit new changesets, "
14344 "while still allowing incoming changesets. Another is to run a build or test, "
14345 "and only allow the commit to begin if the build or test succeeds."
14346 msgstr ""
14348 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14349 #: ../en/ch10-hook.xml:1605
14350 msgid ""
14351 "<literal>parent1</literal>: A changeset ID. The changeset ID of the first "
14352 "parent of the working directory."
14353 msgstr ""
14355 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14356 #: ../en/ch10-hook.xml:1610
14357 msgid ""
14358 "<literal>parent2</literal>: A changeset ID. The changeset ID of the second "
14359 "parent of the working directory."
14360 msgstr ""
14362 #. type: Content of: <book><chapter><sect1><sect2><para>
14363 #: ../en/ch10-hook.xml:1615
14364 msgid ""
14365 "If the commit proceeds, the parents of the working directory will become the "
14366 "parents of the new changeset."
14367 msgstr ""
14369 #. type: Content of: <book><chapter><sect1><sect2><para>
14370 #: ../en/ch10-hook.xml:1619
14371 msgid ""
14372 "See also: <literal role=\"hook\">commit</literal> (<xref linkend=\"sec:hook:"
14373 "commit\"/>), <literal role=\"hook\">pretxncommit</literal> (<xref linkend="
14374 "\"sec:hook:pretxncommit\"/>)"
14375 msgstr ""
14377 #. type: Content of: <book><chapter><sect1><sect2><title>
14378 #: ../en/ch10-hook.xml:1627
14379 msgid ""
14380 "<literal role=\"hook\">preoutgoing</literal>&emdash;before starting to "
14381 "propagate changesets"
14382 msgstr "<literal role=\"hook\">preoutgoing</literal>—传播修改集之前"
14384 #. type: Content of: <book><chapter><sect1><sect2><para>
14385 #: ../en/ch10-hook.xml:1630
14386 msgid ""
14387 "This hook is invoked before Mercurial knows the identities of the changesets "
14388 "to be transmitted."
14389 msgstr ""
14391 #. type: Content of: <book><chapter><sect1><sect2><para>
14392 #: ../en/ch10-hook.xml:1634
14393 msgid ""
14394 "One use for this hook is to prevent changes from being transmitted to another "
14395 "repository."
14396 msgstr ""
14398 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14399 #: ../en/ch10-hook.xml:1641
14400 msgid ""
14401 "<literal>source</literal>: A string. The source of the operation that is "
14402 "attempting to obtain changes from this repository (see <xref linkend=\"sec:"
14403 "hook:sources\"/>). See the documentation for the <literal>source</literal> "
14404 "parameter to the <literal role=\"hook\">outgoing</literal> hook, in <xref "
14405 "linkend=\"sec:hook:outgoing\"/>, for possible values of this parameter."
14406 msgstr ""
14408 #. type: Content of: <book><chapter><sect1><sect2><para>
14409 #: ../en/ch10-hook.xml:1657
14410 msgid ""
14411 "See also: <literal role=\"hook\">outgoing</literal> (<xref linkend=\"sec:hook:"
14412 "outgoing\"/>)"
14413 msgstr ""
14415 #. type: Content of: <book><chapter><sect1><sect2><title>
14416 #: ../en/ch10-hook.xml:1664
14417 msgid ""
14418 "<literal role=\"hook\">pretag</literal>&emdash;before tagging a changeset"
14419 msgstr "<literal role=\"hook\">pretag</literal>—创建标签之前"
14421 #. type: Content of: <book><chapter><sect1><sect2><para>
14422 #: ../en/ch10-hook.xml:1667
14423 msgid ""
14424 "This controlling hook is run before a tag is created. If the hook succeeds, "
14425 "creation of the tag proceeds. If the hook fails, the tag is not created."
14426 msgstr ""
14428 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14429 #: ../en/ch10-hook.xml:1675
14430 msgid ""
14431 "<literal>local</literal>: A boolean. Whether the tag is local to this "
14432 "repository instance (i.e. stored in <filename role=\"special\">.hg/localtags</"
14433 "filename>) or managed by Mercurial (stored in <filename role=\"special\">."
14434 "hgtags</filename>)."
14435 msgstr ""
14437 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14438 #: ../en/ch10-hook.xml:1682
14439 msgid ""
14440 "<literal>node</literal>: A changeset ID. The ID of the changeset to be "
14441 "tagged."
14442 msgstr ""
14444 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14445 #: ../en/ch10-hook.xml:1686
14446 msgid "<literal>tag</literal>: A string. The name of the tag to be created."
14447 msgstr ""
14449 #. type: Content of: <book><chapter><sect1><sect2><para>
14450 #: ../en/ch10-hook.xml:1691
14451 msgid ""
14452 "If the tag to be created is revision-controlled, the <literal role=\"hook"
14453 "\">precommit</literal> and <literal role=\"hook\">pretxncommit</literal> "
14454 "hooks (<xref linkend=\"sec:hook:commit\"/> and <xref linkend=\"sec:hook:"
14455 "pretxncommit\"/>) will also be run."
14456 msgstr ""
14458 #. type: Content of: <book><chapter><sect1><sect2><para>
14459 #: ../en/ch10-hook.xml:1699
14460 msgid ""
14461 "See also: <literal role=\"hook\">tag</literal> (<xref linkend=\"sec:hook:tag"
14462 "\"/>)"
14463 msgstr ""
14465 #. type: Content of: <book><chapter><sect1><sect2><title>
14466 #: ../en/ch10-hook.xml:1705
14467 msgid ""
14468 "<literal role=\"hook\">pretxnchangegroup</literal>&emdash;before completing "
14469 "addition of remote changesets"
14470 msgstr ""
14471 "<literal role=\"hook\">pretxnchangegroup</literal>—完成增加远程修改集之前"
14473 #. type: Content of: <book><chapter><sect1><sect2><para>
14474 #: ../en/ch10-hook.xml:1709
14475 msgid ""
14476 "This controlling hook is run before a transaction&emdash;that manages the "
14477 "addition of a group of new changesets from outside the repository&emdash;"
14478 "completes. If the hook succeeds, the transaction completes, and all of the "
14479 "changesets become permanent within this repository. If the hook fails, the "
14480 "transaction is rolled back, and the data for the changesets is erased."
14481 msgstr ""
14483 #. type: Content of: <book><chapter><sect1><sect2><para>
14484 #: ../en/ch10-hook.xml:1718
14485 msgid ""
14486 "This hook can access the metadata associated with the almost-added "
14487 "changesets, but it should not do anything permanent with this data. It must "
14488 "also not modify the working directory."
14489 msgstr ""
14491 #. type: Content of: <book><chapter><sect1><sect2><para>
14492 #: ../en/ch10-hook.xml:1724
14493 msgid ""
14494 "While this hook is running, if other Mercurial processes access this "
14495 "repository, they will be able to see the almost-added changesets as if they "
14496 "are permanent. This may lead to race conditions if you do not take steps to "
14497 "avoid them."
14498 msgstr ""
14500 #. type: Content of: <book><chapter><sect1><sect2><para>
14501 #: ../en/ch10-hook.xml:1731
14502 msgid ""
14503 "This hook can be used to automatically vet a group of changesets. If the "
14504 "hook fails, all of the changesets are <quote>rejected</quote> when the "
14505 "transaction rolls back."
14506 msgstr ""
14508 #. type: Content of: <book><chapter><sect1><sect2><para>
14509 #: ../en/ch10-hook.xml:1760
14510 msgid ""
14511 "See also: <literal role=\"hook\">changegroup</literal> (<xref linkend=\"sec:"
14512 "hook:changegroup\"/>), <literal role=\"hook\">incoming</literal> (<xref "
14513 "linkend=\"sec:hook:incoming\"/>), <literal role=\"hook\">prechangegroup</"
14514 "literal> (<xref linkend=\"sec:hook:prechangegroup\"/>)"
14515 msgstr ""
14517 #. type: Content of: <book><chapter><sect1><sect2><title>
14518 #: ../en/ch10-hook.xml:1771
14519 msgid ""
14520 "<literal role=\"hook\">pretxncommit</literal>&emdash;before completing commit "
14521 "of new changeset"
14522 msgstr "<literal role=\"hook\">pretxncommit</literal>—完成提交之前"
14524 #. type: Content of: <book><chapter><sect1><sect2><para>
14525 #: ../en/ch10-hook.xml:1774
14526 msgid ""
14527 "This controlling hook is run before a transaction&emdash;that manages a new "
14528 "commit&emdash;completes. If the hook succeeds, the transaction completes and "
14529 "the changeset becomes permanent within this repository. If the hook fails, "
14530 "the transaction is rolled back, and the commit data is erased."
14531 msgstr ""
14533 #. type: Content of: <book><chapter><sect1><sect2><para>
14534 #: ../en/ch10-hook.xml:1782
14535 msgid ""
14536 "This hook can access the metadata associated with the almost-new changeset, "
14537 "but it should not do anything permanent with this data. It must also not "
14538 "modify the working directory."
14539 msgstr ""
14541 #. type: Content of: <book><chapter><sect1><sect2><para>
14542 #: ../en/ch10-hook.xml:1788
14543 msgid ""
14544 "While this hook is running, if other Mercurial processes access this "
14545 "repository, they will be able to see the almost-new changeset as if it is "
14546 "permanent. This may lead to race conditions if you do not take steps to "
14547 "avoid them."
14548 msgstr ""
14550 #. type: Content of: <book><chapter><sect1><sect2><para>
14551 #: ../en/ch10-hook.xml:1812
14552 msgid ""
14553 "See also: <literal role=\"hook\">precommit</literal> (<xref linkend=\"sec:"
14554 "hook:precommit\"/>)"
14555 msgstr ""
14556 "参见: <literal role=\"hook\">precommit</literal> (<xref linkend=\"sec:hook:"
14557 "precommit\"/>)"
14559 #. type: Content of: <book><chapter><sect1><sect2><title>
14560 #: ../en/ch10-hook.xml:1819
14561 msgid ""
14562 "<literal role=\"hook\">preupdate</literal>&emdash;before updating or merging "
14563 "working directory"
14564 msgstr "<literal role=\"hook\">preupdate</literal>—更新或合并工作目录之前"
14566 #. type: Content of: <book><chapter><sect1><sect2><para>
14567 #: ../en/ch10-hook.xml:1822
14568 msgid ""
14569 "This controlling hook is run before an update or merge of the working "
14570 "directory begins. It is run only if Mercurial's normal pre-update checks "
14571 "determine that the update or merge can proceed. If the hook succeeds, the "
14572 "update or merge may proceed; if it fails, the update or merge does not start."
14573 msgstr ""
14575 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14576 #: ../en/ch10-hook.xml:1833
14577 msgid ""
14578 "<literal>parent1</literal>: A changeset ID. The ID of the parent that the "
14579 "working directory is to be updated to. If the working directory is being "
14580 "merged, it will not change this parent."
14581 msgstr ""
14583 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14584 #: ../en/ch10-hook.xml:1839
14585 msgid ""
14586 "<literal>parent2</literal>: A changeset ID. Only set if the working directory "
14587 "is being merged. The ID of the revision that the working directory is being "
14588 "merged with."
14589 msgstr ""
14591 #. type: Content of: <book><chapter><sect1><sect2><para>
14592 #: ../en/ch10-hook.xml:1846
14593 msgid ""
14594 "See also: <literal role=\"hook\">update</literal> (<xref linkend=\"sec:hook:"
14595 "update\"/>)"
14596 msgstr ""
14598 #. type: Content of: <book><chapter><sect1><sect2><title>
14599 #: ../en/ch10-hook.xml:1851
14600 msgid "<literal role=\"hook\">tag</literal>&emdash;after tagging a changeset"
14601 msgstr "<literal role=\"hook\">tag</literal>—创建标签之后"
14603 #. type: Content of: <book><chapter><sect1><sect2><para>
14604 #: ../en/ch10-hook.xml:1854
14605 msgid "This hook is run after a tag has been created."
14606 msgstr ""
14608 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14609 #: ../en/ch10-hook.xml:1860
14610 msgid ""
14611 "<literal>local</literal>: A boolean. Whether the new tag is local to this "
14612 "repository instance (i.e. stored in <filename role=\"special\">.hg/"
14613 "localtags</filename>) or managed by Mercurial (stored in <filename role="
14614 "\"special\">.hgtags</filename>)."
14615 msgstr ""
14617 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14618 #: ../en/ch10-hook.xml:1868
14619 msgid ""
14620 "<literal>node</literal>: A changeset ID. The ID of the changeset that was "
14621 "tagged."
14622 msgstr ""
14624 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14625 #: ../en/ch10-hook.xml:1872
14626 msgid "<literal>tag</literal>: A string. The name of the tag that was created."
14627 msgstr ""
14629 #. type: Content of: <book><chapter><sect1><sect2><para>
14630 #: ../en/ch10-hook.xml:1877
14631 msgid ""
14632 "If the created tag is revision-controlled, the <literal role=\"hook\">commit</"
14633 "literal> hook (section <xref linkend=\"sec:hook:commit\"/>) is run before "
14634 "this hook."
14635 msgstr ""
14637 #. type: Content of: <book><chapter><sect1><sect2><para>
14638 #: ../en/ch10-hook.xml:1882
14639 msgid ""
14640 "See also: <literal role=\"hook\">pretag</literal> (<xref linkend=\"sec:hook:"
14641 "pretag\"/>)"
14642 msgstr ""
14643 "参见: <literal role=\"hook\">pretag</literal> (<xref linkend=\"sec:hook:pretag"
14644 "\"/>)"
14646 #. type: Content of: <book><chapter><sect1><sect2><title>
14647 #: ../en/ch10-hook.xml:1888
14648 msgid ""
14649 "<literal role=\"hook\">update</literal>&emdash;after updating or merging "
14650 "working directory"
14651 msgstr "<literal role=\"hook\">update</literal>—更新或合并工作目录之后"
14653 #. type: Content of: <book><chapter><sect1><sect2><para>
14654 #: ../en/ch10-hook.xml:1891
14655 msgid ""
14656 "This hook is run after an update or merge of the working directory "
14657 "completes. Since a merge can fail (if the external <command>hgmerge</"
14658 "command> command fails to resolve conflicts in a file), this hook "
14659 "communicates whether the update or merge completed cleanly."
14660 msgstr ""
14662 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14663 #: ../en/ch10-hook.xml:1899
14664 msgid ""
14665 "<literal>error</literal>: A boolean. Indicates whether the update or merge "
14666 "completed successfully."
14667 msgstr ""
14669 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14670 #: ../en/ch10-hook.xml:1904
14671 msgid ""
14672 "<literal>parent1</literal>: A changeset ID. The ID of the parent that the "
14673 "working directory was updated to. If the working directory was merged, it "
14674 "will not have changed this parent."
14675 msgstr ""
14677 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14678 #: ../en/ch10-hook.xml:1910
14679 msgid ""
14680 "<literal>parent2</literal>: A changeset ID. Only set if the working "
14681 "directory was merged. The ID of the revision that the working directory was "
14682 "merged with."
14683 msgstr ""
14685 #. type: Content of: <book><chapter><sect1><sect2><para>
14686 #: ../en/ch10-hook.xml:1916
14687 msgid ""
14688 "See also: <literal role=\"hook\">preupdate</literal> (<xref linkend=\"sec:"
14689 "hook:preupdate\"/>)"
14690 msgstr ""
14692 #. type: Content of: <book><chapter><title>
14693 #: ../en/ch11-template.xml:5
14694 msgid "Customizing the output of Mercurial"
14695 msgstr "定制 Mercurial 的输出"
14697 #. type: Content of: <book><chapter><para>
14698 #: ../en/ch11-template.xml:7
14699 msgid ""
14700 "Mercurial provides a powerful mechanism to let you control how it displays "
14701 "information. The mechanism is based on templates. You can use templates to "
14702 "generate specific output for a single command, or to customize the entire "
14703 "appearance of the built-in web interface."
14704 msgstr ""
14706 #. type: Content of: <book><chapter><sect1><title>
14707 #: ../en/ch11-template.xml:14
14708 msgid "Using precanned output styles"
14709 msgstr "使用预定义的输出样式"
14711 #. type: Content of: <book><chapter><sect1><para>
14712 #: ../en/ch11-template.xml:16
14713 msgid ""
14714 "Packaged with Mercurial are some output styles that you can use immediately. "
14715 "A style is simply a precanned template that someone wrote and installed "
14716 "somewhere that Mercurial can find."
14717 msgstr ""
14719 #. type: Content of: <book><chapter><sect1><para>
14720 #: ../en/ch11-template.xml:21
14721 msgid ""
14722 "Before we take a look at Mercurial's bundled styles, let's review its normal "
14723 "output."
14724 msgstr ""
14726 #. type: Content of: <book><chapter><sect1><para>
14727 #: ../en/ch11-template.xml:26
14728 msgid ""
14729 "This is somewhat informative, but it takes up a lot of space&emdash;five "
14730 "lines of output per changeset. The <literal>compact</literal> style reduces "
14731 "this to three lines, presented in a sparse manner."
14732 msgstr ""
14734 #. type: Content of: <book><chapter><sect1><para>
14735 #: ../en/ch11-template.xml:33
14736 msgid ""
14737 "The <literal>changelog</literal> style hints at the expressive power of "
14738 "Mercurial's templating engine. This style attempts to follow the GNU "
14739 "Project's changelog guidelines<citation>web:changelog</citation>."
14740 msgstr ""
14742 #. type: Content of: <book><chapter><sect1><para>
14743 #: ../en/ch11-template.xml:40
14744 msgid ""
14745 "You will not be shocked to learn that Mercurial's default output style is "
14746 "named <literal>default</literal>."
14747 msgstr ""
14749 #. type: Content of: <book><chapter><sect1><sect2><title>
14750 #: ../en/ch11-template.xml:44
14751 msgid "Setting a default style"
14752 msgstr "设置默认样式"
14754 #. type: Content of: <book><chapter><sect1><sect2><para>
14755 #: ../en/ch11-template.xml:46
14756 msgid ""
14757 "You can modify the output style that Mercurial will use for every command by "
14758 "editing your <filename role=\"special\">~/.hgrc</filename> file, naming the "
14759 "style you would prefer to use."
14760 msgstr ""
14762 #. type: Content of: <book><chapter><sect1><sect2><para>
14763 #: ../en/ch11-template.xml:54
14764 msgid ""
14765 "If you write a style of your own, you can use it by either providing the path "
14766 "to your style file, or copying your style file into a location where "
14767 "Mercurial can find it (typically the <literal>templates</literal> "
14768 "subdirectory of your Mercurial install directory)."
14769 msgstr ""
14771 #. type: Content of: <book><chapter><sect1><title>
14772 #: ../en/ch11-template.xml:63
14773 msgid "Commands that support styles and templates"
14774 msgstr "支持样式和模版的命令"
14776 #. type: Content of: <book><chapter><sect1><para>
14777 #: ../en/ch11-template.xml:65
14778 msgid ""
14779 "All of Mercurial's <quote><literal>log</literal>-like</quote> commands let "
14780 "you use styles and templates: <command role=\"hg-cmd\">hg incoming</command>, "
14781 "<command role=\"hg-cmd\">hg log</command>, <command role=\"hg-cmd\">hg "
14782 "outgoing</command>, and <command role=\"hg-cmd\">hg tip</command>."
14783 msgstr ""
14785 #. type: Content of: <book><chapter><sect1><para>
14786 #: ../en/ch11-template.xml:72
14787 msgid ""
14788 "As I write this manual, these are so far the only commands that support "
14789 "styles and templates. Since these are the most important commands that need "
14790 "customizable output, there has been little pressure from the Mercurial user "
14791 "community to add style and template support to other commands."
14792 msgstr ""
14794 #. type: Content of: <book><chapter><sect1><title>
14795 #: ../en/ch11-template.xml:80
14796 msgid "The basics of templating"
14797 msgstr "模版基础"
14799 #. type: Content of: <book><chapter><sect1><para>
14800 #: ../en/ch11-template.xml:82
14801 msgid ""
14802 "At its simplest, a Mercurial template is a piece of text. Some of the text "
14803 "never changes, while other parts are <emphasis>expanded</emphasis>, or "
14804 "replaced with new text, when necessary."
14805 msgstr ""
14807 #. type: Content of: <book><chapter><sect1><para>
14808 #: ../en/ch11-template.xml:87
14809 msgid ""
14810 "Before we continue, let's look again at a simple example of Mercurial's "
14811 "normal output."
14812 msgstr ""
14814 #. type: Content of: <book><chapter><sect1><para>
14815 #: ../en/ch11-template.xml:92
14816 msgid ""
14817 "Now, let's run the same command, but using a template to change its output."
14818 msgstr ""
14820 #. type: Content of: <book><chapter><sect1><para>
14821 #: ../en/ch11-template.xml:97
14822 msgid ""
14823 "The example above illustrates the simplest possible template; it's just a "
14824 "piece of static text, printed once for each changeset. The <option role=\"hg-"
14825 "opt-log\">--template</option> option to the <command role=\"hg-cmd\">hg log</"
14826 "command> command tells Mercurial to use the given text as the template when "
14827 "printing each changeset."
14828 msgstr ""
14830 #. type: Content of: <book><chapter><sect1><para>
14831 #: ../en/ch11-template.xml:105
14832 msgid ""
14833 "Notice that the template string above ends with the text <quote><literal>\\n</"
14834 "literal></quote>. This is an <emphasis>escape sequence</emphasis>, telling "
14835 "Mercurial to print a newline at the end of each template item. If you omit "
14836 "this newline, Mercurial will run each piece of output together. See <xref "
14837 "linkend=\"sec:template:escape\"/> for more details of escape sequences."
14838 msgstr ""
14840 #. type: Content of: <book><chapter><sect1><para>
14841 #: ../en/ch11-template.xml:113
14842 msgid ""
14843 "A template that prints a fixed string of text all the time isn't very useful; "
14844 "let's try something a bit more complex."
14845 msgstr ""
14847 #. type: Content of: <book><chapter><sect1><para>
14848 #: ../en/ch11-template.xml:119
14849 msgid ""
14850 "As you can see, the string <quote><literal>{desc}</literal></quote> in the "
14851 "template has been replaced in the output with the description of each "
14852 "changeset. Every time Mercurial finds text enclosed in curly braces "
14853 "(<quote><literal>{</literal></quote> and <quote><literal>}</literal></"
14854 "quote>), it will try to replace the braces and text with the expansion of "
14855 "whatever is inside. To print a literal curly brace, you must escape it, as "
14856 "described in <xref linkend=\"sec:template:escape\"/>."
14857 msgstr ""
14859 #. type: Content of: <book><chapter><sect1><title>
14860 #: ../en/ch11-template.xml:131
14861 msgid "Common template keywords"
14862 msgstr "模版关键字"
14864 #. type: Content of: <book><chapter><sect1><para>
14865 #: ../en/ch11-template.xml:133
14866 msgid ""
14867 "You can start writing simple templates immediately using the keywords below."
14868 msgstr ""
14870 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14871 #: ../en/ch11-template.xml:137
14872 msgid ""
14873 "<literal role=\"template-keyword\">author</literal>: String. The unmodified "
14874 "author of the changeset."
14875 msgstr ""
14877 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14878 #: ../en/ch11-template.xml:141
14879 msgid ""
14880 "<literal role=\"template-keyword\">branches</literal>: String. The name of "
14881 "the branch on which the changeset was committed. Will be empty if the branch "
14882 "name was <literal>default</literal>."
14883 msgstr ""
14885 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14886 #: ../en/ch11-template.xml:147
14887 msgid ""
14888 "<literal role=\"template-keyword\">date</literal>: Date information. The "
14889 "date when the changeset was committed. This is <emphasis>not</emphasis> "
14890 "human-readable; you must pass it through a filter that will render it "
14891 "appropriately. See <xref linkend=\"sec:template:filter\"/> for more "
14892 "information on filters. The date is expressed as a pair of numbers. The "
14893 "first number is a Unix UTC timestamp (seconds since January 1, 1970); the "
14894 "second is the offset of the committer's timezone from UTC, in seconds."
14895 msgstr ""
14897 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14898 #: ../en/ch11-template.xml:158
14899 msgid ""
14900 "<literal role=\"template-keyword\">desc</literal>: String. The text of the "
14901 "changeset description."
14902 msgstr ""
14904 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14905 #: ../en/ch11-template.xml:161
14906 msgid ""
14907 "<literal role=\"template-keyword\">files</literal>: List of strings. All "
14908 "files modified, added, or removed by this changeset."
14909 msgstr ""
14911 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14912 #: ../en/ch11-template.xml:166
14913 msgid ""
14914 "<literal role=\"template-keyword\">file_adds</literal>: List of strings. "
14915 "Files added by this changeset."
14916 msgstr ""
14918 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14919 #: ../en/ch11-template.xml:170
14920 msgid ""
14921 "<literal role=\"template-keyword\">file_dels</literal>: List of strings. "
14922 "Files removed by this changeset."
14923 msgstr ""
14925 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14926 #: ../en/ch11-template.xml:174
14927 msgid ""
14928 "<literal role=\"template-keyword\">node</literal>: String. The changeset "
14929 "identification hash, as a 40-character hexadecimal string."
14930 msgstr ""
14932 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14933 #: ../en/ch11-template.xml:178
14934 msgid ""
14935 "<literal role=\"template-keyword\">parents</literal>: List of strings. The "
14936 "parents of the changeset."
14937 msgstr ""
14939 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14940 #: ../en/ch11-template.xml:182
14941 msgid ""
14942 "<literal role=\"template-keyword\">rev</literal>: Integer. The repository-"
14943 "local changeset revision number."
14944 msgstr ""
14946 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14947 #: ../en/ch11-template.xml:186
14948 msgid ""
14949 "<literal role=\"template-keyword\">tags</literal>: List of strings. Any tags "
14950 "associated with the changeset."
14951 msgstr ""
14953 #. type: Content of: <book><chapter><sect1><para>
14954 #: ../en/ch11-template.xml:192
14955 msgid ""
14956 "A few simple experiments will show us what to expect when we use these "
14957 "keywords; you can see the results below."
14958 msgstr ""
14960 #. type: Content of: <book><chapter><sect1><para>
14961 #: ../en/ch11-template.xml:197
14962 msgid ""
14963 "As we noted above, the date keyword does not produce human-readable output, "
14964 "so we must treat it specially. This involves using a <emphasis>filter</"
14965 "emphasis>, about which more in <xref linkend=\"sec:template:filter\"/>."
14966 msgstr ""
14968 #. type: Content of: <book><chapter><sect1><title>
14969 #: ../en/ch11-template.xml:206
14970 msgid "Escape sequences"
14971 msgstr "转义序列"
14973 #. type: Content of: <book><chapter><sect1><para>
14974 #: ../en/ch11-template.xml:208
14975 msgid ""
14976 "Mercurial's templating engine recognises the most commonly used escape "
14977 "sequences in strings. When it sees a backslash (<quote><literal>\\</"
14978 "literal></quote>) character, it looks at the following character and "
14979 "substitutes the two characters with a single replacement, as described below."
14980 msgstr ""
14982 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14983 #: ../en/ch11-template.xml:215
14984 msgid ""
14985 "<literal>\\</literal>: Backslash, <quote><literal>\\</literal></quote>, ASCII "
14986 "134."
14987 msgstr ""
14989 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14990 #: ../en/ch11-template.xml:219
14991 msgid "<literal>\\n</literal>: Newline, ASCII 12."
14992 msgstr ""
14994 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14995 #: ../en/ch11-template.xml:222
14996 msgid "<literal>\\r</literal>: Carriage return, ASCII 15."
14997 msgstr ""
14999 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15000 #: ../en/ch11-template.xml:225
15001 msgid "<literal>\\t</literal>: Tab, ASCII 11."
15002 msgstr ""
15004 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15005 #: ../en/ch11-template.xml:228
15006 msgid "<literal>\\v</literal>: Vertical tab, ASCII 13."
15007 msgstr ""
15009 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15010 #: ../en/ch11-template.xml:231
15011 msgid ""
15012 "<literal>\\{</literal>: Open curly brace, <quote><literal>{</literal></"
15013 "quote>, ASCII 173."
15014 msgstr ""
15016 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15017 #: ../en/ch11-template.xml:235
15018 msgid ""
15019 "<literal>\\}</literal>: Close curly brace, <quote><literal>}</literal></"
15020 "quote>, ASCII 175."
15021 msgstr ""
15023 #. type: Content of: <book><chapter><sect1><para>
15024 #: ../en/ch11-template.xml:240
15025 msgid ""
15026 "As indicated above, if you want the expansion of a template to contain a "
15027 "literal <quote><literal>\\</literal></quote>, <quote><literal>{</literal></"
15028 "quote>, or <quote><literal>{</literal></quote> character, you must escape it."
15029 msgstr ""
15031 #. type: Content of: <book><chapter><sect1><title>
15032 #: ../en/ch11-template.xml:248
15033 msgid "Filtering keywords to change their results"
15034 msgstr "通过过滤关键字来修改输出结果"
15036 #. type: Content of: <book><chapter><sect1><para>
15037 #: ../en/ch11-template.xml:250
15038 msgid ""
15039 "Some of the results of template expansion are not immediately easy to use. "
15040 "Mercurial lets you specify an optional chain of <emphasis>filters</emphasis> "
15041 "to modify the result of expanding a keyword. You have already seen a common "
15042 "filter, <literal role=\"template-kw-filt-date\">isodate</literal>, in action "
15043 "above, to make a date readable."
15044 msgstr ""
15046 #. type: Content of: <book><chapter><sect1><para>
15047 #: ../en/ch11-template.xml:257
15048 msgid ""
15049 "Below is a list of the most commonly used filters that Mercurial supports. "
15050 "While some filters can be applied to any text, others can only be used in "
15051 "specific circumstances. The name of each filter is followed first by an "
15052 "indication of where it can be used, then a description of its effect."
15053 msgstr ""
15055 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15056 #: ../en/ch11-template.xml:264
15057 msgid ""
15058 "<literal role=\"template-filter\">addbreaks</literal>: Any text. Add an XHTML "
15059 "<quote><literal>&lt;br/&gt;</literal></quote> tag before the end of every "
15060 "line except the last. For example, <quote><literal>foo\\nbar</literal></"
15061 "quote> becomes <quote><literal>foo&lt;br/&gt;\\nbar</literal></quote>."
15062 msgstr ""
15064 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15065 #: ../en/ch11-template.xml:271
15066 msgid ""
15067 "<literal role=\"template-kw-filt-date\">age</literal>: <literal role="
15068 "\"template-keyword\">date</literal> keyword. Render the age of the date, "
15069 "relative to the current time. Yields a string like <quote><literal>10 "
15070 "minutes</literal></quote>."
15071 msgstr ""
15073 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15074 #: ../en/ch11-template.xml:278
15075 msgid ""
15076 "<literal role=\"template-filter\">basename</literal>: Any text, but most "
15077 "useful for the <literal role=\"template-keyword\">files</literal> keyword and "
15078 "its relatives. Treat the text as a path, and return the basename. For "
15079 "example, <quote><literal>foo/bar/baz</literal></quote> becomes "
15080 "<quote><literal>baz</literal></quote>."
15081 msgstr ""
15083 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15084 #: ../en/ch11-template.xml:287
15085 msgid ""
15086 "<literal role=\"template-kw-filt-date\">date</literal>: <literal role="
15087 "\"template-keyword\">date</literal> keyword. Render a date in a similar "
15088 "format to the Unix <literal role=\"template-keyword\">date</literal> command, "
15089 "but with timezone included. Yields a string like <quote><literal>Mon Sep 04 "
15090 "15:13:13 2006 -0700</literal></quote>."
15091 msgstr ""
15093 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15094 #: ../en/ch11-template.xml:295
15095 msgid ""
15096 "<literal role=\"template-kw-filt-author\">domain</literal>: Any text, but "
15097 "most useful for the <literal role=\"template-keyword\">author</literal> "
15098 "keyword. Finds the first string that looks like an email address, and "
15099 "extract just the domain component. For example, <quote><literal>Bryan "
15100 "O'Sullivan &lt;bos@serpentine.com&gt;</literal></quote> becomes "
15101 "<quote><literal>serpentine.com</literal></quote>."
15102 msgstr ""
15104 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15105 #: ../en/ch11-template.xml:305
15106 msgid ""
15107 "<literal role=\"template-kw-filt-author\">email</literal>: Any text, but most "
15108 "useful for the <literal role=\"template-keyword\">author</literal> keyword. "
15109 "Extract the first string that looks like an email address. For example, "
15110 "<quote><literal>Bryan O'Sullivan &lt;bos@serpentine.com&gt;</literal></quote> "
15111 "becomes <quote><literal>bos@serpentine.com</literal></quote>."
15112 msgstr ""
15114 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15115 #: ../en/ch11-template.xml:314
15116 msgid ""
15117 "<literal role=\"template-filter\">escape</literal>: Any text. Replace the "
15118 "special XML/XHTML characters <quote><literal>&amp;</literal></quote>, "
15119 "<quote><literal>&lt;</literal></quote> and <quote><literal>&gt;</literal></"
15120 "quote> with XML entities."
15121 msgstr ""
15123 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15124 #: ../en/ch11-template.xml:322
15125 msgid ""
15126 "<literal role=\"template-filter\">fill68</literal>: Any text. Wrap the text "
15127 "to fit in 68 columns. This is useful before you pass text through the "
15128 "<literal role=\"template-filter\">tabindent</literal> filter, and still want "
15129 "it to fit in an 80-column fixed-font window."
15130 msgstr ""
15132 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15133 #: ../en/ch11-template.xml:330
15134 msgid ""
15135 "<literal role=\"template-filter\">fill76</literal>: Any text. Wrap the text "
15136 "to fit in 76 columns."
15137 msgstr ""
15139 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15140 #: ../en/ch11-template.xml:334
15141 msgid ""
15142 "<literal role=\"template-filter\">firstline</literal>: Any text. Yield the "
15143 "first line of text, without any trailing newlines."
15144 msgstr ""
15146 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15147 #: ../en/ch11-template.xml:339
15148 msgid ""
15149 "<literal role=\"template-kw-filt-date\">hgdate</literal>: <literal role="
15150 "\"template-keyword\">date</literal> keyword. Render the date as a pair of "
15151 "readable numbers. Yields a string like <quote><literal>1157407993 25200</"
15152 "literal></quote>."
15153 msgstr ""
15155 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15156 #: ../en/ch11-template.xml:346
15157 msgid ""
15158 "<literal role=\"template-kw-filt-date\">isodate</literal>: <literal role="
15159 "\"template-keyword\">date</literal> keyword. Render the date as a text "
15160 "string in ISO 8601 format. Yields a string like <quote><literal>2006-09-04 "
15161 "15:13:13 -0700</literal></quote>."
15162 msgstr ""
15164 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15165 #: ../en/ch11-template.xml:353
15166 msgid ""
15167 "<literal role=\"template-filter\">obfuscate</literal>: Any text, but most "
15168 "useful for the <literal role=\"template-keyword\">author</literal> keyword. "
15169 "Yield the input text rendered as a sequence of XML entities. This helps to "
15170 "defeat some particularly stupid screen-scraping email harvesting spambots."
15171 msgstr ""
15173 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15174 #: ../en/ch11-template.xml:361
15175 msgid ""
15176 "<literal role=\"template-kw-filt-author\">person</literal>: Any text, but "
15177 "most useful for the <literal role=\"template-keyword\">author</literal> "
15178 "keyword. Yield the text before an email address. For example, "
15179 "<quote><literal>Bryan O'Sullivan &lt;bos@serpentine.com&gt;</literal></quote> "
15180 "becomes <quote><literal>Bryan O'Sullivan</literal></quote>."
15181 msgstr ""
15183 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15184 #: ../en/ch11-template.xml:370
15185 msgid ""
15186 "<literal role=\"template-kw-filt-date\">rfc822date</literal>: <literal role="
15187 "\"template-keyword\">date</literal> keyword. Render a date using the same "
15188 "format used in email headers. Yields a string like <quote><literal>Mon, 04 "
15189 "Sep 2006 15:13:13 -0700</literal></quote>."
15190 msgstr ""
15192 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15193 #: ../en/ch11-template.xml:377
15194 msgid ""
15195 "<literal role=\"template-kw-filt-node\">short</literal>: Changeset hash. "
15196 "Yield the short form of a changeset hash, i.e. a 12-character hexadecimal "
15197 "string."
15198 msgstr ""
15200 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15201 #: ../en/ch11-template.xml:382
15202 msgid ""
15203 "<literal role=\"template-kw-filt-date\">shortdate</literal>: <literal role="
15204 "\"template-keyword\">date</literal> keyword. Render the year, month, and day "
15205 "of the date. Yields a string like <quote><literal>2006-09-04</literal></"
15206 "quote>."
15207 msgstr ""
15209 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15210 #: ../en/ch11-template.xml:388
15211 msgid ""
15212 "<literal role=\"template-filter\">strip</literal>: Any text. Strip all "
15213 "leading and trailing whitespace from the string."
15214 msgstr ""
15216 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15217 #: ../en/ch11-template.xml:392
15218 msgid ""
15219 "<literal role=\"template-filter\">tabindent</literal>: Any text. Yield the "
15220 "text, with every line except the first starting with a tab character."
15221 msgstr ""
15223 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15224 #: ../en/ch11-template.xml:397
15225 msgid ""
15226 "<literal role=\"template-filter\">urlescape</literal>: Any text. Escape all "
15227 "characters that are considered <quote>special</quote> by URL parsers. For "
15228 "example, <literal>foo bar</literal> becomes <literal>foo%20bar</literal>."
15229 msgstr ""
15231 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15232 #: ../en/ch11-template.xml:404
15233 msgid ""
15234 "<literal role=\"template-kw-filt-author\">user</literal>: Any text, but most "
15235 "useful for the <literal role=\"template-keyword\">author</literal> keyword. "
15236 "Return the <quote>user</quote> portion of an email address. For example, "
15237 "<quote><literal>Bryan O'Sullivan &lt;bos@serpentine.com&gt;</literal></quote> "
15238 "becomes <quote><literal>bos</literal></quote>."
15239 msgstr ""
15241 #. type: Content of: <book><chapter><sect1><note><para>
15242 #: ../en/ch11-template.xml:418
15243 msgid ""
15244 "If you try to apply a filter to a piece of data that it cannot process, "
15245 "Mercurial will fail and print a Python exception. For example, trying to run "
15246 "the output of the <literal role=\"template-keyword\">desc</literal> keyword "
15247 "into the <literal role=\"template-kw-filt-date\">isodate</literal> filter is "
15248 "not a good idea."
15249 msgstr ""
15251 #. type: Content of: <book><chapter><sect1><sect2><title>
15252 #: ../en/ch11-template.xml:427
15253 msgid "Combining filters"
15254 msgstr "组合过滤器"
15256 #. type: Content of: <book><chapter><sect1><sect2><para>
15257 #: ../en/ch11-template.xml:429
15258 msgid ""
15259 "It is easy to combine filters to yield output in the form you would like. "
15260 "The following chain of filters tidies up a description, then makes sure that "
15261 "it fits cleanly into 68 columns, then indents it by a further 8 characters "
15262 "(at least on Unix-like systems, where a tab is conventionally 8 characters "
15263 "wide)."
15264 msgstr ""
15266 #. type: Content of: <book><chapter><sect1><sect2><para>
15267 #: ../en/ch11-template.xml:438
15268 msgid ""
15269 "Note the use of <quote><literal>\\t</literal></quote> (a tab character) in "
15270 "the template to force the first line to be indented; this is necessary since "
15271 "<literal role=\"template-keyword\">tabindent</literal> indents all lines "
15272 "<emphasis>except</emphasis> the first."
15273 msgstr ""
15275 #. type: Content of: <book><chapter><sect1><sect2><para>
15276 #: ../en/ch11-template.xml:444
15277 msgid ""
15278 "Keep in mind that the order of filters in a chain is significant. The first "
15279 "filter is applied to the result of the keyword; the second to the result of "
15280 "the first filter; and so on. For example, using <literal>fill68|tabindent</"
15281 "literal> gives very different results from <literal>tabindent|fill68</"
15282 "literal>."
15283 msgstr ""
15285 #. type: Content of: <book><chapter><sect1><title>
15286 #: ../en/ch11-template.xml:454
15287 msgid "From templates to styles"
15288 msgstr "从模版到样式"
15290 #. type: Content of: <book><chapter><sect1><para>
15291 #: ../en/ch11-template.xml:456
15292 msgid ""
15293 "A command line template provides a quick and simple way to format some "
15294 "output. Templates can become verbose, though, and it's useful to be able to "
15295 "give a template a name. A style file is a template with a name, stored in a "
15296 "file."
15297 msgstr ""
15299 #. type: Content of: <book><chapter><sect1><para>
15300 #: ../en/ch11-template.xml:461
15301 msgid ""
15302 "More than that, using a style file unlocks the power of Mercurial's "
15303 "templating engine in ways that are not possible using the command line "
15304 "<option role=\"hg-opt-log\">--template</option> option."
15305 msgstr ""
15307 #. type: Content of: <book><chapter><sect1><sect2><title>
15308 #: ../en/ch11-template.xml:467
15309 msgid "The simplest of style files"
15310 msgstr "最简单的样式文件"
15312 #. type: Content of: <book><chapter><sect1><sect2><para>
15313 #: ../en/ch11-template.xml:469
15314 msgid "Our simple style file contains just one line:"
15315 msgstr ""
15317 #. type: Content of: <book><chapter><sect1><sect2><para>
15318 #: ../en/ch11-template.xml:473
15319 msgid ""
15320 "This tells Mercurial, <quote>if you're printing a changeset, use the text on "
15321 "the right as the template</quote>."
15322 msgstr ""
15324 #. type: Content of: <book><chapter><sect1><sect2><title>
15325 #: ../en/ch11-template.xml:479
15326 msgid "Style file syntax"
15327 msgstr "样式文件语法"
15329 #. type: Content of: <book><chapter><sect1><sect2><para>
15330 #: ../en/ch11-template.xml:481
15331 msgid "The syntax rules for a style file are simple."
15332 msgstr ""
15334 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15335 #: ../en/ch11-template.xml:484
15336 msgid "The file is processed one line at a time."
15337 msgstr ""
15339 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15340 #: ../en/ch11-template.xml:487
15341 msgid "Leading and trailing white space are ignored."
15342 msgstr ""
15344 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15345 #: ../en/ch11-template.xml:490
15346 msgid "Empty lines are skipped."
15347 msgstr ""
15349 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15350 #: ../en/ch11-template.xml:492
15351 msgid ""
15352 "If a line starts with either of the characters <quote><literal>#</literal></"
15353 "quote> or <quote><literal>;</literal></quote>, the entire line is treated as "
15354 "a comment, and skipped as if empty."
15355 msgstr ""
15357 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15358 #: ../en/ch11-template.xml:497
15359 msgid ""
15360 "A line starts with a keyword. This must start with an alphabetic character "
15361 "or underscore, and can subsequently contain any alphanumeric character or "
15362 "underscore. (In regexp notation, a keyword must match <literal>[A-Za-z_][A-"
15363 "Za-z0-9_]*</literal>.)"
15364 msgstr ""
15366 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15367 #: ../en/ch11-template.xml:503
15368 msgid ""
15369 "The next element must be an <quote><literal>=</literal></quote> character, "
15370 "which can be preceded or followed by an arbitrary amount of white space."
15371 msgstr ""
15373 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15374 #: ../en/ch11-template.xml:508
15375 msgid ""
15376 "If the rest of the line starts and ends with matching quote characters "
15377 "(either single or double quote), it is treated as a template body."
15378 msgstr ""
15380 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15381 #: ../en/ch11-template.xml:512
15382 msgid ""
15383 "If the rest of the line <emphasis>does not</emphasis> start with a quote "
15384 "character, it is treated as the name of a file; the contents of this file "
15385 "will be read and used as a template body."
15386 msgstr ""
15388 #. type: Content of: <book><chapter><sect1><title>
15389 #: ../en/ch11-template.xml:521
15390 msgid "Style files by example"
15391 msgstr "样式文件例子"
15393 #. type: Content of: <book><chapter><sect1><para>
15394 #: ../en/ch11-template.xml:523
15395 msgid ""
15396 "To illustrate how to write a style file, we will construct a few by example. "
15397 "Rather than provide a complete style file and walk through it, we'll mirror "
15398 "the usual process of developing a style file by starting with something very "
15399 "simple, and walking through a series of successively more complete examples."
15400 msgstr ""
15402 #. type: Content of: <book><chapter><sect1><sect2><title>
15403 #: ../en/ch11-template.xml:530
15404 msgid "Identifying mistakes in style files"
15405 msgstr "在样式文件中定位错误"
15407 #. type: Content of: <book><chapter><sect1><sect2><para>
15408 #: ../en/ch11-template.xml:532
15409 msgid ""
15410 "If Mercurial encounters a problem in a style file you are working on, it "
15411 "prints a terse error message that, once you figure out what it means, is "
15412 "actually quite useful."
15413 msgstr ""
15415 #. type: Content of: <book><chapter><sect1><sect2><para>
15416 #: ../en/ch11-template.xml:538
15417 msgid ""
15418 "Notice that <filename>broken.style</filename> attempts to define a "
15419 "<literal>changeset</literal> keyword, but forgets to give any content for it. "
15420 "When instructed to use this style file, Mercurial promptly complains."
15421 msgstr ""
15423 #. type: Content of: <book><chapter><sect1><sect2><para>
15424 #: ../en/ch11-template.xml:545
15425 msgid "This error message looks intimidating, but it is not too hard to follow."
15426 msgstr ""
15428 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15429 #: ../en/ch11-template.xml:549
15430 msgid ""
15431 "The first component is simply Mercurial's way of saying <quote>I am giving "
15432 "up</quote>."
15433 msgstr ""
15435 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15436 #: ../en/ch11-template.xml:553
15437 msgid "Next comes the name of the style file that contains the error."
15438 msgstr ""
15440 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15441 #: ../en/ch11-template.xml:557
15442 msgid ""
15443 "Following the file name is the line number where the error was encountered."
15444 msgstr ""
15446 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15447 #: ../en/ch11-template.xml:561
15448 msgid "Finally, a description of what went wrong."
15449 msgstr ""
15451 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15452 #: ../en/ch11-template.xml:565
15453 msgid ""
15454 "The description of the problem is not always clear (as in this case), but "
15455 "even when it is cryptic, it is almost always trivial to visually inspect the "
15456 "offending line in the style file and see what is wrong."
15457 msgstr ""
15459 #. type: Content of: <book><chapter><sect1><sect2><title>
15460 #: ../en/ch11-template.xml:574
15461 msgid "Uniquely identifying a repository"
15462 msgstr "版本库的唯一标识"
15464 #. type: Content of: <book><chapter><sect1><sect2><para>
15465 #: ../en/ch11-template.xml:576
15466 msgid ""
15467 "If you would like to be able to identify a Mercurial repository <quote>fairly "
15468 "uniquely</quote> using a short string as an identifier, you can use the first "
15469 "revision in the repository."
15470 msgstr ""
15472 #. type: Content of: <book><chapter><sect1><sect2><para>
15473 #: ../en/ch11-template.xml:583
15474 msgid ""
15475 "This is likely to be unique, and so it is useful in many cases. There are a "
15476 "few caveats."
15477 msgstr ""
15479 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15480 #: ../en/ch11-template.xml:586
15481 msgid ""
15482 "It will not work in a completely empty repository, because such a repository "
15483 "does not have a revision zero."
15484 msgstr ""
15486 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15487 #: ../en/ch11-template.xml:590
15488 msgid ""
15489 "Neither will it work in the (extremely rare) case where a repository is a "
15490 "merge of two or more formerly independent repositories, and you still have "
15491 "those repositories around."
15492 msgstr ""
15494 #. type: Content of: <book><chapter><sect1><sect2><para>
15495 #: ../en/ch11-template.xml:595
15496 msgid "Here are some uses to which you could put this identifier:"
15497 msgstr ""
15499 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15500 #: ../en/ch11-template.xml:598
15501 msgid ""
15502 "As a key into a table for a database that manages repositories on a server."
15503 msgstr ""
15505 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15506 #: ../en/ch11-template.xml:601
15507 msgid ""
15508 "As half of a {<emphasis>repository ID</emphasis>, <emphasis>revision ID</"
15509 "emphasis>} tuple. Save this information away when you run an automated build "
15510 "or other activity, so that you can <quote>replay</quote> the build later if "
15511 "necessary."
15512 msgstr ""
15514 #. type: Content of: <book><chapter><sect1><sect2><title>
15515 #: ../en/ch11-template.xml:611
15516 msgid "Listing files on multiple lines"
15517 msgstr "每行列出一个文件"
15519 #. type: Content of: <book><chapter><sect1><sect2><para>
15520 #: ../en/ch11-template.xml:613
15521 msgid ""
15522 "Suppose we want to list the files changed by a changeset, one per line, with "
15523 "a little indentation before each file name."
15524 msgstr ""
15526 #. type: Content of: <book><chapter><sect1><sect2><title>
15527 #: ../en/ch11-template.xml:621
15528 msgid "Mimicking Subversion's output"
15529 msgstr "模仿 Subversion 的输出"
15532 #. type: Content of: <book><chapter><sect1><sect2><para>
15533 #: ../en/ch11-template.xml:623
15534 msgid ""
15535 "Let's try to emulate the default output format used by another revision "
15536 "control tool, Subversion."
15537 msgstr ""
15540 #. type: Content of: <book><chapter><sect1><sect2><para>
15541 #: ../en/ch11-template.xml:628
15542 msgid ""
15543 "Since Subversion's output style is fairly simple, it is easy to copy-and-"
15544 "paste a hunk of its output into a file, and replace the text produced above "
15545 "by Subversion with the template values we'd like to see expanded."
15546 msgstr ""
15548 #. type: Content of: <book><chapter><sect1><sect2><para>
15549 #: ../en/ch11-template.xml:635
15550 msgid ""
15551 "There are a few small ways in which this template deviates from the output "
15552 "produced by Subversion."
15553 msgstr ""
15555 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15556 #: ../en/ch11-template.xml:638
15557 msgid ""
15558 "Subversion prints a <quote>readable</quote> date (the <quote><literal>Wed, 27 "
15559 "Sep 2006</literal></quote> in the example output above) in parentheses. "
15560 "Mercurial's templating engine does not provide a way to display a date in "
15561 "this format without also printing the time and time zone."
15562 msgstr ""
15564 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15565 #: ../en/ch11-template.xml:645
15566 msgid ""
15567 "We emulate Subversion's printing of <quote>separator</quote> lines full of "
15568 "<quote><literal>-</literal></quote> characters by ending the template with "
15569 "such a line. We use the templating engine's <literal role=\"template-keyword"
15570 "\">header</literal> keyword to print a separator line as the first line of "
15571 "output (see below), thus achieving similar output to Subversion."
15572 msgstr ""
15574 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15575 #: ../en/ch11-template.xml:654
15576 msgid ""
15577 "Subversion's output includes a count in the header of the number of lines in "
15578 "the commit message. We cannot replicate this in Mercurial; the templating "
15579 "engine does not currently provide a filter that counts the number of lines "
15580 "the template generates."
15581 msgstr ""
15584 #. type: Content of: <book><chapter><sect1><sect2><para>
15585 #: ../en/ch11-template.xml:660
15586 msgid ""
15587 "It took me no more than a minute or two of work to replace literal text from "
15588 "an example of Subversion's output with some keywords and filters to give the "
15589 "template above. The style file simply refers to the template."
15590 msgstr ""
15592 #. type: Content of: <book><chapter><sect1><sect2><para>
15593 #: ../en/ch11-template.xml:667
15594 msgid ""
15595 "We could have included the text of the template file directly in the style "
15596 "file by enclosing it in quotes and replacing the newlines with "
15597 "<quote><literal>\\n</literal></quote> sequences, but it would have made the "
15598 "style file too difficult to read. Readability is a good guide when you're "
15599 "trying to decide whether some text belongs in a style file, or in a template "
15600 "file that the style file points to. If the style file will look too big or "
15601 "cluttered if you insert a literal piece of text, drop it into a template "
15602 "instead."
15603 msgstr ""
15605 #. type: Content of: <book><chapter><title>
15606 #: ../en/ch12-mq.xml:5
15607 msgid "Managing change with Mercurial Queues"
15608 msgstr "使用 MQ 管理修改"
15610 #. type: Content of: <book><chapter><sect1><title>
15611 #: ../en/ch12-mq.xml:8
15612 msgid "The patch management problem"
15613 msgstr "补丁的管理问题"
15615 #. type: Content of: <book><chapter><sect1><para>
15616 #: ../en/ch12-mq.xml:10
15617 msgid ""
15618 "Here is a common scenario: you need to install a software package from "
15619 "source, but you find a bug that you must fix in the source before you can "
15620 "start using the package. You make your changes, forget about the package for "
15621 "a while, and a few months later you need to upgrade to a newer version of the "
15622 "package. If the newer version of the package still has the bug, you must "
15623 "extract your fix from the older source tree and apply it against the newer "
15624 "version. This is a tedious task, and it's easy to make mistakes."
15625 msgstr ""
15627 #. type: Content of: <book><chapter><sect1><para>
15628 #: ../en/ch12-mq.xml:20
15629 msgid ""
15630 "This is a simple case of the <quote>patch management</quote> problem. You "
15631 "have an <quote>upstream</quote> source tree that you can't change; you need "
15632 "to make some local changes on top of the upstream tree; and you'd like to be "
15633 "able to keep those changes separate, so that you can apply them to newer "
15634 "versions of the upstream source."
15635 msgstr ""
15637 #. type: Content of: <book><chapter><sect1><para>
15638 #: ../en/ch12-mq.xml:27
15639 msgid ""
15640 "The patch management problem arises in many situations. Probably the most "
15641 "visible is that a user of an open source software project will contribute a "
15642 "bug fix or new feature to the project's maintainers in the form of a patch."
15643 msgstr ""
15645 #. type: Content of: <book><chapter><sect1><para>
15646 #: ../en/ch12-mq.xml:32
15647 msgid ""
15648 "Distributors of operating systems that include open source software often "
15649 "need to make changes to the packages they distribute so that they will build "
15650 "properly in their environments."
15651 msgstr ""
15653 #. type: Content of: <book><chapter><sect1><para>
15654 #: ../en/ch12-mq.xml:37
15655 msgid ""
15656 "When you have few changes to maintain, it is easy to manage a single patch "
15657 "using the standard <command>diff</command> and <command>patch</command> "
15658 "programs (see <xref linkend=\"sec:mq:patch\"/> for a discussion of these "
15659 "tools). Once the number of changes grows, it starts to make sense to maintain "
15660 "patches as discrete <quote>chunks of work,</quote> so that for example a "
15661 "single patch will contain only one bug fix (the patch might modify several "
15662 "files, but it's doing <quote>only one thing</quote>), and you may have a "
15663 "number of such patches for different bugs you need fixed and local changes "
15664 "you require. In this situation, if you submit a bug fix patch to the "
15665 "upstream maintainers of a package and they include your fix in a subsequent "
15666 "release, you can simply drop that single patch when you're updating to the "
15667 "newer release."
15668 msgstr ""
15670 #. type: Content of: <book><chapter><sect1><para>
15671 #: ../en/ch12-mq.xml:52
15672 msgid ""
15673 "Maintaining a single patch against an upstream tree is a little tedious and "
15674 "error-prone, but not difficult. However, the complexity of the problem grows "
15675 "rapidly as the number of patches you have to maintain increases. With more "
15676 "than a tiny number of patches in hand, understanding which ones you have "
15677 "applied and maintaining them moves from messy to overwhelming."
15678 msgstr ""
15680 #. type: Content of: <book><chapter><sect1><para>
15681 #: ../en/ch12-mq.xml:59
15682 msgid ""
15683 "Fortunately, Mercurial includes a powerful extension, Mercurial Queues (or "
15684 "simply <quote>MQ</quote>), that massively simplifies the patch management "
15685 "problem."
15686 msgstr ""
15688 #. type: Content of: <book><chapter><sect1><title>
15689 #: ../en/ch12-mq.xml:65
15690 msgid "The prehistory of Mercurial Queues"
15691 msgstr "MQ 的历史"
15693 #. type: Content of: <book><chapter><sect1><para>
15694 #: ../en/ch12-mq.xml:67
15695 msgid ""
15696 "During the late 1990s, several Linux kernel developers started to maintain "
15697 "<quote>patch series</quote> that modified the behavior of the Linux kernel. "
15698 "Some of these series were focused on stability, some on feature coverage, and "
15699 "others were more speculative."
15700 msgstr ""
15702 #. type: Content of: <book><chapter><sect1><para>
15703 #: ../en/ch12-mq.xml:73
15704 msgid ""
15705 "The sizes of these patch series grew rapidly. In 2002, Andrew Morton "
15706 "published some shell scripts he had been using to automate the task of "
15707 "managing his patch queues. Andrew was successfully using these scripts to "
15708 "manage hundreds (sometimes thousands) of patches on top of the Linux kernel."
15709 msgstr ""
15711 #. type: Content of: <book><chapter><sect1><sect2><title>
15712 #: ../en/ch12-mq.xml:80
15713 msgid "A patchwork quilt"
15714 msgstr ""
15716 #. type: Content of: <book><chapter><sect1><sect2><para>
15717 #: ../en/ch12-mq.xml:82
15718 msgid ""
15719 "In early 2003, Andreas Gruenbacher and Martin Quinson borrowed the approach "
15720 "of Andrew's scripts and published a tool called <quote>patchwork quilt</"
15721 "quote> <citation>web:quilt</citation>, or simply <quote>quilt</quote> (see "
15722 "<citation>gruenbacher:2005</citation> for a paper describing it). Because "
15723 "quilt substantially automated patch management, it rapidly gained a large "
15724 "following among open source software developers."
15725 msgstr ""
15727 #. type: Content of: <book><chapter><sect1><sect2><para>
15728 #: ../en/ch12-mq.xml:91
15729 msgid ""
15730 "Quilt manages a <emphasis>stack of patches</emphasis> on top of a directory "
15731 "tree. To begin, you tell quilt to manage a directory tree, and tell it which "
15732 "files you want to manage; it stores away the names and contents of those "
15733 "files. To fix a bug, you create a new patch (using a single command), edit "
15734 "the files you need to fix, then <quote>refresh</quote> the patch."
15735 msgstr ""
15737 #. type: Content of: <book><chapter><sect1><sect2><para>
15738 #: ../en/ch12-mq.xml:99
15739 msgid ""
15740 "The refresh step causes quilt to scan the directory tree; it updates the "
15741 "patch with all of the changes you have made. You can create another patch on "
15742 "top of the first, which will track the changes required to modify the tree "
15743 "from <quote>tree with one patch applied</quote> to <quote>tree with two "
15744 "patches applied</quote>."
15745 msgstr ""
15747 #. type: Content of: <book><chapter><sect1><sect2><para>
15748 #: ../en/ch12-mq.xml:106
15749 msgid ""
15750 "You can <emphasis>change</emphasis> which patches are applied to the tree. "
15751 "If you <quote>pop</quote> a patch, the changes made by that patch will vanish "
15752 "from the directory tree. Quilt remembers which patches you have popped, "
15753 "though, so you can <quote>push</quote> a popped patch again, and the "
15754 "directory tree will be restored to contain the modifications in the patch. "
15755 "Most importantly, you can run the <quote>refresh</quote> command at any time, "
15756 "and the topmost applied patch will be updated. This means that you can, at "
15757 "any time, change both which patches are applied and what modifications those "
15758 "patches make."
15759 msgstr ""
15761 #. type: Content of: <book><chapter><sect1><sect2><para>
15762 #: ../en/ch12-mq.xml:118
15763 msgid ""
15764 "Quilt knows nothing about revision control tools, so it works equally well on "
15765 "top of an unpacked tarball or a Subversion working copy."
15766 msgstr ""
15768 #. type: Content of: <book><chapter><sect1><sect2><title>
15769 #: ../en/ch12-mq.xml:124
15770 msgid "From patchwork quilt to Mercurial Queues"
15771 msgstr "从 patchwork quilt 到 MQ"
15773 #. type: Content of: <book><chapter><sect1><sect2><para>
15774 #: ../en/ch12-mq.xml:126
15775 msgid ""
15776 "In mid-2005, Chris Mason took the features of quilt and wrote an extension "
15777 "that he called Mercurial Queues, which added quilt-like behavior to Mercurial."
15778 msgstr ""
15780 #. type: Content of: <book><chapter><sect1><sect2><para>
15781 #: ../en/ch12-mq.xml:130
15782 msgid ""
15783 "The key difference between quilt and MQ is that quilt knows nothing about "
15784 "revision control systems, while MQ is <emphasis>integrated</emphasis> into "
15785 "Mercurial. Each patch that you push is represented as a Mercurial "
15786 "changeset. Pop a patch, and the changeset goes away."
15787 msgstr ""
15789 #. type: Content of: <book><chapter><sect1><sect2><para>
15790 #: ../en/ch12-mq.xml:136
15791 msgid ""
15792 "Because quilt does not care about revision control tools, it is still a "
15793 "tremendously useful piece of software to know about for situations where you "
15794 "cannot use Mercurial and MQ."
15795 msgstr ""
15797 #. type: Content of: <book><chapter><sect1><title>
15798 #: ../en/ch12-mq.xml:144
15799 msgid "The huge advantage of MQ"
15800 msgstr "MQ 的巨大优势"
15802 #. type: Content of: <book><chapter><sect1><para>
15803 #: ../en/ch12-mq.xml:146
15804 msgid ""
15805 "I cannot overstate the value that MQ offers through the unification of "
15806 "patches and revision control."
15807 msgstr ""
15809 #. type: Content of: <book><chapter><sect1><para>
15810 #: ../en/ch12-mq.xml:149
15811 msgid ""
15812 "A major reason that patches have persisted in the free software and open "
15813 "source world&emdash;in spite of the availability of increasingly capable "
15814 "revision control tools over the years&emdash;is the <emphasis>agility</"
15815 "emphasis> they offer."
15816 msgstr ""
15818 #. type: Content of: <book><chapter><sect1><para>
15819 #: ../en/ch12-mq.xml:155
15820 msgid ""
15821 "Traditional revision control tools make a permanent, irreversible record of "
15822 "everything that you do. While this has great value, it's also somewhat "
15823 "stifling. If you want to perform a wild-eyed experiment, you have to be "
15824 "careful in how you go about it, or you risk leaving unneeded&emdash;or worse, "
15825 "misleading or destabilising&emdash;traces of your missteps and errors in the "
15826 "permanent revision record."
15827 msgstr ""
15829 #. type: Content of: <book><chapter><sect1><para>
15830 #: ../en/ch12-mq.xml:163
15831 msgid ""
15832 "By contrast, MQ's marriage of distributed revision control with patches makes "
15833 "it much easier to isolate your work. Your patches live on top of normal "
15834 "revision history, and you can make them disappear or reappear at will. If "
15835 "you don't like a patch, you can drop it. If a patch isn't quite as you want "
15836 "it to be, simply fix it&emdash;as many times as you need to, until you have "
15837 "refined it into the form you desire."
15838 msgstr ""
15840 #. type: Content of: <book><chapter><sect1><para>
15841 #: ../en/ch12-mq.xml:171
15842 msgid ""
15843 "As an example, the integration of patches with revision control makes "
15844 "understanding patches and debugging their effects&emdash;and their interplay "
15845 "with the code they're based on&emdash;<emphasis>enormously</emphasis> easier. "
15846 "Since every applied patch has an associated changeset, you can give <command "
15847 "role=\"hg-cmd\">hg log</command> a file name to see which changesets and "
15848 "patches affected the file. You can use the <command role=\"hg-cmd\">hg "
15849 "bisect</command> command to binary-search through all changesets and applied "
15850 "patches to see where a bug got introduced or fixed. You can use the <command "
15851 "role=\"hg-cmd\">hg annotate</command> command to see which changeset or patch "
15852 "modified a particular line of a source file. And so on."
15853 msgstr ""
15855 #. type: Content of: <book><chapter><sect1><para>
15856 #: ../en/ch12-mq.xml:189
15857 msgid ""
15858 "Because MQ doesn't hide its patch-oriented nature, it is helpful to "
15859 "understand what patches are, and a little about the tools that work with them."
15860 msgstr ""
15862 #. type: Content of: <book><chapter><sect1><para>
15863 #: ../en/ch12-mq.xml:193
15864 msgid ""
15865 "The traditional Unix <command>diff</command> command compares two files, and "
15866 "prints a list of differences between them. The <command>patch</command> "
15867 "command understands these differences as <emphasis>modifications</emphasis> "
15868 "to make to a file. Take a look below for a simple example of these commands "
15869 "in action."
15870 msgstr ""
15872 #. type: Content of: <book><chapter><sect1><para>
15873 #: ../en/ch12-mq.xml:202
15874 msgid ""
15875 "The type of file that <command>diff</command> generates (and <command>patch</"
15876 "command> takes as input) is called a <quote>patch</quote> or a <quote>diff</"
15877 "quote>; there is no difference between a patch and a diff. (We'll use the "
15878 "term <quote>patch</quote>, since it's more commonly used.)"
15879 msgstr ""
15881 #. type: Content of: <book><chapter><sect1><para>
15882 #: ../en/ch12-mq.xml:208
15883 msgid ""
15884 "A patch file can start with arbitrary text; the <command>patch</command> "
15885 "command ignores this text, but MQ uses it as the commit message when creating "
15886 "changesets. To find the beginning of the patch content, <command>patch</"
15887 "command> searches for the first line that starts with the string "
15888 "<quote><literal>diff -</literal></quote>."
15889 msgstr ""
15891 #. type: Content of: <book><chapter><sect1><para>
15892 #: ../en/ch12-mq.xml:215
15893 msgid ""
15894 "MQ works with <emphasis>unified</emphasis> diffs (<command>patch</command> "
15895 "can accept several other diff formats, but MQ doesn't). A unified diff "
15896 "contains two kinds of header. The <emphasis>file header</emphasis> describes "
15897 "the file being modified; it contains the name of the file to modify. When "
15898 "<command>patch</command> sees a new file header, it looks for a file with "
15899 "that name to start modifying."
15900 msgstr ""
15902 #. type: Content of: <book><chapter><sect1><para>
15903 #: ../en/ch12-mq.xml:223
15904 msgid ""
15905 "After the file header comes a series of <emphasis>hunks</emphasis>. Each "
15906 "hunk starts with a header; this identifies the range of line numbers within "
15907 "the file that the hunk should modify. Following the header, a hunk starts "
15908 "and ends with a few (usually three) lines of text from the unmodified file; "
15909 "these are called the <emphasis>context</emphasis> for the hunk. If there's "
15910 "only a small amount of context between successive hunks, <command>diff</"
15911 "command> doesn't print a new hunk header; it just runs the hunks together, "
15912 "with a few lines of context between modifications."
15913 msgstr ""
15915 #. type: Content of: <book><chapter><sect1><para>
15916 #: ../en/ch12-mq.xml:235
15917 msgid ""
15918 "Each line of context begins with a space character. Within the hunk, a line "
15919 "that begins with <quote><literal>-</literal></quote> means <quote>remove this "
15920 "line,</quote> while a line that begins with <quote><literal>+</literal></"
15921 "quote> means <quote>insert this line.</quote> For example, a line that is "
15922 "modified is represented by one deletion and one insertion."
15923 msgstr ""
15925 #. type: Content of: <book><chapter><sect1><para>
15926 #: ../en/ch12-mq.xml:243
15927 msgid ""
15928 "We will return to some of the more subtle aspects of patches later (in <xref "
15929 "linkend=\"sec:mq:adv-patch\"/>), but you should have enough information now "
15930 "to use MQ."
15931 msgstr ""
15933 #. type: Content of: <book><chapter><sect1><title>
15934 #: ../en/ch12-mq.xml:250
15935 msgid "Getting started with Mercurial Queues"
15936 msgstr "开始使用 MQ"
15938 #. type: Content of: <book><chapter><sect1><para>
15939 #: ../en/ch12-mq.xml:252
15940 msgid ""
15941 "Because MQ is implemented as an extension, you must explicitly enable before "
15942 "you can use it. (You don't need to download anything; MQ ships with the "
15943 "standard Mercurial distribution.) To enable MQ, edit your <filename role="
15944 "\"home\">~/.hgrc</filename> file, and add the lines below."
15945 msgstr ""
15947 #. type: Content of: <book><chapter><sect1><para>
15948 #: ../en/ch12-mq.xml:262
15949 msgid ""
15950 "Once the extension is enabled, it will make a number of new commands "
15951 "available. To verify that the extension is working, you can use <command "
15952 "role=\"hg-cmd\">hg help</command> to see if the <command role=\"hg-ext-mq"
15953 "\">qinit</command> command is now available."
15954 msgstr ""
15956 #. type: Content of: <book><chapter><sect1><para>
15957 #: ../en/ch12-mq.xml:270
15958 msgid ""
15959 "You can use MQ with <emphasis>any</emphasis> Mercurial repository, and its "
15960 "commands only operate within that repository. To get started, simply prepare "
15961 "the repository using the <command role=\"hg-ext-mq\">qinit</command> command."
15962 msgstr ""
15964 #. type: Content of: <book><chapter><sect1><para>
15965 #: ../en/ch12-mq.xml:277
15966 msgid ""
15967 "This command creates an empty directory called <filename role=\"special\" "
15968 "class=\"directory\">.hg/patches</filename>, where MQ will keep its metadata. "
15969 "As with many Mercurial commands, the <command role=\"hg-ext-mq\">qinit</"
15970 "command> command prints nothing if it succeeds."
15971 msgstr ""
15973 #. type: Content of: <book><chapter><sect1><sect2><title>
15974 #: ../en/ch12-mq.xml:284
15975 msgid "Creating a new patch"
15976 msgstr "创建新补丁"
15978 #. type: Content of: <book><chapter><sect1><sect2><para>
15979 #: ../en/ch12-mq.xml:286
15980 msgid ""
15981 "To begin work on a new patch, use the <command role=\"hg-ext-mq\">qnew</"
15982 "command> command. This command takes one argument, the name of the patch to "
15983 "create."
15984 msgstr ""
15986 #. type: Content of: <book><chapter><sect1><sect2><para>
15987 #: ../en/ch12-mq.xml:290
15988 msgid ""
15989 "MQ will use this as the name of an actual file in the <filename role=\"special"
15990 "\" class=\"directory\">.hg/patches</filename> directory, as you can see below."
15991 msgstr ""
15993 #. type: Content of: <book><chapter><sect1><sect2><para>
15994 #: ../en/ch12-mq.xml:297
15995 msgid ""
15996 "Also newly present in the <filename role=\"special\" class=\"directory\">.hg/"
15997 "patches</filename> directory are two other files, <filename role=\"special"
15998 "\">series</filename> and <filename role=\"special\">status</filename>. The "
15999 "<filename role=\"special\">series</filename> file lists all of the patches "
16000 "that MQ knows about for this repository, with one patch per line. Mercurial "
16001 "uses the <filename role=\"special\">status</filename> file for internal book-"
16002 "keeping; it tracks all of the patches that MQ has <emphasis>applied</"
16003 "emphasis> in this repository."
16004 msgstr ""
16006 #. type: Content of: <book><chapter><sect1><sect2><note><para>
16007 #: ../en/ch12-mq.xml:309
16008 msgid ""
16009 "You may sometimes want to edit the <filename role=\"special\">series</"
16010 "filename> file by hand; for example, to change the sequence in which some "
16011 "patches are applied. However, manually editing the <filename role=\"special"
16012 "\">status</filename> file is almost always a bad idea, as it's easy to "
16013 "corrupt MQ's idea of what is happening."
16014 msgstr ""
16016 #. type: Content of: <book><chapter><sect1><sect2><para>
16017 #: ../en/ch12-mq.xml:318
16018 msgid ""
16019 "Once you have created your new patch, you can edit files in the working "
16020 "directory as you usually would. All of the normal Mercurial commands, such "
16021 "as <command role=\"hg-cmd\">hg diff</command> and <command role=\"hg-cmd\">hg "
16022 "annotate</command>, work exactly as they did before."
16023 msgstr ""
16025 #. type: Content of: <book><chapter><sect1><sect2><title>
16026 #: ../en/ch12-mq.xml:326
16027 msgid "Refreshing a patch"
16028 msgstr "刷新补丁"
16030 #. type: Content of: <book><chapter><sect1><sect2><para>
16031 #: ../en/ch12-mq.xml:328
16032 msgid ""
16033 "When you reach a point where you want to save your work, use the <command "
16034 "role=\"hg-ext-mq\">qrefresh</command> command to update the patch you are "
16035 "working on."
16036 msgstr ""
16038 #. type: Content of: <book><chapter><sect1><sect2><para>
16039 #: ../en/ch12-mq.xml:334
16040 msgid ""
16041 "This command folds the changes you have made in the working directory into "
16042 "your patch, and updates its corresponding changeset to contain those changes."
16043 msgstr ""
16045 #. type: Content of: <book><chapter><sect1><sect2><para>
16046 #: ../en/ch12-mq.xml:338
16047 msgid ""
16048 "You can run <command role=\"hg-ext-mq\">qrefresh</command> as often as you "
16049 "like, so it's a good way to <quote>checkpoint</quote> your work. Refresh "
16050 "your patch at an opportune time; try an experiment; and if the experiment "
16051 "doesn't work out, <command role=\"hg-cmd\">hg revert</command> your "
16052 "modifications back to the last time you refreshed."
16053 msgstr ""
16055 #. type: Content of: <book><chapter><sect1><sect2><title>
16056 #: ../en/ch12-mq.xml:349
16057 msgid "Stacking and tracking patches"
16058 msgstr "堆叠和跟踪补丁"
16060 #. type: Content of: <book><chapter><sect1><sect2><para>
16061 #: ../en/ch12-mq.xml:351
16062 msgid ""
16063 "Once you have finished working on a patch, or need to work on another, you "
16064 "can use the <command role=\"hg-ext-mq\">qnew</command> command again to "
16065 "create a new patch. Mercurial will apply this patch on top of your existing "
16066 "patch."
16067 msgstr ""
16069 #. type: Content of: <book><chapter><sect1><sect2><para>
16070 #: ../en/ch12-mq.xml:359
16071 msgid ""
16072 "Notice that the patch contains the changes in our prior patch as part of its "
16073 "context (you can see this more clearly in the output of <command role=\"hg-cmd"
16074 "\">hg annotate</command>)."
16075 msgstr ""
16077 #. type: Content of: <book><chapter><sect1><sect2><para>
16078 #: ../en/ch12-mq.xml:364
16079 msgid ""
16080 "So far, with the exception of <command role=\"hg-ext-mq\">qnew</command> and "
16081 "<command role=\"hg-ext-mq\">qrefresh</command>, we've been careful to only "
16082 "use regular Mercurial commands. However, MQ provides many commands that are "
16083 "easier to use when you are thinking about patches, as illustrated below."
16084 msgstr ""
16086 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16087 #: ../en/ch12-mq.xml:374
16088 msgid ""
16089 "The <command role=\"hg-ext-mq\">qseries</command> command lists every patch "
16090 "that MQ knows about in this repository, from oldest to newest (most recently "
16091 "<emphasis>created</emphasis>)."
16092 msgstr ""
16094 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16095 #: ../en/ch12-mq.xml:380
16096 msgid ""
16097 "The <command role=\"hg-ext-mq\">qapplied</command> command lists every patch "
16098 "that MQ has <emphasis>applied</emphasis> in this repository, again from "
16099 "oldest to newest (most recently applied)."
16100 msgstr ""
16102 #. type: Content of: <book><chapter><sect1><sect2><title>
16103 #: ../en/ch12-mq.xml:389
16104 msgid "Manipulating the patch stack"
16105 msgstr "操作补丁堆栈"
16107 #. type: Content of: <book><chapter><sect1><sect2><para>
16108 #: ../en/ch12-mq.xml:391
16109 msgid ""
16110 "The previous discussion implied that there must be a difference between "
16111 "<quote>known</quote> and <quote>applied</quote> patches, and there is. MQ "
16112 "can manage a patch without it being applied in the repository."
16113 msgstr ""
16115 #. type: Content of: <book><chapter><sect1><sect2><para>
16116 #: ../en/ch12-mq.xml:396
16117 msgid ""
16118 "An <emphasis>applied</emphasis> patch has a corresponding changeset in the "
16119 "repository, and the effects of the patch and changeset are visible in the "
16120 "working directory. You can undo the application of a patch using the "
16121 "<command role=\"hg-ext-mq\">qpop</command> command. MQ still <emphasis>knows "
16122 "about</emphasis>, or manages, a popped patch, but the patch no longer has a "
16123 "corresponding changeset in the repository, and the working directory does not "
16124 "contain the changes made by the patch. <xref linkend=\"fig:mq:stack\"/> "
16125 "illustrates the difference between applied and tracked patches."
16126 msgstr ""
16128 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
16129 #: ../en/ch12-mq.xml:409
16130 msgid "Applied and unapplied patches in the MQ patch stack"
16131 msgstr "在 MQ 补丁堆栈中应用和撤销补丁"
16133 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
16134 #: ../en/ch12-mq.xml:412
16135 msgid "<imageobject><imagedata fileref=\"figs/mq-stack.png\"/></imageobject>"
16136 msgstr ""
16138 #. type: Content of: <book><chapter><sect1><sect2><para>
16139 #: ../en/ch12-mq.xml:417
16140 msgid ""
16141 "You can reapply an unapplied, or popped, patch using the <command role=\"hg-"
16142 "ext-mq\">qpush</command> command. This creates a new changeset to correspond "
16143 "to the patch, and the patch's changes once again become present in the "
16144 "working directory. See below for examples of <command role=\"hg-ext-mq"
16145 "\">qpop</command> and <command role=\"hg-ext-mq\">qpush</command> in action."
16146 msgstr ""
16148 #. type: Content of: <book><chapter><sect1><sect2><para>
16149 #: ../en/ch12-mq.xml:427
16150 msgid ""
16151 "Notice that once we have popped a patch or two patches, the output of "
16152 "<command role=\"hg-ext-mq\">qseries</command> remains the same, while that of "
16153 "<command role=\"hg-ext-mq\">qapplied</command> has changed."
16154 msgstr ""
16156 #. type: Content of: <book><chapter><sect1><sect2><title>
16157 #: ../en/ch12-mq.xml:435
16158 msgid "Pushing and popping many patches"
16159 msgstr "压入或弹出多个补丁"
16161 #. type: Content of: <book><chapter><sect1><sect2><para>
16162 #: ../en/ch12-mq.xml:437
16163 msgid ""
16164 "While <command role=\"hg-ext-mq\">qpush</command> and <command role=\"hg-ext-"
16165 "mq\">qpop</command> each operate on a single patch at a time by default, you "
16166 "can push and pop many patches in one go. The <option role=\"hg-ext-mq-cmd-"
16167 "qpush-opt\">-a</option> option to <command role=\"hg-ext-mq\">qpush</command> "
16168 "causes it to push all unapplied patches, while the <option role=\"hg-ext-mq-"
16169 "cmd-qpop-opt\">-a</option> option to <command role=\"hg-ext-mq\">qpop</"
16170 "command> causes it to pop all applied patches. (For some more ways to push "
16171 "and pop many patches, see <xref linkend=\"sec:mq:perf\"/> below.)"
16172 msgstr ""
16174 #. type: Content of: <book><chapter><sect1><sect2><title>
16175 #: ../en/ch12-mq.xml:453
16176 msgid "Safety checks, and overriding them"
16177 msgstr "安全的检查,然后覆盖它们"
16179 #. type: Content of: <book><chapter><sect1><sect2><para>
16180 #: ../en/ch12-mq.xml:455
16181 msgid ""
16182 "Several MQ commands check the working directory before they do anything, and "
16183 "fail if they find any modifications. They do this to ensure that you won't "
16184 "lose any changes that you have made, but not yet incorporated into a patch. "
16185 "The example below illustrates this; the <command role=\"hg-ext-mq\">qnew</"
16186 "command> command will not create a new patch if there are outstanding "
16187 "changes, caused in this case by the <command role=\"hg-cmd\">hg add</command> "
16188 "of <filename>file3</filename>."
16189 msgstr ""
16191 #. type: Content of: <book><chapter><sect1><sect2><para>
16192 #: ../en/ch12-mq.xml:467
16193 msgid ""
16194 "Commands that check the working directory all take an <quote>I know what I'm "
16195 "doing</quote> option, which is always named <option>-f</option>. The exact "
16196 "meaning of <option>-f</option> depends on the command. For example, <command "
16197 "role=\"hg-cmd\">hg qnew <option role=\"hg-ext-mq-cmd-qnew-opt\">-f</option></"
16198 "command> will incorporate any outstanding changes into the new patch it "
16199 "creates, but <command role=\"hg-cmd\">hg qpop <option role=\"hg-ext-mq-cmd-"
16200 "qpop-opt\">-f</option></command> will revert modifications to any files "
16201 "affected by the patch that it is popping. Be sure to read the documentation "
16202 "for a command's <option>-f</option> option before you use it!"
16203 msgstr ""
16205 #. type: Content of: <book><chapter><sect1><sect2><title>
16206 #: ../en/ch12-mq.xml:482
16207 msgid "Working on several patches at once"
16208 msgstr "同时处理多个补丁"
16210 #. type: Content of: <book><chapter><sect1><sect2><para>
16211 #: ../en/ch12-mq.xml:484
16212 msgid ""
16213 "The <command role=\"hg-ext-mq\">qrefresh</command> command always refreshes "
16214 "the <emphasis>topmost</emphasis> applied patch. This means that you can "
16215 "suspend work on one patch (by refreshing it), pop or push to make a different "
16216 "patch the top, and work on <emphasis>that</emphasis> patch for a while."
16217 msgstr ""
16219 #. type: Content of: <book><chapter><sect1><sect2><para>
16220 #: ../en/ch12-mq.xml:491
16221 msgid ""
16222 "Here's an example that illustrates how you can use this ability. Let's say "
16223 "you're developing a new feature as two patches. The first is a change to the "
16224 "core of your software, and the second&emdash;layered on top of the "
16225 "first&emdash;changes the user interface to use the code you just added to the "
16226 "core. If you notice a bug in the core while you're working on the UI patch, "
16227 "it's easy to fix the core. Simply <command role=\"hg-ext-mq\">qrefresh</"
16228 "command> the UI patch to save your in-progress changes, and <command role="
16229 "\"hg-ext-mq\">qpop</command> down to the core patch. Fix the core bug, "
16230 "<command role=\"hg-ext-mq\">qrefresh</command> the core patch, and <command "
16231 "role=\"hg-ext-mq\">qpush</command> back to the UI patch to continue where you "
16232 "left off."
16233 msgstr ""
16235 #. type: Content of: <book><chapter><sect1><title>
16236 #: ../en/ch12-mq.xml:508
16237 msgid "More about patches"
16238 msgstr "关于补丁的更多信息"
16240 #. type: Content of: <book><chapter><sect1><para>
16241 #: ../en/ch12-mq.xml:510
16242 msgid ""
16243 "MQ uses the GNU <command>patch</command> command to apply patches, so it's "
16244 "helpful to know a few more detailed aspects of how <command>patch</command> "
16245 "works, and about patches themselves."
16246 msgstr ""
16248 #. type: Content of: <book><chapter><sect1><sect2><title>
16249 #: ../en/ch12-mq.xml:516
16250 msgid "The strip count"
16251 msgstr "修剪计数"
16253 #. type: Content of: <book><chapter><sect1><sect2><para>
16254 #: ../en/ch12-mq.xml:518
16255 msgid ""
16256 "If you look at the file headers in a patch, you will notice that the "
16257 "pathnames usually have an extra component on the front that isn't present in "
16258 "the actual path name. This is a holdover from the way that people used to "
16259 "generate patches (people still do this, but it's somewhat rare with modern "
16260 "revision control tools)."
16261 msgstr ""
16263 #. type: Content of: <book><chapter><sect1><sect2><para>
16264 #: ../en/ch12-mq.xml:525
16265 msgid ""
16266 "Alice would unpack a tarball, edit her files, then decide that she wanted to "
16267 "create a patch. So she'd rename her working directory, unpack the tarball "
16268 "again (hence the need for the rename), and use the <option role=\"cmd-opt-diff"
16269 "\">-r</option> and <option role=\"cmd-opt-diff\">-N</option> options to "
16270 "<command>diff</command> to recursively generate a patch between the "
16271 "unmodified directory and the modified one. The result would be that the name "
16272 "of the unmodified directory would be at the front of the left-hand path in "
16273 "every file header, and the name of the modified directory would be at the "
16274 "front of the right-hand path."
16275 msgstr ""
16277 #. type: Content of: <book><chapter><sect1><sect2><para>
16278 #: ../en/ch12-mq.xml:538
16279 msgid ""
16280 "Since someone receiving a patch from the Alices of the net would be unlikely "
16281 "to have unmodified and modified directories with exactly the same names, the "
16282 "<command>patch</command> command has a <option role=\"cmd-opt-patch\">-p</"
16283 "option> option that indicates the number of leading path name components to "
16284 "strip when trying to apply a patch. This number is called the "
16285 "<emphasis>strip count</emphasis>."
16286 msgstr ""
16288 #. type: Content of: <book><chapter><sect1><sect2><para>
16289 #: ../en/ch12-mq.xml:546
16290 msgid ""
16291 "An option of <quote><literal>-p1</literal></quote> means <quote>use a strip "
16292 "count of one</quote>. If <command>patch</command> sees a file name "
16293 "<filename>foo/bar/baz</filename> in a file header, it will strip "
16294 "<filename>foo</filename> and try to patch a file named <filename>bar/baz</"
16295 "filename>. (Strictly speaking, the strip count refers to the number of "
16296 "<emphasis>path separators</emphasis> (and the components that go with them ) "
16297 "to strip. A strip count of one will turn <filename>foo/bar</filename> into "
16298 "<filename>bar</filename>, but <filename>/foo/bar</filename> (notice the extra "
16299 "leading slash) into <filename>foo/bar</filename>.)"
16300 msgstr ""
16302 #. type: Content of: <book><chapter><sect1><sect2><para>
16303 #: ../en/ch12-mq.xml:559
16304 msgid ""
16305 "The <quote>standard</quote> strip count for patches is one; almost all "
16306 "patches contain one leading path name component that needs to be stripped. "
16307 "Mercurial's <command role=\"hg-cmd\">hg diff</command> command generates path "
16308 "names in this form, and the <command role=\"hg-cmd\">hg import</command> "
16309 "command and MQ expect patches to have a strip count of one."
16310 msgstr ""
16312 #. type: Content of: <book><chapter><sect1><sect2><para>
16313 #: ../en/ch12-mq.xml:567
16314 msgid ""
16315 "If you receive a patch from someone that you want to add to your patch queue, "
16316 "and the patch needs a strip count other than one, you cannot just <command "
16317 "role=\"hg-ext-mq\">qimport</command> the patch, because <command role=\"hg-"
16318 "ext-mq\">qimport</command> does not yet have a <literal>-p</literal> option "
16319 "(see <ulink role=\"hg-bug\" url=\"http://www.selenic.com/mercurial/bts/"
16320 "issue311\">issue 311</ulink>). Your best bet is to <command role=\"hg-ext-mq"
16321 "\">qnew</command> a patch of your own, then use <command>patch -pN</command> "
16322 "to apply their patch, followed by <command role=\"hg-cmd\">hg addremove</"
16323 "command> to pick up any files added or removed by the patch, followed by "
16324 "<command role=\"hg-ext-mq\">hg qrefresh</command>. This complexity may become "
16325 "unnecessary; see <ulink role=\"hg-bug\" url=\"http://www.selenic.com/"
16326 "mercurial/bts/issue311\">issue 311</ulink> for details."
16327 msgstr ""
16329 #. type: Content of: <book><chapter><sect1><sect2><title>
16330 #: ../en/ch12-mq.xml:587
16331 msgid "Strategies for applying a patch"
16332 msgstr "应用补丁的策略"
16334 #. type: Content of: <book><chapter><sect1><sect2><para>
16335 #: ../en/ch12-mq.xml:589
16336 msgid ""
16337 "When <command>patch</command> applies a hunk, it tries a handful of "
16338 "successively less accurate strategies to try to make the hunk apply. This "
16339 "falling-back technique often makes it possible to take a patch that was "
16340 "generated against an old version of a file, and apply it against a newer "
16341 "version of that file."
16342 msgstr ""
16344 #. type: Content of: <book><chapter><sect1><sect2><para>
16345 #: ../en/ch12-mq.xml:596
16346 msgid ""
16347 "First, <command>patch</command> tries an exact match, where the line numbers, "
16348 "the context, and the text to be modified must apply exactly. If it cannot "
16349 "make an exact match, it tries to find an exact match for the context, without "
16350 "honouring the line numbering information. If this succeeds, it prints a line "
16351 "of output saying that the hunk was applied, but at some <emphasis>offset</"
16352 "emphasis> from the original line number."
16353 msgstr ""
16355 #. type: Content of: <book><chapter><sect1><sect2><para>
16356 #: ../en/ch12-mq.xml:605
16357 msgid ""
16358 "If a context-only match fails, <command>patch</command> removes the first and "
16359 "last lines of the context, and tries a <emphasis>reduced</emphasis> context-"
16360 "only match. If the hunk with reduced context succeeds, it prints a message "
16361 "saying that it applied the hunk with a <emphasis>fuzz factor</emphasis> (the "
16362 "number after the fuzz factor indicates how many lines of context "
16363 "<command>patch</command> had to trim before the patch applied)."
16364 msgstr ""
16366 #. type: Content of: <book><chapter><sect1><sect2><para>
16367 #: ../en/ch12-mq.xml:614
16368 msgid ""
16369 "When neither of these techniques works, <command>patch</command> prints a "
16370 "message saying that the hunk in question was rejected. It saves rejected "
16371 "hunks (also simply called <quote>rejects</quote>) to a file with the same "
16372 "name, and an added <filename role=\"special\">.rej</filename> extension. It "
16373 "also saves an unmodified copy of the file with a <filename role=\"special\">."
16374 "orig</filename> extension; the copy of the file without any extensions will "
16375 "contain any changes made by hunks that <emphasis>did</emphasis> apply "
16376 "cleanly. If you have a patch that modifies <filename>foo</filename> with six "
16377 "hunks, and one of them fails to apply, you will have: an unmodified "
16378 "<filename>foo.orig</filename>, a <filename>foo.rej</filename> containing one "
16379 "hunk, and <filename>foo</filename>, containing the changes made by the five "
16380 "successful hunks."
16381 msgstr ""
16383 #. type: Content of: <book><chapter><sect1><sect2><title>
16384 #: ../en/ch12-mq.xml:632
16385 msgid "Some quirks of patch representation"
16386 msgstr "补丁的一些特性"
16388 #. type: Content of: <book><chapter><sect1><sect2><para>
16389 #: ../en/ch12-mq.xml:634
16390 msgid ""
16391 "There are a few useful things to know about how <command>patch</command> "
16392 "works with files."
16393 msgstr ""
16395 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16396 #: ../en/ch12-mq.xml:637
16397 msgid ""
16398 "This should already be obvious, but <command>patch</command> cannot handle "
16399 "binary files."
16400 msgstr ""
16402 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16403 #: ../en/ch12-mq.xml:641
16404 msgid ""
16405 "Neither does it care about the executable bit; it creates new files as "
16406 "readable, but not executable."
16407 msgstr ""
16409 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16410 #: ../en/ch12-mq.xml:645
16411 msgid ""
16412 "<command>patch</command> treats the removal of a file as a diff between the "
16413 "file to be removed and the empty file. So your idea of <quote>I deleted this "
16414 "file</quote> looks like <quote>every line of this file was deleted</quote> in "
16415 "a patch."
16416 msgstr ""
16418 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16419 #: ../en/ch12-mq.xml:651
16420 msgid ""
16421 "It treats the addition of a file as a diff between the empty file and the "
16422 "file to be added. So in a patch, your idea of <quote>I added this file</"
16423 "quote> looks like <quote>every line of this file was added</quote>."
16424 msgstr ""
16426 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16427 #: ../en/ch12-mq.xml:657
16428 msgid ""
16429 "It treats a renamed file as the removal of the old name, and the addition of "
16430 "the new name. This means that renamed files have a big footprint in "
16431 "patches. (Note also that Mercurial does not currently try to infer when "
16432 "files have been renamed or copied in a patch.)"
16433 msgstr ""
16435 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16436 #: ../en/ch12-mq.xml:663
16437 msgid ""
16438 "<command>patch</command> cannot represent empty files, so you cannot use a "
16439 "patch to represent the notion <quote>I added this empty file to the tree</"
16440 "quote>."
16441 msgstr ""
16443 #. type: Content of: <book><chapter><sect1><sect2><title>
16444 #: ../en/ch12-mq.xml:671
16445 msgid "Beware the fuzz"
16446 msgstr "当心毛刺"
16448 #. type: Content of: <book><chapter><sect1><sect2><para>
16449 #: ../en/ch12-mq.xml:673
16450 msgid ""
16451 "While applying a hunk at an offset, or with a fuzz factor, will often be "
16452 "completely successful, these inexact techniques naturally leave open the "
16453 "possibility of corrupting the patched file. The most common cases typically "
16454 "involve applying a patch twice, or at an incorrect location in the file. If "
16455 "<command>patch</command> or <command role=\"hg-ext-mq\">qpush</command> ever "
16456 "mentions an offset or fuzz factor, you should make sure that the modified "
16457 "files are correct afterwards."
16458 msgstr ""
16460 #. type: Content of: <book><chapter><sect1><sect2><para>
16461 #: ../en/ch12-mq.xml:683
16462 msgid ""
16463 "It's often a good idea to refresh a patch that has applied with an offset or "
16464 "fuzz factor; refreshing the patch generates new context information that will "
16465 "make it apply cleanly. I say <quote>often,</quote> not <quote>always,</"
16466 "quote> because sometimes refreshing a patch will make it fail to apply "
16467 "against a different revision of the underlying files. In some cases, such as "
16468 "when you're maintaining a patch that must sit on top of multiple versions of "
16469 "a source tree, it's acceptable to have a patch apply with some fuzz, provided "
16470 "you've verified the results of the patching process in such cases."
16471 msgstr ""
16473 #. type: Content of: <book><chapter><sect1><sect2><title>
16474 #: ../en/ch12-mq.xml:696
16475 msgid "Handling rejection"
16476 msgstr "处理拒绝"
16478 #. type: Content of: <book><chapter><sect1><sect2><para>
16479 #: ../en/ch12-mq.xml:698
16480 msgid ""
16481 "If <command role=\"hg-ext-mq\">qpush</command> fails to apply a patch, it "
16482 "will print an error message and exit. If it has left <filename role=\"special"
16483 "\">.rej</filename> files behind, it is usually best to fix up the rejected "
16484 "hunks before you push more patches or do any further work."
16485 msgstr ""
16487 #. type: Content of: <book><chapter><sect1><sect2><para>
16488 #: ../en/ch12-mq.xml:704
16489 msgid ""
16490 "If your patch <emphasis>used to</emphasis> apply cleanly, and no longer does "
16491 "because you've changed the underlying code that your patches are based on, "
16492 "Mercurial Queues can help; see <xref linkend=\"sec:mq:merge\"/> for details."
16493 msgstr ""
16495 #. type: Content of: <book><chapter><sect1><sect2><para>
16496 #: ../en/ch12-mq.xml:709
16497 msgid ""
16498 "Unfortunately, there aren't any great techniques for dealing with rejected "
16499 "hunks. Most often, you'll need to view the <filename role=\"special\">.rej</"
16500 "filename> file and edit the target file, applying the rejected hunks by hand."
16501 msgstr ""
16503 #. type: Content of: <book><chapter><sect1><sect2><para>
16504 #: ../en/ch12-mq.xml:714
16505 msgid ""
16506 "A Linux kernel hacker, Chris Mason (the author of Mercurial Queues), wrote a "
16507 "tool called <command>mpatch</command> (<ulink url=\"http://oss.oracle.com/"
16508 "~mason/mpatch/\">http://oss.oracle.com/~mason/mpatch/</ulink>), which takes a "
16509 "simple approach to automating the application of hunks rejected by "
16510 "<command>patch</command>. The <command>mpatch</command> command can help "
16511 "with four common reasons that a hunk may be rejected:"
16512 msgstr ""
16514 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16515 #: ../en/ch12-mq.xml:724
16516 msgid "The context in the middle of a hunk has changed."
16517 msgstr ""
16519 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16520 #: ../en/ch12-mq.xml:727
16521 msgid "A hunk is missing some context at the beginning or end."
16522 msgstr ""
16524 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16525 #: ../en/ch12-mq.xml:730
16526 msgid ""
16527 "A large hunk might apply better&emdash;either entirely or in part&emdash;if "
16528 "it was broken up into smaller hunks."
16529 msgstr ""
16531 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16532 #: ../en/ch12-mq.xml:734
16533 msgid ""
16534 "A hunk removes lines with slightly different content than those currently "
16535 "present in the file."
16536 msgstr ""
16538 #. type: Content of: <book><chapter><sect1><sect2><para>
16539 #: ../en/ch12-mq.xml:738
16540 msgid ""
16541 "If you use <command>mpatch</command>, you should be doubly careful to check "
16542 "your results when you're done. In fact, <command>mpatch</command> enforces "
16543 "this method of double-checking the tool's output, by automatically dropping "
16544 "you into a merge program when it has done its job, so that you can verify its "
16545 "work and finish off any remaining merges."
16546 msgstr ""
16548 #. type: Content of: <book><chapter><sect1><title>
16549 #: ../en/ch12-mq.xml:749
16550 msgid "More on patch management"
16551 msgstr "补丁管理进阶"
16553 #. type: Content of: <book><chapter><sect1><para>
16554 #: ../en/ch12-mq.xml:751
16555 msgid ""
16556 "As you grow familiar with MQ, you will find yourself wanting to perform other "
16557 "kinds of patch management operations."
16558 msgstr ""
16560 #. type: Content of: <book><chapter><sect1><sect2><title>
16561 #: ../en/ch12-mq.xml:755
16562 msgid "Deleting unwanted patches"
16563 msgstr "删除不需要的补丁"
16565 #. type: Content of: <book><chapter><sect1><sect2><para>
16566 #: ../en/ch12-mq.xml:757
16567 msgid ""
16568 "If you want to get rid of a patch, use the <command role=\"hg-ext-mq\">hg "
16569 "qdelete</command> command to delete the patch file and remove its entry from "
16570 "the patch series. If you try to delete a patch that is still applied, "
16571 "<command role=\"hg-ext-mq\">hg qdelete</command> will refuse."
16572 msgstr ""
16574 #. type: Content of: <book><chapter><sect1><sect2><title>
16575 #: ../en/ch12-mq.xml:767
16576 msgid "Converting to and from permanent revisions"
16577 msgstr "与持久版本的相互转换"
16579 #. type: Content of: <book><chapter><sect1><sect2><para>
16580 #: ../en/ch12-mq.xml:769
16581 msgid ""
16582 "Once you're done working on a patch and want to turn it into a permanent "
16583 "changeset, use the <command role=\"hg-ext-mq\">hg qfinish</command> command. "
16584 "Pass a revision to the command to identify the patch that you want to turn "
16585 "into a regular changeset; this patch must already be applied."
16586 msgstr ""
16588 #. type: Content of: <book><chapter><sect1><sect2><para>
16589 #: ../en/ch12-mq.xml:777
16590 msgid ""
16591 "The <command role=\"hg-ext-mq\">hg qfinish</command> command accepts an "
16592 "<option>--all</option> or <option>-a</option> option, which turns all applied "
16593 "patches into regular changesets."
16594 msgstr ""
16596 #. type: Content of: <book><chapter><sect1><sect2><para>
16597 #: ../en/ch12-mq.xml:782
16598 msgid ""
16599 "It is also possible to turn an existing changeset into a patch, by passing "
16600 "the <option>-r</option> option to <command role=\"hg-ext-mq\">hg qimport</"
16601 "command>."
16602 msgstr ""
16604 #. type: Content of: <book><chapter><sect1><sect2><para>
16605 #: ../en/ch12-mq.xml:788
16606 msgid ""
16607 "Note that it only makes sense to convert a changeset into a patch if you have "
16608 "not propagated that changeset into any other repositories. The imported "
16609 "changeset's ID will change every time you refresh the patch, which will make "
16610 "Mercurial treat it as unrelated to the original changeset if you have pushed "
16611 "it somewhere else."
16612 msgstr ""
16614 #. type: Content of: <book><chapter><sect1><title>
16615 #: ../en/ch12-mq.xml:798
16616 msgid "Getting the best performance out of MQ"
16617 msgstr "MQ 的性能"
16619 #. type: Content of: <book><chapter><sect1><para>
16620 #: ../en/ch12-mq.xml:800
16621 msgid ""
16622 "MQ is very efficient at handling a large number of patches. I ran some "
16623 "performance experiments in mid-2006 for a talk that I gave at the 2006 "
16624 "EuroPython conference (on modern hardware, you should expect better "
16625 "performance than you'll see below). I used as my data set the Linux 2.6.17-"
16626 "mm1 patch series, which consists of 1,738 patches. I applied these on top of "
16627 "a Linux kernel repository containing all 27,472 revisions between Linux "
16628 "2.6.12-rc2 and Linux 2.6.17."
16629 msgstr ""
16631 #. type: Content of: <book><chapter><sect1><para>
16632 #: ../en/ch12-mq.xml:809
16633 msgid ""
16634 "On my old, slow laptop, I was able to <command role=\"hg-cmd\">hg qpush "
16635 "<option role=\"hg-ext-mq-cmd-qpush-opt\">-a</option></command> all 1,738 "
16636 "patches in 3.5 minutes, and <command role=\"hg-cmd\">hg qpop <option role="
16637 "\"hg-ext-mq-cmd-qpop-opt\">-a</option></command> them all in 30 seconds. (On "
16638 "a newer laptop, the time to push all patches dropped to two minutes.) I "
16639 "could <command role=\"hg-ext-mq\">qrefresh</command> one of the biggest "
16640 "patches (which made 22,779 lines of changes to 287 files) in 6.6 seconds."
16641 msgstr ""
16643 #. type: Content of: <book><chapter><sect1><para>
16644 #: ../en/ch12-mq.xml:820
16645 msgid ""
16646 "Clearly, MQ is well suited to working in large trees, but there are a few "
16647 "tricks you can use to get the best performance of it."
16648 msgstr ""
16650 #. type: Content of: <book><chapter><sect1><para>
16651 #: ../en/ch12-mq.xml:824
16652 msgid ""
16653 "First of all, try to <quote>batch</quote> operations together. Every time "
16654 "you run <command role=\"hg-ext-mq\">qpush</command> or <command role=\"hg-ext-"
16655 "mq\">qpop</command>, these commands scan the working directory once to make "
16656 "sure you haven't made some changes and then forgotten to run <command role="
16657 "\"hg-ext-mq\">qrefresh</command>. On a small tree, the time that this scan "
16658 "takes is unnoticeable. However, on a medium-sized tree (containing tens of "
16659 "thousands of files), it can take a second or more."
16660 msgstr ""
16662 #. type: Content of: <book><chapter><sect1><para>
16663 #: ../en/ch12-mq.xml:835
16664 msgid ""
16665 "The <command role=\"hg-ext-mq\">qpush</command> and <command role=\"hg-ext-mq"
16666 "\">qpop</command> commands allow you to push and pop multiple patches at a "
16667 "time. You can identify the <quote>destination patch</quote> that you want to "
16668 "end up at. When you <command role=\"hg-ext-mq\">qpush</command> with a "
16669 "destination specified, it will push patches until that patch is at the top of "
16670 "the applied stack. When you <command role=\"hg-ext-mq\">qpop</command> to a "
16671 "destination, MQ will pop patches until the destination patch is at the top."
16672 msgstr ""
16674 #. type: Content of: <book><chapter><sect1><para>
16675 #: ../en/ch12-mq.xml:845
16676 msgid ""
16677 "You can identify a destination patch using either the name of the patch, or "
16678 "by number. If you use numeric addressing, patches are counted from zero; "
16679 "this means that the first patch is zero, the second is one, and so on."
16680 msgstr ""
16682 #. type: Content of: <book><chapter><sect1><title>
16683 #: ../en/ch12-mq.xml:852
16684 msgid "Updating your patches when the underlying code changes"
16685 msgstr "当基础代码改变时,更新补丁的方法"
16687 #. type: Content of: <book><chapter><sect1><para>
16688 #: ../en/ch12-mq.xml:855
16689 msgid ""
16690 "It's common to have a stack of patches on top of an underlying repository "
16691 "that you don't modify directly. If you're working on changes to third-party "
16692 "code, or on a feature that is taking longer to develop than the rate of "
16693 "change of the code beneath, you will often need to sync up with the "
16694 "underlying code, and fix up any hunks in your patches that no longer apply. "
16695 "This is called <emphasis>rebasing</emphasis> your patch series."
16696 msgstr ""
16698 #. type: Content of: <book><chapter><sect1><para>
16699 #: ../en/ch12-mq.xml:864
16700 msgid ""
16701 "The simplest way to do this is to <command role=\"hg-cmd\">hg qpop <option "
16702 "role=\"hg-ext-mq-cmd-qpop-opt\">hg -a</option></command> your patches, then "
16703 "<command role=\"hg-cmd\">hg pull</command> changes into the underlying "
16704 "repository, and finally <command role=\"hg-cmd\">hg qpush <option role=\"hg-"
16705 "ext-mq-cmd-qpop-opt\">-a</option></command> your patches again. MQ will stop "
16706 "pushing any time it runs across a patch that fails to apply during conflicts, "
16707 "allowing you to fix your conflicts, <command role=\"hg-ext-mq\">qrefresh</"
16708 "command> the affected patch, and continue pushing until you have fixed your "
16709 "entire stack."
16710 msgstr ""
16712 #. type: Content of: <book><chapter><sect1><para>
16713 #: ../en/ch12-mq.xml:876
16714 msgid ""
16715 "This approach is easy to use and works well if you don't expect changes to "
16716 "the underlying code to affect how well your patches apply. If your patch "
16717 "stack touches code that is modified frequently or invasively in the "
16718 "underlying repository, however, fixing up rejected hunks by hand quickly "
16719 "becomes tiresome."
16720 msgstr ""
16722 #. type: Content of: <book><chapter><sect1><para>
16723 #: ../en/ch12-mq.xml:883
16724 msgid ""
16725 "It's possible to partially automate the rebasing process. If your patches "
16726 "apply cleanly against some revision of the underlying repo, MQ can use this "
16727 "information to help you to resolve conflicts between your patches and a "
16728 "different revision."
16729 msgstr ""
16731 #. type: Content of: <book><chapter><sect1><para>
16732 #: ../en/ch12-mq.xml:889
16733 msgid "The process is a little involved."
16734 msgstr ""
16736 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
16737 #: ../en/ch12-mq.xml:891
16738 msgid ""
16739 "To begin, <command role=\"hg-cmd\">hg qpush -a</command> all of your patches "
16740 "on top of the revision where you know that they apply cleanly."
16741 msgstr ""
16743 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
16744 #: ../en/ch12-mq.xml:895
16745 msgid ""
16746 "Save a backup copy of your patch directory using <command role=\"hg-cmd\">hg "
16747 "qsave <option role=\"hg-ext-mq-cmd-qsave-opt\">hg -e</option> <option role="
16748 "\"hg-ext-mq-cmd-qsave-opt\">hg -c</option></command>. This prints the name "
16749 "of the directory that it has saved the patches in. It will save the patches "
16750 "to a directory called <filename role=\"special\" class=\"directory\">.hg/"
16751 "patches.N</filename>, where <literal>N</literal> is a small integer. It also "
16752 "commits a <quote>save changeset</quote> on top of your applied patches; this "
16753 "is for internal book-keeping, and records the states of the <filename role="
16754 "\"special\">series</filename> and <filename role=\"special\">status</"
16755 "filename> files."
16756 msgstr ""
16758 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
16759 #: ../en/ch12-mq.xml:909
16760 msgid ""
16761 "Use <command role=\"hg-cmd\">hg pull</command> to bring new changes into the "
16762 "underlying repository. (Don't run <command role=\"hg-cmd\">hg pull -u</"
16763 "command>; see below for why.)"
16764 msgstr ""
16766 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
16767 #: ../en/ch12-mq.xml:914
16768 msgid ""
16769 "Update to the new tip revision, using <command role=\"hg-cmd\">hg update "
16770 "<option role=\"hg-opt-update\">-C</option></command> to override the patches "
16771 "you have pushed."
16772 msgstr ""
16774 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
16775 #: ../en/ch12-mq.xml:919
16776 msgid ""
16777 "Merge all patches using <command>hg qpush -m -a</command>. The <option role="
16778 "\"hg-ext-mq-cmd-qpush-opt\">-m</option> option to <command role=\"hg-ext-mq"
16779 "\">qpush</command> tells MQ to perform a three-way merge if the patch fails "
16780 "to apply."
16781 msgstr ""
16783 #. type: Content of: <book><chapter><sect1><para>
16784 #: ../en/ch12-mq.xml:927
16785 msgid ""
16786 "During the <command role=\"hg-cmd\">hg qpush <option role=\"hg-ext-mq-cmd-"
16787 "qpush-opt\">hg -m</option></command>, each patch in the <filename role="
16788 "\"special\">series</filename> file is applied normally. If a patch applies "
16789 "with fuzz or rejects, MQ looks at the queue you <command role=\"hg-ext-mq"
16790 "\">qsave</command>d, and performs a three-way merge with the corresponding "
16791 "changeset. This merge uses Mercurial's normal merge machinery, so it may pop "
16792 "up a GUI merge tool to help you to resolve problems."
16793 msgstr ""
16795 #. type: Content of: <book><chapter><sect1><para>
16796 #: ../en/ch12-mq.xml:937
16797 msgid ""
16798 "When you finish resolving the effects of a patch, MQ refreshes your patch "
16799 "based on the result of the merge."
16800 msgstr ""
16802 #. type: Content of: <book><chapter><sect1><para>
16803 #: ../en/ch12-mq.xml:940
16804 msgid ""
16805 "At the end of this process, your repository will have one extra head from the "
16806 "old patch queue, and a copy of the old patch queue will be in <filename role="
16807 "\"special\" class=\"directory\">.hg/patches.N</filename>. You can remove the "
16808 "extra head using <command role=\"hg-cmd\">hg qpop -a -n patches.N</command> "
16809 "or <command role=\"hg-cmd\">hg strip</command>. You can delete <filename "
16810 "role=\"special\" class=\"directory\">.hg/patches.N</filename> once you are "
16811 "sure that you no longer need it as a backup."
16812 msgstr ""
16814 #. type: Content of: <book><chapter><sect1><title>
16815 #: ../en/ch12-mq.xml:952
16816 msgid "Identifying patches"
16817 msgstr "标识补丁"
16819 #. type: Content of: <book><chapter><sect1><para>
16820 #: ../en/ch12-mq.xml:954
16821 msgid ""
16822 "MQ commands that work with patches let you refer to a patch either by using "
16823 "its name or by a number. By name is obvious enough; pass the name "
16824 "<filename>foo.patch</filename> to <command role=\"hg-ext-mq\">qpush</"
16825 "command>, for example, and it will push patches until <filename>foo.patch</"
16826 "filename> is applied."
16827 msgstr ""
16829 #. type: Content of: <book><chapter><sect1><para>
16830 #: ../en/ch12-mq.xml:961
16831 msgid ""
16832 "As a shortcut, you can refer to a patch using both a name and a numeric "
16833 "offset; <literal>foo.patch-2</literal> means <quote>two patches before "
16834 "<literal>foo.patch</literal></quote>, while <literal>bar.patch+4</literal> "
16835 "means <quote>four patches after <literal>bar.patch</literal></quote>."
16836 msgstr ""
16838 #. type: Content of: <book><chapter><sect1><para>
16839 #: ../en/ch12-mq.xml:967
16840 msgid ""
16841 "Referring to a patch by index isn't much different. The first patch printed "
16842 "in the output of <command role=\"hg-ext-mq\">qseries</command> is patch zero "
16843 "(yes, it's one of those start-at-zero counting systems); the second is patch "
16844 "one; and so on."
16845 msgstr ""
16847 #. type: Content of: <book><chapter><sect1><para>
16848 #: ../en/ch12-mq.xml:973
16849 msgid ""
16850 "MQ also makes it easy to work with patches when you are using normal "
16851 "Mercurial commands. Every command that accepts a changeset ID will also "
16852 "accept the name of an applied patch. MQ augments the tags normally in the "
16853 "repository with an eponymous one for each applied patch. In addition, the "
16854 "special tags <literal role=\"tag\">qbase</literal> and <literal role=\"tag"
16855 "\">qtip</literal> identify the <quote>bottom-most</quote> and topmost applied "
16856 "patches, respectively."
16857 msgstr ""
16859 #. type: Content of: <book><chapter><sect1><para>
16860 #: ../en/ch12-mq.xml:983
16861 msgid ""
16862 "These additions to Mercurial's normal tagging capabilities make dealing with "
16863 "patches even more of a breeze."
16864 msgstr ""
16866 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
16867 #: ../en/ch12-mq.xml:986
16868 msgid "Want to patchbomb a mailing list with your latest series of changes?"
16869 msgstr ""
16871 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
16872 #: ../en/ch12-mq.xml:989
16873 msgid ""
16874 "(Don't know what <quote>patchbombing</quote> is? See <xref linkend=\"sec:"
16875 "hgext:patchbomb\"/>.)"
16876 msgstr ""
16878 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
16879 #: ../en/ch12-mq.xml:992
16880 msgid ""
16881 "Need to see all of the patches since <literal>foo.patch</literal> that have "
16882 "touched files in a subdirectory of your tree?"
16883 msgstr ""
16885 #. type: Content of: <book><chapter><sect1><para>
16886 #: ../en/ch12-mq.xml:999
16887 msgid ""
16888 "Because MQ makes the names of patches available to the rest of Mercurial "
16889 "through its normal internal tag machinery, you don't need to type in the "
16890 "entire name of a patch when you want to identify it by name."
16891 msgstr ""
16893 #. type: Content of: <book><chapter><sect1><para>
16894 #: ../en/ch12-mq.xml:1004
16895 msgid ""
16896 "Another nice consequence of representing patch names as tags is that when you "
16897 "run the <command role=\"hg-cmd\">hg log</command> command, it will display a "
16898 "patch's name as a tag, simply as part of its normal output. This makes it "
16899 "easy to visually distinguish applied patches from underlying <quote>normal</"
16900 "quote> revisions. The following example shows a few normal Mercurial "
16901 "commands in use with applied patches."
16902 msgstr ""
16904 #. type: Content of: <book><chapter><sect1><title>
16905 #: ../en/ch12-mq.xml:1017
16906 msgid "Useful things to know about"
16907 msgstr "其它需要了解的东西"
16909 #. type: Content of: <book><chapter><sect1><para>
16910 #: ../en/ch12-mq.xml:1019
16911 msgid ""
16912 "There are a number of aspects of MQ usage that don't fit tidily into sections "
16913 "of their own, but that are good to know. Here they are, in one place."
16914 msgstr ""
16916 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
16917 #: ../en/ch12-mq.xml:1024
16918 msgid ""
16919 "Normally, when you <command role=\"hg-ext-mq\">qpop</command> a patch and "
16920 "<command role=\"hg-ext-mq\">qpush</command> it again, the changeset that "
16921 "represents the patch after the pop/push will have a <emphasis>different "
16922 "identity</emphasis> than the changeset that represented the hash beforehand. "
16923 "See <xref linkend=\"sec:mqref:cmd:qpush\"/> for information as to why this is."
16924 msgstr ""
16926 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
16927 #: ../en/ch12-mq.xml:1033
16928 msgid ""
16929 "It's not a good idea to <command role=\"hg-cmd\">hg merge</command> changes "
16930 "from another branch with a patch changeset, at least if you want to maintain "
16931 "the <quote>patchiness</quote> of that changeset and changesets below it on "
16932 "the patch stack. If you try to do this, it will appear to succeed, but MQ "
16933 "will become confused."
16934 msgstr ""
16936 #. type: Content of: <book><chapter><sect1><title>
16937 #: ../en/ch12-mq.xml:1044
16938 msgid "Managing patches in a repository"
16939 msgstr "在版本库管理补丁"
16941 #. type: Content of: <book><chapter><sect1><para>
16942 #: ../en/ch12-mq.xml:1046
16943 msgid ""
16944 "Because MQ's <filename role=\"special\" class=\"directory\">.hg/patches</"
16945 "filename> directory resides outside a Mercurial repository's working "
16946 "directory, the <quote>underlying</quote> Mercurial repository knows nothing "
16947 "about the management or presence of patches."
16948 msgstr ""
16950 #. type: Content of: <book><chapter><sect1><para>
16951 #: ../en/ch12-mq.xml:1052
16952 msgid ""
16953 "This presents the interesting possibility of managing the contents of the "
16954 "patch directory as a Mercurial repository in its own right. This can be a "
16955 "useful way to work. For example, you can work on a patch for a while, "
16956 "<command role=\"hg-ext-mq\">qrefresh</command> it, then <command role=\"hg-cmd"
16957 "\">hg commit</command> the current state of the patch. This lets you "
16958 "<quote>roll back</quote> to that version of the patch later on."
16959 msgstr ""
16961 #. type: Content of: <book><chapter><sect1><para>
16962 #: ../en/ch12-mq.xml:1061
16963 msgid ""
16964 "You can then share different versions of the same patch stack among multiple "
16965 "underlying repositories. I use this when I am developing a Linux kernel "
16966 "feature. I have a pristine copy of my kernel sources for each of several CPU "
16967 "architectures, and a cloned repository under each that contains the patches I "
16968 "am working on. When I want to test a change on a different architecture, I "
16969 "push my current patches to the patch repository associated with that kernel "
16970 "tree, pop and push all of my patches, and build and test that kernel."
16971 msgstr ""
16973 #. type: Content of: <book><chapter><sect1><para>
16974 #: ../en/ch12-mq.xml:1071
16975 msgid ""
16976 "Managing patches in a repository makes it possible for multiple developers to "
16977 "work on the same patch series without colliding with each other, all on top "
16978 "of an underlying source base that they may or may not control."
16979 msgstr ""
16981 #. type: Content of: <book><chapter><sect1><sect2><title>
16982 #: ../en/ch12-mq.xml:1077
16983 msgid "MQ support for patch repositories"
16984 msgstr "MQ 支持补丁版本库"
16986 #. type: Content of: <book><chapter><sect1><sect2><para>
16987 #: ../en/ch12-mq.xml:1079
16988 msgid ""
16989 "MQ helps you to work with the <filename role=\"special\" class=\"directory\">."
16990 "hg/patches</filename> directory as a repository; when you prepare a "
16991 "repository for working with patches using <command role=\"hg-ext-mq\">qinit</"
16992 "command>, you can pass the <option role=\"hg-ext-mq-cmd-qinit-opt\">hg -c</"
16993 "option> option to create the <filename role=\"special\" class=\"directory\">."
16994 "hg/patches</filename> directory as a Mercurial repository."
16995 msgstr ""
16997 #. type: Content of: <book><chapter><sect1><sect2><note><para>
16998 #: ../en/ch12-mq.xml:1089
16999 msgid ""
17000 "If you forget to use the <option role=\"hg-ext-mq-cmd-qinit-opt\">hg -c</"
17001 "option> option, you can simply go into the <filename role=\"special\" class="
17002 "\"directory\">.hg/patches</filename> directory at any time and run <command "
17003 "role=\"hg-cmd\">hg init</command>. Don't forget to add an entry for the "
17004 "<filename role=\"special\">status</filename> file to the <filename role="
17005 "\"special\">.hgignore</filename> file, though"
17006 msgstr ""
17008 #. type: Content of: <book><chapter><sect1><sect2><note><para>
17009 #: ../en/ch12-mq.xml:1098
17010 msgid ""
17011 "(<command role=\"hg-cmd\">hg qinit <option role=\"hg-ext-mq-cmd-qinit-opt"
17012 "\">hg -c</option></command> does this for you automatically); you "
17013 "<emphasis>really</emphasis> don't want to manage the <filename role=\"special"
17014 "\">status</filename> file."
17015 msgstr ""
17017 #. type: Content of: <book><chapter><sect1><sect2><para>
17018 #: ../en/ch12-mq.xml:1105
17019 msgid ""
17020 "As a convenience, if MQ notices that the <filename class=\"directory\">.hg/"
17021 "patches</filename> directory is a repository, it will automatically <command "
17022 "role=\"hg-cmd\">hg add</command> every patch that you create and import."
17023 msgstr ""
17025 #. type: Content of: <book><chapter><sect1><sect2><para>
17026 #: ../en/ch12-mq.xml:1110
17027 msgid ""
17028 "MQ provides a shortcut command, <command role=\"hg-ext-mq\">qcommit</"
17029 "command>, that runs <command role=\"hg-cmd\">hg commit</command> in the "
17030 "<filename role=\"special\" class=\"directory\">.hg/patches</filename> "
17031 "directory. This saves some bothersome typing."
17032 msgstr ""
17034 #. type: Content of: <book><chapter><sect1><sect2><para>
17035 #: ../en/ch12-mq.xml:1116
17036 msgid ""
17037 "Finally, as a convenience to manage the patch directory, you can define the "
17038 "alias <command>mq</command> on Unix systems. For example, on Linux systems "
17039 "using the <command>bash</command> shell, you can include the following "
17040 "snippet in your <filename role=\"home\">~/.bashrc</filename>."
17041 msgstr ""
17043 #. type: Content of: <book><chapter><sect1><sect2><para>
17044 #: ../en/ch12-mq.xml:1125
17045 msgid ""
17046 "You can then issue commands of the form <command>mq pull</command> from the "
17047 "main repository."
17048 msgstr ""
17050 #. type: Content of: <book><chapter><sect1><sect2><title>
17051 #: ../en/ch12-mq.xml:1130
17052 msgid "A few things to watch out for"
17053 msgstr "需要注意的事情"
17055 #. type: Content of: <book><chapter><sect1><sect2><para>
17056 #: ../en/ch12-mq.xml:1132
17057 msgid ""
17058 "MQ's support for working with a repository full of patches is limited in a "
17059 "few small respects."
17060 msgstr ""
17062 #. type: Content of: <book><chapter><sect1><sect2><para>
17063 #: ../en/ch12-mq.xml:1135
17064 msgid ""
17065 "MQ cannot automatically detect changes that you make to the patch directory. "
17066 "If you <command role=\"hg-cmd\">hg pull</command>, manually edit, or <command "
17067 "role=\"hg-cmd\">hg update</command> changes to patches or the <filename role="
17068 "\"special\">series</filename> file, you will have to <command role=\"hg-cmd"
17069 "\">hg qpop <option role=\"hg-ext-mq-cmd-qpop-opt\">-a</option></command> and "
17070 "then <command role=\"hg-cmd\">hg qpush <option role=\"hg-ext-mq-cmd-qpush-opt"
17071 "\">-a</option></command> in the underlying repository to see those changes "
17072 "show up there. If you forget to do this, you can confuse MQ's idea of which "
17073 "patches are applied."
17074 msgstr ""
17076 #. type: Content of: <book><chapter><sect1><title>
17077 #: ../en/ch12-mq.xml:1151
17078 msgid "Third party tools for working with patches"
17079 msgstr "操作补丁的第三方工具"
17081 #. type: Content of: <book><chapter><sect1><para>
17082 #: ../en/ch12-mq.xml:1153
17083 msgid ""
17084 "Once you've been working with patches for a while, you'll find yourself "
17085 "hungry for tools that will help you to understand and manipulate the patches "
17086 "you're dealing with."
17087 msgstr ""
17089 #. type: Content of: <book><chapter><sect1><para>
17090 #: ../en/ch12-mq.xml:1157
17091 msgid ""
17092 "The <command>diffstat</command> command <citation>web:diffstat</citation> "
17093 "generates a histogram of the modifications made to each file in a patch. It "
17094 "provides a good way to <quote>get a sense of</quote> a patch&emdash;which "
17095 "files it affects, and how much change it introduces to each file and as a "
17096 "whole. (I find that it's a good idea to use <command>diffstat</command>'s "
17097 "<option role=\"cmd-opt-diffstat\">-p</option> option as a matter of course, "
17098 "as otherwise it will try to do clever things with prefixes of file names that "
17099 "inevitably confuse at least me.)"
17100 msgstr ""
17102 #. type: Content of: <book><chapter><sect1><para>
17103 #: ../en/ch12-mq.xml:1171
17104 msgid ""
17105 "The <literal role=\"package\">patchutils</literal> package <citation>web:"
17106 "patchutils</citation> is invaluable. It provides a set of small utilities "
17107 "that follow the <quote>Unix philosophy;</quote> each does one useful thing "
17108 "with a patch. The <literal role=\"package\">patchutils</literal> command I "
17109 "use most is <command>filterdiff</command>, which extracts subsets from a "
17110 "patch file. For example, given a patch that modifies hundreds of files "
17111 "across dozens of directories, a single invocation of <command>filterdiff</"
17112 "command> can generate a smaller patch that only touches files whose names "
17113 "match a particular glob pattern. See <xref linkend=\"mq-collab:tips:interdiff"
17114 "\"/> for another example."
17115 msgstr ""
17117 #. type: Content of: <book><chapter><sect1><title>
17118 #: ../en/ch12-mq.xml:1187
17119 msgid "Good ways to work with patches"
17120 msgstr "操作补丁的好习惯"
17122 #. type: Content of: <book><chapter><sect1><para>
17123 #: ../en/ch12-mq.xml:1189
17124 msgid ""
17125 "Whether you are working on a patch series to submit to a free software or "
17126 "open source project, or a series that you intend to treat as a sequence of "
17127 "regular changesets when you're done, you can use some simple techniques to "
17128 "keep your work well organized."
17129 msgstr ""
17131 #. type: Content of: <book><chapter><sect1><para>
17132 #: ../en/ch12-mq.xml:1195
17133 msgid ""
17134 "Give your patches descriptive names. A good name for a patch might be "
17135 "<filename>rework-device-alloc.patch</filename>, because it will immediately "
17136 "give you a hint what the purpose of the patch is. Long names shouldn't be a "
17137 "problem; you won't be typing the names often, but you <emphasis>will</"
17138 "emphasis> be running commands like <command role=\"hg-ext-mq\">qapplied</"
17139 "command> and <command role=\"hg-ext-mq\">qtop</command> over and over. Good "
17140 "naming becomes especially important when you have a number of patches to work "
17141 "with, or if you are juggling a number of different tasks and your patches "
17142 "only get a fraction of your attention."
17143 msgstr ""
17145 #. type: Content of: <book><chapter><sect1><para>
17146 #: ../en/ch12-mq.xml:1207
17147 msgid ""
17148 "Be aware of what patch you're working on. Use the <command role=\"hg-ext-mq"
17149 "\">qtop</command> command and skim over the text of your patches "
17150 "frequently&emdash;for example, using <command role=\"hg-cmd\">hg tip <option "
17151 "role=\"hg-opt-tip\">-p</option></command>)&emdash;to be sure of where you "
17152 "stand. I have several times worked on and <command role=\"hg-ext-mq"
17153 "\">qrefresh</command>ed a patch other than the one I intended, and it's often "
17154 "tricky to migrate changes into the right patch after making them in the wrong "
17155 "one."
17156 msgstr ""
17158 #. type: Content of: <book><chapter><sect1><para>
17159 #: ../en/ch12-mq.xml:1217
17160 msgid ""
17161 "For this reason, it is very much worth investing a little time to learn how "
17162 "to use some of the third-party tools I described in <xref linkend=\"sec:mq:"
17163 "tools\"/>, particularly <command>diffstat</command> and <command>filterdiff</"
17164 "command>. The former will give you a quick idea of what changes your patch "
17165 "is making, while the latter makes it easy to splice hunks selectively out of "
17166 "one patch and into another."
17167 msgstr ""
17169 #. type: Content of: <book><chapter><sect1><title>
17170 #: ../en/ch12-mq.xml:1228
17171 msgid "MQ cookbook"
17172 msgstr "MQ 手册"
17174 #. type: Content of: <book><chapter><sect1><sect2><title>
17175 #: ../en/ch12-mq.xml:1231
17176 msgid "Manage <quote>trivial</quote> patches"
17177 msgstr "管理<quote>琐碎的</quote>补丁"
17179 #. type: Content of: <book><chapter><sect1><sect2><para>
17180 #: ../en/ch12-mq.xml:1233
17181 msgid ""
17182 "Because the overhead of dropping files into a new Mercurial repository is so "
17183 "low, it makes a lot of sense to manage patches this way even if you simply "
17184 "want to make a few changes to a source tarball that you downloaded."
17185 msgstr ""
17188 #. type: Content of: <book><chapter><sect1><sect2><para>
17189 #: ../en/ch12-mq.xml:1238
17190 msgid ""
17191 "Begin by downloading and unpacking the source tarball, and turning it into a "
17192 "Mercurial repository."
17193 msgstr ""
17195 #. type: Content of: <book><chapter><sect1><sect2><para>
17196 #: ../en/ch12-mq.xml:1243
17197 msgid "Continue by creating a patch stack and making your changes."
17198 msgstr ""
17200 #. type: Content of: <book><chapter><sect1><sect2><para>
17201 #: ../en/ch12-mq.xml:1248
17202 msgid ""
17203 "Let's say a few weeks or months pass, and your package author releases a new "
17204 "version. First, bring their changes into the repository."
17205 msgstr ""
17207 #. type: Content of: <book><chapter><sect1><sect2><para>
17208 #: ../en/ch12-mq.xml:1254
17209 msgid ""
17210 "The pipeline starting with <command role=\"hg-cmd\">hg locate</command> above "
17211 "deletes all files in the working directory, so that <command role=\"hg-cmd"
17212 "\">hg commit</command>'s <option role=\"hg-opt-commit\">--addremove</option> "
17213 "option can actually tell which files have really been removed in the newer "
17214 "version of the source."
17215 msgstr ""
17217 #. type: Content of: <book><chapter><sect1><sect2><para>
17218 #: ../en/ch12-mq.xml:1262
17219 msgid "Finally, you can apply your patches on top of the new tree."
17220 msgstr ""
17222 #. type: Content of: <book><chapter><sect1><sect2><title>
17223 #: ../en/ch12-mq.xml:1269
17224 msgid "Combining entire patches"
17225 msgstr "组合全部的补丁"
17227 #. type: Content of: <book><chapter><sect1><sect2><para>
17228 #: ../en/ch12-mq.xml:1271
17229 msgid ""
17230 "MQ provides a command, <command role=\"hg-ext-mq\">qfold</command> that lets "
17231 "you combine entire patches. This <quote>folds</quote> the patches you name, "
17232 "in the order you name them, into the topmost applied patch, and concatenates "
17233 "their descriptions onto the end of its description. The patches that you "
17234 "fold must be unapplied before you fold them."
17235 msgstr ""
17237 #. type: Content of: <book><chapter><sect1><sect2><para>
17238 #: ../en/ch12-mq.xml:1279
17239 msgid ""
17240 "The order in which you fold patches matters. If your topmost applied patch "
17241 "is <literal>foo</literal>, and you <command role=\"hg-ext-mq\">qfold</"
17242 "command> <literal>bar</literal> and <literal>quux</literal> into it, you will "
17243 "end up with a patch that has the same effect as if you applied first "
17244 "<literal>foo</literal>, then <literal>bar</literal>, followed by "
17245 "<literal>quux</literal>."
17246 msgstr ""
17248 #. type: Content of: <book><chapter><sect1><sect2><title>
17249 #: ../en/ch12-mq.xml:1290
17250 msgid "Merging part of one patch into another"
17251 msgstr "合并补丁的部分内容到其它补丁"
17253 #. type: Content of: <book><chapter><sect1><sect2><para>
17254 #: ../en/ch12-mq.xml:1292
17255 msgid ""
17256 "Merging <emphasis>part</emphasis> of one patch into another is more difficult "
17257 "than combining entire patches."
17258 msgstr ""
17260 #. type: Content of: <book><chapter><sect1><sect2><para>
17261 #: ../en/ch12-mq.xml:1296
17262 msgid ""
17263 "If you want to move changes to entire files, you can use <command>filterdiff</"
17264 "command>'s <option role=\"cmd-opt-filterdiff\">-i</option> and <option role="
17265 "\"cmd-opt-filterdiff\">-x</option> options to choose the modifications to "
17266 "snip out of one patch, concatenating its output onto the end of the patch you "
17267 "want to merge into. You usually won't need to modify the patch you've merged "
17268 "the changes from. Instead, MQ will report some rejected hunks when you "
17269 "<command role=\"hg-ext-mq\">qpush</command> it (from the hunks you moved into "
17270 "the other patch), and you can simply <command role=\"hg-ext-mq\">qrefresh</"
17271 "command> the patch to drop the duplicate hunks."
17272 msgstr ""
17274 #. type: Content of: <book><chapter><sect1><sect2><para>
17275 #: ../en/ch12-mq.xml:1309
17276 msgid ""
17277 "If you have a patch that has multiple hunks modifying a file, and you only "
17278 "want to move a few of those hunks, the job becomes more messy, but you can "
17279 "still partly automate it. Use <command>lsdiff -nvv</command> to print some "
17280 "metadata about the patch."
17281 msgstr ""
17283 #. type: Content of: <book><chapter><sect1><sect2><para>
17284 #: ../en/ch12-mq.xml:1317
17285 msgid "This command prints three different kinds of number:"
17286 msgstr ""
17288 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
17289 #: ../en/ch12-mq.xml:1320
17290 msgid ""
17291 "(in the first column) a <emphasis>file number</emphasis> to identify each "
17292 "file modified in the patch;"
17293 msgstr ""
17295 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
17296 #: ../en/ch12-mq.xml:1324
17297 msgid ""
17298 "(on the next line, indented) the line number within a modified file where a "
17299 "hunk starts; and"
17300 msgstr ""
17302 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
17303 #: ../en/ch12-mq.xml:1327
17304 msgid ""
17305 "(on the same line) a <emphasis>hunk number</emphasis> to identify that hunk."
17306 msgstr ""
17308 #. type: Content of: <book><chapter><sect1><sect2><para>
17309 #: ../en/ch12-mq.xml:1331
17310 msgid ""
17311 "You'll have to use some visual inspection, and reading of the patch, to "
17312 "identify the file and hunk numbers you'll want, but you can then pass them to "
17313 "to <command>filterdiff</command>'s <option role=\"cmd-opt-filterdiff\">--"
17314 "files</option> and <option role=\"cmd-opt-filterdiff\">--hunks</option> "
17315 "options, to select exactly the file and hunk you want to extract."
17316 msgstr ""
17318 #. type: Content of: <book><chapter><sect1><sect2><para>
17319 #: ../en/ch12-mq.xml:1339
17320 msgid ""
17321 "Once you have this hunk, you can concatenate it onto the end of your "
17322 "destination patch and continue with the remainder of <xref linkend=\"sec:mq:"
17323 "combine\"/>."
17324 msgstr ""
17326 #. type: Content of: <book><chapter><sect1><title>
17327 #: ../en/ch12-mq.xml:1346
17328 msgid "Differences between quilt and MQ"
17329 msgstr "MQ 与 quilt 的区别"
17331 #. type: Content of: <book><chapter><sect1><para>
17332 #: ../en/ch12-mq.xml:1348
17333 msgid ""
17334 "If you are already familiar with quilt, MQ provides a similar command set. "
17335 "There are a few differences in the way that it works."
17336 msgstr ""
17338 #. type: Content of: <book><chapter><sect1><para>
17339 #: ../en/ch12-mq.xml:1352
17340 msgid ""
17341 "You will already have noticed that most quilt commands have MQ counterparts "
17342 "that simply begin with a <quote><literal>q</literal></quote>. The exceptions "
17343 "are quilt's <literal>add</literal> and <literal>remove</literal> commands, "
17344 "the counterparts for which are the normal Mercurial <command role=\"hg-cmd"
17345 "\">hg add</command> and <command role=\"hg-cmd\">hg remove</command> "
17346 "commands. There is no MQ equivalent of the quilt <literal>edit</literal> "
17347 "command."
17348 msgstr ""
17350 #. type: Content of: <book><chapter><title>
17351 #: ../en/ch13-mq-collab.xml:5
17352 msgid "Advanced uses of Mercurial Queues"
17353 msgstr "MQ 的高级用法"
17355 #. type: Content of: <book><chapter><para>
17356 #: ../en/ch13-mq-collab.xml:7
17357 msgid ""
17358 "While it's easy to pick up straightforward uses of Mercurial Queues, use of a "
17359 "little discipline and some of MQ's less frequently used capabilities makes it "
17360 "possible to work in complicated development environments."
17361 msgstr ""
17363 #. type: Content of: <book><chapter><para>
17364 #: ../en/ch13-mq-collab.xml:12
17365 msgid ""
17366 "In this chapter, I will use as an example a technique I have used to manage "
17367 "the development of an Infiniband device driver for the Linux kernel. The "
17368 "driver in question is large (at least as drivers go), with 25,000 lines of "
17369 "code spread across 35 source files. It is maintained by a small team of "
17370 "developers."
17371 msgstr ""
17373 #. type: Content of: <book><chapter><para>
17374 #: ../en/ch13-mq-collab.xml:18
17375 msgid ""
17376 "While much of the material in this chapter is specific to Linux, the same "
17377 "principles apply to any code base for which you're not the primary owner, and "
17378 "upon which you need to do a lot of development."
17379 msgstr ""
17381 #. type: Content of: <book><chapter><sect1><title>
17382 #: ../en/ch13-mq-collab.xml:24
17383 msgid "The problem of many targets"
17384 msgstr "多个目标的问题"
17386 #. type: Content of: <book><chapter><sect1><para>
17387 #: ../en/ch13-mq-collab.xml:26
17388 msgid ""
17389 "The Linux kernel changes rapidly, and has never been internally stable; "
17390 "developers frequently make drastic changes between releases. This means that "
17391 "a version of the driver that works well with a particular released version of "
17392 "the kernel will not even <emphasis>compile</emphasis> correctly against, "
17393 "typically, any other version."
17394 msgstr ""
17396 #. type: Content of: <book><chapter><sect1><para>
17397 #: ../en/ch13-mq-collab.xml:33
17398 msgid ""
17399 "To maintain a driver, we have to keep a number of distinct versions of Linux "
17400 "in mind."
17401 msgstr ""
17403 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17404 #: ../en/ch13-mq-collab.xml:36
17405 msgid ""
17406 "One target is the main Linux kernel development tree. Maintenance of the code "
17407 "is in this case partly shared by other developers in the kernel community, "
17408 "who make <quote>drive-by</quote> modifications to the driver as they develop "
17409 "and refine kernel subsystems."
17410 msgstr ""
17412 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17413 #: ../en/ch13-mq-collab.xml:42
17414 msgid ""
17415 "We also maintain a number of <quote>backports</quote> to older versions of "
17416 "the Linux kernel, to support the needs of customers who are running older "
17417 "Linux distributions that do not incorporate our drivers. (To "
17418 "<emphasis>backport</emphasis> a piece of code is to modify it to work in an "
17419 "older version of its target environment than the version it was developed "
17420 "for.)"
17421 msgstr ""
17423 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17424 #: ../en/ch13-mq-collab.xml:50
17425 msgid ""
17426 "Finally, we make software releases on a schedule that is necessarily not "
17427 "aligned with those used by Linux distributors and kernel developers, so that "
17428 "we can deliver new features to customers without forcing them to upgrade "
17429 "their entire kernels or distributions."
17430 msgstr ""
17432 #. type: Content of: <book><chapter><sect1><sect2><title>
17433 #: ../en/ch13-mq-collab.xml:58
17434 msgid "Tempting approaches that don't work well"
17435 msgstr "工作不好的诱人方法"
17437 #. type: Content of: <book><chapter><sect1><sect2><para>
17438 #: ../en/ch13-mq-collab.xml:60
17439 msgid ""
17440 "There are two <quote>standard</quote> ways to maintain a piece of software "
17441 "that has to target many different environments."
17442 msgstr ""
17444 #. type: Content of: <book><chapter><sect1><sect2><para>
17445 #: ../en/ch13-mq-collab.xml:64
17446 msgid ""
17447 "The first is to maintain a number of branches, each intended for a single "
17448 "target. The trouble with this approach is that you must maintain iron "
17449 "discipline in the flow of changes between repositories. A new feature or bug "
17450 "fix must start life in a <quote>pristine</quote> repository, then percolate "
17451 "out to every backport repository. Backport changes are more limited in the "
17452 "branches they should propagate to; a backport change that is applied to a "
17453 "branch where it doesn't belong will probably stop the driver from compiling."
17454 msgstr ""
17456 #. type: Content of: <book><chapter><sect1><sect2><para>
17457 #: ../en/ch13-mq-collab.xml:74
17458 msgid ""
17459 "The second is to maintain a single source tree filled with conditional "
17460 "statements that turn chunks of code on or off depending on the intended "
17461 "target. Because these <quote>ifdefs</quote> are not allowed in the Linux "
17462 "kernel tree, a manual or automatic process must be followed to strip them out "
17463 "and yield a clean tree. A code base maintained in this fashion rapidly "
17464 "becomes a rat's nest of conditional blocks that are difficult to understand "
17465 "and maintain."
17466 msgstr ""
17468 #. type: Content of: <book><chapter><sect1><sect2><para>
17469 #: ../en/ch13-mq-collab.xml:83
17470 msgid ""
17471 "Neither of these approaches is well suited to a situation where you don't "
17472 "<quote>own</quote> the canonical copy of a source tree. In the case of a "
17473 "Linux driver that is distributed with the standard kernel, Linus's tree "
17474 "contains the copy of the code that will be treated by the world as "
17475 "canonical. The upstream version of <quote>my</quote> driver can be modified "
17476 "by people I don't know, without me even finding out about it until after the "
17477 "changes show up in Linus's tree."
17478 msgstr ""
17480 #. type: Content of: <book><chapter><sect1><sect2><para>
17481 #: ../en/ch13-mq-collab.xml:93
17482 msgid ""
17483 "These approaches have the added weakness of making it difficult to generate "
17484 "well-formed patches to submit upstream."
17485 msgstr ""
17487 #. type: Content of: <book><chapter><sect1><sect2><para>
17488 #: ../en/ch13-mq-collab.xml:97
17489 msgid ""
17490 "In principle, Mercurial Queues seems like a good candidate to manage a "
17491 "development scenario such as the above. While this is indeed the case, MQ "
17492 "contains a few added features that make the job more pleasant."
17493 msgstr ""
17495 #. type: Content of: <book><chapter><sect1><title>
17496 #: ../en/ch13-mq-collab.xml:105
17497 msgid "Conditionally applying patches with guards"
17498 msgstr "有条件的应用补丁"
17500 #. type: Content of: <book><chapter><sect1><para>
17501 #: ../en/ch13-mq-collab.xml:107
17502 msgid ""
17503 "Perhaps the best way to maintain sanity with so many targets is to be able to "
17504 "choose specific patches to apply for a given situation. MQ provides a "
17505 "feature called <quote>guards</quote> (which originates with quilt's "
17506 "<literal>guards</literal> command) that does just this. To start off, let's "
17507 "create a simple repository for experimenting in."
17508 msgstr ""
17510 #. type: Content of: <book><chapter><sect1><para>
17511 #: ../en/ch13-mq-collab.xml:116
17512 msgid ""
17513 "This gives us a tiny repository that contains two patches that don't have any "
17514 "dependencies on each other, because they touch different files."
17515 msgstr ""
17517 #. type: Content of: <book><chapter><sect1><para>
17518 #: ../en/ch13-mq-collab.xml:120
17519 msgid ""
17520 "The idea behind conditional application is that you can <quote>tag</quote> a "
17521 "patch with a <emphasis>guard</emphasis>, which is simply a text string of "
17522 "your choosing, then tell MQ to select specific guards to use when applying "
17523 "patches. MQ will then either apply, or skip over, a guarded patch, depending "
17524 "on the guards that you have selected."
17525 msgstr ""
17527 #. type: Content of: <book><chapter><sect1><para>
17528 #: ../en/ch13-mq-collab.xml:127
17529 msgid ""
17530 "A patch can have an arbitrary number of guards; each one is "
17531 "<emphasis>positive</emphasis> (<quote>apply this patch if this guard is "
17532 "selected</quote>) or <emphasis>negative</emphasis> (<quote>skip this patch if "
17533 "this guard is selected</quote>). A patch with no guards is always applied."
17534 msgstr ""
17536 #. type: Content of: <book><chapter><sect1><title>
17537 #: ../en/ch13-mq-collab.xml:135
17538 msgid "Controlling the guards on a patch"
17539 msgstr "控制补丁的应用条件"
17541 #. type: Content of: <book><chapter><sect1><para>
17542 #: ../en/ch13-mq-collab.xml:137
17543 msgid ""
17544 "The <command role=\"hg-ext-mq\">qguard</command> command lets you determine "
17545 "which guards should apply to a patch, or display the guards that are already "
17546 "in effect. Without any arguments, it displays the guards on the current "
17547 "topmost patch."
17548 msgstr ""
17550 #. type: Content of: <book><chapter><sect1><para>
17551 #: ../en/ch13-mq-collab.xml:144
17552 msgid ""
17553 "To set a positive guard on a patch, prefix the name of the guard with a "
17554 "<quote><literal>+</literal></quote>."
17555 msgstr ""
17557 #. type: Content of: <book><chapter><sect1><para>
17558 #: ../en/ch13-mq-collab.xml:149
17559 msgid ""
17560 "To set a negative guard on a patch, prefix the name of the guard with a "
17561 "<quote><literal>-</literal></quote>."
17562 msgstr ""
17564 #. type: Content of: <book><chapter><sect1><para>
17565 #: ../en/ch13-mq-collab.xml:155
17566 msgid ""
17567 "Notice that we prefixed the arguments to the <command>hg qguard</command> "
17568 "command with a <literal>--</literal> here, so that Mercurial would not "
17569 "interpret the text <literal>-quux</literal> as an option."
17570 msgstr ""
17572 #. type: Content of: <book><chapter><sect1><note><title>
17573 #: ../en/ch13-mq-collab.xml:161
17574 msgid "Setting vs. modifying"
17575 msgstr ""
17577 #. type: Content of: <book><chapter><sect1><note><para>
17578 #: ../en/ch13-mq-collab.xml:163
17579 msgid ""
17580 "The <command role=\"hg-ext-mq\">qguard</command> command <emphasis>sets</"
17581 "emphasis> the guards on a patch; it doesn't <emphasis>modify</emphasis> "
17582 "them. What this means is that if you run <command role=\"hg-cmd\">hg qguard "
17583 "+a +b</command> on a patch, then <command role=\"hg-cmd\">hg qguard +c</"
17584 "command> on the same patch, the <emphasis>only</emphasis> guard that will be "
17585 "set on it afterwards is <literal>+c</literal>."
17586 msgstr ""
17589 #. type: Content of: <book><chapter><sect1><para>
17590 #: ../en/ch13-mq-collab.xml:172
17591 msgid ""
17592 "Mercurial stores guards in the <filename role=\"special\">series</filename> "
17593 "file; the form in which they are stored is easy both to understand and to "
17594 "edit by hand. (In other words, you don't have to use the <command role=\"hg-"
17595 "ext-mq\">qguard</command> command if you don't want to; it's okay to simply "
17596 "edit the <filename role=\"special\">series</filename> file.)"
17597 msgstr ""
17599 #. type: Content of: <book><chapter><sect1><title>
17600 #: ../en/ch13-mq-collab.xml:184
17601 msgid "Selecting the guards to use"
17602 msgstr "选择使用的条件"
17604 #. type: Content of: <book><chapter><sect1><para>
17605 #: ../en/ch13-mq-collab.xml:186
17606 msgid ""
17607 "The <command role=\"hg-ext-mq\">qselect</command> command determines which "
17608 "guards are active at a given time. The effect of this is to determine which "
17609 "patches MQ will apply the next time you run <command role=\"hg-ext-mq"
17610 "\">qpush</command>. It has no other effect; in particular, it doesn't do "
17611 "anything to patches that are already applied."
17612 msgstr ""
17614 #. type: Content of: <book><chapter><sect1><para>
17615 #: ../en/ch13-mq-collab.xml:193
17616 msgid ""
17617 "With no arguments, the <command role=\"hg-ext-mq\">qselect</command> command "
17618 "lists the guards currently in effect, one per line of output. Each argument "
17619 "is treated as the name of a guard to apply."
17620 msgstr ""
17622 #. type: Content of: <book><chapter><sect1><para>
17623 #: ../en/ch13-mq-collab.xml:200
17624 msgid ""
17625 "In case you're interested, the currently selected guards are stored in the "
17626 "<filename role=\"special\">guards</filename> file."
17627 msgstr ""
17629 #. type: Content of: <book><chapter><sect1><para>
17630 #: ../en/ch13-mq-collab.xml:205
17631 msgid ""
17632 "We can see the effect the selected guards have when we run <command role=\"hg-"
17633 "ext-mq\">qpush</command>."
17634 msgstr ""
17636 #. type: Content of: <book><chapter><sect1><para>
17637 #: ../en/ch13-mq-collab.xml:210
17638 msgid ""
17639 "A guard cannot start with a <quote><literal>+</literal></quote> or "
17640 "<quote><literal>-</literal></quote> character. The name of a guard must not "
17641 "contain white space, but most other characters are acceptable. If you try to "
17642 "use a guard with an invalid name, MQ will complain:"
17643 msgstr ""
17645 #. type: Content of: <book><chapter><sect1><para>
17646 #: ../en/ch13-mq-collab.xml:219
17647 msgid "Changing the selected guards changes the patches that are applied."
17648 msgstr ""
17650 #. type: Content of: <book><chapter><sect1><para>
17651 #: ../en/ch13-mq-collab.xml:224
17652 msgid ""
17653 "You can see in the example below that negative guards take precedence over "
17654 "positive guards."
17655 msgstr ""
17657 #. type: Content of: <book><chapter><sect1><title>
17658 #: ../en/ch13-mq-collab.xml:231
17659 msgid "MQ's rules for applying patches"
17660 msgstr "MQ 应用补丁的规则"
17662 #. type: Content of: <book><chapter><sect1><para>
17663 #: ../en/ch13-mq-collab.xml:233
17664 msgid ""
17665 "The rules that MQ uses when deciding whether to apply a patch are as follows."
17666 msgstr ""
17668 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17669 #: ../en/ch13-mq-collab.xml:236
17670 msgid "A patch that has no guards is always applied."
17671 msgstr ""
17673 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17674 #: ../en/ch13-mq-collab.xml:239
17675 msgid ""
17676 "If the patch has any negative guard that matches any currently selected "
17677 "guard, the patch is skipped."
17678 msgstr ""
17680 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17681 #: ../en/ch13-mq-collab.xml:242
17682 msgid ""
17683 "If the patch has any positive guard that matches any currently selected "
17684 "guard, the patch is applied."
17685 msgstr ""
17687 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17688 #: ../en/ch13-mq-collab.xml:245
17689 msgid ""
17690 "If the patch has positive or negative guards, but none matches any currently "
17691 "selected guard, the patch is skipped."
17692 msgstr ""
17694 #. type: Content of: <book><chapter><sect1><title>
17695 #: ../en/ch13-mq-collab.xml:252
17696 msgid "Trimming the work environment"
17697 msgstr "修剪工作环境"
17699 #. type: Content of: <book><chapter><sect1><para>
17700 #: ../en/ch13-mq-collab.xml:254
17701 msgid ""
17702 "In working on the device driver I mentioned earlier, I don't apply the "
17703 "patches to a normal Linux kernel tree. Instead, I use a repository that "
17704 "contains only a snapshot of the source files and headers that are relevant to "
17705 "Infiniband development. This repository is 1% the size of a kernel "
17706 "repository, so it's easier to work with."
17707 msgstr ""
17709 #. type: Content of: <book><chapter><sect1><para>
17710 #: ../en/ch13-mq-collab.xml:261
17711 msgid ""
17712 "I then choose a <quote>base</quote> version on top of which the patches are "
17713 "applied. This is a snapshot of the Linux kernel tree as of a revision of my "
17714 "choosing. When I take the snapshot, I record the changeset ID from the "
17715 "kernel repository in the commit message. Since the snapshot preserves the "
17716 "<quote>shape</quote> and content of the relevant parts of the kernel tree, I "
17717 "can apply my patches on top of either my tiny repository or a normal kernel "
17718 "tree."
17719 msgstr ""
17721 #. type: Content of: <book><chapter><sect1><para>
17722 #: ../en/ch13-mq-collab.xml:270
17723 msgid ""
17724 "Normally, the base tree atop which the patches apply should be a snapshot of "
17725 "a very recent upstream tree. This best facilitates the development of "
17726 "patches that can easily be submitted upstream with few or no modifications."
17727 msgstr ""
17729 #. type: Content of: <book><chapter><sect1><title>
17730 #: ../en/ch13-mq-collab.xml:277
17731 msgid "Dividing up the <filename role=\"special\">series</filename> file"
17732 msgstr "分类补丁<filename role=\"special\">系列</filename>"
17734 #. type: Content of: <book><chapter><sect1><para>
17735 #: ../en/ch13-mq-collab.xml:280
17736 msgid ""
17737 "I categorise the patches in the <filename role=\"special\">series</filename> "
17738 "file into a number of logical groups. Each section of like patches begins "
17739 "with a block of comments that describes the purpose of the patches that "
17740 "follow."
17741 msgstr ""
17743 #. type: Content of: <book><chapter><sect1><para>
17744 #: ../en/ch13-mq-collab.xml:286
17745 msgid ""
17746 "The sequence of patch groups that I maintain follows. The ordering of these "
17747 "groups is important; I'll describe why after I introduce the groups."
17748 msgstr ""
17750 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17751 #: ../en/ch13-mq-collab.xml:290
17752 msgid ""
17753 "The <quote>accepted</quote> group. Patches that the development team has "
17754 "submitted to the maintainer of the Infiniband subsystem, and which he has "
17755 "accepted, but which are not present in the snapshot that the tiny repository "
17756 "is based on. These are <quote>read only</quote> patches, present only to "
17757 "transform the tree into a similar state as it is in the upstream maintainer's "
17758 "repository."
17759 msgstr ""
17761 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17762 #: ../en/ch13-mq-collab.xml:298
17763 msgid ""
17764 "The <quote>rework</quote> group. Patches that I have submitted, but that the "
17765 "upstream maintainer has requested modifications to before he will accept them."
17766 msgstr ""
17768 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17769 #: ../en/ch13-mq-collab.xml:303
17770 msgid ""
17771 "The <quote>pending</quote> group. Patches that I have not yet submitted to "
17772 "the upstream maintainer, but which we have finished working on. These will be "
17773 "<quote>read only</quote> for a while. If the upstream maintainer accepts "
17774 "them upon submission, I'll move them to the end of the <quote>accepted</"
17775 "quote> group. If he requests that I modify any, I'll move them to the "
17776 "beginning of the <quote>rework</quote> group."
17777 msgstr ""
17779 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17780 #: ../en/ch13-mq-collab.xml:312
17781 msgid ""
17782 "The <quote>in progress</quote> group. Patches that are actively being "
17783 "developed, and should not be submitted anywhere yet."
17784 msgstr ""
17786 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17787 #: ../en/ch13-mq-collab.xml:316
17788 msgid ""
17789 "The <quote>backport</quote> group. Patches that adapt the source tree to "
17790 "older versions of the kernel tree."
17791 msgstr ""
17793 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17794 #: ../en/ch13-mq-collab.xml:320
17795 msgid ""
17796 "The <quote>do not ship</quote> group. Patches that for some reason should "
17797 "never be submitted upstream. For example, one such patch might change "
17798 "embedded driver identification strings to make it easier to distinguish, in "
17799 "the field, between an out-of-tree version of the driver and a version shipped "
17800 "by a distribution vendor."
17801 msgstr ""
17803 #. type: Content of: <book><chapter><sect1><para>
17804 #: ../en/ch13-mq-collab.xml:328
17805 msgid ""
17806 "Now to return to the reasons for ordering groups of patches in this way. We "
17807 "would like the lowest patches in the stack to be as stable as possible, so "
17808 "that we will not need to rework higher patches due to changes in context. "
17809 "Putting patches that will never be changed first in the <filename role="
17810 "\"special\">series</filename> file serves this purpose."
17811 msgstr ""
17813 #. type: Content of: <book><chapter><sect1><para>
17814 #: ../en/ch13-mq-collab.xml:336
17815 msgid ""
17816 "We would also like the patches that we know we'll need to modify to be "
17817 "applied on top of a source tree that resembles the upstream tree as closely "
17818 "as possible. This is why we keep accepted patches around for a while."
17819 msgstr ""
17821 #. type: Content of: <book><chapter><sect1><para>
17822 #: ../en/ch13-mq-collab.xml:341
17823 msgid ""
17824 "The <quote>backport</quote> and <quote>do not ship</quote> patches float at "
17825 "the end of the <filename role=\"special\">series</filename> file. The "
17826 "backport patches must be applied on top of all other patches, and the "
17827 "<quote>do not ship</quote> patches might as well stay out of harm's way."
17828 msgstr ""
17830 #. type: Content of: <book><chapter><sect1><title>
17831 #: ../en/ch13-mq-collab.xml:350
17832 msgid "Maintaining the patch series"
17833 msgstr "维护补丁系列"
17835 #. type: Content of: <book><chapter><sect1><para>
17836 #: ../en/ch13-mq-collab.xml:352
17837 msgid ""
17838 "In my work, I use a number of guards to control which patches are to be "
17839 "applied."
17840 msgstr ""
17842 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17843 #: ../en/ch13-mq-collab.xml:356
17844 msgid ""
17845 "<quote>Accepted</quote> patches are guarded with <literal>accepted</"
17846 "literal>. I enable this guard most of the time. When I'm applying the "
17847 "patches on top of a tree where the patches are already present, I can turn "
17848 "this patch off, and the patches that follow it will apply cleanly."
17849 msgstr ""
17851 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17852 #: ../en/ch13-mq-collab.xml:363
17853 msgid ""
17854 "Patches that are <quote>finished</quote>, but not yet submitted, have no "
17855 "guards. If I'm applying the patch stack to a copy of the upstream tree, I "
17856 "don't need to enable any guards in order to get a reasonably safe source tree."
17857 msgstr ""
17859 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17860 #: ../en/ch13-mq-collab.xml:369
17861 msgid ""
17862 "Those patches that need reworking before being resubmitted are guarded with "
17863 "<literal>rework</literal>."
17864 msgstr ""
17866 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17867 #: ../en/ch13-mq-collab.xml:373
17868 msgid ""
17869 "For those patches that are still under development, I use <literal>devel</"
17870 "literal>."
17871 msgstr ""
17873 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17874 #: ../en/ch13-mq-collab.xml:376
17875 msgid ""
17876 "A backport patch may have several guards, one for each version of the kernel "
17877 "to which it applies. For example, a patch that backports a piece of code to "
17878 "2.6.9 will have a <literal>2.6.9</literal> guard."
17879 msgstr ""
17881 #. type: Content of: <book><chapter><sect1><para>
17882 #: ../en/ch13-mq-collab.xml:381
17883 msgid ""
17884 "This variety of guards gives me considerable flexibility in determining what "
17885 "kind of source tree I want to end up with. For most situations, the "
17886 "selection of appropriate guards is automated during the build process, but I "
17887 "can manually tune the guards to use for less common circumstances."
17888 msgstr ""
17890 #. type: Content of: <book><chapter><sect1><sect2><title>
17891 #: ../en/ch13-mq-collab.xml:388
17892 msgid "The art of writing backport patches"
17893 msgstr "编写向后移植补丁的艺术"
17895 #. type: Content of: <book><chapter><sect1><sect2><para>
17896 #: ../en/ch13-mq-collab.xml:390
17897 msgid ""
17898 "Using MQ, writing a backport patch is a simple process. All such a patch has "
17899 "to do is modify a piece of code that uses a kernel feature not present in the "
17900 "older version of the kernel, so that the driver continues to work correctly "
17901 "under that older version."
17902 msgstr ""
17904 #. type: Content of: <book><chapter><sect1><sect2><para>
17905 #: ../en/ch13-mq-collab.xml:396
17906 msgid ""
17907 "A useful goal when writing a good backport patch is to make your code look as "
17908 "if it was written for the older version of the kernel you're targeting. The "
17909 "less obtrusive the patch, the easier it will be to understand and maintain. "
17910 "If you're writing a collection of backport patches to avoid the <quote>rat's "
17911 "nest</quote> effect of lots of <literal>#ifdef</literal>s (hunks of source "
17912 "code that are only used conditionally) in your code, don't introduce version-"
17913 "dependent <literal>#ifdef</literal>s into the patches. Instead, write "
17914 "several patches, each of which makes unconditional changes, and control their "
17915 "application using guards."
17916 msgstr ""
17918 #. type: Content of: <book><chapter><sect1><sect2><para>
17919 #: ../en/ch13-mq-collab.xml:409
17920 msgid ""
17921 "There are two reasons to divide backport patches into a distinct group, away "
17922 "from the <quote>regular</quote> patches whose effects they modify. The first "
17923 "is that intermingling the two makes it more difficult to use a tool like the "
17924 "<literal role=\"hg-ext\">patchbomb</literal> extension to automate the "
17925 "process of submitting the patches to an upstream maintainer. The second is "
17926 "that a backport patch could perturb the context in which a subsequent regular "
17927 "patch is applied, making it impossible to apply the regular patch cleanly "
17928 "<emphasis>without</emphasis> the earlier backport patch already being applied."
17929 msgstr ""
17931 #. type: Content of: <book><chapter><sect1><title>
17932 #: ../en/ch13-mq-collab.xml:424
17933 msgid "Useful tips for developing with MQ"
17934 msgstr "使用 MQ 开发的技巧"
17936 #. type: Content of: <book><chapter><sect1><sect2><title>
17937 #: ../en/ch13-mq-collab.xml:427
17938 msgid "Organising patches in directories"
17939 msgstr "将补丁放到几个目录中"
17941 #. type: Content of: <book><chapter><sect1><sect2><para>
17942 #: ../en/ch13-mq-collab.xml:429
17943 msgid ""
17944 "If you're working on a substantial project with MQ, it's not difficult to "
17945 "accumulate a large number of patches. For example, I have one patch "
17946 "repository that contains over 250 patches."
17947 msgstr ""
17949 #. type: Content of: <book><chapter><sect1><sect2><para>
17950 #: ../en/ch13-mq-collab.xml:434
17951 msgid ""
17952 "If you can group these patches into separate logical categories, you can if "
17953 "you like store them in different directories; MQ has no problems with patch "
17954 "names that contain path separators."
17955 msgstr ""
17957 #. type: Content of: <book><chapter><sect1><sect2><title>
17958 #: ../en/ch13-mq-collab.xml:441
17959 msgid "Viewing the history of a patch"
17960 msgstr "察看补丁的历史"
17962 #. type: Content of: <book><chapter><sect1><sect2><para>
17963 #: ../en/ch13-mq-collab.xml:443
17964 msgid ""
17965 "If you're developing a set of patches over a long time, it's a good idea to "
17966 "maintain them in a repository, as discussed in <xref linkend=\"sec:mq:repo\"/"
17967 ">. If you do so, you'll quickly discover that using the <command role=\"hg-"
17968 "cmd\">hg diff</command> command to look at the history of changes to a patch "
17969 "is unworkable. This is in part because you're looking at the second "
17970 "derivative of the real code (a diff of a diff), but also because MQ adds "
17971 "noise to the process by modifying time stamps and directory names when it "
17972 "updates a patch."
17973 msgstr ""
17975 #. type: Content of: <book><chapter><sect1><sect2><para>
17976 #: ../en/ch13-mq-collab.xml:455
17977 msgid ""
17978 "However, you can use the <literal role=\"hg-ext\">extdiff</literal> "
17979 "extension, which is bundled with Mercurial, to turn a diff of two versions of "
17980 "a patch into something readable. To do this, you will need a third-party "
17981 "package called <literal role=\"package\">patchutils</literal> <citation>web:"
17982 "patchutils</citation>. This provides a command named <command>interdiff</"
17983 "command>, which shows the differences between two diffs as a diff. Used on "
17984 "two versions of the same diff, it generates a diff that represents the diff "
17985 "from the first to the second version."
17986 msgstr ""
17988 #. type: Content of: <book><chapter><sect1><sect2><para>
17989 #: ../en/ch13-mq-collab.xml:466
17990 msgid ""
17991 "You can enable the <literal role=\"hg-ext\">extdiff</literal> extension in "
17992 "the usual way, by adding a line to the <literal role=\"rc-extensions"
17993 "\">extensions</literal> section of your <filename role=\"special\">~/.hgrc</"
17994 "filename>."
17995 msgstr ""
17998 #. &example.hg-interdiff;
17999 #. type: Content of: <book><chapter><sect1><sect2><para>
18000 #: ../en/ch13-mq-collab.xml:473
18001 msgid ""
18002 "The <command>interdiff</command> command expects to be passed the names of "
18003 "two files, but the <literal role=\"hg-ext\">extdiff</literal> extension "
18004 "passes the program it runs a pair of directories, each of which can contain "
18005 "an arbitrary number of files. We thus need a small program that will run "
18006 "<command>interdiff</command> on each pair of files in these two directories. "
18007 "This program is available as <filename role=\"special\">hg-interdiff</"
18008 "filename> in the <filename class=\"directory\">examples</filename> directory "
18009 "of the source code repository that accompanies this book."
18010 msgstr ""
18012 #. type: Content of: <book><chapter><sect1><sect2><para>
18013 #: ../en/ch13-mq-collab.xml:485
18014 msgid ""
18015 "With the <filename role=\"special\">hg-interdiff</filename> program in your "
18016 "shell's search path, you can run it as follows, from inside an MQ patch "
18017 "directory:"
18018 msgstr ""
18020 #. type: Content of: <book><chapter><sect1><sect2><para>
18021 #: ../en/ch13-mq-collab.xml:489
18022 msgid ""
18023 "Since you'll probably want to use this long-winded command a lot, you can get "
18024 "<literal role=\"hg-ext\">hgext</literal> to make it available as a normal "
18025 "Mercurial command, again by editing your <filename role=\"special\">~/.hgrc</"
18026 "filename>."
18027 msgstr ""
18029 #. type: Content of: <book><chapter><sect1><sect2><para>
18030 #: ../en/ch13-mq-collab.xml:496
18031 msgid ""
18032 "This directs <literal role=\"hg-ext\">hgext</literal> to make an "
18033 "<literal>interdiff</literal> command available, so you can now shorten the "
18034 "previous invocation of <command role=\"hg-ext-extdiff\">extdiff</command> to "
18035 "something a little more wieldy."
18036 msgstr ""
18038 #. type: Content of: <book><chapter><sect1><sect2><note><para>
18039 #: ../en/ch13-mq-collab.xml:504
18040 msgid ""
18041 "The <command>interdiff</command> command works well only if the underlying "
18042 "files against which versions of a patch are generated remain the same. If "
18043 "you create a patch, modify the underlying files, and then regenerate the "
18044 "patch, <command>interdiff</command> may not produce useful output."
18045 msgstr ""
18047 #. type: Content of: <book><chapter><sect1><sect2><para>
18048 #: ../en/ch13-mq-collab.xml:512
18049 msgid ""
18050 "The <literal role=\"hg-ext\">extdiff</literal> extension is useful for more "
18051 "than merely improving the presentation of MQ patches. To read more about it, "
18052 "go to <xref linkend=\"sec:hgext:extdiff\"/>."
18053 msgstr ""
18055 #. type: Content of: <book><chapter><title>
18056 #: ../en/ch14-hgext.xml:5
18057 msgid "Adding functionality with extensions"
18058 msgstr "使用扩展增加功能"
18060 #. type: Content of: <book><chapter><para>
18061 #: ../en/ch14-hgext.xml:7
18062 msgid ""
18063 "While the core of Mercurial is quite complete from a functionality "
18064 "standpoint, it's deliberately shorn of fancy features. This approach of "
18065 "preserving simplicity keeps the software easy to deal with for both "
18066 "maintainers and users."
18067 msgstr ""
18069 #. type: Content of: <book><chapter><para>
18070 #: ../en/ch14-hgext.xml:12
18071 msgid ""
18072 "However, Mercurial doesn't box you in with an inflexible command set: you can "
18073 "add features to it as <emphasis>extensions</emphasis> (sometimes known as "
18074 "<emphasis>plugins</emphasis>). We've already discussed a few of these "
18075 "extensions in earlier chapters."
18076 msgstr ""
18078 #. type: Content of: <book><chapter><itemizedlist><listitem><para>
18079 #: ../en/ch14-hgext.xml:18
18080 msgid ""
18081 "<xref linkend=\"sec:tour-merge:fetch\"/> covers the <literal role=\"hg-ext"
18082 "\">fetch</literal> extension; this combines pulling new changes and merging "
18083 "them with local changes into a single command, <command role=\"hg-ext-fetch"
18084 "\">fetch</command>."
18085 msgstr ""
18087 #. type: Content of: <book><chapter><itemizedlist><listitem><para>
18088 #: ../en/ch14-hgext.xml:24
18089 msgid ""
18090 "In <xref linkend=\"chap:hook\"/>, we covered several extensions that are "
18091 "useful for hook-related functionality: <literal role=\"hg-ext\">acl</literal> "
18092 "adds access control lists; <literal role=\"hg-ext\">bugzilla</literal> adds "
18093 "integration with the Bugzilla bug tracking system; and <literal role=\"hg-ext"
18094 "\">notify</literal> sends notification emails on new changes."
18095 msgstr ""
18097 #. type: Content of: <book><chapter><itemizedlist><listitem><para>
18098 #: ../en/ch14-hgext.xml:33
18099 msgid ""
18100 "The Mercurial Queues patch management extension is so invaluable that it "
18101 "merits two chapters and an appendix all to itself. <xref linkend=\"chap:mq\"/"
18102 "> covers the basics; <xref linkend=\"chap:mq-collab\"/> discusses advanced "
18103 "topics; and <xref linkend=\"chap:mqref\"/> goes into detail on each command."
18104 msgstr ""
18106 #. type: Content of: <book><chapter><para>
18107 #: ../en/ch14-hgext.xml:43
18108 msgid ""
18109 "In this chapter, we'll cover some of the other extensions that are available "
18110 "for Mercurial, and briefly touch on some of the machinery you'll need to know "
18111 "about if you want to write an extension of your own."
18112 msgstr ""
18114 #. type: Content of: <book><chapter><itemizedlist><listitem><para>
18115 #: ../en/ch14-hgext.xml:48
18116 msgid ""
18117 "In <xref linkend=\"sec:hgext:inotify\"/>, we'll discuss the possibility of "
18118 "<emphasis>huge</emphasis> performance improvements using the <literal role="
18119 "\"hg-ext\">inotify</literal> extension."
18120 msgstr ""
18122 #. type: Content of: <book><chapter><sect1><title>
18123 #: ../en/ch14-hgext.xml:55
18124 msgid ""
18125 "Improve performance with the <literal role=\"hg-ext\">inotify</literal> "
18126 "extension"
18127 msgstr "使用扩展 <literal role=\"hg-ext\">inotify</literal> 以提高性能"
18129 #. type: Content of: <book><chapter><sect1><para>
18130 #: ../en/ch14-hgext.xml:58
18131 msgid ""
18132 "Are you interested in having some of the most common Mercurial operations run "
18133 "as much as a hundred times faster? Read on!"
18134 msgstr ""
18136 #. type: Content of: <book><chapter><sect1><para>
18137 #: ../en/ch14-hgext.xml:62
18138 msgid ""
18139 "Mercurial has great performance under normal circumstances. For example, "
18140 "when you run the <command role=\"hg-cmd\">hg status</command> command, "
18141 "Mercurial has to scan almost every directory and file in your repository so "
18142 "that it can display file status. Many other Mercurial commands need to do "
18143 "the same work behind the scenes; for example, the <command role=\"hg-cmd\">hg "
18144 "diff</command> command uses the status machinery to avoid doing an expensive "
18145 "comparison operation on files that obviously haven't changed."
18146 msgstr ""
18148 #. type: Content of: <book><chapter><sect1><para>
18149 #: ../en/ch14-hgext.xml:72
18150 msgid ""
18151 "Because obtaining file status is crucial to good performance, the authors of "
18152 "Mercurial have optimised this code to within an inch of its life. However, "
18153 "there's no avoiding the fact that when you run <command role=\"hg-cmd\">hg "
18154 "status</command>, Mercurial is going to have to perform at least one "
18155 "expensive system call for each managed file to determine whether it's changed "
18156 "since the last time Mercurial checked. For a sufficiently large repository, "
18157 "this can take a long time."
18158 msgstr ""
18160 #. type: Content of: <book><chapter><sect1><para>
18161 #: ../en/ch14-hgext.xml:82
18162 msgid ""
18163 "To put a number on the magnitude of this effect, I created a repository "
18164 "containing 150,000 managed files. I timed <command role=\"hg-cmd\">hg "
18165 "status</command> as taking ten seconds to run, even when <emphasis>none</"
18166 "emphasis> of those files had been modified."
18167 msgstr ""
18169 #. type: Content of: <book><chapter><sect1><para>
18170 #: ../en/ch14-hgext.xml:88
18171 msgid ""
18172 "Many modern operating systems contain a file notification facility. If a "
18173 "program signs up to an appropriate service, the operating system will notify "
18174 "it every time a file of interest is created, modified, or deleted. On Linux "
18175 "systems, the kernel component that does this is called <literal>inotify</"
18176 "literal>."
18177 msgstr ""
18179 #. type: Content of: <book><chapter><sect1><para>
18180 #: ../en/ch14-hgext.xml:95
18181 msgid ""
18182 "Mercurial's <literal role=\"hg-ext\">inotify</literal> extension talks to the "
18183 "kernel's <literal>inotify</literal> component to optimise <command role=\"hg-"
18184 "cmd\">hg status</command> commands. The extension has two components. A "
18185 "daemon sits in the background and receives notifications from the "
18186 "<literal>inotify</literal> subsystem. It also listens for connections from a "
18187 "regular Mercurial command. The extension modifies Mercurial's behavior so "
18188 "that instead of scanning the filesystem, it queries the daemon. Since the "
18189 "daemon has perfect information about the state of the repository, it can "
18190 "respond with a result instantaneously, avoiding the need to scan every "
18191 "directory and file in the repository."
18192 msgstr ""
18194 #. type: Content of: <book><chapter><sect1><para>
18195 #: ../en/ch14-hgext.xml:108
18196 msgid ""
18197 "Recall the ten seconds that I measured plain Mercurial as taking to run "
18198 "<command role=\"hg-cmd\">hg status</command> on a 150,000 file repository. "
18199 "With the <literal role=\"hg-ext\">inotify</literal> extension enabled, the "
18200 "time dropped to 0.1 seconds, a factor of <emphasis>one hundred</emphasis> "
18201 "faster."
18202 msgstr ""
18204 #. type: Content of: <book><chapter><sect1><para>
18205 #: ../en/ch14-hgext.xml:115
18206 msgid "Before we continue, please pay attention to some caveats."
18207 msgstr ""
18209 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
18210 #: ../en/ch14-hgext.xml:118
18211 msgid ""
18212 "The <literal role=\"hg-ext\">inotify</literal> extension is Linux-specific. "
18213 "Because it interfaces directly to the Linux kernel's <literal>inotify</"
18214 "literal> subsystem, it does not work on other operating systems."
18215 msgstr ""
18217 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
18218 #: ../en/ch14-hgext.xml:123
18219 msgid ""
18220 "It should work on any Linux distribution that was released after early 2005. "
18221 "Older distributions are likely to have a kernel that lacks <literal>inotify</"
18222 "literal>, or a version of <literal>glibc</literal> that does not have the "
18223 "necessary interfacing support."
18224 msgstr ""
18226 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
18227 #: ../en/ch14-hgext.xml:130
18228 msgid ""
18229 "Not all filesystems are suitable for use with the <literal role=\"hg-ext"
18230 "\">inotify</literal> extension. Network filesystems such as NFS are a non-"
18231 "starter, for example, particularly if you're running Mercurial on several "
18232 "systems, all mounting the same network filesystem. The kernel's "
18233 "<literal>inotify</literal> system has no way of knowing about changes made on "
18234 "another system. Most local filesystems (e.g. ext3, XFS, ReiserFS) should "
18235 "work fine."
18236 msgstr ""
18238 #. type: Content of: <book><chapter><sect1><para>
18239 #: ../en/ch14-hgext.xml:141
18240 msgid ""
18241 "The <literal role=\"hg-ext\">inotify</literal> extension is not yet shipped "
18242 "with Mercurial as of May 2007, so it's a little more involved to set up than "
18243 "other extensions. But the performance improvement is worth it!"
18244 msgstr ""
18246 #. type: Content of: <book><chapter><sect1><para>
18247 #: ../en/ch14-hgext.xml:146
18248 msgid ""
18249 "The extension currently comes in two parts: a set of patches to the Mercurial "
18250 "source code, and a library of Python bindings to the <literal>inotify</"
18251 "literal> subsystem."
18252 msgstr ""
18254 #. type: Content of: <book><chapter><sect1><note><para>
18255 #: ../en/ch14-hgext.xml:150
18256 msgid ""
18257 "There are <emphasis>two</emphasis> Python <literal>inotify</literal> binding "
18258 "libraries. One of them is called <literal>pyinotify</literal>, and is "
18259 "packaged by some Linux distributions as <literal>python-inotify</literal>. "
18260 "This is <emphasis>not</emphasis> the one you'll need, as it is too buggy and "
18261 "inefficient to be practical."
18262 msgstr ""
18264 #. type: Content of: <book><chapter><sect1><para>
18265 #: ../en/ch14-hgext.xml:157
18266 msgid ""
18267 "To get going, it's best to already have a functioning copy of Mercurial "
18268 "installed."
18269 msgstr ""
18271 #. type: Content of: <book><chapter><sect1><note><para>
18272 #: ../en/ch14-hgext.xml:160
18273 msgid ""
18274 "If you follow the instructions below, you'll be <emphasis>replacing</"
18275 "emphasis> and overwriting any existing installation of Mercurial that you "
18276 "might already have, using the latest <quote>bleeding edge</quote> Mercurial "
18277 "code. Don't say you weren't warned!"
18278 msgstr ""
18280 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
18281 #: ../en/ch14-hgext.xml:167
18282 msgid ""
18283 "Clone the Python <literal>inotify</literal> binding repository. Build and "
18284 "install it."
18285 msgstr ""
18287 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
18288 #: ../en/ch14-hgext.xml:174
18289 msgid ""
18290 "Clone the <filename class=\"directory\">crew</filename> Mercurial "
18291 "repository. Clone the <literal role=\"hg-ext\">inotify</literal> patch "
18292 "repository so that Mercurial Queues will be able to apply patches to your "
18293 "cope of the <filename class=\"directory\">crew</filename> repository."
18294 msgstr ""
18296 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
18297 #: ../en/ch14-hgext.xml:184
18298 msgid ""
18299 "Make sure that you have the Mercurial Queues extension, <literal role=\"hg-ext"
18300 "\">mq</literal>, enabled. If you've never used MQ, read <xref linkend=\"sec:"
18301 "mq:start\"/> to get started quickly."
18302 msgstr ""
18304 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
18305 #: ../en/ch14-hgext.xml:190
18306 msgid ""
18307 "Go into the <filename class=\"directory\">inotify</filename> repo, and apply "
18308 "all of the <literal role=\"hg-ext\">inotify</literal> patches using the "
18309 "<option role=\"hg-ext-mq-cmd-qpush-opt\">hg -a</option> option to the "
18310 "<command role=\"hg-ext-mq\">qpush</command> command."
18311 msgstr ""
18313 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
18314 #: ../en/ch14-hgext.xml:199
18315 msgid ""
18316 "If you get an error message from <command role=\"hg-ext-mq\">qpush</command>, "
18317 "you should not continue. Instead, ask for help."
18318 msgstr ""
18320 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
18321 #: ../en/ch14-hgext.xml:203
18322 msgid "Build and install the patched version of Mercurial."
18323 msgstr ""
18325 #. type: Content of: <book><chapter><sect1><para>
18326 #: ../en/ch14-hgext.xml:209
18327 msgid ""
18328 "Once you've build a suitably patched version of Mercurial, all you need to do "
18329 "to enable the <literal role=\"hg-ext\">inotify</literal> extension is add an "
18330 "entry to your <filename role=\"special\">~/.hgrc</filename>."
18331 msgstr ""
18333 #. type: Content of: <book><chapter><sect1><para>
18334 #: ../en/ch14-hgext.xml:214
18335 msgid ""
18336 "When the <literal role=\"hg-ext\">inotify</literal> extension is enabled, "
18337 "Mercurial will automatically and transparently start the status daemon the "
18338 "first time you run a command that needs status in a repository. It runs one "
18339 "status daemon per repository."
18340 msgstr ""
18342 #. type: Content of: <book><chapter><sect1><para>
18343 #: ../en/ch14-hgext.xml:220
18344 msgid ""
18345 "The status daemon is started silently, and runs in the background. If you "
18346 "look at a list of running processes after you've enabled the <literal role="
18347 "\"hg-ext\">inotify</literal> extension and run a few commands in different "
18348 "repositories, you'll thus see a few <literal>hg</literal> processes sitting "
18349 "around, waiting for updates from the kernel and queries from Mercurial."
18350 msgstr ""
18352 #. type: Content of: <book><chapter><sect1><para>
18353 #: ../en/ch14-hgext.xml:228
18354 msgid ""
18355 "The first time you run a Mercurial command in a repository when you have the "
18356 "<literal role=\"hg-ext\">inotify</literal> extension enabled, it will run "
18357 "with about the same performance as a normal Mercurial command. This is "
18358 "because the status daemon needs to perform a normal status scan so that it "
18359 "has a baseline against which to apply later updates from the kernel. "
18360 "However, <emphasis>every</emphasis> subsequent command that does any kind of "
18361 "status check should be noticeably faster on repositories of even fairly "
18362 "modest size. Better yet, the bigger your repository is, the greater a "
18363 "performance advantage you'll see. The <literal role=\"hg-ext\">inotify</"
18364 "literal> daemon makes status operations almost instantaneous on repositories "
18365 "of all sizes!"
18366 msgstr ""
18368 #. type: Content of: <book><chapter><sect1><para>
18369 #: ../en/ch14-hgext.xml:242
18370 msgid ""
18371 "If you like, you can manually start a status daemon using the <command role="
18372 "\"hg-ext-inotify\">inserve</command> command. This gives you slightly finer "
18373 "control over how the daemon ought to run. This command will of course only "
18374 "be available when the <literal role=\"hg-ext\">inotify</literal> extension is "
18375 "enabled."
18376 msgstr ""
18378 #. type: Content of: <book><chapter><sect1><para>
18379 #: ../en/ch14-hgext.xml:249
18380 msgid ""
18381 "When you're using the <literal role=\"hg-ext\">inotify</literal> extension, "
18382 "you should notice <emphasis>no difference at all</emphasis> in Mercurial's "
18383 "behavior, with the sole exception of status-related commands running a whole "
18384 "lot faster than they used to. You should specifically expect that commands "
18385 "will not print different output; neither should they give different results. "
18386 "If either of these situations occurs, please report a bug."
18387 msgstr ""
18389 #. type: Content of: <book><chapter><sect1><title>
18390 #: ../en/ch14-hgext.xml:260
18391 msgid ""
18392 "Flexible diff support with the <literal role=\"hg-ext\">extdiff</literal> "
18393 "extension"
18394 msgstr "使用扩展 <literal role=\"hg-ext\">extdiff</literal> 以扩展差异支持"
18396 #. type: Content of: <book><chapter><sect1><para>
18397 #: ../en/ch14-hgext.xml:263
18398 msgid ""
18399 "Mercurial's built-in <command role=\"hg-cmd\">hg diff</command> command "
18400 "outputs plaintext unified diffs."
18401 msgstr ""
18402 "Mercurial 内置命令 <command role=\"hg-cmd\">hg diff</command> 的输出与统一差异"
18403 "不同。"
18405 #. type: Content of: <book><chapter><sect1><para>
18406 #: ../en/ch14-hgext.xml:268
18407 msgid ""
18408 "If you would like to use an external tool to display modifications, you'll "
18409 "want to use the <literal role=\"hg-ext\">extdiff</literal> extension. This "
18410 "will let you use, for example, a graphical diff tool."
18411 msgstr ""
18413 #. type: Content of: <book><chapter><sect1><para>
18414 #: ../en/ch14-hgext.xml:273
18415 msgid ""
18416 "The <literal role=\"hg-ext\">extdiff</literal> extension is bundled with "
18417 "Mercurial, so it's easy to set up. In the <literal role=\"rc-extensions"
18418 "\">extensions</literal> section of your <filename role=\"special\">~/.hgrc</"
18419 "filename>, simply add a one-line entry to enable the extension."
18420 msgstr ""
18422 #. type: Content of: <book><chapter><sect1><para>
18423 #: ../en/ch14-hgext.xml:280
18424 msgid ""
18425 "This introduces a command named <command role=\"hg-ext-extdiff\">extdiff</"
18426 "command>, which by default uses your system's <command>diff</command> command "
18427 "to generate a unified diff in the same form as the built-in <command role="
18428 "\"hg-cmd\">hg diff</command> command."
18429 msgstr ""
18431 #. type: Content of: <book><chapter><sect1><para>
18432 #: ../en/ch14-hgext.xml:288
18433 msgid ""
18434 "The result won't be exactly the same as with the built-in <command role=\"hg-"
18435 "cmd\">hg diff</command> variations, because the output of <command>diff</"
18436 "command> varies from one system to another, even when passed the same options."
18437 msgstr ""
18439 #. type: Content of: <book><chapter><sect1><para>
18440 #: ../en/ch14-hgext.xml:293
18441 msgid ""
18442 "As the <quote><literal>making snapshot</literal></quote> lines of output "
18443 "above imply, the <command role=\"hg-ext-extdiff\">extdiff</command> command "
18444 "works by creating two snapshots of your source tree. The first snapshot is "
18445 "of the source revision; the second, of the target revision or working "
18446 "directory. The <command role=\"hg-ext-extdiff\">extdiff</command> command "
18447 "generates these snapshots in a temporary directory, passes the name of each "
18448 "directory to an external diff viewer, then deletes the temporary directory. "
18449 "For efficiency, it only snapshots the directories and files that have changed "
18450 "between the two revisions."
18451 msgstr ""
18453 #. type: Content of: <book><chapter><sect1><para>
18454 #: ../en/ch14-hgext.xml:306
18455 msgid ""
18456 "Snapshot directory names have the same base name as your repository. If your "
18457 "repository path is <filename class=\"directory\">/quux/bar/foo</filename>, "
18458 "then <filename class=\"directory\">foo</filename> will be the name of each "
18459 "snapshot directory. Each snapshot directory name has its changeset ID "
18460 "appended, if appropriate. If a snapshot is of revision "
18461 "<literal>a631aca1083f</literal>, the directory will be named <filename class="
18462 "\"directory\">foo.a631aca1083f</filename>. A snapshot of the working "
18463 "directory won't have a changeset ID appended, so it would just be <filename "
18464 "class=\"directory\">foo</filename> in this example. To see what this looks "
18465 "like in practice, look again at the <command role=\"hg-ext-extdiff\">extdiff</"
18466 "command> example above. Notice that the diff has the snapshot directory "
18467 "names embedded in its header."
18468 msgstr ""
18470 #. type: Content of: <book><chapter><sect1><para>
18471 #: ../en/ch14-hgext.xml:322
18472 msgid ""
18473 "The <command role=\"hg-ext-extdiff\">extdiff</command> command accepts two "
18474 "important options. The <option role=\"hg-ext-extdiff-cmd-extdiff-opt\">hg -p</"
18475 "option> option lets you choose a program to view differences with, instead of "
18476 "<command>diff</command>. With the <option role=\"hg-ext-extdiff-cmd-extdiff-"
18477 "opt\">hg -o</option> option, you can change the options that <command role="
18478 "\"hg-ext-extdiff\">extdiff</command> passes to the program (by default, these "
18479 "options are <quote><literal>-Npru</literal></quote>, which only make sense if "
18480 "you're running <command>diff</command>). In other respects, the <command "
18481 "role=\"hg-ext-extdiff\">extdiff</command> command acts similarly to the built-"
18482 "in <command role=\"hg-cmd\">hg diff</command> command: you use the same "
18483 "option names, syntax, and arguments to specify the revisions you want, the "
18484 "files you want, and so on."
18485 msgstr ""
18488 #. type: Content of: <book><chapter><sect1><para>
18489 #: ../en/ch14-hgext.xml:339
18490 msgid ""
18491 "As an example, here's how to run the normal system <command>diff</command> "
18492 "command, getting it to generate context diffs (using the <option role=\"cmd-"
18493 "opt-diff\">-c</option> option) instead of unified diffs, and five lines of "
18494 "context instead of the default three (passing <literal>5</literal> as the "
18495 "argument to the <option role=\"cmd-opt-diff\">-C</option> option)."
18496 msgstr ""
18498 #. type: Content of: <book><chapter><sect1><para>
18499 #: ../en/ch14-hgext.xml:348
18500 msgid ""
18501 "Launching a visual diff tool is just as easy. Here's how to launch the "
18502 "<command>kdiff3</command> viewer."
18503 msgstr ""
18505 #. type: Content of: <book><chapter><sect1><para>
18506 #: ../en/ch14-hgext.xml:352
18507 msgid ""
18508 "If your diff viewing command can't deal with directories, you can easily work "
18509 "around this with a little scripting. For an example of such scripting in "
18510 "action with the <literal role=\"hg-ext\">mq</literal> extension and the "
18511 "<command>interdiff</command> command, see <xref linkend=\"mq-collab:tips:"
18512 "interdiff\"/>."
18513 msgstr ""
18515 #. type: Content of: <book><chapter><sect1><sect2><title>
18516 #: ../en/ch14-hgext.xml:360
18517 msgid "Defining command aliases"
18518 msgstr "定义命令的别名"
18520 #. type: Content of: <book><chapter><sect1><sect2><para>
18521 #: ../en/ch14-hgext.xml:362
18522 msgid ""
18523 "It can be cumbersome to remember the options to both the <command role=\"hg-"
18524 "ext-extdiff\">extdiff</command> command and the diff viewer you want to use, "
18525 "so the <literal role=\"hg-ext\">extdiff</literal> extension lets you define "
18526 "<emphasis>new</emphasis> commands that will invoke your diff viewer with "
18527 "exactly the right options."
18528 msgstr ""
18530 #. type: Content of: <book><chapter><sect1><sect2><para>
18531 #: ../en/ch14-hgext.xml:369
18532 msgid ""
18533 "All you need to do is edit your <filename role=\"special\">~/.hgrc</"
18534 "filename>, and add a section named <literal role=\"rc-extdiff\">extdiff</"
18535 "literal>. Inside this section, you can define multiple commands. Here's how "
18536 "to add a <literal>kdiff3</literal> command. Once you've defined this, you "
18537 "can type <quote><literal>hg kdiff3</literal></quote> and the <literal role="
18538 "\"hg-ext\">extdiff</literal> extension will run <command>kdiff3</command> for "
18539 "you."
18540 msgstr ""
18542 #. type: Content of: <book><chapter><sect1><sect2><para>
18543 #: ../en/ch14-hgext.xml:379
18544 msgid ""
18545 "If you leave the right hand side of the definition empty, as above, the "
18546 "<literal role=\"hg-ext\">extdiff</literal> extension uses the name of the "
18547 "command you defined as the name of the external program to run. But these "
18548 "names don't have to be the same. Here, we define a command named "
18549 "<quote><literal>hg wibble</literal></quote>, which runs <command>kdiff3</"
18550 "command>."
18551 msgstr ""
18553 #. type: Content of: <book><chapter><sect1><sect2><para>
18554 #: ../en/ch14-hgext.xml:389
18555 msgid ""
18556 "You can also specify the default options that you want to invoke your diff "
18557 "viewing program with. The prefix to use is <quote><literal>opts.</literal></"
18558 "quote>, followed by the name of the command to which the options apply. This "
18559 "example defines a <quote><literal>hg vimdiff</literal></quote> command that "
18560 "runs the <command>vim</command> editor's <literal>DirDiff</literal> extension."
18561 msgstr ""
18563 #. type: Content of: <book><chapter><sect1><title>
18564 #: ../en/ch14-hgext.xml:403
18565 msgid ""
18566 "Cherrypicking changes with the <literal role=\"hg-ext\">transplant</literal> "
18567 "extension"
18568 msgstr "使用扩展 <literal role=\"hg-ext\">transplant</literal> 以挑选修改"
18570 #. type: Content of: <book><chapter><sect1><para>
18571 #: ../en/ch14-hgext.xml:406
18572 msgid "Need to have a long chat with Brendan about this."
18573 msgstr ""
18575 #. type: Content of: <book><chapter><sect1><title>
18576 #: ../en/ch14-hgext.xml:410
18577 msgid ""
18578 "Send changes via email with the <literal role=\"hg-ext\">patchbomb</literal> "
18579 "extension"
18580 msgstr ""
18581 "使用扩展 <literal role=\"hg-ext\">patchbomb</literal> 通过 email 发送修改"
18583 #. type: Content of: <book><chapter><sect1><para>
18584 #: ../en/ch14-hgext.xml:413
18585 msgid ""
18586 "Many projects have a culture of <quote>change review</quote>, in which people "
18587 "send their modifications to a mailing list for others to read and comment on "
18588 "before they commit the final version to a shared repository. Some projects "
18589 "have people who act as gatekeepers; they apply changes from other people to a "
18590 "repository to which those others don't have access."
18591 msgstr ""
18593 #. type: Content of: <book><chapter><sect1><para>
18594 #: ../en/ch14-hgext.xml:421
18595 msgid ""
18596 "Mercurial makes it easy to send changes over email for review or application, "
18597 "via its <literal role=\"hg-ext\">patchbomb</literal> extension. The "
18598 "extension is so named because changes are formatted as patches, and it's "
18599 "usual to send one changeset per email message. Sending a long series of "
18600 "changes by email is thus much like <quote>bombing</quote> the recipient's "
18601 "inbox, hence <quote>patchbomb</quote>."
18602 msgstr ""
18604 #. type: Content of: <book><chapter><sect1><para>
18605 #: ../en/ch14-hgext.xml:429
18606 msgid ""
18607 "As usual, the basic configuration of the <literal role=\"hg-ext\">patchbomb</"
18608 "literal> extension takes just one or two lines in your <filename role="
18609 "\"special\"> /.hgrc</filename>."
18610 msgstr ""
18612 #. type: Content of: <book><chapter><sect1><para>
18613 #: ../en/ch14-hgext.xml:435
18614 msgid ""
18615 "Once you've enabled the extension, you will have a new command available, "
18616 "named <command role=\"hg-ext-patchbomb\">email</command>."
18617 msgstr ""
18619 #. type: Content of: <book><chapter><sect1><para>
18620 #: ../en/ch14-hgext.xml:439
18621 msgid ""
18622 "The safest and best way to invoke the <command role=\"hg-ext-patchbomb"
18623 "\">email</command> command is to <emphasis>always</emphasis> run it first "
18624 "with the <option role=\"hg-ext-patchbomb-cmd-email-opt\">hg -n</option> "
18625 "option. This will show you what the command <emphasis>would</emphasis> send, "
18626 "without actually sending anything. Once you've had a quick glance over the "
18627 "changes and verified that you are sending the right ones, you can rerun the "
18628 "same command, with the <option role=\"hg-ext-patchbomb-cmd-email-opt\">hg -n</"
18629 "option> option removed."
18630 msgstr ""
18632 #. type: Content of: <book><chapter><sect1><para>
18633 #: ../en/ch14-hgext.xml:450
18634 msgid ""
18635 "The <command role=\"hg-ext-patchbomb\">email</command> command accepts the "
18636 "same kind of revision syntax as every other Mercurial command. For example, "
18637 "this command will send every revision between 7 and <literal>tip</literal>, "
18638 "inclusive."
18639 msgstr ""
18641 #. type: Content of: <book><chapter><sect1><para>
18642 #: ../en/ch14-hgext.xml:455
18643 msgid ""
18644 "You can also specify a <emphasis>repository</emphasis> to compare with. If "
18645 "you provide a repository but no revisions, the <command role=\"hg-ext-"
18646 "patchbomb\">email</command> command will send all revisions in the local "
18647 "repository that are not present in the remote repository. If you "
18648 "additionally specify revisions or a branch name (the latter using the <option "
18649 "role=\"hg-ext-patchbomb-cmd-email-opt\">hg -b</option> option), this will "
18650 "constrain the revisions sent."
18651 msgstr ""
18653 #. type: Content of: <book><chapter><sect1><para>
18654 #: ../en/ch14-hgext.xml:464
18655 msgid ""
18656 "It's perfectly safe to run the <command role=\"hg-ext-patchbomb\">email</"
18657 "command> command without the names of the people you want to send to: if you "
18658 "do this, it will just prompt you for those values interactively. (If you're "
18659 "using a Linux or Unix-like system, you should have enhanced "
18660 "<literal>readline</literal>-style editing capabilities when entering those "
18661 "headers, too, which is useful.)"
18662 msgstr ""
18664 #. type: Content of: <book><chapter><sect1><para>
18665 #: ../en/ch14-hgext.xml:472
18666 msgid ""
18667 "When you are sending just one revision, the <command role=\"hg-ext-patchbomb"
18668 "\">email</command> command will by default use the first line of the "
18669 "changeset description as the subject of the single email message it sends."
18670 msgstr ""
18672 #. type: Content of: <book><chapter><sect1><para>
18673 #: ../en/ch14-hgext.xml:477
18674 msgid ""
18675 "If you send multiple revisions, the <command role=\"hg-ext-patchbomb\">email</"
18676 "command> command will usually send one message per changeset. It will "
18677 "preface the series with an introductory message, in which you should describe "
18678 "the purpose of the series of changes you're sending."
18679 msgstr ""
18681 #. type: Content of: <book><chapter><sect1><sect2><title>
18682 #: ../en/ch14-hgext.xml:484
18683 msgid "Changing the behavior of patchbombs"
18684 msgstr "修改 patchbomb 的行为"
18686 #. type: Content of: <book><chapter><sect1><sect2><para>
18687 #: ../en/ch14-hgext.xml:486
18688 msgid ""
18689 "Not every project has exactly the same conventions for sending changes in "
18690 "email; the <literal role=\"hg-ext\">patchbomb</literal> extension tries to "
18691 "accommodate a number of variations through command line options."
18692 msgstr ""
18694 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
18695 #: ../en/ch14-hgext.xml:492
18696 msgid ""
18697 "You can write a subject for the introductory message on the command line "
18698 "using the <option role=\"hg-ext-patchbomb-cmd-email-opt\">hg -s</option> "
18699 "option. This takes one argument, the text of the subject to use."
18700 msgstr ""
18702 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
18703 #: ../en/ch14-hgext.xml:498
18704 msgid ""
18705 "To change the email address from which the messages originate, use the "
18706 "<option role=\"hg-ext-patchbomb-cmd-email-opt\">hg -f</option> option. This "
18707 "takes one argument, the email address to use."
18708 msgstr ""
18710 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
18711 #: ../en/ch14-hgext.xml:504
18712 msgid ""
18713 "The default behavior is to send unified diffs (see <xref linkend=\"sec:mq:"
18714 "patch\"/> for a description of the format), one per message. You can send a "
18715 "binary bundle instead with the <option role=\"hg-ext-patchbomb-cmd-email-opt"
18716 "\">hg -b</option> option."
18717 msgstr ""
18719 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
18720 #: ../en/ch14-hgext.xml:512
18721 msgid ""
18722 "Unified diffs are normally prefaced with a metadata header. You can omit "
18723 "this, and send unadorned diffs, with the <option role=\"hg-ext-patchbomb-cmd-"
18724 "email-opt\">hg --plain</option> option."
18725 msgstr ""
18727 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
18728 #: ../en/ch14-hgext.xml:518
18729 msgid ""
18730 "Diffs are normally sent <quote>inline</quote>, in the same body part as the "
18731 "description of a patch. This makes it easiest for the largest number of "
18732 "readers to quote and respond to parts of a diff, as some mail clients will "
18733 "only quote the first MIME body part in a message. If you'd prefer to send the "
18734 "description and the diff in separate body parts, use the <option role=\"hg-"
18735 "ext-patchbomb-cmd-email-opt\">hg -a</option> option."
18736 msgstr ""
18738 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
18739 #: ../en/ch14-hgext.xml:528
18740 msgid ""
18741 "Instead of sending mail messages, you can write them to an <literal>mbox</"
18742 "literal>-format mail folder using the <option role=\"hg-ext-patchbomb-cmd-"
18743 "email-opt\">hg -m</option> option. That option takes one argument, the name "
18744 "of the file to write to."
18745 msgstr ""
18747 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
18748 #: ../en/ch14-hgext.xml:535
18749 msgid ""
18750 "If you would like to add a <command>diffstat</command>-format summary to each "
18751 "patch, and one to the introductory message, use the <option role=\"hg-ext-"
18752 "patchbomb-cmd-email-opt\">hg -d</option> option. The <command>diffstat</"
18753 "command> command displays a table containing the name of each file patched, "
18754 "the number of lines affected, and a histogram showing how much each file is "
18755 "modified. This gives readers a qualitative glance at how complex a patch is."
18756 msgstr ""