hgbook

view po/zh.po @ 1071:9f19da74ac3a

2.4.2 partly zh translated
author Zhaoping Sun <zhaopingsun@gmail.com>
date Wed Nov 11 23:01:15 2009 -0500 (2009-11-11)
parents 3dec81dc4543
children 6a1eebd2e5c2
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 "<literal>date</literal>:这是变更集创建的日期和时间,还有时区。(日期和时间是相对于时区的;"
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 "<literal>summary</literal>:创建者对该变更集的描述的第一行文本信息。"
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 "有些变更集,像上面的第一个,有一个<literal>标签</literal>字段。"
3983 "标签是区分变更集的另外一种方法,给它一个容易记得名字。(叫做<literal>tip</literal>"
3984 "的标签有特殊意义:总是指向版本库中的最新的变更。"
3985 #. type: Content of: <book><chapter><sect1><para>
3986 #: ../en/ch02-tour-basic.xml:245
3987 msgid ""
3988 "The default output printed by <command role=\"hg-cmd\">hg log</command> is "
3989 "purely a summary; it is missing a lot of detail."
3990 msgstr "缺省情况下,<command role=\"hg-cmd\">hg log</command>的输出仅仅是个摘要,"
3991 "没有更详细的信息。"
3993 #. type: Content of: <book><chapter><sect1><para>
3994 #: ../en/ch02-tour-basic.xml:249
3995 msgid ""
3996 "<xref linkend=\"fig:tour-basic:history\"/> provides a graphical "
3997 "representation of the history of the <filename class=\"directory\">hello</"
3998 "filename> repository, to make it a little easier to see which direction "
3999 "history is <quote>flowing</quote> in. We'll be returning to this figure "
4000 "several times in this chapter and the chapter that follows."
4001 msgstr ""
4003 #. type: Content of: <book><chapter><sect1><figure><title>
4004 #: ../en/ch02-tour-basic.xml:258
4005 msgid ""
4006 "Graphical history of the <filename class=\"directory\">hello</filename> "
4007 "repository"
4008 msgstr "版本库 <filename class=\"directory\">hello</filename> 的历史图"
4010 #. type: Content of: <book><chapter><sect1><figure>
4011 #: ../en/ch02-tour-basic.xml:260 ../en/ch03-tour-merge.xml:61
4012 #: ../en/ch03-tour-merge.xml:207 ../en/ch04-concepts.xml:290
4013 msgid "<placeholder type=\"mediaobject\" id=\"0\"/>"
4014 msgstr ""
4016 #. type: Content of: <book><chapter><sect1><figure><mediaobject>
4017 #: ../en/ch02-tour-basic.xml:261
4018 msgid ""
4019 "<imageobject><imagedata fileref=\"figs/tour-history.png\"/></imageobject>"
4020 msgstr ""
4022 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject><textobject><phrase>
4023 #: ../en/ch02-tour-basic.xml:262 ../en/ch03-tour-merge.xml:63
4024 #: ../en/ch03-tour-merge.xml:95 ../en/ch03-tour-merge.xml:182
4025 #: ../en/ch03-tour-merge.xml:209 ../en/ch03-tour-merge.xml:279
4026 #: ../en/ch04-concepts.xml:59 ../en/ch04-concepts.xml:108
4027 #: ../en/ch04-concepts.xml:198 ../en/ch04-concepts.xml:292
4028 #: ../en/ch04-concepts.xml:347 ../en/ch04-concepts.xml:362
4029 #: ../en/ch04-concepts.xml:403 ../en/ch04-concepts.xml:423
4030 #: ../en/ch04-concepts.xml:469 ../en/ch06-collab.xml:316
4031 #: ../en/ch09-undo.xml:344 ../en/ch09-undo.xml:391 ../en/ch09-undo.xml:464
4032 #: ../en/ch09-undo.xml:502 ../en/ch09-undo.xml:658 ../en/ch09-undo.xml:682
4033 #: ../en/ch09-undo.xml:700 ../en/ch09-undo.xml:714 ../en/ch09-undo.xml:727
4034 #: ../en/ch12-mq.xml:413
4035 msgid "XXX add text"
4036 msgstr ""
4038 #. type: Content of: <book><chapter><sect1><sect2><title>
4039 #: ../en/ch02-tour-basic.xml:267
4040 msgid "Changesets, revisions, and talking to other people"
4041 msgstr "修改集,版本,与其它用户交互"
4043 #. type: Content of: <book><chapter><sect1><sect2><para>
4044 #: ../en/ch02-tour-basic.xml:270
4045 msgid ""
4046 "As English is a notoriously sloppy language, and computer science has a "
4047 "hallowed history of terminological confusion (why use one term when four will "
4048 "do?), revision control has a variety of words and phrases that mean the same "
4049 "thing. If you are talking about Mercurial history with other people, you "
4050 "will find that the word <quote>changeset</quote> is often compressed to "
4051 "<quote>change</quote> or (when written) <quote>cset</quote>, and sometimes a "
4052 "changeset is referred to as a <quote>revision</quote> or a <quote>rev</quote>."
4053 msgstr ""
4055 #. type: Content of: <book><chapter><sect1><sect2><para>
4056 #: ../en/ch02-tour-basic.xml:280
4057 msgid ""
4058 "While it doesn't matter what <emphasis>word</emphasis> you use to refer to "
4059 "the concept of <quote>a changeset</quote>, the <emphasis>identifier</"
4060 "emphasis> that you use to refer to <quote>a <emphasis>specific</emphasis> "
4061 "changeset</quote> is of great importance. Recall that the <literal>changeset</"
4062 "literal> field in the output from <command role=\"hg-cmd\">hg log</command> "
4063 "identifies a changeset using both a number and a hexadecimal string."
4064 msgstr ""
4066 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
4067 #: ../en/ch02-tour-basic.xml:289
4068 msgid ""
4069 "The revision number is a handy notation that is <emphasis>only valid in that "
4070 "repository</emphasis>."
4071 msgstr ""
4073 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
4074 #: ../en/ch02-tour-basic.xml:292
4075 msgid ""
4076 "The hexadecimal string is the <emphasis>permanent, unchanging identifier</"
4077 "emphasis> that will always identify that exact changeset in <emphasis>every</"
4078 "emphasis> copy of the repository."
4079 msgstr ""
4081 #. type: Content of: <book><chapter><sect1><sect2><para>
4082 #: ../en/ch02-tour-basic.xml:298
4083 msgid ""
4084 "This distinction is important. If you send someone an email talking about "
4085 "<quote>revision 33</quote>, there's a high likelihood that their revision 33 "
4086 "will <emphasis>not be the same</emphasis> as yours. The reason for this is "
4087 "that a revision number depends on the order in which changes arrived in a "
4088 "repository, and there is no guarantee that the same changes will happen in "
4089 "the same order in different repositories. Three changes <literal>a,b,c</"
4090 "literal> can easily appear in one repository as <literal>0,1,2</literal>, "
4091 "while in another as <literal>0,2,1</literal>."
4092 msgstr ""
4094 #. type: Content of: <book><chapter><sect1><sect2><para>
4095 #: ../en/ch02-tour-basic.xml:310
4096 msgid ""
4097 "Mercurial uses revision numbers purely as a convenient shorthand. If you "
4098 "need to discuss a changeset with someone, or make a record of a changeset for "
4099 "some other reason (for example, in a bug report), use the hexadecimal "
4100 "identifier."
4101 msgstr ""
4103 #. type: Content of: <book><chapter><sect1><sect2><title>
4104 #: ../en/ch02-tour-basic.xml:318
4105 msgid "Viewing specific revisions"
4106 msgstr "察看指定版本"
4108 #. type: Content of: <book><chapter><sect1><sect2><para>
4109 #: ../en/ch02-tour-basic.xml:320
4110 msgid ""
4111 "To narrow the output of <command role=\"hg-cmd\">hg log</command> down to a "
4112 "single revision, use the <option role=\"hg-opt-log\">-r</option> (or <option "
4113 "role=\"hg-opt-log\">--rev</option>) option. You can use either a revision "
4114 "number or a hexadecimal identifier, and you can provide as many revisions as "
4115 "you want."
4116 msgstr ""
4118 #. type: Content of: <book><chapter><sect1><sect2><para>
4119 #: ../en/ch02-tour-basic.xml:329
4120 msgid ""
4121 "If you want to see the history of several revisions without having to list "
4122 "each one, you can use <emphasis>range notation</emphasis>; this lets you "
4123 "express the idea <quote>I want all revisions between <literal>abc</literal> "
4124 "and <literal>def</literal>, inclusive</quote>."
4125 msgstr ""
4127 #. type: Content of: <book><chapter><sect1><sect2><para>
4128 #: ../en/ch02-tour-basic.xml:337
4129 msgid ""
4130 "Mercurial also honours the order in which you specify revisions, so <command "
4131 "role=\"hg-cmd\">hg log -r 2:4</command> prints 2, 3, and 4. while <command "
4132 "role=\"hg-cmd\">hg log -r 4:2</command> prints 4, 3, and 2."
4133 msgstr ""
4135 #. type: Content of: <book><chapter><sect1><sect2><title>
4136 #: ../en/ch02-tour-basic.xml:344
4137 msgid "More detailed information"
4138 msgstr "更详细的信息"
4140 #. type: Content of: <book><chapter><sect1><sect2><para>
4141 #: ../en/ch02-tour-basic.xml:346
4142 msgid ""
4143 "While the summary information printed by <command role=\"hg-cmd\">hg log</"
4144 "command> is useful if you already know what you're looking for, you may need "
4145 "to see a complete description of the change, or a list of the files changed, "
4146 "if you're trying to decide whether a changeset is the one you're looking for. "
4147 "The <command role=\"hg-cmd\">hg log</command> command's <option role=\"hg-opt-"
4148 "global\">-v</option> (or <option role=\"hg-opt-global\">--verbose</option>) "
4149 "option gives you this extra detail."
4150 msgstr ""
4152 #. type: Content of: <book><chapter><sect1><sect2><para>
4153 #: ../en/ch02-tour-basic.xml:358
4154 msgid ""
4155 "If you want to see both the description and content of a change, add the "
4156 "<option role=\"hg-opt-log\">-p</option> (or <option role=\"hg-opt-log\">--"
4157 "patch</option>) option. This displays the content of a change as a "
4158 "<emphasis>unified diff</emphasis> (if you've never seen a unified diff "
4159 "before, see <xref linkend=\"sec:mq:patch\"/> for an overview)."
4160 msgstr ""
4162 #. type: Content of: <book><chapter><sect1><sect2><para>
4163 #: ../en/ch02-tour-basic.xml:368
4164 msgid ""
4165 "The <option role=\"hg-opt-log\">-p</option> option is tremendously useful, so "
4166 "it's well worth remembering."
4167 msgstr ""
4169 #. type: Content of: <book><chapter><sect1><title>
4170 #: ../en/ch02-tour-basic.xml:375
4171 msgid "All about command options"
4172 msgstr "命令选项"
4174 #. type: Content of: <book><chapter><sect1><para>
4175 #: ../en/ch02-tour-basic.xml:377
4176 msgid ""
4177 "Let's take a brief break from exploring Mercurial commands to discuss a "
4178 "pattern in the way that they work; you may find this useful to keep in mind "
4179 "as we continue our tour."
4180 msgstr ""
4182 #. type: Content of: <book><chapter><sect1><para>
4183 #: ../en/ch02-tour-basic.xml:381
4184 msgid ""
4185 "Mercurial has a consistent and straightforward approach to dealing with the "
4186 "options that you can pass to commands. It follows the conventions for "
4187 "options that are common to modern Linux and Unix systems."
4188 msgstr ""
4190 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
4191 #: ../en/ch02-tour-basic.xml:388
4192 msgid ""
4193 "Every option has a long name. For example, as we've already seen, the "
4194 "<command role=\"hg-cmd\">hg log</command> command accepts a <option role=\"hg-"
4195 "opt-log\">--rev</option> option."
4196 msgstr ""
4198 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
4199 #: ../en/ch02-tour-basic.xml:394
4200 msgid ""
4201 "Most options have short names, too. Instead of <option role=\"hg-opt-log\">--"
4202 "rev</option>, we can use <option role=\"hg-opt-log\">-r</option>. (The "
4203 "reason that some options don't have short names is that the options in "
4204 "question are rarely used.)"
4205 msgstr ""
4207 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
4208 #: ../en/ch02-tour-basic.xml:401
4209 msgid ""
4210 "Long options start with two dashes (e.g. <option role=\"hg-opt-log\">--rev</"
4211 "option>), while short options start with one (e.g. <option role=\"hg-opt-log"
4212 "\">-r</option>)."
4213 msgstr ""
4215 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
4216 #: ../en/ch02-tour-basic.xml:407
4217 msgid ""
4218 "Option naming and usage is consistent across commands. For example, every "
4219 "command that lets you specify a changeset ID or revision number accepts both "
4220 "<option role=\"hg-opt-log\">-r</option> and <option role=\"hg-opt-log\">--"
4221 "rev</option> arguments."
4222 msgstr ""
4224 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
4225 #: ../en/ch02-tour-basic.xml:414
4226 msgid ""
4227 "If you are using short options, you can save typing by running them together. "
4228 "For example, the command <command role=\"hg-cmd\">hg log -v -p -r 2</command> "
4229 "can be written as <command role=\"hg-cmd\">hg log -vpr2</command>."
4230 msgstr ""
4232 #. type: Content of: <book><chapter><sect1><para>
4233 #: ../en/ch02-tour-basic.xml:421
4234 msgid ""
4235 "In the examples throughout this book, I usually use short options instead of "
4236 "long. This simply reflects my own preference, so don't read anything "
4237 "significant into it."
4238 msgstr ""
4240 #. type: Content of: <book><chapter><sect1><para>
4241 #: ../en/ch02-tour-basic.xml:425
4242 msgid ""
4243 "Most commands that print output of some kind will print more output when "
4244 "passed a <option role=\"hg-opt-global\">-v</option> (or <option role=\"hg-opt-"
4245 "global\">--verbose</option>) option, and less when passed <option role=\"hg-"
4246 "opt-global\">-q</option> (or <option role=\"hg-opt-global\">--quiet</option>)."
4247 msgstr ""
4249 #. type: Content of: <book><chapter><sect1><note><title>
4250 #: ../en/ch02-tour-basic.xml:432
4251 msgid "Option naming consistency"
4252 msgstr ""
4254 #. type: Content of: <book><chapter><sect1><note><para>
4255 #: ../en/ch02-tour-basic.xml:434
4256 msgid ""
4257 "Almost always, Mercurial commands use consistent option names to refer to the "
4258 "same concepts. For instance, if a command deals with changesets, you'll "
4259 "always identify them with <option role=\"hg-opt-log\">--rev</option> or "
4260 "<option role=\"hg-opt-log\">-r</option>. This consistent use of option names "
4261 "makes it easier to remember what options a particular command takes."
4262 msgstr ""
4264 #. type: Content of: <book><chapter><sect1><title>
4265 #: ../en/ch02-tour-basic.xml:445
4266 msgid "Making and reviewing changes"
4267 msgstr "创建和复审修改"
4269 #. type: Content of: <book><chapter><sect1><para>
4270 #: ../en/ch02-tour-basic.xml:447
4271 msgid ""
4272 "Now that we have a grasp of viewing history in Mercurial, let's take a look "
4273 "at making some changes and examining them."
4274 msgstr ""
4276 #. type: Content of: <book><chapter><sect1><para>
4277 #: ../en/ch02-tour-basic.xml:451
4278 msgid ""
4279 "The first thing we'll do is isolate our experiment in a repository of its "
4280 "own. We use the <command role=\"hg-cmd\">hg clone</command> command, but we "
4281 "don't need to clone a copy of the remote repository. Since we already have a "
4282 "copy of it locally, we can just clone that instead. This is much faster than "
4283 "cloning over the network, and cloning a local repository uses less disk space "
4284 "in most cases, too<placeholder type=\"footnote\" id=\"0\"/>."
4285 msgstr ""
4287 #. type: Content of: <book><chapter><sect1><para><footnote><para>
4288 #: ../en/ch02-tour-basic.xml:458
4289 msgid ""
4290 "The saving of space arises when source and destination repositories are on "
4291 "the same filesystem, in which case Mercurial will use hardlinks to do copy-on-"
4292 "write sharing of its internal metadata. If that explanation meant nothing to "
4293 "you, don't worry: everything happens transparently and automatically, and you "
4294 "don't need to understand it."
4295 msgstr ""
4297 #. type: Content of: <book><chapter><sect1><para>
4298 #: ../en/ch02-tour-basic.xml:468
4299 msgid ""
4300 "As an aside, it's often good practice to keep a <quote>pristine</quote> copy "
4301 "of a remote repository around, which you can then make temporary clones of to "
4302 "create sandboxes for each task you want to work on. This lets you work on "
4303 "multiple tasks in parallel, each isolated from the others until it's complete "
4304 "and you're ready to integrate it back. Because local clones are so cheap, "
4305 "there's almost no overhead to cloning and destroying repositories whenever "
4306 "you want."
4307 msgstr ""
4309 #. type: Content of: <book><chapter><sect1><para>
4310 #: ../en/ch02-tour-basic.xml:477
4311 msgid ""
4312 "In our <filename class=\"directory\">my-hello</filename> repository, we have "
4313 "a file <filename>hello.c</filename> that contains the classic <quote>hello, "
4314 "world</quote> program."
4315 msgstr ""
4317 #. type: Content of: <book><chapter><sect1><para>
4318 #: ../en/ch02-tour-basic.xml:483
4319 msgid "Let's edit this file so that it prints a second line of output."
4320 msgstr ""
4322 #. type: Content of: <book><chapter><sect1><para>
4323 #: ../en/ch02-tour-basic.xml:488
4324 msgid ""
4325 "Mercurial's <command role=\"hg-cmd\">hg status</command> command will tell us "
4326 "what Mercurial knows about the files in the repository."
4327 msgstr ""
4329 #. type: Content of: <book><chapter><sect1><para>
4330 #: ../en/ch02-tour-basic.xml:494
4331 msgid ""
4332 "The <command role=\"hg-cmd\">hg status</command> command prints no output for "
4333 "some files, but a line starting with <quote><literal>M</literal></quote> for "
4334 "<filename>hello.c</filename>. Unless you tell it to, <command role=\"hg-cmd"
4335 "\">hg status</command> will not print any output for files that have not been "
4336 "modified."
4337 msgstr ""
4339 #. type: Content of: <book><chapter><sect1><para>
4340 #: ../en/ch02-tour-basic.xml:501
4341 msgid ""
4342 "The <quote><literal>M</literal></quote> indicates that Mercurial has noticed "
4343 "that we modified <filename>hello.c</filename>. We didn't need to "
4344 "<emphasis>inform</emphasis> Mercurial that we were going to modify the file "
4345 "before we started, or that we had modified the file after we were done; it "
4346 "was able to figure this out itself."
4347 msgstr ""
4349 #. type: Content of: <book><chapter><sect1><para>
4350 #: ../en/ch02-tour-basic.xml:509
4351 msgid ""
4352 "It's somewhat helpful to know that we've modified <filename>hello.c</"
4353 "filename>, but we might prefer to know exactly <emphasis>what</emphasis> "
4354 "changes we've made to it. To do this, we use the <command role=\"hg-cmd\">hg "
4355 "diff</command> command."
4356 msgstr ""
4358 #. type: Content of: <book><chapter><sect1><title>
4359 #: ../en/ch02-tour-basic.xml:518 ../en/ch12-mq.xml:187
4360 msgid "Understanding patches"
4361 msgstr "理解补丁"
4363 #. type: Content of: <book><chapter><sect1><tip><para>
4364 #: ../en/ch02-tour-basic.xml:520
4365 msgid ""
4366 "Remember to take a look at <xref linkend=\"sec:mq:patch\"/> if you don't know "
4367 "how to read output above."
4368 msgstr ""
4370 #. type: Content of: <book><chapter><sect1><title>
4371 #: ../en/ch02-tour-basic.xml:526
4372 msgid "Recording changes in a new changeset"
4373 msgstr "在新修改集中记录修改"
4375 #. type: Content of: <book><chapter><sect1><para>
4376 #: ../en/ch02-tour-basic.xml:528
4377 msgid ""
4378 "We can modify files, build and test our changes, and use <command role=\"hg-"
4379 "cmd\">hg status</command> and <command role=\"hg-cmd\">hg diff</command> to "
4380 "review our changes, until we're satisfied with what we've done and arrive at "
4381 "a natural stopping point where we want to record our work in a new changeset."
4382 msgstr ""
4384 #. type: Content of: <book><chapter><sect1><para>
4385 #: ../en/ch02-tour-basic.xml:535
4386 msgid ""
4387 "The <command role=\"hg-cmd\">hg commit</command> command lets us create a new "
4388 "changeset; we'll usually refer to this as <quote>making a commit</quote> or "
4389 "<quote>committing</quote>."
4390 msgstr ""
4392 #. type: Content of: <book><chapter><sect1><sect2><title>
4393 #: ../en/ch02-tour-basic.xml:541
4394 msgid "Setting up a username"
4395 msgstr "配置用户名称"
4397 #. type: Content of: <book><chapter><sect1><sect2><para>
4398 #: ../en/ch02-tour-basic.xml:543
4399 msgid ""
4400 "When you try to run <command role=\"hg-cmd\">hg commit</command> for the "
4401 "first time, it is not guaranteed to succeed. Mercurial records your name and "
4402 "address with each change that you commit, so that you and others will later "
4403 "be able to tell who made each change. Mercurial tries to automatically "
4404 "figure out a sensible username to commit the change with. It will attempt "
4405 "each of the following methods, in order:"
4406 msgstr ""
4408 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
4409 #: ../en/ch02-tour-basic.xml:552
4410 msgid ""
4411 "If you specify a <option role=\"hg-opt-commit\">-u</option> option to the "
4412 "<command role=\"hg-cmd\">hg commit</command> command on the command line, "
4413 "followed by a username, this is always given the highest precedence."
4414 msgstr ""
4416 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
4417 #: ../en/ch02-tour-basic.xml:557
4418 msgid ""
4419 "If you have set the <envar>HGUSER</envar> environment variable, this is "
4420 "checked next."
4421 msgstr ""
4423 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
4424 #: ../en/ch02-tour-basic.xml:560
4425 msgid ""
4426 "If you create a file in your home directory called <filename role=\"special"
4427 "\">.hgrc</filename>, with a <envar role=\"rc-item-ui\">username</envar> "
4428 "entry, that will be used next. To see what the contents of this file should "
4429 "look like, refer to <xref linkend=\"sec:tour-basic:username\"/> below."
4430 msgstr ""
4432 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
4433 #: ../en/ch02-tour-basic.xml:568
4434 msgid ""
4435 "If you have set the <envar>EMAIL</envar> environment variable, this will be "
4436 "used next."
4437 msgstr ""
4439 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
4440 #: ../en/ch02-tour-basic.xml:571
4441 msgid ""
4442 "Mercurial will query your system to find out your local user name and host "
4443 "name, and construct a username from these components. Since this often "
4444 "results in a username that is not very useful, it will print a warning if it "
4445 "has to do this."
4446 msgstr ""
4448 #. type: Content of: <book><chapter><sect1><sect2><para>
4449 #: ../en/ch02-tour-basic.xml:578
4450 msgid ""
4451 "If all of these mechanisms fail, Mercurial will fail, printing an error "
4452 "message. In this case, it will not let you commit until you set up a "
4453 "username."
4454 msgstr ""
4456 #. type: Content of: <book><chapter><sect1><sect2><para>
4457 #: ../en/ch02-tour-basic.xml:582
4458 msgid ""
4459 "You should think of the <envar>HGUSER</envar> environment variable and the "
4460 "<option role=\"hg-opt-commit\">-u</option> option to the <command role=\"hg-"
4461 "cmd\">hg commit</command> command as ways to <emphasis>override</emphasis> "
4462 "Mercurial's default selection of username. For normal use, the simplest and "
4463 "most robust way to set a username for yourself is by creating a <filename "
4464 "role=\"special\">.hgrc</filename> file; see below for details."
4465 msgstr ""
4467 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
4468 #: ../en/ch02-tour-basic.xml:591
4469 msgid "Creating a Mercurial configuration file"
4470 msgstr "创建 Mercurial 的配置文件"
4472 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
4473 #: ../en/ch02-tour-basic.xml:593
4474 msgid ""
4475 "To set a user name, use your favorite editor to create a file called "
4476 "<filename role=\"special\">.hgrc</filename> in your home directory. "
4477 "Mercurial will use this file to look up your personalised configuration "
4478 "settings. The initial contents of your <filename role=\"special\">.hgrc</"
4479 "filename> should look like this."
4480 msgstr ""
4482 #. type: Content of: <book><chapter><sect1><sect2><sect3><tip><title>
4483 #: ../en/ch02-tour-basic.xml:602
4484 msgid "<quote>Home directory</quote> on Windows"
4485 msgstr ""
4487 #. type: Content of: <book><chapter><sect1><sect2><sect3><tip><para>
4488 #: ../en/ch02-tour-basic.xml:604
4489 msgid ""
4490 "When we refer to your home directory, on an English language installation of "
4491 "Windows this will usually be a folder named after your user name in "
4492 "<filename>C:\\Documents and Settings</filename>. You can find out the exact "
4493 "name of your home directory by opening a command prompt window and running "
4494 "the following command."
4495 msgstr ""
4497 #. type: Content of: <book><chapter><sect1><sect2><sect3><tip><screen><prompt>
4498 #: ../en/ch02-tour-basic.xml:612
4499 msgid "C:\\>"
4500 msgstr "C:\\>"
4502 #. type: Content of: <book><chapter><sect1><sect2><sect3><tip><screen><userinput>
4503 #: ../en/ch02-tour-basic.xml:612
4504 msgid "echo %UserProfile%"
4505 msgstr "echo %UserProfile%"
4507 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
4508 #: ../en/ch02-tour-basic.xml:619
4509 msgid ""
4510 "The <quote><literal>[ui]</literal></quote> line begins a <emphasis>section</"
4511 "emphasis> of the config file, so you can read the <quote><literal>username "
4512 "= ...</literal></quote> line as meaning <quote>set the value of the "
4513 "<literal>username</literal> item in the <literal>ui</literal> section</"
4514 "quote>. A section continues until a new section begins, or the end of the "
4515 "file. Mercurial ignores empty lines and treats any text from "
4516 "<quote><literal>#</literal></quote> to the end of a line as a comment."
4517 msgstr ""
4519 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
4520 #: ../en/ch02-tour-basic.xml:632
4521 msgid "Choosing a user name"
4522 msgstr "选择用户名称"
4524 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
4525 #: ../en/ch02-tour-basic.xml:634
4526 msgid ""
4527 "You can use any text you like as the value of the <literal>username</literal> "
4528 "config item, since this information is for reading by other people, but will "
4529 "not be interpreted by Mercurial. The convention that most people follow is "
4530 "to use their name and email address, as in the example above."
4531 msgstr ""
4533 #. type: Content of: <book><chapter><sect1><sect2><sect3><note><para>
4534 #: ../en/ch02-tour-basic.xml:641
4535 msgid ""
4536 "Mercurial's built-in web server obfuscates email addresses, to make it more "
4537 "difficult for the email harvesting tools that spammers use. This reduces the "
4538 "likelihood that you'll start receiving more junk email if you publish a "
4539 "Mercurial repository on the web."
4540 msgstr ""
4542 #. type: Content of: <book><chapter><sect1><sect2><title>
4543 #: ../en/ch02-tour-basic.xml:650
4544 msgid "Writing a commit message"
4545 msgstr "写提交日志"
4547 #. type: Content of: <book><chapter><sect1><sect2><para>
4548 #: ../en/ch02-tour-basic.xml:652
4549 msgid ""
4550 "When we commit a change, Mercurial drops us into a text editor, to enter a "
4551 "message that will describe the modifications we've made in this changeset. "
4552 "This is called the <emphasis>commit message</emphasis>. It will be a record "
4553 "for readers of what we did and why, and it will be printed by <command role="
4554 "\"hg-cmd\">hg log</command> after we've finished committing."
4555 msgstr ""
4557 #. type: Content of: <book><chapter><sect1><sect2><para>
4558 #: ../en/ch02-tour-basic.xml:662
4559 msgid ""
4560 "The editor that the <command role=\"hg-cmd\">hg commit</command> command "
4561 "drops us into will contain an empty line or two, followed by a number of "
4562 "lines starting with <quote><literal>HG:</literal></quote>."
4563 msgstr ""
4565 #. type: Content of: <book><chapter><sect1><sect2><para>
4566 #: ../en/ch02-tour-basic.xml:676
4567 msgid ""
4568 "Mercurial ignores the lines that start with <quote><literal>HG:</literal></"
4569 "quote>; it uses them only to tell us which files it's recording changes to. "
4570 "Modifying or deleting these lines has no effect."
4571 msgstr ""
4573 #. type: Content of: <book><chapter><sect1><sect2><title>
4574 #: ../en/ch02-tour-basic.xml:682
4575 msgid "Writing a good commit message"
4576 msgstr "写好提交日志"
4578 #. type: Content of: <book><chapter><sect1><sect2><para>
4579 #: ../en/ch02-tour-basic.xml:684
4580 msgid ""
4581 "Since <command role=\"hg-cmd\">hg log</command> only prints the first line of "
4582 "a commit message by default, it's best to write a commit message whose first "
4583 "line stands alone. Here's a real example of a commit message that "
4584 "<emphasis>doesn't</emphasis> follow this guideline, and hence has a summary "
4585 "that is not readable."
4586 msgstr ""
4588 #. type: Content of: <book><chapter><sect1><sect2><para>
4589 #: ../en/ch02-tour-basic.xml:697
4590 msgid ""
4591 "As far as the remainder of the contents of the commit message are concerned, "
4592 "there are no hard-and-fast rules. Mercurial itself doesn't interpret or care "
4593 "about the contents of the commit message, though your project may have "
4594 "policies that dictate a certain kind of formatting."
4595 msgstr ""
4597 #. type: Content of: <book><chapter><sect1><sect2><para>
4598 #: ../en/ch02-tour-basic.xml:702
4599 msgid ""
4600 "My personal preference is for short, but informative, commit messages that "
4601 "tell me something that I can't figure out with a quick glance at the output "
4602 "of <command role=\"hg-cmd\">hg log --patch</command>."
4603 msgstr ""
4605 #. type: Content of: <book><chapter><sect1><sect2><para>
4606 #: ../en/ch02-tour-basic.xml:706
4607 msgid ""
4608 "If we run the <command role=\"hg-cmd\">hg commit</command> command without "
4609 "any arguments, it records all of the changes we've made, as reported by "
4610 "<command role=\"hg-cmd\">hg status</command> and <command role=\"hg-cmd\">hg "
4611 "diff</command>."
4612 msgstr ""
4614 #. type: Content of: <book><chapter><sect1><sect2><note><title>
4615 #: ../en/ch02-tour-basic.xml:713
4616 msgid "A surprise for Subversion users"
4617 msgstr ""
4619 #. type: Content of: <book><chapter><sect1><sect2><note><para>
4620 #: ../en/ch02-tour-basic.xml:715
4621 msgid ""
4622 "Like other Mercurial commands, if we don't supply explicit names to commit to "
4623 "the <command role=\"hg-cmd\">hg commit</command>, it will operate across a "
4624 "repository's entire working directory. Be wary of this if you're coming from "
4625 "the Subversion or CVS world, since you might expect it to operate only on the "
4626 "current directory that you happen to be visiting and its subdirectories."
4627 msgstr ""
4629 #. type: Content of: <book><chapter><sect1><sect2><title>
4630 #: ../en/ch02-tour-basic.xml:726
4631 msgid "Aborting a commit"
4632 msgstr "终止提交"
4634 #. type: Content of: <book><chapter><sect1><sect2><para>
4635 #: ../en/ch02-tour-basic.xml:728
4636 msgid ""
4637 "If you decide that you don't want to commit while in the middle of editing a "
4638 "commit message, simply exit from your editor without saving the file that "
4639 "it's editing. This will cause nothing to happen to either the repository or "
4640 "the working directory."
4641 msgstr ""
4643 #. type: Content of: <book><chapter><sect1><sect2><title>
4644 #: ../en/ch02-tour-basic.xml:736
4645 msgid "Admiring our new handiwork"
4646 msgstr "欣赏我们的成果"
4648 #. type: Content of: <book><chapter><sect1><sect2><para>
4649 #: ../en/ch02-tour-basic.xml:738
4650 msgid ""
4651 "Once we've finished the commit, we can use the <command role=\"hg-cmd\">hg "
4652 "tip</command> command to display the changeset we just created. This command "
4653 "produces output that is identical to <command role=\"hg-cmd\">hg log</"
4654 "command>, but it only displays the newest revision in the repository."
4655 msgstr ""
4657 #. type: Content of: <book><chapter><sect1><sect2><para>
4658 #: ../en/ch02-tour-basic.xml:746
4659 msgid ""
4660 "We refer to the newest revision in the repository as the <emphasis>tip "
4661 "revision</emphasis>, or simply the <emphasis>tip</emphasis>."
4662 msgstr ""
4664 #. type: Content of: <book><chapter><sect1><sect2><para>
4665 #: ../en/ch02-tour-basic.xml:750
4666 msgid ""
4667 "By the way, the <command role=\"hg-cmd\">hg tip</command> command accepts "
4668 "many of the same options as <command role=\"hg-cmd\">hg log</command>, so "
4669 "<option role=\"hg-opt-global\">-v</option> above indicates <quote>be verbose</"
4670 "quote>, <option role=\"hg-opt-tip\">-p</option> specifies <quote>print a "
4671 "patch</quote>. The use of <option role=\"hg-opt-tip\">-p</option> to print "
4672 "patches is another example of the consistent naming we mentioned earlier."
4673 msgstr ""
4675 #. type: Content of: <book><chapter><sect1><title>
4676 #: ../en/ch02-tour-basic.xml:762
4677 msgid "Sharing changes"
4678 msgstr "共享修改"
4680 #. type: Content of: <book><chapter><sect1><para>
4681 #: ../en/ch02-tour-basic.xml:764
4682 msgid ""
4683 "We mentioned earlier that repositories in Mercurial are self-contained. This "
4684 "means that the changeset we just created exists only in our <filename class="
4685 "\"directory\">my-hello</filename> repository. Let's look at a few ways that "
4686 "we can propagate this change into other repositories."
4687 msgstr ""
4689 #. type: Content of: <book><chapter><sect1><sect2><title>
4690 #: ../en/ch02-tour-basic.xml:772
4691 msgid "Pulling changes from another repository"
4692 msgstr "从其它版本库取得修改"
4694 #. type: Content of: <book><chapter><sect1><sect2><para>
4695 #: ../en/ch02-tour-basic.xml:774
4696 msgid ""
4697 "To get started, let's clone our original <filename class=\"directory\">hello</"
4698 "filename> repository, which does not contain the change we just committed. "
4699 "We'll call our temporary repository <filename class=\"directory\">hello-pull</"
4700 "filename>."
4701 msgstr ""
4703 #. type: Content of: <book><chapter><sect1><sect2><para>
4704 #: ../en/ch02-tour-basic.xml:782
4705 msgid ""
4706 "We'll use the <command role=\"hg-cmd\">hg pull</command> command to bring "
4707 "changes from <filename class=\"directory\">my-hello</filename> into <filename "
4708 "class=\"directory\">hello-pull</filename>. However, blindly pulling unknown "
4709 "changes into a repository is a somewhat scary prospect. Mercurial provides "
4710 "the <command role=\"hg-cmd\">hg incoming</command> command to tell us what "
4711 "changes the <command role=\"hg-cmd\">hg pull</command> command "
4712 "<emphasis>would</emphasis> pull into the repository, without actually pulling "
4713 "the changes in."
4714 msgstr ""
4716 #. type: Content of: <book><chapter><sect1><sect2><para>
4717 #: ../en/ch02-tour-basic.xml:795
4718 msgid ""
4719 "Bringing changes into a repository is a simple matter of running the <command "
4720 "role=\"hg-cmd\">hg pull</command> command, and optionally telling it which "
4721 "repository to pull from."
4722 msgstr ""
4724 #. type: Content of: <book><chapter><sect1><sect2><para>
4725 #: ../en/ch02-tour-basic.xml:801
4726 msgid ""
4727 "As you can see from the before-and-after output of <command role=\"hg-cmd"
4728 "\">hg tip</command>, we have successfully pulled changes into our "
4729 "repository. However, Mercurial separates pulling changes in from updating "
4730 "the working directory. There remains one step before we will see the changes "
4731 "that we just pulled appear in the working directory."
4732 msgstr ""
4734 #. type: Content of: <book><chapter><sect1><sect2><tip><title>
4735 #: ../en/ch02-tour-basic.xml:810
4736 msgid "Pulling specific changes"
4737 msgstr "提取指定的修改"
4739 #. type: Content of: <book><chapter><sect1><sect2><tip><para>
4740 #: ../en/ch02-tour-basic.xml:812
4741 msgid ""
4742 "It is possible that due to the delay between running <command role=\"hg-cmd"
4743 "\">hg incoming</command> and <command role=\"hg-cmd\">hg pull</command>, you "
4744 "may not see all changesets that will be brought from the other repository. "
4745 "Suppose you're pulling changes from a repository on the network somewhere. "
4746 "While you are looking at the <command role=\"hg-cmd\">hg incoming</command> "
4747 "output, and before you pull those changes, someone might have committed "
4748 "something in the remote repository. This means that it's possible to pull "
4749 "more changes than you saw when using <command role=\"hg-cmd\">hg incoming</"
4750 "command>."
4751 msgstr ""
4753 #. type: Content of: <book><chapter><sect1><sect2><tip><para>
4754 #: ../en/ch02-tour-basic.xml:824
4755 msgid ""
4756 "If you only want to pull precisely the changes that were listed by <command "
4757 "role=\"hg-cmd\">hg incoming</command>, or you have some other reason to pull "
4758 "a subset of changes, simply identify the change that you want to pull by its "
4759 "changeset ID, e.g. <command>hg pull -r7e95bb</command>."
4760 msgstr ""
4762 #. type: Content of: <book><chapter><sect1><sect2><title>
4763 #: ../en/ch02-tour-basic.xml:834
4764 msgid "Updating the working directory"
4765 msgstr "更新工作目录"
4767 #. type: Content of: <book><chapter><sect1><sect2><para>
4768 #: ../en/ch02-tour-basic.xml:836
4769 msgid ""
4770 "We have so far glossed over the relationship between a repository and its "
4771 "working directory. The <command role=\"hg-cmd\">hg pull</command> command "
4772 "that we ran in <xref linkend=\"sec:tour:pull\"/> brought changes into the "
4773 "repository, but if we check, there's no sign of those changes in the working "
4774 "directory. This is because <command role=\"hg-cmd\">hg pull</command> does "
4775 "not (by default) touch the working directory. Instead, we use the <command "
4776 "role=\"hg-cmd\">hg update</command> command to do this."
4777 msgstr ""
4779 #. type: Content of: <book><chapter><sect1><sect2><para>
4780 #: ../en/ch02-tour-basic.xml:848
4781 msgid ""
4782 "It might seem a bit strange that <command role=\"hg-cmd\">hg pull</command> "
4783 "doesn't update the working directory automatically. There's actually a good "
4784 "reason for this: you can use <command role=\"hg-cmd\">hg update</command> to "
4785 "update the working directory to the state it was in at <emphasis>any "
4786 "revision</emphasis> in the history of the repository. If you had the working "
4787 "directory updated to an old revision&emdash;to hunt down the origin of a bug, "
4788 "say&emdash;and ran a <command role=\"hg-cmd\">hg pull</command> which "
4789 "automatically updated the working directory to a new revision, you might not "
4790 "be terribly happy."
4791 msgstr ""
4793 #. type: Content of: <book><chapter><sect1><sect2><para>
4794 #: ../en/ch02-tour-basic.xml:860
4795 msgid ""
4796 "Since pull-then-update is such a common sequence of operations, Mercurial "
4797 "lets you combine the two by passing the <option role=\"hg-opt-pull\">-u</"
4798 "option> option to <command role=\"hg-cmd\">hg pull</command>."
4799 msgstr ""
4801 #. type: Content of: <book><chapter><sect1><sect2><para>
4802 #: ../en/ch02-tour-basic.xml:865
4803 msgid ""
4804 "If you look back at the output of <command role=\"hg-cmd\">hg pull</command> "
4805 "in <xref linkend=\"sec:tour:pull\"/> when we ran it without <option role=\"hg-"
4806 "opt-pull\">-u</option>, you can see that it printed a helpful reminder that "
4807 "we'd have to take an explicit step to update the working directory."
4808 msgstr ""
4810 #. type: Content of: <book><chapter><sect1><sect2><para>
4811 #: ../en/ch02-tour-basic.xml:872
4812 msgid ""
4813 "To find out what revision the working directory is at, use the <command role="
4814 "\"hg-cmd\">hg parents</command> command."
4815 msgstr ""
4817 #. type: Content of: <book><chapter><sect1><sect2><para>
4818 #: ../en/ch02-tour-basic.xml:878
4819 msgid ""
4820 "If you look back at <xref linkend=\"fig:tour-basic:history\"/>, you'll see "
4821 "arrows connecting each changeset. The node that the arrow leads "
4822 "<emphasis>from</emphasis> in each case is a parent, and the node that the "
4823 "arrow leads <emphasis>to</emphasis> is its child. The working directory has "
4824 "a parent in just the same way; this is the changeset that the working "
4825 "directory currently contains."
4826 msgstr ""
4828 #. type: Content of: <book><chapter><sect1><sect2><para>
4829 #: ../en/ch02-tour-basic.xml:887
4830 msgid ""
4831 "To update the working directory to a particular revision, give a revision "
4832 "number or changeset ID to the <command role=\"hg-cmd\">hg update</command> "
4833 "command."
4834 msgstr ""
4836 #. type: Content of: <book><chapter><sect1><sect2><para>
4837 #: ../en/ch02-tour-basic.xml:893
4838 msgid ""
4839 "If you omit an explicit revision, <command role=\"hg-cmd\">hg update</"
4840 "command> will update to the tip revision, as shown by the second call to "
4841 "<command role=\"hg-cmd\">hg update</command> in the example above."
4842 msgstr ""
4844 #. type: Content of: <book><chapter><sect1><sect2><title>
4845 #: ../en/ch02-tour-basic.xml:901
4846 msgid "Pushing changes to another repository"
4847 msgstr "发布修改到其它版本库"
4849 #. type: Content of: <book><chapter><sect1><sect2><para>
4850 #: ../en/ch02-tour-basic.xml:903
4851 msgid ""
4852 "Mercurial lets us push changes to another repository, from the repository "
4853 "we're currently visiting. As with the example of <command role=\"hg-cmd\">hg "
4854 "pull</command> above, we'll create a temporary repository to push our changes "
4855 "into."
4856 msgstr ""
4858 #. type: Content of: <book><chapter><sect1><sect2><para>
4859 #: ../en/ch02-tour-basic.xml:911
4860 msgid ""
4861 "The <command role=\"hg-cmd\">hg outgoing</command> command tells us what "
4862 "changes would be pushed into another repository."
4863 msgstr ""
4865 #. type: Content of: <book><chapter><sect1><sect2><para>
4866 #: ../en/ch02-tour-basic.xml:917
4867 msgid ""
4868 "And the <command role=\"hg-cmd\">hg push</command> command does the actual "
4869 "push."
4870 msgstr ""
4872 #. type: Content of: <book><chapter><sect1><sect2><para>
4873 #: ../en/ch02-tour-basic.xml:922
4874 msgid ""
4875 "As with <command role=\"hg-cmd\">hg pull</command>, the <command role=\"hg-cmd"
4876 "\">hg push</command> command does not update the working directory in the "
4877 "repository that it's pushing changes into. Unlike <command role=\"hg-cmd\">hg "
4878 "pull</command>, <command role=\"hg-cmd\">hg push</command> does not provide a "
4879 "<literal>-u</literal> option that updates the other repository's working "
4880 "directory. This asymmetry is deliberate: the repository we're pushing to "
4881 "might be on a remote server and shared between several people. If we were to "
4882 "update its working directory while someone was working in it, their work "
4883 "would be disrupted."
4884 msgstr ""
4886 #. type: Content of: <book><chapter><sect1><sect2><para>
4887 #: ../en/ch02-tour-basic.xml:934
4888 msgid ""
4889 "What happens if we try to pull or push changes and the receiving repository "
4890 "already has those changes? Nothing too exciting."
4891 msgstr ""
4893 #. type: Content of: <book><chapter><sect1><sect2><title>
4894 #: ../en/ch02-tour-basic.xml:942
4895 msgid "Default locations"
4896 msgstr "默认位置"
4898 #. type: Content of: <book><chapter><sect1><sect2><para>
4899 #: ../en/ch02-tour-basic.xml:944
4900 msgid ""
4901 "When we clone a repository, Mercurial records the location of the repository "
4902 "we cloned in the <filename>.hg/hgrc</filename> file of the new repository. "
4903 "If we don't supply a location to <command>hg pull</command> from or "
4904 "<command>hg push</command> to, those commands will use this location as a "
4905 "default. The <command>hg incoming</command> and <command>hg outgoing</"
4906 "command> commands do so too."
4907 msgstr ""
4909 #. type: Content of: <book><chapter><sect1><sect2><para>
4910 #: ../en/ch02-tour-basic.xml:952
4911 msgid ""
4912 "If you open a repository's <filename>.hg/hgrc</filename> file in a text "
4913 "editor, you will see contents like the following."
4914 msgstr ""
4916 #. type: Content of: <book><chapter><sect1><sect2><para>
4917 #: ../en/ch02-tour-basic.xml:959
4918 msgid ""
4919 "It is possible&emdash;and often useful&emdash;to have the default location "
4920 "for <command>hg push</command> and <command>hg outgoing</command> be "
4921 "different from those for <command>hg pull</command> and <command>hg incoming</"
4922 "command>. We can do this by adding a <literal>default-push</literal> entry "
4923 "to the <literal>[paths]</literal> section of the <filename>.hg/hgrc</"
4924 "filename> file, as follows."
4925 msgstr ""
4927 #. type: Content of: <book><chapter><sect1><sect2><title>
4928 #: ../en/ch02-tour-basic.xml:973
4929 msgid "Sharing changes over a network"
4930 msgstr "通过网络共享修改"
4932 #. type: Content of: <book><chapter><sect1><sect2><para>
4933 #: ../en/ch02-tour-basic.xml:975
4934 msgid ""
4935 "The commands we have covered in the previous few sections are not limited to "
4936 "working with local repositories. Each works in exactly the same fashion over "
4937 "a network connection; simply pass in a URL instead of a local path."
4938 msgstr ""
4940 #. type: Content of: <book><chapter><sect1><sect2><para>
4941 #: ../en/ch02-tour-basic.xml:983
4942 msgid ""
4943 "In this example, we can see what changes we could push to the remote "
4944 "repository, but the repository is understandably not set up to let anonymous "
4945 "users push to it."
4946 msgstr ""
4948 #. type: Content of: <book><chapter><sect1><title>
4949 #: ../en/ch02-tour-basic.xml:993
4950 msgid "Starting a new project"
4951 msgstr "开始新项目"
4953 #. type: Content of: <book><chapter><sect1><para>
4954 #: ../en/ch02-tour-basic.xml:995
4955 msgid ""
4956 "It is just as easy to begin a new project as to work on one that already "
4957 "exists. The <command>hg init</command> command creates a new, empty "
4958 "Mercurial repository."
4959 msgstr ""
4961 #. type: Content of: <book><chapter><sect1><para>
4962 #: ../en/ch02-tour-basic.xml:1001
4963 msgid ""
4964 "This simply creates a repository named <filename>myproject</filename> in the "
4965 "current directory."
4966 msgstr ""
4968 #. type: Content of: <book><chapter><sect1><para>
4969 #: ../en/ch02-tour-basic.xml:1006
4970 msgid ""
4971 "We can tell that <filename>myproject</filename> is a Mercurial repository, "
4972 "because it contains a <filename>.hg</filename> directory."
4973 msgstr ""
4975 #. type: Content of: <book><chapter><sect1><para>
4976 #: ../en/ch02-tour-basic.xml:1012
4977 msgid ""
4978 "If we want to add some pre-existing files to the repository, we copy them "
4979 "into place, and tell Mercurial to start tracking them using the <command>hg "
4980 "add</command> command."
4981 msgstr ""
4983 #. type: Content of: <book><chapter><sect1><para>
4984 #: ../en/ch02-tour-basic.xml:1018
4985 msgid ""
4986 "Once we are satisfied that our project looks right, we commit our changes."
4987 msgstr ""
4989 #. type: Content of: <book><chapter><sect1><para>
4990 #: ../en/ch02-tour-basic.xml:1023
4991 msgid ""
4992 "It takes just a few moments to start using Mercurial on a new project, which "
4993 "is part of its appeal. Revision control is now so easy to work with, we can "
4994 "use it on the smallest of projects that we might not have considered with a "
4995 "more complicated tool."
4996 msgstr ""
4998 #. type: Content of: <book><chapter><title>
4999 #: ../en/ch03-tour-merge.xml:5
5000 msgid "A tour of Mercurial: merging work"
5001 msgstr "Mercurial 教程: 合并工作"
5003 #. type: Content of: <book><chapter><para>
5004 #: ../en/ch03-tour-merge.xml:7
5005 msgid ""
5006 "We've now covered cloning a repository, making changes in a repository, and "
5007 "pulling or pushing changes from one repository into another. Our next step "
5008 "is <emphasis>merging</emphasis> changes from separate repositories."
5009 msgstr ""
5011 #. type: Content of: <book><chapter><sect1><title>
5012 #: ../en/ch03-tour-merge.xml:13
5013 msgid "Merging streams of work"
5014 msgstr "合并的流程"
5016 #. type: Content of: <book><chapter><sect1><para>
5017 #: ../en/ch03-tour-merge.xml:15
5018 msgid ""
5019 "Merging is a fundamental part of working with a distributed revision control "
5020 "tool. Here are a few cases in which the need to merge work arises."
5021 msgstr ""
5023 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
5024 #: ../en/ch03-tour-merge.xml:20
5025 msgid ""
5026 "Alice and Bob each have a personal copy of a repository for a project they're "
5027 "collaborating on. Alice fixes a bug in her repository; Bob adds a new "
5028 "feature in his. They want the shared repository to contain both the bug fix "
5029 "and the new feature."
5030 msgstr ""
5032 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
5033 #: ../en/ch03-tour-merge.xml:27
5034 msgid ""
5035 "Cynthia frequently works on several different tasks for a single project at "
5036 "once, each safely isolated in its own repository. Working this way means that "
5037 "she often needs to merge one piece of her own work with another."
5038 msgstr ""
5040 #. type: Content of: <book><chapter><sect1><para>
5041 #: ../en/ch03-tour-merge.xml:35
5042 msgid ""
5043 "Because we need to merge often, Mercurial makes the process easy. Let's walk "
5044 "through a merge. We'll begin by cloning yet another repository (see how "
5045 "often they spring up?) and making a change in it."
5046 msgstr ""
5048 #. type: Content of: <book><chapter><sect1><para>
5049 #: ../en/ch03-tour-merge.xml:42
5050 msgid ""
5051 "We should now have two copies of <filename>hello.c</filename> with different "
5052 "contents. The histories of the two repositories have also diverged, as "
5053 "illustrated in <xref linkend=\"fig:tour-merge:sep-repos\"/>. Here is a copy "
5054 "of our file from one repository."
5055 msgstr ""
5057 #. type: Content of: <book><chapter><sect1><para>
5058 #: ../en/ch03-tour-merge.xml:51
5059 msgid "And here is our slightly different version from the other repository."
5060 msgstr ""
5062 #. type: Content of: <book><chapter><sect1><figure><title>
5063 #: ../en/ch03-tour-merge.xml:57
5064 msgid ""
5065 "Divergent recent histories of the <filename class=\"directory\">my-hello</"
5066 "filename> and <filename class=\"directory\">my-new-hello</filename> "
5067 "repositories"
5068 msgstr ""
5069 "<filename class=\"directory\">my-hello</filename> 与 <filename class="
5070 "\"directory\">my-new-hello</filename> 最新的历史分叉"
5072 #. type: Content of: <book><chapter><sect1><figure><mediaobject>
5073 #: ../en/ch03-tour-merge.xml:62
5074 msgid ""
5075 "<imageobject><imagedata fileref=\"figs/tour-merge-sep-repos.png\"/></"
5076 "imageobject>"
5077 msgstr ""
5079 #. type: Content of: <book><chapter><sect1><para>
5080 #: ../en/ch03-tour-merge.xml:67
5081 msgid ""
5082 "We already know that pulling changes from our <filename class=\"directory"
5083 "\">my-hello</filename> repository will have no effect on the working "
5084 "directory."
5085 msgstr ""
5087 #. type: Content of: <book><chapter><sect1><para>
5088 #: ../en/ch03-tour-merge.xml:73
5089 msgid ""
5090 "However, the <command role=\"hg-cmd\">hg pull</command> command says "
5091 "something about <quote>heads</quote>."
5092 msgstr ""
5094 #. type: Content of: <book><chapter><sect1><sect2><title>
5095 #: ../en/ch03-tour-merge.xml:77
5096 msgid "Head changesets"
5097 msgstr "顶点修改集"
5099 #. type: Content of: <book><chapter><sect1><sect2><para>
5100 #: ../en/ch03-tour-merge.xml:79
5101 msgid ""
5102 "Remember that Mercurial records what the parent of each change is. If a "
5103 "change has a parent, we call it a child or descendant of the parent. A head "
5104 "is a change that has no children. The tip revision is thus a head, because "
5105 "the newest revision in a repository doesn't have any children. There are "
5106 "times when a repository can contain more than one head."
5107 msgstr ""
5109 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
5110 #: ../en/ch03-tour-merge.xml:88
5111 msgid ""
5112 "Repository contents after pulling from <filename class=\"directory\">my-"
5113 "hello</filename> into <filename class=\"directory\">my-new-hello</filename>"
5114 msgstr ""
5115 "从 <filename class=\"directory\">my-hello</filename> 拉到 <filename class="
5116 "\"directory\">my-new-hello</filename> 之后版本库的内容"
5118 #. type: Content of: <book><chapter><sect1><sect2><figure>
5119 #: ../en/ch03-tour-merge.xml:91 ../en/ch03-tour-merge.xml:178
5120 #: ../en/ch03-tour-merge.xml:275 ../en/ch04-concepts.xml:57
5121 #: ../en/ch04-concepts.xml:106 ../en/ch04-concepts.xml:196
5122 #: ../en/ch04-concepts.xml:345 ../en/ch04-concepts.xml:360
5123 #: ../en/ch04-concepts.xml:401 ../en/ch04-concepts.xml:421
5124 #: ../en/ch04-concepts.xml:465 ../en/ch06-collab.xml:314
5125 #: ../en/ch09-undo.xml:342 ../en/ch09-undo.xml:389 ../en/ch09-undo.xml:462
5126 #: ../en/ch09-undo.xml:500 ../en/ch09-undo.xml:656 ../en/ch09-undo.xml:680
5127 #: ../en/ch09-undo.xml:698 ../en/ch09-undo.xml:712 ../en/ch09-undo.xml:725
5128 #: ../en/ch12-mq.xml:411
5129 msgid " <placeholder type=\"mediaobject\" id=\"0\"/>"
5130 msgstr ""
5132 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
5133 #: ../en/ch03-tour-merge.xml:92
5134 msgid ""
5135 "<imageobject> <imagedata fileref=\"figs/tour-merge-pull.png\"/> </imageobject>"
5136 msgstr ""
5138 #. type: Content of: <book><chapter><sect1><sect2><para>
5139 #: ../en/ch03-tour-merge.xml:99
5140 msgid ""
5141 "In <xref linkend=\"fig:tour-merge:pull\"/>, you can see the effect of the "
5142 "pull from <filename class=\"directory\">my-hello</filename> into <filename "
5143 "class=\"directory\">my-new-hello</filename>. The history that was already "
5144 "present in <filename class=\"directory\">my-new-hello</filename> is "
5145 "untouched, but a new revision has been added. By referring to <xref linkend="
5146 "\"fig:tour-merge:sep-repos\"/>, we can see that the <emphasis>changeset ID</"
5147 "emphasis> remains the same in the new repository, but the <emphasis>revision "
5148 "number</emphasis> has changed. (This, incidentally, is a fine example of why "
5149 "it's not safe to use revision numbers when discussing changesets.) We can "
5150 "view the heads in a repository using the <command role=\"hg-cmd\">hg heads</"
5151 "command> command."
5152 msgstr ""
5154 #. type: Content of: <book><chapter><sect1><sect2><title>
5155 #: ../en/ch03-tour-merge.xml:118
5156 msgid "Performing the merge"
5157 msgstr "执行合并"
5159 #. type: Content of: <book><chapter><sect1><sect2><para>
5160 #: ../en/ch03-tour-merge.xml:120
5161 msgid ""
5162 "What happens if we try to use the normal <command role=\"hg-cmd\">hg update</"
5163 "command> command to update to the new tip?"
5164 msgstr ""
5166 #. type: Content of: <book><chapter><sect1><sect2><para>
5167 #: ../en/ch03-tour-merge.xml:126
5168 msgid ""
5169 "Mercurial is telling us that the <command role=\"hg-cmd\">hg update</command> "
5170 "command won't do a merge; it won't update the working directory when it "
5171 "thinks we might want to do a merge, unless we force it to do so. "
5172 "(Incidentally, forcing the update with <command>hg update -C</command> would "
5173 "revert any uncommitted changes in the working directory.)"
5174 msgstr ""
5176 #. type: Content of: <book><chapter><sect1><sect2><para>
5177 #: ../en/ch03-tour-merge.xml:134
5178 msgid ""
5179 "To start a merge between the two heads, we use the <command role=\"hg-cmd"
5180 "\">hg merge</command> command."
5181 msgstr ""
5182 "我们使用 <command role=\"hg-cmd\">hg merge</command> 命令来合并两个顶点。"
5184 #. type: Content of: <book><chapter><sect1><sect2><para>
5185 #: ../en/ch03-tour-merge.xml:139
5186 msgid ""
5187 "We resolve the contents of <filename>hello.c</filename> This updates the "
5188 "working directory so that it contains changes from <emphasis>both</emphasis> "
5189 "heads, which is reflected in both the output of <command role=\"hg-cmd\">hg "
5190 "parents</command> and the contents of <filename>hello.c</filename>."
5191 msgstr ""
5193 #. type: Content of: <book><chapter><sect1><sect2><title>
5194 #: ../en/ch03-tour-merge.xml:151
5195 msgid "Committing the results of the merge"
5196 msgstr "提交合并结果"
5198 #. type: Content of: <book><chapter><sect1><sect2><para>
5199 #: ../en/ch03-tour-merge.xml:153
5200 msgid ""
5201 "Whenever we've done a merge, <command role=\"hg-cmd\">hg parents</command> "
5202 "will display two parents until we <command role=\"hg-cmd\">hg commit</"
5203 "command> the results of the merge."
5204 msgstr ""
5206 #. type: Content of: <book><chapter><sect1><sect2><para>
5207 #: ../en/ch03-tour-merge.xml:160
5208 msgid ""
5209 "We now have a new tip revision; notice that it has <emphasis>both</emphasis> "
5210 "of our former heads as its parents. These are the same revisions that were "
5211 "previously displayed by <command role=\"hg-cmd\">hg parents</command>."
5212 msgstr ""
5214 #. type: Content of: <book><chapter><sect1><sect2><para>
5215 #: ../en/ch03-tour-merge.xml:167
5216 msgid ""
5217 "In <xref linkend=\"fig:tour-merge:merge\"/>, you can see a representation of "
5218 "what happens to the working directory during the merge, and how this affects "
5219 "the repository when the commit happens. During the merge, the working "
5220 "directory has two parent changesets, and these become the parents of the new "
5221 "changeset."
5222 msgstr ""
5224 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
5225 #: ../en/ch03-tour-merge.xml:176
5226 msgid "Working directory and repository during merge, and following commit"
5227 msgstr "在合并期间,以及提交之后的工作目录与版本库"
5229 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
5230 #: ../en/ch03-tour-merge.xml:179
5231 msgid ""
5232 "<imageobject> <imagedata fileref=\"figs/tour-merge-merge.png\"/> </"
5233 "imageobject>"
5234 msgstr ""
5236 #. type: Content of: <book><chapter><sect1><sect2><para>
5237 #: ../en/ch03-tour-merge.xml:186
5238 msgid ""
5239 "We sometimes talk about a merge having <emphasis>sides</emphasis>: the left "
5240 "side is the first parent in the output of <command role=\"hg-cmd\">hg "
5241 "parents</command>, and the right side is the second. If the working "
5242 "directory was at e.g. revision 5 before we began a merge, that revision will "
5243 "become the left side of the merge."
5244 msgstr ""
5246 #. type: Content of: <book><chapter><sect1><title>
5247 #: ../en/ch03-tour-merge.xml:196
5248 msgid "Merging conflicting changes"
5249 msgstr "合并有冲突的改变"
5251 #. type: Content of: <book><chapter><sect1><para>
5252 #: ../en/ch03-tour-merge.xml:198
5253 msgid ""
5254 "Most merges are simple affairs, but sometimes you'll find yourself merging "
5255 "changes where each side modifies the same portions of the same files. Unless "
5256 "both modifications are identical, this results in a <emphasis>conflict</"
5257 "emphasis>, where you have to decide how to reconcile the different changes "
5258 "into something coherent."
5259 msgstr ""
5261 #. type: Content of: <book><chapter><sect1><figure><title>
5262 #: ../en/ch03-tour-merge.xml:206
5263 msgid "Conflicting changes to a document"
5264 msgstr "冲突的修改"
5266 #. type: Content of: <book><chapter><sect1><figure><mediaobject>
5267 #: ../en/ch03-tour-merge.xml:208
5268 msgid ""
5269 "<imageobject><imagedata fileref=\"figs/tour-merge-conflict.png\"/></"
5270 "imageobject>"
5271 msgstr ""
5273 #. type: Content of: <book><chapter><sect1><para>
5274 #: ../en/ch03-tour-merge.xml:213
5275 msgid ""
5276 "<xref linkend=\"fig:tour-merge:conflict\"/> illustrates an instance of two "
5277 "conflicting changes to a document. We started with a single version of the "
5278 "file; then we made some changes; while someone else made different changes to "
5279 "the same text. Our task in resolving the conflicting changes is to decide "
5280 "what the file should look like."
5281 msgstr ""
5283 #. type: Content of: <book><chapter><sect1><para>
5284 #: ../en/ch03-tour-merge.xml:220
5285 msgid ""
5286 "Mercurial doesn't have a built-in facility for handling conflicts. Instead, "
5287 "it runs an external program, usually one that displays some kind of graphical "
5288 "conflict resolution interface. By default, Mercurial tries to find one of "
5289 "several different merging tools that are likely to be installed on your "
5290 "system. It first tries a few fully automatic merging tools; if these don't "
5291 "succeed (because the resolution process requires human guidance) or aren't "
5292 "present, it tries a few different graphical merging tools."
5293 msgstr ""
5295 #. type: Content of: <book><chapter><sect1><para>
5296 #: ../en/ch03-tour-merge.xml:230
5297 msgid ""
5298 "It's also possible to get Mercurial to run a specific program or script, by "
5299 "setting the <envar>HGMERGE</envar> environment variable to the name of your "
5300 "preferred program."
5301 msgstr ""
5303 #. type: Content of: <book><chapter><sect1><sect2><title>
5304 #: ../en/ch03-tour-merge.xml:236
5305 msgid "Using a graphical merge tool"
5306 msgstr "使用图形合并工具"
5308 #. type: Content of: <book><chapter><sect1><sect2><para>
5309 #: ../en/ch03-tour-merge.xml:238
5310 msgid ""
5311 "My preferred graphical merge tool is <command>kdiff3</command>, which I'll "
5312 "use to describe the features that are common to graphical file merging "
5313 "tools. You can see a screenshot of <command>kdiff3</command> in action in "
5314 "<xref linkend=\"fig:tour-merge:kdiff3\"/>. The kind of merge it is "
5315 "performing is called a <emphasis>three-way merge</emphasis>, because there "
5316 "are three different versions of the file of interest to us. The tool thus "
5317 "splits the upper portion of the window into three panes:"
5318 msgstr ""
5320 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
5321 #: ../en/ch03-tour-merge.xml:248
5322 msgid ""
5323 "At the left is the <emphasis>base</emphasis> version of the file, i.e. the "
5324 "most recent version from which the two versions we're trying to merge are "
5325 "descended."
5326 msgstr ""
5328 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
5329 #: ../en/ch03-tour-merge.xml:253
5330 msgid ""
5331 "In the middle is <quote>our</quote> version of the file, with the contents "
5332 "that we modified."
5333 msgstr ""
5335 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
5336 #: ../en/ch03-tour-merge.xml:256
5337 msgid ""
5338 "On the right is <quote>their</quote> version of the file, the one that from "
5339 "the changeset that we're trying to merge with."
5340 msgstr ""
5342 #. type: Content of: <book><chapter><sect1><sect2><para>
5343 #: ../en/ch03-tour-merge.xml:260
5344 msgid ""
5345 "In the pane below these is the current <emphasis>result</emphasis> of the "
5346 "merge. Our task is to replace all of the red text, which indicates unresolved "
5347 "conflicts, with some sensible merger of the <quote>ours</quote> and "
5348 "<quote>theirs</quote> versions of the file."
5349 msgstr ""
5351 #. type: Content of: <book><chapter><sect1><sect2><para>
5352 #: ../en/ch03-tour-merge.xml:267
5353 msgid ""
5354 "All four of these panes are <emphasis>locked together</emphasis>; if we "
5355 "scroll vertically or horizontally in any of them, the others are updated to "
5356 "display the corresponding sections of their respective files."
5357 msgstr ""
5359 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
5360 #: ../en/ch03-tour-merge.xml:273
5361 msgid "Using <command>kdiff3</command> to merge versions of a file"
5362 msgstr "使用 <command>kdiff3</command> 合并文件的不同版本"
5364 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
5365 #: ../en/ch03-tour-merge.xml:276
5366 msgid ""
5367 "<imageobject> <imagedata width=\"100%\" fileref=\"figs/kdiff3.png\"/></"
5368 "imageobject>"
5369 msgstr ""
5371 #. type: Content of: <book><chapter><sect1><sect2><para>
5372 #: ../en/ch03-tour-merge.xml:284
5373 msgid ""
5374 "For each conflicting portion of the file, we can choose to resolve the "
5375 "conflict using some combination of text from the base version, ours, or "
5376 "theirs. We can also manually edit the merged file at any time, in case we "
5377 "need to make further modifications."
5378 msgstr ""
5380 #. type: Content of: <book><chapter><sect1><sect2><para>
5381 #: ../en/ch03-tour-merge.xml:290
5382 msgid ""
5383 "There are <emphasis>many</emphasis> file merging tools available, too many to "
5384 "cover here. They vary in which platforms they are available for, and in "
5385 "their particular strengths and weaknesses. Most are tuned for merging files "
5386 "containing plain text, while a few are aimed at specialised file formats "
5387 "(generally XML)."
5388 msgstr ""
5390 #. type: Content of: <book><chapter><sect1><sect2><title>
5391 #: ../en/ch03-tour-merge.xml:299
5392 msgid "A worked example"
5393 msgstr "合并实例"
5395 #. type: Content of: <book><chapter><sect1><sect2><para>
5396 #: ../en/ch03-tour-merge.xml:301
5397 msgid ""
5398 "In this example, we will reproduce the file modification history of <xref "
5399 "linkend=\"fig:tour-merge:conflict\"/> above. Let's begin by creating a "
5400 "repository with a base version of our document."
5401 msgstr ""
5403 #. type: Content of: <book><chapter><sect1><sect2><para>
5404 #: ../en/ch03-tour-merge.xml:308
5405 msgid "We'll clone the repository and make a change to the file."
5406 msgstr ""
5408 #. type: Content of: <book><chapter><sect1><sect2><para>
5409 #: ../en/ch03-tour-merge.xml:313
5410 msgid ""
5411 "And another clone, to simulate someone else making a change to the file. "
5412 "(This hints at the idea that it's not all that unusual to merge with yourself "
5413 "when you isolate tasks in separate repositories, and indeed to find and "
5414 "resolve conflicts while doing so.)"
5415 msgstr ""
5417 #. type: Content of: <book><chapter><sect1><sect2><para>
5418 #: ../en/ch03-tour-merge.xml:321
5419 msgid ""
5420 "Having created two different versions of the file, we'll set up an "
5421 "environment suitable for running our merge."
5422 msgstr ""
5424 #. type: Content of: <book><chapter><sect1><sect2><para>
5425 #: ../en/ch03-tour-merge.xml:327
5426 msgid ""
5427 "In this example, I'll set <envar>HGMERGE</envar> to tell Mercurial to use the "
5428 "non-interactive <command>merge</command> command. This is bundled with many "
5429 "Unix-like systems. (If you're following this example on your computer, don't "
5430 "bother setting <envar>HGMERGE</envar>. You'll get dropped into a GUI file "
5431 "merge tool instead, which is much preferable.)"
5432 msgstr ""
5434 #. type: Content of: <book><chapter><sect1><sect2><para>
5435 #: ../en/ch03-tour-merge.xml:337
5436 msgid ""
5437 "Because <command>merge</command> can't resolve the conflicting changes, it "
5438 "leaves <emphasis>merge markers</emphasis> inside the file that has conflicts, "
5439 "indicating which lines have conflicts, and whether they came from our version "
5440 "of the file or theirs."
5441 msgstr ""
5443 #. type: Content of: <book><chapter><sect1><sect2><para>
5444 #: ../en/ch03-tour-merge.xml:343
5445 msgid ""
5446 "Mercurial can tell from the way <command>merge</command> exits that it wasn't "
5447 "able to merge successfully, so it tells us what commands we'll need to run if "
5448 "we want to redo the merging operation. This could be useful if, for example, "
5449 "we were running a graphical merge tool and quit because we were confused or "
5450 "realised we had made a mistake."
5451 msgstr ""
5453 #. type: Content of: <book><chapter><sect1><sect2><para>
5454 #: ../en/ch03-tour-merge.xml:350
5455 msgid ""
5456 "If automatic or manual merges fail, there's nothing to prevent us from "
5457 "<quote>fixing up</quote> the affected files ourselves, and committing the "
5458 "results of our merge:"
5459 msgstr ""
5461 #. type: Content of: <book><chapter><sect1><sect2><note><title>
5462 #: ../en/ch03-tour-merge.xml:357
5463 msgid "Where is the <command>hg resolve</command> command?"
5464 msgstr "在哪里能找到 <command role=\"hg-cmd\">hg resolve</command> 命令?"
5466 #. type: Content of: <book><chapter><sect1><sect2><note><para>
5467 #: ../en/ch03-tour-merge.xml:359
5468 msgid ""
5469 "The <command>hg resolve</command> command was introduced in Mercurial 1.1, "
5470 "which was released in December 2008. If you are using an older version of "
5471 "Mercurial (run <command>hg version</command> to see), this command will not "
5472 "be present. If your version of Mercurial is older than 1.1, you should "
5473 "strongly consider upgrading to a newer version before trying to tackle "
5474 "complicated merges."
5475 msgstr ""
5477 #. type: Content of: <book><chapter><sect1><title>
5478 #: ../en/ch03-tour-merge.xml:371
5479 msgid "Simplifying the pull-merge-commit sequence"
5480 msgstr "简化拉-合并-提交程序"
5482 #. type: Content of: <book><chapter><sect1><para>
5483 #: ../en/ch03-tour-merge.xml:373
5484 msgid ""
5485 "The process of merging changes as outlined above is straightforward, but "
5486 "requires running three commands in sequence."
5487 msgstr ""
5489 #. type: Content of: <book><chapter><sect1><para>
5490 #: ../en/ch03-tour-merge.xml:379
5491 msgid ""
5492 "In the case of the final commit, you also need to enter a commit message, "
5493 "which is almost always going to be a piece of uninteresting "
5494 "<quote>boilerplate</quote> text."
5495 msgstr ""
5497 #. type: Content of: <book><chapter><sect1><para>
5498 #: ../en/ch03-tour-merge.xml:383
5499 msgid ""
5500 "It would be nice to reduce the number of steps needed, if this were "
5501 "possible. Indeed, Mercurial is distributed with an extension called <literal "
5502 "role=\"hg-ext\">fetch</literal> that does just this."
5503 msgstr ""
5505 #. type: Content of: <book><chapter><sect1><para>
5506 #: ../en/ch03-tour-merge.xml:388
5507 msgid ""
5508 "Mercurial provides a flexible extension mechanism that lets people extend its "
5509 "functionality, while keeping the core of Mercurial small and easy to deal "
5510 "with. Some extensions add new commands that you can use from the command "
5511 "line, while others work <quote>behind the scenes,</quote> for example adding "
5512 "capabilities to Mercurial's built-in server mode."
5513 msgstr ""
5515 #. type: Content of: <book><chapter><sect1><para>
5516 #: ../en/ch03-tour-merge.xml:395
5517 msgid ""
5518 "The <literal role=\"hg-ext\">fetch</literal> extension adds a new command "
5519 "called, not surprisingly, <command role=\"hg-cmd\">hg fetch</command>. This "
5520 "extension acts as a combination of <command role=\"hg-cmd\">hg pull -u</"
5521 "command>, <command role=\"hg-cmd\">hg merge</command> and <command role=\"hg-"
5522 "cmd\">hg commit</command>. It begins by pulling changes from another "
5523 "repository into the current repository. If it finds that the changes added a "
5524 "new head to the repository, it updates to the new head, begins a merge, then "
5525 "(if the merge succeeded) commits the result of the merge with an "
5526 "automatically-generated commit message. If no new heads were added, it "
5527 "updates the working directory to the new tip changeset."
5528 msgstr ""
5530 #. type: Content of: <book><chapter><sect1><para>
5531 #: ../en/ch03-tour-merge.xml:409
5532 msgid ""
5533 "Enabling the <literal role=\"hg-ext\">fetch</literal> extension is easy. "
5534 "Edit the <filename role=\"special\">.hgrc</filename> file in your home "
5535 "directory, and either go to the <literal role=\"rc-extensions\">extensions</"
5536 "literal> section or create an <literal role=\"rc-extensions\">extensions</"
5537 "literal> section. Then add a line that simply reads <quote><literal>fetch=</"
5538 "literal></quote>."
5539 msgstr ""
5541 #. type: Content of: <book><chapter><sect1><para>
5542 #: ../en/ch03-tour-merge.xml:421
5543 msgid ""
5544 "(Normally, the right-hand side of the <quote><literal>=</literal></quote> "
5545 "would indicate where to find the extension, but since the <literal role=\"hg-"
5546 "ext\">fetch</literal> extension is in the standard distribution, Mercurial "
5547 "knows where to search for it.)"
5548 msgstr ""
5550 #. type: Content of: <book><chapter><sect1><title>
5551 #: ../en/ch03-tour-merge.xml:429
5552 msgid "Renaming, copying, and merging"
5553 msgstr "改名,复制与合并"
5555 #. type: Content of: <book><chapter><sect1><para>
5556 #: ../en/ch03-tour-merge.xml:431
5557 msgid ""
5558 "During the life of a project, we will often want to change the layout of its "
5559 "files and directories. This can be as simple as renaming a single file, or as "
5560 "complex as restructuring the entire hierarchy of files within the project."
5561 msgstr ""
5563 #. type: Content of: <book><chapter><sect1><para>
5564 #: ../en/ch03-tour-merge.xml:436
5565 msgid ""
5566 "Mercurial supports these kinds of complex changes fluently, provided we tell "
5567 "it what we're doing. If we want to rename a file, we should use the "
5568 "<command>hg rename</command><placeholder type=\"footnote\" id=\"0\"/> command "
5569 "to rename it, so that Mercurial can do the right thing later when we merge."
5570 msgstr ""
5572 #. type: Content of: <book><chapter><sect1><para><footnote><para>
5573 #: ../en/ch03-tour-merge.xml:439
5574 msgid ""
5575 "If you're a Unix user, you'll be glad to know that the <command>hg rename</"
5576 "command> command can be abbreviated as <command>hg mv</command>."
5577 msgstr ""
5579 #. type: Content of: <book><chapter><sect1><para>
5580 #: ../en/ch03-tour-merge.xml:445
5581 msgid ""
5582 "We will cover the use of these commands in more detail in <xref linkend="
5583 "\"chap:daily.copy\"/>."
5584 msgstr ""
5586 #. type: Content of: <book><chapter><title>
5587 #: ../en/ch04-concepts.xml:5
5588 msgid "Behind the scenes"
5589 msgstr "Mercurial 内幕"
5591 #. type: Content of: <book><chapter><para>
5592 #: ../en/ch04-concepts.xml:7
5593 msgid ""
5594 "Unlike many revision control systems, the concepts upon which Mercurial is "
5595 "built are simple enough that it's easy to understand how the software really "
5596 "works. Knowing these details certainly isn't necessary, so it is certainly "
5597 "safe to skip this chapter. However, I think you will get more out of the "
5598 "software with a <quote>mental model</quote> of what's going on."
5599 msgstr ""
5601 #. type: Content of: <book><chapter><para>
5602 #: ../en/ch04-concepts.xml:14
5603 msgid ""
5604 "Being able to understand what's going on behind the scenes gives me "
5605 "confidence that Mercurial has been carefully designed to be both "
5606 "<emphasis>safe</emphasis> and <emphasis>efficient</emphasis>. And just as "
5607 "importantly, if it's easy for me to retain a good idea of what the software "
5608 "is doing when I perform a revision control task, I'm less likely to be "
5609 "surprised by its behavior."
5610 msgstr ""
5612 #. type: Content of: <book><chapter><para>
5613 #: ../en/ch04-concepts.xml:22
5614 msgid ""
5615 "In this chapter, we'll initially cover the core concepts behind Mercurial's "
5616 "design, then continue to discuss some of the interesting details of its "
5617 "implementation."
5618 msgstr ""
5620 #. type: Content of: <book><chapter><sect1><title>
5621 #: ../en/ch04-concepts.xml:27
5622 msgid "Mercurial's historical record"
5623 msgstr "Mercurial 的历史记录"
5625 #. type: Content of: <book><chapter><sect1><sect2><title>
5626 #: ../en/ch04-concepts.xml:30
5627 msgid "Tracking the history of a single file"
5628 msgstr "跟踪单一文件的历史"
5630 #. type: Content of: <book><chapter><sect1><sect2><para>
5631 #: ../en/ch04-concepts.xml:32
5632 msgid ""
5633 "When Mercurial tracks modifications to a file, it stores the history of that "
5634 "file in a metadata object called a <emphasis>filelog</emphasis>. Each entry "
5635 "in the filelog contains enough information to reconstruct one revision of the "
5636 "file that is being tracked. Filelogs are stored as files in the <filename "
5637 "role=\"special\" class=\"directory\">.hg/store/data</filename> directory. A "
5638 "filelog contains two kinds of information: revision data, and an index to "
5639 "help Mercurial to find a revision efficiently."
5640 msgstr ""
5642 #. type: Content of: <book><chapter><sect1><sect2><para>
5643 #: ../en/ch04-concepts.xml:43
5644 msgid ""
5645 "A file that is large, or has a lot of history, has its filelog stored in "
5646 "separate data (<quote><literal>.d</literal></quote> suffix) and index "
5647 "(<quote><literal>.i</literal></quote> suffix) files. For small files without "
5648 "much history, the revision data and index are combined in a single "
5649 "<quote><literal>.i</literal></quote> file. The correspondence between a file "
5650 "in the working directory and the filelog that tracks its history in the "
5651 "repository is illustrated in <xref linkend=\"fig:concepts:filelog\"/>."
5652 msgstr ""
5654 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
5655 #: ../en/ch04-concepts.xml:55
5656 msgid ""
5657 "Relationships between files in working directory and filelogs in repository"
5658 msgstr "工作目录中的文件与版本库中的文件日志之间的关系"
5660 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
5661 #: ../en/ch04-concepts.xml:58
5662 msgid "<imageobject><imagedata fileref=\"figs/filelog.png\"/></imageobject>"
5663 msgstr ""
5665 #. type: Content of: <book><chapter><sect1><sect2><title>
5666 #: ../en/ch04-concepts.xml:65
5667 msgid "Managing tracked files"
5668 msgstr "管理跟踪的文件"
5670 #. type: Content of: <book><chapter><sect1><sect2><para>
5671 #: ../en/ch04-concepts.xml:67
5672 msgid ""
5673 "Mercurial uses a structure called a <emphasis>manifest</emphasis> to collect "
5674 "together information about the files that it tracks. Each entry in the "
5675 "manifest contains information about the files present in a single changeset. "
5676 "An entry records which files are present in the changeset, the revision of "
5677 "each file, and a few other pieces of file metadata."
5678 msgstr ""
5680 #. type: Content of: <book><chapter><sect1><sect2><title>
5681 #: ../en/ch04-concepts.xml:77
5682 msgid "Recording changeset information"
5683 msgstr "记录修改集信息"
5685 #. type: Content of: <book><chapter><sect1><sect2><para>
5686 #: ../en/ch04-concepts.xml:79
5687 msgid ""
5688 "The <emphasis>changelog</emphasis> contains information about each "
5689 "changeset. Each revision records who committed a change, the changeset "
5690 "comment, other pieces of changeset-related information, and the revision of "
5691 "the manifest to use."
5692 msgstr ""
5694 #. type: Content of: <book><chapter><sect1><sect2><title>
5695 #: ../en/ch04-concepts.xml:87
5696 msgid "Relationships between revisions"
5697 msgstr "版本之间的关系"
5699 #. type: Content of: <book><chapter><sect1><sect2><para>
5700 #: ../en/ch04-concepts.xml:89
5701 msgid ""
5702 "Within a changelog, a manifest, or a filelog, each revision stores a pointer "
5703 "to its immediate parent (or to its two parents, if it's a merge revision). "
5704 "As I mentioned above, there are also relationships between revisions "
5705 "<emphasis>across</emphasis> these structures, and they are hierarchical in "
5706 "nature."
5707 msgstr ""
5709 #. type: Content of: <book><chapter><sect1><sect2><para>
5710 #: ../en/ch04-concepts.xml:96
5711 msgid ""
5712 "For every changeset in a repository, there is exactly one revision stored in "
5713 "the changelog. Each revision of the changelog contains a pointer to a single "
5714 "revision of the manifest. A revision of the manifest stores a pointer to a "
5715 "single revision of each filelog tracked when that changeset was created. "
5716 "These relationships are illustrated in <xref linkend=\"fig:concepts:metadata"
5717 "\"/>."
5718 msgstr ""
5720 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
5721 #: ../en/ch04-concepts.xml:105
5722 msgid "Metadata relationships"
5723 msgstr "元数据之间的关系"
5725 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
5726 #: ../en/ch04-concepts.xml:107
5727 msgid "<imageobject><imagedata fileref=\"figs/metadata.png\"/></imageobject>"
5728 msgstr ""
5730 #. type: Content of: <book><chapter><sect1><sect2><para>
5731 #: ../en/ch04-concepts.xml:112
5732 msgid ""
5733 "As the illustration shows, there is <emphasis>not</emphasis> a <quote>one to "
5734 "one</quote> relationship between revisions in the changelog, manifest, or "
5735 "filelog. If a file that Mercurial tracks hasn't changed between two "
5736 "changesets, the entry for that file in the two revisions of the manifest will "
5737 "point to the same revision of its filelog<placeholder type=\"footnote\" id=\"0"
5738 "\"/>."
5739 msgstr ""
5741 #. type: Content of: <book><chapter><sect1><sect2><para><footnote><para>
5742 #: ../en/ch04-concepts.xml:119
5743 msgid ""
5744 "It is possible (though unusual) for the manifest to remain the same between "
5745 "two changesets, in which case the changelog entries for those changesets will "
5746 "point to the same revision of the manifest."
5747 msgstr ""
5749 #. type: Content of: <book><chapter><sect1><title>
5750 #: ../en/ch04-concepts.xml:128
5751 msgid "Safe, efficient storage"
5752 msgstr "安全,高效的存储"
5754 #. type: Content of: <book><chapter><sect1><para>
5755 #: ../en/ch04-concepts.xml:130
5756 msgid ""
5757 "The underpinnings of changelogs, manifests, and filelogs are provided by a "
5758 "single structure called the <emphasis>revlog</emphasis>."
5759 msgstr ""
5761 #. type: Content of: <book><chapter><sect1><sect2><title>
5762 #: ../en/ch04-concepts.xml:135
5763 msgid "Efficient storage"
5764 msgstr "高效存储"
5766 #. type: Content of: <book><chapter><sect1><sect2><para>
5767 #: ../en/ch04-concepts.xml:137
5768 msgid ""
5769 "The revlog provides efficient storage of revisions using a <emphasis>delta</"
5770 "emphasis> mechanism. Instead of storing a complete copy of a file for each "
5771 "revision, it stores the changes needed to transform an older revision into "
5772 "the new revision. For many kinds of file data, these deltas are typically a "
5773 "fraction of a percent of the size of a full copy of a file."
5774 msgstr ""
5776 #. type: Content of: <book><chapter><sect1><sect2><para>
5777 #: ../en/ch04-concepts.xml:145
5778 msgid ""
5779 "Some obsolete revision control systems can only work with deltas of text "
5780 "files. They must either store binary files as complete snapshots or encoded "
5781 "into a text representation, both of which are wasteful approaches. Mercurial "
5782 "can efficiently handle deltas of files with arbitrary binary contents; it "
5783 "doesn't need to treat text as special."
5784 msgstr ""
5786 #. type: Content of: <book><chapter><sect1><sect2><title>
5787 #: ../en/ch04-concepts.xml:154
5788 msgid "Safe operation"
5789 msgstr "安全操作"
5791 #. type: Content of: <book><chapter><sect1><sect2><para>
5792 #: ../en/ch04-concepts.xml:156
5793 msgid ""
5794 "Mercurial only ever <emphasis>appends</emphasis> data to the end of a revlog "
5795 "file. It never modifies a section of a file after it has written it. This is "
5796 "both more robust and efficient than schemes that need to modify or rewrite "
5797 "data."
5798 msgstr ""
5800 #. type: Content of: <book><chapter><sect1><sect2><para>
5801 #: ../en/ch04-concepts.xml:162
5802 msgid ""
5803 "In addition, Mercurial treats every write as part of a <emphasis>transaction</"
5804 "emphasis> that can span a number of files. A transaction is "
5805 "<emphasis>atomic</emphasis>: either the entire transaction succeeds and its "
5806 "effects are all visible to readers in one go, or the whole thing is undone. "
5807 "This guarantee of atomicity means that if you're running two copies of "
5808 "Mercurial, where one is reading data and one is writing it, the reader will "
5809 "never see a partially written result that might confuse it."
5810 msgstr ""
5812 #. type: Content of: <book><chapter><sect1><sect2><para>
5813 #: ../en/ch04-concepts.xml:172
5814 msgid ""
5815 "The fact that Mercurial only appends to files makes it easier to provide this "
5816 "transactional guarantee. The easier it is to do stuff like this, the more "
5817 "confident you should be that it's done correctly."
5818 msgstr ""
5820 #. type: Content of: <book><chapter><sect1><sect2><title>
5821 #: ../en/ch04-concepts.xml:179
5822 msgid "Fast retrieval"
5823 msgstr "快速检索"
5825 #. type: Content of: <book><chapter><sect1><sect2><para>
5826 #: ../en/ch04-concepts.xml:181
5827 msgid ""
5828 "Mercurial cleverly avoids a pitfall common to all earlier revision control "
5829 "systems: the problem of <emphasis>inefficient retrieval</emphasis>. Most "
5830 "revision control systems store the contents of a revision as an incremental "
5831 "series of modifications against a <quote>snapshot</quote>. (Some base the "
5832 "snapshot on the oldest revision, others on the newest.) To reconstruct a "
5833 "specific revision, you must first read the snapshot, and then every one of "
5834 "the revisions between the snapshot and your target revision. The more "
5835 "history that a file accumulates, the more revisions you must read, hence the "
5836 "longer it takes to reconstruct a particular revision."
5837 msgstr ""
5839 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
5840 #: ../en/ch04-concepts.xml:195
5841 msgid "Snapshot of a revlog, with incremental deltas"
5842 msgstr "版本日志的快照,以及增量差异"
5844 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
5845 #: ../en/ch04-concepts.xml:197
5846 msgid "<imageobject><imagedata fileref=\"figs/snapshot.png\"/></imageobject>"
5847 msgstr ""
5849 #. type: Content of: <book><chapter><sect1><sect2><para>
5850 #: ../en/ch04-concepts.xml:202
5851 msgid ""
5852 "The innovation that Mercurial applies to this problem is simple but "
5853 "effective. Once the cumulative amount of delta information stored since the "
5854 "last snapshot exceeds a fixed threshold, it stores a new snapshot "
5855 "(compressed, of course), instead of another delta. This makes it possible to "
5856 "reconstruct <emphasis>any</emphasis> revision of a file quickly. This "
5857 "approach works so well that it has since been copied by several other "
5858 "revision control systems."
5859 msgstr ""
5861 #. type: Content of: <book><chapter><sect1><sect2><para>
5862 #: ../en/ch04-concepts.xml:211
5863 msgid ""
5864 "<xref linkend=\"fig:concepts:snapshot\"/> illustrates the idea. In an entry "
5865 "in a revlog's index file, Mercurial stores the range of entries from the data "
5866 "file that it must read to reconstruct a particular revision."
5867 msgstr ""
5869 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
5870 #: ../en/ch04-concepts.xml:217
5871 msgid "Aside: the influence of video compression"
5872 msgstr "旁白: 视频压缩的影响"
5874 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
5875 #: ../en/ch04-concepts.xml:219
5876 msgid ""
5877 "If you're familiar with video compression or have ever watched a TV feed "
5878 "through a digital cable or satellite service, you may know that most video "
5879 "compression schemes store each frame of video as a delta against its "
5880 "predecessor frame."
5881 msgstr ""
5883 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
5884 #: ../en/ch04-concepts.xml:225
5885 msgid ""
5886 "Mercurial borrows this idea to make it possible to reconstruct a revision "
5887 "from a snapshot and a small number of deltas."
5888 msgstr ""
5890 #. type: Content of: <book><chapter><sect1><sect2><title>
5891 #: ../en/ch04-concepts.xml:232
5892 msgid "Identification and strong integrity"
5893 msgstr "鉴别和强完整性"
5895 #. type: Content of: <book><chapter><sect1><sect2><para>
5896 #: ../en/ch04-concepts.xml:234
5897 msgid ""
5898 "Along with delta or snapshot information, a revlog entry contains a "
5899 "cryptographic hash of the data that it represents. This makes it difficult "
5900 "to forge the contents of a revision, and easy to detect accidental corruption."
5901 msgstr ""
5903 #. type: Content of: <book><chapter><sect1><sect2><para>
5904 #: ../en/ch04-concepts.xml:239
5905 msgid ""
5906 "Hashes provide more than a mere check against corruption; they are used as "
5907 "the identifiers for revisions. The changeset identification hashes that you "
5908 "see as an end user are from revisions of the changelog. Although filelogs "
5909 "and the manifest also use hashes, Mercurial only uses these behind the scenes."
5910 msgstr ""
5912 #. type: Content of: <book><chapter><sect1><sect2><para>
5913 #: ../en/ch04-concepts.xml:246
5914 msgid ""
5915 "Mercurial verifies that hashes are correct when it retrieves file revisions "
5916 "and when it pulls changes from another repository. If it encounters an "
5917 "integrity problem, it will complain and stop whatever it's doing."
5918 msgstr ""
5920 #. type: Content of: <book><chapter><sect1><sect2><para>
5921 #: ../en/ch04-concepts.xml:251
5922 msgid ""
5923 "In addition to the effect it has on retrieval efficiency, Mercurial's use of "
5924 "periodic snapshots makes it more robust against partial data corruption. If "
5925 "a revlog becomes partly corrupted due to a hardware error or system bug, it's "
5926 "often possible to reconstruct some or most revisions from the uncorrupted "
5927 "sections of the revlog, both before and after the corrupted section. This "
5928 "would not be possible with a delta-only storage model."
5929 msgstr ""
5931 #. type: Content of: <book><chapter><sect1><title>
5932 #: ../en/ch04-concepts.xml:263
5933 msgid "Revision history, branching, and merging"
5934 msgstr "修订历史,分支与合并"
5936 #. type: Content of: <book><chapter><sect1><para>
5937 #: ../en/ch04-concepts.xml:265
5938 msgid ""
5939 "Every entry in a Mercurial revlog knows the identity of its immediate "
5940 "ancestor revision, usually referred to as its <emphasis>parent</emphasis>. "
5941 "In fact, a revision contains room for not one parent, but two. Mercurial "
5942 "uses a special hash, called the <quote>null ID</quote>, to represent the idea "
5943 "<quote>there is no parent here</quote>. This hash is simply a string of "
5944 "zeroes."
5945 msgstr ""
5947 #. type: Content of: <book><chapter><sect1><para>
5948 #: ../en/ch04-concepts.xml:273
5949 msgid ""
5950 "In <xref linkend=\"fig:concepts:revlog\"/>, you can see an example of the "
5951 "conceptual structure of a revlog. Filelogs, manifests, and changelogs all "
5952 "have this same structure; they differ only in the kind of data stored in each "
5953 "delta or snapshot."
5954 msgstr ""
5956 #. type: Content of: <book><chapter><sect1><para>
5957 #: ../en/ch04-concepts.xml:279
5958 msgid ""
5959 "The first revision in a revlog (at the bottom of the image) has the null ID "
5960 "in both of its parent slots. For a <quote>normal</quote> revision, its first "
5961 "parent slot contains the ID of its parent revision, and its second contains "
5962 "the null ID, indicating that the revision has only one real parent. Any two "
5963 "revisions that have the same parent ID are branches. A revision that "
5964 "represents a merge between branches has two normal revision IDs in its parent "
5965 "slots."
5966 msgstr ""
5968 #. type: Content of: <book><chapter><sect1><figure><title>
5969 #: ../en/ch04-concepts.xml:289
5970 msgid "The conceptual structure of a revlog"
5971 msgstr "版本日志的设计结构"
5973 #. type: Content of: <book><chapter><sect1><figure><mediaobject>
5974 #: ../en/ch04-concepts.xml:291
5975 msgid "<imageobject><imagedata fileref=\"figs/revlog.png\"/></imageobject>"
5976 msgstr ""
5978 #. type: Content of: <book><chapter><sect1><title>
5979 #: ../en/ch04-concepts.xml:298
5980 msgid "The working directory"
5981 msgstr "工作目录"
5983 #. type: Content of: <book><chapter><sect1><para>
5984 #: ../en/ch04-concepts.xml:300
5985 msgid ""
5986 "In the working directory, Mercurial stores a snapshot of the files from the "
5987 "repository as of a particular changeset."
5988 msgstr ""
5990 #. type: Content of: <book><chapter><sect1><para>
5991 #: ../en/ch04-concepts.xml:303
5992 msgid ""
5993 "The working directory <quote>knows</quote> which changeset it contains. When "
5994 "you update the working directory to contain a particular changeset, Mercurial "
5995 "looks up the appropriate revision of the manifest to find out which files it "
5996 "was tracking at the time that changeset was committed, and which revision of "
5997 "each file was then current. It then recreates a copy of each of those files, "
5998 "with the same contents it had when the changeset was committed."
5999 msgstr ""
6001 #. type: Content of: <book><chapter><sect1><para>
6002 #: ../en/ch04-concepts.xml:312
6003 msgid ""
6004 "The <emphasis>dirstate</emphasis> is a special structure that contains "
6005 "Mercurial's knowledge of the working directory. It is maintained as a file "
6006 "named <filename>.hg/dirstate</filename> inside a repository. The dirstate "
6007 "details which changeset the working directory is updated to, and all of the "
6008 "files that Mercurial is tracking in the working directory. It also lets "
6009 "Mercurial quickly notice changed files, by recording their checkout times and "
6010 "sizes."
6011 msgstr ""
6013 #. type: Content of: <book><chapter><sect1><para>
6014 #: ../en/ch04-concepts.xml:322
6015 msgid ""
6016 "Just as a revision of a revlog has room for two parents, so that it can "
6017 "represent either a normal revision (with one parent) or a merge of two "
6018 "earlier revisions, the dirstate has slots for two parents. When you use the "
6019 "<command role=\"hg-cmd\">hg update</command> command, the changeset that you "
6020 "update to is stored in the <quote>first parent</quote> slot, and the null ID "
6021 "in the second. When you <command role=\"hg-cmd\">hg merge</command> with "
6022 "another changeset, the first parent remains unchanged, and the second parent "
6023 "is filled in with the changeset you're merging with. The <command role=\"hg-"
6024 "cmd\">hg parents</command> command tells you what the parents of the dirstate "
6025 "are."
6026 msgstr ""
6028 #. type: Content of: <book><chapter><sect1><sect2><title>
6029 #: ../en/ch04-concepts.xml:336
6030 msgid "What happens when you commit"
6031 msgstr "当你提交时发生的事情"
6033 #. type: Content of: <book><chapter><sect1><sect2><para>
6034 #: ../en/ch04-concepts.xml:338
6035 msgid ""
6036 "The dirstate stores parent information for more than just book-keeping "
6037 "purposes. Mercurial uses the parents of the dirstate as <emphasis>the "
6038 "parents of a new changeset</emphasis> when you perform a commit."
6039 msgstr ""
6041 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
6042 #: ../en/ch04-concepts.xml:344
6043 msgid "The working directory can have two parents"
6044 msgstr "工作目录可以有两个父亲"
6046 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
6047 #: ../en/ch04-concepts.xml:346
6048 msgid "<imageobject><imagedata fileref=\"figs/wdir.png\"/></imageobject>"
6049 msgstr ""
6051 #. type: Content of: <book><chapter><sect1><sect2><para>
6052 #: ../en/ch04-concepts.xml:351
6053 msgid ""
6054 "<xref linkend=\"fig:concepts:wdir\"/> shows the normal state of the working "
6055 "directory, where it has a single changeset as parent. That changeset is the "
6056 "<emphasis>tip</emphasis>, the newest changeset in the repository that has no "
6057 "children."
6058 msgstr ""
6060 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
6061 #: ../en/ch04-concepts.xml:358
6062 msgid "The working directory gains new parents after a commit"
6063 msgstr "提交之后,工作目录的父亲就改变了"
6065 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
6066 #: ../en/ch04-concepts.xml:361
6067 msgid ""
6068 "<imageobject><imagedata fileref=\"figs/wdir-after-commit.png\"/></imageobject>"
6069 msgstr ""
6071 #. type: Content of: <book><chapter><sect1><sect2><para>
6072 #: ../en/ch04-concepts.xml:366
6073 msgid ""
6074 "It's useful to think of the working directory as <quote>the changeset I'm "
6075 "about to commit</quote>. Any files that you tell Mercurial that you've "
6076 "added, removed, renamed, or copied will be reflected in that changeset, as "
6077 "will modifications to any files that Mercurial is already tracking; the new "
6078 "changeset will have the parents of the working directory as its parents."
6079 msgstr ""
6081 #. type: Content of: <book><chapter><sect1><sect2><para>
6082 #: ../en/ch04-concepts.xml:374
6083 msgid ""
6084 "After a commit, Mercurial will update the parents of the working directory, "
6085 "so that the first parent is the ID of the new changeset, and the second is "
6086 "the null ID. This is shown in <xref linkend=\"fig:concepts:wdir-after-commit"
6087 "\"/>. Mercurial doesn't touch any of the files in the working directory when "
6088 "you commit; it just modifies the dirstate to note its new parents."
6089 msgstr ""
6091 #. type: Content of: <book><chapter><sect1><sect2><title>
6092 #: ../en/ch04-concepts.xml:385
6093 msgid "Creating a new head"
6094 msgstr "创建新顶点"
6096 #. type: Content of: <book><chapter><sect1><sect2><para>
6097 #: ../en/ch04-concepts.xml:387
6098 msgid ""
6099 "It's perfectly normal to update the working directory to a changeset other "
6100 "than the current tip. For example, you might want to know what your project "
6101 "looked like last Tuesday, or you could be looking through changesets to see "
6102 "which one introduced a bug. In cases like this, the natural thing to do is "
6103 "update the working directory to the changeset you're interested in, and then "
6104 "examine the files in the working directory directly to see their contents as "
6105 "they were when you committed that changeset. The effect of this is shown in "
6106 "<xref linkend=\"fig:concepts:wdir-pre-branch\"/>."
6107 msgstr ""
6109 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
6110 #: ../en/ch04-concepts.xml:399
6111 msgid "The working directory, updated to an older changeset"
6112 msgstr "同步到旧修改集的工作目录"
6114 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
6115 #: ../en/ch04-concepts.xml:402
6116 msgid ""
6117 "<imageobject><imagedata fileref=\"figs/wdir-pre-branch.png\"/></imageobject>"
6118 msgstr ""
6120 #. type: Content of: <book><chapter><sect1><sect2><para>
6121 #: ../en/ch04-concepts.xml:407
6122 msgid ""
6123 "Having updated the working directory to an older changeset, what happens if "
6124 "you make some changes, and then commit? Mercurial behaves in the same way as "
6125 "I outlined above. The parents of the working directory become the parents of "
6126 "the new changeset. This new changeset has no children, so it becomes the new "
6127 "tip. And the repository now contains two changesets that have no children; "
6128 "we call these <emphasis>heads</emphasis>. You can see the structure that "
6129 "this creates in <xref linkend=\"fig:concepts:wdir-branch\"/>."
6130 msgstr ""
6132 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
6133 #: ../en/ch04-concepts.xml:419
6134 msgid "After a commit made while synced to an older changeset"
6135 msgstr "对同步到旧修改集的工作目录提交之后"
6137 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
6138 #: ../en/ch04-concepts.xml:422
6139 msgid "<imageobject><imagedata fileref=\"figs/wdir-branch.png\"/></imageobject>"
6140 msgstr ""
6142 #. type: Content of: <book><chapter><sect1><sect2><note><para>
6143 #: ../en/ch04-concepts.xml:428
6144 msgid ""
6145 "If you're new to Mercurial, you should keep in mind a common <quote>error</"
6146 "quote>, which is to use the <command role=\"hg-cmd\">hg pull</command> "
6147 "command without any options. By default, the <command role=\"hg-cmd\">hg "
6148 "pull</command> command <emphasis>does not</emphasis> update the working "
6149 "directory, so you'll bring new changesets into your repository, but the "
6150 "working directory will stay synced at the same changeset as before the pull. "
6151 "If you make some changes and commit afterwards, you'll thus create a new "
6152 "head, because your working directory isn't synced to whatever the current tip "
6153 "is. To combine the operation of a pull, followed by an update, run "
6154 "<command>hg pull -u</command>."
6155 msgstr ""
6157 #. type: Content of: <book><chapter><sect1><sect2><note><para>
6158 #: ../en/ch04-concepts.xml:442
6159 msgid ""
6160 "I put the word <quote>error</quote> in quotes because all that you need to do "
6161 "to rectify the situation where you created a new head by accident is <command "
6162 "role=\"hg-cmd\">hg merge</command>, then <command role=\"hg-cmd\">hg commit</"
6163 "command>. In other words, this almost never has negative consequences; it's "
6164 "just something of a surprise for newcomers. I'll discuss other ways to avoid "
6165 "this behavior, and why Mercurial behaves in this initially surprising way, "
6166 "later on."
6167 msgstr ""
6169 #. type: Content of: <book><chapter><sect1><sect2><title>
6170 #: ../en/ch04-concepts.xml:455
6171 msgid "Merging changes"
6172 msgstr "合并修改"
6174 #. type: Content of: <book><chapter><sect1><sect2><para>
6175 #: ../en/ch04-concepts.xml:457
6176 msgid ""
6177 "When you run the <command role=\"hg-cmd\">hg merge</command> command, "
6178 "Mercurial leaves the first parent of the working directory unchanged, and "
6179 "sets the second parent to the changeset you're merging with, as shown in "
6180 "<xref linkend=\"fig:concepts:wdir-merge\"/>."
6181 msgstr ""
6183 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
6184 #: ../en/ch04-concepts.xml:464
6185 msgid "Merging two heads"
6186 msgstr "合并两个顶点"
6188 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
6189 #: ../en/ch04-concepts.xml:466
6190 msgid ""
6191 "<imageobject> <imagedata fileref=\"figs/wdir-merge.png\"/> </imageobject>"
6192 msgstr ""
6194 #. type: Content of: <book><chapter><sect1><sect2><para>
6195 #: ../en/ch04-concepts.xml:473
6196 msgid ""
6197 "Mercurial also has to modify the working directory, to merge the files "
6198 "managed in the two changesets. Simplified a little, the merging process goes "
6199 "like this, for every file in the manifests of both changesets."
6200 msgstr ""
6202 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6203 #: ../en/ch04-concepts.xml:478
6204 msgid "If neither changeset has modified a file, do nothing with that file."
6205 msgstr ""
6207 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6208 #: ../en/ch04-concepts.xml:481
6209 msgid ""
6210 "If one changeset has modified a file, and the other hasn't, create the "
6211 "modified copy of the file in the working directory."
6212 msgstr ""
6214 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6215 #: ../en/ch04-concepts.xml:485
6216 msgid ""
6217 "If one changeset has removed a file, and the other hasn't (or has also "
6218 "deleted it), delete the file from the working directory."
6219 msgstr ""
6221 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6222 #: ../en/ch04-concepts.xml:489
6223 msgid ""
6224 "If one changeset has removed a file, but the other has modified the file, ask "
6225 "the user what to do: keep the modified file, or remove it?"
6226 msgstr ""
6228 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6229 #: ../en/ch04-concepts.xml:493
6230 msgid ""
6231 "If both changesets have modified a file, invoke an external merge program to "
6232 "choose the new contents for the merged file. This may require input from the "
6233 "user."
6234 msgstr ""
6236 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6237 #: ../en/ch04-concepts.xml:498
6238 msgid ""
6239 "If one changeset has modified a file, and the other has renamed or copied the "
6240 "file, make sure that the changes follow the new name of the file."
6241 msgstr ""
6243 #. type: Content of: <book><chapter><sect1><sect2><para>
6244 #: ../en/ch04-concepts.xml:502
6245 msgid ""
6246 "There are more details&emdash;merging has plenty of corner cases&emdash;but "
6247 "these are the most common choices that are involved in a merge. As you can "
6248 "see, most cases are completely automatic, and indeed most merges finish "
6249 "automatically, without requiring your input to resolve any conflicts."
6250 msgstr ""
6252 #. type: Content of: <book><chapter><sect1><sect2><para>
6253 #: ../en/ch04-concepts.xml:509
6254 msgid ""
6255 "When you're thinking about what happens when you commit after a merge, once "
6256 "again the working directory is <quote>the changeset I'm about to commit</"
6257 "quote>. After the <command role=\"hg-cmd\">hg merge</command> command "
6258 "completes, the working directory has two parents; these will become the "
6259 "parents of the new changeset."
6260 msgstr ""
6262 #. type: Content of: <book><chapter><sect1><sect2><para>
6263 #: ../en/ch04-concepts.xml:516
6264 msgid ""
6265 "Mercurial lets you perform multiple merges, but you must commit the results "
6266 "of each individual merge as you go. This is necessary because Mercurial only "
6267 "tracks two parents for both revisions and the working directory. While it "
6268 "would be technically feasible to merge multiple changesets at once, Mercurial "
6269 "avoids this for simplicity. With multi-way merges, the risks of user "
6270 "confusion, nasty conflict resolution, and making a terrible mess of a merge "
6271 "would grow intolerable."
6272 msgstr ""
6274 #. type: Content of: <book><chapter><sect1><sect2><title>
6275 #: ../en/ch04-concepts.xml:529
6276 msgid "Merging and renames"
6277 msgstr "合并与改名"
6279 #. type: Content of: <book><chapter><sect1><sect2><para>
6280 #: ../en/ch04-concepts.xml:531
6281 msgid ""
6282 "A surprising number of revision control systems pay little or no attention to "
6283 "a file's <emphasis>name</emphasis> over time. For instance, it used to be "
6284 "common that if a file got renamed on one side of a merge, the changes from "
6285 "the other side would be silently dropped."
6286 msgstr ""
6288 #. type: Content of: <book><chapter><sect1><sect2><para>
6289 #: ../en/ch04-concepts.xml:537
6290 msgid ""
6291 "Mercurial records metadata when you tell it to perform a rename or copy. It "
6292 "uses this metadata during a merge to do the right thing in the case of a "
6293 "merge. For instance, if I rename a file, and you edit it without renaming "
6294 "it, when we merge our work the file will be renamed and have your edits "
6295 "applied."
6296 msgstr ""
6298 #. type: Content of: <book><chapter><sect1><title>
6299 #: ../en/ch04-concepts.xml:547
6300 msgid "Other interesting design features"
6301 msgstr "其它有趣的设计特性"
6303 #. type: Content of: <book><chapter><sect1><para>
6304 #: ../en/ch04-concepts.xml:549
6305 msgid ""
6306 "In the sections above, I've tried to highlight some of the most important "
6307 "aspects of Mercurial's design, to illustrate that it pays careful attention "
6308 "to reliability and performance. However, the attention to detail doesn't "
6309 "stop there. There are a number of other aspects of Mercurial's construction "
6310 "that I personally find interesting. I'll detail a few of them here, separate "
6311 "from the <quote>big ticket</quote> items above, so that if you're interested, "
6312 "you can gain a better idea of the amount of thinking that goes into a well-"
6313 "designed system."
6314 msgstr ""
6316 #. type: Content of: <book><chapter><sect1><sect2><title>
6317 #: ../en/ch04-concepts.xml:560
6318 msgid "Clever compression"
6319 msgstr "智能压缩"
6321 #. type: Content of: <book><chapter><sect1><sect2><para>
6322 #: ../en/ch04-concepts.xml:562
6323 msgid ""
6324 "When appropriate, Mercurial will store both snapshots and deltas in "
6325 "compressed form. It does this by always <emphasis>trying to</emphasis> "
6326 "compress a snapshot or delta, but only storing the compressed version if it's "
6327 "smaller than the uncompressed version."
6328 msgstr ""
6330 #. type: Content of: <book><chapter><sect1><sect2><para>
6331 #: ../en/ch04-concepts.xml:568
6332 msgid ""
6333 "This means that Mercurial does <quote>the right thing</quote> when storing a "
6334 "file whose native form is compressed, such as a <literal>zip</literal> "
6335 "archive or a JPEG image. When these types of files are compressed a second "
6336 "time, the resulting file is usually bigger than the once-compressed form, and "
6337 "so Mercurial will store the plain <literal>zip</literal> or JPEG."
6338 msgstr ""
6340 #. type: Content of: <book><chapter><sect1><sect2><para>
6341 #: ../en/ch04-concepts.xml:576
6342 msgid ""
6343 "Deltas between revisions of a compressed file are usually larger than "
6344 "snapshots of the file, and Mercurial again does <quote>the right thing</"
6345 "quote> in these cases. It finds that such a delta exceeds the threshold at "
6346 "which it should store a complete snapshot of the file, so it stores the "
6347 "snapshot, again saving space compared to a naive delta-only approach."
6348 msgstr ""
6350 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
6351 #: ../en/ch04-concepts.xml:585
6352 msgid "Network recompression"
6353 msgstr "网络重新压缩"
6355 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
6356 #: ../en/ch04-concepts.xml:587
6357 msgid ""
6358 "When storing revisions on disk, Mercurial uses the <quote>deflate</quote> "
6359 "compression algorithm (the same one used by the popular <literal>zip</"
6360 "literal> archive format), which balances good speed with a respectable "
6361 "compression ratio. However, when transmitting revision data over a network "
6362 "connection, Mercurial uncompresses the compressed revision data."
6363 msgstr ""
6365 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
6366 #: ../en/ch04-concepts.xml:595
6367 msgid ""
6368 "If the connection is over HTTP, Mercurial recompresses the entire stream of "
6369 "data using a compression algorithm that gives a better compression ratio (the "
6370 "Burrows-Wheeler algorithm from the widely used <literal>bzip2</literal> "
6371 "compression package). This combination of algorithm and compression of the "
6372 "entire stream (instead of a revision at a time) substantially reduces the "
6373 "number of bytes to be transferred, yielding better network performance over "
6374 "most kinds of network."
6375 msgstr ""
6377 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
6378 #: ../en/ch04-concepts.xml:605
6379 msgid ""
6380 "If the connection is over <command>ssh</command>, Mercurial "
6381 "<emphasis>doesn't</emphasis> recompress the stream, because <command>ssh</"
6382 "command> can already do this itself. You can tell Mercurial to always use "
6383 "<command>ssh</command>'s compression feature by editing the <filename>.hgrc</"
6384 "filename> file in your home directory as follows."
6385 msgstr ""
6387 #. type: Content of: <book><chapter><sect1><sect2><title>
6388 #: ../en/ch04-concepts.xml:620
6389 msgid "Read/write ordering and atomicity"
6390 msgstr "读写顺序与原子性"
6392 #. type: Content of: <book><chapter><sect1><sect2><para>
6393 #: ../en/ch04-concepts.xml:622
6394 msgid ""
6395 "Appending to files isn't the whole story when it comes to guaranteeing that a "
6396 "reader won't see a partial write. If you recall <xref linkend=\"fig:concepts:"
6397 "metadata\"/>, revisions in the changelog point to revisions in the manifest, "
6398 "and revisions in the manifest point to revisions in filelogs. This hierarchy "
6399 "is deliberate."
6400 msgstr ""
6402 #. type: Content of: <book><chapter><sect1><sect2><para>
6403 #: ../en/ch04-concepts.xml:629
6404 msgid ""
6405 "A writer starts a transaction by writing filelog and manifest data, and "
6406 "doesn't write any changelog data until those are finished. A reader starts "
6407 "by reading changelog data, then manifest data, followed by filelog data."
6408 msgstr ""
6410 #. type: Content of: <book><chapter><sect1><sect2><para>
6411 #: ../en/ch04-concepts.xml:634
6412 msgid ""
6413 "Since the writer has always finished writing filelog and manifest data before "
6414 "it writes to the changelog, a reader will never read a pointer to a partially "
6415 "written manifest revision from the changelog, and it will never read a "
6416 "pointer to a partially written filelog revision from the manifest."
6417 msgstr ""
6419 #. type: Content of: <book><chapter><sect1><sect2><title>
6420 #: ../en/ch04-concepts.xml:642
6421 msgid "Concurrent access"
6422 msgstr "并发访问"
6424 #. type: Content of: <book><chapter><sect1><sect2><para>
6425 #: ../en/ch04-concepts.xml:644
6426 msgid ""
6427 "The read/write ordering and atomicity guarantees mean that Mercurial never "
6428 "needs to <emphasis>lock</emphasis> a repository when it's reading data, even "
6429 "if the repository is being written to while the read is occurring. This has a "
6430 "big effect on scalability; you can have an arbitrary number of Mercurial "
6431 "processes safely reading data from a repository all at once, no matter "
6432 "whether it's being written to or not."
6433 msgstr ""
6435 #. type: Content of: <book><chapter><sect1><sect2><para>
6436 #: ../en/ch04-concepts.xml:653
6437 msgid ""
6438 "The lockless nature of reading means that if you're sharing a repository on a "
6439 "multi-user system, you don't need to grant other local users permission to "
6440 "<emphasis>write</emphasis> to your repository in order for them to be able to "
6441 "clone it or pull changes from it; they only need <emphasis>read</emphasis> "
6442 "permission. (This is <emphasis>not</emphasis> a common feature among "
6443 "revision control systems, so don't take it for granted! Most require readers "
6444 "to be able to lock a repository to access it safely, and this requires write "
6445 "permission on at least one directory, which of course makes for all kinds of "
6446 "nasty and annoying security and administrative problems.)"
6447 msgstr ""
6449 #. type: Content of: <book><chapter><sect1><sect2><para>
6450 #: ../en/ch04-concepts.xml:666
6451 msgid ""
6452 "Mercurial uses locks to ensure that only one process can write to a "
6453 "repository at a time (the locking mechanism is safe even over filesystems "
6454 "that are notoriously hostile to locking, such as NFS). If a repository is "
6455 "locked, a writer will wait for a while to retry if the repository becomes "
6456 "unlocked, but if the repository remains locked for too long, the process "
6457 "attempting to write will time out after a while. This means that your daily "
6458 "automated scripts won't get stuck forever and pile up if a system crashes "
6459 "unnoticed, for example. (Yes, the timeout is configurable, from zero to "
6460 "infinity.)"
6461 msgstr ""
6463 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
6464 #: ../en/ch04-concepts.xml:678
6465 msgid "Safe dirstate access"
6466 msgstr "安全的目录状态访问"
6468 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
6469 #: ../en/ch04-concepts.xml:680
6470 msgid ""
6471 "As with revision data, Mercurial doesn't take a lock to read the dirstate "
6472 "file; it does acquire a lock to write it. To avoid the possibility of "
6473 "reading a partially written copy of the dirstate file, Mercurial writes to a "
6474 "file with a unique name in the same directory as the dirstate file, then "
6475 "renames the temporary file atomically to <filename>dirstate</filename>. The "
6476 "file named <filename>dirstate</filename> is thus guaranteed to be complete, "
6477 "not partially written."
6478 msgstr ""
6480 #. type: Content of: <book><chapter><sect1><sect2><title>
6481 #: ../en/ch04-concepts.xml:693
6482 msgid "Avoiding seeks"
6483 msgstr "避免查找"
6485 #. type: Content of: <book><chapter><sect1><sect2><para>
6486 #: ../en/ch04-concepts.xml:695
6487 msgid ""
6488 "Critical to Mercurial's performance is the avoidance of seeks of the disk "
6489 "head, since any seek is far more expensive than even a comparatively large "
6490 "read operation."
6491 msgstr ""
6493 #. type: Content of: <book><chapter><sect1><sect2><para>
6494 #: ../en/ch04-concepts.xml:699
6495 msgid ""
6496 "This is why, for example, the dirstate is stored in a single file. If there "
6497 "were a dirstate file per directory that Mercurial tracked, the disk would "
6498 "seek once per directory. Instead, Mercurial reads the entire single dirstate "
6499 "file in one step."
6500 msgstr ""
6502 #. type: Content of: <book><chapter><sect1><sect2><para>
6503 #: ../en/ch04-concepts.xml:705
6504 msgid ""
6505 "Mercurial also uses a <quote>copy on write</quote> scheme when cloning a "
6506 "repository on local storage. Instead of copying every revlog file from the "
6507 "old repository into the new repository, it makes a <quote>hard link</quote>, "
6508 "which is a shorthand way to say <quote>these two names point to the same "
6509 "file</quote>. When Mercurial is about to write to one of a revlog's files, "
6510 "it checks to see if the number of names pointing at the file is greater than "
6511 "one. If it is, more than one repository is using the file, so Mercurial "
6512 "makes a new copy of the file that is private to this repository."
6513 msgstr ""
6515 #. type: Content of: <book><chapter><sect1><sect2><para>
6516 #: ../en/ch04-concepts.xml:716
6517 msgid ""
6518 "A few revision control developers have pointed out that this idea of making a "
6519 "complete private copy of a file is not very efficient in its use of storage. "
6520 "While this is true, storage is cheap, and this method gives the highest "
6521 "performance while deferring most book-keeping to the operating system. An "
6522 "alternative scheme would most likely reduce performance and increase the "
6523 "complexity of the software, but speed and simplicity are key to the "
6524 "<quote>feel</quote> of day-to-day use."
6525 msgstr ""
6527 #. type: Content of: <book><chapter><sect1><sect2><title>
6528 #: ../en/ch04-concepts.xml:728
6529 msgid "Other contents of the dirstate"
6530 msgstr "目录状态的其它内容"
6532 #. type: Content of: <book><chapter><sect1><sect2><para>
6533 #: ../en/ch04-concepts.xml:730
6534 msgid ""
6535 "Because Mercurial doesn't force you to tell it when you're modifying a file, "
6536 "it uses the dirstate to store some extra information so it can determine "
6537 "efficiently whether you have modified a file. For each file in the working "
6538 "directory, it stores the time that it last modified the file itself, and the "
6539 "size of the file at that time."
6540 msgstr ""
6542 #. type: Content of: <book><chapter><sect1><sect2><para>
6543 #: ../en/ch04-concepts.xml:737
6544 msgid ""
6545 "When you explicitly <command role=\"hg-cmd\">hg add</command>, <command role="
6546 "\"hg-cmd\">hg remove</command>, <command role=\"hg-cmd\">hg rename</command> "
6547 "or <command role=\"hg-cmd\">hg copy</command> files, Mercurial updates the "
6548 "dirstate so that it knows what to do with those files when you commit."
6549 msgstr ""
6551 #. type: Content of: <book><chapter><sect1><sect2><para>
6552 #: ../en/ch04-concepts.xml:744
6553 msgid ""
6554 "The dirstate helps Mercurial to efficiently check the status of files in a "
6555 "repository."
6556 msgstr ""
6558 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6559 #: ../en/ch04-concepts.xml:749
6560 msgid ""
6561 "When Mercurial checks the state of a file in the working directory, it first "
6562 "checks a file's modification time against the time in the dirstate that "
6563 "records when Mercurial last wrote the file. If the last modified time is the "
6564 "same as the time when Mercurial wrote the file, the file must not have been "
6565 "modified, so Mercurial does not need to check any further."
6566 msgstr ""
6568 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6569 #: ../en/ch04-concepts.xml:758
6570 msgid ""
6571 "If the file's size has changed, the file must have been modified. If the "
6572 "modification time has changed, but the size has not, only then does Mercurial "
6573 "need to actually read the contents of the file to see if it has changed."
6574 msgstr ""
6576 #. type: Content of: <book><chapter><sect1><sect2><para>
6577 #: ../en/ch04-concepts.xml:766
6578 msgid ""
6579 "Storing the modification time and size dramatically reduces the number of "
6580 "read operations that Mercurial needs to perform when we run commands like "
6581 "<command>hg status</command>. This results in large performance improvements."
6582 msgstr ""
6584 #. type: Content of: <book><chapter><title>
6585 #: ../en/ch05-daily.xml:5
6586 msgid "Mercurial in daily use"
6587 msgstr "Mercurial 的日常使用"
6589 #. type: Content of: <book><chapter><sect1><title>
6590 #: ../en/ch05-daily.xml:8
6591 msgid "Telling Mercurial which files to track"
6592 msgstr "告诉 Mercurial 要跟踪哪些文件"
6594 #. type: Content of: <book><chapter><sect1><para>
6595 #: ../en/ch05-daily.xml:10
6596 msgid ""
6597 "Mercurial does not work with files in your repository unless you tell it to "
6598 "manage them. The <command role=\"hg-cmd\">hg status</command> command will "
6599 "tell you which files Mercurial doesn't know about; it uses a <quote><literal>?"
6600 "</literal></quote> to display such files."
6601 msgstr ""
6604 #. type: Content of: <book><chapter><sect1><para>
6605 #: ../en/ch05-daily.xml:17
6606 msgid ""
6607 "To tell Mercurial to track a file, use the <command role=\"hg-cmd\">hg add</"
6608 "command> command. Once you have added a file, the entry in the output of "
6609 "<command role=\"hg-cmd\">hg status</command> for that file changes from "
6610 "<quote><literal>?</literal></quote> to <quote><literal>A</literal></quote>."
6611 msgstr ""
6613 #. type: Content of: <book><chapter><sect1><para>
6614 #: ../en/ch05-daily.xml:26
6615 msgid ""
6616 "After you run a <command role=\"hg-cmd\">hg commit</command>, the files that "
6617 "you added before the commit will no longer be listed in the output of "
6618 "<command role=\"hg-cmd\">hg status</command>. The reason for this is that by "
6619 "default, <command role=\"hg-cmd\">hg status</command> only tells you about "
6620 "<quote>interesting</quote> files&emdash;those that you have (for example) "
6621 "modified, removed, or renamed. If you have a repository that contains "
6622 "thousands of files, you will rarely want to know about files that Mercurial "
6623 "is tracking, but that have not changed. (You can still get this information; "
6624 "we'll return to this later.)"
6625 msgstr ""
6627 #. type: Content of: <book><chapter><sect1><para>
6628 #: ../en/ch05-daily.xml:38
6629 msgid ""
6630 "Once you add a file, Mercurial doesn't do anything with it immediately. "
6631 "Instead, it will take a snapshot of the file's state the next time you "
6632 "perform a commit. It will then continue to track the changes you make to the "
6633 "file every time you commit, until you remove the file."
6634 msgstr ""
6636 #. type: Content of: <book><chapter><sect1><sect2><title>
6637 #: ../en/ch05-daily.xml:45
6638 msgid "Explicit versus implicit file naming"
6639 msgstr "明确与隐含文件命名"
6641 #. type: Content of: <book><chapter><sect1><sect2><para>
6642 #: ../en/ch05-daily.xml:47
6643 msgid ""
6644 "A useful behavior that Mercurial has is that if you pass the name of a "
6645 "directory to a command, every Mercurial command will treat this as <quote>I "
6646 "want to operate on every file in this directory and its subdirectories</"
6647 "quote>."
6648 msgstr ""
6650 #. type: Content of: <book><chapter><sect1><sect2><para>
6651 #: ../en/ch05-daily.xml:54
6652 msgid ""
6653 "Notice in this example that Mercurial printed the names of the files it "
6654 "added, whereas it didn't do so when we added the file named <filename>myfile."
6655 "txt</filename> in the earlier example."
6656 msgstr ""
6658 #. type: Content of: <book><chapter><sect1><sect2><para>
6659 #: ../en/ch05-daily.xml:59
6660 msgid ""
6661 "What's going on is that in the former case, we explicitly named the file to "
6662 "add on the command line. The assumption that Mercurial makes in such cases "
6663 "is that we know what we are doing, and it doesn't print any output."
6664 msgstr ""
6666 #. type: Content of: <book><chapter><sect1><sect2><para>
6667 #: ../en/ch05-daily.xml:64
6668 msgid ""
6669 "However, when we <emphasis>imply</emphasis> the names of files by giving the "
6670 "name of a directory, Mercurial takes the extra step of printing the name of "
6671 "each file that it does something with. This makes it more clear what is "
6672 "happening, and reduces the likelihood of a silent and nasty surprise. This "
6673 "behavior is common to most Mercurial commands."
6674 msgstr ""
6676 #. type: Content of: <book><chapter><sect1><sect2><title>
6677 #: ../en/ch05-daily.xml:73
6678 msgid "Mercurial tracks files, not directories"
6679 msgstr "Mercurial 只跟踪文件,不跟踪目录"
6681 #. type: Content of: <book><chapter><sect1><sect2><para>
6682 #: ../en/ch05-daily.xml:75
6683 msgid ""
6684 "Mercurial does not track directory information. Instead, it tracks the path "
6685 "to a file. Before creating a file, it first creates any missing directory "
6686 "components of the path. After it deletes a file, it then deletes any empty "
6687 "directories that were in the deleted file's path. This sounds like a trivial "
6688 "distinction, but it has one minor practical consequence: it is not possible "
6689 "to represent a completely empty directory in Mercurial."
6690 msgstr ""
6692 #. type: Content of: <book><chapter><sect1><sect2><para>
6693 #: ../en/ch05-daily.xml:84
6694 msgid ""
6695 "Empty directories are rarely useful, and there are unintrusive workarounds "
6696 "that you can use to achieve an appropriate effect. The developers of "
6697 "Mercurial thus felt that the complexity that would be required to manage "
6698 "empty directories was not worth the limited benefit this feature would bring."
6699 msgstr ""
6701 #. type: Content of: <book><chapter><sect1><sect2><para>
6702 #: ../en/ch05-daily.xml:91
6703 msgid ""
6704 "If you need an empty directory in your repository, there are a few ways to "
6705 "achieve this. One is to create a directory, then <command role=\"hg-cmd\">hg "
6706 "add</command> a <quote>hidden</quote> file to that directory. On Unix-like "
6707 "systems, any file name that begins with a period (<quote><literal>.</"
6708 "literal></quote>) is treated as hidden by most commands and GUI tools. This "
6709 "approach is illustrated below."
6710 msgstr ""
6712 #. type: Content of: <book><chapter><sect1><sect2><para>
6713 #: ../en/ch05-daily.xml:102
6714 msgid ""
6715 "Another way to tackle a need for an empty directory is to simply create one "
6716 "in your automated build scripts before they will need it."
6717 msgstr ""
6719 #. type: Content of: <book><chapter><sect1><title>
6720 #: ../en/ch05-daily.xml:109
6721 msgid "How to stop tracking a file"
6722 msgstr "如何停止跟踪文件"
6724 #. type: Content of: <book><chapter><sect1><para>
6725 #: ../en/ch05-daily.xml:111
6726 msgid ""
6727 "Once you decide that a file no longer belongs in your repository, use the "
6728 "<command role=\"hg-cmd\">hg remove</command> command. This deletes the file, "
6729 "and tells Mercurial to stop tracking it (which will occur at the next "
6730 "commit). A removed file is represented in the output of <command role=\"hg-"
6731 "cmd\">hg status</command> with a <quote><literal>R</literal></quote>."
6732 msgstr ""
6734 #. type: Content of: <book><chapter><sect1><para>
6735 #: ../en/ch05-daily.xml:121
6736 msgid ""
6737 "After you <command role=\"hg-cmd\">hg remove</command> a file, Mercurial will "
6738 "no longer track changes to that file, even if you recreate a file with the "
6739 "same name in your working directory. If you do recreate a file with the same "
6740 "name and want Mercurial to track the new file, simply <command role=\"hg-cmd"
6741 "\">hg add</command> it. Mercurial will know that the newly added file is not "
6742 "related to the old file of the same name."
6743 msgstr ""
6745 #. type: Content of: <book><chapter><sect1><sect2><title>
6746 #: ../en/ch05-daily.xml:130
6747 msgid "Removing a file does not affect its history"
6748 msgstr "删除文件不影响历史"
6750 #. type: Content of: <book><chapter><sect1><sect2><para>
6751 #: ../en/ch05-daily.xml:132
6752 msgid "It is important to understand that removing a file has only two effects."
6753 msgstr ""
6755 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6756 #: ../en/ch05-daily.xml:135
6757 msgid "It removes the current version of the file from the working directory."
6758 msgstr ""
6760 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6761 #: ../en/ch05-daily.xml:138
6762 msgid ""
6763 "It stops Mercurial from tracking changes to the file, from the time of the "
6764 "next commit."
6765 msgstr ""
6767 #. type: Content of: <book><chapter><sect1><sect2><para>
6768 #: ../en/ch05-daily.xml:141
6769 msgid ""
6770 "Removing a file <emphasis>does not</emphasis> in any way alter the "
6771 "<emphasis>history</emphasis> of the file."
6772 msgstr ""
6774 #. type: Content of: <book><chapter><sect1><sect2><para>
6775 #: ../en/ch05-daily.xml:144
6776 msgid ""
6777 "If you update the working directory to a changeset that was committed when it "
6778 "was still tracking a file that you later removed, the file will reappear in "
6779 "the working directory, with the contents it had when you committed that "
6780 "changeset. If you then update the working directory to a later changeset, in "
6781 "which the file had been removed, Mercurial will once again remove the file "
6782 "from the working directory."
6783 msgstr ""
6785 #. type: Content of: <book><chapter><sect1><sect2><title>
6786 #: ../en/ch05-daily.xml:155
6787 msgid "Missing files"
6788 msgstr "丢失的文件"
6790 #. type: Content of: <book><chapter><sect1><sect2><para>
6791 #: ../en/ch05-daily.xml:157
6792 msgid ""
6793 "Mercurial considers a file that you have deleted, but not used <command role="
6794 "\"hg-cmd\">hg remove</command> to delete, to be <emphasis>missing</"
6795 "emphasis>. A missing file is represented with <quote><literal>!</literal></"
6796 "quote> in the output of <command role=\"hg-cmd\">hg status</command>. "
6797 "Mercurial commands will not generally do anything with missing files."
6798 msgstr ""
6800 #. type: Content of: <book><chapter><sect1><sect2><para>
6801 #: ../en/ch05-daily.xml:167
6802 msgid ""
6803 "If your repository contains a file that <command role=\"hg-cmd\">hg status</"
6804 "command> reports as missing, and you want the file to stay gone, you can run "
6805 "<command role=\"hg-cmd\">hg remove <option role=\"hg-opt-remove\">--after</"
6806 "option></command> at any time later on, to tell Mercurial that you really did "
6807 "mean to remove the file."
6808 msgstr ""
6810 #. type: Content of: <book><chapter><sect1><sect2><para>
6811 #: ../en/ch05-daily.xml:177
6812 msgid ""
6813 "On the other hand, if you deleted the missing file by accident, give <command "
6814 "role=\"hg-cmd\">hg revert</command> the name of the file to recover. It will "
6815 "reappear, in unmodified form."
6816 msgstr ""
6818 #. type: Content of: <book><chapter><sect1><sect2><title>
6819 #: ../en/ch05-daily.xml:186
6820 msgid "Aside: why tell Mercurial explicitly to remove a file?"
6821 msgstr "旁白: 为什么要明确告诉 Mercurial 删除文件?"
6823 #. type: Content of: <book><chapter><sect1><sect2><para>
6824 #: ../en/ch05-daily.xml:189
6825 msgid ""
6826 "You might wonder why Mercurial requires you to explicitly tell it that you "
6827 "are deleting a file. Early during the development of Mercurial, it let you "
6828 "delete a file however you pleased; Mercurial would notice the absence of the "
6829 "file automatically when you next ran a <command role=\"hg-cmd\">hg commit</"
6830 "command>, and stop tracking the file. In practice, this made it too easy to "
6831 "accidentally remove a file without noticing."
6832 msgstr ""
6834 #. type: Content of: <book><chapter><sect1><sect2><title>
6835 #: ../en/ch05-daily.xml:200
6836 msgid "Useful shorthand&emdash;adding and removing files in one step"
6837 msgstr "有用的速记—一个步骤添加和删除文件"
6839 #. type: Content of: <book><chapter><sect1><sect2><para>
6840 #: ../en/ch05-daily.xml:203
6841 msgid ""
6842 "Mercurial offers a combination command, <command role=\"hg-cmd\">hg "
6843 "addremove</command>, that adds untracked files and marks missing files as "
6844 "removed."
6845 msgstr ""
6847 #. type: Content of: <book><chapter><sect1><sect2><para>
6848 #: ../en/ch05-daily.xml:209
6849 msgid ""
6850 "The <command role=\"hg-cmd\">hg commit</command> command also provides a "
6851 "<option role=\"hg-opt-commit\">-A</option> option that performs this same add-"
6852 "and-remove, immediately followed by a commit."
6853 msgstr ""
6855 #. type: Content of: <book><chapter><sect1><title>
6856 #: ../en/ch05-daily.xml:219
6857 msgid "Copying files"
6858 msgstr "复制文件"
6860 #. type: Content of: <book><chapter><sect1><para>
6861 #: ../en/ch05-daily.xml:221
6862 msgid ""
6863 "Mercurial provides a <command role=\"hg-cmd\">hg copy</command> command that "
6864 "lets you make a new copy of a file. When you copy a file using this command, "
6865 "Mercurial makes a record of the fact that the new file is a copy of the "
6866 "original file. It treats these copied files specially when you merge your "
6867 "work with someone else's."
6868 msgstr ""
6870 #. type: Content of: <book><chapter><sect1><sect2><title>
6871 #: ../en/ch05-daily.xml:229
6872 msgid "The results of copying during a merge"
6873 msgstr "合并期间的复制结果"
6875 #. type: Content of: <book><chapter><sect1><sect2><para>
6876 #: ../en/ch05-daily.xml:231
6877 msgid ""
6878 "What happens during a merge is that changes <quote>follow</quote> a copy. To "
6879 "best illustrate what this means, let's create an example. We'll start with "
6880 "the usual tiny repository that contains a single file."
6881 msgstr ""
6883 #. type: Content of: <book><chapter><sect1><sect2><para>
6884 #: ../en/ch05-daily.xml:238
6885 msgid ""
6886 "We need to do some work in parallel, so that we'll have something to merge. "
6887 "So let's clone our repository."
6888 msgstr ""
6890 #. type: Content of: <book><chapter><sect1><sect2><para>
6891 #: ../en/ch05-daily.xml:244
6892 msgid ""
6893 "Back in our initial repository, let's use the <command role=\"hg-cmd\">hg "
6894 "copy</command> command to make a copy of the first file we created."
6895 msgstr ""
6897 #. type: Content of: <book><chapter><sect1><sect2><para>
6898 #: ../en/ch05-daily.xml:250
6899 msgid ""
6900 "If we look at the output of the <command role=\"hg-cmd\">hg status</command> "
6901 "command afterwards, the copied file looks just like a normal added file."
6902 msgstr ""
6904 #. type: Content of: <book><chapter><sect1><sect2><para>
6905 #: ../en/ch05-daily.xml:256
6906 msgid ""
6907 "But if we pass the <option role=\"hg-opt-status\">-C</option> option to "
6908 "<command role=\"hg-cmd\">hg status</command>, it prints another line of "
6909 "output: this is the file that our newly-added file was copied <emphasis>from</"
6910 "emphasis>."
6911 msgstr ""
6913 #. type: Content of: <book><chapter><sect1><sect2><para>
6914 #: ../en/ch05-daily.xml:264
6915 msgid ""
6916 "Now, back in the repository we cloned, let's make a change in parallel. "
6917 "We'll add a line of content to the original file that we created."
6918 msgstr ""
6920 #. type: Content of: <book><chapter><sect1><sect2><para>
6921 #: ../en/ch05-daily.xml:270
6922 msgid ""
6923 "Now we have a modified <filename>file</filename> in this repository. When we "
6924 "pull the changes from the first repository, and merge the two heads, "
6925 "Mercurial will propagate the changes that we made locally to <filename>file</"
6926 "filename> into its copy, <filename>new-file</filename>."
6927 msgstr ""
6929 #. type: Content of: <book><chapter><sect1><sect2><title>
6930 #: ../en/ch05-daily.xml:280
6931 msgid "Why should changes follow copies?"
6932 msgstr "为什么复制后需要后续修改?"
6934 #. type: Content of: <book><chapter><sect1><sect2><para>
6935 #: ../en/ch05-daily.xml:282
6936 msgid ""
6937 "This behavior&emdash;of changes to a file propagating out to copies of the "
6938 "file&emdash;might seem esoteric, but in most cases it's highly desirable."
6939 msgstr ""
6941 #. type: Content of: <book><chapter><sect1><sect2><para>
6942 #: ../en/ch05-daily.xml:286
6943 msgid ""
6944 "First of all, remember that this propagation <emphasis>only</emphasis> "
6945 "happens when you merge. So if you <command role=\"hg-cmd\">hg copy</command> "
6946 "a file, and subsequently modify the original file during the normal course of "
6947 "your work, nothing will happen."
6948 msgstr ""
6950 #. type: Content of: <book><chapter><sect1><sect2><para>
6951 #: ../en/ch05-daily.xml:292
6952 msgid ""
6953 "The second thing to know is that modifications will only propagate across a "
6954 "copy as long as the changeset that you're merging changes from "
6955 "<emphasis>hasn't yet seen</emphasis> the copy."
6956 msgstr ""
6958 #. type: Content of: <book><chapter><sect1><sect2><para>
6959 #: ../en/ch05-daily.xml:297
6960 msgid ""
6961 "The reason that Mercurial does this is as follows. Let's say I make an "
6962 "important bug fix in a source file, and commit my changes. Meanwhile, you've "
6963 "decided to <command role=\"hg-cmd\">hg copy</command> the file in your "
6964 "repository, without knowing about the bug or having seen the fix, and you "
6965 "have started hacking on your copy of the file."
6966 msgstr ""
6968 #. type: Content of: <book><chapter><sect1><sect2><para>
6969 #: ../en/ch05-daily.xml:304
6970 msgid ""
6971 "If you pulled and merged my changes, and Mercurial <emphasis>didn't</"
6972 "emphasis> propagate changes across copies, your new source file would now "
6973 "contain the bug, and unless you knew to propagate the bug fix by hand, the "
6974 "bug would <emphasis>remain</emphasis> in your copy of the file."
6975 msgstr ""
6977 #. type: Content of: <book><chapter><sect1><sect2><para>
6978 #: ../en/ch05-daily.xml:310
6979 msgid ""
6980 "By automatically propagating the change that fixed the bug from the original "
6981 "file to the copy, Mercurial prevents this class of problem. To my knowledge, "
6982 "Mercurial is the <emphasis>only</emphasis> revision control system that "
6983 "propagates changes across copies like this."
6984 msgstr ""
6986 #. type: Content of: <book><chapter><sect1><sect2><para>
6987 #: ../en/ch05-daily.xml:316
6988 msgid ""
6989 "Once your change history has a record that the copy and subsequent merge "
6990 "occurred, there's usually no further need to propagate changes from the "
6991 "original file to the copied file, and that's why Mercurial only propagates "
6992 "changes across copies at the first merge, and not afterwards."
6993 msgstr ""
6995 #. type: Content of: <book><chapter><sect1><sect2><title>
6996 #: ../en/ch05-daily.xml:324
6997 msgid "How to make changes <emphasis>not</emphasis> follow a copy"
6998 msgstr "如何让复制后<emphasis>不</emphasis>修改?"
7000 #. type: Content of: <book><chapter><sect1><sect2><para>
7001 #: ../en/ch05-daily.xml:327
7002 msgid ""
7003 "If, for some reason, you decide that this business of automatically "
7004 "propagating changes across copies is not for you, simply use your system's "
7005 "normal file copy command (on Unix-like systems, that's <command>cp</command>) "
7006 "to make a copy of a file, then <command role=\"hg-cmd\">hg add</command> the "
7007 "new copy by hand. Before you do so, though, please do reread <xref linkend="
7008 "\"sec:daily:why-copy\"/>, and make an informed decision that this behavior is "
7009 "not appropriate to your specific case."
7010 msgstr ""
7012 #. type: Content of: <book><chapter><sect1><sect2><title>
7013 #: ../en/ch05-daily.xml:340
7014 msgid "Behavior of the <command role=\"hg-cmd\">hg copy</command> command"
7015 msgstr "命令 <command role=\"hg-cmd\">hg copy</command> 的特性"
7017 #. type: Content of: <book><chapter><sect1><sect2><para>
7018 #: ../en/ch05-daily.xml:343
7019 msgid ""
7020 "When you use the <command role=\"hg-cmd\">hg copy</command> command, "
7021 "Mercurial makes a copy of each source file as it currently stands in the "
7022 "working directory. This means that if you make some modifications to a file, "
7023 "then <command role=\"hg-cmd\">hg copy</command> it without first having "
7024 "committed those changes, the new copy will also contain the modifications you "
7025 "have made up until that point. (I find this behavior a little "
7026 "counterintuitive, which is why I mention it here.)"
7027 msgstr ""
7029 #. type: Content of: <book><chapter><sect1><sect2><para>
7030 #: ../en/ch05-daily.xml:353
7031 msgid ""
7032 "The <command role=\"hg-cmd\">hg copy</command> command acts similarly to the "
7033 "Unix <command>cp</command> command (you can use the <command role=\"hg-cmd"
7034 "\">hg cp</command> alias if you prefer). We must supply two or more "
7035 "arguments, of which the last is treated as the <emphasis>destination</"
7036 "emphasis>, and all others are <emphasis>sources</emphasis>."
7037 msgstr ""
7039 #. type: Content of: <book><chapter><sect1><sect2><para>
7040 #: ../en/ch05-daily.xml:361
7041 msgid ""
7042 "If you pass <command role=\"hg-cmd\">hg copy</command> a single file as the "
7043 "source, and the destination does not exist, it creates a new file with that "
7044 "name."
7045 msgstr ""
7047 #. type: Content of: <book><chapter><sect1><sect2><para>
7048 #: ../en/ch05-daily.xml:367
7049 msgid ""
7050 "If the destination is a directory, Mercurial copies its sources into that "
7051 "directory."
7052 msgstr ""
7054 #. type: Content of: <book><chapter><sect1><sect2><para>
7055 #: ../en/ch05-daily.xml:372
7056 msgid ""
7057 "Copying a directory is recursive, and preserves the directory structure of "
7058 "the source."
7059 msgstr ""
7061 #. type: Content of: <book><chapter><sect1><sect2><para>
7062 #: ../en/ch05-daily.xml:378
7063 msgid ""
7064 "If the source and destination are both directories, the source tree is "
7065 "recreated in the destination directory."
7066 msgstr ""
7068 #. type: Content of: <book><chapter><sect1><sect2><para>
7069 #: ../en/ch05-daily.xml:383
7070 msgid ""
7071 "As with the <command role=\"hg-cmd\">hg remove</command> command, if you copy "
7072 "a file manually and then want Mercurial to know that you've copied the file, "
7073 "simply use the <option role=\"hg-opt-copy\">--after</option> option to "
7074 "<command role=\"hg-cmd\">hg copy</command>."
7075 msgstr ""
7077 #. type: Content of: <book><chapter><sect1><title>
7078 #: ../en/ch05-daily.xml:394
7079 msgid "Renaming files"
7080 msgstr "改名文件"
7082 #. type: Content of: <book><chapter><sect1><para>
7083 #: ../en/ch05-daily.xml:396
7084 msgid ""
7085 "It's rather more common to need to rename a file than to make a copy of it. "
7086 "The reason I discussed the <command role=\"hg-cmd\">hg copy</command> command "
7087 "before talking about renaming files is that Mercurial treats a rename in "
7088 "essentially the same way as a copy. Therefore, knowing what Mercurial does "
7089 "when you copy a file tells you what to expect when you rename a file."
7090 msgstr ""
7092 #. type: Content of: <book><chapter><sect1><para>
7093 #: ../en/ch05-daily.xml:404
7094 msgid ""
7095 "When you use the <command role=\"hg-cmd\">hg rename</command> command, "
7096 "Mercurial makes a copy of each source file, then deletes it and marks the "
7097 "file as removed."
7098 msgstr ""
7100 #. type: Content of: <book><chapter><sect1><para>
7101 #: ../en/ch05-daily.xml:410
7102 msgid ""
7103 "The <command role=\"hg-cmd\">hg status</command> command shows the newly "
7104 "copied file as added, and the copied-from file as removed."
7105 msgstr ""
7107 #. type: Content of: <book><chapter><sect1><para>
7108 #: ../en/ch05-daily.xml:416
7109 msgid ""
7110 "As with the results of a <command role=\"hg-cmd\">hg copy</command>, we must "
7111 "use the <option role=\"hg-opt-status\">-C</option> option to <command role="
7112 "\"hg-cmd\">hg status</command> to see that the added file is really being "
7113 "tracked by Mercurial as a copy of the original, now removed, file."
7114 msgstr ""
7116 #. type: Content of: <book><chapter><sect1><para>
7117 #: ../en/ch05-daily.xml:425
7118 msgid ""
7119 "As with <command role=\"hg-cmd\">hg remove</command> and <command role=\"hg-"
7120 "cmd\">hg copy</command>, you can tell Mercurial about a rename after the fact "
7121 "using the <option role=\"hg-opt-rename\">--after</option> option. In most "
7122 "other respects, the behavior of the <command role=\"hg-cmd\">hg rename</"
7123 "command> command, and the options it accepts, are similar to the <command "
7124 "role=\"hg-cmd\">hg copy</command> command."
7125 msgstr ""
7127 #. type: Content of: <book><chapter><sect1><para>
7128 #: ../en/ch05-daily.xml:434
7129 msgid ""
7130 "If you're familiar with the Unix command line, you'll be glad to know that "
7131 "<command role=\"hg-cmd\">hg rename</command> command can be invoked as "
7132 "<command role=\"hg-cmd\">hg mv</command>."
7133 msgstr ""
7135 #. type: Content of: <book><chapter><sect1><sect2><title>
7136 #: ../en/ch05-daily.xml:440
7137 msgid "Renaming files and merging changes"
7138 msgstr "改名文件与合并修改"
7140 #. type: Content of: <book><chapter><sect1><sect2><para>
7141 #: ../en/ch05-daily.xml:442
7142 msgid ""
7143 "Since Mercurial's rename is implemented as copy-and-remove, the same "
7144 "propagation of changes happens when you merge after a rename as after a copy."
7145 msgstr ""
7147 #. type: Content of: <book><chapter><sect1><sect2><para>
7148 #: ../en/ch05-daily.xml:446
7149 msgid ""
7150 "If I modify a file, and you rename it to a new name, and then we merge our "
7151 "respective changes, my modifications to the file under its original name will "
7152 "be propagated into the file under its new name. (This is something you might "
7153 "expect to <quote>simply work,</quote> but not all revision control systems "
7154 "actually do this.)"
7155 msgstr ""
7157 #. type: Content of: <book><chapter><sect1><sect2><para>
7158 #: ../en/ch05-daily.xml:453
7159 msgid ""
7160 "Whereas having changes follow a copy is a feature where you can perhaps nod "
7161 "and say <quote>yes, that might be useful,</quote> it should be clear that "
7162 "having them follow a rename is definitely important. Without this facility, "
7163 "it would simply be too easy for changes to become orphaned when files are "
7164 "renamed."
7165 msgstr ""
7167 #. type: Content of: <book><chapter><sect1><sect2><title>
7168 #: ../en/ch05-daily.xml:462
7169 msgid "Divergent renames and merging"
7170 msgstr "改名与合并的分歧"
7172 #. type: Content of: <book><chapter><sect1><sect2><para>
7173 #: ../en/ch05-daily.xml:464
7174 msgid ""
7175 "The case of diverging names occurs when two developers start with a "
7176 "file&emdash;let's call it <filename>foo</filename>&emdash;in their respective "
7177 "repositories."
7178 msgstr ""
7180 #. type: Content of: <book><chapter><sect1><sect2><para>
7181 #: ../en/ch05-daily.xml:471
7182 msgid "Anne renames the file to <filename>bar</filename>."
7183 msgstr ""
7185 #. type: Content of: <book><chapter><sect1><sect2><para>
7186 #: ../en/ch05-daily.xml:475
7187 msgid ""
7188 "Meanwhile, Bob renames it to <filename>quux</filename>. (Remember that "
7189 "<command role=\"hg-cmd\">hg mv</command> is an alias for <command role=\"hg-"
7190 "cmd\">hg rename</command>.)"
7191 msgstr ""
7193 #. type: Content of: <book><chapter><sect1><sect2><para>
7194 #: ../en/ch05-daily.xml:482
7195 msgid ""
7196 "I like to think of this as a conflict because each developer has expressed "
7197 "different intentions about what the file ought to be named."
7198 msgstr ""
7200 #. type: Content of: <book><chapter><sect1><sect2><para>
7201 #: ../en/ch05-daily.xml:486
7202 msgid ""
7203 "What do you think should happen when they merge their work? Mercurial's "
7204 "actual behavior is that it always preserves <emphasis>both</emphasis> names "
7205 "when it merges changesets that contain divergent renames."
7206 msgstr ""
7208 #. type: Content of: <book><chapter><sect1><sect2><para>
7209 #: ../en/ch05-daily.xml:493
7210 msgid ""
7211 "Notice that while Mercurial warns about the divergent renames, it leaves it "
7212 "up to you to do something about the divergence after the merge."
7213 msgstr ""
7215 #. type: Content of: <book><chapter><sect1><sect2><title>
7216 #: ../en/ch05-daily.xml:499
7217 msgid "Convergent renames and merging"
7218 msgstr "收敛改名与合并"
7220 #. type: Content of: <book><chapter><sect1><sect2><para>
7221 #: ../en/ch05-daily.xml:501
7222 msgid ""
7223 "Another kind of rename conflict occurs when two people choose to rename "
7224 "different <emphasis>source</emphasis> files to the same "
7225 "<emphasis>destination</emphasis>. In this case, Mercurial runs its normal "
7226 "merge machinery, and lets you guide it to a suitable resolution."
7227 msgstr ""
7229 #. type: Content of: <book><chapter><sect1><sect2><title>
7230 #: ../en/ch05-daily.xml:509
7231 msgid "Other name-related corner cases"
7232 msgstr "其它名称相关的角落"
7234 #. type: Content of: <book><chapter><sect1><sect2><para>
7235 #: ../en/ch05-daily.xml:511
7236 msgid ""
7237 "Mercurial has a longstanding bug in which it fails to handle a merge where "
7238 "one side has a file with a given name, while another has a directory with the "
7239 "same name. This is documented as <ulink role=\"hg-bug\" url=\"http://www."
7240 "selenic.com/mercurial/bts/issue29\">issue 29</ulink>."
7241 msgstr ""
7243 #. type: Content of: <book><chapter><sect1><title>
7244 #: ../en/ch05-daily.xml:524
7245 msgid "Recovering from mistakes"
7246 msgstr "从错误恢复"
7248 #. type: Content of: <book><chapter><sect1><para>
7249 #: ../en/ch05-daily.xml:526
7250 msgid ""
7251 "Mercurial has some useful commands that will help you to recover from some "
7252 "common mistakes."
7253 msgstr ""
7255 #. type: Content of: <book><chapter><sect1><para>
7256 #: ../en/ch05-daily.xml:529
7257 msgid ""
7258 "The <command role=\"hg-cmd\">hg revert</command> command lets you undo "
7259 "changes that you have made to your working directory. For example, if you "
7260 "<command role=\"hg-cmd\">hg add</command> a file by accident, just run "
7261 "<command role=\"hg-cmd\">hg revert</command> with the name of the file you "
7262 "added, and while the file won't be touched in any way, it won't be tracked "
7263 "for adding by Mercurial any longer, either. You can also use <command role="
7264 "\"hg-cmd\">hg revert</command> to get rid of erroneous changes to a file."
7265 msgstr ""
7267 #. type: Content of: <book><chapter><sect1><para>
7268 #: ../en/ch05-daily.xml:539
7269 msgid ""
7270 "It is helpful to remember that the <command role=\"hg-cmd\">hg revert</"
7271 "command> command is useful for changes that you have not yet committed. Once "
7272 "you've committed a change, if you decide it was a mistake, you can still do "
7273 "something about it, though your options may be more limited."
7274 msgstr ""
7276 #. type: Content of: <book><chapter><sect1><para>
7277 #: ../en/ch05-daily.xml:546
7278 msgid ""
7279 "For more information about the <command role=\"hg-cmd\">hg revert</command> "
7280 "command, and details about how to deal with changes you have already "
7281 "committed, see <xref linkend=\"chap:undo\"/>."
7282 msgstr ""
7284 #. type: Content of: <book><chapter><sect1><title>
7285 #: ../en/ch05-daily.xml:553
7286 msgid "Dealing with tricky merges"
7287 msgstr "合并的技巧"
7289 #. type: Content of: <book><chapter><sect1><para>
7290 #: ../en/ch05-daily.xml:555
7291 msgid ""
7292 "In a complicated or large project, it's not unusual for a merge of two "
7293 "changesets to result in some headaches. Suppose there's a big source file "
7294 "that's been extensively edited by each side of a merge: this is almost "
7295 "inevitably going to result in conflicts, some of which can take a few tries "
7296 "to sort out."
7297 msgstr ""
7299 #. type: Content of: <book><chapter><sect1><para>
7300 #: ../en/ch05-daily.xml:562
7301 msgid ""
7302 "Let's develop a simple case of this and see how to deal with it. We'll start "
7303 "off with a repository containing one file, and clone it twice."
7304 msgstr ""
7306 #. type: Content of: <book><chapter><sect1><para>
7307 #: ../en/ch05-daily.xml:568
7308 msgid "In one clone, we'll modify the file in one way."
7309 msgstr ""
7311 #. type: Content of: <book><chapter><sect1><para>
7312 #: ../en/ch05-daily.xml:572
7313 msgid "In another, we'll modify the file differently."
7314 msgstr ""
7316 #. type: Content of: <book><chapter><sect1><para>
7317 #: ../en/ch05-daily.xml:576
7318 msgid "Next, we'll pull each set of changes into our original repo."
7319 msgstr ""
7321 #. type: Content of: <book><chapter><sect1><para>
7322 #: ../en/ch05-daily.xml:581
7323 msgid "We expect our repository to now contain two heads."
7324 msgstr ""
7326 #. type: Content of: <book><chapter><sect1><para>
7327 #: ../en/ch05-daily.xml:585
7328 msgid ""
7329 "Normally, if we run <command role=\"hg-cmd\">hg merge</command> at this "
7330 "point, it will drop us into a GUI that will let us manually resolve the "
7331 "conflicting edits to <filename>myfile.txt</filename>. However, to simplify "
7332 "things for presentation here, we'd like the merge to fail immediately "
7333 "instead. Here's one way we can do so."
7334 msgstr ""
7336 #. type: Content of: <book><chapter><sect1><para>
7337 #: ../en/ch05-daily.xml:594
7338 msgid ""
7339 "We've told Mercurial's merge machinery to run the command <command>false</"
7340 "command> (which, as we desire, fails immediately) if it detects a merge that "
7341 "it can't sort out automatically."
7342 msgstr ""
7344 #. type: Content of: <book><chapter><sect1><para>
7345 #: ../en/ch05-daily.xml:599
7346 msgid ""
7347 "If we now fire up <command role=\"hg-cmd\">hg merge</command>, it should "
7348 "grind to a halt and report a failure."
7349 msgstr ""
7351 #. type: Content of: <book><chapter><sect1><para>
7352 #: ../en/ch05-daily.xml:605
7353 msgid ""
7354 "Even if we don't notice that the merge failed, Mercurial will prevent us from "
7355 "accidentally committing the result of a failed merge."
7356 msgstr ""
7358 #. type: Content of: <book><chapter><sect1><para>
7359 #: ../en/ch05-daily.xml:611
7360 msgid ""
7361 "When <command role=\"hg-cmd\">hg commit</command> fails in this case, it "
7362 "suggests that we use the unfamiliar <command role=\"hg-cmd\">hg resolve</"
7363 "command> command. As usual, <command role=\"hg-cmd\">hg help resolve</"
7364 "command> will print a helpful synopsis."
7365 msgstr ""
7367 #. type: Content of: <book><chapter><sect1><sect2><title>
7368 #: ../en/ch05-daily.xml:618
7369 msgid "File resolution states"
7370 msgstr "文件的解决状态"
7372 #. type: Content of: <book><chapter><sect1><sect2><para>
7373 #: ../en/ch05-daily.xml:620
7374 msgid ""
7375 "When a merge occurs, most files will usually remain unmodified. For each "
7376 "file where Mercurial has to do something, it tracks the state of the file."
7377 msgstr ""
7379 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
7380 #: ../en/ch05-daily.xml:626
7381 msgid ""
7382 "A <emphasis>resolved</emphasis> file has been successfully merged, either "
7383 "automatically by Mercurial or manually with human intervention."
7384 msgstr ""
7386 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
7387 #: ../en/ch05-daily.xml:631
7388 msgid ""
7389 "An <emphasis>unresolved</emphasis> file was not merged successfully, and "
7390 "needs more attention."
7391 msgstr ""
7393 #. type: Content of: <book><chapter><sect1><sect2><para>
7394 #: ../en/ch05-daily.xml:636
7395 msgid ""
7396 "If Mercurial sees <emphasis>any</emphasis> file in the unresolved state after "
7397 "a merge, it considers the merge to have failed. Fortunately, we do not need "
7398 "to restart the entire merge from scratch."
7399 msgstr ""
7401 #. type: Content of: <book><chapter><sect1><sect2><para>
7402 #: ../en/ch05-daily.xml:641
7403 msgid ""
7404 "The <option role=\"hg-opt-resolve\">--list</option> or <option role=\"hg-opt-"
7405 "resolve\">-l</option> option to <command role=\"hg-cmd\">hg resolve</command> "
7406 "prints out the state of each merged file."
7407 msgstr ""
7409 #. type: Content of: <book><chapter><sect1><sect2><para>
7410 #: ../en/ch05-daily.xml:648
7411 msgid ""
7412 "In the output from <command role=\"hg-cmd\">hg resolve</command>, a resolved "
7413 "file is marked with <literal>R</literal>, while an unresolved file is marked "
7414 "with <literal>U</literal>. If any files are listed with <literal>U</"
7415 "literal>, we know that an attempt to commit the results of the merge will "
7416 "fail."
7417 msgstr ""
7419 #. type: Content of: <book><chapter><sect1><sect2><title>
7420 #: ../en/ch05-daily.xml:657
7421 msgid "Resolving a file merge"
7422 msgstr "合并文件"
7424 #. type: Content of: <book><chapter><sect1><sect2><para>
7425 #: ../en/ch05-daily.xml:659
7426 msgid ""
7427 "We have several options to move a file from the unresolved into the resolved "
7428 "state. By far the most common is to rerun <command role=\"hg-cmd\">hg "
7429 "resolve</command>. If we pass the names of individual files or directories, "
7430 "it will retry the merges of any unresolved files present in those locations. "
7431 "We can also pass the <option role=\"hg-opt-resolve\">--all</option> or "
7432 "<option role=\"hg-opt-resolve\">-a</option> option, which will retry the "
7433 "merges of <emphasis>all</emphasis> unresolved files."
7434 msgstr ""
7436 #. type: Content of: <book><chapter><sect1><sect2><para>
7437 #: ../en/ch05-daily.xml:669
7438 msgid ""
7439 "Mercurial also lets us modify the resolution state of a file directly. We "
7440 "can manually mark a file as resolved using the <option role=\"hg-opt-resolve"
7441 "\">--mark</option> option, or as unresolved using the <option role=\"hg-opt-"
7442 "resolve\">--unmark</option> option. This allows us to clean up a "
7443 "particularly messy merge by hand, and to keep track of our progress with each "
7444 "file as we go."
7445 msgstr ""
7447 #. type: Content of: <book><chapter><sect1><title>
7448 #: ../en/ch05-daily.xml:680
7449 msgid "More useful diffs"
7450 msgstr "更有用的差异"
7452 #. type: Content of: <book><chapter><sect1><para>
7453 #: ../en/ch05-daily.xml:682
7454 msgid ""
7455 "The default output of the <command role=\"hg-cmd\">hg diff</command> command "
7456 "is backwards compatible with the regular <command>diff</command> command, but "
7457 "this has some drawbacks."
7458 msgstr ""
7460 #. type: Content of: <book><chapter><sect1><para>
7461 #: ../en/ch05-daily.xml:687
7462 msgid ""
7463 "Consider the case where we use <command role=\"hg-cmd\">hg rename</command> "
7464 "to rename a file."
7465 msgstr ""
7466 "设想我们使用 <command role=\"hg-cmd\">hg rename</command> 命令来改名文件。"
7468 #. type: Content of: <book><chapter><sect1><para>
7469 #: ../en/ch05-daily.xml:692
7470 msgid ""
7471 "The output of <command role=\"hg-cmd\">hg diff</command> above obscures the "
7472 "fact that we simply renamed a file. The <command role=\"hg-cmd\">hg diff</"
7473 "command> command accepts an option, <option>--git</option> or <option>-g</"
7474 "option>, to use a newer diff format that displays such information in a more "
7475 "readable form."
7476 msgstr ""
7478 #. type: Content of: <book><chapter><sect1><para>
7479 #: ../en/ch05-daily.xml:701
7480 msgid ""
7481 "This option also helps with a case that can otherwise be confusing: a file "
7482 "that appears to be modified according to <command role=\"hg-cmd\">hg status</"
7483 "command>, but for which <command role=\"hg-cmd\">hg diff</command> prints "
7484 "nothing. This situation can arise if we change the file's execute permissions."
7485 msgstr ""
7487 #. type: Content of: <book><chapter><sect1><para>
7488 #: ../en/ch05-daily.xml:710
7489 msgid ""
7490 "The normal <command>diff</command> command pays no attention to file "
7491 "permissions, which is why <command role=\"hg-cmd\">hg diff</command> prints "
7492 "nothing by default. If we supply it with the <option>-g</option> option, it "
7493 "tells us what really happened."
7494 msgstr ""
7496 #. type: Content of: <book><chapter><sect1><title>
7497 #: ../en/ch05-daily.xml:720
7498 msgid "Which files to manage, and which to avoid"
7499 msgstr "需要管理哪些文件,应该避免的事情"
7501 #. type: Content of: <book><chapter><sect1><para>
7502 #: ../en/ch05-daily.xml:722
7503 msgid ""
7504 "Revision control systems are generally best at managing text files that are "
7505 "written by humans, such as source code, where the files do not change much "
7506 "from one revision to the next. Some centralized revision control systems can "
7507 "also deal tolerably well with binary files, such as bitmap images."
7508 msgstr ""
7510 #. type: Content of: <book><chapter><sect1><para>
7511 #: ../en/ch05-daily.xml:728
7512 msgid ""
7513 "For instance, a game development team will typically manage both its source "
7514 "code and all of its binary assets (e.g. geometry data, textures, map layouts) "
7515 "in a revision control system."
7516 msgstr ""
7518 #. type: Content of: <book><chapter><sect1><para>
7519 #: ../en/ch05-daily.xml:733
7520 msgid ""
7521 "Because it is usually impossible to merge two conflicting modifications to a "
7522 "binary file, centralized systems often provide a file locking mechanism that "
7523 "allow a user to say <quote>I am the only person who can edit this file</"
7524 "quote>."
7525 msgstr ""
7527 #. type: Content of: <book><chapter><sect1><para>
7528 #: ../en/ch05-daily.xml:739
7529 msgid ""
7530 "Compared to a centralized system, a distributed revision control system "
7531 "changes some of the factors that guide decisions over which files to manage "
7532 "and how."
7533 msgstr ""
7535 #. type: Content of: <book><chapter><sect1><para>
7536 #: ../en/ch05-daily.xml:743
7537 msgid ""
7538 "For instance, a distributed revision control system cannot, by its nature, "
7539 "offer a file locking facility. There is thus no built-in mechanism to "
7540 "prevent two people from making conflicting changes to a binary file. If you "
7541 "have a team where several people may be editing binary files frequently, it "
7542 "may not be a good idea to use Mercurial&emdash;or any other distributed "
7543 "revision control system&emdash;to manage those files."
7544 msgstr ""
7546 #. type: Content of: <book><chapter><sect1><para>
7547 #: ../en/ch05-daily.xml:751
7548 msgid ""
7549 "When storing modifications to a file, Mercurial usually saves only the "
7550 "differences between the previous and current versions of the file. For most "
7551 "text files, this is extremely efficient. However, some files (particularly "
7552 "binary files) are laid out in such a way that even a small change to a file's "
7553 "logical content results in many or most of the bytes inside the file "
7554 "changing. For instance, compressed files are particularly susceptible to "
7555 "this. If the differences between each successive version of a file are always "
7556 "large, Mercurial will not be able to store the file's revision history very "
7557 "efficiently. This can affect both local storage needs and the amount of time "
7558 "it takes to clone a repository."
7559 msgstr ""
7561 #. type: Content of: <book><chapter><sect1><para>
7562 #: ../en/ch05-daily.xml:764
7563 msgid ""
7564 "To get an idea of how this could affect you in practice, suppose you want to "
7565 "use Mercurial to manage an OpenOffice document. OpenOffice stores documents "
7566 "on disk as compressed zip files. Edit even a single letter of your document "
7567 "in OpenOffice, and almost every byte in the entire file will change when you "
7568 "save it. Now suppose that file is 2MB in size. Because most of the file "
7569 "changes every time you save, Mercurial will have to store all 2MB of the file "
7570 "every time you commit, even though from your perspective, perhaps only a few "
7571 "words are changing each time. A single frequently-edited file that is not "
7572 "friendly to Mercurial's storage assumptions can easily have an outsized "
7573 "effect on the size of the repository."
7574 msgstr ""
7576 #. type: Content of: <book><chapter><sect1><para>
7577 #: ../en/ch05-daily.xml:777
7578 msgid ""
7579 "Even worse, if both you and someone else edit the OpenOffice document you're "
7580 "working on, there is no useful way to merge your work. In fact, there isn't "
7581 "even a good way to tell what the differences are between your respective "
7582 "changes."
7583 msgstr ""
7585 #. type: Content of: <book><chapter><sect1><para>
7586 #: ../en/ch05-daily.xml:782
7587 msgid ""
7588 "There are thus a few clear recommendations about specific kinds of files to "
7589 "be very careful with."
7590 msgstr ""
7592 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
7593 #: ../en/ch05-daily.xml:787
7594 msgid ""
7595 "Files that are very large and incompressible, e.g. ISO CD-ROM images, will by "
7596 "virtue of sheer size make clones over a network very slow."
7597 msgstr ""
7599 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
7600 #: ../en/ch05-daily.xml:792
7601 msgid ""
7602 "Files that change a lot from one revision to the next may be expensive to "
7603 "store if you edit them frequently, and conflicts due to concurrent edits may "
7604 "be difficult to resolve."
7605 msgstr ""
7607 #. type: Content of: <book><chapter><sect1><title>
7608 #: ../en/ch05-daily.xml:801
7609 msgid "Backups and mirroring"
7610 msgstr "备份与镜像"
7612 #. type: Content of: <book><chapter><sect1><para>
7613 #: ../en/ch05-daily.xml:803
7614 msgid ""
7615 "Since Mercurial maintains a complete copy of history in each clone, everyone "
7616 "who uses Mercurial to collaborate on a project can potentially act as a "
7617 "source of backups in the event of a catastrophe. If a central repository "
7618 "becomes unavailable, you can construct a replacement simply by cloning a copy "
7619 "of the repository from one contributor, and pulling any changes they may not "
7620 "have seen from others."
7621 msgstr ""
7623 #. type: Content of: <book><chapter><sect1><para>
7624 #: ../en/ch05-daily.xml:811
7625 msgid ""
7626 "It is simple to use Mercurial to perform off-site backups and remote "
7627 "mirrors. Set up a periodic job (e.g. via the <command>cron</command> "
7628 "command) on a remote server to pull changes from your master repositories "
7629 "every hour. This will only be tricky in the unlikely case that the number of "
7630 "master repositories you maintain changes frequently, in which case you'll "
7631 "need to do a little scripting to refresh the list of repositories to back up."
7632 msgstr ""
7634 #. type: Content of: <book><chapter><sect1><para>
7635 #: ../en/ch05-daily.xml:820
7636 msgid ""
7637 "If you perform traditional backups of your master repositories to tape or "
7638 "disk, and you want to back up a repository named <filename>myrepo</filename>, "
7639 "use <command>hg clone -U myrepo myrepo.bak</command> to create a clone of "
7640 "<filename>myrepo</filename> before you start your backups. The <option>-U</"
7641 "option> option doesn't check out a working directory after the clone "
7642 "completes, since that would be superfluous and make the backup take longer."
7643 msgstr ""
7645 #. type: Content of: <book><chapter><sect1><para>
7646 #: ../en/ch05-daily.xml:829
7647 msgid ""
7648 "If you then back up <filename>myrepo.bak</filename> instead of "
7649 "<filename>myrepo</filename>, you will be guaranteed to have a consistent "
7650 "snapshot of your repository that won't be pushed to by an insomniac developer "
7651 "in mid-backup."
7652 msgstr ""
7654 #. type: Content of: <book><chapter><title>
7655 #: ../en/ch06-collab.xml:5
7656 msgid "Collaborating with other people"
7657 msgstr "团体协作"
7659 #. type: Content of: <book><chapter><para>
7660 #: ../en/ch06-collab.xml:7
7661 msgid ""
7662 "As a completely decentralised tool, Mercurial doesn't impose any policy on "
7663 "how people ought to work with each other. However, if you're new to "
7664 "distributed revision control, it helps to have some tools and examples in "
7665 "mind when you're thinking about possible workflow models."
7666 msgstr ""
7668 #. type: Content of: <book><chapter><sect1><title>
7669 #: ../en/ch06-collab.xml:14
7670 msgid "Mercurial's web interface"
7671 msgstr "Mercurial 的 web 接口"
7673 #. type: Content of: <book><chapter><sect1><para>
7674 #: ../en/ch06-collab.xml:16
7675 msgid ""
7676 "Mercurial has a powerful web interface that provides several useful "
7677 "capabilities."
7678 msgstr ""
7680 #. type: Content of: <book><chapter><sect1><para>
7681 #: ../en/ch06-collab.xml:19
7682 msgid ""
7683 "For interactive use, the web interface lets you browse a single repository or "
7684 "a collection of repositories. You can view the history of a repository, "
7685 "examine each change (comments and diffs), and view the contents of each "
7686 "directory and file. You can even get a view of history that gives a "
7687 "graphical view of the relationships between individual changes and merges."
7688 msgstr ""
7690 #. type: Content of: <book><chapter><sect1><para>
7691 #: ../en/ch06-collab.xml:26
7692 msgid ""
7693 "Also for human consumption, the web interface provides Atom and RSS feeds of "
7694 "the changes in a repository. This lets you <quote>subscribe</quote> to a "
7695 "repository using your favorite feed reader, and be automatically notified of "
7696 "activity in that repository as soon as it happens. I find this capability "
7697 "much more convenient than the model of subscribing to a mailing list to which "
7698 "notifications are sent, as it requires no additional configuration on the "
7699 "part of whoever is serving the repository."
7700 msgstr ""
7702 #. type: Content of: <book><chapter><sect1><para>
7703 #: ../en/ch06-collab.xml:36
7704 msgid ""
7705 "The web interface also lets remote users clone a repository, pull changes "
7706 "from it, and (when the server is configured to permit it) push changes back "
7707 "to it. Mercurial's HTTP tunneling protocol aggressively compresses data, so "
7708 "that it works efficiently even over low-bandwidth network connections."
7709 msgstr ""
7711 #. type: Content of: <book><chapter><sect1><para>
7712 #: ../en/ch06-collab.xml:42
7713 msgid ""
7714 "The easiest way to get started with the web interface is to use your web "
7715 "browser to visit an existing repository, such as the master Mercurial "
7716 "repository at <ulink url=\"http://www.selenic.com/repo/hg\">http://www."
7717 "selenic.com/repo/hg</ulink>."
7718 msgstr ""
7720 #. type: Content of: <book><chapter><sect1><para>
7721 #: ../en/ch06-collab.xml:47
7722 msgid ""
7723 "If you're interested in providing a web interface to your own repositories, "
7724 "there are several good ways to do this."
7725 msgstr ""
7727 #. type: Content of: <book><chapter><sect1><para>
7728 #: ../en/ch06-collab.xml:51
7729 msgid ""
7730 "The easiest and fastest way to get started in an informal environment is to "
7731 "use the <command role=\"hg-cmd\">hg serve</command> command, which is best "
7732 "suited to short-term <quote>lightweight</quote> serving. See <xref linkend="
7733 "\"sec:collab:serve\"/> below for details of how to use this command."
7734 msgstr ""
7736 #. type: Content of: <book><chapter><sect1><para>
7737 #: ../en/ch06-collab.xml:58
7738 msgid ""
7739 "For longer-lived repositories that you'd like to have permanently available, "
7740 "there are several public hosting services available. Some are free to open "
7741 "source projects, while others offer paid commercial hosting. An up-to-date "
7742 "list is available at <ulink url=\"http://www.selenic.com/mercurial/wiki/index."
7743 "cgi/MercurialHosting\">http://www.selenic.com/mercurial/wiki/index.cgi/"
7744 "MercurialHosting</ulink>."
7745 msgstr ""
7747 #. type: Content of: <book><chapter><sect1><para>
7748 #: ../en/ch06-collab.xml:65
7749 msgid ""
7750 "If you would prefer to host your own repositories, Mercurial has built-in "
7751 "support for several popular hosting technologies, most notably CGI (Common "
7752 "Gateway Interface), and WSGI (Web Services Gateway Interface). See <xref "
7753 "linkend=\"sec:collab:cgi\"/> for details of CGI and WSGI configuration."
7754 msgstr ""
7756 #. type: Content of: <book><chapter><sect1><title>
7757 #: ../en/ch06-collab.xml:74
7758 msgid "Collaboration models"
7759 msgstr "协作模型"
7761 #. type: Content of: <book><chapter><sect1><para>
7762 #: ../en/ch06-collab.xml:76
7763 msgid ""
7764 "With a suitably flexible tool, making decisions about workflow is much more "
7765 "of a social engineering challenge than a technical one. Mercurial imposes few "
7766 "limitations on how you can structure the flow of work in a project, so it's "
7767 "up to you and your group to set up and live with a model that matches your "
7768 "own particular needs."
7769 msgstr ""
7771 #. type: Content of: <book><chapter><sect1><sect2><title>
7772 #: ../en/ch06-collab.xml:84
7773 msgid "Factors to keep in mind"
7774 msgstr "要牢记的因素"
7776 #. type: Content of: <book><chapter><sect1><sect2><para>
7777 #: ../en/ch06-collab.xml:86
7778 msgid ""
7779 "The most important aspect of any model that you must keep in mind is how well "
7780 "it matches the needs and capabilities of the people who will be using it. "
7781 "This might seem self-evident; even so, you still can't afford to forget it "
7782 "for a moment."
7783 msgstr ""
7785 #. type: Content of: <book><chapter><sect1><sect2><para>
7786 #: ../en/ch06-collab.xml:92
7787 msgid ""
7788 "I once put together a workflow model that seemed to make perfect sense to me, "
7789 "but that caused a considerable amount of consternation and strife within my "
7790 "development team. In spite of my attempts to explain why we needed a complex "
7791 "set of branches, and how changes ought to flow between them, a few team "
7792 "members revolted. Even though they were smart people, they didn't want to "
7793 "pay attention to the constraints we were operating under, or face the "
7794 "consequences of those constraints in the details of the model that I was "
7795 "advocating."
7796 msgstr ""
7798 #. type: Content of: <book><chapter><sect1><sect2><para>
7799 #: ../en/ch06-collab.xml:102
7800 msgid ""
7801 "Don't sweep foreseeable social or technical problems under the rug. Whatever "
7802 "scheme you put into effect, you should plan for mistakes and problem "
7803 "scenarios. Consider adding automated machinery to prevent, or quickly "
7804 "recover from, trouble that you can anticipate. As an example, if you intend "
7805 "to have a branch with not-for-release changes in it, you'd do well to think "
7806 "early about the possibility that someone might accidentally merge those "
7807 "changes into a release branch. You could avoid this particular problem by "
7808 "writing a hook that prevents changes from being merged from an inappropriate "
7809 "branch."
7810 msgstr ""
7812 #. type: Content of: <book><chapter><sect1><sect2><title>
7813 #: ../en/ch06-collab.xml:116
7814 msgid "Informal anarchy"
7815 msgstr "无政府状态"
7817 #. type: Content of: <book><chapter><sect1><sect2><para>
7818 #: ../en/ch06-collab.xml:118
7819 msgid ""
7820 "I wouldn't suggest an <quote>anything goes</quote> approach as something "
7821 "sustainable, but it's a model that's easy to grasp, and it works perfectly "
7822 "well in a few unusual situations."
7823 msgstr ""
7825 #. type: Content of: <book><chapter><sect1><sect2><para>
7826 #: ../en/ch06-collab.xml:123
7827 msgid ""
7828 "As one example, many projects have a loose-knit group of collaborators who "
7829 "rarely physically meet each other. Some groups like to overcome the "
7830 "isolation of working at a distance by organizing occasional <quote>sprints</"
7831 "quote>. In a sprint, a number of people get together in a single location (a "
7832 "company's conference room, a hotel meeting room, that kind of place) and "
7833 "spend several days more or less locked in there, hacking intensely on a "
7834 "handful of projects."
7835 msgstr ""
7837 #. type: Content of: <book><chapter><sect1><sect2><para>
7838 #: ../en/ch06-collab.xml:132
7839 msgid ""
7840 "A sprint or a hacking session in a coffee shop are the perfect places to use "
7841 "the <command role=\"hg-cmd\">hg serve</command> command, since <command role="
7842 "\"hg-cmd\">hg serve</command> does not require any fancy server "
7843 "infrastructure. You can get started with <command role=\"hg-cmd\">hg serve</"
7844 "command> in moments, by reading <xref linkend=\"sec:collab:serve\"/> below. "
7845 "Then simply tell the person next to you that you're running a server, send "
7846 "the URL to them in an instant message, and you immediately have a quick-"
7847 "turnaround way to work together. They can type your URL into their web "
7848 "browser and quickly review your changes; or they can pull a bugfix from you "
7849 "and verify it; or they can clone a branch containing a new feature and try it "
7850 "out."
7851 msgstr ""
7853 #. type: Content of: <book><chapter><sect1><sect2><para>
7854 #: ../en/ch06-collab.xml:146
7855 msgid ""
7856 "The charm, and the problem, with doing things in an ad hoc fashion like this "
7857 "is that only people who know about your changes, and where they are, can see "
7858 "them. Such an informal approach simply doesn't scale beyond a handful "
7859 "people, because each individual needs to know about <emphasis>n</emphasis> "
7860 "different repositories to pull from."
7861 msgstr ""
7863 #. type: Content of: <book><chapter><sect1><sect2><title>
7864 #: ../en/ch06-collab.xml:156
7865 msgid "A single central repository"
7866 msgstr "单一中央版本库"
7868 #. type: Content of: <book><chapter><sect1><sect2><para>
7869 #: ../en/ch06-collab.xml:158
7870 msgid ""
7871 "For smaller projects migrating from a centralised revision control tool, "
7872 "perhaps the easiest way to get started is to have changes flow through a "
7873 "single shared central repository. This is also the most common "
7874 "<quote>building block</quote> for more ambitious workflow schemes."
7875 msgstr ""
7877 #. type: Content of: <book><chapter><sect1><sect2><para>
7878 #: ../en/ch06-collab.xml:164
7879 msgid ""
7880 "Contributors start by cloning a copy of this repository. They can pull "
7881 "changes from it whenever they need to, and some (perhaps all) developers have "
7882 "permission to push a change back when they're ready for other people to see "
7883 "it."
7884 msgstr ""
7886 #. type: Content of: <book><chapter><sect1><sect2><para>
7887 #: ../en/ch06-collab.xml:169
7888 msgid ""
7889 "Under this model, it can still often make sense for people to pull changes "
7890 "directly from each other, without going through the central repository. "
7891 "Consider a case in which I have a tentative bug fix, but I am worried that if "
7892 "I were to publish it to the central repository, it might subsequently break "
7893 "everyone else's trees as they pull it. To reduce the potential for damage, I "
7894 "can ask you to clone my repository into a temporary repository of your own "
7895 "and test it. This lets us put off publishing the potentially unsafe change "
7896 "until it has had a little testing."
7897 msgstr ""
7899 #. type: Content of: <book><chapter><sect1><sect2><para>
7900 #: ../en/ch06-collab.xml:180
7901 msgid ""
7902 "If a team is hosting its own repository in this kind of scenario, people will "
7903 "usually use the <command>ssh</command> protocol to securely push changes to "
7904 "the central repository, as documented in <xref linkend=\"sec:collab:ssh\"/>. "
7905 "It's also usual to publish a read-only copy of the repository over HTTP, as "
7906 "in <xref linkend=\"sec:collab:cgi\"/>. Publishing over HTTP satisfies the "
7907 "needs of people who don't have push access, and those who want to use web "
7908 "browsers to browse the repository's history."
7909 msgstr ""
7911 #. type: Content of: <book><chapter><sect1><sect2><title>
7912 #: ../en/ch06-collab.xml:193
7913 msgid "A hosted central repository"
7914 msgstr "托管的中央版本库"
7916 #. type: Content of: <book><chapter><sect1><sect2><para>
7917 #: ../en/ch06-collab.xml:195
7918 msgid ""
7919 "A wonderful thing about public hosting services like <ulink url=\"http://"
7920 "bitbucket.org/\">Bitbucket</ulink> is that not only do they handle the fiddly "
7921 "server configuration details, such as user accounts, authentication, and "
7922 "secure wire protocols, they provide additional infrastructure to make this "
7923 "model work well."
7924 msgstr ""
7926 #. type: Content of: <book><chapter><sect1><sect2><para>
7927 #: ../en/ch06-collab.xml:202
7928 msgid ""
7929 "For instance, a well-engineered hosting service will let people clone their "
7930 "own copies of a repository with a single click. This lets people work in "
7931 "separate spaces and share their changes when they're ready."
7932 msgstr ""
7934 #. type: Content of: <book><chapter><sect1><sect2><para>
7935 #: ../en/ch06-collab.xml:207
7936 msgid ""
7937 "In addition, a good hosting service will let people communicate with each "
7938 "other, for instance to say <quote>there are changes ready for you to review "
7939 "in this tree</quote>."
7940 msgstr ""
7942 #. type: Content of: <book><chapter><sect1><sect2><title>
7943 #: ../en/ch06-collab.xml:214
7944 msgid "Working with multiple branches"
7945 msgstr "使用多个分支工作"
7947 #. type: Content of: <book><chapter><sect1><sect2><para>
7948 #: ../en/ch06-collab.xml:216
7949 msgid ""
7950 "Projects of any significant size naturally tend to make progress on several "
7951 "fronts simultaneously. In the case of software, it's common for a project to "
7952 "go through periodic official releases. A release might then go into "
7953 "<quote>maintenance mode</quote> for a while after its first publication; "
7954 "maintenance releases tend to contain only bug fixes, not new features. In "
7955 "parallel with these maintenance releases, one or more future releases may be "
7956 "under development. People normally use the word <quote>branch</quote> to "
7957 "refer to one of these many slightly different directions in which development "
7958 "is proceeding."
7959 msgstr ""
7961 #. type: Content of: <book><chapter><sect1><sect2><para>
7962 #: ../en/ch06-collab.xml:229
7963 msgid ""
7964 "Mercurial is particularly well suited to managing a number of simultaneous, "
7965 "but not identical, branches. Each <quote>development direction</quote> can "
7966 "live in its own central repository, and you can merge changes from one to "
7967 "another as the need arises. Because repositories are independent of each "
7968 "other, unstable changes in a development branch will never affect a stable "
7969 "branch unless someone explicitly merges those changes into the stable branch."
7970 msgstr ""
7972 #. type: Content of: <book><chapter><sect1><sect2><para>
7973 #: ../en/ch06-collab.xml:238
7974 msgid ""
7975 "Here's an example of how this can work in practice. Let's say you have one "
7976 "<quote>main branch</quote> on a central server."
7977 msgstr ""
7979 #. type: Content of: <book><chapter><sect1><sect2><para>
7980 #: ../en/ch06-collab.xml:244
7981 msgid "People clone it, make changes locally, test them, and push them back."
7982 msgstr ""
7984 #. type: Content of: <book><chapter><sect1><sect2><para>
7985 #: ../en/ch06-collab.xml:247
7986 msgid ""
7987 "Once the main branch reaches a release milestone, you can use the <command "
7988 "role=\"hg-cmd\">hg tag</command> command to give a permanent name to the "
7989 "milestone revision."
7990 msgstr ""
7992 #. type: Content of: <book><chapter><sect1><sect2><para>
7993 #: ../en/ch06-collab.xml:253
7994 msgid "Let's say some ongoing development occurs on the main branch."
7995 msgstr ""
7997 #. type: Content of: <book><chapter><sect1><sect2><para>
7998 #: ../en/ch06-collab.xml:258
7999 msgid ""
8000 "Using the tag that was recorded at the milestone, people who clone that "
8001 "repository at any time in the future can use <command role=\"hg-cmd\">hg "
8002 "update</command> to get a copy of the working directory exactly as it was "
8003 "when that tagged revision was committed."
8004 msgstr ""
8006 #. type: Content of: <book><chapter><sect1><sect2><para>
8007 #: ../en/ch06-collab.xml:266
8008 msgid ""
8009 "In addition, immediately after the main branch is tagged, we can then clone "
8010 "the main branch on the server to a new <quote>stable</quote> branch, also on "
8011 "the server."
8012 msgstr ""
8014 #. type: Content of: <book><chapter><sect1><sect2><para>
8015 #: ../en/ch06-collab.xml:272
8016 msgid ""
8017 "If we need to make a change to the stable branch, we can then clone "
8018 "<emphasis>that</emphasis> repository, make our changes, commit, and push our "
8019 "changes back there."
8020 msgstr ""
8022 #. type: Content of: <book><chapter><sect1><sect2><para>
8023 #: ../en/ch06-collab.xml:279
8024 msgid ""
8025 "Because Mercurial repositories are independent, and Mercurial doesn't move "
8026 "changes around automatically, the stable and main branches are "
8027 "<emphasis>isolated</emphasis> from each other. The changes that we made on "
8028 "the main branch don't <quote>leak</quote> to the stable branch, and vice "
8029 "versa."
8030 msgstr ""
8032 #. type: Content of: <book><chapter><sect1><sect2><para>
8033 #: ../en/ch06-collab.xml:286
8034 msgid ""
8035 "We'll often want all of our bugfixes on the stable branch to show up on the "
8036 "main branch, too. Rather than rewrite a bugfix on the main branch, we can "
8037 "simply pull and merge changes from the stable to the main branch, and "
8038 "Mercurial will bring those bugfixes in for us."
8039 msgstr ""
8041 #. type: Content of: <book><chapter><sect1><sect2><para>
8042 #: ../en/ch06-collab.xml:294
8043 msgid ""
8044 "The main branch will still contain changes that are not on the stable branch, "
8045 "but it will also contain all of the bugfixes from the stable branch. The "
8046 "stable branch remains unaffected by these changes, since changes are only "
8047 "flowing from the stable to the main branch, and not the other way."
8048 msgstr ""
8050 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
8051 #: ../en/ch06-collab.xml:303 ../en/ch06-collab.xml:313
8052 msgid "Feature branches"
8053 msgstr "特性分支"
8055 #. type: Content of: <book><chapter><sect1><sect2><para>
8056 #: ../en/ch06-collab.xml:305
8057 msgid ""
8058 "For larger projects, an effective way to manage change is to break up a team "
8059 "into smaller groups. Each group has a shared branch of its own, cloned from "
8060 "a single <quote>master</quote> branch used by the entire project. People "
8061 "working on an individual branch are typically quite isolated from "
8062 "developments on other branches."
8063 msgstr ""
8065 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
8066 #: ../en/ch06-collab.xml:315
8067 msgid ""
8068 "<imageobject><imagedata width=\"100%\" fileref=\"figs/feature-branches.png\"/"
8069 "></imageobject>"
8070 msgstr ""
8072 #. type: Content of: <book><chapter><sect1><sect2><para>
8073 #: ../en/ch06-collab.xml:320
8074 msgid ""
8075 "When a particular feature is deemed to be in suitable shape, someone on that "
8076 "feature team pulls and merges from the master branch into the feature branch, "
8077 "then pushes back up to the master branch."
8078 msgstr ""
8080 #. type: Content of: <book><chapter><sect1><sect2><title>
8081 #: ../en/ch06-collab.xml:327
8082 msgid "The release train"
8083 msgstr "发布列车"
8085 #. type: Content of: <book><chapter><sect1><sect2><para>
8086 #: ../en/ch06-collab.xml:329
8087 msgid ""
8088 "Some projects are organized on a <quote>train</quote> basis: a release is "
8089 "scheduled to happen every few months, and whatever features are ready when "
8090 "the <quote>train</quote> is ready to leave are allowed in."
8091 msgstr ""
8093 #. type: Content of: <book><chapter><sect1><sect2><para>
8094 #: ../en/ch06-collab.xml:334
8095 msgid ""
8096 "This model resembles working with feature branches. The difference is that "
8097 "when a feature branch misses a train, someone on the feature team pulls and "
8098 "merges the changes that went out on that train release into the feature "
8099 "branch, and the team continues its work on top of that release so that their "
8100 "feature can make the next release."
8101 msgstr ""
8103 #. type: Content of: <book><chapter><sect1><sect2><title>
8104 #: ../en/ch06-collab.xml:343
8105 msgid "The Linux kernel model"
8106 msgstr "Linux 内核模型"
8108 #. type: Content of: <book><chapter><sect1><sect2><para>
8109 #: ../en/ch06-collab.xml:345
8110 msgid ""
8111 "The development of the Linux kernel has a shallow hierarchical structure, "
8112 "surrounded by a cloud of apparent chaos. Because most Linux developers use "
8113 "<command>git</command>, a distributed revision control tool with capabilities "
8114 "similar to Mercurial, it's useful to describe the way work flows in that "
8115 "environment; if you like the ideas, the approach translates well across tools."
8116 msgstr ""
8118 #. type: Content of: <book><chapter><sect1><sect2><para>
8119 #: ../en/ch06-collab.xml:353
8120 msgid ""
8121 "At the center of the community sits Linus Torvalds, the creator of Linux. He "
8122 "publishes a single source repository that is considered the "
8123 "<quote>authoritative</quote> current tree by the entire developer community. "
8124 "Anyone can clone Linus's tree, but he is very choosy about whose trees he "
8125 "pulls from."
8126 msgstr ""
8128 #. type: Content of: <book><chapter><sect1><sect2><para>
8129 #: ../en/ch06-collab.xml:360
8130 msgid ""
8131 "Linus has a number of <quote>trusted lieutenants</quote>. As a general rule, "
8132 "he pulls whatever changes they publish, in most cases without even reviewing "
8133 "those changes. Some of those lieutenants are generally agreed to be "
8134 "<quote>maintainers</quote>, responsible for specific subsystems within the "
8135 "kernel. If a random kernel hacker wants to make a change to a subsystem that "
8136 "they want to end up in Linus's tree, they must find out who the subsystem's "
8137 "maintainer is, and ask that maintainer to take their change. If the "
8138 "maintainer reviews their changes and agrees to take them, they'll pass them "
8139 "along to Linus in due course."
8140 msgstr ""
8142 #. type: Content of: <book><chapter><sect1><sect2><para>
8143 #: ../en/ch06-collab.xml:372
8144 msgid ""
8145 "Individual lieutenants have their own approaches to reviewing, accepting, and "
8146 "publishing changes; and for deciding when to feed them to Linus. In "
8147 "addition, there are several well known branches that people use for different "
8148 "purposes. For example, a few people maintain <quote>stable</quote> "
8149 "repositories of older versions of the kernel, to which they apply critical "
8150 "fixes as needed. Some maintainers publish multiple trees: one for "
8151 "experimental changes; one for changes that they are about to feed upstream; "
8152 "and so on. Others just publish a single tree."
8153 msgstr ""
8155 #. type: Content of: <book><chapter><sect1><sect2><para>
8156 #: ../en/ch06-collab.xml:383
8157 msgid ""
8158 "This model has two notable features. The first is that it's <quote>pull "
8159 "only</quote>. You have to ask, convince, or beg another developer to take a "
8160 "change from you, because there are almost no trees to which more than one "
8161 "person can push, and there's no way to push changes into a tree that someone "
8162 "else controls."
8163 msgstr ""
8165 #. type: Content of: <book><chapter><sect1><sect2><para>
8166 #: ../en/ch06-collab.xml:390
8167 msgid ""
8168 "The second is that it's based on reputation and acclaim. If you're an "
8169 "unknown, Linus will probably ignore changes from you without even "
8170 "responding. But a subsystem maintainer will probably review them, and will "
8171 "likely take them if they pass their criteria for suitability. The more "
8172 "<quote>good</quote> changes you contribute to a maintainer, the more likely "
8173 "they are to trust your judgment and accept your changes. If you're well-"
8174 "known and maintain a long-lived branch for something Linus hasn't yet "
8175 "accepted, people with similar interests may pull your changes regularly to "
8176 "keep up with your work."
8177 msgstr ""
8179 #. type: Content of: <book><chapter><sect1><sect2><para>
8180 #: ../en/ch06-collab.xml:401
8181 msgid ""
8182 "Reputation and acclaim don't necessarily cross subsystem or <quote>people</"
8183 "quote> boundaries. If you're a respected but specialised storage hacker, and "
8184 "you try to fix a networking bug, that change will receive a level of scrutiny "
8185 "from a network maintainer comparable to a change from a complete stranger."
8186 msgstr ""
8188 #. type: Content of: <book><chapter><sect1><sect2><para>
8189 #: ../en/ch06-collab.xml:408
8190 msgid ""
8191 "To people who come from more orderly project backgrounds, the comparatively "
8192 "chaotic Linux kernel development process often seems completely insane. It's "
8193 "subject to the whims of individuals; people make sweeping changes whenever "
8194 "they deem it appropriate; and the pace of development is astounding. And yet "
8195 "Linux is a highly successful, well-regarded piece of software."
8196 msgstr ""
8198 #. type: Content of: <book><chapter><sect1><sect2><title>
8199 #: ../en/ch06-collab.xml:418
8200 msgid "Pull-only versus shared-push collaboration"
8201 msgstr "只读与共享写协作"
8203 #. type: Content of: <book><chapter><sect1><sect2><para>
8204 #: ../en/ch06-collab.xml:420
8205 msgid ""
8206 "A perpetual source of heat in the open source community is whether a "
8207 "development model in which people only ever pull changes from others is "
8208 "<quote>better than</quote> one in which multiple people can push changes to a "
8209 "shared repository."
8210 msgstr ""
8212 #. type: Content of: <book><chapter><sect1><sect2><para>
8213 #: ../en/ch06-collab.xml:426
8214 msgid ""
8215 "Typically, the backers of the shared-push model use tools that actively "
8216 "enforce this approach. If you're using a centralised revision control tool "
8217 "such as Subversion, there's no way to make a choice over which model you'll "
8218 "use: the tool gives you shared-push, and if you want to do anything else, "
8219 "you'll have to roll your own approach on top (such as applying a patch by "
8220 "hand)."
8221 msgstr ""
8223 #. type: Content of: <book><chapter><sect1><sect2><para>
8224 #: ../en/ch06-collab.xml:434
8225 msgid ""
8226 "A good distributed revision control tool will support both models. You and "
8227 "your collaborators can then structure how you work together based on your own "
8228 "needs and preferences, not on what contortions your tools force you into."
8229 msgstr ""
8231 #. type: Content of: <book><chapter><sect1><sect2><title>
8232 #: ../en/ch06-collab.xml:441
8233 msgid "Where collaboration meets branch management"
8234 msgstr "协作与分支管理"
8236 #. type: Content of: <book><chapter><sect1><sect2><para>
8237 #: ../en/ch06-collab.xml:443
8238 msgid ""
8239 "Once you and your team set up some shared repositories and start propagating "
8240 "changes back and forth between local and shared repos, you begin to face a "
8241 "related, but slightly different challenge: that of managing the multiple "
8242 "directions in which your team may be moving at once. Even though this "
8243 "subject is intimately related to how your team collaborates, it's dense "
8244 "enough to merit treatment of its own, in <xref linkend=\"chap:branch\"/>."
8245 msgstr ""
8247 #. type: Content of: <book><chapter><sect1><title>
8248 #: ../en/ch06-collab.xml:455
8249 msgid "The technical side of sharing"
8250 msgstr "共享的技术因素"
8252 #. type: Content of: <book><chapter><sect1><para>
8253 #: ../en/ch06-collab.xml:457
8254 msgid ""
8255 "The remainder of this chapter is devoted to the question of sharing changes "
8256 "with your collaborators."
8257 msgstr ""
8259 #. type: Content of: <book><chapter><sect1><title>
8260 #: ../en/ch06-collab.xml:462
8261 msgid "Informal sharing with <command role=\"hg-cmd\">hg serve</command>"
8262 msgstr "使用 <command role=\"hg-cmd\">hg serve</command> 进行非正式共享"
8264 #. type: Content of: <book><chapter><sect1><para>
8265 #: ../en/ch06-collab.xml:465
8266 msgid ""
8267 "Mercurial's <command role=\"hg-cmd\">hg serve</command> command is "
8268 "wonderfully suited to small, tight-knit, and fast-paced group environments. "
8269 "It also provides a great way to get a feel for using Mercurial commands over "
8270 "a network."
8271 msgstr ""
8273 #. type: Content of: <book><chapter><sect1><para>
8274 #: ../en/ch06-collab.xml:470
8275 msgid ""
8276 "Run <command role=\"hg-cmd\">hg serve</command> inside a repository, and in "
8277 "under a second it will bring up a specialised HTTP server; this will accept "
8278 "connections from any client, and serve up data for that repository until you "
8279 "terminate it. Anyone who knows the URL of the server you just started, and "
8280 "can talk to your computer over the network, can then use a web browser or "
8281 "Mercurial to read data from that repository. A URL for a <command role=\"hg-"
8282 "cmd\">hg serve</command> instance running on a laptop is likely to look "
8283 "something like <literal>http://my-laptop.local:8000/</literal>."
8284 msgstr ""
8286 #. type: Content of: <book><chapter><sect1><para>
8287 #: ../en/ch06-collab.xml:481
8288 msgid ""
8289 "The <command role=\"hg-cmd\">hg serve</command> command is <emphasis>not</"
8290 "emphasis> a general-purpose web server. It can do only two things:"
8291 msgstr ""
8293 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8294 #: ../en/ch06-collab.xml:485
8295 msgid ""
8296 "Allow people to browse the history of the repository it's serving, from their "
8297 "normal web browsers."
8298 msgstr ""
8300 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8301 #: ../en/ch06-collab.xml:489
8302 msgid ""
8303 "Speak Mercurial's wire protocol, so that people can <command role=\"hg-cmd"
8304 "\">hg clone</command> or <command role=\"hg-cmd\">hg pull</command> changes "
8305 "from that repository."
8306 msgstr ""
8308 #. type: Content of: <book><chapter><sect1><para>
8309 #: ../en/ch06-collab.xml:494
8310 msgid ""
8311 "In particular, <command role=\"hg-cmd\">hg serve</command> won't allow remote "
8312 "users to <emphasis>modify</emphasis> your repository. It's intended for read-"
8313 "only use."
8314 msgstr ""
8316 #. type: Content of: <book><chapter><sect1><para>
8317 #: ../en/ch06-collab.xml:498
8318 msgid ""
8319 "If you're getting started with Mercurial, there's nothing to prevent you from "
8320 "using <command role=\"hg-cmd\">hg serve</command> to serve up a repository on "
8321 "your own computer, then use commands like <command role=\"hg-cmd\">hg clone</"
8322 "command>, <command role=\"hg-cmd\">hg incoming</command>, and so on to talk "
8323 "to that server as if the repository was hosted remotely. This can help you to "
8324 "quickly get acquainted with using commands on network-hosted repositories."
8325 msgstr ""
8327 #. type: Content of: <book><chapter><sect1><sect2><title>
8328 #: ../en/ch06-collab.xml:508
8329 msgid "A few things to keep in mind"
8330 msgstr "要牢记的几件事"
8332 #. type: Content of: <book><chapter><sect1><sect2><para>
8333 #: ../en/ch06-collab.xml:510
8334 msgid ""
8335 "Because it provides unauthenticated read access to all clients, you should "
8336 "only use <command role=\"hg-cmd\">hg serve</command> in an environment where "
8337 "you either don't care, or have complete control over, who can access your "
8338 "network and pull data from your repository."
8339 msgstr ""
8341 #. type: Content of: <book><chapter><sect1><sect2><para>
8342 #: ../en/ch06-collab.xml:516
8343 msgid ""
8344 "The <command role=\"hg-cmd\">hg serve</command> command knows nothing about "
8345 "any firewall software you might have installed on your system or network. It "
8346 "cannot detect or control your firewall software. If other people are unable "
8347 "to talk to a running <command role=\"hg-cmd\">hg serve</command> instance, "
8348 "the second thing you should do (<emphasis>after</emphasis> you make sure that "
8349 "they're using the correct URL) is check your firewall configuration."
8350 msgstr ""
8352 #. type: Content of: <book><chapter><sect1><sect2><para>
8353 #: ../en/ch06-collab.xml:525
8354 msgid ""
8355 "By default, <command role=\"hg-cmd\">hg serve</command> listens for incoming "
8356 "connections on port 8000. If another process is already listening on the "
8357 "port you want to use, you can specify a different port to listen on using the "
8358 "<option role=\"hg-opt-serve\">-p</option> option."
8359 msgstr ""
8361 #. type: Content of: <book><chapter><sect1><sect2><para>
8362 #: ../en/ch06-collab.xml:531
8363 msgid ""
8364 "Normally, when <command role=\"hg-cmd\">hg serve</command> starts, it prints "
8365 "no output, which can be a bit unnerving. If you'd like to confirm that it is "
8366 "indeed running correctly, and find out what URL you should send to your "
8367 "collaborators, start it with the <option role=\"hg-opt-global\">-v</option> "
8368 "option."
8369 msgstr ""
8371 #. type: Content of: <book><chapter><sect1><title>
8372 #: ../en/ch06-collab.xml:541
8373 msgid "Using the Secure Shell (ssh) protocol"
8374 msgstr "使用 ssh 协议"
8376 #. type: Content of: <book><chapter><sect1><para>
8377 #: ../en/ch06-collab.xml:543
8378 msgid ""
8379 "You can pull and push changes securely over a network connection using the "
8380 "Secure Shell (<literal>ssh</literal>) protocol. To use this successfully, "
8381 "you may have to do a little bit of configuration on the client or server "
8382 "sides."
8383 msgstr ""
8385 #. type: Content of: <book><chapter><sect1><para>
8386 #: ../en/ch06-collab.xml:548
8387 msgid ""
8388 "If you're not familiar with ssh, it's the name of both a command and a "
8389 "network protocol that let you securely communicate with another computer. To "
8390 "use it with Mercurial, you'll be setting up one or more user accounts on a "
8391 "server so that remote users can log in and execute commands."
8392 msgstr ""
8394 #. type: Content of: <book><chapter><sect1><para>
8395 #: ../en/ch06-collab.xml:554
8396 msgid ""
8397 "(If you <emphasis>are</emphasis> familiar with ssh, you'll probably find some "
8398 "of the material that follows to be elementary in nature.)"
8399 msgstr ""
8401 #. type: Content of: <book><chapter><sect1><sect2><title>
8402 #: ../en/ch06-collab.xml:559
8403 msgid "How to read and write ssh URLs"
8404 msgstr "如何读写 ssh 路径"
8406 #. type: Content of: <book><chapter><sect1><sect2><para>
8407 #: ../en/ch06-collab.xml:561
8408 msgid "An ssh URL tends to look like this:"
8409 msgstr ""
8411 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
8412 #: ../en/ch06-collab.xml:564
8413 msgid ""
8414 "The <quote><literal>ssh://</literal></quote> part tells Mercurial to use the "
8415 "ssh protocol."
8416 msgstr ""
8418 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
8419 #: ../en/ch06-collab.xml:567
8420 msgid ""
8421 "The <quote><literal>bos@</literal></quote> component indicates what username "
8422 "to log into the server as. You can leave this out if the remote username is "
8423 "the same as your local username."
8424 msgstr ""
8426 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
8427 #: ../en/ch06-collab.xml:572
8428 msgid ""
8429 "The <quote><literal>hg.serpentine.com</literal></quote> gives the hostname of "
8430 "the server to log into."
8431 msgstr ""
8433 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
8434 #: ../en/ch06-collab.xml:576
8435 msgid ""
8436 "The <quote>:22</quote> identifies the port number to connect to the server "
8437 "on. The default port is 22, so you only need to specify a colon and port "
8438 "number if you're <emphasis>not</emphasis> using port 22."
8439 msgstr ""
8441 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
8442 #: ../en/ch06-collab.xml:581
8443 msgid ""
8444 "The remainder of the URL is the local path to the repository on the server."
8445 msgstr ""
8447 #. type: Content of: <book><chapter><sect1><sect2><para>
8448 #: ../en/ch06-collab.xml:585
8449 msgid ""
8450 "There's plenty of scope for confusion with the path component of ssh URLs, as "
8451 "there is no standard way for tools to interpret it. Some programs behave "
8452 "differently than others when dealing with these paths. This isn't an ideal "
8453 "situation, but it's unlikely to change. Please read the following paragraphs "
8454 "carefully."
8455 msgstr ""
8457 #. type: Content of: <book><chapter><sect1><sect2><para>
8458 #: ../en/ch06-collab.xml:592
8459 msgid ""
8460 "Mercurial treats the path to a repository on the server as relative to the "
8461 "remote user's home directory. For example, if user <literal>foo</literal> on "
8462 "the server has a home directory of <filename class=\"directory\">/home/foo</"
8463 "filename>, then an ssh URL that contains a path component of <filename class="
8464 "\"directory\">bar</filename> <emphasis>really</emphasis> refers to the "
8465 "directory <filename class=\"directory\">/home/foo/bar</filename>."
8466 msgstr ""
8468 #. type: Content of: <book><chapter><sect1><sect2><para>
8469 #: ../en/ch06-collab.xml:601
8470 msgid ""
8471 "If you want to specify a path relative to another user's home directory, you "
8472 "can use a path that starts with a tilde character followed by the user's name "
8473 "(let's call them <literal>otheruser</literal>), like this."
8474 msgstr ""
8476 #. type: Content of: <book><chapter><sect1><sect2><para>
8477 #: ../en/ch06-collab.xml:607
8478 msgid ""
8479 "And if you really want to specify an <emphasis>absolute</emphasis> path on "
8480 "the server, begin the path component with two slashes, as in this example."
8481 msgstr ""
8483 #. type: Content of: <book><chapter><sect1><sect2><title>
8484 #: ../en/ch06-collab.xml:614
8485 msgid "Finding an ssh client for your system"
8486 msgstr "为你的系统寻找 ssh 客户端"
8488 #. type: Content of: <book><chapter><sect1><sect2><para>
8489 #: ../en/ch06-collab.xml:616
8490 msgid ""
8491 "Almost every Unix-like system comes with OpenSSH preinstalled. If you're "
8492 "using such a system, run <literal>which ssh</literal> to find out if the "
8493 "<command>ssh</command> command is installed (it's usually in <filename class="
8494 "\"directory\">/usr/bin</filename>). In the unlikely event that it isn't "
8495 "present, take a look at your system documentation to figure out how to "
8496 "install it."
8497 msgstr ""
8499 #. type: Content of: <book><chapter><sect1><sect2><para>
8500 #: ../en/ch06-collab.xml:624
8501 msgid ""
8502 "On Windows, the TortoiseHg package is bundled with a version of Simon "
8503 "Tatham's excellent <command>plink</command> command, and you should not need "
8504 "to do any further configuration."
8505 msgstr ""
8507 #. type: Content of: <book><chapter><sect1><sect2><title>
8508 #: ../en/ch06-collab.xml:631
8509 msgid "Generating a key pair"
8510 msgstr "产生密钥对"
8512 #. type: Content of: <book><chapter><sect1><sect2><para>
8513 #: ../en/ch06-collab.xml:633
8514 msgid ""
8515 "To avoid the need to repetitively type a password every time you need to use "
8516 "your ssh client, I recommend generating a key pair."
8517 msgstr ""
8519 #. type: Content of: <book><chapter><sect1><sect2><tip><title>
8520 #: ../en/ch06-collab.xml:638
8521 msgid "Key pairs are not mandatory"
8522 msgstr ""
8524 #. type: Content of: <book><chapter><sect1><sect2><tip><para>
8525 #: ../en/ch06-collab.xml:640
8526 msgid ""
8527 "Mercurial knows nothing about ssh authentication or key pairs. You can, if "
8528 "you like, safely ignore this section and the one that follows until you grow "
8529 "tired of repeatedly typing ssh passwords."
8530 msgstr ""
8532 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8533 #: ../en/ch06-collab.xml:648
8534 msgid ""
8535 "On a Unix-like system, the <command>ssh-keygen</command> command will do the "
8536 "trick."
8537 msgstr ""
8539 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8540 #: ../en/ch06-collab.xml:651
8541 msgid ""
8542 "On Windows, if you're using TortoiseHg, you may need to download a command "
8543 "named <command>puttygen</command> from <ulink url=\"http://www.chiark."
8544 "greenend.org.uk/~sgtatham/putty\">the PuTTY web site</ulink> to generate a "
8545 "key pair. See <ulink url=\"http://the.earth.li/~sgtatham/putty/0.60/htmldoc/"
8546 "Chapter8.html#pubkey-puttygen\">the <command>puttygen</command> "
8547 "documentation</ulink> for details of how use the command."
8548 msgstr ""
8550 #. type: Content of: <book><chapter><sect1><sect2><para>
8551 #: ../en/ch06-collab.xml:663
8552 msgid ""
8553 "When you generate a key pair, it's usually <emphasis>highly</emphasis> "
8554 "advisable to protect it with a passphrase. (The only time that you might not "
8555 "want to do this is when you're using the ssh protocol for automated tasks on "
8556 "a secure network.)"
8557 msgstr ""
8559 #. type: Content of: <book><chapter><sect1><sect2><para>
8560 #: ../en/ch06-collab.xml:669
8561 msgid ""
8562 "Simply generating a key pair isn't enough, however. You'll need to add the "
8563 "public key to the set of authorised keys for whatever user you're logging in "
8564 "remotely as. For servers using OpenSSH (the vast majority), this will mean "
8565 "adding the public key to a list in a file called <filename role=\"special"
8566 "\">authorized_keys</filename> in their <filename role=\"special\" class="
8567 "\"directory\">.ssh</filename> directory."
8568 msgstr ""
8570 #. type: Content of: <book><chapter><sect1><sect2><para>
8571 #: ../en/ch06-collab.xml:678
8572 msgid ""
8573 "On a Unix-like system, your public key will have a <filename>.pub</filename> "
8574 "extension. If you're using <command>puttygen</command> on Windows, you can "
8575 "save the public key to a file of your choosing, or paste it from the window "
8576 "it's displayed in straight into the <filename role=\"special"
8577 "\">authorized_keys</filename> file."
8578 msgstr ""
8580 #. type: Content of: <book><chapter><sect1><sect2><title>
8581 #: ../en/ch06-collab.xml:686
8582 msgid "Using an authentication agent"
8583 msgstr "使用认证代理"
8585 #. type: Content of: <book><chapter><sect1><sect2><para>
8586 #: ../en/ch06-collab.xml:688
8587 msgid ""
8588 "An authentication agent is a daemon that stores passphrases in memory (so it "
8589 "will forget passphrases if you log out and log back in again). An ssh client "
8590 "will notice if it's running, and query it for a passphrase. If there's no "
8591 "authentication agent running, or the agent doesn't store the necessary "
8592 "passphrase, you'll have to type your passphrase every time Mercurial tries to "
8593 "communicate with a server on your behalf (e.g. whenever you pull or push "
8594 "changes)."
8595 msgstr ""
8597 #. type: Content of: <book><chapter><sect1><sect2><para>
8598 #: ../en/ch06-collab.xml:697
8599 msgid ""
8600 "The downside of storing passphrases in an agent is that it's possible for a "
8601 "well-prepared attacker to recover the plain text of your passphrases, in some "
8602 "cases even if your system has been power-cycled. You should make your own "
8603 "judgment as to whether this is an acceptable risk. It certainly saves a lot "
8604 "of repeated typing."
8605 msgstr ""
8607 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8608 #: ../en/ch06-collab.xml:706
8609 msgid ""
8610 "On Unix-like systems, the agent is called <command>ssh-agent</command>, and "
8611 "it's often run automatically for you when you log in. You'll need to use the "
8612 "<command>ssh-add</command> command to add passphrases to the agent's store."
8613 msgstr ""
8615 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8616 #: ../en/ch06-collab.xml:713
8617 msgid ""
8618 "On Windows, if you're using TortoiseHg, the <command>pageant</command> "
8619 "command acts as the agent. As with <command>puttygen</command>, you'll need "
8620 "to <ulink url=\"http://www.chiark.greenend.org.uk/%7Esgtatham/putty/download."
8621 "html\">download <command>pageant</command></ulink> from the PuTTY web site "
8622 "and read <ulink url=\"http://the.earth.li/~sgtatham/putty/0.60/htmldoc/"
8623 "Chapter9.html#pageant\">its documentation</ulink>. The <command>pageant</"
8624 "command> command adds an icon to your system tray that will let you manage "
8625 "stored passphrases."
8626 msgstr ""
8628 #. type: Content of: <book><chapter><sect1><sect2><title>
8629 #: ../en/ch06-collab.xml:728
8630 msgid "Configuring the server side properly"
8631 msgstr "正确配置服务器端"
8633 #. type: Content of: <book><chapter><sect1><sect2><para>
8634 #: ../en/ch06-collab.xml:730
8635 msgid ""
8636 "Because ssh can be fiddly to set up if you're new to it, a variety of things "
8637 "can go wrong. Add Mercurial on top, and there's plenty more scope for head-"
8638 "scratching. Most of these potential problems occur on the server side, not "
8639 "the client side. The good news is that once you've gotten a configuration "
8640 "working, it will usually continue to work indefinitely."
8641 msgstr ""
8643 #. type: Content of: <book><chapter><sect1><sect2><para>
8644 #: ../en/ch06-collab.xml:738
8645 msgid ""
8646 "Before you try using Mercurial to talk to an ssh server, it's best to make "
8647 "sure that you can use the normal <command>ssh</command> or <command>putty</"
8648 "command> command to talk to the server first. If you run into problems with "
8649 "using these commands directly, Mercurial surely won't work. Worse, it will "
8650 "obscure the underlying problem. Any time you want to debug ssh-related "
8651 "Mercurial problems, you should drop back to making sure that plain ssh client "
8652 "commands work first, <emphasis>before</emphasis> you worry about whether "
8653 "there's a problem with Mercurial."
8654 msgstr ""
8656 #. type: Content of: <book><chapter><sect1><sect2><para>
8657 #: ../en/ch06-collab.xml:749
8658 msgid ""
8659 "The first thing to be sure of on the server side is that you can actually log "
8660 "in from another machine at all. If you can't use <command>ssh</command> or "
8661 "<command>putty</command> to log in, the error message you get may give you a "
8662 "few hints as to what's wrong. The most common problems are as follows."
8663 msgstr ""
8665 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8666 #: ../en/ch06-collab.xml:756
8667 msgid ""
8668 "If you get a <quote>connection refused</quote> error, either there isn't an "
8669 "SSH daemon running on the server at all, or it's inaccessible due to firewall "
8670 "configuration."
8671 msgstr ""
8673 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8674 #: ../en/ch06-collab.xml:761
8675 msgid ""
8676 "If you get a <quote>no route to host</quote> error, you either have an "
8677 "incorrect address for the server or a seriously locked down firewall that "
8678 "won't admit its existence at all."
8679 msgstr ""
8681 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8682 #: ../en/ch06-collab.xml:766
8683 msgid ""
8684 "If you get a <quote>permission denied</quote> error, you may have mistyped "
8685 "the username on the server, or you could have mistyped your key's passphrase "
8686 "or the remote user's password."
8687 msgstr ""
8689 #. type: Content of: <book><chapter><sect1><sect2><para>
8690 #: ../en/ch06-collab.xml:771
8691 msgid ""
8692 "In summary, if you're having trouble talking to the server's ssh daemon, "
8693 "first make sure that one is running at all. On many systems it will be "
8694 "installed, but disabled, by default. Once you're done with this step, you "
8695 "should then check that the server's firewall is configured to allow incoming "
8696 "connections on the port the ssh daemon is listening on (usually 22). Don't "
8697 "worry about more exotic possibilities for misconfiguration until you've "
8698 "checked these two first."
8699 msgstr ""
8701 #. type: Content of: <book><chapter><sect1><sect2><para>
8702 #: ../en/ch06-collab.xml:781
8703 msgid ""
8704 "If you're using an authentication agent on the client side to store "
8705 "passphrases for your keys, you ought to be able to log into the server "
8706 "without being prompted for a passphrase or a password. If you're prompted "
8707 "for a passphrase, there are a few possible culprits."
8708 msgstr ""
8710 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8711 #: ../en/ch06-collab.xml:787
8712 msgid ""
8713 "You might have forgotten to use <command>ssh-add</command> or "
8714 "<command>pageant</command> to store the passphrase."
8715 msgstr ""
8717 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8718 #: ../en/ch06-collab.xml:791
8719 msgid "You might have stored the passphrase for the wrong key."
8720 msgstr ""
8722 #. type: Content of: <book><chapter><sect1><sect2><para>
8723 #: ../en/ch06-collab.xml:794
8724 msgid ""
8725 "If you're being prompted for the remote user's password, there are another "
8726 "few possible problems to check."
8727 msgstr ""
8729 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8730 #: ../en/ch06-collab.xml:797
8731 msgid ""
8732 "Either the user's home directory or their <filename role=\"special\" class="
8733 "\"directory\">.ssh</filename> directory might have excessively liberal "
8734 "permissions. As a result, the ssh daemon will not trust or read their "
8735 "<filename role=\"special\">authorized_keys</filename> file. For example, a "
8736 "group-writable home or <filename role=\"special\" class=\"directory\">.ssh</"
8737 "filename> directory will often cause this symptom."
8738 msgstr ""
8740 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8741 #: ../en/ch06-collab.xml:806
8742 msgid ""
8743 "The user's <filename role=\"special\">authorized_keys</filename> file may "
8744 "have a problem. If anyone other than the user owns or can write to that file, "
8745 "the ssh daemon will not trust or read it."
8746 msgstr ""
8748 #. type: Content of: <book><chapter><sect1><sect2><para>
8749 #: ../en/ch06-collab.xml:813
8750 msgid ""
8751 "In the ideal world, you should be able to run the following command "
8752 "successfully, and it should print exactly one line of output, the current "
8753 "date and time."
8754 msgstr ""
8756 #. type: Content of: <book><chapter><sect1><sect2><para>
8757 #: ../en/ch06-collab.xml:818
8758 msgid ""
8759 "If, on your server, you have login scripts that print banners or other junk "
8760 "even when running non-interactive commands like this, you should fix them "
8761 "before you continue, so that they only print output if they're run "
8762 "interactively. Otherwise these banners will at least clutter up Mercurial's "
8763 "output. Worse, they could potentially cause problems with running Mercurial "
8764 "commands remotely. Mercurial tries to detect and ignore banners in non-"
8765 "interactive <command>ssh</command> sessions, but it is not foolproof. (If "
8766 "you're editing your login scripts on your server, the usual way to see if a "
8767 "login script is running in an interactive shell is to check the return code "
8768 "from the command <literal>tty -s</literal>.)"
8769 msgstr ""
8771 #. type: Content of: <book><chapter><sect1><sect2><para>
8772 #: ../en/ch06-collab.xml:832
8773 msgid ""
8774 "Once you've verified that plain old ssh is working with your server, the next "
8775 "step is to ensure that Mercurial runs on the server. The following command "
8776 "should run successfully:"
8777 msgstr ""
8779 #. type: Content of: <book><chapter><sect1><sect2><para>
8780 #: ../en/ch06-collab.xml:839
8781 msgid ""
8782 "If you see an error message instead of normal <command role=\"hg-cmd\">hg "
8783 "version</command> output, this is usually because you haven't installed "
8784 "Mercurial to <filename class=\"directory\">/usr/bin</filename>. Don't worry "
8785 "if this is the case; you don't need to do that. But you should check for a "
8786 "few possible problems."
8787 msgstr ""
8789 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8790 #: ../en/ch06-collab.xml:846
8791 msgid ""
8792 "Is Mercurial really installed on the server at all? I know this sounds "
8793 "trivial, but it's worth checking!"
8794 msgstr ""
8796 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8797 #: ../en/ch06-collab.xml:850
8798 msgid ""
8799 "Maybe your shell's search path (usually set via the <envar>PATH</envar> "
8800 "environment variable) is simply misconfigured."
8801 msgstr ""
8803 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8804 #: ../en/ch06-collab.xml:854
8805 msgid ""
8806 "Perhaps your <envar>PATH</envar> environment variable is only being set to "
8807 "point to the location of the <command>hg</command> executable if the login "
8808 "session is interactive. This can happen if you're setting the path in the "
8809 "wrong shell login script. See your shell's documentation for details."
8810 msgstr ""
8812 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8813 #: ../en/ch06-collab.xml:861
8814 msgid ""
8815 "The <envar>PYTHONPATH</envar> environment variable may need to contain the "
8816 "path to the Mercurial Python modules. It might not be set at all; it could "
8817 "be incorrect; or it may be set only if the login is interactive."
8818 msgstr ""
8820 #. type: Content of: <book><chapter><sect1><sect2><para>
8821 #: ../en/ch06-collab.xml:868
8822 msgid ""
8823 "If you can run <command role=\"hg-cmd\">hg version</command> over an ssh "
8824 "connection, well done! You've got the server and client sorted out. You "
8825 "should now be able to use Mercurial to access repositories hosted by that "
8826 "username on that server. If you run into problems with Mercurial and ssh at "
8827 "this point, try using the <option role=\"hg-opt-global\">--debug</option> "
8828 "option to get a clearer picture of what's going on."
8829 msgstr ""
8831 #. type: Content of: <book><chapter><sect1><sect2><title>
8832 #: ../en/ch06-collab.xml:877
8833 msgid "Using compression with ssh"
8834 msgstr "通过 ssh 使用压缩"
8836 #. type: Content of: <book><chapter><sect1><sect2><para>
8837 #: ../en/ch06-collab.xml:879
8838 msgid ""
8839 "Mercurial does not compress data when it uses the ssh protocol, because the "
8840 "ssh protocol can transparently compress data. However, the default behavior "
8841 "of ssh clients is <emphasis>not</emphasis> to request compression."
8842 msgstr ""
8844 #. type: Content of: <book><chapter><sect1><sect2><para>
8845 #: ../en/ch06-collab.xml:884
8846 msgid ""
8847 "Over any network other than a fast LAN (even a wireless network), using "
8848 "compression is likely to significantly speed up Mercurial's network "
8849 "operations. For example, over a WAN, someone measured compression as "
8850 "reducing the amount of time required to clone a particularly large repository "
8851 "from 51 minutes to 17 minutes."
8852 msgstr ""
8854 #. type: Content of: <book><chapter><sect1><sect2><para>
8855 #: ../en/ch06-collab.xml:891
8856 msgid ""
8857 "Both <command>ssh</command> and <command>plink</command> accept a <option "
8858 "role=\"cmd-opt-ssh\">-C</option> option which turns on compression. You can "
8859 "easily edit your <filename role=\"special\">~/.hgrc</filename> to enable "
8860 "compression for all of Mercurial's uses of the ssh protocol. Here is how to "
8861 "do so for regular <command>ssh</command> on Unix-like systems, for example."
8862 msgstr ""
8864 #. type: Content of: <book><chapter><sect1><sect2><para>
8865 #: ../en/ch06-collab.xml:901
8866 msgid ""
8867 "If you use <command>ssh</command> on a Unix-like system, you can configure it "
8868 "to always use compression when talking to your server. To do this, edit your "
8869 "<filename role=\"special\">.ssh/config</filename> file (which may not yet "
8870 "exist), as follows."
8871 msgstr ""
8873 #. type: Content of: <book><chapter><sect1><sect2><para>
8874 #: ../en/ch06-collab.xml:911
8875 msgid ""
8876 "This defines a hostname alias, <literal>hg</literal>. When you use that "
8877 "hostname on the <command>ssh</command> command line or in a Mercurial "
8878 "<literal>ssh</literal>-protocol URL, it will cause <command>ssh</command> to "
8879 "connect to <literal>hg.example.com</literal> and use compression. This gives "
8880 "you both a shorter name to type and compression, each of which is a good "
8881 "thing in its own right."
8882 msgstr ""
8884 #. type: Content of: <book><chapter><sect1><title>
8885 #: ../en/ch06-collab.xml:923
8886 msgid "Serving over HTTP using CGI"
8887 msgstr "使用 CGI 通过 HTTP 提供服务"
8889 #. type: Content of: <book><chapter><sect1><para>
8890 #: ../en/ch06-collab.xml:925
8891 msgid ""
8892 "The simplest way to host one or more repositories in a permanent way is to "
8893 "use a web server and Mercurial's CGI support."
8894 msgstr ""
8896 #. type: Content of: <book><chapter><sect1><para>
8897 #: ../en/ch06-collab.xml:929
8898 msgid ""
8899 "Depending on how ambitious you are, configuring Mercurial's CGI interface can "
8900 "take anything from a few moments to several hours."
8901 msgstr ""
8903 #. type: Content of: <book><chapter><sect1><para>
8904 #: ../en/ch06-collab.xml:933
8905 msgid ""
8906 "We'll begin with the simplest of examples, and work our way towards a more "
8907 "complex configuration. Even for the most basic case, you're almost certainly "
8908 "going to need to read and modify your web server's configuration."
8909 msgstr ""
8911 #. type: Content of: <book><chapter><sect1><note><title>
8912 #: ../en/ch06-collab.xml:939
8913 msgid "High pain tolerance required"
8914 msgstr ""
8916 #. type: Content of: <book><chapter><sect1><note><para>
8917 #: ../en/ch06-collab.xml:941
8918 msgid ""
8919 "Configuring a web server is a complex, fiddly, and highly system-dependent "
8920 "activity. I can't possibly give you instructions that will cover anything "
8921 "like all of the cases you will encounter. Please use your discretion and "
8922 "judgment in following the sections below. Be prepared to make plenty of "
8923 "mistakes, and to spend a lot of time reading your server's error logs."
8924 msgstr ""
8926 #. type: Content of: <book><chapter><sect1><note><para>
8927 #: ../en/ch06-collab.xml:949
8928 msgid ""
8929 "If you don't have a strong stomach for tweaking configurations over and over, "
8930 "or a compelling need to host your own services, you might want to try one of "
8931 "the public hosting services that I mentioned earlier."
8932 msgstr ""
8934 #. type: Content of: <book><chapter><sect1><sect2><title>
8935 #: ../en/ch06-collab.xml:956
8936 msgid "Web server configuration checklist"
8937 msgstr "Web 服务器配置检查表"
8939 #. type: Content of: <book><chapter><sect1><sect2><para>
8940 #: ../en/ch06-collab.xml:958
8941 msgid ""
8942 "Before you continue, do take a few moments to check a few aspects of your "
8943 "system's setup."
8944 msgstr ""
8946 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
8947 #: ../en/ch06-collab.xml:962
8948 msgid ""
8949 "Do you have a web server installed at all? Mac OS X and some Linux "
8950 "distributions ship with Apache, but many other systems may not have a web "
8951 "server installed."
8952 msgstr ""
8954 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
8955 #: ../en/ch06-collab.xml:967
8956 msgid ""
8957 "If you have a web server installed, is it actually running? On most systems, "
8958 "even if one is present, it will be disabled by default."
8959 msgstr ""
8961 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
8962 #: ../en/ch06-collab.xml:971
8963 msgid ""
8964 "Is your server configured to allow you to run CGI programs in the directory "
8965 "where you plan to do so? Most servers default to explicitly disabling the "
8966 "ability to run CGI programs."
8967 msgstr ""
8969 #. type: Content of: <book><chapter><sect1><sect2><para>
8970 #: ../en/ch06-collab.xml:977
8971 msgid ""
8972 "If you don't have a web server installed, and don't have substantial "
8973 "experience configuring Apache, you should consider using the "
8974 "<literal>lighttpd</literal> web server instead of Apache. Apache has a well-"
8975 "deserved reputation for baroque and confusing configuration. While "
8976 "<literal>lighttpd</literal> is less capable in some ways than Apache, most of "
8977 "these capabilities are not relevant to serving Mercurial repositories. And "
8978 "<literal>lighttpd</literal> is undeniably <emphasis>much</emphasis> easier to "
8979 "get started with than Apache."
8980 msgstr ""
8982 #. type: Content of: <book><chapter><sect1><sect2><title>
8983 #: ../en/ch06-collab.xml:990
8984 msgid "Basic CGI configuration"
8985 msgstr "基本 CGI 配置"
8987 #. type: Content of: <book><chapter><sect1><sect2><para>
8988 #: ../en/ch06-collab.xml:992
8989 msgid ""
8990 "On Unix-like systems, it's common for users to have a subdirectory named "
8991 "something like <filename class=\"directory\">public_html</filename> in their "
8992 "home directory, from which they can serve up web pages. A file named "
8993 "<filename>foo</filename> in this directory will be accessible at a URL of the "
8994 "form <literal>http://www.example.com/username/foo</literal>."
8995 msgstr ""
8997 #. type: Content of: <book><chapter><sect1><sect2><para>
8998 #: ../en/ch06-collab.xml:1000
8999 msgid ""
9000 "To get started, find the <filename role=\"special\">hgweb.cgi</filename> "
9001 "script that should be present in your Mercurial installation. If you can't "
9002 "quickly find a local copy on your system, simply download one from the master "
9003 "Mercurial repository at <ulink url=\"http://www.selenic.com/repo/hg/raw-file/"
9004 "tip/hgweb.cgi\">http://www.selenic.com/repo/hg/raw-file/tip/hgweb.cgi</ulink>."
9005 msgstr ""
9007 #. type: Content of: <book><chapter><sect1><sect2><para>
9008 #: ../en/ch06-collab.xml:1007 ../en/ch06-collab.xml:1175
9009 msgid ""
9010 "You'll need to copy this script into your <filename class=\"directory"
9011 "\">public_html</filename> directory, and ensure that it's executable."
9012 msgstr ""
9014 #. type: Content of: <book><chapter><sect1><sect2><para>
9015 #: ../en/ch06-collab.xml:1012
9016 msgid ""
9017 "The <literal>755</literal> argument to <command>chmod</command> is a little "
9018 "more general than just making the script executable: it ensures that the "
9019 "script is executable by anyone, and that <quote>group</quote> and "
9020 "<quote>other</quote> write permissions are <emphasis>not</emphasis> set. If "
9021 "you were to leave those write permissions enabled, Apache's <literal>suexec</"
9022 "literal> subsystem would likely refuse to execute the script. In fact, "
9023 "<literal>suexec</literal> also insists that the <emphasis>directory</"
9024 "emphasis> in which the script resides must not be writable by others."
9025 msgstr ""
9027 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
9028 #: ../en/ch06-collab.xml:1026
9029 msgid "What could <emphasis>possibly</emphasis> go wrong?"
9030 msgstr "什么<emphasis>可能</emphasis>会出错?"
9032 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9033 #: ../en/ch06-collab.xml:1029
9034 msgid ""
9035 "Once you've copied the CGI script into place, go into a web browser, and try "
9036 "to open the URL <literal>http://myhostname/~myuser/hgweb.cgi</literal>, "
9037 "<emphasis>but</emphasis> brace yourself for instant failure. There's a high "
9038 "probability that trying to visit this URL will fail, and there are many "
9039 "possible reasons for this. In fact, you're likely to stumble over almost "
9040 "every one of the possible errors below, so please read carefully. The "
9041 "following are all of the problems I ran into on a system running Fedora 7, "
9042 "with a fresh installation of Apache, and a user account that I created "
9043 "specially to perform this exercise."
9044 msgstr ""
9046 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9047 #: ../en/ch06-collab.xml:1042
9048 msgid ""
9049 "Your web server may have per-user directories disabled. If you're using "
9050 "Apache, search your config file for a <literal>UserDir</literal> directive. "
9051 "If there's none present, per-user directories will be disabled. If one "
9052 "exists, but its value is <literal>disabled</literal>, then per-user "
9053 "directories will be disabled. Otherwise, the string after <literal>UserDir</"
9054 "literal> gives the name of the subdirectory that Apache will look in under "
9055 "your home directory, for example <filename class=\"directory\">public_html</"
9056 "filename>."
9057 msgstr ""
9059 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9060 #: ../en/ch06-collab.xml:1053
9061 msgid ""
9062 "Your file access permissions may be too restrictive. The web server must be "
9063 "able to traverse your home directory and directories under your <filename "
9064 "class=\"directory\">public_html</filename> directory, and read files under "
9065 "the latter too. Here's a quick recipe to help you to make your permissions "
9066 "more appropriate."
9067 msgstr ""
9069 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9070 #: ../en/ch06-collab.xml:1063
9071 msgid ""
9072 "The other possibility with permissions is that you might get a completely "
9073 "empty window when you try to load the script. In this case, it's likely that "
9074 "your access permissions are <emphasis>too permissive</emphasis>. Apache's "
9075 "<literal>suexec</literal> subsystem won't execute a script that's group- or "
9076 "world-writable, for example."
9077 msgstr ""
9079 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9080 #: ../en/ch06-collab.xml:1070
9081 msgid ""
9082 "Your web server may be configured to disallow execution of CGI programs in "
9083 "your per-user web directory. Here's Apache's default per-user configuration "
9084 "from my Fedora system."
9085 msgstr ""
9087 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9088 #: ../en/ch06-collab.xml:1077
9089 msgid ""
9090 "If you find a similar-looking <literal>Directory</literal> group in your "
9091 "Apache configuration, the directive to look at inside it is <literal>Options</"
9092 "literal>. Add <literal>ExecCGI</literal> to the end of this list if it's "
9093 "missing, and restart the web server."
9094 msgstr ""
9096 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9097 #: ../en/ch06-collab.xml:1084
9098 msgid ""
9099 "If you find that Apache serves you the text of the CGI script instead of "
9100 "executing it, you may need to either uncomment (if already present) or add a "
9101 "directive like this."
9102 msgstr ""
9104 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9105 #: ../en/ch06-collab.xml:1090
9106 msgid ""
9107 "The next possibility is that you might be served with a colourful Python "
9108 "backtrace claiming that it can't import a <literal>mercurial</literal>-"
9109 "related module. This is actually progress! The server is now capable of "
9110 "executing your CGI script. This error is only likely to occur if you're "
9111 "running a private installation of Mercurial, instead of a system-wide "
9112 "version. Remember that the web server runs the CGI program without any of "
9113 "the environment variables that you take for granted in an interactive "
9114 "session. If this error happens to you, edit your copy of <filename role="
9115 "\"special\">hgweb.cgi</filename> and follow the directions inside it to "
9116 "correctly set your <envar>PYTHONPATH</envar> environment variable."
9117 msgstr ""
9119 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9120 #: ../en/ch06-collab.xml:1104
9121 msgid ""
9122 "Finally, you are <emphasis>certain</emphasis> to be served with another "
9123 "colourful Python backtrace: this one will complain that it can't find "
9124 "<filename class=\"directory\">/path/to/repository</filename>. Edit your "
9125 "<filename role=\"special\">hgweb.cgi</filename> script and replace the "
9126 "<filename class=\"directory\">/path/to/repository</filename> string with the "
9127 "complete path to the repository you want to serve up."
9128 msgstr ""
9130 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9131 #: ../en/ch06-collab.xml:1114
9132 msgid ""
9133 "At this point, when you try to reload the page, you should be presented with "
9134 "a nice HTML view of your repository's history. Whew!"
9135 msgstr ""
9137 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
9138 #: ../en/ch06-collab.xml:1120
9139 msgid "Configuring lighttpd"
9140 msgstr "配置 lighttpd"
9142 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9143 #: ../en/ch06-collab.xml:1122
9144 msgid ""
9145 "To be exhaustive in my experiments, I tried configuring the increasingly "
9146 "popular <literal>lighttpd</literal> web server to serve the same repository "
9147 "as I described with Apache above. I had already overcome all of the problems "
9148 "I outlined with Apache, many of which are not server-specific. As a result, "
9149 "I was fairly sure that my file and directory permissions were good, and that "
9150 "my <filename role=\"special\">hgweb.cgi</filename> script was properly edited."
9151 msgstr ""
9153 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9154 #: ../en/ch06-collab.xml:1132
9155 msgid ""
9156 "Once I had Apache running, getting <literal>lighttpd</literal> to serve the "
9157 "repository was a snap (in other words, even if you're trying to use "
9158 "<literal>lighttpd</literal>, you should read the Apache section). I first "
9159 "had to edit the <literal>mod_access</literal> section of its config file to "
9160 "enable <literal>mod_cgi</literal> and <literal>mod_userdir</literal>, both of "
9161 "which were disabled by default on my system. I then added a few lines to the "
9162 "end of the config file, to configure these modules."
9163 msgstr ""
9165 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9166 #: ../en/ch06-collab.xml:1144
9167 msgid ""
9168 "With this done, <literal>lighttpd</literal> ran immediately for me. If I had "
9169 "configured <literal>lighttpd</literal> before Apache, I'd almost certainly "
9170 "have run into many of the same system-level configuration problems as I did "
9171 "with Apache. However, I found <literal>lighttpd</literal> to be noticeably "
9172 "easier to configure than Apache, even though I've used Apache for over a "
9173 "decade, and this was my first exposure to <literal>lighttpd</literal>."
9174 msgstr ""
9176 #. type: Content of: <book><chapter><sect1><sect2><title>
9177 #: ../en/ch06-collab.xml:1157
9178 msgid "Sharing multiple repositories with one CGI script"
9179 msgstr "使用一个 CGI 脚本共享多个版本库"
9181 #. type: Content of: <book><chapter><sect1><sect2><para>
9182 #: ../en/ch06-collab.xml:1159
9183 msgid ""
9184 "The <filename role=\"special\">hgweb.cgi</filename> script only lets you "
9185 "publish a single repository, which is an annoying restriction. If you want "
9186 "to publish more than one without wracking yourself with multiple copies of "
9187 "the same script, each with different names, a better choice is to use the "
9188 "<filename role=\"special\">hgwebdir.cgi</filename> script."
9189 msgstr ""
9191 #. type: Content of: <book><chapter><sect1><sect2><para>
9192 #: ../en/ch06-collab.xml:1167
9193 msgid ""
9194 "The procedure to configure <filename role=\"special\">hgwebdir.cgi</filename> "
9195 "is only a little more involved than for <filename role=\"special\">hgweb.cgi</"
9196 "filename>. First, you must obtain a copy of the script. If you don't have "
9197 "one handy, you can download a copy from the master Mercurial repository at "
9198 "<ulink url=\"http://www.selenic.com/repo/hg/raw-file/tip/hgwebdir.cgi"
9199 "\">http://www.selenic.com/repo/hg/raw-file/tip/hgwebdir.cgi</ulink>."
9200 msgstr ""
9202 #. type: Content of: <book><chapter><sect1><sect2><para>
9203 #: ../en/ch06-collab.xml:1182
9204 msgid ""
9205 "With basic configuration out of the way, try to visit <literal>http://"
9206 "myhostname/~myuser/hgwebdir.cgi</literal> in your\tbrowser. It should "
9207 "display an empty list of repositories. If you get a blank window or error "
9208 "message, try walking through the list of potential problems in <xref linkend="
9209 "\"sec:collab:wtf\"/>."
9210 msgstr ""
9212 #. type: Content of: <book><chapter><sect1><sect2><para>
9213 #: ../en/ch06-collab.xml:1190
9214 msgid ""
9215 "The <filename role=\"special\">hgwebdir.cgi</filename> script relies on an "
9216 "external configuration file. By default, it searches for a file named "
9217 "<filename role=\"special\">hgweb.config</filename> in the same directory as "
9218 "itself. You'll need to create this file, and make it world-readable. The "
9219 "format of the file is similar to a Windows <quote>ini</quote> file, as "
9220 "understood by Python's <literal>ConfigParser</literal> <citation>web:"
9221 "configparser</citation> module."
9222 msgstr ""
9224 #. type: Content of: <book><chapter><sect1><sect2><para>
9225 #: ../en/ch06-collab.xml:1200
9226 msgid ""
9227 "The easiest way to configure <filename role=\"special\">hgwebdir.cgi</"
9228 "filename> is with a section named <literal>collections</literal>. This will "
9229 "automatically publish <emphasis>every</emphasis> repository under the "
9230 "directories you name. The section should look like this:"
9231 msgstr ""
9233 #. type: Content of: <book><chapter><sect1><sect2><para>
9234 #: ../en/ch06-collab.xml:1208
9235 msgid ""
9236 "Mercurial interprets this by looking at the directory name on the "
9237 "<emphasis>right</emphasis> hand side of the <quote><literal>=</literal></"
9238 "quote> sign; finding repositories in that directory hierarchy; and using the "
9239 "text on the <emphasis>left</emphasis> to strip off matching text from the "
9240 "names it will actually list in the web interface. The remaining component of "
9241 "a path after this stripping has occurred is called a <quote>virtual path</"
9242 "quote>."
9243 msgstr ""
9245 #. type: Content of: <book><chapter><sect1><sect2><para>
9246 #: ../en/ch06-collab.xml:1217
9247 msgid ""
9248 "Given the example above, if we have a repository whose local path is "
9249 "<filename class=\"directory\">/my/root/this/repo</filename>, the CGI script "
9250 "will strip the leading <filename class=\"directory\">/my/root</filename> from "
9251 "the name, and publish the repository with a virtual path of <filename class="
9252 "\"directory\">this/repo</filename>. If the base URL for our CGI script is "
9253 "<literal>http://myhostname/~myuser/hgwebdir.cgi</literal>, the complete URL "
9254 "for that repository will be <literal>http://myhostname/~myuser/hgwebdir.cgi/"
9255 "this/repo</literal>."
9256 msgstr ""
9258 #. type: Content of: <book><chapter><sect1><sect2><para>
9259 #: ../en/ch06-collab.xml:1229
9260 msgid ""
9261 "If we replace <filename class=\"directory\">/my/root</filename> on the left "
9262 "hand side of this example with <filename class=\"directory\">/my</filename>, "
9263 "then <filename role=\"special\">hgwebdir.cgi</filename> will only strip off "
9264 "<filename class=\"directory\">/my</filename> from the repository name, and "
9265 "will give us a virtual path of <filename class=\"directory\">root/this/repo</"
9266 "filename> instead of <filename class=\"directory\">this/repo</filename>."
9267 msgstr ""
9269 #. type: Content of: <book><chapter><sect1><sect2><para>
9270 #: ../en/ch06-collab.xml:1239
9271 msgid ""
9272 "The <filename role=\"special\">hgwebdir.cgi</filename> script will "
9273 "recursively search each directory listed in the <literal>collections</"
9274 "literal> section of its configuration file, but it will <literal>not</"
9275 "literal> recurse into the repositories it finds."
9276 msgstr ""
9278 #. type: Content of: <book><chapter><sect1><sect2><para>
9279 #: ../en/ch06-collab.xml:1245
9280 msgid ""
9281 "The <literal>collections</literal> mechanism makes it easy to publish many "
9282 "repositories in a <quote>fire and forget</quote> manner. You only need to "
9283 "set up the CGI script and configuration file one time. Afterwards, you can "
9284 "publish or unpublish a repository at any time by simply moving it into, or "
9285 "out of, the directory hierarchy in which you've configured <filename role="
9286 "\"special\">hgwebdir.cgi</filename> to look."
9287 msgstr ""
9289 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
9290 #: ../en/ch06-collab.xml:1255
9291 msgid "Explicitly specifying which repositories to publish"
9292 msgstr "明确指出要发布的版本库"
9294 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9295 #: ../en/ch06-collab.xml:1258
9296 msgid ""
9297 "In addition to the <literal>collections</literal> mechanism, the <filename "
9298 "role=\"special\">hgwebdir.cgi</filename> script allows you to publish a "
9299 "specific list of repositories. To do so, create a <literal>paths</literal> "
9300 "section, with contents of the following form."
9301 msgstr ""
9303 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9304 #: ../en/ch06-collab.xml:1267
9305 msgid ""
9306 "In this case, the virtual path (the component that will appear in a URL) is "
9307 "on the left hand side of each definition, while the path to the repository is "
9308 "on the right. Notice that there does not need to be any relationship between "
9309 "the virtual path you choose and the location of a repository in your "
9310 "filesystem."
9311 msgstr ""
9313 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9314 #: ../en/ch06-collab.xml:1274
9315 msgid ""
9316 "If you wish, you can use both the <literal>collections</literal> and "
9317 "<literal>paths</literal> mechanisms simultaneously in a single configuration "
9318 "file."
9319 msgstr ""
9321 #. type: Content of: <book><chapter><sect1><sect2><sect3><note><title>
9322 #: ../en/ch06-collab.xml:1280
9323 msgid "Beware duplicate virtual paths"
9324 msgstr ""
9326 #. type: Content of: <book><chapter><sect1><sect2><sect3><note><para>
9327 #: ../en/ch06-collab.xml:1282
9328 msgid ""
9329 "If several repositories have the same virtual path, <filename role=\"special"
9330 "\">hgwebdir.cgi</filename> will not report an error. Instead, it will behave "
9331 "unpredictably."
9332 msgstr ""
9334 #. type: Content of: <book><chapter><sect1><sect2><title>
9335 #: ../en/ch06-collab.xml:1291
9336 msgid "Downloading source archives"
9337 msgstr "下载源代码档案包"
9339 #. type: Content of: <book><chapter><sect1><sect2><para>
9340 #: ../en/ch06-collab.xml:1293
9341 msgid ""
9342 "Mercurial's web interface lets users download an archive of any revision. "
9343 "This archive will contain a snapshot of the working directory as of that "
9344 "revision, but it will not contain a copy of the repository data."
9345 msgstr ""
9347 #. type: Content of: <book><chapter><sect1><sect2><para>
9348 #: ../en/ch06-collab.xml:1298
9349 msgid ""
9350 "By default, this feature is not enabled. To enable it, you'll need to add an "
9351 "<envar role=\"rc-item-web\">allow_archive</envar> item to the <literal role="
9352 "\"rc-web\">web</literal> section of your <filename role=\"special\">~/.hgrc</"
9353 "filename>; see below for details."
9354 msgstr ""
9356 #. type: Content of: <book><chapter><sect1><sect2><title>
9357 #: ../en/ch06-collab.xml:1305
9358 msgid "Web configuration options"
9359 msgstr "Web 配置选项"
9361 #. type: Content of: <book><chapter><sect1><sect2><para>
9362 #: ../en/ch06-collab.xml:1307
9363 msgid ""
9364 "Mercurial's web interfaces (the <command role=\"hg-cmd\">hg serve</command> "
9365 "command, and the <filename role=\"special\">hgweb.cgi</filename> and "
9366 "<filename role=\"special\">hgwebdir.cgi</filename> scripts) have a number of "
9367 "configuration options that you can set. These belong in a section named "
9368 "<literal role=\"rc-web\">web</literal>."
9369 msgstr ""
9371 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9372 #: ../en/ch06-collab.xml:1315
9373 msgid ""
9374 "<envar role=\"rc-item-web\">allow_archive</envar>: Determines which (if any) "
9375 "archive download mechanisms Mercurial supports. If you enable this feature, "
9376 "users of the web interface will be able to download an archive of whatever "
9377 "revision of a repository they are viewing. To enable the archive feature, "
9378 "this item must take the form of a sequence of words drawn from the list below."
9379 msgstr ""
9381 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
9382 #: ../en/ch06-collab.xml:1324
9383 msgid ""
9384 "<literal>bz2</literal>: A <command>tar</command> archive, compressed using "
9385 "<literal>bzip2</literal> compression. This has the best compression ratio, "
9386 "but uses the most CPU time on the server."
9387 msgstr ""
9389 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
9390 #: ../en/ch06-collab.xml:1330
9391 msgid ""
9392 "<literal>gz</literal>: A <command>tar</command> archive, compressed using "
9393 "<literal>gzip</literal> compression."
9394 msgstr ""
9396 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
9397 #: ../en/ch06-collab.xml:1334
9398 msgid ""
9399 "<literal>zip</literal>: A <command>zip</command> archive, compressed using "
9400 "LZW compression. This format has the worst compression ratio, but is widely "
9401 "used in the Windows world."
9402 msgstr ""
9404 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9405 #: ../en/ch06-collab.xml:1340
9406 msgid ""
9407 "If you provide an empty list, or don't have an <envar role=\"rc-item-web"
9408 "\">allow_archive</envar> entry at all, this feature will be disabled. Here "
9409 "is an example of how to enable all three supported formats."
9410 msgstr ""
9412 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9413 #: ../en/ch06-collab.xml:1347
9414 msgid ""
9415 "<envar role=\"rc-item-web\">allowpull</envar>: Boolean. Determines whether "
9416 "the web interface allows remote users to <command role=\"hg-cmd\">hg pull</"
9417 "command> and <command role=\"hg-cmd\">hg clone</command> this repository over "
9418 "HTTP. If set to <literal>no</literal> or <literal>false</literal>, only the "
9419 "<quote>human-oriented</quote> portion of the web interface is available."
9420 msgstr ""
9422 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9423 #: ../en/ch06-collab.xml:1356
9424 msgid ""
9425 "<envar role=\"rc-item-web\">contact</envar>: String. A free-form (but "
9426 "preferably brief) string identifying the person or group in charge of the "
9427 "repository. This often contains the name and email address of a person or "
9428 "mailing list. It often makes sense to place this entry in a repository's own "
9429 "<filename role=\"special\">.hg/hgrc</filename> file, but it can make sense to "
9430 "use in a global <filename role=\"special\">~/.hgrc</filename> if every "
9431 "repository has a single maintainer."
9432 msgstr ""
9434 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9435 #: ../en/ch06-collab.xml:1367
9436 msgid ""
9437 "<envar role=\"rc-item-web\">maxchanges</envar>: Integer. The default maximum "
9438 "number of changesets to display in a single page of output."
9439 msgstr ""
9441 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9442 #: ../en/ch06-collab.xml:1371
9443 msgid ""
9444 "<envar role=\"rc-item-web\">maxfiles</envar>: Integer. The default maximum "
9445 "number of modified files to display in a single page of output."
9446 msgstr ""
9448 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9449 #: ../en/ch06-collab.xml:1375
9450 msgid ""
9451 "<envar role=\"rc-item-web\">stripes</envar>: Integer. If the web interface "
9452 "displays alternating <quote>stripes</quote> to make it easier to visually "
9453 "align rows when you are looking at a table, this number controls the number "
9454 "of rows in each stripe."
9455 msgstr ""
9457 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9458 #: ../en/ch06-collab.xml:1381
9459 msgid ""
9460 "<envar role=\"rc-item-web\">style</envar>: Controls the template Mercurial "
9461 "uses to display the web interface. Mercurial ships with several web "
9462 "templates."
9463 msgstr ""
9465 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
9466 #: ../en/ch06-collab.xml:1387
9467 msgid "<literal>coal</literal> is monochromatic."
9468 msgstr ""
9470 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
9471 #: ../en/ch06-collab.xml:1390
9472 msgid ""
9473 "<literal>gitweb</literal> emulates the visual style of git's web interface."
9474 msgstr ""
9476 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
9477 #: ../en/ch06-collab.xml:1394
9478 msgid "<literal>monoblue</literal> uses solid blues and greys."
9479 msgstr ""
9481 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
9482 #: ../en/ch06-collab.xml:1398
9483 msgid "<literal>paper</literal> is the default."
9484 msgstr ""
9486 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
9487 #: ../en/ch06-collab.xml:1401
9488 msgid "<literal>spartan</literal> was the default for a long time."
9489 msgstr ""
9491 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9492 #: ../en/ch06-collab.xml:1405
9493 msgid ""
9494 "You can also specify a custom template of your own; see <xref linkend=\"chap:"
9495 "template\"/> for details. Here, you can see how to enable the "
9496 "<literal>gitweb</literal> style."
9497 msgstr ""
9499 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9500 #: ../en/ch06-collab.xml:1413
9501 msgid ""
9502 "<envar role=\"rc-item-web\">templates</envar>: Path. The directory in which "
9503 "to search for template files. By default, Mercurial searches in the "
9504 "directory in which it was installed."
9505 msgstr ""
9507 #. type: Content of: <book><chapter><sect1><sect2><para>
9508 #: ../en/ch06-collab.xml:1418
9509 msgid ""
9510 "If you are using <filename role=\"special\">hgwebdir.cgi</filename>, you can "
9511 "place a few configuration items in a <literal role=\"rc-web\">web</literal> "
9512 "section of the <filename role=\"special\">hgweb.config</filename> file "
9513 "instead of a <filename role=\"special\">~/.hgrc</filename> file, for "
9514 "convenience. These items are <envar role=\"rc-item-web\">motd</envar> and "
9515 "<envar role=\"rc-item-web\">style</envar>."
9516 msgstr ""
9518 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
9519 #: ../en/ch06-collab.xml:1429
9520 msgid "Options specific to an individual repository"
9521 msgstr "针对单个版本库的选项"
9523 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9524 #: ../en/ch06-collab.xml:1431
9525 msgid ""
9526 "A few <literal role=\"rc-web\">web</literal> configuration items ought to be "
9527 "placed in a repository's local <filename role=\"special\">.hg/hgrc</"
9528 "filename>, rather than a user's or global <filename role=\"special\">~/.hgrc</"
9529 "filename>."
9530 msgstr ""
9532 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
9533 #: ../en/ch06-collab.xml:1436
9534 msgid ""
9535 "<envar role=\"rc-item-web\">description</envar>: String. A free-form (but "
9536 "preferably brief) string that describes the contents or purpose of the "
9537 "repository."
9538 msgstr ""
9540 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
9541 #: ../en/ch06-collab.xml:1441
9542 msgid ""
9543 "<envar role=\"rc-item-web\">name</envar>: String. The name to use for the "
9544 "repository in the web interface. This overrides the default name, which is "
9545 "the last component of the repository's path."
9546 msgstr ""
9548 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
9549 #: ../en/ch06-collab.xml:1449
9550 msgid ""
9551 "Options specific to the <command role=\"hg-cmd\">hg serve</command> command"
9552 msgstr "命令 <command role=\"hg-cmd\">hg serve</command> 的选项"
9554 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9555 #: ../en/ch06-collab.xml:1452
9556 msgid ""
9557 "Some of the items in the <literal role=\"rc-web\">web</literal> section of a "
9558 "<filename role=\"special\">~/.hgrc</filename> file are only for use with the "
9559 "<command role=\"hg-cmd\">hg serve</command> command."
9560 msgstr ""
9562 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
9563 #: ../en/ch06-collab.xml:1458
9564 msgid ""
9565 "<envar role=\"rc-item-web\">accesslog</envar>: Path. The name of a file into "
9566 "which to write an access log. By default, the <command role=\"hg-cmd\">hg "
9567 "serve</command> command writes this information to standard output, not to a "
9568 "file. Log entries are written in the standard <quote>combined</quote> file "
9569 "format used by almost all web servers."
9570 msgstr ""
9572 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
9573 #: ../en/ch06-collab.xml:1466
9574 msgid ""
9575 "<envar role=\"rc-item-web\">address</envar>: String. The local address on "
9576 "which the server should listen for incoming connections. By default, the "
9577 "server listens on all addresses."
9578 msgstr ""
9580 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
9581 #: ../en/ch06-collab.xml:1471
9582 msgid ""
9583 "<envar role=\"rc-item-web\">errorlog</envar>: Path. The name of a file into "
9584 "which to write an error log. By default, the <command role=\"hg-cmd\">hg "
9585 "serve</command> command writes this information to standard error, not to a "
9586 "file."
9587 msgstr ""
9589 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
9590 #: ../en/ch06-collab.xml:1477
9591 msgid ""
9592 "<envar role=\"rc-item-web\">ipv6</envar>: Boolean. Whether to use the IPv6 "
9593 "protocol. By default, IPv6 is not used."
9594 msgstr ""
9596 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
9597 #: ../en/ch06-collab.xml:1481
9598 msgid ""
9599 "<envar role=\"rc-item-web\">port</envar>: Integer. The TCP port number on "
9600 "which the server should listen. The default port number used is 8000."
9601 msgstr ""
9603 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
9604 #: ../en/ch06-collab.xml:1488
9605 msgid ""
9606 "Choosing the right <filename role=\"special\">~/.hgrc</filename> file to add "
9607 "<literal role=\"rc-web\">web</literal> items to"
9608 msgstr ""
9609 "选择正确的 <filename role=\"special\"> ~/.hgrc</filename> 文件增加到 <literal "
9610 "role=\"rc-web\">web</literal> 条目"
9612 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9613 #: ../en/ch06-collab.xml:1492
9614 msgid ""
9615 "It is important to remember that a web server like Apache or "
9616 "<literal>lighttpd</literal> will run under a user ID that is different to "
9617 "yours. CGI scripts run by your server, such as <filename role=\"special"
9618 "\">hgweb.cgi</filename>, will usually also run under that user ID."
9619 msgstr ""
9621 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9622 #: ../en/ch06-collab.xml:1499
9623 msgid ""
9624 "If you add <literal role=\"rc-web\">web</literal> items to your own personal "
9625 "<filename role=\"special\">~/.hgrc</filename> file, CGI scripts won't read "
9626 "that <filename role=\"special\">~/.hgrc</filename> file. Those settings will "
9627 "thus only affect the behavior of the <command role=\"hg-cmd\">hg serve</"
9628 "command> command when you run it. To cause CGI scripts to see your settings, "
9629 "either create a <filename role=\"special\">~/.hgrc</filename> file in the "
9630 "home directory of the user ID that runs your web server, or add those "
9631 "settings to a system-wide <filename role=\"special\">hgrc</filename> file."
9632 msgstr ""
9634 #. type: Content of: <book><chapter><sect1><title>
9635 #: ../en/ch06-collab.xml:1514
9636 msgid "System-wide configuration"
9637 msgstr "全局配置"
9639 #. type: Content of: <book><chapter><sect1><para>
9640 #: ../en/ch06-collab.xml:1516
9641 msgid ""
9642 "On Unix-like systems shared by multiple users (such as a server to which "
9643 "people publish changes), it often makes sense to set up some global default "
9644 "behaviors, such as what theme to use in web interfaces."
9645 msgstr ""
9647 #. type: Content of: <book><chapter><sect1><para>
9648 #: ../en/ch06-collab.xml:1521
9649 msgid ""
9650 "If a file named <filename>/etc/mercurial/hgrc</filename> exists, Mercurial "
9651 "will read it at startup time and apply any configuration settings it finds in "
9652 "that file. It will also look for files ending in a <literal>.rc</literal> "
9653 "extension in a directory named <filename>/etc/mercurial/hgrc.d</filename>, "
9654 "and apply any configuration settings it finds in each of those files."
9655 msgstr ""
9657 #. type: Content of: <book><chapter><sect1><sect2><title>
9658 #: ../en/ch06-collab.xml:1530
9659 msgid "Making Mercurial more trusting"
9660 msgstr "让 Mercurial 更可信"
9662 #. type: Content of: <book><chapter><sect1><sect2><para>
9663 #: ../en/ch06-collab.xml:1532
9664 msgid ""
9665 "One situation in which a global <filename>hgrc</filename> can be useful is if "
9666 "users are pulling changes owned by other users. By default, Mercurial will "
9667 "not trust most of the configuration items in a <filename>.hg/hgrc</filename> "
9668 "file inside a repository that is owned by a different user. If we clone or "
9669 "pull changes from such a repository, Mercurial will print a warning stating "
9670 "that it does not trust their <filename>.hg/hgrc</filename>."
9671 msgstr ""
9673 #. type: Content of: <book><chapter><sect1><sect2><para>
9674 #: ../en/ch06-collab.xml:1541
9675 msgid ""
9676 "If everyone in a particular Unix group is on the same team and "
9677 "<emphasis>should</emphasis> trust each other's configuration settings, or we "
9678 "want to trust particular users, we can override Mercurial's skeptical "
9679 "defaults by creating a system-wide <filename>hgrc</filename> file such as the "
9680 "following:"
9681 msgstr ""
9683 #. type: Content of: <book><chapter><title>
9684 #: ../en/ch07-filenames.xml:5
9685 msgid "File names and pattern matching"
9686 msgstr "文件名称与模式匹配"
9688 #. type: Content of: <book><chapter><para>
9689 #: ../en/ch07-filenames.xml:7
9690 msgid ""
9691 "Mercurial provides mechanisms that let you work with file names in a "
9692 "consistent and expressive way."
9693 msgstr ""
9695 #. type: Content of: <book><chapter><sect1><title>
9696 #: ../en/ch07-filenames.xml:11
9697 msgid "Simple file naming"
9698 msgstr "简单文件名称"
9700 #. type: Content of: <book><chapter><sect1><para>
9701 #: ../en/ch07-filenames.xml:13
9702 msgid ""
9703 "Mercurial uses a unified piece of machinery <quote>under the hood</quote> to "
9704 "handle file names. Every command behaves uniformly with respect to file "
9705 "names. The way in which commands work with file names is as follows."
9706 msgstr ""
9708 #. type: Content of: <book><chapter><sect1><para>
9709 #: ../en/ch07-filenames.xml:18
9710 msgid ""
9711 "If you explicitly name real files on the command line, Mercurial works with "
9712 "exactly those files, as you would expect. &interaction.filenames.files;"
9713 msgstr ""
9716 #. type: Content of: <book><chapter><sect1><para>
9717 #: ../en/ch07-filenames.xml:22
9718 msgid ""
9719 "When you provide a directory name, Mercurial will interpret this as "
9720 "<quote>operate on every file in this directory and its subdirectories</"
9721 "quote>. Mercurial traverses the files and subdirectories in a directory in "
9722 "alphabetical order. When it encounters a subdirectory, it will traverse that "
9723 "subdirectory before continuing with the current directory."
9724 msgstr ""
9726 #. type: Content of: <book><chapter><sect1><title>
9727 #: ../en/ch07-filenames.xml:33
9728 msgid "Running commands without any file names"
9729 msgstr "不提供文件名称的执行命令"
9731 #. type: Content of: <book><chapter><sect1><para>
9732 #: ../en/ch07-filenames.xml:35
9733 msgid ""
9734 "Mercurial's commands that work with file names have useful default behaviors "
9735 "when you invoke them without providing any file names or patterns. What kind "
9736 "of behavior you should expect depends on what the command does. Here are a "
9737 "few rules of thumb you can use to predict what a command is likely to do if "
9738 "you don't give it any names to work with."
9739 msgstr ""
9741 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
9742 #: ../en/ch07-filenames.xml:42
9743 msgid ""
9744 "Most commands will operate on the entire working directory. This is what the "
9745 "<command role=\"hg-cmd\">hg add</command> command does, for example."
9746 msgstr ""
9748 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
9749 #: ../en/ch07-filenames.xml:46
9750 msgid ""
9751 "If the command has effects that are difficult or impossible to reverse, it "
9752 "will force you to explicitly provide at least one name or pattern (see "
9753 "below). This protects you from accidentally deleting files by running "
9754 "<command role=\"hg-cmd\">hg remove</command> with no arguments, for example."
9755 msgstr ""
9757 #. type: Content of: <book><chapter><sect1><para>
9758 #: ../en/ch07-filenames.xml:54
9759 msgid ""
9760 "It's easy to work around these default behaviors if they don't suit you. If "
9761 "a command normally operates on the whole working directory, you can invoke it "
9762 "on just the current directory and its subdirectories by giving it the name "
9763 "<quote><filename class=\"directory\">.</filename></quote>."
9764 msgstr ""
9767 #. type: Content of: <book><chapter><sect1><para>
9768 #: ../en/ch07-filenames.xml:62
9769 msgid ""
9770 "Along the same lines, some commands normally print file names relative to the "
9771 "root of the repository, even if you're invoking them from a subdirectory. "
9772 "Such a command will print file names relative to your subdirectory if you "
9773 "give it explicit names. Here, we're going to run <command role=\"hg-cmd\">hg "
9774 "status</command> from a subdirectory, and get it to operate on the entire "
9775 "working directory while printing file names relative to our subdirectory, by "
9776 "passing it the output of the <command role=\"hg-cmd\">hg root</command> "
9777 "command."
9778 msgstr ""
9780 #. type: Content of: <book><chapter><sect1><title>
9781 #: ../en/ch07-filenames.xml:76
9782 msgid "Telling you what's going on"
9783 msgstr "告诉你正在做什么"
9785 #. type: Content of: <book><chapter><sect1><para>
9786 #: ../en/ch07-filenames.xml:78
9787 msgid ""
9788 "The <command role=\"hg-cmd\">hg add</command> example in the preceding "
9789 "section illustrates something else that's helpful about Mercurial commands. "
9790 "If a command operates on a file that you didn't name explicitly on the "
9791 "command line, it will usually print the name of the file, so that you will "
9792 "not be surprised what's going on."
9793 msgstr ""
9795 #. type: Content of: <book><chapter><sect1><para>
9796 #: ../en/ch07-filenames.xml:85
9797 msgid ""
9798 "The principle here is of <emphasis>least surprise</emphasis>. If you've "
9799 "exactly named a file on the command line, there's no point in repeating it "
9800 "back at you. If Mercurial is acting on a file <emphasis>implicitly</"
9801 "emphasis>, e.g. because you provided no names, or a directory, or a pattern "
9802 "(see below), it is safest to tell you what files it's operating on."
9803 msgstr ""
9805 #. type: Content of: <book><chapter><sect1><para>
9806 #: ../en/ch07-filenames.xml:92
9807 msgid ""
9808 "For commands that behave this way, you can silence them using the <option "
9809 "role=\"hg-opt-global\">-q</option> option. You can also get them to print "
9810 "the name of every file, even those you've named explicitly, using the <option "
9811 "role=\"hg-opt-global\">-v</option> option."
9812 msgstr ""
9814 #. type: Content of: <book><chapter><sect1><title>
9815 #: ../en/ch07-filenames.xml:100
9816 msgid "Using patterns to identify files"
9817 msgstr "使用模式标识文件"
9819 #. type: Content of: <book><chapter><sect1><para>
9820 #: ../en/ch07-filenames.xml:102
9821 msgid ""
9822 "In addition to working with file and directory names, Mercurial lets you use "
9823 "<emphasis>patterns</emphasis> to identify files. Mercurial's pattern "
9824 "handling is expressive."
9825 msgstr ""
9827 #. type: Content of: <book><chapter><sect1><para>
9828 #: ../en/ch07-filenames.xml:106
9829 msgid ""
9830 "On Unix-like systems (Linux, MacOS, etc.), the job of matching file names to "
9831 "patterns normally falls to the shell. On these systems, you must explicitly "
9832 "tell Mercurial that a name is a pattern. On Windows, the shell does not "
9833 "expand patterns, so Mercurial will automatically identify names that are "
9834 "patterns, and expand them for you."
9835 msgstr ""
9837 #. type: Content of: <book><chapter><sect1><para>
9838 #: ../en/ch07-filenames.xml:113
9839 msgid ""
9840 "To provide a pattern in place of a regular name on the command line, the "
9841 "mechanism is simple:"
9842 msgstr ""
9844 #. type: Content of: <book><chapter><sect1><para>
9845 #: ../en/ch07-filenames.xml:116
9846 msgid ""
9847 "That is, a pattern is identified by a short text string that says what kind "
9848 "of pattern this is, followed by a colon, followed by the actual pattern."
9849 msgstr ""
9851 #. type: Content of: <book><chapter><sect1><para>
9852 #: ../en/ch07-filenames.xml:120
9853 msgid ""
9854 "Mercurial supports two kinds of pattern syntax. The most frequently used is "
9855 "called <literal>glob</literal>; this is the same kind of pattern matching "
9856 "used by the Unix shell, and should be familiar to Windows command prompt "
9857 "users, too."
9858 msgstr ""
9860 #. type: Content of: <book><chapter><sect1><para>
9861 #: ../en/ch07-filenames.xml:125
9862 msgid ""
9863 "When Mercurial does automatic pattern matching on Windows, it uses "
9864 "<literal>glob</literal> syntax. You can thus omit the <quote><literal>glob:</"
9865 "literal></quote> prefix on Windows, but it's safe to use it, too."
9866 msgstr ""
9868 #. type: Content of: <book><chapter><sect1><para>
9869 #: ../en/ch07-filenames.xml:130
9870 msgid ""
9871 "The <literal>re</literal> syntax is more powerful; it lets you specify "
9872 "patterns using regular expressions, also known as regexps."
9873 msgstr ""
9875 #. type: Content of: <book><chapter><sect1><para>
9876 #: ../en/ch07-filenames.xml:134
9877 msgid ""
9878 "By the way, in the examples that follow, notice that I'm careful to wrap all "
9879 "of my patterns in quote characters, so that they won't get expanded by the "
9880 "shell before Mercurial sees them."
9881 msgstr ""
9883 #. type: Content of: <book><chapter><sect1><sect2><title>
9884 #: ../en/ch07-filenames.xml:140
9885 msgid "Shell-style <literal>glob</literal> patterns"
9886 msgstr "外壳风格的 <literal>glob</literal> 模式"
9888 #. type: Content of: <book><chapter><sect1><sect2><para>
9889 #: ../en/ch07-filenames.xml:142
9890 msgid ""
9891 "This is an overview of the kinds of patterns you can use when you're matching "
9892 "on glob patterns."
9893 msgstr ""
9896 #. type: Content of: <book><chapter><sect1><sect2><para>
9897 #: ../en/ch07-filenames.xml:145
9898 msgid ""
9899 "The <quote><literal>*</literal></quote> character matches any string, within "
9900 "a single directory."
9901 msgstr ""
9904 #. type: Content of: <book><chapter><sect1><sect2><para>
9905 #: ../en/ch07-filenames.xml:150
9906 msgid ""
9907 "The <quote><literal>**</literal></quote> pattern matches any string, and "
9908 "crosses directory boundaries. It's not a standard Unix glob token, but it's "
9909 "accepted by several popular Unix shells, and is very useful."
9910 msgstr ""
9913 #. type: Content of: <book><chapter><sect1><sect2><para>
9914 #: ../en/ch07-filenames.xml:157
9915 msgid ""
9916 "The <quote><literal>?</literal></quote> pattern matches any single character."
9917 msgstr ""
9919 #. type: Content of: <book><chapter><sect1><sect2><para>
9920 #: ../en/ch07-filenames.xml:162
9921 msgid ""
9922 "The <quote><literal>[</literal></quote> character begins a "
9923 "<emphasis>character class</emphasis>. This matches any single character "
9924 "within the class. The class ends with a <quote><literal>]</literal></quote> "
9925 "character. A class may contain multiple <emphasis>range</emphasis>s of the "
9926 "form <quote><literal>a-f</literal></quote>, which is shorthand for "
9927 "<quote><literal>abcdef</literal></quote>."
9928 msgstr ""
9930 #. type: Content of: <book><chapter><sect1><sect2><para>
9931 #: ../en/ch07-filenames.xml:172
9932 msgid ""
9933 "If the first character after the <quote><literal>[</literal></quote> in a "
9934 "character class is a <quote><literal>!</literal></quote>, it "
9935 "<emphasis>negates</emphasis> the class, making it match any single character "
9936 "not in the class."
9937 msgstr ""
9939 #. type: Content of: <book><chapter><sect1><sect2><para>
9940 #: ../en/ch07-filenames.xml:178
9941 msgid ""
9942 "A <quote><literal>{</literal></quote> begins a group of subpatterns, where "
9943 "the whole group matches if any subpattern in the group matches. The "
9944 "<quote><literal>,</literal></quote> character separates subpatterns, and "
9945 "<quote><literal>}</literal></quote> ends the group."
9946 msgstr ""
9948 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
9949 #: ../en/ch07-filenames.xml:187
9950 msgid "Watch out!"
9951 msgstr "千万小心!"
9954 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9955 #: ../en/ch07-filenames.xml:189
9956 msgid ""
9957 "Don't forget that if you want to match a pattern in any directory, you should "
9958 "not be using the <quote><literal>*</literal></quote> match-any token, as this "
9959 "will only match within one directory. Instead, use the <quote><literal>**</"
9960 "literal></quote> token. This small example illustrates the difference "
9961 "between the two."
9962 msgstr ""
9964 #. type: Content of: <book><chapter><sect1><sect2><title>
9965 #: ../en/ch07-filenames.xml:201
9966 msgid "Regular expression matching with <literal>re</literal> patterns"
9967 msgstr "使用 <literal>re</literal> 模式的正则表达式匹配"
9969 #. type: Content of: <book><chapter><sect1><sect2><para>
9970 #: ../en/ch07-filenames.xml:204
9971 msgid ""
9972 "Mercurial accepts the same regular expression syntax as the Python "
9973 "programming language (it uses Python's regexp engine internally). This is "
9974 "based on the Perl language's regexp syntax, which is the most popular dialect "
9975 "in use (it's also used in Java, for example)."
9976 msgstr ""
9978 #. type: Content of: <book><chapter><sect1><sect2><para>
9979 #: ../en/ch07-filenames.xml:210
9980 msgid ""
9981 "I won't discuss Mercurial's regexp dialect in any detail here, as regexps are "
9982 "not often used. Perl-style regexps are in any case already exhaustively "
9983 "documented on a multitude of web sites, and in many books. Instead, I will "
9984 "focus here on a few things you should know if you find yourself needing to "
9985 "use regexps with Mercurial."
9986 msgstr ""
9988 #. type: Content of: <book><chapter><sect1><sect2><para>
9989 #: ../en/ch07-filenames.xml:217
9990 msgid ""
9991 "A regexp is matched against an entire file name, relative to the root of the "
9992 "repository. In other words, even if you're already in subbdirectory "
9993 "<filename class=\"directory\">foo</filename>, if you want to match files "
9994 "under this directory, your pattern must start with <quote><literal>foo/</"
9995 "literal></quote>."
9996 msgstr ""
9998 #. type: Content of: <book><chapter><sect1><sect2><para>
9999 #: ../en/ch07-filenames.xml:224
10000 msgid ""
10001 "One thing to note, if you're familiar with Perl-style regexps, is that "
10002 "Mercurial's are <emphasis>rooted</emphasis>. That is, a regexp starts "
10003 "matching against the beginning of a string; it doesn't look for a match "
10004 "anywhere within the string. To match anywhere in a string, start your "
10005 "pattern with <quote><literal>.*</literal></quote>."
10006 msgstr ""
10008 #. type: Content of: <book><chapter><sect1><title>
10009 #: ../en/ch07-filenames.xml:234
10010 msgid "Filtering files"
10011 msgstr "过滤文件"
10013 #. type: Content of: <book><chapter><sect1><para>
10014 #: ../en/ch07-filenames.xml:236
10015 msgid ""
10016 "Not only does Mercurial give you a variety of ways to specify files; it lets "
10017 "you further winnow those files using <emphasis>filters</emphasis>. Commands "
10018 "that work with file names accept two filtering options."
10019 msgstr ""
10021 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10022 #: ../en/ch07-filenames.xml:241
10023 msgid ""
10024 "<option role=\"hg-opt-global\">-I</option>, or <option role=\"hg-opt-global"
10025 "\">--include</option>, lets you specify a pattern that file names must match "
10026 "in order to be processed."
10027 msgstr ""
10029 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10030 #: ../en/ch07-filenames.xml:246
10031 msgid ""
10032 "<option role=\"hg-opt-global\">-X</option>, or <option role=\"hg-opt-global"
10033 "\">--exclude</option>, gives you a way to <emphasis>avoid</emphasis> "
10034 "processing files, if they match this pattern."
10035 msgstr ""
10037 #. type: Content of: <book><chapter><sect1><para>
10038 #: ../en/ch07-filenames.xml:251
10039 msgid ""
10040 "You can provide multiple <option role=\"hg-opt-global\">-I</option> and "
10041 "<option role=\"hg-opt-global\">-X</option> options on the command line, and "
10042 "intermix them as you please. Mercurial interprets the patterns you provide "
10043 "using glob syntax by default (but you can use regexps if you need to)."
10044 msgstr ""
10046 #. type: Content of: <book><chapter><sect1><para>
10047 #: ../en/ch07-filenames.xml:258
10048 msgid ""
10049 "You can read a <option role=\"hg-opt-global\">-I</option> filter as "
10050 "<quote>process only the files that match this filter</quote>."
10051 msgstr ""
10053 #. type: Content of: <book><chapter><sect1><para>
10054 #: ../en/ch07-filenames.xml:264
10055 msgid ""
10056 "The <option role=\"hg-opt-global\">-X</option> filter is best read as "
10057 "<quote>process only the files that don't match this pattern</quote>."
10058 msgstr ""
10060 #. type: Content of: <book><chapter><sect1><title>
10061 #: ../en/ch07-filenames.xml:272
10062 msgid "Permanently ignoring unwanted files and directories"
10063 msgstr "始终忽略不需要的文件和目录"
10065 #. type: Content of: <book><chapter><sect1><para>
10066 #: ../en/ch07-filenames.xml:274
10067 msgid ""
10068 "When you create a new repository, the chances are that over time it will grow "
10069 "to contain files that ought to <emphasis>not</emphasis> be managed by "
10070 "Mercurial, but which you don't want to see listed every time you run "
10071 "<command>hg status</command>. For instance, <quote>build products</quote> "
10072 "are files that are created as part of a build but which should not be managed "
10073 "by a revision control system. The most common build products are output "
10074 "files produced by software tools such as compilers. As another example, many "
10075 "text editors litter a directory with lock files, temporary working files, and "
10076 "backup files, which it also makes no sense to manage."
10077 msgstr ""
10079 #. type: Content of: <book><chapter><sect1><para>
10080 #: ../en/ch07-filenames.xml:286
10081 msgid ""
10082 "To have Mercurial permanently ignore such files, create a file named "
10083 "<filename>.hgignore</filename> in the root of your repository. You "
10084 "<emphasis>should</emphasis> <command>hg add</command> this file so that it "
10085 "gets tracked with the rest of your repository contents, since your "
10086 "collaborators will probably find it useful too."
10087 msgstr ""
10089 #. type: Content of: <book><chapter><sect1><para>
10090 #: ../en/ch07-filenames.xml:293
10091 msgid ""
10092 "By default, the <filename>.hgignore</filename> file should contain a list of "
10093 "regular expressions, one per line. Empty lines are skipped. Most people "
10094 "prefer to describe the files they want to ignore using the <quote>glob</"
10095 "quote> syntax that we described above, so a typical <filename>.hgignore</"
10096 "filename> file will start with this directive:"
10097 msgstr ""
10099 #. type: Content of: <book><chapter><sect1><para>
10100 #: ../en/ch07-filenames.xml:302
10101 msgid ""
10102 "This tells Mercurial to interpret the lines that follow as glob patterns, not "
10103 "regular expressions."
10104 msgstr ""
10106 #. type: Content of: <book><chapter><sect1><para>
10107 #: ../en/ch07-filenames.xml:305
10108 msgid "Here is a typical-looking <filename>.hgignore</filename> file."
10109 msgstr ""
10111 #. type: Content of: <book><chapter><sect1><title>
10112 #: ../en/ch07-filenames.xml:329
10113 msgid "Case sensitivity"
10114 msgstr "大小写敏感性"
10116 #. type: Content of: <book><chapter><sect1><para>
10117 #: ../en/ch07-filenames.xml:331
10118 msgid ""
10119 "If you're working in a mixed development environment that contains both Linux "
10120 "(or other Unix) systems and Macs or Windows systems, you should keep in the "
10121 "back of your mind the knowledge that they treat the case (<quote>N</quote> "
10122 "versus <quote>n</quote>) of file names in incompatible ways. This is not "
10123 "very likely to affect you, and it's easy to deal with if it does, but it "
10124 "could surprise you if you don't know about it."
10125 msgstr ""
10127 #. type: Content of: <book><chapter><sect1><para>
10128 #: ../en/ch07-filenames.xml:340
10129 msgid ""
10130 "Operating systems and filesystems differ in the way they handle the "
10131 "<emphasis>case</emphasis> of characters in file and directory names. There "
10132 "are three common ways to handle case in names."
10133 msgstr ""
10135 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10136 #: ../en/ch07-filenames.xml:345
10137 msgid ""
10138 "Completely case insensitive. Uppercase and lowercase versions of a letter "
10139 "are treated as identical, both when creating a file and during subsequent "
10140 "accesses. This is common on older DOS-based systems."
10141 msgstr ""
10143 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10144 #: ../en/ch07-filenames.xml:350
10145 msgid ""
10146 "Case preserving, but insensitive. When a file or directory is created, the "
10147 "case of its name is stored, and can be retrieved and displayed by the "
10148 "operating system. When an existing file is being looked up, its case is "
10149 "ignored. This is the standard arrangement on Windows and MacOS. The names "
10150 "<filename>foo</filename> and <filename>FoO</filename> identify the same "
10151 "file. This treatment of uppercase and lowercase letters as interchangeable "
10152 "is also referred to as <emphasis>case folding</emphasis>."
10153 msgstr ""
10155 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10156 #: ../en/ch07-filenames.xml:361
10157 msgid ""
10158 "Case sensitive. The case of a name is significant at all times. The names "
10159 "<filename>foo</filename> and <filename>FoO</filename> identify different "
10160 "files. This is the way Linux and Unix systems normally work."
10161 msgstr ""
10163 #. type: Content of: <book><chapter><sect1><para>
10164 #: ../en/ch07-filenames.xml:368
10165 msgid ""
10166 "On Unix-like systems, it is possible to have any or all of the above ways of "
10167 "handling case in action at once. For example, if you use a USB thumb drive "
10168 "formatted with a FAT32 filesystem on a Linux system, Linux will handle names "
10169 "on that filesystem in a case preserving, but insensitive, way."
10170 msgstr ""
10172 #. type: Content of: <book><chapter><sect1><sect2><title>
10173 #: ../en/ch07-filenames.xml:375
10174 msgid "Safe, portable repository storage"
10175 msgstr "安全,可移植的版本库存储"
10177 #. type: Content of: <book><chapter><sect1><sect2><para>
10178 #: ../en/ch07-filenames.xml:377
10179 msgid ""
10180 "Mercurial's repository storage mechanism is <emphasis>case safe</emphasis>. "
10181 "It translates file names so that they can be safely stored on both case "
10182 "sensitive and case insensitive filesystems. This means that you can use "
10183 "normal file copying tools to transfer a Mercurial repository onto, for "
10184 "example, a USB thumb drive, and safely move that drive and repository back "
10185 "and forth between a Mac, a PC running Windows, and a Linux box."
10186 msgstr ""
10188 #. type: Content of: <book><chapter><sect1><sect2><title>
10189 #: ../en/ch07-filenames.xml:388
10190 msgid "Detecting case conflicts"
10191 msgstr "检测大小写冲突"
10193 #. type: Content of: <book><chapter><sect1><sect2><para>
10194 #: ../en/ch07-filenames.xml:390
10195 msgid ""
10196 "When operating in the working directory, Mercurial honours the naming policy "
10197 "of the filesystem where the working directory is located. If the filesystem "
10198 "is case preserving, but insensitive, Mercurial will treat names that differ "
10199 "only in case as the same."
10200 msgstr ""
10202 #. type: Content of: <book><chapter><sect1><sect2><para>
10203 #: ../en/ch07-filenames.xml:396
10204 msgid ""
10205 "An important aspect of this approach is that it is possible to commit a "
10206 "changeset on a case sensitive (typically Linux or Unix) filesystem that will "
10207 "cause trouble for users on case insensitive (usually Windows and MacOS) "
10208 "users. If a Linux user commits changes to two files, one named "
10209 "<filename>myfile.c</filename> and the other named <filename>MyFile.C</"
10210 "filename>, they will be stored correctly in the repository. And in the "
10211 "working directories of other Linux users, they will be correctly represented "
10212 "as separate files."
10213 msgstr ""
10215 #. type: Content of: <book><chapter><sect1><sect2><para>
10216 #: ../en/ch07-filenames.xml:407
10217 msgid ""
10218 "If a Windows or Mac user pulls this change, they will not initially have a "
10219 "problem, because Mercurial's repository storage mechanism is case safe. "
10220 "However, once they try to <command role=\"hg-cmd\">hg update</command> the "
10221 "working directory to that changeset, or <command role=\"hg-cmd\">hg merge</"
10222 "command> with that changeset, Mercurial will spot the conflict between the "
10223 "two file names that the filesystem would treat as the same, and forbid the "
10224 "update or merge from occurring."
10225 msgstr ""
10227 #. type: Content of: <book><chapter><sect1><sect2><title>
10228 #: ../en/ch07-filenames.xml:419
10229 msgid "Fixing a case conflict"
10230 msgstr "修正大小写冲突"
10232 #. type: Content of: <book><chapter><sect1><sect2><para>
10233 #: ../en/ch07-filenames.xml:421
10234 msgid ""
10235 "If you are using Windows or a Mac in a mixed environment where some of your "
10236 "collaborators are using Linux or Unix, and Mercurial reports a case folding "
10237 "conflict when you try to <command role=\"hg-cmd\">hg update</command> or "
10238 "<command role=\"hg-cmd\">hg merge</command>, the procedure to fix the problem "
10239 "is simple."
10240 msgstr ""
10242 #. type: Content of: <book><chapter><sect1><sect2><para>
10243 #: ../en/ch07-filenames.xml:428
10244 msgid ""
10245 "Just find a nearby Linux or Unix box, clone the problem repository onto it, "
10246 "and use Mercurial's <command role=\"hg-cmd\">hg rename</command> command to "
10247 "change the names of any offending files or directories so that they will no "
10248 "longer cause case folding conflicts. Commit this change, <command role=\"hg-"
10249 "cmd\">hg pull</command> or <command role=\"hg-cmd\">hg push</command> it "
10250 "across to your Windows or MacOS system, and <command role=\"hg-cmd\">hg "
10251 "update</command> to the revision with the non-conflicting names."
10252 msgstr ""
10254 #. type: Content of: <book><chapter><sect1><sect2><para>
10255 #: ../en/ch07-filenames.xml:438
10256 msgid ""
10257 "The changeset with case-conflicting names will remain in your project's "
10258 "history, and you still won't be able to <command role=\"hg-cmd\">hg update</"
10259 "command> your working directory to that changeset on a Windows or MacOS "
10260 "system, but you can continue development unimpeded."
10261 msgstr ""
10263 #. type: Content of: <book><chapter><title>
10264 #: ../en/ch08-branch.xml:5
10265 msgid "Managing releases and branchy development"
10266 msgstr "发布管理与分支开发"
10268 #. type: Content of: <book><chapter><para>
10269 #: ../en/ch08-branch.xml:7
10270 msgid ""
10271 "Mercurial provides several mechanisms for you to manage a project that is "
10272 "making progress on multiple fronts at once. To understand these mechanisms, "
10273 "let's first take a brief look at a fairly normal software project structure."
10274 msgstr ""
10276 #. type: Content of: <book><chapter><para>
10277 #: ../en/ch08-branch.xml:12
10278 msgid ""
10279 "Many software projects issue periodic <quote>major</quote> releases that "
10280 "contain substantial new features. In parallel, they may issue <quote>minor</"
10281 "quote> releases. These are usually identical to the major releases off which "
10282 "they're based, but with a few bugs fixed."
10283 msgstr ""
10285 #. type: Content of: <book><chapter><para>
10286 #: ../en/ch08-branch.xml:18
10287 msgid ""
10288 "In this chapter, we'll start by talking about how to keep records of project "
10289 "milestones such as releases. We'll then continue on to talk about the flow "
10290 "of work between different phases of a project, and how Mercurial can help you "
10291 "to isolate and manage this work."
10292 msgstr ""
10294 #. type: Content of: <book><chapter><sect1><title>
10295 #: ../en/ch08-branch.xml:25
10296 msgid "Giving a persistent name to a revision"
10297 msgstr "给版本指定一个永久的名称"
10299 #. type: Content of: <book><chapter><sect1><para>
10300 #: ../en/ch08-branch.xml:27
10301 msgid ""
10302 "Once you decide that you'd like to call a particular revision a "
10303 "<quote>release</quote>, it's a good idea to record the identity of that "
10304 "revision. This will let you reproduce that release at a later date, for "
10305 "whatever purpose you might need at the time (reproducing a bug, porting to a "
10306 "new platform, etc). &interaction.tag.init;"
10307 msgstr ""
10310 #. type: Content of: <book><chapter><sect1><para>
10311 #: ../en/ch08-branch.xml:34
10312 msgid ""
10313 "Mercurial lets you give a permanent name to any revision using the <command "
10314 "role=\"hg-cmd\">hg tag</command> command. Not surprisingly, these names are "
10315 "called <quote>tags</quote>."
10316 msgstr ""
10318 #. type: Content of: <book><chapter><sect1><para>
10319 #: ../en/ch08-branch.xml:40
10320 msgid ""
10321 "A tag is nothing more than a <quote>symbolic name</quote> for a revision. "
10322 "Tags exist purely for your convenience, so that you have a handy permanent "
10323 "way to refer to a revision; Mercurial doesn't interpret the tag names you use "
10324 "in any way. Neither does Mercurial place any restrictions on the name of a "
10325 "tag, beyond a few that are necessary to ensure that a tag can be parsed "
10326 "unambiguously. A tag name cannot contain any of the following characters:"
10327 msgstr ""
10329 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10330 #: ../en/ch08-branch.xml:49
10331 msgid "Colon (ASCII 58, <quote><literal>:</literal></quote>)"
10332 msgstr ""
10334 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10335 #: ../en/ch08-branch.xml:52
10336 msgid "Carriage return (ASCII 13, <quote><literal>\\r</literal></quote>)"
10337 msgstr ""
10339 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10340 #: ../en/ch08-branch.xml:55
10341 msgid "Newline (ASCII 10, <quote><literal>\\n</literal></quote>)"
10342 msgstr ""
10344 #. type: Content of: <book><chapter><sect1><para>
10345 #: ../en/ch08-branch.xml:59
10346 msgid ""
10347 "You can use the <command role=\"hg-cmd\">hg tags</command> command to display "
10348 "the tags present in your repository. In the output, each tagged revision is "
10349 "identified first by its name, then by revision number, and finally by the "
10350 "unique hash of the revision."
10351 msgstr ""
10353 #. type: Content of: <book><chapter><sect1><para>
10354 #: ../en/ch08-branch.xml:67
10355 msgid ""
10356 "Notice that <literal>tip</literal> is listed in the output of <command role="
10357 "\"hg-cmd\">hg tags</command>. The <literal>tip</literal> tag is a special "
10358 "<quote>floating</quote> tag, which always identifies the newest revision in "
10359 "the repository."
10360 msgstr ""
10362 #. type: Content of: <book><chapter><sect1><para>
10363 #: ../en/ch08-branch.xml:73
10364 msgid ""
10365 "In the output of the <command role=\"hg-cmd\">hg tags</command> command, tags "
10366 "are listed in reverse order, by revision number. This usually means that "
10367 "recent tags are listed before older tags. It also means that <literal>tip</"
10368 "literal> is always going to be the first tag listed in the output of <command "
10369 "role=\"hg-cmd\">hg tags</command>."
10370 msgstr ""
10372 #. type: Content of: <book><chapter><sect1><para>
10373 #: ../en/ch08-branch.xml:80
10374 msgid ""
10375 "When you run <command role=\"hg-cmd\">hg log</command>, if it displays a "
10376 "revision that has tags associated with it, it will print those tags."
10377 msgstr ""
10380 #. type: Content of: <book><chapter><sect1><para>
10381 #: ../en/ch08-branch.xml:86
10382 msgid ""
10383 "Any time you need to provide a revision ID to a Mercurial command, the "
10384 "command will accept a tag name in its place. Internally, Mercurial will "
10385 "translate your tag name into the corresponding revision ID, then use that."
10386 msgstr ""
10388 #. type: Content of: <book><chapter><sect1><para>
10389 #: ../en/ch08-branch.xml:93
10390 msgid ""
10391 "There's no limit on the number of tags you can have in a repository, or on "
10392 "the number of tags that a single revision can have. As a practical matter, "
10393 "it's not a great idea to have <quote>too many</quote> (a number which will "
10394 "vary from project to project), simply because tags are supposed to help you "
10395 "to find revisions. If you have lots of tags, the ease of using them to "
10396 "identify revisions diminishes rapidly."
10397 msgstr ""
10399 #. type: Content of: <book><chapter><sect1><para>
10400 #: ../en/ch08-branch.xml:101
10401 msgid ""
10402 "For example, if your project has milestones as frequent as every few days, "
10403 "it's perfectly reasonable to tag each one of those. But if you have a "
10404 "continuous build system that makes sure every revision can be built cleanly, "
10405 "you'd be introducing a lot of noise if you were to tag every clean build. "
10406 "Instead, you could tag failed builds (on the assumption that they're rare!), "
10407 "or simply not use tags to track buildability."
10408 msgstr ""
10410 #. type: Content of: <book><chapter><sect1><para>
10411 #: ../en/ch08-branch.xml:109
10412 msgid ""
10413 "If you want to remove a tag that you no longer want, use <command role=\"hg-"
10414 "cmd\">hg tag --remove</command>."
10415 msgstr ""
10417 #. type: Content of: <book><chapter><sect1><para>
10418 #: ../en/ch08-branch.xml:114
10419 msgid ""
10420 "You can also modify a tag at any time, so that it identifies a different "
10421 "revision, by simply issuing a new <command role=\"hg-cmd\">hg tag</command> "
10422 "command. You'll have to use the <option role=\"hg-opt-tag\">-f</option> "
10423 "option to tell Mercurial that you <emphasis>really</emphasis> want to update "
10424 "the tag."
10425 msgstr ""
10427 #. type: Content of: <book><chapter><sect1><para>
10428 #: ../en/ch08-branch.xml:123
10429 msgid ""
10430 "There will still be a permanent record of the previous identity of the tag, "
10431 "but Mercurial will no longer use it. There's thus no penalty to tagging the "
10432 "wrong revision; all you have to do is turn around and tag the correct "
10433 "revision once you discover your error."
10434 msgstr ""
10436 #. type: Content of: <book><chapter><sect1><para>
10437 #: ../en/ch08-branch.xml:129
10438 msgid ""
10439 "Mercurial stores tags in a normal revision-controlled file in your "
10440 "repository. If you've created any tags, you'll find them in a file in the "
10441 "root of your repository named <filename role=\"special\">.hgtags</filename>. "
10442 "When you run the <command role=\"hg-cmd\">hg tag</command> command, Mercurial "
10443 "modifies this file, then automatically commits the change to it. This means "
10444 "that every time you run <command role=\"hg-cmd\">hg tag</command>, you'll see "
10445 "a corresponding changeset in the output of <command role=\"hg-cmd\">hg log</"
10446 "command>."
10447 msgstr ""
10449 #. type: Content of: <book><chapter><sect1><sect2><title>
10450 #: ../en/ch08-branch.xml:142
10451 msgid "Handling tag conflicts during a merge"
10452 msgstr "在合并期间处理标签冲突"
10454 #. type: Content of: <book><chapter><sect1><sect2><para>
10455 #: ../en/ch08-branch.xml:144
10456 msgid ""
10457 "You won't often need to care about the <filename role=\"special\">.hgtags</"
10458 "filename> file, but it sometimes makes its presence known during a merge. "
10459 "The format of the file is simple: it consists of a series of lines. Each "
10460 "line starts with a changeset hash, followed by a space, followed by the name "
10461 "of a tag."
10462 msgstr ""
10464 #. type: Content of: <book><chapter><sect1><sect2><para>
10465 #: ../en/ch08-branch.xml:151
10466 msgid ""
10467 "If you're resolving a conflict in the <filename role=\"special\">.hgtags</"
10468 "filename> file during a merge, there's one twist to modifying the <filename "
10469 "role=\"special\">.hgtags</filename> file: when Mercurial is parsing the tags "
10470 "in a repository, it <emphasis>never</emphasis> reads the working copy of the "
10471 "<filename role=\"special\">.hgtags</filename> file. Instead, it reads the "
10472 "<emphasis>most recently committed</emphasis> revision of the file."
10473 msgstr ""
10475 #. type: Content of: <book><chapter><sect1><sect2><para>
10476 #: ../en/ch08-branch.xml:161
10477 msgid ""
10478 "An unfortunate consequence of this design is that you can't actually verify "
10479 "that your merged <filename role=\"special\">.hgtags</filename> file is "
10480 "correct until <emphasis>after</emphasis> you've committed a change. So if "
10481 "you find yourself resolving a conflict on <filename role=\"special\">.hgtags</"
10482 "filename> during a merge, be sure to run <command role=\"hg-cmd\">hg tags</"
10483 "command> after you commit. If it finds an error in the <filename role="
10484 "\"special\">.hgtags</filename> file, it will report the location of the "
10485 "error, which you can then fix and commit. You should then run <command role="
10486 "\"hg-cmd\">hg tags</command> again, just to be sure that your fix is correct."
10487 msgstr ""
10489 #. type: Content of: <book><chapter><sect1><sect2><title>
10490 #: ../en/ch08-branch.xml:176
10491 msgid "Tags and cloning"
10492 msgstr "标签与克隆"
10494 #. type: Content of: <book><chapter><sect1><sect2><para>
10495 #: ../en/ch08-branch.xml:178
10496 msgid ""
10497 "You may have noticed that the <command role=\"hg-cmd\">hg clone</command> "
10498 "command has a <option role=\"hg-opt-clone\">-r</option> option that lets you "
10499 "clone an exact copy of the repository as of a particular changeset. The new "
10500 "clone will not contain any project history that comes after the revision you "
10501 "specified. This has an interaction with tags that can surprise the unwary."
10502 msgstr ""
10504 #. type: Content of: <book><chapter><sect1><sect2><para>
10505 #: ../en/ch08-branch.xml:186
10506 msgid ""
10507 "Recall that a tag is stored as a revision to the <filename role=\"special\">."
10508 "hgtags</filename> file. When you create a tag, the changeset in which its "
10509 "recorded refers to an older changeset. When you run <command role=\"hg-cmd"
10510 "\">hg clone -r foo</command> to clone a repository as of tag <literal>foo</"
10511 "literal>, the new clone <emphasis>will not contain any revision newer than "
10512 "the one the tag refers to, including the revision where the tag was created</"
10513 "emphasis>. The result is that you'll get exactly the right subset of the "
10514 "project's history in the new repository, but <emphasis>not</emphasis> the tag "
10515 "you might have expected."
10516 msgstr ""
10518 #. type: Content of: <book><chapter><sect1><sect2><title>
10519 #: ../en/ch08-branch.xml:201
10520 msgid "When permanent tags are too much"
10521 msgstr "当永久标签太多的时候"
10523 #. type: Content of: <book><chapter><sect1><sect2><para>
10524 #: ../en/ch08-branch.xml:203
10525 msgid ""
10526 "Since Mercurial's tags are revision controlled and carried around with a "
10527 "project's history, everyone you work with will see the tags you create. But "
10528 "giving names to revisions has uses beyond simply noting that revision "
10529 "<literal>4237e45506ee</literal> is really <literal>v2.0.2</literal>. If "
10530 "you're trying to track down a subtle bug, you might want a tag to remind you "
10531 "of something like <quote>Anne saw the symptoms with this revision</quote>."
10532 msgstr ""
10534 #. type: Content of: <book><chapter><sect1><sect2><para>
10535 #: ../en/ch08-branch.xml:213
10536 msgid ""
10537 "For cases like this, what you might want to use are <emphasis>local</"
10538 "emphasis> tags. You can create a local tag with the <option role=\"hg-opt-tag"
10539 "\">-l</option> option to the <command role=\"hg-cmd\">hg tag</command> "
10540 "command. This will store the tag in a file called <filename role=\"special"
10541 "\">.hg/localtags</filename>. Unlike <filename role=\"special\">.hgtags</"
10542 "filename>, <filename role=\"special\">.hg/localtags</filename> is not "
10543 "revision controlled. Any tags you create using <option role=\"hg-opt-tag\">-"
10544 "l</option> remain strictly local to the repository you're currently working "
10545 "in."
10546 msgstr ""
10548 #. type: Content of: <book><chapter><sect1><title>
10549 #: ../en/ch08-branch.xml:228
10550 msgid "The flow of changes&emdash;big picture vs. little"
10551 msgstr "修改流程—宏观与微观"
10553 #. type: Content of: <book><chapter><sect1><para>
10554 #: ../en/ch08-branch.xml:230
10555 msgid ""
10556 "To return to the outline I sketched at the beginning of the chapter, let's "
10557 "think about a project that has multiple concurrent pieces of work under "
10558 "development at once."
10559 msgstr ""
10561 #. type: Content of: <book><chapter><sect1><para>
10562 #: ../en/ch08-branch.xml:235
10563 msgid ""
10564 "There might be a push for a new <quote>main</quote> release; a new minor "
10565 "bugfix release to the last main release; and an unexpected <quote>hot fix</"
10566 "quote> to an old release that is now in maintenance mode."
10567 msgstr ""
10569 #. type: Content of: <book><chapter><sect1><para>
10570 #: ../en/ch08-branch.xml:240
10571 msgid ""
10572 "The usual way people refer to these different concurrent directions of "
10573 "development is as <quote>branches</quote>. However, we've already seen "
10574 "numerous times that Mercurial treats <emphasis>all of history</emphasis> as a "
10575 "series of branches and merges. Really, what we have here is two ideas that "
10576 "are peripherally related, but which happen to share a name."
10577 msgstr ""
10579 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10580 #: ../en/ch08-branch.xml:247
10581 msgid ""
10582 "<quote>Big picture</quote> branches represent the sweep of a project's "
10583 "evolution; people give them names, and talk about them in conversation."
10584 msgstr ""
10586 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10587 #: ../en/ch08-branch.xml:251
10588 msgid ""
10589 "<quote>Little picture</quote> branches are artefacts of the day-to-day "
10590 "activity of developing and merging changes. They expose the narrative of how "
10591 "the code was developed."
10592 msgstr ""
10594 #. type: Content of: <book><chapter><sect1><title>
10595 #: ../en/ch08-branch.xml:259
10596 msgid "Managing big-picture branches in repositories"
10597 msgstr "在版本库中管理分支"
10599 #. type: Content of: <book><chapter><sect1><para>
10600 #: ../en/ch08-branch.xml:261
10601 msgid ""
10602 "The easiest way to isolate a <quote>big picture</quote> branch in Mercurial "
10603 "is in a dedicated repository. If you have an existing shared "
10604 "repository&emdash;let's call it <literal>myproject</literal>&emdash;that "
10605 "reaches a <quote>1.0</quote> milestone, you can start to prepare for future "
10606 "maintenance releases on top of version 1.0 by tagging the revision from which "
10607 "you prepared the 1.0 release."
10608 msgstr ""
10610 #. type: Content of: <book><chapter><sect1><para>
10611 #: ../en/ch08-branch.xml:271
10612 msgid ""
10613 "You can then clone a new shared <literal>myproject-1.0.1</literal> repository "
10614 "as of that tag."
10615 msgstr ""
10617 #. type: Content of: <book><chapter><sect1><para>
10618 #: ../en/ch08-branch.xml:277
10619 msgid ""
10620 "Afterwards, if someone needs to work on a bug fix that ought to go into an "
10621 "upcoming 1.0.1 minor release, they clone the <literal>myproject-1.0.1</"
10622 "literal> repository, make their changes, and push them back."
10623 msgstr ""
10625 #. type: Content of: <book><chapter><sect1><para>
10626 #: ../en/ch08-branch.xml:284
10627 msgid ""
10628 "Meanwhile, development for the next major release can continue, isolated and "
10629 "unabated, in the <literal>myproject</literal> repository."
10630 msgstr ""
10632 #. type: Content of: <book><chapter><sect1><title>
10633 #: ../en/ch08-branch.xml:292
10634 msgid "Don't repeat yourself: merging across branches"
10635 msgstr "不要重复劳动:在分支间合并"
10637 #. type: Content of: <book><chapter><sect1><para>
10638 #: ../en/ch08-branch.xml:294
10639 msgid ""
10640 "In many cases, if you have a bug to fix on a maintenance branch, the chances "
10641 "are good that the bug exists on your project's main branch (and possibly "
10642 "other maintenance branches, too). It's a rare developer who wants to fix the "
10643 "same bug multiple times, so let's look at a few ways that Mercurial can help "
10644 "you to manage these bugfixes without duplicating your work."
10645 msgstr ""
10647 #. type: Content of: <book><chapter><sect1><para>
10648 #: ../en/ch08-branch.xml:302
10649 msgid ""
10650 "In the simplest instance, all you need to do is pull changes from your "
10651 "maintenance branch into your local clone of the target branch."
10652 msgstr ""
10654 #. type: Content of: <book><chapter><sect1><para>
10655 #: ../en/ch08-branch.xml:308
10656 msgid ""
10657 "You'll then need to merge the heads of the two branches, and push back to the "
10658 "main branch."
10659 msgstr ""
10661 #. type: Content of: <book><chapter><sect1><title>
10662 #: ../en/ch08-branch.xml:315
10663 msgid "Naming branches within one repository"
10664 msgstr "版本库中的命名分支"
10666 #. type: Content of: <book><chapter><sect1><para>
10667 #: ../en/ch08-branch.xml:317
10668 msgid ""
10669 "In most instances, isolating branches in repositories is the right approach. "
10670 "Its simplicity makes it easy to understand; and so it's hard to make "
10671 "mistakes. There's a one-to-one relationship between branches you're working "
10672 "in and directories on your system. This lets you use normal (non-Mercurial-"
10673 "aware) tools to work on files within a branch/repository."
10674 msgstr ""
10676 #. type: Content of: <book><chapter><sect1><para>
10677 #: ../en/ch08-branch.xml:324
10678 msgid ""
10679 "If you're more in the <quote>power user</quote> category (<emphasis>and</"
10680 "emphasis> your collaborators are too), there is an alternative way of "
10681 "handling branches that you can consider. I've already mentioned the human-"
10682 "level distinction between <quote>small picture</quote> and <quote>big "
10683 "picture</quote> branches. While Mercurial works with multiple <quote>small "
10684 "picture</quote> branches in a repository all the time (for example after you "
10685 "pull changes in, but before you merge them), it can <emphasis>also</emphasis> "
10686 "work with multiple <quote>big picture</quote> branches."
10687 msgstr ""
10689 #. type: Content of: <book><chapter><sect1><para>
10690 #: ../en/ch08-branch.xml:335
10691 msgid ""
10692 "The key to working this way is that Mercurial lets you assign a persistent "
10693 "<emphasis>name</emphasis> to a branch. There always exists a branch named "
10694 "<literal>default</literal>. Even before you start naming branches yourself, "
10695 "you can find traces of the <literal>default</literal> branch if you look for "
10696 "them."
10697 msgstr ""
10699 #. type: Content of: <book><chapter><sect1><para>
10700 #: ../en/ch08-branch.xml:342
10701 msgid ""
10702 "As an example, when you run the <command role=\"hg-cmd\">hg commit</command> "
10703 "command, and it pops up your editor so that you can enter a commit message, "
10704 "look for a line that contains the text <quote><literal>HG: branch default</"
10705 "literal></quote> at the bottom. This is telling you that your commit will "
10706 "occur on the branch named <literal>default</literal>."
10707 msgstr ""
10709 #. type: Content of: <book><chapter><sect1><para>
10710 #: ../en/ch08-branch.xml:349
10711 msgid ""
10712 "To start working with named branches, use the <command role=\"hg-cmd\">hg "
10713 "branches</command> command. This command lists the named branches already "
10714 "present in your repository, telling you which changeset is the tip of each."
10715 msgstr ""
10717 #. type: Content of: <book><chapter><sect1><para>
10718 #: ../en/ch08-branch.xml:356
10719 msgid ""
10720 "Since you haven't created any named branches yet, the only one that exists is "
10721 "<literal>default</literal>."
10722 msgstr ""
10724 #. type: Content of: <book><chapter><sect1><para>
10725 #: ../en/ch08-branch.xml:359
10726 msgid ""
10727 "To find out what the <quote>current</quote> branch is, run the <command role="
10728 "\"hg-cmd\">hg branch</command> command, giving it no arguments. This tells "
10729 "you what branch the parent of the current changeset is on."
10730 msgstr ""
10733 #. type: Content of: <book><chapter><sect1><para>
10734 #: ../en/ch08-branch.xml:366
10735 msgid ""
10736 "To create a new branch, run the <command role=\"hg-cmd\">hg branch</command> "
10737 "command again. This time, give it one argument: the name of the branch you "
10738 "want to create."
10739 msgstr ""
10741 #. type: Content of: <book><chapter><sect1><para>
10742 #: ../en/ch08-branch.xml:372
10743 msgid ""
10744 "After you've created a branch, you might wonder what effect the <command role="
10745 "\"hg-cmd\">hg branch</command> command has had. What do the <command role="
10746 "\"hg-cmd\">hg status</command> and <command role=\"hg-cmd\">hg tip</command> "
10747 "commands report?"
10748 msgstr ""
10750 #. type: Content of: <book><chapter><sect1><para>
10751 #: ../en/ch08-branch.xml:379
10752 msgid ""
10753 "Nothing has changed in the working directory, and there's been no new history "
10754 "created. As this suggests, running the <command role=\"hg-cmd\">hg branch</"
10755 "command> command has no permanent effect; it only tells Mercurial what branch "
10756 "name to use the <emphasis>next</emphasis> time you commit a changeset."
10757 msgstr ""
10759 #. type: Content of: <book><chapter><sect1><para>
10760 #: ../en/ch08-branch.xml:386
10761 msgid ""
10762 "When you commit a change, Mercurial records the name of the branch on which "
10763 "you committed. Once you've switched from the <literal>default</literal> "
10764 "branch to another and committed, you'll see the name of the new branch show "
10765 "up in the output of <command role=\"hg-cmd\">hg log</command>, <command role="
10766 "\"hg-cmd\">hg tip</command>, and other commands that display the same kind of "
10767 "output."
10768 msgstr ""
10770 #. type: Content of: <book><chapter><sect1><para>
10771 #: ../en/ch08-branch.xml:396
10772 msgid ""
10773 "The <command role=\"hg-cmd\">hg log</command>-like commands will print the "
10774 "branch name of every changeset that's not on the <literal>default</literal> "
10775 "branch. As a result, if you never use named branches, you'll never see this "
10776 "information."
10777 msgstr ""
10779 #. type: Content of: <book><chapter><sect1><para>
10780 #: ../en/ch08-branch.xml:401
10781 msgid ""
10782 "Once you've named a branch and committed a change with that name, every "
10783 "subsequent commit that descends from that change will inherit the same branch "
10784 "name. You can change the name of a branch at any time, using the <command "
10785 "role=\"hg-cmd\">hg branch</command> command."
10786 msgstr ""
10788 #. type: Content of: <book><chapter><sect1><para>
10789 #: ../en/ch08-branch.xml:409
10790 msgid ""
10791 "In practice, this is something you won't do very often, as branch names tend "
10792 "to have fairly long lifetimes. (This isn't a rule, just an observation.)"
10793 msgstr ""
10795 #. type: Content of: <book><chapter><sect1><title>
10796 #: ../en/ch08-branch.xml:415
10797 msgid "Dealing with multiple named branches in a repository"
10798 msgstr "在版本库中处理多个命名分支"
10800 #. type: Content of: <book><chapter><sect1><para>
10801 #: ../en/ch08-branch.xml:418
10802 msgid ""
10803 "If you have more than one named branch in a repository, Mercurial will "
10804 "remember the branch that your working directory is on when you start a "
10805 "command like <command role=\"hg-cmd\">hg update</command> or <command role="
10806 "\"hg-cmd\">hg pull -u</command>. It will update the working directory to the "
10807 "tip of this branch, no matter what the <quote>repo-wide</quote> tip is. To "
10808 "update to a revision that's on a different named branch, you may need to use "
10809 "the <option role=\"hg-opt-update\">-C</option> option to <command role=\"hg-"
10810 "cmd\">hg update</command>."
10811 msgstr ""
10813 #. type: Content of: <book><chapter><sect1><para>
10814 #: ../en/ch08-branch.xml:428
10815 msgid ""
10816 "This behavior is a little subtle, so let's see it in action. First, let's "
10817 "remind ourselves what branch we're currently on, and what branches are in our "
10818 "repository."
10819 msgstr ""
10821 #. type: Content of: <book><chapter><sect1><para>
10822 #: ../en/ch08-branch.xml:434
10823 msgid ""
10824 "We're on the <literal>bar</literal> branch, but there also exists an older "
10825 "<command role=\"hg-cmd\">hg foo</command> branch."
10826 msgstr ""
10828 #. type: Content of: <book><chapter><sect1><para>
10829 #: ../en/ch08-branch.xml:438
10830 msgid ""
10831 "We can <command role=\"hg-cmd\">hg update</command> back and forth between "
10832 "the tips of the <literal>foo</literal> and <literal>bar</literal> branches "
10833 "without needing to use the <option role=\"hg-opt-update\">-C</option> option, "
10834 "because this only involves going backwards and forwards linearly through our "
10835 "change history."
10836 msgstr ""
10839 #. type: Content of: <book><chapter><sect1><para>
10840 #: ../en/ch08-branch.xml:447
10841 msgid ""
10842 "If we go back to the <literal>foo</literal> branch and then run <command role="
10843 "\"hg-cmd\">hg update</command>, it will keep us on <literal>foo</literal>, "
10844 "not move us to the tip of <literal>bar</literal>."
10845 msgstr ""
10848 #. type: Content of: <book><chapter><sect1><para>
10849 #: ../en/ch08-branch.xml:454
10850 msgid ""
10851 "Committing a new change on the <literal>foo</literal> branch introduces a new "
10852 "head."
10853 msgstr ""
10855 #. type: Content of: <book><chapter><sect1><title>
10856 #: ../en/ch08-branch.xml:461
10857 msgid "Branch names and merging"
10858 msgstr "分支名称与合并"
10860 #. type: Content of: <book><chapter><sect1><para>
10861 #: ../en/ch08-branch.xml:463
10862 msgid ""
10863 "As you've probably noticed, merges in Mercurial are not symmetrical. Let's "
10864 "say our repository has two heads, 17 and 23. If I <command role=\"hg-cmd"
10865 "\">hg update</command> to 17 and then <command role=\"hg-cmd\">hg merge</"
10866 "command> with 23, Mercurial records 17 as the first parent of the merge, and "
10867 "23 as the second. Whereas if I <command role=\"hg-cmd\">hg update</command> "
10868 "to 23 and then <command role=\"hg-cmd\">hg merge</command> with 17, it "
10869 "records 23 as the first parent, and 17 as the second."
10870 msgstr ""
10872 #. type: Content of: <book><chapter><sect1><para>
10873 #: ../en/ch08-branch.xml:473
10874 msgid ""
10875 "This affects Mercurial's choice of branch name when you merge. After a "
10876 "merge, Mercurial will retain the branch name of the first parent when you "
10877 "commit the result of the merge. If your first parent's branch name is "
10878 "<literal>foo</literal>, and you merge with <literal>bar</literal>, the branch "
10879 "name will still be <literal>foo</literal> after you merge."
10880 msgstr ""
10882 #. type: Content of: <book><chapter><sect1><para>
10883 #: ../en/ch08-branch.xml:480
10884 msgid ""
10885 "It's not unusual for a repository to contain multiple heads, each with the "
10886 "same branch name. Let's say I'm working on the <literal>foo</literal> "
10887 "branch, and so are you. We commit different changes; I pull your changes; I "
10888 "now have two heads, each claiming to be on the <literal>foo</literal> "
10889 "branch. The result of a merge will be a single head on the <literal>foo</"
10890 "literal> branch, as you might hope."
10891 msgstr ""
10894 #. type: Content of: <book><chapter><sect1><para>
10895 #: ../en/ch08-branch.xml:488
10896 msgid ""
10897 "But if I'm working on the <literal>bar</literal> branch, and I merge work "
10898 "from the <literal>foo</literal> branch, the result will remain on the "
10899 "<literal>bar</literal> branch."
10900 msgstr ""
10902 #. type: Content of: <book><chapter><sect1><para>
10903 #: ../en/ch08-branch.xml:494
10904 msgid ""
10905 "To give a more concrete example, if I'm working on the <literal>bleeding-"
10906 "edge</literal> branch, and I want to bring in the latest fixes from the "
10907 "<literal>stable</literal> branch, Mercurial will choose the <quote>right</"
10908 "quote> (<literal>bleeding-edge</literal>) branch name when I pull and merge "
10909 "from <literal>stable</literal>."
10910 msgstr ""
10912 #. type: Content of: <book><chapter><sect1><title>
10913 #: ../en/ch08-branch.xml:503
10914 msgid "Branch naming is generally useful"
10915 msgstr "分支名称通常都很有用"
10917 #. type: Content of: <book><chapter><sect1><para>
10918 #: ../en/ch08-branch.xml:505
10919 msgid ""
10920 "You shouldn't think of named branches as applicable only to situations where "
10921 "you have multiple long-lived branches cohabiting in a single repository. "
10922 "They're very useful even in the one-branch-per-repository case."
10923 msgstr ""
10925 #. type: Content of: <book><chapter><sect1><para>
10926 #: ../en/ch08-branch.xml:510
10927 msgid ""
10928 "In the simplest case, giving a name to each branch gives you a permanent "
10929 "record of which branch a changeset originated on. This gives you more "
10930 "context when you're trying to follow the history of a long-lived branchy "
10931 "project."
10932 msgstr ""
10934 #. type: Content of: <book><chapter><sect1><para>
10935 #: ../en/ch08-branch.xml:515
10936 msgid ""
10937 "If you're working with shared repositories, you can set up a <literal role="
10938 "\"hook\">pretxnchangegroup</literal> hook on each that will block incoming "
10939 "changes that have the <quote>wrong</quote> branch name. This provides a "
10940 "simple, but effective, defence against people accidentally pushing changes "
10941 "from a <quote>bleeding edge</quote> branch to a <quote>stable</quote> "
10942 "branch. Such a hook might look like this inside the shared repo's <filename "
10943 "role=\"special\"> /.hgrc</filename>."
10944 msgstr ""
10946 #. type: Content of: <book><chapter><title>
10947 #: ../en/ch09-undo.xml:5
10948 msgid "Finding and fixing mistakes"
10949 msgstr "查找和修改错误"
10951 #. type: Content of: <book><chapter><para>
10952 #: ../en/ch09-undo.xml:7
10953 msgid ""
10954 "To err might be human, but to really handle the consequences well takes a top-"
10955 "notch revision control system. In this chapter, we'll discuss some of the "
10956 "techniques you can use when you find that a problem has crept into your "
10957 "project. Mercurial has some highly capable features that will help you to "
10958 "isolate the sources of problems, and to handle them appropriately."
10959 msgstr ""
10961 #. type: Content of: <book><chapter><sect1><title>
10962 #: ../en/ch09-undo.xml:15
10963 msgid "Erasing local history"
10964 msgstr "销毁本地历史"
10966 #. type: Content of: <book><chapter><sect1><sect2><title>
10967 #: ../en/ch09-undo.xml:18
10968 msgid "The accidental commit"
10969 msgstr "意外的提交"
10971 #. type: Content of: <book><chapter><sect1><sect2><para>
10972 #: ../en/ch09-undo.xml:20
10973 msgid ""
10974 "I have the occasional but persistent problem of typing rather more quickly "
10975 "than I can think, which sometimes results in me committing a changeset that "
10976 "is either incomplete or plain wrong. In my case, the usual kind of "
10977 "incomplete changeset is one in which I've created a new source file, but "
10978 "forgotten to <command role=\"hg-cmd\">hg add</command> it. A <quote>plain "
10979 "wrong</quote> changeset is not as common, but no less annoying."
10980 msgstr ""
10982 #. type: Content of: <book><chapter><sect1><sect2><title>
10983 #: ../en/ch09-undo.xml:31
10984 msgid "Rolling back a transaction"
10985 msgstr "回滚一个事务"
10987 #. type: Content of: <book><chapter><sect1><sect2><para>
10988 #: ../en/ch09-undo.xml:33
10989 msgid ""
10990 "In <xref linkend=\"sec:concepts:txn\"/>, I mentioned that Mercurial treats "
10991 "each modification of a repository as a <emphasis>transaction</emphasis>. "
10992 "Every time you commit a changeset or pull changes from another repository, "
10993 "Mercurial remembers what you did. You can undo, or <emphasis>roll back</"
10994 "emphasis>, exactly one of these actions using the <command role=\"hg-cmd\">hg "
10995 "rollback</command> command. (See <xref linkend=\"sec:undo:rollback-after-push"
10996 "\"/> for an important caveat about the use of this command.)"
10997 msgstr ""
10999 #. type: Content of: <book><chapter><sect1><sect2><para>
11000 #: ../en/ch09-undo.xml:43
11001 msgid ""
11002 "Here's a mistake that I often find myself making: committing a change in "
11003 "which I've created a new file, but forgotten to <command role=\"hg-cmd\">hg "
11004 "add</command> it."
11005 msgstr ""
11007 #. type: Content of: <book><chapter><sect1><sect2><para>
11008 #: ../en/ch09-undo.xml:50
11009 msgid ""
11010 "Looking at the output of <command role=\"hg-cmd\">hg status</command> after "
11011 "the commit immediately confirms the error."
11012 msgstr ""
11014 #. type: Content of: <book><chapter><sect1><sect2><para>
11015 #: ../en/ch09-undo.xml:56
11016 msgid ""
11017 "The commit captured the changes to the file <filename>a</filename>, but not "
11018 "the new file <filename>b</filename>. If I were to push this changeset to a "
11019 "repository that I shared with a colleague, the chances are high that "
11020 "something in <filename>a</filename> would refer to <filename>b</filename>, "
11021 "which would not be present in their repository when they pulled my changes. "
11022 "I would thus become the object of some indignation."
11023 msgstr ""
11025 #. type: Content of: <book><chapter><sect1><sect2><para>
11026 #: ../en/ch09-undo.xml:65
11027 msgid ""
11028 "However, luck is with me&emdash;I've caught my error before I pushed the "
11029 "changeset. I use the <command role=\"hg-cmd\">hg rollback</command> command, "
11030 "and Mercurial makes that last changeset vanish."
11031 msgstr ""
11033 #. type: Content of: <book><chapter><sect1><sect2><para>
11034 #: ../en/ch09-undo.xml:72
11035 msgid ""
11036 "Notice that the changeset is no longer present in the repository's history, "
11037 "and the working directory once again thinks that the file <filename>a</"
11038 "filename> is modified. The commit and rollback have left the working "
11039 "directory exactly as it was prior to the commit; the changeset has been "
11040 "completely erased. I can now safely <command role=\"hg-cmd\">hg add</"
11041 "command> the file <filename>b</filename>, and rerun my commit."
11042 msgstr ""
11044 #. type: Content of: <book><chapter><sect1><sect2><title>
11045 #: ../en/ch09-undo.xml:85
11046 msgid "The erroneous pull"
11047 msgstr "错误的抓取"
11049 #. type: Content of: <book><chapter><sect1><sect2><para>
11050 #: ../en/ch09-undo.xml:87
11051 msgid ""
11052 "It's common practice with Mercurial to maintain separate development branches "
11053 "of a project in different repositories. Your development team might have one "
11054 "shared repository for your project's <quote>0.9</quote> release, and another, "
11055 "containing different changes, for the <quote>1.0</quote> release."
11056 msgstr ""
11058 #. type: Content of: <book><chapter><sect1><sect2><para>
11059 #: ../en/ch09-undo.xml:94
11060 msgid ""
11061 "Given this, you can imagine that the consequences could be messy if you had a "
11062 "local <quote>0.9</quote> repository, and accidentally pulled changes from the "
11063 "shared <quote>1.0</quote> repository into it. At worst, you could be paying "
11064 "insufficient attention, and push those changes into the shared <quote>0.9</"
11065 "quote> tree, confusing your entire team (but don't worry, we'll return to "
11066 "this horror scenario later). However, it's more likely that you'll notice "
11067 "immediately, because Mercurial will display the URL it's pulling from, or you "
11068 "will see it pull a suspiciously large number of changes into the repository."
11069 msgstr ""
11071 #. type: Content of: <book><chapter><sect1><sect2><para>
11072 #: ../en/ch09-undo.xml:106
11073 msgid ""
11074 "The <command role=\"hg-cmd\">hg rollback</command> command will work nicely "
11075 "to expunge all of the changesets that you just pulled. Mercurial groups all "
11076 "changes from one <command role=\"hg-cmd\">hg pull</command> into a single "
11077 "transaction, so one <command role=\"hg-cmd\">hg rollback</command> is all you "
11078 "need to undo this mistake."
11079 msgstr ""
11081 #. type: Content of: <book><chapter><sect1><sect2><title>
11082 #: ../en/ch09-undo.xml:115
11083 msgid "Rolling back is useless once you've pushed"
11084 msgstr "当完成推送后,回滚是无效的"
11086 #. type: Content of: <book><chapter><sect1><sect2><para>
11087 #: ../en/ch09-undo.xml:117
11088 msgid ""
11089 "The value of the <command role=\"hg-cmd\">hg rollback</command> command drops "
11090 "to zero once you've pushed your changes to another repository. Rolling back "
11091 "a change makes it disappear entirely, but <emphasis>only</emphasis> in the "
11092 "repository in which you perform the <command role=\"hg-cmd\">hg rollback</"
11093 "command>. Because a rollback eliminates history, there's no way for the "
11094 "disappearance of a change to propagate between repositories."
11095 msgstr ""
11097 #. type: Content of: <book><chapter><sect1><sect2><para>
11098 #: ../en/ch09-undo.xml:126
11099 msgid ""
11100 "If you've pushed a change to another repository&emdash;particularly if it's a "
11101 "shared repository&emdash;it has essentially <quote>escaped into the wild,</"
11102 "quote> and you'll have to recover from your mistake in a different way. If "
11103 "you push a changeset somewhere, then roll it back, then pull from the "
11104 "repository you pushed to, the changeset you thought you'd gotten rid of will "
11105 "simply reappear in your repository."
11106 msgstr ""
11108 #. type: Content of: <book><chapter><sect1><sect2><para>
11109 #: ../en/ch09-undo.xml:135
11110 msgid ""
11111 "(If you absolutely know for sure that the change you want to roll back is the "
11112 "most recent change in the repository that you pushed to, <emphasis>and</"
11113 "emphasis> you know that nobody else could have pulled it from that "
11114 "repository, you can roll back the changeset there, too, but you really should "
11115 "not expect this to work reliably. Sooner or later a change really will make "
11116 "it into a repository that you don't directly control (or have forgotten "
11117 "about), and come back to bite you.)"
11118 msgstr ""
11120 #. type: Content of: <book><chapter><sect1><sect2><title>
11121 #: ../en/ch09-undo.xml:147
11122 msgid "You can only roll back once"
11123 msgstr "你只能回滚一次"
11125 #. type: Content of: <book><chapter><sect1><sect2><para>
11126 #: ../en/ch09-undo.xml:149
11127 msgid ""
11128 "Mercurial stores exactly one transaction in its transaction log; that "
11129 "transaction is the most recent one that occurred in the repository. This "
11130 "means that you can only roll back one transaction. If you expect to be able "
11131 "to roll back one transaction, then its predecessor, this is not the behavior "
11132 "you will get."
11133 msgstr ""
11135 #. type: Content of: <book><chapter><sect1><sect2><para>
11136 #: ../en/ch09-undo.xml:158
11137 msgid ""
11138 "Once you've rolled back one transaction in a repository, you can't roll back "
11139 "again in that repository until you perform another commit or pull."
11140 msgstr ""
11142 #. type: Content of: <book><chapter><sect1><title>
11143 #: ../en/ch09-undo.xml:165
11144 msgid "Reverting the mistaken change"
11145 msgstr "撤销错误的修改"
11147 #. type: Content of: <book><chapter><sect1><para>
11148 #: ../en/ch09-undo.xml:167
11149 msgid ""
11150 "If you make a modification to a file, and decide that you really didn't want "
11151 "to change the file at all, and you haven't yet committed your changes, the "
11152 "<command role=\"hg-cmd\">hg revert</command> command is the one you'll need. "
11153 "It looks at the changeset that's the parent of the working directory, and "
11154 "restores the contents of the file to their state as of that changeset. "
11155 "(That's a long-winded way of saying that, in the normal case, it undoes your "
11156 "modifications.)"
11157 msgstr ""
11159 #. type: Content of: <book><chapter><sect1><para>
11160 #: ../en/ch09-undo.xml:176
11161 msgid ""
11162 "Let's illustrate how the <command role=\"hg-cmd\">hg revert</command> command "
11163 "works with yet another small example. We'll begin by modifying a file that "
11164 "Mercurial is already tracking."
11165 msgstr ""
11167 #. type: Content of: <book><chapter><sect1><para>
11168 #: ../en/ch09-undo.xml:183
11169 msgid ""
11170 "If we don't want that change, we can simply <command role=\"hg-cmd\">hg "
11171 "revert</command> the file."
11172 msgstr ""
11174 #. type: Content of: <book><chapter><sect1><para>
11175 #: ../en/ch09-undo.xml:189
11176 msgid ""
11177 "The <command role=\"hg-cmd\">hg revert</command> command provides us with an "
11178 "extra degree of safety by saving our modified file with a <filename>.orig</"
11179 "filename> extension."
11180 msgstr ""
11182 #. type: Content of: <book><chapter><sect1><tip><title>
11183 #: ../en/ch09-undo.xml:197
11184 msgid "Be careful with <filename>.orig</filename> files"
11185 msgstr "小心 <filename>.orig</filename> 文件"
11187 #. type: Content of: <book><chapter><sect1><tip><para>
11188 #: ../en/ch09-undo.xml:199
11189 msgid ""
11190 "It's extremely unlikely that you are either using Mercurial to manage files "
11191 "with <filename>.orig</filename> extensions or that you even care about the "
11192 "contents of such files. Just in case, though, it's useful to remember that "
11193 "<command role=\"hg-cmd\">hg revert</command> will unconditionally overwrite "
11194 "an existing file with a <filename>.orig</filename> extension. For instance, "
11195 "if you already have a file named <filename>foo.orig</filename> when you "
11196 "revert <filename>foo</filename>, the contents of <filename>foo.orig</"
11197 "filename> will be clobbered."
11198 msgstr ""
11200 #. type: Content of: <book><chapter><sect1><para>
11201 #: ../en/ch09-undo.xml:211
11202 msgid ""
11203 "Here is a summary of the cases that the <command role=\"hg-cmd\">hg revert</"
11204 "command> command can deal with. We will describe each of these in more "
11205 "detail in the section that follows."
11206 msgstr ""
11208 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
11209 #: ../en/ch09-undo.xml:216
11210 msgid "If you modify a file, it will restore the file to its unmodified state."
11211 msgstr ""
11213 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
11214 #: ../en/ch09-undo.xml:219
11215 msgid ""
11216 "If you <command role=\"hg-cmd\">hg add</command> a file, it will undo the "
11217 "<quote>added</quote> state of the file, but leave the file itself untouched."
11218 msgstr ""
11220 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
11221 #: ../en/ch09-undo.xml:223
11222 msgid ""
11223 "If you delete a file without telling Mercurial, it will restore the file to "
11224 "its unmodified contents."
11225 msgstr ""
11227 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
11228 #: ../en/ch09-undo.xml:226
11229 msgid ""
11230 "If you use the <command role=\"hg-cmd\">hg remove</command> command to remove "
11231 "a file, it will undo the <quote>removed</quote> state of the file, and "
11232 "restore the file to its unmodified contents."
11233 msgstr ""
11235 #. type: Content of: <book><chapter><sect1><sect2><title>
11236 #: ../en/ch09-undo.xml:233
11237 msgid "File management errors"
11238 msgstr "文件管理错误"
11240 #. type: Content of: <book><chapter><sect1><sect2><para>
11241 #: ../en/ch09-undo.xml:235
11242 msgid ""
11243 "The <command role=\"hg-cmd\">hg revert</command> command is useful for more "
11244 "than just modified files. It lets you reverse the results of all of "
11245 "Mercurial's file management commands&emdash;<command role=\"hg-cmd\">hg add</"
11246 "command>, <command role=\"hg-cmd\">hg remove</command>, and so on."
11247 msgstr ""
11250 #. type: Content of: <book><chapter><sect1><sect2><para>
11251 #: ../en/ch09-undo.xml:241
11252 msgid ""
11253 "If you <command role=\"hg-cmd\">hg add</command> a file, then decide that in "
11254 "fact you don't want Mercurial to track it, use <command role=\"hg-cmd\">hg "
11255 "revert</command> to undo the add. Don't worry; Mercurial will not modify the "
11256 "file in any way. It will just <quote>unmark</quote> the file."
11257 msgstr ""
11259 #. type: Content of: <book><chapter><sect1><sect2><para>
11260 #: ../en/ch09-undo.xml:249
11261 msgid ""
11262 "Similarly, if you ask Mercurial to <command role=\"hg-cmd\">hg remove</"
11263 "command> a file, you can use <command role=\"hg-cmd\">hg revert</command> to "
11264 "restore it to the contents it had as of the parent of the working directory. "
11265 "&interaction.daily.revert.remove; This works just as well for a file that you "
11266 "deleted by hand, without telling Mercurial (recall that in Mercurial "
11267 "terminology, this kind of file is called <quote>missing</quote>)."
11268 msgstr ""
11271 #. type: Content of: <book><chapter><sect1><sect2><para>
11272 #: ../en/ch09-undo.xml:260
11273 msgid ""
11274 "If you revert a <command role=\"hg-cmd\">hg copy</command>, the copied-to "
11275 "file remains in your working directory afterwards, untracked. Since a copy "
11276 "doesn't affect the copied-from file in any way, Mercurial doesn't do anything "
11277 "with the copied-from file."
11278 msgstr ""
11280 #. type: Content of: <book><chapter><sect1><title>
11281 #: ../en/ch09-undo.xml:271
11282 msgid "Dealing with committed changes"
11283 msgstr "处理已经提交的修改"
11285 #. type: Content of: <book><chapter><sect1><para>
11286 #: ../en/ch09-undo.xml:273
11287 msgid ""
11288 "Consider a case where you have committed a change <emphasis>a</emphasis>, and "
11289 "another change <emphasis>b</emphasis> on top of it; you then realise that "
11290 "change <emphasis>a</emphasis> was incorrect. Mercurial lets you <quote>back "
11291 "out</quote> an entire changeset automatically, and building blocks that let "
11292 "you reverse part of a changeset by hand."
11293 msgstr ""
11295 #. type: Content of: <book><chapter><sect1><para>
11296 #: ../en/ch09-undo.xml:281
11297 msgid ""
11298 "Before you read this section, here's something to keep in mind: the <command "
11299 "role=\"hg-cmd\">hg backout</command> command undoes the effect of a change by "
11300 "<emphasis>adding</emphasis> to your repository's history, not by modifying or "
11301 "erasing it. It's the right tool to use if you're fixing bugs, but not if "
11302 "you're trying to undo some change that has catastrophic consequences. To "
11303 "deal with those, see <xref linkend=\"sec:undo:aaaiiieee\"/>."
11304 msgstr ""
11306 #. type: Content of: <book><chapter><sect1><sect2><title>
11307 #: ../en/ch09-undo.xml:291
11308 msgid "Backing out a changeset"
11309 msgstr "恢复一个修改集"
11311 #. type: Content of: <book><chapter><sect1><sect2><para>
11312 #: ../en/ch09-undo.xml:293
11313 msgid ""
11314 "The <command role=\"hg-cmd\">hg backout</command> command lets you "
11315 "<quote>undo</quote> the effects of an entire changeset in an automated "
11316 "fashion. Because Mercurial's history is immutable, this command "
11317 "<emphasis>does not</emphasis> get rid of the changeset you want to undo. "
11318 "Instead, it creates a new changeset that <emphasis>reverses</emphasis> the "
11319 "effect of the to-be-undone changeset."
11320 msgstr ""
11323 #. type: Content of: <book><chapter><sect1><sect2><para>
11324 #: ../en/ch09-undo.xml:302
11325 msgid ""
11326 "The operation of the <command role=\"hg-cmd\">hg backout</command> command is "
11327 "a little intricate, so let's illustrate it with some examples. First, we'll "
11328 "create a repository with some simple changes."
11329 msgstr ""
11331 #. type: Content of: <book><chapter><sect1><sect2><para>
11332 #: ../en/ch09-undo.xml:309
11333 msgid ""
11334 "The <command role=\"hg-cmd\">hg backout</command> command takes a single "
11335 "changeset ID as its argument; this is the changeset to back out. Normally, "
11336 "<command role=\"hg-cmd\">hg backout</command> will drop you into a text "
11337 "editor to write a commit message, so you can record why you're backing the "
11338 "change out. In this example, we provide a commit message on the command line "
11339 "using the <option role=\"hg-opt-backout\">-m</option> option."
11340 msgstr ""
11342 #. type: Content of: <book><chapter><sect1><sect2><title>
11343 #: ../en/ch09-undo.xml:320
11344 msgid "Backing out the tip changeset"
11345 msgstr "恢复顶点修改集"
11347 #. type: Content of: <book><chapter><sect1><sect2><para>
11348 #: ../en/ch09-undo.xml:322
11349 msgid "We're going to start by backing out the last changeset we committed."
11350 msgstr ""
11352 #. type: Content of: <book><chapter><sect1><sect2><para>
11353 #: ../en/ch09-undo.xml:327
11354 msgid ""
11355 "You can see that the second line from <filename>myfile</filename> is no "
11356 "longer present. Taking a look at the output of <command role=\"hg-cmd\">hg "
11357 "log</command> gives us an idea of what the <command role=\"hg-cmd\">hg "
11358 "backout</command> command has done. &interaction.backout.simple.log; Notice "
11359 "that the new changeset that <command role=\"hg-cmd\">hg backout</command> has "
11360 "created is a child of the changeset we backed out. It's easier to see this "
11361 "in <xref linkend=\"fig:undo:backout\"/>, which presents a graphical view of "
11362 "the change history. As you can see, the history is nice and linear."
11363 msgstr ""
11365 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
11366 #: ../en/ch09-undo.xml:340 ../en/ch09-undo.xml:460
11367 msgid ""
11368 "Backing out a change using the <command role=\"hg-cmd\">hg backout</command> "
11369 "command"
11370 msgstr "使用 <command role=\"hg-cmd\">hg backout</command> 恢复一个修改"
11372 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
11373 #: ../en/ch09-undo.xml:343
11374 msgid "<imageobject><imagedata fileref=\"figs/undo-simple.png\"/></imageobject>"
11375 msgstr ""
11377 #. type: Content of: <book><chapter><sect1><sect2><title>
11378 #: ../en/ch09-undo.xml:350
11379 msgid "Backing out a non-tip change"
11380 msgstr "恢复非顶点的修改"
11382 #. type: Content of: <book><chapter><sect1><sect2><para>
11383 #: ../en/ch09-undo.xml:352
11384 msgid ""
11385 "If you want to back out a change other than the last one you committed, pass "
11386 "the <option role=\"hg-opt-backout\">--merge</option> option to the <command "
11387 "role=\"hg-cmd\">hg backout</command> command."
11388 msgstr ""
11390 #. type: Content of: <book><chapter><sect1><sect2><para>
11391 #: ../en/ch09-undo.xml:359
11392 msgid ""
11393 "This makes backing out any changeset a <quote>one-shot</quote> operation "
11394 "that's usually simple and fast."
11395 msgstr ""
11397 #. type: Content of: <book><chapter><sect1><sect2><para>
11398 #: ../en/ch09-undo.xml:365
11399 msgid ""
11400 "If you take a look at the contents of <filename>myfile</filename> after the "
11401 "backout finishes, you'll see that the first and third changes are present, "
11402 "but not the second."
11403 msgstr ""
11405 #. type: Content of: <book><chapter><sect1><sect2><para>
11406 #: ../en/ch09-undo.xml:372
11407 msgid ""
11408 "As the graphical history in <xref linkend=\"fig:undo:backout-non-tip\"/> "
11409 "illustrates, Mercurial still commits one change in this kind of situation "
11410 "(the box-shaped node is the ones that Mercurial commits automatically), but "
11411 "the revision graph now looks different. Before Mercurial begins the backout "
11412 "process, it first remembers what the current parent of the working directory "
11413 "is. It then backs out the target changeset, and commits that as a "
11414 "changeset. Finally, it merges back to the previous parent of the working "
11415 "directory, but notice that it <emphasis>does not commit</emphasis> the result "
11416 "of the merge. The repository now contains two heads, and the working "
11417 "directory is in a merge state."
11418 msgstr ""
11420 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
11421 #: ../en/ch09-undo.xml:387
11422 msgid ""
11423 "Automated backout of a non-tip change using the <command role=\"hg-cmd\">hg "
11424 "backout</command> command"
11425 msgstr "使用 <command role=\"hg-cmd\">hg backout</command> 自动恢复非顶点的修改"
11427 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
11428 #: ../en/ch09-undo.xml:390
11429 msgid ""
11430 "<imageobject><imagedata fileref=\"figs/undo-non-tip.png\"/></imageobject>"
11431 msgstr ""
11433 #. type: Content of: <book><chapter><sect1><sect2><para>
11434 #: ../en/ch09-undo.xml:395
11435 msgid ""
11436 "The result is that you end up <quote>back where you were</quote>, only with "
11437 "some extra history that undoes the effect of the changeset you wanted to back "
11438 "out."
11439 msgstr ""
11441 #. type: Content of: <book><chapter><sect1><sect2><para>
11442 #: ../en/ch09-undo.xml:399
11443 msgid ""
11444 "You might wonder why Mercurial does not commit the result of the merge that "
11445 "it performed. The reason lies in Mercurial behaving conservatively: a merge "
11446 "naturally has more scope for error than simply undoing the effect of the tip "
11447 "changeset, so your work will be safest if you first inspect (and test!) the "
11448 "result of the merge, <emphasis>then</emphasis> commit it."
11449 msgstr ""
11451 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
11452 #: ../en/ch09-undo.xml:408
11453 msgid "Always use the <option role=\"hg-opt-backout\">--merge</option> option"
11454 msgstr "始终使用选项 <option role=\"hg-opt-backout\">--merge</option>"
11456 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11457 #: ../en/ch09-undo.xml:411
11458 msgid ""
11459 "In fact, since the <option role=\"hg-opt-backout\">--merge</option> option "
11460 "will do the <quote>right thing</quote> whether or not the changeset you're "
11461 "backing out is the tip (i.e. it won't try to merge if it's backing out the "
11462 "tip, since there's no need), you should <emphasis>always</emphasis> use this "
11463 "option when you run the <command role=\"hg-cmd\">hg backout</command> command."
11464 msgstr ""
11466 #. type: Content of: <book><chapter><sect1><sect2><title>
11467 #: ../en/ch09-undo.xml:422
11468 msgid "Gaining more control of the backout process"
11469 msgstr "在恢复处理中获得更多控制"
11471 #. type: Content of: <book><chapter><sect1><sect2><para>
11472 #: ../en/ch09-undo.xml:424
11473 msgid ""
11474 "While I've recommended that you always use the <option role=\"hg-opt-backout"
11475 "\">--merge</option> option when backing out a change, the <command role=\"hg-"
11476 "cmd\">hg backout</command> command lets you decide how to merge a backout "
11477 "changeset. Taking control of the backout process by hand is something you "
11478 "will rarely need to do, but it can be useful to understand what the <command "
11479 "role=\"hg-cmd\">hg backout</command> command is doing for you automatically. "
11480 "To illustrate this, let's clone our first repository, but omit the backout "
11481 "change that it contains."
11482 msgstr ""
11484 #. type: Content of: <book><chapter><sect1><sect2><para>
11485 #: ../en/ch09-undo.xml:437
11486 msgid ""
11487 "As with our earlier example, We'll commit a third changeset, then back out "
11488 "its parent, and see what happens."
11489 msgstr ""
11491 #. type: Content of: <book><chapter><sect1><sect2><para>
11492 #: ../en/ch09-undo.xml:443
11493 msgid ""
11494 "Our new changeset is again a descendant of the changeset we backout out; it's "
11495 "thus a new head, <emphasis>not</emphasis> a descendant of the changeset that "
11496 "was the tip. The <command role=\"hg-cmd\">hg backout</command> command was "
11497 "quite explicit in telling us this."
11498 msgstr ""
11500 #. type: Content of: <book><chapter><sect1><sect2><para>
11501 #: ../en/ch09-undo.xml:451
11502 msgid ""
11503 "Again, it's easier to see what has happened by looking at a graph of the "
11504 "revision history, in <xref linkend=\"fig:undo:backout-manual\"/>. This makes "
11505 "it clear that when we use <command role=\"hg-cmd\">hg backout</command> to "
11506 "back out a change other than the tip, Mercurial adds a new head to the "
11507 "repository (the change it committed is box-shaped)."
11508 msgstr ""
11510 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
11511 #: ../en/ch09-undo.xml:463
11512 msgid "<imageobject><imagedata fileref=\"figs/undo-manual.png\"/></imageobject>"
11513 msgstr ""
11515 #. type: Content of: <book><chapter><sect1><sect2><para>
11516 #: ../en/ch09-undo.xml:468
11517 msgid ""
11518 "After the <command role=\"hg-cmd\">hg backout</command> command has "
11519 "completed, it leaves the new <quote>backout</quote> changeset as the parent "
11520 "of the working directory."
11521 msgstr ""
11523 #. type: Content of: <book><chapter><sect1><sect2><para>
11524 #: ../en/ch09-undo.xml:475
11525 msgid "Now we have two isolated sets of changes."
11526 msgstr ""
11528 #. type: Content of: <book><chapter><sect1><sect2><para>
11529 #: ../en/ch09-undo.xml:479
11530 msgid ""
11531 "Let's think about what we expect to see as the contents of <filename>myfile</"
11532 "filename> now. The first change should be present, because we've never "
11533 "backed it out. The second change should be missing, as that's the change we "
11534 "backed out. Since the history graph shows the third change as a separate "
11535 "head, we <emphasis>don't</emphasis> expect to see the third change present in "
11536 "<filename>myfile</filename>."
11537 msgstr ""
11539 #. type: Content of: <book><chapter><sect1><sect2><para>
11540 #: ../en/ch09-undo.xml:489
11541 msgid ""
11542 "To get the third change back into the file, we just do a normal merge of our "
11543 "two heads."
11544 msgstr ""
11546 #. type: Content of: <book><chapter><sect1><sect2><para>
11547 #: ../en/ch09-undo.xml:494
11548 msgid ""
11549 "Afterwards, the graphical history of our repository looks like <xref linkend="
11550 "\"fig:undo:backout-manual-merge\"/>."
11551 msgstr ""
11553 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
11554 #: ../en/ch09-undo.xml:499
11555 msgid "Manually merging a backout change"
11556 msgstr "手工合并恢复修改"
11558 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
11559 #: ../en/ch09-undo.xml:501
11560 msgid ""
11561 "<imageobject><imagedata fileref=\"figs/undo-manual-merge.png\"/></imageobject>"
11562 msgstr ""
11564 #. type: Content of: <book><chapter><sect1><sect2><title>
11565 #: ../en/ch09-undo.xml:508
11566 msgid "Why <command role=\"hg-cmd\">hg backout</command> works as it does"
11567 msgstr "<command role=\"hg-cmd\">hg backout</command> 的内幕"
11569 #. type: Content of: <book><chapter><sect1><sect2><para>
11570 #: ../en/ch09-undo.xml:511
11571 msgid ""
11572 "Here's a brief description of how the <command role=\"hg-cmd\">hg backout</"
11573 "command> command works."
11574 msgstr ""
11576 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
11577 #: ../en/ch09-undo.xml:514
11578 msgid ""
11579 "It ensures that the working directory is <quote>clean</quote>, i.e. that the "
11580 "output of <command role=\"hg-cmd\">hg status</command> would be empty."
11581 msgstr ""
11583 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
11584 #: ../en/ch09-undo.xml:518
11585 msgid ""
11586 "It remembers the current parent of the working directory. Let's call this "
11587 "changeset <literal>orig</literal>."
11588 msgstr ""
11590 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
11591 #: ../en/ch09-undo.xml:522
11592 msgid ""
11593 "It does the equivalent of a <command role=\"hg-cmd\">hg update</command> to "
11594 "sync the working directory to the changeset you want to back out. Let's call "
11595 "this changeset <literal>backout</literal>."
11596 msgstr ""
11598 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
11599 #: ../en/ch09-undo.xml:527
11600 msgid ""
11601 "It finds the parent of that changeset. Let's call that changeset "
11602 "<literal>parent</literal>."
11603 msgstr ""
11605 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
11606 #: ../en/ch09-undo.xml:530
11607 msgid ""
11608 "For each file that the <literal>backout</literal> changeset affected, it does "
11609 "the equivalent of a <command role=\"hg-cmd\">hg revert -r parent</command> on "
11610 "that file, to restore it to the contents it had before that changeset was "
11611 "committed."
11612 msgstr ""
11614 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
11615 #: ../en/ch09-undo.xml:537
11616 msgid ""
11617 "It commits the result as a new changeset. This changeset has "
11618 "<literal>backout</literal> as its parent."
11619 msgstr ""
11621 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
11622 #: ../en/ch09-undo.xml:541
11623 msgid ""
11624 "If you specify <option role=\"hg-opt-backout\">--merge</option> on the "
11625 "command line, it merges with <literal>orig</literal>, and commits the result "
11626 "of the merge."
11627 msgstr ""
11629 #. type: Content of: <book><chapter><sect1><sect2><para>
11630 #: ../en/ch09-undo.xml:547
11631 msgid ""
11632 "An alternative way to implement the <command role=\"hg-cmd\">hg backout</"
11633 "command> command would be to <command role=\"hg-cmd\">hg export</command> the "
11634 "to-be-backed-out changeset as a diff, then use the <option role=\"cmd-opt-"
11635 "patch\">--reverse</option> option to the <command>patch</command> command to "
11636 "reverse the effect of the change without fiddling with the working "
11637 "directory. This sounds much simpler, but it would not work nearly as well."
11638 msgstr ""
11640 #. type: Content of: <book><chapter><sect1><sect2><para>
11641 #: ../en/ch09-undo.xml:557
11642 msgid ""
11643 "The reason that <command role=\"hg-cmd\">hg backout</command> does an update, "
11644 "a commit, a merge, and another commit is to give the merge machinery the best "
11645 "chance to do a good job when dealing with all the changes <emphasis>between</"
11646 "emphasis> the change you're backing out and the current tip."
11647 msgstr ""
11649 #. type: Content of: <book><chapter><sect1><sect2><para>
11650 #: ../en/ch09-undo.xml:564
11651 msgid ""
11652 "If you're backing out a changeset that's 100 revisions back in your project's "
11653 "history, the chances that the <command>patch</command> command will be able "
11654 "to apply a reverse diff cleanly are not good, because intervening changes are "
11655 "likely to have <quote>broken the context</quote> that <command>patch</"
11656 "command> uses to determine whether it can apply a patch (if this sounds like "
11657 "gibberish, see <xref linkend=\"sec:mq:patch\"/> for a discussion of the "
11658 "<command>patch</command> command). Also, Mercurial's merge machinery will "
11659 "handle files and directories being renamed, permission changes, and "
11660 "modifications to binary files, none of which <command>patch</command> can "
11661 "deal with."
11662 msgstr ""
11664 #. type: Content of: <book><chapter><sect1><title>
11665 #: ../en/ch09-undo.xml:581
11666 msgid "Changes that should never have been"
11667 msgstr "不该发生的修改"
11669 #. type: Content of: <book><chapter><sect1><para>
11670 #: ../en/ch09-undo.xml:583
11671 msgid ""
11672 "Most of the time, the <command role=\"hg-cmd\">hg backout</command> command "
11673 "is exactly what you need if you want to undo the effects of a change. It "
11674 "leaves a permanent record of exactly what you did, both when committing the "
11675 "original changeset and when you cleaned up after it."
11676 msgstr ""
11678 #. type: Content of: <book><chapter><sect1><para>
11679 #: ../en/ch09-undo.xml:589
11680 msgid ""
11681 "On rare occasions, though, you may find that you've committed a change that "
11682 "really should not be present in the repository at all. For example, it would "
11683 "be very unusual, and usually considered a mistake, to commit a software "
11684 "project's object files as well as its source files. Object files have almost "
11685 "no intrinsic value, and they're <emphasis>big</emphasis>, so they increase "
11686 "the size of the repository and the amount of time it takes to clone or pull "
11687 "changes."
11688 msgstr ""
11690 #. type: Content of: <book><chapter><sect1><para>
11691 #: ../en/ch09-undo.xml:598
11692 msgid ""
11693 "Before I discuss the options that you have if you commit a <quote>brown paper "
11694 "bag</quote> change (the kind that's so bad that you want to pull a brown "
11695 "paper bag over your head), let me first discuss some approaches that probably "
11696 "won't work."
11697 msgstr ""
11699 #. type: Content of: <book><chapter><sect1><para>
11700 #: ../en/ch09-undo.xml:603
11701 msgid ""
11702 "Since Mercurial treats history as accumulative&emdash;every change builds on "
11703 "top of all changes that preceded it&emdash;you generally can't just make "
11704 "disastrous changes disappear. The one exception is when you've just "
11705 "committed a change, and it hasn't been pushed or pulled into another "
11706 "repository. That's when you can safely use the <command role=\"hg-cmd\">hg "
11707 "rollback</command> command, as I detailed in <xref linkend=\"sec:undo:rollback"
11708 "\"/>."
11709 msgstr ""
11711 #. type: Content of: <book><chapter><sect1><para>
11712 #: ../en/ch09-undo.xml:612
11713 msgid ""
11714 "After you've pushed a bad change to another repository, you <emphasis>could</"
11715 "emphasis> still use <command role=\"hg-cmd\">hg rollback</command> to make "
11716 "your local copy of the change disappear, but it won't have the consequences "
11717 "you want. The change will still be present in the remote repository, so it "
11718 "will reappear in your local repository the next time you pull."
11719 msgstr ""
11721 #. type: Content of: <book><chapter><sect1><para>
11722 #: ../en/ch09-undo.xml:620
11723 msgid ""
11724 "If a situation like this arises, and you know which repositories your bad "
11725 "change has propagated into, you can <emphasis>try</emphasis> to get rid of "
11726 "the change from <emphasis>every</emphasis> one of those repositories. This "
11727 "is, of course, not a satisfactory solution: if you miss even a single "
11728 "repository while you're expunging, the change is still <quote>in the wild</"
11729 "quote>, and could propagate further."
11730 msgstr ""
11732 #. type: Content of: <book><chapter><sect1><para>
11733 #: ../en/ch09-undo.xml:628
11734 msgid ""
11735 "If you've committed one or more changes <emphasis>after</emphasis> the change "
11736 "that you'd like to see disappear, your options are further reduced. Mercurial "
11737 "doesn't provide a way to <quote>punch a hole</quote> in history, leaving "
11738 "changesets intact."
11739 msgstr ""
11741 #. type: Content of: <book><chapter><sect1><sect2><title>
11742 #: ../en/ch09-undo.xml:635
11743 msgid "Backing out a merge"
11744 msgstr "撤销一个合并"
11746 #. type: Content of: <book><chapter><sect1><sect2><para>
11747 #: ../en/ch09-undo.xml:637
11748 msgid ""
11749 "Since merges are often complicated, it is not unheard of for a merge to be "
11750 "mangled badly, but committed erroneously. Mercurial provides an important "
11751 "safeguard against bad merges by refusing to commit unresolved files, but "
11752 "human ingenuity guarantees that it is still possible to mess a merge up and "
11753 "commit it."
11754 msgstr ""
11756 #. type: Content of: <book><chapter><sect1><sect2><para>
11757 #: ../en/ch09-undo.xml:644
11758 msgid ""
11759 "Given a bad merge that has been committed, usually the best way to approach "
11760 "it is to simply try to repair the damage by hand. A complete disaster that "
11761 "cannot be easily fixed up by hand ought to be very rare, but the <command "
11762 "role=\"hg-cmd\">hg backout</command> command may help in making the cleanup "
11763 "easier. It offers a <option role=\"hg-opt-backout\">--parent</option> option, "
11764 "which lets you specify which parent to revert to when backing out a merge."
11765 msgstr ""
11767 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
11768 #: ../en/ch09-undo.xml:655
11769 msgid "A bad merge"
11770 msgstr "错误的合并"
11772 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
11773 #: ../en/ch09-undo.xml:657
11774 msgid "<imageobject><imagedata fileref=\"figs/bad-merge-1.png\"/></imageobject>"
11775 msgstr ""
11777 #. type: Content of: <book><chapter><sect1><sect2><para>
11778 #: ../en/ch09-undo.xml:662
11779 msgid ""
11780 "Suppose we have a revision graph like that in <xref linkend=\"fig:undo:bad-"
11781 "merge-1\"/>. What we'd like is to <emphasis>redo</emphasis> the merge of "
11782 "revisions 2 and 3."
11783 msgstr ""
11785 #. type: Content of: <book><chapter><sect1><sect2><para>
11786 #: ../en/ch09-undo.xml:667
11787 msgid "One way to do so would be as follows."
11788 msgstr ""
11790 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
11791 #: ../en/ch09-undo.xml:671
11792 msgid ""
11793 "Call <command role=\"hg-cmd\">hg backout --rev=4 --parent=2</command>. This "
11794 "tells <command role=\"hg-cmd\">hg backout</command> to back out revision 4, "
11795 "which is the bad merge, and to when deciding which revision to prefer, to "
11796 "choose parent 2, one of the parents of the merge. The effect can be seen in "
11797 "<xref linkend=\"fig:undo:bad-merge-2\"/>."
11798 msgstr ""
11800 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><figure><title>
11801 #: ../en/ch09-undo.xml:679
11802 msgid "Backing out the merge, favoring one parent"
11803 msgstr "拆除合并,关注一个父亲"
11805 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><figure><mediaobject>
11806 #: ../en/ch09-undo.xml:681
11807 msgid "<imageobject><imagedata fileref=\"figs/bad-merge-2.png\"/></imageobject>"
11808 msgstr ""
11809 "<imageobject><imagedata fileref=\"figs/bad-merge-2.png\"/></imageobject>"
11811 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
11812 #: ../en/ch09-undo.xml:688
11813 msgid ""
11814 "Call <command role=\"hg-cmd\">hg backout --rev=4 --parent=3</command>. This "
11815 "tells <command role=\"hg-cmd\">hg backout</command> to back out revision 4 "
11816 "again, but this time to choose parent 3, the other parent of the merge. The "
11817 "result is visible in <xref linkend=\"fig:undo:bad-merge-3\"/>, in which the "
11818 "repository now contains three heads."
11819 msgstr ""
11821 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><figure><title>
11822 #: ../en/ch09-undo.xml:696
11823 msgid "Backing out the merge, favoring the other parent"
11824 msgstr "拆除合并,关注其它父亲"
11826 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><figure><mediaobject>
11827 #: ../en/ch09-undo.xml:699
11828 msgid "<imageobject><imagedata fileref=\"figs/bad-merge-3.png\"/></imageobject>"
11829 msgstr ""
11830 "<imageobject><imagedata fileref=\"figs/bad-merge-3.png\"/></imageobject>"
11832 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
11833 #: ../en/ch09-undo.xml:706
11834 msgid ""
11835 "Redo the bad merge by merging the two backout heads, which reduces the number "
11836 "of heads in the repository to two, as can be seen in <xref linkend=\"fig:undo:"
11837 "bad-merge-4\"/>."
11838 msgstr ""
11840 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><figure><title>
11841 #: ../en/ch09-undo.xml:711 ../en/ch09-undo.xml:724
11842 msgid "Merging the backouts"
11843 msgstr "合并拆除"
11845 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><figure><mediaobject>
11846 #: ../en/ch09-undo.xml:713
11847 msgid "<imageobject><imagedata fileref=\"figs/bad-merge-4.png\"/></imageobject>"
11848 msgstr ""
11849 "<imageobject><imagedata fileref=\"figs/bad-merge-4.png\"/></imageobject>"
11851 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
11852 #: ../en/ch09-undo.xml:720
11853 msgid ""
11854 "Merge with the commit that was made after the bad merge, as shown in <xref "
11855 "linkend=\"fig:undo:bad-merge-5\"/>."
11856 msgstr ""
11858 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><figure><mediaobject>
11859 #: ../en/ch09-undo.xml:726
11860 msgid "<imageobject><imagedata fileref=\"figs/bad-merge-5.png\"/></imageobject>"
11861 msgstr ""
11863 #. type: Content of: <book><chapter><sect1><sect2><title>
11864 #: ../en/ch09-undo.xml:735
11865 msgid "Protect yourself from <quote>escaped</quote> changes"
11866 msgstr "使用<quote>校验</quote>修改来保护你自己"
11868 #. type: Content of: <book><chapter><sect1><sect2><para>
11869 #: ../en/ch09-undo.xml:738
11870 msgid ""
11871 "If you've committed some changes to your local repository and they've been "
11872 "pushed or pulled somewhere else, this isn't necessarily a disaster. You can "
11873 "protect yourself ahead of time against some classes of bad changeset. This "
11874 "is particularly easy if your team usually pulls changes from a central "
11875 "repository."
11876 msgstr ""
11878 #. type: Content of: <book><chapter><sect1><sect2><para>
11879 #: ../en/ch09-undo.xml:745
11880 msgid ""
11881 "By configuring some hooks on that repository to validate incoming changesets "
11882 "(see chapter <xref linkend=\"chap:hook\"/>), you can automatically prevent "
11883 "some kinds of bad changeset from being pushed to the central repository at "
11884 "all. With such a configuration in place, some kinds of bad changeset will "
11885 "naturally tend to <quote>die out</quote> because they can't propagate into "
11886 "the central repository. Better yet, this happens without any need for "
11887 "explicit intervention."
11888 msgstr ""
11890 #. type: Content of: <book><chapter><sect1><sect2><para>
11891 #: ../en/ch09-undo.xml:755
11892 msgid ""
11893 "For instance, an incoming change hook that verifies that a changeset will "
11894 "actually compile can prevent people from inadvertently <quote>breaking the "
11895 "build</quote>."
11896 msgstr ""
11898 #. type: Content of: <book><chapter><sect1><sect2><title>
11899 #: ../en/ch09-undo.xml:762
11900 msgid "What to do about sensitive changes that escape"
11901 msgstr "处理敏感信息泄漏的方法"
11903 #. type: Content of: <book><chapter><sect1><sect2><para>
11904 #: ../en/ch09-undo.xml:764
11905 msgid ""
11906 "Even a carefully run project can suffer an unfortunate event such as the "
11907 "committing and uncontrolled propagation of a file that contains important "
11908 "passwords."
11909 msgstr ""
11911 #. type: Content of: <book><chapter><sect1><sect2><para>
11912 #: ../en/ch09-undo.xml:768
11913 msgid ""
11914 "If something like this happens to you, and the information that gets "
11915 "accidentally propagated is truly sensitive, your first step should be to "
11916 "mitigate the effect of the leak without trying to control the leak itself. If "
11917 "you are not 100% certain that you know exactly who could have seen the "
11918 "changes, you should immediately change passwords, cancel credit cards, or "
11919 "find some other way to make sure that the information that has leaked is no "
11920 "longer useful. In other words, assume that the change has propagated far and "
11921 "wide, and that there's nothing more you can do."
11922 msgstr ""
11924 #. type: Content of: <book><chapter><sect1><sect2><para>
11925 #: ../en/ch09-undo.xml:779
11926 msgid ""
11927 "You might hope that there would be mechanisms you could use to either figure "
11928 "out who has seen a change or to erase the change permanently everywhere, but "
11929 "there are good reasons why these are not possible."
11930 msgstr ""
11932 #. type: Content of: <book><chapter><sect1><sect2><para>
11933 #: ../en/ch09-undo.xml:784
11934 msgid ""
11935 "Mercurial does not provide an audit trail of who has pulled changes from a "
11936 "repository, because it is usually either impossible to record such "
11937 "information or trivial to spoof it. In a multi-user or networked "
11938 "environment, you should thus be extremely skeptical of yourself if you think "
11939 "that you have identified every place that a sensitive changeset has "
11940 "propagated to. Don't forget that people can and will send bundles by email, "
11941 "have their backup software save data offsite, carry repositories on USB "
11942 "sticks, and find other completely innocent ways to confound your attempts to "
11943 "track down every copy of a problematic change."
11944 msgstr ""
11946 #. type: Content of: <book><chapter><sect1><sect2><para>
11947 #: ../en/ch09-undo.xml:796
11948 msgid ""
11949 "Mercurial also does not provide a way to make a file or changeset completely "
11950 "disappear from history, because there is no way to enforce its disappearance; "
11951 "someone could easily modify their copy of Mercurial to ignore such "
11952 "directives. In addition, even if Mercurial provided such a capability, "
11953 "someone who simply hadn't pulled a <quote>make this file disappear</quote> "
11954 "changeset wouldn't be affected by it, nor would web crawlers visiting at the "
11955 "wrong time, disk backups, or other mechanisms. Indeed, no distributed "
11956 "revision control system can make data reliably vanish. Providing the illusion "
11957 "of such control could easily give a false sense of security, and be worse "
11958 "than not providing it at all."
11959 msgstr ""
11961 #. type: Content of: <book><chapter><sect1><title>
11962 #: ../en/ch09-undo.xml:812
11963 msgid "Finding the source of a bug"
11964 msgstr "查找问题的根源"
11966 #. type: Content of: <book><chapter><sect1><para>
11967 #: ../en/ch09-undo.xml:814
11968 msgid ""
11969 "While it's all very well to be able to back out a changeset that introduced a "
11970 "bug, this requires that you know which changeset to back out. Mercurial "
11971 "provides an invaluable command, called <command role=\"hg-cmd\">hg bisect</"
11972 "command>, that helps you to automate this process and accomplish it very "
11973 "efficiently."
11974 msgstr ""
11976 #. type: Content of: <book><chapter><sect1><para>
11977 #: ../en/ch09-undo.xml:821
11978 msgid ""
11979 "The idea behind the <command role=\"hg-cmd\">hg bisect</command> command is "
11980 "that a changeset has introduced some change of behavior that you can identify "
11981 "with a simple pass/fail test. You don't know which piece of code introduced "
11982 "the change, but you know how to test for the presence of the bug. The "
11983 "<command role=\"hg-cmd\">hg bisect</command> command uses your test to direct "
11984 "its search for the changeset that introduced the code that caused the bug."
11985 msgstr ""
11987 #. type: Content of: <book><chapter><sect1><para>
11988 #: ../en/ch09-undo.xml:830
11989 msgid ""
11990 "Here are a few scenarios to help you understand how you might apply this "
11991 "command."
11992 msgstr ""
11994 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
11995 #: ../en/ch09-undo.xml:833
11996 msgid ""
11997 "The most recent version of your software has a bug that you remember wasn't "
11998 "present a few weeks ago, but you don't know when it was introduced. Here, "
11999 "your binary test checks for the presence of that bug."
12000 msgstr ""
12002 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12003 #: ../en/ch09-undo.xml:838
12004 msgid ""
12005 "You fixed a bug in a rush, and now it's time to close the entry in your "
12006 "team's bug database. The bug database requires a changeset ID when you close "
12007 "an entry, but you don't remember which changeset you fixed the bug in. Once "
12008 "again, your binary test checks for the presence of the bug."
12009 msgstr ""
12011 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12012 #: ../en/ch09-undo.xml:845
12013 msgid ""
12014 "Your software works correctly, but runs 15% slower than the last time you "
12015 "measured it. You want to know which changeset introduced the performance "
12016 "regression. In this case, your binary test measures the performance of your "
12017 "software, to see whether it's <quote>fast</quote> or <quote>slow</quote>."
12018 msgstr ""
12020 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12021 #: ../en/ch09-undo.xml:852
12022 msgid ""
12023 "The sizes of the components of your project that you ship exploded recently, "
12024 "and you suspect that something changed in the way you build your project."
12025 msgstr ""
12027 #. type: Content of: <book><chapter><sect1><para>
12028 #: ../en/ch09-undo.xml:857
12029 msgid ""
12030 "From these examples, it should be clear that the <command role=\"hg-cmd\">hg "
12031 "bisect</command> command is not useful only for finding the sources of bugs. "
12032 "You can use it to find any <quote>emergent property</quote> of a repository "
12033 "(anything that you can't find from a simple text search of the files in the "
12034 "tree) for which you can write a binary test."
12035 msgstr ""
12037 #. type: Content of: <book><chapter><sect1><para>
12038 #: ../en/ch09-undo.xml:864
12039 msgid ""
12040 "We'll introduce a little bit of terminology here, just to make it clear which "
12041 "parts of the search process are your responsibility, and which are "
12042 "Mercurial's. A <emphasis>test</emphasis> is something that <emphasis>you</"
12043 "emphasis> run when <command role=\"hg-cmd\">hg bisect</command> chooses a "
12044 "changeset. A <emphasis>probe</emphasis> is what <command role=\"hg-cmd\">hg "
12045 "bisect</command> runs to tell whether a revision is good. Finally, we'll use "
12046 "the word <quote>bisect</quote>, as both a noun and a verb, to stand in for "
12047 "the phrase <quote>search using the <command role=\"hg-cmd\">hg bisect</"
12048 "command> command</quote>."
12049 msgstr ""
12051 #. type: Content of: <book><chapter><sect1><para>
12052 #: ../en/ch09-undo.xml:877
12053 msgid ""
12054 "One simple way to automate the searching process would be simply to probe "
12055 "every changeset. However, this scales poorly. If it took ten minutes to "
12056 "test a single changeset, and you had 10,000 changesets in your repository, "
12057 "the exhaustive approach would take on average 35 <emphasis>days</emphasis> to "
12058 "find the changeset that introduced a bug. Even if you knew that the bug was "
12059 "introduced by one of the last 500 changesets, and limited your search to "
12060 "those, you'd still be looking at over 40 hours to find the changeset that "
12061 "introduced your bug."
12062 msgstr ""
12064 #. type: Content of: <book><chapter><sect1><para>
12065 #: ../en/ch09-undo.xml:887
12066 msgid ""
12067 "What the <command role=\"hg-cmd\">hg bisect</command> command does is use its "
12068 "knowledge of the <quote>shape</quote> of your project's revision history to "
12069 "perform a search in time proportional to the <emphasis>logarithm</emphasis> "
12070 "of the number of changesets to check (the kind of search it performs is "
12071 "called a dichotomic search). With this approach, searching through 10,000 "
12072 "changesets will take less than three hours, even at ten minutes per test (the "
12073 "search will require about 14 tests). Limit your search to the last hundred "
12074 "changesets, and it will take only about an hour (roughly seven tests)."
12075 msgstr ""
12077 #. type: Content of: <book><chapter><sect1><para>
12078 #: ../en/ch09-undo.xml:898
12079 msgid ""
12080 "The <command role=\"hg-cmd\">hg bisect</command> command is aware of the "
12081 "<quote>branchy</quote> nature of a Mercurial project's revision history, so "
12082 "it has no problems dealing with branches, merges, or multiple heads in a "
12083 "repository. It can prune entire branches of history with a single probe, "
12084 "which is how it operates so efficiently."
12085 msgstr ""
12087 #. type: Content of: <book><chapter><sect1><sect2><title>
12088 #: ../en/ch09-undo.xml:906
12089 msgid "Using the <command role=\"hg-cmd\">hg bisect</command> command"
12090 msgstr "使用命令 <command role=\"hg-cmd\">hg bisect</command>"
12092 #. type: Content of: <book><chapter><sect1><sect2><para>
12093 #: ../en/ch09-undo.xml:909
12094 msgid ""
12095 "Here's an example of <command role=\"hg-cmd\">hg bisect</command> in action."
12096 msgstr ""
12098 #. type: Content of: <book><chapter><sect1><sect2><note><para>
12099 #: ../en/ch09-undo.xml:913
12100 msgid ""
12101 "In versions 0.9.5 and earlier of Mercurial, <command role=\"hg-cmd\">hg "
12102 "bisect</command> was not a core command: it was distributed with Mercurial as "
12103 "an extension. This section describes the built-in command, not the old "
12104 "extension."
12105 msgstr ""
12107 #. type: Content of: <book><chapter><sect1><sect2><para>
12108 #: ../en/ch09-undo.xml:920
12109 msgid ""
12110 "Now let's create a repository, so that we can try out the <command role=\"hg-"
12111 "cmd\">hg bisect</command> command in isolation."
12112 msgstr ""
12114 #. type: Content of: <book><chapter><sect1><sect2><para>
12115 #: ../en/ch09-undo.xml:926
12116 msgid ""
12117 "We'll simulate a project that has a bug in it in a simple-minded way: create "
12118 "trivial changes in a loop, and nominate one specific change that will have "
12119 "the <quote>bug</quote>. This loop creates 35 changesets, each adding a "
12120 "single file to the repository. We'll represent our <quote>bug</quote> with a "
12121 "file that contains the text <quote>i have a gub</quote>."
12122 msgstr ""
12124 #. type: Content of: <book><chapter><sect1><sect2><para>
12125 #: ../en/ch09-undo.xml:936
12126 msgid ""
12127 "The next thing that we'd like to do is figure out how to use the <command "
12128 "role=\"hg-cmd\">hg bisect</command> command. We can use Mercurial's normal "
12129 "built-in help mechanism for this."
12130 msgstr ""
12132 #. type: Content of: <book><chapter><sect1><sect2><para>
12133 #: ../en/ch09-undo.xml:943
12134 msgid ""
12135 "The <command role=\"hg-cmd\">hg bisect</command> command works in steps. "
12136 "Each step proceeds as follows."
12137 msgstr ""
12139 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
12140 #: ../en/ch09-undo.xml:946
12141 msgid "You run your binary test."
12142 msgstr ""
12144 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><itemizedlist><listitem><para>
12145 #: ../en/ch09-undo.xml:948
12146 msgid ""
12147 "If the test succeeded, you tell <command role=\"hg-cmd\">hg bisect</command> "
12148 "by running the <command role=\"hg-cmd\">hg bisect --good</command> command."
12149 msgstr ""
12150 "当测试成功后,使用 <command role=\"hg-cmd\">hg bisect --good</command> 命令告"
12151 "诉 <command role=\"hg-cmd\">hg bisect</command> 命令。"
12153 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><itemizedlist><listitem><para>
12154 #: ../en/ch09-undo.xml:953
12155 msgid ""
12156 "If it failed, run the <command role=\"hg-cmd\">hg bisect --bad</command> "
12157 "command."
12158 msgstr ""
12159 "如果失败,执行 <command role=\"hg-cmd\">hg bisect --bad</command> 命令。"
12161 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
12162 #: ../en/ch09-undo.xml:957
12163 msgid ""
12164 "The command uses your information to decide which changeset to test next."
12165 msgstr ""
12167 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
12168 #: ../en/ch09-undo.xml:960
12169 msgid ""
12170 "It updates the working directory to that changeset, and the process begins "
12171 "again."
12172 msgstr ""
12174 #. type: Content of: <book><chapter><sect1><sect2><para>
12175 #: ../en/ch09-undo.xml:963
12176 msgid ""
12177 "The process ends when <command role=\"hg-cmd\">hg bisect</command> identifies "
12178 "a unique changeset that marks the point where your test transitioned from "
12179 "<quote>succeeding</quote> to <quote>failing</quote>."
12180 msgstr ""
12183 #. type: Content of: <book><chapter><sect1><sect2><para>
12184 #: ../en/ch09-undo.xml:968
12185 msgid ""
12186 "To start the search, we must run the <command role=\"hg-cmd\">hg bisect --"
12187 "reset</command> command."
12188 msgstr ""
12190 #. type: Content of: <book><chapter><sect1><sect2><para>
12191 #: ../en/ch09-undo.xml:973
12192 msgid ""
12193 "In our case, the binary test we use is simple: we check to see if any file in "
12194 "the repository contains the string <quote>i have a gub</quote>. If it does, "
12195 "this changeset contains the change that <quote>caused the bug</quote>. By "
12196 "convention, a changeset that has the property we're searching for is "
12197 "<quote>bad</quote>, while one that doesn't is <quote>good</quote>."
12198 msgstr ""
12200 #. type: Content of: <book><chapter><sect1><sect2><para>
12201 #: ../en/ch09-undo.xml:981
12202 msgid ""
12203 "Most of the time, the revision to which the working directory is synced "
12204 "(usually the tip) already exhibits the problem introduced by the buggy "
12205 "change, so we'll mark it as <quote>bad</quote>."
12206 msgstr ""
12209 #. type: Content of: <book><chapter><sect1><sect2><para>
12210 #: ../en/ch09-undo.xml:988
12211 msgid ""
12212 "Our next task is to nominate a changeset that we know <emphasis>doesn't</"
12213 "emphasis> have the bug; the <command role=\"hg-cmd\">hg bisect</command> "
12214 "command will <quote>bracket</quote> its search between the first pair of good "
12215 "and bad changesets. In our case, we know that revision 10 didn't have the "
12216 "bug. (I'll have more words about choosing the first <quote>good</quote> "
12217 "changeset later.)"
12218 msgstr ""
12220 #. type: Content of: <book><chapter><sect1><sect2><para>
12221 #: ../en/ch09-undo.xml:998
12222 msgid "Notice that this command printed some output."
12223 msgstr ""
12225 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12226 #: ../en/ch09-undo.xml:1000
12227 msgid ""
12228 "It told us how many changesets it must consider before it can identify the "
12229 "one that introduced the bug, and how many tests that will require."
12230 msgstr ""
12232 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12233 #: ../en/ch09-undo.xml:1004
12234 msgid ""
12235 "It updated the working directory to the next changeset to test, and told us "
12236 "which changeset it's testing."
12237 msgstr ""
12239 #. type: Content of: <book><chapter><sect1><sect2><para>
12240 #: ../en/ch09-undo.xml:1009
12241 msgid ""
12242 "We now run our test in the working directory. We use the <command>grep</"
12243 "command> command to see if our <quote>bad</quote> file is present in the "
12244 "working directory. If it is, this revision is bad; if not, this revision is "
12245 "good. &interaction.bisect.search.step1;"
12246 msgstr ""
12248 #. type: Content of: <book><chapter><sect1><sect2><para>
12249 #: ../en/ch09-undo.xml:1015
12250 msgid ""
12251 "This test looks like a perfect candidate for automation, so let's turn it "
12252 "into a shell function."
12253 msgstr ""
12255 #. type: Content of: <book><chapter><sect1><sect2><para>
12256 #: ../en/ch09-undo.xml:1019
12257 msgid ""
12258 "We can now run an entire test step with a single command, <literal>mytest</"
12259 "literal>."
12260 msgstr ""
12262 #. type: Content of: <book><chapter><sect1><sect2><para>
12263 #: ../en/ch09-undo.xml:1024
12264 msgid "A few more invocations of our canned test step command, and we're done."
12265 msgstr ""
12267 #. type: Content of: <book><chapter><sect1><sect2><para>
12268 #: ../en/ch09-undo.xml:1029
12269 msgid ""
12270 "Even though we had 40 changesets to search through, the <command role=\"hg-cmd"
12271 "\">hg bisect</command> command let us find the changeset that introduced our "
12272 "<quote>bug</quote> with only five tests. Because the number of tests that "
12273 "the <command role=\"hg-cmd\">hg bisect</command> command performs grows "
12274 "logarithmically with the number of changesets to search, the advantage that "
12275 "it has over the <quote>brute force</quote> search approach increases with "
12276 "every changeset you add."
12277 msgstr ""
12279 #. type: Content of: <book><chapter><sect1><sect2><title>
12280 #: ../en/ch09-undo.xml:1040
12281 msgid "Cleaning up after your search"
12282 msgstr "搜索后的清理"
12284 #. type: Content of: <book><chapter><sect1><sect2><para>
12285 #: ../en/ch09-undo.xml:1042
12286 msgid ""
12287 "When you're finished using the <command role=\"hg-cmd\">hg bisect</command> "
12288 "command in a repository, you can use the <command role=\"hg-cmd\">hg bisect --"
12289 "reset</command> command to drop the information it was using to drive your "
12290 "search. The command doesn't use much space, so it doesn't matter if you "
12291 "forget to run this command. However, <command role=\"hg-cmd\">hg bisect</"
12292 "command> won't let you start a new search in that repository until you do a "
12293 "<command role=\"hg-cmd\">hg bisect --reset</command>."
12294 msgstr ""
12296 #. type: Content of: <book><chapter><sect1><title>
12297 #: ../en/ch09-undo.xml:1057
12298 msgid "Tips for finding bugs effectively"
12299 msgstr "有效查找问题的技巧"
12301 #. type: Content of: <book><chapter><sect1><sect2><title>
12302 #: ../en/ch09-undo.xml:1060
12303 msgid "Give consistent input"
12304 msgstr "给出一致的输入"
12306 #. type: Content of: <book><chapter><sect1><sect2><para>
12307 #: ../en/ch09-undo.xml:1062
12308 msgid ""
12309 "The <command role=\"hg-cmd\">hg bisect</command> command requires that you "
12310 "correctly report the result of every test you perform. If you tell it that a "
12311 "test failed when it really succeeded, it <emphasis>might</emphasis> be able "
12312 "to detect the inconsistency. If it can identify an inconsistency in your "
12313 "reports, it will tell you that a particular changeset is both good and bad. "
12314 "However, it can't do this perfectly; it's about as likely to report the wrong "
12315 "changeset as the source of the bug."
12316 msgstr ""
12318 #. type: Content of: <book><chapter><sect1><sect2><title>
12319 #: ../en/ch09-undo.xml:1074
12320 msgid "Automate as much as possible"
12321 msgstr "尽量自动"
12323 #. type: Content of: <book><chapter><sect1><sect2><para>
12324 #: ../en/ch09-undo.xml:1076
12325 msgid ""
12326 "When I started using the <command role=\"hg-cmd\">hg bisect</command> "
12327 "command, I tried a few times to run my tests by hand, on the command line. "
12328 "This is an approach that I, at least, am not suited to. After a few tries, I "
12329 "found that I was making enough mistakes that I was having to restart my "
12330 "searches several times before finally getting correct results."
12331 msgstr ""
12333 #. type: Content of: <book><chapter><sect1><sect2><para>
12334 #: ../en/ch09-undo.xml:1084
12335 msgid ""
12336 "My initial problems with driving the <command role=\"hg-cmd\">hg bisect</"
12337 "command> command by hand occurred even with simple searches on small "
12338 "repositories; if the problem you're looking for is more subtle, or the number "
12339 "of tests that <command role=\"hg-cmd\">hg bisect</command> must perform "
12340 "increases, the likelihood of operator error ruining the search is much "
12341 "higher. Once I started automating my tests, I had much better results."
12342 msgstr ""
12344 #. type: Content of: <book><chapter><sect1><sect2><para>
12345 #: ../en/ch09-undo.xml:1093
12346 msgid "The key to automated testing is twofold:"
12347 msgstr ""
12349 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12350 #: ../en/ch09-undo.xml:1095
12351 msgid "always test for the same symptom, and"
12352 msgstr ""
12354 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12355 #: ../en/ch09-undo.xml:1097
12356 msgid ""
12357 "always feed consistent input to the <command role=\"hg-cmd\">hg bisect</"
12358 "command> command."
12359 msgstr ""
12361 #. type: Content of: <book><chapter><sect1><sect2><para>
12362 #: ../en/ch09-undo.xml:1100
12363 msgid ""
12364 "In my tutorial example above, the <command>grep</command> command tests for "
12365 "the symptom, and the <literal>if</literal> statement takes the result of this "
12366 "check and ensures that we always feed the same input to the <command role="
12367 "\"hg-cmd\">hg bisect</command> command. The <literal>mytest</literal> "
12368 "function marries these together in a reproducible way, so that every test is "
12369 "uniform and consistent."
12370 msgstr ""
12372 #. type: Content of: <book><chapter><sect1><sect2><title>
12373 #: ../en/ch09-undo.xml:1110
12374 msgid "Check your results"
12375 msgstr "检查你的结果"
12377 #. type: Content of: <book><chapter><sect1><sect2><para>
12378 #: ../en/ch09-undo.xml:1112
12379 msgid ""
12380 "Because the output of a <command role=\"hg-cmd\">hg bisect</command> search "
12381 "is only as good as the input you give it, don't take the changeset it reports "
12382 "as the absolute truth. A simple way to cross-check its report is to manually "
12383 "run your test at each of the following changesets:"
12384 msgstr ""
12386 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12387 #: ../en/ch09-undo.xml:1118
12388 msgid ""
12389 "The changeset that it reports as the first bad revision. Your test should "
12390 "still report this as bad."
12391 msgstr ""
12393 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12394 #: ../en/ch09-undo.xml:1122
12395 msgid ""
12396 "The parent of that changeset (either parent, if it's a merge). Your test "
12397 "should report this changeset as good."
12398 msgstr ""
12400 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12401 #: ../en/ch09-undo.xml:1126
12402 msgid ""
12403 "A child of that changeset. Your test should report this changeset as bad."
12404 msgstr ""
12406 #. type: Content of: <book><chapter><sect1><sect2><title>
12407 #: ../en/ch09-undo.xml:1132
12408 msgid "Beware interference between bugs"
12409 msgstr "谨防问题之间的冲突"
12411 #. type: Content of: <book><chapter><sect1><sect2><para>
12412 #: ../en/ch09-undo.xml:1134
12413 msgid ""
12414 "It's possible that your search for one bug could be disrupted by the presence "
12415 "of another. For example, let's say your software crashes at revision 100, "
12416 "and worked correctly at revision 50. Unknown to you, someone else introduced "
12417 "a different crashing bug at revision 60, and fixed it at revision 80. This "
12418 "could distort your results in one of several ways."
12419 msgstr ""
12421 #. type: Content of: <book><chapter><sect1><sect2><para>
12422 #: ../en/ch09-undo.xml:1142
12423 msgid ""
12424 "It is possible that this other bug completely <quote>masks</quote> yours, "
12425 "which is to say that it occurs before your bug has a chance to manifest "
12426 "itself. If you can't avoid that other bug (for example, it prevents your "
12427 "project from building), and so can't tell whether your bug is present in a "
12428 "particular changeset, the <command role=\"hg-cmd\">hg bisect</command> "
12429 "command cannot help you directly. Instead, you can mark a changeset as "
12430 "untested by running <command role=\"hg-cmd\">hg bisect --skip</command>."
12431 msgstr ""
12433 #. type: Content of: <book><chapter><sect1><sect2><para>
12434 #: ../en/ch09-undo.xml:1152
12435 msgid ""
12436 "A different problem could arise if your test for a bug's presence is not "
12437 "specific enough. If you check for <quote>my program crashes</quote>, then "
12438 "both your crashing bug and an unrelated crashing bug that masks it will look "
12439 "like the same thing, and mislead <command role=\"hg-cmd\">hg bisect</command>."
12440 msgstr ""
12442 #. type: Content of: <book><chapter><sect1><sect2><para>
12443 #: ../en/ch09-undo.xml:1159
12444 msgid ""
12445 "Another useful situation in which to use <command role=\"hg-cmd\">hg bisect --"
12446 "skip</command> is if you can't test a revision because your project was in a "
12447 "broken and hence untestable state at that revision, perhaps because someone "
12448 "checked in a change that prevented the project from building."
12449 msgstr ""
12451 #. type: Content of: <book><chapter><sect1><sect2><title>
12452 #: ../en/ch09-undo.xml:1168
12453 msgid "Bracket your search lazily"
12454 msgstr "减少你的查找工作"
12456 #. type: Content of: <book><chapter><sect1><sect2><para>
12457 #: ../en/ch09-undo.xml:1170
12458 msgid ""
12459 "Choosing the first <quote>good</quote> and <quote>bad</quote> changesets that "
12460 "will mark the end points of your search is often easy, but it bears a little "
12461 "discussion nevertheless. From the perspective of <command role=\"hg-cmd\">hg "
12462 "bisect</command>, the <quote>newest</quote> changeset is conventionally "
12463 "<quote>bad</quote>, and the older changeset is <quote>good</quote>."
12464 msgstr ""
12466 #. type: Content of: <book><chapter><sect1><sect2><para>
12467 #: ../en/ch09-undo.xml:1178
12468 msgid ""
12469 "If you're having trouble remembering when a suitable <quote>good</quote> "
12470 "change was, so that you can tell <command role=\"hg-cmd\">hg bisect</"
12471 "command>, you could do worse than testing changesets at random. Just "
12472 "remember to eliminate contenders that can't possibly exhibit the bug (perhaps "
12473 "because the feature with the bug isn't present yet) and those where another "
12474 "problem masks the bug (as I discussed above)."
12475 msgstr ""
12477 #. type: Content of: <book><chapter><sect1><sect2><para>
12478 #: ../en/ch09-undo.xml:1187
12479 msgid ""
12480 "Even if you end up <quote>early</quote> by thousands of changesets or months "
12481 "of history, you will only add a handful of tests to the total number that "
12482 "<command role=\"hg-cmd\">hg bisect</command> must perform, thanks to its "
12483 "logarithmic behavior."
12484 msgstr ""
12486 #. type: Content of: <book><chapter><title>
12487 #: ../en/ch10-hook.xml:5
12488 msgid "Handling repository events with hooks"
12489 msgstr "使用钩子处理版本库事件"
12491 #. type: Content of: <book><chapter><para>
12492 #: ../en/ch10-hook.xml:7
12493 msgid ""
12494 "Mercurial offers a powerful mechanism to let you perform automated actions in "
12495 "response to events that occur in a repository. In some cases, you can even "
12496 "control Mercurial's response to those events."
12497 msgstr ""
12499 #. type: Content of: <book><chapter><para>
12500 #: ../en/ch10-hook.xml:12
12501 msgid ""
12502 "The name Mercurial uses for one of these actions is a <emphasis>hook</"
12503 "emphasis>. Hooks are called <quote>triggers</quote> in some revision control "
12504 "systems, but the two names refer to the same idea."
12505 msgstr ""
12507 #. type: Content of: <book><chapter><sect1><title>
12508 #: ../en/ch10-hook.xml:18
12509 msgid "An overview of hooks in Mercurial"
12510 msgstr "Mercurial 钩子概述"
12512 #. type: Content of: <book><chapter><sect1><para>
12513 #: ../en/ch10-hook.xml:20
12514 msgid ""
12515 "Here is a brief list of the hooks that Mercurial supports. We will revisit "
12516 "each of these hooks in more detail later, in <xref linkend=\"sec:hook:ref\"/>."
12517 msgstr ""
12519 #. type: Content of: <book><chapter><sect1><para>
12520 #: ../en/ch10-hook.xml:24
12521 msgid ""
12522 "Each of the hooks whose description begins with the word <quote>Controlling</"
12523 "quote> has the ability to determine whether an activity can proceed. If the "
12524 "hook succeeds, the activity may proceed; if it fails, the activity is either "
12525 "not permitted or undone, depending on the hook."
12526 msgstr ""
12528 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12529 #: ../en/ch10-hook.xml:31
12530 msgid ""
12531 "<literal role=\"hook\">changegroup</literal>: This is run after a group of "
12532 "changesets has been brought into the repository from elsewhere."
12533 msgstr ""
12535 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12536 #: ../en/ch10-hook.xml:35
12537 msgid ""
12538 "<literal role=\"hook\">commit</literal>: This is run after a new changeset "
12539 "has been created in the local repository."
12540 msgstr ""
12542 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12543 #: ../en/ch10-hook.xml:39
12544 msgid ""
12545 "<literal role=\"hook\">incoming</literal>: This is run once for each new "
12546 "changeset that is brought into the repository from elsewhere. Notice the "
12547 "difference from <literal role=\"hook\">changegroup</literal>, which is run "
12548 "once per <emphasis>group</emphasis> of changesets brought in."
12549 msgstr ""
12551 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12552 #: ../en/ch10-hook.xml:46
12553 msgid ""
12554 "<literal role=\"hook\">outgoing</literal>: This is run after a group of "
12555 "changesets has been transmitted from this repository."
12556 msgstr ""
12558 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12559 #: ../en/ch10-hook.xml:50
12560 msgid ""
12561 "<literal role=\"hook\">prechangegroup</literal>: This is run before starting "
12562 "to bring a group of changesets into the repository."
12563 msgstr ""
12565 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12566 #: ../en/ch10-hook.xml:55
12567 msgid ""
12568 "<literal role=\"hook\">precommit</literal>: Controlling. This is run before "
12569 "starting a commit."
12570 msgstr ""
12572 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12573 #: ../en/ch10-hook.xml:59
12574 msgid ""
12575 "<literal role=\"hook\">preoutgoing</literal>: Controlling. This is run before "
12576 "starting to transmit a group of changesets from this repository."
12577 msgstr ""
12579 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12580 #: ../en/ch10-hook.xml:64
12581 msgid ""
12582 "<literal role=\"hook\">pretag</literal>: Controlling. This is run before "
12583 "creating a tag."
12584 msgstr ""
12586 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12587 #: ../en/ch10-hook.xml:68
12588 msgid ""
12589 "<literal role=\"hook\">pretxnchangegroup</literal>: Controlling. This is run "
12590 "after a group of changesets has been brought into the local repository from "
12591 "another, but before the transaction completes that will make the changes "
12592 "permanent in the repository."
12593 msgstr ""
12595 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12596 #: ../en/ch10-hook.xml:76
12597 msgid ""
12598 "<literal role=\"hook\">pretxncommit</literal>: Controlling. This is run after "
12599 "a new changeset has been created in the local repository, but before the "
12600 "transaction completes that will make it permanent."
12601 msgstr ""
12603 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12604 #: ../en/ch10-hook.xml:82
12605 msgid ""
12606 "<literal role=\"hook\">preupdate</literal>: Controlling. This is run before "
12607 "starting an update or merge of the working directory."
12608 msgstr ""
12610 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12611 #: ../en/ch10-hook.xml:87
12612 msgid ""
12613 "<literal role=\"hook\">tag</literal>: This is run after a tag is created."
12614 msgstr ""
12616 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12617 #: ../en/ch10-hook.xml:91
12618 msgid ""
12619 "<literal role=\"hook\">update</literal>: This is run after an update or merge "
12620 "of the working directory has finished."
12621 msgstr ""
12623 #. type: Content of: <book><chapter><sect1><title>
12624 #: ../en/ch10-hook.xml:99
12625 msgid "Hooks and security"
12626 msgstr "钩子与安全性"
12628 #. type: Content of: <book><chapter><sect1><sect2><title>
12629 #: ../en/ch10-hook.xml:102
12630 msgid "Hooks are run with your privileges"
12631 msgstr "钩子以你的特权执行"
12633 #. type: Content of: <book><chapter><sect1><sect2><para>
12634 #: ../en/ch10-hook.xml:104
12635 msgid ""
12636 "When you run a Mercurial command in a repository, and the command causes a "
12637 "hook to run, that hook runs on <emphasis>your</emphasis> system, under "
12638 "<emphasis>your</emphasis> user account, with <emphasis>your</emphasis> "
12639 "privilege level. Since hooks are arbitrary pieces of executable code, you "
12640 "should treat them with an appropriate level of suspicion. Do not install a "
12641 "hook unless you are confident that you know who created it and what it does."
12642 msgstr ""
12644 #. type: Content of: <book><chapter><sect1><sect2><para>
12645 #: ../en/ch10-hook.xml:115
12646 msgid ""
12647 "In some cases, you may be exposed to hooks that you did not install "
12648 "yourself. If you work with Mercurial on an unfamiliar system, Mercurial will "
12649 "run hooks defined in that system's global <filename role=\"special\">~/.hgrc</"
12650 "filename> file."
12651 msgstr ""
12653 #. type: Content of: <book><chapter><sect1><sect2><para>
12654 #: ../en/ch10-hook.xml:122
12655 msgid ""
12656 "If you are working with a repository owned by another user, Mercurial can run "
12657 "hooks defined in that user's repository, but it will still run them as "
12658 "<quote>you</quote>. For example, if you <command role=\"hg-cmd\">hg pull</"
12659 "command> from that repository, and its <filename role=\"special\">.hg/hgrc</"
12660 "filename> defines a local <literal role=\"hook\">outgoing</literal> hook, "
12661 "that hook will run under your user account, even though you don't own that "
12662 "repository."
12663 msgstr ""
12665 #. type: Content of: <book><chapter><sect1><sect2><note><para>
12666 #: ../en/ch10-hook.xml:134
12667 msgid ""
12668 "This only applies if you are pulling from a repository on a local or network "
12669 "filesystem. If you're pulling over http or ssh, any <literal role=\"hook"
12670 "\">outgoing</literal> hook will run under whatever account is executing the "
12671 "server process, on the server."
12672 msgstr ""
12674 #. type: Content of: <book><chapter><sect1><sect2><para>
12675 #: ../en/ch10-hook.xml:142
12676 msgid ""
12677 "To see what hooks are defined in a repository, use the <command role=\"hg-cmd"
12678 "\">hg showconfig hooks</command> command. If you are working in one "
12679 "repository, but talking to another that you do not own (e.g. using <command "
12680 "role=\"hg-cmd\">hg pull</command> or <command role=\"hg-cmd\">hg incoming</"
12681 "command>), remember that it is the other repository's hooks you should be "
12682 "checking, not your own."
12683 msgstr ""
12685 #. type: Content of: <book><chapter><sect1><sect2><title>
12686 #: ../en/ch10-hook.xml:153
12687 msgid "Hooks do not propagate"
12688 msgstr "钩子不会传播"
12690 #. type: Content of: <book><chapter><sect1><sect2><para>
12691 #: ../en/ch10-hook.xml:155
12692 msgid ""
12693 "In Mercurial, hooks are not revision controlled, and do not propagate when "
12694 "you clone, or pull from, a repository. The reason for this is simple: a hook "
12695 "is a completely arbitrary piece of executable code. It runs under your user "
12696 "identity, with your privilege level, on your machine."
12697 msgstr ""
12699 #. type: Content of: <book><chapter><sect1><sect2><para>
12700 #: ../en/ch10-hook.xml:162
12701 msgid ""
12702 "It would be extremely reckless for any distributed revision control system to "
12703 "implement revision-controlled hooks, as this would offer an easily "
12704 "exploitable way to subvert the accounts of users of the revision control "
12705 "system."
12706 msgstr ""
12708 #. type: Content of: <book><chapter><sect1><sect2><para>
12709 #: ../en/ch10-hook.xml:168
12710 msgid ""
12711 "Since Mercurial does not propagate hooks, if you are collaborating with other "
12712 "people on a common project, you should not assume that they are using the "
12713 "same Mercurial hooks as you are, or that theirs are correctly configured. "
12714 "You should document the hooks you expect people to use."
12715 msgstr ""
12717 #. type: Content of: <book><chapter><sect1><sect2><para>
12718 #: ../en/ch10-hook.xml:175
12719 msgid ""
12720 "In a corporate intranet, this is somewhat easier to control, as you can for "
12721 "example provide a <quote>standard</quote> installation of Mercurial on an NFS "
12722 "filesystem, and use a site-wide <filename role=\"special\">~/.hgrc</filename> "
12723 "file to define hooks that all users will see. However, this too has its "
12724 "limits; see below."
12725 msgstr ""
12727 #. type: Content of: <book><chapter><sect1><sect2><title>
12728 #: ../en/ch10-hook.xml:184
12729 msgid "Hooks can be overridden"
12730 msgstr "钩子可以被覆盖"
12732 #. type: Content of: <book><chapter><sect1><sect2><para>
12733 #: ../en/ch10-hook.xml:186
12734 msgid ""
12735 "Mercurial allows you to override a hook definition by redefining the hook. "
12736 "You can disable it by setting its value to the empty string, or change its "
12737 "behavior as you wish."
12738 msgstr ""
12740 #. type: Content of: <book><chapter><sect1><sect2><para>
12741 #: ../en/ch10-hook.xml:191
12742 msgid ""
12743 "If you deploy a system- or site-wide <filename role=\"special\">~/.hgrc</"
12744 "filename> file that defines some hooks, you should thus understand that your "
12745 "users can disable or override those hooks."
12746 msgstr ""
12748 #. type: Content of: <book><chapter><sect1><sect2><title>
12749 #: ../en/ch10-hook.xml:199
12750 msgid "Ensuring that critical hooks are run"
12751 msgstr "确保关键钩子的执行"
12753 #. type: Content of: <book><chapter><sect1><sect2><para>
12754 #: ../en/ch10-hook.xml:201
12755 msgid ""
12756 "Sometimes you may want to enforce a policy that you do not want others to be "
12757 "able to work around. For example, you may have a requirement that every "
12758 "changeset must pass a rigorous set of tests. Defining this requirement via a "
12759 "hook in a site-wide <filename role=\"special\">~/.hgrc</filename> won't work "
12760 "for remote users on laptops, and of course local users can subvert it at will "
12761 "by overriding the hook."
12762 msgstr ""
12764 #. type: Content of: <book><chapter><sect1><sect2><para>
12765 #: ../en/ch10-hook.xml:210
12766 msgid ""
12767 "Instead, you can set up your policies for use of Mercurial so that people are "
12768 "expected to propagate changes through a well-known <quote>canonical</quote> "
12769 "server that you have locked down and configured appropriately."
12770 msgstr ""
12772 #. type: Content of: <book><chapter><sect1><sect2><para>
12773 #: ../en/ch10-hook.xml:216
12774 msgid ""
12775 "One way to do this is via a combination of social engineering and "
12776 "technology. Set up a restricted-access account; users can push changes over "
12777 "the network to repositories managed by this account, but they cannot log into "
12778 "the account and run normal shell commands. In this scenario, a user can "
12779 "commit a changeset that contains any old garbage they want."
12780 msgstr ""
12782 #. type: Content of: <book><chapter><sect1><sect2><para>
12783 #: ../en/ch10-hook.xml:225
12784 msgid ""
12785 "When someone pushes a changeset to the server that everyone pulls from, the "
12786 "server will test the changeset before it accepts it as permanent, and reject "
12787 "it if it fails to pass the test suite. If people only pull changes from this "
12788 "filtering server, it will serve to ensure that all changes that people pull "
12789 "have been automatically vetted."
12790 msgstr ""
12792 #. type: Content of: <book><chapter><sect1><title>
12793 #: ../en/ch10-hook.xml:237
12794 msgid "A short tutorial on using hooks"
12795 msgstr "使用钩子的简短指南"
12797 #. type: Content of: <book><chapter><sect1><para>
12798 #: ../en/ch10-hook.xml:239
12799 msgid ""
12800 "It is easy to write a Mercurial hook. Let's start with a hook that runs when "
12801 "you finish a <command role=\"hg-cmd\">hg commit</command>, and simply prints "
12802 "the hash of the changeset you just created. The hook is called <literal role="
12803 "\"hook\">commit</literal>."
12804 msgstr ""
12806 #. type: Content of: <book><chapter><sect1><para>
12807 #: ../en/ch10-hook.xml:246
12808 msgid "All hooks follow the pattern in this example."
12809 msgstr ""
12811 #. type: Content of: <book><chapter><sect1><para>
12812 #: ../en/ch10-hook.xml:250
12813 msgid ""
12814 "You add an entry to the <literal role=\"rc-hooks\">hooks</literal> section of "
12815 "your <filename role=\"special\">~/.hgrc</filename>. On the left is the name "
12816 "of the event to trigger on; on the right is the action to take. As you can "
12817 "see, you can run an arbitrary shell command in a hook. Mercurial passes "
12818 "extra information to the hook using environment variables (look for "
12819 "<envar>HG_NODE</envar> in the example)."
12820 msgstr ""
12822 #. type: Content of: <book><chapter><sect1><sect2><title>
12823 #: ../en/ch10-hook.xml:260
12824 msgid "Performing multiple actions per event"
12825 msgstr "每个事件执行多个操作"
12827 #. type: Content of: <book><chapter><sect1><sect2><para>
12828 #: ../en/ch10-hook.xml:262
12829 msgid ""
12830 "Quite often, you will want to define more than one hook for a particular kind "
12831 "of event, as shown below."
12832 msgstr ""
12834 #. type: Content of: <book><chapter><sect1><sect2><para>
12835 #: ../en/ch10-hook.xml:267
12836 msgid ""
12837 "Mercurial lets you do this by adding an <emphasis>extension</emphasis> to the "
12838 "end of a hook's name. You extend a hook's name by giving the name of the "
12839 "hook, followed by a full stop (the <quote><literal>.</literal></quote> "
12840 "character), followed by some more text of your choosing. For example, "
12841 "Mercurial will run both <literal>commit.foo</literal> and <literal>commit."
12842 "bar</literal> when the <literal>commit</literal> event occurs."
12843 msgstr ""
12845 #. type: Content of: <book><chapter><sect1><sect2><para>
12846 #: ../en/ch10-hook.xml:278
12847 msgid ""
12848 "To give a well-defined order of execution when there are multiple hooks "
12849 "defined for an event, Mercurial sorts hooks by extension, and executes the "
12850 "hook commands in this sorted order. In the above example, it will execute "
12851 "<literal>commit.bar</literal> before <literal>commit.foo</literal>, and "
12852 "<literal>commit</literal> before both."
12853 msgstr ""
12855 #. type: Content of: <book><chapter><sect1><sect2><para>
12856 #: ../en/ch10-hook.xml:287
12857 msgid ""
12858 "It is a good idea to use a somewhat descriptive extension when you define a "
12859 "new hook. This will help you to remember what the hook was for. If the hook "
12860 "fails, you'll get an error message that contains the hook name and extension, "
12861 "so using a descriptive extension could give you an immediate hint as to why "
12862 "the hook failed (see <xref linkend=\"sec:hook:perm\"/> for an example)."
12863 msgstr ""
12865 #. type: Content of: <book><chapter><sect1><sect2><title>
12866 #: ../en/ch10-hook.xml:298
12867 msgid "Controlling whether an activity can proceed"
12868 msgstr "控制处理的活动"
12870 #. type: Content of: <book><chapter><sect1><sect2><para>
12871 #: ../en/ch10-hook.xml:300
12872 msgid ""
12873 "In our earlier examples, we used the <literal role=\"hook\">commit</literal> "
12874 "hook, which is run after a commit has completed. This is one of several "
12875 "Mercurial hooks that run after an activity finishes. Such hooks have no way "
12876 "of influencing the activity itself."
12877 msgstr ""
12879 #. type: Content of: <book><chapter><sect1><sect2><para>
12880 #: ../en/ch10-hook.xml:307
12881 msgid ""
12882 "Mercurial defines a number of events that occur before an activity starts; or "
12883 "after it starts, but before it finishes. Hooks that trigger on these events "
12884 "have the added ability to choose whether the activity can continue, or will "
12885 "abort."
12886 msgstr ""
12888 #. type: Content of: <book><chapter><sect1><sect2><para>
12889 #: ../en/ch10-hook.xml:313
12890 msgid ""
12891 "The <literal role=\"hook\">pretxncommit</literal> hook runs after a commit "
12892 "has all but completed. In other words, the metadata representing the "
12893 "changeset has been written out to disk, but the transaction has not yet been "
12894 "allowed to complete. The <literal role=\"hook\">pretxncommit</literal> hook "
12895 "has the ability to decide whether the transaction can complete, or must be "
12896 "rolled back."
12897 msgstr ""
12899 #. type: Content of: <book><chapter><sect1><sect2><para>
12900 #: ../en/ch10-hook.xml:322
12901 msgid ""
12902 "If the <literal role=\"hook\">pretxncommit</literal> hook exits with a status "
12903 "code of zero, the transaction is allowed to complete; the commit finishes; "
12904 "and the <literal role=\"hook\">commit</literal> hook is run. If the <literal "
12905 "role=\"hook\">pretxncommit</literal> hook exits with a non-zero status code, "
12906 "the transaction is rolled back; the metadata representing the changeset is "
12907 "erased; and the <literal role=\"hook\">commit</literal> hook is not run."
12908 msgstr ""
12910 #. type: Content of: <book><chapter><sect1><sect2><para>
12911 #: ../en/ch10-hook.xml:334
12912 msgid ""
12913 "The hook in the example above checks that a commit comment contains a bug "
12914 "ID. If it does, the commit can complete. If not, the commit is rolled back."
12915 msgstr ""
12917 #. type: Content of: <book><chapter><sect1><title>
12918 #: ../en/ch10-hook.xml:342
12919 msgid "Writing your own hooks"
12920 msgstr "编写钩子"
12922 #. type: Content of: <book><chapter><sect1><para>
12923 #: ../en/ch10-hook.xml:344
12924 msgid ""
12925 "When you are writing a hook, you might find it useful to run Mercurial either "
12926 "with the <option role=\"hg-opt-global\">-v</option> option, or the <envar "
12927 "role=\"rc-item-ui\">verbose</envar> config item set to <quote>true</quote>. "
12928 "When you do so, Mercurial will print a message before it calls each hook."
12929 msgstr ""
12931 #. type: Content of: <book><chapter><sect1><sect2><title>
12932 #: ../en/ch10-hook.xml:353
12933 msgid "Choosing how your hook should run"
12934 msgstr "选择钩子的执行方式"
12936 #. type: Content of: <book><chapter><sect1><sect2><para>
12937 #: ../en/ch10-hook.xml:355
12938 msgid ""
12939 "You can write a hook either as a normal program&emdash;typically a shell "
12940 "script&emdash;or as a Python function that is executed within the Mercurial "
12941 "process."
12942 msgstr ""
12944 #. type: Content of: <book><chapter><sect1><sect2><para>
12945 #: ../en/ch10-hook.xml:360
12946 msgid ""
12947 "Writing a hook as an external program has the advantage that it requires no "
12948 "knowledge of Mercurial's internals. You can call normal Mercurial commands "
12949 "to get any added information you need. The trade-off is that external hooks "
12950 "are slower than in-process hooks."
12951 msgstr ""
12953 #. type: Content of: <book><chapter><sect1><sect2><para>
12954 #: ../en/ch10-hook.xml:367
12955 msgid ""
12956 "An in-process Python hook has complete access to the Mercurial API, and does "
12957 "not <quote>shell out</quote> to another process, so it is inherently faster "
12958 "than an external hook. It is also easier to obtain much of the information "
12959 "that a hook requires by using the Mercurial API than by running Mercurial "
12960 "commands."
12961 msgstr ""
12963 #. type: Content of: <book><chapter><sect1><sect2><para>
12964 #: ../en/ch10-hook.xml:375
12965 msgid ""
12966 "If you are comfortable with Python, or require high performance, writing your "
12967 "hooks in Python may be a good choice. However, when you have a "
12968 "straightforward hook to write and you don't need to care about performance "
12969 "(probably the majority of hooks), a shell script is perfectly fine."
12970 msgstr ""
12972 #. type: Content of: <book><chapter><sect1><sect2><title>
12973 #: ../en/ch10-hook.xml:384
12974 msgid "Hook parameters"
12975 msgstr "钩子的参数"
12977 #. type: Content of: <book><chapter><sect1><sect2><para>
12978 #: ../en/ch10-hook.xml:386
12979 msgid ""
12980 "Mercurial calls each hook with a set of well-defined parameters. In Python, "
12981 "a parameter is passed as a keyword argument to your hook function. For an "
12982 "external program, a parameter is passed as an environment variable."
12983 msgstr ""
12985 #. type: Content of: <book><chapter><sect1><sect2><para>
12986 #: ../en/ch10-hook.xml:392
12987 msgid ""
12988 "Whether your hook is written in Python or as a shell script, the hook-"
12989 "specific parameter names and values will be the same. A boolean parameter "
12990 "will be represented as a boolean value in Python, but as the number 1 (for "
12991 "<quote>true</quote>) or 0 (for <quote>false</quote>) as an environment "
12992 "variable for an external hook. If a hook parameter is named <literal>foo</"
12993 "literal>, the keyword argument for a Python hook will also be named "
12994 "<literal>foo</literal>, while the environment variable for an external hook "
12995 "will be named <literal>HG_FOO</literal>."
12996 msgstr ""
12998 #. type: Content of: <book><chapter><sect1><sect2><title>
12999 #: ../en/ch10-hook.xml:406
13000 msgid "Hook return values and activity control"
13001 msgstr "钩子的返回值与活动控制"
13003 #. type: Content of: <book><chapter><sect1><sect2><para>
13004 #: ../en/ch10-hook.xml:408
13005 msgid ""
13006 "A hook that executes successfully must exit with a status of zero if "
13007 "external, or return boolean <quote>false</quote> if in-process. Failure is "
13008 "indicated with a non-zero exit status from an external hook, or an in-process "
13009 "hook returning boolean <quote>true</quote>. If an in-process hook raises an "
13010 "exception, the hook is considered to have failed."
13011 msgstr ""
13013 #. type: Content of: <book><chapter><sect1><sect2><para>
13014 #: ../en/ch10-hook.xml:416
13015 msgid ""
13016 "For a hook that controls whether an activity can proceed, zero/false means "
13017 "<quote>allow</quote>, while non-zero/true/exception means <quote>deny</quote>."
13018 msgstr ""
13020 #. type: Content of: <book><chapter><sect1><sect2><title>
13021 #: ../en/ch10-hook.xml:423
13022 msgid "Writing an external hook"
13023 msgstr "编写外部钩子"
13025 #. type: Content of: <book><chapter><sect1><sect2><para>
13026 #: ../en/ch10-hook.xml:425
13027 msgid ""
13028 "When you define an external hook in your <filename role=\"special\">~/.hgrc</"
13029 "filename> and the hook is run, its value is passed to your shell, which "
13030 "interprets it. This means that you can use normal shell constructs in the "
13031 "body of the hook."
13032 msgstr ""
13034 #. type: Content of: <book><chapter><sect1><sect2><para>
13035 #: ../en/ch10-hook.xml:432
13036 msgid ""
13037 "An executable hook is always run with its current directory set to a "
13038 "repository's root directory."
13039 msgstr ""
13041 #. type: Content of: <book><chapter><sect1><sect2><para>
13042 #: ../en/ch10-hook.xml:436
13043 msgid ""
13044 "Each hook parameter is passed in as an environment variable; the name is "
13045 "upper-cased, and prefixed with the string <quote><literal>HG_</literal></"
13046 "quote>."
13047 msgstr ""
13049 #. type: Content of: <book><chapter><sect1><sect2><para>
13050 #: ../en/ch10-hook.xml:441
13051 msgid ""
13052 "With the exception of hook parameters, Mercurial does not set or modify any "
13053 "environment variables when running a hook. This is useful to remember if you "
13054 "are writing a site-wide hook that may be run by a number of different users "
13055 "with differing environment variables set. In multi-user situations, you "
13056 "should not rely on environment variables being set to the values you have in "
13057 "your environment when testing the hook."
13058 msgstr ""
13060 #. type: Content of: <book><chapter><sect1><sect2><title>
13061 #: ../en/ch10-hook.xml:452
13062 msgid "Telling Mercurial to use an in-process hook"
13063 msgstr "让 Mercurial 使用进程内钩子"
13065 #. type: Content of: <book><chapter><sect1><sect2><para>
13066 #: ../en/ch10-hook.xml:454
13067 msgid ""
13068 "The <filename role=\"special\">~/.hgrc</filename> syntax for defining an in-"
13069 "process hook is slightly different than for an executable hook. The value of "
13070 "the hook must start with the text <quote><literal>python:</literal></quote>, "
13071 "and continue with the fully-qualified name of a callable object to use as the "
13072 "hook's value."
13073 msgstr ""
13075 #. type: Content of: <book><chapter><sect1><sect2><para>
13076 #: ../en/ch10-hook.xml:462
13077 msgid ""
13078 "The module in which a hook lives is automatically imported when a hook is "
13079 "run. So long as you have the module name and <envar>PYTHONPATH</envar> "
13080 "right, it should <quote>just work</quote>."
13081 msgstr ""
13083 #. type: Content of: <book><chapter><sect1><sect2><para>
13084 #: ../en/ch10-hook.xml:468
13085 msgid ""
13086 "The following <filename role=\"special\">~/.hgrc</filename> example snippet "
13087 "illustrates the syntax and meaning of the notions we just described."
13088 msgstr ""
13090 #. type: Content of: <book><chapter><sect1><sect2><para>
13091 #: ../en/ch10-hook.xml:474
13092 msgid ""
13093 "When Mercurial runs the <literal>commit.example</literal> hook, it imports "
13094 "<literal>mymodule.submodule</literal>, looks for the callable object named "
13095 "<literal>myhook</literal>, and calls it."
13096 msgstr ""
13098 #. type: Content of: <book><chapter><sect1><sect2><title>
13099 #: ../en/ch10-hook.xml:482
13100 msgid "Writing an in-process hook"
13101 msgstr "编写进程内钩子"
13103 #. type: Content of: <book><chapter><sect1><sect2><para>
13104 #: ../en/ch10-hook.xml:484
13105 msgid ""
13106 "The simplest in-process hook does nothing, but illustrates the basic shape of "
13107 "the hook API:"
13108 msgstr ""
13110 #. type: Content of: <book><chapter><sect1><sect2><para>
13111 #: ../en/ch10-hook.xml:489
13112 msgid ""
13113 "The first argument to a Python hook is always a <literal role=\"py-mod-"
13114 "mercurial.ui\">ui</literal> object. The second is a repository object; at "
13115 "the moment, it is always an instance of <literal role=\"py-mod-mercurial."
13116 "localrepo\">localrepository</literal>. Following these two arguments are "
13117 "other keyword arguments. Which ones are passed in depends on the hook being "
13118 "called, but a hook can ignore arguments it doesn't care about by dropping "
13119 "them into a keyword argument dict, as with <literal>**kwargs</literal> above."
13120 msgstr ""
13122 #. type: Content of: <book><chapter><sect1><title>
13123 #: ../en/ch10-hook.xml:504
13124 msgid "Some hook examples"
13125 msgstr "钩子样例"
13127 #. type: Content of: <book><chapter><sect1><sect2><title>
13128 #: ../en/ch10-hook.xml:507
13129 msgid "Writing meaningful commit messages"
13130 msgstr "编写有意义的提交日志"
13132 #. type: Content of: <book><chapter><sect1><sect2><para>
13133 #: ../en/ch10-hook.xml:509
13134 msgid ""
13135 "It's hard to imagine a useful commit message being very short. The simple "
13136 "<literal role=\"hook\">pretxncommit</literal> hook of the example below will "
13137 "prevent you from committing a changeset with a message that is less than ten "
13138 "bytes long."
13139 msgstr ""
13141 #. type: Content of: <book><chapter><sect1><sect2><title>
13142 #: ../en/ch10-hook.xml:519
13143 msgid "Checking for trailing whitespace"
13144 msgstr "检查行尾空格"
13146 #. type: Content of: <book><chapter><sect1><sect2><para>
13147 #: ../en/ch10-hook.xml:521
13148 msgid ""
13149 "An interesting use of a commit-related hook is to help you to write cleaner "
13150 "code. A simple example of <quote>cleaner code</quote> is the dictum that a "
13151 "change should not add any new lines of text that contain <quote>trailing "
13152 "whitespace</quote>. Trailing whitespace is a series of space and tab "
13153 "characters at the end of a line of text. In most cases, trailing whitespace "
13154 "is unnecessary, invisible noise, but it is occasionally problematic, and "
13155 "people often prefer to get rid of it."
13156 msgstr ""
13158 #. type: Content of: <book><chapter><sect1><sect2><para>
13159 #: ../en/ch10-hook.xml:532
13160 msgid ""
13161 "You can use either the <literal role=\"hook\">precommit</literal> or <literal "
13162 "role=\"hook\">pretxncommit</literal> hook to tell whether you have a trailing "
13163 "whitespace problem. If you use the <literal role=\"hook\">precommit</"
13164 "literal> hook, the hook will not know which files you are committing, so it "
13165 "will have to check every modified file in the repository for trailing white "
13166 "space. If you want to commit a change to just the file <filename>foo</"
13167 "filename>, but the file <filename>bar</filename> contains trailing "
13168 "whitespace, doing a check in the <literal role=\"hook\">precommit</literal> "
13169 "hook will prevent you from committing <filename>foo</filename> due to the "
13170 "problem with <filename>bar</filename>. This doesn't seem right."
13171 msgstr ""
13173 #. type: Content of: <book><chapter><sect1><sect2><para>
13174 #: ../en/ch10-hook.xml:548
13175 msgid ""
13176 "Should you choose the <literal role=\"hook\">pretxncommit</literal> hook, the "
13177 "check won't occur until just before the transaction for the commit "
13178 "completes. This will allow you to check for problems only the exact files "
13179 "that are being committed. However, if you entered the commit message "
13180 "interactively and the hook fails, the transaction will roll back; you'll have "
13181 "to re-enter the commit message after you fix the trailing whitespace and run "
13182 "<command role=\"hg-cmd\">hg commit</command> again."
13183 msgstr ""
13185 #. type: Content of: <book><chapter><sect1><sect2><para>
13186 #: ../en/ch10-hook.xml:561
13187 msgid ""
13188 "In this example, we introduce a simple <literal role=\"hook\">pretxncommit</"
13189 "literal> hook that checks for trailing whitespace. This hook is short, but "
13190 "not very helpful. It exits with an error status if a change adds a line with "
13191 "trailing whitespace to any file, but does not print any information that "
13192 "might help us to identify the offending file or line. It also has the nice "
13193 "property of not paying attention to unmodified lines; only lines that "
13194 "introduce new trailing whitespace cause problems."
13195 msgstr ""
13197 #. type: Content of: <book><chapter><sect1><sect2><para>
13198 #: ../en/ch10-hook.xml:574
13199 msgid ""
13200 "The above version is much more complex, but also more useful. It parses a "
13201 "unified diff to see if any lines add trailing whitespace, and prints the name "
13202 "of the file and the line number of each such occurrence. Even better, if the "
13203 "change adds trailing whitespace, this hook saves the commit comment and "
13204 "prints the name of the save file before exiting and telling Mercurial to roll "
13205 "the transaction back, so you can use the <option role=\"hg-opt-commit\">-l "
13206 "filename</option> option to <command role=\"hg-cmd\">hg commit</command> to "
13207 "reuse the saved commit message once you've corrected the problem."
13208 msgstr ""
13210 #. type: Content of: <book><chapter><sect1><sect2><para>
13211 #: ../en/ch10-hook.xml:588
13212 msgid ""
13213 "As a final aside, note in the example above the use of <command>sed</"
13214 "command>'s in-place editing feature to get rid of trailing whitespace from a "
13215 "file. This is concise and useful enough that I will reproduce it here (using "
13216 "<command>perl</command> for good measure)."
13217 msgstr ""
13219 #. type: Content of: <book><chapter><sect1><title>
13220 #: ../en/ch10-hook.xml:598
13221 msgid "Bundled hooks"
13222 msgstr "内置的钩子"
13224 #. type: Content of: <book><chapter><sect1><para>
13225 #: ../en/ch10-hook.xml:600
13226 msgid ""
13227 "Mercurial ships with several bundled hooks. You can find them in the "
13228 "<filename class=\"directory\">hgext</filename> directory of a Mercurial "
13229 "source tree. If you are using a Mercurial binary package, the hooks will be "
13230 "located in the <filename class=\"directory\">hgext</filename> directory of "
13231 "wherever your package installer put Mercurial."
13232 msgstr ""
13234 #. type: Content of: <book><chapter><sect1><sect2><title>
13235 #: ../en/ch10-hook.xml:609
13236 msgid ""
13237 "<literal role=\"hg-ext\">acl</literal>&emdash;access control for parts of a "
13238 "repository"
13239 msgstr "<literal role=\"hg-ext\">acl</literal>—版本库的访问控制"
13241 #. type: Content of: <book><chapter><sect1><sect2><para>
13242 #: ../en/ch10-hook.xml:612
13243 msgid ""
13244 "The <literal role=\"hg-ext\">acl</literal> extension lets you control which "
13245 "remote users are allowed to push changesets to a networked server. You can "
13246 "protect any portion of a repository (including the entire repo), so that a "
13247 "specific remote user can push changes that do not affect the protected "
13248 "portion."
13249 msgstr ""
13251 #. type: Content of: <book><chapter><sect1><sect2><para>
13252 #: ../en/ch10-hook.xml:620
13253 msgid ""
13254 "This extension implements access control based on the identity of the user "
13255 "performing a push, <emphasis>not</emphasis> on who committed the changesets "
13256 "they're pushing. It makes sense to use this hook only if you have a locked-"
13257 "down server environment that authenticates remote users, and you want to be "
13258 "sure that only specific users are allowed to push changes to that server."
13259 msgstr ""
13261 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
13262 #: ../en/ch10-hook.xml:630
13263 msgid "Configuring the <literal role=\"hook\">acl</literal> hook"
13264 msgstr "配置 <literal role=\"hook\">acl</literal> 钩子"
13266 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13267 #: ../en/ch10-hook.xml:633
13268 msgid ""
13269 "In order to manage incoming changesets, the <literal role=\"hg-ext\">acl</"
13270 "literal> hook must be used as a <literal role=\"hook\">pretxnchangegroup</"
13271 "literal> hook. This lets it see which files are modified by each incoming "
13272 "changeset, and roll back a group of changesets if they modify "
13273 "<quote>forbidden</quote> files. Example:"
13274 msgstr ""
13276 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13277 #: ../en/ch10-hook.xml:643
13278 msgid ""
13279 "The <literal role=\"hg-ext\">acl</literal> extension is configured using "
13280 "three sections."
13281 msgstr ""
13283 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13284 #: ../en/ch10-hook.xml:647
13285 msgid ""
13286 "The <literal role=\"rc-acl\">acl</literal> section has only one entry, <envar "
13287 "role=\"rc-item-acl\">sources</envar>, which lists the sources of incoming "
13288 "changesets that the hook should pay attention to. You don't normally need to "
13289 "configure this section."
13290 msgstr ""
13292 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13293 #: ../en/ch10-hook.xml:654
13294 msgid ""
13295 "<envar role=\"rc-item-acl\">serve</envar>: Control incoming changesets that "
13296 "are arriving from a remote repository over http or ssh. This is the default "
13297 "value of <envar role=\"rc-item-acl\">sources</envar>, and usually the only "
13298 "setting you'll need for this configuration item."
13299 msgstr ""
13301 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13302 #: ../en/ch10-hook.xml:662
13303 msgid ""
13304 "<envar role=\"rc-item-acl\">pull</envar>: Control incoming changesets that "
13305 "are arriving via a pull from a local repository."
13306 msgstr ""
13308 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13309 #: ../en/ch10-hook.xml:667
13310 msgid ""
13311 "<envar role=\"rc-item-acl\">push</envar>: Control incoming changesets that "
13312 "are arriving via a push from a local repository."
13313 msgstr ""
13315 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13316 #: ../en/ch10-hook.xml:672
13317 msgid ""
13318 "<envar role=\"rc-item-acl\">bundle</envar>: Control incoming changesets that "
13319 "are arriving from another repository via a bundle."
13320 msgstr ""
13322 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13323 #: ../en/ch10-hook.xml:678
13324 msgid ""
13325 "The <literal role=\"rc-acl.allow\">acl.allow</literal> section controls the "
13326 "users that are allowed to add changesets to the repository. If this section "
13327 "is not present, all users that are not explicitly denied are allowed. If "
13328 "this section is present, all users that are not explicitly allowed are denied "
13329 "(so an empty section means that all users are denied)."
13330 msgstr ""
13332 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13333 #: ../en/ch10-hook.xml:687
13334 msgid ""
13335 "The <literal role=\"rc-acl.deny\">acl.deny</literal> section determines which "
13336 "users are denied from adding changesets to the repository. If this section "
13337 "is not present or is empty, no users are denied."
13338 msgstr ""
13340 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13341 #: ../en/ch10-hook.xml:693
13342 msgid ""
13343 "The syntaxes for the <literal role=\"rc-acl.allow\">acl.allow</literal> and "
13344 "<literal role=\"rc-acl.deny\">acl.deny</literal> sections are identical. On "
13345 "the left of each entry is a glob pattern that matches files or directories, "
13346 "relative to the root of the repository; on the right, a user name."
13347 msgstr ""
13349 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13350 #: ../en/ch10-hook.xml:701
13351 msgid ""
13352 "In the following example, the user <literal>docwriter</literal> can only push "
13353 "changes to the <filename class=\"directory\">docs</filename> subtree of the "
13354 "repository, while <literal>intern</literal> can push changes to any file or "
13355 "directory except <filename class=\"directory\">source/sensitive</filename>."
13356 msgstr ""
13358 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
13359 #: ../en/ch10-hook.xml:715 ../en/ch10-hook.xml:979 ../en/ch10-hook.xml:1169
13360 msgid "Testing and troubleshooting"
13361 msgstr "测试与问题处理"
13363 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13364 #: ../en/ch10-hook.xml:717
13365 msgid ""
13366 "If you want to test the <literal role=\"hg-ext\">acl</literal> hook, run it "
13367 "with Mercurial's debugging output enabled. Since you'll probably be running "
13368 "it on a server where it's not convenient (or sometimes possible) to pass in "
13369 "the <option role=\"hg-opt-global\">--debug</option> option, don't forget that "
13370 "you can enable debugging output in your <filename role=\"special\">~/.hgrc</"
13371 "filename>:"
13372 msgstr ""
13374 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13375 #: ../en/ch10-hook.xml:728
13376 msgid ""
13377 "With this enabled, the <literal role=\"hg-ext\">acl</literal> hook will print "
13378 "enough information to let you figure out why it is allowing or forbidding "
13379 "pushes from specific users."
13380 msgstr ""
13382 #. type: Content of: <book><chapter><sect1><sect2><title>
13383 #: ../en/ch10-hook.xml:737
13384 msgid ""
13385 "<literal role=\"hg-ext\">bugzilla</literal>&emdash;integration with Bugzilla"
13386 msgstr "<literal role=\"hg-ext\">bugzilla</literal>—与 Bugzilla 的集成"
13388 #. type: Content of: <book><chapter><sect1><sect2><para>
13389 #: ../en/ch10-hook.xml:741
13390 msgid ""
13391 "The <literal role=\"hg-ext\">bugzilla</literal> extension adds a comment to a "
13392 "Bugzilla bug whenever it finds a reference to that bug ID in a commit "
13393 "comment. You can install this hook on a shared server, so that any time a "
13394 "remote user pushes changes to this server, the hook gets run."
13395 msgstr ""
13397 #. type: Content of: <book><chapter><sect1><sect2><para>
13398 #: ../en/ch10-hook.xml:748
13399 msgid ""
13400 "It adds a comment to the bug that looks like this (you can configure the "
13401 "contents of the comment&emdash;see below):"
13402 msgstr ""
13404 #. type: Content of: <book><chapter><sect1><sect2><para>
13405 #: ../en/ch10-hook.xml:757
13406 msgid ""
13407 "The value of this hook is that it automates the process of updating a bug any "
13408 "time a changeset refers to it. If you configure the hook properly, it makes "
13409 "it easy for people to browse straight from a Bugzilla bug to a changeset that "
13410 "refers to that bug."
13411 msgstr ""
13413 #. type: Content of: <book><chapter><sect1><sect2><para>
13414 #: ../en/ch10-hook.xml:764
13415 msgid ""
13416 "You can use the code in this hook as a starting point for some more exotic "
13417 "Bugzilla integration recipes. Here are a few possibilities:"
13418 msgstr ""
13420 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13421 #: ../en/ch10-hook.xml:769
13422 msgid ""
13423 "Require that every changeset pushed to the server have a valid bug ID in its "
13424 "commit comment. In this case, you'd want to configure the hook as a <literal "
13425 "role=\"hook\">pretxncommit</literal> hook. This would allow the hook to "
13426 "reject changes that didn't contain bug IDs."
13427 msgstr ""
13429 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13430 #: ../en/ch10-hook.xml:777
13431 msgid ""
13432 "Allow incoming changesets to automatically modify the <emphasis>state</"
13433 "emphasis> of a bug, as well as simply adding a comment. For example, the "
13434 "hook could recognise the string <quote>fixed bug 31337</quote> as indicating "
13435 "that it should update the state of bug 31337 to <quote>requires testing</"
13436 "quote>."
13437 msgstr ""
13439 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
13440 #: ../en/ch10-hook.xml:787
13441 msgid "Configuring the <literal role=\"hook\">bugzilla</literal> hook"
13442 msgstr "配置 <literal role=\"hook\">bugzilla</literal> 钩子"
13444 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13445 #: ../en/ch10-hook.xml:790
13446 msgid ""
13447 "You should configure this hook in your server's <filename role=\"special\">~/."
13448 "hgrc</filename> as an <literal role=\"hook\">incoming</literal> hook, for "
13449 "example as follows:"
13450 msgstr ""
13452 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13453 #: ../en/ch10-hook.xml:798
13454 msgid ""
13455 "Because of the specialised nature of this hook, and because Bugzilla was not "
13456 "written with this kind of integration in mind, configuring this hook is a "
13457 "somewhat involved process."
13458 msgstr ""
13460 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13461 #: ../en/ch10-hook.xml:804
13462 msgid ""
13463 "Before you begin, you must install the MySQL bindings for Python on the host"
13464 "(s) where you'll be running the hook. If this is not available as a binary "
13465 "package for your system, you can download it from <citation>web:mysql-python</"
13466 "citation>."
13467 msgstr ""
13469 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13470 #: ../en/ch10-hook.xml:811
13471 msgid ""
13472 "Configuration information for this hook lives in the <literal role=\"rc-"
13473 "bugzilla\">bugzilla</literal> section of your <filename role=\"special\">~/."
13474 "hgrc</filename>."
13475 msgstr ""
13477 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13478 #: ../en/ch10-hook.xml:816
13479 msgid ""
13480 "<envar role=\"rc-item-bugzilla\">version</envar>: The version of Bugzilla "
13481 "installed on the server. The database schema that Bugzilla uses changes "
13482 "occasionally, so this hook has to know exactly which schema to use."
13483 msgstr ""
13485 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13486 #: ../en/ch10-hook.xml:822
13487 msgid ""
13488 "<envar role=\"rc-item-bugzilla\">host</envar>: The hostname of the MySQL "
13489 "server that stores your Bugzilla data. The database must be configured to "
13490 "allow connections from whatever host you are running the <literal role=\"hook"
13491 "\">bugzilla</literal> hook on."
13492 msgstr ""
13494 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13495 #: ../en/ch10-hook.xml:829
13496 msgid ""
13497 "<envar role=\"rc-item-bugzilla\">user</envar>: The username with which to "
13498 "connect to the MySQL server. The database must be configured to allow this "
13499 "user to connect from whatever host you are running the <literal role=\"hook"
13500 "\">bugzilla</literal> hook on. This user must be able to access and modify "
13501 "Bugzilla tables. The default value of this item is <literal>bugs</literal>, "
13502 "which is the standard name of the Bugzilla user in a MySQL database."
13503 msgstr ""
13505 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13506 #: ../en/ch10-hook.xml:840
13507 msgid ""
13508 "<envar role=\"rc-item-bugzilla\">password</envar>: The MySQL password for the "
13509 "user you configured above. This is stored as plain text, so you should make "
13510 "sure that unauthorised users cannot read the <filename role=\"special\">~/."
13511 "hgrc</filename> file where you store this information."
13512 msgstr ""
13514 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13515 #: ../en/ch10-hook.xml:849
13516 msgid ""
13517 "<envar role=\"rc-item-bugzilla\">db</envar>: The name of the Bugzilla "
13518 "database on the MySQL server. The default value of this item is "
13519 "<literal>bugs</literal>, which is the standard name of the MySQL database "
13520 "where Bugzilla stores its data."
13521 msgstr ""
13523 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13524 #: ../en/ch10-hook.xml:856
13525 msgid ""
13526 "<envar role=\"rc-item-bugzilla\">notify</envar>: If you want Bugzilla to send "
13527 "out a notification email to subscribers after this hook has added a comment "
13528 "to a bug, you will need this hook to run a command whenever it updates the "
13529 "database. The command to run depends on where you have installed Bugzilla, "
13530 "but it will typically look something like this, if you have Bugzilla "
13531 "installed in <filename class=\"directory\">/var/www/html/bugzilla</filename>:"
13532 msgstr ""
13534 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13535 #: ../en/ch10-hook.xml:869
13536 msgid ""
13537 "The Bugzilla <literal>processmail</literal> program expects to be given a bug "
13538 "ID (the hook replaces <quote><literal>%s</literal></quote> with the bug ID) "
13539 "and an email address. It also expects to be able to write to some files in "
13540 "the directory that it runs in. If Bugzilla and this hook are not installed "
13541 "on the same machine, you will need to find a way to run <literal>processmail</"
13542 "literal> on the server where Bugzilla is installed."
13543 msgstr ""
13545 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
13546 #: ../en/ch10-hook.xml:884
13547 msgid "Mapping committer names to Bugzilla user names"
13548 msgstr "提交者的名称与 Bugzilla 用户名称的映射"
13550 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13551 #: ../en/ch10-hook.xml:886
13552 msgid ""
13553 "By default, the <literal role=\"hg-ext\">bugzilla</literal> hook tries to use "
13554 "the email address of a changeset's committer as the Bugzilla user name with "
13555 "which to update a bug. If this does not suit your needs, you can map "
13556 "committer email addresses to Bugzilla user names using a <literal role=\"rc-"
13557 "usermap\">usermap</literal> section."
13558 msgstr ""
13560 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13561 #: ../en/ch10-hook.xml:895
13562 msgid ""
13563 "Each item in the <literal role=\"rc-usermap\">usermap</literal> section "
13564 "contains an email address on the left, and a Bugzilla user name on the right."
13565 msgstr ""
13567 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13568 #: ../en/ch10-hook.xml:902
13569 msgid ""
13570 "You can either keep the <literal role=\"rc-usermap\">usermap</literal> data "
13571 "in a normal <filename role=\"special\">~/.hgrc</filename>, or tell the "
13572 "<literal role=\"hg-ext\">bugzilla</literal> hook to read the information from "
13573 "an external <filename>usermap</filename> file. In the latter case, you can "
13574 "store <filename>usermap</filename> data by itself in (for example) a user-"
13575 "modifiable repository. This makes it possible to let your users maintain "
13576 "their own <envar role=\"rc-item-bugzilla\">usermap</envar> entries. The main "
13577 "<filename role=\"special\">~/.hgrc</filename> file might look like this:"
13578 msgstr ""
13580 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13581 #: ../en/ch10-hook.xml:918
13582 msgid ""
13583 "While the <filename>usermap</filename> file that it refers to might look like "
13584 "this:"
13585 msgstr ""
13587 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
13588 #: ../en/ch10-hook.xml:926
13589 msgid "Configuring the text that gets added to a bug"
13590 msgstr "配置增加到问题中的正文"
13592 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13593 #: ../en/ch10-hook.xml:928
13594 msgid ""
13595 "You can configure the text that this hook adds as a comment; you specify it "
13596 "in the form of a Mercurial template. Several <filename role=\"special\">~/."
13597 "hgrc</filename> entries (still in the <literal role=\"rc-bugzilla\">bugzilla</"
13598 "literal> section) control this behavior."
13599 msgstr ""
13601 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13602 #: ../en/ch10-hook.xml:935
13603 msgid ""
13604 "<literal>strip</literal>: The number of leading path elements to strip from a "
13605 "repository's path name to construct a partial path for a URL. For example, if "
13606 "the repositories on your server live under <filename class=\"directory\">/"
13607 "home/hg/repos</filename>, and you have a repository whose path is <filename "
13608 "class=\"directory\">/home/hg/repos/app/tests</filename>, then setting "
13609 "<literal>strip</literal> to <literal>4</literal> will give a partial path of "
13610 "<filename class=\"directory\">app/tests</filename>. The hook will make this "
13611 "partial path available when expanding a template, as <literal>webroot</"
13612 "literal>."
13613 msgstr ""
13615 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13616 #: ../en/ch10-hook.xml:949
13617 msgid ""
13618 "<literal>template</literal>: The text of the template to use. In addition to "
13619 "the usual changeset-related variables, this template can use <literal>hgweb</"
13620 "literal> (the value of the <literal>hgweb</literal> configuration item above) "
13621 "and <literal>webroot</literal> (the path constructed using <literal>strip</"
13622 "literal> above)."
13623 msgstr ""
13625 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13626 #: ../en/ch10-hook.xml:959
13627 msgid ""
13628 "In addition, you can add a <envar role=\"rc-item-web\">baseurl</envar> item "
13629 "to the <literal role=\"rc-web\">web</literal> section of your <filename role="
13630 "\"special\">~/.hgrc</filename>. The <literal role=\"hg-ext\">bugzilla</"
13631 "literal> hook will make this available when expanding a template, as the base "
13632 "string to use when constructing a URL that will let users browse from a "
13633 "Bugzilla comment to view a changeset. Example:"
13634 msgstr ""
13636 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13637 #: ../en/ch10-hook.xml:971
13638 msgid ""
13639 "Here is an example set of <literal role=\"hg-ext\">bugzilla</literal> hook "
13640 "config information."
13641 msgstr ""
13643 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13644 #: ../en/ch10-hook.xml:981
13645 msgid ""
13646 "The most common problems with configuring the <literal role=\"hg-ext"
13647 "\">bugzilla</literal> hook relate to running Bugzilla's "
13648 "<filename>processmail</filename> script and mapping committer names to user "
13649 "names."
13650 msgstr ""
13652 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13653 #: ../en/ch10-hook.xml:987
13654 msgid ""
13655 "Recall from <xref linkend=\"sec:hook:bugzilla:config\"/> above that the user "
13656 "that runs the Mercurial process on the server is also the one that will run "
13657 "the <filename>processmail</filename> script. The <filename>processmail</"
13658 "filename> script sometimes causes Bugzilla to write to files in its "
13659 "configuration directory, and Bugzilla's configuration files are usually owned "
13660 "by the user that your web server runs under."
13661 msgstr ""
13663 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13664 #: ../en/ch10-hook.xml:998
13665 msgid ""
13666 "You can cause <filename>processmail</filename> to be run with the suitable "
13667 "user's identity using the <command>sudo</command> command. Here is an "
13668 "example entry for a <filename>sudoers</filename> file."
13669 msgstr ""
13671 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13672 #: ../en/ch10-hook.xml:1005
13673 msgid ""
13674 "This allows the <literal>hg_user</literal> user to run a "
13675 "<filename>processmail-wrapper</filename> program under the identity of "
13676 "<literal>httpd_user</literal>."
13677 msgstr ""
13679 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13680 #: ../en/ch10-hook.xml:1010
13681 msgid ""
13682 "This indirection through a wrapper script is necessary, because "
13683 "<filename>processmail</filename> expects to be run with its current directory "
13684 "set to wherever you installed Bugzilla; you can't specify that kind of "
13685 "constraint in a <filename>sudoers</filename> file. The contents of the "
13686 "wrapper script are simple:"
13687 msgstr ""
13689 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13690 #: ../en/ch10-hook.xml:1019
13691 msgid ""
13692 "It doesn't seem to matter what email address you pass to "
13693 "<filename>processmail</filename>."
13694 msgstr ""
13696 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13697 #: ../en/ch10-hook.xml:1023
13698 msgid ""
13699 "If your <literal role=\"rc-usermap\">usermap</literal> is not set up "
13700 "correctly, users will see an error message from the <literal role=\"hg-ext"
13701 "\">bugzilla</literal> hook when they push changes to the server. The error "
13702 "message will look like this:"
13703 msgstr ""
13705 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13706 #: ../en/ch10-hook.xml:1030
13707 msgid ""
13708 "What this means is that the committer's address, <literal>john.q."
13709 "public@example.com</literal>, is not a valid Bugzilla user name, nor does it "
13710 "have an entry in your <literal role=\"rc-usermap\">usermap</literal> that "
13711 "maps it to a valid Bugzilla user name."
13712 msgstr ""
13714 #. type: Content of: <book><chapter><sect1><sect2><title>
13715 #: ../en/ch10-hook.xml:1040
13716 msgid ""
13717 "<literal role=\"hg-ext\">notify</literal>&emdash;send email notifications"
13718 msgstr "<literal role=\"hg-ext\">notify</literal>—邮件通知"
13720 #. type: Content of: <book><chapter><sect1><sect2><para>
13721 #: ../en/ch10-hook.xml:1043
13722 msgid ""
13723 "Although Mercurial's built-in web server provides RSS feeds of changes in "
13724 "every repository, many people prefer to receive change notifications via "
13725 "email. The <literal role=\"hg-ext\">notify</literal> hook lets you send out "
13726 "notifications to a set of email addresses whenever changesets arrive that "
13727 "those subscribers are interested in."
13728 msgstr ""
13730 #. type: Content of: <book><chapter><sect1><sect2><para>
13731 #: ../en/ch10-hook.xml:1051
13732 msgid ""
13733 "As with the <literal role=\"hg-ext\">bugzilla</literal> hook, the <literal "
13734 "role=\"hg-ext\">notify</literal> hook is template-driven, so you can "
13735 "customise the contents of the notification messages that it sends."
13736 msgstr ""
13738 #. type: Content of: <book><chapter><sect1><sect2><para>
13739 #: ../en/ch10-hook.xml:1057
13740 msgid ""
13741 "By default, the <literal role=\"hg-ext\">notify</literal> hook includes a "
13742 "diff of every changeset that it sends out; you can limit the size of the "
13743 "diff, or turn this feature off entirely. It is useful for letting "
13744 "subscribers review changes immediately, rather than clicking to follow a URL."
13745 msgstr ""
13747 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
13748 #: ../en/ch10-hook.xml:1065
13749 msgid "Configuring the <literal role=\"hg-ext\">notify</literal> hook"
13750 msgstr "配置 <literal role=\"hg-ext\">notify</literal> 钩子"
13752 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13753 #: ../en/ch10-hook.xml:1068
13754 msgid ""
13755 "You can set up the <literal role=\"hg-ext\">notify</literal> hook to send one "
13756 "email message per incoming changeset, or one per incoming group of changesets "
13757 "(all those that arrived in a single pull or push)."
13758 msgstr ""
13760 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13761 #: ../en/ch10-hook.xml:1080
13762 msgid ""
13763 "Configuration information for this hook lives in the <literal role=\"rc-notify"
13764 "\">notify</literal> section of a <filename role=\"special\">~/.hgrc</"
13765 "filename> file."
13766 msgstr ""
13768 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13769 #: ../en/ch10-hook.xml:1085
13770 msgid ""
13771 "<envar role=\"rc-item-notify\">test</envar>: By default, this hook does not "
13772 "send out email at all; instead, it prints the message that it "
13773 "<emphasis>would</emphasis> send. Set this item to <literal>false</literal> "
13774 "to allow email to be sent. The reason that sending of email is turned off by "
13775 "default is that it takes several tries to configure this extension exactly as "
13776 "you would like, and it would be bad form to spam subscribers with a number of "
13777 "<quote>broken</quote> notifications while you debug your configuration."
13778 msgstr ""
13780 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13781 #: ../en/ch10-hook.xml:1097
13782 msgid ""
13783 "<envar role=\"rc-item-notify\">config</envar>: The path to a configuration "
13784 "file that contains subscription information. This is kept separate from the "
13785 "main <filename role=\"special\">~/.hgrc</filename> so that you can maintain "
13786 "it in a repository of its own. People can then clone that repository, update "
13787 "their subscriptions, and push the changes back to your server."
13788 msgstr ""
13790 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13791 #: ../en/ch10-hook.xml:1106
13792 msgid ""
13793 "<envar role=\"rc-item-notify\">strip</envar>: The number of leading path "
13794 "separator characters to strip from a repository's path, when deciding whether "
13795 "a repository has subscribers. For example, if the repositories on your "
13796 "server live in <filename class=\"directory\">/home/hg/repos</filename>, and "
13797 "<literal role=\"hg-ext\">notify</literal> is considering a repository named "
13798 "<filename class=\"directory\">/home/hg/repos/shared/test</filename>, setting "
13799 "<envar role=\"rc-item-notify\">strip</envar> to <literal>4</literal> will "
13800 "cause <literal role=\"hg-ext\">notify</literal> to trim the path it considers "
13801 "down to <filename class=\"directory\">shared/test</filename>, and it will "
13802 "match subscribers against that."
13803 msgstr ""
13805 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13806 #: ../en/ch10-hook.xml:1123
13807 msgid ""
13808 "<envar role=\"rc-item-notify\">template</envar>: The template text to use "
13809 "when sending messages. This specifies both the contents of the message "
13810 "header and its body."
13811 msgstr ""
13813 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13814 #: ../en/ch10-hook.xml:1129
13815 msgid ""
13816 "<envar role=\"rc-item-notify\">maxdiff</envar>: The maximum number of lines "
13817 "of diff data to append to the end of a message. If a diff is longer than "
13818 "this, it is truncated. By default, this is set to 300. Set this to "
13819 "<literal>0</literal> to omit diffs from notification emails."
13820 msgstr ""
13822 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13823 #: ../en/ch10-hook.xml:1138
13824 msgid ""
13825 "<envar role=\"rc-item-notify\">sources</envar>: A list of sources of "
13826 "changesets to consider. This lets you limit <literal role=\"hg-ext\">notify</"
13827 "literal> to only sending out email about changes that remote users pushed "
13828 "into this repository via a server, for example. See <xref linkend=\"sec:hook:"
13829 "sources\"/> for the sources you can specify here."
13830 msgstr ""
13832 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13833 #: ../en/ch10-hook.xml:1149
13834 msgid ""
13835 "If you set the <envar role=\"rc-item-web\">baseurl</envar> item in the "
13836 "<literal role=\"rc-web\">web</literal> section, you can use it in a template; "
13837 "it will be available as <literal>webroot</literal>."
13838 msgstr ""
13840 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13841 #: ../en/ch10-hook.xml:1155
13842 msgid ""
13843 "Here is an example set of <literal role=\"hg-ext\">notify</literal> "
13844 "configuration information."
13845 msgstr ""
13847 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13848 #: ../en/ch10-hook.xml:1161
13849 msgid "This will produce a message that looks like the following:"
13850 msgstr ""
13852 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13853 #: ../en/ch10-hook.xml:1171
13854 msgid ""
13855 "Do not forget that by default, the <literal role=\"hg-ext\">notify</literal> "
13856 "extension <emphasis>will not send any mail</emphasis> until you explicitly "
13857 "configure it to do so, by setting <envar role=\"rc-item-notify\">test</envar> "
13858 "to <literal>false</literal>. Until you do that, it simply prints the message "
13859 "it <emphasis>would</emphasis> send."
13860 msgstr ""
13862 #. type: Content of: <book><chapter><sect1><title>
13863 #: ../en/ch10-hook.xml:1183
13864 msgid "Information for writers of hooks"
13865 msgstr "编写钩子的信息"
13867 #. type: Content of: <book><chapter><sect1><sect2><title>
13868 #: ../en/ch10-hook.xml:1186
13869 msgid "In-process hook execution"
13870 msgstr "进程内钩子的执行"
13872 #. type: Content of: <book><chapter><sect1><sect2><para>
13873 #: ../en/ch10-hook.xml:1188
13874 msgid "An in-process hook is called with arguments of the following form:"
13875 msgstr ""
13877 #. type: Content of: <book><chapter><sect1><sect2><para>
13878 #: ../en/ch10-hook.xml:1192
13879 msgid ""
13880 "The <literal>ui</literal> parameter is a <literal role=\"py-mod-mercurial.ui"
13881 "\">ui</literal> object. The <literal>repo</literal> parameter is a <literal "
13882 "role=\"py-mod-mercurial.localrepo\">localrepository</literal> object. The "
13883 "names and values of the <literal>**kwargs</literal> parameters depend on the "
13884 "hook being invoked, with the following common features:"
13885 msgstr ""
13887 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13888 #: ../en/ch10-hook.xml:1201
13889 msgid ""
13890 "If a parameter is named <literal>node</literal> or <literal>parentN</"
13891 "literal>, it will contain a hexadecimal changeset ID. The empty string is "
13892 "used to represent <quote>null changeset ID</quote> instead of a string of "
13893 "zeroes."
13894 msgstr ""
13896 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13897 #: ../en/ch10-hook.xml:1208
13898 msgid ""
13899 "If a parameter is named <literal>url</literal>, it will contain the URL of a "
13900 "remote repository, if that can be determined."
13901 msgstr ""
13903 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13904 #: ../en/ch10-hook.xml:1213
13905 msgid ""
13906 "Boolean-valued parameters are represented as Python <literal>bool</literal> "
13907 "objects."
13908 msgstr ""
13910 #. type: Content of: <book><chapter><sect1><sect2><para>
13911 #: ../en/ch10-hook.xml:1218
13912 msgid ""
13913 "An in-process hook is called without a change to the process's working "
13914 "directory (unlike external hooks, which are run in the root of the "
13915 "repository). It must not change the process's working directory, or it will "
13916 "cause any calls it makes into the Mercurial API to fail."
13917 msgstr ""
13919 #. type: Content of: <book><chapter><sect1><sect2><para>
13920 #: ../en/ch10-hook.xml:1225
13921 msgid ""
13922 "If a hook returns a boolean <quote>false</quote> value, it is considered to "
13923 "have succeeded. If it returns a boolean <quote>true</quote> value or raises "
13924 "an exception, it is considered to have failed. A useful way to think of the "
13925 "calling convention is <quote>tell me if you fail</quote>."
13926 msgstr ""
13928 #. type: Content of: <book><chapter><sect1><sect2><para>
13929 #: ../en/ch10-hook.xml:1232
13930 msgid ""
13931 "Note that changeset IDs are passed into Python hooks as hexadecimal strings, "
13932 "not the binary hashes that Mercurial's APIs normally use. To convert a hash "
13933 "from hex to binary, use the <literal>bin</literal> function."
13934 msgstr ""
13936 #. type: Content of: <book><chapter><sect1><sect2><title>
13937 #: ../en/ch10-hook.xml:1240
13938 msgid "External hook execution"
13939 msgstr "外部钩子的执行"
13941 #. type: Content of: <book><chapter><sect1><sect2><para>
13942 #: ../en/ch10-hook.xml:1242
13943 msgid ""
13944 "An external hook is passed to the shell of the user running Mercurial. "
13945 "Features of that shell, such as variable substitution and command "
13946 "redirection, are available. The hook is run in the root directory of the "
13947 "repository (unlike in-process hooks, which are run in the same directory that "
13948 "Mercurial was run in)."
13949 msgstr ""
13951 #. type: Content of: <book><chapter><sect1><sect2><para>
13952 #: ../en/ch10-hook.xml:1250
13953 msgid ""
13954 "Hook parameters are passed to the hook as environment variables. Each "
13955 "environment variable's name is converted in upper case and prefixed with the "
13956 "string <quote><literal>HG_</literal></quote>. For example, if the name of a "
13957 "parameter is <quote><literal>node</literal></quote>, the name of the "
13958 "environment variable representing that parameter will be "
13959 "<quote><literal>HG_NODE</literal></quote>."
13960 msgstr ""
13962 #. type: Content of: <book><chapter><sect1><sect2><para>
13963 #: ../en/ch10-hook.xml:1259
13964 msgid ""
13965 "A boolean parameter is represented as the string <quote><literal>1</literal></"
13966 "quote> for <quote>true</quote>, <quote><literal>0</literal></quote> for "
13967 "<quote>false</quote>. If an environment variable is named <envar>HG_NODE</"
13968 "envar>, <envar>HG_PARENT1</envar> or <envar>HG_PARENT2</envar>, it contains a "
13969 "changeset ID represented as a hexadecimal string. The empty string is used "
13970 "to represent <quote>null changeset ID</quote> instead of a string of zeroes. "
13971 "If an environment variable is named <envar>HG_URL</envar>, it will contain "
13972 "the URL of a remote repository, if that can be determined."
13973 msgstr ""
13975 #. type: Content of: <book><chapter><sect1><sect2><para>
13976 #: ../en/ch10-hook.xml:1271
13977 msgid ""
13978 "If a hook exits with a status of zero, it is considered to have succeeded. "
13979 "If it exits with a non-zero status, it is considered to have failed."
13980 msgstr ""
13982 #. type: Content of: <book><chapter><sect1><sect2><title>
13983 #: ../en/ch10-hook.xml:1278
13984 msgid "Finding out where changesets come from"
13985 msgstr "检查修改集来自何处"
13987 #. type: Content of: <book><chapter><sect1><sect2><para>
13988 #: ../en/ch10-hook.xml:1280
13989 msgid ""
13990 "A hook that involves the transfer of changesets between a local repository "
13991 "and another may be able to find out information about the <quote>far side</"
13992 "quote>. Mercurial knows <emphasis>how</emphasis> changes are being "
13993 "transferred, and in many cases <emphasis>where</emphasis> they are being "
13994 "transferred to or from."
13995 msgstr ""
13997 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
13998 #: ../en/ch10-hook.xml:1289
13999 msgid "Sources of changesets"
14000 msgstr "修改集的来源"
14002 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
14003 #: ../en/ch10-hook.xml:1291
14004 msgid ""
14005 "Mercurial will tell a hook what means are, or were, used to transfer "
14006 "changesets between repositories. This is provided by Mercurial in a Python "
14007 "parameter named <literal>source</literal>, or an environment variable named "
14008 "<envar>HG_SOURCE</envar>."
14009 msgstr ""
14011 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
14012 #: ../en/ch10-hook.xml:1299
14013 msgid ""
14014 "<literal>serve</literal>: Changesets are transferred to or from a remote "
14015 "repository over http or ssh."
14016 msgstr ""
14018 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
14019 #: ../en/ch10-hook.xml:1304
14020 msgid ""
14021 "<literal>pull</literal>: Changesets are being transferred via a pull from one "
14022 "repository into another."
14023 msgstr ""
14025 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
14026 #: ../en/ch10-hook.xml:1309
14027 msgid ""
14028 "<literal>push</literal>: Changesets are being transferred via a push from one "
14029 "repository into another."
14030 msgstr ""
14032 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
14033 #: ../en/ch10-hook.xml:1314
14034 msgid ""
14035 "<literal>bundle</literal>: Changesets are being transferred to or from a "
14036 "bundle."
14037 msgstr ""
14039 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
14040 #: ../en/ch10-hook.xml:1321
14041 msgid "Where changes are going&emdash;remote repository URLs"
14042 msgstr "修改集要到哪里—远程版本库的地址"
14044 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
14045 #: ../en/ch10-hook.xml:1324
14046 msgid ""
14047 "When possible, Mercurial will tell a hook the location of the <quote>far "
14048 "side</quote> of an activity that transfers changeset data between "
14049 "repositories. This is provided by Mercurial in a Python parameter named "
14050 "<literal>url</literal>, or an environment variable named <envar>HG_URL</"
14051 "envar>."
14052 msgstr ""
14054 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
14055 #: ../en/ch10-hook.xml:1332
14056 msgid ""
14057 "This information is not always known. If a hook is invoked in a repository "
14058 "that is being served via http or ssh, Mercurial cannot tell where the remote "
14059 "repository is, but it may know where the client is connecting from. In such "
14060 "cases, the URL will take one of the following forms:"
14061 msgstr ""
14063 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
14064 #: ../en/ch10-hook.xml:1339
14065 msgid ""
14066 "<literal>remote:ssh:1.2.3.4</literal>&emdash;remote ssh client, at the IP "
14067 "address <literal>1.2.3.4</literal>."
14068 msgstr ""
14070 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
14071 #: ../en/ch10-hook.xml:1344
14072 msgid ""
14073 "<literal>remote:http:1.2.3.4</literal>&emdash;remote http client, at the IP "
14074 "address <literal>1.2.3.4</literal>. If the client is using SSL, this will be "
14075 "of the form <literal>remote:https:1.2.3.4</literal>."
14076 msgstr ""
14078 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
14079 #: ../en/ch10-hook.xml:1351
14080 msgid "Empty&emdash;no information could be discovered about the remote client."
14081 msgstr ""
14083 #. type: Content of: <book><chapter><sect1><title>
14084 #: ../en/ch10-hook.xml:1359
14085 msgid "Hook reference"
14086 msgstr "钩子参考"
14088 #. type: Content of: <book><chapter><sect1><sect2><title>
14089 #: ../en/ch10-hook.xml:1362
14090 msgid ""
14091 "<literal role=\"hook\">changegroup</literal>&emdash;after remote changesets "
14092 "added"
14093 msgstr "<literal role=\"hook\">changegroup</literal>—增加远程修改集之后"
14095 #. type: Content of: <book><chapter><sect1><sect2><para>
14096 #: ../en/ch10-hook.xml:1365
14097 msgid ""
14098 "This hook is run after a group of pre-existing changesets has been added to "
14099 "the repository, for example via a <command role=\"hg-cmd\">hg pull</command> "
14100 "or <command role=\"hg-cmd\">hg unbundle</command>. This hook is run once per "
14101 "operation that added one or more changesets. This is in contrast to the "
14102 "<literal role=\"hook\">incoming</literal> hook, which is run once per "
14103 "changeset, regardless of whether the changesets arrive in a group."
14104 msgstr ""
14106 #. type: Content of: <book><chapter><sect1><sect2><para>
14107 #: ../en/ch10-hook.xml:1375
14108 msgid ""
14109 "Some possible uses for this hook include kicking off an automated build or "
14110 "test of the added changesets, updating a bug database, or notifying "
14111 "subscribers that a repository contains new changes."
14112 msgstr ""
14114 #. type: Content of: <book><chapter><sect1><sect2><para>
14115 #: ../en/ch10-hook.xml:1381 ../en/ch10-hook.xml:1421 ../en/ch10-hook.xml:1465
14116 #: ../en/ch10-hook.xml:1507 ../en/ch10-hook.xml:1562 ../en/ch10-hook.xml:1602
14117 #: ../en/ch10-hook.xml:1638 ../en/ch10-hook.xml:1672 ../en/ch10-hook.xml:1736
14118 #: ../en/ch10-hook.xml:1794 ../en/ch10-hook.xml:1830 ../en/ch10-hook.xml:1857
14119 msgid "Parameters to this hook:"
14120 msgstr ""
14122 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14123 #: ../en/ch10-hook.xml:1384 ../en/ch10-hook.xml:1739
14124 msgid ""
14125 "<literal>node</literal>: A changeset ID. The changeset ID of the first "
14126 "changeset in the group that was added. All changesets between this and "
14127 "<literal role=\"tag\">tip</literal>, inclusive, were added by a single "
14128 "<command role=\"hg-cmd\">hg pull</command>, <command role=\"hg-cmd\">hg push</"
14129 "command> or <command role=\"hg-cmd\">hg unbundle</command>."
14130 msgstr ""
14132 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14133 #: ../en/ch10-hook.xml:1393 ../en/ch10-hook.xml:1472 ../en/ch10-hook.xml:1565
14134 #: ../en/ch10-hook.xml:1749
14135 msgid ""
14136 "<literal>source</literal>: A string. The source of these changes. See <xref "
14137 "linkend=\"sec:hook:sources\"/> for details."
14138 msgstr ""
14140 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14141 #: ../en/ch10-hook.xml:1398 ../en/ch10-hook.xml:1477 ../en/ch10-hook.xml:1528
14142 #: ../en/ch10-hook.xml:1570 ../en/ch10-hook.xml:1651 ../en/ch10-hook.xml:1754
14143 msgid ""
14144 "<literal>url</literal>: A URL. The location of the remote repository, if "
14145 "known. See <xref linkend=\"sec:hook:url\"/> for more information."
14146 msgstr ""
14148 #. type: Content of: <book><chapter><sect1><sect2><para>
14149 #: ../en/ch10-hook.xml:1404
14150 msgid ""
14151 "See also: <literal role=\"hook\">incoming</literal> (<xref linkend=\"sec:hook:"
14152 "incoming\"/>), <literal role=\"hook\">prechangegroup</literal> (<xref linkend="
14153 "\"sec:hook:prechangegroup\"/>), <literal role=\"hook\">pretxnchangegroup</"
14154 "literal> (<xref linkend=\"sec:hook:pretxnchangegroup\"/>)"
14155 msgstr ""
14157 #. type: Content of: <book><chapter><sect1><sect2><title>
14158 #: ../en/ch10-hook.xml:1415
14159 msgid ""
14160 "<literal role=\"hook\">commit</literal>&emdash;after a new changeset is "
14161 "created"
14162 msgstr "<literal role=\"hook\">commit</literal>—创建新修改集之后"
14164 #. type: Content of: <book><chapter><sect1><sect2><para>
14165 #: ../en/ch10-hook.xml:1418
14166 msgid "This hook is run after a new changeset has been created."
14167 msgstr ""
14169 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14170 #: ../en/ch10-hook.xml:1424 ../en/ch10-hook.xml:1797
14171 msgid ""
14172 "<literal>node</literal>: A changeset ID. The changeset ID of the newly "
14173 "committed changeset."
14174 msgstr ""
14176 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14177 #: ../en/ch10-hook.xml:1428 ../en/ch10-hook.xml:1801
14178 msgid ""
14179 "<literal>parent1</literal>: A changeset ID. The changeset ID of the first "
14180 "parent of the newly committed changeset."
14181 msgstr ""
14183 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14184 #: ../en/ch10-hook.xml:1433 ../en/ch10-hook.xml:1806
14185 msgid ""
14186 "<literal>parent2</literal>: A changeset ID. The changeset ID of the second "
14187 "parent of the newly committed changeset."
14188 msgstr ""
14190 #. type: Content of: <book><chapter><sect1><sect2><para>
14191 #: ../en/ch10-hook.xml:1439
14192 msgid ""
14193 "See also: <literal role=\"hook\">precommit</literal> (<xref linkend=\"sec:"
14194 "hook:precommit\"/>), <literal role=\"hook\">pretxncommit</literal> (<xref "
14195 "linkend=\"sec:hook:pretxncommit\"/>)"
14196 msgstr ""
14198 #. type: Content of: <book><chapter><sect1><sect2><title>
14199 #: ../en/ch10-hook.xml:1448
14200 msgid ""
14201 "<literal role=\"hook\">incoming</literal>&emdash;after one remote changeset "
14202 "is added"
14203 msgstr "<literal role=\"hook\">incoming</literal>—增加远程修改集之后"
14205 #. type: Content of: <book><chapter><sect1><sect2><para>
14206 #: ../en/ch10-hook.xml:1451
14207 msgid ""
14208 "This hook is run after a pre-existing changeset has been added to the "
14209 "repository, for example via a <command role=\"hg-cmd\">hg push</command>. If "
14210 "a group of changesets was added in a single operation, this hook is called "
14211 "once for each added changeset."
14212 msgstr ""
14214 #. type: Content of: <book><chapter><sect1><sect2><para>
14215 #: ../en/ch10-hook.xml:1458
14216 msgid ""
14217 "You can use this hook for the same purposes as the <literal role=\"hook"
14218 "\">changegroup</literal> hook (<xref linkend=\"sec:hook:changegroup\"/>); "
14219 "it's simply more convenient sometimes to run a hook once per group of "
14220 "changesets, while other times it's handier once per changeset."
14221 msgstr ""
14223 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14224 #: ../en/ch10-hook.xml:1468
14225 msgid ""
14226 "<literal>node</literal>: A changeset ID. The ID of the newly added changeset."
14227 msgstr ""
14229 #. type: Content of: <book><chapter><sect1><sect2><para>
14230 #: ../en/ch10-hook.xml:1483
14231 msgid ""
14232 "See also: <literal role=\"hook\">changegroup</literal> (<xref linkend=\"sec:"
14233 "hook:changegroup\"/>) <literal role=\"hook\">prechangegroup</literal> (<xref "
14234 "linkend=\"sec:hook:prechangegroup\"/>), <literal role=\"hook"
14235 "\">pretxnchangegroup</literal> (<xref linkend=\"sec:hook:pretxnchangegroup\"/"
14236 ">)"
14237 msgstr ""
14239 #. type: Content of: <book><chapter><sect1><sect2><title>
14240 #: ../en/ch10-hook.xml:1494
14241 msgid ""
14242 "<literal role=\"hook\">outgoing</literal>&emdash;after changesets are "
14243 "propagated"
14244 msgstr "<literal role=\"hook\">outgoing</literal>—传播修改集之后"
14246 #. type: Content of: <book><chapter><sect1><sect2><para>
14247 #: ../en/ch10-hook.xml:1497
14248 msgid ""
14249 "This hook is run after a group of changesets has been propagated out of this "
14250 "repository, for example by a <command role=\"hg-cmd\">hg push</command> or "
14251 "<command role=\"hg-cmd\">hg bundle</command> command."
14252 msgstr ""
14254 #. type: Content of: <book><chapter><sect1><sect2><para>
14255 #: ../en/ch10-hook.xml:1503
14256 msgid ""
14257 "One possible use for this hook is to notify administrators that changes have "
14258 "been pulled."
14259 msgstr ""
14261 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14262 #: ../en/ch10-hook.xml:1510
14263 msgid ""
14264 "<literal>node</literal>: A changeset ID. The changeset ID of the first "
14265 "changeset of the group that was sent."
14266 msgstr ""
14268 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14269 #: ../en/ch10-hook.xml:1515
14270 msgid ""
14271 "<literal>source</literal>: A string. The source of the of the operation (see "
14272 "<xref linkend=\"sec:hook:sources\"/>). If a remote client pulled changes "
14273 "from this repository, <literal>source</literal> will be <literal>serve</"
14274 "literal>. If the client that obtained changes from this repository was "
14275 "local, <literal>source</literal> will be <literal>bundle</literal>, "
14276 "<literal>pull</literal>, or <literal>push</literal>, depending on the "
14277 "operation the client performed."
14278 msgstr ""
14280 #. type: Content of: <book><chapter><sect1><sect2><para>
14281 #: ../en/ch10-hook.xml:1534
14282 msgid ""
14283 "See also: <literal role=\"hook\">preoutgoing</literal> (<xref linkend=\"sec:"
14284 "hook:preoutgoing\"/>)"
14285 msgstr ""
14287 #. type: Content of: <book><chapter><sect1><sect2><title>
14288 #: ../en/ch10-hook.xml:1541
14289 msgid ""
14290 "<literal role=\"hook\">prechangegroup</literal>&emdash;before starting to add "
14291 "remote changesets"
14292 msgstr "<literal role=\"hook\">prechangegroup</literal>—增加远程修改集之前"
14294 #. type: Content of: <book><chapter><sect1><sect2><para>
14295 #: ../en/ch10-hook.xml:1545
14296 msgid ""
14297 "This controlling hook is run before Mercurial begins to add a group of "
14298 "changesets from another repository."
14299 msgstr ""
14301 #. type: Content of: <book><chapter><sect1><sect2><para>
14302 #: ../en/ch10-hook.xml:1549
14303 msgid ""
14304 "This hook does not have any information about the changesets to be added, "
14305 "because it is run before transmission of those changesets is allowed to "
14306 "begin. If this hook fails, the changesets will not be transmitted."
14307 msgstr ""
14309 #. type: Content of: <book><chapter><sect1><sect2><para>
14310 #: ../en/ch10-hook.xml:1555
14311 msgid ""
14312 "One use for this hook is to prevent external changes from being added to a "
14313 "repository. For example, you could use this to <quote>freeze</quote> a "
14314 "server-hosted branch temporarily or permanently so that users cannot push to "
14315 "it, while still allowing a local administrator to modify the repository."
14316 msgstr ""
14318 #. type: Content of: <book><chapter><sect1><sect2><para>
14319 #: ../en/ch10-hook.xml:1576
14320 msgid ""
14321 "See also: <literal role=\"hook\">changegroup</literal> (<xref linkend=\"sec:"
14322 "hook:changegroup\"/>), <literal role=\"hook\">incoming</literal> (<xref "
14323 "linkend=\"sec:hook:incoming\"/>), <literal role=\"hook\">pretxnchangegroup</"
14324 "literal> (<xref linkend=\"sec:hook:pretxnchangegroup\"/>)"
14325 msgstr ""
14327 #. type: Content of: <book><chapter><sect1><sect2><title>
14328 #: ../en/ch10-hook.xml:1587
14329 msgid ""
14330 "<literal role=\"hook\">precommit</literal>&emdash;before starting to commit a "
14331 "changeset"
14332 msgstr "<literal role=\"hook\">precommit</literal>—提交修改集之前"
14334 #. type: Content of: <book><chapter><sect1><sect2><para>
14335 #: ../en/ch10-hook.xml:1590
14336 msgid ""
14337 "This hook is run before Mercurial begins to commit a new changeset. It is run "
14338 "before Mercurial has any of the metadata for the commit, such as the files to "
14339 "be committed, the commit message, or the commit date."
14340 msgstr ""
14342 #. type: Content of: <book><chapter><sect1><sect2><para>
14343 #: ../en/ch10-hook.xml:1596
14344 msgid ""
14345 "One use for this hook is to disable the ability to commit new changesets, "
14346 "while still allowing incoming changesets. Another is to run a build or test, "
14347 "and only allow the commit to begin if the build or test succeeds."
14348 msgstr ""
14350 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14351 #: ../en/ch10-hook.xml:1605
14352 msgid ""
14353 "<literal>parent1</literal>: A changeset ID. The changeset ID of the first "
14354 "parent of the working directory."
14355 msgstr ""
14357 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14358 #: ../en/ch10-hook.xml:1610
14359 msgid ""
14360 "<literal>parent2</literal>: A changeset ID. The changeset ID of the second "
14361 "parent of the working directory."
14362 msgstr ""
14364 #. type: Content of: <book><chapter><sect1><sect2><para>
14365 #: ../en/ch10-hook.xml:1615
14366 msgid ""
14367 "If the commit proceeds, the parents of the working directory will become the "
14368 "parents of the new changeset."
14369 msgstr ""
14371 #. type: Content of: <book><chapter><sect1><sect2><para>
14372 #: ../en/ch10-hook.xml:1619
14373 msgid ""
14374 "See also: <literal role=\"hook\">commit</literal> (<xref linkend=\"sec:hook:"
14375 "commit\"/>), <literal role=\"hook\">pretxncommit</literal> (<xref linkend="
14376 "\"sec:hook:pretxncommit\"/>)"
14377 msgstr ""
14379 #. type: Content of: <book><chapter><sect1><sect2><title>
14380 #: ../en/ch10-hook.xml:1627
14381 msgid ""
14382 "<literal role=\"hook\">preoutgoing</literal>&emdash;before starting to "
14383 "propagate changesets"
14384 msgstr "<literal role=\"hook\">preoutgoing</literal>—传播修改集之前"
14386 #. type: Content of: <book><chapter><sect1><sect2><para>
14387 #: ../en/ch10-hook.xml:1630
14388 msgid ""
14389 "This hook is invoked before Mercurial knows the identities of the changesets "
14390 "to be transmitted."
14391 msgstr ""
14393 #. type: Content of: <book><chapter><sect1><sect2><para>
14394 #: ../en/ch10-hook.xml:1634
14395 msgid ""
14396 "One use for this hook is to prevent changes from being transmitted to another "
14397 "repository."
14398 msgstr ""
14400 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14401 #: ../en/ch10-hook.xml:1641
14402 msgid ""
14403 "<literal>source</literal>: A string. The source of the operation that is "
14404 "attempting to obtain changes from this repository (see <xref linkend=\"sec:"
14405 "hook:sources\"/>). See the documentation for the <literal>source</literal> "
14406 "parameter to the <literal role=\"hook\">outgoing</literal> hook, in <xref "
14407 "linkend=\"sec:hook:outgoing\"/>, for possible values of this parameter."
14408 msgstr ""
14410 #. type: Content of: <book><chapter><sect1><sect2><para>
14411 #: ../en/ch10-hook.xml:1657
14412 msgid ""
14413 "See also: <literal role=\"hook\">outgoing</literal> (<xref linkend=\"sec:hook:"
14414 "outgoing\"/>)"
14415 msgstr ""
14417 #. type: Content of: <book><chapter><sect1><sect2><title>
14418 #: ../en/ch10-hook.xml:1664
14419 msgid ""
14420 "<literal role=\"hook\">pretag</literal>&emdash;before tagging a changeset"
14421 msgstr "<literal role=\"hook\">pretag</literal>—创建标签之前"
14423 #. type: Content of: <book><chapter><sect1><sect2><para>
14424 #: ../en/ch10-hook.xml:1667
14425 msgid ""
14426 "This controlling hook is run before a tag is created. If the hook succeeds, "
14427 "creation of the tag proceeds. If the hook fails, the tag is not created."
14428 msgstr ""
14430 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14431 #: ../en/ch10-hook.xml:1675
14432 msgid ""
14433 "<literal>local</literal>: A boolean. Whether the tag is local to this "
14434 "repository instance (i.e. stored in <filename role=\"special\">.hg/localtags</"
14435 "filename>) or managed by Mercurial (stored in <filename role=\"special\">."
14436 "hgtags</filename>)."
14437 msgstr ""
14439 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14440 #: ../en/ch10-hook.xml:1682
14441 msgid ""
14442 "<literal>node</literal>: A changeset ID. The ID of the changeset to be "
14443 "tagged."
14444 msgstr ""
14446 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14447 #: ../en/ch10-hook.xml:1686
14448 msgid "<literal>tag</literal>: A string. The name of the tag to be created."
14449 msgstr ""
14451 #. type: Content of: <book><chapter><sect1><sect2><para>
14452 #: ../en/ch10-hook.xml:1691
14453 msgid ""
14454 "If the tag to be created is revision-controlled, the <literal role=\"hook"
14455 "\">precommit</literal> and <literal role=\"hook\">pretxncommit</literal> "
14456 "hooks (<xref linkend=\"sec:hook:commit\"/> and <xref linkend=\"sec:hook:"
14457 "pretxncommit\"/>) will also be run."
14458 msgstr ""
14460 #. type: Content of: <book><chapter><sect1><sect2><para>
14461 #: ../en/ch10-hook.xml:1699
14462 msgid ""
14463 "See also: <literal role=\"hook\">tag</literal> (<xref linkend=\"sec:hook:tag"
14464 "\"/>)"
14465 msgstr ""
14467 #. type: Content of: <book><chapter><sect1><sect2><title>
14468 #: ../en/ch10-hook.xml:1705
14469 msgid ""
14470 "<literal role=\"hook\">pretxnchangegroup</literal>&emdash;before completing "
14471 "addition of remote changesets"
14472 msgstr ""
14473 "<literal role=\"hook\">pretxnchangegroup</literal>—完成增加远程修改集之前"
14475 #. type: Content of: <book><chapter><sect1><sect2><para>
14476 #: ../en/ch10-hook.xml:1709
14477 msgid ""
14478 "This controlling hook is run before a transaction&emdash;that manages the "
14479 "addition of a group of new changesets from outside the repository&emdash;"
14480 "completes. If the hook succeeds, the transaction completes, and all of the "
14481 "changesets become permanent within this repository. If the hook fails, the "
14482 "transaction is rolled back, and the data for the changesets is erased."
14483 msgstr ""
14485 #. type: Content of: <book><chapter><sect1><sect2><para>
14486 #: ../en/ch10-hook.xml:1718
14487 msgid ""
14488 "This hook can access the metadata associated with the almost-added "
14489 "changesets, but it should not do anything permanent with this data. It must "
14490 "also not modify the working directory."
14491 msgstr ""
14493 #. type: Content of: <book><chapter><sect1><sect2><para>
14494 #: ../en/ch10-hook.xml:1724
14495 msgid ""
14496 "While this hook is running, if other Mercurial processes access this "
14497 "repository, they will be able to see the almost-added changesets as if they "
14498 "are permanent. This may lead to race conditions if you do not take steps to "
14499 "avoid them."
14500 msgstr ""
14502 #. type: Content of: <book><chapter><sect1><sect2><para>
14503 #: ../en/ch10-hook.xml:1731
14504 msgid ""
14505 "This hook can be used to automatically vet a group of changesets. If the "
14506 "hook fails, all of the changesets are <quote>rejected</quote> when the "
14507 "transaction rolls back."
14508 msgstr ""
14510 #. type: Content of: <book><chapter><sect1><sect2><para>
14511 #: ../en/ch10-hook.xml:1760
14512 msgid ""
14513 "See also: <literal role=\"hook\">changegroup</literal> (<xref linkend=\"sec:"
14514 "hook:changegroup\"/>), <literal role=\"hook\">incoming</literal> (<xref "
14515 "linkend=\"sec:hook:incoming\"/>), <literal role=\"hook\">prechangegroup</"
14516 "literal> (<xref linkend=\"sec:hook:prechangegroup\"/>)"
14517 msgstr ""
14519 #. type: Content of: <book><chapter><sect1><sect2><title>
14520 #: ../en/ch10-hook.xml:1771
14521 msgid ""
14522 "<literal role=\"hook\">pretxncommit</literal>&emdash;before completing commit "
14523 "of new changeset"
14524 msgstr "<literal role=\"hook\">pretxncommit</literal>—完成提交之前"
14526 #. type: Content of: <book><chapter><sect1><sect2><para>
14527 #: ../en/ch10-hook.xml:1774
14528 msgid ""
14529 "This controlling hook is run before a transaction&emdash;that manages a new "
14530 "commit&emdash;completes. If the hook succeeds, the transaction completes and "
14531 "the changeset becomes permanent within this repository. If the hook fails, "
14532 "the transaction is rolled back, and the commit data is erased."
14533 msgstr ""
14535 #. type: Content of: <book><chapter><sect1><sect2><para>
14536 #: ../en/ch10-hook.xml:1782
14537 msgid ""
14538 "This hook can access the metadata associated with the almost-new changeset, "
14539 "but it should not do anything permanent with this data. It must also not "
14540 "modify the working directory."
14541 msgstr ""
14543 #. type: Content of: <book><chapter><sect1><sect2><para>
14544 #: ../en/ch10-hook.xml:1788
14545 msgid ""
14546 "While this hook is running, if other Mercurial processes access this "
14547 "repository, they will be able to see the almost-new changeset as if it is "
14548 "permanent. This may lead to race conditions if you do not take steps to "
14549 "avoid them."
14550 msgstr ""
14552 #. type: Content of: <book><chapter><sect1><sect2><para>
14553 #: ../en/ch10-hook.xml:1812
14554 msgid ""
14555 "See also: <literal role=\"hook\">precommit</literal> (<xref linkend=\"sec:"
14556 "hook:precommit\"/>)"
14557 msgstr ""
14558 "参见: <literal role=\"hook\">precommit</literal> (<xref linkend=\"sec:hook:"
14559 "precommit\"/>)"
14561 #. type: Content of: <book><chapter><sect1><sect2><title>
14562 #: ../en/ch10-hook.xml:1819
14563 msgid ""
14564 "<literal role=\"hook\">preupdate</literal>&emdash;before updating or merging "
14565 "working directory"
14566 msgstr "<literal role=\"hook\">preupdate</literal>—更新或合并工作目录之前"
14568 #. type: Content of: <book><chapter><sect1><sect2><para>
14569 #: ../en/ch10-hook.xml:1822
14570 msgid ""
14571 "This controlling hook is run before an update or merge of the working "
14572 "directory begins. It is run only if Mercurial's normal pre-update checks "
14573 "determine that the update or merge can proceed. If the hook succeeds, the "
14574 "update or merge may proceed; if it fails, the update or merge does not start."
14575 msgstr ""
14577 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14578 #: ../en/ch10-hook.xml:1833
14579 msgid ""
14580 "<literal>parent1</literal>: A changeset ID. The ID of the parent that the "
14581 "working directory is to be updated to. If the working directory is being "
14582 "merged, it will not change this parent."
14583 msgstr ""
14585 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14586 #: ../en/ch10-hook.xml:1839
14587 msgid ""
14588 "<literal>parent2</literal>: A changeset ID. Only set if the working directory "
14589 "is being merged. The ID of the revision that the working directory is being "
14590 "merged with."
14591 msgstr ""
14593 #. type: Content of: <book><chapter><sect1><sect2><para>
14594 #: ../en/ch10-hook.xml:1846
14595 msgid ""
14596 "See also: <literal role=\"hook\">update</literal> (<xref linkend=\"sec:hook:"
14597 "update\"/>)"
14598 msgstr ""
14600 #. type: Content of: <book><chapter><sect1><sect2><title>
14601 #: ../en/ch10-hook.xml:1851
14602 msgid "<literal role=\"hook\">tag</literal>&emdash;after tagging a changeset"
14603 msgstr "<literal role=\"hook\">tag</literal>—创建标签之后"
14605 #. type: Content of: <book><chapter><sect1><sect2><para>
14606 #: ../en/ch10-hook.xml:1854
14607 msgid "This hook is run after a tag has been created."
14608 msgstr ""
14610 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14611 #: ../en/ch10-hook.xml:1860
14612 msgid ""
14613 "<literal>local</literal>: A boolean. Whether the new tag is local to this "
14614 "repository instance (i.e. stored in <filename role=\"special\">.hg/"
14615 "localtags</filename>) or managed by Mercurial (stored in <filename role="
14616 "\"special\">.hgtags</filename>)."
14617 msgstr ""
14619 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14620 #: ../en/ch10-hook.xml:1868
14621 msgid ""
14622 "<literal>node</literal>: A changeset ID. The ID of the changeset that was "
14623 "tagged."
14624 msgstr ""
14626 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14627 #: ../en/ch10-hook.xml:1872
14628 msgid "<literal>tag</literal>: A string. The name of the tag that was created."
14629 msgstr ""
14631 #. type: Content of: <book><chapter><sect1><sect2><para>
14632 #: ../en/ch10-hook.xml:1877
14633 msgid ""
14634 "If the created tag is revision-controlled, the <literal role=\"hook\">commit</"
14635 "literal> hook (section <xref linkend=\"sec:hook:commit\"/>) is run before "
14636 "this hook."
14637 msgstr ""
14639 #. type: Content of: <book><chapter><sect1><sect2><para>
14640 #: ../en/ch10-hook.xml:1882
14641 msgid ""
14642 "See also: <literal role=\"hook\">pretag</literal> (<xref linkend=\"sec:hook:"
14643 "pretag\"/>)"
14644 msgstr ""
14645 "参见: <literal role=\"hook\">pretag</literal> (<xref linkend=\"sec:hook:pretag"
14646 "\"/>)"
14648 #. type: Content of: <book><chapter><sect1><sect2><title>
14649 #: ../en/ch10-hook.xml:1888
14650 msgid ""
14651 "<literal role=\"hook\">update</literal>&emdash;after updating or merging "
14652 "working directory"
14653 msgstr "<literal role=\"hook\">update</literal>—更新或合并工作目录之后"
14655 #. type: Content of: <book><chapter><sect1><sect2><para>
14656 #: ../en/ch10-hook.xml:1891
14657 msgid ""
14658 "This hook is run after an update or merge of the working directory "
14659 "completes. Since a merge can fail (if the external <command>hgmerge</"
14660 "command> command fails to resolve conflicts in a file), this hook "
14661 "communicates whether the update or merge completed cleanly."
14662 msgstr ""
14664 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14665 #: ../en/ch10-hook.xml:1899
14666 msgid ""
14667 "<literal>error</literal>: A boolean. Indicates whether the update or merge "
14668 "completed successfully."
14669 msgstr ""
14671 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14672 #: ../en/ch10-hook.xml:1904
14673 msgid ""
14674 "<literal>parent1</literal>: A changeset ID. The ID of the parent that the "
14675 "working directory was updated to. If the working directory was merged, it "
14676 "will not have changed this parent."
14677 msgstr ""
14679 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14680 #: ../en/ch10-hook.xml:1910
14681 msgid ""
14682 "<literal>parent2</literal>: A changeset ID. Only set if the working "
14683 "directory was merged. The ID of the revision that the working directory was "
14684 "merged with."
14685 msgstr ""
14687 #. type: Content of: <book><chapter><sect1><sect2><para>
14688 #: ../en/ch10-hook.xml:1916
14689 msgid ""
14690 "See also: <literal role=\"hook\">preupdate</literal> (<xref linkend=\"sec:"
14691 "hook:preupdate\"/>)"
14692 msgstr ""
14694 #. type: Content of: <book><chapter><title>
14695 #: ../en/ch11-template.xml:5
14696 msgid "Customizing the output of Mercurial"
14697 msgstr "定制 Mercurial 的输出"
14699 #. type: Content of: <book><chapter><para>
14700 #: ../en/ch11-template.xml:7
14701 msgid ""
14702 "Mercurial provides a powerful mechanism to let you control how it displays "
14703 "information. The mechanism is based on templates. You can use templates to "
14704 "generate specific output for a single command, or to customize the entire "
14705 "appearance of the built-in web interface."
14706 msgstr ""
14708 #. type: Content of: <book><chapter><sect1><title>
14709 #: ../en/ch11-template.xml:14
14710 msgid "Using precanned output styles"
14711 msgstr "使用预定义的输出样式"
14713 #. type: Content of: <book><chapter><sect1><para>
14714 #: ../en/ch11-template.xml:16
14715 msgid ""
14716 "Packaged with Mercurial are some output styles that you can use immediately. "
14717 "A style is simply a precanned template that someone wrote and installed "
14718 "somewhere that Mercurial can find."
14719 msgstr ""
14721 #. type: Content of: <book><chapter><sect1><para>
14722 #: ../en/ch11-template.xml:21
14723 msgid ""
14724 "Before we take a look at Mercurial's bundled styles, let's review its normal "
14725 "output."
14726 msgstr ""
14728 #. type: Content of: <book><chapter><sect1><para>
14729 #: ../en/ch11-template.xml:26
14730 msgid ""
14731 "This is somewhat informative, but it takes up a lot of space&emdash;five "
14732 "lines of output per changeset. The <literal>compact</literal> style reduces "
14733 "this to three lines, presented in a sparse manner."
14734 msgstr ""
14736 #. type: Content of: <book><chapter><sect1><para>
14737 #: ../en/ch11-template.xml:33
14738 msgid ""
14739 "The <literal>changelog</literal> style hints at the expressive power of "
14740 "Mercurial's templating engine. This style attempts to follow the GNU "
14741 "Project's changelog guidelines<citation>web:changelog</citation>."
14742 msgstr ""
14744 #. type: Content of: <book><chapter><sect1><para>
14745 #: ../en/ch11-template.xml:40
14746 msgid ""
14747 "You will not be shocked to learn that Mercurial's default output style is "
14748 "named <literal>default</literal>."
14749 msgstr ""
14751 #. type: Content of: <book><chapter><sect1><sect2><title>
14752 #: ../en/ch11-template.xml:44
14753 msgid "Setting a default style"
14754 msgstr "设置默认样式"
14756 #. type: Content of: <book><chapter><sect1><sect2><para>
14757 #: ../en/ch11-template.xml:46
14758 msgid ""
14759 "You can modify the output style that Mercurial will use for every command by "
14760 "editing your <filename role=\"special\">~/.hgrc</filename> file, naming the "
14761 "style you would prefer to use."
14762 msgstr ""
14764 #. type: Content of: <book><chapter><sect1><sect2><para>
14765 #: ../en/ch11-template.xml:54
14766 msgid ""
14767 "If you write a style of your own, you can use it by either providing the path "
14768 "to your style file, or copying your style file into a location where "
14769 "Mercurial can find it (typically the <literal>templates</literal> "
14770 "subdirectory of your Mercurial install directory)."
14771 msgstr ""
14773 #. type: Content of: <book><chapter><sect1><title>
14774 #: ../en/ch11-template.xml:63
14775 msgid "Commands that support styles and templates"
14776 msgstr "支持样式和模版的命令"
14778 #. type: Content of: <book><chapter><sect1><para>
14779 #: ../en/ch11-template.xml:65
14780 msgid ""
14781 "All of Mercurial's <quote><literal>log</literal>-like</quote> commands let "
14782 "you use styles and templates: <command role=\"hg-cmd\">hg incoming</command>, "
14783 "<command role=\"hg-cmd\">hg log</command>, <command role=\"hg-cmd\">hg "
14784 "outgoing</command>, and <command role=\"hg-cmd\">hg tip</command>."
14785 msgstr ""
14787 #. type: Content of: <book><chapter><sect1><para>
14788 #: ../en/ch11-template.xml:72
14789 msgid ""
14790 "As I write this manual, these are so far the only commands that support "
14791 "styles and templates. Since these are the most important commands that need "
14792 "customizable output, there has been little pressure from the Mercurial user "
14793 "community to add style and template support to other commands."
14794 msgstr ""
14796 #. type: Content of: <book><chapter><sect1><title>
14797 #: ../en/ch11-template.xml:80
14798 msgid "The basics of templating"
14799 msgstr "模版基础"
14801 #. type: Content of: <book><chapter><sect1><para>
14802 #: ../en/ch11-template.xml:82
14803 msgid ""
14804 "At its simplest, a Mercurial template is a piece of text. Some of the text "
14805 "never changes, while other parts are <emphasis>expanded</emphasis>, or "
14806 "replaced with new text, when necessary."
14807 msgstr ""
14809 #. type: Content of: <book><chapter><sect1><para>
14810 #: ../en/ch11-template.xml:87
14811 msgid ""
14812 "Before we continue, let's look again at a simple example of Mercurial's "
14813 "normal output."
14814 msgstr ""
14816 #. type: Content of: <book><chapter><sect1><para>
14817 #: ../en/ch11-template.xml:92
14818 msgid ""
14819 "Now, let's run the same command, but using a template to change its output."
14820 msgstr ""
14822 #. type: Content of: <book><chapter><sect1><para>
14823 #: ../en/ch11-template.xml:97
14824 msgid ""
14825 "The example above illustrates the simplest possible template; it's just a "
14826 "piece of static text, printed once for each changeset. The <option role=\"hg-"
14827 "opt-log\">--template</option> option to the <command role=\"hg-cmd\">hg log</"
14828 "command> command tells Mercurial to use the given text as the template when "
14829 "printing each changeset."
14830 msgstr ""
14832 #. type: Content of: <book><chapter><sect1><para>
14833 #: ../en/ch11-template.xml:105
14834 msgid ""
14835 "Notice that the template string above ends with the text <quote><literal>\\n</"
14836 "literal></quote>. This is an <emphasis>escape sequence</emphasis>, telling "
14837 "Mercurial to print a newline at the end of each template item. If you omit "
14838 "this newline, Mercurial will run each piece of output together. See <xref "
14839 "linkend=\"sec:template:escape\"/> for more details of escape sequences."
14840 msgstr ""
14842 #. type: Content of: <book><chapter><sect1><para>
14843 #: ../en/ch11-template.xml:113
14844 msgid ""
14845 "A template that prints a fixed string of text all the time isn't very useful; "
14846 "let's try something a bit more complex."
14847 msgstr ""
14849 #. type: Content of: <book><chapter><sect1><para>
14850 #: ../en/ch11-template.xml:119
14851 msgid ""
14852 "As you can see, the string <quote><literal>{desc}</literal></quote> in the "
14853 "template has been replaced in the output with the description of each "
14854 "changeset. Every time Mercurial finds text enclosed in curly braces "
14855 "(<quote><literal>{</literal></quote> and <quote><literal>}</literal></"
14856 "quote>), it will try to replace the braces and text with the expansion of "
14857 "whatever is inside. To print a literal curly brace, you must escape it, as "
14858 "described in <xref linkend=\"sec:template:escape\"/>."
14859 msgstr ""
14861 #. type: Content of: <book><chapter><sect1><title>
14862 #: ../en/ch11-template.xml:131
14863 msgid "Common template keywords"
14864 msgstr "模版关键字"
14866 #. type: Content of: <book><chapter><sect1><para>
14867 #: ../en/ch11-template.xml:133
14868 msgid ""
14869 "You can start writing simple templates immediately using the keywords below."
14870 msgstr ""
14872 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14873 #: ../en/ch11-template.xml:137
14874 msgid ""
14875 "<literal role=\"template-keyword\">author</literal>: String. The unmodified "
14876 "author of the changeset."
14877 msgstr ""
14879 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14880 #: ../en/ch11-template.xml:141
14881 msgid ""
14882 "<literal role=\"template-keyword\">branches</literal>: String. The name of "
14883 "the branch on which the changeset was committed. Will be empty if the branch "
14884 "name was <literal>default</literal>."
14885 msgstr ""
14887 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14888 #: ../en/ch11-template.xml:147
14889 msgid ""
14890 "<literal role=\"template-keyword\">date</literal>: Date information. The "
14891 "date when the changeset was committed. This is <emphasis>not</emphasis> "
14892 "human-readable; you must pass it through a filter that will render it "
14893 "appropriately. See <xref linkend=\"sec:template:filter\"/> for more "
14894 "information on filters. The date is expressed as a pair of numbers. The "
14895 "first number is a Unix UTC timestamp (seconds since January 1, 1970); the "
14896 "second is the offset of the committer's timezone from UTC, in seconds."
14897 msgstr ""
14899 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14900 #: ../en/ch11-template.xml:158
14901 msgid ""
14902 "<literal role=\"template-keyword\">desc</literal>: String. The text of the "
14903 "changeset description."
14904 msgstr ""
14906 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14907 #: ../en/ch11-template.xml:161
14908 msgid ""
14909 "<literal role=\"template-keyword\">files</literal>: List of strings. All "
14910 "files modified, added, or removed by this changeset."
14911 msgstr ""
14913 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14914 #: ../en/ch11-template.xml:166
14915 msgid ""
14916 "<literal role=\"template-keyword\">file_adds</literal>: List of strings. "
14917 "Files added by this changeset."
14918 msgstr ""
14920 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14921 #: ../en/ch11-template.xml:170
14922 msgid ""
14923 "<literal role=\"template-keyword\">file_dels</literal>: List of strings. "
14924 "Files removed by this changeset."
14925 msgstr ""
14927 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14928 #: ../en/ch11-template.xml:174
14929 msgid ""
14930 "<literal role=\"template-keyword\">node</literal>: String. The changeset "
14931 "identification hash, as a 40-character hexadecimal string."
14932 msgstr ""
14934 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14935 #: ../en/ch11-template.xml:178
14936 msgid ""
14937 "<literal role=\"template-keyword\">parents</literal>: List of strings. The "
14938 "parents of the changeset."
14939 msgstr ""
14941 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14942 #: ../en/ch11-template.xml:182
14943 msgid ""
14944 "<literal role=\"template-keyword\">rev</literal>: Integer. The repository-"
14945 "local changeset revision number."
14946 msgstr ""
14948 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14949 #: ../en/ch11-template.xml:186
14950 msgid ""
14951 "<literal role=\"template-keyword\">tags</literal>: List of strings. Any tags "
14952 "associated with the changeset."
14953 msgstr ""
14955 #. type: Content of: <book><chapter><sect1><para>
14956 #: ../en/ch11-template.xml:192
14957 msgid ""
14958 "A few simple experiments will show us what to expect when we use these "
14959 "keywords; you can see the results below."
14960 msgstr ""
14962 #. type: Content of: <book><chapter><sect1><para>
14963 #: ../en/ch11-template.xml:197
14964 msgid ""
14965 "As we noted above, the date keyword does not produce human-readable output, "
14966 "so we must treat it specially. This involves using a <emphasis>filter</"
14967 "emphasis>, about which more in <xref linkend=\"sec:template:filter\"/>."
14968 msgstr ""
14970 #. type: Content of: <book><chapter><sect1><title>
14971 #: ../en/ch11-template.xml:206
14972 msgid "Escape sequences"
14973 msgstr "转义序列"
14975 #. type: Content of: <book><chapter><sect1><para>
14976 #: ../en/ch11-template.xml:208
14977 msgid ""
14978 "Mercurial's templating engine recognises the most commonly used escape "
14979 "sequences in strings. When it sees a backslash (<quote><literal>\\</"
14980 "literal></quote>) character, it looks at the following character and "
14981 "substitutes the two characters with a single replacement, as described below."
14982 msgstr ""
14984 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14985 #: ../en/ch11-template.xml:215
14986 msgid ""
14987 "<literal>\\</literal>: Backslash, <quote><literal>\\</literal></quote>, ASCII "
14988 "134."
14989 msgstr ""
14991 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14992 #: ../en/ch11-template.xml:219
14993 msgid "<literal>\\n</literal>: Newline, ASCII 12."
14994 msgstr ""
14996 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14997 #: ../en/ch11-template.xml:222
14998 msgid "<literal>\\r</literal>: Carriage return, ASCII 15."
14999 msgstr ""
15001 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15002 #: ../en/ch11-template.xml:225
15003 msgid "<literal>\\t</literal>: Tab, ASCII 11."
15004 msgstr ""
15006 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15007 #: ../en/ch11-template.xml:228
15008 msgid "<literal>\\v</literal>: Vertical tab, ASCII 13."
15009 msgstr ""
15011 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15012 #: ../en/ch11-template.xml:231
15013 msgid ""
15014 "<literal>\\{</literal>: Open curly brace, <quote><literal>{</literal></"
15015 "quote>, ASCII 173."
15016 msgstr ""
15018 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15019 #: ../en/ch11-template.xml:235
15020 msgid ""
15021 "<literal>\\}</literal>: Close curly brace, <quote><literal>}</literal></"
15022 "quote>, ASCII 175."
15023 msgstr ""
15025 #. type: Content of: <book><chapter><sect1><para>
15026 #: ../en/ch11-template.xml:240
15027 msgid ""
15028 "As indicated above, if you want the expansion of a template to contain a "
15029 "literal <quote><literal>\\</literal></quote>, <quote><literal>{</literal></"
15030 "quote>, or <quote><literal>{</literal></quote> character, you must escape it."
15031 msgstr ""
15033 #. type: Content of: <book><chapter><sect1><title>
15034 #: ../en/ch11-template.xml:248
15035 msgid "Filtering keywords to change their results"
15036 msgstr "通过过滤关键字来修改输出结果"
15038 #. type: Content of: <book><chapter><sect1><para>
15039 #: ../en/ch11-template.xml:250
15040 msgid ""
15041 "Some of the results of template expansion are not immediately easy to use. "
15042 "Mercurial lets you specify an optional chain of <emphasis>filters</emphasis> "
15043 "to modify the result of expanding a keyword. You have already seen a common "
15044 "filter, <literal role=\"template-kw-filt-date\">isodate</literal>, in action "
15045 "above, to make a date readable."
15046 msgstr ""
15048 #. type: Content of: <book><chapter><sect1><para>
15049 #: ../en/ch11-template.xml:257
15050 msgid ""
15051 "Below is a list of the most commonly used filters that Mercurial supports. "
15052 "While some filters can be applied to any text, others can only be used in "
15053 "specific circumstances. The name of each filter is followed first by an "
15054 "indication of where it can be used, then a description of its effect."
15055 msgstr ""
15057 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15058 #: ../en/ch11-template.xml:264
15059 msgid ""
15060 "<literal role=\"template-filter\">addbreaks</literal>: Any text. Add an XHTML "
15061 "<quote><literal>&lt;br/&gt;</literal></quote> tag before the end of every "
15062 "line except the last. For example, <quote><literal>foo\\nbar</literal></"
15063 "quote> becomes <quote><literal>foo&lt;br/&gt;\\nbar</literal></quote>."
15064 msgstr ""
15066 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15067 #: ../en/ch11-template.xml:271
15068 msgid ""
15069 "<literal role=\"template-kw-filt-date\">age</literal>: <literal role="
15070 "\"template-keyword\">date</literal> keyword. Render the age of the date, "
15071 "relative to the current time. Yields a string like <quote><literal>10 "
15072 "minutes</literal></quote>."
15073 msgstr ""
15075 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15076 #: ../en/ch11-template.xml:278
15077 msgid ""
15078 "<literal role=\"template-filter\">basename</literal>: Any text, but most "
15079 "useful for the <literal role=\"template-keyword\">files</literal> keyword and "
15080 "its relatives. Treat the text as a path, and return the basename. For "
15081 "example, <quote><literal>foo/bar/baz</literal></quote> becomes "
15082 "<quote><literal>baz</literal></quote>."
15083 msgstr ""
15085 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15086 #: ../en/ch11-template.xml:287
15087 msgid ""
15088 "<literal role=\"template-kw-filt-date\">date</literal>: <literal role="
15089 "\"template-keyword\">date</literal> keyword. Render a date in a similar "
15090 "format to the Unix <literal role=\"template-keyword\">date</literal> command, "
15091 "but with timezone included. Yields a string like <quote><literal>Mon Sep 04 "
15092 "15:13:13 2006 -0700</literal></quote>."
15093 msgstr ""
15095 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15096 #: ../en/ch11-template.xml:295
15097 msgid ""
15098 "<literal role=\"template-kw-filt-author\">domain</literal>: Any text, but "
15099 "most useful for the <literal role=\"template-keyword\">author</literal> "
15100 "keyword. Finds the first string that looks like an email address, and "
15101 "extract just the domain component. For example, <quote><literal>Bryan "
15102 "O'Sullivan &lt;bos@serpentine.com&gt;</literal></quote> becomes "
15103 "<quote><literal>serpentine.com</literal></quote>."
15104 msgstr ""
15106 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15107 #: ../en/ch11-template.xml:305
15108 msgid ""
15109 "<literal role=\"template-kw-filt-author\">email</literal>: Any text, but most "
15110 "useful for the <literal role=\"template-keyword\">author</literal> keyword. "
15111 "Extract the first string that looks like an email address. For example, "
15112 "<quote><literal>Bryan O'Sullivan &lt;bos@serpentine.com&gt;</literal></quote> "
15113 "becomes <quote><literal>bos@serpentine.com</literal></quote>."
15114 msgstr ""
15116 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15117 #: ../en/ch11-template.xml:314
15118 msgid ""
15119 "<literal role=\"template-filter\">escape</literal>: Any text. Replace the "
15120 "special XML/XHTML characters <quote><literal>&amp;</literal></quote>, "
15121 "<quote><literal>&lt;</literal></quote> and <quote><literal>&gt;</literal></"
15122 "quote> with XML entities."
15123 msgstr ""
15125 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15126 #: ../en/ch11-template.xml:322
15127 msgid ""
15128 "<literal role=\"template-filter\">fill68</literal>: Any text. Wrap the text "
15129 "to fit in 68 columns. This is useful before you pass text through the "
15130 "<literal role=\"template-filter\">tabindent</literal> filter, and still want "
15131 "it to fit in an 80-column fixed-font window."
15132 msgstr ""
15134 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15135 #: ../en/ch11-template.xml:330
15136 msgid ""
15137 "<literal role=\"template-filter\">fill76</literal>: Any text. Wrap the text "
15138 "to fit in 76 columns."
15139 msgstr ""
15141 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15142 #: ../en/ch11-template.xml:334
15143 msgid ""
15144 "<literal role=\"template-filter\">firstline</literal>: Any text. Yield the "
15145 "first line of text, without any trailing newlines."
15146 msgstr ""
15148 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15149 #: ../en/ch11-template.xml:339
15150 msgid ""
15151 "<literal role=\"template-kw-filt-date\">hgdate</literal>: <literal role="
15152 "\"template-keyword\">date</literal> keyword. Render the date as a pair of "
15153 "readable numbers. Yields a string like <quote><literal>1157407993 25200</"
15154 "literal></quote>."
15155 msgstr ""
15157 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15158 #: ../en/ch11-template.xml:346
15159 msgid ""
15160 "<literal role=\"template-kw-filt-date\">isodate</literal>: <literal role="
15161 "\"template-keyword\">date</literal> keyword. Render the date as a text "
15162 "string in ISO 8601 format. Yields a string like <quote><literal>2006-09-04 "
15163 "15:13:13 -0700</literal></quote>."
15164 msgstr ""
15166 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15167 #: ../en/ch11-template.xml:353
15168 msgid ""
15169 "<literal role=\"template-filter\">obfuscate</literal>: Any text, but most "
15170 "useful for the <literal role=\"template-keyword\">author</literal> keyword. "
15171 "Yield the input text rendered as a sequence of XML entities. This helps to "
15172 "defeat some particularly stupid screen-scraping email harvesting spambots."
15173 msgstr ""
15175 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15176 #: ../en/ch11-template.xml:361
15177 msgid ""
15178 "<literal role=\"template-kw-filt-author\">person</literal>: Any text, but "
15179 "most useful for the <literal role=\"template-keyword\">author</literal> "
15180 "keyword. Yield the text before an email address. For example, "
15181 "<quote><literal>Bryan O'Sullivan &lt;bos@serpentine.com&gt;</literal></quote> "
15182 "becomes <quote><literal>Bryan O'Sullivan</literal></quote>."
15183 msgstr ""
15185 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15186 #: ../en/ch11-template.xml:370
15187 msgid ""
15188 "<literal role=\"template-kw-filt-date\">rfc822date</literal>: <literal role="
15189 "\"template-keyword\">date</literal> keyword. Render a date using the same "
15190 "format used in email headers. Yields a string like <quote><literal>Mon, 04 "
15191 "Sep 2006 15:13:13 -0700</literal></quote>."
15192 msgstr ""
15194 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15195 #: ../en/ch11-template.xml:377
15196 msgid ""
15197 "<literal role=\"template-kw-filt-node\">short</literal>: Changeset hash. "
15198 "Yield the short form of a changeset hash, i.e. a 12-character hexadecimal "
15199 "string."
15200 msgstr ""
15202 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15203 #: ../en/ch11-template.xml:382
15204 msgid ""
15205 "<literal role=\"template-kw-filt-date\">shortdate</literal>: <literal role="
15206 "\"template-keyword\">date</literal> keyword. Render the year, month, and day "
15207 "of the date. Yields a string like <quote><literal>2006-09-04</literal></"
15208 "quote>."
15209 msgstr ""
15211 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15212 #: ../en/ch11-template.xml:388
15213 msgid ""
15214 "<literal role=\"template-filter\">strip</literal>: Any text. Strip all "
15215 "leading and trailing whitespace from the string."
15216 msgstr ""
15218 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15219 #: ../en/ch11-template.xml:392
15220 msgid ""
15221 "<literal role=\"template-filter\">tabindent</literal>: Any text. Yield the "
15222 "text, with every line except the first starting with a tab character."
15223 msgstr ""
15225 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15226 #: ../en/ch11-template.xml:397
15227 msgid ""
15228 "<literal role=\"template-filter\">urlescape</literal>: Any text. Escape all "
15229 "characters that are considered <quote>special</quote> by URL parsers. For "
15230 "example, <literal>foo bar</literal> becomes <literal>foo%20bar</literal>."
15231 msgstr ""
15233 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15234 #: ../en/ch11-template.xml:404
15235 msgid ""
15236 "<literal role=\"template-kw-filt-author\">user</literal>: Any text, but most "
15237 "useful for the <literal role=\"template-keyword\">author</literal> keyword. "
15238 "Return the <quote>user</quote> portion of an email address. For example, "
15239 "<quote><literal>Bryan O'Sullivan &lt;bos@serpentine.com&gt;</literal></quote> "
15240 "becomes <quote><literal>bos</literal></quote>."
15241 msgstr ""
15243 #. type: Content of: <book><chapter><sect1><note><para>
15244 #: ../en/ch11-template.xml:418
15245 msgid ""
15246 "If you try to apply a filter to a piece of data that it cannot process, "
15247 "Mercurial will fail and print a Python exception. For example, trying to run "
15248 "the output of the <literal role=\"template-keyword\">desc</literal> keyword "
15249 "into the <literal role=\"template-kw-filt-date\">isodate</literal> filter is "
15250 "not a good idea."
15251 msgstr ""
15253 #. type: Content of: <book><chapter><sect1><sect2><title>
15254 #: ../en/ch11-template.xml:427
15255 msgid "Combining filters"
15256 msgstr "组合过滤器"
15258 #. type: Content of: <book><chapter><sect1><sect2><para>
15259 #: ../en/ch11-template.xml:429
15260 msgid ""
15261 "It is easy to combine filters to yield output in the form you would like. "
15262 "The following chain of filters tidies up a description, then makes sure that "
15263 "it fits cleanly into 68 columns, then indents it by a further 8 characters "
15264 "(at least on Unix-like systems, where a tab is conventionally 8 characters "
15265 "wide)."
15266 msgstr ""
15268 #. type: Content of: <book><chapter><sect1><sect2><para>
15269 #: ../en/ch11-template.xml:438
15270 msgid ""
15271 "Note the use of <quote><literal>\\t</literal></quote> (a tab character) in "
15272 "the template to force the first line to be indented; this is necessary since "
15273 "<literal role=\"template-keyword\">tabindent</literal> indents all lines "
15274 "<emphasis>except</emphasis> the first."
15275 msgstr ""
15277 #. type: Content of: <book><chapter><sect1><sect2><para>
15278 #: ../en/ch11-template.xml:444
15279 msgid ""
15280 "Keep in mind that the order of filters in a chain is significant. The first "
15281 "filter is applied to the result of the keyword; the second to the result of "
15282 "the first filter; and so on. For example, using <literal>fill68|tabindent</"
15283 "literal> gives very different results from <literal>tabindent|fill68</"
15284 "literal>."
15285 msgstr ""
15287 #. type: Content of: <book><chapter><sect1><title>
15288 #: ../en/ch11-template.xml:454
15289 msgid "From templates to styles"
15290 msgstr "从模版到样式"
15292 #. type: Content of: <book><chapter><sect1><para>
15293 #: ../en/ch11-template.xml:456
15294 msgid ""
15295 "A command line template provides a quick and simple way to format some "
15296 "output. Templates can become verbose, though, and it's useful to be able to "
15297 "give a template a name. A style file is a template with a name, stored in a "
15298 "file."
15299 msgstr ""
15301 #. type: Content of: <book><chapter><sect1><para>
15302 #: ../en/ch11-template.xml:461
15303 msgid ""
15304 "More than that, using a style file unlocks the power of Mercurial's "
15305 "templating engine in ways that are not possible using the command line "
15306 "<option role=\"hg-opt-log\">--template</option> option."
15307 msgstr ""
15309 #. type: Content of: <book><chapter><sect1><sect2><title>
15310 #: ../en/ch11-template.xml:467
15311 msgid "The simplest of style files"
15312 msgstr "最简单的样式文件"
15314 #. type: Content of: <book><chapter><sect1><sect2><para>
15315 #: ../en/ch11-template.xml:469
15316 msgid "Our simple style file contains just one line:"
15317 msgstr ""
15319 #. type: Content of: <book><chapter><sect1><sect2><para>
15320 #: ../en/ch11-template.xml:473
15321 msgid ""
15322 "This tells Mercurial, <quote>if you're printing a changeset, use the text on "
15323 "the right as the template</quote>."
15324 msgstr ""
15326 #. type: Content of: <book><chapter><sect1><sect2><title>
15327 #: ../en/ch11-template.xml:479
15328 msgid "Style file syntax"
15329 msgstr "样式文件语法"
15331 #. type: Content of: <book><chapter><sect1><sect2><para>
15332 #: ../en/ch11-template.xml:481
15333 msgid "The syntax rules for a style file are simple."
15334 msgstr ""
15336 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15337 #: ../en/ch11-template.xml:484
15338 msgid "The file is processed one line at a time."
15339 msgstr ""
15341 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15342 #: ../en/ch11-template.xml:487
15343 msgid "Leading and trailing white space are ignored."
15344 msgstr ""
15346 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15347 #: ../en/ch11-template.xml:490
15348 msgid "Empty lines are skipped."
15349 msgstr ""
15351 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15352 #: ../en/ch11-template.xml:492
15353 msgid ""
15354 "If a line starts with either of the characters <quote><literal>#</literal></"
15355 "quote> or <quote><literal>;</literal></quote>, the entire line is treated as "
15356 "a comment, and skipped as if empty."
15357 msgstr ""
15359 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15360 #: ../en/ch11-template.xml:497
15361 msgid ""
15362 "A line starts with a keyword. This must start with an alphabetic character "
15363 "or underscore, and can subsequently contain any alphanumeric character or "
15364 "underscore. (In regexp notation, a keyword must match <literal>[A-Za-z_][A-"
15365 "Za-z0-9_]*</literal>.)"
15366 msgstr ""
15368 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15369 #: ../en/ch11-template.xml:503
15370 msgid ""
15371 "The next element must be an <quote><literal>=</literal></quote> character, "
15372 "which can be preceded or followed by an arbitrary amount of white space."
15373 msgstr ""
15375 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15376 #: ../en/ch11-template.xml:508
15377 msgid ""
15378 "If the rest of the line starts and ends with matching quote characters "
15379 "(either single or double quote), it is treated as a template body."
15380 msgstr ""
15382 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15383 #: ../en/ch11-template.xml:512
15384 msgid ""
15385 "If the rest of the line <emphasis>does not</emphasis> start with a quote "
15386 "character, it is treated as the name of a file; the contents of this file "
15387 "will be read and used as a template body."
15388 msgstr ""
15390 #. type: Content of: <book><chapter><sect1><title>
15391 #: ../en/ch11-template.xml:521
15392 msgid "Style files by example"
15393 msgstr "样式文件例子"
15395 #. type: Content of: <book><chapter><sect1><para>
15396 #: ../en/ch11-template.xml:523
15397 msgid ""
15398 "To illustrate how to write a style file, we will construct a few by example. "
15399 "Rather than provide a complete style file and walk through it, we'll mirror "
15400 "the usual process of developing a style file by starting with something very "
15401 "simple, and walking through a series of successively more complete examples."
15402 msgstr ""
15404 #. type: Content of: <book><chapter><sect1><sect2><title>
15405 #: ../en/ch11-template.xml:530
15406 msgid "Identifying mistakes in style files"
15407 msgstr "在样式文件中定位错误"
15409 #. type: Content of: <book><chapter><sect1><sect2><para>
15410 #: ../en/ch11-template.xml:532
15411 msgid ""
15412 "If Mercurial encounters a problem in a style file you are working on, it "
15413 "prints a terse error message that, once you figure out what it means, is "
15414 "actually quite useful."
15415 msgstr ""
15417 #. type: Content of: <book><chapter><sect1><sect2><para>
15418 #: ../en/ch11-template.xml:538
15419 msgid ""
15420 "Notice that <filename>broken.style</filename> attempts to define a "
15421 "<literal>changeset</literal> keyword, but forgets to give any content for it. "
15422 "When instructed to use this style file, Mercurial promptly complains."
15423 msgstr ""
15425 #. type: Content of: <book><chapter><sect1><sect2><para>
15426 #: ../en/ch11-template.xml:545
15427 msgid "This error message looks intimidating, but it is not too hard to follow."
15428 msgstr ""
15430 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15431 #: ../en/ch11-template.xml:549
15432 msgid ""
15433 "The first component is simply Mercurial's way of saying <quote>I am giving "
15434 "up</quote>."
15435 msgstr ""
15437 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15438 #: ../en/ch11-template.xml:553
15439 msgid "Next comes the name of the style file that contains the error."
15440 msgstr ""
15442 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15443 #: ../en/ch11-template.xml:557
15444 msgid ""
15445 "Following the file name is the line number where the error was encountered."
15446 msgstr ""
15448 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15449 #: ../en/ch11-template.xml:561
15450 msgid "Finally, a description of what went wrong."
15451 msgstr ""
15453 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15454 #: ../en/ch11-template.xml:565
15455 msgid ""
15456 "The description of the problem is not always clear (as in this case), but "
15457 "even when it is cryptic, it is almost always trivial to visually inspect the "
15458 "offending line in the style file and see what is wrong."
15459 msgstr ""
15461 #. type: Content of: <book><chapter><sect1><sect2><title>
15462 #: ../en/ch11-template.xml:574
15463 msgid "Uniquely identifying a repository"
15464 msgstr "版本库的唯一标识"
15466 #. type: Content of: <book><chapter><sect1><sect2><para>
15467 #: ../en/ch11-template.xml:576
15468 msgid ""
15469 "If you would like to be able to identify a Mercurial repository <quote>fairly "
15470 "uniquely</quote> using a short string as an identifier, you can use the first "
15471 "revision in the repository."
15472 msgstr ""
15474 #. type: Content of: <book><chapter><sect1><sect2><para>
15475 #: ../en/ch11-template.xml:583
15476 msgid ""
15477 "This is likely to be unique, and so it is useful in many cases. There are a "
15478 "few caveats."
15479 msgstr ""
15481 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15482 #: ../en/ch11-template.xml:586
15483 msgid ""
15484 "It will not work in a completely empty repository, because such a repository "
15485 "does not have a revision zero."
15486 msgstr ""
15488 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15489 #: ../en/ch11-template.xml:590
15490 msgid ""
15491 "Neither will it work in the (extremely rare) case where a repository is a "
15492 "merge of two or more formerly independent repositories, and you still have "
15493 "those repositories around."
15494 msgstr ""
15496 #. type: Content of: <book><chapter><sect1><sect2><para>
15497 #: ../en/ch11-template.xml:595
15498 msgid "Here are some uses to which you could put this identifier:"
15499 msgstr ""
15501 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15502 #: ../en/ch11-template.xml:598
15503 msgid ""
15504 "As a key into a table for a database that manages repositories on a server."
15505 msgstr ""
15507 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15508 #: ../en/ch11-template.xml:601
15509 msgid ""
15510 "As half of a {<emphasis>repository ID</emphasis>, <emphasis>revision ID</"
15511 "emphasis>} tuple. Save this information away when you run an automated build "
15512 "or other activity, so that you can <quote>replay</quote> the build later if "
15513 "necessary."
15514 msgstr ""
15516 #. type: Content of: <book><chapter><sect1><sect2><title>
15517 #: ../en/ch11-template.xml:611
15518 msgid "Listing files on multiple lines"
15519 msgstr "每行列出一个文件"
15521 #. type: Content of: <book><chapter><sect1><sect2><para>
15522 #: ../en/ch11-template.xml:613
15523 msgid ""
15524 "Suppose we want to list the files changed by a changeset, one per line, with "
15525 "a little indentation before each file name."
15526 msgstr ""
15528 #. type: Content of: <book><chapter><sect1><sect2><title>
15529 #: ../en/ch11-template.xml:621
15530 msgid "Mimicking Subversion's output"
15531 msgstr "模仿 Subversion 的输出"
15534 #. type: Content of: <book><chapter><sect1><sect2><para>
15535 #: ../en/ch11-template.xml:623
15536 msgid ""
15537 "Let's try to emulate the default output format used by another revision "
15538 "control tool, Subversion."
15539 msgstr ""
15542 #. type: Content of: <book><chapter><sect1><sect2><para>
15543 #: ../en/ch11-template.xml:628
15544 msgid ""
15545 "Since Subversion's output style is fairly simple, it is easy to copy-and-"
15546 "paste a hunk of its output into a file, and replace the text produced above "
15547 "by Subversion with the template values we'd like to see expanded."
15548 msgstr ""
15550 #. type: Content of: <book><chapter><sect1><sect2><para>
15551 #: ../en/ch11-template.xml:635
15552 msgid ""
15553 "There are a few small ways in which this template deviates from the output "
15554 "produced by Subversion."
15555 msgstr ""
15557 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15558 #: ../en/ch11-template.xml:638
15559 msgid ""
15560 "Subversion prints a <quote>readable</quote> date (the <quote><literal>Wed, 27 "
15561 "Sep 2006</literal></quote> in the example output above) in parentheses. "
15562 "Mercurial's templating engine does not provide a way to display a date in "
15563 "this format without also printing the time and time zone."
15564 msgstr ""
15566 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15567 #: ../en/ch11-template.xml:645
15568 msgid ""
15569 "We emulate Subversion's printing of <quote>separator</quote> lines full of "
15570 "<quote><literal>-</literal></quote> characters by ending the template with "
15571 "such a line. We use the templating engine's <literal role=\"template-keyword"
15572 "\">header</literal> keyword to print a separator line as the first line of "
15573 "output (see below), thus achieving similar output to Subversion."
15574 msgstr ""
15576 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15577 #: ../en/ch11-template.xml:654
15578 msgid ""
15579 "Subversion's output includes a count in the header of the number of lines in "
15580 "the commit message. We cannot replicate this in Mercurial; the templating "
15581 "engine does not currently provide a filter that counts the number of lines "
15582 "the template generates."
15583 msgstr ""
15586 #. type: Content of: <book><chapter><sect1><sect2><para>
15587 #: ../en/ch11-template.xml:660
15588 msgid ""
15589 "It took me no more than a minute or two of work to replace literal text from "
15590 "an example of Subversion's output with some keywords and filters to give the "
15591 "template above. The style file simply refers to the template."
15592 msgstr ""
15594 #. type: Content of: <book><chapter><sect1><sect2><para>
15595 #: ../en/ch11-template.xml:667
15596 msgid ""
15597 "We could have included the text of the template file directly in the style "
15598 "file by enclosing it in quotes and replacing the newlines with "
15599 "<quote><literal>\\n</literal></quote> sequences, but it would have made the "
15600 "style file too difficult to read. Readability is a good guide when you're "
15601 "trying to decide whether some text belongs in a style file, or in a template "
15602 "file that the style file points to. If the style file will look too big or "
15603 "cluttered if you insert a literal piece of text, drop it into a template "
15604 "instead."
15605 msgstr ""
15607 #. type: Content of: <book><chapter><title>
15608 #: ../en/ch12-mq.xml:5
15609 msgid "Managing change with Mercurial Queues"
15610 msgstr "使用 MQ 管理修改"
15612 #. type: Content of: <book><chapter><sect1><title>
15613 #: ../en/ch12-mq.xml:8
15614 msgid "The patch management problem"
15615 msgstr "补丁的管理问题"
15617 #. type: Content of: <book><chapter><sect1><para>
15618 #: ../en/ch12-mq.xml:10
15619 msgid ""
15620 "Here is a common scenario: you need to install a software package from "
15621 "source, but you find a bug that you must fix in the source before you can "
15622 "start using the package. You make your changes, forget about the package for "
15623 "a while, and a few months later you need to upgrade to a newer version of the "
15624 "package. If the newer version of the package still has the bug, you must "
15625 "extract your fix from the older source tree and apply it against the newer "
15626 "version. This is a tedious task, and it's easy to make mistakes."
15627 msgstr ""
15629 #. type: Content of: <book><chapter><sect1><para>
15630 #: ../en/ch12-mq.xml:20
15631 msgid ""
15632 "This is a simple case of the <quote>patch management</quote> problem. You "
15633 "have an <quote>upstream</quote> source tree that you can't change; you need "
15634 "to make some local changes on top of the upstream tree; and you'd like to be "
15635 "able to keep those changes separate, so that you can apply them to newer "
15636 "versions of the upstream source."
15637 msgstr ""
15639 #. type: Content of: <book><chapter><sect1><para>
15640 #: ../en/ch12-mq.xml:27
15641 msgid ""
15642 "The patch management problem arises in many situations. Probably the most "
15643 "visible is that a user of an open source software project will contribute a "
15644 "bug fix or new feature to the project's maintainers in the form of a patch."
15645 msgstr ""
15647 #. type: Content of: <book><chapter><sect1><para>
15648 #: ../en/ch12-mq.xml:32
15649 msgid ""
15650 "Distributors of operating systems that include open source software often "
15651 "need to make changes to the packages they distribute so that they will build "
15652 "properly in their environments."
15653 msgstr ""
15655 #. type: Content of: <book><chapter><sect1><para>
15656 #: ../en/ch12-mq.xml:37
15657 msgid ""
15658 "When you have few changes to maintain, it is easy to manage a single patch "
15659 "using the standard <command>diff</command> and <command>patch</command> "
15660 "programs (see <xref linkend=\"sec:mq:patch\"/> for a discussion of these "
15661 "tools). Once the number of changes grows, it starts to make sense to maintain "
15662 "patches as discrete <quote>chunks of work,</quote> so that for example a "
15663 "single patch will contain only one bug fix (the patch might modify several "
15664 "files, but it's doing <quote>only one thing</quote>), and you may have a "
15665 "number of such patches for different bugs you need fixed and local changes "
15666 "you require. In this situation, if you submit a bug fix patch to the "
15667 "upstream maintainers of a package and they include your fix in a subsequent "
15668 "release, you can simply drop that single patch when you're updating to the "
15669 "newer release."
15670 msgstr ""
15672 #. type: Content of: <book><chapter><sect1><para>
15673 #: ../en/ch12-mq.xml:52
15674 msgid ""
15675 "Maintaining a single patch against an upstream tree is a little tedious and "
15676 "error-prone, but not difficult. However, the complexity of the problem grows "
15677 "rapidly as the number of patches you have to maintain increases. With more "
15678 "than a tiny number of patches in hand, understanding which ones you have "
15679 "applied and maintaining them moves from messy to overwhelming."
15680 msgstr ""
15682 #. type: Content of: <book><chapter><sect1><para>
15683 #: ../en/ch12-mq.xml:59
15684 msgid ""
15685 "Fortunately, Mercurial includes a powerful extension, Mercurial Queues (or "
15686 "simply <quote>MQ</quote>), that massively simplifies the patch management "
15687 "problem."
15688 msgstr ""
15690 #. type: Content of: <book><chapter><sect1><title>
15691 #: ../en/ch12-mq.xml:65
15692 msgid "The prehistory of Mercurial Queues"
15693 msgstr "MQ 的历史"
15695 #. type: Content of: <book><chapter><sect1><para>
15696 #: ../en/ch12-mq.xml:67
15697 msgid ""
15698 "During the late 1990s, several Linux kernel developers started to maintain "
15699 "<quote>patch series</quote> that modified the behavior of the Linux kernel. "
15700 "Some of these series were focused on stability, some on feature coverage, and "
15701 "others were more speculative."
15702 msgstr ""
15704 #. type: Content of: <book><chapter><sect1><para>
15705 #: ../en/ch12-mq.xml:73
15706 msgid ""
15707 "The sizes of these patch series grew rapidly. In 2002, Andrew Morton "
15708 "published some shell scripts he had been using to automate the task of "
15709 "managing his patch queues. Andrew was successfully using these scripts to "
15710 "manage hundreds (sometimes thousands) of patches on top of the Linux kernel."
15711 msgstr ""
15713 #. type: Content of: <book><chapter><sect1><sect2><title>
15714 #: ../en/ch12-mq.xml:80
15715 msgid "A patchwork quilt"
15716 msgstr ""
15718 #. type: Content of: <book><chapter><sect1><sect2><para>
15719 #: ../en/ch12-mq.xml:82
15720 msgid ""
15721 "In early 2003, Andreas Gruenbacher and Martin Quinson borrowed the approach "
15722 "of Andrew's scripts and published a tool called <quote>patchwork quilt</"
15723 "quote> <citation>web:quilt</citation>, or simply <quote>quilt</quote> (see "
15724 "<citation>gruenbacher:2005</citation> for a paper describing it). Because "
15725 "quilt substantially automated patch management, it rapidly gained a large "
15726 "following among open source software developers."
15727 msgstr ""
15729 #. type: Content of: <book><chapter><sect1><sect2><para>
15730 #: ../en/ch12-mq.xml:91
15731 msgid ""
15732 "Quilt manages a <emphasis>stack of patches</emphasis> on top of a directory "
15733 "tree. To begin, you tell quilt to manage a directory tree, and tell it which "
15734 "files you want to manage; it stores away the names and contents of those "
15735 "files. To fix a bug, you create a new patch (using a single command), edit "
15736 "the files you need to fix, then <quote>refresh</quote> the patch."
15737 msgstr ""
15739 #. type: Content of: <book><chapter><sect1><sect2><para>
15740 #: ../en/ch12-mq.xml:99
15741 msgid ""
15742 "The refresh step causes quilt to scan the directory tree; it updates the "
15743 "patch with all of the changes you have made. You can create another patch on "
15744 "top of the first, which will track the changes required to modify the tree "
15745 "from <quote>tree with one patch applied</quote> to <quote>tree with two "
15746 "patches applied</quote>."
15747 msgstr ""
15749 #. type: Content of: <book><chapter><sect1><sect2><para>
15750 #: ../en/ch12-mq.xml:106
15751 msgid ""
15752 "You can <emphasis>change</emphasis> which patches are applied to the tree. "
15753 "If you <quote>pop</quote> a patch, the changes made by that patch will vanish "
15754 "from the directory tree. Quilt remembers which patches you have popped, "
15755 "though, so you can <quote>push</quote> a popped patch again, and the "
15756 "directory tree will be restored to contain the modifications in the patch. "
15757 "Most importantly, you can run the <quote>refresh</quote> command at any time, "
15758 "and the topmost applied patch will be updated. This means that you can, at "
15759 "any time, change both which patches are applied and what modifications those "
15760 "patches make."
15761 msgstr ""
15763 #. type: Content of: <book><chapter><sect1><sect2><para>
15764 #: ../en/ch12-mq.xml:118
15765 msgid ""
15766 "Quilt knows nothing about revision control tools, so it works equally well on "
15767 "top of an unpacked tarball or a Subversion working copy."
15768 msgstr ""
15770 #. type: Content of: <book><chapter><sect1><sect2><title>
15771 #: ../en/ch12-mq.xml:124
15772 msgid "From patchwork quilt to Mercurial Queues"
15773 msgstr "从 patchwork quilt 到 MQ"
15775 #. type: Content of: <book><chapter><sect1><sect2><para>
15776 #: ../en/ch12-mq.xml:126
15777 msgid ""
15778 "In mid-2005, Chris Mason took the features of quilt and wrote an extension "
15779 "that he called Mercurial Queues, which added quilt-like behavior to Mercurial."
15780 msgstr ""
15782 #. type: Content of: <book><chapter><sect1><sect2><para>
15783 #: ../en/ch12-mq.xml:130
15784 msgid ""
15785 "The key difference between quilt and MQ is that quilt knows nothing about "
15786 "revision control systems, while MQ is <emphasis>integrated</emphasis> into "
15787 "Mercurial. Each patch that you push is represented as a Mercurial "
15788 "changeset. Pop a patch, and the changeset goes away."
15789 msgstr ""
15791 #. type: Content of: <book><chapter><sect1><sect2><para>
15792 #: ../en/ch12-mq.xml:136
15793 msgid ""
15794 "Because quilt does not care about revision control tools, it is still a "
15795 "tremendously useful piece of software to know about for situations where you "
15796 "cannot use Mercurial and MQ."
15797 msgstr ""
15799 #. type: Content of: <book><chapter><sect1><title>
15800 #: ../en/ch12-mq.xml:144
15801 msgid "The huge advantage of MQ"
15802 msgstr "MQ 的巨大优势"
15804 #. type: Content of: <book><chapter><sect1><para>
15805 #: ../en/ch12-mq.xml:146
15806 msgid ""
15807 "I cannot overstate the value that MQ offers through the unification of "
15808 "patches and revision control."
15809 msgstr ""
15811 #. type: Content of: <book><chapter><sect1><para>
15812 #: ../en/ch12-mq.xml:149
15813 msgid ""
15814 "A major reason that patches have persisted in the free software and open "
15815 "source world&emdash;in spite of the availability of increasingly capable "
15816 "revision control tools over the years&emdash;is the <emphasis>agility</"
15817 "emphasis> they offer."
15818 msgstr ""
15820 #. type: Content of: <book><chapter><sect1><para>
15821 #: ../en/ch12-mq.xml:155
15822 msgid ""
15823 "Traditional revision control tools make a permanent, irreversible record of "
15824 "everything that you do. While this has great value, it's also somewhat "
15825 "stifling. If you want to perform a wild-eyed experiment, you have to be "
15826 "careful in how you go about it, or you risk leaving unneeded&emdash;or worse, "
15827 "misleading or destabilising&emdash;traces of your missteps and errors in the "
15828 "permanent revision record."
15829 msgstr ""
15831 #. type: Content of: <book><chapter><sect1><para>
15832 #: ../en/ch12-mq.xml:163
15833 msgid ""
15834 "By contrast, MQ's marriage of distributed revision control with patches makes "
15835 "it much easier to isolate your work. Your patches live on top of normal "
15836 "revision history, and you can make them disappear or reappear at will. If "
15837 "you don't like a patch, you can drop it. If a patch isn't quite as you want "
15838 "it to be, simply fix it&emdash;as many times as you need to, until you have "
15839 "refined it into the form you desire."
15840 msgstr ""
15842 #. type: Content of: <book><chapter><sect1><para>
15843 #: ../en/ch12-mq.xml:171
15844 msgid ""
15845 "As an example, the integration of patches with revision control makes "
15846 "understanding patches and debugging their effects&emdash;and their interplay "
15847 "with the code they're based on&emdash;<emphasis>enormously</emphasis> easier. "
15848 "Since every applied patch has an associated changeset, you can give <command "
15849 "role=\"hg-cmd\">hg log</command> a file name to see which changesets and "
15850 "patches affected the file. You can use the <command role=\"hg-cmd\">hg "
15851 "bisect</command> command to binary-search through all changesets and applied "
15852 "patches to see where a bug got introduced or fixed. You can use the <command "
15853 "role=\"hg-cmd\">hg annotate</command> command to see which changeset or patch "
15854 "modified a particular line of a source file. And so on."
15855 msgstr ""
15857 #. type: Content of: <book><chapter><sect1><para>
15858 #: ../en/ch12-mq.xml:189
15859 msgid ""
15860 "Because MQ doesn't hide its patch-oriented nature, it is helpful to "
15861 "understand what patches are, and a little about the tools that work with them."
15862 msgstr ""
15864 #. type: Content of: <book><chapter><sect1><para>
15865 #: ../en/ch12-mq.xml:193
15866 msgid ""
15867 "The traditional Unix <command>diff</command> command compares two files, and "
15868 "prints a list of differences between them. The <command>patch</command> "
15869 "command understands these differences as <emphasis>modifications</emphasis> "
15870 "to make to a file. Take a look below for a simple example of these commands "
15871 "in action."
15872 msgstr ""
15874 #. type: Content of: <book><chapter><sect1><para>
15875 #: ../en/ch12-mq.xml:202
15876 msgid ""
15877 "The type of file that <command>diff</command> generates (and <command>patch</"
15878 "command> takes as input) is called a <quote>patch</quote> or a <quote>diff</"
15879 "quote>; there is no difference between a patch and a diff. (We'll use the "
15880 "term <quote>patch</quote>, since it's more commonly used.)"
15881 msgstr ""
15883 #. type: Content of: <book><chapter><sect1><para>
15884 #: ../en/ch12-mq.xml:208
15885 msgid ""
15886 "A patch file can start with arbitrary text; the <command>patch</command> "
15887 "command ignores this text, but MQ uses it as the commit message when creating "
15888 "changesets. To find the beginning of the patch content, <command>patch</"
15889 "command> searches for the first line that starts with the string "
15890 "<quote><literal>diff -</literal></quote>."
15891 msgstr ""
15893 #. type: Content of: <book><chapter><sect1><para>
15894 #: ../en/ch12-mq.xml:215
15895 msgid ""
15896 "MQ works with <emphasis>unified</emphasis> diffs (<command>patch</command> "
15897 "can accept several other diff formats, but MQ doesn't). A unified diff "
15898 "contains two kinds of header. The <emphasis>file header</emphasis> describes "
15899 "the file being modified; it contains the name of the file to modify. When "
15900 "<command>patch</command> sees a new file header, it looks for a file with "
15901 "that name to start modifying."
15902 msgstr ""
15904 #. type: Content of: <book><chapter><sect1><para>
15905 #: ../en/ch12-mq.xml:223
15906 msgid ""
15907 "After the file header comes a series of <emphasis>hunks</emphasis>. Each "
15908 "hunk starts with a header; this identifies the range of line numbers within "
15909 "the file that the hunk should modify. Following the header, a hunk starts "
15910 "and ends with a few (usually three) lines of text from the unmodified file; "
15911 "these are called the <emphasis>context</emphasis> for the hunk. If there's "
15912 "only a small amount of context between successive hunks, <command>diff</"
15913 "command> doesn't print a new hunk header; it just runs the hunks together, "
15914 "with a few lines of context between modifications."
15915 msgstr ""
15917 #. type: Content of: <book><chapter><sect1><para>
15918 #: ../en/ch12-mq.xml:235
15919 msgid ""
15920 "Each line of context begins with a space character. Within the hunk, a line "
15921 "that begins with <quote><literal>-</literal></quote> means <quote>remove this "
15922 "line,</quote> while a line that begins with <quote><literal>+</literal></"
15923 "quote> means <quote>insert this line.</quote> For example, a line that is "
15924 "modified is represented by one deletion and one insertion."
15925 msgstr ""
15927 #. type: Content of: <book><chapter><sect1><para>
15928 #: ../en/ch12-mq.xml:243
15929 msgid ""
15930 "We will return to some of the more subtle aspects of patches later (in <xref "
15931 "linkend=\"sec:mq:adv-patch\"/>), but you should have enough information now "
15932 "to use MQ."
15933 msgstr ""
15935 #. type: Content of: <book><chapter><sect1><title>
15936 #: ../en/ch12-mq.xml:250
15937 msgid "Getting started with Mercurial Queues"
15938 msgstr "开始使用 MQ"
15940 #. type: Content of: <book><chapter><sect1><para>
15941 #: ../en/ch12-mq.xml:252
15942 msgid ""
15943 "Because MQ is implemented as an extension, you must explicitly enable before "
15944 "you can use it. (You don't need to download anything; MQ ships with the "
15945 "standard Mercurial distribution.) To enable MQ, edit your <filename role="
15946 "\"home\">~/.hgrc</filename> file, and add the lines below."
15947 msgstr ""
15949 #. type: Content of: <book><chapter><sect1><para>
15950 #: ../en/ch12-mq.xml:262
15951 msgid ""
15952 "Once the extension is enabled, it will make a number of new commands "
15953 "available. To verify that the extension is working, you can use <command "
15954 "role=\"hg-cmd\">hg help</command> to see if the <command role=\"hg-ext-mq"
15955 "\">qinit</command> command is now available."
15956 msgstr ""
15958 #. type: Content of: <book><chapter><sect1><para>
15959 #: ../en/ch12-mq.xml:270
15960 msgid ""
15961 "You can use MQ with <emphasis>any</emphasis> Mercurial repository, and its "
15962 "commands only operate within that repository. To get started, simply prepare "
15963 "the repository using the <command role=\"hg-ext-mq\">qinit</command> command."
15964 msgstr ""
15966 #. type: Content of: <book><chapter><sect1><para>
15967 #: ../en/ch12-mq.xml:277
15968 msgid ""
15969 "This command creates an empty directory called <filename role=\"special\" "
15970 "class=\"directory\">.hg/patches</filename>, where MQ will keep its metadata. "
15971 "As with many Mercurial commands, the <command role=\"hg-ext-mq\">qinit</"
15972 "command> command prints nothing if it succeeds."
15973 msgstr ""
15975 #. type: Content of: <book><chapter><sect1><sect2><title>
15976 #: ../en/ch12-mq.xml:284
15977 msgid "Creating a new patch"
15978 msgstr "创建新补丁"
15980 #. type: Content of: <book><chapter><sect1><sect2><para>
15981 #: ../en/ch12-mq.xml:286
15982 msgid ""
15983 "To begin work on a new patch, use the <command role=\"hg-ext-mq\">qnew</"
15984 "command> command. This command takes one argument, the name of the patch to "
15985 "create."
15986 msgstr ""
15988 #. type: Content of: <book><chapter><sect1><sect2><para>
15989 #: ../en/ch12-mq.xml:290
15990 msgid ""
15991 "MQ will use this as the name of an actual file in the <filename role=\"special"
15992 "\" class=\"directory\">.hg/patches</filename> directory, as you can see below."
15993 msgstr ""
15995 #. type: Content of: <book><chapter><sect1><sect2><para>
15996 #: ../en/ch12-mq.xml:297
15997 msgid ""
15998 "Also newly present in the <filename role=\"special\" class=\"directory\">.hg/"
15999 "patches</filename> directory are two other files, <filename role=\"special"
16000 "\">series</filename> and <filename role=\"special\">status</filename>. The "
16001 "<filename role=\"special\">series</filename> file lists all of the patches "
16002 "that MQ knows about for this repository, with one patch per line. Mercurial "
16003 "uses the <filename role=\"special\">status</filename> file for internal book-"
16004 "keeping; it tracks all of the patches that MQ has <emphasis>applied</"
16005 "emphasis> in this repository."
16006 msgstr ""
16008 #. type: Content of: <book><chapter><sect1><sect2><note><para>
16009 #: ../en/ch12-mq.xml:309
16010 msgid ""
16011 "You may sometimes want to edit the <filename role=\"special\">series</"
16012 "filename> file by hand; for example, to change the sequence in which some "
16013 "patches are applied. However, manually editing the <filename role=\"special"
16014 "\">status</filename> file is almost always a bad idea, as it's easy to "
16015 "corrupt MQ's idea of what is happening."
16016 msgstr ""
16018 #. type: Content of: <book><chapter><sect1><sect2><para>
16019 #: ../en/ch12-mq.xml:318
16020 msgid ""
16021 "Once you have created your new patch, you can edit files in the working "
16022 "directory as you usually would. All of the normal Mercurial commands, such "
16023 "as <command role=\"hg-cmd\">hg diff</command> and <command role=\"hg-cmd\">hg "
16024 "annotate</command>, work exactly as they did before."
16025 msgstr ""
16027 #. type: Content of: <book><chapter><sect1><sect2><title>
16028 #: ../en/ch12-mq.xml:326
16029 msgid "Refreshing a patch"
16030 msgstr "刷新补丁"
16032 #. type: Content of: <book><chapter><sect1><sect2><para>
16033 #: ../en/ch12-mq.xml:328
16034 msgid ""
16035 "When you reach a point where you want to save your work, use the <command "
16036 "role=\"hg-ext-mq\">qrefresh</command> command to update the patch you are "
16037 "working on."
16038 msgstr ""
16040 #. type: Content of: <book><chapter><sect1><sect2><para>
16041 #: ../en/ch12-mq.xml:334
16042 msgid ""
16043 "This command folds the changes you have made in the working directory into "
16044 "your patch, and updates its corresponding changeset to contain those changes."
16045 msgstr ""
16047 #. type: Content of: <book><chapter><sect1><sect2><para>
16048 #: ../en/ch12-mq.xml:338
16049 msgid ""
16050 "You can run <command role=\"hg-ext-mq\">qrefresh</command> as often as you "
16051 "like, so it's a good way to <quote>checkpoint</quote> your work. Refresh "
16052 "your patch at an opportune time; try an experiment; and if the experiment "
16053 "doesn't work out, <command role=\"hg-cmd\">hg revert</command> your "
16054 "modifications back to the last time you refreshed."
16055 msgstr ""
16057 #. type: Content of: <book><chapter><sect1><sect2><title>
16058 #: ../en/ch12-mq.xml:349
16059 msgid "Stacking and tracking patches"
16060 msgstr "堆叠和跟踪补丁"
16062 #. type: Content of: <book><chapter><sect1><sect2><para>
16063 #: ../en/ch12-mq.xml:351
16064 msgid ""
16065 "Once you have finished working on a patch, or need to work on another, you "
16066 "can use the <command role=\"hg-ext-mq\">qnew</command> command again to "
16067 "create a new patch. Mercurial will apply this patch on top of your existing "
16068 "patch."
16069 msgstr ""
16071 #. type: Content of: <book><chapter><sect1><sect2><para>
16072 #: ../en/ch12-mq.xml:359
16073 msgid ""
16074 "Notice that the patch contains the changes in our prior patch as part of its "
16075 "context (you can see this more clearly in the output of <command role=\"hg-cmd"
16076 "\">hg annotate</command>)."
16077 msgstr ""
16079 #. type: Content of: <book><chapter><sect1><sect2><para>
16080 #: ../en/ch12-mq.xml:364
16081 msgid ""
16082 "So far, with the exception of <command role=\"hg-ext-mq\">qnew</command> and "
16083 "<command role=\"hg-ext-mq\">qrefresh</command>, we've been careful to only "
16084 "use regular Mercurial commands. However, MQ provides many commands that are "
16085 "easier to use when you are thinking about patches, as illustrated below."
16086 msgstr ""
16088 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16089 #: ../en/ch12-mq.xml:374
16090 msgid ""
16091 "The <command role=\"hg-ext-mq\">qseries</command> command lists every patch "
16092 "that MQ knows about in this repository, from oldest to newest (most recently "
16093 "<emphasis>created</emphasis>)."
16094 msgstr ""
16096 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16097 #: ../en/ch12-mq.xml:380
16098 msgid ""
16099 "The <command role=\"hg-ext-mq\">qapplied</command> command lists every patch "
16100 "that MQ has <emphasis>applied</emphasis> in this repository, again from "
16101 "oldest to newest (most recently applied)."
16102 msgstr ""
16104 #. type: Content of: <book><chapter><sect1><sect2><title>
16105 #: ../en/ch12-mq.xml:389
16106 msgid "Manipulating the patch stack"
16107 msgstr "操作补丁堆栈"
16109 #. type: Content of: <book><chapter><sect1><sect2><para>
16110 #: ../en/ch12-mq.xml:391
16111 msgid ""
16112 "The previous discussion implied that there must be a difference between "
16113 "<quote>known</quote> and <quote>applied</quote> patches, and there is. MQ "
16114 "can manage a patch without it being applied in the repository."
16115 msgstr ""
16117 #. type: Content of: <book><chapter><sect1><sect2><para>
16118 #: ../en/ch12-mq.xml:396
16119 msgid ""
16120 "An <emphasis>applied</emphasis> patch has a corresponding changeset in the "
16121 "repository, and the effects of the patch and changeset are visible in the "
16122 "working directory. You can undo the application of a patch using the "
16123 "<command role=\"hg-ext-mq\">qpop</command> command. MQ still <emphasis>knows "
16124 "about</emphasis>, or manages, a popped patch, but the patch no longer has a "
16125 "corresponding changeset in the repository, and the working directory does not "
16126 "contain the changes made by the patch. <xref linkend=\"fig:mq:stack\"/> "
16127 "illustrates the difference between applied and tracked patches."
16128 msgstr ""
16130 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
16131 #: ../en/ch12-mq.xml:409
16132 msgid "Applied and unapplied patches in the MQ patch stack"
16133 msgstr "在 MQ 补丁堆栈中应用和撤销补丁"
16135 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
16136 #: ../en/ch12-mq.xml:412
16137 msgid "<imageobject><imagedata fileref=\"figs/mq-stack.png\"/></imageobject>"
16138 msgstr ""
16140 #. type: Content of: <book><chapter><sect1><sect2><para>
16141 #: ../en/ch12-mq.xml:417
16142 msgid ""
16143 "You can reapply an unapplied, or popped, patch using the <command role=\"hg-"
16144 "ext-mq\">qpush</command> command. This creates a new changeset to correspond "
16145 "to the patch, and the patch's changes once again become present in the "
16146 "working directory. See below for examples of <command role=\"hg-ext-mq"
16147 "\">qpop</command> and <command role=\"hg-ext-mq\">qpush</command> in action."
16148 msgstr ""
16150 #. type: Content of: <book><chapter><sect1><sect2><para>
16151 #: ../en/ch12-mq.xml:427
16152 msgid ""
16153 "Notice that once we have popped a patch or two patches, the output of "
16154 "<command role=\"hg-ext-mq\">qseries</command> remains the same, while that of "
16155 "<command role=\"hg-ext-mq\">qapplied</command> has changed."
16156 msgstr ""
16158 #. type: Content of: <book><chapter><sect1><sect2><title>
16159 #: ../en/ch12-mq.xml:435
16160 msgid "Pushing and popping many patches"
16161 msgstr "压入或弹出多个补丁"
16163 #. type: Content of: <book><chapter><sect1><sect2><para>
16164 #: ../en/ch12-mq.xml:437
16165 msgid ""
16166 "While <command role=\"hg-ext-mq\">qpush</command> and <command role=\"hg-ext-"
16167 "mq\">qpop</command> each operate on a single patch at a time by default, you "
16168 "can push and pop many patches in one go. The <option role=\"hg-ext-mq-cmd-"
16169 "qpush-opt\">-a</option> option to <command role=\"hg-ext-mq\">qpush</command> "
16170 "causes it to push all unapplied patches, while the <option role=\"hg-ext-mq-"
16171 "cmd-qpop-opt\">-a</option> option to <command role=\"hg-ext-mq\">qpop</"
16172 "command> causes it to pop all applied patches. (For some more ways to push "
16173 "and pop many patches, see <xref linkend=\"sec:mq:perf\"/> below.)"
16174 msgstr ""
16176 #. type: Content of: <book><chapter><sect1><sect2><title>
16177 #: ../en/ch12-mq.xml:453
16178 msgid "Safety checks, and overriding them"
16179 msgstr "安全的检查,然后覆盖它们"
16181 #. type: Content of: <book><chapter><sect1><sect2><para>
16182 #: ../en/ch12-mq.xml:455
16183 msgid ""
16184 "Several MQ commands check the working directory before they do anything, and "
16185 "fail if they find any modifications. They do this to ensure that you won't "
16186 "lose any changes that you have made, but not yet incorporated into a patch. "
16187 "The example below illustrates this; the <command role=\"hg-ext-mq\">qnew</"
16188 "command> command will not create a new patch if there are outstanding "
16189 "changes, caused in this case by the <command role=\"hg-cmd\">hg add</command> "
16190 "of <filename>file3</filename>."
16191 msgstr ""
16193 #. type: Content of: <book><chapter><sect1><sect2><para>
16194 #: ../en/ch12-mq.xml:467
16195 msgid ""
16196 "Commands that check the working directory all take an <quote>I know what I'm "
16197 "doing</quote> option, which is always named <option>-f</option>. The exact "
16198 "meaning of <option>-f</option> depends on the command. For example, <command "
16199 "role=\"hg-cmd\">hg qnew <option role=\"hg-ext-mq-cmd-qnew-opt\">-f</option></"
16200 "command> will incorporate any outstanding changes into the new patch it "
16201 "creates, but <command role=\"hg-cmd\">hg qpop <option role=\"hg-ext-mq-cmd-"
16202 "qpop-opt\">-f</option></command> will revert modifications to any files "
16203 "affected by the patch that it is popping. Be sure to read the documentation "
16204 "for a command's <option>-f</option> option before you use it!"
16205 msgstr ""
16207 #. type: Content of: <book><chapter><sect1><sect2><title>
16208 #: ../en/ch12-mq.xml:482
16209 msgid "Working on several patches at once"
16210 msgstr "同时处理多个补丁"
16212 #. type: Content of: <book><chapter><sect1><sect2><para>
16213 #: ../en/ch12-mq.xml:484
16214 msgid ""
16215 "The <command role=\"hg-ext-mq\">qrefresh</command> command always refreshes "
16216 "the <emphasis>topmost</emphasis> applied patch. This means that you can "
16217 "suspend work on one patch (by refreshing it), pop or push to make a different "
16218 "patch the top, and work on <emphasis>that</emphasis> patch for a while."
16219 msgstr ""
16221 #. type: Content of: <book><chapter><sect1><sect2><para>
16222 #: ../en/ch12-mq.xml:491
16223 msgid ""
16224 "Here's an example that illustrates how you can use this ability. Let's say "
16225 "you're developing a new feature as two patches. The first is a change to the "
16226 "core of your software, and the second&emdash;layered on top of the "
16227 "first&emdash;changes the user interface to use the code you just added to the "
16228 "core. If you notice a bug in the core while you're working on the UI patch, "
16229 "it's easy to fix the core. Simply <command role=\"hg-ext-mq\">qrefresh</"
16230 "command> the UI patch to save your in-progress changes, and <command role="
16231 "\"hg-ext-mq\">qpop</command> down to the core patch. Fix the core bug, "
16232 "<command role=\"hg-ext-mq\">qrefresh</command> the core patch, and <command "
16233 "role=\"hg-ext-mq\">qpush</command> back to the UI patch to continue where you "
16234 "left off."
16235 msgstr ""
16237 #. type: Content of: <book><chapter><sect1><title>
16238 #: ../en/ch12-mq.xml:508
16239 msgid "More about patches"
16240 msgstr "关于补丁的更多信息"
16242 #. type: Content of: <book><chapter><sect1><para>
16243 #: ../en/ch12-mq.xml:510
16244 msgid ""
16245 "MQ uses the GNU <command>patch</command> command to apply patches, so it's "
16246 "helpful to know a few more detailed aspects of how <command>patch</command> "
16247 "works, and about patches themselves."
16248 msgstr ""
16250 #. type: Content of: <book><chapter><sect1><sect2><title>
16251 #: ../en/ch12-mq.xml:516
16252 msgid "The strip count"
16253 msgstr "修剪计数"
16255 #. type: Content of: <book><chapter><sect1><sect2><para>
16256 #: ../en/ch12-mq.xml:518
16257 msgid ""
16258 "If you look at the file headers in a patch, you will notice that the "
16259 "pathnames usually have an extra component on the front that isn't present in "
16260 "the actual path name. This is a holdover from the way that people used to "
16261 "generate patches (people still do this, but it's somewhat rare with modern "
16262 "revision control tools)."
16263 msgstr ""
16265 #. type: Content of: <book><chapter><sect1><sect2><para>
16266 #: ../en/ch12-mq.xml:525
16267 msgid ""
16268 "Alice would unpack a tarball, edit her files, then decide that she wanted to "
16269 "create a patch. So she'd rename her working directory, unpack the tarball "
16270 "again (hence the need for the rename), and use the <option role=\"cmd-opt-diff"
16271 "\">-r</option> and <option role=\"cmd-opt-diff\">-N</option> options to "
16272 "<command>diff</command> to recursively generate a patch between the "
16273 "unmodified directory and the modified one. The result would be that the name "
16274 "of the unmodified directory would be at the front of the left-hand path in "
16275 "every file header, and the name of the modified directory would be at the "
16276 "front of the right-hand path."
16277 msgstr ""
16279 #. type: Content of: <book><chapter><sect1><sect2><para>
16280 #: ../en/ch12-mq.xml:538
16281 msgid ""
16282 "Since someone receiving a patch from the Alices of the net would be unlikely "
16283 "to have unmodified and modified directories with exactly the same names, the "
16284 "<command>patch</command> command has a <option role=\"cmd-opt-patch\">-p</"
16285 "option> option that indicates the number of leading path name components to "
16286 "strip when trying to apply a patch. This number is called the "
16287 "<emphasis>strip count</emphasis>."
16288 msgstr ""
16290 #. type: Content of: <book><chapter><sect1><sect2><para>
16291 #: ../en/ch12-mq.xml:546
16292 msgid ""
16293 "An option of <quote><literal>-p1</literal></quote> means <quote>use a strip "
16294 "count of one</quote>. If <command>patch</command> sees a file name "
16295 "<filename>foo/bar/baz</filename> in a file header, it will strip "
16296 "<filename>foo</filename> and try to patch a file named <filename>bar/baz</"
16297 "filename>. (Strictly speaking, the strip count refers to the number of "
16298 "<emphasis>path separators</emphasis> (and the components that go with them ) "
16299 "to strip. A strip count of one will turn <filename>foo/bar</filename> into "
16300 "<filename>bar</filename>, but <filename>/foo/bar</filename> (notice the extra "
16301 "leading slash) into <filename>foo/bar</filename>.)"
16302 msgstr ""
16304 #. type: Content of: <book><chapter><sect1><sect2><para>
16305 #: ../en/ch12-mq.xml:559
16306 msgid ""
16307 "The <quote>standard</quote> strip count for patches is one; almost all "
16308 "patches contain one leading path name component that needs to be stripped. "
16309 "Mercurial's <command role=\"hg-cmd\">hg diff</command> command generates path "
16310 "names in this form, and the <command role=\"hg-cmd\">hg import</command> "
16311 "command and MQ expect patches to have a strip count of one."
16312 msgstr ""
16314 #. type: Content of: <book><chapter><sect1><sect2><para>
16315 #: ../en/ch12-mq.xml:567
16316 msgid ""
16317 "If you receive a patch from someone that you want to add to your patch queue, "
16318 "and the patch needs a strip count other than one, you cannot just <command "
16319 "role=\"hg-ext-mq\">qimport</command> the patch, because <command role=\"hg-"
16320 "ext-mq\">qimport</command> does not yet have a <literal>-p</literal> option "
16321 "(see <ulink role=\"hg-bug\" url=\"http://www.selenic.com/mercurial/bts/"
16322 "issue311\">issue 311</ulink>). Your best bet is to <command role=\"hg-ext-mq"
16323 "\">qnew</command> a patch of your own, then use <command>patch -pN</command> "
16324 "to apply their patch, followed by <command role=\"hg-cmd\">hg addremove</"
16325 "command> to pick up any files added or removed by the patch, followed by "
16326 "<command role=\"hg-ext-mq\">hg qrefresh</command>. This complexity may become "
16327 "unnecessary; see <ulink role=\"hg-bug\" url=\"http://www.selenic.com/"
16328 "mercurial/bts/issue311\">issue 311</ulink> for details."
16329 msgstr ""
16331 #. type: Content of: <book><chapter><sect1><sect2><title>
16332 #: ../en/ch12-mq.xml:587
16333 msgid "Strategies for applying a patch"
16334 msgstr "应用补丁的策略"
16336 #. type: Content of: <book><chapter><sect1><sect2><para>
16337 #: ../en/ch12-mq.xml:589
16338 msgid ""
16339 "When <command>patch</command> applies a hunk, it tries a handful of "
16340 "successively less accurate strategies to try to make the hunk apply. This "
16341 "falling-back technique often makes it possible to take a patch that was "
16342 "generated against an old version of a file, and apply it against a newer "
16343 "version of that file."
16344 msgstr ""
16346 #. type: Content of: <book><chapter><sect1><sect2><para>
16347 #: ../en/ch12-mq.xml:596
16348 msgid ""
16349 "First, <command>patch</command> tries an exact match, where the line numbers, "
16350 "the context, and the text to be modified must apply exactly. If it cannot "
16351 "make an exact match, it tries to find an exact match for the context, without "
16352 "honouring the line numbering information. If this succeeds, it prints a line "
16353 "of output saying that the hunk was applied, but at some <emphasis>offset</"
16354 "emphasis> from the original line number."
16355 msgstr ""
16357 #. type: Content of: <book><chapter><sect1><sect2><para>
16358 #: ../en/ch12-mq.xml:605
16359 msgid ""
16360 "If a context-only match fails, <command>patch</command> removes the first and "
16361 "last lines of the context, and tries a <emphasis>reduced</emphasis> context-"
16362 "only match. If the hunk with reduced context succeeds, it prints a message "
16363 "saying that it applied the hunk with a <emphasis>fuzz factor</emphasis> (the "
16364 "number after the fuzz factor indicates how many lines of context "
16365 "<command>patch</command> had to trim before the patch applied)."
16366 msgstr ""
16368 #. type: Content of: <book><chapter><sect1><sect2><para>
16369 #: ../en/ch12-mq.xml:614
16370 msgid ""
16371 "When neither of these techniques works, <command>patch</command> prints a "
16372 "message saying that the hunk in question was rejected. It saves rejected "
16373 "hunks (also simply called <quote>rejects</quote>) to a file with the same "
16374 "name, and an added <filename role=\"special\">.rej</filename> extension. It "
16375 "also saves an unmodified copy of the file with a <filename role=\"special\">."
16376 "orig</filename> extension; the copy of the file without any extensions will "
16377 "contain any changes made by hunks that <emphasis>did</emphasis> apply "
16378 "cleanly. If you have a patch that modifies <filename>foo</filename> with six "
16379 "hunks, and one of them fails to apply, you will have: an unmodified "
16380 "<filename>foo.orig</filename>, a <filename>foo.rej</filename> containing one "
16381 "hunk, and <filename>foo</filename>, containing the changes made by the five "
16382 "successful hunks."
16383 msgstr ""
16385 #. type: Content of: <book><chapter><sect1><sect2><title>
16386 #: ../en/ch12-mq.xml:632
16387 msgid "Some quirks of patch representation"
16388 msgstr "补丁的一些特性"
16390 #. type: Content of: <book><chapter><sect1><sect2><para>
16391 #: ../en/ch12-mq.xml:634
16392 msgid ""
16393 "There are a few useful things to know about how <command>patch</command> "
16394 "works with files."
16395 msgstr ""
16397 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16398 #: ../en/ch12-mq.xml:637
16399 msgid ""
16400 "This should already be obvious, but <command>patch</command> cannot handle "
16401 "binary files."
16402 msgstr ""
16404 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16405 #: ../en/ch12-mq.xml:641
16406 msgid ""
16407 "Neither does it care about the executable bit; it creates new files as "
16408 "readable, but not executable."
16409 msgstr ""
16411 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16412 #: ../en/ch12-mq.xml:645
16413 msgid ""
16414 "<command>patch</command> treats the removal of a file as a diff between the "
16415 "file to be removed and the empty file. So your idea of <quote>I deleted this "
16416 "file</quote> looks like <quote>every line of this file was deleted</quote> in "
16417 "a patch."
16418 msgstr ""
16420 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16421 #: ../en/ch12-mq.xml:651
16422 msgid ""
16423 "It treats the addition of a file as a diff between the empty file and the "
16424 "file to be added. So in a patch, your idea of <quote>I added this file</"
16425 "quote> looks like <quote>every line of this file was added</quote>."
16426 msgstr ""
16428 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16429 #: ../en/ch12-mq.xml:657
16430 msgid ""
16431 "It treats a renamed file as the removal of the old name, and the addition of "
16432 "the new name. This means that renamed files have a big footprint in "
16433 "patches. (Note also that Mercurial does not currently try to infer when "
16434 "files have been renamed or copied in a patch.)"
16435 msgstr ""
16437 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16438 #: ../en/ch12-mq.xml:663
16439 msgid ""
16440 "<command>patch</command> cannot represent empty files, so you cannot use a "
16441 "patch to represent the notion <quote>I added this empty file to the tree</"
16442 "quote>."
16443 msgstr ""
16445 #. type: Content of: <book><chapter><sect1><sect2><title>
16446 #: ../en/ch12-mq.xml:671
16447 msgid "Beware the fuzz"
16448 msgstr "当心毛刺"
16450 #. type: Content of: <book><chapter><sect1><sect2><para>
16451 #: ../en/ch12-mq.xml:673
16452 msgid ""
16453 "While applying a hunk at an offset, or with a fuzz factor, will often be "
16454 "completely successful, these inexact techniques naturally leave open the "
16455 "possibility of corrupting the patched file. The most common cases typically "
16456 "involve applying a patch twice, or at an incorrect location in the file. If "
16457 "<command>patch</command> or <command role=\"hg-ext-mq\">qpush</command> ever "
16458 "mentions an offset or fuzz factor, you should make sure that the modified "
16459 "files are correct afterwards."
16460 msgstr ""
16462 #. type: Content of: <book><chapter><sect1><sect2><para>
16463 #: ../en/ch12-mq.xml:683
16464 msgid ""
16465 "It's often a good idea to refresh a patch that has applied with an offset or "
16466 "fuzz factor; refreshing the patch generates new context information that will "
16467 "make it apply cleanly. I say <quote>often,</quote> not <quote>always,</"
16468 "quote> because sometimes refreshing a patch will make it fail to apply "
16469 "against a different revision of the underlying files. In some cases, such as "
16470 "when you're maintaining a patch that must sit on top of multiple versions of "
16471 "a source tree, it's acceptable to have a patch apply with some fuzz, provided "
16472 "you've verified the results of the patching process in such cases."
16473 msgstr ""
16475 #. type: Content of: <book><chapter><sect1><sect2><title>
16476 #: ../en/ch12-mq.xml:696
16477 msgid "Handling rejection"
16478 msgstr "处理拒绝"
16480 #. type: Content of: <book><chapter><sect1><sect2><para>
16481 #: ../en/ch12-mq.xml:698
16482 msgid ""
16483 "If <command role=\"hg-ext-mq\">qpush</command> fails to apply a patch, it "
16484 "will print an error message and exit. If it has left <filename role=\"special"
16485 "\">.rej</filename> files behind, it is usually best to fix up the rejected "
16486 "hunks before you push more patches or do any further work."
16487 msgstr ""
16489 #. type: Content of: <book><chapter><sect1><sect2><para>
16490 #: ../en/ch12-mq.xml:704
16491 msgid ""
16492 "If your patch <emphasis>used to</emphasis> apply cleanly, and no longer does "
16493 "because you've changed the underlying code that your patches are based on, "
16494 "Mercurial Queues can help; see <xref linkend=\"sec:mq:merge\"/> for details."
16495 msgstr ""
16497 #. type: Content of: <book><chapter><sect1><sect2><para>
16498 #: ../en/ch12-mq.xml:709
16499 msgid ""
16500 "Unfortunately, there aren't any great techniques for dealing with rejected "
16501 "hunks. Most often, you'll need to view the <filename role=\"special\">.rej</"
16502 "filename> file and edit the target file, applying the rejected hunks by hand."
16503 msgstr ""
16505 #. type: Content of: <book><chapter><sect1><sect2><para>
16506 #: ../en/ch12-mq.xml:714
16507 msgid ""
16508 "A Linux kernel hacker, Chris Mason (the author of Mercurial Queues), wrote a "
16509 "tool called <command>mpatch</command> (<ulink url=\"http://oss.oracle.com/"
16510 "~mason/mpatch/\">http://oss.oracle.com/~mason/mpatch/</ulink>), which takes a "
16511 "simple approach to automating the application of hunks rejected by "
16512 "<command>patch</command>. The <command>mpatch</command> command can help "
16513 "with four common reasons that a hunk may be rejected:"
16514 msgstr ""
16516 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16517 #: ../en/ch12-mq.xml:724
16518 msgid "The context in the middle of a hunk has changed."
16519 msgstr ""
16521 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16522 #: ../en/ch12-mq.xml:727
16523 msgid "A hunk is missing some context at the beginning or end."
16524 msgstr ""
16526 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16527 #: ../en/ch12-mq.xml:730
16528 msgid ""
16529 "A large hunk might apply better&emdash;either entirely or in part&emdash;if "
16530 "it was broken up into smaller hunks."
16531 msgstr ""
16533 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16534 #: ../en/ch12-mq.xml:734
16535 msgid ""
16536 "A hunk removes lines with slightly different content than those currently "
16537 "present in the file."
16538 msgstr ""
16540 #. type: Content of: <book><chapter><sect1><sect2><para>
16541 #: ../en/ch12-mq.xml:738
16542 msgid ""
16543 "If you use <command>mpatch</command>, you should be doubly careful to check "
16544 "your results when you're done. In fact, <command>mpatch</command> enforces "
16545 "this method of double-checking the tool's output, by automatically dropping "
16546 "you into a merge program when it has done its job, so that you can verify its "
16547 "work and finish off any remaining merges."
16548 msgstr ""
16550 #. type: Content of: <book><chapter><sect1><title>
16551 #: ../en/ch12-mq.xml:749
16552 msgid "More on patch management"
16553 msgstr "补丁管理进阶"
16555 #. type: Content of: <book><chapter><sect1><para>
16556 #: ../en/ch12-mq.xml:751
16557 msgid ""
16558 "As you grow familiar with MQ, you will find yourself wanting to perform other "
16559 "kinds of patch management operations."
16560 msgstr ""
16562 #. type: Content of: <book><chapter><sect1><sect2><title>
16563 #: ../en/ch12-mq.xml:755
16564 msgid "Deleting unwanted patches"
16565 msgstr "删除不需要的补丁"
16567 #. type: Content of: <book><chapter><sect1><sect2><para>
16568 #: ../en/ch12-mq.xml:757
16569 msgid ""
16570 "If you want to get rid of a patch, use the <command role=\"hg-ext-mq\">hg "
16571 "qdelete</command> command to delete the patch file and remove its entry from "
16572 "the patch series. If you try to delete a patch that is still applied, "
16573 "<command role=\"hg-ext-mq\">hg qdelete</command> will refuse."
16574 msgstr ""
16576 #. type: Content of: <book><chapter><sect1><sect2><title>
16577 #: ../en/ch12-mq.xml:767
16578 msgid "Converting to and from permanent revisions"
16579 msgstr "与持久版本的相互转换"
16581 #. type: Content of: <book><chapter><sect1><sect2><para>
16582 #: ../en/ch12-mq.xml:769
16583 msgid ""
16584 "Once you're done working on a patch and want to turn it into a permanent "
16585 "changeset, use the <command role=\"hg-ext-mq\">hg qfinish</command> command. "
16586 "Pass a revision to the command to identify the patch that you want to turn "
16587 "into a regular changeset; this patch must already be applied."
16588 msgstr ""
16590 #. type: Content of: <book><chapter><sect1><sect2><para>
16591 #: ../en/ch12-mq.xml:777
16592 msgid ""
16593 "The <command role=\"hg-ext-mq\">hg qfinish</command> command accepts an "
16594 "<option>--all</option> or <option>-a</option> option, which turns all applied "
16595 "patches into regular changesets."
16596 msgstr ""
16598 #. type: Content of: <book><chapter><sect1><sect2><para>
16599 #: ../en/ch12-mq.xml:782
16600 msgid ""
16601 "It is also possible to turn an existing changeset into a patch, by passing "
16602 "the <option>-r</option> option to <command role=\"hg-ext-mq\">hg qimport</"
16603 "command>."
16604 msgstr ""
16606 #. type: Content of: <book><chapter><sect1><sect2><para>
16607 #: ../en/ch12-mq.xml:788
16608 msgid ""
16609 "Note that it only makes sense to convert a changeset into a patch if you have "
16610 "not propagated that changeset into any other repositories. The imported "
16611 "changeset's ID will change every time you refresh the patch, which will make "
16612 "Mercurial treat it as unrelated to the original changeset if you have pushed "
16613 "it somewhere else."
16614 msgstr ""
16616 #. type: Content of: <book><chapter><sect1><title>
16617 #: ../en/ch12-mq.xml:798
16618 msgid "Getting the best performance out of MQ"
16619 msgstr "MQ 的性能"
16621 #. type: Content of: <book><chapter><sect1><para>
16622 #: ../en/ch12-mq.xml:800
16623 msgid ""
16624 "MQ is very efficient at handling a large number of patches. I ran some "
16625 "performance experiments in mid-2006 for a talk that I gave at the 2006 "
16626 "EuroPython conference (on modern hardware, you should expect better "
16627 "performance than you'll see below). I used as my data set the Linux 2.6.17-"
16628 "mm1 patch series, which consists of 1,738 patches. I applied these on top of "
16629 "a Linux kernel repository containing all 27,472 revisions between Linux "
16630 "2.6.12-rc2 and Linux 2.6.17."
16631 msgstr ""
16633 #. type: Content of: <book><chapter><sect1><para>
16634 #: ../en/ch12-mq.xml:809
16635 msgid ""
16636 "On my old, slow laptop, I was able to <command role=\"hg-cmd\">hg qpush "
16637 "<option role=\"hg-ext-mq-cmd-qpush-opt\">-a</option></command> all 1,738 "
16638 "patches in 3.5 minutes, and <command role=\"hg-cmd\">hg qpop <option role="
16639 "\"hg-ext-mq-cmd-qpop-opt\">-a</option></command> them all in 30 seconds. (On "
16640 "a newer laptop, the time to push all patches dropped to two minutes.) I "
16641 "could <command role=\"hg-ext-mq\">qrefresh</command> one of the biggest "
16642 "patches (which made 22,779 lines of changes to 287 files) in 6.6 seconds."
16643 msgstr ""
16645 #. type: Content of: <book><chapter><sect1><para>
16646 #: ../en/ch12-mq.xml:820
16647 msgid ""
16648 "Clearly, MQ is well suited to working in large trees, but there are a few "
16649 "tricks you can use to get the best performance of it."
16650 msgstr ""
16652 #. type: Content of: <book><chapter><sect1><para>
16653 #: ../en/ch12-mq.xml:824
16654 msgid ""
16655 "First of all, try to <quote>batch</quote> operations together. Every time "
16656 "you run <command role=\"hg-ext-mq\">qpush</command> or <command role=\"hg-ext-"
16657 "mq\">qpop</command>, these commands scan the working directory once to make "
16658 "sure you haven't made some changes and then forgotten to run <command role="
16659 "\"hg-ext-mq\">qrefresh</command>. On a small tree, the time that this scan "
16660 "takes is unnoticeable. However, on a medium-sized tree (containing tens of "
16661 "thousands of files), it can take a second or more."
16662 msgstr ""
16664 #. type: Content of: <book><chapter><sect1><para>
16665 #: ../en/ch12-mq.xml:835
16666 msgid ""
16667 "The <command role=\"hg-ext-mq\">qpush</command> and <command role=\"hg-ext-mq"
16668 "\">qpop</command> commands allow you to push and pop multiple patches at a "
16669 "time. You can identify the <quote>destination patch</quote> that you want to "
16670 "end up at. When you <command role=\"hg-ext-mq\">qpush</command> with a "
16671 "destination specified, it will push patches until that patch is at the top of "
16672 "the applied stack. When you <command role=\"hg-ext-mq\">qpop</command> to a "
16673 "destination, MQ will pop patches until the destination patch is at the top."
16674 msgstr ""
16676 #. type: Content of: <book><chapter><sect1><para>
16677 #: ../en/ch12-mq.xml:845
16678 msgid ""
16679 "You can identify a destination patch using either the name of the patch, or "
16680 "by number. If you use numeric addressing, patches are counted from zero; "
16681 "this means that the first patch is zero, the second is one, and so on."
16682 msgstr ""
16684 #. type: Content of: <book><chapter><sect1><title>
16685 #: ../en/ch12-mq.xml:852
16686 msgid "Updating your patches when the underlying code changes"
16687 msgstr "当基础代码改变时,更新补丁的方法"
16689 #. type: Content of: <book><chapter><sect1><para>
16690 #: ../en/ch12-mq.xml:855
16691 msgid ""
16692 "It's common to have a stack of patches on top of an underlying repository "
16693 "that you don't modify directly. If you're working on changes to third-party "
16694 "code, or on a feature that is taking longer to develop than the rate of "
16695 "change of the code beneath, you will often need to sync up with the "
16696 "underlying code, and fix up any hunks in your patches that no longer apply. "
16697 "This is called <emphasis>rebasing</emphasis> your patch series."
16698 msgstr ""
16700 #. type: Content of: <book><chapter><sect1><para>
16701 #: ../en/ch12-mq.xml:864
16702 msgid ""
16703 "The simplest way to do this is to <command role=\"hg-cmd\">hg qpop <option "
16704 "role=\"hg-ext-mq-cmd-qpop-opt\">hg -a</option></command> your patches, then "
16705 "<command role=\"hg-cmd\">hg pull</command> changes into the underlying "
16706 "repository, and finally <command role=\"hg-cmd\">hg qpush <option role=\"hg-"
16707 "ext-mq-cmd-qpop-opt\">-a</option></command> your patches again. MQ will stop "
16708 "pushing any time it runs across a patch that fails to apply during conflicts, "
16709 "allowing you to fix your conflicts, <command role=\"hg-ext-mq\">qrefresh</"
16710 "command> the affected patch, and continue pushing until you have fixed your "
16711 "entire stack."
16712 msgstr ""
16714 #. type: Content of: <book><chapter><sect1><para>
16715 #: ../en/ch12-mq.xml:876
16716 msgid ""
16717 "This approach is easy to use and works well if you don't expect changes to "
16718 "the underlying code to affect how well your patches apply. If your patch "
16719 "stack touches code that is modified frequently or invasively in the "
16720 "underlying repository, however, fixing up rejected hunks by hand quickly "
16721 "becomes tiresome."
16722 msgstr ""
16724 #. type: Content of: <book><chapter><sect1><para>
16725 #: ../en/ch12-mq.xml:883
16726 msgid ""
16727 "It's possible to partially automate the rebasing process. If your patches "
16728 "apply cleanly against some revision of the underlying repo, MQ can use this "
16729 "information to help you to resolve conflicts between your patches and a "
16730 "different revision."
16731 msgstr ""
16733 #. type: Content of: <book><chapter><sect1><para>
16734 #: ../en/ch12-mq.xml:889
16735 msgid "The process is a little involved."
16736 msgstr ""
16738 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
16739 #: ../en/ch12-mq.xml:891
16740 msgid ""
16741 "To begin, <command role=\"hg-cmd\">hg qpush -a</command> all of your patches "
16742 "on top of the revision where you know that they apply cleanly."
16743 msgstr ""
16745 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
16746 #: ../en/ch12-mq.xml:895
16747 msgid ""
16748 "Save a backup copy of your patch directory using <command role=\"hg-cmd\">hg "
16749 "qsave <option role=\"hg-ext-mq-cmd-qsave-opt\">hg -e</option> <option role="
16750 "\"hg-ext-mq-cmd-qsave-opt\">hg -c</option></command>. This prints the name "
16751 "of the directory that it has saved the patches in. It will save the patches "
16752 "to a directory called <filename role=\"special\" class=\"directory\">.hg/"
16753 "patches.N</filename>, where <literal>N</literal> is a small integer. It also "
16754 "commits a <quote>save changeset</quote> on top of your applied patches; this "
16755 "is for internal book-keeping, and records the states of the <filename role="
16756 "\"special\">series</filename> and <filename role=\"special\">status</"
16757 "filename> files."
16758 msgstr ""
16760 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
16761 #: ../en/ch12-mq.xml:909
16762 msgid ""
16763 "Use <command role=\"hg-cmd\">hg pull</command> to bring new changes into the "
16764 "underlying repository. (Don't run <command role=\"hg-cmd\">hg pull -u</"
16765 "command>; see below for why.)"
16766 msgstr ""
16768 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
16769 #: ../en/ch12-mq.xml:914
16770 msgid ""
16771 "Update to the new tip revision, using <command role=\"hg-cmd\">hg update "
16772 "<option role=\"hg-opt-update\">-C</option></command> to override the patches "
16773 "you have pushed."
16774 msgstr ""
16776 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
16777 #: ../en/ch12-mq.xml:919
16778 msgid ""
16779 "Merge all patches using <command>hg qpush -m -a</command>. The <option role="
16780 "\"hg-ext-mq-cmd-qpush-opt\">-m</option> option to <command role=\"hg-ext-mq"
16781 "\">qpush</command> tells MQ to perform a three-way merge if the patch fails "
16782 "to apply."
16783 msgstr ""
16785 #. type: Content of: <book><chapter><sect1><para>
16786 #: ../en/ch12-mq.xml:927
16787 msgid ""
16788 "During the <command role=\"hg-cmd\">hg qpush <option role=\"hg-ext-mq-cmd-"
16789 "qpush-opt\">hg -m</option></command>, each patch in the <filename role="
16790 "\"special\">series</filename> file is applied normally. If a patch applies "
16791 "with fuzz or rejects, MQ looks at the queue you <command role=\"hg-ext-mq"
16792 "\">qsave</command>d, and performs a three-way merge with the corresponding "
16793 "changeset. This merge uses Mercurial's normal merge machinery, so it may pop "
16794 "up a GUI merge tool to help you to resolve problems."
16795 msgstr ""
16797 #. type: Content of: <book><chapter><sect1><para>
16798 #: ../en/ch12-mq.xml:937
16799 msgid ""
16800 "When you finish resolving the effects of a patch, MQ refreshes your patch "
16801 "based on the result of the merge."
16802 msgstr ""
16804 #. type: Content of: <book><chapter><sect1><para>
16805 #: ../en/ch12-mq.xml:940
16806 msgid ""
16807 "At the end of this process, your repository will have one extra head from the "
16808 "old patch queue, and a copy of the old patch queue will be in <filename role="
16809 "\"special\" class=\"directory\">.hg/patches.N</filename>. You can remove the "
16810 "extra head using <command role=\"hg-cmd\">hg qpop -a -n patches.N</command> "
16811 "or <command role=\"hg-cmd\">hg strip</command>. You can delete <filename "
16812 "role=\"special\" class=\"directory\">.hg/patches.N</filename> once you are "
16813 "sure that you no longer need it as a backup."
16814 msgstr ""
16816 #. type: Content of: <book><chapter><sect1><title>
16817 #: ../en/ch12-mq.xml:952
16818 msgid "Identifying patches"
16819 msgstr "标识补丁"
16821 #. type: Content of: <book><chapter><sect1><para>
16822 #: ../en/ch12-mq.xml:954
16823 msgid ""
16824 "MQ commands that work with patches let you refer to a patch either by using "
16825 "its name or by a number. By name is obvious enough; pass the name "
16826 "<filename>foo.patch</filename> to <command role=\"hg-ext-mq\">qpush</"
16827 "command>, for example, and it will push patches until <filename>foo.patch</"
16828 "filename> is applied."
16829 msgstr ""
16831 #. type: Content of: <book><chapter><sect1><para>
16832 #: ../en/ch12-mq.xml:961
16833 msgid ""
16834 "As a shortcut, you can refer to a patch using both a name and a numeric "
16835 "offset; <literal>foo.patch-2</literal> means <quote>two patches before "
16836 "<literal>foo.patch</literal></quote>, while <literal>bar.patch+4</literal> "
16837 "means <quote>four patches after <literal>bar.patch</literal></quote>."
16838 msgstr ""
16840 #. type: Content of: <book><chapter><sect1><para>
16841 #: ../en/ch12-mq.xml:967
16842 msgid ""
16843 "Referring to a patch by index isn't much different. The first patch printed "
16844 "in the output of <command role=\"hg-ext-mq\">qseries</command> is patch zero "
16845 "(yes, it's one of those start-at-zero counting systems); the second is patch "
16846 "one; and so on."
16847 msgstr ""
16849 #. type: Content of: <book><chapter><sect1><para>
16850 #: ../en/ch12-mq.xml:973
16851 msgid ""
16852 "MQ also makes it easy to work with patches when you are using normal "
16853 "Mercurial commands. Every command that accepts a changeset ID will also "
16854 "accept the name of an applied patch. MQ augments the tags normally in the "
16855 "repository with an eponymous one for each applied patch. In addition, the "
16856 "special tags <literal role=\"tag\">qbase</literal> and <literal role=\"tag"
16857 "\">qtip</literal> identify the <quote>bottom-most</quote> and topmost applied "
16858 "patches, respectively."
16859 msgstr ""
16861 #. type: Content of: <book><chapter><sect1><para>
16862 #: ../en/ch12-mq.xml:983
16863 msgid ""
16864 "These additions to Mercurial's normal tagging capabilities make dealing with "
16865 "patches even more of a breeze."
16866 msgstr ""
16868 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
16869 #: ../en/ch12-mq.xml:986
16870 msgid "Want to patchbomb a mailing list with your latest series of changes?"
16871 msgstr ""
16873 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
16874 #: ../en/ch12-mq.xml:989
16875 msgid ""
16876 "(Don't know what <quote>patchbombing</quote> is? See <xref linkend=\"sec:"
16877 "hgext:patchbomb\"/>.)"
16878 msgstr ""
16880 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
16881 #: ../en/ch12-mq.xml:992
16882 msgid ""
16883 "Need to see all of the patches since <literal>foo.patch</literal> that have "
16884 "touched files in a subdirectory of your tree?"
16885 msgstr ""
16887 #. type: Content of: <book><chapter><sect1><para>
16888 #: ../en/ch12-mq.xml:999
16889 msgid ""
16890 "Because MQ makes the names of patches available to the rest of Mercurial "
16891 "through its normal internal tag machinery, you don't need to type in the "
16892 "entire name of a patch when you want to identify it by name."
16893 msgstr ""
16895 #. type: Content of: <book><chapter><sect1><para>
16896 #: ../en/ch12-mq.xml:1004
16897 msgid ""
16898 "Another nice consequence of representing patch names as tags is that when you "
16899 "run the <command role=\"hg-cmd\">hg log</command> command, it will display a "
16900 "patch's name as a tag, simply as part of its normal output. This makes it "
16901 "easy to visually distinguish applied patches from underlying <quote>normal</"
16902 "quote> revisions. The following example shows a few normal Mercurial "
16903 "commands in use with applied patches."
16904 msgstr ""
16906 #. type: Content of: <book><chapter><sect1><title>
16907 #: ../en/ch12-mq.xml:1017
16908 msgid "Useful things to know about"
16909 msgstr "其它需要了解的东西"
16911 #. type: Content of: <book><chapter><sect1><para>
16912 #: ../en/ch12-mq.xml:1019
16913 msgid ""
16914 "There are a number of aspects of MQ usage that don't fit tidily into sections "
16915 "of their own, but that are good to know. Here they are, in one place."
16916 msgstr ""
16918 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
16919 #: ../en/ch12-mq.xml:1024
16920 msgid ""
16921 "Normally, when you <command role=\"hg-ext-mq\">qpop</command> a patch and "
16922 "<command role=\"hg-ext-mq\">qpush</command> it again, the changeset that "
16923 "represents the patch after the pop/push will have a <emphasis>different "
16924 "identity</emphasis> than the changeset that represented the hash beforehand. "
16925 "See <xref linkend=\"sec:mqref:cmd:qpush\"/> for information as to why this is."
16926 msgstr ""
16928 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
16929 #: ../en/ch12-mq.xml:1033
16930 msgid ""
16931 "It's not a good idea to <command role=\"hg-cmd\">hg merge</command> changes "
16932 "from another branch with a patch changeset, at least if you want to maintain "
16933 "the <quote>patchiness</quote> of that changeset and changesets below it on "
16934 "the patch stack. If you try to do this, it will appear to succeed, but MQ "
16935 "will become confused."
16936 msgstr ""
16938 #. type: Content of: <book><chapter><sect1><title>
16939 #: ../en/ch12-mq.xml:1044
16940 msgid "Managing patches in a repository"
16941 msgstr "在版本库管理补丁"
16943 #. type: Content of: <book><chapter><sect1><para>
16944 #: ../en/ch12-mq.xml:1046
16945 msgid ""
16946 "Because MQ's <filename role=\"special\" class=\"directory\">.hg/patches</"
16947 "filename> directory resides outside a Mercurial repository's working "
16948 "directory, the <quote>underlying</quote> Mercurial repository knows nothing "
16949 "about the management or presence of patches."
16950 msgstr ""
16952 #. type: Content of: <book><chapter><sect1><para>
16953 #: ../en/ch12-mq.xml:1052
16954 msgid ""
16955 "This presents the interesting possibility of managing the contents of the "
16956 "patch directory as a Mercurial repository in its own right. This can be a "
16957 "useful way to work. For example, you can work on a patch for a while, "
16958 "<command role=\"hg-ext-mq\">qrefresh</command> it, then <command role=\"hg-cmd"
16959 "\">hg commit</command> the current state of the patch. This lets you "
16960 "<quote>roll back</quote> to that version of the patch later on."
16961 msgstr ""
16963 #. type: Content of: <book><chapter><sect1><para>
16964 #: ../en/ch12-mq.xml:1061
16965 msgid ""
16966 "You can then share different versions of the same patch stack among multiple "
16967 "underlying repositories. I use this when I am developing a Linux kernel "
16968 "feature. I have a pristine copy of my kernel sources for each of several CPU "
16969 "architectures, and a cloned repository under each that contains the patches I "
16970 "am working on. When I want to test a change on a different architecture, I "
16971 "push my current patches to the patch repository associated with that kernel "
16972 "tree, pop and push all of my patches, and build and test that kernel."
16973 msgstr ""
16975 #. type: Content of: <book><chapter><sect1><para>
16976 #: ../en/ch12-mq.xml:1071
16977 msgid ""
16978 "Managing patches in a repository makes it possible for multiple developers to "
16979 "work on the same patch series without colliding with each other, all on top "
16980 "of an underlying source base that they may or may not control."
16981 msgstr ""
16983 #. type: Content of: <book><chapter><sect1><sect2><title>
16984 #: ../en/ch12-mq.xml:1077
16985 msgid "MQ support for patch repositories"
16986 msgstr "MQ 支持补丁版本库"
16988 #. type: Content of: <book><chapter><sect1><sect2><para>
16989 #: ../en/ch12-mq.xml:1079
16990 msgid ""
16991 "MQ helps you to work with the <filename role=\"special\" class=\"directory\">."
16992 "hg/patches</filename> directory as a repository; when you prepare a "
16993 "repository for working with patches using <command role=\"hg-ext-mq\">qinit</"
16994 "command>, you can pass the <option role=\"hg-ext-mq-cmd-qinit-opt\">hg -c</"
16995 "option> option to create the <filename role=\"special\" class=\"directory\">."
16996 "hg/patches</filename> directory as a Mercurial repository."
16997 msgstr ""
16999 #. type: Content of: <book><chapter><sect1><sect2><note><para>
17000 #: ../en/ch12-mq.xml:1089
17001 msgid ""
17002 "If you forget to use the <option role=\"hg-ext-mq-cmd-qinit-opt\">hg -c</"
17003 "option> option, you can simply go into the <filename role=\"special\" class="
17004 "\"directory\">.hg/patches</filename> directory at any time and run <command "
17005 "role=\"hg-cmd\">hg init</command>. Don't forget to add an entry for the "
17006 "<filename role=\"special\">status</filename> file to the <filename role="
17007 "\"special\">.hgignore</filename> file, though"
17008 msgstr ""
17010 #. type: Content of: <book><chapter><sect1><sect2><note><para>
17011 #: ../en/ch12-mq.xml:1098
17012 msgid ""
17013 "(<command role=\"hg-cmd\">hg qinit <option role=\"hg-ext-mq-cmd-qinit-opt"
17014 "\">hg -c</option></command> does this for you automatically); you "
17015 "<emphasis>really</emphasis> don't want to manage the <filename role=\"special"
17016 "\">status</filename> file."
17017 msgstr ""
17019 #. type: Content of: <book><chapter><sect1><sect2><para>
17020 #: ../en/ch12-mq.xml:1105
17021 msgid ""
17022 "As a convenience, if MQ notices that the <filename class=\"directory\">.hg/"
17023 "patches</filename> directory is a repository, it will automatically <command "
17024 "role=\"hg-cmd\">hg add</command> every patch that you create and import."
17025 msgstr ""
17027 #. type: Content of: <book><chapter><sect1><sect2><para>
17028 #: ../en/ch12-mq.xml:1110
17029 msgid ""
17030 "MQ provides a shortcut command, <command role=\"hg-ext-mq\">qcommit</"
17031 "command>, that runs <command role=\"hg-cmd\">hg commit</command> in the "
17032 "<filename role=\"special\" class=\"directory\">.hg/patches</filename> "
17033 "directory. This saves some bothersome typing."
17034 msgstr ""
17036 #. type: Content of: <book><chapter><sect1><sect2><para>
17037 #: ../en/ch12-mq.xml:1116
17038 msgid ""
17039 "Finally, as a convenience to manage the patch directory, you can define the "
17040 "alias <command>mq</command> on Unix systems. For example, on Linux systems "
17041 "using the <command>bash</command> shell, you can include the following "
17042 "snippet in your <filename role=\"home\">~/.bashrc</filename>."
17043 msgstr ""
17045 #. type: Content of: <book><chapter><sect1><sect2><para>
17046 #: ../en/ch12-mq.xml:1125
17047 msgid ""
17048 "You can then issue commands of the form <command>mq pull</command> from the "
17049 "main repository."
17050 msgstr ""
17052 #. type: Content of: <book><chapter><sect1><sect2><title>
17053 #: ../en/ch12-mq.xml:1130
17054 msgid "A few things to watch out for"
17055 msgstr "需要注意的事情"
17057 #. type: Content of: <book><chapter><sect1><sect2><para>
17058 #: ../en/ch12-mq.xml:1132
17059 msgid ""
17060 "MQ's support for working with a repository full of patches is limited in a "
17061 "few small respects."
17062 msgstr ""
17064 #. type: Content of: <book><chapter><sect1><sect2><para>
17065 #: ../en/ch12-mq.xml:1135
17066 msgid ""
17067 "MQ cannot automatically detect changes that you make to the patch directory. "
17068 "If you <command role=\"hg-cmd\">hg pull</command>, manually edit, or <command "
17069 "role=\"hg-cmd\">hg update</command> changes to patches or the <filename role="
17070 "\"special\">series</filename> file, you will have to <command role=\"hg-cmd"
17071 "\">hg qpop <option role=\"hg-ext-mq-cmd-qpop-opt\">-a</option></command> and "
17072 "then <command role=\"hg-cmd\">hg qpush <option role=\"hg-ext-mq-cmd-qpush-opt"
17073 "\">-a</option></command> in the underlying repository to see those changes "
17074 "show up there. If you forget to do this, you can confuse MQ's idea of which "
17075 "patches are applied."
17076 msgstr ""
17078 #. type: Content of: <book><chapter><sect1><title>
17079 #: ../en/ch12-mq.xml:1151
17080 msgid "Third party tools for working with patches"
17081 msgstr "操作补丁的第三方工具"
17083 #. type: Content of: <book><chapter><sect1><para>
17084 #: ../en/ch12-mq.xml:1153
17085 msgid ""
17086 "Once you've been working with patches for a while, you'll find yourself "
17087 "hungry for tools that will help you to understand and manipulate the patches "
17088 "you're dealing with."
17089 msgstr ""
17091 #. type: Content of: <book><chapter><sect1><para>
17092 #: ../en/ch12-mq.xml:1157
17093 msgid ""
17094 "The <command>diffstat</command> command <citation>web:diffstat</citation> "
17095 "generates a histogram of the modifications made to each file in a patch. It "
17096 "provides a good way to <quote>get a sense of</quote> a patch&emdash;which "
17097 "files it affects, and how much change it introduces to each file and as a "
17098 "whole. (I find that it's a good idea to use <command>diffstat</command>'s "
17099 "<option role=\"cmd-opt-diffstat\">-p</option> option as a matter of course, "
17100 "as otherwise it will try to do clever things with prefixes of file names that "
17101 "inevitably confuse at least me.)"
17102 msgstr ""
17104 #. type: Content of: <book><chapter><sect1><para>
17105 #: ../en/ch12-mq.xml:1171
17106 msgid ""
17107 "The <literal role=\"package\">patchutils</literal> package <citation>web:"
17108 "patchutils</citation> is invaluable. It provides a set of small utilities "
17109 "that follow the <quote>Unix philosophy;</quote> each does one useful thing "
17110 "with a patch. The <literal role=\"package\">patchutils</literal> command I "
17111 "use most is <command>filterdiff</command>, which extracts subsets from a "
17112 "patch file. For example, given a patch that modifies hundreds of files "
17113 "across dozens of directories, a single invocation of <command>filterdiff</"
17114 "command> can generate a smaller patch that only touches files whose names "
17115 "match a particular glob pattern. See <xref linkend=\"mq-collab:tips:interdiff"
17116 "\"/> for another example."
17117 msgstr ""
17119 #. type: Content of: <book><chapter><sect1><title>
17120 #: ../en/ch12-mq.xml:1187
17121 msgid "Good ways to work with patches"
17122 msgstr "操作补丁的好习惯"
17124 #. type: Content of: <book><chapter><sect1><para>
17125 #: ../en/ch12-mq.xml:1189
17126 msgid ""
17127 "Whether you are working on a patch series to submit to a free software or "
17128 "open source project, or a series that you intend to treat as a sequence of "
17129 "regular changesets when you're done, you can use some simple techniques to "
17130 "keep your work well organized."
17131 msgstr ""
17133 #. type: Content of: <book><chapter><sect1><para>
17134 #: ../en/ch12-mq.xml:1195
17135 msgid ""
17136 "Give your patches descriptive names. A good name for a patch might be "
17137 "<filename>rework-device-alloc.patch</filename>, because it will immediately "
17138 "give you a hint what the purpose of the patch is. Long names shouldn't be a "
17139 "problem; you won't be typing the names often, but you <emphasis>will</"
17140 "emphasis> be running commands like <command role=\"hg-ext-mq\">qapplied</"
17141 "command> and <command role=\"hg-ext-mq\">qtop</command> over and over. Good "
17142 "naming becomes especially important when you have a number of patches to work "
17143 "with, or if you are juggling a number of different tasks and your patches "
17144 "only get a fraction of your attention."
17145 msgstr ""
17147 #. type: Content of: <book><chapter><sect1><para>
17148 #: ../en/ch12-mq.xml:1207
17149 msgid ""
17150 "Be aware of what patch you're working on. Use the <command role=\"hg-ext-mq"
17151 "\">qtop</command> command and skim over the text of your patches "
17152 "frequently&emdash;for example, using <command role=\"hg-cmd\">hg tip <option "
17153 "role=\"hg-opt-tip\">-p</option></command>)&emdash;to be sure of where you "
17154 "stand. I have several times worked on and <command role=\"hg-ext-mq"
17155 "\">qrefresh</command>ed a patch other than the one I intended, and it's often "
17156 "tricky to migrate changes into the right patch after making them in the wrong "
17157 "one."
17158 msgstr ""
17160 #. type: Content of: <book><chapter><sect1><para>
17161 #: ../en/ch12-mq.xml:1217
17162 msgid ""
17163 "For this reason, it is very much worth investing a little time to learn how "
17164 "to use some of the third-party tools I described in <xref linkend=\"sec:mq:"
17165 "tools\"/>, particularly <command>diffstat</command> and <command>filterdiff</"
17166 "command>. The former will give you a quick idea of what changes your patch "
17167 "is making, while the latter makes it easy to splice hunks selectively out of "
17168 "one patch and into another."
17169 msgstr ""
17171 #. type: Content of: <book><chapter><sect1><title>
17172 #: ../en/ch12-mq.xml:1228
17173 msgid "MQ cookbook"
17174 msgstr "MQ 手册"
17176 #. type: Content of: <book><chapter><sect1><sect2><title>
17177 #: ../en/ch12-mq.xml:1231
17178 msgid "Manage <quote>trivial</quote> patches"
17179 msgstr "管理<quote>琐碎的</quote>补丁"
17181 #. type: Content of: <book><chapter><sect1><sect2><para>
17182 #: ../en/ch12-mq.xml:1233
17183 msgid ""
17184 "Because the overhead of dropping files into a new Mercurial repository is so "
17185 "low, it makes a lot of sense to manage patches this way even if you simply "
17186 "want to make a few changes to a source tarball that you downloaded."
17187 msgstr ""
17190 #. type: Content of: <book><chapter><sect1><sect2><para>
17191 #: ../en/ch12-mq.xml:1238
17192 msgid ""
17193 "Begin by downloading and unpacking the source tarball, and turning it into a "
17194 "Mercurial repository."
17195 msgstr ""
17197 #. type: Content of: <book><chapter><sect1><sect2><para>
17198 #: ../en/ch12-mq.xml:1243
17199 msgid "Continue by creating a patch stack and making your changes."
17200 msgstr ""
17202 #. type: Content of: <book><chapter><sect1><sect2><para>
17203 #: ../en/ch12-mq.xml:1248
17204 msgid ""
17205 "Let's say a few weeks or months pass, and your package author releases a new "
17206 "version. First, bring their changes into the repository."
17207 msgstr ""
17209 #. type: Content of: <book><chapter><sect1><sect2><para>
17210 #: ../en/ch12-mq.xml:1254
17211 msgid ""
17212 "The pipeline starting with <command role=\"hg-cmd\">hg locate</command> above "
17213 "deletes all files in the working directory, so that <command role=\"hg-cmd"
17214 "\">hg commit</command>'s <option role=\"hg-opt-commit\">--addremove</option> "
17215 "option can actually tell which files have really been removed in the newer "
17216 "version of the source."
17217 msgstr ""
17219 #. type: Content of: <book><chapter><sect1><sect2><para>
17220 #: ../en/ch12-mq.xml:1262
17221 msgid "Finally, you can apply your patches on top of the new tree."
17222 msgstr ""
17224 #. type: Content of: <book><chapter><sect1><sect2><title>
17225 #: ../en/ch12-mq.xml:1269
17226 msgid "Combining entire patches"
17227 msgstr "组合全部的补丁"
17229 #. type: Content of: <book><chapter><sect1><sect2><para>
17230 #: ../en/ch12-mq.xml:1271
17231 msgid ""
17232 "MQ provides a command, <command role=\"hg-ext-mq\">qfold</command> that lets "
17233 "you combine entire patches. This <quote>folds</quote> the patches you name, "
17234 "in the order you name them, into the topmost applied patch, and concatenates "
17235 "their descriptions onto the end of its description. The patches that you "
17236 "fold must be unapplied before you fold them."
17237 msgstr ""
17239 #. type: Content of: <book><chapter><sect1><sect2><para>
17240 #: ../en/ch12-mq.xml:1279
17241 msgid ""
17242 "The order in which you fold patches matters. If your topmost applied patch "
17243 "is <literal>foo</literal>, and you <command role=\"hg-ext-mq\">qfold</"
17244 "command> <literal>bar</literal> and <literal>quux</literal> into it, you will "
17245 "end up with a patch that has the same effect as if you applied first "
17246 "<literal>foo</literal>, then <literal>bar</literal>, followed by "
17247 "<literal>quux</literal>."
17248 msgstr ""
17250 #. type: Content of: <book><chapter><sect1><sect2><title>
17251 #: ../en/ch12-mq.xml:1290
17252 msgid "Merging part of one patch into another"
17253 msgstr "合并补丁的部分内容到其它补丁"
17255 #. type: Content of: <book><chapter><sect1><sect2><para>
17256 #: ../en/ch12-mq.xml:1292
17257 msgid ""
17258 "Merging <emphasis>part</emphasis> of one patch into another is more difficult "
17259 "than combining entire patches."
17260 msgstr ""
17262 #. type: Content of: <book><chapter><sect1><sect2><para>
17263 #: ../en/ch12-mq.xml:1296
17264 msgid ""
17265 "If you want to move changes to entire files, you can use <command>filterdiff</"
17266 "command>'s <option role=\"cmd-opt-filterdiff\">-i</option> and <option role="
17267 "\"cmd-opt-filterdiff\">-x</option> options to choose the modifications to "
17268 "snip out of one patch, concatenating its output onto the end of the patch you "
17269 "want to merge into. You usually won't need to modify the patch you've merged "
17270 "the changes from. Instead, MQ will report some rejected hunks when you "
17271 "<command role=\"hg-ext-mq\">qpush</command> it (from the hunks you moved into "
17272 "the other patch), and you can simply <command role=\"hg-ext-mq\">qrefresh</"
17273 "command> the patch to drop the duplicate hunks."
17274 msgstr ""
17276 #. type: Content of: <book><chapter><sect1><sect2><para>
17277 #: ../en/ch12-mq.xml:1309
17278 msgid ""
17279 "If you have a patch that has multiple hunks modifying a file, and you only "
17280 "want to move a few of those hunks, the job becomes more messy, but you can "
17281 "still partly automate it. Use <command>lsdiff -nvv</command> to print some "
17282 "metadata about the patch."
17283 msgstr ""
17285 #. type: Content of: <book><chapter><sect1><sect2><para>
17286 #: ../en/ch12-mq.xml:1317
17287 msgid "This command prints three different kinds of number:"
17288 msgstr ""
17290 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
17291 #: ../en/ch12-mq.xml:1320
17292 msgid ""
17293 "(in the first column) a <emphasis>file number</emphasis> to identify each "
17294 "file modified in the patch;"
17295 msgstr ""
17297 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
17298 #: ../en/ch12-mq.xml:1324
17299 msgid ""
17300 "(on the next line, indented) the line number within a modified file where a "
17301 "hunk starts; and"
17302 msgstr ""
17304 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
17305 #: ../en/ch12-mq.xml:1327
17306 msgid ""
17307 "(on the same line) a <emphasis>hunk number</emphasis> to identify that hunk."
17308 msgstr ""
17310 #. type: Content of: <book><chapter><sect1><sect2><para>
17311 #: ../en/ch12-mq.xml:1331
17312 msgid ""
17313 "You'll have to use some visual inspection, and reading of the patch, to "
17314 "identify the file and hunk numbers you'll want, but you can then pass them to "
17315 "to <command>filterdiff</command>'s <option role=\"cmd-opt-filterdiff\">--"
17316 "files</option> and <option role=\"cmd-opt-filterdiff\">--hunks</option> "
17317 "options, to select exactly the file and hunk you want to extract."
17318 msgstr ""
17320 #. type: Content of: <book><chapter><sect1><sect2><para>
17321 #: ../en/ch12-mq.xml:1339
17322 msgid ""
17323 "Once you have this hunk, you can concatenate it onto the end of your "
17324 "destination patch and continue with the remainder of <xref linkend=\"sec:mq:"
17325 "combine\"/>."
17326 msgstr ""
17328 #. type: Content of: <book><chapter><sect1><title>
17329 #: ../en/ch12-mq.xml:1346
17330 msgid "Differences between quilt and MQ"
17331 msgstr "MQ 与 quilt 的区别"
17333 #. type: Content of: <book><chapter><sect1><para>
17334 #: ../en/ch12-mq.xml:1348
17335 msgid ""
17336 "If you are already familiar with quilt, MQ provides a similar command set. "
17337 "There are a few differences in the way that it works."
17338 msgstr ""
17340 #. type: Content of: <book><chapter><sect1><para>
17341 #: ../en/ch12-mq.xml:1352
17342 msgid ""
17343 "You will already have noticed that most quilt commands have MQ counterparts "
17344 "that simply begin with a <quote><literal>q</literal></quote>. The exceptions "
17345 "are quilt's <literal>add</literal> and <literal>remove</literal> commands, "
17346 "the counterparts for which are the normal Mercurial <command role=\"hg-cmd"
17347 "\">hg add</command> and <command role=\"hg-cmd\">hg remove</command> "
17348 "commands. There is no MQ equivalent of the quilt <literal>edit</literal> "
17349 "command."
17350 msgstr ""
17352 #. type: Content of: <book><chapter><title>
17353 #: ../en/ch13-mq-collab.xml:5
17354 msgid "Advanced uses of Mercurial Queues"
17355 msgstr "MQ 的高级用法"
17357 #. type: Content of: <book><chapter><para>
17358 #: ../en/ch13-mq-collab.xml:7
17359 msgid ""
17360 "While it's easy to pick up straightforward uses of Mercurial Queues, use of a "
17361 "little discipline and some of MQ's less frequently used capabilities makes it "
17362 "possible to work in complicated development environments."
17363 msgstr ""
17365 #. type: Content of: <book><chapter><para>
17366 #: ../en/ch13-mq-collab.xml:12
17367 msgid ""
17368 "In this chapter, I will use as an example a technique I have used to manage "
17369 "the development of an Infiniband device driver for the Linux kernel. The "
17370 "driver in question is large (at least as drivers go), with 25,000 lines of "
17371 "code spread across 35 source files. It is maintained by a small team of "
17372 "developers."
17373 msgstr ""
17375 #. type: Content of: <book><chapter><para>
17376 #: ../en/ch13-mq-collab.xml:18
17377 msgid ""
17378 "While much of the material in this chapter is specific to Linux, the same "
17379 "principles apply to any code base for which you're not the primary owner, and "
17380 "upon which you need to do a lot of development."
17381 msgstr ""
17383 #. type: Content of: <book><chapter><sect1><title>
17384 #: ../en/ch13-mq-collab.xml:24
17385 msgid "The problem of many targets"
17386 msgstr "多个目标的问题"
17388 #. type: Content of: <book><chapter><sect1><para>
17389 #: ../en/ch13-mq-collab.xml:26
17390 msgid ""
17391 "The Linux kernel changes rapidly, and has never been internally stable; "
17392 "developers frequently make drastic changes between releases. This means that "
17393 "a version of the driver that works well with a particular released version of "
17394 "the kernel will not even <emphasis>compile</emphasis> correctly against, "
17395 "typically, any other version."
17396 msgstr ""
17398 #. type: Content of: <book><chapter><sect1><para>
17399 #: ../en/ch13-mq-collab.xml:33
17400 msgid ""
17401 "To maintain a driver, we have to keep a number of distinct versions of Linux "
17402 "in mind."
17403 msgstr ""
17405 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17406 #: ../en/ch13-mq-collab.xml:36
17407 msgid ""
17408 "One target is the main Linux kernel development tree. Maintenance of the code "
17409 "is in this case partly shared by other developers in the kernel community, "
17410 "who make <quote>drive-by</quote> modifications to the driver as they develop "
17411 "and refine kernel subsystems."
17412 msgstr ""
17414 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17415 #: ../en/ch13-mq-collab.xml:42
17416 msgid ""
17417 "We also maintain a number of <quote>backports</quote> to older versions of "
17418 "the Linux kernel, to support the needs of customers who are running older "
17419 "Linux distributions that do not incorporate our drivers. (To "
17420 "<emphasis>backport</emphasis> a piece of code is to modify it to work in an "
17421 "older version of its target environment than the version it was developed "
17422 "for.)"
17423 msgstr ""
17425 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17426 #: ../en/ch13-mq-collab.xml:50
17427 msgid ""
17428 "Finally, we make software releases on a schedule that is necessarily not "
17429 "aligned with those used by Linux distributors and kernel developers, so that "
17430 "we can deliver new features to customers without forcing them to upgrade "
17431 "their entire kernels or distributions."
17432 msgstr ""
17434 #. type: Content of: <book><chapter><sect1><sect2><title>
17435 #: ../en/ch13-mq-collab.xml:58
17436 msgid "Tempting approaches that don't work well"
17437 msgstr "工作不好的诱人方法"
17439 #. type: Content of: <book><chapter><sect1><sect2><para>
17440 #: ../en/ch13-mq-collab.xml:60
17441 msgid ""
17442 "There are two <quote>standard</quote> ways to maintain a piece of software "
17443 "that has to target many different environments."
17444 msgstr ""
17446 #. type: Content of: <book><chapter><sect1><sect2><para>
17447 #: ../en/ch13-mq-collab.xml:64
17448 msgid ""
17449 "The first is to maintain a number of branches, each intended for a single "
17450 "target. The trouble with this approach is that you must maintain iron "
17451 "discipline in the flow of changes between repositories. A new feature or bug "
17452 "fix must start life in a <quote>pristine</quote> repository, then percolate "
17453 "out to every backport repository. Backport changes are more limited in the "
17454 "branches they should propagate to; a backport change that is applied to a "
17455 "branch where it doesn't belong will probably stop the driver from compiling."
17456 msgstr ""
17458 #. type: Content of: <book><chapter><sect1><sect2><para>
17459 #: ../en/ch13-mq-collab.xml:74
17460 msgid ""
17461 "The second is to maintain a single source tree filled with conditional "
17462 "statements that turn chunks of code on or off depending on the intended "
17463 "target. Because these <quote>ifdefs</quote> are not allowed in the Linux "
17464 "kernel tree, a manual or automatic process must be followed to strip them out "
17465 "and yield a clean tree. A code base maintained in this fashion rapidly "
17466 "becomes a rat's nest of conditional blocks that are difficult to understand "
17467 "and maintain."
17468 msgstr ""
17470 #. type: Content of: <book><chapter><sect1><sect2><para>
17471 #: ../en/ch13-mq-collab.xml:83
17472 msgid ""
17473 "Neither of these approaches is well suited to a situation where you don't "
17474 "<quote>own</quote> the canonical copy of a source tree. In the case of a "
17475 "Linux driver that is distributed with the standard kernel, Linus's tree "
17476 "contains the copy of the code that will be treated by the world as "
17477 "canonical. The upstream version of <quote>my</quote> driver can be modified "
17478 "by people I don't know, without me even finding out about it until after the "
17479 "changes show up in Linus's tree."
17480 msgstr ""
17482 #. type: Content of: <book><chapter><sect1><sect2><para>
17483 #: ../en/ch13-mq-collab.xml:93
17484 msgid ""
17485 "These approaches have the added weakness of making it difficult to generate "
17486 "well-formed patches to submit upstream."
17487 msgstr ""
17489 #. type: Content of: <book><chapter><sect1><sect2><para>
17490 #: ../en/ch13-mq-collab.xml:97
17491 msgid ""
17492 "In principle, Mercurial Queues seems like a good candidate to manage a "
17493 "development scenario such as the above. While this is indeed the case, MQ "
17494 "contains a few added features that make the job more pleasant."
17495 msgstr ""
17497 #. type: Content of: <book><chapter><sect1><title>
17498 #: ../en/ch13-mq-collab.xml:105
17499 msgid "Conditionally applying patches with guards"
17500 msgstr "有条件的应用补丁"
17502 #. type: Content of: <book><chapter><sect1><para>
17503 #: ../en/ch13-mq-collab.xml:107
17504 msgid ""
17505 "Perhaps the best way to maintain sanity with so many targets is to be able to "
17506 "choose specific patches to apply for a given situation. MQ provides a "
17507 "feature called <quote>guards</quote> (which originates with quilt's "
17508 "<literal>guards</literal> command) that does just this. To start off, let's "
17509 "create a simple repository for experimenting in."
17510 msgstr ""
17512 #. type: Content of: <book><chapter><sect1><para>
17513 #: ../en/ch13-mq-collab.xml:116
17514 msgid ""
17515 "This gives us a tiny repository that contains two patches that don't have any "
17516 "dependencies on each other, because they touch different files."
17517 msgstr ""
17519 #. type: Content of: <book><chapter><sect1><para>
17520 #: ../en/ch13-mq-collab.xml:120
17521 msgid ""
17522 "The idea behind conditional application is that you can <quote>tag</quote> a "
17523 "patch with a <emphasis>guard</emphasis>, which is simply a text string of "
17524 "your choosing, then tell MQ to select specific guards to use when applying "
17525 "patches. MQ will then either apply, or skip over, a guarded patch, depending "
17526 "on the guards that you have selected."
17527 msgstr ""
17529 #. type: Content of: <book><chapter><sect1><para>
17530 #: ../en/ch13-mq-collab.xml:127
17531 msgid ""
17532 "A patch can have an arbitrary number of guards; each one is "
17533 "<emphasis>positive</emphasis> (<quote>apply this patch if this guard is "
17534 "selected</quote>) or <emphasis>negative</emphasis> (<quote>skip this patch if "
17535 "this guard is selected</quote>). A patch with no guards is always applied."
17536 msgstr ""
17538 #. type: Content of: <book><chapter><sect1><title>
17539 #: ../en/ch13-mq-collab.xml:135
17540 msgid "Controlling the guards on a patch"
17541 msgstr "控制补丁的应用条件"
17543 #. type: Content of: <book><chapter><sect1><para>
17544 #: ../en/ch13-mq-collab.xml:137
17545 msgid ""
17546 "The <command role=\"hg-ext-mq\">qguard</command> command lets you determine "
17547 "which guards should apply to a patch, or display the guards that are already "
17548 "in effect. Without any arguments, it displays the guards on the current "
17549 "topmost patch."
17550 msgstr ""
17552 #. type: Content of: <book><chapter><sect1><para>
17553 #: ../en/ch13-mq-collab.xml:144
17554 msgid ""
17555 "To set a positive guard on a patch, prefix the name of the guard with a "
17556 "<quote><literal>+</literal></quote>."
17557 msgstr ""
17559 #. type: Content of: <book><chapter><sect1><para>
17560 #: ../en/ch13-mq-collab.xml:149
17561 msgid ""
17562 "To set a negative guard on a patch, prefix the name of the guard with a "
17563 "<quote><literal>-</literal></quote>."
17564 msgstr ""
17566 #. type: Content of: <book><chapter><sect1><para>
17567 #: ../en/ch13-mq-collab.xml:155
17568 msgid ""
17569 "Notice that we prefixed the arguments to the <command>hg qguard</command> "
17570 "command with a <literal>--</literal> here, so that Mercurial would not "
17571 "interpret the text <literal>-quux</literal> as an option."
17572 msgstr ""
17574 #. type: Content of: <book><chapter><sect1><note><title>
17575 #: ../en/ch13-mq-collab.xml:161
17576 msgid "Setting vs. modifying"
17577 msgstr ""
17579 #. type: Content of: <book><chapter><sect1><note><para>
17580 #: ../en/ch13-mq-collab.xml:163
17581 msgid ""
17582 "The <command role=\"hg-ext-mq\">qguard</command> command <emphasis>sets</"
17583 "emphasis> the guards on a patch; it doesn't <emphasis>modify</emphasis> "
17584 "them. What this means is that if you run <command role=\"hg-cmd\">hg qguard "
17585 "+a +b</command> on a patch, then <command role=\"hg-cmd\">hg qguard +c</"
17586 "command> on the same patch, the <emphasis>only</emphasis> guard that will be "
17587 "set on it afterwards is <literal>+c</literal>."
17588 msgstr ""
17591 #. type: Content of: <book><chapter><sect1><para>
17592 #: ../en/ch13-mq-collab.xml:172
17593 msgid ""
17594 "Mercurial stores guards in the <filename role=\"special\">series</filename> "
17595 "file; the form in which they are stored is easy both to understand and to "
17596 "edit by hand. (In other words, you don't have to use the <command role=\"hg-"
17597 "ext-mq\">qguard</command> command if you don't want to; it's okay to simply "
17598 "edit the <filename role=\"special\">series</filename> file.)"
17599 msgstr ""
17601 #. type: Content of: <book><chapter><sect1><title>
17602 #: ../en/ch13-mq-collab.xml:184
17603 msgid "Selecting the guards to use"
17604 msgstr "选择使用的条件"
17606 #. type: Content of: <book><chapter><sect1><para>
17607 #: ../en/ch13-mq-collab.xml:186
17608 msgid ""
17609 "The <command role=\"hg-ext-mq\">qselect</command> command determines which "
17610 "guards are active at a given time. The effect of this is to determine which "
17611 "patches MQ will apply the next time you run <command role=\"hg-ext-mq"
17612 "\">qpush</command>. It has no other effect; in particular, it doesn't do "
17613 "anything to patches that are already applied."
17614 msgstr ""
17616 #. type: Content of: <book><chapter><sect1><para>
17617 #: ../en/ch13-mq-collab.xml:193
17618 msgid ""
17619 "With no arguments, the <command role=\"hg-ext-mq\">qselect</command> command "
17620 "lists the guards currently in effect, one per line of output. Each argument "
17621 "is treated as the name of a guard to apply."
17622 msgstr ""
17624 #. type: Content of: <book><chapter><sect1><para>
17625 #: ../en/ch13-mq-collab.xml:200
17626 msgid ""
17627 "In case you're interested, the currently selected guards are stored in the "
17628 "<filename role=\"special\">guards</filename> file."
17629 msgstr ""
17631 #. type: Content of: <book><chapter><sect1><para>
17632 #: ../en/ch13-mq-collab.xml:205
17633 msgid ""
17634 "We can see the effect the selected guards have when we run <command role=\"hg-"
17635 "ext-mq\">qpush</command>."
17636 msgstr ""
17638 #. type: Content of: <book><chapter><sect1><para>
17639 #: ../en/ch13-mq-collab.xml:210
17640 msgid ""
17641 "A guard cannot start with a <quote><literal>+</literal></quote> or "
17642 "<quote><literal>-</literal></quote> character. The name of a guard must not "
17643 "contain white space, but most other characters are acceptable. If you try to "
17644 "use a guard with an invalid name, MQ will complain:"
17645 msgstr ""
17647 #. type: Content of: <book><chapter><sect1><para>
17648 #: ../en/ch13-mq-collab.xml:219
17649 msgid "Changing the selected guards changes the patches that are applied."
17650 msgstr ""
17652 #. type: Content of: <book><chapter><sect1><para>
17653 #: ../en/ch13-mq-collab.xml:224
17654 msgid ""
17655 "You can see in the example below that negative guards take precedence over "
17656 "positive guards."
17657 msgstr ""
17659 #. type: Content of: <book><chapter><sect1><title>
17660 #: ../en/ch13-mq-collab.xml:231
17661 msgid "MQ's rules for applying patches"
17662 msgstr "MQ 应用补丁的规则"
17664 #. type: Content of: <book><chapter><sect1><para>
17665 #: ../en/ch13-mq-collab.xml:233
17666 msgid ""
17667 "The rules that MQ uses when deciding whether to apply a patch are as follows."
17668 msgstr ""
17670 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17671 #: ../en/ch13-mq-collab.xml:236
17672 msgid "A patch that has no guards is always applied."
17673 msgstr ""
17675 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17676 #: ../en/ch13-mq-collab.xml:239
17677 msgid ""
17678 "If the patch has any negative guard that matches any currently selected "
17679 "guard, the patch is skipped."
17680 msgstr ""
17682 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17683 #: ../en/ch13-mq-collab.xml:242
17684 msgid ""
17685 "If the patch has any positive guard that matches any currently selected "
17686 "guard, the patch is applied."
17687 msgstr ""
17689 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17690 #: ../en/ch13-mq-collab.xml:245
17691 msgid ""
17692 "If the patch has positive or negative guards, but none matches any currently "
17693 "selected guard, the patch is skipped."
17694 msgstr ""
17696 #. type: Content of: <book><chapter><sect1><title>
17697 #: ../en/ch13-mq-collab.xml:252
17698 msgid "Trimming the work environment"
17699 msgstr "修剪工作环境"
17701 #. type: Content of: <book><chapter><sect1><para>
17702 #: ../en/ch13-mq-collab.xml:254
17703 msgid ""
17704 "In working on the device driver I mentioned earlier, I don't apply the "
17705 "patches to a normal Linux kernel tree. Instead, I use a repository that "
17706 "contains only a snapshot of the source files and headers that are relevant to "
17707 "Infiniband development. This repository is 1% the size of a kernel "
17708 "repository, so it's easier to work with."
17709 msgstr ""
17711 #. type: Content of: <book><chapter><sect1><para>
17712 #: ../en/ch13-mq-collab.xml:261
17713 msgid ""
17714 "I then choose a <quote>base</quote> version on top of which the patches are "
17715 "applied. This is a snapshot of the Linux kernel tree as of a revision of my "
17716 "choosing. When I take the snapshot, I record the changeset ID from the "
17717 "kernel repository in the commit message. Since the snapshot preserves the "
17718 "<quote>shape</quote> and content of the relevant parts of the kernel tree, I "
17719 "can apply my patches on top of either my tiny repository or a normal kernel "
17720 "tree."
17721 msgstr ""
17723 #. type: Content of: <book><chapter><sect1><para>
17724 #: ../en/ch13-mq-collab.xml:270
17725 msgid ""
17726 "Normally, the base tree atop which the patches apply should be a snapshot of "
17727 "a very recent upstream tree. This best facilitates the development of "
17728 "patches that can easily be submitted upstream with few or no modifications."
17729 msgstr ""
17731 #. type: Content of: <book><chapter><sect1><title>
17732 #: ../en/ch13-mq-collab.xml:277
17733 msgid "Dividing up the <filename role=\"special\">series</filename> file"
17734 msgstr "分类补丁<filename role=\"special\">系列</filename>"
17736 #. type: Content of: <book><chapter><sect1><para>
17737 #: ../en/ch13-mq-collab.xml:280
17738 msgid ""
17739 "I categorise the patches in the <filename role=\"special\">series</filename> "
17740 "file into a number of logical groups. Each section of like patches begins "
17741 "with a block of comments that describes the purpose of the patches that "
17742 "follow."
17743 msgstr ""
17745 #. type: Content of: <book><chapter><sect1><para>
17746 #: ../en/ch13-mq-collab.xml:286
17747 msgid ""
17748 "The sequence of patch groups that I maintain follows. The ordering of these "
17749 "groups is important; I'll describe why after I introduce the groups."
17750 msgstr ""
17752 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17753 #: ../en/ch13-mq-collab.xml:290
17754 msgid ""
17755 "The <quote>accepted</quote> group. Patches that the development team has "
17756 "submitted to the maintainer of the Infiniband subsystem, and which he has "
17757 "accepted, but which are not present in the snapshot that the tiny repository "
17758 "is based on. These are <quote>read only</quote> patches, present only to "
17759 "transform the tree into a similar state as it is in the upstream maintainer's "
17760 "repository."
17761 msgstr ""
17763 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17764 #: ../en/ch13-mq-collab.xml:298
17765 msgid ""
17766 "The <quote>rework</quote> group. Patches that I have submitted, but that the "
17767 "upstream maintainer has requested modifications to before he will accept them."
17768 msgstr ""
17770 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17771 #: ../en/ch13-mq-collab.xml:303
17772 msgid ""
17773 "The <quote>pending</quote> group. Patches that I have not yet submitted to "
17774 "the upstream maintainer, but which we have finished working on. These will be "
17775 "<quote>read only</quote> for a while. If the upstream maintainer accepts "
17776 "them upon submission, I'll move them to the end of the <quote>accepted</"
17777 "quote> group. If he requests that I modify any, I'll move them to the "
17778 "beginning of the <quote>rework</quote> group."
17779 msgstr ""
17781 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17782 #: ../en/ch13-mq-collab.xml:312
17783 msgid ""
17784 "The <quote>in progress</quote> group. Patches that are actively being "
17785 "developed, and should not be submitted anywhere yet."
17786 msgstr ""
17788 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17789 #: ../en/ch13-mq-collab.xml:316
17790 msgid ""
17791 "The <quote>backport</quote> group. Patches that adapt the source tree to "
17792 "older versions of the kernel tree."
17793 msgstr ""
17795 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17796 #: ../en/ch13-mq-collab.xml:320
17797 msgid ""
17798 "The <quote>do not ship</quote> group. Patches that for some reason should "
17799 "never be submitted upstream. For example, one such patch might change "
17800 "embedded driver identification strings to make it easier to distinguish, in "
17801 "the field, between an out-of-tree version of the driver and a version shipped "
17802 "by a distribution vendor."
17803 msgstr ""
17805 #. type: Content of: <book><chapter><sect1><para>
17806 #: ../en/ch13-mq-collab.xml:328
17807 msgid ""
17808 "Now to return to the reasons for ordering groups of patches in this way. We "
17809 "would like the lowest patches in the stack to be as stable as possible, so "
17810 "that we will not need to rework higher patches due to changes in context. "
17811 "Putting patches that will never be changed first in the <filename role="
17812 "\"special\">series</filename> file serves this purpose."
17813 msgstr ""
17815 #. type: Content of: <book><chapter><sect1><para>
17816 #: ../en/ch13-mq-collab.xml:336
17817 msgid ""
17818 "We would also like the patches that we know we'll need to modify to be "
17819 "applied on top of a source tree that resembles the upstream tree as closely "
17820 "as possible. This is why we keep accepted patches around for a while."
17821 msgstr ""
17823 #. type: Content of: <book><chapter><sect1><para>
17824 #: ../en/ch13-mq-collab.xml:341
17825 msgid ""
17826 "The <quote>backport</quote> and <quote>do not ship</quote> patches float at "
17827 "the end of the <filename role=\"special\">series</filename> file. The "
17828 "backport patches must be applied on top of all other patches, and the "
17829 "<quote>do not ship</quote> patches might as well stay out of harm's way."
17830 msgstr ""
17832 #. type: Content of: <book><chapter><sect1><title>
17833 #: ../en/ch13-mq-collab.xml:350
17834 msgid "Maintaining the patch series"
17835 msgstr "维护补丁系列"
17837 #. type: Content of: <book><chapter><sect1><para>
17838 #: ../en/ch13-mq-collab.xml:352
17839 msgid ""
17840 "In my work, I use a number of guards to control which patches are to be "
17841 "applied."
17842 msgstr ""
17844 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17845 #: ../en/ch13-mq-collab.xml:356
17846 msgid ""
17847 "<quote>Accepted</quote> patches are guarded with <literal>accepted</"
17848 "literal>. I enable this guard most of the time. When I'm applying the "
17849 "patches on top of a tree where the patches are already present, I can turn "
17850 "this patch off, and the patches that follow it will apply cleanly."
17851 msgstr ""
17853 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17854 #: ../en/ch13-mq-collab.xml:363
17855 msgid ""
17856 "Patches that are <quote>finished</quote>, but not yet submitted, have no "
17857 "guards. If I'm applying the patch stack to a copy of the upstream tree, I "
17858 "don't need to enable any guards in order to get a reasonably safe source tree."
17859 msgstr ""
17861 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17862 #: ../en/ch13-mq-collab.xml:369
17863 msgid ""
17864 "Those patches that need reworking before being resubmitted are guarded with "
17865 "<literal>rework</literal>."
17866 msgstr ""
17868 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17869 #: ../en/ch13-mq-collab.xml:373
17870 msgid ""
17871 "For those patches that are still under development, I use <literal>devel</"
17872 "literal>."
17873 msgstr ""
17875 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17876 #: ../en/ch13-mq-collab.xml:376
17877 msgid ""
17878 "A backport patch may have several guards, one for each version of the kernel "
17879 "to which it applies. For example, a patch that backports a piece of code to "
17880 "2.6.9 will have a <literal>2.6.9</literal> guard."
17881 msgstr ""
17883 #. type: Content of: <book><chapter><sect1><para>
17884 #: ../en/ch13-mq-collab.xml:381
17885 msgid ""
17886 "This variety of guards gives me considerable flexibility in determining what "
17887 "kind of source tree I want to end up with. For most situations, the "
17888 "selection of appropriate guards is automated during the build process, but I "
17889 "can manually tune the guards to use for less common circumstances."
17890 msgstr ""
17892 #. type: Content of: <book><chapter><sect1><sect2><title>
17893 #: ../en/ch13-mq-collab.xml:388
17894 msgid "The art of writing backport patches"
17895 msgstr "编写向后移植补丁的艺术"
17897 #. type: Content of: <book><chapter><sect1><sect2><para>
17898 #: ../en/ch13-mq-collab.xml:390
17899 msgid ""
17900 "Using MQ, writing a backport patch is a simple process. All such a patch has "
17901 "to do is modify a piece of code that uses a kernel feature not present in the "
17902 "older version of the kernel, so that the driver continues to work correctly "
17903 "under that older version."
17904 msgstr ""
17906 #. type: Content of: <book><chapter><sect1><sect2><para>
17907 #: ../en/ch13-mq-collab.xml:396
17908 msgid ""
17909 "A useful goal when writing a good backport patch is to make your code look as "
17910 "if it was written for the older version of the kernel you're targeting. The "
17911 "less obtrusive the patch, the easier it will be to understand and maintain. "
17912 "If you're writing a collection of backport patches to avoid the <quote>rat's "
17913 "nest</quote> effect of lots of <literal>#ifdef</literal>s (hunks of source "
17914 "code that are only used conditionally) in your code, don't introduce version-"
17915 "dependent <literal>#ifdef</literal>s into the patches. Instead, write "
17916 "several patches, each of which makes unconditional changes, and control their "
17917 "application using guards."
17918 msgstr ""
17920 #. type: Content of: <book><chapter><sect1><sect2><para>
17921 #: ../en/ch13-mq-collab.xml:409
17922 msgid ""
17923 "There are two reasons to divide backport patches into a distinct group, away "
17924 "from the <quote>regular</quote> patches whose effects they modify. The first "
17925 "is that intermingling the two makes it more difficult to use a tool like the "
17926 "<literal role=\"hg-ext\">patchbomb</literal> extension to automate the "
17927 "process of submitting the patches to an upstream maintainer. The second is "
17928 "that a backport patch could perturb the context in which a subsequent regular "
17929 "patch is applied, making it impossible to apply the regular patch cleanly "
17930 "<emphasis>without</emphasis> the earlier backport patch already being applied."
17931 msgstr ""
17933 #. type: Content of: <book><chapter><sect1><title>
17934 #: ../en/ch13-mq-collab.xml:424
17935 msgid "Useful tips for developing with MQ"
17936 msgstr "使用 MQ 开发的技巧"
17938 #. type: Content of: <book><chapter><sect1><sect2><title>
17939 #: ../en/ch13-mq-collab.xml:427
17940 msgid "Organising patches in directories"
17941 msgstr "将补丁放到几个目录中"
17943 #. type: Content of: <book><chapter><sect1><sect2><para>
17944 #: ../en/ch13-mq-collab.xml:429
17945 msgid ""
17946 "If you're working on a substantial project with MQ, it's not difficult to "
17947 "accumulate a large number of patches. For example, I have one patch "
17948 "repository that contains over 250 patches."
17949 msgstr ""
17951 #. type: Content of: <book><chapter><sect1><sect2><para>
17952 #: ../en/ch13-mq-collab.xml:434
17953 msgid ""
17954 "If you can group these patches into separate logical categories, you can if "
17955 "you like store them in different directories; MQ has no problems with patch "
17956 "names that contain path separators."
17957 msgstr ""
17959 #. type: Content of: <book><chapter><sect1><sect2><title>
17960 #: ../en/ch13-mq-collab.xml:441
17961 msgid "Viewing the history of a patch"
17962 msgstr "察看补丁的历史"
17964 #. type: Content of: <book><chapter><sect1><sect2><para>
17965 #: ../en/ch13-mq-collab.xml:443
17966 msgid ""
17967 "If you're developing a set of patches over a long time, it's a good idea to "
17968 "maintain them in a repository, as discussed in <xref linkend=\"sec:mq:repo\"/"
17969 ">. If you do so, you'll quickly discover that using the <command role=\"hg-"
17970 "cmd\">hg diff</command> command to look at the history of changes to a patch "
17971 "is unworkable. This is in part because you're looking at the second "
17972 "derivative of the real code (a diff of a diff), but also because MQ adds "
17973 "noise to the process by modifying time stamps and directory names when it "
17974 "updates a patch."
17975 msgstr ""
17977 #. type: Content of: <book><chapter><sect1><sect2><para>
17978 #: ../en/ch13-mq-collab.xml:455
17979 msgid ""
17980 "However, you can use the <literal role=\"hg-ext\">extdiff</literal> "
17981 "extension, which is bundled with Mercurial, to turn a diff of two versions of "
17982 "a patch into something readable. To do this, you will need a third-party "
17983 "package called <literal role=\"package\">patchutils</literal> <citation>web:"
17984 "patchutils</citation>. This provides a command named <command>interdiff</"
17985 "command>, which shows the differences between two diffs as a diff. Used on "
17986 "two versions of the same diff, it generates a diff that represents the diff "
17987 "from the first to the second version."
17988 msgstr ""
17990 #. type: Content of: <book><chapter><sect1><sect2><para>
17991 #: ../en/ch13-mq-collab.xml:466
17992 msgid ""
17993 "You can enable the <literal role=\"hg-ext\">extdiff</literal> extension in "
17994 "the usual way, by adding a line to the <literal role=\"rc-extensions"
17995 "\">extensions</literal> section of your <filename role=\"special\">~/.hgrc</"
17996 "filename>."
17997 msgstr ""
18000 #. &example.hg-interdiff;
18001 #. type: Content of: <book><chapter><sect1><sect2><para>
18002 #: ../en/ch13-mq-collab.xml:473
18003 msgid ""
18004 "The <command>interdiff</command> command expects to be passed the names of "
18005 "two files, but the <literal role=\"hg-ext\">extdiff</literal> extension "
18006 "passes the program it runs a pair of directories, each of which can contain "
18007 "an arbitrary number of files. We thus need a small program that will run "
18008 "<command>interdiff</command> on each pair of files in these two directories. "
18009 "This program is available as <filename role=\"special\">hg-interdiff</"
18010 "filename> in the <filename class=\"directory\">examples</filename> directory "
18011 "of the source code repository that accompanies this book."
18012 msgstr ""
18014 #. type: Content of: <book><chapter><sect1><sect2><para>
18015 #: ../en/ch13-mq-collab.xml:485
18016 msgid ""
18017 "With the <filename role=\"special\">hg-interdiff</filename> program in your "
18018 "shell's search path, you can run it as follows, from inside an MQ patch "
18019 "directory:"
18020 msgstr ""
18022 #. type: Content of: <book><chapter><sect1><sect2><para>
18023 #: ../en/ch13-mq-collab.xml:489
18024 msgid ""
18025 "Since you'll probably want to use this long-winded command a lot, you can get "
18026 "<literal role=\"hg-ext\">hgext</literal> to make it available as a normal "
18027 "Mercurial command, again by editing your <filename role=\"special\">~/.hgrc</"
18028 "filename>."
18029 msgstr ""
18031 #. type: Content of: <book><chapter><sect1><sect2><para>
18032 #: ../en/ch13-mq-collab.xml:496
18033 msgid ""
18034 "This directs <literal role=\"hg-ext\">hgext</literal> to make an "
18035 "<literal>interdiff</literal> command available, so you can now shorten the "
18036 "previous invocation of <command role=\"hg-ext-extdiff\">extdiff</command> to "
18037 "something a little more wieldy."
18038 msgstr ""
18040 #. type: Content of: <book><chapter><sect1><sect2><note><para>
18041 #: ../en/ch13-mq-collab.xml:504
18042 msgid ""
18043 "The <command>interdiff</command> command works well only if the underlying "
18044 "files against which versions of a patch are generated remain the same. If "
18045 "you create a patch, modify the underlying files, and then regenerate the "
18046 "patch, <command>interdiff</command> may not produce useful output."
18047 msgstr ""
18049 #. type: Content of: <book><chapter><sect1><sect2><para>
18050 #: ../en/ch13-mq-collab.xml:512
18051 msgid ""
18052 "The <literal role=\"hg-ext\">extdiff</literal> extension is useful for more "
18053 "than merely improving the presentation of MQ patches. To read more about it, "
18054 "go to <xref linkend=\"sec:hgext:extdiff\"/>."
18055 msgstr ""
18057 #. type: Content of: <book><chapter><title>
18058 #: ../en/ch14-hgext.xml:5
18059 msgid "Adding functionality with extensions"
18060 msgstr "使用扩展增加功能"
18062 #. type: Content of: <book><chapter><para>
18063 #: ../en/ch14-hgext.xml:7
18064 msgid ""
18065 "While the core of Mercurial is quite complete from a functionality "
18066 "standpoint, it's deliberately shorn of fancy features. This approach of "
18067 "preserving simplicity keeps the software easy to deal with for both "
18068 "maintainers and users."
18069 msgstr ""
18071 #. type: Content of: <book><chapter><para>
18072 #: ../en/ch14-hgext.xml:12
18073 msgid ""
18074 "However, Mercurial doesn't box you in with an inflexible command set: you can "
18075 "add features to it as <emphasis>extensions</emphasis> (sometimes known as "
18076 "<emphasis>plugins</emphasis>). We've already discussed a few of these "
18077 "extensions in earlier chapters."
18078 msgstr ""
18080 #. type: Content of: <book><chapter><itemizedlist><listitem><para>
18081 #: ../en/ch14-hgext.xml:18
18082 msgid ""
18083 "<xref linkend=\"sec:tour-merge:fetch\"/> covers the <literal role=\"hg-ext"
18084 "\">fetch</literal> extension; this combines pulling new changes and merging "
18085 "them with local changes into a single command, <command role=\"hg-ext-fetch"
18086 "\">fetch</command>."
18087 msgstr ""
18089 #. type: Content of: <book><chapter><itemizedlist><listitem><para>
18090 #: ../en/ch14-hgext.xml:24
18091 msgid ""
18092 "In <xref linkend=\"chap:hook\"/>, we covered several extensions that are "
18093 "useful for hook-related functionality: <literal role=\"hg-ext\">acl</literal> "
18094 "adds access control lists; <literal role=\"hg-ext\">bugzilla</literal> adds "
18095 "integration with the Bugzilla bug tracking system; and <literal role=\"hg-ext"
18096 "\">notify</literal> sends notification emails on new changes."
18097 msgstr ""
18099 #. type: Content of: <book><chapter><itemizedlist><listitem><para>
18100 #: ../en/ch14-hgext.xml:33
18101 msgid ""
18102 "The Mercurial Queues patch management extension is so invaluable that it "
18103 "merits two chapters and an appendix all to itself. <xref linkend=\"chap:mq\"/"
18104 "> covers the basics; <xref linkend=\"chap:mq-collab\"/> discusses advanced "
18105 "topics; and <xref linkend=\"chap:mqref\"/> goes into detail on each command."
18106 msgstr ""
18108 #. type: Content of: <book><chapter><para>
18109 #: ../en/ch14-hgext.xml:43
18110 msgid ""
18111 "In this chapter, we'll cover some of the other extensions that are available "
18112 "for Mercurial, and briefly touch on some of the machinery you'll need to know "
18113 "about if you want to write an extension of your own."
18114 msgstr ""
18116 #. type: Content of: <book><chapter><itemizedlist><listitem><para>
18117 #: ../en/ch14-hgext.xml:48
18118 msgid ""
18119 "In <xref linkend=\"sec:hgext:inotify\"/>, we'll discuss the possibility of "
18120 "<emphasis>huge</emphasis> performance improvements using the <literal role="
18121 "\"hg-ext\">inotify</literal> extension."
18122 msgstr ""
18124 #. type: Content of: <book><chapter><sect1><title>
18125 #: ../en/ch14-hgext.xml:55
18126 msgid ""
18127 "Improve performance with the <literal role=\"hg-ext\">inotify</literal> "
18128 "extension"
18129 msgstr "使用扩展 <literal role=\"hg-ext\">inotify</literal> 以提高性能"
18131 #. type: Content of: <book><chapter><sect1><para>
18132 #: ../en/ch14-hgext.xml:58
18133 msgid ""
18134 "Are you interested in having some of the most common Mercurial operations run "
18135 "as much as a hundred times faster? Read on!"
18136 msgstr ""
18138 #. type: Content of: <book><chapter><sect1><para>
18139 #: ../en/ch14-hgext.xml:62
18140 msgid ""
18141 "Mercurial has great performance under normal circumstances. For example, "
18142 "when you run the <command role=\"hg-cmd\">hg status</command> command, "
18143 "Mercurial has to scan almost every directory and file in your repository so "
18144 "that it can display file status. Many other Mercurial commands need to do "
18145 "the same work behind the scenes; for example, the <command role=\"hg-cmd\">hg "
18146 "diff</command> command uses the status machinery to avoid doing an expensive "
18147 "comparison operation on files that obviously haven't changed."
18148 msgstr ""
18150 #. type: Content of: <book><chapter><sect1><para>
18151 #: ../en/ch14-hgext.xml:72
18152 msgid ""
18153 "Because obtaining file status is crucial to good performance, the authors of "
18154 "Mercurial have optimised this code to within an inch of its life. However, "
18155 "there's no avoiding the fact that when you run <command role=\"hg-cmd\">hg "
18156 "status</command>, Mercurial is going to have to perform at least one "
18157 "expensive system call for each managed file to determine whether it's changed "
18158 "since the last time Mercurial checked. For a sufficiently large repository, "
18159 "this can take a long time."
18160 msgstr ""
18162 #. type: Content of: <book><chapter><sect1><para>
18163 #: ../en/ch14-hgext.xml:82
18164 msgid ""
18165 "To put a number on the magnitude of this effect, I created a repository "
18166 "containing 150,000 managed files. I timed <command role=\"hg-cmd\">hg "
18167 "status</command> as taking ten seconds to run, even when <emphasis>none</"
18168 "emphasis> of those files had been modified."
18169 msgstr ""
18171 #. type: Content of: <book><chapter><sect1><para>
18172 #: ../en/ch14-hgext.xml:88
18173 msgid ""
18174 "Many modern operating systems contain a file notification facility. If a "
18175 "program signs up to an appropriate service, the operating system will notify "
18176 "it every time a file of interest is created, modified, or deleted. On Linux "
18177 "systems, the kernel component that does this is called <literal>inotify</"
18178 "literal>."
18179 msgstr ""
18181 #. type: Content of: <book><chapter><sect1><para>
18182 #: ../en/ch14-hgext.xml:95
18183 msgid ""
18184 "Mercurial's <literal role=\"hg-ext\">inotify</literal> extension talks to the "
18185 "kernel's <literal>inotify</literal> component to optimise <command role=\"hg-"
18186 "cmd\">hg status</command> commands. The extension has two components. A "
18187 "daemon sits in the background and receives notifications from the "
18188 "<literal>inotify</literal> subsystem. It also listens for connections from a "
18189 "regular Mercurial command. The extension modifies Mercurial's behavior so "
18190 "that instead of scanning the filesystem, it queries the daemon. Since the "
18191 "daemon has perfect information about the state of the repository, it can "
18192 "respond with a result instantaneously, avoiding the need to scan every "
18193 "directory and file in the repository."
18194 msgstr ""
18196 #. type: Content of: <book><chapter><sect1><para>
18197 #: ../en/ch14-hgext.xml:108
18198 msgid ""
18199 "Recall the ten seconds that I measured plain Mercurial as taking to run "
18200 "<command role=\"hg-cmd\">hg status</command> on a 150,000 file repository. "
18201 "With the <literal role=\"hg-ext\">inotify</literal> extension enabled, the "
18202 "time dropped to 0.1 seconds, a factor of <emphasis>one hundred</emphasis> "
18203 "faster."
18204 msgstr ""
18206 #. type: Content of: <book><chapter><sect1><para>
18207 #: ../en/ch14-hgext.xml:115
18208 msgid "Before we continue, please pay attention to some caveats."
18209 msgstr ""
18211 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
18212 #: ../en/ch14-hgext.xml:118
18213 msgid ""
18214 "The <literal role=\"hg-ext\">inotify</literal> extension is Linux-specific. "
18215 "Because it interfaces directly to the Linux kernel's <literal>inotify</"
18216 "literal> subsystem, it does not work on other operating systems."
18217 msgstr ""
18219 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
18220 #: ../en/ch14-hgext.xml:123
18221 msgid ""
18222 "It should work on any Linux distribution that was released after early 2005. "
18223 "Older distributions are likely to have a kernel that lacks <literal>inotify</"
18224 "literal>, or a version of <literal>glibc</literal> that does not have the "
18225 "necessary interfacing support."
18226 msgstr ""
18228 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
18229 #: ../en/ch14-hgext.xml:130
18230 msgid ""
18231 "Not all filesystems are suitable for use with the <literal role=\"hg-ext"
18232 "\">inotify</literal> extension. Network filesystems such as NFS are a non-"
18233 "starter, for example, particularly if you're running Mercurial on several "
18234 "systems, all mounting the same network filesystem. The kernel's "
18235 "<literal>inotify</literal> system has no way of knowing about changes made on "
18236 "another system. Most local filesystems (e.g. ext3, XFS, ReiserFS) should "
18237 "work fine."
18238 msgstr ""
18240 #. type: Content of: <book><chapter><sect1><para>
18241 #: ../en/ch14-hgext.xml:141
18242 msgid ""
18243 "The <literal role=\"hg-ext\">inotify</literal> extension is not yet shipped "
18244 "with Mercurial as of May 2007, so it's a little more involved to set up than "
18245 "other extensions. But the performance improvement is worth it!"
18246 msgstr ""
18248 #. type: Content of: <book><chapter><sect1><para>
18249 #: ../en/ch14-hgext.xml:146
18250 msgid ""
18251 "The extension currently comes in two parts: a set of patches to the Mercurial "
18252 "source code, and a library of Python bindings to the <literal>inotify</"
18253 "literal> subsystem."
18254 msgstr ""
18256 #. type: Content of: <book><chapter><sect1><note><para>
18257 #: ../en/ch14-hgext.xml:150
18258 msgid ""
18259 "There are <emphasis>two</emphasis> Python <literal>inotify</literal> binding "
18260 "libraries. One of them is called <literal>pyinotify</literal>, and is "
18261 "packaged by some Linux distributions as <literal>python-inotify</literal>. "
18262 "This is <emphasis>not</emphasis> the one you'll need, as it is too buggy and "
18263 "inefficient to be practical."
18264 msgstr ""
18266 #. type: Content of: <book><chapter><sect1><para>
18267 #: ../en/ch14-hgext.xml:157
18268 msgid ""
18269 "To get going, it's best to already have a functioning copy of Mercurial "
18270 "installed."
18271 msgstr ""
18273 #. type: Content of: <book><chapter><sect1><note><para>
18274 #: ../en/ch14-hgext.xml:160
18275 msgid ""
18276 "If you follow the instructions below, you'll be <emphasis>replacing</"
18277 "emphasis> and overwriting any existing installation of Mercurial that you "
18278 "might already have, using the latest <quote>bleeding edge</quote> Mercurial "
18279 "code. Don't say you weren't warned!"
18280 msgstr ""
18282 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
18283 #: ../en/ch14-hgext.xml:167
18284 msgid ""
18285 "Clone the Python <literal>inotify</literal> binding repository. Build and "
18286 "install it."
18287 msgstr ""
18289 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
18290 #: ../en/ch14-hgext.xml:174
18291 msgid ""
18292 "Clone the <filename class=\"directory\">crew</filename> Mercurial "
18293 "repository. Clone the <literal role=\"hg-ext\">inotify</literal> patch "
18294 "repository so that Mercurial Queues will be able to apply patches to your "
18295 "cope of the <filename class=\"directory\">crew</filename> repository."
18296 msgstr ""
18298 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
18299 #: ../en/ch14-hgext.xml:184
18300 msgid ""
18301 "Make sure that you have the Mercurial Queues extension, <literal role=\"hg-ext"
18302 "\">mq</literal>, enabled. If you've never used MQ, read <xref linkend=\"sec:"
18303 "mq:start\"/> to get started quickly."
18304 msgstr ""
18306 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
18307 #: ../en/ch14-hgext.xml:190
18308 msgid ""
18309 "Go into the <filename class=\"directory\">inotify</filename> repo, and apply "
18310 "all of the <literal role=\"hg-ext\">inotify</literal> patches using the "
18311 "<option role=\"hg-ext-mq-cmd-qpush-opt\">hg -a</option> option to the "
18312 "<command role=\"hg-ext-mq\">qpush</command> command."
18313 msgstr ""
18315 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
18316 #: ../en/ch14-hgext.xml:199
18317 msgid ""
18318 "If you get an error message from <command role=\"hg-ext-mq\">qpush</command>, "
18319 "you should not continue. Instead, ask for help."
18320 msgstr ""
18322 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
18323 #: ../en/ch14-hgext.xml:203
18324 msgid "Build and install the patched version of Mercurial."
18325 msgstr ""
18327 #. type: Content of: <book><chapter><sect1><para>
18328 #: ../en/ch14-hgext.xml:209
18329 msgid ""
18330 "Once you've build a suitably patched version of Mercurial, all you need to do "
18331 "to enable the <literal role=\"hg-ext\">inotify</literal> extension is add an "
18332 "entry to your <filename role=\"special\">~/.hgrc</filename>."
18333 msgstr ""
18335 #. type: Content of: <book><chapter><sect1><para>
18336 #: ../en/ch14-hgext.xml:214
18337 msgid ""
18338 "When the <literal role=\"hg-ext\">inotify</literal> extension is enabled, "
18339 "Mercurial will automatically and transparently start the status daemon the "
18340 "first time you run a command that needs status in a repository. It runs one "
18341 "status daemon per repository."
18342 msgstr ""
18344 #. type: Content of: <book><chapter><sect1><para>
18345 #: ../en/ch14-hgext.xml:220
18346 msgid ""
18347 "The status daemon is started silently, and runs in the background. If you "
18348 "look at a list of running processes after you've enabled the <literal role="
18349 "\"hg-ext\">inotify</literal> extension and run a few commands in different "
18350 "repositories, you'll thus see a few <literal>hg</literal> processes sitting "
18351 "around, waiting for updates from the kernel and queries from Mercurial."
18352 msgstr ""
18354 #. type: Content of: <book><chapter><sect1><para>
18355 #: ../en/ch14-hgext.xml:228
18356 msgid ""
18357 "The first time you run a Mercurial command in a repository when you have the "
18358 "<literal role=\"hg-ext\">inotify</literal> extension enabled, it will run "
18359 "with about the same performance as a normal Mercurial command. This is "
18360 "because the status daemon needs to perform a normal status scan so that it "
18361 "has a baseline against which to apply later updates from the kernel. "
18362 "However, <emphasis>every</emphasis> subsequent command that does any kind of "
18363 "status check should be noticeably faster on repositories of even fairly "
18364 "modest size. Better yet, the bigger your repository is, the greater a "
18365 "performance advantage you'll see. The <literal role=\"hg-ext\">inotify</"
18366 "literal> daemon makes status operations almost instantaneous on repositories "
18367 "of all sizes!"
18368 msgstr ""
18370 #. type: Content of: <book><chapter><sect1><para>
18371 #: ../en/ch14-hgext.xml:242
18372 msgid ""
18373 "If you like, you can manually start a status daemon using the <command role="
18374 "\"hg-ext-inotify\">inserve</command> command. This gives you slightly finer "
18375 "control over how the daemon ought to run. This command will of course only "
18376 "be available when the <literal role=\"hg-ext\">inotify</literal> extension is "
18377 "enabled."
18378 msgstr ""
18380 #. type: Content of: <book><chapter><sect1><para>
18381 #: ../en/ch14-hgext.xml:249
18382 msgid ""
18383 "When you're using the <literal role=\"hg-ext\">inotify</literal> extension, "
18384 "you should notice <emphasis>no difference at all</emphasis> in Mercurial's "
18385 "behavior, with the sole exception of status-related commands running a whole "
18386 "lot faster than they used to. You should specifically expect that commands "
18387 "will not print different output; neither should they give different results. "
18388 "If either of these situations occurs, please report a bug."
18389 msgstr ""
18391 #. type: Content of: <book><chapter><sect1><title>
18392 #: ../en/ch14-hgext.xml:260
18393 msgid ""
18394 "Flexible diff support with the <literal role=\"hg-ext\">extdiff</literal> "
18395 "extension"
18396 msgstr "使用扩展 <literal role=\"hg-ext\">extdiff</literal> 以扩展差异支持"
18398 #. type: Content of: <book><chapter><sect1><para>
18399 #: ../en/ch14-hgext.xml:263
18400 msgid ""
18401 "Mercurial's built-in <command role=\"hg-cmd\">hg diff</command> command "
18402 "outputs plaintext unified diffs."
18403 msgstr ""
18404 "Mercurial 内置命令 <command role=\"hg-cmd\">hg diff</command> 的输出与统一差异"
18405 "不同。"
18407 #. type: Content of: <book><chapter><sect1><para>
18408 #: ../en/ch14-hgext.xml:268
18409 msgid ""
18410 "If you would like to use an external tool to display modifications, you'll "
18411 "want to use the <literal role=\"hg-ext\">extdiff</literal> extension. This "
18412 "will let you use, for example, a graphical diff tool."
18413 msgstr ""
18415 #. type: Content of: <book><chapter><sect1><para>
18416 #: ../en/ch14-hgext.xml:273
18417 msgid ""
18418 "The <literal role=\"hg-ext\">extdiff</literal> extension is bundled with "
18419 "Mercurial, so it's easy to set up. In the <literal role=\"rc-extensions"
18420 "\">extensions</literal> section of your <filename role=\"special\">~/.hgrc</"
18421 "filename>, simply add a one-line entry to enable the extension."
18422 msgstr ""
18424 #. type: Content of: <book><chapter><sect1><para>
18425 #: ../en/ch14-hgext.xml:280
18426 msgid ""
18427 "This introduces a command named <command role=\"hg-ext-extdiff\">extdiff</"
18428 "command>, which by default uses your system's <command>diff</command> command "
18429 "to generate a unified diff in the same form as the built-in <command role="
18430 "\"hg-cmd\">hg diff</command> command."
18431 msgstr ""
18433 #. type: Content of: <book><chapter><sect1><para>
18434 #: ../en/ch14-hgext.xml:288
18435 msgid ""
18436 "The result won't be exactly the same as with the built-in <command role=\"hg-"
18437 "cmd\">hg diff</command> variations, because the output of <command>diff</"
18438 "command> varies from one system to another, even when passed the same options."
18439 msgstr ""
18441 #. type: Content of: <book><chapter><sect1><para>
18442 #: ../en/ch14-hgext.xml:293
18443 msgid ""
18444 "As the <quote><literal>making snapshot</literal></quote> lines of output "
18445 "above imply, the <command role=\"hg-ext-extdiff\">extdiff</command> command "
18446 "works by creating two snapshots of your source tree. The first snapshot is "
18447 "of the source revision; the second, of the target revision or working "
18448 "directory. The <command role=\"hg-ext-extdiff\">extdiff</command> command "
18449 "generates these snapshots in a temporary directory, passes the name of each "
18450 "directory to an external diff viewer, then deletes the temporary directory. "
18451 "For efficiency, it only snapshots the directories and files that have changed "
18452 "between the two revisions."
18453 msgstr ""
18455 #. type: Content of: <book><chapter><sect1><para>
18456 #: ../en/ch14-hgext.xml:306
18457 msgid ""
18458 "Snapshot directory names have the same base name as your repository. If your "
18459 "repository path is <filename class=\"directory\">/quux/bar/foo</filename>, "
18460 "then <filename class=\"directory\">foo</filename> will be the name of each "
18461 "snapshot directory. Each snapshot directory name has its changeset ID "
18462 "appended, if appropriate. If a snapshot is of revision "
18463 "<literal>a631aca1083f</literal>, the directory will be named <filename class="
18464 "\"directory\">foo.a631aca1083f</filename>. A snapshot of the working "
18465 "directory won't have a changeset ID appended, so it would just be <filename "
18466 "class=\"directory\">foo</filename> in this example. To see what this looks "
18467 "like in practice, look again at the <command role=\"hg-ext-extdiff\">extdiff</"
18468 "command> example above. Notice that the diff has the snapshot directory "
18469 "names embedded in its header."
18470 msgstr ""
18472 #. type: Content of: <book><chapter><sect1><para>
18473 #: ../en/ch14-hgext.xml:322
18474 msgid ""
18475 "The <command role=\"hg-ext-extdiff\">extdiff</command> command accepts two "
18476 "important options. The <option role=\"hg-ext-extdiff-cmd-extdiff-opt\">hg -p</"
18477 "option> option lets you choose a program to view differences with, instead of "
18478 "<command>diff</command>. With the <option role=\"hg-ext-extdiff-cmd-extdiff-"
18479 "opt\">hg -o</option> option, you can change the options that <command role="
18480 "\"hg-ext-extdiff\">extdiff</command> passes to the program (by default, these "
18481 "options are <quote><literal>-Npru</literal></quote>, which only make sense if "
18482 "you're running <command>diff</command>). In other respects, the <command "
18483 "role=\"hg-ext-extdiff\">extdiff</command> command acts similarly to the built-"
18484 "in <command role=\"hg-cmd\">hg diff</command> command: you use the same "
18485 "option names, syntax, and arguments to specify the revisions you want, the "
18486 "files you want, and so on."
18487 msgstr ""
18490 #. type: Content of: <book><chapter><sect1><para>
18491 #: ../en/ch14-hgext.xml:339
18492 msgid ""
18493 "As an example, here's how to run the normal system <command>diff</command> "
18494 "command, getting it to generate context diffs (using the <option role=\"cmd-"
18495 "opt-diff\">-c</option> option) instead of unified diffs, and five lines of "
18496 "context instead of the default three (passing <literal>5</literal> as the "
18497 "argument to the <option role=\"cmd-opt-diff\">-C</option> option)."
18498 msgstr ""
18500 #. type: Content of: <book><chapter><sect1><para>
18501 #: ../en/ch14-hgext.xml:348
18502 msgid ""
18503 "Launching a visual diff tool is just as easy. Here's how to launch the "
18504 "<command>kdiff3</command> viewer."
18505 msgstr ""
18507 #. type: Content of: <book><chapter><sect1><para>
18508 #: ../en/ch14-hgext.xml:352
18509 msgid ""
18510 "If your diff viewing command can't deal with directories, you can easily work "
18511 "around this with a little scripting. For an example of such scripting in "
18512 "action with the <literal role=\"hg-ext\">mq</literal> extension and the "
18513 "<command>interdiff</command> command, see <xref linkend=\"mq-collab:tips:"
18514 "interdiff\"/>."
18515 msgstr ""
18517 #. type: Content of: <book><chapter><sect1><sect2><title>
18518 #: ../en/ch14-hgext.xml:360
18519 msgid "Defining command aliases"
18520 msgstr "定义命令的别名"
18522 #. type: Content of: <book><chapter><sect1><sect2><para>
18523 #: ../en/ch14-hgext.xml:362
18524 msgid ""
18525 "It can be cumbersome to remember the options to both the <command role=\"hg-"
18526 "ext-extdiff\">extdiff</command> command and the diff viewer you want to use, "
18527 "so the <literal role=\"hg-ext\">extdiff</literal> extension lets you define "
18528 "<emphasis>new</emphasis> commands that will invoke your diff viewer with "
18529 "exactly the right options."
18530 msgstr ""
18532 #. type: Content of: <book><chapter><sect1><sect2><para>
18533 #: ../en/ch14-hgext.xml:369
18534 msgid ""
18535 "All you need to do is edit your <filename role=\"special\">~/.hgrc</"
18536 "filename>, and add a section named <literal role=\"rc-extdiff\">extdiff</"
18537 "literal>. Inside this section, you can define multiple commands. Here's how "
18538 "to add a <literal>kdiff3</literal> command. Once you've defined this, you "
18539 "can type <quote><literal>hg kdiff3</literal></quote> and the <literal role="
18540 "\"hg-ext\">extdiff</literal> extension will run <command>kdiff3</command> for "
18541 "you."
18542 msgstr ""
18544 #. type: Content of: <book><chapter><sect1><sect2><para>
18545 #: ../en/ch14-hgext.xml:379
18546 msgid ""
18547 "If you leave the right hand side of the definition empty, as above, the "
18548 "<literal role=\"hg-ext\">extdiff</literal> extension uses the name of the "
18549 "command you defined as the name of the external program to run. But these "
18550 "names don't have to be the same. Here, we define a command named "
18551 "<quote><literal>hg wibble</literal></quote>, which runs <command>kdiff3</"
18552 "command>."
18553 msgstr ""
18555 #. type: Content of: <book><chapter><sect1><sect2><para>
18556 #: ../en/ch14-hgext.xml:389
18557 msgid ""
18558 "You can also specify the default options that you want to invoke your diff "
18559 "viewing program with. The prefix to use is <quote><literal>opts.</literal></"
18560 "quote>, followed by the name of the command to which the options apply. This "
18561 "example defines a <quote><literal>hg vimdiff</literal></quote> command that "
18562 "runs the <command>vim</command> editor's <literal>DirDiff</literal> extension."
18563 msgstr ""
18565 #. type: Content of: <book><chapter><sect1><title>
18566 #: ../en/ch14-hgext.xml:403
18567 msgid ""
18568 "Cherrypicking changes with the <literal role=\"hg-ext\">transplant</literal> "
18569 "extension"
18570 msgstr "使用扩展 <literal role=\"hg-ext\">transplant</literal> 以挑选修改"
18572 #. type: Content of: <book><chapter><sect1><para>
18573 #: ../en/ch14-hgext.xml:406
18574 msgid "Need to have a long chat with Brendan about this."
18575 msgstr ""
18577 #. type: Content of: <book><chapter><sect1><title>
18578 #: ../en/ch14-hgext.xml:410
18579 msgid ""
18580 "Send changes via email with the <literal role=\"hg-ext\">patchbomb</literal> "
18581 "extension"
18582 msgstr ""
18583 "使用扩展 <literal role=\"hg-ext\">patchbomb</literal> 通过 email 发送修改"
18585 #. type: Content of: <book><chapter><sect1><para>
18586 #: ../en/ch14-hgext.xml:413
18587 msgid ""
18588 "Many projects have a culture of <quote>change review</quote>, in which people "
18589 "send their modifications to a mailing list for others to read and comment on "
18590 "before they commit the final version to a shared repository. Some projects "
18591 "have people who act as gatekeepers; they apply changes from other people to a "
18592 "repository to which those others don't have access."
18593 msgstr ""
18595 #. type: Content of: <book><chapter><sect1><para>
18596 #: ../en/ch14-hgext.xml:421
18597 msgid ""
18598 "Mercurial makes it easy to send changes over email for review or application, "
18599 "via its <literal role=\"hg-ext\">patchbomb</literal> extension. The "
18600 "extension is so named because changes are formatted as patches, and it's "
18601 "usual to send one changeset per email message. Sending a long series of "
18602 "changes by email is thus much like <quote>bombing</quote> the recipient's "
18603 "inbox, hence <quote>patchbomb</quote>."
18604 msgstr ""
18606 #. type: Content of: <book><chapter><sect1><para>
18607 #: ../en/ch14-hgext.xml:429
18608 msgid ""
18609 "As usual, the basic configuration of the <literal role=\"hg-ext\">patchbomb</"
18610 "literal> extension takes just one or two lines in your <filename role="
18611 "\"special\"> /.hgrc</filename>."
18612 msgstr ""
18614 #. type: Content of: <book><chapter><sect1><para>
18615 #: ../en/ch14-hgext.xml:435
18616 msgid ""
18617 "Once you've enabled the extension, you will have a new command available, "
18618 "named <command role=\"hg-ext-patchbomb\">email</command>."
18619 msgstr ""
18621 #. type: Content of: <book><chapter><sect1><para>
18622 #: ../en/ch14-hgext.xml:439
18623 msgid ""
18624 "The safest and best way to invoke the <command role=\"hg-ext-patchbomb"
18625 "\">email</command> command is to <emphasis>always</emphasis> run it first "
18626 "with the <option role=\"hg-ext-patchbomb-cmd-email-opt\">hg -n</option> "
18627 "option. This will show you what the command <emphasis>would</emphasis> send, "
18628 "without actually sending anything. Once you've had a quick glance over the "
18629 "changes and verified that you are sending the right ones, you can rerun the "
18630 "same command, with the <option role=\"hg-ext-patchbomb-cmd-email-opt\">hg -n</"
18631 "option> option removed."
18632 msgstr ""
18634 #. type: Content of: <book><chapter><sect1><para>
18635 #: ../en/ch14-hgext.xml:450
18636 msgid ""
18637 "The <command role=\"hg-ext-patchbomb\">email</command> command accepts the "
18638 "same kind of revision syntax as every other Mercurial command. For example, "
18639 "this command will send every revision between 7 and <literal>tip</literal>, "
18640 "inclusive."
18641 msgstr ""
18643 #. type: Content of: <book><chapter><sect1><para>
18644 #: ../en/ch14-hgext.xml:455
18645 msgid ""
18646 "You can also specify a <emphasis>repository</emphasis> to compare with. If "
18647 "you provide a repository but no revisions, the <command role=\"hg-ext-"
18648 "patchbomb\">email</command> command will send all revisions in the local "
18649 "repository that are not present in the remote repository. If you "
18650 "additionally specify revisions or a branch name (the latter using the <option "
18651 "role=\"hg-ext-patchbomb-cmd-email-opt\">hg -b</option> option), this will "
18652 "constrain the revisions sent."
18653 msgstr ""
18655 #. type: Content of: <book><chapter><sect1><para>
18656 #: ../en/ch14-hgext.xml:464
18657 msgid ""
18658 "It's perfectly safe to run the <command role=\"hg-ext-patchbomb\">email</"
18659 "command> command without the names of the people you want to send to: if you "
18660 "do this, it will just prompt you for those values interactively. (If you're "
18661 "using a Linux or Unix-like system, you should have enhanced "
18662 "<literal>readline</literal>-style editing capabilities when entering those "
18663 "headers, too, which is useful.)"
18664 msgstr ""
18666 #. type: Content of: <book><chapter><sect1><para>
18667 #: ../en/ch14-hgext.xml:472
18668 msgid ""
18669 "When you are sending just one revision, the <command role=\"hg-ext-patchbomb"
18670 "\">email</command> command will by default use the first line of the "
18671 "changeset description as the subject of the single email message it sends."
18672 msgstr ""
18674 #. type: Content of: <book><chapter><sect1><para>
18675 #: ../en/ch14-hgext.xml:477
18676 msgid ""
18677 "If you send multiple revisions, the <command role=\"hg-ext-patchbomb\">email</"
18678 "command> command will usually send one message per changeset. It will "
18679 "preface the series with an introductory message, in which you should describe "
18680 "the purpose of the series of changes you're sending."
18681 msgstr ""
18683 #. type: Content of: <book><chapter><sect1><sect2><title>
18684 #: ../en/ch14-hgext.xml:484
18685 msgid "Changing the behavior of patchbombs"
18686 msgstr "修改 patchbomb 的行为"
18688 #. type: Content of: <book><chapter><sect1><sect2><para>
18689 #: ../en/ch14-hgext.xml:486
18690 msgid ""
18691 "Not every project has exactly the same conventions for sending changes in "
18692 "email; the <literal role=\"hg-ext\">patchbomb</literal> extension tries to "
18693 "accommodate a number of variations through command line options."
18694 msgstr ""
18696 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
18697 #: ../en/ch14-hgext.xml:492
18698 msgid ""
18699 "You can write a subject for the introductory message on the command line "
18700 "using the <option role=\"hg-ext-patchbomb-cmd-email-opt\">hg -s</option> "
18701 "option. This takes one argument, the text of the subject to use."
18702 msgstr ""
18704 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
18705 #: ../en/ch14-hgext.xml:498
18706 msgid ""
18707 "To change the email address from which the messages originate, use the "
18708 "<option role=\"hg-ext-patchbomb-cmd-email-opt\">hg -f</option> option. This "
18709 "takes one argument, the email address to use."
18710 msgstr ""
18712 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
18713 #: ../en/ch14-hgext.xml:504
18714 msgid ""
18715 "The default behavior is to send unified diffs (see <xref linkend=\"sec:mq:"
18716 "patch\"/> for a description of the format), one per message. You can send a "
18717 "binary bundle instead with the <option role=\"hg-ext-patchbomb-cmd-email-opt"
18718 "\">hg -b</option> option."
18719 msgstr ""
18721 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
18722 #: ../en/ch14-hgext.xml:512
18723 msgid ""
18724 "Unified diffs are normally prefaced with a metadata header. You can omit "
18725 "this, and send unadorned diffs, with the <option role=\"hg-ext-patchbomb-cmd-"
18726 "email-opt\">hg --plain</option> option."
18727 msgstr ""
18729 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
18730 #: ../en/ch14-hgext.xml:518
18731 msgid ""
18732 "Diffs are normally sent <quote>inline</quote>, in the same body part as the "
18733 "description of a patch. This makes it easiest for the largest number of "
18734 "readers to quote and respond to parts of a diff, as some mail clients will "
18735 "only quote the first MIME body part in a message. If you'd prefer to send the "
18736 "description and the diff in separate body parts, use the <option role=\"hg-"
18737 "ext-patchbomb-cmd-email-opt\">hg -a</option> option."
18738 msgstr ""
18740 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
18741 #: ../en/ch14-hgext.xml:528
18742 msgid ""
18743 "Instead of sending mail messages, you can write them to an <literal>mbox</"
18744 "literal>-format mail folder using the <option role=\"hg-ext-patchbomb-cmd-"
18745 "email-opt\">hg -m</option> option. That option takes one argument, the name "
18746 "of the file to write to."
18747 msgstr ""
18749 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
18750 #: ../en/ch14-hgext.xml:535
18751 msgid ""
18752 "If you would like to add a <command>diffstat</command>-format summary to each "
18753 "patch, and one to the introductory message, use the <option role=\"hg-ext-"
18754 "patchbomb-cmd-email-opt\">hg -d</option> option. The <command>diffstat</"
18755 "command> command displays a table containing the name of each file patched, "
18756 "the number of lines affected, and a histogram showing how much each file is "
18757 "modified. This gives readers a qualitative glance at how complex a patch is."
18758 msgstr ""