hgbook

view po/zh.po @ 1062:deb518e1baeb

1.8 3th para zh translated
author zhaopingsun
date Wed Nov 11 08:41:23 2009 -0500 (2009-11-11)
parents 825259963afd
children 1cd77eb65a20
line source
1 #
2 # Simplified Chinese translation for hgbook
3 # This file is distributed under the same license as the hgbook.
4 #
5 # Authors:
6 # Dongsheng Song <dongsheng.song@gmail.com>, 2009
7 #
8 # Check translation:
9 # msgfmt --statistics -c -o zh.mo zh.po
10 #
11 # Please format your translation before commit:
12 # msgcat --sort-by-file --width=80 -o zh_new.po zh.po
13 # mv -f zh_new.po zh.po
14 #
15 # Dictionary:
16 # blame 追溯
17 # branch 分支
18 # changes 修改
19 # changeset 修改集
20 # checkout 检出
21 # remove 移除(从版本库删除)
22 # delete 删除(只从文件系统删除)
23 # filelog 文件日志
24 # patchset 补丁集
25 # pushing to 推到
26 # pulling from 拉自,抓取
27 # rename 改名
28 # repository 版本库
29 # revert 恢复
30 # revision 版本
31 # revlog 版本日志
32 # tag 标签
33 # tip 顶点
34 # undo 撤销
35 # unversioned 未版本控制
36 # updated 更新到,同步到(适用于旧版本)
37 # versioned 受版本控制
38 # working copy 工作副本
39 # ...
40 #
41 msgid ""
42 msgstr ""
43 "Project-Id-Version: hgbook 1.2\n"
44 "POT-Creation-Date: 2009-11-04 14:06+0800\n"
45 "PO-Revision-Date: 2009-10-21 16:42+0800\n"
46 "Last-Translator: 宋冬生 <songdonogsheng@live.cn>\n"
47 "Language-Team: Simplified Chinese <i18n-zh@googlegroups.com >\n"
48 "MIME-Version: 1.0\n"
49 "Content-Type: text/plain; charset=UTF-8\n"
50 "Content-Transfer-Encoding: 8bit\n"
51 "X-Poedit-Language: Chinese\n"
52 "X-Poedit-Country: CHINA\n"
53 "X-Poedit-SourceCharset: utf-8\n"
55 #. type: Content of: <book><title>
56 #: ../en/00book.xml:42
57 msgid "Mercurial: The Definitive Guide"
58 msgstr "Mercurial 权威指南"
60 #. type: Content of: <book><subtitle>
61 #: ../en/00book.xml:47
62 msgid "Compiled from $rev_id$"
63 msgstr "编译自 $rev_id$"
65 #. type: Content of: <book><bookinfo>
66 #: ../en/00book.xml:49
67 msgid "<edition>1</edition> <isbn>9780596800673</isbn>"
68 msgstr "<edition>1</edition> <isbn>9780596800673</isbn>"
70 #. type: Content of: <book><bookinfo><authorgroup><author><firstname>
71 #: ../en/00book.xml:53
72 msgid "Bryan"
73 msgstr "Bryan"
75 #. type: Content of: <book><bookinfo><authorgroup><author><surname>
76 #: ../en/00book.xml:54
77 msgid "O'Sullivan"
78 msgstr "O'Sullivan"
80 #. type: Content of: <book><bookinfo>
81 #: ../en/00book.xml:58
82 msgid ""
83 "<editor> <firstname>Mike</firstname> <surname>Loukides</surname> </editor> "
84 "<copyright> <year>2006</year> <year>2007</year> <year>2008</year> <year>2009</"
85 "year> <holder>Bryan O'Sullivan</holder> </copyright>"
86 msgstr ""
87 "<editor> <firstname>Mike</firstname> <surname>Loukides</surname> </editor> "
88 "<copyright> <year>2006</year> <year>2007</year> <year>2008</year> <year>2009</"
89 "year> <holder>Bryan O'Sullivan</holder> </copyright>"
91 #. type: Content of: <book><appendix><title>
92 #: ../en/appA-svn.xml:5
93 msgid "Migrating to Mercurial"
94 msgstr "迁移到 Mercurial"
96 #. type: Content of: <book><appendix><para>
97 #: ../en/appA-svn.xml:7
98 msgid ""
99 "A common way to test the waters with a new revision control tool is to "
100 "experiment with switching an existing project, rather than starting a new "
101 "project from scratch."
102 msgstr ""
104 #. type: Content of: <book><appendix><para>
105 #: ../en/appA-svn.xml:11
106 msgid ""
107 "In this appendix, we discuss how to import a project's history into "
108 "Mercurial, and what to look out for if you are used to a different revision "
109 "control system."
110 msgstr ""
112 #. type: Content of: <book><appendix><sect1><title>
113 #: ../en/appA-svn.xml:16
114 msgid "Importing history from another system"
115 msgstr "从其它版本控制系统导入历史"
117 #. type: Content of: <book><appendix><sect1><para>
118 #: ../en/appA-svn.xml:18
119 msgid ""
120 "Mercurial ships with an extension named <literal>convert</literal>, which can "
121 "import project history from most popular revision control systems. At the "
122 "time this book was written, it could import history from the following "
123 "systems:"
124 msgstr ""
126 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><thead><row><entry>
127 #: ../en/appA-svn.xml:25 ../en/appA-svn.xml:369 ../en/ch01-intro.xml:416
128 #: ../en/ch01-intro.xml:627
129 msgid "Subversion"
130 msgstr "Subversion"
132 #. type: Content of: <book><appendix><sect1><itemizedlist><listitem><para>
133 #: ../en/appA-svn.xml:28 ../en/ch01-intro.xml:532 ../en/ch01-intro.xml:628
134 msgid "CVS"
135 msgstr "CVS"
137 #. type: Content of: <book><appendix><sect1><itemizedlist><listitem><para>
138 #: ../en/appA-svn.xml:31
139 msgid "git"
140 msgstr "git"
142 #. type: Content of: <book><appendix><sect1><itemizedlist><listitem><para>
143 #: ../en/appA-svn.xml:34 ../en/ch01-intro.xml:630
144 msgid "Darcs"
145 msgstr "Darcs"
147 #. type: Content of: <book><appendix><sect1><itemizedlist><listitem><para>
148 #: ../en/appA-svn.xml:37
149 msgid "Bazaar"
150 msgstr "Bazaar"
152 #. type: Content of: <book><appendix><sect1><itemizedlist><listitem><para>
153 #: ../en/appA-svn.xml:40
154 msgid "Monotone"
155 msgstr "Monotone"
157 #. type: Content of: <book><appendix><sect1><itemizedlist><listitem><para>
158 #: ../en/appA-svn.xml:43
159 msgid "GNU Arch"
160 msgstr "GNU Arch"
162 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><thead><row><entry>
163 #: ../en/appA-svn.xml:46 ../en/appA-svn.xml:370
164 msgid "Mercurial"
165 msgstr "Mercurial"
167 #. type: Content of: <book><appendix><sect1><para>
168 #: ../en/appA-svn.xml:50
169 msgid ""
170 "(To see why Mercurial itself is supported as a source, see <xref linkend="
171 "\"svn.filemap\"/>.)"
172 msgstr ""
174 #. type: Content of: <book><appendix><sect1><para>
175 #: ../en/appA-svn.xml:53
176 msgid ""
177 "You can enable the extension in the usual way, by editing your <filename>~/."
178 "hgrc</filename> file."
179 msgstr ""
180 "你可以通过常用的方式,编辑<filename>~./hgrc</filename>文件来使用这个扩展。"
182 #. type: Content of: <book><appendix><sect1><para>
183 #: ../en/appA-svn.xml:59
184 msgid ""
185 "This will make a <command>hg convert</command> command available. The "
186 "command is easy to use. For instance, this command will import the "
187 "Subversion history for the Nose unit testing framework into Mercurial."
188 msgstr ""
190 #. type: Content of: <book><appendix><sect1><screen><prompt>
191 #: ../en/appA-svn.xml:64 ../en/appA-svn.xml:207 ../en/appA-svn.xml:212
192 #: ../en/appA-svn.xml:213 ../en/appA-svn.xml:218 ../en/appA-svn.xml:224
193 #: ../en/appA-svn.xml:229 ../en/appA-svn.xml:532
194 msgid "$"
195 msgstr "$"
197 #. type: Content of: <book><appendix><sect1><screen><userinput>
198 #: ../en/appA-svn.xml:64
199 msgid "hg convert http://python-nose.googlecode.com/svn/trunk"
200 msgstr ""
202 #. type: Content of: <book><appendix><sect1><para>
203 #: ../en/appA-svn.xml:66
204 msgid ""
205 "The <literal>convert</literal> extension operates incrementally. In other "
206 "words, after you have run <command>hg convert</command> once, running it "
207 "again will import any new revisions committed after the first run began. "
208 "Incremental conversion will only work if you run <command>hg convert</"
209 "command> in the same Mercurial repository that you originally used, because "
210 "the <literal>convert</literal> extension saves some private metadata in a non-"
211 "revision-controlled file named <filename>.hg/shamap</filename> inside the "
212 "target repository."
213 msgstr ""
215 #. type: Content of: <book><appendix><sect1><para>
216 #: ../en/appA-svn.xml:78
217 msgid ""
218 "When you want to start making changes using Mercurial, it's best to clone the "
219 "tree in which you are doing your conversions, and leave the original tree for "
220 "future incremental conversions. This is the safest way to let you pull and "
221 "merge future commits from the source revision control system into your newly "
222 "active Mercurial project."
223 msgstr ""
225 #. type: Content of: <book><appendix><sect1><sect2><title>
226 #: ../en/appA-svn.xml:86
227 msgid "Converting multiple branches"
228 msgstr "转换多个分支"
230 #. type: Content of: <book><appendix><sect1><sect2><para>
231 #: ../en/appA-svn.xml:88
232 msgid ""
233 "The <command>hg convert</command> command given above converts only the "
234 "history of the <literal>trunk</literal> branch of the Subversion repository. "
235 "If we instead use the URL <literal>http://python-nose.googlecode.com/svn</"
236 "literal>, Mercurial will automatically detect the <literal>trunk</literal>, "
237 "<literal>tags</literal> and <literal>branches</literal> layout that "
238 "Subversion projects usually use, and it will import each as a separate "
239 "Mercurial branch."
240 msgstr ""
242 #. type: Content of: <book><appendix><sect1><sect2><para>
243 #: ../en/appA-svn.xml:98
244 msgid ""
245 "By default, each Subversion branch imported into Mercurial is given a branch "
246 "name. After the conversion completes, you can get a list of the active "
247 "branch names in the Mercurial repository using <command>hg branches -a</"
248 "command>. If you would prefer to import the Subversion branches without "
249 "names, pass the <option>--config convert.hg.usebranchnames=false</option> "
250 "option to <command>hg convert</command>."
251 msgstr ""
253 #. type: Content of: <book><appendix><sect1><sect2><para>
254 #: ../en/appA-svn.xml:107
255 msgid ""
256 "Once you have converted your tree, if you want to follow the usual Mercurial "
257 "practice of working in a tree that contains a single branch, you can clone "
258 "that single branch using <command>hg clone -r mybranchname</command>."
259 msgstr ""
261 #. type: Content of: <book><appendix><sect1><sect2><title>
262 #: ../en/appA-svn.xml:114
263 msgid "Mapping user names"
264 msgstr "映射用户名称"
266 #. type: Content of: <book><appendix><sect1><sect2><para>
267 #: ../en/appA-svn.xml:116
268 msgid ""
269 "Some revision control tools save only short usernames with commits, and these "
270 "can be difficult to interpret. The norm with Mercurial is to save a "
271 "committer's name and email address, which is much more useful for talking to "
272 "them after the fact."
273 msgstr ""
275 #. type: Content of: <book><appendix><sect1><sect2><para>
276 #: ../en/appA-svn.xml:122
277 msgid ""
278 "If you are converting a tree from a revision control system that uses short "
279 "names, you can map those names to longer equivalents by passing a <option>--"
280 "authors</option> option to <command>hg convert</command>. This option "
281 "accepts a file name that should contain entries of the following form."
282 msgstr ""
284 #. type: Content of: <book><appendix><sect1><sect2><para>
285 #: ../en/appA-svn.xml:132
286 msgid ""
287 "Whenever <literal>convert</literal> encounters a commit with the username "
288 "<literal>arist</literal> in the source repository, it will use the name "
289 "<literal>Aristotle &lt;aristotle@phil.example.gr&gt;</literal> in the "
290 "converted Mercurial revision. If no match is found for a name, it is used "
291 "verbatim."
292 msgstr ""
294 #. type: Content of: <book><appendix><sect1><sect2><title>
295 #: ../en/appA-svn.xml:141
296 msgid "Tidying up the tree"
297 msgstr "清理目录树"
299 #. type: Content of: <book><appendix><sect1><sect2><para>
300 #: ../en/appA-svn.xml:143
301 msgid ""
302 "Not all projects have pristine history. There may be a directory that should "
303 "never have been checked in, a file that is too big, or a whole hierarchy that "
304 "needs to be refactored."
305 msgstr ""
307 #. type: Content of: <book><appendix><sect1><sect2><para>
308 #: ../en/appA-svn.xml:148
309 msgid ""
310 "The <literal>convert</literal> extension supports the idea of a <quote>file "
311 "map</quote> that can reorganize the files and directories in a project as it "
312 "imports the project's history. This is useful not only when importing "
313 "history from other revision control systems, but also to prune or refactor a "
314 "Mercurial tree."
315 msgstr ""
317 #. type: Content of: <book><appendix><sect1><sect2><para>
318 #: ../en/appA-svn.xml:155
319 msgid ""
320 "To specify a file map, use the <option>--filemap</option> option and supply a "
321 "file name. A file map contains lines of the following forms."
322 msgstr ""
324 #. type: Content of: <book><appendix><sect1><sect2><para>
325 #: ../en/appA-svn.xml:169
326 msgid ""
327 "The <literal>include</literal> directive causes a file, or all files under a "
328 "directory, to be included in the destination repository. This also excludes "
329 "all other files and dirs not explicitely included. The <literal>exclude</"
330 "literal> directive causes files or directories to be omitted, and others not "
331 "explicitly mentioned to be included."
332 msgstr ""
334 #. type: Content of: <book><appendix><sect1><sect2><para>
335 #: ../en/appA-svn.xml:176
336 msgid ""
337 "To move a file or directory from one location to another, use the "
338 "<literal>rename</literal> directive. If you need to move a file or directory "
339 "from a subdirectory into the root of the repository, use <literal>.</literal> "
340 "as the second argument to the <literal>rename</literal> directive."
341 msgstr ""
343 #. type: Content of: <book><appendix><sect1><sect2><title>
344 #: ../en/appA-svn.xml:184
345 msgid "Improving Subversion conversion performance"
346 msgstr "改进 Subversion 的转换性能"
348 #. type: Content of: <book><appendix><sect1><sect2><para>
349 #: ../en/appA-svn.xml:186
350 msgid ""
351 "You will often need several attempts before you hit the perfect combination "
352 "of user map, file map, and other conversion parameters. Converting a "
353 "Subversion repository over an access protocol like <literal>ssh</literal> or "
354 "<literal>http</literal> can proceed thousands of times more slowly than "
355 "Mercurial is capable of actually operating, due to network delays. This can "
356 "make tuning that perfect conversion recipe very painful."
357 msgstr ""
359 #. type: Content of: <book><appendix><sect1><sect2><para>
360 #: ../en/appA-svn.xml:195
361 msgid ""
362 "The <ulink url=\"http://svn.collab.net/repos/svn/trunk/notes/svnsync.txt"
363 "\"><command>svnsync</command></ulink> command can greatly speed up the "
364 "conversion of a Subversion repository. It is a read-only mirroring program "
365 "for Subversion repositories. The idea is that you create a local mirror of "
366 "your Subversion tree, then convert the mirror into a Mercurial repository."
367 msgstr ""
369 #. type: Content of: <book><appendix><sect1><sect2><para>
370 #: ../en/appA-svn.xml:203
371 msgid ""
372 "Suppose we want to convert the Subversion repository for the popular "
373 "Memcached project into a Mercurial tree. First, we create a local Subversion "
374 "repository."
375 msgstr ""
377 #. type: Content of: <book><appendix><sect1><sect2><screen><userinput>
378 #: ../en/appA-svn.xml:207
379 msgid "svnadmin create memcached-mirror"
380 msgstr "svnadmin create memcached-mirror"
382 #. type: Content of: <book><appendix><sect1><sect2><para>
383 #: ../en/appA-svn.xml:209
384 msgid "Next, we set up a Subversion hook that <command>svnsync</command> needs."
385 msgstr ""
387 #. type: Content of: <book><appendix><sect1><sect2><screen><userinput>
388 #: ../en/appA-svn.xml:212
389 msgid "echo '#!/bin/sh' > memcached-mirror/hooks/pre-revprop-change"
390 msgstr "echo '#!/bin/sh' > memcached-mirror/hooks/pre-revprop-change"
392 #. type: Content of: <book><appendix><sect1><sect2><screen><userinput>
393 #: ../en/appA-svn.xml:213
394 msgid "chmod +x memcached-mirror/hooks/pre-revprop-change"
395 msgstr "chmod +x memcached-mirror/hooks/pre-revprop-change"
397 #. type: Content of: <book><appendix><sect1><sect2><para>
398 #: ../en/appA-svn.xml:215
399 msgid "We then initialize <command>svnsync</command> in this repository."
400 msgstr ""
402 #. type: Content of: <book><appendix><sect1><sect2><screen><userinput>
403 #: ../en/appA-svn.xml:218
404 msgid ""
405 "svnsync --init file://`pwd`/memcached-mirror \\ http://code.sixapart.com/svn/"
406 "memcached"
407 msgstr ""
408 "svnsync --init file://`pwd`/memcached-mirror \\ http://code.sixapart.com/svn/"
409 "memcached"
411 #. type: Content of: <book><appendix><sect1><sect2><para>
412 #: ../en/appA-svn.xml:221
413 msgid ""
414 "Our next step is to begin the <command>svnsync</command> mirroring process."
415 msgstr ""
417 #. type: Content of: <book><appendix><sect1><sect2><screen><userinput>
418 #: ../en/appA-svn.xml:224
419 msgid "svnsync sync file://`pwd`/memcached-mirror"
420 msgstr "svnsync sync file://`pwd`/memcached-mirror"
422 #. type: Content of: <book><appendix><sect1><sect2><para>
423 #: ../en/appA-svn.xml:226
424 msgid ""
425 "Finally, we import the history of our local Subversion mirror into Mercurial."
426 msgstr ""
428 #. type: Content of: <book><appendix><sect1><sect2><screen><userinput>
429 #: ../en/appA-svn.xml:229
430 msgid "hg convert memcached-mirror"
431 msgstr ""
433 #. type: Content of: <book><appendix><sect1><sect2><para>
434 #: ../en/appA-svn.xml:231
435 msgid ""
436 "We can use this process incrementally if the Subversion repository is still "
437 "in use. We run <command>svnsync</command> to pull new changes into our "
438 "mirror, then <command>hg convert</command> to import them into our Mercurial "
439 "tree."
440 msgstr ""
442 #. type: Content of: <book><appendix><sect1><sect2><para>
443 #: ../en/appA-svn.xml:237
444 msgid ""
445 "There are two advantages to doing a two-stage import with <command>svnsync</"
446 "command>. The first is that it uses more efficient Subversion network "
447 "syncing code than <command>hg convert</command>, so it transfers less data "
448 "over the network. The second is that the import from a local Subversion tree "
449 "is so fast that you can tweak your conversion setup repeatedly without having "
450 "to sit through a painfully slow network-based conversion process each time."
451 msgstr ""
453 #. type: Content of: <book><appendix><sect1><title>
454 #: ../en/appA-svn.xml:249
455 msgid "Migrating from Subversion"
456 msgstr "从 Subversion 迁移"
458 #. type: Content of: <book><appendix><sect1><para>
459 #: ../en/appA-svn.xml:251
460 msgid ""
461 "Subversion is currently the most popular open source revision control system. "
462 "Although there are many differences between Mercurial and Subversion, making "
463 "the transition from Subversion to Mercurial is not particularly difficult. "
464 "The two have similar command sets and generally uniform interfaces."
465 msgstr ""
467 #. type: Content of: <book><appendix><sect1><sect2><title>
468 #: ../en/appA-svn.xml:259
469 msgid "Philosophical differences"
470 msgstr "哲学的差别"
472 #. type: Content of: <book><appendix><sect1><sect2><para>
473 #: ../en/appA-svn.xml:261
474 msgid ""
475 "The fundamental difference between Subversion and Mercurial is of course that "
476 "Subversion is centralized, while Mercurial is distributed. Since Mercurial "
477 "stores all of a project's history on your local drive, it only needs to "
478 "perform a network access when you want to explicitly communicate with another "
479 "repository. In contrast, Subversion stores very little information locally, "
480 "and the client must thus contact its server for many common operations."
481 msgstr ""
483 #. type: Content of: <book><appendix><sect1><sect2><para>
484 #: ../en/appA-svn.xml:270
485 msgid ""
486 "Subversion more or less gets away without a well-defined notion of a branch: "
487 "which portion of a server's namespace qualifies as a branch is a matter of "
488 "convention, with the software providing no enforcement. Mercurial treats a "
489 "repository as the unit of branch management."
490 msgstr ""
492 #. type: Content of: <book><appendix><sect1><sect2><sect3><title>
493 #: ../en/appA-svn.xml:277
494 msgid "Scope of commands"
495 msgstr "命令作用域"
497 #. type: Content of: <book><appendix><sect1><sect2><sect3><para>
498 #: ../en/appA-svn.xml:279
499 msgid ""
500 "Since Subversion doesn't know what parts of its namespace are really "
501 "branches, it treats most commands as requests to operate at and below "
502 "whatever directory you are currently visiting. For instance, if you run "
503 "<command>svn log</command>, you'll get the history of whatever part of the "
504 "tree you're looking at, not the tree as a whole."
505 msgstr ""
507 #. type: Content of: <book><appendix><sect1><sect2><sect3><para>
508 #: ../en/appA-svn.xml:286
509 msgid ""
510 "Mercurial's commands behave differently, by defaulting to operating over an "
511 "entire repository. Run <command>hg log</command> and it will tell you the "
512 "history of the entire tree, no matter what part of the working directory "
513 "you're visiting at the time. If you want the history of just a particular "
514 "file or directory, simply supply it by name, e.g. <command>hg log src</"
515 "command>."
516 msgstr ""
518 #. type: Content of: <book><appendix><sect1><sect2><sect3><para>
519 #: ../en/appA-svn.xml:294
520 msgid ""
521 "From my own experience, this difference in default behaviors is probably the "
522 "most likely to trip you up if you have to switch back and forth frequently "
523 "between the two tools."
524 msgstr ""
526 #. type: Content of: <book><appendix><sect1><sect2><sect3><title>
527 #: ../en/appA-svn.xml:301
528 msgid "Multi-user operation and safety"
529 msgstr "多用户操作与安全"
531 #. type: Content of: <book><appendix><sect1><sect2><sect3><para>
532 #: ../en/appA-svn.xml:303
533 msgid ""
534 "With Subversion, it is normal (though slightly frowned upon) for multiple "
535 "people to collaborate in a single branch. If Alice and Bob are working "
536 "together, and Alice commits some changes to their shared branch, Bob must "
537 "update his client's view of the branch before he can commit. Since at this "
538 "time he has no permanent record of the changes he has made, he can corrupt or "
539 "lose his modifications during and after his update."
540 msgstr ""
542 #. type: Content of: <book><appendix><sect1><sect2><sect3><para>
543 #: ../en/appA-svn.xml:312
544 msgid ""
545 "Mercurial encourages a commit-then-merge model instead. Bob commits his "
546 "changes locally before pulling changes from, or pushing them to, the server "
547 "that he shares with Alice. If Alice pushed her changes before Bob tries to "
548 "push his, he will not be able to push his changes until he pulls hers, merges "
549 "with them, and commits the result of the merge. If he makes a mistake during "
550 "the merge, he still has the option of reverting to the commit that recorded "
551 "his changes."
552 msgstr ""
554 #. type: Content of: <book><appendix><sect1><sect2><sect3><para>
555 #: ../en/appA-svn.xml:321
556 msgid ""
557 "It is worth emphasizing that these are the common ways of working with these "
558 "tools. Subversion supports a safer work-in-your-own-branch model, but it is "
559 "cumbersome enough in practice to not be widely used. Mercurial can support "
560 "the less safe mode of allowing changes to be pulled in and merged on top of "
561 "uncommitted edits, but this is considered highly unusual."
562 msgstr ""
564 #. type: Content of: <book><appendix><sect1><sect2><sect3><title>
565 #: ../en/appA-svn.xml:331
566 msgid "Published vs local changes"
567 msgstr "已发布的修改与本地修改"
569 #. type: Content of: <book><appendix><sect1><sect2><sect3><para>
570 #: ../en/appA-svn.xml:333
571 msgid ""
572 "A Subversion <command>svn commit</command> command immediately publishes "
573 "changes to a server, where they can be seen by everyone who has read access."
574 msgstr ""
576 #. type: Content of: <book><appendix><sect1><sect2><sect3><para>
577 #: ../en/appA-svn.xml:337
578 msgid ""
579 "With Mercurial, commits are always local, and must be published via a "
580 "<command>hg push</command> command afterwards."
581 msgstr ""
583 #. type: Content of: <book><appendix><sect1><sect2><sect3><para>
584 #: ../en/appA-svn.xml:341
585 msgid ""
586 "Each approach has its advantages and disadvantages. The Subversion model "
587 "means that changes are published, and hence reviewable and usable, "
588 "immediately. On the other hand, this means that a user must have commit "
589 "access to a repository in order to use the software in a normal way, and "
590 "commit access is not lightly given out by most open source projects."
591 msgstr ""
593 #. type: Content of: <book><appendix><sect1><sect2><sect3><para>
594 #: ../en/appA-svn.xml:349
595 msgid ""
596 "The Mercurial approach allows anyone who can clone a repository to commit "
597 "changes without the need for someone else's permission, and they can then "
598 "publish their changes and continue to participate however they see fit. The "
599 "distinction between committing and pushing does open up the possibility of "
600 "someone committing changes to their laptop and walking away for a few days "
601 "having forgotten to push them, which in rare cases might leave collaborators "
602 "temporarily stuck."
603 msgstr ""
605 #. type: Content of: <book><appendix><sect1><sect2><title>
606 #: ../en/appA-svn.xml:362
607 msgid "Quick reference"
608 msgstr "快速参考"
610 #. type: Content of: <book><appendix><sect1><sect2><table><title>
611 #: ../en/appA-svn.xml:365
612 msgid "Subversion commands and Mercurial equivalents"
613 msgstr "Subversion 命令与 Mercurial 对照表"
615 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><thead><row><entry>
616 #: ../en/appA-svn.xml:371
617 msgid "Notes"
618 msgstr "备注"
620 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
621 #: ../en/appA-svn.xml:376
622 msgid "<command>svn add</command>"
623 msgstr "<command>svn add</command>"
625 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
626 #: ../en/appA-svn.xml:377
627 msgid "<command>hg add</command>"
628 msgstr "<command>hg add</command>"
630 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
631 #: ../en/appA-svn.xml:381
632 msgid "<command>svn blame</command>"
633 msgstr "<command>svn blame</command>"
635 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
636 #: ../en/appA-svn.xml:382
637 msgid "<command>hg annotate</command>"
638 msgstr "<command>hg annotate</command>"
640 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
641 #: ../en/appA-svn.xml:386
642 msgid "<command>svn cat</command>"
643 msgstr "<command>svn cat</command>"
645 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
646 #: ../en/appA-svn.xml:387
647 msgid "<command>hg cat</command>"
648 msgstr "<command>hg cat</command>"
650 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
651 #: ../en/appA-svn.xml:391
652 msgid "<command>svn checkout</command>"
653 msgstr "<command>svn checkout</command>"
655 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
656 #: ../en/appA-svn.xml:392 ../en/appA-svn.xml:409
657 msgid "<command>hg clone</command>"
658 msgstr "<command>hg clone</command>"
660 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
661 #: ../en/appA-svn.xml:396
662 msgid "<command>svn cleanup</command>"
663 msgstr "<command>svn cleanup</command>"
665 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
666 #: ../en/appA-svn.xml:397 ../en/appA-svn.xml:472
667 msgid "n/a"
668 msgstr "n/a"
670 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
671 #: ../en/appA-svn.xml:398
672 msgid "No cleanup needed"
673 msgstr "不需要清理"
675 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
676 #: ../en/appA-svn.xml:401
677 msgid "<command>svn commit</command>"
678 msgstr "<command>svn commit</command>"
680 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
681 #: ../en/appA-svn.xml:402
682 msgid "<command>hg commit</command>; <command>hg push</command>"
683 msgstr "<command>hg commit</command>; <command>hg push</command>"
685 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
686 #: ../en/appA-svn.xml:404
687 msgid "<command>hg push</command> publishes after commit"
688 msgstr "提交后使用 <command>hg push</command> 发布"
690 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
691 #: ../en/appA-svn.xml:408 ../en/appA-svn.xml:413
692 msgid "<command>svn copy</command>"
693 msgstr "<command>svn copy</command>"
695 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
696 #: ../en/appA-svn.xml:410
697 msgid "To create a new branch"
698 msgstr "创建新补丁"
700 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
701 #: ../en/appA-svn.xml:414
702 msgid "<command>hg copy</command>"
703 msgstr "<command>hg copy</command>"
705 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
706 #: ../en/appA-svn.xml:415
707 msgid "To copy files or directories"
708 msgstr "复制文件或目录"
710 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
711 #: ../en/appA-svn.xml:418
712 msgid "<command>svn delete</command> (<command>svn remove</command>)"
713 msgstr "<command>svn delete</command> (<command>svn remove</command>)"
715 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
716 #: ../en/appA-svn.xml:420
717 msgid "<command>hg remove</command>"
718 msgstr "<command>hg remove</command>"
720 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
721 #: ../en/appA-svn.xml:424
722 msgid "<command>svn diff</command>"
723 msgstr "<command>svn diff</command>"
725 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
726 #: ../en/appA-svn.xml:425
727 msgid "<command>hg diff</command>"
728 msgstr "<command>hg diff</command>"
730 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
731 #: ../en/appA-svn.xml:429
732 msgid "<command>svn export</command>"
733 msgstr "<command>svn export</command>"
735 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
736 #: ../en/appA-svn.xml:430
737 msgid "<command>hg archive</command>"
738 msgstr "<command>hg archive</command>"
740 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
741 #: ../en/appA-svn.xml:434
742 msgid "<command>svn help</command>"
743 msgstr "<command>svn help</command>"
745 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
746 #: ../en/appA-svn.xml:435
747 msgid "<command>hg help</command>"
748 msgstr "<command>hg help</command>"
750 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
751 #: ../en/appA-svn.xml:439
752 msgid "<command>svn import</command>"
753 msgstr "<command>svn import</command>"
755 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
756 #: ../en/appA-svn.xml:440
757 msgid "<command>hg addremove</command>; <command>hg commit</command>"
758 msgstr "<command>hg addremove</command>; <command>hg commit</command>"
760 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
761 #: ../en/appA-svn.xml:445 ../en/appA-svn.xml:450
762 msgid "<command>svn info</command>"
763 msgstr "<command>svn info</command>"
765 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
766 #: ../en/appA-svn.xml:446
767 msgid "<command>hg parents</command>"
768 msgstr "<command>hg parents</command>"
770 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
771 #: ../en/appA-svn.xml:447
772 msgid "Shows what revision is checked out"
773 msgstr "显示检出的版本信息"
775 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
776 #: ../en/appA-svn.xml:451
777 msgid "<command>hg showconfig paths.parent</command>"
778 msgstr "<command>hg showconfig paths.parent</command>"
780 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
781 #: ../en/appA-svn.xml:453
782 msgid "Shows what URL is checked out"
783 msgstr "显示检出的 URL"
785 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
786 #: ../en/appA-svn.xml:456
787 msgid "<command>svn list</command>"
788 msgstr "<command>svn list</command>"
790 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
791 #: ../en/appA-svn.xml:457
792 msgid "<command>hg manifest</command>"
793 msgstr "<command>hg manifest</command>"
795 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
796 #: ../en/appA-svn.xml:461
797 msgid "<command>svn log</command>"
798 msgstr "<command>svn log</command>"
800 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
801 #: ../en/appA-svn.xml:462
802 msgid "<command>hg log</command>"
803 msgstr "<command>hg log</command>"
805 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
806 #: ../en/appA-svn.xml:466
807 msgid "<command>svn merge</command>"
808 msgstr ""
810 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
811 #: ../en/appA-svn.xml:467
812 msgid "<command>hg merge</command>"
813 msgstr "<command>hg merge</command>"
815 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
816 #: ../en/appA-svn.xml:471
817 msgid "<command>svn mkdir</command>"
818 msgstr "<command>svn mkdir</command>"
820 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
821 #: ../en/appA-svn.xml:473
822 msgid "Mercurial does not track directories"
823 msgstr "Mercurial 不跟踪目录"
825 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
826 #: ../en/appA-svn.xml:476
827 msgid "<command>svn move</command> (<command>svn rename</command>)"
828 msgstr "<command>svn move</command> (<command>svn rename</command>)"
830 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
831 #: ../en/appA-svn.xml:478
832 msgid "<command>hg rename</command>"
833 msgstr "<command>hg rename</command>"
835 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
836 #: ../en/appA-svn.xml:482
837 msgid "<command>svn resolved</command>"
838 msgstr "<command>svn resolved</command>"
840 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
841 #: ../en/appA-svn.xml:483
842 msgid "<command>hg resolve -m</command>"
843 msgstr "<command>hg resolve -m</command>"
845 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
846 #: ../en/appA-svn.xml:487
847 msgid "<command>svn revert</command>"
848 msgstr "<command>svn revert</command>"
850 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
851 #: ../en/appA-svn.xml:488
852 msgid "<command>hg revert</command>"
853 msgstr "<command>hg revert</command>"
855 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
856 #: ../en/appA-svn.xml:492
857 msgid "<command>svn status</command>"
858 msgstr "<command>svn status</command>"
860 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
861 #: ../en/appA-svn.xml:493
862 msgid "<command>hg status</command>"
863 msgstr "<command>hg status</command>"
865 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
866 #: ../en/appA-svn.xml:497
867 msgid "<command>svn update</command>"
868 msgstr "<command>svn update</command>"
870 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
871 #: ../en/appA-svn.xml:498
872 msgid "<command>hg pull -u</command>"
873 msgstr "<command>hg pull -u</command>"
875 #. type: Content of: <book><appendix><sect1><title>
876 #: ../en/appA-svn.xml:508
877 msgid "Useful tips for newcomers"
878 msgstr "新手需要了解的技巧"
880 #. type: Content of: <book><appendix><sect1><para>
881 #: ../en/appA-svn.xml:510
882 msgid ""
883 "Under some revision control systems, printing a diff for a single committed "
884 "revision can be painful. For instance, with Subversion, to see what changed "
885 "in revision 104654, you must type <command>svn diff -r104653:104654</"
886 "command>. Mercurial eliminates the need to type the revision ID twice in this "
887 "common case. For a plain diff, <command>hg export 104654</command>. For a log "
888 "message followed by a diff, <command>hg log -r104654 -p</command>."
889 msgstr ""
891 #. type: Content of: <book><appendix><sect1><para>
892 #: ../en/appA-svn.xml:519
893 msgid ""
894 "When you run <command>hg status</command> without any arguments, it prints "
895 "the status of the entire tree, with paths relative to the root of the "
896 "repository. This makes it tricky to copy a file name from the output of "
897 "<command>hg status</command> into the command line. If you supply a file or "
898 "directory name to <command>hg status</command>, it will print paths relative "
899 "to your current location instead. So to get tree-wide status from "
900 "<command>hg status</command>, with paths that are relative to your current "
901 "directory and not the root of the repository, feed the output of <command>hg "
902 "root</command> into <command>hg status</command>. You can easily do this as "
903 "follows on a Unix-like system:"
904 msgstr ""
906 #. type: Content of: <book><appendix><sect1><screen><userinput>
907 #: ../en/appA-svn.xml:532
908 msgid "hg status `hg root`"
909 msgstr "hg status `hg root`"
911 #. type: Content of: <book><appendix><title>
912 #: ../en/appB-mq-ref.xml:5
913 msgid "Mercurial Queues reference"
914 msgstr "Mercurial 队列参考"
916 #. type: Content of: <book><appendix><sect1><title>
917 #: ../en/appB-mq-ref.xml:8
918 msgid "MQ command reference"
919 msgstr "MQ 命令参考"
921 #. type: Content of: <book><appendix><sect1><para>
922 #: ../en/appB-mq-ref.xml:10
923 msgid ""
924 "For an overview of the commands provided by MQ, use the command <command role="
925 "\"hg-cmd\">hg help mq</command>."
926 msgstr ""
928 #. type: Content of: <book><appendix><sect1><sect2><title>
929 #: ../en/appB-mq-ref.xml:14
930 msgid ""
931 "<command role=\"hg-ext-mq\">qapplied</command>&emdash;print applied patches"
932 msgstr "<command role=\"hg-ext-mq\">qapplied</command>—显示已应用的补丁"
934 #. type: Content of: <book><appendix><sect1><sect2><para>
935 #: ../en/appB-mq-ref.xml:17
936 msgid ""
937 "The <command role=\"hg-ext-mq\">qapplied</command> command prints the current "
938 "stack of applied patches. Patches are printed in oldest-to-newest order, so "
939 "the last patch in the list is the <quote>top</quote> patch."
940 msgstr ""
942 #. type: Content of: <book><appendix><sect1><sect2><title>
943 #: ../en/appB-mq-ref.xml:24
944 msgid ""
945 "<command role=\"hg-ext-mq\">qcommit</command>&emdash;commit changes in the "
946 "queue repository"
947 msgstr "<command role=\"hg-ext-mq\">qcommit</command>—提交队列中的修改"
949 #. type: Content of: <book><appendix><sect1><sect2><para>
950 #: ../en/appB-mq-ref.xml:27
951 msgid ""
952 "The <command role=\"hg-ext-mq\">qcommit</command> command commits any "
953 "outstanding changes in the <filename role=\"special\" class=\"directory\">.hg/"
954 "patches</filename> repository. This command only works if the <filename role="
955 "\"special\" class=\"directory\">.hg/patches</filename> directory is a "
956 "repository, i.e. you created the directory using <command role=\"hg-cmd\">hg "
957 "qinit <option role=\"hg-ext-mq-cmd-qinit-opt\">-c</option></command> or ran "
958 "<command role=\"hg-cmd\">hg init</command> in the directory after running "
959 "<command role=\"hg-ext-mq\">qinit</command>."
960 msgstr ""
962 #. type: Content of: <book><appendix><sect1><sect2><para>
963 #: ../en/appB-mq-ref.xml:39
964 msgid ""
965 "This command is shorthand for <command role=\"hg-cmd\">hg commit --cwd .hg/"
966 "patches</command>."
967 msgstr ""
969 #. type: Content of: <book><appendix><sect1><sect2><title>
970 #: ../en/appB-mq-ref.xml:43
971 msgid ""
972 "<command role=\"hg-ext-mq\">qdelete</command>&emdash;delete a patch from the "
973 "<filename role=\"special\">series</filename> file"
974 msgstr ""
975 "<command role=\"hg-ext-mq\">qdelete</command>—从文件 <filename role=\"special"
976 "\">series</filename> 中删除补丁"
978 #. type: Content of: <book><appendix><sect1><sect2><para>
979 #: ../en/appB-mq-ref.xml:48
980 msgid ""
981 "The <command role=\"hg-ext-mq\">qdelete</command> command removes the entry "
982 "for a patch from the <filename role=\"special\">series</filename> file in the "
983 "<filename role=\"special\" class=\"directory\">.hg/patches</filename> "
984 "directory. It does not pop the patch if the patch is already applied. By "
985 "default, it does not delete the patch file; use the <option role=\"hg-ext-mq-"
986 "cmd-qdel-opt\">-f</option> option to do that."
987 msgstr ""
989 #. type: Content of: <book><appendix><sect1><sect2><para>
990 #: ../en/appB-mq-ref.xml:57 ../en/appB-mq-ref.xml:109 ../en/appB-mq-ref.xml:167
991 #: ../en/appB-mq-ref.xml:207 ../en/appB-mq-ref.xml:274
992 #: ../en/appB-mq-ref.xml:345 ../en/appB-mq-ref.xml:414
993 #: ../en/appB-mq-ref.xml:492
994 msgid "Options:"
995 msgstr "选项:"
997 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
998 #: ../en/appB-mq-ref.xml:59
999 msgid ""
1000 "<option role=\"hg-ext-mq-cmd-qdel-opt\">-f</option>: Delete the patch file."
1001 msgstr ""
1003 #. type: Content of: <book><appendix><sect1><sect2><title>
1004 #: ../en/appB-mq-ref.xml:66
1005 msgid ""
1006 "<command role=\"hg-ext-mq\">qdiff</command>&emdash;print a diff of the "
1007 "topmost applied patch"
1008 msgstr "<command role=\"hg-ext-mq\">qdiff</command>—显示最新应用补丁的差异"
1010 #. type: Content of: <book><appendix><sect1><sect2><para>
1011 #: ../en/appB-mq-ref.xml:69
1012 msgid ""
1013 "The <command role=\"hg-ext-mq\">qdiff</command> command prints a diff of the "
1014 "topmost applied patch. It is equivalent to <command role=\"hg-cmd\">hg diff -"
1015 "r-2:-1</command>."
1016 msgstr ""
1018 #. type: Content of: <book><appendix><sect1><sect2><title>
1019 #: ../en/appB-mq-ref.xml:75
1020 msgid ""
1021 "<command role=\"hg-ext-mq\">qfold</command>&emdash;move applied patches into "
1022 "repository history"
1023 msgstr ""
1024 "<command role=\"hg-ext-mq\">qfold</command>&emdash;将已应用的补丁提交到版本库"
1026 #. type: Content of: <book><appendix><sect1><sect2><para>
1027 #: ../en/appB-mq-ref.xml:78
1028 msgid ""
1029 "The <command>hg qfinish</command> command converts the specified applied "
1030 "patches into permanent changes by moving them out of MQ's control so that "
1031 "they will be treated as normal repository history."
1032 msgstr ""
1034 #. type: Content of: <book><appendix><sect1><sect2><title>
1035 #: ../en/appB-mq-ref.xml:85
1036 msgid ""
1037 "<command role=\"hg-ext-mq\">qfold</command>&emdash;merge (<quote>fold</"
1038 "quote>) several patches into one"
1039 msgstr ""
1040 "<command role=\"hg-ext-mq\">qfold</command>—将多个补丁合并(<quote>折叠</"
1041 "quote>)成一个"
1043 #. type: Content of: <book><appendix><sect1><sect2><para>
1044 #: ../en/appB-mq-ref.xml:88
1045 msgid ""
1046 "The <command role=\"hg-ext-mq\">qfold</command> command merges multiple "
1047 "patches into the topmost applied patch, so that the topmost applied patch "
1048 "makes the union of all of the changes in the patches in question."
1049 msgstr ""
1051 #. type: Content of: <book><appendix><sect1><sect2><para>
1052 #: ../en/appB-mq-ref.xml:93
1053 msgid ""
1054 "The patches to fold must not be applied; <command role=\"hg-ext-mq\">qfold</"
1055 "command> will exit with an error if any is. The order in which patches are "
1056 "folded is significant; <command role=\"hg-cmd\">hg qfold a b</command> means "
1057 "<quote>apply the current topmost patch, followed by <literal>a</literal>, "
1058 "followed by <literal>b</literal></quote>."
1059 msgstr ""
1061 #. type: Content of: <book><appendix><sect1><sect2><para>
1062 #: ../en/appB-mq-ref.xml:101
1063 msgid ""
1064 "The comments from the folded patches are appended to the comments of the "
1065 "destination patch, with each block of comments separated by three asterisk "
1066 "(<quote><literal>*</literal></quote>) characters. Use the <option role=\"hg-"
1067 "ext-mq-cmd-qfold-opt\">-e</option> option to edit the commit message for the "
1068 "combined patch/changeset after the folding has completed."
1069 msgstr ""
1071 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1072 #: ../en/appB-mq-ref.xml:111
1073 msgid ""
1074 "<option role=\"hg-ext-mq-cmd-qfold-opt\">-e</option>: Edit the commit message "
1075 "and patch description for the newly folded patch."
1076 msgstr ""
1077 "<option role=\"hg-ext-mq-cmd-qfold-opt\">-e</option>:为新创建的补丁编辑提交信"
1078 "息和补丁说明。"
1080 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1081 #: ../en/appB-mq-ref.xml:116
1082 msgid ""
1083 "<option role=\"hg-ext-mq-cmd-qfold-opt\">-l</option>: Use the contents of the "
1084 "given file as the new commit message and patch description for the folded "
1085 "patch."
1086 msgstr ""
1087 "<option role=\"hg-ext-mq-cmd-qfold-opt\">-l</option>: 使用给定文件的内容作为创"
1088 "建补丁新的提交信息和补丁说明。"
1090 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1091 #: ../en/appB-mq-ref.xml:121
1092 msgid ""
1093 "<option role=\"hg-ext-mq-cmd-qfold-opt\">-m</option>: Use the given text as "
1094 "the new commit message and patch description for the folded patch."
1095 msgstr ""
1097 #. type: Content of: <book><appendix><sect1><sect2><title>
1098 #: ../en/appB-mq-ref.xml:129
1099 msgid ""
1100 "<command role=\"hg-ext-mq\">qheader</command>&emdash;display the header/"
1101 "description of a patch"
1102 msgstr "<command role=\"hg-ext-mq\">qheader</command>—显示补丁头部描述"
1104 #. type: Content of: <book><appendix><sect1><sect2><para>
1105 #: ../en/appB-mq-ref.xml:133
1106 msgid ""
1107 "The <command role=\"hg-ext-mq\">qheader</command> command prints the header, "
1108 "or description, of a patch. By default, it prints the header of the topmost "
1109 "applied patch. Given an argument, it prints the header of the named patch."
1110 msgstr ""
1112 #. type: Content of: <book><appendix><sect1><sect2><title>
1113 #: ../en/appB-mq-ref.xml:140
1114 msgid ""
1115 "<command role=\"hg-ext-mq\">qimport</command>&emdash;import a third-party "
1116 "patch into the queue"
1117 msgstr "<command role=\"hg-ext-mq\">qimport</command>—将第三方补丁导入队列"
1119 #. type: Content of: <book><appendix><sect1><sect2><para>
1120 #: ../en/appB-mq-ref.xml:143
1121 msgid ""
1122 "The <command role=\"hg-ext-mq\">qimport</command> command adds an entry for "
1123 "an external patch to the <filename role=\"special\">series</filename> file, "
1124 "and copies the patch into the <filename role=\"special\" class=\"directory\">."
1125 "hg/patches</filename> directory. It adds the entry immediately after the "
1126 "topmost applied patch, but does not push the patch."
1127 msgstr ""
1129 #. type: Content of: <book><appendix><sect1><sect2><para>
1130 #: ../en/appB-mq-ref.xml:151
1131 msgid ""
1132 "If the <filename role=\"special\" class=\"directory\">.hg/patches</filename> "
1133 "directory is a repository, <command role=\"hg-ext-mq\">qimport</command> "
1134 "automatically does an <command role=\"hg-cmd\">hg add</command> of the "
1135 "imported patch."
1136 msgstr ""
1138 #. type: Content of: <book><appendix><sect1><sect2><title>
1139 #: ../en/appB-mq-ref.xml:159
1140 msgid ""
1141 "<command role=\"hg-ext-mq\">qinit</command>&emdash;prepare a repository to "
1142 "work with MQ"
1143 msgstr "<command role=\"hg-ext-mq\">qinit</command>—为使用 MQ 配置版本库"
1145 #. type: Content of: <book><appendix><sect1><sect2><para>
1146 #: ../en/appB-mq-ref.xml:162
1147 msgid ""
1148 "The <command role=\"hg-ext-mq\">qinit</command> command prepares a repository "
1149 "to work with MQ. It creates a directory called <filename role=\"special\" "
1150 "class=\"directory\">.hg/patches</filename>."
1151 msgstr ""
1153 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1154 #: ../en/appB-mq-ref.xml:169
1155 msgid ""
1156 "<option role=\"hg-ext-mq-cmd-qinit-opt\">-c</option>: Create <filename role="
1157 "\"special\" class=\"directory\">.hg/patches</filename> as a repository in its "
1158 "own right. Also creates a <filename role=\"special\">.hgignore</filename> "
1159 "file that will ignore the <filename role=\"special\">status</filename> file."
1160 msgstr ""
1162 #. type: Content of: <book><appendix><sect1><sect2><para>
1163 #: ../en/appB-mq-ref.xml:179
1164 msgid ""
1165 "When the <filename role=\"special\" class=\"directory\">.hg/patches</"
1166 "filename> directory is a repository, the <command role=\"hg-ext-mq\">qimport</"
1167 "command> and <command role=\"hg-ext-mq\">qnew</command> commands "
1168 "automatically <command role=\"hg-cmd\">hg add</command> new patches."
1169 msgstr ""
1171 #. type: Content of: <book><appendix><sect1><sect2><title>
1172 #: ../en/appB-mq-ref.xml:188
1173 msgid "<command role=\"hg-ext-mq\">qnew</command>&emdash;create a new patch"
1174 msgstr "<command role=\"hg-ext-mq\">qnew</command>—创建新补丁"
1176 #. type: Content of: <book><appendix><sect1><sect2><para>
1177 #: ../en/appB-mq-ref.xml:191
1178 msgid ""
1179 "The <command role=\"hg-ext-mq\">qnew</command> command creates a new patch. "
1180 "It takes one mandatory argument, the name to use for the patch file. The "
1181 "newly created patch is created empty by default. It is added to the "
1182 "<filename role=\"special\">series</filename> file after the current topmost "
1183 "applied patch, and is immediately pushed on top of that patch."
1184 msgstr ""
1186 #. type: Content of: <book><appendix><sect1><sect2><para>
1187 #: ../en/appB-mq-ref.xml:199
1188 msgid ""
1189 "If <command role=\"hg-ext-mq\">qnew</command> finds modified files in the "
1190 "working directory, it will refuse to create a new patch unless the <option "
1191 "role=\"hg-ext-mq-cmd-qnew-opt\">-f</option> option is used (see below). This "
1192 "behavior allows you to <command role=\"hg-ext-mq\">qrefresh</command> your "
1193 "topmost applied patch before you apply a new patch on top of it."
1194 msgstr ""
1196 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1197 #: ../en/appB-mq-ref.xml:209
1198 msgid ""
1199 "<option role=\"hg-ext-mq-cmd-qnew-opt\">-f</option>: Create a new patch if "
1200 "the contents of the working directory are modified. Any outstanding "
1201 "modifications are added to the newly created patch, so after this command "
1202 "completes, the working directory will no longer be modified."
1203 msgstr ""
1205 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1206 #: ../en/appB-mq-ref.xml:216
1207 msgid ""
1208 "<option role=\"hg-ext-mq-cmd-qnew-opt\">-m</option>: Use the given text as "
1209 "the commit message. This text will be stored at the beginning of the patch "
1210 "file, before the patch data."
1211 msgstr ""
1213 #. type: Content of: <book><appendix><sect1><sect2><title>
1214 #: ../en/appB-mq-ref.xml:225
1215 msgid ""
1216 "<command role=\"hg-ext-mq\">qnext</command>&emdash;print the name of the next "
1217 "patch"
1218 msgstr "<command role=\"hg-ext-mq\">qnext</command>—显示下个补丁的名称"
1220 #. type: Content of: <book><appendix><sect1><sect2><para>
1221 #: ../en/appB-mq-ref.xml:228
1222 msgid ""
1223 "The <command role=\"hg-ext-mq\">qnext</command> command prints the name name "
1224 "of the next patch in the <filename role=\"special\">series</filename> file "
1225 "after the topmost applied patch. This patch will become the topmost applied "
1226 "patch if you run <command role=\"hg-ext-mq\">qpush</command>."
1227 msgstr ""
1229 #. type: Content of: <book><appendix><sect1><sect2><title>
1230 #: ../en/appB-mq-ref.xml:237
1231 msgid ""
1232 "<command role=\"hg-ext-mq\">qpop</command>&emdash;pop patches off the stack"
1233 msgstr "<command role=\"hg-ext-mq\">qpop</command>—删除堆栈顶部的补丁"
1235 #. type: Content of: <book><appendix><sect1><sect2><para>
1236 #: ../en/appB-mq-ref.xml:240
1237 msgid ""
1238 "The <command role=\"hg-ext-mq\">qpop</command> command removes applied "
1239 "patches from the top of the stack of applied patches. By default, it removes "
1240 "only one patch."
1241 msgstr ""
1243 #. type: Content of: <book><appendix><sect1><sect2><para>
1244 #: ../en/appB-mq-ref.xml:244
1245 msgid ""
1246 "This command removes the changesets that represent the popped patches from "
1247 "the repository, and updates the working directory to undo the effects of the "
1248 "patches."
1249 msgstr ""
1251 #. type: Content of: <book><appendix><sect1><sect2><para>
1252 #: ../en/appB-mq-ref.xml:248
1253 msgid ""
1254 "This command takes an optional argument, which it uses as the name or index "
1255 "of the patch to pop to. If given a name, it will pop patches until the named "
1256 "patch is the topmost applied patch. If given a number, <command role=\"hg-"
1257 "ext-mq\">qpop</command> treats the number as an index into the entries in the "
1258 "series file, counting from zero (empty lines and lines containing only "
1259 "comments do not count). It pops patches until the patch identified by the "
1260 "given index is the topmost applied patch."
1261 msgstr ""
1263 #. type: Content of: <book><appendix><sect1><sect2><para>
1264 #: ../en/appB-mq-ref.xml:258
1265 msgid ""
1266 "The <command role=\"hg-ext-mq\">qpop</command> command does not read or write "
1267 "patches or the <filename role=\"special\">series</filename> file. It is thus "
1268 "safe to <command role=\"hg-ext-mq\">qpop</command> a patch that you have "
1269 "removed from the <filename role=\"special\">series</filename> file, or a "
1270 "patch that you have renamed or deleted entirely. In the latter two cases, "
1271 "use the name of the patch as it was when you applied it."
1272 msgstr ""
1274 #. type: Content of: <book><appendix><sect1><sect2><para>
1275 #: ../en/appB-mq-ref.xml:267
1276 msgid ""
1277 "By default, the <command role=\"hg-ext-mq\">qpop</command> command will not "
1278 "pop any patches if the working directory has been modified. You can override "
1279 "this behavior using the <option role=\"hg-ext-mq-cmd-qpop-opt\">-f</option> "
1280 "option, which reverts all modifications in the working directory."
1281 msgstr ""
1283 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1284 #: ../en/appB-mq-ref.xml:276
1285 msgid ""
1286 "<option role=\"hg-ext-mq-cmd-qpop-opt\">-a</option>: Pop all applied "
1287 "patches. This returns the repository to its state before you applied any "
1288 "patches."
1289 msgstr ""
1291 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1292 #: ../en/appB-mq-ref.xml:281
1293 msgid ""
1294 "<option role=\"hg-ext-mq-cmd-qpop-opt\">-f</option>: Forcibly revert any "
1295 "modifications to the working directory when popping."
1296 msgstr ""
1298 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1299 #: ../en/appB-mq-ref.xml:286
1300 msgid ""
1301 "<option role=\"hg-ext-mq-cmd-qpop-opt\">-n</option>: Pop a patch from the "
1302 "named queue."
1303 msgstr ""
1305 #. type: Content of: <book><appendix><sect1><sect2><para>
1306 #: ../en/appB-mq-ref.xml:291
1307 msgid ""
1308 "The <command role=\"hg-ext-mq\">qpop</command> command removes one line from "
1309 "the end of the <filename role=\"special\">status</filename> file for each "
1310 "patch that it pops."
1311 msgstr ""
1313 #. type: Content of: <book><appendix><sect1><sect2><title>
1314 #: ../en/appB-mq-ref.xml:298
1315 msgid ""
1316 "<command role=\"hg-ext-mq\">qprev</command>&emdash;print the name of the "
1317 "previous patch"
1318 msgstr "<command role=\"hg-ext-mq\">qprev</command>—显示上个补丁的名称"
1320 #. type: Content of: <book><appendix><sect1><sect2><para>
1321 #: ../en/appB-mq-ref.xml:301
1322 msgid ""
1323 "The <command role=\"hg-ext-mq\">qprev</command> command prints the name of "
1324 "the patch in the <filename role=\"special\">series</filename> file that comes "
1325 "before the topmost applied patch. This will become the topmost applied patch "
1326 "if you run <command role=\"hg-ext-mq\">qpop</command>."
1327 msgstr ""
1329 #. type: Content of: <book><appendix><sect1><sect2><title>
1330 #: ../en/appB-mq-ref.xml:310
1331 msgid ""
1332 "<command role=\"hg-ext-mq\">qpush</command>&emdash;push patches onto the stack"
1333 msgstr "<command role=\"hg-ext-mq\">qpush</command>—增加补丁到堆栈"
1335 #. type: Content of: <book><appendix><sect1><sect2><para>
1336 #: ../en/appB-mq-ref.xml:313
1337 msgid ""
1338 "The <command role=\"hg-ext-mq\">qpush</command> command adds patches onto the "
1339 "applied stack. By default, it adds only one patch."
1340 msgstr ""
1342 #. type: Content of: <book><appendix><sect1><sect2><para>
1343 #: ../en/appB-mq-ref.xml:317
1344 msgid ""
1345 "This command creates a new changeset to represent each applied patch, and "
1346 "updates the working directory to apply the effects of the patches."
1347 msgstr ""
1349 #. type: Content of: <book><appendix><sect1><sect2><para>
1350 #: ../en/appB-mq-ref.xml:321
1351 msgid "The default data used when creating a changeset are as follows:"
1352 msgstr ""
1354 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1355 #: ../en/appB-mq-ref.xml:324
1356 msgid ""
1357 "The commit date and time zone are the current date and time zone. Because "
1358 "these data are used to compute the identity of a changeset, this means that "
1359 "if you <command role=\"hg-ext-mq\">qpop</command> a patch and <command role="
1360 "\"hg-ext-mq\">qpush</command> it again, the changeset that you push will have "
1361 "a different identity than the changeset you popped."
1362 msgstr ""
1364 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1365 #: ../en/appB-mq-ref.xml:332
1366 msgid ""
1367 "The author is the same as the default used by the <command role=\"hg-cmd\">hg "
1368 "commit</command> command."
1369 msgstr ""
1371 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1372 #: ../en/appB-mq-ref.xml:336
1373 msgid ""
1374 "The commit message is any text from the patch file that comes before the "
1375 "first diff header. If there is no such text, a default commit message is "
1376 "used that identifies the name of the patch."
1377 msgstr ""
1379 #. type: Content of: <book><appendix><sect1><sect2><para>
1380 #: ../en/appB-mq-ref.xml:341
1381 msgid ""
1382 "If a patch contains a Mercurial patch header, the information in the patch "
1383 "header overrides these defaults."
1384 msgstr ""
1386 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1387 #: ../en/appB-mq-ref.xml:347
1388 msgid ""
1389 "<option role=\"hg-ext-mq-cmd-qpush-opt\">-a</option>: Push all unapplied "
1390 "patches from the <filename role=\"special\">series</filename> file until "
1391 "there are none left to push."
1392 msgstr ""
1394 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1395 #: ../en/appB-mq-ref.xml:353
1396 msgid ""
1397 "<option role=\"hg-ext-mq-cmd-qpush-opt\">-l</option>: Add the name of the "
1398 "patch to the end of the commit message."
1399 msgstr ""
1401 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1402 #: ../en/appB-mq-ref.xml:357
1403 msgid ""
1404 "<option role=\"hg-ext-mq-cmd-qpush-opt\">-m</option>: If a patch fails to "
1405 "apply cleanly, use the entry for the patch in another saved queue to compute "
1406 "the parameters for a three-way merge, and perform a three-way merge using the "
1407 "normal Mercurial merge machinery. Use the resolution of the merge as the new "
1408 "patch content."
1409 msgstr ""
1411 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1412 #: ../en/appB-mq-ref.xml:365
1413 msgid ""
1414 "<option role=\"hg-ext-mq-cmd-qpush-opt\">-n</option>: Use the named queue if "
1415 "merging while pushing."
1416 msgstr ""
1418 #. type: Content of: <book><appendix><sect1><sect2><para>
1419 #: ../en/appB-mq-ref.xml:370
1420 msgid ""
1421 "The <command role=\"hg-ext-mq\">qpush</command> command reads, but does not "
1422 "modify, the <filename role=\"special\">series</filename> file. It appends "
1423 "one line to the <command role=\"hg-cmd\">hg status</command> file for each "
1424 "patch that it pushes."
1425 msgstr ""
1427 #. type: Content of: <book><appendix><sect1><sect2><title>
1428 #: ../en/appB-mq-ref.xml:378
1429 msgid ""
1430 "<command role=\"hg-ext-mq\">qrefresh</command>&emdash;update the topmost "
1431 "applied patch"
1432 msgstr "<command role=\"hg-ext-mq\">qrefresh</command>—更新最新的补丁"
1434 #. type: Content of: <book><appendix><sect1><sect2><para>
1435 #: ../en/appB-mq-ref.xml:382
1436 msgid ""
1437 "The <command role=\"hg-ext-mq\">qrefresh</command> command updates the "
1438 "topmost applied patch. It modifies the patch, removes the old changeset that "
1439 "represented the patch, and creates a new changeset to represent the modified "
1440 "patch."
1441 msgstr ""
1443 #. type: Content of: <book><appendix><sect1><sect2><para>
1444 #: ../en/appB-mq-ref.xml:388
1445 msgid ""
1446 "The <command role=\"hg-ext-mq\">qrefresh</command> command looks for the "
1447 "following modifications:"
1448 msgstr ""
1450 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1451 #: ../en/appB-mq-ref.xml:391
1452 msgid ""
1453 "Changes to the commit message, i.e. the text before the first diff header in "
1454 "the patch file, are reflected in the new changeset that represents the patch."
1455 msgstr ""
1457 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1458 #: ../en/appB-mq-ref.xml:396
1459 msgid ""
1460 "Modifications to tracked files in the working directory are added to the "
1461 "patch."
1462 msgstr ""
1464 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1465 #: ../en/appB-mq-ref.xml:399
1466 msgid ""
1467 "Changes to the files tracked using <command role=\"hg-cmd\">hg add</command>, "
1468 "<command role=\"hg-cmd\">hg copy</command>, <command role=\"hg-cmd\">hg "
1469 "remove</command>, or <command role=\"hg-cmd\">hg rename</command>. Added "
1470 "files and copy and rename destinations are added to the patch, while removed "
1471 "files and rename sources are removed."
1472 msgstr ""
1474 #. type: Content of: <book><appendix><sect1><sect2><para>
1475 #: ../en/appB-mq-ref.xml:408
1476 msgid ""
1477 "Even if <command role=\"hg-ext-mq\">qrefresh</command> detects no changes, it "
1478 "still recreates the changeset that represents the patch. This causes the "
1479 "identity of the changeset to differ from the previous changeset that "
1480 "identified the patch."
1481 msgstr ""
1483 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1484 #: ../en/appB-mq-ref.xml:416
1485 msgid ""
1486 "<option role=\"hg-ext-mq-cmd-qrefresh-opt\">-e</option>: Modify the commit "
1487 "and patch description, using the preferred text editor."
1488 msgstr ""
1490 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1491 #: ../en/appB-mq-ref.xml:421
1492 msgid ""
1493 "<option role=\"hg-ext-mq-cmd-qrefresh-opt\">-m</option>: Modify the commit "
1494 "message and patch description, using the given text."
1495 msgstr ""
1497 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1498 #: ../en/appB-mq-ref.xml:426
1499 msgid ""
1500 "<option role=\"hg-ext-mq-cmd-qrefresh-opt\">-l</option>: Modify the commit "
1501 "message and patch description, using text from the given file."
1502 msgstr ""
1504 #. type: Content of: <book><appendix><sect1><sect2><title>
1505 #: ../en/appB-mq-ref.xml:434
1506 msgid "<command role=\"hg-ext-mq\">qrename</command>&emdash;rename a patch"
1507 msgstr "<command role=\"hg-ext-mq\">qrename</command>—改名补丁"
1509 #. type: Content of: <book><appendix><sect1><sect2><para>
1510 #: ../en/appB-mq-ref.xml:437
1511 msgid ""
1512 "The <command role=\"hg-ext-mq\">qrename</command> command renames a patch, "
1513 "and changes the entry for the patch in the <filename role=\"special\">series</"
1514 "filename> file."
1515 msgstr ""
1517 #. type: Content of: <book><appendix><sect1><sect2><para>
1518 #: ../en/appB-mq-ref.xml:441
1519 msgid ""
1520 "With a single argument, <command role=\"hg-ext-mq\">qrename</command> renames "
1521 "the topmost applied patch. With two arguments, it renames its first argument "
1522 "to its second."
1523 msgstr ""
1525 #. type: Content of: <book><appendix><sect1><sect2><title>
1526 #: ../en/appB-mq-ref.xml:448
1527 msgid ""
1528 "<command role=\"hg-ext-mq\">qseries</command>&emdash;print the entire patch "
1529 "series"
1530 msgstr "<command role=\"hg-ext-mq\">qseries</command>—显示补丁序列"
1532 #. type: Content of: <book><appendix><sect1><sect2><para>
1533 #: ../en/appB-mq-ref.xml:451
1534 msgid ""
1535 "The <command role=\"hg-ext-mq\">qseries</command> command prints the entire "
1536 "patch series from the <filename role=\"special\">series</filename> file. It "
1537 "prints only patch names, not empty lines or comments. It prints in order "
1538 "from first to be applied to last."
1539 msgstr ""
1541 #. type: Content of: <book><appendix><sect1><sect2><title>
1542 #: ../en/appB-mq-ref.xml:459
1543 msgid ""
1544 "<command role=\"hg-ext-mq\">qtop</command>&emdash;print the name of the "
1545 "current patch"
1546 msgstr "<command role=\"hg-ext-mq\">qtop</command>—显示当前补丁的名称"
1548 #. type: Content of: <book><appendix><sect1><sect2><para>
1549 #: ../en/appB-mq-ref.xml:462
1550 msgid ""
1551 "The <command role=\"hg-ext-mq\">qtop</command> prints the name of the topmost "
1552 "currently applied patch."
1553 msgstr ""
1555 #. type: Content of: <book><appendix><sect1><sect2><title>
1556 #: ../en/appB-mq-ref.xml:467
1557 msgid ""
1558 "<command role=\"hg-ext-mq\">qunapplied</command>&emdash;print patches not yet "
1559 "applied"
1560 msgstr "<command role=\"hg-ext-mq\">qunapplied</command>—显示尚未应用的补丁"
1562 #. type: Content of: <book><appendix><sect1><sect2><para>
1563 #: ../en/appB-mq-ref.xml:471
1564 msgid ""
1565 "The <command role=\"hg-ext-mq\">qunapplied</command> command prints the names "
1566 "of patches from the <filename role=\"special\">series</filename> file that "
1567 "are not yet applied. It prints them in order from the next patch that will "
1568 "be pushed to the last."
1569 msgstr ""
1571 #. type: Content of: <book><appendix><sect1><sect2><title>
1572 #: ../en/appB-mq-ref.xml:479
1573 msgid ""
1574 "<command role=\"hg-cmd\">hg strip</command>&emdash;remove a revision and "
1575 "descendants"
1576 msgstr "<command role=\"hg-cmd\">hg strip</command>—删除一个版本及其后继"
1578 #. type: Content of: <book><appendix><sect1><sect2><para>
1579 #: ../en/appB-mq-ref.xml:482
1580 msgid ""
1581 "The <command role=\"hg-cmd\">hg strip</command> command removes a revision, "
1582 "and all of its descendants, from the repository. It undoes the effects of "
1583 "the removed revisions from the repository, and updates the working directory "
1584 "to the first parent of the removed revision."
1585 msgstr ""
1587 #. type: Content of: <book><appendix><sect1><sect2><para>
1588 #: ../en/appB-mq-ref.xml:488
1589 msgid ""
1590 "The <command role=\"hg-cmd\">hg strip</command> command saves a backup of the "
1591 "removed changesets in a bundle, so that they can be reapplied if removed in "
1592 "error."
1593 msgstr ""
1595 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1596 #: ../en/appB-mq-ref.xml:494
1597 msgid ""
1598 "<option role=\"hg-opt-strip\">-b</option>: Save unrelated changesets that are "
1599 "intermixed with the stripped changesets in the backup bundle."
1600 msgstr ""
1602 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1603 #: ../en/appB-mq-ref.xml:498
1604 msgid ""
1605 "<option role=\"hg-opt-strip\">-f</option>: If a branch has multiple heads, "
1606 "remove all heads."
1607 msgstr ""
1609 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1610 #: ../en/appB-mq-ref.xml:501
1611 msgid "<option role=\"hg-opt-strip\">-n</option>: Do not save a backup bundle."
1612 msgstr ""
1614 #. type: Content of: <book><appendix><sect1><title>
1615 #: ../en/appB-mq-ref.xml:508
1616 msgid "MQ file reference"
1617 msgstr "MQ 文件参考"
1619 #. type: Content of: <book><appendix><sect1><sect2><title>
1620 #: ../en/appB-mq-ref.xml:511
1621 msgid "The <filename role=\"special\">series</filename> file"
1622 msgstr "<filename role=\"special\">序列</filename>文件"
1624 #. type: Content of: <book><appendix><sect1><sect2><para>
1625 #: ../en/appB-mq-ref.xml:514
1626 msgid ""
1627 "The <filename role=\"special\">series</filename> file contains a list of the "
1628 "names of all patches that MQ can apply. It is represented as a list of "
1629 "names, with one name saved per line. Leading and trailing white space in "
1630 "each line are ignored."
1631 msgstr ""
1633 #. type: Content of: <book><appendix><sect1><sect2><para>
1634 #: ../en/appB-mq-ref.xml:520
1635 msgid ""
1636 "Lines may contain comments. A comment begins with the <quote><literal>#</"
1637 "literal></quote> character, and extends to the end of the line. Empty lines, "
1638 "and lines that contain only comments, are ignored."
1639 msgstr ""
1641 #. type: Content of: <book><appendix><sect1><sect2><para>
1642 #: ../en/appB-mq-ref.xml:525
1643 msgid ""
1644 "You will often need to edit the <filename role=\"special\">series</filename> "
1645 "file by hand, hence the support for comments and empty lines noted above. "
1646 "For example, you can comment out a patch temporarily, and <command role=\"hg-"
1647 "ext-mq\">qpush</command> will skip over that patch when applying patches. "
1648 "You can also change the order in which patches are applied by reordering "
1649 "their entries in the <filename role=\"special\">series</filename> file."
1650 msgstr ""
1652 #. type: Content of: <book><appendix><sect1><sect2><para>
1653 #: ../en/appB-mq-ref.xml:534
1654 msgid ""
1655 "Placing the <filename role=\"special\">series</filename> file under revision "
1656 "control is also supported; it is a good idea to place all of the patches that "
1657 "it refers to under revision control, as well. If you create a patch "
1658 "directory using the <option role=\"hg-ext-mq-cmd-qinit-opt\">-c</option> "
1659 "option to <command role=\"hg-ext-mq\">qinit</command>, this will be done for "
1660 "you automatically."
1661 msgstr ""
1663 #. type: Content of: <book><appendix><sect1><sect2><title>
1664 #: ../en/appB-mq-ref.xml:544
1665 msgid "The <filename role=\"special\">status</filename> file"
1666 msgstr "<filename role=\"special\">状态</filename>文件"
1668 #. type: Content of: <book><appendix><sect1><sect2><para>
1669 #: ../en/appB-mq-ref.xml:547
1670 msgid ""
1671 "The <filename role=\"special\">status</filename> file contains the names and "
1672 "changeset hashes of all patches that MQ currently has applied. Unlike the "
1673 "<filename role=\"special\">series</filename> file, this file is not intended "
1674 "for editing. You should not place this file under revision control, or "
1675 "modify it in any way. It is used by MQ strictly for internal book-keeping."
1676 msgstr ""
1678 #. type: Content of: <book><appendix><title>
1679 #: ../en/appC-srcinstall.xml:5
1680 msgid "Installing Mercurial from source"
1681 msgstr "从源代码安装 Mercurial"
1683 #. type: Content of: <book><appendix><sect1><title>
1684 #: ../en/appC-srcinstall.xml:8
1685 msgid "On a Unix-like system"
1686 msgstr "类 Unix 系统"
1688 #. type: Content of: <book><appendix><sect1><para>
1689 #: ../en/appC-srcinstall.xml:10
1690 msgid ""
1691 "If you are using a Unix-like system that has a sufficiently recent version of "
1692 "Python (2.3 or newer) available, it is easy to install Mercurial from source."
1693 msgstr ""
1694 "如果你使用类 Unix 系统,并且有足够新的 Python (2.3 更新),从源代码安装 "
1695 "Mercurial 就很容易了。"
1697 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1698 #: ../en/appC-srcinstall.xml:14
1699 msgid ""
1700 "Download a recent source tarball from <ulink url=\"http://www.selenic.com/"
1701 "mercurial/download\">http://www.selenic.com/mercurial/download</ulink>."
1702 msgstr ""
1703 "从 <ulink url=\"http://www.selenic.com/mercurial/download\">http://www."
1704 "selenic.com/mercurial/download</ulink> 下载最新的源代码。"
1706 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1707 #: ../en/appC-srcinstall.xml:17
1708 msgid "Unpack the tarball:"
1709 msgstr "解压:"
1711 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1712 #: ../en/appC-srcinstall.xml:20
1713 msgid ""
1714 "Go into the source directory and run the installer script. This will build "
1715 "Mercurial and install it in your home directory."
1716 msgstr "进入源代码目录,执行安装教本。这会构建 Mercurial,安装到你的家目录。"
1718 #. type: Content of: <book><appendix><sect1><para>
1719 #: ../en/appC-srcinstall.xml:27
1720 msgid ""
1721 "Once the install finishes, Mercurial will be in the <literal>bin</literal> "
1722 "subdirectory of your home directory. Don't forget to make sure that this "
1723 "directory is present in your shell's search path."
1724 msgstr ""
1725 "安装完成后,Mercurial 就位于家目录的 <literal>bin</literal> 子目录。不要忘记将"
1726 "这个目录加入到你的可执行文件搜索路径中。"
1728 #. type: Content of: <book><appendix><sect1><para>
1729 #: ../en/appC-srcinstall.xml:32
1730 msgid ""
1731 "You will probably need to set the <envar>PYTHONPATH</envar> environment "
1732 "variable so that the Mercurial executable can find the rest of the Mercurial "
1733 "packages. For example, on my laptop, I have set it to <literal>/home/bos/lib/"
1734 "python</literal>. The exact path that you will need to use depends on how "
1735 "Python was built for your system, but should be easy to figure out. If "
1736 "you're uncertain, look through the output of the installer script above, and "
1737 "see where the contents of the <literal>mercurial</literal> directory were "
1738 "installed to."
1739 msgstr ""
1740 "你可能需要设置环境变量 <envar>PYTHONPATH</envar>,以便 Mercurial 可执行文件能"
1741 "找到 Mercurial 包。例如,在我的笔记本电脑中,必须设置为 <literal>/home/bos/"
1742 "lib/python</literal>。你需要使用的路径依赖于 Python 的构建方式,这很容易找出"
1743 "来。如果你不确定,仔细察看上面的安装脚本输出,检查包含 <literal>mercurial</"
1744 "literal> 目录的内容的安装位置。"
1746 #. type: Content of: <book><appendix><sect1><title>
1747 #: ../en/appC-srcinstall.xml:44
1748 msgid "On Windows"
1749 msgstr "Windows 系统"
1751 #. type: Content of: <book><appendix><sect1><para>
1752 #: ../en/appC-srcinstall.xml:46
1753 msgid ""
1754 "Building and installing Mercurial on Windows requires a variety of tools, a "
1755 "fair amount of technical knowledge, and considerable patience. I very much "
1756 "<emphasis>do not recommend</emphasis> this route if you are a <quote>casual "
1757 "user</quote>. Unless you intend to hack on Mercurial, I strongly suggest "
1758 "that you use a binary package instead."
1759 msgstr ""
1760 "在 Windows 中构建和安装 Mercurial 需要各种工具,相当多的技术背景,以及足够的耐"
1761 "心。如果你是一个<quote>初级用户</quote>,我<emphasis>很不赞成</emphasis>这个方"
1762 "法。我强烈建议你使用二进制安装包,除非你想深入研究 Mercurial 本身。"
1764 #. type: Content of: <book><appendix><sect1><para>
1765 #: ../en/appC-srcinstall.xml:53
1766 msgid ""
1767 "If you are intent on building Mercurial from source on Windows, follow the "
1768 "<quote>hard way</quote> directions on the Mercurial wiki at <ulink url="
1769 "\"http://www.selenic.com/mercurial/wiki/index.cgi/WindowsInstall\">http://www."
1770 "selenic.com/mercurial/wiki/index.cgi/WindowsInstall</ulink>, and expect the "
1771 "process to involve a lot of fiddly work."
1772 msgstr ""
1773 "If you are intent on building Mercurial from source on Windows, follow the "
1774 "<quote>hard way</quote> directions on the Mercurial wiki at <ulink url="
1775 "\"http://www.selenic.com/mercurial/wiki/index.cgi/WindowsInstall\">http://www."
1776 "selenic.com/mercurial/wiki/index.cgi/WindowsInstall</ulink>, and expect the "
1777 "process to involve a lot of fiddly work."
1779 #. type: Content of: <book><appendix><title>
1780 #: ../en/appD-license.xml:5
1781 msgid "Open Publication License"
1782 msgstr "开放出版协议"
1784 #. type: Content of: <book><appendix><para>
1785 #: ../en/appD-license.xml:7
1786 msgid "Version 1.0, 8 June 1999"
1787 msgstr "版本 1.0,1999 年 6 月 8 日。"
1789 #. type: Content of: <book><appendix><sect1><title>
1790 #: ../en/appD-license.xml:10
1791 msgid "Requirements on both unmodified and modified versions"
1792 msgstr ""
1794 #. type: Content of: <book><appendix><sect1><para>
1795 #: ../en/appD-license.xml:13
1796 msgid ""
1797 "The Open Publication works may be reproduced and distributed in whole or in "
1798 "part, in any medium physical or electronic, provided that the terms of this "
1799 "license are adhered to, and that this license or an incorporation of it by "
1800 "reference (with any options elected by the author(s) and/or publisher) is "
1801 "displayed in the reproduction."
1802 msgstr ""
1804 #. type: Content of: <book><appendix><sect1><para>
1805 #: ../en/appD-license.xml:20
1806 msgid "Proper form for an incorporation by reference is as follows:"
1807 msgstr ""
1809 #. type: Content of: <book><appendix><sect1><blockquote><para>
1810 #: ../en/appD-license.xml:24
1811 msgid ""
1812 "Copyright (c) <emphasis>year</emphasis> by <emphasis>author's name or "
1813 "designee</emphasis>. This material may be distributed only subject to the "
1814 "terms and conditions set forth in the Open Publication License, v<emphasis>x."
1815 "y</emphasis> or later (the latest version is presently available at <ulink "
1816 "url=\"http://www.opencontent.org/openpub/\">http://www.opencontent.org/"
1817 "openpub/</ulink>)."
1818 msgstr ""
1820 #. type: Content of: <book><appendix><sect1><para>
1821 #: ../en/appD-license.xml:33
1822 msgid ""
1823 "The reference must be immediately followed with any options elected by the "
1824 "author(s) and/or publisher of the document (see <xref linkend=\"sec:opl:"
1825 "options\"/>)."
1826 msgstr ""
1828 #. type: Content of: <book><appendix><sect1><para>
1829 #: ../en/appD-license.xml:37
1830 msgid ""
1831 "Commercial redistribution of Open Publication-licensed material is permitted."
1832 msgstr ""
1834 #. type: Content of: <book><appendix><sect1><para>
1835 #: ../en/appD-license.xml:40
1836 msgid ""
1837 "Any publication in standard (paper) book form shall require the citation of "
1838 "the original publisher and author. The publisher and author's names shall "
1839 "appear on all outer surfaces of the book. On all outer surfaces of the book "
1840 "the original publisher's name shall be as large as the title of the work and "
1841 "cited as possessive with respect to the title."
1842 msgstr ""
1844 #. type: Content of: <book><appendix><sect1><title>
1845 #: ../en/appD-license.xml:49
1846 msgid "Copyright"
1847 msgstr ""
1849 #. type: Content of: <book><appendix><sect1><para>
1850 #: ../en/appD-license.xml:51
1851 msgid ""
1852 "The copyright to each Open Publication is owned by its author(s) or designee."
1853 msgstr ""
1855 #. type: Content of: <book><appendix><sect1><title>
1856 #: ../en/appD-license.xml:56
1857 msgid "Scope of license"
1858 msgstr ""
1860 #. type: Content of: <book><appendix><sect1><para>
1861 #: ../en/appD-license.xml:58
1862 msgid ""
1863 "The following license terms apply to all Open Publication works, unless "
1864 "otherwise explicitly stated in the document."
1865 msgstr ""
1867 #. type: Content of: <book><appendix><sect1><para>
1868 #: ../en/appD-license.xml:62
1869 msgid ""
1870 "Mere aggregation of Open Publication works or a portion of an Open "
1871 "Publication work with other works or programs on the same media shall not "
1872 "cause this license to apply to those other works. The aggregate work shall "
1873 "contain a notice specifying the inclusion of the Open Publication material "
1874 "and appropriate copyright notice."
1875 msgstr ""
1877 #. type: Content of: <book><appendix><sect1><para>
1878 #: ../en/appD-license.xml:69
1879 msgid ""
1880 "<emphasis role=\"bold\">Severability</emphasis>. If any part of this license "
1881 "is found to be unenforceable in any jurisdiction, the remaining portions of "
1882 "the license remain in force."
1883 msgstr ""
1885 #. type: Content of: <book><appendix><sect1><para>
1886 #: ../en/appD-license.xml:74
1887 msgid ""
1888 "<emphasis role=\"bold\">No warranty</emphasis>. Open Publication works are "
1889 "licensed and provided <quote>as is</quote> without warranty of any kind, "
1890 "express or implied, including, but not limited to, the implied warranties of "
1891 "merchantability and fitness for a particular purpose or a warranty of non-"
1892 "infringement."
1893 msgstr ""
1895 #. type: Content of: <book><appendix><sect1><title>
1896 #: ../en/appD-license.xml:83
1897 msgid "Requirements on modified works"
1898 msgstr ""
1900 #. type: Content of: <book><appendix><sect1><para>
1901 #: ../en/appD-license.xml:85
1902 msgid ""
1903 "All modified versions of documents covered by this license, including "
1904 "translations, anthologies, compilations and partial documents, must meet the "
1905 "following requirements:"
1906 msgstr ""
1908 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1909 #: ../en/appD-license.xml:90
1910 msgid "The modified version must be labeled as such."
1911 msgstr ""
1913 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1914 #: ../en/appD-license.xml:93
1915 msgid ""
1916 "The person making the modifications must be identified and the modifications "
1917 "dated."
1918 msgstr ""
1920 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1921 #: ../en/appD-license.xml:96
1922 msgid ""
1923 "Acknowledgement of the original author and publisher if applicable must be "
1924 "retained according to normal academic citation practices."
1925 msgstr ""
1927 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1928 #: ../en/appD-license.xml:100
1929 msgid "The location of the original unmodified document must be identified."
1930 msgstr ""
1932 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1933 #: ../en/appD-license.xml:103
1934 msgid ""
1935 "The original author's (or authors') name(s) may not be used to assert or "
1936 "imply endorsement of the resulting document without the original author's (or "
1937 "authors') permission."
1938 msgstr ""
1940 #. type: Content of: <book><appendix><sect1><title>
1941 #: ../en/appD-license.xml:111
1942 msgid "Good-practice recommendations"
1943 msgstr ""
1945 #. type: Content of: <book><appendix><sect1><para>
1946 #: ../en/appD-license.xml:113
1947 msgid ""
1948 "In addition to the requirements of this license, it is requested from and "
1949 "strongly recommended of redistributors that:"
1950 msgstr ""
1952 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1953 #: ../en/appD-license.xml:118
1954 msgid ""
1955 "If you are distributing Open Publication works on hardcopy or CD-ROM, you "
1956 "provide email notification to the authors of your intent to redistribute at "
1957 "least thirty days before your manuscript or media freeze, to give the authors "
1958 "time to provide updated documents. This notification should describe "
1959 "modifications, if any, made to the document."
1960 msgstr ""
1962 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1963 #: ../en/appD-license.xml:125
1964 msgid ""
1965 "All substantive modifications (including deletions) be either clearly marked "
1966 "up in the document or else described in an attachment to the document."
1967 msgstr ""
1969 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1970 #: ../en/appD-license.xml:129
1971 msgid ""
1972 "Finally, while it is not mandatory under this license, it is considered good "
1973 "form to offer a free copy of any hardcopy and CD-ROM expression of an Open "
1974 "Publication-licensed work to its author(s)."
1975 msgstr ""
1977 #. type: Content of: <book><appendix><sect1><title>
1978 #: ../en/appD-license.xml:137
1979 msgid "License options"
1980 msgstr ""
1982 #. type: Content of: <book><appendix><sect1><para>
1983 #: ../en/appD-license.xml:139
1984 msgid ""
1985 "The author(s) and/or publisher of an Open Publication-licensed document may "
1986 "elect certain options by appending language to the reference to or copy of "
1987 "the license. These options are considered part of the license instance and "
1988 "must be included with the license (or its incorporation by reference) in "
1989 "derived works."
1990 msgstr ""
1992 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1993 #: ../en/appD-license.xml:147
1994 msgid ""
1995 "To prohibit distribution of substantively modified versions without the "
1996 "explicit permission of the author(s). <quote>Substantive modification</quote> "
1997 "is defined as a change to the semantic content of the document, and excludes "
1998 "mere changes in format or typographical corrections."
1999 msgstr ""
2001 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
2002 #: ../en/appD-license.xml:154
2003 msgid ""
2004 "To accomplish this, add the phrase <quote>Distribution of substantively "
2005 "modified versions of this document is prohibited without the explicit "
2006 "permission of the copyright holder.</quote> to the license reference or copy."
2007 msgstr ""
2009 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
2010 #: ../en/appD-license.xml:160
2011 msgid ""
2012 "To prohibit any publication of this work or derivative works in whole or in "
2013 "part in standard (paper) book form for commercial purposes is prohibited "
2014 "unless prior permission is obtained from the copyright holder."
2015 msgstr ""
2017 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
2018 #: ../en/appD-license.xml:165
2019 msgid ""
2020 "To accomplish this, add the phrase <quote>Distribution of the work or "
2021 "derivative of the work in any standard (paper) book form is prohibited unless "
2022 "prior permission is obtained from the copyright holder.</quote> to the "
2023 "license reference or copy."
2024 msgstr ""
2026 #. type: Content of: <book><preface><title>
2027 #: ../en/ch00-preface.xml:5
2028 msgid "Preface"
2029 msgstr "序言"
2031 #. type: Content of: <book><preface><sect1><title>
2032 #: ../en/ch00-preface.xml:8
2033 msgid "Technical storytelling"
2034 msgstr "技术背景"
2036 #. type: Content of: <book><preface><sect1><para>
2037 #: ../en/ch00-preface.xml:10
2038 msgid ""
2039 "A few years ago, when I wanted to explain why I believed that distributed "
2040 "revision control is important, the field was then so new that there was "
2041 "almost no published literature to refer people to."
2042 msgstr ""
2043 "数年之前,当我想解释为什么我相信分布式版本控制非常重要的时候,这个领域实在太新"
2044 "了,几乎没有公开的文献供人们参考。"
2046 #. type: Content of: <book><preface><sect1><para>
2047 #: ../en/ch00-preface.xml:15
2048 msgid ""
2049 "Although at that time I spent some time working on the internals of Mercurial "
2050 "itself, I switched to writing this book because that seemed like the most "
2051 "effective way to help the software to reach a wide audience, along with the "
2052 "idea that revision control ought to be distributed in nature. I publish the "
2053 "book online under a liberal license for the same reason: to get the word out."
2054 msgstr ""
2055 "虽然在那个时候,我已经在Mercurial的内核上花了一些时间,我转而写这本书是因为我"
2056 "发现这可能是帮助软件吸引更多用户,和让大家接受版本控制本质上就应该是分布式的最"
2057 "有效的方式,我把这本书在网上以自由许可的方式发布也是基于同样的原因:让大家都了"
2058 "解。"
2060 #. type: Content of: <book><preface><sect1><para>
2061 #: ../en/ch00-preface.xml:23
2062 msgid ""
2063 "There's a familiar rhythm to a good software book that closely resembles "
2064 "telling a story: What is this thing? Why does it matter? How will it help me? "
2065 "How do I use it? In this book, I try to answer those questions for "
2066 "distributed revision control in general, and for Mercurial in particular."
2067 msgstr ""
2068 "一本好的关于软件的书应该和讲故事类似:这是个什么东西?为什么需要它?它会怎样帮"
2069 "助我?我怎么使用它?本书中,我会为分布式版本控制回答这些问题,特别是"
2070 "Mercurial。"
2072 #. type: Content of: <book><preface><sect1><title>
2073 #: ../en/ch00-preface.xml:31
2074 msgid "Thank you for supporting Mercurial"
2075 msgstr "谢谢你支持 Mercurial"
2077 #. type: Content of: <book><preface><sect1><para>
2078 #: ../en/ch00-preface.xml:33
2079 msgid ""
2080 "By purchasing a copy of this book, you are supporting the continued "
2081 "development and freedom of Mercurial in particular, and of open source and "
2082 "free software in general. O'Reilly Media and I are donating my royalties on "
2083 "the sales of this book to the Software Freedom Conservancy (<ulink url="
2084 "\"http://www.softwarefreedom.org/\">http://www.softwarefreedom.org/</ulink>) "
2085 "which provides clerical and legal support to Mercurial and a number of other "
2086 "prominent and worthy open source software projects."
2087 msgstr ""
2088 "通过购买此书,你支持了开源和自由软件的持续发展和自由,特别是Mercurial。"
2089 "O'Reilly Media和我将本书的收入捐献给Software Freedom Conservancy (<ulink url="
2090 "\"http://www.softwarefreedom.org/\">http://www.softwarefreedom.org/</ulink>) ,"
2091 "这个组织为Mercurial和其他一些有潜力和价值的开源软件项目提供了办公和法律支持。"
2093 #. type: Content of: <book><preface><sect1><title>
2094 #: ../en/ch00-preface.xml:45
2095 msgid "Acknowledgments"
2096 msgstr "致谢"
2098 #. type: Content of: <book><preface><sect1><para>
2099 #: ../en/ch00-preface.xml:47
2100 msgid ""
2101 "This book would not exist were it not for the efforts of Matt Mackall, the "
2102 "author and project lead of Mercurial. He is ably assisted by hundreds of "
2103 "volunteer contributors across the world."
2104 msgstr ""
2105 "没有Matt Mackall,Mercurial项目的开发者和领导的努力,这本书不可能存在。他得到"
2106 "了全球数以百计的志愿者的帮助。"
2108 #. type: Content of: <book><preface><sect1><para>
2109 #: ../en/ch00-preface.xml:52
2110 msgid ""
2111 "My children, Cian and Ruairi, always stood ready to help me to unwind with "
2112 "wonderful, madcap little-boy games. I'd also like to thank my ex-wife, "
2113 "Shannon, for her support."
2114 msgstr ""
2116 #. type: Content of: <book><preface><sect1><para>
2117 #: ../en/ch00-preface.xml:56
2118 msgid ""
2119 "My colleagues and friends provided help and support in innumerable ways. "
2120 "This list of people is necessarily very incomplete: Stephen Hahn, Karyn "
2121 "Ritter, Bonnie Corwin, James Vasile, Matt Norwood, Eben Moglen, Bradley Kuhn, "
2122 "Robert Walsh, Jeremy Fitzhardinge, Rachel Chalmers."
2123 msgstr ""
2124 "我的同事和朋友以各种方式提供了帮助和支持,这里的名单非常不全:Stephen Hahn, "
2125 "Karyn Ritter, Bonnie Corwin, James Vasile, Matt Norwood, Eben Moglen, Bradley "
2126 "Kuhn, Robert Walsh, Jeremy Fitzhardinge, Rachel Chalmers."
2128 #. type: Content of: <book><preface><sect1><para>
2129 #: ../en/ch00-preface.xml:62
2130 msgid ""
2131 "I developed this book in the open, posting drafts of chapters to the book web "
2132 "site as I completed them. Readers then submitted feedback using a web "
2133 "application that I developed. By the time I finished writing the book, more "
2134 "than 100 people had submitted comments, an amazing number considering that "
2135 "the comment system was live for only about two months towards the end of the "
2136 "writing process."
2137 msgstr ""
2138 "我以开放的方式完成了本书,当我完成各章的草稿后,就将其放在了网上。读者可以使用"
2139 "我开发的一个网络程序提交反馈。到我完成本书时,有100多人提交了评论。考虑到评论"
2140 "系统是在写作完成之前两个月才开放的,这是一个惊人的数字。"
2142 #. type: Content of: <book><preface><sect1><para>
2143 #: ../en/ch00-preface.xml:70
2144 msgid ""
2145 "I would particularly like to recognize the following people, who between them "
2146 "contributed over a third of the total number of comments. I would like to "
2147 "thank them for their care and effort in providing so much detailed feedback."
2148 msgstr ""
2149 "我特别希望认识以下人员,他们中有的人提交了超过总数三分之一的评论。我要感谢他们"
2150 "的关心和努力,提供了那么多详细的反馈。"
2152 #. type: Content of: <book><preface><sect1><para>
2153 #: ../en/ch00-preface.xml:75
2154 msgid ""
2155 "Martin Geisler, Damien Cassou, Alexey Bakhirkin, Till Plewe, Dan Himes, Paul "
2156 "Sargent, Gokberk Hamurcu, Matthijs van der Vleuten, Michael Chermside, John "
2157 "Mulligan, Jordi Fita, Jon Parise."
2158 msgstr ""
2160 #. type: Content of: <book><preface><sect1><para>
2161 #: ../en/ch00-preface.xml:80
2162 msgid ""
2163 "I also want to acknowledge the help of the many people who caught errors and "
2164 "provided helpful suggestions throughout the book."
2165 msgstr "我同样要感谢许多在书中找出错误和提供了有帮助的建议的人。"
2167 #. type: Content of: <book><preface><sect1><para>
2168 #: ../en/ch00-preface.xml:84
2169 msgid ""
2170 "Jeremy W. Sherman, Brian Mearns, Vincent Furia, Iwan Luijks, Billy Edwards, "
2171 "Andreas Sliwka, Paweł Sołyga, Eric Hanchrow, Steve Nicolai, Michał Masłowski, "
2172 "Kevin Fitch, Johan Holmberg, Hal Wine, Volker Simonis, Thomas P Jakobsen, Ted "
2173 "Stresen-Reuter, Stephen Rasku, Raphael Das Gupta, Ned Batchelder, Lou Keeble, "
2174 "Li Linxiao, Kao Cardoso Félix, Joseph Wecker, Jon Prescot, Jon Maken, John "
2175 "Yeary, Jason Harris, Geoffrey Zheng, Fredrik Jonson, Ed Davies, David "
2176 "Zumbrunnen, David Mercer, David Cabana, Ben Karel, Alan Franzoni, Yousry "
2177 "Abdallah, Whitney Young, Vinay Sajip, Tom Towle, Tim Ottinger, Thomas "
2178 "Schraitle, Tero Saarni, Ted Mielczarek, Svetoslav Agafonkin, Shaun Rowland, "
2179 "Rocco Rutte, Polo-Francois Poli, Philip Jenvey, Petr Tesałék, Peter R. "
2180 "Annema, Paul Bonser, Olivier Scherler, Olivier Fournier, Nick Parker, Nick "
2181 "Fabry, Nicholas Guarracino, Mike Driscoll, Mike Coleman, Mietek Bák, Michael "
2182 "Maloney, László Nagy, Kent Johnson, Julio Nobrega, Jord Fita, Jonathan March, "
2183 "Jonas Nockert, Jim Tittsler, Jeduan Cornejo Legorreta, Jan Larres, James "
2184 "Murphy, Henri Wiechers, Hagen Möbius, Gábor Farkas, Fabien Engels, Evert Rol, "
2185 "Evan Willms, Eduardo Felipe Castegnaro, Dennis Decker Jensen, Deniz Dogan, "
2186 "David Smith, Daed Lee, Christine Slotty, Charles Merriam, Guillaume Catto, "
2187 "Brian Dorsey, Bob Nystrom, Benoit Boissinot, Avi Rosenschein, Andrew Watts, "
2188 "Andrew Donkin, Alexey Rodriguez, Ahmed Chaudhary."
2189 msgstr ""
2191 #. type: Content of: <book><preface><sect1><title>
2192 #: ../en/ch00-preface.xml:111
2193 msgid "Conventions Used in This Book"
2194 msgstr "本书的约定"
2196 #. type: Content of: <book><preface><sect1><para>
2197 #: ../en/ch00-preface.xml:113
2198 msgid "The following typographical conventions are used in this book:"
2199 msgstr "本书使用如下的印刷约定:"
2201 #. type: Content of: <book><preface><sect1><variablelist><varlistentry><term>
2202 #: ../en/ch00-preface.xml:118
2203 msgid "Italic"
2204 msgstr "斜体"
2206 #. type: Content of: <book><preface><sect1><variablelist><varlistentry><listitem><para>
2207 #: ../en/ch00-preface.xml:121
2208 msgid ""
2209 "Indicates new terms, URLs, email addresses, filenames, and file extensions."
2210 msgstr "标识新术语,URL,电子邮件地址,文件名称与扩展名。"
2212 #. type: Content of: <book><preface><sect1><variablelist><varlistentry><term>
2213 #: ../en/ch00-preface.xml:127
2214 msgid "<literal>Constant width</literal>"
2215 msgstr "<literal>等宽</literal>"
2217 #. type: Content of: <book><preface><sect1><variablelist><varlistentry><listitem><para>
2218 #: ../en/ch00-preface.xml:130
2219 msgid ""
2220 "Used for program listings, as well as within paragraphs to refer to program "
2221 "elements such as variable or function names, databases, data types, "
2222 "environment variables, statements, and keywords."
2223 msgstr ""
2224 "用于程序列表,以及段内引用的程序元素,例如变量、函数名称、数据库、数据类型、环"
2225 "境变量、声明和关键字。"
2227 #. type: Content of: <book><preface><sect1><variablelist><varlistentry><term>
2228 #: ../en/ch00-preface.xml:138
2229 msgid "<userinput>Constant width bold</userinput>"
2230 msgstr "<userinput>等宽粗体</userinput>"
2232 #. type: Content of: <book><preface><sect1><variablelist><varlistentry><listitem><para>
2233 #: ../en/ch00-preface.xml:141
2234 msgid "Shows commands or other text that should be typed literally by the user."
2235 msgstr "标识命令或者其它用户应该逐字输入的文本。"
2237 #. type: Content of: <book><preface><sect1><variablelist><varlistentry><term>
2238 #: ../en/ch00-preface.xml:147
2239 msgid "<replaceable>Constant width italic</replaceable>"
2240 msgstr "<replaceable>等宽斜体</replaceable>"
2242 #. type: Content of: <book><preface><sect1><variablelist><varlistentry><listitem><para>
2243 #: ../en/ch00-preface.xml:150
2244 msgid ""
2245 "Shows text that should be replaced with user-supplied values or by values "
2246 "determined by context."
2247 msgstr "标识应该被用户提供的值或者取决于上下文的值替换的文本。"
2249 #. type: Content of: <book><preface><sect1><tip><para>
2250 #: ../en/ch00-preface.xml:157
2251 msgid "This icon signifies a tip, suggestion, or general note."
2252 msgstr "此图标表示提示,建议或者一般的的注释。"
2254 #. type: Content of: <book><preface><sect1><caution><para>
2255 #: ../en/ch00-preface.xml:162
2256 msgid "This icon indicates a warning or caution."
2257 msgstr "此图标表示警告。"
2259 #. type: Content of: <book><preface><sect1><title>
2260 #: ../en/ch00-preface.xml:167
2261 msgid "Using Code Examples"
2262 msgstr "使用样例代码"
2264 #. type: Content of: <book><preface><sect1><para>
2265 #: ../en/ch00-preface.xml:169
2266 msgid ""
2267 "This book is here to help you get your job done. In general, you may use the "
2268 "code in this book in your programs and documentation. You do not need to "
2269 "contact us for permission unless you’re reproducing a significant portion of "
2270 "the code. For example, writing a program that uses several chunks of code "
2271 "from this book does not require permission. Selling or distributing a CD-ROM "
2272 "of examples from O’Reilly books does require permission. Answering a "
2273 "question by citing this book and quoting example code does not require "
2274 "permission. Incorporating a significant amount of example code from this book "
2275 "into your product’s documentation does require permission."
2276 msgstr ""
2278 #. type: Content of: <book><preface><sect1><para>
2279 #: ../en/ch00-preface.xml:181
2280 msgid ""
2281 "We appreciate, but do not require, attribution. An attribution usually "
2282 "includes the title, author, publisher, and ISBN. For example: “<emphasis>Book "
2283 "Title</emphasis> by Some Author. Copyright 2008 O’Reilly Media, Inc., 978-0-"
2284 "596-xxxx-x.”"
2285 msgstr ""
2287 #. type: Content of: <book><preface><sect1><para>
2288 #: ../en/ch00-preface.xml:187
2289 msgid ""
2290 "If you feel your use of code examples falls outside fair use or the "
2291 "permission given above, feel free to contact us at <email>permissions@oreilly."
2292 "com</email>."
2293 msgstr ""
2295 #. type: Content of: <book><preface><sect1><title>
2296 #: ../en/ch00-preface.xml:193
2297 msgid "Safari® Books Online"
2298 msgstr "Safari® 在线书库"
2300 #. type: Content of: <book><preface><sect1><note><para>
2301 #: ../en/ch00-preface.xml:196
2302 msgid ""
2303 "When you see a Safari® Books Online icon on the cover of your favorite "
2304 "technology book, that means the book is available online through the O’Reilly "
2305 "Network Safari Bookshelf."
2306 msgstr ""
2308 #. type: Content of: <book><preface><sect1><para>
2309 #: ../en/ch00-preface.xml:202
2310 msgid ""
2311 "Safari offers a solution that’s better than e-books. It’s a virtual library "
2312 "that lets you easily search thousands of top tech books, cut and paste code "
2313 "samples, download chapters, and find quick answers when you need the most "
2314 "accurate, current information. Try it for free at <ulink role=\"orm:hideurl:"
2315 "ital\" url=\"http://my.safaribooksonline.com/?portal=oreilly\">http://my."
2316 "safaribooksonline.com</ulink>."
2317 msgstr ""
2319 #. type: Content of: <book><preface><sect1><title>
2320 #: ../en/ch00-preface.xml:211
2321 msgid "How to Contact Us"
2322 msgstr "联系我们"
2324 #. type: Content of: <book><preface><sect1><para>
2325 #: ../en/ch00-preface.xml:213
2326 msgid ""
2327 "Please address comments and questions concerning this book to the publisher:"
2328 msgstr ""
2330 #. type: Content of: <book><preface><sect1><simplelist><member>
2331 #: ../en/ch00-preface.xml:217
2332 msgid "O’Reilly Media, Inc."
2333 msgstr ""
2335 #. type: Content of: <book><preface><sect1><simplelist><member>
2336 #: ../en/ch00-preface.xml:219
2337 msgid "1005 Gravenstein Highway North"
2338 msgstr ""
2340 #. type: Content of: <book><preface><sect1><simplelist><member>
2341 #: ../en/ch00-preface.xml:221
2342 msgid "Sebastopol, CA 95472"
2343 msgstr ""
2345 #. type: Content of: <book><preface><sect1><simplelist><member>
2346 #: ../en/ch00-preface.xml:223
2347 msgid "800-998-9938 (in the United States or Canada)"
2348 msgstr ""
2350 #. type: Content of: <book><preface><sect1><simplelist><member>
2351 #: ../en/ch00-preface.xml:225
2352 msgid "707-829-0515 (international or local)"
2353 msgstr ""
2355 #. type: Content of: <book><preface><sect1><simplelist><member>
2356 #: ../en/ch00-preface.xml:227
2357 msgid "707 829-0104 (fax)"
2358 msgstr ""
2360 #. type: Content of: <book><preface><sect1><para>
2361 #: ../en/ch00-preface.xml:230
2362 msgid ""
2363 "We have a web page for this book, where we list errata, examples, and any "
2364 "additional information. You can access this page at:"
2365 msgstr ""
2367 #. type: Content of: <book><preface><sect1><simplelist><member>
2368 #: ../en/ch00-preface.xml:235
2369 msgid ""
2370 "<ulink url=\"http://www.oreilly.com/catalog/&lt;catalog page&gt;\"></ulink>"
2371 msgstr ""
2373 #. type: Content of: <book><preface><sect1><remark>
2374 #: ../en/ch00-preface.xml:239
2375 msgid "Don’t forget to update the &lt;url&gt; attribute, too."
2376 msgstr ""
2378 #. type: Content of: <book><preface><sect1><para>
2379 #: ../en/ch00-preface.xml:242
2380 msgid "To comment or ask technical questions about this book, send email to:"
2381 msgstr ""
2383 #. type: Content of: <book><preface><sect1><simplelist><member>
2384 #: ../en/ch00-preface.xml:246
2385 msgid "<email>bookquestions@oreilly.com</email>"
2386 msgstr "<email>bookquestions@oreilly.com</email>"
2388 #. type: Content of: <book><preface><sect1><para>
2389 #: ../en/ch00-preface.xml:249
2390 msgid ""
2391 "For more information about our books, conferences, Resource Centers, and the "
2392 "O’Reilly Network, see our web site at:"
2393 msgstr ""
2395 #. type: Content of: <book><preface><sect1><simplelist><member>
2396 #: ../en/ch00-preface.xml:253
2397 msgid "<ulink url=\"http://www.oreilly.com\"></ulink>"
2398 msgstr "<ulink url=\"http://www.oreilly.com\"></ulink>"
2400 #. type: Content of: <book><chapter><title>
2401 #: ../en/ch01-intro.xml:5
2402 msgid "How did we get here?"
2403 msgstr "写在前面"
2405 #. type: Content of: <book><chapter><sect1><title>
2406 #: ../en/ch01-intro.xml:8
2407 msgid "Why revision control? Why Mercurial?"
2408 msgstr "为什么使用版本控制? 为什么使用 Mercurial?"
2410 #. type: Content of: <book><chapter><sect1><para>
2411 #: ../en/ch01-intro.xml:10
2412 msgid ""
2413 "Revision control is the process of managing multiple versions of a piece of "
2414 "information. In its simplest form, this is something that many people do by "
2415 "hand: every time you modify a file, save it under a new name that contains a "
2416 "number, each one higher than the number of the preceding version."
2417 msgstr ""
2418 "版本控制是管理一些信息的多个版本的过程。它最简单的形式莫过于:每次你修改一个文"
2419 "件后都重新命名保存,文件名中包含一个数字,每次修改后这个数字都增加。这通常是许"
2420 "多人手工完成的。"
2422 #. type: Content of: <book><chapter><sect1><para>
2423 #: ../en/ch01-intro.xml:16
2424 msgid ""
2425 "Manually managing multiple versions of even a single file is an error-prone "
2426 "task, though, so software tools to help automate this process have long been "
2427 "available. The earliest automated revision control tools were intended to "
2428 "help a single user to manage revisions of a single file. Over the past few "
2429 "decades, the scope of revision control tools has expanded greatly; they now "
2430 "manage multiple files, and help multiple people to work together. The best "
2431 "modern revision control tools have no problem coping with thousands of people "
2432 "working together on projects that consist of hundreds of thousands of files."
2433 msgstr ""
2434 "然而,手工管理即使是一个文件的多个版本也是很容易出错的,所以很早就有软件工具来"
2435 "使这个过程自动化。最早的自动化软件管理工具的目标是帮助一个用户管理一个文件的版"
2436 "本。在过去的几十年里,版本控制工具的范围得到极大扩展;现在它们可以管理多个文"
2437 "件,帮助许多人一起工作。最新的版本控制工具可以支持上包含成数十万个文件,几千个"
2438 "人一起工作的项目。"
2440 #. type: Content of: <book><chapter><sect1><para>
2441 #: ../en/ch01-intro.xml:27
2442 msgid ""
2443 "The arrival of distributed revision control is relatively recent, and so far "
2444 "this new field has grown due to people's willingness to explore ill-charted "
2445 "territory."
2446 msgstr ""
2447 "分布式版本控制是最近才出现的,但是由于人们愿意探索新的疆域,目前这一新的领域已"
2448 "经得到了长足的发展"
2450 #. type: Content of: <book><chapter><sect1><para>
2451 #: ../en/ch01-intro.xml:31
2452 msgid ""
2453 "I am writing a book about distributed revision control because I believe that "
2454 "it is an important subject that deserves a field guide. I chose to write "
2455 "about Mercurial because it is the easiest tool to learn the terrain with, and "
2456 "yet it scales to the demands of real, challenging environments where many "
2457 "other revision control tools buckle."
2458 msgstr ""
2459 "我写这本关于分布式版本控制的书是因为我相信这个领域应该有一个指南。我选择"
2460 "Mercurial是因为它是在这个领域中学习最容易上手的工具,并且它能够满足真实的,挑"
2461 "战性的环境的要求,而其他版本控制工具只能望而兴叹。"
2463 #. type: Content of: <book><chapter><sect1><sect2><title>
2464 #: ../en/ch01-intro.xml:39
2465 msgid "Why use revision control?"
2466 msgstr "为什么使用版本控制?"
2468 #. type: Content of: <book><chapter><sect1><sect2><para>
2469 #: ../en/ch01-intro.xml:41
2470 msgid ""
2471 "There are a number of reasons why you or your team might want to use an "
2472 "automated revision control tool for a project."
2473 msgstr ""
2474 "为什么你或者你的团队可能需要在项目中使用自动化版本控制工具呢?有很多理由。"
2476 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2477 #: ../en/ch01-intro.xml:46
2478 msgid ""
2479 "It will track the history and evolution of your project, so you don't have "
2480 "to. For every change, you'll have a log of <emphasis>who</emphasis> made it; "
2481 "<emphasis>why</emphasis> they made it; <emphasis>when</emphasis> they made "
2482 "it; and <emphasis>what</emphasis> the change was."
2483 msgstr ""
2484 "因为它能记录你的项目的历史和演化,所以你不必再给每个变更都记录日志,<emphasis>"
2485 "谁</emphasis>做的;<emphasis>为什么</emphasis>他们这样做;<emphasis>什么时候</"
2486 "emphasis>做的;做了<emphasis>什么</emphasis>修改。"
2488 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2489 #: ../en/ch01-intro.xml:53
2490 msgid ""
2491 "When you're working with other people, revision control software makes it "
2492 "easier for you to collaborate. For example, when people more or less "
2493 "simultaneously make potentially incompatible changes, the software will help "
2494 "you to identify and resolve those conflicts."
2495 msgstr ""
2496 "当你和其他人一起工作的时候,版本控制工具让你合作的更容易。例如,当许多人或多或"
2497 "少的同时进行有可能冲突的修改的时候,软件可以帮助你确定和解决这些冲突。"
2499 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2500 #: ../en/ch01-intro.xml:59
2501 msgid ""
2502 "It can help you to recover from mistakes. If you make a change that later "
2503 "turns out to be in error, you can revert to an earlier version of one or more "
2504 "files. In fact, a <emphasis>really</emphasis> good revision control tool "
2505 "will even help you to efficiently figure out exactly when a problem was "
2506 "introduced (see <xref linkend=\"sec:undo:bisect\"/> for details)."
2507 msgstr ""
2508 "它能帮助你修正错误。如果你做了一个修改,但是后来发现这是个错误,你能恢复到一个"
2509 "或者多个文件以前的版本。实际上,一个<emphasis>相当</emphasis>好的版本控制工具"
2510 "甚至会帮助你找出什么什么是时候引入的这个问题(详细信息参考<xref linkend=\"sec:"
2511 "undo:bisect\"/>)。 "
2513 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2514 #: ../en/ch01-intro.xml:66
2515 msgid ""
2516 "It will help you to work simultaneously on, and manage the drift between, "
2517 "multiple versions of your project."
2518 msgstr "它能帮助你同时工作于项目的多个版本,并管理它们的差异。"
2520 #. type: Content of: <book><chapter><sect1><sect2><para>
2521 #: ../en/ch01-intro.xml:71
2522 msgid ""
2523 "Most of these reasons are equally valid&emdash;at least in theory&emdash;"
2524 "whether you're working on a project by yourself, or with a hundred other "
2525 "people."
2526 msgstr ""
2527 "大多数这些理由都是等效的&emdash;至少在理论上&emdash;不管你是一个人做项目还是和"
2528 "几百个人一起。"
2530 #. type: Content of: <book><chapter><sect1><sect2><para>
2531 #: ../en/ch01-intro.xml:76
2532 msgid ""
2533 "A key question about the practicality of revision control at these two "
2534 "different scales (<quote>lone hacker</quote> and <quote>huge team</quote>) is "
2535 "how its <emphasis>benefits</emphasis> compare to its <emphasis>costs</"
2536 "emphasis>. A revision control tool that's difficult to understand or use is "
2537 "going to impose a high cost."
2538 msgstr ""
2539 "版本控制在在不同尺度上(<quote>单个黑客</quote>和<quote>一个大项目组</quote>)"
2540 "实践的一个关键问题是它的<emphasis>性价</emphasis>比怎么样。一个很难理解和使用"
2541 "的版本控制工具会让你的代价很高。"
2543 #. type: Content of: <book><chapter><sect1><sect2><para>
2544 #: ../en/ch01-intro.xml:84
2545 msgid ""
2546 "A five-hundred-person project is likely to collapse under its own weight "
2547 "almost immediately without a revision control tool and process. In this case, "
2548 "the cost of using revision control might hardly seem worth considering, since "
2549 "<emphasis>without</emphasis> it, failure is almost guaranteed."
2550 msgstr ""
2551 "如果没有版本控制工具和过程,一个五百人的项目很快就可能就将自己压垮。在这种情况"
2552 "下,版本控制的代价基本上不用考虑,因为没有它,失败几乎是一定的。"
2554 #. type: Content of: <book><chapter><sect1><sect2><para>
2555 #: ../en/ch01-intro.xml:91
2556 msgid ""
2557 "On the other hand, a one-person <quote>quick hack</quote> might seem like a "
2558 "poor place to use a revision control tool, because surely the cost of using "
2559 "one must be close to the overall cost of the project. Right?"
2560 msgstr ""
2561 "另一方面,一个人的<quote>快速编程</quote>看起来并不适合使用版本控制工具,因为"
2562 "使用一个版本控制工具的代价就是整个项目的代价,对吧?"
2564 #. type: Content of: <book><chapter><sect1><sect2><para>
2565 #: ../en/ch01-intro.xml:96
2566 msgid ""
2567 "Mercurial uniquely supports <emphasis>both</emphasis> of these scales of "
2568 "development. You can learn the basics in just a few minutes, and due to its "
2569 "low overhead, you can apply revision control to the smallest of projects with "
2570 "ease. Its simplicity means you won't have a lot of abstruse concepts or "
2571 "command sequences competing for mental space with whatever you're "
2572 "<emphasis>really</emphasis> trying to do. At the same time, Mercurial's high "
2573 "performance and peer-to-peer nature let you scale painlessly to handle large "
2574 "projects."
2575 msgstr ""
2576 "Mercurial的独特之处就是它<emphasis>同时</emphasis>支持这两种尺度的开发。你可以"
2577 "在几分钟之内学会基本的使用,因为代价很小,你可以很方便的在最小的项目上应用版本"
2578 "管理。它的简洁性意味着不会有很多艰深的概念和命令干扰你<emphasis>真正</"
2579 "emphasis>的工作。同时,Mercurial高性能和点对点的特性可以让你轻易的应对大的项"
2580 "目。"
2582 #. type: Content of: <book><chapter><sect1><sect2><para>
2583 #: ../en/ch01-intro.xml:106
2584 msgid ""
2585 "No revision control tool can rescue a poorly run project, but a good choice "
2586 "of tools can make a huge difference to the fluidity with which you can work "
2587 "on a project."
2588 msgstr ""
2589 "没有一个版本控制工具能拯救一个糟糕的项目,但是在项目中选择好的工具会大大的提高"
2590 "效率,正是工欲善其事,必先利其器。"
2592 #. type: Content of: <book><chapter><sect1><sect2><title>
2593 #: ../en/ch01-intro.xml:113
2594 msgid "The many names of revision control"
2595 msgstr "版本控制的别名"
2597 #. type: Content of: <book><chapter><sect1><sect2><para>
2598 #: ../en/ch01-intro.xml:115
2599 msgid ""
2600 "Revision control is a diverse field, so much so that it is referred to by "
2601 "many names and acronyms. Here are a few of the more common variations you'll "
2602 "encounter:"
2603 msgstr ""
2604 "版本控制是一个各自为政的领域,以至于有很多名称和缩略语,下面是你可能遇到的一些"
2605 "常用的术语:"
2607 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2608 #: ../en/ch01-intro.xml:119
2609 msgid "Revision control (RCS)"
2610 msgstr "版本控制(RCS)"
2612 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2613 #: ../en/ch01-intro.xml:120
2614 msgid "Software configuration management (SCM), or configuration management"
2615 msgstr "软件配置管理(SCM),或配置管理"
2617 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2618 #: ../en/ch01-intro.xml:122
2619 msgid "Source code management"
2620 msgstr "源代码管理"
2622 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2623 #: ../en/ch01-intro.xml:123
2624 msgid "Source code control, or source control"
2625 msgstr "源代码控制,或源控制"
2627 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2628 #: ../en/ch01-intro.xml:125
2629 msgid "Version control (VCS)"
2630 msgstr "版本控制(VCS)"
2632 #. type: Content of: <book><chapter><sect1><sect2><para>
2633 #: ../en/ch01-intro.xml:127
2634 msgid ""
2635 "Some people claim that these terms actually have different meanings, but in "
2636 "practice they overlap so much that there's no agreed or even useful way to "
2637 "tease them apart."
2638 msgstr ""
2639 "有些人声称这些术语有不同的含义,但实际上它们的含义太重叠了,根本没有一致的,甚"
2640 "至有用的方式来区别它们。"
2642 #. type: Content of: <book><chapter><sect1><title>
2643 #: ../en/ch01-intro.xml:135
2644 msgid "About the examples in this book"
2645 msgstr "本书的例子"
2647 #. type: Content of: <book><chapter><sect1><para>
2648 #: ../en/ch01-intro.xml:137
2649 msgid ""
2650 "This book takes an unusual approach to code samples. Every example is "
2651 "<quote>live</quote>&emdash;each one is actually the result of a shell script "
2652 "that executes the Mercurial commands you see. Every time an image of the "
2653 "book is built from its sources, all the example scripts are automatically "
2654 "run, and their current results compared against their expected results."
2655 msgstr ""
2657 #. type: Content of: <book><chapter><sect1><para>
2658 #: ../en/ch01-intro.xml:144
2659 msgid ""
2660 "The advantage of this approach is that the examples are always accurate; they "
2661 "describe <emphasis>exactly</emphasis> the behavior of the version of "
2662 "Mercurial that's mentioned at the front of the book. If I update the version "
2663 "of Mercurial that I'm documenting, and the output of some command changes, "
2664 "the build fails."
2665 msgstr ""
2667 #. type: Content of: <book><chapter><sect1><para>
2668 #: ../en/ch01-intro.xml:151
2669 msgid ""
2670 "There is a small disadvantage to this approach, which is that the dates and "
2671 "times you'll see in examples tend to be <quote>squashed</quote> together in a "
2672 "way that they wouldn't be if the same commands were being typed by a human. "
2673 "Where a human can issue no more than one command every few seconds, with any "
2674 "resulting timestamps correspondingly spread out, my automated example scripts "
2675 "run many commands in one second."
2676 msgstr ""
2678 #. type: Content of: <book><chapter><sect1><para>
2679 #: ../en/ch01-intro.xml:159
2680 msgid ""
2681 "As an instance of this, several consecutive commits in an example can show up "
2682 "as having occurred during the same second. You can see this occur in the "
2683 "<literal role=\"hg-ext\">bisect</literal> example in <xref linkend=\"sec:undo:"
2684 "bisect\"/>, for instance."
2685 msgstr ""
2687 #. type: Content of: <book><chapter><sect1><para>
2688 #: ../en/ch01-intro.xml:165
2689 msgid ""
2690 "So when you're reading examples, don't place too much weight on the dates or "
2691 "times you see in the output of commands. But <emphasis>do</emphasis> be "
2692 "confident that the behavior you're seeing is consistent and reproducible."
2693 msgstr ""
2694 "所以当你研究这些例子的时候,不要太注意命令输出的日期和时间。但是<emphasis>要</"
2695 "emphasis>保证你看到的行为是一致的和可以再现的。"
2697 #. type: Content of: <book><chapter><sect1><title>
2698 #: ../en/ch01-intro.xml:173
2699 msgid "Trends in the field"
2700 msgstr "版本控制的发展趋势"
2702 #. type: Content of: <book><chapter><sect1><para>
2703 #: ../en/ch01-intro.xml:175
2704 msgid ""
2705 "There has been an unmistakable trend in the development and use of revision "
2706 "control tools over the past four decades, as people have become familiar with "
2707 "the capabilities of their tools and constrained by their limitations."
2708 msgstr ""
2709 "在过去的四十年中,随着人们越来越熟悉他们的工具的能力和限制,开发和使用版本控制"
2710 "工具出现了明确的趋势。 "
2712 #. type: Content of: <book><chapter><sect1><para>
2713 #: ../en/ch01-intro.xml:180
2714 msgid ""
2715 "The first generation began by managing single files on individual computers. "
2716 "Although these tools represented a huge advance over ad-hoc manual revision "
2717 "control, their locking model and reliance on a single computer limited them "
2718 "to small, tightly-knit teams."
2719 msgstr ""
2720 "在第一代软件开始于在个人计算机上管理单个文件。虽然这些工具比手工管理版本有了巨"
2721 "大的飞跃。但是加锁模型和依赖于单个计算机限制了他们之能用于小的,组织严密的团"
2722 "队。"
2724 #. type: Content of: <book><chapter><sect1><para>
2725 #: ../en/ch01-intro.xml:186
2726 msgid ""
2727 "The second generation loosened these constraints by moving to network-"
2728 "centered architectures, and managing entire projects at a time. As projects "
2729 "grew larger, they ran into new problems. With clients needing to talk to "
2730 "servers very frequently, server scaling became an issue for large projects. "
2731 "An unreliable network connection could prevent remote users from being able "
2732 "to talk to the server at all. As open source projects started making read-"
2733 "only access available anonymously to anyone, people without commit privileges "
2734 "found that they could not use the tools to interact with a project in a "
2735 "natural way, as they could not record their changes."
2736 msgstr ""
2737 "第二代软件因为采用以网络为中心的结构,一次性管理整个项目而放松了这些限制。随着"
2738 "项目增长,又出现了新的问题。客户需要频繁的和服务器交互,服务器的可伸缩性成为大"
2739 "项目的主要问题。不可靠的网络会妨碍客户和服务器的交互。随着开源项目开始开放只读"
2740 "权限给匿名用户,没有提交权限的用户发现他们不能以自然的方式使用工具和项目交互,"
2741 "因为他们不能记录他们的修改。"
2743 #. type: Content of: <book><chapter><sect1><para>
2744 #: ../en/ch01-intro.xml:198
2745 msgid ""
2746 "The current generation of revision control tools is peer-to-peer in nature. "
2747 "All of these systems have dropped the dependency on a single central server, "
2748 "and allow people to distribute their revision control data to where it's "
2749 "actually needed. Collaboration over the Internet has moved from constrained "
2750 "by technology to a matter of choice and consensus. Modern tools can operate "
2751 "offline indefinitely and autonomously, with a network connection only needed "
2752 "when syncing changes with another repository."
2753 msgstr ""
2754 "新一代的版本控制工具本质上是点对点的。所有的这些系统都抛弃了对单个中央服务器的"
2755 "依赖,允许用户发布他们的版本控制数据到任何需要的地方。通过互联网的协作摆脱了技"
2756 "术的限制,走向选择和审查。现代的工具可以进行自治的,不受限制的离线操作。只需要"
2757 "在有网络的时候和其他的版本库同步即可。"
2759 #. type: Content of: <book><chapter><sect1><title>
2760 #: ../en/ch01-intro.xml:210
2761 msgid "A few of the advantages of distributed revision control"
2762 msgstr "分布版本控制的优点"
2764 #. type: Content of: <book><chapter><sect1><para>
2765 #: ../en/ch01-intro.xml:213
2766 msgid ""
2767 "Even though distributed revision control tools have for several years been as "
2768 "robust and usable as their previous-generation counterparts, people using "
2769 "older tools have not yet necessarily woken up to their advantages. There are "
2770 "a number of ways in which distributed tools shine relative to centralised "
2771 "ones."
2772 msgstr ""
2773 "与他们的上一代竞争者相比,虽然分布式版本控制工具多年来已经很稳定和实用了,但是"
2774 "使用旧的工具的人们还没有完全了解它们的优点,分布式的工具在很多方面明显由于集中"
2775 "式的工具。"
2777 #. type: Content of: <book><chapter><sect1><para>
2778 #: ../en/ch01-intro.xml:220
2779 msgid ""
2780 "For an individual developer, distributed tools are almost always much faster "
2781 "than centralised tools. This is for a simple reason: a centralised tool "
2782 "needs to talk over the network for many common operations, because most "
2783 "metadata is stored in a single copy on the central server. A distributed "
2784 "tool stores all of its metadata locally. All else being equal, talking over "
2785 "the network adds overhead to a centralised tool. Don't underestimate the "
2786 "value of a snappy, responsive tool: you're going to spend a lot of time "
2787 "interacting with your revision control software."
2788 msgstr ""
2789 "对于个人开发者,分布式工具几乎永远比集中式工具快的多。原因很简单:集中式工具的"
2790 "很多操作需要网络交互,因为大部分元数据都只在中央服务器上有一份拷贝。而一个分布"
2791 "式工具将所有的元数据保存在本地。其他的相同,通过网络的交互增加了集中式工具的负"
2792 "担。不要低估了反应迅速的工具的价值:你要花很多时间和你的版本控制软件交互。"
2794 #. type: Content of: <book><chapter><sect1><para>
2795 #: ../en/ch01-intro.xml:231
2796 msgid ""
2797 "Distributed tools are indifferent to the vagaries of your server "
2798 "infrastructure, again because they replicate metadata to so many locations. "
2799 "If you use a centralised system and your server catches fire, you'd better "
2800 "hope that your backup media are reliable, and that your last backup was "
2801 "recent and actually worked. With a distributed tool, you have many backups "
2802 "available on every contributor's computer."
2803 msgstr ""
2804 "分布式工具对你的服务器结构并不感冒,因为他们在将元数据复制到很多地方。如果你的"
2805 "集中式系统和你的服务器着火了,你最好希望你的备份介质是可靠的,同时你最后的备份"
2806 "是最近的,而且还能用。而对于分布式工具,你在贡献者的计算机上有很多备份。"
2808 #. type: Content of: <book><chapter><sect1><para>
2809 #: ../en/ch01-intro.xml:239
2810 msgid ""
2811 "The reliability of your network will affect distributed tools far less than "
2812 "it will centralised tools. You can't even use a centralised tool without a "
2813 "network connection, except for a few highly constrained commands. With a "
2814 "distributed tool, if your network connection goes down while you're working, "
2815 "you may not even notice. The only thing you won't be able to do is talk to "
2816 "repositories on other computers, something that is relatively rare compared "
2817 "with local operations. If you have a far-flung team of collaborators, this "
2818 "may be significant."
2819 msgstr ""
2820 "网络的可靠性对分布式工具的影响要远远小于集中式工具。如果没有网络你根本不能使用"
2821 "集中式工具,除了少数几个功能有限命令。而对于分布式工具,即使在你工作的时候网络"
2822 "瘫痪了,你可能根本不会注意到。你不能做的事情仅仅是不能和其它计算机上的版本库交"
2823 "互了,这种事在本地操作相当罕见。而如果你的团队有异地的人员,那这就很有可能了。"
2825 #. type: Content of: <book><chapter><sect1><sect2><title>
2826 #: ../en/ch01-intro.xml:250
2827 msgid "Advantages for open source projects"
2828 msgstr "开源项目的优点"
2830 #. type: Content of: <book><chapter><sect1><sect2><para>
2831 #: ../en/ch01-intro.xml:252
2832 msgid ""
2833 "If you take a shine to an open source project and decide that you would like "
2834 "to start hacking on it, and that project uses a distributed revision control "
2835 "tool, you are at once a peer with the people who consider themselves the "
2836 "<quote>core</quote> of that project. If they publish their repositories, you "
2837 "can immediately copy their project history, start making changes, and record "
2838 "your work, using the same tools in the same ways as insiders. By contrast, "
2839 "with a centralised tool, you must use the software in a <quote>read only</"
2840 "quote> mode unless someone grants you permission to commit changes to their "
2841 "central server. Until then, you won't be able to record changes, and your "
2842 "local modifications will be at risk of corruption any time you try to update "
2843 "your client's view of the repository."
2844 msgstr ""
2845 "如果你喜欢一个开源项目并且决定准备开始改进它,同时这个项目使用分布式版本控制工"
2846 "具的话,你立刻可以和其他人一样认为自己成为项目的<quote>核心</quote>。如果他们"
2847 "发布了他们的版本库,你可以立即拷贝他们的项目。开始修改,记录你自己的工作,和内"
2848 "部人员一样使用同样的工具。相比之下,如果使用集中式工具,除非有人给你向中央服务"
2849 "器提交修改的权限,你只能用只读的方式使用软件。这样,你就不能记录你的修改,而且"
2850 "当你从版本库更新的时候,本地的修改随时有崩溃的可能。 "
2852 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
2853 #: ../en/ch01-intro.xml:268
2854 msgid "The forking non-problem"
2855 msgstr "分叉不是问题"
2857 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
2858 #: ../en/ch01-intro.xml:270
2859 msgid ""
2860 "It has been suggested that distributed revision control tools pose some sort "
2861 "of risk to open source projects because they make it easy to <quote>fork</"
2862 "quote> the development of a project. A fork happens when there are "
2863 "differences in opinion or attitude between groups of developers that cause "
2864 "them to decide that they can't work together any longer. Each side takes a "
2865 "more or less complete copy of the project's source code, and goes off in its "
2866 "own direction."
2867 msgstr ""
2869 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
2870 #: ../en/ch01-intro.xml:280
2871 msgid ""
2872 "Sometimes the camps in a fork decide to reconcile their differences. With a "
2873 "centralised revision control system, the <emphasis>technical</emphasis> "
2874 "process of reconciliation is painful, and has to be performed largely by "
2875 "hand. You have to decide whose revision history is going to <quote>win</"
2876 "quote>, and graft the other team's changes into the tree somehow. This "
2877 "usually loses some or all of one side's revision history."
2878 msgstr ""
2880 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
2881 #: ../en/ch01-intro.xml:289
2882 msgid ""
2883 "What distributed tools do with respect to forking is they make forking the "
2884 "<emphasis>only</emphasis> way to develop a project. Every single change that "
2885 "you make is potentially a fork point. The great strength of this approach is "
2886 "that a distributed revision control tool has to be really good at "
2887 "<emphasis>merging</emphasis> forks, because forks are absolutely fundamental: "
2888 "they happen all the time."
2889 msgstr ""
2891 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
2892 #: ../en/ch01-intro.xml:298
2893 msgid ""
2894 "If every piece of work that everybody does, all the time, is framed in terms "
2895 "of forking and merging, then what the open source world refers to as a "
2896 "<quote>fork</quote> becomes <emphasis>purely</emphasis> a social issue. If "
2897 "anything, distributed tools <emphasis>lower</emphasis> the likelihood of a "
2898 "fork:"
2899 msgstr ""
2901 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
2902 #: ../en/ch01-intro.xml:305
2903 msgid ""
2904 "They eliminate the social distinction that centralised tools impose: that "
2905 "between insiders (people with commit access) and outsiders (people without)."
2906 msgstr ""
2908 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
2909 #: ../en/ch01-intro.xml:309
2910 msgid ""
2911 "They make it easier to reconcile after a social fork, because all that's "
2912 "involved from the perspective of the revision control software is just "
2913 "another merge."
2914 msgstr ""
2916 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
2917 #: ../en/ch01-intro.xml:314
2918 msgid ""
2919 "Some people resist distributed tools because they want to retain tight "
2920 "control over their projects, and they believe that centralised tools give "
2921 "them this control. However, if you're of this belief, and you publish your "
2922 "CVS or Subversion repositories publicly, there are plenty of tools available "
2923 "that can pull out your entire project's history (albeit slowly) and recreate "
2924 "it somewhere that you don't control. So while your control in this case is "
2925 "illusory, you are forgoing the ability to fluidly collaborate with whatever "
2926 "people feel compelled to mirror and fork your history."
2927 msgstr ""
2928 "有些人拒绝分布式工具因为他们想保持对项目的控制,他们相信集中式工具会给他们这种"
2929 "控制。如果你这种想法,并你将CVS或者Subversion版本库向大众发布了,那么别人可用"
2930 "现有的很多工具将整个项目的历史抓取出来(可能很慢),在其它你控制不了的地方重建"
2931 "版本库。这时你的控制只不过是一种幻觉罢了,一些人被迫从你的版本库创建映像和分"
2932 "支,而你失去了和他们协作的机会。"
2934 #. type: Content of: <book><chapter><sect1><sect2><title>
2935 #: ../en/ch01-intro.xml:329
2936 msgid "Advantages for commercial projects"
2937 msgstr "商业项目的优点"
2939 #. type: Content of: <book><chapter><sect1><sect2><para>
2940 #: ../en/ch01-intro.xml:331
2941 msgid ""
2942 "Many commercial projects are undertaken by teams that are scattered across "
2943 "the globe. Contributors who are far from a central server will see slower "
2944 "command execution and perhaps less reliability. Commercial revision control "
2945 "systems attempt to ameliorate these problems with remote-site replication add-"
2946 "ons that are typically expensive to buy and cantankerous to administer. A "
2947 "distributed system doesn't suffer from these problems in the first place. "
2948 "Better yet, you can easily set up multiple authoritative servers, say one per "
2949 "site, so that there's no redundant communication between repositories over "
2950 "expensive long-haul network links."
2951 msgstr ""
2952 "遍布全球的团队正在进行许多商业项目。远离中央服务器的贡献者会发现执行命令速度很"
2953 "慢同时不怎么可靠。商业的版本控制系统改善这个问题的办法就是让你购买远程复制插"
2954 "件,这通常很昂贵,并且很难管理。分布式系统首先不会有这样的问题。其次,你可以很"
2955 "容易的建立多个授权服务器,假设每个站点一个,这样可以避免在昂贵的长途线路上的冗"
2956 "余的通讯。"
2958 #. type: Content of: <book><chapter><sect1><sect2><para>
2959 #: ../en/ch01-intro.xml:343
2960 msgid ""
2961 "Centralised revision control systems tend to have relatively low "
2962 "scalability. It's not unusual for an expensive centralised system to fall "
2963 "over under the combined load of just a few dozen concurrent users. Once "
2964 "again, the typical response tends to be an expensive and clunky replication "
2965 "facility. Since the load on a central server&emdash;if you have one at "
2966 "all&emdash;is many times lower with a distributed tool (because all of the "
2967 "data is replicated everywhere), a single cheap server can handle the needs of "
2968 "a much larger team, and replication to balance load becomes a simple matter "
2969 "of scripting."
2970 msgstr ""
2971 "集中式的版本控制系统的扩展性相对较低。只要不多的并行用户的组合负载就可以将一个"
2972 "昂贵的中央服务器压垮。同样,典型的反应就是昂贵笨重的复制设备。因为中央服务器的"
2973 "最大负载&emdash;如果你有的话&emdash;比分布式工具低很多(因为所有的数据要北复制"
2974 "到其它地方),一个廉价的服务器就可以满足一个相当大的团队的要求,为平衡负载而进"
2975 "行的复制只需要简单的脚本就够了。"
2977 #. type: Content of: <book><chapter><sect1><sect2><para>
2978 #: ../en/ch01-intro.xml:355
2979 msgid ""
2980 "If you have an employee in the field, troubleshooting a problem at a "
2981 "customer's site, they'll benefit from distributed revision control. The tool "
2982 "will let them generate custom builds, try different fixes in isolation from "
2983 "each other, and search efficiently through history for the sources of bugs "
2984 "and regressions in the customer's environment, all without needing to connect "
2985 "to your company's network."
2986 msgstr ""
2987 "如果你有员工需要在客户方解决问题,那么他们会受益于分布式版本控制。工具允许他们"
2988 "创建定制的环境,互相独立的尝试不同的解决方案。并且可以高效的从历史代码中查找"
2989 "bug的根源,在客户环境中进行回归,所有的这些都不需要连接公司的网络。"
2991 #. type: Content of: <book><chapter><sect1><title>
2992 #: ../en/ch01-intro.xml:366
2993 msgid "Why choose Mercurial?"
2994 msgstr "为什么选择 Mercurial?"
2996 #. type: Content of: <book><chapter><sect1><para>
2997 #: ../en/ch01-intro.xml:368
2998 msgid ""
2999 "Mercurial has a unique set of properties that make it a particularly good "
3000 "choice as a revision control system."
3001 msgstr "Mercurial是一个非常好的版本控制系统,因为它有很多独一无二的特点。"
3003 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
3004 #: ../en/ch01-intro.xml:371
3005 msgid "It is easy to learn and use."
3006 msgstr "它易学易用。"
3008 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
3009 #: ../en/ch01-intro.xml:372
3010 msgid "It is lightweight."
3011 msgstr "它轻量级。"
3013 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
3014 #: ../en/ch01-intro.xml:373
3015 msgid "It scales excellently."
3016 msgstr "它扩展性很好。"
3018 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
3019 #: ../en/ch01-intro.xml:374
3020 msgid "It is easy to customise."
3021 msgstr "它很容易定制。"
3023 #. type: Content of: <book><chapter><sect1><para>
3024 #: ../en/ch01-intro.xml:377
3025 msgid ""
3026 "If you are at all familiar with revision control systems, you should be able "
3027 "to get up and running with Mercurial in less than five minutes. Even if not, "
3028 "it will take no more than a few minutes longer. Mercurial's command and "
3029 "feature sets are generally uniform and consistent, so you can keep track of a "
3030 "few general rules instead of a host of exceptions."
3031 msgstr ""
3032 "如果你熟悉版本控制系统,你在五分钟之内只能就可以使用Mercurial工作了。即使你不"
3033 "熟悉,也不过是再多花几分钟。Mercurial的命令和功能集非常统一一致,你只要遵守几"
3034 "个通用的规则就够了,很少有例外。"
3036 #. type: Content of: <book><chapter><sect1><para>
3037 #: ../en/ch01-intro.xml:384
3038 msgid ""
3039 "On a small project, you can start working with Mercurial in moments. Creating "
3040 "new changes and branches; transferring changes around (whether locally or "
3041 "over a network); and history and status operations are all fast. Mercurial "
3042 "attempts to stay nimble and largely out of your way by combining low "
3043 "cognitive overhead with blazingly fast operations."
3044 msgstr ""
3045 "在很小的项目上,你马上就可以使用Mercurial开始工作。创建新的修改和分支;到处交"
3046 "换修改(不管本机还是通过网络);获取历史和状态数据非常快。Mercurial努力保持小"
3047 "巧灵活,在眨眼之间就能完成操作。"
3049 #. type: Content of: <book><chapter><sect1><para>
3050 #: ../en/ch01-intro.xml:391
3051 msgid ""
3052 "The usefulness of Mercurial is not limited to small projects: it is used by "
3053 "projects with hundreds to thousands of contributors, each containing tens of "
3054 "thousands of files and hundreds of megabytes of source code."
3055 msgstr ""
3056 "不仅小的项目可以使用Mercurial:有成百上千的贡献者的项目也在使用它,这些项目每"
3057 "个都有上万个文件和几百兆的源码。"
3059 #. type: Content of: <book><chapter><sect1><para>
3060 #: ../en/ch01-intro.xml:396
3061 msgid ""
3062 "If the core functionality of Mercurial is not enough for you, it's easy to "
3063 "build on. Mercurial is well suited to scripting tasks, and its clean "
3064 "internals and implementation in Python make it easy to add features in the "
3065 "form of extensions. There are a number of popular and useful extensions "
3066 "already available, ranging from helping to identify bugs to improving "
3067 "performance."
3068 msgstr ""
3069 "如果觉得Mercurial的核心功能不能满足要求,你很容易在现有基础上开发。Mercurial非"
3070 "常适合于脚本任务,它的核心简洁,并且用Python实现,用扩展的方式增加新的功能非常"
3071 "方便,现在已经有很多流行和有用的扩展了,像帮助你确定bug或者提高性能等。"
3073 #. type: Content of: <book><chapter><sect1><title>
3074 #: ../en/ch01-intro.xml:406
3075 msgid "Mercurial compared with other tools"
3076 msgstr "Mercurial 与其它工具的比较"
3078 #. type: Content of: <book><chapter><sect1><para>
3079 #: ../en/ch01-intro.xml:408
3080 msgid ""
3081 "Before you read on, please understand that this section necessarily reflects "
3082 "my own experiences, interests, and (dare I say it) biases. I have used every "
3083 "one of the revision control tools listed below, in most cases for several "
3084 "years at a time."
3085 msgstr ""
3086 "在你继续阅读之前,请理解本节完全反映了我的个人经验,兴趣,和偏好(我敢说)。下"
3087 "面列的每个版本控制工具我都使用过,大多数情况下都用过好几年。"
3089 #. type: Content of: <book><chapter><sect1><sect2><para>
3090 #: ../en/ch01-intro.xml:418
3091 msgid ""
3092 "Subversion is a popular revision control tool, developed to replace CVS. It "
3093 "has a centralised client/server architecture."
3094 msgstr ""
3095 "Subversion是一个流行的版本控制工具,是用来替代CVS的,它采用的是集中式的客户/服"
3096 "务器结构。"
3098 #. type: Content of: <book><chapter><sect1><sect2><para>
3099 #: ../en/ch01-intro.xml:422
3100 msgid ""
3101 "Subversion and Mercurial have similarly named commands for performing the "
3102 "same operations, so if you're familiar with one, it is easy to learn to use "
3103 "the other. Both tools are portable to all popular operating systems."
3104 msgstr ""
3105 "Subversion和Mercurial相同操作的命令的命名上非常相似,所以如果你熟悉一个,很容"
3106 "易学会另外一个,两个工具都可以在大多数平台上运行。"
3108 #. type: Content of: <book><chapter><sect1><sect2><para>
3109 #: ../en/ch01-intro.xml:427
3110 msgid ""
3111 "Prior to version 1.5, Subversion had no useful support for merges. At the "
3112 "time of writing, its merge tracking capability is new, and known to be <ulink "
3113 "url=\"http://svnbook.red-bean.com/nightly/en/svn.branchmerge.advanced."
3114 "html#svn.branchmerge.advanced.finalword\">complicated and buggy</ulink>."
3115 msgstr ""
3116 "在1.5版之前,Subversion对合并的支持并不好。在我写本书的时候,它刚新增了并跟踪"
3117 "的功能,出名的<ulink url=\"http://svnbook.red-bean.com/nightly/en/svn."
3118 "branchmerge.advanced.html#svn.branchmerge.advanced.finalword\">复杂和容易出错"
3119 "</ulink>。"
3121 #. type: Content of: <book><chapter><sect1><sect2><para>
3122 #: ../en/ch01-intro.xml:433
3123 msgid ""
3124 "Mercurial has a substantial performance advantage over Subversion on every "
3125 "revision control operation I have benchmarked. I have measured its advantage "
3126 "as ranging from a factor of two to a factor of six when compared with "
3127 "Subversion 1.4.3's <emphasis>ra_local</emphasis> file store, which is the "
3128 "fastest access method available. In more realistic deployments involving a "
3129 "network-based store, Subversion will be at a substantially larger "
3130 "disadvantage. Because many Subversion commands must talk to the server and "
3131 "Subversion does not have useful replication facilities, server capacity and "
3132 "network bandwidth become bottlenecks for modestly large projects."
3133 msgstr ""
3134 "在我测量过的每个版本控制操作上Mercurial都比Subversion有很大的性能优势。差距从"
3135 "两个数量级到六个数量级不等,我用的是Subversion 1.4.3的<emphasis>ra_local</"
3136 "emphasis>文件存储方式,这是已知的最快的存取方式了。在实际的部署中包括网络存"
3137 "储,那么Subversion的劣势更大。因为很多Subversion命令必须和主机交互,并且因为"
3138 "Subversion没有好的复制机制,使得对于中的等大小的项目而言,服务器容量和网络带宽"
3139 "成为主要瓶颈。"
3141 #. type: Content of: <book><chapter><sect1><sect2><para>
3142 #: ../en/ch01-intro.xml:446
3143 msgid ""
3144 "Additionally, Subversion incurs substantial storage overhead to avoid network "
3145 "transactions for a few common operations, such as finding modified files "
3146 "(<literal>status</literal>) and displaying modifications against the current "
3147 "revision (<literal>diff</literal>). As a result, a Subversion working copy "
3148 "is often the same size as, or larger than, a Mercurial repository and working "
3149 "directory, even though the Mercurial repository contains a complete history "
3150 "of the project."
3151 msgstr ""
3152 "另外,Subversion以在客户端使用了更多存储空间的方法,换取降低几个常用操作的网络"
3153 "负载,例如查找修改过的文件(<literal>status</literal>)和显示对于当前版本的更"
3154 "改(<literal>diff</literal>)。结果Subversion的工作副本经常和Mercurial的版本库"
3155 "和工作目录一样大,或者更大,虽然Mercurial的版本库包括了项目的完整历史。"
3157 #. type: Content of: <book><chapter><sect1><sect2><para>
3158 #: ../en/ch01-intro.xml:456
3159 msgid ""
3160 "Subversion is widely supported by third party tools. Mercurial currently "
3161 "lags considerably in this area. This gap is closing, however, and indeed "
3162 "some of Mercurial's GUI tools now outshine their Subversion equivalents. "
3163 "Like Mercurial, Subversion has an excellent user manual."
3164 msgstr ""
3165 "Subversion有很多的第三方工具支持。Mercurial现在在这方面稍微欠缺。然而差距正在"
3166 "逐渐缩小,实际上一些有Mercurial的GUI工具比Subversion类似工具还略胜一筹。和"
3167 "Mercurial一样,Subversion也有完善的用户手册。"
3169 #. type: Content of: <book><chapter><sect1><sect2><para>
3170 #: ../en/ch01-intro.xml:462
3171 msgid ""
3172 "Because Subversion doesn't store revision history on the client, it is well "
3173 "suited to managing projects that deal with lots of large, opaque binary "
3174 "files. If you check in fifty revisions to an incompressible 10MB file, "
3175 "Subversion's client-side space usage stays constant The space used by any "
3176 "distributed SCM will grow rapidly in proportion to the number of revisions, "
3177 "because the differences between each revision are large."
3178 msgstr ""
3179 "Subversion并不在客户端存储版本历史,所以它很适合管理那些有很多大的二进制文件的"
3180 "项目。如果你对一个未压缩的10MB文件检入了五十次,Subversion客户端的占用的磁盘空"
3181 "间基本上保持不变。而对于分布式SCM软件,磁盘空间会随着版本数量的增加成而迅速增"
3182 "长,因为每个版本之间的差异非常大。"
3184 #. type: Content of: <book><chapter><sect1><sect2><para>
3185 #: ../en/ch01-intro.xml:471
3186 msgid ""
3187 "In addition, it's often difficult or, more usually, impossible to merge "
3188 "different versions of a binary file. Subversion's ability to let a user lock "
3189 "a file, so that they temporarily have the exclusive right to commit changes "
3190 "to it, can be a significant advantage to a project where binary files are "
3191 "widely used."
3192 msgstr ""
3193 "另外,合并不同版本的二进制文件非常困难,换句话说,基本上不可能。Subversion提供"
3194 "了锁定功能,用户可以锁定一个文件,这样他就取得了对这个文件临时的独占的提交权,"
3195 "这对于广泛使用二进制文件的项目而言是个明显优势。"
3197 #. type: Content of: <book><chapter><sect1><sect2><para>
3198 #: ../en/ch01-intro.xml:478
3199 msgid ""
3200 "Mercurial can import revision history from a Subversion repository. It can "
3201 "also export revision history to a Subversion repository. This makes it easy "
3202 "to <quote>test the waters</quote> and use Mercurial and Subversion in "
3203 "parallel before deciding to switch. History conversion is incremental, so "
3204 "you can perform an initial conversion, then small additional conversions "
3205 "afterwards to bring in new changes."
3206 msgstr ""
3207 "Mercurial可以从Subversion的版本库中导入历史版本。它也可以向Subversion的版本库"
3208 "输出历史版本。这样在决定转换之前很容易先<quote>试一下水</quote>,同时并行的使"
3209 "用Mercurial和Subversion。版本史的转换是递增的,你可以先构造一个初始版本,每次"
3210 "有了新的更改后加入一个小的转换。"
3212 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
3213 #: ../en/ch01-intro.xml:490 ../en/ch01-intro.xml:629
3214 msgid "Git"
3215 msgstr "Git"
3217 #. type: Content of: <book><chapter><sect1><sect2><para>
3218 #: ../en/ch01-intro.xml:492
3219 msgid ""
3220 "Git is a distributed revision control tool that was developed for managing "
3221 "the Linux kernel source tree. Like Mercurial, its early design was somewhat "
3222 "influenced by Monotone."
3223 msgstr ""
3224 "Git是为了管理Linux内核代码而开发的一个分布式版本控制工具。它和Mercurial一样在"
3225 "设计上受了Monotone的影响。"
3227 #. type: Content of: <book><chapter><sect1><sect2><para>
3228 #: ../en/ch01-intro.xml:497
3229 msgid ""
3230 "Git has a very large command set, with version 1.5.0 providing 139 individual "
3231 "commands. It has something of a reputation for being difficult to learn. "
3232 "Compared to Git, Mercurial has a strong focus on simplicity."
3233 msgstr ""
3234 "Git有非常大的命令集,1.5.0版本提供了139个单独的命令。它以难学而闻名于世。与Git"
3235 "相比,Mercurial力求简洁。"
3237 #. type: Content of: <book><chapter><sect1><sect2><para>
3238 #: ../en/ch01-intro.xml:502
3239 msgid ""
3240 "In terms of performance, Git is extremely fast. In several cases, it is "
3241 "faster than Mercurial, at least on Linux, while Mercurial performs better on "
3242 "other operations. However, on Windows, the performance and general level of "
3243 "support that Git provides is, at the time of writing, far behind that of "
3244 "Mercurial."
3245 msgstr ""
3246 "就性能而言,Git非常快。在很多情况下它都比Mercurial快,至少是在Linux上,但"
3247 "Mercurial在其它操作上有优势。而在Windows上,Git不管是性能还是提供的支持,都比"
3248 "Mercurial差很多,至少在本书写作的时候是这样。"
3250 #. type: Content of: <book><chapter><sect1><sect2><para>
3251 #: ../en/ch01-intro.xml:509
3252 msgid ""
3253 "While a Mercurial repository needs no maintenance, a Git repository requires "
3254 "frequent manual <quote>repacks</quote> of its metadata. Without these, "
3255 "performance degrades, while space usage grows rapidly. A server that "
3256 "contains many Git repositories that are not rigorously and frequently "
3257 "repacked will become heavily disk-bound during backups, and there have been "
3258 "instances of daily backups taking far longer than 24 hours as a result. A "
3259 "freshly packed Git repository is slightly smaller than a Mercurial "
3260 "repository, but an unpacked repository is several orders of magnitude larger."
3261 msgstr ""
3262 "Mercurial的版本库不需要维护,但Git的版本库需要频繁的手工维护,将其元数据"
3263 "<quote>repacks</quote>,如果不这样做,性能就会下降,磁盘空间也会迅速增加。有多"
3264 "个Git版本库的服务器需要严格和频繁的重新打包,否则在备份的时候就会成为严重的瓶"
3265 "颈,曾经有过运行每日备份超过24小时的例子。一个新打包的Git版本库比Mercurial稍小"
3266 "一些,但是未打包的版本库则会大几个数量级。"
3268 #. type: Content of: <book><chapter><sect1><sect2><para>
3269 #: ../en/ch01-intro.xml:520
3270 msgid ""
3271 "The core of Git is written in C. Many Git commands are implemented as shell "
3272 "or Perl scripts, and the quality of these scripts varies widely. I have "
3273 "encountered several instances where scripts charged along blindly in the "
3274 "presence of errors that should have been fatal."
3275 msgstr ""
3276 "Git的核心由C语言编写,许多Git命令是用shell或者perl脚本实现的,这些脚本的质量差"
3277 "别很大。我碰到过好几次这样的情况,明明已经出现了致命错误了,脚本还在盲目的执"
3278 "行。"
3280 #. type: Content of: <book><chapter><sect1><sect2><para>
3281 #: ../en/ch01-intro.xml:526
3282 msgid "Mercurial can import revision history from a Git repository."
3283 msgstr "Mercurial可以从Git的版本库中导入版本历史。"
3285 #. type: Content of: <book><chapter><sect1><sect2><para>
3286 #: ../en/ch01-intro.xml:534
3287 msgid ""
3288 "CVS is probably the most widely used revision control tool in the world. Due "
3289 "to its age and internal untidiness, it has been only lightly maintained for "
3290 "many years."
3291 msgstr ""
3292 "CVS可能是世界上使用最广泛的版本控制工具。因为它是太古老和内部实现很混乱,许多"
3293 "年来都处于维护状态。"
3295 #. type: Content of: <book><chapter><sect1><sect2><para>
3296 #: ../en/ch01-intro.xml:538
3297 msgid ""
3298 "It has a centralised client/server architecture. It does not group related "
3299 "file changes into atomic commits, making it easy for people to <quote>break "
3300 "the build</quote>: one person can successfully commit part of a change and "
3301 "then be blocked by the need for a merge, causing other people to see only a "
3302 "portion of the work they intended to do. This also affects how you work with "
3303 "project history. If you want to see all of the modifications someone made as "
3304 "part of a task, you will need to manually inspect the descriptions and "
3305 "timestamps of the changes made to each file involved (if you even know what "
3306 "those files were)."
3307 msgstr ""
3308 "CVS采用的是集中式客户/服务器结构。它不会将相关的文件变更一起作为原子提交,这使"
3309 "得它很容易<quote>破坏构建</quote>:一个人成功的提交了一部分更改,然后要停下来"
3310 "处理合并,这使得其他人只能看见他们的部分工作。这样也会影响你和项目历史的工作方"
3311 "式。如果你想看到其他人针对他的那部分任务做的全部修改,你必须手动检查每个受影响"
3312 "的文件的变更描述和时间戳(假如你知道是哪些文件)。"
3314 #. type: Content of: <book><chapter><sect1><sect2><para>
3315 #: ../en/ch01-intro.xml:550
3316 msgid ""
3317 "CVS has a muddled notion of tags and branches that I will not attempt to even "
3318 "describe. It does not support renaming of files or directories well, making "
3319 "it easy to corrupt a repository. It has almost no internal consistency "
3320 "checking capabilities, so it is usually not even possible to tell whether or "
3321 "how a repository is corrupt. I would not recommend CVS for any project, "
3322 "existing or new."
3323 msgstr ""
3324 "CVS的分支和标签的概念实在是太混乱了,我都不想给你介绍。它也不支持文件和目录的"
3325 "重命名。这使得版本库非常容易崩溃。它几乎没任何的内部一致性检查功能,所以通常你"
3326 "不可能知道版本库是不是崩溃了。不管是新项目还是老项目,我都不推荐使用CVS。"
3328 #. type: Content of: <book><chapter><sect1><sect2><para>
3329 #: ../en/ch01-intro.xml:558
3330 msgid ""
3331 "Mercurial can import CVS revision history. However, there are a few caveats "
3332 "that apply; these are true of every other revision control tool's CVS "
3333 "importer, too. Due to CVS's lack of atomic changes and unversioned "
3334 "filesystem hierarchy, it is not possible to reconstruct CVS history "
3335 "completely accurately; some guesswork is involved, and renames will usually "
3336 "not show up. Because a lot of advanced CVS administration has to be done by "
3337 "hand and is hence error-prone, it's common for CVS importers to run into "
3338 "multiple problems with corrupted repositories (completely bogus revision "
3339 "timestamps and files that have remained locked for over a decade are just two "
3340 "of the less interesting problems I can recall from personal experience)."
3341 msgstr ""
3342 "Mercurial可以导入CVS的版本历史。然而,这里面有很多限制;对其版本控制工具的CVS"
3343 "导入程序也是一样。因为CVS缺少原子更改并且不支持文件系统层次的版本控制,所以不"
3344 "可能完全精确的重建CVS的历史。有些需要猜测,重命名通常发现不了。因为CVS的很多的"
3345 "高级管理功能必须手动完成,因此非常容易出错。碰到崩溃的版本库,CVS导入程序通常"
3346 "会出现很多问题(完全伪造的版本时间戳,若干文件被锁定十多年,这是我个人经历的两"
3347 "个不太有趣的问题)。"
3349 #. type: Content of: <book><chapter><sect1><sect2><para>
3350 #: ../en/ch01-intro.xml:572
3351 msgid "Mercurial can import revision history from a CVS repository."
3352 msgstr "Mercurial可以从CVS版本库导入版本历史。"
3354 #. type: Content of: <book><chapter><sect1><sect2><title>
3355 #: ../en/ch01-intro.xml:578
3356 msgid "Commercial tools"
3357 msgstr "商业工具"
3359 #. type: Content of: <book><chapter><sect1><sect2><para>
3360 #: ../en/ch01-intro.xml:580
3361 msgid ""
3362 "Perforce has a centralised client/server architecture, with no client-side "
3363 "caching of any data. Unlike modern revision control tools, Perforce requires "
3364 "that a user run a command to inform the server about every file they intend "
3365 "to edit."
3366 msgstr ""
3367 "Perforce采用的是集中式客户/服务器结构,客户端不缓存任何数据。和现代的版本控制"
3368 "工具不同,每次想要编辑的一个文件,用户必须运行一个命令通知Perforce服务器。"
3370 #. type: Content of: <book><chapter><sect1><sect2><para>
3371 #: ../en/ch01-intro.xml:586
3372 msgid ""
3373 "The performance of Perforce is quite good for small teams, but it falls off "
3374 "rapidly as the number of users grows beyond a few dozen. Modestly large "
3375 "Perforce installations require the deployment of proxies to cope with the "
3376 "load their users generate."
3377 msgstr ""
3378 "对于小的团队而言,Perforce相当好,但是当用户数目超过数十个以后,性能急剧下降。"
3379 "中等大小Perforce安装需要部署代理来处理用户产生的负载。"
3381 #. type: Content of: <book><chapter><sect1><sect2><title>
3382 #: ../en/ch01-intro.xml:595
3383 msgid "Choosing a revision control tool"
3384 msgstr "选择版本控制工具"
3386 #. type: Content of: <book><chapter><sect1><sect2><para>
3387 #: ../en/ch01-intro.xml:597
3388 msgid ""
3389 "With the exception of CVS, all of the tools listed above have unique "
3390 "strengths that suit them to particular styles of work. There is no single "
3391 "revision control tool that is best in all situations."
3392 msgstr ""
3393 "除了CVS之外,以上列出的所有工具都各有所长,没有一个版本控制工具适合所有情况。"
3395 #. type: Content of: <book><chapter><sect1><sect2><para>
3396 #: ../en/ch01-intro.xml:602
3397 msgid ""
3398 "As an example, Subversion is a good choice for working with frequently edited "
3399 "binary files, due to its centralised nature and support for file locking."
3400 msgstr ""
3401 "比如说,因为采用集中式的结构并且支持文件锁定,Subversion非常适合频繁编辑二进制"
3402 "文件的场合。"
3404 #. type: Content of: <book><chapter><sect1><sect2><para>
3405 #: ../en/ch01-intro.xml:606
3406 msgid ""
3407 "I personally find Mercurial's properties of simplicity, performance, and good "
3408 "merge support to be a compelling combination that has served me well for "
3409 "several years."
3410 msgstr ""
3411 "我已经使用Mercurial很多年了,个人认为它有简洁,高性能,良好的合并支持诸多特"
3412 "点。"
3414 #. type: Content of: <book><chapter><sect1><title>
3415 #: ../en/ch01-intro.xml:614
3416 msgid "Switching from another tool to Mercurial"
3417 msgstr "从其它工具切换到 Mercurial"
3419 #. type: Content of: <book><chapter><sect1><para>
3420 #: ../en/ch01-intro.xml:616
3421 msgid ""
3422 "Mercurial is bundled with an extension named <literal role=\"hg-ext"
3423 "\">convert</literal>, which can incrementally import revision history from "
3424 "several other revision control tools. By <quote>incremental</quote>, I mean "
3425 "that you can convert all of a project's history to date in one go, then rerun "
3426 "the conversion later to obtain new changes that happened after the initial "
3427 "conversion."
3428 msgstr ""
3429 "Mercurial包括一个叫<literal role=\"hg-ext\">convert</literal>的扩展,它可以递"
3430 "增的从几个其他的版本控制工具导入版本历史。 <quote>增量</quote>的意思是你可以在"
3431 "某天将整个项目历史转换,以后再次进行转换获得初始版本以后新增的变更。"
3433 #. type: Content of: <book><chapter><sect1><para>
3434 #: ../en/ch01-intro.xml:624
3435 msgid ""
3436 "The revision control tools supported by <literal role=\"hg-ext\">convert</"
3437 "literal> are as follows:"
3438 msgstr "<literal role=\"hg-ext\">convert</literal> 支持的版本控制工具有:"
3440 #. type: Content of: <book><chapter><sect1><para>
3441 #: ../en/ch01-intro.xml:632
3442 msgid ""
3443 "In addition, <literal role=\"hg-ext\">convert</literal> can export changes "
3444 "from Mercurial to Subversion. This makes it possible to try Subversion and "
3445 "Mercurial in parallel before committing to a switchover, without risking the "
3446 "loss of any work."
3447 msgstr ""
3448 "另外<literal role=\"hg-ext\">convert</literal>可以从Mercurial向Subversion导出"
3449 "历史,这可以让你在切换之前让Mercurial和Subversion并行工作,而不会丢失任何工"
3450 "作。"
3452 #. type: Content of: <book><chapter><sect1><para>
3453 #: ../en/ch01-intro.xml:638
3454 msgid ""
3455 "The <command role=\"hg-ext-convert\">convert</command> command is easy to "
3456 "use. Simply point it at the path or URL of the source repository, optionally "
3457 "give it the name of the destination repository, and it will start working. "
3458 "After the initial conversion, just run the same command again to import new "
3459 "changes."
3460 msgstr ""
3461 "<command role=\"hg-ext-convert\">convert</command>命令非常简单。只要给出源版本"
3462 "库的URL或者路径,给出目标版本库的名称(可选),它就开始工作了。第一次转换之"
3463 "后,只要运行同样的命令就可以导入新的变更。"
3465 #. type: Content of: <book><chapter><sect1><title>
3466 #: ../en/ch01-intro.xml:647
3467 msgid "A short history of revision control"
3468 msgstr "版本控制简史"
3470 #. type: Content of: <book><chapter><sect1><para>
3471 #: ../en/ch01-intro.xml:649
3472 msgid ""
3473 "The best known of the old-time revision control tools is SCCS (Source Code "
3474 "Control System), which Marc Rochkind wrote at Bell Labs, in the early 1970s. "
3475 "SCCS operated on individual files, and required every person working on a "
3476 "project to have access to a shared workspace on a single system. Only one "
3477 "person could modify a file at any time; arbitration for access to files was "
3478 "via locks. It was common for people to lock files, and later forget to "
3479 "unlock them, preventing anyone else from modifying those files without the "
3480 "help of an administrator."
3481 msgstr ""
3482 "最有名史前的版本控制工具是SCCS(源代码控制系统),它是由Marc Rochkind于七十年"
3483 "代在贝尔实验室完成的。SCCS只能控制单个文件,这就要求项目组人员只能使用一个系统"
3484 "上的共享工作空间。任何时候一个文件只能由一个人修改;通过加锁来保证。人们很容易"
3485 "锁定一个文件,然后忘了解锁,没有管理员的帮助,任何人都不能修改那些文件。"
3487 #. type: Content of: <book><chapter><sect1><para>
3488 #: ../en/ch01-intro.xml:660
3489 msgid ""
3490 "Walter Tichy developed a free alternative to SCCS in the early 1980s; he "
3491 "called his program RCS (Revision Control System). Like SCCS, RCS required "
3492 "developers to work in a single shared workspace, and to lock files to prevent "
3493 "multiple people from modifying them simultaneously."
3494 msgstr ""
3495 "Walter Tichy在八十年代早期开发了一个开源的SCCS替代软件;他称之RCS(版本控制系"
3496 "统)。和SCCS一样,RCS要求开发人员在一个共享的工作空间工作,同时锁定文件,以防"
3497 "止多个人他同时修改。"
3499 #. type: Content of: <book><chapter><sect1><para>
3500 #: ../en/ch01-intro.xml:666
3501 msgid ""
3502 "Later in the 1980s, Dick Grune used RCS as a building block for a set of "
3503 "shell scripts he initially called cmt, but then renamed to CVS (Concurrent "
3504 "Versions System). The big innovation of CVS was that it let developers work "
3505 "simultaneously and somewhat independently in their own personal workspaces. "
3506 "The personal workspaces prevented developers from stepping on each other's "
3507 "toes all the time, as was common with SCCS and RCS. Each developer had a copy "
3508 "of every project file, and could modify their copies independently. They had "
3509 "to merge their edits prior to committing changes to the central repository."
3510 msgstr ""
3511 "八十年代后期,Dick Grune在RCS的基础上开发了一套脚本,他开始称之为cmt,后来又改"
3512 "名为CVS(并行版本系统)。CVS的最大的创新在于让开发人员可以在自己的工作空间里同"
3513 "时而且独立的工作。私人的工作空间防止了开发人员总是互相干扰,这在SCCS和RCS的使"
3514 "用中很常见。项目中的每个文件,开发者都有自己的拷贝,可以独立的修改自己的拷贝。"
3515 "他们可以在提交到中央版本库之前合并更改。"
3517 #. type: Content of: <book><chapter><sect1><para>
3518 #: ../en/ch01-intro.xml:677
3519 msgid ""
3520 "Brian Berliner took Grune's original scripts and rewrote them in C, releasing "
3521 "in 1989 the code that has since developed into the modern version of CVS. "
3522 "CVS subsequently acquired the ability to operate over a network connection, "
3523 "giving it a client/server architecture. CVS's architecture is centralised; "
3524 "only the server has a copy of the history of the project. Client workspaces "
3525 "just contain copies of recent versions of the project's files, and a little "
3526 "metadata to tell them where the server is. CVS has been enormously "
3527 "successful; it is probably the world's most widely used revision control "
3528 "system."
3529 msgstr "Brian Berliner接管了Grune的脚本,并且用C重写了一遍,在1989年发布了这些代码,"
3530 "从那时起逐渐发展成现在的CVS。CVS随后增加了通过网络操作的功能,形成了客户/服务器结构。"
3531 "CVS的结构是集中式的;仅在服务器上保存一份项目的历史拷贝。客户工作空间仅仅包含项目"
3532 "中的文件的最近版本的拷贝,一些元数据告诉他们服务器的地址。CVS获得了极大成功;它可能是"
3533 "世界上应用最广泛的版本控制系统。"
3535 #. type: Content of: <book><chapter><sect1><para>
3536 #: ../en/ch01-intro.xml:688
3537 msgid ""
3538 "In the early 1990s, Sun Microsystems developed an early distributed revision "
3539 "control system, called TeamWare. A TeamWare workspace contains a complete "
3540 "copy of the project's history. TeamWare has no notion of a central "
3541 "repository. (CVS relied upon RCS for its history storage; TeamWare used "
3542 "SCCS.)"
3543 msgstr ""
3545 #. type: Content of: <book><chapter><sect1><para>
3546 #: ../en/ch01-intro.xml:695
3547 msgid ""
3548 "As the 1990s progressed, awareness grew of a number of problems with CVS. It "
3549 "records simultaneous changes to multiple files individually, instead of "
3550 "grouping them together as a single logically atomic operation. It does not "
3551 "manage its file hierarchy well; it is easy to make a mess of a repository by "
3552 "renaming files and directories. Worse, its source code is difficult to read "
3553 "and maintain, which made the <quote>pain level</quote> of fixing these "
3554 "architectural problems prohibitive."
3555 msgstr ""
3557 #. type: Content of: <book><chapter><sect1><para>
3558 #: ../en/ch01-intro.xml:705
3559 msgid ""
3560 "In 2001, Jim Blandy and Karl Fogel, two developers who had worked on CVS, "
3561 "started a project to replace it with a tool that would have a better "
3562 "architecture and cleaner code. The result, Subversion, does not stray from "
3563 "CVS's centralised client/server model, but it adds multi-file atomic commits, "
3564 "better namespace management, and a number of other features that make it a "
3565 "generally better tool than CVS. Since its initial release, it has rapidly "
3566 "grown in popularity."
3567 msgstr ""
3569 #. type: Content of: <book><chapter><sect1><para>
3570 #: ../en/ch01-intro.xml:714
3571 msgid ""
3572 "More or less simultaneously, Graydon Hoare began working on an ambitious "
3573 "distributed revision control system that he named Monotone. While Monotone "
3574 "addresses many of CVS's design flaws and has a peer-to-peer architecture, it "
3575 "goes beyond earlier (and subsequent) revision control tools in a number of "
3576 "innovative ways. It uses cryptographic hashes as identifiers, and has an "
3577 "integral notion of <quote>trust</quote> for code from different sources."
3578 msgstr ""
3580 #. type: Content of: <book><chapter><sect1><para>
3581 #: ../en/ch01-intro.xml:723
3582 msgid ""
3583 "Mercurial began life in 2005. While a few aspects of its design are "
3584 "influenced by Monotone, Mercurial focuses on ease of use, high performance, "
3585 "and scalability to very large projects."
3586 msgstr ""
3588 #. type: Content of: <book><chapter><title>
3589 #: ../en/ch02-tour-basic.xml:5
3590 msgid "A tour of Mercurial: the basics"
3591 msgstr "Mercurial 教程: 基础知识"
3593 #. type: Content of: <book><chapter><sect1><title>
3594 #: ../en/ch02-tour-basic.xml:8
3595 msgid "Installing Mercurial on your system"
3596 msgstr "安装 Mercurial"
3598 #. type: Content of: <book><chapter><sect1><para>
3599 #: ../en/ch02-tour-basic.xml:10
3600 msgid ""
3601 "Prebuilt binary packages of Mercurial are available for every popular "
3602 "operating system. These make it easy to start using Mercurial on your "
3603 "computer immediately."
3604 msgstr ""
3605 "对于每种流行的操作系统,都有已经构建的二进制软件包。这让在你的计算机上开始使"
3606 "用 Mercurial 变得很容易。"
3608 #. type: Content of: <book><chapter><sect1><sect2><title>
3609 #: ../en/ch02-tour-basic.xml:15
3610 msgid "Windows"
3611 msgstr "Windows"
3613 #. type: Content of: <book><chapter><sect1><sect2><para>
3614 #: ../en/ch02-tour-basic.xml:17
3615 msgid ""
3616 "The best version of Mercurial for Windows is TortoiseHg, which can be found "
3617 "at <ulink url=\"http://bitbucket.org/tortoisehg/stable/wiki/Home\">http://"
3618 "bitbucket.org/tortoisehg/stable/wiki/Home</ulink>. This package has no "
3619 "external dependencies; it <quote>just works</quote>. It provides both "
3620 "command line and graphical user interfaces."
3621 msgstr ""
3622 "Windows 中最好的 Mercurial 版本是TortoiseHg,它的主页地址是 <ulink url="
3623 "\"http://bitbucket.org/tortoisehg/stable/wiki/Home\">http://bitbucket.org/"
3624 "tortoisehg/stable/wiki/Home</ulink>。这个软件没有外部依赖,它可以<quote>独立工"
3625 "作</quote>,同时提供了命令行和图形用户界面。"
3627 #. type: Content of: <book><chapter><sect1><sect2><title>
3628 #: ../en/ch02-tour-basic.xml:27
3629 msgid "Mac OS X"
3630 msgstr "Mac OS X"
3632 #. type: Content of: <book><chapter><sect1><sect2><para>
3633 #: ../en/ch02-tour-basic.xml:29
3634 msgid ""
3635 "Lee Cantey publishes an installer of Mercurial for Mac OS X at <ulink url="
3636 "\"http://mercurial.berkwood.com\">http://mercurial.berkwood.com</ulink>."
3637 msgstr ""
3638 "Lee Cantey 为 Mac OS X 在 <ulink url=\"http://mercurial.berkwood.com"
3639 "\">http://mercurial.berkwood.com</ulink> 发布了 Mercurial 安装程序。"
3641 #. type: Content of: <book><chapter><sect1><sect2><title>
3642 #: ../en/ch02-tour-basic.xml:35
3643 msgid "Linux"
3644 msgstr "Linux"
3646 #. type: Content of: <book><chapter><sect1><sect2><para>
3647 #: ../en/ch02-tour-basic.xml:37
3648 msgid ""
3649 "Because each Linux distribution has its own packaging tools, policies, and "
3650 "rate of development, it's difficult to give a comprehensive set of "
3651 "instructions on how to install Mercurial binaries. The version of Mercurial "
3652 "that you will end up with can vary depending on how active the person is who "
3653 "maintains the package for your distribution."
3654 msgstr ""
3655 "由于每种 Linux 发行版都有自己的包管理工具,开发策略和进度,从而很难给出安装 "
3656 "Mercurial 二进制包的全面说明。你安装的 Mercurial 版本,在很大程度上依赖于你所"
3657 "使用的发行版的 Mercurial 维护者的活跃程度。"
3659 #. type: Content of: <book><chapter><sect1><sect2><para>
3660 #: ../en/ch02-tour-basic.xml:44
3661 msgid ""
3662 "To keep things simple, I will focus on installing Mercurial from the command "
3663 "line under the most popular Linux distributions. Most of these distributions "
3664 "provide graphical package managers that will let you install Mercurial with a "
3665 "single click; the package name to look for is <literal>mercurial</literal>."
3666 msgstr ""
3667 "为了让事情简单,我会致力于说明在最流行的 Linux 发行版中,从命令行安装 "
3668 "Mercurial 的方法。这些发行版都提供了图形界面的包管理器,让你通过点击鼠标安装 "
3669 "Mercurial;寻找的包名称是 <literal>mercurial</literal>。"
3671 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
3672 #: ../en/ch02-tour-basic.xml:52
3673 msgid "Ubuntu and Debian:"
3674 msgstr "Ubuntu 与 Debian:"
3676 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
3677 #: ../en/ch02-tour-basic.xml:54
3678 msgid "Fedora:"
3679 msgstr "Fedora:"
3681 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
3682 #: ../en/ch02-tour-basic.xml:56
3683 msgid "OpenSUSE:"
3684 msgstr "OpenSUSE:"
3686 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
3687 #: ../en/ch02-tour-basic.xml:58
3688 msgid "Gentoo:"
3689 msgstr "Gentoo:"
3691 #. type: Content of: <book><chapter><sect1><sect2><title>
3692 #: ../en/ch02-tour-basic.xml:64
3693 msgid "Solaris"
3694 msgstr "Solaris"
3696 #. type: Content of: <book><chapter><sect1><sect2><para>
3697 #: ../en/ch02-tour-basic.xml:66
3698 msgid ""
3699 "SunFreeWare, at <ulink url=\"http://www.sunfreeware.com\">http://www."
3700 "sunfreeware.com</ulink>, provides prebuilt packages of Mercurial."
3701 msgstr ""
3702 "位于 <ulink url=\"http://www.sunfreeware.com\">http://www.sunfreeware.com</"
3703 "ulink> 的 SunFreeWare 提供了 Mercurial 的二进制安装包。"
3705 #. type: Content of: <book><chapter><sect1><title>
3706 #: ../en/ch02-tour-basic.xml:75
3707 msgid "Getting started"
3708 msgstr "开始"
3710 #. type: Content of: <book><chapter><sect1><para>
3711 #: ../en/ch02-tour-basic.xml:77
3712 msgid ""
3713 "To begin, we'll use the <command role=\"hg-cmd\">hg version</command> command "
3714 "to find out whether Mercurial is installed properly. The actual version "
3715 "information that it prints isn't so important; we simply care whether the "
3716 "command runs and prints anything at all."
3717 msgstr ""
3718 "首先,我们使用 <command role=\"hg-cmd\">hg version</command> 命令检查 "
3719 "Mercurial 是否已经正确安装。它打印出来的实际版本信息并不重要;我们只关心它是否"
3720 "能够运行,打印出信息。"
3722 #. type: Content of: <book><chapter><sect1><sect2><title>
3723 #: ../en/ch02-tour-basic.xml:86
3724 msgid "Built-in help"
3725 msgstr "内置帮助"
3727 #. type: Content of: <book><chapter><sect1><sect2><para>
3728 #: ../en/ch02-tour-basic.xml:88
3729 msgid ""
3730 "Mercurial provides a built-in help system. This is invaluable for those "
3731 "times when you find yourself stuck trying to remember how to run a command. "
3732 "If you are completely stuck, simply run <command role=\"hg-cmd\">hg help</"
3733 "command>; it will print a brief list of commands, along with a description of "
3734 "what each does. If you ask for help on a specific command (as below), it "
3735 "prints more detailed information."
3736 msgstr ""
3737 "Mercurial 内置了帮助系统。当你不记得如何执行一个命令时,它会给你重要的帮助。如"
3738 "果你完全没有头绪,那就直接运行 <command role=\"hg-cmd\">hg help</command>;它"
3739 "会给出命令的简短列表,还描述了每个命令的作用。如果你需要具体命令的帮助(下述),"
3740 "它会给出更详细的信息。"
3742 #. type: Content of: <book><chapter><sect1><sect2><para>
3743 #: ../en/ch02-tour-basic.xml:99
3744 msgid ""
3745 "For a more impressive level of detail (which you won't usually need) run "
3746 "<command role=\"hg-cmd\">hg help <option role=\"hg-opt-global\">-v</option></"
3747 "command>. The <option role=\"hg-opt-global\">-v</option> option is short for "
3748 "<option role=\"hg-opt-global\">--verbose</option>, and tells Mercurial to "
3749 "print more information than it usually would."
3750 msgstr ""
3751 "要获得更多的详细信息(通常不需要),可以执行 <command role=\"hg-cmd\">hg help "
3752 "<option role=\"hg-opt-global\">-v</option></command>。选项 <option role=\"hg-"
3753 "opt-global\">-v</option> 是 <option role=\"hg-opt-global\">--verbose</option> "
3754 "的短格式,告诉 Mercurial 要打印通常不需要的更多信息。"
3756 #. type: Content of: <book><chapter><sect1><title>
3757 #: ../en/ch02-tour-basic.xml:110
3758 msgid "Working with a repository"
3759 msgstr "使用版本库"
3761 #. type: Content of: <book><chapter><sect1><para>
3762 #: ../en/ch02-tour-basic.xml:112
3763 msgid ""
3764 "In Mercurial, everything happens inside a <emphasis>repository</emphasis>. "
3765 "The repository for a project contains all of the files that <quote>belong to</"
3766 "quote> that project, along with a historical record of the project's files."
3767 msgstr ""
3769 #. type: Content of: <book><chapter><sect1><para>
3770 #: ../en/ch02-tour-basic.xml:118
3771 msgid ""
3772 "There's nothing particularly magical about a repository; it is simply a "
3773 "directory tree in your filesystem that Mercurial treats as special. You can "
3774 "rename or delete a repository any time you like, using either the command "
3775 "line or your file browser."
3776 msgstr ""
3778 #. type: Content of: <book><chapter><sect1><sect2><title>
3779 #: ../en/ch02-tour-basic.xml:125
3780 msgid "Making a local copy of a repository"
3781 msgstr "创建版本库的工作副本"
3783 #. type: Content of: <book><chapter><sect1><sect2><para>
3784 #: ../en/ch02-tour-basic.xml:127
3785 msgid ""
3786 "<emphasis>Copying</emphasis> a repository is just a little bit special. "
3787 "While you could use a normal file copying command to make a copy of a "
3788 "repository, it's best to use a built-in command that Mercurial provides. "
3789 "This command is called <command role=\"hg-cmd\">hg clone</command>, because "
3790 "it makes an identical copy of an existing repository."
3791 msgstr ""
3793 #. type: Content of: <book><chapter><sect1><sect2><para>
3794 #: ../en/ch02-tour-basic.xml:136
3795 msgid ""
3796 "One advantage of using <command role=\"hg-cmd\">hg clone</command> is that, "
3797 "as we can see above, it lets us clone repositories over the network. Another "
3798 "is that it remembers where we cloned from, which we'll find useful soon when "
3799 "we want to fetch new changes from another repository."
3800 msgstr ""
3802 #. type: Content of: <book><chapter><sect1><sect2><para>
3803 #: ../en/ch02-tour-basic.xml:142
3804 msgid ""
3805 "If our clone succeeded, we should now have a local directory called <filename "
3806 "class=\"directory\">hello</filename>. This directory will contain some files."
3807 msgstr ""
3809 #. type: Content of: <book><chapter><sect1><sect2><para>
3810 #: ../en/ch02-tour-basic.xml:148
3811 msgid ""
3812 "These files have the same contents and history in our repository as they do "
3813 "in the repository we cloned."
3814 msgstr ""
3816 #. type: Content of: <book><chapter><sect1><sect2><para>
3817 #: ../en/ch02-tour-basic.xml:151
3818 msgid ""
3819 "Every Mercurial repository is complete, self-contained, and independent. It "
3820 "contains its own private copy of a project's files and history. As we just "
3821 "mentioned, a cloned repository remembers the location of the repository it "
3822 "was cloned from, but Mercurial will not communicate with that repository, or "
3823 "any other, unless you tell it to."
3824 msgstr ""
3826 #. type: Content of: <book><chapter><sect1><sect2><para>
3827 #: ../en/ch02-tour-basic.xml:158
3828 msgid ""
3829 "What this means for now is that we're free to experiment with our repository, "
3830 "safe in the knowledge that it's a private <quote>sandbox</quote> that won't "
3831 "affect anyone else."
3832 msgstr ""
3834 #. type: Content of: <book><chapter><sect1><sect2><title>
3835 #: ../en/ch02-tour-basic.xml:164
3836 msgid "What's in a repository?"
3837 msgstr "什么是版本库?"
3839 #. type: Content of: <book><chapter><sect1><sect2><para>
3840 #: ../en/ch02-tour-basic.xml:166
3841 msgid ""
3842 "When we take a more detailed look inside a repository, we can see that it "
3843 "contains a directory named <filename class=\"directory\">.hg</filename>. "
3844 "This is where Mercurial keeps all of its metadata for the repository."
3845 msgstr ""
3847 #. type: Content of: <book><chapter><sect1><sect2><para>
3848 #: ../en/ch02-tour-basic.xml:173
3849 msgid ""
3850 "The contents of the <filename class=\"directory\">.hg</filename> directory "
3851 "and its subdirectories are private to Mercurial. Every other file and "
3852 "directory in the repository is yours to do with as you please."
3853 msgstr ""
3855 #. type: Content of: <book><chapter><sect1><sect2><para>
3856 #: ../en/ch02-tour-basic.xml:179
3857 msgid ""
3858 "To introduce a little terminology, the <filename class=\"directory\">.hg</"
3859 "filename> directory is the <quote>real</quote> repository, and all of the "
3860 "files and directories that coexist with it are said to live in the "
3861 "<emphasis>working directory</emphasis>. An easy way to remember the "
3862 "distinction is that the <emphasis>repository</emphasis> contains the "
3863 "<emphasis>history</emphasis> of your project, while the <emphasis>working "
3864 "directory</emphasis> contains a <emphasis>snapshot</emphasis> of your project "
3865 "at a particular point in history."
3866 msgstr ""
3868 #. type: Content of: <book><chapter><sect1><title>
3869 #: ../en/ch02-tour-basic.xml:194
3870 msgid "A tour through history"
3871 msgstr "回溯历史"
3873 #. type: Content of: <book><chapter><sect1><para>
3874 #: ../en/ch02-tour-basic.xml:196
3875 msgid ""
3876 "One of the first things we might want to do with a new, unfamiliar repository "
3877 "is understand its history. The <command role=\"hg-cmd\">hg log</command> "
3878 "command gives us a view of the history of changes in the repository."
3879 msgstr ""
3881 #. type: Content of: <book><chapter><sect1><para>
3882 #: ../en/ch02-tour-basic.xml:203
3883 msgid ""
3884 "By default, this command prints a brief paragraph of output for each change "
3885 "to the project that was recorded. In Mercurial terminology, we call each of "
3886 "these recorded events a <emphasis>changeset</emphasis>, because it can "
3887 "contain a record of changes to several files."
3888 msgstr ""
3890 #. type: Content of: <book><chapter><sect1><para>
3891 #: ../en/ch02-tour-basic.xml:209
3892 msgid ""
3893 "The fields in a record of output from <command role=\"hg-cmd\">hg log</"
3894 "command> are as follows."
3895 msgstr ""
3897 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
3898 #: ../en/ch02-tour-basic.xml:213
3899 msgid ""
3900 "<literal>changeset</literal>: This field has the format of a number, followed "
3901 "by a colon, followed by a hexadecimal (or <emphasis>hex</emphasis>) string. "
3902 "These are <emphasis>identifiers</emphasis> for the changeset. The hex string "
3903 "is a unique identifier: the same hex string will always refer to the same "
3904 "changeset in every copy of this repository. The number is shorter and easier "
3905 "to type than the hex string, but it isn't unique: the same number in two "
3906 "different clones of a repository may identify different changesets."
3907 msgstr ""
3909 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
3910 #: ../en/ch02-tour-basic.xml:224
3911 msgid ""
3912 "<literal>user</literal>: The identity of the person who created the "
3913 "changeset. This is a free-form field, but it most often contains a person's "
3914 "name and email address."
3915 msgstr ""
3917 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
3918 #: ../en/ch02-tour-basic.xml:228
3919 msgid ""
3920 "<literal>date</literal>: The date and time on which the changeset was "
3921 "created, and the timezone in which it was created. (The date and time are "
3922 "local to that timezone; they display what time and date it was for the person "
3923 "who created the changeset.)"
3924 msgstr ""
3926 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
3927 #: ../en/ch02-tour-basic.xml:233
3928 msgid ""
3929 "<literal>summary</literal>: The first line of the text message that the "
3930 "creator of the changeset entered to describe the changeset."
3931 msgstr ""
3933 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
3934 #: ../en/ch02-tour-basic.xml:237
3935 msgid ""
3936 "Some changesets, such as the first in the list above, have a <literal>tag</"
3937 "literal> field. A tag is another way to identify a changeset, by giving it "
3938 "an easy-to-remember name. (The tag named <literal>tip</literal> is special: "
3939 "it always refers to the newest change in a repository.)"
3940 msgstr ""
3942 #. type: Content of: <book><chapter><sect1><para>
3943 #: ../en/ch02-tour-basic.xml:245
3944 msgid ""
3945 "The default output printed by <command role=\"hg-cmd\">hg log</command> is "
3946 "purely a summary; it is missing a lot of detail."
3947 msgstr ""
3949 #. type: Content of: <book><chapter><sect1><para>
3950 #: ../en/ch02-tour-basic.xml:249
3951 msgid ""
3952 "<xref linkend=\"fig:tour-basic:history\"/> provides a graphical "
3953 "representation of the history of the <filename class=\"directory\">hello</"
3954 "filename> repository, to make it a little easier to see which direction "
3955 "history is <quote>flowing</quote> in. We'll be returning to this figure "
3956 "several times in this chapter and the chapter that follows."
3957 msgstr ""
3959 #. type: Content of: <book><chapter><sect1><figure><title>
3960 #: ../en/ch02-tour-basic.xml:258
3961 msgid ""
3962 "Graphical history of the <filename class=\"directory\">hello</filename> "
3963 "repository"
3964 msgstr "版本库 <filename class=\"directory\">hello</filename> 的历史图"
3966 #. type: Content of: <book><chapter><sect1><figure>
3967 #: ../en/ch02-tour-basic.xml:260 ../en/ch03-tour-merge.xml:61
3968 #: ../en/ch03-tour-merge.xml:207 ../en/ch04-concepts.xml:290
3969 msgid "<placeholder type=\"mediaobject\" id=\"0\"/>"
3970 msgstr ""
3972 #. type: Content of: <book><chapter><sect1><figure><mediaobject>
3973 #: ../en/ch02-tour-basic.xml:261
3974 msgid ""
3975 "<imageobject><imagedata fileref=\"figs/tour-history.png\"/></imageobject>"
3976 msgstr ""
3978 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject><textobject><phrase>
3979 #: ../en/ch02-tour-basic.xml:262 ../en/ch03-tour-merge.xml:63
3980 #: ../en/ch03-tour-merge.xml:95 ../en/ch03-tour-merge.xml:182
3981 #: ../en/ch03-tour-merge.xml:209 ../en/ch03-tour-merge.xml:279
3982 #: ../en/ch04-concepts.xml:59 ../en/ch04-concepts.xml:108
3983 #: ../en/ch04-concepts.xml:198 ../en/ch04-concepts.xml:292
3984 #: ../en/ch04-concepts.xml:347 ../en/ch04-concepts.xml:362
3985 #: ../en/ch04-concepts.xml:403 ../en/ch04-concepts.xml:423
3986 #: ../en/ch04-concepts.xml:469 ../en/ch06-collab.xml:316
3987 #: ../en/ch09-undo.xml:344 ../en/ch09-undo.xml:391 ../en/ch09-undo.xml:464
3988 #: ../en/ch09-undo.xml:502 ../en/ch09-undo.xml:658 ../en/ch09-undo.xml:682
3989 #: ../en/ch09-undo.xml:700 ../en/ch09-undo.xml:714 ../en/ch09-undo.xml:727
3990 #: ../en/ch12-mq.xml:413
3991 msgid "XXX add text"
3992 msgstr ""
3994 #. type: Content of: <book><chapter><sect1><sect2><title>
3995 #: ../en/ch02-tour-basic.xml:267
3996 msgid "Changesets, revisions, and talking to other people"
3997 msgstr "修改集,版本,与其它用户交互"
3999 #. type: Content of: <book><chapter><sect1><sect2><para>
4000 #: ../en/ch02-tour-basic.xml:270
4001 msgid ""
4002 "As English is a notoriously sloppy language, and computer science has a "
4003 "hallowed history of terminological confusion (why use one term when four will "
4004 "do?), revision control has a variety of words and phrases that mean the same "
4005 "thing. If you are talking about Mercurial history with other people, you "
4006 "will find that the word <quote>changeset</quote> is often compressed to "
4007 "<quote>change</quote> or (when written) <quote>cset</quote>, and sometimes a "
4008 "changeset is referred to as a <quote>revision</quote> or a <quote>rev</quote>."
4009 msgstr ""
4011 #. type: Content of: <book><chapter><sect1><sect2><para>
4012 #: ../en/ch02-tour-basic.xml:280
4013 msgid ""
4014 "While it doesn't matter what <emphasis>word</emphasis> you use to refer to "
4015 "the concept of <quote>a changeset</quote>, the <emphasis>identifier</"
4016 "emphasis> that you use to refer to <quote>a <emphasis>specific</emphasis> "
4017 "changeset</quote> is of great importance. Recall that the <literal>changeset</"
4018 "literal> field in the output from <command role=\"hg-cmd\">hg log</command> "
4019 "identifies a changeset using both a number and a hexadecimal string."
4020 msgstr ""
4022 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
4023 #: ../en/ch02-tour-basic.xml:289
4024 msgid ""
4025 "The revision number is a handy notation that is <emphasis>only valid in that "
4026 "repository</emphasis>."
4027 msgstr ""
4029 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
4030 #: ../en/ch02-tour-basic.xml:292
4031 msgid ""
4032 "The hexadecimal string is the <emphasis>permanent, unchanging identifier</"
4033 "emphasis> that will always identify that exact changeset in <emphasis>every</"
4034 "emphasis> copy of the repository."
4035 msgstr ""
4037 #. type: Content of: <book><chapter><sect1><sect2><para>
4038 #: ../en/ch02-tour-basic.xml:298
4039 msgid ""
4040 "This distinction is important. If you send someone an email talking about "
4041 "<quote>revision 33</quote>, there's a high likelihood that their revision 33 "
4042 "will <emphasis>not be the same</emphasis> as yours. The reason for this is "
4043 "that a revision number depends on the order in which changes arrived in a "
4044 "repository, and there is no guarantee that the same changes will happen in "
4045 "the same order in different repositories. Three changes <literal>a,b,c</"
4046 "literal> can easily appear in one repository as <literal>0,1,2</literal>, "
4047 "while in another as <literal>0,2,1</literal>."
4048 msgstr ""
4050 #. type: Content of: <book><chapter><sect1><sect2><para>
4051 #: ../en/ch02-tour-basic.xml:310
4052 msgid ""
4053 "Mercurial uses revision numbers purely as a convenient shorthand. If you "
4054 "need to discuss a changeset with someone, or make a record of a changeset for "
4055 "some other reason (for example, in a bug report), use the hexadecimal "
4056 "identifier."
4057 msgstr ""
4059 #. type: Content of: <book><chapter><sect1><sect2><title>
4060 #: ../en/ch02-tour-basic.xml:318
4061 msgid "Viewing specific revisions"
4062 msgstr "察看指定版本"
4064 #. type: Content of: <book><chapter><sect1><sect2><para>
4065 #: ../en/ch02-tour-basic.xml:320
4066 msgid ""
4067 "To narrow the output of <command role=\"hg-cmd\">hg log</command> down to a "
4068 "single revision, use the <option role=\"hg-opt-log\">-r</option> (or <option "
4069 "role=\"hg-opt-log\">--rev</option>) option. You can use either a revision "
4070 "number or a hexadecimal identifier, and you can provide as many revisions as "
4071 "you want."
4072 msgstr ""
4074 #. type: Content of: <book><chapter><sect1><sect2><para>
4075 #: ../en/ch02-tour-basic.xml:329
4076 msgid ""
4077 "If you want to see the history of several revisions without having to list "
4078 "each one, you can use <emphasis>range notation</emphasis>; this lets you "
4079 "express the idea <quote>I want all revisions between <literal>abc</literal> "
4080 "and <literal>def</literal>, inclusive</quote>."
4081 msgstr ""
4083 #. type: Content of: <book><chapter><sect1><sect2><para>
4084 #: ../en/ch02-tour-basic.xml:337
4085 msgid ""
4086 "Mercurial also honours the order in which you specify revisions, so <command "
4087 "role=\"hg-cmd\">hg log -r 2:4</command> prints 2, 3, and 4. while <command "
4088 "role=\"hg-cmd\">hg log -r 4:2</command> prints 4, 3, and 2."
4089 msgstr ""
4091 #. type: Content of: <book><chapter><sect1><sect2><title>
4092 #: ../en/ch02-tour-basic.xml:344
4093 msgid "More detailed information"
4094 msgstr "更详细的信息"
4096 #. type: Content of: <book><chapter><sect1><sect2><para>
4097 #: ../en/ch02-tour-basic.xml:346
4098 msgid ""
4099 "While the summary information printed by <command role=\"hg-cmd\">hg log</"
4100 "command> is useful if you already know what you're looking for, you may need "
4101 "to see a complete description of the change, or a list of the files changed, "
4102 "if you're trying to decide whether a changeset is the one you're looking for. "
4103 "The <command role=\"hg-cmd\">hg log</command> command's <option role=\"hg-opt-"
4104 "global\">-v</option> (or <option role=\"hg-opt-global\">--verbose</option>) "
4105 "option gives you this extra detail."
4106 msgstr ""
4108 #. type: Content of: <book><chapter><sect1><sect2><para>
4109 #: ../en/ch02-tour-basic.xml:358
4110 msgid ""
4111 "If you want to see both the description and content of a change, add the "
4112 "<option role=\"hg-opt-log\">-p</option> (or <option role=\"hg-opt-log\">--"
4113 "patch</option>) option. This displays the content of a change as a "
4114 "<emphasis>unified diff</emphasis> (if you've never seen a unified diff "
4115 "before, see <xref linkend=\"sec:mq:patch\"/> for an overview)."
4116 msgstr ""
4118 #. type: Content of: <book><chapter><sect1><sect2><para>
4119 #: ../en/ch02-tour-basic.xml:368
4120 msgid ""
4121 "The <option role=\"hg-opt-log\">-p</option> option is tremendously useful, so "
4122 "it's well worth remembering."
4123 msgstr ""
4125 #. type: Content of: <book><chapter><sect1><title>
4126 #: ../en/ch02-tour-basic.xml:375
4127 msgid "All about command options"
4128 msgstr "命令选项"
4130 #. type: Content of: <book><chapter><sect1><para>
4131 #: ../en/ch02-tour-basic.xml:377
4132 msgid ""
4133 "Let's take a brief break from exploring Mercurial commands to discuss a "
4134 "pattern in the way that they work; you may find this useful to keep in mind "
4135 "as we continue our tour."
4136 msgstr ""
4138 #. type: Content of: <book><chapter><sect1><para>
4139 #: ../en/ch02-tour-basic.xml:381
4140 msgid ""
4141 "Mercurial has a consistent and straightforward approach to dealing with the "
4142 "options that you can pass to commands. It follows the conventions for "
4143 "options that are common to modern Linux and Unix systems."
4144 msgstr ""
4146 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
4147 #: ../en/ch02-tour-basic.xml:388
4148 msgid ""
4149 "Every option has a long name. For example, as we've already seen, the "
4150 "<command role=\"hg-cmd\">hg log</command> command accepts a <option role=\"hg-"
4151 "opt-log\">--rev</option> option."
4152 msgstr ""
4154 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
4155 #: ../en/ch02-tour-basic.xml:394
4156 msgid ""
4157 "Most options have short names, too. Instead of <option role=\"hg-opt-log\">--"
4158 "rev</option>, we can use <option role=\"hg-opt-log\">-r</option>. (The "
4159 "reason that some options don't have short names is that the options in "
4160 "question are rarely used.)"
4161 msgstr ""
4163 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
4164 #: ../en/ch02-tour-basic.xml:401
4165 msgid ""
4166 "Long options start with two dashes (e.g. <option role=\"hg-opt-log\">--rev</"
4167 "option>), while short options start with one (e.g. <option role=\"hg-opt-log"
4168 "\">-r</option>)."
4169 msgstr ""
4171 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
4172 #: ../en/ch02-tour-basic.xml:407
4173 msgid ""
4174 "Option naming and usage is consistent across commands. For example, every "
4175 "command that lets you specify a changeset ID or revision number accepts both "
4176 "<option role=\"hg-opt-log\">-r</option> and <option role=\"hg-opt-log\">--"
4177 "rev</option> arguments."
4178 msgstr ""
4180 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
4181 #: ../en/ch02-tour-basic.xml:414
4182 msgid ""
4183 "If you are using short options, you can save typing by running them together. "
4184 "For example, the command <command role=\"hg-cmd\">hg log -v -p -r 2</command> "
4185 "can be written as <command role=\"hg-cmd\">hg log -vpr2</command>."
4186 msgstr ""
4188 #. type: Content of: <book><chapter><sect1><para>
4189 #: ../en/ch02-tour-basic.xml:421
4190 msgid ""
4191 "In the examples throughout this book, I usually use short options instead of "
4192 "long. This simply reflects my own preference, so don't read anything "
4193 "significant into it."
4194 msgstr ""
4196 #. type: Content of: <book><chapter><sect1><para>
4197 #: ../en/ch02-tour-basic.xml:425
4198 msgid ""
4199 "Most commands that print output of some kind will print more output when "
4200 "passed a <option role=\"hg-opt-global\">-v</option> (or <option role=\"hg-opt-"
4201 "global\">--verbose</option>) option, and less when passed <option role=\"hg-"
4202 "opt-global\">-q</option> (or <option role=\"hg-opt-global\">--quiet</option>)."
4203 msgstr ""
4205 #. type: Content of: <book><chapter><sect1><note><title>
4206 #: ../en/ch02-tour-basic.xml:432
4207 msgid "Option naming consistency"
4208 msgstr ""
4210 #. type: Content of: <book><chapter><sect1><note><para>
4211 #: ../en/ch02-tour-basic.xml:434
4212 msgid ""
4213 "Almost always, Mercurial commands use consistent option names to refer to the "
4214 "same concepts. For instance, if a command deals with changesets, you'll "
4215 "always identify them with <option role=\"hg-opt-log\">--rev</option> or "
4216 "<option role=\"hg-opt-log\">-r</option>. This consistent use of option names "
4217 "makes it easier to remember what options a particular command takes."
4218 msgstr ""
4220 #. type: Content of: <book><chapter><sect1><title>
4221 #: ../en/ch02-tour-basic.xml:445
4222 msgid "Making and reviewing changes"
4223 msgstr "创建和复审修改"
4225 #. type: Content of: <book><chapter><sect1><para>
4226 #: ../en/ch02-tour-basic.xml:447
4227 msgid ""
4228 "Now that we have a grasp of viewing history in Mercurial, let's take a look "
4229 "at making some changes and examining them."
4230 msgstr ""
4232 #. type: Content of: <book><chapter><sect1><para>
4233 #: ../en/ch02-tour-basic.xml:451
4234 msgid ""
4235 "The first thing we'll do is isolate our experiment in a repository of its "
4236 "own. We use the <command role=\"hg-cmd\">hg clone</command> command, but we "
4237 "don't need to clone a copy of the remote repository. Since we already have a "
4238 "copy of it locally, we can just clone that instead. This is much faster than "
4239 "cloning over the network, and cloning a local repository uses less disk space "
4240 "in most cases, too<placeholder type=\"footnote\" id=\"0\"/>."
4241 msgstr ""
4243 #. type: Content of: <book><chapter><sect1><para><footnote><para>
4244 #: ../en/ch02-tour-basic.xml:458
4245 msgid ""
4246 "The saving of space arises when source and destination repositories are on "
4247 "the same filesystem, in which case Mercurial will use hardlinks to do copy-on-"
4248 "write sharing of its internal metadata. If that explanation meant nothing to "
4249 "you, don't worry: everything happens transparently and automatically, and you "
4250 "don't need to understand it."
4251 msgstr ""
4253 #. type: Content of: <book><chapter><sect1><para>
4254 #: ../en/ch02-tour-basic.xml:468
4255 msgid ""
4256 "As an aside, it's often good practice to keep a <quote>pristine</quote> copy "
4257 "of a remote repository around, which you can then make temporary clones of to "
4258 "create sandboxes for each task you want to work on. This lets you work on "
4259 "multiple tasks in parallel, each isolated from the others until it's complete "
4260 "and you're ready to integrate it back. Because local clones are so cheap, "
4261 "there's almost no overhead to cloning and destroying repositories whenever "
4262 "you want."
4263 msgstr ""
4265 #. type: Content of: <book><chapter><sect1><para>
4266 #: ../en/ch02-tour-basic.xml:477
4267 msgid ""
4268 "In our <filename class=\"directory\">my-hello</filename> repository, we have "
4269 "a file <filename>hello.c</filename> that contains the classic <quote>hello, "
4270 "world</quote> program."
4271 msgstr ""
4273 #. type: Content of: <book><chapter><sect1><para>
4274 #: ../en/ch02-tour-basic.xml:483
4275 msgid "Let's edit this file so that it prints a second line of output."
4276 msgstr ""
4278 #. type: Content of: <book><chapter><sect1><para>
4279 #: ../en/ch02-tour-basic.xml:488
4280 msgid ""
4281 "Mercurial's <command role=\"hg-cmd\">hg status</command> command will tell us "
4282 "what Mercurial knows about the files in the repository."
4283 msgstr ""
4285 #. type: Content of: <book><chapter><sect1><para>
4286 #: ../en/ch02-tour-basic.xml:494
4287 msgid ""
4288 "The <command role=\"hg-cmd\">hg status</command> command prints no output for "
4289 "some files, but a line starting with <quote><literal>M</literal></quote> for "
4290 "<filename>hello.c</filename>. Unless you tell it to, <command role=\"hg-cmd"
4291 "\">hg status</command> will not print any output for files that have not been "
4292 "modified."
4293 msgstr ""
4295 #. type: Content of: <book><chapter><sect1><para>
4296 #: ../en/ch02-tour-basic.xml:501
4297 msgid ""
4298 "The <quote><literal>M</literal></quote> indicates that Mercurial has noticed "
4299 "that we modified <filename>hello.c</filename>. We didn't need to "
4300 "<emphasis>inform</emphasis> Mercurial that we were going to modify the file "
4301 "before we started, or that we had modified the file after we were done; it "
4302 "was able to figure this out itself."
4303 msgstr ""
4305 #. type: Content of: <book><chapter><sect1><para>
4306 #: ../en/ch02-tour-basic.xml:509
4307 msgid ""
4308 "It's somewhat helpful to know that we've modified <filename>hello.c</"
4309 "filename>, but we might prefer to know exactly <emphasis>what</emphasis> "
4310 "changes we've made to it. To do this, we use the <command role=\"hg-cmd\">hg "
4311 "diff</command> command."
4312 msgstr ""
4314 #. type: Content of: <book><chapter><sect1><title>
4315 #: ../en/ch02-tour-basic.xml:518 ../en/ch12-mq.xml:187
4316 msgid "Understanding patches"
4317 msgstr "理解补丁"
4319 #. type: Content of: <book><chapter><sect1><tip><para>
4320 #: ../en/ch02-tour-basic.xml:520
4321 msgid ""
4322 "Remember to take a look at <xref linkend=\"sec:mq:patch\"/> if you don't know "
4323 "how to read output above."
4324 msgstr ""
4326 #. type: Content of: <book><chapter><sect1><title>
4327 #: ../en/ch02-tour-basic.xml:526
4328 msgid "Recording changes in a new changeset"
4329 msgstr "在新修改集中记录修改"
4331 #. type: Content of: <book><chapter><sect1><para>
4332 #: ../en/ch02-tour-basic.xml:528
4333 msgid ""
4334 "We can modify files, build and test our changes, and use <command role=\"hg-"
4335 "cmd\">hg status</command> and <command role=\"hg-cmd\">hg diff</command> to "
4336 "review our changes, until we're satisfied with what we've done and arrive at "
4337 "a natural stopping point where we want to record our work in a new changeset."
4338 msgstr ""
4340 #. type: Content of: <book><chapter><sect1><para>
4341 #: ../en/ch02-tour-basic.xml:535
4342 msgid ""
4343 "The <command role=\"hg-cmd\">hg commit</command> command lets us create a new "
4344 "changeset; we'll usually refer to this as <quote>making a commit</quote> or "
4345 "<quote>committing</quote>."
4346 msgstr ""
4348 #. type: Content of: <book><chapter><sect1><sect2><title>
4349 #: ../en/ch02-tour-basic.xml:541
4350 msgid "Setting up a username"
4351 msgstr "配置用户名称"
4353 #. type: Content of: <book><chapter><sect1><sect2><para>
4354 #: ../en/ch02-tour-basic.xml:543
4355 msgid ""
4356 "When you try to run <command role=\"hg-cmd\">hg commit</command> for the "
4357 "first time, it is not guaranteed to succeed. Mercurial records your name and "
4358 "address with each change that you commit, so that you and others will later "
4359 "be able to tell who made each change. Mercurial tries to automatically "
4360 "figure out a sensible username to commit the change with. It will attempt "
4361 "each of the following methods, in order:"
4362 msgstr ""
4364 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
4365 #: ../en/ch02-tour-basic.xml:552
4366 msgid ""
4367 "If you specify a <option role=\"hg-opt-commit\">-u</option> option to the "
4368 "<command role=\"hg-cmd\">hg commit</command> command on the command line, "
4369 "followed by a username, this is always given the highest precedence."
4370 msgstr ""
4372 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
4373 #: ../en/ch02-tour-basic.xml:557
4374 msgid ""
4375 "If you have set the <envar>HGUSER</envar> environment variable, this is "
4376 "checked next."
4377 msgstr ""
4379 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
4380 #: ../en/ch02-tour-basic.xml:560
4381 msgid ""
4382 "If you create a file in your home directory called <filename role=\"special"
4383 "\">.hgrc</filename>, with a <envar role=\"rc-item-ui\">username</envar> "
4384 "entry, that will be used next. To see what the contents of this file should "
4385 "look like, refer to <xref linkend=\"sec:tour-basic:username\"/> below."
4386 msgstr ""
4388 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
4389 #: ../en/ch02-tour-basic.xml:568
4390 msgid ""
4391 "If you have set the <envar>EMAIL</envar> environment variable, this will be "
4392 "used next."
4393 msgstr ""
4395 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
4396 #: ../en/ch02-tour-basic.xml:571
4397 msgid ""
4398 "Mercurial will query your system to find out your local user name and host "
4399 "name, and construct a username from these components. Since this often "
4400 "results in a username that is not very useful, it will print a warning if it "
4401 "has to do this."
4402 msgstr ""
4404 #. type: Content of: <book><chapter><sect1><sect2><para>
4405 #: ../en/ch02-tour-basic.xml:578
4406 msgid ""
4407 "If all of these mechanisms fail, Mercurial will fail, printing an error "
4408 "message. In this case, it will not let you commit until you set up a "
4409 "username."
4410 msgstr ""
4412 #. type: Content of: <book><chapter><sect1><sect2><para>
4413 #: ../en/ch02-tour-basic.xml:582
4414 msgid ""
4415 "You should think of the <envar>HGUSER</envar> environment variable and the "
4416 "<option role=\"hg-opt-commit\">-u</option> option to the <command role=\"hg-"
4417 "cmd\">hg commit</command> command as ways to <emphasis>override</emphasis> "
4418 "Mercurial's default selection of username. For normal use, the simplest and "
4419 "most robust way to set a username for yourself is by creating a <filename "
4420 "role=\"special\">.hgrc</filename> file; see below for details."
4421 msgstr ""
4423 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
4424 #: ../en/ch02-tour-basic.xml:591
4425 msgid "Creating a Mercurial configuration file"
4426 msgstr "创建 Mercurial 的配置文件"
4428 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
4429 #: ../en/ch02-tour-basic.xml:593
4430 msgid ""
4431 "To set a user name, use your favorite editor to create a file called "
4432 "<filename role=\"special\">.hgrc</filename> in your home directory. "
4433 "Mercurial will use this file to look up your personalised configuration "
4434 "settings. The initial contents of your <filename role=\"special\">.hgrc</"
4435 "filename> should look like this."
4436 msgstr ""
4438 #. type: Content of: <book><chapter><sect1><sect2><sect3><tip><title>
4439 #: ../en/ch02-tour-basic.xml:602
4440 msgid "<quote>Home directory</quote> on Windows"
4441 msgstr ""
4443 #. type: Content of: <book><chapter><sect1><sect2><sect3><tip><para>
4444 #: ../en/ch02-tour-basic.xml:604
4445 msgid ""
4446 "When we refer to your home directory, on an English language installation of "
4447 "Windows this will usually be a folder named after your user name in "
4448 "<filename>C:\\Documents and Settings</filename>. You can find out the exact "
4449 "name of your home directory by opening a command prompt window and running "
4450 "the following command."
4451 msgstr ""
4453 #. type: Content of: <book><chapter><sect1><sect2><sect3><tip><screen><prompt>
4454 #: ../en/ch02-tour-basic.xml:612
4455 msgid "C:\\>"
4456 msgstr "C:\\>"
4458 #. type: Content of: <book><chapter><sect1><sect2><sect3><tip><screen><userinput>
4459 #: ../en/ch02-tour-basic.xml:612
4460 msgid "echo %UserProfile%"
4461 msgstr "echo %UserProfile%"
4463 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
4464 #: ../en/ch02-tour-basic.xml:619
4465 msgid ""
4466 "The <quote><literal>[ui]</literal></quote> line begins a <emphasis>section</"
4467 "emphasis> of the config file, so you can read the <quote><literal>username "
4468 "= ...</literal></quote> line as meaning <quote>set the value of the "
4469 "<literal>username</literal> item in the <literal>ui</literal> section</"
4470 "quote>. A section continues until a new section begins, or the end of the "
4471 "file. Mercurial ignores empty lines and treats any text from "
4472 "<quote><literal>#</literal></quote> to the end of a line as a comment."
4473 msgstr ""
4475 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
4476 #: ../en/ch02-tour-basic.xml:632
4477 msgid "Choosing a user name"
4478 msgstr "选择用户名称"
4480 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
4481 #: ../en/ch02-tour-basic.xml:634
4482 msgid ""
4483 "You can use any text you like as the value of the <literal>username</literal> "
4484 "config item, since this information is for reading by other people, but will "
4485 "not be interpreted by Mercurial. The convention that most people follow is "
4486 "to use their name and email address, as in the example above."
4487 msgstr ""
4489 #. type: Content of: <book><chapter><sect1><sect2><sect3><note><para>
4490 #: ../en/ch02-tour-basic.xml:641
4491 msgid ""
4492 "Mercurial's built-in web server obfuscates email addresses, to make it more "
4493 "difficult for the email harvesting tools that spammers use. This reduces the "
4494 "likelihood that you'll start receiving more junk email if you publish a "
4495 "Mercurial repository on the web."
4496 msgstr ""
4498 #. type: Content of: <book><chapter><sect1><sect2><title>
4499 #: ../en/ch02-tour-basic.xml:650
4500 msgid "Writing a commit message"
4501 msgstr "写提交日志"
4503 #. type: Content of: <book><chapter><sect1><sect2><para>
4504 #: ../en/ch02-tour-basic.xml:652
4505 msgid ""
4506 "When we commit a change, Mercurial drops us into a text editor, to enter a "
4507 "message that will describe the modifications we've made in this changeset. "
4508 "This is called the <emphasis>commit message</emphasis>. It will be a record "
4509 "for readers of what we did and why, and it will be printed by <command role="
4510 "\"hg-cmd\">hg log</command> after we've finished committing."
4511 msgstr ""
4513 #. type: Content of: <book><chapter><sect1><sect2><para>
4514 #: ../en/ch02-tour-basic.xml:662
4515 msgid ""
4516 "The editor that the <command role=\"hg-cmd\">hg commit</command> command "
4517 "drops us into will contain an empty line or two, followed by a number of "
4518 "lines starting with <quote><literal>HG:</literal></quote>."
4519 msgstr ""
4521 #. type: Content of: <book><chapter><sect1><sect2><para>
4522 #: ../en/ch02-tour-basic.xml:676
4523 msgid ""
4524 "Mercurial ignores the lines that start with <quote><literal>HG:</literal></"
4525 "quote>; it uses them only to tell us which files it's recording changes to. "
4526 "Modifying or deleting these lines has no effect."
4527 msgstr ""
4529 #. type: Content of: <book><chapter><sect1><sect2><title>
4530 #: ../en/ch02-tour-basic.xml:682
4531 msgid "Writing a good commit message"
4532 msgstr "写好提交日志"
4534 #. type: Content of: <book><chapter><sect1><sect2><para>
4535 #: ../en/ch02-tour-basic.xml:684
4536 msgid ""
4537 "Since <command role=\"hg-cmd\">hg log</command> only prints the first line of "
4538 "a commit message by default, it's best to write a commit message whose first "
4539 "line stands alone. Here's a real example of a commit message that "
4540 "<emphasis>doesn't</emphasis> follow this guideline, and hence has a summary "
4541 "that is not readable."
4542 msgstr ""
4544 #. type: Content of: <book><chapter><sect1><sect2><para>
4545 #: ../en/ch02-tour-basic.xml:697
4546 msgid ""
4547 "As far as the remainder of the contents of the commit message are concerned, "
4548 "there are no hard-and-fast rules. Mercurial itself doesn't interpret or care "
4549 "about the contents of the commit message, though your project may have "
4550 "policies that dictate a certain kind of formatting."
4551 msgstr ""
4553 #. type: Content of: <book><chapter><sect1><sect2><para>
4554 #: ../en/ch02-tour-basic.xml:702
4555 msgid ""
4556 "My personal preference is for short, but informative, commit messages that "
4557 "tell me something that I can't figure out with a quick glance at the output "
4558 "of <command role=\"hg-cmd\">hg log --patch</command>."
4559 msgstr ""
4561 #. type: Content of: <book><chapter><sect1><sect2><para>
4562 #: ../en/ch02-tour-basic.xml:706
4563 msgid ""
4564 "If we run the <command role=\"hg-cmd\">hg commit</command> command without "
4565 "any arguments, it records all of the changes we've made, as reported by "
4566 "<command role=\"hg-cmd\">hg status</command> and <command role=\"hg-cmd\">hg "
4567 "diff</command>."
4568 msgstr ""
4570 #. type: Content of: <book><chapter><sect1><sect2><note><title>
4571 #: ../en/ch02-tour-basic.xml:713
4572 msgid "A surprise for Subversion users"
4573 msgstr ""
4575 #. type: Content of: <book><chapter><sect1><sect2><note><para>
4576 #: ../en/ch02-tour-basic.xml:715
4577 msgid ""
4578 "Like other Mercurial commands, if we don't supply explicit names to commit to "
4579 "the <command role=\"hg-cmd\">hg commit</command>, it will operate across a "
4580 "repository's entire working directory. Be wary of this if you're coming from "
4581 "the Subversion or CVS world, since you might expect it to operate only on the "
4582 "current directory that you happen to be visiting and its subdirectories."
4583 msgstr ""
4585 #. type: Content of: <book><chapter><sect1><sect2><title>
4586 #: ../en/ch02-tour-basic.xml:726
4587 msgid "Aborting a commit"
4588 msgstr "终止提交"
4590 #. type: Content of: <book><chapter><sect1><sect2><para>
4591 #: ../en/ch02-tour-basic.xml:728
4592 msgid ""
4593 "If you decide that you don't want to commit while in the middle of editing a "
4594 "commit message, simply exit from your editor without saving the file that "
4595 "it's editing. This will cause nothing to happen to either the repository or "
4596 "the working directory."
4597 msgstr ""
4599 #. type: Content of: <book><chapter><sect1><sect2><title>
4600 #: ../en/ch02-tour-basic.xml:736
4601 msgid "Admiring our new handiwork"
4602 msgstr "欣赏我们的成果"
4604 #. type: Content of: <book><chapter><sect1><sect2><para>
4605 #: ../en/ch02-tour-basic.xml:738
4606 msgid ""
4607 "Once we've finished the commit, we can use the <command role=\"hg-cmd\">hg "
4608 "tip</command> command to display the changeset we just created. This command "
4609 "produces output that is identical to <command role=\"hg-cmd\">hg log</"
4610 "command>, but it only displays the newest revision in the repository."
4611 msgstr ""
4613 #. type: Content of: <book><chapter><sect1><sect2><para>
4614 #: ../en/ch02-tour-basic.xml:746
4615 msgid ""
4616 "We refer to the newest revision in the repository as the <emphasis>tip "
4617 "revision</emphasis>, or simply the <emphasis>tip</emphasis>."
4618 msgstr ""
4620 #. type: Content of: <book><chapter><sect1><sect2><para>
4621 #: ../en/ch02-tour-basic.xml:750
4622 msgid ""
4623 "By the way, the <command role=\"hg-cmd\">hg tip</command> command accepts "
4624 "many of the same options as <command role=\"hg-cmd\">hg log</command>, so "
4625 "<option role=\"hg-opt-global\">-v</option> above indicates <quote>be verbose</"
4626 "quote>, <option role=\"hg-opt-tip\">-p</option> specifies <quote>print a "
4627 "patch</quote>. The use of <option role=\"hg-opt-tip\">-p</option> to print "
4628 "patches is another example of the consistent naming we mentioned earlier."
4629 msgstr ""
4631 #. type: Content of: <book><chapter><sect1><title>
4632 #: ../en/ch02-tour-basic.xml:762
4633 msgid "Sharing changes"
4634 msgstr "共享修改"
4636 #. type: Content of: <book><chapter><sect1><para>
4637 #: ../en/ch02-tour-basic.xml:764
4638 msgid ""
4639 "We mentioned earlier that repositories in Mercurial are self-contained. This "
4640 "means that the changeset we just created exists only in our <filename class="
4641 "\"directory\">my-hello</filename> repository. Let's look at a few ways that "
4642 "we can propagate this change into other repositories."
4643 msgstr ""
4645 #. type: Content of: <book><chapter><sect1><sect2><title>
4646 #: ../en/ch02-tour-basic.xml:772
4647 msgid "Pulling changes from another repository"
4648 msgstr "从其它版本库取得修改"
4650 #. type: Content of: <book><chapter><sect1><sect2><para>
4651 #: ../en/ch02-tour-basic.xml:774
4652 msgid ""
4653 "To get started, let's clone our original <filename class=\"directory\">hello</"
4654 "filename> repository, which does not contain the change we just committed. "
4655 "We'll call our temporary repository <filename class=\"directory\">hello-pull</"
4656 "filename>."
4657 msgstr ""
4659 #. type: Content of: <book><chapter><sect1><sect2><para>
4660 #: ../en/ch02-tour-basic.xml:782
4661 msgid ""
4662 "We'll use the <command role=\"hg-cmd\">hg pull</command> command to bring "
4663 "changes from <filename class=\"directory\">my-hello</filename> into <filename "
4664 "class=\"directory\">hello-pull</filename>. However, blindly pulling unknown "
4665 "changes into a repository is a somewhat scary prospect. Mercurial provides "
4666 "the <command role=\"hg-cmd\">hg incoming</command> command to tell us what "
4667 "changes the <command role=\"hg-cmd\">hg pull</command> command "
4668 "<emphasis>would</emphasis> pull into the repository, without actually pulling "
4669 "the changes in."
4670 msgstr ""
4672 #. type: Content of: <book><chapter><sect1><sect2><para>
4673 #: ../en/ch02-tour-basic.xml:795
4674 msgid ""
4675 "Bringing changes into a repository is a simple matter of running the <command "
4676 "role=\"hg-cmd\">hg pull</command> command, and optionally telling it which "
4677 "repository to pull from."
4678 msgstr ""
4680 #. type: Content of: <book><chapter><sect1><sect2><para>
4681 #: ../en/ch02-tour-basic.xml:801
4682 msgid ""
4683 "As you can see from the before-and-after output of <command role=\"hg-cmd"
4684 "\">hg tip</command>, we have successfully pulled changes into our "
4685 "repository. However, Mercurial separates pulling changes in from updating "
4686 "the working directory. There remains one step before we will see the changes "
4687 "that we just pulled appear in the working directory."
4688 msgstr ""
4690 #. type: Content of: <book><chapter><sect1><sect2><tip><title>
4691 #: ../en/ch02-tour-basic.xml:810
4692 msgid "Pulling specific changes"
4693 msgstr "提取指定的修改"
4695 #. type: Content of: <book><chapter><sect1><sect2><tip><para>
4696 #: ../en/ch02-tour-basic.xml:812
4697 msgid ""
4698 "It is possible that due to the delay between running <command role=\"hg-cmd"
4699 "\">hg incoming</command> and <command role=\"hg-cmd\">hg pull</command>, you "
4700 "may not see all changesets that will be brought from the other repository. "
4701 "Suppose you're pulling changes from a repository on the network somewhere. "
4702 "While you are looking at the <command role=\"hg-cmd\">hg incoming</command> "
4703 "output, and before you pull those changes, someone might have committed "
4704 "something in the remote repository. This means that it's possible to pull "
4705 "more changes than you saw when using <command role=\"hg-cmd\">hg incoming</"
4706 "command>."
4707 msgstr ""
4709 #. type: Content of: <book><chapter><sect1><sect2><tip><para>
4710 #: ../en/ch02-tour-basic.xml:824
4711 msgid ""
4712 "If you only want to pull precisely the changes that were listed by <command "
4713 "role=\"hg-cmd\">hg incoming</command>, or you have some other reason to pull "
4714 "a subset of changes, simply identify the change that you want to pull by its "
4715 "changeset ID, e.g. <command>hg pull -r7e95bb</command>."
4716 msgstr ""
4718 #. type: Content of: <book><chapter><sect1><sect2><title>
4719 #: ../en/ch02-tour-basic.xml:834
4720 msgid "Updating the working directory"
4721 msgstr "更新工作目录"
4723 #. type: Content of: <book><chapter><sect1><sect2><para>
4724 #: ../en/ch02-tour-basic.xml:836
4725 msgid ""
4726 "We have so far glossed over the relationship between a repository and its "
4727 "working directory. The <command role=\"hg-cmd\">hg pull</command> command "
4728 "that we ran in <xref linkend=\"sec:tour:pull\"/> brought changes into the "
4729 "repository, but if we check, there's no sign of those changes in the working "
4730 "directory. This is because <command role=\"hg-cmd\">hg pull</command> does "
4731 "not (by default) touch the working directory. Instead, we use the <command "
4732 "role=\"hg-cmd\">hg update</command> command to do this."
4733 msgstr ""
4735 #. type: Content of: <book><chapter><sect1><sect2><para>
4736 #: ../en/ch02-tour-basic.xml:848
4737 msgid ""
4738 "It might seem a bit strange that <command role=\"hg-cmd\">hg pull</command> "
4739 "doesn't update the working directory automatically. There's actually a good "
4740 "reason for this: you can use <command role=\"hg-cmd\">hg update</command> to "
4741 "update the working directory to the state it was in at <emphasis>any "
4742 "revision</emphasis> in the history of the repository. If you had the working "
4743 "directory updated to an old revision&emdash;to hunt down the origin of a bug, "
4744 "say&emdash;and ran a <command role=\"hg-cmd\">hg pull</command> which "
4745 "automatically updated the working directory to a new revision, you might not "
4746 "be terribly happy."
4747 msgstr ""
4749 #. type: Content of: <book><chapter><sect1><sect2><para>
4750 #: ../en/ch02-tour-basic.xml:860
4751 msgid ""
4752 "Since pull-then-update is such a common sequence of operations, Mercurial "
4753 "lets you combine the two by passing the <option role=\"hg-opt-pull\">-u</"
4754 "option> option to <command role=\"hg-cmd\">hg pull</command>."
4755 msgstr ""
4757 #. type: Content of: <book><chapter><sect1><sect2><para>
4758 #: ../en/ch02-tour-basic.xml:865
4759 msgid ""
4760 "If you look back at the output of <command role=\"hg-cmd\">hg pull</command> "
4761 "in <xref linkend=\"sec:tour:pull\"/> when we ran it without <option role=\"hg-"
4762 "opt-pull\">-u</option>, you can see that it printed a helpful reminder that "
4763 "we'd have to take an explicit step to update the working directory."
4764 msgstr ""
4766 #. type: Content of: <book><chapter><sect1><sect2><para>
4767 #: ../en/ch02-tour-basic.xml:872
4768 msgid ""
4769 "To find out what revision the working directory is at, use the <command role="
4770 "\"hg-cmd\">hg parents</command> command."
4771 msgstr ""
4773 #. type: Content of: <book><chapter><sect1><sect2><para>
4774 #: ../en/ch02-tour-basic.xml:878
4775 msgid ""
4776 "If you look back at <xref linkend=\"fig:tour-basic:history\"/>, you'll see "
4777 "arrows connecting each changeset. The node that the arrow leads "
4778 "<emphasis>from</emphasis> in each case is a parent, and the node that the "
4779 "arrow leads <emphasis>to</emphasis> is its child. The working directory has "
4780 "a parent in just the same way; this is the changeset that the working "
4781 "directory currently contains."
4782 msgstr ""
4784 #. type: Content of: <book><chapter><sect1><sect2><para>
4785 #: ../en/ch02-tour-basic.xml:887
4786 msgid ""
4787 "To update the working directory to a particular revision, give a revision "
4788 "number or changeset ID to the <command role=\"hg-cmd\">hg update</command> "
4789 "command."
4790 msgstr ""
4792 #. type: Content of: <book><chapter><sect1><sect2><para>
4793 #: ../en/ch02-tour-basic.xml:893
4794 msgid ""
4795 "If you omit an explicit revision, <command role=\"hg-cmd\">hg update</"
4796 "command> will update to the tip revision, as shown by the second call to "
4797 "<command role=\"hg-cmd\">hg update</command> in the example above."
4798 msgstr ""
4800 #. type: Content of: <book><chapter><sect1><sect2><title>
4801 #: ../en/ch02-tour-basic.xml:901
4802 msgid "Pushing changes to another repository"
4803 msgstr "发布修改到其它版本库"
4805 #. type: Content of: <book><chapter><sect1><sect2><para>
4806 #: ../en/ch02-tour-basic.xml:903
4807 msgid ""
4808 "Mercurial lets us push changes to another repository, from the repository "
4809 "we're currently visiting. As with the example of <command role=\"hg-cmd\">hg "
4810 "pull</command> above, we'll create a temporary repository to push our changes "
4811 "into."
4812 msgstr ""
4814 #. type: Content of: <book><chapter><sect1><sect2><para>
4815 #: ../en/ch02-tour-basic.xml:911
4816 msgid ""
4817 "The <command role=\"hg-cmd\">hg outgoing</command> command tells us what "
4818 "changes would be pushed into another repository."
4819 msgstr ""
4821 #. type: Content of: <book><chapter><sect1><sect2><para>
4822 #: ../en/ch02-tour-basic.xml:917
4823 msgid ""
4824 "And the <command role=\"hg-cmd\">hg push</command> command does the actual "
4825 "push."
4826 msgstr ""
4828 #. type: Content of: <book><chapter><sect1><sect2><para>
4829 #: ../en/ch02-tour-basic.xml:922
4830 msgid ""
4831 "As with <command role=\"hg-cmd\">hg pull</command>, the <command role=\"hg-cmd"
4832 "\">hg push</command> command does not update the working directory in the "
4833 "repository that it's pushing changes into. Unlike <command role=\"hg-cmd\">hg "
4834 "pull</command>, <command role=\"hg-cmd\">hg push</command> does not provide a "
4835 "<literal>-u</literal> option that updates the other repository's working "
4836 "directory. This asymmetry is deliberate: the repository we're pushing to "
4837 "might be on a remote server and shared between several people. If we were to "
4838 "update its working directory while someone was working in it, their work "
4839 "would be disrupted."
4840 msgstr ""
4842 #. type: Content of: <book><chapter><sect1><sect2><para>
4843 #: ../en/ch02-tour-basic.xml:934
4844 msgid ""
4845 "What happens if we try to pull or push changes and the receiving repository "
4846 "already has those changes? Nothing too exciting."
4847 msgstr ""
4849 #. type: Content of: <book><chapter><sect1><sect2><title>
4850 #: ../en/ch02-tour-basic.xml:942
4851 msgid "Default locations"
4852 msgstr "默认位置"
4854 #. type: Content of: <book><chapter><sect1><sect2><para>
4855 #: ../en/ch02-tour-basic.xml:944
4856 msgid ""
4857 "When we clone a repository, Mercurial records the location of the repository "
4858 "we cloned in the <filename>.hg/hgrc</filename> file of the new repository. "
4859 "If we don't supply a location to <command>hg pull</command> from or "
4860 "<command>hg push</command> to, those commands will use this location as a "
4861 "default. The <command>hg incoming</command> and <command>hg outgoing</"
4862 "command> commands do so too."
4863 msgstr ""
4865 #. type: Content of: <book><chapter><sect1><sect2><para>
4866 #: ../en/ch02-tour-basic.xml:952
4867 msgid ""
4868 "If you open a repository's <filename>.hg/hgrc</filename> file in a text "
4869 "editor, you will see contents like the following."
4870 msgstr ""
4872 #. type: Content of: <book><chapter><sect1><sect2><para>
4873 #: ../en/ch02-tour-basic.xml:959
4874 msgid ""
4875 "It is possible&emdash;and often useful&emdash;to have the default location "
4876 "for <command>hg push</command> and <command>hg outgoing</command> be "
4877 "different from those for <command>hg pull</command> and <command>hg incoming</"
4878 "command>. We can do this by adding a <literal>default-push</literal> entry "
4879 "to the <literal>[paths]</literal> section of the <filename>.hg/hgrc</"
4880 "filename> file, as follows."
4881 msgstr ""
4883 #. type: Content of: <book><chapter><sect1><sect2><title>
4884 #: ../en/ch02-tour-basic.xml:973
4885 msgid "Sharing changes over a network"
4886 msgstr "通过网络共享修改"
4888 #. type: Content of: <book><chapter><sect1><sect2><para>
4889 #: ../en/ch02-tour-basic.xml:975
4890 msgid ""
4891 "The commands we have covered in the previous few sections are not limited to "
4892 "working with local repositories. Each works in exactly the same fashion over "
4893 "a network connection; simply pass in a URL instead of a local path."
4894 msgstr ""
4896 #. type: Content of: <book><chapter><sect1><sect2><para>
4897 #: ../en/ch02-tour-basic.xml:983
4898 msgid ""
4899 "In this example, we can see what changes we could push to the remote "
4900 "repository, but the repository is understandably not set up to let anonymous "
4901 "users push to it."
4902 msgstr ""
4904 #. type: Content of: <book><chapter><sect1><title>
4905 #: ../en/ch02-tour-basic.xml:993
4906 msgid "Starting a new project"
4907 msgstr "开始新项目"
4909 #. type: Content of: <book><chapter><sect1><para>
4910 #: ../en/ch02-tour-basic.xml:995
4911 msgid ""
4912 "It is just as easy to begin a new project as to work on one that already "
4913 "exists. The <command>hg init</command> command creates a new, empty "
4914 "Mercurial repository."
4915 msgstr ""
4917 #. type: Content of: <book><chapter><sect1><para>
4918 #: ../en/ch02-tour-basic.xml:1001
4919 msgid ""
4920 "This simply creates a repository named <filename>myproject</filename> in the "
4921 "current directory."
4922 msgstr ""
4924 #. type: Content of: <book><chapter><sect1><para>
4925 #: ../en/ch02-tour-basic.xml:1006
4926 msgid ""
4927 "We can tell that <filename>myproject</filename> is a Mercurial repository, "
4928 "because it contains a <filename>.hg</filename> directory."
4929 msgstr ""
4931 #. type: Content of: <book><chapter><sect1><para>
4932 #: ../en/ch02-tour-basic.xml:1012
4933 msgid ""
4934 "If we want to add some pre-existing files to the repository, we copy them "
4935 "into place, and tell Mercurial to start tracking them using the <command>hg "
4936 "add</command> command."
4937 msgstr ""
4939 #. type: Content of: <book><chapter><sect1><para>
4940 #: ../en/ch02-tour-basic.xml:1018
4941 msgid ""
4942 "Once we are satisfied that our project looks right, we commit our changes."
4943 msgstr ""
4945 #. type: Content of: <book><chapter><sect1><para>
4946 #: ../en/ch02-tour-basic.xml:1023
4947 msgid ""
4948 "It takes just a few moments to start using Mercurial on a new project, which "
4949 "is part of its appeal. Revision control is now so easy to work with, we can "
4950 "use it on the smallest of projects that we might not have considered with a "
4951 "more complicated tool."
4952 msgstr ""
4954 #. type: Content of: <book><chapter><title>
4955 #: ../en/ch03-tour-merge.xml:5
4956 msgid "A tour of Mercurial: merging work"
4957 msgstr "Mercurial 教程: 合并工作"
4959 #. type: Content of: <book><chapter><para>
4960 #: ../en/ch03-tour-merge.xml:7
4961 msgid ""
4962 "We've now covered cloning a repository, making changes in a repository, and "
4963 "pulling or pushing changes from one repository into another. Our next step "
4964 "is <emphasis>merging</emphasis> changes from separate repositories."
4965 msgstr ""
4967 #. type: Content of: <book><chapter><sect1><title>
4968 #: ../en/ch03-tour-merge.xml:13
4969 msgid "Merging streams of work"
4970 msgstr "合并的流程"
4972 #. type: Content of: <book><chapter><sect1><para>
4973 #: ../en/ch03-tour-merge.xml:15
4974 msgid ""
4975 "Merging is a fundamental part of working with a distributed revision control "
4976 "tool. Here are a few cases in which the need to merge work arises."
4977 msgstr ""
4979 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
4980 #: ../en/ch03-tour-merge.xml:20
4981 msgid ""
4982 "Alice and Bob each have a personal copy of a repository for a project they're "
4983 "collaborating on. Alice fixes a bug in her repository; Bob adds a new "
4984 "feature in his. They want the shared repository to contain both the bug fix "
4985 "and the new feature."
4986 msgstr ""
4988 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
4989 #: ../en/ch03-tour-merge.xml:27
4990 msgid ""
4991 "Cynthia frequently works on several different tasks for a single project at "
4992 "once, each safely isolated in its own repository. Working this way means that "
4993 "she often needs to merge one piece of her own work with another."
4994 msgstr ""
4996 #. type: Content of: <book><chapter><sect1><para>
4997 #: ../en/ch03-tour-merge.xml:35
4998 msgid ""
4999 "Because we need to merge often, Mercurial makes the process easy. Let's walk "
5000 "through a merge. We'll begin by cloning yet another repository (see how "
5001 "often they spring up?) and making a change in it."
5002 msgstr ""
5004 #. type: Content of: <book><chapter><sect1><para>
5005 #: ../en/ch03-tour-merge.xml:42
5006 msgid ""
5007 "We should now have two copies of <filename>hello.c</filename> with different "
5008 "contents. The histories of the two repositories have also diverged, as "
5009 "illustrated in <xref linkend=\"fig:tour-merge:sep-repos\"/>. Here is a copy "
5010 "of our file from one repository."
5011 msgstr ""
5013 #. type: Content of: <book><chapter><sect1><para>
5014 #: ../en/ch03-tour-merge.xml:51
5015 msgid "And here is our slightly different version from the other repository."
5016 msgstr ""
5018 #. type: Content of: <book><chapter><sect1><figure><title>
5019 #: ../en/ch03-tour-merge.xml:57
5020 msgid ""
5021 "Divergent recent histories of the <filename class=\"directory\">my-hello</"
5022 "filename> and <filename class=\"directory\">my-new-hello</filename> "
5023 "repositories"
5024 msgstr ""
5025 "<filename class=\"directory\">my-hello</filename> 与 <filename class="
5026 "\"directory\">my-new-hello</filename> 最新的历史分叉"
5028 #. type: Content of: <book><chapter><sect1><figure><mediaobject>
5029 #: ../en/ch03-tour-merge.xml:62
5030 msgid ""
5031 "<imageobject><imagedata fileref=\"figs/tour-merge-sep-repos.png\"/></"
5032 "imageobject>"
5033 msgstr ""
5035 #. type: Content of: <book><chapter><sect1><para>
5036 #: ../en/ch03-tour-merge.xml:67
5037 msgid ""
5038 "We already know that pulling changes from our <filename class=\"directory"
5039 "\">my-hello</filename> repository will have no effect on the working "
5040 "directory."
5041 msgstr ""
5043 #. type: Content of: <book><chapter><sect1><para>
5044 #: ../en/ch03-tour-merge.xml:73
5045 msgid ""
5046 "However, the <command role=\"hg-cmd\">hg pull</command> command says "
5047 "something about <quote>heads</quote>."
5048 msgstr ""
5050 #. type: Content of: <book><chapter><sect1><sect2><title>
5051 #: ../en/ch03-tour-merge.xml:77
5052 msgid "Head changesets"
5053 msgstr "顶点修改集"
5055 #. type: Content of: <book><chapter><sect1><sect2><para>
5056 #: ../en/ch03-tour-merge.xml:79
5057 msgid ""
5058 "Remember that Mercurial records what the parent of each change is. If a "
5059 "change has a parent, we call it a child or descendant of the parent. A head "
5060 "is a change that has no children. The tip revision is thus a head, because "
5061 "the newest revision in a repository doesn't have any children. There are "
5062 "times when a repository can contain more than one head."
5063 msgstr ""
5065 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
5066 #: ../en/ch03-tour-merge.xml:88
5067 msgid ""
5068 "Repository contents after pulling from <filename class=\"directory\">my-"
5069 "hello</filename> into <filename class=\"directory\">my-new-hello</filename>"
5070 msgstr ""
5071 "从 <filename class=\"directory\">my-hello</filename> 拉到 <filename class="
5072 "\"directory\">my-new-hello</filename> 之后版本库的内容"
5074 #. type: Content of: <book><chapter><sect1><sect2><figure>
5075 #: ../en/ch03-tour-merge.xml:91 ../en/ch03-tour-merge.xml:178
5076 #: ../en/ch03-tour-merge.xml:275 ../en/ch04-concepts.xml:57
5077 #: ../en/ch04-concepts.xml:106 ../en/ch04-concepts.xml:196
5078 #: ../en/ch04-concepts.xml:345 ../en/ch04-concepts.xml:360
5079 #: ../en/ch04-concepts.xml:401 ../en/ch04-concepts.xml:421
5080 #: ../en/ch04-concepts.xml:465 ../en/ch06-collab.xml:314
5081 #: ../en/ch09-undo.xml:342 ../en/ch09-undo.xml:389 ../en/ch09-undo.xml:462
5082 #: ../en/ch09-undo.xml:500 ../en/ch09-undo.xml:656 ../en/ch09-undo.xml:680
5083 #: ../en/ch09-undo.xml:698 ../en/ch09-undo.xml:712 ../en/ch09-undo.xml:725
5084 #: ../en/ch12-mq.xml:411
5085 msgid " <placeholder type=\"mediaobject\" id=\"0\"/>"
5086 msgstr ""
5088 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
5089 #: ../en/ch03-tour-merge.xml:92
5090 msgid ""
5091 "<imageobject> <imagedata fileref=\"figs/tour-merge-pull.png\"/> </imageobject>"
5092 msgstr ""
5094 #. type: Content of: <book><chapter><sect1><sect2><para>
5095 #: ../en/ch03-tour-merge.xml:99
5096 msgid ""
5097 "In <xref linkend=\"fig:tour-merge:pull\"/>, you can see the effect of the "
5098 "pull from <filename class=\"directory\">my-hello</filename> into <filename "
5099 "class=\"directory\">my-new-hello</filename>. The history that was already "
5100 "present in <filename class=\"directory\">my-new-hello</filename> is "
5101 "untouched, but a new revision has been added. By referring to <xref linkend="
5102 "\"fig:tour-merge:sep-repos\"/>, we can see that the <emphasis>changeset ID</"
5103 "emphasis> remains the same in the new repository, but the <emphasis>revision "
5104 "number</emphasis> has changed. (This, incidentally, is a fine example of why "
5105 "it's not safe to use revision numbers when discussing changesets.) We can "
5106 "view the heads in a repository using the <command role=\"hg-cmd\">hg heads</"
5107 "command> command."
5108 msgstr ""
5110 #. type: Content of: <book><chapter><sect1><sect2><title>
5111 #: ../en/ch03-tour-merge.xml:118
5112 msgid "Performing the merge"
5113 msgstr "执行合并"
5115 #. type: Content of: <book><chapter><sect1><sect2><para>
5116 #: ../en/ch03-tour-merge.xml:120
5117 msgid ""
5118 "What happens if we try to use the normal <command role=\"hg-cmd\">hg update</"
5119 "command> command to update to the new tip?"
5120 msgstr ""
5122 #. type: Content of: <book><chapter><sect1><sect2><para>
5123 #: ../en/ch03-tour-merge.xml:126
5124 msgid ""
5125 "Mercurial is telling us that the <command role=\"hg-cmd\">hg update</command> "
5126 "command won't do a merge; it won't update the working directory when it "
5127 "thinks we might want to do a merge, unless we force it to do so. "
5128 "(Incidentally, forcing the update with <command>hg update -C</command> would "
5129 "revert any uncommitted changes in the working directory.)"
5130 msgstr ""
5132 #. type: Content of: <book><chapter><sect1><sect2><para>
5133 #: ../en/ch03-tour-merge.xml:134
5134 msgid ""
5135 "To start a merge between the two heads, we use the <command role=\"hg-cmd"
5136 "\">hg merge</command> command."
5137 msgstr ""
5138 "我们使用 <command role=\"hg-cmd\">hg merge</command> 命令来合并两个顶点。"
5140 #. type: Content of: <book><chapter><sect1><sect2><para>
5141 #: ../en/ch03-tour-merge.xml:139
5142 msgid ""
5143 "We resolve the contents of <filename>hello.c</filename> This updates the "
5144 "working directory so that it contains changes from <emphasis>both</emphasis> "
5145 "heads, which is reflected in both the output of <command role=\"hg-cmd\">hg "
5146 "parents</command> and the contents of <filename>hello.c</filename>."
5147 msgstr ""
5149 #. type: Content of: <book><chapter><sect1><sect2><title>
5150 #: ../en/ch03-tour-merge.xml:151
5151 msgid "Committing the results of the merge"
5152 msgstr "提交合并结果"
5154 #. type: Content of: <book><chapter><sect1><sect2><para>
5155 #: ../en/ch03-tour-merge.xml:153
5156 msgid ""
5157 "Whenever we've done a merge, <command role=\"hg-cmd\">hg parents</command> "
5158 "will display two parents until we <command role=\"hg-cmd\">hg commit</"
5159 "command> the results of the merge."
5160 msgstr ""
5162 #. type: Content of: <book><chapter><sect1><sect2><para>
5163 #: ../en/ch03-tour-merge.xml:160
5164 msgid ""
5165 "We now have a new tip revision; notice that it has <emphasis>both</emphasis> "
5166 "of our former heads as its parents. These are the same revisions that were "
5167 "previously displayed by <command role=\"hg-cmd\">hg parents</command>."
5168 msgstr ""
5170 #. type: Content of: <book><chapter><sect1><sect2><para>
5171 #: ../en/ch03-tour-merge.xml:167
5172 msgid ""
5173 "In <xref linkend=\"fig:tour-merge:merge\"/>, you can see a representation of "
5174 "what happens to the working directory during the merge, and how this affects "
5175 "the repository when the commit happens. During the merge, the working "
5176 "directory has two parent changesets, and these become the parents of the new "
5177 "changeset."
5178 msgstr ""
5180 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
5181 #: ../en/ch03-tour-merge.xml:176
5182 msgid "Working directory and repository during merge, and following commit"
5183 msgstr "在合并期间,以及提交之后的工作目录与版本库"
5185 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
5186 #: ../en/ch03-tour-merge.xml:179
5187 msgid ""
5188 "<imageobject> <imagedata fileref=\"figs/tour-merge-merge.png\"/> </"
5189 "imageobject>"
5190 msgstr ""
5192 #. type: Content of: <book><chapter><sect1><sect2><para>
5193 #: ../en/ch03-tour-merge.xml:186
5194 msgid ""
5195 "We sometimes talk about a merge having <emphasis>sides</emphasis>: the left "
5196 "side is the first parent in the output of <command role=\"hg-cmd\">hg "
5197 "parents</command>, and the right side is the second. If the working "
5198 "directory was at e.g. revision 5 before we began a merge, that revision will "
5199 "become the left side of the merge."
5200 msgstr ""
5202 #. type: Content of: <book><chapter><sect1><title>
5203 #: ../en/ch03-tour-merge.xml:196
5204 msgid "Merging conflicting changes"
5205 msgstr "合并有冲突的改变"
5207 #. type: Content of: <book><chapter><sect1><para>
5208 #: ../en/ch03-tour-merge.xml:198
5209 msgid ""
5210 "Most merges are simple affairs, but sometimes you'll find yourself merging "
5211 "changes where each side modifies the same portions of the same files. Unless "
5212 "both modifications are identical, this results in a <emphasis>conflict</"
5213 "emphasis>, where you have to decide how to reconcile the different changes "
5214 "into something coherent."
5215 msgstr ""
5217 #. type: Content of: <book><chapter><sect1><figure><title>
5218 #: ../en/ch03-tour-merge.xml:206
5219 msgid "Conflicting changes to a document"
5220 msgstr "冲突的修改"
5222 #. type: Content of: <book><chapter><sect1><figure><mediaobject>
5223 #: ../en/ch03-tour-merge.xml:208
5224 msgid ""
5225 "<imageobject><imagedata fileref=\"figs/tour-merge-conflict.png\"/></"
5226 "imageobject>"
5227 msgstr ""
5229 #. type: Content of: <book><chapter><sect1><para>
5230 #: ../en/ch03-tour-merge.xml:213
5231 msgid ""
5232 "<xref linkend=\"fig:tour-merge:conflict\"/> illustrates an instance of two "
5233 "conflicting changes to a document. We started with a single version of the "
5234 "file; then we made some changes; while someone else made different changes to "
5235 "the same text. Our task in resolving the conflicting changes is to decide "
5236 "what the file should look like."
5237 msgstr ""
5239 #. type: Content of: <book><chapter><sect1><para>
5240 #: ../en/ch03-tour-merge.xml:220
5241 msgid ""
5242 "Mercurial doesn't have a built-in facility for handling conflicts. Instead, "
5243 "it runs an external program, usually one that displays some kind of graphical "
5244 "conflict resolution interface. By default, Mercurial tries to find one of "
5245 "several different merging tools that are likely to be installed on your "
5246 "system. It first tries a few fully automatic merging tools; if these don't "
5247 "succeed (because the resolution process requires human guidance) or aren't "
5248 "present, it tries a few different graphical merging tools."
5249 msgstr ""
5251 #. type: Content of: <book><chapter><sect1><para>
5252 #: ../en/ch03-tour-merge.xml:230
5253 msgid ""
5254 "It's also possible to get Mercurial to run a specific program or script, by "
5255 "setting the <envar>HGMERGE</envar> environment variable to the name of your "
5256 "preferred program."
5257 msgstr ""
5259 #. type: Content of: <book><chapter><sect1><sect2><title>
5260 #: ../en/ch03-tour-merge.xml:236
5261 msgid "Using a graphical merge tool"
5262 msgstr "使用图形合并工具"
5264 #. type: Content of: <book><chapter><sect1><sect2><para>
5265 #: ../en/ch03-tour-merge.xml:238
5266 msgid ""
5267 "My preferred graphical merge tool is <command>kdiff3</command>, which I'll "
5268 "use to describe the features that are common to graphical file merging "
5269 "tools. You can see a screenshot of <command>kdiff3</command> in action in "
5270 "<xref linkend=\"fig:tour-merge:kdiff3\"/>. The kind of merge it is "
5271 "performing is called a <emphasis>three-way merge</emphasis>, because there "
5272 "are three different versions of the file of interest to us. The tool thus "
5273 "splits the upper portion of the window into three panes:"
5274 msgstr ""
5276 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
5277 #: ../en/ch03-tour-merge.xml:248
5278 msgid ""
5279 "At the left is the <emphasis>base</emphasis> version of the file, i.e. the "
5280 "most recent version from which the two versions we're trying to merge are "
5281 "descended."
5282 msgstr ""
5284 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
5285 #: ../en/ch03-tour-merge.xml:253
5286 msgid ""
5287 "In the middle is <quote>our</quote> version of the file, with the contents "
5288 "that we modified."
5289 msgstr ""
5291 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
5292 #: ../en/ch03-tour-merge.xml:256
5293 msgid ""
5294 "On the right is <quote>their</quote> version of the file, the one that from "
5295 "the changeset that we're trying to merge with."
5296 msgstr ""
5298 #. type: Content of: <book><chapter><sect1><sect2><para>
5299 #: ../en/ch03-tour-merge.xml:260
5300 msgid ""
5301 "In the pane below these is the current <emphasis>result</emphasis> of the "
5302 "merge. Our task is to replace all of the red text, which indicates unresolved "
5303 "conflicts, with some sensible merger of the <quote>ours</quote> and "
5304 "<quote>theirs</quote> versions of the file."
5305 msgstr ""
5307 #. type: Content of: <book><chapter><sect1><sect2><para>
5308 #: ../en/ch03-tour-merge.xml:267
5309 msgid ""
5310 "All four of these panes are <emphasis>locked together</emphasis>; if we "
5311 "scroll vertically or horizontally in any of them, the others are updated to "
5312 "display the corresponding sections of their respective files."
5313 msgstr ""
5315 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
5316 #: ../en/ch03-tour-merge.xml:273
5317 msgid "Using <command>kdiff3</command> to merge versions of a file"
5318 msgstr "使用 <command>kdiff3</command> 合并文件的不同版本"
5320 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
5321 #: ../en/ch03-tour-merge.xml:276
5322 msgid ""
5323 "<imageobject> <imagedata width=\"100%\" fileref=\"figs/kdiff3.png\"/></"
5324 "imageobject>"
5325 msgstr ""
5327 #. type: Content of: <book><chapter><sect1><sect2><para>
5328 #: ../en/ch03-tour-merge.xml:284
5329 msgid ""
5330 "For each conflicting portion of the file, we can choose to resolve the "
5331 "conflict using some combination of text from the base version, ours, or "
5332 "theirs. We can also manually edit the merged file at any time, in case we "
5333 "need to make further modifications."
5334 msgstr ""
5336 #. type: Content of: <book><chapter><sect1><sect2><para>
5337 #: ../en/ch03-tour-merge.xml:290
5338 msgid ""
5339 "There are <emphasis>many</emphasis> file merging tools available, too many to "
5340 "cover here. They vary in which platforms they are available for, and in "
5341 "their particular strengths and weaknesses. Most are tuned for merging files "
5342 "containing plain text, while a few are aimed at specialised file formats "
5343 "(generally XML)."
5344 msgstr ""
5346 #. type: Content of: <book><chapter><sect1><sect2><title>
5347 #: ../en/ch03-tour-merge.xml:299
5348 msgid "A worked example"
5349 msgstr "合并实例"
5351 #. type: Content of: <book><chapter><sect1><sect2><para>
5352 #: ../en/ch03-tour-merge.xml:301
5353 msgid ""
5354 "In this example, we will reproduce the file modification history of <xref "
5355 "linkend=\"fig:tour-merge:conflict\"/> above. Let's begin by creating a "
5356 "repository with a base version of our document."
5357 msgstr ""
5359 #. type: Content of: <book><chapter><sect1><sect2><para>
5360 #: ../en/ch03-tour-merge.xml:308
5361 msgid "We'll clone the repository and make a change to the file."
5362 msgstr ""
5364 #. type: Content of: <book><chapter><sect1><sect2><para>
5365 #: ../en/ch03-tour-merge.xml:313
5366 msgid ""
5367 "And another clone, to simulate someone else making a change to the file. "
5368 "(This hints at the idea that it's not all that unusual to merge with yourself "
5369 "when you isolate tasks in separate repositories, and indeed to find and "
5370 "resolve conflicts while doing so.)"
5371 msgstr ""
5373 #. type: Content of: <book><chapter><sect1><sect2><para>
5374 #: ../en/ch03-tour-merge.xml:321
5375 msgid ""
5376 "Having created two different versions of the file, we'll set up an "
5377 "environment suitable for running our merge."
5378 msgstr ""
5380 #. type: Content of: <book><chapter><sect1><sect2><para>
5381 #: ../en/ch03-tour-merge.xml:327
5382 msgid ""
5383 "In this example, I'll set <envar>HGMERGE</envar> to tell Mercurial to use the "
5384 "non-interactive <command>merge</command> command. This is bundled with many "
5385 "Unix-like systems. (If you're following this example on your computer, don't "
5386 "bother setting <envar>HGMERGE</envar>. You'll get dropped into a GUI file "
5387 "merge tool instead, which is much preferable.)"
5388 msgstr ""
5390 #. type: Content of: <book><chapter><sect1><sect2><para>
5391 #: ../en/ch03-tour-merge.xml:337
5392 msgid ""
5393 "Because <command>merge</command> can't resolve the conflicting changes, it "
5394 "leaves <emphasis>merge markers</emphasis> inside the file that has conflicts, "
5395 "indicating which lines have conflicts, and whether they came from our version "
5396 "of the file or theirs."
5397 msgstr ""
5399 #. type: Content of: <book><chapter><sect1><sect2><para>
5400 #: ../en/ch03-tour-merge.xml:343
5401 msgid ""
5402 "Mercurial can tell from the way <command>merge</command> exits that it wasn't "
5403 "able to merge successfully, so it tells us what commands we'll need to run if "
5404 "we want to redo the merging operation. This could be useful if, for example, "
5405 "we were running a graphical merge tool and quit because we were confused or "
5406 "realised we had made a mistake."
5407 msgstr ""
5409 #. type: Content of: <book><chapter><sect1><sect2><para>
5410 #: ../en/ch03-tour-merge.xml:350
5411 msgid ""
5412 "If automatic or manual merges fail, there's nothing to prevent us from "
5413 "<quote>fixing up</quote> the affected files ourselves, and committing the "
5414 "results of our merge:"
5415 msgstr ""
5417 #. type: Content of: <book><chapter><sect1><sect2><note><title>
5418 #: ../en/ch03-tour-merge.xml:357
5419 msgid "Where is the <command>hg resolve</command> command?"
5420 msgstr "在哪里能找到 <command role=\"hg-cmd\">hg resolve</command> 命令?"
5422 #. type: Content of: <book><chapter><sect1><sect2><note><para>
5423 #: ../en/ch03-tour-merge.xml:359
5424 msgid ""
5425 "The <command>hg resolve</command> command was introduced in Mercurial 1.1, "
5426 "which was released in December 2008. If you are using an older version of "
5427 "Mercurial (run <command>hg version</command> to see), this command will not "
5428 "be present. If your version of Mercurial is older than 1.1, you should "
5429 "strongly consider upgrading to a newer version before trying to tackle "
5430 "complicated merges."
5431 msgstr ""
5433 #. type: Content of: <book><chapter><sect1><title>
5434 #: ../en/ch03-tour-merge.xml:371
5435 msgid "Simplifying the pull-merge-commit sequence"
5436 msgstr "简化拉-合并-提交程序"
5438 #. type: Content of: <book><chapter><sect1><para>
5439 #: ../en/ch03-tour-merge.xml:373
5440 msgid ""
5441 "The process of merging changes as outlined above is straightforward, but "
5442 "requires running three commands in sequence."
5443 msgstr ""
5445 #. type: Content of: <book><chapter><sect1><para>
5446 #: ../en/ch03-tour-merge.xml:379
5447 msgid ""
5448 "In the case of the final commit, you also need to enter a commit message, "
5449 "which is almost always going to be a piece of uninteresting "
5450 "<quote>boilerplate</quote> text."
5451 msgstr ""
5453 #. type: Content of: <book><chapter><sect1><para>
5454 #: ../en/ch03-tour-merge.xml:383
5455 msgid ""
5456 "It would be nice to reduce the number of steps needed, if this were "
5457 "possible. Indeed, Mercurial is distributed with an extension called <literal "
5458 "role=\"hg-ext\">fetch</literal> that does just this."
5459 msgstr ""
5461 #. type: Content of: <book><chapter><sect1><para>
5462 #: ../en/ch03-tour-merge.xml:388
5463 msgid ""
5464 "Mercurial provides a flexible extension mechanism that lets people extend its "
5465 "functionality, while keeping the core of Mercurial small and easy to deal "
5466 "with. Some extensions add new commands that you can use from the command "
5467 "line, while others work <quote>behind the scenes,</quote> for example adding "
5468 "capabilities to Mercurial's built-in server mode."
5469 msgstr ""
5471 #. type: Content of: <book><chapter><sect1><para>
5472 #: ../en/ch03-tour-merge.xml:395
5473 msgid ""
5474 "The <literal role=\"hg-ext\">fetch</literal> extension adds a new command "
5475 "called, not surprisingly, <command role=\"hg-cmd\">hg fetch</command>. This "
5476 "extension acts as a combination of <command role=\"hg-cmd\">hg pull -u</"
5477 "command>, <command role=\"hg-cmd\">hg merge</command> and <command role=\"hg-"
5478 "cmd\">hg commit</command>. It begins by pulling changes from another "
5479 "repository into the current repository. If it finds that the changes added a "
5480 "new head to the repository, it updates to the new head, begins a merge, then "
5481 "(if the merge succeeded) commits the result of the merge with an "
5482 "automatically-generated commit message. If no new heads were added, it "
5483 "updates the working directory to the new tip changeset."
5484 msgstr ""
5486 #. type: Content of: <book><chapter><sect1><para>
5487 #: ../en/ch03-tour-merge.xml:409
5488 msgid ""
5489 "Enabling the <literal role=\"hg-ext\">fetch</literal> extension is easy. "
5490 "Edit the <filename role=\"special\">.hgrc</filename> file in your home "
5491 "directory, and either go to the <literal role=\"rc-extensions\">extensions</"
5492 "literal> section or create an <literal role=\"rc-extensions\">extensions</"
5493 "literal> section. Then add a line that simply reads <quote><literal>fetch=</"
5494 "literal></quote>."
5495 msgstr ""
5497 #. type: Content of: <book><chapter><sect1><para>
5498 #: ../en/ch03-tour-merge.xml:421
5499 msgid ""
5500 "(Normally, the right-hand side of the <quote><literal>=</literal></quote> "
5501 "would indicate where to find the extension, but since the <literal role=\"hg-"
5502 "ext\">fetch</literal> extension is in the standard distribution, Mercurial "
5503 "knows where to search for it.)"
5504 msgstr ""
5506 #. type: Content of: <book><chapter><sect1><title>
5507 #: ../en/ch03-tour-merge.xml:429
5508 msgid "Renaming, copying, and merging"
5509 msgstr "改名,复制与合并"
5511 #. type: Content of: <book><chapter><sect1><para>
5512 #: ../en/ch03-tour-merge.xml:431
5513 msgid ""
5514 "During the life of a project, we will often want to change the layout of its "
5515 "files and directories. This can be as simple as renaming a single file, or as "
5516 "complex as restructuring the entire hierarchy of files within the project."
5517 msgstr ""
5519 #. type: Content of: <book><chapter><sect1><para>
5520 #: ../en/ch03-tour-merge.xml:436
5521 msgid ""
5522 "Mercurial supports these kinds of complex changes fluently, provided we tell "
5523 "it what we're doing. If we want to rename a file, we should use the "
5524 "<command>hg rename</command><placeholder type=\"footnote\" id=\"0\"/> command "
5525 "to rename it, so that Mercurial can do the right thing later when we merge."
5526 msgstr ""
5528 #. type: Content of: <book><chapter><sect1><para><footnote><para>
5529 #: ../en/ch03-tour-merge.xml:439
5530 msgid ""
5531 "If you're a Unix user, you'll be glad to know that the <command>hg rename</"
5532 "command> command can be abbreviated as <command>hg mv</command>."
5533 msgstr ""
5535 #. type: Content of: <book><chapter><sect1><para>
5536 #: ../en/ch03-tour-merge.xml:445
5537 msgid ""
5538 "We will cover the use of these commands in more detail in <xref linkend="
5539 "\"chap:daily.copy\"/>."
5540 msgstr ""
5542 #. type: Content of: <book><chapter><title>
5543 #: ../en/ch04-concepts.xml:5
5544 msgid "Behind the scenes"
5545 msgstr "Mercurial 内幕"
5547 #. type: Content of: <book><chapter><para>
5548 #: ../en/ch04-concepts.xml:7
5549 msgid ""
5550 "Unlike many revision control systems, the concepts upon which Mercurial is "
5551 "built are simple enough that it's easy to understand how the software really "
5552 "works. Knowing these details certainly isn't necessary, so it is certainly "
5553 "safe to skip this chapter. However, I think you will get more out of the "
5554 "software with a <quote>mental model</quote> of what's going on."
5555 msgstr ""
5557 #. type: Content of: <book><chapter><para>
5558 #: ../en/ch04-concepts.xml:14
5559 msgid ""
5560 "Being able to understand what's going on behind the scenes gives me "
5561 "confidence that Mercurial has been carefully designed to be both "
5562 "<emphasis>safe</emphasis> and <emphasis>efficient</emphasis>. And just as "
5563 "importantly, if it's easy for me to retain a good idea of what the software "
5564 "is doing when I perform a revision control task, I'm less likely to be "
5565 "surprised by its behavior."
5566 msgstr ""
5568 #. type: Content of: <book><chapter><para>
5569 #: ../en/ch04-concepts.xml:22
5570 msgid ""
5571 "In this chapter, we'll initially cover the core concepts behind Mercurial's "
5572 "design, then continue to discuss some of the interesting details of its "
5573 "implementation."
5574 msgstr ""
5576 #. type: Content of: <book><chapter><sect1><title>
5577 #: ../en/ch04-concepts.xml:27
5578 msgid "Mercurial's historical record"
5579 msgstr "Mercurial 的历史记录"
5581 #. type: Content of: <book><chapter><sect1><sect2><title>
5582 #: ../en/ch04-concepts.xml:30
5583 msgid "Tracking the history of a single file"
5584 msgstr "跟踪单一文件的历史"
5586 #. type: Content of: <book><chapter><sect1><sect2><para>
5587 #: ../en/ch04-concepts.xml:32
5588 msgid ""
5589 "When Mercurial tracks modifications to a file, it stores the history of that "
5590 "file in a metadata object called a <emphasis>filelog</emphasis>. Each entry "
5591 "in the filelog contains enough information to reconstruct one revision of the "
5592 "file that is being tracked. Filelogs are stored as files in the <filename "
5593 "role=\"special\" class=\"directory\">.hg/store/data</filename> directory. A "
5594 "filelog contains two kinds of information: revision data, and an index to "
5595 "help Mercurial to find a revision efficiently."
5596 msgstr ""
5598 #. type: Content of: <book><chapter><sect1><sect2><para>
5599 #: ../en/ch04-concepts.xml:43
5600 msgid ""
5601 "A file that is large, or has a lot of history, has its filelog stored in "
5602 "separate data (<quote><literal>.d</literal></quote> suffix) and index "
5603 "(<quote><literal>.i</literal></quote> suffix) files. For small files without "
5604 "much history, the revision data and index are combined in a single "
5605 "<quote><literal>.i</literal></quote> file. The correspondence between a file "
5606 "in the working directory and the filelog that tracks its history in the "
5607 "repository is illustrated in <xref linkend=\"fig:concepts:filelog\"/>."
5608 msgstr ""
5610 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
5611 #: ../en/ch04-concepts.xml:55
5612 msgid ""
5613 "Relationships between files in working directory and filelogs in repository"
5614 msgstr "工作目录中的文件与版本库中的文件日志之间的关系"
5616 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
5617 #: ../en/ch04-concepts.xml:58
5618 msgid "<imageobject><imagedata fileref=\"figs/filelog.png\"/></imageobject>"
5619 msgstr ""
5621 #. type: Content of: <book><chapter><sect1><sect2><title>
5622 #: ../en/ch04-concepts.xml:65
5623 msgid "Managing tracked files"
5624 msgstr "管理跟踪的文件"
5626 #. type: Content of: <book><chapter><sect1><sect2><para>
5627 #: ../en/ch04-concepts.xml:67
5628 msgid ""
5629 "Mercurial uses a structure called a <emphasis>manifest</emphasis> to collect "
5630 "together information about the files that it tracks. Each entry in the "
5631 "manifest contains information about the files present in a single changeset. "
5632 "An entry records which files are present in the changeset, the revision of "
5633 "each file, and a few other pieces of file metadata."
5634 msgstr ""
5636 #. type: Content of: <book><chapter><sect1><sect2><title>
5637 #: ../en/ch04-concepts.xml:77
5638 msgid "Recording changeset information"
5639 msgstr "记录修改集信息"
5641 #. type: Content of: <book><chapter><sect1><sect2><para>
5642 #: ../en/ch04-concepts.xml:79
5643 msgid ""
5644 "The <emphasis>changelog</emphasis> contains information about each "
5645 "changeset. Each revision records who committed a change, the changeset "
5646 "comment, other pieces of changeset-related information, and the revision of "
5647 "the manifest to use."
5648 msgstr ""
5650 #. type: Content of: <book><chapter><sect1><sect2><title>
5651 #: ../en/ch04-concepts.xml:87
5652 msgid "Relationships between revisions"
5653 msgstr "版本之间的关系"
5655 #. type: Content of: <book><chapter><sect1><sect2><para>
5656 #: ../en/ch04-concepts.xml:89
5657 msgid ""
5658 "Within a changelog, a manifest, or a filelog, each revision stores a pointer "
5659 "to its immediate parent (or to its two parents, if it's a merge revision). "
5660 "As I mentioned above, there are also relationships between revisions "
5661 "<emphasis>across</emphasis> these structures, and they are hierarchical in "
5662 "nature."
5663 msgstr ""
5665 #. type: Content of: <book><chapter><sect1><sect2><para>
5666 #: ../en/ch04-concepts.xml:96
5667 msgid ""
5668 "For every changeset in a repository, there is exactly one revision stored in "
5669 "the changelog. Each revision of the changelog contains a pointer to a single "
5670 "revision of the manifest. A revision of the manifest stores a pointer to a "
5671 "single revision of each filelog tracked when that changeset was created. "
5672 "These relationships are illustrated in <xref linkend=\"fig:concepts:metadata"
5673 "\"/>."
5674 msgstr ""
5676 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
5677 #: ../en/ch04-concepts.xml:105
5678 msgid "Metadata relationships"
5679 msgstr "元数据之间的关系"
5681 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
5682 #: ../en/ch04-concepts.xml:107
5683 msgid "<imageobject><imagedata fileref=\"figs/metadata.png\"/></imageobject>"
5684 msgstr ""
5686 #. type: Content of: <book><chapter><sect1><sect2><para>
5687 #: ../en/ch04-concepts.xml:112
5688 msgid ""
5689 "As the illustration shows, there is <emphasis>not</emphasis> a <quote>one to "
5690 "one</quote> relationship between revisions in the changelog, manifest, or "
5691 "filelog. If a file that Mercurial tracks hasn't changed between two "
5692 "changesets, the entry for that file in the two revisions of the manifest will "
5693 "point to the same revision of its filelog<placeholder type=\"footnote\" id=\"0"
5694 "\"/>."
5695 msgstr ""
5697 #. type: Content of: <book><chapter><sect1><sect2><para><footnote><para>
5698 #: ../en/ch04-concepts.xml:119
5699 msgid ""
5700 "It is possible (though unusual) for the manifest to remain the same between "
5701 "two changesets, in which case the changelog entries for those changesets will "
5702 "point to the same revision of the manifest."
5703 msgstr ""
5705 #. type: Content of: <book><chapter><sect1><title>
5706 #: ../en/ch04-concepts.xml:128
5707 msgid "Safe, efficient storage"
5708 msgstr "安全,高效的存储"
5710 #. type: Content of: <book><chapter><sect1><para>
5711 #: ../en/ch04-concepts.xml:130
5712 msgid ""
5713 "The underpinnings of changelogs, manifests, and filelogs are provided by a "
5714 "single structure called the <emphasis>revlog</emphasis>."
5715 msgstr ""
5717 #. type: Content of: <book><chapter><sect1><sect2><title>
5718 #: ../en/ch04-concepts.xml:135
5719 msgid "Efficient storage"
5720 msgstr "高效存储"
5722 #. type: Content of: <book><chapter><sect1><sect2><para>
5723 #: ../en/ch04-concepts.xml:137
5724 msgid ""
5725 "The revlog provides efficient storage of revisions using a <emphasis>delta</"
5726 "emphasis> mechanism. Instead of storing a complete copy of a file for each "
5727 "revision, it stores the changes needed to transform an older revision into "
5728 "the new revision. For many kinds of file data, these deltas are typically a "
5729 "fraction of a percent of the size of a full copy of a file."
5730 msgstr ""
5732 #. type: Content of: <book><chapter><sect1><sect2><para>
5733 #: ../en/ch04-concepts.xml:145
5734 msgid ""
5735 "Some obsolete revision control systems can only work with deltas of text "
5736 "files. They must either store binary files as complete snapshots or encoded "
5737 "into a text representation, both of which are wasteful approaches. Mercurial "
5738 "can efficiently handle deltas of files with arbitrary binary contents; it "
5739 "doesn't need to treat text as special."
5740 msgstr ""
5742 #. type: Content of: <book><chapter><sect1><sect2><title>
5743 #: ../en/ch04-concepts.xml:154
5744 msgid "Safe operation"
5745 msgstr "安全操作"
5747 #. type: Content of: <book><chapter><sect1><sect2><para>
5748 #: ../en/ch04-concepts.xml:156
5749 msgid ""
5750 "Mercurial only ever <emphasis>appends</emphasis> data to the end of a revlog "
5751 "file. It never modifies a section of a file after it has written it. This is "
5752 "both more robust and efficient than schemes that need to modify or rewrite "
5753 "data."
5754 msgstr ""
5756 #. type: Content of: <book><chapter><sect1><sect2><para>
5757 #: ../en/ch04-concepts.xml:162
5758 msgid ""
5759 "In addition, Mercurial treats every write as part of a <emphasis>transaction</"
5760 "emphasis> that can span a number of files. A transaction is "
5761 "<emphasis>atomic</emphasis>: either the entire transaction succeeds and its "
5762 "effects are all visible to readers in one go, or the whole thing is undone. "
5763 "This guarantee of atomicity means that if you're running two copies of "
5764 "Mercurial, where one is reading data and one is writing it, the reader will "
5765 "never see a partially written result that might confuse it."
5766 msgstr ""
5768 #. type: Content of: <book><chapter><sect1><sect2><para>
5769 #: ../en/ch04-concepts.xml:172
5770 msgid ""
5771 "The fact that Mercurial only appends to files makes it easier to provide this "
5772 "transactional guarantee. The easier it is to do stuff like this, the more "
5773 "confident you should be that it's done correctly."
5774 msgstr ""
5776 #. type: Content of: <book><chapter><sect1><sect2><title>
5777 #: ../en/ch04-concepts.xml:179
5778 msgid "Fast retrieval"
5779 msgstr "快速检索"
5781 #. type: Content of: <book><chapter><sect1><sect2><para>
5782 #: ../en/ch04-concepts.xml:181
5783 msgid ""
5784 "Mercurial cleverly avoids a pitfall common to all earlier revision control "
5785 "systems: the problem of <emphasis>inefficient retrieval</emphasis>. Most "
5786 "revision control systems store the contents of a revision as an incremental "
5787 "series of modifications against a <quote>snapshot</quote>. (Some base the "
5788 "snapshot on the oldest revision, others on the newest.) To reconstruct a "
5789 "specific revision, you must first read the snapshot, and then every one of "
5790 "the revisions between the snapshot and your target revision. The more "
5791 "history that a file accumulates, the more revisions you must read, hence the "
5792 "longer it takes to reconstruct a particular revision."
5793 msgstr ""
5795 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
5796 #: ../en/ch04-concepts.xml:195
5797 msgid "Snapshot of a revlog, with incremental deltas"
5798 msgstr "版本日志的快照,以及增量差异"
5800 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
5801 #: ../en/ch04-concepts.xml:197
5802 msgid "<imageobject><imagedata fileref=\"figs/snapshot.png\"/></imageobject>"
5803 msgstr ""
5805 #. type: Content of: <book><chapter><sect1><sect2><para>
5806 #: ../en/ch04-concepts.xml:202
5807 msgid ""
5808 "The innovation that Mercurial applies to this problem is simple but "
5809 "effective. Once the cumulative amount of delta information stored since the "
5810 "last snapshot exceeds a fixed threshold, it stores a new snapshot "
5811 "(compressed, of course), instead of another delta. This makes it possible to "
5812 "reconstruct <emphasis>any</emphasis> revision of a file quickly. This "
5813 "approach works so well that it has since been copied by several other "
5814 "revision control systems."
5815 msgstr ""
5817 #. type: Content of: <book><chapter><sect1><sect2><para>
5818 #: ../en/ch04-concepts.xml:211
5819 msgid ""
5820 "<xref linkend=\"fig:concepts:snapshot\"/> illustrates the idea. In an entry "
5821 "in a revlog's index file, Mercurial stores the range of entries from the data "
5822 "file that it must read to reconstruct a particular revision."
5823 msgstr ""
5825 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
5826 #: ../en/ch04-concepts.xml:217
5827 msgid "Aside: the influence of video compression"
5828 msgstr "旁白: 视频压缩的影响"
5830 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
5831 #: ../en/ch04-concepts.xml:219
5832 msgid ""
5833 "If you're familiar with video compression or have ever watched a TV feed "
5834 "through a digital cable or satellite service, you may know that most video "
5835 "compression schemes store each frame of video as a delta against its "
5836 "predecessor frame."
5837 msgstr ""
5839 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
5840 #: ../en/ch04-concepts.xml:225
5841 msgid ""
5842 "Mercurial borrows this idea to make it possible to reconstruct a revision "
5843 "from a snapshot and a small number of deltas."
5844 msgstr ""
5846 #. type: Content of: <book><chapter><sect1><sect2><title>
5847 #: ../en/ch04-concepts.xml:232
5848 msgid "Identification and strong integrity"
5849 msgstr "鉴别和强完整性"
5851 #. type: Content of: <book><chapter><sect1><sect2><para>
5852 #: ../en/ch04-concepts.xml:234
5853 msgid ""
5854 "Along with delta or snapshot information, a revlog entry contains a "
5855 "cryptographic hash of the data that it represents. This makes it difficult "
5856 "to forge the contents of a revision, and easy to detect accidental corruption."
5857 msgstr ""
5859 #. type: Content of: <book><chapter><sect1><sect2><para>
5860 #: ../en/ch04-concepts.xml:239
5861 msgid ""
5862 "Hashes provide more than a mere check against corruption; they are used as "
5863 "the identifiers for revisions. The changeset identification hashes that you "
5864 "see as an end user are from revisions of the changelog. Although filelogs "
5865 "and the manifest also use hashes, Mercurial only uses these behind the scenes."
5866 msgstr ""
5868 #. type: Content of: <book><chapter><sect1><sect2><para>
5869 #: ../en/ch04-concepts.xml:246
5870 msgid ""
5871 "Mercurial verifies that hashes are correct when it retrieves file revisions "
5872 "and when it pulls changes from another repository. If it encounters an "
5873 "integrity problem, it will complain and stop whatever it's doing."
5874 msgstr ""
5876 #. type: Content of: <book><chapter><sect1><sect2><para>
5877 #: ../en/ch04-concepts.xml:251
5878 msgid ""
5879 "In addition to the effect it has on retrieval efficiency, Mercurial's use of "
5880 "periodic snapshots makes it more robust against partial data corruption. If "
5881 "a revlog becomes partly corrupted due to a hardware error or system bug, it's "
5882 "often possible to reconstruct some or most revisions from the uncorrupted "
5883 "sections of the revlog, both before and after the corrupted section. This "
5884 "would not be possible with a delta-only storage model."
5885 msgstr ""
5887 #. type: Content of: <book><chapter><sect1><title>
5888 #: ../en/ch04-concepts.xml:263
5889 msgid "Revision history, branching, and merging"
5890 msgstr "修订历史,分支与合并"
5892 #. type: Content of: <book><chapter><sect1><para>
5893 #: ../en/ch04-concepts.xml:265
5894 msgid ""
5895 "Every entry in a Mercurial revlog knows the identity of its immediate "
5896 "ancestor revision, usually referred to as its <emphasis>parent</emphasis>. "
5897 "In fact, a revision contains room for not one parent, but two. Mercurial "
5898 "uses a special hash, called the <quote>null ID</quote>, to represent the idea "
5899 "<quote>there is no parent here</quote>. This hash is simply a string of "
5900 "zeroes."
5901 msgstr ""
5903 #. type: Content of: <book><chapter><sect1><para>
5904 #: ../en/ch04-concepts.xml:273
5905 msgid ""
5906 "In <xref linkend=\"fig:concepts:revlog\"/>, you can see an example of the "
5907 "conceptual structure of a revlog. Filelogs, manifests, and changelogs all "
5908 "have this same structure; they differ only in the kind of data stored in each "
5909 "delta or snapshot."
5910 msgstr ""
5912 #. type: Content of: <book><chapter><sect1><para>
5913 #: ../en/ch04-concepts.xml:279
5914 msgid ""
5915 "The first revision in a revlog (at the bottom of the image) has the null ID "
5916 "in both of its parent slots. For a <quote>normal</quote> revision, its first "
5917 "parent slot contains the ID of its parent revision, and its second contains "
5918 "the null ID, indicating that the revision has only one real parent. Any two "
5919 "revisions that have the same parent ID are branches. A revision that "
5920 "represents a merge between branches has two normal revision IDs in its parent "
5921 "slots."
5922 msgstr ""
5924 #. type: Content of: <book><chapter><sect1><figure><title>
5925 #: ../en/ch04-concepts.xml:289
5926 msgid "The conceptual structure of a revlog"
5927 msgstr "版本日志的设计结构"
5929 #. type: Content of: <book><chapter><sect1><figure><mediaobject>
5930 #: ../en/ch04-concepts.xml:291
5931 msgid "<imageobject><imagedata fileref=\"figs/revlog.png\"/></imageobject>"
5932 msgstr ""
5934 #. type: Content of: <book><chapter><sect1><title>
5935 #: ../en/ch04-concepts.xml:298
5936 msgid "The working directory"
5937 msgstr "工作目录"
5939 #. type: Content of: <book><chapter><sect1><para>
5940 #: ../en/ch04-concepts.xml:300
5941 msgid ""
5942 "In the working directory, Mercurial stores a snapshot of the files from the "
5943 "repository as of a particular changeset."
5944 msgstr ""
5946 #. type: Content of: <book><chapter><sect1><para>
5947 #: ../en/ch04-concepts.xml:303
5948 msgid ""
5949 "The working directory <quote>knows</quote> which changeset it contains. When "
5950 "you update the working directory to contain a particular changeset, Mercurial "
5951 "looks up the appropriate revision of the manifest to find out which files it "
5952 "was tracking at the time that changeset was committed, and which revision of "
5953 "each file was then current. It then recreates a copy of each of those files, "
5954 "with the same contents it had when the changeset was committed."
5955 msgstr ""
5957 #. type: Content of: <book><chapter><sect1><para>
5958 #: ../en/ch04-concepts.xml:312
5959 msgid ""
5960 "The <emphasis>dirstate</emphasis> is a special structure that contains "
5961 "Mercurial's knowledge of the working directory. It is maintained as a file "
5962 "named <filename>.hg/dirstate</filename> inside a repository. The dirstate "
5963 "details which changeset the working directory is updated to, and all of the "
5964 "files that Mercurial is tracking in the working directory. It also lets "
5965 "Mercurial quickly notice changed files, by recording their checkout times and "
5966 "sizes."
5967 msgstr ""
5969 #. type: Content of: <book><chapter><sect1><para>
5970 #: ../en/ch04-concepts.xml:322
5971 msgid ""
5972 "Just as a revision of a revlog has room for two parents, so that it can "
5973 "represent either a normal revision (with one parent) or a merge of two "
5974 "earlier revisions, the dirstate has slots for two parents. When you use the "
5975 "<command role=\"hg-cmd\">hg update</command> command, the changeset that you "
5976 "update to is stored in the <quote>first parent</quote> slot, and the null ID "
5977 "in the second. When you <command role=\"hg-cmd\">hg merge</command> with "
5978 "another changeset, the first parent remains unchanged, and the second parent "
5979 "is filled in with the changeset you're merging with. The <command role=\"hg-"
5980 "cmd\">hg parents</command> command tells you what the parents of the dirstate "
5981 "are."
5982 msgstr ""
5984 #. type: Content of: <book><chapter><sect1><sect2><title>
5985 #: ../en/ch04-concepts.xml:336
5986 msgid "What happens when you commit"
5987 msgstr "当你提交时发生的事情"
5989 #. type: Content of: <book><chapter><sect1><sect2><para>
5990 #: ../en/ch04-concepts.xml:338
5991 msgid ""
5992 "The dirstate stores parent information for more than just book-keeping "
5993 "purposes. Mercurial uses the parents of the dirstate as <emphasis>the "
5994 "parents of a new changeset</emphasis> when you perform a commit."
5995 msgstr ""
5997 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
5998 #: ../en/ch04-concepts.xml:344
5999 msgid "The working directory can have two parents"
6000 msgstr "工作目录可以有两个父亲"
6002 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
6003 #: ../en/ch04-concepts.xml:346
6004 msgid "<imageobject><imagedata fileref=\"figs/wdir.png\"/></imageobject>"
6005 msgstr ""
6007 #. type: Content of: <book><chapter><sect1><sect2><para>
6008 #: ../en/ch04-concepts.xml:351
6009 msgid ""
6010 "<xref linkend=\"fig:concepts:wdir\"/> shows the normal state of the working "
6011 "directory, where it has a single changeset as parent. That changeset is the "
6012 "<emphasis>tip</emphasis>, the newest changeset in the repository that has no "
6013 "children."
6014 msgstr ""
6016 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
6017 #: ../en/ch04-concepts.xml:358
6018 msgid "The working directory gains new parents after a commit"
6019 msgstr "提交之后,工作目录的父亲就改变了"
6021 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
6022 #: ../en/ch04-concepts.xml:361
6023 msgid ""
6024 "<imageobject><imagedata fileref=\"figs/wdir-after-commit.png\"/></imageobject>"
6025 msgstr ""
6027 #. type: Content of: <book><chapter><sect1><sect2><para>
6028 #: ../en/ch04-concepts.xml:366
6029 msgid ""
6030 "It's useful to think of the working directory as <quote>the changeset I'm "
6031 "about to commit</quote>. Any files that you tell Mercurial that you've "
6032 "added, removed, renamed, or copied will be reflected in that changeset, as "
6033 "will modifications to any files that Mercurial is already tracking; the new "
6034 "changeset will have the parents of the working directory as its parents."
6035 msgstr ""
6037 #. type: Content of: <book><chapter><sect1><sect2><para>
6038 #: ../en/ch04-concepts.xml:374
6039 msgid ""
6040 "After a commit, Mercurial will update the parents of the working directory, "
6041 "so that the first parent is the ID of the new changeset, and the second is "
6042 "the null ID. This is shown in <xref linkend=\"fig:concepts:wdir-after-commit"
6043 "\"/>. Mercurial doesn't touch any of the files in the working directory when "
6044 "you commit; it just modifies the dirstate to note its new parents."
6045 msgstr ""
6047 #. type: Content of: <book><chapter><sect1><sect2><title>
6048 #: ../en/ch04-concepts.xml:385
6049 msgid "Creating a new head"
6050 msgstr "创建新顶点"
6052 #. type: Content of: <book><chapter><sect1><sect2><para>
6053 #: ../en/ch04-concepts.xml:387
6054 msgid ""
6055 "It's perfectly normal to update the working directory to a changeset other "
6056 "than the current tip. For example, you might want to know what your project "
6057 "looked like last Tuesday, or you could be looking through changesets to see "
6058 "which one introduced a bug. In cases like this, the natural thing to do is "
6059 "update the working directory to the changeset you're interested in, and then "
6060 "examine the files in the working directory directly to see their contents as "
6061 "they were when you committed that changeset. The effect of this is shown in "
6062 "<xref linkend=\"fig:concepts:wdir-pre-branch\"/>."
6063 msgstr ""
6065 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
6066 #: ../en/ch04-concepts.xml:399
6067 msgid "The working directory, updated to an older changeset"
6068 msgstr "同步到旧修改集的工作目录"
6070 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
6071 #: ../en/ch04-concepts.xml:402
6072 msgid ""
6073 "<imageobject><imagedata fileref=\"figs/wdir-pre-branch.png\"/></imageobject>"
6074 msgstr ""
6076 #. type: Content of: <book><chapter><sect1><sect2><para>
6077 #: ../en/ch04-concepts.xml:407
6078 msgid ""
6079 "Having updated the working directory to an older changeset, what happens if "
6080 "you make some changes, and then commit? Mercurial behaves in the same way as "
6081 "I outlined above. The parents of the working directory become the parents of "
6082 "the new changeset. This new changeset has no children, so it becomes the new "
6083 "tip. And the repository now contains two changesets that have no children; "
6084 "we call these <emphasis>heads</emphasis>. You can see the structure that "
6085 "this creates in <xref linkend=\"fig:concepts:wdir-branch\"/>."
6086 msgstr ""
6088 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
6089 #: ../en/ch04-concepts.xml:419
6090 msgid "After a commit made while synced to an older changeset"
6091 msgstr "对同步到旧修改集的工作目录提交之后"
6093 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
6094 #: ../en/ch04-concepts.xml:422
6095 msgid "<imageobject><imagedata fileref=\"figs/wdir-branch.png\"/></imageobject>"
6096 msgstr ""
6098 #. type: Content of: <book><chapter><sect1><sect2><note><para>
6099 #: ../en/ch04-concepts.xml:428
6100 msgid ""
6101 "If you're new to Mercurial, you should keep in mind a common <quote>error</"
6102 "quote>, which is to use the <command role=\"hg-cmd\">hg pull</command> "
6103 "command without any options. By default, the <command role=\"hg-cmd\">hg "
6104 "pull</command> command <emphasis>does not</emphasis> update the working "
6105 "directory, so you'll bring new changesets into your repository, but the "
6106 "working directory will stay synced at the same changeset as before the pull. "
6107 "If you make some changes and commit afterwards, you'll thus create a new "
6108 "head, because your working directory isn't synced to whatever the current tip "
6109 "is. To combine the operation of a pull, followed by an update, run "
6110 "<command>hg pull -u</command>."
6111 msgstr ""
6113 #. type: Content of: <book><chapter><sect1><sect2><note><para>
6114 #: ../en/ch04-concepts.xml:442
6115 msgid ""
6116 "I put the word <quote>error</quote> in quotes because all that you need to do "
6117 "to rectify the situation where you created a new head by accident is <command "
6118 "role=\"hg-cmd\">hg merge</command>, then <command role=\"hg-cmd\">hg commit</"
6119 "command>. In other words, this almost never has negative consequences; it's "
6120 "just something of a surprise for newcomers. I'll discuss other ways to avoid "
6121 "this behavior, and why Mercurial behaves in this initially surprising way, "
6122 "later on."
6123 msgstr ""
6125 #. type: Content of: <book><chapter><sect1><sect2><title>
6126 #: ../en/ch04-concepts.xml:455
6127 msgid "Merging changes"
6128 msgstr "合并修改"
6130 #. type: Content of: <book><chapter><sect1><sect2><para>
6131 #: ../en/ch04-concepts.xml:457
6132 msgid ""
6133 "When you run the <command role=\"hg-cmd\">hg merge</command> command, "
6134 "Mercurial leaves the first parent of the working directory unchanged, and "
6135 "sets the second parent to the changeset you're merging with, as shown in "
6136 "<xref linkend=\"fig:concepts:wdir-merge\"/>."
6137 msgstr ""
6139 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
6140 #: ../en/ch04-concepts.xml:464
6141 msgid "Merging two heads"
6142 msgstr "合并两个顶点"
6144 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
6145 #: ../en/ch04-concepts.xml:466
6146 msgid ""
6147 "<imageobject> <imagedata fileref=\"figs/wdir-merge.png\"/> </imageobject>"
6148 msgstr ""
6150 #. type: Content of: <book><chapter><sect1><sect2><para>
6151 #: ../en/ch04-concepts.xml:473
6152 msgid ""
6153 "Mercurial also has to modify the working directory, to merge the files "
6154 "managed in the two changesets. Simplified a little, the merging process goes "
6155 "like this, for every file in the manifests of both changesets."
6156 msgstr ""
6158 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6159 #: ../en/ch04-concepts.xml:478
6160 msgid "If neither changeset has modified a file, do nothing with that file."
6161 msgstr ""
6163 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6164 #: ../en/ch04-concepts.xml:481
6165 msgid ""
6166 "If one changeset has modified a file, and the other hasn't, create the "
6167 "modified copy of the file in the working directory."
6168 msgstr ""
6170 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6171 #: ../en/ch04-concepts.xml:485
6172 msgid ""
6173 "If one changeset has removed a file, and the other hasn't (or has also "
6174 "deleted it), delete the file from the working directory."
6175 msgstr ""
6177 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6178 #: ../en/ch04-concepts.xml:489
6179 msgid ""
6180 "If one changeset has removed a file, but the other has modified the file, ask "
6181 "the user what to do: keep the modified file, or remove it?"
6182 msgstr ""
6184 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6185 #: ../en/ch04-concepts.xml:493
6186 msgid ""
6187 "If both changesets have modified a file, invoke an external merge program to "
6188 "choose the new contents for the merged file. This may require input from the "
6189 "user."
6190 msgstr ""
6192 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6193 #: ../en/ch04-concepts.xml:498
6194 msgid ""
6195 "If one changeset has modified a file, and the other has renamed or copied the "
6196 "file, make sure that the changes follow the new name of the file."
6197 msgstr ""
6199 #. type: Content of: <book><chapter><sect1><sect2><para>
6200 #: ../en/ch04-concepts.xml:502
6201 msgid ""
6202 "There are more details&emdash;merging has plenty of corner cases&emdash;but "
6203 "these are the most common choices that are involved in a merge. As you can "
6204 "see, most cases are completely automatic, and indeed most merges finish "
6205 "automatically, without requiring your input to resolve any conflicts."
6206 msgstr ""
6208 #. type: Content of: <book><chapter><sect1><sect2><para>
6209 #: ../en/ch04-concepts.xml:509
6210 msgid ""
6211 "When you're thinking about what happens when you commit after a merge, once "
6212 "again the working directory is <quote>the changeset I'm about to commit</"
6213 "quote>. After the <command role=\"hg-cmd\">hg merge</command> command "
6214 "completes, the working directory has two parents; these will become the "
6215 "parents of the new changeset."
6216 msgstr ""
6218 #. type: Content of: <book><chapter><sect1><sect2><para>
6219 #: ../en/ch04-concepts.xml:516
6220 msgid ""
6221 "Mercurial lets you perform multiple merges, but you must commit the results "
6222 "of each individual merge as you go. This is necessary because Mercurial only "
6223 "tracks two parents for both revisions and the working directory. While it "
6224 "would be technically feasible to merge multiple changesets at once, Mercurial "
6225 "avoids this for simplicity. With multi-way merges, the risks of user "
6226 "confusion, nasty conflict resolution, and making a terrible mess of a merge "
6227 "would grow intolerable."
6228 msgstr ""
6230 #. type: Content of: <book><chapter><sect1><sect2><title>
6231 #: ../en/ch04-concepts.xml:529
6232 msgid "Merging and renames"
6233 msgstr "合并与改名"
6235 #. type: Content of: <book><chapter><sect1><sect2><para>
6236 #: ../en/ch04-concepts.xml:531
6237 msgid ""
6238 "A surprising number of revision control systems pay little or no attention to "
6239 "a file's <emphasis>name</emphasis> over time. For instance, it used to be "
6240 "common that if a file got renamed on one side of a merge, the changes from "
6241 "the other side would be silently dropped."
6242 msgstr ""
6244 #. type: Content of: <book><chapter><sect1><sect2><para>
6245 #: ../en/ch04-concepts.xml:537
6246 msgid ""
6247 "Mercurial records metadata when you tell it to perform a rename or copy. It "
6248 "uses this metadata during a merge to do the right thing in the case of a "
6249 "merge. For instance, if I rename a file, and you edit it without renaming "
6250 "it, when we merge our work the file will be renamed and have your edits "
6251 "applied."
6252 msgstr ""
6254 #. type: Content of: <book><chapter><sect1><title>
6255 #: ../en/ch04-concepts.xml:547
6256 msgid "Other interesting design features"
6257 msgstr "其它有趣的设计特性"
6259 #. type: Content of: <book><chapter><sect1><para>
6260 #: ../en/ch04-concepts.xml:549
6261 msgid ""
6262 "In the sections above, I've tried to highlight some of the most important "
6263 "aspects of Mercurial's design, to illustrate that it pays careful attention "
6264 "to reliability and performance. However, the attention to detail doesn't "
6265 "stop there. There are a number of other aspects of Mercurial's construction "
6266 "that I personally find interesting. I'll detail a few of them here, separate "
6267 "from the <quote>big ticket</quote> items above, so that if you're interested, "
6268 "you can gain a better idea of the amount of thinking that goes into a well-"
6269 "designed system."
6270 msgstr ""
6272 #. type: Content of: <book><chapter><sect1><sect2><title>
6273 #: ../en/ch04-concepts.xml:560
6274 msgid "Clever compression"
6275 msgstr "智能压缩"
6277 #. type: Content of: <book><chapter><sect1><sect2><para>
6278 #: ../en/ch04-concepts.xml:562
6279 msgid ""
6280 "When appropriate, Mercurial will store both snapshots and deltas in "
6281 "compressed form. It does this by always <emphasis>trying to</emphasis> "
6282 "compress a snapshot or delta, but only storing the compressed version if it's "
6283 "smaller than the uncompressed version."
6284 msgstr ""
6286 #. type: Content of: <book><chapter><sect1><sect2><para>
6287 #: ../en/ch04-concepts.xml:568
6288 msgid ""
6289 "This means that Mercurial does <quote>the right thing</quote> when storing a "
6290 "file whose native form is compressed, such as a <literal>zip</literal> "
6291 "archive or a JPEG image. When these types of files are compressed a second "
6292 "time, the resulting file is usually bigger than the once-compressed form, and "
6293 "so Mercurial will store the plain <literal>zip</literal> or JPEG."
6294 msgstr ""
6296 #. type: Content of: <book><chapter><sect1><sect2><para>
6297 #: ../en/ch04-concepts.xml:576
6298 msgid ""
6299 "Deltas between revisions of a compressed file are usually larger than "
6300 "snapshots of the file, and Mercurial again does <quote>the right thing</"
6301 "quote> in these cases. It finds that such a delta exceeds the threshold at "
6302 "which it should store a complete snapshot of the file, so it stores the "
6303 "snapshot, again saving space compared to a naive delta-only approach."
6304 msgstr ""
6306 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
6307 #: ../en/ch04-concepts.xml:585
6308 msgid "Network recompression"
6309 msgstr "网络重新压缩"
6311 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
6312 #: ../en/ch04-concepts.xml:587
6313 msgid ""
6314 "When storing revisions on disk, Mercurial uses the <quote>deflate</quote> "
6315 "compression algorithm (the same one used by the popular <literal>zip</"
6316 "literal> archive format), which balances good speed with a respectable "
6317 "compression ratio. However, when transmitting revision data over a network "
6318 "connection, Mercurial uncompresses the compressed revision data."
6319 msgstr ""
6321 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
6322 #: ../en/ch04-concepts.xml:595
6323 msgid ""
6324 "If the connection is over HTTP, Mercurial recompresses the entire stream of "
6325 "data using a compression algorithm that gives a better compression ratio (the "
6326 "Burrows-Wheeler algorithm from the widely used <literal>bzip2</literal> "
6327 "compression package). This combination of algorithm and compression of the "
6328 "entire stream (instead of a revision at a time) substantially reduces the "
6329 "number of bytes to be transferred, yielding better network performance over "
6330 "most kinds of network."
6331 msgstr ""
6333 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
6334 #: ../en/ch04-concepts.xml:605
6335 msgid ""
6336 "If the connection is over <command>ssh</command>, Mercurial "
6337 "<emphasis>doesn't</emphasis> recompress the stream, because <command>ssh</"
6338 "command> can already do this itself. You can tell Mercurial to always use "
6339 "<command>ssh</command>'s compression feature by editing the <filename>.hgrc</"
6340 "filename> file in your home directory as follows."
6341 msgstr ""
6343 #. type: Content of: <book><chapter><sect1><sect2><title>
6344 #: ../en/ch04-concepts.xml:620
6345 msgid "Read/write ordering and atomicity"
6346 msgstr "读写顺序与原子性"
6348 #. type: Content of: <book><chapter><sect1><sect2><para>
6349 #: ../en/ch04-concepts.xml:622
6350 msgid ""
6351 "Appending to files isn't the whole story when it comes to guaranteeing that a "
6352 "reader won't see a partial write. If you recall <xref linkend=\"fig:concepts:"
6353 "metadata\"/>, revisions in the changelog point to revisions in the manifest, "
6354 "and revisions in the manifest point to revisions in filelogs. This hierarchy "
6355 "is deliberate."
6356 msgstr ""
6358 #. type: Content of: <book><chapter><sect1><sect2><para>
6359 #: ../en/ch04-concepts.xml:629
6360 msgid ""
6361 "A writer starts a transaction by writing filelog and manifest data, and "
6362 "doesn't write any changelog data until those are finished. A reader starts "
6363 "by reading changelog data, then manifest data, followed by filelog data."
6364 msgstr ""
6366 #. type: Content of: <book><chapter><sect1><sect2><para>
6367 #: ../en/ch04-concepts.xml:634
6368 msgid ""
6369 "Since the writer has always finished writing filelog and manifest data before "
6370 "it writes to the changelog, a reader will never read a pointer to a partially "
6371 "written manifest revision from the changelog, and it will never read a "
6372 "pointer to a partially written filelog revision from the manifest."
6373 msgstr ""
6375 #. type: Content of: <book><chapter><sect1><sect2><title>
6376 #: ../en/ch04-concepts.xml:642
6377 msgid "Concurrent access"
6378 msgstr "并发访问"
6380 #. type: Content of: <book><chapter><sect1><sect2><para>
6381 #: ../en/ch04-concepts.xml:644
6382 msgid ""
6383 "The read/write ordering and atomicity guarantees mean that Mercurial never "
6384 "needs to <emphasis>lock</emphasis> a repository when it's reading data, even "
6385 "if the repository is being written to while the read is occurring. This has a "
6386 "big effect on scalability; you can have an arbitrary number of Mercurial "
6387 "processes safely reading data from a repository all at once, no matter "
6388 "whether it's being written to or not."
6389 msgstr ""
6391 #. type: Content of: <book><chapter><sect1><sect2><para>
6392 #: ../en/ch04-concepts.xml:653
6393 msgid ""
6394 "The lockless nature of reading means that if you're sharing a repository on a "
6395 "multi-user system, you don't need to grant other local users permission to "
6396 "<emphasis>write</emphasis> to your repository in order for them to be able to "
6397 "clone it or pull changes from it; they only need <emphasis>read</emphasis> "
6398 "permission. (This is <emphasis>not</emphasis> a common feature among "
6399 "revision control systems, so don't take it for granted! Most require readers "
6400 "to be able to lock a repository to access it safely, and this requires write "
6401 "permission on at least one directory, which of course makes for all kinds of "
6402 "nasty and annoying security and administrative problems.)"
6403 msgstr ""
6405 #. type: Content of: <book><chapter><sect1><sect2><para>
6406 #: ../en/ch04-concepts.xml:666
6407 msgid ""
6408 "Mercurial uses locks to ensure that only one process can write to a "
6409 "repository at a time (the locking mechanism is safe even over filesystems "
6410 "that are notoriously hostile to locking, such as NFS). If a repository is "
6411 "locked, a writer will wait for a while to retry if the repository becomes "
6412 "unlocked, but if the repository remains locked for too long, the process "
6413 "attempting to write will time out after a while. This means that your daily "
6414 "automated scripts won't get stuck forever and pile up if a system crashes "
6415 "unnoticed, for example. (Yes, the timeout is configurable, from zero to "
6416 "infinity.)"
6417 msgstr ""
6419 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
6420 #: ../en/ch04-concepts.xml:678
6421 msgid "Safe dirstate access"
6422 msgstr "安全的目录状态访问"
6424 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
6425 #: ../en/ch04-concepts.xml:680
6426 msgid ""
6427 "As with revision data, Mercurial doesn't take a lock to read the dirstate "
6428 "file; it does acquire a lock to write it. To avoid the possibility of "
6429 "reading a partially written copy of the dirstate file, Mercurial writes to a "
6430 "file with a unique name in the same directory as the dirstate file, then "
6431 "renames the temporary file atomically to <filename>dirstate</filename>. The "
6432 "file named <filename>dirstate</filename> is thus guaranteed to be complete, "
6433 "not partially written."
6434 msgstr ""
6436 #. type: Content of: <book><chapter><sect1><sect2><title>
6437 #: ../en/ch04-concepts.xml:693
6438 msgid "Avoiding seeks"
6439 msgstr "避免查找"
6441 #. type: Content of: <book><chapter><sect1><sect2><para>
6442 #: ../en/ch04-concepts.xml:695
6443 msgid ""
6444 "Critical to Mercurial's performance is the avoidance of seeks of the disk "
6445 "head, since any seek is far more expensive than even a comparatively large "
6446 "read operation."
6447 msgstr ""
6449 #. type: Content of: <book><chapter><sect1><sect2><para>
6450 #: ../en/ch04-concepts.xml:699
6451 msgid ""
6452 "This is why, for example, the dirstate is stored in a single file. If there "
6453 "were a dirstate file per directory that Mercurial tracked, the disk would "
6454 "seek once per directory. Instead, Mercurial reads the entire single dirstate "
6455 "file in one step."
6456 msgstr ""
6458 #. type: Content of: <book><chapter><sect1><sect2><para>
6459 #: ../en/ch04-concepts.xml:705
6460 msgid ""
6461 "Mercurial also uses a <quote>copy on write</quote> scheme when cloning a "
6462 "repository on local storage. Instead of copying every revlog file from the "
6463 "old repository into the new repository, it makes a <quote>hard link</quote>, "
6464 "which is a shorthand way to say <quote>these two names point to the same "
6465 "file</quote>. When Mercurial is about to write to one of a revlog's files, "
6466 "it checks to see if the number of names pointing at the file is greater than "
6467 "one. If it is, more than one repository is using the file, so Mercurial "
6468 "makes a new copy of the file that is private to this repository."
6469 msgstr ""
6471 #. type: Content of: <book><chapter><sect1><sect2><para>
6472 #: ../en/ch04-concepts.xml:716
6473 msgid ""
6474 "A few revision control developers have pointed out that this idea of making a "
6475 "complete private copy of a file is not very efficient in its use of storage. "
6476 "While this is true, storage is cheap, and this method gives the highest "
6477 "performance while deferring most book-keeping to the operating system. An "
6478 "alternative scheme would most likely reduce performance and increase the "
6479 "complexity of the software, but speed and simplicity are key to the "
6480 "<quote>feel</quote> of day-to-day use."
6481 msgstr ""
6483 #. type: Content of: <book><chapter><sect1><sect2><title>
6484 #: ../en/ch04-concepts.xml:728
6485 msgid "Other contents of the dirstate"
6486 msgstr "目录状态的其它内容"
6488 #. type: Content of: <book><chapter><sect1><sect2><para>
6489 #: ../en/ch04-concepts.xml:730
6490 msgid ""
6491 "Because Mercurial doesn't force you to tell it when you're modifying a file, "
6492 "it uses the dirstate to store some extra information so it can determine "
6493 "efficiently whether you have modified a file. For each file in the working "
6494 "directory, it stores the time that it last modified the file itself, and the "
6495 "size of the file at that time."
6496 msgstr ""
6498 #. type: Content of: <book><chapter><sect1><sect2><para>
6499 #: ../en/ch04-concepts.xml:737
6500 msgid ""
6501 "When you explicitly <command role=\"hg-cmd\">hg add</command>, <command role="
6502 "\"hg-cmd\">hg remove</command>, <command role=\"hg-cmd\">hg rename</command> "
6503 "or <command role=\"hg-cmd\">hg copy</command> files, Mercurial updates the "
6504 "dirstate so that it knows what to do with those files when you commit."
6505 msgstr ""
6507 #. type: Content of: <book><chapter><sect1><sect2><para>
6508 #: ../en/ch04-concepts.xml:744
6509 msgid ""
6510 "The dirstate helps Mercurial to efficiently check the status of files in a "
6511 "repository."
6512 msgstr ""
6514 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6515 #: ../en/ch04-concepts.xml:749
6516 msgid ""
6517 "When Mercurial checks the state of a file in the working directory, it first "
6518 "checks a file's modification time against the time in the dirstate that "
6519 "records when Mercurial last wrote the file. If the last modified time is the "
6520 "same as the time when Mercurial wrote the file, the file must not have been "
6521 "modified, so Mercurial does not need to check any further."
6522 msgstr ""
6524 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6525 #: ../en/ch04-concepts.xml:758
6526 msgid ""
6527 "If the file's size has changed, the file must have been modified. If the "
6528 "modification time has changed, but the size has not, only then does Mercurial "
6529 "need to actually read the contents of the file to see if it has changed."
6530 msgstr ""
6532 #. type: Content of: <book><chapter><sect1><sect2><para>
6533 #: ../en/ch04-concepts.xml:766
6534 msgid ""
6535 "Storing the modification time and size dramatically reduces the number of "
6536 "read operations that Mercurial needs to perform when we run commands like "
6537 "<command>hg status</command>. This results in large performance improvements."
6538 msgstr ""
6540 #. type: Content of: <book><chapter><title>
6541 #: ../en/ch05-daily.xml:5
6542 msgid "Mercurial in daily use"
6543 msgstr "Mercurial 的日常使用"
6545 #. type: Content of: <book><chapter><sect1><title>
6546 #: ../en/ch05-daily.xml:8
6547 msgid "Telling Mercurial which files to track"
6548 msgstr "告诉 Mercurial 要跟踪哪些文件"
6550 #. type: Content of: <book><chapter><sect1><para>
6551 #: ../en/ch05-daily.xml:10
6552 msgid ""
6553 "Mercurial does not work with files in your repository unless you tell it to "
6554 "manage them. The <command role=\"hg-cmd\">hg status</command> command will "
6555 "tell you which files Mercurial doesn't know about; it uses a <quote><literal>?"
6556 "</literal></quote> to display such files."
6557 msgstr ""
6560 #. type: Content of: <book><chapter><sect1><para>
6561 #: ../en/ch05-daily.xml:17
6562 msgid ""
6563 "To tell Mercurial to track a file, use the <command role=\"hg-cmd\">hg add</"
6564 "command> command. Once you have added a file, the entry in the output of "
6565 "<command role=\"hg-cmd\">hg status</command> for that file changes from "
6566 "<quote><literal>?</literal></quote> to <quote><literal>A</literal></quote>."
6567 msgstr ""
6569 #. type: Content of: <book><chapter><sect1><para>
6570 #: ../en/ch05-daily.xml:26
6571 msgid ""
6572 "After you run a <command role=\"hg-cmd\">hg commit</command>, the files that "
6573 "you added before the commit will no longer be listed in the output of "
6574 "<command role=\"hg-cmd\">hg status</command>. The reason for this is that by "
6575 "default, <command role=\"hg-cmd\">hg status</command> only tells you about "
6576 "<quote>interesting</quote> files&emdash;those that you have (for example) "
6577 "modified, removed, or renamed. If you have a repository that contains "
6578 "thousands of files, you will rarely want to know about files that Mercurial "
6579 "is tracking, but that have not changed. (You can still get this information; "
6580 "we'll return to this later.)"
6581 msgstr ""
6583 #. type: Content of: <book><chapter><sect1><para>
6584 #: ../en/ch05-daily.xml:38
6585 msgid ""
6586 "Once you add a file, Mercurial doesn't do anything with it immediately. "
6587 "Instead, it will take a snapshot of the file's state the next time you "
6588 "perform a commit. It will then continue to track the changes you make to the "
6589 "file every time you commit, until you remove the file."
6590 msgstr ""
6592 #. type: Content of: <book><chapter><sect1><sect2><title>
6593 #: ../en/ch05-daily.xml:45
6594 msgid "Explicit versus implicit file naming"
6595 msgstr "明确与隐含文件命名"
6597 #. type: Content of: <book><chapter><sect1><sect2><para>
6598 #: ../en/ch05-daily.xml:47
6599 msgid ""
6600 "A useful behavior that Mercurial has is that if you pass the name of a "
6601 "directory to a command, every Mercurial command will treat this as <quote>I "
6602 "want to operate on every file in this directory and its subdirectories</"
6603 "quote>."
6604 msgstr ""
6606 #. type: Content of: <book><chapter><sect1><sect2><para>
6607 #: ../en/ch05-daily.xml:54
6608 msgid ""
6609 "Notice in this example that Mercurial printed the names of the files it "
6610 "added, whereas it didn't do so when we added the file named <filename>myfile."
6611 "txt</filename> in the earlier example."
6612 msgstr ""
6614 #. type: Content of: <book><chapter><sect1><sect2><para>
6615 #: ../en/ch05-daily.xml:59
6616 msgid ""
6617 "What's going on is that in the former case, we explicitly named the file to "
6618 "add on the command line. The assumption that Mercurial makes in such cases "
6619 "is that we know what we are doing, and it doesn't print any output."
6620 msgstr ""
6622 #. type: Content of: <book><chapter><sect1><sect2><para>
6623 #: ../en/ch05-daily.xml:64
6624 msgid ""
6625 "However, when we <emphasis>imply</emphasis> the names of files by giving the "
6626 "name of a directory, Mercurial takes the extra step of printing the name of "
6627 "each file that it does something with. This makes it more clear what is "
6628 "happening, and reduces the likelihood of a silent and nasty surprise. This "
6629 "behavior is common to most Mercurial commands."
6630 msgstr ""
6632 #. type: Content of: <book><chapter><sect1><sect2><title>
6633 #: ../en/ch05-daily.xml:73
6634 msgid "Mercurial tracks files, not directories"
6635 msgstr "Mercurial 只跟踪文件,不跟踪目录"
6637 #. type: Content of: <book><chapter><sect1><sect2><para>
6638 #: ../en/ch05-daily.xml:75
6639 msgid ""
6640 "Mercurial does not track directory information. Instead, it tracks the path "
6641 "to a file. Before creating a file, it first creates any missing directory "
6642 "components of the path. After it deletes a file, it then deletes any empty "
6643 "directories that were in the deleted file's path. This sounds like a trivial "
6644 "distinction, but it has one minor practical consequence: it is not possible "
6645 "to represent a completely empty directory in Mercurial."
6646 msgstr ""
6648 #. type: Content of: <book><chapter><sect1><sect2><para>
6649 #: ../en/ch05-daily.xml:84
6650 msgid ""
6651 "Empty directories are rarely useful, and there are unintrusive workarounds "
6652 "that you can use to achieve an appropriate effect. The developers of "
6653 "Mercurial thus felt that the complexity that would be required to manage "
6654 "empty directories was not worth the limited benefit this feature would bring."
6655 msgstr ""
6657 #. type: Content of: <book><chapter><sect1><sect2><para>
6658 #: ../en/ch05-daily.xml:91
6659 msgid ""
6660 "If you need an empty directory in your repository, there are a few ways to "
6661 "achieve this. One is to create a directory, then <command role=\"hg-cmd\">hg "
6662 "add</command> a <quote>hidden</quote> file to that directory. On Unix-like "
6663 "systems, any file name that begins with a period (<quote><literal>.</"
6664 "literal></quote>) is treated as hidden by most commands and GUI tools. This "
6665 "approach is illustrated below."
6666 msgstr ""
6668 #. type: Content of: <book><chapter><sect1><sect2><para>
6669 #: ../en/ch05-daily.xml:102
6670 msgid ""
6671 "Another way to tackle a need for an empty directory is to simply create one "
6672 "in your automated build scripts before they will need it."
6673 msgstr ""
6675 #. type: Content of: <book><chapter><sect1><title>
6676 #: ../en/ch05-daily.xml:109
6677 msgid "How to stop tracking a file"
6678 msgstr "如何停止跟踪文件"
6680 #. type: Content of: <book><chapter><sect1><para>
6681 #: ../en/ch05-daily.xml:111
6682 msgid ""
6683 "Once you decide that a file no longer belongs in your repository, use the "
6684 "<command role=\"hg-cmd\">hg remove</command> command. This deletes the file, "
6685 "and tells Mercurial to stop tracking it (which will occur at the next "
6686 "commit). A removed file is represented in the output of <command role=\"hg-"
6687 "cmd\">hg status</command> with a <quote><literal>R</literal></quote>."
6688 msgstr ""
6690 #. type: Content of: <book><chapter><sect1><para>
6691 #: ../en/ch05-daily.xml:121
6692 msgid ""
6693 "After you <command role=\"hg-cmd\">hg remove</command> a file, Mercurial will "
6694 "no longer track changes to that file, even if you recreate a file with the "
6695 "same name in your working directory. If you do recreate a file with the same "
6696 "name and want Mercurial to track the new file, simply <command role=\"hg-cmd"
6697 "\">hg add</command> it. Mercurial will know that the newly added file is not "
6698 "related to the old file of the same name."
6699 msgstr ""
6701 #. type: Content of: <book><chapter><sect1><sect2><title>
6702 #: ../en/ch05-daily.xml:130
6703 msgid "Removing a file does not affect its history"
6704 msgstr "删除文件不影响历史"
6706 #. type: Content of: <book><chapter><sect1><sect2><para>
6707 #: ../en/ch05-daily.xml:132
6708 msgid "It is important to understand that removing a file has only two effects."
6709 msgstr ""
6711 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6712 #: ../en/ch05-daily.xml:135
6713 msgid "It removes the current version of the file from the working directory."
6714 msgstr ""
6716 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6717 #: ../en/ch05-daily.xml:138
6718 msgid ""
6719 "It stops Mercurial from tracking changes to the file, from the time of the "
6720 "next commit."
6721 msgstr ""
6723 #. type: Content of: <book><chapter><sect1><sect2><para>
6724 #: ../en/ch05-daily.xml:141
6725 msgid ""
6726 "Removing a file <emphasis>does not</emphasis> in any way alter the "
6727 "<emphasis>history</emphasis> of the file."
6728 msgstr ""
6730 #. type: Content of: <book><chapter><sect1><sect2><para>
6731 #: ../en/ch05-daily.xml:144
6732 msgid ""
6733 "If you update the working directory to a changeset that was committed when it "
6734 "was still tracking a file that you later removed, the file will reappear in "
6735 "the working directory, with the contents it had when you committed that "
6736 "changeset. If you then update the working directory to a later changeset, in "
6737 "which the file had been removed, Mercurial will once again remove the file "
6738 "from the working directory."
6739 msgstr ""
6741 #. type: Content of: <book><chapter><sect1><sect2><title>
6742 #: ../en/ch05-daily.xml:155
6743 msgid "Missing files"
6744 msgstr "丢失的文件"
6746 #. type: Content of: <book><chapter><sect1><sect2><para>
6747 #: ../en/ch05-daily.xml:157
6748 msgid ""
6749 "Mercurial considers a file that you have deleted, but not used <command role="
6750 "\"hg-cmd\">hg remove</command> to delete, to be <emphasis>missing</"
6751 "emphasis>. A missing file is represented with <quote><literal>!</literal></"
6752 "quote> in the output of <command role=\"hg-cmd\">hg status</command>. "
6753 "Mercurial commands will not generally do anything with missing files."
6754 msgstr ""
6756 #. type: Content of: <book><chapter><sect1><sect2><para>
6757 #: ../en/ch05-daily.xml:167
6758 msgid ""
6759 "If your repository contains a file that <command role=\"hg-cmd\">hg status</"
6760 "command> reports as missing, and you want the file to stay gone, you can run "
6761 "<command role=\"hg-cmd\">hg remove <option role=\"hg-opt-remove\">--after</"
6762 "option></command> at any time later on, to tell Mercurial that you really did "
6763 "mean to remove the file."
6764 msgstr ""
6766 #. type: Content of: <book><chapter><sect1><sect2><para>
6767 #: ../en/ch05-daily.xml:177
6768 msgid ""
6769 "On the other hand, if you deleted the missing file by accident, give <command "
6770 "role=\"hg-cmd\">hg revert</command> the name of the file to recover. It will "
6771 "reappear, in unmodified form."
6772 msgstr ""
6774 #. type: Content of: <book><chapter><sect1><sect2><title>
6775 #: ../en/ch05-daily.xml:186
6776 msgid "Aside: why tell Mercurial explicitly to remove a file?"
6777 msgstr "旁白: 为什么要明确告诉 Mercurial 删除文件?"
6779 #. type: Content of: <book><chapter><sect1><sect2><para>
6780 #: ../en/ch05-daily.xml:189
6781 msgid ""
6782 "You might wonder why Mercurial requires you to explicitly tell it that you "
6783 "are deleting a file. Early during the development of Mercurial, it let you "
6784 "delete a file however you pleased; Mercurial would notice the absence of the "
6785 "file automatically when you next ran a <command role=\"hg-cmd\">hg commit</"
6786 "command>, and stop tracking the file. In practice, this made it too easy to "
6787 "accidentally remove a file without noticing."
6788 msgstr ""
6790 #. type: Content of: <book><chapter><sect1><sect2><title>
6791 #: ../en/ch05-daily.xml:200
6792 msgid "Useful shorthand&emdash;adding and removing files in one step"
6793 msgstr "有用的速记—一个步骤添加和删除文件"
6795 #. type: Content of: <book><chapter><sect1><sect2><para>
6796 #: ../en/ch05-daily.xml:203
6797 msgid ""
6798 "Mercurial offers a combination command, <command role=\"hg-cmd\">hg "
6799 "addremove</command>, that adds untracked files and marks missing files as "
6800 "removed."
6801 msgstr ""
6803 #. type: Content of: <book><chapter><sect1><sect2><para>
6804 #: ../en/ch05-daily.xml:209
6805 msgid ""
6806 "The <command role=\"hg-cmd\">hg commit</command> command also provides a "
6807 "<option role=\"hg-opt-commit\">-A</option> option that performs this same add-"
6808 "and-remove, immediately followed by a commit."
6809 msgstr ""
6811 #. type: Content of: <book><chapter><sect1><title>
6812 #: ../en/ch05-daily.xml:219
6813 msgid "Copying files"
6814 msgstr "复制文件"
6816 #. type: Content of: <book><chapter><sect1><para>
6817 #: ../en/ch05-daily.xml:221
6818 msgid ""
6819 "Mercurial provides a <command role=\"hg-cmd\">hg copy</command> command that "
6820 "lets you make a new copy of a file. When you copy a file using this command, "
6821 "Mercurial makes a record of the fact that the new file is a copy of the "
6822 "original file. It treats these copied files specially when you merge your "
6823 "work with someone else's."
6824 msgstr ""
6826 #. type: Content of: <book><chapter><sect1><sect2><title>
6827 #: ../en/ch05-daily.xml:229
6828 msgid "The results of copying during a merge"
6829 msgstr "合并期间的复制结果"
6831 #. type: Content of: <book><chapter><sect1><sect2><para>
6832 #: ../en/ch05-daily.xml:231
6833 msgid ""
6834 "What happens during a merge is that changes <quote>follow</quote> a copy. To "
6835 "best illustrate what this means, let's create an example. We'll start with "
6836 "the usual tiny repository that contains a single file."
6837 msgstr ""
6839 #. type: Content of: <book><chapter><sect1><sect2><para>
6840 #: ../en/ch05-daily.xml:238
6841 msgid ""
6842 "We need to do some work in parallel, so that we'll have something to merge. "
6843 "So let's clone our repository."
6844 msgstr ""
6846 #. type: Content of: <book><chapter><sect1><sect2><para>
6847 #: ../en/ch05-daily.xml:244
6848 msgid ""
6849 "Back in our initial repository, let's use the <command role=\"hg-cmd\">hg "
6850 "copy</command> command to make a copy of the first file we created."
6851 msgstr ""
6853 #. type: Content of: <book><chapter><sect1><sect2><para>
6854 #: ../en/ch05-daily.xml:250
6855 msgid ""
6856 "If we look at the output of the <command role=\"hg-cmd\">hg status</command> "
6857 "command afterwards, the copied file looks just like a normal added file."
6858 msgstr ""
6860 #. type: Content of: <book><chapter><sect1><sect2><para>
6861 #: ../en/ch05-daily.xml:256
6862 msgid ""
6863 "But if we pass the <option role=\"hg-opt-status\">-C</option> option to "
6864 "<command role=\"hg-cmd\">hg status</command>, it prints another line of "
6865 "output: this is the file that our newly-added file was copied <emphasis>from</"
6866 "emphasis>."
6867 msgstr ""
6869 #. type: Content of: <book><chapter><sect1><sect2><para>
6870 #: ../en/ch05-daily.xml:264
6871 msgid ""
6872 "Now, back in the repository we cloned, let's make a change in parallel. "
6873 "We'll add a line of content to the original file that we created."
6874 msgstr ""
6876 #. type: Content of: <book><chapter><sect1><sect2><para>
6877 #: ../en/ch05-daily.xml:270
6878 msgid ""
6879 "Now we have a modified <filename>file</filename> in this repository. When we "
6880 "pull the changes from the first repository, and merge the two heads, "
6881 "Mercurial will propagate the changes that we made locally to <filename>file</"
6882 "filename> into its copy, <filename>new-file</filename>."
6883 msgstr ""
6885 #. type: Content of: <book><chapter><sect1><sect2><title>
6886 #: ../en/ch05-daily.xml:280
6887 msgid "Why should changes follow copies?"
6888 msgstr "为什么复制后需要后续修改?"
6890 #. type: Content of: <book><chapter><sect1><sect2><para>
6891 #: ../en/ch05-daily.xml:282
6892 msgid ""
6893 "This behavior&emdash;of changes to a file propagating out to copies of the "
6894 "file&emdash;might seem esoteric, but in most cases it's highly desirable."
6895 msgstr ""
6897 #. type: Content of: <book><chapter><sect1><sect2><para>
6898 #: ../en/ch05-daily.xml:286
6899 msgid ""
6900 "First of all, remember that this propagation <emphasis>only</emphasis> "
6901 "happens when you merge. So if you <command role=\"hg-cmd\">hg copy</command> "
6902 "a file, and subsequently modify the original file during the normal course of "
6903 "your work, nothing will happen."
6904 msgstr ""
6906 #. type: Content of: <book><chapter><sect1><sect2><para>
6907 #: ../en/ch05-daily.xml:292
6908 msgid ""
6909 "The second thing to know is that modifications will only propagate across a "
6910 "copy as long as the changeset that you're merging changes from "
6911 "<emphasis>hasn't yet seen</emphasis> the copy."
6912 msgstr ""
6914 #. type: Content of: <book><chapter><sect1><sect2><para>
6915 #: ../en/ch05-daily.xml:297
6916 msgid ""
6917 "The reason that Mercurial does this is as follows. Let's say I make an "
6918 "important bug fix in a source file, and commit my changes. Meanwhile, you've "
6919 "decided to <command role=\"hg-cmd\">hg copy</command> the file in your "
6920 "repository, without knowing about the bug or having seen the fix, and you "
6921 "have started hacking on your copy of the file."
6922 msgstr ""
6924 #. type: Content of: <book><chapter><sect1><sect2><para>
6925 #: ../en/ch05-daily.xml:304
6926 msgid ""
6927 "If you pulled and merged my changes, and Mercurial <emphasis>didn't</"
6928 "emphasis> propagate changes across copies, your new source file would now "
6929 "contain the bug, and unless you knew to propagate the bug fix by hand, the "
6930 "bug would <emphasis>remain</emphasis> in your copy of the file."
6931 msgstr ""
6933 #. type: Content of: <book><chapter><sect1><sect2><para>
6934 #: ../en/ch05-daily.xml:310
6935 msgid ""
6936 "By automatically propagating the change that fixed the bug from the original "
6937 "file to the copy, Mercurial prevents this class of problem. To my knowledge, "
6938 "Mercurial is the <emphasis>only</emphasis> revision control system that "
6939 "propagates changes across copies like this."
6940 msgstr ""
6942 #. type: Content of: <book><chapter><sect1><sect2><para>
6943 #: ../en/ch05-daily.xml:316
6944 msgid ""
6945 "Once your change history has a record that the copy and subsequent merge "
6946 "occurred, there's usually no further need to propagate changes from the "
6947 "original file to the copied file, and that's why Mercurial only propagates "
6948 "changes across copies at the first merge, and not afterwards."
6949 msgstr ""
6951 #. type: Content of: <book><chapter><sect1><sect2><title>
6952 #: ../en/ch05-daily.xml:324
6953 msgid "How to make changes <emphasis>not</emphasis> follow a copy"
6954 msgstr "如何让复制后<emphasis>不</emphasis>修改?"
6956 #. type: Content of: <book><chapter><sect1><sect2><para>
6957 #: ../en/ch05-daily.xml:327
6958 msgid ""
6959 "If, for some reason, you decide that this business of automatically "
6960 "propagating changes across copies is not for you, simply use your system's "
6961 "normal file copy command (on Unix-like systems, that's <command>cp</command>) "
6962 "to make a copy of a file, then <command role=\"hg-cmd\">hg add</command> the "
6963 "new copy by hand. Before you do so, though, please do reread <xref linkend="
6964 "\"sec:daily:why-copy\"/>, and make an informed decision that this behavior is "
6965 "not appropriate to your specific case."
6966 msgstr ""
6968 #. type: Content of: <book><chapter><sect1><sect2><title>
6969 #: ../en/ch05-daily.xml:340
6970 msgid "Behavior of the <command role=\"hg-cmd\">hg copy</command> command"
6971 msgstr "命令 <command role=\"hg-cmd\">hg copy</command> 的特性"
6973 #. type: Content of: <book><chapter><sect1><sect2><para>
6974 #: ../en/ch05-daily.xml:343
6975 msgid ""
6976 "When you use the <command role=\"hg-cmd\">hg copy</command> command, "
6977 "Mercurial makes a copy of each source file as it currently stands in the "
6978 "working directory. This means that if you make some modifications to a file, "
6979 "then <command role=\"hg-cmd\">hg copy</command> it without first having "
6980 "committed those changes, the new copy will also contain the modifications you "
6981 "have made up until that point. (I find this behavior a little "
6982 "counterintuitive, which is why I mention it here.)"
6983 msgstr ""
6985 #. type: Content of: <book><chapter><sect1><sect2><para>
6986 #: ../en/ch05-daily.xml:353
6987 msgid ""
6988 "The <command role=\"hg-cmd\">hg copy</command> command acts similarly to the "
6989 "Unix <command>cp</command> command (you can use the <command role=\"hg-cmd"
6990 "\">hg cp</command> alias if you prefer). We must supply two or more "
6991 "arguments, of which the last is treated as the <emphasis>destination</"
6992 "emphasis>, and all others are <emphasis>sources</emphasis>."
6993 msgstr ""
6995 #. type: Content of: <book><chapter><sect1><sect2><para>
6996 #: ../en/ch05-daily.xml:361
6997 msgid ""
6998 "If you pass <command role=\"hg-cmd\">hg copy</command> a single file as the "
6999 "source, and the destination does not exist, it creates a new file with that "
7000 "name."
7001 msgstr ""
7003 #. type: Content of: <book><chapter><sect1><sect2><para>
7004 #: ../en/ch05-daily.xml:367
7005 msgid ""
7006 "If the destination is a directory, Mercurial copies its sources into that "
7007 "directory."
7008 msgstr ""
7010 #. type: Content of: <book><chapter><sect1><sect2><para>
7011 #: ../en/ch05-daily.xml:372
7012 msgid ""
7013 "Copying a directory is recursive, and preserves the directory structure of "
7014 "the source."
7015 msgstr ""
7017 #. type: Content of: <book><chapter><sect1><sect2><para>
7018 #: ../en/ch05-daily.xml:378
7019 msgid ""
7020 "If the source and destination are both directories, the source tree is "
7021 "recreated in the destination directory."
7022 msgstr ""
7024 #. type: Content of: <book><chapter><sect1><sect2><para>
7025 #: ../en/ch05-daily.xml:383
7026 msgid ""
7027 "As with the <command role=\"hg-cmd\">hg remove</command> command, if you copy "
7028 "a file manually and then want Mercurial to know that you've copied the file, "
7029 "simply use the <option role=\"hg-opt-copy\">--after</option> option to "
7030 "<command role=\"hg-cmd\">hg copy</command>."
7031 msgstr ""
7033 #. type: Content of: <book><chapter><sect1><title>
7034 #: ../en/ch05-daily.xml:394
7035 msgid "Renaming files"
7036 msgstr "改名文件"
7038 #. type: Content of: <book><chapter><sect1><para>
7039 #: ../en/ch05-daily.xml:396
7040 msgid ""
7041 "It's rather more common to need to rename a file than to make a copy of it. "
7042 "The reason I discussed the <command role=\"hg-cmd\">hg copy</command> command "
7043 "before talking about renaming files is that Mercurial treats a rename in "
7044 "essentially the same way as a copy. Therefore, knowing what Mercurial does "
7045 "when you copy a file tells you what to expect when you rename a file."
7046 msgstr ""
7048 #. type: Content of: <book><chapter><sect1><para>
7049 #: ../en/ch05-daily.xml:404
7050 msgid ""
7051 "When you use the <command role=\"hg-cmd\">hg rename</command> command, "
7052 "Mercurial makes a copy of each source file, then deletes it and marks the "
7053 "file as removed."
7054 msgstr ""
7056 #. type: Content of: <book><chapter><sect1><para>
7057 #: ../en/ch05-daily.xml:410
7058 msgid ""
7059 "The <command role=\"hg-cmd\">hg status</command> command shows the newly "
7060 "copied file as added, and the copied-from file as removed."
7061 msgstr ""
7063 #. type: Content of: <book><chapter><sect1><para>
7064 #: ../en/ch05-daily.xml:416
7065 msgid ""
7066 "As with the results of a <command role=\"hg-cmd\">hg copy</command>, we must "
7067 "use the <option role=\"hg-opt-status\">-C</option> option to <command role="
7068 "\"hg-cmd\">hg status</command> to see that the added file is really being "
7069 "tracked by Mercurial as a copy of the original, now removed, file."
7070 msgstr ""
7072 #. type: Content of: <book><chapter><sect1><para>
7073 #: ../en/ch05-daily.xml:425
7074 msgid ""
7075 "As with <command role=\"hg-cmd\">hg remove</command> and <command role=\"hg-"
7076 "cmd\">hg copy</command>, you can tell Mercurial about a rename after the fact "
7077 "using the <option role=\"hg-opt-rename\">--after</option> option. In most "
7078 "other respects, the behavior of the <command role=\"hg-cmd\">hg rename</"
7079 "command> command, and the options it accepts, are similar to the <command "
7080 "role=\"hg-cmd\">hg copy</command> command."
7081 msgstr ""
7083 #. type: Content of: <book><chapter><sect1><para>
7084 #: ../en/ch05-daily.xml:434
7085 msgid ""
7086 "If you're familiar with the Unix command line, you'll be glad to know that "
7087 "<command role=\"hg-cmd\">hg rename</command> command can be invoked as "
7088 "<command role=\"hg-cmd\">hg mv</command>."
7089 msgstr ""
7091 #. type: Content of: <book><chapter><sect1><sect2><title>
7092 #: ../en/ch05-daily.xml:440
7093 msgid "Renaming files and merging changes"
7094 msgstr "改名文件与合并修改"
7096 #. type: Content of: <book><chapter><sect1><sect2><para>
7097 #: ../en/ch05-daily.xml:442
7098 msgid ""
7099 "Since Mercurial's rename is implemented as copy-and-remove, the same "
7100 "propagation of changes happens when you merge after a rename as after a copy."
7101 msgstr ""
7103 #. type: Content of: <book><chapter><sect1><sect2><para>
7104 #: ../en/ch05-daily.xml:446
7105 msgid ""
7106 "If I modify a file, and you rename it to a new name, and then we merge our "
7107 "respective changes, my modifications to the file under its original name will "
7108 "be propagated into the file under its new name. (This is something you might "
7109 "expect to <quote>simply work,</quote> but not all revision control systems "
7110 "actually do this.)"
7111 msgstr ""
7113 #. type: Content of: <book><chapter><sect1><sect2><para>
7114 #: ../en/ch05-daily.xml:453
7115 msgid ""
7116 "Whereas having changes follow a copy is a feature where you can perhaps nod "
7117 "and say <quote>yes, that might be useful,</quote> it should be clear that "
7118 "having them follow a rename is definitely important. Without this facility, "
7119 "it would simply be too easy for changes to become orphaned when files are "
7120 "renamed."
7121 msgstr ""
7123 #. type: Content of: <book><chapter><sect1><sect2><title>
7124 #: ../en/ch05-daily.xml:462
7125 msgid "Divergent renames and merging"
7126 msgstr "改名与合并的分歧"
7128 #. type: Content of: <book><chapter><sect1><sect2><para>
7129 #: ../en/ch05-daily.xml:464
7130 msgid ""
7131 "The case of diverging names occurs when two developers start with a "
7132 "file&emdash;let's call it <filename>foo</filename>&emdash;in their respective "
7133 "repositories."
7134 msgstr ""
7136 #. type: Content of: <book><chapter><sect1><sect2><para>
7137 #: ../en/ch05-daily.xml:471
7138 msgid "Anne renames the file to <filename>bar</filename>."
7139 msgstr ""
7141 #. type: Content of: <book><chapter><sect1><sect2><para>
7142 #: ../en/ch05-daily.xml:475
7143 msgid ""
7144 "Meanwhile, Bob renames it to <filename>quux</filename>. (Remember that "
7145 "<command role=\"hg-cmd\">hg mv</command> is an alias for <command role=\"hg-"
7146 "cmd\">hg rename</command>.)"
7147 msgstr ""
7149 #. type: Content of: <book><chapter><sect1><sect2><para>
7150 #: ../en/ch05-daily.xml:482
7151 msgid ""
7152 "I like to think of this as a conflict because each developer has expressed "
7153 "different intentions about what the file ought to be named."
7154 msgstr ""
7156 #. type: Content of: <book><chapter><sect1><sect2><para>
7157 #: ../en/ch05-daily.xml:486
7158 msgid ""
7159 "What do you think should happen when they merge their work? Mercurial's "
7160 "actual behavior is that it always preserves <emphasis>both</emphasis> names "
7161 "when it merges changesets that contain divergent renames."
7162 msgstr ""
7164 #. type: Content of: <book><chapter><sect1><sect2><para>
7165 #: ../en/ch05-daily.xml:493
7166 msgid ""
7167 "Notice that while Mercurial warns about the divergent renames, it leaves it "
7168 "up to you to do something about the divergence after the merge."
7169 msgstr ""
7171 #. type: Content of: <book><chapter><sect1><sect2><title>
7172 #: ../en/ch05-daily.xml:499
7173 msgid "Convergent renames and merging"
7174 msgstr "收敛改名与合并"
7176 #. type: Content of: <book><chapter><sect1><sect2><para>
7177 #: ../en/ch05-daily.xml:501
7178 msgid ""
7179 "Another kind of rename conflict occurs when two people choose to rename "
7180 "different <emphasis>source</emphasis> files to the same "
7181 "<emphasis>destination</emphasis>. In this case, Mercurial runs its normal "
7182 "merge machinery, and lets you guide it to a suitable resolution."
7183 msgstr ""
7185 #. type: Content of: <book><chapter><sect1><sect2><title>
7186 #: ../en/ch05-daily.xml:509
7187 msgid "Other name-related corner cases"
7188 msgstr "其它名称相关的角落"
7190 #. type: Content of: <book><chapter><sect1><sect2><para>
7191 #: ../en/ch05-daily.xml:511
7192 msgid ""
7193 "Mercurial has a longstanding bug in which it fails to handle a merge where "
7194 "one side has a file with a given name, while another has a directory with the "
7195 "same name. This is documented as <ulink role=\"hg-bug\" url=\"http://www."
7196 "selenic.com/mercurial/bts/issue29\">issue 29</ulink>."
7197 msgstr ""
7199 #. type: Content of: <book><chapter><sect1><title>
7200 #: ../en/ch05-daily.xml:524
7201 msgid "Recovering from mistakes"
7202 msgstr "从错误恢复"
7204 #. type: Content of: <book><chapter><sect1><para>
7205 #: ../en/ch05-daily.xml:526
7206 msgid ""
7207 "Mercurial has some useful commands that will help you to recover from some "
7208 "common mistakes."
7209 msgstr ""
7211 #. type: Content of: <book><chapter><sect1><para>
7212 #: ../en/ch05-daily.xml:529
7213 msgid ""
7214 "The <command role=\"hg-cmd\">hg revert</command> command lets you undo "
7215 "changes that you have made to your working directory. For example, if you "
7216 "<command role=\"hg-cmd\">hg add</command> a file by accident, just run "
7217 "<command role=\"hg-cmd\">hg revert</command> with the name of the file you "
7218 "added, and while the file won't be touched in any way, it won't be tracked "
7219 "for adding by Mercurial any longer, either. You can also use <command role="
7220 "\"hg-cmd\">hg revert</command> to get rid of erroneous changes to a file."
7221 msgstr ""
7223 #. type: Content of: <book><chapter><sect1><para>
7224 #: ../en/ch05-daily.xml:539
7225 msgid ""
7226 "It is helpful to remember that the <command role=\"hg-cmd\">hg revert</"
7227 "command> command is useful for changes that you have not yet committed. Once "
7228 "you've committed a change, if you decide it was a mistake, you can still do "
7229 "something about it, though your options may be more limited."
7230 msgstr ""
7232 #. type: Content of: <book><chapter><sect1><para>
7233 #: ../en/ch05-daily.xml:546
7234 msgid ""
7235 "For more information about the <command role=\"hg-cmd\">hg revert</command> "
7236 "command, and details about how to deal with changes you have already "
7237 "committed, see <xref linkend=\"chap:undo\"/>."
7238 msgstr ""
7240 #. type: Content of: <book><chapter><sect1><title>
7241 #: ../en/ch05-daily.xml:553
7242 msgid "Dealing with tricky merges"
7243 msgstr "合并的技巧"
7245 #. type: Content of: <book><chapter><sect1><para>
7246 #: ../en/ch05-daily.xml:555
7247 msgid ""
7248 "In a complicated or large project, it's not unusual for a merge of two "
7249 "changesets to result in some headaches. Suppose there's a big source file "
7250 "that's been extensively edited by each side of a merge: this is almost "
7251 "inevitably going to result in conflicts, some of which can take a few tries "
7252 "to sort out."
7253 msgstr ""
7255 #. type: Content of: <book><chapter><sect1><para>
7256 #: ../en/ch05-daily.xml:562
7257 msgid ""
7258 "Let's develop a simple case of this and see how to deal with it. We'll start "
7259 "off with a repository containing one file, and clone it twice."
7260 msgstr ""
7262 #. type: Content of: <book><chapter><sect1><para>
7263 #: ../en/ch05-daily.xml:568
7264 msgid "In one clone, we'll modify the file in one way."
7265 msgstr ""
7267 #. type: Content of: <book><chapter><sect1><para>
7268 #: ../en/ch05-daily.xml:572
7269 msgid "In another, we'll modify the file differently."
7270 msgstr ""
7272 #. type: Content of: <book><chapter><sect1><para>
7273 #: ../en/ch05-daily.xml:576
7274 msgid "Next, we'll pull each set of changes into our original repo."
7275 msgstr ""
7277 #. type: Content of: <book><chapter><sect1><para>
7278 #: ../en/ch05-daily.xml:581
7279 msgid "We expect our repository to now contain two heads."
7280 msgstr ""
7282 #. type: Content of: <book><chapter><sect1><para>
7283 #: ../en/ch05-daily.xml:585
7284 msgid ""
7285 "Normally, if we run <command role=\"hg-cmd\">hg merge</command> at this "
7286 "point, it will drop us into a GUI that will let us manually resolve the "
7287 "conflicting edits to <filename>myfile.txt</filename>. However, to simplify "
7288 "things for presentation here, we'd like the merge to fail immediately "
7289 "instead. Here's one way we can do so."
7290 msgstr ""
7292 #. type: Content of: <book><chapter><sect1><para>
7293 #: ../en/ch05-daily.xml:594
7294 msgid ""
7295 "We've told Mercurial's merge machinery to run the command <command>false</"
7296 "command> (which, as we desire, fails immediately) if it detects a merge that "
7297 "it can't sort out automatically."
7298 msgstr ""
7300 #. type: Content of: <book><chapter><sect1><para>
7301 #: ../en/ch05-daily.xml:599
7302 msgid ""
7303 "If we now fire up <command role=\"hg-cmd\">hg merge</command>, it should "
7304 "grind to a halt and report a failure."
7305 msgstr ""
7307 #. type: Content of: <book><chapter><sect1><para>
7308 #: ../en/ch05-daily.xml:605
7309 msgid ""
7310 "Even if we don't notice that the merge failed, Mercurial will prevent us from "
7311 "accidentally committing the result of a failed merge."
7312 msgstr ""
7314 #. type: Content of: <book><chapter><sect1><para>
7315 #: ../en/ch05-daily.xml:611
7316 msgid ""
7317 "When <command role=\"hg-cmd\">hg commit</command> fails in this case, it "
7318 "suggests that we use the unfamiliar <command role=\"hg-cmd\">hg resolve</"
7319 "command> command. As usual, <command role=\"hg-cmd\">hg help resolve</"
7320 "command> will print a helpful synopsis."
7321 msgstr ""
7323 #. type: Content of: <book><chapter><sect1><sect2><title>
7324 #: ../en/ch05-daily.xml:618
7325 msgid "File resolution states"
7326 msgstr "文件的解决状态"
7328 #. type: Content of: <book><chapter><sect1><sect2><para>
7329 #: ../en/ch05-daily.xml:620
7330 msgid ""
7331 "When a merge occurs, most files will usually remain unmodified. For each "
7332 "file where Mercurial has to do something, it tracks the state of the file."
7333 msgstr ""
7335 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
7336 #: ../en/ch05-daily.xml:626
7337 msgid ""
7338 "A <emphasis>resolved</emphasis> file has been successfully merged, either "
7339 "automatically by Mercurial or manually with human intervention."
7340 msgstr ""
7342 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
7343 #: ../en/ch05-daily.xml:631
7344 msgid ""
7345 "An <emphasis>unresolved</emphasis> file was not merged successfully, and "
7346 "needs more attention."
7347 msgstr ""
7349 #. type: Content of: <book><chapter><sect1><sect2><para>
7350 #: ../en/ch05-daily.xml:636
7351 msgid ""
7352 "If Mercurial sees <emphasis>any</emphasis> file in the unresolved state after "
7353 "a merge, it considers the merge to have failed. Fortunately, we do not need "
7354 "to restart the entire merge from scratch."
7355 msgstr ""
7357 #. type: Content of: <book><chapter><sect1><sect2><para>
7358 #: ../en/ch05-daily.xml:641
7359 msgid ""
7360 "The <option role=\"hg-opt-resolve\">--list</option> or <option role=\"hg-opt-"
7361 "resolve\">-l</option> option to <command role=\"hg-cmd\">hg resolve</command> "
7362 "prints out the state of each merged file."
7363 msgstr ""
7365 #. type: Content of: <book><chapter><sect1><sect2><para>
7366 #: ../en/ch05-daily.xml:648
7367 msgid ""
7368 "In the output from <command role=\"hg-cmd\">hg resolve</command>, a resolved "
7369 "file is marked with <literal>R</literal>, while an unresolved file is marked "
7370 "with <literal>U</literal>. If any files are listed with <literal>U</"
7371 "literal>, we know that an attempt to commit the results of the merge will "
7372 "fail."
7373 msgstr ""
7375 #. type: Content of: <book><chapter><sect1><sect2><title>
7376 #: ../en/ch05-daily.xml:657
7377 msgid "Resolving a file merge"
7378 msgstr "合并文件"
7380 #. type: Content of: <book><chapter><sect1><sect2><para>
7381 #: ../en/ch05-daily.xml:659
7382 msgid ""
7383 "We have several options to move a file from the unresolved into the resolved "
7384 "state. By far the most common is to rerun <command role=\"hg-cmd\">hg "
7385 "resolve</command>. If we pass the names of individual files or directories, "
7386 "it will retry the merges of any unresolved files present in those locations. "
7387 "We can also pass the <option role=\"hg-opt-resolve\">--all</option> or "
7388 "<option role=\"hg-opt-resolve\">-a</option> option, which will retry the "
7389 "merges of <emphasis>all</emphasis> unresolved files."
7390 msgstr ""
7392 #. type: Content of: <book><chapter><sect1><sect2><para>
7393 #: ../en/ch05-daily.xml:669
7394 msgid ""
7395 "Mercurial also lets us modify the resolution state of a file directly. We "
7396 "can manually mark a file as resolved using the <option role=\"hg-opt-resolve"
7397 "\">--mark</option> option, or as unresolved using the <option role=\"hg-opt-"
7398 "resolve\">--unmark</option> option. This allows us to clean up a "
7399 "particularly messy merge by hand, and to keep track of our progress with each "
7400 "file as we go."
7401 msgstr ""
7403 #. type: Content of: <book><chapter><sect1><title>
7404 #: ../en/ch05-daily.xml:680
7405 msgid "More useful diffs"
7406 msgstr "更有用的差异"
7408 #. type: Content of: <book><chapter><sect1><para>
7409 #: ../en/ch05-daily.xml:682
7410 msgid ""
7411 "The default output of the <command role=\"hg-cmd\">hg diff</command> command "
7412 "is backwards compatible with the regular <command>diff</command> command, but "
7413 "this has some drawbacks."
7414 msgstr ""
7416 #. type: Content of: <book><chapter><sect1><para>
7417 #: ../en/ch05-daily.xml:687
7418 msgid ""
7419 "Consider the case where we use <command role=\"hg-cmd\">hg rename</command> "
7420 "to rename a file."
7421 msgstr ""
7422 "设想我们使用 <command role=\"hg-cmd\">hg rename</command> 命令来改名文件。"
7424 #. type: Content of: <book><chapter><sect1><para>
7425 #: ../en/ch05-daily.xml:692
7426 msgid ""
7427 "The output of <command role=\"hg-cmd\">hg diff</command> above obscures the "
7428 "fact that we simply renamed a file. The <command role=\"hg-cmd\">hg diff</"
7429 "command> command accepts an option, <option>--git</option> or <option>-g</"
7430 "option>, to use a newer diff format that displays such information in a more "
7431 "readable form."
7432 msgstr ""
7434 #. type: Content of: <book><chapter><sect1><para>
7435 #: ../en/ch05-daily.xml:701
7436 msgid ""
7437 "This option also helps with a case that can otherwise be confusing: a file "
7438 "that appears to be modified according to <command role=\"hg-cmd\">hg status</"
7439 "command>, but for which <command role=\"hg-cmd\">hg diff</command> prints "
7440 "nothing. This situation can arise if we change the file's execute permissions."
7441 msgstr ""
7443 #. type: Content of: <book><chapter><sect1><para>
7444 #: ../en/ch05-daily.xml:710
7445 msgid ""
7446 "The normal <command>diff</command> command pays no attention to file "
7447 "permissions, which is why <command role=\"hg-cmd\">hg diff</command> prints "
7448 "nothing by default. If we supply it with the <option>-g</option> option, it "
7449 "tells us what really happened."
7450 msgstr ""
7452 #. type: Content of: <book><chapter><sect1><title>
7453 #: ../en/ch05-daily.xml:720
7454 msgid "Which files to manage, and which to avoid"
7455 msgstr "需要管理哪些文件,应该避免的事情"
7457 #. type: Content of: <book><chapter><sect1><para>
7458 #: ../en/ch05-daily.xml:722
7459 msgid ""
7460 "Revision control systems are generally best at managing text files that are "
7461 "written by humans, such as source code, where the files do not change much "
7462 "from one revision to the next. Some centralized revision control systems can "
7463 "also deal tolerably well with binary files, such as bitmap images."
7464 msgstr ""
7466 #. type: Content of: <book><chapter><sect1><para>
7467 #: ../en/ch05-daily.xml:728
7468 msgid ""
7469 "For instance, a game development team will typically manage both its source "
7470 "code and all of its binary assets (e.g. geometry data, textures, map layouts) "
7471 "in a revision control system."
7472 msgstr ""
7474 #. type: Content of: <book><chapter><sect1><para>
7475 #: ../en/ch05-daily.xml:733
7476 msgid ""
7477 "Because it is usually impossible to merge two conflicting modifications to a "
7478 "binary file, centralized systems often provide a file locking mechanism that "
7479 "allow a user to say <quote>I am the only person who can edit this file</"
7480 "quote>."
7481 msgstr ""
7483 #. type: Content of: <book><chapter><sect1><para>
7484 #: ../en/ch05-daily.xml:739
7485 msgid ""
7486 "Compared to a centralized system, a distributed revision control system "
7487 "changes some of the factors that guide decisions over which files to manage "
7488 "and how."
7489 msgstr ""
7491 #. type: Content of: <book><chapter><sect1><para>
7492 #: ../en/ch05-daily.xml:743
7493 msgid ""
7494 "For instance, a distributed revision control system cannot, by its nature, "
7495 "offer a file locking facility. There is thus no built-in mechanism to "
7496 "prevent two people from making conflicting changes to a binary file. If you "
7497 "have a team where several people may be editing binary files frequently, it "
7498 "may not be a good idea to use Mercurial&emdash;or any other distributed "
7499 "revision control system&emdash;to manage those files."
7500 msgstr ""
7502 #. type: Content of: <book><chapter><sect1><para>
7503 #: ../en/ch05-daily.xml:751
7504 msgid ""
7505 "When storing modifications to a file, Mercurial usually saves only the "
7506 "differences between the previous and current versions of the file. For most "
7507 "text files, this is extremely efficient. However, some files (particularly "
7508 "binary files) are laid out in such a way that even a small change to a file's "
7509 "logical content results in many or most of the bytes inside the file "
7510 "changing. For instance, compressed files are particularly susceptible to "
7511 "this. If the differences between each successive version of a file are always "
7512 "large, Mercurial will not be able to store the file's revision history very "
7513 "efficiently. This can affect both local storage needs and the amount of time "
7514 "it takes to clone a repository."
7515 msgstr ""
7517 #. type: Content of: <book><chapter><sect1><para>
7518 #: ../en/ch05-daily.xml:764
7519 msgid ""
7520 "To get an idea of how this could affect you in practice, suppose you want to "
7521 "use Mercurial to manage an OpenOffice document. OpenOffice stores documents "
7522 "on disk as compressed zip files. Edit even a single letter of your document "
7523 "in OpenOffice, and almost every byte in the entire file will change when you "
7524 "save it. Now suppose that file is 2MB in size. Because most of the file "
7525 "changes every time you save, Mercurial will have to store all 2MB of the file "
7526 "every time you commit, even though from your perspective, perhaps only a few "
7527 "words are changing each time. A single frequently-edited file that is not "
7528 "friendly to Mercurial's storage assumptions can easily have an outsized "
7529 "effect on the size of the repository."
7530 msgstr ""
7532 #. type: Content of: <book><chapter><sect1><para>
7533 #: ../en/ch05-daily.xml:777
7534 msgid ""
7535 "Even worse, if both you and someone else edit the OpenOffice document you're "
7536 "working on, there is no useful way to merge your work. In fact, there isn't "
7537 "even a good way to tell what the differences are between your respective "
7538 "changes."
7539 msgstr ""
7541 #. type: Content of: <book><chapter><sect1><para>
7542 #: ../en/ch05-daily.xml:782
7543 msgid ""
7544 "There are thus a few clear recommendations about specific kinds of files to "
7545 "be very careful with."
7546 msgstr ""
7548 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
7549 #: ../en/ch05-daily.xml:787
7550 msgid ""
7551 "Files that are very large and incompressible, e.g. ISO CD-ROM images, will by "
7552 "virtue of sheer size make clones over a network very slow."
7553 msgstr ""
7555 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
7556 #: ../en/ch05-daily.xml:792
7557 msgid ""
7558 "Files that change a lot from one revision to the next may be expensive to "
7559 "store if you edit them frequently, and conflicts due to concurrent edits may "
7560 "be difficult to resolve."
7561 msgstr ""
7563 #. type: Content of: <book><chapter><sect1><title>
7564 #: ../en/ch05-daily.xml:801
7565 msgid "Backups and mirroring"
7566 msgstr "备份与镜像"
7568 #. type: Content of: <book><chapter><sect1><para>
7569 #: ../en/ch05-daily.xml:803
7570 msgid ""
7571 "Since Mercurial maintains a complete copy of history in each clone, everyone "
7572 "who uses Mercurial to collaborate on a project can potentially act as a "
7573 "source of backups in the event of a catastrophe. If a central repository "
7574 "becomes unavailable, you can construct a replacement simply by cloning a copy "
7575 "of the repository from one contributor, and pulling any changes they may not "
7576 "have seen from others."
7577 msgstr ""
7579 #. type: Content of: <book><chapter><sect1><para>
7580 #: ../en/ch05-daily.xml:811
7581 msgid ""
7582 "It is simple to use Mercurial to perform off-site backups and remote "
7583 "mirrors. Set up a periodic job (e.g. via the <command>cron</command> "
7584 "command) on a remote server to pull changes from your master repositories "
7585 "every hour. This will only be tricky in the unlikely case that the number of "
7586 "master repositories you maintain changes frequently, in which case you'll "
7587 "need to do a little scripting to refresh the list of repositories to back up."
7588 msgstr ""
7590 #. type: Content of: <book><chapter><sect1><para>
7591 #: ../en/ch05-daily.xml:820
7592 msgid ""
7593 "If you perform traditional backups of your master repositories to tape or "
7594 "disk, and you want to back up a repository named <filename>myrepo</filename>, "
7595 "use <command>hg clone -U myrepo myrepo.bak</command> to create a clone of "
7596 "<filename>myrepo</filename> before you start your backups. The <option>-U</"
7597 "option> option doesn't check out a working directory after the clone "
7598 "completes, since that would be superfluous and make the backup take longer."
7599 msgstr ""
7601 #. type: Content of: <book><chapter><sect1><para>
7602 #: ../en/ch05-daily.xml:829
7603 msgid ""
7604 "If you then back up <filename>myrepo.bak</filename> instead of "
7605 "<filename>myrepo</filename>, you will be guaranteed to have a consistent "
7606 "snapshot of your repository that won't be pushed to by an insomniac developer "
7607 "in mid-backup."
7608 msgstr ""
7610 #. type: Content of: <book><chapter><title>
7611 #: ../en/ch06-collab.xml:5
7612 msgid "Collaborating with other people"
7613 msgstr "团体协作"
7615 #. type: Content of: <book><chapter><para>
7616 #: ../en/ch06-collab.xml:7
7617 msgid ""
7618 "As a completely decentralised tool, Mercurial doesn't impose any policy on "
7619 "how people ought to work with each other. However, if you're new to "
7620 "distributed revision control, it helps to have some tools and examples in "
7621 "mind when you're thinking about possible workflow models."
7622 msgstr ""
7624 #. type: Content of: <book><chapter><sect1><title>
7625 #: ../en/ch06-collab.xml:14
7626 msgid "Mercurial's web interface"
7627 msgstr "Mercurial 的 web 接口"
7629 #. type: Content of: <book><chapter><sect1><para>
7630 #: ../en/ch06-collab.xml:16
7631 msgid ""
7632 "Mercurial has a powerful web interface that provides several useful "
7633 "capabilities."
7634 msgstr ""
7636 #. type: Content of: <book><chapter><sect1><para>
7637 #: ../en/ch06-collab.xml:19
7638 msgid ""
7639 "For interactive use, the web interface lets you browse a single repository or "
7640 "a collection of repositories. You can view the history of a repository, "
7641 "examine each change (comments and diffs), and view the contents of each "
7642 "directory and file. You can even get a view of history that gives a "
7643 "graphical view of the relationships between individual changes and merges."
7644 msgstr ""
7646 #. type: Content of: <book><chapter><sect1><para>
7647 #: ../en/ch06-collab.xml:26
7648 msgid ""
7649 "Also for human consumption, the web interface provides Atom and RSS feeds of "
7650 "the changes in a repository. This lets you <quote>subscribe</quote> to a "
7651 "repository using your favorite feed reader, and be automatically notified of "
7652 "activity in that repository as soon as it happens. I find this capability "
7653 "much more convenient than the model of subscribing to a mailing list to which "
7654 "notifications are sent, as it requires no additional configuration on the "
7655 "part of whoever is serving the repository."
7656 msgstr ""
7658 #. type: Content of: <book><chapter><sect1><para>
7659 #: ../en/ch06-collab.xml:36
7660 msgid ""
7661 "The web interface also lets remote users clone a repository, pull changes "
7662 "from it, and (when the server is configured to permit it) push changes back "
7663 "to it. Mercurial's HTTP tunneling protocol aggressively compresses data, so "
7664 "that it works efficiently even over low-bandwidth network connections."
7665 msgstr ""
7667 #. type: Content of: <book><chapter><sect1><para>
7668 #: ../en/ch06-collab.xml:42
7669 msgid ""
7670 "The easiest way to get started with the web interface is to use your web "
7671 "browser to visit an existing repository, such as the master Mercurial "
7672 "repository at <ulink url=\"http://www.selenic.com/repo/hg\">http://www."
7673 "selenic.com/repo/hg</ulink>."
7674 msgstr ""
7676 #. type: Content of: <book><chapter><sect1><para>
7677 #: ../en/ch06-collab.xml:47
7678 msgid ""
7679 "If you're interested in providing a web interface to your own repositories, "
7680 "there are several good ways to do this."
7681 msgstr ""
7683 #. type: Content of: <book><chapter><sect1><para>
7684 #: ../en/ch06-collab.xml:51
7685 msgid ""
7686 "The easiest and fastest way to get started in an informal environment is to "
7687 "use the <command role=\"hg-cmd\">hg serve</command> command, which is best "
7688 "suited to short-term <quote>lightweight</quote> serving. See <xref linkend="
7689 "\"sec:collab:serve\"/> below for details of how to use this command."
7690 msgstr ""
7692 #. type: Content of: <book><chapter><sect1><para>
7693 #: ../en/ch06-collab.xml:58
7694 msgid ""
7695 "For longer-lived repositories that you'd like to have permanently available, "
7696 "there are several public hosting services available. Some are free to open "
7697 "source projects, while others offer paid commercial hosting. An up-to-date "
7698 "list is available at <ulink url=\"http://www.selenic.com/mercurial/wiki/index."
7699 "cgi/MercurialHosting\">http://www.selenic.com/mercurial/wiki/index.cgi/"
7700 "MercurialHosting</ulink>."
7701 msgstr ""
7703 #. type: Content of: <book><chapter><sect1><para>
7704 #: ../en/ch06-collab.xml:65
7705 msgid ""
7706 "If you would prefer to host your own repositories, Mercurial has built-in "
7707 "support for several popular hosting technologies, most notably CGI (Common "
7708 "Gateway Interface), and WSGI (Web Services Gateway Interface). See <xref "
7709 "linkend=\"sec:collab:cgi\"/> for details of CGI and WSGI configuration."
7710 msgstr ""
7712 #. type: Content of: <book><chapter><sect1><title>
7713 #: ../en/ch06-collab.xml:74
7714 msgid "Collaboration models"
7715 msgstr "协作模型"
7717 #. type: Content of: <book><chapter><sect1><para>
7718 #: ../en/ch06-collab.xml:76
7719 msgid ""
7720 "With a suitably flexible tool, making decisions about workflow is much more "
7721 "of a social engineering challenge than a technical one. Mercurial imposes few "
7722 "limitations on how you can structure the flow of work in a project, so it's "
7723 "up to you and your group to set up and live with a model that matches your "
7724 "own particular needs."
7725 msgstr ""
7727 #. type: Content of: <book><chapter><sect1><sect2><title>
7728 #: ../en/ch06-collab.xml:84
7729 msgid "Factors to keep in mind"
7730 msgstr "要牢记的因素"
7732 #. type: Content of: <book><chapter><sect1><sect2><para>
7733 #: ../en/ch06-collab.xml:86
7734 msgid ""
7735 "The most important aspect of any model that you must keep in mind is how well "
7736 "it matches the needs and capabilities of the people who will be using it. "
7737 "This might seem self-evident; even so, you still can't afford to forget it "
7738 "for a moment."
7739 msgstr ""
7741 #. type: Content of: <book><chapter><sect1><sect2><para>
7742 #: ../en/ch06-collab.xml:92
7743 msgid ""
7744 "I once put together a workflow model that seemed to make perfect sense to me, "
7745 "but that caused a considerable amount of consternation and strife within my "
7746 "development team. In spite of my attempts to explain why we needed a complex "
7747 "set of branches, and how changes ought to flow between them, a few team "
7748 "members revolted. Even though they were smart people, they didn't want to "
7749 "pay attention to the constraints we were operating under, or face the "
7750 "consequences of those constraints in the details of the model that I was "
7751 "advocating."
7752 msgstr ""
7754 #. type: Content of: <book><chapter><sect1><sect2><para>
7755 #: ../en/ch06-collab.xml:102
7756 msgid ""
7757 "Don't sweep foreseeable social or technical problems under the rug. Whatever "
7758 "scheme you put into effect, you should plan for mistakes and problem "
7759 "scenarios. Consider adding automated machinery to prevent, or quickly "
7760 "recover from, trouble that you can anticipate. As an example, if you intend "
7761 "to have a branch with not-for-release changes in it, you'd do well to think "
7762 "early about the possibility that someone might accidentally merge those "
7763 "changes into a release branch. You could avoid this particular problem by "
7764 "writing a hook that prevents changes from being merged from an inappropriate "
7765 "branch."
7766 msgstr ""
7768 #. type: Content of: <book><chapter><sect1><sect2><title>
7769 #: ../en/ch06-collab.xml:116
7770 msgid "Informal anarchy"
7771 msgstr "无政府状态"
7773 #. type: Content of: <book><chapter><sect1><sect2><para>
7774 #: ../en/ch06-collab.xml:118
7775 msgid ""
7776 "I wouldn't suggest an <quote>anything goes</quote> approach as something "
7777 "sustainable, but it's a model that's easy to grasp, and it works perfectly "
7778 "well in a few unusual situations."
7779 msgstr ""
7781 #. type: Content of: <book><chapter><sect1><sect2><para>
7782 #: ../en/ch06-collab.xml:123
7783 msgid ""
7784 "As one example, many projects have a loose-knit group of collaborators who "
7785 "rarely physically meet each other. Some groups like to overcome the "
7786 "isolation of working at a distance by organizing occasional <quote>sprints</"
7787 "quote>. In a sprint, a number of people get together in a single location (a "
7788 "company's conference room, a hotel meeting room, that kind of place) and "
7789 "spend several days more or less locked in there, hacking intensely on a "
7790 "handful of projects."
7791 msgstr ""
7793 #. type: Content of: <book><chapter><sect1><sect2><para>
7794 #: ../en/ch06-collab.xml:132
7795 msgid ""
7796 "A sprint or a hacking session in a coffee shop are the perfect places to use "
7797 "the <command role=\"hg-cmd\">hg serve</command> command, since <command role="
7798 "\"hg-cmd\">hg serve</command> does not require any fancy server "
7799 "infrastructure. You can get started with <command role=\"hg-cmd\">hg serve</"
7800 "command> in moments, by reading <xref linkend=\"sec:collab:serve\"/> below. "
7801 "Then simply tell the person next to you that you're running a server, send "
7802 "the URL to them in an instant message, and you immediately have a quick-"
7803 "turnaround way to work together. They can type your URL into their web "
7804 "browser and quickly review your changes; or they can pull a bugfix from you "
7805 "and verify it; or they can clone a branch containing a new feature and try it "
7806 "out."
7807 msgstr ""
7809 #. type: Content of: <book><chapter><sect1><sect2><para>
7810 #: ../en/ch06-collab.xml:146
7811 msgid ""
7812 "The charm, and the problem, with doing things in an ad hoc fashion like this "
7813 "is that only people who know about your changes, and where they are, can see "
7814 "them. Such an informal approach simply doesn't scale beyond a handful "
7815 "people, because each individual needs to know about <emphasis>n</emphasis> "
7816 "different repositories to pull from."
7817 msgstr ""
7819 #. type: Content of: <book><chapter><sect1><sect2><title>
7820 #: ../en/ch06-collab.xml:156
7821 msgid "A single central repository"
7822 msgstr "单一中央版本库"
7824 #. type: Content of: <book><chapter><sect1><sect2><para>
7825 #: ../en/ch06-collab.xml:158
7826 msgid ""
7827 "For smaller projects migrating from a centralised revision control tool, "
7828 "perhaps the easiest way to get started is to have changes flow through a "
7829 "single shared central repository. This is also the most common "
7830 "<quote>building block</quote> for more ambitious workflow schemes."
7831 msgstr ""
7833 #. type: Content of: <book><chapter><sect1><sect2><para>
7834 #: ../en/ch06-collab.xml:164
7835 msgid ""
7836 "Contributors start by cloning a copy of this repository. They can pull "
7837 "changes from it whenever they need to, and some (perhaps all) developers have "
7838 "permission to push a change back when they're ready for other people to see "
7839 "it."
7840 msgstr ""
7842 #. type: Content of: <book><chapter><sect1><sect2><para>
7843 #: ../en/ch06-collab.xml:169
7844 msgid ""
7845 "Under this model, it can still often make sense for people to pull changes "
7846 "directly from each other, without going through the central repository. "
7847 "Consider a case in which I have a tentative bug fix, but I am worried that if "
7848 "I were to publish it to the central repository, it might subsequently break "
7849 "everyone else's trees as they pull it. To reduce the potential for damage, I "
7850 "can ask you to clone my repository into a temporary repository of your own "
7851 "and test it. This lets us put off publishing the potentially unsafe change "
7852 "until it has had a little testing."
7853 msgstr ""
7855 #. type: Content of: <book><chapter><sect1><sect2><para>
7856 #: ../en/ch06-collab.xml:180
7857 msgid ""
7858 "If a team is hosting its own repository in this kind of scenario, people will "
7859 "usually use the <command>ssh</command> protocol to securely push changes to "
7860 "the central repository, as documented in <xref linkend=\"sec:collab:ssh\"/>. "
7861 "It's also usual to publish a read-only copy of the repository over HTTP, as "
7862 "in <xref linkend=\"sec:collab:cgi\"/>. Publishing over HTTP satisfies the "
7863 "needs of people who don't have push access, and those who want to use web "
7864 "browsers to browse the repository's history."
7865 msgstr ""
7867 #. type: Content of: <book><chapter><sect1><sect2><title>
7868 #: ../en/ch06-collab.xml:193
7869 msgid "A hosted central repository"
7870 msgstr "托管的中央版本库"
7872 #. type: Content of: <book><chapter><sect1><sect2><para>
7873 #: ../en/ch06-collab.xml:195
7874 msgid ""
7875 "A wonderful thing about public hosting services like <ulink url=\"http://"
7876 "bitbucket.org/\">Bitbucket</ulink> is that not only do they handle the fiddly "
7877 "server configuration details, such as user accounts, authentication, and "
7878 "secure wire protocols, they provide additional infrastructure to make this "
7879 "model work well."
7880 msgstr ""
7882 #. type: Content of: <book><chapter><sect1><sect2><para>
7883 #: ../en/ch06-collab.xml:202
7884 msgid ""
7885 "For instance, a well-engineered hosting service will let people clone their "
7886 "own copies of a repository with a single click. This lets people work in "
7887 "separate spaces and share their changes when they're ready."
7888 msgstr ""
7890 #. type: Content of: <book><chapter><sect1><sect2><para>
7891 #: ../en/ch06-collab.xml:207
7892 msgid ""
7893 "In addition, a good hosting service will let people communicate with each "
7894 "other, for instance to say <quote>there are changes ready for you to review "
7895 "in this tree</quote>."
7896 msgstr ""
7898 #. type: Content of: <book><chapter><sect1><sect2><title>
7899 #: ../en/ch06-collab.xml:214
7900 msgid "Working with multiple branches"
7901 msgstr "使用多个分支工作"
7903 #. type: Content of: <book><chapter><sect1><sect2><para>
7904 #: ../en/ch06-collab.xml:216
7905 msgid ""
7906 "Projects of any significant size naturally tend to make progress on several "
7907 "fronts simultaneously. In the case of software, it's common for a project to "
7908 "go through periodic official releases. A release might then go into "
7909 "<quote>maintenance mode</quote> for a while after its first publication; "
7910 "maintenance releases tend to contain only bug fixes, not new features. In "
7911 "parallel with these maintenance releases, one or more future releases may be "
7912 "under development. People normally use the word <quote>branch</quote> to "
7913 "refer to one of these many slightly different directions in which development "
7914 "is proceeding."
7915 msgstr ""
7917 #. type: Content of: <book><chapter><sect1><sect2><para>
7918 #: ../en/ch06-collab.xml:229
7919 msgid ""
7920 "Mercurial is particularly well suited to managing a number of simultaneous, "
7921 "but not identical, branches. Each <quote>development direction</quote> can "
7922 "live in its own central repository, and you can merge changes from one to "
7923 "another as the need arises. Because repositories are independent of each "
7924 "other, unstable changes in a development branch will never affect a stable "
7925 "branch unless someone explicitly merges those changes into the stable branch."
7926 msgstr ""
7928 #. type: Content of: <book><chapter><sect1><sect2><para>
7929 #: ../en/ch06-collab.xml:238
7930 msgid ""
7931 "Here's an example of how this can work in practice. Let's say you have one "
7932 "<quote>main branch</quote> on a central server."
7933 msgstr ""
7935 #. type: Content of: <book><chapter><sect1><sect2><para>
7936 #: ../en/ch06-collab.xml:244
7937 msgid "People clone it, make changes locally, test them, and push them back."
7938 msgstr ""
7940 #. type: Content of: <book><chapter><sect1><sect2><para>
7941 #: ../en/ch06-collab.xml:247
7942 msgid ""
7943 "Once the main branch reaches a release milestone, you can use the <command "
7944 "role=\"hg-cmd\">hg tag</command> command to give a permanent name to the "
7945 "milestone revision."
7946 msgstr ""
7948 #. type: Content of: <book><chapter><sect1><sect2><para>
7949 #: ../en/ch06-collab.xml:253
7950 msgid "Let's say some ongoing development occurs on the main branch."
7951 msgstr ""
7953 #. type: Content of: <book><chapter><sect1><sect2><para>
7954 #: ../en/ch06-collab.xml:258
7955 msgid ""
7956 "Using the tag that was recorded at the milestone, people who clone that "
7957 "repository at any time in the future can use <command role=\"hg-cmd\">hg "
7958 "update</command> to get a copy of the working directory exactly as it was "
7959 "when that tagged revision was committed."
7960 msgstr ""
7962 #. type: Content of: <book><chapter><sect1><sect2><para>
7963 #: ../en/ch06-collab.xml:266
7964 msgid ""
7965 "In addition, immediately after the main branch is tagged, we can then clone "
7966 "the main branch on the server to a new <quote>stable</quote> branch, also on "
7967 "the server."
7968 msgstr ""
7970 #. type: Content of: <book><chapter><sect1><sect2><para>
7971 #: ../en/ch06-collab.xml:272
7972 msgid ""
7973 "If we need to make a change to the stable branch, we can then clone "
7974 "<emphasis>that</emphasis> repository, make our changes, commit, and push our "
7975 "changes back there."
7976 msgstr ""
7978 #. type: Content of: <book><chapter><sect1><sect2><para>
7979 #: ../en/ch06-collab.xml:279
7980 msgid ""
7981 "Because Mercurial repositories are independent, and Mercurial doesn't move "
7982 "changes around automatically, the stable and main branches are "
7983 "<emphasis>isolated</emphasis> from each other. The changes that we made on "
7984 "the main branch don't <quote>leak</quote> to the stable branch, and vice "
7985 "versa."
7986 msgstr ""
7988 #. type: Content of: <book><chapter><sect1><sect2><para>
7989 #: ../en/ch06-collab.xml:286
7990 msgid ""
7991 "We'll often want all of our bugfixes on the stable branch to show up on the "
7992 "main branch, too. Rather than rewrite a bugfix on the main branch, we can "
7993 "simply pull and merge changes from the stable to the main branch, and "
7994 "Mercurial will bring those bugfixes in for us."
7995 msgstr ""
7997 #. type: Content of: <book><chapter><sect1><sect2><para>
7998 #: ../en/ch06-collab.xml:294
7999 msgid ""
8000 "The main branch will still contain changes that are not on the stable branch, "
8001 "but it will also contain all of the bugfixes from the stable branch. The "
8002 "stable branch remains unaffected by these changes, since changes are only "
8003 "flowing from the stable to the main branch, and not the other way."
8004 msgstr ""
8006 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
8007 #: ../en/ch06-collab.xml:303 ../en/ch06-collab.xml:313
8008 msgid "Feature branches"
8009 msgstr "特性分支"
8011 #. type: Content of: <book><chapter><sect1><sect2><para>
8012 #: ../en/ch06-collab.xml:305
8013 msgid ""
8014 "For larger projects, an effective way to manage change is to break up a team "
8015 "into smaller groups. Each group has a shared branch of its own, cloned from "
8016 "a single <quote>master</quote> branch used by the entire project. People "
8017 "working on an individual branch are typically quite isolated from "
8018 "developments on other branches."
8019 msgstr ""
8021 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
8022 #: ../en/ch06-collab.xml:315
8023 msgid ""
8024 "<imageobject><imagedata width=\"100%\" fileref=\"figs/feature-branches.png\"/"
8025 "></imageobject>"
8026 msgstr ""
8028 #. type: Content of: <book><chapter><sect1><sect2><para>
8029 #: ../en/ch06-collab.xml:320
8030 msgid ""
8031 "When a particular feature is deemed to be in suitable shape, someone on that "
8032 "feature team pulls and merges from the master branch into the feature branch, "
8033 "then pushes back up to the master branch."
8034 msgstr ""
8036 #. type: Content of: <book><chapter><sect1><sect2><title>
8037 #: ../en/ch06-collab.xml:327
8038 msgid "The release train"
8039 msgstr "发布列车"
8041 #. type: Content of: <book><chapter><sect1><sect2><para>
8042 #: ../en/ch06-collab.xml:329
8043 msgid ""
8044 "Some projects are organized on a <quote>train</quote> basis: a release is "
8045 "scheduled to happen every few months, and whatever features are ready when "
8046 "the <quote>train</quote> is ready to leave are allowed in."
8047 msgstr ""
8049 #. type: Content of: <book><chapter><sect1><sect2><para>
8050 #: ../en/ch06-collab.xml:334
8051 msgid ""
8052 "This model resembles working with feature branches. The difference is that "
8053 "when a feature branch misses a train, someone on the feature team pulls and "
8054 "merges the changes that went out on that train release into the feature "
8055 "branch, and the team continues its work on top of that release so that their "
8056 "feature can make the next release."
8057 msgstr ""
8059 #. type: Content of: <book><chapter><sect1><sect2><title>
8060 #: ../en/ch06-collab.xml:343
8061 msgid "The Linux kernel model"
8062 msgstr "Linux 内核模型"
8064 #. type: Content of: <book><chapter><sect1><sect2><para>
8065 #: ../en/ch06-collab.xml:345
8066 msgid ""
8067 "The development of the Linux kernel has a shallow hierarchical structure, "
8068 "surrounded by a cloud of apparent chaos. Because most Linux developers use "
8069 "<command>git</command>, a distributed revision control tool with capabilities "
8070 "similar to Mercurial, it's useful to describe the way work flows in that "
8071 "environment; if you like the ideas, the approach translates well across tools."
8072 msgstr ""
8074 #. type: Content of: <book><chapter><sect1><sect2><para>
8075 #: ../en/ch06-collab.xml:353
8076 msgid ""
8077 "At the center of the community sits Linus Torvalds, the creator of Linux. He "
8078 "publishes a single source repository that is considered the "
8079 "<quote>authoritative</quote> current tree by the entire developer community. "
8080 "Anyone can clone Linus's tree, but he is very choosy about whose trees he "
8081 "pulls from."
8082 msgstr ""
8084 #. type: Content of: <book><chapter><sect1><sect2><para>
8085 #: ../en/ch06-collab.xml:360
8086 msgid ""
8087 "Linus has a number of <quote>trusted lieutenants</quote>. As a general rule, "
8088 "he pulls whatever changes they publish, in most cases without even reviewing "
8089 "those changes. Some of those lieutenants are generally agreed to be "
8090 "<quote>maintainers</quote>, responsible for specific subsystems within the "
8091 "kernel. If a random kernel hacker wants to make a change to a subsystem that "
8092 "they want to end up in Linus's tree, they must find out who the subsystem's "
8093 "maintainer is, and ask that maintainer to take their change. If the "
8094 "maintainer reviews their changes and agrees to take them, they'll pass them "
8095 "along to Linus in due course."
8096 msgstr ""
8098 #. type: Content of: <book><chapter><sect1><sect2><para>
8099 #: ../en/ch06-collab.xml:372
8100 msgid ""
8101 "Individual lieutenants have their own approaches to reviewing, accepting, and "
8102 "publishing changes; and for deciding when to feed them to Linus. In "
8103 "addition, there are several well known branches that people use for different "
8104 "purposes. For example, a few people maintain <quote>stable</quote> "
8105 "repositories of older versions of the kernel, to which they apply critical "
8106 "fixes as needed. Some maintainers publish multiple trees: one for "
8107 "experimental changes; one for changes that they are about to feed upstream; "
8108 "and so on. Others just publish a single tree."
8109 msgstr ""
8111 #. type: Content of: <book><chapter><sect1><sect2><para>
8112 #: ../en/ch06-collab.xml:383
8113 msgid ""
8114 "This model has two notable features. The first is that it's <quote>pull "
8115 "only</quote>. You have to ask, convince, or beg another developer to take a "
8116 "change from you, because there are almost no trees to which more than one "
8117 "person can push, and there's no way to push changes into a tree that someone "
8118 "else controls."
8119 msgstr ""
8121 #. type: Content of: <book><chapter><sect1><sect2><para>
8122 #: ../en/ch06-collab.xml:390
8123 msgid ""
8124 "The second is that it's based on reputation and acclaim. If you're an "
8125 "unknown, Linus will probably ignore changes from you without even "
8126 "responding. But a subsystem maintainer will probably review them, and will "
8127 "likely take them if they pass their criteria for suitability. The more "
8128 "<quote>good</quote> changes you contribute to a maintainer, the more likely "
8129 "they are to trust your judgment and accept your changes. If you're well-"
8130 "known and maintain a long-lived branch for something Linus hasn't yet "
8131 "accepted, people with similar interests may pull your changes regularly to "
8132 "keep up with your work."
8133 msgstr ""
8135 #. type: Content of: <book><chapter><sect1><sect2><para>
8136 #: ../en/ch06-collab.xml:401
8137 msgid ""
8138 "Reputation and acclaim don't necessarily cross subsystem or <quote>people</"
8139 "quote> boundaries. If you're a respected but specialised storage hacker, and "
8140 "you try to fix a networking bug, that change will receive a level of scrutiny "
8141 "from a network maintainer comparable to a change from a complete stranger."
8142 msgstr ""
8144 #. type: Content of: <book><chapter><sect1><sect2><para>
8145 #: ../en/ch06-collab.xml:408
8146 msgid ""
8147 "To people who come from more orderly project backgrounds, the comparatively "
8148 "chaotic Linux kernel development process often seems completely insane. It's "
8149 "subject to the whims of individuals; people make sweeping changes whenever "
8150 "they deem it appropriate; and the pace of development is astounding. And yet "
8151 "Linux is a highly successful, well-regarded piece of software."
8152 msgstr ""
8154 #. type: Content of: <book><chapter><sect1><sect2><title>
8155 #: ../en/ch06-collab.xml:418
8156 msgid "Pull-only versus shared-push collaboration"
8157 msgstr "只读与共享写协作"
8159 #. type: Content of: <book><chapter><sect1><sect2><para>
8160 #: ../en/ch06-collab.xml:420
8161 msgid ""
8162 "A perpetual source of heat in the open source community is whether a "
8163 "development model in which people only ever pull changes from others is "
8164 "<quote>better than</quote> one in which multiple people can push changes to a "
8165 "shared repository."
8166 msgstr ""
8168 #. type: Content of: <book><chapter><sect1><sect2><para>
8169 #: ../en/ch06-collab.xml:426
8170 msgid ""
8171 "Typically, the backers of the shared-push model use tools that actively "
8172 "enforce this approach. If you're using a centralised revision control tool "
8173 "such as Subversion, there's no way to make a choice over which model you'll "
8174 "use: the tool gives you shared-push, and if you want to do anything else, "
8175 "you'll have to roll your own approach on top (such as applying a patch by "
8176 "hand)."
8177 msgstr ""
8179 #. type: Content of: <book><chapter><sect1><sect2><para>
8180 #: ../en/ch06-collab.xml:434
8181 msgid ""
8182 "A good distributed revision control tool will support both models. You and "
8183 "your collaborators can then structure how you work together based on your own "
8184 "needs and preferences, not on what contortions your tools force you into."
8185 msgstr ""
8187 #. type: Content of: <book><chapter><sect1><sect2><title>
8188 #: ../en/ch06-collab.xml:441
8189 msgid "Where collaboration meets branch management"
8190 msgstr "协作与分支管理"
8192 #. type: Content of: <book><chapter><sect1><sect2><para>
8193 #: ../en/ch06-collab.xml:443
8194 msgid ""
8195 "Once you and your team set up some shared repositories and start propagating "
8196 "changes back and forth between local and shared repos, you begin to face a "
8197 "related, but slightly different challenge: that of managing the multiple "
8198 "directions in which your team may be moving at once. Even though this "
8199 "subject is intimately related to how your team collaborates, it's dense "
8200 "enough to merit treatment of its own, in <xref linkend=\"chap:branch\"/>."
8201 msgstr ""
8203 #. type: Content of: <book><chapter><sect1><title>
8204 #: ../en/ch06-collab.xml:455
8205 msgid "The technical side of sharing"
8206 msgstr "共享的技术因素"
8208 #. type: Content of: <book><chapter><sect1><para>
8209 #: ../en/ch06-collab.xml:457
8210 msgid ""
8211 "The remainder of this chapter is devoted to the question of sharing changes "
8212 "with your collaborators."
8213 msgstr ""
8215 #. type: Content of: <book><chapter><sect1><title>
8216 #: ../en/ch06-collab.xml:462
8217 msgid "Informal sharing with <command role=\"hg-cmd\">hg serve</command>"
8218 msgstr "使用 <command role=\"hg-cmd\">hg serve</command> 进行非正式共享"
8220 #. type: Content of: <book><chapter><sect1><para>
8221 #: ../en/ch06-collab.xml:465
8222 msgid ""
8223 "Mercurial's <command role=\"hg-cmd\">hg serve</command> command is "
8224 "wonderfully suited to small, tight-knit, and fast-paced group environments. "
8225 "It also provides a great way to get a feel for using Mercurial commands over "
8226 "a network."
8227 msgstr ""
8229 #. type: Content of: <book><chapter><sect1><para>
8230 #: ../en/ch06-collab.xml:470
8231 msgid ""
8232 "Run <command role=\"hg-cmd\">hg serve</command> inside a repository, and in "
8233 "under a second it will bring up a specialised HTTP server; this will accept "
8234 "connections from any client, and serve up data for that repository until you "
8235 "terminate it. Anyone who knows the URL of the server you just started, and "
8236 "can talk to your computer over the network, can then use a web browser or "
8237 "Mercurial to read data from that repository. A URL for a <command role=\"hg-"
8238 "cmd\">hg serve</command> instance running on a laptop is likely to look "
8239 "something like <literal>http://my-laptop.local:8000/</literal>."
8240 msgstr ""
8242 #. type: Content of: <book><chapter><sect1><para>
8243 #: ../en/ch06-collab.xml:481
8244 msgid ""
8245 "The <command role=\"hg-cmd\">hg serve</command> command is <emphasis>not</"
8246 "emphasis> a general-purpose web server. It can do only two things:"
8247 msgstr ""
8249 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8250 #: ../en/ch06-collab.xml:485
8251 msgid ""
8252 "Allow people to browse the history of the repository it's serving, from their "
8253 "normal web browsers."
8254 msgstr ""
8256 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8257 #: ../en/ch06-collab.xml:489
8258 msgid ""
8259 "Speak Mercurial's wire protocol, so that people can <command role=\"hg-cmd"
8260 "\">hg clone</command> or <command role=\"hg-cmd\">hg pull</command> changes "
8261 "from that repository."
8262 msgstr ""
8264 #. type: Content of: <book><chapter><sect1><para>
8265 #: ../en/ch06-collab.xml:494
8266 msgid ""
8267 "In particular, <command role=\"hg-cmd\">hg serve</command> won't allow remote "
8268 "users to <emphasis>modify</emphasis> your repository. It's intended for read-"
8269 "only use."
8270 msgstr ""
8272 #. type: Content of: <book><chapter><sect1><para>
8273 #: ../en/ch06-collab.xml:498
8274 msgid ""
8275 "If you're getting started with Mercurial, there's nothing to prevent you from "
8276 "using <command role=\"hg-cmd\">hg serve</command> to serve up a repository on "
8277 "your own computer, then use commands like <command role=\"hg-cmd\">hg clone</"
8278 "command>, <command role=\"hg-cmd\">hg incoming</command>, and so on to talk "
8279 "to that server as if the repository was hosted remotely. This can help you to "
8280 "quickly get acquainted with using commands on network-hosted repositories."
8281 msgstr ""
8283 #. type: Content of: <book><chapter><sect1><sect2><title>
8284 #: ../en/ch06-collab.xml:508
8285 msgid "A few things to keep in mind"
8286 msgstr "要牢记的几件事"
8288 #. type: Content of: <book><chapter><sect1><sect2><para>
8289 #: ../en/ch06-collab.xml:510
8290 msgid ""
8291 "Because it provides unauthenticated read access to all clients, you should "
8292 "only use <command role=\"hg-cmd\">hg serve</command> in an environment where "
8293 "you either don't care, or have complete control over, who can access your "
8294 "network and pull data from your repository."
8295 msgstr ""
8297 #. type: Content of: <book><chapter><sect1><sect2><para>
8298 #: ../en/ch06-collab.xml:516
8299 msgid ""
8300 "The <command role=\"hg-cmd\">hg serve</command> command knows nothing about "
8301 "any firewall software you might have installed on your system or network. It "
8302 "cannot detect or control your firewall software. If other people are unable "
8303 "to talk to a running <command role=\"hg-cmd\">hg serve</command> instance, "
8304 "the second thing you should do (<emphasis>after</emphasis> you make sure that "
8305 "they're using the correct URL) is check your firewall configuration."
8306 msgstr ""
8308 #. type: Content of: <book><chapter><sect1><sect2><para>
8309 #: ../en/ch06-collab.xml:525
8310 msgid ""
8311 "By default, <command role=\"hg-cmd\">hg serve</command> listens for incoming "
8312 "connections on port 8000. If another process is already listening on the "
8313 "port you want to use, you can specify a different port to listen on using the "
8314 "<option role=\"hg-opt-serve\">-p</option> option."
8315 msgstr ""
8317 #. type: Content of: <book><chapter><sect1><sect2><para>
8318 #: ../en/ch06-collab.xml:531
8319 msgid ""
8320 "Normally, when <command role=\"hg-cmd\">hg serve</command> starts, it prints "
8321 "no output, which can be a bit unnerving. If you'd like to confirm that it is "
8322 "indeed running correctly, and find out what URL you should send to your "
8323 "collaborators, start it with the <option role=\"hg-opt-global\">-v</option> "
8324 "option."
8325 msgstr ""
8327 #. type: Content of: <book><chapter><sect1><title>
8328 #: ../en/ch06-collab.xml:541
8329 msgid "Using the Secure Shell (ssh) protocol"
8330 msgstr "使用 ssh 协议"
8332 #. type: Content of: <book><chapter><sect1><para>
8333 #: ../en/ch06-collab.xml:543
8334 msgid ""
8335 "You can pull and push changes securely over a network connection using the "
8336 "Secure Shell (<literal>ssh</literal>) protocol. To use this successfully, "
8337 "you may have to do a little bit of configuration on the client or server "
8338 "sides."
8339 msgstr ""
8341 #. type: Content of: <book><chapter><sect1><para>
8342 #: ../en/ch06-collab.xml:548
8343 msgid ""
8344 "If you're not familiar with ssh, it's the name of both a command and a "
8345 "network protocol that let you securely communicate with another computer. To "
8346 "use it with Mercurial, you'll be setting up one or more user accounts on a "
8347 "server so that remote users can log in and execute commands."
8348 msgstr ""
8350 #. type: Content of: <book><chapter><sect1><para>
8351 #: ../en/ch06-collab.xml:554
8352 msgid ""
8353 "(If you <emphasis>are</emphasis> familiar with ssh, you'll probably find some "
8354 "of the material that follows to be elementary in nature.)"
8355 msgstr ""
8357 #. type: Content of: <book><chapter><sect1><sect2><title>
8358 #: ../en/ch06-collab.xml:559
8359 msgid "How to read and write ssh URLs"
8360 msgstr "如何读写 ssh 路径"
8362 #. type: Content of: <book><chapter><sect1><sect2><para>
8363 #: ../en/ch06-collab.xml:561
8364 msgid "An ssh URL tends to look like this:"
8365 msgstr ""
8367 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
8368 #: ../en/ch06-collab.xml:564
8369 msgid ""
8370 "The <quote><literal>ssh://</literal></quote> part tells Mercurial to use the "
8371 "ssh protocol."
8372 msgstr ""
8374 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
8375 #: ../en/ch06-collab.xml:567
8376 msgid ""
8377 "The <quote><literal>bos@</literal></quote> component indicates what username "
8378 "to log into the server as. You can leave this out if the remote username is "
8379 "the same as your local username."
8380 msgstr ""
8382 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
8383 #: ../en/ch06-collab.xml:572
8384 msgid ""
8385 "The <quote><literal>hg.serpentine.com</literal></quote> gives the hostname of "
8386 "the server to log into."
8387 msgstr ""
8389 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
8390 #: ../en/ch06-collab.xml:576
8391 msgid ""
8392 "The <quote>:22</quote> identifies the port number to connect to the server "
8393 "on. The default port is 22, so you only need to specify a colon and port "
8394 "number if you're <emphasis>not</emphasis> using port 22."
8395 msgstr ""
8397 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
8398 #: ../en/ch06-collab.xml:581
8399 msgid ""
8400 "The remainder of the URL is the local path to the repository on the server."
8401 msgstr ""
8403 #. type: Content of: <book><chapter><sect1><sect2><para>
8404 #: ../en/ch06-collab.xml:585
8405 msgid ""
8406 "There's plenty of scope for confusion with the path component of ssh URLs, as "
8407 "there is no standard way for tools to interpret it. Some programs behave "
8408 "differently than others when dealing with these paths. This isn't an ideal "
8409 "situation, but it's unlikely to change. Please read the following paragraphs "
8410 "carefully."
8411 msgstr ""
8413 #. type: Content of: <book><chapter><sect1><sect2><para>
8414 #: ../en/ch06-collab.xml:592
8415 msgid ""
8416 "Mercurial treats the path to a repository on the server as relative to the "
8417 "remote user's home directory. For example, if user <literal>foo</literal> on "
8418 "the server has a home directory of <filename class=\"directory\">/home/foo</"
8419 "filename>, then an ssh URL that contains a path component of <filename class="
8420 "\"directory\">bar</filename> <emphasis>really</emphasis> refers to the "
8421 "directory <filename class=\"directory\">/home/foo/bar</filename>."
8422 msgstr ""
8424 #. type: Content of: <book><chapter><sect1><sect2><para>
8425 #: ../en/ch06-collab.xml:601
8426 msgid ""
8427 "If you want to specify a path relative to another user's home directory, you "
8428 "can use a path that starts with a tilde character followed by the user's name "
8429 "(let's call them <literal>otheruser</literal>), like this."
8430 msgstr ""
8432 #. type: Content of: <book><chapter><sect1><sect2><para>
8433 #: ../en/ch06-collab.xml:607
8434 msgid ""
8435 "And if you really want to specify an <emphasis>absolute</emphasis> path on "
8436 "the server, begin the path component with two slashes, as in this example."
8437 msgstr ""
8439 #. type: Content of: <book><chapter><sect1><sect2><title>
8440 #: ../en/ch06-collab.xml:614
8441 msgid "Finding an ssh client for your system"
8442 msgstr "为你的系统寻找 ssh 客户端"
8444 #. type: Content of: <book><chapter><sect1><sect2><para>
8445 #: ../en/ch06-collab.xml:616
8446 msgid ""
8447 "Almost every Unix-like system comes with OpenSSH preinstalled. If you're "
8448 "using such a system, run <literal>which ssh</literal> to find out if the "
8449 "<command>ssh</command> command is installed (it's usually in <filename class="
8450 "\"directory\">/usr/bin</filename>). In the unlikely event that it isn't "
8451 "present, take a look at your system documentation to figure out how to "
8452 "install it."
8453 msgstr ""
8455 #. type: Content of: <book><chapter><sect1><sect2><para>
8456 #: ../en/ch06-collab.xml:624
8457 msgid ""
8458 "On Windows, the TortoiseHg package is bundled with a version of Simon "
8459 "Tatham's excellent <command>plink</command> command, and you should not need "
8460 "to do any further configuration."
8461 msgstr ""
8463 #. type: Content of: <book><chapter><sect1><sect2><title>
8464 #: ../en/ch06-collab.xml:631
8465 msgid "Generating a key pair"
8466 msgstr "产生密钥对"
8468 #. type: Content of: <book><chapter><sect1><sect2><para>
8469 #: ../en/ch06-collab.xml:633
8470 msgid ""
8471 "To avoid the need to repetitively type a password every time you need to use "
8472 "your ssh client, I recommend generating a key pair."
8473 msgstr ""
8475 #. type: Content of: <book><chapter><sect1><sect2><tip><title>
8476 #: ../en/ch06-collab.xml:638
8477 msgid "Key pairs are not mandatory"
8478 msgstr ""
8480 #. type: Content of: <book><chapter><sect1><sect2><tip><para>
8481 #: ../en/ch06-collab.xml:640
8482 msgid ""
8483 "Mercurial knows nothing about ssh authentication or key pairs. You can, if "
8484 "you like, safely ignore this section and the one that follows until you grow "
8485 "tired of repeatedly typing ssh passwords."
8486 msgstr ""
8488 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8489 #: ../en/ch06-collab.xml:648
8490 msgid ""
8491 "On a Unix-like system, the <command>ssh-keygen</command> command will do the "
8492 "trick."
8493 msgstr ""
8495 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8496 #: ../en/ch06-collab.xml:651
8497 msgid ""
8498 "On Windows, if you're using TortoiseHg, you may need to download a command "
8499 "named <command>puttygen</command> from <ulink url=\"http://www.chiark."
8500 "greenend.org.uk/~sgtatham/putty\">the PuTTY web site</ulink> to generate a "
8501 "key pair. See <ulink url=\"http://the.earth.li/~sgtatham/putty/0.60/htmldoc/"
8502 "Chapter8.html#pubkey-puttygen\">the <command>puttygen</command> "
8503 "documentation</ulink> for details of how use the command."
8504 msgstr ""
8506 #. type: Content of: <book><chapter><sect1><sect2><para>
8507 #: ../en/ch06-collab.xml:663
8508 msgid ""
8509 "When you generate a key pair, it's usually <emphasis>highly</emphasis> "
8510 "advisable to protect it with a passphrase. (The only time that you might not "
8511 "want to do this is when you're using the ssh protocol for automated tasks on "
8512 "a secure network.)"
8513 msgstr ""
8515 #. type: Content of: <book><chapter><sect1><sect2><para>
8516 #: ../en/ch06-collab.xml:669
8517 msgid ""
8518 "Simply generating a key pair isn't enough, however. You'll need to add the "
8519 "public key to the set of authorised keys for whatever user you're logging in "
8520 "remotely as. For servers using OpenSSH (the vast majority), this will mean "
8521 "adding the public key to a list in a file called <filename role=\"special"
8522 "\">authorized_keys</filename> in their <filename role=\"special\" class="
8523 "\"directory\">.ssh</filename> directory."
8524 msgstr ""
8526 #. type: Content of: <book><chapter><sect1><sect2><para>
8527 #: ../en/ch06-collab.xml:678
8528 msgid ""
8529 "On a Unix-like system, your public key will have a <filename>.pub</filename> "
8530 "extension. If you're using <command>puttygen</command> on Windows, you can "
8531 "save the public key to a file of your choosing, or paste it from the window "
8532 "it's displayed in straight into the <filename role=\"special"
8533 "\">authorized_keys</filename> file."
8534 msgstr ""
8536 #. type: Content of: <book><chapter><sect1><sect2><title>
8537 #: ../en/ch06-collab.xml:686
8538 msgid "Using an authentication agent"
8539 msgstr "使用认证代理"
8541 #. type: Content of: <book><chapter><sect1><sect2><para>
8542 #: ../en/ch06-collab.xml:688
8543 msgid ""
8544 "An authentication agent is a daemon that stores passphrases in memory (so it "
8545 "will forget passphrases if you log out and log back in again). An ssh client "
8546 "will notice if it's running, and query it for a passphrase. If there's no "
8547 "authentication agent running, or the agent doesn't store the necessary "
8548 "passphrase, you'll have to type your passphrase every time Mercurial tries to "
8549 "communicate with a server on your behalf (e.g. whenever you pull or push "
8550 "changes)."
8551 msgstr ""
8553 #. type: Content of: <book><chapter><sect1><sect2><para>
8554 #: ../en/ch06-collab.xml:697
8555 msgid ""
8556 "The downside of storing passphrases in an agent is that it's possible for a "
8557 "well-prepared attacker to recover the plain text of your passphrases, in some "
8558 "cases even if your system has been power-cycled. You should make your own "
8559 "judgment as to whether this is an acceptable risk. It certainly saves a lot "
8560 "of repeated typing."
8561 msgstr ""
8563 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8564 #: ../en/ch06-collab.xml:706
8565 msgid ""
8566 "On Unix-like systems, the agent is called <command>ssh-agent</command>, and "
8567 "it's often run automatically for you when you log in. You'll need to use the "
8568 "<command>ssh-add</command> command to add passphrases to the agent's store."
8569 msgstr ""
8571 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8572 #: ../en/ch06-collab.xml:713
8573 msgid ""
8574 "On Windows, if you're using TortoiseHg, the <command>pageant</command> "
8575 "command acts as the agent. As with <command>puttygen</command>, you'll need "
8576 "to <ulink url=\"http://www.chiark.greenend.org.uk/%7Esgtatham/putty/download."
8577 "html\">download <command>pageant</command></ulink> from the PuTTY web site "
8578 "and read <ulink url=\"http://the.earth.li/~sgtatham/putty/0.60/htmldoc/"
8579 "Chapter9.html#pageant\">its documentation</ulink>. The <command>pageant</"
8580 "command> command adds an icon to your system tray that will let you manage "
8581 "stored passphrases."
8582 msgstr ""
8584 #. type: Content of: <book><chapter><sect1><sect2><title>
8585 #: ../en/ch06-collab.xml:728
8586 msgid "Configuring the server side properly"
8587 msgstr "正确配置服务器端"
8589 #. type: Content of: <book><chapter><sect1><sect2><para>
8590 #: ../en/ch06-collab.xml:730
8591 msgid ""
8592 "Because ssh can be fiddly to set up if you're new to it, a variety of things "
8593 "can go wrong. Add Mercurial on top, and there's plenty more scope for head-"
8594 "scratching. Most of these potential problems occur on the server side, not "
8595 "the client side. The good news is that once you've gotten a configuration "
8596 "working, it will usually continue to work indefinitely."
8597 msgstr ""
8599 #. type: Content of: <book><chapter><sect1><sect2><para>
8600 #: ../en/ch06-collab.xml:738
8601 msgid ""
8602 "Before you try using Mercurial to talk to an ssh server, it's best to make "
8603 "sure that you can use the normal <command>ssh</command> or <command>putty</"
8604 "command> command to talk to the server first. If you run into problems with "
8605 "using these commands directly, Mercurial surely won't work. Worse, it will "
8606 "obscure the underlying problem. Any time you want to debug ssh-related "
8607 "Mercurial problems, you should drop back to making sure that plain ssh client "
8608 "commands work first, <emphasis>before</emphasis> you worry about whether "
8609 "there's a problem with Mercurial."
8610 msgstr ""
8612 #. type: Content of: <book><chapter><sect1><sect2><para>
8613 #: ../en/ch06-collab.xml:749
8614 msgid ""
8615 "The first thing to be sure of on the server side is that you can actually log "
8616 "in from another machine at all. If you can't use <command>ssh</command> or "
8617 "<command>putty</command> to log in, the error message you get may give you a "
8618 "few hints as to what's wrong. The most common problems are as follows."
8619 msgstr ""
8621 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8622 #: ../en/ch06-collab.xml:756
8623 msgid ""
8624 "If you get a <quote>connection refused</quote> error, either there isn't an "
8625 "SSH daemon running on the server at all, or it's inaccessible due to firewall "
8626 "configuration."
8627 msgstr ""
8629 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8630 #: ../en/ch06-collab.xml:761
8631 msgid ""
8632 "If you get a <quote>no route to host</quote> error, you either have an "
8633 "incorrect address for the server or a seriously locked down firewall that "
8634 "won't admit its existence at all."
8635 msgstr ""
8637 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8638 #: ../en/ch06-collab.xml:766
8639 msgid ""
8640 "If you get a <quote>permission denied</quote> error, you may have mistyped "
8641 "the username on the server, or you could have mistyped your key's passphrase "
8642 "or the remote user's password."
8643 msgstr ""
8645 #. type: Content of: <book><chapter><sect1><sect2><para>
8646 #: ../en/ch06-collab.xml:771
8647 msgid ""
8648 "In summary, if you're having trouble talking to the server's ssh daemon, "
8649 "first make sure that one is running at all. On many systems it will be "
8650 "installed, but disabled, by default. Once you're done with this step, you "
8651 "should then check that the server's firewall is configured to allow incoming "
8652 "connections on the port the ssh daemon is listening on (usually 22). Don't "
8653 "worry about more exotic possibilities for misconfiguration until you've "
8654 "checked these two first."
8655 msgstr ""
8657 #. type: Content of: <book><chapter><sect1><sect2><para>
8658 #: ../en/ch06-collab.xml:781
8659 msgid ""
8660 "If you're using an authentication agent on the client side to store "
8661 "passphrases for your keys, you ought to be able to log into the server "
8662 "without being prompted for a passphrase or a password. If you're prompted "
8663 "for a passphrase, there are a few possible culprits."
8664 msgstr ""
8666 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8667 #: ../en/ch06-collab.xml:787
8668 msgid ""
8669 "You might have forgotten to use <command>ssh-add</command> or "
8670 "<command>pageant</command> to store the passphrase."
8671 msgstr ""
8673 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8674 #: ../en/ch06-collab.xml:791
8675 msgid "You might have stored the passphrase for the wrong key."
8676 msgstr ""
8678 #. type: Content of: <book><chapter><sect1><sect2><para>
8679 #: ../en/ch06-collab.xml:794
8680 msgid ""
8681 "If you're being prompted for the remote user's password, there are another "
8682 "few possible problems to check."
8683 msgstr ""
8685 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8686 #: ../en/ch06-collab.xml:797
8687 msgid ""
8688 "Either the user's home directory or their <filename role=\"special\" class="
8689 "\"directory\">.ssh</filename> directory might have excessively liberal "
8690 "permissions. As a result, the ssh daemon will not trust or read their "
8691 "<filename role=\"special\">authorized_keys</filename> file. For example, a "
8692 "group-writable home or <filename role=\"special\" class=\"directory\">.ssh</"
8693 "filename> directory will often cause this symptom."
8694 msgstr ""
8696 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8697 #: ../en/ch06-collab.xml:806
8698 msgid ""
8699 "The user's <filename role=\"special\">authorized_keys</filename> file may "
8700 "have a problem. If anyone other than the user owns or can write to that file, "
8701 "the ssh daemon will not trust or read it."
8702 msgstr ""
8704 #. type: Content of: <book><chapter><sect1><sect2><para>
8705 #: ../en/ch06-collab.xml:813
8706 msgid ""
8707 "In the ideal world, you should be able to run the following command "
8708 "successfully, and it should print exactly one line of output, the current "
8709 "date and time."
8710 msgstr ""
8712 #. type: Content of: <book><chapter><sect1><sect2><para>
8713 #: ../en/ch06-collab.xml:818
8714 msgid ""
8715 "If, on your server, you have login scripts that print banners or other junk "
8716 "even when running non-interactive commands like this, you should fix them "
8717 "before you continue, so that they only print output if they're run "
8718 "interactively. Otherwise these banners will at least clutter up Mercurial's "
8719 "output. Worse, they could potentially cause problems with running Mercurial "
8720 "commands remotely. Mercurial tries to detect and ignore banners in non-"
8721 "interactive <command>ssh</command> sessions, but it is not foolproof. (If "
8722 "you're editing your login scripts on your server, the usual way to see if a "
8723 "login script is running in an interactive shell is to check the return code "
8724 "from the command <literal>tty -s</literal>.)"
8725 msgstr ""
8727 #. type: Content of: <book><chapter><sect1><sect2><para>
8728 #: ../en/ch06-collab.xml:832
8729 msgid ""
8730 "Once you've verified that plain old ssh is working with your server, the next "
8731 "step is to ensure that Mercurial runs on the server. The following command "
8732 "should run successfully:"
8733 msgstr ""
8735 #. type: Content of: <book><chapter><sect1><sect2><para>
8736 #: ../en/ch06-collab.xml:839
8737 msgid ""
8738 "If you see an error message instead of normal <command role=\"hg-cmd\">hg "
8739 "version</command> output, this is usually because you haven't installed "
8740 "Mercurial to <filename class=\"directory\">/usr/bin</filename>. Don't worry "
8741 "if this is the case; you don't need to do that. But you should check for a "
8742 "few possible problems."
8743 msgstr ""
8745 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8746 #: ../en/ch06-collab.xml:846
8747 msgid ""
8748 "Is Mercurial really installed on the server at all? I know this sounds "
8749 "trivial, but it's worth checking!"
8750 msgstr ""
8752 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8753 #: ../en/ch06-collab.xml:850
8754 msgid ""
8755 "Maybe your shell's search path (usually set via the <envar>PATH</envar> "
8756 "environment variable) is simply misconfigured."
8757 msgstr ""
8759 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8760 #: ../en/ch06-collab.xml:854
8761 msgid ""
8762 "Perhaps your <envar>PATH</envar> environment variable is only being set to "
8763 "point to the location of the <command>hg</command> executable if the login "
8764 "session is interactive. This can happen if you're setting the path in the "
8765 "wrong shell login script. See your shell's documentation for details."
8766 msgstr ""
8768 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8769 #: ../en/ch06-collab.xml:861
8770 msgid ""
8771 "The <envar>PYTHONPATH</envar> environment variable may need to contain the "
8772 "path to the Mercurial Python modules. It might not be set at all; it could "
8773 "be incorrect; or it may be set only if the login is interactive."
8774 msgstr ""
8776 #. type: Content of: <book><chapter><sect1><sect2><para>
8777 #: ../en/ch06-collab.xml:868
8778 msgid ""
8779 "If you can run <command role=\"hg-cmd\">hg version</command> over an ssh "
8780 "connection, well done! You've got the server and client sorted out. You "
8781 "should now be able to use Mercurial to access repositories hosted by that "
8782 "username on that server. If you run into problems with Mercurial and ssh at "
8783 "this point, try using the <option role=\"hg-opt-global\">--debug</option> "
8784 "option to get a clearer picture of what's going on."
8785 msgstr ""
8787 #. type: Content of: <book><chapter><sect1><sect2><title>
8788 #: ../en/ch06-collab.xml:877
8789 msgid "Using compression with ssh"
8790 msgstr "通过 ssh 使用压缩"
8792 #. type: Content of: <book><chapter><sect1><sect2><para>
8793 #: ../en/ch06-collab.xml:879
8794 msgid ""
8795 "Mercurial does not compress data when it uses the ssh protocol, because the "
8796 "ssh protocol can transparently compress data. However, the default behavior "
8797 "of ssh clients is <emphasis>not</emphasis> to request compression."
8798 msgstr ""
8800 #. type: Content of: <book><chapter><sect1><sect2><para>
8801 #: ../en/ch06-collab.xml:884
8802 msgid ""
8803 "Over any network other than a fast LAN (even a wireless network), using "
8804 "compression is likely to significantly speed up Mercurial's network "
8805 "operations. For example, over a WAN, someone measured compression as "
8806 "reducing the amount of time required to clone a particularly large repository "
8807 "from 51 minutes to 17 minutes."
8808 msgstr ""
8810 #. type: Content of: <book><chapter><sect1><sect2><para>
8811 #: ../en/ch06-collab.xml:891
8812 msgid ""
8813 "Both <command>ssh</command> and <command>plink</command> accept a <option "
8814 "role=\"cmd-opt-ssh\">-C</option> option which turns on compression. You can "
8815 "easily edit your <filename role=\"special\">~/.hgrc</filename> to enable "
8816 "compression for all of Mercurial's uses of the ssh protocol. Here is how to "
8817 "do so for regular <command>ssh</command> on Unix-like systems, for example."
8818 msgstr ""
8820 #. type: Content of: <book><chapter><sect1><sect2><para>
8821 #: ../en/ch06-collab.xml:901
8822 msgid ""
8823 "If you use <command>ssh</command> on a Unix-like system, you can configure it "
8824 "to always use compression when talking to your server. To do this, edit your "
8825 "<filename role=\"special\">.ssh/config</filename> file (which may not yet "
8826 "exist), as follows."
8827 msgstr ""
8829 #. type: Content of: <book><chapter><sect1><sect2><para>
8830 #: ../en/ch06-collab.xml:911
8831 msgid ""
8832 "This defines a hostname alias, <literal>hg</literal>. When you use that "
8833 "hostname on the <command>ssh</command> command line or in a Mercurial "
8834 "<literal>ssh</literal>-protocol URL, it will cause <command>ssh</command> to "
8835 "connect to <literal>hg.example.com</literal> and use compression. This gives "
8836 "you both a shorter name to type and compression, each of which is a good "
8837 "thing in its own right."
8838 msgstr ""
8840 #. type: Content of: <book><chapter><sect1><title>
8841 #: ../en/ch06-collab.xml:923
8842 msgid "Serving over HTTP using CGI"
8843 msgstr "使用 CGI 通过 HTTP 提供服务"
8845 #. type: Content of: <book><chapter><sect1><para>
8846 #: ../en/ch06-collab.xml:925
8847 msgid ""
8848 "The simplest way to host one or more repositories in a permanent way is to "
8849 "use a web server and Mercurial's CGI support."
8850 msgstr ""
8852 #. type: Content of: <book><chapter><sect1><para>
8853 #: ../en/ch06-collab.xml:929
8854 msgid ""
8855 "Depending on how ambitious you are, configuring Mercurial's CGI interface can "
8856 "take anything from a few moments to several hours."
8857 msgstr ""
8859 #. type: Content of: <book><chapter><sect1><para>
8860 #: ../en/ch06-collab.xml:933
8861 msgid ""
8862 "We'll begin with the simplest of examples, and work our way towards a more "
8863 "complex configuration. Even for the most basic case, you're almost certainly "
8864 "going to need to read and modify your web server's configuration."
8865 msgstr ""
8867 #. type: Content of: <book><chapter><sect1><note><title>
8868 #: ../en/ch06-collab.xml:939
8869 msgid "High pain tolerance required"
8870 msgstr ""
8872 #. type: Content of: <book><chapter><sect1><note><para>
8873 #: ../en/ch06-collab.xml:941
8874 msgid ""
8875 "Configuring a web server is a complex, fiddly, and highly system-dependent "
8876 "activity. I can't possibly give you instructions that will cover anything "
8877 "like all of the cases you will encounter. Please use your discretion and "
8878 "judgment in following the sections below. Be prepared to make plenty of "
8879 "mistakes, and to spend a lot of time reading your server's error logs."
8880 msgstr ""
8882 #. type: Content of: <book><chapter><sect1><note><para>
8883 #: ../en/ch06-collab.xml:949
8884 msgid ""
8885 "If you don't have a strong stomach for tweaking configurations over and over, "
8886 "or a compelling need to host your own services, you might want to try one of "
8887 "the public hosting services that I mentioned earlier."
8888 msgstr ""
8890 #. type: Content of: <book><chapter><sect1><sect2><title>
8891 #: ../en/ch06-collab.xml:956
8892 msgid "Web server configuration checklist"
8893 msgstr "Web 服务器配置检查表"
8895 #. type: Content of: <book><chapter><sect1><sect2><para>
8896 #: ../en/ch06-collab.xml:958
8897 msgid ""
8898 "Before you continue, do take a few moments to check a few aspects of your "
8899 "system's setup."
8900 msgstr ""
8902 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
8903 #: ../en/ch06-collab.xml:962
8904 msgid ""
8905 "Do you have a web server installed at all? Mac OS X and some Linux "
8906 "distributions ship with Apache, but many other systems may not have a web "
8907 "server installed."
8908 msgstr ""
8910 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
8911 #: ../en/ch06-collab.xml:967
8912 msgid ""
8913 "If you have a web server installed, is it actually running? On most systems, "
8914 "even if one is present, it will be disabled by default."
8915 msgstr ""
8917 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
8918 #: ../en/ch06-collab.xml:971
8919 msgid ""
8920 "Is your server configured to allow you to run CGI programs in the directory "
8921 "where you plan to do so? Most servers default to explicitly disabling the "
8922 "ability to run CGI programs."
8923 msgstr ""
8925 #. type: Content of: <book><chapter><sect1><sect2><para>
8926 #: ../en/ch06-collab.xml:977
8927 msgid ""
8928 "If you don't have a web server installed, and don't have substantial "
8929 "experience configuring Apache, you should consider using the "
8930 "<literal>lighttpd</literal> web server instead of Apache. Apache has a well-"
8931 "deserved reputation for baroque and confusing configuration. While "
8932 "<literal>lighttpd</literal> is less capable in some ways than Apache, most of "
8933 "these capabilities are not relevant to serving Mercurial repositories. And "
8934 "<literal>lighttpd</literal> is undeniably <emphasis>much</emphasis> easier to "
8935 "get started with than Apache."
8936 msgstr ""
8938 #. type: Content of: <book><chapter><sect1><sect2><title>
8939 #: ../en/ch06-collab.xml:990
8940 msgid "Basic CGI configuration"
8941 msgstr "基本 CGI 配置"
8943 #. type: Content of: <book><chapter><sect1><sect2><para>
8944 #: ../en/ch06-collab.xml:992
8945 msgid ""
8946 "On Unix-like systems, it's common for users to have a subdirectory named "
8947 "something like <filename class=\"directory\">public_html</filename> in their "
8948 "home directory, from which they can serve up web pages. A file named "
8949 "<filename>foo</filename> in this directory will be accessible at a URL of the "
8950 "form <literal>http://www.example.com/username/foo</literal>."
8951 msgstr ""
8953 #. type: Content of: <book><chapter><sect1><sect2><para>
8954 #: ../en/ch06-collab.xml:1000
8955 msgid ""
8956 "To get started, find the <filename role=\"special\">hgweb.cgi</filename> "
8957 "script that should be present in your Mercurial installation. If you can't "
8958 "quickly find a local copy on your system, simply download one from the master "
8959 "Mercurial repository at <ulink url=\"http://www.selenic.com/repo/hg/raw-file/"
8960 "tip/hgweb.cgi\">http://www.selenic.com/repo/hg/raw-file/tip/hgweb.cgi</ulink>."
8961 msgstr ""
8963 #. type: Content of: <book><chapter><sect1><sect2><para>
8964 #: ../en/ch06-collab.xml:1007 ../en/ch06-collab.xml:1175
8965 msgid ""
8966 "You'll need to copy this script into your <filename class=\"directory"
8967 "\">public_html</filename> directory, and ensure that it's executable."
8968 msgstr ""
8970 #. type: Content of: <book><chapter><sect1><sect2><para>
8971 #: ../en/ch06-collab.xml:1012
8972 msgid ""
8973 "The <literal>755</literal> argument to <command>chmod</command> is a little "
8974 "more general than just making the script executable: it ensures that the "
8975 "script is executable by anyone, and that <quote>group</quote> and "
8976 "<quote>other</quote> write permissions are <emphasis>not</emphasis> set. If "
8977 "you were to leave those write permissions enabled, Apache's <literal>suexec</"
8978 "literal> subsystem would likely refuse to execute the script. In fact, "
8979 "<literal>suexec</literal> also insists that the <emphasis>directory</"
8980 "emphasis> in which the script resides must not be writable by others."
8981 msgstr ""
8983 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
8984 #: ../en/ch06-collab.xml:1026
8985 msgid "What could <emphasis>possibly</emphasis> go wrong?"
8986 msgstr "什么<emphasis>可能</emphasis>会出错?"
8988 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
8989 #: ../en/ch06-collab.xml:1029
8990 msgid ""
8991 "Once you've copied the CGI script into place, go into a web browser, and try "
8992 "to open the URL <literal>http://myhostname/~myuser/hgweb.cgi</literal>, "
8993 "<emphasis>but</emphasis> brace yourself for instant failure. There's a high "
8994 "probability that trying to visit this URL will fail, and there are many "
8995 "possible reasons for this. In fact, you're likely to stumble over almost "
8996 "every one of the possible errors below, so please read carefully. The "
8997 "following are all of the problems I ran into on a system running Fedora 7, "
8998 "with a fresh installation of Apache, and a user account that I created "
8999 "specially to perform this exercise."
9000 msgstr ""
9002 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9003 #: ../en/ch06-collab.xml:1042
9004 msgid ""
9005 "Your web server may have per-user directories disabled. If you're using "
9006 "Apache, search your config file for a <literal>UserDir</literal> directive. "
9007 "If there's none present, per-user directories will be disabled. If one "
9008 "exists, but its value is <literal>disabled</literal>, then per-user "
9009 "directories will be disabled. Otherwise, the string after <literal>UserDir</"
9010 "literal> gives the name of the subdirectory that Apache will look in under "
9011 "your home directory, for example <filename class=\"directory\">public_html</"
9012 "filename>."
9013 msgstr ""
9015 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9016 #: ../en/ch06-collab.xml:1053
9017 msgid ""
9018 "Your file access permissions may be too restrictive. The web server must be "
9019 "able to traverse your home directory and directories under your <filename "
9020 "class=\"directory\">public_html</filename> directory, and read files under "
9021 "the latter too. Here's a quick recipe to help you to make your permissions "
9022 "more appropriate."
9023 msgstr ""
9025 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9026 #: ../en/ch06-collab.xml:1063
9027 msgid ""
9028 "The other possibility with permissions is that you might get a completely "
9029 "empty window when you try to load the script. In this case, it's likely that "
9030 "your access permissions are <emphasis>too permissive</emphasis>. Apache's "
9031 "<literal>suexec</literal> subsystem won't execute a script that's group- or "
9032 "world-writable, for example."
9033 msgstr ""
9035 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9036 #: ../en/ch06-collab.xml:1070
9037 msgid ""
9038 "Your web server may be configured to disallow execution of CGI programs in "
9039 "your per-user web directory. Here's Apache's default per-user configuration "
9040 "from my Fedora system."
9041 msgstr ""
9043 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9044 #: ../en/ch06-collab.xml:1077
9045 msgid ""
9046 "If you find a similar-looking <literal>Directory</literal> group in your "
9047 "Apache configuration, the directive to look at inside it is <literal>Options</"
9048 "literal>. Add <literal>ExecCGI</literal> to the end of this list if it's "
9049 "missing, and restart the web server."
9050 msgstr ""
9052 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9053 #: ../en/ch06-collab.xml:1084
9054 msgid ""
9055 "If you find that Apache serves you the text of the CGI script instead of "
9056 "executing it, you may need to either uncomment (if already present) or add a "
9057 "directive like this."
9058 msgstr ""
9060 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9061 #: ../en/ch06-collab.xml:1090
9062 msgid ""
9063 "The next possibility is that you might be served with a colourful Python "
9064 "backtrace claiming that it can't import a <literal>mercurial</literal>-"
9065 "related module. This is actually progress! The server is now capable of "
9066 "executing your CGI script. This error is only likely to occur if you're "
9067 "running a private installation of Mercurial, instead of a system-wide "
9068 "version. Remember that the web server runs the CGI program without any of "
9069 "the environment variables that you take for granted in an interactive "
9070 "session. If this error happens to you, edit your copy of <filename role="
9071 "\"special\">hgweb.cgi</filename> and follow the directions inside it to "
9072 "correctly set your <envar>PYTHONPATH</envar> environment variable."
9073 msgstr ""
9075 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9076 #: ../en/ch06-collab.xml:1104
9077 msgid ""
9078 "Finally, you are <emphasis>certain</emphasis> to be served with another "
9079 "colourful Python backtrace: this one will complain that it can't find "
9080 "<filename class=\"directory\">/path/to/repository</filename>. Edit your "
9081 "<filename role=\"special\">hgweb.cgi</filename> script and replace the "
9082 "<filename class=\"directory\">/path/to/repository</filename> string with the "
9083 "complete path to the repository you want to serve up."
9084 msgstr ""
9086 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9087 #: ../en/ch06-collab.xml:1114
9088 msgid ""
9089 "At this point, when you try to reload the page, you should be presented with "
9090 "a nice HTML view of your repository's history. Whew!"
9091 msgstr ""
9093 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
9094 #: ../en/ch06-collab.xml:1120
9095 msgid "Configuring lighttpd"
9096 msgstr "配置 lighttpd"
9098 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9099 #: ../en/ch06-collab.xml:1122
9100 msgid ""
9101 "To be exhaustive in my experiments, I tried configuring the increasingly "
9102 "popular <literal>lighttpd</literal> web server to serve the same repository "
9103 "as I described with Apache above. I had already overcome all of the problems "
9104 "I outlined with Apache, many of which are not server-specific. As a result, "
9105 "I was fairly sure that my file and directory permissions were good, and that "
9106 "my <filename role=\"special\">hgweb.cgi</filename> script was properly edited."
9107 msgstr ""
9109 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9110 #: ../en/ch06-collab.xml:1132
9111 msgid ""
9112 "Once I had Apache running, getting <literal>lighttpd</literal> to serve the "
9113 "repository was a snap (in other words, even if you're trying to use "
9114 "<literal>lighttpd</literal>, you should read the Apache section). I first "
9115 "had to edit the <literal>mod_access</literal> section of its config file to "
9116 "enable <literal>mod_cgi</literal> and <literal>mod_userdir</literal>, both of "
9117 "which were disabled by default on my system. I then added a few lines to the "
9118 "end of the config file, to configure these modules."
9119 msgstr ""
9121 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9122 #: ../en/ch06-collab.xml:1144
9123 msgid ""
9124 "With this done, <literal>lighttpd</literal> ran immediately for me. If I had "
9125 "configured <literal>lighttpd</literal> before Apache, I'd almost certainly "
9126 "have run into many of the same system-level configuration problems as I did "
9127 "with Apache. However, I found <literal>lighttpd</literal> to be noticeably "
9128 "easier to configure than Apache, even though I've used Apache for over a "
9129 "decade, and this was my first exposure to <literal>lighttpd</literal>."
9130 msgstr ""
9132 #. type: Content of: <book><chapter><sect1><sect2><title>
9133 #: ../en/ch06-collab.xml:1157
9134 msgid "Sharing multiple repositories with one CGI script"
9135 msgstr "使用一个 CGI 脚本共享多个版本库"
9137 #. type: Content of: <book><chapter><sect1><sect2><para>
9138 #: ../en/ch06-collab.xml:1159
9139 msgid ""
9140 "The <filename role=\"special\">hgweb.cgi</filename> script only lets you "
9141 "publish a single repository, which is an annoying restriction. If you want "
9142 "to publish more than one without wracking yourself with multiple copies of "
9143 "the same script, each with different names, a better choice is to use the "
9144 "<filename role=\"special\">hgwebdir.cgi</filename> script."
9145 msgstr ""
9147 #. type: Content of: <book><chapter><sect1><sect2><para>
9148 #: ../en/ch06-collab.xml:1167
9149 msgid ""
9150 "The procedure to configure <filename role=\"special\">hgwebdir.cgi</filename> "
9151 "is only a little more involved than for <filename role=\"special\">hgweb.cgi</"
9152 "filename>. First, you must obtain a copy of the script. If you don't have "
9153 "one handy, you can download a copy from the master Mercurial repository at "
9154 "<ulink url=\"http://www.selenic.com/repo/hg/raw-file/tip/hgwebdir.cgi"
9155 "\">http://www.selenic.com/repo/hg/raw-file/tip/hgwebdir.cgi</ulink>."
9156 msgstr ""
9158 #. type: Content of: <book><chapter><sect1><sect2><para>
9159 #: ../en/ch06-collab.xml:1182
9160 msgid ""
9161 "With basic configuration out of the way, try to visit <literal>http://"
9162 "myhostname/~myuser/hgwebdir.cgi</literal> in your\tbrowser. It should "
9163 "display an empty list of repositories. If you get a blank window or error "
9164 "message, try walking through the list of potential problems in <xref linkend="
9165 "\"sec:collab:wtf\"/>."
9166 msgstr ""
9168 #. type: Content of: <book><chapter><sect1><sect2><para>
9169 #: ../en/ch06-collab.xml:1190
9170 msgid ""
9171 "The <filename role=\"special\">hgwebdir.cgi</filename> script relies on an "
9172 "external configuration file. By default, it searches for a file named "
9173 "<filename role=\"special\">hgweb.config</filename> in the same directory as "
9174 "itself. You'll need to create this file, and make it world-readable. The "
9175 "format of the file is similar to a Windows <quote>ini</quote> file, as "
9176 "understood by Python's <literal>ConfigParser</literal> <citation>web:"
9177 "configparser</citation> module."
9178 msgstr ""
9180 #. type: Content of: <book><chapter><sect1><sect2><para>
9181 #: ../en/ch06-collab.xml:1200
9182 msgid ""
9183 "The easiest way to configure <filename role=\"special\">hgwebdir.cgi</"
9184 "filename> is with a section named <literal>collections</literal>. This will "
9185 "automatically publish <emphasis>every</emphasis> repository under the "
9186 "directories you name. The section should look like this:"
9187 msgstr ""
9189 #. type: Content of: <book><chapter><sect1><sect2><para>
9190 #: ../en/ch06-collab.xml:1208
9191 msgid ""
9192 "Mercurial interprets this by looking at the directory name on the "
9193 "<emphasis>right</emphasis> hand side of the <quote><literal>=</literal></"
9194 "quote> sign; finding repositories in that directory hierarchy; and using the "
9195 "text on the <emphasis>left</emphasis> to strip off matching text from the "
9196 "names it will actually list in the web interface. The remaining component of "
9197 "a path after this stripping has occurred is called a <quote>virtual path</"
9198 "quote>."
9199 msgstr ""
9201 #. type: Content of: <book><chapter><sect1><sect2><para>
9202 #: ../en/ch06-collab.xml:1217
9203 msgid ""
9204 "Given the example above, if we have a repository whose local path is "
9205 "<filename class=\"directory\">/my/root/this/repo</filename>, the CGI script "
9206 "will strip the leading <filename class=\"directory\">/my/root</filename> from "
9207 "the name, and publish the repository with a virtual path of <filename class="
9208 "\"directory\">this/repo</filename>. If the base URL for our CGI script is "
9209 "<literal>http://myhostname/~myuser/hgwebdir.cgi</literal>, the complete URL "
9210 "for that repository will be <literal>http://myhostname/~myuser/hgwebdir.cgi/"
9211 "this/repo</literal>."
9212 msgstr ""
9214 #. type: Content of: <book><chapter><sect1><sect2><para>
9215 #: ../en/ch06-collab.xml:1229
9216 msgid ""
9217 "If we replace <filename class=\"directory\">/my/root</filename> on the left "
9218 "hand side of this example with <filename class=\"directory\">/my</filename>, "
9219 "then <filename role=\"special\">hgwebdir.cgi</filename> will only strip off "
9220 "<filename class=\"directory\">/my</filename> from the repository name, and "
9221 "will give us a virtual path of <filename class=\"directory\">root/this/repo</"
9222 "filename> instead of <filename class=\"directory\">this/repo</filename>."
9223 msgstr ""
9225 #. type: Content of: <book><chapter><sect1><sect2><para>
9226 #: ../en/ch06-collab.xml:1239
9227 msgid ""
9228 "The <filename role=\"special\">hgwebdir.cgi</filename> script will "
9229 "recursively search each directory listed in the <literal>collections</"
9230 "literal> section of its configuration file, but it will <literal>not</"
9231 "literal> recurse into the repositories it finds."
9232 msgstr ""
9234 #. type: Content of: <book><chapter><sect1><sect2><para>
9235 #: ../en/ch06-collab.xml:1245
9236 msgid ""
9237 "The <literal>collections</literal> mechanism makes it easy to publish many "
9238 "repositories in a <quote>fire and forget</quote> manner. You only need to "
9239 "set up the CGI script and configuration file one time. Afterwards, you can "
9240 "publish or unpublish a repository at any time by simply moving it into, or "
9241 "out of, the directory hierarchy in which you've configured <filename role="
9242 "\"special\">hgwebdir.cgi</filename> to look."
9243 msgstr ""
9245 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
9246 #: ../en/ch06-collab.xml:1255
9247 msgid "Explicitly specifying which repositories to publish"
9248 msgstr "明确指出要发布的版本库"
9250 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9251 #: ../en/ch06-collab.xml:1258
9252 msgid ""
9253 "In addition to the <literal>collections</literal> mechanism, the <filename "
9254 "role=\"special\">hgwebdir.cgi</filename> script allows you to publish a "
9255 "specific list of repositories. To do so, create a <literal>paths</literal> "
9256 "section, with contents of the following form."
9257 msgstr ""
9259 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9260 #: ../en/ch06-collab.xml:1267
9261 msgid ""
9262 "In this case, the virtual path (the component that will appear in a URL) is "
9263 "on the left hand side of each definition, while the path to the repository is "
9264 "on the right. Notice that there does not need to be any relationship between "
9265 "the virtual path you choose and the location of a repository in your "
9266 "filesystem."
9267 msgstr ""
9269 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9270 #: ../en/ch06-collab.xml:1274
9271 msgid ""
9272 "If you wish, you can use both the <literal>collections</literal> and "
9273 "<literal>paths</literal> mechanisms simultaneously in a single configuration "
9274 "file."
9275 msgstr ""
9277 #. type: Content of: <book><chapter><sect1><sect2><sect3><note><title>
9278 #: ../en/ch06-collab.xml:1280
9279 msgid "Beware duplicate virtual paths"
9280 msgstr ""
9282 #. type: Content of: <book><chapter><sect1><sect2><sect3><note><para>
9283 #: ../en/ch06-collab.xml:1282
9284 msgid ""
9285 "If several repositories have the same virtual path, <filename role=\"special"
9286 "\">hgwebdir.cgi</filename> will not report an error. Instead, it will behave "
9287 "unpredictably."
9288 msgstr ""
9290 #. type: Content of: <book><chapter><sect1><sect2><title>
9291 #: ../en/ch06-collab.xml:1291
9292 msgid "Downloading source archives"
9293 msgstr "下载源代码档案包"
9295 #. type: Content of: <book><chapter><sect1><sect2><para>
9296 #: ../en/ch06-collab.xml:1293
9297 msgid ""
9298 "Mercurial's web interface lets users download an archive of any revision. "
9299 "This archive will contain a snapshot of the working directory as of that "
9300 "revision, but it will not contain a copy of the repository data."
9301 msgstr ""
9303 #. type: Content of: <book><chapter><sect1><sect2><para>
9304 #: ../en/ch06-collab.xml:1298
9305 msgid ""
9306 "By default, this feature is not enabled. To enable it, you'll need to add an "
9307 "<envar role=\"rc-item-web\">allow_archive</envar> item to the <literal role="
9308 "\"rc-web\">web</literal> section of your <filename role=\"special\">~/.hgrc</"
9309 "filename>; see below for details."
9310 msgstr ""
9312 #. type: Content of: <book><chapter><sect1><sect2><title>
9313 #: ../en/ch06-collab.xml:1305
9314 msgid "Web configuration options"
9315 msgstr "Web 配置选项"
9317 #. type: Content of: <book><chapter><sect1><sect2><para>
9318 #: ../en/ch06-collab.xml:1307
9319 msgid ""
9320 "Mercurial's web interfaces (the <command role=\"hg-cmd\">hg serve</command> "
9321 "command, and the <filename role=\"special\">hgweb.cgi</filename> and "
9322 "<filename role=\"special\">hgwebdir.cgi</filename> scripts) have a number of "
9323 "configuration options that you can set. These belong in a section named "
9324 "<literal role=\"rc-web\">web</literal>."
9325 msgstr ""
9327 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9328 #: ../en/ch06-collab.xml:1315
9329 msgid ""
9330 "<envar role=\"rc-item-web\">allow_archive</envar>: Determines which (if any) "
9331 "archive download mechanisms Mercurial supports. If you enable this feature, "
9332 "users of the web interface will be able to download an archive of whatever "
9333 "revision of a repository they are viewing. To enable the archive feature, "
9334 "this item must take the form of a sequence of words drawn from the list below."
9335 msgstr ""
9337 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
9338 #: ../en/ch06-collab.xml:1324
9339 msgid ""
9340 "<literal>bz2</literal>: A <command>tar</command> archive, compressed using "
9341 "<literal>bzip2</literal> compression. This has the best compression ratio, "
9342 "but uses the most CPU time on the server."
9343 msgstr ""
9345 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
9346 #: ../en/ch06-collab.xml:1330
9347 msgid ""
9348 "<literal>gz</literal>: A <command>tar</command> archive, compressed using "
9349 "<literal>gzip</literal> compression."
9350 msgstr ""
9352 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
9353 #: ../en/ch06-collab.xml:1334
9354 msgid ""
9355 "<literal>zip</literal>: A <command>zip</command> archive, compressed using "
9356 "LZW compression. This format has the worst compression ratio, but is widely "
9357 "used in the Windows world."
9358 msgstr ""
9360 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9361 #: ../en/ch06-collab.xml:1340
9362 msgid ""
9363 "If you provide an empty list, or don't have an <envar role=\"rc-item-web"
9364 "\">allow_archive</envar> entry at all, this feature will be disabled. Here "
9365 "is an example of how to enable all three supported formats."
9366 msgstr ""
9368 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9369 #: ../en/ch06-collab.xml:1347
9370 msgid ""
9371 "<envar role=\"rc-item-web\">allowpull</envar>: Boolean. Determines whether "
9372 "the web interface allows remote users to <command role=\"hg-cmd\">hg pull</"
9373 "command> and <command role=\"hg-cmd\">hg clone</command> this repository over "
9374 "HTTP. If set to <literal>no</literal> or <literal>false</literal>, only the "
9375 "<quote>human-oriented</quote> portion of the web interface is available."
9376 msgstr ""
9378 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9379 #: ../en/ch06-collab.xml:1356
9380 msgid ""
9381 "<envar role=\"rc-item-web\">contact</envar>: String. A free-form (but "
9382 "preferably brief) string identifying the person or group in charge of the "
9383 "repository. This often contains the name and email address of a person or "
9384 "mailing list. It often makes sense to place this entry in a repository's own "
9385 "<filename role=\"special\">.hg/hgrc</filename> file, but it can make sense to "
9386 "use in a global <filename role=\"special\">~/.hgrc</filename> if every "
9387 "repository has a single maintainer."
9388 msgstr ""
9390 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9391 #: ../en/ch06-collab.xml:1367
9392 msgid ""
9393 "<envar role=\"rc-item-web\">maxchanges</envar>: Integer. The default maximum "
9394 "number of changesets to display in a single page of output."
9395 msgstr ""
9397 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9398 #: ../en/ch06-collab.xml:1371
9399 msgid ""
9400 "<envar role=\"rc-item-web\">maxfiles</envar>: Integer. The default maximum "
9401 "number of modified files to display in a single page of output."
9402 msgstr ""
9404 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9405 #: ../en/ch06-collab.xml:1375
9406 msgid ""
9407 "<envar role=\"rc-item-web\">stripes</envar>: Integer. If the web interface "
9408 "displays alternating <quote>stripes</quote> to make it easier to visually "
9409 "align rows when you are looking at a table, this number controls the number "
9410 "of rows in each stripe."
9411 msgstr ""
9413 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9414 #: ../en/ch06-collab.xml:1381
9415 msgid ""
9416 "<envar role=\"rc-item-web\">style</envar>: Controls the template Mercurial "
9417 "uses to display the web interface. Mercurial ships with several web "
9418 "templates."
9419 msgstr ""
9421 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
9422 #: ../en/ch06-collab.xml:1387
9423 msgid "<literal>coal</literal> is monochromatic."
9424 msgstr ""
9426 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
9427 #: ../en/ch06-collab.xml:1390
9428 msgid ""
9429 "<literal>gitweb</literal> emulates the visual style of git's web interface."
9430 msgstr ""
9432 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
9433 #: ../en/ch06-collab.xml:1394
9434 msgid "<literal>monoblue</literal> uses solid blues and greys."
9435 msgstr ""
9437 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
9438 #: ../en/ch06-collab.xml:1398
9439 msgid "<literal>paper</literal> is the default."
9440 msgstr ""
9442 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
9443 #: ../en/ch06-collab.xml:1401
9444 msgid "<literal>spartan</literal> was the default for a long time."
9445 msgstr ""
9447 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9448 #: ../en/ch06-collab.xml:1405
9449 msgid ""
9450 "You can also specify a custom template of your own; see <xref linkend=\"chap:"
9451 "template\"/> for details. Here, you can see how to enable the "
9452 "<literal>gitweb</literal> style."
9453 msgstr ""
9455 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9456 #: ../en/ch06-collab.xml:1413
9457 msgid ""
9458 "<envar role=\"rc-item-web\">templates</envar>: Path. The directory in which "
9459 "to search for template files. By default, Mercurial searches in the "
9460 "directory in which it was installed."
9461 msgstr ""
9463 #. type: Content of: <book><chapter><sect1><sect2><para>
9464 #: ../en/ch06-collab.xml:1418
9465 msgid ""
9466 "If you are using <filename role=\"special\">hgwebdir.cgi</filename>, you can "
9467 "place a few configuration items in a <literal role=\"rc-web\">web</literal> "
9468 "section of the <filename role=\"special\">hgweb.config</filename> file "
9469 "instead of a <filename role=\"special\">~/.hgrc</filename> file, for "
9470 "convenience. These items are <envar role=\"rc-item-web\">motd</envar> and "
9471 "<envar role=\"rc-item-web\">style</envar>."
9472 msgstr ""
9474 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
9475 #: ../en/ch06-collab.xml:1429
9476 msgid "Options specific to an individual repository"
9477 msgstr "针对单个版本库的选项"
9479 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9480 #: ../en/ch06-collab.xml:1431
9481 msgid ""
9482 "A few <literal role=\"rc-web\">web</literal> configuration items ought to be "
9483 "placed in a repository's local <filename role=\"special\">.hg/hgrc</"
9484 "filename>, rather than a user's or global <filename role=\"special\">~/.hgrc</"
9485 "filename>."
9486 msgstr ""
9488 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
9489 #: ../en/ch06-collab.xml:1436
9490 msgid ""
9491 "<envar role=\"rc-item-web\">description</envar>: String. A free-form (but "
9492 "preferably brief) string that describes the contents or purpose of the "
9493 "repository."
9494 msgstr ""
9496 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
9497 #: ../en/ch06-collab.xml:1441
9498 msgid ""
9499 "<envar role=\"rc-item-web\">name</envar>: String. The name to use for the "
9500 "repository in the web interface. This overrides the default name, which is "
9501 "the last component of the repository's path."
9502 msgstr ""
9504 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
9505 #: ../en/ch06-collab.xml:1449
9506 msgid ""
9507 "Options specific to the <command role=\"hg-cmd\">hg serve</command> command"
9508 msgstr "命令 <command role=\"hg-cmd\">hg serve</command> 的选项"
9510 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9511 #: ../en/ch06-collab.xml:1452
9512 msgid ""
9513 "Some of the items in the <literal role=\"rc-web\">web</literal> section of a "
9514 "<filename role=\"special\">~/.hgrc</filename> file are only for use with the "
9515 "<command role=\"hg-cmd\">hg serve</command> command."
9516 msgstr ""
9518 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
9519 #: ../en/ch06-collab.xml:1458
9520 msgid ""
9521 "<envar role=\"rc-item-web\">accesslog</envar>: Path. The name of a file into "
9522 "which to write an access log. By default, the <command role=\"hg-cmd\">hg "
9523 "serve</command> command writes this information to standard output, not to a "
9524 "file. Log entries are written in the standard <quote>combined</quote> file "
9525 "format used by almost all web servers."
9526 msgstr ""
9528 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
9529 #: ../en/ch06-collab.xml:1466
9530 msgid ""
9531 "<envar role=\"rc-item-web\">address</envar>: String. The local address on "
9532 "which the server should listen for incoming connections. By default, the "
9533 "server listens on all addresses."
9534 msgstr ""
9536 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
9537 #: ../en/ch06-collab.xml:1471
9538 msgid ""
9539 "<envar role=\"rc-item-web\">errorlog</envar>: Path. The name of a file into "
9540 "which to write an error log. By default, the <command role=\"hg-cmd\">hg "
9541 "serve</command> command writes this information to standard error, not to a "
9542 "file."
9543 msgstr ""
9545 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
9546 #: ../en/ch06-collab.xml:1477
9547 msgid ""
9548 "<envar role=\"rc-item-web\">ipv6</envar>: Boolean. Whether to use the IPv6 "
9549 "protocol. By default, IPv6 is not used."
9550 msgstr ""
9552 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
9553 #: ../en/ch06-collab.xml:1481
9554 msgid ""
9555 "<envar role=\"rc-item-web\">port</envar>: Integer. The TCP port number on "
9556 "which the server should listen. The default port number used is 8000."
9557 msgstr ""
9559 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
9560 #: ../en/ch06-collab.xml:1488
9561 msgid ""
9562 "Choosing the right <filename role=\"special\">~/.hgrc</filename> file to add "
9563 "<literal role=\"rc-web\">web</literal> items to"
9564 msgstr ""
9565 "选择正确的 <filename role=\"special\"> ~/.hgrc</filename> 文件增加到 <literal "
9566 "role=\"rc-web\">web</literal> 条目"
9568 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9569 #: ../en/ch06-collab.xml:1492
9570 msgid ""
9571 "It is important to remember that a web server like Apache or "
9572 "<literal>lighttpd</literal> will run under a user ID that is different to "
9573 "yours. CGI scripts run by your server, such as <filename role=\"special"
9574 "\">hgweb.cgi</filename>, will usually also run under that user ID."
9575 msgstr ""
9577 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9578 #: ../en/ch06-collab.xml:1499
9579 msgid ""
9580 "If you add <literal role=\"rc-web\">web</literal> items to your own personal "
9581 "<filename role=\"special\">~/.hgrc</filename> file, CGI scripts won't read "
9582 "that <filename role=\"special\">~/.hgrc</filename> file. Those settings will "
9583 "thus only affect the behavior of the <command role=\"hg-cmd\">hg serve</"
9584 "command> command when you run it. To cause CGI scripts to see your settings, "
9585 "either create a <filename role=\"special\">~/.hgrc</filename> file in the "
9586 "home directory of the user ID that runs your web server, or add those "
9587 "settings to a system-wide <filename role=\"special\">hgrc</filename> file."
9588 msgstr ""
9590 #. type: Content of: <book><chapter><sect1><title>
9591 #: ../en/ch06-collab.xml:1514
9592 msgid "System-wide configuration"
9593 msgstr "全局配置"
9595 #. type: Content of: <book><chapter><sect1><para>
9596 #: ../en/ch06-collab.xml:1516
9597 msgid ""
9598 "On Unix-like systems shared by multiple users (such as a server to which "
9599 "people publish changes), it often makes sense to set up some global default "
9600 "behaviors, such as what theme to use in web interfaces."
9601 msgstr ""
9603 #. type: Content of: <book><chapter><sect1><para>
9604 #: ../en/ch06-collab.xml:1521
9605 msgid ""
9606 "If a file named <filename>/etc/mercurial/hgrc</filename> exists, Mercurial "
9607 "will read it at startup time and apply any configuration settings it finds in "
9608 "that file. It will also look for files ending in a <literal>.rc</literal> "
9609 "extension in a directory named <filename>/etc/mercurial/hgrc.d</filename>, "
9610 "and apply any configuration settings it finds in each of those files."
9611 msgstr ""
9613 #. type: Content of: <book><chapter><sect1><sect2><title>
9614 #: ../en/ch06-collab.xml:1530
9615 msgid "Making Mercurial more trusting"
9616 msgstr "让 Mercurial 更可信"
9618 #. type: Content of: <book><chapter><sect1><sect2><para>
9619 #: ../en/ch06-collab.xml:1532
9620 msgid ""
9621 "One situation in which a global <filename>hgrc</filename> can be useful is if "
9622 "users are pulling changes owned by other users. By default, Mercurial will "
9623 "not trust most of the configuration items in a <filename>.hg/hgrc</filename> "
9624 "file inside a repository that is owned by a different user. If we clone or "
9625 "pull changes from such a repository, Mercurial will print a warning stating "
9626 "that it does not trust their <filename>.hg/hgrc</filename>."
9627 msgstr ""
9629 #. type: Content of: <book><chapter><sect1><sect2><para>
9630 #: ../en/ch06-collab.xml:1541
9631 msgid ""
9632 "If everyone in a particular Unix group is on the same team and "
9633 "<emphasis>should</emphasis> trust each other's configuration settings, or we "
9634 "want to trust particular users, we can override Mercurial's skeptical "
9635 "defaults by creating a system-wide <filename>hgrc</filename> file such as the "
9636 "following:"
9637 msgstr ""
9639 #. type: Content of: <book><chapter><title>
9640 #: ../en/ch07-filenames.xml:5
9641 msgid "File names and pattern matching"
9642 msgstr "文件名称与模式匹配"
9644 #. type: Content of: <book><chapter><para>
9645 #: ../en/ch07-filenames.xml:7
9646 msgid ""
9647 "Mercurial provides mechanisms that let you work with file names in a "
9648 "consistent and expressive way."
9649 msgstr ""
9651 #. type: Content of: <book><chapter><sect1><title>
9652 #: ../en/ch07-filenames.xml:11
9653 msgid "Simple file naming"
9654 msgstr "简单文件名称"
9656 #. type: Content of: <book><chapter><sect1><para>
9657 #: ../en/ch07-filenames.xml:13
9658 msgid ""
9659 "Mercurial uses a unified piece of machinery <quote>under the hood</quote> to "
9660 "handle file names. Every command behaves uniformly with respect to file "
9661 "names. The way in which commands work with file names is as follows."
9662 msgstr ""
9664 #. type: Content of: <book><chapter><sect1><para>
9665 #: ../en/ch07-filenames.xml:18
9666 msgid ""
9667 "If you explicitly name real files on the command line, Mercurial works with "
9668 "exactly those files, as you would expect. &interaction.filenames.files;"
9669 msgstr ""
9672 #. type: Content of: <book><chapter><sect1><para>
9673 #: ../en/ch07-filenames.xml:22
9674 msgid ""
9675 "When you provide a directory name, Mercurial will interpret this as "
9676 "<quote>operate on every file in this directory and its subdirectories</"
9677 "quote>. Mercurial traverses the files and subdirectories in a directory in "
9678 "alphabetical order. When it encounters a subdirectory, it will traverse that "
9679 "subdirectory before continuing with the current directory."
9680 msgstr ""
9682 #. type: Content of: <book><chapter><sect1><title>
9683 #: ../en/ch07-filenames.xml:33
9684 msgid "Running commands without any file names"
9685 msgstr "不提供文件名称的执行命令"
9687 #. type: Content of: <book><chapter><sect1><para>
9688 #: ../en/ch07-filenames.xml:35
9689 msgid ""
9690 "Mercurial's commands that work with file names have useful default behaviors "
9691 "when you invoke them without providing any file names or patterns. What kind "
9692 "of behavior you should expect depends on what the command does. Here are a "
9693 "few rules of thumb you can use to predict what a command is likely to do if "
9694 "you don't give it any names to work with."
9695 msgstr ""
9697 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
9698 #: ../en/ch07-filenames.xml:42
9699 msgid ""
9700 "Most commands will operate on the entire working directory. This is what the "
9701 "<command role=\"hg-cmd\">hg add</command> command does, for example."
9702 msgstr ""
9704 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
9705 #: ../en/ch07-filenames.xml:46
9706 msgid ""
9707 "If the command has effects that are difficult or impossible to reverse, it "
9708 "will force you to explicitly provide at least one name or pattern (see "
9709 "below). This protects you from accidentally deleting files by running "
9710 "<command role=\"hg-cmd\">hg remove</command> with no arguments, for example."
9711 msgstr ""
9713 #. type: Content of: <book><chapter><sect1><para>
9714 #: ../en/ch07-filenames.xml:54
9715 msgid ""
9716 "It's easy to work around these default behaviors if they don't suit you. If "
9717 "a command normally operates on the whole working directory, you can invoke it "
9718 "on just the current directory and its subdirectories by giving it the name "
9719 "<quote><filename class=\"directory\">.</filename></quote>."
9720 msgstr ""
9723 #. type: Content of: <book><chapter><sect1><para>
9724 #: ../en/ch07-filenames.xml:62
9725 msgid ""
9726 "Along the same lines, some commands normally print file names relative to the "
9727 "root of the repository, even if you're invoking them from a subdirectory. "
9728 "Such a command will print file names relative to your subdirectory if you "
9729 "give it explicit names. Here, we're going to run <command role=\"hg-cmd\">hg "
9730 "status</command> from a subdirectory, and get it to operate on the entire "
9731 "working directory while printing file names relative to our subdirectory, by "
9732 "passing it the output of the <command role=\"hg-cmd\">hg root</command> "
9733 "command."
9734 msgstr ""
9736 #. type: Content of: <book><chapter><sect1><title>
9737 #: ../en/ch07-filenames.xml:76
9738 msgid "Telling you what's going on"
9739 msgstr "告诉你正在做什么"
9741 #. type: Content of: <book><chapter><sect1><para>
9742 #: ../en/ch07-filenames.xml:78
9743 msgid ""
9744 "The <command role=\"hg-cmd\">hg add</command> example in the preceding "
9745 "section illustrates something else that's helpful about Mercurial commands. "
9746 "If a command operates on a file that you didn't name explicitly on the "
9747 "command line, it will usually print the name of the file, so that you will "
9748 "not be surprised what's going on."
9749 msgstr ""
9751 #. type: Content of: <book><chapter><sect1><para>
9752 #: ../en/ch07-filenames.xml:85
9753 msgid ""
9754 "The principle here is of <emphasis>least surprise</emphasis>. If you've "
9755 "exactly named a file on the command line, there's no point in repeating it "
9756 "back at you. If Mercurial is acting on a file <emphasis>implicitly</"
9757 "emphasis>, e.g. because you provided no names, or a directory, or a pattern "
9758 "(see below), it is safest to tell you what files it's operating on."
9759 msgstr ""
9761 #. type: Content of: <book><chapter><sect1><para>
9762 #: ../en/ch07-filenames.xml:92
9763 msgid ""
9764 "For commands that behave this way, you can silence them using the <option "
9765 "role=\"hg-opt-global\">-q</option> option. You can also get them to print "
9766 "the name of every file, even those you've named explicitly, using the <option "
9767 "role=\"hg-opt-global\">-v</option> option."
9768 msgstr ""
9770 #. type: Content of: <book><chapter><sect1><title>
9771 #: ../en/ch07-filenames.xml:100
9772 msgid "Using patterns to identify files"
9773 msgstr "使用模式标识文件"
9775 #. type: Content of: <book><chapter><sect1><para>
9776 #: ../en/ch07-filenames.xml:102
9777 msgid ""
9778 "In addition to working with file and directory names, Mercurial lets you use "
9779 "<emphasis>patterns</emphasis> to identify files. Mercurial's pattern "
9780 "handling is expressive."
9781 msgstr ""
9783 #. type: Content of: <book><chapter><sect1><para>
9784 #: ../en/ch07-filenames.xml:106
9785 msgid ""
9786 "On Unix-like systems (Linux, MacOS, etc.), the job of matching file names to "
9787 "patterns normally falls to the shell. On these systems, you must explicitly "
9788 "tell Mercurial that a name is a pattern. On Windows, the shell does not "
9789 "expand patterns, so Mercurial will automatically identify names that are "
9790 "patterns, and expand them for you."
9791 msgstr ""
9793 #. type: Content of: <book><chapter><sect1><para>
9794 #: ../en/ch07-filenames.xml:113
9795 msgid ""
9796 "To provide a pattern in place of a regular name on the command line, the "
9797 "mechanism is simple:"
9798 msgstr ""
9800 #. type: Content of: <book><chapter><sect1><para>
9801 #: ../en/ch07-filenames.xml:116
9802 msgid ""
9803 "That is, a pattern is identified by a short text string that says what kind "
9804 "of pattern this is, followed by a colon, followed by the actual pattern."
9805 msgstr ""
9807 #. type: Content of: <book><chapter><sect1><para>
9808 #: ../en/ch07-filenames.xml:120
9809 msgid ""
9810 "Mercurial supports two kinds of pattern syntax. The most frequently used is "
9811 "called <literal>glob</literal>; this is the same kind of pattern matching "
9812 "used by the Unix shell, and should be familiar to Windows command prompt "
9813 "users, too."
9814 msgstr ""
9816 #. type: Content of: <book><chapter><sect1><para>
9817 #: ../en/ch07-filenames.xml:125
9818 msgid ""
9819 "When Mercurial does automatic pattern matching on Windows, it uses "
9820 "<literal>glob</literal> syntax. You can thus omit the <quote><literal>glob:</"
9821 "literal></quote> prefix on Windows, but it's safe to use it, too."
9822 msgstr ""
9824 #. type: Content of: <book><chapter><sect1><para>
9825 #: ../en/ch07-filenames.xml:130
9826 msgid ""
9827 "The <literal>re</literal> syntax is more powerful; it lets you specify "
9828 "patterns using regular expressions, also known as regexps."
9829 msgstr ""
9831 #. type: Content of: <book><chapter><sect1><para>
9832 #: ../en/ch07-filenames.xml:134
9833 msgid ""
9834 "By the way, in the examples that follow, notice that I'm careful to wrap all "
9835 "of my patterns in quote characters, so that they won't get expanded by the "
9836 "shell before Mercurial sees them."
9837 msgstr ""
9839 #. type: Content of: <book><chapter><sect1><sect2><title>
9840 #: ../en/ch07-filenames.xml:140
9841 msgid "Shell-style <literal>glob</literal> patterns"
9842 msgstr "外壳风格的 <literal>glob</literal> 模式"
9844 #. type: Content of: <book><chapter><sect1><sect2><para>
9845 #: ../en/ch07-filenames.xml:142
9846 msgid ""
9847 "This is an overview of the kinds of patterns you can use when you're matching "
9848 "on glob patterns."
9849 msgstr ""
9852 #. type: Content of: <book><chapter><sect1><sect2><para>
9853 #: ../en/ch07-filenames.xml:145
9854 msgid ""
9855 "The <quote><literal>*</literal></quote> character matches any string, within "
9856 "a single directory."
9857 msgstr ""
9860 #. type: Content of: <book><chapter><sect1><sect2><para>
9861 #: ../en/ch07-filenames.xml:150
9862 msgid ""
9863 "The <quote><literal>**</literal></quote> pattern matches any string, and "
9864 "crosses directory boundaries. It's not a standard Unix glob token, but it's "
9865 "accepted by several popular Unix shells, and is very useful."
9866 msgstr ""
9869 #. type: Content of: <book><chapter><sect1><sect2><para>
9870 #: ../en/ch07-filenames.xml:157
9871 msgid ""
9872 "The <quote><literal>?</literal></quote> pattern matches any single character."
9873 msgstr ""
9875 #. type: Content of: <book><chapter><sect1><sect2><para>
9876 #: ../en/ch07-filenames.xml:162
9877 msgid ""
9878 "The <quote><literal>[</literal></quote> character begins a "
9879 "<emphasis>character class</emphasis>. This matches any single character "
9880 "within the class. The class ends with a <quote><literal>]</literal></quote> "
9881 "character. A class may contain multiple <emphasis>range</emphasis>s of the "
9882 "form <quote><literal>a-f</literal></quote>, which is shorthand for "
9883 "<quote><literal>abcdef</literal></quote>."
9884 msgstr ""
9886 #. type: Content of: <book><chapter><sect1><sect2><para>
9887 #: ../en/ch07-filenames.xml:172
9888 msgid ""
9889 "If the first character after the <quote><literal>[</literal></quote> in a "
9890 "character class is a <quote><literal>!</literal></quote>, it "
9891 "<emphasis>negates</emphasis> the class, making it match any single character "
9892 "not in the class."
9893 msgstr ""
9895 #. type: Content of: <book><chapter><sect1><sect2><para>
9896 #: ../en/ch07-filenames.xml:178
9897 msgid ""
9898 "A <quote><literal>{</literal></quote> begins a group of subpatterns, where "
9899 "the whole group matches if any subpattern in the group matches. The "
9900 "<quote><literal>,</literal></quote> character separates subpatterns, and "
9901 "<quote><literal>}</literal></quote> ends the group."
9902 msgstr ""
9904 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
9905 #: ../en/ch07-filenames.xml:187
9906 msgid "Watch out!"
9907 msgstr "千万小心!"
9910 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9911 #: ../en/ch07-filenames.xml:189
9912 msgid ""
9913 "Don't forget that if you want to match a pattern in any directory, you should "
9914 "not be using the <quote><literal>*</literal></quote> match-any token, as this "
9915 "will only match within one directory. Instead, use the <quote><literal>**</"
9916 "literal></quote> token. This small example illustrates the difference "
9917 "between the two."
9918 msgstr ""
9920 #. type: Content of: <book><chapter><sect1><sect2><title>
9921 #: ../en/ch07-filenames.xml:201
9922 msgid "Regular expression matching with <literal>re</literal> patterns"
9923 msgstr "使用 <literal>re</literal> 模式的正则表达式匹配"
9925 #. type: Content of: <book><chapter><sect1><sect2><para>
9926 #: ../en/ch07-filenames.xml:204
9927 msgid ""
9928 "Mercurial accepts the same regular expression syntax as the Python "
9929 "programming language (it uses Python's regexp engine internally). This is "
9930 "based on the Perl language's regexp syntax, which is the most popular dialect "
9931 "in use (it's also used in Java, for example)."
9932 msgstr ""
9934 #. type: Content of: <book><chapter><sect1><sect2><para>
9935 #: ../en/ch07-filenames.xml:210
9936 msgid ""
9937 "I won't discuss Mercurial's regexp dialect in any detail here, as regexps are "
9938 "not often used. Perl-style regexps are in any case already exhaustively "
9939 "documented on a multitude of web sites, and in many books. Instead, I will "
9940 "focus here on a few things you should know if you find yourself needing to "
9941 "use regexps with Mercurial."
9942 msgstr ""
9944 #. type: Content of: <book><chapter><sect1><sect2><para>
9945 #: ../en/ch07-filenames.xml:217
9946 msgid ""
9947 "A regexp is matched against an entire file name, relative to the root of the "
9948 "repository. In other words, even if you're already in subbdirectory "
9949 "<filename class=\"directory\">foo</filename>, if you want to match files "
9950 "under this directory, your pattern must start with <quote><literal>foo/</"
9951 "literal></quote>."
9952 msgstr ""
9954 #. type: Content of: <book><chapter><sect1><sect2><para>
9955 #: ../en/ch07-filenames.xml:224
9956 msgid ""
9957 "One thing to note, if you're familiar with Perl-style regexps, is that "
9958 "Mercurial's are <emphasis>rooted</emphasis>. That is, a regexp starts "
9959 "matching against the beginning of a string; it doesn't look for a match "
9960 "anywhere within the string. To match anywhere in a string, start your "
9961 "pattern with <quote><literal>.*</literal></quote>."
9962 msgstr ""
9964 #. type: Content of: <book><chapter><sect1><title>
9965 #: ../en/ch07-filenames.xml:234
9966 msgid "Filtering files"
9967 msgstr "过滤文件"
9969 #. type: Content of: <book><chapter><sect1><para>
9970 #: ../en/ch07-filenames.xml:236
9971 msgid ""
9972 "Not only does Mercurial give you a variety of ways to specify files; it lets "
9973 "you further winnow those files using <emphasis>filters</emphasis>. Commands "
9974 "that work with file names accept two filtering options."
9975 msgstr ""
9977 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
9978 #: ../en/ch07-filenames.xml:241
9979 msgid ""
9980 "<option role=\"hg-opt-global\">-I</option>, or <option role=\"hg-opt-global"
9981 "\">--include</option>, lets you specify a pattern that file names must match "
9982 "in order to be processed."
9983 msgstr ""
9985 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
9986 #: ../en/ch07-filenames.xml:246
9987 msgid ""
9988 "<option role=\"hg-opt-global\">-X</option>, or <option role=\"hg-opt-global"
9989 "\">--exclude</option>, gives you a way to <emphasis>avoid</emphasis> "
9990 "processing files, if they match this pattern."
9991 msgstr ""
9993 #. type: Content of: <book><chapter><sect1><para>
9994 #: ../en/ch07-filenames.xml:251
9995 msgid ""
9996 "You can provide multiple <option role=\"hg-opt-global\">-I</option> and "
9997 "<option role=\"hg-opt-global\">-X</option> options on the command line, and "
9998 "intermix them as you please. Mercurial interprets the patterns you provide "
9999 "using glob syntax by default (but you can use regexps if you need to)."
10000 msgstr ""
10002 #. type: Content of: <book><chapter><sect1><para>
10003 #: ../en/ch07-filenames.xml:258
10004 msgid ""
10005 "You can read a <option role=\"hg-opt-global\">-I</option> filter as "
10006 "<quote>process only the files that match this filter</quote>."
10007 msgstr ""
10009 #. type: Content of: <book><chapter><sect1><para>
10010 #: ../en/ch07-filenames.xml:264
10011 msgid ""
10012 "The <option role=\"hg-opt-global\">-X</option> filter is best read as "
10013 "<quote>process only the files that don't match this pattern</quote>."
10014 msgstr ""
10016 #. type: Content of: <book><chapter><sect1><title>
10017 #: ../en/ch07-filenames.xml:272
10018 msgid "Permanently ignoring unwanted files and directories"
10019 msgstr "始终忽略不需要的文件和目录"
10021 #. type: Content of: <book><chapter><sect1><para>
10022 #: ../en/ch07-filenames.xml:274
10023 msgid ""
10024 "When you create a new repository, the chances are that over time it will grow "
10025 "to contain files that ought to <emphasis>not</emphasis> be managed by "
10026 "Mercurial, but which you don't want to see listed every time you run "
10027 "<command>hg status</command>. For instance, <quote>build products</quote> "
10028 "are files that are created as part of a build but which should not be managed "
10029 "by a revision control system. The most common build products are output "
10030 "files produced by software tools such as compilers. As another example, many "
10031 "text editors litter a directory with lock files, temporary working files, and "
10032 "backup files, which it also makes no sense to manage."
10033 msgstr ""
10035 #. type: Content of: <book><chapter><sect1><para>
10036 #: ../en/ch07-filenames.xml:286
10037 msgid ""
10038 "To have Mercurial permanently ignore such files, create a file named "
10039 "<filename>.hgignore</filename> in the root of your repository. You "
10040 "<emphasis>should</emphasis> <command>hg add</command> this file so that it "
10041 "gets tracked with the rest of your repository contents, since your "
10042 "collaborators will probably find it useful too."
10043 msgstr ""
10045 #. type: Content of: <book><chapter><sect1><para>
10046 #: ../en/ch07-filenames.xml:293
10047 msgid ""
10048 "By default, the <filename>.hgignore</filename> file should contain a list of "
10049 "regular expressions, one per line. Empty lines are skipped. Most people "
10050 "prefer to describe the files they want to ignore using the <quote>glob</"
10051 "quote> syntax that we described above, so a typical <filename>.hgignore</"
10052 "filename> file will start with this directive:"
10053 msgstr ""
10055 #. type: Content of: <book><chapter><sect1><para>
10056 #: ../en/ch07-filenames.xml:302
10057 msgid ""
10058 "This tells Mercurial to interpret the lines that follow as glob patterns, not "
10059 "regular expressions."
10060 msgstr ""
10062 #. type: Content of: <book><chapter><sect1><para>
10063 #: ../en/ch07-filenames.xml:305
10064 msgid "Here is a typical-looking <filename>.hgignore</filename> file."
10065 msgstr ""
10067 #. type: Content of: <book><chapter><sect1><title>
10068 #: ../en/ch07-filenames.xml:329
10069 msgid "Case sensitivity"
10070 msgstr "大小写敏感性"
10072 #. type: Content of: <book><chapter><sect1><para>
10073 #: ../en/ch07-filenames.xml:331
10074 msgid ""
10075 "If you're working in a mixed development environment that contains both Linux "
10076 "(or other Unix) systems and Macs or Windows systems, you should keep in the "
10077 "back of your mind the knowledge that they treat the case (<quote>N</quote> "
10078 "versus <quote>n</quote>) of file names in incompatible ways. This is not "
10079 "very likely to affect you, and it's easy to deal with if it does, but it "
10080 "could surprise you if you don't know about it."
10081 msgstr ""
10083 #. type: Content of: <book><chapter><sect1><para>
10084 #: ../en/ch07-filenames.xml:340
10085 msgid ""
10086 "Operating systems and filesystems differ in the way they handle the "
10087 "<emphasis>case</emphasis> of characters in file and directory names. There "
10088 "are three common ways to handle case in names."
10089 msgstr ""
10091 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10092 #: ../en/ch07-filenames.xml:345
10093 msgid ""
10094 "Completely case insensitive. Uppercase and lowercase versions of a letter "
10095 "are treated as identical, both when creating a file and during subsequent "
10096 "accesses. This is common on older DOS-based systems."
10097 msgstr ""
10099 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10100 #: ../en/ch07-filenames.xml:350
10101 msgid ""
10102 "Case preserving, but insensitive. When a file or directory is created, the "
10103 "case of its name is stored, and can be retrieved and displayed by the "
10104 "operating system. When an existing file is being looked up, its case is "
10105 "ignored. This is the standard arrangement on Windows and MacOS. The names "
10106 "<filename>foo</filename> and <filename>FoO</filename> identify the same "
10107 "file. This treatment of uppercase and lowercase letters as interchangeable "
10108 "is also referred to as <emphasis>case folding</emphasis>."
10109 msgstr ""
10111 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10112 #: ../en/ch07-filenames.xml:361
10113 msgid ""
10114 "Case sensitive. The case of a name is significant at all times. The names "
10115 "<filename>foo</filename> and <filename>FoO</filename> identify different "
10116 "files. This is the way Linux and Unix systems normally work."
10117 msgstr ""
10119 #. type: Content of: <book><chapter><sect1><para>
10120 #: ../en/ch07-filenames.xml:368
10121 msgid ""
10122 "On Unix-like systems, it is possible to have any or all of the above ways of "
10123 "handling case in action at once. For example, if you use a USB thumb drive "
10124 "formatted with a FAT32 filesystem on a Linux system, Linux will handle names "
10125 "on that filesystem in a case preserving, but insensitive, way."
10126 msgstr ""
10128 #. type: Content of: <book><chapter><sect1><sect2><title>
10129 #: ../en/ch07-filenames.xml:375
10130 msgid "Safe, portable repository storage"
10131 msgstr "安全,可移植的版本库存储"
10133 #. type: Content of: <book><chapter><sect1><sect2><para>
10134 #: ../en/ch07-filenames.xml:377
10135 msgid ""
10136 "Mercurial's repository storage mechanism is <emphasis>case safe</emphasis>. "
10137 "It translates file names so that they can be safely stored on both case "
10138 "sensitive and case insensitive filesystems. This means that you can use "
10139 "normal file copying tools to transfer a Mercurial repository onto, for "
10140 "example, a USB thumb drive, and safely move that drive and repository back "
10141 "and forth between a Mac, a PC running Windows, and a Linux box."
10142 msgstr ""
10144 #. type: Content of: <book><chapter><sect1><sect2><title>
10145 #: ../en/ch07-filenames.xml:388
10146 msgid "Detecting case conflicts"
10147 msgstr "检测大小写冲突"
10149 #. type: Content of: <book><chapter><sect1><sect2><para>
10150 #: ../en/ch07-filenames.xml:390
10151 msgid ""
10152 "When operating in the working directory, Mercurial honours the naming policy "
10153 "of the filesystem where the working directory is located. If the filesystem "
10154 "is case preserving, but insensitive, Mercurial will treat names that differ "
10155 "only in case as the same."
10156 msgstr ""
10158 #. type: Content of: <book><chapter><sect1><sect2><para>
10159 #: ../en/ch07-filenames.xml:396
10160 msgid ""
10161 "An important aspect of this approach is that it is possible to commit a "
10162 "changeset on a case sensitive (typically Linux or Unix) filesystem that will "
10163 "cause trouble for users on case insensitive (usually Windows and MacOS) "
10164 "users. If a Linux user commits changes to two files, one named "
10165 "<filename>myfile.c</filename> and the other named <filename>MyFile.C</"
10166 "filename>, they will be stored correctly in the repository. And in the "
10167 "working directories of other Linux users, they will be correctly represented "
10168 "as separate files."
10169 msgstr ""
10171 #. type: Content of: <book><chapter><sect1><sect2><para>
10172 #: ../en/ch07-filenames.xml:407
10173 msgid ""
10174 "If a Windows or Mac user pulls this change, they will not initially have a "
10175 "problem, because Mercurial's repository storage mechanism is case safe. "
10176 "However, once they try to <command role=\"hg-cmd\">hg update</command> the "
10177 "working directory to that changeset, or <command role=\"hg-cmd\">hg merge</"
10178 "command> with that changeset, Mercurial will spot the conflict between the "
10179 "two file names that the filesystem would treat as the same, and forbid the "
10180 "update or merge from occurring."
10181 msgstr ""
10183 #. type: Content of: <book><chapter><sect1><sect2><title>
10184 #: ../en/ch07-filenames.xml:419
10185 msgid "Fixing a case conflict"
10186 msgstr "修正大小写冲突"
10188 #. type: Content of: <book><chapter><sect1><sect2><para>
10189 #: ../en/ch07-filenames.xml:421
10190 msgid ""
10191 "If you are using Windows or a Mac in a mixed environment where some of your "
10192 "collaborators are using Linux or Unix, and Mercurial reports a case folding "
10193 "conflict when you try to <command role=\"hg-cmd\">hg update</command> or "
10194 "<command role=\"hg-cmd\">hg merge</command>, the procedure to fix the problem "
10195 "is simple."
10196 msgstr ""
10198 #. type: Content of: <book><chapter><sect1><sect2><para>
10199 #: ../en/ch07-filenames.xml:428
10200 msgid ""
10201 "Just find a nearby Linux or Unix box, clone the problem repository onto it, "
10202 "and use Mercurial's <command role=\"hg-cmd\">hg rename</command> command to "
10203 "change the names of any offending files or directories so that they will no "
10204 "longer cause case folding conflicts. Commit this change, <command role=\"hg-"
10205 "cmd\">hg pull</command> or <command role=\"hg-cmd\">hg push</command> it "
10206 "across to your Windows or MacOS system, and <command role=\"hg-cmd\">hg "
10207 "update</command> to the revision with the non-conflicting names."
10208 msgstr ""
10210 #. type: Content of: <book><chapter><sect1><sect2><para>
10211 #: ../en/ch07-filenames.xml:438
10212 msgid ""
10213 "The changeset with case-conflicting names will remain in your project's "
10214 "history, and you still won't be able to <command role=\"hg-cmd\">hg update</"
10215 "command> your working directory to that changeset on a Windows or MacOS "
10216 "system, but you can continue development unimpeded."
10217 msgstr ""
10219 #. type: Content of: <book><chapter><title>
10220 #: ../en/ch08-branch.xml:5
10221 msgid "Managing releases and branchy development"
10222 msgstr "发布管理与分支开发"
10224 #. type: Content of: <book><chapter><para>
10225 #: ../en/ch08-branch.xml:7
10226 msgid ""
10227 "Mercurial provides several mechanisms for you to manage a project that is "
10228 "making progress on multiple fronts at once. To understand these mechanisms, "
10229 "let's first take a brief look at a fairly normal software project structure."
10230 msgstr ""
10232 #. type: Content of: <book><chapter><para>
10233 #: ../en/ch08-branch.xml:12
10234 msgid ""
10235 "Many software projects issue periodic <quote>major</quote> releases that "
10236 "contain substantial new features. In parallel, they may issue <quote>minor</"
10237 "quote> releases. These are usually identical to the major releases off which "
10238 "they're based, but with a few bugs fixed."
10239 msgstr ""
10241 #. type: Content of: <book><chapter><para>
10242 #: ../en/ch08-branch.xml:18
10243 msgid ""
10244 "In this chapter, we'll start by talking about how to keep records of project "
10245 "milestones such as releases. We'll then continue on to talk about the flow "
10246 "of work between different phases of a project, and how Mercurial can help you "
10247 "to isolate and manage this work."
10248 msgstr ""
10250 #. type: Content of: <book><chapter><sect1><title>
10251 #: ../en/ch08-branch.xml:25
10252 msgid "Giving a persistent name to a revision"
10253 msgstr "给版本指定一个永久的名称"
10255 #. type: Content of: <book><chapter><sect1><para>
10256 #: ../en/ch08-branch.xml:27
10257 msgid ""
10258 "Once you decide that you'd like to call a particular revision a "
10259 "<quote>release</quote>, it's a good idea to record the identity of that "
10260 "revision. This will let you reproduce that release at a later date, for "
10261 "whatever purpose you might need at the time (reproducing a bug, porting to a "
10262 "new platform, etc). &interaction.tag.init;"
10263 msgstr ""
10266 #. type: Content of: <book><chapter><sect1><para>
10267 #: ../en/ch08-branch.xml:34
10268 msgid ""
10269 "Mercurial lets you give a permanent name to any revision using the <command "
10270 "role=\"hg-cmd\">hg tag</command> command. Not surprisingly, these names are "
10271 "called <quote>tags</quote>."
10272 msgstr ""
10274 #. type: Content of: <book><chapter><sect1><para>
10275 #: ../en/ch08-branch.xml:40
10276 msgid ""
10277 "A tag is nothing more than a <quote>symbolic name</quote> for a revision. "
10278 "Tags exist purely for your convenience, so that you have a handy permanent "
10279 "way to refer to a revision; Mercurial doesn't interpret the tag names you use "
10280 "in any way. Neither does Mercurial place any restrictions on the name of a "
10281 "tag, beyond a few that are necessary to ensure that a tag can be parsed "
10282 "unambiguously. A tag name cannot contain any of the following characters:"
10283 msgstr ""
10285 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10286 #: ../en/ch08-branch.xml:49
10287 msgid "Colon (ASCII 58, <quote><literal>:</literal></quote>)"
10288 msgstr ""
10290 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10291 #: ../en/ch08-branch.xml:52
10292 msgid "Carriage return (ASCII 13, <quote><literal>\\r</literal></quote>)"
10293 msgstr ""
10295 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10296 #: ../en/ch08-branch.xml:55
10297 msgid "Newline (ASCII 10, <quote><literal>\\n</literal></quote>)"
10298 msgstr ""
10300 #. type: Content of: <book><chapter><sect1><para>
10301 #: ../en/ch08-branch.xml:59
10302 msgid ""
10303 "You can use the <command role=\"hg-cmd\">hg tags</command> command to display "
10304 "the tags present in your repository. In the output, each tagged revision is "
10305 "identified first by its name, then by revision number, and finally by the "
10306 "unique hash of the revision."
10307 msgstr ""
10309 #. type: Content of: <book><chapter><sect1><para>
10310 #: ../en/ch08-branch.xml:67
10311 msgid ""
10312 "Notice that <literal>tip</literal> is listed in the output of <command role="
10313 "\"hg-cmd\">hg tags</command>. The <literal>tip</literal> tag is a special "
10314 "<quote>floating</quote> tag, which always identifies the newest revision in "
10315 "the repository."
10316 msgstr ""
10318 #. type: Content of: <book><chapter><sect1><para>
10319 #: ../en/ch08-branch.xml:73
10320 msgid ""
10321 "In the output of the <command role=\"hg-cmd\">hg tags</command> command, tags "
10322 "are listed in reverse order, by revision number. This usually means that "
10323 "recent tags are listed before older tags. It also means that <literal>tip</"
10324 "literal> is always going to be the first tag listed in the output of <command "
10325 "role=\"hg-cmd\">hg tags</command>."
10326 msgstr ""
10328 #. type: Content of: <book><chapter><sect1><para>
10329 #: ../en/ch08-branch.xml:80
10330 msgid ""
10331 "When you run <command role=\"hg-cmd\">hg log</command>, if it displays a "
10332 "revision that has tags associated with it, it will print those tags."
10333 msgstr ""
10336 #. type: Content of: <book><chapter><sect1><para>
10337 #: ../en/ch08-branch.xml:86
10338 msgid ""
10339 "Any time you need to provide a revision ID to a Mercurial command, the "
10340 "command will accept a tag name in its place. Internally, Mercurial will "
10341 "translate your tag name into the corresponding revision ID, then use that."
10342 msgstr ""
10344 #. type: Content of: <book><chapter><sect1><para>
10345 #: ../en/ch08-branch.xml:93
10346 msgid ""
10347 "There's no limit on the number of tags you can have in a repository, or on "
10348 "the number of tags that a single revision can have. As a practical matter, "
10349 "it's not a great idea to have <quote>too many</quote> (a number which will "
10350 "vary from project to project), simply because tags are supposed to help you "
10351 "to find revisions. If you have lots of tags, the ease of using them to "
10352 "identify revisions diminishes rapidly."
10353 msgstr ""
10355 #. type: Content of: <book><chapter><sect1><para>
10356 #: ../en/ch08-branch.xml:101
10357 msgid ""
10358 "For example, if your project has milestones as frequent as every few days, "
10359 "it's perfectly reasonable to tag each one of those. But if you have a "
10360 "continuous build system that makes sure every revision can be built cleanly, "
10361 "you'd be introducing a lot of noise if you were to tag every clean build. "
10362 "Instead, you could tag failed builds (on the assumption that they're rare!), "
10363 "or simply not use tags to track buildability."
10364 msgstr ""
10366 #. type: Content of: <book><chapter><sect1><para>
10367 #: ../en/ch08-branch.xml:109
10368 msgid ""
10369 "If you want to remove a tag that you no longer want, use <command role=\"hg-"
10370 "cmd\">hg tag --remove</command>."
10371 msgstr ""
10373 #. type: Content of: <book><chapter><sect1><para>
10374 #: ../en/ch08-branch.xml:114
10375 msgid ""
10376 "You can also modify a tag at any time, so that it identifies a different "
10377 "revision, by simply issuing a new <command role=\"hg-cmd\">hg tag</command> "
10378 "command. You'll have to use the <option role=\"hg-opt-tag\">-f</option> "
10379 "option to tell Mercurial that you <emphasis>really</emphasis> want to update "
10380 "the tag."
10381 msgstr ""
10383 #. type: Content of: <book><chapter><sect1><para>
10384 #: ../en/ch08-branch.xml:123
10385 msgid ""
10386 "There will still be a permanent record of the previous identity of the tag, "
10387 "but Mercurial will no longer use it. There's thus no penalty to tagging the "
10388 "wrong revision; all you have to do is turn around and tag the correct "
10389 "revision once you discover your error."
10390 msgstr ""
10392 #. type: Content of: <book><chapter><sect1><para>
10393 #: ../en/ch08-branch.xml:129
10394 msgid ""
10395 "Mercurial stores tags in a normal revision-controlled file in your "
10396 "repository. If you've created any tags, you'll find them in a file in the "
10397 "root of your repository named <filename role=\"special\">.hgtags</filename>. "
10398 "When you run the <command role=\"hg-cmd\">hg tag</command> command, Mercurial "
10399 "modifies this file, then automatically commits the change to it. This means "
10400 "that every time you run <command role=\"hg-cmd\">hg tag</command>, you'll see "
10401 "a corresponding changeset in the output of <command role=\"hg-cmd\">hg log</"
10402 "command>."
10403 msgstr ""
10405 #. type: Content of: <book><chapter><sect1><sect2><title>
10406 #: ../en/ch08-branch.xml:142
10407 msgid "Handling tag conflicts during a merge"
10408 msgstr "在合并期间处理标签冲突"
10410 #. type: Content of: <book><chapter><sect1><sect2><para>
10411 #: ../en/ch08-branch.xml:144
10412 msgid ""
10413 "You won't often need to care about the <filename role=\"special\">.hgtags</"
10414 "filename> file, but it sometimes makes its presence known during a merge. "
10415 "The format of the file is simple: it consists of a series of lines. Each "
10416 "line starts with a changeset hash, followed by a space, followed by the name "
10417 "of a tag."
10418 msgstr ""
10420 #. type: Content of: <book><chapter><sect1><sect2><para>
10421 #: ../en/ch08-branch.xml:151
10422 msgid ""
10423 "If you're resolving a conflict in the <filename role=\"special\">.hgtags</"
10424 "filename> file during a merge, there's one twist to modifying the <filename "
10425 "role=\"special\">.hgtags</filename> file: when Mercurial is parsing the tags "
10426 "in a repository, it <emphasis>never</emphasis> reads the working copy of the "
10427 "<filename role=\"special\">.hgtags</filename> file. Instead, it reads the "
10428 "<emphasis>most recently committed</emphasis> revision of the file."
10429 msgstr ""
10431 #. type: Content of: <book><chapter><sect1><sect2><para>
10432 #: ../en/ch08-branch.xml:161
10433 msgid ""
10434 "An unfortunate consequence of this design is that you can't actually verify "
10435 "that your merged <filename role=\"special\">.hgtags</filename> file is "
10436 "correct until <emphasis>after</emphasis> you've committed a change. So if "
10437 "you find yourself resolving a conflict on <filename role=\"special\">.hgtags</"
10438 "filename> during a merge, be sure to run <command role=\"hg-cmd\">hg tags</"
10439 "command> after you commit. If it finds an error in the <filename role="
10440 "\"special\">.hgtags</filename> file, it will report the location of the "
10441 "error, which you can then fix and commit. You should then run <command role="
10442 "\"hg-cmd\">hg tags</command> again, just to be sure that your fix is correct."
10443 msgstr ""
10445 #. type: Content of: <book><chapter><sect1><sect2><title>
10446 #: ../en/ch08-branch.xml:176
10447 msgid "Tags and cloning"
10448 msgstr "标签与克隆"
10450 #. type: Content of: <book><chapter><sect1><sect2><para>
10451 #: ../en/ch08-branch.xml:178
10452 msgid ""
10453 "You may have noticed that the <command role=\"hg-cmd\">hg clone</command> "
10454 "command has a <option role=\"hg-opt-clone\">-r</option> option that lets you "
10455 "clone an exact copy of the repository as of a particular changeset. The new "
10456 "clone will not contain any project history that comes after the revision you "
10457 "specified. This has an interaction with tags that can surprise the unwary."
10458 msgstr ""
10460 #. type: Content of: <book><chapter><sect1><sect2><para>
10461 #: ../en/ch08-branch.xml:186
10462 msgid ""
10463 "Recall that a tag is stored as a revision to the <filename role=\"special\">."
10464 "hgtags</filename> file. When you create a tag, the changeset in which its "
10465 "recorded refers to an older changeset. When you run <command role=\"hg-cmd"
10466 "\">hg clone -r foo</command> to clone a repository as of tag <literal>foo</"
10467 "literal>, the new clone <emphasis>will not contain any revision newer than "
10468 "the one the tag refers to, including the revision where the tag was created</"
10469 "emphasis>. The result is that you'll get exactly the right subset of the "
10470 "project's history in the new repository, but <emphasis>not</emphasis> the tag "
10471 "you might have expected."
10472 msgstr ""
10474 #. type: Content of: <book><chapter><sect1><sect2><title>
10475 #: ../en/ch08-branch.xml:201
10476 msgid "When permanent tags are too much"
10477 msgstr "当永久标签太多的时候"
10479 #. type: Content of: <book><chapter><sect1><sect2><para>
10480 #: ../en/ch08-branch.xml:203
10481 msgid ""
10482 "Since Mercurial's tags are revision controlled and carried around with a "
10483 "project's history, everyone you work with will see the tags you create. But "
10484 "giving names to revisions has uses beyond simply noting that revision "
10485 "<literal>4237e45506ee</literal> is really <literal>v2.0.2</literal>. If "
10486 "you're trying to track down a subtle bug, you might want a tag to remind you "
10487 "of something like <quote>Anne saw the symptoms with this revision</quote>."
10488 msgstr ""
10490 #. type: Content of: <book><chapter><sect1><sect2><para>
10491 #: ../en/ch08-branch.xml:213
10492 msgid ""
10493 "For cases like this, what you might want to use are <emphasis>local</"
10494 "emphasis> tags. You can create a local tag with the <option role=\"hg-opt-tag"
10495 "\">-l</option> option to the <command role=\"hg-cmd\">hg tag</command> "
10496 "command. This will store the tag in a file called <filename role=\"special"
10497 "\">.hg/localtags</filename>. Unlike <filename role=\"special\">.hgtags</"
10498 "filename>, <filename role=\"special\">.hg/localtags</filename> is not "
10499 "revision controlled. Any tags you create using <option role=\"hg-opt-tag\">-"
10500 "l</option> remain strictly local to the repository you're currently working "
10501 "in."
10502 msgstr ""
10504 #. type: Content of: <book><chapter><sect1><title>
10505 #: ../en/ch08-branch.xml:228
10506 msgid "The flow of changes&emdash;big picture vs. little"
10507 msgstr "修改流程—宏观与微观"
10509 #. type: Content of: <book><chapter><sect1><para>
10510 #: ../en/ch08-branch.xml:230
10511 msgid ""
10512 "To return to the outline I sketched at the beginning of the chapter, let's "
10513 "think about a project that has multiple concurrent pieces of work under "
10514 "development at once."
10515 msgstr ""
10517 #. type: Content of: <book><chapter><sect1><para>
10518 #: ../en/ch08-branch.xml:235
10519 msgid ""
10520 "There might be a push for a new <quote>main</quote> release; a new minor "
10521 "bugfix release to the last main release; and an unexpected <quote>hot fix</"
10522 "quote> to an old release that is now in maintenance mode."
10523 msgstr ""
10525 #. type: Content of: <book><chapter><sect1><para>
10526 #: ../en/ch08-branch.xml:240
10527 msgid ""
10528 "The usual way people refer to these different concurrent directions of "
10529 "development is as <quote>branches</quote>. However, we've already seen "
10530 "numerous times that Mercurial treats <emphasis>all of history</emphasis> as a "
10531 "series of branches and merges. Really, what we have here is two ideas that "
10532 "are peripherally related, but which happen to share a name."
10533 msgstr ""
10535 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10536 #: ../en/ch08-branch.xml:247
10537 msgid ""
10538 "<quote>Big picture</quote> branches represent the sweep of a project's "
10539 "evolution; people give them names, and talk about them in conversation."
10540 msgstr ""
10542 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10543 #: ../en/ch08-branch.xml:251
10544 msgid ""
10545 "<quote>Little picture</quote> branches are artefacts of the day-to-day "
10546 "activity of developing and merging changes. They expose the narrative of how "
10547 "the code was developed."
10548 msgstr ""
10550 #. type: Content of: <book><chapter><sect1><title>
10551 #: ../en/ch08-branch.xml:259
10552 msgid "Managing big-picture branches in repositories"
10553 msgstr "在版本库中管理分支"
10555 #. type: Content of: <book><chapter><sect1><para>
10556 #: ../en/ch08-branch.xml:261
10557 msgid ""
10558 "The easiest way to isolate a <quote>big picture</quote> branch in Mercurial "
10559 "is in a dedicated repository. If you have an existing shared "
10560 "repository&emdash;let's call it <literal>myproject</literal>&emdash;that "
10561 "reaches a <quote>1.0</quote> milestone, you can start to prepare for future "
10562 "maintenance releases on top of version 1.0 by tagging the revision from which "
10563 "you prepared the 1.0 release."
10564 msgstr ""
10566 #. type: Content of: <book><chapter><sect1><para>
10567 #: ../en/ch08-branch.xml:271
10568 msgid ""
10569 "You can then clone a new shared <literal>myproject-1.0.1</literal> repository "
10570 "as of that tag."
10571 msgstr ""
10573 #. type: Content of: <book><chapter><sect1><para>
10574 #: ../en/ch08-branch.xml:277
10575 msgid ""
10576 "Afterwards, if someone needs to work on a bug fix that ought to go into an "
10577 "upcoming 1.0.1 minor release, they clone the <literal>myproject-1.0.1</"
10578 "literal> repository, make their changes, and push them back."
10579 msgstr ""
10581 #. type: Content of: <book><chapter><sect1><para>
10582 #: ../en/ch08-branch.xml:284
10583 msgid ""
10584 "Meanwhile, development for the next major release can continue, isolated and "
10585 "unabated, in the <literal>myproject</literal> repository."
10586 msgstr ""
10588 #. type: Content of: <book><chapter><sect1><title>
10589 #: ../en/ch08-branch.xml:292
10590 msgid "Don't repeat yourself: merging across branches"
10591 msgstr "不要重复劳动:在分支间合并"
10593 #. type: Content of: <book><chapter><sect1><para>
10594 #: ../en/ch08-branch.xml:294
10595 msgid ""
10596 "In many cases, if you have a bug to fix on a maintenance branch, the chances "
10597 "are good that the bug exists on your project's main branch (and possibly "
10598 "other maintenance branches, too). It's a rare developer who wants to fix the "
10599 "same bug multiple times, so let's look at a few ways that Mercurial can help "
10600 "you to manage these bugfixes without duplicating your work."
10601 msgstr ""
10603 #. type: Content of: <book><chapter><sect1><para>
10604 #: ../en/ch08-branch.xml:302
10605 msgid ""
10606 "In the simplest instance, all you need to do is pull changes from your "
10607 "maintenance branch into your local clone of the target branch."
10608 msgstr ""
10610 #. type: Content of: <book><chapter><sect1><para>
10611 #: ../en/ch08-branch.xml:308
10612 msgid ""
10613 "You'll then need to merge the heads of the two branches, and push back to the "
10614 "main branch."
10615 msgstr ""
10617 #. type: Content of: <book><chapter><sect1><title>
10618 #: ../en/ch08-branch.xml:315
10619 msgid "Naming branches within one repository"
10620 msgstr "版本库中的命名分支"
10622 #. type: Content of: <book><chapter><sect1><para>
10623 #: ../en/ch08-branch.xml:317
10624 msgid ""
10625 "In most instances, isolating branches in repositories is the right approach. "
10626 "Its simplicity makes it easy to understand; and so it's hard to make "
10627 "mistakes. There's a one-to-one relationship between branches you're working "
10628 "in and directories on your system. This lets you use normal (non-Mercurial-"
10629 "aware) tools to work on files within a branch/repository."
10630 msgstr ""
10632 #. type: Content of: <book><chapter><sect1><para>
10633 #: ../en/ch08-branch.xml:324
10634 msgid ""
10635 "If you're more in the <quote>power user</quote> category (<emphasis>and</"
10636 "emphasis> your collaborators are too), there is an alternative way of "
10637 "handling branches that you can consider. I've already mentioned the human-"
10638 "level distinction between <quote>small picture</quote> and <quote>big "
10639 "picture</quote> branches. While Mercurial works with multiple <quote>small "
10640 "picture</quote> branches in a repository all the time (for example after you "
10641 "pull changes in, but before you merge them), it can <emphasis>also</emphasis> "
10642 "work with multiple <quote>big picture</quote> branches."
10643 msgstr ""
10645 #. type: Content of: <book><chapter><sect1><para>
10646 #: ../en/ch08-branch.xml:335
10647 msgid ""
10648 "The key to working this way is that Mercurial lets you assign a persistent "
10649 "<emphasis>name</emphasis> to a branch. There always exists a branch named "
10650 "<literal>default</literal>. Even before you start naming branches yourself, "
10651 "you can find traces of the <literal>default</literal> branch if you look for "
10652 "them."
10653 msgstr ""
10655 #. type: Content of: <book><chapter><sect1><para>
10656 #: ../en/ch08-branch.xml:342
10657 msgid ""
10658 "As an example, when you run the <command role=\"hg-cmd\">hg commit</command> "
10659 "command, and it pops up your editor so that you can enter a commit message, "
10660 "look for a line that contains the text <quote><literal>HG: branch default</"
10661 "literal></quote> at the bottom. This is telling you that your commit will "
10662 "occur on the branch named <literal>default</literal>."
10663 msgstr ""
10665 #. type: Content of: <book><chapter><sect1><para>
10666 #: ../en/ch08-branch.xml:349
10667 msgid ""
10668 "To start working with named branches, use the <command role=\"hg-cmd\">hg "
10669 "branches</command> command. This command lists the named branches already "
10670 "present in your repository, telling you which changeset is the tip of each."
10671 msgstr ""
10673 #. type: Content of: <book><chapter><sect1><para>
10674 #: ../en/ch08-branch.xml:356
10675 msgid ""
10676 "Since you haven't created any named branches yet, the only one that exists is "
10677 "<literal>default</literal>."
10678 msgstr ""
10680 #. type: Content of: <book><chapter><sect1><para>
10681 #: ../en/ch08-branch.xml:359
10682 msgid ""
10683 "To find out what the <quote>current</quote> branch is, run the <command role="
10684 "\"hg-cmd\">hg branch</command> command, giving it no arguments. This tells "
10685 "you what branch the parent of the current changeset is on."
10686 msgstr ""
10689 #. type: Content of: <book><chapter><sect1><para>
10690 #: ../en/ch08-branch.xml:366
10691 msgid ""
10692 "To create a new branch, run the <command role=\"hg-cmd\">hg branch</command> "
10693 "command again. This time, give it one argument: the name of the branch you "
10694 "want to create."
10695 msgstr ""
10697 #. type: Content of: <book><chapter><sect1><para>
10698 #: ../en/ch08-branch.xml:372
10699 msgid ""
10700 "After you've created a branch, you might wonder what effect the <command role="
10701 "\"hg-cmd\">hg branch</command> command has had. What do the <command role="
10702 "\"hg-cmd\">hg status</command> and <command role=\"hg-cmd\">hg tip</command> "
10703 "commands report?"
10704 msgstr ""
10706 #. type: Content of: <book><chapter><sect1><para>
10707 #: ../en/ch08-branch.xml:379
10708 msgid ""
10709 "Nothing has changed in the working directory, and there's been no new history "
10710 "created. As this suggests, running the <command role=\"hg-cmd\">hg branch</"
10711 "command> command has no permanent effect; it only tells Mercurial what branch "
10712 "name to use the <emphasis>next</emphasis> time you commit a changeset."
10713 msgstr ""
10715 #. type: Content of: <book><chapter><sect1><para>
10716 #: ../en/ch08-branch.xml:386
10717 msgid ""
10718 "When you commit a change, Mercurial records the name of the branch on which "
10719 "you committed. Once you've switched from the <literal>default</literal> "
10720 "branch to another and committed, you'll see the name of the new branch show "
10721 "up in the output of <command role=\"hg-cmd\">hg log</command>, <command role="
10722 "\"hg-cmd\">hg tip</command>, and other commands that display the same kind of "
10723 "output."
10724 msgstr ""
10726 #. type: Content of: <book><chapter><sect1><para>
10727 #: ../en/ch08-branch.xml:396
10728 msgid ""
10729 "The <command role=\"hg-cmd\">hg log</command>-like commands will print the "
10730 "branch name of every changeset that's not on the <literal>default</literal> "
10731 "branch. As a result, if you never use named branches, you'll never see this "
10732 "information."
10733 msgstr ""
10735 #. type: Content of: <book><chapter><sect1><para>
10736 #: ../en/ch08-branch.xml:401
10737 msgid ""
10738 "Once you've named a branch and committed a change with that name, every "
10739 "subsequent commit that descends from that change will inherit the same branch "
10740 "name. You can change the name of a branch at any time, using the <command "
10741 "role=\"hg-cmd\">hg branch</command> command."
10742 msgstr ""
10744 #. type: Content of: <book><chapter><sect1><para>
10745 #: ../en/ch08-branch.xml:409
10746 msgid ""
10747 "In practice, this is something you won't do very often, as branch names tend "
10748 "to have fairly long lifetimes. (This isn't a rule, just an observation.)"
10749 msgstr ""
10751 #. type: Content of: <book><chapter><sect1><title>
10752 #: ../en/ch08-branch.xml:415
10753 msgid "Dealing with multiple named branches in a repository"
10754 msgstr "在版本库中处理多个命名分支"
10756 #. type: Content of: <book><chapter><sect1><para>
10757 #: ../en/ch08-branch.xml:418
10758 msgid ""
10759 "If you have more than one named branch in a repository, Mercurial will "
10760 "remember the branch that your working directory is on when you start a "
10761 "command like <command role=\"hg-cmd\">hg update</command> or <command role="
10762 "\"hg-cmd\">hg pull -u</command>. It will update the working directory to the "
10763 "tip of this branch, no matter what the <quote>repo-wide</quote> tip is. To "
10764 "update to a revision that's on a different named branch, you may need to use "
10765 "the <option role=\"hg-opt-update\">-C</option> option to <command role=\"hg-"
10766 "cmd\">hg update</command>."
10767 msgstr ""
10769 #. type: Content of: <book><chapter><sect1><para>
10770 #: ../en/ch08-branch.xml:428
10771 msgid ""
10772 "This behavior is a little subtle, so let's see it in action. First, let's "
10773 "remind ourselves what branch we're currently on, and what branches are in our "
10774 "repository."
10775 msgstr ""
10777 #. type: Content of: <book><chapter><sect1><para>
10778 #: ../en/ch08-branch.xml:434
10779 msgid ""
10780 "We're on the <literal>bar</literal> branch, but there also exists an older "
10781 "<command role=\"hg-cmd\">hg foo</command> branch."
10782 msgstr ""
10784 #. type: Content of: <book><chapter><sect1><para>
10785 #: ../en/ch08-branch.xml:438
10786 msgid ""
10787 "We can <command role=\"hg-cmd\">hg update</command> back and forth between "
10788 "the tips of the <literal>foo</literal> and <literal>bar</literal> branches "
10789 "without needing to use the <option role=\"hg-opt-update\">-C</option> option, "
10790 "because this only involves going backwards and forwards linearly through our "
10791 "change history."
10792 msgstr ""
10795 #. type: Content of: <book><chapter><sect1><para>
10796 #: ../en/ch08-branch.xml:447
10797 msgid ""
10798 "If we go back to the <literal>foo</literal> branch and then run <command role="
10799 "\"hg-cmd\">hg update</command>, it will keep us on <literal>foo</literal>, "
10800 "not move us to the tip of <literal>bar</literal>."
10801 msgstr ""
10804 #. type: Content of: <book><chapter><sect1><para>
10805 #: ../en/ch08-branch.xml:454
10806 msgid ""
10807 "Committing a new change on the <literal>foo</literal> branch introduces a new "
10808 "head."
10809 msgstr ""
10811 #. type: Content of: <book><chapter><sect1><title>
10812 #: ../en/ch08-branch.xml:461
10813 msgid "Branch names and merging"
10814 msgstr "分支名称与合并"
10816 #. type: Content of: <book><chapter><sect1><para>
10817 #: ../en/ch08-branch.xml:463
10818 msgid ""
10819 "As you've probably noticed, merges in Mercurial are not symmetrical. Let's "
10820 "say our repository has two heads, 17 and 23. If I <command role=\"hg-cmd"
10821 "\">hg update</command> to 17 and then <command role=\"hg-cmd\">hg merge</"
10822 "command> with 23, Mercurial records 17 as the first parent of the merge, and "
10823 "23 as the second. Whereas if I <command role=\"hg-cmd\">hg update</command> "
10824 "to 23 and then <command role=\"hg-cmd\">hg merge</command> with 17, it "
10825 "records 23 as the first parent, and 17 as the second."
10826 msgstr ""
10828 #. type: Content of: <book><chapter><sect1><para>
10829 #: ../en/ch08-branch.xml:473
10830 msgid ""
10831 "This affects Mercurial's choice of branch name when you merge. After a "
10832 "merge, Mercurial will retain the branch name of the first parent when you "
10833 "commit the result of the merge. If your first parent's branch name is "
10834 "<literal>foo</literal>, and you merge with <literal>bar</literal>, the branch "
10835 "name will still be <literal>foo</literal> after you merge."
10836 msgstr ""
10838 #. type: Content of: <book><chapter><sect1><para>
10839 #: ../en/ch08-branch.xml:480
10840 msgid ""
10841 "It's not unusual for a repository to contain multiple heads, each with the "
10842 "same branch name. Let's say I'm working on the <literal>foo</literal> "
10843 "branch, and so are you. We commit different changes; I pull your changes; I "
10844 "now have two heads, each claiming to be on the <literal>foo</literal> "
10845 "branch. The result of a merge will be a single head on the <literal>foo</"
10846 "literal> branch, as you might hope."
10847 msgstr ""
10850 #. type: Content of: <book><chapter><sect1><para>
10851 #: ../en/ch08-branch.xml:488
10852 msgid ""
10853 "But if I'm working on the <literal>bar</literal> branch, and I merge work "
10854 "from the <literal>foo</literal> branch, the result will remain on the "
10855 "<literal>bar</literal> branch."
10856 msgstr ""
10858 #. type: Content of: <book><chapter><sect1><para>
10859 #: ../en/ch08-branch.xml:494
10860 msgid ""
10861 "To give a more concrete example, if I'm working on the <literal>bleeding-"
10862 "edge</literal> branch, and I want to bring in the latest fixes from the "
10863 "<literal>stable</literal> branch, Mercurial will choose the <quote>right</"
10864 "quote> (<literal>bleeding-edge</literal>) branch name when I pull and merge "
10865 "from <literal>stable</literal>."
10866 msgstr ""
10868 #. type: Content of: <book><chapter><sect1><title>
10869 #: ../en/ch08-branch.xml:503
10870 msgid "Branch naming is generally useful"
10871 msgstr "分支名称通常都很有用"
10873 #. type: Content of: <book><chapter><sect1><para>
10874 #: ../en/ch08-branch.xml:505
10875 msgid ""
10876 "You shouldn't think of named branches as applicable only to situations where "
10877 "you have multiple long-lived branches cohabiting in a single repository. "
10878 "They're very useful even in the one-branch-per-repository case."
10879 msgstr ""
10881 #. type: Content of: <book><chapter><sect1><para>
10882 #: ../en/ch08-branch.xml:510
10883 msgid ""
10884 "In the simplest case, giving a name to each branch gives you a permanent "
10885 "record of which branch a changeset originated on. This gives you more "
10886 "context when you're trying to follow the history of a long-lived branchy "
10887 "project."
10888 msgstr ""
10890 #. type: Content of: <book><chapter><sect1><para>
10891 #: ../en/ch08-branch.xml:515
10892 msgid ""
10893 "If you're working with shared repositories, you can set up a <literal role="
10894 "\"hook\">pretxnchangegroup</literal> hook on each that will block incoming "
10895 "changes that have the <quote>wrong</quote> branch name. This provides a "
10896 "simple, but effective, defence against people accidentally pushing changes "
10897 "from a <quote>bleeding edge</quote> branch to a <quote>stable</quote> "
10898 "branch. Such a hook might look like this inside the shared repo's <filename "
10899 "role=\"special\"> /.hgrc</filename>."
10900 msgstr ""
10902 #. type: Content of: <book><chapter><title>
10903 #: ../en/ch09-undo.xml:5
10904 msgid "Finding and fixing mistakes"
10905 msgstr "查找和修改错误"
10907 #. type: Content of: <book><chapter><para>
10908 #: ../en/ch09-undo.xml:7
10909 msgid ""
10910 "To err might be human, but to really handle the consequences well takes a top-"
10911 "notch revision control system. In this chapter, we'll discuss some of the "
10912 "techniques you can use when you find that a problem has crept into your "
10913 "project. Mercurial has some highly capable features that will help you to "
10914 "isolate the sources of problems, and to handle them appropriately."
10915 msgstr ""
10917 #. type: Content of: <book><chapter><sect1><title>
10918 #: ../en/ch09-undo.xml:15
10919 msgid "Erasing local history"
10920 msgstr "销毁本地历史"
10922 #. type: Content of: <book><chapter><sect1><sect2><title>
10923 #: ../en/ch09-undo.xml:18
10924 msgid "The accidental commit"
10925 msgstr "意外的提交"
10927 #. type: Content of: <book><chapter><sect1><sect2><para>
10928 #: ../en/ch09-undo.xml:20
10929 msgid ""
10930 "I have the occasional but persistent problem of typing rather more quickly "
10931 "than I can think, which sometimes results in me committing a changeset that "
10932 "is either incomplete or plain wrong. In my case, the usual kind of "
10933 "incomplete changeset is one in which I've created a new source file, but "
10934 "forgotten to <command role=\"hg-cmd\">hg add</command> it. A <quote>plain "
10935 "wrong</quote> changeset is not as common, but no less annoying."
10936 msgstr ""
10938 #. type: Content of: <book><chapter><sect1><sect2><title>
10939 #: ../en/ch09-undo.xml:31
10940 msgid "Rolling back a transaction"
10941 msgstr "回滚一个事务"
10943 #. type: Content of: <book><chapter><sect1><sect2><para>
10944 #: ../en/ch09-undo.xml:33
10945 msgid ""
10946 "In <xref linkend=\"sec:concepts:txn\"/>, I mentioned that Mercurial treats "
10947 "each modification of a repository as a <emphasis>transaction</emphasis>. "
10948 "Every time you commit a changeset or pull changes from another repository, "
10949 "Mercurial remembers what you did. You can undo, or <emphasis>roll back</"
10950 "emphasis>, exactly one of these actions using the <command role=\"hg-cmd\">hg "
10951 "rollback</command> command. (See <xref linkend=\"sec:undo:rollback-after-push"
10952 "\"/> for an important caveat about the use of this command.)"
10953 msgstr ""
10955 #. type: Content of: <book><chapter><sect1><sect2><para>
10956 #: ../en/ch09-undo.xml:43
10957 msgid ""
10958 "Here's a mistake that I often find myself making: committing a change in "
10959 "which I've created a new file, but forgotten to <command role=\"hg-cmd\">hg "
10960 "add</command> it."
10961 msgstr ""
10963 #. type: Content of: <book><chapter><sect1><sect2><para>
10964 #: ../en/ch09-undo.xml:50
10965 msgid ""
10966 "Looking at the output of <command role=\"hg-cmd\">hg status</command> after "
10967 "the commit immediately confirms the error."
10968 msgstr ""
10970 #. type: Content of: <book><chapter><sect1><sect2><para>
10971 #: ../en/ch09-undo.xml:56
10972 msgid ""
10973 "The commit captured the changes to the file <filename>a</filename>, but not "
10974 "the new file <filename>b</filename>. If I were to push this changeset to a "
10975 "repository that I shared with a colleague, the chances are high that "
10976 "something in <filename>a</filename> would refer to <filename>b</filename>, "
10977 "which would not be present in their repository when they pulled my changes. "
10978 "I would thus become the object of some indignation."
10979 msgstr ""
10981 #. type: Content of: <book><chapter><sect1><sect2><para>
10982 #: ../en/ch09-undo.xml:65
10983 msgid ""
10984 "However, luck is with me&emdash;I've caught my error before I pushed the "
10985 "changeset. I use the <command role=\"hg-cmd\">hg rollback</command> command, "
10986 "and Mercurial makes that last changeset vanish."
10987 msgstr ""
10989 #. type: Content of: <book><chapter><sect1><sect2><para>
10990 #: ../en/ch09-undo.xml:72
10991 msgid ""
10992 "Notice that the changeset is no longer present in the repository's history, "
10993 "and the working directory once again thinks that the file <filename>a</"
10994 "filename> is modified. The commit and rollback have left the working "
10995 "directory exactly as it was prior to the commit; the changeset has been "
10996 "completely erased. I can now safely <command role=\"hg-cmd\">hg add</"
10997 "command> the file <filename>b</filename>, and rerun my commit."
10998 msgstr ""
11000 #. type: Content of: <book><chapter><sect1><sect2><title>
11001 #: ../en/ch09-undo.xml:85
11002 msgid "The erroneous pull"
11003 msgstr "错误的抓取"
11005 #. type: Content of: <book><chapter><sect1><sect2><para>
11006 #: ../en/ch09-undo.xml:87
11007 msgid ""
11008 "It's common practice with Mercurial to maintain separate development branches "
11009 "of a project in different repositories. Your development team might have one "
11010 "shared repository for your project's <quote>0.9</quote> release, and another, "
11011 "containing different changes, for the <quote>1.0</quote> release."
11012 msgstr ""
11014 #. type: Content of: <book><chapter><sect1><sect2><para>
11015 #: ../en/ch09-undo.xml:94
11016 msgid ""
11017 "Given this, you can imagine that the consequences could be messy if you had a "
11018 "local <quote>0.9</quote> repository, and accidentally pulled changes from the "
11019 "shared <quote>1.0</quote> repository into it. At worst, you could be paying "
11020 "insufficient attention, and push those changes into the shared <quote>0.9</"
11021 "quote> tree, confusing your entire team (but don't worry, we'll return to "
11022 "this horror scenario later). However, it's more likely that you'll notice "
11023 "immediately, because Mercurial will display the URL it's pulling from, or you "
11024 "will see it pull a suspiciously large number of changes into the repository."
11025 msgstr ""
11027 #. type: Content of: <book><chapter><sect1><sect2><para>
11028 #: ../en/ch09-undo.xml:106
11029 msgid ""
11030 "The <command role=\"hg-cmd\">hg rollback</command> command will work nicely "
11031 "to expunge all of the changesets that you just pulled. Mercurial groups all "
11032 "changes from one <command role=\"hg-cmd\">hg pull</command> into a single "
11033 "transaction, so one <command role=\"hg-cmd\">hg rollback</command> is all you "
11034 "need to undo this mistake."
11035 msgstr ""
11037 #. type: Content of: <book><chapter><sect1><sect2><title>
11038 #: ../en/ch09-undo.xml:115
11039 msgid "Rolling back is useless once you've pushed"
11040 msgstr "当完成推送后,回滚是无效的"
11042 #. type: Content of: <book><chapter><sect1><sect2><para>
11043 #: ../en/ch09-undo.xml:117
11044 msgid ""
11045 "The value of the <command role=\"hg-cmd\">hg rollback</command> command drops "
11046 "to zero once you've pushed your changes to another repository. Rolling back "
11047 "a change makes it disappear entirely, but <emphasis>only</emphasis> in the "
11048 "repository in which you perform the <command role=\"hg-cmd\">hg rollback</"
11049 "command>. Because a rollback eliminates history, there's no way for the "
11050 "disappearance of a change to propagate between repositories."
11051 msgstr ""
11053 #. type: Content of: <book><chapter><sect1><sect2><para>
11054 #: ../en/ch09-undo.xml:126
11055 msgid ""
11056 "If you've pushed a change to another repository&emdash;particularly if it's a "
11057 "shared repository&emdash;it has essentially <quote>escaped into the wild,</"
11058 "quote> and you'll have to recover from your mistake in a different way. If "
11059 "you push a changeset somewhere, then roll it back, then pull from the "
11060 "repository you pushed to, the changeset you thought you'd gotten rid of will "
11061 "simply reappear in your repository."
11062 msgstr ""
11064 #. type: Content of: <book><chapter><sect1><sect2><para>
11065 #: ../en/ch09-undo.xml:135
11066 msgid ""
11067 "(If you absolutely know for sure that the change you want to roll back is the "
11068 "most recent change in the repository that you pushed to, <emphasis>and</"
11069 "emphasis> you know that nobody else could have pulled it from that "
11070 "repository, you can roll back the changeset there, too, but you really should "
11071 "not expect this to work reliably. Sooner or later a change really will make "
11072 "it into a repository that you don't directly control (or have forgotten "
11073 "about), and come back to bite you.)"
11074 msgstr ""
11076 #. type: Content of: <book><chapter><sect1><sect2><title>
11077 #: ../en/ch09-undo.xml:147
11078 msgid "You can only roll back once"
11079 msgstr "你只能回滚一次"
11081 #. type: Content of: <book><chapter><sect1><sect2><para>
11082 #: ../en/ch09-undo.xml:149
11083 msgid ""
11084 "Mercurial stores exactly one transaction in its transaction log; that "
11085 "transaction is the most recent one that occurred in the repository. This "
11086 "means that you can only roll back one transaction. If you expect to be able "
11087 "to roll back one transaction, then its predecessor, this is not the behavior "
11088 "you will get."
11089 msgstr ""
11091 #. type: Content of: <book><chapter><sect1><sect2><para>
11092 #: ../en/ch09-undo.xml:158
11093 msgid ""
11094 "Once you've rolled back one transaction in a repository, you can't roll back "
11095 "again in that repository until you perform another commit or pull."
11096 msgstr ""
11098 #. type: Content of: <book><chapter><sect1><title>
11099 #: ../en/ch09-undo.xml:165
11100 msgid "Reverting the mistaken change"
11101 msgstr "撤销错误的修改"
11103 #. type: Content of: <book><chapter><sect1><para>
11104 #: ../en/ch09-undo.xml:167
11105 msgid ""
11106 "If you make a modification to a file, and decide that you really didn't want "
11107 "to change the file at all, and you haven't yet committed your changes, the "
11108 "<command role=\"hg-cmd\">hg revert</command> command is the one you'll need. "
11109 "It looks at the changeset that's the parent of the working directory, and "
11110 "restores the contents of the file to their state as of that changeset. "
11111 "(That's a long-winded way of saying that, in the normal case, it undoes your "
11112 "modifications.)"
11113 msgstr ""
11115 #. type: Content of: <book><chapter><sect1><para>
11116 #: ../en/ch09-undo.xml:176
11117 msgid ""
11118 "Let's illustrate how the <command role=\"hg-cmd\">hg revert</command> command "
11119 "works with yet another small example. We'll begin by modifying a file that "
11120 "Mercurial is already tracking."
11121 msgstr ""
11123 #. type: Content of: <book><chapter><sect1><para>
11124 #: ../en/ch09-undo.xml:183
11125 msgid ""
11126 "If we don't want that change, we can simply <command role=\"hg-cmd\">hg "
11127 "revert</command> the file."
11128 msgstr ""
11130 #. type: Content of: <book><chapter><sect1><para>
11131 #: ../en/ch09-undo.xml:189
11132 msgid ""
11133 "The <command role=\"hg-cmd\">hg revert</command> command provides us with an "
11134 "extra degree of safety by saving our modified file with a <filename>.orig</"
11135 "filename> extension."
11136 msgstr ""
11138 #. type: Content of: <book><chapter><sect1><tip><title>
11139 #: ../en/ch09-undo.xml:197
11140 msgid "Be careful with <filename>.orig</filename> files"
11141 msgstr "小心 <filename>.orig</filename> 文件"
11143 #. type: Content of: <book><chapter><sect1><tip><para>
11144 #: ../en/ch09-undo.xml:199
11145 msgid ""
11146 "It's extremely unlikely that you are either using Mercurial to manage files "
11147 "with <filename>.orig</filename> extensions or that you even care about the "
11148 "contents of such files. Just in case, though, it's useful to remember that "
11149 "<command role=\"hg-cmd\">hg revert</command> will unconditionally overwrite "
11150 "an existing file with a <filename>.orig</filename> extension. For instance, "
11151 "if you already have a file named <filename>foo.orig</filename> when you "
11152 "revert <filename>foo</filename>, the contents of <filename>foo.orig</"
11153 "filename> will be clobbered."
11154 msgstr ""
11156 #. type: Content of: <book><chapter><sect1><para>
11157 #: ../en/ch09-undo.xml:211
11158 msgid ""
11159 "Here is a summary of the cases that the <command role=\"hg-cmd\">hg revert</"
11160 "command> command can deal with. We will describe each of these in more "
11161 "detail in the section that follows."
11162 msgstr ""
11164 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
11165 #: ../en/ch09-undo.xml:216
11166 msgid "If you modify a file, it will restore the file to its unmodified state."
11167 msgstr ""
11169 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
11170 #: ../en/ch09-undo.xml:219
11171 msgid ""
11172 "If you <command role=\"hg-cmd\">hg add</command> a file, it will undo the "
11173 "<quote>added</quote> state of the file, but leave the file itself untouched."
11174 msgstr ""
11176 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
11177 #: ../en/ch09-undo.xml:223
11178 msgid ""
11179 "If you delete a file without telling Mercurial, it will restore the file to "
11180 "its unmodified contents."
11181 msgstr ""
11183 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
11184 #: ../en/ch09-undo.xml:226
11185 msgid ""
11186 "If you use the <command role=\"hg-cmd\">hg remove</command> command to remove "
11187 "a file, it will undo the <quote>removed</quote> state of the file, and "
11188 "restore the file to its unmodified contents."
11189 msgstr ""
11191 #. type: Content of: <book><chapter><sect1><sect2><title>
11192 #: ../en/ch09-undo.xml:233
11193 msgid "File management errors"
11194 msgstr "文件管理错误"
11196 #. type: Content of: <book><chapter><sect1><sect2><para>
11197 #: ../en/ch09-undo.xml:235
11198 msgid ""
11199 "The <command role=\"hg-cmd\">hg revert</command> command is useful for more "
11200 "than just modified files. It lets you reverse the results of all of "
11201 "Mercurial's file management commands&emdash;<command role=\"hg-cmd\">hg add</"
11202 "command>, <command role=\"hg-cmd\">hg remove</command>, and so on."
11203 msgstr ""
11206 #. type: Content of: <book><chapter><sect1><sect2><para>
11207 #: ../en/ch09-undo.xml:241
11208 msgid ""
11209 "If you <command role=\"hg-cmd\">hg add</command> a file, then decide that in "
11210 "fact you don't want Mercurial to track it, use <command role=\"hg-cmd\">hg "
11211 "revert</command> to undo the add. Don't worry; Mercurial will not modify the "
11212 "file in any way. It will just <quote>unmark</quote> the file."
11213 msgstr ""
11215 #. type: Content of: <book><chapter><sect1><sect2><para>
11216 #: ../en/ch09-undo.xml:249
11217 msgid ""
11218 "Similarly, if you ask Mercurial to <command role=\"hg-cmd\">hg remove</"
11219 "command> a file, you can use <command role=\"hg-cmd\">hg revert</command> to "
11220 "restore it to the contents it had as of the parent of the working directory. "
11221 "&interaction.daily.revert.remove; This works just as well for a file that you "
11222 "deleted by hand, without telling Mercurial (recall that in Mercurial "
11223 "terminology, this kind of file is called <quote>missing</quote>)."
11224 msgstr ""
11227 #. type: Content of: <book><chapter><sect1><sect2><para>
11228 #: ../en/ch09-undo.xml:260
11229 msgid ""
11230 "If you revert a <command role=\"hg-cmd\">hg copy</command>, the copied-to "
11231 "file remains in your working directory afterwards, untracked. Since a copy "
11232 "doesn't affect the copied-from file in any way, Mercurial doesn't do anything "
11233 "with the copied-from file."
11234 msgstr ""
11236 #. type: Content of: <book><chapter><sect1><title>
11237 #: ../en/ch09-undo.xml:271
11238 msgid "Dealing with committed changes"
11239 msgstr "处理已经提交的修改"
11241 #. type: Content of: <book><chapter><sect1><para>
11242 #: ../en/ch09-undo.xml:273
11243 msgid ""
11244 "Consider a case where you have committed a change <emphasis>a</emphasis>, and "
11245 "another change <emphasis>b</emphasis> on top of it; you then realise that "
11246 "change <emphasis>a</emphasis> was incorrect. Mercurial lets you <quote>back "
11247 "out</quote> an entire changeset automatically, and building blocks that let "
11248 "you reverse part of a changeset by hand."
11249 msgstr ""
11251 #. type: Content of: <book><chapter><sect1><para>
11252 #: ../en/ch09-undo.xml:281
11253 msgid ""
11254 "Before you read this section, here's something to keep in mind: the <command "
11255 "role=\"hg-cmd\">hg backout</command> command undoes the effect of a change by "
11256 "<emphasis>adding</emphasis> to your repository's history, not by modifying or "
11257 "erasing it. It's the right tool to use if you're fixing bugs, but not if "
11258 "you're trying to undo some change that has catastrophic consequences. To "
11259 "deal with those, see <xref linkend=\"sec:undo:aaaiiieee\"/>."
11260 msgstr ""
11262 #. type: Content of: <book><chapter><sect1><sect2><title>
11263 #: ../en/ch09-undo.xml:291
11264 msgid "Backing out a changeset"
11265 msgstr "恢复一个修改集"
11267 #. type: Content of: <book><chapter><sect1><sect2><para>
11268 #: ../en/ch09-undo.xml:293
11269 msgid ""
11270 "The <command role=\"hg-cmd\">hg backout</command> command lets you "
11271 "<quote>undo</quote> the effects of an entire changeset in an automated "
11272 "fashion. Because Mercurial's history is immutable, this command "
11273 "<emphasis>does not</emphasis> get rid of the changeset you want to undo. "
11274 "Instead, it creates a new changeset that <emphasis>reverses</emphasis> the "
11275 "effect of the to-be-undone changeset."
11276 msgstr ""
11279 #. type: Content of: <book><chapter><sect1><sect2><para>
11280 #: ../en/ch09-undo.xml:302
11281 msgid ""
11282 "The operation of the <command role=\"hg-cmd\">hg backout</command> command is "
11283 "a little intricate, so let's illustrate it with some examples. First, we'll "
11284 "create a repository with some simple changes."
11285 msgstr ""
11287 #. type: Content of: <book><chapter><sect1><sect2><para>
11288 #: ../en/ch09-undo.xml:309
11289 msgid ""
11290 "The <command role=\"hg-cmd\">hg backout</command> command takes a single "
11291 "changeset ID as its argument; this is the changeset to back out. Normally, "
11292 "<command role=\"hg-cmd\">hg backout</command> will drop you into a text "
11293 "editor to write a commit message, so you can record why you're backing the "
11294 "change out. In this example, we provide a commit message on the command line "
11295 "using the <option role=\"hg-opt-backout\">-m</option> option."
11296 msgstr ""
11298 #. type: Content of: <book><chapter><sect1><sect2><title>
11299 #: ../en/ch09-undo.xml:320
11300 msgid "Backing out the tip changeset"
11301 msgstr "恢复顶点修改集"
11303 #. type: Content of: <book><chapter><sect1><sect2><para>
11304 #: ../en/ch09-undo.xml:322
11305 msgid "We're going to start by backing out the last changeset we committed."
11306 msgstr ""
11308 #. type: Content of: <book><chapter><sect1><sect2><para>
11309 #: ../en/ch09-undo.xml:327
11310 msgid ""
11311 "You can see that the second line from <filename>myfile</filename> is no "
11312 "longer present. Taking a look at the output of <command role=\"hg-cmd\">hg "
11313 "log</command> gives us an idea of what the <command role=\"hg-cmd\">hg "
11314 "backout</command> command has done. &interaction.backout.simple.log; Notice "
11315 "that the new changeset that <command role=\"hg-cmd\">hg backout</command> has "
11316 "created is a child of the changeset we backed out. It's easier to see this "
11317 "in <xref linkend=\"fig:undo:backout\"/>, which presents a graphical view of "
11318 "the change history. As you can see, the history is nice and linear."
11319 msgstr ""
11321 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
11322 #: ../en/ch09-undo.xml:340 ../en/ch09-undo.xml:460
11323 msgid ""
11324 "Backing out a change using the <command role=\"hg-cmd\">hg backout</command> "
11325 "command"
11326 msgstr "使用 <command role=\"hg-cmd\">hg backout</command> 恢复一个修改"
11328 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
11329 #: ../en/ch09-undo.xml:343
11330 msgid "<imageobject><imagedata fileref=\"figs/undo-simple.png\"/></imageobject>"
11331 msgstr ""
11333 #. type: Content of: <book><chapter><sect1><sect2><title>
11334 #: ../en/ch09-undo.xml:350
11335 msgid "Backing out a non-tip change"
11336 msgstr "恢复非顶点的修改"
11338 #. type: Content of: <book><chapter><sect1><sect2><para>
11339 #: ../en/ch09-undo.xml:352
11340 msgid ""
11341 "If you want to back out a change other than the last one you committed, pass "
11342 "the <option role=\"hg-opt-backout\">--merge</option> option to the <command "
11343 "role=\"hg-cmd\">hg backout</command> command."
11344 msgstr ""
11346 #. type: Content of: <book><chapter><sect1><sect2><para>
11347 #: ../en/ch09-undo.xml:359
11348 msgid ""
11349 "This makes backing out any changeset a <quote>one-shot</quote> operation "
11350 "that's usually simple and fast."
11351 msgstr ""
11353 #. type: Content of: <book><chapter><sect1><sect2><para>
11354 #: ../en/ch09-undo.xml:365
11355 msgid ""
11356 "If you take a look at the contents of <filename>myfile</filename> after the "
11357 "backout finishes, you'll see that the first and third changes are present, "
11358 "but not the second."
11359 msgstr ""
11361 #. type: Content of: <book><chapter><sect1><sect2><para>
11362 #: ../en/ch09-undo.xml:372
11363 msgid ""
11364 "As the graphical history in <xref linkend=\"fig:undo:backout-non-tip\"/> "
11365 "illustrates, Mercurial still commits one change in this kind of situation "
11366 "(the box-shaped node is the ones that Mercurial commits automatically), but "
11367 "the revision graph now looks different. Before Mercurial begins the backout "
11368 "process, it first remembers what the current parent of the working directory "
11369 "is. It then backs out the target changeset, and commits that as a "
11370 "changeset. Finally, it merges back to the previous parent of the working "
11371 "directory, but notice that it <emphasis>does not commit</emphasis> the result "
11372 "of the merge. The repository now contains two heads, and the working "
11373 "directory is in a merge state."
11374 msgstr ""
11376 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
11377 #: ../en/ch09-undo.xml:387
11378 msgid ""
11379 "Automated backout of a non-tip change using the <command role=\"hg-cmd\">hg "
11380 "backout</command> command"
11381 msgstr "使用 <command role=\"hg-cmd\">hg backout</command> 自动恢复非顶点的修改"
11383 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
11384 #: ../en/ch09-undo.xml:390
11385 msgid ""
11386 "<imageobject><imagedata fileref=\"figs/undo-non-tip.png\"/></imageobject>"
11387 msgstr ""
11389 #. type: Content of: <book><chapter><sect1><sect2><para>
11390 #: ../en/ch09-undo.xml:395
11391 msgid ""
11392 "The result is that you end up <quote>back where you were</quote>, only with "
11393 "some extra history that undoes the effect of the changeset you wanted to back "
11394 "out."
11395 msgstr ""
11397 #. type: Content of: <book><chapter><sect1><sect2><para>
11398 #: ../en/ch09-undo.xml:399
11399 msgid ""
11400 "You might wonder why Mercurial does not commit the result of the merge that "
11401 "it performed. The reason lies in Mercurial behaving conservatively: a merge "
11402 "naturally has more scope for error than simply undoing the effect of the tip "
11403 "changeset, so your work will be safest if you first inspect (and test!) the "
11404 "result of the merge, <emphasis>then</emphasis> commit it."
11405 msgstr ""
11407 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
11408 #: ../en/ch09-undo.xml:408
11409 msgid "Always use the <option role=\"hg-opt-backout\">--merge</option> option"
11410 msgstr "始终使用选项 <option role=\"hg-opt-backout\">--merge</option>"
11412 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11413 #: ../en/ch09-undo.xml:411
11414 msgid ""
11415 "In fact, since the <option role=\"hg-opt-backout\">--merge</option> option "
11416 "will do the <quote>right thing</quote> whether or not the changeset you're "
11417 "backing out is the tip (i.e. it won't try to merge if it's backing out the "
11418 "tip, since there's no need), you should <emphasis>always</emphasis> use this "
11419 "option when you run the <command role=\"hg-cmd\">hg backout</command> command."
11420 msgstr ""
11422 #. type: Content of: <book><chapter><sect1><sect2><title>
11423 #: ../en/ch09-undo.xml:422
11424 msgid "Gaining more control of the backout process"
11425 msgstr "在恢复处理中获得更多控制"
11427 #. type: Content of: <book><chapter><sect1><sect2><para>
11428 #: ../en/ch09-undo.xml:424
11429 msgid ""
11430 "While I've recommended that you always use the <option role=\"hg-opt-backout"
11431 "\">--merge</option> option when backing out a change, the <command role=\"hg-"
11432 "cmd\">hg backout</command> command lets you decide how to merge a backout "
11433 "changeset. Taking control of the backout process by hand is something you "
11434 "will rarely need to do, but it can be useful to understand what the <command "
11435 "role=\"hg-cmd\">hg backout</command> command is doing for you automatically. "
11436 "To illustrate this, let's clone our first repository, but omit the backout "
11437 "change that it contains."
11438 msgstr ""
11440 #. type: Content of: <book><chapter><sect1><sect2><para>
11441 #: ../en/ch09-undo.xml:437
11442 msgid ""
11443 "As with our earlier example, We'll commit a third changeset, then back out "
11444 "its parent, and see what happens."
11445 msgstr ""
11447 #. type: Content of: <book><chapter><sect1><sect2><para>
11448 #: ../en/ch09-undo.xml:443
11449 msgid ""
11450 "Our new changeset is again a descendant of the changeset we backout out; it's "
11451 "thus a new head, <emphasis>not</emphasis> a descendant of the changeset that "
11452 "was the tip. The <command role=\"hg-cmd\">hg backout</command> command was "
11453 "quite explicit in telling us this."
11454 msgstr ""
11456 #. type: Content of: <book><chapter><sect1><sect2><para>
11457 #: ../en/ch09-undo.xml:451
11458 msgid ""
11459 "Again, it's easier to see what has happened by looking at a graph of the "
11460 "revision history, in <xref linkend=\"fig:undo:backout-manual\"/>. This makes "
11461 "it clear that when we use <command role=\"hg-cmd\">hg backout</command> to "
11462 "back out a change other than the tip, Mercurial adds a new head to the "
11463 "repository (the change it committed is box-shaped)."
11464 msgstr ""
11466 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
11467 #: ../en/ch09-undo.xml:463
11468 msgid "<imageobject><imagedata fileref=\"figs/undo-manual.png\"/></imageobject>"
11469 msgstr ""
11471 #. type: Content of: <book><chapter><sect1><sect2><para>
11472 #: ../en/ch09-undo.xml:468
11473 msgid ""
11474 "After the <command role=\"hg-cmd\">hg backout</command> command has "
11475 "completed, it leaves the new <quote>backout</quote> changeset as the parent "
11476 "of the working directory."
11477 msgstr ""
11479 #. type: Content of: <book><chapter><sect1><sect2><para>
11480 #: ../en/ch09-undo.xml:475
11481 msgid "Now we have two isolated sets of changes."
11482 msgstr ""
11484 #. type: Content of: <book><chapter><sect1><sect2><para>
11485 #: ../en/ch09-undo.xml:479
11486 msgid ""
11487 "Let's think about what we expect to see as the contents of <filename>myfile</"
11488 "filename> now. The first change should be present, because we've never "
11489 "backed it out. The second change should be missing, as that's the change we "
11490 "backed out. Since the history graph shows the third change as a separate "
11491 "head, we <emphasis>don't</emphasis> expect to see the third change present in "
11492 "<filename>myfile</filename>."
11493 msgstr ""
11495 #. type: Content of: <book><chapter><sect1><sect2><para>
11496 #: ../en/ch09-undo.xml:489
11497 msgid ""
11498 "To get the third change back into the file, we just do a normal merge of our "
11499 "two heads."
11500 msgstr ""
11502 #. type: Content of: <book><chapter><sect1><sect2><para>
11503 #: ../en/ch09-undo.xml:494
11504 msgid ""
11505 "Afterwards, the graphical history of our repository looks like <xref linkend="
11506 "\"fig:undo:backout-manual-merge\"/>."
11507 msgstr ""
11509 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
11510 #: ../en/ch09-undo.xml:499
11511 msgid "Manually merging a backout change"
11512 msgstr "手工合并恢复修改"
11514 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
11515 #: ../en/ch09-undo.xml:501
11516 msgid ""
11517 "<imageobject><imagedata fileref=\"figs/undo-manual-merge.png\"/></imageobject>"
11518 msgstr ""
11520 #. type: Content of: <book><chapter><sect1><sect2><title>
11521 #: ../en/ch09-undo.xml:508
11522 msgid "Why <command role=\"hg-cmd\">hg backout</command> works as it does"
11523 msgstr "<command role=\"hg-cmd\">hg backout</command> 的内幕"
11525 #. type: Content of: <book><chapter><sect1><sect2><para>
11526 #: ../en/ch09-undo.xml:511
11527 msgid ""
11528 "Here's a brief description of how the <command role=\"hg-cmd\">hg backout</"
11529 "command> command works."
11530 msgstr ""
11532 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
11533 #: ../en/ch09-undo.xml:514
11534 msgid ""
11535 "It ensures that the working directory is <quote>clean</quote>, i.e. that the "
11536 "output of <command role=\"hg-cmd\">hg status</command> would be empty."
11537 msgstr ""
11539 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
11540 #: ../en/ch09-undo.xml:518
11541 msgid ""
11542 "It remembers the current parent of the working directory. Let's call this "
11543 "changeset <literal>orig</literal>."
11544 msgstr ""
11546 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
11547 #: ../en/ch09-undo.xml:522
11548 msgid ""
11549 "It does the equivalent of a <command role=\"hg-cmd\">hg update</command> to "
11550 "sync the working directory to the changeset you want to back out. Let's call "
11551 "this changeset <literal>backout</literal>."
11552 msgstr ""
11554 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
11555 #: ../en/ch09-undo.xml:527
11556 msgid ""
11557 "It finds the parent of that changeset. Let's call that changeset "
11558 "<literal>parent</literal>."
11559 msgstr ""
11561 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
11562 #: ../en/ch09-undo.xml:530
11563 msgid ""
11564 "For each file that the <literal>backout</literal> changeset affected, it does "
11565 "the equivalent of a <command role=\"hg-cmd\">hg revert -r parent</command> on "
11566 "that file, to restore it to the contents it had before that changeset was "
11567 "committed."
11568 msgstr ""
11570 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
11571 #: ../en/ch09-undo.xml:537
11572 msgid ""
11573 "It commits the result as a new changeset. This changeset has "
11574 "<literal>backout</literal> as its parent."
11575 msgstr ""
11577 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
11578 #: ../en/ch09-undo.xml:541
11579 msgid ""
11580 "If you specify <option role=\"hg-opt-backout\">--merge</option> on the "
11581 "command line, it merges with <literal>orig</literal>, and commits the result "
11582 "of the merge."
11583 msgstr ""
11585 #. type: Content of: <book><chapter><sect1><sect2><para>
11586 #: ../en/ch09-undo.xml:547
11587 msgid ""
11588 "An alternative way to implement the <command role=\"hg-cmd\">hg backout</"
11589 "command> command would be to <command role=\"hg-cmd\">hg export</command> the "
11590 "to-be-backed-out changeset as a diff, then use the <option role=\"cmd-opt-"
11591 "patch\">--reverse</option> option to the <command>patch</command> command to "
11592 "reverse the effect of the change without fiddling with the working "
11593 "directory. This sounds much simpler, but it would not work nearly as well."
11594 msgstr ""
11596 #. type: Content of: <book><chapter><sect1><sect2><para>
11597 #: ../en/ch09-undo.xml:557
11598 msgid ""
11599 "The reason that <command role=\"hg-cmd\">hg backout</command> does an update, "
11600 "a commit, a merge, and another commit is to give the merge machinery the best "
11601 "chance to do a good job when dealing with all the changes <emphasis>between</"
11602 "emphasis> the change you're backing out and the current tip."
11603 msgstr ""
11605 #. type: Content of: <book><chapter><sect1><sect2><para>
11606 #: ../en/ch09-undo.xml:564
11607 msgid ""
11608 "If you're backing out a changeset that's 100 revisions back in your project's "
11609 "history, the chances that the <command>patch</command> command will be able "
11610 "to apply a reverse diff cleanly are not good, because intervening changes are "
11611 "likely to have <quote>broken the context</quote> that <command>patch</"
11612 "command> uses to determine whether it can apply a patch (if this sounds like "
11613 "gibberish, see <xref linkend=\"sec:mq:patch\"/> for a discussion of the "
11614 "<command>patch</command> command). Also, Mercurial's merge machinery will "
11615 "handle files and directories being renamed, permission changes, and "
11616 "modifications to binary files, none of which <command>patch</command> can "
11617 "deal with."
11618 msgstr ""
11620 #. type: Content of: <book><chapter><sect1><title>
11621 #: ../en/ch09-undo.xml:581
11622 msgid "Changes that should never have been"
11623 msgstr "不该发生的修改"
11625 #. type: Content of: <book><chapter><sect1><para>
11626 #: ../en/ch09-undo.xml:583
11627 msgid ""
11628 "Most of the time, the <command role=\"hg-cmd\">hg backout</command> command "
11629 "is exactly what you need if you want to undo the effects of a change. It "
11630 "leaves a permanent record of exactly what you did, both when committing the "
11631 "original changeset and when you cleaned up after it."
11632 msgstr ""
11634 #. type: Content of: <book><chapter><sect1><para>
11635 #: ../en/ch09-undo.xml:589
11636 msgid ""
11637 "On rare occasions, though, you may find that you've committed a change that "
11638 "really should not be present in the repository at all. For example, it would "
11639 "be very unusual, and usually considered a mistake, to commit a software "
11640 "project's object files as well as its source files. Object files have almost "
11641 "no intrinsic value, and they're <emphasis>big</emphasis>, so they increase "
11642 "the size of the repository and the amount of time it takes to clone or pull "
11643 "changes."
11644 msgstr ""
11646 #. type: Content of: <book><chapter><sect1><para>
11647 #: ../en/ch09-undo.xml:598
11648 msgid ""
11649 "Before I discuss the options that you have if you commit a <quote>brown paper "
11650 "bag</quote> change (the kind that's so bad that you want to pull a brown "
11651 "paper bag over your head), let me first discuss some approaches that probably "
11652 "won't work."
11653 msgstr ""
11655 #. type: Content of: <book><chapter><sect1><para>
11656 #: ../en/ch09-undo.xml:603
11657 msgid ""
11658 "Since Mercurial treats history as accumulative&emdash;every change builds on "
11659 "top of all changes that preceded it&emdash;you generally can't just make "
11660 "disastrous changes disappear. The one exception is when you've just "
11661 "committed a change, and it hasn't been pushed or pulled into another "
11662 "repository. That's when you can safely use the <command role=\"hg-cmd\">hg "
11663 "rollback</command> command, as I detailed in <xref linkend=\"sec:undo:rollback"
11664 "\"/>."
11665 msgstr ""
11667 #. type: Content of: <book><chapter><sect1><para>
11668 #: ../en/ch09-undo.xml:612
11669 msgid ""
11670 "After you've pushed a bad change to another repository, you <emphasis>could</"
11671 "emphasis> still use <command role=\"hg-cmd\">hg rollback</command> to make "
11672 "your local copy of the change disappear, but it won't have the consequences "
11673 "you want. The change will still be present in the remote repository, so it "
11674 "will reappear in your local repository the next time you pull."
11675 msgstr ""
11677 #. type: Content of: <book><chapter><sect1><para>
11678 #: ../en/ch09-undo.xml:620
11679 msgid ""
11680 "If a situation like this arises, and you know which repositories your bad "
11681 "change has propagated into, you can <emphasis>try</emphasis> to get rid of "
11682 "the change from <emphasis>every</emphasis> one of those repositories. This "
11683 "is, of course, not a satisfactory solution: if you miss even a single "
11684 "repository while you're expunging, the change is still <quote>in the wild</"
11685 "quote>, and could propagate further."
11686 msgstr ""
11688 #. type: Content of: <book><chapter><sect1><para>
11689 #: ../en/ch09-undo.xml:628
11690 msgid ""
11691 "If you've committed one or more changes <emphasis>after</emphasis> the change "
11692 "that you'd like to see disappear, your options are further reduced. Mercurial "
11693 "doesn't provide a way to <quote>punch a hole</quote> in history, leaving "
11694 "changesets intact."
11695 msgstr ""
11697 #. type: Content of: <book><chapter><sect1><sect2><title>
11698 #: ../en/ch09-undo.xml:635
11699 msgid "Backing out a merge"
11700 msgstr "撤销一个合并"
11702 #. type: Content of: <book><chapter><sect1><sect2><para>
11703 #: ../en/ch09-undo.xml:637
11704 msgid ""
11705 "Since merges are often complicated, it is not unheard of for a merge to be "
11706 "mangled badly, but committed erroneously. Mercurial provides an important "
11707 "safeguard against bad merges by refusing to commit unresolved files, but "
11708 "human ingenuity guarantees that it is still possible to mess a merge up and "
11709 "commit it."
11710 msgstr ""
11712 #. type: Content of: <book><chapter><sect1><sect2><para>
11713 #: ../en/ch09-undo.xml:644
11714 msgid ""
11715 "Given a bad merge that has been committed, usually the best way to approach "
11716 "it is to simply try to repair the damage by hand. A complete disaster that "
11717 "cannot be easily fixed up by hand ought to be very rare, but the <command "
11718 "role=\"hg-cmd\">hg backout</command> command may help in making the cleanup "
11719 "easier. It offers a <option role=\"hg-opt-backout\">--parent</option> option, "
11720 "which lets you specify which parent to revert to when backing out a merge."
11721 msgstr ""
11723 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
11724 #: ../en/ch09-undo.xml:655
11725 msgid "A bad merge"
11726 msgstr "错误的合并"
11728 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
11729 #: ../en/ch09-undo.xml:657
11730 msgid "<imageobject><imagedata fileref=\"figs/bad-merge-1.png\"/></imageobject>"
11731 msgstr ""
11733 #. type: Content of: <book><chapter><sect1><sect2><para>
11734 #: ../en/ch09-undo.xml:662
11735 msgid ""
11736 "Suppose we have a revision graph like that in <xref linkend=\"fig:undo:bad-"
11737 "merge-1\"/>. What we'd like is to <emphasis>redo</emphasis> the merge of "
11738 "revisions 2 and 3."
11739 msgstr ""
11741 #. type: Content of: <book><chapter><sect1><sect2><para>
11742 #: ../en/ch09-undo.xml:667
11743 msgid "One way to do so would be as follows."
11744 msgstr ""
11746 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
11747 #: ../en/ch09-undo.xml:671
11748 msgid ""
11749 "Call <command role=\"hg-cmd\">hg backout --rev=4 --parent=2</command>. This "
11750 "tells <command role=\"hg-cmd\">hg backout</command> to back out revision 4, "
11751 "which is the bad merge, and to when deciding which revision to prefer, to "
11752 "choose parent 2, one of the parents of the merge. The effect can be seen in "
11753 "<xref linkend=\"fig:undo:bad-merge-2\"/>."
11754 msgstr ""
11756 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><figure><title>
11757 #: ../en/ch09-undo.xml:679
11758 msgid "Backing out the merge, favoring one parent"
11759 msgstr "拆除合并,关注一个父亲"
11761 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><figure><mediaobject>
11762 #: ../en/ch09-undo.xml:681
11763 msgid "<imageobject><imagedata fileref=\"figs/bad-merge-2.png\"/></imageobject>"
11764 msgstr ""
11765 "<imageobject><imagedata fileref=\"figs/bad-merge-2.png\"/></imageobject>"
11767 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
11768 #: ../en/ch09-undo.xml:688
11769 msgid ""
11770 "Call <command role=\"hg-cmd\">hg backout --rev=4 --parent=3</command>. This "
11771 "tells <command role=\"hg-cmd\">hg backout</command> to back out revision 4 "
11772 "again, but this time to choose parent 3, the other parent of the merge. The "
11773 "result is visible in <xref linkend=\"fig:undo:bad-merge-3\"/>, in which the "
11774 "repository now contains three heads."
11775 msgstr ""
11777 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><figure><title>
11778 #: ../en/ch09-undo.xml:696
11779 msgid "Backing out the merge, favoring the other parent"
11780 msgstr "拆除合并,关注其它父亲"
11782 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><figure><mediaobject>
11783 #: ../en/ch09-undo.xml:699
11784 msgid "<imageobject><imagedata fileref=\"figs/bad-merge-3.png\"/></imageobject>"
11785 msgstr ""
11786 "<imageobject><imagedata fileref=\"figs/bad-merge-3.png\"/></imageobject>"
11788 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
11789 #: ../en/ch09-undo.xml:706
11790 msgid ""
11791 "Redo the bad merge by merging the two backout heads, which reduces the number "
11792 "of heads in the repository to two, as can be seen in <xref linkend=\"fig:undo:"
11793 "bad-merge-4\"/>."
11794 msgstr ""
11796 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><figure><title>
11797 #: ../en/ch09-undo.xml:711 ../en/ch09-undo.xml:724
11798 msgid "Merging the backouts"
11799 msgstr "合并拆除"
11801 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><figure><mediaobject>
11802 #: ../en/ch09-undo.xml:713
11803 msgid "<imageobject><imagedata fileref=\"figs/bad-merge-4.png\"/></imageobject>"
11804 msgstr ""
11805 "<imageobject><imagedata fileref=\"figs/bad-merge-4.png\"/></imageobject>"
11807 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
11808 #: ../en/ch09-undo.xml:720
11809 msgid ""
11810 "Merge with the commit that was made after the bad merge, as shown in <xref "
11811 "linkend=\"fig:undo:bad-merge-5\"/>."
11812 msgstr ""
11814 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><figure><mediaobject>
11815 #: ../en/ch09-undo.xml:726
11816 msgid "<imageobject><imagedata fileref=\"figs/bad-merge-5.png\"/></imageobject>"
11817 msgstr ""
11819 #. type: Content of: <book><chapter><sect1><sect2><title>
11820 #: ../en/ch09-undo.xml:735
11821 msgid "Protect yourself from <quote>escaped</quote> changes"
11822 msgstr "使用<quote>校验</quote>修改来保护你自己"
11824 #. type: Content of: <book><chapter><sect1><sect2><para>
11825 #: ../en/ch09-undo.xml:738
11826 msgid ""
11827 "If you've committed some changes to your local repository and they've been "
11828 "pushed or pulled somewhere else, this isn't necessarily a disaster. You can "
11829 "protect yourself ahead of time against some classes of bad changeset. This "
11830 "is particularly easy if your team usually pulls changes from a central "
11831 "repository."
11832 msgstr ""
11834 #. type: Content of: <book><chapter><sect1><sect2><para>
11835 #: ../en/ch09-undo.xml:745
11836 msgid ""
11837 "By configuring some hooks on that repository to validate incoming changesets "
11838 "(see chapter <xref linkend=\"chap:hook\"/>), you can automatically prevent "
11839 "some kinds of bad changeset from being pushed to the central repository at "
11840 "all. With such a configuration in place, some kinds of bad changeset will "
11841 "naturally tend to <quote>die out</quote> because they can't propagate into "
11842 "the central repository. Better yet, this happens without any need for "
11843 "explicit intervention."
11844 msgstr ""
11846 #. type: Content of: <book><chapter><sect1><sect2><para>
11847 #: ../en/ch09-undo.xml:755
11848 msgid ""
11849 "For instance, an incoming change hook that verifies that a changeset will "
11850 "actually compile can prevent people from inadvertently <quote>breaking the "
11851 "build</quote>."
11852 msgstr ""
11854 #. type: Content of: <book><chapter><sect1><sect2><title>
11855 #: ../en/ch09-undo.xml:762
11856 msgid "What to do about sensitive changes that escape"
11857 msgstr "处理敏感信息泄漏的方法"
11859 #. type: Content of: <book><chapter><sect1><sect2><para>
11860 #: ../en/ch09-undo.xml:764
11861 msgid ""
11862 "Even a carefully run project can suffer an unfortunate event such as the "
11863 "committing and uncontrolled propagation of a file that contains important "
11864 "passwords."
11865 msgstr ""
11867 #. type: Content of: <book><chapter><sect1><sect2><para>
11868 #: ../en/ch09-undo.xml:768
11869 msgid ""
11870 "If something like this happens to you, and the information that gets "
11871 "accidentally propagated is truly sensitive, your first step should be to "
11872 "mitigate the effect of the leak without trying to control the leak itself. If "
11873 "you are not 100% certain that you know exactly who could have seen the "
11874 "changes, you should immediately change passwords, cancel credit cards, or "
11875 "find some other way to make sure that the information that has leaked is no "
11876 "longer useful. In other words, assume that the change has propagated far and "
11877 "wide, and that there's nothing more you can do."
11878 msgstr ""
11880 #. type: Content of: <book><chapter><sect1><sect2><para>
11881 #: ../en/ch09-undo.xml:779
11882 msgid ""
11883 "You might hope that there would be mechanisms you could use to either figure "
11884 "out who has seen a change or to erase the change permanently everywhere, but "
11885 "there are good reasons why these are not possible."
11886 msgstr ""
11888 #. type: Content of: <book><chapter><sect1><sect2><para>
11889 #: ../en/ch09-undo.xml:784
11890 msgid ""
11891 "Mercurial does not provide an audit trail of who has pulled changes from a "
11892 "repository, because it is usually either impossible to record such "
11893 "information or trivial to spoof it. In a multi-user or networked "
11894 "environment, you should thus be extremely skeptical of yourself if you think "
11895 "that you have identified every place that a sensitive changeset has "
11896 "propagated to. Don't forget that people can and will send bundles by email, "
11897 "have their backup software save data offsite, carry repositories on USB "
11898 "sticks, and find other completely innocent ways to confound your attempts to "
11899 "track down every copy of a problematic change."
11900 msgstr ""
11902 #. type: Content of: <book><chapter><sect1><sect2><para>
11903 #: ../en/ch09-undo.xml:796
11904 msgid ""
11905 "Mercurial also does not provide a way to make a file or changeset completely "
11906 "disappear from history, because there is no way to enforce its disappearance; "
11907 "someone could easily modify their copy of Mercurial to ignore such "
11908 "directives. In addition, even if Mercurial provided such a capability, "
11909 "someone who simply hadn't pulled a <quote>make this file disappear</quote> "
11910 "changeset wouldn't be affected by it, nor would web crawlers visiting at the "
11911 "wrong time, disk backups, or other mechanisms. Indeed, no distributed "
11912 "revision control system can make data reliably vanish. Providing the illusion "
11913 "of such control could easily give a false sense of security, and be worse "
11914 "than not providing it at all."
11915 msgstr ""
11917 #. type: Content of: <book><chapter><sect1><title>
11918 #: ../en/ch09-undo.xml:812
11919 msgid "Finding the source of a bug"
11920 msgstr "查找问题的根源"
11922 #. type: Content of: <book><chapter><sect1><para>
11923 #: ../en/ch09-undo.xml:814
11924 msgid ""
11925 "While it's all very well to be able to back out a changeset that introduced a "
11926 "bug, this requires that you know which changeset to back out. Mercurial "
11927 "provides an invaluable command, called <command role=\"hg-cmd\">hg bisect</"
11928 "command>, that helps you to automate this process and accomplish it very "
11929 "efficiently."
11930 msgstr ""
11932 #. type: Content of: <book><chapter><sect1><para>
11933 #: ../en/ch09-undo.xml:821
11934 msgid ""
11935 "The idea behind the <command role=\"hg-cmd\">hg bisect</command> command is "
11936 "that a changeset has introduced some change of behavior that you can identify "
11937 "with a simple pass/fail test. You don't know which piece of code introduced "
11938 "the change, but you know how to test for the presence of the bug. The "
11939 "<command role=\"hg-cmd\">hg bisect</command> command uses your test to direct "
11940 "its search for the changeset that introduced the code that caused the bug."
11941 msgstr ""
11943 #. type: Content of: <book><chapter><sect1><para>
11944 #: ../en/ch09-undo.xml:830
11945 msgid ""
11946 "Here are a few scenarios to help you understand how you might apply this "
11947 "command."
11948 msgstr ""
11950 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
11951 #: ../en/ch09-undo.xml:833
11952 msgid ""
11953 "The most recent version of your software has a bug that you remember wasn't "
11954 "present a few weeks ago, but you don't know when it was introduced. Here, "
11955 "your binary test checks for the presence of that bug."
11956 msgstr ""
11958 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
11959 #: ../en/ch09-undo.xml:838
11960 msgid ""
11961 "You fixed a bug in a rush, and now it's time to close the entry in your "
11962 "team's bug database. The bug database requires a changeset ID when you close "
11963 "an entry, but you don't remember which changeset you fixed the bug in. Once "
11964 "again, your binary test checks for the presence of the bug."
11965 msgstr ""
11967 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
11968 #: ../en/ch09-undo.xml:845
11969 msgid ""
11970 "Your software works correctly, but runs 15% slower than the last time you "
11971 "measured it. You want to know which changeset introduced the performance "
11972 "regression. In this case, your binary test measures the performance of your "
11973 "software, to see whether it's <quote>fast</quote> or <quote>slow</quote>."
11974 msgstr ""
11976 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
11977 #: ../en/ch09-undo.xml:852
11978 msgid ""
11979 "The sizes of the components of your project that you ship exploded recently, "
11980 "and you suspect that something changed in the way you build your project."
11981 msgstr ""
11983 #. type: Content of: <book><chapter><sect1><para>
11984 #: ../en/ch09-undo.xml:857
11985 msgid ""
11986 "From these examples, it should be clear that the <command role=\"hg-cmd\">hg "
11987 "bisect</command> command is not useful only for finding the sources of bugs. "
11988 "You can use it to find any <quote>emergent property</quote> of a repository "
11989 "(anything that you can't find from a simple text search of the files in the "
11990 "tree) for which you can write a binary test."
11991 msgstr ""
11993 #. type: Content of: <book><chapter><sect1><para>
11994 #: ../en/ch09-undo.xml:864
11995 msgid ""
11996 "We'll introduce a little bit of terminology here, just to make it clear which "
11997 "parts of the search process are your responsibility, and which are "
11998 "Mercurial's. A <emphasis>test</emphasis> is something that <emphasis>you</"
11999 "emphasis> run when <command role=\"hg-cmd\">hg bisect</command> chooses a "
12000 "changeset. A <emphasis>probe</emphasis> is what <command role=\"hg-cmd\">hg "
12001 "bisect</command> runs to tell whether a revision is good. Finally, we'll use "
12002 "the word <quote>bisect</quote>, as both a noun and a verb, to stand in for "
12003 "the phrase <quote>search using the <command role=\"hg-cmd\">hg bisect</"
12004 "command> command</quote>."
12005 msgstr ""
12007 #. type: Content of: <book><chapter><sect1><para>
12008 #: ../en/ch09-undo.xml:877
12009 msgid ""
12010 "One simple way to automate the searching process would be simply to probe "
12011 "every changeset. However, this scales poorly. If it took ten minutes to "
12012 "test a single changeset, and you had 10,000 changesets in your repository, "
12013 "the exhaustive approach would take on average 35 <emphasis>days</emphasis> to "
12014 "find the changeset that introduced a bug. Even if you knew that the bug was "
12015 "introduced by one of the last 500 changesets, and limited your search to "
12016 "those, you'd still be looking at over 40 hours to find the changeset that "
12017 "introduced your bug."
12018 msgstr ""
12020 #. type: Content of: <book><chapter><sect1><para>
12021 #: ../en/ch09-undo.xml:887
12022 msgid ""
12023 "What the <command role=\"hg-cmd\">hg bisect</command> command does is use its "
12024 "knowledge of the <quote>shape</quote> of your project's revision history to "
12025 "perform a search in time proportional to the <emphasis>logarithm</emphasis> "
12026 "of the number of changesets to check (the kind of search it performs is "
12027 "called a dichotomic search). With this approach, searching through 10,000 "
12028 "changesets will take less than three hours, even at ten minutes per test (the "
12029 "search will require about 14 tests). Limit your search to the last hundred "
12030 "changesets, and it will take only about an hour (roughly seven tests)."
12031 msgstr ""
12033 #. type: Content of: <book><chapter><sect1><para>
12034 #: ../en/ch09-undo.xml:898
12035 msgid ""
12036 "The <command role=\"hg-cmd\">hg bisect</command> command is aware of the "
12037 "<quote>branchy</quote> nature of a Mercurial project's revision history, so "
12038 "it has no problems dealing with branches, merges, or multiple heads in a "
12039 "repository. It can prune entire branches of history with a single probe, "
12040 "which is how it operates so efficiently."
12041 msgstr ""
12043 #. type: Content of: <book><chapter><sect1><sect2><title>
12044 #: ../en/ch09-undo.xml:906
12045 msgid "Using the <command role=\"hg-cmd\">hg bisect</command> command"
12046 msgstr "使用命令 <command role=\"hg-cmd\">hg bisect</command>"
12048 #. type: Content of: <book><chapter><sect1><sect2><para>
12049 #: ../en/ch09-undo.xml:909
12050 msgid ""
12051 "Here's an example of <command role=\"hg-cmd\">hg bisect</command> in action."
12052 msgstr ""
12054 #. type: Content of: <book><chapter><sect1><sect2><note><para>
12055 #: ../en/ch09-undo.xml:913
12056 msgid ""
12057 "In versions 0.9.5 and earlier of Mercurial, <command role=\"hg-cmd\">hg "
12058 "bisect</command> was not a core command: it was distributed with Mercurial as "
12059 "an extension. This section describes the built-in command, not the old "
12060 "extension."
12061 msgstr ""
12063 #. type: Content of: <book><chapter><sect1><sect2><para>
12064 #: ../en/ch09-undo.xml:920
12065 msgid ""
12066 "Now let's create a repository, so that we can try out the <command role=\"hg-"
12067 "cmd\">hg bisect</command> command in isolation."
12068 msgstr ""
12070 #. type: Content of: <book><chapter><sect1><sect2><para>
12071 #: ../en/ch09-undo.xml:926
12072 msgid ""
12073 "We'll simulate a project that has a bug in it in a simple-minded way: create "
12074 "trivial changes in a loop, and nominate one specific change that will have "
12075 "the <quote>bug</quote>. This loop creates 35 changesets, each adding a "
12076 "single file to the repository. We'll represent our <quote>bug</quote> with a "
12077 "file that contains the text <quote>i have a gub</quote>."
12078 msgstr ""
12080 #. type: Content of: <book><chapter><sect1><sect2><para>
12081 #: ../en/ch09-undo.xml:936
12082 msgid ""
12083 "The next thing that we'd like to do is figure out how to use the <command "
12084 "role=\"hg-cmd\">hg bisect</command> command. We can use Mercurial's normal "
12085 "built-in help mechanism for this."
12086 msgstr ""
12088 #. type: Content of: <book><chapter><sect1><sect2><para>
12089 #: ../en/ch09-undo.xml:943
12090 msgid ""
12091 "The <command role=\"hg-cmd\">hg bisect</command> command works in steps. "
12092 "Each step proceeds as follows."
12093 msgstr ""
12095 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
12096 #: ../en/ch09-undo.xml:946
12097 msgid "You run your binary test."
12098 msgstr ""
12100 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><itemizedlist><listitem><para>
12101 #: ../en/ch09-undo.xml:948
12102 msgid ""
12103 "If the test succeeded, you tell <command role=\"hg-cmd\">hg bisect</command> "
12104 "by running the <command role=\"hg-cmd\">hg bisect --good</command> command."
12105 msgstr ""
12106 "当测试成功后,使用 <command role=\"hg-cmd\">hg bisect --good</command> 命令告"
12107 "诉 <command role=\"hg-cmd\">hg bisect</command> 命令。"
12109 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><itemizedlist><listitem><para>
12110 #: ../en/ch09-undo.xml:953
12111 msgid ""
12112 "If it failed, run the <command role=\"hg-cmd\">hg bisect --bad</command> "
12113 "command."
12114 msgstr ""
12115 "如果失败,执行 <command role=\"hg-cmd\">hg bisect --bad</command> 命令。"
12117 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
12118 #: ../en/ch09-undo.xml:957
12119 msgid ""
12120 "The command uses your information to decide which changeset to test next."
12121 msgstr ""
12123 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
12124 #: ../en/ch09-undo.xml:960
12125 msgid ""
12126 "It updates the working directory to that changeset, and the process begins "
12127 "again."
12128 msgstr ""
12130 #. type: Content of: <book><chapter><sect1><sect2><para>
12131 #: ../en/ch09-undo.xml:963
12132 msgid ""
12133 "The process ends when <command role=\"hg-cmd\">hg bisect</command> identifies "
12134 "a unique changeset that marks the point where your test transitioned from "
12135 "<quote>succeeding</quote> to <quote>failing</quote>."
12136 msgstr ""
12139 #. type: Content of: <book><chapter><sect1><sect2><para>
12140 #: ../en/ch09-undo.xml:968
12141 msgid ""
12142 "To start the search, we must run the <command role=\"hg-cmd\">hg bisect --"
12143 "reset</command> command."
12144 msgstr ""
12146 #. type: Content of: <book><chapter><sect1><sect2><para>
12147 #: ../en/ch09-undo.xml:973
12148 msgid ""
12149 "In our case, the binary test we use is simple: we check to see if any file in "
12150 "the repository contains the string <quote>i have a gub</quote>. If it does, "
12151 "this changeset contains the change that <quote>caused the bug</quote>. By "
12152 "convention, a changeset that has the property we're searching for is "
12153 "<quote>bad</quote>, while one that doesn't is <quote>good</quote>."
12154 msgstr ""
12156 #. type: Content of: <book><chapter><sect1><sect2><para>
12157 #: ../en/ch09-undo.xml:981
12158 msgid ""
12159 "Most of the time, the revision to which the working directory is synced "
12160 "(usually the tip) already exhibits the problem introduced by the buggy "
12161 "change, so we'll mark it as <quote>bad</quote>."
12162 msgstr ""
12165 #. type: Content of: <book><chapter><sect1><sect2><para>
12166 #: ../en/ch09-undo.xml:988
12167 msgid ""
12168 "Our next task is to nominate a changeset that we know <emphasis>doesn't</"
12169 "emphasis> have the bug; the <command role=\"hg-cmd\">hg bisect</command> "
12170 "command will <quote>bracket</quote> its search between the first pair of good "
12171 "and bad changesets. In our case, we know that revision 10 didn't have the "
12172 "bug. (I'll have more words about choosing the first <quote>good</quote> "
12173 "changeset later.)"
12174 msgstr ""
12176 #. type: Content of: <book><chapter><sect1><sect2><para>
12177 #: ../en/ch09-undo.xml:998
12178 msgid "Notice that this command printed some output."
12179 msgstr ""
12181 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12182 #: ../en/ch09-undo.xml:1000
12183 msgid ""
12184 "It told us how many changesets it must consider before it can identify the "
12185 "one that introduced the bug, and how many tests that will require."
12186 msgstr ""
12188 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12189 #: ../en/ch09-undo.xml:1004
12190 msgid ""
12191 "It updated the working directory to the next changeset to test, and told us "
12192 "which changeset it's testing."
12193 msgstr ""
12195 #. type: Content of: <book><chapter><sect1><sect2><para>
12196 #: ../en/ch09-undo.xml:1009
12197 msgid ""
12198 "We now run our test in the working directory. We use the <command>grep</"
12199 "command> command to see if our <quote>bad</quote> file is present in the "
12200 "working directory. If it is, this revision is bad; if not, this revision is "
12201 "good. &interaction.bisect.search.step1;"
12202 msgstr ""
12204 #. type: Content of: <book><chapter><sect1><sect2><para>
12205 #: ../en/ch09-undo.xml:1015
12206 msgid ""
12207 "This test looks like a perfect candidate for automation, so let's turn it "
12208 "into a shell function."
12209 msgstr ""
12211 #. type: Content of: <book><chapter><sect1><sect2><para>
12212 #: ../en/ch09-undo.xml:1019
12213 msgid ""
12214 "We can now run an entire test step with a single command, <literal>mytest</"
12215 "literal>."
12216 msgstr ""
12218 #. type: Content of: <book><chapter><sect1><sect2><para>
12219 #: ../en/ch09-undo.xml:1024
12220 msgid "A few more invocations of our canned test step command, and we're done."
12221 msgstr ""
12223 #. type: Content of: <book><chapter><sect1><sect2><para>
12224 #: ../en/ch09-undo.xml:1029
12225 msgid ""
12226 "Even though we had 40 changesets to search through, the <command role=\"hg-cmd"
12227 "\">hg bisect</command> command let us find the changeset that introduced our "
12228 "<quote>bug</quote> with only five tests. Because the number of tests that "
12229 "the <command role=\"hg-cmd\">hg bisect</command> command performs grows "
12230 "logarithmically with the number of changesets to search, the advantage that "
12231 "it has over the <quote>brute force</quote> search approach increases with "
12232 "every changeset you add."
12233 msgstr ""
12235 #. type: Content of: <book><chapter><sect1><sect2><title>
12236 #: ../en/ch09-undo.xml:1040
12237 msgid "Cleaning up after your search"
12238 msgstr "搜索后的清理"
12240 #. type: Content of: <book><chapter><sect1><sect2><para>
12241 #: ../en/ch09-undo.xml:1042
12242 msgid ""
12243 "When you're finished using the <command role=\"hg-cmd\">hg bisect</command> "
12244 "command in a repository, you can use the <command role=\"hg-cmd\">hg bisect --"
12245 "reset</command> command to drop the information it was using to drive your "
12246 "search. The command doesn't use much space, so it doesn't matter if you "
12247 "forget to run this command. However, <command role=\"hg-cmd\">hg bisect</"
12248 "command> won't let you start a new search in that repository until you do a "
12249 "<command role=\"hg-cmd\">hg bisect --reset</command>."
12250 msgstr ""
12252 #. type: Content of: <book><chapter><sect1><title>
12253 #: ../en/ch09-undo.xml:1057
12254 msgid "Tips for finding bugs effectively"
12255 msgstr "有效查找问题的技巧"
12257 #. type: Content of: <book><chapter><sect1><sect2><title>
12258 #: ../en/ch09-undo.xml:1060
12259 msgid "Give consistent input"
12260 msgstr "给出一致的输入"
12262 #. type: Content of: <book><chapter><sect1><sect2><para>
12263 #: ../en/ch09-undo.xml:1062
12264 msgid ""
12265 "The <command role=\"hg-cmd\">hg bisect</command> command requires that you "
12266 "correctly report the result of every test you perform. If you tell it that a "
12267 "test failed when it really succeeded, it <emphasis>might</emphasis> be able "
12268 "to detect the inconsistency. If it can identify an inconsistency in your "
12269 "reports, it will tell you that a particular changeset is both good and bad. "
12270 "However, it can't do this perfectly; it's about as likely to report the wrong "
12271 "changeset as the source of the bug."
12272 msgstr ""
12274 #. type: Content of: <book><chapter><sect1><sect2><title>
12275 #: ../en/ch09-undo.xml:1074
12276 msgid "Automate as much as possible"
12277 msgstr "尽量自动"
12279 #. type: Content of: <book><chapter><sect1><sect2><para>
12280 #: ../en/ch09-undo.xml:1076
12281 msgid ""
12282 "When I started using the <command role=\"hg-cmd\">hg bisect</command> "
12283 "command, I tried a few times to run my tests by hand, on the command line. "
12284 "This is an approach that I, at least, am not suited to. After a few tries, I "
12285 "found that I was making enough mistakes that I was having to restart my "
12286 "searches several times before finally getting correct results."
12287 msgstr ""
12289 #. type: Content of: <book><chapter><sect1><sect2><para>
12290 #: ../en/ch09-undo.xml:1084
12291 msgid ""
12292 "My initial problems with driving the <command role=\"hg-cmd\">hg bisect</"
12293 "command> command by hand occurred even with simple searches on small "
12294 "repositories; if the problem you're looking for is more subtle, or the number "
12295 "of tests that <command role=\"hg-cmd\">hg bisect</command> must perform "
12296 "increases, the likelihood of operator error ruining the search is much "
12297 "higher. Once I started automating my tests, I had much better results."
12298 msgstr ""
12300 #. type: Content of: <book><chapter><sect1><sect2><para>
12301 #: ../en/ch09-undo.xml:1093
12302 msgid "The key to automated testing is twofold:"
12303 msgstr ""
12305 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12306 #: ../en/ch09-undo.xml:1095
12307 msgid "always test for the same symptom, and"
12308 msgstr ""
12310 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12311 #: ../en/ch09-undo.xml:1097
12312 msgid ""
12313 "always feed consistent input to the <command role=\"hg-cmd\">hg bisect</"
12314 "command> command."
12315 msgstr ""
12317 #. type: Content of: <book><chapter><sect1><sect2><para>
12318 #: ../en/ch09-undo.xml:1100
12319 msgid ""
12320 "In my tutorial example above, the <command>grep</command> command tests for "
12321 "the symptom, and the <literal>if</literal> statement takes the result of this "
12322 "check and ensures that we always feed the same input to the <command role="
12323 "\"hg-cmd\">hg bisect</command> command. The <literal>mytest</literal> "
12324 "function marries these together in a reproducible way, so that every test is "
12325 "uniform and consistent."
12326 msgstr ""
12328 #. type: Content of: <book><chapter><sect1><sect2><title>
12329 #: ../en/ch09-undo.xml:1110
12330 msgid "Check your results"
12331 msgstr "检查你的结果"
12333 #. type: Content of: <book><chapter><sect1><sect2><para>
12334 #: ../en/ch09-undo.xml:1112
12335 msgid ""
12336 "Because the output of a <command role=\"hg-cmd\">hg bisect</command> search "
12337 "is only as good as the input you give it, don't take the changeset it reports "
12338 "as the absolute truth. A simple way to cross-check its report is to manually "
12339 "run your test at each of the following changesets:"
12340 msgstr ""
12342 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12343 #: ../en/ch09-undo.xml:1118
12344 msgid ""
12345 "The changeset that it reports as the first bad revision. Your test should "
12346 "still report this as bad."
12347 msgstr ""
12349 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12350 #: ../en/ch09-undo.xml:1122
12351 msgid ""
12352 "The parent of that changeset (either parent, if it's a merge). Your test "
12353 "should report this changeset as good."
12354 msgstr ""
12356 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12357 #: ../en/ch09-undo.xml:1126
12358 msgid ""
12359 "A child of that changeset. Your test should report this changeset as bad."
12360 msgstr ""
12362 #. type: Content of: <book><chapter><sect1><sect2><title>
12363 #: ../en/ch09-undo.xml:1132
12364 msgid "Beware interference between bugs"
12365 msgstr "谨防问题之间的冲突"
12367 #. type: Content of: <book><chapter><sect1><sect2><para>
12368 #: ../en/ch09-undo.xml:1134
12369 msgid ""
12370 "It's possible that your search for one bug could be disrupted by the presence "
12371 "of another. For example, let's say your software crashes at revision 100, "
12372 "and worked correctly at revision 50. Unknown to you, someone else introduced "
12373 "a different crashing bug at revision 60, and fixed it at revision 80. This "
12374 "could distort your results in one of several ways."
12375 msgstr ""
12377 #. type: Content of: <book><chapter><sect1><sect2><para>
12378 #: ../en/ch09-undo.xml:1142
12379 msgid ""
12380 "It is possible that this other bug completely <quote>masks</quote> yours, "
12381 "which is to say that it occurs before your bug has a chance to manifest "
12382 "itself. If you can't avoid that other bug (for example, it prevents your "
12383 "project from building), and so can't tell whether your bug is present in a "
12384 "particular changeset, the <command role=\"hg-cmd\">hg bisect</command> "
12385 "command cannot help you directly. Instead, you can mark a changeset as "
12386 "untested by running <command role=\"hg-cmd\">hg bisect --skip</command>."
12387 msgstr ""
12389 #. type: Content of: <book><chapter><sect1><sect2><para>
12390 #: ../en/ch09-undo.xml:1152
12391 msgid ""
12392 "A different problem could arise if your test for a bug's presence is not "
12393 "specific enough. If you check for <quote>my program crashes</quote>, then "
12394 "both your crashing bug and an unrelated crashing bug that masks it will look "
12395 "like the same thing, and mislead <command role=\"hg-cmd\">hg bisect</command>."
12396 msgstr ""
12398 #. type: Content of: <book><chapter><sect1><sect2><para>
12399 #: ../en/ch09-undo.xml:1159
12400 msgid ""
12401 "Another useful situation in which to use <command role=\"hg-cmd\">hg bisect --"
12402 "skip</command> is if you can't test a revision because your project was in a "
12403 "broken and hence untestable state at that revision, perhaps because someone "
12404 "checked in a change that prevented the project from building."
12405 msgstr ""
12407 #. type: Content of: <book><chapter><sect1><sect2><title>
12408 #: ../en/ch09-undo.xml:1168
12409 msgid "Bracket your search lazily"
12410 msgstr "减少你的查找工作"
12412 #. type: Content of: <book><chapter><sect1><sect2><para>
12413 #: ../en/ch09-undo.xml:1170
12414 msgid ""
12415 "Choosing the first <quote>good</quote> and <quote>bad</quote> changesets that "
12416 "will mark the end points of your search is often easy, but it bears a little "
12417 "discussion nevertheless. From the perspective of <command role=\"hg-cmd\">hg "
12418 "bisect</command>, the <quote>newest</quote> changeset is conventionally "
12419 "<quote>bad</quote>, and the older changeset is <quote>good</quote>."
12420 msgstr ""
12422 #. type: Content of: <book><chapter><sect1><sect2><para>
12423 #: ../en/ch09-undo.xml:1178
12424 msgid ""
12425 "If you're having trouble remembering when a suitable <quote>good</quote> "
12426 "change was, so that you can tell <command role=\"hg-cmd\">hg bisect</"
12427 "command>, you could do worse than testing changesets at random. Just "
12428 "remember to eliminate contenders that can't possibly exhibit the bug (perhaps "
12429 "because the feature with the bug isn't present yet) and those where another "
12430 "problem masks the bug (as I discussed above)."
12431 msgstr ""
12433 #. type: Content of: <book><chapter><sect1><sect2><para>
12434 #: ../en/ch09-undo.xml:1187
12435 msgid ""
12436 "Even if you end up <quote>early</quote> by thousands of changesets or months "
12437 "of history, you will only add a handful of tests to the total number that "
12438 "<command role=\"hg-cmd\">hg bisect</command> must perform, thanks to its "
12439 "logarithmic behavior."
12440 msgstr ""
12442 #. type: Content of: <book><chapter><title>
12443 #: ../en/ch10-hook.xml:5
12444 msgid "Handling repository events with hooks"
12445 msgstr "使用钩子处理版本库事件"
12447 #. type: Content of: <book><chapter><para>
12448 #: ../en/ch10-hook.xml:7
12449 msgid ""
12450 "Mercurial offers a powerful mechanism to let you perform automated actions in "
12451 "response to events that occur in a repository. In some cases, you can even "
12452 "control Mercurial's response to those events."
12453 msgstr ""
12455 #. type: Content of: <book><chapter><para>
12456 #: ../en/ch10-hook.xml:12
12457 msgid ""
12458 "The name Mercurial uses for one of these actions is a <emphasis>hook</"
12459 "emphasis>. Hooks are called <quote>triggers</quote> in some revision control "
12460 "systems, but the two names refer to the same idea."
12461 msgstr ""
12463 #. type: Content of: <book><chapter><sect1><title>
12464 #: ../en/ch10-hook.xml:18
12465 msgid "An overview of hooks in Mercurial"
12466 msgstr "Mercurial 钩子概述"
12468 #. type: Content of: <book><chapter><sect1><para>
12469 #: ../en/ch10-hook.xml:20
12470 msgid ""
12471 "Here is a brief list of the hooks that Mercurial supports. We will revisit "
12472 "each of these hooks in more detail later, in <xref linkend=\"sec:hook:ref\"/>."
12473 msgstr ""
12475 #. type: Content of: <book><chapter><sect1><para>
12476 #: ../en/ch10-hook.xml:24
12477 msgid ""
12478 "Each of the hooks whose description begins with the word <quote>Controlling</"
12479 "quote> has the ability to determine whether an activity can proceed. If the "
12480 "hook succeeds, the activity may proceed; if it fails, the activity is either "
12481 "not permitted or undone, depending on the hook."
12482 msgstr ""
12484 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12485 #: ../en/ch10-hook.xml:31
12486 msgid ""
12487 "<literal role=\"hook\">changegroup</literal>: This is run after a group of "
12488 "changesets has been brought into the repository from elsewhere."
12489 msgstr ""
12491 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12492 #: ../en/ch10-hook.xml:35
12493 msgid ""
12494 "<literal role=\"hook\">commit</literal>: This is run after a new changeset "
12495 "has been created in the local repository."
12496 msgstr ""
12498 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12499 #: ../en/ch10-hook.xml:39
12500 msgid ""
12501 "<literal role=\"hook\">incoming</literal>: This is run once for each new "
12502 "changeset that is brought into the repository from elsewhere. Notice the "
12503 "difference from <literal role=\"hook\">changegroup</literal>, which is run "
12504 "once per <emphasis>group</emphasis> of changesets brought in."
12505 msgstr ""
12507 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12508 #: ../en/ch10-hook.xml:46
12509 msgid ""
12510 "<literal role=\"hook\">outgoing</literal>: This is run after a group of "
12511 "changesets has been transmitted from this repository."
12512 msgstr ""
12514 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12515 #: ../en/ch10-hook.xml:50
12516 msgid ""
12517 "<literal role=\"hook\">prechangegroup</literal>: This is run before starting "
12518 "to bring a group of changesets into the repository."
12519 msgstr ""
12521 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12522 #: ../en/ch10-hook.xml:55
12523 msgid ""
12524 "<literal role=\"hook\">precommit</literal>: Controlling. This is run before "
12525 "starting a commit."
12526 msgstr ""
12528 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12529 #: ../en/ch10-hook.xml:59
12530 msgid ""
12531 "<literal role=\"hook\">preoutgoing</literal>: Controlling. This is run before "
12532 "starting to transmit a group of changesets from this repository."
12533 msgstr ""
12535 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12536 #: ../en/ch10-hook.xml:64
12537 msgid ""
12538 "<literal role=\"hook\">pretag</literal>: Controlling. This is run before "
12539 "creating a tag."
12540 msgstr ""
12542 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12543 #: ../en/ch10-hook.xml:68
12544 msgid ""
12545 "<literal role=\"hook\">pretxnchangegroup</literal>: Controlling. This is run "
12546 "after a group of changesets has been brought into the local repository from "
12547 "another, but before the transaction completes that will make the changes "
12548 "permanent in the repository."
12549 msgstr ""
12551 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12552 #: ../en/ch10-hook.xml:76
12553 msgid ""
12554 "<literal role=\"hook\">pretxncommit</literal>: Controlling. This is run after "
12555 "a new changeset has been created in the local repository, but before the "
12556 "transaction completes that will make it permanent."
12557 msgstr ""
12559 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12560 #: ../en/ch10-hook.xml:82
12561 msgid ""
12562 "<literal role=\"hook\">preupdate</literal>: Controlling. This is run before "
12563 "starting an update or merge of the working directory."
12564 msgstr ""
12566 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12567 #: ../en/ch10-hook.xml:87
12568 msgid ""
12569 "<literal role=\"hook\">tag</literal>: This is run after a tag is created."
12570 msgstr ""
12572 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12573 #: ../en/ch10-hook.xml:91
12574 msgid ""
12575 "<literal role=\"hook\">update</literal>: This is run after an update or merge "
12576 "of the working directory has finished."
12577 msgstr ""
12579 #. type: Content of: <book><chapter><sect1><title>
12580 #: ../en/ch10-hook.xml:99
12581 msgid "Hooks and security"
12582 msgstr "钩子与安全性"
12584 #. type: Content of: <book><chapter><sect1><sect2><title>
12585 #: ../en/ch10-hook.xml:102
12586 msgid "Hooks are run with your privileges"
12587 msgstr "钩子以你的特权执行"
12589 #. type: Content of: <book><chapter><sect1><sect2><para>
12590 #: ../en/ch10-hook.xml:104
12591 msgid ""
12592 "When you run a Mercurial command in a repository, and the command causes a "
12593 "hook to run, that hook runs on <emphasis>your</emphasis> system, under "
12594 "<emphasis>your</emphasis> user account, with <emphasis>your</emphasis> "
12595 "privilege level. Since hooks are arbitrary pieces of executable code, you "
12596 "should treat them with an appropriate level of suspicion. Do not install a "
12597 "hook unless you are confident that you know who created it and what it does."
12598 msgstr ""
12600 #. type: Content of: <book><chapter><sect1><sect2><para>
12601 #: ../en/ch10-hook.xml:115
12602 msgid ""
12603 "In some cases, you may be exposed to hooks that you did not install "
12604 "yourself. If you work with Mercurial on an unfamiliar system, Mercurial will "
12605 "run hooks defined in that system's global <filename role=\"special\">~/.hgrc</"
12606 "filename> file."
12607 msgstr ""
12609 #. type: Content of: <book><chapter><sect1><sect2><para>
12610 #: ../en/ch10-hook.xml:122
12611 msgid ""
12612 "If you are working with a repository owned by another user, Mercurial can run "
12613 "hooks defined in that user's repository, but it will still run them as "
12614 "<quote>you</quote>. For example, if you <command role=\"hg-cmd\">hg pull</"
12615 "command> from that repository, and its <filename role=\"special\">.hg/hgrc</"
12616 "filename> defines a local <literal role=\"hook\">outgoing</literal> hook, "
12617 "that hook will run under your user account, even though you don't own that "
12618 "repository."
12619 msgstr ""
12621 #. type: Content of: <book><chapter><sect1><sect2><note><para>
12622 #: ../en/ch10-hook.xml:134
12623 msgid ""
12624 "This only applies if you are pulling from a repository on a local or network "
12625 "filesystem. If you're pulling over http or ssh, any <literal role=\"hook"
12626 "\">outgoing</literal> hook will run under whatever account is executing the "
12627 "server process, on the server."
12628 msgstr ""
12630 #. type: Content of: <book><chapter><sect1><sect2><para>
12631 #: ../en/ch10-hook.xml:142
12632 msgid ""
12633 "To see what hooks are defined in a repository, use the <command role=\"hg-cmd"
12634 "\">hg showconfig hooks</command> command. If you are working in one "
12635 "repository, but talking to another that you do not own (e.g. using <command "
12636 "role=\"hg-cmd\">hg pull</command> or <command role=\"hg-cmd\">hg incoming</"
12637 "command>), remember that it is the other repository's hooks you should be "
12638 "checking, not your own."
12639 msgstr ""
12641 #. type: Content of: <book><chapter><sect1><sect2><title>
12642 #: ../en/ch10-hook.xml:153
12643 msgid "Hooks do not propagate"
12644 msgstr "钩子不会传播"
12646 #. type: Content of: <book><chapter><sect1><sect2><para>
12647 #: ../en/ch10-hook.xml:155
12648 msgid ""
12649 "In Mercurial, hooks are not revision controlled, and do not propagate when "
12650 "you clone, or pull from, a repository. The reason for this is simple: a hook "
12651 "is a completely arbitrary piece of executable code. It runs under your user "
12652 "identity, with your privilege level, on your machine."
12653 msgstr ""
12655 #. type: Content of: <book><chapter><sect1><sect2><para>
12656 #: ../en/ch10-hook.xml:162
12657 msgid ""
12658 "It would be extremely reckless for any distributed revision control system to "
12659 "implement revision-controlled hooks, as this would offer an easily "
12660 "exploitable way to subvert the accounts of users of the revision control "
12661 "system."
12662 msgstr ""
12664 #. type: Content of: <book><chapter><sect1><sect2><para>
12665 #: ../en/ch10-hook.xml:168
12666 msgid ""
12667 "Since Mercurial does not propagate hooks, if you are collaborating with other "
12668 "people on a common project, you should not assume that they are using the "
12669 "same Mercurial hooks as you are, or that theirs are correctly configured. "
12670 "You should document the hooks you expect people to use."
12671 msgstr ""
12673 #. type: Content of: <book><chapter><sect1><sect2><para>
12674 #: ../en/ch10-hook.xml:175
12675 msgid ""
12676 "In a corporate intranet, this is somewhat easier to control, as you can for "
12677 "example provide a <quote>standard</quote> installation of Mercurial on an NFS "
12678 "filesystem, and use a site-wide <filename role=\"special\">~/.hgrc</filename> "
12679 "file to define hooks that all users will see. However, this too has its "
12680 "limits; see below."
12681 msgstr ""
12683 #. type: Content of: <book><chapter><sect1><sect2><title>
12684 #: ../en/ch10-hook.xml:184
12685 msgid "Hooks can be overridden"
12686 msgstr "钩子可以被覆盖"
12688 #. type: Content of: <book><chapter><sect1><sect2><para>
12689 #: ../en/ch10-hook.xml:186
12690 msgid ""
12691 "Mercurial allows you to override a hook definition by redefining the hook. "
12692 "You can disable it by setting its value to the empty string, or change its "
12693 "behavior as you wish."
12694 msgstr ""
12696 #. type: Content of: <book><chapter><sect1><sect2><para>
12697 #: ../en/ch10-hook.xml:191
12698 msgid ""
12699 "If you deploy a system- or site-wide <filename role=\"special\">~/.hgrc</"
12700 "filename> file that defines some hooks, you should thus understand that your "
12701 "users can disable or override those hooks."
12702 msgstr ""
12704 #. type: Content of: <book><chapter><sect1><sect2><title>
12705 #: ../en/ch10-hook.xml:199
12706 msgid "Ensuring that critical hooks are run"
12707 msgstr "确保关键钩子的执行"
12709 #. type: Content of: <book><chapter><sect1><sect2><para>
12710 #: ../en/ch10-hook.xml:201
12711 msgid ""
12712 "Sometimes you may want to enforce a policy that you do not want others to be "
12713 "able to work around. For example, you may have a requirement that every "
12714 "changeset must pass a rigorous set of tests. Defining this requirement via a "
12715 "hook in a site-wide <filename role=\"special\">~/.hgrc</filename> won't work "
12716 "for remote users on laptops, and of course local users can subvert it at will "
12717 "by overriding the hook."
12718 msgstr ""
12720 #. type: Content of: <book><chapter><sect1><sect2><para>
12721 #: ../en/ch10-hook.xml:210
12722 msgid ""
12723 "Instead, you can set up your policies for use of Mercurial so that people are "
12724 "expected to propagate changes through a well-known <quote>canonical</quote> "
12725 "server that you have locked down and configured appropriately."
12726 msgstr ""
12728 #. type: Content of: <book><chapter><sect1><sect2><para>
12729 #: ../en/ch10-hook.xml:216
12730 msgid ""
12731 "One way to do this is via a combination of social engineering and "
12732 "technology. Set up a restricted-access account; users can push changes over "
12733 "the network to repositories managed by this account, but they cannot log into "
12734 "the account and run normal shell commands. In this scenario, a user can "
12735 "commit a changeset that contains any old garbage they want."
12736 msgstr ""
12738 #. type: Content of: <book><chapter><sect1><sect2><para>
12739 #: ../en/ch10-hook.xml:225
12740 msgid ""
12741 "When someone pushes a changeset to the server that everyone pulls from, the "
12742 "server will test the changeset before it accepts it as permanent, and reject "
12743 "it if it fails to pass the test suite. If people only pull changes from this "
12744 "filtering server, it will serve to ensure that all changes that people pull "
12745 "have been automatically vetted."
12746 msgstr ""
12748 #. type: Content of: <book><chapter><sect1><title>
12749 #: ../en/ch10-hook.xml:237
12750 msgid "A short tutorial on using hooks"
12751 msgstr "使用钩子的简短指南"
12753 #. type: Content of: <book><chapter><sect1><para>
12754 #: ../en/ch10-hook.xml:239
12755 msgid ""
12756 "It is easy to write a Mercurial hook. Let's start with a hook that runs when "
12757 "you finish a <command role=\"hg-cmd\">hg commit</command>, and simply prints "
12758 "the hash of the changeset you just created. The hook is called <literal role="
12759 "\"hook\">commit</literal>."
12760 msgstr ""
12762 #. type: Content of: <book><chapter><sect1><para>
12763 #: ../en/ch10-hook.xml:246
12764 msgid "All hooks follow the pattern in this example."
12765 msgstr ""
12767 #. type: Content of: <book><chapter><sect1><para>
12768 #: ../en/ch10-hook.xml:250
12769 msgid ""
12770 "You add an entry to the <literal role=\"rc-hooks\">hooks</literal> section of "
12771 "your <filename role=\"special\">~/.hgrc</filename>. On the left is the name "
12772 "of the event to trigger on; on the right is the action to take. As you can "
12773 "see, you can run an arbitrary shell command in a hook. Mercurial passes "
12774 "extra information to the hook using environment variables (look for "
12775 "<envar>HG_NODE</envar> in the example)."
12776 msgstr ""
12778 #. type: Content of: <book><chapter><sect1><sect2><title>
12779 #: ../en/ch10-hook.xml:260
12780 msgid "Performing multiple actions per event"
12781 msgstr "每个事件执行多个操作"
12783 #. type: Content of: <book><chapter><sect1><sect2><para>
12784 #: ../en/ch10-hook.xml:262
12785 msgid ""
12786 "Quite often, you will want to define more than one hook for a particular kind "
12787 "of event, as shown below."
12788 msgstr ""
12790 #. type: Content of: <book><chapter><sect1><sect2><para>
12791 #: ../en/ch10-hook.xml:267
12792 msgid ""
12793 "Mercurial lets you do this by adding an <emphasis>extension</emphasis> to the "
12794 "end of a hook's name. You extend a hook's name by giving the name of the "
12795 "hook, followed by a full stop (the <quote><literal>.</literal></quote> "
12796 "character), followed by some more text of your choosing. For example, "
12797 "Mercurial will run both <literal>commit.foo</literal> and <literal>commit."
12798 "bar</literal> when the <literal>commit</literal> event occurs."
12799 msgstr ""
12801 #. type: Content of: <book><chapter><sect1><sect2><para>
12802 #: ../en/ch10-hook.xml:278
12803 msgid ""
12804 "To give a well-defined order of execution when there are multiple hooks "
12805 "defined for an event, Mercurial sorts hooks by extension, and executes the "
12806 "hook commands in this sorted order. In the above example, it will execute "
12807 "<literal>commit.bar</literal> before <literal>commit.foo</literal>, and "
12808 "<literal>commit</literal> before both."
12809 msgstr ""
12811 #. type: Content of: <book><chapter><sect1><sect2><para>
12812 #: ../en/ch10-hook.xml:287
12813 msgid ""
12814 "It is a good idea to use a somewhat descriptive extension when you define a "
12815 "new hook. This will help you to remember what the hook was for. If the hook "
12816 "fails, you'll get an error message that contains the hook name and extension, "
12817 "so using a descriptive extension could give you an immediate hint as to why "
12818 "the hook failed (see <xref linkend=\"sec:hook:perm\"/> for an example)."
12819 msgstr ""
12821 #. type: Content of: <book><chapter><sect1><sect2><title>
12822 #: ../en/ch10-hook.xml:298
12823 msgid "Controlling whether an activity can proceed"
12824 msgstr "控制处理的活动"
12826 #. type: Content of: <book><chapter><sect1><sect2><para>
12827 #: ../en/ch10-hook.xml:300
12828 msgid ""
12829 "In our earlier examples, we used the <literal role=\"hook\">commit</literal> "
12830 "hook, which is run after a commit has completed. This is one of several "
12831 "Mercurial hooks that run after an activity finishes. Such hooks have no way "
12832 "of influencing the activity itself."
12833 msgstr ""
12835 #. type: Content of: <book><chapter><sect1><sect2><para>
12836 #: ../en/ch10-hook.xml:307
12837 msgid ""
12838 "Mercurial defines a number of events that occur before an activity starts; or "
12839 "after it starts, but before it finishes. Hooks that trigger on these events "
12840 "have the added ability to choose whether the activity can continue, or will "
12841 "abort."
12842 msgstr ""
12844 #. type: Content of: <book><chapter><sect1><sect2><para>
12845 #: ../en/ch10-hook.xml:313
12846 msgid ""
12847 "The <literal role=\"hook\">pretxncommit</literal> hook runs after a commit "
12848 "has all but completed. In other words, the metadata representing the "
12849 "changeset has been written out to disk, but the transaction has not yet been "
12850 "allowed to complete. The <literal role=\"hook\">pretxncommit</literal> hook "
12851 "has the ability to decide whether the transaction can complete, or must be "
12852 "rolled back."
12853 msgstr ""
12855 #. type: Content of: <book><chapter><sect1><sect2><para>
12856 #: ../en/ch10-hook.xml:322
12857 msgid ""
12858 "If the <literal role=\"hook\">pretxncommit</literal> hook exits with a status "
12859 "code of zero, the transaction is allowed to complete; the commit finishes; "
12860 "and the <literal role=\"hook\">commit</literal> hook is run. If the <literal "
12861 "role=\"hook\">pretxncommit</literal> hook exits with a non-zero status code, "
12862 "the transaction is rolled back; the metadata representing the changeset is "
12863 "erased; and the <literal role=\"hook\">commit</literal> hook is not run."
12864 msgstr ""
12866 #. type: Content of: <book><chapter><sect1><sect2><para>
12867 #: ../en/ch10-hook.xml:334
12868 msgid ""
12869 "The hook in the example above checks that a commit comment contains a bug "
12870 "ID. If it does, the commit can complete. If not, the commit is rolled back."
12871 msgstr ""
12873 #. type: Content of: <book><chapter><sect1><title>
12874 #: ../en/ch10-hook.xml:342
12875 msgid "Writing your own hooks"
12876 msgstr "编写钩子"
12878 #. type: Content of: <book><chapter><sect1><para>
12879 #: ../en/ch10-hook.xml:344
12880 msgid ""
12881 "When you are writing a hook, you might find it useful to run Mercurial either "
12882 "with the <option role=\"hg-opt-global\">-v</option> option, or the <envar "
12883 "role=\"rc-item-ui\">verbose</envar> config item set to <quote>true</quote>. "
12884 "When you do so, Mercurial will print a message before it calls each hook."
12885 msgstr ""
12887 #. type: Content of: <book><chapter><sect1><sect2><title>
12888 #: ../en/ch10-hook.xml:353
12889 msgid "Choosing how your hook should run"
12890 msgstr "选择钩子的执行方式"
12892 #. type: Content of: <book><chapter><sect1><sect2><para>
12893 #: ../en/ch10-hook.xml:355
12894 msgid ""
12895 "You can write a hook either as a normal program&emdash;typically a shell "
12896 "script&emdash;or as a Python function that is executed within the Mercurial "
12897 "process."
12898 msgstr ""
12900 #. type: Content of: <book><chapter><sect1><sect2><para>
12901 #: ../en/ch10-hook.xml:360
12902 msgid ""
12903 "Writing a hook as an external program has the advantage that it requires no "
12904 "knowledge of Mercurial's internals. You can call normal Mercurial commands "
12905 "to get any added information you need. The trade-off is that external hooks "
12906 "are slower than in-process hooks."
12907 msgstr ""
12909 #. type: Content of: <book><chapter><sect1><sect2><para>
12910 #: ../en/ch10-hook.xml:367
12911 msgid ""
12912 "An in-process Python hook has complete access to the Mercurial API, and does "
12913 "not <quote>shell out</quote> to another process, so it is inherently faster "
12914 "than an external hook. It is also easier to obtain much of the information "
12915 "that a hook requires by using the Mercurial API than by running Mercurial "
12916 "commands."
12917 msgstr ""
12919 #. type: Content of: <book><chapter><sect1><sect2><para>
12920 #: ../en/ch10-hook.xml:375
12921 msgid ""
12922 "If you are comfortable with Python, or require high performance, writing your "
12923 "hooks in Python may be a good choice. However, when you have a "
12924 "straightforward hook to write and you don't need to care about performance "
12925 "(probably the majority of hooks), a shell script is perfectly fine."
12926 msgstr ""
12928 #. type: Content of: <book><chapter><sect1><sect2><title>
12929 #: ../en/ch10-hook.xml:384
12930 msgid "Hook parameters"
12931 msgstr "钩子的参数"
12933 #. type: Content of: <book><chapter><sect1><sect2><para>
12934 #: ../en/ch10-hook.xml:386
12935 msgid ""
12936 "Mercurial calls each hook with a set of well-defined parameters. In Python, "
12937 "a parameter is passed as a keyword argument to your hook function. For an "
12938 "external program, a parameter is passed as an environment variable."
12939 msgstr ""
12941 #. type: Content of: <book><chapter><sect1><sect2><para>
12942 #: ../en/ch10-hook.xml:392
12943 msgid ""
12944 "Whether your hook is written in Python or as a shell script, the hook-"
12945 "specific parameter names and values will be the same. A boolean parameter "
12946 "will be represented as a boolean value in Python, but as the number 1 (for "
12947 "<quote>true</quote>) or 0 (for <quote>false</quote>) as an environment "
12948 "variable for an external hook. If a hook parameter is named <literal>foo</"
12949 "literal>, the keyword argument for a Python hook will also be named "
12950 "<literal>foo</literal>, while the environment variable for an external hook "
12951 "will be named <literal>HG_FOO</literal>."
12952 msgstr ""
12954 #. type: Content of: <book><chapter><sect1><sect2><title>
12955 #: ../en/ch10-hook.xml:406
12956 msgid "Hook return values and activity control"
12957 msgstr "钩子的返回值与活动控制"
12959 #. type: Content of: <book><chapter><sect1><sect2><para>
12960 #: ../en/ch10-hook.xml:408
12961 msgid ""
12962 "A hook that executes successfully must exit with a status of zero if "
12963 "external, or return boolean <quote>false</quote> if in-process. Failure is "
12964 "indicated with a non-zero exit status from an external hook, or an in-process "
12965 "hook returning boolean <quote>true</quote>. If an in-process hook raises an "
12966 "exception, the hook is considered to have failed."
12967 msgstr ""
12969 #. type: Content of: <book><chapter><sect1><sect2><para>
12970 #: ../en/ch10-hook.xml:416
12971 msgid ""
12972 "For a hook that controls whether an activity can proceed, zero/false means "
12973 "<quote>allow</quote>, while non-zero/true/exception means <quote>deny</quote>."
12974 msgstr ""
12976 #. type: Content of: <book><chapter><sect1><sect2><title>
12977 #: ../en/ch10-hook.xml:423
12978 msgid "Writing an external hook"
12979 msgstr "编写外部钩子"
12981 #. type: Content of: <book><chapter><sect1><sect2><para>
12982 #: ../en/ch10-hook.xml:425
12983 msgid ""
12984 "When you define an external hook in your <filename role=\"special\">~/.hgrc</"
12985 "filename> and the hook is run, its value is passed to your shell, which "
12986 "interprets it. This means that you can use normal shell constructs in the "
12987 "body of the hook."
12988 msgstr ""
12990 #. type: Content of: <book><chapter><sect1><sect2><para>
12991 #: ../en/ch10-hook.xml:432
12992 msgid ""
12993 "An executable hook is always run with its current directory set to a "
12994 "repository's root directory."
12995 msgstr ""
12997 #. type: Content of: <book><chapter><sect1><sect2><para>
12998 #: ../en/ch10-hook.xml:436
12999 msgid ""
13000 "Each hook parameter is passed in as an environment variable; the name is "
13001 "upper-cased, and prefixed with the string <quote><literal>HG_</literal></"
13002 "quote>."
13003 msgstr ""
13005 #. type: Content of: <book><chapter><sect1><sect2><para>
13006 #: ../en/ch10-hook.xml:441
13007 msgid ""
13008 "With the exception of hook parameters, Mercurial does not set or modify any "
13009 "environment variables when running a hook. This is useful to remember if you "
13010 "are writing a site-wide hook that may be run by a number of different users "
13011 "with differing environment variables set. In multi-user situations, you "
13012 "should not rely on environment variables being set to the values you have in "
13013 "your environment when testing the hook."
13014 msgstr ""
13016 #. type: Content of: <book><chapter><sect1><sect2><title>
13017 #: ../en/ch10-hook.xml:452
13018 msgid "Telling Mercurial to use an in-process hook"
13019 msgstr "让 Mercurial 使用进程内钩子"
13021 #. type: Content of: <book><chapter><sect1><sect2><para>
13022 #: ../en/ch10-hook.xml:454
13023 msgid ""
13024 "The <filename role=\"special\">~/.hgrc</filename> syntax for defining an in-"
13025 "process hook is slightly different than for an executable hook. The value of "
13026 "the hook must start with the text <quote><literal>python:</literal></quote>, "
13027 "and continue with the fully-qualified name of a callable object to use as the "
13028 "hook's value."
13029 msgstr ""
13031 #. type: Content of: <book><chapter><sect1><sect2><para>
13032 #: ../en/ch10-hook.xml:462
13033 msgid ""
13034 "The module in which a hook lives is automatically imported when a hook is "
13035 "run. So long as you have the module name and <envar>PYTHONPATH</envar> "
13036 "right, it should <quote>just work</quote>."
13037 msgstr ""
13039 #. type: Content of: <book><chapter><sect1><sect2><para>
13040 #: ../en/ch10-hook.xml:468
13041 msgid ""
13042 "The following <filename role=\"special\">~/.hgrc</filename> example snippet "
13043 "illustrates the syntax and meaning of the notions we just described."
13044 msgstr ""
13046 #. type: Content of: <book><chapter><sect1><sect2><para>
13047 #: ../en/ch10-hook.xml:474
13048 msgid ""
13049 "When Mercurial runs the <literal>commit.example</literal> hook, it imports "
13050 "<literal>mymodule.submodule</literal>, looks for the callable object named "
13051 "<literal>myhook</literal>, and calls it."
13052 msgstr ""
13054 #. type: Content of: <book><chapter><sect1><sect2><title>
13055 #: ../en/ch10-hook.xml:482
13056 msgid "Writing an in-process hook"
13057 msgstr "编写进程内钩子"
13059 #. type: Content of: <book><chapter><sect1><sect2><para>
13060 #: ../en/ch10-hook.xml:484
13061 msgid ""
13062 "The simplest in-process hook does nothing, but illustrates the basic shape of "
13063 "the hook API:"
13064 msgstr ""
13066 #. type: Content of: <book><chapter><sect1><sect2><para>
13067 #: ../en/ch10-hook.xml:489
13068 msgid ""
13069 "The first argument to a Python hook is always a <literal role=\"py-mod-"
13070 "mercurial.ui\">ui</literal> object. The second is a repository object; at "
13071 "the moment, it is always an instance of <literal role=\"py-mod-mercurial."
13072 "localrepo\">localrepository</literal>. Following these two arguments are "
13073 "other keyword arguments. Which ones are passed in depends on the hook being "
13074 "called, but a hook can ignore arguments it doesn't care about by dropping "
13075 "them into a keyword argument dict, as with <literal>**kwargs</literal> above."
13076 msgstr ""
13078 #. type: Content of: <book><chapter><sect1><title>
13079 #: ../en/ch10-hook.xml:504
13080 msgid "Some hook examples"
13081 msgstr "钩子样例"
13083 #. type: Content of: <book><chapter><sect1><sect2><title>
13084 #: ../en/ch10-hook.xml:507
13085 msgid "Writing meaningful commit messages"
13086 msgstr "编写有意义的提交日志"
13088 #. type: Content of: <book><chapter><sect1><sect2><para>
13089 #: ../en/ch10-hook.xml:509
13090 msgid ""
13091 "It's hard to imagine a useful commit message being very short. The simple "
13092 "<literal role=\"hook\">pretxncommit</literal> hook of the example below will "
13093 "prevent you from committing a changeset with a message that is less than ten "
13094 "bytes long."
13095 msgstr ""
13097 #. type: Content of: <book><chapter><sect1><sect2><title>
13098 #: ../en/ch10-hook.xml:519
13099 msgid "Checking for trailing whitespace"
13100 msgstr "检查行尾空格"
13102 #. type: Content of: <book><chapter><sect1><sect2><para>
13103 #: ../en/ch10-hook.xml:521
13104 msgid ""
13105 "An interesting use of a commit-related hook is to help you to write cleaner "
13106 "code. A simple example of <quote>cleaner code</quote> is the dictum that a "
13107 "change should not add any new lines of text that contain <quote>trailing "
13108 "whitespace</quote>. Trailing whitespace is a series of space and tab "
13109 "characters at the end of a line of text. In most cases, trailing whitespace "
13110 "is unnecessary, invisible noise, but it is occasionally problematic, and "
13111 "people often prefer to get rid of it."
13112 msgstr ""
13114 #. type: Content of: <book><chapter><sect1><sect2><para>
13115 #: ../en/ch10-hook.xml:532
13116 msgid ""
13117 "You can use either the <literal role=\"hook\">precommit</literal> or <literal "
13118 "role=\"hook\">pretxncommit</literal> hook to tell whether you have a trailing "
13119 "whitespace problem. If you use the <literal role=\"hook\">precommit</"
13120 "literal> hook, the hook will not know which files you are committing, so it "
13121 "will have to check every modified file in the repository for trailing white "
13122 "space. If you want to commit a change to just the file <filename>foo</"
13123 "filename>, but the file <filename>bar</filename> contains trailing "
13124 "whitespace, doing a check in the <literal role=\"hook\">precommit</literal> "
13125 "hook will prevent you from committing <filename>foo</filename> due to the "
13126 "problem with <filename>bar</filename>. This doesn't seem right."
13127 msgstr ""
13129 #. type: Content of: <book><chapter><sect1><sect2><para>
13130 #: ../en/ch10-hook.xml:548
13131 msgid ""
13132 "Should you choose the <literal role=\"hook\">pretxncommit</literal> hook, the "
13133 "check won't occur until just before the transaction for the commit "
13134 "completes. This will allow you to check for problems only the exact files "
13135 "that are being committed. However, if you entered the commit message "
13136 "interactively and the hook fails, the transaction will roll back; you'll have "
13137 "to re-enter the commit message after you fix the trailing whitespace and run "
13138 "<command role=\"hg-cmd\">hg commit</command> again."
13139 msgstr ""
13141 #. type: Content of: <book><chapter><sect1><sect2><para>
13142 #: ../en/ch10-hook.xml:561
13143 msgid ""
13144 "In this example, we introduce a simple <literal role=\"hook\">pretxncommit</"
13145 "literal> hook that checks for trailing whitespace. This hook is short, but "
13146 "not very helpful. It exits with an error status if a change adds a line with "
13147 "trailing whitespace to any file, but does not print any information that "
13148 "might help us to identify the offending file or line. It also has the nice "
13149 "property of not paying attention to unmodified lines; only lines that "
13150 "introduce new trailing whitespace cause problems."
13151 msgstr ""
13153 #. type: Content of: <book><chapter><sect1><sect2><para>
13154 #: ../en/ch10-hook.xml:574
13155 msgid ""
13156 "The above version is much more complex, but also more useful. It parses a "
13157 "unified diff to see if any lines add trailing whitespace, and prints the name "
13158 "of the file and the line number of each such occurrence. Even better, if the "
13159 "change adds trailing whitespace, this hook saves the commit comment and "
13160 "prints the name of the save file before exiting and telling Mercurial to roll "
13161 "the transaction back, so you can use the <option role=\"hg-opt-commit\">-l "
13162 "filename</option> option to <command role=\"hg-cmd\">hg commit</command> to "
13163 "reuse the saved commit message once you've corrected the problem."
13164 msgstr ""
13166 #. type: Content of: <book><chapter><sect1><sect2><para>
13167 #: ../en/ch10-hook.xml:588
13168 msgid ""
13169 "As a final aside, note in the example above the use of <command>sed</"
13170 "command>'s in-place editing feature to get rid of trailing whitespace from a "
13171 "file. This is concise and useful enough that I will reproduce it here (using "
13172 "<command>perl</command> for good measure)."
13173 msgstr ""
13175 #. type: Content of: <book><chapter><sect1><title>
13176 #: ../en/ch10-hook.xml:598
13177 msgid "Bundled hooks"
13178 msgstr "内置的钩子"
13180 #. type: Content of: <book><chapter><sect1><para>
13181 #: ../en/ch10-hook.xml:600
13182 msgid ""
13183 "Mercurial ships with several bundled hooks. You can find them in the "
13184 "<filename class=\"directory\">hgext</filename> directory of a Mercurial "
13185 "source tree. If you are using a Mercurial binary package, the hooks will be "
13186 "located in the <filename class=\"directory\">hgext</filename> directory of "
13187 "wherever your package installer put Mercurial."
13188 msgstr ""
13190 #. type: Content of: <book><chapter><sect1><sect2><title>
13191 #: ../en/ch10-hook.xml:609
13192 msgid ""
13193 "<literal role=\"hg-ext\">acl</literal>&emdash;access control for parts of a "
13194 "repository"
13195 msgstr "<literal role=\"hg-ext\">acl</literal>—版本库的访问控制"
13197 #. type: Content of: <book><chapter><sect1><sect2><para>
13198 #: ../en/ch10-hook.xml:612
13199 msgid ""
13200 "The <literal role=\"hg-ext\">acl</literal> extension lets you control which "
13201 "remote users are allowed to push changesets to a networked server. You can "
13202 "protect any portion of a repository (including the entire repo), so that a "
13203 "specific remote user can push changes that do not affect the protected "
13204 "portion."
13205 msgstr ""
13207 #. type: Content of: <book><chapter><sect1><sect2><para>
13208 #: ../en/ch10-hook.xml:620
13209 msgid ""
13210 "This extension implements access control based on the identity of the user "
13211 "performing a push, <emphasis>not</emphasis> on who committed the changesets "
13212 "they're pushing. It makes sense to use this hook only if you have a locked-"
13213 "down server environment that authenticates remote users, and you want to be "
13214 "sure that only specific users are allowed to push changes to that server."
13215 msgstr ""
13217 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
13218 #: ../en/ch10-hook.xml:630
13219 msgid "Configuring the <literal role=\"hook\">acl</literal> hook"
13220 msgstr "配置 <literal role=\"hook\">acl</literal> 钩子"
13222 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13223 #: ../en/ch10-hook.xml:633
13224 msgid ""
13225 "In order to manage incoming changesets, the <literal role=\"hg-ext\">acl</"
13226 "literal> hook must be used as a <literal role=\"hook\">pretxnchangegroup</"
13227 "literal> hook. This lets it see which files are modified by each incoming "
13228 "changeset, and roll back a group of changesets if they modify "
13229 "<quote>forbidden</quote> files. Example:"
13230 msgstr ""
13232 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13233 #: ../en/ch10-hook.xml:643
13234 msgid ""
13235 "The <literal role=\"hg-ext\">acl</literal> extension is configured using "
13236 "three sections."
13237 msgstr ""
13239 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13240 #: ../en/ch10-hook.xml:647
13241 msgid ""
13242 "The <literal role=\"rc-acl\">acl</literal> section has only one entry, <envar "
13243 "role=\"rc-item-acl\">sources</envar>, which lists the sources of incoming "
13244 "changesets that the hook should pay attention to. You don't normally need to "
13245 "configure this section."
13246 msgstr ""
13248 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13249 #: ../en/ch10-hook.xml:654
13250 msgid ""
13251 "<envar role=\"rc-item-acl\">serve</envar>: Control incoming changesets that "
13252 "are arriving from a remote repository over http or ssh. This is the default "
13253 "value of <envar role=\"rc-item-acl\">sources</envar>, and usually the only "
13254 "setting you'll need for this configuration item."
13255 msgstr ""
13257 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13258 #: ../en/ch10-hook.xml:662
13259 msgid ""
13260 "<envar role=\"rc-item-acl\">pull</envar>: Control incoming changesets that "
13261 "are arriving via a pull from a local repository."
13262 msgstr ""
13264 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13265 #: ../en/ch10-hook.xml:667
13266 msgid ""
13267 "<envar role=\"rc-item-acl\">push</envar>: Control incoming changesets that "
13268 "are arriving via a push from a local repository."
13269 msgstr ""
13271 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13272 #: ../en/ch10-hook.xml:672
13273 msgid ""
13274 "<envar role=\"rc-item-acl\">bundle</envar>: Control incoming changesets that "
13275 "are arriving from another repository via a bundle."
13276 msgstr ""
13278 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13279 #: ../en/ch10-hook.xml:678
13280 msgid ""
13281 "The <literal role=\"rc-acl.allow\">acl.allow</literal> section controls the "
13282 "users that are allowed to add changesets to the repository. If this section "
13283 "is not present, all users that are not explicitly denied are allowed. If "
13284 "this section is present, all users that are not explicitly allowed are denied "
13285 "(so an empty section means that all users are denied)."
13286 msgstr ""
13288 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13289 #: ../en/ch10-hook.xml:687
13290 msgid ""
13291 "The <literal role=\"rc-acl.deny\">acl.deny</literal> section determines which "
13292 "users are denied from adding changesets to the repository. If this section "
13293 "is not present or is empty, no users are denied."
13294 msgstr ""
13296 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13297 #: ../en/ch10-hook.xml:693
13298 msgid ""
13299 "The syntaxes for the <literal role=\"rc-acl.allow\">acl.allow</literal> and "
13300 "<literal role=\"rc-acl.deny\">acl.deny</literal> sections are identical. On "
13301 "the left of each entry is a glob pattern that matches files or directories, "
13302 "relative to the root of the repository; on the right, a user name."
13303 msgstr ""
13305 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13306 #: ../en/ch10-hook.xml:701
13307 msgid ""
13308 "In the following example, the user <literal>docwriter</literal> can only push "
13309 "changes to the <filename class=\"directory\">docs</filename> subtree of the "
13310 "repository, while <literal>intern</literal> can push changes to any file or "
13311 "directory except <filename class=\"directory\">source/sensitive</filename>."
13312 msgstr ""
13314 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
13315 #: ../en/ch10-hook.xml:715 ../en/ch10-hook.xml:979 ../en/ch10-hook.xml:1169
13316 msgid "Testing and troubleshooting"
13317 msgstr "测试与问题处理"
13319 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13320 #: ../en/ch10-hook.xml:717
13321 msgid ""
13322 "If you want to test the <literal role=\"hg-ext\">acl</literal> hook, run it "
13323 "with Mercurial's debugging output enabled. Since you'll probably be running "
13324 "it on a server where it's not convenient (or sometimes possible) to pass in "
13325 "the <option role=\"hg-opt-global\">--debug</option> option, don't forget that "
13326 "you can enable debugging output in your <filename role=\"special\">~/.hgrc</"
13327 "filename>:"
13328 msgstr ""
13330 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13331 #: ../en/ch10-hook.xml:728
13332 msgid ""
13333 "With this enabled, the <literal role=\"hg-ext\">acl</literal> hook will print "
13334 "enough information to let you figure out why it is allowing or forbidding "
13335 "pushes from specific users."
13336 msgstr ""
13338 #. type: Content of: <book><chapter><sect1><sect2><title>
13339 #: ../en/ch10-hook.xml:737
13340 msgid ""
13341 "<literal role=\"hg-ext\">bugzilla</literal>&emdash;integration with Bugzilla"
13342 msgstr "<literal role=\"hg-ext\">bugzilla</literal>—与 Bugzilla 的集成"
13344 #. type: Content of: <book><chapter><sect1><sect2><para>
13345 #: ../en/ch10-hook.xml:741
13346 msgid ""
13347 "The <literal role=\"hg-ext\">bugzilla</literal> extension adds a comment to a "
13348 "Bugzilla bug whenever it finds a reference to that bug ID in a commit "
13349 "comment. You can install this hook on a shared server, so that any time a "
13350 "remote user pushes changes to this server, the hook gets run."
13351 msgstr ""
13353 #. type: Content of: <book><chapter><sect1><sect2><para>
13354 #: ../en/ch10-hook.xml:748
13355 msgid ""
13356 "It adds a comment to the bug that looks like this (you can configure the "
13357 "contents of the comment&emdash;see below):"
13358 msgstr ""
13360 #. type: Content of: <book><chapter><sect1><sect2><para>
13361 #: ../en/ch10-hook.xml:757
13362 msgid ""
13363 "The value of this hook is that it automates the process of updating a bug any "
13364 "time a changeset refers to it. If you configure the hook properly, it makes "
13365 "it easy for people to browse straight from a Bugzilla bug to a changeset that "
13366 "refers to that bug."
13367 msgstr ""
13369 #. type: Content of: <book><chapter><sect1><sect2><para>
13370 #: ../en/ch10-hook.xml:764
13371 msgid ""
13372 "You can use the code in this hook as a starting point for some more exotic "
13373 "Bugzilla integration recipes. Here are a few possibilities:"
13374 msgstr ""
13376 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13377 #: ../en/ch10-hook.xml:769
13378 msgid ""
13379 "Require that every changeset pushed to the server have a valid bug ID in its "
13380 "commit comment. In this case, you'd want to configure the hook as a <literal "
13381 "role=\"hook\">pretxncommit</literal> hook. This would allow the hook to "
13382 "reject changes that didn't contain bug IDs."
13383 msgstr ""
13385 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13386 #: ../en/ch10-hook.xml:777
13387 msgid ""
13388 "Allow incoming changesets to automatically modify the <emphasis>state</"
13389 "emphasis> of a bug, as well as simply adding a comment. For example, the "
13390 "hook could recognise the string <quote>fixed bug 31337</quote> as indicating "
13391 "that it should update the state of bug 31337 to <quote>requires testing</"
13392 "quote>."
13393 msgstr ""
13395 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
13396 #: ../en/ch10-hook.xml:787
13397 msgid "Configuring the <literal role=\"hook\">bugzilla</literal> hook"
13398 msgstr "配置 <literal role=\"hook\">bugzilla</literal> 钩子"
13400 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13401 #: ../en/ch10-hook.xml:790
13402 msgid ""
13403 "You should configure this hook in your server's <filename role=\"special\">~/."
13404 "hgrc</filename> as an <literal role=\"hook\">incoming</literal> hook, for "
13405 "example as follows:"
13406 msgstr ""
13408 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13409 #: ../en/ch10-hook.xml:798
13410 msgid ""
13411 "Because of the specialised nature of this hook, and because Bugzilla was not "
13412 "written with this kind of integration in mind, configuring this hook is a "
13413 "somewhat involved process."
13414 msgstr ""
13416 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13417 #: ../en/ch10-hook.xml:804
13418 msgid ""
13419 "Before you begin, you must install the MySQL bindings for Python on the host"
13420 "(s) where you'll be running the hook. If this is not available as a binary "
13421 "package for your system, you can download it from <citation>web:mysql-python</"
13422 "citation>."
13423 msgstr ""
13425 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13426 #: ../en/ch10-hook.xml:811
13427 msgid ""
13428 "Configuration information for this hook lives in the <literal role=\"rc-"
13429 "bugzilla\">bugzilla</literal> section of your <filename role=\"special\">~/."
13430 "hgrc</filename>."
13431 msgstr ""
13433 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13434 #: ../en/ch10-hook.xml:816
13435 msgid ""
13436 "<envar role=\"rc-item-bugzilla\">version</envar>: The version of Bugzilla "
13437 "installed on the server. The database schema that Bugzilla uses changes "
13438 "occasionally, so this hook has to know exactly which schema to use."
13439 msgstr ""
13441 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13442 #: ../en/ch10-hook.xml:822
13443 msgid ""
13444 "<envar role=\"rc-item-bugzilla\">host</envar>: The hostname of the MySQL "
13445 "server that stores your Bugzilla data. The database must be configured to "
13446 "allow connections from whatever host you are running the <literal role=\"hook"
13447 "\">bugzilla</literal> hook on."
13448 msgstr ""
13450 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13451 #: ../en/ch10-hook.xml:829
13452 msgid ""
13453 "<envar role=\"rc-item-bugzilla\">user</envar>: The username with which to "
13454 "connect to the MySQL server. The database must be configured to allow this "
13455 "user to connect from whatever host you are running the <literal role=\"hook"
13456 "\">bugzilla</literal> hook on. This user must be able to access and modify "
13457 "Bugzilla tables. The default value of this item is <literal>bugs</literal>, "
13458 "which is the standard name of the Bugzilla user in a MySQL database."
13459 msgstr ""
13461 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13462 #: ../en/ch10-hook.xml:840
13463 msgid ""
13464 "<envar role=\"rc-item-bugzilla\">password</envar>: The MySQL password for the "
13465 "user you configured above. This is stored as plain text, so you should make "
13466 "sure that unauthorised users cannot read the <filename role=\"special\">~/."
13467 "hgrc</filename> file where you store this information."
13468 msgstr ""
13470 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13471 #: ../en/ch10-hook.xml:849
13472 msgid ""
13473 "<envar role=\"rc-item-bugzilla\">db</envar>: The name of the Bugzilla "
13474 "database on the MySQL server. The default value of this item is "
13475 "<literal>bugs</literal>, which is the standard name of the MySQL database "
13476 "where Bugzilla stores its data."
13477 msgstr ""
13479 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13480 #: ../en/ch10-hook.xml:856
13481 msgid ""
13482 "<envar role=\"rc-item-bugzilla\">notify</envar>: If you want Bugzilla to send "
13483 "out a notification email to subscribers after this hook has added a comment "
13484 "to a bug, you will need this hook to run a command whenever it updates the "
13485 "database. The command to run depends on where you have installed Bugzilla, "
13486 "but it will typically look something like this, if you have Bugzilla "
13487 "installed in <filename class=\"directory\">/var/www/html/bugzilla</filename>:"
13488 msgstr ""
13490 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13491 #: ../en/ch10-hook.xml:869
13492 msgid ""
13493 "The Bugzilla <literal>processmail</literal> program expects to be given a bug "
13494 "ID (the hook replaces <quote><literal>%s</literal></quote> with the bug ID) "
13495 "and an email address. It also expects to be able to write to some files in "
13496 "the directory that it runs in. If Bugzilla and this hook are not installed "
13497 "on the same machine, you will need to find a way to run <literal>processmail</"
13498 "literal> on the server where Bugzilla is installed."
13499 msgstr ""
13501 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
13502 #: ../en/ch10-hook.xml:884
13503 msgid "Mapping committer names to Bugzilla user names"
13504 msgstr "提交者的名称与 Bugzilla 用户名称的映射"
13506 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13507 #: ../en/ch10-hook.xml:886
13508 msgid ""
13509 "By default, the <literal role=\"hg-ext\">bugzilla</literal> hook tries to use "
13510 "the email address of a changeset's committer as the Bugzilla user name with "
13511 "which to update a bug. If this does not suit your needs, you can map "
13512 "committer email addresses to Bugzilla user names using a <literal role=\"rc-"
13513 "usermap\">usermap</literal> section."
13514 msgstr ""
13516 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13517 #: ../en/ch10-hook.xml:895
13518 msgid ""
13519 "Each item in the <literal role=\"rc-usermap\">usermap</literal> section "
13520 "contains an email address on the left, and a Bugzilla user name on the right."
13521 msgstr ""
13523 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13524 #: ../en/ch10-hook.xml:902
13525 msgid ""
13526 "You can either keep the <literal role=\"rc-usermap\">usermap</literal> data "
13527 "in a normal <filename role=\"special\">~/.hgrc</filename>, or tell the "
13528 "<literal role=\"hg-ext\">bugzilla</literal> hook to read the information from "
13529 "an external <filename>usermap</filename> file. In the latter case, you can "
13530 "store <filename>usermap</filename> data by itself in (for example) a user-"
13531 "modifiable repository. This makes it possible to let your users maintain "
13532 "their own <envar role=\"rc-item-bugzilla\">usermap</envar> entries. The main "
13533 "<filename role=\"special\">~/.hgrc</filename> file might look like this:"
13534 msgstr ""
13536 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13537 #: ../en/ch10-hook.xml:918
13538 msgid ""
13539 "While the <filename>usermap</filename> file that it refers to might look like "
13540 "this:"
13541 msgstr ""
13543 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
13544 #: ../en/ch10-hook.xml:926
13545 msgid "Configuring the text that gets added to a bug"
13546 msgstr "配置增加到问题中的正文"
13548 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13549 #: ../en/ch10-hook.xml:928
13550 msgid ""
13551 "You can configure the text that this hook adds as a comment; you specify it "
13552 "in the form of a Mercurial template. Several <filename role=\"special\">~/."
13553 "hgrc</filename> entries (still in the <literal role=\"rc-bugzilla\">bugzilla</"
13554 "literal> section) control this behavior."
13555 msgstr ""
13557 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13558 #: ../en/ch10-hook.xml:935
13559 msgid ""
13560 "<literal>strip</literal>: The number of leading path elements to strip from a "
13561 "repository's path name to construct a partial path for a URL. For example, if "
13562 "the repositories on your server live under <filename class=\"directory\">/"
13563 "home/hg/repos</filename>, and you have a repository whose path is <filename "
13564 "class=\"directory\">/home/hg/repos/app/tests</filename>, then setting "
13565 "<literal>strip</literal> to <literal>4</literal> will give a partial path of "
13566 "<filename class=\"directory\">app/tests</filename>. The hook will make this "
13567 "partial path available when expanding a template, as <literal>webroot</"
13568 "literal>."
13569 msgstr ""
13571 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13572 #: ../en/ch10-hook.xml:949
13573 msgid ""
13574 "<literal>template</literal>: The text of the template to use. In addition to "
13575 "the usual changeset-related variables, this template can use <literal>hgweb</"
13576 "literal> (the value of the <literal>hgweb</literal> configuration item above) "
13577 "and <literal>webroot</literal> (the path constructed using <literal>strip</"
13578 "literal> above)."
13579 msgstr ""
13581 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13582 #: ../en/ch10-hook.xml:959
13583 msgid ""
13584 "In addition, you can add a <envar role=\"rc-item-web\">baseurl</envar> item "
13585 "to the <literal role=\"rc-web\">web</literal> section of your <filename role="
13586 "\"special\">~/.hgrc</filename>. The <literal role=\"hg-ext\">bugzilla</"
13587 "literal> hook will make this available when expanding a template, as the base "
13588 "string to use when constructing a URL that will let users browse from a "
13589 "Bugzilla comment to view a changeset. Example:"
13590 msgstr ""
13592 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13593 #: ../en/ch10-hook.xml:971
13594 msgid ""
13595 "Here is an example set of <literal role=\"hg-ext\">bugzilla</literal> hook "
13596 "config information."
13597 msgstr ""
13599 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13600 #: ../en/ch10-hook.xml:981
13601 msgid ""
13602 "The most common problems with configuring the <literal role=\"hg-ext"
13603 "\">bugzilla</literal> hook relate to running Bugzilla's "
13604 "<filename>processmail</filename> script and mapping committer names to user "
13605 "names."
13606 msgstr ""
13608 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13609 #: ../en/ch10-hook.xml:987
13610 msgid ""
13611 "Recall from <xref linkend=\"sec:hook:bugzilla:config\"/> above that the user "
13612 "that runs the Mercurial process on the server is also the one that will run "
13613 "the <filename>processmail</filename> script. The <filename>processmail</"
13614 "filename> script sometimes causes Bugzilla to write to files in its "
13615 "configuration directory, and Bugzilla's configuration files are usually owned "
13616 "by the user that your web server runs under."
13617 msgstr ""
13619 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13620 #: ../en/ch10-hook.xml:998
13621 msgid ""
13622 "You can cause <filename>processmail</filename> to be run with the suitable "
13623 "user's identity using the <command>sudo</command> command. Here is an "
13624 "example entry for a <filename>sudoers</filename> file."
13625 msgstr ""
13627 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13628 #: ../en/ch10-hook.xml:1005
13629 msgid ""
13630 "This allows the <literal>hg_user</literal> user to run a "
13631 "<filename>processmail-wrapper</filename> program under the identity of "
13632 "<literal>httpd_user</literal>."
13633 msgstr ""
13635 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13636 #: ../en/ch10-hook.xml:1010
13637 msgid ""
13638 "This indirection through a wrapper script is necessary, because "
13639 "<filename>processmail</filename> expects to be run with its current directory "
13640 "set to wherever you installed Bugzilla; you can't specify that kind of "
13641 "constraint in a <filename>sudoers</filename> file. The contents of the "
13642 "wrapper script are simple:"
13643 msgstr ""
13645 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13646 #: ../en/ch10-hook.xml:1019
13647 msgid ""
13648 "It doesn't seem to matter what email address you pass to "
13649 "<filename>processmail</filename>."
13650 msgstr ""
13652 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13653 #: ../en/ch10-hook.xml:1023
13654 msgid ""
13655 "If your <literal role=\"rc-usermap\">usermap</literal> is not set up "
13656 "correctly, users will see an error message from the <literal role=\"hg-ext"
13657 "\">bugzilla</literal> hook when they push changes to the server. The error "
13658 "message will look like this:"
13659 msgstr ""
13661 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13662 #: ../en/ch10-hook.xml:1030
13663 msgid ""
13664 "What this means is that the committer's address, <literal>john.q."
13665 "public@example.com</literal>, is not a valid Bugzilla user name, nor does it "
13666 "have an entry in your <literal role=\"rc-usermap\">usermap</literal> that "
13667 "maps it to a valid Bugzilla user name."
13668 msgstr ""
13670 #. type: Content of: <book><chapter><sect1><sect2><title>
13671 #: ../en/ch10-hook.xml:1040
13672 msgid ""
13673 "<literal role=\"hg-ext\">notify</literal>&emdash;send email notifications"
13674 msgstr "<literal role=\"hg-ext\">notify</literal>—邮件通知"
13676 #. type: Content of: <book><chapter><sect1><sect2><para>
13677 #: ../en/ch10-hook.xml:1043
13678 msgid ""
13679 "Although Mercurial's built-in web server provides RSS feeds of changes in "
13680 "every repository, many people prefer to receive change notifications via "
13681 "email. The <literal role=\"hg-ext\">notify</literal> hook lets you send out "
13682 "notifications to a set of email addresses whenever changesets arrive that "
13683 "those subscribers are interested in."
13684 msgstr ""
13686 #. type: Content of: <book><chapter><sect1><sect2><para>
13687 #: ../en/ch10-hook.xml:1051
13688 msgid ""
13689 "As with the <literal role=\"hg-ext\">bugzilla</literal> hook, the <literal "
13690 "role=\"hg-ext\">notify</literal> hook is template-driven, so you can "
13691 "customise the contents of the notification messages that it sends."
13692 msgstr ""
13694 #. type: Content of: <book><chapter><sect1><sect2><para>
13695 #: ../en/ch10-hook.xml:1057
13696 msgid ""
13697 "By default, the <literal role=\"hg-ext\">notify</literal> hook includes a "
13698 "diff of every changeset that it sends out; you can limit the size of the "
13699 "diff, or turn this feature off entirely. It is useful for letting "
13700 "subscribers review changes immediately, rather than clicking to follow a URL."
13701 msgstr ""
13703 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
13704 #: ../en/ch10-hook.xml:1065
13705 msgid "Configuring the <literal role=\"hg-ext\">notify</literal> hook"
13706 msgstr "配置 <literal role=\"hg-ext\">notify</literal> 钩子"
13708 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13709 #: ../en/ch10-hook.xml:1068
13710 msgid ""
13711 "You can set up the <literal role=\"hg-ext\">notify</literal> hook to send one "
13712 "email message per incoming changeset, or one per incoming group of changesets "
13713 "(all those that arrived in a single pull or push)."
13714 msgstr ""
13716 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13717 #: ../en/ch10-hook.xml:1080
13718 msgid ""
13719 "Configuration information for this hook lives in the <literal role=\"rc-notify"
13720 "\">notify</literal> section of a <filename role=\"special\">~/.hgrc</"
13721 "filename> file."
13722 msgstr ""
13724 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13725 #: ../en/ch10-hook.xml:1085
13726 msgid ""
13727 "<envar role=\"rc-item-notify\">test</envar>: By default, this hook does not "
13728 "send out email at all; instead, it prints the message that it "
13729 "<emphasis>would</emphasis> send. Set this item to <literal>false</literal> "
13730 "to allow email to be sent. The reason that sending of email is turned off by "
13731 "default is that it takes several tries to configure this extension exactly as "
13732 "you would like, and it would be bad form to spam subscribers with a number of "
13733 "<quote>broken</quote> notifications while you debug your configuration."
13734 msgstr ""
13736 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13737 #: ../en/ch10-hook.xml:1097
13738 msgid ""
13739 "<envar role=\"rc-item-notify\">config</envar>: The path to a configuration "
13740 "file that contains subscription information. This is kept separate from the "
13741 "main <filename role=\"special\">~/.hgrc</filename> so that you can maintain "
13742 "it in a repository of its own. People can then clone that repository, update "
13743 "their subscriptions, and push the changes back to your server."
13744 msgstr ""
13746 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13747 #: ../en/ch10-hook.xml:1106
13748 msgid ""
13749 "<envar role=\"rc-item-notify\">strip</envar>: The number of leading path "
13750 "separator characters to strip from a repository's path, when deciding whether "
13751 "a repository has subscribers. For example, if the repositories on your "
13752 "server live in <filename class=\"directory\">/home/hg/repos</filename>, and "
13753 "<literal role=\"hg-ext\">notify</literal> is considering a repository named "
13754 "<filename class=\"directory\">/home/hg/repos/shared/test</filename>, setting "
13755 "<envar role=\"rc-item-notify\">strip</envar> to <literal>4</literal> will "
13756 "cause <literal role=\"hg-ext\">notify</literal> to trim the path it considers "
13757 "down to <filename class=\"directory\">shared/test</filename>, and it will "
13758 "match subscribers against that."
13759 msgstr ""
13761 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13762 #: ../en/ch10-hook.xml:1123
13763 msgid ""
13764 "<envar role=\"rc-item-notify\">template</envar>: The template text to use "
13765 "when sending messages. This specifies both the contents of the message "
13766 "header and its body."
13767 msgstr ""
13769 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13770 #: ../en/ch10-hook.xml:1129
13771 msgid ""
13772 "<envar role=\"rc-item-notify\">maxdiff</envar>: The maximum number of lines "
13773 "of diff data to append to the end of a message. If a diff is longer than "
13774 "this, it is truncated. By default, this is set to 300. Set this to "
13775 "<literal>0</literal> to omit diffs from notification emails."
13776 msgstr ""
13778 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13779 #: ../en/ch10-hook.xml:1138
13780 msgid ""
13781 "<envar role=\"rc-item-notify\">sources</envar>: A list of sources of "
13782 "changesets to consider. This lets you limit <literal role=\"hg-ext\">notify</"
13783 "literal> to only sending out email about changes that remote users pushed "
13784 "into this repository via a server, for example. See <xref linkend=\"sec:hook:"
13785 "sources\"/> for the sources you can specify here."
13786 msgstr ""
13788 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13789 #: ../en/ch10-hook.xml:1149
13790 msgid ""
13791 "If you set the <envar role=\"rc-item-web\">baseurl</envar> item in the "
13792 "<literal role=\"rc-web\">web</literal> section, you can use it in a template; "
13793 "it will be available as <literal>webroot</literal>."
13794 msgstr ""
13796 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13797 #: ../en/ch10-hook.xml:1155
13798 msgid ""
13799 "Here is an example set of <literal role=\"hg-ext\">notify</literal> "
13800 "configuration information."
13801 msgstr ""
13803 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13804 #: ../en/ch10-hook.xml:1161
13805 msgid "This will produce a message that looks like the following:"
13806 msgstr ""
13808 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13809 #: ../en/ch10-hook.xml:1171
13810 msgid ""
13811 "Do not forget that by default, the <literal role=\"hg-ext\">notify</literal> "
13812 "extension <emphasis>will not send any mail</emphasis> until you explicitly "
13813 "configure it to do so, by setting <envar role=\"rc-item-notify\">test</envar> "
13814 "to <literal>false</literal>. Until you do that, it simply prints the message "
13815 "it <emphasis>would</emphasis> send."
13816 msgstr ""
13818 #. type: Content of: <book><chapter><sect1><title>
13819 #: ../en/ch10-hook.xml:1183
13820 msgid "Information for writers of hooks"
13821 msgstr "编写钩子的信息"
13823 #. type: Content of: <book><chapter><sect1><sect2><title>
13824 #: ../en/ch10-hook.xml:1186
13825 msgid "In-process hook execution"
13826 msgstr "进程内钩子的执行"
13828 #. type: Content of: <book><chapter><sect1><sect2><para>
13829 #: ../en/ch10-hook.xml:1188
13830 msgid "An in-process hook is called with arguments of the following form:"
13831 msgstr ""
13833 #. type: Content of: <book><chapter><sect1><sect2><para>
13834 #: ../en/ch10-hook.xml:1192
13835 msgid ""
13836 "The <literal>ui</literal> parameter is a <literal role=\"py-mod-mercurial.ui"
13837 "\">ui</literal> object. The <literal>repo</literal> parameter is a <literal "
13838 "role=\"py-mod-mercurial.localrepo\">localrepository</literal> object. The "
13839 "names and values of the <literal>**kwargs</literal> parameters depend on the "
13840 "hook being invoked, with the following common features:"
13841 msgstr ""
13843 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13844 #: ../en/ch10-hook.xml:1201
13845 msgid ""
13846 "If a parameter is named <literal>node</literal> or <literal>parentN</"
13847 "literal>, it will contain a hexadecimal changeset ID. The empty string is "
13848 "used to represent <quote>null changeset ID</quote> instead of a string of "
13849 "zeroes."
13850 msgstr ""
13852 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13853 #: ../en/ch10-hook.xml:1208
13854 msgid ""
13855 "If a parameter is named <literal>url</literal>, it will contain the URL of a "
13856 "remote repository, if that can be determined."
13857 msgstr ""
13859 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13860 #: ../en/ch10-hook.xml:1213
13861 msgid ""
13862 "Boolean-valued parameters are represented as Python <literal>bool</literal> "
13863 "objects."
13864 msgstr ""
13866 #. type: Content of: <book><chapter><sect1><sect2><para>
13867 #: ../en/ch10-hook.xml:1218
13868 msgid ""
13869 "An in-process hook is called without a change to the process's working "
13870 "directory (unlike external hooks, which are run in the root of the "
13871 "repository). It must not change the process's working directory, or it will "
13872 "cause any calls it makes into the Mercurial API to fail."
13873 msgstr ""
13875 #. type: Content of: <book><chapter><sect1><sect2><para>
13876 #: ../en/ch10-hook.xml:1225
13877 msgid ""
13878 "If a hook returns a boolean <quote>false</quote> value, it is considered to "
13879 "have succeeded. If it returns a boolean <quote>true</quote> value or raises "
13880 "an exception, it is considered to have failed. A useful way to think of the "
13881 "calling convention is <quote>tell me if you fail</quote>."
13882 msgstr ""
13884 #. type: Content of: <book><chapter><sect1><sect2><para>
13885 #: ../en/ch10-hook.xml:1232
13886 msgid ""
13887 "Note that changeset IDs are passed into Python hooks as hexadecimal strings, "
13888 "not the binary hashes that Mercurial's APIs normally use. To convert a hash "
13889 "from hex to binary, use the <literal>bin</literal> function."
13890 msgstr ""
13892 #. type: Content of: <book><chapter><sect1><sect2><title>
13893 #: ../en/ch10-hook.xml:1240
13894 msgid "External hook execution"
13895 msgstr "外部钩子的执行"
13897 #. type: Content of: <book><chapter><sect1><sect2><para>
13898 #: ../en/ch10-hook.xml:1242
13899 msgid ""
13900 "An external hook is passed to the shell of the user running Mercurial. "
13901 "Features of that shell, such as variable substitution and command "
13902 "redirection, are available. The hook is run in the root directory of the "
13903 "repository (unlike in-process hooks, which are run in the same directory that "
13904 "Mercurial was run in)."
13905 msgstr ""
13907 #. type: Content of: <book><chapter><sect1><sect2><para>
13908 #: ../en/ch10-hook.xml:1250
13909 msgid ""
13910 "Hook parameters are passed to the hook as environment variables. Each "
13911 "environment variable's name is converted in upper case and prefixed with the "
13912 "string <quote><literal>HG_</literal></quote>. For example, if the name of a "
13913 "parameter is <quote><literal>node</literal></quote>, the name of the "
13914 "environment variable representing that parameter will be "
13915 "<quote><literal>HG_NODE</literal></quote>."
13916 msgstr ""
13918 #. type: Content of: <book><chapter><sect1><sect2><para>
13919 #: ../en/ch10-hook.xml:1259
13920 msgid ""
13921 "A boolean parameter is represented as the string <quote><literal>1</literal></"
13922 "quote> for <quote>true</quote>, <quote><literal>0</literal></quote> for "
13923 "<quote>false</quote>. If an environment variable is named <envar>HG_NODE</"
13924 "envar>, <envar>HG_PARENT1</envar> or <envar>HG_PARENT2</envar>, it contains a "
13925 "changeset ID represented as a hexadecimal string. The empty string is used "
13926 "to represent <quote>null changeset ID</quote> instead of a string of zeroes. "
13927 "If an environment variable is named <envar>HG_URL</envar>, it will contain "
13928 "the URL of a remote repository, if that can be determined."
13929 msgstr ""
13931 #. type: Content of: <book><chapter><sect1><sect2><para>
13932 #: ../en/ch10-hook.xml:1271
13933 msgid ""
13934 "If a hook exits with a status of zero, it is considered to have succeeded. "
13935 "If it exits with a non-zero status, it is considered to have failed."
13936 msgstr ""
13938 #. type: Content of: <book><chapter><sect1><sect2><title>
13939 #: ../en/ch10-hook.xml:1278
13940 msgid "Finding out where changesets come from"
13941 msgstr "检查修改集来自何处"
13943 #. type: Content of: <book><chapter><sect1><sect2><para>
13944 #: ../en/ch10-hook.xml:1280
13945 msgid ""
13946 "A hook that involves the transfer of changesets between a local repository "
13947 "and another may be able to find out information about the <quote>far side</"
13948 "quote>. Mercurial knows <emphasis>how</emphasis> changes are being "
13949 "transferred, and in many cases <emphasis>where</emphasis> they are being "
13950 "transferred to or from."
13951 msgstr ""
13953 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
13954 #: ../en/ch10-hook.xml:1289
13955 msgid "Sources of changesets"
13956 msgstr "修改集的来源"
13958 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13959 #: ../en/ch10-hook.xml:1291
13960 msgid ""
13961 "Mercurial will tell a hook what means are, or were, used to transfer "
13962 "changesets between repositories. This is provided by Mercurial in a Python "
13963 "parameter named <literal>source</literal>, or an environment variable named "
13964 "<envar>HG_SOURCE</envar>."
13965 msgstr ""
13967 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13968 #: ../en/ch10-hook.xml:1299
13969 msgid ""
13970 "<literal>serve</literal>: Changesets are transferred to or from a remote "
13971 "repository over http or ssh."
13972 msgstr ""
13974 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13975 #: ../en/ch10-hook.xml:1304
13976 msgid ""
13977 "<literal>pull</literal>: Changesets are being transferred via a pull from one "
13978 "repository into another."
13979 msgstr ""
13981 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13982 #: ../en/ch10-hook.xml:1309
13983 msgid ""
13984 "<literal>push</literal>: Changesets are being transferred via a push from one "
13985 "repository into another."
13986 msgstr ""
13988 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13989 #: ../en/ch10-hook.xml:1314
13990 msgid ""
13991 "<literal>bundle</literal>: Changesets are being transferred to or from a "
13992 "bundle."
13993 msgstr ""
13995 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
13996 #: ../en/ch10-hook.xml:1321
13997 msgid "Where changes are going&emdash;remote repository URLs"
13998 msgstr "修改集要到哪里—远程版本库的地址"
14000 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
14001 #: ../en/ch10-hook.xml:1324
14002 msgid ""
14003 "When possible, Mercurial will tell a hook the location of the <quote>far "
14004 "side</quote> of an activity that transfers changeset data between "
14005 "repositories. This is provided by Mercurial in a Python parameter named "
14006 "<literal>url</literal>, or an environment variable named <envar>HG_URL</"
14007 "envar>."
14008 msgstr ""
14010 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
14011 #: ../en/ch10-hook.xml:1332
14012 msgid ""
14013 "This information is not always known. If a hook is invoked in a repository "
14014 "that is being served via http or ssh, Mercurial cannot tell where the remote "
14015 "repository is, but it may know where the client is connecting from. In such "
14016 "cases, the URL will take one of the following forms:"
14017 msgstr ""
14019 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
14020 #: ../en/ch10-hook.xml:1339
14021 msgid ""
14022 "<literal>remote:ssh:1.2.3.4</literal>&emdash;remote ssh client, at the IP "
14023 "address <literal>1.2.3.4</literal>."
14024 msgstr ""
14026 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
14027 #: ../en/ch10-hook.xml:1344
14028 msgid ""
14029 "<literal>remote:http:1.2.3.4</literal>&emdash;remote http client, at the IP "
14030 "address <literal>1.2.3.4</literal>. If the client is using SSL, this will be "
14031 "of the form <literal>remote:https:1.2.3.4</literal>."
14032 msgstr ""
14034 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
14035 #: ../en/ch10-hook.xml:1351
14036 msgid "Empty&emdash;no information could be discovered about the remote client."
14037 msgstr ""
14039 #. type: Content of: <book><chapter><sect1><title>
14040 #: ../en/ch10-hook.xml:1359
14041 msgid "Hook reference"
14042 msgstr "钩子参考"
14044 #. type: Content of: <book><chapter><sect1><sect2><title>
14045 #: ../en/ch10-hook.xml:1362
14046 msgid ""
14047 "<literal role=\"hook\">changegroup</literal>&emdash;after remote changesets "
14048 "added"
14049 msgstr "<literal role=\"hook\">changegroup</literal>—增加远程修改集之后"
14051 #. type: Content of: <book><chapter><sect1><sect2><para>
14052 #: ../en/ch10-hook.xml:1365
14053 msgid ""
14054 "This hook is run after a group of pre-existing changesets has been added to "
14055 "the repository, for example via a <command role=\"hg-cmd\">hg pull</command> "
14056 "or <command role=\"hg-cmd\">hg unbundle</command>. This hook is run once per "
14057 "operation that added one or more changesets. This is in contrast to the "
14058 "<literal role=\"hook\">incoming</literal> hook, which is run once per "
14059 "changeset, regardless of whether the changesets arrive in a group."
14060 msgstr ""
14062 #. type: Content of: <book><chapter><sect1><sect2><para>
14063 #: ../en/ch10-hook.xml:1375
14064 msgid ""
14065 "Some possible uses for this hook include kicking off an automated build or "
14066 "test of the added changesets, updating a bug database, or notifying "
14067 "subscribers that a repository contains new changes."
14068 msgstr ""
14070 #. type: Content of: <book><chapter><sect1><sect2><para>
14071 #: ../en/ch10-hook.xml:1381 ../en/ch10-hook.xml:1421 ../en/ch10-hook.xml:1465
14072 #: ../en/ch10-hook.xml:1507 ../en/ch10-hook.xml:1562 ../en/ch10-hook.xml:1602
14073 #: ../en/ch10-hook.xml:1638 ../en/ch10-hook.xml:1672 ../en/ch10-hook.xml:1736
14074 #: ../en/ch10-hook.xml:1794 ../en/ch10-hook.xml:1830 ../en/ch10-hook.xml:1857
14075 msgid "Parameters to this hook:"
14076 msgstr ""
14078 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14079 #: ../en/ch10-hook.xml:1384 ../en/ch10-hook.xml:1739
14080 msgid ""
14081 "<literal>node</literal>: A changeset ID. The changeset ID of the first "
14082 "changeset in the group that was added. All changesets between this and "
14083 "<literal role=\"tag\">tip</literal>, inclusive, were added by a single "
14084 "<command role=\"hg-cmd\">hg pull</command>, <command role=\"hg-cmd\">hg push</"
14085 "command> or <command role=\"hg-cmd\">hg unbundle</command>."
14086 msgstr ""
14088 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14089 #: ../en/ch10-hook.xml:1393 ../en/ch10-hook.xml:1472 ../en/ch10-hook.xml:1565
14090 #: ../en/ch10-hook.xml:1749
14091 msgid ""
14092 "<literal>source</literal>: A string. The source of these changes. See <xref "
14093 "linkend=\"sec:hook:sources\"/> for details."
14094 msgstr ""
14096 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14097 #: ../en/ch10-hook.xml:1398 ../en/ch10-hook.xml:1477 ../en/ch10-hook.xml:1528
14098 #: ../en/ch10-hook.xml:1570 ../en/ch10-hook.xml:1651 ../en/ch10-hook.xml:1754
14099 msgid ""
14100 "<literal>url</literal>: A URL. The location of the remote repository, if "
14101 "known. See <xref linkend=\"sec:hook:url\"/> for more information."
14102 msgstr ""
14104 #. type: Content of: <book><chapter><sect1><sect2><para>
14105 #: ../en/ch10-hook.xml:1404
14106 msgid ""
14107 "See also: <literal role=\"hook\">incoming</literal> (<xref linkend=\"sec:hook:"
14108 "incoming\"/>), <literal role=\"hook\">prechangegroup</literal> (<xref linkend="
14109 "\"sec:hook:prechangegroup\"/>), <literal role=\"hook\">pretxnchangegroup</"
14110 "literal> (<xref linkend=\"sec:hook:pretxnchangegroup\"/>)"
14111 msgstr ""
14113 #. type: Content of: <book><chapter><sect1><sect2><title>
14114 #: ../en/ch10-hook.xml:1415
14115 msgid ""
14116 "<literal role=\"hook\">commit</literal>&emdash;after a new changeset is "
14117 "created"
14118 msgstr "<literal role=\"hook\">commit</literal>—创建新修改集之后"
14120 #. type: Content of: <book><chapter><sect1><sect2><para>
14121 #: ../en/ch10-hook.xml:1418
14122 msgid "This hook is run after a new changeset has been created."
14123 msgstr ""
14125 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14126 #: ../en/ch10-hook.xml:1424 ../en/ch10-hook.xml:1797
14127 msgid ""
14128 "<literal>node</literal>: A changeset ID. The changeset ID of the newly "
14129 "committed changeset."
14130 msgstr ""
14132 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14133 #: ../en/ch10-hook.xml:1428 ../en/ch10-hook.xml:1801
14134 msgid ""
14135 "<literal>parent1</literal>: A changeset ID. The changeset ID of the first "
14136 "parent of the newly committed changeset."
14137 msgstr ""
14139 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14140 #: ../en/ch10-hook.xml:1433 ../en/ch10-hook.xml:1806
14141 msgid ""
14142 "<literal>parent2</literal>: A changeset ID. The changeset ID of the second "
14143 "parent of the newly committed changeset."
14144 msgstr ""
14146 #. type: Content of: <book><chapter><sect1><sect2><para>
14147 #: ../en/ch10-hook.xml:1439
14148 msgid ""
14149 "See also: <literal role=\"hook\">precommit</literal> (<xref linkend=\"sec:"
14150 "hook:precommit\"/>), <literal role=\"hook\">pretxncommit</literal> (<xref "
14151 "linkend=\"sec:hook:pretxncommit\"/>)"
14152 msgstr ""
14154 #. type: Content of: <book><chapter><sect1><sect2><title>
14155 #: ../en/ch10-hook.xml:1448
14156 msgid ""
14157 "<literal role=\"hook\">incoming</literal>&emdash;after one remote changeset "
14158 "is added"
14159 msgstr "<literal role=\"hook\">incoming</literal>—增加远程修改集之后"
14161 #. type: Content of: <book><chapter><sect1><sect2><para>
14162 #: ../en/ch10-hook.xml:1451
14163 msgid ""
14164 "This hook is run after a pre-existing changeset has been added to the "
14165 "repository, for example via a <command role=\"hg-cmd\">hg push</command>. If "
14166 "a group of changesets was added in a single operation, this hook is called "
14167 "once for each added changeset."
14168 msgstr ""
14170 #. type: Content of: <book><chapter><sect1><sect2><para>
14171 #: ../en/ch10-hook.xml:1458
14172 msgid ""
14173 "You can use this hook for the same purposes as the <literal role=\"hook"
14174 "\">changegroup</literal> hook (<xref linkend=\"sec:hook:changegroup\"/>); "
14175 "it's simply more convenient sometimes to run a hook once per group of "
14176 "changesets, while other times it's handier once per changeset."
14177 msgstr ""
14179 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14180 #: ../en/ch10-hook.xml:1468
14181 msgid ""
14182 "<literal>node</literal>: A changeset ID. The ID of the newly added changeset."
14183 msgstr ""
14185 #. type: Content of: <book><chapter><sect1><sect2><para>
14186 #: ../en/ch10-hook.xml:1483
14187 msgid ""
14188 "See also: <literal role=\"hook\">changegroup</literal> (<xref linkend=\"sec:"
14189 "hook:changegroup\"/>) <literal role=\"hook\">prechangegroup</literal> (<xref "
14190 "linkend=\"sec:hook:prechangegroup\"/>), <literal role=\"hook"
14191 "\">pretxnchangegroup</literal> (<xref linkend=\"sec:hook:pretxnchangegroup\"/"
14192 ">)"
14193 msgstr ""
14195 #. type: Content of: <book><chapter><sect1><sect2><title>
14196 #: ../en/ch10-hook.xml:1494
14197 msgid ""
14198 "<literal role=\"hook\">outgoing</literal>&emdash;after changesets are "
14199 "propagated"
14200 msgstr "<literal role=\"hook\">outgoing</literal>—传播修改集之后"
14202 #. type: Content of: <book><chapter><sect1><sect2><para>
14203 #: ../en/ch10-hook.xml:1497
14204 msgid ""
14205 "This hook is run after a group of changesets has been propagated out of this "
14206 "repository, for example by a <command role=\"hg-cmd\">hg push</command> or "
14207 "<command role=\"hg-cmd\">hg bundle</command> command."
14208 msgstr ""
14210 #. type: Content of: <book><chapter><sect1><sect2><para>
14211 #: ../en/ch10-hook.xml:1503
14212 msgid ""
14213 "One possible use for this hook is to notify administrators that changes have "
14214 "been pulled."
14215 msgstr ""
14217 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14218 #: ../en/ch10-hook.xml:1510
14219 msgid ""
14220 "<literal>node</literal>: A changeset ID. The changeset ID of the first "
14221 "changeset of the group that was sent."
14222 msgstr ""
14224 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14225 #: ../en/ch10-hook.xml:1515
14226 msgid ""
14227 "<literal>source</literal>: A string. The source of the of the operation (see "
14228 "<xref linkend=\"sec:hook:sources\"/>). If a remote client pulled changes "
14229 "from this repository, <literal>source</literal> will be <literal>serve</"
14230 "literal>. If the client that obtained changes from this repository was "
14231 "local, <literal>source</literal> will be <literal>bundle</literal>, "
14232 "<literal>pull</literal>, or <literal>push</literal>, depending on the "
14233 "operation the client performed."
14234 msgstr ""
14236 #. type: Content of: <book><chapter><sect1><sect2><para>
14237 #: ../en/ch10-hook.xml:1534
14238 msgid ""
14239 "See also: <literal role=\"hook\">preoutgoing</literal> (<xref linkend=\"sec:"
14240 "hook:preoutgoing\"/>)"
14241 msgstr ""
14243 #. type: Content of: <book><chapter><sect1><sect2><title>
14244 #: ../en/ch10-hook.xml:1541
14245 msgid ""
14246 "<literal role=\"hook\">prechangegroup</literal>&emdash;before starting to add "
14247 "remote changesets"
14248 msgstr "<literal role=\"hook\">prechangegroup</literal>—增加远程修改集之前"
14250 #. type: Content of: <book><chapter><sect1><sect2><para>
14251 #: ../en/ch10-hook.xml:1545
14252 msgid ""
14253 "This controlling hook is run before Mercurial begins to add a group of "
14254 "changesets from another repository."
14255 msgstr ""
14257 #. type: Content of: <book><chapter><sect1><sect2><para>
14258 #: ../en/ch10-hook.xml:1549
14259 msgid ""
14260 "This hook does not have any information about the changesets to be added, "
14261 "because it is run before transmission of those changesets is allowed to "
14262 "begin. If this hook fails, the changesets will not be transmitted."
14263 msgstr ""
14265 #. type: Content of: <book><chapter><sect1><sect2><para>
14266 #: ../en/ch10-hook.xml:1555
14267 msgid ""
14268 "One use for this hook is to prevent external changes from being added to a "
14269 "repository. For example, you could use this to <quote>freeze</quote> a "
14270 "server-hosted branch temporarily or permanently so that users cannot push to "
14271 "it, while still allowing a local administrator to modify the repository."
14272 msgstr ""
14274 #. type: Content of: <book><chapter><sect1><sect2><para>
14275 #: ../en/ch10-hook.xml:1576
14276 msgid ""
14277 "See also: <literal role=\"hook\">changegroup</literal> (<xref linkend=\"sec:"
14278 "hook:changegroup\"/>), <literal role=\"hook\">incoming</literal> (<xref "
14279 "linkend=\"sec:hook:incoming\"/>), <literal role=\"hook\">pretxnchangegroup</"
14280 "literal> (<xref linkend=\"sec:hook:pretxnchangegroup\"/>)"
14281 msgstr ""
14283 #. type: Content of: <book><chapter><sect1><sect2><title>
14284 #: ../en/ch10-hook.xml:1587
14285 msgid ""
14286 "<literal role=\"hook\">precommit</literal>&emdash;before starting to commit a "
14287 "changeset"
14288 msgstr "<literal role=\"hook\">precommit</literal>—提交修改集之前"
14290 #. type: Content of: <book><chapter><sect1><sect2><para>
14291 #: ../en/ch10-hook.xml:1590
14292 msgid ""
14293 "This hook is run before Mercurial begins to commit a new changeset. It is run "
14294 "before Mercurial has any of the metadata for the commit, such as the files to "
14295 "be committed, the commit message, or the commit date."
14296 msgstr ""
14298 #. type: Content of: <book><chapter><sect1><sect2><para>
14299 #: ../en/ch10-hook.xml:1596
14300 msgid ""
14301 "One use for this hook is to disable the ability to commit new changesets, "
14302 "while still allowing incoming changesets. Another is to run a build or test, "
14303 "and only allow the commit to begin if the build or test succeeds."
14304 msgstr ""
14306 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14307 #: ../en/ch10-hook.xml:1605
14308 msgid ""
14309 "<literal>parent1</literal>: A changeset ID. The changeset ID of the first "
14310 "parent of the working directory."
14311 msgstr ""
14313 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14314 #: ../en/ch10-hook.xml:1610
14315 msgid ""
14316 "<literal>parent2</literal>: A changeset ID. The changeset ID of the second "
14317 "parent of the working directory."
14318 msgstr ""
14320 #. type: Content of: <book><chapter><sect1><sect2><para>
14321 #: ../en/ch10-hook.xml:1615
14322 msgid ""
14323 "If the commit proceeds, the parents of the working directory will become the "
14324 "parents of the new changeset."
14325 msgstr ""
14327 #. type: Content of: <book><chapter><sect1><sect2><para>
14328 #: ../en/ch10-hook.xml:1619
14329 msgid ""
14330 "See also: <literal role=\"hook\">commit</literal> (<xref linkend=\"sec:hook:"
14331 "commit\"/>), <literal role=\"hook\">pretxncommit</literal> (<xref linkend="
14332 "\"sec:hook:pretxncommit\"/>)"
14333 msgstr ""
14335 #. type: Content of: <book><chapter><sect1><sect2><title>
14336 #: ../en/ch10-hook.xml:1627
14337 msgid ""
14338 "<literal role=\"hook\">preoutgoing</literal>&emdash;before starting to "
14339 "propagate changesets"
14340 msgstr "<literal role=\"hook\">preoutgoing</literal>—传播修改集之前"
14342 #. type: Content of: <book><chapter><sect1><sect2><para>
14343 #: ../en/ch10-hook.xml:1630
14344 msgid ""
14345 "This hook is invoked before Mercurial knows the identities of the changesets "
14346 "to be transmitted."
14347 msgstr ""
14349 #. type: Content of: <book><chapter><sect1><sect2><para>
14350 #: ../en/ch10-hook.xml:1634
14351 msgid ""
14352 "One use for this hook is to prevent changes from being transmitted to another "
14353 "repository."
14354 msgstr ""
14356 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14357 #: ../en/ch10-hook.xml:1641
14358 msgid ""
14359 "<literal>source</literal>: A string. The source of the operation that is "
14360 "attempting to obtain changes from this repository (see <xref linkend=\"sec:"
14361 "hook:sources\"/>). See the documentation for the <literal>source</literal> "
14362 "parameter to the <literal role=\"hook\">outgoing</literal> hook, in <xref "
14363 "linkend=\"sec:hook:outgoing\"/>, for possible values of this parameter."
14364 msgstr ""
14366 #. type: Content of: <book><chapter><sect1><sect2><para>
14367 #: ../en/ch10-hook.xml:1657
14368 msgid ""
14369 "See also: <literal role=\"hook\">outgoing</literal> (<xref linkend=\"sec:hook:"
14370 "outgoing\"/>)"
14371 msgstr ""
14373 #. type: Content of: <book><chapter><sect1><sect2><title>
14374 #: ../en/ch10-hook.xml:1664
14375 msgid ""
14376 "<literal role=\"hook\">pretag</literal>&emdash;before tagging a changeset"
14377 msgstr "<literal role=\"hook\">pretag</literal>—创建标签之前"
14379 #. type: Content of: <book><chapter><sect1><sect2><para>
14380 #: ../en/ch10-hook.xml:1667
14381 msgid ""
14382 "This controlling hook is run before a tag is created. If the hook succeeds, "
14383 "creation of the tag proceeds. If the hook fails, the tag is not created."
14384 msgstr ""
14386 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14387 #: ../en/ch10-hook.xml:1675
14388 msgid ""
14389 "<literal>local</literal>: A boolean. Whether the tag is local to this "
14390 "repository instance (i.e. stored in <filename role=\"special\">.hg/localtags</"
14391 "filename>) or managed by Mercurial (stored in <filename role=\"special\">."
14392 "hgtags</filename>)."
14393 msgstr ""
14395 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14396 #: ../en/ch10-hook.xml:1682
14397 msgid ""
14398 "<literal>node</literal>: A changeset ID. The ID of the changeset to be "
14399 "tagged."
14400 msgstr ""
14402 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14403 #: ../en/ch10-hook.xml:1686
14404 msgid "<literal>tag</literal>: A string. The name of the tag to be created."
14405 msgstr ""
14407 #. type: Content of: <book><chapter><sect1><sect2><para>
14408 #: ../en/ch10-hook.xml:1691
14409 msgid ""
14410 "If the tag to be created is revision-controlled, the <literal role=\"hook"
14411 "\">precommit</literal> and <literal role=\"hook\">pretxncommit</literal> "
14412 "hooks (<xref linkend=\"sec:hook:commit\"/> and <xref linkend=\"sec:hook:"
14413 "pretxncommit\"/>) will also be run."
14414 msgstr ""
14416 #. type: Content of: <book><chapter><sect1><sect2><para>
14417 #: ../en/ch10-hook.xml:1699
14418 msgid ""
14419 "See also: <literal role=\"hook\">tag</literal> (<xref linkend=\"sec:hook:tag"
14420 "\"/>)"
14421 msgstr ""
14423 #. type: Content of: <book><chapter><sect1><sect2><title>
14424 #: ../en/ch10-hook.xml:1705
14425 msgid ""
14426 "<literal role=\"hook\">pretxnchangegroup</literal>&emdash;before completing "
14427 "addition of remote changesets"
14428 msgstr ""
14429 "<literal role=\"hook\">pretxnchangegroup</literal>—完成增加远程修改集之前"
14431 #. type: Content of: <book><chapter><sect1><sect2><para>
14432 #: ../en/ch10-hook.xml:1709
14433 msgid ""
14434 "This controlling hook is run before a transaction&emdash;that manages the "
14435 "addition of a group of new changesets from outside the repository&emdash;"
14436 "completes. If the hook succeeds, the transaction completes, and all of the "
14437 "changesets become permanent within this repository. If the hook fails, the "
14438 "transaction is rolled back, and the data for the changesets is erased."
14439 msgstr ""
14441 #. type: Content of: <book><chapter><sect1><sect2><para>
14442 #: ../en/ch10-hook.xml:1718
14443 msgid ""
14444 "This hook can access the metadata associated with the almost-added "
14445 "changesets, but it should not do anything permanent with this data. It must "
14446 "also not modify the working directory."
14447 msgstr ""
14449 #. type: Content of: <book><chapter><sect1><sect2><para>
14450 #: ../en/ch10-hook.xml:1724
14451 msgid ""
14452 "While this hook is running, if other Mercurial processes access this "
14453 "repository, they will be able to see the almost-added changesets as if they "
14454 "are permanent. This may lead to race conditions if you do not take steps to "
14455 "avoid them."
14456 msgstr ""
14458 #. type: Content of: <book><chapter><sect1><sect2><para>
14459 #: ../en/ch10-hook.xml:1731
14460 msgid ""
14461 "This hook can be used to automatically vet a group of changesets. If the "
14462 "hook fails, all of the changesets are <quote>rejected</quote> when the "
14463 "transaction rolls back."
14464 msgstr ""
14466 #. type: Content of: <book><chapter><sect1><sect2><para>
14467 #: ../en/ch10-hook.xml:1760
14468 msgid ""
14469 "See also: <literal role=\"hook\">changegroup</literal> (<xref linkend=\"sec:"
14470 "hook:changegroup\"/>), <literal role=\"hook\">incoming</literal> (<xref "
14471 "linkend=\"sec:hook:incoming\"/>), <literal role=\"hook\">prechangegroup</"
14472 "literal> (<xref linkend=\"sec:hook:prechangegroup\"/>)"
14473 msgstr ""
14475 #. type: Content of: <book><chapter><sect1><sect2><title>
14476 #: ../en/ch10-hook.xml:1771
14477 msgid ""
14478 "<literal role=\"hook\">pretxncommit</literal>&emdash;before completing commit "
14479 "of new changeset"
14480 msgstr "<literal role=\"hook\">pretxncommit</literal>—完成提交之前"
14482 #. type: Content of: <book><chapter><sect1><sect2><para>
14483 #: ../en/ch10-hook.xml:1774
14484 msgid ""
14485 "This controlling hook is run before a transaction&emdash;that manages a new "
14486 "commit&emdash;completes. If the hook succeeds, the transaction completes and "
14487 "the changeset becomes permanent within this repository. If the hook fails, "
14488 "the transaction is rolled back, and the commit data is erased."
14489 msgstr ""
14491 #. type: Content of: <book><chapter><sect1><sect2><para>
14492 #: ../en/ch10-hook.xml:1782
14493 msgid ""
14494 "This hook can access the metadata associated with the almost-new changeset, "
14495 "but it should not do anything permanent with this data. It must also not "
14496 "modify the working directory."
14497 msgstr ""
14499 #. type: Content of: <book><chapter><sect1><sect2><para>
14500 #: ../en/ch10-hook.xml:1788
14501 msgid ""
14502 "While this hook is running, if other Mercurial processes access this "
14503 "repository, they will be able to see the almost-new changeset as if it is "
14504 "permanent. This may lead to race conditions if you do not take steps to "
14505 "avoid them."
14506 msgstr ""
14508 #. type: Content of: <book><chapter><sect1><sect2><para>
14509 #: ../en/ch10-hook.xml:1812
14510 msgid ""
14511 "See also: <literal role=\"hook\">precommit</literal> (<xref linkend=\"sec:"
14512 "hook:precommit\"/>)"
14513 msgstr ""
14514 "参见: <literal role=\"hook\">precommit</literal> (<xref linkend=\"sec:hook:"
14515 "precommit\"/>)"
14517 #. type: Content of: <book><chapter><sect1><sect2><title>
14518 #: ../en/ch10-hook.xml:1819
14519 msgid ""
14520 "<literal role=\"hook\">preupdate</literal>&emdash;before updating or merging "
14521 "working directory"
14522 msgstr "<literal role=\"hook\">preupdate</literal>—更新或合并工作目录之前"
14524 #. type: Content of: <book><chapter><sect1><sect2><para>
14525 #: ../en/ch10-hook.xml:1822
14526 msgid ""
14527 "This controlling hook is run before an update or merge of the working "
14528 "directory begins. It is run only if Mercurial's normal pre-update checks "
14529 "determine that the update or merge can proceed. If the hook succeeds, the "
14530 "update or merge may proceed; if it fails, the update or merge does not start."
14531 msgstr ""
14533 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14534 #: ../en/ch10-hook.xml:1833
14535 msgid ""
14536 "<literal>parent1</literal>: A changeset ID. The ID of the parent that the "
14537 "working directory is to be updated to. If the working directory is being "
14538 "merged, it will not change this parent."
14539 msgstr ""
14541 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14542 #: ../en/ch10-hook.xml:1839
14543 msgid ""
14544 "<literal>parent2</literal>: A changeset ID. Only set if the working directory "
14545 "is being merged. The ID of the revision that the working directory is being "
14546 "merged with."
14547 msgstr ""
14549 #. type: Content of: <book><chapter><sect1><sect2><para>
14550 #: ../en/ch10-hook.xml:1846
14551 msgid ""
14552 "See also: <literal role=\"hook\">update</literal> (<xref linkend=\"sec:hook:"
14553 "update\"/>)"
14554 msgstr ""
14556 #. type: Content of: <book><chapter><sect1><sect2><title>
14557 #: ../en/ch10-hook.xml:1851
14558 msgid "<literal role=\"hook\">tag</literal>&emdash;after tagging a changeset"
14559 msgstr "<literal role=\"hook\">tag</literal>—创建标签之后"
14561 #. type: Content of: <book><chapter><sect1><sect2><para>
14562 #: ../en/ch10-hook.xml:1854
14563 msgid "This hook is run after a tag has been created."
14564 msgstr ""
14566 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14567 #: ../en/ch10-hook.xml:1860
14568 msgid ""
14569 "<literal>local</literal>: A boolean. Whether the new tag is local to this "
14570 "repository instance (i.e. stored in <filename role=\"special\">.hg/"
14571 "localtags</filename>) or managed by Mercurial (stored in <filename role="
14572 "\"special\">.hgtags</filename>)."
14573 msgstr ""
14575 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14576 #: ../en/ch10-hook.xml:1868
14577 msgid ""
14578 "<literal>node</literal>: A changeset ID. The ID of the changeset that was "
14579 "tagged."
14580 msgstr ""
14582 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14583 #: ../en/ch10-hook.xml:1872
14584 msgid "<literal>tag</literal>: A string. The name of the tag that was created."
14585 msgstr ""
14587 #. type: Content of: <book><chapter><sect1><sect2><para>
14588 #: ../en/ch10-hook.xml:1877
14589 msgid ""
14590 "If the created tag is revision-controlled, the <literal role=\"hook\">commit</"
14591 "literal> hook (section <xref linkend=\"sec:hook:commit\"/>) is run before "
14592 "this hook."
14593 msgstr ""
14595 #. type: Content of: <book><chapter><sect1><sect2><para>
14596 #: ../en/ch10-hook.xml:1882
14597 msgid ""
14598 "See also: <literal role=\"hook\">pretag</literal> (<xref linkend=\"sec:hook:"
14599 "pretag\"/>)"
14600 msgstr ""
14601 "参见: <literal role=\"hook\">pretag</literal> (<xref linkend=\"sec:hook:pretag"
14602 "\"/>)"
14604 #. type: Content of: <book><chapter><sect1><sect2><title>
14605 #: ../en/ch10-hook.xml:1888
14606 msgid ""
14607 "<literal role=\"hook\">update</literal>&emdash;after updating or merging "
14608 "working directory"
14609 msgstr "<literal role=\"hook\">update</literal>—更新或合并工作目录之后"
14611 #. type: Content of: <book><chapter><sect1><sect2><para>
14612 #: ../en/ch10-hook.xml:1891
14613 msgid ""
14614 "This hook is run after an update or merge of the working directory "
14615 "completes. Since a merge can fail (if the external <command>hgmerge</"
14616 "command> command fails to resolve conflicts in a file), this hook "
14617 "communicates whether the update or merge completed cleanly."
14618 msgstr ""
14620 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14621 #: ../en/ch10-hook.xml:1899
14622 msgid ""
14623 "<literal>error</literal>: A boolean. Indicates whether the update or merge "
14624 "completed successfully."
14625 msgstr ""
14627 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14628 #: ../en/ch10-hook.xml:1904
14629 msgid ""
14630 "<literal>parent1</literal>: A changeset ID. The ID of the parent that the "
14631 "working directory was updated to. If the working directory was merged, it "
14632 "will not have changed this parent."
14633 msgstr ""
14635 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14636 #: ../en/ch10-hook.xml:1910
14637 msgid ""
14638 "<literal>parent2</literal>: A changeset ID. Only set if the working "
14639 "directory was merged. The ID of the revision that the working directory was "
14640 "merged with."
14641 msgstr ""
14643 #. type: Content of: <book><chapter><sect1><sect2><para>
14644 #: ../en/ch10-hook.xml:1916
14645 msgid ""
14646 "See also: <literal role=\"hook\">preupdate</literal> (<xref linkend=\"sec:"
14647 "hook:preupdate\"/>)"
14648 msgstr ""
14650 #. type: Content of: <book><chapter><title>
14651 #: ../en/ch11-template.xml:5
14652 msgid "Customizing the output of Mercurial"
14653 msgstr "定制 Mercurial 的输出"
14655 #. type: Content of: <book><chapter><para>
14656 #: ../en/ch11-template.xml:7
14657 msgid ""
14658 "Mercurial provides a powerful mechanism to let you control how it displays "
14659 "information. The mechanism is based on templates. You can use templates to "
14660 "generate specific output for a single command, or to customize the entire "
14661 "appearance of the built-in web interface."
14662 msgstr ""
14664 #. type: Content of: <book><chapter><sect1><title>
14665 #: ../en/ch11-template.xml:14
14666 msgid "Using precanned output styles"
14667 msgstr "使用预定义的输出样式"
14669 #. type: Content of: <book><chapter><sect1><para>
14670 #: ../en/ch11-template.xml:16
14671 msgid ""
14672 "Packaged with Mercurial are some output styles that you can use immediately. "
14673 "A style is simply a precanned template that someone wrote and installed "
14674 "somewhere that Mercurial can find."
14675 msgstr ""
14677 #. type: Content of: <book><chapter><sect1><para>
14678 #: ../en/ch11-template.xml:21
14679 msgid ""
14680 "Before we take a look at Mercurial's bundled styles, let's review its normal "
14681 "output."
14682 msgstr ""
14684 #. type: Content of: <book><chapter><sect1><para>
14685 #: ../en/ch11-template.xml:26
14686 msgid ""
14687 "This is somewhat informative, but it takes up a lot of space&emdash;five "
14688 "lines of output per changeset. The <literal>compact</literal> style reduces "
14689 "this to three lines, presented in a sparse manner."
14690 msgstr ""
14692 #. type: Content of: <book><chapter><sect1><para>
14693 #: ../en/ch11-template.xml:33
14694 msgid ""
14695 "The <literal>changelog</literal> style hints at the expressive power of "
14696 "Mercurial's templating engine. This style attempts to follow the GNU "
14697 "Project's changelog guidelines<citation>web:changelog</citation>."
14698 msgstr ""
14700 #. type: Content of: <book><chapter><sect1><para>
14701 #: ../en/ch11-template.xml:40
14702 msgid ""
14703 "You will not be shocked to learn that Mercurial's default output style is "
14704 "named <literal>default</literal>."
14705 msgstr ""
14707 #. type: Content of: <book><chapter><sect1><sect2><title>
14708 #: ../en/ch11-template.xml:44
14709 msgid "Setting a default style"
14710 msgstr "设置默认样式"
14712 #. type: Content of: <book><chapter><sect1><sect2><para>
14713 #: ../en/ch11-template.xml:46
14714 msgid ""
14715 "You can modify the output style that Mercurial will use for every command by "
14716 "editing your <filename role=\"special\">~/.hgrc</filename> file, naming the "
14717 "style you would prefer to use."
14718 msgstr ""
14720 #. type: Content of: <book><chapter><sect1><sect2><para>
14721 #: ../en/ch11-template.xml:54
14722 msgid ""
14723 "If you write a style of your own, you can use it by either providing the path "
14724 "to your style file, or copying your style file into a location where "
14725 "Mercurial can find it (typically the <literal>templates</literal> "
14726 "subdirectory of your Mercurial install directory)."
14727 msgstr ""
14729 #. type: Content of: <book><chapter><sect1><title>
14730 #: ../en/ch11-template.xml:63
14731 msgid "Commands that support styles and templates"
14732 msgstr "支持样式和模版的命令"
14734 #. type: Content of: <book><chapter><sect1><para>
14735 #: ../en/ch11-template.xml:65
14736 msgid ""
14737 "All of Mercurial's <quote><literal>log</literal>-like</quote> commands let "
14738 "you use styles and templates: <command role=\"hg-cmd\">hg incoming</command>, "
14739 "<command role=\"hg-cmd\">hg log</command>, <command role=\"hg-cmd\">hg "
14740 "outgoing</command>, and <command role=\"hg-cmd\">hg tip</command>."
14741 msgstr ""
14743 #. type: Content of: <book><chapter><sect1><para>
14744 #: ../en/ch11-template.xml:72
14745 msgid ""
14746 "As I write this manual, these are so far the only commands that support "
14747 "styles and templates. Since these are the most important commands that need "
14748 "customizable output, there has been little pressure from the Mercurial user "
14749 "community to add style and template support to other commands."
14750 msgstr ""
14752 #. type: Content of: <book><chapter><sect1><title>
14753 #: ../en/ch11-template.xml:80
14754 msgid "The basics of templating"
14755 msgstr "模版基础"
14757 #. type: Content of: <book><chapter><sect1><para>
14758 #: ../en/ch11-template.xml:82
14759 msgid ""
14760 "At its simplest, a Mercurial template is a piece of text. Some of the text "
14761 "never changes, while other parts are <emphasis>expanded</emphasis>, or "
14762 "replaced with new text, when necessary."
14763 msgstr ""
14765 #. type: Content of: <book><chapter><sect1><para>
14766 #: ../en/ch11-template.xml:87
14767 msgid ""
14768 "Before we continue, let's look again at a simple example of Mercurial's "
14769 "normal output."
14770 msgstr ""
14772 #. type: Content of: <book><chapter><sect1><para>
14773 #: ../en/ch11-template.xml:92
14774 msgid ""
14775 "Now, let's run the same command, but using a template to change its output."
14776 msgstr ""
14778 #. type: Content of: <book><chapter><sect1><para>
14779 #: ../en/ch11-template.xml:97
14780 msgid ""
14781 "The example above illustrates the simplest possible template; it's just a "
14782 "piece of static text, printed once for each changeset. The <option role=\"hg-"
14783 "opt-log\">--template</option> option to the <command role=\"hg-cmd\">hg log</"
14784 "command> command tells Mercurial to use the given text as the template when "
14785 "printing each changeset."
14786 msgstr ""
14788 #. type: Content of: <book><chapter><sect1><para>
14789 #: ../en/ch11-template.xml:105
14790 msgid ""
14791 "Notice that the template string above ends with the text <quote><literal>\\n</"
14792 "literal></quote>. This is an <emphasis>escape sequence</emphasis>, telling "
14793 "Mercurial to print a newline at the end of each template item. If you omit "
14794 "this newline, Mercurial will run each piece of output together. See <xref "
14795 "linkend=\"sec:template:escape\"/> for more details of escape sequences."
14796 msgstr ""
14798 #. type: Content of: <book><chapter><sect1><para>
14799 #: ../en/ch11-template.xml:113
14800 msgid ""
14801 "A template that prints a fixed string of text all the time isn't very useful; "
14802 "let's try something a bit more complex."
14803 msgstr ""
14805 #. type: Content of: <book><chapter><sect1><para>
14806 #: ../en/ch11-template.xml:119
14807 msgid ""
14808 "As you can see, the string <quote><literal>{desc}</literal></quote> in the "
14809 "template has been replaced in the output with the description of each "
14810 "changeset. Every time Mercurial finds text enclosed in curly braces "
14811 "(<quote><literal>{</literal></quote> and <quote><literal>}</literal></"
14812 "quote>), it will try to replace the braces and text with the expansion of "
14813 "whatever is inside. To print a literal curly brace, you must escape it, as "
14814 "described in <xref linkend=\"sec:template:escape\"/>."
14815 msgstr ""
14817 #. type: Content of: <book><chapter><sect1><title>
14818 #: ../en/ch11-template.xml:131
14819 msgid "Common template keywords"
14820 msgstr "模版关键字"
14822 #. type: Content of: <book><chapter><sect1><para>
14823 #: ../en/ch11-template.xml:133
14824 msgid ""
14825 "You can start writing simple templates immediately using the keywords below."
14826 msgstr ""
14828 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14829 #: ../en/ch11-template.xml:137
14830 msgid ""
14831 "<literal role=\"template-keyword\">author</literal>: String. The unmodified "
14832 "author of the changeset."
14833 msgstr ""
14835 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14836 #: ../en/ch11-template.xml:141
14837 msgid ""
14838 "<literal role=\"template-keyword\">branches</literal>: String. The name of "
14839 "the branch on which the changeset was committed. Will be empty if the branch "
14840 "name was <literal>default</literal>."
14841 msgstr ""
14843 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14844 #: ../en/ch11-template.xml:147
14845 msgid ""
14846 "<literal role=\"template-keyword\">date</literal>: Date information. The "
14847 "date when the changeset was committed. This is <emphasis>not</emphasis> "
14848 "human-readable; you must pass it through a filter that will render it "
14849 "appropriately. See <xref linkend=\"sec:template:filter\"/> for more "
14850 "information on filters. The date is expressed as a pair of numbers. The "
14851 "first number is a Unix UTC timestamp (seconds since January 1, 1970); the "
14852 "second is the offset of the committer's timezone from UTC, in seconds."
14853 msgstr ""
14855 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14856 #: ../en/ch11-template.xml:158
14857 msgid ""
14858 "<literal role=\"template-keyword\">desc</literal>: String. The text of the "
14859 "changeset description."
14860 msgstr ""
14862 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14863 #: ../en/ch11-template.xml:161
14864 msgid ""
14865 "<literal role=\"template-keyword\">files</literal>: List of strings. All "
14866 "files modified, added, or removed by this changeset."
14867 msgstr ""
14869 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14870 #: ../en/ch11-template.xml:166
14871 msgid ""
14872 "<literal role=\"template-keyword\">file_adds</literal>: List of strings. "
14873 "Files added by this changeset."
14874 msgstr ""
14876 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14877 #: ../en/ch11-template.xml:170
14878 msgid ""
14879 "<literal role=\"template-keyword\">file_dels</literal>: List of strings. "
14880 "Files removed by this changeset."
14881 msgstr ""
14883 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14884 #: ../en/ch11-template.xml:174
14885 msgid ""
14886 "<literal role=\"template-keyword\">node</literal>: String. The changeset "
14887 "identification hash, as a 40-character hexadecimal string."
14888 msgstr ""
14890 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14891 #: ../en/ch11-template.xml:178
14892 msgid ""
14893 "<literal role=\"template-keyword\">parents</literal>: List of strings. The "
14894 "parents of the changeset."
14895 msgstr ""
14897 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14898 #: ../en/ch11-template.xml:182
14899 msgid ""
14900 "<literal role=\"template-keyword\">rev</literal>: Integer. The repository-"
14901 "local changeset revision number."
14902 msgstr ""
14904 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14905 #: ../en/ch11-template.xml:186
14906 msgid ""
14907 "<literal role=\"template-keyword\">tags</literal>: List of strings. Any tags "
14908 "associated with the changeset."
14909 msgstr ""
14911 #. type: Content of: <book><chapter><sect1><para>
14912 #: ../en/ch11-template.xml:192
14913 msgid ""
14914 "A few simple experiments will show us what to expect when we use these "
14915 "keywords; you can see the results below."
14916 msgstr ""
14918 #. type: Content of: <book><chapter><sect1><para>
14919 #: ../en/ch11-template.xml:197
14920 msgid ""
14921 "As we noted above, the date keyword does not produce human-readable output, "
14922 "so we must treat it specially. This involves using a <emphasis>filter</"
14923 "emphasis>, about which more in <xref linkend=\"sec:template:filter\"/>."
14924 msgstr ""
14926 #. type: Content of: <book><chapter><sect1><title>
14927 #: ../en/ch11-template.xml:206
14928 msgid "Escape sequences"
14929 msgstr "转义序列"
14931 #. type: Content of: <book><chapter><sect1><para>
14932 #: ../en/ch11-template.xml:208
14933 msgid ""
14934 "Mercurial's templating engine recognises the most commonly used escape "
14935 "sequences in strings. When it sees a backslash (<quote><literal>\\</"
14936 "literal></quote>) character, it looks at the following character and "
14937 "substitutes the two characters with a single replacement, as described below."
14938 msgstr ""
14940 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14941 #: ../en/ch11-template.xml:215
14942 msgid ""
14943 "<literal>\\</literal>: Backslash, <quote><literal>\\</literal></quote>, ASCII "
14944 "134."
14945 msgstr ""
14947 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14948 #: ../en/ch11-template.xml:219
14949 msgid "<literal>\\n</literal>: Newline, ASCII 12."
14950 msgstr ""
14952 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14953 #: ../en/ch11-template.xml:222
14954 msgid "<literal>\\r</literal>: Carriage return, ASCII 15."
14955 msgstr ""
14957 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14958 #: ../en/ch11-template.xml:225
14959 msgid "<literal>\\t</literal>: Tab, ASCII 11."
14960 msgstr ""
14962 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14963 #: ../en/ch11-template.xml:228
14964 msgid "<literal>\\v</literal>: Vertical tab, ASCII 13."
14965 msgstr ""
14967 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14968 #: ../en/ch11-template.xml:231
14969 msgid ""
14970 "<literal>\\{</literal>: Open curly brace, <quote><literal>{</literal></"
14971 "quote>, ASCII 173."
14972 msgstr ""
14974 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14975 #: ../en/ch11-template.xml:235
14976 msgid ""
14977 "<literal>\\}</literal>: Close curly brace, <quote><literal>}</literal></"
14978 "quote>, ASCII 175."
14979 msgstr ""
14981 #. type: Content of: <book><chapter><sect1><para>
14982 #: ../en/ch11-template.xml:240
14983 msgid ""
14984 "As indicated above, if you want the expansion of a template to contain a "
14985 "literal <quote><literal>\\</literal></quote>, <quote><literal>{</literal></"
14986 "quote>, or <quote><literal>{</literal></quote> character, you must escape it."
14987 msgstr ""
14989 #. type: Content of: <book><chapter><sect1><title>
14990 #: ../en/ch11-template.xml:248
14991 msgid "Filtering keywords to change their results"
14992 msgstr "通过过滤关键字来修改输出结果"
14994 #. type: Content of: <book><chapter><sect1><para>
14995 #: ../en/ch11-template.xml:250
14996 msgid ""
14997 "Some of the results of template expansion are not immediately easy to use. "
14998 "Mercurial lets you specify an optional chain of <emphasis>filters</emphasis> "
14999 "to modify the result of expanding a keyword. You have already seen a common "
15000 "filter, <literal role=\"template-kw-filt-date\">isodate</literal>, in action "
15001 "above, to make a date readable."
15002 msgstr ""
15004 #. type: Content of: <book><chapter><sect1><para>
15005 #: ../en/ch11-template.xml:257
15006 msgid ""
15007 "Below is a list of the most commonly used filters that Mercurial supports. "
15008 "While some filters can be applied to any text, others can only be used in "
15009 "specific circumstances. The name of each filter is followed first by an "
15010 "indication of where it can be used, then a description of its effect."
15011 msgstr ""
15013 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15014 #: ../en/ch11-template.xml:264
15015 msgid ""
15016 "<literal role=\"template-filter\">addbreaks</literal>: Any text. Add an XHTML "
15017 "<quote><literal>&lt;br/&gt;</literal></quote> tag before the end of every "
15018 "line except the last. For example, <quote><literal>foo\\nbar</literal></"
15019 "quote> becomes <quote><literal>foo&lt;br/&gt;\\nbar</literal></quote>."
15020 msgstr ""
15022 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15023 #: ../en/ch11-template.xml:271
15024 msgid ""
15025 "<literal role=\"template-kw-filt-date\">age</literal>: <literal role="
15026 "\"template-keyword\">date</literal> keyword. Render the age of the date, "
15027 "relative to the current time. Yields a string like <quote><literal>10 "
15028 "minutes</literal></quote>."
15029 msgstr ""
15031 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15032 #: ../en/ch11-template.xml:278
15033 msgid ""
15034 "<literal role=\"template-filter\">basename</literal>: Any text, but most "
15035 "useful for the <literal role=\"template-keyword\">files</literal> keyword and "
15036 "its relatives. Treat the text as a path, and return the basename. For "
15037 "example, <quote><literal>foo/bar/baz</literal></quote> becomes "
15038 "<quote><literal>baz</literal></quote>."
15039 msgstr ""
15041 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15042 #: ../en/ch11-template.xml:287
15043 msgid ""
15044 "<literal role=\"template-kw-filt-date\">date</literal>: <literal role="
15045 "\"template-keyword\">date</literal> keyword. Render a date in a similar "
15046 "format to the Unix <literal role=\"template-keyword\">date</literal> command, "
15047 "but with timezone included. Yields a string like <quote><literal>Mon Sep 04 "
15048 "15:13:13 2006 -0700</literal></quote>."
15049 msgstr ""
15051 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15052 #: ../en/ch11-template.xml:295
15053 msgid ""
15054 "<literal role=\"template-kw-filt-author\">domain</literal>: Any text, but "
15055 "most useful for the <literal role=\"template-keyword\">author</literal> "
15056 "keyword. Finds the first string that looks like an email address, and "
15057 "extract just the domain component. For example, <quote><literal>Bryan "
15058 "O'Sullivan &lt;bos@serpentine.com&gt;</literal></quote> becomes "
15059 "<quote><literal>serpentine.com</literal></quote>."
15060 msgstr ""
15062 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15063 #: ../en/ch11-template.xml:305
15064 msgid ""
15065 "<literal role=\"template-kw-filt-author\">email</literal>: Any text, but most "
15066 "useful for the <literal role=\"template-keyword\">author</literal> keyword. "
15067 "Extract the first string that looks like an email address. For example, "
15068 "<quote><literal>Bryan O'Sullivan &lt;bos@serpentine.com&gt;</literal></quote> "
15069 "becomes <quote><literal>bos@serpentine.com</literal></quote>."
15070 msgstr ""
15072 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15073 #: ../en/ch11-template.xml:314
15074 msgid ""
15075 "<literal role=\"template-filter\">escape</literal>: Any text. Replace the "
15076 "special XML/XHTML characters <quote><literal>&amp;</literal></quote>, "
15077 "<quote><literal>&lt;</literal></quote> and <quote><literal>&gt;</literal></"
15078 "quote> with XML entities."
15079 msgstr ""
15081 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15082 #: ../en/ch11-template.xml:322
15083 msgid ""
15084 "<literal role=\"template-filter\">fill68</literal>: Any text. Wrap the text "
15085 "to fit in 68 columns. This is useful before you pass text through the "
15086 "<literal role=\"template-filter\">tabindent</literal> filter, and still want "
15087 "it to fit in an 80-column fixed-font window."
15088 msgstr ""
15090 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15091 #: ../en/ch11-template.xml:330
15092 msgid ""
15093 "<literal role=\"template-filter\">fill76</literal>: Any text. Wrap the text "
15094 "to fit in 76 columns."
15095 msgstr ""
15097 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15098 #: ../en/ch11-template.xml:334
15099 msgid ""
15100 "<literal role=\"template-filter\">firstline</literal>: Any text. Yield the "
15101 "first line of text, without any trailing newlines."
15102 msgstr ""
15104 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15105 #: ../en/ch11-template.xml:339
15106 msgid ""
15107 "<literal role=\"template-kw-filt-date\">hgdate</literal>: <literal role="
15108 "\"template-keyword\">date</literal> keyword. Render the date as a pair of "
15109 "readable numbers. Yields a string like <quote><literal>1157407993 25200</"
15110 "literal></quote>."
15111 msgstr ""
15113 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15114 #: ../en/ch11-template.xml:346
15115 msgid ""
15116 "<literal role=\"template-kw-filt-date\">isodate</literal>: <literal role="
15117 "\"template-keyword\">date</literal> keyword. Render the date as a text "
15118 "string in ISO 8601 format. Yields a string like <quote><literal>2006-09-04 "
15119 "15:13:13 -0700</literal></quote>."
15120 msgstr ""
15122 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15123 #: ../en/ch11-template.xml:353
15124 msgid ""
15125 "<literal role=\"template-filter\">obfuscate</literal>: Any text, but most "
15126 "useful for the <literal role=\"template-keyword\">author</literal> keyword. "
15127 "Yield the input text rendered as a sequence of XML entities. This helps to "
15128 "defeat some particularly stupid screen-scraping email harvesting spambots."
15129 msgstr ""
15131 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15132 #: ../en/ch11-template.xml:361
15133 msgid ""
15134 "<literal role=\"template-kw-filt-author\">person</literal>: Any text, but "
15135 "most useful for the <literal role=\"template-keyword\">author</literal> "
15136 "keyword. Yield the text before an email address. For example, "
15137 "<quote><literal>Bryan O'Sullivan &lt;bos@serpentine.com&gt;</literal></quote> "
15138 "becomes <quote><literal>Bryan O'Sullivan</literal></quote>."
15139 msgstr ""
15141 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15142 #: ../en/ch11-template.xml:370
15143 msgid ""
15144 "<literal role=\"template-kw-filt-date\">rfc822date</literal>: <literal role="
15145 "\"template-keyword\">date</literal> keyword. Render a date using the same "
15146 "format used in email headers. Yields a string like <quote><literal>Mon, 04 "
15147 "Sep 2006 15:13:13 -0700</literal></quote>."
15148 msgstr ""
15150 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15151 #: ../en/ch11-template.xml:377
15152 msgid ""
15153 "<literal role=\"template-kw-filt-node\">short</literal>: Changeset hash. "
15154 "Yield the short form of a changeset hash, i.e. a 12-character hexadecimal "
15155 "string."
15156 msgstr ""
15158 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15159 #: ../en/ch11-template.xml:382
15160 msgid ""
15161 "<literal role=\"template-kw-filt-date\">shortdate</literal>: <literal role="
15162 "\"template-keyword\">date</literal> keyword. Render the year, month, and day "
15163 "of the date. Yields a string like <quote><literal>2006-09-04</literal></"
15164 "quote>."
15165 msgstr ""
15167 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15168 #: ../en/ch11-template.xml:388
15169 msgid ""
15170 "<literal role=\"template-filter\">strip</literal>: Any text. Strip all "
15171 "leading and trailing whitespace from the string."
15172 msgstr ""
15174 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15175 #: ../en/ch11-template.xml:392
15176 msgid ""
15177 "<literal role=\"template-filter\">tabindent</literal>: Any text. Yield the "
15178 "text, with every line except the first starting with a tab character."
15179 msgstr ""
15181 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15182 #: ../en/ch11-template.xml:397
15183 msgid ""
15184 "<literal role=\"template-filter\">urlescape</literal>: Any text. Escape all "
15185 "characters that are considered <quote>special</quote> by URL parsers. For "
15186 "example, <literal>foo bar</literal> becomes <literal>foo%20bar</literal>."
15187 msgstr ""
15189 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15190 #: ../en/ch11-template.xml:404
15191 msgid ""
15192 "<literal role=\"template-kw-filt-author\">user</literal>: Any text, but most "
15193 "useful for the <literal role=\"template-keyword\">author</literal> keyword. "
15194 "Return the <quote>user</quote> portion of an email address. For example, "
15195 "<quote><literal>Bryan O'Sullivan &lt;bos@serpentine.com&gt;</literal></quote> "
15196 "becomes <quote><literal>bos</literal></quote>."
15197 msgstr ""
15199 #. type: Content of: <book><chapter><sect1><note><para>
15200 #: ../en/ch11-template.xml:418
15201 msgid ""
15202 "If you try to apply a filter to a piece of data that it cannot process, "
15203 "Mercurial will fail and print a Python exception. For example, trying to run "
15204 "the output of the <literal role=\"template-keyword\">desc</literal> keyword "
15205 "into the <literal role=\"template-kw-filt-date\">isodate</literal> filter is "
15206 "not a good idea."
15207 msgstr ""
15209 #. type: Content of: <book><chapter><sect1><sect2><title>
15210 #: ../en/ch11-template.xml:427
15211 msgid "Combining filters"
15212 msgstr "组合过滤器"
15214 #. type: Content of: <book><chapter><sect1><sect2><para>
15215 #: ../en/ch11-template.xml:429
15216 msgid ""
15217 "It is easy to combine filters to yield output in the form you would like. "
15218 "The following chain of filters tidies up a description, then makes sure that "
15219 "it fits cleanly into 68 columns, then indents it by a further 8 characters "
15220 "(at least on Unix-like systems, where a tab is conventionally 8 characters "
15221 "wide)."
15222 msgstr ""
15224 #. type: Content of: <book><chapter><sect1><sect2><para>
15225 #: ../en/ch11-template.xml:438
15226 msgid ""
15227 "Note the use of <quote><literal>\\t</literal></quote> (a tab character) in "
15228 "the template to force the first line to be indented; this is necessary since "
15229 "<literal role=\"template-keyword\">tabindent</literal> indents all lines "
15230 "<emphasis>except</emphasis> the first."
15231 msgstr ""
15233 #. type: Content of: <book><chapter><sect1><sect2><para>
15234 #: ../en/ch11-template.xml:444
15235 msgid ""
15236 "Keep in mind that the order of filters in a chain is significant. The first "
15237 "filter is applied to the result of the keyword; the second to the result of "
15238 "the first filter; and so on. For example, using <literal>fill68|tabindent</"
15239 "literal> gives very different results from <literal>tabindent|fill68</"
15240 "literal>."
15241 msgstr ""
15243 #. type: Content of: <book><chapter><sect1><title>
15244 #: ../en/ch11-template.xml:454
15245 msgid "From templates to styles"
15246 msgstr "从模版到样式"
15248 #. type: Content of: <book><chapter><sect1><para>
15249 #: ../en/ch11-template.xml:456
15250 msgid ""
15251 "A command line template provides a quick and simple way to format some "
15252 "output. Templates can become verbose, though, and it's useful to be able to "
15253 "give a template a name. A style file is a template with a name, stored in a "
15254 "file."
15255 msgstr ""
15257 #. type: Content of: <book><chapter><sect1><para>
15258 #: ../en/ch11-template.xml:461
15259 msgid ""
15260 "More than that, using a style file unlocks the power of Mercurial's "
15261 "templating engine in ways that are not possible using the command line "
15262 "<option role=\"hg-opt-log\">--template</option> option."
15263 msgstr ""
15265 #. type: Content of: <book><chapter><sect1><sect2><title>
15266 #: ../en/ch11-template.xml:467
15267 msgid "The simplest of style files"
15268 msgstr "最简单的样式文件"
15270 #. type: Content of: <book><chapter><sect1><sect2><para>
15271 #: ../en/ch11-template.xml:469
15272 msgid "Our simple style file contains just one line:"
15273 msgstr ""
15275 #. type: Content of: <book><chapter><sect1><sect2><para>
15276 #: ../en/ch11-template.xml:473
15277 msgid ""
15278 "This tells Mercurial, <quote>if you're printing a changeset, use the text on "
15279 "the right as the template</quote>."
15280 msgstr ""
15282 #. type: Content of: <book><chapter><sect1><sect2><title>
15283 #: ../en/ch11-template.xml:479
15284 msgid "Style file syntax"
15285 msgstr "样式文件语法"
15287 #. type: Content of: <book><chapter><sect1><sect2><para>
15288 #: ../en/ch11-template.xml:481
15289 msgid "The syntax rules for a style file are simple."
15290 msgstr ""
15292 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15293 #: ../en/ch11-template.xml:484
15294 msgid "The file is processed one line at a time."
15295 msgstr ""
15297 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15298 #: ../en/ch11-template.xml:487
15299 msgid "Leading and trailing white space are ignored."
15300 msgstr ""
15302 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15303 #: ../en/ch11-template.xml:490
15304 msgid "Empty lines are skipped."
15305 msgstr ""
15307 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15308 #: ../en/ch11-template.xml:492
15309 msgid ""
15310 "If a line starts with either of the characters <quote><literal>#</literal></"
15311 "quote> or <quote><literal>;</literal></quote>, the entire line is treated as "
15312 "a comment, and skipped as if empty."
15313 msgstr ""
15315 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15316 #: ../en/ch11-template.xml:497
15317 msgid ""
15318 "A line starts with a keyword. This must start with an alphabetic character "
15319 "or underscore, and can subsequently contain any alphanumeric character or "
15320 "underscore. (In regexp notation, a keyword must match <literal>[A-Za-z_][A-"
15321 "Za-z0-9_]*</literal>.)"
15322 msgstr ""
15324 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15325 #: ../en/ch11-template.xml:503
15326 msgid ""
15327 "The next element must be an <quote><literal>=</literal></quote> character, "
15328 "which can be preceded or followed by an arbitrary amount of white space."
15329 msgstr ""
15331 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15332 #: ../en/ch11-template.xml:508
15333 msgid ""
15334 "If the rest of the line starts and ends with matching quote characters "
15335 "(either single or double quote), it is treated as a template body."
15336 msgstr ""
15338 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15339 #: ../en/ch11-template.xml:512
15340 msgid ""
15341 "If the rest of the line <emphasis>does not</emphasis> start with a quote "
15342 "character, it is treated as the name of a file; the contents of this file "
15343 "will be read and used as a template body."
15344 msgstr ""
15346 #. type: Content of: <book><chapter><sect1><title>
15347 #: ../en/ch11-template.xml:521
15348 msgid "Style files by example"
15349 msgstr "样式文件例子"
15351 #. type: Content of: <book><chapter><sect1><para>
15352 #: ../en/ch11-template.xml:523
15353 msgid ""
15354 "To illustrate how to write a style file, we will construct a few by example. "
15355 "Rather than provide a complete style file and walk through it, we'll mirror "
15356 "the usual process of developing a style file by starting with something very "
15357 "simple, and walking through a series of successively more complete examples."
15358 msgstr ""
15360 #. type: Content of: <book><chapter><sect1><sect2><title>
15361 #: ../en/ch11-template.xml:530
15362 msgid "Identifying mistakes in style files"
15363 msgstr "在样式文件中定位错误"
15365 #. type: Content of: <book><chapter><sect1><sect2><para>
15366 #: ../en/ch11-template.xml:532
15367 msgid ""
15368 "If Mercurial encounters a problem in a style file you are working on, it "
15369 "prints a terse error message that, once you figure out what it means, is "
15370 "actually quite useful."
15371 msgstr ""
15373 #. type: Content of: <book><chapter><sect1><sect2><para>
15374 #: ../en/ch11-template.xml:538
15375 msgid ""
15376 "Notice that <filename>broken.style</filename> attempts to define a "
15377 "<literal>changeset</literal> keyword, but forgets to give any content for it. "
15378 "When instructed to use this style file, Mercurial promptly complains."
15379 msgstr ""
15381 #. type: Content of: <book><chapter><sect1><sect2><para>
15382 #: ../en/ch11-template.xml:545
15383 msgid "This error message looks intimidating, but it is not too hard to follow."
15384 msgstr ""
15386 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15387 #: ../en/ch11-template.xml:549
15388 msgid ""
15389 "The first component is simply Mercurial's way of saying <quote>I am giving "
15390 "up</quote>."
15391 msgstr ""
15393 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15394 #: ../en/ch11-template.xml:553
15395 msgid "Next comes the name of the style file that contains the error."
15396 msgstr ""
15398 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15399 #: ../en/ch11-template.xml:557
15400 msgid ""
15401 "Following the file name is the line number where the error was encountered."
15402 msgstr ""
15404 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15405 #: ../en/ch11-template.xml:561
15406 msgid "Finally, a description of what went wrong."
15407 msgstr ""
15409 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15410 #: ../en/ch11-template.xml:565
15411 msgid ""
15412 "The description of the problem is not always clear (as in this case), but "
15413 "even when it is cryptic, it is almost always trivial to visually inspect the "
15414 "offending line in the style file and see what is wrong."
15415 msgstr ""
15417 #. type: Content of: <book><chapter><sect1><sect2><title>
15418 #: ../en/ch11-template.xml:574
15419 msgid "Uniquely identifying a repository"
15420 msgstr "版本库的唯一标识"
15422 #. type: Content of: <book><chapter><sect1><sect2><para>
15423 #: ../en/ch11-template.xml:576
15424 msgid ""
15425 "If you would like to be able to identify a Mercurial repository <quote>fairly "
15426 "uniquely</quote> using a short string as an identifier, you can use the first "
15427 "revision in the repository."
15428 msgstr ""
15430 #. type: Content of: <book><chapter><sect1><sect2><para>
15431 #: ../en/ch11-template.xml:583
15432 msgid ""
15433 "This is likely to be unique, and so it is useful in many cases. There are a "
15434 "few caveats."
15435 msgstr ""
15437 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15438 #: ../en/ch11-template.xml:586
15439 msgid ""
15440 "It will not work in a completely empty repository, because such a repository "
15441 "does not have a revision zero."
15442 msgstr ""
15444 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15445 #: ../en/ch11-template.xml:590
15446 msgid ""
15447 "Neither will it work in the (extremely rare) case where a repository is a "
15448 "merge of two or more formerly independent repositories, and you still have "
15449 "those repositories around."
15450 msgstr ""
15452 #. type: Content of: <book><chapter><sect1><sect2><para>
15453 #: ../en/ch11-template.xml:595
15454 msgid "Here are some uses to which you could put this identifier:"
15455 msgstr ""
15457 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15458 #: ../en/ch11-template.xml:598
15459 msgid ""
15460 "As a key into a table for a database that manages repositories on a server."
15461 msgstr ""
15463 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15464 #: ../en/ch11-template.xml:601
15465 msgid ""
15466 "As half of a {<emphasis>repository ID</emphasis>, <emphasis>revision ID</"
15467 "emphasis>} tuple. Save this information away when you run an automated build "
15468 "or other activity, so that you can <quote>replay</quote> the build later if "
15469 "necessary."
15470 msgstr ""
15472 #. type: Content of: <book><chapter><sect1><sect2><title>
15473 #: ../en/ch11-template.xml:611
15474 msgid "Listing files on multiple lines"
15475 msgstr "每行列出一个文件"
15477 #. type: Content of: <book><chapter><sect1><sect2><para>
15478 #: ../en/ch11-template.xml:613
15479 msgid ""
15480 "Suppose we want to list the files changed by a changeset, one per line, with "
15481 "a little indentation before each file name."
15482 msgstr ""
15484 #. type: Content of: <book><chapter><sect1><sect2><title>
15485 #: ../en/ch11-template.xml:621
15486 msgid "Mimicking Subversion's output"
15487 msgstr "模仿 Subversion 的输出"
15490 #. type: Content of: <book><chapter><sect1><sect2><para>
15491 #: ../en/ch11-template.xml:623
15492 msgid ""
15493 "Let's try to emulate the default output format used by another revision "
15494 "control tool, Subversion."
15495 msgstr ""
15498 #. type: Content of: <book><chapter><sect1><sect2><para>
15499 #: ../en/ch11-template.xml:628
15500 msgid ""
15501 "Since Subversion's output style is fairly simple, it is easy to copy-and-"
15502 "paste a hunk of its output into a file, and replace the text produced above "
15503 "by Subversion with the template values we'd like to see expanded."
15504 msgstr ""
15506 #. type: Content of: <book><chapter><sect1><sect2><para>
15507 #: ../en/ch11-template.xml:635
15508 msgid ""
15509 "There are a few small ways in which this template deviates from the output "
15510 "produced by Subversion."
15511 msgstr ""
15513 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15514 #: ../en/ch11-template.xml:638
15515 msgid ""
15516 "Subversion prints a <quote>readable</quote> date (the <quote><literal>Wed, 27 "
15517 "Sep 2006</literal></quote> in the example output above) in parentheses. "
15518 "Mercurial's templating engine does not provide a way to display a date in "
15519 "this format without also printing the time and time zone."
15520 msgstr ""
15522 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15523 #: ../en/ch11-template.xml:645
15524 msgid ""
15525 "We emulate Subversion's printing of <quote>separator</quote> lines full of "
15526 "<quote><literal>-</literal></quote> characters by ending the template with "
15527 "such a line. We use the templating engine's <literal role=\"template-keyword"
15528 "\">header</literal> keyword to print a separator line as the first line of "
15529 "output (see below), thus achieving similar output to Subversion."
15530 msgstr ""
15532 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15533 #: ../en/ch11-template.xml:654
15534 msgid ""
15535 "Subversion's output includes a count in the header of the number of lines in "
15536 "the commit message. We cannot replicate this in Mercurial; the templating "
15537 "engine does not currently provide a filter that counts the number of lines "
15538 "the template generates."
15539 msgstr ""
15542 #. type: Content of: <book><chapter><sect1><sect2><para>
15543 #: ../en/ch11-template.xml:660
15544 msgid ""
15545 "It took me no more than a minute or two of work to replace literal text from "
15546 "an example of Subversion's output with some keywords and filters to give the "
15547 "template above. The style file simply refers to the template."
15548 msgstr ""
15550 #. type: Content of: <book><chapter><sect1><sect2><para>
15551 #: ../en/ch11-template.xml:667
15552 msgid ""
15553 "We could have included the text of the template file directly in the style "
15554 "file by enclosing it in quotes and replacing the newlines with "
15555 "<quote><literal>\\n</literal></quote> sequences, but it would have made the "
15556 "style file too difficult to read. Readability is a good guide when you're "
15557 "trying to decide whether some text belongs in a style file, or in a template "
15558 "file that the style file points to. If the style file will look too big or "
15559 "cluttered if you insert a literal piece of text, drop it into a template "
15560 "instead."
15561 msgstr ""
15563 #. type: Content of: <book><chapter><title>
15564 #: ../en/ch12-mq.xml:5
15565 msgid "Managing change with Mercurial Queues"
15566 msgstr "使用 MQ 管理修改"
15568 #. type: Content of: <book><chapter><sect1><title>
15569 #: ../en/ch12-mq.xml:8
15570 msgid "The patch management problem"
15571 msgstr "补丁的管理问题"
15573 #. type: Content of: <book><chapter><sect1><para>
15574 #: ../en/ch12-mq.xml:10
15575 msgid ""
15576 "Here is a common scenario: you need to install a software package from "
15577 "source, but you find a bug that you must fix in the source before you can "
15578 "start using the package. You make your changes, forget about the package for "
15579 "a while, and a few months later you need to upgrade to a newer version of the "
15580 "package. If the newer version of the package still has the bug, you must "
15581 "extract your fix from the older source tree and apply it against the newer "
15582 "version. This is a tedious task, and it's easy to make mistakes."
15583 msgstr ""
15585 #. type: Content of: <book><chapter><sect1><para>
15586 #: ../en/ch12-mq.xml:20
15587 msgid ""
15588 "This is a simple case of the <quote>patch management</quote> problem. You "
15589 "have an <quote>upstream</quote> source tree that you can't change; you need "
15590 "to make some local changes on top of the upstream tree; and you'd like to be "
15591 "able to keep those changes separate, so that you can apply them to newer "
15592 "versions of the upstream source."
15593 msgstr ""
15595 #. type: Content of: <book><chapter><sect1><para>
15596 #: ../en/ch12-mq.xml:27
15597 msgid ""
15598 "The patch management problem arises in many situations. Probably the most "
15599 "visible is that a user of an open source software project will contribute a "
15600 "bug fix or new feature to the project's maintainers in the form of a patch."
15601 msgstr ""
15603 #. type: Content of: <book><chapter><sect1><para>
15604 #: ../en/ch12-mq.xml:32
15605 msgid ""
15606 "Distributors of operating systems that include open source software often "
15607 "need to make changes to the packages they distribute so that they will build "
15608 "properly in their environments."
15609 msgstr ""
15611 #. type: Content of: <book><chapter><sect1><para>
15612 #: ../en/ch12-mq.xml:37
15613 msgid ""
15614 "When you have few changes to maintain, it is easy to manage a single patch "
15615 "using the standard <command>diff</command> and <command>patch</command> "
15616 "programs (see <xref linkend=\"sec:mq:patch\"/> for a discussion of these "
15617 "tools). Once the number of changes grows, it starts to make sense to maintain "
15618 "patches as discrete <quote>chunks of work,</quote> so that for example a "
15619 "single patch will contain only one bug fix (the patch might modify several "
15620 "files, but it's doing <quote>only one thing</quote>), and you may have a "
15621 "number of such patches for different bugs you need fixed and local changes "
15622 "you require. In this situation, if you submit a bug fix patch to the "
15623 "upstream maintainers of a package and they include your fix in a subsequent "
15624 "release, you can simply drop that single patch when you're updating to the "
15625 "newer release."
15626 msgstr ""
15628 #. type: Content of: <book><chapter><sect1><para>
15629 #: ../en/ch12-mq.xml:52
15630 msgid ""
15631 "Maintaining a single patch against an upstream tree is a little tedious and "
15632 "error-prone, but not difficult. However, the complexity of the problem grows "
15633 "rapidly as the number of patches you have to maintain increases. With more "
15634 "than a tiny number of patches in hand, understanding which ones you have "
15635 "applied and maintaining them moves from messy to overwhelming."
15636 msgstr ""
15638 #. type: Content of: <book><chapter><sect1><para>
15639 #: ../en/ch12-mq.xml:59
15640 msgid ""
15641 "Fortunately, Mercurial includes a powerful extension, Mercurial Queues (or "
15642 "simply <quote>MQ</quote>), that massively simplifies the patch management "
15643 "problem."
15644 msgstr ""
15646 #. type: Content of: <book><chapter><sect1><title>
15647 #: ../en/ch12-mq.xml:65
15648 msgid "The prehistory of Mercurial Queues"
15649 msgstr "MQ 的历史"
15651 #. type: Content of: <book><chapter><sect1><para>
15652 #: ../en/ch12-mq.xml:67
15653 msgid ""
15654 "During the late 1990s, several Linux kernel developers started to maintain "
15655 "<quote>patch series</quote> that modified the behavior of the Linux kernel. "
15656 "Some of these series were focused on stability, some on feature coverage, and "
15657 "others were more speculative."
15658 msgstr ""
15660 #. type: Content of: <book><chapter><sect1><para>
15661 #: ../en/ch12-mq.xml:73
15662 msgid ""
15663 "The sizes of these patch series grew rapidly. In 2002, Andrew Morton "
15664 "published some shell scripts he had been using to automate the task of "
15665 "managing his patch queues. Andrew was successfully using these scripts to "
15666 "manage hundreds (sometimes thousands) of patches on top of the Linux kernel."
15667 msgstr ""
15669 #. type: Content of: <book><chapter><sect1><sect2><title>
15670 #: ../en/ch12-mq.xml:80
15671 msgid "A patchwork quilt"
15672 msgstr ""
15674 #. type: Content of: <book><chapter><sect1><sect2><para>
15675 #: ../en/ch12-mq.xml:82
15676 msgid ""
15677 "In early 2003, Andreas Gruenbacher and Martin Quinson borrowed the approach "
15678 "of Andrew's scripts and published a tool called <quote>patchwork quilt</"
15679 "quote> <citation>web:quilt</citation>, or simply <quote>quilt</quote> (see "
15680 "<citation>gruenbacher:2005</citation> for a paper describing it). Because "
15681 "quilt substantially automated patch management, it rapidly gained a large "
15682 "following among open source software developers."
15683 msgstr ""
15685 #. type: Content of: <book><chapter><sect1><sect2><para>
15686 #: ../en/ch12-mq.xml:91
15687 msgid ""
15688 "Quilt manages a <emphasis>stack of patches</emphasis> on top of a directory "
15689 "tree. To begin, you tell quilt to manage a directory tree, and tell it which "
15690 "files you want to manage; it stores away the names and contents of those "
15691 "files. To fix a bug, you create a new patch (using a single command), edit "
15692 "the files you need to fix, then <quote>refresh</quote> the patch."
15693 msgstr ""
15695 #. type: Content of: <book><chapter><sect1><sect2><para>
15696 #: ../en/ch12-mq.xml:99
15697 msgid ""
15698 "The refresh step causes quilt to scan the directory tree; it updates the "
15699 "patch with all of the changes you have made. You can create another patch on "
15700 "top of the first, which will track the changes required to modify the tree "
15701 "from <quote>tree with one patch applied</quote> to <quote>tree with two "
15702 "patches applied</quote>."
15703 msgstr ""
15705 #. type: Content of: <book><chapter><sect1><sect2><para>
15706 #: ../en/ch12-mq.xml:106
15707 msgid ""
15708 "You can <emphasis>change</emphasis> which patches are applied to the tree. "
15709 "If you <quote>pop</quote> a patch, the changes made by that patch will vanish "
15710 "from the directory tree. Quilt remembers which patches you have popped, "
15711 "though, so you can <quote>push</quote> a popped patch again, and the "
15712 "directory tree will be restored to contain the modifications in the patch. "
15713 "Most importantly, you can run the <quote>refresh</quote> command at any time, "
15714 "and the topmost applied patch will be updated. This means that you can, at "
15715 "any time, change both which patches are applied and what modifications those "
15716 "patches make."
15717 msgstr ""
15719 #. type: Content of: <book><chapter><sect1><sect2><para>
15720 #: ../en/ch12-mq.xml:118
15721 msgid ""
15722 "Quilt knows nothing about revision control tools, so it works equally well on "
15723 "top of an unpacked tarball or a Subversion working copy."
15724 msgstr ""
15726 #. type: Content of: <book><chapter><sect1><sect2><title>
15727 #: ../en/ch12-mq.xml:124
15728 msgid "From patchwork quilt to Mercurial Queues"
15729 msgstr "从 patchwork quilt 到 MQ"
15731 #. type: Content of: <book><chapter><sect1><sect2><para>
15732 #: ../en/ch12-mq.xml:126
15733 msgid ""
15734 "In mid-2005, Chris Mason took the features of quilt and wrote an extension "
15735 "that he called Mercurial Queues, which added quilt-like behavior to Mercurial."
15736 msgstr ""
15738 #. type: Content of: <book><chapter><sect1><sect2><para>
15739 #: ../en/ch12-mq.xml:130
15740 msgid ""
15741 "The key difference between quilt and MQ is that quilt knows nothing about "
15742 "revision control systems, while MQ is <emphasis>integrated</emphasis> into "
15743 "Mercurial. Each patch that you push is represented as a Mercurial "
15744 "changeset. Pop a patch, and the changeset goes away."
15745 msgstr ""
15747 #. type: Content of: <book><chapter><sect1><sect2><para>
15748 #: ../en/ch12-mq.xml:136
15749 msgid ""
15750 "Because quilt does not care about revision control tools, it is still a "
15751 "tremendously useful piece of software to know about for situations where you "
15752 "cannot use Mercurial and MQ."
15753 msgstr ""
15755 #. type: Content of: <book><chapter><sect1><title>
15756 #: ../en/ch12-mq.xml:144
15757 msgid "The huge advantage of MQ"
15758 msgstr "MQ 的巨大优势"
15760 #. type: Content of: <book><chapter><sect1><para>
15761 #: ../en/ch12-mq.xml:146
15762 msgid ""
15763 "I cannot overstate the value that MQ offers through the unification of "
15764 "patches and revision control."
15765 msgstr ""
15767 #. type: Content of: <book><chapter><sect1><para>
15768 #: ../en/ch12-mq.xml:149
15769 msgid ""
15770 "A major reason that patches have persisted in the free software and open "
15771 "source world&emdash;in spite of the availability of increasingly capable "
15772 "revision control tools over the years&emdash;is the <emphasis>agility</"
15773 "emphasis> they offer."
15774 msgstr ""
15776 #. type: Content of: <book><chapter><sect1><para>
15777 #: ../en/ch12-mq.xml:155
15778 msgid ""
15779 "Traditional revision control tools make a permanent, irreversible record of "
15780 "everything that you do. While this has great value, it's also somewhat "
15781 "stifling. If you want to perform a wild-eyed experiment, you have to be "
15782 "careful in how you go about it, or you risk leaving unneeded&emdash;or worse, "
15783 "misleading or destabilising&emdash;traces of your missteps and errors in the "
15784 "permanent revision record."
15785 msgstr ""
15787 #. type: Content of: <book><chapter><sect1><para>
15788 #: ../en/ch12-mq.xml:163
15789 msgid ""
15790 "By contrast, MQ's marriage of distributed revision control with patches makes "
15791 "it much easier to isolate your work. Your patches live on top of normal "
15792 "revision history, and you can make them disappear or reappear at will. If "
15793 "you don't like a patch, you can drop it. If a patch isn't quite as you want "
15794 "it to be, simply fix it&emdash;as many times as you need to, until you have "
15795 "refined it into the form you desire."
15796 msgstr ""
15798 #. type: Content of: <book><chapter><sect1><para>
15799 #: ../en/ch12-mq.xml:171
15800 msgid ""
15801 "As an example, the integration of patches with revision control makes "
15802 "understanding patches and debugging their effects&emdash;and their interplay "
15803 "with the code they're based on&emdash;<emphasis>enormously</emphasis> easier. "
15804 "Since every applied patch has an associated changeset, you can give <command "
15805 "role=\"hg-cmd\">hg log</command> a file name to see which changesets and "
15806 "patches affected the file. You can use the <command role=\"hg-cmd\">hg "
15807 "bisect</command> command to binary-search through all changesets and applied "
15808 "patches to see where a bug got introduced or fixed. You can use the <command "
15809 "role=\"hg-cmd\">hg annotate</command> command to see which changeset or patch "
15810 "modified a particular line of a source file. And so on."
15811 msgstr ""
15813 #. type: Content of: <book><chapter><sect1><para>
15814 #: ../en/ch12-mq.xml:189
15815 msgid ""
15816 "Because MQ doesn't hide its patch-oriented nature, it is helpful to "
15817 "understand what patches are, and a little about the tools that work with them."
15818 msgstr ""
15820 #. type: Content of: <book><chapter><sect1><para>
15821 #: ../en/ch12-mq.xml:193
15822 msgid ""
15823 "The traditional Unix <command>diff</command> command compares two files, and "
15824 "prints a list of differences between them. The <command>patch</command> "
15825 "command understands these differences as <emphasis>modifications</emphasis> "
15826 "to make to a file. Take a look below for a simple example of these commands "
15827 "in action."
15828 msgstr ""
15830 #. type: Content of: <book><chapter><sect1><para>
15831 #: ../en/ch12-mq.xml:202
15832 msgid ""
15833 "The type of file that <command>diff</command> generates (and <command>patch</"
15834 "command> takes as input) is called a <quote>patch</quote> or a <quote>diff</"
15835 "quote>; there is no difference between a patch and a diff. (We'll use the "
15836 "term <quote>patch</quote>, since it's more commonly used.)"
15837 msgstr ""
15839 #. type: Content of: <book><chapter><sect1><para>
15840 #: ../en/ch12-mq.xml:208
15841 msgid ""
15842 "A patch file can start with arbitrary text; the <command>patch</command> "
15843 "command ignores this text, but MQ uses it as the commit message when creating "
15844 "changesets. To find the beginning of the patch content, <command>patch</"
15845 "command> searches for the first line that starts with the string "
15846 "<quote><literal>diff -</literal></quote>."
15847 msgstr ""
15849 #. type: Content of: <book><chapter><sect1><para>
15850 #: ../en/ch12-mq.xml:215
15851 msgid ""
15852 "MQ works with <emphasis>unified</emphasis> diffs (<command>patch</command> "
15853 "can accept several other diff formats, but MQ doesn't). A unified diff "
15854 "contains two kinds of header. The <emphasis>file header</emphasis> describes "
15855 "the file being modified; it contains the name of the file to modify. When "
15856 "<command>patch</command> sees a new file header, it looks for a file with "
15857 "that name to start modifying."
15858 msgstr ""
15860 #. type: Content of: <book><chapter><sect1><para>
15861 #: ../en/ch12-mq.xml:223
15862 msgid ""
15863 "After the file header comes a series of <emphasis>hunks</emphasis>. Each "
15864 "hunk starts with a header; this identifies the range of line numbers within "
15865 "the file that the hunk should modify. Following the header, a hunk starts "
15866 "and ends with a few (usually three) lines of text from the unmodified file; "
15867 "these are called the <emphasis>context</emphasis> for the hunk. If there's "
15868 "only a small amount of context between successive hunks, <command>diff</"
15869 "command> doesn't print a new hunk header; it just runs the hunks together, "
15870 "with a few lines of context between modifications."
15871 msgstr ""
15873 #. type: Content of: <book><chapter><sect1><para>
15874 #: ../en/ch12-mq.xml:235
15875 msgid ""
15876 "Each line of context begins with a space character. Within the hunk, a line "
15877 "that begins with <quote><literal>-</literal></quote> means <quote>remove this "
15878 "line,</quote> while a line that begins with <quote><literal>+</literal></"
15879 "quote> means <quote>insert this line.</quote> For example, a line that is "
15880 "modified is represented by one deletion and one insertion."
15881 msgstr ""
15883 #. type: Content of: <book><chapter><sect1><para>
15884 #: ../en/ch12-mq.xml:243
15885 msgid ""
15886 "We will return to some of the more subtle aspects of patches later (in <xref "
15887 "linkend=\"sec:mq:adv-patch\"/>), but you should have enough information now "
15888 "to use MQ."
15889 msgstr ""
15891 #. type: Content of: <book><chapter><sect1><title>
15892 #: ../en/ch12-mq.xml:250
15893 msgid "Getting started with Mercurial Queues"
15894 msgstr "开始使用 MQ"
15896 #. type: Content of: <book><chapter><sect1><para>
15897 #: ../en/ch12-mq.xml:252
15898 msgid ""
15899 "Because MQ is implemented as an extension, you must explicitly enable before "
15900 "you can use it. (You don't need to download anything; MQ ships with the "
15901 "standard Mercurial distribution.) To enable MQ, edit your <filename role="
15902 "\"home\">~/.hgrc</filename> file, and add the lines below."
15903 msgstr ""
15905 #. type: Content of: <book><chapter><sect1><para>
15906 #: ../en/ch12-mq.xml:262
15907 msgid ""
15908 "Once the extension is enabled, it will make a number of new commands "
15909 "available. To verify that the extension is working, you can use <command "
15910 "role=\"hg-cmd\">hg help</command> to see if the <command role=\"hg-ext-mq"
15911 "\">qinit</command> command is now available."
15912 msgstr ""
15914 #. type: Content of: <book><chapter><sect1><para>
15915 #: ../en/ch12-mq.xml:270
15916 msgid ""
15917 "You can use MQ with <emphasis>any</emphasis> Mercurial repository, and its "
15918 "commands only operate within that repository. To get started, simply prepare "
15919 "the repository using the <command role=\"hg-ext-mq\">qinit</command> command."
15920 msgstr ""
15922 #. type: Content of: <book><chapter><sect1><para>
15923 #: ../en/ch12-mq.xml:277
15924 msgid ""
15925 "This command creates an empty directory called <filename role=\"special\" "
15926 "class=\"directory\">.hg/patches</filename>, where MQ will keep its metadata. "
15927 "As with many Mercurial commands, the <command role=\"hg-ext-mq\">qinit</"
15928 "command> command prints nothing if it succeeds."
15929 msgstr ""
15931 #. type: Content of: <book><chapter><sect1><sect2><title>
15932 #: ../en/ch12-mq.xml:284
15933 msgid "Creating a new patch"
15934 msgstr "创建新补丁"
15936 #. type: Content of: <book><chapter><sect1><sect2><para>
15937 #: ../en/ch12-mq.xml:286
15938 msgid ""
15939 "To begin work on a new patch, use the <command role=\"hg-ext-mq\">qnew</"
15940 "command> command. This command takes one argument, the name of the patch to "
15941 "create."
15942 msgstr ""
15944 #. type: Content of: <book><chapter><sect1><sect2><para>
15945 #: ../en/ch12-mq.xml:290
15946 msgid ""
15947 "MQ will use this as the name of an actual file in the <filename role=\"special"
15948 "\" class=\"directory\">.hg/patches</filename> directory, as you can see below."
15949 msgstr ""
15951 #. type: Content of: <book><chapter><sect1><sect2><para>
15952 #: ../en/ch12-mq.xml:297
15953 msgid ""
15954 "Also newly present in the <filename role=\"special\" class=\"directory\">.hg/"
15955 "patches</filename> directory are two other files, <filename role=\"special"
15956 "\">series</filename> and <filename role=\"special\">status</filename>. The "
15957 "<filename role=\"special\">series</filename> file lists all of the patches "
15958 "that MQ knows about for this repository, with one patch per line. Mercurial "
15959 "uses the <filename role=\"special\">status</filename> file for internal book-"
15960 "keeping; it tracks all of the patches that MQ has <emphasis>applied</"
15961 "emphasis> in this repository."
15962 msgstr ""
15964 #. type: Content of: <book><chapter><sect1><sect2><note><para>
15965 #: ../en/ch12-mq.xml:309
15966 msgid ""
15967 "You may sometimes want to edit the <filename role=\"special\">series</"
15968 "filename> file by hand; for example, to change the sequence in which some "
15969 "patches are applied. However, manually editing the <filename role=\"special"
15970 "\">status</filename> file is almost always a bad idea, as it's easy to "
15971 "corrupt MQ's idea of what is happening."
15972 msgstr ""
15974 #. type: Content of: <book><chapter><sect1><sect2><para>
15975 #: ../en/ch12-mq.xml:318
15976 msgid ""
15977 "Once you have created your new patch, you can edit files in the working "
15978 "directory as you usually would. All of the normal Mercurial commands, such "
15979 "as <command role=\"hg-cmd\">hg diff</command> and <command role=\"hg-cmd\">hg "
15980 "annotate</command>, work exactly as they did before."
15981 msgstr ""
15983 #. type: Content of: <book><chapter><sect1><sect2><title>
15984 #: ../en/ch12-mq.xml:326
15985 msgid "Refreshing a patch"
15986 msgstr "刷新补丁"
15988 #. type: Content of: <book><chapter><sect1><sect2><para>
15989 #: ../en/ch12-mq.xml:328
15990 msgid ""
15991 "When you reach a point where you want to save your work, use the <command "
15992 "role=\"hg-ext-mq\">qrefresh</command> command to update the patch you are "
15993 "working on."
15994 msgstr ""
15996 #. type: Content of: <book><chapter><sect1><sect2><para>
15997 #: ../en/ch12-mq.xml:334
15998 msgid ""
15999 "This command folds the changes you have made in the working directory into "
16000 "your patch, and updates its corresponding changeset to contain those changes."
16001 msgstr ""
16003 #. type: Content of: <book><chapter><sect1><sect2><para>
16004 #: ../en/ch12-mq.xml:338
16005 msgid ""
16006 "You can run <command role=\"hg-ext-mq\">qrefresh</command> as often as you "
16007 "like, so it's a good way to <quote>checkpoint</quote> your work. Refresh "
16008 "your patch at an opportune time; try an experiment; and if the experiment "
16009 "doesn't work out, <command role=\"hg-cmd\">hg revert</command> your "
16010 "modifications back to the last time you refreshed."
16011 msgstr ""
16013 #. type: Content of: <book><chapter><sect1><sect2><title>
16014 #: ../en/ch12-mq.xml:349
16015 msgid "Stacking and tracking patches"
16016 msgstr "堆叠和跟踪补丁"
16018 #. type: Content of: <book><chapter><sect1><sect2><para>
16019 #: ../en/ch12-mq.xml:351
16020 msgid ""
16021 "Once you have finished working on a patch, or need to work on another, you "
16022 "can use the <command role=\"hg-ext-mq\">qnew</command> command again to "
16023 "create a new patch. Mercurial will apply this patch on top of your existing "
16024 "patch."
16025 msgstr ""
16027 #. type: Content of: <book><chapter><sect1><sect2><para>
16028 #: ../en/ch12-mq.xml:359
16029 msgid ""
16030 "Notice that the patch contains the changes in our prior patch as part of its "
16031 "context (you can see this more clearly in the output of <command role=\"hg-cmd"
16032 "\">hg annotate</command>)."
16033 msgstr ""
16035 #. type: Content of: <book><chapter><sect1><sect2><para>
16036 #: ../en/ch12-mq.xml:364
16037 msgid ""
16038 "So far, with the exception of <command role=\"hg-ext-mq\">qnew</command> and "
16039 "<command role=\"hg-ext-mq\">qrefresh</command>, we've been careful to only "
16040 "use regular Mercurial commands. However, MQ provides many commands that are "
16041 "easier to use when you are thinking about patches, as illustrated below."
16042 msgstr ""
16044 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16045 #: ../en/ch12-mq.xml:374
16046 msgid ""
16047 "The <command role=\"hg-ext-mq\">qseries</command> command lists every patch "
16048 "that MQ knows about in this repository, from oldest to newest (most recently "
16049 "<emphasis>created</emphasis>)."
16050 msgstr ""
16052 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16053 #: ../en/ch12-mq.xml:380
16054 msgid ""
16055 "The <command role=\"hg-ext-mq\">qapplied</command> command lists every patch "
16056 "that MQ has <emphasis>applied</emphasis> in this repository, again from "
16057 "oldest to newest (most recently applied)."
16058 msgstr ""
16060 #. type: Content of: <book><chapter><sect1><sect2><title>
16061 #: ../en/ch12-mq.xml:389
16062 msgid "Manipulating the patch stack"
16063 msgstr "操作补丁堆栈"
16065 #. type: Content of: <book><chapter><sect1><sect2><para>
16066 #: ../en/ch12-mq.xml:391
16067 msgid ""
16068 "The previous discussion implied that there must be a difference between "
16069 "<quote>known</quote> and <quote>applied</quote> patches, and there is. MQ "
16070 "can manage a patch without it being applied in the repository."
16071 msgstr ""
16073 #. type: Content of: <book><chapter><sect1><sect2><para>
16074 #: ../en/ch12-mq.xml:396
16075 msgid ""
16076 "An <emphasis>applied</emphasis> patch has a corresponding changeset in the "
16077 "repository, and the effects of the patch and changeset are visible in the "
16078 "working directory. You can undo the application of a patch using the "
16079 "<command role=\"hg-ext-mq\">qpop</command> command. MQ still <emphasis>knows "
16080 "about</emphasis>, or manages, a popped patch, but the patch no longer has a "
16081 "corresponding changeset in the repository, and the working directory does not "
16082 "contain the changes made by the patch. <xref linkend=\"fig:mq:stack\"/> "
16083 "illustrates the difference between applied and tracked patches."
16084 msgstr ""
16086 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
16087 #: ../en/ch12-mq.xml:409
16088 msgid "Applied and unapplied patches in the MQ patch stack"
16089 msgstr "在 MQ 补丁堆栈中应用和撤销补丁"
16091 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
16092 #: ../en/ch12-mq.xml:412
16093 msgid "<imageobject><imagedata fileref=\"figs/mq-stack.png\"/></imageobject>"
16094 msgstr ""
16096 #. type: Content of: <book><chapter><sect1><sect2><para>
16097 #: ../en/ch12-mq.xml:417
16098 msgid ""
16099 "You can reapply an unapplied, or popped, patch using the <command role=\"hg-"
16100 "ext-mq\">qpush</command> command. This creates a new changeset to correspond "
16101 "to the patch, and the patch's changes once again become present in the "
16102 "working directory. See below for examples of <command role=\"hg-ext-mq"
16103 "\">qpop</command> and <command role=\"hg-ext-mq\">qpush</command> in action."
16104 msgstr ""
16106 #. type: Content of: <book><chapter><sect1><sect2><para>
16107 #: ../en/ch12-mq.xml:427
16108 msgid ""
16109 "Notice that once we have popped a patch or two patches, the output of "
16110 "<command role=\"hg-ext-mq\">qseries</command> remains the same, while that of "
16111 "<command role=\"hg-ext-mq\">qapplied</command> has changed."
16112 msgstr ""
16114 #. type: Content of: <book><chapter><sect1><sect2><title>
16115 #: ../en/ch12-mq.xml:435
16116 msgid "Pushing and popping many patches"
16117 msgstr "压入或弹出多个补丁"
16119 #. type: Content of: <book><chapter><sect1><sect2><para>
16120 #: ../en/ch12-mq.xml:437
16121 msgid ""
16122 "While <command role=\"hg-ext-mq\">qpush</command> and <command role=\"hg-ext-"
16123 "mq\">qpop</command> each operate on a single patch at a time by default, you "
16124 "can push and pop many patches in one go. The <option role=\"hg-ext-mq-cmd-"
16125 "qpush-opt\">-a</option> option to <command role=\"hg-ext-mq\">qpush</command> "
16126 "causes it to push all unapplied patches, while the <option role=\"hg-ext-mq-"
16127 "cmd-qpop-opt\">-a</option> option to <command role=\"hg-ext-mq\">qpop</"
16128 "command> causes it to pop all applied patches. (For some more ways to push "
16129 "and pop many patches, see <xref linkend=\"sec:mq:perf\"/> below.)"
16130 msgstr ""
16132 #. type: Content of: <book><chapter><sect1><sect2><title>
16133 #: ../en/ch12-mq.xml:453
16134 msgid "Safety checks, and overriding them"
16135 msgstr "安全的检查,然后覆盖它们"
16137 #. type: Content of: <book><chapter><sect1><sect2><para>
16138 #: ../en/ch12-mq.xml:455
16139 msgid ""
16140 "Several MQ commands check the working directory before they do anything, and "
16141 "fail if they find any modifications. They do this to ensure that you won't "
16142 "lose any changes that you have made, but not yet incorporated into a patch. "
16143 "The example below illustrates this; the <command role=\"hg-ext-mq\">qnew</"
16144 "command> command will not create a new patch if there are outstanding "
16145 "changes, caused in this case by the <command role=\"hg-cmd\">hg add</command> "
16146 "of <filename>file3</filename>."
16147 msgstr ""
16149 #. type: Content of: <book><chapter><sect1><sect2><para>
16150 #: ../en/ch12-mq.xml:467
16151 msgid ""
16152 "Commands that check the working directory all take an <quote>I know what I'm "
16153 "doing</quote> option, which is always named <option>-f</option>. The exact "
16154 "meaning of <option>-f</option> depends on the command. For example, <command "
16155 "role=\"hg-cmd\">hg qnew <option role=\"hg-ext-mq-cmd-qnew-opt\">-f</option></"
16156 "command> will incorporate any outstanding changes into the new patch it "
16157 "creates, but <command role=\"hg-cmd\">hg qpop <option role=\"hg-ext-mq-cmd-"
16158 "qpop-opt\">-f</option></command> will revert modifications to any files "
16159 "affected by the patch that it is popping. Be sure to read the documentation "
16160 "for a command's <option>-f</option> option before you use it!"
16161 msgstr ""
16163 #. type: Content of: <book><chapter><sect1><sect2><title>
16164 #: ../en/ch12-mq.xml:482
16165 msgid "Working on several patches at once"
16166 msgstr "同时处理多个补丁"
16168 #. type: Content of: <book><chapter><sect1><sect2><para>
16169 #: ../en/ch12-mq.xml:484
16170 msgid ""
16171 "The <command role=\"hg-ext-mq\">qrefresh</command> command always refreshes "
16172 "the <emphasis>topmost</emphasis> applied patch. This means that you can "
16173 "suspend work on one patch (by refreshing it), pop or push to make a different "
16174 "patch the top, and work on <emphasis>that</emphasis> patch for a while."
16175 msgstr ""
16177 #. type: Content of: <book><chapter><sect1><sect2><para>
16178 #: ../en/ch12-mq.xml:491
16179 msgid ""
16180 "Here's an example that illustrates how you can use this ability. Let's say "
16181 "you're developing a new feature as two patches. The first is a change to the "
16182 "core of your software, and the second&emdash;layered on top of the "
16183 "first&emdash;changes the user interface to use the code you just added to the "
16184 "core. If you notice a bug in the core while you're working on the UI patch, "
16185 "it's easy to fix the core. Simply <command role=\"hg-ext-mq\">qrefresh</"
16186 "command> the UI patch to save your in-progress changes, and <command role="
16187 "\"hg-ext-mq\">qpop</command> down to the core patch. Fix the core bug, "
16188 "<command role=\"hg-ext-mq\">qrefresh</command> the core patch, and <command "
16189 "role=\"hg-ext-mq\">qpush</command> back to the UI patch to continue where you "
16190 "left off."
16191 msgstr ""
16193 #. type: Content of: <book><chapter><sect1><title>
16194 #: ../en/ch12-mq.xml:508
16195 msgid "More about patches"
16196 msgstr "关于补丁的更多信息"
16198 #. type: Content of: <book><chapter><sect1><para>
16199 #: ../en/ch12-mq.xml:510
16200 msgid ""
16201 "MQ uses the GNU <command>patch</command> command to apply patches, so it's "
16202 "helpful to know a few more detailed aspects of how <command>patch</command> "
16203 "works, and about patches themselves."
16204 msgstr ""
16206 #. type: Content of: <book><chapter><sect1><sect2><title>
16207 #: ../en/ch12-mq.xml:516
16208 msgid "The strip count"
16209 msgstr "修剪计数"
16211 #. type: Content of: <book><chapter><sect1><sect2><para>
16212 #: ../en/ch12-mq.xml:518
16213 msgid ""
16214 "If you look at the file headers in a patch, you will notice that the "
16215 "pathnames usually have an extra component on the front that isn't present in "
16216 "the actual path name. This is a holdover from the way that people used to "
16217 "generate patches (people still do this, but it's somewhat rare with modern "
16218 "revision control tools)."
16219 msgstr ""
16221 #. type: Content of: <book><chapter><sect1><sect2><para>
16222 #: ../en/ch12-mq.xml:525
16223 msgid ""
16224 "Alice would unpack a tarball, edit her files, then decide that she wanted to "
16225 "create a patch. So she'd rename her working directory, unpack the tarball "
16226 "again (hence the need for the rename), and use the <option role=\"cmd-opt-diff"
16227 "\">-r</option> and <option role=\"cmd-opt-diff\">-N</option> options to "
16228 "<command>diff</command> to recursively generate a patch between the "
16229 "unmodified directory and the modified one. The result would be that the name "
16230 "of the unmodified directory would be at the front of the left-hand path in "
16231 "every file header, and the name of the modified directory would be at the "
16232 "front of the right-hand path."
16233 msgstr ""
16235 #. type: Content of: <book><chapter><sect1><sect2><para>
16236 #: ../en/ch12-mq.xml:538
16237 msgid ""
16238 "Since someone receiving a patch from the Alices of the net would be unlikely "
16239 "to have unmodified and modified directories with exactly the same names, the "
16240 "<command>patch</command> command has a <option role=\"cmd-opt-patch\">-p</"
16241 "option> option that indicates the number of leading path name components to "
16242 "strip when trying to apply a patch. This number is called the "
16243 "<emphasis>strip count</emphasis>."
16244 msgstr ""
16246 #. type: Content of: <book><chapter><sect1><sect2><para>
16247 #: ../en/ch12-mq.xml:546
16248 msgid ""
16249 "An option of <quote><literal>-p1</literal></quote> means <quote>use a strip "
16250 "count of one</quote>. If <command>patch</command> sees a file name "
16251 "<filename>foo/bar/baz</filename> in a file header, it will strip "
16252 "<filename>foo</filename> and try to patch a file named <filename>bar/baz</"
16253 "filename>. (Strictly speaking, the strip count refers to the number of "
16254 "<emphasis>path separators</emphasis> (and the components that go with them ) "
16255 "to strip. A strip count of one will turn <filename>foo/bar</filename> into "
16256 "<filename>bar</filename>, but <filename>/foo/bar</filename> (notice the extra "
16257 "leading slash) into <filename>foo/bar</filename>.)"
16258 msgstr ""
16260 #. type: Content of: <book><chapter><sect1><sect2><para>
16261 #: ../en/ch12-mq.xml:559
16262 msgid ""
16263 "The <quote>standard</quote> strip count for patches is one; almost all "
16264 "patches contain one leading path name component that needs to be stripped. "
16265 "Mercurial's <command role=\"hg-cmd\">hg diff</command> command generates path "
16266 "names in this form, and the <command role=\"hg-cmd\">hg import</command> "
16267 "command and MQ expect patches to have a strip count of one."
16268 msgstr ""
16270 #. type: Content of: <book><chapter><sect1><sect2><para>
16271 #: ../en/ch12-mq.xml:567
16272 msgid ""
16273 "If you receive a patch from someone that you want to add to your patch queue, "
16274 "and the patch needs a strip count other than one, you cannot just <command "
16275 "role=\"hg-ext-mq\">qimport</command> the patch, because <command role=\"hg-"
16276 "ext-mq\">qimport</command> does not yet have a <literal>-p</literal> option "
16277 "(see <ulink role=\"hg-bug\" url=\"http://www.selenic.com/mercurial/bts/"
16278 "issue311\">issue 311</ulink>). Your best bet is to <command role=\"hg-ext-mq"
16279 "\">qnew</command> a patch of your own, then use <command>patch -pN</command> "
16280 "to apply their patch, followed by <command role=\"hg-cmd\">hg addremove</"
16281 "command> to pick up any files added or removed by the patch, followed by "
16282 "<command role=\"hg-ext-mq\">hg qrefresh</command>. This complexity may become "
16283 "unnecessary; see <ulink role=\"hg-bug\" url=\"http://www.selenic.com/"
16284 "mercurial/bts/issue311\">issue 311</ulink> for details."
16285 msgstr ""
16287 #. type: Content of: <book><chapter><sect1><sect2><title>
16288 #: ../en/ch12-mq.xml:587
16289 msgid "Strategies for applying a patch"
16290 msgstr "应用补丁的策略"
16292 #. type: Content of: <book><chapter><sect1><sect2><para>
16293 #: ../en/ch12-mq.xml:589
16294 msgid ""
16295 "When <command>patch</command> applies a hunk, it tries a handful of "
16296 "successively less accurate strategies to try to make the hunk apply. This "
16297 "falling-back technique often makes it possible to take a patch that was "
16298 "generated against an old version of a file, and apply it against a newer "
16299 "version of that file."
16300 msgstr ""
16302 #. type: Content of: <book><chapter><sect1><sect2><para>
16303 #: ../en/ch12-mq.xml:596
16304 msgid ""
16305 "First, <command>patch</command> tries an exact match, where the line numbers, "
16306 "the context, and the text to be modified must apply exactly. If it cannot "
16307 "make an exact match, it tries to find an exact match for the context, without "
16308 "honouring the line numbering information. If this succeeds, it prints a line "
16309 "of output saying that the hunk was applied, but at some <emphasis>offset</"
16310 "emphasis> from the original line number."
16311 msgstr ""
16313 #. type: Content of: <book><chapter><sect1><sect2><para>
16314 #: ../en/ch12-mq.xml:605
16315 msgid ""
16316 "If a context-only match fails, <command>patch</command> removes the first and "
16317 "last lines of the context, and tries a <emphasis>reduced</emphasis> context-"
16318 "only match. If the hunk with reduced context succeeds, it prints a message "
16319 "saying that it applied the hunk with a <emphasis>fuzz factor</emphasis> (the "
16320 "number after the fuzz factor indicates how many lines of context "
16321 "<command>patch</command> had to trim before the patch applied)."
16322 msgstr ""
16324 #. type: Content of: <book><chapter><sect1><sect2><para>
16325 #: ../en/ch12-mq.xml:614
16326 msgid ""
16327 "When neither of these techniques works, <command>patch</command> prints a "
16328 "message saying that the hunk in question was rejected. It saves rejected "
16329 "hunks (also simply called <quote>rejects</quote>) to a file with the same "
16330 "name, and an added <filename role=\"special\">.rej</filename> extension. It "
16331 "also saves an unmodified copy of the file with a <filename role=\"special\">."
16332 "orig</filename> extension; the copy of the file without any extensions will "
16333 "contain any changes made by hunks that <emphasis>did</emphasis> apply "
16334 "cleanly. If you have a patch that modifies <filename>foo</filename> with six "
16335 "hunks, and one of them fails to apply, you will have: an unmodified "
16336 "<filename>foo.orig</filename>, a <filename>foo.rej</filename> containing one "
16337 "hunk, and <filename>foo</filename>, containing the changes made by the five "
16338 "successful hunks."
16339 msgstr ""
16341 #. type: Content of: <book><chapter><sect1><sect2><title>
16342 #: ../en/ch12-mq.xml:632
16343 msgid "Some quirks of patch representation"
16344 msgstr "补丁的一些特性"
16346 #. type: Content of: <book><chapter><sect1><sect2><para>
16347 #: ../en/ch12-mq.xml:634
16348 msgid ""
16349 "There are a few useful things to know about how <command>patch</command> "
16350 "works with files."
16351 msgstr ""
16353 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16354 #: ../en/ch12-mq.xml:637
16355 msgid ""
16356 "This should already be obvious, but <command>patch</command> cannot handle "
16357 "binary files."
16358 msgstr ""
16360 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16361 #: ../en/ch12-mq.xml:641
16362 msgid ""
16363 "Neither does it care about the executable bit; it creates new files as "
16364 "readable, but not executable."
16365 msgstr ""
16367 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16368 #: ../en/ch12-mq.xml:645
16369 msgid ""
16370 "<command>patch</command> treats the removal of a file as a diff between the "
16371 "file to be removed and the empty file. So your idea of <quote>I deleted this "
16372 "file</quote> looks like <quote>every line of this file was deleted</quote> in "
16373 "a patch."
16374 msgstr ""
16376 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16377 #: ../en/ch12-mq.xml:651
16378 msgid ""
16379 "It treats the addition of a file as a diff between the empty file and the "
16380 "file to be added. So in a patch, your idea of <quote>I added this file</"
16381 "quote> looks like <quote>every line of this file was added</quote>."
16382 msgstr ""
16384 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16385 #: ../en/ch12-mq.xml:657
16386 msgid ""
16387 "It treats a renamed file as the removal of the old name, and the addition of "
16388 "the new name. This means that renamed files have a big footprint in "
16389 "patches. (Note also that Mercurial does not currently try to infer when "
16390 "files have been renamed or copied in a patch.)"
16391 msgstr ""
16393 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16394 #: ../en/ch12-mq.xml:663
16395 msgid ""
16396 "<command>patch</command> cannot represent empty files, so you cannot use a "
16397 "patch to represent the notion <quote>I added this empty file to the tree</"
16398 "quote>."
16399 msgstr ""
16401 #. type: Content of: <book><chapter><sect1><sect2><title>
16402 #: ../en/ch12-mq.xml:671
16403 msgid "Beware the fuzz"
16404 msgstr "当心毛刺"
16406 #. type: Content of: <book><chapter><sect1><sect2><para>
16407 #: ../en/ch12-mq.xml:673
16408 msgid ""
16409 "While applying a hunk at an offset, or with a fuzz factor, will often be "
16410 "completely successful, these inexact techniques naturally leave open the "
16411 "possibility of corrupting the patched file. The most common cases typically "
16412 "involve applying a patch twice, or at an incorrect location in the file. If "
16413 "<command>patch</command> or <command role=\"hg-ext-mq\">qpush</command> ever "
16414 "mentions an offset or fuzz factor, you should make sure that the modified "
16415 "files are correct afterwards."
16416 msgstr ""
16418 #. type: Content of: <book><chapter><sect1><sect2><para>
16419 #: ../en/ch12-mq.xml:683
16420 msgid ""
16421 "It's often a good idea to refresh a patch that has applied with an offset or "
16422 "fuzz factor; refreshing the patch generates new context information that will "
16423 "make it apply cleanly. I say <quote>often,</quote> not <quote>always,</"
16424 "quote> because sometimes refreshing a patch will make it fail to apply "
16425 "against a different revision of the underlying files. In some cases, such as "
16426 "when you're maintaining a patch that must sit on top of multiple versions of "
16427 "a source tree, it's acceptable to have a patch apply with some fuzz, provided "
16428 "you've verified the results of the patching process in such cases."
16429 msgstr ""
16431 #. type: Content of: <book><chapter><sect1><sect2><title>
16432 #: ../en/ch12-mq.xml:696
16433 msgid "Handling rejection"
16434 msgstr "处理拒绝"
16436 #. type: Content of: <book><chapter><sect1><sect2><para>
16437 #: ../en/ch12-mq.xml:698
16438 msgid ""
16439 "If <command role=\"hg-ext-mq\">qpush</command> fails to apply a patch, it "
16440 "will print an error message and exit. If it has left <filename role=\"special"
16441 "\">.rej</filename> files behind, it is usually best to fix up the rejected "
16442 "hunks before you push more patches or do any further work."
16443 msgstr ""
16445 #. type: Content of: <book><chapter><sect1><sect2><para>
16446 #: ../en/ch12-mq.xml:704
16447 msgid ""
16448 "If your patch <emphasis>used to</emphasis> apply cleanly, and no longer does "
16449 "because you've changed the underlying code that your patches are based on, "
16450 "Mercurial Queues can help; see <xref linkend=\"sec:mq:merge\"/> for details."
16451 msgstr ""
16453 #. type: Content of: <book><chapter><sect1><sect2><para>
16454 #: ../en/ch12-mq.xml:709
16455 msgid ""
16456 "Unfortunately, there aren't any great techniques for dealing with rejected "
16457 "hunks. Most often, you'll need to view the <filename role=\"special\">.rej</"
16458 "filename> file and edit the target file, applying the rejected hunks by hand."
16459 msgstr ""
16461 #. type: Content of: <book><chapter><sect1><sect2><para>
16462 #: ../en/ch12-mq.xml:714
16463 msgid ""
16464 "A Linux kernel hacker, Chris Mason (the author of Mercurial Queues), wrote a "
16465 "tool called <command>mpatch</command> (<ulink url=\"http://oss.oracle.com/"
16466 "~mason/mpatch/\">http://oss.oracle.com/~mason/mpatch/</ulink>), which takes a "
16467 "simple approach to automating the application of hunks rejected by "
16468 "<command>patch</command>. The <command>mpatch</command> command can help "
16469 "with four common reasons that a hunk may be rejected:"
16470 msgstr ""
16472 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16473 #: ../en/ch12-mq.xml:724
16474 msgid "The context in the middle of a hunk has changed."
16475 msgstr ""
16477 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16478 #: ../en/ch12-mq.xml:727
16479 msgid "A hunk is missing some context at the beginning or end."
16480 msgstr ""
16482 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16483 #: ../en/ch12-mq.xml:730
16484 msgid ""
16485 "A large hunk might apply better&emdash;either entirely or in part&emdash;if "
16486 "it was broken up into smaller hunks."
16487 msgstr ""
16489 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16490 #: ../en/ch12-mq.xml:734
16491 msgid ""
16492 "A hunk removes lines with slightly different content than those currently "
16493 "present in the file."
16494 msgstr ""
16496 #. type: Content of: <book><chapter><sect1><sect2><para>
16497 #: ../en/ch12-mq.xml:738
16498 msgid ""
16499 "If you use <command>mpatch</command>, you should be doubly careful to check "
16500 "your results when you're done. In fact, <command>mpatch</command> enforces "
16501 "this method of double-checking the tool's output, by automatically dropping "
16502 "you into a merge program when it has done its job, so that you can verify its "
16503 "work and finish off any remaining merges."
16504 msgstr ""
16506 #. type: Content of: <book><chapter><sect1><title>
16507 #: ../en/ch12-mq.xml:749
16508 msgid "More on patch management"
16509 msgstr "补丁管理进阶"
16511 #. type: Content of: <book><chapter><sect1><para>
16512 #: ../en/ch12-mq.xml:751
16513 msgid ""
16514 "As you grow familiar with MQ, you will find yourself wanting to perform other "
16515 "kinds of patch management operations."
16516 msgstr ""
16518 #. type: Content of: <book><chapter><sect1><sect2><title>
16519 #: ../en/ch12-mq.xml:755
16520 msgid "Deleting unwanted patches"
16521 msgstr "删除不需要的补丁"
16523 #. type: Content of: <book><chapter><sect1><sect2><para>
16524 #: ../en/ch12-mq.xml:757
16525 msgid ""
16526 "If you want to get rid of a patch, use the <command role=\"hg-ext-mq\">hg "
16527 "qdelete</command> command to delete the patch file and remove its entry from "
16528 "the patch series. If you try to delete a patch that is still applied, "
16529 "<command role=\"hg-ext-mq\">hg qdelete</command> will refuse."
16530 msgstr ""
16532 #. type: Content of: <book><chapter><sect1><sect2><title>
16533 #: ../en/ch12-mq.xml:767
16534 msgid "Converting to and from permanent revisions"
16535 msgstr "与持久版本的相互转换"
16537 #. type: Content of: <book><chapter><sect1><sect2><para>
16538 #: ../en/ch12-mq.xml:769
16539 msgid ""
16540 "Once you're done working on a patch and want to turn it into a permanent "
16541 "changeset, use the <command role=\"hg-ext-mq\">hg qfinish</command> command. "
16542 "Pass a revision to the command to identify the patch that you want to turn "
16543 "into a regular changeset; this patch must already be applied."
16544 msgstr ""
16546 #. type: Content of: <book><chapter><sect1><sect2><para>
16547 #: ../en/ch12-mq.xml:777
16548 msgid ""
16549 "The <command role=\"hg-ext-mq\">hg qfinish</command> command accepts an "
16550 "<option>--all</option> or <option>-a</option> option, which turns all applied "
16551 "patches into regular changesets."
16552 msgstr ""
16554 #. type: Content of: <book><chapter><sect1><sect2><para>
16555 #: ../en/ch12-mq.xml:782
16556 msgid ""
16557 "It is also possible to turn an existing changeset into a patch, by passing "
16558 "the <option>-r</option> option to <command role=\"hg-ext-mq\">hg qimport</"
16559 "command>."
16560 msgstr ""
16562 #. type: Content of: <book><chapter><sect1><sect2><para>
16563 #: ../en/ch12-mq.xml:788
16564 msgid ""
16565 "Note that it only makes sense to convert a changeset into a patch if you have "
16566 "not propagated that changeset into any other repositories. The imported "
16567 "changeset's ID will change every time you refresh the patch, which will make "
16568 "Mercurial treat it as unrelated to the original changeset if you have pushed "
16569 "it somewhere else."
16570 msgstr ""
16572 #. type: Content of: <book><chapter><sect1><title>
16573 #: ../en/ch12-mq.xml:798
16574 msgid "Getting the best performance out of MQ"
16575 msgstr "MQ 的性能"
16577 #. type: Content of: <book><chapter><sect1><para>
16578 #: ../en/ch12-mq.xml:800
16579 msgid ""
16580 "MQ is very efficient at handling a large number of patches. I ran some "
16581 "performance experiments in mid-2006 for a talk that I gave at the 2006 "
16582 "EuroPython conference (on modern hardware, you should expect better "
16583 "performance than you'll see below). I used as my data set the Linux 2.6.17-"
16584 "mm1 patch series, which consists of 1,738 patches. I applied these on top of "
16585 "a Linux kernel repository containing all 27,472 revisions between Linux "
16586 "2.6.12-rc2 and Linux 2.6.17."
16587 msgstr ""
16589 #. type: Content of: <book><chapter><sect1><para>
16590 #: ../en/ch12-mq.xml:809
16591 msgid ""
16592 "On my old, slow laptop, I was able to <command role=\"hg-cmd\">hg qpush "
16593 "<option role=\"hg-ext-mq-cmd-qpush-opt\">-a</option></command> all 1,738 "
16594 "patches in 3.5 minutes, and <command role=\"hg-cmd\">hg qpop <option role="
16595 "\"hg-ext-mq-cmd-qpop-opt\">-a</option></command> them all in 30 seconds. (On "
16596 "a newer laptop, the time to push all patches dropped to two minutes.) I "
16597 "could <command role=\"hg-ext-mq\">qrefresh</command> one of the biggest "
16598 "patches (which made 22,779 lines of changes to 287 files) in 6.6 seconds."
16599 msgstr ""
16601 #. type: Content of: <book><chapter><sect1><para>
16602 #: ../en/ch12-mq.xml:820
16603 msgid ""
16604 "Clearly, MQ is well suited to working in large trees, but there are a few "
16605 "tricks you can use to get the best performance of it."
16606 msgstr ""
16608 #. type: Content of: <book><chapter><sect1><para>
16609 #: ../en/ch12-mq.xml:824
16610 msgid ""
16611 "First of all, try to <quote>batch</quote> operations together. Every time "
16612 "you run <command role=\"hg-ext-mq\">qpush</command> or <command role=\"hg-ext-"
16613 "mq\">qpop</command>, these commands scan the working directory once to make "
16614 "sure you haven't made some changes and then forgotten to run <command role="
16615 "\"hg-ext-mq\">qrefresh</command>. On a small tree, the time that this scan "
16616 "takes is unnoticeable. However, on a medium-sized tree (containing tens of "
16617 "thousands of files), it can take a second or more."
16618 msgstr ""
16620 #. type: Content of: <book><chapter><sect1><para>
16621 #: ../en/ch12-mq.xml:835
16622 msgid ""
16623 "The <command role=\"hg-ext-mq\">qpush</command> and <command role=\"hg-ext-mq"
16624 "\">qpop</command> commands allow you to push and pop multiple patches at a "
16625 "time. You can identify the <quote>destination patch</quote> that you want to "
16626 "end up at. When you <command role=\"hg-ext-mq\">qpush</command> with a "
16627 "destination specified, it will push patches until that patch is at the top of "
16628 "the applied stack. When you <command role=\"hg-ext-mq\">qpop</command> to a "
16629 "destination, MQ will pop patches until the destination patch is at the top."
16630 msgstr ""
16632 #. type: Content of: <book><chapter><sect1><para>
16633 #: ../en/ch12-mq.xml:845
16634 msgid ""
16635 "You can identify a destination patch using either the name of the patch, or "
16636 "by number. If you use numeric addressing, patches are counted from zero; "
16637 "this means that the first patch is zero, the second is one, and so on."
16638 msgstr ""
16640 #. type: Content of: <book><chapter><sect1><title>
16641 #: ../en/ch12-mq.xml:852
16642 msgid "Updating your patches when the underlying code changes"
16643 msgstr "当基础代码改变时,更新补丁的方法"
16645 #. type: Content of: <book><chapter><sect1><para>
16646 #: ../en/ch12-mq.xml:855
16647 msgid ""
16648 "It's common to have a stack of patches on top of an underlying repository "
16649 "that you don't modify directly. If you're working on changes to third-party "
16650 "code, or on a feature that is taking longer to develop than the rate of "
16651 "change of the code beneath, you will often need to sync up with the "
16652 "underlying code, and fix up any hunks in your patches that no longer apply. "
16653 "This is called <emphasis>rebasing</emphasis> your patch series."
16654 msgstr ""
16656 #. type: Content of: <book><chapter><sect1><para>
16657 #: ../en/ch12-mq.xml:864
16658 msgid ""
16659 "The simplest way to do this is to <command role=\"hg-cmd\">hg qpop <option "
16660 "role=\"hg-ext-mq-cmd-qpop-opt\">hg -a</option></command> your patches, then "
16661 "<command role=\"hg-cmd\">hg pull</command> changes into the underlying "
16662 "repository, and finally <command role=\"hg-cmd\">hg qpush <option role=\"hg-"
16663 "ext-mq-cmd-qpop-opt\">-a</option></command> your patches again. MQ will stop "
16664 "pushing any time it runs across a patch that fails to apply during conflicts, "
16665 "allowing you to fix your conflicts, <command role=\"hg-ext-mq\">qrefresh</"
16666 "command> the affected patch, and continue pushing until you have fixed your "
16667 "entire stack."
16668 msgstr ""
16670 #. type: Content of: <book><chapter><sect1><para>
16671 #: ../en/ch12-mq.xml:876
16672 msgid ""
16673 "This approach is easy to use and works well if you don't expect changes to "
16674 "the underlying code to affect how well your patches apply. If your patch "
16675 "stack touches code that is modified frequently or invasively in the "
16676 "underlying repository, however, fixing up rejected hunks by hand quickly "
16677 "becomes tiresome."
16678 msgstr ""
16680 #. type: Content of: <book><chapter><sect1><para>
16681 #: ../en/ch12-mq.xml:883
16682 msgid ""
16683 "It's possible to partially automate the rebasing process. If your patches "
16684 "apply cleanly against some revision of the underlying repo, MQ can use this "
16685 "information to help you to resolve conflicts between your patches and a "
16686 "different revision."
16687 msgstr ""
16689 #. type: Content of: <book><chapter><sect1><para>
16690 #: ../en/ch12-mq.xml:889
16691 msgid "The process is a little involved."
16692 msgstr ""
16694 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
16695 #: ../en/ch12-mq.xml:891
16696 msgid ""
16697 "To begin, <command role=\"hg-cmd\">hg qpush -a</command> all of your patches "
16698 "on top of the revision where you know that they apply cleanly."
16699 msgstr ""
16701 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
16702 #: ../en/ch12-mq.xml:895
16703 msgid ""
16704 "Save a backup copy of your patch directory using <command role=\"hg-cmd\">hg "
16705 "qsave <option role=\"hg-ext-mq-cmd-qsave-opt\">hg -e</option> <option role="
16706 "\"hg-ext-mq-cmd-qsave-opt\">hg -c</option></command>. This prints the name "
16707 "of the directory that it has saved the patches in. It will save the patches "
16708 "to a directory called <filename role=\"special\" class=\"directory\">.hg/"
16709 "patches.N</filename>, where <literal>N</literal> is a small integer. It also "
16710 "commits a <quote>save changeset</quote> on top of your applied patches; this "
16711 "is for internal book-keeping, and records the states of the <filename role="
16712 "\"special\">series</filename> and <filename role=\"special\">status</"
16713 "filename> files."
16714 msgstr ""
16716 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
16717 #: ../en/ch12-mq.xml:909
16718 msgid ""
16719 "Use <command role=\"hg-cmd\">hg pull</command> to bring new changes into the "
16720 "underlying repository. (Don't run <command role=\"hg-cmd\">hg pull -u</"
16721 "command>; see below for why.)"
16722 msgstr ""
16724 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
16725 #: ../en/ch12-mq.xml:914
16726 msgid ""
16727 "Update to the new tip revision, using <command role=\"hg-cmd\">hg update "
16728 "<option role=\"hg-opt-update\">-C</option></command> to override the patches "
16729 "you have pushed."
16730 msgstr ""
16732 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
16733 #: ../en/ch12-mq.xml:919
16734 msgid ""
16735 "Merge all patches using <command>hg qpush -m -a</command>. The <option role="
16736 "\"hg-ext-mq-cmd-qpush-opt\">-m</option> option to <command role=\"hg-ext-mq"
16737 "\">qpush</command> tells MQ to perform a three-way merge if the patch fails "
16738 "to apply."
16739 msgstr ""
16741 #. type: Content of: <book><chapter><sect1><para>
16742 #: ../en/ch12-mq.xml:927
16743 msgid ""
16744 "During the <command role=\"hg-cmd\">hg qpush <option role=\"hg-ext-mq-cmd-"
16745 "qpush-opt\">hg -m</option></command>, each patch in the <filename role="
16746 "\"special\">series</filename> file is applied normally. If a patch applies "
16747 "with fuzz or rejects, MQ looks at the queue you <command role=\"hg-ext-mq"
16748 "\">qsave</command>d, and performs a three-way merge with the corresponding "
16749 "changeset. This merge uses Mercurial's normal merge machinery, so it may pop "
16750 "up a GUI merge tool to help you to resolve problems."
16751 msgstr ""
16753 #. type: Content of: <book><chapter><sect1><para>
16754 #: ../en/ch12-mq.xml:937
16755 msgid ""
16756 "When you finish resolving the effects of a patch, MQ refreshes your patch "
16757 "based on the result of the merge."
16758 msgstr ""
16760 #. type: Content of: <book><chapter><sect1><para>
16761 #: ../en/ch12-mq.xml:940
16762 msgid ""
16763 "At the end of this process, your repository will have one extra head from the "
16764 "old patch queue, and a copy of the old patch queue will be in <filename role="
16765 "\"special\" class=\"directory\">.hg/patches.N</filename>. You can remove the "
16766 "extra head using <command role=\"hg-cmd\">hg qpop -a -n patches.N</command> "
16767 "or <command role=\"hg-cmd\">hg strip</command>. You can delete <filename "
16768 "role=\"special\" class=\"directory\">.hg/patches.N</filename> once you are "
16769 "sure that you no longer need it as a backup."
16770 msgstr ""
16772 #. type: Content of: <book><chapter><sect1><title>
16773 #: ../en/ch12-mq.xml:952
16774 msgid "Identifying patches"
16775 msgstr "标识补丁"
16777 #. type: Content of: <book><chapter><sect1><para>
16778 #: ../en/ch12-mq.xml:954
16779 msgid ""
16780 "MQ commands that work with patches let you refer to a patch either by using "
16781 "its name or by a number. By name is obvious enough; pass the name "
16782 "<filename>foo.patch</filename> to <command role=\"hg-ext-mq\">qpush</"
16783 "command>, for example, and it will push patches until <filename>foo.patch</"
16784 "filename> is applied."
16785 msgstr ""
16787 #. type: Content of: <book><chapter><sect1><para>
16788 #: ../en/ch12-mq.xml:961
16789 msgid ""
16790 "As a shortcut, you can refer to a patch using both a name and a numeric "
16791 "offset; <literal>foo.patch-2</literal> means <quote>two patches before "
16792 "<literal>foo.patch</literal></quote>, while <literal>bar.patch+4</literal> "
16793 "means <quote>four patches after <literal>bar.patch</literal></quote>."
16794 msgstr ""
16796 #. type: Content of: <book><chapter><sect1><para>
16797 #: ../en/ch12-mq.xml:967
16798 msgid ""
16799 "Referring to a patch by index isn't much different. The first patch printed "
16800 "in the output of <command role=\"hg-ext-mq\">qseries</command> is patch zero "
16801 "(yes, it's one of those start-at-zero counting systems); the second is patch "
16802 "one; and so on."
16803 msgstr ""
16805 #. type: Content of: <book><chapter><sect1><para>
16806 #: ../en/ch12-mq.xml:973
16807 msgid ""
16808 "MQ also makes it easy to work with patches when you are using normal "
16809 "Mercurial commands. Every command that accepts a changeset ID will also "
16810 "accept the name of an applied patch. MQ augments the tags normally in the "
16811 "repository with an eponymous one for each applied patch. In addition, the "
16812 "special tags <literal role=\"tag\">qbase</literal> and <literal role=\"tag"
16813 "\">qtip</literal> identify the <quote>bottom-most</quote> and topmost applied "
16814 "patches, respectively."
16815 msgstr ""
16817 #. type: Content of: <book><chapter><sect1><para>
16818 #: ../en/ch12-mq.xml:983
16819 msgid ""
16820 "These additions to Mercurial's normal tagging capabilities make dealing with "
16821 "patches even more of a breeze."
16822 msgstr ""
16824 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
16825 #: ../en/ch12-mq.xml:986
16826 msgid "Want to patchbomb a mailing list with your latest series of changes?"
16827 msgstr ""
16829 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
16830 #: ../en/ch12-mq.xml:989
16831 msgid ""
16832 "(Don't know what <quote>patchbombing</quote> is? See <xref linkend=\"sec:"
16833 "hgext:patchbomb\"/>.)"
16834 msgstr ""
16836 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
16837 #: ../en/ch12-mq.xml:992
16838 msgid ""
16839 "Need to see all of the patches since <literal>foo.patch</literal> that have "
16840 "touched files in a subdirectory of your tree?"
16841 msgstr ""
16843 #. type: Content of: <book><chapter><sect1><para>
16844 #: ../en/ch12-mq.xml:999
16845 msgid ""
16846 "Because MQ makes the names of patches available to the rest of Mercurial "
16847 "through its normal internal tag machinery, you don't need to type in the "
16848 "entire name of a patch when you want to identify it by name."
16849 msgstr ""
16851 #. type: Content of: <book><chapter><sect1><para>
16852 #: ../en/ch12-mq.xml:1004
16853 msgid ""
16854 "Another nice consequence of representing patch names as tags is that when you "
16855 "run the <command role=\"hg-cmd\">hg log</command> command, it will display a "
16856 "patch's name as a tag, simply as part of its normal output. This makes it "
16857 "easy to visually distinguish applied patches from underlying <quote>normal</"
16858 "quote> revisions. The following example shows a few normal Mercurial "
16859 "commands in use with applied patches."
16860 msgstr ""
16862 #. type: Content of: <book><chapter><sect1><title>
16863 #: ../en/ch12-mq.xml:1017
16864 msgid "Useful things to know about"
16865 msgstr "其它需要了解的东西"
16867 #. type: Content of: <book><chapter><sect1><para>
16868 #: ../en/ch12-mq.xml:1019
16869 msgid ""
16870 "There are a number of aspects of MQ usage that don't fit tidily into sections "
16871 "of their own, but that are good to know. Here they are, in one place."
16872 msgstr ""
16874 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
16875 #: ../en/ch12-mq.xml:1024
16876 msgid ""
16877 "Normally, when you <command role=\"hg-ext-mq\">qpop</command> a patch and "
16878 "<command role=\"hg-ext-mq\">qpush</command> it again, the changeset that "
16879 "represents the patch after the pop/push will have a <emphasis>different "
16880 "identity</emphasis> than the changeset that represented the hash beforehand. "
16881 "See <xref linkend=\"sec:mqref:cmd:qpush\"/> for information as to why this is."
16882 msgstr ""
16884 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
16885 #: ../en/ch12-mq.xml:1033
16886 msgid ""
16887 "It's not a good idea to <command role=\"hg-cmd\">hg merge</command> changes "
16888 "from another branch with a patch changeset, at least if you want to maintain "
16889 "the <quote>patchiness</quote> of that changeset and changesets below it on "
16890 "the patch stack. If you try to do this, it will appear to succeed, but MQ "
16891 "will become confused."
16892 msgstr ""
16894 #. type: Content of: <book><chapter><sect1><title>
16895 #: ../en/ch12-mq.xml:1044
16896 msgid "Managing patches in a repository"
16897 msgstr "在版本库管理补丁"
16899 #. type: Content of: <book><chapter><sect1><para>
16900 #: ../en/ch12-mq.xml:1046
16901 msgid ""
16902 "Because MQ's <filename role=\"special\" class=\"directory\">.hg/patches</"
16903 "filename> directory resides outside a Mercurial repository's working "
16904 "directory, the <quote>underlying</quote> Mercurial repository knows nothing "
16905 "about the management or presence of patches."
16906 msgstr ""
16908 #. type: Content of: <book><chapter><sect1><para>
16909 #: ../en/ch12-mq.xml:1052
16910 msgid ""
16911 "This presents the interesting possibility of managing the contents of the "
16912 "patch directory as a Mercurial repository in its own right. This can be a "
16913 "useful way to work. For example, you can work on a patch for a while, "
16914 "<command role=\"hg-ext-mq\">qrefresh</command> it, then <command role=\"hg-cmd"
16915 "\">hg commit</command> the current state of the patch. This lets you "
16916 "<quote>roll back</quote> to that version of the patch later on."
16917 msgstr ""
16919 #. type: Content of: <book><chapter><sect1><para>
16920 #: ../en/ch12-mq.xml:1061
16921 msgid ""
16922 "You can then share different versions of the same patch stack among multiple "
16923 "underlying repositories. I use this when I am developing a Linux kernel "
16924 "feature. I have a pristine copy of my kernel sources for each of several CPU "
16925 "architectures, and a cloned repository under each that contains the patches I "
16926 "am working on. When I want to test a change on a different architecture, I "
16927 "push my current patches to the patch repository associated with that kernel "
16928 "tree, pop and push all of my patches, and build and test that kernel."
16929 msgstr ""
16931 #. type: Content of: <book><chapter><sect1><para>
16932 #: ../en/ch12-mq.xml:1071
16933 msgid ""
16934 "Managing patches in a repository makes it possible for multiple developers to "
16935 "work on the same patch series without colliding with each other, all on top "
16936 "of an underlying source base that they may or may not control."
16937 msgstr ""
16939 #. type: Content of: <book><chapter><sect1><sect2><title>
16940 #: ../en/ch12-mq.xml:1077
16941 msgid "MQ support for patch repositories"
16942 msgstr "MQ 支持补丁版本库"
16944 #. type: Content of: <book><chapter><sect1><sect2><para>
16945 #: ../en/ch12-mq.xml:1079
16946 msgid ""
16947 "MQ helps you to work with the <filename role=\"special\" class=\"directory\">."
16948 "hg/patches</filename> directory as a repository; when you prepare a "
16949 "repository for working with patches using <command role=\"hg-ext-mq\">qinit</"
16950 "command>, you can pass the <option role=\"hg-ext-mq-cmd-qinit-opt\">hg -c</"
16951 "option> option to create the <filename role=\"special\" class=\"directory\">."
16952 "hg/patches</filename> directory as a Mercurial repository."
16953 msgstr ""
16955 #. type: Content of: <book><chapter><sect1><sect2><note><para>
16956 #: ../en/ch12-mq.xml:1089
16957 msgid ""
16958 "If you forget to use the <option role=\"hg-ext-mq-cmd-qinit-opt\">hg -c</"
16959 "option> option, you can simply go into the <filename role=\"special\" class="
16960 "\"directory\">.hg/patches</filename> directory at any time and run <command "
16961 "role=\"hg-cmd\">hg init</command>. Don't forget to add an entry for the "
16962 "<filename role=\"special\">status</filename> file to the <filename role="
16963 "\"special\">.hgignore</filename> file, though"
16964 msgstr ""
16966 #. type: Content of: <book><chapter><sect1><sect2><note><para>
16967 #: ../en/ch12-mq.xml:1098
16968 msgid ""
16969 "(<command role=\"hg-cmd\">hg qinit <option role=\"hg-ext-mq-cmd-qinit-opt"
16970 "\">hg -c</option></command> does this for you automatically); you "
16971 "<emphasis>really</emphasis> don't want to manage the <filename role=\"special"
16972 "\">status</filename> file."
16973 msgstr ""
16975 #. type: Content of: <book><chapter><sect1><sect2><para>
16976 #: ../en/ch12-mq.xml:1105
16977 msgid ""
16978 "As a convenience, if MQ notices that the <filename class=\"directory\">.hg/"
16979 "patches</filename> directory is a repository, it will automatically <command "
16980 "role=\"hg-cmd\">hg add</command> every patch that you create and import."
16981 msgstr ""
16983 #. type: Content of: <book><chapter><sect1><sect2><para>
16984 #: ../en/ch12-mq.xml:1110
16985 msgid ""
16986 "MQ provides a shortcut command, <command role=\"hg-ext-mq\">qcommit</"
16987 "command>, that runs <command role=\"hg-cmd\">hg commit</command> in the "
16988 "<filename role=\"special\" class=\"directory\">.hg/patches</filename> "
16989 "directory. This saves some bothersome typing."
16990 msgstr ""
16992 #. type: Content of: <book><chapter><sect1><sect2><para>
16993 #: ../en/ch12-mq.xml:1116
16994 msgid ""
16995 "Finally, as a convenience to manage the patch directory, you can define the "
16996 "alias <command>mq</command> on Unix systems. For example, on Linux systems "
16997 "using the <command>bash</command> shell, you can include the following "
16998 "snippet in your <filename role=\"home\">~/.bashrc</filename>."
16999 msgstr ""
17001 #. type: Content of: <book><chapter><sect1><sect2><para>
17002 #: ../en/ch12-mq.xml:1125
17003 msgid ""
17004 "You can then issue commands of the form <command>mq pull</command> from the "
17005 "main repository."
17006 msgstr ""
17008 #. type: Content of: <book><chapter><sect1><sect2><title>
17009 #: ../en/ch12-mq.xml:1130
17010 msgid "A few things to watch out for"
17011 msgstr "需要注意的事情"
17013 #. type: Content of: <book><chapter><sect1><sect2><para>
17014 #: ../en/ch12-mq.xml:1132
17015 msgid ""
17016 "MQ's support for working with a repository full of patches is limited in a "
17017 "few small respects."
17018 msgstr ""
17020 #. type: Content of: <book><chapter><sect1><sect2><para>
17021 #: ../en/ch12-mq.xml:1135
17022 msgid ""
17023 "MQ cannot automatically detect changes that you make to the patch directory. "
17024 "If you <command role=\"hg-cmd\">hg pull</command>, manually edit, or <command "
17025 "role=\"hg-cmd\">hg update</command> changes to patches or the <filename role="
17026 "\"special\">series</filename> file, you will have to <command role=\"hg-cmd"
17027 "\">hg qpop <option role=\"hg-ext-mq-cmd-qpop-opt\">-a</option></command> and "
17028 "then <command role=\"hg-cmd\">hg qpush <option role=\"hg-ext-mq-cmd-qpush-opt"
17029 "\">-a</option></command> in the underlying repository to see those changes "
17030 "show up there. If you forget to do this, you can confuse MQ's idea of which "
17031 "patches are applied."
17032 msgstr ""
17034 #. type: Content of: <book><chapter><sect1><title>
17035 #: ../en/ch12-mq.xml:1151
17036 msgid "Third party tools for working with patches"
17037 msgstr "操作补丁的第三方工具"
17039 #. type: Content of: <book><chapter><sect1><para>
17040 #: ../en/ch12-mq.xml:1153
17041 msgid ""
17042 "Once you've been working with patches for a while, you'll find yourself "
17043 "hungry for tools that will help you to understand and manipulate the patches "
17044 "you're dealing with."
17045 msgstr ""
17047 #. type: Content of: <book><chapter><sect1><para>
17048 #: ../en/ch12-mq.xml:1157
17049 msgid ""
17050 "The <command>diffstat</command> command <citation>web:diffstat</citation> "
17051 "generates a histogram of the modifications made to each file in a patch. It "
17052 "provides a good way to <quote>get a sense of</quote> a patch&emdash;which "
17053 "files it affects, and how much change it introduces to each file and as a "
17054 "whole. (I find that it's a good idea to use <command>diffstat</command>'s "
17055 "<option role=\"cmd-opt-diffstat\">-p</option> option as a matter of course, "
17056 "as otherwise it will try to do clever things with prefixes of file names that "
17057 "inevitably confuse at least me.)"
17058 msgstr ""
17060 #. type: Content of: <book><chapter><sect1><para>
17061 #: ../en/ch12-mq.xml:1171
17062 msgid ""
17063 "The <literal role=\"package\">patchutils</literal> package <citation>web:"
17064 "patchutils</citation> is invaluable. It provides a set of small utilities "
17065 "that follow the <quote>Unix philosophy;</quote> each does one useful thing "
17066 "with a patch. The <literal role=\"package\">patchutils</literal> command I "
17067 "use most is <command>filterdiff</command>, which extracts subsets from a "
17068 "patch file. For example, given a patch that modifies hundreds of files "
17069 "across dozens of directories, a single invocation of <command>filterdiff</"
17070 "command> can generate a smaller patch that only touches files whose names "
17071 "match a particular glob pattern. See <xref linkend=\"mq-collab:tips:interdiff"
17072 "\"/> for another example."
17073 msgstr ""
17075 #. type: Content of: <book><chapter><sect1><title>
17076 #: ../en/ch12-mq.xml:1187
17077 msgid "Good ways to work with patches"
17078 msgstr "操作补丁的好习惯"
17080 #. type: Content of: <book><chapter><sect1><para>
17081 #: ../en/ch12-mq.xml:1189
17082 msgid ""
17083 "Whether you are working on a patch series to submit to a free software or "
17084 "open source project, or a series that you intend to treat as a sequence of "
17085 "regular changesets when you're done, you can use some simple techniques to "
17086 "keep your work well organized."
17087 msgstr ""
17089 #. type: Content of: <book><chapter><sect1><para>
17090 #: ../en/ch12-mq.xml:1195
17091 msgid ""
17092 "Give your patches descriptive names. A good name for a patch might be "
17093 "<filename>rework-device-alloc.patch</filename>, because it will immediately "
17094 "give you a hint what the purpose of the patch is. Long names shouldn't be a "
17095 "problem; you won't be typing the names often, but you <emphasis>will</"
17096 "emphasis> be running commands like <command role=\"hg-ext-mq\">qapplied</"
17097 "command> and <command role=\"hg-ext-mq\">qtop</command> over and over. Good "
17098 "naming becomes especially important when you have a number of patches to work "
17099 "with, or if you are juggling a number of different tasks and your patches "
17100 "only get a fraction of your attention."
17101 msgstr ""
17103 #. type: Content of: <book><chapter><sect1><para>
17104 #: ../en/ch12-mq.xml:1207
17105 msgid ""
17106 "Be aware of what patch you're working on. Use the <command role=\"hg-ext-mq"
17107 "\">qtop</command> command and skim over the text of your patches "
17108 "frequently&emdash;for example, using <command role=\"hg-cmd\">hg tip <option "
17109 "role=\"hg-opt-tip\">-p</option></command>)&emdash;to be sure of where you "
17110 "stand. I have several times worked on and <command role=\"hg-ext-mq"
17111 "\">qrefresh</command>ed a patch other than the one I intended, and it's often "
17112 "tricky to migrate changes into the right patch after making them in the wrong "
17113 "one."
17114 msgstr ""
17116 #. type: Content of: <book><chapter><sect1><para>
17117 #: ../en/ch12-mq.xml:1217
17118 msgid ""
17119 "For this reason, it is very much worth investing a little time to learn how "
17120 "to use some of the third-party tools I described in <xref linkend=\"sec:mq:"
17121 "tools\"/>, particularly <command>diffstat</command> and <command>filterdiff</"
17122 "command>. The former will give you a quick idea of what changes your patch "
17123 "is making, while the latter makes it easy to splice hunks selectively out of "
17124 "one patch and into another."
17125 msgstr ""
17127 #. type: Content of: <book><chapter><sect1><title>
17128 #: ../en/ch12-mq.xml:1228
17129 msgid "MQ cookbook"
17130 msgstr "MQ 手册"
17132 #. type: Content of: <book><chapter><sect1><sect2><title>
17133 #: ../en/ch12-mq.xml:1231
17134 msgid "Manage <quote>trivial</quote> patches"
17135 msgstr "管理<quote>琐碎的</quote>补丁"
17137 #. type: Content of: <book><chapter><sect1><sect2><para>
17138 #: ../en/ch12-mq.xml:1233
17139 msgid ""
17140 "Because the overhead of dropping files into a new Mercurial repository is so "
17141 "low, it makes a lot of sense to manage patches this way even if you simply "
17142 "want to make a few changes to a source tarball that you downloaded."
17143 msgstr ""
17146 #. type: Content of: <book><chapter><sect1><sect2><para>
17147 #: ../en/ch12-mq.xml:1238
17148 msgid ""
17149 "Begin by downloading and unpacking the source tarball, and turning it into a "
17150 "Mercurial repository."
17151 msgstr ""
17153 #. type: Content of: <book><chapter><sect1><sect2><para>
17154 #: ../en/ch12-mq.xml:1243
17155 msgid "Continue by creating a patch stack and making your changes."
17156 msgstr ""
17158 #. type: Content of: <book><chapter><sect1><sect2><para>
17159 #: ../en/ch12-mq.xml:1248
17160 msgid ""
17161 "Let's say a few weeks or months pass, and your package author releases a new "
17162 "version. First, bring their changes into the repository."
17163 msgstr ""
17165 #. type: Content of: <book><chapter><sect1><sect2><para>
17166 #: ../en/ch12-mq.xml:1254
17167 msgid ""
17168 "The pipeline starting with <command role=\"hg-cmd\">hg locate</command> above "
17169 "deletes all files in the working directory, so that <command role=\"hg-cmd"
17170 "\">hg commit</command>'s <option role=\"hg-opt-commit\">--addremove</option> "
17171 "option can actually tell which files have really been removed in the newer "
17172 "version of the source."
17173 msgstr ""
17175 #. type: Content of: <book><chapter><sect1><sect2><para>
17176 #: ../en/ch12-mq.xml:1262
17177 msgid "Finally, you can apply your patches on top of the new tree."
17178 msgstr ""
17180 #. type: Content of: <book><chapter><sect1><sect2><title>
17181 #: ../en/ch12-mq.xml:1269
17182 msgid "Combining entire patches"
17183 msgstr "组合全部的补丁"
17185 #. type: Content of: <book><chapter><sect1><sect2><para>
17186 #: ../en/ch12-mq.xml:1271
17187 msgid ""
17188 "MQ provides a command, <command role=\"hg-ext-mq\">qfold</command> that lets "
17189 "you combine entire patches. This <quote>folds</quote> the patches you name, "
17190 "in the order you name them, into the topmost applied patch, and concatenates "
17191 "their descriptions onto the end of its description. The patches that you "
17192 "fold must be unapplied before you fold them."
17193 msgstr ""
17195 #. type: Content of: <book><chapter><sect1><sect2><para>
17196 #: ../en/ch12-mq.xml:1279
17197 msgid ""
17198 "The order in which you fold patches matters. If your topmost applied patch "
17199 "is <literal>foo</literal>, and you <command role=\"hg-ext-mq\">qfold</"
17200 "command> <literal>bar</literal> and <literal>quux</literal> into it, you will "
17201 "end up with a patch that has the same effect as if you applied first "
17202 "<literal>foo</literal>, then <literal>bar</literal>, followed by "
17203 "<literal>quux</literal>."
17204 msgstr ""
17206 #. type: Content of: <book><chapter><sect1><sect2><title>
17207 #: ../en/ch12-mq.xml:1290
17208 msgid "Merging part of one patch into another"
17209 msgstr "合并补丁的部分内容到其它补丁"
17211 #. type: Content of: <book><chapter><sect1><sect2><para>
17212 #: ../en/ch12-mq.xml:1292
17213 msgid ""
17214 "Merging <emphasis>part</emphasis> of one patch into another is more difficult "
17215 "than combining entire patches."
17216 msgstr ""
17218 #. type: Content of: <book><chapter><sect1><sect2><para>
17219 #: ../en/ch12-mq.xml:1296
17220 msgid ""
17221 "If you want to move changes to entire files, you can use <command>filterdiff</"
17222 "command>'s <option role=\"cmd-opt-filterdiff\">-i</option> and <option role="
17223 "\"cmd-opt-filterdiff\">-x</option> options to choose the modifications to "
17224 "snip out of one patch, concatenating its output onto the end of the patch you "
17225 "want to merge into. You usually won't need to modify the patch you've merged "
17226 "the changes from. Instead, MQ will report some rejected hunks when you "
17227 "<command role=\"hg-ext-mq\">qpush</command> it (from the hunks you moved into "
17228 "the other patch), and you can simply <command role=\"hg-ext-mq\">qrefresh</"
17229 "command> the patch to drop the duplicate hunks."
17230 msgstr ""
17232 #. type: Content of: <book><chapter><sect1><sect2><para>
17233 #: ../en/ch12-mq.xml:1309
17234 msgid ""
17235 "If you have a patch that has multiple hunks modifying a file, and you only "
17236 "want to move a few of those hunks, the job becomes more messy, but you can "
17237 "still partly automate it. Use <command>lsdiff -nvv</command> to print some "
17238 "metadata about the patch."
17239 msgstr ""
17241 #. type: Content of: <book><chapter><sect1><sect2><para>
17242 #: ../en/ch12-mq.xml:1317
17243 msgid "This command prints three different kinds of number:"
17244 msgstr ""
17246 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
17247 #: ../en/ch12-mq.xml:1320
17248 msgid ""
17249 "(in the first column) a <emphasis>file number</emphasis> to identify each "
17250 "file modified in the patch;"
17251 msgstr ""
17253 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
17254 #: ../en/ch12-mq.xml:1324
17255 msgid ""
17256 "(on the next line, indented) the line number within a modified file where a "
17257 "hunk starts; and"
17258 msgstr ""
17260 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
17261 #: ../en/ch12-mq.xml:1327
17262 msgid ""
17263 "(on the same line) a <emphasis>hunk number</emphasis> to identify that hunk."
17264 msgstr ""
17266 #. type: Content of: <book><chapter><sect1><sect2><para>
17267 #: ../en/ch12-mq.xml:1331
17268 msgid ""
17269 "You'll have to use some visual inspection, and reading of the patch, to "
17270 "identify the file and hunk numbers you'll want, but you can then pass them to "
17271 "to <command>filterdiff</command>'s <option role=\"cmd-opt-filterdiff\">--"
17272 "files</option> and <option role=\"cmd-opt-filterdiff\">--hunks</option> "
17273 "options, to select exactly the file and hunk you want to extract."
17274 msgstr ""
17276 #. type: Content of: <book><chapter><sect1><sect2><para>
17277 #: ../en/ch12-mq.xml:1339
17278 msgid ""
17279 "Once you have this hunk, you can concatenate it onto the end of your "
17280 "destination patch and continue with the remainder of <xref linkend=\"sec:mq:"
17281 "combine\"/>."
17282 msgstr ""
17284 #. type: Content of: <book><chapter><sect1><title>
17285 #: ../en/ch12-mq.xml:1346
17286 msgid "Differences between quilt and MQ"
17287 msgstr "MQ 与 quilt 的区别"
17289 #. type: Content of: <book><chapter><sect1><para>
17290 #: ../en/ch12-mq.xml:1348
17291 msgid ""
17292 "If you are already familiar with quilt, MQ provides a similar command set. "
17293 "There are a few differences in the way that it works."
17294 msgstr ""
17296 #. type: Content of: <book><chapter><sect1><para>
17297 #: ../en/ch12-mq.xml:1352
17298 msgid ""
17299 "You will already have noticed that most quilt commands have MQ counterparts "
17300 "that simply begin with a <quote><literal>q</literal></quote>. The exceptions "
17301 "are quilt's <literal>add</literal> and <literal>remove</literal> commands, "
17302 "the counterparts for which are the normal Mercurial <command role=\"hg-cmd"
17303 "\">hg add</command> and <command role=\"hg-cmd\">hg remove</command> "
17304 "commands. There is no MQ equivalent of the quilt <literal>edit</literal> "
17305 "command."
17306 msgstr ""
17308 #. type: Content of: <book><chapter><title>
17309 #: ../en/ch13-mq-collab.xml:5
17310 msgid "Advanced uses of Mercurial Queues"
17311 msgstr "MQ 的高级用法"
17313 #. type: Content of: <book><chapter><para>
17314 #: ../en/ch13-mq-collab.xml:7
17315 msgid ""
17316 "While it's easy to pick up straightforward uses of Mercurial Queues, use of a "
17317 "little discipline and some of MQ's less frequently used capabilities makes it "
17318 "possible to work in complicated development environments."
17319 msgstr ""
17321 #. type: Content of: <book><chapter><para>
17322 #: ../en/ch13-mq-collab.xml:12
17323 msgid ""
17324 "In this chapter, I will use as an example a technique I have used to manage "
17325 "the development of an Infiniband device driver for the Linux kernel. The "
17326 "driver in question is large (at least as drivers go), with 25,000 lines of "
17327 "code spread across 35 source files. It is maintained by a small team of "
17328 "developers."
17329 msgstr ""
17331 #. type: Content of: <book><chapter><para>
17332 #: ../en/ch13-mq-collab.xml:18
17333 msgid ""
17334 "While much of the material in this chapter is specific to Linux, the same "
17335 "principles apply to any code base for which you're not the primary owner, and "
17336 "upon which you need to do a lot of development."
17337 msgstr ""
17339 #. type: Content of: <book><chapter><sect1><title>
17340 #: ../en/ch13-mq-collab.xml:24
17341 msgid "The problem of many targets"
17342 msgstr "多个目标的问题"
17344 #. type: Content of: <book><chapter><sect1><para>
17345 #: ../en/ch13-mq-collab.xml:26
17346 msgid ""
17347 "The Linux kernel changes rapidly, and has never been internally stable; "
17348 "developers frequently make drastic changes between releases. This means that "
17349 "a version of the driver that works well with a particular released version of "
17350 "the kernel will not even <emphasis>compile</emphasis> correctly against, "
17351 "typically, any other version."
17352 msgstr ""
17354 #. type: Content of: <book><chapter><sect1><para>
17355 #: ../en/ch13-mq-collab.xml:33
17356 msgid ""
17357 "To maintain a driver, we have to keep a number of distinct versions of Linux "
17358 "in mind."
17359 msgstr ""
17361 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17362 #: ../en/ch13-mq-collab.xml:36
17363 msgid ""
17364 "One target is the main Linux kernel development tree. Maintenance of the code "
17365 "is in this case partly shared by other developers in the kernel community, "
17366 "who make <quote>drive-by</quote> modifications to the driver as they develop "
17367 "and refine kernel subsystems."
17368 msgstr ""
17370 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17371 #: ../en/ch13-mq-collab.xml:42
17372 msgid ""
17373 "We also maintain a number of <quote>backports</quote> to older versions of "
17374 "the Linux kernel, to support the needs of customers who are running older "
17375 "Linux distributions that do not incorporate our drivers. (To "
17376 "<emphasis>backport</emphasis> a piece of code is to modify it to work in an "
17377 "older version of its target environment than the version it was developed "
17378 "for.)"
17379 msgstr ""
17381 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17382 #: ../en/ch13-mq-collab.xml:50
17383 msgid ""
17384 "Finally, we make software releases on a schedule that is necessarily not "
17385 "aligned with those used by Linux distributors and kernel developers, so that "
17386 "we can deliver new features to customers without forcing them to upgrade "
17387 "their entire kernels or distributions."
17388 msgstr ""
17390 #. type: Content of: <book><chapter><sect1><sect2><title>
17391 #: ../en/ch13-mq-collab.xml:58
17392 msgid "Tempting approaches that don't work well"
17393 msgstr "工作不好的诱人方法"
17395 #. type: Content of: <book><chapter><sect1><sect2><para>
17396 #: ../en/ch13-mq-collab.xml:60
17397 msgid ""
17398 "There are two <quote>standard</quote> ways to maintain a piece of software "
17399 "that has to target many different environments."
17400 msgstr ""
17402 #. type: Content of: <book><chapter><sect1><sect2><para>
17403 #: ../en/ch13-mq-collab.xml:64
17404 msgid ""
17405 "The first is to maintain a number of branches, each intended for a single "
17406 "target. The trouble with this approach is that you must maintain iron "
17407 "discipline in the flow of changes between repositories. A new feature or bug "
17408 "fix must start life in a <quote>pristine</quote> repository, then percolate "
17409 "out to every backport repository. Backport changes are more limited in the "
17410 "branches they should propagate to; a backport change that is applied to a "
17411 "branch where it doesn't belong will probably stop the driver from compiling."
17412 msgstr ""
17414 #. type: Content of: <book><chapter><sect1><sect2><para>
17415 #: ../en/ch13-mq-collab.xml:74
17416 msgid ""
17417 "The second is to maintain a single source tree filled with conditional "
17418 "statements that turn chunks of code on or off depending on the intended "
17419 "target. Because these <quote>ifdefs</quote> are not allowed in the Linux "
17420 "kernel tree, a manual or automatic process must be followed to strip them out "
17421 "and yield a clean tree. A code base maintained in this fashion rapidly "
17422 "becomes a rat's nest of conditional blocks that are difficult to understand "
17423 "and maintain."
17424 msgstr ""
17426 #. type: Content of: <book><chapter><sect1><sect2><para>
17427 #: ../en/ch13-mq-collab.xml:83
17428 msgid ""
17429 "Neither of these approaches is well suited to a situation where you don't "
17430 "<quote>own</quote> the canonical copy of a source tree. In the case of a "
17431 "Linux driver that is distributed with the standard kernel, Linus's tree "
17432 "contains the copy of the code that will be treated by the world as "
17433 "canonical. The upstream version of <quote>my</quote> driver can be modified "
17434 "by people I don't know, without me even finding out about it until after the "
17435 "changes show up in Linus's tree."
17436 msgstr ""
17438 #. type: Content of: <book><chapter><sect1><sect2><para>
17439 #: ../en/ch13-mq-collab.xml:93
17440 msgid ""
17441 "These approaches have the added weakness of making it difficult to generate "
17442 "well-formed patches to submit upstream."
17443 msgstr ""
17445 #. type: Content of: <book><chapter><sect1><sect2><para>
17446 #: ../en/ch13-mq-collab.xml:97
17447 msgid ""
17448 "In principle, Mercurial Queues seems like a good candidate to manage a "
17449 "development scenario such as the above. While this is indeed the case, MQ "
17450 "contains a few added features that make the job more pleasant."
17451 msgstr ""
17453 #. type: Content of: <book><chapter><sect1><title>
17454 #: ../en/ch13-mq-collab.xml:105
17455 msgid "Conditionally applying patches with guards"
17456 msgstr "有条件的应用补丁"
17458 #. type: Content of: <book><chapter><sect1><para>
17459 #: ../en/ch13-mq-collab.xml:107
17460 msgid ""
17461 "Perhaps the best way to maintain sanity with so many targets is to be able to "
17462 "choose specific patches to apply for a given situation. MQ provides a "
17463 "feature called <quote>guards</quote> (which originates with quilt's "
17464 "<literal>guards</literal> command) that does just this. To start off, let's "
17465 "create a simple repository for experimenting in."
17466 msgstr ""
17468 #. type: Content of: <book><chapter><sect1><para>
17469 #: ../en/ch13-mq-collab.xml:116
17470 msgid ""
17471 "This gives us a tiny repository that contains two patches that don't have any "
17472 "dependencies on each other, because they touch different files."
17473 msgstr ""
17475 #. type: Content of: <book><chapter><sect1><para>
17476 #: ../en/ch13-mq-collab.xml:120
17477 msgid ""
17478 "The idea behind conditional application is that you can <quote>tag</quote> a "
17479 "patch with a <emphasis>guard</emphasis>, which is simply a text string of "
17480 "your choosing, then tell MQ to select specific guards to use when applying "
17481 "patches. MQ will then either apply, or skip over, a guarded patch, depending "
17482 "on the guards that you have selected."
17483 msgstr ""
17485 #. type: Content of: <book><chapter><sect1><para>
17486 #: ../en/ch13-mq-collab.xml:127
17487 msgid ""
17488 "A patch can have an arbitrary number of guards; each one is "
17489 "<emphasis>positive</emphasis> (<quote>apply this patch if this guard is "
17490 "selected</quote>) or <emphasis>negative</emphasis> (<quote>skip this patch if "
17491 "this guard is selected</quote>). A patch with no guards is always applied."
17492 msgstr ""
17494 #. type: Content of: <book><chapter><sect1><title>
17495 #: ../en/ch13-mq-collab.xml:135
17496 msgid "Controlling the guards on a patch"
17497 msgstr "控制补丁的应用条件"
17499 #. type: Content of: <book><chapter><sect1><para>
17500 #: ../en/ch13-mq-collab.xml:137
17501 msgid ""
17502 "The <command role=\"hg-ext-mq\">qguard</command> command lets you determine "
17503 "which guards should apply to a patch, or display the guards that are already "
17504 "in effect. Without any arguments, it displays the guards on the current "
17505 "topmost patch."
17506 msgstr ""
17508 #. type: Content of: <book><chapter><sect1><para>
17509 #: ../en/ch13-mq-collab.xml:144
17510 msgid ""
17511 "To set a positive guard on a patch, prefix the name of the guard with a "
17512 "<quote><literal>+</literal></quote>."
17513 msgstr ""
17515 #. type: Content of: <book><chapter><sect1><para>
17516 #: ../en/ch13-mq-collab.xml:149
17517 msgid ""
17518 "To set a negative guard on a patch, prefix the name of the guard with a "
17519 "<quote><literal>-</literal></quote>."
17520 msgstr ""
17522 #. type: Content of: <book><chapter><sect1><para>
17523 #: ../en/ch13-mq-collab.xml:155
17524 msgid ""
17525 "Notice that we prefixed the arguments to the <command>hg qguard</command> "
17526 "command with a <literal>--</literal> here, so that Mercurial would not "
17527 "interpret the text <literal>-quux</literal> as an option."
17528 msgstr ""
17530 #. type: Content of: <book><chapter><sect1><note><title>
17531 #: ../en/ch13-mq-collab.xml:161
17532 msgid "Setting vs. modifying"
17533 msgstr ""
17535 #. type: Content of: <book><chapter><sect1><note><para>
17536 #: ../en/ch13-mq-collab.xml:163
17537 msgid ""
17538 "The <command role=\"hg-ext-mq\">qguard</command> command <emphasis>sets</"
17539 "emphasis> the guards on a patch; it doesn't <emphasis>modify</emphasis> "
17540 "them. What this means is that if you run <command role=\"hg-cmd\">hg qguard "
17541 "+a +b</command> on a patch, then <command role=\"hg-cmd\">hg qguard +c</"
17542 "command> on the same patch, the <emphasis>only</emphasis> guard that will be "
17543 "set on it afterwards is <literal>+c</literal>."
17544 msgstr ""
17547 #. type: Content of: <book><chapter><sect1><para>
17548 #: ../en/ch13-mq-collab.xml:172
17549 msgid ""
17550 "Mercurial stores guards in the <filename role=\"special\">series</filename> "
17551 "file; the form in which they are stored is easy both to understand and to "
17552 "edit by hand. (In other words, you don't have to use the <command role=\"hg-"
17553 "ext-mq\">qguard</command> command if you don't want to; it's okay to simply "
17554 "edit the <filename role=\"special\">series</filename> file.)"
17555 msgstr ""
17557 #. type: Content of: <book><chapter><sect1><title>
17558 #: ../en/ch13-mq-collab.xml:184
17559 msgid "Selecting the guards to use"
17560 msgstr "选择使用的条件"
17562 #. type: Content of: <book><chapter><sect1><para>
17563 #: ../en/ch13-mq-collab.xml:186
17564 msgid ""
17565 "The <command role=\"hg-ext-mq\">qselect</command> command determines which "
17566 "guards are active at a given time. The effect of this is to determine which "
17567 "patches MQ will apply the next time you run <command role=\"hg-ext-mq"
17568 "\">qpush</command>. It has no other effect; in particular, it doesn't do "
17569 "anything to patches that are already applied."
17570 msgstr ""
17572 #. type: Content of: <book><chapter><sect1><para>
17573 #: ../en/ch13-mq-collab.xml:193
17574 msgid ""
17575 "With no arguments, the <command role=\"hg-ext-mq\">qselect</command> command "
17576 "lists the guards currently in effect, one per line of output. Each argument "
17577 "is treated as the name of a guard to apply."
17578 msgstr ""
17580 #. type: Content of: <book><chapter><sect1><para>
17581 #: ../en/ch13-mq-collab.xml:200
17582 msgid ""
17583 "In case you're interested, the currently selected guards are stored in the "
17584 "<filename role=\"special\">guards</filename> file."
17585 msgstr ""
17587 #. type: Content of: <book><chapter><sect1><para>
17588 #: ../en/ch13-mq-collab.xml:205
17589 msgid ""
17590 "We can see the effect the selected guards have when we run <command role=\"hg-"
17591 "ext-mq\">qpush</command>."
17592 msgstr ""
17594 #. type: Content of: <book><chapter><sect1><para>
17595 #: ../en/ch13-mq-collab.xml:210
17596 msgid ""
17597 "A guard cannot start with a <quote><literal>+</literal></quote> or "
17598 "<quote><literal>-</literal></quote> character. The name of a guard must not "
17599 "contain white space, but most other characters are acceptable. If you try to "
17600 "use a guard with an invalid name, MQ will complain:"
17601 msgstr ""
17603 #. type: Content of: <book><chapter><sect1><para>
17604 #: ../en/ch13-mq-collab.xml:219
17605 msgid "Changing the selected guards changes the patches that are applied."
17606 msgstr ""
17608 #. type: Content of: <book><chapter><sect1><para>
17609 #: ../en/ch13-mq-collab.xml:224
17610 msgid ""
17611 "You can see in the example below that negative guards take precedence over "
17612 "positive guards."
17613 msgstr ""
17615 #. type: Content of: <book><chapter><sect1><title>
17616 #: ../en/ch13-mq-collab.xml:231
17617 msgid "MQ's rules for applying patches"
17618 msgstr "MQ 应用补丁的规则"
17620 #. type: Content of: <book><chapter><sect1><para>
17621 #: ../en/ch13-mq-collab.xml:233
17622 msgid ""
17623 "The rules that MQ uses when deciding whether to apply a patch are as follows."
17624 msgstr ""
17626 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17627 #: ../en/ch13-mq-collab.xml:236
17628 msgid "A patch that has no guards is always applied."
17629 msgstr ""
17631 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17632 #: ../en/ch13-mq-collab.xml:239
17633 msgid ""
17634 "If the patch has any negative guard that matches any currently selected "
17635 "guard, the patch is skipped."
17636 msgstr ""
17638 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17639 #: ../en/ch13-mq-collab.xml:242
17640 msgid ""
17641 "If the patch has any positive guard that matches any currently selected "
17642 "guard, the patch is applied."
17643 msgstr ""
17645 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17646 #: ../en/ch13-mq-collab.xml:245
17647 msgid ""
17648 "If the patch has positive or negative guards, but none matches any currently "
17649 "selected guard, the patch is skipped."
17650 msgstr ""
17652 #. type: Content of: <book><chapter><sect1><title>
17653 #: ../en/ch13-mq-collab.xml:252
17654 msgid "Trimming the work environment"
17655 msgstr "修剪工作环境"
17657 #. type: Content of: <book><chapter><sect1><para>
17658 #: ../en/ch13-mq-collab.xml:254
17659 msgid ""
17660 "In working on the device driver I mentioned earlier, I don't apply the "
17661 "patches to a normal Linux kernel tree. Instead, I use a repository that "
17662 "contains only a snapshot of the source files and headers that are relevant to "
17663 "Infiniband development. This repository is 1% the size of a kernel "
17664 "repository, so it's easier to work with."
17665 msgstr ""
17667 #. type: Content of: <book><chapter><sect1><para>
17668 #: ../en/ch13-mq-collab.xml:261
17669 msgid ""
17670 "I then choose a <quote>base</quote> version on top of which the patches are "
17671 "applied. This is a snapshot of the Linux kernel tree as of a revision of my "
17672 "choosing. When I take the snapshot, I record the changeset ID from the "
17673 "kernel repository in the commit message. Since the snapshot preserves the "
17674 "<quote>shape</quote> and content of the relevant parts of the kernel tree, I "
17675 "can apply my patches on top of either my tiny repository or a normal kernel "
17676 "tree."
17677 msgstr ""
17679 #. type: Content of: <book><chapter><sect1><para>
17680 #: ../en/ch13-mq-collab.xml:270
17681 msgid ""
17682 "Normally, the base tree atop which the patches apply should be a snapshot of "
17683 "a very recent upstream tree. This best facilitates the development of "
17684 "patches that can easily be submitted upstream with few or no modifications."
17685 msgstr ""
17687 #. type: Content of: <book><chapter><sect1><title>
17688 #: ../en/ch13-mq-collab.xml:277
17689 msgid "Dividing up the <filename role=\"special\">series</filename> file"
17690 msgstr "分类补丁<filename role=\"special\">系列</filename>"
17692 #. type: Content of: <book><chapter><sect1><para>
17693 #: ../en/ch13-mq-collab.xml:280
17694 msgid ""
17695 "I categorise the patches in the <filename role=\"special\">series</filename> "
17696 "file into a number of logical groups. Each section of like patches begins "
17697 "with a block of comments that describes the purpose of the patches that "
17698 "follow."
17699 msgstr ""
17701 #. type: Content of: <book><chapter><sect1><para>
17702 #: ../en/ch13-mq-collab.xml:286
17703 msgid ""
17704 "The sequence of patch groups that I maintain follows. The ordering of these "
17705 "groups is important; I'll describe why after I introduce the groups."
17706 msgstr ""
17708 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17709 #: ../en/ch13-mq-collab.xml:290
17710 msgid ""
17711 "The <quote>accepted</quote> group. Patches that the development team has "
17712 "submitted to the maintainer of the Infiniband subsystem, and which he has "
17713 "accepted, but which are not present in the snapshot that the tiny repository "
17714 "is based on. These are <quote>read only</quote> patches, present only to "
17715 "transform the tree into a similar state as it is in the upstream maintainer's "
17716 "repository."
17717 msgstr ""
17719 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17720 #: ../en/ch13-mq-collab.xml:298
17721 msgid ""
17722 "The <quote>rework</quote> group. Patches that I have submitted, but that the "
17723 "upstream maintainer has requested modifications to before he will accept them."
17724 msgstr ""
17726 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17727 #: ../en/ch13-mq-collab.xml:303
17728 msgid ""
17729 "The <quote>pending</quote> group. Patches that I have not yet submitted to "
17730 "the upstream maintainer, but which we have finished working on. These will be "
17731 "<quote>read only</quote> for a while. If the upstream maintainer accepts "
17732 "them upon submission, I'll move them to the end of the <quote>accepted</"
17733 "quote> group. If he requests that I modify any, I'll move them to the "
17734 "beginning of the <quote>rework</quote> group."
17735 msgstr ""
17737 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17738 #: ../en/ch13-mq-collab.xml:312
17739 msgid ""
17740 "The <quote>in progress</quote> group. Patches that are actively being "
17741 "developed, and should not be submitted anywhere yet."
17742 msgstr ""
17744 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17745 #: ../en/ch13-mq-collab.xml:316
17746 msgid ""
17747 "The <quote>backport</quote> group. Patches that adapt the source tree to "
17748 "older versions of the kernel tree."
17749 msgstr ""
17751 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17752 #: ../en/ch13-mq-collab.xml:320
17753 msgid ""
17754 "The <quote>do not ship</quote> group. Patches that for some reason should "
17755 "never be submitted upstream. For example, one such patch might change "
17756 "embedded driver identification strings to make it easier to distinguish, in "
17757 "the field, between an out-of-tree version of the driver and a version shipped "
17758 "by a distribution vendor."
17759 msgstr ""
17761 #. type: Content of: <book><chapter><sect1><para>
17762 #: ../en/ch13-mq-collab.xml:328
17763 msgid ""
17764 "Now to return to the reasons for ordering groups of patches in this way. We "
17765 "would like the lowest patches in the stack to be as stable as possible, so "
17766 "that we will not need to rework higher patches due to changes in context. "
17767 "Putting patches that will never be changed first in the <filename role="
17768 "\"special\">series</filename> file serves this purpose."
17769 msgstr ""
17771 #. type: Content of: <book><chapter><sect1><para>
17772 #: ../en/ch13-mq-collab.xml:336
17773 msgid ""
17774 "We would also like the patches that we know we'll need to modify to be "
17775 "applied on top of a source tree that resembles the upstream tree as closely "
17776 "as possible. This is why we keep accepted patches around for a while."
17777 msgstr ""
17779 #. type: Content of: <book><chapter><sect1><para>
17780 #: ../en/ch13-mq-collab.xml:341
17781 msgid ""
17782 "The <quote>backport</quote> and <quote>do not ship</quote> patches float at "
17783 "the end of the <filename role=\"special\">series</filename> file. The "
17784 "backport patches must be applied on top of all other patches, and the "
17785 "<quote>do not ship</quote> patches might as well stay out of harm's way."
17786 msgstr ""
17788 #. type: Content of: <book><chapter><sect1><title>
17789 #: ../en/ch13-mq-collab.xml:350
17790 msgid "Maintaining the patch series"
17791 msgstr "维护补丁系列"
17793 #. type: Content of: <book><chapter><sect1><para>
17794 #: ../en/ch13-mq-collab.xml:352
17795 msgid ""
17796 "In my work, I use a number of guards to control which patches are to be "
17797 "applied."
17798 msgstr ""
17800 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17801 #: ../en/ch13-mq-collab.xml:356
17802 msgid ""
17803 "<quote>Accepted</quote> patches are guarded with <literal>accepted</"
17804 "literal>. I enable this guard most of the time. When I'm applying the "
17805 "patches on top of a tree where the patches are already present, I can turn "
17806 "this patch off, and the patches that follow it will apply cleanly."
17807 msgstr ""
17809 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17810 #: ../en/ch13-mq-collab.xml:363
17811 msgid ""
17812 "Patches that are <quote>finished</quote>, but not yet submitted, have no "
17813 "guards. If I'm applying the patch stack to a copy of the upstream tree, I "
17814 "don't need to enable any guards in order to get a reasonably safe source tree."
17815 msgstr ""
17817 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17818 #: ../en/ch13-mq-collab.xml:369
17819 msgid ""
17820 "Those patches that need reworking before being resubmitted are guarded with "
17821 "<literal>rework</literal>."
17822 msgstr ""
17824 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17825 #: ../en/ch13-mq-collab.xml:373
17826 msgid ""
17827 "For those patches that are still under development, I use <literal>devel</"
17828 "literal>."
17829 msgstr ""
17831 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17832 #: ../en/ch13-mq-collab.xml:376
17833 msgid ""
17834 "A backport patch may have several guards, one for each version of the kernel "
17835 "to which it applies. For example, a patch that backports a piece of code to "
17836 "2.6.9 will have a <literal>2.6.9</literal> guard."
17837 msgstr ""
17839 #. type: Content of: <book><chapter><sect1><para>
17840 #: ../en/ch13-mq-collab.xml:381
17841 msgid ""
17842 "This variety of guards gives me considerable flexibility in determining what "
17843 "kind of source tree I want to end up with. For most situations, the "
17844 "selection of appropriate guards is automated during the build process, but I "
17845 "can manually tune the guards to use for less common circumstances."
17846 msgstr ""
17848 #. type: Content of: <book><chapter><sect1><sect2><title>
17849 #: ../en/ch13-mq-collab.xml:388
17850 msgid "The art of writing backport patches"
17851 msgstr "编写向后移植补丁的艺术"
17853 #. type: Content of: <book><chapter><sect1><sect2><para>
17854 #: ../en/ch13-mq-collab.xml:390
17855 msgid ""
17856 "Using MQ, writing a backport patch is a simple process. All such a patch has "
17857 "to do is modify a piece of code that uses a kernel feature not present in the "
17858 "older version of the kernel, so that the driver continues to work correctly "
17859 "under that older version."
17860 msgstr ""
17862 #. type: Content of: <book><chapter><sect1><sect2><para>
17863 #: ../en/ch13-mq-collab.xml:396
17864 msgid ""
17865 "A useful goal when writing a good backport patch is to make your code look as "
17866 "if it was written for the older version of the kernel you're targeting. The "
17867 "less obtrusive the patch, the easier it will be to understand and maintain. "
17868 "If you're writing a collection of backport patches to avoid the <quote>rat's "
17869 "nest</quote> effect of lots of <literal>#ifdef</literal>s (hunks of source "
17870 "code that are only used conditionally) in your code, don't introduce version-"
17871 "dependent <literal>#ifdef</literal>s into the patches. Instead, write "
17872 "several patches, each of which makes unconditional changes, and control their "
17873 "application using guards."
17874 msgstr ""
17876 #. type: Content of: <book><chapter><sect1><sect2><para>
17877 #: ../en/ch13-mq-collab.xml:409
17878 msgid ""
17879 "There are two reasons to divide backport patches into a distinct group, away "
17880 "from the <quote>regular</quote> patches whose effects they modify. The first "
17881 "is that intermingling the two makes it more difficult to use a tool like the "
17882 "<literal role=\"hg-ext\">patchbomb</literal> extension to automate the "
17883 "process of submitting the patches to an upstream maintainer. The second is "
17884 "that a backport patch could perturb the context in which a subsequent regular "
17885 "patch is applied, making it impossible to apply the regular patch cleanly "
17886 "<emphasis>without</emphasis> the earlier backport patch already being applied."
17887 msgstr ""
17889 #. type: Content of: <book><chapter><sect1><title>
17890 #: ../en/ch13-mq-collab.xml:424
17891 msgid "Useful tips for developing with MQ"
17892 msgstr "使用 MQ 开发的技巧"
17894 #. type: Content of: <book><chapter><sect1><sect2><title>
17895 #: ../en/ch13-mq-collab.xml:427
17896 msgid "Organising patches in directories"
17897 msgstr "将补丁放到几个目录中"
17899 #. type: Content of: <book><chapter><sect1><sect2><para>
17900 #: ../en/ch13-mq-collab.xml:429
17901 msgid ""
17902 "If you're working on a substantial project with MQ, it's not difficult to "
17903 "accumulate a large number of patches. For example, I have one patch "
17904 "repository that contains over 250 patches."
17905 msgstr ""
17907 #. type: Content of: <book><chapter><sect1><sect2><para>
17908 #: ../en/ch13-mq-collab.xml:434
17909 msgid ""
17910 "If you can group these patches into separate logical categories, you can if "
17911 "you like store them in different directories; MQ has no problems with patch "
17912 "names that contain path separators."
17913 msgstr ""
17915 #. type: Content of: <book><chapter><sect1><sect2><title>
17916 #: ../en/ch13-mq-collab.xml:441
17917 msgid "Viewing the history of a patch"
17918 msgstr "察看补丁的历史"
17920 #. type: Content of: <book><chapter><sect1><sect2><para>
17921 #: ../en/ch13-mq-collab.xml:443
17922 msgid ""
17923 "If you're developing a set of patches over a long time, it's a good idea to "
17924 "maintain them in a repository, as discussed in <xref linkend=\"sec:mq:repo\"/"
17925 ">. If you do so, you'll quickly discover that using the <command role=\"hg-"
17926 "cmd\">hg diff</command> command to look at the history of changes to a patch "
17927 "is unworkable. This is in part because you're looking at the second "
17928 "derivative of the real code (a diff of a diff), but also because MQ adds "
17929 "noise to the process by modifying time stamps and directory names when it "
17930 "updates a patch."
17931 msgstr ""
17933 #. type: Content of: <book><chapter><sect1><sect2><para>
17934 #: ../en/ch13-mq-collab.xml:455
17935 msgid ""
17936 "However, you can use the <literal role=\"hg-ext\">extdiff</literal> "
17937 "extension, which is bundled with Mercurial, to turn a diff of two versions of "
17938 "a patch into something readable. To do this, you will need a third-party "
17939 "package called <literal role=\"package\">patchutils</literal> <citation>web:"
17940 "patchutils</citation>. This provides a command named <command>interdiff</"
17941 "command>, which shows the differences between two diffs as a diff. Used on "
17942 "two versions of the same diff, it generates a diff that represents the diff "
17943 "from the first to the second version."
17944 msgstr ""
17946 #. type: Content of: <book><chapter><sect1><sect2><para>
17947 #: ../en/ch13-mq-collab.xml:466
17948 msgid ""
17949 "You can enable the <literal role=\"hg-ext\">extdiff</literal> extension in "
17950 "the usual way, by adding a line to the <literal role=\"rc-extensions"
17951 "\">extensions</literal> section of your <filename role=\"special\">~/.hgrc</"
17952 "filename>."
17953 msgstr ""
17956 #. &example.hg-interdiff;
17957 #. type: Content of: <book><chapter><sect1><sect2><para>
17958 #: ../en/ch13-mq-collab.xml:473
17959 msgid ""
17960 "The <command>interdiff</command> command expects to be passed the names of "
17961 "two files, but the <literal role=\"hg-ext\">extdiff</literal> extension "
17962 "passes the program it runs a pair of directories, each of which can contain "
17963 "an arbitrary number of files. We thus need a small program that will run "
17964 "<command>interdiff</command> on each pair of files in these two directories. "
17965 "This program is available as <filename role=\"special\">hg-interdiff</"
17966 "filename> in the <filename class=\"directory\">examples</filename> directory "
17967 "of the source code repository that accompanies this book."
17968 msgstr ""
17970 #. type: Content of: <book><chapter><sect1><sect2><para>
17971 #: ../en/ch13-mq-collab.xml:485
17972 msgid ""
17973 "With the <filename role=\"special\">hg-interdiff</filename> program in your "
17974 "shell's search path, you can run it as follows, from inside an MQ patch "
17975 "directory:"
17976 msgstr ""
17978 #. type: Content of: <book><chapter><sect1><sect2><para>
17979 #: ../en/ch13-mq-collab.xml:489
17980 msgid ""
17981 "Since you'll probably want to use this long-winded command a lot, you can get "
17982 "<literal role=\"hg-ext\">hgext</literal> to make it available as a normal "
17983 "Mercurial command, again by editing your <filename role=\"special\">~/.hgrc</"
17984 "filename>."
17985 msgstr ""
17987 #. type: Content of: <book><chapter><sect1><sect2><para>
17988 #: ../en/ch13-mq-collab.xml:496
17989 msgid ""
17990 "This directs <literal role=\"hg-ext\">hgext</literal> to make an "
17991 "<literal>interdiff</literal> command available, so you can now shorten the "
17992 "previous invocation of <command role=\"hg-ext-extdiff\">extdiff</command> to "
17993 "something a little more wieldy."
17994 msgstr ""
17996 #. type: Content of: <book><chapter><sect1><sect2><note><para>
17997 #: ../en/ch13-mq-collab.xml:504
17998 msgid ""
17999 "The <command>interdiff</command> command works well only if the underlying "
18000 "files against which versions of a patch are generated remain the same. If "
18001 "you create a patch, modify the underlying files, and then regenerate the "
18002 "patch, <command>interdiff</command> may not produce useful output."
18003 msgstr ""
18005 #. type: Content of: <book><chapter><sect1><sect2><para>
18006 #: ../en/ch13-mq-collab.xml:512
18007 msgid ""
18008 "The <literal role=\"hg-ext\">extdiff</literal> extension is useful for more "
18009 "than merely improving the presentation of MQ patches. To read more about it, "
18010 "go to <xref linkend=\"sec:hgext:extdiff\"/>."
18011 msgstr ""
18013 #. type: Content of: <book><chapter><title>
18014 #: ../en/ch14-hgext.xml:5
18015 msgid "Adding functionality with extensions"
18016 msgstr "使用扩展增加功能"
18018 #. type: Content of: <book><chapter><para>
18019 #: ../en/ch14-hgext.xml:7
18020 msgid ""
18021 "While the core of Mercurial is quite complete from a functionality "
18022 "standpoint, it's deliberately shorn of fancy features. This approach of "
18023 "preserving simplicity keeps the software easy to deal with for both "
18024 "maintainers and users."
18025 msgstr ""
18027 #. type: Content of: <book><chapter><para>
18028 #: ../en/ch14-hgext.xml:12
18029 msgid ""
18030 "However, Mercurial doesn't box you in with an inflexible command set: you can "
18031 "add features to it as <emphasis>extensions</emphasis> (sometimes known as "
18032 "<emphasis>plugins</emphasis>). We've already discussed a few of these "
18033 "extensions in earlier chapters."
18034 msgstr ""
18036 #. type: Content of: <book><chapter><itemizedlist><listitem><para>
18037 #: ../en/ch14-hgext.xml:18
18038 msgid ""
18039 "<xref linkend=\"sec:tour-merge:fetch\"/> covers the <literal role=\"hg-ext"
18040 "\">fetch</literal> extension; this combines pulling new changes and merging "
18041 "them with local changes into a single command, <command role=\"hg-ext-fetch"
18042 "\">fetch</command>."
18043 msgstr ""
18045 #. type: Content of: <book><chapter><itemizedlist><listitem><para>
18046 #: ../en/ch14-hgext.xml:24
18047 msgid ""
18048 "In <xref linkend=\"chap:hook\"/>, we covered several extensions that are "
18049 "useful for hook-related functionality: <literal role=\"hg-ext\">acl</literal> "
18050 "adds access control lists; <literal role=\"hg-ext\">bugzilla</literal> adds "
18051 "integration with the Bugzilla bug tracking system; and <literal role=\"hg-ext"
18052 "\">notify</literal> sends notification emails on new changes."
18053 msgstr ""
18055 #. type: Content of: <book><chapter><itemizedlist><listitem><para>
18056 #: ../en/ch14-hgext.xml:33
18057 msgid ""
18058 "The Mercurial Queues patch management extension is so invaluable that it "
18059 "merits two chapters and an appendix all to itself. <xref linkend=\"chap:mq\"/"
18060 "> covers the basics; <xref linkend=\"chap:mq-collab\"/> discusses advanced "
18061 "topics; and <xref linkend=\"chap:mqref\"/> goes into detail on each command."
18062 msgstr ""
18064 #. type: Content of: <book><chapter><para>
18065 #: ../en/ch14-hgext.xml:43
18066 msgid ""
18067 "In this chapter, we'll cover some of the other extensions that are available "
18068 "for Mercurial, and briefly touch on some of the machinery you'll need to know "
18069 "about if you want to write an extension of your own."
18070 msgstr ""
18072 #. type: Content of: <book><chapter><itemizedlist><listitem><para>
18073 #: ../en/ch14-hgext.xml:48
18074 msgid ""
18075 "In <xref linkend=\"sec:hgext:inotify\"/>, we'll discuss the possibility of "
18076 "<emphasis>huge</emphasis> performance improvements using the <literal role="
18077 "\"hg-ext\">inotify</literal> extension."
18078 msgstr ""
18080 #. type: Content of: <book><chapter><sect1><title>
18081 #: ../en/ch14-hgext.xml:55
18082 msgid ""
18083 "Improve performance with the <literal role=\"hg-ext\">inotify</literal> "
18084 "extension"
18085 msgstr "使用扩展 <literal role=\"hg-ext\">inotify</literal> 以提高性能"
18087 #. type: Content of: <book><chapter><sect1><para>
18088 #: ../en/ch14-hgext.xml:58
18089 msgid ""
18090 "Are you interested in having some of the most common Mercurial operations run "
18091 "as much as a hundred times faster? Read on!"
18092 msgstr ""
18094 #. type: Content of: <book><chapter><sect1><para>
18095 #: ../en/ch14-hgext.xml:62
18096 msgid ""
18097 "Mercurial has great performance under normal circumstances. For example, "
18098 "when you run the <command role=\"hg-cmd\">hg status</command> command, "
18099 "Mercurial has to scan almost every directory and file in your repository so "
18100 "that it can display file status. Many other Mercurial commands need to do "
18101 "the same work behind the scenes; for example, the <command role=\"hg-cmd\">hg "
18102 "diff</command> command uses the status machinery to avoid doing an expensive "
18103 "comparison operation on files that obviously haven't changed."
18104 msgstr ""
18106 #. type: Content of: <book><chapter><sect1><para>
18107 #: ../en/ch14-hgext.xml:72
18108 msgid ""
18109 "Because obtaining file status is crucial to good performance, the authors of "
18110 "Mercurial have optimised this code to within an inch of its life. However, "
18111 "there's no avoiding the fact that when you run <command role=\"hg-cmd\">hg "
18112 "status</command>, Mercurial is going to have to perform at least one "
18113 "expensive system call for each managed file to determine whether it's changed "
18114 "since the last time Mercurial checked. For a sufficiently large repository, "
18115 "this can take a long time."
18116 msgstr ""
18118 #. type: Content of: <book><chapter><sect1><para>
18119 #: ../en/ch14-hgext.xml:82
18120 msgid ""
18121 "To put a number on the magnitude of this effect, I created a repository "
18122 "containing 150,000 managed files. I timed <command role=\"hg-cmd\">hg "
18123 "status</command> as taking ten seconds to run, even when <emphasis>none</"
18124 "emphasis> of those files had been modified."
18125 msgstr ""
18127 #. type: Content of: <book><chapter><sect1><para>
18128 #: ../en/ch14-hgext.xml:88
18129 msgid ""
18130 "Many modern operating systems contain a file notification facility. If a "
18131 "program signs up to an appropriate service, the operating system will notify "
18132 "it every time a file of interest is created, modified, or deleted. On Linux "
18133 "systems, the kernel component that does this is called <literal>inotify</"
18134 "literal>."
18135 msgstr ""
18137 #. type: Content of: <book><chapter><sect1><para>
18138 #: ../en/ch14-hgext.xml:95
18139 msgid ""
18140 "Mercurial's <literal role=\"hg-ext\">inotify</literal> extension talks to the "
18141 "kernel's <literal>inotify</literal> component to optimise <command role=\"hg-"
18142 "cmd\">hg status</command> commands. The extension has two components. A "
18143 "daemon sits in the background and receives notifications from the "
18144 "<literal>inotify</literal> subsystem. It also listens for connections from a "
18145 "regular Mercurial command. The extension modifies Mercurial's behavior so "
18146 "that instead of scanning the filesystem, it queries the daemon. Since the "
18147 "daemon has perfect information about the state of the repository, it can "
18148 "respond with a result instantaneously, avoiding the need to scan every "
18149 "directory and file in the repository."
18150 msgstr ""
18152 #. type: Content of: <book><chapter><sect1><para>
18153 #: ../en/ch14-hgext.xml:108
18154 msgid ""
18155 "Recall the ten seconds that I measured plain Mercurial as taking to run "
18156 "<command role=\"hg-cmd\">hg status</command> on a 150,000 file repository. "
18157 "With the <literal role=\"hg-ext\">inotify</literal> extension enabled, the "
18158 "time dropped to 0.1 seconds, a factor of <emphasis>one hundred</emphasis> "
18159 "faster."
18160 msgstr ""
18162 #. type: Content of: <book><chapter><sect1><para>
18163 #: ../en/ch14-hgext.xml:115
18164 msgid "Before we continue, please pay attention to some caveats."
18165 msgstr ""
18167 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
18168 #: ../en/ch14-hgext.xml:118
18169 msgid ""
18170 "The <literal role=\"hg-ext\">inotify</literal> extension is Linux-specific. "
18171 "Because it interfaces directly to the Linux kernel's <literal>inotify</"
18172 "literal> subsystem, it does not work on other operating systems."
18173 msgstr ""
18175 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
18176 #: ../en/ch14-hgext.xml:123
18177 msgid ""
18178 "It should work on any Linux distribution that was released after early 2005. "
18179 "Older distributions are likely to have a kernel that lacks <literal>inotify</"
18180 "literal>, or a version of <literal>glibc</literal> that does not have the "
18181 "necessary interfacing support."
18182 msgstr ""
18184 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
18185 #: ../en/ch14-hgext.xml:130
18186 msgid ""
18187 "Not all filesystems are suitable for use with the <literal role=\"hg-ext"
18188 "\">inotify</literal> extension. Network filesystems such as NFS are a non-"
18189 "starter, for example, particularly if you're running Mercurial on several "
18190 "systems, all mounting the same network filesystem. The kernel's "
18191 "<literal>inotify</literal> system has no way of knowing about changes made on "
18192 "another system. Most local filesystems (e.g. ext3, XFS, ReiserFS) should "
18193 "work fine."
18194 msgstr ""
18196 #. type: Content of: <book><chapter><sect1><para>
18197 #: ../en/ch14-hgext.xml:141
18198 msgid ""
18199 "The <literal role=\"hg-ext\">inotify</literal> extension is not yet shipped "
18200 "with Mercurial as of May 2007, so it's a little more involved to set up than "
18201 "other extensions. But the performance improvement is worth it!"
18202 msgstr ""
18204 #. type: Content of: <book><chapter><sect1><para>
18205 #: ../en/ch14-hgext.xml:146
18206 msgid ""
18207 "The extension currently comes in two parts: a set of patches to the Mercurial "
18208 "source code, and a library of Python bindings to the <literal>inotify</"
18209 "literal> subsystem."
18210 msgstr ""
18212 #. type: Content of: <book><chapter><sect1><note><para>
18213 #: ../en/ch14-hgext.xml:150
18214 msgid ""
18215 "There are <emphasis>two</emphasis> Python <literal>inotify</literal> binding "
18216 "libraries. One of them is called <literal>pyinotify</literal>, and is "
18217 "packaged by some Linux distributions as <literal>python-inotify</literal>. "
18218 "This is <emphasis>not</emphasis> the one you'll need, as it is too buggy and "
18219 "inefficient to be practical."
18220 msgstr ""
18222 #. type: Content of: <book><chapter><sect1><para>
18223 #: ../en/ch14-hgext.xml:157
18224 msgid ""
18225 "To get going, it's best to already have a functioning copy of Mercurial "
18226 "installed."
18227 msgstr ""
18229 #. type: Content of: <book><chapter><sect1><note><para>
18230 #: ../en/ch14-hgext.xml:160
18231 msgid ""
18232 "If you follow the instructions below, you'll be <emphasis>replacing</"
18233 "emphasis> and overwriting any existing installation of Mercurial that you "
18234 "might already have, using the latest <quote>bleeding edge</quote> Mercurial "
18235 "code. Don't say you weren't warned!"
18236 msgstr ""
18238 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
18239 #: ../en/ch14-hgext.xml:167
18240 msgid ""
18241 "Clone the Python <literal>inotify</literal> binding repository. Build and "
18242 "install it."
18243 msgstr ""
18245 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
18246 #: ../en/ch14-hgext.xml:174
18247 msgid ""
18248 "Clone the <filename class=\"directory\">crew</filename> Mercurial "
18249 "repository. Clone the <literal role=\"hg-ext\">inotify</literal> patch "
18250 "repository so that Mercurial Queues will be able to apply patches to your "
18251 "cope of the <filename class=\"directory\">crew</filename> repository."
18252 msgstr ""
18254 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
18255 #: ../en/ch14-hgext.xml:184
18256 msgid ""
18257 "Make sure that you have the Mercurial Queues extension, <literal role=\"hg-ext"
18258 "\">mq</literal>, enabled. If you've never used MQ, read <xref linkend=\"sec:"
18259 "mq:start\"/> to get started quickly."
18260 msgstr ""
18262 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
18263 #: ../en/ch14-hgext.xml:190
18264 msgid ""
18265 "Go into the <filename class=\"directory\">inotify</filename> repo, and apply "
18266 "all of the <literal role=\"hg-ext\">inotify</literal> patches using the "
18267 "<option role=\"hg-ext-mq-cmd-qpush-opt\">hg -a</option> option to the "
18268 "<command role=\"hg-ext-mq\">qpush</command> command."
18269 msgstr ""
18271 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
18272 #: ../en/ch14-hgext.xml:199
18273 msgid ""
18274 "If you get an error message from <command role=\"hg-ext-mq\">qpush</command>, "
18275 "you should not continue. Instead, ask for help."
18276 msgstr ""
18278 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
18279 #: ../en/ch14-hgext.xml:203
18280 msgid "Build and install the patched version of Mercurial."
18281 msgstr ""
18283 #. type: Content of: <book><chapter><sect1><para>
18284 #: ../en/ch14-hgext.xml:209
18285 msgid ""
18286 "Once you've build a suitably patched version of Mercurial, all you need to do "
18287 "to enable the <literal role=\"hg-ext\">inotify</literal> extension is add an "
18288 "entry to your <filename role=\"special\">~/.hgrc</filename>."
18289 msgstr ""
18291 #. type: Content of: <book><chapter><sect1><para>
18292 #: ../en/ch14-hgext.xml:214
18293 msgid ""
18294 "When the <literal role=\"hg-ext\">inotify</literal> extension is enabled, "
18295 "Mercurial will automatically and transparently start the status daemon the "
18296 "first time you run a command that needs status in a repository. It runs one "
18297 "status daemon per repository."
18298 msgstr ""
18300 #. type: Content of: <book><chapter><sect1><para>
18301 #: ../en/ch14-hgext.xml:220
18302 msgid ""
18303 "The status daemon is started silently, and runs in the background. If you "
18304 "look at a list of running processes after you've enabled the <literal role="
18305 "\"hg-ext\">inotify</literal> extension and run a few commands in different "
18306 "repositories, you'll thus see a few <literal>hg</literal> processes sitting "
18307 "around, waiting for updates from the kernel and queries from Mercurial."
18308 msgstr ""
18310 #. type: Content of: <book><chapter><sect1><para>
18311 #: ../en/ch14-hgext.xml:228
18312 msgid ""
18313 "The first time you run a Mercurial command in a repository when you have the "
18314 "<literal role=\"hg-ext\">inotify</literal> extension enabled, it will run "
18315 "with about the same performance as a normal Mercurial command. This is "
18316 "because the status daemon needs to perform a normal status scan so that it "
18317 "has a baseline against which to apply later updates from the kernel. "
18318 "However, <emphasis>every</emphasis> subsequent command that does any kind of "
18319 "status check should be noticeably faster on repositories of even fairly "
18320 "modest size. Better yet, the bigger your repository is, the greater a "
18321 "performance advantage you'll see. The <literal role=\"hg-ext\">inotify</"
18322 "literal> daemon makes status operations almost instantaneous on repositories "
18323 "of all sizes!"
18324 msgstr ""
18326 #. type: Content of: <book><chapter><sect1><para>
18327 #: ../en/ch14-hgext.xml:242
18328 msgid ""
18329 "If you like, you can manually start a status daemon using the <command role="
18330 "\"hg-ext-inotify\">inserve</command> command. This gives you slightly finer "
18331 "control over how the daemon ought to run. This command will of course only "
18332 "be available when the <literal role=\"hg-ext\">inotify</literal> extension is "
18333 "enabled."
18334 msgstr ""
18336 #. type: Content of: <book><chapter><sect1><para>
18337 #: ../en/ch14-hgext.xml:249
18338 msgid ""
18339 "When you're using the <literal role=\"hg-ext\">inotify</literal> extension, "
18340 "you should notice <emphasis>no difference at all</emphasis> in Mercurial's "
18341 "behavior, with the sole exception of status-related commands running a whole "
18342 "lot faster than they used to. You should specifically expect that commands "
18343 "will not print different output; neither should they give different results. "
18344 "If either of these situations occurs, please report a bug."
18345 msgstr ""
18347 #. type: Content of: <book><chapter><sect1><title>
18348 #: ../en/ch14-hgext.xml:260
18349 msgid ""
18350 "Flexible diff support with the <literal role=\"hg-ext\">extdiff</literal> "
18351 "extension"
18352 msgstr "使用扩展 <literal role=\"hg-ext\">extdiff</literal> 以扩展差异支持"
18354 #. type: Content of: <book><chapter><sect1><para>
18355 #: ../en/ch14-hgext.xml:263
18356 msgid ""
18357 "Mercurial's built-in <command role=\"hg-cmd\">hg diff</command> command "
18358 "outputs plaintext unified diffs."
18359 msgstr ""
18360 "Mercurial 内置命令 <command role=\"hg-cmd\">hg diff</command> 的输出与统一差异"
18361 "不同。"
18363 #. type: Content of: <book><chapter><sect1><para>
18364 #: ../en/ch14-hgext.xml:268
18365 msgid ""
18366 "If you would like to use an external tool to display modifications, you'll "
18367 "want to use the <literal role=\"hg-ext\">extdiff</literal> extension. This "
18368 "will let you use, for example, a graphical diff tool."
18369 msgstr ""
18371 #. type: Content of: <book><chapter><sect1><para>
18372 #: ../en/ch14-hgext.xml:273
18373 msgid ""
18374 "The <literal role=\"hg-ext\">extdiff</literal> extension is bundled with "
18375 "Mercurial, so it's easy to set up. In the <literal role=\"rc-extensions"
18376 "\">extensions</literal> section of your <filename role=\"special\">~/.hgrc</"
18377 "filename>, simply add a one-line entry to enable the extension."
18378 msgstr ""
18380 #. type: Content of: <book><chapter><sect1><para>
18381 #: ../en/ch14-hgext.xml:280
18382 msgid ""
18383 "This introduces a command named <command role=\"hg-ext-extdiff\">extdiff</"
18384 "command>, which by default uses your system's <command>diff</command> command "
18385 "to generate a unified diff in the same form as the built-in <command role="
18386 "\"hg-cmd\">hg diff</command> command."
18387 msgstr ""
18389 #. type: Content of: <book><chapter><sect1><para>
18390 #: ../en/ch14-hgext.xml:288
18391 msgid ""
18392 "The result won't be exactly the same as with the built-in <command role=\"hg-"
18393 "cmd\">hg diff</command> variations, because the output of <command>diff</"
18394 "command> varies from one system to another, even when passed the same options."
18395 msgstr ""
18397 #. type: Content of: <book><chapter><sect1><para>
18398 #: ../en/ch14-hgext.xml:293
18399 msgid ""
18400 "As the <quote><literal>making snapshot</literal></quote> lines of output "
18401 "above imply, the <command role=\"hg-ext-extdiff\">extdiff</command> command "
18402 "works by creating two snapshots of your source tree. The first snapshot is "
18403 "of the source revision; the second, of the target revision or working "
18404 "directory. The <command role=\"hg-ext-extdiff\">extdiff</command> command "
18405 "generates these snapshots in a temporary directory, passes the name of each "
18406 "directory to an external diff viewer, then deletes the temporary directory. "
18407 "For efficiency, it only snapshots the directories and files that have changed "
18408 "between the two revisions."
18409 msgstr ""
18411 #. type: Content of: <book><chapter><sect1><para>
18412 #: ../en/ch14-hgext.xml:306
18413 msgid ""
18414 "Snapshot directory names have the same base name as your repository. If your "
18415 "repository path is <filename class=\"directory\">/quux/bar/foo</filename>, "
18416 "then <filename class=\"directory\">foo</filename> will be the name of each "
18417 "snapshot directory. Each snapshot directory name has its changeset ID "
18418 "appended, if appropriate. If a snapshot is of revision "
18419 "<literal>a631aca1083f</literal>, the directory will be named <filename class="
18420 "\"directory\">foo.a631aca1083f</filename>. A snapshot of the working "
18421 "directory won't have a changeset ID appended, so it would just be <filename "
18422 "class=\"directory\">foo</filename> in this example. To see what this looks "
18423 "like in practice, look again at the <command role=\"hg-ext-extdiff\">extdiff</"
18424 "command> example above. Notice that the diff has the snapshot directory "
18425 "names embedded in its header."
18426 msgstr ""
18428 #. type: Content of: <book><chapter><sect1><para>
18429 #: ../en/ch14-hgext.xml:322
18430 msgid ""
18431 "The <command role=\"hg-ext-extdiff\">extdiff</command> command accepts two "
18432 "important options. The <option role=\"hg-ext-extdiff-cmd-extdiff-opt\">hg -p</"
18433 "option> option lets you choose a program to view differences with, instead of "
18434 "<command>diff</command>. With the <option role=\"hg-ext-extdiff-cmd-extdiff-"
18435 "opt\">hg -o</option> option, you can change the options that <command role="
18436 "\"hg-ext-extdiff\">extdiff</command> passes to the program (by default, these "
18437 "options are <quote><literal>-Npru</literal></quote>, which only make sense if "
18438 "you're running <command>diff</command>). In other respects, the <command "
18439 "role=\"hg-ext-extdiff\">extdiff</command> command acts similarly to the built-"
18440 "in <command role=\"hg-cmd\">hg diff</command> command: you use the same "
18441 "option names, syntax, and arguments to specify the revisions you want, the "
18442 "files you want, and so on."
18443 msgstr ""
18446 #. type: Content of: <book><chapter><sect1><para>
18447 #: ../en/ch14-hgext.xml:339
18448 msgid ""
18449 "As an example, here's how to run the normal system <command>diff</command> "
18450 "command, getting it to generate context diffs (using the <option role=\"cmd-"
18451 "opt-diff\">-c</option> option) instead of unified diffs, and five lines of "
18452 "context instead of the default three (passing <literal>5</literal> as the "
18453 "argument to the <option role=\"cmd-opt-diff\">-C</option> option)."
18454 msgstr ""
18456 #. type: Content of: <book><chapter><sect1><para>
18457 #: ../en/ch14-hgext.xml:348
18458 msgid ""
18459 "Launching a visual diff tool is just as easy. Here's how to launch the "
18460 "<command>kdiff3</command> viewer."
18461 msgstr ""
18463 #. type: Content of: <book><chapter><sect1><para>
18464 #: ../en/ch14-hgext.xml:352
18465 msgid ""
18466 "If your diff viewing command can't deal with directories, you can easily work "
18467 "around this with a little scripting. For an example of such scripting in "
18468 "action with the <literal role=\"hg-ext\">mq</literal> extension and the "
18469 "<command>interdiff</command> command, see <xref linkend=\"mq-collab:tips:"
18470 "interdiff\"/>."
18471 msgstr ""
18473 #. type: Content of: <book><chapter><sect1><sect2><title>
18474 #: ../en/ch14-hgext.xml:360
18475 msgid "Defining command aliases"
18476 msgstr "定义命令的别名"
18478 #. type: Content of: <book><chapter><sect1><sect2><para>
18479 #: ../en/ch14-hgext.xml:362
18480 msgid ""
18481 "It can be cumbersome to remember the options to both the <command role=\"hg-"
18482 "ext-extdiff\">extdiff</command> command and the diff viewer you want to use, "
18483 "so the <literal role=\"hg-ext\">extdiff</literal> extension lets you define "
18484 "<emphasis>new</emphasis> commands that will invoke your diff viewer with "
18485 "exactly the right options."
18486 msgstr ""
18488 #. type: Content of: <book><chapter><sect1><sect2><para>
18489 #: ../en/ch14-hgext.xml:369
18490 msgid ""
18491 "All you need to do is edit your <filename role=\"special\">~/.hgrc</"
18492 "filename>, and add a section named <literal role=\"rc-extdiff\">extdiff</"
18493 "literal>. Inside this section, you can define multiple commands. Here's how "
18494 "to add a <literal>kdiff3</literal> command. Once you've defined this, you "
18495 "can type <quote><literal>hg kdiff3</literal></quote> and the <literal role="
18496 "\"hg-ext\">extdiff</literal> extension will run <command>kdiff3</command> for "
18497 "you."
18498 msgstr ""
18500 #. type: Content of: <book><chapter><sect1><sect2><para>
18501 #: ../en/ch14-hgext.xml:379
18502 msgid ""
18503 "If you leave the right hand side of the definition empty, as above, the "
18504 "<literal role=\"hg-ext\">extdiff</literal> extension uses the name of the "
18505 "command you defined as the name of the external program to run. But these "
18506 "names don't have to be the same. Here, we define a command named "
18507 "<quote><literal>hg wibble</literal></quote>, which runs <command>kdiff3</"
18508 "command>."
18509 msgstr ""
18511 #. type: Content of: <book><chapter><sect1><sect2><para>
18512 #: ../en/ch14-hgext.xml:389
18513 msgid ""
18514 "You can also specify the default options that you want to invoke your diff "
18515 "viewing program with. The prefix to use is <quote><literal>opts.</literal></"
18516 "quote>, followed by the name of the command to which the options apply. This "
18517 "example defines a <quote><literal>hg vimdiff</literal></quote> command that "
18518 "runs the <command>vim</command> editor's <literal>DirDiff</literal> extension."
18519 msgstr ""
18521 #. type: Content of: <book><chapter><sect1><title>
18522 #: ../en/ch14-hgext.xml:403
18523 msgid ""
18524 "Cherrypicking changes with the <literal role=\"hg-ext\">transplant</literal> "
18525 "extension"
18526 msgstr "使用扩展 <literal role=\"hg-ext\">transplant</literal> 以挑选修改"
18528 #. type: Content of: <book><chapter><sect1><para>
18529 #: ../en/ch14-hgext.xml:406
18530 msgid "Need to have a long chat with Brendan about this."
18531 msgstr ""
18533 #. type: Content of: <book><chapter><sect1><title>
18534 #: ../en/ch14-hgext.xml:410
18535 msgid ""
18536 "Send changes via email with the <literal role=\"hg-ext\">patchbomb</literal> "
18537 "extension"
18538 msgstr ""
18539 "使用扩展 <literal role=\"hg-ext\">patchbomb</literal> 通过 email 发送修改"
18541 #. type: Content of: <book><chapter><sect1><para>
18542 #: ../en/ch14-hgext.xml:413
18543 msgid ""
18544 "Many projects have a culture of <quote>change review</quote>, in which people "
18545 "send their modifications to a mailing list for others to read and comment on "
18546 "before they commit the final version to a shared repository. Some projects "
18547 "have people who act as gatekeepers; they apply changes from other people to a "
18548 "repository to which those others don't have access."
18549 msgstr ""
18551 #. type: Content of: <book><chapter><sect1><para>
18552 #: ../en/ch14-hgext.xml:421
18553 msgid ""
18554 "Mercurial makes it easy to send changes over email for review or application, "
18555 "via its <literal role=\"hg-ext\">patchbomb</literal> extension. The "
18556 "extension is so named because changes are formatted as patches, and it's "
18557 "usual to send one changeset per email message. Sending a long series of "
18558 "changes by email is thus much like <quote>bombing</quote> the recipient's "
18559 "inbox, hence <quote>patchbomb</quote>."
18560 msgstr ""
18562 #. type: Content of: <book><chapter><sect1><para>
18563 #: ../en/ch14-hgext.xml:429
18564 msgid ""
18565 "As usual, the basic configuration of the <literal role=\"hg-ext\">patchbomb</"
18566 "literal> extension takes just one or two lines in your <filename role="
18567 "\"special\"> /.hgrc</filename>."
18568 msgstr ""
18570 #. type: Content of: <book><chapter><sect1><para>
18571 #: ../en/ch14-hgext.xml:435
18572 msgid ""
18573 "Once you've enabled the extension, you will have a new command available, "
18574 "named <command role=\"hg-ext-patchbomb\">email</command>."
18575 msgstr ""
18577 #. type: Content of: <book><chapter><sect1><para>
18578 #: ../en/ch14-hgext.xml:439
18579 msgid ""
18580 "The safest and best way to invoke the <command role=\"hg-ext-patchbomb"
18581 "\">email</command> command is to <emphasis>always</emphasis> run it first "
18582 "with the <option role=\"hg-ext-patchbomb-cmd-email-opt\">hg -n</option> "
18583 "option. This will show you what the command <emphasis>would</emphasis> send, "
18584 "without actually sending anything. Once you've had a quick glance over the "
18585 "changes and verified that you are sending the right ones, you can rerun the "
18586 "same command, with the <option role=\"hg-ext-patchbomb-cmd-email-opt\">hg -n</"
18587 "option> option removed."
18588 msgstr ""
18590 #. type: Content of: <book><chapter><sect1><para>
18591 #: ../en/ch14-hgext.xml:450
18592 msgid ""
18593 "The <command role=\"hg-ext-patchbomb\">email</command> command accepts the "
18594 "same kind of revision syntax as every other Mercurial command. For example, "
18595 "this command will send every revision between 7 and <literal>tip</literal>, "
18596 "inclusive."
18597 msgstr ""
18599 #. type: Content of: <book><chapter><sect1><para>
18600 #: ../en/ch14-hgext.xml:455
18601 msgid ""
18602 "You can also specify a <emphasis>repository</emphasis> to compare with. If "
18603 "you provide a repository but no revisions, the <command role=\"hg-ext-"
18604 "patchbomb\">email</command> command will send all revisions in the local "
18605 "repository that are not present in the remote repository. If you "
18606 "additionally specify revisions or a branch name (the latter using the <option "
18607 "role=\"hg-ext-patchbomb-cmd-email-opt\">hg -b</option> option), this will "
18608 "constrain the revisions sent."
18609 msgstr ""
18611 #. type: Content of: <book><chapter><sect1><para>
18612 #: ../en/ch14-hgext.xml:464
18613 msgid ""
18614 "It's perfectly safe to run the <command role=\"hg-ext-patchbomb\">email</"
18615 "command> command without the names of the people you want to send to: if you "
18616 "do this, it will just prompt you for those values interactively. (If you're "
18617 "using a Linux or Unix-like system, you should have enhanced "
18618 "<literal>readline</literal>-style editing capabilities when entering those "
18619 "headers, too, which is useful.)"
18620 msgstr ""
18622 #. type: Content of: <book><chapter><sect1><para>
18623 #: ../en/ch14-hgext.xml:472
18624 msgid ""
18625 "When you are sending just one revision, the <command role=\"hg-ext-patchbomb"
18626 "\">email</command> command will by default use the first line of the "
18627 "changeset description as the subject of the single email message it sends."
18628 msgstr ""
18630 #. type: Content of: <book><chapter><sect1><para>
18631 #: ../en/ch14-hgext.xml:477
18632 msgid ""
18633 "If you send multiple revisions, the <command role=\"hg-ext-patchbomb\">email</"
18634 "command> command will usually send one message per changeset. It will "
18635 "preface the series with an introductory message, in which you should describe "
18636 "the purpose of the series of changes you're sending."
18637 msgstr ""
18639 #. type: Content of: <book><chapter><sect1><sect2><title>
18640 #: ../en/ch14-hgext.xml:484
18641 msgid "Changing the behavior of patchbombs"
18642 msgstr "修改 patchbomb 的行为"
18644 #. type: Content of: <book><chapter><sect1><sect2><para>
18645 #: ../en/ch14-hgext.xml:486
18646 msgid ""
18647 "Not every project has exactly the same conventions for sending changes in "
18648 "email; the <literal role=\"hg-ext\">patchbomb</literal> extension tries to "
18649 "accommodate a number of variations through command line options."
18650 msgstr ""
18652 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
18653 #: ../en/ch14-hgext.xml:492
18654 msgid ""
18655 "You can write a subject for the introductory message on the command line "
18656 "using the <option role=\"hg-ext-patchbomb-cmd-email-opt\">hg -s</option> "
18657 "option. This takes one argument, the text of the subject to use."
18658 msgstr ""
18660 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
18661 #: ../en/ch14-hgext.xml:498
18662 msgid ""
18663 "To change the email address from which the messages originate, use the "
18664 "<option role=\"hg-ext-patchbomb-cmd-email-opt\">hg -f</option> option. This "
18665 "takes one argument, the email address to use."
18666 msgstr ""
18668 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
18669 #: ../en/ch14-hgext.xml:504
18670 msgid ""
18671 "The default behavior is to send unified diffs (see <xref linkend=\"sec:mq:"
18672 "patch\"/> for a description of the format), one per message. You can send a "
18673 "binary bundle instead with the <option role=\"hg-ext-patchbomb-cmd-email-opt"
18674 "\">hg -b</option> option."
18675 msgstr ""
18677 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
18678 #: ../en/ch14-hgext.xml:512
18679 msgid ""
18680 "Unified diffs are normally prefaced with a metadata header. You can omit "
18681 "this, and send unadorned diffs, with the <option role=\"hg-ext-patchbomb-cmd-"
18682 "email-opt\">hg --plain</option> option."
18683 msgstr ""
18685 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
18686 #: ../en/ch14-hgext.xml:518
18687 msgid ""
18688 "Diffs are normally sent <quote>inline</quote>, in the same body part as the "
18689 "description of a patch. This makes it easiest for the largest number of "
18690 "readers to quote and respond to parts of a diff, as some mail clients will "
18691 "only quote the first MIME body part in a message. If you'd prefer to send the "
18692 "description and the diff in separate body parts, use the <option role=\"hg-"
18693 "ext-patchbomb-cmd-email-opt\">hg -a</option> option."
18694 msgstr ""
18696 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
18697 #: ../en/ch14-hgext.xml:528
18698 msgid ""
18699 "Instead of sending mail messages, you can write them to an <literal>mbox</"
18700 "literal>-format mail folder using the <option role=\"hg-ext-patchbomb-cmd-"
18701 "email-opt\">hg -m</option> option. That option takes one argument, the name "
18702 "of the file to write to."
18703 msgstr ""
18705 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
18706 #: ../en/ch14-hgext.xml:535
18707 msgid ""
18708 "If you would like to add a <command>diffstat</command>-format summary to each "
18709 "patch, and one to the introductory message, use the <option role=\"hg-ext-"
18710 "patchbomb-cmd-email-opt\">hg -d</option> option. The <command>diffstat</"
18711 "command> command displays a table containing the name of each file patched, "
18712 "the number of lines affected, and a histogram showing how much each file is "
18713 "modified. This gives readers a qualitative glance at how complex a patch is."
18714 msgstr ""