hgbook

view po/zh.po @ 1102:77fa81a32f2e

2.7.5 zh translated ,1 fuzzy
author Zhaoping Sun <zhaopingsun@gmail.com>
date Wed Nov 25 21:51:40 2009 -0500 (2009-11-25)
parents 5b6b0d5fc1b8
children b6bb5b383887
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 ""
2116 "我的孩子Cian和Ruairi总是站在我旁边帮我解决奇妙的疯狂小男孩游戏。我同样也要感谢"
2117 "我的前妻Shannon的帮助。"
2119 #. type: Content of: <book><preface><sect1><para>
2120 #: ../en/ch00-preface.xml:56
2121 msgid ""
2122 "My colleagues and friends provided help and support in innumerable ways. "
2123 "This list of people is necessarily very incomplete: Stephen Hahn, Karyn "
2124 "Ritter, Bonnie Corwin, James Vasile, Matt Norwood, Eben Moglen, Bradley Kuhn, "
2125 "Robert Walsh, Jeremy Fitzhardinge, Rachel Chalmers."
2126 msgstr ""
2127 "我的同事和朋友以各种方式提供了帮助和支持,这里的名单非常不全:Stephen Hahn, "
2128 "Karyn Ritter, Bonnie Corwin, James Vasile, Matt Norwood, Eben Moglen, Bradley "
2129 "Kuhn, Robert Walsh, Jeremy Fitzhardinge, Rachel Chalmers."
2131 #. type: Content of: <book><preface><sect1><para>
2132 #: ../en/ch00-preface.xml:62
2133 msgid ""
2134 "I developed this book in the open, posting drafts of chapters to the book web "
2135 "site as I completed them. Readers then submitted feedback using a web "
2136 "application that I developed. By the time I finished writing the book, more "
2137 "than 100 people had submitted comments, an amazing number considering that "
2138 "the comment system was live for only about two months towards the end of the "
2139 "writing process."
2140 msgstr ""
2141 "我以开放的方式完成了本书,当我完成各章的草稿后,就将其放在了网上。读者可以使用"
2142 "我开发的一个网络程序提交反馈。到我完成本书时,有100多人提交了评论。考虑到评论"
2143 "系统是在写作完成之前两个月才开放的,这是一个惊人的数字。"
2145 #. type: Content of: <book><preface><sect1><para>
2146 #: ../en/ch00-preface.xml:70
2147 msgid ""
2148 "I would particularly like to recognize the following people, who between them "
2149 "contributed over a third of the total number of comments. I would like to "
2150 "thank them for their care and effort in providing so much detailed feedback."
2151 msgstr ""
2152 "我特别希望认识以下人员,他们中有的人提交了超过总数三分之一的评论。我要感谢他们"
2153 "的关心和努力,提供了那么多详细的反馈。"
2155 #. type: Content of: <book><preface><sect1><para>
2156 #: ../en/ch00-preface.xml:75
2157 msgid ""
2158 "Martin Geisler, Damien Cassou, Alexey Bakhirkin, Till Plewe, Dan Himes, Paul "
2159 "Sargent, Gokberk Hamurcu, Matthijs van der Vleuten, Michael Chermside, John "
2160 "Mulligan, Jordi Fita, Jon Parise."
2161 msgstr ""
2163 #. type: Content of: <book><preface><sect1><para>
2164 #: ../en/ch00-preface.xml:80
2165 msgid ""
2166 "I also want to acknowledge the help of the many people who caught errors and "
2167 "provided helpful suggestions throughout the book."
2168 msgstr "我同样要感谢许多在书中找出错误和提供了有帮助的建议的人。"
2170 #. type: Content of: <book><preface><sect1><para>
2171 #: ../en/ch00-preface.xml:84
2172 msgid ""
2173 "Jeremy W. Sherman, Brian Mearns, Vincent Furia, Iwan Luijks, Billy Edwards, "
2174 "Andreas Sliwka, Paweł Sołyga, Eric Hanchrow, Steve Nicolai, Michał Masłowski, "
2175 "Kevin Fitch, Johan Holmberg, Hal Wine, Volker Simonis, Thomas P Jakobsen, Ted "
2176 "Stresen-Reuter, Stephen Rasku, Raphael Das Gupta, Ned Batchelder, Lou Keeble, "
2177 "Li Linxiao, Kao Cardoso Félix, Joseph Wecker, Jon Prescot, Jon Maken, John "
2178 "Yeary, Jason Harris, Geoffrey Zheng, Fredrik Jonson, Ed Davies, David "
2179 "Zumbrunnen, David Mercer, David Cabana, Ben Karel, Alan Franzoni, Yousry "
2180 "Abdallah, Whitney Young, Vinay Sajip, Tom Towle, Tim Ottinger, Thomas "
2181 "Schraitle, Tero Saarni, Ted Mielczarek, Svetoslav Agafonkin, Shaun Rowland, "
2182 "Rocco Rutte, Polo-Francois Poli, Philip Jenvey, Petr Tesałék, Peter R. "
2183 "Annema, Paul Bonser, Olivier Scherler, Olivier Fournier, Nick Parker, Nick "
2184 "Fabry, Nicholas Guarracino, Mike Driscoll, Mike Coleman, Mietek Bák, Michael "
2185 "Maloney, László Nagy, Kent Johnson, Julio Nobrega, Jord Fita, Jonathan March, "
2186 "Jonas Nockert, Jim Tittsler, Jeduan Cornejo Legorreta, Jan Larres, James "
2187 "Murphy, Henri Wiechers, Hagen Möbius, Gábor Farkas, Fabien Engels, Evert Rol, "
2188 "Evan Willms, Eduardo Felipe Castegnaro, Dennis Decker Jensen, Deniz Dogan, "
2189 "David Smith, Daed Lee, Christine Slotty, Charles Merriam, Guillaume Catto, "
2190 "Brian Dorsey, Bob Nystrom, Benoit Boissinot, Avi Rosenschein, Andrew Watts, "
2191 "Andrew Donkin, Alexey Rodriguez, Ahmed Chaudhary."
2192 msgstr ""
2194 #. type: Content of: <book><preface><sect1><title>
2195 #: ../en/ch00-preface.xml:111
2196 msgid "Conventions Used in This Book"
2197 msgstr "本书的约定"
2199 #. type: Content of: <book><preface><sect1><para>
2200 #: ../en/ch00-preface.xml:113
2201 msgid "The following typographical conventions are used in this book:"
2202 msgstr "本书使用如下的印刷约定:"
2204 #. type: Content of: <book><preface><sect1><variablelist><varlistentry><term>
2205 #: ../en/ch00-preface.xml:118
2206 msgid "Italic"
2207 msgstr "斜体"
2209 #. type: Content of: <book><preface><sect1><variablelist><varlistentry><listitem><para>
2210 #: ../en/ch00-preface.xml:121
2211 msgid ""
2212 "Indicates new terms, URLs, email addresses, filenames, and file extensions."
2213 msgstr "标识新术语,URL,电子邮件地址,文件名称与扩展名。"
2215 #. type: Content of: <book><preface><sect1><variablelist><varlistentry><term>
2216 #: ../en/ch00-preface.xml:127
2217 msgid "<literal>Constant width</literal>"
2218 msgstr "<literal>等宽</literal>"
2220 #. type: Content of: <book><preface><sect1><variablelist><varlistentry><listitem><para>
2221 #: ../en/ch00-preface.xml:130
2222 msgid ""
2223 "Used for program listings, as well as within paragraphs to refer to program "
2224 "elements such as variable or function names, databases, data types, "
2225 "environment variables, statements, and keywords."
2226 msgstr ""
2227 "用于程序列表,以及段内引用的程序元素,例如变量、函数名称、数据库、数据类型、环"
2228 "境变量、声明和关键字。"
2230 #. type: Content of: <book><preface><sect1><variablelist><varlistentry><term>
2231 #: ../en/ch00-preface.xml:138
2232 msgid "<userinput>Constant width bold</userinput>"
2233 msgstr "<userinput>等宽粗体</userinput>"
2235 #. type: Content of: <book><preface><sect1><variablelist><varlistentry><listitem><para>
2236 #: ../en/ch00-preface.xml:141
2237 msgid "Shows commands or other text that should be typed literally by the user."
2238 msgstr "标识命令或者其它用户应该逐字输入的文本。"
2240 #. type: Content of: <book><preface><sect1><variablelist><varlistentry><term>
2241 #: ../en/ch00-preface.xml:147
2242 msgid "<replaceable>Constant width italic</replaceable>"
2243 msgstr "<replaceable>等宽斜体</replaceable>"
2245 #. type: Content of: <book><preface><sect1><variablelist><varlistentry><listitem><para>
2246 #: ../en/ch00-preface.xml:150
2247 msgid ""
2248 "Shows text that should be replaced with user-supplied values or by values "
2249 "determined by context."
2250 msgstr "标识应该被用户提供的值或者取决于上下文的值替换的文本。"
2252 #. type: Content of: <book><preface><sect1><tip><para>
2253 #: ../en/ch00-preface.xml:157
2254 msgid "This icon signifies a tip, suggestion, or general note."
2255 msgstr "此图标表示提示,建议或者一般的的注释。"
2257 #. type: Content of: <book><preface><sect1><caution><para>
2258 #: ../en/ch00-preface.xml:162
2259 msgid "This icon indicates a warning or caution."
2260 msgstr "此图标表示警告。"
2262 #. type: Content of: <book><preface><sect1><title>
2263 #: ../en/ch00-preface.xml:167
2264 msgid "Using Code Examples"
2265 msgstr "使用样例代码"
2267 #. type: Content of: <book><preface><sect1><para>
2268 #: ../en/ch00-preface.xml:169
2269 msgid ""
2270 "This book is here to help you get your job done. In general, you may use the "
2271 "code in this book in your programs and documentation. You do not need to "
2272 "contact us for permission unless you’re reproducing a significant portion of "
2273 "the code. For example, writing a program that uses several chunks of code "
2274 "from this book does not require permission. Selling or distributing a CD-ROM "
2275 "of examples from O’Reilly books does require permission. Answering a "
2276 "question by citing this book and quoting example code does not require "
2277 "permission. Incorporating a significant amount of example code from this book "
2278 "into your product’s documentation does require permission."
2279 msgstr ""
2280 "本书的目的是帮助你完成工作。基本上,你可以将书中的代码用于你的程序或文档。无需"
2281 "取得我们的许可,除非你直接复制大量的代码。举例来说,在程序中使用几段书中的代码"
2282 "无需许可。出售或发布含有O'Reilly书中示例的CD-ROM则需经许可。引用本书中的叙述或"
2283 "示例代码来回答问题无需许可。将书中的大量代码合并到你的产品文档中则需经许可。"
2285 #. type: Content of: <book><preface><sect1><para>
2286 #: ../en/ch00-preface.xml:181
2287 msgid ""
2288 "We appreciate, but do not require, attribution. An attribution usually "
2289 "includes the title, author, publisher, and ISBN. For example: “<emphasis>Book "
2290 "Title</emphasis> by Some Author. Copyright 2008 O’Reilly Media, Inc., 978-0-"
2291 "596-xxxx-x.”"
2292 msgstr ""
2293 "虽然我们并不要求在引用本书的时候做版权归属声明,但如果你这样做了,我们将非常感"
2294 "激。版权归属声明通常包含标题,作者,发行者和ISBN。例如: “<emphasis>书名</"
2295 "emphasis> 某人著。 版权所有 2008 O’Reilly Media,Inc., 978-0-596-xxxx-x。”"
2297 #. type: Content of: <book><preface><sect1><para>
2298 #: ../en/ch00-preface.xml:187
2299 msgid ""
2300 "If you feel your use of code examples falls outside fair use or the "
2301 "permission given above, feel free to contact us at <email>permissions@oreilly."
2302 "com</email>."
2303 msgstr ""
2304 "如果你觉得你对书中示例代码的使用超出了正常范围,或者不符合以上描述的许可,尽管"
2305 "用电子邮件跟我们联系:<email>permissions@oreilly.com</email>。"
2307 #. type: Content of: <book><preface><sect1><title>
2308 #: ../en/ch00-preface.xml:193
2309 msgid "Safari® Books Online"
2310 msgstr "Safari® 在线书库"
2312 #. type: Content of: <book><preface><sect1><note><para>
2313 #: ../en/ch00-preface.xml:196
2314 msgid ""
2315 "When you see a Safari® Books Online icon on the cover of your favorite "
2316 "technology book, that means the book is available online through the O’Reilly "
2317 "Network Safari Bookshelf."
2318 msgstr ""
2319 "如果你在喜欢的技术图书的封面上看见Safari® Books Online的图标,这表示你你可以通"
2320 "过O'Reilly Network Safari Bookshelf在网上使用此书。"
2322 #. type: Content of: <book><preface><sect1><para>
2323 #: ../en/ch00-preface.xml:202
2324 msgid ""
2325 "Safari offers a solution that’s better than e-books. It’s a virtual library "
2326 "that lets you easily search thousands of top tech books, cut and paste code "
2327 "samples, download chapters, and find quick answers when you need the most "
2328 "accurate, current information. Try it for free at <ulink role=\"orm:hideurl:"
2329 "ital\" url=\"http://my.safaribooksonline.com/?portal=oreilly\">http://my."
2330 "safaribooksonline.com</ulink>."
2331 msgstr ""
2332 "Safari提供了一个比电子书更好的解决方案。它是一所虚拟图书馆,你可以在上面轻松搜"
2333 "索上千种顶级的技术书籍,剪切和复制示例代码,下载章节,当你需要最准确、最新的信"
2334 "息时,让你更快地找到答案。可以通过下面链接免费试用<ulink role=\"orm:hideurl:"
2335 "ital\" url=\"http://my.safaribooksonline.com/?portal=oreilly\">http://my."
2336 "safaribooksonline.com</ulink>。"
2338 #. type: Content of: <book><preface><sect1><title>
2339 #: ../en/ch00-preface.xml:211
2340 msgid "How to Contact Us"
2341 msgstr "联系我们"
2343 #. type: Content of: <book><preface><sect1><para>
2344 #: ../en/ch00-preface.xml:213
2345 msgid ""
2346 "Please address comments and questions concerning this book to the publisher:"
2347 msgstr "关于本书的任何问题或评论请发邮件给出版商:"
2349 #. type: Content of: <book><preface><sect1><simplelist><member>
2350 #: ../en/ch00-preface.xml:217
2351 msgid "O’Reilly Media, Inc."
2352 msgstr ""
2354 #. type: Content of: <book><preface><sect1><simplelist><member>
2355 #: ../en/ch00-preface.xml:219
2356 msgid "1005 Gravenstein Highway North"
2357 msgstr ""
2359 #. type: Content of: <book><preface><sect1><simplelist><member>
2360 #: ../en/ch00-preface.xml:221
2361 msgid "Sebastopol, CA 95472"
2362 msgstr ""
2364 #. type: Content of: <book><preface><sect1><simplelist><member>
2365 #: ../en/ch00-preface.xml:223
2366 msgid "800-998-9938 (in the United States or Canada)"
2367 msgstr ""
2369 #. type: Content of: <book><preface><sect1><simplelist><member>
2370 #: ../en/ch00-preface.xml:225
2371 msgid "707-829-0515 (international or local)"
2372 msgstr ""
2374 #. type: Content of: <book><preface><sect1><simplelist><member>
2375 #: ../en/ch00-preface.xml:227
2376 msgid "707 829-0104 (fax)"
2377 msgstr ""
2379 #. type: Content of: <book><preface><sect1><para>
2380 #: ../en/ch00-preface.xml:230
2381 msgid ""
2382 "We have a web page for this book, where we list errata, examples, and any "
2383 "additional information. You can access this page at:"
2384 msgstr ""
2385 "我们将提供一个关于本书的主页,在那上面提供勘误表、示例以及其它附加信息。你可以"
2386 "从这里访问到它:"
2388 #. type: Content of: <book><preface><sect1><simplelist><member>
2389 #: ../en/ch00-preface.xml:235
2390 msgid ""
2391 "<ulink url=\"http://www.oreilly.com/catalog/&lt;catalog page&gt;\"></ulink>"
2392 msgstr ""
2394 #. type: Content of: <book><preface><sect1><remark>
2395 #: ../en/ch00-preface.xml:239
2396 msgid "Don’t forget to update the &lt;url&gt; attribute, too."
2397 msgstr ""
2399 #. type: Content of: <book><preface><sect1><para>
2400 #: ../en/ch00-preface.xml:242
2401 msgid "To comment or ask technical questions about this book, send email to:"
2402 msgstr "关于本书的任何技术问题或评论请发邮件给出版商:"
2404 #. type: Content of: <book><preface><sect1><simplelist><member>
2405 #: ../en/ch00-preface.xml:246
2406 msgid "<email>bookquestions@oreilly.com</email>"
2407 msgstr "<email>bookquestions@oreilly.com</email>"
2409 #. type: Content of: <book><preface><sect1><para>
2410 #: ../en/ch00-preface.xml:249
2411 msgid ""
2412 "For more information about our books, conferences, Resource Centers, and the "
2413 "O’Reilly Network, see our web site at:"
2414 msgstr ""
2415 "如果想了解关于我们的图书、会议、资源中心以及O'Reilly Network的更多信息,可以浏"
2416 "览以下站点:"
2418 #. type: Content of: <book><preface><sect1><simplelist><member>
2419 #: ../en/ch00-preface.xml:253
2420 msgid "<ulink url=\"http://www.oreilly.com\"></ulink>"
2421 msgstr "<ulink url=\"http://www.oreilly.com\"></ulink>"
2423 #. type: Content of: <book><chapter><title>
2424 #: ../en/ch01-intro.xml:5
2425 msgid "How did we get here?"
2426 msgstr "写在前面"
2428 #. type: Content of: <book><chapter><sect1><title>
2429 #: ../en/ch01-intro.xml:8
2430 msgid "Why revision control? Why Mercurial?"
2431 msgstr "为什么使用版本控制? 为什么使用 Mercurial?"
2433 #. type: Content of: <book><chapter><sect1><para>
2434 #: ../en/ch01-intro.xml:10
2435 msgid ""
2436 "Revision control is the process of managing multiple versions of a piece of "
2437 "information. In its simplest form, this is something that many people do by "
2438 "hand: every time you modify a file, save it under a new name that contains a "
2439 "number, each one higher than the number of the preceding version."
2440 msgstr ""
2441 "版本控制是管理一些信息的多个版本的过程。它最简单的形式莫过于:每次你修改一个文"
2442 "件后都重新命名保存,文件名中包含一个数字,每次修改后这个数字都增加。这通常是许"
2443 "多人手工完成的。"
2445 #. type: Content of: <book><chapter><sect1><para>
2446 #: ../en/ch01-intro.xml:16
2447 msgid ""
2448 "Manually managing multiple versions of even a single file is an error-prone "
2449 "task, though, so software tools to help automate this process have long been "
2450 "available. The earliest automated revision control tools were intended to "
2451 "help a single user to manage revisions of a single file. Over the past few "
2452 "decades, the scope of revision control tools has expanded greatly; they now "
2453 "manage multiple files, and help multiple people to work together. The best "
2454 "modern revision control tools have no problem coping with thousands of people "
2455 "working together on projects that consist of hundreds of thousands of files."
2456 msgstr ""
2457 "然而,手工管理即使是一个文件的多个版本也是很容易出错的,所以很早就有软件工具来"
2458 "使这个过程自动化。最早的自动化软件管理工具的目标是帮助一个用户管理一个文件的版"
2459 "本。在过去的几十年里,版本控制工具的范围得到极大扩展;现在它们可以管理多个文"
2460 "件,帮助许多人一起工作。最新的版本控制工具可以支持上包含成数十万个文件,几千个"
2461 "人一起工作的项目。"
2463 #. type: Content of: <book><chapter><sect1><para>
2464 #: ../en/ch01-intro.xml:27
2465 msgid ""
2466 "The arrival of distributed revision control is relatively recent, and so far "
2467 "this new field has grown due to people's willingness to explore ill-charted "
2468 "territory."
2469 msgstr ""
2470 "分布式版本控制是最近才出现的,但是由于人们愿意探索新的疆域,目前这一新的领域已"
2471 "经得到了长足的发展"
2473 #. type: Content of: <book><chapter><sect1><para>
2474 #: ../en/ch01-intro.xml:31
2475 msgid ""
2476 "I am writing a book about distributed revision control because I believe that "
2477 "it is an important subject that deserves a field guide. I chose to write "
2478 "about Mercurial because it is the easiest tool to learn the terrain with, and "
2479 "yet it scales to the demands of real, challenging environments where many "
2480 "other revision control tools buckle."
2481 msgstr ""
2482 "我写这本关于分布式版本控制的书是因为我相信这个领域应该有一个指南。我选择"
2483 "Mercurial是因为它是在这个领域中学习最容易上手的工具,并且它能够满足真实的,挑"
2484 "战性的环境的要求,而其他版本控制工具只能望而兴叹。"
2486 #. type: Content of: <book><chapter><sect1><sect2><title>
2487 #: ../en/ch01-intro.xml:39
2488 msgid "Why use revision control?"
2489 msgstr "为什么使用版本控制?"
2491 #. type: Content of: <book><chapter><sect1><sect2><para>
2492 #: ../en/ch01-intro.xml:41
2493 msgid ""
2494 "There are a number of reasons why you or your team might want to use an "
2495 "automated revision control tool for a project."
2496 msgstr ""
2497 "为什么你或者你的团队可能需要在项目中使用自动化版本控制工具呢?有很多理由。"
2499 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2500 #: ../en/ch01-intro.xml:46
2501 msgid ""
2502 "It will track the history and evolution of your project, so you don't have "
2503 "to. For every change, you'll have a log of <emphasis>who</emphasis> made it; "
2504 "<emphasis>why</emphasis> they made it; <emphasis>when</emphasis> they made "
2505 "it; and <emphasis>what</emphasis> the change was."
2506 msgstr ""
2507 "因为它能记录你的项目的历史和演化,所以你不必再给每个变更都记录日志,<emphasis>"
2508 "谁</emphasis>做的;<emphasis>为什么</emphasis>他们这样做;<emphasis>什么时候</"
2509 "emphasis>做的;做了<emphasis>什么</emphasis>修改。"
2511 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2512 #: ../en/ch01-intro.xml:53
2513 msgid ""
2514 "When you're working with other people, revision control software makes it "
2515 "easier for you to collaborate. For example, when people more or less "
2516 "simultaneously make potentially incompatible changes, the software will help "
2517 "you to identify and resolve those conflicts."
2518 msgstr ""
2519 "当你和其他人一起工作的时候,版本控制工具让你合作的更容易。例如,当许多人或多或"
2520 "少的同时进行有可能冲突的修改的时候,软件可以帮助你确定和解决这些冲突。"
2522 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2523 #: ../en/ch01-intro.xml:59
2524 msgid ""
2525 "It can help you to recover from mistakes. If you make a change that later "
2526 "turns out to be in error, you can revert to an earlier version of one or more "
2527 "files. In fact, a <emphasis>really</emphasis> good revision control tool "
2528 "will even help you to efficiently figure out exactly when a problem was "
2529 "introduced (see <xref linkend=\"sec:undo:bisect\"/> for details)."
2530 msgstr ""
2531 "它能帮助你修正错误。如果你做了一个修改,但是后来发现这是个错误,你能恢复到一个"
2532 "或者多个文件以前的版本。实际上,一个<emphasis>相当</emphasis>好的版本控制工具"
2533 "甚至会帮助你找出什么什么是时候引入的这个问题(详细信息参考<xref linkend=\"sec:"
2534 "undo:bisect\"/>)。 "
2536 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2537 #: ../en/ch01-intro.xml:66
2538 msgid ""
2539 "It will help you to work simultaneously on, and manage the drift between, "
2540 "multiple versions of your project."
2541 msgstr "它能帮助你同时工作于项目的多个版本,并管理它们的差异。"
2543 #. type: Content of: <book><chapter><sect1><sect2><para>
2544 #: ../en/ch01-intro.xml:71
2545 msgid ""
2546 "Most of these reasons are equally valid&emdash;at least in theory&emdash;"
2547 "whether you're working on a project by yourself, or with a hundred other "
2548 "people."
2549 msgstr ""
2550 "大多数这些理由都是等效的&emdash;至少在理论上&emdash;不管你是一个人做项目还是和"
2551 "几百个人一起。"
2553 #. type: Content of: <book><chapter><sect1><sect2><para>
2554 #: ../en/ch01-intro.xml:76
2555 msgid ""
2556 "A key question about the practicality of revision control at these two "
2557 "different scales (<quote>lone hacker</quote> and <quote>huge team</quote>) is "
2558 "how its <emphasis>benefits</emphasis> compare to its <emphasis>costs</"
2559 "emphasis>. A revision control tool that's difficult to understand or use is "
2560 "going to impose a high cost."
2561 msgstr ""
2562 "版本控制在在不同尺度上(<quote>单个黑客</quote>和<quote>一个大项目组</quote>)"
2563 "实践的一个关键问题是它的<emphasis>性价</emphasis>比怎么样。一个很难理解和使用"
2564 "的版本控制工具会让你的代价很高。"
2566 #. type: Content of: <book><chapter><sect1><sect2><para>
2567 #: ../en/ch01-intro.xml:84
2568 msgid ""
2569 "A five-hundred-person project is likely to collapse under its own weight "
2570 "almost immediately without a revision control tool and process. In this case, "
2571 "the cost of using revision control might hardly seem worth considering, since "
2572 "<emphasis>without</emphasis> it, failure is almost guaranteed."
2573 msgstr ""
2574 "如果没有版本控制工具和过程,一个五百人的项目很快就可能就将自己压垮。在这种情况"
2575 "下,版本控制的代价基本上不用考虑,因为没有它,失败几乎是一定的。"
2577 #. type: Content of: <book><chapter><sect1><sect2><para>
2578 #: ../en/ch01-intro.xml:91
2579 msgid ""
2580 "On the other hand, a one-person <quote>quick hack</quote> might seem like a "
2581 "poor place to use a revision control tool, because surely the cost of using "
2582 "one must be close to the overall cost of the project. Right?"
2583 msgstr ""
2584 "另一方面,一个人的<quote>快速编程</quote>看起来并不适合使用版本控制工具,因为"
2585 "使用一个版本控制工具的代价就是整个项目的代价,对吧?"
2587 #. type: Content of: <book><chapter><sect1><sect2><para>
2588 #: ../en/ch01-intro.xml:96
2589 msgid ""
2590 "Mercurial uniquely supports <emphasis>both</emphasis> of these scales of "
2591 "development. You can learn the basics in just a few minutes, and due to its "
2592 "low overhead, you can apply revision control to the smallest of projects with "
2593 "ease. Its simplicity means you won't have a lot of abstruse concepts or "
2594 "command sequences competing for mental space with whatever you're "
2595 "<emphasis>really</emphasis> trying to do. At the same time, Mercurial's high "
2596 "performance and peer-to-peer nature let you scale painlessly to handle large "
2597 "projects."
2598 msgstr ""
2599 "Mercurial的独特之处就是它<emphasis>同时</emphasis>支持这两种尺度的开发。你可以"
2600 "在几分钟之内学会基本的使用,因为代价很小,你可以很方便的在最小的项目上应用版本"
2601 "管理。它的简洁性意味着不会有很多艰深的概念和命令干扰你<emphasis>真正</"
2602 "emphasis>的工作。同时,Mercurial高性能和点对点的特性可以让你轻易的应对大的项"
2603 "目。"
2605 #. type: Content of: <book><chapter><sect1><sect2><para>
2606 #: ../en/ch01-intro.xml:106
2607 msgid ""
2608 "No revision control tool can rescue a poorly run project, but a good choice "
2609 "of tools can make a huge difference to the fluidity with which you can work "
2610 "on a project."
2611 msgstr ""
2612 "没有一个版本控制工具能拯救一个糟糕的项目,但是在项目中选择好的工具会大大的提高"
2613 "效率,正是工欲善其事,必先利其器。"
2615 #. type: Content of: <book><chapter><sect1><sect2><title>
2616 #: ../en/ch01-intro.xml:113
2617 msgid "The many names of revision control"
2618 msgstr "版本控制的别名"
2620 #. type: Content of: <book><chapter><sect1><sect2><para>
2621 #: ../en/ch01-intro.xml:115
2622 msgid ""
2623 "Revision control is a diverse field, so much so that it is referred to by "
2624 "many names and acronyms. Here are a few of the more common variations you'll "
2625 "encounter:"
2626 msgstr ""
2627 "版本控制是一个各自为政的领域,以至于有很多名称和缩略语,下面是你可能遇到的一些"
2628 "常用的术语:"
2630 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2631 #: ../en/ch01-intro.xml:119
2632 msgid "Revision control (RCS)"
2633 msgstr "版本控制(RCS)"
2635 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2636 #: ../en/ch01-intro.xml:120
2637 msgid "Software configuration management (SCM), or configuration management"
2638 msgstr "软件配置管理(SCM),或配置管理"
2640 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2641 #: ../en/ch01-intro.xml:122
2642 msgid "Source code management"
2643 msgstr "源代码管理"
2645 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2646 #: ../en/ch01-intro.xml:123
2647 msgid "Source code control, or source control"
2648 msgstr "源代码控制,或源控制"
2650 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2651 #: ../en/ch01-intro.xml:125
2652 msgid "Version control (VCS)"
2653 msgstr "版本控制(VCS)"
2655 #. type: Content of: <book><chapter><sect1><sect2><para>
2656 #: ../en/ch01-intro.xml:127
2657 msgid ""
2658 "Some people claim that these terms actually have different meanings, but in "
2659 "practice they overlap so much that there's no agreed or even useful way to "
2660 "tease them apart."
2661 msgstr ""
2662 "有些人声称这些术语有不同的含义,但实际上它们的含义太重叠了,根本没有一致的,甚"
2663 "至有用的方式来区别它们。"
2665 #. type: Content of: <book><chapter><sect1><title>
2666 #: ../en/ch01-intro.xml:135
2667 msgid "About the examples in this book"
2668 msgstr "本书的例子"
2670 #. type: Content of: <book><chapter><sect1><para>
2671 #: ../en/ch01-intro.xml:137
2672 msgid ""
2673 "This book takes an unusual approach to code samples. Every example is "
2674 "<quote>live</quote>&emdash;each one is actually the result of a shell script "
2675 "that executes the Mercurial commands you see. Every time an image of the "
2676 "book is built from its sources, all the example scripts are automatically "
2677 "run, and their current results compared against their expected results."
2678 msgstr ""
2679 "本书采用了一种非同寻常的示例编程方法。每个例子都是<quote>活的</quote>&emdash;"
2680 "每一个示例都是一个shell脚本执行的实际结果,这个脚本执行了你看到的Mercurial命"
2681 "令。每次从源代码构建本书的映像时,所有的示例脚本都自动执行,然后将预期结果和实"
2682 "际执行结果比较。"
2684 #. type: Content of: <book><chapter><sect1><para>
2685 #: ../en/ch01-intro.xml:144
2686 msgid ""
2687 "The advantage of this approach is that the examples are always accurate; they "
2688 "describe <emphasis>exactly</emphasis> the behavior of the version of "
2689 "Mercurial that's mentioned at the front of the book. If I update the version "
2690 "of Mercurial that I'm documenting, and the output of some command changes, "
2691 "the build fails."
2692 msgstr ""
2693 "这种方法的优点是每个例子都是永远精确的,它们是本书前面描述的Mercurial版本的"
2694 "<emphasis>实际</emphasis>运行结果。如果我更新了描述的Mercurial的版本,同时有些"
2695 "命令的输出变化了,创建就会失败。"
2697 #. type: Content of: <book><chapter><sect1><para>
2698 #: ../en/ch01-intro.xml:151
2699 msgid ""
2700 "There is a small disadvantage to this approach, which is that the dates and "
2701 "times you'll see in examples tend to be <quote>squashed</quote> together in a "
2702 "way that they wouldn't be if the same commands were being typed by a human. "
2703 "Where a human can issue no more than one command every few seconds, with any "
2704 "resulting timestamps correspondingly spread out, my automated example scripts "
2705 "run many commands in one second."
2706 msgstr ""
2707 "这种方法也有小的缺点,就是你在示例中看见的日期和时间被<quote>压缩</quote>了,"
2708 "看起来这些命令不是人输入的。人不可能再一秒之内执行一条以上的命令,相应的时间戳"
2709 "都应该展开,我的自动化脚本中一秒之内可以执行很多命令。"
2711 #. type: Content of: <book><chapter><sect1><para>
2712 #: ../en/ch01-intro.xml:159
2713 msgid ""
2714 "As an instance of this, several consecutive commits in an example can show up "
2715 "as having occurred during the same second. You can see this occur in the "
2716 "<literal role=\"hg-ext\">bisect</literal> example in <xref linkend=\"sec:undo:"
2717 "bisect\"/>, for instance."
2718 msgstr ""
2719 "举例来说,示例中的几个连续的提交可能显示发生于同一秒之内。你可以在<literal "
2720 "role=\"hg-ext\">bisect</literal> 示例中看到例子<xref linkend=\"sec:undo:bisect"
2721 "\"/>。"
2723 #. type: Content of: <book><chapter><sect1><para>
2724 #: ../en/ch01-intro.xml:165
2725 msgid ""
2726 "So when you're reading examples, don't place too much weight on the dates or "
2727 "times you see in the output of commands. But <emphasis>do</emphasis> be "
2728 "confident that the behavior you're seeing is consistent and reproducible."
2729 msgstr ""
2730 "所以当你研究这些例子的时候,不要太注意命令输出的日期和时间。但是<emphasis>要</"
2731 "emphasis>保证你看到的结果是一致的和可以再现的。"
2733 #. type: Content of: <book><chapter><sect1><title>
2734 #: ../en/ch01-intro.xml:173
2735 msgid "Trends in the field"
2736 msgstr "版本控制的发展趋势"
2738 #. type: Content of: <book><chapter><sect1><para>
2739 #: ../en/ch01-intro.xml:175
2740 msgid ""
2741 "There has been an unmistakable trend in the development and use of revision "
2742 "control tools over the past four decades, as people have become familiar with "
2743 "the capabilities of their tools and constrained by their limitations."
2744 msgstr ""
2745 "在过去的四十年中,随着人们越来越熟悉他们的工具的能力和限制,开发和使用版本控制"
2746 "工具出现了明确的趋势。 "
2748 #. type: Content of: <book><chapter><sect1><para>
2749 #: ../en/ch01-intro.xml:180
2750 msgid ""
2751 "The first generation began by managing single files on individual computers. "
2752 "Although these tools represented a huge advance over ad-hoc manual revision "
2753 "control, their locking model and reliance on a single computer limited them "
2754 "to small, tightly-knit teams."
2755 msgstr ""
2756 "第一代软件开始于在个人计算机,人们用这些软件管理单个文件。虽然这些工具比手工管"
2757 "理版本有了巨大的飞跃。但是加锁模型和依赖于单个计算机限制了他们使用范围,只用于"
2758 "小的,组织严密的团队。"
2760 #. type: Content of: <book><chapter><sect1><para>
2761 #: ../en/ch01-intro.xml:186
2762 msgid ""
2763 "The second generation loosened these constraints by moving to network-"
2764 "centered architectures, and managing entire projects at a time. As projects "
2765 "grew larger, they ran into new problems. With clients needing to talk to "
2766 "servers very frequently, server scaling became an issue for large projects. "
2767 "An unreliable network connection could prevent remote users from being able "
2768 "to talk to the server at all. As open source projects started making read-"
2769 "only access available anonymously to anyone, people without commit privileges "
2770 "found that they could not use the tools to interact with a project in a "
2771 "natural way, as they could not record their changes."
2772 msgstr ""
2773 "第二代软件放松了这些限制,因为它们采用了以网络为中心的结构,并且能够一次管理整"
2774 "个项目。随着项目增长,又出现了新的问题。客户需要频繁的和服务器交互,服务器的可"
2775 "伸缩性成为大项目的主要问题。不可靠的网络会妨碍客户和服务器的交互。随着开源项目"
2776 "开始开放只读权限给匿名用户,没有提交权限的用户发现他们不能以自然的方式使用工具"
2777 "和项目交互,因为他们不能记录他们的修改。"
2779 #. type: Content of: <book><chapter><sect1><para>
2780 #: ../en/ch01-intro.xml:198
2781 msgid ""
2782 "The current generation of revision control tools is peer-to-peer in nature. "
2783 "All of these systems have dropped the dependency on a single central server, "
2784 "and allow people to distribute their revision control data to where it's "
2785 "actually needed. Collaboration over the Internet has moved from constrained "
2786 "by technology to a matter of choice and consensus. Modern tools can operate "
2787 "offline indefinitely and autonomously, with a network connection only needed "
2788 "when syncing changes with another repository."
2789 msgstr ""
2790 "新一代的版本控制工具本质上是点对点的。所有的这些系统都抛弃了对单个中央服务器的"
2791 "依赖,允许用户将他们的版本控制数据发布到任何需要的地方。通过互联网的协作摆脱了"
2792 "技术的限制,走向选择和审查。现代的工具可以进行自治的,不受限制的离线操作。只需"
2793 "要在有网络的时候和其他的版本库同步即可。"
2795 #. type: Content of: <book><chapter><sect1><title>
2796 #: ../en/ch01-intro.xml:210
2797 msgid "A few of the advantages of distributed revision control"
2798 msgstr "分布版本控制的优点"
2800 #. type: Content of: <book><chapter><sect1><para>
2801 #: ../en/ch01-intro.xml:213
2802 msgid ""
2803 "Even though distributed revision control tools have for several years been as "
2804 "robust and usable as their previous-generation counterparts, people using "
2805 "older tools have not yet necessarily woken up to their advantages. There are "
2806 "a number of ways in which distributed tools shine relative to centralised "
2807 "ones."
2808 msgstr ""
2809 "与它们的上一代竞争者相比,虽然分布式版本控制工具多年来已经很稳定和实用了,但是"
2810 "旧的工具的使用者还没有完全了解它们的优点,分布式的工具在很多方面明显由于集中式"
2811 "的工具。"
2813 #. type: Content of: <book><chapter><sect1><para>
2814 #: ../en/ch01-intro.xml:220
2815 msgid ""
2816 "For an individual developer, distributed tools are almost always much faster "
2817 "than centralised tools. This is for a simple reason: a centralised tool "
2818 "needs to talk over the network for many common operations, because most "
2819 "metadata is stored in a single copy on the central server. A distributed "
2820 "tool stores all of its metadata locally. All else being equal, talking over "
2821 "the network adds overhead to a centralised tool. Don't underestimate the "
2822 "value of a snappy, responsive tool: you're going to spend a lot of time "
2823 "interacting with your revision control software."
2824 msgstr ""
2825 "对于个人开发者,分布式工具几乎永远比集中式工具快的多。原因很简单:集中式工具的"
2826 "很多操作需要网络交互,因为大部分元数据都只在中央服务器上有一份拷贝。而一个分布"
2827 "式工具将所有的元数据保存在本地。其他的相同,通过网络的交互增加了集中式工具的负"
2828 "担。不要低估了反应迅速的工具的价值:你要花很多时间和你的版本控制软件交互。"
2830 #. type: Content of: <book><chapter><sect1><para>
2831 #: ../en/ch01-intro.xml:231
2832 msgid ""
2833 "Distributed tools are indifferent to the vagaries of your server "
2834 "infrastructure, again because they replicate metadata to so many locations. "
2835 "If you use a centralised system and your server catches fire, you'd better "
2836 "hope that your backup media are reliable, and that your last backup was "
2837 "recent and actually worked. With a distributed tool, you have many backups "
2838 "available on every contributor's computer."
2839 msgstr ""
2840 "分布式工具对你的服务器结构并不感冒,因为他们在将元数据复制到很多地方。如果你的"
2841 "集中式系统和你的服务器着火了,你最好希望你的备份介质是可靠的,同时你最后的备份"
2842 "是最近的,而且还能用。而对于分布式工具,你在贡献者的计算机上有很多备份。"
2844 #. type: Content of: <book><chapter><sect1><para>
2845 #: ../en/ch01-intro.xml:239
2846 msgid ""
2847 "The reliability of your network will affect distributed tools far less than "
2848 "it will centralised tools. You can't even use a centralised tool without a "
2849 "network connection, except for a few highly constrained commands. With a "
2850 "distributed tool, if your network connection goes down while you're working, "
2851 "you may not even notice. The only thing you won't be able to do is talk to "
2852 "repositories on other computers, something that is relatively rare compared "
2853 "with local operations. If you have a far-flung team of collaborators, this "
2854 "may be significant."
2855 msgstr ""
2856 "网络的可靠性对分布式工具的影响要远远小于集中式工具。如果没有网络你根本不能使用"
2857 "集中式工具,除了少数几个功能有限命令。而对于分布式工具,即使在你工作的时候网络"
2858 "瘫痪了,你可能根本不会注意到。你不能做的事情仅仅是不能和其它计算机上的版本库交"
2859 "互了,这种情况在本地操作相当罕见。而如果你的团队有异地的人员,那这就很有可能"
2860 "了。"
2862 #. type: Content of: <book><chapter><sect1><sect2><title>
2863 #: ../en/ch01-intro.xml:250
2864 msgid "Advantages for open source projects"
2865 msgstr "开源项目的优点"
2867 #. type: Content of: <book><chapter><sect1><sect2><para>
2868 #: ../en/ch01-intro.xml:252
2869 msgid ""
2870 "If you take a shine to an open source project and decide that you would like "
2871 "to start hacking on it, and that project uses a distributed revision control "
2872 "tool, you are at once a peer with the people who consider themselves the "
2873 "<quote>core</quote> of that project. If they publish their repositories, you "
2874 "can immediately copy their project history, start making changes, and record "
2875 "your work, using the same tools in the same ways as insiders. By contrast, "
2876 "with a centralised tool, you must use the software in a <quote>read only</"
2877 "quote> mode unless someone grants you permission to commit changes to their "
2878 "central server. Until then, you won't be able to record changes, and your "
2879 "local modifications will be at risk of corruption any time you try to update "
2880 "your client's view of the repository."
2881 msgstr ""
2882 "如果你喜欢一个开源项目并且决定准备开始改进它,同时这个项目使用分布式版本控制工"
2883 "具的话,你立刻可以和其他人一样认为自己成为项目的<quote>核心</quote>。如果他们"
2884 "发布了他们的版本库,你可以立即拷贝他们的项目。开始修改,记录你自己的工作,和内"
2885 "部人员一样使用同样的工具。相比之下,如果使用集中式工具,除非有人给你向中央服务"
2886 "器提交修改的权限,你只能用只读的方式使用软件。这样,你就不能记录你的修改,而且"
2887 "当你从版本库更新的时候,本地的修改随时有崩溃的可能。 "
2889 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
2890 #: ../en/ch01-intro.xml:268
2891 msgid "The forking non-problem"
2892 msgstr "分支不是问题"
2894 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
2895 #: ../en/ch01-intro.xml:270
2896 msgid ""
2897 "It has been suggested that distributed revision control tools pose some sort "
2898 "of risk to open source projects because they make it easy to <quote>fork</"
2899 "quote> the development of a project. A fork happens when there are "
2900 "differences in opinion or attitude between groups of developers that cause "
2901 "them to decide that they can't work together any longer. Each side takes a "
2902 "more or less complete copy of the project's source code, and goes off in its "
2903 "own direction."
2904 msgstr ""
2905 "有人说分布式版本控制工具给开源项目带来了某种风险,因为在项目的发展过程中很容易"
2906 "出现<quote>分支</quote>。当不同组的开发人员有不同的意见和看法,决定不再一起工"
2907 "作的时候,就会产生新的分支,每个组的人都或多或少的获得项目代码的完整拷贝,然后"
2908 "向自己的方向发展。"
2910 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
2911 #: ../en/ch01-intro.xml:280
2912 msgid ""
2913 "Sometimes the camps in a fork decide to reconcile their differences. With a "
2914 "centralised revision control system, the <emphasis>technical</emphasis> "
2915 "process of reconciliation is painful, and has to be performed largely by "
2916 "hand. You have to decide whose revision history is going to <quote>win</"
2917 "quote>, and graft the other team's changes into the tree somehow. This "
2918 "usually loses some or all of one side's revision history."
2919 msgstr ""
2920 "有时候,不同分支的阵营决定协调他们之间的分歧。如果使用了集中式版本控制系统 "
2921 "<emphasis>技术</emphasis>上的问题使协调过程非常痛苦,大部分需要手动解决。你必"
2922 "须决定那个版本历史<quote>赢</quote>了,然后将其它团队的更改合并到代码中。这通"
2923 "常造成别的团队某些或者全部版本历史丢失。"
2925 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
2926 #: ../en/ch01-intro.xml:289
2927 msgid ""
2928 "What distributed tools do with respect to forking is they make forking the "
2929 "<emphasis>only</emphasis> way to develop a project. Every single change that "
2930 "you make is potentially a fork point. The great strength of this approach is "
2931 "that a distributed revision control tool has to be really good at "
2932 "<emphasis>merging</emphasis> forks, because forks are absolutely fundamental: "
2933 "they happen all the time."
2934 msgstr ""
2935 "分布式工具认为分支是项目开发的<emphasis>唯一</emphasis>方式。每个单独的变更都"
2936 "是潜在的分支点。这种方法的巨大力量在于,分布式版本控制工具非常善于<emphasis>合"
2937 "并</emphasis>分支,因为分支是非常基本的操作:它们随时都在发生。"
2939 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
2940 #: ../en/ch01-intro.xml:298
2941 msgid ""
2942 "If every piece of work that everybody does, all the time, is framed in terms "
2943 "of forking and merging, then what the open source world refers to as a "
2944 "<quote>fork</quote> becomes <emphasis>purely</emphasis> a social issue. If "
2945 "anything, distributed tools <emphasis>lower</emphasis> the likelihood of a "
2946 "fork:"
2947 msgstr ""
2948 "如果所有的人在任何时候的做任何工作都这样使用合并和分支,那么对开源世界来讲,"
2949 "<quote>分支</quote>就变成了<emphasis>纯粹</emphasis>的社会事件。如果真的有什么"
2950 "影响到话,就是分布式工具<emphasis>降低</emphasis>了分支的可能性:"
2952 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
2953 #: ../en/ch01-intro.xml:305
2954 msgid ""
2955 "They eliminate the social distinction that centralised tools impose: that "
2956 "between insiders (people with commit access) and outsiders (people without)."
2957 msgstr ""
2958 "消除了集中式工具带来的社会级别:有内部人员(有提交权限)和外部人员(没有权限)"
2959 "之分。"
2961 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
2962 #: ../en/ch01-intro.xml:309
2963 msgid ""
2964 "They make it easier to reconcile after a social fork, because all that's "
2965 "involved from the perspective of the revision control software is just "
2966 "another merge."
2967 msgstr ""
2968 "在社会性分支之后很容易和解,因为从版本控制工具的角度来讲这仅仅是一次新的合并而"
2969 "已。"
2971 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
2972 #: ../en/ch01-intro.xml:314
2973 msgid ""
2974 "Some people resist distributed tools because they want to retain tight "
2975 "control over their projects, and they believe that centralised tools give "
2976 "them this control. However, if you're of this belief, and you publish your "
2977 "CVS or Subversion repositories publicly, there are plenty of tools available "
2978 "that can pull out your entire project's history (albeit slowly) and recreate "
2979 "it somewhere that you don't control. So while your control in this case is "
2980 "illusory, you are forgoing the ability to fluidly collaborate with whatever "
2981 "people feel compelled to mirror and fork your history."
2982 msgstr ""
2983 "有些人拒绝分布式工具因为他们想保持对项目的控制,他们相信集中式工具会给他们这种"
2984 "控制。如果你这种想法,并你将CVS或者Subversion版本库向大众发布了,那么别人可用"
2985 "现有的很多工具将整个项目的历史抓取出来(可能很慢),在其它你控制不了的地方重建"
2986 "版本库。这时你的控制只不过是一种幻觉罢了,一些人被迫从你的版本库创建映像和分"
2987 "支,而你失去了和他们协作的机会。"
2989 #. type: Content of: <book><chapter><sect1><sect2><title>
2990 #: ../en/ch01-intro.xml:329
2991 msgid "Advantages for commercial projects"
2992 msgstr "商业项目的优点"
2994 #. type: Content of: <book><chapter><sect1><sect2><para>
2995 #: ../en/ch01-intro.xml:331
2996 msgid ""
2997 "Many commercial projects are undertaken by teams that are scattered across "
2998 "the globe. Contributors who are far from a central server will see slower "
2999 "command execution and perhaps less reliability. Commercial revision control "
3000 "systems attempt to ameliorate these problems with remote-site replication add-"
3001 "ons that are typically expensive to buy and cantankerous to administer. A "
3002 "distributed system doesn't suffer from these problems in the first place. "
3003 "Better yet, you can easily set up multiple authoritative servers, say one per "
3004 "site, so that there's no redundant communication between repositories over "
3005 "expensive long-haul network links."
3006 msgstr ""
3007 "遍布全球的团队正在进行许多商业项目。远离中央服务器的贡献者会发现执行命令速度很"
3008 "慢同时不怎么可靠。商业的版本控制系统改善这个问题的办法就是让你购买远程复制插"
3009 "件,这通常很昂贵,并且很难管理。分布式系统首先不会有这样的问题。其次,你可以很"
3010 "容易的建立多个授权服务器,假设每个站点一个,这样可以避免在昂贵的长途线路上的冗"
3011 "余的通讯。"
3013 #. type: Content of: <book><chapter><sect1><sect2><para>
3014 #: ../en/ch01-intro.xml:343
3015 msgid ""
3016 "Centralised revision control systems tend to have relatively low "
3017 "scalability. It's not unusual for an expensive centralised system to fall "
3018 "over under the combined load of just a few dozen concurrent users. Once "
3019 "again, the typical response tends to be an expensive and clunky replication "
3020 "facility. Since the load on a central server&emdash;if you have one at "
3021 "all&emdash;is many times lower with a distributed tool (because all of the "
3022 "data is replicated everywhere), a single cheap server can handle the needs of "
3023 "a much larger team, and replication to balance load becomes a simple matter "
3024 "of scripting."
3025 msgstr ""
3026 "集中式的版本控制系统的扩展性相对较低。只要不多的并行用户的组合负载就可以将一个"
3027 "昂贵的中央服务器压垮。同样,典型的反应就是昂贵笨重的复制设备。因为中央服务器的"
3028 "最大负载&emdash;如果你有的话&emdash;比分布式工具低很多(因为所有的数据要北复制"
3029 "到其它地方),一个廉价的服务器就可以满足一个相当大的团队的要求,为平衡负载而进"
3030 "行的复制只需要简单的脚本就够了。"
3032 #. type: Content of: <book><chapter><sect1><sect2><para>
3033 #: ../en/ch01-intro.xml:355
3034 msgid ""
3035 "If you have an employee in the field, troubleshooting a problem at a "
3036 "customer's site, they'll benefit from distributed revision control. The tool "
3037 "will let them generate custom builds, try different fixes in isolation from "
3038 "each other, and search efficiently through history for the sources of bugs "
3039 "and regressions in the customer's environment, all without needing to connect "
3040 "to your company's network."
3041 msgstr ""
3042 "如果你有员工需要在客户方解决问题,那么他们会受益于分布式版本控制。工具允许他们"
3043 "创建定制的环境,互相独立的尝试不同的解决方案。并且可以高效的从历史代码中查找"
3044 "bug的根源,在客户环境中进行回归,所有的这些都不需要连接公司的网络。"
3046 #. type: Content of: <book><chapter><sect1><title>
3047 #: ../en/ch01-intro.xml:366
3048 msgid "Why choose Mercurial?"
3049 msgstr "为什么选择 Mercurial?"
3051 #. type: Content of: <book><chapter><sect1><para>
3052 #: ../en/ch01-intro.xml:368
3053 msgid ""
3054 "Mercurial has a unique set of properties that make it a particularly good "
3055 "choice as a revision control system."
3056 msgstr "Mercurial是一个非常好的版本控制系统,因为它有很多独一无二的特点。"
3058 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
3059 #: ../en/ch01-intro.xml:371
3060 msgid "It is easy to learn and use."
3061 msgstr "它易学易用。"
3063 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
3064 #: ../en/ch01-intro.xml:372
3065 msgid "It is lightweight."
3066 msgstr "它轻量级。"
3068 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
3069 #: ../en/ch01-intro.xml:373
3070 msgid "It scales excellently."
3071 msgstr "它扩展性很好。"
3073 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
3074 #: ../en/ch01-intro.xml:374
3075 msgid "It is easy to customise."
3076 msgstr "它很容易定制。"
3078 #. type: Content of: <book><chapter><sect1><para>
3079 #: ../en/ch01-intro.xml:377
3080 msgid ""
3081 "If you are at all familiar with revision control systems, you should be able "
3082 "to get up and running with Mercurial in less than five minutes. Even if not, "
3083 "it will take no more than a few minutes longer. Mercurial's command and "
3084 "feature sets are generally uniform and consistent, so you can keep track of a "
3085 "few general rules instead of a host of exceptions."
3086 msgstr ""
3087 "如果你熟悉版本控制系统,你在五分钟之内只能就可以使用Mercurial工作了。即使你不"
3088 "熟悉,也不过是再多花几分钟。Mercurial的命令和功能集非常统一一致,你只要遵守几"
3089 "个通用的规则就够了,很少有例外。"
3091 #. type: Content of: <book><chapter><sect1><para>
3092 #: ../en/ch01-intro.xml:384
3093 msgid ""
3094 "On a small project, you can start working with Mercurial in moments. Creating "
3095 "new changes and branches; transferring changes around (whether locally or "
3096 "over a network); and history and status operations are all fast. Mercurial "
3097 "attempts to stay nimble and largely out of your way by combining low "
3098 "cognitive overhead with blazingly fast operations."
3099 msgstr ""
3100 "在很小的项目上,你马上就可以使用Mercurial开始工作。创建新的修改和分支;到处交"
3101 "换修改(不管本机还是通过网络);获取历史和状态数据非常快。Mercurial努力保持小"
3102 "巧灵活,在眨眼之间就能完成操作。"
3104 #. type: Content of: <book><chapter><sect1><para>
3105 #: ../en/ch01-intro.xml:391
3106 msgid ""
3107 "The usefulness of Mercurial is not limited to small projects: it is used by "
3108 "projects with hundreds to thousands of contributors, each containing tens of "
3109 "thousands of files and hundreds of megabytes of source code."
3110 msgstr ""
3111 "不仅小的项目可以使用Mercurial:有成百上千的贡献者的项目也在使用它,这些项目每"
3112 "个都有上万个文件和几百兆的源码。"
3114 #. type: Content of: <book><chapter><sect1><para>
3115 #: ../en/ch01-intro.xml:396
3116 msgid ""
3117 "If the core functionality of Mercurial is not enough for you, it's easy to "
3118 "build on. Mercurial is well suited to scripting tasks, and its clean "
3119 "internals and implementation in Python make it easy to add features in the "
3120 "form of extensions. There are a number of popular and useful extensions "
3121 "already available, ranging from helping to identify bugs to improving "
3122 "performance."
3123 msgstr ""
3124 "如果觉得Mercurial的核心功能不能满足要求,你很容易在现有基础上开发。Mercurial非"
3125 "常适合于脚本任务,它的核心简洁,并且用Python实现,用扩展的方式增加新的功能非常"
3126 "方便,现在已经有很多流行和有用的扩展了,像帮助你确定bug或者提高性能等。"
3128 #. type: Content of: <book><chapter><sect1><title>
3129 #: ../en/ch01-intro.xml:406
3130 msgid "Mercurial compared with other tools"
3131 msgstr "Mercurial 与其它工具的比较"
3133 #. type: Content of: <book><chapter><sect1><para>
3134 #: ../en/ch01-intro.xml:408
3135 msgid ""
3136 "Before you read on, please understand that this section necessarily reflects "
3137 "my own experiences, interests, and (dare I say it) biases. I have used every "
3138 "one of the revision control tools listed below, in most cases for several "
3139 "years at a time."
3140 msgstr ""
3141 "在你继续阅读之前,请理解本节完全反映了我的个人经验,兴趣,和偏好(我敢说)。下"
3142 "面列的每个版本控制工具我都使用过,大多数情况下都用过好几年。"
3144 #. type: Content of: <book><chapter><sect1><sect2><para>
3145 #: ../en/ch01-intro.xml:418
3146 msgid ""
3147 "Subversion is a popular revision control tool, developed to replace CVS. It "
3148 "has a centralised client/server architecture."
3149 msgstr ""
3150 "Subversion是一个流行的版本控制工具,是用来替代CVS的,它采用的是集中式的客户/服"
3151 "务器结构。"
3153 #. type: Content of: <book><chapter><sect1><sect2><para>
3154 #: ../en/ch01-intro.xml:422
3155 msgid ""
3156 "Subversion and Mercurial have similarly named commands for performing the "
3157 "same operations, so if you're familiar with one, it is easy to learn to use "
3158 "the other. Both tools are portable to all popular operating systems."
3159 msgstr ""
3160 "Subversion和Mercurial相同操作的命令的命名上非常相似,所以如果你熟悉一个,很容"
3161 "易学会另外一个,两个工具都可以在大多数平台上运行。"
3163 #. type: Content of: <book><chapter><sect1><sect2><para>
3164 #: ../en/ch01-intro.xml:427
3165 msgid ""
3166 "Prior to version 1.5, Subversion had no useful support for merges. At the "
3167 "time of writing, its merge tracking capability is new, and known to be <ulink "
3168 "url=\"http://svnbook.red-bean.com/nightly/en/svn.branchmerge.advanced."
3169 "html#svn.branchmerge.advanced.finalword\">complicated and buggy</ulink>."
3170 msgstr ""
3171 "在1.5版之前,Subversion对合并的支持并不好。在我写本书的时候,它刚新增了并跟踪"
3172 "的功能,出名的<ulink url=\"http://svnbook.red-bean.com/nightly/en/svn."
3173 "branchmerge.advanced.html#svn.branchmerge.advanced.finalword\">复杂和容易出错"
3174 "</ulink>。"
3176 #. type: Content of: <book><chapter><sect1><sect2><para>
3177 #: ../en/ch01-intro.xml:433
3178 msgid ""
3179 "Mercurial has a substantial performance advantage over Subversion on every "
3180 "revision control operation I have benchmarked. I have measured its advantage "
3181 "as ranging from a factor of two to a factor of six when compared with "
3182 "Subversion 1.4.3's <emphasis>ra_local</emphasis> file store, which is the "
3183 "fastest access method available. In more realistic deployments involving a "
3184 "network-based store, Subversion will be at a substantially larger "
3185 "disadvantage. Because many Subversion commands must talk to the server and "
3186 "Subversion does not have useful replication facilities, server capacity and "
3187 "network bandwidth become bottlenecks for modestly large projects."
3188 msgstr ""
3189 "在我测量过的每个版本控制操作上Mercurial都比Subversion有很大的性能优势。差距从"
3190 "两个数量级到六个数量级不等,我用的是Subversion 1.4.3的<emphasis>ra_local</"
3191 "emphasis>文件存储方式,这是已知的最快的存取方式了。在实际的部署中包括网络存"
3192 "储,那么Subversion的劣势更大。因为很多Subversion命令必须和主机交互,并且因为"
3193 "Subversion没有好的复制机制,使得对于中的等大小的项目而言,服务器容量和网络带宽"
3194 "成为主要瓶颈。"
3196 #. type: Content of: <book><chapter><sect1><sect2><para>
3197 #: ../en/ch01-intro.xml:446
3198 msgid ""
3199 "Additionally, Subversion incurs substantial storage overhead to avoid network "
3200 "transactions for a few common operations, such as finding modified files "
3201 "(<literal>status</literal>) and displaying modifications against the current "
3202 "revision (<literal>diff</literal>). As a result, a Subversion working copy "
3203 "is often the same size as, or larger than, a Mercurial repository and working "
3204 "directory, even though the Mercurial repository contains a complete history "
3205 "of the project."
3206 msgstr ""
3207 "另外,Subversion以在客户端使用了更多存储空间的方法,换取降低几个常用操作的网络"
3208 "负载,例如查找修改过的文件(<literal>status</literal>)和显示对于当前版本的更"
3209 "改(<literal>diff</literal>)。结果Subversion的工作副本经常和Mercurial的版本库"
3210 "和工作目录一样大,或者更大,虽然Mercurial的版本库包括了项目的完整历史。"
3212 #. type: Content of: <book><chapter><sect1><sect2><para>
3213 #: ../en/ch01-intro.xml:456
3214 msgid ""
3215 "Subversion is widely supported by third party tools. Mercurial currently "
3216 "lags considerably in this area. This gap is closing, however, and indeed "
3217 "some of Mercurial's GUI tools now outshine their Subversion equivalents. "
3218 "Like Mercurial, Subversion has an excellent user manual."
3219 msgstr ""
3220 "Subversion有很多的第三方工具支持。Mercurial现在在这方面稍微欠缺。然而差距正在"
3221 "逐渐缩小,实际上一些有Mercurial的GUI工具比Subversion类似工具还略胜一筹。和"
3222 "Mercurial一样,Subversion也有完善的用户手册。"
3224 #. type: Content of: <book><chapter><sect1><sect2><para>
3225 #: ../en/ch01-intro.xml:462
3226 msgid ""
3227 "Because Subversion doesn't store revision history on the client, it is well "
3228 "suited to managing projects that deal with lots of large, opaque binary "
3229 "files. If you check in fifty revisions to an incompressible 10MB file, "
3230 "Subversion's client-side space usage stays constant The space used by any "
3231 "distributed SCM will grow rapidly in proportion to the number of revisions, "
3232 "because the differences between each revision are large."
3233 msgstr ""
3234 "Subversion并不在客户端存储版本历史,所以它很适合管理那些有很多大的二进制文件的"
3235 "项目。如果你对一个未压缩的10MB文件检入了五十次,Subversion客户端的占用的磁盘空"
3236 "间基本上保持不变。而对于分布式SCM软件,磁盘空间会随着版本数量的增加成而迅速增"
3237 "长,因为每个版本之间的差异非常大。"
3239 #. type: Content of: <book><chapter><sect1><sect2><para>
3240 #: ../en/ch01-intro.xml:471
3241 msgid ""
3242 "In addition, it's often difficult or, more usually, impossible to merge "
3243 "different versions of a binary file. Subversion's ability to let a user lock "
3244 "a file, so that they temporarily have the exclusive right to commit changes "
3245 "to it, can be a significant advantage to a project where binary files are "
3246 "widely used."
3247 msgstr ""
3248 "另外,合并不同版本的二进制文件非常困难,换句话说,基本上不可能。Subversion提供"
3249 "了锁定功能,用户可以锁定一个文件,这样他就取得了对这个文件临时的独占的提交权,"
3250 "这对于广泛使用二进制文件的项目而言是个明显优势。"
3252 #. type: Content of: <book><chapter><sect1><sect2><para>
3253 #: ../en/ch01-intro.xml:478
3254 msgid ""
3255 "Mercurial can import revision history from a Subversion repository. It can "
3256 "also export revision history to a Subversion repository. This makes it easy "
3257 "to <quote>test the waters</quote> and use Mercurial and Subversion in "
3258 "parallel before deciding to switch. History conversion is incremental, so "
3259 "you can perform an initial conversion, then small additional conversions "
3260 "afterwards to bring in new changes."
3261 msgstr ""
3262 "Mercurial可以从Subversion的版本库中导入历史版本。它也可以向Subversion的版本库"
3263 "输出历史版本。这样在决定转换之前很容易先<quote>试一下水</quote>,同时并行的使"
3264 "用Mercurial和Subversion。版本史的转换是递增的,你可以先构造一个初始版本,每次"
3265 "有了新的更改后加入一个小的转换。"
3267 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
3268 #: ../en/ch01-intro.xml:490 ../en/ch01-intro.xml:629
3269 msgid "Git"
3270 msgstr "Git"
3272 #. type: Content of: <book><chapter><sect1><sect2><para>
3273 #: ../en/ch01-intro.xml:492
3274 msgid ""
3275 "Git is a distributed revision control tool that was developed for managing "
3276 "the Linux kernel source tree. Like Mercurial, its early design was somewhat "
3277 "influenced by Monotone."
3278 msgstr ""
3279 "Git是为了管理Linux内核代码而开发的一个分布式版本控制工具。它和Mercurial一样在"
3280 "设计上受了Monotone的影响。"
3282 #. type: Content of: <book><chapter><sect1><sect2><para>
3283 #: ../en/ch01-intro.xml:497
3284 msgid ""
3285 "Git has a very large command set, with version 1.5.0 providing 139 individual "
3286 "commands. It has something of a reputation for being difficult to learn. "
3287 "Compared to Git, Mercurial has a strong focus on simplicity."
3288 msgstr ""
3289 "Git有非常大的命令集,1.5.0版本提供了139个单独的命令。它以难学而闻名于世。与Git"
3290 "相比,Mercurial力求简洁。"
3292 #. type: Content of: <book><chapter><sect1><sect2><para>
3293 #: ../en/ch01-intro.xml:502
3294 msgid ""
3295 "In terms of performance, Git is extremely fast. In several cases, it is "
3296 "faster than Mercurial, at least on Linux, while Mercurial performs better on "
3297 "other operations. However, on Windows, the performance and general level of "
3298 "support that Git provides is, at the time of writing, far behind that of "
3299 "Mercurial."
3300 msgstr ""
3301 "就性能而言,Git非常快。在很多情况下它都比Mercurial快,至少是在Linux上,但"
3302 "Mercurial在其它操作上有优势。而在Windows上,Git不管是性能还是提供的支持,都比"
3303 "Mercurial差很多,至少在本书写作的时候是这样。"
3305 #. type: Content of: <book><chapter><sect1><sect2><para>
3306 #: ../en/ch01-intro.xml:509
3307 msgid ""
3308 "While a Mercurial repository needs no maintenance, a Git repository requires "
3309 "frequent manual <quote>repacks</quote> of its metadata. Without these, "
3310 "performance degrades, while space usage grows rapidly. A server that "
3311 "contains many Git repositories that are not rigorously and frequently "
3312 "repacked will become heavily disk-bound during backups, and there have been "
3313 "instances of daily backups taking far longer than 24 hours as a result. A "
3314 "freshly packed Git repository is slightly smaller than a Mercurial "
3315 "repository, but an unpacked repository is several orders of magnitude larger."
3316 msgstr ""
3317 "Mercurial的版本库不需要维护,但Git的版本库需要频繁的手工维护,将其元数据"
3318 "<quote>repacks</quote>,如果不这样做,性能就会下降,磁盘空间也会迅速增加。有多"
3319 "个Git版本库的服务器需要严格和频繁的重新打包,否则在备份的时候就会成为严重的瓶"
3320 "颈,曾经有过运行每日备份超过24小时的例子。一个新打包的Git版本库比Mercurial稍小"
3321 "一些,但是未打包的版本库则会大几个数量级。"
3323 #. type: Content of: <book><chapter><sect1><sect2><para>
3324 #: ../en/ch01-intro.xml:520
3325 msgid ""
3326 "The core of Git is written in C. Many Git commands are implemented as shell "
3327 "or Perl scripts, and the quality of these scripts varies widely. I have "
3328 "encountered several instances where scripts charged along blindly in the "
3329 "presence of errors that should have been fatal."
3330 msgstr ""
3331 "Git的核心由C语言编写,许多Git命令是用shell或者perl脚本实现的,这些脚本的质量差"
3332 "别很大。我碰到过好几次这样的情况,明明已经出现了致命错误了,脚本还在盲目的执"
3333 "行。"
3335 #. type: Content of: <book><chapter><sect1><sect2><para>
3336 #: ../en/ch01-intro.xml:526
3337 msgid "Mercurial can import revision history from a Git repository."
3338 msgstr "Mercurial可以从Git的版本库中导入版本历史。"
3340 #. type: Content of: <book><chapter><sect1><sect2><para>
3341 #: ../en/ch01-intro.xml:534
3342 msgid ""
3343 "CVS is probably the most widely used revision control tool in the world. Due "
3344 "to its age and internal untidiness, it has been only lightly maintained for "
3345 "many years."
3346 msgstr ""
3347 "CVS可能是世界上使用最广泛的版本控制工具。因为它是太古老和内部实现很混乱,许多"
3348 "年来都处于维护状态。"
3350 #. type: Content of: <book><chapter><sect1><sect2><para>
3351 #: ../en/ch01-intro.xml:538
3352 msgid ""
3353 "It has a centralised client/server architecture. It does not group related "
3354 "file changes into atomic commits, making it easy for people to <quote>break "
3355 "the build</quote>: one person can successfully commit part of a change and "
3356 "then be blocked by the need for a merge, causing other people to see only a "
3357 "portion of the work they intended to do. This also affects how you work with "
3358 "project history. If you want to see all of the modifications someone made as "
3359 "part of a task, you will need to manually inspect the descriptions and "
3360 "timestamps of the changes made to each file involved (if you even know what "
3361 "those files were)."
3362 msgstr ""
3363 "CVS采用的是集中式客户/服务器结构。它不会将相关的文件变更一起作为原子提交,这使"
3364 "得它很容易<quote>破坏构建</quote>:一个人成功的提交了一部分更改,然后要停下来"
3365 "处理合并,这使得其他人只能看见他们的部分工作。这样也会影响你和项目历史的工作方"
3366 "式。如果你想看到其他人针对他的那部分任务做的全部修改,你必须手动检查每个受影响"
3367 "的文件的变更描述和时间戳(假如你知道是哪些文件)。"
3369 #. type: Content of: <book><chapter><sect1><sect2><para>
3370 #: ../en/ch01-intro.xml:550
3371 msgid ""
3372 "CVS has a muddled notion of tags and branches that I will not attempt to even "
3373 "describe. It does not support renaming of files or directories well, making "
3374 "it easy to corrupt a repository. It has almost no internal consistency "
3375 "checking capabilities, so it is usually not even possible to tell whether or "
3376 "how a repository is corrupt. I would not recommend CVS for any project, "
3377 "existing or new."
3378 msgstr ""
3379 "CVS的分支和标签的概念实在是太混乱了,我都不想给你介绍。它也不支持文件和目录的"
3380 "重命名。这使得版本库非常容易崩溃。它几乎没任何的内部一致性检查功能,所以通常你"
3381 "不可能知道版本库是不是崩溃了。不管是新项目还是老项目,我都不推荐使用CVS。"
3383 #. type: Content of: <book><chapter><sect1><sect2><para>
3384 #: ../en/ch01-intro.xml:558
3385 msgid ""
3386 "Mercurial can import CVS revision history. However, there are a few caveats "
3387 "that apply; these are true of every other revision control tool's CVS "
3388 "importer, too. Due to CVS's lack of atomic changes and unversioned "
3389 "filesystem hierarchy, it is not possible to reconstruct CVS history "
3390 "completely accurately; some guesswork is involved, and renames will usually "
3391 "not show up. Because a lot of advanced CVS administration has to be done by "
3392 "hand and is hence error-prone, it's common for CVS importers to run into "
3393 "multiple problems with corrupted repositories (completely bogus revision "
3394 "timestamps and files that have remained locked for over a decade are just two "
3395 "of the less interesting problems I can recall from personal experience)."
3396 msgstr ""
3397 "Mercurial可以导入CVS的版本历史。然而,这里面有很多限制;对其版本控制工具的CVS"
3398 "导入程序也是一样。因为CVS缺少原子更改并且不支持文件系统层次的版本控制,所以不"
3399 "可能完全精确的重建CVS的历史。有些需要猜测,重命名通常发现不了。因为CVS的很多的"
3400 "高级管理功能必须手动完成,因此非常容易出错。碰到崩溃的版本库,CVS导入程序通常"
3401 "会出现很多问题(完全伪造的版本时间戳,若干文件被锁定十多年,这是我个人经历的两"
3402 "个不太有趣的问题)。"
3404 #. type: Content of: <book><chapter><sect1><sect2><para>
3405 #: ../en/ch01-intro.xml:572
3406 msgid "Mercurial can import revision history from a CVS repository."
3407 msgstr "Mercurial可以从CVS版本库导入版本历史。"
3409 #. type: Content of: <book><chapter><sect1><sect2><title>
3410 #: ../en/ch01-intro.xml:578
3411 msgid "Commercial tools"
3412 msgstr "商业工具"
3414 #. type: Content of: <book><chapter><sect1><sect2><para>
3415 #: ../en/ch01-intro.xml:580
3416 msgid ""
3417 "Perforce has a centralised client/server architecture, with no client-side "
3418 "caching of any data. Unlike modern revision control tools, Perforce requires "
3419 "that a user run a command to inform the server about every file they intend "
3420 "to edit."
3421 msgstr ""
3422 "Perforce采用的是集中式客户/服务器结构,客户端不缓存任何数据。和现代的版本控制"
3423 "工具不同,每次想要编辑的一个文件,用户必须运行一个命令通知Perforce服务器。"
3425 #. type: Content of: <book><chapter><sect1><sect2><para>
3426 #: ../en/ch01-intro.xml:586
3427 msgid ""
3428 "The performance of Perforce is quite good for small teams, but it falls off "
3429 "rapidly as the number of users grows beyond a few dozen. Modestly large "
3430 "Perforce installations require the deployment of proxies to cope with the "
3431 "load their users generate."
3432 msgstr ""
3433 "对于小的团队而言,Perforce相当好,但是当用户数目超过数十个以后,性能急剧下降。"
3434 "中等大小Perforce安装需要部署代理来处理用户产生的负载。"
3436 #. type: Content of: <book><chapter><sect1><sect2><title>
3437 #: ../en/ch01-intro.xml:595
3438 msgid "Choosing a revision control tool"
3439 msgstr "选择版本控制工具"
3441 #. type: Content of: <book><chapter><sect1><sect2><para>
3442 #: ../en/ch01-intro.xml:597
3443 msgid ""
3444 "With the exception of CVS, all of the tools listed above have unique "
3445 "strengths that suit them to particular styles of work. There is no single "
3446 "revision control tool that is best in all situations."
3447 msgstr ""
3448 "除了CVS之外,以上列出的所有工具都各有所长,没有一个版本控制工具适合所有情况。"
3450 #. type: Content of: <book><chapter><sect1><sect2><para>
3451 #: ../en/ch01-intro.xml:602
3452 msgid ""
3453 "As an example, Subversion is a good choice for working with frequently edited "
3454 "binary files, due to its centralised nature and support for file locking."
3455 msgstr ""
3456 "比如说,因为采用集中式的结构并且支持文件锁定,Subversion非常适合频繁编辑二进制"
3457 "文件的场合。"
3459 #. type: Content of: <book><chapter><sect1><sect2><para>
3460 #: ../en/ch01-intro.xml:606
3461 msgid ""
3462 "I personally find Mercurial's properties of simplicity, performance, and good "
3463 "merge support to be a compelling combination that has served me well for "
3464 "several years."
3465 msgstr ""
3466 "我已经使用Mercurial很多年了,个人认为它有简洁,高性能,良好的合并支持诸多特"
3467 "点。"
3469 #. type: Content of: <book><chapter><sect1><title>
3470 #: ../en/ch01-intro.xml:614
3471 msgid "Switching from another tool to Mercurial"
3472 msgstr "从其它工具切换到 Mercurial"
3474 #. type: Content of: <book><chapter><sect1><para>
3475 #: ../en/ch01-intro.xml:616
3476 msgid ""
3477 "Mercurial is bundled with an extension named <literal role=\"hg-ext"
3478 "\">convert</literal>, which can incrementally import revision history from "
3479 "several other revision control tools. By <quote>incremental</quote>, I mean "
3480 "that you can convert all of a project's history to date in one go, then rerun "
3481 "the conversion later to obtain new changes that happened after the initial "
3482 "conversion."
3483 msgstr ""
3484 "Mercurial包括一个叫<literal role=\"hg-ext\">convert</literal>的扩展,它可以递"
3485 "增的从几个其他的版本控制工具导入版本历史。 <quote>增量</quote>的意思是你可以在"
3486 "某天将整个项目历史转换,以后再次进行转换获得初始版本以后新增的变更。"
3488 #. type: Content of: <book><chapter><sect1><para>
3489 #: ../en/ch01-intro.xml:624
3490 msgid ""
3491 "The revision control tools supported by <literal role=\"hg-ext\">convert</"
3492 "literal> are as follows:"
3493 msgstr "<literal role=\"hg-ext\">convert</literal> 支持的版本控制工具有:"
3495 #. type: Content of: <book><chapter><sect1><para>
3496 #: ../en/ch01-intro.xml:632
3497 msgid ""
3498 "In addition, <literal role=\"hg-ext\">convert</literal> can export changes "
3499 "from Mercurial to Subversion. This makes it possible to try Subversion and "
3500 "Mercurial in parallel before committing to a switchover, without risking the "
3501 "loss of any work."
3502 msgstr ""
3503 "另外<literal role=\"hg-ext\">convert</literal>可以从Mercurial向Subversion导出"
3504 "历史,这可以让你在切换之前让Mercurial和Subversion并行工作,而不会丢失任何工"
3505 "作。"
3507 #. type: Content of: <book><chapter><sect1><para>
3508 #: ../en/ch01-intro.xml:638
3509 msgid ""
3510 "The <command role=\"hg-ext-convert\">convert</command> command is easy to "
3511 "use. Simply point it at the path or URL of the source repository, optionally "
3512 "give it the name of the destination repository, and it will start working. "
3513 "After the initial conversion, just run the same command again to import new "
3514 "changes."
3515 msgstr ""
3516 "<command role=\"hg-ext-convert\">convert</command>命令非常简单。只要给出源版本"
3517 "库的URL或者路径,给出目标版本库的名称(可选),它就开始工作了。第一次转换之"
3518 "后,只要运行同样的命令就可以导入新的变更。"
3520 #. type: Content of: <book><chapter><sect1><title>
3521 #: ../en/ch01-intro.xml:647
3522 msgid "A short history of revision control"
3523 msgstr "版本控制简史"
3525 #. type: Content of: <book><chapter><sect1><para>
3526 #: ../en/ch01-intro.xml:649
3527 msgid ""
3528 "The best known of the old-time revision control tools is SCCS (Source Code "
3529 "Control System), which Marc Rochkind wrote at Bell Labs, in the early 1970s. "
3530 "SCCS operated on individual files, and required every person working on a "
3531 "project to have access to a shared workspace on a single system. Only one "
3532 "person could modify a file at any time; arbitration for access to files was "
3533 "via locks. It was common for people to lock files, and later forget to "
3534 "unlock them, preventing anyone else from modifying those files without the "
3535 "help of an administrator."
3536 msgstr ""
3537 "最有名史前的版本控制工具是SCCS(源代码控制系统),它是由Marc Rochkind于七十年"
3538 "代在贝尔实验室完成的。SCCS只能控制单个文件,这就要求项目组人员只能使用一个系统"
3539 "上的共享工作空间。任何时候一个文件只能由一个人修改;通过加锁来保证。人们很容易"
3540 "锁定一个文件,然后忘了解锁,没有管理员的帮助,任何人都不能修改那些文件。"
3542 #. type: Content of: <book><chapter><sect1><para>
3543 #: ../en/ch01-intro.xml:660
3544 msgid ""
3545 "Walter Tichy developed a free alternative to SCCS in the early 1980s; he "
3546 "called his program RCS (Revision Control System). Like SCCS, RCS required "
3547 "developers to work in a single shared workspace, and to lock files to prevent "
3548 "multiple people from modifying them simultaneously."
3549 msgstr ""
3550 "Walter Tichy在八十年代早期开发了一个开源的SCCS替代软件;他称之RCS(版本控制系"
3551 "统)。和SCCS一样,RCS要求开发人员在一个共享的工作空间工作,同时锁定文件,以防"
3552 "止多个人他同时修改。"
3554 #. type: Content of: <book><chapter><sect1><para>
3555 #: ../en/ch01-intro.xml:666
3556 msgid ""
3557 "Later in the 1980s, Dick Grune used RCS as a building block for a set of "
3558 "shell scripts he initially called cmt, but then renamed to CVS (Concurrent "
3559 "Versions System). The big innovation of CVS was that it let developers work "
3560 "simultaneously and somewhat independently in their own personal workspaces. "
3561 "The personal workspaces prevented developers from stepping on each other's "
3562 "toes all the time, as was common with SCCS and RCS. Each developer had a copy "
3563 "of every project file, and could modify their copies independently. They had "
3564 "to merge their edits prior to committing changes to the central repository."
3565 msgstr ""
3566 "八十年代后期,Dick Grune在RCS的基础上开发了一套脚本,他开始称之为cmt,后来又改"
3567 "名为CVS(并行版本系统)。CVS的最大的创新在于让开发人员可以在自己的工作空间里同"
3568 "时而且独立的工作。私人的工作空间防止了开发人员总是互相干扰,这在SCCS和RCS的使"
3569 "用中很常见。项目中的每个文件,开发者都有自己的拷贝,可以独立的修改自己的拷贝。"
3570 "他们可以在提交到中央版本库之前合并更改。"
3572 #. type: Content of: <book><chapter><sect1><para>
3573 #: ../en/ch01-intro.xml:677
3574 msgid ""
3575 "Brian Berliner took Grune's original scripts and rewrote them in C, releasing "
3576 "in 1989 the code that has since developed into the modern version of CVS. "
3577 "CVS subsequently acquired the ability to operate over a network connection, "
3578 "giving it a client/server architecture. CVS's architecture is centralised; "
3579 "only the server has a copy of the history of the project. Client workspaces "
3580 "just contain copies of recent versions of the project's files, and a little "
3581 "metadata to tell them where the server is. CVS has been enormously "
3582 "successful; it is probably the world's most widely used revision control "
3583 "system."
3584 msgstr ""
3585 "Brian Berliner接管了Grune的脚本,用C重写了一遍,并在1989年发布了这些代码,现在"
3586 "的CVS就是从那时逐渐发展起来的。CVS随后增加了网络的功能,形成了客户/服务器结"
3587 "构。CVS的结构是集中式的;仅在服务器上保存一份项目的历史拷贝。客户工作空间仅包"
3588 "含项目中的文件的最近版本的拷贝,一些元数据告诉它们服务器的地址。CVS获得了极大"
3589 "成功;它可能是世界上应用最广泛的版本控制系统。"
3591 #. type: Content of: <book><chapter><sect1><para>
3592 #: ../en/ch01-intro.xml:688
3593 msgid ""
3594 "In the early 1990s, Sun Microsystems developed an early distributed revision "
3595 "control system, called TeamWare. A TeamWare workspace contains a complete "
3596 "copy of the project's history. TeamWare has no notion of a central "
3597 "repository. (CVS relied upon RCS for its history storage; TeamWare used "
3598 "SCCS.)"
3599 msgstr ""
3600 "90年代早期,Sun公司开发了一个早期的分布式版本控制系统,叫做TeamWeare。TeamWare"
3601 "的工作空间包括项目历史的完整拷贝。TeamWare没有中央版本库的概念。(CVS使用RCS存"
3602 "储其历史,TeamWare使用SCCS。"
3604 #. type: Content of: <book><chapter><sect1><para>
3605 #: ../en/ch01-intro.xml:695
3606 msgid ""
3607 "As the 1990s progressed, awareness grew of a number of problems with CVS. It "
3608 "records simultaneous changes to multiple files individually, instead of "
3609 "grouping them together as a single logically atomic operation. It does not "
3610 "manage its file hierarchy well; it is easy to make a mess of a repository by "
3611 "renaming files and directories. Worse, its source code is difficult to read "
3612 "and maintain, which made the <quote>pain level</quote> of fixing these "
3613 "architectural problems prohibitive."
3614 msgstr ""
3615 "在90年代中,随着时间的流逝,CVS逐渐暴露出很多问题。它对多个文件同时发生的变更"
3616 "不能一起记录,不能按照层次管理文件;对目录和文件的重命名很容易破坏版本库。更糟"
3617 "的是,它的源代码很难阅读和维护,修复这些架构上的问题的非常困难。"
3619 #. type: Content of: <book><chapter><sect1><para>
3620 #: ../en/ch01-intro.xml:705
3621 msgid ""
3622 "In 2001, Jim Blandy and Karl Fogel, two developers who had worked on CVS, "
3623 "started a project to replace it with a tool that would have a better "
3624 "architecture and cleaner code. The result, Subversion, does not stray from "
3625 "CVS's centralised client/server model, but it adds multi-file atomic commits, "
3626 "better namespace management, and a number of other features that make it a "
3627 "generally better tool than CVS. Since its initial release, it has rapidly "
3628 "grown in popularity."
3629 msgstr ""
3630 "2001年,原来维护过CVS的两个开发者Jim Blandy和Karl Fogel,开始了一个新项目,其"
3631 "目标是替代CVS,新的软件将采用更好的架构和更整洁的代码。于是Subversion诞生了,"
3632 "它并保留了CVS集中式的客户/服务器模型,但是增加了多文件原子提交,更好的命名空间"
3633 "管理,和其他一些功能。总而言之,它比CVS好的多。Subversion在发布后迅速流行起"
3634 "来。"
3636 #. type: Content of: <book><chapter><sect1><para>
3637 #: ../en/ch01-intro.xml:714
3638 msgid ""
3639 "More or less simultaneously, Graydon Hoare began working on an ambitious "
3640 "distributed revision control system that he named Monotone. While Monotone "
3641 "addresses many of CVS's design flaws and has a peer-to-peer architecture, it "
3642 "goes beyond earlier (and subsequent) revision control tools in a number of "
3643 "innovative ways. It uses cryptographic hashes as identifiers, and has an "
3644 "integral notion of <quote>trust</quote> for code from different sources."
3645 msgstr ""
3646 "大概相同时间,Graydon Hoare开始了一个野心勃勃的分布式版本控制项目,他称之为"
3647 "Monotone。Monotone解决了很多CVS设计上的漏洞并且采用了点对点的架构,它在创新方"
3648 "面比以前(和以后)的版本控制系统走的更远。它使用加密哈希作为标识符,并且对于不"
3649 "同源的代码有了完整的 <quote>信任</quote>概念。"
3651 #. type: Content of: <book><chapter><sect1><para>
3652 #: ../en/ch01-intro.xml:723
3653 msgid ""
3654 "Mercurial began life in 2005. While a few aspects of its design are "
3655 "influenced by Monotone, Mercurial focuses on ease of use, high performance, "
3656 "and scalability to very large projects."
3657 msgstr ""
3658 "Mercurial诞生于2005年。设计方面受了Monotone的一些影响,Mercurial的目标是易用,"
3659 "高性能,对大的项目的良好扩展性。"
3661 #. type: Content of: <book><chapter><title>
3662 #: ../en/ch02-tour-basic.xml:5
3663 msgid "A tour of Mercurial: the basics"
3664 msgstr "Mercurial 教程: 基础知识"
3666 #. type: Content of: <book><chapter><sect1><title>
3667 #: ../en/ch02-tour-basic.xml:8
3668 msgid "Installing Mercurial on your system"
3669 msgstr "安装 Mercurial"
3671 #. type: Content of: <book><chapter><sect1><para>
3672 #: ../en/ch02-tour-basic.xml:10
3673 msgid ""
3674 "Prebuilt binary packages of Mercurial are available for every popular "
3675 "operating system. These make it easy to start using Mercurial on your "
3676 "computer immediately."
3677 msgstr ""
3678 "对于每种流行的操作系统,都有已经构建的二进制软件包。这让在你的计算机上开始使"
3679 "用 Mercurial 变得很容易。"
3681 #. type: Content of: <book><chapter><sect1><sect2><title>
3682 #: ../en/ch02-tour-basic.xml:15
3683 msgid "Windows"
3684 msgstr "Windows"
3686 #. type: Content of: <book><chapter><sect1><sect2><para>
3687 #: ../en/ch02-tour-basic.xml:17
3688 msgid ""
3689 "The best version of Mercurial for Windows is TortoiseHg, which can be found "
3690 "at <ulink url=\"http://bitbucket.org/tortoisehg/stable/wiki/Home\">http://"
3691 "bitbucket.org/tortoisehg/stable/wiki/Home</ulink>. This package has no "
3692 "external dependencies; it <quote>just works</quote>. It provides both "
3693 "command line and graphical user interfaces."
3694 msgstr ""
3695 "Windows 中最好的 Mercurial 版本是TortoiseHg,它的主页地址是 <ulink url="
3696 "\"http://bitbucket.org/tortoisehg/stable/wiki/Home\">http://bitbucket.org/"
3697 "tortoisehg/stable/wiki/Home</ulink>。这个软件没有外部依赖,它可以<quote>独立工"
3698 "作</quote>,同时提供了命令行和图形用户界面。"
3700 #. type: Content of: <book><chapter><sect1><sect2><title>
3701 #: ../en/ch02-tour-basic.xml:27
3702 msgid "Mac OS X"
3703 msgstr "Mac OS X"
3705 #. type: Content of: <book><chapter><sect1><sect2><para>
3706 #: ../en/ch02-tour-basic.xml:29
3707 msgid ""
3708 "Lee Cantey publishes an installer of Mercurial for Mac OS X at <ulink url="
3709 "\"http://mercurial.berkwood.com\">http://mercurial.berkwood.com</ulink>."
3710 msgstr ""
3711 "Lee Cantey 为 Mac OS X 在 <ulink url=\"http://mercurial.berkwood.com"
3712 "\">http://mercurial.berkwood.com</ulink> 发布了 Mercurial 安装程序。"
3714 #. type: Content of: <book><chapter><sect1><sect2><title>
3715 #: ../en/ch02-tour-basic.xml:35
3716 msgid "Linux"
3717 msgstr "Linux"
3719 #. type: Content of: <book><chapter><sect1><sect2><para>
3720 #: ../en/ch02-tour-basic.xml:37
3721 msgid ""
3722 "Because each Linux distribution has its own packaging tools, policies, and "
3723 "rate of development, it's difficult to give a comprehensive set of "
3724 "instructions on how to install Mercurial binaries. The version of Mercurial "
3725 "that you will end up with can vary depending on how active the person is who "
3726 "maintains the package for your distribution."
3727 msgstr ""
3728 "由于每种 Linux 发行版都有自己的包管理工具,开发策略和进度,从而很难给出安装 "
3729 "Mercurial 二进制包的全面说明。你安装的 Mercurial 版本,在很大程度上依赖于你所"
3730 "使用的发行版的 Mercurial 维护者的活跃程度。"
3732 #. type: Content of: <book><chapter><sect1><sect2><para>
3733 #: ../en/ch02-tour-basic.xml:44
3734 msgid ""
3735 "To keep things simple, I will focus on installing Mercurial from the command "
3736 "line under the most popular Linux distributions. Most of these distributions "
3737 "provide graphical package managers that will let you install Mercurial with a "
3738 "single click; the package name to look for is <literal>mercurial</literal>."
3739 msgstr ""
3740 "为了让事情简单,我会致力于说明在最流行的 Linux 发行版中,从命令行安装 "
3741 "Mercurial 的方法。这些发行版都提供了图形界面的包管理器,让你通过点击鼠标安装 "
3742 "Mercurial;寻找的包名称是 <literal>mercurial</literal>。"
3744 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
3745 #: ../en/ch02-tour-basic.xml:52
3746 msgid "Ubuntu and Debian:"
3747 msgstr "Ubuntu 与 Debian:"
3749 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
3750 #: ../en/ch02-tour-basic.xml:54
3751 msgid "Fedora:"
3752 msgstr "Fedora:"
3754 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
3755 #: ../en/ch02-tour-basic.xml:56
3756 msgid "OpenSUSE:"
3757 msgstr "OpenSUSE:"
3759 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
3760 #: ../en/ch02-tour-basic.xml:58
3761 msgid "Gentoo:"
3762 msgstr "Gentoo:"
3764 #. type: Content of: <book><chapter><sect1><sect2><title>
3765 #: ../en/ch02-tour-basic.xml:64
3766 msgid "Solaris"
3767 msgstr "Solaris"
3769 #. type: Content of: <book><chapter><sect1><sect2><para>
3770 #: ../en/ch02-tour-basic.xml:66
3771 msgid ""
3772 "SunFreeWare, at <ulink url=\"http://www.sunfreeware.com\">http://www."
3773 "sunfreeware.com</ulink>, provides prebuilt packages of Mercurial."
3774 msgstr ""
3775 "位于 <ulink url=\"http://www.sunfreeware.com\">http://www.sunfreeware.com</"
3776 "ulink> 的 SunFreeWare 提供了 Mercurial 的二进制安装包。"
3778 #. type: Content of: <book><chapter><sect1><title>
3779 #: ../en/ch02-tour-basic.xml:75
3780 msgid "Getting started"
3781 msgstr "开始"
3783 #. type: Content of: <book><chapter><sect1><para>
3784 #: ../en/ch02-tour-basic.xml:77
3785 msgid ""
3786 "To begin, we'll use the <command role=\"hg-cmd\">hg version</command> command "
3787 "to find out whether Mercurial is installed properly. The actual version "
3788 "information that it prints isn't so important; we simply care whether the "
3789 "command runs and prints anything at all."
3790 msgstr ""
3791 "首先,我们使用 <command role=\"hg-cmd\">hg version</command> 命令检查 "
3792 "Mercurial 是否已经正确安装。它打印出来的实际版本信息并不重要;我们只关心它是否"
3793 "能够运行,打印出信息。"
3795 #. type: Content of: <book><chapter><sect1><sect2><title>
3796 #: ../en/ch02-tour-basic.xml:86
3797 msgid "Built-in help"
3798 msgstr "内置帮助"
3800 #. type: Content of: <book><chapter><sect1><sect2><para>
3801 #: ../en/ch02-tour-basic.xml:88
3802 msgid ""
3803 "Mercurial provides a built-in help system. This is invaluable for those "
3804 "times when you find yourself stuck trying to remember how to run a command. "
3805 "If you are completely stuck, simply run <command role=\"hg-cmd\">hg help</"
3806 "command>; it will print a brief list of commands, along with a description of "
3807 "what each does. If you ask for help on a specific command (as below), it "
3808 "prints more detailed information."
3809 msgstr ""
3810 "Mercurial 内置了帮助系统。当你不记得如何执行一个命令时,它会给你重要的帮助。如"
3811 "果你完全没有头绪,那就直接运行 <command role=\"hg-cmd\">hg help</command>;它"
3812 "会给出命令的简短列表,还描述了每个命令的作用。如果你需要具体命令的帮助(下述),"
3813 "它会给出更详细的信息。"
3815 #. type: Content of: <book><chapter><sect1><sect2><para>
3816 #: ../en/ch02-tour-basic.xml:99
3817 msgid ""
3818 "For a more impressive level of detail (which you won't usually need) run "
3819 "<command role=\"hg-cmd\">hg help <option role=\"hg-opt-global\">-v</option></"
3820 "command>. The <option role=\"hg-opt-global\">-v</option> option is short for "
3821 "<option role=\"hg-opt-global\">--verbose</option>, and tells Mercurial to "
3822 "print more information than it usually would."
3823 msgstr ""
3824 "要获得更多的详细信息(通常不需要),可以执行 <command role=\"hg-cmd\">hg help "
3825 "<option role=\"hg-opt-global\">-v</option></command>。选项 <option role=\"hg-"
3826 "opt-global\">-v</option> 是 <option role=\"hg-opt-global\">--verbose</option> "
3827 "的短格式,告诉 Mercurial 要打印通常不需要的更多信息。"
3829 #. type: Content of: <book><chapter><sect1><title>
3830 #: ../en/ch02-tour-basic.xml:110
3831 msgid "Working with a repository"
3832 msgstr "使用版本库"
3834 #. type: Content of: <book><chapter><sect1><para>
3835 #: ../en/ch02-tour-basic.xml:112
3836 msgid ""
3837 "In Mercurial, everything happens inside a <emphasis>repository</emphasis>. "
3838 "The repository for a project contains all of the files that <quote>belong to</"
3839 "quote> that project, along with a historical record of the project's files."
3840 msgstr ""
3841 "在Mercurial中,所有的操作都在<emphasis>版本库</emphasis>中进行。项目的版本库包"
3842 "括了属于该项目的所有文件和这些文件的历史记录。"
3844 #. type: Content of: <book><chapter><sect1><para>
3845 #: ../en/ch02-tour-basic.xml:118
3846 msgid ""
3847 "There's nothing particularly magical about a repository; it is simply a "
3848 "directory tree in your filesystem that Mercurial treats as special. You can "
3849 "rename or delete a repository any time you like, using either the command "
3850 "line or your file browser."
3851 msgstr ""
3852 "版本库没有什么神秘的地方;仅仅是你系统中的一个目录树,Mercurial会将它们特殊处"
3853 "理。你可以在任何喜欢的时候使用命令行或者文件浏览器删除版本库或者给它改名。"
3855 #. type: Content of: <book><chapter><sect1><sect2><title>
3856 #: ../en/ch02-tour-basic.xml:125
3857 msgid "Making a local copy of a repository"
3858 msgstr "创建版本库的工作副本"
3860 #. type: Content of: <book><chapter><sect1><sect2><para>
3861 #: ../en/ch02-tour-basic.xml:127
3862 msgid ""
3863 "<emphasis>Copying</emphasis> a repository is just a little bit special. "
3864 "While you could use a normal file copying command to make a copy of a "
3865 "repository, it's best to use a built-in command that Mercurial provides. "
3866 "This command is called <command role=\"hg-cmd\">hg clone</command>, because "
3867 "it makes an identical copy of an existing repository."
3868 msgstr ""
3869 "<emphasis>拷贝</emphasis>版本库有点特殊。虽然你可以使用文件拷贝命令来复制一般"
3870 "版本库,最好还是用Mercurial内置的命令。这个命令叫做 <command role=\"hg-cmd"
3871 "\">hg clone</command>,因为它创建了一个原来版本库的拷贝。"
3873 #. type: Content of: <book><chapter><sect1><sect2><para>
3874 #: ../en/ch02-tour-basic.xml:136
3875 msgid ""
3876 "One advantage of using <command role=\"hg-cmd\">hg clone</command> is that, "
3877 "as we can see above, it lets us clone repositories over the network. Another "
3878 "is that it remembers where we cloned from, which we'll find useful soon when "
3879 "we want to fetch new changes from another repository."
3880 msgstr ""
3881 "如上所示,使用<command role=\"hg-cmd\">hg clone</command>的好处在于它能够让你"
3882 "通过网络克隆版本库。另外一个好处你它会记得这个版本库是从哪里克隆的,稍后会看"
3883 "到,当我们想从其他的版本库获取新的变更的时候这点这会非常有用。"
3885 #. type: Content of: <book><chapter><sect1><sect2><para>
3886 #: ../en/ch02-tour-basic.xml:142
3887 msgid ""
3888 "If our clone succeeded, we should now have a local directory called <filename "
3889 "class=\"directory\">hello</filename>. This directory will contain some files."
3890 msgstr ""
3891 "如果我们克隆成功,我们会得到一个本地目录,叫做 <filename class=\"directory"
3892 "\">hello</filename>。这个目录会包括一些文件。"
3894 #. type: Content of: <book><chapter><sect1><sect2><para>
3895 #: ../en/ch02-tour-basic.xml:148
3896 msgid ""
3897 "These files have the same contents and history in our repository as they do "
3898 "in the repository we cloned."
3899 msgstr "这个版本库中的文件和我们刚才克隆的版本库中的文件相同的内容和版本历史"
3901 #. type: Content of: <book><chapter><sect1><sect2><para>
3902 #: ../en/ch02-tour-basic.xml:151
3903 msgid ""
3904 "Every Mercurial repository is complete, self-contained, and independent. It "
3905 "contains its own private copy of a project's files and history. As we just "
3906 "mentioned, a cloned repository remembers the location of the repository it "
3907 "was cloned from, but Mercurial will not communicate with that repository, or "
3908 "any other, unless you tell it to."
3909 msgstr ""
3910 "每个Mercurial版本库都是完整的,自包含的,独立的。它包含了项目文件的一份私有拷"
3911 "贝和全部历史。我们刚才已经提到,克隆的版本库会记住它克隆的那个版本库的地址,但"
3912 "是Mercurial不会和那个或者其他任何一个版本库通信,除非你给它命令。"
3914 #. type: Content of: <book><chapter><sect1><sect2><para>
3915 #: ../en/ch02-tour-basic.xml:158
3916 msgid ""
3917 "What this means for now is that we're free to experiment with our repository, "
3918 "safe in the knowledge that it's a private <quote>sandbox</quote> that won't "
3919 "affect anyone else."
3920 msgstr ""
3921 "这意味着,我们可以随意的在我们的版本库中做实验,非常安全,因为它是一个私有的"
3922 "<quote>沙盒</quote>,不会影响任何人。"
3924 #. type: Content of: <book><chapter><sect1><sect2><title>
3925 #: ../en/ch02-tour-basic.xml:164
3926 msgid "What's in a repository?"
3927 msgstr "什么是版本库?"
3929 #. type: Content of: <book><chapter><sect1><sect2><para>
3930 #: ../en/ch02-tour-basic.xml:166
3931 msgid ""
3932 "When we take a more detailed look inside a repository, we can see that it "
3933 "contains a directory named <filename class=\"directory\">.hg</filename>. "
3934 "This is where Mercurial keeps all of its metadata for the repository."
3935 msgstr ""
3936 "当我们仔细观察版本库内部时,我们会发现它有一个叫<filename class=\"directory"
3937 "\">.hg</filename>的目录。这就是Mercurial为版本库保存所有元数据的地方。"
3939 #. type: Content of: <book><chapter><sect1><sect2><para>
3940 #: ../en/ch02-tour-basic.xml:173
3941 msgid ""
3942 "The contents of the <filename class=\"directory\">.hg</filename> directory "
3943 "and its subdirectories are private to Mercurial. Every other file and "
3944 "directory in the repository is yours to do with as you please."
3945 msgstr ""
3946 "目录<filename class=\"directory\">.hg</filename>中的内容和其子目录是Mercurial"
3947 "私有的。版本库中的其他任何文件和目录你都可以随意操作。"
3949 #. type: Content of: <book><chapter><sect1><sect2><para>
3950 #: ../en/ch02-tour-basic.xml:179
3951 msgid ""
3952 "To introduce a little terminology, the <filename class=\"directory\">.hg</"
3953 "filename> directory is the <quote>real</quote> repository, and all of the "
3954 "files and directories that coexist with it are said to live in the "
3955 "<emphasis>working directory</emphasis>. An easy way to remember the "
3956 "distinction is that the <emphasis>repository</emphasis> contains the "
3957 "<emphasis>history</emphasis> of your project, while the <emphasis>working "
3958 "directory</emphasis> contains a <emphasis>snapshot</emphasis> of your project "
3959 "at a particular point in history."
3960 msgstr ""
3961 "介绍一点术语, <filename class=\"directory\">.hg</filename>目录是<quote>真正的"
3962 "</quote>版本库,所有其他的文件和目录称为<emphasis>工作目录</emphasis>一个简单"
3963 "的区分的方法就是<emphasis>版本库</emphasis>中包含了项目的<emphasis>历史</"
3964 "emphasis>,而 <emphasis>工作目录</emphasis>则是项目组一个特定历史点上的"
3965 "<emphasis>快照</emphasis>。"
3967 #. type: Content of: <book><chapter><sect1><title>
3968 #: ../en/ch02-tour-basic.xml:194
3969 msgid "A tour through history"
3970 msgstr "回溯历史"
3972 #. type: Content of: <book><chapter><sect1><para>
3973 #: ../en/ch02-tour-basic.xml:196
3974 msgid ""
3975 "One of the first things we might want to do with a new, unfamiliar repository "
3976 "is understand its history. The <command role=\"hg-cmd\">hg log</command> "
3977 "command gives us a view of the history of changes in the repository."
3978 msgstr ""
3979 "对于一个新的,我们不熟悉的版本库,我们想做的第一件事就是了解它的历史。命令"
3980 "<command role=\"hg-cmd\">hg log</command>可以让我们浏览版本库中的历史变更。"
3982 #. type: Content of: <book><chapter><sect1><para>
3983 #: ../en/ch02-tour-basic.xml:203
3984 msgid ""
3985 "By default, this command prints a brief paragraph of output for each change "
3986 "to the project that was recorded. In Mercurial terminology, we call each of "
3987 "these recorded events a <emphasis>changeset</emphasis>, because it can "
3988 "contain a record of changes to several files."
3989 msgstr ""
3990 "缺省情况下,这个命令对项目中记录的每个变更都输出一段简介,在Mercurial的术语"
3991 "中,我们将这些记录的事件成为<emphasis>变更集</emphasis>,因为每个记录都可能包"
3992 "括几个文件的变更。"
3994 #. type: Content of: <book><chapter><sect1><para>
3995 #: ../en/ch02-tour-basic.xml:209
3996 msgid ""
3997 "The fields in a record of output from <command role=\"hg-cmd\">hg log</"
3998 "command> are as follows."
3999 msgstr ""
4000 " <command role=\"hg-cmd\">hg log</command>输出记录的各个字段的意义如下。"
4002 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
4003 #: ../en/ch02-tour-basic.xml:213
4004 msgid ""
4005 "<literal>changeset</literal>: This field has the format of a number, followed "
4006 "by a colon, followed by a hexadecimal (or <emphasis>hex</emphasis>) string. "
4007 "These are <emphasis>identifiers</emphasis> for the changeset. The hex string "
4008 "is a unique identifier: the same hex string will always refer to the same "
4009 "changeset in every copy of this repository. The number is shorter and easier "
4010 "to type than the hex string, but it isn't unique: the same number in two "
4011 "different clones of a repository may identify different changesets."
4012 msgstr ""
4013 "<literal>changeset</literal>:这个字段包括一个数字,接着一个冒号,然后是是一个"
4014 "十六进制字符串。这是这个变更的<emphasis>标识符</emphasis>。十六进制字符串是唯"
4015 "一标识符:在这个版本库的任何一个拷贝中,同一个字符串总是对应同一个变更集。数字"
4016 "更短并且比十六进制字符串更容易书写,但它不是唯一的:一个版本库的两个不同的的克"
4017 "隆中的同一个数字可能对应不同的变更集。"
4019 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
4020 #: ../en/ch02-tour-basic.xml:224
4021 msgid ""
4022 "<literal>user</literal>: The identity of the person who created the "
4023 "changeset. This is a free-form field, but it most often contains a person's "
4024 "name and email address."
4025 msgstr ""
4026 "<literal>user</literal>:这个字段标识是谁创建了这个变更集。这个字段格式可以自"
4027 "由定义,通常是一个人的姓名加上电子邮件地址。"
4029 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
4030 #: ../en/ch02-tour-basic.xml:228
4031 msgid ""
4032 "<literal>date</literal>: The date and time on which the changeset was "
4033 "created, and the timezone in which it was created. (The date and time are "
4034 "local to that timezone; they display what time and date it was for the person "
4035 "who created the changeset.)"
4036 msgstr ""
4037 "<literal>date</literal>:这是变更集创建的日期和时间,还有时区。(日期和时间是"
4038 "相对于时区的;他们显示了创建变更的人的日期和时间。)"
4040 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
4041 #: ../en/ch02-tour-basic.xml:233
4042 msgid ""
4043 "<literal>summary</literal>: The first line of the text message that the "
4044 "creator of the changeset entered to describe the changeset."
4045 msgstr "<literal>summary</literal>:创建者对该变更集的描述的第一行文本信息。"
4047 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
4048 #: ../en/ch02-tour-basic.xml:237
4049 msgid ""
4050 "Some changesets, such as the first in the list above, have a <literal>tag</"
4051 "literal> field. A tag is another way to identify a changeset, by giving it "
4052 "an easy-to-remember name. (The tag named <literal>tip</literal> is special: "
4053 "it always refers to the newest change in a repository.)"
4054 msgstr ""
4055 "有些变更集,像上面的第一个,有一个<literal>标签</literal>字段。标签是区分变更"
4056 "集的另外一种方法,给它一个容易记得名字。(叫做<literal>tip</literal>的标签有特"
4057 "殊意义:总是指向版本库中的最新的变更。)"
4059 #. type: Content of: <book><chapter><sect1><para>
4060 #: ../en/ch02-tour-basic.xml:245
4061 msgid ""
4062 "The default output printed by <command role=\"hg-cmd\">hg log</command> is "
4063 "purely a summary; it is missing a lot of detail."
4064 msgstr ""
4065 "缺省情况下,<command role=\"hg-cmd\">hg log</command>的输出仅仅是个摘要,没有"
4066 "更详细的信息。"
4068 #. type: Content of: <book><chapter><sect1><para>
4069 #: ../en/ch02-tour-basic.xml:249
4070 msgid ""
4071 "<xref linkend=\"fig:tour-basic:history\"/> provides a graphical "
4072 "representation of the history of the <filename class=\"directory\">hello</"
4073 "filename> repository, to make it a little easier to see which direction "
4074 "history is <quote>flowing</quote> in. We'll be returning to this figure "
4075 "several times in this chapter and the chapter that follows."
4076 msgstr ""
4077 "<xref linkend=\"fig:tour-basic:history\"/>以图形化方式显示了版本库<filename "
4078 "class=\"directory\">hello</filename>的历史,这样很容易看出历史的<quote>流向</"
4079 "quote>。在本章和下面的章节中,我们会多次使用这个图。"
4081 #. type: Content of: <book><chapter><sect1><figure><title>
4082 #: ../en/ch02-tour-basic.xml:258
4083 msgid ""
4084 "Graphical history of the <filename class=\"directory\">hello</filename> "
4085 "repository"
4086 msgstr "版本库 <filename class=\"directory\">hello</filename> 的历史图"
4088 #. type: Content of: <book><chapter><sect1><figure>
4089 #: ../en/ch02-tour-basic.xml:260 ../en/ch03-tour-merge.xml:61
4090 #: ../en/ch03-tour-merge.xml:207 ../en/ch04-concepts.xml:290
4091 msgid "<placeholder type=\"mediaobject\" id=\"0\"/>"
4092 msgstr ""
4094 #. type: Content of: <book><chapter><sect1><figure><mediaobject>
4095 #: ../en/ch02-tour-basic.xml:261
4096 msgid ""
4097 "<imageobject><imagedata fileref=\"figs/tour-history.png\"/></imageobject>"
4098 msgstr ""
4100 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject><textobject><phrase>
4101 #: ../en/ch02-tour-basic.xml:262 ../en/ch03-tour-merge.xml:63
4102 #: ../en/ch03-tour-merge.xml:95 ../en/ch03-tour-merge.xml:182
4103 #: ../en/ch03-tour-merge.xml:209 ../en/ch03-tour-merge.xml:279
4104 #: ../en/ch04-concepts.xml:59 ../en/ch04-concepts.xml:108
4105 #: ../en/ch04-concepts.xml:198 ../en/ch04-concepts.xml:292
4106 #: ../en/ch04-concepts.xml:347 ../en/ch04-concepts.xml:362
4107 #: ../en/ch04-concepts.xml:403 ../en/ch04-concepts.xml:423
4108 #: ../en/ch04-concepts.xml:469 ../en/ch06-collab.xml:316
4109 #: ../en/ch09-undo.xml:344 ../en/ch09-undo.xml:391 ../en/ch09-undo.xml:464
4110 #: ../en/ch09-undo.xml:502 ../en/ch09-undo.xml:658 ../en/ch09-undo.xml:682
4111 #: ../en/ch09-undo.xml:700 ../en/ch09-undo.xml:714 ../en/ch09-undo.xml:727
4112 #: ../en/ch12-mq.xml:413
4113 msgid "XXX add text"
4114 msgstr ""
4116 #. type: Content of: <book><chapter><sect1><sect2><title>
4117 #: ../en/ch02-tour-basic.xml:267
4118 msgid "Changesets, revisions, and talking to other people"
4119 msgstr "变更集,版本,与其它用户交互"
4121 #. type: Content of: <book><chapter><sect1><sect2><para>
4122 #: ../en/ch02-tour-basic.xml:270
4123 msgid ""
4124 "As English is a notoriously sloppy language, and computer science has a "
4125 "hallowed history of terminological confusion (why use one term when four will "
4126 "do?), revision control has a variety of words and phrases that mean the same "
4127 "thing. If you are talking about Mercurial history with other people, you "
4128 "will find that the word <quote>changeset</quote> is often compressed to "
4129 "<quote>change</quote> or (when written) <quote>cset</quote>, and sometimes a "
4130 "changeset is referred to as a <quote>revision</quote> or a <quote>rev</quote>."
4131 msgstr ""
4132 "英语是一种非常随便的语言,计算机史上也向来以混乱的术语为荣(如能用四个词为什么"
4133 "要用一个呢?),就版本控制而言,有很多词和短语有相同的意思。如果你和别人讨论"
4134 "Mercurial版本库的历史,你会发现<quote>变更集</quote>这个词常常被简化成<quote>"
4135 "变更</quote>或者(写的时候)<quote>cset</quote>,有时候变更集也指一个<quote>版"
4136 "本</quote>或者<quote>rev</quote>。"
4138 #. type: Content of: <book><chapter><sect1><sect2><para>
4139 #: ../en/ch02-tour-basic.xml:280
4140 msgid ""
4141 "While it doesn't matter what <emphasis>word</emphasis> you use to refer to "
4142 "the concept of <quote>a changeset</quote>, the <emphasis>identifier</"
4143 "emphasis> that you use to refer to <quote>a <emphasis>specific</emphasis> "
4144 "changeset</quote> is of great importance. Recall that the <literal>changeset</"
4145 "literal> field in the output from <command role=\"hg-cmd\">hg log</command> "
4146 "identifies a changeset using both a number and a hexadecimal string."
4147 msgstr ""
4148 "实际上,用哪个<emphasis>词</emphasis>来描述<quote>变更集</quote>的概念并不重"
4149 "要,重要的是如何用<emphasis>标识符</emphasis>来标识<quote>一个<emphasis>特定的"
4150 "</emphasis>变更集</quote>。回忆一下<command role=\"hg-cmd\">hg log</command>命"
4151 "令的输出,<literal>changeset</literal>字段里用一个数字和一个十六进制字符串来标"
4152 "识一个变更集。"
4154 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
4155 #: ../en/ch02-tour-basic.xml:289
4156 msgid ""
4157 "The revision number is a handy notation that is <emphasis>only valid in that "
4158 "repository</emphasis>."
4159 msgstr "版本号是一个方便的标识,它仅在<emphasis>当前版本库中有效</emphasis>。"
4161 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
4162 #: ../en/ch02-tour-basic.xml:292
4163 msgid ""
4164 "The hexadecimal string is the <emphasis>permanent, unchanging identifier</"
4165 "emphasis> that will always identify that exact changeset in <emphasis>every</"
4166 "emphasis> copy of the repository."
4167 msgstr ""
4168 "十六进制字符串是<emphasis>永久的,不变的标识</emphasis>,它在该版本库的所有拷"
4169 "贝中都指向同一个变更集。"
4171 #. type: Content of: <book><chapter><sect1><sect2><para>
4172 #: ../en/ch02-tour-basic.xml:298
4173 msgid ""
4174 "This distinction is important. If you send someone an email talking about "
4175 "<quote>revision 33</quote>, there's a high likelihood that their revision 33 "
4176 "will <emphasis>not be the same</emphasis> as yours. The reason for this is "
4177 "that a revision number depends on the order in which changes arrived in a "
4178 "repository, and there is no guarantee that the same changes will happen in "
4179 "the same order in different repositories. Three changes <literal>a,b,c</"
4180 "literal> can easily appear in one repository as <literal>0,1,2</literal>, "
4181 "while in another as <literal>0,2,1</literal>."
4182 msgstr ""
4183 "这个区别很重要。如果你通过邮件和别人讨论<quote>版本33</quote>,很有可能他们的"
4184 "版本33和你的<emphasis>不一样</emphasis>。原因在于版本号依赖于相应变更进入版本"
4185 "库的顺序。,不能保证同一个变更在不同的版本库中会有相同的次序。有可能三个变更"
4186 "<literal>a,b,c</literal>在一个版本库中的次序是<literal>0,1,2</literal>,而在另"
4187 "外一个版本库中则变成<literal>0,2,1</literal>"
4189 #. type: Content of: <book><chapter><sect1><sect2><para>
4190 #: ../en/ch02-tour-basic.xml:310
4191 msgid ""
4192 "Mercurial uses revision numbers purely as a convenient shorthand. If you "
4193 "need to discuss a changeset with someone, or make a record of a changeset for "
4194 "some other reason (for example, in a bug report), use the hexadecimal "
4195 "identifier."
4196 msgstr ""
4197 "Mercurial使用版本号纯粹是为了有些命令的方便,如果你要和别人讨论变更集,或者由"
4198 "于某些原因为一个变更集做记录(如在bug报告中),请使用十六进制标识符。"
4200 #. type: Content of: <book><chapter><sect1><sect2><title>
4201 #: ../en/ch02-tour-basic.xml:318
4202 msgid "Viewing specific revisions"
4203 msgstr "查看指定版本"
4205 #. type: Content of: <book><chapter><sect1><sect2><para>
4206 #: ../en/ch02-tour-basic.xml:320
4207 msgid ""
4208 "To narrow the output of <command role=\"hg-cmd\">hg log</command> down to a "
4209 "single revision, use the <option role=\"hg-opt-log\">-r</option> (or <option "
4210 "role=\"hg-opt-log\">--rev</option>) option. You can use either a revision "
4211 "number or a hexadecimal identifier, and you can provide as many revisions as "
4212 "you want."
4213 msgstr ""
4214 "如果只想用<command role=\"hg-cmd\">hg log</command>查看一个版本的日志使用"
4215 "<option role=\"hg-opt-log\">-r</option>(或者<option role=\"hg-opt-log\">--"
4216 "rev</option>)选项。版本号和十六进制标识符都可以来指定版本,可以一次指定任意多"
4217 "个版本。"
4219 #. type: Content of: <book><chapter><sect1><sect2><para>
4220 #: ../en/ch02-tour-basic.xml:329
4221 msgid ""
4222 "If you want to see the history of several revisions without having to list "
4223 "each one, you can use <emphasis>range notation</emphasis>; this lets you "
4224 "express the idea <quote>I want all revisions between <literal>abc</literal> "
4225 "and <literal>def</literal>, inclusive</quote>."
4226 msgstr ""
4227 "如果你想显示几个版本历史,但是不想一个一个的列出来,可以使用 <emphasis>范围标"
4228 "记</emphasis>;它会显示包括<literal>abc</literal>和<literal>def</literal>,以"
4229 "及它们之间的所有版本的版本历史。"
4231 #. type: Content of: <book><chapter><sect1><sect2><para>
4232 #: ../en/ch02-tour-basic.xml:337
4233 msgid ""
4234 "Mercurial also honours the order in which you specify revisions, so <command "
4235 "role=\"hg-cmd\">hg log -r 2:4</command> prints 2, 3, and 4. while <command "
4236 "role=\"hg-cmd\">hg log -r 4:2</command> prints 4, 3, and 2."
4237 msgstr ""
4238 "Mercurial还可以指定版本的输出顺序,如<command role=\"hg-cmd\">hg log -r 2:4</"
4239 "command>输出2,3,4。而<command role=\"hg-cmd\">hg log -r 4:2</command>则输出"
4240 "4,3,2。"
4242 #. type: Content of: <book><chapter><sect1><sect2><title>
4243 #: ../en/ch02-tour-basic.xml:344
4244 msgid "More detailed information"
4245 msgstr "更详细的信息"
4247 #. type: Content of: <book><chapter><sect1><sect2><para>
4248 #: ../en/ch02-tour-basic.xml:346
4249 msgid ""
4250 "While the summary information printed by <command role=\"hg-cmd\">hg log</"
4251 "command> is useful if you already know what you're looking for, you may need "
4252 "to see a complete description of the change, or a list of the files changed, "
4253 "if you're trying to decide whether a changeset is the one you're looking for. "
4254 "The <command role=\"hg-cmd\">hg log</command> command's <option role=\"hg-opt-"
4255 "global\">-v</option> (or <option role=\"hg-opt-global\">--verbose</option>) "
4256 "option gives you this extra detail."
4257 msgstr ""
4258 "当你知道你在找那个版本的时候,<command role=\"hg-cmd\">hg log</command>输出的"
4259 "摘要是非常有用的,但有时候你不知道要找哪个版本,你想看到变更的完整描述,或者修"
4260 "改过的文件的列表,<command role=\"hg-cmd\">hg log</command>命令的<option role="
4261 "\"hg-opt-global\">-v</option>(<option role=\"hg-opt-global\">--verbose</"
4262 "option>)选项会给出更详细的信息。"
4264 #. type: Content of: <book><chapter><sect1><sect2><para>
4265 #: ../en/ch02-tour-basic.xml:358
4266 msgid ""
4267 "If you want to see both the description and content of a change, add the "
4268 "<option role=\"hg-opt-log\">-p</option> (or <option role=\"hg-opt-log\">--"
4269 "patch</option>) option. This displays the content of a change as a "
4270 "<emphasis>unified diff</emphasis> (if you've never seen a unified diff "
4271 "before, see <xref linkend=\"sec:mq:patch\"/> for an overview)."
4272 msgstr ""
4273 "如果你想同时看到变更的描述和内容,增加<option role=\"hg-opt-log\">-p</option>"
4274 "(<option role=\"hg-opt-log\">--patch</option>)选项。这会将变更的内容以"
4275 "<emphasis>unified diff</emphasis>的格式显示(如果你不知道unified diff,请参考"
4276 "<xref linkend=\"sec:mq:patch\"/>。"
4278 #. type: Content of: <book><chapter><sect1><sect2><para>
4279 #: ../en/ch02-tour-basic.xml:368
4280 msgid ""
4281 "The <option role=\"hg-opt-log\">-p</option> option is tremendously useful, so "
4282 "it's well worth remembering."
4283 msgstr "<option role=\"hg-opt-log\">-p</option>选项非常有用,所以一定要记住。"
4285 #. type: Content of: <book><chapter><sect1><title>
4286 #: ../en/ch02-tour-basic.xml:375
4287 msgid "All about command options"
4288 msgstr "命令选项"
4290 #. type: Content of: <book><chapter><sect1><para>
4291 #: ../en/ch02-tour-basic.xml:377
4292 msgid ""
4293 "Let's take a brief break from exploring Mercurial commands to discuss a "
4294 "pattern in the way that they work; you may find this useful to keep in mind "
4295 "as we continue our tour."
4296 msgstr ""
4297 "我们休息一下,先不讨论Mercurial命令了,而是来看看它们工作的模式;这对以后的学"
4298 "习会非常有帮助。"
4300 #. type: Content of: <book><chapter><sect1><para>
4301 #: ../en/ch02-tour-basic.xml:381
4302 msgid ""
4303 "Mercurial has a consistent and straightforward approach to dealing with the "
4304 "options that you can pass to commands. It follows the conventions for "
4305 "options that are common to modern Linux and Unix systems."
4306 msgstr ""
4307 "Mercurial处理传递给它的命令选项的方法简单一致。它遵从现代Linux和Unix对选项的处"
4308 "理习惯。"
4310 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
4311 #: ../en/ch02-tour-basic.xml:388
4312 msgid ""
4313 "Every option has a long name. For example, as we've already seen, the "
4314 "<command role=\"hg-cmd\">hg log</command> command accepts a <option role=\"hg-"
4315 "opt-log\">--rev</option> option."
4316 msgstr ""
4317 "每个选项有一个长名。例如,我们已经看到了,<command role=\"hg-cmd\">hg log</"
4318 "command>命令接受<option role=\"hg-opt-log\">--rev</option>选项。"
4320 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
4321 #: ../en/ch02-tour-basic.xml:394
4322 msgid ""
4323 "Most options have short names, too. Instead of <option role=\"hg-opt-log\">--"
4324 "rev</option>, we can use <option role=\"hg-opt-log\">-r</option>. (The "
4325 "reason that some options don't have short names is that the options in "
4326 "question are rarely used.)"
4327 msgstr ""
4328 "大多数选项还有短名,除了使用<option role=\"hg-opt-log\">--rev</option>,我们还"
4329 "可以用<option role=\"hg-opt-log\">-r</option>。(有些选项没有短名的原因是他们"
4330 "很少用到。)"
4332 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
4333 #: ../en/ch02-tour-basic.xml:401
4334 msgid ""
4335 "Long options start with two dashes (e.g. <option role=\"hg-opt-log\">--rev</"
4336 "option>), while short options start with one (e.g. <option role=\"hg-opt-log"
4337 "\">-r</option>)."
4338 msgstr ""
4340 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
4341 #: ../en/ch02-tour-basic.xml:407
4342 msgid ""
4343 "Option naming and usage is consistent across commands. For example, every "
4344 "command that lets you specify a changeset ID or revision number accepts both "
4345 "<option role=\"hg-opt-log\">-r</option> and <option role=\"hg-opt-log\">--"
4346 "rev</option> arguments."
4347 msgstr ""
4349 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
4350 #: ../en/ch02-tour-basic.xml:414
4351 msgid ""
4352 "If you are using short options, you can save typing by running them together. "
4353 "For example, the command <command role=\"hg-cmd\">hg log -v -p -r 2</command> "
4354 "can be written as <command role=\"hg-cmd\">hg log -vpr2</command>."
4355 msgstr ""
4356 "如果使用短选项,你可以把它们放在一起以减少输入。例如,命令<command role=\"hg-"
4357 "cmd\">hg log -v -p -r 2</command> 可以写成 <command role=\"hg-cmd\">hg log -"
4358 "vpr2</command>。"
4360 #. type: Content of: <book><chapter><sect1><para>
4361 #: ../en/ch02-tour-basic.xml:421
4362 msgid ""
4363 "In the examples throughout this book, I usually use short options instead of "
4364 "long. This simply reflects my own preference, so don't read anything "
4365 "significant into it."
4366 msgstr ""
4367 "在本书的例子中,我通常使用短选项,很少用长选项。这仅仅是我个人的习惯,你不一定"
4368 "要这样。"
4370 #. type: Content of: <book><chapter><sect1><para>
4371 #: ../en/ch02-tour-basic.xml:425
4372 msgid ""
4373 "Most commands that print output of some kind will print more output when "
4374 "passed a <option role=\"hg-opt-global\">-v</option> (or <option role=\"hg-opt-"
4375 "global\">--verbose</option>) option, and less when passed <option role=\"hg-"
4376 "opt-global\">-q</option> (or <option role=\"hg-opt-global\">--quiet</option>)."
4377 msgstr ""
4379 #. type: Content of: <book><chapter><sect1><note><title>
4380 #: ../en/ch02-tour-basic.xml:432
4381 msgid "Option naming consistency"
4382 msgstr "选项命名的一致性"
4384 #. type: Content of: <book><chapter><sect1><note><para>
4385 #: ../en/ch02-tour-basic.xml:434
4386 msgid ""
4387 "Almost always, Mercurial commands use consistent option names to refer to the "
4388 "same concepts. For instance, if a command deals with changesets, you'll "
4389 "always identify them with <option role=\"hg-opt-log\">--rev</option> or "
4390 "<option role=\"hg-opt-log\">-r</option>. This consistent use of option names "
4391 "makes it easier to remember what options a particular command takes."
4392 msgstr ""
4394 #. type: Content of: <book><chapter><sect1><title>
4395 #: ../en/ch02-tour-basic.xml:445
4396 msgid "Making and reviewing changes"
4397 msgstr "创建和复审变更"
4399 #. type: Content of: <book><chapter><sect1><para>
4400 #: ../en/ch02-tour-basic.xml:447
4401 msgid ""
4402 "Now that we have a grasp of viewing history in Mercurial, let's take a look "
4403 "at making some changes and examining them."
4404 msgstr ""
4405 "现在我们已经对查看Mercurial的版本历史有了一些了解,现在我们开始做些修改并且检"
4406 "查这些修改。"
4408 #. type: Content of: <book><chapter><sect1><para>
4409 #: ../en/ch02-tour-basic.xml:451
4410 msgid ""
4411 "The first thing we'll do is isolate our experiment in a repository of its "
4412 "own. We use the <command role=\"hg-cmd\">hg clone</command> command, but we "
4413 "don't need to clone a copy of the remote repository. Since we already have a "
4414 "copy of it locally, we can just clone that instead. This is much faster than "
4415 "cloning over the network, and cloning a local repository uses less disk space "
4416 "in most cases, too<placeholder type=\"footnote\" id=\"0\"/>."
4417 msgstr ""
4419 #. type: Content of: <book><chapter><sect1><para><footnote><para>
4420 #: ../en/ch02-tour-basic.xml:458
4421 msgid ""
4422 "The saving of space arises when source and destination repositories are on "
4423 "the same filesystem, in which case Mercurial will use hardlinks to do copy-on-"
4424 "write sharing of its internal metadata. If that explanation meant nothing to "
4425 "you, don't worry: everything happens transparently and automatically, and you "
4426 "don't need to understand it."
4427 msgstr ""
4429 #. type: Content of: <book><chapter><sect1><para>
4430 #: ../en/ch02-tour-basic.xml:468
4431 msgid ""
4432 "As an aside, it's often good practice to keep a <quote>pristine</quote> copy "
4433 "of a remote repository around, which you can then make temporary clones of to "
4434 "create sandboxes for each task you want to work on. This lets you work on "
4435 "multiple tasks in parallel, each isolated from the others until it's complete "
4436 "and you're ready to integrate it back. Because local clones are so cheap, "
4437 "there's almost no overhead to cloning and destroying repositories whenever "
4438 "you want."
4439 msgstr ""
4440 "说句题外话,保留远程版本库的一份<quote>原始</quote>拷贝是一个很好的习惯,这样"
4441 "你就可以为每个任务都创建临时的克隆作为沙盒。直到认务完成并且你准备好提交到版本"
4442 "库, 每个任务都和其他的独立,这样你可以并行工作。因为本地的克隆很方便,在任何时"
4443 "候克隆和销毁一个版本库都只有很小的开销。"
4445 #. type: Content of: <book><chapter><sect1><para>
4446 #: ../en/ch02-tour-basic.xml:477
4447 msgid ""
4448 "In our <filename class=\"directory\">my-hello</filename> repository, we have "
4449 "a file <filename>hello.c</filename> that contains the classic <quote>hello, "
4450 "world</quote> program."
4451 msgstr ""
4452 "在我们的<filename class=\"directory\">my-hello</filename>版本库中,有一个叫"
4453 "<filename>hello.c</filename>的文件,它包含了经典的<quote>hello, world</quote>"
4454 "程序。"
4456 #. type: Content of: <book><chapter><sect1><para>
4457 #: ../en/ch02-tour-basic.xml:483
4458 msgid "Let's edit this file so that it prints a second line of output."
4459 msgstr "我们编辑这个文件,让它打印第二行输出。"
4461 #. type: Content of: <book><chapter><sect1><para>
4462 #: ../en/ch02-tour-basic.xml:488
4463 msgid ""
4464 "Mercurial's <command role=\"hg-cmd\">hg status</command> command will tell us "
4465 "what Mercurial knows about the files in the repository."
4466 msgstr ""
4467 "Mercurial的<command role=\"hg-cmd\">hg status</command>命令能告诉我们它对版本"
4468 "库中的文件有多少了解。"
4470 #. type: Content of: <book><chapter><sect1><para>
4471 #: ../en/ch02-tour-basic.xml:494
4472 msgid ""
4473 "The <command role=\"hg-cmd\">hg status</command> command prints no output for "
4474 "some files, but a line starting with <quote><literal>M</literal></quote> for "
4475 "<filename>hello.c</filename>. Unless you tell it to, <command role=\"hg-cmd"
4476 "\">hg status</command> will not print any output for files that have not been "
4477 "modified."
4478 msgstr ""
4479 "<command role=\"hg-cmd\">hg status</command>命令对有些文件没有输出信息,但是对"
4480 "文件<filename>hello.c</filename>,有一行以<quote><literal>M</literal></quote>"
4481 "为开头的输出。除非你明确告诉它,命令<command role=\"hg-cmd\">hg status</"
4482 "command>不会输出那些没有修改的文件的信息。"
4484 #. type: Content of: <book><chapter><sect1><para>
4485 #: ../en/ch02-tour-basic.xml:501
4486 msgid ""
4487 "The <quote><literal>M</literal></quote> indicates that Mercurial has noticed "
4488 "that we modified <filename>hello.c</filename>. We didn't need to "
4489 "<emphasis>inform</emphasis> Mercurial that we were going to modify the file "
4490 "before we started, or that we had modified the file after we were done; it "
4491 "was able to figure this out itself."
4492 msgstr ""
4493 "<quote><literal>M</literal></quote>表明Mercurial已经发现我们修改了"
4494 "<filename>hello.c</filename>。我们不需要在改文件之前,或者在修改完之后"
4495 "<emphasis>通知</emphasis>Mercurial;它自己能处理。"
4497 #. type: Content of: <book><chapter><sect1><para>
4498 #: ../en/ch02-tour-basic.xml:509
4499 msgid ""
4500 "It's somewhat helpful to know that we've modified <filename>hello.c</"
4501 "filename>, but we might prefer to know exactly <emphasis>what</emphasis> "
4502 "changes we've made to it. To do this, we use the <command role=\"hg-cmd\">hg "
4503 "diff</command> command."
4504 msgstr ""
4505 "知道文件<filename>hello.c</filename>被修改了很有用,但有时候我们想知道做了"
4506 "<emphasis>什么</emphasis>样的修改。这时,我们应该使用 <command role=\"hg-cmd"
4507 "\">hg diff</command>命令。"
4509 #. type: Content of: <book><chapter><sect1><title>
4510 #: ../en/ch02-tour-basic.xml:518 ../en/ch12-mq.xml:187
4511 msgid "Understanding patches"
4512 msgstr "理解补丁"
4514 #. type: Content of: <book><chapter><sect1><tip><para>
4515 #: ../en/ch02-tour-basic.xml:520
4516 msgid ""
4517 "Remember to take a look at <xref linkend=\"sec:mq:patch\"/> if you don't know "
4518 "how to read output above."
4519 msgstr "如果你不知道如何理解以上信息,请参考<xref linkend=\"sec:mq:patch\"/>。"
4521 #. type: Content of: <book><chapter><sect1><title>
4522 #: ../en/ch02-tour-basic.xml:526
4523 msgid "Recording changes in a new changeset"
4524 msgstr "在新修改集中记录修改"
4526 #. type: Content of: <book><chapter><sect1><para>
4527 #: ../en/ch02-tour-basic.xml:528
4528 msgid ""
4529 "We can modify files, build and test our changes, and use <command role=\"hg-"
4530 "cmd\">hg status</command> and <command role=\"hg-cmd\">hg diff</command> to "
4531 "review our changes, until we're satisfied with what we've done and arrive at "
4532 "a natural stopping point where we want to record our work in a new changeset."
4533 msgstr ""
4534 "我们可以修改文件,创建并测试我们的修改,使用命令<command role=\"hg-cmd\">hg "
4535 "status</command>和<command role=\"hg-cmd\">hg diff</command>复审修改,直到我们"
4536 "对修改满意,同时也达到了一个自然的停止点,然后用一个新的变更集记录我们的工作。"
4538 #. type: Content of: <book><chapter><sect1><para>
4539 #: ../en/ch02-tour-basic.xml:535
4540 msgid ""
4541 "The <command role=\"hg-cmd\">hg commit</command> command lets us create a new "
4542 "changeset; we'll usually refer to this as <quote>making a commit</quote> or "
4543 "<quote>committing</quote>."
4544 msgstr ""
4545 "我们用命令<command role=\"hg-cmd\">hg commit</command>创建新的变更集;我们通常"
4546 "把这个称为<quote>做一次提交</quote>或者<quote>提交</quote>。"
4548 #. type: Content of: <book><chapter><sect1><sect2><title>
4549 #: ../en/ch02-tour-basic.xml:541
4550 msgid "Setting up a username"
4551 msgstr "配置用户名称"
4553 #. type: Content of: <book><chapter><sect1><sect2><para>
4554 #: ../en/ch02-tour-basic.xml:543
4555 msgid ""
4556 "When you try to run <command role=\"hg-cmd\">hg commit</command> for the "
4557 "first time, it is not guaranteed to succeed. Mercurial records your name and "
4558 "address with each change that you commit, so that you and others will later "
4559 "be able to tell who made each change. Mercurial tries to automatically "
4560 "figure out a sensible username to commit the change with. It will attempt "
4561 "each of the following methods, in order:"
4562 msgstr ""
4563 "当你准备第一次运行<command role=\"hg-cmd\">hg commit</command>命令时,不一定会"
4564 "成功。对于你提交的每个变更,Mercurial都会记录你的名字和邮件地址,这样你和其他"
4565 "人以后就能分开是谁做的哪个变更。Mercurial会自动尝试找出一个有意义的用户名来提"
4566 "交。它会依次尝试以下方法:"
4568 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
4569 #: ../en/ch02-tour-basic.xml:552
4570 msgid ""
4571 "If you specify a <option role=\"hg-opt-commit\">-u</option> option to the "
4572 "<command role=\"hg-cmd\">hg commit</command> command on the command line, "
4573 "followed by a username, this is always given the highest precedence."
4574 msgstr ""
4575 "如果你给<command role=\"hg-cmd\">hg commit</command>命令加上了<option role="
4576 "\"hg-opt-commit\">-u</option>选项,接着是一个用户名,Mercurial会使用这个用户"
4577 "名,这是最高的优先级。"
4579 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
4580 #: ../en/ch02-tour-basic.xml:557
4581 msgid ""
4582 "If you have set the <envar>HGUSER</envar> environment variable, this is "
4583 "checked next."
4584 msgstr "接下来测试你是否设定了<envar>HGUSER</envar>环境变量。"
4586 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
4587 #: ../en/ch02-tour-basic.xml:560
4588 msgid ""
4589 "If you create a file in your home directory called <filename role=\"special"
4590 "\">.hgrc</filename>, with a <envar role=\"rc-item-ui\">username</envar> "
4591 "entry, that will be used next. To see what the contents of this file should "
4592 "look like, refer to <xref linkend=\"sec:tour-basic:username\"/> below."
4593 msgstr ""
4594 "如果你在主目录创建了名字为<filename role=\"special\">.hgrc</filename>的文件,"
4595 "其中包括<envar role=\"rc-item-ui\">username</envar>条目,那就用它。如果想知道"
4596 "这个文件的格式,请参考下面的<xref linkend=\"sec:tour-basic:username\"/>。"
4598 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
4599 #: ../en/ch02-tour-basic.xml:568
4600 msgid ""
4601 "If you have set the <envar>EMAIL</envar> environment variable, this will be "
4602 "used next."
4603 msgstr "如果你设置了<envar>EMAIL</envar>环境变量,那就用它。"
4605 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
4606 #: ../en/ch02-tour-basic.xml:571
4607 msgid ""
4608 "Mercurial will query your system to find out your local user name and host "
4609 "name, and construct a username from these components. Since this often "
4610 "results in a username that is not very useful, it will print a warning if it "
4611 "has to do this."
4612 msgstr ""
4613 "Mercurial会查询你的系统,找出主机名和你的用户名,然后用他们创建一个用户名。这"
4614 "样的用户名不怎么有用,所以在只能这样生成用户名的时候,它会打印出一条告警信息。"
4616 #. type: Content of: <book><chapter><sect1><sect2><para>
4617 #: ../en/ch02-tour-basic.xml:578
4618 msgid ""
4619 "If all of these mechanisms fail, Mercurial will fail, printing an error "
4620 "message. In this case, it will not let you commit until you set up a "
4621 "username."
4622 msgstr ""
4623 "如果所有的这些机制都失败了,Mercurial会执行失败退出,打印出一条错误信息这种情"
4624 "况下,只有你设定了用户名之后才能提交。"
4626 #. type: Content of: <book><chapter><sect1><sect2><para>
4627 #: ../en/ch02-tour-basic.xml:582
4628 msgid ""
4629 "You should think of the <envar>HGUSER</envar> environment variable and the "
4630 "<option role=\"hg-opt-commit\">-u</option> option to the <command role=\"hg-"
4631 "cmd\">hg commit</command> command as ways to <emphasis>override</emphasis> "
4632 "Mercurial's default selection of username. For normal use, the simplest and "
4633 "most robust way to set a username for yourself is by creating a <filename "
4634 "role=\"special\">.hgrc</filename> file; see below for details."
4635 msgstr ""
4636 "当你需要覆盖Mercurial缺省的用户时,可以考虑<envar>HGUSER</envar>环境变量和"
4637 "<command role=\"hg-cmd\">hg commit</command>命令的<option role=\"hg-opt-commit"
4638 "\">-u</option>选项。正常使用的情况下,最简单实用的方法就是创建<filename role="
4639 "\"special\">.hgrc</filename>文件来设定用户名;步骤如下。"
4641 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
4642 #: ../en/ch02-tour-basic.xml:591
4643 msgid "Creating a Mercurial configuration file"
4644 msgstr "创建 Mercurial 的配置文件"
4646 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
4647 #: ../en/ch02-tour-basic.xml:593
4648 msgid ""
4649 "To set a user name, use your favorite editor to create a file called "
4650 "<filename role=\"special\">.hgrc</filename> in your home directory. "
4651 "Mercurial will use this file to look up your personalised configuration "
4652 "settings. The initial contents of your <filename role=\"special\">.hgrc</"
4653 "filename> should look like this."
4654 msgstr ""
4655 "设定用户名的时候,使用你最喜欢的编辑器在你的主目录创建一个名为<filename role="
4656 "\"special\">.hgrc</filename>的文件。Mercurial将会从这个文件中查找你的个人配置"
4657 "信息。你的<filename role=\"special\">.hgrc</filename>开始的时候应该是这样子。"
4659 #. type: Content of: <book><chapter><sect1><sect2><sect3><tip><title>
4660 #: ../en/ch02-tour-basic.xml:602
4661 msgid "<quote>Home directory</quote> on Windows"
4662 msgstr "Windows上的<quote>主目录</quote>"
4664 #. type: Content of: <book><chapter><sect1><sect2><sect3><tip><para>
4665 #: ../en/ch02-tour-basic.xml:604
4666 msgid ""
4667 "When we refer to your home directory, on an English language installation of "
4668 "Windows this will usually be a folder named after your user name in "
4669 "<filename>C:\\Documents and Settings</filename>. You can find out the exact "
4670 "name of your home directory by opening a command prompt window and running "
4671 "the following command."
4672 msgstr ""
4673 "英文版的Windows的主目录通常是<filename>C:\\Documents and Settings</filename>下"
4674 "你的用户名的那个文件夹。如果要找出你的主目录的确切位置,可以打开一个命令行窗"
4675 "口,运行以下命令。"
4677 #. type: Content of: <book><chapter><sect1><sect2><sect3><tip><screen><prompt>
4678 #: ../en/ch02-tour-basic.xml:612
4679 msgid "C:\\>"
4680 msgstr "C:\\>"
4682 #. type: Content of: <book><chapter><sect1><sect2><sect3><tip><screen><userinput>
4683 #: ../en/ch02-tour-basic.xml:612
4684 msgid "echo %UserProfile%"
4685 msgstr "echo %UserProfile%"
4687 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
4688 #: ../en/ch02-tour-basic.xml:619
4689 msgid ""
4690 "The <quote><literal>[ui]</literal></quote> line begins a <emphasis>section</"
4691 "emphasis> of the config file, so you can read the <quote><literal>username "
4692 "= ...</literal></quote> line as meaning <quote>set the value of the "
4693 "<literal>username</literal> item in the <literal>ui</literal> section</"
4694 "quote>. A section continues until a new section begins, or the end of the "
4695 "file. Mercurial ignores empty lines and treats any text from "
4696 "<quote><literal>#</literal></quote> to the end of a line as a comment."
4697 msgstr ""
4698 "配置文件中<quote><literal>[ui]</literal></quote>这行标识着一个<emphasis>字段</"
4699 "emphasis>的开始,<quote><literal>username = ...</literal></quote>这行的意思是在"
4700 "<literal>ui</literal>字段中设定项<literal>username</literal>的值。当出现一个新"
4701 "的字段或者到达文件结尾的时候,当前的字段才结束。"
4703 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
4704 #: ../en/ch02-tour-basic.xml:632
4705 msgid "Choosing a user name"
4706 msgstr "选择用户名称"
4708 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
4709 #: ../en/ch02-tour-basic.xml:634
4710 msgid ""
4711 "You can use any text you like as the value of the <literal>username</literal> "
4712 "config item, since this information is for reading by other people, but will "
4713 "not be interpreted by Mercurial. The convention that most people follow is "
4714 "to use their name and email address, as in the example above."
4715 msgstr ""
4716 "<literal>username</literal>配置项的值可以是你喜欢的任意文字,因为这项信息主要"
4717 "是给其他用户阅读的,所以Mercurial不会去解释它。大多数人的习惯是采用用户名加上"
4718 "邮件地址的格式,就像上面的例子一样。"
4720 #. type: Content of: <book><chapter><sect1><sect2><sect3><note><para>
4721 #: ../en/ch02-tour-basic.xml:641
4722 msgid ""
4723 "Mercurial's built-in web server obfuscates email addresses, to make it more "
4724 "difficult for the email harvesting tools that spammers use. This reduces the "
4725 "likelihood that you'll start receiving more junk email if you publish a "
4726 "Mercurial repository on the web."
4727 msgstr ""
4728 "Mercurial内置的网络服务器会混淆邮件地址,让垃圾邮件发送者用的邮件地址抓取工具"
4729 "很难获取你的邮件地址。当你把Mercurial的版本库在网路上发布的时候,这可以减小你"
4730 "接收到垃圾邮件的风险。"
4732 #. type: Content of: <book><chapter><sect1><sect2><title>
4733 #: ../en/ch02-tour-basic.xml:650
4734 msgid "Writing a commit message"
4735 msgstr "写提交日志"
4737 #. type: Content of: <book><chapter><sect1><sect2><para>
4738 #: ../en/ch02-tour-basic.xml:652
4739 msgid ""
4740 "When we commit a change, Mercurial drops us into a text editor, to enter a "
4741 "message that will describe the modifications we've made in this changeset. "
4742 "This is called the <emphasis>commit message</emphasis>. It will be a record "
4743 "for readers of what we did and why, and it will be printed by <command role="
4744 "\"hg-cmd\">hg log</command> after we've finished committing."
4745 msgstr ""
4746 "我们提交一个变更的时候,Mercurial会打开一个编辑器,让我们输入一些信息来描述这"
4747 "个变更集做的更改。这就是<emphasis>提交日志</emphasis>。它会告诉读者我们改了什"
4748 "么以及修改的原因,我们提交之后,命令<command role=\"hg-cmd\">hg log</command>"
4749 "会输出这些信息。"
4751 #. type: Content of: <book><chapter><sect1><sect2><para>
4752 #: ../en/ch02-tour-basic.xml:662
4753 msgid ""
4754 "The editor that the <command role=\"hg-cmd\">hg commit</command> command "
4755 "drops us into will contain an empty line or two, followed by a number of "
4756 "lines starting with <quote><literal>HG:</literal></quote>."
4757 msgstr ""
4758 "<command role=\"hg-cmd\">hg commit</command>命令打开的编辑器包括一两个空行,接"
4759 "着是以<quote><literal>HG:</literal></quote>开始的行。"
4761 #. type: Content of: <book><chapter><sect1><sect2><para>
4762 #: ../en/ch02-tour-basic.xml:676
4763 msgid ""
4764 "Mercurial ignores the lines that start with <quote><literal>HG:</literal></"
4765 "quote>; it uses them only to tell us which files it's recording changes to. "
4766 "Modifying or deleting these lines has no effect."
4767 msgstr ""
4768 "Mercurial会忽略以<quote><literal>HG:</literal></quote>为开始的行;它仅仅用来告"
4769 "诉我们这个变更集中包括哪些文件。修改或者删除这行没有任何影响。"
4771 #. type: Content of: <book><chapter><sect1><sect2><title>
4772 #: ../en/ch02-tour-basic.xml:682
4773 msgid "Writing a good commit message"
4774 msgstr "写高质量的提交日志"
4776 #. type: Content of: <book><chapter><sect1><sect2><para>
4777 #: ../en/ch02-tour-basic.xml:684
4778 msgid ""
4779 "Since <command role=\"hg-cmd\">hg log</command> only prints the first line of "
4780 "a commit message by default, it's best to write a commit message whose first "
4781 "line stands alone. Here's a real example of a commit message that "
4782 "<emphasis>doesn't</emphasis> follow this guideline, and hence has a summary "
4783 "that is not readable."
4784 msgstr ""
4785 "因为<command role=\"hg-cmd\">hg log</command>命令在缺省情况下仅会输出提交日志"
4786 "的第一行,所以最好日志的第一行是独立的。下面是一个日志的实例,它<emphasis>没有"
4787 "</emphasis>遵守这个规则,因此摘要可读性很差。"
4789 #. type: Content of: <book><chapter><sect1><sect2><para>
4790 #: ../en/ch02-tour-basic.xml:697
4791 msgid ""
4792 "As far as the remainder of the contents of the commit message are concerned, "
4793 "there are no hard-and-fast rules. Mercurial itself doesn't interpret or care "
4794 "about the contents of the commit message, though your project may have "
4795 "policies that dictate a certain kind of formatting."
4796 msgstr ""
4797 "至于日志的其他部分的内容,没有严格的规定。Mercurial并不解释或者关心日志的内"
4798 "容,虽然你的项目可能有某种格式的规定。"
4800 #. type: Content of: <book><chapter><sect1><sect2><para>
4801 #: ../en/ch02-tour-basic.xml:702
4802 msgid ""
4803 "My personal preference is for short, but informative, commit messages that "
4804 "tell me something that I can't figure out with a quick glance at the output "
4805 "of <command role=\"hg-cmd\">hg log --patch</command>."
4806 msgstr ""
4807 "我个人喜欢简短,而又信息量大的日志,它能告诉我一些我不能通过快速浏览<command "
4808 "role=\"hg-cmd\">hg log --patch</command>的输出而得到的信息。"
4810 #. type: Content of: <book><chapter><sect1><sect2><para>
4811 #: ../en/ch02-tour-basic.xml:706
4812 msgid ""
4813 "If we run the <command role=\"hg-cmd\">hg commit</command> command without "
4814 "any arguments, it records all of the changes we've made, as reported by "
4815 "<command role=\"hg-cmd\">hg status</command> and <command role=\"hg-cmd\">hg "
4816 "diff</command>."
4817 msgstr ""
4818 "如果我们运行<command role=\"hg-cmd\">hg commit</command>命令的时候没有指定文"
4819 "件,它会提交我们做的所有修改,与<command role=\"hg-cmd\">hg status</command>和"
4820 "<command role=\"hg-cmd\">hg diff</command>这两个命令的输出一样。"
4822 #. type: Content of: <book><chapter><sect1><sect2><note><title>
4823 #: ../en/ch02-tour-basic.xml:713
4824 msgid "A surprise for Subversion users"
4825 msgstr "Subversion用户的困惑"
4827 #. type: Content of: <book><chapter><sect1><sect2><note><para>
4828 #: ../en/ch02-tour-basic.xml:715
4829 msgid ""
4830 "Like other Mercurial commands, if we don't supply explicit names to commit to "
4831 "the <command role=\"hg-cmd\">hg commit</command>, it will operate across a "
4832 "repository's entire working directory. Be wary of this if you're coming from "
4833 "the Subversion or CVS world, since you might expect it to operate only on the "
4834 "current directory that you happen to be visiting and its subdirectories."
4835 msgstr ""
4836 "和所有的Mercurial命令一样,如果我们不明确指出<command role=\"hg-cmd\">hg "
4837 "commit</command>命令要提交的文件名,它会在整个版本库的工作目录上执行操作。如果"
4838 "你以前使用过CVS或者Subversion,那一定要注意,你可能仅仅希望提交当前目录与其子"
4839 "目录的修改。"
4841 #. type: Content of: <book><chapter><sect1><sect2><title>
4842 #: ../en/ch02-tour-basic.xml:726
4843 msgid "Aborting a commit"
4844 msgstr "终止提交"
4846 #. type: Content of: <book><chapter><sect1><sect2><para>
4847 #: ../en/ch02-tour-basic.xml:728
4848 msgid ""
4849 "If you decide that you don't want to commit while in the middle of editing a "
4850 "commit message, simply exit from your editor without saving the file that "
4851 "it's editing. This will cause nothing to happen to either the repository or "
4852 "the working directory."
4853 msgstr ""
4854 "如果你在编辑日志的时候决定不再提交,只要退出编辑器同时不保存文件就可以了。这对"
4855 "版本库和当前目录都没有任何影响。"
4857 #. type: Content of: <book><chapter><sect1><sect2><title>
4858 #: ../en/ch02-tour-basic.xml:736
4859 msgid "Admiring our new handiwork"
4860 msgstr "欣赏我们的成果"
4862 #. type: Content of: <book><chapter><sect1><sect2><para>
4863 #: ../en/ch02-tour-basic.xml:738
4864 msgid ""
4865 "Once we've finished the commit, we can use the <command role=\"hg-cmd\">hg "
4866 "tip</command> command to display the changeset we just created. This command "
4867 "produces output that is identical to <command role=\"hg-cmd\">hg log</"
4868 "command>, but it only displays the newest revision in the repository."
4869 msgstr ""
4870 "提交完成后,我们就可以用<command role=\"hg-cmd\">hg tip</command>命令显示刚刚"
4871 "创建的变更集。这个命令和<command role=\"hg-cmd\">hg log</command>的输出一样,"
4872 "但是只显示版本库中最新的版本。"
4874 #. type: Content of: <book><chapter><sect1><sect2><para>
4875 #: ../en/ch02-tour-basic.xml:746
4876 msgid ""
4877 "We refer to the newest revision in the repository as the <emphasis>tip "
4878 "revision</emphasis>, or simply the <emphasis>tip</emphasis>."
4879 msgstr ""
4880 "我们通常把版本库中最新的版本称为<emphasis>tip版本</emphasis>或者简称为"
4881 "<emphasis>tip</emphasis>。"
4883 #. type: Content of: <book><chapter><sect1><sect2><para>
4884 #: ../en/ch02-tour-basic.xml:750
4885 msgid ""
4886 "By the way, the <command role=\"hg-cmd\">hg tip</command> command accepts "
4887 "many of the same options as <command role=\"hg-cmd\">hg log</command>, so "
4888 "<option role=\"hg-opt-global\">-v</option> above indicates <quote>be verbose</"
4889 "quote>, <option role=\"hg-opt-tip\">-p</option> specifies <quote>print a "
4890 "patch</quote>. The use of <option role=\"hg-opt-tip\">-p</option> to print "
4891 "patches is another example of the consistent naming we mentioned earlier."
4892 msgstr ""
4893 "顺便提一下,<command role=\"hg-cmd\">hg tip</command>命令可以接受很多和"
4894 "<command role=\"hg-cmd\">hg log</command>命令一样的选项。如<option role=\"hg-"
4895 "opt-global\">-v</option>选项的意思是<quote>详细的</quote>。<option role=\"hg-"
4896 "opt-tip\">-p</option>的意思是<quote>输出补丁</quote>。使用<option role=\"hg-"
4897 "opt-tip\">-p</option>输出补丁也是我们前面提到的一致性的另外一个例子。"
4899 #. type: Content of: <book><chapter><sect1><title>
4900 #: ../en/ch02-tour-basic.xml:762
4901 msgid "Sharing changes"
4902 msgstr "分享修改"
4904 #. type: Content of: <book><chapter><sect1><para>
4905 #: ../en/ch02-tour-basic.xml:764
4906 msgid ""
4907 "We mentioned earlier that repositories in Mercurial are self-contained. This "
4908 "means that the changeset we just created exists only in our <filename class="
4909 "\"directory\">my-hello</filename> repository. Let's look at a few ways that "
4910 "we can propagate this change into other repositories."
4911 msgstr ""
4912 "前面我们曾经提到Mercurial的版本库是自包含的。这意味着我们刚才创建的变更集仅仅"
4913 "存在于我们的<filename class=\"directory\">my-hello</filename>版本库中。下面我"
4914 "们会看到几种将变更传播到其他版本库的方法。"
4916 #. type: Content of: <book><chapter><sect1><sect2><title>
4917 #: ../en/ch02-tour-basic.xml:772
4918 msgid "Pulling changes from another repository"
4919 msgstr "从其它版本库取得修改"
4921 #. type: Content of: <book><chapter><sect1><sect2><para>
4922 #: ../en/ch02-tour-basic.xml:774
4923 msgid ""
4924 "To get started, let's clone our original <filename class=\"directory\">hello</"
4925 "filename> repository, which does not contain the change we just committed. "
4926 "We'll call our temporary repository <filename class=\"directory\">hello-pull</"
4927 "filename>."
4928 msgstr ""
4930 #. type: Content of: <book><chapter><sect1><sect2><para>
4931 #: ../en/ch02-tour-basic.xml:782
4932 msgid ""
4933 "We'll use the <command role=\"hg-cmd\">hg pull</command> command to bring "
4934 "changes from <filename class=\"directory\">my-hello</filename> into <filename "
4935 "class=\"directory\">hello-pull</filename>. However, blindly pulling unknown "
4936 "changes into a repository is a somewhat scary prospect. Mercurial provides "
4937 "the <command role=\"hg-cmd\">hg incoming</command> command to tell us what "
4938 "changes the <command role=\"hg-cmd\">hg pull</command> command "
4939 "<emphasis>would</emphasis> pull into the repository, without actually pulling "
4940 "the changes in."
4941 msgstr ""
4943 #. type: Content of: <book><chapter><sect1><sect2><para>
4944 #: ../en/ch02-tour-basic.xml:795
4945 msgid ""
4946 "Bringing changes into a repository is a simple matter of running the <command "
4947 "role=\"hg-cmd\">hg pull</command> command, and optionally telling it which "
4948 "repository to pull from."
4949 msgstr ""
4951 #. type: Content of: <book><chapter><sect1><sect2><para>
4952 #: ../en/ch02-tour-basic.xml:801
4953 msgid ""
4954 "As you can see from the before-and-after output of <command role=\"hg-cmd"
4955 "\">hg tip</command>, we have successfully pulled changes into our "
4956 "repository. However, Mercurial separates pulling changes in from updating "
4957 "the working directory. There remains one step before we will see the changes "
4958 "that we just pulled appear in the working directory."
4959 msgstr ""
4961 #. type: Content of: <book><chapter><sect1><sect2><tip><title>
4962 #: ../en/ch02-tour-basic.xml:810
4963 msgid "Pulling specific changes"
4964 msgstr "提取指定的修改"
4966 #. type: Content of: <book><chapter><sect1><sect2><tip><para>
4967 #: ../en/ch02-tour-basic.xml:812
4968 msgid ""
4969 "It is possible that due to the delay between running <command role=\"hg-cmd"
4970 "\">hg incoming</command> and <command role=\"hg-cmd\">hg pull</command>, you "
4971 "may not see all changesets that will be brought from the other repository. "
4972 "Suppose you're pulling changes from a repository on the network somewhere. "
4973 "While you are looking at the <command role=\"hg-cmd\">hg incoming</command> "
4974 "output, and before you pull those changes, someone might have committed "
4975 "something in the remote repository. This means that it's possible to pull "
4976 "more changes than you saw when using <command role=\"hg-cmd\">hg incoming</"
4977 "command>."
4978 msgstr ""
4980 #. type: Content of: <book><chapter><sect1><sect2><tip><para>
4981 #: ../en/ch02-tour-basic.xml:824
4982 msgid ""
4983 "If you only want to pull precisely the changes that were listed by <command "
4984 "role=\"hg-cmd\">hg incoming</command>, or you have some other reason to pull "
4985 "a subset of changes, simply identify the change that you want to pull by its "
4986 "changeset ID, e.g. <command>hg pull -r7e95bb</command>."
4987 msgstr ""
4989 #. type: Content of: <book><chapter><sect1><sect2><title>
4990 #: ../en/ch02-tour-basic.xml:834
4991 msgid "Updating the working directory"
4992 msgstr "更新工作目录"
4994 #. type: Content of: <book><chapter><sect1><sect2><para>
4995 #: ../en/ch02-tour-basic.xml:836
4996 msgid ""
4997 "We have so far glossed over the relationship between a repository and its "
4998 "working directory. The <command role=\"hg-cmd\">hg pull</command> command "
4999 "that we ran in <xref linkend=\"sec:tour:pull\"/> brought changes into the "
5000 "repository, but if we check, there's no sign of those changes in the working "
5001 "directory. This is because <command role=\"hg-cmd\">hg pull</command> does "
5002 "not (by default) touch the working directory. Instead, we use the <command "
5003 "role=\"hg-cmd\">hg update</command> command to do this."
5004 msgstr ""
5006 #. type: Content of: <book><chapter><sect1><sect2><para>
5007 #: ../en/ch02-tour-basic.xml:848
5008 msgid ""
5009 "It might seem a bit strange that <command role=\"hg-cmd\">hg pull</command> "
5010 "doesn't update the working directory automatically. There's actually a good "
5011 "reason for this: you can use <command role=\"hg-cmd\">hg update</command> to "
5012 "update the working directory to the state it was in at <emphasis>any "
5013 "revision</emphasis> in the history of the repository. If you had the working "
5014 "directory updated to an old revision&emdash;to hunt down the origin of a bug, "
5015 "say&emdash;and ran a <command role=\"hg-cmd\">hg pull</command> which "
5016 "automatically updated the working directory to a new revision, you might not "
5017 "be terribly happy."
5018 msgstr ""
5020 #. type: Content of: <book><chapter><sect1><sect2><para>
5021 #: ../en/ch02-tour-basic.xml:860
5022 msgid ""
5023 "Since pull-then-update is such a common sequence of operations, Mercurial "
5024 "lets you combine the two by passing the <option role=\"hg-opt-pull\">-u</"
5025 "option> option to <command role=\"hg-cmd\">hg pull</command>."
5026 msgstr ""
5028 #. type: Content of: <book><chapter><sect1><sect2><para>
5029 #: ../en/ch02-tour-basic.xml:865
5030 msgid ""
5031 "If you look back at the output of <command role=\"hg-cmd\">hg pull</command> "
5032 "in <xref linkend=\"sec:tour:pull\"/> when we ran it without <option role=\"hg-"
5033 "opt-pull\">-u</option>, you can see that it printed a helpful reminder that "
5034 "we'd have to take an explicit step to update the working directory."
5035 msgstr ""
5037 #. type: Content of: <book><chapter><sect1><sect2><para>
5038 #: ../en/ch02-tour-basic.xml:872
5039 msgid ""
5040 "To find out what revision the working directory is at, use the <command role="
5041 "\"hg-cmd\">hg parents</command> command."
5042 msgstr ""
5044 #. type: Content of: <book><chapter><sect1><sect2><para>
5045 #: ../en/ch02-tour-basic.xml:878
5046 msgid ""
5047 "If you look back at <xref linkend=\"fig:tour-basic:history\"/>, you'll see "
5048 "arrows connecting each changeset. The node that the arrow leads "
5049 "<emphasis>from</emphasis> in each case is a parent, and the node that the "
5050 "arrow leads <emphasis>to</emphasis> is its child. The working directory has "
5051 "a parent in just the same way; this is the changeset that the working "
5052 "directory currently contains."
5053 msgstr ""
5055 #. type: Content of: <book><chapter><sect1><sect2><para>
5056 #: ../en/ch02-tour-basic.xml:887
5057 msgid ""
5058 "To update the working directory to a particular revision, give a revision "
5059 "number or changeset ID to the <command role=\"hg-cmd\">hg update</command> "
5060 "command."
5061 msgstr ""
5063 #. type: Content of: <book><chapter><sect1><sect2><para>
5064 #: ../en/ch02-tour-basic.xml:893
5065 msgid ""
5066 "If you omit an explicit revision, <command role=\"hg-cmd\">hg update</"
5067 "command> will update to the tip revision, as shown by the second call to "
5068 "<command role=\"hg-cmd\">hg update</command> in the example above."
5069 msgstr ""
5071 #. type: Content of: <book><chapter><sect1><sect2><title>
5072 #: ../en/ch02-tour-basic.xml:901
5073 msgid "Pushing changes to another repository"
5074 msgstr "发布修改到其它版本库"
5076 #. type: Content of: <book><chapter><sect1><sect2><para>
5077 #: ../en/ch02-tour-basic.xml:903
5078 msgid ""
5079 "Mercurial lets us push changes to another repository, from the repository "
5080 "we're currently visiting. As with the example of <command role=\"hg-cmd\">hg "
5081 "pull</command> above, we'll create a temporary repository to push our changes "
5082 "into."
5083 msgstr ""
5085 #. type: Content of: <book><chapter><sect1><sect2><para>
5086 #: ../en/ch02-tour-basic.xml:911
5087 msgid ""
5088 "The <command role=\"hg-cmd\">hg outgoing</command> command tells us what "
5089 "changes would be pushed into another repository."
5090 msgstr ""
5092 #. type: Content of: <book><chapter><sect1><sect2><para>
5093 #: ../en/ch02-tour-basic.xml:917
5094 msgid ""
5095 "And the <command role=\"hg-cmd\">hg push</command> command does the actual "
5096 "push."
5097 msgstr ""
5099 #. type: Content of: <book><chapter><sect1><sect2><para>
5100 #: ../en/ch02-tour-basic.xml:922
5101 msgid ""
5102 "As with <command role=\"hg-cmd\">hg pull</command>, the <command role=\"hg-cmd"
5103 "\">hg push</command> command does not update the working directory in the "
5104 "repository that it's pushing changes into. Unlike <command role=\"hg-cmd\">hg "
5105 "pull</command>, <command role=\"hg-cmd\">hg push</command> does not provide a "
5106 "<literal>-u</literal> option that updates the other repository's working "
5107 "directory. This asymmetry is deliberate: the repository we're pushing to "
5108 "might be on a remote server and shared between several people. If we were to "
5109 "update its working directory while someone was working in it, their work "
5110 "would be disrupted."
5111 msgstr ""
5113 #. type: Content of: <book><chapter><sect1><sect2><para>
5114 #: ../en/ch02-tour-basic.xml:934
5115 msgid ""
5116 "What happens if we try to pull or push changes and the receiving repository "
5117 "already has those changes? Nothing too exciting."
5118 msgstr ""
5120 #. type: Content of: <book><chapter><sect1><sect2><title>
5121 #: ../en/ch02-tour-basic.xml:942
5122 msgid "Default locations"
5123 msgstr "默认位置"
5125 #. type: Content of: <book><chapter><sect1><sect2><para>
5126 #: ../en/ch02-tour-basic.xml:944
5127 msgid ""
5128 "When we clone a repository, Mercurial records the location of the repository "
5129 "we cloned in the <filename>.hg/hgrc</filename> file of the new repository. "
5130 "If we don't supply a location to <command>hg pull</command> from or "
5131 "<command>hg push</command> to, those commands will use this location as a "
5132 "default. The <command>hg incoming</command> and <command>hg outgoing</"
5133 "command> commands do so too."
5134 msgstr ""
5136 #. type: Content of: <book><chapter><sect1><sect2><para>
5137 #: ../en/ch02-tour-basic.xml:952
5138 msgid ""
5139 "If you open a repository's <filename>.hg/hgrc</filename> file in a text "
5140 "editor, you will see contents like the following."
5141 msgstr ""
5143 #. type: Content of: <book><chapter><sect1><sect2><para>
5144 #: ../en/ch02-tour-basic.xml:959
5145 msgid ""
5146 "It is possible&emdash;and often useful&emdash;to have the default location "
5147 "for <command>hg push</command> and <command>hg outgoing</command> be "
5148 "different from those for <command>hg pull</command> and <command>hg incoming</"
5149 "command>. We can do this by adding a <literal>default-push</literal> entry "
5150 "to the <literal>[paths]</literal> section of the <filename>.hg/hgrc</"
5151 "filename> file, as follows."
5152 msgstr ""
5154 #. type: Content of: <book><chapter><sect1><sect2><title>
5155 #: ../en/ch02-tour-basic.xml:973
5156 msgid "Sharing changes over a network"
5157 msgstr "通过网络共享修改"
5159 #. type: Content of: <book><chapter><sect1><sect2><para>
5160 #: ../en/ch02-tour-basic.xml:975
5161 msgid ""
5162 "The commands we have covered in the previous few sections are not limited to "
5163 "working with local repositories. Each works in exactly the same fashion over "
5164 "a network connection; simply pass in a URL instead of a local path."
5165 msgstr ""
5167 #. type: Content of: <book><chapter><sect1><sect2><para>
5168 #: ../en/ch02-tour-basic.xml:983
5169 msgid ""
5170 "In this example, we can see what changes we could push to the remote "
5171 "repository, but the repository is understandably not set up to let anonymous "
5172 "users push to it."
5173 msgstr ""
5175 #. type: Content of: <book><chapter><sect1><title>
5176 #: ../en/ch02-tour-basic.xml:993
5177 msgid "Starting a new project"
5178 msgstr "开始新项目"
5180 #. type: Content of: <book><chapter><sect1><para>
5181 #: ../en/ch02-tour-basic.xml:995
5182 msgid ""
5183 "It is just as easy to begin a new project as to work on one that already "
5184 "exists. The <command>hg init</command> command creates a new, empty "
5185 "Mercurial repository."
5186 msgstr ""
5188 #. type: Content of: <book><chapter><sect1><para>
5189 #: ../en/ch02-tour-basic.xml:1001
5190 msgid ""
5191 "This simply creates a repository named <filename>myproject</filename> in the "
5192 "current directory."
5193 msgstr ""
5195 #. type: Content of: <book><chapter><sect1><para>
5196 #: ../en/ch02-tour-basic.xml:1006
5197 msgid ""
5198 "We can tell that <filename>myproject</filename> is a Mercurial repository, "
5199 "because it contains a <filename>.hg</filename> directory."
5200 msgstr ""
5202 #. type: Content of: <book><chapter><sect1><para>
5203 #: ../en/ch02-tour-basic.xml:1012
5204 msgid ""
5205 "If we want to add some pre-existing files to the repository, we copy them "
5206 "into place, and tell Mercurial to start tracking them using the <command>hg "
5207 "add</command> command."
5208 msgstr ""
5210 #. type: Content of: <book><chapter><sect1><para>
5211 #: ../en/ch02-tour-basic.xml:1018
5212 msgid ""
5213 "Once we are satisfied that our project looks right, we commit our changes."
5214 msgstr ""
5216 #. type: Content of: <book><chapter><sect1><para>
5217 #: ../en/ch02-tour-basic.xml:1023
5218 msgid ""
5219 "It takes just a few moments to start using Mercurial on a new project, which "
5220 "is part of its appeal. Revision control is now so easy to work with, we can "
5221 "use it on the smallest of projects that we might not have considered with a "
5222 "more complicated tool."
5223 msgstr ""
5225 #. type: Content of: <book><chapter><title>
5226 #: ../en/ch03-tour-merge.xml:5
5227 msgid "A tour of Mercurial: merging work"
5228 msgstr "Mercurial 教程: 合并工作"
5230 #. type: Content of: <book><chapter><para>
5231 #: ../en/ch03-tour-merge.xml:7
5232 msgid ""
5233 "We've now covered cloning a repository, making changes in a repository, and "
5234 "pulling or pushing changes from one repository into another. Our next step "
5235 "is <emphasis>merging</emphasis> changes from separate repositories."
5236 msgstr ""
5238 #. type: Content of: <book><chapter><sect1><title>
5239 #: ../en/ch03-tour-merge.xml:13
5240 msgid "Merging streams of work"
5241 msgstr "合并的流程"
5243 #. type: Content of: <book><chapter><sect1><para>
5244 #: ../en/ch03-tour-merge.xml:15
5245 msgid ""
5246 "Merging is a fundamental part of working with a distributed revision control "
5247 "tool. Here are a few cases in which the need to merge work arises."
5248 msgstr ""
5250 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
5251 #: ../en/ch03-tour-merge.xml:20
5252 msgid ""
5253 "Alice and Bob each have a personal copy of a repository for a project they're "
5254 "collaborating on. Alice fixes a bug in her repository; Bob adds a new "
5255 "feature in his. They want the shared repository to contain both the bug fix "
5256 "and the new feature."
5257 msgstr ""
5259 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
5260 #: ../en/ch03-tour-merge.xml:27
5261 msgid ""
5262 "Cynthia frequently works on several different tasks for a single project at "
5263 "once, each safely isolated in its own repository. Working this way means that "
5264 "she often needs to merge one piece of her own work with another."
5265 msgstr ""
5267 #. type: Content of: <book><chapter><sect1><para>
5268 #: ../en/ch03-tour-merge.xml:35
5269 msgid ""
5270 "Because we need to merge often, Mercurial makes the process easy. Let's walk "
5271 "through a merge. We'll begin by cloning yet another repository (see how "
5272 "often they spring up?) and making a change in it."
5273 msgstr ""
5275 #. type: Content of: <book><chapter><sect1><para>
5276 #: ../en/ch03-tour-merge.xml:42
5277 msgid ""
5278 "We should now have two copies of <filename>hello.c</filename> with different "
5279 "contents. The histories of the two repositories have also diverged, as "
5280 "illustrated in <xref linkend=\"fig:tour-merge:sep-repos\"/>. Here is a copy "
5281 "of our file from one repository."
5282 msgstr ""
5284 #. type: Content of: <book><chapter><sect1><para>
5285 #: ../en/ch03-tour-merge.xml:51
5286 msgid "And here is our slightly different version from the other repository."
5287 msgstr ""
5289 #. type: Content of: <book><chapter><sect1><figure><title>
5290 #: ../en/ch03-tour-merge.xml:57
5291 msgid ""
5292 "Divergent recent histories of the <filename class=\"directory\">my-hello</"
5293 "filename> and <filename class=\"directory\">my-new-hello</filename> "
5294 "repositories"
5295 msgstr ""
5296 "<filename class=\"directory\">my-hello</filename> 与 <filename class="
5297 "\"directory\">my-new-hello</filename> 最新的历史分叉"
5299 #. type: Content of: <book><chapter><sect1><figure><mediaobject>
5300 #: ../en/ch03-tour-merge.xml:62
5301 msgid ""
5302 "<imageobject><imagedata fileref=\"figs/tour-merge-sep-repos.png\"/></"
5303 "imageobject>"
5304 msgstr ""
5306 #. type: Content of: <book><chapter><sect1><para>
5307 #: ../en/ch03-tour-merge.xml:67
5308 msgid ""
5309 "We already know that pulling changes from our <filename class=\"directory"
5310 "\">my-hello</filename> repository will have no effect on the working "
5311 "directory."
5312 msgstr ""
5314 #. type: Content of: <book><chapter><sect1><para>
5315 #: ../en/ch03-tour-merge.xml:73
5316 msgid ""
5317 "However, the <command role=\"hg-cmd\">hg pull</command> command says "
5318 "something about <quote>heads</quote>."
5319 msgstr ""
5321 #. type: Content of: <book><chapter><sect1><sect2><title>
5322 #: ../en/ch03-tour-merge.xml:77
5323 msgid "Head changesets"
5324 msgstr "顶点修改集"
5326 #. type: Content of: <book><chapter><sect1><sect2><para>
5327 #: ../en/ch03-tour-merge.xml:79
5328 msgid ""
5329 "Remember that Mercurial records what the parent of each change is. If a "
5330 "change has a parent, we call it a child or descendant of the parent. A head "
5331 "is a change that has no children. The tip revision is thus a head, because "
5332 "the newest revision in a repository doesn't have any children. There are "
5333 "times when a repository can contain more than one head."
5334 msgstr ""
5336 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
5337 #: ../en/ch03-tour-merge.xml:88
5338 msgid ""
5339 "Repository contents after pulling from <filename class=\"directory\">my-"
5340 "hello</filename> into <filename class=\"directory\">my-new-hello</filename>"
5341 msgstr ""
5342 "从 <filename class=\"directory\">my-hello</filename> 拉到 <filename class="
5343 "\"directory\">my-new-hello</filename> 之后版本库的内容"
5345 #. type: Content of: <book><chapter><sect1><sect2><figure>
5346 #: ../en/ch03-tour-merge.xml:91 ../en/ch03-tour-merge.xml:178
5347 #: ../en/ch03-tour-merge.xml:275 ../en/ch04-concepts.xml:57
5348 #: ../en/ch04-concepts.xml:106 ../en/ch04-concepts.xml:196
5349 #: ../en/ch04-concepts.xml:345 ../en/ch04-concepts.xml:360
5350 #: ../en/ch04-concepts.xml:401 ../en/ch04-concepts.xml:421
5351 #: ../en/ch04-concepts.xml:465 ../en/ch06-collab.xml:314
5352 #: ../en/ch09-undo.xml:342 ../en/ch09-undo.xml:389 ../en/ch09-undo.xml:462
5353 #: ../en/ch09-undo.xml:500 ../en/ch09-undo.xml:656 ../en/ch09-undo.xml:680
5354 #: ../en/ch09-undo.xml:698 ../en/ch09-undo.xml:712 ../en/ch09-undo.xml:725
5355 #: ../en/ch12-mq.xml:411
5356 msgid " <placeholder type=\"mediaobject\" id=\"0\"/>"
5357 msgstr ""
5359 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
5360 #: ../en/ch03-tour-merge.xml:92
5361 msgid ""
5362 "<imageobject> <imagedata fileref=\"figs/tour-merge-pull.png\"/> </imageobject>"
5363 msgstr ""
5365 #. type: Content of: <book><chapter><sect1><sect2><para>
5366 #: ../en/ch03-tour-merge.xml:99
5367 msgid ""
5368 "In <xref linkend=\"fig:tour-merge:pull\"/>, you can see the effect of the "
5369 "pull from <filename class=\"directory\">my-hello</filename> into <filename "
5370 "class=\"directory\">my-new-hello</filename>. The history that was already "
5371 "present in <filename class=\"directory\">my-new-hello</filename> is "
5372 "untouched, but a new revision has been added. By referring to <xref linkend="
5373 "\"fig:tour-merge:sep-repos\"/>, we can see that the <emphasis>changeset ID</"
5374 "emphasis> remains the same in the new repository, but the <emphasis>revision "
5375 "number</emphasis> has changed. (This, incidentally, is a fine example of why "
5376 "it's not safe to use revision numbers when discussing changesets.) We can "
5377 "view the heads in a repository using the <command role=\"hg-cmd\">hg heads</"
5378 "command> command."
5379 msgstr ""
5381 #. type: Content of: <book><chapter><sect1><sect2><title>
5382 #: ../en/ch03-tour-merge.xml:118
5383 msgid "Performing the merge"
5384 msgstr "执行合并"
5386 #. type: Content of: <book><chapter><sect1><sect2><para>
5387 #: ../en/ch03-tour-merge.xml:120
5388 msgid ""
5389 "What happens if we try to use the normal <command role=\"hg-cmd\">hg update</"
5390 "command> command to update to the new tip?"
5391 msgstr ""
5393 #. type: Content of: <book><chapter><sect1><sect2><para>
5394 #: ../en/ch03-tour-merge.xml:126
5395 msgid ""
5396 "Mercurial is telling us that the <command role=\"hg-cmd\">hg update</command> "
5397 "command won't do a merge; it won't update the working directory when it "
5398 "thinks we might want to do a merge, unless we force it to do so. "
5399 "(Incidentally, forcing the update with <command>hg update -C</command> would "
5400 "revert any uncommitted changes in the working directory.)"
5401 msgstr ""
5403 #. type: Content of: <book><chapter><sect1><sect2><para>
5404 #: ../en/ch03-tour-merge.xml:134
5405 msgid ""
5406 "To start a merge between the two heads, we use the <command role=\"hg-cmd"
5407 "\">hg merge</command> command."
5408 msgstr ""
5409 "我们使用 <command role=\"hg-cmd\">hg merge</command> 命令来合并两个顶点。"
5411 #. type: Content of: <book><chapter><sect1><sect2><para>
5412 #: ../en/ch03-tour-merge.xml:139
5413 msgid ""
5414 "We resolve the contents of <filename>hello.c</filename> This updates the "
5415 "working directory so that it contains changes from <emphasis>both</emphasis> "
5416 "heads, which is reflected in both the output of <command role=\"hg-cmd\">hg "
5417 "parents</command> and the contents of <filename>hello.c</filename>."
5418 msgstr ""
5420 #. type: Content of: <book><chapter><sect1><sect2><title>
5421 #: ../en/ch03-tour-merge.xml:151
5422 msgid "Committing the results of the merge"
5423 msgstr "提交合并结果"
5425 #. type: Content of: <book><chapter><sect1><sect2><para>
5426 #: ../en/ch03-tour-merge.xml:153
5427 msgid ""
5428 "Whenever we've done a merge, <command role=\"hg-cmd\">hg parents</command> "
5429 "will display two parents until we <command role=\"hg-cmd\">hg commit</"
5430 "command> the results of the merge."
5431 msgstr ""
5433 #. type: Content of: <book><chapter><sect1><sect2><para>
5434 #: ../en/ch03-tour-merge.xml:160
5435 msgid ""
5436 "We now have a new tip revision; notice that it has <emphasis>both</emphasis> "
5437 "of our former heads as its parents. These are the same revisions that were "
5438 "previously displayed by <command role=\"hg-cmd\">hg parents</command>."
5439 msgstr ""
5441 #. type: Content of: <book><chapter><sect1><sect2><para>
5442 #: ../en/ch03-tour-merge.xml:167
5443 msgid ""
5444 "In <xref linkend=\"fig:tour-merge:merge\"/>, you can see a representation of "
5445 "what happens to the working directory during the merge, and how this affects "
5446 "the repository when the commit happens. During the merge, the working "
5447 "directory has two parent changesets, and these become the parents of the new "
5448 "changeset."
5449 msgstr ""
5451 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
5452 #: ../en/ch03-tour-merge.xml:176
5453 msgid "Working directory and repository during merge, and following commit"
5454 msgstr "在合并期间,以及提交之后的工作目录与版本库"
5456 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
5457 #: ../en/ch03-tour-merge.xml:179
5458 msgid ""
5459 "<imageobject> <imagedata fileref=\"figs/tour-merge-merge.png\"/> </"
5460 "imageobject>"
5461 msgstr ""
5463 #. type: Content of: <book><chapter><sect1><sect2><para>
5464 #: ../en/ch03-tour-merge.xml:186
5465 msgid ""
5466 "We sometimes talk about a merge having <emphasis>sides</emphasis>: the left "
5467 "side is the first parent in the output of <command role=\"hg-cmd\">hg "
5468 "parents</command>, and the right side is the second. If the working "
5469 "directory was at e.g. revision 5 before we began a merge, that revision will "
5470 "become the left side of the merge."
5471 msgstr ""
5473 #. type: Content of: <book><chapter><sect1><title>
5474 #: ../en/ch03-tour-merge.xml:196
5475 msgid "Merging conflicting changes"
5476 msgstr "合并有冲突的改变"
5478 #. type: Content of: <book><chapter><sect1><para>
5479 #: ../en/ch03-tour-merge.xml:198
5480 msgid ""
5481 "Most merges are simple affairs, but sometimes you'll find yourself merging "
5482 "changes where each side modifies the same portions of the same files. Unless "
5483 "both modifications are identical, this results in a <emphasis>conflict</"
5484 "emphasis>, where you have to decide how to reconcile the different changes "
5485 "into something coherent."
5486 msgstr ""
5488 #. type: Content of: <book><chapter><sect1><figure><title>
5489 #: ../en/ch03-tour-merge.xml:206
5490 msgid "Conflicting changes to a document"
5491 msgstr "冲突的修改"
5493 #. type: Content of: <book><chapter><sect1><figure><mediaobject>
5494 #: ../en/ch03-tour-merge.xml:208
5495 msgid ""
5496 "<imageobject><imagedata fileref=\"figs/tour-merge-conflict.png\"/></"
5497 "imageobject>"
5498 msgstr ""
5500 #. type: Content of: <book><chapter><sect1><para>
5501 #: ../en/ch03-tour-merge.xml:213
5502 msgid ""
5503 "<xref linkend=\"fig:tour-merge:conflict\"/> illustrates an instance of two "
5504 "conflicting changes to a document. We started with a single version of the "
5505 "file; then we made some changes; while someone else made different changes to "
5506 "the same text. Our task in resolving the conflicting changes is to decide "
5507 "what the file should look like."
5508 msgstr ""
5510 #. type: Content of: <book><chapter><sect1><para>
5511 #: ../en/ch03-tour-merge.xml:220
5512 msgid ""
5513 "Mercurial doesn't have a built-in facility for handling conflicts. Instead, "
5514 "it runs an external program, usually one that displays some kind of graphical "
5515 "conflict resolution interface. By default, Mercurial tries to find one of "
5516 "several different merging tools that are likely to be installed on your "
5517 "system. It first tries a few fully automatic merging tools; if these don't "
5518 "succeed (because the resolution process requires human guidance) or aren't "
5519 "present, it tries a few different graphical merging tools."
5520 msgstr ""
5522 #. type: Content of: <book><chapter><sect1><para>
5523 #: ../en/ch03-tour-merge.xml:230
5524 msgid ""
5525 "It's also possible to get Mercurial to run a specific program or script, by "
5526 "setting the <envar>HGMERGE</envar> environment variable to the name of your "
5527 "preferred program."
5528 msgstr ""
5530 #. type: Content of: <book><chapter><sect1><sect2><title>
5531 #: ../en/ch03-tour-merge.xml:236
5532 msgid "Using a graphical merge tool"
5533 msgstr "使用图形合并工具"
5535 #. type: Content of: <book><chapter><sect1><sect2><para>
5536 #: ../en/ch03-tour-merge.xml:238
5537 msgid ""
5538 "My preferred graphical merge tool is <command>kdiff3</command>, which I'll "
5539 "use to describe the features that are common to graphical file merging "
5540 "tools. You can see a screenshot of <command>kdiff3</command> in action in "
5541 "<xref linkend=\"fig:tour-merge:kdiff3\"/>. The kind of merge it is "
5542 "performing is called a <emphasis>three-way merge</emphasis>, because there "
5543 "are three different versions of the file of interest to us. The tool thus "
5544 "splits the upper portion of the window into three panes:"
5545 msgstr ""
5547 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
5548 #: ../en/ch03-tour-merge.xml:248
5549 msgid ""
5550 "At the left is the <emphasis>base</emphasis> version of the file, i.e. the "
5551 "most recent version from which the two versions we're trying to merge are "
5552 "descended."
5553 msgstr ""
5555 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
5556 #: ../en/ch03-tour-merge.xml:253
5557 msgid ""
5558 "In the middle is <quote>our</quote> version of the file, with the contents "
5559 "that we modified."
5560 msgstr ""
5562 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
5563 #: ../en/ch03-tour-merge.xml:256
5564 msgid ""
5565 "On the right is <quote>their</quote> version of the file, the one that from "
5566 "the changeset that we're trying to merge with."
5567 msgstr ""
5569 #. type: Content of: <book><chapter><sect1><sect2><para>
5570 #: ../en/ch03-tour-merge.xml:260
5571 msgid ""
5572 "In the pane below these is the current <emphasis>result</emphasis> of the "
5573 "merge. Our task is to replace all of the red text, which indicates unresolved "
5574 "conflicts, with some sensible merger of the <quote>ours</quote> and "
5575 "<quote>theirs</quote> versions of the file."
5576 msgstr ""
5578 #. type: Content of: <book><chapter><sect1><sect2><para>
5579 #: ../en/ch03-tour-merge.xml:267
5580 msgid ""
5581 "All four of these panes are <emphasis>locked together</emphasis>; if we "
5582 "scroll vertically or horizontally in any of them, the others are updated to "
5583 "display the corresponding sections of their respective files."
5584 msgstr ""
5586 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
5587 #: ../en/ch03-tour-merge.xml:273
5588 msgid "Using <command>kdiff3</command> to merge versions of a file"
5589 msgstr "使用 <command>kdiff3</command> 合并文件的不同版本"
5591 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
5592 #: ../en/ch03-tour-merge.xml:276
5593 msgid ""
5594 "<imageobject> <imagedata width=\"100%\" fileref=\"figs/kdiff3.png\"/></"
5595 "imageobject>"
5596 msgstr ""
5598 #. type: Content of: <book><chapter><sect1><sect2><para>
5599 #: ../en/ch03-tour-merge.xml:284
5600 msgid ""
5601 "For each conflicting portion of the file, we can choose to resolve the "
5602 "conflict using some combination of text from the base version, ours, or "
5603 "theirs. We can also manually edit the merged file at any time, in case we "
5604 "need to make further modifications."
5605 msgstr ""
5607 #. type: Content of: <book><chapter><sect1><sect2><para>
5608 #: ../en/ch03-tour-merge.xml:290
5609 msgid ""
5610 "There are <emphasis>many</emphasis> file merging tools available, too many to "
5611 "cover here. They vary in which platforms they are available for, and in "
5612 "their particular strengths and weaknesses. Most are tuned for merging files "
5613 "containing plain text, while a few are aimed at specialised file formats "
5614 "(generally XML)."
5615 msgstr ""
5617 #. type: Content of: <book><chapter><sect1><sect2><title>
5618 #: ../en/ch03-tour-merge.xml:299
5619 msgid "A worked example"
5620 msgstr "合并实例"
5622 #. type: Content of: <book><chapter><sect1><sect2><para>
5623 #: ../en/ch03-tour-merge.xml:301
5624 msgid ""
5625 "In this example, we will reproduce the file modification history of <xref "
5626 "linkend=\"fig:tour-merge:conflict\"/> above. Let's begin by creating a "
5627 "repository with a base version of our document."
5628 msgstr ""
5630 #. type: Content of: <book><chapter><sect1><sect2><para>
5631 #: ../en/ch03-tour-merge.xml:308
5632 msgid "We'll clone the repository and make a change to the file."
5633 msgstr ""
5635 #. type: Content of: <book><chapter><sect1><sect2><para>
5636 #: ../en/ch03-tour-merge.xml:313
5637 msgid ""
5638 "And another clone, to simulate someone else making a change to the file. "
5639 "(This hints at the idea that it's not all that unusual to merge with yourself "
5640 "when you isolate tasks in separate repositories, and indeed to find and "
5641 "resolve conflicts while doing so.)"
5642 msgstr ""
5644 #. type: Content of: <book><chapter><sect1><sect2><para>
5645 #: ../en/ch03-tour-merge.xml:321
5646 msgid ""
5647 "Having created two different versions of the file, we'll set up an "
5648 "environment suitable for running our merge."
5649 msgstr ""
5651 #. type: Content of: <book><chapter><sect1><sect2><para>
5652 #: ../en/ch03-tour-merge.xml:327
5653 msgid ""
5654 "In this example, I'll set <envar>HGMERGE</envar> to tell Mercurial to use the "
5655 "non-interactive <command>merge</command> command. This is bundled with many "
5656 "Unix-like systems. (If you're following this example on your computer, don't "
5657 "bother setting <envar>HGMERGE</envar>. You'll get dropped into a GUI file "
5658 "merge tool instead, which is much preferable.)"
5659 msgstr ""
5661 #. type: Content of: <book><chapter><sect1><sect2><para>
5662 #: ../en/ch03-tour-merge.xml:337
5663 msgid ""
5664 "Because <command>merge</command> can't resolve the conflicting changes, it "
5665 "leaves <emphasis>merge markers</emphasis> inside the file that has conflicts, "
5666 "indicating which lines have conflicts, and whether they came from our version "
5667 "of the file or theirs."
5668 msgstr ""
5670 #. type: Content of: <book><chapter><sect1><sect2><para>
5671 #: ../en/ch03-tour-merge.xml:343
5672 msgid ""
5673 "Mercurial can tell from the way <command>merge</command> exits that it wasn't "
5674 "able to merge successfully, so it tells us what commands we'll need to run if "
5675 "we want to redo the merging operation. This could be useful if, for example, "
5676 "we were running a graphical merge tool and quit because we were confused or "
5677 "realised we had made a mistake."
5678 msgstr ""
5680 #. type: Content of: <book><chapter><sect1><sect2><para>
5681 #: ../en/ch03-tour-merge.xml:350
5682 msgid ""
5683 "If automatic or manual merges fail, there's nothing to prevent us from "
5684 "<quote>fixing up</quote> the affected files ourselves, and committing the "
5685 "results of our merge:"
5686 msgstr ""
5688 #. type: Content of: <book><chapter><sect1><sect2><note><title>
5689 #: ../en/ch03-tour-merge.xml:357
5690 msgid "Where is the <command>hg resolve</command> command?"
5691 msgstr "在哪里能找到 <command role=\"hg-cmd\">hg resolve</command> 命令?"
5693 #. type: Content of: <book><chapter><sect1><sect2><note><para>
5694 #: ../en/ch03-tour-merge.xml:359
5695 msgid ""
5696 "The <command>hg resolve</command> command was introduced in Mercurial 1.1, "
5697 "which was released in December 2008. If you are using an older version of "
5698 "Mercurial (run <command>hg version</command> to see), this command will not "
5699 "be present. If your version of Mercurial is older than 1.1, you should "
5700 "strongly consider upgrading to a newer version before trying to tackle "
5701 "complicated merges."
5702 msgstr ""
5704 #. type: Content of: <book><chapter><sect1><title>
5705 #: ../en/ch03-tour-merge.xml:371
5706 msgid "Simplifying the pull-merge-commit sequence"
5707 msgstr "简化拉-合并-提交程序"
5709 #. type: Content of: <book><chapter><sect1><para>
5710 #: ../en/ch03-tour-merge.xml:373
5711 msgid ""
5712 "The process of merging changes as outlined above is straightforward, but "
5713 "requires running three commands in sequence."
5714 msgstr ""
5716 #. type: Content of: <book><chapter><sect1><para>
5717 #: ../en/ch03-tour-merge.xml:379
5718 msgid ""
5719 "In the case of the final commit, you also need to enter a commit message, "
5720 "which is almost always going to be a piece of uninteresting "
5721 "<quote>boilerplate</quote> text."
5722 msgstr ""
5724 #. type: Content of: <book><chapter><sect1><para>
5725 #: ../en/ch03-tour-merge.xml:383
5726 msgid ""
5727 "It would be nice to reduce the number of steps needed, if this were "
5728 "possible. Indeed, Mercurial is distributed with an extension called <literal "
5729 "role=\"hg-ext\">fetch</literal> that does just this."
5730 msgstr ""
5732 #. type: Content of: <book><chapter><sect1><para>
5733 #: ../en/ch03-tour-merge.xml:388
5734 msgid ""
5735 "Mercurial provides a flexible extension mechanism that lets people extend its "
5736 "functionality, while keeping the core of Mercurial small and easy to deal "
5737 "with. Some extensions add new commands that you can use from the command "
5738 "line, while others work <quote>behind the scenes,</quote> for example adding "
5739 "capabilities to Mercurial's built-in server mode."
5740 msgstr ""
5742 #. type: Content of: <book><chapter><sect1><para>
5743 #: ../en/ch03-tour-merge.xml:395
5744 msgid ""
5745 "The <literal role=\"hg-ext\">fetch</literal> extension adds a new command "
5746 "called, not surprisingly, <command role=\"hg-cmd\">hg fetch</command>. This "
5747 "extension acts as a combination of <command role=\"hg-cmd\">hg pull -u</"
5748 "command>, <command role=\"hg-cmd\">hg merge</command> and <command role=\"hg-"
5749 "cmd\">hg commit</command>. It begins by pulling changes from another "
5750 "repository into the current repository. If it finds that the changes added a "
5751 "new head to the repository, it updates to the new head, begins a merge, then "
5752 "(if the merge succeeded) commits the result of the merge with an "
5753 "automatically-generated commit message. If no new heads were added, it "
5754 "updates the working directory to the new tip changeset."
5755 msgstr ""
5757 #. type: Content of: <book><chapter><sect1><para>
5758 #: ../en/ch03-tour-merge.xml:409
5759 msgid ""
5760 "Enabling the <literal role=\"hg-ext\">fetch</literal> extension is easy. "
5761 "Edit the <filename role=\"special\">.hgrc</filename> file in your home "
5762 "directory, and either go to the <literal role=\"rc-extensions\">extensions</"
5763 "literal> section or create an <literal role=\"rc-extensions\">extensions</"
5764 "literal> section. Then add a line that simply reads <quote><literal>fetch=</"
5765 "literal></quote>."
5766 msgstr ""
5768 #. type: Content of: <book><chapter><sect1><para>
5769 #: ../en/ch03-tour-merge.xml:421
5770 msgid ""
5771 "(Normally, the right-hand side of the <quote><literal>=</literal></quote> "
5772 "would indicate where to find the extension, but since the <literal role=\"hg-"
5773 "ext\">fetch</literal> extension is in the standard distribution, Mercurial "
5774 "knows where to search for it.)"
5775 msgstr ""
5777 #. type: Content of: <book><chapter><sect1><title>
5778 #: ../en/ch03-tour-merge.xml:429
5779 msgid "Renaming, copying, and merging"
5780 msgstr "改名,复制与合并"
5782 #. type: Content of: <book><chapter><sect1><para>
5783 #: ../en/ch03-tour-merge.xml:431
5784 msgid ""
5785 "During the life of a project, we will often want to change the layout of its "
5786 "files and directories. This can be as simple as renaming a single file, or as "
5787 "complex as restructuring the entire hierarchy of files within the project."
5788 msgstr ""
5790 #. type: Content of: <book><chapter><sect1><para>
5791 #: ../en/ch03-tour-merge.xml:436
5792 msgid ""
5793 "Mercurial supports these kinds of complex changes fluently, provided we tell "
5794 "it what we're doing. If we want to rename a file, we should use the "
5795 "<command>hg rename</command><placeholder type=\"footnote\" id=\"0\"/> command "
5796 "to rename it, so that Mercurial can do the right thing later when we merge."
5797 msgstr ""
5799 #. type: Content of: <book><chapter><sect1><para><footnote><para>
5800 #: ../en/ch03-tour-merge.xml:439
5801 msgid ""
5802 "If you're a Unix user, you'll be glad to know that the <command>hg rename</"
5803 "command> command can be abbreviated as <command>hg mv</command>."
5804 msgstr ""
5806 #. type: Content of: <book><chapter><sect1><para>
5807 #: ../en/ch03-tour-merge.xml:445
5808 msgid ""
5809 "We will cover the use of these commands in more detail in <xref linkend="
5810 "\"chap:daily.copy\"/>."
5811 msgstr ""
5813 #. type: Content of: <book><chapter><title>
5814 #: ../en/ch04-concepts.xml:5
5815 msgid "Behind the scenes"
5816 msgstr "Mercurial 内幕"
5818 #. type: Content of: <book><chapter><para>
5819 #: ../en/ch04-concepts.xml:7
5820 msgid ""
5821 "Unlike many revision control systems, the concepts upon which Mercurial is "
5822 "built are simple enough that it's easy to understand how the software really "
5823 "works. Knowing these details certainly isn't necessary, so it is certainly "
5824 "safe to skip this chapter. However, I think you will get more out of the "
5825 "software with a <quote>mental model</quote> of what's going on."
5826 msgstr ""
5828 #. type: Content of: <book><chapter><para>
5829 #: ../en/ch04-concepts.xml:14
5830 msgid ""
5831 "Being able to understand what's going on behind the scenes gives me "
5832 "confidence that Mercurial has been carefully designed to be both "
5833 "<emphasis>safe</emphasis> and <emphasis>efficient</emphasis>. And just as "
5834 "importantly, if it's easy for me to retain a good idea of what the software "
5835 "is doing when I perform a revision control task, I'm less likely to be "
5836 "surprised by its behavior."
5837 msgstr ""
5839 #. type: Content of: <book><chapter><para>
5840 #: ../en/ch04-concepts.xml:22
5841 msgid ""
5842 "In this chapter, we'll initially cover the core concepts behind Mercurial's "
5843 "design, then continue to discuss some of the interesting details of its "
5844 "implementation."
5845 msgstr ""
5847 #. type: Content of: <book><chapter><sect1><title>
5848 #: ../en/ch04-concepts.xml:27
5849 msgid "Mercurial's historical record"
5850 msgstr "Mercurial 的历史记录"
5852 #. type: Content of: <book><chapter><sect1><sect2><title>
5853 #: ../en/ch04-concepts.xml:30
5854 msgid "Tracking the history of a single file"
5855 msgstr "跟踪单一文件的历史"
5857 #. type: Content of: <book><chapter><sect1><sect2><para>
5858 #: ../en/ch04-concepts.xml:32
5859 msgid ""
5860 "When Mercurial tracks modifications to a file, it stores the history of that "
5861 "file in a metadata object called a <emphasis>filelog</emphasis>. Each entry "
5862 "in the filelog contains enough information to reconstruct one revision of the "
5863 "file that is being tracked. Filelogs are stored as files in the <filename "
5864 "role=\"special\" class=\"directory\">.hg/store/data</filename> directory. A "
5865 "filelog contains two kinds of information: revision data, and an index to "
5866 "help Mercurial to find a revision efficiently."
5867 msgstr ""
5869 #. type: Content of: <book><chapter><sect1><sect2><para>
5870 #: ../en/ch04-concepts.xml:43
5871 msgid ""
5872 "A file that is large, or has a lot of history, has its filelog stored in "
5873 "separate data (<quote><literal>.d</literal></quote> suffix) and index "
5874 "(<quote><literal>.i</literal></quote> suffix) files. For small files without "
5875 "much history, the revision data and index are combined in a single "
5876 "<quote><literal>.i</literal></quote> file. The correspondence between a file "
5877 "in the working directory and the filelog that tracks its history in the "
5878 "repository is illustrated in <xref linkend=\"fig:concepts:filelog\"/>."
5879 msgstr ""
5881 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
5882 #: ../en/ch04-concepts.xml:55
5883 msgid ""
5884 "Relationships between files in working directory and filelogs in repository"
5885 msgstr "工作目录中的文件与版本库中的文件日志之间的关系"
5887 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
5888 #: ../en/ch04-concepts.xml:58
5889 msgid "<imageobject><imagedata fileref=\"figs/filelog.png\"/></imageobject>"
5890 msgstr ""
5892 #. type: Content of: <book><chapter><sect1><sect2><title>
5893 #: ../en/ch04-concepts.xml:65
5894 msgid "Managing tracked files"
5895 msgstr "管理跟踪的文件"
5897 #. type: Content of: <book><chapter><sect1><sect2><para>
5898 #: ../en/ch04-concepts.xml:67
5899 msgid ""
5900 "Mercurial uses a structure called a <emphasis>manifest</emphasis> to collect "
5901 "together information about the files that it tracks. Each entry in the "
5902 "manifest contains information about the files present in a single changeset. "
5903 "An entry records which files are present in the changeset, the revision of "
5904 "each file, and a few other pieces of file metadata."
5905 msgstr ""
5907 #. type: Content of: <book><chapter><sect1><sect2><title>
5908 #: ../en/ch04-concepts.xml:77
5909 msgid "Recording changeset information"
5910 msgstr "记录修改集信息"
5912 #. type: Content of: <book><chapter><sect1><sect2><para>
5913 #: ../en/ch04-concepts.xml:79
5914 msgid ""
5915 "The <emphasis>changelog</emphasis> contains information about each "
5916 "changeset. Each revision records who committed a change, the changeset "
5917 "comment, other pieces of changeset-related information, and the revision of "
5918 "the manifest to use."
5919 msgstr ""
5921 #. type: Content of: <book><chapter><sect1><sect2><title>
5922 #: ../en/ch04-concepts.xml:87
5923 msgid "Relationships between revisions"
5924 msgstr "版本之间的关系"
5926 #. type: Content of: <book><chapter><sect1><sect2><para>
5927 #: ../en/ch04-concepts.xml:89
5928 msgid ""
5929 "Within a changelog, a manifest, or a filelog, each revision stores a pointer "
5930 "to its immediate parent (or to its two parents, if it's a merge revision). "
5931 "As I mentioned above, there are also relationships between revisions "
5932 "<emphasis>across</emphasis> these structures, and they are hierarchical in "
5933 "nature."
5934 msgstr ""
5936 #. type: Content of: <book><chapter><sect1><sect2><para>
5937 #: ../en/ch04-concepts.xml:96
5938 msgid ""
5939 "For every changeset in a repository, there is exactly one revision stored in "
5940 "the changelog. Each revision of the changelog contains a pointer to a single "
5941 "revision of the manifest. A revision of the manifest stores a pointer to a "
5942 "single revision of each filelog tracked when that changeset was created. "
5943 "These relationships are illustrated in <xref linkend=\"fig:concepts:metadata"
5944 "\"/>."
5945 msgstr ""
5947 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
5948 #: ../en/ch04-concepts.xml:105
5949 msgid "Metadata relationships"
5950 msgstr "元数据之间的关系"
5952 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
5953 #: ../en/ch04-concepts.xml:107
5954 msgid "<imageobject><imagedata fileref=\"figs/metadata.png\"/></imageobject>"
5955 msgstr ""
5957 #. type: Content of: <book><chapter><sect1><sect2><para>
5958 #: ../en/ch04-concepts.xml:112
5959 msgid ""
5960 "As the illustration shows, there is <emphasis>not</emphasis> a <quote>one to "
5961 "one</quote> relationship between revisions in the changelog, manifest, or "
5962 "filelog. If a file that Mercurial tracks hasn't changed between two "
5963 "changesets, the entry for that file in the two revisions of the manifest will "
5964 "point to the same revision of its filelog<placeholder type=\"footnote\" id=\"0"
5965 "\"/>."
5966 msgstr ""
5968 #. type: Content of: <book><chapter><sect1><sect2><para><footnote><para>
5969 #: ../en/ch04-concepts.xml:119
5970 msgid ""
5971 "It is possible (though unusual) for the manifest to remain the same between "
5972 "two changesets, in which case the changelog entries for those changesets will "
5973 "point to the same revision of the manifest."
5974 msgstr ""
5976 #. type: Content of: <book><chapter><sect1><title>
5977 #: ../en/ch04-concepts.xml:128
5978 msgid "Safe, efficient storage"
5979 msgstr "安全,高效的存储"
5981 #. type: Content of: <book><chapter><sect1><para>
5982 #: ../en/ch04-concepts.xml:130
5983 msgid ""
5984 "The underpinnings of changelogs, manifests, and filelogs are provided by a "
5985 "single structure called the <emphasis>revlog</emphasis>."
5986 msgstr ""
5988 #. type: Content of: <book><chapter><sect1><sect2><title>
5989 #: ../en/ch04-concepts.xml:135
5990 msgid "Efficient storage"
5991 msgstr "高效存储"
5993 #. type: Content of: <book><chapter><sect1><sect2><para>
5994 #: ../en/ch04-concepts.xml:137
5995 msgid ""
5996 "The revlog provides efficient storage of revisions using a <emphasis>delta</"
5997 "emphasis> mechanism. Instead of storing a complete copy of a file for each "
5998 "revision, it stores the changes needed to transform an older revision into "
5999 "the new revision. For many kinds of file data, these deltas are typically a "
6000 "fraction of a percent of the size of a full copy of a file."
6001 msgstr ""
6003 #. type: Content of: <book><chapter><sect1><sect2><para>
6004 #: ../en/ch04-concepts.xml:145
6005 msgid ""
6006 "Some obsolete revision control systems can only work with deltas of text "
6007 "files. They must either store binary files as complete snapshots or encoded "
6008 "into a text representation, both of which are wasteful approaches. Mercurial "
6009 "can efficiently handle deltas of files with arbitrary binary contents; it "
6010 "doesn't need to treat text as special."
6011 msgstr ""
6013 #. type: Content of: <book><chapter><sect1><sect2><title>
6014 #: ../en/ch04-concepts.xml:154
6015 msgid "Safe operation"
6016 msgstr "安全操作"
6018 #. type: Content of: <book><chapter><sect1><sect2><para>
6019 #: ../en/ch04-concepts.xml:156
6020 msgid ""
6021 "Mercurial only ever <emphasis>appends</emphasis> data to the end of a revlog "
6022 "file. It never modifies a section of a file after it has written it. This is "
6023 "both more robust and efficient than schemes that need to modify or rewrite "
6024 "data."
6025 msgstr ""
6027 #. type: Content of: <book><chapter><sect1><sect2><para>
6028 #: ../en/ch04-concepts.xml:162
6029 msgid ""
6030 "In addition, Mercurial treats every write as part of a <emphasis>transaction</"
6031 "emphasis> that can span a number of files. A transaction is "
6032 "<emphasis>atomic</emphasis>: either the entire transaction succeeds and its "
6033 "effects are all visible to readers in one go, or the whole thing is undone. "
6034 "This guarantee of atomicity means that if you're running two copies of "
6035 "Mercurial, where one is reading data and one is writing it, the reader will "
6036 "never see a partially written result that might confuse it."
6037 msgstr ""
6039 #. type: Content of: <book><chapter><sect1><sect2><para>
6040 #: ../en/ch04-concepts.xml:172
6041 msgid ""
6042 "The fact that Mercurial only appends to files makes it easier to provide this "
6043 "transactional guarantee. The easier it is to do stuff like this, the more "
6044 "confident you should be that it's done correctly."
6045 msgstr ""
6047 #. type: Content of: <book><chapter><sect1><sect2><title>
6048 #: ../en/ch04-concepts.xml:179
6049 msgid "Fast retrieval"
6050 msgstr "快速检索"
6052 #. type: Content of: <book><chapter><sect1><sect2><para>
6053 #: ../en/ch04-concepts.xml:181
6054 msgid ""
6055 "Mercurial cleverly avoids a pitfall common to all earlier revision control "
6056 "systems: the problem of <emphasis>inefficient retrieval</emphasis>. Most "
6057 "revision control systems store the contents of a revision as an incremental "
6058 "series of modifications against a <quote>snapshot</quote>. (Some base the "
6059 "snapshot on the oldest revision, others on the newest.) To reconstruct a "
6060 "specific revision, you must first read the snapshot, and then every one of "
6061 "the revisions between the snapshot and your target revision. The more "
6062 "history that a file accumulates, the more revisions you must read, hence the "
6063 "longer it takes to reconstruct a particular revision."
6064 msgstr ""
6066 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
6067 #: ../en/ch04-concepts.xml:195
6068 msgid "Snapshot of a revlog, with incremental deltas"
6069 msgstr "版本日志的快照,以及增量差异"
6071 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
6072 #: ../en/ch04-concepts.xml:197
6073 msgid "<imageobject><imagedata fileref=\"figs/snapshot.png\"/></imageobject>"
6074 msgstr ""
6076 #. type: Content of: <book><chapter><sect1><sect2><para>
6077 #: ../en/ch04-concepts.xml:202
6078 msgid ""
6079 "The innovation that Mercurial applies to this problem is simple but "
6080 "effective. Once the cumulative amount of delta information stored since the "
6081 "last snapshot exceeds a fixed threshold, it stores a new snapshot "
6082 "(compressed, of course), instead of another delta. This makes it possible to "
6083 "reconstruct <emphasis>any</emphasis> revision of a file quickly. This "
6084 "approach works so well that it has since been copied by several other "
6085 "revision control systems."
6086 msgstr ""
6088 #. type: Content of: <book><chapter><sect1><sect2><para>
6089 #: ../en/ch04-concepts.xml:211
6090 msgid ""
6091 "<xref linkend=\"fig:concepts:snapshot\"/> illustrates the idea. In an entry "
6092 "in a revlog's index file, Mercurial stores the range of entries from the data "
6093 "file that it must read to reconstruct a particular revision."
6094 msgstr ""
6096 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
6097 #: ../en/ch04-concepts.xml:217
6098 msgid "Aside: the influence of video compression"
6099 msgstr "旁白: 视频压缩的影响"
6101 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
6102 #: ../en/ch04-concepts.xml:219
6103 msgid ""
6104 "If you're familiar with video compression or have ever watched a TV feed "
6105 "through a digital cable or satellite service, you may know that most video "
6106 "compression schemes store each frame of video as a delta against its "
6107 "predecessor frame."
6108 msgstr ""
6110 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
6111 #: ../en/ch04-concepts.xml:225
6112 msgid ""
6113 "Mercurial borrows this idea to make it possible to reconstruct a revision "
6114 "from a snapshot and a small number of deltas."
6115 msgstr ""
6117 #. type: Content of: <book><chapter><sect1><sect2><title>
6118 #: ../en/ch04-concepts.xml:232
6119 msgid "Identification and strong integrity"
6120 msgstr "鉴别和强完整性"
6122 #. type: Content of: <book><chapter><sect1><sect2><para>
6123 #: ../en/ch04-concepts.xml:234
6124 msgid ""
6125 "Along with delta or snapshot information, a revlog entry contains a "
6126 "cryptographic hash of the data that it represents. This makes it difficult "
6127 "to forge the contents of a revision, and easy to detect accidental corruption."
6128 msgstr ""
6130 #. type: Content of: <book><chapter><sect1><sect2><para>
6131 #: ../en/ch04-concepts.xml:239
6132 msgid ""
6133 "Hashes provide more than a mere check against corruption; they are used as "
6134 "the identifiers for revisions. The changeset identification hashes that you "
6135 "see as an end user are from revisions of the changelog. Although filelogs "
6136 "and the manifest also use hashes, Mercurial only uses these behind the scenes."
6137 msgstr ""
6139 #. type: Content of: <book><chapter><sect1><sect2><para>
6140 #: ../en/ch04-concepts.xml:246
6141 msgid ""
6142 "Mercurial verifies that hashes are correct when it retrieves file revisions "
6143 "and when it pulls changes from another repository. If it encounters an "
6144 "integrity problem, it will complain and stop whatever it's doing."
6145 msgstr ""
6147 #. type: Content of: <book><chapter><sect1><sect2><para>
6148 #: ../en/ch04-concepts.xml:251
6149 msgid ""
6150 "In addition to the effect it has on retrieval efficiency, Mercurial's use of "
6151 "periodic snapshots makes it more robust against partial data corruption. If "
6152 "a revlog becomes partly corrupted due to a hardware error or system bug, it's "
6153 "often possible to reconstruct some or most revisions from the uncorrupted "
6154 "sections of the revlog, both before and after the corrupted section. This "
6155 "would not be possible with a delta-only storage model."
6156 msgstr ""
6158 #. type: Content of: <book><chapter><sect1><title>
6159 #: ../en/ch04-concepts.xml:263
6160 msgid "Revision history, branching, and merging"
6161 msgstr "修订历史,分支与合并"
6163 #. type: Content of: <book><chapter><sect1><para>
6164 #: ../en/ch04-concepts.xml:265
6165 msgid ""
6166 "Every entry in a Mercurial revlog knows the identity of its immediate "
6167 "ancestor revision, usually referred to as its <emphasis>parent</emphasis>. "
6168 "In fact, a revision contains room for not one parent, but two. Mercurial "
6169 "uses a special hash, called the <quote>null ID</quote>, to represent the idea "
6170 "<quote>there is no parent here</quote>. This hash is simply a string of "
6171 "zeroes."
6172 msgstr ""
6174 #. type: Content of: <book><chapter><sect1><para>
6175 #: ../en/ch04-concepts.xml:273
6176 msgid ""
6177 "In <xref linkend=\"fig:concepts:revlog\"/>, you can see an example of the "
6178 "conceptual structure of a revlog. Filelogs, manifests, and changelogs all "
6179 "have this same structure; they differ only in the kind of data stored in each "
6180 "delta or snapshot."
6181 msgstr ""
6183 #. type: Content of: <book><chapter><sect1><para>
6184 #: ../en/ch04-concepts.xml:279
6185 msgid ""
6186 "The first revision in a revlog (at the bottom of the image) has the null ID "
6187 "in both of its parent slots. For a <quote>normal</quote> revision, its first "
6188 "parent slot contains the ID of its parent revision, and its second contains "
6189 "the null ID, indicating that the revision has only one real parent. Any two "
6190 "revisions that have the same parent ID are branches. A revision that "
6191 "represents a merge between branches has two normal revision IDs in its parent "
6192 "slots."
6193 msgstr ""
6195 #. type: Content of: <book><chapter><sect1><figure><title>
6196 #: ../en/ch04-concepts.xml:289
6197 msgid "The conceptual structure of a revlog"
6198 msgstr "版本日志的设计结构"
6200 #. type: Content of: <book><chapter><sect1><figure><mediaobject>
6201 #: ../en/ch04-concepts.xml:291
6202 msgid "<imageobject><imagedata fileref=\"figs/revlog.png\"/></imageobject>"
6203 msgstr ""
6205 #. type: Content of: <book><chapter><sect1><title>
6206 #: ../en/ch04-concepts.xml:298
6207 msgid "The working directory"
6208 msgstr "工作目录"
6210 #. type: Content of: <book><chapter><sect1><para>
6211 #: ../en/ch04-concepts.xml:300
6212 msgid ""
6213 "In the working directory, Mercurial stores a snapshot of the files from the "
6214 "repository as of a particular changeset."
6215 msgstr ""
6217 #. type: Content of: <book><chapter><sect1><para>
6218 #: ../en/ch04-concepts.xml:303
6219 msgid ""
6220 "The working directory <quote>knows</quote> which changeset it contains. When "
6221 "you update the working directory to contain a particular changeset, Mercurial "
6222 "looks up the appropriate revision of the manifest to find out which files it "
6223 "was tracking at the time that changeset was committed, and which revision of "
6224 "each file was then current. It then recreates a copy of each of those files, "
6225 "with the same contents it had when the changeset was committed."
6226 msgstr ""
6228 #. type: Content of: <book><chapter><sect1><para>
6229 #: ../en/ch04-concepts.xml:312
6230 msgid ""
6231 "The <emphasis>dirstate</emphasis> is a special structure that contains "
6232 "Mercurial's knowledge of the working directory. It is maintained as a file "
6233 "named <filename>.hg/dirstate</filename> inside a repository. The dirstate "
6234 "details which changeset the working directory is updated to, and all of the "
6235 "files that Mercurial is tracking in the working directory. It also lets "
6236 "Mercurial quickly notice changed files, by recording their checkout times and "
6237 "sizes."
6238 msgstr ""
6240 #. type: Content of: <book><chapter><sect1><para>
6241 #: ../en/ch04-concepts.xml:322
6242 msgid ""
6243 "Just as a revision of a revlog has room for two parents, so that it can "
6244 "represent either a normal revision (with one parent) or a merge of two "
6245 "earlier revisions, the dirstate has slots for two parents. When you use the "
6246 "<command role=\"hg-cmd\">hg update</command> command, the changeset that you "
6247 "update to is stored in the <quote>first parent</quote> slot, and the null ID "
6248 "in the second. When you <command role=\"hg-cmd\">hg merge</command> with "
6249 "another changeset, the first parent remains unchanged, and the second parent "
6250 "is filled in with the changeset you're merging with. The <command role=\"hg-"
6251 "cmd\">hg parents</command> command tells you what the parents of the dirstate "
6252 "are."
6253 msgstr ""
6255 #. type: Content of: <book><chapter><sect1><sect2><title>
6256 #: ../en/ch04-concepts.xml:336
6257 msgid "What happens when you commit"
6258 msgstr "当你提交时发生的事情"
6260 #. type: Content of: <book><chapter><sect1><sect2><para>
6261 #: ../en/ch04-concepts.xml:338
6262 msgid ""
6263 "The dirstate stores parent information for more than just book-keeping "
6264 "purposes. Mercurial uses the parents of the dirstate as <emphasis>the "
6265 "parents of a new changeset</emphasis> when you perform a commit."
6266 msgstr ""
6268 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
6269 #: ../en/ch04-concepts.xml:344
6270 msgid "The working directory can have two parents"
6271 msgstr "工作目录可以有两个父亲"
6273 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
6274 #: ../en/ch04-concepts.xml:346
6275 msgid "<imageobject><imagedata fileref=\"figs/wdir.png\"/></imageobject>"
6276 msgstr ""
6278 #. type: Content of: <book><chapter><sect1><sect2><para>
6279 #: ../en/ch04-concepts.xml:351
6280 msgid ""
6281 "<xref linkend=\"fig:concepts:wdir\"/> shows the normal state of the working "
6282 "directory, where it has a single changeset as parent. That changeset is the "
6283 "<emphasis>tip</emphasis>, the newest changeset in the repository that has no "
6284 "children."
6285 msgstr ""
6287 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
6288 #: ../en/ch04-concepts.xml:358
6289 msgid "The working directory gains new parents after a commit"
6290 msgstr "提交之后,工作目录的父亲就改变了"
6292 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
6293 #: ../en/ch04-concepts.xml:361
6294 msgid ""
6295 "<imageobject><imagedata fileref=\"figs/wdir-after-commit.png\"/></imageobject>"
6296 msgstr ""
6298 #. type: Content of: <book><chapter><sect1><sect2><para>
6299 #: ../en/ch04-concepts.xml:366
6300 msgid ""
6301 "It's useful to think of the working directory as <quote>the changeset I'm "
6302 "about to commit</quote>. Any files that you tell Mercurial that you've "
6303 "added, removed, renamed, or copied will be reflected in that changeset, as "
6304 "will modifications to any files that Mercurial is already tracking; the new "
6305 "changeset will have the parents of the working directory as its parents."
6306 msgstr ""
6308 #. type: Content of: <book><chapter><sect1><sect2><para>
6309 #: ../en/ch04-concepts.xml:374
6310 msgid ""
6311 "After a commit, Mercurial will update the parents of the working directory, "
6312 "so that the first parent is the ID of the new changeset, and the second is "
6313 "the null ID. This is shown in <xref linkend=\"fig:concepts:wdir-after-commit"
6314 "\"/>. Mercurial doesn't touch any of the files in the working directory when "
6315 "you commit; it just modifies the dirstate to note its new parents."
6316 msgstr ""
6318 #. type: Content of: <book><chapter><sect1><sect2><title>
6319 #: ../en/ch04-concepts.xml:385
6320 msgid "Creating a new head"
6321 msgstr "创建新顶点"
6323 #. type: Content of: <book><chapter><sect1><sect2><para>
6324 #: ../en/ch04-concepts.xml:387
6325 msgid ""
6326 "It's perfectly normal to update the working directory to a changeset other "
6327 "than the current tip. For example, you might want to know what your project "
6328 "looked like last Tuesday, or you could be looking through changesets to see "
6329 "which one introduced a bug. In cases like this, the natural thing to do is "
6330 "update the working directory to the changeset you're interested in, and then "
6331 "examine the files in the working directory directly to see their contents as "
6332 "they were when you committed that changeset. The effect of this is shown in "
6333 "<xref linkend=\"fig:concepts:wdir-pre-branch\"/>."
6334 msgstr ""
6336 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
6337 #: ../en/ch04-concepts.xml:399
6338 msgid "The working directory, updated to an older changeset"
6339 msgstr "同步到旧修改集的工作目录"
6341 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
6342 #: ../en/ch04-concepts.xml:402
6343 msgid ""
6344 "<imageobject><imagedata fileref=\"figs/wdir-pre-branch.png\"/></imageobject>"
6345 msgstr ""
6347 #. type: Content of: <book><chapter><sect1><sect2><para>
6348 #: ../en/ch04-concepts.xml:407
6349 msgid ""
6350 "Having updated the working directory to an older changeset, what happens if "
6351 "you make some changes, and then commit? Mercurial behaves in the same way as "
6352 "I outlined above. The parents of the working directory become the parents of "
6353 "the new changeset. This new changeset has no children, so it becomes the new "
6354 "tip. And the repository now contains two changesets that have no children; "
6355 "we call these <emphasis>heads</emphasis>. You can see the structure that "
6356 "this creates in <xref linkend=\"fig:concepts:wdir-branch\"/>."
6357 msgstr ""
6359 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
6360 #: ../en/ch04-concepts.xml:419
6361 msgid "After a commit made while synced to an older changeset"
6362 msgstr "对同步到旧修改集的工作目录提交之后"
6364 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
6365 #: ../en/ch04-concepts.xml:422
6366 msgid "<imageobject><imagedata fileref=\"figs/wdir-branch.png\"/></imageobject>"
6367 msgstr ""
6369 #. type: Content of: <book><chapter><sect1><sect2><note><para>
6370 #: ../en/ch04-concepts.xml:428
6371 msgid ""
6372 "If you're new to Mercurial, you should keep in mind a common <quote>error</"
6373 "quote>, which is to use the <command role=\"hg-cmd\">hg pull</command> "
6374 "command without any options. By default, the <command role=\"hg-cmd\">hg "
6375 "pull</command> command <emphasis>does not</emphasis> update the working "
6376 "directory, so you'll bring new changesets into your repository, but the "
6377 "working directory will stay synced at the same changeset as before the pull. "
6378 "If you make some changes and commit afterwards, you'll thus create a new "
6379 "head, because your working directory isn't synced to whatever the current tip "
6380 "is. To combine the operation of a pull, followed by an update, run "
6381 "<command>hg pull -u</command>."
6382 msgstr ""
6384 #. type: Content of: <book><chapter><sect1><sect2><note><para>
6385 #: ../en/ch04-concepts.xml:442
6386 msgid ""
6387 "I put the word <quote>error</quote> in quotes because all that you need to do "
6388 "to rectify the situation where you created a new head by accident is <command "
6389 "role=\"hg-cmd\">hg merge</command>, then <command role=\"hg-cmd\">hg commit</"
6390 "command>. In other words, this almost never has negative consequences; it's "
6391 "just something of a surprise for newcomers. I'll discuss other ways to avoid "
6392 "this behavior, and why Mercurial behaves in this initially surprising way, "
6393 "later on."
6394 msgstr ""
6396 #. type: Content of: <book><chapter><sect1><sect2><title>
6397 #: ../en/ch04-concepts.xml:455
6398 msgid "Merging changes"
6399 msgstr "合并修改"
6401 #. type: Content of: <book><chapter><sect1><sect2><para>
6402 #: ../en/ch04-concepts.xml:457
6403 msgid ""
6404 "When you run the <command role=\"hg-cmd\">hg merge</command> command, "
6405 "Mercurial leaves the first parent of the working directory unchanged, and "
6406 "sets the second parent to the changeset you're merging with, as shown in "
6407 "<xref linkend=\"fig:concepts:wdir-merge\"/>."
6408 msgstr ""
6410 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
6411 #: ../en/ch04-concepts.xml:464
6412 msgid "Merging two heads"
6413 msgstr "合并两个顶点"
6415 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
6416 #: ../en/ch04-concepts.xml:466
6417 msgid ""
6418 "<imageobject> <imagedata fileref=\"figs/wdir-merge.png\"/> </imageobject>"
6419 msgstr ""
6421 #. type: Content of: <book><chapter><sect1><sect2><para>
6422 #: ../en/ch04-concepts.xml:473
6423 msgid ""
6424 "Mercurial also has to modify the working directory, to merge the files "
6425 "managed in the two changesets. Simplified a little, the merging process goes "
6426 "like this, for every file in the manifests of both changesets."
6427 msgstr ""
6429 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6430 #: ../en/ch04-concepts.xml:478
6431 msgid "If neither changeset has modified a file, do nothing with that file."
6432 msgstr ""
6434 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6435 #: ../en/ch04-concepts.xml:481
6436 msgid ""
6437 "If one changeset has modified a file, and the other hasn't, create the "
6438 "modified copy of the file in the working directory."
6439 msgstr ""
6441 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6442 #: ../en/ch04-concepts.xml:485
6443 msgid ""
6444 "If one changeset has removed a file, and the other hasn't (or has also "
6445 "deleted it), delete the file from the working directory."
6446 msgstr ""
6448 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6449 #: ../en/ch04-concepts.xml:489
6450 msgid ""
6451 "If one changeset has removed a file, but the other has modified the file, ask "
6452 "the user what to do: keep the modified file, or remove it?"
6453 msgstr ""
6455 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6456 #: ../en/ch04-concepts.xml:493
6457 msgid ""
6458 "If both changesets have modified a file, invoke an external merge program to "
6459 "choose the new contents for the merged file. This may require input from the "
6460 "user."
6461 msgstr ""
6463 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6464 #: ../en/ch04-concepts.xml:498
6465 msgid ""
6466 "If one changeset has modified a file, and the other has renamed or copied the "
6467 "file, make sure that the changes follow the new name of the file."
6468 msgstr ""
6470 #. type: Content of: <book><chapter><sect1><sect2><para>
6471 #: ../en/ch04-concepts.xml:502
6472 msgid ""
6473 "There are more details&emdash;merging has plenty of corner cases&emdash;but "
6474 "these are the most common choices that are involved in a merge. As you can "
6475 "see, most cases are completely automatic, and indeed most merges finish "
6476 "automatically, without requiring your input to resolve any conflicts."
6477 msgstr ""
6479 #. type: Content of: <book><chapter><sect1><sect2><para>
6480 #: ../en/ch04-concepts.xml:509
6481 msgid ""
6482 "When you're thinking about what happens when you commit after a merge, once "
6483 "again the working directory is <quote>the changeset I'm about to commit</"
6484 "quote>. After the <command role=\"hg-cmd\">hg merge</command> command "
6485 "completes, the working directory has two parents; these will become the "
6486 "parents of the new changeset."
6487 msgstr ""
6489 #. type: Content of: <book><chapter><sect1><sect2><para>
6490 #: ../en/ch04-concepts.xml:516
6491 msgid ""
6492 "Mercurial lets you perform multiple merges, but you must commit the results "
6493 "of each individual merge as you go. This is necessary because Mercurial only "
6494 "tracks two parents for both revisions and the working directory. While it "
6495 "would be technically feasible to merge multiple changesets at once, Mercurial "
6496 "avoids this for simplicity. With multi-way merges, the risks of user "
6497 "confusion, nasty conflict resolution, and making a terrible mess of a merge "
6498 "would grow intolerable."
6499 msgstr ""
6501 #. type: Content of: <book><chapter><sect1><sect2><title>
6502 #: ../en/ch04-concepts.xml:529
6503 msgid "Merging and renames"
6504 msgstr "合并与改名"
6506 #. type: Content of: <book><chapter><sect1><sect2><para>
6507 #: ../en/ch04-concepts.xml:531
6508 msgid ""
6509 "A surprising number of revision control systems pay little or no attention to "
6510 "a file's <emphasis>name</emphasis> over time. For instance, it used to be "
6511 "common that if a file got renamed on one side of a merge, the changes from "
6512 "the other side would be silently dropped."
6513 msgstr ""
6515 #. type: Content of: <book><chapter><sect1><sect2><para>
6516 #: ../en/ch04-concepts.xml:537
6517 msgid ""
6518 "Mercurial records metadata when you tell it to perform a rename or copy. It "
6519 "uses this metadata during a merge to do the right thing in the case of a "
6520 "merge. For instance, if I rename a file, and you edit it without renaming "
6521 "it, when we merge our work the file will be renamed and have your edits "
6522 "applied."
6523 msgstr ""
6525 #. type: Content of: <book><chapter><sect1><title>
6526 #: ../en/ch04-concepts.xml:547
6527 msgid "Other interesting design features"
6528 msgstr "其它有趣的设计特性"
6530 #. type: Content of: <book><chapter><sect1><para>
6531 #: ../en/ch04-concepts.xml:549
6532 msgid ""
6533 "In the sections above, I've tried to highlight some of the most important "
6534 "aspects of Mercurial's design, to illustrate that it pays careful attention "
6535 "to reliability and performance. However, the attention to detail doesn't "
6536 "stop there. There are a number of other aspects of Mercurial's construction "
6537 "that I personally find interesting. I'll detail a few of them here, separate "
6538 "from the <quote>big ticket</quote> items above, so that if you're interested, "
6539 "you can gain a better idea of the amount of thinking that goes into a well-"
6540 "designed system."
6541 msgstr ""
6543 #. type: Content of: <book><chapter><sect1><sect2><title>
6544 #: ../en/ch04-concepts.xml:560
6545 msgid "Clever compression"
6546 msgstr "智能压缩"
6548 #. type: Content of: <book><chapter><sect1><sect2><para>
6549 #: ../en/ch04-concepts.xml:562
6550 msgid ""
6551 "When appropriate, Mercurial will store both snapshots and deltas in "
6552 "compressed form. It does this by always <emphasis>trying to</emphasis> "
6553 "compress a snapshot or delta, but only storing the compressed version if it's "
6554 "smaller than the uncompressed version."
6555 msgstr ""
6557 #. type: Content of: <book><chapter><sect1><sect2><para>
6558 #: ../en/ch04-concepts.xml:568
6559 msgid ""
6560 "This means that Mercurial does <quote>the right thing</quote> when storing a "
6561 "file whose native form is compressed, such as a <literal>zip</literal> "
6562 "archive or a JPEG image. When these types of files are compressed a second "
6563 "time, the resulting file is usually bigger than the once-compressed form, and "
6564 "so Mercurial will store the plain <literal>zip</literal> or JPEG."
6565 msgstr ""
6567 #. type: Content of: <book><chapter><sect1><sect2><para>
6568 #: ../en/ch04-concepts.xml:576
6569 msgid ""
6570 "Deltas between revisions of a compressed file are usually larger than "
6571 "snapshots of the file, and Mercurial again does <quote>the right thing</"
6572 "quote> in these cases. It finds that such a delta exceeds the threshold at "
6573 "which it should store a complete snapshot of the file, so it stores the "
6574 "snapshot, again saving space compared to a naive delta-only approach."
6575 msgstr ""
6577 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
6578 #: ../en/ch04-concepts.xml:585
6579 msgid "Network recompression"
6580 msgstr "网络重新压缩"
6582 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
6583 #: ../en/ch04-concepts.xml:587
6584 msgid ""
6585 "When storing revisions on disk, Mercurial uses the <quote>deflate</quote> "
6586 "compression algorithm (the same one used by the popular <literal>zip</"
6587 "literal> archive format), which balances good speed with a respectable "
6588 "compression ratio. However, when transmitting revision data over a network "
6589 "connection, Mercurial uncompresses the compressed revision data."
6590 msgstr ""
6592 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
6593 #: ../en/ch04-concepts.xml:595
6594 msgid ""
6595 "If the connection is over HTTP, Mercurial recompresses the entire stream of "
6596 "data using a compression algorithm that gives a better compression ratio (the "
6597 "Burrows-Wheeler algorithm from the widely used <literal>bzip2</literal> "
6598 "compression package). This combination of algorithm and compression of the "
6599 "entire stream (instead of a revision at a time) substantially reduces the "
6600 "number of bytes to be transferred, yielding better network performance over "
6601 "most kinds of network."
6602 msgstr ""
6604 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
6605 #: ../en/ch04-concepts.xml:605
6606 msgid ""
6607 "If the connection is over <command>ssh</command>, Mercurial "
6608 "<emphasis>doesn't</emphasis> recompress the stream, because <command>ssh</"
6609 "command> can already do this itself. You can tell Mercurial to always use "
6610 "<command>ssh</command>'s compression feature by editing the <filename>.hgrc</"
6611 "filename> file in your home directory as follows."
6612 msgstr ""
6614 #. type: Content of: <book><chapter><sect1><sect2><title>
6615 #: ../en/ch04-concepts.xml:620
6616 msgid "Read/write ordering and atomicity"
6617 msgstr "读写顺序与原子性"
6619 #. type: Content of: <book><chapter><sect1><sect2><para>
6620 #: ../en/ch04-concepts.xml:622
6621 msgid ""
6622 "Appending to files isn't the whole story when it comes to guaranteeing that a "
6623 "reader won't see a partial write. If you recall <xref linkend=\"fig:concepts:"
6624 "metadata\"/>, revisions in the changelog point to revisions in the manifest, "
6625 "and revisions in the manifest point to revisions in filelogs. This hierarchy "
6626 "is deliberate."
6627 msgstr ""
6629 #. type: Content of: <book><chapter><sect1><sect2><para>
6630 #: ../en/ch04-concepts.xml:629
6631 msgid ""
6632 "A writer starts a transaction by writing filelog and manifest data, and "
6633 "doesn't write any changelog data until those are finished. A reader starts "
6634 "by reading changelog data, then manifest data, followed by filelog data."
6635 msgstr ""
6637 #. type: Content of: <book><chapter><sect1><sect2><para>
6638 #: ../en/ch04-concepts.xml:634
6639 msgid ""
6640 "Since the writer has always finished writing filelog and manifest data before "
6641 "it writes to the changelog, a reader will never read a pointer to a partially "
6642 "written manifest revision from the changelog, and it will never read a "
6643 "pointer to a partially written filelog revision from the manifest."
6644 msgstr ""
6646 #. type: Content of: <book><chapter><sect1><sect2><title>
6647 #: ../en/ch04-concepts.xml:642
6648 msgid "Concurrent access"
6649 msgstr "并发访问"
6651 #. type: Content of: <book><chapter><sect1><sect2><para>
6652 #: ../en/ch04-concepts.xml:644
6653 msgid ""
6654 "The read/write ordering and atomicity guarantees mean that Mercurial never "
6655 "needs to <emphasis>lock</emphasis> a repository when it's reading data, even "
6656 "if the repository is being written to while the read is occurring. This has a "
6657 "big effect on scalability; you can have an arbitrary number of Mercurial "
6658 "processes safely reading data from a repository all at once, no matter "
6659 "whether it's being written to or not."
6660 msgstr ""
6662 #. type: Content of: <book><chapter><sect1><sect2><para>
6663 #: ../en/ch04-concepts.xml:653
6664 msgid ""
6665 "The lockless nature of reading means that if you're sharing a repository on a "
6666 "multi-user system, you don't need to grant other local users permission to "
6667 "<emphasis>write</emphasis> to your repository in order for them to be able to "
6668 "clone it or pull changes from it; they only need <emphasis>read</emphasis> "
6669 "permission. (This is <emphasis>not</emphasis> a common feature among "
6670 "revision control systems, so don't take it for granted! Most require readers "
6671 "to be able to lock a repository to access it safely, and this requires write "
6672 "permission on at least one directory, which of course makes for all kinds of "
6673 "nasty and annoying security and administrative problems.)"
6674 msgstr ""
6676 #. type: Content of: <book><chapter><sect1><sect2><para>
6677 #: ../en/ch04-concepts.xml:666
6678 msgid ""
6679 "Mercurial uses locks to ensure that only one process can write to a "
6680 "repository at a time (the locking mechanism is safe even over filesystems "
6681 "that are notoriously hostile to locking, such as NFS). If a repository is "
6682 "locked, a writer will wait for a while to retry if the repository becomes "
6683 "unlocked, but if the repository remains locked for too long, the process "
6684 "attempting to write will time out after a while. This means that your daily "
6685 "automated scripts won't get stuck forever and pile up if a system crashes "
6686 "unnoticed, for example. (Yes, the timeout is configurable, from zero to "
6687 "infinity.)"
6688 msgstr ""
6690 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
6691 #: ../en/ch04-concepts.xml:678
6692 msgid "Safe dirstate access"
6693 msgstr "安全的目录状态访问"
6695 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
6696 #: ../en/ch04-concepts.xml:680
6697 msgid ""
6698 "As with revision data, Mercurial doesn't take a lock to read the dirstate "
6699 "file; it does acquire a lock to write it. To avoid the possibility of "
6700 "reading a partially written copy of the dirstate file, Mercurial writes to a "
6701 "file with a unique name in the same directory as the dirstate file, then "
6702 "renames the temporary file atomically to <filename>dirstate</filename>. The "
6703 "file named <filename>dirstate</filename> is thus guaranteed to be complete, "
6704 "not partially written."
6705 msgstr ""
6707 #. type: Content of: <book><chapter><sect1><sect2><title>
6708 #: ../en/ch04-concepts.xml:693
6709 msgid "Avoiding seeks"
6710 msgstr "避免查找"
6712 #. type: Content of: <book><chapter><sect1><sect2><para>
6713 #: ../en/ch04-concepts.xml:695
6714 msgid ""
6715 "Critical to Mercurial's performance is the avoidance of seeks of the disk "
6716 "head, since any seek is far more expensive than even a comparatively large "
6717 "read operation."
6718 msgstr ""
6720 #. type: Content of: <book><chapter><sect1><sect2><para>
6721 #: ../en/ch04-concepts.xml:699
6722 msgid ""
6723 "This is why, for example, the dirstate is stored in a single file. If there "
6724 "were a dirstate file per directory that Mercurial tracked, the disk would "
6725 "seek once per directory. Instead, Mercurial reads the entire single dirstate "
6726 "file in one step."
6727 msgstr ""
6729 #. type: Content of: <book><chapter><sect1><sect2><para>
6730 #: ../en/ch04-concepts.xml:705
6731 msgid ""
6732 "Mercurial also uses a <quote>copy on write</quote> scheme when cloning a "
6733 "repository on local storage. Instead of copying every revlog file from the "
6734 "old repository into the new repository, it makes a <quote>hard link</quote>, "
6735 "which is a shorthand way to say <quote>these two names point to the same "
6736 "file</quote>. When Mercurial is about to write to one of a revlog's files, "
6737 "it checks to see if the number of names pointing at the file is greater than "
6738 "one. If it is, more than one repository is using the file, so Mercurial "
6739 "makes a new copy of the file that is private to this repository."
6740 msgstr ""
6742 #. type: Content of: <book><chapter><sect1><sect2><para>
6743 #: ../en/ch04-concepts.xml:716
6744 msgid ""
6745 "A few revision control developers have pointed out that this idea of making a "
6746 "complete private copy of a file is not very efficient in its use of storage. "
6747 "While this is true, storage is cheap, and this method gives the highest "
6748 "performance while deferring most book-keeping to the operating system. An "
6749 "alternative scheme would most likely reduce performance and increase the "
6750 "complexity of the software, but speed and simplicity are key to the "
6751 "<quote>feel</quote> of day-to-day use."
6752 msgstr ""
6754 #. type: Content of: <book><chapter><sect1><sect2><title>
6755 #: ../en/ch04-concepts.xml:728
6756 msgid "Other contents of the dirstate"
6757 msgstr "目录状态的其它内容"
6759 #. type: Content of: <book><chapter><sect1><sect2><para>
6760 #: ../en/ch04-concepts.xml:730
6761 msgid ""
6762 "Because Mercurial doesn't force you to tell it when you're modifying a file, "
6763 "it uses the dirstate to store some extra information so it can determine "
6764 "efficiently whether you have modified a file. For each file in the working "
6765 "directory, it stores the time that it last modified the file itself, and the "
6766 "size of the file at that time."
6767 msgstr ""
6769 #. type: Content of: <book><chapter><sect1><sect2><para>
6770 #: ../en/ch04-concepts.xml:737
6771 msgid ""
6772 "When you explicitly <command role=\"hg-cmd\">hg add</command>, <command role="
6773 "\"hg-cmd\">hg remove</command>, <command role=\"hg-cmd\">hg rename</command> "
6774 "or <command role=\"hg-cmd\">hg copy</command> files, Mercurial updates the "
6775 "dirstate so that it knows what to do with those files when you commit."
6776 msgstr ""
6778 #. type: Content of: <book><chapter><sect1><sect2><para>
6779 #: ../en/ch04-concepts.xml:744
6780 msgid ""
6781 "The dirstate helps Mercurial to efficiently check the status of files in a "
6782 "repository."
6783 msgstr ""
6785 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6786 #: ../en/ch04-concepts.xml:749
6787 msgid ""
6788 "When Mercurial checks the state of a file in the working directory, it first "
6789 "checks a file's modification time against the time in the dirstate that "
6790 "records when Mercurial last wrote the file. If the last modified time is the "
6791 "same as the time when Mercurial wrote the file, the file must not have been "
6792 "modified, so Mercurial does not need to check any further."
6793 msgstr ""
6795 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6796 #: ../en/ch04-concepts.xml:758
6797 msgid ""
6798 "If the file's size has changed, the file must have been modified. If the "
6799 "modification time has changed, but the size has not, only then does Mercurial "
6800 "need to actually read the contents of the file to see if it has changed."
6801 msgstr ""
6803 #. type: Content of: <book><chapter><sect1><sect2><para>
6804 #: ../en/ch04-concepts.xml:766
6805 msgid ""
6806 "Storing the modification time and size dramatically reduces the number of "
6807 "read operations that Mercurial needs to perform when we run commands like "
6808 "<command>hg status</command>. This results in large performance improvements."
6809 msgstr ""
6811 #. type: Content of: <book><chapter><title>
6812 #: ../en/ch05-daily.xml:5
6813 msgid "Mercurial in daily use"
6814 msgstr "Mercurial 的日常使用"
6816 #. type: Content of: <book><chapter><sect1><title>
6817 #: ../en/ch05-daily.xml:8
6818 msgid "Telling Mercurial which files to track"
6819 msgstr "告诉 Mercurial 要跟踪哪些文件"
6821 #. type: Content of: <book><chapter><sect1><para>
6822 #: ../en/ch05-daily.xml:10
6823 msgid ""
6824 "Mercurial does not work with files in your repository unless you tell it to "
6825 "manage them. The <command role=\"hg-cmd\">hg status</command> command will "
6826 "tell you which files Mercurial doesn't know about; it uses a <quote><literal>?"
6827 "</literal></quote> to display such files."
6828 msgstr ""
6831 #. type: Content of: <book><chapter><sect1><para>
6832 #: ../en/ch05-daily.xml:17
6833 msgid ""
6834 "To tell Mercurial to track a file, use the <command role=\"hg-cmd\">hg add</"
6835 "command> command. Once you have added a file, the entry in the output of "
6836 "<command role=\"hg-cmd\">hg status</command> for that file changes from "
6837 "<quote><literal>?</literal></quote> to <quote><literal>A</literal></quote>."
6838 msgstr ""
6840 #. type: Content of: <book><chapter><sect1><para>
6841 #: ../en/ch05-daily.xml:26
6842 msgid ""
6843 "After you run a <command role=\"hg-cmd\">hg commit</command>, the files that "
6844 "you added before the commit will no longer be listed in the output of "
6845 "<command role=\"hg-cmd\">hg status</command>. The reason for this is that by "
6846 "default, <command role=\"hg-cmd\">hg status</command> only tells you about "
6847 "<quote>interesting</quote> files&emdash;those that you have (for example) "
6848 "modified, removed, or renamed. If you have a repository that contains "
6849 "thousands of files, you will rarely want to know about files that Mercurial "
6850 "is tracking, but that have not changed. (You can still get this information; "
6851 "we'll return to this later.)"
6852 msgstr ""
6854 #. type: Content of: <book><chapter><sect1><para>
6855 #: ../en/ch05-daily.xml:38
6856 msgid ""
6857 "Once you add a file, Mercurial doesn't do anything with it immediately. "
6858 "Instead, it will take a snapshot of the file's state the next time you "
6859 "perform a commit. It will then continue to track the changes you make to the "
6860 "file every time you commit, until you remove the file."
6861 msgstr ""
6863 #. type: Content of: <book><chapter><sect1><sect2><title>
6864 #: ../en/ch05-daily.xml:45
6865 msgid "Explicit versus implicit file naming"
6866 msgstr "明确与隐含文件命名"
6868 #. type: Content of: <book><chapter><sect1><sect2><para>
6869 #: ../en/ch05-daily.xml:47
6870 msgid ""
6871 "A useful behavior that Mercurial has is that if you pass the name of a "
6872 "directory to a command, every Mercurial command will treat this as <quote>I "
6873 "want to operate on every file in this directory and its subdirectories</"
6874 "quote>."
6875 msgstr ""
6877 #. type: Content of: <book><chapter><sect1><sect2><para>
6878 #: ../en/ch05-daily.xml:54
6879 msgid ""
6880 "Notice in this example that Mercurial printed the names of the files it "
6881 "added, whereas it didn't do so when we added the file named <filename>myfile."
6882 "txt</filename> in the earlier example."
6883 msgstr ""
6885 #. type: Content of: <book><chapter><sect1><sect2><para>
6886 #: ../en/ch05-daily.xml:59
6887 msgid ""
6888 "What's going on is that in the former case, we explicitly named the file to "
6889 "add on the command line. The assumption that Mercurial makes in such cases "
6890 "is that we know what we are doing, and it doesn't print any output."
6891 msgstr ""
6893 #. type: Content of: <book><chapter><sect1><sect2><para>
6894 #: ../en/ch05-daily.xml:64
6895 msgid ""
6896 "However, when we <emphasis>imply</emphasis> the names of files by giving the "
6897 "name of a directory, Mercurial takes the extra step of printing the name of "
6898 "each file that it does something with. This makes it more clear what is "
6899 "happening, and reduces the likelihood of a silent and nasty surprise. This "
6900 "behavior is common to most Mercurial commands."
6901 msgstr ""
6903 #. type: Content of: <book><chapter><sect1><sect2><title>
6904 #: ../en/ch05-daily.xml:73
6905 msgid "Mercurial tracks files, not directories"
6906 msgstr "Mercurial 只跟踪文件,不跟踪目录"
6908 #. type: Content of: <book><chapter><sect1><sect2><para>
6909 #: ../en/ch05-daily.xml:75
6910 msgid ""
6911 "Mercurial does not track directory information. Instead, it tracks the path "
6912 "to a file. Before creating a file, it first creates any missing directory "
6913 "components of the path. After it deletes a file, it then deletes any empty "
6914 "directories that were in the deleted file's path. This sounds like a trivial "
6915 "distinction, but it has one minor practical consequence: it is not possible "
6916 "to represent a completely empty directory in Mercurial."
6917 msgstr ""
6919 #. type: Content of: <book><chapter><sect1><sect2><para>
6920 #: ../en/ch05-daily.xml:84
6921 msgid ""
6922 "Empty directories are rarely useful, and there are unintrusive workarounds "
6923 "that you can use to achieve an appropriate effect. The developers of "
6924 "Mercurial thus felt that the complexity that would be required to manage "
6925 "empty directories was not worth the limited benefit this feature would bring."
6926 msgstr ""
6928 #. type: Content of: <book><chapter><sect1><sect2><para>
6929 #: ../en/ch05-daily.xml:91
6930 msgid ""
6931 "If you need an empty directory in your repository, there are a few ways to "
6932 "achieve this. One is to create a directory, then <command role=\"hg-cmd\">hg "
6933 "add</command> a <quote>hidden</quote> file to that directory. On Unix-like "
6934 "systems, any file name that begins with a period (<quote><literal>.</"
6935 "literal></quote>) is treated as hidden by most commands and GUI tools. This "
6936 "approach is illustrated below."
6937 msgstr ""
6939 #. type: Content of: <book><chapter><sect1><sect2><para>
6940 #: ../en/ch05-daily.xml:102
6941 msgid ""
6942 "Another way to tackle a need for an empty directory is to simply create one "
6943 "in your automated build scripts before they will need it."
6944 msgstr ""
6946 #. type: Content of: <book><chapter><sect1><title>
6947 #: ../en/ch05-daily.xml:109
6948 msgid "How to stop tracking a file"
6949 msgstr "如何停止跟踪文件"
6951 #. type: Content of: <book><chapter><sect1><para>
6952 #: ../en/ch05-daily.xml:111
6953 msgid ""
6954 "Once you decide that a file no longer belongs in your repository, use the "
6955 "<command role=\"hg-cmd\">hg remove</command> command. This deletes the file, "
6956 "and tells Mercurial to stop tracking it (which will occur at the next "
6957 "commit). A removed file is represented in the output of <command role=\"hg-"
6958 "cmd\">hg status</command> with a <quote><literal>R</literal></quote>."
6959 msgstr ""
6961 #. type: Content of: <book><chapter><sect1><para>
6962 #: ../en/ch05-daily.xml:121
6963 msgid ""
6964 "After you <command role=\"hg-cmd\">hg remove</command> a file, Mercurial will "
6965 "no longer track changes to that file, even if you recreate a file with the "
6966 "same name in your working directory. If you do recreate a file with the same "
6967 "name and want Mercurial to track the new file, simply <command role=\"hg-cmd"
6968 "\">hg add</command> it. Mercurial will know that the newly added file is not "
6969 "related to the old file of the same name."
6970 msgstr ""
6972 #. type: Content of: <book><chapter><sect1><sect2><title>
6973 #: ../en/ch05-daily.xml:130
6974 msgid "Removing a file does not affect its history"
6975 msgstr "删除文件不影响历史"
6977 #. type: Content of: <book><chapter><sect1><sect2><para>
6978 #: ../en/ch05-daily.xml:132
6979 msgid "It is important to understand that removing a file has only two effects."
6980 msgstr ""
6982 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6983 #: ../en/ch05-daily.xml:135
6984 msgid "It removes the current version of the file from the working directory."
6985 msgstr ""
6987 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6988 #: ../en/ch05-daily.xml:138
6989 msgid ""
6990 "It stops Mercurial from tracking changes to the file, from the time of the "
6991 "next commit."
6992 msgstr ""
6994 #. type: Content of: <book><chapter><sect1><sect2><para>
6995 #: ../en/ch05-daily.xml:141
6996 msgid ""
6997 "Removing a file <emphasis>does not</emphasis> in any way alter the "
6998 "<emphasis>history</emphasis> of the file."
6999 msgstr ""
7001 #. type: Content of: <book><chapter><sect1><sect2><para>
7002 #: ../en/ch05-daily.xml:144
7003 msgid ""
7004 "If you update the working directory to a changeset that was committed when it "
7005 "was still tracking a file that you later removed, the file will reappear in "
7006 "the working directory, with the contents it had when you committed that "
7007 "changeset. If you then update the working directory to a later changeset, in "
7008 "which the file had been removed, Mercurial will once again remove the file "
7009 "from the working directory."
7010 msgstr ""
7012 #. type: Content of: <book><chapter><sect1><sect2><title>
7013 #: ../en/ch05-daily.xml:155
7014 msgid "Missing files"
7015 msgstr "丢失的文件"
7017 #. type: Content of: <book><chapter><sect1><sect2><para>
7018 #: ../en/ch05-daily.xml:157
7019 msgid ""
7020 "Mercurial considers a file that you have deleted, but not used <command role="
7021 "\"hg-cmd\">hg remove</command> to delete, to be <emphasis>missing</"
7022 "emphasis>. A missing file is represented with <quote><literal>!</literal></"
7023 "quote> in the output of <command role=\"hg-cmd\">hg status</command>. "
7024 "Mercurial commands will not generally do anything with missing files."
7025 msgstr ""
7027 #. type: Content of: <book><chapter><sect1><sect2><para>
7028 #: ../en/ch05-daily.xml:167
7029 msgid ""
7030 "If your repository contains a file that <command role=\"hg-cmd\">hg status</"
7031 "command> reports as missing, and you want the file to stay gone, you can run "
7032 "<command role=\"hg-cmd\">hg remove <option role=\"hg-opt-remove\">--after</"
7033 "option></command> at any time later on, to tell Mercurial that you really did "
7034 "mean to remove the file."
7035 msgstr ""
7037 #. type: Content of: <book><chapter><sect1><sect2><para>
7038 #: ../en/ch05-daily.xml:177
7039 msgid ""
7040 "On the other hand, if you deleted the missing file by accident, give <command "
7041 "role=\"hg-cmd\">hg revert</command> the name of the file to recover. It will "
7042 "reappear, in unmodified form."
7043 msgstr ""
7045 #. type: Content of: <book><chapter><sect1><sect2><title>
7046 #: ../en/ch05-daily.xml:186
7047 msgid "Aside: why tell Mercurial explicitly to remove a file?"
7048 msgstr "旁白: 为什么要明确告诉 Mercurial 删除文件?"
7050 #. type: Content of: <book><chapter><sect1><sect2><para>
7051 #: ../en/ch05-daily.xml:189
7052 msgid ""
7053 "You might wonder why Mercurial requires you to explicitly tell it that you "
7054 "are deleting a file. Early during the development of Mercurial, it let you "
7055 "delete a file however you pleased; Mercurial would notice the absence of the "
7056 "file automatically when you next ran a <command role=\"hg-cmd\">hg commit</"
7057 "command>, and stop tracking the file. In practice, this made it too easy to "
7058 "accidentally remove a file without noticing."
7059 msgstr ""
7061 #. type: Content of: <book><chapter><sect1><sect2><title>
7062 #: ../en/ch05-daily.xml:200
7063 msgid "Useful shorthand&emdash;adding and removing files in one step"
7064 msgstr "有用的速记—一个步骤添加和删除文件"
7066 #. type: Content of: <book><chapter><sect1><sect2><para>
7067 #: ../en/ch05-daily.xml:203
7068 msgid ""
7069 "Mercurial offers a combination command, <command role=\"hg-cmd\">hg "
7070 "addremove</command>, that adds untracked files and marks missing files as "
7071 "removed."
7072 msgstr ""
7074 #. type: Content of: <book><chapter><sect1><sect2><para>
7075 #: ../en/ch05-daily.xml:209
7076 msgid ""
7077 "The <command role=\"hg-cmd\">hg commit</command> command also provides a "
7078 "<option role=\"hg-opt-commit\">-A</option> option that performs this same add-"
7079 "and-remove, immediately followed by a commit."
7080 msgstr ""
7082 #. type: Content of: <book><chapter><sect1><title>
7083 #: ../en/ch05-daily.xml:219
7084 msgid "Copying files"
7085 msgstr "复制文件"
7087 #. type: Content of: <book><chapter><sect1><para>
7088 #: ../en/ch05-daily.xml:221
7089 msgid ""
7090 "Mercurial provides a <command role=\"hg-cmd\">hg copy</command> command that "
7091 "lets you make a new copy of a file. When you copy a file using this command, "
7092 "Mercurial makes a record of the fact that the new file is a copy of the "
7093 "original file. It treats these copied files specially when you merge your "
7094 "work with someone else's."
7095 msgstr ""
7097 #. type: Content of: <book><chapter><sect1><sect2><title>
7098 #: ../en/ch05-daily.xml:229
7099 msgid "The results of copying during a merge"
7100 msgstr "合并期间的复制结果"
7102 #. type: Content of: <book><chapter><sect1><sect2><para>
7103 #: ../en/ch05-daily.xml:231
7104 msgid ""
7105 "What happens during a merge is that changes <quote>follow</quote> a copy. To "
7106 "best illustrate what this means, let's create an example. We'll start with "
7107 "the usual tiny repository that contains a single file."
7108 msgstr ""
7110 #. type: Content of: <book><chapter><sect1><sect2><para>
7111 #: ../en/ch05-daily.xml:238
7112 msgid ""
7113 "We need to do some work in parallel, so that we'll have something to merge. "
7114 "So let's clone our repository."
7115 msgstr ""
7117 #. type: Content of: <book><chapter><sect1><sect2><para>
7118 #: ../en/ch05-daily.xml:244
7119 msgid ""
7120 "Back in our initial repository, let's use the <command role=\"hg-cmd\">hg "
7121 "copy</command> command to make a copy of the first file we created."
7122 msgstr ""
7124 #. type: Content of: <book><chapter><sect1><sect2><para>
7125 #: ../en/ch05-daily.xml:250
7126 msgid ""
7127 "If we look at the output of the <command role=\"hg-cmd\">hg status</command> "
7128 "command afterwards, the copied file looks just like a normal added file."
7129 msgstr ""
7131 #. type: Content of: <book><chapter><sect1><sect2><para>
7132 #: ../en/ch05-daily.xml:256
7133 msgid ""
7134 "But if we pass the <option role=\"hg-opt-status\">-C</option> option to "
7135 "<command role=\"hg-cmd\">hg status</command>, it prints another line of "
7136 "output: this is the file that our newly-added file was copied <emphasis>from</"
7137 "emphasis>."
7138 msgstr ""
7140 #. type: Content of: <book><chapter><sect1><sect2><para>
7141 #: ../en/ch05-daily.xml:264
7142 msgid ""
7143 "Now, back in the repository we cloned, let's make a change in parallel. "
7144 "We'll add a line of content to the original file that we created."
7145 msgstr ""
7147 #. type: Content of: <book><chapter><sect1><sect2><para>
7148 #: ../en/ch05-daily.xml:270
7149 msgid ""
7150 "Now we have a modified <filename>file</filename> in this repository. When we "
7151 "pull the changes from the first repository, and merge the two heads, "
7152 "Mercurial will propagate the changes that we made locally to <filename>file</"
7153 "filename> into its copy, <filename>new-file</filename>."
7154 msgstr ""
7156 #. type: Content of: <book><chapter><sect1><sect2><title>
7157 #: ../en/ch05-daily.xml:280
7158 msgid "Why should changes follow copies?"
7159 msgstr "为什么复制后需要后续修改?"
7161 #. type: Content of: <book><chapter><sect1><sect2><para>
7162 #: ../en/ch05-daily.xml:282
7163 msgid ""
7164 "This behavior&emdash;of changes to a file propagating out to copies of the "
7165 "file&emdash;might seem esoteric, but in most cases it's highly desirable."
7166 msgstr ""
7168 #. type: Content of: <book><chapter><sect1><sect2><para>
7169 #: ../en/ch05-daily.xml:286
7170 msgid ""
7171 "First of all, remember that this propagation <emphasis>only</emphasis> "
7172 "happens when you merge. So if you <command role=\"hg-cmd\">hg copy</command> "
7173 "a file, and subsequently modify the original file during the normal course of "
7174 "your work, nothing will happen."
7175 msgstr ""
7177 #. type: Content of: <book><chapter><sect1><sect2><para>
7178 #: ../en/ch05-daily.xml:292
7179 msgid ""
7180 "The second thing to know is that modifications will only propagate across a "
7181 "copy as long as the changeset that you're merging changes from "
7182 "<emphasis>hasn't yet seen</emphasis> the copy."
7183 msgstr ""
7185 #. type: Content of: <book><chapter><sect1><sect2><para>
7186 #: ../en/ch05-daily.xml:297
7187 msgid ""
7188 "The reason that Mercurial does this is as follows. Let's say I make an "
7189 "important bug fix in a source file, and commit my changes. Meanwhile, you've "
7190 "decided to <command role=\"hg-cmd\">hg copy</command> the file in your "
7191 "repository, without knowing about the bug or having seen the fix, and you "
7192 "have started hacking on your copy of the file."
7193 msgstr ""
7195 #. type: Content of: <book><chapter><sect1><sect2><para>
7196 #: ../en/ch05-daily.xml:304
7197 msgid ""
7198 "If you pulled and merged my changes, and Mercurial <emphasis>didn't</"
7199 "emphasis> propagate changes across copies, your new source file would now "
7200 "contain the bug, and unless you knew to propagate the bug fix by hand, the "
7201 "bug would <emphasis>remain</emphasis> in your copy of the file."
7202 msgstr ""
7204 #. type: Content of: <book><chapter><sect1><sect2><para>
7205 #: ../en/ch05-daily.xml:310
7206 msgid ""
7207 "By automatically propagating the change that fixed the bug from the original "
7208 "file to the copy, Mercurial prevents this class of problem. To my knowledge, "
7209 "Mercurial is the <emphasis>only</emphasis> revision control system that "
7210 "propagates changes across copies like this."
7211 msgstr ""
7213 #. type: Content of: <book><chapter><sect1><sect2><para>
7214 #: ../en/ch05-daily.xml:316
7215 msgid ""
7216 "Once your change history has a record that the copy and subsequent merge "
7217 "occurred, there's usually no further need to propagate changes from the "
7218 "original file to the copied file, and that's why Mercurial only propagates "
7219 "changes across copies at the first merge, and not afterwards."
7220 msgstr ""
7222 #. type: Content of: <book><chapter><sect1><sect2><title>
7223 #: ../en/ch05-daily.xml:324
7224 msgid "How to make changes <emphasis>not</emphasis> follow a copy"
7225 msgstr "如何让复制后<emphasis>不</emphasis>修改?"
7227 #. type: Content of: <book><chapter><sect1><sect2><para>
7228 #: ../en/ch05-daily.xml:327
7229 msgid ""
7230 "If, for some reason, you decide that this business of automatically "
7231 "propagating changes across copies is not for you, simply use your system's "
7232 "normal file copy command (on Unix-like systems, that's <command>cp</command>) "
7233 "to make a copy of a file, then <command role=\"hg-cmd\">hg add</command> the "
7234 "new copy by hand. Before you do so, though, please do reread <xref linkend="
7235 "\"sec:daily:why-copy\"/>, and make an informed decision that this behavior is "
7236 "not appropriate to your specific case."
7237 msgstr ""
7239 #. type: Content of: <book><chapter><sect1><sect2><title>
7240 #: ../en/ch05-daily.xml:340
7241 msgid "Behavior of the <command role=\"hg-cmd\">hg copy</command> command"
7242 msgstr "命令 <command role=\"hg-cmd\">hg copy</command> 的特性"
7244 #. type: Content of: <book><chapter><sect1><sect2><para>
7245 #: ../en/ch05-daily.xml:343
7246 msgid ""
7247 "When you use the <command role=\"hg-cmd\">hg copy</command> command, "
7248 "Mercurial makes a copy of each source file as it currently stands in the "
7249 "working directory. This means that if you make some modifications to a file, "
7250 "then <command role=\"hg-cmd\">hg copy</command> it without first having "
7251 "committed those changes, the new copy will also contain the modifications you "
7252 "have made up until that point. (I find this behavior a little "
7253 "counterintuitive, which is why I mention it here.)"
7254 msgstr ""
7256 #. type: Content of: <book><chapter><sect1><sect2><para>
7257 #: ../en/ch05-daily.xml:353
7258 msgid ""
7259 "The <command role=\"hg-cmd\">hg copy</command> command acts similarly to the "
7260 "Unix <command>cp</command> command (you can use the <command role=\"hg-cmd"
7261 "\">hg cp</command> alias if you prefer). We must supply two or more "
7262 "arguments, of which the last is treated as the <emphasis>destination</"
7263 "emphasis>, and all others are <emphasis>sources</emphasis>."
7264 msgstr ""
7266 #. type: Content of: <book><chapter><sect1><sect2><para>
7267 #: ../en/ch05-daily.xml:361
7268 msgid ""
7269 "If you pass <command role=\"hg-cmd\">hg copy</command> a single file as the "
7270 "source, and the destination does not exist, it creates a new file with that "
7271 "name."
7272 msgstr ""
7274 #. type: Content of: <book><chapter><sect1><sect2><para>
7275 #: ../en/ch05-daily.xml:367
7276 msgid ""
7277 "If the destination is a directory, Mercurial copies its sources into that "
7278 "directory."
7279 msgstr ""
7281 #. type: Content of: <book><chapter><sect1><sect2><para>
7282 #: ../en/ch05-daily.xml:372
7283 msgid ""
7284 "Copying a directory is recursive, and preserves the directory structure of "
7285 "the source."
7286 msgstr ""
7288 #. type: Content of: <book><chapter><sect1><sect2><para>
7289 #: ../en/ch05-daily.xml:378
7290 msgid ""
7291 "If the source and destination are both directories, the source tree is "
7292 "recreated in the destination directory."
7293 msgstr ""
7295 #. type: Content of: <book><chapter><sect1><sect2><para>
7296 #: ../en/ch05-daily.xml:383
7297 msgid ""
7298 "As with the <command role=\"hg-cmd\">hg remove</command> command, if you copy "
7299 "a file manually and then want Mercurial to know that you've copied the file, "
7300 "simply use the <option role=\"hg-opt-copy\">--after</option> option to "
7301 "<command role=\"hg-cmd\">hg copy</command>."
7302 msgstr ""
7304 #. type: Content of: <book><chapter><sect1><title>
7305 #: ../en/ch05-daily.xml:394
7306 msgid "Renaming files"
7307 msgstr "改名文件"
7309 #. type: Content of: <book><chapter><sect1><para>
7310 #: ../en/ch05-daily.xml:396
7311 msgid ""
7312 "It's rather more common to need to rename a file than to make a copy of it. "
7313 "The reason I discussed the <command role=\"hg-cmd\">hg copy</command> command "
7314 "before talking about renaming files is that Mercurial treats a rename in "
7315 "essentially the same way as a copy. Therefore, knowing what Mercurial does "
7316 "when you copy a file tells you what to expect when you rename a file."
7317 msgstr ""
7319 #. type: Content of: <book><chapter><sect1><para>
7320 #: ../en/ch05-daily.xml:404
7321 msgid ""
7322 "When you use the <command role=\"hg-cmd\">hg rename</command> command, "
7323 "Mercurial makes a copy of each source file, then deletes it and marks the "
7324 "file as removed."
7325 msgstr ""
7327 #. type: Content of: <book><chapter><sect1><para>
7328 #: ../en/ch05-daily.xml:410
7329 msgid ""
7330 "The <command role=\"hg-cmd\">hg status</command> command shows the newly "
7331 "copied file as added, and the copied-from file as removed."
7332 msgstr ""
7334 #. type: Content of: <book><chapter><sect1><para>
7335 #: ../en/ch05-daily.xml:416
7336 msgid ""
7337 "As with the results of a <command role=\"hg-cmd\">hg copy</command>, we must "
7338 "use the <option role=\"hg-opt-status\">-C</option> option to <command role="
7339 "\"hg-cmd\">hg status</command> to see that the added file is really being "
7340 "tracked by Mercurial as a copy of the original, now removed, file."
7341 msgstr ""
7343 #. type: Content of: <book><chapter><sect1><para>
7344 #: ../en/ch05-daily.xml:425
7345 msgid ""
7346 "As with <command role=\"hg-cmd\">hg remove</command> and <command role=\"hg-"
7347 "cmd\">hg copy</command>, you can tell Mercurial about a rename after the fact "
7348 "using the <option role=\"hg-opt-rename\">--after</option> option. In most "
7349 "other respects, the behavior of the <command role=\"hg-cmd\">hg rename</"
7350 "command> command, and the options it accepts, are similar to the <command "
7351 "role=\"hg-cmd\">hg copy</command> command."
7352 msgstr ""
7354 #. type: Content of: <book><chapter><sect1><para>
7355 #: ../en/ch05-daily.xml:434
7356 msgid ""
7357 "If you're familiar with the Unix command line, you'll be glad to know that "
7358 "<command role=\"hg-cmd\">hg rename</command> command can be invoked as "
7359 "<command role=\"hg-cmd\">hg mv</command>."
7360 msgstr ""
7362 #. type: Content of: <book><chapter><sect1><sect2><title>
7363 #: ../en/ch05-daily.xml:440
7364 msgid "Renaming files and merging changes"
7365 msgstr "改名文件与合并修改"
7367 #. type: Content of: <book><chapter><sect1><sect2><para>
7368 #: ../en/ch05-daily.xml:442
7369 msgid ""
7370 "Since Mercurial's rename is implemented as copy-and-remove, the same "
7371 "propagation of changes happens when you merge after a rename as after a copy."
7372 msgstr ""
7374 #. type: Content of: <book><chapter><sect1><sect2><para>
7375 #: ../en/ch05-daily.xml:446
7376 msgid ""
7377 "If I modify a file, and you rename it to a new name, and then we merge our "
7378 "respective changes, my modifications to the file under its original name will "
7379 "be propagated into the file under its new name. (This is something you might "
7380 "expect to <quote>simply work,</quote> but not all revision control systems "
7381 "actually do this.)"
7382 msgstr ""
7384 #. type: Content of: <book><chapter><sect1><sect2><para>
7385 #: ../en/ch05-daily.xml:453
7386 msgid ""
7387 "Whereas having changes follow a copy is a feature where you can perhaps nod "
7388 "and say <quote>yes, that might be useful,</quote> it should be clear that "
7389 "having them follow a rename is definitely important. Without this facility, "
7390 "it would simply be too easy for changes to become orphaned when files are "
7391 "renamed."
7392 msgstr ""
7394 #. type: Content of: <book><chapter><sect1><sect2><title>
7395 #: ../en/ch05-daily.xml:462
7396 msgid "Divergent renames and merging"
7397 msgstr "改名与合并的分歧"
7399 #. type: Content of: <book><chapter><sect1><sect2><para>
7400 #: ../en/ch05-daily.xml:464
7401 msgid ""
7402 "The case of diverging names occurs when two developers start with a "
7403 "file&emdash;let's call it <filename>foo</filename>&emdash;in their respective "
7404 "repositories."
7405 msgstr ""
7407 #. type: Content of: <book><chapter><sect1><sect2><para>
7408 #: ../en/ch05-daily.xml:471
7409 msgid "Anne renames the file to <filename>bar</filename>."
7410 msgstr ""
7412 #. type: Content of: <book><chapter><sect1><sect2><para>
7413 #: ../en/ch05-daily.xml:475
7414 msgid ""
7415 "Meanwhile, Bob renames it to <filename>quux</filename>. (Remember that "
7416 "<command role=\"hg-cmd\">hg mv</command> is an alias for <command role=\"hg-"
7417 "cmd\">hg rename</command>.)"
7418 msgstr ""
7420 #. type: Content of: <book><chapter><sect1><sect2><para>
7421 #: ../en/ch05-daily.xml:482
7422 msgid ""
7423 "I like to think of this as a conflict because each developer has expressed "
7424 "different intentions about what the file ought to be named."
7425 msgstr ""
7427 #. type: Content of: <book><chapter><sect1><sect2><para>
7428 #: ../en/ch05-daily.xml:486
7429 msgid ""
7430 "What do you think should happen when they merge their work? Mercurial's "
7431 "actual behavior is that it always preserves <emphasis>both</emphasis> names "
7432 "when it merges changesets that contain divergent renames."
7433 msgstr ""
7435 #. type: Content of: <book><chapter><sect1><sect2><para>
7436 #: ../en/ch05-daily.xml:493
7437 msgid ""
7438 "Notice that while Mercurial warns about the divergent renames, it leaves it "
7439 "up to you to do something about the divergence after the merge."
7440 msgstr ""
7442 #. type: Content of: <book><chapter><sect1><sect2><title>
7443 #: ../en/ch05-daily.xml:499
7444 msgid "Convergent renames and merging"
7445 msgstr "收敛改名与合并"
7447 #. type: Content of: <book><chapter><sect1><sect2><para>
7448 #: ../en/ch05-daily.xml:501
7449 msgid ""
7450 "Another kind of rename conflict occurs when two people choose to rename "
7451 "different <emphasis>source</emphasis> files to the same "
7452 "<emphasis>destination</emphasis>. In this case, Mercurial runs its normal "
7453 "merge machinery, and lets you guide it to a suitable resolution."
7454 msgstr ""
7456 #. type: Content of: <book><chapter><sect1><sect2><title>
7457 #: ../en/ch05-daily.xml:509
7458 msgid "Other name-related corner cases"
7459 msgstr "其它名称相关的角落"
7461 #. type: Content of: <book><chapter><sect1><sect2><para>
7462 #: ../en/ch05-daily.xml:511
7463 msgid ""
7464 "Mercurial has a longstanding bug in which it fails to handle a merge where "
7465 "one side has a file with a given name, while another has a directory with the "
7466 "same name. This is documented as <ulink role=\"hg-bug\" url=\"http://www."
7467 "selenic.com/mercurial/bts/issue29\">issue 29</ulink>."
7468 msgstr ""
7470 #. type: Content of: <book><chapter><sect1><title>
7471 #: ../en/ch05-daily.xml:524
7472 msgid "Recovering from mistakes"
7473 msgstr "从错误恢复"
7475 #. type: Content of: <book><chapter><sect1><para>
7476 #: ../en/ch05-daily.xml:526
7477 msgid ""
7478 "Mercurial has some useful commands that will help you to recover from some "
7479 "common mistakes."
7480 msgstr ""
7482 #. type: Content of: <book><chapter><sect1><para>
7483 #: ../en/ch05-daily.xml:529
7484 msgid ""
7485 "The <command role=\"hg-cmd\">hg revert</command> command lets you undo "
7486 "changes that you have made to your working directory. For example, if you "
7487 "<command role=\"hg-cmd\">hg add</command> a file by accident, just run "
7488 "<command role=\"hg-cmd\">hg revert</command> with the name of the file you "
7489 "added, and while the file won't be touched in any way, it won't be tracked "
7490 "for adding by Mercurial any longer, either. You can also use <command role="
7491 "\"hg-cmd\">hg revert</command> to get rid of erroneous changes to a file."
7492 msgstr ""
7494 #. type: Content of: <book><chapter><sect1><para>
7495 #: ../en/ch05-daily.xml:539
7496 msgid ""
7497 "It is helpful to remember that the <command role=\"hg-cmd\">hg revert</"
7498 "command> command is useful for changes that you have not yet committed. Once "
7499 "you've committed a change, if you decide it was a mistake, you can still do "
7500 "something about it, though your options may be more limited."
7501 msgstr ""
7503 #. type: Content of: <book><chapter><sect1><para>
7504 #: ../en/ch05-daily.xml:546
7505 msgid ""
7506 "For more information about the <command role=\"hg-cmd\">hg revert</command> "
7507 "command, and details about how to deal with changes you have already "
7508 "committed, see <xref linkend=\"chap:undo\"/>."
7509 msgstr ""
7511 #. type: Content of: <book><chapter><sect1><title>
7512 #: ../en/ch05-daily.xml:553
7513 msgid "Dealing with tricky merges"
7514 msgstr "合并的技巧"
7516 #. type: Content of: <book><chapter><sect1><para>
7517 #: ../en/ch05-daily.xml:555
7518 msgid ""
7519 "In a complicated or large project, it's not unusual for a merge of two "
7520 "changesets to result in some headaches. Suppose there's a big source file "
7521 "that's been extensively edited by each side of a merge: this is almost "
7522 "inevitably going to result in conflicts, some of which can take a few tries "
7523 "to sort out."
7524 msgstr ""
7526 #. type: Content of: <book><chapter><sect1><para>
7527 #: ../en/ch05-daily.xml:562
7528 msgid ""
7529 "Let's develop a simple case of this and see how to deal with it. We'll start "
7530 "off with a repository containing one file, and clone it twice."
7531 msgstr ""
7533 #. type: Content of: <book><chapter><sect1><para>
7534 #: ../en/ch05-daily.xml:568
7535 msgid "In one clone, we'll modify the file in one way."
7536 msgstr ""
7538 #. type: Content of: <book><chapter><sect1><para>
7539 #: ../en/ch05-daily.xml:572
7540 msgid "In another, we'll modify the file differently."
7541 msgstr ""
7543 #. type: Content of: <book><chapter><sect1><para>
7544 #: ../en/ch05-daily.xml:576
7545 msgid "Next, we'll pull each set of changes into our original repo."
7546 msgstr ""
7548 #. type: Content of: <book><chapter><sect1><para>
7549 #: ../en/ch05-daily.xml:581
7550 msgid "We expect our repository to now contain two heads."
7551 msgstr ""
7553 #. type: Content of: <book><chapter><sect1><para>
7554 #: ../en/ch05-daily.xml:585
7555 msgid ""
7556 "Normally, if we run <command role=\"hg-cmd\">hg merge</command> at this "
7557 "point, it will drop us into a GUI that will let us manually resolve the "
7558 "conflicting edits to <filename>myfile.txt</filename>. However, to simplify "
7559 "things for presentation here, we'd like the merge to fail immediately "
7560 "instead. Here's one way we can do so."
7561 msgstr ""
7563 #. type: Content of: <book><chapter><sect1><para>
7564 #: ../en/ch05-daily.xml:594
7565 msgid ""
7566 "We've told Mercurial's merge machinery to run the command <command>false</"
7567 "command> (which, as we desire, fails immediately) if it detects a merge that "
7568 "it can't sort out automatically."
7569 msgstr ""
7571 #. type: Content of: <book><chapter><sect1><para>
7572 #: ../en/ch05-daily.xml:599
7573 msgid ""
7574 "If we now fire up <command role=\"hg-cmd\">hg merge</command>, it should "
7575 "grind to a halt and report a failure."
7576 msgstr ""
7578 #. type: Content of: <book><chapter><sect1><para>
7579 #: ../en/ch05-daily.xml:605
7580 msgid ""
7581 "Even if we don't notice that the merge failed, Mercurial will prevent us from "
7582 "accidentally committing the result of a failed merge."
7583 msgstr ""
7585 #. type: Content of: <book><chapter><sect1><para>
7586 #: ../en/ch05-daily.xml:611
7587 msgid ""
7588 "When <command role=\"hg-cmd\">hg commit</command> fails in this case, it "
7589 "suggests that we use the unfamiliar <command role=\"hg-cmd\">hg resolve</"
7590 "command> command. As usual, <command role=\"hg-cmd\">hg help resolve</"
7591 "command> will print a helpful synopsis."
7592 msgstr ""
7594 #. type: Content of: <book><chapter><sect1><sect2><title>
7595 #: ../en/ch05-daily.xml:618
7596 msgid "File resolution states"
7597 msgstr "文件的解决状态"
7599 #. type: Content of: <book><chapter><sect1><sect2><para>
7600 #: ../en/ch05-daily.xml:620
7601 msgid ""
7602 "When a merge occurs, most files will usually remain unmodified. For each "
7603 "file where Mercurial has to do something, it tracks the state of the file."
7604 msgstr ""
7606 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
7607 #: ../en/ch05-daily.xml:626
7608 msgid ""
7609 "A <emphasis>resolved</emphasis> file has been successfully merged, either "
7610 "automatically by Mercurial or manually with human intervention."
7611 msgstr ""
7613 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
7614 #: ../en/ch05-daily.xml:631
7615 msgid ""
7616 "An <emphasis>unresolved</emphasis> file was not merged successfully, and "
7617 "needs more attention."
7618 msgstr ""
7620 #. type: Content of: <book><chapter><sect1><sect2><para>
7621 #: ../en/ch05-daily.xml:636
7622 msgid ""
7623 "If Mercurial sees <emphasis>any</emphasis> file in the unresolved state after "
7624 "a merge, it considers the merge to have failed. Fortunately, we do not need "
7625 "to restart the entire merge from scratch."
7626 msgstr ""
7628 #. type: Content of: <book><chapter><sect1><sect2><para>
7629 #: ../en/ch05-daily.xml:641
7630 msgid ""
7631 "The <option role=\"hg-opt-resolve\">--list</option> or <option role=\"hg-opt-"
7632 "resolve\">-l</option> option to <command role=\"hg-cmd\">hg resolve</command> "
7633 "prints out the state of each merged file."
7634 msgstr ""
7636 #. type: Content of: <book><chapter><sect1><sect2><para>
7637 #: ../en/ch05-daily.xml:648
7638 msgid ""
7639 "In the output from <command role=\"hg-cmd\">hg resolve</command>, a resolved "
7640 "file is marked with <literal>R</literal>, while an unresolved file is marked "
7641 "with <literal>U</literal>. If any files are listed with <literal>U</"
7642 "literal>, we know that an attempt to commit the results of the merge will "
7643 "fail."
7644 msgstr ""
7646 #. type: Content of: <book><chapter><sect1><sect2><title>
7647 #: ../en/ch05-daily.xml:657
7648 msgid "Resolving a file merge"
7649 msgstr "合并文件"
7651 #. type: Content of: <book><chapter><sect1><sect2><para>
7652 #: ../en/ch05-daily.xml:659
7653 msgid ""
7654 "We have several options to move a file from the unresolved into the resolved "
7655 "state. By far the most common is to rerun <command role=\"hg-cmd\">hg "
7656 "resolve</command>. If we pass the names of individual files or directories, "
7657 "it will retry the merges of any unresolved files present in those locations. "
7658 "We can also pass the <option role=\"hg-opt-resolve\">--all</option> or "
7659 "<option role=\"hg-opt-resolve\">-a</option> option, which will retry the "
7660 "merges of <emphasis>all</emphasis> unresolved files."
7661 msgstr ""
7663 #. type: Content of: <book><chapter><sect1><sect2><para>
7664 #: ../en/ch05-daily.xml:669
7665 msgid ""
7666 "Mercurial also lets us modify the resolution state of a file directly. We "
7667 "can manually mark a file as resolved using the <option role=\"hg-opt-resolve"
7668 "\">--mark</option> option, or as unresolved using the <option role=\"hg-opt-"
7669 "resolve\">--unmark</option> option. This allows us to clean up a "
7670 "particularly messy merge by hand, and to keep track of our progress with each "
7671 "file as we go."
7672 msgstr ""
7674 #. type: Content of: <book><chapter><sect1><title>
7675 #: ../en/ch05-daily.xml:680
7676 msgid "More useful diffs"
7677 msgstr "更有用的差异"
7679 #. type: Content of: <book><chapter><sect1><para>
7680 #: ../en/ch05-daily.xml:682
7681 msgid ""
7682 "The default output of the <command role=\"hg-cmd\">hg diff</command> command "
7683 "is backwards compatible with the regular <command>diff</command> command, but "
7684 "this has some drawbacks."
7685 msgstr ""
7687 #. type: Content of: <book><chapter><sect1><para>
7688 #: ../en/ch05-daily.xml:687
7689 msgid ""
7690 "Consider the case where we use <command role=\"hg-cmd\">hg rename</command> "
7691 "to rename a file."
7692 msgstr ""
7693 "设想我们使用 <command role=\"hg-cmd\">hg rename</command> 命令来改名文件。"
7695 #. type: Content of: <book><chapter><sect1><para>
7696 #: ../en/ch05-daily.xml:692
7697 msgid ""
7698 "The output of <command role=\"hg-cmd\">hg diff</command> above obscures the "
7699 "fact that we simply renamed a file. The <command role=\"hg-cmd\">hg diff</"
7700 "command> command accepts an option, <option>--git</option> or <option>-g</"
7701 "option>, to use a newer diff format that displays such information in a more "
7702 "readable form."
7703 msgstr ""
7705 #. type: Content of: <book><chapter><sect1><para>
7706 #: ../en/ch05-daily.xml:701
7707 msgid ""
7708 "This option also helps with a case that can otherwise be confusing: a file "
7709 "that appears to be modified according to <command role=\"hg-cmd\">hg status</"
7710 "command>, but for which <command role=\"hg-cmd\">hg diff</command> prints "
7711 "nothing. This situation can arise if we change the file's execute permissions."
7712 msgstr ""
7714 #. type: Content of: <book><chapter><sect1><para>
7715 #: ../en/ch05-daily.xml:710
7716 msgid ""
7717 "The normal <command>diff</command> command pays no attention to file "
7718 "permissions, which is why <command role=\"hg-cmd\">hg diff</command> prints "
7719 "nothing by default. If we supply it with the <option>-g</option> option, it "
7720 "tells us what really happened."
7721 msgstr ""
7723 #. type: Content of: <book><chapter><sect1><title>
7724 #: ../en/ch05-daily.xml:720
7725 msgid "Which files to manage, and which to avoid"
7726 msgstr "需要管理哪些文件,应该避免的事情"
7728 #. type: Content of: <book><chapter><sect1><para>
7729 #: ../en/ch05-daily.xml:722
7730 msgid ""
7731 "Revision control systems are generally best at managing text files that are "
7732 "written by humans, such as source code, where the files do not change much "
7733 "from one revision to the next. Some centralized revision control systems can "
7734 "also deal tolerably well with binary files, such as bitmap images."
7735 msgstr ""
7737 #. type: Content of: <book><chapter><sect1><para>
7738 #: ../en/ch05-daily.xml:728
7739 msgid ""
7740 "For instance, a game development team will typically manage both its source "
7741 "code and all of its binary assets (e.g. geometry data, textures, map layouts) "
7742 "in a revision control system."
7743 msgstr ""
7745 #. type: Content of: <book><chapter><sect1><para>
7746 #: ../en/ch05-daily.xml:733
7747 msgid ""
7748 "Because it is usually impossible to merge two conflicting modifications to a "
7749 "binary file, centralized systems often provide a file locking mechanism that "
7750 "allow a user to say <quote>I am the only person who can edit this file</"
7751 "quote>."
7752 msgstr ""
7754 #. type: Content of: <book><chapter><sect1><para>
7755 #: ../en/ch05-daily.xml:739
7756 msgid ""
7757 "Compared to a centralized system, a distributed revision control system "
7758 "changes some of the factors that guide decisions over which files to manage "
7759 "and how."
7760 msgstr ""
7762 #. type: Content of: <book><chapter><sect1><para>
7763 #: ../en/ch05-daily.xml:743
7764 msgid ""
7765 "For instance, a distributed revision control system cannot, by its nature, "
7766 "offer a file locking facility. There is thus no built-in mechanism to "
7767 "prevent two people from making conflicting changes to a binary file. If you "
7768 "have a team where several people may be editing binary files frequently, it "
7769 "may not be a good idea to use Mercurial&emdash;or any other distributed "
7770 "revision control system&emdash;to manage those files."
7771 msgstr ""
7773 #. type: Content of: <book><chapter><sect1><para>
7774 #: ../en/ch05-daily.xml:751
7775 msgid ""
7776 "When storing modifications to a file, Mercurial usually saves only the "
7777 "differences between the previous and current versions of the file. For most "
7778 "text files, this is extremely efficient. However, some files (particularly "
7779 "binary files) are laid out in such a way that even a small change to a file's "
7780 "logical content results in many or most of the bytes inside the file "
7781 "changing. For instance, compressed files are particularly susceptible to "
7782 "this. If the differences between each successive version of a file are always "
7783 "large, Mercurial will not be able to store the file's revision history very "
7784 "efficiently. This can affect both local storage needs and the amount of time "
7785 "it takes to clone a repository."
7786 msgstr ""
7788 #. type: Content of: <book><chapter><sect1><para>
7789 #: ../en/ch05-daily.xml:764
7790 msgid ""
7791 "To get an idea of how this could affect you in practice, suppose you want to "
7792 "use Mercurial to manage an OpenOffice document. OpenOffice stores documents "
7793 "on disk as compressed zip files. Edit even a single letter of your document "
7794 "in OpenOffice, and almost every byte in the entire file will change when you "
7795 "save it. Now suppose that file is 2MB in size. Because most of the file "
7796 "changes every time you save, Mercurial will have to store all 2MB of the file "
7797 "every time you commit, even though from your perspective, perhaps only a few "
7798 "words are changing each time. A single frequently-edited file that is not "
7799 "friendly to Mercurial's storage assumptions can easily have an outsized "
7800 "effect on the size of the repository."
7801 msgstr ""
7803 #. type: Content of: <book><chapter><sect1><para>
7804 #: ../en/ch05-daily.xml:777
7805 msgid ""
7806 "Even worse, if both you and someone else edit the OpenOffice document you're "
7807 "working on, there is no useful way to merge your work. In fact, there isn't "
7808 "even a good way to tell what the differences are between your respective "
7809 "changes."
7810 msgstr ""
7812 #. type: Content of: <book><chapter><sect1><para>
7813 #: ../en/ch05-daily.xml:782
7814 msgid ""
7815 "There are thus a few clear recommendations about specific kinds of files to "
7816 "be very careful with."
7817 msgstr ""
7819 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
7820 #: ../en/ch05-daily.xml:787
7821 msgid ""
7822 "Files that are very large and incompressible, e.g. ISO CD-ROM images, will by "
7823 "virtue of sheer size make clones over a network very slow."
7824 msgstr ""
7826 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
7827 #: ../en/ch05-daily.xml:792
7828 msgid ""
7829 "Files that change a lot from one revision to the next may be expensive to "
7830 "store if you edit them frequently, and conflicts due to concurrent edits may "
7831 "be difficult to resolve."
7832 msgstr ""
7834 #. type: Content of: <book><chapter><sect1><title>
7835 #: ../en/ch05-daily.xml:801
7836 msgid "Backups and mirroring"
7837 msgstr "备份与镜像"
7839 #. type: Content of: <book><chapter><sect1><para>
7840 #: ../en/ch05-daily.xml:803
7841 msgid ""
7842 "Since Mercurial maintains a complete copy of history in each clone, everyone "
7843 "who uses Mercurial to collaborate on a project can potentially act as a "
7844 "source of backups in the event of a catastrophe. If a central repository "
7845 "becomes unavailable, you can construct a replacement simply by cloning a copy "
7846 "of the repository from one contributor, and pulling any changes they may not "
7847 "have seen from others."
7848 msgstr ""
7850 #. type: Content of: <book><chapter><sect1><para>
7851 #: ../en/ch05-daily.xml:811
7852 msgid ""
7853 "It is simple to use Mercurial to perform off-site backups and remote "
7854 "mirrors. Set up a periodic job (e.g. via the <command>cron</command> "
7855 "command) on a remote server to pull changes from your master repositories "
7856 "every hour. This will only be tricky in the unlikely case that the number of "
7857 "master repositories you maintain changes frequently, in which case you'll "
7858 "need to do a little scripting to refresh the list of repositories to back up."
7859 msgstr ""
7861 #. type: Content of: <book><chapter><sect1><para>
7862 #: ../en/ch05-daily.xml:820
7863 msgid ""
7864 "If you perform traditional backups of your master repositories to tape or "
7865 "disk, and you want to back up a repository named <filename>myrepo</filename>, "
7866 "use <command>hg clone -U myrepo myrepo.bak</command> to create a clone of "
7867 "<filename>myrepo</filename> before you start your backups. The <option>-U</"
7868 "option> option doesn't check out a working directory after the clone "
7869 "completes, since that would be superfluous and make the backup take longer."
7870 msgstr ""
7872 #. type: Content of: <book><chapter><sect1><para>
7873 #: ../en/ch05-daily.xml:829
7874 msgid ""
7875 "If you then back up <filename>myrepo.bak</filename> instead of "
7876 "<filename>myrepo</filename>, you will be guaranteed to have a consistent "
7877 "snapshot of your repository that won't be pushed to by an insomniac developer "
7878 "in mid-backup."
7879 msgstr ""
7881 #. type: Content of: <book><chapter><title>
7882 #: ../en/ch06-collab.xml:5
7883 msgid "Collaborating with other people"
7884 msgstr "团体协作"
7886 #. type: Content of: <book><chapter><para>
7887 #: ../en/ch06-collab.xml:7
7888 msgid ""
7889 "As a completely decentralised tool, Mercurial doesn't impose any policy on "
7890 "how people ought to work with each other. However, if you're new to "
7891 "distributed revision control, it helps to have some tools and examples in "
7892 "mind when you're thinking about possible workflow models."
7893 msgstr ""
7895 #. type: Content of: <book><chapter><sect1><title>
7896 #: ../en/ch06-collab.xml:14
7897 msgid "Mercurial's web interface"
7898 msgstr "Mercurial 的 web 接口"
7900 #. type: Content of: <book><chapter><sect1><para>
7901 #: ../en/ch06-collab.xml:16
7902 msgid ""
7903 "Mercurial has a powerful web interface that provides several useful "
7904 "capabilities."
7905 msgstr ""
7907 #. type: Content of: <book><chapter><sect1><para>
7908 #: ../en/ch06-collab.xml:19
7909 msgid ""
7910 "For interactive use, the web interface lets you browse a single repository or "
7911 "a collection of repositories. You can view the history of a repository, "
7912 "examine each change (comments and diffs), and view the contents of each "
7913 "directory and file. You can even get a view of history that gives a "
7914 "graphical view of the relationships between individual changes and merges."
7915 msgstr ""
7917 #. type: Content of: <book><chapter><sect1><para>
7918 #: ../en/ch06-collab.xml:26
7919 msgid ""
7920 "Also for human consumption, the web interface provides Atom and RSS feeds of "
7921 "the changes in a repository. This lets you <quote>subscribe</quote> to a "
7922 "repository using your favorite feed reader, and be automatically notified of "
7923 "activity in that repository as soon as it happens. I find this capability "
7924 "much more convenient than the model of subscribing to a mailing list to which "
7925 "notifications are sent, as it requires no additional configuration on the "
7926 "part of whoever is serving the repository."
7927 msgstr ""
7929 #. type: Content of: <book><chapter><sect1><para>
7930 #: ../en/ch06-collab.xml:36
7931 msgid ""
7932 "The web interface also lets remote users clone a repository, pull changes "
7933 "from it, and (when the server is configured to permit it) push changes back "
7934 "to it. Mercurial's HTTP tunneling protocol aggressively compresses data, so "
7935 "that it works efficiently even over low-bandwidth network connections."
7936 msgstr ""
7938 #. type: Content of: <book><chapter><sect1><para>
7939 #: ../en/ch06-collab.xml:42
7940 msgid ""
7941 "The easiest way to get started with the web interface is to use your web "
7942 "browser to visit an existing repository, such as the master Mercurial "
7943 "repository at <ulink url=\"http://www.selenic.com/repo/hg\">http://www."
7944 "selenic.com/repo/hg</ulink>."
7945 msgstr ""
7947 #. type: Content of: <book><chapter><sect1><para>
7948 #: ../en/ch06-collab.xml:47
7949 msgid ""
7950 "If you're interested in providing a web interface to your own repositories, "
7951 "there are several good ways to do this."
7952 msgstr ""
7954 #. type: Content of: <book><chapter><sect1><para>
7955 #: ../en/ch06-collab.xml:51
7956 msgid ""
7957 "The easiest and fastest way to get started in an informal environment is to "
7958 "use the <command role=\"hg-cmd\">hg serve</command> command, which is best "
7959 "suited to short-term <quote>lightweight</quote> serving. See <xref linkend="
7960 "\"sec:collab:serve\"/> below for details of how to use this command."
7961 msgstr ""
7963 #. type: Content of: <book><chapter><sect1><para>
7964 #: ../en/ch06-collab.xml:58
7965 msgid ""
7966 "For longer-lived repositories that you'd like to have permanently available, "
7967 "there are several public hosting services available. Some are free to open "
7968 "source projects, while others offer paid commercial hosting. An up-to-date "
7969 "list is available at <ulink url=\"http://www.selenic.com/mercurial/wiki/index."
7970 "cgi/MercurialHosting\">http://www.selenic.com/mercurial/wiki/index.cgi/"
7971 "MercurialHosting</ulink>."
7972 msgstr ""
7974 #. type: Content of: <book><chapter><sect1><para>
7975 #: ../en/ch06-collab.xml:65
7976 msgid ""
7977 "If you would prefer to host your own repositories, Mercurial has built-in "
7978 "support for several popular hosting technologies, most notably CGI (Common "
7979 "Gateway Interface), and WSGI (Web Services Gateway Interface). See <xref "
7980 "linkend=\"sec:collab:cgi\"/> for details of CGI and WSGI configuration."
7981 msgstr ""
7983 #. type: Content of: <book><chapter><sect1><title>
7984 #: ../en/ch06-collab.xml:74
7985 msgid "Collaboration models"
7986 msgstr "协作模型"
7988 #. type: Content of: <book><chapter><sect1><para>
7989 #: ../en/ch06-collab.xml:76
7990 msgid ""
7991 "With a suitably flexible tool, making decisions about workflow is much more "
7992 "of a social engineering challenge than a technical one. Mercurial imposes few "
7993 "limitations on how you can structure the flow of work in a project, so it's "
7994 "up to you and your group to set up and live with a model that matches your "
7995 "own particular needs."
7996 msgstr ""
7998 #. type: Content of: <book><chapter><sect1><sect2><title>
7999 #: ../en/ch06-collab.xml:84
8000 msgid "Factors to keep in mind"
8001 msgstr "要牢记的因素"
8003 #. type: Content of: <book><chapter><sect1><sect2><para>
8004 #: ../en/ch06-collab.xml:86
8005 msgid ""
8006 "The most important aspect of any model that you must keep in mind is how well "
8007 "it matches the needs and capabilities of the people who will be using it. "
8008 "This might seem self-evident; even so, you still can't afford to forget it "
8009 "for a moment."
8010 msgstr ""
8012 #. type: Content of: <book><chapter><sect1><sect2><para>
8013 #: ../en/ch06-collab.xml:92
8014 msgid ""
8015 "I once put together a workflow model that seemed to make perfect sense to me, "
8016 "but that caused a considerable amount of consternation and strife within my "
8017 "development team. In spite of my attempts to explain why we needed a complex "
8018 "set of branches, and how changes ought to flow between them, a few team "
8019 "members revolted. Even though they were smart people, they didn't want to "
8020 "pay attention to the constraints we were operating under, or face the "
8021 "consequences of those constraints in the details of the model that I was "
8022 "advocating."
8023 msgstr ""
8025 #. type: Content of: <book><chapter><sect1><sect2><para>
8026 #: ../en/ch06-collab.xml:102
8027 msgid ""
8028 "Don't sweep foreseeable social or technical problems under the rug. Whatever "
8029 "scheme you put into effect, you should plan for mistakes and problem "
8030 "scenarios. Consider adding automated machinery to prevent, or quickly "
8031 "recover from, trouble that you can anticipate. As an example, if you intend "
8032 "to have a branch with not-for-release changes in it, you'd do well to think "
8033 "early about the possibility that someone might accidentally merge those "
8034 "changes into a release branch. You could avoid this particular problem by "
8035 "writing a hook that prevents changes from being merged from an inappropriate "
8036 "branch."
8037 msgstr ""
8039 #. type: Content of: <book><chapter><sect1><sect2><title>
8040 #: ../en/ch06-collab.xml:116
8041 msgid "Informal anarchy"
8042 msgstr "无政府状态"
8044 #. type: Content of: <book><chapter><sect1><sect2><para>
8045 #: ../en/ch06-collab.xml:118
8046 msgid ""
8047 "I wouldn't suggest an <quote>anything goes</quote> approach as something "
8048 "sustainable, but it's a model that's easy to grasp, and it works perfectly "
8049 "well in a few unusual situations."
8050 msgstr ""
8052 #. type: Content of: <book><chapter><sect1><sect2><para>
8053 #: ../en/ch06-collab.xml:123
8054 msgid ""
8055 "As one example, many projects have a loose-knit group of collaborators who "
8056 "rarely physically meet each other. Some groups like to overcome the "
8057 "isolation of working at a distance by organizing occasional <quote>sprints</"
8058 "quote>. In a sprint, a number of people get together in a single location (a "
8059 "company's conference room, a hotel meeting room, that kind of place) and "
8060 "spend several days more or less locked in there, hacking intensely on a "
8061 "handful of projects."
8062 msgstr ""
8064 #. type: Content of: <book><chapter><sect1><sect2><para>
8065 #: ../en/ch06-collab.xml:132
8066 msgid ""
8067 "A sprint or a hacking session in a coffee shop are the perfect places to use "
8068 "the <command role=\"hg-cmd\">hg serve</command> command, since <command role="
8069 "\"hg-cmd\">hg serve</command> does not require any fancy server "
8070 "infrastructure. You can get started with <command role=\"hg-cmd\">hg serve</"
8071 "command> in moments, by reading <xref linkend=\"sec:collab:serve\"/> below. "
8072 "Then simply tell the person next to you that you're running a server, send "
8073 "the URL to them in an instant message, and you immediately have a quick-"
8074 "turnaround way to work together. They can type your URL into their web "
8075 "browser and quickly review your changes; or they can pull a bugfix from you "
8076 "and verify it; or they can clone a branch containing a new feature and try it "
8077 "out."
8078 msgstr ""
8080 #. type: Content of: <book><chapter><sect1><sect2><para>
8081 #: ../en/ch06-collab.xml:146
8082 msgid ""
8083 "The charm, and the problem, with doing things in an ad hoc fashion like this "
8084 "is that only people who know about your changes, and where they are, can see "
8085 "them. Such an informal approach simply doesn't scale beyond a handful "
8086 "people, because each individual needs to know about <emphasis>n</emphasis> "
8087 "different repositories to pull from."
8088 msgstr ""
8090 #. type: Content of: <book><chapter><sect1><sect2><title>
8091 #: ../en/ch06-collab.xml:156
8092 msgid "A single central repository"
8093 msgstr "单一中央版本库"
8095 #. type: Content of: <book><chapter><sect1><sect2><para>
8096 #: ../en/ch06-collab.xml:158
8097 msgid ""
8098 "For smaller projects migrating from a centralised revision control tool, "
8099 "perhaps the easiest way to get started is to have changes flow through a "
8100 "single shared central repository. This is also the most common "
8101 "<quote>building block</quote> for more ambitious workflow schemes."
8102 msgstr ""
8104 #. type: Content of: <book><chapter><sect1><sect2><para>
8105 #: ../en/ch06-collab.xml:164
8106 msgid ""
8107 "Contributors start by cloning a copy of this repository. They can pull "
8108 "changes from it whenever they need to, and some (perhaps all) developers have "
8109 "permission to push a change back when they're ready for other people to see "
8110 "it."
8111 msgstr ""
8113 #. type: Content of: <book><chapter><sect1><sect2><para>
8114 #: ../en/ch06-collab.xml:169
8115 msgid ""
8116 "Under this model, it can still often make sense for people to pull changes "
8117 "directly from each other, without going through the central repository. "
8118 "Consider a case in which I have a tentative bug fix, but I am worried that if "
8119 "I were to publish it to the central repository, it might subsequently break "
8120 "everyone else's trees as they pull it. To reduce the potential for damage, I "
8121 "can ask you to clone my repository into a temporary repository of your own "
8122 "and test it. This lets us put off publishing the potentially unsafe change "
8123 "until it has had a little testing."
8124 msgstr ""
8126 #. type: Content of: <book><chapter><sect1><sect2><para>
8127 #: ../en/ch06-collab.xml:180
8128 msgid ""
8129 "If a team is hosting its own repository in this kind of scenario, people will "
8130 "usually use the <command>ssh</command> protocol to securely push changes to "
8131 "the central repository, as documented in <xref linkend=\"sec:collab:ssh\"/>. "
8132 "It's also usual to publish a read-only copy of the repository over HTTP, as "
8133 "in <xref linkend=\"sec:collab:cgi\"/>. Publishing over HTTP satisfies the "
8134 "needs of people who don't have push access, and those who want to use web "
8135 "browsers to browse the repository's history."
8136 msgstr ""
8138 #. type: Content of: <book><chapter><sect1><sect2><title>
8139 #: ../en/ch06-collab.xml:193
8140 msgid "A hosted central repository"
8141 msgstr "托管的中央版本库"
8143 #. type: Content of: <book><chapter><sect1><sect2><para>
8144 #: ../en/ch06-collab.xml:195
8145 msgid ""
8146 "A wonderful thing about public hosting services like <ulink url=\"http://"
8147 "bitbucket.org/\">Bitbucket</ulink> is that not only do they handle the fiddly "
8148 "server configuration details, such as user accounts, authentication, and "
8149 "secure wire protocols, they provide additional infrastructure to make this "
8150 "model work well."
8151 msgstr ""
8153 #. type: Content of: <book><chapter><sect1><sect2><para>
8154 #: ../en/ch06-collab.xml:202
8155 msgid ""
8156 "For instance, a well-engineered hosting service will let people clone their "
8157 "own copies of a repository with a single click. This lets people work in "
8158 "separate spaces and share their changes when they're ready."
8159 msgstr ""
8161 #. type: Content of: <book><chapter><sect1><sect2><para>
8162 #: ../en/ch06-collab.xml:207
8163 msgid ""
8164 "In addition, a good hosting service will let people communicate with each "
8165 "other, for instance to say <quote>there are changes ready for you to review "
8166 "in this tree</quote>."
8167 msgstr ""
8169 #. type: Content of: <book><chapter><sect1><sect2><title>
8170 #: ../en/ch06-collab.xml:214
8171 msgid "Working with multiple branches"
8172 msgstr "使用多个分支工作"
8174 #. type: Content of: <book><chapter><sect1><sect2><para>
8175 #: ../en/ch06-collab.xml:216
8176 msgid ""
8177 "Projects of any significant size naturally tend to make progress on several "
8178 "fronts simultaneously. In the case of software, it's common for a project to "
8179 "go through periodic official releases. A release might then go into "
8180 "<quote>maintenance mode</quote> for a while after its first publication; "
8181 "maintenance releases tend to contain only bug fixes, not new features. In "
8182 "parallel with these maintenance releases, one or more future releases may be "
8183 "under development. People normally use the word <quote>branch</quote> to "
8184 "refer to one of these many slightly different directions in which development "
8185 "is proceeding."
8186 msgstr ""
8188 #. type: Content of: <book><chapter><sect1><sect2><para>
8189 #: ../en/ch06-collab.xml:229
8190 msgid ""
8191 "Mercurial is particularly well suited to managing a number of simultaneous, "
8192 "but not identical, branches. Each <quote>development direction</quote> can "
8193 "live in its own central repository, and you can merge changes from one to "
8194 "another as the need arises. Because repositories are independent of each "
8195 "other, unstable changes in a development branch will never affect a stable "
8196 "branch unless someone explicitly merges those changes into the stable branch."
8197 msgstr ""
8199 #. type: Content of: <book><chapter><sect1><sect2><para>
8200 #: ../en/ch06-collab.xml:238
8201 msgid ""
8202 "Here's an example of how this can work in practice. Let's say you have one "
8203 "<quote>main branch</quote> on a central server."
8204 msgstr ""
8206 #. type: Content of: <book><chapter><sect1><sect2><para>
8207 #: ../en/ch06-collab.xml:244
8208 msgid "People clone it, make changes locally, test them, and push them back."
8209 msgstr ""
8211 #. type: Content of: <book><chapter><sect1><sect2><para>
8212 #: ../en/ch06-collab.xml:247
8213 msgid ""
8214 "Once the main branch reaches a release milestone, you can use the <command "
8215 "role=\"hg-cmd\">hg tag</command> command to give a permanent name to the "
8216 "milestone revision."
8217 msgstr ""
8219 #. type: Content of: <book><chapter><sect1><sect2><para>
8220 #: ../en/ch06-collab.xml:253
8221 msgid "Let's say some ongoing development occurs on the main branch."
8222 msgstr ""
8224 #. type: Content of: <book><chapter><sect1><sect2><para>
8225 #: ../en/ch06-collab.xml:258
8226 msgid ""
8227 "Using the tag that was recorded at the milestone, people who clone that "
8228 "repository at any time in the future can use <command role=\"hg-cmd\">hg "
8229 "update</command> to get a copy of the working directory exactly as it was "
8230 "when that tagged revision was committed."
8231 msgstr ""
8233 #. type: Content of: <book><chapter><sect1><sect2><para>
8234 #: ../en/ch06-collab.xml:266
8235 msgid ""
8236 "In addition, immediately after the main branch is tagged, we can then clone "
8237 "the main branch on the server to a new <quote>stable</quote> branch, also on "
8238 "the server."
8239 msgstr ""
8241 #. type: Content of: <book><chapter><sect1><sect2><para>
8242 #: ../en/ch06-collab.xml:272
8243 msgid ""
8244 "If we need to make a change to the stable branch, we can then clone "
8245 "<emphasis>that</emphasis> repository, make our changes, commit, and push our "
8246 "changes back there."
8247 msgstr ""
8249 #. type: Content of: <book><chapter><sect1><sect2><para>
8250 #: ../en/ch06-collab.xml:279
8251 msgid ""
8252 "Because Mercurial repositories are independent, and Mercurial doesn't move "
8253 "changes around automatically, the stable and main branches are "
8254 "<emphasis>isolated</emphasis> from each other. The changes that we made on "
8255 "the main branch don't <quote>leak</quote> to the stable branch, and vice "
8256 "versa."
8257 msgstr ""
8259 #. type: Content of: <book><chapter><sect1><sect2><para>
8260 #: ../en/ch06-collab.xml:286
8261 msgid ""
8262 "We'll often want all of our bugfixes on the stable branch to show up on the "
8263 "main branch, too. Rather than rewrite a bugfix on the main branch, we can "
8264 "simply pull and merge changes from the stable to the main branch, and "
8265 "Mercurial will bring those bugfixes in for us."
8266 msgstr ""
8268 #. type: Content of: <book><chapter><sect1><sect2><para>
8269 #: ../en/ch06-collab.xml:294
8270 msgid ""
8271 "The main branch will still contain changes that are not on the stable branch, "
8272 "but it will also contain all of the bugfixes from the stable branch. The "
8273 "stable branch remains unaffected by these changes, since changes are only "
8274 "flowing from the stable to the main branch, and not the other way."
8275 msgstr ""
8277 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
8278 #: ../en/ch06-collab.xml:303 ../en/ch06-collab.xml:313
8279 msgid "Feature branches"
8280 msgstr "特性分支"
8282 #. type: Content of: <book><chapter><sect1><sect2><para>
8283 #: ../en/ch06-collab.xml:305
8284 msgid ""
8285 "For larger projects, an effective way to manage change is to break up a team "
8286 "into smaller groups. Each group has a shared branch of its own, cloned from "
8287 "a single <quote>master</quote> branch used by the entire project. People "
8288 "working on an individual branch are typically quite isolated from "
8289 "developments on other branches."
8290 msgstr ""
8292 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
8293 #: ../en/ch06-collab.xml:315
8294 msgid ""
8295 "<imageobject><imagedata width=\"100%\" fileref=\"figs/feature-branches.png\"/"
8296 "></imageobject>"
8297 msgstr ""
8299 #. type: Content of: <book><chapter><sect1><sect2><para>
8300 #: ../en/ch06-collab.xml:320
8301 msgid ""
8302 "When a particular feature is deemed to be in suitable shape, someone on that "
8303 "feature team pulls and merges from the master branch into the feature branch, "
8304 "then pushes back up to the master branch."
8305 msgstr ""
8307 #. type: Content of: <book><chapter><sect1><sect2><title>
8308 #: ../en/ch06-collab.xml:327
8309 msgid "The release train"
8310 msgstr "发布列车"
8312 #. type: Content of: <book><chapter><sect1><sect2><para>
8313 #: ../en/ch06-collab.xml:329
8314 msgid ""
8315 "Some projects are organized on a <quote>train</quote> basis: a release is "
8316 "scheduled to happen every few months, and whatever features are ready when "
8317 "the <quote>train</quote> is ready to leave are allowed in."
8318 msgstr ""
8320 #. type: Content of: <book><chapter><sect1><sect2><para>
8321 #: ../en/ch06-collab.xml:334
8322 msgid ""
8323 "This model resembles working with feature branches. The difference is that "
8324 "when a feature branch misses a train, someone on the feature team pulls and "
8325 "merges the changes that went out on that train release into the feature "
8326 "branch, and the team continues its work on top of that release so that their "
8327 "feature can make the next release."
8328 msgstr ""
8330 #. type: Content of: <book><chapter><sect1><sect2><title>
8331 #: ../en/ch06-collab.xml:343
8332 msgid "The Linux kernel model"
8333 msgstr "Linux 内核模型"
8335 #. type: Content of: <book><chapter><sect1><sect2><para>
8336 #: ../en/ch06-collab.xml:345
8337 msgid ""
8338 "The development of the Linux kernel has a shallow hierarchical structure, "
8339 "surrounded by a cloud of apparent chaos. Because most Linux developers use "
8340 "<command>git</command>, a distributed revision control tool with capabilities "
8341 "similar to Mercurial, it's useful to describe the way work flows in that "
8342 "environment; if you like the ideas, the approach translates well across tools."
8343 msgstr ""
8345 #. type: Content of: <book><chapter><sect1><sect2><para>
8346 #: ../en/ch06-collab.xml:353
8347 msgid ""
8348 "At the center of the community sits Linus Torvalds, the creator of Linux. He "
8349 "publishes a single source repository that is considered the "
8350 "<quote>authoritative</quote> current tree by the entire developer community. "
8351 "Anyone can clone Linus's tree, but he is very choosy about whose trees he "
8352 "pulls from."
8353 msgstr ""
8355 #. type: Content of: <book><chapter><sect1><sect2><para>
8356 #: ../en/ch06-collab.xml:360
8357 msgid ""
8358 "Linus has a number of <quote>trusted lieutenants</quote>. As a general rule, "
8359 "he pulls whatever changes they publish, in most cases without even reviewing "
8360 "those changes. Some of those lieutenants are generally agreed to be "
8361 "<quote>maintainers</quote>, responsible for specific subsystems within the "
8362 "kernel. If a random kernel hacker wants to make a change to a subsystem that "
8363 "they want to end up in Linus's tree, they must find out who the subsystem's "
8364 "maintainer is, and ask that maintainer to take their change. If the "
8365 "maintainer reviews their changes and agrees to take them, they'll pass them "
8366 "along to Linus in due course."
8367 msgstr ""
8369 #. type: Content of: <book><chapter><sect1><sect2><para>
8370 #: ../en/ch06-collab.xml:372
8371 msgid ""
8372 "Individual lieutenants have their own approaches to reviewing, accepting, and "
8373 "publishing changes; and for deciding when to feed them to Linus. In "
8374 "addition, there are several well known branches that people use for different "
8375 "purposes. For example, a few people maintain <quote>stable</quote> "
8376 "repositories of older versions of the kernel, to which they apply critical "
8377 "fixes as needed. Some maintainers publish multiple trees: one for "
8378 "experimental changes; one for changes that they are about to feed upstream; "
8379 "and so on. Others just publish a single tree."
8380 msgstr ""
8382 #. type: Content of: <book><chapter><sect1><sect2><para>
8383 #: ../en/ch06-collab.xml:383
8384 msgid ""
8385 "This model has two notable features. The first is that it's <quote>pull "
8386 "only</quote>. You have to ask, convince, or beg another developer to take a "
8387 "change from you, because there are almost no trees to which more than one "
8388 "person can push, and there's no way to push changes into a tree that someone "
8389 "else controls."
8390 msgstr ""
8392 #. type: Content of: <book><chapter><sect1><sect2><para>
8393 #: ../en/ch06-collab.xml:390
8394 msgid ""
8395 "The second is that it's based on reputation and acclaim. If you're an "
8396 "unknown, Linus will probably ignore changes from you without even "
8397 "responding. But a subsystem maintainer will probably review them, and will "
8398 "likely take them if they pass their criteria for suitability. The more "
8399 "<quote>good</quote> changes you contribute to a maintainer, the more likely "
8400 "they are to trust your judgment and accept your changes. If you're well-"
8401 "known and maintain a long-lived branch for something Linus hasn't yet "
8402 "accepted, people with similar interests may pull your changes regularly to "
8403 "keep up with your work."
8404 msgstr ""
8406 #. type: Content of: <book><chapter><sect1><sect2><para>
8407 #: ../en/ch06-collab.xml:401
8408 msgid ""
8409 "Reputation and acclaim don't necessarily cross subsystem or <quote>people</"
8410 "quote> boundaries. If you're a respected but specialised storage hacker, and "
8411 "you try to fix a networking bug, that change will receive a level of scrutiny "
8412 "from a network maintainer comparable to a change from a complete stranger."
8413 msgstr ""
8415 #. type: Content of: <book><chapter><sect1><sect2><para>
8416 #: ../en/ch06-collab.xml:408
8417 msgid ""
8418 "To people who come from more orderly project backgrounds, the comparatively "
8419 "chaotic Linux kernel development process often seems completely insane. It's "
8420 "subject to the whims of individuals; people make sweeping changes whenever "
8421 "they deem it appropriate; and the pace of development is astounding. And yet "
8422 "Linux is a highly successful, well-regarded piece of software."
8423 msgstr ""
8425 #. type: Content of: <book><chapter><sect1><sect2><title>
8426 #: ../en/ch06-collab.xml:418
8427 msgid "Pull-only versus shared-push collaboration"
8428 msgstr "只读与共享写协作"
8430 #. type: Content of: <book><chapter><sect1><sect2><para>
8431 #: ../en/ch06-collab.xml:420
8432 msgid ""
8433 "A perpetual source of heat in the open source community is whether a "
8434 "development model in which people only ever pull changes from others is "
8435 "<quote>better than</quote> one in which multiple people can push changes to a "
8436 "shared repository."
8437 msgstr ""
8439 #. type: Content of: <book><chapter><sect1><sect2><para>
8440 #: ../en/ch06-collab.xml:426
8441 msgid ""
8442 "Typically, the backers of the shared-push model use tools that actively "
8443 "enforce this approach. If you're using a centralised revision control tool "
8444 "such as Subversion, there's no way to make a choice over which model you'll "
8445 "use: the tool gives you shared-push, and if you want to do anything else, "
8446 "you'll have to roll your own approach on top (such as applying a patch by "
8447 "hand)."
8448 msgstr ""
8450 #. type: Content of: <book><chapter><sect1><sect2><para>
8451 #: ../en/ch06-collab.xml:434
8452 msgid ""
8453 "A good distributed revision control tool will support both models. You and "
8454 "your collaborators can then structure how you work together based on your own "
8455 "needs and preferences, not on what contortions your tools force you into."
8456 msgstr ""
8458 #. type: Content of: <book><chapter><sect1><sect2><title>
8459 #: ../en/ch06-collab.xml:441
8460 msgid "Where collaboration meets branch management"
8461 msgstr "协作与分支管理"
8463 #. type: Content of: <book><chapter><sect1><sect2><para>
8464 #: ../en/ch06-collab.xml:443
8465 msgid ""
8466 "Once you and your team set up some shared repositories and start propagating "
8467 "changes back and forth between local and shared repos, you begin to face a "
8468 "related, but slightly different challenge: that of managing the multiple "
8469 "directions in which your team may be moving at once. Even though this "
8470 "subject is intimately related to how your team collaborates, it's dense "
8471 "enough to merit treatment of its own, in <xref linkend=\"chap:branch\"/>."
8472 msgstr ""
8474 #. type: Content of: <book><chapter><sect1><title>
8475 #: ../en/ch06-collab.xml:455
8476 msgid "The technical side of sharing"
8477 msgstr "共享的技术因素"
8479 #. type: Content of: <book><chapter><sect1><para>
8480 #: ../en/ch06-collab.xml:457
8481 msgid ""
8482 "The remainder of this chapter is devoted to the question of sharing changes "
8483 "with your collaborators."
8484 msgstr ""
8486 #. type: Content of: <book><chapter><sect1><title>
8487 #: ../en/ch06-collab.xml:462
8488 msgid "Informal sharing with <command role=\"hg-cmd\">hg serve</command>"
8489 msgstr "使用 <command role=\"hg-cmd\">hg serve</command> 进行非正式共享"
8491 #. type: Content of: <book><chapter><sect1><para>
8492 #: ../en/ch06-collab.xml:465
8493 msgid ""
8494 "Mercurial's <command role=\"hg-cmd\">hg serve</command> command is "
8495 "wonderfully suited to small, tight-knit, and fast-paced group environments. "
8496 "It also provides a great way to get a feel for using Mercurial commands over "
8497 "a network."
8498 msgstr ""
8500 #. type: Content of: <book><chapter><sect1><para>
8501 #: ../en/ch06-collab.xml:470
8502 msgid ""
8503 "Run <command role=\"hg-cmd\">hg serve</command> inside a repository, and in "
8504 "under a second it will bring up a specialised HTTP server; this will accept "
8505 "connections from any client, and serve up data for that repository until you "
8506 "terminate it. Anyone who knows the URL of the server you just started, and "
8507 "can talk to your computer over the network, can then use a web browser or "
8508 "Mercurial to read data from that repository. A URL for a <command role=\"hg-"
8509 "cmd\">hg serve</command> instance running on a laptop is likely to look "
8510 "something like <literal>http://my-laptop.local:8000/</literal>."
8511 msgstr ""
8513 #. type: Content of: <book><chapter><sect1><para>
8514 #: ../en/ch06-collab.xml:481
8515 msgid ""
8516 "The <command role=\"hg-cmd\">hg serve</command> command is <emphasis>not</"
8517 "emphasis> a general-purpose web server. It can do only two things:"
8518 msgstr ""
8520 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8521 #: ../en/ch06-collab.xml:485
8522 msgid ""
8523 "Allow people to browse the history of the repository it's serving, from their "
8524 "normal web browsers."
8525 msgstr ""
8527 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8528 #: ../en/ch06-collab.xml:489
8529 msgid ""
8530 "Speak Mercurial's wire protocol, so that people can <command role=\"hg-cmd"
8531 "\">hg clone</command> or <command role=\"hg-cmd\">hg pull</command> changes "
8532 "from that repository."
8533 msgstr ""
8535 #. type: Content of: <book><chapter><sect1><para>
8536 #: ../en/ch06-collab.xml:494
8537 msgid ""
8538 "In particular, <command role=\"hg-cmd\">hg serve</command> won't allow remote "
8539 "users to <emphasis>modify</emphasis> your repository. It's intended for read-"
8540 "only use."
8541 msgstr ""
8543 #. type: Content of: <book><chapter><sect1><para>
8544 #: ../en/ch06-collab.xml:498
8545 msgid ""
8546 "If you're getting started with Mercurial, there's nothing to prevent you from "
8547 "using <command role=\"hg-cmd\">hg serve</command> to serve up a repository on "
8548 "your own computer, then use commands like <command role=\"hg-cmd\">hg clone</"
8549 "command>, <command role=\"hg-cmd\">hg incoming</command>, and so on to talk "
8550 "to that server as if the repository was hosted remotely. This can help you to "
8551 "quickly get acquainted with using commands on network-hosted repositories."
8552 msgstr ""
8554 #. type: Content of: <book><chapter><sect1><sect2><title>
8555 #: ../en/ch06-collab.xml:508
8556 msgid "A few things to keep in mind"
8557 msgstr "要牢记的几件事"
8559 #. type: Content of: <book><chapter><sect1><sect2><para>
8560 #: ../en/ch06-collab.xml:510
8561 msgid ""
8562 "Because it provides unauthenticated read access to all clients, you should "
8563 "only use <command role=\"hg-cmd\">hg serve</command> in an environment where "
8564 "you either don't care, or have complete control over, who can access your "
8565 "network and pull data from your repository."
8566 msgstr ""
8568 #. type: Content of: <book><chapter><sect1><sect2><para>
8569 #: ../en/ch06-collab.xml:516
8570 msgid ""
8571 "The <command role=\"hg-cmd\">hg serve</command> command knows nothing about "
8572 "any firewall software you might have installed on your system or network. It "
8573 "cannot detect or control your firewall software. If other people are unable "
8574 "to talk to a running <command role=\"hg-cmd\">hg serve</command> instance, "
8575 "the second thing you should do (<emphasis>after</emphasis> you make sure that "
8576 "they're using the correct URL) is check your firewall configuration."
8577 msgstr ""
8579 #. type: Content of: <book><chapter><sect1><sect2><para>
8580 #: ../en/ch06-collab.xml:525
8581 msgid ""
8582 "By default, <command role=\"hg-cmd\">hg serve</command> listens for incoming "
8583 "connections on port 8000. If another process is already listening on the "
8584 "port you want to use, you can specify a different port to listen on using the "
8585 "<option role=\"hg-opt-serve\">-p</option> option."
8586 msgstr ""
8588 #. type: Content of: <book><chapter><sect1><sect2><para>
8589 #: ../en/ch06-collab.xml:531
8590 msgid ""
8591 "Normally, when <command role=\"hg-cmd\">hg serve</command> starts, it prints "
8592 "no output, which can be a bit unnerving. If you'd like to confirm that it is "
8593 "indeed running correctly, and find out what URL you should send to your "
8594 "collaborators, start it with the <option role=\"hg-opt-global\">-v</option> "
8595 "option."
8596 msgstr ""
8598 #. type: Content of: <book><chapter><sect1><title>
8599 #: ../en/ch06-collab.xml:541
8600 msgid "Using the Secure Shell (ssh) protocol"
8601 msgstr "使用 ssh 协议"
8603 #. type: Content of: <book><chapter><sect1><para>
8604 #: ../en/ch06-collab.xml:543
8605 msgid ""
8606 "You can pull and push changes securely over a network connection using the "
8607 "Secure Shell (<literal>ssh</literal>) protocol. To use this successfully, "
8608 "you may have to do a little bit of configuration on the client or server "
8609 "sides."
8610 msgstr ""
8612 #. type: Content of: <book><chapter><sect1><para>
8613 #: ../en/ch06-collab.xml:548
8614 msgid ""
8615 "If you're not familiar with ssh, it's the name of both a command and a "
8616 "network protocol that let you securely communicate with another computer. To "
8617 "use it with Mercurial, you'll be setting up one or more user accounts on a "
8618 "server so that remote users can log in and execute commands."
8619 msgstr ""
8621 #. type: Content of: <book><chapter><sect1><para>
8622 #: ../en/ch06-collab.xml:554
8623 msgid ""
8624 "(If you <emphasis>are</emphasis> familiar with ssh, you'll probably find some "
8625 "of the material that follows to be elementary in nature.)"
8626 msgstr ""
8628 #. type: Content of: <book><chapter><sect1><sect2><title>
8629 #: ../en/ch06-collab.xml:559
8630 msgid "How to read and write ssh URLs"
8631 msgstr "如何读写 ssh 路径"
8633 #. type: Content of: <book><chapter><sect1><sect2><para>
8634 #: ../en/ch06-collab.xml:561
8635 msgid "An ssh URL tends to look like this:"
8636 msgstr ""
8638 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
8639 #: ../en/ch06-collab.xml:564
8640 msgid ""
8641 "The <quote><literal>ssh://</literal></quote> part tells Mercurial to use the "
8642 "ssh protocol."
8643 msgstr ""
8645 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
8646 #: ../en/ch06-collab.xml:567
8647 msgid ""
8648 "The <quote><literal>bos@</literal></quote> component indicates what username "
8649 "to log into the server as. You can leave this out if the remote username is "
8650 "the same as your local username."
8651 msgstr ""
8653 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
8654 #: ../en/ch06-collab.xml:572
8655 msgid ""
8656 "The <quote><literal>hg.serpentine.com</literal></quote> gives the hostname of "
8657 "the server to log into."
8658 msgstr ""
8660 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
8661 #: ../en/ch06-collab.xml:576
8662 msgid ""
8663 "The <quote>:22</quote> identifies the port number to connect to the server "
8664 "on. The default port is 22, so you only need to specify a colon and port "
8665 "number if you're <emphasis>not</emphasis> using port 22."
8666 msgstr ""
8668 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
8669 #: ../en/ch06-collab.xml:581
8670 msgid ""
8671 "The remainder of the URL is the local path to the repository on the server."
8672 msgstr ""
8674 #. type: Content of: <book><chapter><sect1><sect2><para>
8675 #: ../en/ch06-collab.xml:585
8676 msgid ""
8677 "There's plenty of scope for confusion with the path component of ssh URLs, as "
8678 "there is no standard way for tools to interpret it. Some programs behave "
8679 "differently than others when dealing with these paths. This isn't an ideal "
8680 "situation, but it's unlikely to change. Please read the following paragraphs "
8681 "carefully."
8682 msgstr ""
8684 #. type: Content of: <book><chapter><sect1><sect2><para>
8685 #: ../en/ch06-collab.xml:592
8686 msgid ""
8687 "Mercurial treats the path to a repository on the server as relative to the "
8688 "remote user's home directory. For example, if user <literal>foo</literal> on "
8689 "the server has a home directory of <filename class=\"directory\">/home/foo</"
8690 "filename>, then an ssh URL that contains a path component of <filename class="
8691 "\"directory\">bar</filename> <emphasis>really</emphasis> refers to the "
8692 "directory <filename class=\"directory\">/home/foo/bar</filename>."
8693 msgstr ""
8695 #. type: Content of: <book><chapter><sect1><sect2><para>
8696 #: ../en/ch06-collab.xml:601
8697 msgid ""
8698 "If you want to specify a path relative to another user's home directory, you "
8699 "can use a path that starts with a tilde character followed by the user's name "
8700 "(let's call them <literal>otheruser</literal>), like this."
8701 msgstr ""
8703 #. type: Content of: <book><chapter><sect1><sect2><para>
8704 #: ../en/ch06-collab.xml:607
8705 msgid ""
8706 "And if you really want to specify an <emphasis>absolute</emphasis> path on "
8707 "the server, begin the path component with two slashes, as in this example."
8708 msgstr ""
8710 #. type: Content of: <book><chapter><sect1><sect2><title>
8711 #: ../en/ch06-collab.xml:614
8712 msgid "Finding an ssh client for your system"
8713 msgstr "为你的系统寻找 ssh 客户端"
8715 #. type: Content of: <book><chapter><sect1><sect2><para>
8716 #: ../en/ch06-collab.xml:616
8717 msgid ""
8718 "Almost every Unix-like system comes with OpenSSH preinstalled. If you're "
8719 "using such a system, run <literal>which ssh</literal> to find out if the "
8720 "<command>ssh</command> command is installed (it's usually in <filename class="
8721 "\"directory\">/usr/bin</filename>). In the unlikely event that it isn't "
8722 "present, take a look at your system documentation to figure out how to "
8723 "install it."
8724 msgstr ""
8726 #. type: Content of: <book><chapter><sect1><sect2><para>
8727 #: ../en/ch06-collab.xml:624
8728 msgid ""
8729 "On Windows, the TortoiseHg package is bundled with a version of Simon "
8730 "Tatham's excellent <command>plink</command> command, and you should not need "
8731 "to do any further configuration."
8732 msgstr ""
8734 #. type: Content of: <book><chapter><sect1><sect2><title>
8735 #: ../en/ch06-collab.xml:631
8736 msgid "Generating a key pair"
8737 msgstr "产生密钥对"
8739 #. type: Content of: <book><chapter><sect1><sect2><para>
8740 #: ../en/ch06-collab.xml:633
8741 msgid ""
8742 "To avoid the need to repetitively type a password every time you need to use "
8743 "your ssh client, I recommend generating a key pair."
8744 msgstr ""
8746 #. type: Content of: <book><chapter><sect1><sect2><tip><title>
8747 #: ../en/ch06-collab.xml:638
8748 msgid "Key pairs are not mandatory"
8749 msgstr ""
8751 #. type: Content of: <book><chapter><sect1><sect2><tip><para>
8752 #: ../en/ch06-collab.xml:640
8753 msgid ""
8754 "Mercurial knows nothing about ssh authentication or key pairs. You can, if "
8755 "you like, safely ignore this section and the one that follows until you grow "
8756 "tired of repeatedly typing ssh passwords."
8757 msgstr ""
8759 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8760 #: ../en/ch06-collab.xml:648
8761 msgid ""
8762 "On a Unix-like system, the <command>ssh-keygen</command> command will do the "
8763 "trick."
8764 msgstr ""
8766 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8767 #: ../en/ch06-collab.xml:651
8768 msgid ""
8769 "On Windows, if you're using TortoiseHg, you may need to download a command "
8770 "named <command>puttygen</command> from <ulink url=\"http://www.chiark."
8771 "greenend.org.uk/~sgtatham/putty\">the PuTTY web site</ulink> to generate a "
8772 "key pair. See <ulink url=\"http://the.earth.li/~sgtatham/putty/0.60/htmldoc/"
8773 "Chapter8.html#pubkey-puttygen\">the <command>puttygen</command> "
8774 "documentation</ulink> for details of how use the command."
8775 msgstr ""
8777 #. type: Content of: <book><chapter><sect1><sect2><para>
8778 #: ../en/ch06-collab.xml:663
8779 msgid ""
8780 "When you generate a key pair, it's usually <emphasis>highly</emphasis> "
8781 "advisable to protect it with a passphrase. (The only time that you might not "
8782 "want to do this is when you're using the ssh protocol for automated tasks on "
8783 "a secure network.)"
8784 msgstr ""
8786 #. type: Content of: <book><chapter><sect1><sect2><para>
8787 #: ../en/ch06-collab.xml:669
8788 msgid ""
8789 "Simply generating a key pair isn't enough, however. You'll need to add the "
8790 "public key to the set of authorised keys for whatever user you're logging in "
8791 "remotely as. For servers using OpenSSH (the vast majority), this will mean "
8792 "adding the public key to a list in a file called <filename role=\"special"
8793 "\">authorized_keys</filename> in their <filename role=\"special\" class="
8794 "\"directory\">.ssh</filename> directory."
8795 msgstr ""
8797 #. type: Content of: <book><chapter><sect1><sect2><para>
8798 #: ../en/ch06-collab.xml:678
8799 msgid ""
8800 "On a Unix-like system, your public key will have a <filename>.pub</filename> "
8801 "extension. If you're using <command>puttygen</command> on Windows, you can "
8802 "save the public key to a file of your choosing, or paste it from the window "
8803 "it's displayed in straight into the <filename role=\"special"
8804 "\">authorized_keys</filename> file."
8805 msgstr ""
8807 #. type: Content of: <book><chapter><sect1><sect2><title>
8808 #: ../en/ch06-collab.xml:686
8809 msgid "Using an authentication agent"
8810 msgstr "使用认证代理"
8812 #. type: Content of: <book><chapter><sect1><sect2><para>
8813 #: ../en/ch06-collab.xml:688
8814 msgid ""
8815 "An authentication agent is a daemon that stores passphrases in memory (so it "
8816 "will forget passphrases if you log out and log back in again). An ssh client "
8817 "will notice if it's running, and query it for a passphrase. If there's no "
8818 "authentication agent running, or the agent doesn't store the necessary "
8819 "passphrase, you'll have to type your passphrase every time Mercurial tries to "
8820 "communicate with a server on your behalf (e.g. whenever you pull or push "
8821 "changes)."
8822 msgstr ""
8824 #. type: Content of: <book><chapter><sect1><sect2><para>
8825 #: ../en/ch06-collab.xml:697
8826 msgid ""
8827 "The downside of storing passphrases in an agent is that it's possible for a "
8828 "well-prepared attacker to recover the plain text of your passphrases, in some "
8829 "cases even if your system has been power-cycled. You should make your own "
8830 "judgment as to whether this is an acceptable risk. It certainly saves a lot "
8831 "of repeated typing."
8832 msgstr ""
8834 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8835 #: ../en/ch06-collab.xml:706
8836 msgid ""
8837 "On Unix-like systems, the agent is called <command>ssh-agent</command>, and "
8838 "it's often run automatically for you when you log in. You'll need to use the "
8839 "<command>ssh-add</command> command to add passphrases to the agent's store."
8840 msgstr ""
8842 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8843 #: ../en/ch06-collab.xml:713
8844 msgid ""
8845 "On Windows, if you're using TortoiseHg, the <command>pageant</command> "
8846 "command acts as the agent. As with <command>puttygen</command>, you'll need "
8847 "to <ulink url=\"http://www.chiark.greenend.org.uk/%7Esgtatham/putty/download."
8848 "html\">download <command>pageant</command></ulink> from the PuTTY web site "
8849 "and read <ulink url=\"http://the.earth.li/~sgtatham/putty/0.60/htmldoc/"
8850 "Chapter9.html#pageant\">its documentation</ulink>. The <command>pageant</"
8851 "command> command adds an icon to your system tray that will let you manage "
8852 "stored passphrases."
8853 msgstr ""
8855 #. type: Content of: <book><chapter><sect1><sect2><title>
8856 #: ../en/ch06-collab.xml:728
8857 msgid "Configuring the server side properly"
8858 msgstr "正确配置服务器端"
8860 #. type: Content of: <book><chapter><sect1><sect2><para>
8861 #: ../en/ch06-collab.xml:730
8862 msgid ""
8863 "Because ssh can be fiddly to set up if you're new to it, a variety of things "
8864 "can go wrong. Add Mercurial on top, and there's plenty more scope for head-"
8865 "scratching. Most of these potential problems occur on the server side, not "
8866 "the client side. The good news is that once you've gotten a configuration "
8867 "working, it will usually continue to work indefinitely."
8868 msgstr ""
8870 #. type: Content of: <book><chapter><sect1><sect2><para>
8871 #: ../en/ch06-collab.xml:738
8872 msgid ""
8873 "Before you try using Mercurial to talk to an ssh server, it's best to make "
8874 "sure that you can use the normal <command>ssh</command> or <command>putty</"
8875 "command> command to talk to the server first. If you run into problems with "
8876 "using these commands directly, Mercurial surely won't work. Worse, it will "
8877 "obscure the underlying problem. Any time you want to debug ssh-related "
8878 "Mercurial problems, you should drop back to making sure that plain ssh client "
8879 "commands work first, <emphasis>before</emphasis> you worry about whether "
8880 "there's a problem with Mercurial."
8881 msgstr ""
8883 #. type: Content of: <book><chapter><sect1><sect2><para>
8884 #: ../en/ch06-collab.xml:749
8885 msgid ""
8886 "The first thing to be sure of on the server side is that you can actually log "
8887 "in from another machine at all. If you can't use <command>ssh</command> or "
8888 "<command>putty</command> to log in, the error message you get may give you a "
8889 "few hints as to what's wrong. The most common problems are as follows."
8890 msgstr ""
8892 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8893 #: ../en/ch06-collab.xml:756
8894 msgid ""
8895 "If you get a <quote>connection refused</quote> error, either there isn't an "
8896 "SSH daemon running on the server at all, or it's inaccessible due to firewall "
8897 "configuration."
8898 msgstr ""
8900 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8901 #: ../en/ch06-collab.xml:761
8902 msgid ""
8903 "If you get a <quote>no route to host</quote> error, you either have an "
8904 "incorrect address for the server or a seriously locked down firewall that "
8905 "won't admit its existence at all."
8906 msgstr ""
8908 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8909 #: ../en/ch06-collab.xml:766
8910 msgid ""
8911 "If you get a <quote>permission denied</quote> error, you may have mistyped "
8912 "the username on the server, or you could have mistyped your key's passphrase "
8913 "or the remote user's password."
8914 msgstr ""
8916 #. type: Content of: <book><chapter><sect1><sect2><para>
8917 #: ../en/ch06-collab.xml:771
8918 msgid ""
8919 "In summary, if you're having trouble talking to the server's ssh daemon, "
8920 "first make sure that one is running at all. On many systems it will be "
8921 "installed, but disabled, by default. Once you're done with this step, you "
8922 "should then check that the server's firewall is configured to allow incoming "
8923 "connections on the port the ssh daemon is listening on (usually 22). Don't "
8924 "worry about more exotic possibilities for misconfiguration until you've "
8925 "checked these two first."
8926 msgstr ""
8928 #. type: Content of: <book><chapter><sect1><sect2><para>
8929 #: ../en/ch06-collab.xml:781
8930 msgid ""
8931 "If you're using an authentication agent on the client side to store "
8932 "passphrases for your keys, you ought to be able to log into the server "
8933 "without being prompted for a passphrase or a password. If you're prompted "
8934 "for a passphrase, there are a few possible culprits."
8935 msgstr ""
8937 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8938 #: ../en/ch06-collab.xml:787
8939 msgid ""
8940 "You might have forgotten to use <command>ssh-add</command> or "
8941 "<command>pageant</command> to store the passphrase."
8942 msgstr ""
8944 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8945 #: ../en/ch06-collab.xml:791
8946 msgid "You might have stored the passphrase for the wrong key."
8947 msgstr ""
8949 #. type: Content of: <book><chapter><sect1><sect2><para>
8950 #: ../en/ch06-collab.xml:794
8951 msgid ""
8952 "If you're being prompted for the remote user's password, there are another "
8953 "few possible problems to check."
8954 msgstr ""
8956 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8957 #: ../en/ch06-collab.xml:797
8958 msgid ""
8959 "Either the user's home directory or their <filename role=\"special\" class="
8960 "\"directory\">.ssh</filename> directory might have excessively liberal "
8961 "permissions. As a result, the ssh daemon will not trust or read their "
8962 "<filename role=\"special\">authorized_keys</filename> file. For example, a "
8963 "group-writable home or <filename role=\"special\" class=\"directory\">.ssh</"
8964 "filename> directory will often cause this symptom."
8965 msgstr ""
8967 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8968 #: ../en/ch06-collab.xml:806
8969 msgid ""
8970 "The user's <filename role=\"special\">authorized_keys</filename> file may "
8971 "have a problem. If anyone other than the user owns or can write to that file, "
8972 "the ssh daemon will not trust or read it."
8973 msgstr ""
8975 #. type: Content of: <book><chapter><sect1><sect2><para>
8976 #: ../en/ch06-collab.xml:813
8977 msgid ""
8978 "In the ideal world, you should be able to run the following command "
8979 "successfully, and it should print exactly one line of output, the current "
8980 "date and time."
8981 msgstr ""
8983 #. type: Content of: <book><chapter><sect1><sect2><para>
8984 #: ../en/ch06-collab.xml:818
8985 msgid ""
8986 "If, on your server, you have login scripts that print banners or other junk "
8987 "even when running non-interactive commands like this, you should fix them "
8988 "before you continue, so that they only print output if they're run "
8989 "interactively. Otherwise these banners will at least clutter up Mercurial's "
8990 "output. Worse, they could potentially cause problems with running Mercurial "
8991 "commands remotely. Mercurial tries to detect and ignore banners in non-"
8992 "interactive <command>ssh</command> sessions, but it is not foolproof. (If "
8993 "you're editing your login scripts on your server, the usual way to see if a "
8994 "login script is running in an interactive shell is to check the return code "
8995 "from the command <literal>tty -s</literal>.)"
8996 msgstr ""
8998 #. type: Content of: <book><chapter><sect1><sect2><para>
8999 #: ../en/ch06-collab.xml:832
9000 msgid ""
9001 "Once you've verified that plain old ssh is working with your server, the next "
9002 "step is to ensure that Mercurial runs on the server. The following command "
9003 "should run successfully:"
9004 msgstr ""
9006 #. type: Content of: <book><chapter><sect1><sect2><para>
9007 #: ../en/ch06-collab.xml:839
9008 msgid ""
9009 "If you see an error message instead of normal <command role=\"hg-cmd\">hg "
9010 "version</command> output, this is usually because you haven't installed "
9011 "Mercurial to <filename class=\"directory\">/usr/bin</filename>. Don't worry "
9012 "if this is the case; you don't need to do that. But you should check for a "
9013 "few possible problems."
9014 msgstr ""
9016 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9017 #: ../en/ch06-collab.xml:846
9018 msgid ""
9019 "Is Mercurial really installed on the server at all? I know this sounds "
9020 "trivial, but it's worth checking!"
9021 msgstr ""
9023 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9024 #: ../en/ch06-collab.xml:850
9025 msgid ""
9026 "Maybe your shell's search path (usually set via the <envar>PATH</envar> "
9027 "environment variable) is simply misconfigured."
9028 msgstr ""
9030 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9031 #: ../en/ch06-collab.xml:854
9032 msgid ""
9033 "Perhaps your <envar>PATH</envar> environment variable is only being set to "
9034 "point to the location of the <command>hg</command> executable if the login "
9035 "session is interactive. This can happen if you're setting the path in the "
9036 "wrong shell login script. See your shell's documentation for details."
9037 msgstr ""
9039 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9040 #: ../en/ch06-collab.xml:861
9041 msgid ""
9042 "The <envar>PYTHONPATH</envar> environment variable may need to contain the "
9043 "path to the Mercurial Python modules. It might not be set at all; it could "
9044 "be incorrect; or it may be set only if the login is interactive."
9045 msgstr ""
9047 #. type: Content of: <book><chapter><sect1><sect2><para>
9048 #: ../en/ch06-collab.xml:868
9049 msgid ""
9050 "If you can run <command role=\"hg-cmd\">hg version</command> over an ssh "
9051 "connection, well done! You've got the server and client sorted out. You "
9052 "should now be able to use Mercurial to access repositories hosted by that "
9053 "username on that server. If you run into problems with Mercurial and ssh at "
9054 "this point, try using the <option role=\"hg-opt-global\">--debug</option> "
9055 "option to get a clearer picture of what's going on."
9056 msgstr ""
9058 #. type: Content of: <book><chapter><sect1><sect2><title>
9059 #: ../en/ch06-collab.xml:877
9060 msgid "Using compression with ssh"
9061 msgstr "通过 ssh 使用压缩"
9063 #. type: Content of: <book><chapter><sect1><sect2><para>
9064 #: ../en/ch06-collab.xml:879
9065 msgid ""
9066 "Mercurial does not compress data when it uses the ssh protocol, because the "
9067 "ssh protocol can transparently compress data. However, the default behavior "
9068 "of ssh clients is <emphasis>not</emphasis> to request compression."
9069 msgstr ""
9071 #. type: Content of: <book><chapter><sect1><sect2><para>
9072 #: ../en/ch06-collab.xml:884
9073 msgid ""
9074 "Over any network other than a fast LAN (even a wireless network), using "
9075 "compression is likely to significantly speed up Mercurial's network "
9076 "operations. For example, over a WAN, someone measured compression as "
9077 "reducing the amount of time required to clone a particularly large repository "
9078 "from 51 minutes to 17 minutes."
9079 msgstr ""
9081 #. type: Content of: <book><chapter><sect1><sect2><para>
9082 #: ../en/ch06-collab.xml:891
9083 msgid ""
9084 "Both <command>ssh</command> and <command>plink</command> accept a <option "
9085 "role=\"cmd-opt-ssh\">-C</option> option which turns on compression. You can "
9086 "easily edit your <filename role=\"special\">~/.hgrc</filename> to enable "
9087 "compression for all of Mercurial's uses of the ssh protocol. Here is how to "
9088 "do so for regular <command>ssh</command> on Unix-like systems, for example."
9089 msgstr ""
9091 #. type: Content of: <book><chapter><sect1><sect2><para>
9092 #: ../en/ch06-collab.xml:901
9093 msgid ""
9094 "If you use <command>ssh</command> on a Unix-like system, you can configure it "
9095 "to always use compression when talking to your server. To do this, edit your "
9096 "<filename role=\"special\">.ssh/config</filename> file (which may not yet "
9097 "exist), as follows."
9098 msgstr ""
9100 #. type: Content of: <book><chapter><sect1><sect2><para>
9101 #: ../en/ch06-collab.xml:911
9102 msgid ""
9103 "This defines a hostname alias, <literal>hg</literal>. When you use that "
9104 "hostname on the <command>ssh</command> command line or in a Mercurial "
9105 "<literal>ssh</literal>-protocol URL, it will cause <command>ssh</command> to "
9106 "connect to <literal>hg.example.com</literal> and use compression. This gives "
9107 "you both a shorter name to type and compression, each of which is a good "
9108 "thing in its own right."
9109 msgstr ""
9111 #. type: Content of: <book><chapter><sect1><title>
9112 #: ../en/ch06-collab.xml:923
9113 msgid "Serving over HTTP using CGI"
9114 msgstr "使用 CGI 通过 HTTP 提供服务"
9116 #. type: Content of: <book><chapter><sect1><para>
9117 #: ../en/ch06-collab.xml:925
9118 msgid ""
9119 "The simplest way to host one or more repositories in a permanent way is to "
9120 "use a web server and Mercurial's CGI support."
9121 msgstr ""
9123 #. type: Content of: <book><chapter><sect1><para>
9124 #: ../en/ch06-collab.xml:929
9125 msgid ""
9126 "Depending on how ambitious you are, configuring Mercurial's CGI interface can "
9127 "take anything from a few moments to several hours."
9128 msgstr ""
9130 #. type: Content of: <book><chapter><sect1><para>
9131 #: ../en/ch06-collab.xml:933
9132 msgid ""
9133 "We'll begin with the simplest of examples, and work our way towards a more "
9134 "complex configuration. Even for the most basic case, you're almost certainly "
9135 "going to need to read and modify your web server's configuration."
9136 msgstr ""
9138 #. type: Content of: <book><chapter><sect1><note><title>
9139 #: ../en/ch06-collab.xml:939
9140 msgid "High pain tolerance required"
9141 msgstr ""
9143 #. type: Content of: <book><chapter><sect1><note><para>
9144 #: ../en/ch06-collab.xml:941
9145 msgid ""
9146 "Configuring a web server is a complex, fiddly, and highly system-dependent "
9147 "activity. I can't possibly give you instructions that will cover anything "
9148 "like all of the cases you will encounter. Please use your discretion and "
9149 "judgment in following the sections below. Be prepared to make plenty of "
9150 "mistakes, and to spend a lot of time reading your server's error logs."
9151 msgstr ""
9153 #. type: Content of: <book><chapter><sect1><note><para>
9154 #: ../en/ch06-collab.xml:949
9155 msgid ""
9156 "If you don't have a strong stomach for tweaking configurations over and over, "
9157 "or a compelling need to host your own services, you might want to try one of "
9158 "the public hosting services that I mentioned earlier."
9159 msgstr ""
9161 #. type: Content of: <book><chapter><sect1><sect2><title>
9162 #: ../en/ch06-collab.xml:956
9163 msgid "Web server configuration checklist"
9164 msgstr "Web 服务器配置检查表"
9166 #. type: Content of: <book><chapter><sect1><sect2><para>
9167 #: ../en/ch06-collab.xml:958
9168 msgid ""
9169 "Before you continue, do take a few moments to check a few aspects of your "
9170 "system's setup."
9171 msgstr ""
9173 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
9174 #: ../en/ch06-collab.xml:962
9175 msgid ""
9176 "Do you have a web server installed at all? Mac OS X and some Linux "
9177 "distributions ship with Apache, but many other systems may not have a web "
9178 "server installed."
9179 msgstr ""
9181 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
9182 #: ../en/ch06-collab.xml:967
9183 msgid ""
9184 "If you have a web server installed, is it actually running? On most systems, "
9185 "even if one is present, it will be disabled by default."
9186 msgstr ""
9188 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
9189 #: ../en/ch06-collab.xml:971
9190 msgid ""
9191 "Is your server configured to allow you to run CGI programs in the directory "
9192 "where you plan to do so? Most servers default to explicitly disabling the "
9193 "ability to run CGI programs."
9194 msgstr ""
9196 #. type: Content of: <book><chapter><sect1><sect2><para>
9197 #: ../en/ch06-collab.xml:977
9198 msgid ""
9199 "If you don't have a web server installed, and don't have substantial "
9200 "experience configuring Apache, you should consider using the "
9201 "<literal>lighttpd</literal> web server instead of Apache. Apache has a well-"
9202 "deserved reputation for baroque and confusing configuration. While "
9203 "<literal>lighttpd</literal> is less capable in some ways than Apache, most of "
9204 "these capabilities are not relevant to serving Mercurial repositories. And "
9205 "<literal>lighttpd</literal> is undeniably <emphasis>much</emphasis> easier to "
9206 "get started with than Apache."
9207 msgstr ""
9209 #. type: Content of: <book><chapter><sect1><sect2><title>
9210 #: ../en/ch06-collab.xml:990
9211 msgid "Basic CGI configuration"
9212 msgstr "基本 CGI 配置"
9214 #. type: Content of: <book><chapter><sect1><sect2><para>
9215 #: ../en/ch06-collab.xml:992
9216 msgid ""
9217 "On Unix-like systems, it's common for users to have a subdirectory named "
9218 "something like <filename class=\"directory\">public_html</filename> in their "
9219 "home directory, from which they can serve up web pages. A file named "
9220 "<filename>foo</filename> in this directory will be accessible at a URL of the "
9221 "form <literal>http://www.example.com/username/foo</literal>."
9222 msgstr ""
9224 #. type: Content of: <book><chapter><sect1><sect2><para>
9225 #: ../en/ch06-collab.xml:1000
9226 msgid ""
9227 "To get started, find the <filename role=\"special\">hgweb.cgi</filename> "
9228 "script that should be present in your Mercurial installation. If you can't "
9229 "quickly find a local copy on your system, simply download one from the master "
9230 "Mercurial repository at <ulink url=\"http://www.selenic.com/repo/hg/raw-file/"
9231 "tip/hgweb.cgi\">http://www.selenic.com/repo/hg/raw-file/tip/hgweb.cgi</ulink>."
9232 msgstr ""
9234 #. type: Content of: <book><chapter><sect1><sect2><para>
9235 #: ../en/ch06-collab.xml:1007 ../en/ch06-collab.xml:1175
9236 msgid ""
9237 "You'll need to copy this script into your <filename class=\"directory"
9238 "\">public_html</filename> directory, and ensure that it's executable."
9239 msgstr ""
9241 #. type: Content of: <book><chapter><sect1><sect2><para>
9242 #: ../en/ch06-collab.xml:1012
9243 msgid ""
9244 "The <literal>755</literal> argument to <command>chmod</command> is a little "
9245 "more general than just making the script executable: it ensures that the "
9246 "script is executable by anyone, and that <quote>group</quote> and "
9247 "<quote>other</quote> write permissions are <emphasis>not</emphasis> set. If "
9248 "you were to leave those write permissions enabled, Apache's <literal>suexec</"
9249 "literal> subsystem would likely refuse to execute the script. In fact, "
9250 "<literal>suexec</literal> also insists that the <emphasis>directory</"
9251 "emphasis> in which the script resides must not be writable by others."
9252 msgstr ""
9254 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
9255 #: ../en/ch06-collab.xml:1026
9256 msgid "What could <emphasis>possibly</emphasis> go wrong?"
9257 msgstr "什么<emphasis>可能</emphasis>会出错?"
9259 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9260 #: ../en/ch06-collab.xml:1029
9261 msgid ""
9262 "Once you've copied the CGI script into place, go into a web browser, and try "
9263 "to open the URL <literal>http://myhostname/~myuser/hgweb.cgi</literal>, "
9264 "<emphasis>but</emphasis> brace yourself for instant failure. There's a high "
9265 "probability that trying to visit this URL will fail, and there are many "
9266 "possible reasons for this. In fact, you're likely to stumble over almost "
9267 "every one of the possible errors below, so please read carefully. The "
9268 "following are all of the problems I ran into on a system running Fedora 7, "
9269 "with a fresh installation of Apache, and a user account that I created "
9270 "specially to perform this exercise."
9271 msgstr ""
9273 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9274 #: ../en/ch06-collab.xml:1042
9275 msgid ""
9276 "Your web server may have per-user directories disabled. If you're using "
9277 "Apache, search your config file for a <literal>UserDir</literal> directive. "
9278 "If there's none present, per-user directories will be disabled. If one "
9279 "exists, but its value is <literal>disabled</literal>, then per-user "
9280 "directories will be disabled. Otherwise, the string after <literal>UserDir</"
9281 "literal> gives the name of the subdirectory that Apache will look in under "
9282 "your home directory, for example <filename class=\"directory\">public_html</"
9283 "filename>."
9284 msgstr ""
9286 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9287 #: ../en/ch06-collab.xml:1053
9288 msgid ""
9289 "Your file access permissions may be too restrictive. The web server must be "
9290 "able to traverse your home directory and directories under your <filename "
9291 "class=\"directory\">public_html</filename> directory, and read files under "
9292 "the latter too. Here's a quick recipe to help you to make your permissions "
9293 "more appropriate."
9294 msgstr ""
9296 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9297 #: ../en/ch06-collab.xml:1063
9298 msgid ""
9299 "The other possibility with permissions is that you might get a completely "
9300 "empty window when you try to load the script. In this case, it's likely that "
9301 "your access permissions are <emphasis>too permissive</emphasis>. Apache's "
9302 "<literal>suexec</literal> subsystem won't execute a script that's group- or "
9303 "world-writable, for example."
9304 msgstr ""
9306 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9307 #: ../en/ch06-collab.xml:1070
9308 msgid ""
9309 "Your web server may be configured to disallow execution of CGI programs in "
9310 "your per-user web directory. Here's Apache's default per-user configuration "
9311 "from my Fedora system."
9312 msgstr ""
9314 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9315 #: ../en/ch06-collab.xml:1077
9316 msgid ""
9317 "If you find a similar-looking <literal>Directory</literal> group in your "
9318 "Apache configuration, the directive to look at inside it is <literal>Options</"
9319 "literal>. Add <literal>ExecCGI</literal> to the end of this list if it's "
9320 "missing, and restart the web server."
9321 msgstr ""
9323 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9324 #: ../en/ch06-collab.xml:1084
9325 msgid ""
9326 "If you find that Apache serves you the text of the CGI script instead of "
9327 "executing it, you may need to either uncomment (if already present) or add a "
9328 "directive like this."
9329 msgstr ""
9331 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9332 #: ../en/ch06-collab.xml:1090
9333 msgid ""
9334 "The next possibility is that you might be served with a colourful Python "
9335 "backtrace claiming that it can't import a <literal>mercurial</literal>-"
9336 "related module. This is actually progress! The server is now capable of "
9337 "executing your CGI script. This error is only likely to occur if you're "
9338 "running a private installation of Mercurial, instead of a system-wide "
9339 "version. Remember that the web server runs the CGI program without any of "
9340 "the environment variables that you take for granted in an interactive "
9341 "session. If this error happens to you, edit your copy of <filename role="
9342 "\"special\">hgweb.cgi</filename> and follow the directions inside it to "
9343 "correctly set your <envar>PYTHONPATH</envar> environment variable."
9344 msgstr ""
9346 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9347 #: ../en/ch06-collab.xml:1104
9348 msgid ""
9349 "Finally, you are <emphasis>certain</emphasis> to be served with another "
9350 "colourful Python backtrace: this one will complain that it can't find "
9351 "<filename class=\"directory\">/path/to/repository</filename>. Edit your "
9352 "<filename role=\"special\">hgweb.cgi</filename> script and replace the "
9353 "<filename class=\"directory\">/path/to/repository</filename> string with the "
9354 "complete path to the repository you want to serve up."
9355 msgstr ""
9357 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9358 #: ../en/ch06-collab.xml:1114
9359 msgid ""
9360 "At this point, when you try to reload the page, you should be presented with "
9361 "a nice HTML view of your repository's history. Whew!"
9362 msgstr ""
9364 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
9365 #: ../en/ch06-collab.xml:1120
9366 msgid "Configuring lighttpd"
9367 msgstr "配置 lighttpd"
9369 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9370 #: ../en/ch06-collab.xml:1122
9371 msgid ""
9372 "To be exhaustive in my experiments, I tried configuring the increasingly "
9373 "popular <literal>lighttpd</literal> web server to serve the same repository "
9374 "as I described with Apache above. I had already overcome all of the problems "
9375 "I outlined with Apache, many of which are not server-specific. As a result, "
9376 "I was fairly sure that my file and directory permissions were good, and that "
9377 "my <filename role=\"special\">hgweb.cgi</filename> script was properly edited."
9378 msgstr ""
9380 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9381 #: ../en/ch06-collab.xml:1132
9382 msgid ""
9383 "Once I had Apache running, getting <literal>lighttpd</literal> to serve the "
9384 "repository was a snap (in other words, even if you're trying to use "
9385 "<literal>lighttpd</literal>, you should read the Apache section). I first "
9386 "had to edit the <literal>mod_access</literal> section of its config file to "
9387 "enable <literal>mod_cgi</literal> and <literal>mod_userdir</literal>, both of "
9388 "which were disabled by default on my system. I then added a few lines to the "
9389 "end of the config file, to configure these modules."
9390 msgstr ""
9392 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9393 #: ../en/ch06-collab.xml:1144
9394 msgid ""
9395 "With this done, <literal>lighttpd</literal> ran immediately for me. If I had "
9396 "configured <literal>lighttpd</literal> before Apache, I'd almost certainly "
9397 "have run into many of the same system-level configuration problems as I did "
9398 "with Apache. However, I found <literal>lighttpd</literal> to be noticeably "
9399 "easier to configure than Apache, even though I've used Apache for over a "
9400 "decade, and this was my first exposure to <literal>lighttpd</literal>."
9401 msgstr ""
9403 #. type: Content of: <book><chapter><sect1><sect2><title>
9404 #: ../en/ch06-collab.xml:1157
9405 msgid "Sharing multiple repositories with one CGI script"
9406 msgstr "使用一个 CGI 脚本共享多个版本库"
9408 #. type: Content of: <book><chapter><sect1><sect2><para>
9409 #: ../en/ch06-collab.xml:1159
9410 msgid ""
9411 "The <filename role=\"special\">hgweb.cgi</filename> script only lets you "
9412 "publish a single repository, which is an annoying restriction. If you want "
9413 "to publish more than one without wracking yourself with multiple copies of "
9414 "the same script, each with different names, a better choice is to use the "
9415 "<filename role=\"special\">hgwebdir.cgi</filename> script."
9416 msgstr ""
9418 #. type: Content of: <book><chapter><sect1><sect2><para>
9419 #: ../en/ch06-collab.xml:1167
9420 msgid ""
9421 "The procedure to configure <filename role=\"special\">hgwebdir.cgi</filename> "
9422 "is only a little more involved than for <filename role=\"special\">hgweb.cgi</"
9423 "filename>. First, you must obtain a copy of the script. If you don't have "
9424 "one handy, you can download a copy from the master Mercurial repository at "
9425 "<ulink url=\"http://www.selenic.com/repo/hg/raw-file/tip/hgwebdir.cgi"
9426 "\">http://www.selenic.com/repo/hg/raw-file/tip/hgwebdir.cgi</ulink>."
9427 msgstr ""
9429 #. type: Content of: <book><chapter><sect1><sect2><para>
9430 #: ../en/ch06-collab.xml:1182
9431 msgid ""
9432 "With basic configuration out of the way, try to visit <literal>http://"
9433 "myhostname/~myuser/hgwebdir.cgi</literal> in your\tbrowser. It should "
9434 "display an empty list of repositories. If you get a blank window or error "
9435 "message, try walking through the list of potential problems in <xref linkend="
9436 "\"sec:collab:wtf\"/>."
9437 msgstr ""
9439 #. type: Content of: <book><chapter><sect1><sect2><para>
9440 #: ../en/ch06-collab.xml:1190
9441 msgid ""
9442 "The <filename role=\"special\">hgwebdir.cgi</filename> script relies on an "
9443 "external configuration file. By default, it searches for a file named "
9444 "<filename role=\"special\">hgweb.config</filename> in the same directory as "
9445 "itself. You'll need to create this file, and make it world-readable. The "
9446 "format of the file is similar to a Windows <quote>ini</quote> file, as "
9447 "understood by Python's <literal>ConfigParser</literal> <citation>web:"
9448 "configparser</citation> module."
9449 msgstr ""
9451 #. type: Content of: <book><chapter><sect1><sect2><para>
9452 #: ../en/ch06-collab.xml:1200
9453 msgid ""
9454 "The easiest way to configure <filename role=\"special\">hgwebdir.cgi</"
9455 "filename> is with a section named <literal>collections</literal>. This will "
9456 "automatically publish <emphasis>every</emphasis> repository under the "
9457 "directories you name. The section should look like this:"
9458 msgstr ""
9460 #. type: Content of: <book><chapter><sect1><sect2><para>
9461 #: ../en/ch06-collab.xml:1208
9462 msgid ""
9463 "Mercurial interprets this by looking at the directory name on the "
9464 "<emphasis>right</emphasis> hand side of the <quote><literal>=</literal></"
9465 "quote> sign; finding repositories in that directory hierarchy; and using the "
9466 "text on the <emphasis>left</emphasis> to strip off matching text from the "
9467 "names it will actually list in the web interface. The remaining component of "
9468 "a path after this stripping has occurred is called a <quote>virtual path</"
9469 "quote>."
9470 msgstr ""
9472 #. type: Content of: <book><chapter><sect1><sect2><para>
9473 #: ../en/ch06-collab.xml:1217
9474 msgid ""
9475 "Given the example above, if we have a repository whose local path is "
9476 "<filename class=\"directory\">/my/root/this/repo</filename>, the CGI script "
9477 "will strip the leading <filename class=\"directory\">/my/root</filename> from "
9478 "the name, and publish the repository with a virtual path of <filename class="
9479 "\"directory\">this/repo</filename>. If the base URL for our CGI script is "
9480 "<literal>http://myhostname/~myuser/hgwebdir.cgi</literal>, the complete URL "
9481 "for that repository will be <literal>http://myhostname/~myuser/hgwebdir.cgi/"
9482 "this/repo</literal>."
9483 msgstr ""
9485 #. type: Content of: <book><chapter><sect1><sect2><para>
9486 #: ../en/ch06-collab.xml:1229
9487 msgid ""
9488 "If we replace <filename class=\"directory\">/my/root</filename> on the left "
9489 "hand side of this example with <filename class=\"directory\">/my</filename>, "
9490 "then <filename role=\"special\">hgwebdir.cgi</filename> will only strip off "
9491 "<filename class=\"directory\">/my</filename> from the repository name, and "
9492 "will give us a virtual path of <filename class=\"directory\">root/this/repo</"
9493 "filename> instead of <filename class=\"directory\">this/repo</filename>."
9494 msgstr ""
9496 #. type: Content of: <book><chapter><sect1><sect2><para>
9497 #: ../en/ch06-collab.xml:1239
9498 msgid ""
9499 "The <filename role=\"special\">hgwebdir.cgi</filename> script will "
9500 "recursively search each directory listed in the <literal>collections</"
9501 "literal> section of its configuration file, but it will <literal>not</"
9502 "literal> recurse into the repositories it finds."
9503 msgstr ""
9505 #. type: Content of: <book><chapter><sect1><sect2><para>
9506 #: ../en/ch06-collab.xml:1245
9507 msgid ""
9508 "The <literal>collections</literal> mechanism makes it easy to publish many "
9509 "repositories in a <quote>fire and forget</quote> manner. You only need to "
9510 "set up the CGI script and configuration file one time. Afterwards, you can "
9511 "publish or unpublish a repository at any time by simply moving it into, or "
9512 "out of, the directory hierarchy in which you've configured <filename role="
9513 "\"special\">hgwebdir.cgi</filename> to look."
9514 msgstr ""
9516 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
9517 #: ../en/ch06-collab.xml:1255
9518 msgid "Explicitly specifying which repositories to publish"
9519 msgstr "明确指出要发布的版本库"
9521 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9522 #: ../en/ch06-collab.xml:1258
9523 msgid ""
9524 "In addition to the <literal>collections</literal> mechanism, the <filename "
9525 "role=\"special\">hgwebdir.cgi</filename> script allows you to publish a "
9526 "specific list of repositories. To do so, create a <literal>paths</literal> "
9527 "section, with contents of the following form."
9528 msgstr ""
9530 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9531 #: ../en/ch06-collab.xml:1267
9532 msgid ""
9533 "In this case, the virtual path (the component that will appear in a URL) is "
9534 "on the left hand side of each definition, while the path to the repository is "
9535 "on the right. Notice that there does not need to be any relationship between "
9536 "the virtual path you choose and the location of a repository in your "
9537 "filesystem."
9538 msgstr ""
9540 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9541 #: ../en/ch06-collab.xml:1274
9542 msgid ""
9543 "If you wish, you can use both the <literal>collections</literal> and "
9544 "<literal>paths</literal> mechanisms simultaneously in a single configuration "
9545 "file."
9546 msgstr ""
9548 #. type: Content of: <book><chapter><sect1><sect2><sect3><note><title>
9549 #: ../en/ch06-collab.xml:1280
9550 msgid "Beware duplicate virtual paths"
9551 msgstr ""
9553 #. type: Content of: <book><chapter><sect1><sect2><sect3><note><para>
9554 #: ../en/ch06-collab.xml:1282
9555 msgid ""
9556 "If several repositories have the same virtual path, <filename role=\"special"
9557 "\">hgwebdir.cgi</filename> will not report an error. Instead, it will behave "
9558 "unpredictably."
9559 msgstr ""
9561 #. type: Content of: <book><chapter><sect1><sect2><title>
9562 #: ../en/ch06-collab.xml:1291
9563 msgid "Downloading source archives"
9564 msgstr "下载源代码档案包"
9566 #. type: Content of: <book><chapter><sect1><sect2><para>
9567 #: ../en/ch06-collab.xml:1293
9568 msgid ""
9569 "Mercurial's web interface lets users download an archive of any revision. "
9570 "This archive will contain a snapshot of the working directory as of that "
9571 "revision, but it will not contain a copy of the repository data."
9572 msgstr ""
9574 #. type: Content of: <book><chapter><sect1><sect2><para>
9575 #: ../en/ch06-collab.xml:1298
9576 msgid ""
9577 "By default, this feature is not enabled. To enable it, you'll need to add an "
9578 "<envar role=\"rc-item-web\">allow_archive</envar> item to the <literal role="
9579 "\"rc-web\">web</literal> section of your <filename role=\"special\">~/.hgrc</"
9580 "filename>; see below for details."
9581 msgstr ""
9583 #. type: Content of: <book><chapter><sect1><sect2><title>
9584 #: ../en/ch06-collab.xml:1305
9585 msgid "Web configuration options"
9586 msgstr "Web 配置选项"
9588 #. type: Content of: <book><chapter><sect1><sect2><para>
9589 #: ../en/ch06-collab.xml:1307
9590 msgid ""
9591 "Mercurial's web interfaces (the <command role=\"hg-cmd\">hg serve</command> "
9592 "command, and the <filename role=\"special\">hgweb.cgi</filename> and "
9593 "<filename role=\"special\">hgwebdir.cgi</filename> scripts) have a number of "
9594 "configuration options that you can set. These belong in a section named "
9595 "<literal role=\"rc-web\">web</literal>."
9596 msgstr ""
9598 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9599 #: ../en/ch06-collab.xml:1315
9600 msgid ""
9601 "<envar role=\"rc-item-web\">allow_archive</envar>: Determines which (if any) "
9602 "archive download mechanisms Mercurial supports. If you enable this feature, "
9603 "users of the web interface will be able to download an archive of whatever "
9604 "revision of a repository they are viewing. To enable the archive feature, "
9605 "this item must take the form of a sequence of words drawn from the list below."
9606 msgstr ""
9608 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
9609 #: ../en/ch06-collab.xml:1324
9610 msgid ""
9611 "<literal>bz2</literal>: A <command>tar</command> archive, compressed using "
9612 "<literal>bzip2</literal> compression. This has the best compression ratio, "
9613 "but uses the most CPU time on the server."
9614 msgstr ""
9616 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
9617 #: ../en/ch06-collab.xml:1330
9618 msgid ""
9619 "<literal>gz</literal>: A <command>tar</command> archive, compressed using "
9620 "<literal>gzip</literal> compression."
9621 msgstr ""
9623 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
9624 #: ../en/ch06-collab.xml:1334
9625 msgid ""
9626 "<literal>zip</literal>: A <command>zip</command> archive, compressed using "
9627 "LZW compression. This format has the worst compression ratio, but is widely "
9628 "used in the Windows world."
9629 msgstr ""
9631 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9632 #: ../en/ch06-collab.xml:1340
9633 msgid ""
9634 "If you provide an empty list, or don't have an <envar role=\"rc-item-web"
9635 "\">allow_archive</envar> entry at all, this feature will be disabled. Here "
9636 "is an example of how to enable all three supported formats."
9637 msgstr ""
9639 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9640 #: ../en/ch06-collab.xml:1347
9641 msgid ""
9642 "<envar role=\"rc-item-web\">allowpull</envar>: Boolean. Determines whether "
9643 "the web interface allows remote users to <command role=\"hg-cmd\">hg pull</"
9644 "command> and <command role=\"hg-cmd\">hg clone</command> this repository over "
9645 "HTTP. If set to <literal>no</literal> or <literal>false</literal>, only the "
9646 "<quote>human-oriented</quote> portion of the web interface is available."
9647 msgstr ""
9649 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9650 #: ../en/ch06-collab.xml:1356
9651 msgid ""
9652 "<envar role=\"rc-item-web\">contact</envar>: String. A free-form (but "
9653 "preferably brief) string identifying the person or group in charge of the "
9654 "repository. This often contains the name and email address of a person or "
9655 "mailing list. It often makes sense to place this entry in a repository's own "
9656 "<filename role=\"special\">.hg/hgrc</filename> file, but it can make sense to "
9657 "use in a global <filename role=\"special\">~/.hgrc</filename> if every "
9658 "repository has a single maintainer."
9659 msgstr ""
9661 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9662 #: ../en/ch06-collab.xml:1367
9663 msgid ""
9664 "<envar role=\"rc-item-web\">maxchanges</envar>: Integer. The default maximum "
9665 "number of changesets to display in a single page of output."
9666 msgstr ""
9668 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9669 #: ../en/ch06-collab.xml:1371
9670 msgid ""
9671 "<envar role=\"rc-item-web\">maxfiles</envar>: Integer. The default maximum "
9672 "number of modified files to display in a single page of output."
9673 msgstr ""
9675 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9676 #: ../en/ch06-collab.xml:1375
9677 msgid ""
9678 "<envar role=\"rc-item-web\">stripes</envar>: Integer. If the web interface "
9679 "displays alternating <quote>stripes</quote> to make it easier to visually "
9680 "align rows when you are looking at a table, this number controls the number "
9681 "of rows in each stripe."
9682 msgstr ""
9684 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9685 #: ../en/ch06-collab.xml:1381
9686 msgid ""
9687 "<envar role=\"rc-item-web\">style</envar>: Controls the template Mercurial "
9688 "uses to display the web interface. Mercurial ships with several web "
9689 "templates."
9690 msgstr ""
9692 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
9693 #: ../en/ch06-collab.xml:1387
9694 msgid "<literal>coal</literal> is monochromatic."
9695 msgstr ""
9697 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
9698 #: ../en/ch06-collab.xml:1390
9699 msgid ""
9700 "<literal>gitweb</literal> emulates the visual style of git's web interface."
9701 msgstr ""
9703 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
9704 #: ../en/ch06-collab.xml:1394
9705 msgid "<literal>monoblue</literal> uses solid blues and greys."
9706 msgstr ""
9708 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
9709 #: ../en/ch06-collab.xml:1398
9710 msgid "<literal>paper</literal> is the default."
9711 msgstr ""
9713 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
9714 #: ../en/ch06-collab.xml:1401
9715 msgid "<literal>spartan</literal> was the default for a long time."
9716 msgstr ""
9718 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9719 #: ../en/ch06-collab.xml:1405
9720 msgid ""
9721 "You can also specify a custom template of your own; see <xref linkend=\"chap:"
9722 "template\"/> for details. Here, you can see how to enable the "
9723 "<literal>gitweb</literal> style."
9724 msgstr ""
9726 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9727 #: ../en/ch06-collab.xml:1413
9728 msgid ""
9729 "<envar role=\"rc-item-web\">templates</envar>: Path. The directory in which "
9730 "to search for template files. By default, Mercurial searches in the "
9731 "directory in which it was installed."
9732 msgstr ""
9734 #. type: Content of: <book><chapter><sect1><sect2><para>
9735 #: ../en/ch06-collab.xml:1418
9736 msgid ""
9737 "If you are using <filename role=\"special\">hgwebdir.cgi</filename>, you can "
9738 "place a few configuration items in a <literal role=\"rc-web\">web</literal> "
9739 "section of the <filename role=\"special\">hgweb.config</filename> file "
9740 "instead of a <filename role=\"special\">~/.hgrc</filename> file, for "
9741 "convenience. These items are <envar role=\"rc-item-web\">motd</envar> and "
9742 "<envar role=\"rc-item-web\">style</envar>."
9743 msgstr ""
9745 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
9746 #: ../en/ch06-collab.xml:1429
9747 msgid "Options specific to an individual repository"
9748 msgstr "针对单个版本库的选项"
9750 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9751 #: ../en/ch06-collab.xml:1431
9752 msgid ""
9753 "A few <literal role=\"rc-web\">web</literal> configuration items ought to be "
9754 "placed in a repository's local <filename role=\"special\">.hg/hgrc</"
9755 "filename>, rather than a user's or global <filename role=\"special\">~/.hgrc</"
9756 "filename>."
9757 msgstr ""
9759 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
9760 #: ../en/ch06-collab.xml:1436
9761 msgid ""
9762 "<envar role=\"rc-item-web\">description</envar>: String. A free-form (but "
9763 "preferably brief) string that describes the contents or purpose of the "
9764 "repository."
9765 msgstr ""
9767 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
9768 #: ../en/ch06-collab.xml:1441
9769 msgid ""
9770 "<envar role=\"rc-item-web\">name</envar>: String. The name to use for the "
9771 "repository in the web interface. This overrides the default name, which is "
9772 "the last component of the repository's path."
9773 msgstr ""
9775 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
9776 #: ../en/ch06-collab.xml:1449
9777 msgid ""
9778 "Options specific to the <command role=\"hg-cmd\">hg serve</command> command"
9779 msgstr "命令 <command role=\"hg-cmd\">hg serve</command> 的选项"
9781 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9782 #: ../en/ch06-collab.xml:1452
9783 msgid ""
9784 "Some of the items in the <literal role=\"rc-web\">web</literal> section of a "
9785 "<filename role=\"special\">~/.hgrc</filename> file are only for use with the "
9786 "<command role=\"hg-cmd\">hg serve</command> command."
9787 msgstr ""
9789 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
9790 #: ../en/ch06-collab.xml:1458
9791 msgid ""
9792 "<envar role=\"rc-item-web\">accesslog</envar>: Path. The name of a file into "
9793 "which to write an access log. By default, the <command role=\"hg-cmd\">hg "
9794 "serve</command> command writes this information to standard output, not to a "
9795 "file. Log entries are written in the standard <quote>combined</quote> file "
9796 "format used by almost all web servers."
9797 msgstr ""
9799 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
9800 #: ../en/ch06-collab.xml:1466
9801 msgid ""
9802 "<envar role=\"rc-item-web\">address</envar>: String. The local address on "
9803 "which the server should listen for incoming connections. By default, the "
9804 "server listens on all addresses."
9805 msgstr ""
9807 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
9808 #: ../en/ch06-collab.xml:1471
9809 msgid ""
9810 "<envar role=\"rc-item-web\">errorlog</envar>: Path. The name of a file into "
9811 "which to write an error log. By default, the <command role=\"hg-cmd\">hg "
9812 "serve</command> command writes this information to standard error, not to a "
9813 "file."
9814 msgstr ""
9816 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
9817 #: ../en/ch06-collab.xml:1477
9818 msgid ""
9819 "<envar role=\"rc-item-web\">ipv6</envar>: Boolean. Whether to use the IPv6 "
9820 "protocol. By default, IPv6 is not used."
9821 msgstr ""
9823 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
9824 #: ../en/ch06-collab.xml:1481
9825 msgid ""
9826 "<envar role=\"rc-item-web\">port</envar>: Integer. The TCP port number on "
9827 "which the server should listen. The default port number used is 8000."
9828 msgstr ""
9830 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
9831 #: ../en/ch06-collab.xml:1488
9832 msgid ""
9833 "Choosing the right <filename role=\"special\">~/.hgrc</filename> file to add "
9834 "<literal role=\"rc-web\">web</literal> items to"
9835 msgstr ""
9836 "选择正确的 <filename role=\"special\"> ~/.hgrc</filename> 文件增加到 <literal "
9837 "role=\"rc-web\">web</literal> 条目"
9839 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9840 #: ../en/ch06-collab.xml:1492
9841 msgid ""
9842 "It is important to remember that a web server like Apache or "
9843 "<literal>lighttpd</literal> will run under a user ID that is different to "
9844 "yours. CGI scripts run by your server, such as <filename role=\"special"
9845 "\">hgweb.cgi</filename>, will usually also run under that user ID."
9846 msgstr ""
9848 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9849 #: ../en/ch06-collab.xml:1499
9850 msgid ""
9851 "If you add <literal role=\"rc-web\">web</literal> items to your own personal "
9852 "<filename role=\"special\">~/.hgrc</filename> file, CGI scripts won't read "
9853 "that <filename role=\"special\">~/.hgrc</filename> file. Those settings will "
9854 "thus only affect the behavior of the <command role=\"hg-cmd\">hg serve</"
9855 "command> command when you run it. To cause CGI scripts to see your settings, "
9856 "either create a <filename role=\"special\">~/.hgrc</filename> file in the "
9857 "home directory of the user ID that runs your web server, or add those "
9858 "settings to a system-wide <filename role=\"special\">hgrc</filename> file."
9859 msgstr ""
9861 #. type: Content of: <book><chapter><sect1><title>
9862 #: ../en/ch06-collab.xml:1514
9863 msgid "System-wide configuration"
9864 msgstr "全局配置"
9866 #. type: Content of: <book><chapter><sect1><para>
9867 #: ../en/ch06-collab.xml:1516
9868 msgid ""
9869 "On Unix-like systems shared by multiple users (such as a server to which "
9870 "people publish changes), it often makes sense to set up some global default "
9871 "behaviors, such as what theme to use in web interfaces."
9872 msgstr ""
9874 #. type: Content of: <book><chapter><sect1><para>
9875 #: ../en/ch06-collab.xml:1521
9876 msgid ""
9877 "If a file named <filename>/etc/mercurial/hgrc</filename> exists, Mercurial "
9878 "will read it at startup time and apply any configuration settings it finds in "
9879 "that file. It will also look for files ending in a <literal>.rc</literal> "
9880 "extension in a directory named <filename>/etc/mercurial/hgrc.d</filename>, "
9881 "and apply any configuration settings it finds in each of those files."
9882 msgstr ""
9884 #. type: Content of: <book><chapter><sect1><sect2><title>
9885 #: ../en/ch06-collab.xml:1530
9886 msgid "Making Mercurial more trusting"
9887 msgstr "让 Mercurial 更可信"
9889 #. type: Content of: <book><chapter><sect1><sect2><para>
9890 #: ../en/ch06-collab.xml:1532
9891 msgid ""
9892 "One situation in which a global <filename>hgrc</filename> can be useful is if "
9893 "users are pulling changes owned by other users. By default, Mercurial will "
9894 "not trust most of the configuration items in a <filename>.hg/hgrc</filename> "
9895 "file inside a repository that is owned by a different user. If we clone or "
9896 "pull changes from such a repository, Mercurial will print a warning stating "
9897 "that it does not trust their <filename>.hg/hgrc</filename>."
9898 msgstr ""
9900 #. type: Content of: <book><chapter><sect1><sect2><para>
9901 #: ../en/ch06-collab.xml:1541
9902 msgid ""
9903 "If everyone in a particular Unix group is on the same team and "
9904 "<emphasis>should</emphasis> trust each other's configuration settings, or we "
9905 "want to trust particular users, we can override Mercurial's skeptical "
9906 "defaults by creating a system-wide <filename>hgrc</filename> file such as the "
9907 "following:"
9908 msgstr ""
9910 #. type: Content of: <book><chapter><title>
9911 #: ../en/ch07-filenames.xml:5
9912 msgid "File names and pattern matching"
9913 msgstr "文件名称与模式匹配"
9915 #. type: Content of: <book><chapter><para>
9916 #: ../en/ch07-filenames.xml:7
9917 msgid ""
9918 "Mercurial provides mechanisms that let you work with file names in a "
9919 "consistent and expressive way."
9920 msgstr ""
9922 #. type: Content of: <book><chapter><sect1><title>
9923 #: ../en/ch07-filenames.xml:11
9924 msgid "Simple file naming"
9925 msgstr "简单文件名称"
9927 #. type: Content of: <book><chapter><sect1><para>
9928 #: ../en/ch07-filenames.xml:13
9929 msgid ""
9930 "Mercurial uses a unified piece of machinery <quote>under the hood</quote> to "
9931 "handle file names. Every command behaves uniformly with respect to file "
9932 "names. The way in which commands work with file names is as follows."
9933 msgstr ""
9935 #. type: Content of: <book><chapter><sect1><para>
9936 #: ../en/ch07-filenames.xml:18
9937 msgid ""
9938 "If you explicitly name real files on the command line, Mercurial works with "
9939 "exactly those files, as you would expect. &interaction.filenames.files;"
9940 msgstr ""
9943 #. type: Content of: <book><chapter><sect1><para>
9944 #: ../en/ch07-filenames.xml:22
9945 msgid ""
9946 "When you provide a directory name, Mercurial will interpret this as "
9947 "<quote>operate on every file in this directory and its subdirectories</"
9948 "quote>. Mercurial traverses the files and subdirectories in a directory in "
9949 "alphabetical order. When it encounters a subdirectory, it will traverse that "
9950 "subdirectory before continuing with the current directory."
9951 msgstr ""
9953 #. type: Content of: <book><chapter><sect1><title>
9954 #: ../en/ch07-filenames.xml:33
9955 msgid "Running commands without any file names"
9956 msgstr "不提供文件名称的执行命令"
9958 #. type: Content of: <book><chapter><sect1><para>
9959 #: ../en/ch07-filenames.xml:35
9960 msgid ""
9961 "Mercurial's commands that work with file names have useful default behaviors "
9962 "when you invoke them without providing any file names or patterns. What kind "
9963 "of behavior you should expect depends on what the command does. Here are a "
9964 "few rules of thumb you can use to predict what a command is likely to do if "
9965 "you don't give it any names to work with."
9966 msgstr ""
9968 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
9969 #: ../en/ch07-filenames.xml:42
9970 msgid ""
9971 "Most commands will operate on the entire working directory. This is what the "
9972 "<command role=\"hg-cmd\">hg add</command> command does, for example."
9973 msgstr ""
9975 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
9976 #: ../en/ch07-filenames.xml:46
9977 msgid ""
9978 "If the command has effects that are difficult or impossible to reverse, it "
9979 "will force you to explicitly provide at least one name or pattern (see "
9980 "below). This protects you from accidentally deleting files by running "
9981 "<command role=\"hg-cmd\">hg remove</command> with no arguments, for example."
9982 msgstr ""
9984 #. type: Content of: <book><chapter><sect1><para>
9985 #: ../en/ch07-filenames.xml:54
9986 msgid ""
9987 "It's easy to work around these default behaviors if they don't suit you. If "
9988 "a command normally operates on the whole working directory, you can invoke it "
9989 "on just the current directory and its subdirectories by giving it the name "
9990 "<quote><filename class=\"directory\">.</filename></quote>."
9991 msgstr ""
9994 #. type: Content of: <book><chapter><sect1><para>
9995 #: ../en/ch07-filenames.xml:62
9996 msgid ""
9997 "Along the same lines, some commands normally print file names relative to the "
9998 "root of the repository, even if you're invoking them from a subdirectory. "
9999 "Such a command will print file names relative to your subdirectory if you "
10000 "give it explicit names. Here, we're going to run <command role=\"hg-cmd\">hg "
10001 "status</command> from a subdirectory, and get it to operate on the entire "
10002 "working directory while printing file names relative to our subdirectory, by "
10003 "passing it the output of the <command role=\"hg-cmd\">hg root</command> "
10004 "command."
10005 msgstr ""
10007 #. type: Content of: <book><chapter><sect1><title>
10008 #: ../en/ch07-filenames.xml:76
10009 msgid "Telling you what's going on"
10010 msgstr "告诉你正在做什么"
10012 #. type: Content of: <book><chapter><sect1><para>
10013 #: ../en/ch07-filenames.xml:78
10014 msgid ""
10015 "The <command role=\"hg-cmd\">hg add</command> example in the preceding "
10016 "section illustrates something else that's helpful about Mercurial commands. "
10017 "If a command operates on a file that you didn't name explicitly on the "
10018 "command line, it will usually print the name of the file, so that you will "
10019 "not be surprised what's going on."
10020 msgstr ""
10022 #. type: Content of: <book><chapter><sect1><para>
10023 #: ../en/ch07-filenames.xml:85
10024 msgid ""
10025 "The principle here is of <emphasis>least surprise</emphasis>. If you've "
10026 "exactly named a file on the command line, there's no point in repeating it "
10027 "back at you. If Mercurial is acting on a file <emphasis>implicitly</"
10028 "emphasis>, e.g. because you provided no names, or a directory, or a pattern "
10029 "(see below), it is safest to tell you what files it's operating on."
10030 msgstr ""
10032 #. type: Content of: <book><chapter><sect1><para>
10033 #: ../en/ch07-filenames.xml:92
10034 msgid ""
10035 "For commands that behave this way, you can silence them using the <option "
10036 "role=\"hg-opt-global\">-q</option> option. You can also get them to print "
10037 "the name of every file, even those you've named explicitly, using the <option "
10038 "role=\"hg-opt-global\">-v</option> option."
10039 msgstr ""
10041 #. type: Content of: <book><chapter><sect1><title>
10042 #: ../en/ch07-filenames.xml:100
10043 msgid "Using patterns to identify files"
10044 msgstr "使用模式标识文件"
10046 #. type: Content of: <book><chapter><sect1><para>
10047 #: ../en/ch07-filenames.xml:102
10048 msgid ""
10049 "In addition to working with file and directory names, Mercurial lets you use "
10050 "<emphasis>patterns</emphasis> to identify files. Mercurial's pattern "
10051 "handling is expressive."
10052 msgstr ""
10054 #. type: Content of: <book><chapter><sect1><para>
10055 #: ../en/ch07-filenames.xml:106
10056 msgid ""
10057 "On Unix-like systems (Linux, MacOS, etc.), the job of matching file names to "
10058 "patterns normally falls to the shell. On these systems, you must explicitly "
10059 "tell Mercurial that a name is a pattern. On Windows, the shell does not "
10060 "expand patterns, so Mercurial will automatically identify names that are "
10061 "patterns, and expand them for you."
10062 msgstr ""
10064 #. type: Content of: <book><chapter><sect1><para>
10065 #: ../en/ch07-filenames.xml:113
10066 msgid ""
10067 "To provide a pattern in place of a regular name on the command line, the "
10068 "mechanism is simple:"
10069 msgstr ""
10071 #. type: Content of: <book><chapter><sect1><para>
10072 #: ../en/ch07-filenames.xml:116
10073 msgid ""
10074 "That is, a pattern is identified by a short text string that says what kind "
10075 "of pattern this is, followed by a colon, followed by the actual pattern."
10076 msgstr ""
10078 #. type: Content of: <book><chapter><sect1><para>
10079 #: ../en/ch07-filenames.xml:120
10080 msgid ""
10081 "Mercurial supports two kinds of pattern syntax. The most frequently used is "
10082 "called <literal>glob</literal>; this is the same kind of pattern matching "
10083 "used by the Unix shell, and should be familiar to Windows command prompt "
10084 "users, too."
10085 msgstr ""
10087 #. type: Content of: <book><chapter><sect1><para>
10088 #: ../en/ch07-filenames.xml:125
10089 msgid ""
10090 "When Mercurial does automatic pattern matching on Windows, it uses "
10091 "<literal>glob</literal> syntax. You can thus omit the <quote><literal>glob:</"
10092 "literal></quote> prefix on Windows, but it's safe to use it, too."
10093 msgstr ""
10095 #. type: Content of: <book><chapter><sect1><para>
10096 #: ../en/ch07-filenames.xml:130
10097 msgid ""
10098 "The <literal>re</literal> syntax is more powerful; it lets you specify "
10099 "patterns using regular expressions, also known as regexps."
10100 msgstr ""
10102 #. type: Content of: <book><chapter><sect1><para>
10103 #: ../en/ch07-filenames.xml:134
10104 msgid ""
10105 "By the way, in the examples that follow, notice that I'm careful to wrap all "
10106 "of my patterns in quote characters, so that they won't get expanded by the "
10107 "shell before Mercurial sees them."
10108 msgstr ""
10110 #. type: Content of: <book><chapter><sect1><sect2><title>
10111 #: ../en/ch07-filenames.xml:140
10112 msgid "Shell-style <literal>glob</literal> patterns"
10113 msgstr "外壳风格的 <literal>glob</literal> 模式"
10115 #. type: Content of: <book><chapter><sect1><sect2><para>
10116 #: ../en/ch07-filenames.xml:142
10117 msgid ""
10118 "This is an overview of the kinds of patterns you can use when you're matching "
10119 "on glob patterns."
10120 msgstr ""
10123 #. type: Content of: <book><chapter><sect1><sect2><para>
10124 #: ../en/ch07-filenames.xml:145
10125 msgid ""
10126 "The <quote><literal>*</literal></quote> character matches any string, within "
10127 "a single directory."
10128 msgstr ""
10131 #. type: Content of: <book><chapter><sect1><sect2><para>
10132 #: ../en/ch07-filenames.xml:150
10133 msgid ""
10134 "The <quote><literal>**</literal></quote> pattern matches any string, and "
10135 "crosses directory boundaries. It's not a standard Unix glob token, but it's "
10136 "accepted by several popular Unix shells, and is very useful."
10137 msgstr ""
10140 #. type: Content of: <book><chapter><sect1><sect2><para>
10141 #: ../en/ch07-filenames.xml:157
10142 msgid ""
10143 "The <quote><literal>?</literal></quote> pattern matches any single character."
10144 msgstr ""
10146 #. type: Content of: <book><chapter><sect1><sect2><para>
10147 #: ../en/ch07-filenames.xml:162
10148 msgid ""
10149 "The <quote><literal>[</literal></quote> character begins a "
10150 "<emphasis>character class</emphasis>. This matches any single character "
10151 "within the class. The class ends with a <quote><literal>]</literal></quote> "
10152 "character. A class may contain multiple <emphasis>range</emphasis>s of the "
10153 "form <quote><literal>a-f</literal></quote>, which is shorthand for "
10154 "<quote><literal>abcdef</literal></quote>."
10155 msgstr ""
10157 #. type: Content of: <book><chapter><sect1><sect2><para>
10158 #: ../en/ch07-filenames.xml:172
10159 msgid ""
10160 "If the first character after the <quote><literal>[</literal></quote> in a "
10161 "character class is a <quote><literal>!</literal></quote>, it "
10162 "<emphasis>negates</emphasis> the class, making it match any single character "
10163 "not in the class."
10164 msgstr ""
10166 #. type: Content of: <book><chapter><sect1><sect2><para>
10167 #: ../en/ch07-filenames.xml:178
10168 msgid ""
10169 "A <quote><literal>{</literal></quote> begins a group of subpatterns, where "
10170 "the whole group matches if any subpattern in the group matches. The "
10171 "<quote><literal>,</literal></quote> character separates subpatterns, and "
10172 "<quote><literal>}</literal></quote> ends the group."
10173 msgstr ""
10175 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
10176 #: ../en/ch07-filenames.xml:187
10177 msgid "Watch out!"
10178 msgstr "千万小心!"
10181 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
10182 #: ../en/ch07-filenames.xml:189
10183 msgid ""
10184 "Don't forget that if you want to match a pattern in any directory, you should "
10185 "not be using the <quote><literal>*</literal></quote> match-any token, as this "
10186 "will only match within one directory. Instead, use the <quote><literal>**</"
10187 "literal></quote> token. This small example illustrates the difference "
10188 "between the two."
10189 msgstr ""
10191 #. type: Content of: <book><chapter><sect1><sect2><title>
10192 #: ../en/ch07-filenames.xml:201
10193 msgid "Regular expression matching with <literal>re</literal> patterns"
10194 msgstr "使用 <literal>re</literal> 模式的正则表达式匹配"
10196 #. type: Content of: <book><chapter><sect1><sect2><para>
10197 #: ../en/ch07-filenames.xml:204
10198 msgid ""
10199 "Mercurial accepts the same regular expression syntax as the Python "
10200 "programming language (it uses Python's regexp engine internally). This is "
10201 "based on the Perl language's regexp syntax, which is the most popular dialect "
10202 "in use (it's also used in Java, for example)."
10203 msgstr ""
10205 #. type: Content of: <book><chapter><sect1><sect2><para>
10206 #: ../en/ch07-filenames.xml:210
10207 msgid ""
10208 "I won't discuss Mercurial's regexp dialect in any detail here, as regexps are "
10209 "not often used. Perl-style regexps are in any case already exhaustively "
10210 "documented on a multitude of web sites, and in many books. Instead, I will "
10211 "focus here on a few things you should know if you find yourself needing to "
10212 "use regexps with Mercurial."
10213 msgstr ""
10215 #. type: Content of: <book><chapter><sect1><sect2><para>
10216 #: ../en/ch07-filenames.xml:217
10217 msgid ""
10218 "A regexp is matched against an entire file name, relative to the root of the "
10219 "repository. In other words, even if you're already in subbdirectory "
10220 "<filename class=\"directory\">foo</filename>, if you want to match files "
10221 "under this directory, your pattern must start with <quote><literal>foo/</"
10222 "literal></quote>."
10223 msgstr ""
10225 #. type: Content of: <book><chapter><sect1><sect2><para>
10226 #: ../en/ch07-filenames.xml:224
10227 msgid ""
10228 "One thing to note, if you're familiar with Perl-style regexps, is that "
10229 "Mercurial's are <emphasis>rooted</emphasis>. That is, a regexp starts "
10230 "matching against the beginning of a string; it doesn't look for a match "
10231 "anywhere within the string. To match anywhere in a string, start your "
10232 "pattern with <quote><literal>.*</literal></quote>."
10233 msgstr ""
10235 #. type: Content of: <book><chapter><sect1><title>
10236 #: ../en/ch07-filenames.xml:234
10237 msgid "Filtering files"
10238 msgstr "过滤文件"
10240 #. type: Content of: <book><chapter><sect1><para>
10241 #: ../en/ch07-filenames.xml:236
10242 msgid ""
10243 "Not only does Mercurial give you a variety of ways to specify files; it lets "
10244 "you further winnow those files using <emphasis>filters</emphasis>. Commands "
10245 "that work with file names accept two filtering options."
10246 msgstr ""
10248 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10249 #: ../en/ch07-filenames.xml:241
10250 msgid ""
10251 "<option role=\"hg-opt-global\">-I</option>, or <option role=\"hg-opt-global"
10252 "\">--include</option>, lets you specify a pattern that file names must match "
10253 "in order to be processed."
10254 msgstr ""
10256 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10257 #: ../en/ch07-filenames.xml:246
10258 msgid ""
10259 "<option role=\"hg-opt-global\">-X</option>, or <option role=\"hg-opt-global"
10260 "\">--exclude</option>, gives you a way to <emphasis>avoid</emphasis> "
10261 "processing files, if they match this pattern."
10262 msgstr ""
10264 #. type: Content of: <book><chapter><sect1><para>
10265 #: ../en/ch07-filenames.xml:251
10266 msgid ""
10267 "You can provide multiple <option role=\"hg-opt-global\">-I</option> and "
10268 "<option role=\"hg-opt-global\">-X</option> options on the command line, and "
10269 "intermix them as you please. Mercurial interprets the patterns you provide "
10270 "using glob syntax by default (but you can use regexps if you need to)."
10271 msgstr ""
10273 #. type: Content of: <book><chapter><sect1><para>
10274 #: ../en/ch07-filenames.xml:258
10275 msgid ""
10276 "You can read a <option role=\"hg-opt-global\">-I</option> filter as "
10277 "<quote>process only the files that match this filter</quote>."
10278 msgstr ""
10280 #. type: Content of: <book><chapter><sect1><para>
10281 #: ../en/ch07-filenames.xml:264
10282 msgid ""
10283 "The <option role=\"hg-opt-global\">-X</option> filter is best read as "
10284 "<quote>process only the files that don't match this pattern</quote>."
10285 msgstr ""
10287 #. type: Content of: <book><chapter><sect1><title>
10288 #: ../en/ch07-filenames.xml:272
10289 msgid "Permanently ignoring unwanted files and directories"
10290 msgstr "始终忽略不需要的文件和目录"
10292 #. type: Content of: <book><chapter><sect1><para>
10293 #: ../en/ch07-filenames.xml:274
10294 msgid ""
10295 "When you create a new repository, the chances are that over time it will grow "
10296 "to contain files that ought to <emphasis>not</emphasis> be managed by "
10297 "Mercurial, but which you don't want to see listed every time you run "
10298 "<command>hg status</command>. For instance, <quote>build products</quote> "
10299 "are files that are created as part of a build but which should not be managed "
10300 "by a revision control system. The most common build products are output "
10301 "files produced by software tools such as compilers. As another example, many "
10302 "text editors litter a directory with lock files, temporary working files, and "
10303 "backup files, which it also makes no sense to manage."
10304 msgstr ""
10306 #. type: Content of: <book><chapter><sect1><para>
10307 #: ../en/ch07-filenames.xml:286
10308 msgid ""
10309 "To have Mercurial permanently ignore such files, create a file named "
10310 "<filename>.hgignore</filename> in the root of your repository. You "
10311 "<emphasis>should</emphasis> <command>hg add</command> this file so that it "
10312 "gets tracked with the rest of your repository contents, since your "
10313 "collaborators will probably find it useful too."
10314 msgstr ""
10316 #. type: Content of: <book><chapter><sect1><para>
10317 #: ../en/ch07-filenames.xml:293
10318 msgid ""
10319 "By default, the <filename>.hgignore</filename> file should contain a list of "
10320 "regular expressions, one per line. Empty lines are skipped. Most people "
10321 "prefer to describe the files they want to ignore using the <quote>glob</"
10322 "quote> syntax that we described above, so a typical <filename>.hgignore</"
10323 "filename> file will start with this directive:"
10324 msgstr ""
10326 #. type: Content of: <book><chapter><sect1><para>
10327 #: ../en/ch07-filenames.xml:302
10328 msgid ""
10329 "This tells Mercurial to interpret the lines that follow as glob patterns, not "
10330 "regular expressions."
10331 msgstr ""
10333 #. type: Content of: <book><chapter><sect1><para>
10334 #: ../en/ch07-filenames.xml:305
10335 msgid "Here is a typical-looking <filename>.hgignore</filename> file."
10336 msgstr ""
10338 #. type: Content of: <book><chapter><sect1><title>
10339 #: ../en/ch07-filenames.xml:329
10340 msgid "Case sensitivity"
10341 msgstr "大小写敏感性"
10343 #. type: Content of: <book><chapter><sect1><para>
10344 #: ../en/ch07-filenames.xml:331
10345 msgid ""
10346 "If you're working in a mixed development environment that contains both Linux "
10347 "(or other Unix) systems and Macs or Windows systems, you should keep in the "
10348 "back of your mind the knowledge that they treat the case (<quote>N</quote> "
10349 "versus <quote>n</quote>) of file names in incompatible ways. This is not "
10350 "very likely to affect you, and it's easy to deal with if it does, but it "
10351 "could surprise you if you don't know about it."
10352 msgstr ""
10354 #. type: Content of: <book><chapter><sect1><para>
10355 #: ../en/ch07-filenames.xml:340
10356 msgid ""
10357 "Operating systems and filesystems differ in the way they handle the "
10358 "<emphasis>case</emphasis> of characters in file and directory names. There "
10359 "are three common ways to handle case in names."
10360 msgstr ""
10362 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10363 #: ../en/ch07-filenames.xml:345
10364 msgid ""
10365 "Completely case insensitive. Uppercase and lowercase versions of a letter "
10366 "are treated as identical, both when creating a file and during subsequent "
10367 "accesses. This is common on older DOS-based systems."
10368 msgstr ""
10370 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10371 #: ../en/ch07-filenames.xml:350
10372 msgid ""
10373 "Case preserving, but insensitive. When a file or directory is created, the "
10374 "case of its name is stored, and can be retrieved and displayed by the "
10375 "operating system. When an existing file is being looked up, its case is "
10376 "ignored. This is the standard arrangement on Windows and MacOS. The names "
10377 "<filename>foo</filename> and <filename>FoO</filename> identify the same "
10378 "file. This treatment of uppercase and lowercase letters as interchangeable "
10379 "is also referred to as <emphasis>case folding</emphasis>."
10380 msgstr ""
10382 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10383 #: ../en/ch07-filenames.xml:361
10384 msgid ""
10385 "Case sensitive. The case of a name is significant at all times. The names "
10386 "<filename>foo</filename> and <filename>FoO</filename> identify different "
10387 "files. This is the way Linux and Unix systems normally work."
10388 msgstr ""
10390 #. type: Content of: <book><chapter><sect1><para>
10391 #: ../en/ch07-filenames.xml:368
10392 msgid ""
10393 "On Unix-like systems, it is possible to have any or all of the above ways of "
10394 "handling case in action at once. For example, if you use a USB thumb drive "
10395 "formatted with a FAT32 filesystem on a Linux system, Linux will handle names "
10396 "on that filesystem in a case preserving, but insensitive, way."
10397 msgstr ""
10399 #. type: Content of: <book><chapter><sect1><sect2><title>
10400 #: ../en/ch07-filenames.xml:375
10401 msgid "Safe, portable repository storage"
10402 msgstr "安全,可移植的版本库存储"
10404 #. type: Content of: <book><chapter><sect1><sect2><para>
10405 #: ../en/ch07-filenames.xml:377
10406 msgid ""
10407 "Mercurial's repository storage mechanism is <emphasis>case safe</emphasis>. "
10408 "It translates file names so that they can be safely stored on both case "
10409 "sensitive and case insensitive filesystems. This means that you can use "
10410 "normal file copying tools to transfer a Mercurial repository onto, for "
10411 "example, a USB thumb drive, and safely move that drive and repository back "
10412 "and forth between a Mac, a PC running Windows, and a Linux box."
10413 msgstr ""
10415 #. type: Content of: <book><chapter><sect1><sect2><title>
10416 #: ../en/ch07-filenames.xml:388
10417 msgid "Detecting case conflicts"
10418 msgstr "检测大小写冲突"
10420 #. type: Content of: <book><chapter><sect1><sect2><para>
10421 #: ../en/ch07-filenames.xml:390
10422 msgid ""
10423 "When operating in the working directory, Mercurial honours the naming policy "
10424 "of the filesystem where the working directory is located. If the filesystem "
10425 "is case preserving, but insensitive, Mercurial will treat names that differ "
10426 "only in case as the same."
10427 msgstr ""
10429 #. type: Content of: <book><chapter><sect1><sect2><para>
10430 #: ../en/ch07-filenames.xml:396
10431 msgid ""
10432 "An important aspect of this approach is that it is possible to commit a "
10433 "changeset on a case sensitive (typically Linux or Unix) filesystem that will "
10434 "cause trouble for users on case insensitive (usually Windows and MacOS) "
10435 "users. If a Linux user commits changes to two files, one named "
10436 "<filename>myfile.c</filename> and the other named <filename>MyFile.C</"
10437 "filename>, they will be stored correctly in the repository. And in the "
10438 "working directories of other Linux users, they will be correctly represented "
10439 "as separate files."
10440 msgstr ""
10442 #. type: Content of: <book><chapter><sect1><sect2><para>
10443 #: ../en/ch07-filenames.xml:407
10444 msgid ""
10445 "If a Windows or Mac user pulls this change, they will not initially have a "
10446 "problem, because Mercurial's repository storage mechanism is case safe. "
10447 "However, once they try to <command role=\"hg-cmd\">hg update</command> the "
10448 "working directory to that changeset, or <command role=\"hg-cmd\">hg merge</"
10449 "command> with that changeset, Mercurial will spot the conflict between the "
10450 "two file names that the filesystem would treat as the same, and forbid the "
10451 "update or merge from occurring."
10452 msgstr ""
10454 #. type: Content of: <book><chapter><sect1><sect2><title>
10455 #: ../en/ch07-filenames.xml:419
10456 msgid "Fixing a case conflict"
10457 msgstr "修正大小写冲突"
10459 #. type: Content of: <book><chapter><sect1><sect2><para>
10460 #: ../en/ch07-filenames.xml:421
10461 msgid ""
10462 "If you are using Windows or a Mac in a mixed environment where some of your "
10463 "collaborators are using Linux or Unix, and Mercurial reports a case folding "
10464 "conflict when you try to <command role=\"hg-cmd\">hg update</command> or "
10465 "<command role=\"hg-cmd\">hg merge</command>, the procedure to fix the problem "
10466 "is simple."
10467 msgstr ""
10469 #. type: Content of: <book><chapter><sect1><sect2><para>
10470 #: ../en/ch07-filenames.xml:428
10471 msgid ""
10472 "Just find a nearby Linux or Unix box, clone the problem repository onto it, "
10473 "and use Mercurial's <command role=\"hg-cmd\">hg rename</command> command to "
10474 "change the names of any offending files or directories so that they will no "
10475 "longer cause case folding conflicts. Commit this change, <command role=\"hg-"
10476 "cmd\">hg pull</command> or <command role=\"hg-cmd\">hg push</command> it "
10477 "across to your Windows or MacOS system, and <command role=\"hg-cmd\">hg "
10478 "update</command> to the revision with the non-conflicting names."
10479 msgstr ""
10481 #. type: Content of: <book><chapter><sect1><sect2><para>
10482 #: ../en/ch07-filenames.xml:438
10483 msgid ""
10484 "The changeset with case-conflicting names will remain in your project's "
10485 "history, and you still won't be able to <command role=\"hg-cmd\">hg update</"
10486 "command> your working directory to that changeset on a Windows or MacOS "
10487 "system, but you can continue development unimpeded."
10488 msgstr ""
10490 #. type: Content of: <book><chapter><title>
10491 #: ../en/ch08-branch.xml:5
10492 msgid "Managing releases and branchy development"
10493 msgstr "发布管理与分支开发"
10495 #. type: Content of: <book><chapter><para>
10496 #: ../en/ch08-branch.xml:7
10497 msgid ""
10498 "Mercurial provides several mechanisms for you to manage a project that is "
10499 "making progress on multiple fronts at once. To understand these mechanisms, "
10500 "let's first take a brief look at a fairly normal software project structure."
10501 msgstr ""
10503 #. type: Content of: <book><chapter><para>
10504 #: ../en/ch08-branch.xml:12
10505 msgid ""
10506 "Many software projects issue periodic <quote>major</quote> releases that "
10507 "contain substantial new features. In parallel, they may issue <quote>minor</"
10508 "quote> releases. These are usually identical to the major releases off which "
10509 "they're based, but with a few bugs fixed."
10510 msgstr ""
10512 #. type: Content of: <book><chapter><para>
10513 #: ../en/ch08-branch.xml:18
10514 msgid ""
10515 "In this chapter, we'll start by talking about how to keep records of project "
10516 "milestones such as releases. We'll then continue on to talk about the flow "
10517 "of work between different phases of a project, and how Mercurial can help you "
10518 "to isolate and manage this work."
10519 msgstr ""
10521 #. type: Content of: <book><chapter><sect1><title>
10522 #: ../en/ch08-branch.xml:25
10523 msgid "Giving a persistent name to a revision"
10524 msgstr "给版本指定一个永久的名称"
10526 #. type: Content of: <book><chapter><sect1><para>
10527 #: ../en/ch08-branch.xml:27
10528 msgid ""
10529 "Once you decide that you'd like to call a particular revision a "
10530 "<quote>release</quote>, it's a good idea to record the identity of that "
10531 "revision. This will let you reproduce that release at a later date, for "
10532 "whatever purpose you might need at the time (reproducing a bug, porting to a "
10533 "new platform, etc). &interaction.tag.init;"
10534 msgstr ""
10537 #. type: Content of: <book><chapter><sect1><para>
10538 #: ../en/ch08-branch.xml:34
10539 msgid ""
10540 "Mercurial lets you give a permanent name to any revision using the <command "
10541 "role=\"hg-cmd\">hg tag</command> command. Not surprisingly, these names are "
10542 "called <quote>tags</quote>."
10543 msgstr ""
10545 #. type: Content of: <book><chapter><sect1><para>
10546 #: ../en/ch08-branch.xml:40
10547 msgid ""
10548 "A tag is nothing more than a <quote>symbolic name</quote> for a revision. "
10549 "Tags exist purely for your convenience, so that you have a handy permanent "
10550 "way to refer to a revision; Mercurial doesn't interpret the tag names you use "
10551 "in any way. Neither does Mercurial place any restrictions on the name of a "
10552 "tag, beyond a few that are necessary to ensure that a tag can be parsed "
10553 "unambiguously. A tag name cannot contain any of the following characters:"
10554 msgstr ""
10556 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10557 #: ../en/ch08-branch.xml:49
10558 msgid "Colon (ASCII 58, <quote><literal>:</literal></quote>)"
10559 msgstr ""
10561 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10562 #: ../en/ch08-branch.xml:52
10563 msgid "Carriage return (ASCII 13, <quote><literal>\\r</literal></quote>)"
10564 msgstr ""
10566 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10567 #: ../en/ch08-branch.xml:55
10568 msgid "Newline (ASCII 10, <quote><literal>\\n</literal></quote>)"
10569 msgstr ""
10571 #. type: Content of: <book><chapter><sect1><para>
10572 #: ../en/ch08-branch.xml:59
10573 msgid ""
10574 "You can use the <command role=\"hg-cmd\">hg tags</command> command to display "
10575 "the tags present in your repository. In the output, each tagged revision is "
10576 "identified first by its name, then by revision number, and finally by the "
10577 "unique hash of the revision."
10578 msgstr ""
10580 #. type: Content of: <book><chapter><sect1><para>
10581 #: ../en/ch08-branch.xml:67
10582 msgid ""
10583 "Notice that <literal>tip</literal> is listed in the output of <command role="
10584 "\"hg-cmd\">hg tags</command>. The <literal>tip</literal> tag is a special "
10585 "<quote>floating</quote> tag, which always identifies the newest revision in "
10586 "the repository."
10587 msgstr ""
10589 #. type: Content of: <book><chapter><sect1><para>
10590 #: ../en/ch08-branch.xml:73
10591 msgid ""
10592 "In the output of the <command role=\"hg-cmd\">hg tags</command> command, tags "
10593 "are listed in reverse order, by revision number. This usually means that "
10594 "recent tags are listed before older tags. It also means that <literal>tip</"
10595 "literal> is always going to be the first tag listed in the output of <command "
10596 "role=\"hg-cmd\">hg tags</command>."
10597 msgstr ""
10599 #. type: Content of: <book><chapter><sect1><para>
10600 #: ../en/ch08-branch.xml:80
10601 msgid ""
10602 "When you run <command role=\"hg-cmd\">hg log</command>, if it displays a "
10603 "revision that has tags associated with it, it will print those tags."
10604 msgstr ""
10607 #. type: Content of: <book><chapter><sect1><para>
10608 #: ../en/ch08-branch.xml:86
10609 msgid ""
10610 "Any time you need to provide a revision ID to a Mercurial command, the "
10611 "command will accept a tag name in its place. Internally, Mercurial will "
10612 "translate your tag name into the corresponding revision ID, then use that."
10613 msgstr ""
10615 #. type: Content of: <book><chapter><sect1><para>
10616 #: ../en/ch08-branch.xml:93
10617 msgid ""
10618 "There's no limit on the number of tags you can have in a repository, or on "
10619 "the number of tags that a single revision can have. As a practical matter, "
10620 "it's not a great idea to have <quote>too many</quote> (a number which will "
10621 "vary from project to project), simply because tags are supposed to help you "
10622 "to find revisions. If you have lots of tags, the ease of using them to "
10623 "identify revisions diminishes rapidly."
10624 msgstr ""
10626 #. type: Content of: <book><chapter><sect1><para>
10627 #: ../en/ch08-branch.xml:101
10628 msgid ""
10629 "For example, if your project has milestones as frequent as every few days, "
10630 "it's perfectly reasonable to tag each one of those. But if you have a "
10631 "continuous build system that makes sure every revision can be built cleanly, "
10632 "you'd be introducing a lot of noise if you were to tag every clean build. "
10633 "Instead, you could tag failed builds (on the assumption that they're rare!), "
10634 "or simply not use tags to track buildability."
10635 msgstr ""
10637 #. type: Content of: <book><chapter><sect1><para>
10638 #: ../en/ch08-branch.xml:109
10639 msgid ""
10640 "If you want to remove a tag that you no longer want, use <command role=\"hg-"
10641 "cmd\">hg tag --remove</command>."
10642 msgstr ""
10644 #. type: Content of: <book><chapter><sect1><para>
10645 #: ../en/ch08-branch.xml:114
10646 msgid ""
10647 "You can also modify a tag at any time, so that it identifies a different "
10648 "revision, by simply issuing a new <command role=\"hg-cmd\">hg tag</command> "
10649 "command. You'll have to use the <option role=\"hg-opt-tag\">-f</option> "
10650 "option to tell Mercurial that you <emphasis>really</emphasis> want to update "
10651 "the tag."
10652 msgstr ""
10654 #. type: Content of: <book><chapter><sect1><para>
10655 #: ../en/ch08-branch.xml:123
10656 msgid ""
10657 "There will still be a permanent record of the previous identity of the tag, "
10658 "but Mercurial will no longer use it. There's thus no penalty to tagging the "
10659 "wrong revision; all you have to do is turn around and tag the correct "
10660 "revision once you discover your error."
10661 msgstr ""
10663 #. type: Content of: <book><chapter><sect1><para>
10664 #: ../en/ch08-branch.xml:129
10665 msgid ""
10666 "Mercurial stores tags in a normal revision-controlled file in your "
10667 "repository. If you've created any tags, you'll find them in a file in the "
10668 "root of your repository named <filename role=\"special\">.hgtags</filename>. "
10669 "When you run the <command role=\"hg-cmd\">hg tag</command> command, Mercurial "
10670 "modifies this file, then automatically commits the change to it. This means "
10671 "that every time you run <command role=\"hg-cmd\">hg tag</command>, you'll see "
10672 "a corresponding changeset in the output of <command role=\"hg-cmd\">hg log</"
10673 "command>."
10674 msgstr ""
10676 #. type: Content of: <book><chapter><sect1><sect2><title>
10677 #: ../en/ch08-branch.xml:142
10678 msgid "Handling tag conflicts during a merge"
10679 msgstr "在合并期间处理标签冲突"
10681 #. type: Content of: <book><chapter><sect1><sect2><para>
10682 #: ../en/ch08-branch.xml:144
10683 msgid ""
10684 "You won't often need to care about the <filename role=\"special\">.hgtags</"
10685 "filename> file, but it sometimes makes its presence known during a merge. "
10686 "The format of the file is simple: it consists of a series of lines. Each "
10687 "line starts with a changeset hash, followed by a space, followed by the name "
10688 "of a tag."
10689 msgstr ""
10691 #. type: Content of: <book><chapter><sect1><sect2><para>
10692 #: ../en/ch08-branch.xml:151
10693 msgid ""
10694 "If you're resolving a conflict in the <filename role=\"special\">.hgtags</"
10695 "filename> file during a merge, there's one twist to modifying the <filename "
10696 "role=\"special\">.hgtags</filename> file: when Mercurial is parsing the tags "
10697 "in a repository, it <emphasis>never</emphasis> reads the working copy of the "
10698 "<filename role=\"special\">.hgtags</filename> file. Instead, it reads the "
10699 "<emphasis>most recently committed</emphasis> revision of the file."
10700 msgstr ""
10702 #. type: Content of: <book><chapter><sect1><sect2><para>
10703 #: ../en/ch08-branch.xml:161
10704 msgid ""
10705 "An unfortunate consequence of this design is that you can't actually verify "
10706 "that your merged <filename role=\"special\">.hgtags</filename> file is "
10707 "correct until <emphasis>after</emphasis> you've committed a change. So if "
10708 "you find yourself resolving a conflict on <filename role=\"special\">.hgtags</"
10709 "filename> during a merge, be sure to run <command role=\"hg-cmd\">hg tags</"
10710 "command> after you commit. If it finds an error in the <filename role="
10711 "\"special\">.hgtags</filename> file, it will report the location of the "
10712 "error, which you can then fix and commit. You should then run <command role="
10713 "\"hg-cmd\">hg tags</command> again, just to be sure that your fix is correct."
10714 msgstr ""
10716 #. type: Content of: <book><chapter><sect1><sect2><title>
10717 #: ../en/ch08-branch.xml:176
10718 msgid "Tags and cloning"
10719 msgstr "标签与克隆"
10721 #. type: Content of: <book><chapter><sect1><sect2><para>
10722 #: ../en/ch08-branch.xml:178
10723 msgid ""
10724 "You may have noticed that the <command role=\"hg-cmd\">hg clone</command> "
10725 "command has a <option role=\"hg-opt-clone\">-r</option> option that lets you "
10726 "clone an exact copy of the repository as of a particular changeset. The new "
10727 "clone will not contain any project history that comes after the revision you "
10728 "specified. This has an interaction with tags that can surprise the unwary."
10729 msgstr ""
10731 #. type: Content of: <book><chapter><sect1><sect2><para>
10732 #: ../en/ch08-branch.xml:186
10733 msgid ""
10734 "Recall that a tag is stored as a revision to the <filename role=\"special\">."
10735 "hgtags</filename> file. When you create a tag, the changeset in which its "
10736 "recorded refers to an older changeset. When you run <command role=\"hg-cmd"
10737 "\">hg clone -r foo</command> to clone a repository as of tag <literal>foo</"
10738 "literal>, the new clone <emphasis>will not contain any revision newer than "
10739 "the one the tag refers to, including the revision where the tag was created</"
10740 "emphasis>. The result is that you'll get exactly the right subset of the "
10741 "project's history in the new repository, but <emphasis>not</emphasis> the tag "
10742 "you might have expected."
10743 msgstr ""
10745 #. type: Content of: <book><chapter><sect1><sect2><title>
10746 #: ../en/ch08-branch.xml:201
10747 msgid "When permanent tags are too much"
10748 msgstr "当永久标签太多的时候"
10750 #. type: Content of: <book><chapter><sect1><sect2><para>
10751 #: ../en/ch08-branch.xml:203
10752 msgid ""
10753 "Since Mercurial's tags are revision controlled and carried around with a "
10754 "project's history, everyone you work with will see the tags you create. But "
10755 "giving names to revisions has uses beyond simply noting that revision "
10756 "<literal>4237e45506ee</literal> is really <literal>v2.0.2</literal>. If "
10757 "you're trying to track down a subtle bug, you might want a tag to remind you "
10758 "of something like <quote>Anne saw the symptoms with this revision</quote>."
10759 msgstr ""
10761 #. type: Content of: <book><chapter><sect1><sect2><para>
10762 #: ../en/ch08-branch.xml:213
10763 msgid ""
10764 "For cases like this, what you might want to use are <emphasis>local</"
10765 "emphasis> tags. You can create a local tag with the <option role=\"hg-opt-tag"
10766 "\">-l</option> option to the <command role=\"hg-cmd\">hg tag</command> "
10767 "command. This will store the tag in a file called <filename role=\"special"
10768 "\">.hg/localtags</filename>. Unlike <filename role=\"special\">.hgtags</"
10769 "filename>, <filename role=\"special\">.hg/localtags</filename> is not "
10770 "revision controlled. Any tags you create using <option role=\"hg-opt-tag\">-"
10771 "l</option> remain strictly local to the repository you're currently working "
10772 "in."
10773 msgstr ""
10775 #. type: Content of: <book><chapter><sect1><title>
10776 #: ../en/ch08-branch.xml:228
10777 msgid "The flow of changes&emdash;big picture vs. little"
10778 msgstr "修改流程—宏观与微观"
10780 #. type: Content of: <book><chapter><sect1><para>
10781 #: ../en/ch08-branch.xml:230
10782 msgid ""
10783 "To return to the outline I sketched at the beginning of the chapter, let's "
10784 "think about a project that has multiple concurrent pieces of work under "
10785 "development at once."
10786 msgstr ""
10788 #. type: Content of: <book><chapter><sect1><para>
10789 #: ../en/ch08-branch.xml:235
10790 msgid ""
10791 "There might be a push for a new <quote>main</quote> release; a new minor "
10792 "bugfix release to the last main release; and an unexpected <quote>hot fix</"
10793 "quote> to an old release that is now in maintenance mode."
10794 msgstr ""
10796 #. type: Content of: <book><chapter><sect1><para>
10797 #: ../en/ch08-branch.xml:240
10798 msgid ""
10799 "The usual way people refer to these different concurrent directions of "
10800 "development is as <quote>branches</quote>. However, we've already seen "
10801 "numerous times that Mercurial treats <emphasis>all of history</emphasis> as a "
10802 "series of branches and merges. Really, what we have here is two ideas that "
10803 "are peripherally related, but which happen to share a name."
10804 msgstr ""
10806 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10807 #: ../en/ch08-branch.xml:247
10808 msgid ""
10809 "<quote>Big picture</quote> branches represent the sweep of a project's "
10810 "evolution; people give them names, and talk about them in conversation."
10811 msgstr ""
10813 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10814 #: ../en/ch08-branch.xml:251
10815 msgid ""
10816 "<quote>Little picture</quote> branches are artefacts of the day-to-day "
10817 "activity of developing and merging changes. They expose the narrative of how "
10818 "the code was developed."
10819 msgstr ""
10821 #. type: Content of: <book><chapter><sect1><title>
10822 #: ../en/ch08-branch.xml:259
10823 msgid "Managing big-picture branches in repositories"
10824 msgstr "在版本库中管理分支"
10826 #. type: Content of: <book><chapter><sect1><para>
10827 #: ../en/ch08-branch.xml:261
10828 msgid ""
10829 "The easiest way to isolate a <quote>big picture</quote> branch in Mercurial "
10830 "is in a dedicated repository. If you have an existing shared "
10831 "repository&emdash;let's call it <literal>myproject</literal>&emdash;that "
10832 "reaches a <quote>1.0</quote> milestone, you can start to prepare for future "
10833 "maintenance releases on top of version 1.0 by tagging the revision from which "
10834 "you prepared the 1.0 release."
10835 msgstr ""
10837 #. type: Content of: <book><chapter><sect1><para>
10838 #: ../en/ch08-branch.xml:271
10839 msgid ""
10840 "You can then clone a new shared <literal>myproject-1.0.1</literal> repository "
10841 "as of that tag."
10842 msgstr ""
10844 #. type: Content of: <book><chapter><sect1><para>
10845 #: ../en/ch08-branch.xml:277
10846 msgid ""
10847 "Afterwards, if someone needs to work on a bug fix that ought to go into an "
10848 "upcoming 1.0.1 minor release, they clone the <literal>myproject-1.0.1</"
10849 "literal> repository, make their changes, and push them back."
10850 msgstr ""
10852 #. type: Content of: <book><chapter><sect1><para>
10853 #: ../en/ch08-branch.xml:284
10854 msgid ""
10855 "Meanwhile, development for the next major release can continue, isolated and "
10856 "unabated, in the <literal>myproject</literal> repository."
10857 msgstr ""
10859 #. type: Content of: <book><chapter><sect1><title>
10860 #: ../en/ch08-branch.xml:292
10861 msgid "Don't repeat yourself: merging across branches"
10862 msgstr "不要重复劳动:在分支间合并"
10864 #. type: Content of: <book><chapter><sect1><para>
10865 #: ../en/ch08-branch.xml:294
10866 msgid ""
10867 "In many cases, if you have a bug to fix on a maintenance branch, the chances "
10868 "are good that the bug exists on your project's main branch (and possibly "
10869 "other maintenance branches, too). It's a rare developer who wants to fix the "
10870 "same bug multiple times, so let's look at a few ways that Mercurial can help "
10871 "you to manage these bugfixes without duplicating your work."
10872 msgstr ""
10874 #. type: Content of: <book><chapter><sect1><para>
10875 #: ../en/ch08-branch.xml:302
10876 msgid ""
10877 "In the simplest instance, all you need to do is pull changes from your "
10878 "maintenance branch into your local clone of the target branch."
10879 msgstr ""
10881 #. type: Content of: <book><chapter><sect1><para>
10882 #: ../en/ch08-branch.xml:308
10883 msgid ""
10884 "You'll then need to merge the heads of the two branches, and push back to the "
10885 "main branch."
10886 msgstr ""
10888 #. type: Content of: <book><chapter><sect1><title>
10889 #: ../en/ch08-branch.xml:315
10890 msgid "Naming branches within one repository"
10891 msgstr "版本库中的命名分支"
10893 #. type: Content of: <book><chapter><sect1><para>
10894 #: ../en/ch08-branch.xml:317
10895 msgid ""
10896 "In most instances, isolating branches in repositories is the right approach. "
10897 "Its simplicity makes it easy to understand; and so it's hard to make "
10898 "mistakes. There's a one-to-one relationship between branches you're working "
10899 "in and directories on your system. This lets you use normal (non-Mercurial-"
10900 "aware) tools to work on files within a branch/repository."
10901 msgstr ""
10903 #. type: Content of: <book><chapter><sect1><para>
10904 #: ../en/ch08-branch.xml:324
10905 msgid ""
10906 "If you're more in the <quote>power user</quote> category (<emphasis>and</"
10907 "emphasis> your collaborators are too), there is an alternative way of "
10908 "handling branches that you can consider. I've already mentioned the human-"
10909 "level distinction between <quote>small picture</quote> and <quote>big "
10910 "picture</quote> branches. While Mercurial works with multiple <quote>small "
10911 "picture</quote> branches in a repository all the time (for example after you "
10912 "pull changes in, but before you merge them), it can <emphasis>also</emphasis> "
10913 "work with multiple <quote>big picture</quote> branches."
10914 msgstr ""
10916 #. type: Content of: <book><chapter><sect1><para>
10917 #: ../en/ch08-branch.xml:335
10918 msgid ""
10919 "The key to working this way is that Mercurial lets you assign a persistent "
10920 "<emphasis>name</emphasis> to a branch. There always exists a branch named "
10921 "<literal>default</literal>. Even before you start naming branches yourself, "
10922 "you can find traces of the <literal>default</literal> branch if you look for "
10923 "them."
10924 msgstr ""
10926 #. type: Content of: <book><chapter><sect1><para>
10927 #: ../en/ch08-branch.xml:342
10928 msgid ""
10929 "As an example, when you run the <command role=\"hg-cmd\">hg commit</command> "
10930 "command, and it pops up your editor so that you can enter a commit message, "
10931 "look for a line that contains the text <quote><literal>HG: branch default</"
10932 "literal></quote> at the bottom. This is telling you that your commit will "
10933 "occur on the branch named <literal>default</literal>."
10934 msgstr ""
10936 #. type: Content of: <book><chapter><sect1><para>
10937 #: ../en/ch08-branch.xml:349
10938 msgid ""
10939 "To start working with named branches, use the <command role=\"hg-cmd\">hg "
10940 "branches</command> command. This command lists the named branches already "
10941 "present in your repository, telling you which changeset is the tip of each."
10942 msgstr ""
10944 #. type: Content of: <book><chapter><sect1><para>
10945 #: ../en/ch08-branch.xml:356
10946 msgid ""
10947 "Since you haven't created any named branches yet, the only one that exists is "
10948 "<literal>default</literal>."
10949 msgstr ""
10951 #. type: Content of: <book><chapter><sect1><para>
10952 #: ../en/ch08-branch.xml:359
10953 msgid ""
10954 "To find out what the <quote>current</quote> branch is, run the <command role="
10955 "\"hg-cmd\">hg branch</command> command, giving it no arguments. This tells "
10956 "you what branch the parent of the current changeset is on."
10957 msgstr ""
10960 #. type: Content of: <book><chapter><sect1><para>
10961 #: ../en/ch08-branch.xml:366
10962 msgid ""
10963 "To create a new branch, run the <command role=\"hg-cmd\">hg branch</command> "
10964 "command again. This time, give it one argument: the name of the branch you "
10965 "want to create."
10966 msgstr ""
10968 #. type: Content of: <book><chapter><sect1><para>
10969 #: ../en/ch08-branch.xml:372
10970 msgid ""
10971 "After you've created a branch, you might wonder what effect the <command role="
10972 "\"hg-cmd\">hg branch</command> command has had. What do the <command role="
10973 "\"hg-cmd\">hg status</command> and <command role=\"hg-cmd\">hg tip</command> "
10974 "commands report?"
10975 msgstr ""
10977 #. type: Content of: <book><chapter><sect1><para>
10978 #: ../en/ch08-branch.xml:379
10979 msgid ""
10980 "Nothing has changed in the working directory, and there's been no new history "
10981 "created. As this suggests, running the <command role=\"hg-cmd\">hg branch</"
10982 "command> command has no permanent effect; it only tells Mercurial what branch "
10983 "name to use the <emphasis>next</emphasis> time you commit a changeset."
10984 msgstr ""
10986 #. type: Content of: <book><chapter><sect1><para>
10987 #: ../en/ch08-branch.xml:386
10988 msgid ""
10989 "When you commit a change, Mercurial records the name of the branch on which "
10990 "you committed. Once you've switched from the <literal>default</literal> "
10991 "branch to another and committed, you'll see the name of the new branch show "
10992 "up in the output of <command role=\"hg-cmd\">hg log</command>, <command role="
10993 "\"hg-cmd\">hg tip</command>, and other commands that display the same kind of "
10994 "output."
10995 msgstr ""
10997 #. type: Content of: <book><chapter><sect1><para>
10998 #: ../en/ch08-branch.xml:396
10999 msgid ""
11000 "The <command role=\"hg-cmd\">hg log</command>-like commands will print the "
11001 "branch name of every changeset that's not on the <literal>default</literal> "
11002 "branch. As a result, if you never use named branches, you'll never see this "
11003 "information."
11004 msgstr ""
11006 #. type: Content of: <book><chapter><sect1><para>
11007 #: ../en/ch08-branch.xml:401
11008 msgid ""
11009 "Once you've named a branch and committed a change with that name, every "
11010 "subsequent commit that descends from that change will inherit the same branch "
11011 "name. You can change the name of a branch at any time, using the <command "
11012 "role=\"hg-cmd\">hg branch</command> command."
11013 msgstr ""
11015 #. type: Content of: <book><chapter><sect1><para>
11016 #: ../en/ch08-branch.xml:409
11017 msgid ""
11018 "In practice, this is something you won't do very often, as branch names tend "
11019 "to have fairly long lifetimes. (This isn't a rule, just an observation.)"
11020 msgstr ""
11022 #. type: Content of: <book><chapter><sect1><title>
11023 #: ../en/ch08-branch.xml:415
11024 msgid "Dealing with multiple named branches in a repository"
11025 msgstr "在版本库中处理多个命名分支"
11027 #. type: Content of: <book><chapter><sect1><para>
11028 #: ../en/ch08-branch.xml:418
11029 msgid ""
11030 "If you have more than one named branch in a repository, Mercurial will "
11031 "remember the branch that your working directory is on when you start a "
11032 "command like <command role=\"hg-cmd\">hg update</command> or <command role="
11033 "\"hg-cmd\">hg pull -u</command>. It will update the working directory to the "
11034 "tip of this branch, no matter what the <quote>repo-wide</quote> tip is. To "
11035 "update to a revision that's on a different named branch, you may need to use "
11036 "the <option role=\"hg-opt-update\">-C</option> option to <command role=\"hg-"
11037 "cmd\">hg update</command>."
11038 msgstr ""
11040 #. type: Content of: <book><chapter><sect1><para>
11041 #: ../en/ch08-branch.xml:428
11042 msgid ""
11043 "This behavior is a little subtle, so let's see it in action. First, let's "
11044 "remind ourselves what branch we're currently on, and what branches are in our "
11045 "repository."
11046 msgstr ""
11048 #. type: Content of: <book><chapter><sect1><para>
11049 #: ../en/ch08-branch.xml:434
11050 msgid ""
11051 "We're on the <literal>bar</literal> branch, but there also exists an older "
11052 "<command role=\"hg-cmd\">hg foo</command> branch."
11053 msgstr ""
11055 #. type: Content of: <book><chapter><sect1><para>
11056 #: ../en/ch08-branch.xml:438
11057 msgid ""
11058 "We can <command role=\"hg-cmd\">hg update</command> back and forth between "
11059 "the tips of the <literal>foo</literal> and <literal>bar</literal> branches "
11060 "without needing to use the <option role=\"hg-opt-update\">-C</option> option, "
11061 "because this only involves going backwards and forwards linearly through our "
11062 "change history."
11063 msgstr ""
11066 #. type: Content of: <book><chapter><sect1><para>
11067 #: ../en/ch08-branch.xml:447
11068 msgid ""
11069 "If we go back to the <literal>foo</literal> branch and then run <command role="
11070 "\"hg-cmd\">hg update</command>, it will keep us on <literal>foo</literal>, "
11071 "not move us to the tip of <literal>bar</literal>."
11072 msgstr ""
11075 #. type: Content of: <book><chapter><sect1><para>
11076 #: ../en/ch08-branch.xml:454
11077 msgid ""
11078 "Committing a new change on the <literal>foo</literal> branch introduces a new "
11079 "head."
11080 msgstr ""
11082 #. type: Content of: <book><chapter><sect1><title>
11083 #: ../en/ch08-branch.xml:461
11084 msgid "Branch names and merging"
11085 msgstr "分支名称与合并"
11087 #. type: Content of: <book><chapter><sect1><para>
11088 #: ../en/ch08-branch.xml:463
11089 msgid ""
11090 "As you've probably noticed, merges in Mercurial are not symmetrical. Let's "
11091 "say our repository has two heads, 17 and 23. If I <command role=\"hg-cmd"
11092 "\">hg update</command> to 17 and then <command role=\"hg-cmd\">hg merge</"
11093 "command> with 23, Mercurial records 17 as the first parent of the merge, and "
11094 "23 as the second. Whereas if I <command role=\"hg-cmd\">hg update</command> "
11095 "to 23 and then <command role=\"hg-cmd\">hg merge</command> with 17, it "
11096 "records 23 as the first parent, and 17 as the second."
11097 msgstr ""
11099 #. type: Content of: <book><chapter><sect1><para>
11100 #: ../en/ch08-branch.xml:473
11101 msgid ""
11102 "This affects Mercurial's choice of branch name when you merge. After a "
11103 "merge, Mercurial will retain the branch name of the first parent when you "
11104 "commit the result of the merge. If your first parent's branch name is "
11105 "<literal>foo</literal>, and you merge with <literal>bar</literal>, the branch "
11106 "name will still be <literal>foo</literal> after you merge."
11107 msgstr ""
11109 #. type: Content of: <book><chapter><sect1><para>
11110 #: ../en/ch08-branch.xml:480
11111 msgid ""
11112 "It's not unusual for a repository to contain multiple heads, each with the "
11113 "same branch name. Let's say I'm working on the <literal>foo</literal> "
11114 "branch, and so are you. We commit different changes; I pull your changes; I "
11115 "now have two heads, each claiming to be on the <literal>foo</literal> "
11116 "branch. The result of a merge will be a single head on the <literal>foo</"
11117 "literal> branch, as you might hope."
11118 msgstr ""
11121 #. type: Content of: <book><chapter><sect1><para>
11122 #: ../en/ch08-branch.xml:488
11123 msgid ""
11124 "But if I'm working on the <literal>bar</literal> branch, and I merge work "
11125 "from the <literal>foo</literal> branch, the result will remain on the "
11126 "<literal>bar</literal> branch."
11127 msgstr ""
11129 #. type: Content of: <book><chapter><sect1><para>
11130 #: ../en/ch08-branch.xml:494
11131 msgid ""
11132 "To give a more concrete example, if I'm working on the <literal>bleeding-"
11133 "edge</literal> branch, and I want to bring in the latest fixes from the "
11134 "<literal>stable</literal> branch, Mercurial will choose the <quote>right</"
11135 "quote> (<literal>bleeding-edge</literal>) branch name when I pull and merge "
11136 "from <literal>stable</literal>."
11137 msgstr ""
11139 #. type: Content of: <book><chapter><sect1><title>
11140 #: ../en/ch08-branch.xml:503
11141 msgid "Branch naming is generally useful"
11142 msgstr "分支名称通常都很有用"
11144 #. type: Content of: <book><chapter><sect1><para>
11145 #: ../en/ch08-branch.xml:505
11146 msgid ""
11147 "You shouldn't think of named branches as applicable only to situations where "
11148 "you have multiple long-lived branches cohabiting in a single repository. "
11149 "They're very useful even in the one-branch-per-repository case."
11150 msgstr ""
11152 #. type: Content of: <book><chapter><sect1><para>
11153 #: ../en/ch08-branch.xml:510
11154 msgid ""
11155 "In the simplest case, giving a name to each branch gives you a permanent "
11156 "record of which branch a changeset originated on. This gives you more "
11157 "context when you're trying to follow the history of a long-lived branchy "
11158 "project."
11159 msgstr ""
11161 #. type: Content of: <book><chapter><sect1><para>
11162 #: ../en/ch08-branch.xml:515
11163 msgid ""
11164 "If you're working with shared repositories, you can set up a <literal role="
11165 "\"hook\">pretxnchangegroup</literal> hook on each that will block incoming "
11166 "changes that have the <quote>wrong</quote> branch name. This provides a "
11167 "simple, but effective, defence against people accidentally pushing changes "
11168 "from a <quote>bleeding edge</quote> branch to a <quote>stable</quote> "
11169 "branch. Such a hook might look like this inside the shared repo's <filename "
11170 "role=\"special\"> /.hgrc</filename>."
11171 msgstr ""
11173 #. type: Content of: <book><chapter><title>
11174 #: ../en/ch09-undo.xml:5
11175 msgid "Finding and fixing mistakes"
11176 msgstr "查找和修改错误"
11178 #. type: Content of: <book><chapter><para>
11179 #: ../en/ch09-undo.xml:7
11180 msgid ""
11181 "To err might be human, but to really handle the consequences well takes a top-"
11182 "notch revision control system. In this chapter, we'll discuss some of the "
11183 "techniques you can use when you find that a problem has crept into your "
11184 "project. Mercurial has some highly capable features that will help you to "
11185 "isolate the sources of problems, and to handle them appropriately."
11186 msgstr ""
11188 #. type: Content of: <book><chapter><sect1><title>
11189 #: ../en/ch09-undo.xml:15
11190 msgid "Erasing local history"
11191 msgstr "销毁本地历史"
11193 #. type: Content of: <book><chapter><sect1><sect2><title>
11194 #: ../en/ch09-undo.xml:18
11195 msgid "The accidental commit"
11196 msgstr "意外的提交"
11198 #. type: Content of: <book><chapter><sect1><sect2><para>
11199 #: ../en/ch09-undo.xml:20
11200 msgid ""
11201 "I have the occasional but persistent problem of typing rather more quickly "
11202 "than I can think, which sometimes results in me committing a changeset that "
11203 "is either incomplete or plain wrong. In my case, the usual kind of "
11204 "incomplete changeset is one in which I've created a new source file, but "
11205 "forgotten to <command role=\"hg-cmd\">hg add</command> it. A <quote>plain "
11206 "wrong</quote> changeset is not as common, but no less annoying."
11207 msgstr ""
11209 #. type: Content of: <book><chapter><sect1><sect2><title>
11210 #: ../en/ch09-undo.xml:31
11211 msgid "Rolling back a transaction"
11212 msgstr "回滚一个事务"
11214 #. type: Content of: <book><chapter><sect1><sect2><para>
11215 #: ../en/ch09-undo.xml:33
11216 msgid ""
11217 "In <xref linkend=\"sec:concepts:txn\"/>, I mentioned that Mercurial treats "
11218 "each modification of a repository as a <emphasis>transaction</emphasis>. "
11219 "Every time you commit a changeset or pull changes from another repository, "
11220 "Mercurial remembers what you did. You can undo, or <emphasis>roll back</"
11221 "emphasis>, exactly one of these actions using the <command role=\"hg-cmd\">hg "
11222 "rollback</command> command. (See <xref linkend=\"sec:undo:rollback-after-push"
11223 "\"/> for an important caveat about the use of this command.)"
11224 msgstr ""
11226 #. type: Content of: <book><chapter><sect1><sect2><para>
11227 #: ../en/ch09-undo.xml:43
11228 msgid ""
11229 "Here's a mistake that I often find myself making: committing a change in "
11230 "which I've created a new file, but forgotten to <command role=\"hg-cmd\">hg "
11231 "add</command> it."
11232 msgstr ""
11234 #. type: Content of: <book><chapter><sect1><sect2><para>
11235 #: ../en/ch09-undo.xml:50
11236 msgid ""
11237 "Looking at the output of <command role=\"hg-cmd\">hg status</command> after "
11238 "the commit immediately confirms the error."
11239 msgstr ""
11241 #. type: Content of: <book><chapter><sect1><sect2><para>
11242 #: ../en/ch09-undo.xml:56
11243 msgid ""
11244 "The commit captured the changes to the file <filename>a</filename>, but not "
11245 "the new file <filename>b</filename>. If I were to push this changeset to a "
11246 "repository that I shared with a colleague, the chances are high that "
11247 "something in <filename>a</filename> would refer to <filename>b</filename>, "
11248 "which would not be present in their repository when they pulled my changes. "
11249 "I would thus become the object of some indignation."
11250 msgstr ""
11252 #. type: Content of: <book><chapter><sect1><sect2><para>
11253 #: ../en/ch09-undo.xml:65
11254 msgid ""
11255 "However, luck is with me&emdash;I've caught my error before I pushed the "
11256 "changeset. I use the <command role=\"hg-cmd\">hg rollback</command> command, "
11257 "and Mercurial makes that last changeset vanish."
11258 msgstr ""
11260 #. type: Content of: <book><chapter><sect1><sect2><para>
11261 #: ../en/ch09-undo.xml:72
11262 msgid ""
11263 "Notice that the changeset is no longer present in the repository's history, "
11264 "and the working directory once again thinks that the file <filename>a</"
11265 "filename> is modified. The commit and rollback have left the working "
11266 "directory exactly as it was prior to the commit; the changeset has been "
11267 "completely erased. I can now safely <command role=\"hg-cmd\">hg add</"
11268 "command> the file <filename>b</filename>, and rerun my commit."
11269 msgstr ""
11271 #. type: Content of: <book><chapter><sect1><sect2><title>
11272 #: ../en/ch09-undo.xml:85
11273 msgid "The erroneous pull"
11274 msgstr "错误的抓取"
11276 #. type: Content of: <book><chapter><sect1><sect2><para>
11277 #: ../en/ch09-undo.xml:87
11278 msgid ""
11279 "It's common practice with Mercurial to maintain separate development branches "
11280 "of a project in different repositories. Your development team might have one "
11281 "shared repository for your project's <quote>0.9</quote> release, and another, "
11282 "containing different changes, for the <quote>1.0</quote> release."
11283 msgstr ""
11285 #. type: Content of: <book><chapter><sect1><sect2><para>
11286 #: ../en/ch09-undo.xml:94
11287 msgid ""
11288 "Given this, you can imagine that the consequences could be messy if you had a "
11289 "local <quote>0.9</quote> repository, and accidentally pulled changes from the "
11290 "shared <quote>1.0</quote> repository into it. At worst, you could be paying "
11291 "insufficient attention, and push those changes into the shared <quote>0.9</"
11292 "quote> tree, confusing your entire team (but don't worry, we'll return to "
11293 "this horror scenario later). However, it's more likely that you'll notice "
11294 "immediately, because Mercurial will display the URL it's pulling from, or you "
11295 "will see it pull a suspiciously large number of changes into the repository."
11296 msgstr ""
11298 #. type: Content of: <book><chapter><sect1><sect2><para>
11299 #: ../en/ch09-undo.xml:106
11300 msgid ""
11301 "The <command role=\"hg-cmd\">hg rollback</command> command will work nicely "
11302 "to expunge all of the changesets that you just pulled. Mercurial groups all "
11303 "changes from one <command role=\"hg-cmd\">hg pull</command> into a single "
11304 "transaction, so one <command role=\"hg-cmd\">hg rollback</command> is all you "
11305 "need to undo this mistake."
11306 msgstr ""
11308 #. type: Content of: <book><chapter><sect1><sect2><title>
11309 #: ../en/ch09-undo.xml:115
11310 msgid "Rolling back is useless once you've pushed"
11311 msgstr "当完成推送后,回滚是无效的"
11313 #. type: Content of: <book><chapter><sect1><sect2><para>
11314 #: ../en/ch09-undo.xml:117
11315 msgid ""
11316 "The value of the <command role=\"hg-cmd\">hg rollback</command> command drops "
11317 "to zero once you've pushed your changes to another repository. Rolling back "
11318 "a change makes it disappear entirely, but <emphasis>only</emphasis> in the "
11319 "repository in which you perform the <command role=\"hg-cmd\">hg rollback</"
11320 "command>. Because a rollback eliminates history, there's no way for the "
11321 "disappearance of a change to propagate between repositories."
11322 msgstr ""
11324 #. type: Content of: <book><chapter><sect1><sect2><para>
11325 #: ../en/ch09-undo.xml:126
11326 msgid ""
11327 "If you've pushed a change to another repository&emdash;particularly if it's a "
11328 "shared repository&emdash;it has essentially <quote>escaped into the wild,</"
11329 "quote> and you'll have to recover from your mistake in a different way. If "
11330 "you push a changeset somewhere, then roll it back, then pull from the "
11331 "repository you pushed to, the changeset you thought you'd gotten rid of will "
11332 "simply reappear in your repository."
11333 msgstr ""
11335 #. type: Content of: <book><chapter><sect1><sect2><para>
11336 #: ../en/ch09-undo.xml:135
11337 msgid ""
11338 "(If you absolutely know for sure that the change you want to roll back is the "
11339 "most recent change in the repository that you pushed to, <emphasis>and</"
11340 "emphasis> you know that nobody else could have pulled it from that "
11341 "repository, you can roll back the changeset there, too, but you really should "
11342 "not expect this to work reliably. Sooner or later a change really will make "
11343 "it into a repository that you don't directly control (or have forgotten "
11344 "about), and come back to bite you.)"
11345 msgstr ""
11347 #. type: Content of: <book><chapter><sect1><sect2><title>
11348 #: ../en/ch09-undo.xml:147
11349 msgid "You can only roll back once"
11350 msgstr "你只能回滚一次"
11352 #. type: Content of: <book><chapter><sect1><sect2><para>
11353 #: ../en/ch09-undo.xml:149
11354 msgid ""
11355 "Mercurial stores exactly one transaction in its transaction log; that "
11356 "transaction is the most recent one that occurred in the repository. This "
11357 "means that you can only roll back one transaction. If you expect to be able "
11358 "to roll back one transaction, then its predecessor, this is not the behavior "
11359 "you will get."
11360 msgstr ""
11362 #. type: Content of: <book><chapter><sect1><sect2><para>
11363 #: ../en/ch09-undo.xml:158
11364 msgid ""
11365 "Once you've rolled back one transaction in a repository, you can't roll back "
11366 "again in that repository until you perform another commit or pull."
11367 msgstr ""
11369 #. type: Content of: <book><chapter><sect1><title>
11370 #: ../en/ch09-undo.xml:165
11371 msgid "Reverting the mistaken change"
11372 msgstr "撤销错误的修改"
11374 #. type: Content of: <book><chapter><sect1><para>
11375 #: ../en/ch09-undo.xml:167
11376 msgid ""
11377 "If you make a modification to a file, and decide that you really didn't want "
11378 "to change the file at all, and you haven't yet committed your changes, the "
11379 "<command role=\"hg-cmd\">hg revert</command> command is the one you'll need. "
11380 "It looks at the changeset that's the parent of the working directory, and "
11381 "restores the contents of the file to their state as of that changeset. "
11382 "(That's a long-winded way of saying that, in the normal case, it undoes your "
11383 "modifications.)"
11384 msgstr ""
11386 #. type: Content of: <book><chapter><sect1><para>
11387 #: ../en/ch09-undo.xml:176
11388 msgid ""
11389 "Let's illustrate how the <command role=\"hg-cmd\">hg revert</command> command "
11390 "works with yet another small example. We'll begin by modifying a file that "
11391 "Mercurial is already tracking."
11392 msgstr ""
11394 #. type: Content of: <book><chapter><sect1><para>
11395 #: ../en/ch09-undo.xml:183
11396 msgid ""
11397 "If we don't want that change, we can simply <command role=\"hg-cmd\">hg "
11398 "revert</command> the file."
11399 msgstr ""
11401 #. type: Content of: <book><chapter><sect1><para>
11402 #: ../en/ch09-undo.xml:189
11403 msgid ""
11404 "The <command role=\"hg-cmd\">hg revert</command> command provides us with an "
11405 "extra degree of safety by saving our modified file with a <filename>.orig</"
11406 "filename> extension."
11407 msgstr ""
11409 #. type: Content of: <book><chapter><sect1><tip><title>
11410 #: ../en/ch09-undo.xml:197
11411 msgid "Be careful with <filename>.orig</filename> files"
11412 msgstr "小心 <filename>.orig</filename> 文件"
11414 #. type: Content of: <book><chapter><sect1><tip><para>
11415 #: ../en/ch09-undo.xml:199
11416 msgid ""
11417 "It's extremely unlikely that you are either using Mercurial to manage files "
11418 "with <filename>.orig</filename> extensions or that you even care about the "
11419 "contents of such files. Just in case, though, it's useful to remember that "
11420 "<command role=\"hg-cmd\">hg revert</command> will unconditionally overwrite "
11421 "an existing file with a <filename>.orig</filename> extension. For instance, "
11422 "if you already have a file named <filename>foo.orig</filename> when you "
11423 "revert <filename>foo</filename>, the contents of <filename>foo.orig</"
11424 "filename> will be clobbered."
11425 msgstr ""
11427 #. type: Content of: <book><chapter><sect1><para>
11428 #: ../en/ch09-undo.xml:211
11429 msgid ""
11430 "Here is a summary of the cases that the <command role=\"hg-cmd\">hg revert</"
11431 "command> command can deal with. We will describe each of these in more "
11432 "detail in the section that follows."
11433 msgstr ""
11435 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
11436 #: ../en/ch09-undo.xml:216
11437 msgid "If you modify a file, it will restore the file to its unmodified state."
11438 msgstr ""
11440 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
11441 #: ../en/ch09-undo.xml:219
11442 msgid ""
11443 "If you <command role=\"hg-cmd\">hg add</command> a file, it will undo the "
11444 "<quote>added</quote> state of the file, but leave the file itself untouched."
11445 msgstr ""
11447 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
11448 #: ../en/ch09-undo.xml:223
11449 msgid ""
11450 "If you delete a file without telling Mercurial, it will restore the file to "
11451 "its unmodified contents."
11452 msgstr ""
11454 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
11455 #: ../en/ch09-undo.xml:226
11456 msgid ""
11457 "If you use the <command role=\"hg-cmd\">hg remove</command> command to remove "
11458 "a file, it will undo the <quote>removed</quote> state of the file, and "
11459 "restore the file to its unmodified contents."
11460 msgstr ""
11462 #. type: Content of: <book><chapter><sect1><sect2><title>
11463 #: ../en/ch09-undo.xml:233
11464 msgid "File management errors"
11465 msgstr "文件管理错误"
11467 #. type: Content of: <book><chapter><sect1><sect2><para>
11468 #: ../en/ch09-undo.xml:235
11469 msgid ""
11470 "The <command role=\"hg-cmd\">hg revert</command> command is useful for more "
11471 "than just modified files. It lets you reverse the results of all of "
11472 "Mercurial's file management commands&emdash;<command role=\"hg-cmd\">hg add</"
11473 "command>, <command role=\"hg-cmd\">hg remove</command>, and so on."
11474 msgstr ""
11477 #. type: Content of: <book><chapter><sect1><sect2><para>
11478 #: ../en/ch09-undo.xml:241
11479 msgid ""
11480 "If you <command role=\"hg-cmd\">hg add</command> a file, then decide that in "
11481 "fact you don't want Mercurial to track it, use <command role=\"hg-cmd\">hg "
11482 "revert</command> to undo the add. Don't worry; Mercurial will not modify the "
11483 "file in any way. It will just <quote>unmark</quote> the file."
11484 msgstr ""
11486 #. type: Content of: <book><chapter><sect1><sect2><para>
11487 #: ../en/ch09-undo.xml:249
11488 msgid ""
11489 "Similarly, if you ask Mercurial to <command role=\"hg-cmd\">hg remove</"
11490 "command> a file, you can use <command role=\"hg-cmd\">hg revert</command> to "
11491 "restore it to the contents it had as of the parent of the working directory. "
11492 "&interaction.daily.revert.remove; This works just as well for a file that you "
11493 "deleted by hand, without telling Mercurial (recall that in Mercurial "
11494 "terminology, this kind of file is called <quote>missing</quote>)."
11495 msgstr ""
11498 #. type: Content of: <book><chapter><sect1><sect2><para>
11499 #: ../en/ch09-undo.xml:260
11500 msgid ""
11501 "If you revert a <command role=\"hg-cmd\">hg copy</command>, the copied-to "
11502 "file remains in your working directory afterwards, untracked. Since a copy "
11503 "doesn't affect the copied-from file in any way, Mercurial doesn't do anything "
11504 "with the copied-from file."
11505 msgstr ""
11507 #. type: Content of: <book><chapter><sect1><title>
11508 #: ../en/ch09-undo.xml:271
11509 msgid "Dealing with committed changes"
11510 msgstr "处理已经提交的修改"
11512 #. type: Content of: <book><chapter><sect1><para>
11513 #: ../en/ch09-undo.xml:273
11514 msgid ""
11515 "Consider a case where you have committed a change <emphasis>a</emphasis>, and "
11516 "another change <emphasis>b</emphasis> on top of it; you then realise that "
11517 "change <emphasis>a</emphasis> was incorrect. Mercurial lets you <quote>back "
11518 "out</quote> an entire changeset automatically, and building blocks that let "
11519 "you reverse part of a changeset by hand."
11520 msgstr ""
11522 #. type: Content of: <book><chapter><sect1><para>
11523 #: ../en/ch09-undo.xml:281
11524 msgid ""
11525 "Before you read this section, here's something to keep in mind: the <command "
11526 "role=\"hg-cmd\">hg backout</command> command undoes the effect of a change by "
11527 "<emphasis>adding</emphasis> to your repository's history, not by modifying or "
11528 "erasing it. It's the right tool to use if you're fixing bugs, but not if "
11529 "you're trying to undo some change that has catastrophic consequences. To "
11530 "deal with those, see <xref linkend=\"sec:undo:aaaiiieee\"/>."
11531 msgstr ""
11533 #. type: Content of: <book><chapter><sect1><sect2><title>
11534 #: ../en/ch09-undo.xml:291
11535 msgid "Backing out a changeset"
11536 msgstr "恢复一个修改集"
11538 #. type: Content of: <book><chapter><sect1><sect2><para>
11539 #: ../en/ch09-undo.xml:293
11540 msgid ""
11541 "The <command role=\"hg-cmd\">hg backout</command> command lets you "
11542 "<quote>undo</quote> the effects of an entire changeset in an automated "
11543 "fashion. Because Mercurial's history is immutable, this command "
11544 "<emphasis>does not</emphasis> get rid of the changeset you want to undo. "
11545 "Instead, it creates a new changeset that <emphasis>reverses</emphasis> the "
11546 "effect of the to-be-undone changeset."
11547 msgstr ""
11550 #. type: Content of: <book><chapter><sect1><sect2><para>
11551 #: ../en/ch09-undo.xml:302
11552 msgid ""
11553 "The operation of the <command role=\"hg-cmd\">hg backout</command> command is "
11554 "a little intricate, so let's illustrate it with some examples. First, we'll "
11555 "create a repository with some simple changes."
11556 msgstr ""
11558 #. type: Content of: <book><chapter><sect1><sect2><para>
11559 #: ../en/ch09-undo.xml:309
11560 msgid ""
11561 "The <command role=\"hg-cmd\">hg backout</command> command takes a single "
11562 "changeset ID as its argument; this is the changeset to back out. Normally, "
11563 "<command role=\"hg-cmd\">hg backout</command> will drop you into a text "
11564 "editor to write a commit message, so you can record why you're backing the "
11565 "change out. In this example, we provide a commit message on the command line "
11566 "using the <option role=\"hg-opt-backout\">-m</option> option."
11567 msgstr ""
11569 #. type: Content of: <book><chapter><sect1><sect2><title>
11570 #: ../en/ch09-undo.xml:320
11571 msgid "Backing out the tip changeset"
11572 msgstr "恢复顶点修改集"
11574 #. type: Content of: <book><chapter><sect1><sect2><para>
11575 #: ../en/ch09-undo.xml:322
11576 msgid "We're going to start by backing out the last changeset we committed."
11577 msgstr ""
11579 #. type: Content of: <book><chapter><sect1><sect2><para>
11580 #: ../en/ch09-undo.xml:327
11581 msgid ""
11582 "You can see that the second line from <filename>myfile</filename> is no "
11583 "longer present. Taking a look at the output of <command role=\"hg-cmd\">hg "
11584 "log</command> gives us an idea of what the <command role=\"hg-cmd\">hg "
11585 "backout</command> command has done. &interaction.backout.simple.log; Notice "
11586 "that the new changeset that <command role=\"hg-cmd\">hg backout</command> has "
11587 "created is a child of the changeset we backed out. It's easier to see this "
11588 "in <xref linkend=\"fig:undo:backout\"/>, which presents a graphical view of "
11589 "the change history. As you can see, the history is nice and linear."
11590 msgstr ""
11592 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
11593 #: ../en/ch09-undo.xml:340 ../en/ch09-undo.xml:460
11594 msgid ""
11595 "Backing out a change using the <command role=\"hg-cmd\">hg backout</command> "
11596 "command"
11597 msgstr "使用 <command role=\"hg-cmd\">hg backout</command> 恢复一个修改"
11599 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
11600 #: ../en/ch09-undo.xml:343
11601 msgid "<imageobject><imagedata fileref=\"figs/undo-simple.png\"/></imageobject>"
11602 msgstr ""
11604 #. type: Content of: <book><chapter><sect1><sect2><title>
11605 #: ../en/ch09-undo.xml:350
11606 msgid "Backing out a non-tip change"
11607 msgstr "恢复非顶点的修改"
11609 #. type: Content of: <book><chapter><sect1><sect2><para>
11610 #: ../en/ch09-undo.xml:352
11611 msgid ""
11612 "If you want to back out a change other than the last one you committed, pass "
11613 "the <option role=\"hg-opt-backout\">--merge</option> option to the <command "
11614 "role=\"hg-cmd\">hg backout</command> command."
11615 msgstr ""
11617 #. type: Content of: <book><chapter><sect1><sect2><para>
11618 #: ../en/ch09-undo.xml:359
11619 msgid ""
11620 "This makes backing out any changeset a <quote>one-shot</quote> operation "
11621 "that's usually simple and fast."
11622 msgstr ""
11624 #. type: Content of: <book><chapter><sect1><sect2><para>
11625 #: ../en/ch09-undo.xml:365
11626 msgid ""
11627 "If you take a look at the contents of <filename>myfile</filename> after the "
11628 "backout finishes, you'll see that the first and third changes are present, "
11629 "but not the second."
11630 msgstr ""
11632 #. type: Content of: <book><chapter><sect1><sect2><para>
11633 #: ../en/ch09-undo.xml:372
11634 msgid ""
11635 "As the graphical history in <xref linkend=\"fig:undo:backout-non-tip\"/> "
11636 "illustrates, Mercurial still commits one change in this kind of situation "
11637 "(the box-shaped node is the ones that Mercurial commits automatically), but "
11638 "the revision graph now looks different. Before Mercurial begins the backout "
11639 "process, it first remembers what the current parent of the working directory "
11640 "is. It then backs out the target changeset, and commits that as a "
11641 "changeset. Finally, it merges back to the previous parent of the working "
11642 "directory, but notice that it <emphasis>does not commit</emphasis> the result "
11643 "of the merge. The repository now contains two heads, and the working "
11644 "directory is in a merge state."
11645 msgstr ""
11647 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
11648 #: ../en/ch09-undo.xml:387
11649 msgid ""
11650 "Automated backout of a non-tip change using the <command role=\"hg-cmd\">hg "
11651 "backout</command> command"
11652 msgstr "使用 <command role=\"hg-cmd\">hg backout</command> 自动恢复非顶点的修改"
11654 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
11655 #: ../en/ch09-undo.xml:390
11656 msgid ""
11657 "<imageobject><imagedata fileref=\"figs/undo-non-tip.png\"/></imageobject>"
11658 msgstr ""
11660 #. type: Content of: <book><chapter><sect1><sect2><para>
11661 #: ../en/ch09-undo.xml:395
11662 msgid ""
11663 "The result is that you end up <quote>back where you were</quote>, only with "
11664 "some extra history that undoes the effect of the changeset you wanted to back "
11665 "out."
11666 msgstr ""
11668 #. type: Content of: <book><chapter><sect1><sect2><para>
11669 #: ../en/ch09-undo.xml:399
11670 msgid ""
11671 "You might wonder why Mercurial does not commit the result of the merge that "
11672 "it performed. The reason lies in Mercurial behaving conservatively: a merge "
11673 "naturally has more scope for error than simply undoing the effect of the tip "
11674 "changeset, so your work will be safest if you first inspect (and test!) the "
11675 "result of the merge, <emphasis>then</emphasis> commit it."
11676 msgstr ""
11678 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
11679 #: ../en/ch09-undo.xml:408
11680 msgid "Always use the <option role=\"hg-opt-backout\">--merge</option> option"
11681 msgstr "始终使用选项 <option role=\"hg-opt-backout\">--merge</option>"
11683 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11684 #: ../en/ch09-undo.xml:411
11685 msgid ""
11686 "In fact, since the <option role=\"hg-opt-backout\">--merge</option> option "
11687 "will do the <quote>right thing</quote> whether or not the changeset you're "
11688 "backing out is the tip (i.e. it won't try to merge if it's backing out the "
11689 "tip, since there's no need), you should <emphasis>always</emphasis> use this "
11690 "option when you run the <command role=\"hg-cmd\">hg backout</command> command."
11691 msgstr ""
11693 #. type: Content of: <book><chapter><sect1><sect2><title>
11694 #: ../en/ch09-undo.xml:422
11695 msgid "Gaining more control of the backout process"
11696 msgstr "在恢复处理中获得更多控制"
11698 #. type: Content of: <book><chapter><sect1><sect2><para>
11699 #: ../en/ch09-undo.xml:424
11700 msgid ""
11701 "While I've recommended that you always use the <option role=\"hg-opt-backout"
11702 "\">--merge</option> option when backing out a change, the <command role=\"hg-"
11703 "cmd\">hg backout</command> command lets you decide how to merge a backout "
11704 "changeset. Taking control of the backout process by hand is something you "
11705 "will rarely need to do, but it can be useful to understand what the <command "
11706 "role=\"hg-cmd\">hg backout</command> command is doing for you automatically. "
11707 "To illustrate this, let's clone our first repository, but omit the backout "
11708 "change that it contains."
11709 msgstr ""
11711 #. type: Content of: <book><chapter><sect1><sect2><para>
11712 #: ../en/ch09-undo.xml:437
11713 msgid ""
11714 "As with our earlier example, We'll commit a third changeset, then back out "
11715 "its parent, and see what happens."
11716 msgstr ""
11718 #. type: Content of: <book><chapter><sect1><sect2><para>
11719 #: ../en/ch09-undo.xml:443
11720 msgid ""
11721 "Our new changeset is again a descendant of the changeset we backout out; it's "
11722 "thus a new head, <emphasis>not</emphasis> a descendant of the changeset that "
11723 "was the tip. The <command role=\"hg-cmd\">hg backout</command> command was "
11724 "quite explicit in telling us this."
11725 msgstr ""
11727 #. type: Content of: <book><chapter><sect1><sect2><para>
11728 #: ../en/ch09-undo.xml:451
11729 msgid ""
11730 "Again, it's easier to see what has happened by looking at a graph of the "
11731 "revision history, in <xref linkend=\"fig:undo:backout-manual\"/>. This makes "
11732 "it clear that when we use <command role=\"hg-cmd\">hg backout</command> to "
11733 "back out a change other than the tip, Mercurial adds a new head to the "
11734 "repository (the change it committed is box-shaped)."
11735 msgstr ""
11737 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
11738 #: ../en/ch09-undo.xml:463
11739 msgid "<imageobject><imagedata fileref=\"figs/undo-manual.png\"/></imageobject>"
11740 msgstr ""
11742 #. type: Content of: <book><chapter><sect1><sect2><para>
11743 #: ../en/ch09-undo.xml:468
11744 msgid ""
11745 "After the <command role=\"hg-cmd\">hg backout</command> command has "
11746 "completed, it leaves the new <quote>backout</quote> changeset as the parent "
11747 "of the working directory."
11748 msgstr ""
11750 #. type: Content of: <book><chapter><sect1><sect2><para>
11751 #: ../en/ch09-undo.xml:475
11752 msgid "Now we have two isolated sets of changes."
11753 msgstr ""
11755 #. type: Content of: <book><chapter><sect1><sect2><para>
11756 #: ../en/ch09-undo.xml:479
11757 msgid ""
11758 "Let's think about what we expect to see as the contents of <filename>myfile</"
11759 "filename> now. The first change should be present, because we've never "
11760 "backed it out. The second change should be missing, as that's the change we "
11761 "backed out. Since the history graph shows the third change as a separate "
11762 "head, we <emphasis>don't</emphasis> expect to see the third change present in "
11763 "<filename>myfile</filename>."
11764 msgstr ""
11766 #. type: Content of: <book><chapter><sect1><sect2><para>
11767 #: ../en/ch09-undo.xml:489
11768 msgid ""
11769 "To get the third change back into the file, we just do a normal merge of our "
11770 "two heads."
11771 msgstr ""
11773 #. type: Content of: <book><chapter><sect1><sect2><para>
11774 #: ../en/ch09-undo.xml:494
11775 msgid ""
11776 "Afterwards, the graphical history of our repository looks like <xref linkend="
11777 "\"fig:undo:backout-manual-merge\"/>."
11778 msgstr ""
11780 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
11781 #: ../en/ch09-undo.xml:499
11782 msgid "Manually merging a backout change"
11783 msgstr "手工合并恢复修改"
11785 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
11786 #: ../en/ch09-undo.xml:501
11787 msgid ""
11788 "<imageobject><imagedata fileref=\"figs/undo-manual-merge.png\"/></imageobject>"
11789 msgstr ""
11791 #. type: Content of: <book><chapter><sect1><sect2><title>
11792 #: ../en/ch09-undo.xml:508
11793 msgid "Why <command role=\"hg-cmd\">hg backout</command> works as it does"
11794 msgstr "<command role=\"hg-cmd\">hg backout</command> 的内幕"
11796 #. type: Content of: <book><chapter><sect1><sect2><para>
11797 #: ../en/ch09-undo.xml:511
11798 msgid ""
11799 "Here's a brief description of how the <command role=\"hg-cmd\">hg backout</"
11800 "command> command works."
11801 msgstr ""
11803 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
11804 #: ../en/ch09-undo.xml:514
11805 msgid ""
11806 "It ensures that the working directory is <quote>clean</quote>, i.e. that the "
11807 "output of <command role=\"hg-cmd\">hg status</command> would be empty."
11808 msgstr ""
11810 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
11811 #: ../en/ch09-undo.xml:518
11812 msgid ""
11813 "It remembers the current parent of the working directory. Let's call this "
11814 "changeset <literal>orig</literal>."
11815 msgstr ""
11817 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
11818 #: ../en/ch09-undo.xml:522
11819 msgid ""
11820 "It does the equivalent of a <command role=\"hg-cmd\">hg update</command> to "
11821 "sync the working directory to the changeset you want to back out. Let's call "
11822 "this changeset <literal>backout</literal>."
11823 msgstr ""
11825 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
11826 #: ../en/ch09-undo.xml:527
11827 msgid ""
11828 "It finds the parent of that changeset. Let's call that changeset "
11829 "<literal>parent</literal>."
11830 msgstr ""
11832 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
11833 #: ../en/ch09-undo.xml:530
11834 msgid ""
11835 "For each file that the <literal>backout</literal> changeset affected, it does "
11836 "the equivalent of a <command role=\"hg-cmd\">hg revert -r parent</command> on "
11837 "that file, to restore it to the contents it had before that changeset was "
11838 "committed."
11839 msgstr ""
11841 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
11842 #: ../en/ch09-undo.xml:537
11843 msgid ""
11844 "It commits the result as a new changeset. This changeset has "
11845 "<literal>backout</literal> as its parent."
11846 msgstr ""
11848 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
11849 #: ../en/ch09-undo.xml:541
11850 msgid ""
11851 "If you specify <option role=\"hg-opt-backout\">--merge</option> on the "
11852 "command line, it merges with <literal>orig</literal>, and commits the result "
11853 "of the merge."
11854 msgstr ""
11856 #. type: Content of: <book><chapter><sect1><sect2><para>
11857 #: ../en/ch09-undo.xml:547
11858 msgid ""
11859 "An alternative way to implement the <command role=\"hg-cmd\">hg backout</"
11860 "command> command would be to <command role=\"hg-cmd\">hg export</command> the "
11861 "to-be-backed-out changeset as a diff, then use the <option role=\"cmd-opt-"
11862 "patch\">--reverse</option> option to the <command>patch</command> command to "
11863 "reverse the effect of the change without fiddling with the working "
11864 "directory. This sounds much simpler, but it would not work nearly as well."
11865 msgstr ""
11867 #. type: Content of: <book><chapter><sect1><sect2><para>
11868 #: ../en/ch09-undo.xml:557
11869 msgid ""
11870 "The reason that <command role=\"hg-cmd\">hg backout</command> does an update, "
11871 "a commit, a merge, and another commit is to give the merge machinery the best "
11872 "chance to do a good job when dealing with all the changes <emphasis>between</"
11873 "emphasis> the change you're backing out and the current tip."
11874 msgstr ""
11876 #. type: Content of: <book><chapter><sect1><sect2><para>
11877 #: ../en/ch09-undo.xml:564
11878 msgid ""
11879 "If you're backing out a changeset that's 100 revisions back in your project's "
11880 "history, the chances that the <command>patch</command> command will be able "
11881 "to apply a reverse diff cleanly are not good, because intervening changes are "
11882 "likely to have <quote>broken the context</quote> that <command>patch</"
11883 "command> uses to determine whether it can apply a patch (if this sounds like "
11884 "gibberish, see <xref linkend=\"sec:mq:patch\"/> for a discussion of the "
11885 "<command>patch</command> command). Also, Mercurial's merge machinery will "
11886 "handle files and directories being renamed, permission changes, and "
11887 "modifications to binary files, none of which <command>patch</command> can "
11888 "deal with."
11889 msgstr ""
11891 #. type: Content of: <book><chapter><sect1><title>
11892 #: ../en/ch09-undo.xml:581
11893 msgid "Changes that should never have been"
11894 msgstr "不该发生的修改"
11896 #. type: Content of: <book><chapter><sect1><para>
11897 #: ../en/ch09-undo.xml:583
11898 msgid ""
11899 "Most of the time, the <command role=\"hg-cmd\">hg backout</command> command "
11900 "is exactly what you need if you want to undo the effects of a change. It "
11901 "leaves a permanent record of exactly what you did, both when committing the "
11902 "original changeset and when you cleaned up after it."
11903 msgstr ""
11905 #. type: Content of: <book><chapter><sect1><para>
11906 #: ../en/ch09-undo.xml:589
11907 msgid ""
11908 "On rare occasions, though, you may find that you've committed a change that "
11909 "really should not be present in the repository at all. For example, it would "
11910 "be very unusual, and usually considered a mistake, to commit a software "
11911 "project's object files as well as its source files. Object files have almost "
11912 "no intrinsic value, and they're <emphasis>big</emphasis>, so they increase "
11913 "the size of the repository and the amount of time it takes to clone or pull "
11914 "changes."
11915 msgstr ""
11917 #. type: Content of: <book><chapter><sect1><para>
11918 #: ../en/ch09-undo.xml:598
11919 msgid ""
11920 "Before I discuss the options that you have if you commit a <quote>brown paper "
11921 "bag</quote> change (the kind that's so bad that you want to pull a brown "
11922 "paper bag over your head), let me first discuss some approaches that probably "
11923 "won't work."
11924 msgstr ""
11926 #. type: Content of: <book><chapter><sect1><para>
11927 #: ../en/ch09-undo.xml:603
11928 msgid ""
11929 "Since Mercurial treats history as accumulative&emdash;every change builds on "
11930 "top of all changes that preceded it&emdash;you generally can't just make "
11931 "disastrous changes disappear. The one exception is when you've just "
11932 "committed a change, and it hasn't been pushed or pulled into another "
11933 "repository. That's when you can safely use the <command role=\"hg-cmd\">hg "
11934 "rollback</command> command, as I detailed in <xref linkend=\"sec:undo:rollback"
11935 "\"/>."
11936 msgstr ""
11938 #. type: Content of: <book><chapter><sect1><para>
11939 #: ../en/ch09-undo.xml:612
11940 msgid ""
11941 "After you've pushed a bad change to another repository, you <emphasis>could</"
11942 "emphasis> still use <command role=\"hg-cmd\">hg rollback</command> to make "
11943 "your local copy of the change disappear, but it won't have the consequences "
11944 "you want. The change will still be present in the remote repository, so it "
11945 "will reappear in your local repository the next time you pull."
11946 msgstr ""
11948 #. type: Content of: <book><chapter><sect1><para>
11949 #: ../en/ch09-undo.xml:620
11950 msgid ""
11951 "If a situation like this arises, and you know which repositories your bad "
11952 "change has propagated into, you can <emphasis>try</emphasis> to get rid of "
11953 "the change from <emphasis>every</emphasis> one of those repositories. This "
11954 "is, of course, not a satisfactory solution: if you miss even a single "
11955 "repository while you're expunging, the change is still <quote>in the wild</"
11956 "quote>, and could propagate further."
11957 msgstr ""
11959 #. type: Content of: <book><chapter><sect1><para>
11960 #: ../en/ch09-undo.xml:628
11961 msgid ""
11962 "If you've committed one or more changes <emphasis>after</emphasis> the change "
11963 "that you'd like to see disappear, your options are further reduced. Mercurial "
11964 "doesn't provide a way to <quote>punch a hole</quote> in history, leaving "
11965 "changesets intact."
11966 msgstr ""
11968 #. type: Content of: <book><chapter><sect1><sect2><title>
11969 #: ../en/ch09-undo.xml:635
11970 msgid "Backing out a merge"
11971 msgstr "撤销一个合并"
11973 #. type: Content of: <book><chapter><sect1><sect2><para>
11974 #: ../en/ch09-undo.xml:637
11975 msgid ""
11976 "Since merges are often complicated, it is not unheard of for a merge to be "
11977 "mangled badly, but committed erroneously. Mercurial provides an important "
11978 "safeguard against bad merges by refusing to commit unresolved files, but "
11979 "human ingenuity guarantees that it is still possible to mess a merge up and "
11980 "commit it."
11981 msgstr ""
11983 #. type: Content of: <book><chapter><sect1><sect2><para>
11984 #: ../en/ch09-undo.xml:644
11985 msgid ""
11986 "Given a bad merge that has been committed, usually the best way to approach "
11987 "it is to simply try to repair the damage by hand. A complete disaster that "
11988 "cannot be easily fixed up by hand ought to be very rare, but the <command "
11989 "role=\"hg-cmd\">hg backout</command> command may help in making the cleanup "
11990 "easier. It offers a <option role=\"hg-opt-backout\">--parent</option> option, "
11991 "which lets you specify which parent to revert to when backing out a merge."
11992 msgstr ""
11994 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
11995 #: ../en/ch09-undo.xml:655
11996 msgid "A bad merge"
11997 msgstr "错误的合并"
11999 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
12000 #: ../en/ch09-undo.xml:657
12001 msgid "<imageobject><imagedata fileref=\"figs/bad-merge-1.png\"/></imageobject>"
12002 msgstr ""
12004 #. type: Content of: <book><chapter><sect1><sect2><para>
12005 #: ../en/ch09-undo.xml:662
12006 msgid ""
12007 "Suppose we have a revision graph like that in <xref linkend=\"fig:undo:bad-"
12008 "merge-1\"/>. What we'd like is to <emphasis>redo</emphasis> the merge of "
12009 "revisions 2 and 3."
12010 msgstr ""
12012 #. type: Content of: <book><chapter><sect1><sect2><para>
12013 #: ../en/ch09-undo.xml:667
12014 msgid "One way to do so would be as follows."
12015 msgstr ""
12017 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
12018 #: ../en/ch09-undo.xml:671
12019 msgid ""
12020 "Call <command role=\"hg-cmd\">hg backout --rev=4 --parent=2</command>. This "
12021 "tells <command role=\"hg-cmd\">hg backout</command> to back out revision 4, "
12022 "which is the bad merge, and to when deciding which revision to prefer, to "
12023 "choose parent 2, one of the parents of the merge. The effect can be seen in "
12024 "<xref linkend=\"fig:undo:bad-merge-2\"/>."
12025 msgstr ""
12027 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><figure><title>
12028 #: ../en/ch09-undo.xml:679
12029 msgid "Backing out the merge, favoring one parent"
12030 msgstr "拆除合并,关注一个父亲"
12032 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><figure><mediaobject>
12033 #: ../en/ch09-undo.xml:681
12034 msgid "<imageobject><imagedata fileref=\"figs/bad-merge-2.png\"/></imageobject>"
12035 msgstr ""
12036 "<imageobject><imagedata fileref=\"figs/bad-merge-2.png\"/></imageobject>"
12038 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
12039 #: ../en/ch09-undo.xml:688
12040 msgid ""
12041 "Call <command role=\"hg-cmd\">hg backout --rev=4 --parent=3</command>. This "
12042 "tells <command role=\"hg-cmd\">hg backout</command> to back out revision 4 "
12043 "again, but this time to choose parent 3, the other parent of the merge. The "
12044 "result is visible in <xref linkend=\"fig:undo:bad-merge-3\"/>, in which the "
12045 "repository now contains three heads."
12046 msgstr ""
12048 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><figure><title>
12049 #: ../en/ch09-undo.xml:696
12050 msgid "Backing out the merge, favoring the other parent"
12051 msgstr "拆除合并,关注其它父亲"
12053 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><figure><mediaobject>
12054 #: ../en/ch09-undo.xml:699
12055 msgid "<imageobject><imagedata fileref=\"figs/bad-merge-3.png\"/></imageobject>"
12056 msgstr ""
12057 "<imageobject><imagedata fileref=\"figs/bad-merge-3.png\"/></imageobject>"
12059 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
12060 #: ../en/ch09-undo.xml:706
12061 msgid ""
12062 "Redo the bad merge by merging the two backout heads, which reduces the number "
12063 "of heads in the repository to two, as can be seen in <xref linkend=\"fig:undo:"
12064 "bad-merge-4\"/>."
12065 msgstr ""
12067 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><figure><title>
12068 #: ../en/ch09-undo.xml:711 ../en/ch09-undo.xml:724
12069 msgid "Merging the backouts"
12070 msgstr "合并拆除"
12072 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><figure><mediaobject>
12073 #: ../en/ch09-undo.xml:713
12074 msgid "<imageobject><imagedata fileref=\"figs/bad-merge-4.png\"/></imageobject>"
12075 msgstr ""
12076 "<imageobject><imagedata fileref=\"figs/bad-merge-4.png\"/></imageobject>"
12078 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
12079 #: ../en/ch09-undo.xml:720
12080 msgid ""
12081 "Merge with the commit that was made after the bad merge, as shown in <xref "
12082 "linkend=\"fig:undo:bad-merge-5\"/>."
12083 msgstr ""
12085 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><figure><mediaobject>
12086 #: ../en/ch09-undo.xml:726
12087 msgid "<imageobject><imagedata fileref=\"figs/bad-merge-5.png\"/></imageobject>"
12088 msgstr ""
12090 #. type: Content of: <book><chapter><sect1><sect2><title>
12091 #: ../en/ch09-undo.xml:735
12092 msgid "Protect yourself from <quote>escaped</quote> changes"
12093 msgstr "使用<quote>校验</quote>修改来保护你自己"
12095 #. type: Content of: <book><chapter><sect1><sect2><para>
12096 #: ../en/ch09-undo.xml:738
12097 msgid ""
12098 "If you've committed some changes to your local repository and they've been "
12099 "pushed or pulled somewhere else, this isn't necessarily a disaster. You can "
12100 "protect yourself ahead of time against some classes of bad changeset. This "
12101 "is particularly easy if your team usually pulls changes from a central "
12102 "repository."
12103 msgstr ""
12105 #. type: Content of: <book><chapter><sect1><sect2><para>
12106 #: ../en/ch09-undo.xml:745
12107 msgid ""
12108 "By configuring some hooks on that repository to validate incoming changesets "
12109 "(see chapter <xref linkend=\"chap:hook\"/>), you can automatically prevent "
12110 "some kinds of bad changeset from being pushed to the central repository at "
12111 "all. With such a configuration in place, some kinds of bad changeset will "
12112 "naturally tend to <quote>die out</quote> because they can't propagate into "
12113 "the central repository. Better yet, this happens without any need for "
12114 "explicit intervention."
12115 msgstr ""
12117 #. type: Content of: <book><chapter><sect1><sect2><para>
12118 #: ../en/ch09-undo.xml:755
12119 msgid ""
12120 "For instance, an incoming change hook that verifies that a changeset will "
12121 "actually compile can prevent people from inadvertently <quote>breaking the "
12122 "build</quote>."
12123 msgstr ""
12125 #. type: Content of: <book><chapter><sect1><sect2><title>
12126 #: ../en/ch09-undo.xml:762
12127 msgid "What to do about sensitive changes that escape"
12128 msgstr "处理敏感信息泄漏的方法"
12130 #. type: Content of: <book><chapter><sect1><sect2><para>
12131 #: ../en/ch09-undo.xml:764
12132 msgid ""
12133 "Even a carefully run project can suffer an unfortunate event such as the "
12134 "committing and uncontrolled propagation of a file that contains important "
12135 "passwords."
12136 msgstr ""
12138 #. type: Content of: <book><chapter><sect1><sect2><para>
12139 #: ../en/ch09-undo.xml:768
12140 msgid ""
12141 "If something like this happens to you, and the information that gets "
12142 "accidentally propagated is truly sensitive, your first step should be to "
12143 "mitigate the effect of the leak without trying to control the leak itself. If "
12144 "you are not 100% certain that you know exactly who could have seen the "
12145 "changes, you should immediately change passwords, cancel credit cards, or "
12146 "find some other way to make sure that the information that has leaked is no "
12147 "longer useful. In other words, assume that the change has propagated far and "
12148 "wide, and that there's nothing more you can do."
12149 msgstr ""
12151 #. type: Content of: <book><chapter><sect1><sect2><para>
12152 #: ../en/ch09-undo.xml:779
12153 msgid ""
12154 "You might hope that there would be mechanisms you could use to either figure "
12155 "out who has seen a change or to erase the change permanently everywhere, but "
12156 "there are good reasons why these are not possible."
12157 msgstr ""
12159 #. type: Content of: <book><chapter><sect1><sect2><para>
12160 #: ../en/ch09-undo.xml:784
12161 msgid ""
12162 "Mercurial does not provide an audit trail of who has pulled changes from a "
12163 "repository, because it is usually either impossible to record such "
12164 "information or trivial to spoof it. In a multi-user or networked "
12165 "environment, you should thus be extremely skeptical of yourself if you think "
12166 "that you have identified every place that a sensitive changeset has "
12167 "propagated to. Don't forget that people can and will send bundles by email, "
12168 "have their backup software save data offsite, carry repositories on USB "
12169 "sticks, and find other completely innocent ways to confound your attempts to "
12170 "track down every copy of a problematic change."
12171 msgstr ""
12173 #. type: Content of: <book><chapter><sect1><sect2><para>
12174 #: ../en/ch09-undo.xml:796
12175 msgid ""
12176 "Mercurial also does not provide a way to make a file or changeset completely "
12177 "disappear from history, because there is no way to enforce its disappearance; "
12178 "someone could easily modify their copy of Mercurial to ignore such "
12179 "directives. In addition, even if Mercurial provided such a capability, "
12180 "someone who simply hadn't pulled a <quote>make this file disappear</quote> "
12181 "changeset wouldn't be affected by it, nor would web crawlers visiting at the "
12182 "wrong time, disk backups, or other mechanisms. Indeed, no distributed "
12183 "revision control system can make data reliably vanish. Providing the illusion "
12184 "of such control could easily give a false sense of security, and be worse "
12185 "than not providing it at all."
12186 msgstr ""
12188 #. type: Content of: <book><chapter><sect1><title>
12189 #: ../en/ch09-undo.xml:812
12190 msgid "Finding the source of a bug"
12191 msgstr "查找问题的根源"
12193 #. type: Content of: <book><chapter><sect1><para>
12194 #: ../en/ch09-undo.xml:814
12195 msgid ""
12196 "While it's all very well to be able to back out a changeset that introduced a "
12197 "bug, this requires that you know which changeset to back out. Mercurial "
12198 "provides an invaluable command, called <command role=\"hg-cmd\">hg bisect</"
12199 "command>, that helps you to automate this process and accomplish it very "
12200 "efficiently."
12201 msgstr ""
12203 #. type: Content of: <book><chapter><sect1><para>
12204 #: ../en/ch09-undo.xml:821
12205 msgid ""
12206 "The idea behind the <command role=\"hg-cmd\">hg bisect</command> command is "
12207 "that a changeset has introduced some change of behavior that you can identify "
12208 "with a simple pass/fail test. You don't know which piece of code introduced "
12209 "the change, but you know how to test for the presence of the bug. The "
12210 "<command role=\"hg-cmd\">hg bisect</command> command uses your test to direct "
12211 "its search for the changeset that introduced the code that caused the bug."
12212 msgstr ""
12214 #. type: Content of: <book><chapter><sect1><para>
12215 #: ../en/ch09-undo.xml:830
12216 msgid ""
12217 "Here are a few scenarios to help you understand how you might apply this "
12218 "command."
12219 msgstr ""
12221 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12222 #: ../en/ch09-undo.xml:833
12223 msgid ""
12224 "The most recent version of your software has a bug that you remember wasn't "
12225 "present a few weeks ago, but you don't know when it was introduced. Here, "
12226 "your binary test checks for the presence of that bug."
12227 msgstr ""
12229 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12230 #: ../en/ch09-undo.xml:838
12231 msgid ""
12232 "You fixed a bug in a rush, and now it's time to close the entry in your "
12233 "team's bug database. The bug database requires a changeset ID when you close "
12234 "an entry, but you don't remember which changeset you fixed the bug in. Once "
12235 "again, your binary test checks for the presence of the bug."
12236 msgstr ""
12238 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12239 #: ../en/ch09-undo.xml:845
12240 msgid ""
12241 "Your software works correctly, but runs 15% slower than the last time you "
12242 "measured it. You want to know which changeset introduced the performance "
12243 "regression. In this case, your binary test measures the performance of your "
12244 "software, to see whether it's <quote>fast</quote> or <quote>slow</quote>."
12245 msgstr ""
12247 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12248 #: ../en/ch09-undo.xml:852
12249 msgid ""
12250 "The sizes of the components of your project that you ship exploded recently, "
12251 "and you suspect that something changed in the way you build your project."
12252 msgstr ""
12254 #. type: Content of: <book><chapter><sect1><para>
12255 #: ../en/ch09-undo.xml:857
12256 msgid ""
12257 "From these examples, it should be clear that the <command role=\"hg-cmd\">hg "
12258 "bisect</command> command is not useful only for finding the sources of bugs. "
12259 "You can use it to find any <quote>emergent property</quote> of a repository "
12260 "(anything that you can't find from a simple text search of the files in the "
12261 "tree) for which you can write a binary test."
12262 msgstr ""
12264 #. type: Content of: <book><chapter><sect1><para>
12265 #: ../en/ch09-undo.xml:864
12266 msgid ""
12267 "We'll introduce a little bit of terminology here, just to make it clear which "
12268 "parts of the search process are your responsibility, and which are "
12269 "Mercurial's. A <emphasis>test</emphasis> is something that <emphasis>you</"
12270 "emphasis> run when <command role=\"hg-cmd\">hg bisect</command> chooses a "
12271 "changeset. A <emphasis>probe</emphasis> is what <command role=\"hg-cmd\">hg "
12272 "bisect</command> runs to tell whether a revision is good. Finally, we'll use "
12273 "the word <quote>bisect</quote>, as both a noun and a verb, to stand in for "
12274 "the phrase <quote>search using the <command role=\"hg-cmd\">hg bisect</"
12275 "command> command</quote>."
12276 msgstr ""
12278 #. type: Content of: <book><chapter><sect1><para>
12279 #: ../en/ch09-undo.xml:877
12280 msgid ""
12281 "One simple way to automate the searching process would be simply to probe "
12282 "every changeset. However, this scales poorly. If it took ten minutes to "
12283 "test a single changeset, and you had 10,000 changesets in your repository, "
12284 "the exhaustive approach would take on average 35 <emphasis>days</emphasis> to "
12285 "find the changeset that introduced a bug. Even if you knew that the bug was "
12286 "introduced by one of the last 500 changesets, and limited your search to "
12287 "those, you'd still be looking at over 40 hours to find the changeset that "
12288 "introduced your bug."
12289 msgstr ""
12291 #. type: Content of: <book><chapter><sect1><para>
12292 #: ../en/ch09-undo.xml:887
12293 msgid ""
12294 "What the <command role=\"hg-cmd\">hg bisect</command> command does is use its "
12295 "knowledge of the <quote>shape</quote> of your project's revision history to "
12296 "perform a search in time proportional to the <emphasis>logarithm</emphasis> "
12297 "of the number of changesets to check (the kind of search it performs is "
12298 "called a dichotomic search). With this approach, searching through 10,000 "
12299 "changesets will take less than three hours, even at ten minutes per test (the "
12300 "search will require about 14 tests). Limit your search to the last hundred "
12301 "changesets, and it will take only about an hour (roughly seven tests)."
12302 msgstr ""
12304 #. type: Content of: <book><chapter><sect1><para>
12305 #: ../en/ch09-undo.xml:898
12306 msgid ""
12307 "The <command role=\"hg-cmd\">hg bisect</command> command is aware of the "
12308 "<quote>branchy</quote> nature of a Mercurial project's revision history, so "
12309 "it has no problems dealing with branches, merges, or multiple heads in a "
12310 "repository. It can prune entire branches of history with a single probe, "
12311 "which is how it operates so efficiently."
12312 msgstr ""
12314 #. type: Content of: <book><chapter><sect1><sect2><title>
12315 #: ../en/ch09-undo.xml:906
12316 msgid "Using the <command role=\"hg-cmd\">hg bisect</command> command"
12317 msgstr "使用命令 <command role=\"hg-cmd\">hg bisect</command>"
12319 #. type: Content of: <book><chapter><sect1><sect2><para>
12320 #: ../en/ch09-undo.xml:909
12321 msgid ""
12322 "Here's an example of <command role=\"hg-cmd\">hg bisect</command> in action."
12323 msgstr ""
12325 #. type: Content of: <book><chapter><sect1><sect2><note><para>
12326 #: ../en/ch09-undo.xml:913
12327 msgid ""
12328 "In versions 0.9.5 and earlier of Mercurial, <command role=\"hg-cmd\">hg "
12329 "bisect</command> was not a core command: it was distributed with Mercurial as "
12330 "an extension. This section describes the built-in command, not the old "
12331 "extension."
12332 msgstr ""
12334 #. type: Content of: <book><chapter><sect1><sect2><para>
12335 #: ../en/ch09-undo.xml:920
12336 msgid ""
12337 "Now let's create a repository, so that we can try out the <command role=\"hg-"
12338 "cmd\">hg bisect</command> command in isolation."
12339 msgstr ""
12341 #. type: Content of: <book><chapter><sect1><sect2><para>
12342 #: ../en/ch09-undo.xml:926
12343 msgid ""
12344 "We'll simulate a project that has a bug in it in a simple-minded way: create "
12345 "trivial changes in a loop, and nominate one specific change that will have "
12346 "the <quote>bug</quote>. This loop creates 35 changesets, each adding a "
12347 "single file to the repository. We'll represent our <quote>bug</quote> with a "
12348 "file that contains the text <quote>i have a gub</quote>."
12349 msgstr ""
12351 #. type: Content of: <book><chapter><sect1><sect2><para>
12352 #: ../en/ch09-undo.xml:936
12353 msgid ""
12354 "The next thing that we'd like to do is figure out how to use the <command "
12355 "role=\"hg-cmd\">hg bisect</command> command. We can use Mercurial's normal "
12356 "built-in help mechanism for this."
12357 msgstr ""
12359 #. type: Content of: <book><chapter><sect1><sect2><para>
12360 #: ../en/ch09-undo.xml:943
12361 msgid ""
12362 "The <command role=\"hg-cmd\">hg bisect</command> command works in steps. "
12363 "Each step proceeds as follows."
12364 msgstr ""
12366 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
12367 #: ../en/ch09-undo.xml:946
12368 msgid "You run your binary test."
12369 msgstr ""
12371 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><itemizedlist><listitem><para>
12372 #: ../en/ch09-undo.xml:948
12373 msgid ""
12374 "If the test succeeded, you tell <command role=\"hg-cmd\">hg bisect</command> "
12375 "by running the <command role=\"hg-cmd\">hg bisect --good</command> command."
12376 msgstr ""
12377 "当测试成功后,使用 <command role=\"hg-cmd\">hg bisect --good</command> 命令告"
12378 "诉 <command role=\"hg-cmd\">hg bisect</command> 命令。"
12380 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><itemizedlist><listitem><para>
12381 #: ../en/ch09-undo.xml:953
12382 msgid ""
12383 "If it failed, run the <command role=\"hg-cmd\">hg bisect --bad</command> "
12384 "command."
12385 msgstr ""
12386 "如果失败,执行 <command role=\"hg-cmd\">hg bisect --bad</command> 命令。"
12388 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
12389 #: ../en/ch09-undo.xml:957
12390 msgid ""
12391 "The command uses your information to decide which changeset to test next."
12392 msgstr ""
12394 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
12395 #: ../en/ch09-undo.xml:960
12396 msgid ""
12397 "It updates the working directory to that changeset, and the process begins "
12398 "again."
12399 msgstr ""
12401 #. type: Content of: <book><chapter><sect1><sect2><para>
12402 #: ../en/ch09-undo.xml:963
12403 msgid ""
12404 "The process ends when <command role=\"hg-cmd\">hg bisect</command> identifies "
12405 "a unique changeset that marks the point where your test transitioned from "
12406 "<quote>succeeding</quote> to <quote>failing</quote>."
12407 msgstr ""
12410 #. type: Content of: <book><chapter><sect1><sect2><para>
12411 #: ../en/ch09-undo.xml:968
12412 msgid ""
12413 "To start the search, we must run the <command role=\"hg-cmd\">hg bisect --"
12414 "reset</command> command."
12415 msgstr ""
12417 #. type: Content of: <book><chapter><sect1><sect2><para>
12418 #: ../en/ch09-undo.xml:973
12419 msgid ""
12420 "In our case, the binary test we use is simple: we check to see if any file in "
12421 "the repository contains the string <quote>i have a gub</quote>. If it does, "
12422 "this changeset contains the change that <quote>caused the bug</quote>. By "
12423 "convention, a changeset that has the property we're searching for is "
12424 "<quote>bad</quote>, while one that doesn't is <quote>good</quote>."
12425 msgstr ""
12427 #. type: Content of: <book><chapter><sect1><sect2><para>
12428 #: ../en/ch09-undo.xml:981
12429 msgid ""
12430 "Most of the time, the revision to which the working directory is synced "
12431 "(usually the tip) already exhibits the problem introduced by the buggy "
12432 "change, so we'll mark it as <quote>bad</quote>."
12433 msgstr ""
12436 #. type: Content of: <book><chapter><sect1><sect2><para>
12437 #: ../en/ch09-undo.xml:988
12438 msgid ""
12439 "Our next task is to nominate a changeset that we know <emphasis>doesn't</"
12440 "emphasis> have the bug; the <command role=\"hg-cmd\">hg bisect</command> "
12441 "command will <quote>bracket</quote> its search between the first pair of good "
12442 "and bad changesets. In our case, we know that revision 10 didn't have the "
12443 "bug. (I'll have more words about choosing the first <quote>good</quote> "
12444 "changeset later.)"
12445 msgstr ""
12447 #. type: Content of: <book><chapter><sect1><sect2><para>
12448 #: ../en/ch09-undo.xml:998
12449 msgid "Notice that this command printed some output."
12450 msgstr ""
12452 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12453 #: ../en/ch09-undo.xml:1000
12454 msgid ""
12455 "It told us how many changesets it must consider before it can identify the "
12456 "one that introduced the bug, and how many tests that will require."
12457 msgstr ""
12459 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12460 #: ../en/ch09-undo.xml:1004
12461 msgid ""
12462 "It updated the working directory to the next changeset to test, and told us "
12463 "which changeset it's testing."
12464 msgstr ""
12466 #. type: Content of: <book><chapter><sect1><sect2><para>
12467 #: ../en/ch09-undo.xml:1009
12468 msgid ""
12469 "We now run our test in the working directory. We use the <command>grep</"
12470 "command> command to see if our <quote>bad</quote> file is present in the "
12471 "working directory. If it is, this revision is bad; if not, this revision is "
12472 "good. &interaction.bisect.search.step1;"
12473 msgstr ""
12475 #. type: Content of: <book><chapter><sect1><sect2><para>
12476 #: ../en/ch09-undo.xml:1015
12477 msgid ""
12478 "This test looks like a perfect candidate for automation, so let's turn it "
12479 "into a shell function."
12480 msgstr ""
12482 #. type: Content of: <book><chapter><sect1><sect2><para>
12483 #: ../en/ch09-undo.xml:1019
12484 msgid ""
12485 "We can now run an entire test step with a single command, <literal>mytest</"
12486 "literal>."
12487 msgstr ""
12489 #. type: Content of: <book><chapter><sect1><sect2><para>
12490 #: ../en/ch09-undo.xml:1024
12491 msgid "A few more invocations of our canned test step command, and we're done."
12492 msgstr ""
12494 #. type: Content of: <book><chapter><sect1><sect2><para>
12495 #: ../en/ch09-undo.xml:1029
12496 msgid ""
12497 "Even though we had 40 changesets to search through, the <command role=\"hg-cmd"
12498 "\">hg bisect</command> command let us find the changeset that introduced our "
12499 "<quote>bug</quote> with only five tests. Because the number of tests that "
12500 "the <command role=\"hg-cmd\">hg bisect</command> command performs grows "
12501 "logarithmically with the number of changesets to search, the advantage that "
12502 "it has over the <quote>brute force</quote> search approach increases with "
12503 "every changeset you add."
12504 msgstr ""
12506 #. type: Content of: <book><chapter><sect1><sect2><title>
12507 #: ../en/ch09-undo.xml:1040
12508 msgid "Cleaning up after your search"
12509 msgstr "搜索后的清理"
12511 #. type: Content of: <book><chapter><sect1><sect2><para>
12512 #: ../en/ch09-undo.xml:1042
12513 msgid ""
12514 "When you're finished using the <command role=\"hg-cmd\">hg bisect</command> "
12515 "command in a repository, you can use the <command role=\"hg-cmd\">hg bisect --"
12516 "reset</command> command to drop the information it was using to drive your "
12517 "search. The command doesn't use much space, so it doesn't matter if you "
12518 "forget to run this command. However, <command role=\"hg-cmd\">hg bisect</"
12519 "command> won't let you start a new search in that repository until you do a "
12520 "<command role=\"hg-cmd\">hg bisect --reset</command>."
12521 msgstr ""
12523 #. type: Content of: <book><chapter><sect1><title>
12524 #: ../en/ch09-undo.xml:1057
12525 msgid "Tips for finding bugs effectively"
12526 msgstr "有效查找问题的技巧"
12528 #. type: Content of: <book><chapter><sect1><sect2><title>
12529 #: ../en/ch09-undo.xml:1060
12530 msgid "Give consistent input"
12531 msgstr "给出一致的输入"
12533 #. type: Content of: <book><chapter><sect1><sect2><para>
12534 #: ../en/ch09-undo.xml:1062
12535 msgid ""
12536 "The <command role=\"hg-cmd\">hg bisect</command> command requires that you "
12537 "correctly report the result of every test you perform. If you tell it that a "
12538 "test failed when it really succeeded, it <emphasis>might</emphasis> be able "
12539 "to detect the inconsistency. If it can identify an inconsistency in your "
12540 "reports, it will tell you that a particular changeset is both good and bad. "
12541 "However, it can't do this perfectly; it's about as likely to report the wrong "
12542 "changeset as the source of the bug."
12543 msgstr ""
12545 #. type: Content of: <book><chapter><sect1><sect2><title>
12546 #: ../en/ch09-undo.xml:1074
12547 msgid "Automate as much as possible"
12548 msgstr "尽量自动"
12550 #. type: Content of: <book><chapter><sect1><sect2><para>
12551 #: ../en/ch09-undo.xml:1076
12552 msgid ""
12553 "When I started using the <command role=\"hg-cmd\">hg bisect</command> "
12554 "command, I tried a few times to run my tests by hand, on the command line. "
12555 "This is an approach that I, at least, am not suited to. After a few tries, I "
12556 "found that I was making enough mistakes that I was having to restart my "
12557 "searches several times before finally getting correct results."
12558 msgstr ""
12560 #. type: Content of: <book><chapter><sect1><sect2><para>
12561 #: ../en/ch09-undo.xml:1084
12562 msgid ""
12563 "My initial problems with driving the <command role=\"hg-cmd\">hg bisect</"
12564 "command> command by hand occurred even with simple searches on small "
12565 "repositories; if the problem you're looking for is more subtle, or the number "
12566 "of tests that <command role=\"hg-cmd\">hg bisect</command> must perform "
12567 "increases, the likelihood of operator error ruining the search is much "
12568 "higher. Once I started automating my tests, I had much better results."
12569 msgstr ""
12571 #. type: Content of: <book><chapter><sect1><sect2><para>
12572 #: ../en/ch09-undo.xml:1093
12573 msgid "The key to automated testing is twofold:"
12574 msgstr ""
12576 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12577 #: ../en/ch09-undo.xml:1095
12578 msgid "always test for the same symptom, and"
12579 msgstr ""
12581 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12582 #: ../en/ch09-undo.xml:1097
12583 msgid ""
12584 "always feed consistent input to the <command role=\"hg-cmd\">hg bisect</"
12585 "command> command."
12586 msgstr ""
12588 #. type: Content of: <book><chapter><sect1><sect2><para>
12589 #: ../en/ch09-undo.xml:1100
12590 msgid ""
12591 "In my tutorial example above, the <command>grep</command> command tests for "
12592 "the symptom, and the <literal>if</literal> statement takes the result of this "
12593 "check and ensures that we always feed the same input to the <command role="
12594 "\"hg-cmd\">hg bisect</command> command. The <literal>mytest</literal> "
12595 "function marries these together in a reproducible way, so that every test is "
12596 "uniform and consistent."
12597 msgstr ""
12599 #. type: Content of: <book><chapter><sect1><sect2><title>
12600 #: ../en/ch09-undo.xml:1110
12601 msgid "Check your results"
12602 msgstr "检查你的结果"
12604 #. type: Content of: <book><chapter><sect1><sect2><para>
12605 #: ../en/ch09-undo.xml:1112
12606 msgid ""
12607 "Because the output of a <command role=\"hg-cmd\">hg bisect</command> search "
12608 "is only as good as the input you give it, don't take the changeset it reports "
12609 "as the absolute truth. A simple way to cross-check its report is to manually "
12610 "run your test at each of the following changesets:"
12611 msgstr ""
12613 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12614 #: ../en/ch09-undo.xml:1118
12615 msgid ""
12616 "The changeset that it reports as the first bad revision. Your test should "
12617 "still report this as bad."
12618 msgstr ""
12620 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12621 #: ../en/ch09-undo.xml:1122
12622 msgid ""
12623 "The parent of that changeset (either parent, if it's a merge). Your test "
12624 "should report this changeset as good."
12625 msgstr ""
12627 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12628 #: ../en/ch09-undo.xml:1126
12629 msgid ""
12630 "A child of that changeset. Your test should report this changeset as bad."
12631 msgstr ""
12633 #. type: Content of: <book><chapter><sect1><sect2><title>
12634 #: ../en/ch09-undo.xml:1132
12635 msgid "Beware interference between bugs"
12636 msgstr "谨防问题之间的冲突"
12638 #. type: Content of: <book><chapter><sect1><sect2><para>
12639 #: ../en/ch09-undo.xml:1134
12640 msgid ""
12641 "It's possible that your search for one bug could be disrupted by the presence "
12642 "of another. For example, let's say your software crashes at revision 100, "
12643 "and worked correctly at revision 50. Unknown to you, someone else introduced "
12644 "a different crashing bug at revision 60, and fixed it at revision 80. This "
12645 "could distort your results in one of several ways."
12646 msgstr ""
12648 #. type: Content of: <book><chapter><sect1><sect2><para>
12649 #: ../en/ch09-undo.xml:1142
12650 msgid ""
12651 "It is possible that this other bug completely <quote>masks</quote> yours, "
12652 "which is to say that it occurs before your bug has a chance to manifest "
12653 "itself. If you can't avoid that other bug (for example, it prevents your "
12654 "project from building), and so can't tell whether your bug is present in a "
12655 "particular changeset, the <command role=\"hg-cmd\">hg bisect</command> "
12656 "command cannot help you directly. Instead, you can mark a changeset as "
12657 "untested by running <command role=\"hg-cmd\">hg bisect --skip</command>."
12658 msgstr ""
12660 #. type: Content of: <book><chapter><sect1><sect2><para>
12661 #: ../en/ch09-undo.xml:1152
12662 msgid ""
12663 "A different problem could arise if your test for a bug's presence is not "
12664 "specific enough. If you check for <quote>my program crashes</quote>, then "
12665 "both your crashing bug and an unrelated crashing bug that masks it will look "
12666 "like the same thing, and mislead <command role=\"hg-cmd\">hg bisect</command>."
12667 msgstr ""
12669 #. type: Content of: <book><chapter><sect1><sect2><para>
12670 #: ../en/ch09-undo.xml:1159
12671 msgid ""
12672 "Another useful situation in which to use <command role=\"hg-cmd\">hg bisect --"
12673 "skip</command> is if you can't test a revision because your project was in a "
12674 "broken and hence untestable state at that revision, perhaps because someone "
12675 "checked in a change that prevented the project from building."
12676 msgstr ""
12678 #. type: Content of: <book><chapter><sect1><sect2><title>
12679 #: ../en/ch09-undo.xml:1168
12680 msgid "Bracket your search lazily"
12681 msgstr "减少你的查找工作"
12683 #. type: Content of: <book><chapter><sect1><sect2><para>
12684 #: ../en/ch09-undo.xml:1170
12685 msgid ""
12686 "Choosing the first <quote>good</quote> and <quote>bad</quote> changesets that "
12687 "will mark the end points of your search is often easy, but it bears a little "
12688 "discussion nevertheless. From the perspective of <command role=\"hg-cmd\">hg "
12689 "bisect</command>, the <quote>newest</quote> changeset is conventionally "
12690 "<quote>bad</quote>, and the older changeset is <quote>good</quote>."
12691 msgstr ""
12693 #. type: Content of: <book><chapter><sect1><sect2><para>
12694 #: ../en/ch09-undo.xml:1178
12695 msgid ""
12696 "If you're having trouble remembering when a suitable <quote>good</quote> "
12697 "change was, so that you can tell <command role=\"hg-cmd\">hg bisect</"
12698 "command>, you could do worse than testing changesets at random. Just "
12699 "remember to eliminate contenders that can't possibly exhibit the bug (perhaps "
12700 "because the feature with the bug isn't present yet) and those where another "
12701 "problem masks the bug (as I discussed above)."
12702 msgstr ""
12704 #. type: Content of: <book><chapter><sect1><sect2><para>
12705 #: ../en/ch09-undo.xml:1187
12706 msgid ""
12707 "Even if you end up <quote>early</quote> by thousands of changesets or months "
12708 "of history, you will only add a handful of tests to the total number that "
12709 "<command role=\"hg-cmd\">hg bisect</command> must perform, thanks to its "
12710 "logarithmic behavior."
12711 msgstr ""
12713 #. type: Content of: <book><chapter><title>
12714 #: ../en/ch10-hook.xml:5
12715 msgid "Handling repository events with hooks"
12716 msgstr "使用钩子处理版本库事件"
12718 #. type: Content of: <book><chapter><para>
12719 #: ../en/ch10-hook.xml:7
12720 msgid ""
12721 "Mercurial offers a powerful mechanism to let you perform automated actions in "
12722 "response to events that occur in a repository. In some cases, you can even "
12723 "control Mercurial's response to those events."
12724 msgstr ""
12726 #. type: Content of: <book><chapter><para>
12727 #: ../en/ch10-hook.xml:12
12728 msgid ""
12729 "The name Mercurial uses for one of these actions is a <emphasis>hook</"
12730 "emphasis>. Hooks are called <quote>triggers</quote> in some revision control "
12731 "systems, but the two names refer to the same idea."
12732 msgstr ""
12734 #. type: Content of: <book><chapter><sect1><title>
12735 #: ../en/ch10-hook.xml:18
12736 msgid "An overview of hooks in Mercurial"
12737 msgstr "Mercurial 钩子概述"
12739 #. type: Content of: <book><chapter><sect1><para>
12740 #: ../en/ch10-hook.xml:20
12741 msgid ""
12742 "Here is a brief list of the hooks that Mercurial supports. We will revisit "
12743 "each of these hooks in more detail later, in <xref linkend=\"sec:hook:ref\"/>."
12744 msgstr ""
12746 #. type: Content of: <book><chapter><sect1><para>
12747 #: ../en/ch10-hook.xml:24
12748 msgid ""
12749 "Each of the hooks whose description begins with the word <quote>Controlling</"
12750 "quote> has the ability to determine whether an activity can proceed. If the "
12751 "hook succeeds, the activity may proceed; if it fails, the activity is either "
12752 "not permitted or undone, depending on the hook."
12753 msgstr ""
12755 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12756 #: ../en/ch10-hook.xml:31
12757 msgid ""
12758 "<literal role=\"hook\">changegroup</literal>: This is run after a group of "
12759 "changesets has been brought into the repository from elsewhere."
12760 msgstr ""
12762 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12763 #: ../en/ch10-hook.xml:35
12764 msgid ""
12765 "<literal role=\"hook\">commit</literal>: This is run after a new changeset "
12766 "has been created in the local repository."
12767 msgstr ""
12769 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12770 #: ../en/ch10-hook.xml:39
12771 msgid ""
12772 "<literal role=\"hook\">incoming</literal>: This is run once for each new "
12773 "changeset that is brought into the repository from elsewhere. Notice the "
12774 "difference from <literal role=\"hook\">changegroup</literal>, which is run "
12775 "once per <emphasis>group</emphasis> of changesets brought in."
12776 msgstr ""
12778 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12779 #: ../en/ch10-hook.xml:46
12780 msgid ""
12781 "<literal role=\"hook\">outgoing</literal>: This is run after a group of "
12782 "changesets has been transmitted from this repository."
12783 msgstr ""
12785 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12786 #: ../en/ch10-hook.xml:50
12787 msgid ""
12788 "<literal role=\"hook\">prechangegroup</literal>: This is run before starting "
12789 "to bring a group of changesets into the repository."
12790 msgstr ""
12792 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12793 #: ../en/ch10-hook.xml:55
12794 msgid ""
12795 "<literal role=\"hook\">precommit</literal>: Controlling. This is run before "
12796 "starting a commit."
12797 msgstr ""
12799 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12800 #: ../en/ch10-hook.xml:59
12801 msgid ""
12802 "<literal role=\"hook\">preoutgoing</literal>: Controlling. This is run before "
12803 "starting to transmit a group of changesets from this repository."
12804 msgstr ""
12806 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12807 #: ../en/ch10-hook.xml:64
12808 msgid ""
12809 "<literal role=\"hook\">pretag</literal>: Controlling. This is run before "
12810 "creating a tag."
12811 msgstr ""
12813 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12814 #: ../en/ch10-hook.xml:68
12815 msgid ""
12816 "<literal role=\"hook\">pretxnchangegroup</literal>: Controlling. This is run "
12817 "after a group of changesets has been brought into the local repository from "
12818 "another, but before the transaction completes that will make the changes "
12819 "permanent in the repository."
12820 msgstr ""
12822 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12823 #: ../en/ch10-hook.xml:76
12824 msgid ""
12825 "<literal role=\"hook\">pretxncommit</literal>: Controlling. This is run after "
12826 "a new changeset has been created in the local repository, but before the "
12827 "transaction completes that will make it permanent."
12828 msgstr ""
12830 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12831 #: ../en/ch10-hook.xml:82
12832 msgid ""
12833 "<literal role=\"hook\">preupdate</literal>: Controlling. This is run before "
12834 "starting an update or merge of the working directory."
12835 msgstr ""
12837 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12838 #: ../en/ch10-hook.xml:87
12839 msgid ""
12840 "<literal role=\"hook\">tag</literal>: This is run after a tag is created."
12841 msgstr ""
12843 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12844 #: ../en/ch10-hook.xml:91
12845 msgid ""
12846 "<literal role=\"hook\">update</literal>: This is run after an update or merge "
12847 "of the working directory has finished."
12848 msgstr ""
12850 #. type: Content of: <book><chapter><sect1><title>
12851 #: ../en/ch10-hook.xml:99
12852 msgid "Hooks and security"
12853 msgstr "钩子与安全性"
12855 #. type: Content of: <book><chapter><sect1><sect2><title>
12856 #: ../en/ch10-hook.xml:102
12857 msgid "Hooks are run with your privileges"
12858 msgstr "钩子以你的特权执行"
12860 #. type: Content of: <book><chapter><sect1><sect2><para>
12861 #: ../en/ch10-hook.xml:104
12862 msgid ""
12863 "When you run a Mercurial command in a repository, and the command causes a "
12864 "hook to run, that hook runs on <emphasis>your</emphasis> system, under "
12865 "<emphasis>your</emphasis> user account, with <emphasis>your</emphasis> "
12866 "privilege level. Since hooks are arbitrary pieces of executable code, you "
12867 "should treat them with an appropriate level of suspicion. Do not install a "
12868 "hook unless you are confident that you know who created it and what it does."
12869 msgstr ""
12871 #. type: Content of: <book><chapter><sect1><sect2><para>
12872 #: ../en/ch10-hook.xml:115
12873 msgid ""
12874 "In some cases, you may be exposed to hooks that you did not install "
12875 "yourself. If you work with Mercurial on an unfamiliar system, Mercurial will "
12876 "run hooks defined in that system's global <filename role=\"special\">~/.hgrc</"
12877 "filename> file."
12878 msgstr ""
12880 #. type: Content of: <book><chapter><sect1><sect2><para>
12881 #: ../en/ch10-hook.xml:122
12882 msgid ""
12883 "If you are working with a repository owned by another user, Mercurial can run "
12884 "hooks defined in that user's repository, but it will still run them as "
12885 "<quote>you</quote>. For example, if you <command role=\"hg-cmd\">hg pull</"
12886 "command> from that repository, and its <filename role=\"special\">.hg/hgrc</"
12887 "filename> defines a local <literal role=\"hook\">outgoing</literal> hook, "
12888 "that hook will run under your user account, even though you don't own that "
12889 "repository."
12890 msgstr ""
12892 #. type: Content of: <book><chapter><sect1><sect2><note><para>
12893 #: ../en/ch10-hook.xml:134
12894 msgid ""
12895 "This only applies if you are pulling from a repository on a local or network "
12896 "filesystem. If you're pulling over http or ssh, any <literal role=\"hook"
12897 "\">outgoing</literal> hook will run under whatever account is executing the "
12898 "server process, on the server."
12899 msgstr ""
12901 #. type: Content of: <book><chapter><sect1><sect2><para>
12902 #: ../en/ch10-hook.xml:142
12903 msgid ""
12904 "To see what hooks are defined in a repository, use the <command role=\"hg-cmd"
12905 "\">hg showconfig hooks</command> command. If you are working in one "
12906 "repository, but talking to another that you do not own (e.g. using <command "
12907 "role=\"hg-cmd\">hg pull</command> or <command role=\"hg-cmd\">hg incoming</"
12908 "command>), remember that it is the other repository's hooks you should be "
12909 "checking, not your own."
12910 msgstr ""
12912 #. type: Content of: <book><chapter><sect1><sect2><title>
12913 #: ../en/ch10-hook.xml:153
12914 msgid "Hooks do not propagate"
12915 msgstr "钩子不会传播"
12917 #. type: Content of: <book><chapter><sect1><sect2><para>
12918 #: ../en/ch10-hook.xml:155
12919 msgid ""
12920 "In Mercurial, hooks are not revision controlled, and do not propagate when "
12921 "you clone, or pull from, a repository. The reason for this is simple: a hook "
12922 "is a completely arbitrary piece of executable code. It runs under your user "
12923 "identity, with your privilege level, on your machine."
12924 msgstr ""
12926 #. type: Content of: <book><chapter><sect1><sect2><para>
12927 #: ../en/ch10-hook.xml:162
12928 msgid ""
12929 "It would be extremely reckless for any distributed revision control system to "
12930 "implement revision-controlled hooks, as this would offer an easily "
12931 "exploitable way to subvert the accounts of users of the revision control "
12932 "system."
12933 msgstr ""
12935 #. type: Content of: <book><chapter><sect1><sect2><para>
12936 #: ../en/ch10-hook.xml:168
12937 msgid ""
12938 "Since Mercurial does not propagate hooks, if you are collaborating with other "
12939 "people on a common project, you should not assume that they are using the "
12940 "same Mercurial hooks as you are, or that theirs are correctly configured. "
12941 "You should document the hooks you expect people to use."
12942 msgstr ""
12944 #. type: Content of: <book><chapter><sect1><sect2><para>
12945 #: ../en/ch10-hook.xml:175
12946 msgid ""
12947 "In a corporate intranet, this is somewhat easier to control, as you can for "
12948 "example provide a <quote>standard</quote> installation of Mercurial on an NFS "
12949 "filesystem, and use a site-wide <filename role=\"special\">~/.hgrc</filename> "
12950 "file to define hooks that all users will see. However, this too has its "
12951 "limits; see below."
12952 msgstr ""
12954 #. type: Content of: <book><chapter><sect1><sect2><title>
12955 #: ../en/ch10-hook.xml:184
12956 msgid "Hooks can be overridden"
12957 msgstr "钩子可以被覆盖"
12959 #. type: Content of: <book><chapter><sect1><sect2><para>
12960 #: ../en/ch10-hook.xml:186
12961 msgid ""
12962 "Mercurial allows you to override a hook definition by redefining the hook. "
12963 "You can disable it by setting its value to the empty string, or change its "
12964 "behavior as you wish."
12965 msgstr ""
12967 #. type: Content of: <book><chapter><sect1><sect2><para>
12968 #: ../en/ch10-hook.xml:191
12969 msgid ""
12970 "If you deploy a system- or site-wide <filename role=\"special\">~/.hgrc</"
12971 "filename> file that defines some hooks, you should thus understand that your "
12972 "users can disable or override those hooks."
12973 msgstr ""
12975 #. type: Content of: <book><chapter><sect1><sect2><title>
12976 #: ../en/ch10-hook.xml:199
12977 msgid "Ensuring that critical hooks are run"
12978 msgstr "确保关键钩子的执行"
12980 #. type: Content of: <book><chapter><sect1><sect2><para>
12981 #: ../en/ch10-hook.xml:201
12982 msgid ""
12983 "Sometimes you may want to enforce a policy that you do not want others to be "
12984 "able to work around. For example, you may have a requirement that every "
12985 "changeset must pass a rigorous set of tests. Defining this requirement via a "
12986 "hook in a site-wide <filename role=\"special\">~/.hgrc</filename> won't work "
12987 "for remote users on laptops, and of course local users can subvert it at will "
12988 "by overriding the hook."
12989 msgstr ""
12991 #. type: Content of: <book><chapter><sect1><sect2><para>
12992 #: ../en/ch10-hook.xml:210
12993 msgid ""
12994 "Instead, you can set up your policies for use of Mercurial so that people are "
12995 "expected to propagate changes through a well-known <quote>canonical</quote> "
12996 "server that you have locked down and configured appropriately."
12997 msgstr ""
12999 #. type: Content of: <book><chapter><sect1><sect2><para>
13000 #: ../en/ch10-hook.xml:216
13001 msgid ""
13002 "One way to do this is via a combination of social engineering and "
13003 "technology. Set up a restricted-access account; users can push changes over "
13004 "the network to repositories managed by this account, but they cannot log into "
13005 "the account and run normal shell commands. In this scenario, a user can "
13006 "commit a changeset that contains any old garbage they want."
13007 msgstr ""
13009 #. type: Content of: <book><chapter><sect1><sect2><para>
13010 #: ../en/ch10-hook.xml:225
13011 msgid ""
13012 "When someone pushes a changeset to the server that everyone pulls from, the "
13013 "server will test the changeset before it accepts it as permanent, and reject "
13014 "it if it fails to pass the test suite. If people only pull changes from this "
13015 "filtering server, it will serve to ensure that all changes that people pull "
13016 "have been automatically vetted."
13017 msgstr ""
13019 #. type: Content of: <book><chapter><sect1><title>
13020 #: ../en/ch10-hook.xml:237
13021 msgid "A short tutorial on using hooks"
13022 msgstr "使用钩子的简短指南"
13024 #. type: Content of: <book><chapter><sect1><para>
13025 #: ../en/ch10-hook.xml:239
13026 msgid ""
13027 "It is easy to write a Mercurial hook. Let's start with a hook that runs when "
13028 "you finish a <command role=\"hg-cmd\">hg commit</command>, and simply prints "
13029 "the hash of the changeset you just created. The hook is called <literal role="
13030 "\"hook\">commit</literal>."
13031 msgstr ""
13033 #. type: Content of: <book><chapter><sect1><para>
13034 #: ../en/ch10-hook.xml:246
13035 msgid "All hooks follow the pattern in this example."
13036 msgstr ""
13038 #. type: Content of: <book><chapter><sect1><para>
13039 #: ../en/ch10-hook.xml:250
13040 msgid ""
13041 "You add an entry to the <literal role=\"rc-hooks\">hooks</literal> section of "
13042 "your <filename role=\"special\">~/.hgrc</filename>. On the left is the name "
13043 "of the event to trigger on; on the right is the action to take. As you can "
13044 "see, you can run an arbitrary shell command in a hook. Mercurial passes "
13045 "extra information to the hook using environment variables (look for "
13046 "<envar>HG_NODE</envar> in the example)."
13047 msgstr ""
13049 #. type: Content of: <book><chapter><sect1><sect2><title>
13050 #: ../en/ch10-hook.xml:260
13051 msgid "Performing multiple actions per event"
13052 msgstr "每个事件执行多个操作"
13054 #. type: Content of: <book><chapter><sect1><sect2><para>
13055 #: ../en/ch10-hook.xml:262
13056 msgid ""
13057 "Quite often, you will want to define more than one hook for a particular kind "
13058 "of event, as shown below."
13059 msgstr ""
13061 #. type: Content of: <book><chapter><sect1><sect2><para>
13062 #: ../en/ch10-hook.xml:267
13063 msgid ""
13064 "Mercurial lets you do this by adding an <emphasis>extension</emphasis> to the "
13065 "end of a hook's name. You extend a hook's name by giving the name of the "
13066 "hook, followed by a full stop (the <quote><literal>.</literal></quote> "
13067 "character), followed by some more text of your choosing. For example, "
13068 "Mercurial will run both <literal>commit.foo</literal> and <literal>commit."
13069 "bar</literal> when the <literal>commit</literal> event occurs."
13070 msgstr ""
13072 #. type: Content of: <book><chapter><sect1><sect2><para>
13073 #: ../en/ch10-hook.xml:278
13074 msgid ""
13075 "To give a well-defined order of execution when there are multiple hooks "
13076 "defined for an event, Mercurial sorts hooks by extension, and executes the "
13077 "hook commands in this sorted order. In the above example, it will execute "
13078 "<literal>commit.bar</literal> before <literal>commit.foo</literal>, and "
13079 "<literal>commit</literal> before both."
13080 msgstr ""
13082 #. type: Content of: <book><chapter><sect1><sect2><para>
13083 #: ../en/ch10-hook.xml:287
13084 msgid ""
13085 "It is a good idea to use a somewhat descriptive extension when you define a "
13086 "new hook. This will help you to remember what the hook was for. If the hook "
13087 "fails, you'll get an error message that contains the hook name and extension, "
13088 "so using a descriptive extension could give you an immediate hint as to why "
13089 "the hook failed (see <xref linkend=\"sec:hook:perm\"/> for an example)."
13090 msgstr ""
13092 #. type: Content of: <book><chapter><sect1><sect2><title>
13093 #: ../en/ch10-hook.xml:298
13094 msgid "Controlling whether an activity can proceed"
13095 msgstr "控制处理的活动"
13097 #. type: Content of: <book><chapter><sect1><sect2><para>
13098 #: ../en/ch10-hook.xml:300
13099 msgid ""
13100 "In our earlier examples, we used the <literal role=\"hook\">commit</literal> "
13101 "hook, which is run after a commit has completed. This is one of several "
13102 "Mercurial hooks that run after an activity finishes. Such hooks have no way "
13103 "of influencing the activity itself."
13104 msgstr ""
13106 #. type: Content of: <book><chapter><sect1><sect2><para>
13107 #: ../en/ch10-hook.xml:307
13108 msgid ""
13109 "Mercurial defines a number of events that occur before an activity starts; or "
13110 "after it starts, but before it finishes. Hooks that trigger on these events "
13111 "have the added ability to choose whether the activity can continue, or will "
13112 "abort."
13113 msgstr ""
13115 #. type: Content of: <book><chapter><sect1><sect2><para>
13116 #: ../en/ch10-hook.xml:313
13117 msgid ""
13118 "The <literal role=\"hook\">pretxncommit</literal> hook runs after a commit "
13119 "has all but completed. In other words, the metadata representing the "
13120 "changeset has been written out to disk, but the transaction has not yet been "
13121 "allowed to complete. The <literal role=\"hook\">pretxncommit</literal> hook "
13122 "has the ability to decide whether the transaction can complete, or must be "
13123 "rolled back."
13124 msgstr ""
13126 #. type: Content of: <book><chapter><sect1><sect2><para>
13127 #: ../en/ch10-hook.xml:322
13128 msgid ""
13129 "If the <literal role=\"hook\">pretxncommit</literal> hook exits with a status "
13130 "code of zero, the transaction is allowed to complete; the commit finishes; "
13131 "and the <literal role=\"hook\">commit</literal> hook is run. If the <literal "
13132 "role=\"hook\">pretxncommit</literal> hook exits with a non-zero status code, "
13133 "the transaction is rolled back; the metadata representing the changeset is "
13134 "erased; and the <literal role=\"hook\">commit</literal> hook is not run."
13135 msgstr ""
13137 #. type: Content of: <book><chapter><sect1><sect2><para>
13138 #: ../en/ch10-hook.xml:334
13139 msgid ""
13140 "The hook in the example above checks that a commit comment contains a bug "
13141 "ID. If it does, the commit can complete. If not, the commit is rolled back."
13142 msgstr ""
13144 #. type: Content of: <book><chapter><sect1><title>
13145 #: ../en/ch10-hook.xml:342
13146 msgid "Writing your own hooks"
13147 msgstr "编写钩子"
13149 #. type: Content of: <book><chapter><sect1><para>
13150 #: ../en/ch10-hook.xml:344
13151 msgid ""
13152 "When you are writing a hook, you might find it useful to run Mercurial either "
13153 "with the <option role=\"hg-opt-global\">-v</option> option, or the <envar "
13154 "role=\"rc-item-ui\">verbose</envar> config item set to <quote>true</quote>. "
13155 "When you do so, Mercurial will print a message before it calls each hook."
13156 msgstr ""
13158 #. type: Content of: <book><chapter><sect1><sect2><title>
13159 #: ../en/ch10-hook.xml:353
13160 msgid "Choosing how your hook should run"
13161 msgstr "选择钩子的执行方式"
13163 #. type: Content of: <book><chapter><sect1><sect2><para>
13164 #: ../en/ch10-hook.xml:355
13165 msgid ""
13166 "You can write a hook either as a normal program&emdash;typically a shell "
13167 "script&emdash;or as a Python function that is executed within the Mercurial "
13168 "process."
13169 msgstr ""
13171 #. type: Content of: <book><chapter><sect1><sect2><para>
13172 #: ../en/ch10-hook.xml:360
13173 msgid ""
13174 "Writing a hook as an external program has the advantage that it requires no "
13175 "knowledge of Mercurial's internals. You can call normal Mercurial commands "
13176 "to get any added information you need. The trade-off is that external hooks "
13177 "are slower than in-process hooks."
13178 msgstr ""
13180 #. type: Content of: <book><chapter><sect1><sect2><para>
13181 #: ../en/ch10-hook.xml:367
13182 msgid ""
13183 "An in-process Python hook has complete access to the Mercurial API, and does "
13184 "not <quote>shell out</quote> to another process, so it is inherently faster "
13185 "than an external hook. It is also easier to obtain much of the information "
13186 "that a hook requires by using the Mercurial API than by running Mercurial "
13187 "commands."
13188 msgstr ""
13190 #. type: Content of: <book><chapter><sect1><sect2><para>
13191 #: ../en/ch10-hook.xml:375
13192 msgid ""
13193 "If you are comfortable with Python, or require high performance, writing your "
13194 "hooks in Python may be a good choice. However, when you have a "
13195 "straightforward hook to write and you don't need to care about performance "
13196 "(probably the majority of hooks), a shell script is perfectly fine."
13197 msgstr ""
13199 #. type: Content of: <book><chapter><sect1><sect2><title>
13200 #: ../en/ch10-hook.xml:384
13201 msgid "Hook parameters"
13202 msgstr "钩子的参数"
13204 #. type: Content of: <book><chapter><sect1><sect2><para>
13205 #: ../en/ch10-hook.xml:386
13206 msgid ""
13207 "Mercurial calls each hook with a set of well-defined parameters. In Python, "
13208 "a parameter is passed as a keyword argument to your hook function. For an "
13209 "external program, a parameter is passed as an environment variable."
13210 msgstr ""
13212 #. type: Content of: <book><chapter><sect1><sect2><para>
13213 #: ../en/ch10-hook.xml:392
13214 msgid ""
13215 "Whether your hook is written in Python or as a shell script, the hook-"
13216 "specific parameter names and values will be the same. A boolean parameter "
13217 "will be represented as a boolean value in Python, but as the number 1 (for "
13218 "<quote>true</quote>) or 0 (for <quote>false</quote>) as an environment "
13219 "variable for an external hook. If a hook parameter is named <literal>foo</"
13220 "literal>, the keyword argument for a Python hook will also be named "
13221 "<literal>foo</literal>, while the environment variable for an external hook "
13222 "will be named <literal>HG_FOO</literal>."
13223 msgstr ""
13225 #. type: Content of: <book><chapter><sect1><sect2><title>
13226 #: ../en/ch10-hook.xml:406
13227 msgid "Hook return values and activity control"
13228 msgstr "钩子的返回值与活动控制"
13230 #. type: Content of: <book><chapter><sect1><sect2><para>
13231 #: ../en/ch10-hook.xml:408
13232 msgid ""
13233 "A hook that executes successfully must exit with a status of zero if "
13234 "external, or return boolean <quote>false</quote> if in-process. Failure is "
13235 "indicated with a non-zero exit status from an external hook, or an in-process "
13236 "hook returning boolean <quote>true</quote>. If an in-process hook raises an "
13237 "exception, the hook is considered to have failed."
13238 msgstr ""
13240 #. type: Content of: <book><chapter><sect1><sect2><para>
13241 #: ../en/ch10-hook.xml:416
13242 msgid ""
13243 "For a hook that controls whether an activity can proceed, zero/false means "
13244 "<quote>allow</quote>, while non-zero/true/exception means <quote>deny</quote>."
13245 msgstr ""
13247 #. type: Content of: <book><chapter><sect1><sect2><title>
13248 #: ../en/ch10-hook.xml:423
13249 msgid "Writing an external hook"
13250 msgstr "编写外部钩子"
13252 #. type: Content of: <book><chapter><sect1><sect2><para>
13253 #: ../en/ch10-hook.xml:425
13254 msgid ""
13255 "When you define an external hook in your <filename role=\"special\">~/.hgrc</"
13256 "filename> and the hook is run, its value is passed to your shell, which "
13257 "interprets it. This means that you can use normal shell constructs in the "
13258 "body of the hook."
13259 msgstr ""
13261 #. type: Content of: <book><chapter><sect1><sect2><para>
13262 #: ../en/ch10-hook.xml:432
13263 msgid ""
13264 "An executable hook is always run with its current directory set to a "
13265 "repository's root directory."
13266 msgstr ""
13268 #. type: Content of: <book><chapter><sect1><sect2><para>
13269 #: ../en/ch10-hook.xml:436
13270 msgid ""
13271 "Each hook parameter is passed in as an environment variable; the name is "
13272 "upper-cased, and prefixed with the string <quote><literal>HG_</literal></"
13273 "quote>."
13274 msgstr ""
13276 #. type: Content of: <book><chapter><sect1><sect2><para>
13277 #: ../en/ch10-hook.xml:441
13278 msgid ""
13279 "With the exception of hook parameters, Mercurial does not set or modify any "
13280 "environment variables when running a hook. This is useful to remember if you "
13281 "are writing a site-wide hook that may be run by a number of different users "
13282 "with differing environment variables set. In multi-user situations, you "
13283 "should not rely on environment variables being set to the values you have in "
13284 "your environment when testing the hook."
13285 msgstr ""
13287 #. type: Content of: <book><chapter><sect1><sect2><title>
13288 #: ../en/ch10-hook.xml:452
13289 msgid "Telling Mercurial to use an in-process hook"
13290 msgstr "让 Mercurial 使用进程内钩子"
13292 #. type: Content of: <book><chapter><sect1><sect2><para>
13293 #: ../en/ch10-hook.xml:454
13294 msgid ""
13295 "The <filename role=\"special\">~/.hgrc</filename> syntax for defining an in-"
13296 "process hook is slightly different than for an executable hook. The value of "
13297 "the hook must start with the text <quote><literal>python:</literal></quote>, "
13298 "and continue with the fully-qualified name of a callable object to use as the "
13299 "hook's value."
13300 msgstr ""
13302 #. type: Content of: <book><chapter><sect1><sect2><para>
13303 #: ../en/ch10-hook.xml:462
13304 msgid ""
13305 "The module in which a hook lives is automatically imported when a hook is "
13306 "run. So long as you have the module name and <envar>PYTHONPATH</envar> "
13307 "right, it should <quote>just work</quote>."
13308 msgstr ""
13310 #. type: Content of: <book><chapter><sect1><sect2><para>
13311 #: ../en/ch10-hook.xml:468
13312 msgid ""
13313 "The following <filename role=\"special\">~/.hgrc</filename> example snippet "
13314 "illustrates the syntax and meaning of the notions we just described."
13315 msgstr ""
13317 #. type: Content of: <book><chapter><sect1><sect2><para>
13318 #: ../en/ch10-hook.xml:474
13319 msgid ""
13320 "When Mercurial runs the <literal>commit.example</literal> hook, it imports "
13321 "<literal>mymodule.submodule</literal>, looks for the callable object named "
13322 "<literal>myhook</literal>, and calls it."
13323 msgstr ""
13325 #. type: Content of: <book><chapter><sect1><sect2><title>
13326 #: ../en/ch10-hook.xml:482
13327 msgid "Writing an in-process hook"
13328 msgstr "编写进程内钩子"
13330 #. type: Content of: <book><chapter><sect1><sect2><para>
13331 #: ../en/ch10-hook.xml:484
13332 msgid ""
13333 "The simplest in-process hook does nothing, but illustrates the basic shape of "
13334 "the hook API:"
13335 msgstr ""
13337 #. type: Content of: <book><chapter><sect1><sect2><para>
13338 #: ../en/ch10-hook.xml:489
13339 msgid ""
13340 "The first argument to a Python hook is always a <literal role=\"py-mod-"
13341 "mercurial.ui\">ui</literal> object. The second is a repository object; at "
13342 "the moment, it is always an instance of <literal role=\"py-mod-mercurial."
13343 "localrepo\">localrepository</literal>. Following these two arguments are "
13344 "other keyword arguments. Which ones are passed in depends on the hook being "
13345 "called, but a hook can ignore arguments it doesn't care about by dropping "
13346 "them into a keyword argument dict, as with <literal>**kwargs</literal> above."
13347 msgstr ""
13349 #. type: Content of: <book><chapter><sect1><title>
13350 #: ../en/ch10-hook.xml:504
13351 msgid "Some hook examples"
13352 msgstr "钩子样例"
13354 #. type: Content of: <book><chapter><sect1><sect2><title>
13355 #: ../en/ch10-hook.xml:507
13356 msgid "Writing meaningful commit messages"
13357 msgstr "编写有意义的提交日志"
13359 #. type: Content of: <book><chapter><sect1><sect2><para>
13360 #: ../en/ch10-hook.xml:509
13361 msgid ""
13362 "It's hard to imagine a useful commit message being very short. The simple "
13363 "<literal role=\"hook\">pretxncommit</literal> hook of the example below will "
13364 "prevent you from committing a changeset with a message that is less than ten "
13365 "bytes long."
13366 msgstr ""
13368 #. type: Content of: <book><chapter><sect1><sect2><title>
13369 #: ../en/ch10-hook.xml:519
13370 msgid "Checking for trailing whitespace"
13371 msgstr "检查行尾空格"
13373 #. type: Content of: <book><chapter><sect1><sect2><para>
13374 #: ../en/ch10-hook.xml:521
13375 msgid ""
13376 "An interesting use of a commit-related hook is to help you to write cleaner "
13377 "code. A simple example of <quote>cleaner code</quote> is the dictum that a "
13378 "change should not add any new lines of text that contain <quote>trailing "
13379 "whitespace</quote>. Trailing whitespace is a series of space and tab "
13380 "characters at the end of a line of text. In most cases, trailing whitespace "
13381 "is unnecessary, invisible noise, but it is occasionally problematic, and "
13382 "people often prefer to get rid of it."
13383 msgstr ""
13385 #. type: Content of: <book><chapter><sect1><sect2><para>
13386 #: ../en/ch10-hook.xml:532
13387 msgid ""
13388 "You can use either the <literal role=\"hook\">precommit</literal> or <literal "
13389 "role=\"hook\">pretxncommit</literal> hook to tell whether you have a trailing "
13390 "whitespace problem. If you use the <literal role=\"hook\">precommit</"
13391 "literal> hook, the hook will not know which files you are committing, so it "
13392 "will have to check every modified file in the repository for trailing white "
13393 "space. If you want to commit a change to just the file <filename>foo</"
13394 "filename>, but the file <filename>bar</filename> contains trailing "
13395 "whitespace, doing a check in the <literal role=\"hook\">precommit</literal> "
13396 "hook will prevent you from committing <filename>foo</filename> due to the "
13397 "problem with <filename>bar</filename>. This doesn't seem right."
13398 msgstr ""
13400 #. type: Content of: <book><chapter><sect1><sect2><para>
13401 #: ../en/ch10-hook.xml:548
13402 msgid ""
13403 "Should you choose the <literal role=\"hook\">pretxncommit</literal> hook, the "
13404 "check won't occur until just before the transaction for the commit "
13405 "completes. This will allow you to check for problems only the exact files "
13406 "that are being committed. However, if you entered the commit message "
13407 "interactively and the hook fails, the transaction will roll back; you'll have "
13408 "to re-enter the commit message after you fix the trailing whitespace and run "
13409 "<command role=\"hg-cmd\">hg commit</command> again."
13410 msgstr ""
13412 #. type: Content of: <book><chapter><sect1><sect2><para>
13413 #: ../en/ch10-hook.xml:561
13414 msgid ""
13415 "In this example, we introduce a simple <literal role=\"hook\">pretxncommit</"
13416 "literal> hook that checks for trailing whitespace. This hook is short, but "
13417 "not very helpful. It exits with an error status if a change adds a line with "
13418 "trailing whitespace to any file, but does not print any information that "
13419 "might help us to identify the offending file or line. It also has the nice "
13420 "property of not paying attention to unmodified lines; only lines that "
13421 "introduce new trailing whitespace cause problems."
13422 msgstr ""
13424 #. type: Content of: <book><chapter><sect1><sect2><para>
13425 #: ../en/ch10-hook.xml:574
13426 msgid ""
13427 "The above version is much more complex, but also more useful. It parses a "
13428 "unified diff to see if any lines add trailing whitespace, and prints the name "
13429 "of the file and the line number of each such occurrence. Even better, if the "
13430 "change adds trailing whitespace, this hook saves the commit comment and "
13431 "prints the name of the save file before exiting and telling Mercurial to roll "
13432 "the transaction back, so you can use the <option role=\"hg-opt-commit\">-l "
13433 "filename</option> option to <command role=\"hg-cmd\">hg commit</command> to "
13434 "reuse the saved commit message once you've corrected the problem."
13435 msgstr ""
13437 #. type: Content of: <book><chapter><sect1><sect2><para>
13438 #: ../en/ch10-hook.xml:588
13439 msgid ""
13440 "As a final aside, note in the example above the use of <command>sed</"
13441 "command>'s in-place editing feature to get rid of trailing whitespace from a "
13442 "file. This is concise and useful enough that I will reproduce it here (using "
13443 "<command>perl</command> for good measure)."
13444 msgstr ""
13446 #. type: Content of: <book><chapter><sect1><title>
13447 #: ../en/ch10-hook.xml:598
13448 msgid "Bundled hooks"
13449 msgstr "内置的钩子"
13451 #. type: Content of: <book><chapter><sect1><para>
13452 #: ../en/ch10-hook.xml:600
13453 msgid ""
13454 "Mercurial ships with several bundled hooks. You can find them in the "
13455 "<filename class=\"directory\">hgext</filename> directory of a Mercurial "
13456 "source tree. If you are using a Mercurial binary package, the hooks will be "
13457 "located in the <filename class=\"directory\">hgext</filename> directory of "
13458 "wherever your package installer put Mercurial."
13459 msgstr ""
13461 #. type: Content of: <book><chapter><sect1><sect2><title>
13462 #: ../en/ch10-hook.xml:609
13463 msgid ""
13464 "<literal role=\"hg-ext\">acl</literal>&emdash;access control for parts of a "
13465 "repository"
13466 msgstr "<literal role=\"hg-ext\">acl</literal>—版本库的访问控制"
13468 #. type: Content of: <book><chapter><sect1><sect2><para>
13469 #: ../en/ch10-hook.xml:612
13470 msgid ""
13471 "The <literal role=\"hg-ext\">acl</literal> extension lets you control which "
13472 "remote users are allowed to push changesets to a networked server. You can "
13473 "protect any portion of a repository (including the entire repo), so that a "
13474 "specific remote user can push changes that do not affect the protected "
13475 "portion."
13476 msgstr ""
13478 #. type: Content of: <book><chapter><sect1><sect2><para>
13479 #: ../en/ch10-hook.xml:620
13480 msgid ""
13481 "This extension implements access control based on the identity of the user "
13482 "performing a push, <emphasis>not</emphasis> on who committed the changesets "
13483 "they're pushing. It makes sense to use this hook only if you have a locked-"
13484 "down server environment that authenticates remote users, and you want to be "
13485 "sure that only specific users are allowed to push changes to that server."
13486 msgstr ""
13488 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
13489 #: ../en/ch10-hook.xml:630
13490 msgid "Configuring the <literal role=\"hook\">acl</literal> hook"
13491 msgstr "配置 <literal role=\"hook\">acl</literal> 钩子"
13493 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13494 #: ../en/ch10-hook.xml:633
13495 msgid ""
13496 "In order to manage incoming changesets, the <literal role=\"hg-ext\">acl</"
13497 "literal> hook must be used as a <literal role=\"hook\">pretxnchangegroup</"
13498 "literal> hook. This lets it see which files are modified by each incoming "
13499 "changeset, and roll back a group of changesets if they modify "
13500 "<quote>forbidden</quote> files. Example:"
13501 msgstr ""
13503 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13504 #: ../en/ch10-hook.xml:643
13505 msgid ""
13506 "The <literal role=\"hg-ext\">acl</literal> extension is configured using "
13507 "three sections."
13508 msgstr ""
13510 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13511 #: ../en/ch10-hook.xml:647
13512 msgid ""
13513 "The <literal role=\"rc-acl\">acl</literal> section has only one entry, <envar "
13514 "role=\"rc-item-acl\">sources</envar>, which lists the sources of incoming "
13515 "changesets that the hook should pay attention to. You don't normally need to "
13516 "configure this section."
13517 msgstr ""
13519 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13520 #: ../en/ch10-hook.xml:654
13521 msgid ""
13522 "<envar role=\"rc-item-acl\">serve</envar>: Control incoming changesets that "
13523 "are arriving from a remote repository over http or ssh. This is the default "
13524 "value of <envar role=\"rc-item-acl\">sources</envar>, and usually the only "
13525 "setting you'll need for this configuration item."
13526 msgstr ""
13528 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13529 #: ../en/ch10-hook.xml:662
13530 msgid ""
13531 "<envar role=\"rc-item-acl\">pull</envar>: Control incoming changesets that "
13532 "are arriving via a pull from a local repository."
13533 msgstr ""
13535 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13536 #: ../en/ch10-hook.xml:667
13537 msgid ""
13538 "<envar role=\"rc-item-acl\">push</envar>: Control incoming changesets that "
13539 "are arriving via a push from a local repository."
13540 msgstr ""
13542 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13543 #: ../en/ch10-hook.xml:672
13544 msgid ""
13545 "<envar role=\"rc-item-acl\">bundle</envar>: Control incoming changesets that "
13546 "are arriving from another repository via a bundle."
13547 msgstr ""
13549 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13550 #: ../en/ch10-hook.xml:678
13551 msgid ""
13552 "The <literal role=\"rc-acl.allow\">acl.allow</literal> section controls the "
13553 "users that are allowed to add changesets to the repository. If this section "
13554 "is not present, all users that are not explicitly denied are allowed. If "
13555 "this section is present, all users that are not explicitly allowed are denied "
13556 "(so an empty section means that all users are denied)."
13557 msgstr ""
13559 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13560 #: ../en/ch10-hook.xml:687
13561 msgid ""
13562 "The <literal role=\"rc-acl.deny\">acl.deny</literal> section determines which "
13563 "users are denied from adding changesets to the repository. If this section "
13564 "is not present or is empty, no users are denied."
13565 msgstr ""
13567 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13568 #: ../en/ch10-hook.xml:693
13569 msgid ""
13570 "The syntaxes for the <literal role=\"rc-acl.allow\">acl.allow</literal> and "
13571 "<literal role=\"rc-acl.deny\">acl.deny</literal> sections are identical. On "
13572 "the left of each entry is a glob pattern that matches files or directories, "
13573 "relative to the root of the repository; on the right, a user name."
13574 msgstr ""
13576 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13577 #: ../en/ch10-hook.xml:701
13578 msgid ""
13579 "In the following example, the user <literal>docwriter</literal> can only push "
13580 "changes to the <filename class=\"directory\">docs</filename> subtree of the "
13581 "repository, while <literal>intern</literal> can push changes to any file or "
13582 "directory except <filename class=\"directory\">source/sensitive</filename>."
13583 msgstr ""
13585 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
13586 #: ../en/ch10-hook.xml:715 ../en/ch10-hook.xml:979 ../en/ch10-hook.xml:1169
13587 msgid "Testing and troubleshooting"
13588 msgstr "测试与问题处理"
13590 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13591 #: ../en/ch10-hook.xml:717
13592 msgid ""
13593 "If you want to test the <literal role=\"hg-ext\">acl</literal> hook, run it "
13594 "with Mercurial's debugging output enabled. Since you'll probably be running "
13595 "it on a server where it's not convenient (or sometimes possible) to pass in "
13596 "the <option role=\"hg-opt-global\">--debug</option> option, don't forget that "
13597 "you can enable debugging output in your <filename role=\"special\">~/.hgrc</"
13598 "filename>:"
13599 msgstr ""
13601 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13602 #: ../en/ch10-hook.xml:728
13603 msgid ""
13604 "With this enabled, the <literal role=\"hg-ext\">acl</literal> hook will print "
13605 "enough information to let you figure out why it is allowing or forbidding "
13606 "pushes from specific users."
13607 msgstr ""
13609 #. type: Content of: <book><chapter><sect1><sect2><title>
13610 #: ../en/ch10-hook.xml:737
13611 msgid ""
13612 "<literal role=\"hg-ext\">bugzilla</literal>&emdash;integration with Bugzilla"
13613 msgstr "<literal role=\"hg-ext\">bugzilla</literal>—与 Bugzilla 的集成"
13615 #. type: Content of: <book><chapter><sect1><sect2><para>
13616 #: ../en/ch10-hook.xml:741
13617 msgid ""
13618 "The <literal role=\"hg-ext\">bugzilla</literal> extension adds a comment to a "
13619 "Bugzilla bug whenever it finds a reference to that bug ID in a commit "
13620 "comment. You can install this hook on a shared server, so that any time a "
13621 "remote user pushes changes to this server, the hook gets run."
13622 msgstr ""
13624 #. type: Content of: <book><chapter><sect1><sect2><para>
13625 #: ../en/ch10-hook.xml:748
13626 msgid ""
13627 "It adds a comment to the bug that looks like this (you can configure the "
13628 "contents of the comment&emdash;see below):"
13629 msgstr ""
13631 #. type: Content of: <book><chapter><sect1><sect2><para>
13632 #: ../en/ch10-hook.xml:757
13633 msgid ""
13634 "The value of this hook is that it automates the process of updating a bug any "
13635 "time a changeset refers to it. If you configure the hook properly, it makes "
13636 "it easy for people to browse straight from a Bugzilla bug to a changeset that "
13637 "refers to that bug."
13638 msgstr ""
13640 #. type: Content of: <book><chapter><sect1><sect2><para>
13641 #: ../en/ch10-hook.xml:764
13642 msgid ""
13643 "You can use the code in this hook as a starting point for some more exotic "
13644 "Bugzilla integration recipes. Here are a few possibilities:"
13645 msgstr ""
13647 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13648 #: ../en/ch10-hook.xml:769
13649 msgid ""
13650 "Require that every changeset pushed to the server have a valid bug ID in its "
13651 "commit comment. In this case, you'd want to configure the hook as a <literal "
13652 "role=\"hook\">pretxncommit</literal> hook. This would allow the hook to "
13653 "reject changes that didn't contain bug IDs."
13654 msgstr ""
13656 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13657 #: ../en/ch10-hook.xml:777
13658 msgid ""
13659 "Allow incoming changesets to automatically modify the <emphasis>state</"
13660 "emphasis> of a bug, as well as simply adding a comment. For example, the "
13661 "hook could recognise the string <quote>fixed bug 31337</quote> as indicating "
13662 "that it should update the state of bug 31337 to <quote>requires testing</"
13663 "quote>."
13664 msgstr ""
13666 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
13667 #: ../en/ch10-hook.xml:787
13668 msgid "Configuring the <literal role=\"hook\">bugzilla</literal> hook"
13669 msgstr "配置 <literal role=\"hook\">bugzilla</literal> 钩子"
13671 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13672 #: ../en/ch10-hook.xml:790
13673 msgid ""
13674 "You should configure this hook in your server's <filename role=\"special\">~/."
13675 "hgrc</filename> as an <literal role=\"hook\">incoming</literal> hook, for "
13676 "example as follows:"
13677 msgstr ""
13679 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13680 #: ../en/ch10-hook.xml:798
13681 msgid ""
13682 "Because of the specialised nature of this hook, and because Bugzilla was not "
13683 "written with this kind of integration in mind, configuring this hook is a "
13684 "somewhat involved process."
13685 msgstr ""
13687 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13688 #: ../en/ch10-hook.xml:804
13689 msgid ""
13690 "Before you begin, you must install the MySQL bindings for Python on the host"
13691 "(s) where you'll be running the hook. If this is not available as a binary "
13692 "package for your system, you can download it from <citation>web:mysql-python</"
13693 "citation>."
13694 msgstr ""
13696 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13697 #: ../en/ch10-hook.xml:811
13698 msgid ""
13699 "Configuration information for this hook lives in the <literal role=\"rc-"
13700 "bugzilla\">bugzilla</literal> section of your <filename role=\"special\">~/."
13701 "hgrc</filename>."
13702 msgstr ""
13704 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13705 #: ../en/ch10-hook.xml:816
13706 msgid ""
13707 "<envar role=\"rc-item-bugzilla\">version</envar>: The version of Bugzilla "
13708 "installed on the server. The database schema that Bugzilla uses changes "
13709 "occasionally, so this hook has to know exactly which schema to use."
13710 msgstr ""
13712 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13713 #: ../en/ch10-hook.xml:822
13714 msgid ""
13715 "<envar role=\"rc-item-bugzilla\">host</envar>: The hostname of the MySQL "
13716 "server that stores your Bugzilla data. The database must be configured to "
13717 "allow connections from whatever host you are running the <literal role=\"hook"
13718 "\">bugzilla</literal> hook on."
13719 msgstr ""
13721 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13722 #: ../en/ch10-hook.xml:829
13723 msgid ""
13724 "<envar role=\"rc-item-bugzilla\">user</envar>: The username with which to "
13725 "connect to the MySQL server. The database must be configured to allow this "
13726 "user to connect from whatever host you are running the <literal role=\"hook"
13727 "\">bugzilla</literal> hook on. This user must be able to access and modify "
13728 "Bugzilla tables. The default value of this item is <literal>bugs</literal>, "
13729 "which is the standard name of the Bugzilla user in a MySQL database."
13730 msgstr ""
13732 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13733 #: ../en/ch10-hook.xml:840
13734 msgid ""
13735 "<envar role=\"rc-item-bugzilla\">password</envar>: The MySQL password for the "
13736 "user you configured above. This is stored as plain text, so you should make "
13737 "sure that unauthorised users cannot read the <filename role=\"special\">~/."
13738 "hgrc</filename> file where you store this information."
13739 msgstr ""
13741 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13742 #: ../en/ch10-hook.xml:849
13743 msgid ""
13744 "<envar role=\"rc-item-bugzilla\">db</envar>: The name of the Bugzilla "
13745 "database on the MySQL server. The default value of this item is "
13746 "<literal>bugs</literal>, which is the standard name of the MySQL database "
13747 "where Bugzilla stores its data."
13748 msgstr ""
13750 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13751 #: ../en/ch10-hook.xml:856
13752 msgid ""
13753 "<envar role=\"rc-item-bugzilla\">notify</envar>: If you want Bugzilla to send "
13754 "out a notification email to subscribers after this hook has added a comment "
13755 "to a bug, you will need this hook to run a command whenever it updates the "
13756 "database. The command to run depends on where you have installed Bugzilla, "
13757 "but it will typically look something like this, if you have Bugzilla "
13758 "installed in <filename class=\"directory\">/var/www/html/bugzilla</filename>:"
13759 msgstr ""
13761 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13762 #: ../en/ch10-hook.xml:869
13763 msgid ""
13764 "The Bugzilla <literal>processmail</literal> program expects to be given a bug "
13765 "ID (the hook replaces <quote><literal>%s</literal></quote> with the bug ID) "
13766 "and an email address. It also expects to be able to write to some files in "
13767 "the directory that it runs in. If Bugzilla and this hook are not installed "
13768 "on the same machine, you will need to find a way to run <literal>processmail</"
13769 "literal> on the server where Bugzilla is installed."
13770 msgstr ""
13772 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
13773 #: ../en/ch10-hook.xml:884
13774 msgid "Mapping committer names to Bugzilla user names"
13775 msgstr "提交者的名称与 Bugzilla 用户名称的映射"
13777 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13778 #: ../en/ch10-hook.xml:886
13779 msgid ""
13780 "By default, the <literal role=\"hg-ext\">bugzilla</literal> hook tries to use "
13781 "the email address of a changeset's committer as the Bugzilla user name with "
13782 "which to update a bug. If this does not suit your needs, you can map "
13783 "committer email addresses to Bugzilla user names using a <literal role=\"rc-"
13784 "usermap\">usermap</literal> section."
13785 msgstr ""
13787 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13788 #: ../en/ch10-hook.xml:895
13789 msgid ""
13790 "Each item in the <literal role=\"rc-usermap\">usermap</literal> section "
13791 "contains an email address on the left, and a Bugzilla user name on the right."
13792 msgstr ""
13794 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13795 #: ../en/ch10-hook.xml:902
13796 msgid ""
13797 "You can either keep the <literal role=\"rc-usermap\">usermap</literal> data "
13798 "in a normal <filename role=\"special\">~/.hgrc</filename>, or tell the "
13799 "<literal role=\"hg-ext\">bugzilla</literal> hook to read the information from "
13800 "an external <filename>usermap</filename> file. In the latter case, you can "
13801 "store <filename>usermap</filename> data by itself in (for example) a user-"
13802 "modifiable repository. This makes it possible to let your users maintain "
13803 "their own <envar role=\"rc-item-bugzilla\">usermap</envar> entries. The main "
13804 "<filename role=\"special\">~/.hgrc</filename> file might look like this:"
13805 msgstr ""
13807 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13808 #: ../en/ch10-hook.xml:918
13809 msgid ""
13810 "While the <filename>usermap</filename> file that it refers to might look like "
13811 "this:"
13812 msgstr ""
13814 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
13815 #: ../en/ch10-hook.xml:926
13816 msgid "Configuring the text that gets added to a bug"
13817 msgstr "配置增加到问题中的正文"
13819 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13820 #: ../en/ch10-hook.xml:928
13821 msgid ""
13822 "You can configure the text that this hook adds as a comment; you specify it "
13823 "in the form of a Mercurial template. Several <filename role=\"special\">~/."
13824 "hgrc</filename> entries (still in the <literal role=\"rc-bugzilla\">bugzilla</"
13825 "literal> section) control this behavior."
13826 msgstr ""
13828 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13829 #: ../en/ch10-hook.xml:935
13830 msgid ""
13831 "<literal>strip</literal>: The number of leading path elements to strip from a "
13832 "repository's path name to construct a partial path for a URL. For example, if "
13833 "the repositories on your server live under <filename class=\"directory\">/"
13834 "home/hg/repos</filename>, and you have a repository whose path is <filename "
13835 "class=\"directory\">/home/hg/repos/app/tests</filename>, then setting "
13836 "<literal>strip</literal> to <literal>4</literal> will give a partial path of "
13837 "<filename class=\"directory\">app/tests</filename>. The hook will make this "
13838 "partial path available when expanding a template, as <literal>webroot</"
13839 "literal>."
13840 msgstr ""
13842 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13843 #: ../en/ch10-hook.xml:949
13844 msgid ""
13845 "<literal>template</literal>: The text of the template to use. In addition to "
13846 "the usual changeset-related variables, this template can use <literal>hgweb</"
13847 "literal> (the value of the <literal>hgweb</literal> configuration item above) "
13848 "and <literal>webroot</literal> (the path constructed using <literal>strip</"
13849 "literal> above)."
13850 msgstr ""
13852 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13853 #: ../en/ch10-hook.xml:959
13854 msgid ""
13855 "In addition, you can add a <envar role=\"rc-item-web\">baseurl</envar> item "
13856 "to the <literal role=\"rc-web\">web</literal> section of your <filename role="
13857 "\"special\">~/.hgrc</filename>. The <literal role=\"hg-ext\">bugzilla</"
13858 "literal> hook will make this available when expanding a template, as the base "
13859 "string to use when constructing a URL that will let users browse from a "
13860 "Bugzilla comment to view a changeset. Example:"
13861 msgstr ""
13863 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13864 #: ../en/ch10-hook.xml:971
13865 msgid ""
13866 "Here is an example set of <literal role=\"hg-ext\">bugzilla</literal> hook "
13867 "config information."
13868 msgstr ""
13870 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13871 #: ../en/ch10-hook.xml:981
13872 msgid ""
13873 "The most common problems with configuring the <literal role=\"hg-ext"
13874 "\">bugzilla</literal> hook relate to running Bugzilla's "
13875 "<filename>processmail</filename> script and mapping committer names to user "
13876 "names."
13877 msgstr ""
13879 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13880 #: ../en/ch10-hook.xml:987
13881 msgid ""
13882 "Recall from <xref linkend=\"sec:hook:bugzilla:config\"/> above that the user "
13883 "that runs the Mercurial process on the server is also the one that will run "
13884 "the <filename>processmail</filename> script. The <filename>processmail</"
13885 "filename> script sometimes causes Bugzilla to write to files in its "
13886 "configuration directory, and Bugzilla's configuration files are usually owned "
13887 "by the user that your web server runs under."
13888 msgstr ""
13890 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13891 #: ../en/ch10-hook.xml:998
13892 msgid ""
13893 "You can cause <filename>processmail</filename> to be run with the suitable "
13894 "user's identity using the <command>sudo</command> command. Here is an "
13895 "example entry for a <filename>sudoers</filename> file."
13896 msgstr ""
13898 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13899 #: ../en/ch10-hook.xml:1005
13900 msgid ""
13901 "This allows the <literal>hg_user</literal> user to run a "
13902 "<filename>processmail-wrapper</filename> program under the identity of "
13903 "<literal>httpd_user</literal>."
13904 msgstr ""
13906 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13907 #: ../en/ch10-hook.xml:1010
13908 msgid ""
13909 "This indirection through a wrapper script is necessary, because "
13910 "<filename>processmail</filename> expects to be run with its current directory "
13911 "set to wherever you installed Bugzilla; you can't specify that kind of "
13912 "constraint in a <filename>sudoers</filename> file. The contents of the "
13913 "wrapper script are simple:"
13914 msgstr ""
13916 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13917 #: ../en/ch10-hook.xml:1019
13918 msgid ""
13919 "It doesn't seem to matter what email address you pass to "
13920 "<filename>processmail</filename>."
13921 msgstr ""
13923 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13924 #: ../en/ch10-hook.xml:1023
13925 msgid ""
13926 "If your <literal role=\"rc-usermap\">usermap</literal> is not set up "
13927 "correctly, users will see an error message from the <literal role=\"hg-ext"
13928 "\">bugzilla</literal> hook when they push changes to the server. The error "
13929 "message will look like this:"
13930 msgstr ""
13932 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13933 #: ../en/ch10-hook.xml:1030
13934 msgid ""
13935 "What this means is that the committer's address, <literal>john.q."
13936 "public@example.com</literal>, is not a valid Bugzilla user name, nor does it "
13937 "have an entry in your <literal role=\"rc-usermap\">usermap</literal> that "
13938 "maps it to a valid Bugzilla user name."
13939 msgstr ""
13941 #. type: Content of: <book><chapter><sect1><sect2><title>
13942 #: ../en/ch10-hook.xml:1040
13943 msgid ""
13944 "<literal role=\"hg-ext\">notify</literal>&emdash;send email notifications"
13945 msgstr "<literal role=\"hg-ext\">notify</literal>—邮件通知"
13947 #. type: Content of: <book><chapter><sect1><sect2><para>
13948 #: ../en/ch10-hook.xml:1043
13949 msgid ""
13950 "Although Mercurial's built-in web server provides RSS feeds of changes in "
13951 "every repository, many people prefer to receive change notifications via "
13952 "email. The <literal role=\"hg-ext\">notify</literal> hook lets you send out "
13953 "notifications to a set of email addresses whenever changesets arrive that "
13954 "those subscribers are interested in."
13955 msgstr ""
13957 #. type: Content of: <book><chapter><sect1><sect2><para>
13958 #: ../en/ch10-hook.xml:1051
13959 msgid ""
13960 "As with the <literal role=\"hg-ext\">bugzilla</literal> hook, the <literal "
13961 "role=\"hg-ext\">notify</literal> hook is template-driven, so you can "
13962 "customise the contents of the notification messages that it sends."
13963 msgstr ""
13965 #. type: Content of: <book><chapter><sect1><sect2><para>
13966 #: ../en/ch10-hook.xml:1057
13967 msgid ""
13968 "By default, the <literal role=\"hg-ext\">notify</literal> hook includes a "
13969 "diff of every changeset that it sends out; you can limit the size of the "
13970 "diff, or turn this feature off entirely. It is useful for letting "
13971 "subscribers review changes immediately, rather than clicking to follow a URL."
13972 msgstr ""
13974 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
13975 #: ../en/ch10-hook.xml:1065
13976 msgid "Configuring the <literal role=\"hg-ext\">notify</literal> hook"
13977 msgstr "配置 <literal role=\"hg-ext\">notify</literal> 钩子"
13979 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13980 #: ../en/ch10-hook.xml:1068
13981 msgid ""
13982 "You can set up the <literal role=\"hg-ext\">notify</literal> hook to send one "
13983 "email message per incoming changeset, or one per incoming group of changesets "
13984 "(all those that arrived in a single pull or push)."
13985 msgstr ""
13987 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13988 #: ../en/ch10-hook.xml:1080
13989 msgid ""
13990 "Configuration information for this hook lives in the <literal role=\"rc-notify"
13991 "\">notify</literal> section of a <filename role=\"special\">~/.hgrc</"
13992 "filename> file."
13993 msgstr ""
13995 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13996 #: ../en/ch10-hook.xml:1085
13997 msgid ""
13998 "<envar role=\"rc-item-notify\">test</envar>: By default, this hook does not "
13999 "send out email at all; instead, it prints the message that it "
14000 "<emphasis>would</emphasis> send. Set this item to <literal>false</literal> "
14001 "to allow email to be sent. The reason that sending of email is turned off by "
14002 "default is that it takes several tries to configure this extension exactly as "
14003 "you would like, and it would be bad form to spam subscribers with a number of "
14004 "<quote>broken</quote> notifications while you debug your configuration."
14005 msgstr ""
14007 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
14008 #: ../en/ch10-hook.xml:1097
14009 msgid ""
14010 "<envar role=\"rc-item-notify\">config</envar>: The path to a configuration "
14011 "file that contains subscription information. This is kept separate from the "
14012 "main <filename role=\"special\">~/.hgrc</filename> so that you can maintain "
14013 "it in a repository of its own. People can then clone that repository, update "
14014 "their subscriptions, and push the changes back to your server."
14015 msgstr ""
14017 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
14018 #: ../en/ch10-hook.xml:1106
14019 msgid ""
14020 "<envar role=\"rc-item-notify\">strip</envar>: The number of leading path "
14021 "separator characters to strip from a repository's path, when deciding whether "
14022 "a repository has subscribers. For example, if the repositories on your "
14023 "server live in <filename class=\"directory\">/home/hg/repos</filename>, and "
14024 "<literal role=\"hg-ext\">notify</literal> is considering a repository named "
14025 "<filename class=\"directory\">/home/hg/repos/shared/test</filename>, setting "
14026 "<envar role=\"rc-item-notify\">strip</envar> to <literal>4</literal> will "
14027 "cause <literal role=\"hg-ext\">notify</literal> to trim the path it considers "
14028 "down to <filename class=\"directory\">shared/test</filename>, and it will "
14029 "match subscribers against that."
14030 msgstr ""
14032 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
14033 #: ../en/ch10-hook.xml:1123
14034 msgid ""
14035 "<envar role=\"rc-item-notify\">template</envar>: The template text to use "
14036 "when sending messages. This specifies both the contents of the message "
14037 "header and its body."
14038 msgstr ""
14040 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
14041 #: ../en/ch10-hook.xml:1129
14042 msgid ""
14043 "<envar role=\"rc-item-notify\">maxdiff</envar>: The maximum number of lines "
14044 "of diff data to append to the end of a message. If a diff is longer than "
14045 "this, it is truncated. By default, this is set to 300. Set this to "
14046 "<literal>0</literal> to omit diffs from notification emails."
14047 msgstr ""
14049 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
14050 #: ../en/ch10-hook.xml:1138
14051 msgid ""
14052 "<envar role=\"rc-item-notify\">sources</envar>: A list of sources of "
14053 "changesets to consider. This lets you limit <literal role=\"hg-ext\">notify</"
14054 "literal> to only sending out email about changes that remote users pushed "
14055 "into this repository via a server, for example. See <xref linkend=\"sec:hook:"
14056 "sources\"/> for the sources you can specify here."
14057 msgstr ""
14059 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
14060 #: ../en/ch10-hook.xml:1149
14061 msgid ""
14062 "If you set the <envar role=\"rc-item-web\">baseurl</envar> item in the "
14063 "<literal role=\"rc-web\">web</literal> section, you can use it in a template; "
14064 "it will be available as <literal>webroot</literal>."
14065 msgstr ""
14067 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
14068 #: ../en/ch10-hook.xml:1155
14069 msgid ""
14070 "Here is an example set of <literal role=\"hg-ext\">notify</literal> "
14071 "configuration information."
14072 msgstr ""
14074 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
14075 #: ../en/ch10-hook.xml:1161
14076 msgid "This will produce a message that looks like the following:"
14077 msgstr ""
14079 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
14080 #: ../en/ch10-hook.xml:1171
14081 msgid ""
14082 "Do not forget that by default, the <literal role=\"hg-ext\">notify</literal> "
14083 "extension <emphasis>will not send any mail</emphasis> until you explicitly "
14084 "configure it to do so, by setting <envar role=\"rc-item-notify\">test</envar> "
14085 "to <literal>false</literal>. Until you do that, it simply prints the message "
14086 "it <emphasis>would</emphasis> send."
14087 msgstr ""
14089 #. type: Content of: <book><chapter><sect1><title>
14090 #: ../en/ch10-hook.xml:1183
14091 msgid "Information for writers of hooks"
14092 msgstr "编写钩子的信息"
14094 #. type: Content of: <book><chapter><sect1><sect2><title>
14095 #: ../en/ch10-hook.xml:1186
14096 msgid "In-process hook execution"
14097 msgstr "进程内钩子的执行"
14099 #. type: Content of: <book><chapter><sect1><sect2><para>
14100 #: ../en/ch10-hook.xml:1188
14101 msgid "An in-process hook is called with arguments of the following form:"
14102 msgstr ""
14104 #. type: Content of: <book><chapter><sect1><sect2><para>
14105 #: ../en/ch10-hook.xml:1192
14106 msgid ""
14107 "The <literal>ui</literal> parameter is a <literal role=\"py-mod-mercurial.ui"
14108 "\">ui</literal> object. The <literal>repo</literal> parameter is a <literal "
14109 "role=\"py-mod-mercurial.localrepo\">localrepository</literal> object. The "
14110 "names and values of the <literal>**kwargs</literal> parameters depend on the "
14111 "hook being invoked, with the following common features:"
14112 msgstr ""
14114 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14115 #: ../en/ch10-hook.xml:1201
14116 msgid ""
14117 "If a parameter is named <literal>node</literal> or <literal>parentN</"
14118 "literal>, it will contain a hexadecimal changeset ID. The empty string is "
14119 "used to represent <quote>null changeset ID</quote> instead of a string of "
14120 "zeroes."
14121 msgstr ""
14123 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14124 #: ../en/ch10-hook.xml:1208
14125 msgid ""
14126 "If a parameter is named <literal>url</literal>, it will contain the URL of a "
14127 "remote repository, if that can be determined."
14128 msgstr ""
14130 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14131 #: ../en/ch10-hook.xml:1213
14132 msgid ""
14133 "Boolean-valued parameters are represented as Python <literal>bool</literal> "
14134 "objects."
14135 msgstr ""
14137 #. type: Content of: <book><chapter><sect1><sect2><para>
14138 #: ../en/ch10-hook.xml:1218
14139 msgid ""
14140 "An in-process hook is called without a change to the process's working "
14141 "directory (unlike external hooks, which are run in the root of the "
14142 "repository). It must not change the process's working directory, or it will "
14143 "cause any calls it makes into the Mercurial API to fail."
14144 msgstr ""
14146 #. type: Content of: <book><chapter><sect1><sect2><para>
14147 #: ../en/ch10-hook.xml:1225
14148 msgid ""
14149 "If a hook returns a boolean <quote>false</quote> value, it is considered to "
14150 "have succeeded. If it returns a boolean <quote>true</quote> value or raises "
14151 "an exception, it is considered to have failed. A useful way to think of the "
14152 "calling convention is <quote>tell me if you fail</quote>."
14153 msgstr ""
14155 #. type: Content of: <book><chapter><sect1><sect2><para>
14156 #: ../en/ch10-hook.xml:1232
14157 msgid ""
14158 "Note that changeset IDs are passed into Python hooks as hexadecimal strings, "
14159 "not the binary hashes that Mercurial's APIs normally use. To convert a hash "
14160 "from hex to binary, use the <literal>bin</literal> function."
14161 msgstr ""
14163 #. type: Content of: <book><chapter><sect1><sect2><title>
14164 #: ../en/ch10-hook.xml:1240
14165 msgid "External hook execution"
14166 msgstr "外部钩子的执行"
14168 #. type: Content of: <book><chapter><sect1><sect2><para>
14169 #: ../en/ch10-hook.xml:1242
14170 msgid ""
14171 "An external hook is passed to the shell of the user running Mercurial. "
14172 "Features of that shell, such as variable substitution and command "
14173 "redirection, are available. The hook is run in the root directory of the "
14174 "repository (unlike in-process hooks, which are run in the same directory that "
14175 "Mercurial was run in)."
14176 msgstr ""
14178 #. type: Content of: <book><chapter><sect1><sect2><para>
14179 #: ../en/ch10-hook.xml:1250
14180 msgid ""
14181 "Hook parameters are passed to the hook as environment variables. Each "
14182 "environment variable's name is converted in upper case and prefixed with the "
14183 "string <quote><literal>HG_</literal></quote>. For example, if the name of a "
14184 "parameter is <quote><literal>node</literal></quote>, the name of the "
14185 "environment variable representing that parameter will be "
14186 "<quote><literal>HG_NODE</literal></quote>."
14187 msgstr ""
14189 #. type: Content of: <book><chapter><sect1><sect2><para>
14190 #: ../en/ch10-hook.xml:1259
14191 msgid ""
14192 "A boolean parameter is represented as the string <quote><literal>1</literal></"
14193 "quote> for <quote>true</quote>, <quote><literal>0</literal></quote> for "
14194 "<quote>false</quote>. If an environment variable is named <envar>HG_NODE</"
14195 "envar>, <envar>HG_PARENT1</envar> or <envar>HG_PARENT2</envar>, it contains a "
14196 "changeset ID represented as a hexadecimal string. The empty string is used "
14197 "to represent <quote>null changeset ID</quote> instead of a string of zeroes. "
14198 "If an environment variable is named <envar>HG_URL</envar>, it will contain "
14199 "the URL of a remote repository, if that can be determined."
14200 msgstr ""
14202 #. type: Content of: <book><chapter><sect1><sect2><para>
14203 #: ../en/ch10-hook.xml:1271
14204 msgid ""
14205 "If a hook exits with a status of zero, it is considered to have succeeded. "
14206 "If it exits with a non-zero status, it is considered to have failed."
14207 msgstr ""
14209 #. type: Content of: <book><chapter><sect1><sect2><title>
14210 #: ../en/ch10-hook.xml:1278
14211 msgid "Finding out where changesets come from"
14212 msgstr "检查修改集来自何处"
14214 #. type: Content of: <book><chapter><sect1><sect2><para>
14215 #: ../en/ch10-hook.xml:1280
14216 msgid ""
14217 "A hook that involves the transfer of changesets between a local repository "
14218 "and another may be able to find out information about the <quote>far side</"
14219 "quote>. Mercurial knows <emphasis>how</emphasis> changes are being "
14220 "transferred, and in many cases <emphasis>where</emphasis> they are being "
14221 "transferred to or from."
14222 msgstr ""
14224 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
14225 #: ../en/ch10-hook.xml:1289
14226 msgid "Sources of changesets"
14227 msgstr "修改集的来源"
14229 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
14230 #: ../en/ch10-hook.xml:1291
14231 msgid ""
14232 "Mercurial will tell a hook what means are, or were, used to transfer "
14233 "changesets between repositories. This is provided by Mercurial in a Python "
14234 "parameter named <literal>source</literal>, or an environment variable named "
14235 "<envar>HG_SOURCE</envar>."
14236 msgstr ""
14238 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
14239 #: ../en/ch10-hook.xml:1299
14240 msgid ""
14241 "<literal>serve</literal>: Changesets are transferred to or from a remote "
14242 "repository over http or ssh."
14243 msgstr ""
14245 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
14246 #: ../en/ch10-hook.xml:1304
14247 msgid ""
14248 "<literal>pull</literal>: Changesets are being transferred via a pull from one "
14249 "repository into another."
14250 msgstr ""
14252 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
14253 #: ../en/ch10-hook.xml:1309
14254 msgid ""
14255 "<literal>push</literal>: Changesets are being transferred via a push from one "
14256 "repository into another."
14257 msgstr ""
14259 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
14260 #: ../en/ch10-hook.xml:1314
14261 msgid ""
14262 "<literal>bundle</literal>: Changesets are being transferred to or from a "
14263 "bundle."
14264 msgstr ""
14266 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
14267 #: ../en/ch10-hook.xml:1321
14268 msgid "Where changes are going&emdash;remote repository URLs"
14269 msgstr "修改集要到哪里—远程版本库的地址"
14271 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
14272 #: ../en/ch10-hook.xml:1324
14273 msgid ""
14274 "When possible, Mercurial will tell a hook the location of the <quote>far "
14275 "side</quote> of an activity that transfers changeset data between "
14276 "repositories. This is provided by Mercurial in a Python parameter named "
14277 "<literal>url</literal>, or an environment variable named <envar>HG_URL</"
14278 "envar>."
14279 msgstr ""
14281 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
14282 #: ../en/ch10-hook.xml:1332
14283 msgid ""
14284 "This information is not always known. If a hook is invoked in a repository "
14285 "that is being served via http or ssh, Mercurial cannot tell where the remote "
14286 "repository is, but it may know where the client is connecting from. In such "
14287 "cases, the URL will take one of the following forms:"
14288 msgstr ""
14290 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
14291 #: ../en/ch10-hook.xml:1339
14292 msgid ""
14293 "<literal>remote:ssh:1.2.3.4</literal>&emdash;remote ssh client, at the IP "
14294 "address <literal>1.2.3.4</literal>."
14295 msgstr ""
14297 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
14298 #: ../en/ch10-hook.xml:1344
14299 msgid ""
14300 "<literal>remote:http:1.2.3.4</literal>&emdash;remote http client, at the IP "
14301 "address <literal>1.2.3.4</literal>. If the client is using SSL, this will be "
14302 "of the form <literal>remote:https:1.2.3.4</literal>."
14303 msgstr ""
14305 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
14306 #: ../en/ch10-hook.xml:1351
14307 msgid "Empty&emdash;no information could be discovered about the remote client."
14308 msgstr ""
14310 #. type: Content of: <book><chapter><sect1><title>
14311 #: ../en/ch10-hook.xml:1359
14312 msgid "Hook reference"
14313 msgstr "钩子参考"
14315 #. type: Content of: <book><chapter><sect1><sect2><title>
14316 #: ../en/ch10-hook.xml:1362
14317 msgid ""
14318 "<literal role=\"hook\">changegroup</literal>&emdash;after remote changesets "
14319 "added"
14320 msgstr "<literal role=\"hook\">changegroup</literal>—增加远程修改集之后"
14322 #. type: Content of: <book><chapter><sect1><sect2><para>
14323 #: ../en/ch10-hook.xml:1365
14324 msgid ""
14325 "This hook is run after a group of pre-existing changesets has been added to "
14326 "the repository, for example via a <command role=\"hg-cmd\">hg pull</command> "
14327 "or <command role=\"hg-cmd\">hg unbundle</command>. This hook is run once per "
14328 "operation that added one or more changesets. This is in contrast to the "
14329 "<literal role=\"hook\">incoming</literal> hook, which is run once per "
14330 "changeset, regardless of whether the changesets arrive in a group."
14331 msgstr ""
14333 #. type: Content of: <book><chapter><sect1><sect2><para>
14334 #: ../en/ch10-hook.xml:1375
14335 msgid ""
14336 "Some possible uses for this hook include kicking off an automated build or "
14337 "test of the added changesets, updating a bug database, or notifying "
14338 "subscribers that a repository contains new changes."
14339 msgstr ""
14341 #. type: Content of: <book><chapter><sect1><sect2><para>
14342 #: ../en/ch10-hook.xml:1381 ../en/ch10-hook.xml:1421 ../en/ch10-hook.xml:1465
14343 #: ../en/ch10-hook.xml:1507 ../en/ch10-hook.xml:1562 ../en/ch10-hook.xml:1602
14344 #: ../en/ch10-hook.xml:1638 ../en/ch10-hook.xml:1672 ../en/ch10-hook.xml:1736
14345 #: ../en/ch10-hook.xml:1794 ../en/ch10-hook.xml:1830 ../en/ch10-hook.xml:1857
14346 msgid "Parameters to this hook:"
14347 msgstr ""
14349 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14350 #: ../en/ch10-hook.xml:1384 ../en/ch10-hook.xml:1739
14351 msgid ""
14352 "<literal>node</literal>: A changeset ID. The changeset ID of the first "
14353 "changeset in the group that was added. All changesets between this and "
14354 "<literal role=\"tag\">tip</literal>, inclusive, were added by a single "
14355 "<command role=\"hg-cmd\">hg pull</command>, <command role=\"hg-cmd\">hg push</"
14356 "command> or <command role=\"hg-cmd\">hg unbundle</command>."
14357 msgstr ""
14359 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14360 #: ../en/ch10-hook.xml:1393 ../en/ch10-hook.xml:1472 ../en/ch10-hook.xml:1565
14361 #: ../en/ch10-hook.xml:1749
14362 msgid ""
14363 "<literal>source</literal>: A string. The source of these changes. See <xref "
14364 "linkend=\"sec:hook:sources\"/> for details."
14365 msgstr ""
14367 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14368 #: ../en/ch10-hook.xml:1398 ../en/ch10-hook.xml:1477 ../en/ch10-hook.xml:1528
14369 #: ../en/ch10-hook.xml:1570 ../en/ch10-hook.xml:1651 ../en/ch10-hook.xml:1754
14370 msgid ""
14371 "<literal>url</literal>: A URL. The location of the remote repository, if "
14372 "known. See <xref linkend=\"sec:hook:url\"/> for more information."
14373 msgstr ""
14375 #. type: Content of: <book><chapter><sect1><sect2><para>
14376 #: ../en/ch10-hook.xml:1404
14377 msgid ""
14378 "See also: <literal role=\"hook\">incoming</literal> (<xref linkend=\"sec:hook:"
14379 "incoming\"/>), <literal role=\"hook\">prechangegroup</literal> (<xref linkend="
14380 "\"sec:hook:prechangegroup\"/>), <literal role=\"hook\">pretxnchangegroup</"
14381 "literal> (<xref linkend=\"sec:hook:pretxnchangegroup\"/>)"
14382 msgstr ""
14384 #. type: Content of: <book><chapter><sect1><sect2><title>
14385 #: ../en/ch10-hook.xml:1415
14386 msgid ""
14387 "<literal role=\"hook\">commit</literal>&emdash;after a new changeset is "
14388 "created"
14389 msgstr "<literal role=\"hook\">commit</literal>—创建新修改集之后"
14391 #. type: Content of: <book><chapter><sect1><sect2><para>
14392 #: ../en/ch10-hook.xml:1418
14393 msgid "This hook is run after a new changeset has been created."
14394 msgstr ""
14396 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14397 #: ../en/ch10-hook.xml:1424 ../en/ch10-hook.xml:1797
14398 msgid ""
14399 "<literal>node</literal>: A changeset ID. The changeset ID of the newly "
14400 "committed changeset."
14401 msgstr ""
14403 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14404 #: ../en/ch10-hook.xml:1428 ../en/ch10-hook.xml:1801
14405 msgid ""
14406 "<literal>parent1</literal>: A changeset ID. The changeset ID of the first "
14407 "parent of the newly committed changeset."
14408 msgstr ""
14410 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14411 #: ../en/ch10-hook.xml:1433 ../en/ch10-hook.xml:1806
14412 msgid ""
14413 "<literal>parent2</literal>: A changeset ID. The changeset ID of the second "
14414 "parent of the newly committed changeset."
14415 msgstr ""
14417 #. type: Content of: <book><chapter><sect1><sect2><para>
14418 #: ../en/ch10-hook.xml:1439
14419 msgid ""
14420 "See also: <literal role=\"hook\">precommit</literal> (<xref linkend=\"sec:"
14421 "hook:precommit\"/>), <literal role=\"hook\">pretxncommit</literal> (<xref "
14422 "linkend=\"sec:hook:pretxncommit\"/>)"
14423 msgstr ""
14425 #. type: Content of: <book><chapter><sect1><sect2><title>
14426 #: ../en/ch10-hook.xml:1448
14427 msgid ""
14428 "<literal role=\"hook\">incoming</literal>&emdash;after one remote changeset "
14429 "is added"
14430 msgstr "<literal role=\"hook\">incoming</literal>—增加远程修改集之后"
14432 #. type: Content of: <book><chapter><sect1><sect2><para>
14433 #: ../en/ch10-hook.xml:1451
14434 msgid ""
14435 "This hook is run after a pre-existing changeset has been added to the "
14436 "repository, for example via a <command role=\"hg-cmd\">hg push</command>. If "
14437 "a group of changesets was added in a single operation, this hook is called "
14438 "once for each added changeset."
14439 msgstr ""
14441 #. type: Content of: <book><chapter><sect1><sect2><para>
14442 #: ../en/ch10-hook.xml:1458
14443 msgid ""
14444 "You can use this hook for the same purposes as the <literal role=\"hook"
14445 "\">changegroup</literal> hook (<xref linkend=\"sec:hook:changegroup\"/>); "
14446 "it's simply more convenient sometimes to run a hook once per group of "
14447 "changesets, while other times it's handier once per changeset."
14448 msgstr ""
14450 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14451 #: ../en/ch10-hook.xml:1468
14452 msgid ""
14453 "<literal>node</literal>: A changeset ID. The ID of the newly added changeset."
14454 msgstr ""
14456 #. type: Content of: <book><chapter><sect1><sect2><para>
14457 #: ../en/ch10-hook.xml:1483
14458 msgid ""
14459 "See also: <literal role=\"hook\">changegroup</literal> (<xref linkend=\"sec:"
14460 "hook:changegroup\"/>) <literal role=\"hook\">prechangegroup</literal> (<xref "
14461 "linkend=\"sec:hook:prechangegroup\"/>), <literal role=\"hook"
14462 "\">pretxnchangegroup</literal> (<xref linkend=\"sec:hook:pretxnchangegroup\"/"
14463 ">)"
14464 msgstr ""
14466 #. type: Content of: <book><chapter><sect1><sect2><title>
14467 #: ../en/ch10-hook.xml:1494
14468 msgid ""
14469 "<literal role=\"hook\">outgoing</literal>&emdash;after changesets are "
14470 "propagated"
14471 msgstr "<literal role=\"hook\">outgoing</literal>—传播修改集之后"
14473 #. type: Content of: <book><chapter><sect1><sect2><para>
14474 #: ../en/ch10-hook.xml:1497
14475 msgid ""
14476 "This hook is run after a group of changesets has been propagated out of this "
14477 "repository, for example by a <command role=\"hg-cmd\">hg push</command> or "
14478 "<command role=\"hg-cmd\">hg bundle</command> command."
14479 msgstr ""
14481 #. type: Content of: <book><chapter><sect1><sect2><para>
14482 #: ../en/ch10-hook.xml:1503
14483 msgid ""
14484 "One possible use for this hook is to notify administrators that changes have "
14485 "been pulled."
14486 msgstr ""
14488 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14489 #: ../en/ch10-hook.xml:1510
14490 msgid ""
14491 "<literal>node</literal>: A changeset ID. The changeset ID of the first "
14492 "changeset of the group that was sent."
14493 msgstr ""
14495 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14496 #: ../en/ch10-hook.xml:1515
14497 msgid ""
14498 "<literal>source</literal>: A string. The source of the of the operation (see "
14499 "<xref linkend=\"sec:hook:sources\"/>). If a remote client pulled changes "
14500 "from this repository, <literal>source</literal> will be <literal>serve</"
14501 "literal>. If the client that obtained changes from this repository was "
14502 "local, <literal>source</literal> will be <literal>bundle</literal>, "
14503 "<literal>pull</literal>, or <literal>push</literal>, depending on the "
14504 "operation the client performed."
14505 msgstr ""
14507 #. type: Content of: <book><chapter><sect1><sect2><para>
14508 #: ../en/ch10-hook.xml:1534
14509 msgid ""
14510 "See also: <literal role=\"hook\">preoutgoing</literal> (<xref linkend=\"sec:"
14511 "hook:preoutgoing\"/>)"
14512 msgstr ""
14514 #. type: Content of: <book><chapter><sect1><sect2><title>
14515 #: ../en/ch10-hook.xml:1541
14516 msgid ""
14517 "<literal role=\"hook\">prechangegroup</literal>&emdash;before starting to add "
14518 "remote changesets"
14519 msgstr "<literal role=\"hook\">prechangegroup</literal>—增加远程修改集之前"
14521 #. type: Content of: <book><chapter><sect1><sect2><para>
14522 #: ../en/ch10-hook.xml:1545
14523 msgid ""
14524 "This controlling hook is run before Mercurial begins to add a group of "
14525 "changesets from another repository."
14526 msgstr ""
14528 #. type: Content of: <book><chapter><sect1><sect2><para>
14529 #: ../en/ch10-hook.xml:1549
14530 msgid ""
14531 "This hook does not have any information about the changesets to be added, "
14532 "because it is run before transmission of those changesets is allowed to "
14533 "begin. If this hook fails, the changesets will not be transmitted."
14534 msgstr ""
14536 #. type: Content of: <book><chapter><sect1><sect2><para>
14537 #: ../en/ch10-hook.xml:1555
14538 msgid ""
14539 "One use for this hook is to prevent external changes from being added to a "
14540 "repository. For example, you could use this to <quote>freeze</quote> a "
14541 "server-hosted branch temporarily or permanently so that users cannot push to "
14542 "it, while still allowing a local administrator to modify the repository."
14543 msgstr ""
14545 #. type: Content of: <book><chapter><sect1><sect2><para>
14546 #: ../en/ch10-hook.xml:1576
14547 msgid ""
14548 "See also: <literal role=\"hook\">changegroup</literal> (<xref linkend=\"sec:"
14549 "hook:changegroup\"/>), <literal role=\"hook\">incoming</literal> (<xref "
14550 "linkend=\"sec:hook:incoming\"/>), <literal role=\"hook\">pretxnchangegroup</"
14551 "literal> (<xref linkend=\"sec:hook:pretxnchangegroup\"/>)"
14552 msgstr ""
14554 #. type: Content of: <book><chapter><sect1><sect2><title>
14555 #: ../en/ch10-hook.xml:1587
14556 msgid ""
14557 "<literal role=\"hook\">precommit</literal>&emdash;before starting to commit a "
14558 "changeset"
14559 msgstr "<literal role=\"hook\">precommit</literal>—提交修改集之前"
14561 #. type: Content of: <book><chapter><sect1><sect2><para>
14562 #: ../en/ch10-hook.xml:1590
14563 msgid ""
14564 "This hook is run before Mercurial begins to commit a new changeset. It is run "
14565 "before Mercurial has any of the metadata for the commit, such as the files to "
14566 "be committed, the commit message, or the commit date."
14567 msgstr ""
14569 #. type: Content of: <book><chapter><sect1><sect2><para>
14570 #: ../en/ch10-hook.xml:1596
14571 msgid ""
14572 "One use for this hook is to disable the ability to commit new changesets, "
14573 "while still allowing incoming changesets. Another is to run a build or test, "
14574 "and only allow the commit to begin if the build or test succeeds."
14575 msgstr ""
14577 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14578 #: ../en/ch10-hook.xml:1605
14579 msgid ""
14580 "<literal>parent1</literal>: A changeset ID. The changeset ID of the first "
14581 "parent of the working directory."
14582 msgstr ""
14584 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14585 #: ../en/ch10-hook.xml:1610
14586 msgid ""
14587 "<literal>parent2</literal>: A changeset ID. The changeset ID of the second "
14588 "parent of the working directory."
14589 msgstr ""
14591 #. type: Content of: <book><chapter><sect1><sect2><para>
14592 #: ../en/ch10-hook.xml:1615
14593 msgid ""
14594 "If the commit proceeds, the parents of the working directory will become the "
14595 "parents of the new changeset."
14596 msgstr ""
14598 #. type: Content of: <book><chapter><sect1><sect2><para>
14599 #: ../en/ch10-hook.xml:1619
14600 msgid ""
14601 "See also: <literal role=\"hook\">commit</literal> (<xref linkend=\"sec:hook:"
14602 "commit\"/>), <literal role=\"hook\">pretxncommit</literal> (<xref linkend="
14603 "\"sec:hook:pretxncommit\"/>)"
14604 msgstr ""
14606 #. type: Content of: <book><chapter><sect1><sect2><title>
14607 #: ../en/ch10-hook.xml:1627
14608 msgid ""
14609 "<literal role=\"hook\">preoutgoing</literal>&emdash;before starting to "
14610 "propagate changesets"
14611 msgstr "<literal role=\"hook\">preoutgoing</literal>—传播修改集之前"
14613 #. type: Content of: <book><chapter><sect1><sect2><para>
14614 #: ../en/ch10-hook.xml:1630
14615 msgid ""
14616 "This hook is invoked before Mercurial knows the identities of the changesets "
14617 "to be transmitted."
14618 msgstr ""
14620 #. type: Content of: <book><chapter><sect1><sect2><para>
14621 #: ../en/ch10-hook.xml:1634
14622 msgid ""
14623 "One use for this hook is to prevent changes from being transmitted to another "
14624 "repository."
14625 msgstr ""
14627 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14628 #: ../en/ch10-hook.xml:1641
14629 msgid ""
14630 "<literal>source</literal>: A string. The source of the operation that is "
14631 "attempting to obtain changes from this repository (see <xref linkend=\"sec:"
14632 "hook:sources\"/>). See the documentation for the <literal>source</literal> "
14633 "parameter to the <literal role=\"hook\">outgoing</literal> hook, in <xref "
14634 "linkend=\"sec:hook:outgoing\"/>, for possible values of this parameter."
14635 msgstr ""
14637 #. type: Content of: <book><chapter><sect1><sect2><para>
14638 #: ../en/ch10-hook.xml:1657
14639 msgid ""
14640 "See also: <literal role=\"hook\">outgoing</literal> (<xref linkend=\"sec:hook:"
14641 "outgoing\"/>)"
14642 msgstr ""
14644 #. type: Content of: <book><chapter><sect1><sect2><title>
14645 #: ../en/ch10-hook.xml:1664
14646 msgid ""
14647 "<literal role=\"hook\">pretag</literal>&emdash;before tagging a changeset"
14648 msgstr "<literal role=\"hook\">pretag</literal>—创建标签之前"
14650 #. type: Content of: <book><chapter><sect1><sect2><para>
14651 #: ../en/ch10-hook.xml:1667
14652 msgid ""
14653 "This controlling hook is run before a tag is created. If the hook succeeds, "
14654 "creation of the tag proceeds. If the hook fails, the tag is not created."
14655 msgstr ""
14657 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14658 #: ../en/ch10-hook.xml:1675
14659 msgid ""
14660 "<literal>local</literal>: A boolean. Whether the tag is local to this "
14661 "repository instance (i.e. stored in <filename role=\"special\">.hg/localtags</"
14662 "filename>) or managed by Mercurial (stored in <filename role=\"special\">."
14663 "hgtags</filename>)."
14664 msgstr ""
14666 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14667 #: ../en/ch10-hook.xml:1682
14668 msgid ""
14669 "<literal>node</literal>: A changeset ID. The ID of the changeset to be "
14670 "tagged."
14671 msgstr ""
14673 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14674 #: ../en/ch10-hook.xml:1686
14675 msgid "<literal>tag</literal>: A string. The name of the tag to be created."
14676 msgstr ""
14678 #. type: Content of: <book><chapter><sect1><sect2><para>
14679 #: ../en/ch10-hook.xml:1691
14680 msgid ""
14681 "If the tag to be created is revision-controlled, the <literal role=\"hook"
14682 "\">precommit</literal> and <literal role=\"hook\">pretxncommit</literal> "
14683 "hooks (<xref linkend=\"sec:hook:commit\"/> and <xref linkend=\"sec:hook:"
14684 "pretxncommit\"/>) will also be run."
14685 msgstr ""
14687 #. type: Content of: <book><chapter><sect1><sect2><para>
14688 #: ../en/ch10-hook.xml:1699
14689 msgid ""
14690 "See also: <literal role=\"hook\">tag</literal> (<xref linkend=\"sec:hook:tag"
14691 "\"/>)"
14692 msgstr ""
14694 #. type: Content of: <book><chapter><sect1><sect2><title>
14695 #: ../en/ch10-hook.xml:1705
14696 msgid ""
14697 "<literal role=\"hook\">pretxnchangegroup</literal>&emdash;before completing "
14698 "addition of remote changesets"
14699 msgstr ""
14700 "<literal role=\"hook\">pretxnchangegroup</literal>—完成增加远程修改集之前"
14702 #. type: Content of: <book><chapter><sect1><sect2><para>
14703 #: ../en/ch10-hook.xml:1709
14704 msgid ""
14705 "This controlling hook is run before a transaction&emdash;that manages the "
14706 "addition of a group of new changesets from outside the repository&emdash;"
14707 "completes. If the hook succeeds, the transaction completes, and all of the "
14708 "changesets become permanent within this repository. If the hook fails, the "
14709 "transaction is rolled back, and the data for the changesets is erased."
14710 msgstr ""
14712 #. type: Content of: <book><chapter><sect1><sect2><para>
14713 #: ../en/ch10-hook.xml:1718
14714 msgid ""
14715 "This hook can access the metadata associated with the almost-added "
14716 "changesets, but it should not do anything permanent with this data. It must "
14717 "also not modify the working directory."
14718 msgstr ""
14720 #. type: Content of: <book><chapter><sect1><sect2><para>
14721 #: ../en/ch10-hook.xml:1724
14722 msgid ""
14723 "While this hook is running, if other Mercurial processes access this "
14724 "repository, they will be able to see the almost-added changesets as if they "
14725 "are permanent. This may lead to race conditions if you do not take steps to "
14726 "avoid them."
14727 msgstr ""
14729 #. type: Content of: <book><chapter><sect1><sect2><para>
14730 #: ../en/ch10-hook.xml:1731
14731 msgid ""
14732 "This hook can be used to automatically vet a group of changesets. If the "
14733 "hook fails, all of the changesets are <quote>rejected</quote> when the "
14734 "transaction rolls back."
14735 msgstr ""
14737 #. type: Content of: <book><chapter><sect1><sect2><para>
14738 #: ../en/ch10-hook.xml:1760
14739 msgid ""
14740 "See also: <literal role=\"hook\">changegroup</literal> (<xref linkend=\"sec:"
14741 "hook:changegroup\"/>), <literal role=\"hook\">incoming</literal> (<xref "
14742 "linkend=\"sec:hook:incoming\"/>), <literal role=\"hook\">prechangegroup</"
14743 "literal> (<xref linkend=\"sec:hook:prechangegroup\"/>)"
14744 msgstr ""
14746 #. type: Content of: <book><chapter><sect1><sect2><title>
14747 #: ../en/ch10-hook.xml:1771
14748 msgid ""
14749 "<literal role=\"hook\">pretxncommit</literal>&emdash;before completing commit "
14750 "of new changeset"
14751 msgstr "<literal role=\"hook\">pretxncommit</literal>—完成提交之前"
14753 #. type: Content of: <book><chapter><sect1><sect2><para>
14754 #: ../en/ch10-hook.xml:1774
14755 msgid ""
14756 "This controlling hook is run before a transaction&emdash;that manages a new "
14757 "commit&emdash;completes. If the hook succeeds, the transaction completes and "
14758 "the changeset becomes permanent within this repository. If the hook fails, "
14759 "the transaction is rolled back, and the commit data is erased."
14760 msgstr ""
14762 #. type: Content of: <book><chapter><sect1><sect2><para>
14763 #: ../en/ch10-hook.xml:1782
14764 msgid ""
14765 "This hook can access the metadata associated with the almost-new changeset, "
14766 "but it should not do anything permanent with this data. It must also not "
14767 "modify the working directory."
14768 msgstr ""
14770 #. type: Content of: <book><chapter><sect1><sect2><para>
14771 #: ../en/ch10-hook.xml:1788
14772 msgid ""
14773 "While this hook is running, if other Mercurial processes access this "
14774 "repository, they will be able to see the almost-new changeset as if it is "
14775 "permanent. This may lead to race conditions if you do not take steps to "
14776 "avoid them."
14777 msgstr ""
14779 #. type: Content of: <book><chapter><sect1><sect2><para>
14780 #: ../en/ch10-hook.xml:1812
14781 msgid ""
14782 "See also: <literal role=\"hook\">precommit</literal> (<xref linkend=\"sec:"
14783 "hook:precommit\"/>)"
14784 msgstr ""
14785 "参见: <literal role=\"hook\">precommit</literal> (<xref linkend=\"sec:hook:"
14786 "precommit\"/>)"
14788 #. type: Content of: <book><chapter><sect1><sect2><title>
14789 #: ../en/ch10-hook.xml:1819
14790 msgid ""
14791 "<literal role=\"hook\">preupdate</literal>&emdash;before updating or merging "
14792 "working directory"
14793 msgstr "<literal role=\"hook\">preupdate</literal>—更新或合并工作目录之前"
14795 #. type: Content of: <book><chapter><sect1><sect2><para>
14796 #: ../en/ch10-hook.xml:1822
14797 msgid ""
14798 "This controlling hook is run before an update or merge of the working "
14799 "directory begins. It is run only if Mercurial's normal pre-update checks "
14800 "determine that the update or merge can proceed. If the hook succeeds, the "
14801 "update or merge may proceed; if it fails, the update or merge does not start."
14802 msgstr ""
14804 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14805 #: ../en/ch10-hook.xml:1833
14806 msgid ""
14807 "<literal>parent1</literal>: A changeset ID. The ID of the parent that the "
14808 "working directory is to be updated to. If the working directory is being "
14809 "merged, it will not change this parent."
14810 msgstr ""
14812 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14813 #: ../en/ch10-hook.xml:1839
14814 msgid ""
14815 "<literal>parent2</literal>: A changeset ID. Only set if the working directory "
14816 "is being merged. The ID of the revision that the working directory is being "
14817 "merged with."
14818 msgstr ""
14820 #. type: Content of: <book><chapter><sect1><sect2><para>
14821 #: ../en/ch10-hook.xml:1846
14822 msgid ""
14823 "See also: <literal role=\"hook\">update</literal> (<xref linkend=\"sec:hook:"
14824 "update\"/>)"
14825 msgstr ""
14827 #. type: Content of: <book><chapter><sect1><sect2><title>
14828 #: ../en/ch10-hook.xml:1851
14829 msgid "<literal role=\"hook\">tag</literal>&emdash;after tagging a changeset"
14830 msgstr "<literal role=\"hook\">tag</literal>—创建标签之后"
14832 #. type: Content of: <book><chapter><sect1><sect2><para>
14833 #: ../en/ch10-hook.xml:1854
14834 msgid "This hook is run after a tag has been created."
14835 msgstr ""
14837 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14838 #: ../en/ch10-hook.xml:1860
14839 msgid ""
14840 "<literal>local</literal>: A boolean. Whether the new tag is local to this "
14841 "repository instance (i.e. stored in <filename role=\"special\">.hg/"
14842 "localtags</filename>) or managed by Mercurial (stored in <filename role="
14843 "\"special\">.hgtags</filename>)."
14844 msgstr ""
14846 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14847 #: ../en/ch10-hook.xml:1868
14848 msgid ""
14849 "<literal>node</literal>: A changeset ID. The ID of the changeset that was "
14850 "tagged."
14851 msgstr ""
14853 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14854 #: ../en/ch10-hook.xml:1872
14855 msgid "<literal>tag</literal>: A string. The name of the tag that was created."
14856 msgstr ""
14858 #. type: Content of: <book><chapter><sect1><sect2><para>
14859 #: ../en/ch10-hook.xml:1877
14860 msgid ""
14861 "If the created tag is revision-controlled, the <literal role=\"hook\">commit</"
14862 "literal> hook (section <xref linkend=\"sec:hook:commit\"/>) is run before "
14863 "this hook."
14864 msgstr ""
14866 #. type: Content of: <book><chapter><sect1><sect2><para>
14867 #: ../en/ch10-hook.xml:1882
14868 msgid ""
14869 "See also: <literal role=\"hook\">pretag</literal> (<xref linkend=\"sec:hook:"
14870 "pretag\"/>)"
14871 msgstr ""
14872 "参见: <literal role=\"hook\">pretag</literal> (<xref linkend=\"sec:hook:pretag"
14873 "\"/>)"
14875 #. type: Content of: <book><chapter><sect1><sect2><title>
14876 #: ../en/ch10-hook.xml:1888
14877 msgid ""
14878 "<literal role=\"hook\">update</literal>&emdash;after updating or merging "
14879 "working directory"
14880 msgstr "<literal role=\"hook\">update</literal>—更新或合并工作目录之后"
14882 #. type: Content of: <book><chapter><sect1><sect2><para>
14883 #: ../en/ch10-hook.xml:1891
14884 msgid ""
14885 "This hook is run after an update or merge of the working directory "
14886 "completes. Since a merge can fail (if the external <command>hgmerge</"
14887 "command> command fails to resolve conflicts in a file), this hook "
14888 "communicates whether the update or merge completed cleanly."
14889 msgstr ""
14891 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14892 #: ../en/ch10-hook.xml:1899
14893 msgid ""
14894 "<literal>error</literal>: A boolean. Indicates whether the update or merge "
14895 "completed successfully."
14896 msgstr ""
14898 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14899 #: ../en/ch10-hook.xml:1904
14900 msgid ""
14901 "<literal>parent1</literal>: A changeset ID. The ID of the parent that the "
14902 "working directory was updated to. If the working directory was merged, it "
14903 "will not have changed this parent."
14904 msgstr ""
14906 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14907 #: ../en/ch10-hook.xml:1910
14908 msgid ""
14909 "<literal>parent2</literal>: A changeset ID. Only set if the working "
14910 "directory was merged. The ID of the revision that the working directory was "
14911 "merged with."
14912 msgstr ""
14914 #. type: Content of: <book><chapter><sect1><sect2><para>
14915 #: ../en/ch10-hook.xml:1916
14916 msgid ""
14917 "See also: <literal role=\"hook\">preupdate</literal> (<xref linkend=\"sec:"
14918 "hook:preupdate\"/>)"
14919 msgstr ""
14921 #. type: Content of: <book><chapter><title>
14922 #: ../en/ch11-template.xml:5
14923 msgid "Customizing the output of Mercurial"
14924 msgstr "定制 Mercurial 的输出"
14926 #. type: Content of: <book><chapter><para>
14927 #: ../en/ch11-template.xml:7
14928 msgid ""
14929 "Mercurial provides a powerful mechanism to let you control how it displays "
14930 "information. The mechanism is based on templates. You can use templates to "
14931 "generate specific output for a single command, or to customize the entire "
14932 "appearance of the built-in web interface."
14933 msgstr ""
14935 #. type: Content of: <book><chapter><sect1><title>
14936 #: ../en/ch11-template.xml:14
14937 msgid "Using precanned output styles"
14938 msgstr "使用预定义的输出样式"
14940 #. type: Content of: <book><chapter><sect1><para>
14941 #: ../en/ch11-template.xml:16
14942 msgid ""
14943 "Packaged with Mercurial are some output styles that you can use immediately. "
14944 "A style is simply a precanned template that someone wrote and installed "
14945 "somewhere that Mercurial can find."
14946 msgstr ""
14948 #. type: Content of: <book><chapter><sect1><para>
14949 #: ../en/ch11-template.xml:21
14950 msgid ""
14951 "Before we take a look at Mercurial's bundled styles, let's review its normal "
14952 "output."
14953 msgstr ""
14955 #. type: Content of: <book><chapter><sect1><para>
14956 #: ../en/ch11-template.xml:26
14957 msgid ""
14958 "This is somewhat informative, but it takes up a lot of space&emdash;five "
14959 "lines of output per changeset. The <literal>compact</literal> style reduces "
14960 "this to three lines, presented in a sparse manner."
14961 msgstr ""
14963 #. type: Content of: <book><chapter><sect1><para>
14964 #: ../en/ch11-template.xml:33
14965 msgid ""
14966 "The <literal>changelog</literal> style hints at the expressive power of "
14967 "Mercurial's templating engine. This style attempts to follow the GNU "
14968 "Project's changelog guidelines<citation>web:changelog</citation>."
14969 msgstr ""
14971 #. type: Content of: <book><chapter><sect1><para>
14972 #: ../en/ch11-template.xml:40
14973 msgid ""
14974 "You will not be shocked to learn that Mercurial's default output style is "
14975 "named <literal>default</literal>."
14976 msgstr ""
14978 #. type: Content of: <book><chapter><sect1><sect2><title>
14979 #: ../en/ch11-template.xml:44
14980 msgid "Setting a default style"
14981 msgstr "设置默认样式"
14983 #. type: Content of: <book><chapter><sect1><sect2><para>
14984 #: ../en/ch11-template.xml:46
14985 msgid ""
14986 "You can modify the output style that Mercurial will use for every command by "
14987 "editing your <filename role=\"special\">~/.hgrc</filename> file, naming the "
14988 "style you would prefer to use."
14989 msgstr ""
14991 #. type: Content of: <book><chapter><sect1><sect2><para>
14992 #: ../en/ch11-template.xml:54
14993 msgid ""
14994 "If you write a style of your own, you can use it by either providing the path "
14995 "to your style file, or copying your style file into a location where "
14996 "Mercurial can find it (typically the <literal>templates</literal> "
14997 "subdirectory of your Mercurial install directory)."
14998 msgstr ""
15000 #. type: Content of: <book><chapter><sect1><title>
15001 #: ../en/ch11-template.xml:63
15002 msgid "Commands that support styles and templates"
15003 msgstr "支持样式和模版的命令"
15005 #. type: Content of: <book><chapter><sect1><para>
15006 #: ../en/ch11-template.xml:65
15007 msgid ""
15008 "All of Mercurial's <quote><literal>log</literal>-like</quote> commands let "
15009 "you use styles and templates: <command role=\"hg-cmd\">hg incoming</command>, "
15010 "<command role=\"hg-cmd\">hg log</command>, <command role=\"hg-cmd\">hg "
15011 "outgoing</command>, and <command role=\"hg-cmd\">hg tip</command>."
15012 msgstr ""
15014 #. type: Content of: <book><chapter><sect1><para>
15015 #: ../en/ch11-template.xml:72
15016 msgid ""
15017 "As I write this manual, these are so far the only commands that support "
15018 "styles and templates. Since these are the most important commands that need "
15019 "customizable output, there has been little pressure from the Mercurial user "
15020 "community to add style and template support to other commands."
15021 msgstr ""
15023 #. type: Content of: <book><chapter><sect1><title>
15024 #: ../en/ch11-template.xml:80
15025 msgid "The basics of templating"
15026 msgstr "模版基础"
15028 #. type: Content of: <book><chapter><sect1><para>
15029 #: ../en/ch11-template.xml:82
15030 msgid ""
15031 "At its simplest, a Mercurial template is a piece of text. Some of the text "
15032 "never changes, while other parts are <emphasis>expanded</emphasis>, or "
15033 "replaced with new text, when necessary."
15034 msgstr ""
15036 #. type: Content of: <book><chapter><sect1><para>
15037 #: ../en/ch11-template.xml:87
15038 msgid ""
15039 "Before we continue, let's look again at a simple example of Mercurial's "
15040 "normal output."
15041 msgstr ""
15043 #. type: Content of: <book><chapter><sect1><para>
15044 #: ../en/ch11-template.xml:92
15045 msgid ""
15046 "Now, let's run the same command, but using a template to change its output."
15047 msgstr ""
15049 #. type: Content of: <book><chapter><sect1><para>
15050 #: ../en/ch11-template.xml:97
15051 msgid ""
15052 "The example above illustrates the simplest possible template; it's just a "
15053 "piece of static text, printed once for each changeset. The <option role=\"hg-"
15054 "opt-log\">--template</option> option to the <command role=\"hg-cmd\">hg log</"
15055 "command> command tells Mercurial to use the given text as the template when "
15056 "printing each changeset."
15057 msgstr ""
15059 #. type: Content of: <book><chapter><sect1><para>
15060 #: ../en/ch11-template.xml:105
15061 msgid ""
15062 "Notice that the template string above ends with the text <quote><literal>\\n</"
15063 "literal></quote>. This is an <emphasis>escape sequence</emphasis>, telling "
15064 "Mercurial to print a newline at the end of each template item. If you omit "
15065 "this newline, Mercurial will run each piece of output together. See <xref "
15066 "linkend=\"sec:template:escape\"/> for more details of escape sequences."
15067 msgstr ""
15069 #. type: Content of: <book><chapter><sect1><para>
15070 #: ../en/ch11-template.xml:113
15071 msgid ""
15072 "A template that prints a fixed string of text all the time isn't very useful; "
15073 "let's try something a bit more complex."
15074 msgstr ""
15076 #. type: Content of: <book><chapter><sect1><para>
15077 #: ../en/ch11-template.xml:119
15078 msgid ""
15079 "As you can see, the string <quote><literal>{desc}</literal></quote> in the "
15080 "template has been replaced in the output with the description of each "
15081 "changeset. Every time Mercurial finds text enclosed in curly braces "
15082 "(<quote><literal>{</literal></quote> and <quote><literal>}</literal></"
15083 "quote>), it will try to replace the braces and text with the expansion of "
15084 "whatever is inside. To print a literal curly brace, you must escape it, as "
15085 "described in <xref linkend=\"sec:template:escape\"/>."
15086 msgstr ""
15088 #. type: Content of: <book><chapter><sect1><title>
15089 #: ../en/ch11-template.xml:131
15090 msgid "Common template keywords"
15091 msgstr "模版关键字"
15093 #. type: Content of: <book><chapter><sect1><para>
15094 #: ../en/ch11-template.xml:133
15095 msgid ""
15096 "You can start writing simple templates immediately using the keywords below."
15097 msgstr ""
15099 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15100 #: ../en/ch11-template.xml:137
15101 msgid ""
15102 "<literal role=\"template-keyword\">author</literal>: String. The unmodified "
15103 "author of the changeset."
15104 msgstr ""
15106 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15107 #: ../en/ch11-template.xml:141
15108 msgid ""
15109 "<literal role=\"template-keyword\">branches</literal>: String. The name of "
15110 "the branch on which the changeset was committed. Will be empty if the branch "
15111 "name was <literal>default</literal>."
15112 msgstr ""
15114 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15115 #: ../en/ch11-template.xml:147
15116 msgid ""
15117 "<literal role=\"template-keyword\">date</literal>: Date information. The "
15118 "date when the changeset was committed. This is <emphasis>not</emphasis> "
15119 "human-readable; you must pass it through a filter that will render it "
15120 "appropriately. See <xref linkend=\"sec:template:filter\"/> for more "
15121 "information on filters. The date is expressed as a pair of numbers. The "
15122 "first number is a Unix UTC timestamp (seconds since January 1, 1970); the "
15123 "second is the offset of the committer's timezone from UTC, in seconds."
15124 msgstr ""
15126 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15127 #: ../en/ch11-template.xml:158
15128 msgid ""
15129 "<literal role=\"template-keyword\">desc</literal>: String. The text of the "
15130 "changeset description."
15131 msgstr ""
15133 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15134 #: ../en/ch11-template.xml:161
15135 msgid ""
15136 "<literal role=\"template-keyword\">files</literal>: List of strings. All "
15137 "files modified, added, or removed by this changeset."
15138 msgstr ""
15140 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15141 #: ../en/ch11-template.xml:166
15142 msgid ""
15143 "<literal role=\"template-keyword\">file_adds</literal>: List of strings. "
15144 "Files added by this changeset."
15145 msgstr ""
15147 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15148 #: ../en/ch11-template.xml:170
15149 msgid ""
15150 "<literal role=\"template-keyword\">file_dels</literal>: List of strings. "
15151 "Files removed by this changeset."
15152 msgstr ""
15154 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15155 #: ../en/ch11-template.xml:174
15156 msgid ""
15157 "<literal role=\"template-keyword\">node</literal>: String. The changeset "
15158 "identification hash, as a 40-character hexadecimal string."
15159 msgstr ""
15161 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15162 #: ../en/ch11-template.xml:178
15163 msgid ""
15164 "<literal role=\"template-keyword\">parents</literal>: List of strings. The "
15165 "parents of the changeset."
15166 msgstr ""
15168 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15169 #: ../en/ch11-template.xml:182
15170 msgid ""
15171 "<literal role=\"template-keyword\">rev</literal>: Integer. The repository-"
15172 "local changeset revision number."
15173 msgstr ""
15175 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15176 #: ../en/ch11-template.xml:186
15177 msgid ""
15178 "<literal role=\"template-keyword\">tags</literal>: List of strings. Any tags "
15179 "associated with the changeset."
15180 msgstr ""
15182 #. type: Content of: <book><chapter><sect1><para>
15183 #: ../en/ch11-template.xml:192
15184 msgid ""
15185 "A few simple experiments will show us what to expect when we use these "
15186 "keywords; you can see the results below."
15187 msgstr ""
15189 #. type: Content of: <book><chapter><sect1><para>
15190 #: ../en/ch11-template.xml:197
15191 msgid ""
15192 "As we noted above, the date keyword does not produce human-readable output, "
15193 "so we must treat it specially. This involves using a <emphasis>filter</"
15194 "emphasis>, about which more in <xref linkend=\"sec:template:filter\"/>."
15195 msgstr ""
15197 #. type: Content of: <book><chapter><sect1><title>
15198 #: ../en/ch11-template.xml:206
15199 msgid "Escape sequences"
15200 msgstr "转义序列"
15202 #. type: Content of: <book><chapter><sect1><para>
15203 #: ../en/ch11-template.xml:208
15204 msgid ""
15205 "Mercurial's templating engine recognises the most commonly used escape "
15206 "sequences in strings. When it sees a backslash (<quote><literal>\\</"
15207 "literal></quote>) character, it looks at the following character and "
15208 "substitutes the two characters with a single replacement, as described below."
15209 msgstr ""
15211 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15212 #: ../en/ch11-template.xml:215
15213 msgid ""
15214 "<literal>\\</literal>: Backslash, <quote><literal>\\</literal></quote>, ASCII "
15215 "134."
15216 msgstr ""
15218 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15219 #: ../en/ch11-template.xml:219
15220 msgid "<literal>\\n</literal>: Newline, ASCII 12."
15221 msgstr ""
15223 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15224 #: ../en/ch11-template.xml:222
15225 msgid "<literal>\\r</literal>: Carriage return, ASCII 15."
15226 msgstr ""
15228 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15229 #: ../en/ch11-template.xml:225
15230 msgid "<literal>\\t</literal>: Tab, ASCII 11."
15231 msgstr ""
15233 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15234 #: ../en/ch11-template.xml:228
15235 msgid "<literal>\\v</literal>: Vertical tab, ASCII 13."
15236 msgstr ""
15238 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15239 #: ../en/ch11-template.xml:231
15240 msgid ""
15241 "<literal>\\{</literal>: Open curly brace, <quote><literal>{</literal></"
15242 "quote>, ASCII 173."
15243 msgstr ""
15245 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15246 #: ../en/ch11-template.xml:235
15247 msgid ""
15248 "<literal>\\}</literal>: Close curly brace, <quote><literal>}</literal></"
15249 "quote>, ASCII 175."
15250 msgstr ""
15252 #. type: Content of: <book><chapter><sect1><para>
15253 #: ../en/ch11-template.xml:240
15254 msgid ""
15255 "As indicated above, if you want the expansion of a template to contain a "
15256 "literal <quote><literal>\\</literal></quote>, <quote><literal>{</literal></"
15257 "quote>, or <quote><literal>{</literal></quote> character, you must escape it."
15258 msgstr ""
15260 #. type: Content of: <book><chapter><sect1><title>
15261 #: ../en/ch11-template.xml:248
15262 msgid "Filtering keywords to change their results"
15263 msgstr "通过过滤关键字来修改输出结果"
15265 #. type: Content of: <book><chapter><sect1><para>
15266 #: ../en/ch11-template.xml:250
15267 msgid ""
15268 "Some of the results of template expansion are not immediately easy to use. "
15269 "Mercurial lets you specify an optional chain of <emphasis>filters</emphasis> "
15270 "to modify the result of expanding a keyword. You have already seen a common "
15271 "filter, <literal role=\"template-kw-filt-date\">isodate</literal>, in action "
15272 "above, to make a date readable."
15273 msgstr ""
15275 #. type: Content of: <book><chapter><sect1><para>
15276 #: ../en/ch11-template.xml:257
15277 msgid ""
15278 "Below is a list of the most commonly used filters that Mercurial supports. "
15279 "While some filters can be applied to any text, others can only be used in "
15280 "specific circumstances. The name of each filter is followed first by an "
15281 "indication of where it can be used, then a description of its effect."
15282 msgstr ""
15284 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15285 #: ../en/ch11-template.xml:264
15286 msgid ""
15287 "<literal role=\"template-filter\">addbreaks</literal>: Any text. Add an XHTML "
15288 "<quote><literal>&lt;br/&gt;</literal></quote> tag before the end of every "
15289 "line except the last. For example, <quote><literal>foo\\nbar</literal></"
15290 "quote> becomes <quote><literal>foo&lt;br/&gt;\\nbar</literal></quote>."
15291 msgstr ""
15293 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15294 #: ../en/ch11-template.xml:271
15295 msgid ""
15296 "<literal role=\"template-kw-filt-date\">age</literal>: <literal role="
15297 "\"template-keyword\">date</literal> keyword. Render the age of the date, "
15298 "relative to the current time. Yields a string like <quote><literal>10 "
15299 "minutes</literal></quote>."
15300 msgstr ""
15302 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15303 #: ../en/ch11-template.xml:278
15304 msgid ""
15305 "<literal role=\"template-filter\">basename</literal>: Any text, but most "
15306 "useful for the <literal role=\"template-keyword\">files</literal> keyword and "
15307 "its relatives. Treat the text as a path, and return the basename. For "
15308 "example, <quote><literal>foo/bar/baz</literal></quote> becomes "
15309 "<quote><literal>baz</literal></quote>."
15310 msgstr ""
15312 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15313 #: ../en/ch11-template.xml:287
15314 msgid ""
15315 "<literal role=\"template-kw-filt-date\">date</literal>: <literal role="
15316 "\"template-keyword\">date</literal> keyword. Render a date in a similar "
15317 "format to the Unix <literal role=\"template-keyword\">date</literal> command, "
15318 "but with timezone included. Yields a string like <quote><literal>Mon Sep 04 "
15319 "15:13:13 2006 -0700</literal></quote>."
15320 msgstr ""
15322 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15323 #: ../en/ch11-template.xml:295
15324 msgid ""
15325 "<literal role=\"template-kw-filt-author\">domain</literal>: Any text, but "
15326 "most useful for the <literal role=\"template-keyword\">author</literal> "
15327 "keyword. Finds the first string that looks like an email address, and "
15328 "extract just the domain component. For example, <quote><literal>Bryan "
15329 "O'Sullivan &lt;bos@serpentine.com&gt;</literal></quote> becomes "
15330 "<quote><literal>serpentine.com</literal></quote>."
15331 msgstr ""
15333 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15334 #: ../en/ch11-template.xml:305
15335 msgid ""
15336 "<literal role=\"template-kw-filt-author\">email</literal>: Any text, but most "
15337 "useful for the <literal role=\"template-keyword\">author</literal> keyword. "
15338 "Extract the first string that looks like an email address. For example, "
15339 "<quote><literal>Bryan O'Sullivan &lt;bos@serpentine.com&gt;</literal></quote> "
15340 "becomes <quote><literal>bos@serpentine.com</literal></quote>."
15341 msgstr ""
15343 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15344 #: ../en/ch11-template.xml:314
15345 msgid ""
15346 "<literal role=\"template-filter\">escape</literal>: Any text. Replace the "
15347 "special XML/XHTML characters <quote><literal>&amp;</literal></quote>, "
15348 "<quote><literal>&lt;</literal></quote> and <quote><literal>&gt;</literal></"
15349 "quote> with XML entities."
15350 msgstr ""
15352 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15353 #: ../en/ch11-template.xml:322
15354 msgid ""
15355 "<literal role=\"template-filter\">fill68</literal>: Any text. Wrap the text "
15356 "to fit in 68 columns. This is useful before you pass text through the "
15357 "<literal role=\"template-filter\">tabindent</literal> filter, and still want "
15358 "it to fit in an 80-column fixed-font window."
15359 msgstr ""
15361 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15362 #: ../en/ch11-template.xml:330
15363 msgid ""
15364 "<literal role=\"template-filter\">fill76</literal>: Any text. Wrap the text "
15365 "to fit in 76 columns."
15366 msgstr ""
15368 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15369 #: ../en/ch11-template.xml:334
15370 msgid ""
15371 "<literal role=\"template-filter\">firstline</literal>: Any text. Yield the "
15372 "first line of text, without any trailing newlines."
15373 msgstr ""
15375 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15376 #: ../en/ch11-template.xml:339
15377 msgid ""
15378 "<literal role=\"template-kw-filt-date\">hgdate</literal>: <literal role="
15379 "\"template-keyword\">date</literal> keyword. Render the date as a pair of "
15380 "readable numbers. Yields a string like <quote><literal>1157407993 25200</"
15381 "literal></quote>."
15382 msgstr ""
15384 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15385 #: ../en/ch11-template.xml:346
15386 msgid ""
15387 "<literal role=\"template-kw-filt-date\">isodate</literal>: <literal role="
15388 "\"template-keyword\">date</literal> keyword. Render the date as a text "
15389 "string in ISO 8601 format. Yields a string like <quote><literal>2006-09-04 "
15390 "15:13:13 -0700</literal></quote>."
15391 msgstr ""
15393 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15394 #: ../en/ch11-template.xml:353
15395 msgid ""
15396 "<literal role=\"template-filter\">obfuscate</literal>: Any text, but most "
15397 "useful for the <literal role=\"template-keyword\">author</literal> keyword. "
15398 "Yield the input text rendered as a sequence of XML entities. This helps to "
15399 "defeat some particularly stupid screen-scraping email harvesting spambots."
15400 msgstr ""
15402 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15403 #: ../en/ch11-template.xml:361
15404 msgid ""
15405 "<literal role=\"template-kw-filt-author\">person</literal>: Any text, but "
15406 "most useful for the <literal role=\"template-keyword\">author</literal> "
15407 "keyword. Yield the text before an email address. For example, "
15408 "<quote><literal>Bryan O'Sullivan &lt;bos@serpentine.com&gt;</literal></quote> "
15409 "becomes <quote><literal>Bryan O'Sullivan</literal></quote>."
15410 msgstr ""
15412 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15413 #: ../en/ch11-template.xml:370
15414 msgid ""
15415 "<literal role=\"template-kw-filt-date\">rfc822date</literal>: <literal role="
15416 "\"template-keyword\">date</literal> keyword. Render a date using the same "
15417 "format used in email headers. Yields a string like <quote><literal>Mon, 04 "
15418 "Sep 2006 15:13:13 -0700</literal></quote>."
15419 msgstr ""
15421 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15422 #: ../en/ch11-template.xml:377
15423 msgid ""
15424 "<literal role=\"template-kw-filt-node\">short</literal>: Changeset hash. "
15425 "Yield the short form of a changeset hash, i.e. a 12-character hexadecimal "
15426 "string."
15427 msgstr ""
15429 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15430 #: ../en/ch11-template.xml:382
15431 msgid ""
15432 "<literal role=\"template-kw-filt-date\">shortdate</literal>: <literal role="
15433 "\"template-keyword\">date</literal> keyword. Render the year, month, and day "
15434 "of the date. Yields a string like <quote><literal>2006-09-04</literal></"
15435 "quote>."
15436 msgstr ""
15438 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15439 #: ../en/ch11-template.xml:388
15440 msgid ""
15441 "<literal role=\"template-filter\">strip</literal>: Any text. Strip all "
15442 "leading and trailing whitespace from the string."
15443 msgstr ""
15445 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15446 #: ../en/ch11-template.xml:392
15447 msgid ""
15448 "<literal role=\"template-filter\">tabindent</literal>: Any text. Yield the "
15449 "text, with every line except the first starting with a tab character."
15450 msgstr ""
15452 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15453 #: ../en/ch11-template.xml:397
15454 msgid ""
15455 "<literal role=\"template-filter\">urlescape</literal>: Any text. Escape all "
15456 "characters that are considered <quote>special</quote> by URL parsers. For "
15457 "example, <literal>foo bar</literal> becomes <literal>foo%20bar</literal>."
15458 msgstr ""
15460 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15461 #: ../en/ch11-template.xml:404
15462 msgid ""
15463 "<literal role=\"template-kw-filt-author\">user</literal>: Any text, but most "
15464 "useful for the <literal role=\"template-keyword\">author</literal> keyword. "
15465 "Return the <quote>user</quote> portion of an email address. For example, "
15466 "<quote><literal>Bryan O'Sullivan &lt;bos@serpentine.com&gt;</literal></quote> "
15467 "becomes <quote><literal>bos</literal></quote>."
15468 msgstr ""
15470 #. type: Content of: <book><chapter><sect1><note><para>
15471 #: ../en/ch11-template.xml:418
15472 msgid ""
15473 "If you try to apply a filter to a piece of data that it cannot process, "
15474 "Mercurial will fail and print a Python exception. For example, trying to run "
15475 "the output of the <literal role=\"template-keyword\">desc</literal> keyword "
15476 "into the <literal role=\"template-kw-filt-date\">isodate</literal> filter is "
15477 "not a good idea."
15478 msgstr ""
15480 #. type: Content of: <book><chapter><sect1><sect2><title>
15481 #: ../en/ch11-template.xml:427
15482 msgid "Combining filters"
15483 msgstr "组合过滤器"
15485 #. type: Content of: <book><chapter><sect1><sect2><para>
15486 #: ../en/ch11-template.xml:429
15487 msgid ""
15488 "It is easy to combine filters to yield output in the form you would like. "
15489 "The following chain of filters tidies up a description, then makes sure that "
15490 "it fits cleanly into 68 columns, then indents it by a further 8 characters "
15491 "(at least on Unix-like systems, where a tab is conventionally 8 characters "
15492 "wide)."
15493 msgstr ""
15495 #. type: Content of: <book><chapter><sect1><sect2><para>
15496 #: ../en/ch11-template.xml:438
15497 msgid ""
15498 "Note the use of <quote><literal>\\t</literal></quote> (a tab character) in "
15499 "the template to force the first line to be indented; this is necessary since "
15500 "<literal role=\"template-keyword\">tabindent</literal> indents all lines "
15501 "<emphasis>except</emphasis> the first."
15502 msgstr ""
15504 #. type: Content of: <book><chapter><sect1><sect2><para>
15505 #: ../en/ch11-template.xml:444
15506 msgid ""
15507 "Keep in mind that the order of filters in a chain is significant. The first "
15508 "filter is applied to the result of the keyword; the second to the result of "
15509 "the first filter; and so on. For example, using <literal>fill68|tabindent</"
15510 "literal> gives very different results from <literal>tabindent|fill68</"
15511 "literal>."
15512 msgstr ""
15514 #. type: Content of: <book><chapter><sect1><title>
15515 #: ../en/ch11-template.xml:454
15516 msgid "From templates to styles"
15517 msgstr "从模版到样式"
15519 #. type: Content of: <book><chapter><sect1><para>
15520 #: ../en/ch11-template.xml:456
15521 msgid ""
15522 "A command line template provides a quick and simple way to format some "
15523 "output. Templates can become verbose, though, and it's useful to be able to "
15524 "give a template a name. A style file is a template with a name, stored in a "
15525 "file."
15526 msgstr ""
15528 #. type: Content of: <book><chapter><sect1><para>
15529 #: ../en/ch11-template.xml:461
15530 msgid ""
15531 "More than that, using a style file unlocks the power of Mercurial's "
15532 "templating engine in ways that are not possible using the command line "
15533 "<option role=\"hg-opt-log\">--template</option> option."
15534 msgstr ""
15536 #. type: Content of: <book><chapter><sect1><sect2><title>
15537 #: ../en/ch11-template.xml:467
15538 msgid "The simplest of style files"
15539 msgstr "最简单的样式文件"
15541 #. type: Content of: <book><chapter><sect1><sect2><para>
15542 #: ../en/ch11-template.xml:469
15543 msgid "Our simple style file contains just one line:"
15544 msgstr ""
15546 #. type: Content of: <book><chapter><sect1><sect2><para>
15547 #: ../en/ch11-template.xml:473
15548 msgid ""
15549 "This tells Mercurial, <quote>if you're printing a changeset, use the text on "
15550 "the right as the template</quote>."
15551 msgstr ""
15553 #. type: Content of: <book><chapter><sect1><sect2><title>
15554 #: ../en/ch11-template.xml:479
15555 msgid "Style file syntax"
15556 msgstr "样式文件语法"
15558 #. type: Content of: <book><chapter><sect1><sect2><para>
15559 #: ../en/ch11-template.xml:481
15560 msgid "The syntax rules for a style file are simple."
15561 msgstr ""
15563 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15564 #: ../en/ch11-template.xml:484
15565 msgid "The file is processed one line at a time."
15566 msgstr ""
15568 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15569 #: ../en/ch11-template.xml:487
15570 msgid "Leading and trailing white space are ignored."
15571 msgstr ""
15573 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15574 #: ../en/ch11-template.xml:490
15575 msgid "Empty lines are skipped."
15576 msgstr ""
15578 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15579 #: ../en/ch11-template.xml:492
15580 msgid ""
15581 "If a line starts with either of the characters <quote><literal>#</literal></"
15582 "quote> or <quote><literal>;</literal></quote>, the entire line is treated as "
15583 "a comment, and skipped as if empty."
15584 msgstr ""
15586 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15587 #: ../en/ch11-template.xml:497
15588 msgid ""
15589 "A line starts with a keyword. This must start with an alphabetic character "
15590 "or underscore, and can subsequently contain any alphanumeric character or "
15591 "underscore. (In regexp notation, a keyword must match <literal>[A-Za-z_][A-"
15592 "Za-z0-9_]*</literal>.)"
15593 msgstr ""
15595 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15596 #: ../en/ch11-template.xml:503
15597 msgid ""
15598 "The next element must be an <quote><literal>=</literal></quote> character, "
15599 "which can be preceded or followed by an arbitrary amount of white space."
15600 msgstr ""
15602 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15603 #: ../en/ch11-template.xml:508
15604 msgid ""
15605 "If the rest of the line starts and ends with matching quote characters "
15606 "(either single or double quote), it is treated as a template body."
15607 msgstr ""
15609 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15610 #: ../en/ch11-template.xml:512
15611 msgid ""
15612 "If the rest of the line <emphasis>does not</emphasis> start with a quote "
15613 "character, it is treated as the name of a file; the contents of this file "
15614 "will be read and used as a template body."
15615 msgstr ""
15617 #. type: Content of: <book><chapter><sect1><title>
15618 #: ../en/ch11-template.xml:521
15619 msgid "Style files by example"
15620 msgstr "样式文件例子"
15622 #. type: Content of: <book><chapter><sect1><para>
15623 #: ../en/ch11-template.xml:523
15624 msgid ""
15625 "To illustrate how to write a style file, we will construct a few by example. "
15626 "Rather than provide a complete style file and walk through it, we'll mirror "
15627 "the usual process of developing a style file by starting with something very "
15628 "simple, and walking through a series of successively more complete examples."
15629 msgstr ""
15631 #. type: Content of: <book><chapter><sect1><sect2><title>
15632 #: ../en/ch11-template.xml:530
15633 msgid "Identifying mistakes in style files"
15634 msgstr "在样式文件中定位错误"
15636 #. type: Content of: <book><chapter><sect1><sect2><para>
15637 #: ../en/ch11-template.xml:532
15638 msgid ""
15639 "If Mercurial encounters a problem in a style file you are working on, it "
15640 "prints a terse error message that, once you figure out what it means, is "
15641 "actually quite useful."
15642 msgstr ""
15644 #. type: Content of: <book><chapter><sect1><sect2><para>
15645 #: ../en/ch11-template.xml:538
15646 msgid ""
15647 "Notice that <filename>broken.style</filename> attempts to define a "
15648 "<literal>changeset</literal> keyword, but forgets to give any content for it. "
15649 "When instructed to use this style file, Mercurial promptly complains."
15650 msgstr ""
15652 #. type: Content of: <book><chapter><sect1><sect2><para>
15653 #: ../en/ch11-template.xml:545
15654 msgid "This error message looks intimidating, but it is not too hard to follow."
15655 msgstr ""
15657 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15658 #: ../en/ch11-template.xml:549
15659 msgid ""
15660 "The first component is simply Mercurial's way of saying <quote>I am giving "
15661 "up</quote>."
15662 msgstr ""
15664 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15665 #: ../en/ch11-template.xml:553
15666 msgid "Next comes the name of the style file that contains the error."
15667 msgstr ""
15669 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15670 #: ../en/ch11-template.xml:557
15671 msgid ""
15672 "Following the file name is the line number where the error was encountered."
15673 msgstr ""
15675 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15676 #: ../en/ch11-template.xml:561
15677 msgid "Finally, a description of what went wrong."
15678 msgstr ""
15680 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15681 #: ../en/ch11-template.xml:565
15682 msgid ""
15683 "The description of the problem is not always clear (as in this case), but "
15684 "even when it is cryptic, it is almost always trivial to visually inspect the "
15685 "offending line in the style file and see what is wrong."
15686 msgstr ""
15688 #. type: Content of: <book><chapter><sect1><sect2><title>
15689 #: ../en/ch11-template.xml:574
15690 msgid "Uniquely identifying a repository"
15691 msgstr "版本库的唯一标识"
15693 #. type: Content of: <book><chapter><sect1><sect2><para>
15694 #: ../en/ch11-template.xml:576
15695 msgid ""
15696 "If you would like to be able to identify a Mercurial repository <quote>fairly "
15697 "uniquely</quote> using a short string as an identifier, you can use the first "
15698 "revision in the repository."
15699 msgstr ""
15701 #. type: Content of: <book><chapter><sect1><sect2><para>
15702 #: ../en/ch11-template.xml:583
15703 msgid ""
15704 "This is likely to be unique, and so it is useful in many cases. There are a "
15705 "few caveats."
15706 msgstr ""
15708 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15709 #: ../en/ch11-template.xml:586
15710 msgid ""
15711 "It will not work in a completely empty repository, because such a repository "
15712 "does not have a revision zero."
15713 msgstr ""
15715 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15716 #: ../en/ch11-template.xml:590
15717 msgid ""
15718 "Neither will it work in the (extremely rare) case where a repository is a "
15719 "merge of two or more formerly independent repositories, and you still have "
15720 "those repositories around."
15721 msgstr ""
15723 #. type: Content of: <book><chapter><sect1><sect2><para>
15724 #: ../en/ch11-template.xml:595
15725 msgid "Here are some uses to which you could put this identifier:"
15726 msgstr ""
15728 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15729 #: ../en/ch11-template.xml:598
15730 msgid ""
15731 "As a key into a table for a database that manages repositories on a server."
15732 msgstr ""
15734 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15735 #: ../en/ch11-template.xml:601
15736 msgid ""
15737 "As half of a {<emphasis>repository ID</emphasis>, <emphasis>revision ID</"
15738 "emphasis>} tuple. Save this information away when you run an automated build "
15739 "or other activity, so that you can <quote>replay</quote> the build later if "
15740 "necessary."
15741 msgstr ""
15743 #. type: Content of: <book><chapter><sect1><sect2><title>
15744 #: ../en/ch11-template.xml:611
15745 msgid "Listing files on multiple lines"
15746 msgstr "每行列出一个文件"
15748 #. type: Content of: <book><chapter><sect1><sect2><para>
15749 #: ../en/ch11-template.xml:613
15750 msgid ""
15751 "Suppose we want to list the files changed by a changeset, one per line, with "
15752 "a little indentation before each file name."
15753 msgstr ""
15755 #. type: Content of: <book><chapter><sect1><sect2><title>
15756 #: ../en/ch11-template.xml:621
15757 msgid "Mimicking Subversion's output"
15758 msgstr "模仿 Subversion 的输出"
15761 #. type: Content of: <book><chapter><sect1><sect2><para>
15762 #: ../en/ch11-template.xml:623
15763 msgid ""
15764 "Let's try to emulate the default output format used by another revision "
15765 "control tool, Subversion."
15766 msgstr ""
15769 #. type: Content of: <book><chapter><sect1><sect2><para>
15770 #: ../en/ch11-template.xml:628
15771 msgid ""
15772 "Since Subversion's output style is fairly simple, it is easy to copy-and-"
15773 "paste a hunk of its output into a file, and replace the text produced above "
15774 "by Subversion with the template values we'd like to see expanded."
15775 msgstr ""
15777 #. type: Content of: <book><chapter><sect1><sect2><para>
15778 #: ../en/ch11-template.xml:635
15779 msgid ""
15780 "There are a few small ways in which this template deviates from the output "
15781 "produced by Subversion."
15782 msgstr ""
15784 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15785 #: ../en/ch11-template.xml:638
15786 msgid ""
15787 "Subversion prints a <quote>readable</quote> date (the <quote><literal>Wed, 27 "
15788 "Sep 2006</literal></quote> in the example output above) in parentheses. "
15789 "Mercurial's templating engine does not provide a way to display a date in "
15790 "this format without also printing the time and time zone."
15791 msgstr ""
15793 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15794 #: ../en/ch11-template.xml:645
15795 msgid ""
15796 "We emulate Subversion's printing of <quote>separator</quote> lines full of "
15797 "<quote><literal>-</literal></quote> characters by ending the template with "
15798 "such a line. We use the templating engine's <literal role=\"template-keyword"
15799 "\">header</literal> keyword to print a separator line as the first line of "
15800 "output (see below), thus achieving similar output to Subversion."
15801 msgstr ""
15803 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15804 #: ../en/ch11-template.xml:654
15805 msgid ""
15806 "Subversion's output includes a count in the header of the number of lines in "
15807 "the commit message. We cannot replicate this in Mercurial; the templating "
15808 "engine does not currently provide a filter that counts the number of lines "
15809 "the template generates."
15810 msgstr ""
15813 #. type: Content of: <book><chapter><sect1><sect2><para>
15814 #: ../en/ch11-template.xml:660
15815 msgid ""
15816 "It took me no more than a minute or two of work to replace literal text from "
15817 "an example of Subversion's output with some keywords and filters to give the "
15818 "template above. The style file simply refers to the template."
15819 msgstr ""
15821 #. type: Content of: <book><chapter><sect1><sect2><para>
15822 #: ../en/ch11-template.xml:667
15823 msgid ""
15824 "We could have included the text of the template file directly in the style "
15825 "file by enclosing it in quotes and replacing the newlines with "
15826 "<quote><literal>\\n</literal></quote> sequences, but it would have made the "
15827 "style file too difficult to read. Readability is a good guide when you're "
15828 "trying to decide whether some text belongs in a style file, or in a template "
15829 "file that the style file points to. If the style file will look too big or "
15830 "cluttered if you insert a literal piece of text, drop it into a template "
15831 "instead."
15832 msgstr ""
15834 #. type: Content of: <book><chapter><title>
15835 #: ../en/ch12-mq.xml:5
15836 msgid "Managing change with Mercurial Queues"
15837 msgstr "使用 MQ 管理修改"
15839 #. type: Content of: <book><chapter><sect1><title>
15840 #: ../en/ch12-mq.xml:8
15841 msgid "The patch management problem"
15842 msgstr "补丁的管理问题"
15844 #. type: Content of: <book><chapter><sect1><para>
15845 #: ../en/ch12-mq.xml:10
15846 msgid ""
15847 "Here is a common scenario: you need to install a software package from "
15848 "source, but you find a bug that you must fix in the source before you can "
15849 "start using the package. You make your changes, forget about the package for "
15850 "a while, and a few months later you need to upgrade to a newer version of the "
15851 "package. If the newer version of the package still has the bug, you must "
15852 "extract your fix from the older source tree and apply it against the newer "
15853 "version. This is a tedious task, and it's easy to make mistakes."
15854 msgstr ""
15856 #. type: Content of: <book><chapter><sect1><para>
15857 #: ../en/ch12-mq.xml:20
15858 msgid ""
15859 "This is a simple case of the <quote>patch management</quote> problem. You "
15860 "have an <quote>upstream</quote> source tree that you can't change; you need "
15861 "to make some local changes on top of the upstream tree; and you'd like to be "
15862 "able to keep those changes separate, so that you can apply them to newer "
15863 "versions of the upstream source."
15864 msgstr ""
15866 #. type: Content of: <book><chapter><sect1><para>
15867 #: ../en/ch12-mq.xml:27
15868 msgid ""
15869 "The patch management problem arises in many situations. Probably the most "
15870 "visible is that a user of an open source software project will contribute a "
15871 "bug fix or new feature to the project's maintainers in the form of a patch."
15872 msgstr ""
15874 #. type: Content of: <book><chapter><sect1><para>
15875 #: ../en/ch12-mq.xml:32
15876 msgid ""
15877 "Distributors of operating systems that include open source software often "
15878 "need to make changes to the packages they distribute so that they will build "
15879 "properly in their environments."
15880 msgstr ""
15882 #. type: Content of: <book><chapter><sect1><para>
15883 #: ../en/ch12-mq.xml:37
15884 msgid ""
15885 "When you have few changes to maintain, it is easy to manage a single patch "
15886 "using the standard <command>diff</command> and <command>patch</command> "
15887 "programs (see <xref linkend=\"sec:mq:patch\"/> for a discussion of these "
15888 "tools). Once the number of changes grows, it starts to make sense to maintain "
15889 "patches as discrete <quote>chunks of work,</quote> so that for example a "
15890 "single patch will contain only one bug fix (the patch might modify several "
15891 "files, but it's doing <quote>only one thing</quote>), and you may have a "
15892 "number of such patches for different bugs you need fixed and local changes "
15893 "you require. In this situation, if you submit a bug fix patch to the "
15894 "upstream maintainers of a package and they include your fix in a subsequent "
15895 "release, you can simply drop that single patch when you're updating to the "
15896 "newer release."
15897 msgstr ""
15899 #. type: Content of: <book><chapter><sect1><para>
15900 #: ../en/ch12-mq.xml:52
15901 msgid ""
15902 "Maintaining a single patch against an upstream tree is a little tedious and "
15903 "error-prone, but not difficult. However, the complexity of the problem grows "
15904 "rapidly as the number of patches you have to maintain increases. With more "
15905 "than a tiny number of patches in hand, understanding which ones you have "
15906 "applied and maintaining them moves from messy to overwhelming."
15907 msgstr ""
15909 #. type: Content of: <book><chapter><sect1><para>
15910 #: ../en/ch12-mq.xml:59
15911 msgid ""
15912 "Fortunately, Mercurial includes a powerful extension, Mercurial Queues (or "
15913 "simply <quote>MQ</quote>), that massively simplifies the patch management "
15914 "problem."
15915 msgstr ""
15917 #. type: Content of: <book><chapter><sect1><title>
15918 #: ../en/ch12-mq.xml:65
15919 msgid "The prehistory of Mercurial Queues"
15920 msgstr "MQ 的历史"
15922 #. type: Content of: <book><chapter><sect1><para>
15923 #: ../en/ch12-mq.xml:67
15924 msgid ""
15925 "During the late 1990s, several Linux kernel developers started to maintain "
15926 "<quote>patch series</quote> that modified the behavior of the Linux kernel. "
15927 "Some of these series were focused on stability, some on feature coverage, and "
15928 "others were more speculative."
15929 msgstr ""
15931 #. type: Content of: <book><chapter><sect1><para>
15932 #: ../en/ch12-mq.xml:73
15933 msgid ""
15934 "The sizes of these patch series grew rapidly. In 2002, Andrew Morton "
15935 "published some shell scripts he had been using to automate the task of "
15936 "managing his patch queues. Andrew was successfully using these scripts to "
15937 "manage hundreds (sometimes thousands) of patches on top of the Linux kernel."
15938 msgstr ""
15940 #. type: Content of: <book><chapter><sect1><sect2><title>
15941 #: ../en/ch12-mq.xml:80
15942 msgid "A patchwork quilt"
15943 msgstr ""
15945 #. type: Content of: <book><chapter><sect1><sect2><para>
15946 #: ../en/ch12-mq.xml:82
15947 msgid ""
15948 "In early 2003, Andreas Gruenbacher and Martin Quinson borrowed the approach "
15949 "of Andrew's scripts and published a tool called <quote>patchwork quilt</"
15950 "quote> <citation>web:quilt</citation>, or simply <quote>quilt</quote> (see "
15951 "<citation>gruenbacher:2005</citation> for a paper describing it). Because "
15952 "quilt substantially automated patch management, it rapidly gained a large "
15953 "following among open source software developers."
15954 msgstr ""
15956 #. type: Content of: <book><chapter><sect1><sect2><para>
15957 #: ../en/ch12-mq.xml:91
15958 msgid ""
15959 "Quilt manages a <emphasis>stack of patches</emphasis> on top of a directory "
15960 "tree. To begin, you tell quilt to manage a directory tree, and tell it which "
15961 "files you want to manage; it stores away the names and contents of those "
15962 "files. To fix a bug, you create a new patch (using a single command), edit "
15963 "the files you need to fix, then <quote>refresh</quote> the patch."
15964 msgstr ""
15966 #. type: Content of: <book><chapter><sect1><sect2><para>
15967 #: ../en/ch12-mq.xml:99
15968 msgid ""
15969 "The refresh step causes quilt to scan the directory tree; it updates the "
15970 "patch with all of the changes you have made. You can create another patch on "
15971 "top of the first, which will track the changes required to modify the tree "
15972 "from <quote>tree with one patch applied</quote> to <quote>tree with two "
15973 "patches applied</quote>."
15974 msgstr ""
15976 #. type: Content of: <book><chapter><sect1><sect2><para>
15977 #: ../en/ch12-mq.xml:106
15978 msgid ""
15979 "You can <emphasis>change</emphasis> which patches are applied to the tree. "
15980 "If you <quote>pop</quote> a patch, the changes made by that patch will vanish "
15981 "from the directory tree. Quilt remembers which patches you have popped, "
15982 "though, so you can <quote>push</quote> a popped patch again, and the "
15983 "directory tree will be restored to contain the modifications in the patch. "
15984 "Most importantly, you can run the <quote>refresh</quote> command at any time, "
15985 "and the topmost applied patch will be updated. This means that you can, at "
15986 "any time, change both which patches are applied and what modifications those "
15987 "patches make."
15988 msgstr ""
15990 #. type: Content of: <book><chapter><sect1><sect2><para>
15991 #: ../en/ch12-mq.xml:118
15992 msgid ""
15993 "Quilt knows nothing about revision control tools, so it works equally well on "
15994 "top of an unpacked tarball or a Subversion working copy."
15995 msgstr ""
15997 #. type: Content of: <book><chapter><sect1><sect2><title>
15998 #: ../en/ch12-mq.xml:124
15999 msgid "From patchwork quilt to Mercurial Queues"
16000 msgstr "从 patchwork quilt 到 MQ"
16002 #. type: Content of: <book><chapter><sect1><sect2><para>
16003 #: ../en/ch12-mq.xml:126
16004 msgid ""
16005 "In mid-2005, Chris Mason took the features of quilt and wrote an extension "
16006 "that he called Mercurial Queues, which added quilt-like behavior to Mercurial."
16007 msgstr ""
16009 #. type: Content of: <book><chapter><sect1><sect2><para>
16010 #: ../en/ch12-mq.xml:130
16011 msgid ""
16012 "The key difference between quilt and MQ is that quilt knows nothing about "
16013 "revision control systems, while MQ is <emphasis>integrated</emphasis> into "
16014 "Mercurial. Each patch that you push is represented as a Mercurial "
16015 "changeset. Pop a patch, and the changeset goes away."
16016 msgstr ""
16018 #. type: Content of: <book><chapter><sect1><sect2><para>
16019 #: ../en/ch12-mq.xml:136
16020 msgid ""
16021 "Because quilt does not care about revision control tools, it is still a "
16022 "tremendously useful piece of software to know about for situations where you "
16023 "cannot use Mercurial and MQ."
16024 msgstr ""
16026 #. type: Content of: <book><chapter><sect1><title>
16027 #: ../en/ch12-mq.xml:144
16028 msgid "The huge advantage of MQ"
16029 msgstr "MQ 的巨大优势"
16031 #. type: Content of: <book><chapter><sect1><para>
16032 #: ../en/ch12-mq.xml:146
16033 msgid ""
16034 "I cannot overstate the value that MQ offers through the unification of "
16035 "patches and revision control."
16036 msgstr ""
16038 #. type: Content of: <book><chapter><sect1><para>
16039 #: ../en/ch12-mq.xml:149
16040 msgid ""
16041 "A major reason that patches have persisted in the free software and open "
16042 "source world&emdash;in spite of the availability of increasingly capable "
16043 "revision control tools over the years&emdash;is the <emphasis>agility</"
16044 "emphasis> they offer."
16045 msgstr ""
16047 #. type: Content of: <book><chapter><sect1><para>
16048 #: ../en/ch12-mq.xml:155
16049 msgid ""
16050 "Traditional revision control tools make a permanent, irreversible record of "
16051 "everything that you do. While this has great value, it's also somewhat "
16052 "stifling. If you want to perform a wild-eyed experiment, you have to be "
16053 "careful in how you go about it, or you risk leaving unneeded&emdash;or worse, "
16054 "misleading or destabilising&emdash;traces of your missteps and errors in the "
16055 "permanent revision record."
16056 msgstr ""
16058 #. type: Content of: <book><chapter><sect1><para>
16059 #: ../en/ch12-mq.xml:163
16060 msgid ""
16061 "By contrast, MQ's marriage of distributed revision control with patches makes "
16062 "it much easier to isolate your work. Your patches live on top of normal "
16063 "revision history, and you can make them disappear or reappear at will. If "
16064 "you don't like a patch, you can drop it. If a patch isn't quite as you want "
16065 "it to be, simply fix it&emdash;as many times as you need to, until you have "
16066 "refined it into the form you desire."
16067 msgstr ""
16069 #. type: Content of: <book><chapter><sect1><para>
16070 #: ../en/ch12-mq.xml:171
16071 msgid ""
16072 "As an example, the integration of patches with revision control makes "
16073 "understanding patches and debugging their effects&emdash;and their interplay "
16074 "with the code they're based on&emdash;<emphasis>enormously</emphasis> easier. "
16075 "Since every applied patch has an associated changeset, you can give <command "
16076 "role=\"hg-cmd\">hg log</command> a file name to see which changesets and "
16077 "patches affected the file. You can use the <command role=\"hg-cmd\">hg "
16078 "bisect</command> command to binary-search through all changesets and applied "
16079 "patches to see where a bug got introduced or fixed. You can use the <command "
16080 "role=\"hg-cmd\">hg annotate</command> command to see which changeset or patch "
16081 "modified a particular line of a source file. And so on."
16082 msgstr ""
16084 #. type: Content of: <book><chapter><sect1><para>
16085 #: ../en/ch12-mq.xml:189
16086 msgid ""
16087 "Because MQ doesn't hide its patch-oriented nature, it is helpful to "
16088 "understand what patches are, and a little about the tools that work with them."
16089 msgstr ""
16091 #. type: Content of: <book><chapter><sect1><para>
16092 #: ../en/ch12-mq.xml:193
16093 msgid ""
16094 "The traditional Unix <command>diff</command> command compares two files, and "
16095 "prints a list of differences between them. The <command>patch</command> "
16096 "command understands these differences as <emphasis>modifications</emphasis> "
16097 "to make to a file. Take a look below for a simple example of these commands "
16098 "in action."
16099 msgstr ""
16101 #. type: Content of: <book><chapter><sect1><para>
16102 #: ../en/ch12-mq.xml:202
16103 msgid ""
16104 "The type of file that <command>diff</command> generates (and <command>patch</"
16105 "command> takes as input) is called a <quote>patch</quote> or a <quote>diff</"
16106 "quote>; there is no difference between a patch and a diff. (We'll use the "
16107 "term <quote>patch</quote>, since it's more commonly used.)"
16108 msgstr ""
16110 #. type: Content of: <book><chapter><sect1><para>
16111 #: ../en/ch12-mq.xml:208
16112 msgid ""
16113 "A patch file can start with arbitrary text; the <command>patch</command> "
16114 "command ignores this text, but MQ uses it as the commit message when creating "
16115 "changesets. To find the beginning of the patch content, <command>patch</"
16116 "command> searches for the first line that starts with the string "
16117 "<quote><literal>diff -</literal></quote>."
16118 msgstr ""
16120 #. type: Content of: <book><chapter><sect1><para>
16121 #: ../en/ch12-mq.xml:215
16122 msgid ""
16123 "MQ works with <emphasis>unified</emphasis> diffs (<command>patch</command> "
16124 "can accept several other diff formats, but MQ doesn't). A unified diff "
16125 "contains two kinds of header. The <emphasis>file header</emphasis> describes "
16126 "the file being modified; it contains the name of the file to modify. When "
16127 "<command>patch</command> sees a new file header, it looks for a file with "
16128 "that name to start modifying."
16129 msgstr ""
16131 #. type: Content of: <book><chapter><sect1><para>
16132 #: ../en/ch12-mq.xml:223
16133 msgid ""
16134 "After the file header comes a series of <emphasis>hunks</emphasis>. Each "
16135 "hunk starts with a header; this identifies the range of line numbers within "
16136 "the file that the hunk should modify. Following the header, a hunk starts "
16137 "and ends with a few (usually three) lines of text from the unmodified file; "
16138 "these are called the <emphasis>context</emphasis> for the hunk. If there's "
16139 "only a small amount of context between successive hunks, <command>diff</"
16140 "command> doesn't print a new hunk header; it just runs the hunks together, "
16141 "with a few lines of context between modifications."
16142 msgstr ""
16144 #. type: Content of: <book><chapter><sect1><para>
16145 #: ../en/ch12-mq.xml:235
16146 msgid ""
16147 "Each line of context begins with a space character. Within the hunk, a line "
16148 "that begins with <quote><literal>-</literal></quote> means <quote>remove this "
16149 "line,</quote> while a line that begins with <quote><literal>+</literal></"
16150 "quote> means <quote>insert this line.</quote> For example, a line that is "
16151 "modified is represented by one deletion and one insertion."
16152 msgstr ""
16154 #. type: Content of: <book><chapter><sect1><para>
16155 #: ../en/ch12-mq.xml:243
16156 msgid ""
16157 "We will return to some of the more subtle aspects of patches later (in <xref "
16158 "linkend=\"sec:mq:adv-patch\"/>), but you should have enough information now "
16159 "to use MQ."
16160 msgstr ""
16162 #. type: Content of: <book><chapter><sect1><title>
16163 #: ../en/ch12-mq.xml:250
16164 msgid "Getting started with Mercurial Queues"
16165 msgstr "开始使用 MQ"
16167 #. type: Content of: <book><chapter><sect1><para>
16168 #: ../en/ch12-mq.xml:252
16169 msgid ""
16170 "Because MQ is implemented as an extension, you must explicitly enable before "
16171 "you can use it. (You don't need to download anything; MQ ships with the "
16172 "standard Mercurial distribution.) To enable MQ, edit your <filename role="
16173 "\"home\">~/.hgrc</filename> file, and add the lines below."
16174 msgstr ""
16176 #. type: Content of: <book><chapter><sect1><para>
16177 #: ../en/ch12-mq.xml:262
16178 msgid ""
16179 "Once the extension is enabled, it will make a number of new commands "
16180 "available. To verify that the extension is working, you can use <command "
16181 "role=\"hg-cmd\">hg help</command> to see if the <command role=\"hg-ext-mq"
16182 "\">qinit</command> command is now available."
16183 msgstr ""
16185 #. type: Content of: <book><chapter><sect1><para>
16186 #: ../en/ch12-mq.xml:270
16187 msgid ""
16188 "You can use MQ with <emphasis>any</emphasis> Mercurial repository, and its "
16189 "commands only operate within that repository. To get started, simply prepare "
16190 "the repository using the <command role=\"hg-ext-mq\">qinit</command> command."
16191 msgstr ""
16193 #. type: Content of: <book><chapter><sect1><para>
16194 #: ../en/ch12-mq.xml:277
16195 msgid ""
16196 "This command creates an empty directory called <filename role=\"special\" "
16197 "class=\"directory\">.hg/patches</filename>, where MQ will keep its metadata. "
16198 "As with many Mercurial commands, the <command role=\"hg-ext-mq\">qinit</"
16199 "command> command prints nothing if it succeeds."
16200 msgstr ""
16202 #. type: Content of: <book><chapter><sect1><sect2><title>
16203 #: ../en/ch12-mq.xml:284
16204 msgid "Creating a new patch"
16205 msgstr "创建新补丁"
16207 #. type: Content of: <book><chapter><sect1><sect2><para>
16208 #: ../en/ch12-mq.xml:286
16209 msgid ""
16210 "To begin work on a new patch, use the <command role=\"hg-ext-mq\">qnew</"
16211 "command> command. This command takes one argument, the name of the patch to "
16212 "create."
16213 msgstr ""
16215 #. type: Content of: <book><chapter><sect1><sect2><para>
16216 #: ../en/ch12-mq.xml:290
16217 msgid ""
16218 "MQ will use this as the name of an actual file in the <filename role=\"special"
16219 "\" class=\"directory\">.hg/patches</filename> directory, as you can see below."
16220 msgstr ""
16222 #. type: Content of: <book><chapter><sect1><sect2><para>
16223 #: ../en/ch12-mq.xml:297
16224 msgid ""
16225 "Also newly present in the <filename role=\"special\" class=\"directory\">.hg/"
16226 "patches</filename> directory are two other files, <filename role=\"special"
16227 "\">series</filename> and <filename role=\"special\">status</filename>. The "
16228 "<filename role=\"special\">series</filename> file lists all of the patches "
16229 "that MQ knows about for this repository, with one patch per line. Mercurial "
16230 "uses the <filename role=\"special\">status</filename> file for internal book-"
16231 "keeping; it tracks all of the patches that MQ has <emphasis>applied</"
16232 "emphasis> in this repository."
16233 msgstr ""
16235 #. type: Content of: <book><chapter><sect1><sect2><note><para>
16236 #: ../en/ch12-mq.xml:309
16237 msgid ""
16238 "You may sometimes want to edit the <filename role=\"special\">series</"
16239 "filename> file by hand; for example, to change the sequence in which some "
16240 "patches are applied. However, manually editing the <filename role=\"special"
16241 "\">status</filename> file is almost always a bad idea, as it's easy to "
16242 "corrupt MQ's idea of what is happening."
16243 msgstr ""
16245 #. type: Content of: <book><chapter><sect1><sect2><para>
16246 #: ../en/ch12-mq.xml:318
16247 msgid ""
16248 "Once you have created your new patch, you can edit files in the working "
16249 "directory as you usually would. All of the normal Mercurial commands, such "
16250 "as <command role=\"hg-cmd\">hg diff</command> and <command role=\"hg-cmd\">hg "
16251 "annotate</command>, work exactly as they did before."
16252 msgstr ""
16254 #. type: Content of: <book><chapter><sect1><sect2><title>
16255 #: ../en/ch12-mq.xml:326
16256 msgid "Refreshing a patch"
16257 msgstr "刷新补丁"
16259 #. type: Content of: <book><chapter><sect1><sect2><para>
16260 #: ../en/ch12-mq.xml:328
16261 msgid ""
16262 "When you reach a point where you want to save your work, use the <command "
16263 "role=\"hg-ext-mq\">qrefresh</command> command to update the patch you are "
16264 "working on."
16265 msgstr ""
16267 #. type: Content of: <book><chapter><sect1><sect2><para>
16268 #: ../en/ch12-mq.xml:334
16269 msgid ""
16270 "This command folds the changes you have made in the working directory into "
16271 "your patch, and updates its corresponding changeset to contain those changes."
16272 msgstr ""
16274 #. type: Content of: <book><chapter><sect1><sect2><para>
16275 #: ../en/ch12-mq.xml:338
16276 msgid ""
16277 "You can run <command role=\"hg-ext-mq\">qrefresh</command> as often as you "
16278 "like, so it's a good way to <quote>checkpoint</quote> your work. Refresh "
16279 "your patch at an opportune time; try an experiment; and if the experiment "
16280 "doesn't work out, <command role=\"hg-cmd\">hg revert</command> your "
16281 "modifications back to the last time you refreshed."
16282 msgstr ""
16284 #. type: Content of: <book><chapter><sect1><sect2><title>
16285 #: ../en/ch12-mq.xml:349
16286 msgid "Stacking and tracking patches"
16287 msgstr "堆叠和跟踪补丁"
16289 #. type: Content of: <book><chapter><sect1><sect2><para>
16290 #: ../en/ch12-mq.xml:351
16291 msgid ""
16292 "Once you have finished working on a patch, or need to work on another, you "
16293 "can use the <command role=\"hg-ext-mq\">qnew</command> command again to "
16294 "create a new patch. Mercurial will apply this patch on top of your existing "
16295 "patch."
16296 msgstr ""
16298 #. type: Content of: <book><chapter><sect1><sect2><para>
16299 #: ../en/ch12-mq.xml:359
16300 msgid ""
16301 "Notice that the patch contains the changes in our prior patch as part of its "
16302 "context (you can see this more clearly in the output of <command role=\"hg-cmd"
16303 "\">hg annotate</command>)."
16304 msgstr ""
16306 #. type: Content of: <book><chapter><sect1><sect2><para>
16307 #: ../en/ch12-mq.xml:364
16308 msgid ""
16309 "So far, with the exception of <command role=\"hg-ext-mq\">qnew</command> and "
16310 "<command role=\"hg-ext-mq\">qrefresh</command>, we've been careful to only "
16311 "use regular Mercurial commands. However, MQ provides many commands that are "
16312 "easier to use when you are thinking about patches, as illustrated below."
16313 msgstr ""
16315 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16316 #: ../en/ch12-mq.xml:374
16317 msgid ""
16318 "The <command role=\"hg-ext-mq\">qseries</command> command lists every patch "
16319 "that MQ knows about in this repository, from oldest to newest (most recently "
16320 "<emphasis>created</emphasis>)."
16321 msgstr ""
16323 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16324 #: ../en/ch12-mq.xml:380
16325 msgid ""
16326 "The <command role=\"hg-ext-mq\">qapplied</command> command lists every patch "
16327 "that MQ has <emphasis>applied</emphasis> in this repository, again from "
16328 "oldest to newest (most recently applied)."
16329 msgstr ""
16331 #. type: Content of: <book><chapter><sect1><sect2><title>
16332 #: ../en/ch12-mq.xml:389
16333 msgid "Manipulating the patch stack"
16334 msgstr "操作补丁堆栈"
16336 #. type: Content of: <book><chapter><sect1><sect2><para>
16337 #: ../en/ch12-mq.xml:391
16338 msgid ""
16339 "The previous discussion implied that there must be a difference between "
16340 "<quote>known</quote> and <quote>applied</quote> patches, and there is. MQ "
16341 "can manage a patch without it being applied in the repository."
16342 msgstr ""
16344 #. type: Content of: <book><chapter><sect1><sect2><para>
16345 #: ../en/ch12-mq.xml:396
16346 msgid ""
16347 "An <emphasis>applied</emphasis> patch has a corresponding changeset in the "
16348 "repository, and the effects of the patch and changeset are visible in the "
16349 "working directory. You can undo the application of a patch using the "
16350 "<command role=\"hg-ext-mq\">qpop</command> command. MQ still <emphasis>knows "
16351 "about</emphasis>, or manages, a popped patch, but the patch no longer has a "
16352 "corresponding changeset in the repository, and the working directory does not "
16353 "contain the changes made by the patch. <xref linkend=\"fig:mq:stack\"/> "
16354 "illustrates the difference between applied and tracked patches."
16355 msgstr ""
16357 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
16358 #: ../en/ch12-mq.xml:409
16359 msgid "Applied and unapplied patches in the MQ patch stack"
16360 msgstr "在 MQ 补丁堆栈中应用和撤销补丁"
16362 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
16363 #: ../en/ch12-mq.xml:412
16364 msgid "<imageobject><imagedata fileref=\"figs/mq-stack.png\"/></imageobject>"
16365 msgstr ""
16367 #. type: Content of: <book><chapter><sect1><sect2><para>
16368 #: ../en/ch12-mq.xml:417
16369 msgid ""
16370 "You can reapply an unapplied, or popped, patch using the <command role=\"hg-"
16371 "ext-mq\">qpush</command> command. This creates a new changeset to correspond "
16372 "to the patch, and the patch's changes once again become present in the "
16373 "working directory. See below for examples of <command role=\"hg-ext-mq"
16374 "\">qpop</command> and <command role=\"hg-ext-mq\">qpush</command> in action."
16375 msgstr ""
16377 #. type: Content of: <book><chapter><sect1><sect2><para>
16378 #: ../en/ch12-mq.xml:427
16379 msgid ""
16380 "Notice that once we have popped a patch or two patches, the output of "
16381 "<command role=\"hg-ext-mq\">qseries</command> remains the same, while that of "
16382 "<command role=\"hg-ext-mq\">qapplied</command> has changed."
16383 msgstr ""
16385 #. type: Content of: <book><chapter><sect1><sect2><title>
16386 #: ../en/ch12-mq.xml:435
16387 msgid "Pushing and popping many patches"
16388 msgstr "压入或弹出多个补丁"
16390 #. type: Content of: <book><chapter><sect1><sect2><para>
16391 #: ../en/ch12-mq.xml:437
16392 msgid ""
16393 "While <command role=\"hg-ext-mq\">qpush</command> and <command role=\"hg-ext-"
16394 "mq\">qpop</command> each operate on a single patch at a time by default, you "
16395 "can push and pop many patches in one go. The <option role=\"hg-ext-mq-cmd-"
16396 "qpush-opt\">-a</option> option to <command role=\"hg-ext-mq\">qpush</command> "
16397 "causes it to push all unapplied patches, while the <option role=\"hg-ext-mq-"
16398 "cmd-qpop-opt\">-a</option> option to <command role=\"hg-ext-mq\">qpop</"
16399 "command> causes it to pop all applied patches. (For some more ways to push "
16400 "and pop many patches, see <xref linkend=\"sec:mq:perf\"/> below.)"
16401 msgstr ""
16403 #. type: Content of: <book><chapter><sect1><sect2><title>
16404 #: ../en/ch12-mq.xml:453
16405 msgid "Safety checks, and overriding them"
16406 msgstr "安全的检查,然后覆盖它们"
16408 #. type: Content of: <book><chapter><sect1><sect2><para>
16409 #: ../en/ch12-mq.xml:455
16410 msgid ""
16411 "Several MQ commands check the working directory before they do anything, and "
16412 "fail if they find any modifications. They do this to ensure that you won't "
16413 "lose any changes that you have made, but not yet incorporated into a patch. "
16414 "The example below illustrates this; the <command role=\"hg-ext-mq\">qnew</"
16415 "command> command will not create a new patch if there are outstanding "
16416 "changes, caused in this case by the <command role=\"hg-cmd\">hg add</command> "
16417 "of <filename>file3</filename>."
16418 msgstr ""
16420 #. type: Content of: <book><chapter><sect1><sect2><para>
16421 #: ../en/ch12-mq.xml:467
16422 msgid ""
16423 "Commands that check the working directory all take an <quote>I know what I'm "
16424 "doing</quote> option, which is always named <option>-f</option>. The exact "
16425 "meaning of <option>-f</option> depends on the command. For example, <command "
16426 "role=\"hg-cmd\">hg qnew <option role=\"hg-ext-mq-cmd-qnew-opt\">-f</option></"
16427 "command> will incorporate any outstanding changes into the new patch it "
16428 "creates, but <command role=\"hg-cmd\">hg qpop <option role=\"hg-ext-mq-cmd-"
16429 "qpop-opt\">-f</option></command> will revert modifications to any files "
16430 "affected by the patch that it is popping. Be sure to read the documentation "
16431 "for a command's <option>-f</option> option before you use it!"
16432 msgstr ""
16434 #. type: Content of: <book><chapter><sect1><sect2><title>
16435 #: ../en/ch12-mq.xml:482
16436 msgid "Working on several patches at once"
16437 msgstr "同时处理多个补丁"
16439 #. type: Content of: <book><chapter><sect1><sect2><para>
16440 #: ../en/ch12-mq.xml:484
16441 msgid ""
16442 "The <command role=\"hg-ext-mq\">qrefresh</command> command always refreshes "
16443 "the <emphasis>topmost</emphasis> applied patch. This means that you can "
16444 "suspend work on one patch (by refreshing it), pop or push to make a different "
16445 "patch the top, and work on <emphasis>that</emphasis> patch for a while."
16446 msgstr ""
16448 #. type: Content of: <book><chapter><sect1><sect2><para>
16449 #: ../en/ch12-mq.xml:491
16450 msgid ""
16451 "Here's an example that illustrates how you can use this ability. Let's say "
16452 "you're developing a new feature as two patches. The first is a change to the "
16453 "core of your software, and the second&emdash;layered on top of the "
16454 "first&emdash;changes the user interface to use the code you just added to the "
16455 "core. If you notice a bug in the core while you're working on the UI patch, "
16456 "it's easy to fix the core. Simply <command role=\"hg-ext-mq\">qrefresh</"
16457 "command> the UI patch to save your in-progress changes, and <command role="
16458 "\"hg-ext-mq\">qpop</command> down to the core patch. Fix the core bug, "
16459 "<command role=\"hg-ext-mq\">qrefresh</command> the core patch, and <command "
16460 "role=\"hg-ext-mq\">qpush</command> back to the UI patch to continue where you "
16461 "left off."
16462 msgstr ""
16464 #. type: Content of: <book><chapter><sect1><title>
16465 #: ../en/ch12-mq.xml:508
16466 msgid "More about patches"
16467 msgstr "关于补丁的更多信息"
16469 #. type: Content of: <book><chapter><sect1><para>
16470 #: ../en/ch12-mq.xml:510
16471 msgid ""
16472 "MQ uses the GNU <command>patch</command> command to apply patches, so it's "
16473 "helpful to know a few more detailed aspects of how <command>patch</command> "
16474 "works, and about patches themselves."
16475 msgstr ""
16477 #. type: Content of: <book><chapter><sect1><sect2><title>
16478 #: ../en/ch12-mq.xml:516
16479 msgid "The strip count"
16480 msgstr "修剪计数"
16482 #. type: Content of: <book><chapter><sect1><sect2><para>
16483 #: ../en/ch12-mq.xml:518
16484 msgid ""
16485 "If you look at the file headers in a patch, you will notice that the "
16486 "pathnames usually have an extra component on the front that isn't present in "
16487 "the actual path name. This is a holdover from the way that people used to "
16488 "generate patches (people still do this, but it's somewhat rare with modern "
16489 "revision control tools)."
16490 msgstr ""
16492 #. type: Content of: <book><chapter><sect1><sect2><para>
16493 #: ../en/ch12-mq.xml:525
16494 msgid ""
16495 "Alice would unpack a tarball, edit her files, then decide that she wanted to "
16496 "create a patch. So she'd rename her working directory, unpack the tarball "
16497 "again (hence the need for the rename), and use the <option role=\"cmd-opt-diff"
16498 "\">-r</option> and <option role=\"cmd-opt-diff\">-N</option> options to "
16499 "<command>diff</command> to recursively generate a patch between the "
16500 "unmodified directory and the modified one. The result would be that the name "
16501 "of the unmodified directory would be at the front of the left-hand path in "
16502 "every file header, and the name of the modified directory would be at the "
16503 "front of the right-hand path."
16504 msgstr ""
16506 #. type: Content of: <book><chapter><sect1><sect2><para>
16507 #: ../en/ch12-mq.xml:538
16508 msgid ""
16509 "Since someone receiving a patch from the Alices of the net would be unlikely "
16510 "to have unmodified and modified directories with exactly the same names, the "
16511 "<command>patch</command> command has a <option role=\"cmd-opt-patch\">-p</"
16512 "option> option that indicates the number of leading path name components to "
16513 "strip when trying to apply a patch. This number is called the "
16514 "<emphasis>strip count</emphasis>."
16515 msgstr ""
16517 #. type: Content of: <book><chapter><sect1><sect2><para>
16518 #: ../en/ch12-mq.xml:546
16519 msgid ""
16520 "An option of <quote><literal>-p1</literal></quote> means <quote>use a strip "
16521 "count of one</quote>. If <command>patch</command> sees a file name "
16522 "<filename>foo/bar/baz</filename> in a file header, it will strip "
16523 "<filename>foo</filename> and try to patch a file named <filename>bar/baz</"
16524 "filename>. (Strictly speaking, the strip count refers to the number of "
16525 "<emphasis>path separators</emphasis> (and the components that go with them ) "
16526 "to strip. A strip count of one will turn <filename>foo/bar</filename> into "
16527 "<filename>bar</filename>, but <filename>/foo/bar</filename> (notice the extra "
16528 "leading slash) into <filename>foo/bar</filename>.)"
16529 msgstr ""
16531 #. type: Content of: <book><chapter><sect1><sect2><para>
16532 #: ../en/ch12-mq.xml:559
16533 msgid ""
16534 "The <quote>standard</quote> strip count for patches is one; almost all "
16535 "patches contain one leading path name component that needs to be stripped. "
16536 "Mercurial's <command role=\"hg-cmd\">hg diff</command> command generates path "
16537 "names in this form, and the <command role=\"hg-cmd\">hg import</command> "
16538 "command and MQ expect patches to have a strip count of one."
16539 msgstr ""
16541 #. type: Content of: <book><chapter><sect1><sect2><para>
16542 #: ../en/ch12-mq.xml:567
16543 msgid ""
16544 "If you receive a patch from someone that you want to add to your patch queue, "
16545 "and the patch needs a strip count other than one, you cannot just <command "
16546 "role=\"hg-ext-mq\">qimport</command> the patch, because <command role=\"hg-"
16547 "ext-mq\">qimport</command> does not yet have a <literal>-p</literal> option "
16548 "(see <ulink role=\"hg-bug\" url=\"http://www.selenic.com/mercurial/bts/"
16549 "issue311\">issue 311</ulink>). Your best bet is to <command role=\"hg-ext-mq"
16550 "\">qnew</command> a patch of your own, then use <command>patch -pN</command> "
16551 "to apply their patch, followed by <command role=\"hg-cmd\">hg addremove</"
16552 "command> to pick up any files added or removed by the patch, followed by "
16553 "<command role=\"hg-ext-mq\">hg qrefresh</command>. This complexity may become "
16554 "unnecessary; see <ulink role=\"hg-bug\" url=\"http://www.selenic.com/"
16555 "mercurial/bts/issue311\">issue 311</ulink> for details."
16556 msgstr ""
16558 #. type: Content of: <book><chapter><sect1><sect2><title>
16559 #: ../en/ch12-mq.xml:587
16560 msgid "Strategies for applying a patch"
16561 msgstr "应用补丁的策略"
16563 #. type: Content of: <book><chapter><sect1><sect2><para>
16564 #: ../en/ch12-mq.xml:589
16565 msgid ""
16566 "When <command>patch</command> applies a hunk, it tries a handful of "
16567 "successively less accurate strategies to try to make the hunk apply. This "
16568 "falling-back technique often makes it possible to take a patch that was "
16569 "generated against an old version of a file, and apply it against a newer "
16570 "version of that file."
16571 msgstr ""
16573 #. type: Content of: <book><chapter><sect1><sect2><para>
16574 #: ../en/ch12-mq.xml:596
16575 msgid ""
16576 "First, <command>patch</command> tries an exact match, where the line numbers, "
16577 "the context, and the text to be modified must apply exactly. If it cannot "
16578 "make an exact match, it tries to find an exact match for the context, without "
16579 "honouring the line numbering information. If this succeeds, it prints a line "
16580 "of output saying that the hunk was applied, but at some <emphasis>offset</"
16581 "emphasis> from the original line number."
16582 msgstr ""
16584 #. type: Content of: <book><chapter><sect1><sect2><para>
16585 #: ../en/ch12-mq.xml:605
16586 msgid ""
16587 "If a context-only match fails, <command>patch</command> removes the first and "
16588 "last lines of the context, and tries a <emphasis>reduced</emphasis> context-"
16589 "only match. If the hunk with reduced context succeeds, it prints a message "
16590 "saying that it applied the hunk with a <emphasis>fuzz factor</emphasis> (the "
16591 "number after the fuzz factor indicates how many lines of context "
16592 "<command>patch</command> had to trim before the patch applied)."
16593 msgstr ""
16595 #. type: Content of: <book><chapter><sect1><sect2><para>
16596 #: ../en/ch12-mq.xml:614
16597 msgid ""
16598 "When neither of these techniques works, <command>patch</command> prints a "
16599 "message saying that the hunk in question was rejected. It saves rejected "
16600 "hunks (also simply called <quote>rejects</quote>) to a file with the same "
16601 "name, and an added <filename role=\"special\">.rej</filename> extension. It "
16602 "also saves an unmodified copy of the file with a <filename role=\"special\">."
16603 "orig</filename> extension; the copy of the file without any extensions will "
16604 "contain any changes made by hunks that <emphasis>did</emphasis> apply "
16605 "cleanly. If you have a patch that modifies <filename>foo</filename> with six "
16606 "hunks, and one of them fails to apply, you will have: an unmodified "
16607 "<filename>foo.orig</filename>, a <filename>foo.rej</filename> containing one "
16608 "hunk, and <filename>foo</filename>, containing the changes made by the five "
16609 "successful hunks."
16610 msgstr ""
16612 #. type: Content of: <book><chapter><sect1><sect2><title>
16613 #: ../en/ch12-mq.xml:632
16614 msgid "Some quirks of patch representation"
16615 msgstr "补丁的一些特性"
16617 #. type: Content of: <book><chapter><sect1><sect2><para>
16618 #: ../en/ch12-mq.xml:634
16619 msgid ""
16620 "There are a few useful things to know about how <command>patch</command> "
16621 "works with files."
16622 msgstr ""
16624 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16625 #: ../en/ch12-mq.xml:637
16626 msgid ""
16627 "This should already be obvious, but <command>patch</command> cannot handle "
16628 "binary files."
16629 msgstr ""
16631 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16632 #: ../en/ch12-mq.xml:641
16633 msgid ""
16634 "Neither does it care about the executable bit; it creates new files as "
16635 "readable, but not executable."
16636 msgstr ""
16638 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16639 #: ../en/ch12-mq.xml:645
16640 msgid ""
16641 "<command>patch</command> treats the removal of a file as a diff between the "
16642 "file to be removed and the empty file. So your idea of <quote>I deleted this "
16643 "file</quote> looks like <quote>every line of this file was deleted</quote> in "
16644 "a patch."
16645 msgstr ""
16647 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16648 #: ../en/ch12-mq.xml:651
16649 msgid ""
16650 "It treats the addition of a file as a diff between the empty file and the "
16651 "file to be added. So in a patch, your idea of <quote>I added this file</"
16652 "quote> looks like <quote>every line of this file was added</quote>."
16653 msgstr ""
16655 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16656 #: ../en/ch12-mq.xml:657
16657 msgid ""
16658 "It treats a renamed file as the removal of the old name, and the addition of "
16659 "the new name. This means that renamed files have a big footprint in "
16660 "patches. (Note also that Mercurial does not currently try to infer when "
16661 "files have been renamed or copied in a patch.)"
16662 msgstr ""
16664 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16665 #: ../en/ch12-mq.xml:663
16666 msgid ""
16667 "<command>patch</command> cannot represent empty files, so you cannot use a "
16668 "patch to represent the notion <quote>I added this empty file to the tree</"
16669 "quote>."
16670 msgstr ""
16672 #. type: Content of: <book><chapter><sect1><sect2><title>
16673 #: ../en/ch12-mq.xml:671
16674 msgid "Beware the fuzz"
16675 msgstr "当心毛刺"
16677 #. type: Content of: <book><chapter><sect1><sect2><para>
16678 #: ../en/ch12-mq.xml:673
16679 msgid ""
16680 "While applying a hunk at an offset, or with a fuzz factor, will often be "
16681 "completely successful, these inexact techniques naturally leave open the "
16682 "possibility of corrupting the patched file. The most common cases typically "
16683 "involve applying a patch twice, or at an incorrect location in the file. If "
16684 "<command>patch</command> or <command role=\"hg-ext-mq\">qpush</command> ever "
16685 "mentions an offset or fuzz factor, you should make sure that the modified "
16686 "files are correct afterwards."
16687 msgstr ""
16689 #. type: Content of: <book><chapter><sect1><sect2><para>
16690 #: ../en/ch12-mq.xml:683
16691 msgid ""
16692 "It's often a good idea to refresh a patch that has applied with an offset or "
16693 "fuzz factor; refreshing the patch generates new context information that will "
16694 "make it apply cleanly. I say <quote>often,</quote> not <quote>always,</"
16695 "quote> because sometimes refreshing a patch will make it fail to apply "
16696 "against a different revision of the underlying files. In some cases, such as "
16697 "when you're maintaining a patch that must sit on top of multiple versions of "
16698 "a source tree, it's acceptable to have a patch apply with some fuzz, provided "
16699 "you've verified the results of the patching process in such cases."
16700 msgstr ""
16702 #. type: Content of: <book><chapter><sect1><sect2><title>
16703 #: ../en/ch12-mq.xml:696
16704 msgid "Handling rejection"
16705 msgstr "处理拒绝"
16707 #. type: Content of: <book><chapter><sect1><sect2><para>
16708 #: ../en/ch12-mq.xml:698
16709 msgid ""
16710 "If <command role=\"hg-ext-mq\">qpush</command> fails to apply a patch, it "
16711 "will print an error message and exit. If it has left <filename role=\"special"
16712 "\">.rej</filename> files behind, it is usually best to fix up the rejected "
16713 "hunks before you push more patches or do any further work."
16714 msgstr ""
16716 #. type: Content of: <book><chapter><sect1><sect2><para>
16717 #: ../en/ch12-mq.xml:704
16718 msgid ""
16719 "If your patch <emphasis>used to</emphasis> apply cleanly, and no longer does "
16720 "because you've changed the underlying code that your patches are based on, "
16721 "Mercurial Queues can help; see <xref linkend=\"sec:mq:merge\"/> for details."
16722 msgstr ""
16724 #. type: Content of: <book><chapter><sect1><sect2><para>
16725 #: ../en/ch12-mq.xml:709
16726 msgid ""
16727 "Unfortunately, there aren't any great techniques for dealing with rejected "
16728 "hunks. Most often, you'll need to view the <filename role=\"special\">.rej</"
16729 "filename> file and edit the target file, applying the rejected hunks by hand."
16730 msgstr ""
16732 #. type: Content of: <book><chapter><sect1><sect2><para>
16733 #: ../en/ch12-mq.xml:714
16734 msgid ""
16735 "A Linux kernel hacker, Chris Mason (the author of Mercurial Queues), wrote a "
16736 "tool called <command>mpatch</command> (<ulink url=\"http://oss.oracle.com/"
16737 "~mason/mpatch/\">http://oss.oracle.com/~mason/mpatch/</ulink>), which takes a "
16738 "simple approach to automating the application of hunks rejected by "
16739 "<command>patch</command>. The <command>mpatch</command> command can help "
16740 "with four common reasons that a hunk may be rejected:"
16741 msgstr ""
16743 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16744 #: ../en/ch12-mq.xml:724
16745 msgid "The context in the middle of a hunk has changed."
16746 msgstr ""
16748 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16749 #: ../en/ch12-mq.xml:727
16750 msgid "A hunk is missing some context at the beginning or end."
16751 msgstr ""
16753 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16754 #: ../en/ch12-mq.xml:730
16755 msgid ""
16756 "A large hunk might apply better&emdash;either entirely or in part&emdash;if "
16757 "it was broken up into smaller hunks."
16758 msgstr ""
16760 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16761 #: ../en/ch12-mq.xml:734
16762 msgid ""
16763 "A hunk removes lines with slightly different content than those currently "
16764 "present in the file."
16765 msgstr ""
16767 #. type: Content of: <book><chapter><sect1><sect2><para>
16768 #: ../en/ch12-mq.xml:738
16769 msgid ""
16770 "If you use <command>mpatch</command>, you should be doubly careful to check "
16771 "your results when you're done. In fact, <command>mpatch</command> enforces "
16772 "this method of double-checking the tool's output, by automatically dropping "
16773 "you into a merge program when it has done its job, so that you can verify its "
16774 "work and finish off any remaining merges."
16775 msgstr ""
16777 #. type: Content of: <book><chapter><sect1><title>
16778 #: ../en/ch12-mq.xml:749
16779 msgid "More on patch management"
16780 msgstr "补丁管理进阶"
16782 #. type: Content of: <book><chapter><sect1><para>
16783 #: ../en/ch12-mq.xml:751
16784 msgid ""
16785 "As you grow familiar with MQ, you will find yourself wanting to perform other "
16786 "kinds of patch management operations."
16787 msgstr ""
16789 #. type: Content of: <book><chapter><sect1><sect2><title>
16790 #: ../en/ch12-mq.xml:755
16791 msgid "Deleting unwanted patches"
16792 msgstr "删除不需要的补丁"
16794 #. type: Content of: <book><chapter><sect1><sect2><para>
16795 #: ../en/ch12-mq.xml:757
16796 msgid ""
16797 "If you want to get rid of a patch, use the <command role=\"hg-ext-mq\">hg "
16798 "qdelete</command> command to delete the patch file and remove its entry from "
16799 "the patch series. If you try to delete a patch that is still applied, "
16800 "<command role=\"hg-ext-mq\">hg qdelete</command> will refuse."
16801 msgstr ""
16803 #. type: Content of: <book><chapter><sect1><sect2><title>
16804 #: ../en/ch12-mq.xml:767
16805 msgid "Converting to and from permanent revisions"
16806 msgstr "与持久版本的相互转换"
16808 #. type: Content of: <book><chapter><sect1><sect2><para>
16809 #: ../en/ch12-mq.xml:769
16810 msgid ""
16811 "Once you're done working on a patch and want to turn it into a permanent "
16812 "changeset, use the <command role=\"hg-ext-mq\">hg qfinish</command> command. "
16813 "Pass a revision to the command to identify the patch that you want to turn "
16814 "into a regular changeset; this patch must already be applied."
16815 msgstr ""
16817 #. type: Content of: <book><chapter><sect1><sect2><para>
16818 #: ../en/ch12-mq.xml:777
16819 msgid ""
16820 "The <command role=\"hg-ext-mq\">hg qfinish</command> command accepts an "
16821 "<option>--all</option> or <option>-a</option> option, which turns all applied "
16822 "patches into regular changesets."
16823 msgstr ""
16825 #. type: Content of: <book><chapter><sect1><sect2><para>
16826 #: ../en/ch12-mq.xml:782
16827 msgid ""
16828 "It is also possible to turn an existing changeset into a patch, by passing "
16829 "the <option>-r</option> option to <command role=\"hg-ext-mq\">hg qimport</"
16830 "command>."
16831 msgstr ""
16833 #. type: Content of: <book><chapter><sect1><sect2><para>
16834 #: ../en/ch12-mq.xml:788
16835 msgid ""
16836 "Note that it only makes sense to convert a changeset into a patch if you have "
16837 "not propagated that changeset into any other repositories. The imported "
16838 "changeset's ID will change every time you refresh the patch, which will make "
16839 "Mercurial treat it as unrelated to the original changeset if you have pushed "
16840 "it somewhere else."
16841 msgstr ""
16843 #. type: Content of: <book><chapter><sect1><title>
16844 #: ../en/ch12-mq.xml:798
16845 msgid "Getting the best performance out of MQ"
16846 msgstr "MQ 的性能"
16848 #. type: Content of: <book><chapter><sect1><para>
16849 #: ../en/ch12-mq.xml:800
16850 msgid ""
16851 "MQ is very efficient at handling a large number of patches. I ran some "
16852 "performance experiments in mid-2006 for a talk that I gave at the 2006 "
16853 "EuroPython conference (on modern hardware, you should expect better "
16854 "performance than you'll see below). I used as my data set the Linux 2.6.17-"
16855 "mm1 patch series, which consists of 1,738 patches. I applied these on top of "
16856 "a Linux kernel repository containing all 27,472 revisions between Linux "
16857 "2.6.12-rc2 and Linux 2.6.17."
16858 msgstr ""
16860 #. type: Content of: <book><chapter><sect1><para>
16861 #: ../en/ch12-mq.xml:809
16862 msgid ""
16863 "On my old, slow laptop, I was able to <command role=\"hg-cmd\">hg qpush "
16864 "<option role=\"hg-ext-mq-cmd-qpush-opt\">-a</option></command> all 1,738 "
16865 "patches in 3.5 minutes, and <command role=\"hg-cmd\">hg qpop <option role="
16866 "\"hg-ext-mq-cmd-qpop-opt\">-a</option></command> them all in 30 seconds. (On "
16867 "a newer laptop, the time to push all patches dropped to two minutes.) I "
16868 "could <command role=\"hg-ext-mq\">qrefresh</command> one of the biggest "
16869 "patches (which made 22,779 lines of changes to 287 files) in 6.6 seconds."
16870 msgstr ""
16872 #. type: Content of: <book><chapter><sect1><para>
16873 #: ../en/ch12-mq.xml:820
16874 msgid ""
16875 "Clearly, MQ is well suited to working in large trees, but there are a few "
16876 "tricks you can use to get the best performance of it."
16877 msgstr ""
16879 #. type: Content of: <book><chapter><sect1><para>
16880 #: ../en/ch12-mq.xml:824
16881 msgid ""
16882 "First of all, try to <quote>batch</quote> operations together. Every time "
16883 "you run <command role=\"hg-ext-mq\">qpush</command> or <command role=\"hg-ext-"
16884 "mq\">qpop</command>, these commands scan the working directory once to make "
16885 "sure you haven't made some changes and then forgotten to run <command role="
16886 "\"hg-ext-mq\">qrefresh</command>. On a small tree, the time that this scan "
16887 "takes is unnoticeable. However, on a medium-sized tree (containing tens of "
16888 "thousands of files), it can take a second or more."
16889 msgstr ""
16891 #. type: Content of: <book><chapter><sect1><para>
16892 #: ../en/ch12-mq.xml:835
16893 msgid ""
16894 "The <command role=\"hg-ext-mq\">qpush</command> and <command role=\"hg-ext-mq"
16895 "\">qpop</command> commands allow you to push and pop multiple patches at a "
16896 "time. You can identify the <quote>destination patch</quote> that you want to "
16897 "end up at. When you <command role=\"hg-ext-mq\">qpush</command> with a "
16898 "destination specified, it will push patches until that patch is at the top of "
16899 "the applied stack. When you <command role=\"hg-ext-mq\">qpop</command> to a "
16900 "destination, MQ will pop patches until the destination patch is at the top."
16901 msgstr ""
16903 #. type: Content of: <book><chapter><sect1><para>
16904 #: ../en/ch12-mq.xml:845
16905 msgid ""
16906 "You can identify a destination patch using either the name of the patch, or "
16907 "by number. If you use numeric addressing, patches are counted from zero; "
16908 "this means that the first patch is zero, the second is one, and so on."
16909 msgstr ""
16911 #. type: Content of: <book><chapter><sect1><title>
16912 #: ../en/ch12-mq.xml:852
16913 msgid "Updating your patches when the underlying code changes"
16914 msgstr "当基础代码改变时,更新补丁的方法"
16916 #. type: Content of: <book><chapter><sect1><para>
16917 #: ../en/ch12-mq.xml:855
16918 msgid ""
16919 "It's common to have a stack of patches on top of an underlying repository "
16920 "that you don't modify directly. If you're working on changes to third-party "
16921 "code, or on a feature that is taking longer to develop than the rate of "
16922 "change of the code beneath, you will often need to sync up with the "
16923 "underlying code, and fix up any hunks in your patches that no longer apply. "
16924 "This is called <emphasis>rebasing</emphasis> your patch series."
16925 msgstr ""
16927 #. type: Content of: <book><chapter><sect1><para>
16928 #: ../en/ch12-mq.xml:864
16929 msgid ""
16930 "The simplest way to do this is to <command role=\"hg-cmd\">hg qpop <option "
16931 "role=\"hg-ext-mq-cmd-qpop-opt\">hg -a</option></command> your patches, then "
16932 "<command role=\"hg-cmd\">hg pull</command> changes into the underlying "
16933 "repository, and finally <command role=\"hg-cmd\">hg qpush <option role=\"hg-"
16934 "ext-mq-cmd-qpop-opt\">-a</option></command> your patches again. MQ will stop "
16935 "pushing any time it runs across a patch that fails to apply during conflicts, "
16936 "allowing you to fix your conflicts, <command role=\"hg-ext-mq\">qrefresh</"
16937 "command> the affected patch, and continue pushing until you have fixed your "
16938 "entire stack."
16939 msgstr ""
16941 #. type: Content of: <book><chapter><sect1><para>
16942 #: ../en/ch12-mq.xml:876
16943 msgid ""
16944 "This approach is easy to use and works well if you don't expect changes to "
16945 "the underlying code to affect how well your patches apply. If your patch "
16946 "stack touches code that is modified frequently or invasively in the "
16947 "underlying repository, however, fixing up rejected hunks by hand quickly "
16948 "becomes tiresome."
16949 msgstr ""
16951 #. type: Content of: <book><chapter><sect1><para>
16952 #: ../en/ch12-mq.xml:883
16953 msgid ""
16954 "It's possible to partially automate the rebasing process. If your patches "
16955 "apply cleanly against some revision of the underlying repo, MQ can use this "
16956 "information to help you to resolve conflicts between your patches and a "
16957 "different revision."
16958 msgstr ""
16960 #. type: Content of: <book><chapter><sect1><para>
16961 #: ../en/ch12-mq.xml:889
16962 msgid "The process is a little involved."
16963 msgstr ""
16965 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
16966 #: ../en/ch12-mq.xml:891
16967 msgid ""
16968 "To begin, <command role=\"hg-cmd\">hg qpush -a</command> all of your patches "
16969 "on top of the revision where you know that they apply cleanly."
16970 msgstr ""
16972 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
16973 #: ../en/ch12-mq.xml:895
16974 msgid ""
16975 "Save a backup copy of your patch directory using <command role=\"hg-cmd\">hg "
16976 "qsave <option role=\"hg-ext-mq-cmd-qsave-opt\">hg -e</option> <option role="
16977 "\"hg-ext-mq-cmd-qsave-opt\">hg -c</option></command>. This prints the name "
16978 "of the directory that it has saved the patches in. It will save the patches "
16979 "to a directory called <filename role=\"special\" class=\"directory\">.hg/"
16980 "patches.N</filename>, where <literal>N</literal> is a small integer. It also "
16981 "commits a <quote>save changeset</quote> on top of your applied patches; this "
16982 "is for internal book-keeping, and records the states of the <filename role="
16983 "\"special\">series</filename> and <filename role=\"special\">status</"
16984 "filename> files."
16985 msgstr ""
16987 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
16988 #: ../en/ch12-mq.xml:909
16989 msgid ""
16990 "Use <command role=\"hg-cmd\">hg pull</command> to bring new changes into the "
16991 "underlying repository. (Don't run <command role=\"hg-cmd\">hg pull -u</"
16992 "command>; see below for why.)"
16993 msgstr ""
16995 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
16996 #: ../en/ch12-mq.xml:914
16997 msgid ""
16998 "Update to the new tip revision, using <command role=\"hg-cmd\">hg update "
16999 "<option role=\"hg-opt-update\">-C</option></command> to override the patches "
17000 "you have pushed."
17001 msgstr ""
17003 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
17004 #: ../en/ch12-mq.xml:919
17005 msgid ""
17006 "Merge all patches using <command>hg qpush -m -a</command>. The <option role="
17007 "\"hg-ext-mq-cmd-qpush-opt\">-m</option> option to <command role=\"hg-ext-mq"
17008 "\">qpush</command> tells MQ to perform a three-way merge if the patch fails "
17009 "to apply."
17010 msgstr ""
17012 #. type: Content of: <book><chapter><sect1><para>
17013 #: ../en/ch12-mq.xml:927
17014 msgid ""
17015 "During the <command role=\"hg-cmd\">hg qpush <option role=\"hg-ext-mq-cmd-"
17016 "qpush-opt\">hg -m</option></command>, each patch in the <filename role="
17017 "\"special\">series</filename> file is applied normally. If a patch applies "
17018 "with fuzz or rejects, MQ looks at the queue you <command role=\"hg-ext-mq"
17019 "\">qsave</command>d, and performs a three-way merge with the corresponding "
17020 "changeset. This merge uses Mercurial's normal merge machinery, so it may pop "
17021 "up a GUI merge tool to help you to resolve problems."
17022 msgstr ""
17024 #. type: Content of: <book><chapter><sect1><para>
17025 #: ../en/ch12-mq.xml:937
17026 msgid ""
17027 "When you finish resolving the effects of a patch, MQ refreshes your patch "
17028 "based on the result of the merge."
17029 msgstr ""
17031 #. type: Content of: <book><chapter><sect1><para>
17032 #: ../en/ch12-mq.xml:940
17033 msgid ""
17034 "At the end of this process, your repository will have one extra head from the "
17035 "old patch queue, and a copy of the old patch queue will be in <filename role="
17036 "\"special\" class=\"directory\">.hg/patches.N</filename>. You can remove the "
17037 "extra head using <command role=\"hg-cmd\">hg qpop -a -n patches.N</command> "
17038 "or <command role=\"hg-cmd\">hg strip</command>. You can delete <filename "
17039 "role=\"special\" class=\"directory\">.hg/patches.N</filename> once you are "
17040 "sure that you no longer need it as a backup."
17041 msgstr ""
17043 #. type: Content of: <book><chapter><sect1><title>
17044 #: ../en/ch12-mq.xml:952
17045 msgid "Identifying patches"
17046 msgstr "标识补丁"
17048 #. type: Content of: <book><chapter><sect1><para>
17049 #: ../en/ch12-mq.xml:954
17050 msgid ""
17051 "MQ commands that work with patches let you refer to a patch either by using "
17052 "its name or by a number. By name is obvious enough; pass the name "
17053 "<filename>foo.patch</filename> to <command role=\"hg-ext-mq\">qpush</"
17054 "command>, for example, and it will push patches until <filename>foo.patch</"
17055 "filename> is applied."
17056 msgstr ""
17058 #. type: Content of: <book><chapter><sect1><para>
17059 #: ../en/ch12-mq.xml:961
17060 msgid ""
17061 "As a shortcut, you can refer to a patch using both a name and a numeric "
17062 "offset; <literal>foo.patch-2</literal> means <quote>two patches before "
17063 "<literal>foo.patch</literal></quote>, while <literal>bar.patch+4</literal> "
17064 "means <quote>four patches after <literal>bar.patch</literal></quote>."
17065 msgstr ""
17067 #. type: Content of: <book><chapter><sect1><para>
17068 #: ../en/ch12-mq.xml:967
17069 msgid ""
17070 "Referring to a patch by index isn't much different. The first patch printed "
17071 "in the output of <command role=\"hg-ext-mq\">qseries</command> is patch zero "
17072 "(yes, it's one of those start-at-zero counting systems); the second is patch "
17073 "one; and so on."
17074 msgstr ""
17076 #. type: Content of: <book><chapter><sect1><para>
17077 #: ../en/ch12-mq.xml:973
17078 msgid ""
17079 "MQ also makes it easy to work with patches when you are using normal "
17080 "Mercurial commands. Every command that accepts a changeset ID will also "
17081 "accept the name of an applied patch. MQ augments the tags normally in the "
17082 "repository with an eponymous one for each applied patch. In addition, the "
17083 "special tags <literal role=\"tag\">qbase</literal> and <literal role=\"tag"
17084 "\">qtip</literal> identify the <quote>bottom-most</quote> and topmost applied "
17085 "patches, respectively."
17086 msgstr ""
17088 #. type: Content of: <book><chapter><sect1><para>
17089 #: ../en/ch12-mq.xml:983
17090 msgid ""
17091 "These additions to Mercurial's normal tagging capabilities make dealing with "
17092 "patches even more of a breeze."
17093 msgstr ""
17095 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17096 #: ../en/ch12-mq.xml:986
17097 msgid "Want to patchbomb a mailing list with your latest series of changes?"
17098 msgstr ""
17100 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17101 #: ../en/ch12-mq.xml:989
17102 msgid ""
17103 "(Don't know what <quote>patchbombing</quote> is? See <xref linkend=\"sec:"
17104 "hgext:patchbomb\"/>.)"
17105 msgstr ""
17107 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17108 #: ../en/ch12-mq.xml:992
17109 msgid ""
17110 "Need to see all of the patches since <literal>foo.patch</literal> that have "
17111 "touched files in a subdirectory of your tree?"
17112 msgstr ""
17114 #. type: Content of: <book><chapter><sect1><para>
17115 #: ../en/ch12-mq.xml:999
17116 msgid ""
17117 "Because MQ makes the names of patches available to the rest of Mercurial "
17118 "through its normal internal tag machinery, you don't need to type in the "
17119 "entire name of a patch when you want to identify it by name."
17120 msgstr ""
17122 #. type: Content of: <book><chapter><sect1><para>
17123 #: ../en/ch12-mq.xml:1004
17124 msgid ""
17125 "Another nice consequence of representing patch names as tags is that when you "
17126 "run the <command role=\"hg-cmd\">hg log</command> command, it will display a "
17127 "patch's name as a tag, simply as part of its normal output. This makes it "
17128 "easy to visually distinguish applied patches from underlying <quote>normal</"
17129 "quote> revisions. The following example shows a few normal Mercurial "
17130 "commands in use with applied patches."
17131 msgstr ""
17133 #. type: Content of: <book><chapter><sect1><title>
17134 #: ../en/ch12-mq.xml:1017
17135 msgid "Useful things to know about"
17136 msgstr "其它需要了解的东西"
17138 #. type: Content of: <book><chapter><sect1><para>
17139 #: ../en/ch12-mq.xml:1019
17140 msgid ""
17141 "There are a number of aspects of MQ usage that don't fit tidily into sections "
17142 "of their own, but that are good to know. Here they are, in one place."
17143 msgstr ""
17145 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17146 #: ../en/ch12-mq.xml:1024
17147 msgid ""
17148 "Normally, when you <command role=\"hg-ext-mq\">qpop</command> a patch and "
17149 "<command role=\"hg-ext-mq\">qpush</command> it again, the changeset that "
17150 "represents the patch after the pop/push will have a <emphasis>different "
17151 "identity</emphasis> than the changeset that represented the hash beforehand. "
17152 "See <xref linkend=\"sec:mqref:cmd:qpush\"/> for information as to why this is."
17153 msgstr ""
17155 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17156 #: ../en/ch12-mq.xml:1033
17157 msgid ""
17158 "It's not a good idea to <command role=\"hg-cmd\">hg merge</command> changes "
17159 "from another branch with a patch changeset, at least if you want to maintain "
17160 "the <quote>patchiness</quote> of that changeset and changesets below it on "
17161 "the patch stack. If you try to do this, it will appear to succeed, but MQ "
17162 "will become confused."
17163 msgstr ""
17165 #. type: Content of: <book><chapter><sect1><title>
17166 #: ../en/ch12-mq.xml:1044
17167 msgid "Managing patches in a repository"
17168 msgstr "在版本库管理补丁"
17170 #. type: Content of: <book><chapter><sect1><para>
17171 #: ../en/ch12-mq.xml:1046
17172 msgid ""
17173 "Because MQ's <filename role=\"special\" class=\"directory\">.hg/patches</"
17174 "filename> directory resides outside a Mercurial repository's working "
17175 "directory, the <quote>underlying</quote> Mercurial repository knows nothing "
17176 "about the management or presence of patches."
17177 msgstr ""
17179 #. type: Content of: <book><chapter><sect1><para>
17180 #: ../en/ch12-mq.xml:1052
17181 msgid ""
17182 "This presents the interesting possibility of managing the contents of the "
17183 "patch directory as a Mercurial repository in its own right. This can be a "
17184 "useful way to work. For example, you can work on a patch for a while, "
17185 "<command role=\"hg-ext-mq\">qrefresh</command> it, then <command role=\"hg-cmd"
17186 "\">hg commit</command> the current state of the patch. This lets you "
17187 "<quote>roll back</quote> to that version of the patch later on."
17188 msgstr ""
17190 #. type: Content of: <book><chapter><sect1><para>
17191 #: ../en/ch12-mq.xml:1061
17192 msgid ""
17193 "You can then share different versions of the same patch stack among multiple "
17194 "underlying repositories. I use this when I am developing a Linux kernel "
17195 "feature. I have a pristine copy of my kernel sources for each of several CPU "
17196 "architectures, and a cloned repository under each that contains the patches I "
17197 "am working on. When I want to test a change on a different architecture, I "
17198 "push my current patches to the patch repository associated with that kernel "
17199 "tree, pop and push all of my patches, and build and test that kernel."
17200 msgstr ""
17202 #. type: Content of: <book><chapter><sect1><para>
17203 #: ../en/ch12-mq.xml:1071
17204 msgid ""
17205 "Managing patches in a repository makes it possible for multiple developers to "
17206 "work on the same patch series without colliding with each other, all on top "
17207 "of an underlying source base that they may or may not control."
17208 msgstr ""
17210 #. type: Content of: <book><chapter><sect1><sect2><title>
17211 #: ../en/ch12-mq.xml:1077
17212 msgid "MQ support for patch repositories"
17213 msgstr "MQ 支持补丁版本库"
17215 #. type: Content of: <book><chapter><sect1><sect2><para>
17216 #: ../en/ch12-mq.xml:1079
17217 msgid ""
17218 "MQ helps you to work with the <filename role=\"special\" class=\"directory\">."
17219 "hg/patches</filename> directory as a repository; when you prepare a "
17220 "repository for working with patches using <command role=\"hg-ext-mq\">qinit</"
17221 "command>, you can pass the <option role=\"hg-ext-mq-cmd-qinit-opt\">hg -c</"
17222 "option> option to create the <filename role=\"special\" class=\"directory\">."
17223 "hg/patches</filename> directory as a Mercurial repository."
17224 msgstr ""
17226 #. type: Content of: <book><chapter><sect1><sect2><note><para>
17227 #: ../en/ch12-mq.xml:1089
17228 msgid ""
17229 "If you forget to use the <option role=\"hg-ext-mq-cmd-qinit-opt\">hg -c</"
17230 "option> option, you can simply go into the <filename role=\"special\" class="
17231 "\"directory\">.hg/patches</filename> directory at any time and run <command "
17232 "role=\"hg-cmd\">hg init</command>. Don't forget to add an entry for the "
17233 "<filename role=\"special\">status</filename> file to the <filename role="
17234 "\"special\">.hgignore</filename> file, though"
17235 msgstr ""
17237 #. type: Content of: <book><chapter><sect1><sect2><note><para>
17238 #: ../en/ch12-mq.xml:1098
17239 msgid ""
17240 "(<command role=\"hg-cmd\">hg qinit <option role=\"hg-ext-mq-cmd-qinit-opt"
17241 "\">hg -c</option></command> does this for you automatically); you "
17242 "<emphasis>really</emphasis> don't want to manage the <filename role=\"special"
17243 "\">status</filename> file."
17244 msgstr ""
17246 #. type: Content of: <book><chapter><sect1><sect2><para>
17247 #: ../en/ch12-mq.xml:1105
17248 msgid ""
17249 "As a convenience, if MQ notices that the <filename class=\"directory\">.hg/"
17250 "patches</filename> directory is a repository, it will automatically <command "
17251 "role=\"hg-cmd\">hg add</command> every patch that you create and import."
17252 msgstr ""
17254 #. type: Content of: <book><chapter><sect1><sect2><para>
17255 #: ../en/ch12-mq.xml:1110
17256 msgid ""
17257 "MQ provides a shortcut command, <command role=\"hg-ext-mq\">qcommit</"
17258 "command>, that runs <command role=\"hg-cmd\">hg commit</command> in the "
17259 "<filename role=\"special\" class=\"directory\">.hg/patches</filename> "
17260 "directory. This saves some bothersome typing."
17261 msgstr ""
17263 #. type: Content of: <book><chapter><sect1><sect2><para>
17264 #: ../en/ch12-mq.xml:1116
17265 msgid ""
17266 "Finally, as a convenience to manage the patch directory, you can define the "
17267 "alias <command>mq</command> on Unix systems. For example, on Linux systems "
17268 "using the <command>bash</command> shell, you can include the following "
17269 "snippet in your <filename role=\"home\">~/.bashrc</filename>."
17270 msgstr ""
17272 #. type: Content of: <book><chapter><sect1><sect2><para>
17273 #: ../en/ch12-mq.xml:1125
17274 msgid ""
17275 "You can then issue commands of the form <command>mq pull</command> from the "
17276 "main repository."
17277 msgstr ""
17279 #. type: Content of: <book><chapter><sect1><sect2><title>
17280 #: ../en/ch12-mq.xml:1130
17281 msgid "A few things to watch out for"
17282 msgstr "需要注意的事情"
17284 #. type: Content of: <book><chapter><sect1><sect2><para>
17285 #: ../en/ch12-mq.xml:1132
17286 msgid ""
17287 "MQ's support for working with a repository full of patches is limited in a "
17288 "few small respects."
17289 msgstr ""
17291 #. type: Content of: <book><chapter><sect1><sect2><para>
17292 #: ../en/ch12-mq.xml:1135
17293 msgid ""
17294 "MQ cannot automatically detect changes that you make to the patch directory. "
17295 "If you <command role=\"hg-cmd\">hg pull</command>, manually edit, or <command "
17296 "role=\"hg-cmd\">hg update</command> changes to patches or the <filename role="
17297 "\"special\">series</filename> file, you will have to <command role=\"hg-cmd"
17298 "\">hg qpop <option role=\"hg-ext-mq-cmd-qpop-opt\">-a</option></command> and "
17299 "then <command role=\"hg-cmd\">hg qpush <option role=\"hg-ext-mq-cmd-qpush-opt"
17300 "\">-a</option></command> in the underlying repository to see those changes "
17301 "show up there. If you forget to do this, you can confuse MQ's idea of which "
17302 "patches are applied."
17303 msgstr ""
17305 #. type: Content of: <book><chapter><sect1><title>
17306 #: ../en/ch12-mq.xml:1151
17307 msgid "Third party tools for working with patches"
17308 msgstr "操作补丁的第三方工具"
17310 #. type: Content of: <book><chapter><sect1><para>
17311 #: ../en/ch12-mq.xml:1153
17312 msgid ""
17313 "Once you've been working with patches for a while, you'll find yourself "
17314 "hungry for tools that will help you to understand and manipulate the patches "
17315 "you're dealing with."
17316 msgstr ""
17318 #. type: Content of: <book><chapter><sect1><para>
17319 #: ../en/ch12-mq.xml:1157
17320 msgid ""
17321 "The <command>diffstat</command> command <citation>web:diffstat</citation> "
17322 "generates a histogram of the modifications made to each file in a patch. It "
17323 "provides a good way to <quote>get a sense of</quote> a patch&emdash;which "
17324 "files it affects, and how much change it introduces to each file and as a "
17325 "whole. (I find that it's a good idea to use <command>diffstat</command>'s "
17326 "<option role=\"cmd-opt-diffstat\">-p</option> option as a matter of course, "
17327 "as otherwise it will try to do clever things with prefixes of file names that "
17328 "inevitably confuse at least me.)"
17329 msgstr ""
17331 #. type: Content of: <book><chapter><sect1><para>
17332 #: ../en/ch12-mq.xml:1171
17333 msgid ""
17334 "The <literal role=\"package\">patchutils</literal> package <citation>web:"
17335 "patchutils</citation> is invaluable. It provides a set of small utilities "
17336 "that follow the <quote>Unix philosophy;</quote> each does one useful thing "
17337 "with a patch. The <literal role=\"package\">patchutils</literal> command I "
17338 "use most is <command>filterdiff</command>, which extracts subsets from a "
17339 "patch file. For example, given a patch that modifies hundreds of files "
17340 "across dozens of directories, a single invocation of <command>filterdiff</"
17341 "command> can generate a smaller patch that only touches files whose names "
17342 "match a particular glob pattern. See <xref linkend=\"mq-collab:tips:interdiff"
17343 "\"/> for another example."
17344 msgstr ""
17346 #. type: Content of: <book><chapter><sect1><title>
17347 #: ../en/ch12-mq.xml:1187
17348 msgid "Good ways to work with patches"
17349 msgstr "操作补丁的好习惯"
17351 #. type: Content of: <book><chapter><sect1><para>
17352 #: ../en/ch12-mq.xml:1189
17353 msgid ""
17354 "Whether you are working on a patch series to submit to a free software or "
17355 "open source project, or a series that you intend to treat as a sequence of "
17356 "regular changesets when you're done, you can use some simple techniques to "
17357 "keep your work well organized."
17358 msgstr ""
17360 #. type: Content of: <book><chapter><sect1><para>
17361 #: ../en/ch12-mq.xml:1195
17362 msgid ""
17363 "Give your patches descriptive names. A good name for a patch might be "
17364 "<filename>rework-device-alloc.patch</filename>, because it will immediately "
17365 "give you a hint what the purpose of the patch is. Long names shouldn't be a "
17366 "problem; you won't be typing the names often, but you <emphasis>will</"
17367 "emphasis> be running commands like <command role=\"hg-ext-mq\">qapplied</"
17368 "command> and <command role=\"hg-ext-mq\">qtop</command> over and over. Good "
17369 "naming becomes especially important when you have a number of patches to work "
17370 "with, or if you are juggling a number of different tasks and your patches "
17371 "only get a fraction of your attention."
17372 msgstr ""
17374 #. type: Content of: <book><chapter><sect1><para>
17375 #: ../en/ch12-mq.xml:1207
17376 msgid ""
17377 "Be aware of what patch you're working on. Use the <command role=\"hg-ext-mq"
17378 "\">qtop</command> command and skim over the text of your patches "
17379 "frequently&emdash;for example, using <command role=\"hg-cmd\">hg tip <option "
17380 "role=\"hg-opt-tip\">-p</option></command>)&emdash;to be sure of where you "
17381 "stand. I have several times worked on and <command role=\"hg-ext-mq"
17382 "\">qrefresh</command>ed a patch other than the one I intended, and it's often "
17383 "tricky to migrate changes into the right patch after making them in the wrong "
17384 "one."
17385 msgstr ""
17387 #. type: Content of: <book><chapter><sect1><para>
17388 #: ../en/ch12-mq.xml:1217
17389 msgid ""
17390 "For this reason, it is very much worth investing a little time to learn how "
17391 "to use some of the third-party tools I described in <xref linkend=\"sec:mq:"
17392 "tools\"/>, particularly <command>diffstat</command> and <command>filterdiff</"
17393 "command>. The former will give you a quick idea of what changes your patch "
17394 "is making, while the latter makes it easy to splice hunks selectively out of "
17395 "one patch and into another."
17396 msgstr ""
17398 #. type: Content of: <book><chapter><sect1><title>
17399 #: ../en/ch12-mq.xml:1228
17400 msgid "MQ cookbook"
17401 msgstr "MQ 手册"
17403 #. type: Content of: <book><chapter><sect1><sect2><title>
17404 #: ../en/ch12-mq.xml:1231
17405 msgid "Manage <quote>trivial</quote> patches"
17406 msgstr "管理<quote>琐碎的</quote>补丁"
17408 #. type: Content of: <book><chapter><sect1><sect2><para>
17409 #: ../en/ch12-mq.xml:1233
17410 msgid ""
17411 "Because the overhead of dropping files into a new Mercurial repository is so "
17412 "low, it makes a lot of sense to manage patches this way even if you simply "
17413 "want to make a few changes to a source tarball that you downloaded."
17414 msgstr ""
17417 #. type: Content of: <book><chapter><sect1><sect2><para>
17418 #: ../en/ch12-mq.xml:1238
17419 msgid ""
17420 "Begin by downloading and unpacking the source tarball, and turning it into a "
17421 "Mercurial repository."
17422 msgstr ""
17424 #. type: Content of: <book><chapter><sect1><sect2><para>
17425 #: ../en/ch12-mq.xml:1243
17426 msgid "Continue by creating a patch stack and making your changes."
17427 msgstr ""
17429 #. type: Content of: <book><chapter><sect1><sect2><para>
17430 #: ../en/ch12-mq.xml:1248
17431 msgid ""
17432 "Let's say a few weeks or months pass, and your package author releases a new "
17433 "version. First, bring their changes into the repository."
17434 msgstr ""
17436 #. type: Content of: <book><chapter><sect1><sect2><para>
17437 #: ../en/ch12-mq.xml:1254
17438 msgid ""
17439 "The pipeline starting with <command role=\"hg-cmd\">hg locate</command> above "
17440 "deletes all files in the working directory, so that <command role=\"hg-cmd"
17441 "\">hg commit</command>'s <option role=\"hg-opt-commit\">--addremove</option> "
17442 "option can actually tell which files have really been removed in the newer "
17443 "version of the source."
17444 msgstr ""
17446 #. type: Content of: <book><chapter><sect1><sect2><para>
17447 #: ../en/ch12-mq.xml:1262
17448 msgid "Finally, you can apply your patches on top of the new tree."
17449 msgstr ""
17451 #. type: Content of: <book><chapter><sect1><sect2><title>
17452 #: ../en/ch12-mq.xml:1269
17453 msgid "Combining entire patches"
17454 msgstr "组合全部的补丁"
17456 #. type: Content of: <book><chapter><sect1><sect2><para>
17457 #: ../en/ch12-mq.xml:1271
17458 msgid ""
17459 "MQ provides a command, <command role=\"hg-ext-mq\">qfold</command> that lets "
17460 "you combine entire patches. This <quote>folds</quote> the patches you name, "
17461 "in the order you name them, into the topmost applied patch, and concatenates "
17462 "their descriptions onto the end of its description. The patches that you "
17463 "fold must be unapplied before you fold them."
17464 msgstr ""
17466 #. type: Content of: <book><chapter><sect1><sect2><para>
17467 #: ../en/ch12-mq.xml:1279
17468 msgid ""
17469 "The order in which you fold patches matters. If your topmost applied patch "
17470 "is <literal>foo</literal>, and you <command role=\"hg-ext-mq\">qfold</"
17471 "command> <literal>bar</literal> and <literal>quux</literal> into it, you will "
17472 "end up with a patch that has the same effect as if you applied first "
17473 "<literal>foo</literal>, then <literal>bar</literal>, followed by "
17474 "<literal>quux</literal>."
17475 msgstr ""
17477 #. type: Content of: <book><chapter><sect1><sect2><title>
17478 #: ../en/ch12-mq.xml:1290
17479 msgid "Merging part of one patch into another"
17480 msgstr "合并补丁的部分内容到其它补丁"
17482 #. type: Content of: <book><chapter><sect1><sect2><para>
17483 #: ../en/ch12-mq.xml:1292
17484 msgid ""
17485 "Merging <emphasis>part</emphasis> of one patch into another is more difficult "
17486 "than combining entire patches."
17487 msgstr ""
17489 #. type: Content of: <book><chapter><sect1><sect2><para>
17490 #: ../en/ch12-mq.xml:1296
17491 msgid ""
17492 "If you want to move changes to entire files, you can use <command>filterdiff</"
17493 "command>'s <option role=\"cmd-opt-filterdiff\">-i</option> and <option role="
17494 "\"cmd-opt-filterdiff\">-x</option> options to choose the modifications to "
17495 "snip out of one patch, concatenating its output onto the end of the patch you "
17496 "want to merge into. You usually won't need to modify the patch you've merged "
17497 "the changes from. Instead, MQ will report some rejected hunks when you "
17498 "<command role=\"hg-ext-mq\">qpush</command> it (from the hunks you moved into "
17499 "the other patch), and you can simply <command role=\"hg-ext-mq\">qrefresh</"
17500 "command> the patch to drop the duplicate hunks."
17501 msgstr ""
17503 #. type: Content of: <book><chapter><sect1><sect2><para>
17504 #: ../en/ch12-mq.xml:1309
17505 msgid ""
17506 "If you have a patch that has multiple hunks modifying a file, and you only "
17507 "want to move a few of those hunks, the job becomes more messy, but you can "
17508 "still partly automate it. Use <command>lsdiff -nvv</command> to print some "
17509 "metadata about the patch."
17510 msgstr ""
17512 #. type: Content of: <book><chapter><sect1><sect2><para>
17513 #: ../en/ch12-mq.xml:1317
17514 msgid "This command prints three different kinds of number:"
17515 msgstr ""
17517 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
17518 #: ../en/ch12-mq.xml:1320
17519 msgid ""
17520 "(in the first column) a <emphasis>file number</emphasis> to identify each "
17521 "file modified in the patch;"
17522 msgstr ""
17524 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
17525 #: ../en/ch12-mq.xml:1324
17526 msgid ""
17527 "(on the next line, indented) the line number within a modified file where a "
17528 "hunk starts; and"
17529 msgstr ""
17531 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
17532 #: ../en/ch12-mq.xml:1327
17533 msgid ""
17534 "(on the same line) a <emphasis>hunk number</emphasis> to identify that hunk."
17535 msgstr ""
17537 #. type: Content of: <book><chapter><sect1><sect2><para>
17538 #: ../en/ch12-mq.xml:1331
17539 msgid ""
17540 "You'll have to use some visual inspection, and reading of the patch, to "
17541 "identify the file and hunk numbers you'll want, but you can then pass them to "
17542 "to <command>filterdiff</command>'s <option role=\"cmd-opt-filterdiff\">--"
17543 "files</option> and <option role=\"cmd-opt-filterdiff\">--hunks</option> "
17544 "options, to select exactly the file and hunk you want to extract."
17545 msgstr ""
17547 #. type: Content of: <book><chapter><sect1><sect2><para>
17548 #: ../en/ch12-mq.xml:1339
17549 msgid ""
17550 "Once you have this hunk, you can concatenate it onto the end of your "
17551 "destination patch and continue with the remainder of <xref linkend=\"sec:mq:"
17552 "combine\"/>."
17553 msgstr ""
17555 #. type: Content of: <book><chapter><sect1><title>
17556 #: ../en/ch12-mq.xml:1346
17557 msgid "Differences between quilt and MQ"
17558 msgstr "MQ 与 quilt 的区别"
17560 #. type: Content of: <book><chapter><sect1><para>
17561 #: ../en/ch12-mq.xml:1348
17562 msgid ""
17563 "If you are already familiar with quilt, MQ provides a similar command set. "
17564 "There are a few differences in the way that it works."
17565 msgstr ""
17567 #. type: Content of: <book><chapter><sect1><para>
17568 #: ../en/ch12-mq.xml:1352
17569 msgid ""
17570 "You will already have noticed that most quilt commands have MQ counterparts "
17571 "that simply begin with a <quote><literal>q</literal></quote>. The exceptions "
17572 "are quilt's <literal>add</literal> and <literal>remove</literal> commands, "
17573 "the counterparts for which are the normal Mercurial <command role=\"hg-cmd"
17574 "\">hg add</command> and <command role=\"hg-cmd\">hg remove</command> "
17575 "commands. There is no MQ equivalent of the quilt <literal>edit</literal> "
17576 "command."
17577 msgstr ""
17579 #. type: Content of: <book><chapter><title>
17580 #: ../en/ch13-mq-collab.xml:5
17581 msgid "Advanced uses of Mercurial Queues"
17582 msgstr "MQ 的高级用法"
17584 #. type: Content of: <book><chapter><para>
17585 #: ../en/ch13-mq-collab.xml:7
17586 msgid ""
17587 "While it's easy to pick up straightforward uses of Mercurial Queues, use of a "
17588 "little discipline and some of MQ's less frequently used capabilities makes it "
17589 "possible to work in complicated development environments."
17590 msgstr ""
17592 #. type: Content of: <book><chapter><para>
17593 #: ../en/ch13-mq-collab.xml:12
17594 msgid ""
17595 "In this chapter, I will use as an example a technique I have used to manage "
17596 "the development of an Infiniband device driver for the Linux kernel. The "
17597 "driver in question is large (at least as drivers go), with 25,000 lines of "
17598 "code spread across 35 source files. It is maintained by a small team of "
17599 "developers."
17600 msgstr ""
17602 #. type: Content of: <book><chapter><para>
17603 #: ../en/ch13-mq-collab.xml:18
17604 msgid ""
17605 "While much of the material in this chapter is specific to Linux, the same "
17606 "principles apply to any code base for which you're not the primary owner, and "
17607 "upon which you need to do a lot of development."
17608 msgstr ""
17610 #. type: Content of: <book><chapter><sect1><title>
17611 #: ../en/ch13-mq-collab.xml:24
17612 msgid "The problem of many targets"
17613 msgstr "多个目标的问题"
17615 #. type: Content of: <book><chapter><sect1><para>
17616 #: ../en/ch13-mq-collab.xml:26
17617 msgid ""
17618 "The Linux kernel changes rapidly, and has never been internally stable; "
17619 "developers frequently make drastic changes between releases. This means that "
17620 "a version of the driver that works well with a particular released version of "
17621 "the kernel will not even <emphasis>compile</emphasis> correctly against, "
17622 "typically, any other version."
17623 msgstr ""
17625 #. type: Content of: <book><chapter><sect1><para>
17626 #: ../en/ch13-mq-collab.xml:33
17627 msgid ""
17628 "To maintain a driver, we have to keep a number of distinct versions of Linux "
17629 "in mind."
17630 msgstr ""
17632 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17633 #: ../en/ch13-mq-collab.xml:36
17634 msgid ""
17635 "One target is the main Linux kernel development tree. Maintenance of the code "
17636 "is in this case partly shared by other developers in the kernel community, "
17637 "who make <quote>drive-by</quote> modifications to the driver as they develop "
17638 "and refine kernel subsystems."
17639 msgstr ""
17641 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17642 #: ../en/ch13-mq-collab.xml:42
17643 msgid ""
17644 "We also maintain a number of <quote>backports</quote> to older versions of "
17645 "the Linux kernel, to support the needs of customers who are running older "
17646 "Linux distributions that do not incorporate our drivers. (To "
17647 "<emphasis>backport</emphasis> a piece of code is to modify it to work in an "
17648 "older version of its target environment than the version it was developed "
17649 "for.)"
17650 msgstr ""
17652 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17653 #: ../en/ch13-mq-collab.xml:50
17654 msgid ""
17655 "Finally, we make software releases on a schedule that is necessarily not "
17656 "aligned with those used by Linux distributors and kernel developers, so that "
17657 "we can deliver new features to customers without forcing them to upgrade "
17658 "their entire kernels or distributions."
17659 msgstr ""
17661 #. type: Content of: <book><chapter><sect1><sect2><title>
17662 #: ../en/ch13-mq-collab.xml:58
17663 msgid "Tempting approaches that don't work well"
17664 msgstr "工作不好的诱人方法"
17666 #. type: Content of: <book><chapter><sect1><sect2><para>
17667 #: ../en/ch13-mq-collab.xml:60
17668 msgid ""
17669 "There are two <quote>standard</quote> ways to maintain a piece of software "
17670 "that has to target many different environments."
17671 msgstr ""
17673 #. type: Content of: <book><chapter><sect1><sect2><para>
17674 #: ../en/ch13-mq-collab.xml:64
17675 msgid ""
17676 "The first is to maintain a number of branches, each intended for a single "
17677 "target. The trouble with this approach is that you must maintain iron "
17678 "discipline in the flow of changes between repositories. A new feature or bug "
17679 "fix must start life in a <quote>pristine</quote> repository, then percolate "
17680 "out to every backport repository. Backport changes are more limited in the "
17681 "branches they should propagate to; a backport change that is applied to a "
17682 "branch where it doesn't belong will probably stop the driver from compiling."
17683 msgstr ""
17685 #. type: Content of: <book><chapter><sect1><sect2><para>
17686 #: ../en/ch13-mq-collab.xml:74
17687 msgid ""
17688 "The second is to maintain a single source tree filled with conditional "
17689 "statements that turn chunks of code on or off depending on the intended "
17690 "target. Because these <quote>ifdefs</quote> are not allowed in the Linux "
17691 "kernel tree, a manual or automatic process must be followed to strip them out "
17692 "and yield a clean tree. A code base maintained in this fashion rapidly "
17693 "becomes a rat's nest of conditional blocks that are difficult to understand "
17694 "and maintain."
17695 msgstr ""
17697 #. type: Content of: <book><chapter><sect1><sect2><para>
17698 #: ../en/ch13-mq-collab.xml:83
17699 msgid ""
17700 "Neither of these approaches is well suited to a situation where you don't "
17701 "<quote>own</quote> the canonical copy of a source tree. In the case of a "
17702 "Linux driver that is distributed with the standard kernel, Linus's tree "
17703 "contains the copy of the code that will be treated by the world as "
17704 "canonical. The upstream version of <quote>my</quote> driver can be modified "
17705 "by people I don't know, without me even finding out about it until after the "
17706 "changes show up in Linus's tree."
17707 msgstr ""
17709 #. type: Content of: <book><chapter><sect1><sect2><para>
17710 #: ../en/ch13-mq-collab.xml:93
17711 msgid ""
17712 "These approaches have the added weakness of making it difficult to generate "
17713 "well-formed patches to submit upstream."
17714 msgstr ""
17716 #. type: Content of: <book><chapter><sect1><sect2><para>
17717 #: ../en/ch13-mq-collab.xml:97
17718 msgid ""
17719 "In principle, Mercurial Queues seems like a good candidate to manage a "
17720 "development scenario such as the above. While this is indeed the case, MQ "
17721 "contains a few added features that make the job more pleasant."
17722 msgstr ""
17724 #. type: Content of: <book><chapter><sect1><title>
17725 #: ../en/ch13-mq-collab.xml:105
17726 msgid "Conditionally applying patches with guards"
17727 msgstr "有条件的应用补丁"
17729 #. type: Content of: <book><chapter><sect1><para>
17730 #: ../en/ch13-mq-collab.xml:107
17731 msgid ""
17732 "Perhaps the best way to maintain sanity with so many targets is to be able to "
17733 "choose specific patches to apply for a given situation. MQ provides a "
17734 "feature called <quote>guards</quote> (which originates with quilt's "
17735 "<literal>guards</literal> command) that does just this. To start off, let's "
17736 "create a simple repository for experimenting in."
17737 msgstr ""
17739 #. type: Content of: <book><chapter><sect1><para>
17740 #: ../en/ch13-mq-collab.xml:116
17741 msgid ""
17742 "This gives us a tiny repository that contains two patches that don't have any "
17743 "dependencies on each other, because they touch different files."
17744 msgstr ""
17746 #. type: Content of: <book><chapter><sect1><para>
17747 #: ../en/ch13-mq-collab.xml:120
17748 msgid ""
17749 "The idea behind conditional application is that you can <quote>tag</quote> a "
17750 "patch with a <emphasis>guard</emphasis>, which is simply a text string of "
17751 "your choosing, then tell MQ to select specific guards to use when applying "
17752 "patches. MQ will then either apply, or skip over, a guarded patch, depending "
17753 "on the guards that you have selected."
17754 msgstr ""
17756 #. type: Content of: <book><chapter><sect1><para>
17757 #: ../en/ch13-mq-collab.xml:127
17758 msgid ""
17759 "A patch can have an arbitrary number of guards; each one is "
17760 "<emphasis>positive</emphasis> (<quote>apply this patch if this guard is "
17761 "selected</quote>) or <emphasis>negative</emphasis> (<quote>skip this patch if "
17762 "this guard is selected</quote>). A patch with no guards is always applied."
17763 msgstr ""
17765 #. type: Content of: <book><chapter><sect1><title>
17766 #: ../en/ch13-mq-collab.xml:135
17767 msgid "Controlling the guards on a patch"
17768 msgstr "控制补丁的应用条件"
17770 #. type: Content of: <book><chapter><sect1><para>
17771 #: ../en/ch13-mq-collab.xml:137
17772 msgid ""
17773 "The <command role=\"hg-ext-mq\">qguard</command> command lets you determine "
17774 "which guards should apply to a patch, or display the guards that are already "
17775 "in effect. Without any arguments, it displays the guards on the current "
17776 "topmost patch."
17777 msgstr ""
17779 #. type: Content of: <book><chapter><sect1><para>
17780 #: ../en/ch13-mq-collab.xml:144
17781 msgid ""
17782 "To set a positive guard on a patch, prefix the name of the guard with a "
17783 "<quote><literal>+</literal></quote>."
17784 msgstr ""
17786 #. type: Content of: <book><chapter><sect1><para>
17787 #: ../en/ch13-mq-collab.xml:149
17788 msgid ""
17789 "To set a negative guard on a patch, prefix the name of the guard with a "
17790 "<quote><literal>-</literal></quote>."
17791 msgstr ""
17793 #. type: Content of: <book><chapter><sect1><para>
17794 #: ../en/ch13-mq-collab.xml:155
17795 msgid ""
17796 "Notice that we prefixed the arguments to the <command>hg qguard</command> "
17797 "command with a <literal>--</literal> here, so that Mercurial would not "
17798 "interpret the text <literal>-quux</literal> as an option."
17799 msgstr ""
17801 #. type: Content of: <book><chapter><sect1><note><title>
17802 #: ../en/ch13-mq-collab.xml:161
17803 msgid "Setting vs. modifying"
17804 msgstr ""
17806 #. type: Content of: <book><chapter><sect1><note><para>
17807 #: ../en/ch13-mq-collab.xml:163
17808 msgid ""
17809 "The <command role=\"hg-ext-mq\">qguard</command> command <emphasis>sets</"
17810 "emphasis> the guards on a patch; it doesn't <emphasis>modify</emphasis> "
17811 "them. What this means is that if you run <command role=\"hg-cmd\">hg qguard "
17812 "+a +b</command> on a patch, then <command role=\"hg-cmd\">hg qguard +c</"
17813 "command> on the same patch, the <emphasis>only</emphasis> guard that will be "
17814 "set on it afterwards is <literal>+c</literal>."
17815 msgstr ""
17818 #. type: Content of: <book><chapter><sect1><para>
17819 #: ../en/ch13-mq-collab.xml:172
17820 msgid ""
17821 "Mercurial stores guards in the <filename role=\"special\">series</filename> "
17822 "file; the form in which they are stored is easy both to understand and to "
17823 "edit by hand. (In other words, you don't have to use the <command role=\"hg-"
17824 "ext-mq\">qguard</command> command if you don't want to; it's okay to simply "
17825 "edit the <filename role=\"special\">series</filename> file.)"
17826 msgstr ""
17828 #. type: Content of: <book><chapter><sect1><title>
17829 #: ../en/ch13-mq-collab.xml:184
17830 msgid "Selecting the guards to use"
17831 msgstr "选择使用的条件"
17833 #. type: Content of: <book><chapter><sect1><para>
17834 #: ../en/ch13-mq-collab.xml:186
17835 msgid ""
17836 "The <command role=\"hg-ext-mq\">qselect</command> command determines which "
17837 "guards are active at a given time. The effect of this is to determine which "
17838 "patches MQ will apply the next time you run <command role=\"hg-ext-mq"
17839 "\">qpush</command>. It has no other effect; in particular, it doesn't do "
17840 "anything to patches that are already applied."
17841 msgstr ""
17843 #. type: Content of: <book><chapter><sect1><para>
17844 #: ../en/ch13-mq-collab.xml:193
17845 msgid ""
17846 "With no arguments, the <command role=\"hg-ext-mq\">qselect</command> command "
17847 "lists the guards currently in effect, one per line of output. Each argument "
17848 "is treated as the name of a guard to apply."
17849 msgstr ""
17851 #. type: Content of: <book><chapter><sect1><para>
17852 #: ../en/ch13-mq-collab.xml:200
17853 msgid ""
17854 "In case you're interested, the currently selected guards are stored in the "
17855 "<filename role=\"special\">guards</filename> file."
17856 msgstr ""
17858 #. type: Content of: <book><chapter><sect1><para>
17859 #: ../en/ch13-mq-collab.xml:205
17860 msgid ""
17861 "We can see the effect the selected guards have when we run <command role=\"hg-"
17862 "ext-mq\">qpush</command>."
17863 msgstr ""
17865 #. type: Content of: <book><chapter><sect1><para>
17866 #: ../en/ch13-mq-collab.xml:210
17867 msgid ""
17868 "A guard cannot start with a <quote><literal>+</literal></quote> or "
17869 "<quote><literal>-</literal></quote> character. The name of a guard must not "
17870 "contain white space, but most other characters are acceptable. If you try to "
17871 "use a guard with an invalid name, MQ will complain:"
17872 msgstr ""
17874 #. type: Content of: <book><chapter><sect1><para>
17875 #: ../en/ch13-mq-collab.xml:219
17876 msgid "Changing the selected guards changes the patches that are applied."
17877 msgstr ""
17879 #. type: Content of: <book><chapter><sect1><para>
17880 #: ../en/ch13-mq-collab.xml:224
17881 msgid ""
17882 "You can see in the example below that negative guards take precedence over "
17883 "positive guards."
17884 msgstr ""
17886 #. type: Content of: <book><chapter><sect1><title>
17887 #: ../en/ch13-mq-collab.xml:231
17888 msgid "MQ's rules for applying patches"
17889 msgstr "MQ 应用补丁的规则"
17891 #. type: Content of: <book><chapter><sect1><para>
17892 #: ../en/ch13-mq-collab.xml:233
17893 msgid ""
17894 "The rules that MQ uses when deciding whether to apply a patch are as follows."
17895 msgstr ""
17897 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17898 #: ../en/ch13-mq-collab.xml:236
17899 msgid "A patch that has no guards is always applied."
17900 msgstr ""
17902 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17903 #: ../en/ch13-mq-collab.xml:239
17904 msgid ""
17905 "If the patch has any negative guard that matches any currently selected "
17906 "guard, the patch is skipped."
17907 msgstr ""
17909 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17910 #: ../en/ch13-mq-collab.xml:242
17911 msgid ""
17912 "If the patch has any positive guard that matches any currently selected "
17913 "guard, the patch is applied."
17914 msgstr ""
17916 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17917 #: ../en/ch13-mq-collab.xml:245
17918 msgid ""
17919 "If the patch has positive or negative guards, but none matches any currently "
17920 "selected guard, the patch is skipped."
17921 msgstr ""
17923 #. type: Content of: <book><chapter><sect1><title>
17924 #: ../en/ch13-mq-collab.xml:252
17925 msgid "Trimming the work environment"
17926 msgstr "修剪工作环境"
17928 #. type: Content of: <book><chapter><sect1><para>
17929 #: ../en/ch13-mq-collab.xml:254
17930 msgid ""
17931 "In working on the device driver I mentioned earlier, I don't apply the "
17932 "patches to a normal Linux kernel tree. Instead, I use a repository that "
17933 "contains only a snapshot of the source files and headers that are relevant to "
17934 "Infiniband development. This repository is 1% the size of a kernel "
17935 "repository, so it's easier to work with."
17936 msgstr ""
17938 #. type: Content of: <book><chapter><sect1><para>
17939 #: ../en/ch13-mq-collab.xml:261
17940 msgid ""
17941 "I then choose a <quote>base</quote> version on top of which the patches are "
17942 "applied. This is a snapshot of the Linux kernel tree as of a revision of my "
17943 "choosing. When I take the snapshot, I record the changeset ID from the "
17944 "kernel repository in the commit message. Since the snapshot preserves the "
17945 "<quote>shape</quote> and content of the relevant parts of the kernel tree, I "
17946 "can apply my patches on top of either my tiny repository or a normal kernel "
17947 "tree."
17948 msgstr ""
17950 #. type: Content of: <book><chapter><sect1><para>
17951 #: ../en/ch13-mq-collab.xml:270
17952 msgid ""
17953 "Normally, the base tree atop which the patches apply should be a snapshot of "
17954 "a very recent upstream tree. This best facilitates the development of "
17955 "patches that can easily be submitted upstream with few or no modifications."
17956 msgstr ""
17958 #. type: Content of: <book><chapter><sect1><title>
17959 #: ../en/ch13-mq-collab.xml:277
17960 msgid "Dividing up the <filename role=\"special\">series</filename> file"
17961 msgstr "分类补丁<filename role=\"special\">系列</filename>"
17963 #. type: Content of: <book><chapter><sect1><para>
17964 #: ../en/ch13-mq-collab.xml:280
17965 msgid ""
17966 "I categorise the patches in the <filename role=\"special\">series</filename> "
17967 "file into a number of logical groups. Each section of like patches begins "
17968 "with a block of comments that describes the purpose of the patches that "
17969 "follow."
17970 msgstr ""
17972 #. type: Content of: <book><chapter><sect1><para>
17973 #: ../en/ch13-mq-collab.xml:286
17974 msgid ""
17975 "The sequence of patch groups that I maintain follows. The ordering of these "
17976 "groups is important; I'll describe why after I introduce the groups."
17977 msgstr ""
17979 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17980 #: ../en/ch13-mq-collab.xml:290
17981 msgid ""
17982 "The <quote>accepted</quote> group. Patches that the development team has "
17983 "submitted to the maintainer of the Infiniband subsystem, and which he has "
17984 "accepted, but which are not present in the snapshot that the tiny repository "
17985 "is based on. These are <quote>read only</quote> patches, present only to "
17986 "transform the tree into a similar state as it is in the upstream maintainer's "
17987 "repository."
17988 msgstr ""
17990 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17991 #: ../en/ch13-mq-collab.xml:298
17992 msgid ""
17993 "The <quote>rework</quote> group. Patches that I have submitted, but that the "
17994 "upstream maintainer has requested modifications to before he will accept them."
17995 msgstr ""
17997 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17998 #: ../en/ch13-mq-collab.xml:303
17999 msgid ""
18000 "The <quote>pending</quote> group. Patches that I have not yet submitted to "
18001 "the upstream maintainer, but which we have finished working on. These will be "
18002 "<quote>read only</quote> for a while. If the upstream maintainer accepts "
18003 "them upon submission, I'll move them to the end of the <quote>accepted</"
18004 "quote> group. If he requests that I modify any, I'll move them to the "
18005 "beginning of the <quote>rework</quote> group."
18006 msgstr ""
18008 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
18009 #: ../en/ch13-mq-collab.xml:312
18010 msgid ""
18011 "The <quote>in progress</quote> group. Patches that are actively being "
18012 "developed, and should not be submitted anywhere yet."
18013 msgstr ""
18015 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
18016 #: ../en/ch13-mq-collab.xml:316
18017 msgid ""
18018 "The <quote>backport</quote> group. Patches that adapt the source tree to "
18019 "older versions of the kernel tree."
18020 msgstr ""
18022 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
18023 #: ../en/ch13-mq-collab.xml:320
18024 msgid ""
18025 "The <quote>do not ship</quote> group. Patches that for some reason should "
18026 "never be submitted upstream. For example, one such patch might change "
18027 "embedded driver identification strings to make it easier to distinguish, in "
18028 "the field, between an out-of-tree version of the driver and a version shipped "
18029 "by a distribution vendor."
18030 msgstr ""
18032 #. type: Content of: <book><chapter><sect1><para>
18033 #: ../en/ch13-mq-collab.xml:328
18034 msgid ""
18035 "Now to return to the reasons for ordering groups of patches in this way. We "
18036 "would like the lowest patches in the stack to be as stable as possible, so "
18037 "that we will not need to rework higher patches due to changes in context. "
18038 "Putting patches that will never be changed first in the <filename role="
18039 "\"special\">series</filename> file serves this purpose."
18040 msgstr ""
18042 #. type: Content of: <book><chapter><sect1><para>
18043 #: ../en/ch13-mq-collab.xml:336
18044 msgid ""
18045 "We would also like the patches that we know we'll need to modify to be "
18046 "applied on top of a source tree that resembles the upstream tree as closely "
18047 "as possible. This is why we keep accepted patches around for a while."
18048 msgstr ""
18050 #. type: Content of: <book><chapter><sect1><para>
18051 #: ../en/ch13-mq-collab.xml:341
18052 msgid ""
18053 "The <quote>backport</quote> and <quote>do not ship</quote> patches float at "
18054 "the end of the <filename role=\"special\">series</filename> file. The "
18055 "backport patches must be applied on top of all other patches, and the "
18056 "<quote>do not ship</quote> patches might as well stay out of harm's way."
18057 msgstr ""
18059 #. type: Content of: <book><chapter><sect1><title>
18060 #: ../en/ch13-mq-collab.xml:350
18061 msgid "Maintaining the patch series"
18062 msgstr "维护补丁系列"
18064 #. type: Content of: <book><chapter><sect1><para>
18065 #: ../en/ch13-mq-collab.xml:352
18066 msgid ""
18067 "In my work, I use a number of guards to control which patches are to be "
18068 "applied."
18069 msgstr ""
18071 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
18072 #: ../en/ch13-mq-collab.xml:356
18073 msgid ""
18074 "<quote>Accepted</quote> patches are guarded with <literal>accepted</"
18075 "literal>. I enable this guard most of the time. When I'm applying the "
18076 "patches on top of a tree where the patches are already present, I can turn "
18077 "this patch off, and the patches that follow it will apply cleanly."
18078 msgstr ""
18080 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
18081 #: ../en/ch13-mq-collab.xml:363
18082 msgid ""
18083 "Patches that are <quote>finished</quote>, but not yet submitted, have no "
18084 "guards. If I'm applying the patch stack to a copy of the upstream tree, I "
18085 "don't need to enable any guards in order to get a reasonably safe source tree."
18086 msgstr ""
18088 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
18089 #: ../en/ch13-mq-collab.xml:369
18090 msgid ""
18091 "Those patches that need reworking before being resubmitted are guarded with "
18092 "<literal>rework</literal>."
18093 msgstr ""
18095 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
18096 #: ../en/ch13-mq-collab.xml:373
18097 msgid ""
18098 "For those patches that are still under development, I use <literal>devel</"
18099 "literal>."
18100 msgstr ""
18102 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
18103 #: ../en/ch13-mq-collab.xml:376
18104 msgid ""
18105 "A backport patch may have several guards, one for each version of the kernel "
18106 "to which it applies. For example, a patch that backports a piece of code to "
18107 "2.6.9 will have a <literal>2.6.9</literal> guard."
18108 msgstr ""
18110 #. type: Content of: <book><chapter><sect1><para>
18111 #: ../en/ch13-mq-collab.xml:381
18112 msgid ""
18113 "This variety of guards gives me considerable flexibility in determining what "
18114 "kind of source tree I want to end up with. For most situations, the "
18115 "selection of appropriate guards is automated during the build process, but I "
18116 "can manually tune the guards to use for less common circumstances."
18117 msgstr ""
18119 #. type: Content of: <book><chapter><sect1><sect2><title>
18120 #: ../en/ch13-mq-collab.xml:388
18121 msgid "The art of writing backport patches"
18122 msgstr "编写向后移植补丁的艺术"
18124 #. type: Content of: <book><chapter><sect1><sect2><para>
18125 #: ../en/ch13-mq-collab.xml:390
18126 msgid ""
18127 "Using MQ, writing a backport patch is a simple process. All such a patch has "
18128 "to do is modify a piece of code that uses a kernel feature not present in the "
18129 "older version of the kernel, so that the driver continues to work correctly "
18130 "under that older version."
18131 msgstr ""
18133 #. type: Content of: <book><chapter><sect1><sect2><para>
18134 #: ../en/ch13-mq-collab.xml:396
18135 msgid ""
18136 "A useful goal when writing a good backport patch is to make your code look as "
18137 "if it was written for the older version of the kernel you're targeting. The "
18138 "less obtrusive the patch, the easier it will be to understand and maintain. "
18139 "If you're writing a collection of backport patches to avoid the <quote>rat's "
18140 "nest</quote> effect of lots of <literal>#ifdef</literal>s (hunks of source "
18141 "code that are only used conditionally) in your code, don't introduce version-"
18142 "dependent <literal>#ifdef</literal>s into the patches. Instead, write "
18143 "several patches, each of which makes unconditional changes, and control their "
18144 "application using guards."
18145 msgstr ""
18147 #. type: Content of: <book><chapter><sect1><sect2><para>
18148 #: ../en/ch13-mq-collab.xml:409
18149 msgid ""
18150 "There are two reasons to divide backport patches into a distinct group, away "
18151 "from the <quote>regular</quote> patches whose effects they modify. The first "
18152 "is that intermingling the two makes it more difficult to use a tool like the "
18153 "<literal role=\"hg-ext\">patchbomb</literal> extension to automate the "
18154 "process of submitting the patches to an upstream maintainer. The second is "
18155 "that a backport patch could perturb the context in which a subsequent regular "
18156 "patch is applied, making it impossible to apply the regular patch cleanly "
18157 "<emphasis>without</emphasis> the earlier backport patch already being applied."
18158 msgstr ""
18160 #. type: Content of: <book><chapter><sect1><title>
18161 #: ../en/ch13-mq-collab.xml:424
18162 msgid "Useful tips for developing with MQ"
18163 msgstr "使用 MQ 开发的技巧"
18165 #. type: Content of: <book><chapter><sect1><sect2><title>
18166 #: ../en/ch13-mq-collab.xml:427
18167 msgid "Organising patches in directories"
18168 msgstr "将补丁放到几个目录中"
18170 #. type: Content of: <book><chapter><sect1><sect2><para>
18171 #: ../en/ch13-mq-collab.xml:429
18172 msgid ""
18173 "If you're working on a substantial project with MQ, it's not difficult to "
18174 "accumulate a large number of patches. For example, I have one patch "
18175 "repository that contains over 250 patches."
18176 msgstr ""
18178 #. type: Content of: <book><chapter><sect1><sect2><para>
18179 #: ../en/ch13-mq-collab.xml:434
18180 msgid ""
18181 "If you can group these patches into separate logical categories, you can if "
18182 "you like store them in different directories; MQ has no problems with patch "
18183 "names that contain path separators."
18184 msgstr ""
18186 #. type: Content of: <book><chapter><sect1><sect2><title>
18187 #: ../en/ch13-mq-collab.xml:441
18188 msgid "Viewing the history of a patch"
18189 msgstr "察看补丁的历史"
18191 #. type: Content of: <book><chapter><sect1><sect2><para>
18192 #: ../en/ch13-mq-collab.xml:443
18193 msgid ""
18194 "If you're developing a set of patches over a long time, it's a good idea to "
18195 "maintain them in a repository, as discussed in <xref linkend=\"sec:mq:repo\"/"
18196 ">. If you do so, you'll quickly discover that using the <command role=\"hg-"
18197 "cmd\">hg diff</command> command to look at the history of changes to a patch "
18198 "is unworkable. This is in part because you're looking at the second "
18199 "derivative of the real code (a diff of a diff), but also because MQ adds "
18200 "noise to the process by modifying time stamps and directory names when it "
18201 "updates a patch."
18202 msgstr ""
18204 #. type: Content of: <book><chapter><sect1><sect2><para>
18205 #: ../en/ch13-mq-collab.xml:455
18206 msgid ""
18207 "However, you can use the <literal role=\"hg-ext\">extdiff</literal> "
18208 "extension, which is bundled with Mercurial, to turn a diff of two versions of "
18209 "a patch into something readable. To do this, you will need a third-party "
18210 "package called <literal role=\"package\">patchutils</literal> <citation>web:"
18211 "patchutils</citation>. This provides a command named <command>interdiff</"
18212 "command>, which shows the differences between two diffs as a diff. Used on "
18213 "two versions of the same diff, it generates a diff that represents the diff "
18214 "from the first to the second version."
18215 msgstr ""
18217 #. type: Content of: <book><chapter><sect1><sect2><para>
18218 #: ../en/ch13-mq-collab.xml:466
18219 msgid ""
18220 "You can enable the <literal role=\"hg-ext\">extdiff</literal> extension in "
18221 "the usual way, by adding a line to the <literal role=\"rc-extensions"
18222 "\">extensions</literal> section of your <filename role=\"special\">~/.hgrc</"
18223 "filename>."
18224 msgstr ""
18227 #. &example.hg-interdiff;
18228 #. type: Content of: <book><chapter><sect1><sect2><para>
18229 #: ../en/ch13-mq-collab.xml:473
18230 msgid ""
18231 "The <command>interdiff</command> command expects to be passed the names of "
18232 "two files, but the <literal role=\"hg-ext\">extdiff</literal> extension "
18233 "passes the program it runs a pair of directories, each of which can contain "
18234 "an arbitrary number of files. We thus need a small program that will run "
18235 "<command>interdiff</command> on each pair of files in these two directories. "
18236 "This program is available as <filename role=\"special\">hg-interdiff</"
18237 "filename> in the <filename class=\"directory\">examples</filename> directory "
18238 "of the source code repository that accompanies this book."
18239 msgstr ""
18241 #. type: Content of: <book><chapter><sect1><sect2><para>
18242 #: ../en/ch13-mq-collab.xml:485
18243 msgid ""
18244 "With the <filename role=\"special\">hg-interdiff</filename> program in your "
18245 "shell's search path, you can run it as follows, from inside an MQ patch "
18246 "directory:"
18247 msgstr ""
18249 #. type: Content of: <book><chapter><sect1><sect2><para>
18250 #: ../en/ch13-mq-collab.xml:489
18251 msgid ""
18252 "Since you'll probably want to use this long-winded command a lot, you can get "
18253 "<literal role=\"hg-ext\">hgext</literal> to make it available as a normal "
18254 "Mercurial command, again by editing your <filename role=\"special\">~/.hgrc</"
18255 "filename>."
18256 msgstr ""
18258 #. type: Content of: <book><chapter><sect1><sect2><para>
18259 #: ../en/ch13-mq-collab.xml:496
18260 msgid ""
18261 "This directs <literal role=\"hg-ext\">hgext</literal> to make an "
18262 "<literal>interdiff</literal> command available, so you can now shorten the "
18263 "previous invocation of <command role=\"hg-ext-extdiff\">extdiff</command> to "
18264 "something a little more wieldy."
18265 msgstr ""
18267 #. type: Content of: <book><chapter><sect1><sect2><note><para>
18268 #: ../en/ch13-mq-collab.xml:504
18269 msgid ""
18270 "The <command>interdiff</command> command works well only if the underlying "
18271 "files against which versions of a patch are generated remain the same. If "
18272 "you create a patch, modify the underlying files, and then regenerate the "
18273 "patch, <command>interdiff</command> may not produce useful output."
18274 msgstr ""
18276 #. type: Content of: <book><chapter><sect1><sect2><para>
18277 #: ../en/ch13-mq-collab.xml:512
18278 msgid ""
18279 "The <literal role=\"hg-ext\">extdiff</literal> extension is useful for more "
18280 "than merely improving the presentation of MQ patches. To read more about it, "
18281 "go to <xref linkend=\"sec:hgext:extdiff\"/>."
18282 msgstr ""
18284 #. type: Content of: <book><chapter><title>
18285 #: ../en/ch14-hgext.xml:5
18286 msgid "Adding functionality with extensions"
18287 msgstr "使用扩展增加功能"
18289 #. type: Content of: <book><chapter><para>
18290 #: ../en/ch14-hgext.xml:7
18291 msgid ""
18292 "While the core of Mercurial is quite complete from a functionality "
18293 "standpoint, it's deliberately shorn of fancy features. This approach of "
18294 "preserving simplicity keeps the software easy to deal with for both "
18295 "maintainers and users."
18296 msgstr ""
18298 #. type: Content of: <book><chapter><para>
18299 #: ../en/ch14-hgext.xml:12
18300 msgid ""
18301 "However, Mercurial doesn't box you in with an inflexible command set: you can "
18302 "add features to it as <emphasis>extensions</emphasis> (sometimes known as "
18303 "<emphasis>plugins</emphasis>). We've already discussed a few of these "
18304 "extensions in earlier chapters."
18305 msgstr ""
18307 #. type: Content of: <book><chapter><itemizedlist><listitem><para>
18308 #: ../en/ch14-hgext.xml:18
18309 msgid ""
18310 "<xref linkend=\"sec:tour-merge:fetch\"/> covers the <literal role=\"hg-ext"
18311 "\">fetch</literal> extension; this combines pulling new changes and merging "
18312 "them with local changes into a single command, <command role=\"hg-ext-fetch"
18313 "\">fetch</command>."
18314 msgstr ""
18316 #. type: Content of: <book><chapter><itemizedlist><listitem><para>
18317 #: ../en/ch14-hgext.xml:24
18318 msgid ""
18319 "In <xref linkend=\"chap:hook\"/>, we covered several extensions that are "
18320 "useful for hook-related functionality: <literal role=\"hg-ext\">acl</literal> "
18321 "adds access control lists; <literal role=\"hg-ext\">bugzilla</literal> adds "
18322 "integration with the Bugzilla bug tracking system; and <literal role=\"hg-ext"
18323 "\">notify</literal> sends notification emails on new changes."
18324 msgstr ""
18326 #. type: Content of: <book><chapter><itemizedlist><listitem><para>
18327 #: ../en/ch14-hgext.xml:33
18328 msgid ""
18329 "The Mercurial Queues patch management extension is so invaluable that it "
18330 "merits two chapters and an appendix all to itself. <xref linkend=\"chap:mq\"/"
18331 "> covers the basics; <xref linkend=\"chap:mq-collab\"/> discusses advanced "
18332 "topics; and <xref linkend=\"chap:mqref\"/> goes into detail on each command."
18333 msgstr ""
18335 #. type: Content of: <book><chapter><para>
18336 #: ../en/ch14-hgext.xml:43
18337 msgid ""
18338 "In this chapter, we'll cover some of the other extensions that are available "
18339 "for Mercurial, and briefly touch on some of the machinery you'll need to know "
18340 "about if you want to write an extension of your own."
18341 msgstr ""
18343 #. type: Content of: <book><chapter><itemizedlist><listitem><para>
18344 #: ../en/ch14-hgext.xml:48
18345 msgid ""
18346 "In <xref linkend=\"sec:hgext:inotify\"/>, we'll discuss the possibility of "
18347 "<emphasis>huge</emphasis> performance improvements using the <literal role="
18348 "\"hg-ext\">inotify</literal> extension."
18349 msgstr ""
18351 #. type: Content of: <book><chapter><sect1><title>
18352 #: ../en/ch14-hgext.xml:55
18353 msgid ""
18354 "Improve performance with the <literal role=\"hg-ext\">inotify</literal> "
18355 "extension"
18356 msgstr "使用扩展 <literal role=\"hg-ext\">inotify</literal> 以提高性能"
18358 #. type: Content of: <book><chapter><sect1><para>
18359 #: ../en/ch14-hgext.xml:58
18360 msgid ""
18361 "Are you interested in having some of the most common Mercurial operations run "
18362 "as much as a hundred times faster? Read on!"
18363 msgstr ""
18365 #. type: Content of: <book><chapter><sect1><para>
18366 #: ../en/ch14-hgext.xml:62
18367 msgid ""
18368 "Mercurial has great performance under normal circumstances. For example, "
18369 "when you run the <command role=\"hg-cmd\">hg status</command> command, "
18370 "Mercurial has to scan almost every directory and file in your repository so "
18371 "that it can display file status. Many other Mercurial commands need to do "
18372 "the same work behind the scenes; for example, the <command role=\"hg-cmd\">hg "
18373 "diff</command> command uses the status machinery to avoid doing an expensive "
18374 "comparison operation on files that obviously haven't changed."
18375 msgstr ""
18377 #. type: Content of: <book><chapter><sect1><para>
18378 #: ../en/ch14-hgext.xml:72
18379 msgid ""
18380 "Because obtaining file status is crucial to good performance, the authors of "
18381 "Mercurial have optimised this code to within an inch of its life. However, "
18382 "there's no avoiding the fact that when you run <command role=\"hg-cmd\">hg "
18383 "status</command>, Mercurial is going to have to perform at least one "
18384 "expensive system call for each managed file to determine whether it's changed "
18385 "since the last time Mercurial checked. For a sufficiently large repository, "
18386 "this can take a long time."
18387 msgstr ""
18389 #. type: Content of: <book><chapter><sect1><para>
18390 #: ../en/ch14-hgext.xml:82
18391 msgid ""
18392 "To put a number on the magnitude of this effect, I created a repository "
18393 "containing 150,000 managed files. I timed <command role=\"hg-cmd\">hg "
18394 "status</command> as taking ten seconds to run, even when <emphasis>none</"
18395 "emphasis> of those files had been modified."
18396 msgstr ""
18398 #. type: Content of: <book><chapter><sect1><para>
18399 #: ../en/ch14-hgext.xml:88
18400 msgid ""
18401 "Many modern operating systems contain a file notification facility. If a "
18402 "program signs up to an appropriate service, the operating system will notify "
18403 "it every time a file of interest is created, modified, or deleted. On Linux "
18404 "systems, the kernel component that does this is called <literal>inotify</"
18405 "literal>."
18406 msgstr ""
18408 #. type: Content of: <book><chapter><sect1><para>
18409 #: ../en/ch14-hgext.xml:95
18410 msgid ""
18411 "Mercurial's <literal role=\"hg-ext\">inotify</literal> extension talks to the "
18412 "kernel's <literal>inotify</literal> component to optimise <command role=\"hg-"
18413 "cmd\">hg status</command> commands. The extension has two components. A "
18414 "daemon sits in the background and receives notifications from the "
18415 "<literal>inotify</literal> subsystem. It also listens for connections from a "
18416 "regular Mercurial command. The extension modifies Mercurial's behavior so "
18417 "that instead of scanning the filesystem, it queries the daemon. Since the "
18418 "daemon has perfect information about the state of the repository, it can "
18419 "respond with a result instantaneously, avoiding the need to scan every "
18420 "directory and file in the repository."
18421 msgstr ""
18423 #. type: Content of: <book><chapter><sect1><para>
18424 #: ../en/ch14-hgext.xml:108
18425 msgid ""
18426 "Recall the ten seconds that I measured plain Mercurial as taking to run "
18427 "<command role=\"hg-cmd\">hg status</command> on a 150,000 file repository. "
18428 "With the <literal role=\"hg-ext\">inotify</literal> extension enabled, the "
18429 "time dropped to 0.1 seconds, a factor of <emphasis>one hundred</emphasis> "
18430 "faster."
18431 msgstr ""
18433 #. type: Content of: <book><chapter><sect1><para>
18434 #: ../en/ch14-hgext.xml:115
18435 msgid "Before we continue, please pay attention to some caveats."
18436 msgstr ""
18438 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
18439 #: ../en/ch14-hgext.xml:118
18440 msgid ""
18441 "The <literal role=\"hg-ext\">inotify</literal> extension is Linux-specific. "
18442 "Because it interfaces directly to the Linux kernel's <literal>inotify</"
18443 "literal> subsystem, it does not work on other operating systems."
18444 msgstr ""
18446 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
18447 #: ../en/ch14-hgext.xml:123
18448 msgid ""
18449 "It should work on any Linux distribution that was released after early 2005. "
18450 "Older distributions are likely to have a kernel that lacks <literal>inotify</"
18451 "literal>, or a version of <literal>glibc</literal> that does not have the "
18452 "necessary interfacing support."
18453 msgstr ""
18455 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
18456 #: ../en/ch14-hgext.xml:130
18457 msgid ""
18458 "Not all filesystems are suitable for use with the <literal role=\"hg-ext"
18459 "\">inotify</literal> extension. Network filesystems such as NFS are a non-"
18460 "starter, for example, particularly if you're running Mercurial on several "
18461 "systems, all mounting the same network filesystem. The kernel's "
18462 "<literal>inotify</literal> system has no way of knowing about changes made on "
18463 "another system. Most local filesystems (e.g. ext3, XFS, ReiserFS) should "
18464 "work fine."
18465 msgstr ""
18467 #. type: Content of: <book><chapter><sect1><para>
18468 #: ../en/ch14-hgext.xml:141
18469 msgid ""
18470 "The <literal role=\"hg-ext\">inotify</literal> extension is not yet shipped "
18471 "with Mercurial as of May 2007, so it's a little more involved to set up than "
18472 "other extensions. But the performance improvement is worth it!"
18473 msgstr ""
18475 #. type: Content of: <book><chapter><sect1><para>
18476 #: ../en/ch14-hgext.xml:146
18477 msgid ""
18478 "The extension currently comes in two parts: a set of patches to the Mercurial "
18479 "source code, and a library of Python bindings to the <literal>inotify</"
18480 "literal> subsystem."
18481 msgstr ""
18483 #. type: Content of: <book><chapter><sect1><note><para>
18484 #: ../en/ch14-hgext.xml:150
18485 msgid ""
18486 "There are <emphasis>two</emphasis> Python <literal>inotify</literal> binding "
18487 "libraries. One of them is called <literal>pyinotify</literal>, and is "
18488 "packaged by some Linux distributions as <literal>python-inotify</literal>. "
18489 "This is <emphasis>not</emphasis> the one you'll need, as it is too buggy and "
18490 "inefficient to be practical."
18491 msgstr ""
18493 #. type: Content of: <book><chapter><sect1><para>
18494 #: ../en/ch14-hgext.xml:157
18495 msgid ""
18496 "To get going, it's best to already have a functioning copy of Mercurial "
18497 "installed."
18498 msgstr ""
18500 #. type: Content of: <book><chapter><sect1><note><para>
18501 #: ../en/ch14-hgext.xml:160
18502 msgid ""
18503 "If you follow the instructions below, you'll be <emphasis>replacing</"
18504 "emphasis> and overwriting any existing installation of Mercurial that you "
18505 "might already have, using the latest <quote>bleeding edge</quote> Mercurial "
18506 "code. Don't say you weren't warned!"
18507 msgstr ""
18509 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
18510 #: ../en/ch14-hgext.xml:167
18511 msgid ""
18512 "Clone the Python <literal>inotify</literal> binding repository. Build and "
18513 "install it."
18514 msgstr ""
18516 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
18517 #: ../en/ch14-hgext.xml:174
18518 msgid ""
18519 "Clone the <filename class=\"directory\">crew</filename> Mercurial "
18520 "repository. Clone the <literal role=\"hg-ext\">inotify</literal> patch "
18521 "repository so that Mercurial Queues will be able to apply patches to your "
18522 "cope of the <filename class=\"directory\">crew</filename> repository."
18523 msgstr ""
18525 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
18526 #: ../en/ch14-hgext.xml:184
18527 msgid ""
18528 "Make sure that you have the Mercurial Queues extension, <literal role=\"hg-ext"
18529 "\">mq</literal>, enabled. If you've never used MQ, read <xref linkend=\"sec:"
18530 "mq:start\"/> to get started quickly."
18531 msgstr ""
18533 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
18534 #: ../en/ch14-hgext.xml:190
18535 msgid ""
18536 "Go into the <filename class=\"directory\">inotify</filename> repo, and apply "
18537 "all of the <literal role=\"hg-ext\">inotify</literal> patches using the "
18538 "<option role=\"hg-ext-mq-cmd-qpush-opt\">hg -a</option> option to the "
18539 "<command role=\"hg-ext-mq\">qpush</command> command."
18540 msgstr ""
18542 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
18543 #: ../en/ch14-hgext.xml:199
18544 msgid ""
18545 "If you get an error message from <command role=\"hg-ext-mq\">qpush</command>, "
18546 "you should not continue. Instead, ask for help."
18547 msgstr ""
18549 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
18550 #: ../en/ch14-hgext.xml:203
18551 msgid "Build and install the patched version of Mercurial."
18552 msgstr ""
18554 #. type: Content of: <book><chapter><sect1><para>
18555 #: ../en/ch14-hgext.xml:209
18556 msgid ""
18557 "Once you've build a suitably patched version of Mercurial, all you need to do "
18558 "to enable the <literal role=\"hg-ext\">inotify</literal> extension is add an "
18559 "entry to your <filename role=\"special\">~/.hgrc</filename>."
18560 msgstr ""
18562 #. type: Content of: <book><chapter><sect1><para>
18563 #: ../en/ch14-hgext.xml:214
18564 msgid ""
18565 "When the <literal role=\"hg-ext\">inotify</literal> extension is enabled, "
18566 "Mercurial will automatically and transparently start the status daemon the "
18567 "first time you run a command that needs status in a repository. It runs one "
18568 "status daemon per repository."
18569 msgstr ""
18571 #. type: Content of: <book><chapter><sect1><para>
18572 #: ../en/ch14-hgext.xml:220
18573 msgid ""
18574 "The status daemon is started silently, and runs in the background. If you "
18575 "look at a list of running processes after you've enabled the <literal role="
18576 "\"hg-ext\">inotify</literal> extension and run a few commands in different "
18577 "repositories, you'll thus see a few <literal>hg</literal> processes sitting "
18578 "around, waiting for updates from the kernel and queries from Mercurial."
18579 msgstr ""
18581 #. type: Content of: <book><chapter><sect1><para>
18582 #: ../en/ch14-hgext.xml:228
18583 msgid ""
18584 "The first time you run a Mercurial command in a repository when you have the "
18585 "<literal role=\"hg-ext\">inotify</literal> extension enabled, it will run "
18586 "with about the same performance as a normal Mercurial command. This is "
18587 "because the status daemon needs to perform a normal status scan so that it "
18588 "has a baseline against which to apply later updates from the kernel. "
18589 "However, <emphasis>every</emphasis> subsequent command that does any kind of "
18590 "status check should be noticeably faster on repositories of even fairly "
18591 "modest size. Better yet, the bigger your repository is, the greater a "
18592 "performance advantage you'll see. The <literal role=\"hg-ext\">inotify</"
18593 "literal> daemon makes status operations almost instantaneous on repositories "
18594 "of all sizes!"
18595 msgstr ""
18597 #. type: Content of: <book><chapter><sect1><para>
18598 #: ../en/ch14-hgext.xml:242
18599 msgid ""
18600 "If you like, you can manually start a status daemon using the <command role="
18601 "\"hg-ext-inotify\">inserve</command> command. This gives you slightly finer "
18602 "control over how the daemon ought to run. This command will of course only "
18603 "be available when the <literal role=\"hg-ext\">inotify</literal> extension is "
18604 "enabled."
18605 msgstr ""
18607 #. type: Content of: <book><chapter><sect1><para>
18608 #: ../en/ch14-hgext.xml:249
18609 msgid ""
18610 "When you're using the <literal role=\"hg-ext\">inotify</literal> extension, "
18611 "you should notice <emphasis>no difference at all</emphasis> in Mercurial's "
18612 "behavior, with the sole exception of status-related commands running a whole "
18613 "lot faster than they used to. You should specifically expect that commands "
18614 "will not print different output; neither should they give different results. "
18615 "If either of these situations occurs, please report a bug."
18616 msgstr ""
18618 #. type: Content of: <book><chapter><sect1><title>
18619 #: ../en/ch14-hgext.xml:260
18620 msgid ""
18621 "Flexible diff support with the <literal role=\"hg-ext\">extdiff</literal> "
18622 "extension"
18623 msgstr "使用扩展 <literal role=\"hg-ext\">extdiff</literal> 以扩展差异支持"
18625 #. type: Content of: <book><chapter><sect1><para>
18626 #: ../en/ch14-hgext.xml:263
18627 msgid ""
18628 "Mercurial's built-in <command role=\"hg-cmd\">hg diff</command> command "
18629 "outputs plaintext unified diffs."
18630 msgstr ""
18631 "Mercurial 内置命令 <command role=\"hg-cmd\">hg diff</command> 的输出与统一差异"
18632 "不同。"
18634 #. type: Content of: <book><chapter><sect1><para>
18635 #: ../en/ch14-hgext.xml:268
18636 msgid ""
18637 "If you would like to use an external tool to display modifications, you'll "
18638 "want to use the <literal role=\"hg-ext\">extdiff</literal> extension. This "
18639 "will let you use, for example, a graphical diff tool."
18640 msgstr ""
18642 #. type: Content of: <book><chapter><sect1><para>
18643 #: ../en/ch14-hgext.xml:273
18644 msgid ""
18645 "The <literal role=\"hg-ext\">extdiff</literal> extension is bundled with "
18646 "Mercurial, so it's easy to set up. In the <literal role=\"rc-extensions"
18647 "\">extensions</literal> section of your <filename role=\"special\">~/.hgrc</"
18648 "filename>, simply add a one-line entry to enable the extension."
18649 msgstr ""
18651 #. type: Content of: <book><chapter><sect1><para>
18652 #: ../en/ch14-hgext.xml:280
18653 msgid ""
18654 "This introduces a command named <command role=\"hg-ext-extdiff\">extdiff</"
18655 "command>, which by default uses your system's <command>diff</command> command "
18656 "to generate a unified diff in the same form as the built-in <command role="
18657 "\"hg-cmd\">hg diff</command> command."
18658 msgstr ""
18660 #. type: Content of: <book><chapter><sect1><para>
18661 #: ../en/ch14-hgext.xml:288
18662 msgid ""
18663 "The result won't be exactly the same as with the built-in <command role=\"hg-"
18664 "cmd\">hg diff</command> variations, because the output of <command>diff</"
18665 "command> varies from one system to another, even when passed the same options."
18666 msgstr ""
18668 #. type: Content of: <book><chapter><sect1><para>
18669 #: ../en/ch14-hgext.xml:293
18670 msgid ""
18671 "As the <quote><literal>making snapshot</literal></quote> lines of output "
18672 "above imply, the <command role=\"hg-ext-extdiff\">extdiff</command> command "
18673 "works by creating two snapshots of your source tree. The first snapshot is "
18674 "of the source revision; the second, of the target revision or working "
18675 "directory. The <command role=\"hg-ext-extdiff\">extdiff</command> command "
18676 "generates these snapshots in a temporary directory, passes the name of each "
18677 "directory to an external diff viewer, then deletes the temporary directory. "
18678 "For efficiency, it only snapshots the directories and files that have changed "
18679 "between the two revisions."
18680 msgstr ""
18682 #. type: Content of: <book><chapter><sect1><para>
18683 #: ../en/ch14-hgext.xml:306
18684 msgid ""
18685 "Snapshot directory names have the same base name as your repository. If your "
18686 "repository path is <filename class=\"directory\">/quux/bar/foo</filename>, "
18687 "then <filename class=\"directory\">foo</filename> will be the name of each "
18688 "snapshot directory. Each snapshot directory name has its changeset ID "
18689 "appended, if appropriate. If a snapshot is of revision "
18690 "<literal>a631aca1083f</literal>, the directory will be named <filename class="
18691 "\"directory\">foo.a631aca1083f</filename>. A snapshot of the working "
18692 "directory won't have a changeset ID appended, so it would just be <filename "
18693 "class=\"directory\">foo</filename> in this example. To see what this looks "
18694 "like in practice, look again at the <command role=\"hg-ext-extdiff\">extdiff</"
18695 "command> example above. Notice that the diff has the snapshot directory "
18696 "names embedded in its header."
18697 msgstr ""
18699 #. type: Content of: <book><chapter><sect1><para>
18700 #: ../en/ch14-hgext.xml:322
18701 msgid ""
18702 "The <command role=\"hg-ext-extdiff\">extdiff</command> command accepts two "
18703 "important options. The <option role=\"hg-ext-extdiff-cmd-extdiff-opt\">hg -p</"
18704 "option> option lets you choose a program to view differences with, instead of "
18705 "<command>diff</command>. With the <option role=\"hg-ext-extdiff-cmd-extdiff-"
18706 "opt\">hg -o</option> option, you can change the options that <command role="
18707 "\"hg-ext-extdiff\">extdiff</command> passes to the program (by default, these "
18708 "options are <quote><literal>-Npru</literal></quote>, which only make sense if "
18709 "you're running <command>diff</command>). In other respects, the <command "
18710 "role=\"hg-ext-extdiff\">extdiff</command> command acts similarly to the built-"
18711 "in <command role=\"hg-cmd\">hg diff</command> command: you use the same "
18712 "option names, syntax, and arguments to specify the revisions you want, the "
18713 "files you want, and so on."
18714 msgstr ""
18717 #. type: Content of: <book><chapter><sect1><para>
18718 #: ../en/ch14-hgext.xml:339
18719 msgid ""
18720 "As an example, here's how to run the normal system <command>diff</command> "
18721 "command, getting it to generate context diffs (using the <option role=\"cmd-"
18722 "opt-diff\">-c</option> option) instead of unified diffs, and five lines of "
18723 "context instead of the default three (passing <literal>5</literal> as the "
18724 "argument to the <option role=\"cmd-opt-diff\">-C</option> option)."
18725 msgstr ""
18727 #. type: Content of: <book><chapter><sect1><para>
18728 #: ../en/ch14-hgext.xml:348
18729 msgid ""
18730 "Launching a visual diff tool is just as easy. Here's how to launch the "
18731 "<command>kdiff3</command> viewer."
18732 msgstr ""
18734 #. type: Content of: <book><chapter><sect1><para>
18735 #: ../en/ch14-hgext.xml:352
18736 msgid ""
18737 "If your diff viewing command can't deal with directories, you can easily work "
18738 "around this with a little scripting. For an example of such scripting in "
18739 "action with the <literal role=\"hg-ext\">mq</literal> extension and the "
18740 "<command>interdiff</command> command, see <xref linkend=\"mq-collab:tips:"
18741 "interdiff\"/>."
18742 msgstr ""
18744 #. type: Content of: <book><chapter><sect1><sect2><title>
18745 #: ../en/ch14-hgext.xml:360
18746 msgid "Defining command aliases"
18747 msgstr "定义命令的别名"
18749 #. type: Content of: <book><chapter><sect1><sect2><para>
18750 #: ../en/ch14-hgext.xml:362
18751 msgid ""
18752 "It can be cumbersome to remember the options to both the <command role=\"hg-"
18753 "ext-extdiff\">extdiff</command> command and the diff viewer you want to use, "
18754 "so the <literal role=\"hg-ext\">extdiff</literal> extension lets you define "
18755 "<emphasis>new</emphasis> commands that will invoke your diff viewer with "
18756 "exactly the right options."
18757 msgstr ""
18759 #. type: Content of: <book><chapter><sect1><sect2><para>
18760 #: ../en/ch14-hgext.xml:369
18761 msgid ""
18762 "All you need to do is edit your <filename role=\"special\">~/.hgrc</"
18763 "filename>, and add a section named <literal role=\"rc-extdiff\">extdiff</"
18764 "literal>. Inside this section, you can define multiple commands. Here's how "
18765 "to add a <literal>kdiff3</literal> command. Once you've defined this, you "
18766 "can type <quote><literal>hg kdiff3</literal></quote> and the <literal role="
18767 "\"hg-ext\">extdiff</literal> extension will run <command>kdiff3</command> for "
18768 "you."
18769 msgstr ""
18771 #. type: Content of: <book><chapter><sect1><sect2><para>
18772 #: ../en/ch14-hgext.xml:379
18773 msgid ""
18774 "If you leave the right hand side of the definition empty, as above, the "
18775 "<literal role=\"hg-ext\">extdiff</literal> extension uses the name of the "
18776 "command you defined as the name of the external program to run. But these "
18777 "names don't have to be the same. Here, we define a command named "
18778 "<quote><literal>hg wibble</literal></quote>, which runs <command>kdiff3</"
18779 "command>."
18780 msgstr ""
18782 #. type: Content of: <book><chapter><sect1><sect2><para>
18783 #: ../en/ch14-hgext.xml:389
18784 msgid ""
18785 "You can also specify the default options that you want to invoke your diff "
18786 "viewing program with. The prefix to use is <quote><literal>opts.</literal></"
18787 "quote>, followed by the name of the command to which the options apply. This "
18788 "example defines a <quote><literal>hg vimdiff</literal></quote> command that "
18789 "runs the <command>vim</command> editor's <literal>DirDiff</literal> extension."
18790 msgstr ""
18792 #. type: Content of: <book><chapter><sect1><title>
18793 #: ../en/ch14-hgext.xml:403
18794 msgid ""
18795 "Cherrypicking changes with the <literal role=\"hg-ext\">transplant</literal> "
18796 "extension"
18797 msgstr "使用扩展 <literal role=\"hg-ext\">transplant</literal> 以挑选修改"
18799 #. type: Content of: <book><chapter><sect1><para>
18800 #: ../en/ch14-hgext.xml:406
18801 msgid "Need to have a long chat with Brendan about this."
18802 msgstr ""
18804 #. type: Content of: <book><chapter><sect1><title>
18805 #: ../en/ch14-hgext.xml:410
18806 msgid ""
18807 "Send changes via email with the <literal role=\"hg-ext\">patchbomb</literal> "
18808 "extension"
18809 msgstr ""
18810 "使用扩展 <literal role=\"hg-ext\">patchbomb</literal> 通过 email 发送修改"
18812 #. type: Content of: <book><chapter><sect1><para>
18813 #: ../en/ch14-hgext.xml:413
18814 msgid ""
18815 "Many projects have a culture of <quote>change review</quote>, in which people "
18816 "send their modifications to a mailing list for others to read and comment on "
18817 "before they commit the final version to a shared repository. Some projects "
18818 "have people who act as gatekeepers; they apply changes from other people to a "
18819 "repository to which those others don't have access."
18820 msgstr ""
18822 #. type: Content of: <book><chapter><sect1><para>
18823 #: ../en/ch14-hgext.xml:421
18824 msgid ""
18825 "Mercurial makes it easy to send changes over email for review or application, "
18826 "via its <literal role=\"hg-ext\">patchbomb</literal> extension. The "
18827 "extension is so named because changes are formatted as patches, and it's "
18828 "usual to send one changeset per email message. Sending a long series of "
18829 "changes by email is thus much like <quote>bombing</quote> the recipient's "
18830 "inbox, hence <quote>patchbomb</quote>."
18831 msgstr ""
18833 #. type: Content of: <book><chapter><sect1><para>
18834 #: ../en/ch14-hgext.xml:429
18835 msgid ""
18836 "As usual, the basic configuration of the <literal role=\"hg-ext\">patchbomb</"
18837 "literal> extension takes just one or two lines in your <filename role="
18838 "\"special\"> /.hgrc</filename>."
18839 msgstr ""
18841 #. type: Content of: <book><chapter><sect1><para>
18842 #: ../en/ch14-hgext.xml:435
18843 msgid ""
18844 "Once you've enabled the extension, you will have a new command available, "
18845 "named <command role=\"hg-ext-patchbomb\">email</command>."
18846 msgstr ""
18848 #. type: Content of: <book><chapter><sect1><para>
18849 #: ../en/ch14-hgext.xml:439
18850 msgid ""
18851 "The safest and best way to invoke the <command role=\"hg-ext-patchbomb"
18852 "\">email</command> command is to <emphasis>always</emphasis> run it first "
18853 "with the <option role=\"hg-ext-patchbomb-cmd-email-opt\">hg -n</option> "
18854 "option. This will show you what the command <emphasis>would</emphasis> send, "
18855 "without actually sending anything. Once you've had a quick glance over the "
18856 "changes and verified that you are sending the right ones, you can rerun the "
18857 "same command, with the <option role=\"hg-ext-patchbomb-cmd-email-opt\">hg -n</"
18858 "option> option removed."
18859 msgstr ""
18861 #. type: Content of: <book><chapter><sect1><para>
18862 #: ../en/ch14-hgext.xml:450
18863 msgid ""
18864 "The <command role=\"hg-ext-patchbomb\">email</command> command accepts the "
18865 "same kind of revision syntax as every other Mercurial command. For example, "
18866 "this command will send every revision between 7 and <literal>tip</literal>, "
18867 "inclusive."
18868 msgstr ""
18870 #. type: Content of: <book><chapter><sect1><para>
18871 #: ../en/ch14-hgext.xml:455
18872 msgid ""
18873 "You can also specify a <emphasis>repository</emphasis> to compare with. If "
18874 "you provide a repository but no revisions, the <command role=\"hg-ext-"
18875 "patchbomb\">email</command> command will send all revisions in the local "
18876 "repository that are not present in the remote repository. If you "
18877 "additionally specify revisions or a branch name (the latter using the <option "
18878 "role=\"hg-ext-patchbomb-cmd-email-opt\">hg -b</option> option), this will "
18879 "constrain the revisions sent."
18880 msgstr ""
18882 #. type: Content of: <book><chapter><sect1><para>
18883 #: ../en/ch14-hgext.xml:464
18884 msgid ""
18885 "It's perfectly safe to run the <command role=\"hg-ext-patchbomb\">email</"
18886 "command> command without the names of the people you want to send to: if you "
18887 "do this, it will just prompt you for those values interactively. (If you're "
18888 "using a Linux or Unix-like system, you should have enhanced "
18889 "<literal>readline</literal>-style editing capabilities when entering those "
18890 "headers, too, which is useful.)"
18891 msgstr ""
18893 #. type: Content of: <book><chapter><sect1><para>
18894 #: ../en/ch14-hgext.xml:472
18895 msgid ""
18896 "When you are sending just one revision, the <command role=\"hg-ext-patchbomb"
18897 "\">email</command> command will by default use the first line of the "
18898 "changeset description as the subject of the single email message it sends."
18899 msgstr ""
18901 #. type: Content of: <book><chapter><sect1><para>
18902 #: ../en/ch14-hgext.xml:477
18903 msgid ""
18904 "If you send multiple revisions, the <command role=\"hg-ext-patchbomb\">email</"
18905 "command> command will usually send one message per changeset. It will "
18906 "preface the series with an introductory message, in which you should describe "
18907 "the purpose of the series of changes you're sending."
18908 msgstr ""
18910 #. type: Content of: <book><chapter><sect1><sect2><title>
18911 #: ../en/ch14-hgext.xml:484
18912 msgid "Changing the behavior of patchbombs"
18913 msgstr "修改 patchbomb 的行为"
18915 #. type: Content of: <book><chapter><sect1><sect2><para>
18916 #: ../en/ch14-hgext.xml:486
18917 msgid ""
18918 "Not every project has exactly the same conventions for sending changes in "
18919 "email; the <literal role=\"hg-ext\">patchbomb</literal> extension tries to "
18920 "accommodate a number of variations through command line options."
18921 msgstr ""
18923 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
18924 #: ../en/ch14-hgext.xml:492
18925 msgid ""
18926 "You can write a subject for the introductory message on the command line "
18927 "using the <option role=\"hg-ext-patchbomb-cmd-email-opt\">hg -s</option> "
18928 "option. This takes one argument, the text of the subject to use."
18929 msgstr ""
18931 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
18932 #: ../en/ch14-hgext.xml:498
18933 msgid ""
18934 "To change the email address from which the messages originate, use the "
18935 "<option role=\"hg-ext-patchbomb-cmd-email-opt\">hg -f</option> option. This "
18936 "takes one argument, the email address to use."
18937 msgstr ""
18939 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
18940 #: ../en/ch14-hgext.xml:504
18941 msgid ""
18942 "The default behavior is to send unified diffs (see <xref linkend=\"sec:mq:"
18943 "patch\"/> for a description of the format), one per message. You can send a "
18944 "binary bundle instead with the <option role=\"hg-ext-patchbomb-cmd-email-opt"
18945 "\">hg -b</option> option."
18946 msgstr ""
18948 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
18949 #: ../en/ch14-hgext.xml:512
18950 msgid ""
18951 "Unified diffs are normally prefaced with a metadata header. You can omit "
18952 "this, and send unadorned diffs, with the <option role=\"hg-ext-patchbomb-cmd-"
18953 "email-opt\">hg --plain</option> option."
18954 msgstr ""
18956 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
18957 #: ../en/ch14-hgext.xml:518
18958 msgid ""
18959 "Diffs are normally sent <quote>inline</quote>, in the same body part as the "
18960 "description of a patch. This makes it easiest for the largest number of "
18961 "readers to quote and respond to parts of a diff, as some mail clients will "
18962 "only quote the first MIME body part in a message. If you'd prefer to send the "
18963 "description and the diff in separate body parts, use the <option role=\"hg-"
18964 "ext-patchbomb-cmd-email-opt\">hg -a</option> option."
18965 msgstr ""
18967 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
18968 #: ../en/ch14-hgext.xml:528
18969 msgid ""
18970 "Instead of sending mail messages, you can write them to an <literal>mbox</"
18971 "literal>-format mail folder using the <option role=\"hg-ext-patchbomb-cmd-"
18972 "email-opt\">hg -m</option> option. That option takes one argument, the name "
18973 "of the file to write to."
18974 msgstr ""
18976 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
18977 #: ../en/ch14-hgext.xml:535
18978 msgid ""
18979 "If you would like to add a <command>diffstat</command>-format summary to each "
18980 "patch, and one to the introductory message, use the <option role=\"hg-ext-"
18981 "patchbomb-cmd-email-opt\">hg -d</option> option. The <command>diffstat</"
18982 "command> command displays a table containing the name of each file patched, "
18983 "the number of lines affected, and a histogram showing how much each file is "
18984 "modified. This gives readers a qualitative glance at how complex a patch is."
18985 msgstr ""