hgbook

view po/zh.po @ 833:63ef1efbac57

Translate more code, matching repository names in figures.
author gpiancastelli
date Tue Aug 18 17:31:11 2009 +0200 (2009-08-18)
parents c03f7ff6069c
children 851bed11c742
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-05-21 14:26+0800\n"
45 "PO-Revision-Date: 2009-05-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 ""
181 #. type: Content of: <book><appendix><sect1><para>
182 #: ../en/appA-svn.xml:59
183 msgid ""
184 "This will make a <command>hg convert</command> command available. The "
185 "command is easy to use. For instance, this command will import the "
186 "Subversion history for the Nose unit testing framework into Mercurial."
187 msgstr ""
189 #. type: Content of: <book><appendix><sect1><screen><prompt>
190 #: ../en/appA-svn.xml:64 ../en/appA-svn.xml:207 ../en/appA-svn.xml:212
191 #: ../en/appA-svn.xml:213 ../en/appA-svn.xml:218 ../en/appA-svn.xml:224
192 #: ../en/appA-svn.xml:229 ../en/appA-svn.xml:532
193 msgid "$"
194 msgstr "$"
196 #. type: Content of: <book><appendix><sect1><screen><userinput>
197 #: ../en/appA-svn.xml:64
198 msgid "hg convert http://python-nose.googlecode.com/svn/trunk"
199 msgstr ""
201 #. type: Content of: <book><appendix><sect1><para>
202 #: ../en/appA-svn.xml:66
203 msgid ""
204 "The <literal>convert</literal> extension operates incrementally. In other "
205 "words, after you have run <command>hg convert</command> once, running it "
206 "again will import any new revisions committed after the first run began. "
207 "Incremental conversion will only work if you run <command>hg convert</"
208 "command> in the same Mercurial repository that you originally used, because "
209 "the <literal>convert</literal> extension saves some private metadata in a non-"
210 "revision-controlled file named <filename>.hg/shamap</filename> inside the "
211 "target repository."
212 msgstr ""
214 #. type: Content of: <book><appendix><sect1><para>
215 #: ../en/appA-svn.xml:78
216 msgid ""
217 "When you want to start making changes using Mercurial, it's best to clone the "
218 "tree in which you are doing your conversions, and leave the original tree for "
219 "future incremental conversions. This is the safest way to let you pull and "
220 "merge future commits from the source revision control system into your newly "
221 "active Mercurial project."
222 msgstr ""
224 #. type: Content of: <book><appendix><sect1><sect2><title>
225 #: ../en/appA-svn.xml:86
226 msgid "Converting multiple branches"
227 msgstr "转换多个分支"
229 #. type: Content of: <book><appendix><sect1><sect2><para>
230 #: ../en/appA-svn.xml:88
231 msgid ""
232 "The <command>hg convert</command> command given above converts only the "
233 "history of the <literal>trunk</literal> branch of the Subversion repository. "
234 "If we instead use the URL <literal>http://python-nose.googlecode.com/svn</"
235 "literal>, Mercurial will automatically detect the <literal>trunk</literal>, "
236 "<literal>tags</literal> and <literal>branches</literal> layout that "
237 "Subversion projects usually use, and it will import each as a separate "
238 "Mercurial branch."
239 msgstr ""
241 #. type: Content of: <book><appendix><sect1><sect2><para>
242 #: ../en/appA-svn.xml:98
243 msgid ""
244 "By default, each Subversion branch imported into Mercurial is given a branch "
245 "name. After the conversion completes, you can get a list of the active "
246 "branch names in the Mercurial repository using <command>hg branches -a</"
247 "command>. If you would prefer to import the Subversion branches without "
248 "names, pass the <option>--config convert.hg.usebranchnames=false</option> "
249 "option to <command>hg convert</command>."
250 msgstr ""
252 #. type: Content of: <book><appendix><sect1><sect2><para>
253 #: ../en/appA-svn.xml:107
254 msgid ""
255 "Once you have converted your tree, if you want to follow the usual Mercurial "
256 "practice of working in a tree that contains a single branch, you can clone "
257 "that single branch using <command>hg clone -r mybranchname</command>."
258 msgstr ""
260 #. type: Content of: <book><appendix><sect1><sect2><title>
261 #: ../en/appA-svn.xml:114
262 msgid "Mapping user names"
263 msgstr "映射用户名称"
265 #. type: Content of: <book><appendix><sect1><sect2><para>
266 #: ../en/appA-svn.xml:116
267 msgid ""
268 "Some revision control tools save only short usernames with commits, and these "
269 "can be difficult to interpret. The norm with Mercurial is to save a "
270 "committer's name and email address, which is much more useful for talking to "
271 "them after the fact."
272 msgstr ""
274 #. type: Content of: <book><appendix><sect1><sect2><para>
275 #: ../en/appA-svn.xml:122
276 msgid ""
277 "If you are converting a tree from a revision control system that uses short "
278 "names, you can map those names to longer equivalents by passing a <option>--"
279 "authors</option> option to <command>hg convert</command>. This option "
280 "accepts a file name that should contain entries of the following form."
281 msgstr ""
283 #. type: Content of: <book><appendix><sect1><sect2><para>
284 #: ../en/appA-svn.xml:132
285 msgid ""
286 "Whenever <literal>convert</literal> encounters a commit with the username "
287 "<literal>arist</literal> in the source repository, it will use the name "
288 "<literal>Aristotle &lt;aristotle@phil.example.gr&gt;</literal> in the "
289 "converted Mercurial revision. If no match is found for a name, it is used "
290 "verbatim."
291 msgstr ""
293 #. type: Content of: <book><appendix><sect1><sect2><title>
294 #: ../en/appA-svn.xml:141
295 msgid "Tidying up the tree"
296 msgstr "清理目录树"
298 #. type: Content of: <book><appendix><sect1><sect2><para>
299 #: ../en/appA-svn.xml:143
300 msgid ""
301 "Not all projects have pristine history. There may be a directory that should "
302 "never have been checked in, a file that is too big, or a whole hierarchy that "
303 "needs to be refactored."
304 msgstr ""
306 #. type: Content of: <book><appendix><sect1><sect2><para>
307 #: ../en/appA-svn.xml:148
308 msgid ""
309 "The <literal>convert</literal> extension supports the idea of a <quote>file "
310 "map</quote> that can reorganize the files and directories in a project as it "
311 "imports the project's history. This is useful not only when importing "
312 "history from other revision control systems, but also to prune or refactor a "
313 "Mercurial tree."
314 msgstr ""
316 #. type: Content of: <book><appendix><sect1><sect2><para>
317 #: ../en/appA-svn.xml:155
318 msgid ""
319 "To specify a file map, use the <option>--filemap</option> option and supply a "
320 "file name. A file map contains lines of the following forms."
321 msgstr ""
323 #. type: Content of: <book><appendix><sect1><sect2><para>
324 #: ../en/appA-svn.xml:169
325 msgid ""
326 "The <literal>include</literal> directive causes a file, or all files under a "
327 "directory, to be included in the destination repository. This also excludes "
328 "all other files and dirs not explicitely included. The <literal>exclude</"
329 "literal> directive causes files or directories to be omitted, and others not "
330 "explicitly mentioned to be included."
331 msgstr ""
333 #. type: Content of: <book><appendix><sect1><sect2><para>
334 #: ../en/appA-svn.xml:176
335 msgid ""
336 "To move a file or directory from one location to another, use the "
337 "<literal>rename</literal> directive. If you need to move a file or directory "
338 "from a subdirectory into the root of the repository, use <literal>.</literal> "
339 "as the second argument to the <literal>rename</literal> directive."
340 msgstr ""
342 #. type: Content of: <book><appendix><sect1><sect2><title>
343 #: ../en/appA-svn.xml:184
344 msgid "Improving Subversion conversion performance"
345 msgstr "改进 Subversion 的转换性能"
347 #. type: Content of: <book><appendix><sect1><sect2><para>
348 #: ../en/appA-svn.xml:186
349 msgid ""
350 "You will often need several attempts before you hit the perfect combination "
351 "of user map, file map, and other conversion parameters. Converting a "
352 "Subversion repository over an access protocol like <literal>ssh</literal> or "
353 "<literal>http</literal> can proceed thousands of times more slowly than "
354 "Mercurial is capable of actually operating, due to network delays. This can "
355 "make tuning that perfect conversion recipe very painful."
356 msgstr ""
358 #. type: Content of: <book><appendix><sect1><sect2><para>
359 #: ../en/appA-svn.xml:195
360 msgid ""
361 "The <ulink url=\"http://svn.collab.net/repos/svn/trunk/notes/svnsync.txt"
362 "\"><command>svnsync</command></ulink> command can greatly speed up the "
363 "conversion of a Subversion repository. It is a read-only mirroring program "
364 "for Subversion repositories. The idea is that you create a local mirror of "
365 "your Subversion tree, then convert the mirror into a Mercurial repository."
366 msgstr ""
368 #. type: Content of: <book><appendix><sect1><sect2><para>
369 #: ../en/appA-svn.xml:203
370 msgid ""
371 "Suppose we want to convert the Subversion repository for the popular "
372 "Memcached project into a Mercurial tree. First, we create a local Subversion "
373 "repository."
374 msgstr ""
376 #. type: Content of: <book><appendix><sect1><sect2><screen><userinput>
377 #: ../en/appA-svn.xml:207
378 msgid "svnadmin create memcached-mirror"
379 msgstr "svnadmin create memcached-mirror"
381 #. type: Content of: <book><appendix><sect1><sect2><para>
382 #: ../en/appA-svn.xml:209
383 msgid "Next, we set up a Subversion hook that <command>svnsync</command> needs."
384 msgstr ""
386 #. type: Content of: <book><appendix><sect1><sect2><screen><userinput>
387 #: ../en/appA-svn.xml:212
388 msgid "echo '#!/bin/sh' > memcached-mirror/hooks/pre-revprop-change"
389 msgstr "echo '#!/bin/sh' > memcached-mirror/hooks/pre-revprop-change"
391 #. type: Content of: <book><appendix><sect1><sect2><screen><userinput>
392 #: ../en/appA-svn.xml:213
393 msgid "chmod +x memcached-mirror/hooks/pre-revprop-change"
394 msgstr "chmod +x memcached-mirror/hooks/pre-revprop-change"
396 #. type: Content of: <book><appendix><sect1><sect2><para>
397 #: ../en/appA-svn.xml:215
398 msgid "We then initialize <command>svnsync</command> in this repository."
399 msgstr ""
401 #. type: Content of: <book><appendix><sect1><sect2><screen><userinput>
402 #: ../en/appA-svn.xml:218
403 msgid ""
404 "svnsync --init file://`pwd`/memcached-mirror \\ http://code.sixapart.com/svn/"
405 "memcached"
406 msgstr ""
407 "svnsync --init file://`pwd`/memcached-mirror \\ http://code.sixapart.com/svn/"
408 "memcached"
410 #. type: Content of: <book><appendix><sect1><sect2><para>
411 #: ../en/appA-svn.xml:221
412 msgid ""
413 "Our next step is to begin the <command>svnsync</command> mirroring process."
414 msgstr ""
416 #. type: Content of: <book><appendix><sect1><sect2><screen><userinput>
417 #: ../en/appA-svn.xml:224
418 msgid "svnsync sync file://`pwd`/memcached-mirror"
419 msgstr "svnsync sync file://`pwd`/memcached-mirror"
421 #. type: Content of: <book><appendix><sect1><sect2><para>
422 #: ../en/appA-svn.xml:226
423 msgid ""
424 "Finally, we import the history of our local Subversion mirror into Mercurial."
425 msgstr ""
427 #. type: Content of: <book><appendix><sect1><sect2><screen><userinput>
428 #: ../en/appA-svn.xml:229
429 msgid "hg convert memcached-mirror"
430 msgstr ""
432 #. type: Content of: <book><appendix><sect1><sect2><para>
433 #: ../en/appA-svn.xml:231
434 msgid ""
435 "We can use this process incrementally if the Subversion repository is still "
436 "in use. We run <command>svnsync</command> to pull new changes into our "
437 "mirror, then <command>hg convert</command> to import them into our Mercurial "
438 "tree."
439 msgstr ""
441 #. type: Content of: <book><appendix><sect1><sect2><para>
442 #: ../en/appA-svn.xml:237
443 msgid ""
444 "There are two advantages to doing a two-stage import with <command>svnsync</"
445 "command>. The first is that it uses more efficient Subversion network "
446 "syncing code than <command>hg convert</command>, so it transfers less data "
447 "over the network. The second is that the import from a local Subversion tree "
448 "is so fast that you can tweak your conversion setup repeatedly without having "
449 "to sit through a painfully slow network-based conversion process each time."
450 msgstr ""
452 #. type: Content of: <book><appendix><sect1><title>
453 #: ../en/appA-svn.xml:249
454 msgid "Migrating from Subversion"
455 msgstr "从 Subversion 迁移"
457 #. type: Content of: <book><appendix><sect1><para>
458 #: ../en/appA-svn.xml:251
459 msgid ""
460 "Subversion is currently the most popular open source revision control system. "
461 "Although there are many differences between Mercurial and Subversion, making "
462 "the transition from Subversion to Mercurial is not particularly difficult. "
463 "The two have similar command sets and generally uniform interfaces."
464 msgstr ""
466 #. type: Content of: <book><appendix><sect1><sect2><title>
467 #: ../en/appA-svn.xml:259
468 msgid "Philosophical differences"
469 msgstr "哲学的差别"
471 #. type: Content of: <book><appendix><sect1><sect2><para>
472 #: ../en/appA-svn.xml:261
473 msgid ""
474 "The fundamental difference between Subversion and Mercurial is of course that "
475 "Subversion is centralized, while Mercurial is distributed. Since Mercurial "
476 "stores all of a project's history on your local drive, it only needs to "
477 "perform a network access when you want to explicitly communicate with another "
478 "repository. In contrast, Subversion stores very little information locally, "
479 "and the client must thus contact its server for many common operations."
480 msgstr ""
482 #. type: Content of: <book><appendix><sect1><sect2><para>
483 #: ../en/appA-svn.xml:270
484 msgid ""
485 "Subversion more or less gets away without a well-defined notion of a branch: "
486 "which portion of a server's namespace qualifies as a branch is a matter of "
487 "convention, with the software providing no enforcement. Mercurial treats a "
488 "repository as the unit of branch management."
489 msgstr ""
491 #. type: Content of: <book><appendix><sect1><sect2><sect3><title>
492 #: ../en/appA-svn.xml:277
493 msgid "Scope of commands"
494 msgstr "命令作用域"
496 #. type: Content of: <book><appendix><sect1><sect2><sect3><para>
497 #: ../en/appA-svn.xml:279
498 msgid ""
499 "Since Subversion doesn't know what parts of its namespace are really "
500 "branches, it treats most commands as requests to operate at and below "
501 "whatever directory you are currently visiting. For instance, if you run "
502 "<command>svn log</command>, you'll get the history of whatever part of the "
503 "tree you're looking at, not the tree as a whole."
504 msgstr ""
506 #. type: Content of: <book><appendix><sect1><sect2><sect3><para>
507 #: ../en/appA-svn.xml:286
508 msgid ""
509 "Mercurial's commands behave differently, by defaulting to operating over an "
510 "entire repository. Run <command>hg log</command> and it will tell you the "
511 "history of the entire tree, no matter what part of the working directory "
512 "you're visiting at the time. If you want the history of just a particular "
513 "file or directory, simply supply it by name, e.g. <command>hg log src</"
514 "command>."
515 msgstr ""
517 #. type: Content of: <book><appendix><sect1><sect2><sect3><para>
518 #: ../en/appA-svn.xml:294
519 msgid ""
520 "From my own experience, this difference in default behaviors is probably the "
521 "most likely to trip you up if you have to switch back and forth frequently "
522 "between the two tools."
523 msgstr ""
525 #. type: Content of: <book><appendix><sect1><sect2><sect3><title>
526 #: ../en/appA-svn.xml:301
527 msgid "Multi-user operation and safety"
528 msgstr "多用户操作与安全"
530 #. type: Content of: <book><appendix><sect1><sect2><sect3><para>
531 #: ../en/appA-svn.xml:303
532 msgid ""
533 "With Subversion, it is normal (though slightly frowned upon) for multiple "
534 "people to collaborate in a single branch. If Alice and Bob are working "
535 "together, and Alice commits some changes to their shared branch, Bob must "
536 "update his client's view of the branch before he can commit. Since at this "
537 "time he has no permanent record of the changes he has made, he can corrupt or "
538 "lose his modifications during and after his update."
539 msgstr ""
541 #. type: Content of: <book><appendix><sect1><sect2><sect3><para>
542 #: ../en/appA-svn.xml:312
543 msgid ""
544 "Mercurial encourages a commit-then-merge model instead. Bob commits his "
545 "changes locally before pulling changes from, or pushing them to, the server "
546 "that he shares with Alice. If Alice pushed her changes before Bob tries to "
547 "push his, he will not be able to push his changes until he pulls hers, merges "
548 "with them, and commits the result of the merge. If he makes a mistake during "
549 "the merge, he still has the option of reverting to the commit that recorded "
550 "his changes."
551 msgstr ""
553 #. type: Content of: <book><appendix><sect1><sect2><sect3><para>
554 #: ../en/appA-svn.xml:321
555 msgid ""
556 "It is worth emphasizing that these are the common ways of working with these "
557 "tools. Subversion supports a safer work-in-your-own-branch model, but it is "
558 "cumbersome enough in practice to not be widely used. Mercurial can support "
559 "the less safe mode of allowing changes to be pulled in and merged on top of "
560 "uncommitted edits, but this is considered highly unusual."
561 msgstr ""
563 #. type: Content of: <book><appendix><sect1><sect2><sect3><title>
564 #: ../en/appA-svn.xml:331
565 msgid "Published vs local changes"
566 msgstr "已发布的修改与本地修改"
568 #. type: Content of: <book><appendix><sect1><sect2><sect3><para>
569 #: ../en/appA-svn.xml:333
570 msgid ""
571 "A Subversion <command>svn commit</command> command immediately publishes "
572 "changes to a server, where they can be seen by everyone who has read access."
573 msgstr ""
575 #. type: Content of: <book><appendix><sect1><sect2><sect3><para>
576 #: ../en/appA-svn.xml:337
577 msgid ""
578 "With Mercurial, commits are always local, and must be published via a "
579 "<command>hg push</command> command afterwards."
580 msgstr ""
582 #. type: Content of: <book><appendix><sect1><sect2><sect3><para>
583 #: ../en/appA-svn.xml:341
584 msgid ""
585 "Each approach has its advantages and disadvantages. The Subversion model "
586 "means that changes are published, and hence reviewable and usable, "
587 "immediately. On the other hand, this means that a user must have commit "
588 "access to a repository in order to use the software in a normal way, and "
589 "commit access is not lightly given out by most open source projects."
590 msgstr ""
592 #. type: Content of: <book><appendix><sect1><sect2><sect3><para>
593 #: ../en/appA-svn.xml:349
594 msgid ""
595 "The Mercurial approach allows anyone who can clone a repository to commit "
596 "changes without the need for someone else's permission, and they can then "
597 "publish their changes and continue to participate however they see fit. The "
598 "distinction between committing and pushing does open up the possibility of "
599 "someone committing changes to their laptop and walking away for a few days "
600 "having forgotten to push them, which in rare cases might leave collaborators "
601 "temporarily stuck."
602 msgstr ""
604 #. type: Content of: <book><appendix><sect1><sect2><title>
605 #: ../en/appA-svn.xml:362
606 msgid "Quick reference"
607 msgstr "快速参考"
609 #. type: Content of: <book><appendix><sect1><sect2><table><title>
610 #: ../en/appA-svn.xml:365
611 msgid "Subversion commands and Mercurial equivalents"
612 msgstr "Subversion 命令与 Mercurial 对照表"
614 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><thead><row><entry>
615 #: ../en/appA-svn.xml:371
616 msgid "Notes"
617 msgstr "备注"
619 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
620 #: ../en/appA-svn.xml:376
621 msgid "<command>svn add</command>"
622 msgstr "<command>svn add</command>"
624 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
625 #: ../en/appA-svn.xml:377
626 msgid "<command>hg add</command>"
627 msgstr "<command>hg add</command>"
629 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
630 #: ../en/appA-svn.xml:381
631 msgid "<command>svn blame</command>"
632 msgstr "<command>svn blame</command>"
634 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
635 #: ../en/appA-svn.xml:382
636 msgid "<command>hg annotate</command>"
637 msgstr "<command>hg annotate</command>"
639 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
640 #: ../en/appA-svn.xml:386
641 msgid "<command>svn cat</command>"
642 msgstr "<command>svn cat</command>"
644 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
645 #: ../en/appA-svn.xml:387
646 msgid "<command>hg cat</command>"
647 msgstr "<command>hg cat</command>"
649 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
650 #: ../en/appA-svn.xml:391
651 msgid "<command>svn checkout</command>"
652 msgstr "<command>svn checkout</command>"
654 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
655 #: ../en/appA-svn.xml:392 ../en/appA-svn.xml:409
656 msgid "<command>hg clone</command>"
657 msgstr "<command>hg clone</command>"
659 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
660 #: ../en/appA-svn.xml:396
661 msgid "<command>svn cleanup</command>"
662 msgstr "<command>svn cleanup</command>"
664 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
665 #: ../en/appA-svn.xml:397 ../en/appA-svn.xml:472
666 msgid "n/a"
667 msgstr "n/a"
669 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
670 #: ../en/appA-svn.xml:398
671 msgid "No cleanup needed"
672 msgstr "不需要清理"
674 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
675 #: ../en/appA-svn.xml:401
676 msgid "<command>svn commit</command>"
677 msgstr "<command>svn commit</command>"
679 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
680 #: ../en/appA-svn.xml:402
681 msgid "<command>hg commit</command>; <command>hg push</command>"
682 msgstr "<command>hg commit</command>; <command>hg push</command>"
684 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
685 #: ../en/appA-svn.xml:404
686 msgid "<command>hg push</command> publishes after commit"
687 msgstr "提交后使用 <command>hg push</command> 发布"
689 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
690 #: ../en/appA-svn.xml:408 ../en/appA-svn.xml:413
691 msgid "<command>svn copy</command>"
692 msgstr "<command>svn copy</command>"
694 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
695 #: ../en/appA-svn.xml:410
696 msgid "To create a new branch"
697 msgstr "创建新补丁"
699 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
700 #: ../en/appA-svn.xml:414
701 msgid "<command>hg copy</command>"
702 msgstr "<command>hg copy</command>"
704 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
705 #: ../en/appA-svn.xml:415
706 msgid "To copy files or directories"
707 msgstr "复制文件或目录"
709 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
710 #: ../en/appA-svn.xml:418
711 msgid "<command>svn delete</command> (<command>svn remove</command>)"
712 msgstr "<command>svn delete</command> (<command>svn remove</command>)"
714 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
715 #: ../en/appA-svn.xml:420
716 msgid "<command>hg remove</command>"
717 msgstr "<command>hg remove</command>"
719 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
720 #: ../en/appA-svn.xml:424
721 msgid "<command>svn diff</command>"
722 msgstr "<command>svn diff</command>"
724 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
725 #: ../en/appA-svn.xml:425
726 msgid "<command>hg diff</command>"
727 msgstr "<command>hg diff</command>"
729 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
730 #: ../en/appA-svn.xml:429
731 msgid "<command>svn export</command>"
732 msgstr "<command>svn export</command>"
734 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
735 #: ../en/appA-svn.xml:430
736 msgid "<command>hg archive</command>"
737 msgstr "<command>hg archive</command>"
739 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
740 #: ../en/appA-svn.xml:434
741 msgid "<command>svn help</command>"
742 msgstr "<command>svn help</command>"
744 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
745 #: ../en/appA-svn.xml:435
746 msgid "<command>hg help</command>"
747 msgstr "<command>hg help</command>"
749 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
750 #: ../en/appA-svn.xml:439
751 msgid "<command>svn import</command>"
752 msgstr "<command>svn import</command>"
754 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
755 #: ../en/appA-svn.xml:440
756 msgid "<command>hg addremove</command>; <command>hg commit</command>"
757 msgstr "<command>hg addremove</command>; <command>hg commit</command>"
759 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
760 #: ../en/appA-svn.xml:445 ../en/appA-svn.xml:450
761 msgid "<command>svn info</command>"
762 msgstr "<command>svn info</command>"
764 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
765 #: ../en/appA-svn.xml:446
766 msgid "<command>hg parents</command>"
767 msgstr "<command>hg parents</command>"
769 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
770 #: ../en/appA-svn.xml:447
771 msgid "Shows what revision is checked out"
772 msgstr "显示检出的版本信息"
774 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
775 #: ../en/appA-svn.xml:451
776 msgid "<command>hg showconfig paths.parent</command>"
777 msgstr "<command>hg showconfig paths.parent</command>"
779 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
780 #: ../en/appA-svn.xml:453
781 msgid "Shows what URL is checked out"
782 msgstr "显示检出的 URL"
784 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
785 #: ../en/appA-svn.xml:456
786 msgid "<command>svn list</command>"
787 msgstr "<command>svn list</command>"
789 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
790 #: ../en/appA-svn.xml:457
791 msgid "<command>hg manifest</command>"
792 msgstr "<command>hg manifest</command>"
794 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
795 #: ../en/appA-svn.xml:461
796 msgid "<command>svn log</command>"
797 msgstr "<command>svn log</command>"
799 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
800 #: ../en/appA-svn.xml:462
801 msgid "<command>hg log</command>"
802 msgstr "<command>hg log</command>"
804 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
805 #: ../en/appA-svn.xml:466
806 msgid "<command>svn merge</command>"
807 msgstr ""
809 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
810 #: ../en/appA-svn.xml:467
811 msgid "<command>hg merge</command>"
812 msgstr "<command>hg merge</command>"
814 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
815 #: ../en/appA-svn.xml:471
816 msgid "<command>svn mkdir</command>"
817 msgstr "<command>svn mkdir</command>"
819 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
820 #: ../en/appA-svn.xml:473
821 msgid "Mercurial does not track directories"
822 msgstr "Mercurial 不跟踪目录"
824 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
825 #: ../en/appA-svn.xml:476
826 msgid "<command>svn move</command> (<command>svn rename</command>)"
827 msgstr "<command>svn move</command> (<command>svn rename</command>)"
829 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
830 #: ../en/appA-svn.xml:478
831 msgid "<command>hg rename</command>"
832 msgstr "<command>hg rename</command>"
834 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
835 #: ../en/appA-svn.xml:482
836 msgid "<command>svn resolved</command>"
837 msgstr "<command>svn resolved</command>"
839 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
840 #: ../en/appA-svn.xml:483
841 msgid "<command>hg resolve -m</command>"
842 msgstr "<command>hg resolve -m</command>"
844 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
845 #: ../en/appA-svn.xml:487
846 msgid "<command>svn revert</command>"
847 msgstr "<command>svn revert</command>"
849 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
850 #: ../en/appA-svn.xml:488
851 msgid "<command>hg revert</command>"
852 msgstr "<command>hg revert</command>"
854 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
855 #: ../en/appA-svn.xml:492
856 msgid "<command>svn status</command>"
857 msgstr "<command>svn status</command>"
859 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
860 #: ../en/appA-svn.xml:493
861 msgid "<command>hg status</command>"
862 msgstr "<command>hg status</command>"
864 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
865 #: ../en/appA-svn.xml:497
866 msgid "<command>svn update</command>"
867 msgstr "<command>svn update</command>"
869 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
870 #: ../en/appA-svn.xml:498
871 msgid "<command>hg pull -u</command>"
872 msgstr "<command>hg pull -u</command>"
874 #. type: Content of: <book><appendix><sect1><title>
875 #: ../en/appA-svn.xml:508
876 msgid "Useful tips for newcomers"
877 msgstr "新手需要了解的技巧"
879 #. type: Content of: <book><appendix><sect1><para>
880 #: ../en/appA-svn.xml:510
881 msgid ""
882 "Under some revision control systems, printing a diff for a single committed "
883 "revision can be painful. For instance, with Subversion, to see what changed "
884 "in revision 104654, you must type <command>svn diff -r104653:104654</"
885 "command>. Mercurial eliminates the need to type the revision ID twice in this "
886 "common case. For a plain diff, <command>hg export 104654</command>. For a log "
887 "message followed by a diff, <command>hg log -r104654 -p</command>."
888 msgstr ""
890 #. type: Content of: <book><appendix><sect1><para>
891 #: ../en/appA-svn.xml:519
892 msgid ""
893 "When you run <command>hg status</command> without any arguments, it prints "
894 "the status of the entire tree, with paths relative to the root of the "
895 "repository. This makes it tricky to copy a file name from the output of "
896 "<command>hg status</command> into the command line. If you supply a file or "
897 "directory name to <command>hg status</command>, it will print paths relative "
898 "to your current location instead. So to get tree-wide status from "
899 "<command>hg status</command>, with paths that are relative to your current "
900 "directory and not the root of the repository, feed the output of <command>hg "
901 "root</command> into <command>hg status</command>. You can easily do this as "
902 "follows on a Unix-like system:"
903 msgstr ""
905 #. type: Content of: <book><appendix><sect1><screen><userinput>
906 #: ../en/appA-svn.xml:532
907 msgid "hg status `hg root`"
908 msgstr "hg status `hg root`"
910 #. type: Content of: <book><appendix><title>
911 #: ../en/appB-mq-ref.xml:5
912 msgid "Mercurial Queues reference"
913 msgstr "Mercurial 队列参考"
915 #. type: Content of: <book><appendix><sect1><title>
916 #: ../en/appB-mq-ref.xml:8
917 msgid "MQ command reference"
918 msgstr "MQ 命令参考"
920 #. type: Content of: <book><appendix><sect1><para>
921 #: ../en/appB-mq-ref.xml:10
922 msgid ""
923 "For an overview of the commands provided by MQ, use the command <command role="
924 "\"hg-cmd\">hg help mq</command>."
925 msgstr ""
927 #. type: Content of: <book><appendix><sect1><sect2><title>
928 #: ../en/appB-mq-ref.xml:14
929 msgid ""
930 "<command role=\"hg-ext-mq\">qapplied</command>&emdash;print applied patches"
931 msgstr "<command role=\"hg-ext-mq\">qapplied</command>—显示已应用的补丁"
933 #. type: Content of: <book><appendix><sect1><sect2><para>
934 #: ../en/appB-mq-ref.xml:17
935 msgid ""
936 "The <command role=\"hg-ext-mq\">qapplied</command> command prints the current "
937 "stack of applied patches. Patches are printed in oldest-to-newest order, so "
938 "the last patch in the list is the <quote>top</quote> patch."
939 msgstr ""
941 #. type: Content of: <book><appendix><sect1><sect2><title>
942 #: ../en/appB-mq-ref.xml:24
943 msgid ""
944 "<command role=\"hg-ext-mq\">qcommit</command>&emdash;commit changes in the "
945 "queue repository"
946 msgstr "<command role=\"hg-ext-mq\">qcommit</command>—提交队列中的修改"
948 #. type: Content of: <book><appendix><sect1><sect2><para>
949 #: ../en/appB-mq-ref.xml:27
950 msgid ""
951 "The <command role=\"hg-ext-mq\">qcommit</command> command commits any "
952 "outstanding changes in the <filename role=\"special\" class=\"directory\">.hg/"
953 "patches</filename> repository. This command only works if the <filename role="
954 "\"special\" class=\"directory\">.hg/patches</filename> directory is a "
955 "repository, i.e. you created the directory using <command role=\"hg-cmd\">hg "
956 "qinit <option role=\"hg-ext-mq-cmd-qinit-opt\">-c</option></command> or ran "
957 "<command role=\"hg-cmd\">hg init</command> in the directory after running "
958 "<command role=\"hg-ext-mq\">qinit</command>."
959 msgstr ""
961 #. type: Content of: <book><appendix><sect1><sect2><para>
962 #: ../en/appB-mq-ref.xml:39
963 msgid ""
964 "This command is shorthand for <command role=\"hg-cmd\">hg commit --cwd .hg/"
965 "patches</command>."
966 msgstr ""
968 #. type: Content of: <book><appendix><sect1><sect2><title>
969 #: ../en/appB-mq-ref.xml:43
970 msgid ""
971 "<command role=\"hg-ext-mq\">qdelete</command>&emdash;delete a patch from the "
972 "<filename role=\"special\">series</filename> file"
973 msgstr ""
974 "<command role=\"hg-ext-mq\">qdelete</command>—从文件 <filename role=\"special"
975 "\">series</filename> 中删除补丁"
977 #. type: Content of: <book><appendix><sect1><sect2><para>
978 #: ../en/appB-mq-ref.xml:48
979 msgid ""
980 "The <command role=\"hg-ext-mq\">qdelete</command> command removes the entry "
981 "for a patch from the <filename role=\"special\">series</filename> file in the "
982 "<filename role=\"special\" class=\"directory\">.hg/patches</filename> "
983 "directory. It does not pop the patch if the patch is already applied. By "
984 "default, it does not delete the patch file; use the <option role=\"hg-ext-mq-"
985 "cmd-qdel-opt\">-f</option> option to do that."
986 msgstr ""
988 #. type: Content of: <book><appendix><sect1><sect2><para>
989 #: ../en/appB-mq-ref.xml:57 ../en/appB-mq-ref.xml:109 ../en/appB-mq-ref.xml:167
990 #: ../en/appB-mq-ref.xml:207 ../en/appB-mq-ref.xml:274
991 #: ../en/appB-mq-ref.xml:345 ../en/appB-mq-ref.xml:414
992 #: ../en/appB-mq-ref.xml:492
993 msgid "Options:"
994 msgstr "选项:"
996 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
997 #: ../en/appB-mq-ref.xml:59
998 msgid ""
999 "<option role=\"hg-ext-mq-cmd-qdel-opt\">-f</option>: Delete the patch file."
1000 msgstr ""
1002 #. type: Content of: <book><appendix><sect1><sect2><title>
1003 #: ../en/appB-mq-ref.xml:66
1004 msgid ""
1005 "<command role=\"hg-ext-mq\">qdiff</command>&emdash;print a diff of the "
1006 "topmost applied patch"
1007 msgstr "<command role=\"hg-ext-mq\">qdiff</command>—显示最新应用补丁的差异"
1009 #. type: Content of: <book><appendix><sect1><sect2><para>
1010 #: ../en/appB-mq-ref.xml:69
1011 msgid ""
1012 "The <command role=\"hg-ext-mq\">qdiff</command> command prints a diff of the "
1013 "topmost applied patch. It is equivalent to <command role=\"hg-cmd\">hg diff -"
1014 "r-2:-1</command>."
1015 msgstr ""
1017 #. type: Content of: <book><appendix><sect1><sect2><title>
1018 #: ../en/appB-mq-ref.xml:75
1019 msgid ""
1020 "<command role=\"hg-ext-mq\">qfold</command>&emdash;move applied patches into "
1021 "repository history"
1022 msgstr ""
1023 "<command role=\"hg-ext-mq\">qfold</command>&emdash;将已应用的补丁提交到版本库"
1025 #. type: Content of: <book><appendix><sect1><sect2><para>
1026 #: ../en/appB-mq-ref.xml:78
1027 msgid ""
1028 "The <command>hg qfinish</command> command converts the specified applied "
1029 "patches into permanent changes by moving them out of MQ's control so that "
1030 "they will be treated as normal repository history."
1031 msgstr ""
1033 #. type: Content of: <book><appendix><sect1><sect2><title>
1034 #: ../en/appB-mq-ref.xml:85
1035 msgid ""
1036 "<command role=\"hg-ext-mq\">qfold</command>&emdash;merge (<quote>fold</"
1037 "quote>) several patches into one"
1038 msgstr ""
1039 "<command role=\"hg-ext-mq\">qfold</command>—将多个补丁合并(<quote>折叠</"
1040 "quote>)成一个"
1042 #. type: Content of: <book><appendix><sect1><sect2><para>
1043 #: ../en/appB-mq-ref.xml:88
1044 msgid ""
1045 "The <command role=\"hg-ext-mq\">qfold</command> command merges multiple "
1046 "patches into the topmost applied patch, so that the topmost applied patch "
1047 "makes the union of all of the changes in the patches in question."
1048 msgstr ""
1050 #. type: Content of: <book><appendix><sect1><sect2><para>
1051 #: ../en/appB-mq-ref.xml:93
1052 msgid ""
1053 "The patches to fold must not be applied; <command role=\"hg-ext-mq\">qfold</"
1054 "command> will exit with an error if any is. The order in which patches are "
1055 "folded is significant; <command role=\"hg-cmd\">hg qfold a b</command> means "
1056 "<quote>apply the current topmost patch, followed by <literal>a</literal>, "
1057 "followed by <literal>b</literal></quote>."
1058 msgstr ""
1060 #. type: Content of: <book><appendix><sect1><sect2><para>
1061 #: ../en/appB-mq-ref.xml:101
1062 msgid ""
1063 "The comments from the folded patches are appended to the comments of the "
1064 "destination patch, with each block of comments separated by three asterisk "
1065 "(<quote><literal>*</literal></quote>) characters. Use the <option role=\"hg-"
1066 "ext-mq-cmd-qfold-opt\">-e</option> option to edit the commit message for the "
1067 "combined patch/changeset after the folding has completed."
1068 msgstr ""
1070 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1071 #: ../en/appB-mq-ref.xml:111
1072 msgid ""
1073 "<option role=\"hg-ext-mq-cmd-qfold-opt\">-e</option>: Edit the commit message "
1074 "and patch description for the newly folded patch."
1075 msgstr ""
1077 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1078 #: ../en/appB-mq-ref.xml:116
1079 msgid ""
1080 "<option role=\"hg-ext-mq-cmd-qfold-opt\">-l</option>: Use the contents of the "
1081 "given file as the new commit message and patch description for the folded "
1082 "patch."
1083 msgstr ""
1085 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1086 #: ../en/appB-mq-ref.xml:121
1087 msgid ""
1088 "<option role=\"hg-ext-mq-cmd-qfold-opt\">-m</option>: Use the given text as "
1089 "the new commit message and patch description for the folded patch."
1090 msgstr ""
1092 #. type: Content of: <book><appendix><sect1><sect2><title>
1093 #: ../en/appB-mq-ref.xml:129
1094 msgid ""
1095 "<command role=\"hg-ext-mq\">qheader</command>&emdash;display the header/"
1096 "description of a patch"
1097 msgstr "<command role=\"hg-ext-mq\">qheader</command>—显示补丁头部描述"
1099 #. type: Content of: <book><appendix><sect1><sect2><para>
1100 #: ../en/appB-mq-ref.xml:133
1101 msgid ""
1102 "The <command role=\"hg-ext-mq\">qheader</command> command prints the header, "
1103 "or description, of a patch. By default, it prints the header of the topmost "
1104 "applied patch. Given an argument, it prints the header of the named patch."
1105 msgstr ""
1107 #. type: Content of: <book><appendix><sect1><sect2><title>
1108 #: ../en/appB-mq-ref.xml:140
1109 msgid ""
1110 "<command role=\"hg-ext-mq\">qimport</command>&emdash;import a third-party "
1111 "patch into the queue"
1112 msgstr "<command role=\"hg-ext-mq\">qimport</command>—将第三方补丁导入队列"
1114 #. type: Content of: <book><appendix><sect1><sect2><para>
1115 #: ../en/appB-mq-ref.xml:143
1116 msgid ""
1117 "The <command role=\"hg-ext-mq\">qimport</command> command adds an entry for "
1118 "an external patch to the <filename role=\"special\">series</filename> file, "
1119 "and copies the patch into the <filename role=\"special\" class=\"directory\">."
1120 "hg/patches</filename> directory. It adds the entry immediately after the "
1121 "topmost applied patch, but does not push the patch."
1122 msgstr ""
1124 #. type: Content of: <book><appendix><sect1><sect2><para>
1125 #: ../en/appB-mq-ref.xml:151
1126 msgid ""
1127 "If the <filename role=\"special\" class=\"directory\">.hg/patches</filename> "
1128 "directory is a repository, <command role=\"hg-ext-mq\">qimport</command> "
1129 "automatically does an <command role=\"hg-cmd\">hg add</command> of the "
1130 "imported patch."
1131 msgstr ""
1133 #. type: Content of: <book><appendix><sect1><sect2><title>
1134 #: ../en/appB-mq-ref.xml:159
1135 msgid ""
1136 "<command role=\"hg-ext-mq\">qinit</command>&emdash;prepare a repository to "
1137 "work with MQ"
1138 msgstr "<command role=\"hg-ext-mq\">qinit</command>—为使用 MQ 配置版本库"
1140 #. type: Content of: <book><appendix><sect1><sect2><para>
1141 #: ../en/appB-mq-ref.xml:162
1142 msgid ""
1143 "The <command role=\"hg-ext-mq\">qinit</command> command prepares a repository "
1144 "to work with MQ. It creates a directory called <filename role=\"special\" "
1145 "class=\"directory\">.hg/patches</filename>."
1146 msgstr ""
1148 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1149 #: ../en/appB-mq-ref.xml:169
1150 msgid ""
1151 "<option role=\"hg-ext-mq-cmd-qinit-opt\">-c</option>: Create <filename role="
1152 "\"special\" class=\"directory\">.hg/patches</filename> as a repository in its "
1153 "own right. Also creates a <filename role=\"special\">.hgignore</filename> "
1154 "file that will ignore the <filename role=\"special\">status</filename> file."
1155 msgstr ""
1157 #. type: Content of: <book><appendix><sect1><sect2><para>
1158 #: ../en/appB-mq-ref.xml:179
1159 msgid ""
1160 "When the <filename role=\"special\" class=\"directory\">.hg/patches</"
1161 "filename> directory is a repository, the <command role=\"hg-ext-mq\">qimport</"
1162 "command> and <command role=\"hg-ext-mq\">qnew</command> commands "
1163 "automatically <command role=\"hg-cmd\">hg add</command> new patches."
1164 msgstr ""
1166 #. type: Content of: <book><appendix><sect1><sect2><title>
1167 #: ../en/appB-mq-ref.xml:188
1168 msgid "<command role=\"hg-ext-mq\">qnew</command>&emdash;create a new patch"
1169 msgstr "<command role=\"hg-ext-mq\">qnew</command>—创建新补丁"
1171 #. type: Content of: <book><appendix><sect1><sect2><para>
1172 #: ../en/appB-mq-ref.xml:191
1173 msgid ""
1174 "The <command role=\"hg-ext-mq\">qnew</command> command creates a new patch. "
1175 "It takes one mandatory argument, the name to use for the patch file. The "
1176 "newly created patch is created empty by default. It is added to the "
1177 "<filename role=\"special\">series</filename> file after the current topmost "
1178 "applied patch, and is immediately pushed on top of that patch."
1179 msgstr ""
1181 #. type: Content of: <book><appendix><sect1><sect2><para>
1182 #: ../en/appB-mq-ref.xml:199
1183 msgid ""
1184 "If <command role=\"hg-ext-mq\">qnew</command> finds modified files in the "
1185 "working directory, it will refuse to create a new patch unless the <option "
1186 "role=\"hg-ext-mq-cmd-qnew-opt\">-f</option> option is used (see below). This "
1187 "behavior allows you to <command role=\"hg-ext-mq\">qrefresh</command> your "
1188 "topmost applied patch before you apply a new patch on top of it."
1189 msgstr ""
1191 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1192 #: ../en/appB-mq-ref.xml:209
1193 msgid ""
1194 "<option role=\"hg-ext-mq-cmd-qnew-opt\">-f</option>: Create a new patch if "
1195 "the contents of the working directory are modified. Any outstanding "
1196 "modifications are added to the newly created patch, so after this command "
1197 "completes, the working directory will no longer be modified."
1198 msgstr ""
1200 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1201 #: ../en/appB-mq-ref.xml:216
1202 msgid ""
1203 "<option role=\"hg-ext-mq-cmd-qnew-opt\">-m</option>: Use the given text as "
1204 "the commit message. This text will be stored at the beginning of the patch "
1205 "file, before the patch data."
1206 msgstr ""
1208 #. type: Content of: <book><appendix><sect1><sect2><title>
1209 #: ../en/appB-mq-ref.xml:225
1210 msgid ""
1211 "<command role=\"hg-ext-mq\">qnext</command>&emdash;print the name of the next "
1212 "patch"
1213 msgstr "<command role=\"hg-ext-mq\">qnext</command>—显示下个补丁的名称"
1215 #. type: Content of: <book><appendix><sect1><sect2><para>
1216 #: ../en/appB-mq-ref.xml:228
1217 msgid ""
1218 "The <command role=\"hg-ext-mq\">qnext</command> command prints the name name "
1219 "of the next patch in the <filename role=\"special\">series</filename> file "
1220 "after the topmost applied patch. This patch will become the topmost applied "
1221 "patch if you run <command role=\"hg-ext-mq\">qpush</command>."
1222 msgstr ""
1224 #. type: Content of: <book><appendix><sect1><sect2><title>
1225 #: ../en/appB-mq-ref.xml:237
1226 msgid ""
1227 "<command role=\"hg-ext-mq\">qpop</command>&emdash;pop patches off the stack"
1228 msgstr "<command role=\"hg-ext-mq\">qpop</command>—删除堆栈顶部的补丁"
1230 #. type: Content of: <book><appendix><sect1><sect2><para>
1231 #: ../en/appB-mq-ref.xml:240
1232 msgid ""
1233 "The <command role=\"hg-ext-mq\">qpop</command> command removes applied "
1234 "patches from the top of the stack of applied patches. By default, it removes "
1235 "only one patch."
1236 msgstr ""
1238 #. type: Content of: <book><appendix><sect1><sect2><para>
1239 #: ../en/appB-mq-ref.xml:244
1240 msgid ""
1241 "This command removes the changesets that represent the popped patches from "
1242 "the repository, and updates the working directory to undo the effects of the "
1243 "patches."
1244 msgstr ""
1246 #. type: Content of: <book><appendix><sect1><sect2><para>
1247 #: ../en/appB-mq-ref.xml:248
1248 msgid ""
1249 "This command takes an optional argument, which it uses as the name or index "
1250 "of the patch to pop to. If given a name, it will pop patches until the named "
1251 "patch is the topmost applied patch. If given a number, <command role=\"hg-"
1252 "ext-mq\">qpop</command> treats the number as an index into the entries in the "
1253 "series file, counting from zero (empty lines and lines containing only "
1254 "comments do not count). It pops patches until the patch identified by the "
1255 "given index is the topmost applied patch."
1256 msgstr ""
1258 #. type: Content of: <book><appendix><sect1><sect2><para>
1259 #: ../en/appB-mq-ref.xml:258
1260 msgid ""
1261 "The <command role=\"hg-ext-mq\">qpop</command> command does not read or write "
1262 "patches or the <filename role=\"special\">series</filename> file. It is thus "
1263 "safe to <command role=\"hg-ext-mq\">qpop</command> a patch that you have "
1264 "removed from the <filename role=\"special\">series</filename> file, or a "
1265 "patch that you have renamed or deleted entirely. In the latter two cases, "
1266 "use the name of the patch as it was when you applied it."
1267 msgstr ""
1269 #. type: Content of: <book><appendix><sect1><sect2><para>
1270 #: ../en/appB-mq-ref.xml:267
1271 msgid ""
1272 "By default, the <command role=\"hg-ext-mq\">qpop</command> command will not "
1273 "pop any patches if the working directory has been modified. You can override "
1274 "this behavior using the <option role=\"hg-ext-mq-cmd-qpop-opt\">-f</option> "
1275 "option, which reverts all modifications in the working directory."
1276 msgstr ""
1278 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1279 #: ../en/appB-mq-ref.xml:276
1280 msgid ""
1281 "<option role=\"hg-ext-mq-cmd-qpop-opt\">-a</option>: Pop all applied "
1282 "patches. This returns the repository to its state before you applied any "
1283 "patches."
1284 msgstr ""
1286 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1287 #: ../en/appB-mq-ref.xml:281
1288 msgid ""
1289 "<option role=\"hg-ext-mq-cmd-qpop-opt\">-f</option>: Forcibly revert any "
1290 "modifications to the working directory when popping."
1291 msgstr ""
1293 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1294 #: ../en/appB-mq-ref.xml:286
1295 msgid ""
1296 "<option role=\"hg-ext-mq-cmd-qpop-opt\">-n</option>: Pop a patch from the "
1297 "named queue."
1298 msgstr ""
1300 #. type: Content of: <book><appendix><sect1><sect2><para>
1301 #: ../en/appB-mq-ref.xml:291
1302 msgid ""
1303 "The <command role=\"hg-ext-mq\">qpop</command> command removes one line from "
1304 "the end of the <filename role=\"special\">status</filename> file for each "
1305 "patch that it pops."
1306 msgstr ""
1308 #. type: Content of: <book><appendix><sect1><sect2><title>
1309 #: ../en/appB-mq-ref.xml:298
1310 msgid ""
1311 "<command role=\"hg-ext-mq\">qprev</command>&emdash;print the name of the "
1312 "previous patch"
1313 msgstr "<command role=\"hg-ext-mq\">qprev</command>—显示上个补丁的名称"
1315 #. type: Content of: <book><appendix><sect1><sect2><para>
1316 #: ../en/appB-mq-ref.xml:301
1317 msgid ""
1318 "The <command role=\"hg-ext-mq\">qprev</command> command prints the name of "
1319 "the patch in the <filename role=\"special\">series</filename> file that comes "
1320 "before the topmost applied patch. This will become the topmost applied patch "
1321 "if you run <command role=\"hg-ext-mq\">qpop</command>."
1322 msgstr ""
1324 #. type: Content of: <book><appendix><sect1><sect2><title>
1325 #: ../en/appB-mq-ref.xml:310
1326 msgid ""
1327 "<command role=\"hg-ext-mq\">qpush</command>&emdash;push patches onto the stack"
1328 msgstr "<command role=\"hg-ext-mq\">qpush</command>—增加补丁到堆栈"
1330 #. type: Content of: <book><appendix><sect1><sect2><para>
1331 #: ../en/appB-mq-ref.xml:313
1332 msgid ""
1333 "The <command role=\"hg-ext-mq\">qpush</command> command adds patches onto the "
1334 "applied stack. By default, it adds only one patch."
1335 msgstr ""
1337 #. type: Content of: <book><appendix><sect1><sect2><para>
1338 #: ../en/appB-mq-ref.xml:317
1339 msgid ""
1340 "This command creates a new changeset to represent each applied patch, and "
1341 "updates the working directory to apply the effects of the patches."
1342 msgstr ""
1344 #. type: Content of: <book><appendix><sect1><sect2><para>
1345 #: ../en/appB-mq-ref.xml:321
1346 msgid "The default data used when creating a changeset are as follows:"
1347 msgstr ""
1349 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1350 #: ../en/appB-mq-ref.xml:324
1351 msgid ""
1352 "The commit date and time zone are the current date and time zone. Because "
1353 "these data are used to compute the identity of a changeset, this means that "
1354 "if you <command role=\"hg-ext-mq\">qpop</command> a patch and <command role="
1355 "\"hg-ext-mq\">qpush</command> it again, the changeset that you push will have "
1356 "a different identity than the changeset you popped."
1357 msgstr ""
1359 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1360 #: ../en/appB-mq-ref.xml:332
1361 msgid ""
1362 "The author is the same as the default used by the <command role=\"hg-cmd\">hg "
1363 "commit</command> command."
1364 msgstr ""
1366 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1367 #: ../en/appB-mq-ref.xml:336
1368 msgid ""
1369 "The commit message is any text from the patch file that comes before the "
1370 "first diff header. If there is no such text, a default commit message is "
1371 "used that identifies the name of the patch."
1372 msgstr ""
1374 #. type: Content of: <book><appendix><sect1><sect2><para>
1375 #: ../en/appB-mq-ref.xml:341
1376 msgid ""
1377 "If a patch contains a Mercurial patch header, the information in the patch "
1378 "header overrides these defaults."
1379 msgstr ""
1381 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1382 #: ../en/appB-mq-ref.xml:347
1383 msgid ""
1384 "<option role=\"hg-ext-mq-cmd-qpush-opt\">-a</option>: Push all unapplied "
1385 "patches from the <filename role=\"special\">series</filename> file until "
1386 "there are none left to push."
1387 msgstr ""
1389 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1390 #: ../en/appB-mq-ref.xml:353
1391 msgid ""
1392 "<option role=\"hg-ext-mq-cmd-qpush-opt\">-l</option>: Add the name of the "
1393 "patch to the end of the commit message."
1394 msgstr ""
1396 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1397 #: ../en/appB-mq-ref.xml:357
1398 msgid ""
1399 "<option role=\"hg-ext-mq-cmd-qpush-opt\">-m</option>: If a patch fails to "
1400 "apply cleanly, use the entry for the patch in another saved queue to compute "
1401 "the parameters for a three-way merge, and perform a three-way merge using the "
1402 "normal Mercurial merge machinery. Use the resolution of the merge as the new "
1403 "patch content."
1404 msgstr ""
1406 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1407 #: ../en/appB-mq-ref.xml:365
1408 msgid ""
1409 "<option role=\"hg-ext-mq-cmd-qpush-opt\">-n</option>: Use the named queue if "
1410 "merging while pushing."
1411 msgstr ""
1413 #. type: Content of: <book><appendix><sect1><sect2><para>
1414 #: ../en/appB-mq-ref.xml:370
1415 msgid ""
1416 "The <command role=\"hg-ext-mq\">qpush</command> command reads, but does not "
1417 "modify, the <filename role=\"special\">series</filename> file. It appends "
1418 "one line to the <command role=\"hg-cmd\">hg status</command> file for each "
1419 "patch that it pushes."
1420 msgstr ""
1422 #. type: Content of: <book><appendix><sect1><sect2><title>
1423 #: ../en/appB-mq-ref.xml:378
1424 msgid ""
1425 "<command role=\"hg-ext-mq\">qrefresh</command>&emdash;update the topmost "
1426 "applied patch"
1427 msgstr "<command role=\"hg-ext-mq\">qrefresh</command>—更新最新的补丁"
1429 #. type: Content of: <book><appendix><sect1><sect2><para>
1430 #: ../en/appB-mq-ref.xml:382
1431 msgid ""
1432 "The <command role=\"hg-ext-mq\">qrefresh</command> command updates the "
1433 "topmost applied patch. It modifies the patch, removes the old changeset that "
1434 "represented the patch, and creates a new changeset to represent the modified "
1435 "patch."
1436 msgstr ""
1438 #. type: Content of: <book><appendix><sect1><sect2><para>
1439 #: ../en/appB-mq-ref.xml:388
1440 msgid ""
1441 "The <command role=\"hg-ext-mq\">qrefresh</command> command looks for the "
1442 "following modifications:"
1443 msgstr ""
1445 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1446 #: ../en/appB-mq-ref.xml:391
1447 msgid ""
1448 "Changes to the commit message, i.e. the text before the first diff header in "
1449 "the patch file, are reflected in the new changeset that represents the patch."
1450 msgstr ""
1452 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1453 #: ../en/appB-mq-ref.xml:396
1454 msgid ""
1455 "Modifications to tracked files in the working directory are added to the "
1456 "patch."
1457 msgstr ""
1459 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1460 #: ../en/appB-mq-ref.xml:399
1461 msgid ""
1462 "Changes to the files tracked using <command role=\"hg-cmd\">hg add</command>, "
1463 "<command role=\"hg-cmd\">hg copy</command>, <command role=\"hg-cmd\">hg "
1464 "remove</command>, or <command role=\"hg-cmd\">hg rename</command>. Added "
1465 "files and copy and rename destinations are added to the patch, while removed "
1466 "files and rename sources are removed."
1467 msgstr ""
1469 #. type: Content of: <book><appendix><sect1><sect2><para>
1470 #: ../en/appB-mq-ref.xml:408
1471 msgid ""
1472 "Even if <command role=\"hg-ext-mq\">qrefresh</command> detects no changes, it "
1473 "still recreates the changeset that represents the patch. This causes the "
1474 "identity of the changeset to differ from the previous changeset that "
1475 "identified the patch."
1476 msgstr ""
1478 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1479 #: ../en/appB-mq-ref.xml:416
1480 msgid ""
1481 "<option role=\"hg-ext-mq-cmd-qrefresh-opt\">-e</option>: Modify the commit "
1482 "and patch description, using the preferred text editor."
1483 msgstr ""
1485 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1486 #: ../en/appB-mq-ref.xml:421
1487 msgid ""
1488 "<option role=\"hg-ext-mq-cmd-qrefresh-opt\">-m</option>: Modify the commit "
1489 "message and patch description, using the given text."
1490 msgstr ""
1492 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1493 #: ../en/appB-mq-ref.xml:426
1494 msgid ""
1495 "<option role=\"hg-ext-mq-cmd-qrefresh-opt\">-l</option>: Modify the commit "
1496 "message and patch description, using text from the given file."
1497 msgstr ""
1499 #. type: Content of: <book><appendix><sect1><sect2><title>
1500 #: ../en/appB-mq-ref.xml:434
1501 msgid "<command role=\"hg-ext-mq\">qrename</command>&emdash;rename a patch"
1502 msgstr "<command role=\"hg-ext-mq\">qrename</command>—改名补丁"
1504 #. type: Content of: <book><appendix><sect1><sect2><para>
1505 #: ../en/appB-mq-ref.xml:437
1506 msgid ""
1507 "The <command role=\"hg-ext-mq\">qrename</command> command renames a patch, "
1508 "and changes the entry for the patch in the <filename role=\"special\">series</"
1509 "filename> file."
1510 msgstr ""
1512 #. type: Content of: <book><appendix><sect1><sect2><para>
1513 #: ../en/appB-mq-ref.xml:441
1514 msgid ""
1515 "With a single argument, <command role=\"hg-ext-mq\">qrename</command> renames "
1516 "the topmost applied patch. With two arguments, it renames its first argument "
1517 "to its second."
1518 msgstr ""
1520 #. type: Content of: <book><appendix><sect1><sect2><title>
1521 #: ../en/appB-mq-ref.xml:448
1522 msgid ""
1523 "<command role=\"hg-ext-mq\">qseries</command>&emdash;print the entire patch "
1524 "series"
1525 msgstr "<command role=\"hg-ext-mq\">qseries</command>—显示补丁序列"
1527 #. type: Content of: <book><appendix><sect1><sect2><para>
1528 #: ../en/appB-mq-ref.xml:451
1529 msgid ""
1530 "The <command role=\"hg-ext-mq\">qseries</command> command prints the entire "
1531 "patch series from the <filename role=\"special\">series</filename> file. It "
1532 "prints only patch names, not empty lines or comments. It prints in order "
1533 "from first to be applied to last."
1534 msgstr ""
1536 #. type: Content of: <book><appendix><sect1><sect2><title>
1537 #: ../en/appB-mq-ref.xml:459
1538 msgid ""
1539 "<command role=\"hg-ext-mq\">qtop</command>&emdash;print the name of the "
1540 "current patch"
1541 msgstr "<command role=\"hg-ext-mq\">qtop</command>—显示当前补丁的名称"
1543 #. type: Content of: <book><appendix><sect1><sect2><para>
1544 #: ../en/appB-mq-ref.xml:462
1545 msgid ""
1546 "The <command role=\"hg-ext-mq\">qtop</command> prints the name of the topmost "
1547 "currently applied patch."
1548 msgstr ""
1550 #. type: Content of: <book><appendix><sect1><sect2><title>
1551 #: ../en/appB-mq-ref.xml:467
1552 msgid ""
1553 "<command role=\"hg-ext-mq\">qunapplied</command>&emdash;print patches not yet "
1554 "applied"
1555 msgstr "<command role=\"hg-ext-mq\">qunapplied</command>—显示尚未应用的补丁"
1557 #. type: Content of: <book><appendix><sect1><sect2><para>
1558 #: ../en/appB-mq-ref.xml:471
1559 msgid ""
1560 "The <command role=\"hg-ext-mq\">qunapplied</command> command prints the names "
1561 "of patches from the <filename role=\"special\">series</filename> file that "
1562 "are not yet applied. It prints them in order from the next patch that will "
1563 "be pushed to the last."
1564 msgstr ""
1566 #. type: Content of: <book><appendix><sect1><sect2><title>
1567 #: ../en/appB-mq-ref.xml:479
1568 msgid ""
1569 "<command role=\"hg-cmd\">hg strip</command>&emdash;remove a revision and "
1570 "descendants"
1571 msgstr "<command role=\"hg-cmd\">hg strip</command>—删除一个版本及其后继"
1573 #. type: Content of: <book><appendix><sect1><sect2><para>
1574 #: ../en/appB-mq-ref.xml:482
1575 msgid ""
1576 "The <command role=\"hg-cmd\">hg strip</command> command removes a revision, "
1577 "and all of its descendants, from the repository. It undoes the effects of "
1578 "the removed revisions from the repository, and updates the working directory "
1579 "to the first parent of the removed revision."
1580 msgstr ""
1582 #. type: Content of: <book><appendix><sect1><sect2><para>
1583 #: ../en/appB-mq-ref.xml:488
1584 msgid ""
1585 "The <command role=\"hg-cmd\">hg strip</command> command saves a backup of the "
1586 "removed changesets in a bundle, so that they can be reapplied if removed in "
1587 "error."
1588 msgstr ""
1590 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1591 #: ../en/appB-mq-ref.xml:494
1592 msgid ""
1593 "<option role=\"hg-opt-strip\">-b</option>: Save unrelated changesets that are "
1594 "intermixed with the stripped changesets in the backup bundle."
1595 msgstr ""
1597 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1598 #: ../en/appB-mq-ref.xml:498
1599 msgid ""
1600 "<option role=\"hg-opt-strip\">-f</option>: If a branch has multiple heads, "
1601 "remove all heads."
1602 msgstr ""
1604 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
1605 #: ../en/appB-mq-ref.xml:501
1606 msgid "<option role=\"hg-opt-strip\">-n</option>: Do not save a backup bundle."
1607 msgstr ""
1609 #. type: Content of: <book><appendix><sect1><title>
1610 #: ../en/appB-mq-ref.xml:508
1611 msgid "MQ file reference"
1612 msgstr "MQ 文件参考"
1614 #. type: Content of: <book><appendix><sect1><sect2><title>
1615 #: ../en/appB-mq-ref.xml:511
1616 msgid "The <filename role=\"special\">series</filename> file"
1617 msgstr "<filename role=\"special\">序列</filename>文件"
1619 #. type: Content of: <book><appendix><sect1><sect2><para>
1620 #: ../en/appB-mq-ref.xml:514
1621 msgid ""
1622 "The <filename role=\"special\">series</filename> file contains a list of the "
1623 "names of all patches that MQ can apply. It is represented as a list of "
1624 "names, with one name saved per line. Leading and trailing white space in "
1625 "each line are ignored."
1626 msgstr ""
1628 #. type: Content of: <book><appendix><sect1><sect2><para>
1629 #: ../en/appB-mq-ref.xml:520
1630 msgid ""
1631 "Lines may contain comments. A comment begins with the <quote><literal>#</"
1632 "literal></quote> character, and extends to the end of the line. Empty lines, "
1633 "and lines that contain only comments, are ignored."
1634 msgstr ""
1636 #. type: Content of: <book><appendix><sect1><sect2><para>
1637 #: ../en/appB-mq-ref.xml:525
1638 msgid ""
1639 "You will often need to edit the <filename role=\"special\">series</filename> "
1640 "file by hand, hence the support for comments and empty lines noted above. "
1641 "For example, you can comment out a patch temporarily, and <command role=\"hg-"
1642 "ext-mq\">qpush</command> will skip over that patch when applying patches. "
1643 "You can also change the order in which patches are applied by reordering "
1644 "their entries in the <filename role=\"special\">series</filename> file."
1645 msgstr ""
1647 #. type: Content of: <book><appendix><sect1><sect2><para>
1648 #: ../en/appB-mq-ref.xml:534
1649 msgid ""
1650 "Placing the <filename role=\"special\">series</filename> file under revision "
1651 "control is also supported; it is a good idea to place all of the patches that "
1652 "it refers to under revision control, as well. If you create a patch "
1653 "directory using the <option role=\"hg-ext-mq-cmd-qinit-opt\">-c</option> "
1654 "option to <command role=\"hg-ext-mq\">qinit</command>, this will be done for "
1655 "you automatically."
1656 msgstr ""
1658 #. type: Content of: <book><appendix><sect1><sect2><title>
1659 #: ../en/appB-mq-ref.xml:544
1660 msgid "The <filename role=\"special\">status</filename> file"
1661 msgstr "<filename role=\"special\">状态</filename>文件"
1663 #. type: Content of: <book><appendix><sect1><sect2><para>
1664 #: ../en/appB-mq-ref.xml:547
1665 msgid ""
1666 "The <filename role=\"special\">status</filename> file contains the names and "
1667 "changeset hashes of all patches that MQ currently has applied. Unlike the "
1668 "<filename role=\"special\">series</filename> file, this file is not intended "
1669 "for editing. You should not place this file under revision control, or "
1670 "modify it in any way. It is used by MQ strictly for internal book-keeping."
1671 msgstr ""
1673 #. type: Content of: <book><appendix><title>
1674 #: ../en/appC-srcinstall.xml:5
1675 msgid "Installing Mercurial from source"
1676 msgstr "从源代码安装 Mercurial"
1678 #. type: Content of: <book><appendix><sect1><title>
1679 #: ../en/appC-srcinstall.xml:8
1680 msgid "On a Unix-like system"
1681 msgstr "类 Unix 系统"
1683 #. type: Content of: <book><appendix><sect1><para>
1684 #: ../en/appC-srcinstall.xml:10
1685 msgid ""
1686 "If you are using a Unix-like system that has a sufficiently recent version of "
1687 "Python (2.3 or newer) available, it is easy to install Mercurial from source."
1688 msgstr ""
1689 "如果你使用类 Unix 系统,并且有足够新的 Python (2.3 更新),从源代码安装 "
1690 "Mercurial 就很容易了。"
1692 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1693 #: ../en/appC-srcinstall.xml:14
1694 msgid ""
1695 "Download a recent source tarball from <ulink url=\"http://www.selenic.com/"
1696 "mercurial/download\">http://www.selenic.com/mercurial/download</ulink>."
1697 msgstr ""
1698 "从 <ulink url=\"http://www.selenic.com/mercurial/download\">http://www."
1699 "selenic.com/mercurial/download</ulink> 下载最新的源代码。"
1701 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1702 #: ../en/appC-srcinstall.xml:17
1703 msgid "Unpack the tarball:"
1704 msgstr "解压:"
1706 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1707 #: ../en/appC-srcinstall.xml:20
1708 msgid ""
1709 "Go into the source directory and run the installer script. This will build "
1710 "Mercurial and install it in your home directory."
1711 msgstr "进入源代码目录,执行安装教本。这会构建 Mercurial,安装到你的家目录。"
1713 #. type: Content of: <book><appendix><sect1><para>
1714 #: ../en/appC-srcinstall.xml:27
1715 msgid ""
1716 "Once the install finishes, Mercurial will be in the <literal>bin</literal> "
1717 "subdirectory of your home directory. Don't forget to make sure that this "
1718 "directory is present in your shell's search path."
1719 msgstr ""
1720 "安装完成后,Mercurial 就位于家目录的 <literal>bin</literal> 子目录。不要忘记将"
1721 "这个目录加入到你的可执行文件搜索路径中。"
1723 #. type: Content of: <book><appendix><sect1><para>
1724 #: ../en/appC-srcinstall.xml:32
1725 msgid ""
1726 "You will probably need to set the <envar>PYTHONPATH</envar> environment "
1727 "variable so that the Mercurial executable can find the rest of the Mercurial "
1728 "packages. For example, on my laptop, I have set it to <literal>/home/bos/lib/"
1729 "python</literal>. The exact path that you will need to use depends on how "
1730 "Python was built for your system, but should be easy to figure out. If "
1731 "you're uncertain, look through the output of the installer script above, and "
1732 "see where the contents of the <literal>mercurial</literal> directory were "
1733 "installed to."
1734 msgstr ""
1735 "你可能需要设置环境变量 <envar>PYTHONPATH</envar>,以便 Mercurial 可执行文件能"
1736 "找到 Mercurial 包。例如,在我的笔记本电脑中,必须设置为 <literal>/home/bos/"
1737 "lib/python</literal>。你需要使用的路径依赖于 Python 的构建方式,这很容易找出"
1738 "来。如果你不确定,仔细察看上面的安装脚本输出,检查包含 <literal>mercurial</"
1739 "literal> 目录的内容的安装位置。"
1741 #. type: Content of: <book><appendix><sect1><title>
1742 #: ../en/appC-srcinstall.xml:44
1743 msgid "On Windows"
1744 msgstr "Windows 系统"
1746 #. type: Content of: <book><appendix><sect1><para>
1747 #: ../en/appC-srcinstall.xml:46
1748 msgid ""
1749 "Building and installing Mercurial on Windows requires a variety of tools, a "
1750 "fair amount of technical knowledge, and considerable patience. I very much "
1751 "<emphasis>do not recommend</emphasis> this route if you are a <quote>casual "
1752 "user</quote>. Unless you intend to hack on Mercurial, I strongly suggest "
1753 "that you use a binary package instead."
1754 msgstr ""
1755 "在 Windows 中构建和安装 Mercurial 需要各种工具,相当多的技术背景,以及足够的耐"
1756 "心。如果你是一个<quote>初级用户</quote>,我<emphasis>很不赞成</emphasis>这个方"
1757 "法。我强烈建议你使用二进制安装包,除非你想深入研究 Mercurial 本身。"
1759 #. type: Content of: <book><appendix><sect1><para>
1760 #: ../en/appC-srcinstall.xml:53
1761 msgid ""
1762 "If you are intent on building Mercurial from source on Windows, follow the "
1763 "<quote>hard way</quote> directions on the Mercurial wiki at <ulink url="
1764 "\"http://www.selenic.com/mercurial/wiki/index.cgi/WindowsInstall\">http://www."
1765 "selenic.com/mercurial/wiki/index.cgi/WindowsInstall</ulink>, and expect the "
1766 "process to involve a lot of fiddly work."
1767 msgstr ""
1768 "If you are intent on building Mercurial from source on Windows, follow the "
1769 "<quote>hard way</quote> directions on the Mercurial wiki at <ulink url="
1770 "\"http://www.selenic.com/mercurial/wiki/index.cgi/WindowsInstall\">http://www."
1771 "selenic.com/mercurial/wiki/index.cgi/WindowsInstall</ulink>, and expect the "
1772 "process to involve a lot of fiddly work."
1774 #. type: Content of: <book><appendix><title>
1775 #: ../en/appD-license.xml:5
1776 msgid "Open Publication License"
1777 msgstr "开放出版协议"
1779 #. type: Content of: <book><appendix><para>
1780 #: ../en/appD-license.xml:7
1781 msgid "Version 1.0, 8 June 1999"
1782 msgstr "版本 1.0,1999 年 6 月 8 日。"
1784 #. type: Content of: <book><appendix><sect1><title>
1785 #: ../en/appD-license.xml:10
1786 msgid "Requirements on both unmodified and modified versions"
1787 msgstr ""
1789 #. type: Content of: <book><appendix><sect1><para>
1790 #: ../en/appD-license.xml:13
1791 msgid ""
1792 "The Open Publication works may be reproduced and distributed in whole or in "
1793 "part, in any medium physical or electronic, provided that the terms of this "
1794 "license are adhered to, and that this license or an incorporation of it by "
1795 "reference (with any options elected by the author(s) and/or publisher) is "
1796 "displayed in the reproduction."
1797 msgstr ""
1799 #. type: Content of: <book><appendix><sect1><para>
1800 #: ../en/appD-license.xml:20
1801 msgid "Proper form for an incorporation by reference is as follows:"
1802 msgstr ""
1804 #. type: Content of: <book><appendix><sect1><blockquote><para>
1805 #: ../en/appD-license.xml:24
1806 msgid ""
1807 "Copyright (c) <emphasis>year</emphasis> by <emphasis>author's name or "
1808 "designee</emphasis>. This material may be distributed only subject to the "
1809 "terms and conditions set forth in the Open Publication License, v<emphasis>x."
1810 "y</emphasis> or later (the latest version is presently available at <ulink "
1811 "url=\"http://www.opencontent.org/openpub/\">http://www.opencontent.org/"
1812 "openpub/</ulink>)."
1813 msgstr ""
1815 #. type: Content of: <book><appendix><sect1><para>
1816 #: ../en/appD-license.xml:33
1817 msgid ""
1818 "The reference must be immediately followed with any options elected by the "
1819 "author(s) and/or publisher of the document (see <xref linkend=\"sec:opl:"
1820 "options\"/>)."
1821 msgstr ""
1823 #. type: Content of: <book><appendix><sect1><para>
1824 #: ../en/appD-license.xml:37
1825 msgid ""
1826 "Commercial redistribution of Open Publication-licensed material is permitted."
1827 msgstr ""
1829 #. type: Content of: <book><appendix><sect1><para>
1830 #: ../en/appD-license.xml:40
1831 msgid ""
1832 "Any publication in standard (paper) book form shall require the citation of "
1833 "the original publisher and author. The publisher and author's names shall "
1834 "appear on all outer surfaces of the book. On all outer surfaces of the book "
1835 "the original publisher's name shall be as large as the title of the work and "
1836 "cited as possessive with respect to the title."
1837 msgstr ""
1839 #. type: Content of: <book><appendix><sect1><title>
1840 #: ../en/appD-license.xml:49
1841 msgid "Copyright"
1842 msgstr ""
1844 #. type: Content of: <book><appendix><sect1><para>
1845 #: ../en/appD-license.xml:51
1846 msgid ""
1847 "The copyright to each Open Publication is owned by its author(s) or designee."
1848 msgstr ""
1850 #. type: Content of: <book><appendix><sect1><title>
1851 #: ../en/appD-license.xml:56
1852 msgid "Scope of license"
1853 msgstr ""
1855 #. type: Content of: <book><appendix><sect1><para>
1856 #: ../en/appD-license.xml:58
1857 msgid ""
1858 "The following license terms apply to all Open Publication works, unless "
1859 "otherwise explicitly stated in the document."
1860 msgstr ""
1862 #. type: Content of: <book><appendix><sect1><para>
1863 #: ../en/appD-license.xml:62
1864 msgid ""
1865 "Mere aggregation of Open Publication works or a portion of an Open "
1866 "Publication work with other works or programs on the same media shall not "
1867 "cause this license to apply to those other works. The aggregate work shall "
1868 "contain a notice specifying the inclusion of the Open Publication material "
1869 "and appropriate copyright notice."
1870 msgstr ""
1872 #. type: Content of: <book><appendix><sect1><para>
1873 #: ../en/appD-license.xml:69
1874 msgid ""
1875 "<emphasis role=\"bold\">Severability</emphasis>. If any part of this license "
1876 "is found to be unenforceable in any jurisdiction, the remaining portions of "
1877 "the license remain in force."
1878 msgstr ""
1880 #. type: Content of: <book><appendix><sect1><para>
1881 #: ../en/appD-license.xml:74
1882 msgid ""
1883 "<emphasis role=\"bold\">No warranty</emphasis>. Open Publication works are "
1884 "licensed and provided <quote>as is</quote> without warranty of any kind, "
1885 "express or implied, including, but not limited to, the implied warranties of "
1886 "merchantability and fitness for a particular purpose or a warranty of non-"
1887 "infringement."
1888 msgstr ""
1890 #. type: Content of: <book><appendix><sect1><title>
1891 #: ../en/appD-license.xml:83
1892 msgid "Requirements on modified works"
1893 msgstr ""
1895 #. type: Content of: <book><appendix><sect1><para>
1896 #: ../en/appD-license.xml:85
1897 msgid ""
1898 "All modified versions of documents covered by this license, including "
1899 "translations, anthologies, compilations and partial documents, must meet the "
1900 "following requirements:"
1901 msgstr ""
1903 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1904 #: ../en/appD-license.xml:90
1905 msgid "The modified version must be labeled as such."
1906 msgstr ""
1908 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1909 #: ../en/appD-license.xml:93
1910 msgid ""
1911 "The person making the modifications must be identified and the modifications "
1912 "dated."
1913 msgstr ""
1915 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1916 #: ../en/appD-license.xml:96
1917 msgid ""
1918 "Acknowledgement of the original author and publisher if applicable must be "
1919 "retained according to normal academic citation practices."
1920 msgstr ""
1922 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1923 #: ../en/appD-license.xml:100
1924 msgid "The location of the original unmodified document must be identified."
1925 msgstr ""
1927 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1928 #: ../en/appD-license.xml:103
1929 msgid ""
1930 "The original author's (or authors') name(s) may not be used to assert or "
1931 "imply endorsement of the resulting document without the original author's (or "
1932 "authors') permission."
1933 msgstr ""
1935 #. type: Content of: <book><appendix><sect1><title>
1936 #: ../en/appD-license.xml:111
1937 msgid "Good-practice recommendations"
1938 msgstr ""
1940 #. type: Content of: <book><appendix><sect1><para>
1941 #: ../en/appD-license.xml:113
1942 msgid ""
1943 "In addition to the requirements of this license, it is requested from and "
1944 "strongly recommended of redistributors that:"
1945 msgstr ""
1947 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1948 #: ../en/appD-license.xml:118
1949 msgid ""
1950 "If you are distributing Open Publication works on hardcopy or CD-ROM, you "
1951 "provide email notification to the authors of your intent to redistribute at "
1952 "least thirty days before your manuscript or media freeze, to give the authors "
1953 "time to provide updated documents. This notification should describe "
1954 "modifications, if any, made to the document."
1955 msgstr ""
1957 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1958 #: ../en/appD-license.xml:125
1959 msgid ""
1960 "All substantive modifications (including deletions) be either clearly marked "
1961 "up in the document or else described in an attachment to the document."
1962 msgstr ""
1964 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1965 #: ../en/appD-license.xml:129
1966 msgid ""
1967 "Finally, while it is not mandatory under this license, it is considered good "
1968 "form to offer a free copy of any hardcopy and CD-ROM expression of an Open "
1969 "Publication-licensed work to its author(s)."
1970 msgstr ""
1972 #. type: Content of: <book><appendix><sect1><title>
1973 #: ../en/appD-license.xml:137
1974 msgid "License options"
1975 msgstr ""
1977 #. type: Content of: <book><appendix><sect1><para>
1978 #: ../en/appD-license.xml:139
1979 msgid ""
1980 "The author(s) and/or publisher of an Open Publication-licensed document may "
1981 "elect certain options by appending language to the reference to or copy of "
1982 "the license. These options are considered part of the license instance and "
1983 "must be included with the license (or its incorporation by reference) in "
1984 "derived works."
1985 msgstr ""
1987 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1988 #: ../en/appD-license.xml:147
1989 msgid ""
1990 "To prohibit distribution of substantively modified versions without the "
1991 "explicit permission of the author(s). <quote>Substantive modification</quote> "
1992 "is defined as a change to the semantic content of the document, and excludes "
1993 "mere changes in format or typographical corrections."
1994 msgstr ""
1996 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1997 #: ../en/appD-license.xml:154
1998 msgid ""
1999 "To accomplish this, add the phrase <quote>Distribution of substantively "
2000 "modified versions of this document is prohibited without the explicit "
2001 "permission of the copyright holder.</quote> to the license reference or copy."
2002 msgstr ""
2004 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
2005 #: ../en/appD-license.xml:160
2006 msgid ""
2007 "To prohibit any publication of this work or derivative works in whole or in "
2008 "part in standard (paper) book form for commercial purposes is prohibited "
2009 "unless prior permission is obtained from the copyright holder."
2010 msgstr ""
2012 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
2013 #: ../en/appD-license.xml:165
2014 msgid ""
2015 "To accomplish this, add the phrase <quote>Distribution of the work or "
2016 "derivative of the work in any standard (paper) book form is prohibited unless "
2017 "prior permission is obtained from the copyright holder.</quote> to the "
2018 "license reference or copy."
2019 msgstr ""
2021 #. type: Content of: <book><preface><title>
2022 #: ../en/ch00-preface.xml:5
2023 msgid "Preface"
2024 msgstr "序言"
2026 #. type: Content of: <book><preface><sect1><title>
2027 #: ../en/ch00-preface.xml:8
2028 msgid "Technical storytelling"
2029 msgstr "技术背景"
2031 #. type: Content of: <book><preface><sect1><para>
2032 #: ../en/ch00-preface.xml:10
2033 msgid ""
2034 "A few years ago, when I wanted to explain why I believed that distributed "
2035 "revision control is important, the field was then so new that there was "
2036 "almost no published literature to refer people to."
2037 msgstr ""
2039 #. type: Content of: <book><preface><sect1><para>
2040 #: ../en/ch00-preface.xml:15
2041 msgid ""
2042 "Although at that time I spent some time working on the internals of Mercurial "
2043 "itself, I switched to writing this book because that seemed like the most "
2044 "effective way to help the software to reach a wide audience, along with the "
2045 "idea that revision control ought to be distributed in nature. I publish the "
2046 "book online under a liberal license for the same reason: to get the word out."
2047 msgstr ""
2049 #. type: Content of: <book><preface><sect1><para>
2050 #: ../en/ch00-preface.xml:23
2051 msgid ""
2052 "There's a familiar rhythm to a good software book that closely resembles "
2053 "telling a story: What is this thing? Why does it matter? How will it help me? "
2054 "How do I use it? In this book, I try to answer those questions for "
2055 "distributed revision control in general, and for Mercurial in particular."
2056 msgstr ""
2058 #. type: Content of: <book><preface><sect1><title>
2059 #: ../en/ch00-preface.xml:31
2060 msgid "Thank you for supporting Mercurial"
2061 msgstr "谢谢你支持 Mercurial"
2063 #. type: Content of: <book><preface><sect1><para>
2064 #: ../en/ch00-preface.xml:33
2065 msgid ""
2066 "By purchasing a copy of this book, you are supporting the continued "
2067 "development and freedom of Mercurial in particular, and of open source and "
2068 "free software in general. O'Reilly Media and I are donating my royalties on "
2069 "the sales of this book to the Software Freedom Conservancy (<ulink url="
2070 "\"http://www.softwarefreedom.org/\">http://www.softwarefreedom.org/</ulink>) "
2071 "which provides clerical and legal support to Mercurial and a number of other "
2072 "prominent and worthy open source software projects."
2073 msgstr ""
2075 #. type: Content of: <book><preface><sect1><title>
2076 #: ../en/ch00-preface.xml:45
2077 msgid "Acknowledgments"
2078 msgstr "致谢"
2080 #. type: Content of: <book><preface><sect1><para>
2081 #: ../en/ch00-preface.xml:47
2082 msgid ""
2083 "This book would not exist were it not for the efforts of Matt Mackall, the "
2084 "author and project lead of Mercurial. He is ably assisted by hundreds of "
2085 "volunteer contributors across the world."
2086 msgstr ""
2088 #. type: Content of: <book><preface><sect1><para>
2089 #: ../en/ch00-preface.xml:52
2090 msgid ""
2091 "My children, Cian and Ruairi, always stood ready to help me to unwind with "
2092 "wonderful, madcap little-boy games. I'd also like to thank my ex-wife, "
2093 "Shannon, for her support."
2094 msgstr ""
2096 #. type: Content of: <book><preface><sect1><para>
2097 #: ../en/ch00-preface.xml:56
2098 msgid ""
2099 "My colleagues and friends provided help and support in innumerable ways. "
2100 "This list of people is necessarily very incomplete: Stephen Hahn, Karyn "
2101 "Ritter, Bonnie Corwin, James Vasile, Matt Norwood, Eben Moglen, Bradley Kuhn, "
2102 "Robert Walsh, Jeremy Fitzhardinge, Rachel Chalmers."
2103 msgstr ""
2105 #. type: Content of: <book><preface><sect1><para>
2106 #: ../en/ch00-preface.xml:62
2107 msgid ""
2108 "I developed this book in the open, posting drafts of chapters to the book web "
2109 "site as I completed them. Readers then submitted feedback using a web "
2110 "application that I developed. By the time I finished writing the book, more "
2111 "than 100 people had submitted comments, an amazing number considering that "
2112 "the comment system was live for only about two months towards the end of the "
2113 "writing process."
2114 msgstr ""
2116 #. type: Content of: <book><preface><sect1><para>
2117 #: ../en/ch00-preface.xml:70
2118 msgid ""
2119 "I would particularly like to recognize the following people, who between them "
2120 "contributed over a third of the total number of comments. I would like to "
2121 "thank them for their care and effort in providing so much detailed feedback."
2122 msgstr ""
2124 #. type: Content of: <book><preface><sect1><para>
2125 #: ../en/ch00-preface.xml:75
2126 msgid ""
2127 "Martin Geisler, Damien Cassou, Alexey Bakhirkin, Till Plewe, Dan Himes, Paul "
2128 "Sargent, Gokberk Hamurcu, Matthijs van der Vleuten, Michael Chermside, John "
2129 "Mulligan, Jordi Fita, Jon Parise."
2130 msgstr ""
2132 #. type: Content of: <book><preface><sect1><para>
2133 #: ../en/ch00-preface.xml:80
2134 msgid ""
2135 "I also want to acknowledge the help of the many people who caught errors and "
2136 "provided helpful suggestions throughout the book."
2137 msgstr ""
2139 #. type: Content of: <book><preface><sect1><para>
2140 #: ../en/ch00-preface.xml:84
2141 msgid ""
2142 "Jeremy W. Sherman, Brian Mearns, Vincent Furia, Iwan Luijks, Billy Edwards, "
2143 "Andreas Sliwka, Paweł Sołyga, Eric Hanchrow, Steve Nicolai, Michał Masłowski, "
2144 "Kevin Fitch, Johan Holmberg, Hal Wine, Volker Simonis, Thomas P Jakobsen, Ted "
2145 "Stresen-Reuter, Stephen Rasku, Raphael Das Gupta, Ned Batchelder, Lou Keeble, "
2146 "Li Linxiao, Kao Cardoso Félix, Joseph Wecker, Jon Prescot, Jon Maken, John "
2147 "Yeary, Jason Harris, Geoffrey Zheng, Fredrik Jonson, Ed Davies, David "
2148 "Zumbrunnen, David Mercer, David Cabana, Ben Karel, Alan Franzoni, Yousry "
2149 "Abdallah, Whitney Young, Vinay Sajip, Tom Towle, Tim Ottinger, Thomas "
2150 "Schraitle, Tero Saarni, Ted Mielczarek, Svetoslav Agafonkin, Shaun Rowland, "
2151 "Rocco Rutte, Polo-Francois Poli, Philip Jenvey, Petr Tesałék, Peter R. "
2152 "Annema, Paul Bonser, Olivier Scherler, Olivier Fournier, Nick Parker, Nick "
2153 "Fabry, Nicholas Guarracino, Mike Driscoll, Mike Coleman, Mietek Bák, Michael "
2154 "Maloney, László Nagy, Kent Johnson, Julio Nobrega, Jord Fita, Jonathan March, "
2155 "Jonas Nockert, Jim Tittsler, Jeduan Cornejo Legorreta, Jan Larres, James "
2156 "Murphy, Henri Wiechers, Hagen Möbius, Gábor Farkas, Fabien Engels, Evert Rol, "
2157 "Evan Willms, Eduardo Felipe Castegnaro, Dennis Decker Jensen, Deniz Dogan, "
2158 "David Smith, Daed Lee, Christine Slotty, Charles Merriam, Guillaume Catto, "
2159 "Brian Dorsey, Bob Nystrom, Benoit Boissinot, Avi Rosenschein, Andrew Watts, "
2160 "Andrew Donkin, Alexey Rodriguez, Ahmed Chaudhary."
2161 msgstr ""
2163 #. type: Content of: <book><preface><sect1><title>
2164 #: ../en/ch00-preface.xml:111
2165 msgid "Conventions Used in This Book"
2166 msgstr "本书的约定"
2168 #. type: Content of: <book><preface><sect1><para>
2169 #: ../en/ch00-preface.xml:113
2170 msgid "The following typographical conventions are used in this book:"
2171 msgstr "本书使用如下的印刷约定:"
2173 #. type: Content of: <book><preface><sect1><variablelist><varlistentry><term>
2174 #: ../en/ch00-preface.xml:118
2175 msgid "Italic"
2176 msgstr "斜体"
2178 #. type: Content of: <book><preface><sect1><variablelist><varlistentry><listitem><para>
2179 #: ../en/ch00-preface.xml:121
2180 msgid ""
2181 "Indicates new terms, URLs, email addresses, filenames, and file extensions."
2182 msgstr "标识新术语,URL,电子邮件地址,文件名称与扩展名。"
2184 #. type: Content of: <book><preface><sect1><variablelist><varlistentry><term>
2185 #: ../en/ch00-preface.xml:127
2186 msgid "<literal>Constant width</literal>"
2187 msgstr "<literal>等宽</literal>"
2189 #. type: Content of: <book><preface><sect1><variablelist><varlistentry><listitem><para>
2190 #: ../en/ch00-preface.xml:130
2191 msgid ""
2192 "Used for program listings, as well as within paragraphs to refer to program "
2193 "elements such as variable or function names, databases, data types, "
2194 "environment variables, statements, and keywords."
2195 msgstr ""
2196 "用于程序列表,以及段内引用的程序元素,例如变量、函数名称、数据库、数据类型、环"
2197 "境变量、声明和关键字。"
2199 #. type: Content of: <book><preface><sect1><variablelist><varlistentry><term>
2200 #: ../en/ch00-preface.xml:138
2201 msgid "<userinput>Constant width bold</userinput>"
2202 msgstr "<userinput>等宽粗体</userinput>"
2204 #. type: Content of: <book><preface><sect1><variablelist><varlistentry><listitem><para>
2205 #: ../en/ch00-preface.xml:141
2206 msgid "Shows commands or other text that should be typed literally by the user."
2207 msgstr "标识命令或者其它用户应该逐字输入的文本。"
2209 #. type: Content of: <book><preface><sect1><variablelist><varlistentry><term>
2210 #: ../en/ch00-preface.xml:147
2211 msgid "<replaceable>Constant width italic</replaceable>"
2212 msgstr "<replaceable>等宽斜体</replaceable>"
2214 #. type: Content of: <book><preface><sect1><variablelist><varlistentry><listitem><para>
2215 #: ../en/ch00-preface.xml:150
2216 msgid ""
2217 "Shows text that should be replaced with user-supplied values or by values "
2218 "determined by context."
2219 msgstr "标识应该被用户提供的值或者取决于上下文的值替换的文本。"
2221 #. type: Content of: <book><preface><sect1><tip><para>
2222 #: ../en/ch00-preface.xml:157
2223 msgid "This icon signifies a tip, suggestion, or general note."
2224 msgstr "此图标表示提示,建议或者一般的的注释。"
2226 #. type: Content of: <book><preface><sect1><caution><para>
2227 #: ../en/ch00-preface.xml:162
2228 msgid "This icon indicates a warning or caution."
2229 msgstr "此图标表示警告。"
2231 #. type: Content of: <book><preface><sect1><title>
2232 #: ../en/ch00-preface.xml:167
2233 msgid "Using Code Examples"
2234 msgstr "使用样例代码"
2236 #. type: Content of: <book><preface><sect1><para>
2237 #: ../en/ch00-preface.xml:169
2238 msgid ""
2239 "This book is here to help you get your job done. In general, you may use the "
2240 "code in this book in your programs and documentation. You do not need to "
2241 "contact us for permission unless you’re reproducing a significant portion of "
2242 "the code. For example, writing a program that uses several chunks of code "
2243 "from this book does not require permission. Selling or distributing a CD-ROM "
2244 "of examples from O’Reilly books does require permission. Answering a "
2245 "question by citing this book and quoting example code does not require "
2246 "permission. Incorporating a significant amount of example code from this book "
2247 "into your product’s documentation does require permission."
2248 msgstr ""
2250 #. type: Content of: <book><preface><sect1><para>
2251 #: ../en/ch00-preface.xml:181
2252 msgid ""
2253 "We appreciate, but do not require, attribution. An attribution usually "
2254 "includes the title, author, publisher, and ISBN. For example: “<emphasis>Book "
2255 "Title</emphasis> by Some Author. Copyright 2008 O’Reilly Media, Inc., 978-0-"
2256 "596-xxxx-x.”"
2257 msgstr ""
2259 #. type: Content of: <book><preface><sect1><para>
2260 #: ../en/ch00-preface.xml:187
2261 msgid ""
2262 "If you feel your use of code examples falls outside fair use or the "
2263 "permission given above, feel free to contact us at <email>permissions@oreilly."
2264 "com</email>."
2265 msgstr ""
2267 #. type: Content of: <book><preface><sect1><title>
2268 #: ../en/ch00-preface.xml:193
2269 msgid "Safari® Books Online"
2270 msgstr "Safari® 在线书库"
2272 #. type: Content of: <book><preface><sect1><note><para>
2273 #: ../en/ch00-preface.xml:196
2274 msgid ""
2275 "When you see a Safari® Books Online icon on the cover of your favorite "
2276 "technology book, that means the book is available online through the O’Reilly "
2277 "Network Safari Bookshelf."
2278 msgstr ""
2280 #. type: Content of: <book><preface><sect1><para>
2281 #: ../en/ch00-preface.xml:202
2282 msgid ""
2283 "Safari offers a solution that’s better than e-books. It’s a virtual library "
2284 "that lets you easily search thousands of top tech books, cut and paste code "
2285 "samples, download chapters, and find quick answers when you need the most "
2286 "accurate, current information. Try it for free at <ulink role=\"orm:hideurl:"
2287 "ital\" url=\"http://my.safaribooksonline.com/?portal=oreilly\">http://my."
2288 "safaribooksonline.com</ulink>."
2289 msgstr ""
2291 #. type: Content of: <book><preface><sect1><title>
2292 #: ../en/ch00-preface.xml:211
2293 msgid "How to Contact Us"
2294 msgstr "联系我们"
2296 #. type: Content of: <book><preface><sect1><para>
2297 #: ../en/ch00-preface.xml:213
2298 msgid ""
2299 "Please address comments and questions concerning this book to the publisher:"
2300 msgstr ""
2302 #. type: Content of: <book><preface><sect1><simplelist><member>
2303 #: ../en/ch00-preface.xml:217
2304 msgid "O’Reilly Media, Inc."
2305 msgstr ""
2307 #. type: Content of: <book><preface><sect1><simplelist><member>
2308 #: ../en/ch00-preface.xml:219
2309 msgid "1005 Gravenstein Highway North"
2310 msgstr ""
2312 #. type: Content of: <book><preface><sect1><simplelist><member>
2313 #: ../en/ch00-preface.xml:221
2314 msgid "Sebastopol, CA 95472"
2315 msgstr ""
2317 #. type: Content of: <book><preface><sect1><simplelist><member>
2318 #: ../en/ch00-preface.xml:223
2319 msgid "800-998-9938 (in the United States or Canada)"
2320 msgstr ""
2322 #. type: Content of: <book><preface><sect1><simplelist><member>
2323 #: ../en/ch00-preface.xml:225
2324 msgid "707-829-0515 (international or local)"
2325 msgstr ""
2327 #. type: Content of: <book><preface><sect1><simplelist><member>
2328 #: ../en/ch00-preface.xml:227
2329 msgid "707 829-0104 (fax)"
2330 msgstr ""
2332 #. type: Content of: <book><preface><sect1><para>
2333 #: ../en/ch00-preface.xml:230
2334 msgid ""
2335 "We have a web page for this book, where we list errata, examples, and any "
2336 "additional information. You can access this page at:"
2337 msgstr ""
2339 #. type: Content of: <book><preface><sect1><simplelist><member>
2340 #: ../en/ch00-preface.xml:235
2341 msgid ""
2342 "<ulink url=\"http://www.oreilly.com/catalog/&lt;catalog page&gt;\"></ulink>"
2343 msgstr ""
2345 #. type: Content of: <book><preface><sect1><remark>
2346 #: ../en/ch00-preface.xml:239
2347 msgid "Don’t forget to update the &lt;url&gt; attribute, too."
2348 msgstr ""
2350 #. type: Content of: <book><preface><sect1><para>
2351 #: ../en/ch00-preface.xml:242
2352 msgid "To comment or ask technical questions about this book, send email to:"
2353 msgstr ""
2355 #. type: Content of: <book><preface><sect1><simplelist><member>
2356 #: ../en/ch00-preface.xml:246
2357 msgid "<email>bookquestions@oreilly.com</email>"
2358 msgstr "<email>bookquestions@oreilly.com</email>"
2360 #. type: Content of: <book><preface><sect1><para>
2361 #: ../en/ch00-preface.xml:249
2362 msgid ""
2363 "For more information about our books, conferences, Resource Centers, and the "
2364 "O’Reilly Network, see our web site at:"
2365 msgstr ""
2367 #. type: Content of: <book><preface><sect1><simplelist><member>
2368 #: ../en/ch00-preface.xml:253
2369 msgid "<ulink url=\"http://www.oreilly.com\"></ulink>"
2370 msgstr "<ulink url=\"http://www.oreilly.com\"></ulink>"
2372 #. type: Content of: <book><chapter><title>
2373 #: ../en/ch01-intro.xml:5
2374 msgid "How did we get here?"
2375 msgstr ""
2377 #. type: Content of: <book><chapter><sect1><title>
2378 #: ../en/ch01-intro.xml:8
2379 msgid "Why revision control? Why Mercurial?"
2380 msgstr "为什么使用版本控制? 为什么使用 Mercurial?"
2382 #. type: Content of: <book><chapter><sect1><para>
2383 #: ../en/ch01-intro.xml:10
2384 msgid ""
2385 "Revision control is the process of managing multiple versions of a piece of "
2386 "information. In its simplest form, this is something that many people do by "
2387 "hand: every time you modify a file, save it under a new name that contains a "
2388 "number, each one higher than the number of the preceding version."
2389 msgstr ""
2391 #. type: Content of: <book><chapter><sect1><para>
2392 #: ../en/ch01-intro.xml:16
2393 msgid ""
2394 "Manually managing multiple versions of even a single file is an error-prone "
2395 "task, though, so software tools to help automate this process have long been "
2396 "available. The earliest automated revision control tools were intended to "
2397 "help a single user to manage revisions of a single file. Over the past few "
2398 "decades, the scope of revision control tools has expanded greatly; they now "
2399 "manage multiple files, and help multiple people to work together. The best "
2400 "modern revision control tools have no problem coping with thousands of people "
2401 "working together on projects that consist of hundreds of thousands of files."
2402 msgstr ""
2404 #. type: Content of: <book><chapter><sect1><para>
2405 #: ../en/ch01-intro.xml:27
2406 msgid ""
2407 "The arrival of distributed revision control is relatively recent, and so far "
2408 "this new field has grown due to people's willingness to explore ill-charted "
2409 "territory."
2410 msgstr ""
2412 #. type: Content of: <book><chapter><sect1><para>
2413 #: ../en/ch01-intro.xml:31
2414 msgid ""
2415 "I am writing a book about distributed revision control because I believe that "
2416 "it is an important subject that deserves a field guide. I chose to write "
2417 "about Mercurial because it is the easiest tool to learn the terrain with, and "
2418 "yet it scales to the demands of real, challenging environments where many "
2419 "other revision control tools buckle."
2420 msgstr ""
2422 #. type: Content of: <book><chapter><sect1><sect2><title>
2423 #: ../en/ch01-intro.xml:39
2424 msgid "Why use revision control?"
2425 msgstr "为什么使用版本控制?"
2427 #. type: Content of: <book><chapter><sect1><sect2><para>
2428 #: ../en/ch01-intro.xml:41
2429 msgid ""
2430 "There are a number of reasons why you or your team might want to use an "
2431 "automated revision control tool for a project."
2432 msgstr ""
2434 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2435 #: ../en/ch01-intro.xml:46
2436 msgid ""
2437 "It will track the history and evolution of your project, so you don't have "
2438 "to. For every change, you'll have a log of <emphasis>who</emphasis> made it; "
2439 "<emphasis>why</emphasis> they made it; <emphasis>when</emphasis> they made "
2440 "it; and <emphasis>what</emphasis> the change was."
2441 msgstr ""
2443 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2444 #: ../en/ch01-intro.xml:53
2445 msgid ""
2446 "When you're working with other people, revision control software makes it "
2447 "easier for you to collaborate. For example, when people more or less "
2448 "simultaneously make potentially incompatible changes, the software will help "
2449 "you to identify and resolve those conflicts."
2450 msgstr ""
2452 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2453 #: ../en/ch01-intro.xml:59
2454 msgid ""
2455 "It can help you to recover from mistakes. If you make a change that later "
2456 "turns out to be in error, you can revert to an earlier version of one or more "
2457 "files. In fact, a <emphasis>really</emphasis> good revision control tool "
2458 "will even help you to efficiently figure out exactly when a problem was "
2459 "introduced (see <xref linkend=\"sec:undo:bisect\"/> for details)."
2460 msgstr ""
2462 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2463 #: ../en/ch01-intro.xml:66
2464 msgid ""
2465 "It will help you to work simultaneously on, and manage the drift between, "
2466 "multiple versions of your project."
2467 msgstr ""
2469 #. type: Content of: <book><chapter><sect1><sect2><para>
2470 #: ../en/ch01-intro.xml:71
2471 msgid ""
2472 "Most of these reasons are equally valid&emdash;at least in theory&emdash;"
2473 "whether you're working on a project by yourself, or with a hundred other "
2474 "people."
2475 msgstr ""
2477 #. type: Content of: <book><chapter><sect1><sect2><para>
2478 #: ../en/ch01-intro.xml:76
2479 msgid ""
2480 "A key question about the practicality of revision control at these two "
2481 "different scales (<quote>lone hacker</quote> and <quote>huge team</quote>) is "
2482 "how its <emphasis>benefits</emphasis> compare to its <emphasis>costs</"
2483 "emphasis>. A revision control tool that's difficult to understand or use is "
2484 "going to impose a high cost."
2485 msgstr ""
2487 #. type: Content of: <book><chapter><sect1><sect2><para>
2488 #: ../en/ch01-intro.xml:84
2489 msgid ""
2490 "A five-hundred-person project is likely to collapse under its own weight "
2491 "almost immediately without a revision control tool and process. In this case, "
2492 "the cost of using revision control might hardly seem worth considering, since "
2493 "<emphasis>without</emphasis> it, failure is almost guaranteed."
2494 msgstr ""
2496 #. type: Content of: <book><chapter><sect1><sect2><para>
2497 #: ../en/ch01-intro.xml:91
2498 msgid ""
2499 "On the other hand, a one-person <quote>quick hack</quote> might seem like a "
2500 "poor place to use a revision control tool, because surely the cost of using "
2501 "one must be close to the overall cost of the project. Right?"
2502 msgstr ""
2504 #. type: Content of: <book><chapter><sect1><sect2><para>
2505 #: ../en/ch01-intro.xml:96
2506 msgid ""
2507 "Mercurial uniquely supports <emphasis>both</emphasis> of these scales of "
2508 "development. You can learn the basics in just a few minutes, and due to its "
2509 "low overhead, you can apply revision control to the smallest of projects with "
2510 "ease. Its simplicity means you won't have a lot of abstruse concepts or "
2511 "command sequences competing for mental space with whatever you're "
2512 "<emphasis>really</emphasis> trying to do. At the same time, Mercurial's high "
2513 "performance and peer-to-peer nature let you scale painlessly to handle large "
2514 "projects."
2515 msgstr ""
2517 #. type: Content of: <book><chapter><sect1><sect2><para>
2518 #: ../en/ch01-intro.xml:106
2519 msgid ""
2520 "No revision control tool can rescue a poorly run project, but a good choice "
2521 "of tools can make a huge difference to the fluidity with which you can work "
2522 "on a project."
2523 msgstr ""
2525 #. type: Content of: <book><chapter><sect1><sect2><title>
2526 #: ../en/ch01-intro.xml:113
2527 msgid "The many names of revision control"
2528 msgstr "版本控制的别名"
2530 #. type: Content of: <book><chapter><sect1><sect2><para>
2531 #: ../en/ch01-intro.xml:115
2532 msgid ""
2533 "Revision control is a diverse field, so much so that it is referred to by "
2534 "many names and acronyms. Here are a few of the more common variations you'll "
2535 "encounter:"
2536 msgstr ""
2538 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2539 #: ../en/ch01-intro.xml:119
2540 msgid "Revision control (RCS)"
2541 msgstr "版本控制(RCS)"
2543 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2544 #: ../en/ch01-intro.xml:120
2545 msgid "Software configuration management (SCM), or configuration management"
2546 msgstr "软件配置管理(SCM),或配置管理"
2548 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2549 #: ../en/ch01-intro.xml:122
2550 msgid "Source code management"
2551 msgstr "源代码管理"
2553 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2554 #: ../en/ch01-intro.xml:123
2555 msgid "Source code control, or source control"
2556 msgstr "源代码控制,或源控制"
2558 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2559 #: ../en/ch01-intro.xml:125
2560 msgid "Version control (VCS)"
2561 msgstr "版本控制(VCS)"
2563 #. type: Content of: <book><chapter><sect1><sect2><para>
2564 #: ../en/ch01-intro.xml:127
2565 msgid ""
2566 "Some people claim that these terms actually have different meanings, but in "
2567 "practice they overlap so much that there's no agreed or even useful way to "
2568 "tease them apart."
2569 msgstr ""
2571 #. type: Content of: <book><chapter><sect1><title>
2572 #: ../en/ch01-intro.xml:135
2573 msgid "About the examples in this book"
2574 msgstr "本书的例子"
2576 #. type: Content of: <book><chapter><sect1><para>
2577 #: ../en/ch01-intro.xml:137
2578 msgid ""
2579 "This book takes an unusual approach to code samples. Every example is "
2580 "<quote>live</quote>&emdash;each one is actually the result of a shell script "
2581 "that executes the Mercurial commands you see. Every time an image of the "
2582 "book is built from its sources, all the example scripts are automatically "
2583 "run, and their current results compared against their expected results."
2584 msgstr ""
2586 #. type: Content of: <book><chapter><sect1><para>
2587 #: ../en/ch01-intro.xml:144
2588 msgid ""
2589 "The advantage of this approach is that the examples are always accurate; they "
2590 "describe <emphasis>exactly</emphasis> the behavior of the version of "
2591 "Mercurial that's mentioned at the front of the book. If I update the version "
2592 "of Mercurial that I'm documenting, and the output of some command changes, "
2593 "the build fails."
2594 msgstr ""
2596 #. type: Content of: <book><chapter><sect1><para>
2597 #: ../en/ch01-intro.xml:151
2598 msgid ""
2599 "There is a small disadvantage to this approach, which is that the dates and "
2600 "times you'll see in examples tend to be <quote>squashed</quote> together in a "
2601 "way that they wouldn't be if the same commands were being typed by a human. "
2602 "Where a human can issue no more than one command every few seconds, with any "
2603 "resulting timestamps correspondingly spread out, my automated example scripts "
2604 "run many commands in one second."
2605 msgstr ""
2607 #. type: Content of: <book><chapter><sect1><para>
2608 #: ../en/ch01-intro.xml:159
2609 msgid ""
2610 "As an instance of this, several consecutive commits in an example can show up "
2611 "as having occurred during the same second. You can see this occur in the "
2612 "<literal role=\"hg-ext\">bisect</literal> example in <xref linkend=\"sec:undo:"
2613 "bisect\"/>, for instance."
2614 msgstr ""
2616 #. type: Content of: <book><chapter><sect1><para>
2617 #: ../en/ch01-intro.xml:165
2618 msgid ""
2619 "So when you're reading examples, don't place too much weight on the dates or "
2620 "times you see in the output of commands. But <emphasis>do</emphasis> be "
2621 "confident that the behavior you're seeing is consistent and reproducible."
2622 msgstr ""
2624 #. type: Content of: <book><chapter><sect1><title>
2625 #: ../en/ch01-intro.xml:173
2626 msgid "Trends in the field"
2627 msgstr "版本控制的发展趋势"
2629 #. type: Content of: <book><chapter><sect1><para>
2630 #: ../en/ch01-intro.xml:175
2631 msgid ""
2632 "There has been an unmistakable trend in the development and use of revision "
2633 "control tools over the past four decades, as people have become familiar with "
2634 "the capabilities of their tools and constrained by their limitations."
2635 msgstr ""
2637 #. type: Content of: <book><chapter><sect1><para>
2638 #: ../en/ch01-intro.xml:180
2639 msgid ""
2640 "The first generation began by managing single files on individual computers. "
2641 "Although these tools represented a huge advance over ad-hoc manual revision "
2642 "control, their locking model and reliance on a single computer limited them "
2643 "to small, tightly-knit teams."
2644 msgstr ""
2646 #. type: Content of: <book><chapter><sect1><para>
2647 #: ../en/ch01-intro.xml:186
2648 msgid ""
2649 "The second generation loosened these constraints by moving to network-"
2650 "centered architectures, and managing entire projects at a time. As projects "
2651 "grew larger, they ran into new problems. With clients needing to talk to "
2652 "servers very frequently, server scaling became an issue for large projects. "
2653 "An unreliable network connection could prevent remote users from being able "
2654 "to talk to the server at all. As open source projects started making read-"
2655 "only access available anonymously to anyone, people without commit privileges "
2656 "found that they could not use the tools to interact with a project in a "
2657 "natural way, as they could not record their changes."
2658 msgstr ""
2660 #. type: Content of: <book><chapter><sect1><para>
2661 #: ../en/ch01-intro.xml:198
2662 msgid ""
2663 "The current generation of revision control tools is peer-to-peer in nature. "
2664 "All of these systems have dropped the dependency on a single central server, "
2665 "and allow people to distribute their revision control data to where it's "
2666 "actually needed. Collaboration over the Internet has moved from constrained "
2667 "by technology to a matter of choice and consensus. Modern tools can operate "
2668 "offline indefinitely and autonomously, with a network connection only needed "
2669 "when syncing changes with another repository."
2670 msgstr ""
2672 #. type: Content of: <book><chapter><sect1><title>
2673 #: ../en/ch01-intro.xml:210
2674 msgid "A few of the advantages of distributed revision control"
2675 msgstr "分布版本控制的优点"
2677 #. type: Content of: <book><chapter><sect1><para>
2678 #: ../en/ch01-intro.xml:213
2679 msgid ""
2680 "Even though distributed revision control tools have for several years been as "
2681 "robust and usable as their previous-generation counterparts, people using "
2682 "older tools have not yet necessarily woken up to their advantages. There are "
2683 "a number of ways in which distributed tools shine relative to centralised "
2684 "ones."
2685 msgstr ""
2687 #. type: Content of: <book><chapter><sect1><para>
2688 #: ../en/ch01-intro.xml:220
2689 msgid ""
2690 "For an individual developer, distributed tools are almost always much faster "
2691 "than centralised tools. This is for a simple reason: a centralised tool "
2692 "needs to talk over the network for many common operations, because most "
2693 "metadata is stored in a single copy on the central server. A distributed "
2694 "tool stores all of its metadata locally. All else being equal, talking over "
2695 "the network adds overhead to a centralised tool. Don't underestimate the "
2696 "value of a snappy, responsive tool: you're going to spend a lot of time "
2697 "interacting with your revision control software."
2698 msgstr ""
2700 #. type: Content of: <book><chapter><sect1><para>
2701 #: ../en/ch01-intro.xml:231
2702 msgid ""
2703 "Distributed tools are indifferent to the vagaries of your server "
2704 "infrastructure, again because they replicate metadata to so many locations. "
2705 "If you use a centralised system and your server catches fire, you'd better "
2706 "hope that your backup media are reliable, and that your last backup was "
2707 "recent and actually worked. With a distributed tool, you have many backups "
2708 "available on every contributor's computer."
2709 msgstr ""
2711 #. type: Content of: <book><chapter><sect1><para>
2712 #: ../en/ch01-intro.xml:239
2713 msgid ""
2714 "The reliability of your network will affect distributed tools far less than "
2715 "it will centralised tools. You can't even use a centralised tool without a "
2716 "network connection, except for a few highly constrained commands. With a "
2717 "distributed tool, if your network connection goes down while you're working, "
2718 "you may not even notice. The only thing you won't be able to do is talk to "
2719 "repositories on other computers, something that is relatively rare compared "
2720 "with local operations. If you have a far-flung team of collaborators, this "
2721 "may be significant."
2722 msgstr ""
2724 #. type: Content of: <book><chapter><sect1><sect2><title>
2725 #: ../en/ch01-intro.xml:250
2726 msgid "Advantages for open source projects"
2727 msgstr "开源项目的优点"
2729 #. type: Content of: <book><chapter><sect1><sect2><para>
2730 #: ../en/ch01-intro.xml:252
2731 msgid ""
2732 "If you take a shine to an open source project and decide that you would like "
2733 "to start hacking on it, and that project uses a distributed revision control "
2734 "tool, you are at once a peer with the people who consider themselves the "
2735 "<quote>core</quote> of that project. If they publish their repositories, you "
2736 "can immediately copy their project history, start making changes, and record "
2737 "your work, using the same tools in the same ways as insiders. By contrast, "
2738 "with a centralised tool, you must use the software in a <quote>read only</"
2739 "quote> mode unless someone grants you permission to commit changes to their "
2740 "central server. Until then, you won't be able to record changes, and your "
2741 "local modifications will be at risk of corruption any time you try to update "
2742 "your client's view of the repository."
2743 msgstr ""
2745 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
2746 #: ../en/ch01-intro.xml:268
2747 msgid "The forking non-problem"
2748 msgstr "分叉不是问题"
2750 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
2751 #: ../en/ch01-intro.xml:270
2752 msgid ""
2753 "It has been suggested that distributed revision control tools pose some sort "
2754 "of risk to open source projects because they make it easy to <quote>fork</"
2755 "quote> the development of a project. A fork happens when there are "
2756 "differences in opinion or attitude between groups of developers that cause "
2757 "them to decide that they can't work together any longer. Each side takes a "
2758 "more or less complete copy of the project's source code, and goes off in its "
2759 "own direction."
2760 msgstr ""
2762 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
2763 #: ../en/ch01-intro.xml:280
2764 msgid ""
2765 "Sometimes the camps in a fork decide to reconcile their differences. With a "
2766 "centralised revision control system, the <emphasis>technical</emphasis> "
2767 "process of reconciliation is painful, and has to be performed largely by "
2768 "hand. You have to decide whose revision history is going to <quote>win</"
2769 "quote>, and graft the other team's changes into the tree somehow. This "
2770 "usually loses some or all of one side's revision history."
2771 msgstr ""
2773 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
2774 #: ../en/ch01-intro.xml:289
2775 msgid ""
2776 "What distributed tools do with respect to forking is they make forking the "
2777 "<emphasis>only</emphasis> way to develop a project. Every single change that "
2778 "you make is potentially a fork point. The great strength of this approach is "
2779 "that a distributed revision control tool has to be really good at "
2780 "<emphasis>merging</emphasis> forks, because forks are absolutely fundamental: "
2781 "they happen all the time."
2782 msgstr ""
2784 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
2785 #: ../en/ch01-intro.xml:298
2786 msgid ""
2787 "If every piece of work that everybody does, all the time, is framed in terms "
2788 "of forking and merging, then what the open source world refers to as a "
2789 "<quote>fork</quote> becomes <emphasis>purely</emphasis> a social issue. If "
2790 "anything, distributed tools <emphasis>lower</emphasis> the likelihood of a "
2791 "fork:"
2792 msgstr ""
2794 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
2795 #: ../en/ch01-intro.xml:305
2796 msgid ""
2797 "They eliminate the social distinction that centralised tools impose: that "
2798 "between insiders (people with commit access) and outsiders (people without)."
2799 msgstr ""
2801 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
2802 #: ../en/ch01-intro.xml:309
2803 msgid ""
2804 "They make it easier to reconcile after a social fork, because all that's "
2805 "involved from the perspective of the revision control software is just "
2806 "another merge."
2807 msgstr ""
2809 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
2810 #: ../en/ch01-intro.xml:314
2811 msgid ""
2812 "Some people resist distributed tools because they want to retain tight "
2813 "control over their projects, and they believe that centralised tools give "
2814 "them this control. However, if you're of this belief, and you publish your "
2815 "CVS or Subversion repositories publicly, there are plenty of tools available "
2816 "that can pull out your entire project's history (albeit slowly) and recreate "
2817 "it somewhere that you don't control. So while your control in this case is "
2818 "illusory, you are forgoing the ability to fluidly collaborate with whatever "
2819 "people feel compelled to mirror and fork your history."
2820 msgstr ""
2822 #. type: Content of: <book><chapter><sect1><sect2><title>
2823 #: ../en/ch01-intro.xml:329
2824 msgid "Advantages for commercial projects"
2825 msgstr "商业项目的优点"
2827 #. type: Content of: <book><chapter><sect1><sect2><para>
2828 #: ../en/ch01-intro.xml:331
2829 msgid ""
2830 "Many commercial projects are undertaken by teams that are scattered across "
2831 "the globe. Contributors who are far from a central server will see slower "
2832 "command execution and perhaps less reliability. Commercial revision control "
2833 "systems attempt to ameliorate these problems with remote-site replication add-"
2834 "ons that are typically expensive to buy and cantankerous to administer. A "
2835 "distributed system doesn't suffer from these problems in the first place. "
2836 "Better yet, you can easily set up multiple authoritative servers, say one per "
2837 "site, so that there's no redundant communication between repositories over "
2838 "expensive long-haul network links."
2839 msgstr ""
2841 #. type: Content of: <book><chapter><sect1><sect2><para>
2842 #: ../en/ch01-intro.xml:343
2843 msgid ""
2844 "Centralised revision control systems tend to have relatively low "
2845 "scalability. It's not unusual for an expensive centralised system to fall "
2846 "over under the combined load of just a few dozen concurrent users. Once "
2847 "again, the typical response tends to be an expensive and clunky replication "
2848 "facility. Since the load on a central server&emdash;if you have one at "
2849 "all&emdash;is many times lower with a distributed tool (because all of the "
2850 "data is replicated everywhere), a single cheap server can handle the needs of "
2851 "a much larger team, and replication to balance load becomes a simple matter "
2852 "of scripting."
2853 msgstr ""
2855 #. type: Content of: <book><chapter><sect1><sect2><para>
2856 #: ../en/ch01-intro.xml:355
2857 msgid ""
2858 "If you have an employee in the field, troubleshooting a problem at a "
2859 "customer's site, they'll benefit from distributed revision control. The tool "
2860 "will let them generate custom builds, try different fixes in isolation from "
2861 "each other, and search efficiently through history for the sources of bugs "
2862 "and regressions in the customer's environment, all without needing to connect "
2863 "to your company's network."
2864 msgstr ""
2866 #. type: Content of: <book><chapter><sect1><title>
2867 #: ../en/ch01-intro.xml:366
2868 msgid "Why choose Mercurial?"
2869 msgstr "为什么选择 Mercurial?"
2871 #. type: Content of: <book><chapter><sect1><para>
2872 #: ../en/ch01-intro.xml:368
2873 msgid ""
2874 "Mercurial has a unique set of properties that make it a particularly good "
2875 "choice as a revision control system."
2876 msgstr ""
2878 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
2879 #: ../en/ch01-intro.xml:371
2880 msgid "It is easy to learn and use."
2881 msgstr ""
2883 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
2884 #: ../en/ch01-intro.xml:372
2885 msgid "It is lightweight."
2886 msgstr ""
2888 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
2889 #: ../en/ch01-intro.xml:373
2890 msgid "It scales excellently."
2891 msgstr ""
2893 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
2894 #: ../en/ch01-intro.xml:374
2895 msgid "It is easy to customise."
2896 msgstr ""
2898 #. type: Content of: <book><chapter><sect1><para>
2899 #: ../en/ch01-intro.xml:377
2900 msgid ""
2901 "If you are at all familiar with revision control systems, you should be able "
2902 "to get up and running with Mercurial in less than five minutes. Even if not, "
2903 "it will take no more than a few minutes longer. Mercurial's command and "
2904 "feature sets are generally uniform and consistent, so you can keep track of a "
2905 "few general rules instead of a host of exceptions."
2906 msgstr ""
2908 #. type: Content of: <book><chapter><sect1><para>
2909 #: ../en/ch01-intro.xml:384
2910 msgid ""
2911 "On a small project, you can start working with Mercurial in moments. Creating "
2912 "new changes and branches; transferring changes around (whether locally or "
2913 "over a network); and history and status operations are all fast. Mercurial "
2914 "attempts to stay nimble and largely out of your way by combining low "
2915 "cognitive overhead with blazingly fast operations."
2916 msgstr ""
2918 #. type: Content of: <book><chapter><sect1><para>
2919 #: ../en/ch01-intro.xml:391
2920 msgid ""
2921 "The usefulness of Mercurial is not limited to small projects: it is used by "
2922 "projects with hundreds to thousands of contributors, each containing tens of "
2923 "thousands of files and hundreds of megabytes of source code."
2924 msgstr ""
2926 #. type: Content of: <book><chapter><sect1><para>
2927 #: ../en/ch01-intro.xml:396
2928 msgid ""
2929 "If the core functionality of Mercurial is not enough for you, it's easy to "
2930 "build on. Mercurial is well suited to scripting tasks, and its clean "
2931 "internals and implementation in Python make it easy to add features in the "
2932 "form of extensions. There are a number of popular and useful extensions "
2933 "already available, ranging from helping to identify bugs to improving "
2934 "performance."
2935 msgstr ""
2937 #. type: Content of: <book><chapter><sect1><title>
2938 #: ../en/ch01-intro.xml:406
2939 msgid "Mercurial compared with other tools"
2940 msgstr "Mercurial 与其它工具的比较"
2942 #. type: Content of: <book><chapter><sect1><para>
2943 #: ../en/ch01-intro.xml:408
2944 msgid ""
2945 "Before you read on, please understand that this section necessarily reflects "
2946 "my own experiences, interests, and (dare I say it) biases. I have used every "
2947 "one of the revision control tools listed below, in most cases for several "
2948 "years at a time."
2949 msgstr ""
2951 #. type: Content of: <book><chapter><sect1><sect2><para>
2952 #: ../en/ch01-intro.xml:418
2953 msgid ""
2954 "Subversion is a popular revision control tool, developed to replace CVS. It "
2955 "has a centralised client/server architecture."
2956 msgstr ""
2958 #. type: Content of: <book><chapter><sect1><sect2><para>
2959 #: ../en/ch01-intro.xml:422
2960 msgid ""
2961 "Subversion and Mercurial have similarly named commands for performing the "
2962 "same operations, so if you're familiar with one, it is easy to learn to use "
2963 "the other. Both tools are portable to all popular operating systems."
2964 msgstr ""
2966 #. type: Content of: <book><chapter><sect1><sect2><para>
2967 #: ../en/ch01-intro.xml:427
2968 msgid ""
2969 "Prior to version 1.5, Subversion had no useful support for merges. At the "
2970 "time of writing, its merge tracking capability is new, and known to be <ulink "
2971 "url=\"http://svnbook.red-bean.com/nightly/en/svn.branchmerge.advanced."
2972 "html#svn.branchmerge.advanced.finalword\">complicated and buggy</ulink>."
2973 msgstr ""
2975 #. type: Content of: <book><chapter><sect1><sect2><para>
2976 #: ../en/ch01-intro.xml:433
2977 msgid ""
2978 "Mercurial has a substantial performance advantage over Subversion on every "
2979 "revision control operation I have benchmarked. I have measured its advantage "
2980 "as ranging from a factor of two to a factor of six when compared with "
2981 "Subversion 1.4.3's <emphasis>ra_local</emphasis> file store, which is the "
2982 "fastest access method available. In more realistic deployments involving a "
2983 "network-based store, Subversion will be at a substantially larger "
2984 "disadvantage. Because many Subversion commands must talk to the server and "
2985 "Subversion does not have useful replication facilities, server capacity and "
2986 "network bandwidth become bottlenecks for modestly large projects."
2987 msgstr ""
2989 #. type: Content of: <book><chapter><sect1><sect2><para>
2990 #: ../en/ch01-intro.xml:446
2991 msgid ""
2992 "Additionally, Subversion incurs substantial storage overhead to avoid network "
2993 "transactions for a few common operations, such as finding modified files "
2994 "(<literal>status</literal>) and displaying modifications against the current "
2995 "revision (<literal>diff</literal>). As a result, a Subversion working copy "
2996 "is often the same size as, or larger than, a Mercurial repository and working "
2997 "directory, even though the Mercurial repository contains a complete history "
2998 "of the project."
2999 msgstr ""
3001 #. type: Content of: <book><chapter><sect1><sect2><para>
3002 #: ../en/ch01-intro.xml:456
3003 msgid ""
3004 "Subversion is widely supported by third party tools. Mercurial currently "
3005 "lags considerably in this area. This gap is closing, however, and indeed "
3006 "some of Mercurial's GUI tools now outshine their Subversion equivalents. "
3007 "Like Mercurial, Subversion has an excellent user manual."
3008 msgstr ""
3010 #. type: Content of: <book><chapter><sect1><sect2><para>
3011 #: ../en/ch01-intro.xml:462
3012 msgid ""
3013 "Because Subversion doesn't store revision history on the client, it is well "
3014 "suited to managing projects that deal with lots of large, opaque binary "
3015 "files. If you check in fifty revisions to an incompressible 10MB file, "
3016 "Subversion's client-side space usage stays constant The space used by any "
3017 "distributed SCM will grow rapidly in proportion to the number of revisions, "
3018 "because the differences between each revision are large."
3019 msgstr ""
3021 #. type: Content of: <book><chapter><sect1><sect2><para>
3022 #: ../en/ch01-intro.xml:471
3023 msgid ""
3024 "In addition, it's often difficult or, more usually, impossible to merge "
3025 "different versions of a binary file. Subversion's ability to let a user lock "
3026 "a file, so that they temporarily have the exclusive right to commit changes "
3027 "to it, can be a significant advantage to a project where binary files are "
3028 "widely used."
3029 msgstr ""
3031 #. type: Content of: <book><chapter><sect1><sect2><para>
3032 #: ../en/ch01-intro.xml:478
3033 msgid ""
3034 "Mercurial can import revision history from a Subversion repository. It can "
3035 "also export revision history to a Subversion repository. This makes it easy "
3036 "to <quote>test the waters</quote> and use Mercurial and Subversion in "
3037 "parallel before deciding to switch. History conversion is incremental, so "
3038 "you can perform an initial conversion, then small additional conversions "
3039 "afterwards to bring in new changes."
3040 msgstr ""
3042 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
3043 #: ../en/ch01-intro.xml:490 ../en/ch01-intro.xml:629
3044 msgid "Git"
3045 msgstr "Git"
3047 #. type: Content of: <book><chapter><sect1><sect2><para>
3048 #: ../en/ch01-intro.xml:492
3049 msgid ""
3050 "Git is a distributed revision control tool that was developed for managing "
3051 "the Linux kernel source tree. Like Mercurial, its early design was somewhat "
3052 "influenced by Monotone."
3053 msgstr ""
3055 #. type: Content of: <book><chapter><sect1><sect2><para>
3056 #: ../en/ch01-intro.xml:497
3057 msgid ""
3058 "Git has a very large command set, with version 1.5.0 providing 139 individual "
3059 "commands. It has something of a reputation for being difficult to learn. "
3060 "Compared to Git, Mercurial has a strong focus on simplicity."
3061 msgstr ""
3063 #. type: Content of: <book><chapter><sect1><sect2><para>
3064 #: ../en/ch01-intro.xml:502
3065 msgid ""
3066 "In terms of performance, Git is extremely fast. In several cases, it is "
3067 "faster than Mercurial, at least on Linux, while Mercurial performs better on "
3068 "other operations. However, on Windows, the performance and general level of "
3069 "support that Git provides is, at the time of writing, far behind that of "
3070 "Mercurial."
3071 msgstr ""
3073 #. type: Content of: <book><chapter><sect1><sect2><para>
3074 #: ../en/ch01-intro.xml:509
3075 msgid ""
3076 "While a Mercurial repository needs no maintenance, a Git repository requires "
3077 "frequent manual <quote>repacks</quote> of its metadata. Without these, "
3078 "performance degrades, while space usage grows rapidly. A server that "
3079 "contains many Git repositories that are not rigorously and frequently "
3080 "repacked will become heavily disk-bound during backups, and there have been "
3081 "instances of daily backups taking far longer than 24 hours as a result. A "
3082 "freshly packed Git repository is slightly smaller than a Mercurial "
3083 "repository, but an unpacked repository is several orders of magnitude larger."
3084 msgstr ""
3086 #. type: Content of: <book><chapter><sect1><sect2><para>
3087 #: ../en/ch01-intro.xml:520
3088 msgid ""
3089 "The core of Git is written in C. Many Git commands are implemented as shell "
3090 "or Perl scripts, and the quality of these scripts varies widely. I have "
3091 "encountered several instances where scripts charged along blindly in the "
3092 "presence of errors that should have been fatal."
3093 msgstr ""
3095 #. type: Content of: <book><chapter><sect1><sect2><para>
3096 #: ../en/ch01-intro.xml:526
3097 msgid "Mercurial can import revision history from a Git repository."
3098 msgstr ""
3100 #. type: Content of: <book><chapter><sect1><sect2><para>
3101 #: ../en/ch01-intro.xml:534
3102 msgid ""
3103 "CVS is probably the most widely used revision control tool in the world. Due "
3104 "to its age and internal untidiness, it has been only lightly maintained for "
3105 "many years."
3106 msgstr ""
3108 #. type: Content of: <book><chapter><sect1><sect2><para>
3109 #: ../en/ch01-intro.xml:538
3110 msgid ""
3111 "It has a centralised client/server architecture. It does not group related "
3112 "file changes into atomic commits, making it easy for people to <quote>break "
3113 "the build</quote>: one person can successfully commit part of a change and "
3114 "then be blocked by the need for a merge, causing other people to see only a "
3115 "portion of the work they intended to do. This also affects how you work with "
3116 "project history. If you want to see all of the modifications someone made as "
3117 "part of a task, you will need to manually inspect the descriptions and "
3118 "timestamps of the changes made to each file involved (if you even know what "
3119 "those files were)."
3120 msgstr ""
3122 #. type: Content of: <book><chapter><sect1><sect2><para>
3123 #: ../en/ch01-intro.xml:550
3124 msgid ""
3125 "CVS has a muddled notion of tags and branches that I will not attempt to even "
3126 "describe. It does not support renaming of files or directories well, making "
3127 "it easy to corrupt a repository. It has almost no internal consistency "
3128 "checking capabilities, so it is usually not even possible to tell whether or "
3129 "how a repository is corrupt. I would not recommend CVS for any project, "
3130 "existing or new."
3131 msgstr ""
3133 #. type: Content of: <book><chapter><sect1><sect2><para>
3134 #: ../en/ch01-intro.xml:558
3135 msgid ""
3136 "Mercurial can import CVS revision history. However, there are a few caveats "
3137 "that apply; these are true of every other revision control tool's CVS "
3138 "importer, too. Due to CVS's lack of atomic changes and unversioned "
3139 "filesystem hierarchy, it is not possible to reconstruct CVS history "
3140 "completely accurately; some guesswork is involved, and renames will usually "
3141 "not show up. Because a lot of advanced CVS administration has to be done by "
3142 "hand and is hence error-prone, it's common for CVS importers to run into "
3143 "multiple problems with corrupted repositories (completely bogus revision "
3144 "timestamps and files that have remained locked for over a decade are just two "
3145 "of the less interesting problems I can recall from personal experience)."
3146 msgstr ""
3148 #. type: Content of: <book><chapter><sect1><sect2><para>
3149 #: ../en/ch01-intro.xml:572
3150 msgid "Mercurial can import revision history from a CVS repository."
3151 msgstr ""
3153 #. type: Content of: <book><chapter><sect1><sect2><title>
3154 #: ../en/ch01-intro.xml:578
3155 msgid "Commercial tools"
3156 msgstr "商业工具"
3158 #. type: Content of: <book><chapter><sect1><sect2><para>
3159 #: ../en/ch01-intro.xml:580
3160 msgid ""
3161 "Perforce has a centralised client/server architecture, with no client-side "
3162 "caching of any data. Unlike modern revision control tools, Perforce requires "
3163 "that a user run a command to inform the server about every file they intend "
3164 "to edit."
3165 msgstr ""
3167 #. type: Content of: <book><chapter><sect1><sect2><para>
3168 #: ../en/ch01-intro.xml:586
3169 msgid ""
3170 "The performance of Perforce is quite good for small teams, but it falls off "
3171 "rapidly as the number of users grows beyond a few dozen. Modestly large "
3172 "Perforce installations require the deployment of proxies to cope with the "
3173 "load their users generate."
3174 msgstr ""
3176 #. type: Content of: <book><chapter><sect1><sect2><title>
3177 #: ../en/ch01-intro.xml:595
3178 msgid "Choosing a revision control tool"
3179 msgstr "选择版本控制工具"
3181 #. type: Content of: <book><chapter><sect1><sect2><para>
3182 #: ../en/ch01-intro.xml:597
3183 msgid ""
3184 "With the exception of CVS, all of the tools listed above have unique "
3185 "strengths that suit them to particular styles of work. There is no single "
3186 "revision control tool that is best in all situations."
3187 msgstr ""
3189 #. type: Content of: <book><chapter><sect1><sect2><para>
3190 #: ../en/ch01-intro.xml:602
3191 msgid ""
3192 "As an example, Subversion is a good choice for working with frequently edited "
3193 "binary files, due to its centralised nature and support for file locking."
3194 msgstr ""
3196 #. type: Content of: <book><chapter><sect1><sect2><para>
3197 #: ../en/ch01-intro.xml:606
3198 msgid ""
3199 "I personally find Mercurial's properties of simplicity, performance, and good "
3200 "merge support to be a compelling combination that has served me well for "
3201 "several years."
3202 msgstr ""
3204 #. type: Content of: <book><chapter><sect1><title>
3205 #: ../en/ch01-intro.xml:614
3206 msgid "Switching from another tool to Mercurial"
3207 msgstr "从其它工具切换到 Mercurial"
3209 #. type: Content of: <book><chapter><sect1><para>
3210 #: ../en/ch01-intro.xml:616
3211 msgid ""
3212 "Mercurial is bundled with an extension named <literal role=\"hg-ext"
3213 "\">convert</literal>, which can incrementally import revision history from "
3214 "several other revision control tools. By <quote>incremental</quote>, I mean "
3215 "that you can convert all of a project's history to date in one go, then rerun "
3216 "the conversion later to obtain new changes that happened after the initial "
3217 "conversion."
3218 msgstr ""
3220 #. type: Content of: <book><chapter><sect1><para>
3221 #: ../en/ch01-intro.xml:624
3222 msgid ""
3223 "The revision control tools supported by <literal role=\"hg-ext\">convert</"
3224 "literal> are as follows:"
3225 msgstr "<literal role=\"hg-ext\">convert</literal> 支持的版本控制工具有:"
3227 #. type: Content of: <book><chapter><sect1><para>
3228 #: ../en/ch01-intro.xml:632
3229 msgid ""
3230 "In addition, <literal role=\"hg-ext\">convert</literal> can export changes "
3231 "from Mercurial to Subversion. This makes it possible to try Subversion and "
3232 "Mercurial in parallel before committing to a switchover, without risking the "
3233 "loss of any work."
3234 msgstr ""
3236 #. type: Content of: <book><chapter><sect1><para>
3237 #: ../en/ch01-intro.xml:638
3238 msgid ""
3239 "The <command role=\"hg-ext-convert\">convert</command> command is easy to "
3240 "use. Simply point it at the path or URL of the source repository, optionally "
3241 "give it the name of the destination repository, and it will start working. "
3242 "After the initial conversion, just run the same command again to import new "
3243 "changes."
3244 msgstr ""
3246 #. type: Content of: <book><chapter><sect1><title>
3247 #: ../en/ch01-intro.xml:647
3248 msgid "A short history of revision control"
3249 msgstr "版本控制简史"
3251 #. type: Content of: <book><chapter><sect1><para>
3252 #: ../en/ch01-intro.xml:649
3253 msgid ""
3254 "The best known of the old-time revision control tools is SCCS (Source Code "
3255 "Control System), which Marc Rochkind wrote at Bell Labs, in the early 1970s. "
3256 "SCCS operated on individual files, and required every person working on a "
3257 "project to have access to a shared workspace on a single system. Only one "
3258 "person could modify a file at any time; arbitration for access to files was "
3259 "via locks. It was common for people to lock files, and later forget to "
3260 "unlock them, preventing anyone else from modifying those files without the "
3261 "help of an administrator."
3262 msgstr ""
3264 #. type: Content of: <book><chapter><sect1><para>
3265 #: ../en/ch01-intro.xml:660
3266 msgid ""
3267 "Walter Tichy developed a free alternative to SCCS in the early 1980s; he "
3268 "called his program RCS (Revision Control System). Like SCCS, RCS required "
3269 "developers to work in a single shared workspace, and to lock files to prevent "
3270 "multiple people from modifying them simultaneously."
3271 msgstr ""
3273 #. type: Content of: <book><chapter><sect1><para>
3274 #: ../en/ch01-intro.xml:666
3275 msgid ""
3276 "Later in the 1980s, Dick Grune used RCS as a building block for a set of "
3277 "shell scripts he initially called cmt, but then renamed to CVS (Concurrent "
3278 "Versions System). The big innovation of CVS was that it let developers work "
3279 "simultaneously and somewhat independently in their own personal workspaces. "
3280 "The personal workspaces prevented developers from stepping on each other's "
3281 "toes all the time, as was common with SCCS and RCS. Each developer had a copy "
3282 "of every project file, and could modify their copies independently. They had "
3283 "to merge their edits prior to committing changes to the central repository."
3284 msgstr ""
3286 #. type: Content of: <book><chapter><sect1><para>
3287 #: ../en/ch01-intro.xml:677
3288 msgid ""
3289 "Brian Berliner took Grune's original scripts and rewrote them in C, releasing "
3290 "in 1989 the code that has since developed into the modern version of CVS. "
3291 "CVS subsequently acquired the ability to operate over a network connection, "
3292 "giving it a client/server architecture. CVS's architecture is centralised; "
3293 "only the server has a copy of the history of the project. Client workspaces "
3294 "just contain copies of recent versions of the project's files, and a little "
3295 "metadata to tell them where the server is. CVS has been enormously "
3296 "successful; it is probably the world's most widely used revision control "
3297 "system."
3298 msgstr ""
3300 #. type: Content of: <book><chapter><sect1><para>
3301 #: ../en/ch01-intro.xml:688
3302 msgid ""
3303 "In the early 1990s, Sun Microsystems developed an early distributed revision "
3304 "control system, called TeamWare. A TeamWare workspace contains a complete "
3305 "copy of the project's history. TeamWare has no notion of a central "
3306 "repository. (CVS relied upon RCS for its history storage; TeamWare used "
3307 "SCCS.)"
3308 msgstr ""
3310 #. type: Content of: <book><chapter><sect1><para>
3311 #: ../en/ch01-intro.xml:695
3312 msgid ""
3313 "As the 1990s progressed, awareness grew of a number of problems with CVS. It "
3314 "records simultaneous changes to multiple files individually, instead of "
3315 "grouping them together as a single logically atomic operation. It does not "
3316 "manage its file hierarchy well; it is easy to make a mess of a repository by "
3317 "renaming files and directories. Worse, its source code is difficult to read "
3318 "and maintain, which made the <quote>pain level</quote> of fixing these "
3319 "architectural problems prohibitive."
3320 msgstr ""
3322 #. type: Content of: <book><chapter><sect1><para>
3323 #: ../en/ch01-intro.xml:705
3324 msgid ""
3325 "In 2001, Jim Blandy and Karl Fogel, two developers who had worked on CVS, "
3326 "started a project to replace it with a tool that would have a better "
3327 "architecture and cleaner code. The result, Subversion, does not stray from "
3328 "CVS's centralised client/server model, but it adds multi-file atomic commits, "
3329 "better namespace management, and a number of other features that make it a "
3330 "generally better tool than CVS. Since its initial release, it has rapidly "
3331 "grown in popularity."
3332 msgstr ""
3334 #. type: Content of: <book><chapter><sect1><para>
3335 #: ../en/ch01-intro.xml:714
3336 msgid ""
3337 "More or less simultaneously, Graydon Hoare began working on an ambitious "
3338 "distributed revision control system that he named Monotone. While Monotone "
3339 "addresses many of CVS's design flaws and has a peer-to-peer architecture, it "
3340 "goes beyond earlier (and subsequent) revision control tools in a number of "
3341 "innovative ways. It uses cryptographic hashes as identifiers, and has an "
3342 "integral notion of <quote>trust</quote> for code from different sources."
3343 msgstr ""
3345 #. type: Content of: <book><chapter><sect1><para>
3346 #: ../en/ch01-intro.xml:723
3347 msgid ""
3348 "Mercurial began life in 2005. While a few aspects of its design are "
3349 "influenced by Monotone, Mercurial focuses on ease of use, high performance, "
3350 "and scalability to very large projects."
3351 msgstr ""
3353 #. type: Content of: <book><chapter><title>
3354 #: ../en/ch02-tour-basic.xml:5
3355 msgid "A tour of Mercurial: the basics"
3356 msgstr "Mercurial 教程: 基础知识"
3358 #. type: Content of: <book><chapter><sect1><title>
3359 #: ../en/ch02-tour-basic.xml:8
3360 msgid "Installing Mercurial on your system"
3361 msgstr "安装 Mercurial"
3363 #. type: Content of: <book><chapter><sect1><para>
3364 #: ../en/ch02-tour-basic.xml:10
3365 msgid ""
3366 "Prebuilt binary packages of Mercurial are available for every popular "
3367 "operating system. These make it easy to start using Mercurial on your "
3368 "computer immediately."
3369 msgstr ""
3370 "对于每种流行的操作系统,都有已经构建的二进制软件包。这让在你的计算机上开始使"
3371 "用 Mercurial 变得很容易。"
3373 #. type: Content of: <book><chapter><sect1><sect2><title>
3374 #: ../en/ch02-tour-basic.xml:15
3375 msgid "Windows"
3376 msgstr "Windows"
3378 #. type: Content of: <book><chapter><sect1><sect2><para>
3379 #: ../en/ch02-tour-basic.xml:17
3380 msgid ""
3381 "The best version of Mercurial for Windows is TortoiseHg, which can be found "
3382 "at <ulink url=\"http://bitbucket.org/tortoisehg/stable/wiki/Home\">http://"
3383 "bitbucket.org/tortoisehg/stable/wiki/Home</ulink>. This package has no "
3384 "external dependencies; it <quote>just works</quote>. It provides both "
3385 "command line and graphical user interfaces."
3386 msgstr ""
3387 "Windows 中最好的 Mercurial 版本是TortoiseHg,它的主页地址是 <ulink url="
3388 "\"http://bitbucket.org/tortoisehg/stable/wiki/Home\">http://bitbucket.org/"
3389 "tortoisehg/stable/wiki/Home</ulink>。这个软件没有外部依赖,它可以<quote>独立工"
3390 "作</quote>,同时提供了命令行和图形用户界面。"
3392 #. type: Content of: <book><chapter><sect1><sect2><title>
3393 #: ../en/ch02-tour-basic.xml:27
3394 msgid "Mac OS X"
3395 msgstr "Mac OS X"
3397 #. type: Content of: <book><chapter><sect1><sect2><para>
3398 #: ../en/ch02-tour-basic.xml:29
3399 msgid ""
3400 "Lee Cantey publishes an installer of Mercurial for Mac OS X at <ulink url="
3401 "\"http://mercurial.berkwood.com\">http://mercurial.berkwood.com</ulink>."
3402 msgstr ""
3403 "Lee Cantey 为 Mac OS X 在 <ulink url=\"http://mercurial.berkwood.com"
3404 "\">http://mercurial.berkwood.com</ulink> 发布了 Mercurial 安装程序。"
3406 #. type: Content of: <book><chapter><sect1><sect2><title>
3407 #: ../en/ch02-tour-basic.xml:35
3408 msgid "Linux"
3409 msgstr "Linux"
3411 #. type: Content of: <book><chapter><sect1><sect2><para>
3412 #: ../en/ch02-tour-basic.xml:37
3413 msgid ""
3414 "Because each Linux distribution has its own packaging tools, policies, and "
3415 "rate of development, it's difficult to give a comprehensive set of "
3416 "instructions on how to install Mercurial binaries. The version of Mercurial "
3417 "that you will end up with can vary depending on how active the person is who "
3418 "maintains the package for your distribution."
3419 msgstr ""
3420 "由于每种 Linux 发行版都有自己的包管理工具,开发策略和进度,从而很难给出安装 "
3421 "Mercurial 二进制包的全面说明。你安装的 Mercurial 版本,在很大程度上依赖于你所"
3422 "使用的发行版的 Mercurial 维护者的活跃程度。"
3424 #. type: Content of: <book><chapter><sect1><sect2><para>
3425 #: ../en/ch02-tour-basic.xml:44
3426 msgid ""
3427 "To keep things simple, I will focus on installing Mercurial from the command "
3428 "line under the most popular Linux distributions. Most of these distributions "
3429 "provide graphical package managers that will let you install Mercurial with a "
3430 "single click; the package name to look for is <literal>mercurial</literal>."
3431 msgstr ""
3432 "为了让事情简单,我会致力于说明在最流行的 Linux 发行版中,从命令行安装 "
3433 "Mercurial 的方法。这些发行版都提供了图形界面的包管理器,让你通过点击鼠标安装 "
3434 "Mercurial;寻找的包名称是 <literal>mercurial</literal>。"
3436 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
3437 #: ../en/ch02-tour-basic.xml:52
3438 msgid "Ubuntu and Debian:"
3439 msgstr "Ubuntu 与 Debian:"
3441 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
3442 #: ../en/ch02-tour-basic.xml:54
3443 msgid "Fedora:"
3444 msgstr "Fedora:"
3446 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
3447 #: ../en/ch02-tour-basic.xml:56
3448 msgid "OpenSUSE:"
3449 msgstr "OpenSUSE:"
3451 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
3452 #: ../en/ch02-tour-basic.xml:58
3453 msgid "Gentoo:"
3454 msgstr "Gentoo:"
3456 #. type: Content of: <book><chapter><sect1><sect2><title>
3457 #: ../en/ch02-tour-basic.xml:64
3458 msgid "Solaris"
3459 msgstr "Solaris"
3461 #. type: Content of: <book><chapter><sect1><sect2><para>
3462 #: ../en/ch02-tour-basic.xml:66
3463 msgid ""
3464 "SunFreeWare, at <ulink url=\"http://www.sunfreeware.com\">http://www."
3465 "sunfreeware.com</ulink>, provides prebuilt packages of Mercurial."
3466 msgstr ""
3467 "位于 <ulink url=\"http://www.sunfreeware.com\">http://www.sunfreeware.com</"
3468 "ulink> 的 SunFreeWare 提供了 Mercurial 的二进制安装包。"
3470 #. type: Content of: <book><chapter><sect1><title>
3471 #: ../en/ch02-tour-basic.xml:75
3472 msgid "Getting started"
3473 msgstr "开始"
3475 #. type: Content of: <book><chapter><sect1><para>
3476 #: ../en/ch02-tour-basic.xml:77
3477 msgid ""
3478 "To begin, we'll use the <command role=\"hg-cmd\">hg version</command> command "
3479 "to find out whether Mercurial is installed properly. The actual version "
3480 "information that it prints isn't so important; we simply care whether the "
3481 "command runs and prints anything at all."
3482 msgstr ""
3483 "首先,我们使用 <command role=\"hg-cmd\">hg version</command> 命令检查 "
3484 "Mercurial 是否已经正确安装。它打印出来的实际版本信息并不重要;我们只关心它是否"
3485 "能够运行,打印出信息。"
3487 #. type: Content of: <book><chapter><sect1><sect2><title>
3488 #: ../en/ch02-tour-basic.xml:86
3489 msgid "Built-in help"
3490 msgstr "内置帮助"
3492 #. type: Content of: <book><chapter><sect1><sect2><para>
3493 #: ../en/ch02-tour-basic.xml:88
3494 msgid ""
3495 "Mercurial provides a built-in help system. This is invaluable for those "
3496 "times when you find yourself stuck trying to remember how to run a command. "
3497 "If you are completely stuck, simply run <command role=\"hg-cmd\">hg help</"
3498 "command>; it will print a brief list of commands, along with a description of "
3499 "what each does. If you ask for help on a specific command (as below), it "
3500 "prints more detailed information."
3501 msgstr ""
3502 "Mercurial 内置了帮助系统。当你不记得如何执行一个命令时,它会给你重要的帮助。如"
3503 "果你完全没有头绪,那就直接运行 <command role=\"hg-cmd\">hg help</command>;它"
3504 "会给出命令的简短列表,还描述了每个命令的作用。如果你需要具体命令的帮助(下述),"
3505 "它会给出更详细的信息。"
3507 #. type: Content of: <book><chapter><sect1><sect2><para>
3508 #: ../en/ch02-tour-basic.xml:99
3509 msgid ""
3510 "For a more impressive level of detail (which you won't usually need) run "
3511 "<command role=\"hg-cmd\">hg help <option role=\"hg-opt-global\">-v</option></"
3512 "command>. The <option role=\"hg-opt-global\">-v</option> option is short for "
3513 "<option role=\"hg-opt-global\">--verbose</option>, and tells Mercurial to "
3514 "print more information than it usually would."
3515 msgstr ""
3516 "要获得更多的详细信息(通常不需要),可以执行 <command role=\"hg-cmd\">hg help "
3517 "<option role=\"hg-opt-global\">-v</option></command>。选项 <option role=\"hg-"
3518 "opt-global\">-v</option> 是 <option role=\"hg-opt-global\">--verbose</option> "
3519 "的短格式,告诉 Mercurial 要打印通常不需要的更多信息。"
3521 #. type: Content of: <book><chapter><sect1><title>
3522 #: ../en/ch02-tour-basic.xml:110
3523 msgid "Working with a repository"
3524 msgstr "使用版本库"
3526 #. type: Content of: <book><chapter><sect1><para>
3527 #: ../en/ch02-tour-basic.xml:112
3528 msgid ""
3529 "In Mercurial, everything happens inside a <emphasis>repository</emphasis>. "
3530 "The repository for a project contains all of the files that <quote>belong to</"
3531 "quote> that project, along with a historical record of the project's files."
3532 msgstr ""
3534 #. type: Content of: <book><chapter><sect1><para>
3535 #: ../en/ch02-tour-basic.xml:118
3536 msgid ""
3537 "There's nothing particularly magical about a repository; it is simply a "
3538 "directory tree in your filesystem that Mercurial treats as special. You can "
3539 "rename or delete a repository any time you like, using either the command "
3540 "line or your file browser."
3541 msgstr ""
3543 #. type: Content of: <book><chapter><sect1><sect2><title>
3544 #: ../en/ch02-tour-basic.xml:125
3545 msgid "Making a local copy of a repository"
3546 msgstr "创建版本库的工作副本"
3548 #. type: Content of: <book><chapter><sect1><sect2><para>
3549 #: ../en/ch02-tour-basic.xml:127
3550 msgid ""
3551 "<emphasis>Copying</emphasis> a repository is just a little bit special. "
3552 "While you could use a normal file copying command to make a copy of a "
3553 "repository, it's best to use a built-in command that Mercurial provides. "
3554 "This command is called <command role=\"hg-cmd\">hg clone</command>, because "
3555 "it makes an identical copy of an existing repository."
3556 msgstr ""
3558 #. type: Content of: <book><chapter><sect1><sect2><para>
3559 #: ../en/ch02-tour-basic.xml:136
3560 msgid ""
3561 "One advantage of using <command role=\"hg-cmd\">hg clone</command> is that, "
3562 "as we can see above, it lets us clone repositories over the network. Another "
3563 "is that it remembers where we cloned from, which we'll find useful soon when "
3564 "we want to fetch new changes from another repository."
3565 msgstr ""
3567 #. type: Content of: <book><chapter><sect1><sect2><para>
3568 #: ../en/ch02-tour-basic.xml:142
3569 msgid ""
3570 "If our clone succeeded, we should now have a local directory called <filename "
3571 "class=\"directory\">hello</filename>. This directory will contain some files."
3572 msgstr ""
3574 #. type: Content of: <book><chapter><sect1><sect2><para>
3575 #: ../en/ch02-tour-basic.xml:148
3576 msgid ""
3577 "These files have the same contents and history in our repository as they do "
3578 "in the repository we cloned."
3579 msgstr ""
3581 #. type: Content of: <book><chapter><sect1><sect2><para>
3582 #: ../en/ch02-tour-basic.xml:151
3583 msgid ""
3584 "Every Mercurial repository is complete, self-contained, and independent. It "
3585 "contains its own private copy of a project's files and history. As we just "
3586 "mentioned, a cloned repository remembers the location of the repository it "
3587 "was cloned from, but Mercurial will not communicate with that repository, or "
3588 "any other, unless you tell it to."
3589 msgstr ""
3591 #. type: Content of: <book><chapter><sect1><sect2><para>
3592 #: ../en/ch02-tour-basic.xml:158
3593 msgid ""
3594 "What this means for now is that we're free to experiment with our repository, "
3595 "safe in the knowledge that it's a private <quote>sandbox</quote> that won't "
3596 "affect anyone else."
3597 msgstr ""
3599 #. type: Content of: <book><chapter><sect1><sect2><title>
3600 #: ../en/ch02-tour-basic.xml:164
3601 msgid "What's in a repository?"
3602 msgstr "什么是版本库?"
3604 #. type: Content of: <book><chapter><sect1><sect2><para>
3605 #: ../en/ch02-tour-basic.xml:166
3606 msgid ""
3607 "When we take a more detailed look inside a repository, we can see that it "
3608 "contains a directory named <filename class=\"directory\">.hg</filename>. "
3609 "This is where Mercurial keeps all of its metadata for the repository."
3610 msgstr ""
3612 #. type: Content of: <book><chapter><sect1><sect2><para>
3613 #: ../en/ch02-tour-basic.xml:173
3614 msgid ""
3615 "The contents of the <filename class=\"directory\">.hg</filename> directory "
3616 "and its subdirectories are private to Mercurial. Every other file and "
3617 "directory in the repository is yours to do with as you please."
3618 msgstr ""
3620 #. type: Content of: <book><chapter><sect1><sect2><para>
3621 #: ../en/ch02-tour-basic.xml:179
3622 msgid ""
3623 "To introduce a little terminology, the <filename class=\"directory\">.hg</"
3624 "filename> directory is the <quote>real</quote> repository, and all of the "
3625 "files and directories that coexist with it are said to live in the "
3626 "<emphasis>working directory</emphasis>. An easy way to remember the "
3627 "distinction is that the <emphasis>repository</emphasis> contains the "
3628 "<emphasis>history</emphasis> of your project, while the <emphasis>working "
3629 "directory</emphasis> contains a <emphasis>snapshot</emphasis> of your project "
3630 "at a particular point in history."
3631 msgstr ""
3633 #. type: Content of: <book><chapter><sect1><title>
3634 #: ../en/ch02-tour-basic.xml:194
3635 msgid "A tour through history"
3636 msgstr "回溯历史"
3638 #. type: Content of: <book><chapter><sect1><para>
3639 #: ../en/ch02-tour-basic.xml:196
3640 msgid ""
3641 "One of the first things we might want to do with a new, unfamiliar repository "
3642 "is understand its history. The <command role=\"hg-cmd\">hg log</command> "
3643 "command gives us a view of the history of changes in the repository."
3644 msgstr ""
3646 #. type: Content of: <book><chapter><sect1><para>
3647 #: ../en/ch02-tour-basic.xml:203
3648 msgid ""
3649 "By default, this command prints a brief paragraph of output for each change "
3650 "to the project that was recorded. In Mercurial terminology, we call each of "
3651 "these recorded events a <emphasis>changeset</emphasis>, because it can "
3652 "contain a record of changes to several files."
3653 msgstr ""
3655 #. type: Content of: <book><chapter><sect1><para>
3656 #: ../en/ch02-tour-basic.xml:209
3657 msgid ""
3658 "The fields in a record of output from <command role=\"hg-cmd\">hg log</"
3659 "command> are as follows."
3660 msgstr ""
3662 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
3663 #: ../en/ch02-tour-basic.xml:213
3664 msgid ""
3665 "<literal>changeset</literal>: This field has the format of a number, followed "
3666 "by a colon, followed by a hexadecimal (or <emphasis>hex</emphasis>) string. "
3667 "These are <emphasis>identifiers</emphasis> for the changeset. The hex string "
3668 "is a unique identifier: the same hex string will always refer to the same "
3669 "changeset in every copy of this repository. The number is shorter and easier "
3670 "to type than the hex string, but it isn't unique: the same number in two "
3671 "different clones of a repository may identify different changesets."
3672 msgstr ""
3674 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
3675 #: ../en/ch02-tour-basic.xml:224
3676 msgid ""
3677 "<literal>user</literal>: The identity of the person who created the "
3678 "changeset. This is a free-form field, but it most often contains a person's "
3679 "name and email address."
3680 msgstr ""
3682 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
3683 #: ../en/ch02-tour-basic.xml:228
3684 msgid ""
3685 "<literal>date</literal>: The date and time on which the changeset was "
3686 "created, and the timezone in which it was created. (The date and time are "
3687 "local to that timezone; they display what time and date it was for the person "
3688 "who created the changeset.)"
3689 msgstr ""
3691 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
3692 #: ../en/ch02-tour-basic.xml:233
3693 msgid ""
3694 "<literal>summary</literal>: The first line of the text message that the "
3695 "creator of the changeset entered to describe the changeset."
3696 msgstr ""
3698 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
3699 #: ../en/ch02-tour-basic.xml:237
3700 msgid ""
3701 "Some changesets, such as the first in the list above, have a <literal>tag</"
3702 "literal> field. A tag is another way to identify a changeset, by giving it "
3703 "an easy-to-remember name. (The tag named <literal>tip</literal> is special: "
3704 "it always refers to the newest change in a repository.)"
3705 msgstr ""
3707 #. type: Content of: <book><chapter><sect1><para>
3708 #: ../en/ch02-tour-basic.xml:245
3709 msgid ""
3710 "The default output printed by <command role=\"hg-cmd\">hg log</command> is "
3711 "purely a summary; it is missing a lot of detail."
3712 msgstr ""
3714 #. type: Content of: <book><chapter><sect1><para>
3715 #: ../en/ch02-tour-basic.xml:249
3716 msgid ""
3717 "<xref linkend=\"fig:tour-basic:history\"/> provides a graphical "
3718 "representation of the history of the <filename class=\"directory\">hello</"
3719 "filename> repository, to make it a little easier to see which direction "
3720 "history is <quote>flowing</quote> in. We'll be returning to this figure "
3721 "several times in this chapter and the chapter that follows."
3722 msgstr ""
3724 #. type: Content of: <book><chapter><sect1><figure><title>
3725 #: ../en/ch02-tour-basic.xml:258
3726 msgid ""
3727 "Graphical history of the <filename class=\"directory\">hello</filename> "
3728 "repository"
3729 msgstr "版本库 <filename class=\"directory\">hello</filename> 的历史图"
3731 #. type: Content of: <book><chapter><sect1><figure>
3732 #: ../en/ch02-tour-basic.xml:260 ../en/ch03-tour-merge.xml:61
3733 #: ../en/ch03-tour-merge.xml:207 ../en/ch04-concepts.xml:290
3734 msgid "<placeholder type=\"mediaobject\" id=\"0\"/>"
3735 msgstr ""
3737 #. type: Content of: <book><chapter><sect1><figure><mediaobject>
3738 #: ../en/ch02-tour-basic.xml:261
3739 msgid ""
3740 "<imageobject><imagedata fileref=\"figs/tour-history.png\"/></imageobject>"
3741 msgstr ""
3743 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject><textobject><phrase>
3744 #: ../en/ch02-tour-basic.xml:262 ../en/ch03-tour-merge.xml:63
3745 #: ../en/ch03-tour-merge.xml:95 ../en/ch03-tour-merge.xml:182
3746 #: ../en/ch03-tour-merge.xml:209 ../en/ch03-tour-merge.xml:279
3747 #: ../en/ch04-concepts.xml:59 ../en/ch04-concepts.xml:108
3748 #: ../en/ch04-concepts.xml:198 ../en/ch04-concepts.xml:292
3749 #: ../en/ch04-concepts.xml:347 ../en/ch04-concepts.xml:362
3750 #: ../en/ch04-concepts.xml:403 ../en/ch04-concepts.xml:423
3751 #: ../en/ch04-concepts.xml:469 ../en/ch06-collab.xml:316
3752 #: ../en/ch09-undo.xml:344 ../en/ch09-undo.xml:391 ../en/ch09-undo.xml:464
3753 #: ../en/ch09-undo.xml:502 ../en/ch09-undo.xml:658 ../en/ch09-undo.xml:682
3754 #: ../en/ch09-undo.xml:700 ../en/ch09-undo.xml:714 ../en/ch09-undo.xml:727
3755 #: ../en/ch12-mq.xml:413
3756 msgid "XXX add text"
3757 msgstr ""
3759 #. type: Content of: <book><chapter><sect1><sect2><title>
3760 #: ../en/ch02-tour-basic.xml:267
3761 msgid "Changesets, revisions, and talking to other people"
3762 msgstr "修改集,版本,与其它用户交互"
3764 #. type: Content of: <book><chapter><sect1><sect2><para>
3765 #: ../en/ch02-tour-basic.xml:270
3766 msgid ""
3767 "As English is a notoriously sloppy language, and computer science has a "
3768 "hallowed history of terminological confusion (why use one term when four will "
3769 "do?), revision control has a variety of words and phrases that mean the same "
3770 "thing. If you are talking about Mercurial history with other people, you "
3771 "will find that the word <quote>changeset</quote> is often compressed to "
3772 "<quote>change</quote> or (when written) <quote>cset</quote>, and sometimes a "
3773 "changeset is referred to as a <quote>revision</quote> or a <quote>rev</quote>."
3774 msgstr ""
3776 #. type: Content of: <book><chapter><sect1><sect2><para>
3777 #: ../en/ch02-tour-basic.xml:280
3778 msgid ""
3779 "While it doesn't matter what <emphasis>word</emphasis> you use to refer to "
3780 "the concept of <quote>a changeset</quote>, the <emphasis>identifier</"
3781 "emphasis> that you use to refer to <quote>a <emphasis>specific</emphasis> "
3782 "changeset</quote> is of great importance. Recall that the <literal>changeset</"
3783 "literal> field in the output from <command role=\"hg-cmd\">hg log</command> "
3784 "identifies a changeset using both a number and a hexadecimal string."
3785 msgstr ""
3787 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
3788 #: ../en/ch02-tour-basic.xml:289
3789 msgid ""
3790 "The revision number is a handy notation that is <emphasis>only valid in that "
3791 "repository</emphasis>."
3792 msgstr ""
3794 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
3795 #: ../en/ch02-tour-basic.xml:292
3796 msgid ""
3797 "The hexadecimal string is the <emphasis>permanent, unchanging identifier</"
3798 "emphasis> that will always identify that exact changeset in <emphasis>every</"
3799 "emphasis> copy of the repository."
3800 msgstr ""
3802 #. type: Content of: <book><chapter><sect1><sect2><para>
3803 #: ../en/ch02-tour-basic.xml:298
3804 msgid ""
3805 "This distinction is important. If you send someone an email talking about "
3806 "<quote>revision 33</quote>, there's a high likelihood that their revision 33 "
3807 "will <emphasis>not be the same</emphasis> as yours. The reason for this is "
3808 "that a revision number depends on the order in which changes arrived in a "
3809 "repository, and there is no guarantee that the same changes will happen in "
3810 "the same order in different repositories. Three changes <literal>a,b,c</"
3811 "literal> can easily appear in one repository as <literal>0,1,2</literal>, "
3812 "while in another as <literal>0,2,1</literal>."
3813 msgstr ""
3815 #. type: Content of: <book><chapter><sect1><sect2><para>
3816 #: ../en/ch02-tour-basic.xml:310
3817 msgid ""
3818 "Mercurial uses revision numbers purely as a convenient shorthand. If you "
3819 "need to discuss a changeset with someone, or make a record of a changeset for "
3820 "some other reason (for example, in a bug report), use the hexadecimal "
3821 "identifier."
3822 msgstr ""
3824 #. type: Content of: <book><chapter><sect1><sect2><title>
3825 #: ../en/ch02-tour-basic.xml:318
3826 msgid "Viewing specific revisions"
3827 msgstr "察看指定版本"
3829 #. type: Content of: <book><chapter><sect1><sect2><para>
3830 #: ../en/ch02-tour-basic.xml:320
3831 msgid ""
3832 "To narrow the output of <command role=\"hg-cmd\">hg log</command> down to a "
3833 "single revision, use the <option role=\"hg-opt-log\">-r</option> (or <option "
3834 "role=\"hg-opt-log\">--rev</option>) option. You can use either a revision "
3835 "number or a hexadecimal identifier, and you can provide as many revisions as "
3836 "you want."
3837 msgstr ""
3839 #. type: Content of: <book><chapter><sect1><sect2><para>
3840 #: ../en/ch02-tour-basic.xml:329
3841 msgid ""
3842 "If you want to see the history of several revisions without having to list "
3843 "each one, you can use <emphasis>range notation</emphasis>; this lets you "
3844 "express the idea <quote>I want all revisions between <literal>abc</literal> "
3845 "and <literal>def</literal>, inclusive</quote>."
3846 msgstr ""
3848 #. type: Content of: <book><chapter><sect1><sect2><para>
3849 #: ../en/ch02-tour-basic.xml:337
3850 msgid ""
3851 "Mercurial also honours the order in which you specify revisions, so <command "
3852 "role=\"hg-cmd\">hg log -r 2:4</command> prints 2, 3, and 4. while <command "
3853 "role=\"hg-cmd\">hg log -r 4:2</command> prints 4, 3, and 2."
3854 msgstr ""
3856 #. type: Content of: <book><chapter><sect1><sect2><title>
3857 #: ../en/ch02-tour-basic.xml:344
3858 msgid "More detailed information"
3859 msgstr "更详细的信息"
3861 #. type: Content of: <book><chapter><sect1><sect2><para>
3862 #: ../en/ch02-tour-basic.xml:346
3863 msgid ""
3864 "While the summary information printed by <command role=\"hg-cmd\">hg log</"
3865 "command> is useful if you already know what you're looking for, you may need "
3866 "to see a complete description of the change, or a list of the files changed, "
3867 "if you're trying to decide whether a changeset is the one you're looking for. "
3868 "The <command role=\"hg-cmd\">hg log</command> command's <option role=\"hg-opt-"
3869 "global\">-v</option> (or <option role=\"hg-opt-global\">--verbose</option>) "
3870 "option gives you this extra detail."
3871 msgstr ""
3873 #. type: Content of: <book><chapter><sect1><sect2><para>
3874 #: ../en/ch02-tour-basic.xml:358
3875 msgid ""
3876 "If you want to see both the description and content of a change, add the "
3877 "<option role=\"hg-opt-log\">-p</option> (or <option role=\"hg-opt-log\">--"
3878 "patch</option>) option. This displays the content of a change as a "
3879 "<emphasis>unified diff</emphasis> (if you've never seen a unified diff "
3880 "before, see <xref linkend=\"sec:mq:patch\"/> for an overview)."
3881 msgstr ""
3883 #. type: Content of: <book><chapter><sect1><sect2><para>
3884 #: ../en/ch02-tour-basic.xml:368
3885 msgid ""
3886 "The <option role=\"hg-opt-log\">-p</option> option is tremendously useful, so "
3887 "it's well worth remembering."
3888 msgstr ""
3890 #. type: Content of: <book><chapter><sect1><title>
3891 #: ../en/ch02-tour-basic.xml:375
3892 msgid "All about command options"
3893 msgstr "命令选项"
3895 #. type: Content of: <book><chapter><sect1><para>
3896 #: ../en/ch02-tour-basic.xml:377
3897 msgid ""
3898 "Let's take a brief break from exploring Mercurial commands to discuss a "
3899 "pattern in the way that they work; you may find this useful to keep in mind "
3900 "as we continue our tour."
3901 msgstr ""
3903 #. type: Content of: <book><chapter><sect1><para>
3904 #: ../en/ch02-tour-basic.xml:381
3905 msgid ""
3906 "Mercurial has a consistent and straightforward approach to dealing with the "
3907 "options that you can pass to commands. It follows the conventions for "
3908 "options that are common to modern Linux and Unix systems."
3909 msgstr ""
3911 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
3912 #: ../en/ch02-tour-basic.xml:388
3913 msgid ""
3914 "Every option has a long name. For example, as we've already seen, the "
3915 "<command role=\"hg-cmd\">hg log</command> command accepts a <option role=\"hg-"
3916 "opt-log\">--rev</option> option."
3917 msgstr ""
3919 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
3920 #: ../en/ch02-tour-basic.xml:394
3921 msgid ""
3922 "Most options have short names, too. Instead of <option role=\"hg-opt-log\">--"
3923 "rev</option>, we can use <option role=\"hg-opt-log\">-r</option>. (The "
3924 "reason that some options don't have short names is that the options in "
3925 "question are rarely used.)"
3926 msgstr ""
3928 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
3929 #: ../en/ch02-tour-basic.xml:401
3930 msgid ""
3931 "Long options start with two dashes (e.g. <option role=\"hg-opt-log\">--rev</"
3932 "option>), while short options start with one (e.g. <option role=\"hg-opt-log"
3933 "\">-r</option>)."
3934 msgstr ""
3936 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
3937 #: ../en/ch02-tour-basic.xml:407
3938 msgid ""
3939 "Option naming and usage is consistent across commands. For example, every "
3940 "command that lets you specify a changeset ID or revision number accepts both "
3941 "<option role=\"hg-opt-log\">-r</option> and <option role=\"hg-opt-log\">--"
3942 "rev</option> arguments."
3943 msgstr ""
3945 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
3946 #: ../en/ch02-tour-basic.xml:414
3947 msgid ""
3948 "If you are using short options, you can save typing by running them together. "
3949 "For example, the command <command role=\"hg-cmd\">hg log -v -p -r 2</command> "
3950 "can be written as <command role=\"hg-cmd\">hg log -vpr2</command>."
3951 msgstr ""
3953 #. type: Content of: <book><chapter><sect1><para>
3954 #: ../en/ch02-tour-basic.xml:421
3955 msgid ""
3956 "In the examples throughout this book, I usually use short options instead of "
3957 "long. This simply reflects my own preference, so don't read anything "
3958 "significant into it."
3959 msgstr ""
3961 #. type: Content of: <book><chapter><sect1><para>
3962 #: ../en/ch02-tour-basic.xml:425
3963 msgid ""
3964 "Most commands that print output of some kind will print more output when "
3965 "passed a <option role=\"hg-opt-global\">-v</option> (or <option role=\"hg-opt-"
3966 "global\">--verbose</option>) option, and less when passed <option role=\"hg-"
3967 "opt-global\">-q</option> (or <option role=\"hg-opt-global\">--quiet</option>)."
3968 msgstr ""
3970 #. type: Content of: <book><chapter><sect1><note><title>
3971 #: ../en/ch02-tour-basic.xml:432
3972 msgid "Option naming consistency"
3973 msgstr ""
3975 #. type: Content of: <book><chapter><sect1><note><para>
3976 #: ../en/ch02-tour-basic.xml:434
3977 msgid ""
3978 "Almost always, Mercurial commands use consistent option names to refer to the "
3979 "same concepts. For instance, if a command deals with changesets, you'll "
3980 "always identify them with <option role=\"hg-opt-log\">--rev</option> or "
3981 "<option role=\"hg-opt-log\">-r</option>. This consistent use of option names "
3982 "makes it easier to remember what options a particular command takes."
3983 msgstr ""
3985 #. type: Content of: <book><chapter><sect1><title>
3986 #: ../en/ch02-tour-basic.xml:445
3987 msgid "Making and reviewing changes"
3988 msgstr "创建和复审修改"
3990 #. type: Content of: <book><chapter><sect1><para>
3991 #: ../en/ch02-tour-basic.xml:447
3992 msgid ""
3993 "Now that we have a grasp of viewing history in Mercurial, let's take a look "
3994 "at making some changes and examining them."
3995 msgstr ""
3997 #. type: Content of: <book><chapter><sect1><para>
3998 #: ../en/ch02-tour-basic.xml:451
3999 msgid ""
4000 "The first thing we'll do is isolate our experiment in a repository of its "
4001 "own. We use the <command role=\"hg-cmd\">hg clone</command> command, but we "
4002 "don't need to clone a copy of the remote repository. Since we already have a "
4003 "copy of it locally, we can just clone that instead. This is much faster than "
4004 "cloning over the network, and cloning a local repository uses less disk space "
4005 "in most cases, too<placeholder type=\"footnote\" id=\"0\"/>."
4006 msgstr ""
4008 #. type: Content of: <book><chapter><sect1><para><footnote><para>
4009 #: ../en/ch02-tour-basic.xml:458
4010 msgid ""
4011 "The saving of space arises when source and destination repositories are on "
4012 "the same filesystem, in which case Mercurial will use hardlinks to do copy-on-"
4013 "write sharing of its internal metadata. If that explanation meant nothing to "
4014 "you, don't worry: everything happens transparently and automatically, and you "
4015 "don't need to understand it."
4016 msgstr ""
4018 #. type: Content of: <book><chapter><sect1><para>
4019 #: ../en/ch02-tour-basic.xml:468
4020 msgid ""
4021 "As an aside, it's often good practice to keep a <quote>pristine</quote> copy "
4022 "of a remote repository around, which you can then make temporary clones of to "
4023 "create sandboxes for each task you want to work on. This lets you work on "
4024 "multiple tasks in parallel, each isolated from the others until it's complete "
4025 "and you're ready to integrate it back. Because local clones are so cheap, "
4026 "there's almost no overhead to cloning and destroying repositories whenever "
4027 "you want."
4028 msgstr ""
4030 #. type: Content of: <book><chapter><sect1><para>
4031 #: ../en/ch02-tour-basic.xml:477
4032 msgid ""
4033 "In our <filename class=\"directory\">my-hello</filename> repository, we have "
4034 "a file <filename>hello.c</filename> that contains the classic <quote>hello, "
4035 "world</quote> program."
4036 msgstr ""
4038 #. type: Content of: <book><chapter><sect1><para>
4039 #: ../en/ch02-tour-basic.xml:483
4040 msgid "Let's edit this file so that it prints a second line of output."
4041 msgstr ""
4043 #. type: Content of: <book><chapter><sect1><para>
4044 #: ../en/ch02-tour-basic.xml:488
4045 msgid ""
4046 "Mercurial's <command role=\"hg-cmd\">hg status</command> command will tell us "
4047 "what Mercurial knows about the files in the repository."
4048 msgstr ""
4050 #. type: Content of: <book><chapter><sect1><para>
4051 #: ../en/ch02-tour-basic.xml:494
4052 msgid ""
4053 "The <command role=\"hg-cmd\">hg status</command> command prints no output for "
4054 "some files, but a line starting with <quote><literal>M</literal></quote> for "
4055 "<filename>hello.c</filename>. Unless you tell it to, <command role=\"hg-cmd"
4056 "\">hg status</command> will not print any output for files that have not been "
4057 "modified."
4058 msgstr ""
4060 #. type: Content of: <book><chapter><sect1><para>
4061 #: ../en/ch02-tour-basic.xml:501
4062 msgid ""
4063 "The <quote><literal>M</literal></quote> indicates that Mercurial has noticed "
4064 "that we modified <filename>hello.c</filename>. We didn't need to "
4065 "<emphasis>inform</emphasis> Mercurial that we were going to modify the file "
4066 "before we started, or that we had modified the file after we were done; it "
4067 "was able to figure this out itself."
4068 msgstr ""
4070 #. type: Content of: <book><chapter><sect1><para>
4071 #: ../en/ch02-tour-basic.xml:509
4072 msgid ""
4073 "It's somewhat helpful to know that we've modified <filename>hello.c</"
4074 "filename>, but we might prefer to know exactly <emphasis>what</emphasis> "
4075 "changes we've made to it. To do this, we use the <command role=\"hg-cmd\">hg "
4076 "diff</command> command."
4077 msgstr ""
4079 #. type: Content of: <book><chapter><sect1><title>
4080 #: ../en/ch02-tour-basic.xml:518 ../en/ch12-mq.xml:187
4081 msgid "Understanding patches"
4082 msgstr "理解补丁"
4084 #. type: Content of: <book><chapter><sect1><tip><para>
4085 #: ../en/ch02-tour-basic.xml:520
4086 msgid ""
4087 "Remember to take a look at <xref linkend=\"sec:mq:patch\"/> if you don't know "
4088 "how to read output above."
4089 msgstr ""
4091 #. type: Content of: <book><chapter><sect1><title>
4092 #: ../en/ch02-tour-basic.xml:526
4093 msgid "Recording changes in a new changeset"
4094 msgstr "在新修改集中记录修改"
4096 #. type: Content of: <book><chapter><sect1><para>
4097 #: ../en/ch02-tour-basic.xml:528
4098 msgid ""
4099 "We can modify files, build and test our changes, and use <command role=\"hg-"
4100 "cmd\">hg status</command> and <command role=\"hg-cmd\">hg diff</command> to "
4101 "review our changes, until we're satisfied with what we've done and arrive at "
4102 "a natural stopping point where we want to record our work in a new changeset."
4103 msgstr ""
4105 #. type: Content of: <book><chapter><sect1><para>
4106 #: ../en/ch02-tour-basic.xml:535
4107 msgid ""
4108 "The <command role=\"hg-cmd\">hg commit</command> command lets us create a new "
4109 "changeset; we'll usually refer to this as <quote>making a commit</quote> or "
4110 "<quote>committing</quote>."
4111 msgstr ""
4113 #. type: Content of: <book><chapter><sect1><sect2><title>
4114 #: ../en/ch02-tour-basic.xml:541
4115 msgid "Setting up a username"
4116 msgstr "配置用户名称"
4118 #. type: Content of: <book><chapter><sect1><sect2><para>
4119 #: ../en/ch02-tour-basic.xml:543
4120 msgid ""
4121 "When you try to run <command role=\"hg-cmd\">hg commit</command> for the "
4122 "first time, it is not guaranteed to succeed. Mercurial records your name and "
4123 "address with each change that you commit, so that you and others will later "
4124 "be able to tell who made each change. Mercurial tries to automatically "
4125 "figure out a sensible username to commit the change with. It will attempt "
4126 "each of the following methods, in order:"
4127 msgstr ""
4129 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
4130 #: ../en/ch02-tour-basic.xml:552
4131 msgid ""
4132 "If you specify a <option role=\"hg-opt-commit\">-u</option> option to the "
4133 "<command role=\"hg-cmd\">hg commit</command> command on the command line, "
4134 "followed by a username, this is always given the highest precedence."
4135 msgstr ""
4137 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
4138 #: ../en/ch02-tour-basic.xml:557
4139 msgid ""
4140 "If you have set the <envar>HGUSER</envar> environment variable, this is "
4141 "checked next."
4142 msgstr ""
4144 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
4145 #: ../en/ch02-tour-basic.xml:560
4146 msgid ""
4147 "If you create a file in your home directory called <filename role=\"special"
4148 "\">.hgrc</filename>, with a <envar role=\"rc-item-ui\">username</envar> "
4149 "entry, that will be used next. To see what the contents of this file should "
4150 "look like, refer to <xref linkend=\"sec:tour-basic:username\"/> below."
4151 msgstr ""
4153 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
4154 #: ../en/ch02-tour-basic.xml:568
4155 msgid ""
4156 "If you have set the <envar>EMAIL</envar> environment variable, this will be "
4157 "used next."
4158 msgstr ""
4160 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
4161 #: ../en/ch02-tour-basic.xml:571
4162 msgid ""
4163 "Mercurial will query your system to find out your local user name and host "
4164 "name, and construct a username from these components. Since this often "
4165 "results in a username that is not very useful, it will print a warning if it "
4166 "has to do this."
4167 msgstr ""
4169 #. type: Content of: <book><chapter><sect1><sect2><para>
4170 #: ../en/ch02-tour-basic.xml:578
4171 msgid ""
4172 "If all of these mechanisms fail, Mercurial will fail, printing an error "
4173 "message. In this case, it will not let you commit until you set up a "
4174 "username."
4175 msgstr ""
4177 #. type: Content of: <book><chapter><sect1><sect2><para>
4178 #: ../en/ch02-tour-basic.xml:582
4179 msgid ""
4180 "You should think of the <envar>HGUSER</envar> environment variable and the "
4181 "<option role=\"hg-opt-commit\">-u</option> option to the <command role=\"hg-"
4182 "cmd\">hg commit</command> command as ways to <emphasis>override</emphasis> "
4183 "Mercurial's default selection of username. For normal use, the simplest and "
4184 "most robust way to set a username for yourself is by creating a <filename "
4185 "role=\"special\">.hgrc</filename> file; see below for details."
4186 msgstr ""
4188 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
4189 #: ../en/ch02-tour-basic.xml:591
4190 msgid "Creating a Mercurial configuration file"
4191 msgstr "创建 Mercurial 的配置文件"
4193 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
4194 #: ../en/ch02-tour-basic.xml:593
4195 msgid ""
4196 "To set a user name, use your favorite editor to create a file called "
4197 "<filename role=\"special\">.hgrc</filename> in your home directory. "
4198 "Mercurial will use this file to look up your personalised configuration "
4199 "settings. The initial contents of your <filename role=\"special\">.hgrc</"
4200 "filename> should look like this."
4201 msgstr ""
4203 #. type: Content of: <book><chapter><sect1><sect2><sect3><tip><title>
4204 #: ../en/ch02-tour-basic.xml:602
4205 msgid "<quote>Home directory</quote> on Windows"
4206 msgstr ""
4208 #. type: Content of: <book><chapter><sect1><sect2><sect3><tip><para>
4209 #: ../en/ch02-tour-basic.xml:604
4210 msgid ""
4211 "When we refer to your home directory, on an English language installation of "
4212 "Windows this will usually be a folder named after your user name in "
4213 "<filename>C:\\Documents and Settings</filename>. You can find out the exact "
4214 "name of your home directory by opening a command prompt window and running "
4215 "the following command."
4216 msgstr ""
4218 #. type: Content of: <book><chapter><sect1><sect2><sect3><tip><screen><prompt>
4219 #: ../en/ch02-tour-basic.xml:612
4220 msgid "C:\\>"
4221 msgstr "C:\\>"
4223 #. type: Content of: <book><chapter><sect1><sect2><sect3><tip><screen><userinput>
4224 #: ../en/ch02-tour-basic.xml:612
4225 msgid "echo %UserProfile%"
4226 msgstr "echo %UserProfile%"
4228 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
4229 #: ../en/ch02-tour-basic.xml:619
4230 msgid ""
4231 "The <quote><literal>[ui]</literal></quote> line begins a <emphasis>section</"
4232 "emphasis> of the config file, so you can read the <quote><literal>username "
4233 "= ...</literal></quote> line as meaning <quote>set the value of the "
4234 "<literal>username</literal> item in the <literal>ui</literal> section</"
4235 "quote>. A section continues until a new section begins, or the end of the "
4236 "file. Mercurial ignores empty lines and treats any text from "
4237 "<quote><literal>#</literal></quote> to the end of a line as a comment."
4238 msgstr ""
4240 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
4241 #: ../en/ch02-tour-basic.xml:632
4242 msgid "Choosing a user name"
4243 msgstr "选择用户名称"
4245 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
4246 #: ../en/ch02-tour-basic.xml:634
4247 msgid ""
4248 "You can use any text you like as the value of the <literal>username</literal> "
4249 "config item, since this information is for reading by other people, but will "
4250 "not be interpreted by Mercurial. The convention that most people follow is "
4251 "to use their name and email address, as in the example above."
4252 msgstr ""
4254 #. type: Content of: <book><chapter><sect1><sect2><sect3><note><para>
4255 #: ../en/ch02-tour-basic.xml:641
4256 msgid ""
4257 "Mercurial's built-in web server obfuscates email addresses, to make it more "
4258 "difficult for the email harvesting tools that spammers use. This reduces the "
4259 "likelihood that you'll start receiving more junk email if you publish a "
4260 "Mercurial repository on the web."
4261 msgstr ""
4263 #. type: Content of: <book><chapter><sect1><sect2><title>
4264 #: ../en/ch02-tour-basic.xml:650
4265 msgid "Writing a commit message"
4266 msgstr "写提交日志"
4268 #. type: Content of: <book><chapter><sect1><sect2><para>
4269 #: ../en/ch02-tour-basic.xml:652
4270 msgid ""
4271 "When we commit a change, Mercurial drops us into a text editor, to enter a "
4272 "message that will describe the modifications we've made in this changeset. "
4273 "This is called the <emphasis>commit message</emphasis>. It will be a record "
4274 "for readers of what we did and why, and it will be printed by <command role="
4275 "\"hg-cmd\">hg log</command> after we've finished committing."
4276 msgstr ""
4278 #. type: Content of: <book><chapter><sect1><sect2><para>
4279 #: ../en/ch02-tour-basic.xml:662
4280 msgid ""
4281 "The editor that the <command role=\"hg-cmd\">hg commit</command> command "
4282 "drops us into will contain an empty line or two, followed by a number of "
4283 "lines starting with <quote><literal>HG:</literal></quote>."
4284 msgstr ""
4286 #. type: Content of: <book><chapter><sect1><sect2><para>
4287 #: ../en/ch02-tour-basic.xml:676
4288 msgid ""
4289 "Mercurial ignores the lines that start with <quote><literal>HG:</literal></"
4290 "quote>; it uses them only to tell us which files it's recording changes to. "
4291 "Modifying or deleting these lines has no effect."
4292 msgstr ""
4294 #. type: Content of: <book><chapter><sect1><sect2><title>
4295 #: ../en/ch02-tour-basic.xml:682
4296 msgid "Writing a good commit message"
4297 msgstr "写好提交日志"
4299 #. type: Content of: <book><chapter><sect1><sect2><para>
4300 #: ../en/ch02-tour-basic.xml:684
4301 msgid ""
4302 "Since <command role=\"hg-cmd\">hg log</command> only prints the first line of "
4303 "a commit message by default, it's best to write a commit message whose first "
4304 "line stands alone. Here's a real example of a commit message that "
4305 "<emphasis>doesn't</emphasis> follow this guideline, and hence has a summary "
4306 "that is not readable."
4307 msgstr ""
4309 #. type: Content of: <book><chapter><sect1><sect2><para>
4310 #: ../en/ch02-tour-basic.xml:697
4311 msgid ""
4312 "As far as the remainder of the contents of the commit message are concerned, "
4313 "there are no hard-and-fast rules. Mercurial itself doesn't interpret or care "
4314 "about the contents of the commit message, though your project may have "
4315 "policies that dictate a certain kind of formatting."
4316 msgstr ""
4318 #. type: Content of: <book><chapter><sect1><sect2><para>
4319 #: ../en/ch02-tour-basic.xml:702
4320 msgid ""
4321 "My personal preference is for short, but informative, commit messages that "
4322 "tell me something that I can't figure out with a quick glance at the output "
4323 "of <command role=\"hg-cmd\">hg log --patch</command>."
4324 msgstr ""
4326 #. type: Content of: <book><chapter><sect1><sect2><para>
4327 #: ../en/ch02-tour-basic.xml:706
4328 msgid ""
4329 "If we run the <command role=\"hg-cmd\">hg commit</command> command without "
4330 "any arguments, it records all of the changes we've made, as reported by "
4331 "<command role=\"hg-cmd\">hg status</command> and <command role=\"hg-cmd\">hg "
4332 "diff</command>."
4333 msgstr ""
4335 #. type: Content of: <book><chapter><sect1><sect2><note><title>
4336 #: ../en/ch02-tour-basic.xml:713
4337 msgid "A surprise for Subversion users"
4338 msgstr ""
4340 #. type: Content of: <book><chapter><sect1><sect2><note><para>
4341 #: ../en/ch02-tour-basic.xml:715
4342 msgid ""
4343 "Like other Mercurial commands, if we don't supply explicit names to commit to "
4344 "the <command role=\"hg-cmd\">hg commit</command>, it will operate across a "
4345 "repository's entire working directory. Be wary of this if you're coming from "
4346 "the Subversion or CVS world, since you might expect it to operate only on the "
4347 "current directory that you happen to be visiting and its subdirectories."
4348 msgstr ""
4350 #. type: Content of: <book><chapter><sect1><sect2><title>
4351 #: ../en/ch02-tour-basic.xml:726
4352 msgid "Aborting a commit"
4353 msgstr "终止提交"
4355 #. type: Content of: <book><chapter><sect1><sect2><para>
4356 #: ../en/ch02-tour-basic.xml:728
4357 msgid ""
4358 "If you decide that you don't want to commit while in the middle of editing a "
4359 "commit message, simply exit from your editor without saving the file that "
4360 "it's editing. This will cause nothing to happen to either the repository or "
4361 "the working directory."
4362 msgstr ""
4364 #. type: Content of: <book><chapter><sect1><sect2><title>
4365 #: ../en/ch02-tour-basic.xml:736
4366 msgid "Admiring our new handiwork"
4367 msgstr "欣赏我们的成果"
4369 #. type: Content of: <book><chapter><sect1><sect2><para>
4370 #: ../en/ch02-tour-basic.xml:738
4371 msgid ""
4372 "Once we've finished the commit, we can use the <command role=\"hg-cmd\">hg "
4373 "tip</command> command to display the changeset we just created. This command "
4374 "produces output that is identical to <command role=\"hg-cmd\">hg log</"
4375 "command>, but it only displays the newest revision in the repository."
4376 msgstr ""
4378 #. type: Content of: <book><chapter><sect1><sect2><para>
4379 #: ../en/ch02-tour-basic.xml:746
4380 msgid ""
4381 "We refer to the newest revision in the repository as the <emphasis>tip "
4382 "revision</emphasis>, or simply the <emphasis>tip</emphasis>."
4383 msgstr ""
4385 #. type: Content of: <book><chapter><sect1><sect2><para>
4386 #: ../en/ch02-tour-basic.xml:750
4387 msgid ""
4388 "By the way, the <command role=\"hg-cmd\">hg tip</command> command accepts "
4389 "many of the same options as <command role=\"hg-cmd\">hg log</command>, so "
4390 "<option role=\"hg-opt-global\">-v</option> above indicates <quote>be verbose</"
4391 "quote>, <option role=\"hg-opt-tip\">-p</option> specifies <quote>print a "
4392 "patch</quote>. The use of <option role=\"hg-opt-tip\">-p</option> to print "
4393 "patches is another example of the consistent naming we mentioned earlier."
4394 msgstr ""
4396 #. type: Content of: <book><chapter><sect1><title>
4397 #: ../en/ch02-tour-basic.xml:762
4398 msgid "Sharing changes"
4399 msgstr "共享修改"
4401 #. type: Content of: <book><chapter><sect1><para>
4402 #: ../en/ch02-tour-basic.xml:764
4403 msgid ""
4404 "We mentioned earlier that repositories in Mercurial are self-contained. This "
4405 "means that the changeset we just created exists only in our <filename class="
4406 "\"directory\">my-hello</filename> repository. Let's look at a few ways that "
4407 "we can propagate this change into other repositories."
4408 msgstr ""
4410 #. type: Content of: <book><chapter><sect1><sect2><title>
4411 #: ../en/ch02-tour-basic.xml:772
4412 msgid "Pulling changes from another repository"
4413 msgstr "从其它版本库取得修改"
4415 #. type: Content of: <book><chapter><sect1><sect2><para>
4416 #: ../en/ch02-tour-basic.xml:774
4417 msgid ""
4418 "To get started, let's clone our original <filename class=\"directory\">hello</"
4419 "filename> repository, which does not contain the change we just committed. "
4420 "We'll call our temporary repository <filename class=\"directory\">hello-pull</"
4421 "filename>."
4422 msgstr ""
4424 #. type: Content of: <book><chapter><sect1><sect2><para>
4425 #: ../en/ch02-tour-basic.xml:782
4426 msgid ""
4427 "We'll use the <command role=\"hg-cmd\">hg pull</command> command to bring "
4428 "changes from <filename class=\"directory\">my-hello</filename> into <filename "
4429 "class=\"directory\">hello-pull</filename>. However, blindly pulling unknown "
4430 "changes into a repository is a somewhat scary prospect. Mercurial provides "
4431 "the <command role=\"hg-cmd\">hg incoming</command> command to tell us what "
4432 "changes the <command role=\"hg-cmd\">hg pull</command> command "
4433 "<emphasis>would</emphasis> pull into the repository, without actually pulling "
4434 "the changes in."
4435 msgstr ""
4437 #. type: Content of: <book><chapter><sect1><sect2><para>
4438 #: ../en/ch02-tour-basic.xml:795
4439 msgid ""
4440 "Bringing changes into a repository is a simple matter of running the <command "
4441 "role=\"hg-cmd\">hg pull</command> command, and optionally telling it which "
4442 "repository to pull from."
4443 msgstr ""
4445 #. type: Content of: <book><chapter><sect1><sect2><para>
4446 #: ../en/ch02-tour-basic.xml:801
4447 msgid ""
4448 "As you can see from the before-and-after output of <command role=\"hg-cmd"
4449 "\">hg tip</command>, we have successfully pulled changes into our "
4450 "repository. However, Mercurial separates pulling changes in from updating "
4451 "the working directory. There remains one step before we will see the changes "
4452 "that we just pulled appear in the working directory."
4453 msgstr ""
4455 #. type: Content of: <book><chapter><sect1><sect2><tip><title>
4456 #: ../en/ch02-tour-basic.xml:810
4457 msgid "Pulling specific changes"
4458 msgstr "提取指定的修改"
4460 #. type: Content of: <book><chapter><sect1><sect2><tip><para>
4461 #: ../en/ch02-tour-basic.xml:812
4462 msgid ""
4463 "It is possible that due to the delay between running <command role=\"hg-cmd"
4464 "\">hg incoming</command> and <command role=\"hg-cmd\">hg pull</command>, you "
4465 "may not see all changesets that will be brought from the other repository. "
4466 "Suppose you're pulling changes from a repository on the network somewhere. "
4467 "While you are looking at the <command role=\"hg-cmd\">hg incoming</command> "
4468 "output, and before you pull those changes, someone might have committed "
4469 "something in the remote repository. This means that it's possible to pull "
4470 "more changes than you saw when using <command role=\"hg-cmd\">hg incoming</"
4471 "command>."
4472 msgstr ""
4474 #. type: Content of: <book><chapter><sect1><sect2><tip><para>
4475 #: ../en/ch02-tour-basic.xml:824
4476 msgid ""
4477 "If you only want to pull precisely the changes that were listed by <command "
4478 "role=\"hg-cmd\">hg incoming</command>, or you have some other reason to pull "
4479 "a subset of changes, simply identify the change that you want to pull by its "
4480 "changeset ID, e.g. <command>hg pull -r7e95bb</command>."
4481 msgstr ""
4483 #. type: Content of: <book><chapter><sect1><sect2><title>
4484 #: ../en/ch02-tour-basic.xml:834
4485 msgid "Updating the working directory"
4486 msgstr "更新工作目录"
4488 #. type: Content of: <book><chapter><sect1><sect2><para>
4489 #: ../en/ch02-tour-basic.xml:836
4490 msgid ""
4491 "We have so far glossed over the relationship between a repository and its "
4492 "working directory. The <command role=\"hg-cmd\">hg pull</command> command "
4493 "that we ran in <xref linkend=\"sec:tour:pull\"/> brought changes into the "
4494 "repository, but if we check, there's no sign of those changes in the working "
4495 "directory. This is because <command role=\"hg-cmd\">hg pull</command> does "
4496 "not (by default) touch the working directory. Instead, we use the <command "
4497 "role=\"hg-cmd\">hg update</command> command to do this."
4498 msgstr ""
4500 #. type: Content of: <book><chapter><sect1><sect2><para>
4501 #: ../en/ch02-tour-basic.xml:848
4502 msgid ""
4503 "It might seem a bit strange that <command role=\"hg-cmd\">hg pull</command> "
4504 "doesn't update the working directory automatically. There's actually a good "
4505 "reason for this: you can use <command role=\"hg-cmd\">hg update</command> to "
4506 "update the working directory to the state it was in at <emphasis>any "
4507 "revision</emphasis> in the history of the repository. If you had the working "
4508 "directory updated to an old revision&emdash;to hunt down the origin of a bug, "
4509 "say&emdash;and ran a <command role=\"hg-cmd\">hg pull</command> which "
4510 "automatically updated the working directory to a new revision, you might not "
4511 "be terribly happy."
4512 msgstr ""
4514 #. type: Content of: <book><chapter><sect1><sect2><para>
4515 #: ../en/ch02-tour-basic.xml:860
4516 msgid ""
4517 "Since pull-then-update is such a common sequence of operations, Mercurial "
4518 "lets you combine the two by passing the <option role=\"hg-opt-pull\">-u</"
4519 "option> option to <command role=\"hg-cmd\">hg pull</command>."
4520 msgstr ""
4522 #. type: Content of: <book><chapter><sect1><sect2><para>
4523 #: ../en/ch02-tour-basic.xml:865
4524 msgid ""
4525 "If you look back at the output of <command role=\"hg-cmd\">hg pull</command> "
4526 "in <xref linkend=\"sec:tour:pull\"/> when we ran it without <option role=\"hg-"
4527 "opt-pull\">-u</option>, you can see that it printed a helpful reminder that "
4528 "we'd have to take an explicit step to update the working directory."
4529 msgstr ""
4531 #. type: Content of: <book><chapter><sect1><sect2><para>
4532 #: ../en/ch02-tour-basic.xml:872
4533 msgid ""
4534 "To find out what revision the working directory is at, use the <command role="
4535 "\"hg-cmd\">hg parents</command> command."
4536 msgstr ""
4538 #. type: Content of: <book><chapter><sect1><sect2><para>
4539 #: ../en/ch02-tour-basic.xml:878
4540 msgid ""
4541 "If you look back at <xref linkend=\"fig:tour-basic:history\"/>, you'll see "
4542 "arrows connecting each changeset. The node that the arrow leads "
4543 "<emphasis>from</emphasis> in each case is a parent, and the node that the "
4544 "arrow leads <emphasis>to</emphasis> is its child. The working directory has "
4545 "a parent in just the same way; this is the changeset that the working "
4546 "directory currently contains."
4547 msgstr ""
4549 #. type: Content of: <book><chapter><sect1><sect2><para>
4550 #: ../en/ch02-tour-basic.xml:887
4551 msgid ""
4552 "To update the working directory to a particular revision, give a revision "
4553 "number or changeset ID to the <command role=\"hg-cmd\">hg update</command> "
4554 "command."
4555 msgstr ""
4557 #. type: Content of: <book><chapter><sect1><sect2><para>
4558 #: ../en/ch02-tour-basic.xml:893
4559 msgid ""
4560 "If you omit an explicit revision, <command role=\"hg-cmd\">hg update</"
4561 "command> will update to the tip revision, as shown by the second call to "
4562 "<command role=\"hg-cmd\">hg update</command> in the example above."
4563 msgstr ""
4565 #. type: Content of: <book><chapter><sect1><sect2><title>
4566 #: ../en/ch02-tour-basic.xml:901
4567 msgid "Pushing changes to another repository"
4568 msgstr "发布修改到其它版本库"
4570 #. type: Content of: <book><chapter><sect1><sect2><para>
4571 #: ../en/ch02-tour-basic.xml:903
4572 msgid ""
4573 "Mercurial lets us push changes to another repository, from the repository "
4574 "we're currently visiting. As with the example of <command role=\"hg-cmd\">hg "
4575 "pull</command> above, we'll create a temporary repository to push our changes "
4576 "into."
4577 msgstr ""
4579 #. type: Content of: <book><chapter><sect1><sect2><para>
4580 #: ../en/ch02-tour-basic.xml:911
4581 msgid ""
4582 "The <command role=\"hg-cmd\">hg outgoing</command> command tells us what "
4583 "changes would be pushed into another repository."
4584 msgstr ""
4586 #. type: Content of: <book><chapter><sect1><sect2><para>
4587 #: ../en/ch02-tour-basic.xml:917
4588 msgid ""
4589 "And the <command role=\"hg-cmd\">hg push</command> command does the actual "
4590 "push."
4591 msgstr ""
4593 #. type: Content of: <book><chapter><sect1><sect2><para>
4594 #: ../en/ch02-tour-basic.xml:922
4595 msgid ""
4596 "As with <command role=\"hg-cmd\">hg pull</command>, the <command role=\"hg-cmd"
4597 "\">hg push</command> command does not update the working directory in the "
4598 "repository that it's pushing changes into. Unlike <command role=\"hg-cmd\">hg "
4599 "pull</command>, <command role=\"hg-cmd\">hg push</command> does not provide a "
4600 "<literal>-u</literal> option that updates the other repository's working "
4601 "directory. This asymmetry is deliberate: the repository we're pushing to "
4602 "might be on a remote server and shared between several people. If we were to "
4603 "update its working directory while someone was working in it, their work "
4604 "would be disrupted."
4605 msgstr ""
4607 #. type: Content of: <book><chapter><sect1><sect2><para>
4608 #: ../en/ch02-tour-basic.xml:934
4609 msgid ""
4610 "What happens if we try to pull or push changes and the receiving repository "
4611 "already has those changes? Nothing too exciting."
4612 msgstr ""
4614 #. type: Content of: <book><chapter><sect1><sect2><title>
4615 #: ../en/ch02-tour-basic.xml:942
4616 msgid "Default locations"
4617 msgstr "默认位置"
4619 #. type: Content of: <book><chapter><sect1><sect2><para>
4620 #: ../en/ch02-tour-basic.xml:944
4621 msgid ""
4622 "When we clone a repository, Mercurial records the location of the repository "
4623 "we cloned in the <filename>.hg/hgrc</filename> file of the new repository. "
4624 "If we don't supply a location to <command>hg pull</command> from or "
4625 "<command>hg push</command> to, those commands will use this location as a "
4626 "default. The <command>hg incoming</command> and <command>hg outgoing</"
4627 "command> commands do so too."
4628 msgstr ""
4630 #. type: Content of: <book><chapter><sect1><sect2><para>
4631 #: ../en/ch02-tour-basic.xml:952
4632 msgid ""
4633 "If you open a repository's <filename>.hg/hgrc</filename> file in a text "
4634 "editor, you will see contents like the following."
4635 msgstr ""
4637 #. type: Content of: <book><chapter><sect1><sect2><para>
4638 #: ../en/ch02-tour-basic.xml:959
4639 msgid ""
4640 "It is possible&emdash;and often useful&emdash;to have the default location "
4641 "for <command>hg push</command> and <command>hg outgoing</command> be "
4642 "different from those for <command>hg pull</command> and <command>hg incoming</"
4643 "command>. We can do this by adding a <literal>default-push</literal> entry "
4644 "to the <literal>[paths]</literal> section of the <filename>.hg/hgrc</"
4645 "filename> file, as follows."
4646 msgstr ""
4648 #. type: Content of: <book><chapter><sect1><sect2><title>
4649 #: ../en/ch02-tour-basic.xml:973
4650 msgid "Sharing changes over a network"
4651 msgstr "通过网络共享修改"
4653 #. type: Content of: <book><chapter><sect1><sect2><para>
4654 #: ../en/ch02-tour-basic.xml:975
4655 msgid ""
4656 "The commands we have covered in the previous few sections are not limited to "
4657 "working with local repositories. Each works in exactly the same fashion over "
4658 "a network connection; simply pass in a URL instead of a local path."
4659 msgstr ""
4661 #. type: Content of: <book><chapter><sect1><sect2><para>
4662 #: ../en/ch02-tour-basic.xml:983
4663 msgid ""
4664 "In this example, we can see what changes we could push to the remote "
4665 "repository, but the repository is understandably not set up to let anonymous "
4666 "users push to it."
4667 msgstr ""
4669 #. type: Content of: <book><chapter><sect1><title>
4670 #: ../en/ch02-tour-basic.xml:993
4671 msgid "Starting a new project"
4672 msgstr "开始新项目"
4674 #. type: Content of: <book><chapter><sect1><para>
4675 #: ../en/ch02-tour-basic.xml:995
4676 msgid ""
4677 "It is just as easy to begin a new project as to work on one that already "
4678 "exists. The <command>hg init</command> command creates a new, empty "
4679 "Mercurial repository."
4680 msgstr ""
4682 #. type: Content of: <book><chapter><sect1><para>
4683 #: ../en/ch02-tour-basic.xml:1001
4684 msgid ""
4685 "This simply creates a repository named <filename>myproject</filename> in the "
4686 "current directory."
4687 msgstr ""
4689 #. type: Content of: <book><chapter><sect1><para>
4690 #: ../en/ch02-tour-basic.xml:1006
4691 msgid ""
4692 "We can tell that <filename>myproject</filename> is a Mercurial repository, "
4693 "because it contains a <filename>.hg</filename> directory."
4694 msgstr ""
4696 #. type: Content of: <book><chapter><sect1><para>
4697 #: ../en/ch02-tour-basic.xml:1012
4698 msgid ""
4699 "If we want to add some pre-existing files to the repository, we copy them "
4700 "into place, and tell Mercurial to start tracking them using the <command>hg "
4701 "add</command> command."
4702 msgstr ""
4704 #. type: Content of: <book><chapter><sect1><para>
4705 #: ../en/ch02-tour-basic.xml:1018
4706 msgid ""
4707 "Once we are satisfied that our project looks right, we commit our changes."
4708 msgstr ""
4710 #. type: Content of: <book><chapter><sect1><para>
4711 #: ../en/ch02-tour-basic.xml:1023
4712 msgid ""
4713 "It takes just a few moments to start using Mercurial on a new project, which "
4714 "is part of its appeal. Revision control is now so easy to work with, we can "
4715 "use it on the smallest of projects that we might not have considered with a "
4716 "more complicated tool."
4717 msgstr ""
4719 #. type: Content of: <book><chapter><title>
4720 #: ../en/ch03-tour-merge.xml:5
4721 msgid "A tour of Mercurial: merging work"
4722 msgstr "Mercurial 教程: 合并工作"
4724 #. type: Content of: <book><chapter><para>
4725 #: ../en/ch03-tour-merge.xml:7
4726 msgid ""
4727 "We've now covered cloning a repository, making changes in a repository, and "
4728 "pulling or pushing changes from one repository into another. Our next step "
4729 "is <emphasis>merging</emphasis> changes from separate repositories."
4730 msgstr ""
4732 #. type: Content of: <book><chapter><sect1><title>
4733 #: ../en/ch03-tour-merge.xml:13
4734 msgid "Merging streams of work"
4735 msgstr "合并的流程"
4737 #. type: Content of: <book><chapter><sect1><para>
4738 #: ../en/ch03-tour-merge.xml:15
4739 msgid ""
4740 "Merging is a fundamental part of working with a distributed revision control "
4741 "tool. Here are a few cases in which the need to merge work arises."
4742 msgstr ""
4744 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
4745 #: ../en/ch03-tour-merge.xml:20
4746 msgid ""
4747 "Alice and Bob each have a personal copy of a repository for a project they're "
4748 "collaborating on. Alice fixes a bug in her repository; Bob adds a new "
4749 "feature in his. They want the shared repository to contain both the bug fix "
4750 "and the new feature."
4751 msgstr ""
4753 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
4754 #: ../en/ch03-tour-merge.xml:27
4755 msgid ""
4756 "Cynthia frequently works on several different tasks for a single project at "
4757 "once, each safely isolated in its own repository. Working this way means that "
4758 "she often needs to merge one piece of her own work with another."
4759 msgstr ""
4761 #. type: Content of: <book><chapter><sect1><para>
4762 #: ../en/ch03-tour-merge.xml:35
4763 msgid ""
4764 "Because we need to merge often, Mercurial makes the process easy. Let's walk "
4765 "through a merge. We'll begin by cloning yet another repository (see how "
4766 "often they spring up?) and making a change in it."
4767 msgstr ""
4769 #. type: Content of: <book><chapter><sect1><para>
4770 #: ../en/ch03-tour-merge.xml:42
4771 msgid ""
4772 "We should now have two copies of <filename>hello.c</filename> with different "
4773 "contents. The histories of the two repositories have also diverged, as "
4774 "illustrated in <xref linkend=\"fig:tour-merge:sep-repos\"/>. Here is a copy "
4775 "of our file from one repository."
4776 msgstr ""
4778 #. type: Content of: <book><chapter><sect1><para>
4779 #: ../en/ch03-tour-merge.xml:51
4780 msgid "And here is our slightly different version from the other repository."
4781 msgstr ""
4783 #. type: Content of: <book><chapter><sect1><figure><title>
4784 #: ../en/ch03-tour-merge.xml:57
4785 msgid ""
4786 "Divergent recent histories of the <filename class=\"directory\">my-hello</"
4787 "filename> and <filename class=\"directory\">my-new-hello</filename> "
4788 "repositories"
4789 msgstr ""
4790 "<filename class=\"directory\">my-hello</filename> 与 <filename class="
4791 "\"directory\">my-new-hello</filename> 最新的历史分叉"
4793 #. type: Content of: <book><chapter><sect1><figure><mediaobject>
4794 #: ../en/ch03-tour-merge.xml:62
4795 msgid ""
4796 "<imageobject><imagedata fileref=\"figs/tour-merge-sep-repos.png\"/></"
4797 "imageobject>"
4798 msgstr ""
4800 #. type: Content of: <book><chapter><sect1><para>
4801 #: ../en/ch03-tour-merge.xml:67
4802 msgid ""
4803 "We already know that pulling changes from our <filename class=\"directory"
4804 "\">my-hello</filename> repository will have no effect on the working "
4805 "directory."
4806 msgstr ""
4808 #. type: Content of: <book><chapter><sect1><para>
4809 #: ../en/ch03-tour-merge.xml:73
4810 msgid ""
4811 "However, the <command role=\"hg-cmd\">hg pull</command> command says "
4812 "something about <quote>heads</quote>."
4813 msgstr ""
4815 #. type: Content of: <book><chapter><sect1><sect2><title>
4816 #: ../en/ch03-tour-merge.xml:77
4817 msgid "Head changesets"
4818 msgstr "顶点修改集"
4820 #. type: Content of: <book><chapter><sect1><sect2><para>
4821 #: ../en/ch03-tour-merge.xml:79
4822 msgid ""
4823 "Remember that Mercurial records what the parent of each change is. If a "
4824 "change has a parent, we call it a child or descendant of the parent. A head "
4825 "is a change that has no children. The tip revision is thus a head, because "
4826 "the newest revision in a repository doesn't have any children. There are "
4827 "times when a repository can contain more than one head."
4828 msgstr ""
4830 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
4831 #: ../en/ch03-tour-merge.xml:88
4832 msgid ""
4833 "Repository contents after pulling from <filename class=\"directory\">my-"
4834 "hello</filename> into <filename class=\"directory\">my-new-hello</filename>"
4835 msgstr ""
4836 "从 <filename class=\"directory\">my-hello</filename> 拉到 <filename class="
4837 "\"directory\">my-new-hello</filename> 之后版本库的内容"
4839 #. type: Content of: <book><chapter><sect1><sect2><figure>
4840 #: ../en/ch03-tour-merge.xml:91 ../en/ch03-tour-merge.xml:178
4841 #: ../en/ch03-tour-merge.xml:275 ../en/ch04-concepts.xml:57
4842 #: ../en/ch04-concepts.xml:106 ../en/ch04-concepts.xml:196
4843 #: ../en/ch04-concepts.xml:345 ../en/ch04-concepts.xml:360
4844 #: ../en/ch04-concepts.xml:401 ../en/ch04-concepts.xml:421
4845 #: ../en/ch04-concepts.xml:465 ../en/ch06-collab.xml:314
4846 #: ../en/ch09-undo.xml:342 ../en/ch09-undo.xml:389 ../en/ch09-undo.xml:462
4847 #: ../en/ch09-undo.xml:500 ../en/ch09-undo.xml:656 ../en/ch09-undo.xml:680
4848 #: ../en/ch09-undo.xml:698 ../en/ch09-undo.xml:712 ../en/ch09-undo.xml:725
4849 #: ../en/ch12-mq.xml:411
4850 msgid " <placeholder type=\"mediaobject\" id=\"0\"/>"
4851 msgstr ""
4853 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
4854 #: ../en/ch03-tour-merge.xml:92
4855 msgid ""
4856 "<imageobject> <imagedata fileref=\"figs/tour-merge-pull.png\"/> </imageobject>"
4857 msgstr ""
4859 #. type: Content of: <book><chapter><sect1><sect2><para>
4860 #: ../en/ch03-tour-merge.xml:99
4861 msgid ""
4862 "In <xref linkend=\"fig:tour-merge:pull\"/>, you can see the effect of the "
4863 "pull from <filename class=\"directory\">my-hello</filename> into <filename "
4864 "class=\"directory\">my-new-hello</filename>. The history that was already "
4865 "present in <filename class=\"directory\">my-new-hello</filename> is "
4866 "untouched, but a new revision has been added. By referring to <xref linkend="
4867 "\"fig:tour-merge:sep-repos\"/>, we can see that the <emphasis>changeset ID</"
4868 "emphasis> remains the same in the new repository, but the <emphasis>revision "
4869 "number</emphasis> has changed. (This, incidentally, is a fine example of why "
4870 "it's not safe to use revision numbers when discussing changesets.) We can "
4871 "view the heads in a repository using the <command role=\"hg-cmd\">hg heads</"
4872 "command> command."
4873 msgstr ""
4875 #. type: Content of: <book><chapter><sect1><sect2><title>
4876 #: ../en/ch03-tour-merge.xml:118
4877 msgid "Performing the merge"
4878 msgstr "执行合并"
4880 #. type: Content of: <book><chapter><sect1><sect2><para>
4881 #: ../en/ch03-tour-merge.xml:120
4882 msgid ""
4883 "What happens if we try to use the normal <command role=\"hg-cmd\">hg update</"
4884 "command> command to update to the new tip?"
4885 msgstr ""
4887 #. type: Content of: <book><chapter><sect1><sect2><para>
4888 #: ../en/ch03-tour-merge.xml:126
4889 msgid ""
4890 "Mercurial is telling us that the <command role=\"hg-cmd\">hg update</command> "
4891 "command won't do a merge; it won't update the working directory when it "
4892 "thinks we might want to do a merge, unless we force it to do so. "
4893 "(Incidentally, forcing the update with <command>hg update -C</command> would "
4894 "revert any uncommitted changes in the working directory.)"
4895 msgstr ""
4897 #. type: Content of: <book><chapter><sect1><sect2><para>
4898 #: ../en/ch03-tour-merge.xml:134
4899 msgid ""
4900 "To start a merge between the two heads, we use the <command role=\"hg-cmd"
4901 "\">hg merge</command> command."
4902 msgstr ""
4903 "我们使用 <command role=\"hg-cmd\">hg merge</command> 命令来合并两个顶点。"
4905 #. type: Content of: <book><chapter><sect1><sect2><para>
4906 #: ../en/ch03-tour-merge.xml:139
4907 msgid ""
4908 "We resolve the contents of <filename>hello.c</filename> This updates the "
4909 "working directory so that it contains changes from <emphasis>both</emphasis> "
4910 "heads, which is reflected in both the output of <command role=\"hg-cmd\">hg "
4911 "parents</command> and the contents of <filename>hello.c</filename>."
4912 msgstr ""
4914 #. type: Content of: <book><chapter><sect1><sect2><title>
4915 #: ../en/ch03-tour-merge.xml:151
4916 msgid "Committing the results of the merge"
4917 msgstr "提交合并结果"
4919 #. type: Content of: <book><chapter><sect1><sect2><para>
4920 #: ../en/ch03-tour-merge.xml:153
4921 msgid ""
4922 "Whenever we've done a merge, <command role=\"hg-cmd\">hg parents</command> "
4923 "will display two parents until we <command role=\"hg-cmd\">hg commit</"
4924 "command> the results of the merge."
4925 msgstr ""
4927 #. type: Content of: <book><chapter><sect1><sect2><para>
4928 #: ../en/ch03-tour-merge.xml:160
4929 msgid ""
4930 "We now have a new tip revision; notice that it has <emphasis>both</emphasis> "
4931 "of our former heads as its parents. These are the same revisions that were "
4932 "previously displayed by <command role=\"hg-cmd\">hg parents</command>."
4933 msgstr ""
4935 #. type: Content of: <book><chapter><sect1><sect2><para>
4936 #: ../en/ch03-tour-merge.xml:167
4937 msgid ""
4938 "In <xref linkend=\"fig:tour-merge:merge\"/>, you can see a representation of "
4939 "what happens to the working directory during the merge, and how this affects "
4940 "the repository when the commit happens. During the merge, the working "
4941 "directory has two parent changesets, and these become the parents of the new "
4942 "changeset."
4943 msgstr ""
4945 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
4946 #: ../en/ch03-tour-merge.xml:176
4947 msgid "Working directory and repository during merge, and following commit"
4948 msgstr "在合并期间,以及提交之后的工作目录与版本库"
4950 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
4951 #: ../en/ch03-tour-merge.xml:179
4952 msgid ""
4953 "<imageobject> <imagedata fileref=\"figs/tour-merge-merge.png\"/> </"
4954 "imageobject>"
4955 msgstr ""
4957 #. type: Content of: <book><chapter><sect1><sect2><para>
4958 #: ../en/ch03-tour-merge.xml:186
4959 msgid ""
4960 "We sometimes talk about a merge having <emphasis>sides</emphasis>: the left "
4961 "side is the first parent in the output of <command role=\"hg-cmd\">hg "
4962 "parents</command>, and the right side is the second. If the working "
4963 "directory was at e.g. revision 5 before we began a merge, that revision will "
4964 "become the left side of the merge."
4965 msgstr ""
4967 #. type: Content of: <book><chapter><sect1><title>
4968 #: ../en/ch03-tour-merge.xml:196
4969 msgid "Merging conflicting changes"
4970 msgstr "合并有冲突的改变"
4972 #. type: Content of: <book><chapter><sect1><para>
4973 #: ../en/ch03-tour-merge.xml:198
4974 msgid ""
4975 "Most merges are simple affairs, but sometimes you'll find yourself merging "
4976 "changes where each side modifies the same portions of the same files. Unless "
4977 "both modifications are identical, this results in a <emphasis>conflict</"
4978 "emphasis>, where you have to decide how to reconcile the different changes "
4979 "into something coherent."
4980 msgstr ""
4982 #. type: Content of: <book><chapter><sect1><figure><title>
4983 #: ../en/ch03-tour-merge.xml:206
4984 msgid "Conflicting changes to a document"
4985 msgstr "冲突的修改"
4987 #. type: Content of: <book><chapter><sect1><figure><mediaobject>
4988 #: ../en/ch03-tour-merge.xml:208
4989 msgid ""
4990 "<imageobject><imagedata fileref=\"figs/tour-merge-conflict.png\"/></"
4991 "imageobject>"
4992 msgstr ""
4994 #. type: Content of: <book><chapter><sect1><para>
4995 #: ../en/ch03-tour-merge.xml:213
4996 msgid ""
4997 "<xref linkend=\"fig:tour-merge:conflict\"/> illustrates an instance of two "
4998 "conflicting changes to a document. We started with a single version of the "
4999 "file; then we made some changes; while someone else made different changes to "
5000 "the same text. Our task in resolving the conflicting changes is to decide "
5001 "what the file should look like."
5002 msgstr ""
5004 #. type: Content of: <book><chapter><sect1><para>
5005 #: ../en/ch03-tour-merge.xml:220
5006 msgid ""
5007 "Mercurial doesn't have a built-in facility for handling conflicts. Instead, "
5008 "it runs an external program, usually one that displays some kind of graphical "
5009 "conflict resolution interface. By default, Mercurial tries to find one of "
5010 "several different merging tools that are likely to be installed on your "
5011 "system. It first tries a few fully automatic merging tools; if these don't "
5012 "succeed (because the resolution process requires human guidance) or aren't "
5013 "present, it tries a few different graphical merging tools."
5014 msgstr ""
5016 #. type: Content of: <book><chapter><sect1><para>
5017 #: ../en/ch03-tour-merge.xml:230
5018 msgid ""
5019 "It's also possible to get Mercurial to run a specific program or script, by "
5020 "setting the <envar>HGMERGE</envar> environment variable to the name of your "
5021 "preferred program."
5022 msgstr ""
5024 #. type: Content of: <book><chapter><sect1><sect2><title>
5025 #: ../en/ch03-tour-merge.xml:236
5026 msgid "Using a graphical merge tool"
5027 msgstr "使用图形合并工具"
5029 #. type: Content of: <book><chapter><sect1><sect2><para>
5030 #: ../en/ch03-tour-merge.xml:238
5031 msgid ""
5032 "My preferred graphical merge tool is <command>kdiff3</command>, which I'll "
5033 "use to describe the features that are common to graphical file merging "
5034 "tools. You can see a screenshot of <command>kdiff3</command> in action in "
5035 "<xref linkend=\"fig:tour-merge:kdiff3\"/>. The kind of merge it is "
5036 "performing is called a <emphasis>three-way merge</emphasis>, because there "
5037 "are three different versions of the file of interest to us. The tool thus "
5038 "splits the upper portion of the window into three panes:"
5039 msgstr ""
5041 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
5042 #: ../en/ch03-tour-merge.xml:248
5043 msgid ""
5044 "At the left is the <emphasis>base</emphasis> version of the file, i.e. the "
5045 "most recent version from which the two versions we're trying to merge are "
5046 "descended."
5047 msgstr ""
5049 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
5050 #: ../en/ch03-tour-merge.xml:253
5051 msgid ""
5052 "In the middle is <quote>our</quote> version of the file, with the contents "
5053 "that we modified."
5054 msgstr ""
5056 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
5057 #: ../en/ch03-tour-merge.xml:256
5058 msgid ""
5059 "On the right is <quote>their</quote> version of the file, the one that from "
5060 "the changeset that we're trying to merge with."
5061 msgstr ""
5063 #. type: Content of: <book><chapter><sect1><sect2><para>
5064 #: ../en/ch03-tour-merge.xml:260
5065 msgid ""
5066 "In the pane below these is the current <emphasis>result</emphasis> of the "
5067 "merge. Our task is to replace all of the red text, which indicates unresolved "
5068 "conflicts, with some sensible merger of the <quote>ours</quote> and "
5069 "<quote>theirs</quote> versions of the file."
5070 msgstr ""
5072 #. type: Content of: <book><chapter><sect1><sect2><para>
5073 #: ../en/ch03-tour-merge.xml:267
5074 msgid ""
5075 "All four of these panes are <emphasis>locked together</emphasis>; if we "
5076 "scroll vertically or horizontally in any of them, the others are updated to "
5077 "display the corresponding sections of their respective files."
5078 msgstr ""
5080 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
5081 #: ../en/ch03-tour-merge.xml:273
5082 msgid "Using <command>kdiff3</command> to merge versions of a file"
5083 msgstr "使用 <command>kdiff3</command> 合并文件的不同版本"
5085 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
5086 #: ../en/ch03-tour-merge.xml:276
5087 msgid ""
5088 "<imageobject> <imagedata width=\"100%\" fileref=\"figs/kdiff3.png\"/></"
5089 "imageobject>"
5090 msgstr ""
5092 #. type: Content of: <book><chapter><sect1><sect2><para>
5093 #: ../en/ch03-tour-merge.xml:284
5094 msgid ""
5095 "For each conflicting portion of the file, we can choose to resolve the "
5096 "conflict using some combination of text from the base version, ours, or "
5097 "theirs. We can also manually edit the merged file at any time, in case we "
5098 "need to make further modifications."
5099 msgstr ""
5101 #. type: Content of: <book><chapter><sect1><sect2><para>
5102 #: ../en/ch03-tour-merge.xml:290
5103 msgid ""
5104 "There are <emphasis>many</emphasis> file merging tools available, too many to "
5105 "cover here. They vary in which platforms they are available for, and in "
5106 "their particular strengths and weaknesses. Most are tuned for merging files "
5107 "containing plain text, while a few are aimed at specialised file formats "
5108 "(generally XML)."
5109 msgstr ""
5111 #. type: Content of: <book><chapter><sect1><sect2><title>
5112 #: ../en/ch03-tour-merge.xml:299
5113 msgid "A worked example"
5114 msgstr "合并实例"
5116 #. type: Content of: <book><chapter><sect1><sect2><para>
5117 #: ../en/ch03-tour-merge.xml:301
5118 msgid ""
5119 "In this example, we will reproduce the file modification history of <xref "
5120 "linkend=\"fig:tour-merge:conflict\"/> above. Let's begin by creating a "
5121 "repository with a base version of our document."
5122 msgstr ""
5124 #. type: Content of: <book><chapter><sect1><sect2><para>
5125 #: ../en/ch03-tour-merge.xml:308
5126 msgid "We'll clone the repository and make a change to the file."
5127 msgstr ""
5129 #. type: Content of: <book><chapter><sect1><sect2><para>
5130 #: ../en/ch03-tour-merge.xml:313
5131 msgid ""
5132 "And another clone, to simulate someone else making a change to the file. "
5133 "(This hints at the idea that it's not all that unusual to merge with yourself "
5134 "when you isolate tasks in separate repositories, and indeed to find and "
5135 "resolve conflicts while doing so.)"
5136 msgstr ""
5138 #. type: Content of: <book><chapter><sect1><sect2><para>
5139 #: ../en/ch03-tour-merge.xml:321
5140 msgid ""
5141 "Having created two different versions of the file, we'll set up an "
5142 "environment suitable for running our merge."
5143 msgstr ""
5145 #. type: Content of: <book><chapter><sect1><sect2><para>
5146 #: ../en/ch03-tour-merge.xml:327
5147 msgid ""
5148 "In this example, I'll set <envar>HGMERGE</envar> to tell Mercurial to use the "
5149 "non-interactive <command>merge</command> command. This is bundled with many "
5150 "Unix-like systems. (If you're following this example on your computer, don't "
5151 "bother setting <envar>HGMERGE</envar>. You'll get dropped into a GUI file "
5152 "merge tool instead, which is much preferable.)"
5153 msgstr ""
5155 #. type: Content of: <book><chapter><sect1><sect2><para>
5156 #: ../en/ch03-tour-merge.xml:337
5157 msgid ""
5158 "Because <command>merge</command> can't resolve the conflicting changes, it "
5159 "leaves <emphasis>merge markers</emphasis> inside the file that has conflicts, "
5160 "indicating which lines have conflicts, and whether they came from our version "
5161 "of the file or theirs."
5162 msgstr ""
5164 #. type: Content of: <book><chapter><sect1><sect2><para>
5165 #: ../en/ch03-tour-merge.xml:343
5166 msgid ""
5167 "Mercurial can tell from the way <command>merge</command> exits that it wasn't "
5168 "able to merge successfully, so it tells us what commands we'll need to run if "
5169 "we want to redo the merging operation. This could be useful if, for example, "
5170 "we were running a graphical merge tool and quit because we were confused or "
5171 "realised we had made a mistake."
5172 msgstr ""
5174 #. type: Content of: <book><chapter><sect1><sect2><para>
5175 #: ../en/ch03-tour-merge.xml:350
5176 msgid ""
5177 "If automatic or manual merges fail, there's nothing to prevent us from "
5178 "<quote>fixing up</quote> the affected files ourselves, and committing the "
5179 "results of our merge:"
5180 msgstr ""
5182 #. type: Content of: <book><chapter><sect1><sect2><note><title>
5183 #: ../en/ch03-tour-merge.xml:357
5184 msgid "Where is the <command>hg resolve</command> command?"
5185 msgstr "在哪里能找到 <command role=\"hg-cmd\">hg resolve</command> 命令?"
5187 #. type: Content of: <book><chapter><sect1><sect2><note><para>
5188 #: ../en/ch03-tour-merge.xml:359
5189 msgid ""
5190 "The <command>hg resolve</command> command was introduced in Mercurial 1.1, "
5191 "which was released in December 2008. If you are using an older version of "
5192 "Mercurial (run <command>hg version</command> to see), this command will not "
5193 "be present. If your version of Mercurial is older than 1.1, you should "
5194 "strongly consider upgrading to a newer version before trying to tackle "
5195 "complicated merges."
5196 msgstr ""
5198 #. type: Content of: <book><chapter><sect1><title>
5199 #: ../en/ch03-tour-merge.xml:371
5200 msgid "Simplifying the pull-merge-commit sequence"
5201 msgstr "简化拉-合并-提交程序"
5203 #. type: Content of: <book><chapter><sect1><para>
5204 #: ../en/ch03-tour-merge.xml:373
5205 msgid ""
5206 "The process of merging changes as outlined above is straightforward, but "
5207 "requires running three commands in sequence."
5208 msgstr ""
5210 #. type: Content of: <book><chapter><sect1><para>
5211 #: ../en/ch03-tour-merge.xml:379
5212 msgid ""
5213 "In the case of the final commit, you also need to enter a commit message, "
5214 "which is almost always going to be a piece of uninteresting "
5215 "<quote>boilerplate</quote> text."
5216 msgstr ""
5218 #. type: Content of: <book><chapter><sect1><para>
5219 #: ../en/ch03-tour-merge.xml:383
5220 msgid ""
5221 "It would be nice to reduce the number of steps needed, if this were "
5222 "possible. Indeed, Mercurial is distributed with an extension called <literal "
5223 "role=\"hg-ext\">fetch</literal> that does just this."
5224 msgstr ""
5226 #. type: Content of: <book><chapter><sect1><para>
5227 #: ../en/ch03-tour-merge.xml:388
5228 msgid ""
5229 "Mercurial provides a flexible extension mechanism that lets people extend its "
5230 "functionality, while keeping the core of Mercurial small and easy to deal "
5231 "with. Some extensions add new commands that you can use from the command "
5232 "line, while others work <quote>behind the scenes,</quote> for example adding "
5233 "capabilities to Mercurial's built-in server mode."
5234 msgstr ""
5236 #. type: Content of: <book><chapter><sect1><para>
5237 #: ../en/ch03-tour-merge.xml:395
5238 msgid ""
5239 "The <literal role=\"hg-ext\">fetch</literal> extension adds a new command "
5240 "called, not surprisingly, <command role=\"hg-cmd\">hg fetch</command>. This "
5241 "extension acts as a combination of <command role=\"hg-cmd\">hg pull -u</"
5242 "command>, <command role=\"hg-cmd\">hg merge</command> and <command role=\"hg-"
5243 "cmd\">hg commit</command>. It begins by pulling changes from another "
5244 "repository into the current repository. If it finds that the changes added a "
5245 "new head to the repository, it updates to the new head, begins a merge, then "
5246 "(if the merge succeeded) commits the result of the merge with an "
5247 "automatically-generated commit message. If no new heads were added, it "
5248 "updates the working directory to the new tip changeset."
5249 msgstr ""
5251 #. type: Content of: <book><chapter><sect1><para>
5252 #: ../en/ch03-tour-merge.xml:409
5253 msgid ""
5254 "Enabling the <literal role=\"hg-ext\">fetch</literal> extension is easy. "
5255 "Edit the <filename role=\"special\">.hgrc</filename> file in your home "
5256 "directory, and either go to the <literal role=\"rc-extensions\">extensions</"
5257 "literal> section or create an <literal role=\"rc-extensions\">extensions</"
5258 "literal> section. Then add a line that simply reads <quote><literal>fetch=</"
5259 "literal></quote>."
5260 msgstr ""
5262 #. type: Content of: <book><chapter><sect1><para>
5263 #: ../en/ch03-tour-merge.xml:421
5264 msgid ""
5265 "(Normally, the right-hand side of the <quote><literal>=</literal></quote> "
5266 "would indicate where to find the extension, but since the <literal role=\"hg-"
5267 "ext\">fetch</literal> extension is in the standard distribution, Mercurial "
5268 "knows where to search for it.)"
5269 msgstr ""
5271 #. type: Content of: <book><chapter><sect1><title>
5272 #: ../en/ch03-tour-merge.xml:429
5273 msgid "Renaming, copying, and merging"
5274 msgstr "改名,复制与合并"
5276 #. type: Content of: <book><chapter><sect1><para>
5277 #: ../en/ch03-tour-merge.xml:431
5278 msgid ""
5279 "During the life of a project, we will often want to change the layout of its "
5280 "files and directories. This can be as simple as renaming a single file, or as "
5281 "complex as restructuring the entire hierarchy of files within the project."
5282 msgstr ""
5284 #. type: Content of: <book><chapter><sect1><para>
5285 #: ../en/ch03-tour-merge.xml:436
5286 msgid ""
5287 "Mercurial supports these kinds of complex changes fluently, provided we tell "
5288 "it what we're doing. If we want to rename a file, we should use the "
5289 "<command>hg rename</command><placeholder type=\"footnote\" id=\"0\"/> command "
5290 "to rename it, so that Mercurial can do the right thing later when we merge."
5291 msgstr ""
5293 #. type: Content of: <book><chapter><sect1><para><footnote><para>
5294 #: ../en/ch03-tour-merge.xml:439
5295 msgid ""
5296 "If you're a Unix user, you'll be glad to know that the <command>hg rename</"
5297 "command> command can be abbreviated as <command>hg mv</command>."
5298 msgstr ""
5300 #. type: Content of: <book><chapter><sect1><para>
5301 #: ../en/ch03-tour-merge.xml:445
5302 msgid ""
5303 "We will cover the use of these commands in more detail in <xref linkend="
5304 "\"chap:daily.copy\"/>."
5305 msgstr ""
5307 #. type: Content of: <book><chapter><title>
5308 #: ../en/ch04-concepts.xml:5
5309 msgid "Behind the scenes"
5310 msgstr "Mercurial 内幕"
5312 #. type: Content of: <book><chapter><para>
5313 #: ../en/ch04-concepts.xml:7
5314 msgid ""
5315 "Unlike many revision control systems, the concepts upon which Mercurial is "
5316 "built are simple enough that it's easy to understand how the software really "
5317 "works. Knowing these details certainly isn't necessary, so it is certainly "
5318 "safe to skip this chapter. However, I think you will get more out of the "
5319 "software with a <quote>mental model</quote> of what's going on."
5320 msgstr ""
5322 #. type: Content of: <book><chapter><para>
5323 #: ../en/ch04-concepts.xml:14
5324 msgid ""
5325 "Being able to understand what's going on behind the scenes gives me "
5326 "confidence that Mercurial has been carefully designed to be both "
5327 "<emphasis>safe</emphasis> and <emphasis>efficient</emphasis>. And just as "
5328 "importantly, if it's easy for me to retain a good idea of what the software "
5329 "is doing when I perform a revision control task, I'm less likely to be "
5330 "surprised by its behavior."
5331 msgstr ""
5333 #. type: Content of: <book><chapter><para>
5334 #: ../en/ch04-concepts.xml:22
5335 msgid ""
5336 "In this chapter, we'll initially cover the core concepts behind Mercurial's "
5337 "design, then continue to discuss some of the interesting details of its "
5338 "implementation."
5339 msgstr ""
5341 #. type: Content of: <book><chapter><sect1><title>
5342 #: ../en/ch04-concepts.xml:27
5343 msgid "Mercurial's historical record"
5344 msgstr "Mercurial 的历史记录"
5346 #. type: Content of: <book><chapter><sect1><sect2><title>
5347 #: ../en/ch04-concepts.xml:30
5348 msgid "Tracking the history of a single file"
5349 msgstr "跟踪单一文件的历史"
5351 #. type: Content of: <book><chapter><sect1><sect2><para>
5352 #: ../en/ch04-concepts.xml:32
5353 msgid ""
5354 "When Mercurial tracks modifications to a file, it stores the history of that "
5355 "file in a metadata object called a <emphasis>filelog</emphasis>. Each entry "
5356 "in the filelog contains enough information to reconstruct one revision of the "
5357 "file that is being tracked. Filelogs are stored as files in the <filename "
5358 "role=\"special\" class=\"directory\">.hg/store/data</filename> directory. A "
5359 "filelog contains two kinds of information: revision data, and an index to "
5360 "help Mercurial to find a revision efficiently."
5361 msgstr ""
5363 #. type: Content of: <book><chapter><sect1><sect2><para>
5364 #: ../en/ch04-concepts.xml:43
5365 msgid ""
5366 "A file that is large, or has a lot of history, has its filelog stored in "
5367 "separate data (<quote><literal>.d</literal></quote> suffix) and index "
5368 "(<quote><literal>.i</literal></quote> suffix) files. For small files without "
5369 "much history, the revision data and index are combined in a single "
5370 "<quote><literal>.i</literal></quote> file. The correspondence between a file "
5371 "in the working directory and the filelog that tracks its history in the "
5372 "repository is illustrated in <xref linkend=\"fig:concepts:filelog\"/>."
5373 msgstr ""
5375 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
5376 #: ../en/ch04-concepts.xml:55
5377 msgid ""
5378 "Relationships between files in working directory and filelogs in repository"
5379 msgstr "工作目录中的文件与版本库中的文件日志之间的关系"
5381 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
5382 #: ../en/ch04-concepts.xml:58
5383 msgid "<imageobject><imagedata fileref=\"figs/filelog.png\"/></imageobject>"
5384 msgstr ""
5386 #. type: Content of: <book><chapter><sect1><sect2><title>
5387 #: ../en/ch04-concepts.xml:65
5388 msgid "Managing tracked files"
5389 msgstr "管理跟踪的文件"
5391 #. type: Content of: <book><chapter><sect1><sect2><para>
5392 #: ../en/ch04-concepts.xml:67
5393 msgid ""
5394 "Mercurial uses a structure called a <emphasis>manifest</emphasis> to collect "
5395 "together information about the files that it tracks. Each entry in the "
5396 "manifest contains information about the files present in a single changeset. "
5397 "An entry records which files are present in the changeset, the revision of "
5398 "each file, and a few other pieces of file metadata."
5399 msgstr ""
5401 #. type: Content of: <book><chapter><sect1><sect2><title>
5402 #: ../en/ch04-concepts.xml:77
5403 msgid "Recording changeset information"
5404 msgstr "记录修改集信息"
5406 #. type: Content of: <book><chapter><sect1><sect2><para>
5407 #: ../en/ch04-concepts.xml:79
5408 msgid ""
5409 "The <emphasis>changelog</emphasis> contains information about each "
5410 "changeset. Each revision records who committed a change, the changeset "
5411 "comment, other pieces of changeset-related information, and the revision of "
5412 "the manifest to use."
5413 msgstr ""
5415 #. type: Content of: <book><chapter><sect1><sect2><title>
5416 #: ../en/ch04-concepts.xml:87
5417 msgid "Relationships between revisions"
5418 msgstr "版本之间的关系"
5420 #. type: Content of: <book><chapter><sect1><sect2><para>
5421 #: ../en/ch04-concepts.xml:89
5422 msgid ""
5423 "Within a changelog, a manifest, or a filelog, each revision stores a pointer "
5424 "to its immediate parent (or to its two parents, if it's a merge revision). "
5425 "As I mentioned above, there are also relationships between revisions "
5426 "<emphasis>across</emphasis> these structures, and they are hierarchical in "
5427 "nature."
5428 msgstr ""
5430 #. type: Content of: <book><chapter><sect1><sect2><para>
5431 #: ../en/ch04-concepts.xml:96
5432 msgid ""
5433 "For every changeset in a repository, there is exactly one revision stored in "
5434 "the changelog. Each revision of the changelog contains a pointer to a single "
5435 "revision of the manifest. A revision of the manifest stores a pointer to a "
5436 "single revision of each filelog tracked when that changeset was created. "
5437 "These relationships are illustrated in <xref linkend=\"fig:concepts:metadata"
5438 "\"/>."
5439 msgstr ""
5441 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
5442 #: ../en/ch04-concepts.xml:105
5443 msgid "Metadata relationships"
5444 msgstr "元数据之间的关系"
5446 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
5447 #: ../en/ch04-concepts.xml:107
5448 msgid "<imageobject><imagedata fileref=\"figs/metadata.png\"/></imageobject>"
5449 msgstr ""
5451 #. type: Content of: <book><chapter><sect1><sect2><para>
5452 #: ../en/ch04-concepts.xml:112
5453 msgid ""
5454 "As the illustration shows, there is <emphasis>not</emphasis> a <quote>one to "
5455 "one</quote> relationship between revisions in the changelog, manifest, or "
5456 "filelog. If a file that Mercurial tracks hasn't changed between two "
5457 "changesets, the entry for that file in the two revisions of the manifest will "
5458 "point to the same revision of its filelog<placeholder type=\"footnote\" id=\"0"
5459 "\"/>."
5460 msgstr ""
5462 #. type: Content of: <book><chapter><sect1><sect2><para><footnote><para>
5463 #: ../en/ch04-concepts.xml:119
5464 msgid ""
5465 "It is possible (though unusual) for the manifest to remain the same between "
5466 "two changesets, in which case the changelog entries for those changesets will "
5467 "point to the same revision of the manifest."
5468 msgstr ""
5470 #. type: Content of: <book><chapter><sect1><title>
5471 #: ../en/ch04-concepts.xml:128
5472 msgid "Safe, efficient storage"
5473 msgstr "安全,高效的存储"
5475 #. type: Content of: <book><chapter><sect1><para>
5476 #: ../en/ch04-concepts.xml:130
5477 msgid ""
5478 "The underpinnings of changelogs, manifests, and filelogs are provided by a "
5479 "single structure called the <emphasis>revlog</emphasis>."
5480 msgstr ""
5482 #. type: Content of: <book><chapter><sect1><sect2><title>
5483 #: ../en/ch04-concepts.xml:135
5484 msgid "Efficient storage"
5485 msgstr "高效存储"
5487 #. type: Content of: <book><chapter><sect1><sect2><para>
5488 #: ../en/ch04-concepts.xml:137
5489 msgid ""
5490 "The revlog provides efficient storage of revisions using a <emphasis>delta</"
5491 "emphasis> mechanism. Instead of storing a complete copy of a file for each "
5492 "revision, it stores the changes needed to transform an older revision into "
5493 "the new revision. For many kinds of file data, these deltas are typically a "
5494 "fraction of a percent of the size of a full copy of a file."
5495 msgstr ""
5497 #. type: Content of: <book><chapter><sect1><sect2><para>
5498 #: ../en/ch04-concepts.xml:145
5499 msgid ""
5500 "Some obsolete revision control systems can only work with deltas of text "
5501 "files. They must either store binary files as complete snapshots or encoded "
5502 "into a text representation, both of which are wasteful approaches. Mercurial "
5503 "can efficiently handle deltas of files with arbitrary binary contents; it "
5504 "doesn't need to treat text as special."
5505 msgstr ""
5507 #. type: Content of: <book><chapter><sect1><sect2><title>
5508 #: ../en/ch04-concepts.xml:154
5509 msgid "Safe operation"
5510 msgstr "安全操作"
5512 #. type: Content of: <book><chapter><sect1><sect2><para>
5513 #: ../en/ch04-concepts.xml:156
5514 msgid ""
5515 "Mercurial only ever <emphasis>appends</emphasis> data to the end of a revlog "
5516 "file. It never modifies a section of a file after it has written it. This is "
5517 "both more robust and efficient than schemes that need to modify or rewrite "
5518 "data."
5519 msgstr ""
5521 #. type: Content of: <book><chapter><sect1><sect2><para>
5522 #: ../en/ch04-concepts.xml:162
5523 msgid ""
5524 "In addition, Mercurial treats every write as part of a <emphasis>transaction</"
5525 "emphasis> that can span a number of files. A transaction is "
5526 "<emphasis>atomic</emphasis>: either the entire transaction succeeds and its "
5527 "effects are all visible to readers in one go, or the whole thing is undone. "
5528 "This guarantee of atomicity means that if you're running two copies of "
5529 "Mercurial, where one is reading data and one is writing it, the reader will "
5530 "never see a partially written result that might confuse it."
5531 msgstr ""
5533 #. type: Content of: <book><chapter><sect1><sect2><para>
5534 #: ../en/ch04-concepts.xml:172
5535 msgid ""
5536 "The fact that Mercurial only appends to files makes it easier to provide this "
5537 "transactional guarantee. The easier it is to do stuff like this, the more "
5538 "confident you should be that it's done correctly."
5539 msgstr ""
5541 #. type: Content of: <book><chapter><sect1><sect2><title>
5542 #: ../en/ch04-concepts.xml:179
5543 msgid "Fast retrieval"
5544 msgstr "快速检索"
5546 #. type: Content of: <book><chapter><sect1><sect2><para>
5547 #: ../en/ch04-concepts.xml:181
5548 msgid ""
5549 "Mercurial cleverly avoids a pitfall common to all earlier revision control "
5550 "systems: the problem of <emphasis>inefficient retrieval</emphasis>. Most "
5551 "revision control systems store the contents of a revision as an incremental "
5552 "series of modifications against a <quote>snapshot</quote>. (Some base the "
5553 "snapshot on the oldest revision, others on the newest.) To reconstruct a "
5554 "specific revision, you must first read the snapshot, and then every one of "
5555 "the revisions between the snapshot and your target revision. The more "
5556 "history that a file accumulates, the more revisions you must read, hence the "
5557 "longer it takes to reconstruct a particular revision."
5558 msgstr ""
5560 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
5561 #: ../en/ch04-concepts.xml:195
5562 msgid "Snapshot of a revlog, with incremental deltas"
5563 msgstr "版本日志的快照,以及增量差异"
5565 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
5566 #: ../en/ch04-concepts.xml:197
5567 msgid "<imageobject><imagedata fileref=\"figs/snapshot.png\"/></imageobject>"
5568 msgstr ""
5570 #. type: Content of: <book><chapter><sect1><sect2><para>
5571 #: ../en/ch04-concepts.xml:202
5572 msgid ""
5573 "The innovation that Mercurial applies to this problem is simple but "
5574 "effective. Once the cumulative amount of delta information stored since the "
5575 "last snapshot exceeds a fixed threshold, it stores a new snapshot "
5576 "(compressed, of course), instead of another delta. This makes it possible to "
5577 "reconstruct <emphasis>any</emphasis> revision of a file quickly. This "
5578 "approach works so well that it has since been copied by several other "
5579 "revision control systems."
5580 msgstr ""
5582 #. type: Content of: <book><chapter><sect1><sect2><para>
5583 #: ../en/ch04-concepts.xml:211
5584 msgid ""
5585 "<xref linkend=\"fig:concepts:snapshot\"/> illustrates the idea. In an entry "
5586 "in a revlog's index file, Mercurial stores the range of entries from the data "
5587 "file that it must read to reconstruct a particular revision."
5588 msgstr ""
5590 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
5591 #: ../en/ch04-concepts.xml:217
5592 msgid "Aside: the influence of video compression"
5593 msgstr "旁白: 视频压缩的影响"
5595 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
5596 #: ../en/ch04-concepts.xml:219
5597 msgid ""
5598 "If you're familiar with video compression or have ever watched a TV feed "
5599 "through a digital cable or satellite service, you may know that most video "
5600 "compression schemes store each frame of video as a delta against its "
5601 "predecessor frame."
5602 msgstr ""
5604 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
5605 #: ../en/ch04-concepts.xml:225
5606 msgid ""
5607 "Mercurial borrows this idea to make it possible to reconstruct a revision "
5608 "from a snapshot and a small number of deltas."
5609 msgstr ""
5611 #. type: Content of: <book><chapter><sect1><sect2><title>
5612 #: ../en/ch04-concepts.xml:232
5613 msgid "Identification and strong integrity"
5614 msgstr "鉴别和强完整性"
5616 #. type: Content of: <book><chapter><sect1><sect2><para>
5617 #: ../en/ch04-concepts.xml:234
5618 msgid ""
5619 "Along with delta or snapshot information, a revlog entry contains a "
5620 "cryptographic hash of the data that it represents. This makes it difficult "
5621 "to forge the contents of a revision, and easy to detect accidental corruption."
5622 msgstr ""
5624 #. type: Content of: <book><chapter><sect1><sect2><para>
5625 #: ../en/ch04-concepts.xml:239
5626 msgid ""
5627 "Hashes provide more than a mere check against corruption; they are used as "
5628 "the identifiers for revisions. The changeset identification hashes that you "
5629 "see as an end user are from revisions of the changelog. Although filelogs "
5630 "and the manifest also use hashes, Mercurial only uses these behind the scenes."
5631 msgstr ""
5633 #. type: Content of: <book><chapter><sect1><sect2><para>
5634 #: ../en/ch04-concepts.xml:246
5635 msgid ""
5636 "Mercurial verifies that hashes are correct when it retrieves file revisions "
5637 "and when it pulls changes from another repository. If it encounters an "
5638 "integrity problem, it will complain and stop whatever it's doing."
5639 msgstr ""
5641 #. type: Content of: <book><chapter><sect1><sect2><para>
5642 #: ../en/ch04-concepts.xml:251
5643 msgid ""
5644 "In addition to the effect it has on retrieval efficiency, Mercurial's use of "
5645 "periodic snapshots makes it more robust against partial data corruption. If "
5646 "a revlog becomes partly corrupted due to a hardware error or system bug, it's "
5647 "often possible to reconstruct some or most revisions from the uncorrupted "
5648 "sections of the revlog, both before and after the corrupted section. This "
5649 "would not be possible with a delta-only storage model."
5650 msgstr ""
5652 #. type: Content of: <book><chapter><sect1><title>
5653 #: ../en/ch04-concepts.xml:263
5654 msgid "Revision history, branching, and merging"
5655 msgstr "修订历史,分支与合并"
5657 #. type: Content of: <book><chapter><sect1><para>
5658 #: ../en/ch04-concepts.xml:265
5659 msgid ""
5660 "Every entry in a Mercurial revlog knows the identity of its immediate "
5661 "ancestor revision, usually referred to as its <emphasis>parent</emphasis>. "
5662 "In fact, a revision contains room for not one parent, but two. Mercurial "
5663 "uses a special hash, called the <quote>null ID</quote>, to represent the idea "
5664 "<quote>there is no parent here</quote>. This hash is simply a string of "
5665 "zeroes."
5666 msgstr ""
5668 #. type: Content of: <book><chapter><sect1><para>
5669 #: ../en/ch04-concepts.xml:273
5670 msgid ""
5671 "In <xref linkend=\"fig:concepts:revlog\"/>, you can see an example of the "
5672 "conceptual structure of a revlog. Filelogs, manifests, and changelogs all "
5673 "have this same structure; they differ only in the kind of data stored in each "
5674 "delta or snapshot."
5675 msgstr ""
5677 #. type: Content of: <book><chapter><sect1><para>
5678 #: ../en/ch04-concepts.xml:279
5679 msgid ""
5680 "The first revision in a revlog (at the bottom of the image) has the null ID "
5681 "in both of its parent slots. For a <quote>normal</quote> revision, its first "
5682 "parent slot contains the ID of its parent revision, and its second contains "
5683 "the null ID, indicating that the revision has only one real parent. Any two "
5684 "revisions that have the same parent ID are branches. A revision that "
5685 "represents a merge between branches has two normal revision IDs in its parent "
5686 "slots."
5687 msgstr ""
5689 #. type: Content of: <book><chapter><sect1><figure><title>
5690 #: ../en/ch04-concepts.xml:289
5691 msgid "The conceptual structure of a revlog"
5692 msgstr "版本日志的设计结构"
5694 #. type: Content of: <book><chapter><sect1><figure><mediaobject>
5695 #: ../en/ch04-concepts.xml:291
5696 msgid "<imageobject><imagedata fileref=\"figs/revlog.png\"/></imageobject>"
5697 msgstr ""
5699 #. type: Content of: <book><chapter><sect1><title>
5700 #: ../en/ch04-concepts.xml:298
5701 msgid "The working directory"
5702 msgstr "工作目录"
5704 #. type: Content of: <book><chapter><sect1><para>
5705 #: ../en/ch04-concepts.xml:300
5706 msgid ""
5707 "In the working directory, Mercurial stores a snapshot of the files from the "
5708 "repository as of a particular changeset."
5709 msgstr ""
5711 #. type: Content of: <book><chapter><sect1><para>
5712 #: ../en/ch04-concepts.xml:303
5713 msgid ""
5714 "The working directory <quote>knows</quote> which changeset it contains. When "
5715 "you update the working directory to contain a particular changeset, Mercurial "
5716 "looks up the appropriate revision of the manifest to find out which files it "
5717 "was tracking at the time that changeset was committed, and which revision of "
5718 "each file was then current. It then recreates a copy of each of those files, "
5719 "with the same contents it had when the changeset was committed."
5720 msgstr ""
5722 #. type: Content of: <book><chapter><sect1><para>
5723 #: ../en/ch04-concepts.xml:312
5724 msgid ""
5725 "The <emphasis>dirstate</emphasis> is a special structure that contains "
5726 "Mercurial's knowledge of the working directory. It is maintained as a file "
5727 "named <filename>.hg/dirstate</filename> inside a repository. The dirstate "
5728 "details which changeset the working directory is updated to, and all of the "
5729 "files that Mercurial is tracking in the working directory. It also lets "
5730 "Mercurial quickly notice changed files, by recording their checkout times and "
5731 "sizes."
5732 msgstr ""
5734 #. type: Content of: <book><chapter><sect1><para>
5735 #: ../en/ch04-concepts.xml:322
5736 msgid ""
5737 "Just as a revision of a revlog has room for two parents, so that it can "
5738 "represent either a normal revision (with one parent) or a merge of two "
5739 "earlier revisions, the dirstate has slots for two parents. When you use the "
5740 "<command role=\"hg-cmd\">hg update</command> command, the changeset that you "
5741 "update to is stored in the <quote>first parent</quote> slot, and the null ID "
5742 "in the second. When you <command role=\"hg-cmd\">hg merge</command> with "
5743 "another changeset, the first parent remains unchanged, and the second parent "
5744 "is filled in with the changeset you're merging with. The <command role=\"hg-"
5745 "cmd\">hg parents</command> command tells you what the parents of the dirstate "
5746 "are."
5747 msgstr ""
5749 #. type: Content of: <book><chapter><sect1><sect2><title>
5750 #: ../en/ch04-concepts.xml:336
5751 msgid "What happens when you commit"
5752 msgstr "当你提交时发生的事情"
5754 #. type: Content of: <book><chapter><sect1><sect2><para>
5755 #: ../en/ch04-concepts.xml:338
5756 msgid ""
5757 "The dirstate stores parent information for more than just book-keeping "
5758 "purposes. Mercurial uses the parents of the dirstate as <emphasis>the "
5759 "parents of a new changeset</emphasis> when you perform a commit."
5760 msgstr ""
5762 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
5763 #: ../en/ch04-concepts.xml:344
5764 msgid "The working directory can have two parents"
5765 msgstr "工作目录可以有两个父亲"
5767 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
5768 #: ../en/ch04-concepts.xml:346
5769 msgid "<imageobject><imagedata fileref=\"figs/wdir.png\"/></imageobject>"
5770 msgstr ""
5772 #. type: Content of: <book><chapter><sect1><sect2><para>
5773 #: ../en/ch04-concepts.xml:351
5774 msgid ""
5775 "<xref linkend=\"fig:concepts:wdir\"/> shows the normal state of the working "
5776 "directory, where it has a single changeset as parent. That changeset is the "
5777 "<emphasis>tip</emphasis>, the newest changeset in the repository that has no "
5778 "children."
5779 msgstr ""
5781 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
5782 #: ../en/ch04-concepts.xml:358
5783 msgid "The working directory gains new parents after a commit"
5784 msgstr "提交之后,工作目录的父亲就改变了"
5786 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
5787 #: ../en/ch04-concepts.xml:361
5788 msgid ""
5789 "<imageobject><imagedata fileref=\"figs/wdir-after-commit.png\"/></imageobject>"
5790 msgstr ""
5792 #. type: Content of: <book><chapter><sect1><sect2><para>
5793 #: ../en/ch04-concepts.xml:366
5794 msgid ""
5795 "It's useful to think of the working directory as <quote>the changeset I'm "
5796 "about to commit</quote>. Any files that you tell Mercurial that you've "
5797 "added, removed, renamed, or copied will be reflected in that changeset, as "
5798 "will modifications to any files that Mercurial is already tracking; the new "
5799 "changeset will have the parents of the working directory as its parents."
5800 msgstr ""
5802 #. type: Content of: <book><chapter><sect1><sect2><para>
5803 #: ../en/ch04-concepts.xml:374
5804 msgid ""
5805 "After a commit, Mercurial will update the parents of the working directory, "
5806 "so that the first parent is the ID of the new changeset, and the second is "
5807 "the null ID. This is shown in <xref linkend=\"fig:concepts:wdir-after-commit"
5808 "\"/>. Mercurial doesn't touch any of the files in the working directory when "
5809 "you commit; it just modifies the dirstate to note its new parents."
5810 msgstr ""
5812 #. type: Content of: <book><chapter><sect1><sect2><title>
5813 #: ../en/ch04-concepts.xml:385
5814 msgid "Creating a new head"
5815 msgstr "创建新顶点"
5817 #. type: Content of: <book><chapter><sect1><sect2><para>
5818 #: ../en/ch04-concepts.xml:387
5819 msgid ""
5820 "It's perfectly normal to update the working directory to a changeset other "
5821 "than the current tip. For example, you might want to know what your project "
5822 "looked like last Tuesday, or you could be looking through changesets to see "
5823 "which one introduced a bug. In cases like this, the natural thing to do is "
5824 "update the working directory to the changeset you're interested in, and then "
5825 "examine the files in the working directory directly to see their contents as "
5826 "they were when you committed that changeset. The effect of this is shown in "
5827 "<xref linkend=\"fig:concepts:wdir-pre-branch\"/>."
5828 msgstr ""
5830 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
5831 #: ../en/ch04-concepts.xml:399
5832 msgid "The working directory, updated to an older changeset"
5833 msgstr "同步到旧修改集的工作目录"
5835 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
5836 #: ../en/ch04-concepts.xml:402
5837 msgid ""
5838 "<imageobject><imagedata fileref=\"figs/wdir-pre-branch.png\"/></imageobject>"
5839 msgstr ""
5841 #. type: Content of: <book><chapter><sect1><sect2><para>
5842 #: ../en/ch04-concepts.xml:407
5843 msgid ""
5844 "Having updated the working directory to an older changeset, what happens if "
5845 "you make some changes, and then commit? Mercurial behaves in the same way as "
5846 "I outlined above. The parents of the working directory become the parents of "
5847 "the new changeset. This new changeset has no children, so it becomes the new "
5848 "tip. And the repository now contains two changesets that have no children; "
5849 "we call these <emphasis>heads</emphasis>. You can see the structure that "
5850 "this creates in <xref linkend=\"fig:concepts:wdir-branch\"/>."
5851 msgstr ""
5853 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
5854 #: ../en/ch04-concepts.xml:419
5855 msgid "After a commit made while synced to an older changeset"
5856 msgstr "对同步到旧修改集的工作目录提交之后"
5858 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
5859 #: ../en/ch04-concepts.xml:422
5860 msgid "<imageobject><imagedata fileref=\"figs/wdir-branch.png\"/></imageobject>"
5861 msgstr ""
5863 #. type: Content of: <book><chapter><sect1><sect2><note><para>
5864 #: ../en/ch04-concepts.xml:428
5865 msgid ""
5866 "If you're new to Mercurial, you should keep in mind a common <quote>error</"
5867 "quote>, which is to use the <command role=\"hg-cmd\">hg pull</command> "
5868 "command without any options. By default, the <command role=\"hg-cmd\">hg "
5869 "pull</command> command <emphasis>does not</emphasis> update the working "
5870 "directory, so you'll bring new changesets into your repository, but the "
5871 "working directory will stay synced at the same changeset as before the pull. "
5872 "If you make some changes and commit afterwards, you'll thus create a new "
5873 "head, because your working directory isn't synced to whatever the current tip "
5874 "is. To combine the operation of a pull, followed by an update, run "
5875 "<command>hg pull -u</command>."
5876 msgstr ""
5878 #. type: Content of: <book><chapter><sect1><sect2><note><para>
5879 #: ../en/ch04-concepts.xml:442
5880 msgid ""
5881 "I put the word <quote>error</quote> in quotes because all that you need to do "
5882 "to rectify the situation where you created a new head by accident is <command "
5883 "role=\"hg-cmd\">hg merge</command>, then <command role=\"hg-cmd\">hg commit</"
5884 "command>. In other words, this almost never has negative consequences; it's "
5885 "just something of a surprise for newcomers. I'll discuss other ways to avoid "
5886 "this behavior, and why Mercurial behaves in this initially surprising way, "
5887 "later on."
5888 msgstr ""
5890 #. type: Content of: <book><chapter><sect1><sect2><title>
5891 #: ../en/ch04-concepts.xml:455
5892 msgid "Merging changes"
5893 msgstr "合并修改"
5895 #. type: Content of: <book><chapter><sect1><sect2><para>
5896 #: ../en/ch04-concepts.xml:457
5897 msgid ""
5898 "When you run the <command role=\"hg-cmd\">hg merge</command> command, "
5899 "Mercurial leaves the first parent of the working directory unchanged, and "
5900 "sets the second parent to the changeset you're merging with, as shown in "
5901 "<xref linkend=\"fig:concepts:wdir-merge\"/>."
5902 msgstr ""
5904 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
5905 #: ../en/ch04-concepts.xml:464
5906 msgid "Merging two heads"
5907 msgstr "合并两个顶点"
5909 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
5910 #: ../en/ch04-concepts.xml:466
5911 msgid ""
5912 "<imageobject> <imagedata fileref=\"figs/wdir-merge.png\"/> </imageobject>"
5913 msgstr ""
5915 #. type: Content of: <book><chapter><sect1><sect2><para>
5916 #: ../en/ch04-concepts.xml:473
5917 msgid ""
5918 "Mercurial also has to modify the working directory, to merge the files "
5919 "managed in the two changesets. Simplified a little, the merging process goes "
5920 "like this, for every file in the manifests of both changesets."
5921 msgstr ""
5923 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
5924 #: ../en/ch04-concepts.xml:478
5925 msgid "If neither changeset has modified a file, do nothing with that file."
5926 msgstr ""
5928 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
5929 #: ../en/ch04-concepts.xml:481
5930 msgid ""
5931 "If one changeset has modified a file, and the other hasn't, create the "
5932 "modified copy of the file in the working directory."
5933 msgstr ""
5935 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
5936 #: ../en/ch04-concepts.xml:485
5937 msgid ""
5938 "If one changeset has removed a file, and the other hasn't (or has also "
5939 "deleted it), delete the file from the working directory."
5940 msgstr ""
5942 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
5943 #: ../en/ch04-concepts.xml:489
5944 msgid ""
5945 "If one changeset has removed a file, but the other has modified the file, ask "
5946 "the user what to do: keep the modified file, or remove it?"
5947 msgstr ""
5949 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
5950 #: ../en/ch04-concepts.xml:493
5951 msgid ""
5952 "If both changesets have modified a file, invoke an external merge program to "
5953 "choose the new contents for the merged file. This may require input from the "
5954 "user."
5955 msgstr ""
5957 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
5958 #: ../en/ch04-concepts.xml:498
5959 msgid ""
5960 "If one changeset has modified a file, and the other has renamed or copied the "
5961 "file, make sure that the changes follow the new name of the file."
5962 msgstr ""
5964 #. type: Content of: <book><chapter><sect1><sect2><para>
5965 #: ../en/ch04-concepts.xml:502
5966 msgid ""
5967 "There are more details&emdash;merging has plenty of corner cases&emdash;but "
5968 "these are the most common choices that are involved in a merge. As you can "
5969 "see, most cases are completely automatic, and indeed most merges finish "
5970 "automatically, without requiring your input to resolve any conflicts."
5971 msgstr ""
5973 #. type: Content of: <book><chapter><sect1><sect2><para>
5974 #: ../en/ch04-concepts.xml:509
5975 msgid ""
5976 "When you're thinking about what happens when you commit after a merge, once "
5977 "again the working directory is <quote>the changeset I'm about to commit</"
5978 "quote>. After the <command role=\"hg-cmd\">hg merge</command> command "
5979 "completes, the working directory has two parents; these will become the "
5980 "parents of the new changeset."
5981 msgstr ""
5983 #. type: Content of: <book><chapter><sect1><sect2><para>
5984 #: ../en/ch04-concepts.xml:516
5985 msgid ""
5986 "Mercurial lets you perform multiple merges, but you must commit the results "
5987 "of each individual merge as you go. This is necessary because Mercurial only "
5988 "tracks two parents for both revisions and the working directory. While it "
5989 "would be technically feasible to merge multiple changesets at once, Mercurial "
5990 "avoids this for simplicity. With multi-way merges, the risks of user "
5991 "confusion, nasty conflict resolution, and making a terrible mess of a merge "
5992 "would grow intolerable."
5993 msgstr ""
5995 #. type: Content of: <book><chapter><sect1><sect2><title>
5996 #: ../en/ch04-concepts.xml:529
5997 msgid "Merging and renames"
5998 msgstr "合并与改名"
6000 #. type: Content of: <book><chapter><sect1><sect2><para>
6001 #: ../en/ch04-concepts.xml:531
6002 msgid ""
6003 "A surprising number of revision control systems pay little or no attention to "
6004 "a file's <emphasis>name</emphasis> over time. For instance, it used to be "
6005 "common that if a file got renamed on one side of a merge, the changes from "
6006 "the other side would be silently dropped."
6007 msgstr ""
6009 #. type: Content of: <book><chapter><sect1><sect2><para>
6010 #: ../en/ch04-concepts.xml:537
6011 msgid ""
6012 "Mercurial records metadata when you tell it to perform a rename or copy. It "
6013 "uses this metadata during a merge to do the right thing in the case of a "
6014 "merge. For instance, if I rename a file, and you edit it without renaming "
6015 "it, when we merge our work the file will be renamed and have your edits "
6016 "applied."
6017 msgstr ""
6019 #. type: Content of: <book><chapter><sect1><title>
6020 #: ../en/ch04-concepts.xml:547
6021 msgid "Other interesting design features"
6022 msgstr "其它有趣的设计特性"
6024 #. type: Content of: <book><chapter><sect1><para>
6025 #: ../en/ch04-concepts.xml:549
6026 msgid ""
6027 "In the sections above, I've tried to highlight some of the most important "
6028 "aspects of Mercurial's design, to illustrate that it pays careful attention "
6029 "to reliability and performance. However, the attention to detail doesn't "
6030 "stop there. There are a number of other aspects of Mercurial's construction "
6031 "that I personally find interesting. I'll detail a few of them here, separate "
6032 "from the <quote>big ticket</quote> items above, so that if you're interested, "
6033 "you can gain a better idea of the amount of thinking that goes into a well-"
6034 "designed system."
6035 msgstr ""
6037 #. type: Content of: <book><chapter><sect1><sect2><title>
6038 #: ../en/ch04-concepts.xml:560
6039 msgid "Clever compression"
6040 msgstr "智能压缩"
6042 #. type: Content of: <book><chapter><sect1><sect2><para>
6043 #: ../en/ch04-concepts.xml:562
6044 msgid ""
6045 "When appropriate, Mercurial will store both snapshots and deltas in "
6046 "compressed form. It does this by always <emphasis>trying to</emphasis> "
6047 "compress a snapshot or delta, but only storing the compressed version if it's "
6048 "smaller than the uncompressed version."
6049 msgstr ""
6051 #. type: Content of: <book><chapter><sect1><sect2><para>
6052 #: ../en/ch04-concepts.xml:568
6053 msgid ""
6054 "This means that Mercurial does <quote>the right thing</quote> when storing a "
6055 "file whose native form is compressed, such as a <literal>zip</literal> "
6056 "archive or a JPEG image. When these types of files are compressed a second "
6057 "time, the resulting file is usually bigger than the once-compressed form, and "
6058 "so Mercurial will store the plain <literal>zip</literal> or JPEG."
6059 msgstr ""
6061 #. type: Content of: <book><chapter><sect1><sect2><para>
6062 #: ../en/ch04-concepts.xml:576
6063 msgid ""
6064 "Deltas between revisions of a compressed file are usually larger than "
6065 "snapshots of the file, and Mercurial again does <quote>the right thing</"
6066 "quote> in these cases. It finds that such a delta exceeds the threshold at "
6067 "which it should store a complete snapshot of the file, so it stores the "
6068 "snapshot, again saving space compared to a naive delta-only approach."
6069 msgstr ""
6071 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
6072 #: ../en/ch04-concepts.xml:585
6073 msgid "Network recompression"
6074 msgstr "网络重新压缩"
6076 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
6077 #: ../en/ch04-concepts.xml:587
6078 msgid ""
6079 "When storing revisions on disk, Mercurial uses the <quote>deflate</quote> "
6080 "compression algorithm (the same one used by the popular <literal>zip</"
6081 "literal> archive format), which balances good speed with a respectable "
6082 "compression ratio. However, when transmitting revision data over a network "
6083 "connection, Mercurial uncompresses the compressed revision data."
6084 msgstr ""
6086 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
6087 #: ../en/ch04-concepts.xml:595
6088 msgid ""
6089 "If the connection is over HTTP, Mercurial recompresses the entire stream of "
6090 "data using a compression algorithm that gives a better compression ratio (the "
6091 "Burrows-Wheeler algorithm from the widely used <literal>bzip2</literal> "
6092 "compression package). This combination of algorithm and compression of the "
6093 "entire stream (instead of a revision at a time) substantially reduces the "
6094 "number of bytes to be transferred, yielding better network performance over "
6095 "most kinds of network."
6096 msgstr ""
6098 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
6099 #: ../en/ch04-concepts.xml:605
6100 msgid ""
6101 "If the connection is over <command>ssh</command>, Mercurial "
6102 "<emphasis>doesn't</emphasis> recompress the stream, because <command>ssh</"
6103 "command> can already do this itself. You can tell Mercurial to always use "
6104 "<command>ssh</command>'s compression feature by editing the <filename>.hgrc</"
6105 "filename> file in your home directory as follows."
6106 msgstr ""
6108 #. type: Content of: <book><chapter><sect1><sect2><title>
6109 #: ../en/ch04-concepts.xml:620
6110 msgid "Read/write ordering and atomicity"
6111 msgstr "读写顺序与原子性"
6113 #. type: Content of: <book><chapter><sect1><sect2><para>
6114 #: ../en/ch04-concepts.xml:622
6115 msgid ""
6116 "Appending to files isn't the whole story when it comes to guaranteeing that a "
6117 "reader won't see a partial write. If you recall <xref linkend=\"fig:concepts:"
6118 "metadata\"/>, revisions in the changelog point to revisions in the manifest, "
6119 "and revisions in the manifest point to revisions in filelogs. This hierarchy "
6120 "is deliberate."
6121 msgstr ""
6123 #. type: Content of: <book><chapter><sect1><sect2><para>
6124 #: ../en/ch04-concepts.xml:629
6125 msgid ""
6126 "A writer starts a transaction by writing filelog and manifest data, and "
6127 "doesn't write any changelog data until those are finished. A reader starts "
6128 "by reading changelog data, then manifest data, followed by filelog data."
6129 msgstr ""
6131 #. type: Content of: <book><chapter><sect1><sect2><para>
6132 #: ../en/ch04-concepts.xml:634
6133 msgid ""
6134 "Since the writer has always finished writing filelog and manifest data before "
6135 "it writes to the changelog, a reader will never read a pointer to a partially "
6136 "written manifest revision from the changelog, and it will never read a "
6137 "pointer to a partially written filelog revision from the manifest."
6138 msgstr ""
6140 #. type: Content of: <book><chapter><sect1><sect2><title>
6141 #: ../en/ch04-concepts.xml:642
6142 msgid "Concurrent access"
6143 msgstr "并发访问"
6145 #. type: Content of: <book><chapter><sect1><sect2><para>
6146 #: ../en/ch04-concepts.xml:644
6147 msgid ""
6148 "The read/write ordering and atomicity guarantees mean that Mercurial never "
6149 "needs to <emphasis>lock</emphasis> a repository when it's reading data, even "
6150 "if the repository is being written to while the read is occurring. This has a "
6151 "big effect on scalability; you can have an arbitrary number of Mercurial "
6152 "processes safely reading data from a repository all at once, no matter "
6153 "whether it's being written to or not."
6154 msgstr ""
6156 #. type: Content of: <book><chapter><sect1><sect2><para>
6157 #: ../en/ch04-concepts.xml:653
6158 msgid ""
6159 "The lockless nature of reading means that if you're sharing a repository on a "
6160 "multi-user system, you don't need to grant other local users permission to "
6161 "<emphasis>write</emphasis> to your repository in order for them to be able to "
6162 "clone it or pull changes from it; they only need <emphasis>read</emphasis> "
6163 "permission. (This is <emphasis>not</emphasis> a common feature among "
6164 "revision control systems, so don't take it for granted! Most require readers "
6165 "to be able to lock a repository to access it safely, and this requires write "
6166 "permission on at least one directory, which of course makes for all kinds of "
6167 "nasty and annoying security and administrative problems.)"
6168 msgstr ""
6170 #. type: Content of: <book><chapter><sect1><sect2><para>
6171 #: ../en/ch04-concepts.xml:666
6172 msgid ""
6173 "Mercurial uses locks to ensure that only one process can write to a "
6174 "repository at a time (the locking mechanism is safe even over filesystems "
6175 "that are notoriously hostile to locking, such as NFS). If a repository is "
6176 "locked, a writer will wait for a while to retry if the repository becomes "
6177 "unlocked, but if the repository remains locked for too long, the process "
6178 "attempting to write will time out after a while. This means that your daily "
6179 "automated scripts won't get stuck forever and pile up if a system crashes "
6180 "unnoticed, for example. (Yes, the timeout is configurable, from zero to "
6181 "infinity.)"
6182 msgstr ""
6184 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
6185 #: ../en/ch04-concepts.xml:678
6186 msgid "Safe dirstate access"
6187 msgstr "安全的目录状态访问"
6189 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
6190 #: ../en/ch04-concepts.xml:680
6191 msgid ""
6192 "As with revision data, Mercurial doesn't take a lock to read the dirstate "
6193 "file; it does acquire a lock to write it. To avoid the possibility of "
6194 "reading a partially written copy of the dirstate file, Mercurial writes to a "
6195 "file with a unique name in the same directory as the dirstate file, then "
6196 "renames the temporary file atomically to <filename>dirstate</filename>. The "
6197 "file named <filename>dirstate</filename> is thus guaranteed to be complete, "
6198 "not partially written."
6199 msgstr ""
6201 #. type: Content of: <book><chapter><sect1><sect2><title>
6202 #: ../en/ch04-concepts.xml:693
6203 msgid "Avoiding seeks"
6204 msgstr "避免查找"
6206 #. type: Content of: <book><chapter><sect1><sect2><para>
6207 #: ../en/ch04-concepts.xml:695
6208 msgid ""
6209 "Critical to Mercurial's performance is the avoidance of seeks of the disk "
6210 "head, since any seek is far more expensive than even a comparatively large "
6211 "read operation."
6212 msgstr ""
6214 #. type: Content of: <book><chapter><sect1><sect2><para>
6215 #: ../en/ch04-concepts.xml:699
6216 msgid ""
6217 "This is why, for example, the dirstate is stored in a single file. If there "
6218 "were a dirstate file per directory that Mercurial tracked, the disk would "
6219 "seek once per directory. Instead, Mercurial reads the entire single dirstate "
6220 "file in one step."
6221 msgstr ""
6223 #. type: Content of: <book><chapter><sect1><sect2><para>
6224 #: ../en/ch04-concepts.xml:705
6225 msgid ""
6226 "Mercurial also uses a <quote>copy on write</quote> scheme when cloning a "
6227 "repository on local storage. Instead of copying every revlog file from the "
6228 "old repository into the new repository, it makes a <quote>hard link</quote>, "
6229 "which is a shorthand way to say <quote>these two names point to the same "
6230 "file</quote>. When Mercurial is about to write to one of a revlog's files, "
6231 "it checks to see if the number of names pointing at the file is greater than "
6232 "one. If it is, more than one repository is using the file, so Mercurial "
6233 "makes a new copy of the file that is private to this repository."
6234 msgstr ""
6236 #. type: Content of: <book><chapter><sect1><sect2><para>
6237 #: ../en/ch04-concepts.xml:716
6238 msgid ""
6239 "A few revision control developers have pointed out that this idea of making a "
6240 "complete private copy of a file is not very efficient in its use of storage. "
6241 "While this is true, storage is cheap, and this method gives the highest "
6242 "performance while deferring most book-keeping to the operating system. An "
6243 "alternative scheme would most likely reduce performance and increase the "
6244 "complexity of the software, but speed and simplicity are key to the "
6245 "<quote>feel</quote> of day-to-day use."
6246 msgstr ""
6248 #. type: Content of: <book><chapter><sect1><sect2><title>
6249 #: ../en/ch04-concepts.xml:728
6250 msgid "Other contents of the dirstate"
6251 msgstr "目录状态的其它内容"
6253 #. type: Content of: <book><chapter><sect1><sect2><para>
6254 #: ../en/ch04-concepts.xml:730
6255 msgid ""
6256 "Because Mercurial doesn't force you to tell it when you're modifying a file, "
6257 "it uses the dirstate to store some extra information so it can determine "
6258 "efficiently whether you have modified a file. For each file in the working "
6259 "directory, it stores the time that it last modified the file itself, and the "
6260 "size of the file at that time."
6261 msgstr ""
6263 #. type: Content of: <book><chapter><sect1><sect2><para>
6264 #: ../en/ch04-concepts.xml:737
6265 msgid ""
6266 "When you explicitly <command role=\"hg-cmd\">hg add</command>, <command role="
6267 "\"hg-cmd\">hg remove</command>, <command role=\"hg-cmd\">hg rename</command> "
6268 "or <command role=\"hg-cmd\">hg copy</command> files, Mercurial updates the "
6269 "dirstate so that it knows what to do with those files when you commit."
6270 msgstr ""
6272 #. type: Content of: <book><chapter><sect1><sect2><para>
6273 #: ../en/ch04-concepts.xml:744
6274 msgid ""
6275 "The dirstate helps Mercurial to efficiently check the status of files in a "
6276 "repository."
6277 msgstr ""
6279 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6280 #: ../en/ch04-concepts.xml:749
6281 msgid ""
6282 "When Mercurial checks the state of a file in the working directory, it first "
6283 "checks a file's modification time against the time in the dirstate that "
6284 "records when Mercurial last wrote the file. If the last modified time is the "
6285 "same as the time when Mercurial wrote the file, the file must not have been "
6286 "modified, so Mercurial does not need to check any further."
6287 msgstr ""
6289 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6290 #: ../en/ch04-concepts.xml:758
6291 msgid ""
6292 "If the file's size has changed, the file must have been modified. If the "
6293 "modification time has changed, but the size has not, only then does Mercurial "
6294 "need to actually read the contents of the file to see if it has changed."
6295 msgstr ""
6297 #. type: Content of: <book><chapter><sect1><sect2><para>
6298 #: ../en/ch04-concepts.xml:766
6299 msgid ""
6300 "Storing the modification time and size dramatically reduces the number of "
6301 "read operations that Mercurial needs to perform when we run commands like "
6302 "<command>hg status</command>. This results in large performance improvements."
6303 msgstr ""
6305 #. type: Content of: <book><chapter><title>
6306 #: ../en/ch05-daily.xml:5
6307 msgid "Mercurial in daily use"
6308 msgstr "Mercurial 的日常使用"
6310 #. type: Content of: <book><chapter><sect1><title>
6311 #: ../en/ch05-daily.xml:8
6312 msgid "Telling Mercurial which files to track"
6313 msgstr "告诉 Mercurial 要跟踪哪些文件"
6315 #. type: Content of: <book><chapter><sect1><para>
6316 #: ../en/ch05-daily.xml:10
6317 msgid ""
6318 "Mercurial does not work with files in your repository unless you tell it to "
6319 "manage them. The <command role=\"hg-cmd\">hg status</command> command will "
6320 "tell you which files Mercurial doesn't know about; it uses a <quote><literal>?"
6321 "</literal></quote> to display such files."
6322 msgstr ""
6325 #. type: Content of: <book><chapter><sect1><para>
6326 #: ../en/ch05-daily.xml:17
6327 msgid ""
6328 "To tell Mercurial to track a file, use the <command role=\"hg-cmd\">hg add</"
6329 "command> command. Once you have added a file, the entry in the output of "
6330 "<command role=\"hg-cmd\">hg status</command> for that file changes from "
6331 "<quote><literal>?</literal></quote> to <quote><literal>A</literal></quote>."
6332 msgstr ""
6334 #. type: Content of: <book><chapter><sect1><para>
6335 #: ../en/ch05-daily.xml:26
6336 msgid ""
6337 "After you run a <command role=\"hg-cmd\">hg commit</command>, the files that "
6338 "you added before the commit will no longer be listed in the output of "
6339 "<command role=\"hg-cmd\">hg status</command>. The reason for this is that by "
6340 "default, <command role=\"hg-cmd\">hg status</command> only tells you about "
6341 "<quote>interesting</quote> files&emdash;those that you have (for example) "
6342 "modified, removed, or renamed. If you have a repository that contains "
6343 "thousands of files, you will rarely want to know about files that Mercurial "
6344 "is tracking, but that have not changed. (You can still get this information; "
6345 "we'll return to this later.)"
6346 msgstr ""
6348 #. type: Content of: <book><chapter><sect1><para>
6349 #: ../en/ch05-daily.xml:38
6350 msgid ""
6351 "Once you add a file, Mercurial doesn't do anything with it immediately. "
6352 "Instead, it will take a snapshot of the file's state the next time you "
6353 "perform a commit. It will then continue to track the changes you make to the "
6354 "file every time you commit, until you remove the file."
6355 msgstr ""
6357 #. type: Content of: <book><chapter><sect1><sect2><title>
6358 #: ../en/ch05-daily.xml:45
6359 msgid "Explicit versus implicit file naming"
6360 msgstr "明确与隐含文件命名"
6362 #. type: Content of: <book><chapter><sect1><sect2><para>
6363 #: ../en/ch05-daily.xml:47
6364 msgid ""
6365 "A useful behavior that Mercurial has is that if you pass the name of a "
6366 "directory to a command, every Mercurial command will treat this as <quote>I "
6367 "want to operate on every file in this directory and its subdirectories</"
6368 "quote>."
6369 msgstr ""
6371 #. type: Content of: <book><chapter><sect1><sect2><para>
6372 #: ../en/ch05-daily.xml:54
6373 msgid ""
6374 "Notice in this example that Mercurial printed the names of the files it "
6375 "added, whereas it didn't do so when we added the file named <filename>myfile."
6376 "txt</filename> in the earlier example."
6377 msgstr ""
6379 #. type: Content of: <book><chapter><sect1><sect2><para>
6380 #: ../en/ch05-daily.xml:59
6381 msgid ""
6382 "What's going on is that in the former case, we explicitly named the file to "
6383 "add on the command line. The assumption that Mercurial makes in such cases "
6384 "is that we know what we are doing, and it doesn't print any output."
6385 msgstr ""
6387 #. type: Content of: <book><chapter><sect1><sect2><para>
6388 #: ../en/ch05-daily.xml:64
6389 msgid ""
6390 "However, when we <emphasis>imply</emphasis> the names of files by giving the "
6391 "name of a directory, Mercurial takes the extra step of printing the name of "
6392 "each file that it does something with. This makes it more clear what is "
6393 "happening, and reduces the likelihood of a silent and nasty surprise. This "
6394 "behavior is common to most Mercurial commands."
6395 msgstr ""
6397 #. type: Content of: <book><chapter><sect1><sect2><title>
6398 #: ../en/ch05-daily.xml:73
6399 msgid "Mercurial tracks files, not directories"
6400 msgstr "Mercurial 只跟踪文件,不跟踪目录"
6402 #. type: Content of: <book><chapter><sect1><sect2><para>
6403 #: ../en/ch05-daily.xml:75
6404 msgid ""
6405 "Mercurial does not track directory information. Instead, it tracks the path "
6406 "to a file. Before creating a file, it first creates any missing directory "
6407 "components of the path. After it deletes a file, it then deletes any empty "
6408 "directories that were in the deleted file's path. This sounds like a trivial "
6409 "distinction, but it has one minor practical consequence: it is not possible "
6410 "to represent a completely empty directory in Mercurial."
6411 msgstr ""
6413 #. type: Content of: <book><chapter><sect1><sect2><para>
6414 #: ../en/ch05-daily.xml:84
6415 msgid ""
6416 "Empty directories are rarely useful, and there are unintrusive workarounds "
6417 "that you can use to achieve an appropriate effect. The developers of "
6418 "Mercurial thus felt that the complexity that would be required to manage "
6419 "empty directories was not worth the limited benefit this feature would bring."
6420 msgstr ""
6422 #. type: Content of: <book><chapter><sect1><sect2><para>
6423 #: ../en/ch05-daily.xml:91
6424 msgid ""
6425 "If you need an empty directory in your repository, there are a few ways to "
6426 "achieve this. One is to create a directory, then <command role=\"hg-cmd\">hg "
6427 "add</command> a <quote>hidden</quote> file to that directory. On Unix-like "
6428 "systems, any file name that begins with a period (<quote><literal>.</"
6429 "literal></quote>) is treated as hidden by most commands and GUI tools. This "
6430 "approach is illustrated below."
6431 msgstr ""
6433 #. type: Content of: <book><chapter><sect1><sect2><para>
6434 #: ../en/ch05-daily.xml:102
6435 msgid ""
6436 "Another way to tackle a need for an empty directory is to simply create one "
6437 "in your automated build scripts before they will need it."
6438 msgstr ""
6440 #. type: Content of: <book><chapter><sect1><title>
6441 #: ../en/ch05-daily.xml:109
6442 msgid "How to stop tracking a file"
6443 msgstr "如何停止跟踪文件"
6445 #. type: Content of: <book><chapter><sect1><para>
6446 #: ../en/ch05-daily.xml:111
6447 msgid ""
6448 "Once you decide that a file no longer belongs in your repository, use the "
6449 "<command role=\"hg-cmd\">hg remove</command> command. This deletes the file, "
6450 "and tells Mercurial to stop tracking it (which will occur at the next "
6451 "commit). A removed file is represented in the output of <command role=\"hg-"
6452 "cmd\">hg status</command> with a <quote><literal>R</literal></quote>."
6453 msgstr ""
6455 #. type: Content of: <book><chapter><sect1><para>
6456 #: ../en/ch05-daily.xml:121
6457 msgid ""
6458 "After you <command role=\"hg-cmd\">hg remove</command> a file, Mercurial will "
6459 "no longer track changes to that file, even if you recreate a file with the "
6460 "same name in your working directory. If you do recreate a file with the same "
6461 "name and want Mercurial to track the new file, simply <command role=\"hg-cmd"
6462 "\">hg add</command> it. Mercurial will know that the newly added file is not "
6463 "related to the old file of the same name."
6464 msgstr ""
6466 #. type: Content of: <book><chapter><sect1><sect2><title>
6467 #: ../en/ch05-daily.xml:130
6468 msgid "Removing a file does not affect its history"
6469 msgstr "删除文件不影响历史"
6471 #. type: Content of: <book><chapter><sect1><sect2><para>
6472 #: ../en/ch05-daily.xml:132
6473 msgid "It is important to understand that removing a file has only two effects."
6474 msgstr ""
6476 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6477 #: ../en/ch05-daily.xml:135
6478 msgid "It removes the current version of the file from the working directory."
6479 msgstr ""
6481 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6482 #: ../en/ch05-daily.xml:138
6483 msgid ""
6484 "It stops Mercurial from tracking changes to the file, from the time of the "
6485 "next commit."
6486 msgstr ""
6488 #. type: Content of: <book><chapter><sect1><sect2><para>
6489 #: ../en/ch05-daily.xml:141
6490 msgid ""
6491 "Removing a file <emphasis>does not</emphasis> in any way alter the "
6492 "<emphasis>history</emphasis> of the file."
6493 msgstr ""
6495 #. type: Content of: <book><chapter><sect1><sect2><para>
6496 #: ../en/ch05-daily.xml:144
6497 msgid ""
6498 "If you update the working directory to a changeset that was committed when it "
6499 "was still tracking a file that you later removed, the file will reappear in "
6500 "the working directory, with the contents it had when you committed that "
6501 "changeset. If you then update the working directory to a later changeset, in "
6502 "which the file had been removed, Mercurial will once again remove the file "
6503 "from the working directory."
6504 msgstr ""
6506 #. type: Content of: <book><chapter><sect1><sect2><title>
6507 #: ../en/ch05-daily.xml:155
6508 msgid "Missing files"
6509 msgstr "丢失的文件"
6511 #. type: Content of: <book><chapter><sect1><sect2><para>
6512 #: ../en/ch05-daily.xml:157
6513 msgid ""
6514 "Mercurial considers a file that you have deleted, but not used <command role="
6515 "\"hg-cmd\">hg remove</command> to delete, to be <emphasis>missing</"
6516 "emphasis>. A missing file is represented with <quote><literal>!</literal></"
6517 "quote> in the output of <command role=\"hg-cmd\">hg status</command>. "
6518 "Mercurial commands will not generally do anything with missing files."
6519 msgstr ""
6521 #. type: Content of: <book><chapter><sect1><sect2><para>
6522 #: ../en/ch05-daily.xml:167
6523 msgid ""
6524 "If your repository contains a file that <command role=\"hg-cmd\">hg status</"
6525 "command> reports as missing, and you want the file to stay gone, you can run "
6526 "<command role=\"hg-cmd\">hg remove <option role=\"hg-opt-remove\">--after</"
6527 "option></command> at any time later on, to tell Mercurial that you really did "
6528 "mean to remove the file."
6529 msgstr ""
6531 #. type: Content of: <book><chapter><sect1><sect2><para>
6532 #: ../en/ch05-daily.xml:177
6533 msgid ""
6534 "On the other hand, if you deleted the missing file by accident, give <command "
6535 "role=\"hg-cmd\">hg revert</command> the name of the file to recover. It will "
6536 "reappear, in unmodified form."
6537 msgstr ""
6539 #. type: Content of: <book><chapter><sect1><sect2><title>
6540 #: ../en/ch05-daily.xml:186
6541 msgid "Aside: why tell Mercurial explicitly to remove a file?"
6542 msgstr "旁白: 为什么要明确告诉 Mercurial 删除文件?"
6544 #. type: Content of: <book><chapter><sect1><sect2><para>
6545 #: ../en/ch05-daily.xml:189
6546 msgid ""
6547 "You might wonder why Mercurial requires you to explicitly tell it that you "
6548 "are deleting a file. Early during the development of Mercurial, it let you "
6549 "delete a file however you pleased; Mercurial would notice the absence of the "
6550 "file automatically when you next ran a <command role=\"hg-cmd\">hg commit</"
6551 "command>, and stop tracking the file. In practice, this made it too easy to "
6552 "accidentally remove a file without noticing."
6553 msgstr ""
6555 #. type: Content of: <book><chapter><sect1><sect2><title>
6556 #: ../en/ch05-daily.xml:200
6557 msgid "Useful shorthand&emdash;adding and removing files in one step"
6558 msgstr "有用的速记—一个步骤添加和删除文件"
6560 #. type: Content of: <book><chapter><sect1><sect2><para>
6561 #: ../en/ch05-daily.xml:203
6562 msgid ""
6563 "Mercurial offers a combination command, <command role=\"hg-cmd\">hg "
6564 "addremove</command>, that adds untracked files and marks missing files as "
6565 "removed."
6566 msgstr ""
6568 #. type: Content of: <book><chapter><sect1><sect2><para>
6569 #: ../en/ch05-daily.xml:209
6570 msgid ""
6571 "The <command role=\"hg-cmd\">hg commit</command> command also provides a "
6572 "<option role=\"hg-opt-commit\">-A</option> option that performs this same add-"
6573 "and-remove, immediately followed by a commit."
6574 msgstr ""
6576 #. type: Content of: <book><chapter><sect1><title>
6577 #: ../en/ch05-daily.xml:219
6578 msgid "Copying files"
6579 msgstr "复制文件"
6581 #. type: Content of: <book><chapter><sect1><para>
6582 #: ../en/ch05-daily.xml:221
6583 msgid ""
6584 "Mercurial provides a <command role=\"hg-cmd\">hg copy</command> command that "
6585 "lets you make a new copy of a file. When you copy a file using this command, "
6586 "Mercurial makes a record of the fact that the new file is a copy of the "
6587 "original file. It treats these copied files specially when you merge your "
6588 "work with someone else's."
6589 msgstr ""
6591 #. type: Content of: <book><chapter><sect1><sect2><title>
6592 #: ../en/ch05-daily.xml:229
6593 msgid "The results of copying during a merge"
6594 msgstr "合并期间的复制结果"
6596 #. type: Content of: <book><chapter><sect1><sect2><para>
6597 #: ../en/ch05-daily.xml:231
6598 msgid ""
6599 "What happens during a merge is that changes <quote>follow</quote> a copy. To "
6600 "best illustrate what this means, let's create an example. We'll start with "
6601 "the usual tiny repository that contains a single file."
6602 msgstr ""
6604 #. type: Content of: <book><chapter><sect1><sect2><para>
6605 #: ../en/ch05-daily.xml:238
6606 msgid ""
6607 "We need to do some work in parallel, so that we'll have something to merge. "
6608 "So let's clone our repository."
6609 msgstr ""
6611 #. type: Content of: <book><chapter><sect1><sect2><para>
6612 #: ../en/ch05-daily.xml:244
6613 msgid ""
6614 "Back in our initial repository, let's use the <command role=\"hg-cmd\">hg "
6615 "copy</command> command to make a copy of the first file we created."
6616 msgstr ""
6618 #. type: Content of: <book><chapter><sect1><sect2><para>
6619 #: ../en/ch05-daily.xml:250
6620 msgid ""
6621 "If we look at the output of the <command role=\"hg-cmd\">hg status</command> "
6622 "command afterwards, the copied file looks just like a normal added file."
6623 msgstr ""
6625 #. type: Content of: <book><chapter><sect1><sect2><para>
6626 #: ../en/ch05-daily.xml:256
6627 msgid ""
6628 "But if we pass the <option role=\"hg-opt-status\">-C</option> option to "
6629 "<command role=\"hg-cmd\">hg status</command>, it prints another line of "
6630 "output: this is the file that our newly-added file was copied <emphasis>from</"
6631 "emphasis>."
6632 msgstr ""
6634 #. type: Content of: <book><chapter><sect1><sect2><para>
6635 #: ../en/ch05-daily.xml:264
6636 msgid ""
6637 "Now, back in the repository we cloned, let's make a change in parallel. "
6638 "We'll add a line of content to the original file that we created."
6639 msgstr ""
6641 #. type: Content of: <book><chapter><sect1><sect2><para>
6642 #: ../en/ch05-daily.xml:270
6643 msgid ""
6644 "Now we have a modified <filename>file</filename> in this repository. When we "
6645 "pull the changes from the first repository, and merge the two heads, "
6646 "Mercurial will propagate the changes that we made locally to <filename>file</"
6647 "filename> into its copy, <filename>new-file</filename>."
6648 msgstr ""
6650 #. type: Content of: <book><chapter><sect1><sect2><title>
6651 #: ../en/ch05-daily.xml:280
6652 msgid "Why should changes follow copies?"
6653 msgstr "为什么复制后需要后续修改?"
6655 #. type: Content of: <book><chapter><sect1><sect2><para>
6656 #: ../en/ch05-daily.xml:282
6657 msgid ""
6658 "This behavior&emdash;of changes to a file propagating out to copies of the "
6659 "file&emdash;might seem esoteric, but in most cases it's highly desirable."
6660 msgstr ""
6662 #. type: Content of: <book><chapter><sect1><sect2><para>
6663 #: ../en/ch05-daily.xml:286
6664 msgid ""
6665 "First of all, remember that this propagation <emphasis>only</emphasis> "
6666 "happens when you merge. So if you <command role=\"hg-cmd\">hg copy</command> "
6667 "a file, and subsequently modify the original file during the normal course of "
6668 "your work, nothing will happen."
6669 msgstr ""
6671 #. type: Content of: <book><chapter><sect1><sect2><para>
6672 #: ../en/ch05-daily.xml:292
6673 msgid ""
6674 "The second thing to know is that modifications will only propagate across a "
6675 "copy as long as the changeset that you're merging changes from "
6676 "<emphasis>hasn't yet seen</emphasis> the copy."
6677 msgstr ""
6679 #. type: Content of: <book><chapter><sect1><sect2><para>
6680 #: ../en/ch05-daily.xml:297
6681 msgid ""
6682 "The reason that Mercurial does this is as follows. Let's say I make an "
6683 "important bug fix in a source file, and commit my changes. Meanwhile, you've "
6684 "decided to <command role=\"hg-cmd\">hg copy</command> the file in your "
6685 "repository, without knowing about the bug or having seen the fix, and you "
6686 "have started hacking on your copy of the file."
6687 msgstr ""
6689 #. type: Content of: <book><chapter><sect1><sect2><para>
6690 #: ../en/ch05-daily.xml:304
6691 msgid ""
6692 "If you pulled and merged my changes, and Mercurial <emphasis>didn't</"
6693 "emphasis> propagate changes across copies, your new source file would now "
6694 "contain the bug, and unless you knew to propagate the bug fix by hand, the "
6695 "bug would <emphasis>remain</emphasis> in your copy of the file."
6696 msgstr ""
6698 #. type: Content of: <book><chapter><sect1><sect2><para>
6699 #: ../en/ch05-daily.xml:310
6700 msgid ""
6701 "By automatically propagating the change that fixed the bug from the original "
6702 "file to the copy, Mercurial prevents this class of problem. To my knowledge, "
6703 "Mercurial is the <emphasis>only</emphasis> revision control system that "
6704 "propagates changes across copies like this."
6705 msgstr ""
6707 #. type: Content of: <book><chapter><sect1><sect2><para>
6708 #: ../en/ch05-daily.xml:316
6709 msgid ""
6710 "Once your change history has a record that the copy and subsequent merge "
6711 "occurred, there's usually no further need to propagate changes from the "
6712 "original file to the copied file, and that's why Mercurial only propagates "
6713 "changes across copies at the first merge, and not afterwards."
6714 msgstr ""
6716 #. type: Content of: <book><chapter><sect1><sect2><title>
6717 #: ../en/ch05-daily.xml:324
6718 msgid "How to make changes <emphasis>not</emphasis> follow a copy"
6719 msgstr "如何让复制后<emphasis>不</emphasis>修改?"
6721 #. type: Content of: <book><chapter><sect1><sect2><para>
6722 #: ../en/ch05-daily.xml:327
6723 msgid ""
6724 "If, for some reason, you decide that this business of automatically "
6725 "propagating changes across copies is not for you, simply use your system's "
6726 "normal file copy command (on Unix-like systems, that's <command>cp</command>) "
6727 "to make a copy of a file, then <command role=\"hg-cmd\">hg add</command> the "
6728 "new copy by hand. Before you do so, though, please do reread <xref linkend="
6729 "\"sec:daily:why-copy\"/>, and make an informed decision that this behavior is "
6730 "not appropriate to your specific case."
6731 msgstr ""
6733 #. type: Content of: <book><chapter><sect1><sect2><title>
6734 #: ../en/ch05-daily.xml:340
6735 msgid "Behavior of the <command role=\"hg-cmd\">hg copy</command> command"
6736 msgstr "命令 <command role=\"hg-cmd\">hg copy</command> 的特性"
6738 #. type: Content of: <book><chapter><sect1><sect2><para>
6739 #: ../en/ch05-daily.xml:343
6740 msgid ""
6741 "When you use the <command role=\"hg-cmd\">hg copy</command> command, "
6742 "Mercurial makes a copy of each source file as it currently stands in the "
6743 "working directory. This means that if you make some modifications to a file, "
6744 "then <command role=\"hg-cmd\">hg copy</command> it without first having "
6745 "committed those changes, the new copy will also contain the modifications you "
6746 "have made up until that point. (I find this behavior a little "
6747 "counterintuitive, which is why I mention it here.)"
6748 msgstr ""
6750 #. type: Content of: <book><chapter><sect1><sect2><para>
6751 #: ../en/ch05-daily.xml:353
6752 msgid ""
6753 "The <command role=\"hg-cmd\">hg copy</command> command acts similarly to the "
6754 "Unix <command>cp</command> command (you can use the <command role=\"hg-cmd"
6755 "\">hg cp</command> alias if you prefer). We must supply two or more "
6756 "arguments, of which the last is treated as the <emphasis>destination</"
6757 "emphasis>, and all others are <emphasis>sources</emphasis>."
6758 msgstr ""
6760 #. type: Content of: <book><chapter><sect1><sect2><para>
6761 #: ../en/ch05-daily.xml:361
6762 msgid ""
6763 "If you pass <command role=\"hg-cmd\">hg copy</command> a single file as the "
6764 "source, and the destination does not exist, it creates a new file with that "
6765 "name."
6766 msgstr ""
6768 #. type: Content of: <book><chapter><sect1><sect2><para>
6769 #: ../en/ch05-daily.xml:367
6770 msgid ""
6771 "If the destination is a directory, Mercurial copies its sources into that "
6772 "directory."
6773 msgstr ""
6775 #. type: Content of: <book><chapter><sect1><sect2><para>
6776 #: ../en/ch05-daily.xml:372
6777 msgid ""
6778 "Copying a directory is recursive, and preserves the directory structure of "
6779 "the source."
6780 msgstr ""
6782 #. type: Content of: <book><chapter><sect1><sect2><para>
6783 #: ../en/ch05-daily.xml:378
6784 msgid ""
6785 "If the source and destination are both directories, the source tree is "
6786 "recreated in the destination directory."
6787 msgstr ""
6789 #. type: Content of: <book><chapter><sect1><sect2><para>
6790 #: ../en/ch05-daily.xml:383
6791 msgid ""
6792 "As with the <command role=\"hg-cmd\">hg remove</command> command, if you copy "
6793 "a file manually and then want Mercurial to know that you've copied the file, "
6794 "simply use the <option role=\"hg-opt-copy\">--after</option> option to "
6795 "<command role=\"hg-cmd\">hg copy</command>."
6796 msgstr ""
6798 #. type: Content of: <book><chapter><sect1><title>
6799 #: ../en/ch05-daily.xml:394
6800 msgid "Renaming files"
6801 msgstr "改名文件"
6803 #. type: Content of: <book><chapter><sect1><para>
6804 #: ../en/ch05-daily.xml:396
6805 msgid ""
6806 "It's rather more common to need to rename a file than to make a copy of it. "
6807 "The reason I discussed the <command role=\"hg-cmd\">hg copy</command> command "
6808 "before talking about renaming files is that Mercurial treats a rename in "
6809 "essentially the same way as a copy. Therefore, knowing what Mercurial does "
6810 "when you copy a file tells you what to expect when you rename a file."
6811 msgstr ""
6813 #. type: Content of: <book><chapter><sect1><para>
6814 #: ../en/ch05-daily.xml:404
6815 msgid ""
6816 "When you use the <command role=\"hg-cmd\">hg rename</command> command, "
6817 "Mercurial makes a copy of each source file, then deletes it and marks the "
6818 "file as removed."
6819 msgstr ""
6821 #. type: Content of: <book><chapter><sect1><para>
6822 #: ../en/ch05-daily.xml:410
6823 msgid ""
6824 "The <command role=\"hg-cmd\">hg status</command> command shows the newly "
6825 "copied file as added, and the copied-from file as removed."
6826 msgstr ""
6828 #. type: Content of: <book><chapter><sect1><para>
6829 #: ../en/ch05-daily.xml:416
6830 msgid ""
6831 "As with the results of a <command role=\"hg-cmd\">hg copy</command>, we must "
6832 "use the <option role=\"hg-opt-status\">-C</option> option to <command role="
6833 "\"hg-cmd\">hg status</command> to see that the added file is really being "
6834 "tracked by Mercurial as a copy of the original, now removed, file."
6835 msgstr ""
6837 #. type: Content of: <book><chapter><sect1><para>
6838 #: ../en/ch05-daily.xml:425
6839 msgid ""
6840 "As with <command role=\"hg-cmd\">hg remove</command> and <command role=\"hg-"
6841 "cmd\">hg copy</command>, you can tell Mercurial about a rename after the fact "
6842 "using the <option role=\"hg-opt-rename\">--after</option> option. In most "
6843 "other respects, the behavior of the <command role=\"hg-cmd\">hg rename</"
6844 "command> command, and the options it accepts, are similar to the <command "
6845 "role=\"hg-cmd\">hg copy</command> command."
6846 msgstr ""
6848 #. type: Content of: <book><chapter><sect1><para>
6849 #: ../en/ch05-daily.xml:434
6850 msgid ""
6851 "If you're familiar with the Unix command line, you'll be glad to know that "
6852 "<command role=\"hg-cmd\">hg rename</command> command can be invoked as "
6853 "<command role=\"hg-cmd\">hg mv</command>."
6854 msgstr ""
6856 #. type: Content of: <book><chapter><sect1><sect2><title>
6857 #: ../en/ch05-daily.xml:440
6858 msgid "Renaming files and merging changes"
6859 msgstr "改名文件与合并修改"
6861 #. type: Content of: <book><chapter><sect1><sect2><para>
6862 #: ../en/ch05-daily.xml:442
6863 msgid ""
6864 "Since Mercurial's rename is implemented as copy-and-remove, the same "
6865 "propagation of changes happens when you merge after a rename as after a copy."
6866 msgstr ""
6868 #. type: Content of: <book><chapter><sect1><sect2><para>
6869 #: ../en/ch05-daily.xml:446
6870 msgid ""
6871 "If I modify a file, and you rename it to a new name, and then we merge our "
6872 "respective changes, my modifications to the file under its original name will "
6873 "be propagated into the file under its new name. (This is something you might "
6874 "expect to <quote>simply work,</quote> but not all revision control systems "
6875 "actually do this.)"
6876 msgstr ""
6878 #. type: Content of: <book><chapter><sect1><sect2><para>
6879 #: ../en/ch05-daily.xml:453
6880 msgid ""
6881 "Whereas having changes follow a copy is a feature where you can perhaps nod "
6882 "and say <quote>yes, that might be useful,</quote> it should be clear that "
6883 "having them follow a rename is definitely important. Without this facility, "
6884 "it would simply be too easy for changes to become orphaned when files are "
6885 "renamed."
6886 msgstr ""
6888 #. type: Content of: <book><chapter><sect1><sect2><title>
6889 #: ../en/ch05-daily.xml:462
6890 msgid "Divergent renames and merging"
6891 msgstr "改名与合并的分歧"
6893 #. type: Content of: <book><chapter><sect1><sect2><para>
6894 #: ../en/ch05-daily.xml:464
6895 msgid ""
6896 "The case of diverging names occurs when two developers start with a "
6897 "file&emdash;let's call it <filename>foo</filename>&emdash;in their respective "
6898 "repositories."
6899 msgstr ""
6901 #. type: Content of: <book><chapter><sect1><sect2><para>
6902 #: ../en/ch05-daily.xml:471
6903 msgid "Anne renames the file to <filename>bar</filename>."
6904 msgstr ""
6906 #. type: Content of: <book><chapter><sect1><sect2><para>
6907 #: ../en/ch05-daily.xml:475
6908 msgid ""
6909 "Meanwhile, Bob renames it to <filename>quux</filename>. (Remember that "
6910 "<command role=\"hg-cmd\">hg mv</command> is an alias for <command role=\"hg-"
6911 "cmd\">hg rename</command>.)"
6912 msgstr ""
6914 #. type: Content of: <book><chapter><sect1><sect2><para>
6915 #: ../en/ch05-daily.xml:482
6916 msgid ""
6917 "I like to think of this as a conflict because each developer has expressed "
6918 "different intentions about what the file ought to be named."
6919 msgstr ""
6921 #. type: Content of: <book><chapter><sect1><sect2><para>
6922 #: ../en/ch05-daily.xml:486
6923 msgid ""
6924 "What do you think should happen when they merge their work? Mercurial's "
6925 "actual behavior is that it always preserves <emphasis>both</emphasis> names "
6926 "when it merges changesets that contain divergent renames."
6927 msgstr ""
6929 #. type: Content of: <book><chapter><sect1><sect2><para>
6930 #: ../en/ch05-daily.xml:493
6931 msgid ""
6932 "Notice that while Mercurial warns about the divergent renames, it leaves it "
6933 "up to you to do something about the divergence after the merge."
6934 msgstr ""
6936 #. type: Content of: <book><chapter><sect1><sect2><title>
6937 #: ../en/ch05-daily.xml:499
6938 msgid "Convergent renames and merging"
6939 msgstr "收敛改名与合并"
6941 #. type: Content of: <book><chapter><sect1><sect2><para>
6942 #: ../en/ch05-daily.xml:501
6943 msgid ""
6944 "Another kind of rename conflict occurs when two people choose to rename "
6945 "different <emphasis>source</emphasis> files to the same "
6946 "<emphasis>destination</emphasis>. In this case, Mercurial runs its normal "
6947 "merge machinery, and lets you guide it to a suitable resolution."
6948 msgstr ""
6950 #. type: Content of: <book><chapter><sect1><sect2><title>
6951 #: ../en/ch05-daily.xml:509
6952 msgid "Other name-related corner cases"
6953 msgstr "其它名称相关的角落"
6955 #. type: Content of: <book><chapter><sect1><sect2><para>
6956 #: ../en/ch05-daily.xml:511
6957 msgid ""
6958 "Mercurial has a longstanding bug in which it fails to handle a merge where "
6959 "one side has a file with a given name, while another has a directory with the "
6960 "same name. This is documented as <ulink role=\"hg-bug\" url=\"http://www."
6961 "selenic.com/mercurial/bts/issue29\">issue 29</ulink>."
6962 msgstr ""
6964 #. type: Content of: <book><chapter><sect1><title>
6965 #: ../en/ch05-daily.xml:524
6966 msgid "Recovering from mistakes"
6967 msgstr "从错误恢复"
6969 #. type: Content of: <book><chapter><sect1><para>
6970 #: ../en/ch05-daily.xml:526
6971 msgid ""
6972 "Mercurial has some useful commands that will help you to recover from some "
6973 "common mistakes."
6974 msgstr ""
6976 #. type: Content of: <book><chapter><sect1><para>
6977 #: ../en/ch05-daily.xml:529
6978 msgid ""
6979 "The <command role=\"hg-cmd\">hg revert</command> command lets you undo "
6980 "changes that you have made to your working directory. For example, if you "
6981 "<command role=\"hg-cmd\">hg add</command> a file by accident, just run "
6982 "<command role=\"hg-cmd\">hg revert</command> with the name of the file you "
6983 "added, and while the file won't be touched in any way, it won't be tracked "
6984 "for adding by Mercurial any longer, either. You can also use <command role="
6985 "\"hg-cmd\">hg revert</command> to get rid of erroneous changes to a file."
6986 msgstr ""
6988 #. type: Content of: <book><chapter><sect1><para>
6989 #: ../en/ch05-daily.xml:539
6990 msgid ""
6991 "It is helpful to remember that the <command role=\"hg-cmd\">hg revert</"
6992 "command> command is useful for changes that you have not yet committed. Once "
6993 "you've committed a change, if you decide it was a mistake, you can still do "
6994 "something about it, though your options may be more limited."
6995 msgstr ""
6997 #. type: Content of: <book><chapter><sect1><para>
6998 #: ../en/ch05-daily.xml:546
6999 msgid ""
7000 "For more information about the <command role=\"hg-cmd\">hg revert</command> "
7001 "command, and details about how to deal with changes you have already "
7002 "committed, see <xref linkend=\"chap:undo\"/>."
7003 msgstr ""
7005 #. type: Content of: <book><chapter><sect1><title>
7006 #: ../en/ch05-daily.xml:553
7007 msgid "Dealing with tricky merges"
7008 msgstr "合并的技巧"
7010 #. type: Content of: <book><chapter><sect1><para>
7011 #: ../en/ch05-daily.xml:555
7012 msgid ""
7013 "In a complicated or large project, it's not unusual for a merge of two "
7014 "changesets to result in some headaches. Suppose there's a big source file "
7015 "that's been extensively edited by each side of a merge: this is almost "
7016 "inevitably going to result in conflicts, some of which can take a few tries "
7017 "to sort out."
7018 msgstr ""
7020 #. type: Content of: <book><chapter><sect1><para>
7021 #: ../en/ch05-daily.xml:562
7022 msgid ""
7023 "Let's develop a simple case of this and see how to deal with it. We'll start "
7024 "off with a repository containing one file, and clone it twice."
7025 msgstr ""
7027 #. type: Content of: <book><chapter><sect1><para>
7028 #: ../en/ch05-daily.xml:568
7029 msgid "In one clone, we'll modify the file in one way."
7030 msgstr ""
7032 #. type: Content of: <book><chapter><sect1><para>
7033 #: ../en/ch05-daily.xml:572
7034 msgid "In another, we'll modify the file differently."
7035 msgstr ""
7037 #. type: Content of: <book><chapter><sect1><para>
7038 #: ../en/ch05-daily.xml:576
7039 msgid "Next, we'll pull each set of changes into our original repo."
7040 msgstr ""
7042 #. type: Content of: <book><chapter><sect1><para>
7043 #: ../en/ch05-daily.xml:581
7044 msgid "We expect our repository to now contain two heads."
7045 msgstr ""
7047 #. type: Content of: <book><chapter><sect1><para>
7048 #: ../en/ch05-daily.xml:585
7049 msgid ""
7050 "Normally, if we run <command role=\"hg-cmd\">hg merge</command> at this "
7051 "point, it will drop us into a GUI that will let us manually resolve the "
7052 "conflicting edits to <filename>myfile.txt</filename>. However, to simplify "
7053 "things for presentation here, we'd like the merge to fail immediately "
7054 "instead. Here's one way we can do so."
7055 msgstr ""
7057 #. type: Content of: <book><chapter><sect1><para>
7058 #: ../en/ch05-daily.xml:594
7059 msgid ""
7060 "We've told Mercurial's merge machinery to run the command <command>false</"
7061 "command> (which, as we desire, fails immediately) if it detects a merge that "
7062 "it can't sort out automatically."
7063 msgstr ""
7065 #. type: Content of: <book><chapter><sect1><para>
7066 #: ../en/ch05-daily.xml:599
7067 msgid ""
7068 "If we now fire up <command role=\"hg-cmd\">hg merge</command>, it should "
7069 "grind to a halt and report a failure."
7070 msgstr ""
7072 #. type: Content of: <book><chapter><sect1><para>
7073 #: ../en/ch05-daily.xml:605
7074 msgid ""
7075 "Even if we don't notice that the merge failed, Mercurial will prevent us from "
7076 "accidentally committing the result of a failed merge."
7077 msgstr ""
7079 #. type: Content of: <book><chapter><sect1><para>
7080 #: ../en/ch05-daily.xml:611
7081 msgid ""
7082 "When <command role=\"hg-cmd\">hg commit</command> fails in this case, it "
7083 "suggests that we use the unfamiliar <command role=\"hg-cmd\">hg resolve</"
7084 "command> command. As usual, <command role=\"hg-cmd\">hg help resolve</"
7085 "command> will print a helpful synopsis."
7086 msgstr ""
7088 #. type: Content of: <book><chapter><sect1><sect2><title>
7089 #: ../en/ch05-daily.xml:618
7090 msgid "File resolution states"
7091 msgstr "文件的解决状态"
7093 #. type: Content of: <book><chapter><sect1><sect2><para>
7094 #: ../en/ch05-daily.xml:620
7095 msgid ""
7096 "When a merge occurs, most files will usually remain unmodified. For each "
7097 "file where Mercurial has to do something, it tracks the state of the file."
7098 msgstr ""
7100 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
7101 #: ../en/ch05-daily.xml:626
7102 msgid ""
7103 "A <emphasis>resolved</emphasis> file has been successfully merged, either "
7104 "automatically by Mercurial or manually with human intervention."
7105 msgstr ""
7107 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
7108 #: ../en/ch05-daily.xml:631
7109 msgid ""
7110 "An <emphasis>unresolved</emphasis> file was not merged successfully, and "
7111 "needs more attention."
7112 msgstr ""
7114 #. type: Content of: <book><chapter><sect1><sect2><para>
7115 #: ../en/ch05-daily.xml:636
7116 msgid ""
7117 "If Mercurial sees <emphasis>any</emphasis> file in the unresolved state after "
7118 "a merge, it considers the merge to have failed. Fortunately, we do not need "
7119 "to restart the entire merge from scratch."
7120 msgstr ""
7122 #. type: Content of: <book><chapter><sect1><sect2><para>
7123 #: ../en/ch05-daily.xml:641
7124 msgid ""
7125 "The <option role=\"hg-opt-resolve\">--list</option> or <option role=\"hg-opt-"
7126 "resolve\">-l</option> option to <command role=\"hg-cmd\">hg resolve</command> "
7127 "prints out the state of each merged file."
7128 msgstr ""
7130 #. type: Content of: <book><chapter><sect1><sect2><para>
7131 #: ../en/ch05-daily.xml:648
7132 msgid ""
7133 "In the output from <command role=\"hg-cmd\">hg resolve</command>, a resolved "
7134 "file is marked with <literal>R</literal>, while an unresolved file is marked "
7135 "with <literal>U</literal>. If any files are listed with <literal>U</"
7136 "literal>, we know that an attempt to commit the results of the merge will "
7137 "fail."
7138 msgstr ""
7140 #. type: Content of: <book><chapter><sect1><sect2><title>
7141 #: ../en/ch05-daily.xml:657
7142 msgid "Resolving a file merge"
7143 msgstr "合并文件"
7145 #. type: Content of: <book><chapter><sect1><sect2><para>
7146 #: ../en/ch05-daily.xml:659
7147 msgid ""
7148 "We have several options to move a file from the unresolved into the resolved "
7149 "state. By far the most common is to rerun <command role=\"hg-cmd\">hg "
7150 "resolve</command>. If we pass the names of individual files or directories, "
7151 "it will retry the merges of any unresolved files present in those locations. "
7152 "We can also pass the <option role=\"hg-opt-resolve\">--all</option> or "
7153 "<option role=\"hg-opt-resolve\">-a</option> option, which will retry the "
7154 "merges of <emphasis>all</emphasis> unresolved files."
7155 msgstr ""
7157 #. type: Content of: <book><chapter><sect1><sect2><para>
7158 #: ../en/ch05-daily.xml:669
7159 msgid ""
7160 "Mercurial also lets us modify the resolution state of a file directly. We "
7161 "can manually mark a file as resolved using the <option role=\"hg-opt-resolve"
7162 "\">--mark</option> option, or as unresolved using the <option role=\"hg-opt-"
7163 "resolve\">--unmark</option> option. This allows us to clean up a "
7164 "particularly messy merge by hand, and to keep track of our progress with each "
7165 "file as we go."
7166 msgstr ""
7168 #. type: Content of: <book><chapter><sect1><title>
7169 #: ../en/ch05-daily.xml:680
7170 msgid "More useful diffs"
7171 msgstr "更有用的差异"
7173 #. type: Content of: <book><chapter><sect1><para>
7174 #: ../en/ch05-daily.xml:682
7175 msgid ""
7176 "The default output of the <command role=\"hg-cmd\">hg diff</command> command "
7177 "is backwards compatible with the regular <command>diff</command> command, but "
7178 "this has some drawbacks."
7179 msgstr ""
7181 #. type: Content of: <book><chapter><sect1><para>
7182 #: ../en/ch05-daily.xml:687
7183 msgid ""
7184 "Consider the case where we use <command role=\"hg-cmd\">hg rename</command> "
7185 "to rename a file."
7186 msgstr ""
7187 "设想我们使用 <command role=\"hg-cmd\">hg rename</command> 命令来改名文件。"
7189 #. type: Content of: <book><chapter><sect1><para>
7190 #: ../en/ch05-daily.xml:692
7191 msgid ""
7192 "The output of <command role=\"hg-cmd\">hg diff</command> above obscures the "
7193 "fact that we simply renamed a file. The <command role=\"hg-cmd\">hg diff</"
7194 "command> command accepts an option, <option>--git</option> or <option>-g</"
7195 "option>, to use a newer diff format that displays such information in a more "
7196 "readable form."
7197 msgstr ""
7199 #. type: Content of: <book><chapter><sect1><para>
7200 #: ../en/ch05-daily.xml:701
7201 msgid ""
7202 "This option also helps with a case that can otherwise be confusing: a file "
7203 "that appears to be modified according to <command role=\"hg-cmd\">hg status</"
7204 "command>, but for which <command role=\"hg-cmd\">hg diff</command> prints "
7205 "nothing. This situation can arise if we change the file's execute permissions."
7206 msgstr ""
7208 #. type: Content of: <book><chapter><sect1><para>
7209 #: ../en/ch05-daily.xml:710
7210 msgid ""
7211 "The normal <command>diff</command> command pays no attention to file "
7212 "permissions, which is why <command role=\"hg-cmd\">hg diff</command> prints "
7213 "nothing by default. If we supply it with the <option>-g</option> option, it "
7214 "tells us what really happened."
7215 msgstr ""
7217 #. type: Content of: <book><chapter><sect1><title>
7218 #: ../en/ch05-daily.xml:720
7219 msgid "Which files to manage, and which to avoid"
7220 msgstr "需要管理哪些文件,应该避免的事情"
7222 #. type: Content of: <book><chapter><sect1><para>
7223 #: ../en/ch05-daily.xml:722
7224 msgid ""
7225 "Revision control systems are generally best at managing text files that are "
7226 "written by humans, such as source code, where the files do not change much "
7227 "from one revision to the next. Some centralized revision control systems can "
7228 "also deal tolerably well with binary files, such as bitmap images."
7229 msgstr ""
7231 #. type: Content of: <book><chapter><sect1><para>
7232 #: ../en/ch05-daily.xml:728
7233 msgid ""
7234 "For instance, a game development team will typically manage both its source "
7235 "code and all of its binary assets (e.g. geometry data, textures, map layouts) "
7236 "in a revision control system."
7237 msgstr ""
7239 #. type: Content of: <book><chapter><sect1><para>
7240 #: ../en/ch05-daily.xml:733
7241 msgid ""
7242 "Because it is usually impossible to merge two conflicting modifications to a "
7243 "binary file, centralized systems often provide a file locking mechanism that "
7244 "allow a user to say <quote>I am the only person who can edit this file</"
7245 "quote>."
7246 msgstr ""
7248 #. type: Content of: <book><chapter><sect1><para>
7249 #: ../en/ch05-daily.xml:739
7250 msgid ""
7251 "Compared to a centralized system, a distributed revision control system "
7252 "changes some of the factors that guide decisions over which files to manage "
7253 "and how."
7254 msgstr ""
7256 #. type: Content of: <book><chapter><sect1><para>
7257 #: ../en/ch05-daily.xml:743
7258 msgid ""
7259 "For instance, a distributed revision control system cannot, by its nature, "
7260 "offer a file locking facility. There is thus no built-in mechanism to "
7261 "prevent two people from making conflicting changes to a binary file. If you "
7262 "have a team where several people may be editing binary files frequently, it "
7263 "may not be a good idea to use Mercurial&emdash;or any other distributed "
7264 "revision control system&emdash;to manage those files."
7265 msgstr ""
7267 #. type: Content of: <book><chapter><sect1><para>
7268 #: ../en/ch05-daily.xml:751
7269 msgid ""
7270 "When storing modifications to a file, Mercurial usually saves only the "
7271 "differences between the previous and current versions of the file. For most "
7272 "text files, this is extremely efficient. However, some files (particularly "
7273 "binary files) are laid out in such a way that even a small change to a file's "
7274 "logical content results in many or most of the bytes inside the file "
7275 "changing. For instance, compressed files are particularly susceptible to "
7276 "this. If the differences between each successive version of a file are always "
7277 "large, Mercurial will not be able to store the file's revision history very "
7278 "efficiently. This can affect both local storage needs and the amount of time "
7279 "it takes to clone a repository."
7280 msgstr ""
7282 #. type: Content of: <book><chapter><sect1><para>
7283 #: ../en/ch05-daily.xml:764
7284 msgid ""
7285 "To get an idea of how this could affect you in practice, suppose you want to "
7286 "use Mercurial to manage an OpenOffice document. OpenOffice stores documents "
7287 "on disk as compressed zip files. Edit even a single letter of your document "
7288 "in OpenOffice, and almost every byte in the entire file will change when you "
7289 "save it. Now suppose that file is 2MB in size. Because most of the file "
7290 "changes every time you save, Mercurial will have to store all 2MB of the file "
7291 "every time you commit, even though from your perspective, perhaps only a few "
7292 "words are changing each time. A single frequently-edited file that is not "
7293 "friendly to Mercurial's storage assumptions can easily have an outsized "
7294 "effect on the size of the repository."
7295 msgstr ""
7297 #. type: Content of: <book><chapter><sect1><para>
7298 #: ../en/ch05-daily.xml:777
7299 msgid ""
7300 "Even worse, if both you and someone else edit the OpenOffice document you're "
7301 "working on, there is no useful way to merge your work. In fact, there isn't "
7302 "even a good way to tell what the differences are between your respective "
7303 "changes."
7304 msgstr ""
7306 #. type: Content of: <book><chapter><sect1><para>
7307 #: ../en/ch05-daily.xml:782
7308 msgid ""
7309 "There are thus a few clear recommendations about specific kinds of files to "
7310 "be very careful with."
7311 msgstr ""
7313 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
7314 #: ../en/ch05-daily.xml:787
7315 msgid ""
7316 "Files that are very large and incompressible, e.g. ISO CD-ROM images, will by "
7317 "virtue of sheer size make clones over a network very slow."
7318 msgstr ""
7320 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
7321 #: ../en/ch05-daily.xml:792
7322 msgid ""
7323 "Files that change a lot from one revision to the next may be expensive to "
7324 "store if you edit them frequently, and conflicts due to concurrent edits may "
7325 "be difficult to resolve."
7326 msgstr ""
7328 #. type: Content of: <book><chapter><sect1><title>
7329 #: ../en/ch05-daily.xml:801
7330 msgid "Backups and mirroring"
7331 msgstr "备份与镜像"
7333 #. type: Content of: <book><chapter><sect1><para>
7334 #: ../en/ch05-daily.xml:803
7335 msgid ""
7336 "Since Mercurial maintains a complete copy of history in each clone, everyone "
7337 "who uses Mercurial to collaborate on a project can potentially act as a "
7338 "source of backups in the event of a catastrophe. If a central repository "
7339 "becomes unavailable, you can construct a replacement simply by cloning a copy "
7340 "of the repository from one contributor, and pulling any changes they may not "
7341 "have seen from others."
7342 msgstr ""
7344 #. type: Content of: <book><chapter><sect1><para>
7345 #: ../en/ch05-daily.xml:811
7346 msgid ""
7347 "It is simple to use Mercurial to perform off-site backups and remote "
7348 "mirrors. Set up a periodic job (e.g. via the <command>cron</command> "
7349 "command) on a remote server to pull changes from your master repositories "
7350 "every hour. This will only be tricky in the unlikely case that the number of "
7351 "master repositories you maintain changes frequently, in which case you'll "
7352 "need to do a little scripting to refresh the list of repositories to back up."
7353 msgstr ""
7355 #. type: Content of: <book><chapter><sect1><para>
7356 #: ../en/ch05-daily.xml:820
7357 msgid ""
7358 "If you perform traditional backups of your master repositories to tape or "
7359 "disk, and you want to back up a repository named <filename>myrepo</filename>, "
7360 "use <command>hg clone -U myrepo myrepo.bak</command> to create a clone of "
7361 "<filename>myrepo</filename> before you start your backups. The <option>-U</"
7362 "option> option doesn't check out a working directory after the clone "
7363 "completes, since that would be superfluous and make the backup take longer."
7364 msgstr ""
7366 #. type: Content of: <book><chapter><sect1><para>
7367 #: ../en/ch05-daily.xml:829
7368 msgid ""
7369 "If you then back up <filename>myrepo.bak</filename> instead of "
7370 "<filename>myrepo</filename>, you will be guaranteed to have a consistent "
7371 "snapshot of your repository that won't be pushed to by an insomniac developer "
7372 "in mid-backup."
7373 msgstr ""
7375 #. type: Content of: <book><chapter><title>
7376 #: ../en/ch06-collab.xml:5
7377 msgid "Collaborating with other people"
7378 msgstr "团体协作"
7380 #. type: Content of: <book><chapter><para>
7381 #: ../en/ch06-collab.xml:7
7382 msgid ""
7383 "As a completely decentralised tool, Mercurial doesn't impose any policy on "
7384 "how people ought to work with each other. However, if you're new to "
7385 "distributed revision control, it helps to have some tools and examples in "
7386 "mind when you're thinking about possible workflow models."
7387 msgstr ""
7389 #. type: Content of: <book><chapter><sect1><title>
7390 #: ../en/ch06-collab.xml:14
7391 msgid "Mercurial's web interface"
7392 msgstr "Mercurial 的 web 接口"
7394 #. type: Content of: <book><chapter><sect1><para>
7395 #: ../en/ch06-collab.xml:16
7396 msgid ""
7397 "Mercurial has a powerful web interface that provides several useful "
7398 "capabilities."
7399 msgstr ""
7401 #. type: Content of: <book><chapter><sect1><para>
7402 #: ../en/ch06-collab.xml:19
7403 msgid ""
7404 "For interactive use, the web interface lets you browse a single repository or "
7405 "a collection of repositories. You can view the history of a repository, "
7406 "examine each change (comments and diffs), and view the contents of each "
7407 "directory and file. You can even get a view of history that gives a "
7408 "graphical view of the relationships between individual changes and merges."
7409 msgstr ""
7411 #. type: Content of: <book><chapter><sect1><para>
7412 #: ../en/ch06-collab.xml:26
7413 msgid ""
7414 "Also for human consumption, the web interface provides Atom and RSS feeds of "
7415 "the changes in a repository. This lets you <quote>subscribe</quote> to a "
7416 "repository using your favorite feed reader, and be automatically notified of "
7417 "activity in that repository as soon as it happens. I find this capability "
7418 "much more convenient than the model of subscribing to a mailing list to which "
7419 "notifications are sent, as it requires no additional configuration on the "
7420 "part of whoever is serving the repository."
7421 msgstr ""
7423 #. type: Content of: <book><chapter><sect1><para>
7424 #: ../en/ch06-collab.xml:36
7425 msgid ""
7426 "The web interface also lets remote users clone a repository, pull changes "
7427 "from it, and (when the server is configured to permit it) push changes back "
7428 "to it. Mercurial's HTTP tunneling protocol aggressively compresses data, so "
7429 "that it works efficiently even over low-bandwidth network connections."
7430 msgstr ""
7432 #. type: Content of: <book><chapter><sect1><para>
7433 #: ../en/ch06-collab.xml:42
7434 msgid ""
7435 "The easiest way to get started with the web interface is to use your web "
7436 "browser to visit an existing repository, such as the master Mercurial "
7437 "repository at <ulink url=\"http://www.selenic.com/repo/hg\">http://www."
7438 "selenic.com/repo/hg</ulink>."
7439 msgstr ""
7441 #. type: Content of: <book><chapter><sect1><para>
7442 #: ../en/ch06-collab.xml:47
7443 msgid ""
7444 "If you're interested in providing a web interface to your own repositories, "
7445 "there are several good ways to do this."
7446 msgstr ""
7448 #. type: Content of: <book><chapter><sect1><para>
7449 #: ../en/ch06-collab.xml:51
7450 msgid ""
7451 "The easiest and fastest way to get started in an informal environment is to "
7452 "use the <command role=\"hg-cmd\">hg serve</command> command, which is best "
7453 "suited to short-term <quote>lightweight</quote> serving. See <xref linkend="
7454 "\"sec:collab:serve\"/> below for details of how to use this command."
7455 msgstr ""
7457 #. type: Content of: <book><chapter><sect1><para>
7458 #: ../en/ch06-collab.xml:58
7459 msgid ""
7460 "For longer-lived repositories that you'd like to have permanently available, "
7461 "there are several public hosting services available. Some are free to open "
7462 "source projects, while others offer paid commercial hosting. An up-to-date "
7463 "list is available at <ulink url=\"http://www.selenic.com/mercurial/wiki/index."
7464 "cgi/MercurialHosting\">http://www.selenic.com/mercurial/wiki/index.cgi/"
7465 "MercurialHosting</ulink>."
7466 msgstr ""
7468 #. type: Content of: <book><chapter><sect1><para>
7469 #: ../en/ch06-collab.xml:65
7470 msgid ""
7471 "If you would prefer to host your own repositories, Mercurial has built-in "
7472 "support for several popular hosting technologies, most notably CGI (Common "
7473 "Gateway Interface), and WSGI (Web Services Gateway Interface). See <xref "
7474 "linkend=\"sec:collab:cgi\"/> for details of CGI and WSGI configuration."
7475 msgstr ""
7477 #. type: Content of: <book><chapter><sect1><title>
7478 #: ../en/ch06-collab.xml:74
7479 msgid "Collaboration models"
7480 msgstr "协作模型"
7482 #. type: Content of: <book><chapter><sect1><para>
7483 #: ../en/ch06-collab.xml:76
7484 msgid ""
7485 "With a suitably flexible tool, making decisions about workflow is much more "
7486 "of a social engineering challenge than a technical one. Mercurial imposes few "
7487 "limitations on how you can structure the flow of work in a project, so it's "
7488 "up to you and your group to set up and live with a model that matches your "
7489 "own particular needs."
7490 msgstr ""
7492 #. type: Content of: <book><chapter><sect1><sect2><title>
7493 #: ../en/ch06-collab.xml:84
7494 msgid "Factors to keep in mind"
7495 msgstr "要牢记的因素"
7497 #. type: Content of: <book><chapter><sect1><sect2><para>
7498 #: ../en/ch06-collab.xml:86
7499 msgid ""
7500 "The most important aspect of any model that you must keep in mind is how well "
7501 "it matches the needs and capabilities of the people who will be using it. "
7502 "This might seem self-evident; even so, you still can't afford to forget it "
7503 "for a moment."
7504 msgstr ""
7506 #. type: Content of: <book><chapter><sect1><sect2><para>
7507 #: ../en/ch06-collab.xml:92
7508 msgid ""
7509 "I once put together a workflow model that seemed to make perfect sense to me, "
7510 "but that caused a considerable amount of consternation and strife within my "
7511 "development team. In spite of my attempts to explain why we needed a complex "
7512 "set of branches, and how changes ought to flow between them, a few team "
7513 "members revolted. Even though they were smart people, they didn't want to "
7514 "pay attention to the constraints we were operating under, or face the "
7515 "consequences of those constraints in the details of the model that I was "
7516 "advocating."
7517 msgstr ""
7519 #. type: Content of: <book><chapter><sect1><sect2><para>
7520 #: ../en/ch06-collab.xml:102
7521 msgid ""
7522 "Don't sweep foreseeable social or technical problems under the rug. Whatever "
7523 "scheme you put into effect, you should plan for mistakes and problem "
7524 "scenarios. Consider adding automated machinery to prevent, or quickly "
7525 "recover from, trouble that you can anticipate. As an example, if you intend "
7526 "to have a branch with not-for-release changes in it, you'd do well to think "
7527 "early about the possibility that someone might accidentally merge those "
7528 "changes into a release branch. You could avoid this particular problem by "
7529 "writing a hook that prevents changes from being merged from an inappropriate "
7530 "branch."
7531 msgstr ""
7533 #. type: Content of: <book><chapter><sect1><sect2><title>
7534 #: ../en/ch06-collab.xml:116
7535 msgid "Informal anarchy"
7536 msgstr "无政府状态"
7538 #. type: Content of: <book><chapter><sect1><sect2><para>
7539 #: ../en/ch06-collab.xml:118
7540 msgid ""
7541 "I wouldn't suggest an <quote>anything goes</quote> approach as something "
7542 "sustainable, but it's a model that's easy to grasp, and it works perfectly "
7543 "well in a few unusual situations."
7544 msgstr ""
7546 #. type: Content of: <book><chapter><sect1><sect2><para>
7547 #: ../en/ch06-collab.xml:123
7548 msgid ""
7549 "As one example, many projects have a loose-knit group of collaborators who "
7550 "rarely physically meet each other. Some groups like to overcome the "
7551 "isolation of working at a distance by organizing occasional <quote>sprints</"
7552 "quote>. In a sprint, a number of people get together in a single location (a "
7553 "company's conference room, a hotel meeting room, that kind of place) and "
7554 "spend several days more or less locked in there, hacking intensely on a "
7555 "handful of projects."
7556 msgstr ""
7558 #. type: Content of: <book><chapter><sect1><sect2><para>
7559 #: ../en/ch06-collab.xml:132
7560 msgid ""
7561 "A sprint or a hacking session in a coffee shop are the perfect places to use "
7562 "the <command role=\"hg-cmd\">hg serve</command> command, since <command role="
7563 "\"hg-cmd\">hg serve</command> does not require any fancy server "
7564 "infrastructure. You can get started with <command role=\"hg-cmd\">hg serve</"
7565 "command> in moments, by reading <xref linkend=\"sec:collab:serve\"/> below. "
7566 "Then simply tell the person next to you that you're running a server, send "
7567 "the URL to them in an instant message, and you immediately have a quick-"
7568 "turnaround way to work together. They can type your URL into their web "
7569 "browser and quickly review your changes; or they can pull a bugfix from you "
7570 "and verify it; or they can clone a branch containing a new feature and try it "
7571 "out."
7572 msgstr ""
7574 #. type: Content of: <book><chapter><sect1><sect2><para>
7575 #: ../en/ch06-collab.xml:146
7576 msgid ""
7577 "The charm, and the problem, with doing things in an ad hoc fashion like this "
7578 "is that only people who know about your changes, and where they are, can see "
7579 "them. Such an informal approach simply doesn't scale beyond a handful "
7580 "people, because each individual needs to know about <emphasis>n</emphasis> "
7581 "different repositories to pull from."
7582 msgstr ""
7584 #. type: Content of: <book><chapter><sect1><sect2><title>
7585 #: ../en/ch06-collab.xml:156
7586 msgid "A single central repository"
7587 msgstr "单一中央版本库"
7589 #. type: Content of: <book><chapter><sect1><sect2><para>
7590 #: ../en/ch06-collab.xml:158
7591 msgid ""
7592 "For smaller projects migrating from a centralised revision control tool, "
7593 "perhaps the easiest way to get started is to have changes flow through a "
7594 "single shared central repository. This is also the most common "
7595 "<quote>building block</quote> for more ambitious workflow schemes."
7596 msgstr ""
7598 #. type: Content of: <book><chapter><sect1><sect2><para>
7599 #: ../en/ch06-collab.xml:164
7600 msgid ""
7601 "Contributors start by cloning a copy of this repository. They can pull "
7602 "changes from it whenever they need to, and some (perhaps all) developers have "
7603 "permission to push a change back when they're ready for other people to see "
7604 "it."
7605 msgstr ""
7607 #. type: Content of: <book><chapter><sect1><sect2><para>
7608 #: ../en/ch06-collab.xml:169
7609 msgid ""
7610 "Under this model, it can still often make sense for people to pull changes "
7611 "directly from each other, without going through the central repository. "
7612 "Consider a case in which I have a tentative bug fix, but I am worried that if "
7613 "I were to publish it to the central repository, it might subsequently break "
7614 "everyone else's trees as they pull it. To reduce the potential for damage, I "
7615 "can ask you to clone my repository into a temporary repository of your own "
7616 "and test it. This lets us put off publishing the potentially unsafe change "
7617 "until it has had a little testing."
7618 msgstr ""
7620 #. type: Content of: <book><chapter><sect1><sect2><para>
7621 #: ../en/ch06-collab.xml:180
7622 msgid ""
7623 "If a team is hosting its own repository in this kind of scenario, people will "
7624 "usually use the <command>ssh</command> protocol to securely push changes to "
7625 "the central repository, as documented in <xref linkend=\"sec:collab:ssh\"/>. "
7626 "It's also usual to publish a read-only copy of the repository over HTTP, as "
7627 "in <xref linkend=\"sec:collab:cgi\"/>. Publishing over HTTP satisfies the "
7628 "needs of people who don't have push access, and those who want to use web "
7629 "browsers to browse the repository's history."
7630 msgstr ""
7632 #. type: Content of: <book><chapter><sect1><sect2><title>
7633 #: ../en/ch06-collab.xml:193
7634 msgid "A hosted central repository"
7635 msgstr "托管的中央版本库"
7637 #. type: Content of: <book><chapter><sect1><sect2><para>
7638 #: ../en/ch06-collab.xml:195
7639 msgid ""
7640 "A wonderful thing about public hosting services like <ulink url=\"http://"
7641 "bitbucket.org/\">Bitbucket</ulink> is that not only do they handle the fiddly "
7642 "server configuration details, such as user accounts, authentication, and "
7643 "secure wire protocols, they provide additional infrastructure to make this "
7644 "model work well."
7645 msgstr ""
7647 #. type: Content of: <book><chapter><sect1><sect2><para>
7648 #: ../en/ch06-collab.xml:202
7649 msgid ""
7650 "For instance, a well-engineered hosting service will let people clone their "
7651 "own copies of a repository with a single click. This lets people work in "
7652 "separate spaces and share their changes when they're ready."
7653 msgstr ""
7655 #. type: Content of: <book><chapter><sect1><sect2><para>
7656 #: ../en/ch06-collab.xml:207
7657 msgid ""
7658 "In addition, a good hosting service will let people communicate with each "
7659 "other, for instance to say <quote>there are changes ready for you to review "
7660 "in this tree</quote>."
7661 msgstr ""
7663 #. type: Content of: <book><chapter><sect1><sect2><title>
7664 #: ../en/ch06-collab.xml:214
7665 msgid "Working with multiple branches"
7666 msgstr "使用多个分支工作"
7668 #. type: Content of: <book><chapter><sect1><sect2><para>
7669 #: ../en/ch06-collab.xml:216
7670 msgid ""
7671 "Projects of any significant size naturally tend to make progress on several "
7672 "fronts simultaneously. In the case of software, it's common for a project to "
7673 "go through periodic official releases. A release might then go into "
7674 "<quote>maintenance mode</quote> for a while after its first publication; "
7675 "maintenance releases tend to contain only bug fixes, not new features. In "
7676 "parallel with these maintenance releases, one or more future releases may be "
7677 "under development. People normally use the word <quote>branch</quote> to "
7678 "refer to one of these many slightly different directions in which development "
7679 "is proceeding."
7680 msgstr ""
7682 #. type: Content of: <book><chapter><sect1><sect2><para>
7683 #: ../en/ch06-collab.xml:229
7684 msgid ""
7685 "Mercurial is particularly well suited to managing a number of simultaneous, "
7686 "but not identical, branches. Each <quote>development direction</quote> can "
7687 "live in its own central repository, and you can merge changes from one to "
7688 "another as the need arises. Because repositories are independent of each "
7689 "other, unstable changes in a development branch will never affect a stable "
7690 "branch unless someone explicitly merges those changes into the stable branch."
7691 msgstr ""
7693 #. type: Content of: <book><chapter><sect1><sect2><para>
7694 #: ../en/ch06-collab.xml:238
7695 msgid ""
7696 "Here's an example of how this can work in practice. Let's say you have one "
7697 "<quote>main branch</quote> on a central server."
7698 msgstr ""
7700 #. type: Content of: <book><chapter><sect1><sect2><para>
7701 #: ../en/ch06-collab.xml:244
7702 msgid "People clone it, make changes locally, test them, and push them back."
7703 msgstr ""
7705 #. type: Content of: <book><chapter><sect1><sect2><para>
7706 #: ../en/ch06-collab.xml:247
7707 msgid ""
7708 "Once the main branch reaches a release milestone, you can use the <command "
7709 "role=\"hg-cmd\">hg tag</command> command to give a permanent name to the "
7710 "milestone revision."
7711 msgstr ""
7713 #. type: Content of: <book><chapter><sect1><sect2><para>
7714 #: ../en/ch06-collab.xml:253
7715 msgid "Let's say some ongoing development occurs on the main branch."
7716 msgstr ""
7718 #. type: Content of: <book><chapter><sect1><sect2><para>
7719 #: ../en/ch06-collab.xml:258
7720 msgid ""
7721 "Using the tag that was recorded at the milestone, people who clone that "
7722 "repository at any time in the future can use <command role=\"hg-cmd\">hg "
7723 "update</command> to get a copy of the working directory exactly as it was "
7724 "when that tagged revision was committed."
7725 msgstr ""
7727 #. type: Content of: <book><chapter><sect1><sect2><para>
7728 #: ../en/ch06-collab.xml:266
7729 msgid ""
7730 "In addition, immediately after the main branch is tagged, we can then clone "
7731 "the main branch on the server to a new <quote>stable</quote> branch, also on "
7732 "the server."
7733 msgstr ""
7735 #. type: Content of: <book><chapter><sect1><sect2><para>
7736 #: ../en/ch06-collab.xml:272
7737 msgid ""
7738 "If we need to make a change to the stable branch, we can then clone "
7739 "<emphasis>that</emphasis> repository, make our changes, commit, and push our "
7740 "changes back there."
7741 msgstr ""
7743 #. type: Content of: <book><chapter><sect1><sect2><para>
7744 #: ../en/ch06-collab.xml:279
7745 msgid ""
7746 "Because Mercurial repositories are independent, and Mercurial doesn't move "
7747 "changes around automatically, the stable and main branches are "
7748 "<emphasis>isolated</emphasis> from each other. The changes that we made on "
7749 "the main branch don't <quote>leak</quote> to the stable branch, and vice "
7750 "versa."
7751 msgstr ""
7753 #. type: Content of: <book><chapter><sect1><sect2><para>
7754 #: ../en/ch06-collab.xml:286
7755 msgid ""
7756 "We'll often want all of our bugfixes on the stable branch to show up on the "
7757 "main branch, too. Rather than rewrite a bugfix on the main branch, we can "
7758 "simply pull and merge changes from the stable to the main branch, and "
7759 "Mercurial will bring those bugfixes in for us."
7760 msgstr ""
7762 #. type: Content of: <book><chapter><sect1><sect2><para>
7763 #: ../en/ch06-collab.xml:294
7764 msgid ""
7765 "The main branch will still contain changes that are not on the stable branch, "
7766 "but it will also contain all of the bugfixes from the stable branch. The "
7767 "stable branch remains unaffected by these changes, since changes are only "
7768 "flowing from the stable to the main branch, and not the other way."
7769 msgstr ""
7771 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
7772 #: ../en/ch06-collab.xml:303 ../en/ch06-collab.xml:313
7773 msgid "Feature branches"
7774 msgstr "特性分支"
7776 #. type: Content of: <book><chapter><sect1><sect2><para>
7777 #: ../en/ch06-collab.xml:305
7778 msgid ""
7779 "For larger projects, an effective way to manage change is to break up a team "
7780 "into smaller groups. Each group has a shared branch of its own, cloned from "
7781 "a single <quote>master</quote> branch used by the entire project. People "
7782 "working on an individual branch are typically quite isolated from "
7783 "developments on other branches."
7784 msgstr ""
7786 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
7787 #: ../en/ch06-collab.xml:315
7788 msgid ""
7789 "<imageobject><imagedata width=\"100%\" fileref=\"figs/feature-branches.png\"/"
7790 "></imageobject>"
7791 msgstr ""
7793 #. type: Content of: <book><chapter><sect1><sect2><para>
7794 #: ../en/ch06-collab.xml:320
7795 msgid ""
7796 "When a particular feature is deemed to be in suitable shape, someone on that "
7797 "feature team pulls and merges from the master branch into the feature branch, "
7798 "then pushes back up to the master branch."
7799 msgstr ""
7801 #. type: Content of: <book><chapter><sect1><sect2><title>
7802 #: ../en/ch06-collab.xml:327
7803 msgid "The release train"
7804 msgstr "发布列车"
7806 #. type: Content of: <book><chapter><sect1><sect2><para>
7807 #: ../en/ch06-collab.xml:329
7808 msgid ""
7809 "Some projects are organized on a <quote>train</quote> basis: a release is "
7810 "scheduled to happen every few months, and whatever features are ready when "
7811 "the <quote>train</quote> is ready to leave are allowed in."
7812 msgstr ""
7814 #. type: Content of: <book><chapter><sect1><sect2><para>
7815 #: ../en/ch06-collab.xml:334
7816 msgid ""
7817 "This model resembles working with feature branches. The difference is that "
7818 "when a feature branch misses a train, someone on the feature team pulls and "
7819 "merges the changes that went out on that train release into the feature "
7820 "branch, and the team continues its work on top of that release so that their "
7821 "feature can make the next release."
7822 msgstr ""
7824 #. type: Content of: <book><chapter><sect1><sect2><title>
7825 #: ../en/ch06-collab.xml:343
7826 msgid "The Linux kernel model"
7827 msgstr "Linux 内核模型"
7829 #. type: Content of: <book><chapter><sect1><sect2><para>
7830 #: ../en/ch06-collab.xml:345
7831 msgid ""
7832 "The development of the Linux kernel has a shallow hierarchical structure, "
7833 "surrounded by a cloud of apparent chaos. Because most Linux developers use "
7834 "<command>git</command>, a distributed revision control tool with capabilities "
7835 "similar to Mercurial, it's useful to describe the way work flows in that "
7836 "environment; if you like the ideas, the approach translates well across tools."
7837 msgstr ""
7839 #. type: Content of: <book><chapter><sect1><sect2><para>
7840 #: ../en/ch06-collab.xml:353
7841 msgid ""
7842 "At the center of the community sits Linus Torvalds, the creator of Linux. He "
7843 "publishes a single source repository that is considered the "
7844 "<quote>authoritative</quote> current tree by the entire developer community. "
7845 "Anyone can clone Linus's tree, but he is very choosy about whose trees he "
7846 "pulls from."
7847 msgstr ""
7849 #. type: Content of: <book><chapter><sect1><sect2><para>
7850 #: ../en/ch06-collab.xml:360
7851 msgid ""
7852 "Linus has a number of <quote>trusted lieutenants</quote>. As a general rule, "
7853 "he pulls whatever changes they publish, in most cases without even reviewing "
7854 "those changes. Some of those lieutenants are generally agreed to be "
7855 "<quote>maintainers</quote>, responsible for specific subsystems within the "
7856 "kernel. If a random kernel hacker wants to make a change to a subsystem that "
7857 "they want to end up in Linus's tree, they must find out who the subsystem's "
7858 "maintainer is, and ask that maintainer to take their change. If the "
7859 "maintainer reviews their changes and agrees to take them, they'll pass them "
7860 "along to Linus in due course."
7861 msgstr ""
7863 #. type: Content of: <book><chapter><sect1><sect2><para>
7864 #: ../en/ch06-collab.xml:372
7865 msgid ""
7866 "Individual lieutenants have their own approaches to reviewing, accepting, and "
7867 "publishing changes; and for deciding when to feed them to Linus. In "
7868 "addition, there are several well known branches that people use for different "
7869 "purposes. For example, a few people maintain <quote>stable</quote> "
7870 "repositories of older versions of the kernel, to which they apply critical "
7871 "fixes as needed. Some maintainers publish multiple trees: one for "
7872 "experimental changes; one for changes that they are about to feed upstream; "
7873 "and so on. Others just publish a single tree."
7874 msgstr ""
7876 #. type: Content of: <book><chapter><sect1><sect2><para>
7877 #: ../en/ch06-collab.xml:383
7878 msgid ""
7879 "This model has two notable features. The first is that it's <quote>pull "
7880 "only</quote>. You have to ask, convince, or beg another developer to take a "
7881 "change from you, because there are almost no trees to which more than one "
7882 "person can push, and there's no way to push changes into a tree that someone "
7883 "else controls."
7884 msgstr ""
7886 #. type: Content of: <book><chapter><sect1><sect2><para>
7887 #: ../en/ch06-collab.xml:390
7888 msgid ""
7889 "The second is that it's based on reputation and acclaim. If you're an "
7890 "unknown, Linus will probably ignore changes from you without even "
7891 "responding. But a subsystem maintainer will probably review them, and will "
7892 "likely take them if they pass their criteria for suitability. The more "
7893 "<quote>good</quote> changes you contribute to a maintainer, the more likely "
7894 "they are to trust your judgment and accept your changes. If you're well-"
7895 "known and maintain a long-lived branch for something Linus hasn't yet "
7896 "accepted, people with similar interests may pull your changes regularly to "
7897 "keep up with your work."
7898 msgstr ""
7900 #. type: Content of: <book><chapter><sect1><sect2><para>
7901 #: ../en/ch06-collab.xml:401
7902 msgid ""
7903 "Reputation and acclaim don't necessarily cross subsystem or <quote>people</"
7904 "quote> boundaries. If you're a respected but specialised storage hacker, and "
7905 "you try to fix a networking bug, that change will receive a level of scrutiny "
7906 "from a network maintainer comparable to a change from a complete stranger."
7907 msgstr ""
7909 #. type: Content of: <book><chapter><sect1><sect2><para>
7910 #: ../en/ch06-collab.xml:408
7911 msgid ""
7912 "To people who come from more orderly project backgrounds, the comparatively "
7913 "chaotic Linux kernel development process often seems completely insane. It's "
7914 "subject to the whims of individuals; people make sweeping changes whenever "
7915 "they deem it appropriate; and the pace of development is astounding. And yet "
7916 "Linux is a highly successful, well-regarded piece of software."
7917 msgstr ""
7919 #. type: Content of: <book><chapter><sect1><sect2><title>
7920 #: ../en/ch06-collab.xml:418
7921 msgid "Pull-only versus shared-push collaboration"
7922 msgstr "只读与共享写协作"
7924 #. type: Content of: <book><chapter><sect1><sect2><para>
7925 #: ../en/ch06-collab.xml:420
7926 msgid ""
7927 "A perpetual source of heat in the open source community is whether a "
7928 "development model in which people only ever pull changes from others is "
7929 "<quote>better than</quote> one in which multiple people can push changes to a "
7930 "shared repository."
7931 msgstr ""
7933 #. type: Content of: <book><chapter><sect1><sect2><para>
7934 #: ../en/ch06-collab.xml:426
7935 msgid ""
7936 "Typically, the backers of the shared-push model use tools that actively "
7937 "enforce this approach. If you're using a centralised revision control tool "
7938 "such as Subversion, there's no way to make a choice over which model you'll "
7939 "use: the tool gives you shared-push, and if you want to do anything else, "
7940 "you'll have to roll your own approach on top (such as applying a patch by "
7941 "hand)."
7942 msgstr ""
7944 #. type: Content of: <book><chapter><sect1><sect2><para>
7945 #: ../en/ch06-collab.xml:434
7946 msgid ""
7947 "A good distributed revision control tool will support both models. You and "
7948 "your collaborators can then structure how you work together based on your own "
7949 "needs and preferences, not on what contortions your tools force you into."
7950 msgstr ""
7952 #. type: Content of: <book><chapter><sect1><sect2><title>
7953 #: ../en/ch06-collab.xml:441
7954 msgid "Where collaboration meets branch management"
7955 msgstr "协作与分支管理"
7957 #. type: Content of: <book><chapter><sect1><sect2><para>
7958 #: ../en/ch06-collab.xml:443
7959 msgid ""
7960 "Once you and your team set up some shared repositories and start propagating "
7961 "changes back and forth between local and shared repos, you begin to face a "
7962 "related, but slightly different challenge: that of managing the multiple "
7963 "directions in which your team may be moving at once. Even though this "
7964 "subject is intimately related to how your team collaborates, it's dense "
7965 "enough to merit treatment of its own, in <xref linkend=\"chap:branch\"/>."
7966 msgstr ""
7968 #. type: Content of: <book><chapter><sect1><title>
7969 #: ../en/ch06-collab.xml:455
7970 msgid "The technical side of sharing"
7971 msgstr "共享的技术因素"
7973 #. type: Content of: <book><chapter><sect1><para>
7974 #: ../en/ch06-collab.xml:457
7975 msgid ""
7976 "The remainder of this chapter is devoted to the question of sharing changes "
7977 "with your collaborators."
7978 msgstr ""
7980 #. type: Content of: <book><chapter><sect1><title>
7981 #: ../en/ch06-collab.xml:462
7982 msgid "Informal sharing with <command role=\"hg-cmd\">hg serve</command>"
7983 msgstr "使用 <command role=\"hg-cmd\">hg serve</command> 进行非正式共享"
7985 #. type: Content of: <book><chapter><sect1><para>
7986 #: ../en/ch06-collab.xml:465
7987 msgid ""
7988 "Mercurial's <command role=\"hg-cmd\">hg serve</command> command is "
7989 "wonderfully suited to small, tight-knit, and fast-paced group environments. "
7990 "It also provides a great way to get a feel for using Mercurial commands over "
7991 "a network."
7992 msgstr ""
7994 #. type: Content of: <book><chapter><sect1><para>
7995 #: ../en/ch06-collab.xml:470
7996 msgid ""
7997 "Run <command role=\"hg-cmd\">hg serve</command> inside a repository, and in "
7998 "under a second it will bring up a specialised HTTP server; this will accept "
7999 "connections from any client, and serve up data for that repository until you "
8000 "terminate it. Anyone who knows the URL of the server you just started, and "
8001 "can talk to your computer over the network, can then use a web browser or "
8002 "Mercurial to read data from that repository. A URL for a <command role=\"hg-"
8003 "cmd\">hg serve</command> instance running on a laptop is likely to look "
8004 "something like <literal>http://my-laptop.local:8000/</literal>."
8005 msgstr ""
8007 #. type: Content of: <book><chapter><sect1><para>
8008 #: ../en/ch06-collab.xml:481
8009 msgid ""
8010 "The <command role=\"hg-cmd\">hg serve</command> command is <emphasis>not</"
8011 "emphasis> a general-purpose web server. It can do only two things:"
8012 msgstr ""
8014 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8015 #: ../en/ch06-collab.xml:485
8016 msgid ""
8017 "Allow people to browse the history of the repository it's serving, from their "
8018 "normal web browsers."
8019 msgstr ""
8021 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8022 #: ../en/ch06-collab.xml:489
8023 msgid ""
8024 "Speak Mercurial's wire protocol, so that people can <command role=\"hg-cmd"
8025 "\">hg clone</command> or <command role=\"hg-cmd\">hg pull</command> changes "
8026 "from that repository."
8027 msgstr ""
8029 #. type: Content of: <book><chapter><sect1><para>
8030 #: ../en/ch06-collab.xml:494
8031 msgid ""
8032 "In particular, <command role=\"hg-cmd\">hg serve</command> won't allow remote "
8033 "users to <emphasis>modify</emphasis> your repository. It's intended for read-"
8034 "only use."
8035 msgstr ""
8037 #. type: Content of: <book><chapter><sect1><para>
8038 #: ../en/ch06-collab.xml:498
8039 msgid ""
8040 "If you're getting started with Mercurial, there's nothing to prevent you from "
8041 "using <command role=\"hg-cmd\">hg serve</command> to serve up a repository on "
8042 "your own computer, then use commands like <command role=\"hg-cmd\">hg clone</"
8043 "command>, <command role=\"hg-cmd\">hg incoming</command>, and so on to talk "
8044 "to that server as if the repository was hosted remotely. This can help you to "
8045 "quickly get acquainted with using commands on network-hosted repositories."
8046 msgstr ""
8048 #. type: Content of: <book><chapter><sect1><sect2><title>
8049 #: ../en/ch06-collab.xml:508
8050 msgid "A few things to keep in mind"
8051 msgstr "要牢记的几件事"
8053 #. type: Content of: <book><chapter><sect1><sect2><para>
8054 #: ../en/ch06-collab.xml:510
8055 msgid ""
8056 "Because it provides unauthenticated read access to all clients, you should "
8057 "only use <command role=\"hg-cmd\">hg serve</command> in an environment where "
8058 "you either don't care, or have complete control over, who can access your "
8059 "network and pull data from your repository."
8060 msgstr ""
8062 #. type: Content of: <book><chapter><sect1><sect2><para>
8063 #: ../en/ch06-collab.xml:516
8064 msgid ""
8065 "The <command role=\"hg-cmd\">hg serve</command> command knows nothing about "
8066 "any firewall software you might have installed on your system or network. It "
8067 "cannot detect or control your firewall software. If other people are unable "
8068 "to talk to a running <command role=\"hg-cmd\">hg serve</command> instance, "
8069 "the second thing you should do (<emphasis>after</emphasis> you make sure that "
8070 "they're using the correct URL) is check your firewall configuration."
8071 msgstr ""
8073 #. type: Content of: <book><chapter><sect1><sect2><para>
8074 #: ../en/ch06-collab.xml:525
8075 msgid ""
8076 "By default, <command role=\"hg-cmd\">hg serve</command> listens for incoming "
8077 "connections on port 8000. If another process is already listening on the "
8078 "port you want to use, you can specify a different port to listen on using the "
8079 "<option role=\"hg-opt-serve\">-p</option> option."
8080 msgstr ""
8082 #. type: Content of: <book><chapter><sect1><sect2><para>
8083 #: ../en/ch06-collab.xml:531
8084 msgid ""
8085 "Normally, when <command role=\"hg-cmd\">hg serve</command> starts, it prints "
8086 "no output, which can be a bit unnerving. If you'd like to confirm that it is "
8087 "indeed running correctly, and find out what URL you should send to your "
8088 "collaborators, start it with the <option role=\"hg-opt-global\">-v</option> "
8089 "option."
8090 msgstr ""
8092 #. type: Content of: <book><chapter><sect1><title>
8093 #: ../en/ch06-collab.xml:541
8094 msgid "Using the Secure Shell (ssh) protocol"
8095 msgstr "使用 ssh 协议"
8097 #. type: Content of: <book><chapter><sect1><para>
8098 #: ../en/ch06-collab.xml:543
8099 msgid ""
8100 "You can pull and push changes securely over a network connection using the "
8101 "Secure Shell (<literal>ssh</literal>) protocol. To use this successfully, "
8102 "you may have to do a little bit of configuration on the client or server "
8103 "sides."
8104 msgstr ""
8106 #. type: Content of: <book><chapter><sect1><para>
8107 #: ../en/ch06-collab.xml:548
8108 msgid ""
8109 "If you're not familiar with ssh, it's the name of both a command and a "
8110 "network protocol that let you securely communicate with another computer. To "
8111 "use it with Mercurial, you'll be setting up one or more user accounts on a "
8112 "server so that remote users can log in and execute commands."
8113 msgstr ""
8115 #. type: Content of: <book><chapter><sect1><para>
8116 #: ../en/ch06-collab.xml:554
8117 msgid ""
8118 "(If you <emphasis>are</emphasis> familiar with ssh, you'll probably find some "
8119 "of the material that follows to be elementary in nature.)"
8120 msgstr ""
8122 #. type: Content of: <book><chapter><sect1><sect2><title>
8123 #: ../en/ch06-collab.xml:559
8124 msgid "How to read and write ssh URLs"
8125 msgstr "如何读写 ssh 路径"
8127 #. type: Content of: <book><chapter><sect1><sect2><para>
8128 #: ../en/ch06-collab.xml:561
8129 msgid "An ssh URL tends to look like this:"
8130 msgstr ""
8132 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
8133 #: ../en/ch06-collab.xml:564
8134 msgid ""
8135 "The <quote><literal>ssh://</literal></quote> part tells Mercurial to use the "
8136 "ssh protocol."
8137 msgstr ""
8139 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
8140 #: ../en/ch06-collab.xml:567
8141 msgid ""
8142 "The <quote><literal>bos@</literal></quote> component indicates what username "
8143 "to log into the server as. You can leave this out if the remote username is "
8144 "the same as your local username."
8145 msgstr ""
8147 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
8148 #: ../en/ch06-collab.xml:572
8149 msgid ""
8150 "The <quote><literal>hg.serpentine.com</literal></quote> gives the hostname of "
8151 "the server to log into."
8152 msgstr ""
8154 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
8155 #: ../en/ch06-collab.xml:576
8156 msgid ""
8157 "The <quote>:22</quote> identifies the port number to connect to the server "
8158 "on. The default port is 22, so you only need to specify a colon and port "
8159 "number if you're <emphasis>not</emphasis> using port 22."
8160 msgstr ""
8162 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
8163 #: ../en/ch06-collab.xml:581
8164 msgid ""
8165 "The remainder of the URL is the local path to the repository on the server."
8166 msgstr ""
8168 #. type: Content of: <book><chapter><sect1><sect2><para>
8169 #: ../en/ch06-collab.xml:585
8170 msgid ""
8171 "There's plenty of scope for confusion with the path component of ssh URLs, as "
8172 "there is no standard way for tools to interpret it. Some programs behave "
8173 "differently than others when dealing with these paths. This isn't an ideal "
8174 "situation, but it's unlikely to change. Please read the following paragraphs "
8175 "carefully."
8176 msgstr ""
8178 #. type: Content of: <book><chapter><sect1><sect2><para>
8179 #: ../en/ch06-collab.xml:592
8180 msgid ""
8181 "Mercurial treats the path to a repository on the server as relative to the "
8182 "remote user's home directory. For example, if user <literal>foo</literal> on "
8183 "the server has a home directory of <filename class=\"directory\">/home/foo</"
8184 "filename>, then an ssh URL that contains a path component of <filename class="
8185 "\"directory\">bar</filename> <emphasis>really</emphasis> refers to the "
8186 "directory <filename class=\"directory\">/home/foo/bar</filename>."
8187 msgstr ""
8189 #. type: Content of: <book><chapter><sect1><sect2><para>
8190 #: ../en/ch06-collab.xml:601
8191 msgid ""
8192 "If you want to specify a path relative to another user's home directory, you "
8193 "can use a path that starts with a tilde character followed by the user's name "
8194 "(let's call them <literal>otheruser</literal>), like this."
8195 msgstr ""
8197 #. type: Content of: <book><chapter><sect1><sect2><para>
8198 #: ../en/ch06-collab.xml:607
8199 msgid ""
8200 "And if you really want to specify an <emphasis>absolute</emphasis> path on "
8201 "the server, begin the path component with two slashes, as in this example."
8202 msgstr ""
8204 #. type: Content of: <book><chapter><sect1><sect2><title>
8205 #: ../en/ch06-collab.xml:614
8206 msgid "Finding an ssh client for your system"
8207 msgstr "为你的系统寻找 ssh 客户端"
8209 #. type: Content of: <book><chapter><sect1><sect2><para>
8210 #: ../en/ch06-collab.xml:616
8211 msgid ""
8212 "Almost every Unix-like system comes with OpenSSH preinstalled. If you're "
8213 "using such a system, run <literal>which ssh</literal> to find out if the "
8214 "<command>ssh</command> command is installed (it's usually in <filename class="
8215 "\"directory\">/usr/bin</filename>). In the unlikely event that it isn't "
8216 "present, take a look at your system documentation to figure out how to "
8217 "install it."
8218 msgstr ""
8220 #. type: Content of: <book><chapter><sect1><sect2><para>
8221 #: ../en/ch06-collab.xml:624
8222 msgid ""
8223 "On Windows, the TortoiseHg package is bundled with a version of Simon "
8224 "Tatham's excellent <command>plink</command> command, and you should not need "
8225 "to do any further configuration."
8226 msgstr ""
8228 #. type: Content of: <book><chapter><sect1><sect2><title>
8229 #: ../en/ch06-collab.xml:631
8230 msgid "Generating a key pair"
8231 msgstr "产生密钥对"
8233 #. type: Content of: <book><chapter><sect1><sect2><para>
8234 #: ../en/ch06-collab.xml:633
8235 msgid ""
8236 "To avoid the need to repetitively type a password every time you need to use "
8237 "your ssh client, I recommend generating a key pair."
8238 msgstr ""
8240 #. type: Content of: <book><chapter><sect1><sect2><tip><title>
8241 #: ../en/ch06-collab.xml:638
8242 msgid "Key pairs are not mandatory"
8243 msgstr ""
8245 #. type: Content of: <book><chapter><sect1><sect2><tip><para>
8246 #: ../en/ch06-collab.xml:640
8247 msgid ""
8248 "Mercurial knows nothing about ssh authentication or key pairs. You can, if "
8249 "you like, safely ignore this section and the one that follows until you grow "
8250 "tired of repeatedly typing ssh passwords."
8251 msgstr ""
8253 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8254 #: ../en/ch06-collab.xml:648
8255 msgid ""
8256 "On a Unix-like system, the <command>ssh-keygen</command> command will do the "
8257 "trick."
8258 msgstr ""
8260 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8261 #: ../en/ch06-collab.xml:651
8262 msgid ""
8263 "On Windows, if you're using TortoiseHg, you may need to download a command "
8264 "named <command>puttygen</command> from <ulink url=\"http://www.chiark."
8265 "greenend.org.uk/~sgtatham/putty\">the PuTTY web site</ulink> to generate a "
8266 "key pair. See <ulink url=\"http://the.earth.li/~sgtatham/putty/0.60/htmldoc/"
8267 "Chapter8.html#pubkey-puttygen\">the <command>puttygen</command> "
8268 "documentation</ulink> for details of how use the command."
8269 msgstr ""
8271 #. type: Content of: <book><chapter><sect1><sect2><para>
8272 #: ../en/ch06-collab.xml:663
8273 msgid ""
8274 "When you generate a key pair, it's usually <emphasis>highly</emphasis> "
8275 "advisable to protect it with a passphrase. (The only time that you might not "
8276 "want to do this is when you're using the ssh protocol for automated tasks on "
8277 "a secure network.)"
8278 msgstr ""
8280 #. type: Content of: <book><chapter><sect1><sect2><para>
8281 #: ../en/ch06-collab.xml:669
8282 msgid ""
8283 "Simply generating a key pair isn't enough, however. You'll need to add the "
8284 "public key to the set of authorised keys for whatever user you're logging in "
8285 "remotely as. For servers using OpenSSH (the vast majority), this will mean "
8286 "adding the public key to a list in a file called <filename role=\"special"
8287 "\">authorized_keys</filename> in their <filename role=\"special\" class="
8288 "\"directory\">.ssh</filename> directory."
8289 msgstr ""
8291 #. type: Content of: <book><chapter><sect1><sect2><para>
8292 #: ../en/ch06-collab.xml:678
8293 msgid ""
8294 "On a Unix-like system, your public key will have a <filename>.pub</filename> "
8295 "extension. If you're using <command>puttygen</command> on Windows, you can "
8296 "save the public key to a file of your choosing, or paste it from the window "
8297 "it's displayed in straight into the <filename role=\"special"
8298 "\">authorized_keys</filename> file."
8299 msgstr ""
8301 #. type: Content of: <book><chapter><sect1><sect2><title>
8302 #: ../en/ch06-collab.xml:686
8303 msgid "Using an authentication agent"
8304 msgstr "使用认证代理"
8306 #. type: Content of: <book><chapter><sect1><sect2><para>
8307 #: ../en/ch06-collab.xml:688
8308 msgid ""
8309 "An authentication agent is a daemon that stores passphrases in memory (so it "
8310 "will forget passphrases if you log out and log back in again). An ssh client "
8311 "will notice if it's running, and query it for a passphrase. If there's no "
8312 "authentication agent running, or the agent doesn't store the necessary "
8313 "passphrase, you'll have to type your passphrase every time Mercurial tries to "
8314 "communicate with a server on your behalf (e.g. whenever you pull or push "
8315 "changes)."
8316 msgstr ""
8318 #. type: Content of: <book><chapter><sect1><sect2><para>
8319 #: ../en/ch06-collab.xml:697
8320 msgid ""
8321 "The downside of storing passphrases in an agent is that it's possible for a "
8322 "well-prepared attacker to recover the plain text of your passphrases, in some "
8323 "cases even if your system has been power-cycled. You should make your own "
8324 "judgment as to whether this is an acceptable risk. It certainly saves a lot "
8325 "of repeated typing."
8326 msgstr ""
8328 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8329 #: ../en/ch06-collab.xml:706
8330 msgid ""
8331 "On Unix-like systems, the agent is called <command>ssh-agent</command>, and "
8332 "it's often run automatically for you when you log in. You'll need to use the "
8333 "<command>ssh-add</command> command to add passphrases to the agent's store."
8334 msgstr ""
8336 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8337 #: ../en/ch06-collab.xml:713
8338 msgid ""
8339 "On Windows, if you're using TortoiseHg, the <command>pageant</command> "
8340 "command acts as the agent. As with <command>puttygen</command>, you'll need "
8341 "to <ulink url=\"http://www.chiark.greenend.org.uk/%7Esgtatham/putty/download."
8342 "html\">download <command>pageant</command></ulink> from the PuTTY web site "
8343 "and read <ulink url=\"http://the.earth.li/~sgtatham/putty/0.60/htmldoc/"
8344 "Chapter9.html#pageant\">its documentation</ulink>. The <command>pageant</"
8345 "command> command adds an icon to your system tray that will let you manage "
8346 "stored passphrases."
8347 msgstr ""
8349 #. type: Content of: <book><chapter><sect1><sect2><title>
8350 #: ../en/ch06-collab.xml:728
8351 msgid "Configuring the server side properly"
8352 msgstr "正确配置服务器端"
8354 #. type: Content of: <book><chapter><sect1><sect2><para>
8355 #: ../en/ch06-collab.xml:730
8356 msgid ""
8357 "Because ssh can be fiddly to set up if you're new to it, a variety of things "
8358 "can go wrong. Add Mercurial on top, and there's plenty more scope for head-"
8359 "scratching. Most of these potential problems occur on the server side, not "
8360 "the client side. The good news is that once you've gotten a configuration "
8361 "working, it will usually continue to work indefinitely."
8362 msgstr ""
8364 #. type: Content of: <book><chapter><sect1><sect2><para>
8365 #: ../en/ch06-collab.xml:738
8366 msgid ""
8367 "Before you try using Mercurial to talk to an ssh server, it's best to make "
8368 "sure that you can use the normal <command>ssh</command> or <command>putty</"
8369 "command> command to talk to the server first. If you run into problems with "
8370 "using these commands directly, Mercurial surely won't work. Worse, it will "
8371 "obscure the underlying problem. Any time you want to debug ssh-related "
8372 "Mercurial problems, you should drop back to making sure that plain ssh client "
8373 "commands work first, <emphasis>before</emphasis> you worry about whether "
8374 "there's a problem with Mercurial."
8375 msgstr ""
8377 #. type: Content of: <book><chapter><sect1><sect2><para>
8378 #: ../en/ch06-collab.xml:749
8379 msgid ""
8380 "The first thing to be sure of on the server side is that you can actually log "
8381 "in from another machine at all. If you can't use <command>ssh</command> or "
8382 "<command>putty</command> to log in, the error message you get may give you a "
8383 "few hints as to what's wrong. The most common problems are as follows."
8384 msgstr ""
8386 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8387 #: ../en/ch06-collab.xml:756
8388 msgid ""
8389 "If you get a <quote>connection refused</quote> error, either there isn't an "
8390 "SSH daemon running on the server at all, or it's inaccessible due to firewall "
8391 "configuration."
8392 msgstr ""
8394 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8395 #: ../en/ch06-collab.xml:761
8396 msgid ""
8397 "If you get a <quote>no route to host</quote> error, you either have an "
8398 "incorrect address for the server or a seriously locked down firewall that "
8399 "won't admit its existence at all."
8400 msgstr ""
8402 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8403 #: ../en/ch06-collab.xml:766
8404 msgid ""
8405 "If you get a <quote>permission denied</quote> error, you may have mistyped "
8406 "the username on the server, or you could have mistyped your key's passphrase "
8407 "or the remote user's password."
8408 msgstr ""
8410 #. type: Content of: <book><chapter><sect1><sect2><para>
8411 #: ../en/ch06-collab.xml:771
8412 msgid ""
8413 "In summary, if you're having trouble talking to the server's ssh daemon, "
8414 "first make sure that one is running at all. On many systems it will be "
8415 "installed, but disabled, by default. Once you're done with this step, you "
8416 "should then check that the server's firewall is configured to allow incoming "
8417 "connections on the port the ssh daemon is listening on (usually 22). Don't "
8418 "worry about more exotic possibilities for misconfiguration until you've "
8419 "checked these two first."
8420 msgstr ""
8422 #. type: Content of: <book><chapter><sect1><sect2><para>
8423 #: ../en/ch06-collab.xml:781
8424 msgid ""
8425 "If you're using an authentication agent on the client side to store "
8426 "passphrases for your keys, you ought to be able to log into the server "
8427 "without being prompted for a passphrase or a password. If you're prompted "
8428 "for a passphrase, there are a few possible culprits."
8429 msgstr ""
8431 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8432 #: ../en/ch06-collab.xml:787
8433 msgid ""
8434 "You might have forgotten to use <command>ssh-add</command> or "
8435 "<command>pageant</command> to store the passphrase."
8436 msgstr ""
8438 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8439 #: ../en/ch06-collab.xml:791
8440 msgid "You might have stored the passphrase for the wrong key."
8441 msgstr ""
8443 #. type: Content of: <book><chapter><sect1><sect2><para>
8444 #: ../en/ch06-collab.xml:794
8445 msgid ""
8446 "If you're being prompted for the remote user's password, there are another "
8447 "few possible problems to check."
8448 msgstr ""
8450 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8451 #: ../en/ch06-collab.xml:797
8452 msgid ""
8453 "Either the user's home directory or their <filename role=\"special\" class="
8454 "\"directory\">.ssh</filename> directory might have excessively liberal "
8455 "permissions. As a result, the ssh daemon will not trust or read their "
8456 "<filename role=\"special\">authorized_keys</filename> file. For example, a "
8457 "group-writable home or <filename role=\"special\" class=\"directory\">.ssh</"
8458 "filename> directory will often cause this symptom."
8459 msgstr ""
8461 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8462 #: ../en/ch06-collab.xml:806
8463 msgid ""
8464 "The user's <filename role=\"special\">authorized_keys</filename> file may "
8465 "have a problem. If anyone other than the user owns or can write to that file, "
8466 "the ssh daemon will not trust or read it."
8467 msgstr ""
8469 #. type: Content of: <book><chapter><sect1><sect2><para>
8470 #: ../en/ch06-collab.xml:813
8471 msgid ""
8472 "In the ideal world, you should be able to run the following command "
8473 "successfully, and it should print exactly one line of output, the current "
8474 "date and time."
8475 msgstr ""
8477 #. type: Content of: <book><chapter><sect1><sect2><para>
8478 #: ../en/ch06-collab.xml:818
8479 msgid ""
8480 "If, on your server, you have login scripts that print banners or other junk "
8481 "even when running non-interactive commands like this, you should fix them "
8482 "before you continue, so that they only print output if they're run "
8483 "interactively. Otherwise these banners will at least clutter up Mercurial's "
8484 "output. Worse, they could potentially cause problems with running Mercurial "
8485 "commands remotely. Mercurial tries to detect and ignore banners in non-"
8486 "interactive <command>ssh</command> sessions, but it is not foolproof. (If "
8487 "you're editing your login scripts on your server, the usual way to see if a "
8488 "login script is running in an interactive shell is to check the return code "
8489 "from the command <literal>tty -s</literal>.)"
8490 msgstr ""
8492 #. type: Content of: <book><chapter><sect1><sect2><para>
8493 #: ../en/ch06-collab.xml:832
8494 msgid ""
8495 "Once you've verified that plain old ssh is working with your server, the next "
8496 "step is to ensure that Mercurial runs on the server. The following command "
8497 "should run successfully:"
8498 msgstr ""
8500 #. type: Content of: <book><chapter><sect1><sect2><para>
8501 #: ../en/ch06-collab.xml:839
8502 msgid ""
8503 "If you see an error message instead of normal <command role=\"hg-cmd\">hg "
8504 "version</command> output, this is usually because you haven't installed "
8505 "Mercurial to <filename class=\"directory\">/usr/bin</filename>. Don't worry "
8506 "if this is the case; you don't need to do that. But you should check for a "
8507 "few possible problems."
8508 msgstr ""
8510 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8511 #: ../en/ch06-collab.xml:846
8512 msgid ""
8513 "Is Mercurial really installed on the server at all? I know this sounds "
8514 "trivial, but it's worth checking!"
8515 msgstr ""
8517 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8518 #: ../en/ch06-collab.xml:850
8519 msgid ""
8520 "Maybe your shell's search path (usually set via the <envar>PATH</envar> "
8521 "environment variable) is simply misconfigured."
8522 msgstr ""
8524 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8525 #: ../en/ch06-collab.xml:854
8526 msgid ""
8527 "Perhaps your <envar>PATH</envar> environment variable is only being set to "
8528 "point to the location of the <command>hg</command> executable if the login "
8529 "session is interactive. This can happen if you're setting the path in the "
8530 "wrong shell login script. See your shell's documentation for details."
8531 msgstr ""
8533 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
8534 #: ../en/ch06-collab.xml:861
8535 msgid ""
8536 "The <envar>PYTHONPATH</envar> environment variable may need to contain the "
8537 "path to the Mercurial Python modules. It might not be set at all; it could "
8538 "be incorrect; or it may be set only if the login is interactive."
8539 msgstr ""
8541 #. type: Content of: <book><chapter><sect1><sect2><para>
8542 #: ../en/ch06-collab.xml:868
8543 msgid ""
8544 "If you can run <command role=\"hg-cmd\">hg version</command> over an ssh "
8545 "connection, well done! You've got the server and client sorted out. You "
8546 "should now be able to use Mercurial to access repositories hosted by that "
8547 "username on that server. If you run into problems with Mercurial and ssh at "
8548 "this point, try using the <option role=\"hg-opt-global\">--debug</option> "
8549 "option to get a clearer picture of what's going on."
8550 msgstr ""
8552 #. type: Content of: <book><chapter><sect1><sect2><title>
8553 #: ../en/ch06-collab.xml:877
8554 msgid "Using compression with ssh"
8555 msgstr "通过 ssh 使用压缩"
8557 #. type: Content of: <book><chapter><sect1><sect2><para>
8558 #: ../en/ch06-collab.xml:879
8559 msgid ""
8560 "Mercurial does not compress data when it uses the ssh protocol, because the "
8561 "ssh protocol can transparently compress data. However, the default behavior "
8562 "of ssh clients is <emphasis>not</emphasis> to request compression."
8563 msgstr ""
8565 #. type: Content of: <book><chapter><sect1><sect2><para>
8566 #: ../en/ch06-collab.xml:884
8567 msgid ""
8568 "Over any network other than a fast LAN (even a wireless network), using "
8569 "compression is likely to significantly speed up Mercurial's network "
8570 "operations. For example, over a WAN, someone measured compression as "
8571 "reducing the amount of time required to clone a particularly large repository "
8572 "from 51 minutes to 17 minutes."
8573 msgstr ""
8575 #. type: Content of: <book><chapter><sect1><sect2><para>
8576 #: ../en/ch06-collab.xml:891
8577 msgid ""
8578 "Both <command>ssh</command> and <command>plink</command> accept a <option "
8579 "role=\"cmd-opt-ssh\">-C</option> option which turns on compression. You can "
8580 "easily edit your <filename role=\"special\">~/.hgrc</filename> to enable "
8581 "compression for all of Mercurial's uses of the ssh protocol. Here is how to "
8582 "do so for regular <command>ssh</command> on Unix-like systems, for example."
8583 msgstr ""
8585 #. type: Content of: <book><chapter><sect1><sect2><para>
8586 #: ../en/ch06-collab.xml:901
8587 msgid ""
8588 "If you use <command>ssh</command> on a Unix-like system, you can configure it "
8589 "to always use compression when talking to your server. To do this, edit your "
8590 "<filename role=\"special\">.ssh/config</filename> file (which may not yet "
8591 "exist), as follows."
8592 msgstr ""
8594 #. type: Content of: <book><chapter><sect1><sect2><para>
8595 #: ../en/ch06-collab.xml:911
8596 msgid ""
8597 "This defines a hostname alias, <literal>hg</literal>. When you use that "
8598 "hostname on the <command>ssh</command> command line or in a Mercurial "
8599 "<literal>ssh</literal>-protocol URL, it will cause <command>ssh</command> to "
8600 "connect to <literal>hg.example.com</literal> and use compression. This gives "
8601 "you both a shorter name to type and compression, each of which is a good "
8602 "thing in its own right."
8603 msgstr ""
8605 #. type: Content of: <book><chapter><sect1><title>
8606 #: ../en/ch06-collab.xml:923
8607 msgid "Serving over HTTP using CGI"
8608 msgstr "使用 CGI 通过 HTTP 提供服务"
8610 #. type: Content of: <book><chapter><sect1><para>
8611 #: ../en/ch06-collab.xml:925
8612 msgid ""
8613 "The simplest way to host one or more repositories in a permanent way is to "
8614 "use a web server and Mercurial's CGI support."
8615 msgstr ""
8617 #. type: Content of: <book><chapter><sect1><para>
8618 #: ../en/ch06-collab.xml:929
8619 msgid ""
8620 "Depending on how ambitious you are, configuring Mercurial's CGI interface can "
8621 "take anything from a few moments to several hours."
8622 msgstr ""
8624 #. type: Content of: <book><chapter><sect1><para>
8625 #: ../en/ch06-collab.xml:933
8626 msgid ""
8627 "We'll begin with the simplest of examples, and work our way towards a more "
8628 "complex configuration. Even for the most basic case, you're almost certainly "
8629 "going to need to read and modify your web server's configuration."
8630 msgstr ""
8632 #. type: Content of: <book><chapter><sect1><note><title>
8633 #: ../en/ch06-collab.xml:939
8634 msgid "High pain tolerance required"
8635 msgstr ""
8637 #. type: Content of: <book><chapter><sect1><note><para>
8638 #: ../en/ch06-collab.xml:941
8639 msgid ""
8640 "Configuring a web server is a complex, fiddly, and highly system-dependent "
8641 "activity. I can't possibly give you instructions that will cover anything "
8642 "like all of the cases you will encounter. Please use your discretion and "
8643 "judgment in following the sections below. Be prepared to make plenty of "
8644 "mistakes, and to spend a lot of time reading your server's error logs."
8645 msgstr ""
8647 #. type: Content of: <book><chapter><sect1><note><para>
8648 #: ../en/ch06-collab.xml:949
8649 msgid ""
8650 "If you don't have a strong stomach for tweaking configurations over and over, "
8651 "or a compelling need to host your own services, you might want to try one of "
8652 "the public hosting services that I mentioned earlier."
8653 msgstr ""
8655 #. type: Content of: <book><chapter><sect1><sect2><title>
8656 #: ../en/ch06-collab.xml:956
8657 msgid "Web server configuration checklist"
8658 msgstr "Web 服务器配置检查表"
8660 #. type: Content of: <book><chapter><sect1><sect2><para>
8661 #: ../en/ch06-collab.xml:958
8662 msgid ""
8663 "Before you continue, do take a few moments to check a few aspects of your "
8664 "system's setup."
8665 msgstr ""
8667 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
8668 #: ../en/ch06-collab.xml:962
8669 msgid ""
8670 "Do you have a web server installed at all? Mac OS X and some Linux "
8671 "distributions ship with Apache, but many other systems may not have a web "
8672 "server installed."
8673 msgstr ""
8675 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
8676 #: ../en/ch06-collab.xml:967
8677 msgid ""
8678 "If you have a web server installed, is it actually running? On most systems, "
8679 "even if one is present, it will be disabled by default."
8680 msgstr ""
8682 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
8683 #: ../en/ch06-collab.xml:971
8684 msgid ""
8685 "Is your server configured to allow you to run CGI programs in the directory "
8686 "where you plan to do so? Most servers default to explicitly disabling the "
8687 "ability to run CGI programs."
8688 msgstr ""
8690 #. type: Content of: <book><chapter><sect1><sect2><para>
8691 #: ../en/ch06-collab.xml:977
8692 msgid ""
8693 "If you don't have a web server installed, and don't have substantial "
8694 "experience configuring Apache, you should consider using the "
8695 "<literal>lighttpd</literal> web server instead of Apache. Apache has a well-"
8696 "deserved reputation for baroque and confusing configuration. While "
8697 "<literal>lighttpd</literal> is less capable in some ways than Apache, most of "
8698 "these capabilities are not relevant to serving Mercurial repositories. And "
8699 "<literal>lighttpd</literal> is undeniably <emphasis>much</emphasis> easier to "
8700 "get started with than Apache."
8701 msgstr ""
8703 #. type: Content of: <book><chapter><sect1><sect2><title>
8704 #: ../en/ch06-collab.xml:990
8705 msgid "Basic CGI configuration"
8706 msgstr "基本 CGI 配置"
8708 #. type: Content of: <book><chapter><sect1><sect2><para>
8709 #: ../en/ch06-collab.xml:992
8710 msgid ""
8711 "On Unix-like systems, it's common for users to have a subdirectory named "
8712 "something like <filename class=\"directory\">public_html</filename> in their "
8713 "home directory, from which they can serve up web pages. A file named "
8714 "<filename>foo</filename> in this directory will be accessible at a URL of the "
8715 "form <literal>http://www.example.com/username/foo</literal>."
8716 msgstr ""
8718 #. type: Content of: <book><chapter><sect1><sect2><para>
8719 #: ../en/ch06-collab.xml:1000
8720 msgid ""
8721 "To get started, find the <filename role=\"special\">hgweb.cgi</filename> "
8722 "script that should be present in your Mercurial installation. If you can't "
8723 "quickly find a local copy on your system, simply download one from the master "
8724 "Mercurial repository at <ulink url=\"http://www.selenic.com/repo/hg/raw-file/"
8725 "tip/hgweb.cgi\">http://www.selenic.com/repo/hg/raw-file/tip/hgweb.cgi</ulink>."
8726 msgstr ""
8728 #. type: Content of: <book><chapter><sect1><sect2><para>
8729 #: ../en/ch06-collab.xml:1007 ../en/ch06-collab.xml:1175
8730 msgid ""
8731 "You'll need to copy this script into your <filename class=\"directory"
8732 "\">public_html</filename> directory, and ensure that it's executable."
8733 msgstr ""
8735 #. type: Content of: <book><chapter><sect1><sect2><para>
8736 #: ../en/ch06-collab.xml:1012
8737 msgid ""
8738 "The <literal>755</literal> argument to <command>chmod</command> is a little "
8739 "more general than just making the script executable: it ensures that the "
8740 "script is executable by anyone, and that <quote>group</quote> and "
8741 "<quote>other</quote> write permissions are <emphasis>not</emphasis> set. If "
8742 "you were to leave those write permissions enabled, Apache's <literal>suexec</"
8743 "literal> subsystem would likely refuse to execute the script. In fact, "
8744 "<literal>suexec</literal> also insists that the <emphasis>directory</"
8745 "emphasis> in which the script resides must not be writable by others."
8746 msgstr ""
8748 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
8749 #: ../en/ch06-collab.xml:1026
8750 msgid "What could <emphasis>possibly</emphasis> go wrong?"
8751 msgstr "什么<emphasis>可能</emphasis>会出错?"
8753 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
8754 #: ../en/ch06-collab.xml:1029
8755 msgid ""
8756 "Once you've copied the CGI script into place, go into a web browser, and try "
8757 "to open the URL <literal>http://myhostname/~myuser/hgweb.cgi</literal>, "
8758 "<emphasis>but</emphasis> brace yourself for instant failure. There's a high "
8759 "probability that trying to visit this URL will fail, and there are many "
8760 "possible reasons for this. In fact, you're likely to stumble over almost "
8761 "every one of the possible errors below, so please read carefully. The "
8762 "following are all of the problems I ran into on a system running Fedora 7, "
8763 "with a fresh installation of Apache, and a user account that I created "
8764 "specially to perform this exercise."
8765 msgstr ""
8767 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
8768 #: ../en/ch06-collab.xml:1042
8769 msgid ""
8770 "Your web server may have per-user directories disabled. If you're using "
8771 "Apache, search your config file for a <literal>UserDir</literal> directive. "
8772 "If there's none present, per-user directories will be disabled. If one "
8773 "exists, but its value is <literal>disabled</literal>, then per-user "
8774 "directories will be disabled. Otherwise, the string after <literal>UserDir</"
8775 "literal> gives the name of the subdirectory that Apache will look in under "
8776 "your home directory, for example <filename class=\"directory\">public_html</"
8777 "filename>."
8778 msgstr ""
8780 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
8781 #: ../en/ch06-collab.xml:1053
8782 msgid ""
8783 "Your file access permissions may be too restrictive. The web server must be "
8784 "able to traverse your home directory and directories under your <filename "
8785 "class=\"directory\">public_html</filename> directory, and read files under "
8786 "the latter too. Here's a quick recipe to help you to make your permissions "
8787 "more appropriate."
8788 msgstr ""
8790 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
8791 #: ../en/ch06-collab.xml:1063
8792 msgid ""
8793 "The other possibility with permissions is that you might get a completely "
8794 "empty window when you try to load the script. In this case, it's likely that "
8795 "your access permissions are <emphasis>too permissive</emphasis>. Apache's "
8796 "<literal>suexec</literal> subsystem won't execute a script that's group- or "
8797 "world-writable, for example."
8798 msgstr ""
8800 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
8801 #: ../en/ch06-collab.xml:1070
8802 msgid ""
8803 "Your web server may be configured to disallow execution of CGI programs in "
8804 "your per-user web directory. Here's Apache's default per-user configuration "
8805 "from my Fedora system."
8806 msgstr ""
8808 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
8809 #: ../en/ch06-collab.xml:1077
8810 msgid ""
8811 "If you find a similar-looking <literal>Directory</literal> group in your "
8812 "Apache configuration, the directive to look at inside it is <literal>Options</"
8813 "literal>. Add <literal>ExecCGI</literal> to the end of this list if it's "
8814 "missing, and restart the web server."
8815 msgstr ""
8817 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
8818 #: ../en/ch06-collab.xml:1084
8819 msgid ""
8820 "If you find that Apache serves you the text of the CGI script instead of "
8821 "executing it, you may need to either uncomment (if already present) or add a "
8822 "directive like this."
8823 msgstr ""
8825 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
8826 #: ../en/ch06-collab.xml:1090
8827 msgid ""
8828 "The next possibility is that you might be served with a colourful Python "
8829 "backtrace claiming that it can't import a <literal>mercurial</literal>-"
8830 "related module. This is actually progress! The server is now capable of "
8831 "executing your CGI script. This error is only likely to occur if you're "
8832 "running a private installation of Mercurial, instead of a system-wide "
8833 "version. Remember that the web server runs the CGI program without any of "
8834 "the environment variables that you take for granted in an interactive "
8835 "session. If this error happens to you, edit your copy of <filename role="
8836 "\"special\">hgweb.cgi</filename> and follow the directions inside it to "
8837 "correctly set your <envar>PYTHONPATH</envar> environment variable."
8838 msgstr ""
8840 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
8841 #: ../en/ch06-collab.xml:1104
8842 msgid ""
8843 "Finally, you are <emphasis>certain</emphasis> to be served with another "
8844 "colourful Python backtrace: this one will complain that it can't find "
8845 "<filename class=\"directory\">/path/to/repository</filename>. Edit your "
8846 "<filename role=\"special\">hgweb.cgi</filename> script and replace the "
8847 "<filename class=\"directory\">/path/to/repository</filename> string with the "
8848 "complete path to the repository you want to serve up."
8849 msgstr ""
8851 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
8852 #: ../en/ch06-collab.xml:1114
8853 msgid ""
8854 "At this point, when you try to reload the page, you should be presented with "
8855 "a nice HTML view of your repository's history. Whew!"
8856 msgstr ""
8858 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
8859 #: ../en/ch06-collab.xml:1120
8860 msgid "Configuring lighttpd"
8861 msgstr "配置 lighttpd"
8863 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
8864 #: ../en/ch06-collab.xml:1122
8865 msgid ""
8866 "To be exhaustive in my experiments, I tried configuring the increasingly "
8867 "popular <literal>lighttpd</literal> web server to serve the same repository "
8868 "as I described with Apache above. I had already overcome all of the problems "
8869 "I outlined with Apache, many of which are not server-specific. As a result, "
8870 "I was fairly sure that my file and directory permissions were good, and that "
8871 "my <filename role=\"special\">hgweb.cgi</filename> script was properly edited."
8872 msgstr ""
8874 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
8875 #: ../en/ch06-collab.xml:1132
8876 msgid ""
8877 "Once I had Apache running, getting <literal>lighttpd</literal> to serve the "
8878 "repository was a snap (in other words, even if you're trying to use "
8879 "<literal>lighttpd</literal>, you should read the Apache section). I first "
8880 "had to edit the <literal>mod_access</literal> section of its config file to "
8881 "enable <literal>mod_cgi</literal> and <literal>mod_userdir</literal>, both of "
8882 "which were disabled by default on my system. I then added a few lines to the "
8883 "end of the config file, to configure these modules."
8884 msgstr ""
8886 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
8887 #: ../en/ch06-collab.xml:1144
8888 msgid ""
8889 "With this done, <literal>lighttpd</literal> ran immediately for me. If I had "
8890 "configured <literal>lighttpd</literal> before Apache, I'd almost certainly "
8891 "have run into many of the same system-level configuration problems as I did "
8892 "with Apache. However, I found <literal>lighttpd</literal> to be noticeably "
8893 "easier to configure than Apache, even though I've used Apache for over a "
8894 "decade, and this was my first exposure to <literal>lighttpd</literal>."
8895 msgstr ""
8897 #. type: Content of: <book><chapter><sect1><sect2><title>
8898 #: ../en/ch06-collab.xml:1157
8899 msgid "Sharing multiple repositories with one CGI script"
8900 msgstr "使用一个 CGI 脚本共享多个版本库"
8902 #. type: Content of: <book><chapter><sect1><sect2><para>
8903 #: ../en/ch06-collab.xml:1159
8904 msgid ""
8905 "The <filename role=\"special\">hgweb.cgi</filename> script only lets you "
8906 "publish a single repository, which is an annoying restriction. If you want "
8907 "to publish more than one without wracking yourself with multiple copies of "
8908 "the same script, each with different names, a better choice is to use the "
8909 "<filename role=\"special\">hgwebdir.cgi</filename> script."
8910 msgstr ""
8912 #. type: Content of: <book><chapter><sect1><sect2><para>
8913 #: ../en/ch06-collab.xml:1167
8914 msgid ""
8915 "The procedure to configure <filename role=\"special\">hgwebdir.cgi</filename> "
8916 "is only a little more involved than for <filename role=\"special\">hgweb.cgi</"
8917 "filename>. First, you must obtain a copy of the script. If you don't have "
8918 "one handy, you can download a copy from the master Mercurial repository at "
8919 "<ulink url=\"http://www.selenic.com/repo/hg/raw-file/tip/hgwebdir.cgi"
8920 "\">http://www.selenic.com/repo/hg/raw-file/tip/hgwebdir.cgi</ulink>."
8921 msgstr ""
8923 #. type: Content of: <book><chapter><sect1><sect2><para>
8924 #: ../en/ch06-collab.xml:1182
8925 msgid ""
8926 "With basic configuration out of the way, try to visit <literal>http://"
8927 "myhostname/~myuser/hgwebdir.cgi</literal> in your\tbrowser. It should "
8928 "display an empty list of repositories. If you get a blank window or error "
8929 "message, try walking through the list of potential problems in <xref linkend="
8930 "\"sec:collab:wtf\"/>."
8931 msgstr ""
8933 #. type: Content of: <book><chapter><sect1><sect2><para>
8934 #: ../en/ch06-collab.xml:1190
8935 msgid ""
8936 "The <filename role=\"special\">hgwebdir.cgi</filename> script relies on an "
8937 "external configuration file. By default, it searches for a file named "
8938 "<filename role=\"special\">hgweb.config</filename> in the same directory as "
8939 "itself. You'll need to create this file, and make it world-readable. The "
8940 "format of the file is similar to a Windows <quote>ini</quote> file, as "
8941 "understood by Python's <literal>ConfigParser</literal> <citation>web:"
8942 "configparser</citation> module."
8943 msgstr ""
8945 #. type: Content of: <book><chapter><sect1><sect2><para>
8946 #: ../en/ch06-collab.xml:1200
8947 msgid ""
8948 "The easiest way to configure <filename role=\"special\">hgwebdir.cgi</"
8949 "filename> is with a section named <literal>collections</literal>. This will "
8950 "automatically publish <emphasis>every</emphasis> repository under the "
8951 "directories you name. The section should look like this:"
8952 msgstr ""
8954 #. type: Content of: <book><chapter><sect1><sect2><para>
8955 #: ../en/ch06-collab.xml:1208
8956 msgid ""
8957 "Mercurial interprets this by looking at the directory name on the "
8958 "<emphasis>right</emphasis> hand side of the <quote><literal>=</literal></"
8959 "quote> sign; finding repositories in that directory hierarchy; and using the "
8960 "text on the <emphasis>left</emphasis> to strip off matching text from the "
8961 "names it will actually list in the web interface. The remaining component of "
8962 "a path after this stripping has occurred is called a <quote>virtual path</"
8963 "quote>."
8964 msgstr ""
8966 #. type: Content of: <book><chapter><sect1><sect2><para>
8967 #: ../en/ch06-collab.xml:1217
8968 msgid ""
8969 "Given the example above, if we have a repository whose local path is "
8970 "<filename class=\"directory\">/my/root/this/repo</filename>, the CGI script "
8971 "will strip the leading <filename class=\"directory\">/my/root</filename> from "
8972 "the name, and publish the repository with a virtual path of <filename class="
8973 "\"directory\">this/repo</filename>. If the base URL for our CGI script is "
8974 "<literal>http://myhostname/~myuser/hgwebdir.cgi</literal>, the complete URL "
8975 "for that repository will be <literal>http://myhostname/~myuser/hgwebdir.cgi/"
8976 "this/repo</literal>."
8977 msgstr ""
8979 #. type: Content of: <book><chapter><sect1><sect2><para>
8980 #: ../en/ch06-collab.xml:1229
8981 msgid ""
8982 "If we replace <filename class=\"directory\">/my/root</filename> on the left "
8983 "hand side of this example with <filename class=\"directory\">/my</filename>, "
8984 "then <filename role=\"special\">hgwebdir.cgi</filename> will only strip off "
8985 "<filename class=\"directory\">/my</filename> from the repository name, and "
8986 "will give us a virtual path of <filename class=\"directory\">root/this/repo</"
8987 "filename> instead of <filename class=\"directory\">this/repo</filename>."
8988 msgstr ""
8990 #. type: Content of: <book><chapter><sect1><sect2><para>
8991 #: ../en/ch06-collab.xml:1239
8992 msgid ""
8993 "The <filename role=\"special\">hgwebdir.cgi</filename> script will "
8994 "recursively search each directory listed in the <literal>collections</"
8995 "literal> section of its configuration file, but it will <literal>not</"
8996 "literal> recurse into the repositories it finds."
8997 msgstr ""
8999 #. type: Content of: <book><chapter><sect1><sect2><para>
9000 #: ../en/ch06-collab.xml:1245
9001 msgid ""
9002 "The <literal>collections</literal> mechanism makes it easy to publish many "
9003 "repositories in a <quote>fire and forget</quote> manner. You only need to "
9004 "set up the CGI script and configuration file one time. Afterwards, you can "
9005 "publish or unpublish a repository at any time by simply moving it into, or "
9006 "out of, the directory hierarchy in which you've configured <filename role="
9007 "\"special\">hgwebdir.cgi</filename> to look."
9008 msgstr ""
9010 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
9011 #: ../en/ch06-collab.xml:1255
9012 msgid "Explicitly specifying which repositories to publish"
9013 msgstr "明确指出要发布的版本库"
9015 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9016 #: ../en/ch06-collab.xml:1258
9017 msgid ""
9018 "In addition to the <literal>collections</literal> mechanism, the <filename "
9019 "role=\"special\">hgwebdir.cgi</filename> script allows you to publish a "
9020 "specific list of repositories. To do so, create a <literal>paths</literal> "
9021 "section, with contents of the following form."
9022 msgstr ""
9024 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9025 #: ../en/ch06-collab.xml:1267
9026 msgid ""
9027 "In this case, the virtual path (the component that will appear in a URL) is "
9028 "on the left hand side of each definition, while the path to the repository is "
9029 "on the right. Notice that there does not need to be any relationship between "
9030 "the virtual path you choose and the location of a repository in your "
9031 "filesystem."
9032 msgstr ""
9034 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9035 #: ../en/ch06-collab.xml:1274
9036 msgid ""
9037 "If you wish, you can use both the <literal>collections</literal> and "
9038 "<literal>paths</literal> mechanisms simultaneously in a single configuration "
9039 "file."
9040 msgstr ""
9042 #. type: Content of: <book><chapter><sect1><sect2><sect3><note><title>
9043 #: ../en/ch06-collab.xml:1280
9044 msgid "Beware duplicate virtual paths"
9045 msgstr ""
9047 #. type: Content of: <book><chapter><sect1><sect2><sect3><note><para>
9048 #: ../en/ch06-collab.xml:1282
9049 msgid ""
9050 "If several repositories have the same virtual path, <filename role=\"special"
9051 "\">hgwebdir.cgi</filename> will not report an error. Instead, it will behave "
9052 "unpredictably."
9053 msgstr ""
9055 #. type: Content of: <book><chapter><sect1><sect2><title>
9056 #: ../en/ch06-collab.xml:1291
9057 msgid "Downloading source archives"
9058 msgstr "下载源代码档案包"
9060 #. type: Content of: <book><chapter><sect1><sect2><para>
9061 #: ../en/ch06-collab.xml:1293
9062 msgid ""
9063 "Mercurial's web interface lets users download an archive of any revision. "
9064 "This archive will contain a snapshot of the working directory as of that "
9065 "revision, but it will not contain a copy of the repository data."
9066 msgstr ""
9068 #. type: Content of: <book><chapter><sect1><sect2><para>
9069 #: ../en/ch06-collab.xml:1298
9070 msgid ""
9071 "By default, this feature is not enabled. To enable it, you'll need to add an "
9072 "<envar role=\"rc-item-web\">allow_archive</envar> item to the <literal role="
9073 "\"rc-web\">web</literal> section of your <filename role=\"special\">~/.hgrc</"
9074 "filename>; see below for details."
9075 msgstr ""
9077 #. type: Content of: <book><chapter><sect1><sect2><title>
9078 #: ../en/ch06-collab.xml:1305
9079 msgid "Web configuration options"
9080 msgstr "Web 配置选项"
9082 #. type: Content of: <book><chapter><sect1><sect2><para>
9083 #: ../en/ch06-collab.xml:1307
9084 msgid ""
9085 "Mercurial's web interfaces (the <command role=\"hg-cmd\">hg serve</command> "
9086 "command, and the <filename role=\"special\">hgweb.cgi</filename> and "
9087 "<filename role=\"special\">hgwebdir.cgi</filename> scripts) have a number of "
9088 "configuration options that you can set. These belong in a section named "
9089 "<literal role=\"rc-web\">web</literal>."
9090 msgstr ""
9092 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9093 #: ../en/ch06-collab.xml:1315
9094 msgid ""
9095 "<envar role=\"rc-item-web\">allow_archive</envar>: Determines which (if any) "
9096 "archive download mechanisms Mercurial supports. If you enable this feature, "
9097 "users of the web interface will be able to download an archive of whatever "
9098 "revision of a repository they are viewing. To enable the archive feature, "
9099 "this item must take the form of a sequence of words drawn from the list below."
9100 msgstr ""
9102 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
9103 #: ../en/ch06-collab.xml:1324
9104 msgid ""
9105 "<literal>bz2</literal>: A <command>tar</command> archive, compressed using "
9106 "<literal>bzip2</literal> compression. This has the best compression ratio, "
9107 "but uses the most CPU time on the server."
9108 msgstr ""
9110 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
9111 #: ../en/ch06-collab.xml:1330
9112 msgid ""
9113 "<literal>gz</literal>: A <command>tar</command> archive, compressed using "
9114 "<literal>gzip</literal> compression."
9115 msgstr ""
9117 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
9118 #: ../en/ch06-collab.xml:1334
9119 msgid ""
9120 "<literal>zip</literal>: A <command>zip</command> archive, compressed using "
9121 "LZW compression. This format has the worst compression ratio, but is widely "
9122 "used in the Windows world."
9123 msgstr ""
9125 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9126 #: ../en/ch06-collab.xml:1340
9127 msgid ""
9128 "If you provide an empty list, or don't have an <envar role=\"rc-item-web"
9129 "\">allow_archive</envar> entry at all, this feature will be disabled. Here "
9130 "is an example of how to enable all three supported formats."
9131 msgstr ""
9133 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9134 #: ../en/ch06-collab.xml:1347
9135 msgid ""
9136 "<envar role=\"rc-item-web\">allowpull</envar>: Boolean. Determines whether "
9137 "the web interface allows remote users to <command role=\"hg-cmd\">hg pull</"
9138 "command> and <command role=\"hg-cmd\">hg clone</command> this repository over "
9139 "HTTP. If set to <literal>no</literal> or <literal>false</literal>, only the "
9140 "<quote>human-oriented</quote> portion of the web interface is available."
9141 msgstr ""
9143 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9144 #: ../en/ch06-collab.xml:1356
9145 msgid ""
9146 "<envar role=\"rc-item-web\">contact</envar>: String. A free-form (but "
9147 "preferably brief) string identifying the person or group in charge of the "
9148 "repository. This often contains the name and email address of a person or "
9149 "mailing list. It often makes sense to place this entry in a repository's own "
9150 "<filename role=\"special\">.hg/hgrc</filename> file, but it can make sense to "
9151 "use in a global <filename role=\"special\">~/.hgrc</filename> if every "
9152 "repository has a single maintainer."
9153 msgstr ""
9155 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9156 #: ../en/ch06-collab.xml:1367
9157 msgid ""
9158 "<envar role=\"rc-item-web\">maxchanges</envar>: Integer. The default maximum "
9159 "number of changesets to display in a single page of output."
9160 msgstr ""
9162 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9163 #: ../en/ch06-collab.xml:1371
9164 msgid ""
9165 "<envar role=\"rc-item-web\">maxfiles</envar>: Integer. The default maximum "
9166 "number of modified files to display in a single page of output."
9167 msgstr ""
9169 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9170 #: ../en/ch06-collab.xml:1375
9171 msgid ""
9172 "<envar role=\"rc-item-web\">stripes</envar>: Integer. If the web interface "
9173 "displays alternating <quote>stripes</quote> to make it easier to visually "
9174 "align rows when you are looking at a table, this number controls the number "
9175 "of rows in each stripe."
9176 msgstr ""
9178 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9179 #: ../en/ch06-collab.xml:1381
9180 msgid ""
9181 "<envar role=\"rc-item-web\">style</envar>: Controls the template Mercurial "
9182 "uses to display the web interface. Mercurial ships with several web "
9183 "templates."
9184 msgstr ""
9186 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
9187 #: ../en/ch06-collab.xml:1387
9188 msgid "<literal>coal</literal> is monochromatic."
9189 msgstr ""
9191 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
9192 #: ../en/ch06-collab.xml:1390
9193 msgid ""
9194 "<literal>gitweb</literal> emulates the visual style of git's web interface."
9195 msgstr ""
9197 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
9198 #: ../en/ch06-collab.xml:1394
9199 msgid "<literal>monoblue</literal> uses solid blues and greys."
9200 msgstr ""
9202 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
9203 #: ../en/ch06-collab.xml:1398
9204 msgid "<literal>paper</literal> is the default."
9205 msgstr ""
9207 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
9208 #: ../en/ch06-collab.xml:1401
9209 msgid "<literal>spartan</literal> was the default for a long time."
9210 msgstr ""
9212 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9213 #: ../en/ch06-collab.xml:1405
9214 msgid ""
9215 "You can also specify a custom template of your own; see <xref linkend=\"chap:"
9216 "template\"/> for details. Here, you can see how to enable the "
9217 "<literal>gitweb</literal> style."
9218 msgstr ""
9220 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9221 #: ../en/ch06-collab.xml:1413
9222 msgid ""
9223 "<envar role=\"rc-item-web\">templates</envar>: Path. The directory in which "
9224 "to search for template files. By default, Mercurial searches in the "
9225 "directory in which it was installed."
9226 msgstr ""
9228 #. type: Content of: <book><chapter><sect1><sect2><para>
9229 #: ../en/ch06-collab.xml:1418
9230 msgid ""
9231 "If you are using <filename role=\"special\">hgwebdir.cgi</filename>, you can "
9232 "place a few configuration items in a <literal role=\"rc-web\">web</literal> "
9233 "section of the <filename role=\"special\">hgweb.config</filename> file "
9234 "instead of a <filename role=\"special\">~/.hgrc</filename> file, for "
9235 "convenience. These items are <envar role=\"rc-item-web\">motd</envar> and "
9236 "<envar role=\"rc-item-web\">style</envar>."
9237 msgstr ""
9239 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
9240 #: ../en/ch06-collab.xml:1429
9241 msgid "Options specific to an individual repository"
9242 msgstr "针对单个版本库的选项"
9244 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9245 #: ../en/ch06-collab.xml:1431
9246 msgid ""
9247 "A few <literal role=\"rc-web\">web</literal> configuration items ought to be "
9248 "placed in a repository's local <filename role=\"special\">.hg/hgrc</"
9249 "filename>, rather than a user's or global <filename role=\"special\">~/.hgrc</"
9250 "filename>."
9251 msgstr ""
9253 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
9254 #: ../en/ch06-collab.xml:1436
9255 msgid ""
9256 "<envar role=\"rc-item-web\">description</envar>: String. A free-form (but "
9257 "preferably brief) string that describes the contents or purpose of the "
9258 "repository."
9259 msgstr ""
9261 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
9262 #: ../en/ch06-collab.xml:1441
9263 msgid ""
9264 "<envar role=\"rc-item-web\">name</envar>: String. The name to use for the "
9265 "repository in the web interface. This overrides the default name, which is "
9266 "the last component of the repository's path."
9267 msgstr ""
9269 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
9270 #: ../en/ch06-collab.xml:1449
9271 msgid ""
9272 "Options specific to the <command role=\"hg-cmd\">hg serve</command> command"
9273 msgstr "命令 <command role=\"hg-cmd\">hg serve</command> 的选项"
9275 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9276 #: ../en/ch06-collab.xml:1452
9277 msgid ""
9278 "Some of the items in the <literal role=\"rc-web\">web</literal> section of a "
9279 "<filename role=\"special\">~/.hgrc</filename> file are only for use with the "
9280 "<command role=\"hg-cmd\">hg serve</command> command."
9281 msgstr ""
9283 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
9284 #: ../en/ch06-collab.xml:1458
9285 msgid ""
9286 "<envar role=\"rc-item-web\">accesslog</envar>: Path. The name of a file into "
9287 "which to write an access log. By default, the <command role=\"hg-cmd\">hg "
9288 "serve</command> command writes this information to standard output, not to a "
9289 "file. Log entries are written in the standard <quote>combined</quote> file "
9290 "format used by almost all web servers."
9291 msgstr ""
9293 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
9294 #: ../en/ch06-collab.xml:1466
9295 msgid ""
9296 "<envar role=\"rc-item-web\">address</envar>: String. The local address on "
9297 "which the server should listen for incoming connections. By default, the "
9298 "server listens on all addresses."
9299 msgstr ""
9301 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
9302 #: ../en/ch06-collab.xml:1471
9303 msgid ""
9304 "<envar role=\"rc-item-web\">errorlog</envar>: Path. The name of a file into "
9305 "which to write an error log. By default, the <command role=\"hg-cmd\">hg "
9306 "serve</command> command writes this information to standard error, not to a "
9307 "file."
9308 msgstr ""
9310 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
9311 #: ../en/ch06-collab.xml:1477
9312 msgid ""
9313 "<envar role=\"rc-item-web\">ipv6</envar>: Boolean. Whether to use the IPv6 "
9314 "protocol. By default, IPv6 is not used."
9315 msgstr ""
9317 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
9318 #: ../en/ch06-collab.xml:1481
9319 msgid ""
9320 "<envar role=\"rc-item-web\">port</envar>: Integer. The TCP port number on "
9321 "which the server should listen. The default port number used is 8000."
9322 msgstr ""
9324 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
9325 #: ../en/ch06-collab.xml:1488
9326 msgid ""
9327 "Choosing the right <filename role=\"special\">~/.hgrc</filename> file to add "
9328 "<literal role=\"rc-web\">web</literal> items to"
9329 msgstr ""
9330 "选择正确的 <filename role=\"special\"> ~/.hgrc</filename> 文件增加到 <literal "
9331 "role=\"rc-web\">web</literal> 条目"
9333 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9334 #: ../en/ch06-collab.xml:1492
9335 msgid ""
9336 "It is important to remember that a web server like Apache or "
9337 "<literal>lighttpd</literal> will run under a user ID that is different to "
9338 "yours. CGI scripts run by your server, such as <filename role=\"special"
9339 "\">hgweb.cgi</filename>, will usually also run under that user ID."
9340 msgstr ""
9342 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9343 #: ../en/ch06-collab.xml:1499
9344 msgid ""
9345 "If you add <literal role=\"rc-web\">web</literal> items to your own personal "
9346 "<filename role=\"special\">~/.hgrc</filename> file, CGI scripts won't read "
9347 "that <filename role=\"special\">~/.hgrc</filename> file. Those settings will "
9348 "thus only affect the behavior of the <command role=\"hg-cmd\">hg serve</"
9349 "command> command when you run it. To cause CGI scripts to see your settings, "
9350 "either create a <filename role=\"special\">~/.hgrc</filename> file in the "
9351 "home directory of the user ID that runs your web server, or add those "
9352 "settings to a system-wide <filename role=\"special\">hgrc</filename> file."
9353 msgstr ""
9355 #. type: Content of: <book><chapter><sect1><title>
9356 #: ../en/ch06-collab.xml:1514
9357 msgid "System-wide configuration"
9358 msgstr "全局配置"
9360 #. type: Content of: <book><chapter><sect1><para>
9361 #: ../en/ch06-collab.xml:1516
9362 msgid ""
9363 "On Unix-like systems shared by multiple users (such as a server to which "
9364 "people publish changes), it often makes sense to set up some global default "
9365 "behaviors, such as what theme to use in web interfaces."
9366 msgstr ""
9368 #. type: Content of: <book><chapter><sect1><para>
9369 #: ../en/ch06-collab.xml:1521
9370 msgid ""
9371 "If a file named <filename>/etc/mercurial/hgrc</filename> exists, Mercurial "
9372 "will read it at startup time and apply any configuration settings it finds in "
9373 "that file. It will also look for files ending in a <literal>.rc</literal> "
9374 "extension in a directory named <filename>/etc/mercurial/hgrc.d</filename>, "
9375 "and apply any configuration settings it finds in each of those files."
9376 msgstr ""
9378 #. type: Content of: <book><chapter><sect1><sect2><title>
9379 #: ../en/ch06-collab.xml:1530
9380 msgid "Making Mercurial more trusting"
9381 msgstr "让 Mercurial 更可信"
9383 #. type: Content of: <book><chapter><sect1><sect2><para>
9384 #: ../en/ch06-collab.xml:1532
9385 msgid ""
9386 "One situation in which a global <filename>hgrc</filename> can be useful is if "
9387 "users are pulling changes owned by other users. By default, Mercurial will "
9388 "not trust most of the configuration items in a <filename>.hg/hgrc</filename> "
9389 "file inside a repository that is owned by a different user. If we clone or "
9390 "pull changes from such a repository, Mercurial will print a warning stating "
9391 "that it does not trust their <filename>.hg/hgrc</filename>."
9392 msgstr ""
9394 #. type: Content of: <book><chapter><sect1><sect2><para>
9395 #: ../en/ch06-collab.xml:1541
9396 msgid ""
9397 "If everyone in a particular Unix group is on the same team and "
9398 "<emphasis>should</emphasis> trust each other's configuration settings, or we "
9399 "want to trust particular users, we can override Mercurial's skeptical "
9400 "defaults by creating a system-wide <filename>hgrc</filename> file such as the "
9401 "following:"
9402 msgstr ""
9404 #. type: Content of: <book><chapter><title>
9405 #: ../en/ch07-filenames.xml:5
9406 msgid "File names and pattern matching"
9407 msgstr "文件名称与模式匹配"
9409 #. type: Content of: <book><chapter><para>
9410 #: ../en/ch07-filenames.xml:7
9411 msgid ""
9412 "Mercurial provides mechanisms that let you work with file names in a "
9413 "consistent and expressive way."
9414 msgstr ""
9416 #. type: Content of: <book><chapter><sect1><title>
9417 #: ../en/ch07-filenames.xml:11
9418 msgid "Simple file naming"
9419 msgstr "简单文件名称"
9421 #. type: Content of: <book><chapter><sect1><para>
9422 #: ../en/ch07-filenames.xml:13
9423 msgid ""
9424 "Mercurial uses a unified piece of machinery <quote>under the hood</quote> to "
9425 "handle file names. Every command behaves uniformly with respect to file "
9426 "names. The way in which commands work with file names is as follows."
9427 msgstr ""
9429 #. type: Content of: <book><chapter><sect1><para>
9430 #: ../en/ch07-filenames.xml:18
9431 msgid ""
9432 "If you explicitly name real files on the command line, Mercurial works with "
9433 "exactly those files, as you would expect. &interaction.filenames.files;"
9434 msgstr ""
9437 #. type: Content of: <book><chapter><sect1><para>
9438 #: ../en/ch07-filenames.xml:22
9439 msgid ""
9440 "When you provide a directory name, Mercurial will interpret this as "
9441 "<quote>operate on every file in this directory and its subdirectories</"
9442 "quote>. Mercurial traverses the files and subdirectories in a directory in "
9443 "alphabetical order. When it encounters a subdirectory, it will traverse that "
9444 "subdirectory before continuing with the current directory."
9445 msgstr ""
9447 #. type: Content of: <book><chapter><sect1><title>
9448 #: ../en/ch07-filenames.xml:33
9449 msgid "Running commands without any file names"
9450 msgstr "不提供文件名称的执行命令"
9452 #. type: Content of: <book><chapter><sect1><para>
9453 #: ../en/ch07-filenames.xml:35
9454 msgid ""
9455 "Mercurial's commands that work with file names have useful default behaviors "
9456 "when you invoke them without providing any file names or patterns. What kind "
9457 "of behavior you should expect depends on what the command does. Here are a "
9458 "few rules of thumb you can use to predict what a command is likely to do if "
9459 "you don't give it any names to work with."
9460 msgstr ""
9462 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
9463 #: ../en/ch07-filenames.xml:42
9464 msgid ""
9465 "Most commands will operate on the entire working directory. This is what the "
9466 "<command role=\"hg-cmd\">hg add</command> command does, for example."
9467 msgstr ""
9469 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
9470 #: ../en/ch07-filenames.xml:46
9471 msgid ""
9472 "If the command has effects that are difficult or impossible to reverse, it "
9473 "will force you to explicitly provide at least one name or pattern (see "
9474 "below). This protects you from accidentally deleting files by running "
9475 "<command role=\"hg-cmd\">hg remove</command> with no arguments, for example."
9476 msgstr ""
9478 #. type: Content of: <book><chapter><sect1><para>
9479 #: ../en/ch07-filenames.xml:54
9480 msgid ""
9481 "It's easy to work around these default behaviors if they don't suit you. If "
9482 "a command normally operates on the whole working directory, you can invoke it "
9483 "on just the current directory and its subdirectories by giving it the name "
9484 "<quote><filename class=\"directory\">.</filename></quote>."
9485 msgstr ""
9488 #. type: Content of: <book><chapter><sect1><para>
9489 #: ../en/ch07-filenames.xml:62
9490 msgid ""
9491 "Along the same lines, some commands normally print file names relative to the "
9492 "root of the repository, even if you're invoking them from a subdirectory. "
9493 "Such a command will print file names relative to your subdirectory if you "
9494 "give it explicit names. Here, we're going to run <command role=\"hg-cmd\">hg "
9495 "status</command> from a subdirectory, and get it to operate on the entire "
9496 "working directory while printing file names relative to our subdirectory, by "
9497 "passing it the output of the <command role=\"hg-cmd\">hg root</command> "
9498 "command."
9499 msgstr ""
9501 #. type: Content of: <book><chapter><sect1><title>
9502 #: ../en/ch07-filenames.xml:76
9503 msgid "Telling you what's going on"
9504 msgstr "告诉你正在做什么"
9506 #. type: Content of: <book><chapter><sect1><para>
9507 #: ../en/ch07-filenames.xml:78
9508 msgid ""
9509 "The <command role=\"hg-cmd\">hg add</command> example in the preceding "
9510 "section illustrates something else that's helpful about Mercurial commands. "
9511 "If a command operates on a file that you didn't name explicitly on the "
9512 "command line, it will usually print the name of the file, so that you will "
9513 "not be surprised what's going on."
9514 msgstr ""
9516 #. type: Content of: <book><chapter><sect1><para>
9517 #: ../en/ch07-filenames.xml:85
9518 msgid ""
9519 "The principle here is of <emphasis>least surprise</emphasis>. If you've "
9520 "exactly named a file on the command line, there's no point in repeating it "
9521 "back at you. If Mercurial is acting on a file <emphasis>implicitly</"
9522 "emphasis>, e.g. because you provided no names, or a directory, or a pattern "
9523 "(see below), it is safest to tell you what files it's operating on."
9524 msgstr ""
9526 #. type: Content of: <book><chapter><sect1><para>
9527 #: ../en/ch07-filenames.xml:92
9528 msgid ""
9529 "For commands that behave this way, you can silence them using the <option "
9530 "role=\"hg-opt-global\">-q</option> option. You can also get them to print "
9531 "the name of every file, even those you've named explicitly, using the <option "
9532 "role=\"hg-opt-global\">-v</option> option."
9533 msgstr ""
9535 #. type: Content of: <book><chapter><sect1><title>
9536 #: ../en/ch07-filenames.xml:100
9537 msgid "Using patterns to identify files"
9538 msgstr "使用模式标识文件"
9540 #. type: Content of: <book><chapter><sect1><para>
9541 #: ../en/ch07-filenames.xml:102
9542 msgid ""
9543 "In addition to working with file and directory names, Mercurial lets you use "
9544 "<emphasis>patterns</emphasis> to identify files. Mercurial's pattern "
9545 "handling is expressive."
9546 msgstr ""
9548 #. type: Content of: <book><chapter><sect1><para>
9549 #: ../en/ch07-filenames.xml:106
9550 msgid ""
9551 "On Unix-like systems (Linux, MacOS, etc.), the job of matching file names to "
9552 "patterns normally falls to the shell. On these systems, you must explicitly "
9553 "tell Mercurial that a name is a pattern. On Windows, the shell does not "
9554 "expand patterns, so Mercurial will automatically identify names that are "
9555 "patterns, and expand them for you."
9556 msgstr ""
9558 #. type: Content of: <book><chapter><sect1><para>
9559 #: ../en/ch07-filenames.xml:113
9560 msgid ""
9561 "To provide a pattern in place of a regular name on the command line, the "
9562 "mechanism is simple:"
9563 msgstr ""
9565 #. type: Content of: <book><chapter><sect1><para>
9566 #: ../en/ch07-filenames.xml:116
9567 msgid ""
9568 "That is, a pattern is identified by a short text string that says what kind "
9569 "of pattern this is, followed by a colon, followed by the actual pattern."
9570 msgstr ""
9572 #. type: Content of: <book><chapter><sect1><para>
9573 #: ../en/ch07-filenames.xml:120
9574 msgid ""
9575 "Mercurial supports two kinds of pattern syntax. The most frequently used is "
9576 "called <literal>glob</literal>; this is the same kind of pattern matching "
9577 "used by the Unix shell, and should be familiar to Windows command prompt "
9578 "users, too."
9579 msgstr ""
9581 #. type: Content of: <book><chapter><sect1><para>
9582 #: ../en/ch07-filenames.xml:125
9583 msgid ""
9584 "When Mercurial does automatic pattern matching on Windows, it uses "
9585 "<literal>glob</literal> syntax. You can thus omit the <quote><literal>glob:</"
9586 "literal></quote> prefix on Windows, but it's safe to use it, too."
9587 msgstr ""
9589 #. type: Content of: <book><chapter><sect1><para>
9590 #: ../en/ch07-filenames.xml:130
9591 msgid ""
9592 "The <literal>re</literal> syntax is more powerful; it lets you specify "
9593 "patterns using regular expressions, also known as regexps."
9594 msgstr ""
9596 #. type: Content of: <book><chapter><sect1><para>
9597 #: ../en/ch07-filenames.xml:134
9598 msgid ""
9599 "By the way, in the examples that follow, notice that I'm careful to wrap all "
9600 "of my patterns in quote characters, so that they won't get expanded by the "
9601 "shell before Mercurial sees them."
9602 msgstr ""
9604 #. type: Content of: <book><chapter><sect1><sect2><title>
9605 #: ../en/ch07-filenames.xml:140
9606 msgid "Shell-style <literal>glob</literal> patterns"
9607 msgstr "外壳风格的 <literal>glob</literal> 模式"
9609 #. type: Content of: <book><chapter><sect1><sect2><para>
9610 #: ../en/ch07-filenames.xml:142
9611 msgid ""
9612 "This is an overview of the kinds of patterns you can use when you're matching "
9613 "on glob patterns."
9614 msgstr ""
9617 #. type: Content of: <book><chapter><sect1><sect2><para>
9618 #: ../en/ch07-filenames.xml:145
9619 msgid ""
9620 "The <quote><literal>*</literal></quote> character matches any string, within "
9621 "a single directory."
9622 msgstr ""
9625 #. type: Content of: <book><chapter><sect1><sect2><para>
9626 #: ../en/ch07-filenames.xml:150
9627 msgid ""
9628 "The <quote><literal>**</literal></quote> pattern matches any string, and "
9629 "crosses directory boundaries. It's not a standard Unix glob token, but it's "
9630 "accepted by several popular Unix shells, and is very useful."
9631 msgstr ""
9634 #. type: Content of: <book><chapter><sect1><sect2><para>
9635 #: ../en/ch07-filenames.xml:157
9636 msgid ""
9637 "The <quote><literal>?</literal></quote> pattern matches any single character."
9638 msgstr ""
9640 #. type: Content of: <book><chapter><sect1><sect2><para>
9641 #: ../en/ch07-filenames.xml:162
9642 msgid ""
9643 "The <quote><literal>[</literal></quote> character begins a "
9644 "<emphasis>character class</emphasis>. This matches any single character "
9645 "within the class. The class ends with a <quote><literal>]</literal></quote> "
9646 "character. A class may contain multiple <emphasis>range</emphasis>s of the "
9647 "form <quote><literal>a-f</literal></quote>, which is shorthand for "
9648 "<quote><literal>abcdef</literal></quote>."
9649 msgstr ""
9651 #. type: Content of: <book><chapter><sect1><sect2><para>
9652 #: ../en/ch07-filenames.xml:172
9653 msgid ""
9654 "If the first character after the <quote><literal>[</literal></quote> in a "
9655 "character class is a <quote><literal>!</literal></quote>, it "
9656 "<emphasis>negates</emphasis> the class, making it match any single character "
9657 "not in the class."
9658 msgstr ""
9660 #. type: Content of: <book><chapter><sect1><sect2><para>
9661 #: ../en/ch07-filenames.xml:178
9662 msgid ""
9663 "A <quote><literal>{</literal></quote> begins a group of subpatterns, where "
9664 "the whole group matches if any subpattern in the group matches. The "
9665 "<quote><literal>,</literal></quote> character separates subpatterns, and "
9666 "<quote><literal>}</literal></quote> ends the group."
9667 msgstr ""
9669 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
9670 #: ../en/ch07-filenames.xml:187
9671 msgid "Watch out!"
9672 msgstr "千万小心!"
9675 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9676 #: ../en/ch07-filenames.xml:189
9677 msgid ""
9678 "Don't forget that if you want to match a pattern in any directory, you should "
9679 "not be using the <quote><literal>*</literal></quote> match-any token, as this "
9680 "will only match within one directory. Instead, use the <quote><literal>**</"
9681 "literal></quote> token. This small example illustrates the difference "
9682 "between the two."
9683 msgstr ""
9685 #. type: Content of: <book><chapter><sect1><sect2><title>
9686 #: ../en/ch07-filenames.xml:201
9687 msgid "Regular expression matching with <literal>re</literal> patterns"
9688 msgstr "使用 <literal>re</literal> 模式的正则表达式匹配"
9690 #. type: Content of: <book><chapter><sect1><sect2><para>
9691 #: ../en/ch07-filenames.xml:204
9692 msgid ""
9693 "Mercurial accepts the same regular expression syntax as the Python "
9694 "programming language (it uses Python's regexp engine internally). This is "
9695 "based on the Perl language's regexp syntax, which is the most popular dialect "
9696 "in use (it's also used in Java, for example)."
9697 msgstr ""
9699 #. type: Content of: <book><chapter><sect1><sect2><para>
9700 #: ../en/ch07-filenames.xml:210
9701 msgid ""
9702 "I won't discuss Mercurial's regexp dialect in any detail here, as regexps are "
9703 "not often used. Perl-style regexps are in any case already exhaustively "
9704 "documented on a multitude of web sites, and in many books. Instead, I will "
9705 "focus here on a few things you should know if you find yourself needing to "
9706 "use regexps with Mercurial."
9707 msgstr ""
9709 #. type: Content of: <book><chapter><sect1><sect2><para>
9710 #: ../en/ch07-filenames.xml:217
9711 msgid ""
9712 "A regexp is matched against an entire file name, relative to the root of the "
9713 "repository. In other words, even if you're already in subbdirectory "
9714 "<filename class=\"directory\">foo</filename>, if you want to match files "
9715 "under this directory, your pattern must start with <quote><literal>foo/</"
9716 "literal></quote>."
9717 msgstr ""
9719 #. type: Content of: <book><chapter><sect1><sect2><para>
9720 #: ../en/ch07-filenames.xml:224
9721 msgid ""
9722 "One thing to note, if you're familiar with Perl-style regexps, is that "
9723 "Mercurial's are <emphasis>rooted</emphasis>. That is, a regexp starts "
9724 "matching against the beginning of a string; it doesn't look for a match "
9725 "anywhere within the string. To match anywhere in a string, start your "
9726 "pattern with <quote><literal>.*</literal></quote>."
9727 msgstr ""
9729 #. type: Content of: <book><chapter><sect1><title>
9730 #: ../en/ch07-filenames.xml:234
9731 msgid "Filtering files"
9732 msgstr "过滤文件"
9734 #. type: Content of: <book><chapter><sect1><para>
9735 #: ../en/ch07-filenames.xml:236
9736 msgid ""
9737 "Not only does Mercurial give you a variety of ways to specify files; it lets "
9738 "you further winnow those files using <emphasis>filters</emphasis>. Commands "
9739 "that work with file names accept two filtering options."
9740 msgstr ""
9742 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
9743 #: ../en/ch07-filenames.xml:241
9744 msgid ""
9745 "<option role=\"hg-opt-global\">-I</option>, or <option role=\"hg-opt-global"
9746 "\">--include</option>, lets you specify a pattern that file names must match "
9747 "in order to be processed."
9748 msgstr ""
9750 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
9751 #: ../en/ch07-filenames.xml:246
9752 msgid ""
9753 "<option role=\"hg-opt-global\">-X</option>, or <option role=\"hg-opt-global"
9754 "\">--exclude</option>, gives you a way to <emphasis>avoid</emphasis> "
9755 "processing files, if they match this pattern."
9756 msgstr ""
9758 #. type: Content of: <book><chapter><sect1><para>
9759 #: ../en/ch07-filenames.xml:251
9760 msgid ""
9761 "You can provide multiple <option role=\"hg-opt-global\">-I</option> and "
9762 "<option role=\"hg-opt-global\">-X</option> options on the command line, and "
9763 "intermix them as you please. Mercurial interprets the patterns you provide "
9764 "using glob syntax by default (but you can use regexps if you need to)."
9765 msgstr ""
9767 #. type: Content of: <book><chapter><sect1><para>
9768 #: ../en/ch07-filenames.xml:258
9769 msgid ""
9770 "You can read a <option role=\"hg-opt-global\">-I</option> filter as "
9771 "<quote>process only the files that match this filter</quote>."
9772 msgstr ""
9774 #. type: Content of: <book><chapter><sect1><para>
9775 #: ../en/ch07-filenames.xml:264
9776 msgid ""
9777 "The <option role=\"hg-opt-global\">-X</option> filter is best read as "
9778 "<quote>process only the files that don't match this pattern</quote>."
9779 msgstr ""
9781 #. type: Content of: <book><chapter><sect1><title>
9782 #: ../en/ch07-filenames.xml:272
9783 msgid "Permanently ignoring unwanted files and directories"
9784 msgstr "始终忽略不需要的文件和目录"
9786 #. type: Content of: <book><chapter><sect1><para>
9787 #: ../en/ch07-filenames.xml:274
9788 msgid ""
9789 "When you create a new repository, the chances are that over time it will grow "
9790 "to contain files that ought to <emphasis>not</emphasis> be managed by "
9791 "Mercurial, but which you don't want to see listed every time you run "
9792 "<command>hg status</command>. For instance, <quote>build products</quote> "
9793 "are files that are created as part of a build but which should not be managed "
9794 "by a revision control system. The most common build products are output "
9795 "files produced by software tools such as compilers. As another example, many "
9796 "text editors litter a directory with lock files, temporary working files, and "
9797 "backup files, which it also makes no sense to manage."
9798 msgstr ""
9800 #. type: Content of: <book><chapter><sect1><para>
9801 #: ../en/ch07-filenames.xml:286
9802 msgid ""
9803 "To have Mercurial permanently ignore such files, create a file named "
9804 "<filename>.hgignore</filename> in the root of your repository. You "
9805 "<emphasis>should</emphasis> <command>hg add</command> this file so that it "
9806 "gets tracked with the rest of your repository contents, since your "
9807 "collaborators will probably find it useful too."
9808 msgstr ""
9810 #. type: Content of: <book><chapter><sect1><para>
9811 #: ../en/ch07-filenames.xml:293
9812 msgid ""
9813 "By default, the <filename>.hgignore</filename> file should contain a list of "
9814 "regular expressions, one per line. Empty lines are skipped. Most people "
9815 "prefer to describe the files they want to ignore using the <quote>glob</"
9816 "quote> syntax that we described above, so a typical <filename>.hgignore</"
9817 "filename> file will start with this directive:"
9818 msgstr ""
9820 #. type: Content of: <book><chapter><sect1><para>
9821 #: ../en/ch07-filenames.xml:302
9822 msgid ""
9823 "This tells Mercurial to interpret the lines that follow as glob patterns, not "
9824 "regular expressions."
9825 msgstr ""
9827 #. type: Content of: <book><chapter><sect1><para>
9828 #: ../en/ch07-filenames.xml:305
9829 msgid "Here is a typical-looking <filename>.hgignore</filename> file."
9830 msgstr ""
9832 #. type: Content of: <book><chapter><sect1><title>
9833 #: ../en/ch07-filenames.xml:329
9834 msgid "Case sensitivity"
9835 msgstr "大小写敏感性"
9837 #. type: Content of: <book><chapter><sect1><para>
9838 #: ../en/ch07-filenames.xml:331
9839 msgid ""
9840 "If you're working in a mixed development environment that contains both Linux "
9841 "(or other Unix) systems and Macs or Windows systems, you should keep in the "
9842 "back of your mind the knowledge that they treat the case (<quote>N</quote> "
9843 "versus <quote>n</quote>) of file names in incompatible ways. This is not "
9844 "very likely to affect you, and it's easy to deal with if it does, but it "
9845 "could surprise you if you don't know about it."
9846 msgstr ""
9848 #. type: Content of: <book><chapter><sect1><para>
9849 #: ../en/ch07-filenames.xml:340
9850 msgid ""
9851 "Operating systems and filesystems differ in the way they handle the "
9852 "<emphasis>case</emphasis> of characters in file and directory names. There "
9853 "are three common ways to handle case in names."
9854 msgstr ""
9856 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
9857 #: ../en/ch07-filenames.xml:345
9858 msgid ""
9859 "Completely case insensitive. Uppercase and lowercase versions of a letter "
9860 "are treated as identical, both when creating a file and during subsequent "
9861 "accesses. This is common on older DOS-based systems."
9862 msgstr ""
9864 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
9865 #: ../en/ch07-filenames.xml:350
9866 msgid ""
9867 "Case preserving, but insensitive. When a file or directory is created, the "
9868 "case of its name is stored, and can be retrieved and displayed by the "
9869 "operating system. When an existing file is being looked up, its case is "
9870 "ignored. This is the standard arrangement on Windows and MacOS. The names "
9871 "<filename>foo</filename> and <filename>FoO</filename> identify the same "
9872 "file. This treatment of uppercase and lowercase letters as interchangeable "
9873 "is also referred to as <emphasis>case folding</emphasis>."
9874 msgstr ""
9876 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
9877 #: ../en/ch07-filenames.xml:361
9878 msgid ""
9879 "Case sensitive. The case of a name is significant at all times. The names "
9880 "<filename>foo</filename> and <filename>FoO</filename> identify different "
9881 "files. This is the way Linux and Unix systems normally work."
9882 msgstr ""
9884 #. type: Content of: <book><chapter><sect1><para>
9885 #: ../en/ch07-filenames.xml:368
9886 msgid ""
9887 "On Unix-like systems, it is possible to have any or all of the above ways of "
9888 "handling case in action at once. For example, if you use a USB thumb drive "
9889 "formatted with a FAT32 filesystem on a Linux system, Linux will handle names "
9890 "on that filesystem in a case preserving, but insensitive, way."
9891 msgstr ""
9893 #. type: Content of: <book><chapter><sect1><sect2><title>
9894 #: ../en/ch07-filenames.xml:375
9895 msgid "Safe, portable repository storage"
9896 msgstr "安全,可移植的版本库存储"
9898 #. type: Content of: <book><chapter><sect1><sect2><para>
9899 #: ../en/ch07-filenames.xml:377
9900 msgid ""
9901 "Mercurial's repository storage mechanism is <emphasis>case safe</emphasis>. "
9902 "It translates file names so that they can be safely stored on both case "
9903 "sensitive and case insensitive filesystems. This means that you can use "
9904 "normal file copying tools to transfer a Mercurial repository onto, for "
9905 "example, a USB thumb drive, and safely move that drive and repository back "
9906 "and forth between a Mac, a PC running Windows, and a Linux box."
9907 msgstr ""
9909 #. type: Content of: <book><chapter><sect1><sect2><title>
9910 #: ../en/ch07-filenames.xml:388
9911 msgid "Detecting case conflicts"
9912 msgstr "检测大小写冲突"
9914 #. type: Content of: <book><chapter><sect1><sect2><para>
9915 #: ../en/ch07-filenames.xml:390
9916 msgid ""
9917 "When operating in the working directory, Mercurial honours the naming policy "
9918 "of the filesystem where the working directory is located. If the filesystem "
9919 "is case preserving, but insensitive, Mercurial will treat names that differ "
9920 "only in case as the same."
9921 msgstr ""
9923 #. type: Content of: <book><chapter><sect1><sect2><para>
9924 #: ../en/ch07-filenames.xml:396
9925 msgid ""
9926 "An important aspect of this approach is that it is possible to commit a "
9927 "changeset on a case sensitive (typically Linux or Unix) filesystem that will "
9928 "cause trouble for users on case insensitive (usually Windows and MacOS) "
9929 "users. If a Linux user commits changes to two files, one named "
9930 "<filename>myfile.c</filename> and the other named <filename>MyFile.C</"
9931 "filename>, they will be stored correctly in the repository. And in the "
9932 "working directories of other Linux users, they will be correctly represented "
9933 "as separate files."
9934 msgstr ""
9936 #. type: Content of: <book><chapter><sect1><sect2><para>
9937 #: ../en/ch07-filenames.xml:407
9938 msgid ""
9939 "If a Windows or Mac user pulls this change, they will not initially have a "
9940 "problem, because Mercurial's repository storage mechanism is case safe. "
9941 "However, once they try to <command role=\"hg-cmd\">hg update</command> the "
9942 "working directory to that changeset, or <command role=\"hg-cmd\">hg merge</"
9943 "command> with that changeset, Mercurial will spot the conflict between the "
9944 "two file names that the filesystem would treat as the same, and forbid the "
9945 "update or merge from occurring."
9946 msgstr ""
9948 #. type: Content of: <book><chapter><sect1><sect2><title>
9949 #: ../en/ch07-filenames.xml:419
9950 msgid "Fixing a case conflict"
9951 msgstr "修正大小写冲突"
9953 #. type: Content of: <book><chapter><sect1><sect2><para>
9954 #: ../en/ch07-filenames.xml:421
9955 msgid ""
9956 "If you are using Windows or a Mac in a mixed environment where some of your "
9957 "collaborators are using Linux or Unix, and Mercurial reports a case folding "
9958 "conflict when you try to <command role=\"hg-cmd\">hg update</command> or "
9959 "<command role=\"hg-cmd\">hg merge</command>, the procedure to fix the problem "
9960 "is simple."
9961 msgstr ""
9963 #. type: Content of: <book><chapter><sect1><sect2><para>
9964 #: ../en/ch07-filenames.xml:428
9965 msgid ""
9966 "Just find a nearby Linux or Unix box, clone the problem repository onto it, "
9967 "and use Mercurial's <command role=\"hg-cmd\">hg rename</command> command to "
9968 "change the names of any offending files or directories so that they will no "
9969 "longer cause case folding conflicts. Commit this change, <command role=\"hg-"
9970 "cmd\">hg pull</command> or <command role=\"hg-cmd\">hg push</command> it "
9971 "across to your Windows or MacOS system, and <command role=\"hg-cmd\">hg "
9972 "update</command> to the revision with the non-conflicting names."
9973 msgstr ""
9975 #. type: Content of: <book><chapter><sect1><sect2><para>
9976 #: ../en/ch07-filenames.xml:438
9977 msgid ""
9978 "The changeset with case-conflicting names will remain in your project's "
9979 "history, and you still won't be able to <command role=\"hg-cmd\">hg update</"
9980 "command> your working directory to that changeset on a Windows or MacOS "
9981 "system, but you can continue development unimpeded."
9982 msgstr ""
9984 #. type: Content of: <book><chapter><title>
9985 #: ../en/ch08-branch.xml:5
9986 msgid "Managing releases and branchy development"
9987 msgstr "发布管理与分支开发"
9989 #. type: Content of: <book><chapter><para>
9990 #: ../en/ch08-branch.xml:7
9991 msgid ""
9992 "Mercurial provides several mechanisms for you to manage a project that is "
9993 "making progress on multiple fronts at once. To understand these mechanisms, "
9994 "let's first take a brief look at a fairly normal software project structure."
9995 msgstr ""
9997 #. type: Content of: <book><chapter><para>
9998 #: ../en/ch08-branch.xml:12
9999 msgid ""
10000 "Many software projects issue periodic <quote>major</quote> releases that "
10001 "contain substantial new features. In parallel, they may issue <quote>minor</"
10002 "quote> releases. These are usually identical to the major releases off which "
10003 "they're based, but with a few bugs fixed."
10004 msgstr ""
10006 #. type: Content of: <book><chapter><para>
10007 #: ../en/ch08-branch.xml:18
10008 msgid ""
10009 "In this chapter, we'll start by talking about how to keep records of project "
10010 "milestones such as releases. We'll then continue on to talk about the flow "
10011 "of work between different phases of a project, and how Mercurial can help you "
10012 "to isolate and manage this work."
10013 msgstr ""
10015 #. type: Content of: <book><chapter><sect1><title>
10016 #: ../en/ch08-branch.xml:25
10017 msgid "Giving a persistent name to a revision"
10018 msgstr "给版本指定一个永久的名称"
10020 #. type: Content of: <book><chapter><sect1><para>
10021 #: ../en/ch08-branch.xml:27
10022 msgid ""
10023 "Once you decide that you'd like to call a particular revision a "
10024 "<quote>release</quote>, it's a good idea to record the identity of that "
10025 "revision. This will let you reproduce that release at a later date, for "
10026 "whatever purpose you might need at the time (reproducing a bug, porting to a "
10027 "new platform, etc). &interaction.tag.init;"
10028 msgstr ""
10031 #. type: Content of: <book><chapter><sect1><para>
10032 #: ../en/ch08-branch.xml:34
10033 msgid ""
10034 "Mercurial lets you give a permanent name to any revision using the <command "
10035 "role=\"hg-cmd\">hg tag</command> command. Not surprisingly, these names are "
10036 "called <quote>tags</quote>."
10037 msgstr ""
10039 #. type: Content of: <book><chapter><sect1><para>
10040 #: ../en/ch08-branch.xml:40
10041 msgid ""
10042 "A tag is nothing more than a <quote>symbolic name</quote> for a revision. "
10043 "Tags exist purely for your convenience, so that you have a handy permanent "
10044 "way to refer to a revision; Mercurial doesn't interpret the tag names you use "
10045 "in any way. Neither does Mercurial place any restrictions on the name of a "
10046 "tag, beyond a few that are necessary to ensure that a tag can be parsed "
10047 "unambiguously. A tag name cannot contain any of the following characters:"
10048 msgstr ""
10050 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10051 #: ../en/ch08-branch.xml:49
10052 msgid "Colon (ASCII 58, <quote><literal>:</literal></quote>)"
10053 msgstr ""
10055 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10056 #: ../en/ch08-branch.xml:52
10057 msgid "Carriage return (ASCII 13, <quote><literal>\\r</literal></quote>)"
10058 msgstr ""
10060 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10061 #: ../en/ch08-branch.xml:55
10062 msgid "Newline (ASCII 10, <quote><literal>\\n</literal></quote>)"
10063 msgstr ""
10065 #. type: Content of: <book><chapter><sect1><para>
10066 #: ../en/ch08-branch.xml:59
10067 msgid ""
10068 "You can use the <command role=\"hg-cmd\">hg tags</command> command to display "
10069 "the tags present in your repository. In the output, each tagged revision is "
10070 "identified first by its name, then by revision number, and finally by the "
10071 "unique hash of the revision."
10072 msgstr ""
10074 #. type: Content of: <book><chapter><sect1><para>
10075 #: ../en/ch08-branch.xml:67
10076 msgid ""
10077 "Notice that <literal>tip</literal> is listed in the output of <command role="
10078 "\"hg-cmd\">hg tags</command>. The <literal>tip</literal> tag is a special "
10079 "<quote>floating</quote> tag, which always identifies the newest revision in "
10080 "the repository."
10081 msgstr ""
10083 #. type: Content of: <book><chapter><sect1><para>
10084 #: ../en/ch08-branch.xml:73
10085 msgid ""
10086 "In the output of the <command role=\"hg-cmd\">hg tags</command> command, tags "
10087 "are listed in reverse order, by revision number. This usually means that "
10088 "recent tags are listed before older tags. It also means that <literal>tip</"
10089 "literal> is always going to be the first tag listed in the output of <command "
10090 "role=\"hg-cmd\">hg tags</command>."
10091 msgstr ""
10093 #. type: Content of: <book><chapter><sect1><para>
10094 #: ../en/ch08-branch.xml:80
10095 msgid ""
10096 "When you run <command role=\"hg-cmd\">hg log</command>, if it displays a "
10097 "revision that has tags associated with it, it will print those tags."
10098 msgstr ""
10101 #. type: Content of: <book><chapter><sect1><para>
10102 #: ../en/ch08-branch.xml:86
10103 msgid ""
10104 "Any time you need to provide a revision ID to a Mercurial command, the "
10105 "command will accept a tag name in its place. Internally, Mercurial will "
10106 "translate your tag name into the corresponding revision ID, then use that."
10107 msgstr ""
10109 #. type: Content of: <book><chapter><sect1><para>
10110 #: ../en/ch08-branch.xml:93
10111 msgid ""
10112 "There's no limit on the number of tags you can have in a repository, or on "
10113 "the number of tags that a single revision can have. As a practical matter, "
10114 "it's not a great idea to have <quote>too many</quote> (a number which will "
10115 "vary from project to project), simply because tags are supposed to help you "
10116 "to find revisions. If you have lots of tags, the ease of using them to "
10117 "identify revisions diminishes rapidly."
10118 msgstr ""
10120 #. type: Content of: <book><chapter><sect1><para>
10121 #: ../en/ch08-branch.xml:101
10122 msgid ""
10123 "For example, if your project has milestones as frequent as every few days, "
10124 "it's perfectly reasonable to tag each one of those. But if you have a "
10125 "continuous build system that makes sure every revision can be built cleanly, "
10126 "you'd be introducing a lot of noise if you were to tag every clean build. "
10127 "Instead, you could tag failed builds (on the assumption that they're rare!), "
10128 "or simply not use tags to track buildability."
10129 msgstr ""
10131 #. type: Content of: <book><chapter><sect1><para>
10132 #: ../en/ch08-branch.xml:109
10133 msgid ""
10134 "If you want to remove a tag that you no longer want, use <command role=\"hg-"
10135 "cmd\">hg tag --remove</command>."
10136 msgstr ""
10138 #. type: Content of: <book><chapter><sect1><para>
10139 #: ../en/ch08-branch.xml:114
10140 msgid ""
10141 "You can also modify a tag at any time, so that it identifies a different "
10142 "revision, by simply issuing a new <command role=\"hg-cmd\">hg tag</command> "
10143 "command. You'll have to use the <option role=\"hg-opt-tag\">-f</option> "
10144 "option to tell Mercurial that you <emphasis>really</emphasis> want to update "
10145 "the tag."
10146 msgstr ""
10148 #. type: Content of: <book><chapter><sect1><para>
10149 #: ../en/ch08-branch.xml:123
10150 msgid ""
10151 "There will still be a permanent record of the previous identity of the tag, "
10152 "but Mercurial will no longer use it. There's thus no penalty to tagging the "
10153 "wrong revision; all you have to do is turn around and tag the correct "
10154 "revision once you discover your error."
10155 msgstr ""
10157 #. type: Content of: <book><chapter><sect1><para>
10158 #: ../en/ch08-branch.xml:129
10159 msgid ""
10160 "Mercurial stores tags in a normal revision-controlled file in your "
10161 "repository. If you've created any tags, you'll find them in a file in the "
10162 "root of your repository named <filename role=\"special\">.hgtags</filename>. "
10163 "When you run the <command role=\"hg-cmd\">hg tag</command> command, Mercurial "
10164 "modifies this file, then automatically commits the change to it. This means "
10165 "that every time you run <command role=\"hg-cmd\">hg tag</command>, you'll see "
10166 "a corresponding changeset in the output of <command role=\"hg-cmd\">hg log</"
10167 "command>."
10168 msgstr ""
10170 #. type: Content of: <book><chapter><sect1><sect2><title>
10171 #: ../en/ch08-branch.xml:142
10172 msgid "Handling tag conflicts during a merge"
10173 msgstr "在合并期间处理标签冲突"
10175 #. type: Content of: <book><chapter><sect1><sect2><para>
10176 #: ../en/ch08-branch.xml:144
10177 msgid ""
10178 "You won't often need to care about the <filename role=\"special\">.hgtags</"
10179 "filename> file, but it sometimes makes its presence known during a merge. "
10180 "The format of the file is simple: it consists of a series of lines. Each "
10181 "line starts with a changeset hash, followed by a space, followed by the name "
10182 "of a tag."
10183 msgstr ""
10185 #. type: Content of: <book><chapter><sect1><sect2><para>
10186 #: ../en/ch08-branch.xml:151
10187 msgid ""
10188 "If you're resolving a conflict in the <filename role=\"special\">.hgtags</"
10189 "filename> file during a merge, there's one twist to modifying the <filename "
10190 "role=\"special\">.hgtags</filename> file: when Mercurial is parsing the tags "
10191 "in a repository, it <emphasis>never</emphasis> reads the working copy of the "
10192 "<filename role=\"special\">.hgtags</filename> file. Instead, it reads the "
10193 "<emphasis>most recently committed</emphasis> revision of the file."
10194 msgstr ""
10196 #. type: Content of: <book><chapter><sect1><sect2><para>
10197 #: ../en/ch08-branch.xml:161
10198 msgid ""
10199 "An unfortunate consequence of this design is that you can't actually verify "
10200 "that your merged <filename role=\"special\">.hgtags</filename> file is "
10201 "correct until <emphasis>after</emphasis> you've committed a change. So if "
10202 "you find yourself resolving a conflict on <filename role=\"special\">.hgtags</"
10203 "filename> during a merge, be sure to run <command role=\"hg-cmd\">hg tags</"
10204 "command> after you commit. If it finds an error in the <filename role="
10205 "\"special\">.hgtags</filename> file, it will report the location of the "
10206 "error, which you can then fix and commit. You should then run <command role="
10207 "\"hg-cmd\">hg tags</command> again, just to be sure that your fix is correct."
10208 msgstr ""
10210 #. type: Content of: <book><chapter><sect1><sect2><title>
10211 #: ../en/ch08-branch.xml:176
10212 msgid "Tags and cloning"
10213 msgstr "标签与克隆"
10215 #. type: Content of: <book><chapter><sect1><sect2><para>
10216 #: ../en/ch08-branch.xml:178
10217 msgid ""
10218 "You may have noticed that the <command role=\"hg-cmd\">hg clone</command> "
10219 "command has a <option role=\"hg-opt-clone\">-r</option> option that lets you "
10220 "clone an exact copy of the repository as of a particular changeset. The new "
10221 "clone will not contain any project history that comes after the revision you "
10222 "specified. This has an interaction with tags that can surprise the unwary."
10223 msgstr ""
10225 #. type: Content of: <book><chapter><sect1><sect2><para>
10226 #: ../en/ch08-branch.xml:186
10227 msgid ""
10228 "Recall that a tag is stored as a revision to the <filename role=\"special\">."
10229 "hgtags</filename> file. When you create a tag, the changeset in which its "
10230 "recorded refers to an older changeset. When you run <command role=\"hg-cmd"
10231 "\">hg clone -r foo</command> to clone a repository as of tag <literal>foo</"
10232 "literal>, the new clone <emphasis>will not contain any revision newer than "
10233 "the one the tag refers to, including the revision where the tag was created</"
10234 "emphasis>. The result is that you'll get exactly the right subset of the "
10235 "project's history in the new repository, but <emphasis>not</emphasis> the tag "
10236 "you might have expected."
10237 msgstr ""
10239 #. type: Content of: <book><chapter><sect1><sect2><title>
10240 #: ../en/ch08-branch.xml:201
10241 msgid "When permanent tags are too much"
10242 msgstr "当永久标签太多的时候"
10244 #. type: Content of: <book><chapter><sect1><sect2><para>
10245 #: ../en/ch08-branch.xml:203
10246 msgid ""
10247 "Since Mercurial's tags are revision controlled and carried around with a "
10248 "project's history, everyone you work with will see the tags you create. But "
10249 "giving names to revisions has uses beyond simply noting that revision "
10250 "<literal>4237e45506ee</literal> is really <literal>v2.0.2</literal>. If "
10251 "you're trying to track down a subtle bug, you might want a tag to remind you "
10252 "of something like <quote>Anne saw the symptoms with this revision</quote>."
10253 msgstr ""
10255 #. type: Content of: <book><chapter><sect1><sect2><para>
10256 #: ../en/ch08-branch.xml:213
10257 msgid ""
10258 "For cases like this, what you might want to use are <emphasis>local</"
10259 "emphasis> tags. You can create a local tag with the <option role=\"hg-opt-tag"
10260 "\">-l</option> option to the <command role=\"hg-cmd\">hg tag</command> "
10261 "command. This will store the tag in a file called <filename role=\"special"
10262 "\">.hg/localtags</filename>. Unlike <filename role=\"special\">.hgtags</"
10263 "filename>, <filename role=\"special\">.hg/localtags</filename> is not "
10264 "revision controlled. Any tags you create using <option role=\"hg-opt-tag\">-"
10265 "l</option> remain strictly local to the repository you're currently working "
10266 "in."
10267 msgstr ""
10269 #. type: Content of: <book><chapter><sect1><title>
10270 #: ../en/ch08-branch.xml:228
10271 msgid "The flow of changes&emdash;big picture vs. little"
10272 msgstr "修改流程—宏观与微观"
10274 #. type: Content of: <book><chapter><sect1><para>
10275 #: ../en/ch08-branch.xml:230
10276 msgid ""
10277 "To return to the outline I sketched at the beginning of the chapter, let's "
10278 "think about a project that has multiple concurrent pieces of work under "
10279 "development at once."
10280 msgstr ""
10282 #. type: Content of: <book><chapter><sect1><para>
10283 #: ../en/ch08-branch.xml:235
10284 msgid ""
10285 "There might be a push for a new <quote>main</quote> release; a new minor "
10286 "bugfix release to the last main release; and an unexpected <quote>hot fix</"
10287 "quote> to an old release that is now in maintenance mode."
10288 msgstr ""
10290 #. type: Content of: <book><chapter><sect1><para>
10291 #: ../en/ch08-branch.xml:240
10292 msgid ""
10293 "The usual way people refer to these different concurrent directions of "
10294 "development is as <quote>branches</quote>. However, we've already seen "
10295 "numerous times that Mercurial treats <emphasis>all of history</emphasis> as a "
10296 "series of branches and merges. Really, what we have here is two ideas that "
10297 "are peripherally related, but which happen to share a name."
10298 msgstr ""
10300 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10301 #: ../en/ch08-branch.xml:247
10302 msgid ""
10303 "<quote>Big picture</quote> branches represent the sweep of a project's "
10304 "evolution; people give them names, and talk about them in conversation."
10305 msgstr ""
10307 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10308 #: ../en/ch08-branch.xml:251
10309 msgid ""
10310 "<quote>Little picture</quote> branches are artefacts of the day-to-day "
10311 "activity of developing and merging changes. They expose the narrative of how "
10312 "the code was developed."
10313 msgstr ""
10315 #. type: Content of: <book><chapter><sect1><title>
10316 #: ../en/ch08-branch.xml:259
10317 msgid "Managing big-picture branches in repositories"
10318 msgstr "在版本库中管理分支"
10320 #. type: Content of: <book><chapter><sect1><para>
10321 #: ../en/ch08-branch.xml:261
10322 msgid ""
10323 "The easiest way to isolate a <quote>big picture</quote> branch in Mercurial "
10324 "is in a dedicated repository. If you have an existing shared "
10325 "repository&emdash;let's call it <literal>myproject</literal>&emdash;that "
10326 "reaches a <quote>1.0</quote> milestone, you can start to prepare for future "
10327 "maintenance releases on top of version 1.0 by tagging the revision from which "
10328 "you prepared the 1.0 release."
10329 msgstr ""
10331 #. type: Content of: <book><chapter><sect1><para>
10332 #: ../en/ch08-branch.xml:271
10333 msgid ""
10334 "You can then clone a new shared <literal>myproject-1.0.1</literal> repository "
10335 "as of that tag."
10336 msgstr ""
10338 #. type: Content of: <book><chapter><sect1><para>
10339 #: ../en/ch08-branch.xml:277
10340 msgid ""
10341 "Afterwards, if someone needs to work on a bug fix that ought to go into an "
10342 "upcoming 1.0.1 minor release, they clone the <literal>myproject-1.0.1</"
10343 "literal> repository, make their changes, and push them back."
10344 msgstr ""
10346 #. type: Content of: <book><chapter><sect1><para>
10347 #: ../en/ch08-branch.xml:284
10348 msgid ""
10349 "Meanwhile, development for the next major release can continue, isolated and "
10350 "unabated, in the <literal>myproject</literal> repository."
10351 msgstr ""
10353 #. type: Content of: <book><chapter><sect1><title>
10354 #: ../en/ch08-branch.xml:292
10355 msgid "Don't repeat yourself: merging across branches"
10356 msgstr "不要重复劳动:在分支间合并"
10358 #. type: Content of: <book><chapter><sect1><para>
10359 #: ../en/ch08-branch.xml:294
10360 msgid ""
10361 "In many cases, if you have a bug to fix on a maintenance branch, the chances "
10362 "are good that the bug exists on your project's main branch (and possibly "
10363 "other maintenance branches, too). It's a rare developer who wants to fix the "
10364 "same bug multiple times, so let's look at a few ways that Mercurial can help "
10365 "you to manage these bugfixes without duplicating your work."
10366 msgstr ""
10368 #. type: Content of: <book><chapter><sect1><para>
10369 #: ../en/ch08-branch.xml:302
10370 msgid ""
10371 "In the simplest instance, all you need to do is pull changes from your "
10372 "maintenance branch into your local clone of the target branch."
10373 msgstr ""
10375 #. type: Content of: <book><chapter><sect1><para>
10376 #: ../en/ch08-branch.xml:308
10377 msgid ""
10378 "You'll then need to merge the heads of the two branches, and push back to the "
10379 "main branch."
10380 msgstr ""
10382 #. type: Content of: <book><chapter><sect1><title>
10383 #: ../en/ch08-branch.xml:315
10384 msgid "Naming branches within one repository"
10385 msgstr "版本库中的命名分支"
10387 #. type: Content of: <book><chapter><sect1><para>
10388 #: ../en/ch08-branch.xml:317
10389 msgid ""
10390 "In most instances, isolating branches in repositories is the right approach. "
10391 "Its simplicity makes it easy to understand; and so it's hard to make "
10392 "mistakes. There's a one-to-one relationship between branches you're working "
10393 "in and directories on your system. This lets you use normal (non-Mercurial-"
10394 "aware) tools to work on files within a branch/repository."
10395 msgstr ""
10397 #. type: Content of: <book><chapter><sect1><para>
10398 #: ../en/ch08-branch.xml:324
10399 msgid ""
10400 "If you're more in the <quote>power user</quote> category (<emphasis>and</"
10401 "emphasis> your collaborators are too), there is an alternative way of "
10402 "handling branches that you can consider. I've already mentioned the human-"
10403 "level distinction between <quote>small picture</quote> and <quote>big "
10404 "picture</quote> branches. While Mercurial works with multiple <quote>small "
10405 "picture</quote> branches in a repository all the time (for example after you "
10406 "pull changes in, but before you merge them), it can <emphasis>also</emphasis> "
10407 "work with multiple <quote>big picture</quote> branches."
10408 msgstr ""
10410 #. type: Content of: <book><chapter><sect1><para>
10411 #: ../en/ch08-branch.xml:335
10412 msgid ""
10413 "The key to working this way is that Mercurial lets you assign a persistent "
10414 "<emphasis>name</emphasis> to a branch. There always exists a branch named "
10415 "<literal>default</literal>. Even before you start naming branches yourself, "
10416 "you can find traces of the <literal>default</literal> branch if you look for "
10417 "them."
10418 msgstr ""
10420 #. type: Content of: <book><chapter><sect1><para>
10421 #: ../en/ch08-branch.xml:342
10422 msgid ""
10423 "As an example, when you run the <command role=\"hg-cmd\">hg commit</command> "
10424 "command, and it pops up your editor so that you can enter a commit message, "
10425 "look for a line that contains the text <quote><literal>HG: branch default</"
10426 "literal></quote> at the bottom. This is telling you that your commit will "
10427 "occur on the branch named <literal>default</literal>."
10428 msgstr ""
10430 #. type: Content of: <book><chapter><sect1><para>
10431 #: ../en/ch08-branch.xml:349
10432 msgid ""
10433 "To start working with named branches, use the <command role=\"hg-cmd\">hg "
10434 "branches</command> command. This command lists the named branches already "
10435 "present in your repository, telling you which changeset is the tip of each."
10436 msgstr ""
10438 #. type: Content of: <book><chapter><sect1><para>
10439 #: ../en/ch08-branch.xml:356
10440 msgid ""
10441 "Since you haven't created any named branches yet, the only one that exists is "
10442 "<literal>default</literal>."
10443 msgstr ""
10445 #. type: Content of: <book><chapter><sect1><para>
10446 #: ../en/ch08-branch.xml:359
10447 msgid ""
10448 "To find out what the <quote>current</quote> branch is, run the <command role="
10449 "\"hg-cmd\">hg branch</command> command, giving it no arguments. This tells "
10450 "you what branch the parent of the current changeset is on."
10451 msgstr ""
10454 #. type: Content of: <book><chapter><sect1><para>
10455 #: ../en/ch08-branch.xml:366
10456 msgid ""
10457 "To create a new branch, run the <command role=\"hg-cmd\">hg branch</command> "
10458 "command again. This time, give it one argument: the name of the branch you "
10459 "want to create."
10460 msgstr ""
10462 #. type: Content of: <book><chapter><sect1><para>
10463 #: ../en/ch08-branch.xml:372
10464 msgid ""
10465 "After you've created a branch, you might wonder what effect the <command role="
10466 "\"hg-cmd\">hg branch</command> command has had. What do the <command role="
10467 "\"hg-cmd\">hg status</command> and <command role=\"hg-cmd\">hg tip</command> "
10468 "commands report?"
10469 msgstr ""
10471 #. type: Content of: <book><chapter><sect1><para>
10472 #: ../en/ch08-branch.xml:379
10473 msgid ""
10474 "Nothing has changed in the working directory, and there's been no new history "
10475 "created. As this suggests, running the <command role=\"hg-cmd\">hg branch</"
10476 "command> command has no permanent effect; it only tells Mercurial what branch "
10477 "name to use the <emphasis>next</emphasis> time you commit a changeset."
10478 msgstr ""
10480 #. type: Content of: <book><chapter><sect1><para>
10481 #: ../en/ch08-branch.xml:386
10482 msgid ""
10483 "When you commit a change, Mercurial records the name of the branch on which "
10484 "you committed. Once you've switched from the <literal>default</literal> "
10485 "branch to another and committed, you'll see the name of the new branch show "
10486 "up in the output of <command role=\"hg-cmd\">hg log</command>, <command role="
10487 "\"hg-cmd\">hg tip</command>, and other commands that display the same kind of "
10488 "output."
10489 msgstr ""
10491 #. type: Content of: <book><chapter><sect1><para>
10492 #: ../en/ch08-branch.xml:396
10493 msgid ""
10494 "The <command role=\"hg-cmd\">hg log</command>-like commands will print the "
10495 "branch name of every changeset that's not on the <literal>default</literal> "
10496 "branch. As a result, if you never use named branches, you'll never see this "
10497 "information."
10498 msgstr ""
10500 #. type: Content of: <book><chapter><sect1><para>
10501 #: ../en/ch08-branch.xml:401
10502 msgid ""
10503 "Once you've named a branch and committed a change with that name, every "
10504 "subsequent commit that descends from that change will inherit the same branch "
10505 "name. You can change the name of a branch at any time, using the <command "
10506 "role=\"hg-cmd\">hg branch</command> command."
10507 msgstr ""
10509 #. type: Content of: <book><chapter><sect1><para>
10510 #: ../en/ch08-branch.xml:409
10511 msgid ""
10512 "In practice, this is something you won't do very often, as branch names tend "
10513 "to have fairly long lifetimes. (This isn't a rule, just an observation.)"
10514 msgstr ""
10516 #. type: Content of: <book><chapter><sect1><title>
10517 #: ../en/ch08-branch.xml:415
10518 msgid "Dealing with multiple named branches in a repository"
10519 msgstr "在版本库中处理多个命名分支"
10521 #. type: Content of: <book><chapter><sect1><para>
10522 #: ../en/ch08-branch.xml:418
10523 msgid ""
10524 "If you have more than one named branch in a repository, Mercurial will "
10525 "remember the branch that your working directory is on when you start a "
10526 "command like <command role=\"hg-cmd\">hg update</command> or <command role="
10527 "\"hg-cmd\">hg pull -u</command>. It will update the working directory to the "
10528 "tip of this branch, no matter what the <quote>repo-wide</quote> tip is. To "
10529 "update to a revision that's on a different named branch, you may need to use "
10530 "the <option role=\"hg-opt-update\">-C</option> option to <command role=\"hg-"
10531 "cmd\">hg update</command>."
10532 msgstr ""
10534 #. type: Content of: <book><chapter><sect1><para>
10535 #: ../en/ch08-branch.xml:428
10536 msgid ""
10537 "This behavior is a little subtle, so let's see it in action. First, let's "
10538 "remind ourselves what branch we're currently on, and what branches are in our "
10539 "repository."
10540 msgstr ""
10542 #. type: Content of: <book><chapter><sect1><para>
10543 #: ../en/ch08-branch.xml:434
10544 msgid ""
10545 "We're on the <literal>bar</literal> branch, but there also exists an older "
10546 "<command role=\"hg-cmd\">hg foo</command> branch."
10547 msgstr ""
10549 #. type: Content of: <book><chapter><sect1><para>
10550 #: ../en/ch08-branch.xml:438
10551 msgid ""
10552 "We can <command role=\"hg-cmd\">hg update</command> back and forth between "
10553 "the tips of the <literal>foo</literal> and <literal>bar</literal> branches "
10554 "without needing to use the <option role=\"hg-opt-update\">-C</option> option, "
10555 "because this only involves going backwards and forwards linearly through our "
10556 "change history."
10557 msgstr ""
10560 #. type: Content of: <book><chapter><sect1><para>
10561 #: ../en/ch08-branch.xml:447
10562 msgid ""
10563 "If we go back to the <literal>foo</literal> branch and then run <command role="
10564 "\"hg-cmd\">hg update</command>, it will keep us on <literal>foo</literal>, "
10565 "not move us to the tip of <literal>bar</literal>."
10566 msgstr ""
10569 #. type: Content of: <book><chapter><sect1><para>
10570 #: ../en/ch08-branch.xml:454
10571 msgid ""
10572 "Committing a new change on the <literal>foo</literal> branch introduces a new "
10573 "head."
10574 msgstr ""
10576 #. type: Content of: <book><chapter><sect1><title>
10577 #: ../en/ch08-branch.xml:461
10578 msgid "Branch names and merging"
10579 msgstr "分支名称与合并"
10581 #. type: Content of: <book><chapter><sect1><para>
10582 #: ../en/ch08-branch.xml:463
10583 msgid ""
10584 "As you've probably noticed, merges in Mercurial are not symmetrical. Let's "
10585 "say our repository has two heads, 17 and 23. If I <command role=\"hg-cmd"
10586 "\">hg update</command> to 17 and then <command role=\"hg-cmd\">hg merge</"
10587 "command> with 23, Mercurial records 17 as the first parent of the merge, and "
10588 "23 as the second. Whereas if I <command role=\"hg-cmd\">hg update</command> "
10589 "to 23 and then <command role=\"hg-cmd\">hg merge</command> with 17, it "
10590 "records 23 as the first parent, and 17 as the second."
10591 msgstr ""
10593 #. type: Content of: <book><chapter><sect1><para>
10594 #: ../en/ch08-branch.xml:473
10595 msgid ""
10596 "This affects Mercurial's choice of branch name when you merge. After a "
10597 "merge, Mercurial will retain the branch name of the first parent when you "
10598 "commit the result of the merge. If your first parent's branch name is "
10599 "<literal>foo</literal>, and you merge with <literal>bar</literal>, the branch "
10600 "name will still be <literal>foo</literal> after you merge."
10601 msgstr ""
10603 #. type: Content of: <book><chapter><sect1><para>
10604 #: ../en/ch08-branch.xml:480
10605 msgid ""
10606 "It's not unusual for a repository to contain multiple heads, each with the "
10607 "same branch name. Let's say I'm working on the <literal>foo</literal> "
10608 "branch, and so are you. We commit different changes; I pull your changes; I "
10609 "now have two heads, each claiming to be on the <literal>foo</literal> "
10610 "branch. The result of a merge will be a single head on the <literal>foo</"
10611 "literal> branch, as you might hope."
10612 msgstr ""
10615 #. type: Content of: <book><chapter><sect1><para>
10616 #: ../en/ch08-branch.xml:488
10617 msgid ""
10618 "But if I'm working on the <literal>bar</literal> branch, and I merge work "
10619 "from the <literal>foo</literal> branch, the result will remain on the "
10620 "<literal>bar</literal> branch."
10621 msgstr ""
10623 #. type: Content of: <book><chapter><sect1><para>
10624 #: ../en/ch08-branch.xml:494
10625 msgid ""
10626 "To give a more concrete example, if I'm working on the <literal>bleeding-"
10627 "edge</literal> branch, and I want to bring in the latest fixes from the "
10628 "<literal>stable</literal> branch, Mercurial will choose the <quote>right</"
10629 "quote> (<literal>bleeding-edge</literal>) branch name when I pull and merge "
10630 "from <literal>stable</literal>."
10631 msgstr ""
10633 #. type: Content of: <book><chapter><sect1><title>
10634 #: ../en/ch08-branch.xml:503
10635 msgid "Branch naming is generally useful"
10636 msgstr "分支名称通常都很有用"
10638 #. type: Content of: <book><chapter><sect1><para>
10639 #: ../en/ch08-branch.xml:505
10640 msgid ""
10641 "You shouldn't think of named branches as applicable only to situations where "
10642 "you have multiple long-lived branches cohabiting in a single repository. "
10643 "They're very useful even in the one-branch-per-repository case."
10644 msgstr ""
10646 #. type: Content of: <book><chapter><sect1><para>
10647 #: ../en/ch08-branch.xml:510
10648 msgid ""
10649 "In the simplest case, giving a name to each branch gives you a permanent "
10650 "record of which branch a changeset originated on. This gives you more "
10651 "context when you're trying to follow the history of a long-lived branchy "
10652 "project."
10653 msgstr ""
10655 #. type: Content of: <book><chapter><sect1><para>
10656 #: ../en/ch08-branch.xml:515
10657 msgid ""
10658 "If you're working with shared repositories, you can set up a <literal role="
10659 "\"hook\">pretxnchangegroup</literal> hook on each that will block incoming "
10660 "changes that have the <quote>wrong</quote> branch name. This provides a "
10661 "simple, but effective, defence against people accidentally pushing changes "
10662 "from a <quote>bleeding edge</quote> branch to a <quote>stable</quote> "
10663 "branch. Such a hook might look like this inside the shared repo's <filename "
10664 "role=\"special\"> /.hgrc</filename>."
10665 msgstr ""
10667 #. type: Content of: <book><chapter><title>
10668 #: ../en/ch09-undo.xml:5
10669 msgid "Finding and fixing mistakes"
10670 msgstr "查找和修改错误"
10672 #. type: Content of: <book><chapter><para>
10673 #: ../en/ch09-undo.xml:7
10674 msgid ""
10675 "To err might be human, but to really handle the consequences well takes a top-"
10676 "notch revision control system. In this chapter, we'll discuss some of the "
10677 "techniques you can use when you find that a problem has crept into your "
10678 "project. Mercurial has some highly capable features that will help you to "
10679 "isolate the sources of problems, and to handle them appropriately."
10680 msgstr ""
10682 #. type: Content of: <book><chapter><sect1><title>
10683 #: ../en/ch09-undo.xml:15
10684 msgid "Erasing local history"
10685 msgstr "销毁本地历史"
10687 #. type: Content of: <book><chapter><sect1><sect2><title>
10688 #: ../en/ch09-undo.xml:18
10689 msgid "The accidental commit"
10690 msgstr "意外的提交"
10692 #. type: Content of: <book><chapter><sect1><sect2><para>
10693 #: ../en/ch09-undo.xml:20
10694 msgid ""
10695 "I have the occasional but persistent problem of typing rather more quickly "
10696 "than I can think, which sometimes results in me committing a changeset that "
10697 "is either incomplete or plain wrong. In my case, the usual kind of "
10698 "incomplete changeset is one in which I've created a new source file, but "
10699 "forgotten to <command role=\"hg-cmd\">hg add</command> it. A <quote>plain "
10700 "wrong</quote> changeset is not as common, but no less annoying."
10701 msgstr ""
10703 #. type: Content of: <book><chapter><sect1><sect2><title>
10704 #: ../en/ch09-undo.xml:31
10705 msgid "Rolling back a transaction"
10706 msgstr "回滚一个事务"
10708 #. type: Content of: <book><chapter><sect1><sect2><para>
10709 #: ../en/ch09-undo.xml:33
10710 msgid ""
10711 "In <xref linkend=\"sec:concepts:txn\"/>, I mentioned that Mercurial treats "
10712 "each modification of a repository as a <emphasis>transaction</emphasis>. "
10713 "Every time you commit a changeset or pull changes from another repository, "
10714 "Mercurial remembers what you did. You can undo, or <emphasis>roll back</"
10715 "emphasis>, exactly one of these actions using the <command role=\"hg-cmd\">hg "
10716 "rollback</command> command. (See <xref linkend=\"sec:undo:rollback-after-push"
10717 "\"/> for an important caveat about the use of this command.)"
10718 msgstr ""
10720 #. type: Content of: <book><chapter><sect1><sect2><para>
10721 #: ../en/ch09-undo.xml:43
10722 msgid ""
10723 "Here's a mistake that I often find myself making: committing a change in "
10724 "which I've created a new file, but forgotten to <command role=\"hg-cmd\">hg "
10725 "add</command> it."
10726 msgstr ""
10728 #. type: Content of: <book><chapter><sect1><sect2><para>
10729 #: ../en/ch09-undo.xml:50
10730 msgid ""
10731 "Looking at the output of <command role=\"hg-cmd\">hg status</command> after "
10732 "the commit immediately confirms the error."
10733 msgstr ""
10735 #. type: Content of: <book><chapter><sect1><sect2><para>
10736 #: ../en/ch09-undo.xml:56
10737 msgid ""
10738 "The commit captured the changes to the file <filename>a</filename>, but not "
10739 "the new file <filename>b</filename>. If I were to push this changeset to a "
10740 "repository that I shared with a colleague, the chances are high that "
10741 "something in <filename>a</filename> would refer to <filename>b</filename>, "
10742 "which would not be present in their repository when they pulled my changes. "
10743 "I would thus become the object of some indignation."
10744 msgstr ""
10746 #. type: Content of: <book><chapter><sect1><sect2><para>
10747 #: ../en/ch09-undo.xml:65
10748 msgid ""
10749 "However, luck is with me&emdash;I've caught my error before I pushed the "
10750 "changeset. I use the <command role=\"hg-cmd\">hg rollback</command> command, "
10751 "and Mercurial makes that last changeset vanish."
10752 msgstr ""
10754 #. type: Content of: <book><chapter><sect1><sect2><para>
10755 #: ../en/ch09-undo.xml:72
10756 msgid ""
10757 "Notice that the changeset is no longer present in the repository's history, "
10758 "and the working directory once again thinks that the file <filename>a</"
10759 "filename> is modified. The commit and rollback have left the working "
10760 "directory exactly as it was prior to the commit; the changeset has been "
10761 "completely erased. I can now safely <command role=\"hg-cmd\">hg add</"
10762 "command> the file <filename>b</filename>, and rerun my commit."
10763 msgstr ""
10765 #. type: Content of: <book><chapter><sect1><sect2><title>
10766 #: ../en/ch09-undo.xml:85
10767 msgid "The erroneous pull"
10768 msgstr "错误的抓取"
10770 #. type: Content of: <book><chapter><sect1><sect2><para>
10771 #: ../en/ch09-undo.xml:87
10772 msgid ""
10773 "It's common practice with Mercurial to maintain separate development branches "
10774 "of a project in different repositories. Your development team might have one "
10775 "shared repository for your project's <quote>0.9</quote> release, and another, "
10776 "containing different changes, for the <quote>1.0</quote> release."
10777 msgstr ""
10779 #. type: Content of: <book><chapter><sect1><sect2><para>
10780 #: ../en/ch09-undo.xml:94
10781 msgid ""
10782 "Given this, you can imagine that the consequences could be messy if you had a "
10783 "local <quote>0.9</quote> repository, and accidentally pulled changes from the "
10784 "shared <quote>1.0</quote> repository into it. At worst, you could be paying "
10785 "insufficient attention, and push those changes into the shared <quote>0.9</"
10786 "quote> tree, confusing your entire team (but don't worry, we'll return to "
10787 "this horror scenario later). However, it's more likely that you'll notice "
10788 "immediately, because Mercurial will display the URL it's pulling from, or you "
10789 "will see it pull a suspiciously large number of changes into the repository."
10790 msgstr ""
10792 #. type: Content of: <book><chapter><sect1><sect2><para>
10793 #: ../en/ch09-undo.xml:106
10794 msgid ""
10795 "The <command role=\"hg-cmd\">hg rollback</command> command will work nicely "
10796 "to expunge all of the changesets that you just pulled. Mercurial groups all "
10797 "changes from one <command role=\"hg-cmd\">hg pull</command> into a single "
10798 "transaction, so one <command role=\"hg-cmd\">hg rollback</command> is all you "
10799 "need to undo this mistake."
10800 msgstr ""
10802 #. type: Content of: <book><chapter><sect1><sect2><title>
10803 #: ../en/ch09-undo.xml:115
10804 msgid "Rolling back is useless once you've pushed"
10805 msgstr "当完成推送后,回滚是无效的"
10807 #. type: Content of: <book><chapter><sect1><sect2><para>
10808 #: ../en/ch09-undo.xml:117
10809 msgid ""
10810 "The value of the <command role=\"hg-cmd\">hg rollback</command> command drops "
10811 "to zero once you've pushed your changes to another repository. Rolling back "
10812 "a change makes it disappear entirely, but <emphasis>only</emphasis> in the "
10813 "repository in which you perform the <command role=\"hg-cmd\">hg rollback</"
10814 "command>. Because a rollback eliminates history, there's no way for the "
10815 "disappearance of a change to propagate between repositories."
10816 msgstr ""
10818 #. type: Content of: <book><chapter><sect1><sect2><para>
10819 #: ../en/ch09-undo.xml:126
10820 msgid ""
10821 "If you've pushed a change to another repository&emdash;particularly if it's a "
10822 "shared repository&emdash;it has essentially <quote>escaped into the wild,</"
10823 "quote> and you'll have to recover from your mistake in a different way. If "
10824 "you push a changeset somewhere, then roll it back, then pull from the "
10825 "repository you pushed to, the changeset you thought you'd gotten rid of will "
10826 "simply reappear in your repository."
10827 msgstr ""
10829 #. type: Content of: <book><chapter><sect1><sect2><para>
10830 #: ../en/ch09-undo.xml:135
10831 msgid ""
10832 "(If you absolutely know for sure that the change you want to roll back is the "
10833 "most recent change in the repository that you pushed to, <emphasis>and</"
10834 "emphasis> you know that nobody else could have pulled it from that "
10835 "repository, you can roll back the changeset there, too, but you really should "
10836 "not expect this to work reliably. Sooner or later a change really will make "
10837 "it into a repository that you don't directly control (or have forgotten "
10838 "about), and come back to bite you.)"
10839 msgstr ""
10841 #. type: Content of: <book><chapter><sect1><sect2><title>
10842 #: ../en/ch09-undo.xml:147
10843 msgid "You can only roll back once"
10844 msgstr "你只能回滚一次"
10846 #. type: Content of: <book><chapter><sect1><sect2><para>
10847 #: ../en/ch09-undo.xml:149
10848 msgid ""
10849 "Mercurial stores exactly one transaction in its transaction log; that "
10850 "transaction is the most recent one that occurred in the repository. This "
10851 "means that you can only roll back one transaction. If you expect to be able "
10852 "to roll back one transaction, then its predecessor, this is not the behavior "
10853 "you will get."
10854 msgstr ""
10856 #. type: Content of: <book><chapter><sect1><sect2><para>
10857 #: ../en/ch09-undo.xml:158
10858 msgid ""
10859 "Once you've rolled back one transaction in a repository, you can't roll back "
10860 "again in that repository until you perform another commit or pull."
10861 msgstr ""
10863 #. type: Content of: <book><chapter><sect1><title>
10864 #: ../en/ch09-undo.xml:165
10865 msgid "Reverting the mistaken change"
10866 msgstr "撤销错误的修改"
10868 #. type: Content of: <book><chapter><sect1><para>
10869 #: ../en/ch09-undo.xml:167
10870 msgid ""
10871 "If you make a modification to a file, and decide that you really didn't want "
10872 "to change the file at all, and you haven't yet committed your changes, the "
10873 "<command role=\"hg-cmd\">hg revert</command> command is the one you'll need. "
10874 "It looks at the changeset that's the parent of the working directory, and "
10875 "restores the contents of the file to their state as of that changeset. "
10876 "(That's a long-winded way of saying that, in the normal case, it undoes your "
10877 "modifications.)"
10878 msgstr ""
10880 #. type: Content of: <book><chapter><sect1><para>
10881 #: ../en/ch09-undo.xml:176
10882 msgid ""
10883 "Let's illustrate how the <command role=\"hg-cmd\">hg revert</command> command "
10884 "works with yet another small example. We'll begin by modifying a file that "
10885 "Mercurial is already tracking."
10886 msgstr ""
10888 #. type: Content of: <book><chapter><sect1><para>
10889 #: ../en/ch09-undo.xml:183
10890 msgid ""
10891 "If we don't want that change, we can simply <command role=\"hg-cmd\">hg "
10892 "revert</command> the file."
10893 msgstr ""
10895 #. type: Content of: <book><chapter><sect1><para>
10896 #: ../en/ch09-undo.xml:189
10897 msgid ""
10898 "The <command role=\"hg-cmd\">hg revert</command> command provides us with an "
10899 "extra degree of safety by saving our modified file with a <filename>.orig</"
10900 "filename> extension."
10901 msgstr ""
10903 #. type: Content of: <book><chapter><sect1><tip><title>
10904 #: ../en/ch09-undo.xml:197
10905 msgid "Be careful with <filename>.orig</filename> files"
10906 msgstr "小心 <filename>.orig</filename> 文件"
10908 #. type: Content of: <book><chapter><sect1><tip><para>
10909 #: ../en/ch09-undo.xml:199
10910 msgid ""
10911 "It's extremely unlikely that you are either using Mercurial to manage files "
10912 "with <filename>.orig</filename> extensions or that you even care about the "
10913 "contents of such files. Just in case, though, it's useful to remember that "
10914 "<command role=\"hg-cmd\">hg revert</command> will unconditionally overwrite "
10915 "an existing file with a <filename>.orig</filename> extension. For instance, "
10916 "if you already have a file named <filename>foo.orig</filename> when you "
10917 "revert <filename>foo</filename>, the contents of <filename>foo.orig</"
10918 "filename> will be clobbered."
10919 msgstr ""
10921 #. type: Content of: <book><chapter><sect1><para>
10922 #: ../en/ch09-undo.xml:211
10923 msgid ""
10924 "Here is a summary of the cases that the <command role=\"hg-cmd\">hg revert</"
10925 "command> command can deal with. We will describe each of these in more "
10926 "detail in the section that follows."
10927 msgstr ""
10929 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10930 #: ../en/ch09-undo.xml:216
10931 msgid "If you modify a file, it will restore the file to its unmodified state."
10932 msgstr ""
10934 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10935 #: ../en/ch09-undo.xml:219
10936 msgid ""
10937 "If you <command role=\"hg-cmd\">hg add</command> a file, it will undo the "
10938 "<quote>added</quote> state of the file, but leave the file itself untouched."
10939 msgstr ""
10941 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10942 #: ../en/ch09-undo.xml:223
10943 msgid ""
10944 "If you delete a file without telling Mercurial, it will restore the file to "
10945 "its unmodified contents."
10946 msgstr ""
10948 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10949 #: ../en/ch09-undo.xml:226
10950 msgid ""
10951 "If you use the <command role=\"hg-cmd\">hg remove</command> command to remove "
10952 "a file, it will undo the <quote>removed</quote> state of the file, and "
10953 "restore the file to its unmodified contents."
10954 msgstr ""
10956 #. type: Content of: <book><chapter><sect1><sect2><title>
10957 #: ../en/ch09-undo.xml:233
10958 msgid "File management errors"
10959 msgstr "文件管理错误"
10961 #. type: Content of: <book><chapter><sect1><sect2><para>
10962 #: ../en/ch09-undo.xml:235
10963 msgid ""
10964 "The <command role=\"hg-cmd\">hg revert</command> command is useful for more "
10965 "than just modified files. It lets you reverse the results of all of "
10966 "Mercurial's file management commands&emdash;<command role=\"hg-cmd\">hg add</"
10967 "command>, <command role=\"hg-cmd\">hg remove</command>, and so on."
10968 msgstr ""
10971 #. type: Content of: <book><chapter><sect1><sect2><para>
10972 #: ../en/ch09-undo.xml:241
10973 msgid ""
10974 "If you <command role=\"hg-cmd\">hg add</command> a file, then decide that in "
10975 "fact you don't want Mercurial to track it, use <command role=\"hg-cmd\">hg "
10976 "revert</command> to undo the add. Don't worry; Mercurial will not modify the "
10977 "file in any way. It will just <quote>unmark</quote> the file."
10978 msgstr ""
10980 #. type: Content of: <book><chapter><sect1><sect2><para>
10981 #: ../en/ch09-undo.xml:249
10982 msgid ""
10983 "Similarly, if you ask Mercurial to <command role=\"hg-cmd\">hg remove</"
10984 "command> a file, you can use <command role=\"hg-cmd\">hg revert</command> to "
10985 "restore it to the contents it had as of the parent of the working directory. "
10986 "&interaction.daily.revert.remove; This works just as well for a file that you "
10987 "deleted by hand, without telling Mercurial (recall that in Mercurial "
10988 "terminology, this kind of file is called <quote>missing</quote>)."
10989 msgstr ""
10992 #. type: Content of: <book><chapter><sect1><sect2><para>
10993 #: ../en/ch09-undo.xml:260
10994 msgid ""
10995 "If you revert a <command role=\"hg-cmd\">hg copy</command>, the copied-to "
10996 "file remains in your working directory afterwards, untracked. Since a copy "
10997 "doesn't affect the copied-from file in any way, Mercurial doesn't do anything "
10998 "with the copied-from file."
10999 msgstr ""
11001 #. type: Content of: <book><chapter><sect1><title>
11002 #: ../en/ch09-undo.xml:271
11003 msgid "Dealing with committed changes"
11004 msgstr "处理已经提交的修改"
11006 #. type: Content of: <book><chapter><sect1><para>
11007 #: ../en/ch09-undo.xml:273
11008 msgid ""
11009 "Consider a case where you have committed a change <emphasis>a</emphasis>, and "
11010 "another change <emphasis>b</emphasis> on top of it; you then realise that "
11011 "change <emphasis>a</emphasis> was incorrect. Mercurial lets you <quote>back "
11012 "out</quote> an entire changeset automatically, and building blocks that let "
11013 "you reverse part of a changeset by hand."
11014 msgstr ""
11016 #. type: Content of: <book><chapter><sect1><para>
11017 #: ../en/ch09-undo.xml:281
11018 msgid ""
11019 "Before you read this section, here's something to keep in mind: the <command "
11020 "role=\"hg-cmd\">hg backout</command> command undoes the effect of a change by "
11021 "<emphasis>adding</emphasis> to your repository's history, not by modifying or "
11022 "erasing it. It's the right tool to use if you're fixing bugs, but not if "
11023 "you're trying to undo some change that has catastrophic consequences. To "
11024 "deal with those, see <xref linkend=\"sec:undo:aaaiiieee\"/>."
11025 msgstr ""
11027 #. type: Content of: <book><chapter><sect1><sect2><title>
11028 #: ../en/ch09-undo.xml:291
11029 msgid "Backing out a changeset"
11030 msgstr "恢复一个修改集"
11032 #. type: Content of: <book><chapter><sect1><sect2><para>
11033 #: ../en/ch09-undo.xml:293
11034 msgid ""
11035 "The <command role=\"hg-cmd\">hg backout</command> command lets you "
11036 "<quote>undo</quote> the effects of an entire changeset in an automated "
11037 "fashion. Because Mercurial's history is immutable, this command "
11038 "<emphasis>does not</emphasis> get rid of the changeset you want to undo. "
11039 "Instead, it creates a new changeset that <emphasis>reverses</emphasis> the "
11040 "effect of the to-be-undone changeset."
11041 msgstr ""
11044 #. type: Content of: <book><chapter><sect1><sect2><para>
11045 #: ../en/ch09-undo.xml:302
11046 msgid ""
11047 "The operation of the <command role=\"hg-cmd\">hg backout</command> command is "
11048 "a little intricate, so let's illustrate it with some examples. First, we'll "
11049 "create a repository with some simple changes."
11050 msgstr ""
11052 #. type: Content of: <book><chapter><sect1><sect2><para>
11053 #: ../en/ch09-undo.xml:309
11054 msgid ""
11055 "The <command role=\"hg-cmd\">hg backout</command> command takes a single "
11056 "changeset ID as its argument; this is the changeset to back out. Normally, "
11057 "<command role=\"hg-cmd\">hg backout</command> will drop you into a text "
11058 "editor to write a commit message, so you can record why you're backing the "
11059 "change out. In this example, we provide a commit message on the command line "
11060 "using the <option role=\"hg-opt-backout\">-m</option> option."
11061 msgstr ""
11063 #. type: Content of: <book><chapter><sect1><sect2><title>
11064 #: ../en/ch09-undo.xml:320
11065 msgid "Backing out the tip changeset"
11066 msgstr "恢复顶点修改集"
11068 #. type: Content of: <book><chapter><sect1><sect2><para>
11069 #: ../en/ch09-undo.xml:322
11070 msgid "We're going to start by backing out the last changeset we committed."
11071 msgstr ""
11073 #. type: Content of: <book><chapter><sect1><sect2><para>
11074 #: ../en/ch09-undo.xml:327
11075 msgid ""
11076 "You can see that the second line from <filename>myfile</filename> is no "
11077 "longer present. Taking a look at the output of <command role=\"hg-cmd\">hg "
11078 "log</command> gives us an idea of what the <command role=\"hg-cmd\">hg "
11079 "backout</command> command has done. &interaction.backout.simple.log; Notice "
11080 "that the new changeset that <command role=\"hg-cmd\">hg backout</command> has "
11081 "created is a child of the changeset we backed out. It's easier to see this "
11082 "in <xref linkend=\"fig:undo:backout\"/>, which presents a graphical view of "
11083 "the change history. As you can see, the history is nice and linear."
11084 msgstr ""
11086 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
11087 #: ../en/ch09-undo.xml:340 ../en/ch09-undo.xml:460
11088 msgid ""
11089 "Backing out a change using the <command role=\"hg-cmd\">hg backout</command> "
11090 "command"
11091 msgstr "使用 <command role=\"hg-cmd\">hg backout</command> 恢复一个修改"
11093 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
11094 #: ../en/ch09-undo.xml:343
11095 msgid "<imageobject><imagedata fileref=\"figs/undo-simple.png\"/></imageobject>"
11096 msgstr ""
11098 #. type: Content of: <book><chapter><sect1><sect2><title>
11099 #: ../en/ch09-undo.xml:350
11100 msgid "Backing out a non-tip change"
11101 msgstr "恢复非顶点的修改"
11103 #. type: Content of: <book><chapter><sect1><sect2><para>
11104 #: ../en/ch09-undo.xml:352
11105 msgid ""
11106 "If you want to back out a change other than the last one you committed, pass "
11107 "the <option role=\"hg-opt-backout\">--merge</option> option to the <command "
11108 "role=\"hg-cmd\">hg backout</command> command."
11109 msgstr ""
11111 #. type: Content of: <book><chapter><sect1><sect2><para>
11112 #: ../en/ch09-undo.xml:359
11113 msgid ""
11114 "This makes backing out any changeset a <quote>one-shot</quote> operation "
11115 "that's usually simple and fast."
11116 msgstr ""
11118 #. type: Content of: <book><chapter><sect1><sect2><para>
11119 #: ../en/ch09-undo.xml:365
11120 msgid ""
11121 "If you take a look at the contents of <filename>myfile</filename> after the "
11122 "backout finishes, you'll see that the first and third changes are present, "
11123 "but not the second."
11124 msgstr ""
11126 #. type: Content of: <book><chapter><sect1><sect2><para>
11127 #: ../en/ch09-undo.xml:372
11128 msgid ""
11129 "As the graphical history in <xref linkend=\"fig:undo:backout-non-tip\"/> "
11130 "illustrates, Mercurial still commits one change in this kind of situation "
11131 "(the box-shaped node is the ones that Mercurial commits automatically), but "
11132 "the revision graph now looks different. Before Mercurial begins the backout "
11133 "process, it first remembers what the current parent of the working directory "
11134 "is. It then backs out the target changeset, and commits that as a "
11135 "changeset. Finally, it merges back to the previous parent of the working "
11136 "directory, but notice that it <emphasis>does not commit</emphasis> the result "
11137 "of the merge. The repository now contains two heads, and the working "
11138 "directory is in a merge state."
11139 msgstr ""
11141 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
11142 #: ../en/ch09-undo.xml:387
11143 msgid ""
11144 "Automated backout of a non-tip change using the <command role=\"hg-cmd\">hg "
11145 "backout</command> command"
11146 msgstr "使用 <command role=\"hg-cmd\">hg backout</command> 自动恢复非顶点的修改"
11148 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
11149 #: ../en/ch09-undo.xml:390
11150 msgid ""
11151 "<imageobject><imagedata fileref=\"figs/undo-non-tip.png\"/></imageobject>"
11152 msgstr ""
11154 #. type: Content of: <book><chapter><sect1><sect2><para>
11155 #: ../en/ch09-undo.xml:395
11156 msgid ""
11157 "The result is that you end up <quote>back where you were</quote>, only with "
11158 "some extra history that undoes the effect of the changeset you wanted to back "
11159 "out."
11160 msgstr ""
11162 #. type: Content of: <book><chapter><sect1><sect2><para>
11163 #: ../en/ch09-undo.xml:399
11164 msgid ""
11165 "You might wonder why Mercurial does not commit the result of the merge that "
11166 "it performed. The reason lies in Mercurial behaving conservatively: a merge "
11167 "naturally has more scope for error than simply undoing the effect of the tip "
11168 "changeset, so your work will be safest if you first inspect (and test!) the "
11169 "result of the merge, <emphasis>then</emphasis> commit it."
11170 msgstr ""
11172 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
11173 #: ../en/ch09-undo.xml:408
11174 msgid "Always use the <option role=\"hg-opt-backout\">--merge</option> option"
11175 msgstr "始终使用选项 <option role=\"hg-opt-backout\">--merge</option>"
11177 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11178 #: ../en/ch09-undo.xml:411
11179 msgid ""
11180 "In fact, since the <option role=\"hg-opt-backout\">--merge</option> option "
11181 "will do the <quote>right thing</quote> whether or not the changeset you're "
11182 "backing out is the tip (i.e. it won't try to merge if it's backing out the "
11183 "tip, since there's no need), you should <emphasis>always</emphasis> use this "
11184 "option when you run the <command role=\"hg-cmd\">hg backout</command> command."
11185 msgstr ""
11187 #. type: Content of: <book><chapter><sect1><sect2><title>
11188 #: ../en/ch09-undo.xml:422
11189 msgid "Gaining more control of the backout process"
11190 msgstr "在恢复处理中获得更多控制"
11192 #. type: Content of: <book><chapter><sect1><sect2><para>
11193 #: ../en/ch09-undo.xml:424
11194 msgid ""
11195 "While I've recommended that you always use the <option role=\"hg-opt-backout"
11196 "\">--merge</option> option when backing out a change, the <command role=\"hg-"
11197 "cmd\">hg backout</command> command lets you decide how to merge a backout "
11198 "changeset. Taking control of the backout process by hand is something you "
11199 "will rarely need to do, but it can be useful to understand what the <command "
11200 "role=\"hg-cmd\">hg backout</command> command is doing for you automatically. "
11201 "To illustrate this, let's clone our first repository, but omit the backout "
11202 "change that it contains."
11203 msgstr ""
11205 #. type: Content of: <book><chapter><sect1><sect2><para>
11206 #: ../en/ch09-undo.xml:437
11207 msgid ""
11208 "As with our earlier example, We'll commit a third changeset, then back out "
11209 "its parent, and see what happens."
11210 msgstr ""
11212 #. type: Content of: <book><chapter><sect1><sect2><para>
11213 #: ../en/ch09-undo.xml:443
11214 msgid ""
11215 "Our new changeset is again a descendant of the changeset we backout out; it's "
11216 "thus a new head, <emphasis>not</emphasis> a descendant of the changeset that "
11217 "was the tip. The <command role=\"hg-cmd\">hg backout</command> command was "
11218 "quite explicit in telling us this."
11219 msgstr ""
11221 #. type: Content of: <book><chapter><sect1><sect2><para>
11222 #: ../en/ch09-undo.xml:451
11223 msgid ""
11224 "Again, it's easier to see what has happened by looking at a graph of the "
11225 "revision history, in <xref linkend=\"fig:undo:backout-manual\"/>. This makes "
11226 "it clear that when we use <command role=\"hg-cmd\">hg backout</command> to "
11227 "back out a change other than the tip, Mercurial adds a new head to the "
11228 "repository (the change it committed is box-shaped)."
11229 msgstr ""
11231 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
11232 #: ../en/ch09-undo.xml:463
11233 msgid "<imageobject><imagedata fileref=\"figs/undo-manual.png\"/></imageobject>"
11234 msgstr ""
11236 #. type: Content of: <book><chapter><sect1><sect2><para>
11237 #: ../en/ch09-undo.xml:468
11238 msgid ""
11239 "After the <command role=\"hg-cmd\">hg backout</command> command has "
11240 "completed, it leaves the new <quote>backout</quote> changeset as the parent "
11241 "of the working directory."
11242 msgstr ""
11244 #. type: Content of: <book><chapter><sect1><sect2><para>
11245 #: ../en/ch09-undo.xml:475
11246 msgid "Now we have two isolated sets of changes."
11247 msgstr ""
11249 #. type: Content of: <book><chapter><sect1><sect2><para>
11250 #: ../en/ch09-undo.xml:479
11251 msgid ""
11252 "Let's think about what we expect to see as the contents of <filename>myfile</"
11253 "filename> now. The first change should be present, because we've never "
11254 "backed it out. The second change should be missing, as that's the change we "
11255 "backed out. Since the history graph shows the third change as a separate "
11256 "head, we <emphasis>don't</emphasis> expect to see the third change present in "
11257 "<filename>myfile</filename>."
11258 msgstr ""
11260 #. type: Content of: <book><chapter><sect1><sect2><para>
11261 #: ../en/ch09-undo.xml:489
11262 msgid ""
11263 "To get the third change back into the file, we just do a normal merge of our "
11264 "two heads."
11265 msgstr ""
11267 #. type: Content of: <book><chapter><sect1><sect2><para>
11268 #: ../en/ch09-undo.xml:494
11269 msgid ""
11270 "Afterwards, the graphical history of our repository looks like <xref linkend="
11271 "\"fig:undo:backout-manual-merge\"/>."
11272 msgstr ""
11274 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
11275 #: ../en/ch09-undo.xml:499
11276 msgid "Manually merging a backout change"
11277 msgstr "手工合并恢复修改"
11279 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
11280 #: ../en/ch09-undo.xml:501
11281 msgid ""
11282 "<imageobject><imagedata fileref=\"figs/undo-manual-merge.png\"/></imageobject>"
11283 msgstr ""
11285 #. type: Content of: <book><chapter><sect1><sect2><title>
11286 #: ../en/ch09-undo.xml:508
11287 msgid "Why <command role=\"hg-cmd\">hg backout</command> works as it does"
11288 msgstr "<command role=\"hg-cmd\">hg backout</command> 的内幕"
11290 #. type: Content of: <book><chapter><sect1><sect2><para>
11291 #: ../en/ch09-undo.xml:511
11292 msgid ""
11293 "Here's a brief description of how the <command role=\"hg-cmd\">hg backout</"
11294 "command> command works."
11295 msgstr ""
11297 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
11298 #: ../en/ch09-undo.xml:514
11299 msgid ""
11300 "It ensures that the working directory is <quote>clean</quote>, i.e. that the "
11301 "output of <command role=\"hg-cmd\">hg status</command> would be empty."
11302 msgstr ""
11304 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
11305 #: ../en/ch09-undo.xml:518
11306 msgid ""
11307 "It remembers the current parent of the working directory. Let's call this "
11308 "changeset <literal>orig</literal>."
11309 msgstr ""
11311 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
11312 #: ../en/ch09-undo.xml:522
11313 msgid ""
11314 "It does the equivalent of a <command role=\"hg-cmd\">hg update</command> to "
11315 "sync the working directory to the changeset you want to back out. Let's call "
11316 "this changeset <literal>backout</literal>."
11317 msgstr ""
11319 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
11320 #: ../en/ch09-undo.xml:527
11321 msgid ""
11322 "It finds the parent of that changeset. Let's call that changeset "
11323 "<literal>parent</literal>."
11324 msgstr ""
11326 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
11327 #: ../en/ch09-undo.xml:530
11328 msgid ""
11329 "For each file that the <literal>backout</literal> changeset affected, it does "
11330 "the equivalent of a <command role=\"hg-cmd\">hg revert -r parent</command> on "
11331 "that file, to restore it to the contents it had before that changeset was "
11332 "committed."
11333 msgstr ""
11335 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
11336 #: ../en/ch09-undo.xml:537
11337 msgid ""
11338 "It commits the result as a new changeset. This changeset has "
11339 "<literal>backout</literal> as its parent."
11340 msgstr ""
11342 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
11343 #: ../en/ch09-undo.xml:541
11344 msgid ""
11345 "If you specify <option role=\"hg-opt-backout\">--merge</option> on the "
11346 "command line, it merges with <literal>orig</literal>, and commits the result "
11347 "of the merge."
11348 msgstr ""
11350 #. type: Content of: <book><chapter><sect1><sect2><para>
11351 #: ../en/ch09-undo.xml:547
11352 msgid ""
11353 "An alternative way to implement the <command role=\"hg-cmd\">hg backout</"
11354 "command> command would be to <command role=\"hg-cmd\">hg export</command> the "
11355 "to-be-backed-out changeset as a diff, then use the <option role=\"cmd-opt-"
11356 "patch\">--reverse</option> option to the <command>patch</command> command to "
11357 "reverse the effect of the change without fiddling with the working "
11358 "directory. This sounds much simpler, but it would not work nearly as well."
11359 msgstr ""
11361 #. type: Content of: <book><chapter><sect1><sect2><para>
11362 #: ../en/ch09-undo.xml:557
11363 msgid ""
11364 "The reason that <command role=\"hg-cmd\">hg backout</command> does an update, "
11365 "a commit, a merge, and another commit is to give the merge machinery the best "
11366 "chance to do a good job when dealing with all the changes <emphasis>between</"
11367 "emphasis> the change you're backing out and the current tip."
11368 msgstr ""
11370 #. type: Content of: <book><chapter><sect1><sect2><para>
11371 #: ../en/ch09-undo.xml:564
11372 msgid ""
11373 "If you're backing out a changeset that's 100 revisions back in your project's "
11374 "history, the chances that the <command>patch</command> command will be able "
11375 "to apply a reverse diff cleanly are not good, because intervening changes are "
11376 "likely to have <quote>broken the context</quote> that <command>patch</"
11377 "command> uses to determine whether it can apply a patch (if this sounds like "
11378 "gibberish, see <xref linkend=\"sec:mq:patch\"/> for a discussion of the "
11379 "<command>patch</command> command). Also, Mercurial's merge machinery will "
11380 "handle files and directories being renamed, permission changes, and "
11381 "modifications to binary files, none of which <command>patch</command> can "
11382 "deal with."
11383 msgstr ""
11385 #. type: Content of: <book><chapter><sect1><title>
11386 #: ../en/ch09-undo.xml:581
11387 msgid "Changes that should never have been"
11388 msgstr "不该发生的修改"
11390 #. type: Content of: <book><chapter><sect1><para>
11391 #: ../en/ch09-undo.xml:583
11392 msgid ""
11393 "Most of the time, the <command role=\"hg-cmd\">hg backout</command> command "
11394 "is exactly what you need if you want to undo the effects of a change. It "
11395 "leaves a permanent record of exactly what you did, both when committing the "
11396 "original changeset and when you cleaned up after it."
11397 msgstr ""
11399 #. type: Content of: <book><chapter><sect1><para>
11400 #: ../en/ch09-undo.xml:589
11401 msgid ""
11402 "On rare occasions, though, you may find that you've committed a change that "
11403 "really should not be present in the repository at all. For example, it would "
11404 "be very unusual, and usually considered a mistake, to commit a software "
11405 "project's object files as well as its source files. Object files have almost "
11406 "no intrinsic value, and they're <emphasis>big</emphasis>, so they increase "
11407 "the size of the repository and the amount of time it takes to clone or pull "
11408 "changes."
11409 msgstr ""
11411 #. type: Content of: <book><chapter><sect1><para>
11412 #: ../en/ch09-undo.xml:598
11413 msgid ""
11414 "Before I discuss the options that you have if you commit a <quote>brown paper "
11415 "bag</quote> change (the kind that's so bad that you want to pull a brown "
11416 "paper bag over your head), let me first discuss some approaches that probably "
11417 "won't work."
11418 msgstr ""
11420 #. type: Content of: <book><chapter><sect1><para>
11421 #: ../en/ch09-undo.xml:603
11422 msgid ""
11423 "Since Mercurial treats history as accumulative&emdash;every change builds on "
11424 "top of all changes that preceded it&emdash;you generally can't just make "
11425 "disastrous changes disappear. The one exception is when you've just "
11426 "committed a change, and it hasn't been pushed or pulled into another "
11427 "repository. That's when you can safely use the <command role=\"hg-cmd\">hg "
11428 "rollback</command> command, as I detailed in <xref linkend=\"sec:undo:rollback"
11429 "\"/>."
11430 msgstr ""
11432 #. type: Content of: <book><chapter><sect1><para>
11433 #: ../en/ch09-undo.xml:612
11434 msgid ""
11435 "After you've pushed a bad change to another repository, you <emphasis>could</"
11436 "emphasis> still use <command role=\"hg-cmd\">hg rollback</command> to make "
11437 "your local copy of the change disappear, but it won't have the consequences "
11438 "you want. The change will still be present in the remote repository, so it "
11439 "will reappear in your local repository the next time you pull."
11440 msgstr ""
11442 #. type: Content of: <book><chapter><sect1><para>
11443 #: ../en/ch09-undo.xml:620
11444 msgid ""
11445 "If a situation like this arises, and you know which repositories your bad "
11446 "change has propagated into, you can <emphasis>try</emphasis> to get rid of "
11447 "the change from <emphasis>every</emphasis> one of those repositories. This "
11448 "is, of course, not a satisfactory solution: if you miss even a single "
11449 "repository while you're expunging, the change is still <quote>in the wild</"
11450 "quote>, and could propagate further."
11451 msgstr ""
11453 #. type: Content of: <book><chapter><sect1><para>
11454 #: ../en/ch09-undo.xml:628
11455 msgid ""
11456 "If you've committed one or more changes <emphasis>after</emphasis> the change "
11457 "that you'd like to see disappear, your options are further reduced. Mercurial "
11458 "doesn't provide a way to <quote>punch a hole</quote> in history, leaving "
11459 "changesets intact."
11460 msgstr ""
11462 #. type: Content of: <book><chapter><sect1><sect2><title>
11463 #: ../en/ch09-undo.xml:635
11464 msgid "Backing out a merge"
11465 msgstr "撤销一个合并"
11467 #. type: Content of: <book><chapter><sect1><sect2><para>
11468 #: ../en/ch09-undo.xml:637
11469 msgid ""
11470 "Since merges are often complicated, it is not unheard of for a merge to be "
11471 "mangled badly, but committed erroneously. Mercurial provides an important "
11472 "safeguard against bad merges by refusing to commit unresolved files, but "
11473 "human ingenuity guarantees that it is still possible to mess a merge up and "
11474 "commit it."
11475 msgstr ""
11477 #. type: Content of: <book><chapter><sect1><sect2><para>
11478 #: ../en/ch09-undo.xml:644
11479 msgid ""
11480 "Given a bad merge that has been committed, usually the best way to approach "
11481 "it is to simply try to repair the damage by hand. A complete disaster that "
11482 "cannot be easily fixed up by hand ought to be very rare, but the <command "
11483 "role=\"hg-cmd\">hg backout</command> command may help in making the cleanup "
11484 "easier. It offers a <option role=\"hg-opt-backout\">--parent</option> option, "
11485 "which lets you specify which parent to revert to when backing out a merge."
11486 msgstr ""
11488 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
11489 #: ../en/ch09-undo.xml:655
11490 msgid "A bad merge"
11491 msgstr "错误的合并"
11493 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
11494 #: ../en/ch09-undo.xml:657
11495 msgid "<imageobject><imagedata fileref=\"figs/bad-merge-1.png\"/></imageobject>"
11496 msgstr ""
11498 #. type: Content of: <book><chapter><sect1><sect2><para>
11499 #: ../en/ch09-undo.xml:662
11500 msgid ""
11501 "Suppose we have a revision graph like that in <xref linkend=\"fig:undo:bad-"
11502 "merge-1\"/>. What we'd like is to <emphasis>redo</emphasis> the merge of "
11503 "revisions 2 and 3."
11504 msgstr ""
11506 #. type: Content of: <book><chapter><sect1><sect2><para>
11507 #: ../en/ch09-undo.xml:667
11508 msgid "One way to do so would be as follows."
11509 msgstr ""
11511 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
11512 #: ../en/ch09-undo.xml:671
11513 msgid ""
11514 "Call <command role=\"hg-cmd\">hg backout --rev=4 --parent=2</command>. This "
11515 "tells <command role=\"hg-cmd\">hg backout</command> to back out revision 4, "
11516 "which is the bad merge, and to when deciding which revision to prefer, to "
11517 "choose parent 2, one of the parents of the merge. The effect can be seen in "
11518 "<xref linkend=\"fig:undo:bad-merge-2\"/>."
11519 msgstr ""
11521 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><figure><title>
11522 #: ../en/ch09-undo.xml:679
11523 msgid "Backing out the merge, favoring one parent"
11524 msgstr "拆除合并,关注一个父亲"
11526 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><figure><mediaobject>
11527 #: ../en/ch09-undo.xml:681
11528 msgid "<imageobject><imagedata fileref=\"figs/bad-merge-2.png\"/></imageobject>"
11529 msgstr ""
11530 "<imageobject><imagedata fileref=\"figs/bad-merge-2.png\"/></imageobject>"
11532 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
11533 #: ../en/ch09-undo.xml:688
11534 msgid ""
11535 "Call <command role=\"hg-cmd\">hg backout --rev=4 --parent=3</command>. This "
11536 "tells <command role=\"hg-cmd\">hg backout</command> to back out revision 4 "
11537 "again, but this time to choose parent 3, the other parent of the merge. The "
11538 "result is visible in <xref linkend=\"fig:undo:bad-merge-3\"/>, in which the "
11539 "repository now contains three heads."
11540 msgstr ""
11542 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><figure><title>
11543 #: ../en/ch09-undo.xml:696
11544 msgid "Backing out the merge, favoring the other parent"
11545 msgstr "拆除合并,关注其它父亲"
11547 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><figure><mediaobject>
11548 #: ../en/ch09-undo.xml:699
11549 msgid "<imageobject><imagedata fileref=\"figs/bad-merge-3.png\"/></imageobject>"
11550 msgstr ""
11551 "<imageobject><imagedata fileref=\"figs/bad-merge-3.png\"/></imageobject>"
11553 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
11554 #: ../en/ch09-undo.xml:706
11555 msgid ""
11556 "Redo the bad merge by merging the two backout heads, which reduces the number "
11557 "of heads in the repository to two, as can be seen in <xref linkend=\"fig:undo:"
11558 "bad-merge-4\"/>."
11559 msgstr ""
11561 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><figure><title>
11562 #: ../en/ch09-undo.xml:711 ../en/ch09-undo.xml:724
11563 msgid "Merging the backouts"
11564 msgstr "合并拆除"
11566 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><figure><mediaobject>
11567 #: ../en/ch09-undo.xml:713
11568 msgid "<imageobject><imagedata fileref=\"figs/bad-merge-4.png\"/></imageobject>"
11569 msgstr ""
11570 "<imageobject><imagedata fileref=\"figs/bad-merge-4.png\"/></imageobject>"
11572 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
11573 #: ../en/ch09-undo.xml:720
11574 msgid ""
11575 "Merge with the commit that was made after the bad merge, as shown in <xref "
11576 "linkend=\"fig:undo:bad-merge-5\"/>."
11577 msgstr ""
11579 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><figure><mediaobject>
11580 #: ../en/ch09-undo.xml:726
11581 msgid "<imageobject><imagedata fileref=\"figs/bad-merge-5.png\"/></imageobject>"
11582 msgstr ""
11584 #. type: Content of: <book><chapter><sect1><sect2><title>
11585 #: ../en/ch09-undo.xml:735
11586 msgid "Protect yourself from <quote>escaped</quote> changes"
11587 msgstr "使用<quote>校验</quote>修改来保护你自己"
11589 #. type: Content of: <book><chapter><sect1><sect2><para>
11590 #: ../en/ch09-undo.xml:738
11591 msgid ""
11592 "If you've committed some changes to your local repository and they've been "
11593 "pushed or pulled somewhere else, this isn't necessarily a disaster. You can "
11594 "protect yourself ahead of time against some classes of bad changeset. This "
11595 "is particularly easy if your team usually pulls changes from a central "
11596 "repository."
11597 msgstr ""
11599 #. type: Content of: <book><chapter><sect1><sect2><para>
11600 #: ../en/ch09-undo.xml:745
11601 msgid ""
11602 "By configuring some hooks on that repository to validate incoming changesets "
11603 "(see chapter <xref linkend=\"chap:hook\"/>), you can automatically prevent "
11604 "some kinds of bad changeset from being pushed to the central repository at "
11605 "all. With such a configuration in place, some kinds of bad changeset will "
11606 "naturally tend to <quote>die out</quote> because they can't propagate into "
11607 "the central repository. Better yet, this happens without any need for "
11608 "explicit intervention."
11609 msgstr ""
11611 #. type: Content of: <book><chapter><sect1><sect2><para>
11612 #: ../en/ch09-undo.xml:755
11613 msgid ""
11614 "For instance, an incoming change hook that verifies that a changeset will "
11615 "actually compile can prevent people from inadvertently <quote>breaking the "
11616 "build</quote>."
11617 msgstr ""
11619 #. type: Content of: <book><chapter><sect1><sect2><title>
11620 #: ../en/ch09-undo.xml:762
11621 msgid "What to do about sensitive changes that escape"
11622 msgstr "处理敏感信息泄漏的方法"
11624 #. type: Content of: <book><chapter><sect1><sect2><para>
11625 #: ../en/ch09-undo.xml:764
11626 msgid ""
11627 "Even a carefully run project can suffer an unfortunate event such as the "
11628 "committing and uncontrolled propagation of a file that contains important "
11629 "passwords."
11630 msgstr ""
11632 #. type: Content of: <book><chapter><sect1><sect2><para>
11633 #: ../en/ch09-undo.xml:768
11634 msgid ""
11635 "If something like this happens to you, and the information that gets "
11636 "accidentally propagated is truly sensitive, your first step should be to "
11637 "mitigate the effect of the leak without trying to control the leak itself. If "
11638 "you are not 100% certain that you know exactly who could have seen the "
11639 "changes, you should immediately change passwords, cancel credit cards, or "
11640 "find some other way to make sure that the information that has leaked is no "
11641 "longer useful. In other words, assume that the change has propagated far and "
11642 "wide, and that there's nothing more you can do."
11643 msgstr ""
11645 #. type: Content of: <book><chapter><sect1><sect2><para>
11646 #: ../en/ch09-undo.xml:779
11647 msgid ""
11648 "You might hope that there would be mechanisms you could use to either figure "
11649 "out who has seen a change or to erase the change permanently everywhere, but "
11650 "there are good reasons why these are not possible."
11651 msgstr ""
11653 #. type: Content of: <book><chapter><sect1><sect2><para>
11654 #: ../en/ch09-undo.xml:784
11655 msgid ""
11656 "Mercurial does not provide an audit trail of who has pulled changes from a "
11657 "repository, because it is usually either impossible to record such "
11658 "information or trivial to spoof it. In a multi-user or networked "
11659 "environment, you should thus be extremely skeptical of yourself if you think "
11660 "that you have identified every place that a sensitive changeset has "
11661 "propagated to. Don't forget that people can and will send bundles by email, "
11662 "have their backup software save data offsite, carry repositories on USB "
11663 "sticks, and find other completely innocent ways to confound your attempts to "
11664 "track down every copy of a problematic change."
11665 msgstr ""
11667 #. type: Content of: <book><chapter><sect1><sect2><para>
11668 #: ../en/ch09-undo.xml:796
11669 msgid ""
11670 "Mercurial also does not provide a way to make a file or changeset completely "
11671 "disappear from history, because there is no way to enforce its disappearance; "
11672 "someone could easily modify their copy of Mercurial to ignore such "
11673 "directives. In addition, even if Mercurial provided such a capability, "
11674 "someone who simply hadn't pulled a <quote>make this file disappear</quote> "
11675 "changeset wouldn't be affected by it, nor would web crawlers visiting at the "
11676 "wrong time, disk backups, or other mechanisms. Indeed, no distributed "
11677 "revision control system can make data reliably vanish. Providing the illusion "
11678 "of such control could easily give a false sense of security, and be worse "
11679 "than not providing it at all."
11680 msgstr ""
11682 #. type: Content of: <book><chapter><sect1><title>
11683 #: ../en/ch09-undo.xml:812
11684 msgid "Finding the source of a bug"
11685 msgstr "查找问题的根源"
11687 #. type: Content of: <book><chapter><sect1><para>
11688 #: ../en/ch09-undo.xml:814
11689 msgid ""
11690 "While it's all very well to be able to back out a changeset that introduced a "
11691 "bug, this requires that you know which changeset to back out. Mercurial "
11692 "provides an invaluable command, called <command role=\"hg-cmd\">hg bisect</"
11693 "command>, that helps you to automate this process and accomplish it very "
11694 "efficiently."
11695 msgstr ""
11697 #. type: Content of: <book><chapter><sect1><para>
11698 #: ../en/ch09-undo.xml:821
11699 msgid ""
11700 "The idea behind the <command role=\"hg-cmd\">hg bisect</command> command is "
11701 "that a changeset has introduced some change of behavior that you can identify "
11702 "with a simple pass/fail test. You don't know which piece of code introduced "
11703 "the change, but you know how to test for the presence of the bug. The "
11704 "<command role=\"hg-cmd\">hg bisect</command> command uses your test to direct "
11705 "its search for the changeset that introduced the code that caused the bug."
11706 msgstr ""
11708 #. type: Content of: <book><chapter><sect1><para>
11709 #: ../en/ch09-undo.xml:830
11710 msgid ""
11711 "Here are a few scenarios to help you understand how you might apply this "
11712 "command."
11713 msgstr ""
11715 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
11716 #: ../en/ch09-undo.xml:833
11717 msgid ""
11718 "The most recent version of your software has a bug that you remember wasn't "
11719 "present a few weeks ago, but you don't know when it was introduced. Here, "
11720 "your binary test checks for the presence of that bug."
11721 msgstr ""
11723 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
11724 #: ../en/ch09-undo.xml:838
11725 msgid ""
11726 "You fixed a bug in a rush, and now it's time to close the entry in your "
11727 "team's bug database. The bug database requires a changeset ID when you close "
11728 "an entry, but you don't remember which changeset you fixed the bug in. Once "
11729 "again, your binary test checks for the presence of the bug."
11730 msgstr ""
11732 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
11733 #: ../en/ch09-undo.xml:845
11734 msgid ""
11735 "Your software works correctly, but runs 15% slower than the last time you "
11736 "measured it. You want to know which changeset introduced the performance "
11737 "regression. In this case, your binary test measures the performance of your "
11738 "software, to see whether it's <quote>fast</quote> or <quote>slow</quote>."
11739 msgstr ""
11741 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
11742 #: ../en/ch09-undo.xml:852
11743 msgid ""
11744 "The sizes of the components of your project that you ship exploded recently, "
11745 "and you suspect that something changed in the way you build your project."
11746 msgstr ""
11748 #. type: Content of: <book><chapter><sect1><para>
11749 #: ../en/ch09-undo.xml:857
11750 msgid ""
11751 "From these examples, it should be clear that the <command role=\"hg-cmd\">hg "
11752 "bisect</command> command is not useful only for finding the sources of bugs. "
11753 "You can use it to find any <quote>emergent property</quote> of a repository "
11754 "(anything that you can't find from a simple text search of the files in the "
11755 "tree) for which you can write a binary test."
11756 msgstr ""
11758 #. type: Content of: <book><chapter><sect1><para>
11759 #: ../en/ch09-undo.xml:864
11760 msgid ""
11761 "We'll introduce a little bit of terminology here, just to make it clear which "
11762 "parts of the search process are your responsibility, and which are "
11763 "Mercurial's. A <emphasis>test</emphasis> is something that <emphasis>you</"
11764 "emphasis> run when <command role=\"hg-cmd\">hg bisect</command> chooses a "
11765 "changeset. A <emphasis>probe</emphasis> is what <command role=\"hg-cmd\">hg "
11766 "bisect</command> runs to tell whether a revision is good. Finally, we'll use "
11767 "the word <quote>bisect</quote>, as both a noun and a verb, to stand in for "
11768 "the phrase <quote>search using the <command role=\"hg-cmd\">hg bisect</"
11769 "command> command</quote>."
11770 msgstr ""
11772 #. type: Content of: <book><chapter><sect1><para>
11773 #: ../en/ch09-undo.xml:877
11774 msgid ""
11775 "One simple way to automate the searching process would be simply to probe "
11776 "every changeset. However, this scales poorly. If it took ten minutes to "
11777 "test a single changeset, and you had 10,000 changesets in your repository, "
11778 "the exhaustive approach would take on average 35 <emphasis>days</emphasis> to "
11779 "find the changeset that introduced a bug. Even if you knew that the bug was "
11780 "introduced by one of the last 500 changesets, and limited your search to "
11781 "those, you'd still be looking at over 40 hours to find the changeset that "
11782 "introduced your bug."
11783 msgstr ""
11785 #. type: Content of: <book><chapter><sect1><para>
11786 #: ../en/ch09-undo.xml:887
11787 msgid ""
11788 "What the <command role=\"hg-cmd\">hg bisect</command> command does is use its "
11789 "knowledge of the <quote>shape</quote> of your project's revision history to "
11790 "perform a search in time proportional to the <emphasis>logarithm</emphasis> "
11791 "of the number of changesets to check (the kind of search it performs is "
11792 "called a dichotomic search). With this approach, searching through 10,000 "
11793 "changesets will take less than three hours, even at ten minutes per test (the "
11794 "search will require about 14 tests). Limit your search to the last hundred "
11795 "changesets, and it will take only about an hour (roughly seven tests)."
11796 msgstr ""
11798 #. type: Content of: <book><chapter><sect1><para>
11799 #: ../en/ch09-undo.xml:898
11800 msgid ""
11801 "The <command role=\"hg-cmd\">hg bisect</command> command is aware of the "
11802 "<quote>branchy</quote> nature of a Mercurial project's revision history, so "
11803 "it has no problems dealing with branches, merges, or multiple heads in a "
11804 "repository. It can prune entire branches of history with a single probe, "
11805 "which is how it operates so efficiently."
11806 msgstr ""
11808 #. type: Content of: <book><chapter><sect1><sect2><title>
11809 #: ../en/ch09-undo.xml:906
11810 msgid "Using the <command role=\"hg-cmd\">hg bisect</command> command"
11811 msgstr "使用命令 <command role=\"hg-cmd\">hg bisect</command>"
11813 #. type: Content of: <book><chapter><sect1><sect2><para>
11814 #: ../en/ch09-undo.xml:909
11815 msgid ""
11816 "Here's an example of <command role=\"hg-cmd\">hg bisect</command> in action."
11817 msgstr ""
11819 #. type: Content of: <book><chapter><sect1><sect2><note><para>
11820 #: ../en/ch09-undo.xml:913
11821 msgid ""
11822 "In versions 0.9.5 and earlier of Mercurial, <command role=\"hg-cmd\">hg "
11823 "bisect</command> was not a core command: it was distributed with Mercurial as "
11824 "an extension. This section describes the built-in command, not the old "
11825 "extension."
11826 msgstr ""
11828 #. type: Content of: <book><chapter><sect1><sect2><para>
11829 #: ../en/ch09-undo.xml:920
11830 msgid ""
11831 "Now let's create a repository, so that we can try out the <command role=\"hg-"
11832 "cmd\">hg bisect</command> command in isolation."
11833 msgstr ""
11835 #. type: Content of: <book><chapter><sect1><sect2><para>
11836 #: ../en/ch09-undo.xml:926
11837 msgid ""
11838 "We'll simulate a project that has a bug in it in a simple-minded way: create "
11839 "trivial changes in a loop, and nominate one specific change that will have "
11840 "the <quote>bug</quote>. This loop creates 35 changesets, each adding a "
11841 "single file to the repository. We'll represent our <quote>bug</quote> with a "
11842 "file that contains the text <quote>i have a gub</quote>."
11843 msgstr ""
11845 #. type: Content of: <book><chapter><sect1><sect2><para>
11846 #: ../en/ch09-undo.xml:936
11847 msgid ""
11848 "The next thing that we'd like to do is figure out how to use the <command "
11849 "role=\"hg-cmd\">hg bisect</command> command. We can use Mercurial's normal "
11850 "built-in help mechanism for this."
11851 msgstr ""
11853 #. type: Content of: <book><chapter><sect1><sect2><para>
11854 #: ../en/ch09-undo.xml:943
11855 msgid ""
11856 "The <command role=\"hg-cmd\">hg bisect</command> command works in steps. "
11857 "Each step proceeds as follows."
11858 msgstr ""
11860 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
11861 #: ../en/ch09-undo.xml:946
11862 msgid "You run your binary test."
11863 msgstr ""
11865 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><itemizedlist><listitem><para>
11866 #: ../en/ch09-undo.xml:948
11867 msgid ""
11868 "If the test succeeded, you tell <command role=\"hg-cmd\">hg bisect</command> "
11869 "by running the <command role=\"hg-cmd\">hg bisect --good</command> command."
11870 msgstr ""
11871 "当测试成功后,使用 <command role=\"hg-cmd\">hg bisect --good</command> 命令告"
11872 "诉 <command role=\"hg-cmd\">hg bisect</command> 命令。"
11874 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><itemizedlist><listitem><para>
11875 #: ../en/ch09-undo.xml:953
11876 msgid ""
11877 "If it failed, run the <command role=\"hg-cmd\">hg bisect --bad</command> "
11878 "command."
11879 msgstr ""
11880 "如果失败,执行 <command role=\"hg-cmd\">hg bisect --bad</command> 命令。"
11882 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
11883 #: ../en/ch09-undo.xml:957
11884 msgid ""
11885 "The command uses your information to decide which changeset to test next."
11886 msgstr ""
11888 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
11889 #: ../en/ch09-undo.xml:960
11890 msgid ""
11891 "It updates the working directory to that changeset, and the process begins "
11892 "again."
11893 msgstr ""
11895 #. type: Content of: <book><chapter><sect1><sect2><para>
11896 #: ../en/ch09-undo.xml:963
11897 msgid ""
11898 "The process ends when <command role=\"hg-cmd\">hg bisect</command> identifies "
11899 "a unique changeset that marks the point where your test transitioned from "
11900 "<quote>succeeding</quote> to <quote>failing</quote>."
11901 msgstr ""
11904 #. type: Content of: <book><chapter><sect1><sect2><para>
11905 #: ../en/ch09-undo.xml:968
11906 msgid ""
11907 "To start the search, we must run the <command role=\"hg-cmd\">hg bisect --"
11908 "reset</command> command."
11909 msgstr ""
11911 #. type: Content of: <book><chapter><sect1><sect2><para>
11912 #: ../en/ch09-undo.xml:973
11913 msgid ""
11914 "In our case, the binary test we use is simple: we check to see if any file in "
11915 "the repository contains the string <quote>i have a gub</quote>. If it does, "
11916 "this changeset contains the change that <quote>caused the bug</quote>. By "
11917 "convention, a changeset that has the property we're searching for is "
11918 "<quote>bad</quote>, while one that doesn't is <quote>good</quote>."
11919 msgstr ""
11921 #. type: Content of: <book><chapter><sect1><sect2><para>
11922 #: ../en/ch09-undo.xml:981
11923 msgid ""
11924 "Most of the time, the revision to which the working directory is synced "
11925 "(usually the tip) already exhibits the problem introduced by the buggy "
11926 "change, so we'll mark it as <quote>bad</quote>."
11927 msgstr ""
11930 #. type: Content of: <book><chapter><sect1><sect2><para>
11931 #: ../en/ch09-undo.xml:988
11932 msgid ""
11933 "Our next task is to nominate a changeset that we know <emphasis>doesn't</"
11934 "emphasis> have the bug; the <command role=\"hg-cmd\">hg bisect</command> "
11935 "command will <quote>bracket</quote> its search between the first pair of good "
11936 "and bad changesets. In our case, we know that revision 10 didn't have the "
11937 "bug. (I'll have more words about choosing the first <quote>good</quote> "
11938 "changeset later.)"
11939 msgstr ""
11941 #. type: Content of: <book><chapter><sect1><sect2><para>
11942 #: ../en/ch09-undo.xml:998
11943 msgid "Notice that this command printed some output."
11944 msgstr ""
11946 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
11947 #: ../en/ch09-undo.xml:1000
11948 msgid ""
11949 "It told us how many changesets it must consider before it can identify the "
11950 "one that introduced the bug, and how many tests that will require."
11951 msgstr ""
11953 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
11954 #: ../en/ch09-undo.xml:1004
11955 msgid ""
11956 "It updated the working directory to the next changeset to test, and told us "
11957 "which changeset it's testing."
11958 msgstr ""
11960 #. type: Content of: <book><chapter><sect1><sect2><para>
11961 #: ../en/ch09-undo.xml:1009
11962 msgid ""
11963 "We now run our test in the working directory. We use the <command>grep</"
11964 "command> command to see if our <quote>bad</quote> file is present in the "
11965 "working directory. If it is, this revision is bad; if not, this revision is "
11966 "good. &interaction.bisect.search.step1;"
11967 msgstr ""
11969 #. type: Content of: <book><chapter><sect1><sect2><para>
11970 #: ../en/ch09-undo.xml:1015
11971 msgid ""
11972 "This test looks like a perfect candidate for automation, so let's turn it "
11973 "into a shell function."
11974 msgstr ""
11976 #. type: Content of: <book><chapter><sect1><sect2><para>
11977 #: ../en/ch09-undo.xml:1019
11978 msgid ""
11979 "We can now run an entire test step with a single command, <literal>mytest</"
11980 "literal>."
11981 msgstr ""
11983 #. type: Content of: <book><chapter><sect1><sect2><para>
11984 #: ../en/ch09-undo.xml:1024
11985 msgid "A few more invocations of our canned test step command, and we're done."
11986 msgstr ""
11988 #. type: Content of: <book><chapter><sect1><sect2><para>
11989 #: ../en/ch09-undo.xml:1029
11990 msgid ""
11991 "Even though we had 40 changesets to search through, the <command role=\"hg-cmd"
11992 "\">hg bisect</command> command let us find the changeset that introduced our "
11993 "<quote>bug</quote> with only five tests. Because the number of tests that "
11994 "the <command role=\"hg-cmd\">hg bisect</command> command performs grows "
11995 "logarithmically with the number of changesets to search, the advantage that "
11996 "it has over the <quote>brute force</quote> search approach increases with "
11997 "every changeset you add."
11998 msgstr ""
12000 #. type: Content of: <book><chapter><sect1><sect2><title>
12001 #: ../en/ch09-undo.xml:1040
12002 msgid "Cleaning up after your search"
12003 msgstr "搜索后的清理"
12005 #. type: Content of: <book><chapter><sect1><sect2><para>
12006 #: ../en/ch09-undo.xml:1042
12007 msgid ""
12008 "When you're finished using the <command role=\"hg-cmd\">hg bisect</command> "
12009 "command in a repository, you can use the <command role=\"hg-cmd\">hg bisect --"
12010 "reset</command> command to drop the information it was using to drive your "
12011 "search. The command doesn't use much space, so it doesn't matter if you "
12012 "forget to run this command. However, <command role=\"hg-cmd\">hg bisect</"
12013 "command> won't let you start a new search in that repository until you do a "
12014 "<command role=\"hg-cmd\">hg bisect --reset</command>."
12015 msgstr ""
12017 #. type: Content of: <book><chapter><sect1><title>
12018 #: ../en/ch09-undo.xml:1057
12019 msgid "Tips for finding bugs effectively"
12020 msgstr "有效查找问题的技巧"
12022 #. type: Content of: <book><chapter><sect1><sect2><title>
12023 #: ../en/ch09-undo.xml:1060
12024 msgid "Give consistent input"
12025 msgstr "给出一致的输入"
12027 #. type: Content of: <book><chapter><sect1><sect2><para>
12028 #: ../en/ch09-undo.xml:1062
12029 msgid ""
12030 "The <command role=\"hg-cmd\">hg bisect</command> command requires that you "
12031 "correctly report the result of every test you perform. If you tell it that a "
12032 "test failed when it really succeeded, it <emphasis>might</emphasis> be able "
12033 "to detect the inconsistency. If it can identify an inconsistency in your "
12034 "reports, it will tell you that a particular changeset is both good and bad. "
12035 "However, it can't do this perfectly; it's about as likely to report the wrong "
12036 "changeset as the source of the bug."
12037 msgstr ""
12039 #. type: Content of: <book><chapter><sect1><sect2><title>
12040 #: ../en/ch09-undo.xml:1074
12041 msgid "Automate as much as possible"
12042 msgstr "尽量自动"
12044 #. type: Content of: <book><chapter><sect1><sect2><para>
12045 #: ../en/ch09-undo.xml:1076
12046 msgid ""
12047 "When I started using the <command role=\"hg-cmd\">hg bisect</command> "
12048 "command, I tried a few times to run my tests by hand, on the command line. "
12049 "This is an approach that I, at least, am not suited to. After a few tries, I "
12050 "found that I was making enough mistakes that I was having to restart my "
12051 "searches several times before finally getting correct results."
12052 msgstr ""
12054 #. type: Content of: <book><chapter><sect1><sect2><para>
12055 #: ../en/ch09-undo.xml:1084
12056 msgid ""
12057 "My initial problems with driving the <command role=\"hg-cmd\">hg bisect</"
12058 "command> command by hand occurred even with simple searches on small "
12059 "repositories; if the problem you're looking for is more subtle, or the number "
12060 "of tests that <command role=\"hg-cmd\">hg bisect</command> must perform "
12061 "increases, the likelihood of operator error ruining the search is much "
12062 "higher. Once I started automating my tests, I had much better results."
12063 msgstr ""
12065 #. type: Content of: <book><chapter><sect1><sect2><para>
12066 #: ../en/ch09-undo.xml:1093
12067 msgid "The key to automated testing is twofold:"
12068 msgstr ""
12070 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12071 #: ../en/ch09-undo.xml:1095
12072 msgid "always test for the same symptom, and"
12073 msgstr ""
12075 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12076 #: ../en/ch09-undo.xml:1097
12077 msgid ""
12078 "always feed consistent input to the <command role=\"hg-cmd\">hg bisect</"
12079 "command> command."
12080 msgstr ""
12082 #. type: Content of: <book><chapter><sect1><sect2><para>
12083 #: ../en/ch09-undo.xml:1100
12084 msgid ""
12085 "In my tutorial example above, the <command>grep</command> command tests for "
12086 "the symptom, and the <literal>if</literal> statement takes the result of this "
12087 "check and ensures that we always feed the same input to the <command role="
12088 "\"hg-cmd\">hg bisect</command> command. The <literal>mytest</literal> "
12089 "function marries these together in a reproducible way, so that every test is "
12090 "uniform and consistent."
12091 msgstr ""
12093 #. type: Content of: <book><chapter><sect1><sect2><title>
12094 #: ../en/ch09-undo.xml:1110
12095 msgid "Check your results"
12096 msgstr "检查你的结果"
12098 #. type: Content of: <book><chapter><sect1><sect2><para>
12099 #: ../en/ch09-undo.xml:1112
12100 msgid ""
12101 "Because the output of a <command role=\"hg-cmd\">hg bisect</command> search "
12102 "is only as good as the input you give it, don't take the changeset it reports "
12103 "as the absolute truth. A simple way to cross-check its report is to manually "
12104 "run your test at each of the following changesets:"
12105 msgstr ""
12107 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12108 #: ../en/ch09-undo.xml:1118
12109 msgid ""
12110 "The changeset that it reports as the first bad revision. Your test should "
12111 "still report this as bad."
12112 msgstr ""
12114 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12115 #: ../en/ch09-undo.xml:1122
12116 msgid ""
12117 "The parent of that changeset (either parent, if it's a merge). Your test "
12118 "should report this changeset as good."
12119 msgstr ""
12121 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12122 #: ../en/ch09-undo.xml:1126
12123 msgid ""
12124 "A child of that changeset. Your test should report this changeset as bad."
12125 msgstr ""
12127 #. type: Content of: <book><chapter><sect1><sect2><title>
12128 #: ../en/ch09-undo.xml:1132
12129 msgid "Beware interference between bugs"
12130 msgstr "谨防问题之间的冲突"
12132 #. type: Content of: <book><chapter><sect1><sect2><para>
12133 #: ../en/ch09-undo.xml:1134
12134 msgid ""
12135 "It's possible that your search for one bug could be disrupted by the presence "
12136 "of another. For example, let's say your software crashes at revision 100, "
12137 "and worked correctly at revision 50. Unknown to you, someone else introduced "
12138 "a different crashing bug at revision 60, and fixed it at revision 80. This "
12139 "could distort your results in one of several ways."
12140 msgstr ""
12142 #. type: Content of: <book><chapter><sect1><sect2><para>
12143 #: ../en/ch09-undo.xml:1142
12144 msgid ""
12145 "It is possible that this other bug completely <quote>masks</quote> yours, "
12146 "which is to say that it occurs before your bug has a chance to manifest "
12147 "itself. If you can't avoid that other bug (for example, it prevents your "
12148 "project from building), and so can't tell whether your bug is present in a "
12149 "particular changeset, the <command role=\"hg-cmd\">hg bisect</command> "
12150 "command cannot help you directly. Instead, you can mark a changeset as "
12151 "untested by running <command role=\"hg-cmd\">hg bisect --skip</command>."
12152 msgstr ""
12154 #. type: Content of: <book><chapter><sect1><sect2><para>
12155 #: ../en/ch09-undo.xml:1152
12156 msgid ""
12157 "A different problem could arise if your test for a bug's presence is not "
12158 "specific enough. If you check for <quote>my program crashes</quote>, then "
12159 "both your crashing bug and an unrelated crashing bug that masks it will look "
12160 "like the same thing, and mislead <command role=\"hg-cmd\">hg bisect</command>."
12161 msgstr ""
12163 #. type: Content of: <book><chapter><sect1><sect2><para>
12164 #: ../en/ch09-undo.xml:1159
12165 msgid ""
12166 "Another useful situation in which to use <command role=\"hg-cmd\">hg bisect --"
12167 "skip</command> is if you can't test a revision because your project was in a "
12168 "broken and hence untestable state at that revision, perhaps because someone "
12169 "checked in a change that prevented the project from building."
12170 msgstr ""
12172 #. type: Content of: <book><chapter><sect1><sect2><title>
12173 #: ../en/ch09-undo.xml:1168
12174 msgid "Bracket your search lazily"
12175 msgstr "减少你的查找工作"
12177 #. type: Content of: <book><chapter><sect1><sect2><para>
12178 #: ../en/ch09-undo.xml:1170
12179 msgid ""
12180 "Choosing the first <quote>good</quote> and <quote>bad</quote> changesets that "
12181 "will mark the end points of your search is often easy, but it bears a little "
12182 "discussion nevertheless. From the perspective of <command role=\"hg-cmd\">hg "
12183 "bisect</command>, the <quote>newest</quote> changeset is conventionally "
12184 "<quote>bad</quote>, and the older changeset is <quote>good</quote>."
12185 msgstr ""
12187 #. type: Content of: <book><chapter><sect1><sect2><para>
12188 #: ../en/ch09-undo.xml:1178
12189 msgid ""
12190 "If you're having trouble remembering when a suitable <quote>good</quote> "
12191 "change was, so that you can tell <command role=\"hg-cmd\">hg bisect</"
12192 "command>, you could do worse than testing changesets at random. Just "
12193 "remember to eliminate contenders that can't possibly exhibit the bug (perhaps "
12194 "because the feature with the bug isn't present yet) and those where another "
12195 "problem masks the bug (as I discussed above)."
12196 msgstr ""
12198 #. type: Content of: <book><chapter><sect1><sect2><para>
12199 #: ../en/ch09-undo.xml:1187
12200 msgid ""
12201 "Even if you end up <quote>early</quote> by thousands of changesets or months "
12202 "of history, you will only add a handful of tests to the total number that "
12203 "<command role=\"hg-cmd\">hg bisect</command> must perform, thanks to its "
12204 "logarithmic behavior."
12205 msgstr ""
12207 #. type: Content of: <book><chapter><title>
12208 #: ../en/ch10-hook.xml:5
12209 msgid "Handling repository events with hooks"
12210 msgstr "使用钩子处理版本库事件"
12212 #. type: Content of: <book><chapter><para>
12213 #: ../en/ch10-hook.xml:7
12214 msgid ""
12215 "Mercurial offers a powerful mechanism to let you perform automated actions in "
12216 "response to events that occur in a repository. In some cases, you can even "
12217 "control Mercurial's response to those events."
12218 msgstr ""
12220 #. type: Content of: <book><chapter><para>
12221 #: ../en/ch10-hook.xml:12
12222 msgid ""
12223 "The name Mercurial uses for one of these actions is a <emphasis>hook</"
12224 "emphasis>. Hooks are called <quote>triggers</quote> in some revision control "
12225 "systems, but the two names refer to the same idea."
12226 msgstr ""
12228 #. type: Content of: <book><chapter><sect1><title>
12229 #: ../en/ch10-hook.xml:18
12230 msgid "An overview of hooks in Mercurial"
12231 msgstr "Mercurial 钩子概述"
12233 #. type: Content of: <book><chapter><sect1><para>
12234 #: ../en/ch10-hook.xml:20
12235 msgid ""
12236 "Here is a brief list of the hooks that Mercurial supports. We will revisit "
12237 "each of these hooks in more detail later, in <xref linkend=\"sec:hook:ref\"/>."
12238 msgstr ""
12240 #. type: Content of: <book><chapter><sect1><para>
12241 #: ../en/ch10-hook.xml:24
12242 msgid ""
12243 "Each of the hooks whose description begins with the word <quote>Controlling</"
12244 "quote> has the ability to determine whether an activity can proceed. If the "
12245 "hook succeeds, the activity may proceed; if it fails, the activity is either "
12246 "not permitted or undone, depending on the hook."
12247 msgstr ""
12249 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12250 #: ../en/ch10-hook.xml:31
12251 msgid ""
12252 "<literal role=\"hook\">changegroup</literal>: This is run after a group of "
12253 "changesets has been brought into the repository from elsewhere."
12254 msgstr ""
12256 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12257 #: ../en/ch10-hook.xml:35
12258 msgid ""
12259 "<literal role=\"hook\">commit</literal>: This is run after a new changeset "
12260 "has been created in the local repository."
12261 msgstr ""
12263 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12264 #: ../en/ch10-hook.xml:39
12265 msgid ""
12266 "<literal role=\"hook\">incoming</literal>: This is run once for each new "
12267 "changeset that is brought into the repository from elsewhere. Notice the "
12268 "difference from <literal role=\"hook\">changegroup</literal>, which is run "
12269 "once per <emphasis>group</emphasis> of changesets brought in."
12270 msgstr ""
12272 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12273 #: ../en/ch10-hook.xml:46
12274 msgid ""
12275 "<literal role=\"hook\">outgoing</literal>: This is run after a group of "
12276 "changesets has been transmitted from this repository."
12277 msgstr ""
12279 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12280 #: ../en/ch10-hook.xml:50
12281 msgid ""
12282 "<literal role=\"hook\">prechangegroup</literal>: This is run before starting "
12283 "to bring a group of changesets into the repository."
12284 msgstr ""
12286 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12287 #: ../en/ch10-hook.xml:55
12288 msgid ""
12289 "<literal role=\"hook\">precommit</literal>: Controlling. This is run before "
12290 "starting a commit."
12291 msgstr ""
12293 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12294 #: ../en/ch10-hook.xml:59
12295 msgid ""
12296 "<literal role=\"hook\">preoutgoing</literal>: Controlling. This is run before "
12297 "starting to transmit a group of changesets from this repository."
12298 msgstr ""
12300 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12301 #: ../en/ch10-hook.xml:64
12302 msgid ""
12303 "<literal role=\"hook\">pretag</literal>: Controlling. This is run before "
12304 "creating a tag."
12305 msgstr ""
12307 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12308 #: ../en/ch10-hook.xml:68
12309 msgid ""
12310 "<literal role=\"hook\">pretxnchangegroup</literal>: Controlling. This is run "
12311 "after a group of changesets has been brought into the local repository from "
12312 "another, but before the transaction completes that will make the changes "
12313 "permanent in the repository."
12314 msgstr ""
12316 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12317 #: ../en/ch10-hook.xml:76
12318 msgid ""
12319 "<literal role=\"hook\">pretxncommit</literal>: Controlling. This is run after "
12320 "a new changeset has been created in the local repository, but before the "
12321 "transaction completes that will make it permanent."
12322 msgstr ""
12324 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12325 #: ../en/ch10-hook.xml:82
12326 msgid ""
12327 "<literal role=\"hook\">preupdate</literal>: Controlling. This is run before "
12328 "starting an update or merge of the working directory."
12329 msgstr ""
12331 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12332 #: ../en/ch10-hook.xml:87
12333 msgid ""
12334 "<literal role=\"hook\">tag</literal>: This is run after a tag is created."
12335 msgstr ""
12337 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12338 #: ../en/ch10-hook.xml:91
12339 msgid ""
12340 "<literal role=\"hook\">update</literal>: This is run after an update or merge "
12341 "of the working directory has finished."
12342 msgstr ""
12344 #. type: Content of: <book><chapter><sect1><title>
12345 #: ../en/ch10-hook.xml:99
12346 msgid "Hooks and security"
12347 msgstr "钩子与安全性"
12349 #. type: Content of: <book><chapter><sect1><sect2><title>
12350 #: ../en/ch10-hook.xml:102
12351 msgid "Hooks are run with your privileges"
12352 msgstr "钩子以你的特权执行"
12354 #. type: Content of: <book><chapter><sect1><sect2><para>
12355 #: ../en/ch10-hook.xml:104
12356 msgid ""
12357 "When you run a Mercurial command in a repository, and the command causes a "
12358 "hook to run, that hook runs on <emphasis>your</emphasis> system, under "
12359 "<emphasis>your</emphasis> user account, with <emphasis>your</emphasis> "
12360 "privilege level. Since hooks are arbitrary pieces of executable code, you "
12361 "should treat them with an appropriate level of suspicion. Do not install a "
12362 "hook unless you are confident that you know who created it and what it does."
12363 msgstr ""
12365 #. type: Content of: <book><chapter><sect1><sect2><para>
12366 #: ../en/ch10-hook.xml:115
12367 msgid ""
12368 "In some cases, you may be exposed to hooks that you did not install "
12369 "yourself. If you work with Mercurial on an unfamiliar system, Mercurial will "
12370 "run hooks defined in that system's global <filename role=\"special\">~/.hgrc</"
12371 "filename> file."
12372 msgstr ""
12374 #. type: Content of: <book><chapter><sect1><sect2><para>
12375 #: ../en/ch10-hook.xml:122
12376 msgid ""
12377 "If you are working with a repository owned by another user, Mercurial can run "
12378 "hooks defined in that user's repository, but it will still run them as "
12379 "<quote>you</quote>. For example, if you <command role=\"hg-cmd\">hg pull</"
12380 "command> from that repository, and its <filename role=\"special\">.hg/hgrc</"
12381 "filename> defines a local <literal role=\"hook\">outgoing</literal> hook, "
12382 "that hook will run under your user account, even though you don't own that "
12383 "repository."
12384 msgstr ""
12386 #. type: Content of: <book><chapter><sect1><sect2><note><para>
12387 #: ../en/ch10-hook.xml:134
12388 msgid ""
12389 "This only applies if you are pulling from a repository on a local or network "
12390 "filesystem. If you're pulling over http or ssh, any <literal role=\"hook"
12391 "\">outgoing</literal> hook will run under whatever account is executing the "
12392 "server process, on the server."
12393 msgstr ""
12395 #. type: Content of: <book><chapter><sect1><sect2><para>
12396 #: ../en/ch10-hook.xml:142
12397 msgid ""
12398 "To see what hooks are defined in a repository, use the <command role=\"hg-cmd"
12399 "\">hg showconfig hooks</command> command. If you are working in one "
12400 "repository, but talking to another that you do not own (e.g. using <command "
12401 "role=\"hg-cmd\">hg pull</command> or <command role=\"hg-cmd\">hg incoming</"
12402 "command>), remember that it is the other repository's hooks you should be "
12403 "checking, not your own."
12404 msgstr ""
12406 #. type: Content of: <book><chapter><sect1><sect2><title>
12407 #: ../en/ch10-hook.xml:153
12408 msgid "Hooks do not propagate"
12409 msgstr "钩子不会传播"
12411 #. type: Content of: <book><chapter><sect1><sect2><para>
12412 #: ../en/ch10-hook.xml:155
12413 msgid ""
12414 "In Mercurial, hooks are not revision controlled, and do not propagate when "
12415 "you clone, or pull from, a repository. The reason for this is simple: a hook "
12416 "is a completely arbitrary piece of executable code. It runs under your user "
12417 "identity, with your privilege level, on your machine."
12418 msgstr ""
12420 #. type: Content of: <book><chapter><sect1><sect2><para>
12421 #: ../en/ch10-hook.xml:162
12422 msgid ""
12423 "It would be extremely reckless for any distributed revision control system to "
12424 "implement revision-controlled hooks, as this would offer an easily "
12425 "exploitable way to subvert the accounts of users of the revision control "
12426 "system."
12427 msgstr ""
12429 #. type: Content of: <book><chapter><sect1><sect2><para>
12430 #: ../en/ch10-hook.xml:168
12431 msgid ""
12432 "Since Mercurial does not propagate hooks, if you are collaborating with other "
12433 "people on a common project, you should not assume that they are using the "
12434 "same Mercurial hooks as you are, or that theirs are correctly configured. "
12435 "You should document the hooks you expect people to use."
12436 msgstr ""
12438 #. type: Content of: <book><chapter><sect1><sect2><para>
12439 #: ../en/ch10-hook.xml:175
12440 msgid ""
12441 "In a corporate intranet, this is somewhat easier to control, as you can for "
12442 "example provide a <quote>standard</quote> installation of Mercurial on an NFS "
12443 "filesystem, and use a site-wide <filename role=\"special\">~/.hgrc</filename> "
12444 "file to define hooks that all users will see. However, this too has its "
12445 "limits; see below."
12446 msgstr ""
12448 #. type: Content of: <book><chapter><sect1><sect2><title>
12449 #: ../en/ch10-hook.xml:184
12450 msgid "Hooks can be overridden"
12451 msgstr "钩子可以被覆盖"
12453 #. type: Content of: <book><chapter><sect1><sect2><para>
12454 #: ../en/ch10-hook.xml:186
12455 msgid ""
12456 "Mercurial allows you to override a hook definition by redefining the hook. "
12457 "You can disable it by setting its value to the empty string, or change its "
12458 "behavior as you wish."
12459 msgstr ""
12461 #. type: Content of: <book><chapter><sect1><sect2><para>
12462 #: ../en/ch10-hook.xml:191
12463 msgid ""
12464 "If you deploy a system- or site-wide <filename role=\"special\">~/.hgrc</"
12465 "filename> file that defines some hooks, you should thus understand that your "
12466 "users can disable or override those hooks."
12467 msgstr ""
12469 #. type: Content of: <book><chapter><sect1><sect2><title>
12470 #: ../en/ch10-hook.xml:199
12471 msgid "Ensuring that critical hooks are run"
12472 msgstr "确保关键钩子的执行"
12474 #. type: Content of: <book><chapter><sect1><sect2><para>
12475 #: ../en/ch10-hook.xml:201
12476 msgid ""
12477 "Sometimes you may want to enforce a policy that you do not want others to be "
12478 "able to work around. For example, you may have a requirement that every "
12479 "changeset must pass a rigorous set of tests. Defining this requirement via a "
12480 "hook in a site-wide <filename role=\"special\">~/.hgrc</filename> won't work "
12481 "for remote users on laptops, and of course local users can subvert it at will "
12482 "by overriding the hook."
12483 msgstr ""
12485 #. type: Content of: <book><chapter><sect1><sect2><para>
12486 #: ../en/ch10-hook.xml:210
12487 msgid ""
12488 "Instead, you can set up your policies for use of Mercurial so that people are "
12489 "expected to propagate changes through a well-known <quote>canonical</quote> "
12490 "server that you have locked down and configured appropriately."
12491 msgstr ""
12493 #. type: Content of: <book><chapter><sect1><sect2><para>
12494 #: ../en/ch10-hook.xml:216
12495 msgid ""
12496 "One way to do this is via a combination of social engineering and "
12497 "technology. Set up a restricted-access account; users can push changes over "
12498 "the network to repositories managed by this account, but they cannot log into "
12499 "the account and run normal shell commands. In this scenario, a user can "
12500 "commit a changeset that contains any old garbage they want."
12501 msgstr ""
12503 #. type: Content of: <book><chapter><sect1><sect2><para>
12504 #: ../en/ch10-hook.xml:225
12505 msgid ""
12506 "When someone pushes a changeset to the server that everyone pulls from, the "
12507 "server will test the changeset before it accepts it as permanent, and reject "
12508 "it if it fails to pass the test suite. If people only pull changes from this "
12509 "filtering server, it will serve to ensure that all changes that people pull "
12510 "have been automatically vetted."
12511 msgstr ""
12513 #. type: Content of: <book><chapter><sect1><title>
12514 #: ../en/ch10-hook.xml:237
12515 msgid "A short tutorial on using hooks"
12516 msgstr "使用钩子的简短指南"
12518 #. type: Content of: <book><chapter><sect1><para>
12519 #: ../en/ch10-hook.xml:239
12520 msgid ""
12521 "It is easy to write a Mercurial hook. Let's start with a hook that runs when "
12522 "you finish a <command role=\"hg-cmd\">hg commit</command>, and simply prints "
12523 "the hash of the changeset you just created. The hook is called <literal role="
12524 "\"hook\">commit</literal>."
12525 msgstr ""
12527 #. type: Content of: <book><chapter><sect1><para>
12528 #: ../en/ch10-hook.xml:246
12529 msgid "All hooks follow the pattern in this example."
12530 msgstr ""
12532 #. type: Content of: <book><chapter><sect1><para>
12533 #: ../en/ch10-hook.xml:250
12534 msgid ""
12535 "You add an entry to the <literal role=\"rc-hooks\">hooks</literal> section of "
12536 "your <filename role=\"special\">~/.hgrc</filename>. On the left is the name "
12537 "of the event to trigger on; on the right is the action to take. As you can "
12538 "see, you can run an arbitrary shell command in a hook. Mercurial passes "
12539 "extra information to the hook using environment variables (look for "
12540 "<envar>HG_NODE</envar> in the example)."
12541 msgstr ""
12543 #. type: Content of: <book><chapter><sect1><sect2><title>
12544 #: ../en/ch10-hook.xml:260
12545 msgid "Performing multiple actions per event"
12546 msgstr "每个事件执行多个操作"
12548 #. type: Content of: <book><chapter><sect1><sect2><para>
12549 #: ../en/ch10-hook.xml:262
12550 msgid ""
12551 "Quite often, you will want to define more than one hook for a particular kind "
12552 "of event, as shown below."
12553 msgstr ""
12555 #. type: Content of: <book><chapter><sect1><sect2><para>
12556 #: ../en/ch10-hook.xml:267
12557 msgid ""
12558 "Mercurial lets you do this by adding an <emphasis>extension</emphasis> to the "
12559 "end of a hook's name. You extend a hook's name by giving the name of the "
12560 "hook, followed by a full stop (the <quote><literal>.</literal></quote> "
12561 "character), followed by some more text of your choosing. For example, "
12562 "Mercurial will run both <literal>commit.foo</literal> and <literal>commit."
12563 "bar</literal> when the <literal>commit</literal> event occurs."
12564 msgstr ""
12566 #. type: Content of: <book><chapter><sect1><sect2><para>
12567 #: ../en/ch10-hook.xml:278
12568 msgid ""
12569 "To give a well-defined order of execution when there are multiple hooks "
12570 "defined for an event, Mercurial sorts hooks by extension, and executes the "
12571 "hook commands in this sorted order. In the above example, it will execute "
12572 "<literal>commit.bar</literal> before <literal>commit.foo</literal>, and "
12573 "<literal>commit</literal> before both."
12574 msgstr ""
12576 #. type: Content of: <book><chapter><sect1><sect2><para>
12577 #: ../en/ch10-hook.xml:287
12578 msgid ""
12579 "It is a good idea to use a somewhat descriptive extension when you define a "
12580 "new hook. This will help you to remember what the hook was for. If the hook "
12581 "fails, you'll get an error message that contains the hook name and extension, "
12582 "so using a descriptive extension could give you an immediate hint as to why "
12583 "the hook failed (see <xref linkend=\"sec:hook:perm\"/> for an example)."
12584 msgstr ""
12586 #. type: Content of: <book><chapter><sect1><sect2><title>
12587 #: ../en/ch10-hook.xml:298
12588 msgid "Controlling whether an activity can proceed"
12589 msgstr "控制处理的活动"
12591 #. type: Content of: <book><chapter><sect1><sect2><para>
12592 #: ../en/ch10-hook.xml:300
12593 msgid ""
12594 "In our earlier examples, we used the <literal role=\"hook\">commit</literal> "
12595 "hook, which is run after a commit has completed. This is one of several "
12596 "Mercurial hooks that run after an activity finishes. Such hooks have no way "
12597 "of influencing the activity itself."
12598 msgstr ""
12600 #. type: Content of: <book><chapter><sect1><sect2><para>
12601 #: ../en/ch10-hook.xml:307
12602 msgid ""
12603 "Mercurial defines a number of events that occur before an activity starts; or "
12604 "after it starts, but before it finishes. Hooks that trigger on these events "
12605 "have the added ability to choose whether the activity can continue, or will "
12606 "abort."
12607 msgstr ""
12609 #. type: Content of: <book><chapter><sect1><sect2><para>
12610 #: ../en/ch10-hook.xml:313
12611 msgid ""
12612 "The <literal role=\"hook\">pretxncommit</literal> hook runs after a commit "
12613 "has all but completed. In other words, the metadata representing the "
12614 "changeset has been written out to disk, but the transaction has not yet been "
12615 "allowed to complete. The <literal role=\"hook\">pretxncommit</literal> hook "
12616 "has the ability to decide whether the transaction can complete, or must be "
12617 "rolled back."
12618 msgstr ""
12620 #. type: Content of: <book><chapter><sect1><sect2><para>
12621 #: ../en/ch10-hook.xml:322
12622 msgid ""
12623 "If the <literal role=\"hook\">pretxncommit</literal> hook exits with a status "
12624 "code of zero, the transaction is allowed to complete; the commit finishes; "
12625 "and the <literal role=\"hook\">commit</literal> hook is run. If the <literal "
12626 "role=\"hook\">pretxncommit</literal> hook exits with a non-zero status code, "
12627 "the transaction is rolled back; the metadata representing the changeset is "
12628 "erased; and the <literal role=\"hook\">commit</literal> hook is not run."
12629 msgstr ""
12631 #. type: Content of: <book><chapter><sect1><sect2><para>
12632 #: ../en/ch10-hook.xml:334
12633 msgid ""
12634 "The hook in the example above checks that a commit comment contains a bug "
12635 "ID. If it does, the commit can complete. If not, the commit is rolled back."
12636 msgstr ""
12638 #. type: Content of: <book><chapter><sect1><title>
12639 #: ../en/ch10-hook.xml:342
12640 msgid "Writing your own hooks"
12641 msgstr "编写钩子"
12643 #. type: Content of: <book><chapter><sect1><para>
12644 #: ../en/ch10-hook.xml:344
12645 msgid ""
12646 "When you are writing a hook, you might find it useful to run Mercurial either "
12647 "with the <option role=\"hg-opt-global\">-v</option> option, or the <envar "
12648 "role=\"rc-item-ui\">verbose</envar> config item set to <quote>true</quote>. "
12649 "When you do so, Mercurial will print a message before it calls each hook."
12650 msgstr ""
12652 #. type: Content of: <book><chapter><sect1><sect2><title>
12653 #: ../en/ch10-hook.xml:353
12654 msgid "Choosing how your hook should run"
12655 msgstr "选择钩子的执行方式"
12657 #. type: Content of: <book><chapter><sect1><sect2><para>
12658 #: ../en/ch10-hook.xml:355
12659 msgid ""
12660 "You can write a hook either as a normal program&emdash;typically a shell "
12661 "script&emdash;or as a Python function that is executed within the Mercurial "
12662 "process."
12663 msgstr ""
12665 #. type: Content of: <book><chapter><sect1><sect2><para>
12666 #: ../en/ch10-hook.xml:360
12667 msgid ""
12668 "Writing a hook as an external program has the advantage that it requires no "
12669 "knowledge of Mercurial's internals. You can call normal Mercurial commands "
12670 "to get any added information you need. The trade-off is that external hooks "
12671 "are slower than in-process hooks."
12672 msgstr ""
12674 #. type: Content of: <book><chapter><sect1><sect2><para>
12675 #: ../en/ch10-hook.xml:367
12676 msgid ""
12677 "An in-process Python hook has complete access to the Mercurial API, and does "
12678 "not <quote>shell out</quote> to another process, so it is inherently faster "
12679 "than an external hook. It is also easier to obtain much of the information "
12680 "that a hook requires by using the Mercurial API than by running Mercurial "
12681 "commands."
12682 msgstr ""
12684 #. type: Content of: <book><chapter><sect1><sect2><para>
12685 #: ../en/ch10-hook.xml:375
12686 msgid ""
12687 "If you are comfortable with Python, or require high performance, writing your "
12688 "hooks in Python may be a good choice. However, when you have a "
12689 "straightforward hook to write and you don't need to care about performance "
12690 "(probably the majority of hooks), a shell script is perfectly fine."
12691 msgstr ""
12693 #. type: Content of: <book><chapter><sect1><sect2><title>
12694 #: ../en/ch10-hook.xml:384
12695 msgid "Hook parameters"
12696 msgstr "钩子的参数"
12698 #. type: Content of: <book><chapter><sect1><sect2><para>
12699 #: ../en/ch10-hook.xml:386
12700 msgid ""
12701 "Mercurial calls each hook with a set of well-defined parameters. In Python, "
12702 "a parameter is passed as a keyword argument to your hook function. For an "
12703 "external program, a parameter is passed as an environment variable."
12704 msgstr ""
12706 #. type: Content of: <book><chapter><sect1><sect2><para>
12707 #: ../en/ch10-hook.xml:392
12708 msgid ""
12709 "Whether your hook is written in Python or as a shell script, the hook-"
12710 "specific parameter names and values will be the same. A boolean parameter "
12711 "will be represented as a boolean value in Python, but as the number 1 (for "
12712 "<quote>true</quote>) or 0 (for <quote>false</quote>) as an environment "
12713 "variable for an external hook. If a hook parameter is named <literal>foo</"
12714 "literal>, the keyword argument for a Python hook will also be named "
12715 "<literal>foo</literal>, while the environment variable for an external hook "
12716 "will be named <literal>HG_FOO</literal>."
12717 msgstr ""
12719 #. type: Content of: <book><chapter><sect1><sect2><title>
12720 #: ../en/ch10-hook.xml:406
12721 msgid "Hook return values and activity control"
12722 msgstr "钩子的返回值与活动控制"
12724 #. type: Content of: <book><chapter><sect1><sect2><para>
12725 #: ../en/ch10-hook.xml:408
12726 msgid ""
12727 "A hook that executes successfully must exit with a status of zero if "
12728 "external, or return boolean <quote>false</quote> if in-process. Failure is "
12729 "indicated with a non-zero exit status from an external hook, or an in-process "
12730 "hook returning boolean <quote>true</quote>. If an in-process hook raises an "
12731 "exception, the hook is considered to have failed."
12732 msgstr ""
12734 #. type: Content of: <book><chapter><sect1><sect2><para>
12735 #: ../en/ch10-hook.xml:416
12736 msgid ""
12737 "For a hook that controls whether an activity can proceed, zero/false means "
12738 "<quote>allow</quote>, while non-zero/true/exception means <quote>deny</quote>."
12739 msgstr ""
12741 #. type: Content of: <book><chapter><sect1><sect2><title>
12742 #: ../en/ch10-hook.xml:423
12743 msgid "Writing an external hook"
12744 msgstr "编写外部钩子"
12746 #. type: Content of: <book><chapter><sect1><sect2><para>
12747 #: ../en/ch10-hook.xml:425
12748 msgid ""
12749 "When you define an external hook in your <filename role=\"special\">~/.hgrc</"
12750 "filename> and the hook is run, its value is passed to your shell, which "
12751 "interprets it. This means that you can use normal shell constructs in the "
12752 "body of the hook."
12753 msgstr ""
12755 #. type: Content of: <book><chapter><sect1><sect2><para>
12756 #: ../en/ch10-hook.xml:432
12757 msgid ""
12758 "An executable hook is always run with its current directory set to a "
12759 "repository's root directory."
12760 msgstr ""
12762 #. type: Content of: <book><chapter><sect1><sect2><para>
12763 #: ../en/ch10-hook.xml:436
12764 msgid ""
12765 "Each hook parameter is passed in as an environment variable; the name is "
12766 "upper-cased, and prefixed with the string <quote><literal>HG_</literal></"
12767 "quote>."
12768 msgstr ""
12770 #. type: Content of: <book><chapter><sect1><sect2><para>
12771 #: ../en/ch10-hook.xml:441
12772 msgid ""
12773 "With the exception of hook parameters, Mercurial does not set or modify any "
12774 "environment variables when running a hook. This is useful to remember if you "
12775 "are writing a site-wide hook that may be run by a number of different users "
12776 "with differing environment variables set. In multi-user situations, you "
12777 "should not rely on environment variables being set to the values you have in "
12778 "your environment when testing the hook."
12779 msgstr ""
12781 #. type: Content of: <book><chapter><sect1><sect2><title>
12782 #: ../en/ch10-hook.xml:452
12783 msgid "Telling Mercurial to use an in-process hook"
12784 msgstr "让 Mercurial 使用进程内钩子"
12786 #. type: Content of: <book><chapter><sect1><sect2><para>
12787 #: ../en/ch10-hook.xml:454
12788 msgid ""
12789 "The <filename role=\"special\">~/.hgrc</filename> syntax for defining an in-"
12790 "process hook is slightly different than for an executable hook. The value of "
12791 "the hook must start with the text <quote><literal>python:</literal></quote>, "
12792 "and continue with the fully-qualified name of a callable object to use as the "
12793 "hook's value."
12794 msgstr ""
12796 #. type: Content of: <book><chapter><sect1><sect2><para>
12797 #: ../en/ch10-hook.xml:462
12798 msgid ""
12799 "The module in which a hook lives is automatically imported when a hook is "
12800 "run. So long as you have the module name and <envar>PYTHONPATH</envar> "
12801 "right, it should <quote>just work</quote>."
12802 msgstr ""
12804 #. type: Content of: <book><chapter><sect1><sect2><para>
12805 #: ../en/ch10-hook.xml:468
12806 msgid ""
12807 "The following <filename role=\"special\">~/.hgrc</filename> example snippet "
12808 "illustrates the syntax and meaning of the notions we just described."
12809 msgstr ""
12811 #. type: Content of: <book><chapter><sect1><sect2><para>
12812 #: ../en/ch10-hook.xml:474
12813 msgid ""
12814 "When Mercurial runs the <literal>commit.example</literal> hook, it imports "
12815 "<literal>mymodule.submodule</literal>, looks for the callable object named "
12816 "<literal>myhook</literal>, and calls it."
12817 msgstr ""
12819 #. type: Content of: <book><chapter><sect1><sect2><title>
12820 #: ../en/ch10-hook.xml:482
12821 msgid "Writing an in-process hook"
12822 msgstr "编写进程内钩子"
12824 #. type: Content of: <book><chapter><sect1><sect2><para>
12825 #: ../en/ch10-hook.xml:484
12826 msgid ""
12827 "The simplest in-process hook does nothing, but illustrates the basic shape of "
12828 "the hook API:"
12829 msgstr ""
12831 #. type: Content of: <book><chapter><sect1><sect2><para>
12832 #: ../en/ch10-hook.xml:489
12833 msgid ""
12834 "The first argument to a Python hook is always a <literal role=\"py-mod-"
12835 "mercurial.ui\">ui</literal> object. The second is a repository object; at "
12836 "the moment, it is always an instance of <literal role=\"py-mod-mercurial."
12837 "localrepo\">localrepository</literal>. Following these two arguments are "
12838 "other keyword arguments. Which ones are passed in depends on the hook being "
12839 "called, but a hook can ignore arguments it doesn't care about by dropping "
12840 "them into a keyword argument dict, as with <literal>**kwargs</literal> above."
12841 msgstr ""
12843 #. type: Content of: <book><chapter><sect1><title>
12844 #: ../en/ch10-hook.xml:504
12845 msgid "Some hook examples"
12846 msgstr "钩子样例"
12848 #. type: Content of: <book><chapter><sect1><sect2><title>
12849 #: ../en/ch10-hook.xml:507
12850 msgid "Writing meaningful commit messages"
12851 msgstr "编写有意义的提交日志"
12853 #. type: Content of: <book><chapter><sect1><sect2><para>
12854 #: ../en/ch10-hook.xml:509
12855 msgid ""
12856 "It's hard to imagine a useful commit message being very short. The simple "
12857 "<literal role=\"hook\">pretxncommit</literal> hook of the example below will "
12858 "prevent you from committing a changeset with a message that is less than ten "
12859 "bytes long."
12860 msgstr ""
12862 #. type: Content of: <book><chapter><sect1><sect2><title>
12863 #: ../en/ch10-hook.xml:519
12864 msgid "Checking for trailing whitespace"
12865 msgstr "检查行尾空格"
12867 #. type: Content of: <book><chapter><sect1><sect2><para>
12868 #: ../en/ch10-hook.xml:521
12869 msgid ""
12870 "An interesting use of a commit-related hook is to help you to write cleaner "
12871 "code. A simple example of <quote>cleaner code</quote> is the dictum that a "
12872 "change should not add any new lines of text that contain <quote>trailing "
12873 "whitespace</quote>. Trailing whitespace is a series of space and tab "
12874 "characters at the end of a line of text. In most cases, trailing whitespace "
12875 "is unnecessary, invisible noise, but it is occasionally problematic, and "
12876 "people often prefer to get rid of it."
12877 msgstr ""
12879 #. type: Content of: <book><chapter><sect1><sect2><para>
12880 #: ../en/ch10-hook.xml:532
12881 msgid ""
12882 "You can use either the <literal role=\"hook\">precommit</literal> or <literal "
12883 "role=\"hook\">pretxncommit</literal> hook to tell whether you have a trailing "
12884 "whitespace problem. If you use the <literal role=\"hook\">precommit</"
12885 "literal> hook, the hook will not know which files you are committing, so it "
12886 "will have to check every modified file in the repository for trailing white "
12887 "space. If you want to commit a change to just the file <filename>foo</"
12888 "filename>, but the file <filename>bar</filename> contains trailing "
12889 "whitespace, doing a check in the <literal role=\"hook\">precommit</literal> "
12890 "hook will prevent you from committing <filename>foo</filename> due to the "
12891 "problem with <filename>bar</filename>. This doesn't seem right."
12892 msgstr ""
12894 #. type: Content of: <book><chapter><sect1><sect2><para>
12895 #: ../en/ch10-hook.xml:548
12896 msgid ""
12897 "Should you choose the <literal role=\"hook\">pretxncommit</literal> hook, the "
12898 "check won't occur until just before the transaction for the commit "
12899 "completes. This will allow you to check for problems only the exact files "
12900 "that are being committed. However, if you entered the commit message "
12901 "interactively and the hook fails, the transaction will roll back; you'll have "
12902 "to re-enter the commit message after you fix the trailing whitespace and run "
12903 "<command role=\"hg-cmd\">hg commit</command> again."
12904 msgstr ""
12906 #. type: Content of: <book><chapter><sect1><sect2><para>
12907 #: ../en/ch10-hook.xml:561
12908 msgid ""
12909 "In this example, we introduce a simple <literal role=\"hook\">pretxncommit</"
12910 "literal> hook that checks for trailing whitespace. This hook is short, but "
12911 "not very helpful. It exits with an error status if a change adds a line with "
12912 "trailing whitespace to any file, but does not print any information that "
12913 "might help us to identify the offending file or line. It also has the nice "
12914 "property of not paying attention to unmodified lines; only lines that "
12915 "introduce new trailing whitespace cause problems."
12916 msgstr ""
12918 #. type: Content of: <book><chapter><sect1><sect2><para>
12919 #: ../en/ch10-hook.xml:574
12920 msgid ""
12921 "The above version is much more complex, but also more useful. It parses a "
12922 "unified diff to see if any lines add trailing whitespace, and prints the name "
12923 "of the file and the line number of each such occurrence. Even better, if the "
12924 "change adds trailing whitespace, this hook saves the commit comment and "
12925 "prints the name of the save file before exiting and telling Mercurial to roll "
12926 "the transaction back, so you can use the <option role=\"hg-opt-commit\">-l "
12927 "filename</option> option to <command role=\"hg-cmd\">hg commit</command> to "
12928 "reuse the saved commit message once you've corrected the problem."
12929 msgstr ""
12931 #. type: Content of: <book><chapter><sect1><sect2><para>
12932 #: ../en/ch10-hook.xml:588
12933 msgid ""
12934 "As a final aside, note in the example above the use of <command>sed</"
12935 "command>'s in-place editing feature to get rid of trailing whitespace from a "
12936 "file. This is concise and useful enough that I will reproduce it here (using "
12937 "<command>perl</command> for good measure)."
12938 msgstr ""
12940 #. type: Content of: <book><chapter><sect1><title>
12941 #: ../en/ch10-hook.xml:598
12942 msgid "Bundled hooks"
12943 msgstr "内置的钩子"
12945 #. type: Content of: <book><chapter><sect1><para>
12946 #: ../en/ch10-hook.xml:600
12947 msgid ""
12948 "Mercurial ships with several bundled hooks. You can find them in the "
12949 "<filename class=\"directory\">hgext</filename> directory of a Mercurial "
12950 "source tree. If you are using a Mercurial binary package, the hooks will be "
12951 "located in the <filename class=\"directory\">hgext</filename> directory of "
12952 "wherever your package installer put Mercurial."
12953 msgstr ""
12955 #. type: Content of: <book><chapter><sect1><sect2><title>
12956 #: ../en/ch10-hook.xml:609
12957 msgid ""
12958 "<literal role=\"hg-ext\">acl</literal>&emdash;access control for parts of a "
12959 "repository"
12960 msgstr "<literal role=\"hg-ext\">acl</literal>—版本库的访问控制"
12962 #. type: Content of: <book><chapter><sect1><sect2><para>
12963 #: ../en/ch10-hook.xml:612
12964 msgid ""
12965 "The <literal role=\"hg-ext\">acl</literal> extension lets you control which "
12966 "remote users are allowed to push changesets to a networked server. You can "
12967 "protect any portion of a repository (including the entire repo), so that a "
12968 "specific remote user can push changes that do not affect the protected "
12969 "portion."
12970 msgstr ""
12972 #. type: Content of: <book><chapter><sect1><sect2><para>
12973 #: ../en/ch10-hook.xml:620
12974 msgid ""
12975 "This extension implements access control based on the identity of the user "
12976 "performing a push, <emphasis>not</emphasis> on who committed the changesets "
12977 "they're pushing. It makes sense to use this hook only if you have a locked-"
12978 "down server environment that authenticates remote users, and you want to be "
12979 "sure that only specific users are allowed to push changes to that server."
12980 msgstr ""
12982 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
12983 #: ../en/ch10-hook.xml:630
12984 msgid "Configuring the <literal role=\"hook\">acl</literal> hook"
12985 msgstr "配置 <literal role=\"hook\">acl</literal> 钩子"
12987 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
12988 #: ../en/ch10-hook.xml:633
12989 msgid ""
12990 "In order to manage incoming changesets, the <literal role=\"hg-ext\">acl</"
12991 "literal> hook must be used as a <literal role=\"hook\">pretxnchangegroup</"
12992 "literal> hook. This lets it see which files are modified by each incoming "
12993 "changeset, and roll back a group of changesets if they modify "
12994 "<quote>forbidden</quote> files. Example:"
12995 msgstr ""
12997 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
12998 #: ../en/ch10-hook.xml:643
12999 msgid ""
13000 "The <literal role=\"hg-ext\">acl</literal> extension is configured using "
13001 "three sections."
13002 msgstr ""
13004 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13005 #: ../en/ch10-hook.xml:647
13006 msgid ""
13007 "The <literal role=\"rc-acl\">acl</literal> section has only one entry, <envar "
13008 "role=\"rc-item-acl\">sources</envar>, which lists the sources of incoming "
13009 "changesets that the hook should pay attention to. You don't normally need to "
13010 "configure this section."
13011 msgstr ""
13013 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13014 #: ../en/ch10-hook.xml:654
13015 msgid ""
13016 "<envar role=\"rc-item-acl\">serve</envar>: Control incoming changesets that "
13017 "are arriving from a remote repository over http or ssh. This is the default "
13018 "value of <envar role=\"rc-item-acl\">sources</envar>, and usually the only "
13019 "setting you'll need for this configuration item."
13020 msgstr ""
13022 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13023 #: ../en/ch10-hook.xml:662
13024 msgid ""
13025 "<envar role=\"rc-item-acl\">pull</envar>: Control incoming changesets that "
13026 "are arriving via a pull from a local repository."
13027 msgstr ""
13029 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13030 #: ../en/ch10-hook.xml:667
13031 msgid ""
13032 "<envar role=\"rc-item-acl\">push</envar>: Control incoming changesets that "
13033 "are arriving via a push from a local repository."
13034 msgstr ""
13036 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13037 #: ../en/ch10-hook.xml:672
13038 msgid ""
13039 "<envar role=\"rc-item-acl\">bundle</envar>: Control incoming changesets that "
13040 "are arriving from another repository via a bundle."
13041 msgstr ""
13043 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13044 #: ../en/ch10-hook.xml:678
13045 msgid ""
13046 "The <literal role=\"rc-acl.allow\">acl.allow</literal> section controls the "
13047 "users that are allowed to add changesets to the repository. If this section "
13048 "is not present, all users that are not explicitly denied are allowed. If "
13049 "this section is present, all users that are not explicitly allowed are denied "
13050 "(so an empty section means that all users are denied)."
13051 msgstr ""
13053 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13054 #: ../en/ch10-hook.xml:687
13055 msgid ""
13056 "The <literal role=\"rc-acl.deny\">acl.deny</literal> section determines which "
13057 "users are denied from adding changesets to the repository. If this section "
13058 "is not present or is empty, no users are denied."
13059 msgstr ""
13061 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13062 #: ../en/ch10-hook.xml:693
13063 msgid ""
13064 "The syntaxes for the <literal role=\"rc-acl.allow\">acl.allow</literal> and "
13065 "<literal role=\"rc-acl.deny\">acl.deny</literal> sections are identical. On "
13066 "the left of each entry is a glob pattern that matches files or directories, "
13067 "relative to the root of the repository; on the right, a user name."
13068 msgstr ""
13070 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13071 #: ../en/ch10-hook.xml:701
13072 msgid ""
13073 "In the following example, the user <literal>docwriter</literal> can only push "
13074 "changes to the <filename class=\"directory\">docs</filename> subtree of the "
13075 "repository, while <literal>intern</literal> can push changes to any file or "
13076 "directory except <filename class=\"directory\">source/sensitive</filename>."
13077 msgstr ""
13079 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
13080 #: ../en/ch10-hook.xml:715 ../en/ch10-hook.xml:979 ../en/ch10-hook.xml:1169
13081 msgid "Testing and troubleshooting"
13082 msgstr "测试与问题处理"
13084 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13085 #: ../en/ch10-hook.xml:717
13086 msgid ""
13087 "If you want to test the <literal role=\"hg-ext\">acl</literal> hook, run it "
13088 "with Mercurial's debugging output enabled. Since you'll probably be running "
13089 "it on a server where it's not convenient (or sometimes possible) to pass in "
13090 "the <option role=\"hg-opt-global\">--debug</option> option, don't forget that "
13091 "you can enable debugging output in your <filename role=\"special\">~/.hgrc</"
13092 "filename>:"
13093 msgstr ""
13095 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13096 #: ../en/ch10-hook.xml:728
13097 msgid ""
13098 "With this enabled, the <literal role=\"hg-ext\">acl</literal> hook will print "
13099 "enough information to let you figure out why it is allowing or forbidding "
13100 "pushes from specific users."
13101 msgstr ""
13103 #. type: Content of: <book><chapter><sect1><sect2><title>
13104 #: ../en/ch10-hook.xml:737
13105 msgid ""
13106 "<literal role=\"hg-ext\">bugzilla</literal>&emdash;integration with Bugzilla"
13107 msgstr "<literal role=\"hg-ext\">bugzilla</literal>—与 Bugzilla 的集成"
13109 #. type: Content of: <book><chapter><sect1><sect2><para>
13110 #: ../en/ch10-hook.xml:741
13111 msgid ""
13112 "The <literal role=\"hg-ext\">bugzilla</literal> extension adds a comment to a "
13113 "Bugzilla bug whenever it finds a reference to that bug ID in a commit "
13114 "comment. You can install this hook on a shared server, so that any time a "
13115 "remote user pushes changes to this server, the hook gets run."
13116 msgstr ""
13118 #. type: Content of: <book><chapter><sect1><sect2><para>
13119 #: ../en/ch10-hook.xml:748
13120 msgid ""
13121 "It adds a comment to the bug that looks like this (you can configure the "
13122 "contents of the comment&emdash;see below):"
13123 msgstr ""
13125 #. type: Content of: <book><chapter><sect1><sect2><para>
13126 #: ../en/ch10-hook.xml:757
13127 msgid ""
13128 "The value of this hook is that it automates the process of updating a bug any "
13129 "time a changeset refers to it. If you configure the hook properly, it makes "
13130 "it easy for people to browse straight from a Bugzilla bug to a changeset that "
13131 "refers to that bug."
13132 msgstr ""
13134 #. type: Content of: <book><chapter><sect1><sect2><para>
13135 #: ../en/ch10-hook.xml:764
13136 msgid ""
13137 "You can use the code in this hook as a starting point for some more exotic "
13138 "Bugzilla integration recipes. Here are a few possibilities:"
13139 msgstr ""
13141 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13142 #: ../en/ch10-hook.xml:769
13143 msgid ""
13144 "Require that every changeset pushed to the server have a valid bug ID in its "
13145 "commit comment. In this case, you'd want to configure the hook as a <literal "
13146 "role=\"hook\">pretxncommit</literal> hook. This would allow the hook to "
13147 "reject changes that didn't contain bug IDs."
13148 msgstr ""
13150 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13151 #: ../en/ch10-hook.xml:777
13152 msgid ""
13153 "Allow incoming changesets to automatically modify the <emphasis>state</"
13154 "emphasis> of a bug, as well as simply adding a comment. For example, the "
13155 "hook could recognise the string <quote>fixed bug 31337</quote> as indicating "
13156 "that it should update the state of bug 31337 to <quote>requires testing</"
13157 "quote>."
13158 msgstr ""
13160 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
13161 #: ../en/ch10-hook.xml:787
13162 msgid "Configuring the <literal role=\"hook\">bugzilla</literal> hook"
13163 msgstr "配置 <literal role=\"hook\">bugzilla</literal> 钩子"
13165 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13166 #: ../en/ch10-hook.xml:790
13167 msgid ""
13168 "You should configure this hook in your server's <filename role=\"special\">~/."
13169 "hgrc</filename> as an <literal role=\"hook\">incoming</literal> hook, for "
13170 "example as follows:"
13171 msgstr ""
13173 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13174 #: ../en/ch10-hook.xml:798
13175 msgid ""
13176 "Because of the specialised nature of this hook, and because Bugzilla was not "
13177 "written with this kind of integration in mind, configuring this hook is a "
13178 "somewhat involved process."
13179 msgstr ""
13181 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13182 #: ../en/ch10-hook.xml:804
13183 msgid ""
13184 "Before you begin, you must install the MySQL bindings for Python on the host"
13185 "(s) where you'll be running the hook. If this is not available as a binary "
13186 "package for your system, you can download it from <citation>web:mysql-python</"
13187 "citation>."
13188 msgstr ""
13190 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13191 #: ../en/ch10-hook.xml:811
13192 msgid ""
13193 "Configuration information for this hook lives in the <literal role=\"rc-"
13194 "bugzilla\">bugzilla</literal> section of your <filename role=\"special\">~/."
13195 "hgrc</filename>."
13196 msgstr ""
13198 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13199 #: ../en/ch10-hook.xml:816
13200 msgid ""
13201 "<envar role=\"rc-item-bugzilla\">version</envar>: The version of Bugzilla "
13202 "installed on the server. The database schema that Bugzilla uses changes "
13203 "occasionally, so this hook has to know exactly which schema to use."
13204 msgstr ""
13206 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13207 #: ../en/ch10-hook.xml:822
13208 msgid ""
13209 "<envar role=\"rc-item-bugzilla\">host</envar>: The hostname of the MySQL "
13210 "server that stores your Bugzilla data. The database must be configured to "
13211 "allow connections from whatever host you are running the <literal role=\"hook"
13212 "\">bugzilla</literal> hook on."
13213 msgstr ""
13215 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13216 #: ../en/ch10-hook.xml:829
13217 msgid ""
13218 "<envar role=\"rc-item-bugzilla\">user</envar>: The username with which to "
13219 "connect to the MySQL server. The database must be configured to allow this "
13220 "user to connect from whatever host you are running the <literal role=\"hook"
13221 "\">bugzilla</literal> hook on. This user must be able to access and modify "
13222 "Bugzilla tables. The default value of this item is <literal>bugs</literal>, "
13223 "which is the standard name of the Bugzilla user in a MySQL database."
13224 msgstr ""
13226 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13227 #: ../en/ch10-hook.xml:840
13228 msgid ""
13229 "<envar role=\"rc-item-bugzilla\">password</envar>: The MySQL password for the "
13230 "user you configured above. This is stored as plain text, so you should make "
13231 "sure that unauthorised users cannot read the <filename role=\"special\">~/."
13232 "hgrc</filename> file where you store this information."
13233 msgstr ""
13235 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13236 #: ../en/ch10-hook.xml:849
13237 msgid ""
13238 "<envar role=\"rc-item-bugzilla\">db</envar>: The name of the Bugzilla "
13239 "database on the MySQL server. The default value of this item is "
13240 "<literal>bugs</literal>, which is the standard name of the MySQL database "
13241 "where Bugzilla stores its data."
13242 msgstr ""
13244 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13245 #: ../en/ch10-hook.xml:856
13246 msgid ""
13247 "<envar role=\"rc-item-bugzilla\">notify</envar>: If you want Bugzilla to send "
13248 "out a notification email to subscribers after this hook has added a comment "
13249 "to a bug, you will need this hook to run a command whenever it updates the "
13250 "database. The command to run depends on where you have installed Bugzilla, "
13251 "but it will typically look something like this, if you have Bugzilla "
13252 "installed in <filename class=\"directory\">/var/www/html/bugzilla</filename>:"
13253 msgstr ""
13255 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13256 #: ../en/ch10-hook.xml:869
13257 msgid ""
13258 "The Bugzilla <literal>processmail</literal> program expects to be given a bug "
13259 "ID (the hook replaces <quote><literal>%s</literal></quote> with the bug ID) "
13260 "and an email address. It also expects to be able to write to some files in "
13261 "the directory that it runs in. If Bugzilla and this hook are not installed "
13262 "on the same machine, you will need to find a way to run <literal>processmail</"
13263 "literal> on the server where Bugzilla is installed."
13264 msgstr ""
13266 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
13267 #: ../en/ch10-hook.xml:884
13268 msgid "Mapping committer names to Bugzilla user names"
13269 msgstr "提交者的名称与 Bugzilla 用户名称的映射"
13271 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13272 #: ../en/ch10-hook.xml:886
13273 msgid ""
13274 "By default, the <literal role=\"hg-ext\">bugzilla</literal> hook tries to use "
13275 "the email address of a changeset's committer as the Bugzilla user name with "
13276 "which to update a bug. If this does not suit your needs, you can map "
13277 "committer email addresses to Bugzilla user names using a <literal role=\"rc-"
13278 "usermap\">usermap</literal> section."
13279 msgstr ""
13281 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13282 #: ../en/ch10-hook.xml:895
13283 msgid ""
13284 "Each item in the <literal role=\"rc-usermap\">usermap</literal> section "
13285 "contains an email address on the left, and a Bugzilla user name on the right."
13286 msgstr ""
13288 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13289 #: ../en/ch10-hook.xml:902
13290 msgid ""
13291 "You can either keep the <literal role=\"rc-usermap\">usermap</literal> data "
13292 "in a normal <filename role=\"special\">~/.hgrc</filename>, or tell the "
13293 "<literal role=\"hg-ext\">bugzilla</literal> hook to read the information from "
13294 "an external <filename>usermap</filename> file. In the latter case, you can "
13295 "store <filename>usermap</filename> data by itself in (for example) a user-"
13296 "modifiable repository. This makes it possible to let your users maintain "
13297 "their own <envar role=\"rc-item-bugzilla\">usermap</envar> entries. The main "
13298 "<filename role=\"special\">~/.hgrc</filename> file might look like this:"
13299 msgstr ""
13301 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13302 #: ../en/ch10-hook.xml:918
13303 msgid ""
13304 "While the <filename>usermap</filename> file that it refers to might look like "
13305 "this:"
13306 msgstr ""
13308 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
13309 #: ../en/ch10-hook.xml:926
13310 msgid "Configuring the text that gets added to a bug"
13311 msgstr "配置增加到问题中的正文"
13313 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13314 #: ../en/ch10-hook.xml:928
13315 msgid ""
13316 "You can configure the text that this hook adds as a comment; you specify it "
13317 "in the form of a Mercurial template. Several <filename role=\"special\">~/."
13318 "hgrc</filename> entries (still in the <literal role=\"rc-bugzilla\">bugzilla</"
13319 "literal> section) control this behavior."
13320 msgstr ""
13322 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13323 #: ../en/ch10-hook.xml:935
13324 msgid ""
13325 "<literal>strip</literal>: The number of leading path elements to strip from a "
13326 "repository's path name to construct a partial path for a URL. For example, if "
13327 "the repositories on your server live under <filename class=\"directory\">/"
13328 "home/hg/repos</filename>, and you have a repository whose path is <filename "
13329 "class=\"directory\">/home/hg/repos/app/tests</filename>, then setting "
13330 "<literal>strip</literal> to <literal>4</literal> will give a partial path of "
13331 "<filename class=\"directory\">app/tests</filename>. The hook will make this "
13332 "partial path available when expanding a template, as <literal>webroot</"
13333 "literal>."
13334 msgstr ""
13336 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13337 #: ../en/ch10-hook.xml:949
13338 msgid ""
13339 "<literal>template</literal>: The text of the template to use. In addition to "
13340 "the usual changeset-related variables, this template can use <literal>hgweb</"
13341 "literal> (the value of the <literal>hgweb</literal> configuration item above) "
13342 "and <literal>webroot</literal> (the path constructed using <literal>strip</"
13343 "literal> above)."
13344 msgstr ""
13346 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13347 #: ../en/ch10-hook.xml:959
13348 msgid ""
13349 "In addition, you can add a <envar role=\"rc-item-web\">baseurl</envar> item "
13350 "to the <literal role=\"rc-web\">web</literal> section of your <filename role="
13351 "\"special\">~/.hgrc</filename>. The <literal role=\"hg-ext\">bugzilla</"
13352 "literal> hook will make this available when expanding a template, as the base "
13353 "string to use when constructing a URL that will let users browse from a "
13354 "Bugzilla comment to view a changeset. Example:"
13355 msgstr ""
13357 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13358 #: ../en/ch10-hook.xml:971
13359 msgid ""
13360 "Here is an example set of <literal role=\"hg-ext\">bugzilla</literal> hook "
13361 "config information."
13362 msgstr ""
13364 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13365 #: ../en/ch10-hook.xml:981
13366 msgid ""
13367 "The most common problems with configuring the <literal role=\"hg-ext"
13368 "\">bugzilla</literal> hook relate to running Bugzilla's "
13369 "<filename>processmail</filename> script and mapping committer names to user "
13370 "names."
13371 msgstr ""
13373 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13374 #: ../en/ch10-hook.xml:987
13375 msgid ""
13376 "Recall from <xref linkend=\"sec:hook:bugzilla:config\"/> above that the user "
13377 "that runs the Mercurial process on the server is also the one that will run "
13378 "the <filename>processmail</filename> script. The <filename>processmail</"
13379 "filename> script sometimes causes Bugzilla to write to files in its "
13380 "configuration directory, and Bugzilla's configuration files are usually owned "
13381 "by the user that your web server runs under."
13382 msgstr ""
13384 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13385 #: ../en/ch10-hook.xml:998
13386 msgid ""
13387 "You can cause <filename>processmail</filename> to be run with the suitable "
13388 "user's identity using the <command>sudo</command> command. Here is an "
13389 "example entry for a <filename>sudoers</filename> file."
13390 msgstr ""
13392 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13393 #: ../en/ch10-hook.xml:1005
13394 msgid ""
13395 "This allows the <literal>hg_user</literal> user to run a "
13396 "<filename>processmail-wrapper</filename> program under the identity of "
13397 "<literal>httpd_user</literal>."
13398 msgstr ""
13400 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13401 #: ../en/ch10-hook.xml:1010
13402 msgid ""
13403 "This indirection through a wrapper script is necessary, because "
13404 "<filename>processmail</filename> expects to be run with its current directory "
13405 "set to wherever you installed Bugzilla; you can't specify that kind of "
13406 "constraint in a <filename>sudoers</filename> file. The contents of the "
13407 "wrapper script are simple:"
13408 msgstr ""
13410 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13411 #: ../en/ch10-hook.xml:1019
13412 msgid ""
13413 "It doesn't seem to matter what email address you pass to "
13414 "<filename>processmail</filename>."
13415 msgstr ""
13417 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13418 #: ../en/ch10-hook.xml:1023
13419 msgid ""
13420 "If your <literal role=\"rc-usermap\">usermap</literal> is not set up "
13421 "correctly, users will see an error message from the <literal role=\"hg-ext"
13422 "\">bugzilla</literal> hook when they push changes to the server. The error "
13423 "message will look like this:"
13424 msgstr ""
13426 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13427 #: ../en/ch10-hook.xml:1030
13428 msgid ""
13429 "What this means is that the committer's address, <literal>john.q."
13430 "public@example.com</literal>, is not a valid Bugzilla user name, nor does it "
13431 "have an entry in your <literal role=\"rc-usermap\">usermap</literal> that "
13432 "maps it to a valid Bugzilla user name."
13433 msgstr ""
13435 #. type: Content of: <book><chapter><sect1><sect2><title>
13436 #: ../en/ch10-hook.xml:1040
13437 msgid ""
13438 "<literal role=\"hg-ext\">notify</literal>&emdash;send email notifications"
13439 msgstr "<literal role=\"hg-ext\">notify</literal>—邮件通知"
13441 #. type: Content of: <book><chapter><sect1><sect2><para>
13442 #: ../en/ch10-hook.xml:1043
13443 msgid ""
13444 "Although Mercurial's built-in web server provides RSS feeds of changes in "
13445 "every repository, many people prefer to receive change notifications via "
13446 "email. The <literal role=\"hg-ext\">notify</literal> hook lets you send out "
13447 "notifications to a set of email addresses whenever changesets arrive that "
13448 "those subscribers are interested in."
13449 msgstr ""
13451 #. type: Content of: <book><chapter><sect1><sect2><para>
13452 #: ../en/ch10-hook.xml:1051
13453 msgid ""
13454 "As with the <literal role=\"hg-ext\">bugzilla</literal> hook, the <literal "
13455 "role=\"hg-ext\">notify</literal> hook is template-driven, so you can "
13456 "customise the contents of the notification messages that it sends."
13457 msgstr ""
13459 #. type: Content of: <book><chapter><sect1><sect2><para>
13460 #: ../en/ch10-hook.xml:1057
13461 msgid ""
13462 "By default, the <literal role=\"hg-ext\">notify</literal> hook includes a "
13463 "diff of every changeset that it sends out; you can limit the size of the "
13464 "diff, or turn this feature off entirely. It is useful for letting "
13465 "subscribers review changes immediately, rather than clicking to follow a URL."
13466 msgstr ""
13468 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
13469 #: ../en/ch10-hook.xml:1065
13470 msgid "Configuring the <literal role=\"hg-ext\">notify</literal> hook"
13471 msgstr "配置 <literal role=\"hg-ext\">notify</literal> 钩子"
13473 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13474 #: ../en/ch10-hook.xml:1068
13475 msgid ""
13476 "You can set up the <literal role=\"hg-ext\">notify</literal> hook to send one "
13477 "email message per incoming changeset, or one per incoming group of changesets "
13478 "(all those that arrived in a single pull or push)."
13479 msgstr ""
13481 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13482 #: ../en/ch10-hook.xml:1080
13483 msgid ""
13484 "Configuration information for this hook lives in the <literal role=\"rc-notify"
13485 "\">notify</literal> section of a <filename role=\"special\">~/.hgrc</"
13486 "filename> file."
13487 msgstr ""
13489 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13490 #: ../en/ch10-hook.xml:1085
13491 msgid ""
13492 "<envar role=\"rc-item-notify\">test</envar>: By default, this hook does not "
13493 "send out email at all; instead, it prints the message that it "
13494 "<emphasis>would</emphasis> send. Set this item to <literal>false</literal> "
13495 "to allow email to be sent. The reason that sending of email is turned off by "
13496 "default is that it takes several tries to configure this extension exactly as "
13497 "you would like, and it would be bad form to spam subscribers with a number of "
13498 "<quote>broken</quote> notifications while you debug your configuration."
13499 msgstr ""
13501 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13502 #: ../en/ch10-hook.xml:1097
13503 msgid ""
13504 "<envar role=\"rc-item-notify\">config</envar>: The path to a configuration "
13505 "file that contains subscription information. This is kept separate from the "
13506 "main <filename role=\"special\">~/.hgrc</filename> so that you can maintain "
13507 "it in a repository of its own. People can then clone that repository, update "
13508 "their subscriptions, and push the changes back to your server."
13509 msgstr ""
13511 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13512 #: ../en/ch10-hook.xml:1106
13513 msgid ""
13514 "<envar role=\"rc-item-notify\">strip</envar>: The number of leading path "
13515 "separator characters to strip from a repository's path, when deciding whether "
13516 "a repository has subscribers. For example, if the repositories on your "
13517 "server live in <filename class=\"directory\">/home/hg/repos</filename>, and "
13518 "<literal role=\"hg-ext\">notify</literal> is considering a repository named "
13519 "<filename class=\"directory\">/home/hg/repos/shared/test</filename>, setting "
13520 "<envar role=\"rc-item-notify\">strip</envar> to <literal>4</literal> will "
13521 "cause <literal role=\"hg-ext\">notify</literal> to trim the path it considers "
13522 "down to <filename class=\"directory\">shared/test</filename>, and it will "
13523 "match subscribers against that."
13524 msgstr ""
13526 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13527 #: ../en/ch10-hook.xml:1123
13528 msgid ""
13529 "<envar role=\"rc-item-notify\">template</envar>: The template text to use "
13530 "when sending messages. This specifies both the contents of the message "
13531 "header and its body."
13532 msgstr ""
13534 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13535 #: ../en/ch10-hook.xml:1129
13536 msgid ""
13537 "<envar role=\"rc-item-notify\">maxdiff</envar>: The maximum number of lines "
13538 "of diff data to append to the end of a message. If a diff is longer than "
13539 "this, it is truncated. By default, this is set to 300. Set this to "
13540 "<literal>0</literal> to omit diffs from notification emails."
13541 msgstr ""
13543 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13544 #: ../en/ch10-hook.xml:1138
13545 msgid ""
13546 "<envar role=\"rc-item-notify\">sources</envar>: A list of sources of "
13547 "changesets to consider. This lets you limit <literal role=\"hg-ext\">notify</"
13548 "literal> to only sending out email about changes that remote users pushed "
13549 "into this repository via a server, for example. See <xref linkend=\"sec:hook:"
13550 "sources\"/> for the sources you can specify here."
13551 msgstr ""
13553 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13554 #: ../en/ch10-hook.xml:1149
13555 msgid ""
13556 "If you set the <envar role=\"rc-item-web\">baseurl</envar> item in the "
13557 "<literal role=\"rc-web\">web</literal> section, you can use it in a template; "
13558 "it will be available as <literal>webroot</literal>."
13559 msgstr ""
13561 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13562 #: ../en/ch10-hook.xml:1155
13563 msgid ""
13564 "Here is an example set of <literal role=\"hg-ext\">notify</literal> "
13565 "configuration information."
13566 msgstr ""
13568 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13569 #: ../en/ch10-hook.xml:1161
13570 msgid "This will produce a message that looks like the following:"
13571 msgstr ""
13573 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13574 #: ../en/ch10-hook.xml:1171
13575 msgid ""
13576 "Do not forget that by default, the <literal role=\"hg-ext\">notify</literal> "
13577 "extension <emphasis>will not send any mail</emphasis> until you explicitly "
13578 "configure it to do so, by setting <envar role=\"rc-item-notify\">test</envar> "
13579 "to <literal>false</literal>. Until you do that, it simply prints the message "
13580 "it <emphasis>would</emphasis> send."
13581 msgstr ""
13583 #. type: Content of: <book><chapter><sect1><title>
13584 #: ../en/ch10-hook.xml:1183
13585 msgid "Information for writers of hooks"
13586 msgstr "编写钩子的信息"
13588 #. type: Content of: <book><chapter><sect1><sect2><title>
13589 #: ../en/ch10-hook.xml:1186
13590 msgid "In-process hook execution"
13591 msgstr "进程内钩子的执行"
13593 #. type: Content of: <book><chapter><sect1><sect2><para>
13594 #: ../en/ch10-hook.xml:1188
13595 msgid "An in-process hook is called with arguments of the following form:"
13596 msgstr ""
13598 #. type: Content of: <book><chapter><sect1><sect2><para>
13599 #: ../en/ch10-hook.xml:1192
13600 msgid ""
13601 "The <literal>ui</literal> parameter is a <literal role=\"py-mod-mercurial.ui"
13602 "\">ui</literal> object. The <literal>repo</literal> parameter is a <literal "
13603 "role=\"py-mod-mercurial.localrepo\">localrepository</literal> object. The "
13604 "names and values of the <literal>**kwargs</literal> parameters depend on the "
13605 "hook being invoked, with the following common features:"
13606 msgstr ""
13608 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13609 #: ../en/ch10-hook.xml:1201
13610 msgid ""
13611 "If a parameter is named <literal>node</literal> or <literal>parentN</"
13612 "literal>, it will contain a hexadecimal changeset ID. The empty string is "
13613 "used to represent <quote>null changeset ID</quote> instead of a string of "
13614 "zeroes."
13615 msgstr ""
13617 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13618 #: ../en/ch10-hook.xml:1208
13619 msgid ""
13620 "If a parameter is named <literal>url</literal>, it will contain the URL of a "
13621 "remote repository, if that can be determined."
13622 msgstr ""
13624 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13625 #: ../en/ch10-hook.xml:1213
13626 msgid ""
13627 "Boolean-valued parameters are represented as Python <literal>bool</literal> "
13628 "objects."
13629 msgstr ""
13631 #. type: Content of: <book><chapter><sect1><sect2><para>
13632 #: ../en/ch10-hook.xml:1218
13633 msgid ""
13634 "An in-process hook is called without a change to the process's working "
13635 "directory (unlike external hooks, which are run in the root of the "
13636 "repository). It must not change the process's working directory, or it will "
13637 "cause any calls it makes into the Mercurial API to fail."
13638 msgstr ""
13640 #. type: Content of: <book><chapter><sect1><sect2><para>
13641 #: ../en/ch10-hook.xml:1225
13642 msgid ""
13643 "If a hook returns a boolean <quote>false</quote> value, it is considered to "
13644 "have succeeded. If it returns a boolean <quote>true</quote> value or raises "
13645 "an exception, it is considered to have failed. A useful way to think of the "
13646 "calling convention is <quote>tell me if you fail</quote>."
13647 msgstr ""
13649 #. type: Content of: <book><chapter><sect1><sect2><para>
13650 #: ../en/ch10-hook.xml:1232
13651 msgid ""
13652 "Note that changeset IDs are passed into Python hooks as hexadecimal strings, "
13653 "not the binary hashes that Mercurial's APIs normally use. To convert a hash "
13654 "from hex to binary, use the <literal>bin</literal> function."
13655 msgstr ""
13657 #. type: Content of: <book><chapter><sect1><sect2><title>
13658 #: ../en/ch10-hook.xml:1240
13659 msgid "External hook execution"
13660 msgstr "外部钩子的执行"
13662 #. type: Content of: <book><chapter><sect1><sect2><para>
13663 #: ../en/ch10-hook.xml:1242
13664 msgid ""
13665 "An external hook is passed to the shell of the user running Mercurial. "
13666 "Features of that shell, such as variable substitution and command "
13667 "redirection, are available. The hook is run in the root directory of the "
13668 "repository (unlike in-process hooks, which are run in the same directory that "
13669 "Mercurial was run in)."
13670 msgstr ""
13672 #. type: Content of: <book><chapter><sect1><sect2><para>
13673 #: ../en/ch10-hook.xml:1250
13674 msgid ""
13675 "Hook parameters are passed to the hook as environment variables. Each "
13676 "environment variable's name is converted in upper case and prefixed with the "
13677 "string <quote><literal>HG_</literal></quote>. For example, if the name of a "
13678 "parameter is <quote><literal>node</literal></quote>, the name of the "
13679 "environment variable representing that parameter will be "
13680 "<quote><literal>HG_NODE</literal></quote>."
13681 msgstr ""
13683 #. type: Content of: <book><chapter><sect1><sect2><para>
13684 #: ../en/ch10-hook.xml:1259
13685 msgid ""
13686 "A boolean parameter is represented as the string <quote><literal>1</literal></"
13687 "quote> for <quote>true</quote>, <quote><literal>0</literal></quote> for "
13688 "<quote>false</quote>. If an environment variable is named <envar>HG_NODE</"
13689 "envar>, <envar>HG_PARENT1</envar> or <envar>HG_PARENT2</envar>, it contains a "
13690 "changeset ID represented as a hexadecimal string. The empty string is used "
13691 "to represent <quote>null changeset ID</quote> instead of a string of zeroes. "
13692 "If an environment variable is named <envar>HG_URL</envar>, it will contain "
13693 "the URL of a remote repository, if that can be determined."
13694 msgstr ""
13696 #. type: Content of: <book><chapter><sect1><sect2><para>
13697 #: ../en/ch10-hook.xml:1271
13698 msgid ""
13699 "If a hook exits with a status of zero, it is considered to have succeeded. "
13700 "If it exits with a non-zero status, it is considered to have failed."
13701 msgstr ""
13703 #. type: Content of: <book><chapter><sect1><sect2><title>
13704 #: ../en/ch10-hook.xml:1278
13705 msgid "Finding out where changesets come from"
13706 msgstr "检查修改集来自何处"
13708 #. type: Content of: <book><chapter><sect1><sect2><para>
13709 #: ../en/ch10-hook.xml:1280
13710 msgid ""
13711 "A hook that involves the transfer of changesets between a local repository "
13712 "and another may be able to find out information about the <quote>far side</"
13713 "quote>. Mercurial knows <emphasis>how</emphasis> changes are being "
13714 "transferred, and in many cases <emphasis>where</emphasis> they are being "
13715 "transferred to or from."
13716 msgstr ""
13718 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
13719 #: ../en/ch10-hook.xml:1289
13720 msgid "Sources of changesets"
13721 msgstr "修改集的来源"
13723 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13724 #: ../en/ch10-hook.xml:1291
13725 msgid ""
13726 "Mercurial will tell a hook what means are, or were, used to transfer "
13727 "changesets between repositories. This is provided by Mercurial in a Python "
13728 "parameter named <literal>source</literal>, or an environment variable named "
13729 "<envar>HG_SOURCE</envar>."
13730 msgstr ""
13732 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13733 #: ../en/ch10-hook.xml:1299
13734 msgid ""
13735 "<literal>serve</literal>: Changesets are transferred to or from a remote "
13736 "repository over http or ssh."
13737 msgstr ""
13739 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13740 #: ../en/ch10-hook.xml:1304
13741 msgid ""
13742 "<literal>pull</literal>: Changesets are being transferred via a pull from one "
13743 "repository into another."
13744 msgstr ""
13746 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13747 #: ../en/ch10-hook.xml:1309
13748 msgid ""
13749 "<literal>push</literal>: Changesets are being transferred via a push from one "
13750 "repository into another."
13751 msgstr ""
13753 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13754 #: ../en/ch10-hook.xml:1314
13755 msgid ""
13756 "<literal>bundle</literal>: Changesets are being transferred to or from a "
13757 "bundle."
13758 msgstr ""
13760 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
13761 #: ../en/ch10-hook.xml:1321
13762 msgid "Where changes are going&emdash;remote repository URLs"
13763 msgstr "修改集要到哪里—远程版本库的地址"
13765 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13766 #: ../en/ch10-hook.xml:1324
13767 msgid ""
13768 "When possible, Mercurial will tell a hook the location of the <quote>far "
13769 "side</quote> of an activity that transfers changeset data between "
13770 "repositories. This is provided by Mercurial in a Python parameter named "
13771 "<literal>url</literal>, or an environment variable named <envar>HG_URL</"
13772 "envar>."
13773 msgstr ""
13775 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
13776 #: ../en/ch10-hook.xml:1332
13777 msgid ""
13778 "This information is not always known. If a hook is invoked in a repository "
13779 "that is being served via http or ssh, Mercurial cannot tell where the remote "
13780 "repository is, but it may know where the client is connecting from. In such "
13781 "cases, the URL will take one of the following forms:"
13782 msgstr ""
13784 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13785 #: ../en/ch10-hook.xml:1339
13786 msgid ""
13787 "<literal>remote:ssh:1.2.3.4</literal>&emdash;remote ssh client, at the IP "
13788 "address <literal>1.2.3.4</literal>."
13789 msgstr ""
13791 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13792 #: ../en/ch10-hook.xml:1344
13793 msgid ""
13794 "<literal>remote:http:1.2.3.4</literal>&emdash;remote http client, at the IP "
13795 "address <literal>1.2.3.4</literal>. If the client is using SSL, this will be "
13796 "of the form <literal>remote:https:1.2.3.4</literal>."
13797 msgstr ""
13799 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
13800 #: ../en/ch10-hook.xml:1351
13801 msgid "Empty&emdash;no information could be discovered about the remote client."
13802 msgstr ""
13804 #. type: Content of: <book><chapter><sect1><title>
13805 #: ../en/ch10-hook.xml:1359
13806 msgid "Hook reference"
13807 msgstr "钩子参考"
13809 #. type: Content of: <book><chapter><sect1><sect2><title>
13810 #: ../en/ch10-hook.xml:1362
13811 msgid ""
13812 "<literal role=\"hook\">changegroup</literal>&emdash;after remote changesets "
13813 "added"
13814 msgstr "<literal role=\"hook\">changegroup</literal>—增加远程修改集之后"
13816 #. type: Content of: <book><chapter><sect1><sect2><para>
13817 #: ../en/ch10-hook.xml:1365
13818 msgid ""
13819 "This hook is run after a group of pre-existing changesets has been added to "
13820 "the repository, for example via a <command role=\"hg-cmd\">hg pull</command> "
13821 "or <command role=\"hg-cmd\">hg unbundle</command>. This hook is run once per "
13822 "operation that added one or more changesets. This is in contrast to the "
13823 "<literal role=\"hook\">incoming</literal> hook, which is run once per "
13824 "changeset, regardless of whether the changesets arrive in a group."
13825 msgstr ""
13827 #. type: Content of: <book><chapter><sect1><sect2><para>
13828 #: ../en/ch10-hook.xml:1375
13829 msgid ""
13830 "Some possible uses for this hook include kicking off an automated build or "
13831 "test of the added changesets, updating a bug database, or notifying "
13832 "subscribers that a repository contains new changes."
13833 msgstr ""
13835 #. type: Content of: <book><chapter><sect1><sect2><para>
13836 #: ../en/ch10-hook.xml:1381 ../en/ch10-hook.xml:1421 ../en/ch10-hook.xml:1465
13837 #: ../en/ch10-hook.xml:1507 ../en/ch10-hook.xml:1562 ../en/ch10-hook.xml:1602
13838 #: ../en/ch10-hook.xml:1638 ../en/ch10-hook.xml:1672 ../en/ch10-hook.xml:1736
13839 #: ../en/ch10-hook.xml:1794 ../en/ch10-hook.xml:1830 ../en/ch10-hook.xml:1857
13840 msgid "Parameters to this hook:"
13841 msgstr ""
13843 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13844 #: ../en/ch10-hook.xml:1384 ../en/ch10-hook.xml:1739
13845 msgid ""
13846 "<literal>node</literal>: A changeset ID. The changeset ID of the first "
13847 "changeset in the group that was added. All changesets between this and "
13848 "<literal role=\"tag\">tip</literal>, inclusive, were added by a single "
13849 "<command role=\"hg-cmd\">hg pull</command>, <command role=\"hg-cmd\">hg push</"
13850 "command> or <command role=\"hg-cmd\">hg unbundle</command>."
13851 msgstr ""
13853 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13854 #: ../en/ch10-hook.xml:1393 ../en/ch10-hook.xml:1472 ../en/ch10-hook.xml:1565
13855 #: ../en/ch10-hook.xml:1749
13856 msgid ""
13857 "<literal>source</literal>: A string. The source of these changes. See <xref "
13858 "linkend=\"sec:hook:sources\"/> for details."
13859 msgstr ""
13861 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13862 #: ../en/ch10-hook.xml:1398 ../en/ch10-hook.xml:1477 ../en/ch10-hook.xml:1528
13863 #: ../en/ch10-hook.xml:1570 ../en/ch10-hook.xml:1651 ../en/ch10-hook.xml:1754
13864 msgid ""
13865 "<literal>url</literal>: A URL. The location of the remote repository, if "
13866 "known. See <xref linkend=\"sec:hook:url\"/> for more information."
13867 msgstr ""
13869 #. type: Content of: <book><chapter><sect1><sect2><para>
13870 #: ../en/ch10-hook.xml:1404
13871 msgid ""
13872 "See also: <literal role=\"hook\">incoming</literal> (<xref linkend=\"sec:hook:"
13873 "incoming\"/>), <literal role=\"hook\">prechangegroup</literal> (<xref linkend="
13874 "\"sec:hook:prechangegroup\"/>), <literal role=\"hook\">pretxnchangegroup</"
13875 "literal> (<xref linkend=\"sec:hook:pretxnchangegroup\"/>)"
13876 msgstr ""
13878 #. type: Content of: <book><chapter><sect1><sect2><title>
13879 #: ../en/ch10-hook.xml:1415
13880 msgid ""
13881 "<literal role=\"hook\">commit</literal>&emdash;after a new changeset is "
13882 "created"
13883 msgstr "<literal role=\"hook\">commit</literal>—创建新修改集之后"
13885 #. type: Content of: <book><chapter><sect1><sect2><para>
13886 #: ../en/ch10-hook.xml:1418
13887 msgid "This hook is run after a new changeset has been created."
13888 msgstr ""
13890 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13891 #: ../en/ch10-hook.xml:1424 ../en/ch10-hook.xml:1797
13892 msgid ""
13893 "<literal>node</literal>: A changeset ID. The changeset ID of the newly "
13894 "committed changeset."
13895 msgstr ""
13897 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13898 #: ../en/ch10-hook.xml:1428 ../en/ch10-hook.xml:1801
13899 msgid ""
13900 "<literal>parent1</literal>: A changeset ID. The changeset ID of the first "
13901 "parent of the newly committed changeset."
13902 msgstr ""
13904 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13905 #: ../en/ch10-hook.xml:1433 ../en/ch10-hook.xml:1806
13906 msgid ""
13907 "<literal>parent2</literal>: A changeset ID. The changeset ID of the second "
13908 "parent of the newly committed changeset."
13909 msgstr ""
13911 #. type: Content of: <book><chapter><sect1><sect2><para>
13912 #: ../en/ch10-hook.xml:1439
13913 msgid ""
13914 "See also: <literal role=\"hook\">precommit</literal> (<xref linkend=\"sec:"
13915 "hook:precommit\"/>), <literal role=\"hook\">pretxncommit</literal> (<xref "
13916 "linkend=\"sec:hook:pretxncommit\"/>)"
13917 msgstr ""
13919 #. type: Content of: <book><chapter><sect1><sect2><title>
13920 #: ../en/ch10-hook.xml:1448
13921 msgid ""
13922 "<literal role=\"hook\">incoming</literal>&emdash;after one remote changeset "
13923 "is added"
13924 msgstr "<literal role=\"hook\">incoming</literal>—增加远程修改集之后"
13926 #. type: Content of: <book><chapter><sect1><sect2><para>
13927 #: ../en/ch10-hook.xml:1451
13928 msgid ""
13929 "This hook is run after a pre-existing changeset has been added to the "
13930 "repository, for example via a <command role=\"hg-cmd\">hg push</command>. If "
13931 "a group of changesets was added in a single operation, this hook is called "
13932 "once for each added changeset."
13933 msgstr ""
13935 #. type: Content of: <book><chapter><sect1><sect2><para>
13936 #: ../en/ch10-hook.xml:1458
13937 msgid ""
13938 "You can use this hook for the same purposes as the <literal role=\"hook"
13939 "\">changegroup</literal> hook (<xref linkend=\"sec:hook:changegroup\"/>); "
13940 "it's simply more convenient sometimes to run a hook once per group of "
13941 "changesets, while other times it's handier once per changeset."
13942 msgstr ""
13944 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13945 #: ../en/ch10-hook.xml:1468
13946 msgid ""
13947 "<literal>node</literal>: A changeset ID. The ID of the newly added changeset."
13948 msgstr ""
13950 #. type: Content of: <book><chapter><sect1><sect2><para>
13951 #: ../en/ch10-hook.xml:1483
13952 msgid ""
13953 "See also: <literal role=\"hook\">changegroup</literal> (<xref linkend=\"sec:"
13954 "hook:changegroup\"/>) <literal role=\"hook\">prechangegroup</literal> (<xref "
13955 "linkend=\"sec:hook:prechangegroup\"/>), <literal role=\"hook"
13956 "\">pretxnchangegroup</literal> (<xref linkend=\"sec:hook:pretxnchangegroup\"/"
13957 ">)"
13958 msgstr ""
13960 #. type: Content of: <book><chapter><sect1><sect2><title>
13961 #: ../en/ch10-hook.xml:1494
13962 msgid ""
13963 "<literal role=\"hook\">outgoing</literal>&emdash;after changesets are "
13964 "propagated"
13965 msgstr "<literal role=\"hook\">outgoing</literal>—传播修改集之后"
13967 #. type: Content of: <book><chapter><sect1><sect2><para>
13968 #: ../en/ch10-hook.xml:1497
13969 msgid ""
13970 "This hook is run after a group of changesets has been propagated out of this "
13971 "repository, for example by a <command role=\"hg-cmd\">hg push</command> or "
13972 "<command role=\"hg-cmd\">hg bundle</command> command."
13973 msgstr ""
13975 #. type: Content of: <book><chapter><sect1><sect2><para>
13976 #: ../en/ch10-hook.xml:1503
13977 msgid ""
13978 "One possible use for this hook is to notify administrators that changes have "
13979 "been pulled."
13980 msgstr ""
13982 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13983 #: ../en/ch10-hook.xml:1510
13984 msgid ""
13985 "<literal>node</literal>: A changeset ID. The changeset ID of the first "
13986 "changeset of the group that was sent."
13987 msgstr ""
13989 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13990 #: ../en/ch10-hook.xml:1515
13991 msgid ""
13992 "<literal>source</literal>: A string. The source of the of the operation (see "
13993 "<xref linkend=\"sec:hook:sources\"/>). If a remote client pulled changes "
13994 "from this repository, <literal>source</literal> will be <literal>serve</"
13995 "literal>. If the client that obtained changes from this repository was "
13996 "local, <literal>source</literal> will be <literal>bundle</literal>, "
13997 "<literal>pull</literal>, or <literal>push</literal>, depending on the "
13998 "operation the client performed."
13999 msgstr ""
14001 #. type: Content of: <book><chapter><sect1><sect2><para>
14002 #: ../en/ch10-hook.xml:1534
14003 msgid ""
14004 "See also: <literal role=\"hook\">preoutgoing</literal> (<xref linkend=\"sec:"
14005 "hook:preoutgoing\"/>)"
14006 msgstr ""
14008 #. type: Content of: <book><chapter><sect1><sect2><title>
14009 #: ../en/ch10-hook.xml:1541
14010 msgid ""
14011 "<literal role=\"hook\">prechangegroup</literal>&emdash;before starting to add "
14012 "remote changesets"
14013 msgstr "<literal role=\"hook\">prechangegroup</literal>—增加远程修改集之前"
14015 #. type: Content of: <book><chapter><sect1><sect2><para>
14016 #: ../en/ch10-hook.xml:1545
14017 msgid ""
14018 "This controlling hook is run before Mercurial begins to add a group of "
14019 "changesets from another repository."
14020 msgstr ""
14022 #. type: Content of: <book><chapter><sect1><sect2><para>
14023 #: ../en/ch10-hook.xml:1549
14024 msgid ""
14025 "This hook does not have any information about the changesets to be added, "
14026 "because it is run before transmission of those changesets is allowed to "
14027 "begin. If this hook fails, the changesets will not be transmitted."
14028 msgstr ""
14030 #. type: Content of: <book><chapter><sect1><sect2><para>
14031 #: ../en/ch10-hook.xml:1555
14032 msgid ""
14033 "One use for this hook is to prevent external changes from being added to a "
14034 "repository. For example, you could use this to <quote>freeze</quote> a "
14035 "server-hosted branch temporarily or permanently so that users cannot push to "
14036 "it, while still allowing a local administrator to modify the repository."
14037 msgstr ""
14039 #. type: Content of: <book><chapter><sect1><sect2><para>
14040 #: ../en/ch10-hook.xml:1576
14041 msgid ""
14042 "See also: <literal role=\"hook\">changegroup</literal> (<xref linkend=\"sec:"
14043 "hook:changegroup\"/>), <literal role=\"hook\">incoming</literal> (<xref "
14044 "linkend=\"sec:hook:incoming\"/>), <literal role=\"hook\">pretxnchangegroup</"
14045 "literal> (<xref linkend=\"sec:hook:pretxnchangegroup\"/>)"
14046 msgstr ""
14048 #. type: Content of: <book><chapter><sect1><sect2><title>
14049 #: ../en/ch10-hook.xml:1587
14050 msgid ""
14051 "<literal role=\"hook\">precommit</literal>&emdash;before starting to commit a "
14052 "changeset"
14053 msgstr "<literal role=\"hook\">precommit</literal>—提交修改集之前"
14055 #. type: Content of: <book><chapter><sect1><sect2><para>
14056 #: ../en/ch10-hook.xml:1590
14057 msgid ""
14058 "This hook is run before Mercurial begins to commit a new changeset. It is run "
14059 "before Mercurial has any of the metadata for the commit, such as the files to "
14060 "be committed, the commit message, or the commit date."
14061 msgstr ""
14063 #. type: Content of: <book><chapter><sect1><sect2><para>
14064 #: ../en/ch10-hook.xml:1596
14065 msgid ""
14066 "One use for this hook is to disable the ability to commit new changesets, "
14067 "while still allowing incoming changesets. Another is to run a build or test, "
14068 "and only allow the commit to begin if the build or test succeeds."
14069 msgstr ""
14071 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14072 #: ../en/ch10-hook.xml:1605
14073 msgid ""
14074 "<literal>parent1</literal>: A changeset ID. The changeset ID of the first "
14075 "parent of the working directory."
14076 msgstr ""
14078 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14079 #: ../en/ch10-hook.xml:1610
14080 msgid ""
14081 "<literal>parent2</literal>: A changeset ID. The changeset ID of the second "
14082 "parent of the working directory."
14083 msgstr ""
14085 #. type: Content of: <book><chapter><sect1><sect2><para>
14086 #: ../en/ch10-hook.xml:1615
14087 msgid ""
14088 "If the commit proceeds, the parents of the working directory will become the "
14089 "parents of the new changeset."
14090 msgstr ""
14092 #. type: Content of: <book><chapter><sect1><sect2><para>
14093 #: ../en/ch10-hook.xml:1619
14094 msgid ""
14095 "See also: <literal role=\"hook\">commit</literal> (<xref linkend=\"sec:hook:"
14096 "commit\"/>), <literal role=\"hook\">pretxncommit</literal> (<xref linkend="
14097 "\"sec:hook:pretxncommit\"/>)"
14098 msgstr ""
14100 #. type: Content of: <book><chapter><sect1><sect2><title>
14101 #: ../en/ch10-hook.xml:1627
14102 msgid ""
14103 "<literal role=\"hook\">preoutgoing</literal>&emdash;before starting to "
14104 "propagate changesets"
14105 msgstr "<literal role=\"hook\">preoutgoing</literal>—传播修改集之前"
14107 #. type: Content of: <book><chapter><sect1><sect2><para>
14108 #: ../en/ch10-hook.xml:1630
14109 msgid ""
14110 "This hook is invoked before Mercurial knows the identities of the changesets "
14111 "to be transmitted."
14112 msgstr ""
14114 #. type: Content of: <book><chapter><sect1><sect2><para>
14115 #: ../en/ch10-hook.xml:1634
14116 msgid ""
14117 "One use for this hook is to prevent changes from being transmitted to another "
14118 "repository."
14119 msgstr ""
14121 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14122 #: ../en/ch10-hook.xml:1641
14123 msgid ""
14124 "<literal>source</literal>: A string. The source of the operation that is "
14125 "attempting to obtain changes from this repository (see <xref linkend=\"sec:"
14126 "hook:sources\"/>). See the documentation for the <literal>source</literal> "
14127 "parameter to the <literal role=\"hook\">outgoing</literal> hook, in <xref "
14128 "linkend=\"sec:hook:outgoing\"/>, for possible values of this parameter."
14129 msgstr ""
14131 #. type: Content of: <book><chapter><sect1><sect2><para>
14132 #: ../en/ch10-hook.xml:1657
14133 msgid ""
14134 "See also: <literal role=\"hook\">outgoing</literal> (<xref linkend=\"sec:hook:"
14135 "outgoing\"/>)"
14136 msgstr ""
14138 #. type: Content of: <book><chapter><sect1><sect2><title>
14139 #: ../en/ch10-hook.xml:1664
14140 msgid ""
14141 "<literal role=\"hook\">pretag</literal>&emdash;before tagging a changeset"
14142 msgstr "<literal role=\"hook\">pretag</literal>—创建标签之前"
14144 #. type: Content of: <book><chapter><sect1><sect2><para>
14145 #: ../en/ch10-hook.xml:1667
14146 msgid ""
14147 "This controlling hook is run before a tag is created. If the hook succeeds, "
14148 "creation of the tag proceeds. If the hook fails, the tag is not created."
14149 msgstr ""
14151 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14152 #: ../en/ch10-hook.xml:1675
14153 msgid ""
14154 "<literal>local</literal>: A boolean. Whether the tag is local to this "
14155 "repository instance (i.e. stored in <filename role=\"special\">.hg/localtags</"
14156 "filename>) or managed by Mercurial (stored in <filename role=\"special\">."
14157 "hgtags</filename>)."
14158 msgstr ""
14160 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14161 #: ../en/ch10-hook.xml:1682
14162 msgid ""
14163 "<literal>node</literal>: A changeset ID. The ID of the changeset to be "
14164 "tagged."
14165 msgstr ""
14167 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14168 #: ../en/ch10-hook.xml:1686
14169 msgid "<literal>tag</literal>: A string. The name of the tag to be created."
14170 msgstr ""
14172 #. type: Content of: <book><chapter><sect1><sect2><para>
14173 #: ../en/ch10-hook.xml:1691
14174 msgid ""
14175 "If the tag to be created is revision-controlled, the <literal role=\"hook"
14176 "\">precommit</literal> and <literal role=\"hook\">pretxncommit</literal> "
14177 "hooks (<xref linkend=\"sec:hook:commit\"/> and <xref linkend=\"sec:hook:"
14178 "pretxncommit\"/>) will also be run."
14179 msgstr ""
14181 #. type: Content of: <book><chapter><sect1><sect2><para>
14182 #: ../en/ch10-hook.xml:1699
14183 msgid ""
14184 "See also: <literal role=\"hook\">tag</literal> (<xref linkend=\"sec:hook:tag"
14185 "\"/>)"
14186 msgstr ""
14188 #. type: Content of: <book><chapter><sect1><sect2><title>
14189 #: ../en/ch10-hook.xml:1705
14190 msgid ""
14191 "<literal role=\"hook\">pretxnchangegroup</literal>&emdash;before completing "
14192 "addition of remote changesets"
14193 msgstr ""
14194 "<literal role=\"hook\">pretxnchangegroup</literal>—完成增加远程修改集之前"
14196 #. type: Content of: <book><chapter><sect1><sect2><para>
14197 #: ../en/ch10-hook.xml:1709
14198 msgid ""
14199 "This controlling hook is run before a transaction&emdash;that manages the "
14200 "addition of a group of new changesets from outside the repository&emdash;"
14201 "completes. If the hook succeeds, the transaction completes, and all of the "
14202 "changesets become permanent within this repository. If the hook fails, the "
14203 "transaction is rolled back, and the data for the changesets is erased."
14204 msgstr ""
14206 #. type: Content of: <book><chapter><sect1><sect2><para>
14207 #: ../en/ch10-hook.xml:1718
14208 msgid ""
14209 "This hook can access the metadata associated with the almost-added "
14210 "changesets, but it should not do anything permanent with this data. It must "
14211 "also not modify the working directory."
14212 msgstr ""
14214 #. type: Content of: <book><chapter><sect1><sect2><para>
14215 #: ../en/ch10-hook.xml:1724
14216 msgid ""
14217 "While this hook is running, if other Mercurial processes access this "
14218 "repository, they will be able to see the almost-added changesets as if they "
14219 "are permanent. This may lead to race conditions if you do not take steps to "
14220 "avoid them."
14221 msgstr ""
14223 #. type: Content of: <book><chapter><sect1><sect2><para>
14224 #: ../en/ch10-hook.xml:1731
14225 msgid ""
14226 "This hook can be used to automatically vet a group of changesets. If the "
14227 "hook fails, all of the changesets are <quote>rejected</quote> when the "
14228 "transaction rolls back."
14229 msgstr ""
14231 #. type: Content of: <book><chapter><sect1><sect2><para>
14232 #: ../en/ch10-hook.xml:1760
14233 msgid ""
14234 "See also: <literal role=\"hook\">changegroup</literal> (<xref linkend=\"sec:"
14235 "hook:changegroup\"/>), <literal role=\"hook\">incoming</literal> (<xref "
14236 "linkend=\"sec:hook:incoming\"/>), <literal role=\"hook\">prechangegroup</"
14237 "literal> (<xref linkend=\"sec:hook:prechangegroup\"/>)"
14238 msgstr ""
14240 #. type: Content of: <book><chapter><sect1><sect2><title>
14241 #: ../en/ch10-hook.xml:1771
14242 msgid ""
14243 "<literal role=\"hook\">pretxncommit</literal>&emdash;before completing commit "
14244 "of new changeset"
14245 msgstr "<literal role=\"hook\">pretxncommit</literal>—完成提交之前"
14247 #. type: Content of: <book><chapter><sect1><sect2><para>
14248 #: ../en/ch10-hook.xml:1774
14249 msgid ""
14250 "This controlling hook is run before a transaction&emdash;that manages a new "
14251 "commit&emdash;completes. If the hook succeeds, the transaction completes and "
14252 "the changeset becomes permanent within this repository. If the hook fails, "
14253 "the transaction is rolled back, and the commit data is erased."
14254 msgstr ""
14256 #. type: Content of: <book><chapter><sect1><sect2><para>
14257 #: ../en/ch10-hook.xml:1782
14258 msgid ""
14259 "This hook can access the metadata associated with the almost-new changeset, "
14260 "but it should not do anything permanent with this data. It must also not "
14261 "modify the working directory."
14262 msgstr ""
14264 #. type: Content of: <book><chapter><sect1><sect2><para>
14265 #: ../en/ch10-hook.xml:1788
14266 msgid ""
14267 "While this hook is running, if other Mercurial processes access this "
14268 "repository, they will be able to see the almost-new changeset as if it is "
14269 "permanent. This may lead to race conditions if you do not take steps to "
14270 "avoid them."
14271 msgstr ""
14273 #. type: Content of: <book><chapter><sect1><sect2><para>
14274 #: ../en/ch10-hook.xml:1812
14275 msgid ""
14276 "See also: <literal role=\"hook\">precommit</literal> (<xref linkend=\"sec:"
14277 "hook:precommit\"/>)"
14278 msgstr ""
14279 "参见: <literal role=\"hook\">precommit</literal> (<xref linkend=\"sec:hook:"
14280 "precommit\"/>)"
14282 #. type: Content of: <book><chapter><sect1><sect2><title>
14283 #: ../en/ch10-hook.xml:1819
14284 msgid ""
14285 "<literal role=\"hook\">preupdate</literal>&emdash;before updating or merging "
14286 "working directory"
14287 msgstr "<literal role=\"hook\">preupdate</literal>—更新或合并工作目录之前"
14289 #. type: Content of: <book><chapter><sect1><sect2><para>
14290 #: ../en/ch10-hook.xml:1822
14291 msgid ""
14292 "This controlling hook is run before an update or merge of the working "
14293 "directory begins. It is run only if Mercurial's normal pre-update checks "
14294 "determine that the update or merge can proceed. If the hook succeeds, the "
14295 "update or merge may proceed; if it fails, the update or merge does not start."
14296 msgstr ""
14298 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14299 #: ../en/ch10-hook.xml:1833
14300 msgid ""
14301 "<literal>parent1</literal>: A changeset ID. The ID of the parent that the "
14302 "working directory is to be updated to. If the working directory is being "
14303 "merged, it will not change this parent."
14304 msgstr ""
14306 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14307 #: ../en/ch10-hook.xml:1839
14308 msgid ""
14309 "<literal>parent2</literal>: A changeset ID. Only set if the working directory "
14310 "is being merged. The ID of the revision that the working directory is being "
14311 "merged with."
14312 msgstr ""
14314 #. type: Content of: <book><chapter><sect1><sect2><para>
14315 #: ../en/ch10-hook.xml:1846
14316 msgid ""
14317 "See also: <literal role=\"hook\">update</literal> (<xref linkend=\"sec:hook:"
14318 "update\"/>)"
14319 msgstr ""
14321 #. type: Content of: <book><chapter><sect1><sect2><title>
14322 #: ../en/ch10-hook.xml:1851
14323 msgid "<literal role=\"hook\">tag</literal>&emdash;after tagging a changeset"
14324 msgstr "<literal role=\"hook\">tag</literal>—创建标签之后"
14326 #. type: Content of: <book><chapter><sect1><sect2><para>
14327 #: ../en/ch10-hook.xml:1854
14328 msgid "This hook is run after a tag has been created."
14329 msgstr ""
14331 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14332 #: ../en/ch10-hook.xml:1860
14333 msgid ""
14334 "<literal>local</literal>: A boolean. Whether the new tag is local to this "
14335 "repository instance (i.e. stored in <filename role=\"special\">.hg/"
14336 "localtags</filename>) or managed by Mercurial (stored in <filename role="
14337 "\"special\">.hgtags</filename>)."
14338 msgstr ""
14340 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14341 #: ../en/ch10-hook.xml:1868
14342 msgid ""
14343 "<literal>node</literal>: A changeset ID. The ID of the changeset that was "
14344 "tagged."
14345 msgstr ""
14347 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14348 #: ../en/ch10-hook.xml:1872
14349 msgid "<literal>tag</literal>: A string. The name of the tag that was created."
14350 msgstr ""
14352 #. type: Content of: <book><chapter><sect1><sect2><para>
14353 #: ../en/ch10-hook.xml:1877
14354 msgid ""
14355 "If the created tag is revision-controlled, the <literal role=\"hook\">commit</"
14356 "literal> hook (section <xref linkend=\"sec:hook:commit\"/>) is run before "
14357 "this hook."
14358 msgstr ""
14360 #. type: Content of: <book><chapter><sect1><sect2><para>
14361 #: ../en/ch10-hook.xml:1882
14362 msgid ""
14363 "See also: <literal role=\"hook\">pretag</literal> (<xref linkend=\"sec:hook:"
14364 "pretag\"/>)"
14365 msgstr ""
14366 "参见: <literal role=\"hook\">pretag</literal> (<xref linkend=\"sec:hook:pretag"
14367 "\"/>)"
14369 #. type: Content of: <book><chapter><sect1><sect2><title>
14370 #: ../en/ch10-hook.xml:1888
14371 msgid ""
14372 "<literal role=\"hook\">update</literal>&emdash;after updating or merging "
14373 "working directory"
14374 msgstr "<literal role=\"hook\">update</literal>—更新或合并工作目录之后"
14376 #. type: Content of: <book><chapter><sect1><sect2><para>
14377 #: ../en/ch10-hook.xml:1891
14378 msgid ""
14379 "This hook is run after an update or merge of the working directory "
14380 "completes. Since a merge can fail (if the external <command>hgmerge</"
14381 "command> command fails to resolve conflicts in a file), this hook "
14382 "communicates whether the update or merge completed cleanly."
14383 msgstr ""
14385 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14386 #: ../en/ch10-hook.xml:1899
14387 msgid ""
14388 "<literal>error</literal>: A boolean. Indicates whether the update or merge "
14389 "completed successfully."
14390 msgstr ""
14392 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14393 #: ../en/ch10-hook.xml:1904
14394 msgid ""
14395 "<literal>parent1</literal>: A changeset ID. The ID of the parent that the "
14396 "working directory was updated to. If the working directory was merged, it "
14397 "will not have changed this parent."
14398 msgstr ""
14400 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14401 #: ../en/ch10-hook.xml:1910
14402 msgid ""
14403 "<literal>parent2</literal>: A changeset ID. Only set if the working "
14404 "directory was merged. The ID of the revision that the working directory was "
14405 "merged with."
14406 msgstr ""
14408 #. type: Content of: <book><chapter><sect1><sect2><para>
14409 #: ../en/ch10-hook.xml:1916
14410 msgid ""
14411 "See also: <literal role=\"hook\">preupdate</literal> (<xref linkend=\"sec:"
14412 "hook:preupdate\"/>)"
14413 msgstr ""
14415 #. type: Content of: <book><chapter><title>
14416 #: ../en/ch11-template.xml:5
14417 msgid "Customizing the output of Mercurial"
14418 msgstr "定制 Mercurial 的输出"
14420 #. type: Content of: <book><chapter><para>
14421 #: ../en/ch11-template.xml:7
14422 msgid ""
14423 "Mercurial provides a powerful mechanism to let you control how it displays "
14424 "information. The mechanism is based on templates. You can use templates to "
14425 "generate specific output for a single command, or to customize the entire "
14426 "appearance of the built-in web interface."
14427 msgstr ""
14429 #. type: Content of: <book><chapter><sect1><title>
14430 #: ../en/ch11-template.xml:14
14431 msgid "Using precanned output styles"
14432 msgstr "使用预定义的输出样式"
14434 #. type: Content of: <book><chapter><sect1><para>
14435 #: ../en/ch11-template.xml:16
14436 msgid ""
14437 "Packaged with Mercurial are some output styles that you can use immediately. "
14438 "A style is simply a precanned template that someone wrote and installed "
14439 "somewhere that Mercurial can find."
14440 msgstr ""
14442 #. type: Content of: <book><chapter><sect1><para>
14443 #: ../en/ch11-template.xml:21
14444 msgid ""
14445 "Before we take a look at Mercurial's bundled styles, let's review its normal "
14446 "output."
14447 msgstr ""
14449 #. type: Content of: <book><chapter><sect1><para>
14450 #: ../en/ch11-template.xml:26
14451 msgid ""
14452 "This is somewhat informative, but it takes up a lot of space&emdash;five "
14453 "lines of output per changeset. The <literal>compact</literal> style reduces "
14454 "this to three lines, presented in a sparse manner."
14455 msgstr ""
14457 #. type: Content of: <book><chapter><sect1><para>
14458 #: ../en/ch11-template.xml:33
14459 msgid ""
14460 "The <literal>changelog</literal> style hints at the expressive power of "
14461 "Mercurial's templating engine. This style attempts to follow the GNU "
14462 "Project's changelog guidelines<citation>web:changelog</citation>."
14463 msgstr ""
14465 #. type: Content of: <book><chapter><sect1><para>
14466 #: ../en/ch11-template.xml:40
14467 msgid ""
14468 "You will not be shocked to learn that Mercurial's default output style is "
14469 "named <literal>default</literal>."
14470 msgstr ""
14472 #. type: Content of: <book><chapter><sect1><sect2><title>
14473 #: ../en/ch11-template.xml:44
14474 msgid "Setting a default style"
14475 msgstr "设置默认样式"
14477 #. type: Content of: <book><chapter><sect1><sect2><para>
14478 #: ../en/ch11-template.xml:46
14479 msgid ""
14480 "You can modify the output style that Mercurial will use for every command by "
14481 "editing your <filename role=\"special\">~/.hgrc</filename> file, naming the "
14482 "style you would prefer to use."
14483 msgstr ""
14485 #. type: Content of: <book><chapter><sect1><sect2><para>
14486 #: ../en/ch11-template.xml:54
14487 msgid ""
14488 "If you write a style of your own, you can use it by either providing the path "
14489 "to your style file, or copying your style file into a location where "
14490 "Mercurial can find it (typically the <literal>templates</literal> "
14491 "subdirectory of your Mercurial install directory)."
14492 msgstr ""
14494 #. type: Content of: <book><chapter><sect1><title>
14495 #: ../en/ch11-template.xml:63
14496 msgid "Commands that support styles and templates"
14497 msgstr "支持样式和模版的命令"
14499 #. type: Content of: <book><chapter><sect1><para>
14500 #: ../en/ch11-template.xml:65
14501 msgid ""
14502 "All of Mercurial's <quote><literal>log</literal>-like</quote> commands let "
14503 "you use styles and templates: <command role=\"hg-cmd\">hg incoming</command>, "
14504 "<command role=\"hg-cmd\">hg log</command>, <command role=\"hg-cmd\">hg "
14505 "outgoing</command>, and <command role=\"hg-cmd\">hg tip</command>."
14506 msgstr ""
14508 #. type: Content of: <book><chapter><sect1><para>
14509 #: ../en/ch11-template.xml:72
14510 msgid ""
14511 "As I write this manual, these are so far the only commands that support "
14512 "styles and templates. Since these are the most important commands that need "
14513 "customizable output, there has been little pressure from the Mercurial user "
14514 "community to add style and template support to other commands."
14515 msgstr ""
14517 #. type: Content of: <book><chapter><sect1><title>
14518 #: ../en/ch11-template.xml:80
14519 msgid "The basics of templating"
14520 msgstr "模版基础"
14522 #. type: Content of: <book><chapter><sect1><para>
14523 #: ../en/ch11-template.xml:82
14524 msgid ""
14525 "At its simplest, a Mercurial template is a piece of text. Some of the text "
14526 "never changes, while other parts are <emphasis>expanded</emphasis>, or "
14527 "replaced with new text, when necessary."
14528 msgstr ""
14530 #. type: Content of: <book><chapter><sect1><para>
14531 #: ../en/ch11-template.xml:87
14532 msgid ""
14533 "Before we continue, let's look again at a simple example of Mercurial's "
14534 "normal output."
14535 msgstr ""
14537 #. type: Content of: <book><chapter><sect1><para>
14538 #: ../en/ch11-template.xml:92
14539 msgid ""
14540 "Now, let's run the same command, but using a template to change its output."
14541 msgstr ""
14543 #. type: Content of: <book><chapter><sect1><para>
14544 #: ../en/ch11-template.xml:97
14545 msgid ""
14546 "The example above illustrates the simplest possible template; it's just a "
14547 "piece of static text, printed once for each changeset. The <option role=\"hg-"
14548 "opt-log\">--template</option> option to the <command role=\"hg-cmd\">hg log</"
14549 "command> command tells Mercurial to use the given text as the template when "
14550 "printing each changeset."
14551 msgstr ""
14553 #. type: Content of: <book><chapter><sect1><para>
14554 #: ../en/ch11-template.xml:105
14555 msgid ""
14556 "Notice that the template string above ends with the text <quote><literal>\\n</"
14557 "literal></quote>. This is an <emphasis>escape sequence</emphasis>, telling "
14558 "Mercurial to print a newline at the end of each template item. If you omit "
14559 "this newline, Mercurial will run each piece of output together. See <xref "
14560 "linkend=\"sec:template:escape\"/> for more details of escape sequences."
14561 msgstr ""
14563 #. type: Content of: <book><chapter><sect1><para>
14564 #: ../en/ch11-template.xml:113
14565 msgid ""
14566 "A template that prints a fixed string of text all the time isn't very useful; "
14567 "let's try something a bit more complex."
14568 msgstr ""
14570 #. type: Content of: <book><chapter><sect1><para>
14571 #: ../en/ch11-template.xml:119
14572 msgid ""
14573 "As you can see, the string <quote><literal>{desc}</literal></quote> in the "
14574 "template has been replaced in the output with the description of each "
14575 "changeset. Every time Mercurial finds text enclosed in curly braces "
14576 "(<quote><literal>{</literal></quote> and <quote><literal>}</literal></"
14577 "quote>), it will try to replace the braces and text with the expansion of "
14578 "whatever is inside. To print a literal curly brace, you must escape it, as "
14579 "described in <xref linkend=\"sec:template:escape\"/>."
14580 msgstr ""
14582 #. type: Content of: <book><chapter><sect1><title>
14583 #: ../en/ch11-template.xml:131
14584 msgid "Common template keywords"
14585 msgstr "模版关键字"
14587 #. type: Content of: <book><chapter><sect1><para>
14588 #: ../en/ch11-template.xml:133
14589 msgid ""
14590 "You can start writing simple templates immediately using the keywords below."
14591 msgstr ""
14593 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14594 #: ../en/ch11-template.xml:137
14595 msgid ""
14596 "<literal role=\"template-keyword\">author</literal>: String. The unmodified "
14597 "author of the changeset."
14598 msgstr ""
14600 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14601 #: ../en/ch11-template.xml:141
14602 msgid ""
14603 "<literal role=\"template-keyword\">branches</literal>: String. The name of "
14604 "the branch on which the changeset was committed. Will be empty if the branch "
14605 "name was <literal>default</literal>."
14606 msgstr ""
14608 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14609 #: ../en/ch11-template.xml:147
14610 msgid ""
14611 "<literal role=\"template-keyword\">date</literal>: Date information. The "
14612 "date when the changeset was committed. This is <emphasis>not</emphasis> "
14613 "human-readable; you must pass it through a filter that will render it "
14614 "appropriately. See <xref linkend=\"sec:template:filter\"/> for more "
14615 "information on filters. The date is expressed as a pair of numbers. The "
14616 "first number is a Unix UTC timestamp (seconds since January 1, 1970); the "
14617 "second is the offset of the committer's timezone from UTC, in seconds."
14618 msgstr ""
14620 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14621 #: ../en/ch11-template.xml:158
14622 msgid ""
14623 "<literal role=\"template-keyword\">desc</literal>: String. The text of the "
14624 "changeset description."
14625 msgstr ""
14627 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14628 #: ../en/ch11-template.xml:161
14629 msgid ""
14630 "<literal role=\"template-keyword\">files</literal>: List of strings. All "
14631 "files modified, added, or removed by this changeset."
14632 msgstr ""
14634 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14635 #: ../en/ch11-template.xml:166
14636 msgid ""
14637 "<literal role=\"template-keyword\">file_adds</literal>: List of strings. "
14638 "Files added by this changeset."
14639 msgstr ""
14641 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14642 #: ../en/ch11-template.xml:170
14643 msgid ""
14644 "<literal role=\"template-keyword\">file_dels</literal>: List of strings. "
14645 "Files removed by this changeset."
14646 msgstr ""
14648 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14649 #: ../en/ch11-template.xml:174
14650 msgid ""
14651 "<literal role=\"template-keyword\">node</literal>: String. The changeset "
14652 "identification hash, as a 40-character hexadecimal string."
14653 msgstr ""
14655 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14656 #: ../en/ch11-template.xml:178
14657 msgid ""
14658 "<literal role=\"template-keyword\">parents</literal>: List of strings. The "
14659 "parents of the changeset."
14660 msgstr ""
14662 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14663 #: ../en/ch11-template.xml:182
14664 msgid ""
14665 "<literal role=\"template-keyword\">rev</literal>: Integer. The repository-"
14666 "local changeset revision number."
14667 msgstr ""
14669 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14670 #: ../en/ch11-template.xml:186
14671 msgid ""
14672 "<literal role=\"template-keyword\">tags</literal>: List of strings. Any tags "
14673 "associated with the changeset."
14674 msgstr ""
14676 #. type: Content of: <book><chapter><sect1><para>
14677 #: ../en/ch11-template.xml:192
14678 msgid ""
14679 "A few simple experiments will show us what to expect when we use these "
14680 "keywords; you can see the results below."
14681 msgstr ""
14683 #. type: Content of: <book><chapter><sect1><para>
14684 #: ../en/ch11-template.xml:197
14685 msgid ""
14686 "As we noted above, the date keyword does not produce human-readable output, "
14687 "so we must treat it specially. This involves using a <emphasis>filter</"
14688 "emphasis>, about which more in <xref linkend=\"sec:template:filter\"/>."
14689 msgstr ""
14691 #. type: Content of: <book><chapter><sect1><title>
14692 #: ../en/ch11-template.xml:206
14693 msgid "Escape sequences"
14694 msgstr "转义序列"
14696 #. type: Content of: <book><chapter><sect1><para>
14697 #: ../en/ch11-template.xml:208
14698 msgid ""
14699 "Mercurial's templating engine recognises the most commonly used escape "
14700 "sequences in strings. When it sees a backslash (<quote><literal>\\</"
14701 "literal></quote>) character, it looks at the following character and "
14702 "substitutes the two characters with a single replacement, as described below."
14703 msgstr ""
14705 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14706 #: ../en/ch11-template.xml:215
14707 msgid ""
14708 "<literal>\\</literal>: Backslash, <quote><literal>\\</literal></quote>, ASCII "
14709 "134."
14710 msgstr ""
14712 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14713 #: ../en/ch11-template.xml:219
14714 msgid "<literal>\\n</literal>: Newline, ASCII 12."
14715 msgstr ""
14717 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14718 #: ../en/ch11-template.xml:222
14719 msgid "<literal>\\r</literal>: Carriage return, ASCII 15."
14720 msgstr ""
14722 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14723 #: ../en/ch11-template.xml:225
14724 msgid "<literal>\\t</literal>: Tab, ASCII 11."
14725 msgstr ""
14727 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14728 #: ../en/ch11-template.xml:228
14729 msgid "<literal>\\v</literal>: Vertical tab, ASCII 13."
14730 msgstr ""
14732 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14733 #: ../en/ch11-template.xml:231
14734 msgid ""
14735 "<literal>\\{</literal>: Open curly brace, <quote><literal>{</literal></"
14736 "quote>, ASCII 173."
14737 msgstr ""
14739 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14740 #: ../en/ch11-template.xml:235
14741 msgid ""
14742 "<literal>\\}</literal>: Close curly brace, <quote><literal>}</literal></"
14743 "quote>, ASCII 175."
14744 msgstr ""
14746 #. type: Content of: <book><chapter><sect1><para>
14747 #: ../en/ch11-template.xml:240
14748 msgid ""
14749 "As indicated above, if you want the expansion of a template to contain a "
14750 "literal <quote><literal>\\</literal></quote>, <quote><literal>{</literal></"
14751 "quote>, or <quote><literal>{</literal></quote> character, you must escape it."
14752 msgstr ""
14754 #. type: Content of: <book><chapter><sect1><title>
14755 #: ../en/ch11-template.xml:248
14756 msgid "Filtering keywords to change their results"
14757 msgstr "通过过滤关键字来修改输出结果"
14759 #. type: Content of: <book><chapter><sect1><para>
14760 #: ../en/ch11-template.xml:250
14761 msgid ""
14762 "Some of the results of template expansion are not immediately easy to use. "
14763 "Mercurial lets you specify an optional chain of <emphasis>filters</emphasis> "
14764 "to modify the result of expanding a keyword. You have already seen a common "
14765 "filter, <literal role=\"template-kw-filt-date\">isodate</literal>, in action "
14766 "above, to make a date readable."
14767 msgstr ""
14769 #. type: Content of: <book><chapter><sect1><para>
14770 #: ../en/ch11-template.xml:257
14771 msgid ""
14772 "Below is a list of the most commonly used filters that Mercurial supports. "
14773 "While some filters can be applied to any text, others can only be used in "
14774 "specific circumstances. The name of each filter is followed first by an "
14775 "indication of where it can be used, then a description of its effect."
14776 msgstr ""
14778 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14779 #: ../en/ch11-template.xml:264
14780 msgid ""
14781 "<literal role=\"template-filter\">addbreaks</literal>: Any text. Add an XHTML "
14782 "<quote><literal>&lt;br/&gt;</literal></quote> tag before the end of every "
14783 "line except the last. For example, <quote><literal>foo\\nbar</literal></"
14784 "quote> becomes <quote><literal>foo&lt;br/&gt;\\nbar</literal></quote>."
14785 msgstr ""
14787 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14788 #: ../en/ch11-template.xml:271
14789 msgid ""
14790 "<literal role=\"template-kw-filt-date\">age</literal>: <literal role="
14791 "\"template-keyword\">date</literal> keyword. Render the age of the date, "
14792 "relative to the current time. Yields a string like <quote><literal>10 "
14793 "minutes</literal></quote>."
14794 msgstr ""
14796 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14797 #: ../en/ch11-template.xml:278
14798 msgid ""
14799 "<literal role=\"template-filter\">basename</literal>: Any text, but most "
14800 "useful for the <literal role=\"template-keyword\">files</literal> keyword and "
14801 "its relatives. Treat the text as a path, and return the basename. For "
14802 "example, <quote><literal>foo/bar/baz</literal></quote> becomes "
14803 "<quote><literal>baz</literal></quote>."
14804 msgstr ""
14806 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14807 #: ../en/ch11-template.xml:287
14808 msgid ""
14809 "<literal role=\"template-kw-filt-date\">date</literal>: <literal role="
14810 "\"template-keyword\">date</literal> keyword. Render a date in a similar "
14811 "format to the Unix <literal role=\"template-keyword\">date</literal> command, "
14812 "but with timezone included. Yields a string like <quote><literal>Mon Sep 04 "
14813 "15:13:13 2006 -0700</literal></quote>."
14814 msgstr ""
14816 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14817 #: ../en/ch11-template.xml:295
14818 msgid ""
14819 "<literal role=\"template-kw-filt-author\">domain</literal>: Any text, but "
14820 "most useful for the <literal role=\"template-keyword\">author</literal> "
14821 "keyword. Finds the first string that looks like an email address, and "
14822 "extract just the domain component. For example, <quote><literal>Bryan "
14823 "O'Sullivan &lt;bos@serpentine.com&gt;</literal></quote> becomes "
14824 "<quote><literal>serpentine.com</literal></quote>."
14825 msgstr ""
14827 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14828 #: ../en/ch11-template.xml:305
14829 msgid ""
14830 "<literal role=\"template-kw-filt-author\">email</literal>: Any text, but most "
14831 "useful for the <literal role=\"template-keyword\">author</literal> keyword. "
14832 "Extract the first string that looks like an email address. For example, "
14833 "<quote><literal>Bryan O'Sullivan &lt;bos@serpentine.com&gt;</literal></quote> "
14834 "becomes <quote><literal>bos@serpentine.com</literal></quote>."
14835 msgstr ""
14837 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14838 #: ../en/ch11-template.xml:314
14839 msgid ""
14840 "<literal role=\"template-filter\">escape</literal>: Any text. Replace the "
14841 "special XML/XHTML characters <quote><literal>&amp;</literal></quote>, "
14842 "<quote><literal>&lt;</literal></quote> and <quote><literal>&gt;</literal></"
14843 "quote> with XML entities."
14844 msgstr ""
14846 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14847 #: ../en/ch11-template.xml:322
14848 msgid ""
14849 "<literal role=\"template-filter\">fill68</literal>: Any text. Wrap the text "
14850 "to fit in 68 columns. This is useful before you pass text through the "
14851 "<literal role=\"template-filter\">tabindent</literal> filter, and still want "
14852 "it to fit in an 80-column fixed-font window."
14853 msgstr ""
14855 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14856 #: ../en/ch11-template.xml:330
14857 msgid ""
14858 "<literal role=\"template-filter\">fill76</literal>: Any text. Wrap the text "
14859 "to fit in 76 columns."
14860 msgstr ""
14862 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14863 #: ../en/ch11-template.xml:334
14864 msgid ""
14865 "<literal role=\"template-filter\">firstline</literal>: Any text. Yield the "
14866 "first line of text, without any trailing newlines."
14867 msgstr ""
14869 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14870 #: ../en/ch11-template.xml:339
14871 msgid ""
14872 "<literal role=\"template-kw-filt-date\">hgdate</literal>: <literal role="
14873 "\"template-keyword\">date</literal> keyword. Render the date as a pair of "
14874 "readable numbers. Yields a string like <quote><literal>1157407993 25200</"
14875 "literal></quote>."
14876 msgstr ""
14878 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14879 #: ../en/ch11-template.xml:346
14880 msgid ""
14881 "<literal role=\"template-kw-filt-date\">isodate</literal>: <literal role="
14882 "\"template-keyword\">date</literal> keyword. Render the date as a text "
14883 "string in ISO 8601 format. Yields a string like <quote><literal>2006-09-04 "
14884 "15:13:13 -0700</literal></quote>."
14885 msgstr ""
14887 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14888 #: ../en/ch11-template.xml:353
14889 msgid ""
14890 "<literal role=\"template-filter\">obfuscate</literal>: Any text, but most "
14891 "useful for the <literal role=\"template-keyword\">author</literal> keyword. "
14892 "Yield the input text rendered as a sequence of XML entities. This helps to "
14893 "defeat some particularly stupid screen-scraping email harvesting spambots."
14894 msgstr ""
14896 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14897 #: ../en/ch11-template.xml:361
14898 msgid ""
14899 "<literal role=\"template-kw-filt-author\">person</literal>: Any text, but "
14900 "most useful for the <literal role=\"template-keyword\">author</literal> "
14901 "keyword. Yield the text before an email address. For example, "
14902 "<quote><literal>Bryan O'Sullivan &lt;bos@serpentine.com&gt;</literal></quote> "
14903 "becomes <quote><literal>Bryan O'Sullivan</literal></quote>."
14904 msgstr ""
14906 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14907 #: ../en/ch11-template.xml:370
14908 msgid ""
14909 "<literal role=\"template-kw-filt-date\">rfc822date</literal>: <literal role="
14910 "\"template-keyword\">date</literal> keyword. Render a date using the same "
14911 "format used in email headers. Yields a string like <quote><literal>Mon, 04 "
14912 "Sep 2006 15:13:13 -0700</literal></quote>."
14913 msgstr ""
14915 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14916 #: ../en/ch11-template.xml:377
14917 msgid ""
14918 "<literal role=\"template-kw-filt-node\">short</literal>: Changeset hash. "
14919 "Yield the short form of a changeset hash, i.e. a 12-character hexadecimal "
14920 "string."
14921 msgstr ""
14923 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14924 #: ../en/ch11-template.xml:382
14925 msgid ""
14926 "<literal role=\"template-kw-filt-date\">shortdate</literal>: <literal role="
14927 "\"template-keyword\">date</literal> keyword. Render the year, month, and day "
14928 "of the date. Yields a string like <quote><literal>2006-09-04</literal></"
14929 "quote>."
14930 msgstr ""
14932 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14933 #: ../en/ch11-template.xml:388
14934 msgid ""
14935 "<literal role=\"template-filter\">strip</literal>: Any text. Strip all "
14936 "leading and trailing whitespace from the string."
14937 msgstr ""
14939 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14940 #: ../en/ch11-template.xml:392
14941 msgid ""
14942 "<literal role=\"template-filter\">tabindent</literal>: Any text. Yield the "
14943 "text, with every line except the first starting with a tab character."
14944 msgstr ""
14946 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14947 #: ../en/ch11-template.xml:397
14948 msgid ""
14949 "<literal role=\"template-filter\">urlescape</literal>: Any text. Escape all "
14950 "characters that are considered <quote>special</quote> by URL parsers. For "
14951 "example, <literal>foo bar</literal> becomes <literal>foo%20bar</literal>."
14952 msgstr ""
14954 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14955 #: ../en/ch11-template.xml:404
14956 msgid ""
14957 "<literal role=\"template-kw-filt-author\">user</literal>: Any text, but most "
14958 "useful for the <literal role=\"template-keyword\">author</literal> keyword. "
14959 "Return the <quote>user</quote> portion of an email address. For example, "
14960 "<quote><literal>Bryan O'Sullivan &lt;bos@serpentine.com&gt;</literal></quote> "
14961 "becomes <quote><literal>bos</literal></quote>."
14962 msgstr ""
14964 #. type: Content of: <book><chapter><sect1><note><para>
14965 #: ../en/ch11-template.xml:418
14966 msgid ""
14967 "If you try to apply a filter to a piece of data that it cannot process, "
14968 "Mercurial will fail and print a Python exception. For example, trying to run "
14969 "the output of the <literal role=\"template-keyword\">desc</literal> keyword "
14970 "into the <literal role=\"template-kw-filt-date\">isodate</literal> filter is "
14971 "not a good idea."
14972 msgstr ""
14974 #. type: Content of: <book><chapter><sect1><sect2><title>
14975 #: ../en/ch11-template.xml:427
14976 msgid "Combining filters"
14977 msgstr "组合过滤器"
14979 #. type: Content of: <book><chapter><sect1><sect2><para>
14980 #: ../en/ch11-template.xml:429
14981 msgid ""
14982 "It is easy to combine filters to yield output in the form you would like. "
14983 "The following chain of filters tidies up a description, then makes sure that "
14984 "it fits cleanly into 68 columns, then indents it by a further 8 characters "
14985 "(at least on Unix-like systems, where a tab is conventionally 8 characters "
14986 "wide)."
14987 msgstr ""
14989 #. type: Content of: <book><chapter><sect1><sect2><para>
14990 #: ../en/ch11-template.xml:438
14991 msgid ""
14992 "Note the use of <quote><literal>\\t</literal></quote> (a tab character) in "
14993 "the template to force the first line to be indented; this is necessary since "
14994 "<literal role=\"template-keyword\">tabindent</literal> indents all lines "
14995 "<emphasis>except</emphasis> the first."
14996 msgstr ""
14998 #. type: Content of: <book><chapter><sect1><sect2><para>
14999 #: ../en/ch11-template.xml:444
15000 msgid ""
15001 "Keep in mind that the order of filters in a chain is significant. The first "
15002 "filter is applied to the result of the keyword; the second to the result of "
15003 "the first filter; and so on. For example, using <literal>fill68|tabindent</"
15004 "literal> gives very different results from <literal>tabindent|fill68</"
15005 "literal>."
15006 msgstr ""
15008 #. type: Content of: <book><chapter><sect1><title>
15009 #: ../en/ch11-template.xml:454
15010 msgid "From templates to styles"
15011 msgstr "从模版到样式"
15013 #. type: Content of: <book><chapter><sect1><para>
15014 #: ../en/ch11-template.xml:456
15015 msgid ""
15016 "A command line template provides a quick and simple way to format some "
15017 "output. Templates can become verbose, though, and it's useful to be able to "
15018 "give a template a name. A style file is a template with a name, stored in a "
15019 "file."
15020 msgstr ""
15022 #. type: Content of: <book><chapter><sect1><para>
15023 #: ../en/ch11-template.xml:461
15024 msgid ""
15025 "More than that, using a style file unlocks the power of Mercurial's "
15026 "templating engine in ways that are not possible using the command line "
15027 "<option role=\"hg-opt-log\">--template</option> option."
15028 msgstr ""
15030 #. type: Content of: <book><chapter><sect1><sect2><title>
15031 #: ../en/ch11-template.xml:467
15032 msgid "The simplest of style files"
15033 msgstr "最简单的样式文件"
15035 #. type: Content of: <book><chapter><sect1><sect2><para>
15036 #: ../en/ch11-template.xml:469
15037 msgid "Our simple style file contains just one line:"
15038 msgstr ""
15040 #. type: Content of: <book><chapter><sect1><sect2><para>
15041 #: ../en/ch11-template.xml:473
15042 msgid ""
15043 "This tells Mercurial, <quote>if you're printing a changeset, use the text on "
15044 "the right as the template</quote>."
15045 msgstr ""
15047 #. type: Content of: <book><chapter><sect1><sect2><title>
15048 #: ../en/ch11-template.xml:479
15049 msgid "Style file syntax"
15050 msgstr "样式文件语法"
15052 #. type: Content of: <book><chapter><sect1><sect2><para>
15053 #: ../en/ch11-template.xml:481
15054 msgid "The syntax rules for a style file are simple."
15055 msgstr ""
15057 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15058 #: ../en/ch11-template.xml:484
15059 msgid "The file is processed one line at a time."
15060 msgstr ""
15062 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15063 #: ../en/ch11-template.xml:487
15064 msgid "Leading and trailing white space are ignored."
15065 msgstr ""
15067 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15068 #: ../en/ch11-template.xml:490
15069 msgid "Empty lines are skipped."
15070 msgstr ""
15072 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15073 #: ../en/ch11-template.xml:492
15074 msgid ""
15075 "If a line starts with either of the characters <quote><literal>#</literal></"
15076 "quote> or <quote><literal>;</literal></quote>, the entire line is treated as "
15077 "a comment, and skipped as if empty."
15078 msgstr ""
15080 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15081 #: ../en/ch11-template.xml:497
15082 msgid ""
15083 "A line starts with a keyword. This must start with an alphabetic character "
15084 "or underscore, and can subsequently contain any alphanumeric character or "
15085 "underscore. (In regexp notation, a keyword must match <literal>[A-Za-z_][A-"
15086 "Za-z0-9_]*</literal>.)"
15087 msgstr ""
15089 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15090 #: ../en/ch11-template.xml:503
15091 msgid ""
15092 "The next element must be an <quote><literal>=</literal></quote> character, "
15093 "which can be preceded or followed by an arbitrary amount of white space."
15094 msgstr ""
15096 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15097 #: ../en/ch11-template.xml:508
15098 msgid ""
15099 "If the rest of the line starts and ends with matching quote characters "
15100 "(either single or double quote), it is treated as a template body."
15101 msgstr ""
15103 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15104 #: ../en/ch11-template.xml:512
15105 msgid ""
15106 "If the rest of the line <emphasis>does not</emphasis> start with a quote "
15107 "character, it is treated as the name of a file; the contents of this file "
15108 "will be read and used as a template body."
15109 msgstr ""
15111 #. type: Content of: <book><chapter><sect1><title>
15112 #: ../en/ch11-template.xml:521
15113 msgid "Style files by example"
15114 msgstr "样式文件例子"
15116 #. type: Content of: <book><chapter><sect1><para>
15117 #: ../en/ch11-template.xml:523
15118 msgid ""
15119 "To illustrate how to write a style file, we will construct a few by example. "
15120 "Rather than provide a complete style file and walk through it, we'll mirror "
15121 "the usual process of developing a style file by starting with something very "
15122 "simple, and walking through a series of successively more complete examples."
15123 msgstr ""
15125 #. type: Content of: <book><chapter><sect1><sect2><title>
15126 #: ../en/ch11-template.xml:530
15127 msgid "Identifying mistakes in style files"
15128 msgstr "在样式文件中定位错误"
15130 #. type: Content of: <book><chapter><sect1><sect2><para>
15131 #: ../en/ch11-template.xml:532
15132 msgid ""
15133 "If Mercurial encounters a problem in a style file you are working on, it "
15134 "prints a terse error message that, once you figure out what it means, is "
15135 "actually quite useful."
15136 msgstr ""
15138 #. type: Content of: <book><chapter><sect1><sect2><para>
15139 #: ../en/ch11-template.xml:538
15140 msgid ""
15141 "Notice that <filename>broken.style</filename> attempts to define a "
15142 "<literal>changeset</literal> keyword, but forgets to give any content for it. "
15143 "When instructed to use this style file, Mercurial promptly complains."
15144 msgstr ""
15146 #. type: Content of: <book><chapter><sect1><sect2><para>
15147 #: ../en/ch11-template.xml:545
15148 msgid "This error message looks intimidating, but it is not too hard to follow."
15149 msgstr ""
15151 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15152 #: ../en/ch11-template.xml:549
15153 msgid ""
15154 "The first component is simply Mercurial's way of saying <quote>I am giving "
15155 "up</quote>."
15156 msgstr ""
15158 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15159 #: ../en/ch11-template.xml:553
15160 msgid "Next comes the name of the style file that contains the error."
15161 msgstr ""
15163 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15164 #: ../en/ch11-template.xml:557
15165 msgid ""
15166 "Following the file name is the line number where the error was encountered."
15167 msgstr ""
15169 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15170 #: ../en/ch11-template.xml:561
15171 msgid "Finally, a description of what went wrong."
15172 msgstr ""
15174 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15175 #: ../en/ch11-template.xml:565
15176 msgid ""
15177 "The description of the problem is not always clear (as in this case), but "
15178 "even when it is cryptic, it is almost always trivial to visually inspect the "
15179 "offending line in the style file and see what is wrong."
15180 msgstr ""
15182 #. type: Content of: <book><chapter><sect1><sect2><title>
15183 #: ../en/ch11-template.xml:574
15184 msgid "Uniquely identifying a repository"
15185 msgstr "版本库的唯一标识"
15187 #. type: Content of: <book><chapter><sect1><sect2><para>
15188 #: ../en/ch11-template.xml:576
15189 msgid ""
15190 "If you would like to be able to identify a Mercurial repository <quote>fairly "
15191 "uniquely</quote> using a short string as an identifier, you can use the first "
15192 "revision in the repository."
15193 msgstr ""
15195 #. type: Content of: <book><chapter><sect1><sect2><para>
15196 #: ../en/ch11-template.xml:583
15197 msgid ""
15198 "This is likely to be unique, and so it is useful in many cases. There are a "
15199 "few caveats."
15200 msgstr ""
15202 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15203 #: ../en/ch11-template.xml:586
15204 msgid ""
15205 "It will not work in a completely empty repository, because such a repository "
15206 "does not have a revision zero."
15207 msgstr ""
15209 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15210 #: ../en/ch11-template.xml:590
15211 msgid ""
15212 "Neither will it work in the (extremely rare) case where a repository is a "
15213 "merge of two or more formerly independent repositories, and you still have "
15214 "those repositories around."
15215 msgstr ""
15217 #. type: Content of: <book><chapter><sect1><sect2><para>
15218 #: ../en/ch11-template.xml:595
15219 msgid "Here are some uses to which you could put this identifier:"
15220 msgstr ""
15222 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15223 #: ../en/ch11-template.xml:598
15224 msgid ""
15225 "As a key into a table for a database that manages repositories on a server."
15226 msgstr ""
15228 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15229 #: ../en/ch11-template.xml:601
15230 msgid ""
15231 "As half of a {<emphasis>repository ID</emphasis>, <emphasis>revision ID</"
15232 "emphasis>} tuple. Save this information away when you run an automated build "
15233 "or other activity, so that you can <quote>replay</quote> the build later if "
15234 "necessary."
15235 msgstr ""
15237 #. type: Content of: <book><chapter><sect1><sect2><title>
15238 #: ../en/ch11-template.xml:611
15239 msgid "Listing files on multiple lines"
15240 msgstr "每行列出一个文件"
15242 #. type: Content of: <book><chapter><sect1><sect2><para>
15243 #: ../en/ch11-template.xml:613
15244 msgid ""
15245 "Suppose we want to list the files changed by a changeset, one per line, with "
15246 "a little indentation before each file name."
15247 msgstr ""
15249 #. type: Content of: <book><chapter><sect1><sect2><title>
15250 #: ../en/ch11-template.xml:621
15251 msgid "Mimicking Subversion's output"
15252 msgstr "模仿 Subversion 的输出"
15255 #. type: Content of: <book><chapter><sect1><sect2><para>
15256 #: ../en/ch11-template.xml:623
15257 msgid ""
15258 "Let's try to emulate the default output format used by another revision "
15259 "control tool, Subversion."
15260 msgstr ""
15263 #. type: Content of: <book><chapter><sect1><sect2><para>
15264 #: ../en/ch11-template.xml:628
15265 msgid ""
15266 "Since Subversion's output style is fairly simple, it is easy to copy-and-"
15267 "paste a hunk of its output into a file, and replace the text produced above "
15268 "by Subversion with the template values we'd like to see expanded."
15269 msgstr ""
15271 #. type: Content of: <book><chapter><sect1><sect2><para>
15272 #: ../en/ch11-template.xml:635
15273 msgid ""
15274 "There are a few small ways in which this template deviates from the output "
15275 "produced by Subversion."
15276 msgstr ""
15278 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15279 #: ../en/ch11-template.xml:638
15280 msgid ""
15281 "Subversion prints a <quote>readable</quote> date (the <quote><literal>Wed, 27 "
15282 "Sep 2006</literal></quote> in the example output above) in parentheses. "
15283 "Mercurial's templating engine does not provide a way to display a date in "
15284 "this format without also printing the time and time zone."
15285 msgstr ""
15287 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15288 #: ../en/ch11-template.xml:645
15289 msgid ""
15290 "We emulate Subversion's printing of <quote>separator</quote> lines full of "
15291 "<quote><literal>-</literal></quote> characters by ending the template with "
15292 "such a line. We use the templating engine's <literal role=\"template-keyword"
15293 "\">header</literal> keyword to print a separator line as the first line of "
15294 "output (see below), thus achieving similar output to Subversion."
15295 msgstr ""
15297 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15298 #: ../en/ch11-template.xml:654
15299 msgid ""
15300 "Subversion's output includes a count in the header of the number of lines in "
15301 "the commit message. We cannot replicate this in Mercurial; the templating "
15302 "engine does not currently provide a filter that counts the number of lines "
15303 "the template generates."
15304 msgstr ""
15307 #. type: Content of: <book><chapter><sect1><sect2><para>
15308 #: ../en/ch11-template.xml:660
15309 msgid ""
15310 "It took me no more than a minute or two of work to replace literal text from "
15311 "an example of Subversion's output with some keywords and filters to give the "
15312 "template above. The style file simply refers to the template."
15313 msgstr ""
15315 #. type: Content of: <book><chapter><sect1><sect2><para>
15316 #: ../en/ch11-template.xml:667
15317 msgid ""
15318 "We could have included the text of the template file directly in the style "
15319 "file by enclosing it in quotes and replacing the newlines with "
15320 "<quote><literal>\\n</literal></quote> sequences, but it would have made the "
15321 "style file too difficult to read. Readability is a good guide when you're "
15322 "trying to decide whether some text belongs in a style file, or in a template "
15323 "file that the style file points to. If the style file will look too big or "
15324 "cluttered if you insert a literal piece of text, drop it into a template "
15325 "instead."
15326 msgstr ""
15328 #. type: Content of: <book><chapter><title>
15329 #: ../en/ch12-mq.xml:5
15330 msgid "Managing change with Mercurial Queues"
15331 msgstr "使用 MQ 管理修改"
15333 #. type: Content of: <book><chapter><sect1><title>
15334 #: ../en/ch12-mq.xml:8
15335 msgid "The patch management problem"
15336 msgstr "补丁的管理问题"
15338 #. type: Content of: <book><chapter><sect1><para>
15339 #: ../en/ch12-mq.xml:10
15340 msgid ""
15341 "Here is a common scenario: you need to install a software package from "
15342 "source, but you find a bug that you must fix in the source before you can "
15343 "start using the package. You make your changes, forget about the package for "
15344 "a while, and a few months later you need to upgrade to a newer version of the "
15345 "package. If the newer version of the package still has the bug, you must "
15346 "extract your fix from the older source tree and apply it against the newer "
15347 "version. This is a tedious task, and it's easy to make mistakes."
15348 msgstr ""
15350 #. type: Content of: <book><chapter><sect1><para>
15351 #: ../en/ch12-mq.xml:20
15352 msgid ""
15353 "This is a simple case of the <quote>patch management</quote> problem. You "
15354 "have an <quote>upstream</quote> source tree that you can't change; you need "
15355 "to make some local changes on top of the upstream tree; and you'd like to be "
15356 "able to keep those changes separate, so that you can apply them to newer "
15357 "versions of the upstream source."
15358 msgstr ""
15360 #. type: Content of: <book><chapter><sect1><para>
15361 #: ../en/ch12-mq.xml:27
15362 msgid ""
15363 "The patch management problem arises in many situations. Probably the most "
15364 "visible is that a user of an open source software project will contribute a "
15365 "bug fix or new feature to the project's maintainers in the form of a patch."
15366 msgstr ""
15368 #. type: Content of: <book><chapter><sect1><para>
15369 #: ../en/ch12-mq.xml:32
15370 msgid ""
15371 "Distributors of operating systems that include open source software often "
15372 "need to make changes to the packages they distribute so that they will build "
15373 "properly in their environments."
15374 msgstr ""
15376 #. type: Content of: <book><chapter><sect1><para>
15377 #: ../en/ch12-mq.xml:37
15378 msgid ""
15379 "When you have few changes to maintain, it is easy to manage a single patch "
15380 "using the standard <command>diff</command> and <command>patch</command> "
15381 "programs (see <xref linkend=\"sec:mq:patch\"/> for a discussion of these "
15382 "tools). Once the number of changes grows, it starts to make sense to maintain "
15383 "patches as discrete <quote>chunks of work,</quote> so that for example a "
15384 "single patch will contain only one bug fix (the patch might modify several "
15385 "files, but it's doing <quote>only one thing</quote>), and you may have a "
15386 "number of such patches for different bugs you need fixed and local changes "
15387 "you require. In this situation, if you submit a bug fix patch to the "
15388 "upstream maintainers of a package and they include your fix in a subsequent "
15389 "release, you can simply drop that single patch when you're updating to the "
15390 "newer release."
15391 msgstr ""
15393 #. type: Content of: <book><chapter><sect1><para>
15394 #: ../en/ch12-mq.xml:52
15395 msgid ""
15396 "Maintaining a single patch against an upstream tree is a little tedious and "
15397 "error-prone, but not difficult. However, the complexity of the problem grows "
15398 "rapidly as the number of patches you have to maintain increases. With more "
15399 "than a tiny number of patches in hand, understanding which ones you have "
15400 "applied and maintaining them moves from messy to overwhelming."
15401 msgstr ""
15403 #. type: Content of: <book><chapter><sect1><para>
15404 #: ../en/ch12-mq.xml:59
15405 msgid ""
15406 "Fortunately, Mercurial includes a powerful extension, Mercurial Queues (or "
15407 "simply <quote>MQ</quote>), that massively simplifies the patch management "
15408 "problem."
15409 msgstr ""
15411 #. type: Content of: <book><chapter><sect1><title>
15412 #: ../en/ch12-mq.xml:65
15413 msgid "The prehistory of Mercurial Queues"
15414 msgstr "MQ 的历史"
15416 #. type: Content of: <book><chapter><sect1><para>
15417 #: ../en/ch12-mq.xml:67
15418 msgid ""
15419 "During the late 1990s, several Linux kernel developers started to maintain "
15420 "<quote>patch series</quote> that modified the behavior of the Linux kernel. "
15421 "Some of these series were focused on stability, some on feature coverage, and "
15422 "others were more speculative."
15423 msgstr ""
15425 #. type: Content of: <book><chapter><sect1><para>
15426 #: ../en/ch12-mq.xml:73
15427 msgid ""
15428 "The sizes of these patch series grew rapidly. In 2002, Andrew Morton "
15429 "published some shell scripts he had been using to automate the task of "
15430 "managing his patch queues. Andrew was successfully using these scripts to "
15431 "manage hundreds (sometimes thousands) of patches on top of the Linux kernel."
15432 msgstr ""
15434 #. type: Content of: <book><chapter><sect1><sect2><title>
15435 #: ../en/ch12-mq.xml:80
15436 msgid "A patchwork quilt"
15437 msgstr ""
15439 #. type: Content of: <book><chapter><sect1><sect2><para>
15440 #: ../en/ch12-mq.xml:82
15441 msgid ""
15442 "In early 2003, Andreas Gruenbacher and Martin Quinson borrowed the approach "
15443 "of Andrew's scripts and published a tool called <quote>patchwork quilt</"
15444 "quote> <citation>web:quilt</citation>, or simply <quote>quilt</quote> (see "
15445 "<citation>gruenbacher:2005</citation> for a paper describing it). Because "
15446 "quilt substantially automated patch management, it rapidly gained a large "
15447 "following among open source software developers."
15448 msgstr ""
15450 #. type: Content of: <book><chapter><sect1><sect2><para>
15451 #: ../en/ch12-mq.xml:91
15452 msgid ""
15453 "Quilt manages a <emphasis>stack of patches</emphasis> on top of a directory "
15454 "tree. To begin, you tell quilt to manage a directory tree, and tell it which "
15455 "files you want to manage; it stores away the names and contents of those "
15456 "files. To fix a bug, you create a new patch (using a single command), edit "
15457 "the files you need to fix, then <quote>refresh</quote> the patch."
15458 msgstr ""
15460 #. type: Content of: <book><chapter><sect1><sect2><para>
15461 #: ../en/ch12-mq.xml:99
15462 msgid ""
15463 "The refresh step causes quilt to scan the directory tree; it updates the "
15464 "patch with all of the changes you have made. You can create another patch on "
15465 "top of the first, which will track the changes required to modify the tree "
15466 "from <quote>tree with one patch applied</quote> to <quote>tree with two "
15467 "patches applied</quote>."
15468 msgstr ""
15470 #. type: Content of: <book><chapter><sect1><sect2><para>
15471 #: ../en/ch12-mq.xml:106
15472 msgid ""
15473 "You can <emphasis>change</emphasis> which patches are applied to the tree. "
15474 "If you <quote>pop</quote> a patch, the changes made by that patch will vanish "
15475 "from the directory tree. Quilt remembers which patches you have popped, "
15476 "though, so you can <quote>push</quote> a popped patch again, and the "
15477 "directory tree will be restored to contain the modifications in the patch. "
15478 "Most importantly, you can run the <quote>refresh</quote> command at any time, "
15479 "and the topmost applied patch will be updated. This means that you can, at "
15480 "any time, change both which patches are applied and what modifications those "
15481 "patches make."
15482 msgstr ""
15484 #. type: Content of: <book><chapter><sect1><sect2><para>
15485 #: ../en/ch12-mq.xml:118
15486 msgid ""
15487 "Quilt knows nothing about revision control tools, so it works equally well on "
15488 "top of an unpacked tarball or a Subversion working copy."
15489 msgstr ""
15491 #. type: Content of: <book><chapter><sect1><sect2><title>
15492 #: ../en/ch12-mq.xml:124
15493 msgid "From patchwork quilt to Mercurial Queues"
15494 msgstr "从 patchwork quilt 到 MQ"
15496 #. type: Content of: <book><chapter><sect1><sect2><para>
15497 #: ../en/ch12-mq.xml:126
15498 msgid ""
15499 "In mid-2005, Chris Mason took the features of quilt and wrote an extension "
15500 "that he called Mercurial Queues, which added quilt-like behavior to Mercurial."
15501 msgstr ""
15503 #. type: Content of: <book><chapter><sect1><sect2><para>
15504 #: ../en/ch12-mq.xml:130
15505 msgid ""
15506 "The key difference between quilt and MQ is that quilt knows nothing about "
15507 "revision control systems, while MQ is <emphasis>integrated</emphasis> into "
15508 "Mercurial. Each patch that you push is represented as a Mercurial "
15509 "changeset. Pop a patch, and the changeset goes away."
15510 msgstr ""
15512 #. type: Content of: <book><chapter><sect1><sect2><para>
15513 #: ../en/ch12-mq.xml:136
15514 msgid ""
15515 "Because quilt does not care about revision control tools, it is still a "
15516 "tremendously useful piece of software to know about for situations where you "
15517 "cannot use Mercurial and MQ."
15518 msgstr ""
15520 #. type: Content of: <book><chapter><sect1><title>
15521 #: ../en/ch12-mq.xml:144
15522 msgid "The huge advantage of MQ"
15523 msgstr "MQ 的巨大优势"
15525 #. type: Content of: <book><chapter><sect1><para>
15526 #: ../en/ch12-mq.xml:146
15527 msgid ""
15528 "I cannot overstate the value that MQ offers through the unification of "
15529 "patches and revision control."
15530 msgstr ""
15532 #. type: Content of: <book><chapter><sect1><para>
15533 #: ../en/ch12-mq.xml:149
15534 msgid ""
15535 "A major reason that patches have persisted in the free software and open "
15536 "source world&emdash;in spite of the availability of increasingly capable "
15537 "revision control tools over the years&emdash;is the <emphasis>agility</"
15538 "emphasis> they offer."
15539 msgstr ""
15541 #. type: Content of: <book><chapter><sect1><para>
15542 #: ../en/ch12-mq.xml:155
15543 msgid ""
15544 "Traditional revision control tools make a permanent, irreversible record of "
15545 "everything that you do. While this has great value, it's also somewhat "
15546 "stifling. If you want to perform a wild-eyed experiment, you have to be "
15547 "careful in how you go about it, or you risk leaving unneeded&emdash;or worse, "
15548 "misleading or destabilising&emdash;traces of your missteps and errors in the "
15549 "permanent revision record."
15550 msgstr ""
15552 #. type: Content of: <book><chapter><sect1><para>
15553 #: ../en/ch12-mq.xml:163
15554 msgid ""
15555 "By contrast, MQ's marriage of distributed revision control with patches makes "
15556 "it much easier to isolate your work. Your patches live on top of normal "
15557 "revision history, and you can make them disappear or reappear at will. If "
15558 "you don't like a patch, you can drop it. If a patch isn't quite as you want "
15559 "it to be, simply fix it&emdash;as many times as you need to, until you have "
15560 "refined it into the form you desire."
15561 msgstr ""
15563 #. type: Content of: <book><chapter><sect1><para>
15564 #: ../en/ch12-mq.xml:171
15565 msgid ""
15566 "As an example, the integration of patches with revision control makes "
15567 "understanding patches and debugging their effects&emdash;and their interplay "
15568 "with the code they're based on&emdash;<emphasis>enormously</emphasis> easier. "
15569 "Since every applied patch has an associated changeset, you can give <command "
15570 "role=\"hg-cmd\">hg log</command> a file name to see which changesets and "
15571 "patches affected the file. You can use the <command role=\"hg-cmd\">hg "
15572 "bisect</command> command to binary-search through all changesets and applied "
15573 "patches to see where a bug got introduced or fixed. You can use the <command "
15574 "role=\"hg-cmd\">hg annotate</command> command to see which changeset or patch "
15575 "modified a particular line of a source file. And so on."
15576 msgstr ""
15578 #. type: Content of: <book><chapter><sect1><para>
15579 #: ../en/ch12-mq.xml:189
15580 msgid ""
15581 "Because MQ doesn't hide its patch-oriented nature, it is helpful to "
15582 "understand what patches are, and a little about the tools that work with them."
15583 msgstr ""
15585 #. type: Content of: <book><chapter><sect1><para>
15586 #: ../en/ch12-mq.xml:193
15587 msgid ""
15588 "The traditional Unix <command>diff</command> command compares two files, and "
15589 "prints a list of differences between them. The <command>patch</command> "
15590 "command understands these differences as <emphasis>modifications</emphasis> "
15591 "to make to a file. Take a look below for a simple example of these commands "
15592 "in action."
15593 msgstr ""
15595 #. type: Content of: <book><chapter><sect1><para>
15596 #: ../en/ch12-mq.xml:202
15597 msgid ""
15598 "The type of file that <command>diff</command> generates (and <command>patch</"
15599 "command> takes as input) is called a <quote>patch</quote> or a <quote>diff</"
15600 "quote>; there is no difference between a patch and a diff. (We'll use the "
15601 "term <quote>patch</quote>, since it's more commonly used.)"
15602 msgstr ""
15604 #. type: Content of: <book><chapter><sect1><para>
15605 #: ../en/ch12-mq.xml:208
15606 msgid ""
15607 "A patch file can start with arbitrary text; the <command>patch</command> "
15608 "command ignores this text, but MQ uses it as the commit message when creating "
15609 "changesets. To find the beginning of the patch content, <command>patch</"
15610 "command> searches for the first line that starts with the string "
15611 "<quote><literal>diff -</literal></quote>."
15612 msgstr ""
15614 #. type: Content of: <book><chapter><sect1><para>
15615 #: ../en/ch12-mq.xml:215
15616 msgid ""
15617 "MQ works with <emphasis>unified</emphasis> diffs (<command>patch</command> "
15618 "can accept several other diff formats, but MQ doesn't). A unified diff "
15619 "contains two kinds of header. The <emphasis>file header</emphasis> describes "
15620 "the file being modified; it contains the name of the file to modify. When "
15621 "<command>patch</command> sees a new file header, it looks for a file with "
15622 "that name to start modifying."
15623 msgstr ""
15625 #. type: Content of: <book><chapter><sect1><para>
15626 #: ../en/ch12-mq.xml:223
15627 msgid ""
15628 "After the file header comes a series of <emphasis>hunks</emphasis>. Each "
15629 "hunk starts with a header; this identifies the range of line numbers within "
15630 "the file that the hunk should modify. Following the header, a hunk starts "
15631 "and ends with a few (usually three) lines of text from the unmodified file; "
15632 "these are called the <emphasis>context</emphasis> for the hunk. If there's "
15633 "only a small amount of context between successive hunks, <command>diff</"
15634 "command> doesn't print a new hunk header; it just runs the hunks together, "
15635 "with a few lines of context between modifications."
15636 msgstr ""
15638 #. type: Content of: <book><chapter><sect1><para>
15639 #: ../en/ch12-mq.xml:235
15640 msgid ""
15641 "Each line of context begins with a space character. Within the hunk, a line "
15642 "that begins with <quote><literal>-</literal></quote> means <quote>remove this "
15643 "line,</quote> while a line that begins with <quote><literal>+</literal></"
15644 "quote> means <quote>insert this line.</quote> For example, a line that is "
15645 "modified is represented by one deletion and one insertion."
15646 msgstr ""
15648 #. type: Content of: <book><chapter><sect1><para>
15649 #: ../en/ch12-mq.xml:243
15650 msgid ""
15651 "We will return to some of the more subtle aspects of patches later (in <xref "
15652 "linkend=\"sec:mq:adv-patch\"/>), but you should have enough information now "
15653 "to use MQ."
15654 msgstr ""
15656 #. type: Content of: <book><chapter><sect1><title>
15657 #: ../en/ch12-mq.xml:250
15658 msgid "Getting started with Mercurial Queues"
15659 msgstr "开始使用 MQ"
15661 #. type: Content of: <book><chapter><sect1><para>
15662 #: ../en/ch12-mq.xml:252
15663 msgid ""
15664 "Because MQ is implemented as an extension, you must explicitly enable before "
15665 "you can use it. (You don't need to download anything; MQ ships with the "
15666 "standard Mercurial distribution.) To enable MQ, edit your <filename role="
15667 "\"home\">~/.hgrc</filename> file, and add the lines below."
15668 msgstr ""
15670 #. type: Content of: <book><chapter><sect1><para>
15671 #: ../en/ch12-mq.xml:262
15672 msgid ""
15673 "Once the extension is enabled, it will make a number of new commands "
15674 "available. To verify that the extension is working, you can use <command "
15675 "role=\"hg-cmd\">hg help</command> to see if the <command role=\"hg-ext-mq"
15676 "\">qinit</command> command is now available."
15677 msgstr ""
15679 #. type: Content of: <book><chapter><sect1><para>
15680 #: ../en/ch12-mq.xml:270
15681 msgid ""
15682 "You can use MQ with <emphasis>any</emphasis> Mercurial repository, and its "
15683 "commands only operate within that repository. To get started, simply prepare "
15684 "the repository using the <command role=\"hg-ext-mq\">qinit</command> command."
15685 msgstr ""
15687 #. type: Content of: <book><chapter><sect1><para>
15688 #: ../en/ch12-mq.xml:277
15689 msgid ""
15690 "This command creates an empty directory called <filename role=\"special\" "
15691 "class=\"directory\">.hg/patches</filename>, where MQ will keep its metadata. "
15692 "As with many Mercurial commands, the <command role=\"hg-ext-mq\">qinit</"
15693 "command> command prints nothing if it succeeds."
15694 msgstr ""
15696 #. type: Content of: <book><chapter><sect1><sect2><title>
15697 #: ../en/ch12-mq.xml:284
15698 msgid "Creating a new patch"
15699 msgstr "创建新补丁"
15701 #. type: Content of: <book><chapter><sect1><sect2><para>
15702 #: ../en/ch12-mq.xml:286
15703 msgid ""
15704 "To begin work on a new patch, use the <command role=\"hg-ext-mq\">qnew</"
15705 "command> command. This command takes one argument, the name of the patch to "
15706 "create."
15707 msgstr ""
15709 #. type: Content of: <book><chapter><sect1><sect2><para>
15710 #: ../en/ch12-mq.xml:290
15711 msgid ""
15712 "MQ will use this as the name of an actual file in the <filename role=\"special"
15713 "\" class=\"directory\">.hg/patches</filename> directory, as you can see below."
15714 msgstr ""
15716 #. type: Content of: <book><chapter><sect1><sect2><para>
15717 #: ../en/ch12-mq.xml:297
15718 msgid ""
15719 "Also newly present in the <filename role=\"special\" class=\"directory\">.hg/"
15720 "patches</filename> directory are two other files, <filename role=\"special"
15721 "\">series</filename> and <filename role=\"special\">status</filename>. The "
15722 "<filename role=\"special\">series</filename> file lists all of the patches "
15723 "that MQ knows about for this repository, with one patch per line. Mercurial "
15724 "uses the <filename role=\"special\">status</filename> file for internal book-"
15725 "keeping; it tracks all of the patches that MQ has <emphasis>applied</"
15726 "emphasis> in this repository."
15727 msgstr ""
15729 #. type: Content of: <book><chapter><sect1><sect2><note><para>
15730 #: ../en/ch12-mq.xml:309
15731 msgid ""
15732 "You may sometimes want to edit the <filename role=\"special\">series</"
15733 "filename> file by hand; for example, to change the sequence in which some "
15734 "patches are applied. However, manually editing the <filename role=\"special"
15735 "\">status</filename> file is almost always a bad idea, as it's easy to "
15736 "corrupt MQ's idea of what is happening."
15737 msgstr ""
15739 #. type: Content of: <book><chapter><sect1><sect2><para>
15740 #: ../en/ch12-mq.xml:318
15741 msgid ""
15742 "Once you have created your new patch, you can edit files in the working "
15743 "directory as you usually would. All of the normal Mercurial commands, such "
15744 "as <command role=\"hg-cmd\">hg diff</command> and <command role=\"hg-cmd\">hg "
15745 "annotate</command>, work exactly as they did before."
15746 msgstr ""
15748 #. type: Content of: <book><chapter><sect1><sect2><title>
15749 #: ../en/ch12-mq.xml:326
15750 msgid "Refreshing a patch"
15751 msgstr "刷新补丁"
15753 #. type: Content of: <book><chapter><sect1><sect2><para>
15754 #: ../en/ch12-mq.xml:328
15755 msgid ""
15756 "When you reach a point where you want to save your work, use the <command "
15757 "role=\"hg-ext-mq\">qrefresh</command> command to update the patch you are "
15758 "working on."
15759 msgstr ""
15761 #. type: Content of: <book><chapter><sect1><sect2><para>
15762 #: ../en/ch12-mq.xml:334
15763 msgid ""
15764 "This command folds the changes you have made in the working directory into "
15765 "your patch, and updates its corresponding changeset to contain those changes."
15766 msgstr ""
15768 #. type: Content of: <book><chapter><sect1><sect2><para>
15769 #: ../en/ch12-mq.xml:338
15770 msgid ""
15771 "You can run <command role=\"hg-ext-mq\">qrefresh</command> as often as you "
15772 "like, so it's a good way to <quote>checkpoint</quote> your work. Refresh "
15773 "your patch at an opportune time; try an experiment; and if the experiment "
15774 "doesn't work out, <command role=\"hg-cmd\">hg revert</command> your "
15775 "modifications back to the last time you refreshed."
15776 msgstr ""
15778 #. type: Content of: <book><chapter><sect1><sect2><title>
15779 #: ../en/ch12-mq.xml:349
15780 msgid "Stacking and tracking patches"
15781 msgstr "堆叠和跟踪补丁"
15783 #. type: Content of: <book><chapter><sect1><sect2><para>
15784 #: ../en/ch12-mq.xml:351
15785 msgid ""
15786 "Once you have finished working on a patch, or need to work on another, you "
15787 "can use the <command role=\"hg-ext-mq\">qnew</command> command again to "
15788 "create a new patch. Mercurial will apply this patch on top of your existing "
15789 "patch."
15790 msgstr ""
15792 #. type: Content of: <book><chapter><sect1><sect2><para>
15793 #: ../en/ch12-mq.xml:359
15794 msgid ""
15795 "Notice that the patch contains the changes in our prior patch as part of its "
15796 "context (you can see this more clearly in the output of <command role=\"hg-cmd"
15797 "\">hg annotate</command>)."
15798 msgstr ""
15800 #. type: Content of: <book><chapter><sect1><sect2><para>
15801 #: ../en/ch12-mq.xml:364
15802 msgid ""
15803 "So far, with the exception of <command role=\"hg-ext-mq\">qnew</command> and "
15804 "<command role=\"hg-ext-mq\">qrefresh</command>, we've been careful to only "
15805 "use regular Mercurial commands. However, MQ provides many commands that are "
15806 "easier to use when you are thinking about patches, as illustrated below."
15807 msgstr ""
15809 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15810 #: ../en/ch12-mq.xml:374
15811 msgid ""
15812 "The <command role=\"hg-ext-mq\">qseries</command> command lists every patch "
15813 "that MQ knows about in this repository, from oldest to newest (most recently "
15814 "<emphasis>created</emphasis>)."
15815 msgstr ""
15817 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15818 #: ../en/ch12-mq.xml:380
15819 msgid ""
15820 "The <command role=\"hg-ext-mq\">qapplied</command> command lists every patch "
15821 "that MQ has <emphasis>applied</emphasis> in this repository, again from "
15822 "oldest to newest (most recently applied)."
15823 msgstr ""
15825 #. type: Content of: <book><chapter><sect1><sect2><title>
15826 #: ../en/ch12-mq.xml:389
15827 msgid "Manipulating the patch stack"
15828 msgstr "操作补丁堆栈"
15830 #. type: Content of: <book><chapter><sect1><sect2><para>
15831 #: ../en/ch12-mq.xml:391
15832 msgid ""
15833 "The previous discussion implied that there must be a difference between "
15834 "<quote>known</quote> and <quote>applied</quote> patches, and there is. MQ "
15835 "can manage a patch without it being applied in the repository."
15836 msgstr ""
15838 #. type: Content of: <book><chapter><sect1><sect2><para>
15839 #: ../en/ch12-mq.xml:396
15840 msgid ""
15841 "An <emphasis>applied</emphasis> patch has a corresponding changeset in the "
15842 "repository, and the effects of the patch and changeset are visible in the "
15843 "working directory. You can undo the application of a patch using the "
15844 "<command role=\"hg-ext-mq\">qpop</command> command. MQ still <emphasis>knows "
15845 "about</emphasis>, or manages, a popped patch, but the patch no longer has a "
15846 "corresponding changeset in the repository, and the working directory does not "
15847 "contain the changes made by the patch. <xref linkend=\"fig:mq:stack\"/> "
15848 "illustrates the difference between applied and tracked patches."
15849 msgstr ""
15851 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
15852 #: ../en/ch12-mq.xml:409
15853 msgid "Applied and unapplied patches in the MQ patch stack"
15854 msgstr "在 MQ 补丁堆栈中应用和撤销补丁"
15856 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
15857 #: ../en/ch12-mq.xml:412
15858 msgid "<imageobject><imagedata fileref=\"figs/mq-stack.png\"/></imageobject>"
15859 msgstr ""
15861 #. type: Content of: <book><chapter><sect1><sect2><para>
15862 #: ../en/ch12-mq.xml:417
15863 msgid ""
15864 "You can reapply an unapplied, or popped, patch using the <command role=\"hg-"
15865 "ext-mq\">qpush</command> command. This creates a new changeset to correspond "
15866 "to the patch, and the patch's changes once again become present in the "
15867 "working directory. See below for examples of <command role=\"hg-ext-mq"
15868 "\">qpop</command> and <command role=\"hg-ext-mq\">qpush</command> in action."
15869 msgstr ""
15871 #. type: Content of: <book><chapter><sect1><sect2><para>
15872 #: ../en/ch12-mq.xml:427
15873 msgid ""
15874 "Notice that once we have popped a patch or two patches, the output of "
15875 "<command role=\"hg-ext-mq\">qseries</command> remains the same, while that of "
15876 "<command role=\"hg-ext-mq\">qapplied</command> has changed."
15877 msgstr ""
15879 #. type: Content of: <book><chapter><sect1><sect2><title>
15880 #: ../en/ch12-mq.xml:435
15881 msgid "Pushing and popping many patches"
15882 msgstr "压入或弹出多个补丁"
15884 #. type: Content of: <book><chapter><sect1><sect2><para>
15885 #: ../en/ch12-mq.xml:437
15886 msgid ""
15887 "While <command role=\"hg-ext-mq\">qpush</command> and <command role=\"hg-ext-"
15888 "mq\">qpop</command> each operate on a single patch at a time by default, you "
15889 "can push and pop many patches in one go. The <option role=\"hg-ext-mq-cmd-"
15890 "qpush-opt\">hg -a</option> option to <command role=\"hg-ext-mq\">qpush</"
15891 "command> causes it to push all unapplied patches, while the <option role=\"hg-"
15892 "ext-mq-cmd-qpop-opt\">-a</option> option to <command role=\"hg-ext-mq\">qpop</"
15893 "command> causes it to pop all applied patches. (For some more ways to push "
15894 "and pop many patches, see <xref linkend=\"sec:mq:perf\"/> below.)"
15895 msgstr ""
15897 #. type: Content of: <book><chapter><sect1><sect2><title>
15898 #: ../en/ch12-mq.xml:453
15899 msgid "Safety checks, and overriding them"
15900 msgstr "安全的检查,然后覆盖它们"
15902 #. type: Content of: <book><chapter><sect1><sect2><para>
15903 #: ../en/ch12-mq.xml:455
15904 msgid ""
15905 "Several MQ commands check the working directory before they do anything, and "
15906 "fail if they find any modifications. They do this to ensure that you won't "
15907 "lose any changes that you have made, but not yet incorporated into a patch. "
15908 "The example below illustrates this; the <command role=\"hg-ext-mq\">qnew</"
15909 "command> command will not create a new patch if there are outstanding "
15910 "changes, caused in this case by the <command role=\"hg-cmd\">hg add</command> "
15911 "of <filename>file3</filename>."
15912 msgstr ""
15914 #. type: Content of: <book><chapter><sect1><sect2><para>
15915 #: ../en/ch12-mq.xml:467
15916 msgid ""
15917 "Commands that check the working directory all take an <quote>I know what I'm "
15918 "doing</quote> option, which is always named <option>-f</option>. The exact "
15919 "meaning of <option>-f</option> depends on the command. For example, <command "
15920 "role=\"hg-cmd\">hg qnew <option role=\"hg-ext-mq-cmd-qnew-opt\">hg -f</"
15921 "option></command> will incorporate any outstanding changes into the new patch "
15922 "it creates, but <command role=\"hg-cmd\">hg qpop <option role=\"hg-ext-mq-cmd-"
15923 "qpop-opt\">hg -f</option></command> will revert modifications to any files "
15924 "affected by the patch that it is popping. Be sure to read the documentation "
15925 "for a command's <option>-f</option> option before you use it!"
15926 msgstr ""
15928 #. type: Content of: <book><chapter><sect1><sect2><title>
15929 #: ../en/ch12-mq.xml:482
15930 msgid "Working on several patches at once"
15931 msgstr "同时处理多个补丁"
15933 #. type: Content of: <book><chapter><sect1><sect2><para>
15934 #: ../en/ch12-mq.xml:484
15935 msgid ""
15936 "The <command role=\"hg-ext-mq\">qrefresh</command> command always refreshes "
15937 "the <emphasis>topmost</emphasis> applied patch. This means that you can "
15938 "suspend work on one patch (by refreshing it), pop or push to make a different "
15939 "patch the top, and work on <emphasis>that</emphasis> patch for a while."
15940 msgstr ""
15942 #. type: Content of: <book><chapter><sect1><sect2><para>
15943 #: ../en/ch12-mq.xml:491
15944 msgid ""
15945 "Here's an example that illustrates how you can use this ability. Let's say "
15946 "you're developing a new feature as two patches. The first is a change to the "
15947 "core of your software, and the second&emdash;layered on top of the "
15948 "first&emdash;changes the user interface to use the code you just added to the "
15949 "core. If you notice a bug in the core while you're working on the UI patch, "
15950 "it's easy to fix the core. Simply <command role=\"hg-ext-mq\">qrefresh</"
15951 "command> the UI patch to save your in-progress changes, and <command role="
15952 "\"hg-ext-mq\">qpop</command> down to the core patch. Fix the core bug, "
15953 "<command role=\"hg-ext-mq\">qrefresh</command> the core patch, and <command "
15954 "role=\"hg-ext-mq\">qpush</command> back to the UI patch to continue where you "
15955 "left off."
15956 msgstr ""
15958 #. type: Content of: <book><chapter><sect1><title>
15959 #: ../en/ch12-mq.xml:508
15960 msgid "More about patches"
15961 msgstr "关于补丁的更多信息"
15963 #. type: Content of: <book><chapter><sect1><para>
15964 #: ../en/ch12-mq.xml:510
15965 msgid ""
15966 "MQ uses the GNU <command>patch</command> command to apply patches, so it's "
15967 "helpful to know a few more detailed aspects of how <command>patch</command> "
15968 "works, and about patches themselves."
15969 msgstr ""
15971 #. type: Content of: <book><chapter><sect1><sect2><title>
15972 #: ../en/ch12-mq.xml:516
15973 msgid "The strip count"
15974 msgstr "修剪计数"
15976 #. type: Content of: <book><chapter><sect1><sect2><para>
15977 #: ../en/ch12-mq.xml:518
15978 msgid ""
15979 "If you look at the file headers in a patch, you will notice that the "
15980 "pathnames usually have an extra component on the front that isn't present in "
15981 "the actual path name. This is a holdover from the way that people used to "
15982 "generate patches (people still do this, but it's somewhat rare with modern "
15983 "revision control tools)."
15984 msgstr ""
15986 #. type: Content of: <book><chapter><sect1><sect2><para>
15987 #: ../en/ch12-mq.xml:525
15988 msgid ""
15989 "Alice would unpack a tarball, edit her files, then decide that she wanted to "
15990 "create a patch. So she'd rename her working directory, unpack the tarball "
15991 "again (hence the need for the rename), and use the <option role=\"cmd-opt-diff"
15992 "\">-r</option> and <option role=\"cmd-opt-diff\">-N</option> options to "
15993 "<command>diff</command> to recursively generate a patch between the "
15994 "unmodified directory and the modified one. The result would be that the name "
15995 "of the unmodified directory would be at the front of the left-hand path in "
15996 "every file header, and the name of the modified directory would be at the "
15997 "front of the right-hand path."
15998 msgstr ""
16000 #. type: Content of: <book><chapter><sect1><sect2><para>
16001 #: ../en/ch12-mq.xml:538
16002 msgid ""
16003 "Since someone receiving a patch from the Alices of the net would be unlikely "
16004 "to have unmodified and modified directories with exactly the same names, the "
16005 "<command>patch</command> command has a <option role=\"cmd-opt-patch\">-p</"
16006 "option> option that indicates the number of leading path name components to "
16007 "strip when trying to apply a patch. This number is called the "
16008 "<emphasis>strip count</emphasis>."
16009 msgstr ""
16011 #. type: Content of: <book><chapter><sect1><sect2><para>
16012 #: ../en/ch12-mq.xml:546
16013 msgid ""
16014 "An option of <quote><literal>-p1</literal></quote> means <quote>use a strip "
16015 "count of one</quote>. If <command>patch</command> sees a file name "
16016 "<filename>foo/bar/baz</filename> in a file header, it will strip "
16017 "<filename>foo</filename> and try to patch a file named <filename>bar/baz</"
16018 "filename>. (Strictly speaking, the strip count refers to the number of "
16019 "<emphasis>path separators</emphasis> (and the components that go with them ) "
16020 "to strip. A strip count of one will turn <filename>foo/bar</filename> into "
16021 "<filename>bar</filename>, but <filename>/foo/bar</filename> (notice the extra "
16022 "leading slash) into <filename>foo/bar</filename>.)"
16023 msgstr ""
16025 #. type: Content of: <book><chapter><sect1><sect2><para>
16026 #: ../en/ch12-mq.xml:559
16027 msgid ""
16028 "The <quote>standard</quote> strip count for patches is one; almost all "
16029 "patches contain one leading path name component that needs to be stripped. "
16030 "Mercurial's <command role=\"hg-cmd\">hg diff</command> command generates path "
16031 "names in this form, and the <command role=\"hg-cmd\">hg import</command> "
16032 "command and MQ expect patches to have a strip count of one."
16033 msgstr ""
16035 #. type: Content of: <book><chapter><sect1><sect2><para>
16036 #: ../en/ch12-mq.xml:567
16037 msgid ""
16038 "If you receive a patch from someone that you want to add to your patch queue, "
16039 "and the patch needs a strip count other than one, you cannot just <command "
16040 "role=\"hg-ext-mq\">qimport</command> the patch, because <command role=\"hg-"
16041 "ext-mq\">qimport</command> does not yet have a <literal>-p</literal> option "
16042 "(see <ulink role=\"hg-bug\" url=\"http://www.selenic.com/mercurial/bts/"
16043 "issue311\">issue 311</ulink>). Your best bet is to <command role=\"hg-ext-mq"
16044 "\">qnew</command> a patch of your own, then use <command>patch -pN</command> "
16045 "to apply their patch, followed by <command role=\"hg-cmd\">hg addremove</"
16046 "command> to pick up any files added or removed by the patch, followed by "
16047 "<command role=\"hg-ext-mq\">hg qrefresh</command>. This complexity may become "
16048 "unnecessary; see <ulink role=\"hg-bug\" url=\"http://www.selenic.com/"
16049 "mercurial/bts/issue311\">issue 311</ulink> for details."
16050 msgstr ""
16052 #. type: Content of: <book><chapter><sect1><sect2><title>
16053 #: ../en/ch12-mq.xml:587
16054 msgid "Strategies for applying a patch"
16055 msgstr "应用补丁的策略"
16057 #. type: Content of: <book><chapter><sect1><sect2><para>
16058 #: ../en/ch12-mq.xml:589
16059 msgid ""
16060 "When <command>patch</command> applies a hunk, it tries a handful of "
16061 "successively less accurate strategies to try to make the hunk apply. This "
16062 "falling-back technique often makes it possible to take a patch that was "
16063 "generated against an old version of a file, and apply it against a newer "
16064 "version of that file."
16065 msgstr ""
16067 #. type: Content of: <book><chapter><sect1><sect2><para>
16068 #: ../en/ch12-mq.xml:596
16069 msgid ""
16070 "First, <command>patch</command> tries an exact match, where the line numbers, "
16071 "the context, and the text to be modified must apply exactly. If it cannot "
16072 "make an exact match, it tries to find an exact match for the context, without "
16073 "honouring the line numbering information. If this succeeds, it prints a line "
16074 "of output saying that the hunk was applied, but at some <emphasis>offset</"
16075 "emphasis> from the original line number."
16076 msgstr ""
16078 #. type: Content of: <book><chapter><sect1><sect2><para>
16079 #: ../en/ch12-mq.xml:605
16080 msgid ""
16081 "If a context-only match fails, <command>patch</command> removes the first and "
16082 "last lines of the context, and tries a <emphasis>reduced</emphasis> context-"
16083 "only match. If the hunk with reduced context succeeds, it prints a message "
16084 "saying that it applied the hunk with a <emphasis>fuzz factor</emphasis> (the "
16085 "number after the fuzz factor indicates how many lines of context "
16086 "<command>patch</command> had to trim before the patch applied)."
16087 msgstr ""
16089 #. type: Content of: <book><chapter><sect1><sect2><para>
16090 #: ../en/ch12-mq.xml:614
16091 msgid ""
16092 "When neither of these techniques works, <command>patch</command> prints a "
16093 "message saying that the hunk in question was rejected. It saves rejected "
16094 "hunks (also simply called <quote>rejects</quote>) to a file with the same "
16095 "name, and an added <filename role=\"special\">.rej</filename> extension. It "
16096 "also saves an unmodified copy of the file with a <filename role=\"special\">."
16097 "orig</filename> extension; the copy of the file without any extensions will "
16098 "contain any changes made by hunks that <emphasis>did</emphasis> apply "
16099 "cleanly. If you have a patch that modifies <filename>foo</filename> with six "
16100 "hunks, and one of them fails to apply, you will have: an unmodified "
16101 "<filename>foo.orig</filename>, a <filename>foo.rej</filename> containing one "
16102 "hunk, and <filename>foo</filename>, containing the changes made by the five "
16103 "successful hunks."
16104 msgstr ""
16106 #. type: Content of: <book><chapter><sect1><sect2><title>
16107 #: ../en/ch12-mq.xml:632
16108 msgid "Some quirks of patch representation"
16109 msgstr "补丁的一些特性"
16111 #. type: Content of: <book><chapter><sect1><sect2><para>
16112 #: ../en/ch12-mq.xml:634
16113 msgid ""
16114 "There are a few useful things to know about how <command>patch</command> "
16115 "works with files."
16116 msgstr ""
16118 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16119 #: ../en/ch12-mq.xml:637
16120 msgid ""
16121 "This should already be obvious, but <command>patch</command> cannot handle "
16122 "binary files."
16123 msgstr ""
16125 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16126 #: ../en/ch12-mq.xml:641
16127 msgid ""
16128 "Neither does it care about the executable bit; it creates new files as "
16129 "readable, but not executable."
16130 msgstr ""
16132 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16133 #: ../en/ch12-mq.xml:645
16134 msgid ""
16135 "<command>patch</command> treats the removal of a file as a diff between the "
16136 "file to be removed and the empty file. So your idea of <quote>I deleted this "
16137 "file</quote> looks like <quote>every line of this file was deleted</quote> in "
16138 "a patch."
16139 msgstr ""
16141 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16142 #: ../en/ch12-mq.xml:651
16143 msgid ""
16144 "It treats the addition of a file as a diff between the empty file and the "
16145 "file to be added. So in a patch, your idea of <quote>I added this file</"
16146 "quote> looks like <quote>every line of this file was added</quote>."
16147 msgstr ""
16149 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16150 #: ../en/ch12-mq.xml:657
16151 msgid ""
16152 "It treats a renamed file as the removal of the old name, and the addition of "
16153 "the new name. This means that renamed files have a big footprint in "
16154 "patches. (Note also that Mercurial does not currently try to infer when "
16155 "files have been renamed or copied in a patch.)"
16156 msgstr ""
16158 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16159 #: ../en/ch12-mq.xml:663
16160 msgid ""
16161 "<command>patch</command> cannot represent empty files, so you cannot use a "
16162 "patch to represent the notion <quote>I added this empty file to the tree</"
16163 "quote>."
16164 msgstr ""
16166 #. type: Content of: <book><chapter><sect1><sect2><title>
16167 #: ../en/ch12-mq.xml:671
16168 msgid "Beware the fuzz"
16169 msgstr "当心毛刺"
16171 #. type: Content of: <book><chapter><sect1><sect2><para>
16172 #: ../en/ch12-mq.xml:673
16173 msgid ""
16174 "While applying a hunk at an offset, or with a fuzz factor, will often be "
16175 "completely successful, these inexact techniques naturally leave open the "
16176 "possibility of corrupting the patched file. The most common cases typically "
16177 "involve applying a patch twice, or at an incorrect location in the file. If "
16178 "<command>patch</command> or <command role=\"hg-ext-mq\">qpush</command> ever "
16179 "mentions an offset or fuzz factor, you should make sure that the modified "
16180 "files are correct afterwards."
16181 msgstr ""
16183 #. type: Content of: <book><chapter><sect1><sect2><para>
16184 #: ../en/ch12-mq.xml:683
16185 msgid ""
16186 "It's often a good idea to refresh a patch that has applied with an offset or "
16187 "fuzz factor; refreshing the patch generates new context information that will "
16188 "make it apply cleanly. I say <quote>often,</quote> not <quote>always,</"
16189 "quote> because sometimes refreshing a patch will make it fail to apply "
16190 "against a different revision of the underlying files. In some cases, such as "
16191 "when you're maintaining a patch that must sit on top of multiple versions of "
16192 "a source tree, it's acceptable to have a patch apply with some fuzz, provided "
16193 "you've verified the results of the patching process in such cases."
16194 msgstr ""
16196 #. type: Content of: <book><chapter><sect1><sect2><title>
16197 #: ../en/ch12-mq.xml:696
16198 msgid "Handling rejection"
16199 msgstr "处理拒绝"
16201 #. type: Content of: <book><chapter><sect1><sect2><para>
16202 #: ../en/ch12-mq.xml:698
16203 msgid ""
16204 "If <command role=\"hg-ext-mq\">qpush</command> fails to apply a patch, it "
16205 "will print an error message and exit. If it has left <filename role=\"special"
16206 "\">.rej</filename> files behind, it is usually best to fix up the rejected "
16207 "hunks before you push more patches or do any further work."
16208 msgstr ""
16210 #. type: Content of: <book><chapter><sect1><sect2><para>
16211 #: ../en/ch12-mq.xml:704
16212 msgid ""
16213 "If your patch <emphasis>used to</emphasis> apply cleanly, and no longer does "
16214 "because you've changed the underlying code that your patches are based on, "
16215 "Mercurial Queues can help; see <xref linkend=\"sec:mq:merge\"/> for details."
16216 msgstr ""
16218 #. type: Content of: <book><chapter><sect1><sect2><para>
16219 #: ../en/ch12-mq.xml:709
16220 msgid ""
16221 "Unfortunately, there aren't any great techniques for dealing with rejected "
16222 "hunks. Most often, you'll need to view the <filename role=\"special\">.rej</"
16223 "filename> file and edit the target file, applying the rejected hunks by hand."
16224 msgstr ""
16226 #. type: Content of: <book><chapter><sect1><sect2><para>
16227 #: ../en/ch12-mq.xml:714
16228 msgid ""
16229 "A Linux kernel hacker, Chris Mason (the author of Mercurial Queues), wrote a "
16230 "tool called <command>mpatch</command> (<ulink url=\"http://oss.oracle.com/"
16231 "~mason/mpatch/\">http://oss.oracle.com/~mason/mpatch/</ulink>), which takes a "
16232 "simple approach to automating the application of hunks rejected by "
16233 "<command>patch</command>. The <command>mpatch</command> command can help "
16234 "with four common reasons that a hunk may be rejected:"
16235 msgstr ""
16237 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16238 #: ../en/ch12-mq.xml:724
16239 msgid "The context in the middle of a hunk has changed."
16240 msgstr ""
16242 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16243 #: ../en/ch12-mq.xml:727
16244 msgid "A hunk is missing some context at the beginning or end."
16245 msgstr ""
16247 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16248 #: ../en/ch12-mq.xml:730
16249 msgid ""
16250 "A large hunk might apply better&emdash;either entirely or in part&emdash;if "
16251 "it was broken up into smaller hunks."
16252 msgstr ""
16254 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16255 #: ../en/ch12-mq.xml:734
16256 msgid ""
16257 "A hunk removes lines with slightly different content than those currently "
16258 "present in the file."
16259 msgstr ""
16261 #. type: Content of: <book><chapter><sect1><sect2><para>
16262 #: ../en/ch12-mq.xml:738
16263 msgid ""
16264 "If you use <command>mpatch</command>, you should be doubly careful to check "
16265 "your results when you're done. In fact, <command>mpatch</command> enforces "
16266 "this method of double-checking the tool's output, by automatically dropping "
16267 "you into a merge program when it has done its job, so that you can verify its "
16268 "work and finish off any remaining merges."
16269 msgstr ""
16271 #. type: Content of: <book><chapter><sect1><title>
16272 #: ../en/ch12-mq.xml:749
16273 msgid "More on patch management"
16274 msgstr "补丁管理进阶"
16276 #. type: Content of: <book><chapter><sect1><para>
16277 #: ../en/ch12-mq.xml:751
16278 msgid ""
16279 "As you grow familiar with MQ, you will find yourself wanting to perform other "
16280 "kinds of patch management operations."
16281 msgstr ""
16283 #. type: Content of: <book><chapter><sect1><sect2><title>
16284 #: ../en/ch12-mq.xml:755
16285 msgid "Deleting unwanted patches"
16286 msgstr "删除不需要的补丁"
16288 #. type: Content of: <book><chapter><sect1><sect2><para>
16289 #: ../en/ch12-mq.xml:757
16290 msgid ""
16291 "If you want to get rid of a patch, use the <command role=\"hg-ext-mq\">hg "
16292 "qdelete</command> command to delete the patch file and remove its entry from "
16293 "the patch series. If you try to delete a patch that is still applied, "
16294 "<command role=\"hg-ext-mq\">hg qdelete</command> will refuse."
16295 msgstr ""
16297 #. type: Content of: <book><chapter><sect1><sect2><title>
16298 #: ../en/ch12-mq.xml:767
16299 msgid "Converting to and from permanent revisions"
16300 msgstr "与持久版本的相互转换"
16302 #. type: Content of: <book><chapter><sect1><sect2><para>
16303 #: ../en/ch12-mq.xml:769
16304 msgid ""
16305 "Once you're done working on a patch and want to turn it into a permanent "
16306 "changeset, use the <command role=\"hg-ext-mq\">hg qfinish</command> command. "
16307 "Pass a revision to the command to identify the patch that you want to turn "
16308 "into a regular changeset; this patch must already be applied."
16309 msgstr ""
16311 #. type: Content of: <book><chapter><sect1><sect2><para>
16312 #: ../en/ch12-mq.xml:777
16313 msgid ""
16314 "The <command role=\"hg-ext-mq\">hg qfinish</command> command accepts an "
16315 "<option>--all</option> or <option>-a</option> option, which turns all applied "
16316 "patches into regular changesets."
16317 msgstr ""
16319 #. type: Content of: <book><chapter><sect1><sect2><para>
16320 #: ../en/ch12-mq.xml:782
16321 msgid ""
16322 "It is also possible to turn an existing changeset into a patch, by passing "
16323 "the <option>-r</option> option to <command role=\"hg-ext-mq\">hg qimport</"
16324 "command>."
16325 msgstr ""
16327 #. type: Content of: <book><chapter><sect1><sect2><para>
16328 #: ../en/ch12-mq.xml:788
16329 msgid ""
16330 "Note that it only makes sense to convert a changeset into a patch if you have "
16331 "not propagated that changeset into any other repositories. The imported "
16332 "changeset's ID will change every time you refresh the patch, which will make "
16333 "Mercurial treat it as unrelated to the original changeset if you have pushed "
16334 "it somewhere else."
16335 msgstr ""
16337 #. type: Content of: <book><chapter><sect1><title>
16338 #: ../en/ch12-mq.xml:798
16339 msgid "Getting the best performance out of MQ"
16340 msgstr "MQ 的性能"
16342 #. type: Content of: <book><chapter><sect1><para>
16343 #: ../en/ch12-mq.xml:800
16344 msgid ""
16345 "MQ is very efficient at handling a large number of patches. I ran some "
16346 "performance experiments in mid-2006 for a talk that I gave at the 2006 "
16347 "EuroPython conference (on modern hardware, you should expect better "
16348 "performance than you'll see below). I used as my data set the Linux 2.6.17-"
16349 "mm1 patch series, which consists of 1,738 patches. I applied these on top of "
16350 "a Linux kernel repository containing all 27,472 revisions between Linux "
16351 "2.6.12-rc2 and Linux 2.6.17."
16352 msgstr ""
16354 #. type: Content of: <book><chapter><sect1><para>
16355 #: ../en/ch12-mq.xml:809
16356 msgid ""
16357 "On my old, slow laptop, I was able to <command role=\"hg-cmd\">hg qpush "
16358 "<option role=\"hg-ext-mq-cmd-qpush-opt\">hg -a</option></command> all 1,738 "
16359 "patches in 3.5 minutes, and <command role=\"hg-cmd\">hg qpop <option role="
16360 "\"hg-ext-mq-cmd-qpop-opt\">hg -a</option></command> them all in 30 seconds. "
16361 "(On a newer laptop, the time to push all patches dropped to two minutes.) I "
16362 "could <command role=\"hg-ext-mq\">qrefresh</command> one of the biggest "
16363 "patches (which made 22,779 lines of changes to 287 files) in 6.6 seconds."
16364 msgstr ""
16366 #. type: Content of: <book><chapter><sect1><para>
16367 #: ../en/ch12-mq.xml:820
16368 msgid ""
16369 "Clearly, MQ is well suited to working in large trees, but there are a few "
16370 "tricks you can use to get the best performance of it."
16371 msgstr ""
16373 #. type: Content of: <book><chapter><sect1><para>
16374 #: ../en/ch12-mq.xml:824
16375 msgid ""
16376 "First of all, try to <quote>batch</quote> operations together. Every time "
16377 "you run <command role=\"hg-ext-mq\">qpush</command> or <command role=\"hg-ext-"
16378 "mq\">qpop</command>, these commands scan the working directory once to make "
16379 "sure you haven't made some changes and then forgotten to run <command role="
16380 "\"hg-ext-mq\">qrefresh</command>. On a small tree, the time that this scan "
16381 "takes is unnoticeable. However, on a medium-sized tree (containing tens of "
16382 "thousands of files), it can take a second or more."
16383 msgstr ""
16385 #. type: Content of: <book><chapter><sect1><para>
16386 #: ../en/ch12-mq.xml:835
16387 msgid ""
16388 "The <command role=\"hg-ext-mq\">qpush</command> and <command role=\"hg-ext-mq"
16389 "\">qpop</command> commands allow you to push and pop multiple patches at a "
16390 "time. You can identify the <quote>destination patch</quote> that you want to "
16391 "end up at. When you <command role=\"hg-ext-mq\">qpush</command> with a "
16392 "destination specified, it will push patches until that patch is at the top of "
16393 "the applied stack. When you <command role=\"hg-ext-mq\">qpop</command> to a "
16394 "destination, MQ will pop patches until the destination patch is at the top."
16395 msgstr ""
16397 #. type: Content of: <book><chapter><sect1><para>
16398 #: ../en/ch12-mq.xml:845
16399 msgid ""
16400 "You can identify a destination patch using either the name of the patch, or "
16401 "by number. If you use numeric addressing, patches are counted from zero; "
16402 "this means that the first patch is zero, the second is one, and so on."
16403 msgstr ""
16405 #. type: Content of: <book><chapter><sect1><title>
16406 #: ../en/ch12-mq.xml:852
16407 msgid "Updating your patches when the underlying code changes"
16408 msgstr "当基础代码改变时,更新补丁的方法"
16410 #. type: Content of: <book><chapter><sect1><para>
16411 #: ../en/ch12-mq.xml:855
16412 msgid ""
16413 "It's common to have a stack of patches on top of an underlying repository "
16414 "that you don't modify directly. If you're working on changes to third-party "
16415 "code, or on a feature that is taking longer to develop than the rate of "
16416 "change of the code beneath, you will often need to sync up with the "
16417 "underlying code, and fix up any hunks in your patches that no longer apply. "
16418 "This is called <emphasis>rebasing</emphasis> your patch series."
16419 msgstr ""
16421 #. type: Content of: <book><chapter><sect1><para>
16422 #: ../en/ch12-mq.xml:864
16423 msgid ""
16424 "The simplest way to do this is to <command role=\"hg-cmd\">hg qpop <option "
16425 "role=\"hg-ext-mq-cmd-qpop-opt\">hg -a</option></command> your patches, then "
16426 "<command role=\"hg-cmd\">hg pull</command> changes into the underlying "
16427 "repository, and finally <command role=\"hg-cmd\">hg qpush <option role=\"hg-"
16428 "ext-mq-cmd-qpop-opt\">hg -a</option></command> your patches again. MQ will "
16429 "stop pushing any time it runs across a patch that fails to apply during "
16430 "conflicts, allowing you to fix your conflicts, <command role=\"hg-ext-mq"
16431 "\">qrefresh</command> the affected patch, and continue pushing until you have "
16432 "fixed your entire stack."
16433 msgstr ""
16435 #. type: Content of: <book><chapter><sect1><para>
16436 #: ../en/ch12-mq.xml:876
16437 msgid ""
16438 "This approach is easy to use and works well if you don't expect changes to "
16439 "the underlying code to affect how well your patches apply. If your patch "
16440 "stack touches code that is modified frequently or invasively in the "
16441 "underlying repository, however, fixing up rejected hunks by hand quickly "
16442 "becomes tiresome."
16443 msgstr ""
16445 #. type: Content of: <book><chapter><sect1><para>
16446 #: ../en/ch12-mq.xml:883
16447 msgid ""
16448 "It's possible to partially automate the rebasing process. If your patches "
16449 "apply cleanly against some revision of the underlying repo, MQ can use this "
16450 "information to help you to resolve conflicts between your patches and a "
16451 "different revision."
16452 msgstr ""
16454 #. type: Content of: <book><chapter><sect1><para>
16455 #: ../en/ch12-mq.xml:889
16456 msgid "The process is a little involved."
16457 msgstr ""
16459 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
16460 #: ../en/ch12-mq.xml:891
16461 msgid ""
16462 "To begin, <command role=\"hg-cmd\">hg qpush -a</command> all of your patches "
16463 "on top of the revision where you know that they apply cleanly."
16464 msgstr ""
16466 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
16467 #: ../en/ch12-mq.xml:895
16468 msgid ""
16469 "Save a backup copy of your patch directory using <command role=\"hg-cmd\">hg "
16470 "qsave <option role=\"hg-ext-mq-cmd-qsave-opt\">hg -e</option> <option role="
16471 "\"hg-ext-mq-cmd-qsave-opt\">hg -c</option></command>. This prints the name "
16472 "of the directory that it has saved the patches in. It will save the patches "
16473 "to a directory called <filename role=\"special\" class=\"directory\">.hg/"
16474 "patches.N</filename>, where <literal>N</literal> is a small integer. It also "
16475 "commits a <quote>save changeset</quote> on top of your applied patches; this "
16476 "is for internal book-keeping, and records the states of the <filename role="
16477 "\"special\">series</filename> and <filename role=\"special\">status</"
16478 "filename> files."
16479 msgstr ""
16481 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
16482 #: ../en/ch12-mq.xml:909
16483 msgid ""
16484 "Use <command role=\"hg-cmd\">hg pull</command> to bring new changes into the "
16485 "underlying repository. (Don't run <command role=\"hg-cmd\">hg pull -u</"
16486 "command>; see below for why.)"
16487 msgstr ""
16489 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
16490 #: ../en/ch12-mq.xml:914
16491 msgid ""
16492 "Update to the new tip revision, using <command role=\"hg-cmd\">hg update "
16493 "<option role=\"hg-opt-update\">-C</option></command> to override the patches "
16494 "you have pushed."
16495 msgstr ""
16497 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
16498 #: ../en/ch12-mq.xml:919
16499 msgid ""
16500 "Merge all patches using <command>hg qpush -m -a</command>. The <option role="
16501 "\"hg-ext-mq-cmd-qpush-opt\">-m</option> option to <command role=\"hg-ext-mq"
16502 "\">qpush</command> tells MQ to perform a three-way merge if the patch fails "
16503 "to apply."
16504 msgstr ""
16506 #. type: Content of: <book><chapter><sect1><para>
16507 #: ../en/ch12-mq.xml:927
16508 msgid ""
16509 "During the <command role=\"hg-cmd\">hg qpush <option role=\"hg-ext-mq-cmd-"
16510 "qpush-opt\">hg -m</option></command>, each patch in the <filename role="
16511 "\"special\">series</filename> file is applied normally. If a patch applies "
16512 "with fuzz or rejects, MQ looks at the queue you <command role=\"hg-ext-mq"
16513 "\">qsave</command>d, and performs a three-way merge with the corresponding "
16514 "changeset. This merge uses Mercurial's normal merge machinery, so it may pop "
16515 "up a GUI merge tool to help you to resolve problems."
16516 msgstr ""
16518 #. type: Content of: <book><chapter><sect1><para>
16519 #: ../en/ch12-mq.xml:937
16520 msgid ""
16521 "When you finish resolving the effects of a patch, MQ refreshes your patch "
16522 "based on the result of the merge."
16523 msgstr ""
16525 #. type: Content of: <book><chapter><sect1><para>
16526 #: ../en/ch12-mq.xml:940
16527 msgid ""
16528 "At the end of this process, your repository will have one extra head from the "
16529 "old patch queue, and a copy of the old patch queue will be in <filename role="
16530 "\"special\" class=\"directory\">.hg/patches.N</filename>. You can remove the "
16531 "extra head using <command role=\"hg-cmd\">hg qpop -a -n patches.N</command> "
16532 "or <command role=\"hg-cmd\">hg strip</command>. You can delete <filename "
16533 "role=\"special\" class=\"directory\">.hg/patches.N</filename> once you are "
16534 "sure that you no longer need it as a backup."
16535 msgstr ""
16537 #. type: Content of: <book><chapter><sect1><title>
16538 #: ../en/ch12-mq.xml:952
16539 msgid "Identifying patches"
16540 msgstr "标识补丁"
16542 #. type: Content of: <book><chapter><sect1><para>
16543 #: ../en/ch12-mq.xml:954
16544 msgid ""
16545 "MQ commands that work with patches let you refer to a patch either by using "
16546 "its name or by a number. By name is obvious enough; pass the name "
16547 "<filename>foo.patch</filename> to <command role=\"hg-ext-mq\">qpush</"
16548 "command>, for example, and it will push patches until <filename>foo.patch</"
16549 "filename> is applied."
16550 msgstr ""
16552 #. type: Content of: <book><chapter><sect1><para>
16553 #: ../en/ch12-mq.xml:961
16554 msgid ""
16555 "As a shortcut, you can refer to a patch using both a name and a numeric "
16556 "offset; <literal>foo.patch-2</literal> means <quote>two patches before "
16557 "<literal>foo.patch</literal></quote>, while <literal>bar.patch+4</literal> "
16558 "means <quote>four patches after <literal>bar.patch</literal></quote>."
16559 msgstr ""
16561 #. type: Content of: <book><chapter><sect1><para>
16562 #: ../en/ch12-mq.xml:967
16563 msgid ""
16564 "Referring to a patch by index isn't much different. The first patch printed "
16565 "in the output of <command role=\"hg-ext-mq\">qseries</command> is patch zero "
16566 "(yes, it's one of those start-at-zero counting systems); the second is patch "
16567 "one; and so on."
16568 msgstr ""
16570 #. type: Content of: <book><chapter><sect1><para>
16571 #: ../en/ch12-mq.xml:973
16572 msgid ""
16573 "MQ also makes it easy to work with patches when you are using normal "
16574 "Mercurial commands. Every command that accepts a changeset ID will also "
16575 "accept the name of an applied patch. MQ augments the tags normally in the "
16576 "repository with an eponymous one for each applied patch. In addition, the "
16577 "special tags <literal role=\"tag\">qbase</literal> and <literal role=\"tag"
16578 "\">qtip</literal> identify the <quote>bottom-most</quote> and topmost applied "
16579 "patches, respectively."
16580 msgstr ""
16582 #. type: Content of: <book><chapter><sect1><para>
16583 #: ../en/ch12-mq.xml:983
16584 msgid ""
16585 "These additions to Mercurial's normal tagging capabilities make dealing with "
16586 "patches even more of a breeze."
16587 msgstr ""
16589 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
16590 #: ../en/ch12-mq.xml:986
16591 msgid "Want to patchbomb a mailing list with your latest series of changes?"
16592 msgstr ""
16594 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
16595 #: ../en/ch12-mq.xml:989
16596 msgid ""
16597 "(Don't know what <quote>patchbombing</quote> is? See <xref linkend=\"sec:"
16598 "hgext:patchbomb\"/>.)"
16599 msgstr ""
16601 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
16602 #: ../en/ch12-mq.xml:992
16603 msgid ""
16604 "Need to see all of the patches since <literal>foo.patch</literal> that have "
16605 "touched files in a subdirectory of your tree?"
16606 msgstr ""
16608 #. type: Content of: <book><chapter><sect1><para>
16609 #: ../en/ch12-mq.xml:999
16610 msgid ""
16611 "Because MQ makes the names of patches available to the rest of Mercurial "
16612 "through its normal internal tag machinery, you don't need to type in the "
16613 "entire name of a patch when you want to identify it by name."
16614 msgstr ""
16616 #. type: Content of: <book><chapter><sect1><para>
16617 #: ../en/ch12-mq.xml:1004
16618 msgid ""
16619 "Another nice consequence of representing patch names as tags is that when you "
16620 "run the <command role=\"hg-cmd\">hg log</command> command, it will display a "
16621 "patch's name as a tag, simply as part of its normal output. This makes it "
16622 "easy to visually distinguish applied patches from underlying <quote>normal</"
16623 "quote> revisions. The following example shows a few normal Mercurial "
16624 "commands in use with applied patches."
16625 msgstr ""
16627 #. type: Content of: <book><chapter><sect1><title>
16628 #: ../en/ch12-mq.xml:1017
16629 msgid "Useful things to know about"
16630 msgstr "其它需要了解的东西"
16632 #. type: Content of: <book><chapter><sect1><para>
16633 #: ../en/ch12-mq.xml:1019
16634 msgid ""
16635 "There are a number of aspects of MQ usage that don't fit tidily into sections "
16636 "of their own, but that are good to know. Here they are, in one place."
16637 msgstr ""
16639 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
16640 #: ../en/ch12-mq.xml:1024
16641 msgid ""
16642 "Normally, when you <command role=\"hg-ext-mq\">qpop</command> a patch and "
16643 "<command role=\"hg-ext-mq\">qpush</command> it again, the changeset that "
16644 "represents the patch after the pop/push will have a <emphasis>different "
16645 "identity</emphasis> than the changeset that represented the hash beforehand. "
16646 "See <xref linkend=\"sec:mqref:cmd:qpush\"/> for information as to why this is."
16647 msgstr ""
16649 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
16650 #: ../en/ch12-mq.xml:1033
16651 msgid ""
16652 "It's not a good idea to <command role=\"hg-cmd\">hg merge</command> changes "
16653 "from another branch with a patch changeset, at least if you want to maintain "
16654 "the <quote>patchiness</quote> of that changeset and changesets below it on "
16655 "the patch stack. If you try to do this, it will appear to succeed, but MQ "
16656 "will become confused."
16657 msgstr ""
16659 #. type: Content of: <book><chapter><sect1><title>
16660 #: ../en/ch12-mq.xml:1044
16661 msgid "Managing patches in a repository"
16662 msgstr "在版本库管理补丁"
16664 #. type: Content of: <book><chapter><sect1><para>
16665 #: ../en/ch12-mq.xml:1046
16666 msgid ""
16667 "Because MQ's <filename role=\"special\" class=\"directory\">.hg/patches</"
16668 "filename> directory resides outside a Mercurial repository's working "
16669 "directory, the <quote>underlying</quote> Mercurial repository knows nothing "
16670 "about the management or presence of patches."
16671 msgstr ""
16673 #. type: Content of: <book><chapter><sect1><para>
16674 #: ../en/ch12-mq.xml:1052
16675 msgid ""
16676 "This presents the interesting possibility of managing the contents of the "
16677 "patch directory as a Mercurial repository in its own right. This can be a "
16678 "useful way to work. For example, you can work on a patch for a while, "
16679 "<command role=\"hg-ext-mq\">qrefresh</command> it, then <command role=\"hg-cmd"
16680 "\">hg commit</command> the current state of the patch. This lets you "
16681 "<quote>roll back</quote> to that version of the patch later on."
16682 msgstr ""
16684 #. type: Content of: <book><chapter><sect1><para>
16685 #: ../en/ch12-mq.xml:1061
16686 msgid ""
16687 "You can then share different versions of the same patch stack among multiple "
16688 "underlying repositories. I use this when I am developing a Linux kernel "
16689 "feature. I have a pristine copy of my kernel sources for each of several CPU "
16690 "architectures, and a cloned repository under each that contains the patches I "
16691 "am working on. When I want to test a change on a different architecture, I "
16692 "push my current patches to the patch repository associated with that kernel "
16693 "tree, pop and push all of my patches, and build and test that kernel."
16694 msgstr ""
16696 #. type: Content of: <book><chapter><sect1><para>
16697 #: ../en/ch12-mq.xml:1071
16698 msgid ""
16699 "Managing patches in a repository makes it possible for multiple developers to "
16700 "work on the same patch series without colliding with each other, all on top "
16701 "of an underlying source base that they may or may not control."
16702 msgstr ""
16704 #. type: Content of: <book><chapter><sect1><sect2><title>
16705 #: ../en/ch12-mq.xml:1077
16706 msgid "MQ support for patch repositories"
16707 msgstr "MQ 支持补丁版本库"
16709 #. type: Content of: <book><chapter><sect1><sect2><para>
16710 #: ../en/ch12-mq.xml:1079
16711 msgid ""
16712 "MQ helps you to work with the <filename role=\"special\" class=\"directory\">."
16713 "hg/patches</filename> directory as a repository; when you prepare a "
16714 "repository for working with patches using <command role=\"hg-ext-mq\">qinit</"
16715 "command>, you can pass the <option role=\"hg-ext-mq-cmd-qinit-opt\">hg -c</"
16716 "option> option to create the <filename role=\"special\" class=\"directory\">."
16717 "hg/patches</filename> directory as a Mercurial repository."
16718 msgstr ""
16720 #. type: Content of: <book><chapter><sect1><sect2><note><para>
16721 #: ../en/ch12-mq.xml:1089
16722 msgid ""
16723 "If you forget to use the <option role=\"hg-ext-mq-cmd-qinit-opt\">hg -c</"
16724 "option> option, you can simply go into the <filename role=\"special\" class="
16725 "\"directory\">.hg/patches</filename> directory at any time and run <command "
16726 "role=\"hg-cmd\">hg init</command>. Don't forget to add an entry for the "
16727 "<filename role=\"special\">status</filename> file to the <filename role="
16728 "\"special\">.hgignore</filename> file, though"
16729 msgstr ""
16731 #. type: Content of: <book><chapter><sect1><sect2><note><para>
16732 #: ../en/ch12-mq.xml:1098
16733 msgid ""
16734 "(<command role=\"hg-cmd\">hg qinit <option role=\"hg-ext-mq-cmd-qinit-opt"
16735 "\">hg -c</option></command> does this for you automatically); you "
16736 "<emphasis>really</emphasis> don't want to manage the <filename role=\"special"
16737 "\">status</filename> file."
16738 msgstr ""
16740 #. type: Content of: <book><chapter><sect1><sect2><para>
16741 #: ../en/ch12-mq.xml:1105
16742 msgid ""
16743 "As a convenience, if MQ notices that the <filename class=\"directory\">.hg/"
16744 "patches</filename> directory is a repository, it will automatically <command "
16745 "role=\"hg-cmd\">hg add</command> every patch that you create and import."
16746 msgstr ""
16748 #. type: Content of: <book><chapter><sect1><sect2><para>
16749 #: ../en/ch12-mq.xml:1110
16750 msgid ""
16751 "MQ provides a shortcut command, <command role=\"hg-ext-mq\">qcommit</"
16752 "command>, that runs <command role=\"hg-cmd\">hg commit</command> in the "
16753 "<filename role=\"special\" class=\"directory\">.hg/patches</filename> "
16754 "directory. This saves some bothersome typing."
16755 msgstr ""
16757 #. type: Content of: <book><chapter><sect1><sect2><para>
16758 #: ../en/ch12-mq.xml:1116
16759 msgid ""
16760 "Finally, as a convenience to manage the patch directory, you can define the "
16761 "alias <command>mq</command> on Unix systems. For example, on Linux systems "
16762 "using the <command>bash</command> shell, you can include the following "
16763 "snippet in your <filename role=\"home\">~/.bashrc</filename>."
16764 msgstr ""
16766 #. type: Content of: <book><chapter><sect1><sect2><para>
16767 #: ../en/ch12-mq.xml:1125
16768 msgid ""
16769 "You can then issue commands of the form <command>mq pull</command> from the "
16770 "main repository."
16771 msgstr ""
16773 #. type: Content of: <book><chapter><sect1><sect2><title>
16774 #: ../en/ch12-mq.xml:1130
16775 msgid "A few things to watch out for"
16776 msgstr "需要注意的事情"
16778 #. type: Content of: <book><chapter><sect1><sect2><para>
16779 #: ../en/ch12-mq.xml:1132
16780 msgid ""
16781 "MQ's support for working with a repository full of patches is limited in a "
16782 "few small respects."
16783 msgstr ""
16785 #. type: Content of: <book><chapter><sect1><sect2><para>
16786 #: ../en/ch12-mq.xml:1135
16787 msgid ""
16788 "MQ cannot automatically detect changes that you make to the patch directory. "
16789 "If you <command role=\"hg-cmd\">hg pull</command>, manually edit, or <command "
16790 "role=\"hg-cmd\">hg update</command> changes to patches or the <filename role="
16791 "\"special\">series</filename> file, you will have to <command role=\"hg-cmd"
16792 "\">hg qpop <option role=\"hg-ext-mq-cmd-qpop-opt\">hg -a</option></command> "
16793 "and then <command role=\"hg-cmd\">hg qpush <option role=\"hg-ext-mq-cmd-qpush-"
16794 "opt\">hg -a</option></command> in the underlying repository to see those "
16795 "changes show up there. If you forget to do this, you can confuse MQ's idea "
16796 "of which patches are applied."
16797 msgstr ""
16799 #. type: Content of: <book><chapter><sect1><title>
16800 #: ../en/ch12-mq.xml:1151
16801 msgid "Third party tools for working with patches"
16802 msgstr "操作补丁的第三方工具"
16804 #. type: Content of: <book><chapter><sect1><para>
16805 #: ../en/ch12-mq.xml:1153
16806 msgid ""
16807 "Once you've been working with patches for a while, you'll find yourself "
16808 "hungry for tools that will help you to understand and manipulate the patches "
16809 "you're dealing with."
16810 msgstr ""
16812 #. type: Content of: <book><chapter><sect1><para>
16813 #: ../en/ch12-mq.xml:1157
16814 msgid ""
16815 "The <command>diffstat</command> command <citation>web:diffstat</citation> "
16816 "generates a histogram of the modifications made to each file in a patch. It "
16817 "provides a good way to <quote>get a sense of</quote> a patch&emdash;which "
16818 "files it affects, and how much change it introduces to each file and as a "
16819 "whole. (I find that it's a good idea to use <command>diffstat</command>'s "
16820 "<option role=\"cmd-opt-diffstat\">-p</option> option as a matter of course, "
16821 "as otherwise it will try to do clever things with prefixes of file names that "
16822 "inevitably confuse at least me.)"
16823 msgstr ""
16825 #. type: Content of: <book><chapter><sect1><para>
16826 #: ../en/ch12-mq.xml:1171
16827 msgid ""
16828 "The <literal role=\"package\">patchutils</literal> package <citation>web:"
16829 "patchutils</citation> is invaluable. It provides a set of small utilities "
16830 "that follow the <quote>Unix philosophy;</quote> each does one useful thing "
16831 "with a patch. The <literal role=\"package\">patchutils</literal> command I "
16832 "use most is <command>filterdiff</command>, which extracts subsets from a "
16833 "patch file. For example, given a patch that modifies hundreds of files "
16834 "across dozens of directories, a single invocation of <command>filterdiff</"
16835 "command> can generate a smaller patch that only touches files whose names "
16836 "match a particular glob pattern. See <xref linkend=\"mq-collab:tips:interdiff"
16837 "\"/> for another example."
16838 msgstr ""
16840 #. type: Content of: <book><chapter><sect1><title>
16841 #: ../en/ch12-mq.xml:1187
16842 msgid "Good ways to work with patches"
16843 msgstr "操作补丁的好习惯"
16845 #. type: Content of: <book><chapter><sect1><para>
16846 #: ../en/ch12-mq.xml:1189
16847 msgid ""
16848 "Whether you are working on a patch series to submit to a free software or "
16849 "open source project, or a series that you intend to treat as a sequence of "
16850 "regular changesets when you're done, you can use some simple techniques to "
16851 "keep your work well organized."
16852 msgstr ""
16854 #. type: Content of: <book><chapter><sect1><para>
16855 #: ../en/ch12-mq.xml:1195
16856 msgid ""
16857 "Give your patches descriptive names. A good name for a patch might be "
16858 "<filename>rework-device-alloc.patch</filename>, because it will immediately "
16859 "give you a hint what the purpose of the patch is. Long names shouldn't be a "
16860 "problem; you won't be typing the names often, but you <emphasis>will</"
16861 "emphasis> be running commands like <command role=\"hg-ext-mq\">qapplied</"
16862 "command> and <command role=\"hg-ext-mq\">qtop</command> over and over. Good "
16863 "naming becomes especially important when you have a number of patches to work "
16864 "with, or if you are juggling a number of different tasks and your patches "
16865 "only get a fraction of your attention."
16866 msgstr ""
16868 #. type: Content of: <book><chapter><sect1><para>
16869 #: ../en/ch12-mq.xml:1207
16870 msgid ""
16871 "Be aware of what patch you're working on. Use the <command role=\"hg-ext-mq"
16872 "\">qtop</command> command and skim over the text of your patches "
16873 "frequently&emdash;for example, using <command role=\"hg-cmd\">hg tip <option "
16874 "role=\"hg-opt-tip\">-p</option></command>)&emdash;to be sure of where you "
16875 "stand. I have several times worked on and <command role=\"hg-ext-mq"
16876 "\">qrefresh</command>ed a patch other than the one I intended, and it's often "
16877 "tricky to migrate changes into the right patch after making them in the wrong "
16878 "one."
16879 msgstr ""
16881 #. type: Content of: <book><chapter><sect1><para>
16882 #: ../en/ch12-mq.xml:1217
16883 msgid ""
16884 "For this reason, it is very much worth investing a little time to learn how "
16885 "to use some of the third-party tools I described in <xref linkend=\"sec:mq:"
16886 "tools\"/>, particularly <command>diffstat</command> and <command>filterdiff</"
16887 "command>. The former will give you a quick idea of what changes your patch "
16888 "is making, while the latter makes it easy to splice hunks selectively out of "
16889 "one patch and into another."
16890 msgstr ""
16892 #. type: Content of: <book><chapter><sect1><title>
16893 #: ../en/ch12-mq.xml:1228
16894 msgid "MQ cookbook"
16895 msgstr "MQ 手册"
16897 #. type: Content of: <book><chapter><sect1><sect2><title>
16898 #: ../en/ch12-mq.xml:1231
16899 msgid "Manage <quote>trivial</quote> patches"
16900 msgstr "管理<quote>琐碎的</quote>补丁"
16902 #. type: Content of: <book><chapter><sect1><sect2><para>
16903 #: ../en/ch12-mq.xml:1233
16904 msgid ""
16905 "Because the overhead of dropping files into a new Mercurial repository is so "
16906 "low, it makes a lot of sense to manage patches this way even if you simply "
16907 "want to make a few changes to a source tarball that you downloaded."
16908 msgstr ""
16911 #. type: Content of: <book><chapter><sect1><sect2><para>
16912 #: ../en/ch12-mq.xml:1238
16913 msgid ""
16914 "Begin by downloading and unpacking the source tarball, and turning it into a "
16915 "Mercurial repository."
16916 msgstr ""
16918 #. type: Content of: <book><chapter><sect1><sect2><para>
16919 #: ../en/ch12-mq.xml:1243
16920 msgid "Continue by creating a patch stack and making your changes."
16921 msgstr ""
16923 #. type: Content of: <book><chapter><sect1><sect2><para>
16924 #: ../en/ch12-mq.xml:1248
16925 msgid ""
16926 "Let's say a few weeks or months pass, and your package author releases a new "
16927 "version. First, bring their changes into the repository."
16928 msgstr ""
16930 #. type: Content of: <book><chapter><sect1><sect2><para>
16931 #: ../en/ch12-mq.xml:1254
16932 msgid ""
16933 "The pipeline starting with <command role=\"hg-cmd\">hg locate</command> above "
16934 "deletes all files in the working directory, so that <command role=\"hg-cmd"
16935 "\">hg commit</command>'s <option role=\"hg-opt-commit\">--addremove</option> "
16936 "option can actually tell which files have really been removed in the newer "
16937 "version of the source."
16938 msgstr ""
16940 #. type: Content of: <book><chapter><sect1><sect2><para>
16941 #: ../en/ch12-mq.xml:1262
16942 msgid "Finally, you can apply your patches on top of the new tree."
16943 msgstr ""
16945 #. type: Content of: <book><chapter><sect1><sect2><title>
16946 #: ../en/ch12-mq.xml:1269
16947 msgid "Combining entire patches"
16948 msgstr "组合全部的补丁"
16950 #. type: Content of: <book><chapter><sect1><sect2><para>
16951 #: ../en/ch12-mq.xml:1271
16952 msgid ""
16953 "MQ provides a command, <command role=\"hg-ext-mq\">qfold</command> that lets "
16954 "you combine entire patches. This <quote>folds</quote> the patches you name, "
16955 "in the order you name them, into the topmost applied patch, and concatenates "
16956 "their descriptions onto the end of its description. The patches that you "
16957 "fold must be unapplied before you fold them."
16958 msgstr ""
16960 #. type: Content of: <book><chapter><sect1><sect2><para>
16961 #: ../en/ch12-mq.xml:1279
16962 msgid ""
16963 "The order in which you fold patches matters. If your topmost applied patch "
16964 "is <literal>foo</literal>, and you <command role=\"hg-ext-mq\">qfold</"
16965 "command> <literal>bar</literal> and <literal>quux</literal> into it, you will "
16966 "end up with a patch that has the same effect as if you applied first "
16967 "<literal>foo</literal>, then <literal>bar</literal>, followed by "
16968 "<literal>quux</literal>."
16969 msgstr ""
16971 #. type: Content of: <book><chapter><sect1><sect2><title>
16972 #: ../en/ch12-mq.xml:1290
16973 msgid "Merging part of one patch into another"
16974 msgstr "合并补丁的部分内容到其它补丁"
16976 #. type: Content of: <book><chapter><sect1><sect2><para>
16977 #: ../en/ch12-mq.xml:1292
16978 msgid ""
16979 "Merging <emphasis>part</emphasis> of one patch into another is more difficult "
16980 "than combining entire patches."
16981 msgstr ""
16983 #. type: Content of: <book><chapter><sect1><sect2><para>
16984 #: ../en/ch12-mq.xml:1296
16985 msgid ""
16986 "If you want to move changes to entire files, you can use <command>filterdiff</"
16987 "command>'s <option role=\"cmd-opt-filterdiff\">-i</option> and <option role="
16988 "\"cmd-opt-filterdiff\">-x</option> options to choose the modifications to "
16989 "snip out of one patch, concatenating its output onto the end of the patch you "
16990 "want to merge into. You usually won't need to modify the patch you've merged "
16991 "the changes from. Instead, MQ will report some rejected hunks when you "
16992 "<command role=\"hg-ext-mq\">qpush</command> it (from the hunks you moved into "
16993 "the other patch), and you can simply <command role=\"hg-ext-mq\">qrefresh</"
16994 "command> the patch to drop the duplicate hunks."
16995 msgstr ""
16997 #. type: Content of: <book><chapter><sect1><sect2><para>
16998 #: ../en/ch12-mq.xml:1309
16999 msgid ""
17000 "If you have a patch that has multiple hunks modifying a file, and you only "
17001 "want to move a few of those hunks, the job becomes more messy, but you can "
17002 "still partly automate it. Use <command>lsdiff -nvv</command> to print some "
17003 "metadata about the patch."
17004 msgstr ""
17006 #. type: Content of: <book><chapter><sect1><sect2><para>
17007 #: ../en/ch12-mq.xml:1317
17008 msgid "This command prints three different kinds of number:"
17009 msgstr ""
17011 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
17012 #: ../en/ch12-mq.xml:1320
17013 msgid ""
17014 "(in the first column) a <emphasis>file number</emphasis> to identify each "
17015 "file modified in the patch;"
17016 msgstr ""
17018 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
17019 #: ../en/ch12-mq.xml:1324
17020 msgid ""
17021 "(on the next line, indented) the line number within a modified file where a "
17022 "hunk starts; and"
17023 msgstr ""
17025 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
17026 #: ../en/ch12-mq.xml:1327
17027 msgid ""
17028 "(on the same line) a <emphasis>hunk number</emphasis> to identify that hunk."
17029 msgstr ""
17031 #. type: Content of: <book><chapter><sect1><sect2><para>
17032 #: ../en/ch12-mq.xml:1331
17033 msgid ""
17034 "You'll have to use some visual inspection, and reading of the patch, to "
17035 "identify the file and hunk numbers you'll want, but you can then pass them to "
17036 "to <command>filterdiff</command>'s <option role=\"cmd-opt-filterdiff\">--"
17037 "files</option> and <option role=\"cmd-opt-filterdiff\">--hunks</option> "
17038 "options, to select exactly the file and hunk you want to extract."
17039 msgstr ""
17041 #. type: Content of: <book><chapter><sect1><sect2><para>
17042 #: ../en/ch12-mq.xml:1339
17043 msgid ""
17044 "Once you have this hunk, you can concatenate it onto the end of your "
17045 "destination patch and continue with the remainder of <xref linkend=\"sec:mq:"
17046 "combine\"/>."
17047 msgstr ""
17049 #. type: Content of: <book><chapter><sect1><title>
17050 #: ../en/ch12-mq.xml:1346
17051 msgid "Differences between quilt and MQ"
17052 msgstr "MQ 与 quilt 的区别"
17054 #. type: Content of: <book><chapter><sect1><para>
17055 #: ../en/ch12-mq.xml:1348
17056 msgid ""
17057 "If you are already familiar with quilt, MQ provides a similar command set. "
17058 "There are a few differences in the way that it works."
17059 msgstr ""
17061 #. type: Content of: <book><chapter><sect1><para>
17062 #: ../en/ch12-mq.xml:1352
17063 msgid ""
17064 "You will already have noticed that most quilt commands have MQ counterparts "
17065 "that simply begin with a <quote><literal>q</literal></quote>. The exceptions "
17066 "are quilt's <literal>add</literal> and <literal>remove</literal> commands, "
17067 "the counterparts for which are the normal Mercurial <command role=\"hg-cmd"
17068 "\">hg add</command> and <command role=\"hg-cmd\">hg remove</command> "
17069 "commands. There is no MQ equivalent of the quilt <literal>edit</literal> "
17070 "command."
17071 msgstr ""
17073 #. type: Content of: <book><chapter><title>
17074 #: ../en/ch13-mq-collab.xml:5
17075 msgid "Advanced uses of Mercurial Queues"
17076 msgstr "MQ 的高级用法"
17078 #. type: Content of: <book><chapter><para>
17079 #: ../en/ch13-mq-collab.xml:7
17080 msgid ""
17081 "While it's easy to pick up straightforward uses of Mercurial Queues, use of a "
17082 "little discipline and some of MQ's less frequently used capabilities makes it "
17083 "possible to work in complicated development environments."
17084 msgstr ""
17086 #. type: Content of: <book><chapter><para>
17087 #: ../en/ch13-mq-collab.xml:12
17088 msgid ""
17089 "In this chapter, I will use as an example a technique I have used to manage "
17090 "the development of an Infiniband device driver for the Linux kernel. The "
17091 "driver in question is large (at least as drivers go), with 25,000 lines of "
17092 "code spread across 35 source files. It is maintained by a small team of "
17093 "developers."
17094 msgstr ""
17096 #. type: Content of: <book><chapter><para>
17097 #: ../en/ch13-mq-collab.xml:18
17098 msgid ""
17099 "While much of the material in this chapter is specific to Linux, the same "
17100 "principles apply to any code base for which you're not the primary owner, and "
17101 "upon which you need to do a lot of development."
17102 msgstr ""
17104 #. type: Content of: <book><chapter><sect1><title>
17105 #: ../en/ch13-mq-collab.xml:24
17106 msgid "The problem of many targets"
17107 msgstr "多个目标的问题"
17109 #. type: Content of: <book><chapter><sect1><para>
17110 #: ../en/ch13-mq-collab.xml:26
17111 msgid ""
17112 "The Linux kernel changes rapidly, and has never been internally stable; "
17113 "developers frequently make drastic changes between releases. This means that "
17114 "a version of the driver that works well with a particular released version of "
17115 "the kernel will not even <emphasis>compile</emphasis> correctly against, "
17116 "typically, any other version."
17117 msgstr ""
17119 #. type: Content of: <book><chapter><sect1><para>
17120 #: ../en/ch13-mq-collab.xml:33
17121 msgid ""
17122 "To maintain a driver, we have to keep a number of distinct versions of Linux "
17123 "in mind."
17124 msgstr ""
17126 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17127 #: ../en/ch13-mq-collab.xml:36
17128 msgid ""
17129 "One target is the main Linux kernel development tree. Maintenance of the code "
17130 "is in this case partly shared by other developers in the kernel community, "
17131 "who make <quote>drive-by</quote> modifications to the driver as they develop "
17132 "and refine kernel subsystems."
17133 msgstr ""
17135 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17136 #: ../en/ch13-mq-collab.xml:42
17137 msgid ""
17138 "We also maintain a number of <quote>backports</quote> to older versions of "
17139 "the Linux kernel, to support the needs of customers who are running older "
17140 "Linux distributions that do not incorporate our drivers. (To "
17141 "<emphasis>backport</emphasis> a piece of code is to modify it to work in an "
17142 "older version of its target environment than the version it was developed "
17143 "for.)"
17144 msgstr ""
17146 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17147 #: ../en/ch13-mq-collab.xml:50
17148 msgid ""
17149 "Finally, we make software releases on a schedule that is necessarily not "
17150 "aligned with those used by Linux distributors and kernel developers, so that "
17151 "we can deliver new features to customers without forcing them to upgrade "
17152 "their entire kernels or distributions."
17153 msgstr ""
17155 #. type: Content of: <book><chapter><sect1><sect2><title>
17156 #: ../en/ch13-mq-collab.xml:58
17157 msgid "Tempting approaches that don't work well"
17158 msgstr "工作不好的诱人方法"
17160 #. type: Content of: <book><chapter><sect1><sect2><para>
17161 #: ../en/ch13-mq-collab.xml:60
17162 msgid ""
17163 "There are two <quote>standard</quote> ways to maintain a piece of software "
17164 "that has to target many different environments."
17165 msgstr ""
17167 #. type: Content of: <book><chapter><sect1><sect2><para>
17168 #: ../en/ch13-mq-collab.xml:64
17169 msgid ""
17170 "The first is to maintain a number of branches, each intended for a single "
17171 "target. The trouble with this approach is that you must maintain iron "
17172 "discipline in the flow of changes between repositories. A new feature or bug "
17173 "fix must start life in a <quote>pristine</quote> repository, then percolate "
17174 "out to every backport repository. Backport changes are more limited in the "
17175 "branches they should propagate to; a backport change that is applied to a "
17176 "branch where it doesn't belong will probably stop the driver from compiling."
17177 msgstr ""
17179 #. type: Content of: <book><chapter><sect1><sect2><para>
17180 #: ../en/ch13-mq-collab.xml:74
17181 msgid ""
17182 "The second is to maintain a single source tree filled with conditional "
17183 "statements that turn chunks of code on or off depending on the intended "
17184 "target. Because these <quote>ifdefs</quote> are not allowed in the Linux "
17185 "kernel tree, a manual or automatic process must be followed to strip them out "
17186 "and yield a clean tree. A code base maintained in this fashion rapidly "
17187 "becomes a rat's nest of conditional blocks that are difficult to understand "
17188 "and maintain."
17189 msgstr ""
17191 #. type: Content of: <book><chapter><sect1><sect2><para>
17192 #: ../en/ch13-mq-collab.xml:83
17193 msgid ""
17194 "Neither of these approaches is well suited to a situation where you don't "
17195 "<quote>own</quote> the canonical copy of a source tree. In the case of a "
17196 "Linux driver that is distributed with the standard kernel, Linus's tree "
17197 "contains the copy of the code that will be treated by the world as "
17198 "canonical. The upstream version of <quote>my</quote> driver can be modified "
17199 "by people I don't know, without me even finding out about it until after the "
17200 "changes show up in Linus's tree."
17201 msgstr ""
17203 #. type: Content of: <book><chapter><sect1><sect2><para>
17204 #: ../en/ch13-mq-collab.xml:93
17205 msgid ""
17206 "These approaches have the added weakness of making it difficult to generate "
17207 "well-formed patches to submit upstream."
17208 msgstr ""
17210 #. type: Content of: <book><chapter><sect1><sect2><para>
17211 #: ../en/ch13-mq-collab.xml:97
17212 msgid ""
17213 "In principle, Mercurial Queues seems like a good candidate to manage a "
17214 "development scenario such as the above. While this is indeed the case, MQ "
17215 "contains a few added features that make the job more pleasant."
17216 msgstr ""
17218 #. type: Content of: <book><chapter><sect1><title>
17219 #: ../en/ch13-mq-collab.xml:105
17220 msgid "Conditionally applying patches with guards"
17221 msgstr "有条件的应用补丁"
17223 #. type: Content of: <book><chapter><sect1><para>
17224 #: ../en/ch13-mq-collab.xml:107
17225 msgid ""
17226 "Perhaps the best way to maintain sanity with so many targets is to be able to "
17227 "choose specific patches to apply for a given situation. MQ provides a "
17228 "feature called <quote>guards</quote> (which originates with quilt's "
17229 "<literal>guards</literal> command) that does just this. To start off, let's "
17230 "create a simple repository for experimenting in."
17231 msgstr ""
17233 #. type: Content of: <book><chapter><sect1><para>
17234 #: ../en/ch13-mq-collab.xml:116
17235 msgid ""
17236 "This gives us a tiny repository that contains two patches that don't have any "
17237 "dependencies on each other, because they touch different files."
17238 msgstr ""
17240 #. type: Content of: <book><chapter><sect1><para>
17241 #: ../en/ch13-mq-collab.xml:120
17242 msgid ""
17243 "The idea behind conditional application is that you can <quote>tag</quote> a "
17244 "patch with a <emphasis>guard</emphasis>, which is simply a text string of "
17245 "your choosing, then tell MQ to select specific guards to use when applying "
17246 "patches. MQ will then either apply, or skip over, a guarded patch, depending "
17247 "on the guards that you have selected."
17248 msgstr ""
17250 #. type: Content of: <book><chapter><sect1><para>
17251 #: ../en/ch13-mq-collab.xml:127
17252 msgid ""
17253 "A patch can have an arbitrary number of guards; each one is "
17254 "<emphasis>positive</emphasis> (<quote>apply this patch if this guard is "
17255 "selected</quote>) or <emphasis>negative</emphasis> (<quote>skip this patch if "
17256 "this guard is selected</quote>). A patch with no guards is always applied."
17257 msgstr ""
17259 #. type: Content of: <book><chapter><sect1><title>
17260 #: ../en/ch13-mq-collab.xml:135
17261 msgid "Controlling the guards on a patch"
17262 msgstr "控制补丁的应用条件"
17264 #. type: Content of: <book><chapter><sect1><para>
17265 #: ../en/ch13-mq-collab.xml:137
17266 msgid ""
17267 "The <command role=\"hg-ext-mq\">qguard</command> command lets you determine "
17268 "which guards should apply to a patch, or display the guards that are already "
17269 "in effect. Without any arguments, it displays the guards on the current "
17270 "topmost patch."
17271 msgstr ""
17273 #. type: Content of: <book><chapter><sect1><para>
17274 #: ../en/ch13-mq-collab.xml:144
17275 msgid ""
17276 "To set a positive guard on a patch, prefix the name of the guard with a "
17277 "<quote><literal>+</literal></quote>."
17278 msgstr ""
17280 #. type: Content of: <book><chapter><sect1><para>
17281 #: ../en/ch13-mq-collab.xml:149
17282 msgid ""
17283 "To set a negative guard on a patch, prefix the name of the guard with a "
17284 "<quote><literal>-</literal></quote>."
17285 msgstr ""
17287 #. type: Content of: <book><chapter><sect1><para>
17288 #: ../en/ch13-mq-collab.xml:155
17289 msgid ""
17290 "Notice that we prefixed the arguments to the <command>hg qguard</command> "
17291 "command with a <literal>--</literal> here, so that Mercurial would not "
17292 "interpret the text <literal>-quux</literal> as an option."
17293 msgstr ""
17295 #. type: Content of: <book><chapter><sect1><note><title>
17296 #: ../en/ch13-mq-collab.xml:161
17297 msgid "Setting vs. modifying"
17298 msgstr ""
17300 #. type: Content of: <book><chapter><sect1><note><para>
17301 #: ../en/ch13-mq-collab.xml:163
17302 msgid ""
17303 "The <command role=\"hg-ext-mq\">qguard</command> command <emphasis>sets</"
17304 "emphasis> the guards on a patch; it doesn't <emphasis>modify</emphasis> "
17305 "them. What this means is that if you run <command role=\"hg-cmd\">hg qguard "
17306 "+a +b</command> on a patch, then <command role=\"hg-cmd\">hg qguard +c</"
17307 "command> on the same patch, the <emphasis>only</emphasis> guard that will be "
17308 "set on it afterwards is <literal>+c</literal>."
17309 msgstr ""
17312 #. type: Content of: <book><chapter><sect1><para>
17313 #: ../en/ch13-mq-collab.xml:172
17314 msgid ""
17315 "Mercurial stores guards in the <filename role=\"special\">series</filename> "
17316 "file; the form in which they are stored is easy both to understand and to "
17317 "edit by hand. (In other words, you don't have to use the <command role=\"hg-"
17318 "ext-mq\">qguard</command> command if you don't want to; it's okay to simply "
17319 "edit the <filename role=\"special\">series</filename> file.)"
17320 msgstr ""
17322 #. type: Content of: <book><chapter><sect1><title>
17323 #: ../en/ch13-mq-collab.xml:184
17324 msgid "Selecting the guards to use"
17325 msgstr "选择使用的条件"
17327 #. type: Content of: <book><chapter><sect1><para>
17328 #: ../en/ch13-mq-collab.xml:186
17329 msgid ""
17330 "The <command role=\"hg-ext-mq\">qselect</command> command determines which "
17331 "guards are active at a given time. The effect of this is to determine which "
17332 "patches MQ will apply the next time you run <command role=\"hg-ext-mq"
17333 "\">qpush</command>. It has no other effect; in particular, it doesn't do "
17334 "anything to patches that are already applied."
17335 msgstr ""
17337 #. type: Content of: <book><chapter><sect1><para>
17338 #: ../en/ch13-mq-collab.xml:193
17339 msgid ""
17340 "With no arguments, the <command role=\"hg-ext-mq\">qselect</command> command "
17341 "lists the guards currently in effect, one per line of output. Each argument "
17342 "is treated as the name of a guard to apply."
17343 msgstr ""
17345 #. type: Content of: <book><chapter><sect1><para>
17346 #: ../en/ch13-mq-collab.xml:200
17347 msgid ""
17348 "In case you're interested, the currently selected guards are stored in the "
17349 "<filename role=\"special\">guards</filename> file."
17350 msgstr ""
17352 #. type: Content of: <book><chapter><sect1><para>
17353 #: ../en/ch13-mq-collab.xml:205
17354 msgid ""
17355 "We can see the effect the selected guards have when we run <command role=\"hg-"
17356 "ext-mq\">qpush</command>."
17357 msgstr ""
17359 #. type: Content of: <book><chapter><sect1><para>
17360 #: ../en/ch13-mq-collab.xml:210
17361 msgid ""
17362 "A guard cannot start with a <quote><literal>+</literal></quote> or "
17363 "<quote><literal>-</literal></quote> character. The name of a guard must not "
17364 "contain white space, but most other characters are acceptable. If you try to "
17365 "use a guard with an invalid name, MQ will complain:"
17366 msgstr ""
17368 #. type: Content of: <book><chapter><sect1><para>
17369 #: ../en/ch13-mq-collab.xml:219
17370 msgid "Changing the selected guards changes the patches that are applied."
17371 msgstr ""
17373 #. type: Content of: <book><chapter><sect1><para>
17374 #: ../en/ch13-mq-collab.xml:224
17375 msgid ""
17376 "You can see in the example below that negative guards take precedence over "
17377 "positive guards."
17378 msgstr ""
17380 #. type: Content of: <book><chapter><sect1><title>
17381 #: ../en/ch13-mq-collab.xml:231
17382 msgid "MQ's rules for applying patches"
17383 msgstr "MQ 应用补丁的规则"
17385 #. type: Content of: <book><chapter><sect1><para>
17386 #: ../en/ch13-mq-collab.xml:233
17387 msgid ""
17388 "The rules that MQ uses when deciding whether to apply a patch are as follows."
17389 msgstr ""
17391 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17392 #: ../en/ch13-mq-collab.xml:236
17393 msgid "A patch that has no guards is always applied."
17394 msgstr ""
17396 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17397 #: ../en/ch13-mq-collab.xml:239
17398 msgid ""
17399 "If the patch has any negative guard that matches any currently selected "
17400 "guard, the patch is skipped."
17401 msgstr ""
17403 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17404 #: ../en/ch13-mq-collab.xml:242
17405 msgid ""
17406 "If the patch has any positive guard that matches any currently selected "
17407 "guard, the patch is applied."
17408 msgstr ""
17410 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17411 #: ../en/ch13-mq-collab.xml:245
17412 msgid ""
17413 "If the patch has positive or negative guards, but none matches any currently "
17414 "selected guard, the patch is skipped."
17415 msgstr ""
17417 #. type: Content of: <book><chapter><sect1><title>
17418 #: ../en/ch13-mq-collab.xml:252
17419 msgid "Trimming the work environment"
17420 msgstr "修剪工作环境"
17422 #. type: Content of: <book><chapter><sect1><para>
17423 #: ../en/ch13-mq-collab.xml:254
17424 msgid ""
17425 "In working on the device driver I mentioned earlier, I don't apply the "
17426 "patches to a normal Linux kernel tree. Instead, I use a repository that "
17427 "contains only a snapshot of the source files and headers that are relevant to "
17428 "Infiniband development. This repository is 1% the size of a kernel "
17429 "repository, so it's easier to work with."
17430 msgstr ""
17432 #. type: Content of: <book><chapter><sect1><para>
17433 #: ../en/ch13-mq-collab.xml:261
17434 msgid ""
17435 "I then choose a <quote>base</quote> version on top of which the patches are "
17436 "applied. This is a snapshot of the Linux kernel tree as of a revision of my "
17437 "choosing. When I take the snapshot, I record the changeset ID from the "
17438 "kernel repository in the commit message. Since the snapshot preserves the "
17439 "<quote>shape</quote> and content of the relevant parts of the kernel tree, I "
17440 "can apply my patches on top of either my tiny repository or a normal kernel "
17441 "tree."
17442 msgstr ""
17444 #. type: Content of: <book><chapter><sect1><para>
17445 #: ../en/ch13-mq-collab.xml:270
17446 msgid ""
17447 "Normally, the base tree atop which the patches apply should be a snapshot of "
17448 "a very recent upstream tree. This best facilitates the development of "
17449 "patches that can easily be submitted upstream with few or no modifications."
17450 msgstr ""
17452 #. type: Content of: <book><chapter><sect1><title>
17453 #: ../en/ch13-mq-collab.xml:277
17454 msgid "Dividing up the <filename role=\"special\">series</filename> file"
17455 msgstr "分类补丁<filename role=\"special\">系列</filename>"
17457 #. type: Content of: <book><chapter><sect1><para>
17458 #: ../en/ch13-mq-collab.xml:280
17459 msgid ""
17460 "I categorise the patches in the <filename role=\"special\">series</filename> "
17461 "file into a number of logical groups. Each section of like patches begins "
17462 "with a block of comments that describes the purpose of the patches that "
17463 "follow."
17464 msgstr ""
17466 #. type: Content of: <book><chapter><sect1><para>
17467 #: ../en/ch13-mq-collab.xml:286
17468 msgid ""
17469 "The sequence of patch groups that I maintain follows. The ordering of these "
17470 "groups is important; I'll describe why after I introduce the groups."
17471 msgstr ""
17473 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17474 #: ../en/ch13-mq-collab.xml:290
17475 msgid ""
17476 "The <quote>accepted</quote> group. Patches that the development team has "
17477 "submitted to the maintainer of the Infiniband subsystem, and which he has "
17478 "accepted, but which are not present in the snapshot that the tiny repository "
17479 "is based on. These are <quote>read only</quote> patches, present only to "
17480 "transform the tree into a similar state as it is in the upstream maintainer's "
17481 "repository."
17482 msgstr ""
17484 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17485 #: ../en/ch13-mq-collab.xml:298
17486 msgid ""
17487 "The <quote>rework</quote> group. Patches that I have submitted, but that the "
17488 "upstream maintainer has requested modifications to before he will accept them."
17489 msgstr ""
17491 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17492 #: ../en/ch13-mq-collab.xml:303
17493 msgid ""
17494 "The <quote>pending</quote> group. Patches that I have not yet submitted to "
17495 "the upstream maintainer, but which we have finished working on. These will be "
17496 "<quote>read only</quote> for a while. If the upstream maintainer accepts "
17497 "them upon submission, I'll move them to the end of the <quote>accepted</"
17498 "quote> group. If he requests that I modify any, I'll move them to the "
17499 "beginning of the <quote>rework</quote> group."
17500 msgstr ""
17502 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17503 #: ../en/ch13-mq-collab.xml:312
17504 msgid ""
17505 "The <quote>in progress</quote> group. Patches that are actively being "
17506 "developed, and should not be submitted anywhere yet."
17507 msgstr ""
17509 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17510 #: ../en/ch13-mq-collab.xml:316
17511 msgid ""
17512 "The <quote>backport</quote> group. Patches that adapt the source tree to "
17513 "older versions of the kernel tree."
17514 msgstr ""
17516 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17517 #: ../en/ch13-mq-collab.xml:320
17518 msgid ""
17519 "The <quote>do not ship</quote> group. Patches that for some reason should "
17520 "never be submitted upstream. For example, one such patch might change "
17521 "embedded driver identification strings to make it easier to distinguish, in "
17522 "the field, between an out-of-tree version of the driver and a version shipped "
17523 "by a distribution vendor."
17524 msgstr ""
17526 #. type: Content of: <book><chapter><sect1><para>
17527 #: ../en/ch13-mq-collab.xml:328
17528 msgid ""
17529 "Now to return to the reasons for ordering groups of patches in this way. We "
17530 "would like the lowest patches in the stack to be as stable as possible, so "
17531 "that we will not need to rework higher patches due to changes in context. "
17532 "Putting patches that will never be changed first in the <filename role="
17533 "\"special\">series</filename> file serves this purpose."
17534 msgstr ""
17536 #. type: Content of: <book><chapter><sect1><para>
17537 #: ../en/ch13-mq-collab.xml:336
17538 msgid ""
17539 "We would also like the patches that we know we'll need to modify to be "
17540 "applied on top of a source tree that resembles the upstream tree as closely "
17541 "as possible. This is why we keep accepted patches around for a while."
17542 msgstr ""
17544 #. type: Content of: <book><chapter><sect1><para>
17545 #: ../en/ch13-mq-collab.xml:341
17546 msgid ""
17547 "The <quote>backport</quote> and <quote>do not ship</quote> patches float at "
17548 "the end of the <filename role=\"special\">series</filename> file. The "
17549 "backport patches must be applied on top of all other patches, and the "
17550 "<quote>do not ship</quote> patches might as well stay out of harm's way."
17551 msgstr ""
17553 #. type: Content of: <book><chapter><sect1><title>
17554 #: ../en/ch13-mq-collab.xml:350
17555 msgid "Maintaining the patch series"
17556 msgstr "维护补丁系列"
17558 #. type: Content of: <book><chapter><sect1><para>
17559 #: ../en/ch13-mq-collab.xml:352
17560 msgid ""
17561 "In my work, I use a number of guards to control which patches are to be "
17562 "applied."
17563 msgstr ""
17565 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17566 #: ../en/ch13-mq-collab.xml:356
17567 msgid ""
17568 "<quote>Accepted</quote> patches are guarded with <literal>accepted</"
17569 "literal>. I enable this guard most of the time. When I'm applying the "
17570 "patches on top of a tree where the patches are already present, I can turn "
17571 "this patch off, and the patches that follow it will apply cleanly."
17572 msgstr ""
17574 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17575 #: ../en/ch13-mq-collab.xml:363
17576 msgid ""
17577 "Patches that are <quote>finished</quote>, but not yet submitted, have no "
17578 "guards. If I'm applying the patch stack to a copy of the upstream tree, I "
17579 "don't need to enable any guards in order to get a reasonably safe source tree."
17580 msgstr ""
17582 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17583 #: ../en/ch13-mq-collab.xml:369
17584 msgid ""
17585 "Those patches that need reworking before being resubmitted are guarded with "
17586 "<literal>rework</literal>."
17587 msgstr ""
17589 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17590 #: ../en/ch13-mq-collab.xml:373
17591 msgid ""
17592 "For those patches that are still under development, I use <literal>devel</"
17593 "literal>."
17594 msgstr ""
17596 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17597 #: ../en/ch13-mq-collab.xml:376
17598 msgid ""
17599 "A backport patch may have several guards, one for each version of the kernel "
17600 "to which it applies. For example, a patch that backports a piece of code to "
17601 "2.6.9 will have a <literal>2.6.9</literal> guard."
17602 msgstr ""
17604 #. type: Content of: <book><chapter><sect1><para>
17605 #: ../en/ch13-mq-collab.xml:381
17606 msgid ""
17607 "This variety of guards gives me considerable flexibility in determining what "
17608 "kind of source tree I want to end up with. For most situations, the "
17609 "selection of appropriate guards is automated during the build process, but I "
17610 "can manually tune the guards to use for less common circumstances."
17611 msgstr ""
17613 #. type: Content of: <book><chapter><sect1><sect2><title>
17614 #: ../en/ch13-mq-collab.xml:388
17615 msgid "The art of writing backport patches"
17616 msgstr "编写向后移植补丁的艺术"
17618 #. type: Content of: <book><chapter><sect1><sect2><para>
17619 #: ../en/ch13-mq-collab.xml:390
17620 msgid ""
17621 "Using MQ, writing a backport patch is a simple process. All such a patch has "
17622 "to do is modify a piece of code that uses a kernel feature not present in the "
17623 "older version of the kernel, so that the driver continues to work correctly "
17624 "under that older version."
17625 msgstr ""
17627 #. type: Content of: <book><chapter><sect1><sect2><para>
17628 #: ../en/ch13-mq-collab.xml:396
17629 msgid ""
17630 "A useful goal when writing a good backport patch is to make your code look as "
17631 "if it was written for the older version of the kernel you're targeting. The "
17632 "less obtrusive the patch, the easier it will be to understand and maintain. "
17633 "If you're writing a collection of backport patches to avoid the <quote>rat's "
17634 "nest</quote> effect of lots of <literal>#ifdef</literal>s (hunks of source "
17635 "code that are only used conditionally) in your code, don't introduce version-"
17636 "dependent <literal>#ifdef</literal>s into the patches. Instead, write "
17637 "several patches, each of which makes unconditional changes, and control their "
17638 "application using guards."
17639 msgstr ""
17641 #. type: Content of: <book><chapter><sect1><sect2><para>
17642 #: ../en/ch13-mq-collab.xml:409
17643 msgid ""
17644 "There are two reasons to divide backport patches into a distinct group, away "
17645 "from the <quote>regular</quote> patches whose effects they modify. The first "
17646 "is that intermingling the two makes it more difficult to use a tool like the "
17647 "<literal role=\"hg-ext\">patchbomb</literal> extension to automate the "
17648 "process of submitting the patches to an upstream maintainer. The second is "
17649 "that a backport patch could perturb the context in which a subsequent regular "
17650 "patch is applied, making it impossible to apply the regular patch cleanly "
17651 "<emphasis>without</emphasis> the earlier backport patch already being applied."
17652 msgstr ""
17654 #. type: Content of: <book><chapter><sect1><title>
17655 #: ../en/ch13-mq-collab.xml:424
17656 msgid "Useful tips for developing with MQ"
17657 msgstr "使用 MQ 开发的技巧"
17659 #. type: Content of: <book><chapter><sect1><sect2><title>
17660 #: ../en/ch13-mq-collab.xml:427
17661 msgid "Organising patches in directories"
17662 msgstr "将补丁放到几个目录中"
17664 #. type: Content of: <book><chapter><sect1><sect2><para>
17665 #: ../en/ch13-mq-collab.xml:429
17666 msgid ""
17667 "If you're working on a substantial project with MQ, it's not difficult to "
17668 "accumulate a large number of patches. For example, I have one patch "
17669 "repository that contains over 250 patches."
17670 msgstr ""
17672 #. type: Content of: <book><chapter><sect1><sect2><para>
17673 #: ../en/ch13-mq-collab.xml:434
17674 msgid ""
17675 "If you can group these patches into separate logical categories, you can if "
17676 "you like store them in different directories; MQ has no problems with patch "
17677 "names that contain path separators."
17678 msgstr ""
17680 #. type: Content of: <book><chapter><sect1><sect2><title>
17681 #: ../en/ch13-mq-collab.xml:441
17682 msgid "Viewing the history of a patch"
17683 msgstr "察看补丁的历史"
17685 #. type: Content of: <book><chapter><sect1><sect2><para>
17686 #: ../en/ch13-mq-collab.xml:443
17687 msgid ""
17688 "If you're developing a set of patches over a long time, it's a good idea to "
17689 "maintain them in a repository, as discussed in <xref linkend=\"sec:mq:repo\"/"
17690 ">. If you do so, you'll quickly discover that using the <command role=\"hg-"
17691 "cmd\">hg diff</command> command to look at the history of changes to a patch "
17692 "is unworkable. This is in part because you're looking at the second "
17693 "derivative of the real code (a diff of a diff), but also because MQ adds "
17694 "noise to the process by modifying time stamps and directory names when it "
17695 "updates a patch."
17696 msgstr ""
17698 #. type: Content of: <book><chapter><sect1><sect2><para>
17699 #: ../en/ch13-mq-collab.xml:455
17700 msgid ""
17701 "However, you can use the <literal role=\"hg-ext\">extdiff</literal> "
17702 "extension, which is bundled with Mercurial, to turn a diff of two versions of "
17703 "a patch into something readable. To do this, you will need a third-party "
17704 "package called <literal role=\"package\">patchutils</literal> <citation>web:"
17705 "patchutils</citation>. This provides a command named <command>interdiff</"
17706 "command>, which shows the differences between two diffs as a diff. Used on "
17707 "two versions of the same diff, it generates a diff that represents the diff "
17708 "from the first to the second version."
17709 msgstr ""
17711 #. type: Content of: <book><chapter><sect1><sect2><para>
17712 #: ../en/ch13-mq-collab.xml:466
17713 msgid ""
17714 "You can enable the <literal role=\"hg-ext\">extdiff</literal> extension in "
17715 "the usual way, by adding a line to the <literal role=\"rc-extensions"
17716 "\">extensions</literal> section of your <filename role=\"special\">~/.hgrc</"
17717 "filename>."
17718 msgstr ""
17721 #. &example.hg-interdiff;
17722 #. type: Content of: <book><chapter><sect1><sect2><para>
17723 #: ../en/ch13-mq-collab.xml:473
17724 msgid ""
17725 "The <command>interdiff</command> command expects to be passed the names of "
17726 "two files, but the <literal role=\"hg-ext\">extdiff</literal> extension "
17727 "passes the program it runs a pair of directories, each of which can contain "
17728 "an arbitrary number of files. We thus need a small program that will run "
17729 "<command>interdiff</command> on each pair of files in these two directories. "
17730 "This program is available as <filename role=\"special\">hg-interdiff</"
17731 "filename> in the <filename class=\"directory\">examples</filename> directory "
17732 "of the source code repository that accompanies this book."
17733 msgstr ""
17735 #. type: Content of: <book><chapter><sect1><sect2><para>
17736 #: ../en/ch13-mq-collab.xml:485
17737 msgid ""
17738 "With the <filename role=\"special\">hg-interdiff</filename> program in your "
17739 "shell's search path, you can run it as follows, from inside an MQ patch "
17740 "directory:"
17741 msgstr ""
17743 #. type: Content of: <book><chapter><sect1><sect2><para>
17744 #: ../en/ch13-mq-collab.xml:489
17745 msgid ""
17746 "Since you'll probably want to use this long-winded command a lot, you can get "
17747 "<literal role=\"hg-ext\">hgext</literal> to make it available as a normal "
17748 "Mercurial command, again by editing your <filename role=\"special\">~/.hgrc</"
17749 "filename>."
17750 msgstr ""
17752 #. type: Content of: <book><chapter><sect1><sect2><para>
17753 #: ../en/ch13-mq-collab.xml:496
17754 msgid ""
17755 "This directs <literal role=\"hg-ext\">hgext</literal> to make an "
17756 "<literal>interdiff</literal> command available, so you can now shorten the "
17757 "previous invocation of <command role=\"hg-ext-extdiff\">extdiff</command> to "
17758 "something a little more wieldy."
17759 msgstr ""
17761 #. type: Content of: <book><chapter><sect1><sect2><note><para>
17762 #: ../en/ch13-mq-collab.xml:504
17763 msgid ""
17764 "The <command>interdiff</command> command works well only if the underlying "
17765 "files against which versions of a patch are generated remain the same. If "
17766 "you create a patch, modify the underlying files, and then regenerate the "
17767 "patch, <command>interdiff</command> may not produce useful output."
17768 msgstr ""
17770 #. type: Content of: <book><chapter><sect1><sect2><para>
17771 #: ../en/ch13-mq-collab.xml:512
17772 msgid ""
17773 "The <literal role=\"hg-ext\">extdiff</literal> extension is useful for more "
17774 "than merely improving the presentation of MQ patches. To read more about it, "
17775 "go to <xref linkend=\"sec:hgext:extdiff\"/>."
17776 msgstr ""
17778 #. type: Content of: <book><chapter><title>
17779 #: ../en/ch14-hgext.xml:5
17780 msgid "Adding functionality with extensions"
17781 msgstr "使用扩展增加功能"
17783 #. type: Content of: <book><chapter><para>
17784 #: ../en/ch14-hgext.xml:7
17785 msgid ""
17786 "While the core of Mercurial is quite complete from a functionality "
17787 "standpoint, it's deliberately shorn of fancy features. This approach of "
17788 "preserving simplicity keeps the software easy to deal with for both "
17789 "maintainers and users."
17790 msgstr ""
17792 #. type: Content of: <book><chapter><para>
17793 #: ../en/ch14-hgext.xml:12
17794 msgid ""
17795 "However, Mercurial doesn't box you in with an inflexible command set: you can "
17796 "add features to it as <emphasis>extensions</emphasis> (sometimes known as "
17797 "<emphasis>plugins</emphasis>). We've already discussed a few of these "
17798 "extensions in earlier chapters."
17799 msgstr ""
17801 #. type: Content of: <book><chapter><itemizedlist><listitem><para>
17802 #: ../en/ch14-hgext.xml:18
17803 msgid ""
17804 "<xref linkend=\"sec:tour-merge:fetch\"/> covers the <literal role=\"hg-ext"
17805 "\">fetch</literal> extension; this combines pulling new changes and merging "
17806 "them with local changes into a single command, <command role=\"hg-ext-fetch"
17807 "\">fetch</command>."
17808 msgstr ""
17810 #. type: Content of: <book><chapter><itemizedlist><listitem><para>
17811 #: ../en/ch14-hgext.xml:24
17812 msgid ""
17813 "In <xref linkend=\"chap:hook\"/>, we covered several extensions that are "
17814 "useful for hook-related functionality: <literal role=\"hg-ext\">acl</literal> "
17815 "adds access control lists; <literal role=\"hg-ext\">bugzilla</literal> adds "
17816 "integration with the Bugzilla bug tracking system; and <literal role=\"hg-ext"
17817 "\">notify</literal> sends notification emails on new changes."
17818 msgstr ""
17820 #. type: Content of: <book><chapter><itemizedlist><listitem><para>
17821 #: ../en/ch14-hgext.xml:33
17822 msgid ""
17823 "The Mercurial Queues patch management extension is so invaluable that it "
17824 "merits two chapters and an appendix all to itself. <xref linkend=\"chap:mq\"/"
17825 "> covers the basics; <xref linkend=\"chap:mq-collab\"/> discusses advanced "
17826 "topics; and <xref linkend=\"chap:mqref\"/> goes into detail on each command."
17827 msgstr ""
17829 #. type: Content of: <book><chapter><para>
17830 #: ../en/ch14-hgext.xml:43
17831 msgid ""
17832 "In this chapter, we'll cover some of the other extensions that are available "
17833 "for Mercurial, and briefly touch on some of the machinery you'll need to know "
17834 "about if you want to write an extension of your own."
17835 msgstr ""
17837 #. type: Content of: <book><chapter><itemizedlist><listitem><para>
17838 #: ../en/ch14-hgext.xml:48
17839 msgid ""
17840 "In <xref linkend=\"sec:hgext:inotify\"/>, we'll discuss the possibility of "
17841 "<emphasis>huge</emphasis> performance improvements using the <literal role="
17842 "\"hg-ext\">inotify</literal> extension."
17843 msgstr ""
17845 #. type: Content of: <book><chapter><sect1><title>
17846 #: ../en/ch14-hgext.xml:55
17847 msgid ""
17848 "Improve performance with the <literal role=\"hg-ext\">inotify</literal> "
17849 "extension"
17850 msgstr "使用扩展 <literal role=\"hg-ext\">inotify</literal> 以提高性能"
17852 #. type: Content of: <book><chapter><sect1><para>
17853 #: ../en/ch14-hgext.xml:58
17854 msgid ""
17855 "Are you interested in having some of the most common Mercurial operations run "
17856 "as much as a hundred times faster? Read on!"
17857 msgstr ""
17859 #. type: Content of: <book><chapter><sect1><para>
17860 #: ../en/ch14-hgext.xml:62
17861 msgid ""
17862 "Mercurial has great performance under normal circumstances. For example, "
17863 "when you run the <command role=\"hg-cmd\">hg status</command> command, "
17864 "Mercurial has to scan almost every directory and file in your repository so "
17865 "that it can display file status. Many other Mercurial commands need to do "
17866 "the same work behind the scenes; for example, the <command role=\"hg-cmd\">hg "
17867 "diff</command> command uses the status machinery to avoid doing an expensive "
17868 "comparison operation on files that obviously haven't changed."
17869 msgstr ""
17871 #. type: Content of: <book><chapter><sect1><para>
17872 #: ../en/ch14-hgext.xml:72
17873 msgid ""
17874 "Because obtaining file status is crucial to good performance, the authors of "
17875 "Mercurial have optimised this code to within an inch of its life. However, "
17876 "there's no avoiding the fact that when you run <command role=\"hg-cmd\">hg "
17877 "status</command>, Mercurial is going to have to perform at least one "
17878 "expensive system call for each managed file to determine whether it's changed "
17879 "since the last time Mercurial checked. For a sufficiently large repository, "
17880 "this can take a long time."
17881 msgstr ""
17883 #. type: Content of: <book><chapter><sect1><para>
17884 #: ../en/ch14-hgext.xml:82
17885 msgid ""
17886 "To put a number on the magnitude of this effect, I created a repository "
17887 "containing 150,000 managed files. I timed <command role=\"hg-cmd\">hg "
17888 "status</command> as taking ten seconds to run, even when <emphasis>none</"
17889 "emphasis> of those files had been modified."
17890 msgstr ""
17892 #. type: Content of: <book><chapter><sect1><para>
17893 #: ../en/ch14-hgext.xml:88
17894 msgid ""
17895 "Many modern operating systems contain a file notification facility. If a "
17896 "program signs up to an appropriate service, the operating system will notify "
17897 "it every time a file of interest is created, modified, or deleted. On Linux "
17898 "systems, the kernel component that does this is called <literal>inotify</"
17899 "literal>."
17900 msgstr ""
17902 #. type: Content of: <book><chapter><sect1><para>
17903 #: ../en/ch14-hgext.xml:95
17904 msgid ""
17905 "Mercurial's <literal role=\"hg-ext\">inotify</literal> extension talks to the "
17906 "kernel's <literal>inotify</literal> component to optimise <command role=\"hg-"
17907 "cmd\">hg status</command> commands. The extension has two components. A "
17908 "daemon sits in the background and receives notifications from the "
17909 "<literal>inotify</literal> subsystem. It also listens for connections from a "
17910 "regular Mercurial command. The extension modifies Mercurial's behavior so "
17911 "that instead of scanning the filesystem, it queries the daemon. Since the "
17912 "daemon has perfect information about the state of the repository, it can "
17913 "respond with a result instantaneously, avoiding the need to scan every "
17914 "directory and file in the repository."
17915 msgstr ""
17917 #. type: Content of: <book><chapter><sect1><para>
17918 #: ../en/ch14-hgext.xml:108
17919 msgid ""
17920 "Recall the ten seconds that I measured plain Mercurial as taking to run "
17921 "<command role=\"hg-cmd\">hg status</command> on a 150,000 file repository. "
17922 "With the <literal role=\"hg-ext\">inotify</literal> extension enabled, the "
17923 "time dropped to 0.1 seconds, a factor of <emphasis>one hundred</emphasis> "
17924 "faster."
17925 msgstr ""
17927 #. type: Content of: <book><chapter><sect1><para>
17928 #: ../en/ch14-hgext.xml:115
17929 msgid "Before we continue, please pay attention to some caveats."
17930 msgstr ""
17932 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17933 #: ../en/ch14-hgext.xml:118
17934 msgid ""
17935 "The <literal role=\"hg-ext\">inotify</literal> extension is Linux-specific. "
17936 "Because it interfaces directly to the Linux kernel's <literal>inotify</"
17937 "literal> subsystem, it does not work on other operating systems."
17938 msgstr ""
17940 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17941 #: ../en/ch14-hgext.xml:123
17942 msgid ""
17943 "It should work on any Linux distribution that was released after early 2005. "
17944 "Older distributions are likely to have a kernel that lacks <literal>inotify</"
17945 "literal>, or a version of <literal>glibc</literal> that does not have the "
17946 "necessary interfacing support."
17947 msgstr ""
17949 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
17950 #: ../en/ch14-hgext.xml:130
17951 msgid ""
17952 "Not all filesystems are suitable for use with the <literal role=\"hg-ext"
17953 "\">inotify</literal> extension. Network filesystems such as NFS are a non-"
17954 "starter, for example, particularly if you're running Mercurial on several "
17955 "systems, all mounting the same network filesystem. The kernel's "
17956 "<literal>inotify</literal> system has no way of knowing about changes made on "
17957 "another system. Most local filesystems (e.g. ext3, XFS, ReiserFS) should "
17958 "work fine."
17959 msgstr ""
17961 #. type: Content of: <book><chapter><sect1><para>
17962 #: ../en/ch14-hgext.xml:141
17963 msgid ""
17964 "The <literal role=\"hg-ext\">inotify</literal> extension is not yet shipped "
17965 "with Mercurial as of May 2007, so it's a little more involved to set up than "
17966 "other extensions. But the performance improvement is worth it!"
17967 msgstr ""
17969 #. type: Content of: <book><chapter><sect1><para>
17970 #: ../en/ch14-hgext.xml:146
17971 msgid ""
17972 "The extension currently comes in two parts: a set of patches to the Mercurial "
17973 "source code, and a library of Python bindings to the <literal>inotify</"
17974 "literal> subsystem."
17975 msgstr ""
17977 #. type: Content of: <book><chapter><sect1><note><para>
17978 #: ../en/ch14-hgext.xml:150
17979 msgid ""
17980 "There are <emphasis>two</emphasis> Python <literal>inotify</literal> binding "
17981 "libraries. One of them is called <literal>pyinotify</literal>, and is "
17982 "packaged by some Linux distributions as <literal>python-inotify</literal>. "
17983 "This is <emphasis>not</emphasis> the one you'll need, as it is too buggy and "
17984 "inefficient to be practical."
17985 msgstr ""
17987 #. type: Content of: <book><chapter><sect1><para>
17988 #: ../en/ch14-hgext.xml:157
17989 msgid ""
17990 "To get going, it's best to already have a functioning copy of Mercurial "
17991 "installed."
17992 msgstr ""
17994 #. type: Content of: <book><chapter><sect1><note><para>
17995 #: ../en/ch14-hgext.xml:160
17996 msgid ""
17997 "If you follow the instructions below, you'll be <emphasis>replacing</"
17998 "emphasis> and overwriting any existing installation of Mercurial that you "
17999 "might already have, using the latest <quote>bleeding edge</quote> Mercurial "
18000 "code. Don't say you weren't warned!"
18001 msgstr ""
18003 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
18004 #: ../en/ch14-hgext.xml:167
18005 msgid ""
18006 "Clone the Python <literal>inotify</literal> binding repository. Build and "
18007 "install it."
18008 msgstr ""
18010 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
18011 #: ../en/ch14-hgext.xml:174
18012 msgid ""
18013 "Clone the <filename class=\"directory\">crew</filename> Mercurial "
18014 "repository. Clone the <literal role=\"hg-ext\">inotify</literal> patch "
18015 "repository so that Mercurial Queues will be able to apply patches to your "
18016 "cope of the <filename class=\"directory\">crew</filename> repository."
18017 msgstr ""
18019 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
18020 #: ../en/ch14-hgext.xml:184
18021 msgid ""
18022 "Make sure that you have the Mercurial Queues extension, <literal role=\"hg-ext"
18023 "\">mq</literal>, enabled. If you've never used MQ, read <xref linkend=\"sec:"
18024 "mq:start\"/> to get started quickly."
18025 msgstr ""
18027 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
18028 #: ../en/ch14-hgext.xml:190
18029 msgid ""
18030 "Go into the <filename class=\"directory\">inotify</filename> repo, and apply "
18031 "all of the <literal role=\"hg-ext\">inotify</literal> patches using the "
18032 "<option role=\"hg-ext-mq-cmd-qpush-opt\">hg -a</option> option to the "
18033 "<command role=\"hg-ext-mq\">qpush</command> command."
18034 msgstr ""
18036 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
18037 #: ../en/ch14-hgext.xml:199
18038 msgid ""
18039 "If you get an error message from <command role=\"hg-ext-mq\">qpush</command>, "
18040 "you should not continue. Instead, ask for help."
18041 msgstr ""
18043 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
18044 #: ../en/ch14-hgext.xml:203
18045 msgid "Build and install the patched version of Mercurial."
18046 msgstr ""
18048 #. type: Content of: <book><chapter><sect1><para>
18049 #: ../en/ch14-hgext.xml:209
18050 msgid ""
18051 "Once you've build a suitably patched version of Mercurial, all you need to do "
18052 "to enable the <literal role=\"hg-ext\">inotify</literal> extension is add an "
18053 "entry to your <filename role=\"special\">~/.hgrc</filename>."
18054 msgstr ""
18056 #. type: Content of: <book><chapter><sect1><para>
18057 #: ../en/ch14-hgext.xml:214
18058 msgid ""
18059 "When the <literal role=\"hg-ext\">inotify</literal> extension is enabled, "
18060 "Mercurial will automatically and transparently start the status daemon the "
18061 "first time you run a command that needs status in a repository. It runs one "
18062 "status daemon per repository."
18063 msgstr ""
18065 #. type: Content of: <book><chapter><sect1><para>
18066 #: ../en/ch14-hgext.xml:220
18067 msgid ""
18068 "The status daemon is started silently, and runs in the background. If you "
18069 "look at a list of running processes after you've enabled the <literal role="
18070 "\"hg-ext\">inotify</literal> extension and run a few commands in different "
18071 "repositories, you'll thus see a few <literal>hg</literal> processes sitting "
18072 "around, waiting for updates from the kernel and queries from Mercurial."
18073 msgstr ""
18075 #. type: Content of: <book><chapter><sect1><para>
18076 #: ../en/ch14-hgext.xml:228
18077 msgid ""
18078 "The first time you run a Mercurial command in a repository when you have the "
18079 "<literal role=\"hg-ext\">inotify</literal> extension enabled, it will run "
18080 "with about the same performance as a normal Mercurial command. This is "
18081 "because the status daemon needs to perform a normal status scan so that it "
18082 "has a baseline against which to apply later updates from the kernel. "
18083 "However, <emphasis>every</emphasis> subsequent command that does any kind of "
18084 "status check should be noticeably faster on repositories of even fairly "
18085 "modest size. Better yet, the bigger your repository is, the greater a "
18086 "performance advantage you'll see. The <literal role=\"hg-ext\">inotify</"
18087 "literal> daemon makes status operations almost instantaneous on repositories "
18088 "of all sizes!"
18089 msgstr ""
18091 #. type: Content of: <book><chapter><sect1><para>
18092 #: ../en/ch14-hgext.xml:242
18093 msgid ""
18094 "If you like, you can manually start a status daemon using the <command role="
18095 "\"hg-ext-inotify\">inserve</command> command. This gives you slightly finer "
18096 "control over how the daemon ought to run. This command will of course only "
18097 "be available when the <literal role=\"hg-ext\">inotify</literal> extension is "
18098 "enabled."
18099 msgstr ""
18101 #. type: Content of: <book><chapter><sect1><para>
18102 #: ../en/ch14-hgext.xml:249
18103 msgid ""
18104 "When you're using the <literal role=\"hg-ext\">inotify</literal> extension, "
18105 "you should notice <emphasis>no difference at all</emphasis> in Mercurial's "
18106 "behavior, with the sole exception of status-related commands running a whole "
18107 "lot faster than they used to. You should specifically expect that commands "
18108 "will not print different output; neither should they give different results. "
18109 "If either of these situations occurs, please report a bug."
18110 msgstr ""
18112 #. type: Content of: <book><chapter><sect1><title>
18113 #: ../en/ch14-hgext.xml:260
18114 msgid ""
18115 "Flexible diff support with the <literal role=\"hg-ext\">extdiff</literal> "
18116 "extension"
18117 msgstr "使用扩展 <literal role=\"hg-ext\">extdiff</literal> 以扩展差异支持"
18119 #. type: Content of: <book><chapter><sect1><para>
18120 #: ../en/ch14-hgext.xml:263
18121 msgid ""
18122 "Mercurial's built-in <command role=\"hg-cmd\">hg diff</command> command "
18123 "outputs plaintext unified diffs."
18124 msgstr ""
18125 "Mercurial 内置命令 <command role=\"hg-cmd\">hg diff</command> 的输出与统一差异"
18126 "不同。"
18128 #. type: Content of: <book><chapter><sect1><para>
18129 #: ../en/ch14-hgext.xml:268
18130 msgid ""
18131 "If you would like to use an external tool to display modifications, you'll "
18132 "want to use the <literal role=\"hg-ext\">extdiff</literal> extension. This "
18133 "will let you use, for example, a graphical diff tool."
18134 msgstr ""
18136 #. type: Content of: <book><chapter><sect1><para>
18137 #: ../en/ch14-hgext.xml:273
18138 msgid ""
18139 "The <literal role=\"hg-ext\">extdiff</literal> extension is bundled with "
18140 "Mercurial, so it's easy to set up. In the <literal role=\"rc-extensions"
18141 "\">extensions</literal> section of your <filename role=\"special\">~/.hgrc</"
18142 "filename>, simply add a one-line entry to enable the extension."
18143 msgstr ""
18145 #. type: Content of: <book><chapter><sect1><para>
18146 #: ../en/ch14-hgext.xml:280
18147 msgid ""
18148 "This introduces a command named <command role=\"hg-ext-extdiff\">extdiff</"
18149 "command>, which by default uses your system's <command>diff</command> command "
18150 "to generate a unified diff in the same form as the built-in <command role="
18151 "\"hg-cmd\">hg diff</command> command."
18152 msgstr ""
18154 #. type: Content of: <book><chapter><sect1><para>
18155 #: ../en/ch14-hgext.xml:288
18156 msgid ""
18157 "The result won't be exactly the same as with the built-in <command role=\"hg-"
18158 "cmd\">hg diff</command> variations, because the output of <command>diff</"
18159 "command> varies from one system to another, even when passed the same options."
18160 msgstr ""
18162 #. type: Content of: <book><chapter><sect1><para>
18163 #: ../en/ch14-hgext.xml:293
18164 msgid ""
18165 "As the <quote><literal>making snapshot</literal></quote> lines of output "
18166 "above imply, the <command role=\"hg-ext-extdiff\">extdiff</command> command "
18167 "works by creating two snapshots of your source tree. The first snapshot is "
18168 "of the source revision; the second, of the target revision or working "
18169 "directory. The <command role=\"hg-ext-extdiff\">extdiff</command> command "
18170 "generates these snapshots in a temporary directory, passes the name of each "
18171 "directory to an external diff viewer, then deletes the temporary directory. "
18172 "For efficiency, it only snapshots the directories and files that have changed "
18173 "between the two revisions."
18174 msgstr ""
18176 #. type: Content of: <book><chapter><sect1><para>
18177 #: ../en/ch14-hgext.xml:306
18178 msgid ""
18179 "Snapshot directory names have the same base name as your repository. If your "
18180 "repository path is <filename class=\"directory\">/quux/bar/foo</filename>, "
18181 "then <filename class=\"directory\">foo</filename> will be the name of each "
18182 "snapshot directory. Each snapshot directory name has its changeset ID "
18183 "appended, if appropriate. If a snapshot is of revision "
18184 "<literal>a631aca1083f</literal>, the directory will be named <filename class="
18185 "\"directory\">foo.a631aca1083f</filename>. A snapshot of the working "
18186 "directory won't have a changeset ID appended, so it would just be <filename "
18187 "class=\"directory\">foo</filename> in this example. To see what this looks "
18188 "like in practice, look again at the <command role=\"hg-ext-extdiff\">extdiff</"
18189 "command> example above. Notice that the diff has the snapshot directory "
18190 "names embedded in its header."
18191 msgstr ""
18193 #. type: Content of: <book><chapter><sect1><para>
18194 #: ../en/ch14-hgext.xml:322
18195 msgid ""
18196 "The <command role=\"hg-ext-extdiff\">extdiff</command> command accepts two "
18197 "important options. The <option role=\"hg-ext-extdiff-cmd-extdiff-opt\">hg -p</"
18198 "option> option lets you choose a program to view differences with, instead of "
18199 "<command>diff</command>. With the <option role=\"hg-ext-extdiff-cmd-extdiff-"
18200 "opt\">hg -o</option> option, you can change the options that <command role="
18201 "\"hg-ext-extdiff\">extdiff</command> passes to the program (by default, these "
18202 "options are <quote><literal>-Npru</literal></quote>, which only make sense if "
18203 "you're running <command>diff</command>). In other respects, the <command "
18204 "role=\"hg-ext-extdiff\">extdiff</command> command acts similarly to the built-"
18205 "in <command role=\"hg-cmd\">hg diff</command> command: you use the same "
18206 "option names, syntax, and arguments to specify the revisions you want, the "
18207 "files you want, and so on."
18208 msgstr ""
18211 #. type: Content of: <book><chapter><sect1><para>
18212 #: ../en/ch14-hgext.xml:339
18213 msgid ""
18214 "As an example, here's how to run the normal system <command>diff</command> "
18215 "command, getting it to generate context diffs (using the <option role=\"cmd-"
18216 "opt-diff\">-c</option> option) instead of unified diffs, and five lines of "
18217 "context instead of the default three (passing <literal>5</literal> as the "
18218 "argument to the <option role=\"cmd-opt-diff\">-C</option> option)."
18219 msgstr ""
18221 #. type: Content of: <book><chapter><sect1><para>
18222 #: ../en/ch14-hgext.xml:348
18223 msgid ""
18224 "Launching a visual diff tool is just as easy. Here's how to launch the "
18225 "<command>kdiff3</command> viewer."
18226 msgstr ""
18228 #. type: Content of: <book><chapter><sect1><para>
18229 #: ../en/ch14-hgext.xml:352
18230 msgid ""
18231 "If your diff viewing command can't deal with directories, you can easily work "
18232 "around this with a little scripting. For an example of such scripting in "
18233 "action with the <literal role=\"hg-ext\">mq</literal> extension and the "
18234 "<command>interdiff</command> command, see <xref linkend=\"mq-collab:tips:"
18235 "interdiff\"/>."
18236 msgstr ""
18238 #. type: Content of: <book><chapter><sect1><sect2><title>
18239 #: ../en/ch14-hgext.xml:360
18240 msgid "Defining command aliases"
18241 msgstr "定义命令的别名"
18243 #. type: Content of: <book><chapter><sect1><sect2><para>
18244 #: ../en/ch14-hgext.xml:362
18245 msgid ""
18246 "It can be cumbersome to remember the options to both the <command role=\"hg-"
18247 "ext-extdiff\">extdiff</command> command and the diff viewer you want to use, "
18248 "so the <literal role=\"hg-ext\">extdiff</literal> extension lets you define "
18249 "<emphasis>new</emphasis> commands that will invoke your diff viewer with "
18250 "exactly the right options."
18251 msgstr ""
18253 #. type: Content of: <book><chapter><sect1><sect2><para>
18254 #: ../en/ch14-hgext.xml:369
18255 msgid ""
18256 "All you need to do is edit your <filename role=\"special\">~/.hgrc</"
18257 "filename>, and add a section named <literal role=\"rc-extdiff\">extdiff</"
18258 "literal>. Inside this section, you can define multiple commands. Here's how "
18259 "to add a <literal>kdiff3</literal> command. Once you've defined this, you "
18260 "can type <quote><literal>hg kdiff3</literal></quote> and the <literal role="
18261 "\"hg-ext\">extdiff</literal> extension will run <command>kdiff3</command> for "
18262 "you."
18263 msgstr ""
18265 #. type: Content of: <book><chapter><sect1><sect2><para>
18266 #: ../en/ch14-hgext.xml:379
18267 msgid ""
18268 "If you leave the right hand side of the definition empty, as above, the "
18269 "<literal role=\"hg-ext\">extdiff</literal> extension uses the name of the "
18270 "command you defined as the name of the external program to run. But these "
18271 "names don't have to be the same. Here, we define a command named "
18272 "<quote><literal>hg wibble</literal></quote>, which runs <command>kdiff3</"
18273 "command>."
18274 msgstr ""
18276 #. type: Content of: <book><chapter><sect1><sect2><para>
18277 #: ../en/ch14-hgext.xml:389
18278 msgid ""
18279 "You can also specify the default options that you want to invoke your diff "
18280 "viewing program with. The prefix to use is <quote><literal>opts.</literal></"
18281 "quote>, followed by the name of the command to which the options apply. This "
18282 "example defines a <quote><literal>hg vimdiff</literal></quote> command that "
18283 "runs the <command>vim</command> editor's <literal>DirDiff</literal> extension."
18284 msgstr ""
18286 #. type: Content of: <book><chapter><sect1><title>
18287 #: ../en/ch14-hgext.xml:403
18288 msgid ""
18289 "Cherrypicking changes with the <literal role=\"hg-ext\">transplant</literal> "
18290 "extension"
18291 msgstr "使用扩展 <literal role=\"hg-ext\">transplant</literal> 以挑选修改"
18293 #. type: Content of: <book><chapter><sect1><para>
18294 #: ../en/ch14-hgext.xml:406
18295 msgid "Need to have a long chat with Brendan about this."
18296 msgstr ""
18298 #. type: Content of: <book><chapter><sect1><title>
18299 #: ../en/ch14-hgext.xml:410
18300 msgid ""
18301 "Send changes via email with the <literal role=\"hg-ext\">patchbomb</literal> "
18302 "extension"
18303 msgstr ""
18304 "使用扩展 <literal role=\"hg-ext\">patchbomb</literal> 通过 email 发送修改"
18306 #. type: Content of: <book><chapter><sect1><para>
18307 #: ../en/ch14-hgext.xml:413
18308 msgid ""
18309 "Many projects have a culture of <quote>change review</quote>, in which people "
18310 "send their modifications to a mailing list for others to read and comment on "
18311 "before they commit the final version to a shared repository. Some projects "
18312 "have people who act as gatekeepers; they apply changes from other people to a "
18313 "repository to which those others don't have access."
18314 msgstr ""
18316 #. type: Content of: <book><chapter><sect1><para>
18317 #: ../en/ch14-hgext.xml:421
18318 msgid ""
18319 "Mercurial makes it easy to send changes over email for review or application, "
18320 "via its <literal role=\"hg-ext\">patchbomb</literal> extension. The "
18321 "extension is so named because changes are formatted as patches, and it's "
18322 "usual to send one changeset per email message. Sending a long series of "
18323 "changes by email is thus much like <quote>bombing</quote> the recipient's "
18324 "inbox, hence <quote>patchbomb</quote>."
18325 msgstr ""
18327 #. type: Content of: <book><chapter><sect1><para>
18328 #: ../en/ch14-hgext.xml:429
18329 msgid ""
18330 "As usual, the basic configuration of the <literal role=\"hg-ext\">patchbomb</"
18331 "literal> extension takes just one or two lines in your <filename role="
18332 "\"special\"> /.hgrc</filename>."
18333 msgstr ""
18335 #. type: Content of: <book><chapter><sect1><para>
18336 #: ../en/ch14-hgext.xml:435
18337 msgid ""
18338 "Once you've enabled the extension, you will have a new command available, "
18339 "named <command role=\"hg-ext-patchbomb\">email</command>."
18340 msgstr ""
18342 #. type: Content of: <book><chapter><sect1><para>
18343 #: ../en/ch14-hgext.xml:439
18344 msgid ""
18345 "The safest and best way to invoke the <command role=\"hg-ext-patchbomb"
18346 "\">email</command> command is to <emphasis>always</emphasis> run it first "
18347 "with the <option role=\"hg-ext-patchbomb-cmd-email-opt\">hg -n</option> "
18348 "option. This will show you what the command <emphasis>would</emphasis> send, "
18349 "without actually sending anything. Once you've had a quick glance over the "
18350 "changes and verified that you are sending the right ones, you can rerun the "
18351 "same command, with the <option role=\"hg-ext-patchbomb-cmd-email-opt\">hg -n</"
18352 "option> option removed."
18353 msgstr ""
18355 #. type: Content of: <book><chapter><sect1><para>
18356 #: ../en/ch14-hgext.xml:450
18357 msgid ""
18358 "The <command role=\"hg-ext-patchbomb\">email</command> command accepts the "
18359 "same kind of revision syntax as every other Mercurial command. For example, "
18360 "this command will send every revision between 7 and <literal>tip</literal>, "
18361 "inclusive."
18362 msgstr ""
18364 #. type: Content of: <book><chapter><sect1><para>
18365 #: ../en/ch14-hgext.xml:455
18366 msgid ""
18367 "You can also specify a <emphasis>repository</emphasis> to compare with. If "
18368 "you provide a repository but no revisions, the <command role=\"hg-ext-"
18369 "patchbomb\">email</command> command will send all revisions in the local "
18370 "repository that are not present in the remote repository. If you "
18371 "additionally specify revisions or a branch name (the latter using the <option "
18372 "role=\"hg-ext-patchbomb-cmd-email-opt\">hg -b</option> option), this will "
18373 "constrain the revisions sent."
18374 msgstr ""
18376 #. type: Content of: <book><chapter><sect1><para>
18377 #: ../en/ch14-hgext.xml:464
18378 msgid ""
18379 "It's perfectly safe to run the <command role=\"hg-ext-patchbomb\">email</"
18380 "command> command without the names of the people you want to send to: if you "
18381 "do this, it will just prompt you for those values interactively. (If you're "
18382 "using a Linux or Unix-like system, you should have enhanced "
18383 "<literal>readline</literal>-style editing capabilities when entering those "
18384 "headers, too, which is useful.)"
18385 msgstr ""
18387 #. type: Content of: <book><chapter><sect1><para>
18388 #: ../en/ch14-hgext.xml:472
18389 msgid ""
18390 "When you are sending just one revision, the <command role=\"hg-ext-patchbomb"
18391 "\">email</command> command will by default use the first line of the "
18392 "changeset description as the subject of the single email message it sends."
18393 msgstr ""
18395 #. type: Content of: <book><chapter><sect1><para>
18396 #: ../en/ch14-hgext.xml:477
18397 msgid ""
18398 "If you send multiple revisions, the <command role=\"hg-ext-patchbomb\">email</"
18399 "command> command will usually send one message per changeset. It will "
18400 "preface the series with an introductory message, in which you should describe "
18401 "the purpose of the series of changes you're sending."
18402 msgstr ""
18404 #. type: Content of: <book><chapter><sect1><sect2><title>
18405 #: ../en/ch14-hgext.xml:484
18406 msgid "Changing the behavior of patchbombs"
18407 msgstr "修改 patchbomb 的行为"
18409 #. type: Content of: <book><chapter><sect1><sect2><para>
18410 #: ../en/ch14-hgext.xml:486
18411 msgid ""
18412 "Not every project has exactly the same conventions for sending changes in "
18413 "email; the <literal role=\"hg-ext\">patchbomb</literal> extension tries to "
18414 "accommodate a number of variations through command line options."
18415 msgstr ""
18417 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
18418 #: ../en/ch14-hgext.xml:492
18419 msgid ""
18420 "You can write a subject for the introductory message on the command line "
18421 "using the <option role=\"hg-ext-patchbomb-cmd-email-opt\">hg -s</option> "
18422 "option. This takes one argument, the text of the subject to use."
18423 msgstr ""
18425 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
18426 #: ../en/ch14-hgext.xml:498
18427 msgid ""
18428 "To change the email address from which the messages originate, use the "
18429 "<option role=\"hg-ext-patchbomb-cmd-email-opt\">hg -f</option> option. This "
18430 "takes one argument, the email address to use."
18431 msgstr ""
18433 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
18434 #: ../en/ch14-hgext.xml:504
18435 msgid ""
18436 "The default behavior is to send unified diffs (see <xref linkend=\"sec:mq:"
18437 "patch\"/> for a description of the format), one per message. You can send a "
18438 "binary bundle instead with the <option role=\"hg-ext-patchbomb-cmd-email-opt"
18439 "\">hg -b</option> option."
18440 msgstr ""
18442 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
18443 #: ../en/ch14-hgext.xml:512
18444 msgid ""
18445 "Unified diffs are normally prefaced with a metadata header. You can omit "
18446 "this, and send unadorned diffs, with the <option role=\"hg-ext-patchbomb-cmd-"
18447 "email-opt\">hg --plain</option> option."
18448 msgstr ""
18450 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
18451 #: ../en/ch14-hgext.xml:518
18452 msgid ""
18453 "Diffs are normally sent <quote>inline</quote>, in the same body part as the "
18454 "description of a patch. This makes it easiest for the largest number of "
18455 "readers to quote and respond to parts of a diff, as some mail clients will "
18456 "only quote the first MIME body part in a message. If you'd prefer to send the "
18457 "description and the diff in separate body parts, use the <option role=\"hg-"
18458 "ext-patchbomb-cmd-email-opt\">hg -a</option> option."
18459 msgstr ""
18461 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
18462 #: ../en/ch14-hgext.xml:528
18463 msgid ""
18464 "Instead of sending mail messages, you can write them to an <literal>mbox</"
18465 "literal>-format mail folder using the <option role=\"hg-ext-patchbomb-cmd-"
18466 "email-opt\">hg -m</option> option. That option takes one argument, the name "
18467 "of the file to write to."
18468 msgstr ""
18470 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
18471 #: ../en/ch14-hgext.xml:535
18472 msgid ""
18473 "If you would like to add a <command>diffstat</command>-format summary to each "
18474 "patch, and one to the introductory message, use the <option role=\"hg-ext-"
18475 "patchbomb-cmd-email-opt\">hg -d</option> option. The <command>diffstat</"
18476 "command> command displays a table containing the name of each file patched, "
18477 "the number of lines affected, and a histogram showing how much each file is "
18478 "modified. This gives readers a qualitative glance at how complex a patch is."
18479 msgstr ""