hgbook

annotate po/zh.po @ 1041:dcf0d7d91c28

1.6.1 zh partly translated
author Zhaoping Sun <zhaopingsun@gmail.com>
date Sun Nov 08 19:56:39 2009 -0500 (2009-11-08)
parents c84e50397ae8
children b08a63383d04
rev   line source
dongsheng@627 1 #
dongsheng@627 2 # Simplified Chinese translation for hgbook
dongsheng@627 3 # This file is distributed under the same license as the hgbook.
dongsheng@627 4 #
dongsheng@627 5 # Authors:
dongsheng@627 6 # Dongsheng Song <dongsheng.song@gmail.com>, 2009
dongsheng@627 7 #
dongsheng@627 8 # Check translation:
dongsheng@627 9 # msgfmt --statistics -c -o zh.mo zh.po
dongsheng@627 10 #
dongsheng@627 11 # Please format your translation before commit:
dongsheng@627 12 # msgcat --sort-by-file --width=80 -o zh_new.po zh.po
dongsheng@627 13 # mv -f zh_new.po zh.po
dongsheng@627 14 #
dongsheng@627 15 # Dictionary:
dongsheng@627 16 # blame 追溯
dongsheng@627 17 # branch 分支
dongsheng@627 18 # changes 修改
dongsheng@627 19 # changeset 修改集
dongsheng@627 20 # checkout 检出
dongsheng@627 21 # remove 移除(从版本库删除)
dongsheng@627 22 # delete 删除(只从文件系统删除)
dongsheng@660 23 # filelog 文件日志
dongsheng@627 24 # patchset 补丁集
dongsheng@627 25 # pushing to 推到
dongsheng@635 26 # pulling from 拉自,抓取
dongsheng@627 27 # rename 改名
dongsheng@627 28 # repository 版本库
dongsheng@627 29 # revert 恢复
dongsheng@627 30 # revision 版本
dongsheng@660 31 # revlog 版本日志
dongsheng@627 32 # tag 标签
dongsheng@627 33 # tip 顶点
dongsheng@627 34 # undo 撤销
dongsheng@627 35 # unversioned 未版本控制
dongsheng@660 36 # updated 更新到,同步到(适用于旧版本)
dongsheng@627 37 # versioned 受版本控制
dongsheng@627 38 # working copy 工作副本
dongsheng@627 39 # ...
dongsheng@627 40 #
dongsheng@627 41 msgid ""
dongsheng@627 42 msgstr ""
dongsheng@627 43 "Project-Id-Version: hgbook 1.2\n"
dongsheng@1034 44 "POT-Creation-Date: 2009-11-04 14:06+0800\n"
dongsheng@876 45 "PO-Revision-Date: 2009-10-21 16:42+0800\n"
songdongsheng@668 46 "Last-Translator: 宋冬生 <songdonogsheng@live.cn>\n"
dongsheng@627 47 "Language-Team: Simplified Chinese <i18n-zh@googlegroups.com >\n"
dongsheng@627 48 "MIME-Version: 1.0\n"
dongsheng@627 49 "Content-Type: text/plain; charset=UTF-8\n"
dongsheng@627 50 "Content-Transfer-Encoding: 8bit\n"
dongsheng@627 51 "X-Poedit-Language: Chinese\n"
dongsheng@627 52 "X-Poedit-Country: CHINA\n"
dongsheng@627 53 "X-Poedit-SourceCharset: utf-8\n"
dongsheng@627 54
dongsheng@627 55 #. type: Content of: <book><title>
dongsheng@714 56 #: ../en/00book.xml:42
dongsheng@627 57 msgid "Mercurial: The Definitive Guide"
dongsheng@627 58 msgstr "Mercurial 权威指南"
dongsheng@627 59
dongsheng@627 60 #. type: Content of: <book><subtitle>
dongsheng@714 61 #: ../en/00book.xml:47
dongsheng@627 62 msgid "Compiled from $rev_id$"
dongsheng@627 63 msgstr "编译自 $rev_id$"
dongsheng@627 64
songdongsheng@667 65 #. type: Content of: <book><bookinfo>
dongsheng@714 66 #: ../en/00book.xml:49
songdongsheng@667 67 msgid "<edition>1</edition> <isbn>9780596800673</isbn>"
songdongsheng@668 68 msgstr "<edition>1</edition> <isbn>9780596800673</isbn>"
songdongsheng@667 69
dongsheng@627 70 #. type: Content of: <book><bookinfo><authorgroup><author><firstname>
dongsheng@714 71 #: ../en/00book.xml:53
dongsheng@627 72 msgid "Bryan"
dongsheng@643 73 msgstr "Bryan"
dongsheng@627 74
dongsheng@627 75 #. type: Content of: <book><bookinfo><authorgroup><author><surname>
dongsheng@714 76 #: ../en/00book.xml:54
dongsheng@627 77 msgid "O'Sullivan"
dongsheng@643 78 msgstr "O'Sullivan"
dongsheng@627 79
dongsheng@627 80 #. type: Content of: <book><bookinfo>
dongsheng@714 81 #: ../en/00book.xml:58
dongsheng@627 82 msgid ""
dongsheng@627 83 "<editor> <firstname>Mike</firstname> <surname>Loukides</surname> </editor> "
dongsheng@627 84 "<copyright> <year>2006</year> <year>2007</year> <year>2008</year> <year>2009</"
dongsheng@627 85 "year> <holder>Bryan O'Sullivan</holder> </copyright>"
dongsheng@627 86 msgstr ""
dongsheng@643 87 "<editor> <firstname>Mike</firstname> <surname>Loukides</surname> </editor> "
dongsheng@643 88 "<copyright> <year>2006</year> <year>2007</year> <year>2008</year> <year>2009</"
dongsheng@643 89 "year> <holder>Bryan O'Sullivan</holder> </copyright>"
dongsheng@627 90
dongsheng@627 91 #. type: Content of: <book><appendix><title>
dongsheng@714 92 #: ../en/appA-svn.xml:5
dongsheng@714 93 msgid "Migrating to Mercurial"
dongsheng@715 94 msgstr "迁移到 Mercurial"
dongsheng@714 95
dongsheng@714 96 #. type: Content of: <book><appendix><para>
dongsheng@714 97 #: ../en/appA-svn.xml:7
dongsheng@714 98 msgid ""
dongsheng@714 99 "A common way to test the waters with a new revision control tool is to "
dongsheng@714 100 "experiment with switching an existing project, rather than starting a new "
dongsheng@714 101 "project from scratch."
dongsheng@714 102 msgstr ""
dongsheng@714 103
dongsheng@714 104 #. type: Content of: <book><appendix><para>
dongsheng@714 105 #: ../en/appA-svn.xml:11
dongsheng@714 106 msgid ""
dongsheng@714 107 "In this appendix, we discuss how to import a project's history into "
dongsheng@714 108 "Mercurial, and what to look out for if you are used to a different revision "
dongsheng@714 109 "control system."
dongsheng@714 110 msgstr ""
dongsheng@714 111
dongsheng@714 112 #. type: Content of: <book><appendix><sect1><title>
dongsheng@714 113 #: ../en/appA-svn.xml:16
dongsheng@714 114 msgid "Importing history from another system"
dongsheng@716 115 msgstr "从其它版本控制系统导入历史"
dongsheng@714 116
dongsheng@714 117 #. type: Content of: <book><appendix><sect1><para>
dongsheng@714 118 #: ../en/appA-svn.xml:18
dongsheng@714 119 msgid ""
dongsheng@714 120 "Mercurial ships with an extension named <literal>convert</literal>, which can "
dongsheng@714 121 "import project history from most popular revision control systems. At the "
dongsheng@714 122 "time this book was written, it could import history from the following "
dongsheng@714 123 "systems:"
dongsheng@714 124 msgstr ""
dongsheng@714 125
dongsheng@714 126 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><thead><row><entry>
dongsheng@714 127 #: ../en/appA-svn.xml:25 ../en/appA-svn.xml:369 ../en/ch01-intro.xml:416
dongsheng@714 128 #: ../en/ch01-intro.xml:627
dongsheng@714 129 msgid "Subversion"
dongsheng@715 130 msgstr "Subversion"
dongsheng@714 131
dongsheng@714 132 #. type: Content of: <book><appendix><sect1><itemizedlist><listitem><para>
dongsheng@714 133 #: ../en/appA-svn.xml:28 ../en/ch01-intro.xml:532 ../en/ch01-intro.xml:628
dongsheng@714 134 msgid "CVS"
dongsheng@714 135 msgstr "CVS"
dongsheng@714 136
dongsheng@714 137 #. type: Content of: <book><appendix><sect1><itemizedlist><listitem><para>
dongsheng@714 138 #: ../en/appA-svn.xml:31
dongsheng@714 139 msgid "git"
dongsheng@715 140 msgstr "git"
dongsheng@714 141
dongsheng@714 142 #. type: Content of: <book><appendix><sect1><itemizedlist><listitem><para>
dongsheng@714 143 #: ../en/appA-svn.xml:34 ../en/ch01-intro.xml:630
dongsheng@714 144 msgid "Darcs"
dongsheng@714 145 msgstr "Darcs"
dongsheng@714 146
dongsheng@714 147 #. type: Content of: <book><appendix><sect1><itemizedlist><listitem><para>
dongsheng@714 148 #: ../en/appA-svn.xml:37
dongsheng@714 149 msgid "Bazaar"
dongsheng@715 150 msgstr "Bazaar"
dongsheng@714 151
dongsheng@714 152 #. type: Content of: <book><appendix><sect1><itemizedlist><listitem><para>
dongsheng@714 153 #: ../en/appA-svn.xml:40
dongsheng@714 154 msgid "Monotone"
dongsheng@715 155 msgstr "Monotone"
dongsheng@714 156
dongsheng@714 157 #. type: Content of: <book><appendix><sect1><itemizedlist><listitem><para>
dongsheng@714 158 #: ../en/appA-svn.xml:43
dongsheng@714 159 msgid "GNU Arch"
dongsheng@715 160 msgstr "GNU Arch"
dongsheng@714 161
dongsheng@714 162 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><thead><row><entry>
dongsheng@714 163 #: ../en/appA-svn.xml:46 ../en/appA-svn.xml:370
dongsheng@714 164 msgid "Mercurial"
dongsheng@715 165 msgstr "Mercurial"
dongsheng@714 166
dongsheng@714 167 #. type: Content of: <book><appendix><sect1><para>
dongsheng@714 168 #: ../en/appA-svn.xml:50
dongsheng@714 169 msgid ""
dongsheng@714 170 "(To see why Mercurial itself is supported as a source, see <xref linkend="
dongsheng@714 171 "\"svn.filemap\"/>.)"
dongsheng@714 172 msgstr ""
dongsheng@714 173
dongsheng@714 174 #. type: Content of: <book><appendix><sect1><para>
dongsheng@714 175 #: ../en/appA-svn.xml:53
dongsheng@714 176 msgid ""
dongsheng@714 177 "You can enable the extension in the usual way, by editing your <filename>~/."
dongsheng@714 178 "hgrc</filename> file."
dongsheng@714 179 msgstr ""
zhaopingsun@1036 180 "你可以通过常用的方式,编辑<filename>~./hgrc</filename>文件来使用这个扩展。"
dongsheng@714 181
dongsheng@714 182 #. type: Content of: <book><appendix><sect1><para>
dongsheng@714 183 #: ../en/appA-svn.xml:59
dongsheng@714 184 msgid ""
dongsheng@714 185 "This will make a <command>hg convert</command> command available. The "
dongsheng@714 186 "command is easy to use. For instance, this command will import the "
dongsheng@714 187 "Subversion history for the Nose unit testing framework into Mercurial."
dongsheng@714 188 msgstr ""
dongsheng@714 189
dongsheng@714 190 #. type: Content of: <book><appendix><sect1><screen><prompt>
dongsheng@714 191 #: ../en/appA-svn.xml:64 ../en/appA-svn.xml:207 ../en/appA-svn.xml:212
dongsheng@714 192 #: ../en/appA-svn.xml:213 ../en/appA-svn.xml:218 ../en/appA-svn.xml:224
dongsheng@714 193 #: ../en/appA-svn.xml:229 ../en/appA-svn.xml:532
dongsheng@714 194 msgid "$"
dongsheng@715 195 msgstr "$"
dongsheng@714 196
dongsheng@714 197 #. type: Content of: <book><appendix><sect1><screen><userinput>
dongsheng@714 198 #: ../en/appA-svn.xml:64
dongsheng@714 199 msgid "hg convert http://python-nose.googlecode.com/svn/trunk"
dongsheng@714 200 msgstr ""
dongsheng@714 201
dongsheng@714 202 #. type: Content of: <book><appendix><sect1><para>
dongsheng@714 203 #: ../en/appA-svn.xml:66
dongsheng@714 204 msgid ""
dongsheng@714 205 "The <literal>convert</literal> extension operates incrementally. In other "
dongsheng@714 206 "words, after you have run <command>hg convert</command> once, running it "
dongsheng@714 207 "again will import any new revisions committed after the first run began. "
dongsheng@714 208 "Incremental conversion will only work if you run <command>hg convert</"
dongsheng@714 209 "command> in the same Mercurial repository that you originally used, because "
dongsheng@714 210 "the <literal>convert</literal> extension saves some private metadata in a non-"
dongsheng@714 211 "revision-controlled file named <filename>.hg/shamap</filename> inside the "
dongsheng@714 212 "target repository."
dongsheng@714 213 msgstr ""
dongsheng@714 214
dongsheng@714 215 #. type: Content of: <book><appendix><sect1><para>
dongsheng@714 216 #: ../en/appA-svn.xml:78
dongsheng@714 217 msgid ""
dongsheng@714 218 "When you want to start making changes using Mercurial, it's best to clone the "
dongsheng@714 219 "tree in which you are doing your conversions, and leave the original tree for "
dongsheng@714 220 "future incremental conversions. This is the safest way to let you pull and "
dongsheng@714 221 "merge future commits from the source revision control system into your newly "
dongsheng@714 222 "active Mercurial project."
dongsheng@714 223 msgstr ""
dongsheng@714 224
dongsheng@714 225 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@714 226 #: ../en/appA-svn.xml:86
dongsheng@714 227 msgid "Converting multiple branches"
dongsheng@715 228 msgstr "转换多个分支"
dongsheng@714 229
dongsheng@714 230 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 231 #: ../en/appA-svn.xml:88
dongsheng@714 232 msgid ""
dongsheng@714 233 "The <command>hg convert</command> command given above converts only the "
dongsheng@714 234 "history of the <literal>trunk</literal> branch of the Subversion repository. "
dongsheng@714 235 "If we instead use the URL <literal>http://python-nose.googlecode.com/svn</"
dongsheng@714 236 "literal>, Mercurial will automatically detect the <literal>trunk</literal>, "
dongsheng@714 237 "<literal>tags</literal> and <literal>branches</literal> layout that "
dongsheng@714 238 "Subversion projects usually use, and it will import each as a separate "
dongsheng@714 239 "Mercurial branch."
dongsheng@714 240 msgstr ""
dongsheng@714 241
dongsheng@714 242 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 243 #: ../en/appA-svn.xml:98
dongsheng@714 244 msgid ""
dongsheng@714 245 "By default, each Subversion branch imported into Mercurial is given a branch "
dongsheng@714 246 "name. After the conversion completes, you can get a list of the active "
dongsheng@714 247 "branch names in the Mercurial repository using <command>hg branches -a</"
dongsheng@714 248 "command>. If you would prefer to import the Subversion branches without "
dongsheng@714 249 "names, pass the <option>--config convert.hg.usebranchnames=false</option> "
dongsheng@714 250 "option to <command>hg convert</command>."
dongsheng@714 251 msgstr ""
dongsheng@714 252
dongsheng@714 253 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 254 #: ../en/appA-svn.xml:107
dongsheng@714 255 msgid ""
dongsheng@714 256 "Once you have converted your tree, if you want to follow the usual Mercurial "
dongsheng@714 257 "practice of working in a tree that contains a single branch, you can clone "
dongsheng@714 258 "that single branch using <command>hg clone -r mybranchname</command>."
dongsheng@714 259 msgstr ""
dongsheng@714 260
dongsheng@714 261 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@714 262 #: ../en/appA-svn.xml:114
dongsheng@714 263 msgid "Mapping user names"
dongsheng@715 264 msgstr "映射用户名称"
dongsheng@714 265
dongsheng@714 266 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 267 #: ../en/appA-svn.xml:116
dongsheng@714 268 msgid ""
dongsheng@714 269 "Some revision control tools save only short usernames with commits, and these "
dongsheng@714 270 "can be difficult to interpret. The norm with Mercurial is to save a "
dongsheng@714 271 "committer's name and email address, which is much more useful for talking to "
dongsheng@714 272 "them after the fact."
dongsheng@714 273 msgstr ""
dongsheng@714 274
dongsheng@714 275 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 276 #: ../en/appA-svn.xml:122
dongsheng@714 277 msgid ""
dongsheng@714 278 "If you are converting a tree from a revision control system that uses short "
dongsheng@714 279 "names, you can map those names to longer equivalents by passing a <option>--"
dongsheng@714 280 "authors</option> option to <command>hg convert</command>. This option "
dongsheng@714 281 "accepts a file name that should contain entries of the following form."
dongsheng@714 282 msgstr ""
dongsheng@714 283
dongsheng@714 284 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 285 #: ../en/appA-svn.xml:132
dongsheng@714 286 msgid ""
dongsheng@714 287 "Whenever <literal>convert</literal> encounters a commit with the username "
dongsheng@714 288 "<literal>arist</literal> in the source repository, it will use the name "
dongsheng@714 289 "<literal>Aristotle &lt;aristotle@phil.example.gr&gt;</literal> in the "
dongsheng@714 290 "converted Mercurial revision. If no match is found for a name, it is used "
dongsheng@714 291 "verbatim."
dongsheng@714 292 msgstr ""
dongsheng@714 293
dongsheng@714 294 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@714 295 #: ../en/appA-svn.xml:141
dongsheng@714 296 msgid "Tidying up the tree"
dongsheng@716 297 msgstr "清理目录树"
dongsheng@714 298
dongsheng@714 299 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 300 #: ../en/appA-svn.xml:143
dongsheng@714 301 msgid ""
dongsheng@714 302 "Not all projects have pristine history. There may be a directory that should "
dongsheng@714 303 "never have been checked in, a file that is too big, or a whole hierarchy that "
dongsheng@714 304 "needs to be refactored."
dongsheng@714 305 msgstr ""
dongsheng@714 306
dongsheng@714 307 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 308 #: ../en/appA-svn.xml:148
dongsheng@714 309 msgid ""
dongsheng@714 310 "The <literal>convert</literal> extension supports the idea of a <quote>file "
dongsheng@714 311 "map</quote> that can reorganize the files and directories in a project as it "
dongsheng@714 312 "imports the project's history. This is useful not only when importing "
dongsheng@714 313 "history from other revision control systems, but also to prune or refactor a "
dongsheng@714 314 "Mercurial tree."
dongsheng@714 315 msgstr ""
dongsheng@714 316
dongsheng@714 317 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 318 #: ../en/appA-svn.xml:155
dongsheng@714 319 msgid ""
dongsheng@714 320 "To specify a file map, use the <option>--filemap</option> option and supply a "
dongsheng@714 321 "file name. A file map contains lines of the following forms."
dongsheng@714 322 msgstr ""
dongsheng@714 323
dongsheng@714 324 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 325 #: ../en/appA-svn.xml:169
dongsheng@714 326 msgid ""
dongsheng@714 327 "The <literal>include</literal> directive causes a file, or all files under a "
dongsheng@714 328 "directory, to be included in the destination repository. This also excludes "
dongsheng@714 329 "all other files and dirs not explicitely included. The <literal>exclude</"
dongsheng@714 330 "literal> directive causes files or directories to be omitted, and others not "
dongsheng@714 331 "explicitly mentioned to be included."
dongsheng@714 332 msgstr ""
dongsheng@714 333
dongsheng@714 334 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 335 #: ../en/appA-svn.xml:176
dongsheng@714 336 msgid ""
dongsheng@714 337 "To move a file or directory from one location to another, use the "
dongsheng@714 338 "<literal>rename</literal> directive. If you need to move a file or directory "
dongsheng@714 339 "from a subdirectory into the root of the repository, use <literal>.</literal> "
dongsheng@714 340 "as the second argument to the <literal>rename</literal> directive."
dongsheng@714 341 msgstr ""
dongsheng@714 342
dongsheng@714 343 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@714 344 #: ../en/appA-svn.xml:184
dongsheng@714 345 msgid "Improving Subversion conversion performance"
dongsheng@716 346 msgstr "改进 Subversion 的转换性能"
dongsheng@714 347
dongsheng@714 348 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 349 #: ../en/appA-svn.xml:186
dongsheng@714 350 msgid ""
dongsheng@714 351 "You will often need several attempts before you hit the perfect combination "
dongsheng@714 352 "of user map, file map, and other conversion parameters. Converting a "
dongsheng@714 353 "Subversion repository over an access protocol like <literal>ssh</literal> or "
dongsheng@714 354 "<literal>http</literal> can proceed thousands of times more slowly than "
dongsheng@714 355 "Mercurial is capable of actually operating, due to network delays. This can "
dongsheng@714 356 "make tuning that perfect conversion recipe very painful."
dongsheng@714 357 msgstr ""
dongsheng@714 358
dongsheng@714 359 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 360 #: ../en/appA-svn.xml:195
dongsheng@714 361 msgid ""
dongsheng@714 362 "The <ulink url=\"http://svn.collab.net/repos/svn/trunk/notes/svnsync.txt"
dongsheng@714 363 "\"><command>svnsync</command></ulink> command can greatly speed up the "
dongsheng@714 364 "conversion of a Subversion repository. It is a read-only mirroring program "
dongsheng@714 365 "for Subversion repositories. The idea is that you create a local mirror of "
dongsheng@714 366 "your Subversion tree, then convert the mirror into a Mercurial repository."
dongsheng@714 367 msgstr ""
dongsheng@714 368
dongsheng@714 369 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 370 #: ../en/appA-svn.xml:203
dongsheng@714 371 msgid ""
dongsheng@714 372 "Suppose we want to convert the Subversion repository for the popular "
dongsheng@714 373 "Memcached project into a Mercurial tree. First, we create a local Subversion "
dongsheng@714 374 "repository."
dongsheng@714 375 msgstr ""
dongsheng@714 376
dongsheng@714 377 #. type: Content of: <book><appendix><sect1><sect2><screen><userinput>
dongsheng@714 378 #: ../en/appA-svn.xml:207
dongsheng@714 379 msgid "svnadmin create memcached-mirror"
dongsheng@715 380 msgstr "svnadmin create memcached-mirror"
dongsheng@714 381
dongsheng@714 382 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 383 #: ../en/appA-svn.xml:209
dongsheng@714 384 msgid "Next, we set up a Subversion hook that <command>svnsync</command> needs."
dongsheng@714 385 msgstr ""
dongsheng@714 386
dongsheng@714 387 #. type: Content of: <book><appendix><sect1><sect2><screen><userinput>
dongsheng@714 388 #: ../en/appA-svn.xml:212
dongsheng@714 389 msgid "echo '#!/bin/sh' > memcached-mirror/hooks/pre-revprop-change"
dongsheng@715 390 msgstr "echo '#!/bin/sh' > memcached-mirror/hooks/pre-revprop-change"
dongsheng@714 391
dongsheng@714 392 #. type: Content of: <book><appendix><sect1><sect2><screen><userinput>
dongsheng@714 393 #: ../en/appA-svn.xml:213
dongsheng@714 394 msgid "chmod +x memcached-mirror/hooks/pre-revprop-change"
dongsheng@715 395 msgstr "chmod +x memcached-mirror/hooks/pre-revprop-change"
dongsheng@714 396
dongsheng@714 397 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 398 #: ../en/appA-svn.xml:215
dongsheng@714 399 msgid "We then initialize <command>svnsync</command> in this repository."
dongsheng@714 400 msgstr ""
dongsheng@714 401
dongsheng@714 402 #. type: Content of: <book><appendix><sect1><sect2><screen><userinput>
dongsheng@714 403 #: ../en/appA-svn.xml:218
dongsheng@714 404 msgid ""
dongsheng@714 405 "svnsync --init file://`pwd`/memcached-mirror \\ http://code.sixapart.com/svn/"
dongsheng@714 406 "memcached"
dongsheng@714 407 msgstr ""
dongsheng@715 408 "svnsync --init file://`pwd`/memcached-mirror \\ http://code.sixapart.com/svn/"
dongsheng@715 409 "memcached"
dongsheng@714 410
dongsheng@714 411 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 412 #: ../en/appA-svn.xml:221
dongsheng@714 413 msgid ""
dongsheng@714 414 "Our next step is to begin the <command>svnsync</command> mirroring process."
dongsheng@714 415 msgstr ""
dongsheng@714 416
dongsheng@714 417 #. type: Content of: <book><appendix><sect1><sect2><screen><userinput>
dongsheng@714 418 #: ../en/appA-svn.xml:224
dongsheng@714 419 msgid "svnsync sync file://`pwd`/memcached-mirror"
dongsheng@715 420 msgstr "svnsync sync file://`pwd`/memcached-mirror"
dongsheng@714 421
dongsheng@714 422 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 423 #: ../en/appA-svn.xml:226
dongsheng@714 424 msgid ""
dongsheng@714 425 "Finally, we import the history of our local Subversion mirror into Mercurial."
dongsheng@714 426 msgstr ""
dongsheng@714 427
dongsheng@714 428 #. type: Content of: <book><appendix><sect1><sect2><screen><userinput>
dongsheng@714 429 #: ../en/appA-svn.xml:229
dongsheng@714 430 msgid "hg convert memcached-mirror"
dongsheng@714 431 msgstr ""
dongsheng@714 432
dongsheng@714 433 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 434 #: ../en/appA-svn.xml:231
dongsheng@714 435 msgid ""
dongsheng@714 436 "We can use this process incrementally if the Subversion repository is still "
dongsheng@714 437 "in use. We run <command>svnsync</command> to pull new changes into our "
dongsheng@714 438 "mirror, then <command>hg convert</command> to import them into our Mercurial "
dongsheng@714 439 "tree."
dongsheng@714 440 msgstr ""
dongsheng@714 441
dongsheng@714 442 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 443 #: ../en/appA-svn.xml:237
dongsheng@714 444 msgid ""
dongsheng@714 445 "There are two advantages to doing a two-stage import with <command>svnsync</"
dongsheng@714 446 "command>. The first is that it uses more efficient Subversion network "
dongsheng@714 447 "syncing code than <command>hg convert</command>, so it transfers less data "
dongsheng@714 448 "over the network. The second is that the import from a local Subversion tree "
dongsheng@714 449 "is so fast that you can tweak your conversion setup repeatedly without having "
dongsheng@714 450 "to sit through a painfully slow network-based conversion process each time."
dongsheng@714 451 msgstr ""
dongsheng@714 452
dongsheng@714 453 #. type: Content of: <book><appendix><sect1><title>
dongsheng@714 454 #: ../en/appA-svn.xml:249
dongsheng@714 455 msgid "Migrating from Subversion"
dongsheng@715 456 msgstr "从 Subversion 迁移"
dongsheng@714 457
dongsheng@714 458 #. type: Content of: <book><appendix><sect1><para>
dongsheng@714 459 #: ../en/appA-svn.xml:251
dongsheng@714 460 msgid ""
dongsheng@714 461 "Subversion is currently the most popular open source revision control system. "
dongsheng@714 462 "Although there are many differences between Mercurial and Subversion, making "
dongsheng@714 463 "the transition from Subversion to Mercurial is not particularly difficult. "
dongsheng@714 464 "The two have similar command sets and generally uniform interfaces."
dongsheng@714 465 msgstr ""
dongsheng@714 466
dongsheng@714 467 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@714 468 #: ../en/appA-svn.xml:259
dongsheng@714 469 msgid "Philosophical differences"
dongsheng@716 470 msgstr "哲学的差别"
dongsheng@714 471
dongsheng@714 472 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 473 #: ../en/appA-svn.xml:261
dongsheng@714 474 msgid ""
dongsheng@714 475 "The fundamental difference between Subversion and Mercurial is of course that "
dongsheng@714 476 "Subversion is centralized, while Mercurial is distributed. Since Mercurial "
dongsheng@714 477 "stores all of a project's history on your local drive, it only needs to "
dongsheng@714 478 "perform a network access when you want to explicitly communicate with another "
dongsheng@714 479 "repository. In contrast, Subversion stores very little information locally, "
dongsheng@714 480 "and the client must thus contact its server for many common operations."
dongsheng@714 481 msgstr ""
dongsheng@714 482
dongsheng@714 483 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 484 #: ../en/appA-svn.xml:270
dongsheng@714 485 msgid ""
dongsheng@714 486 "Subversion more or less gets away without a well-defined notion of a branch: "
dongsheng@714 487 "which portion of a server's namespace qualifies as a branch is a matter of "
dongsheng@714 488 "convention, with the software providing no enforcement. Mercurial treats a "
dongsheng@714 489 "repository as the unit of branch management."
dongsheng@714 490 msgstr ""
dongsheng@714 491
dongsheng@714 492 #. type: Content of: <book><appendix><sect1><sect2><sect3><title>
dongsheng@714 493 #: ../en/appA-svn.xml:277
dongsheng@714 494 msgid "Scope of commands"
dongsheng@715 495 msgstr "命令作用域"
dongsheng@714 496
dongsheng@714 497 #. type: Content of: <book><appendix><sect1><sect2><sect3><para>
dongsheng@714 498 #: ../en/appA-svn.xml:279
dongsheng@714 499 msgid ""
dongsheng@714 500 "Since Subversion doesn't know what parts of its namespace are really "
dongsheng@714 501 "branches, it treats most commands as requests to operate at and below "
dongsheng@714 502 "whatever directory you are currently visiting. For instance, if you run "
dongsheng@714 503 "<command>svn log</command>, you'll get the history of whatever part of the "
dongsheng@714 504 "tree you're looking at, not the tree as a whole."
dongsheng@714 505 msgstr ""
dongsheng@714 506
dongsheng@714 507 #. type: Content of: <book><appendix><sect1><sect2><sect3><para>
dongsheng@714 508 #: ../en/appA-svn.xml:286
dongsheng@714 509 msgid ""
dongsheng@714 510 "Mercurial's commands behave differently, by defaulting to operating over an "
dongsheng@714 511 "entire repository. Run <command>hg log</command> and it will tell you the "
dongsheng@714 512 "history of the entire tree, no matter what part of the working directory "
dongsheng@714 513 "you're visiting at the time. If you want the history of just a particular "
dongsheng@714 514 "file or directory, simply supply it by name, e.g. <command>hg log src</"
dongsheng@714 515 "command>."
dongsheng@714 516 msgstr ""
dongsheng@714 517
dongsheng@714 518 #. type: Content of: <book><appendix><sect1><sect2><sect3><para>
dongsheng@714 519 #: ../en/appA-svn.xml:294
dongsheng@714 520 msgid ""
dongsheng@714 521 "From my own experience, this difference in default behaviors is probably the "
dongsheng@714 522 "most likely to trip you up if you have to switch back and forth frequently "
dongsheng@714 523 "between the two tools."
dongsheng@714 524 msgstr ""
dongsheng@714 525
dongsheng@714 526 #. type: Content of: <book><appendix><sect1><sect2><sect3><title>
dongsheng@714 527 #: ../en/appA-svn.xml:301
dongsheng@714 528 msgid "Multi-user operation and safety"
dongsheng@716 529 msgstr "多用户操作与安全"
dongsheng@714 530
dongsheng@714 531 #. type: Content of: <book><appendix><sect1><sect2><sect3><para>
dongsheng@714 532 #: ../en/appA-svn.xml:303
dongsheng@714 533 msgid ""
dongsheng@714 534 "With Subversion, it is normal (though slightly frowned upon) for multiple "
dongsheng@714 535 "people to collaborate in a single branch. If Alice and Bob are working "
dongsheng@714 536 "together, and Alice commits some changes to their shared branch, Bob must "
dongsheng@714 537 "update his client's view of the branch before he can commit. Since at this "
dongsheng@714 538 "time he has no permanent record of the changes he has made, he can corrupt or "
dongsheng@714 539 "lose his modifications during and after his update."
dongsheng@714 540 msgstr ""
dongsheng@714 541
dongsheng@714 542 #. type: Content of: <book><appendix><sect1><sect2><sect3><para>
dongsheng@714 543 #: ../en/appA-svn.xml:312
dongsheng@714 544 msgid ""
dongsheng@714 545 "Mercurial encourages a commit-then-merge model instead. Bob commits his "
dongsheng@714 546 "changes locally before pulling changes from, or pushing them to, the server "
dongsheng@714 547 "that he shares with Alice. If Alice pushed her changes before Bob tries to "
dongsheng@714 548 "push his, he will not be able to push his changes until he pulls hers, merges "
dongsheng@714 549 "with them, and commits the result of the merge. If he makes a mistake during "
dongsheng@714 550 "the merge, he still has the option of reverting to the commit that recorded "
dongsheng@714 551 "his changes."
dongsheng@714 552 msgstr ""
dongsheng@714 553
dongsheng@714 554 #. type: Content of: <book><appendix><sect1><sect2><sect3><para>
dongsheng@714 555 #: ../en/appA-svn.xml:321
dongsheng@714 556 msgid ""
dongsheng@714 557 "It is worth emphasizing that these are the common ways of working with these "
dongsheng@714 558 "tools. Subversion supports a safer work-in-your-own-branch model, but it is "
dongsheng@714 559 "cumbersome enough in practice to not be widely used. Mercurial can support "
dongsheng@714 560 "the less safe mode of allowing changes to be pulled in and merged on top of "
dongsheng@714 561 "uncommitted edits, but this is considered highly unusual."
dongsheng@714 562 msgstr ""
dongsheng@714 563
dongsheng@714 564 #. type: Content of: <book><appendix><sect1><sect2><sect3><title>
dongsheng@714 565 #: ../en/appA-svn.xml:331
dongsheng@714 566 msgid "Published vs local changes"
dongsheng@716 567 msgstr "已发布的修改与本地修改"
dongsheng@714 568
dongsheng@714 569 #. type: Content of: <book><appendix><sect1><sect2><sect3><para>
dongsheng@714 570 #: ../en/appA-svn.xml:333
dongsheng@714 571 msgid ""
dongsheng@714 572 "A Subversion <command>svn commit</command> command immediately publishes "
dongsheng@714 573 "changes to a server, where they can be seen by everyone who has read access."
dongsheng@714 574 msgstr ""
dongsheng@714 575
dongsheng@714 576 #. type: Content of: <book><appendix><sect1><sect2><sect3><para>
dongsheng@714 577 #: ../en/appA-svn.xml:337
dongsheng@714 578 msgid ""
dongsheng@714 579 "With Mercurial, commits are always local, and must be published via a "
dongsheng@714 580 "<command>hg push</command> command afterwards."
dongsheng@714 581 msgstr ""
dongsheng@714 582
dongsheng@714 583 #. type: Content of: <book><appendix><sect1><sect2><sect3><para>
dongsheng@714 584 #: ../en/appA-svn.xml:341
dongsheng@714 585 msgid ""
dongsheng@714 586 "Each approach has its advantages and disadvantages. The Subversion model "
dongsheng@714 587 "means that changes are published, and hence reviewable and usable, "
dongsheng@714 588 "immediately. On the other hand, this means that a user must have commit "
dongsheng@714 589 "access to a repository in order to use the software in a normal way, and "
dongsheng@714 590 "commit access is not lightly given out by most open source projects."
dongsheng@714 591 msgstr ""
dongsheng@714 592
dongsheng@714 593 #. type: Content of: <book><appendix><sect1><sect2><sect3><para>
dongsheng@714 594 #: ../en/appA-svn.xml:349
dongsheng@714 595 msgid ""
dongsheng@714 596 "The Mercurial approach allows anyone who can clone a repository to commit "
dongsheng@714 597 "changes without the need for someone else's permission, and they can then "
dongsheng@714 598 "publish their changes and continue to participate however they see fit. The "
dongsheng@714 599 "distinction between committing and pushing does open up the possibility of "
dongsheng@714 600 "someone committing changes to their laptop and walking away for a few days "
dongsheng@714 601 "having forgotten to push them, which in rare cases might leave collaborators "
dongsheng@714 602 "temporarily stuck."
dongsheng@714 603 msgstr ""
dongsheng@714 604
dongsheng@714 605 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@714 606 #: ../en/appA-svn.xml:362
dongsheng@714 607 msgid "Quick reference"
dongsheng@715 608 msgstr "快速参考"
dongsheng@714 609
dongsheng@714 610 #. type: Content of: <book><appendix><sect1><sect2><table><title>
dongsheng@714 611 #: ../en/appA-svn.xml:365
dongsheng@714 612 msgid "Subversion commands and Mercurial equivalents"
dongsheng@715 613 msgstr "Subversion 命令与 Mercurial 对照表"
dongsheng@714 614
dongsheng@714 615 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><thead><row><entry>
dongsheng@714 616 #: ../en/appA-svn.xml:371
dongsheng@714 617 msgid "Notes"
dongsheng@715 618 msgstr "备注"
dongsheng@714 619
dongsheng@714 620 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
dongsheng@714 621 #: ../en/appA-svn.xml:376
dongsheng@714 622 msgid "<command>svn add</command>"
dongsheng@715 623 msgstr "<command>svn add</command>"
dongsheng@714 624
dongsheng@714 625 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
dongsheng@714 626 #: ../en/appA-svn.xml:377
dongsheng@714 627 msgid "<command>hg add</command>"
dongsheng@715 628 msgstr "<command>hg add</command>"
dongsheng@714 629
dongsheng@714 630 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
dongsheng@714 631 #: ../en/appA-svn.xml:381
dongsheng@714 632 msgid "<command>svn blame</command>"
dongsheng@715 633 msgstr "<command>svn blame</command>"
dongsheng@714 634
dongsheng@714 635 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
dongsheng@714 636 #: ../en/appA-svn.xml:382
dongsheng@714 637 msgid "<command>hg annotate</command>"
dongsheng@715 638 msgstr "<command>hg annotate</command>"
dongsheng@714 639
dongsheng@714 640 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
dongsheng@714 641 #: ../en/appA-svn.xml:386
dongsheng@714 642 msgid "<command>svn cat</command>"
dongsheng@715 643 msgstr "<command>svn cat</command>"
dongsheng@714 644
dongsheng@714 645 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
dongsheng@714 646 #: ../en/appA-svn.xml:387
dongsheng@714 647 msgid "<command>hg cat</command>"
dongsheng@715 648 msgstr "<command>hg cat</command>"
dongsheng@714 649
dongsheng@714 650 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
dongsheng@714 651 #: ../en/appA-svn.xml:391
dongsheng@714 652 msgid "<command>svn checkout</command>"
dongsheng@715 653 msgstr "<command>svn checkout</command>"
dongsheng@714 654
dongsheng@714 655 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
dongsheng@714 656 #: ../en/appA-svn.xml:392 ../en/appA-svn.xml:409
dongsheng@714 657 msgid "<command>hg clone</command>"
dongsheng@715 658 msgstr "<command>hg clone</command>"
dongsheng@714 659
dongsheng@714 660 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
dongsheng@714 661 #: ../en/appA-svn.xml:396
dongsheng@714 662 msgid "<command>svn cleanup</command>"
dongsheng@715 663 msgstr "<command>svn cleanup</command>"
dongsheng@714 664
dongsheng@714 665 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
dongsheng@714 666 #: ../en/appA-svn.xml:397 ../en/appA-svn.xml:472
dongsheng@714 667 msgid "n/a"
dongsheng@715 668 msgstr "n/a"
dongsheng@714 669
dongsheng@714 670 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
dongsheng@714 671 #: ../en/appA-svn.xml:398
dongsheng@714 672 msgid "No cleanup needed"
dongsheng@715 673 msgstr "不需要清理"
dongsheng@714 674
dongsheng@714 675 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
dongsheng@714 676 #: ../en/appA-svn.xml:401
dongsheng@714 677 msgid "<command>svn commit</command>"
dongsheng@715 678 msgstr "<command>svn commit</command>"
dongsheng@714 679
dongsheng@714 680 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
dongsheng@714 681 #: ../en/appA-svn.xml:402
dongsheng@714 682 msgid "<command>hg commit</command>; <command>hg push</command>"
dongsheng@715 683 msgstr "<command>hg commit</command>; <command>hg push</command>"
dongsheng@714 684
dongsheng@714 685 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
dongsheng@714 686 #: ../en/appA-svn.xml:404
dongsheng@714 687 msgid "<command>hg push</command> publishes after commit"
dongsheng@715 688 msgstr "提交后使用 <command>hg push</command> 发布"
dongsheng@714 689
dongsheng@714 690 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
dongsheng@714 691 #: ../en/appA-svn.xml:408 ../en/appA-svn.xml:413
dongsheng@714 692 msgid "<command>svn copy</command>"
dongsheng@715 693 msgstr "<command>svn copy</command>"
dongsheng@714 694
dongsheng@714 695 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
dongsheng@714 696 #: ../en/appA-svn.xml:410
dongsheng@714 697 msgid "To create a new branch"
dongsheng@714 698 msgstr "创建新补丁"
dongsheng@714 699
dongsheng@714 700 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
dongsheng@714 701 #: ../en/appA-svn.xml:414
dongsheng@714 702 msgid "<command>hg copy</command>"
dongsheng@715 703 msgstr "<command>hg copy</command>"
dongsheng@714 704
dongsheng@714 705 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
dongsheng@714 706 #: ../en/appA-svn.xml:415
dongsheng@714 707 msgid "To copy files or directories"
dongsheng@715 708 msgstr "复制文件或目录"
dongsheng@714 709
dongsheng@714 710 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
dongsheng@714 711 #: ../en/appA-svn.xml:418
dongsheng@714 712 msgid "<command>svn delete</command> (<command>svn remove</command>)"
dongsheng@715 713 msgstr "<command>svn delete</command> (<command>svn remove</command>)"
dongsheng@714 714
dongsheng@714 715 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
dongsheng@714 716 #: ../en/appA-svn.xml:420
dongsheng@714 717 msgid "<command>hg remove</command>"
dongsheng@715 718 msgstr "<command>hg remove</command>"
dongsheng@714 719
dongsheng@714 720 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
dongsheng@714 721 #: ../en/appA-svn.xml:424
dongsheng@714 722 msgid "<command>svn diff</command>"
dongsheng@715 723 msgstr "<command>svn diff</command>"
dongsheng@714 724
dongsheng@714 725 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
dongsheng@714 726 #: ../en/appA-svn.xml:425
dongsheng@714 727 msgid "<command>hg diff</command>"
dongsheng@715 728 msgstr "<command>hg diff</command>"
dongsheng@714 729
dongsheng@714 730 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
dongsheng@714 731 #: ../en/appA-svn.xml:429
dongsheng@714 732 msgid "<command>svn export</command>"
dongsheng@715 733 msgstr "<command>svn export</command>"
dongsheng@714 734
dongsheng@714 735 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
dongsheng@714 736 #: ../en/appA-svn.xml:430
dongsheng@714 737 msgid "<command>hg archive</command>"
dongsheng@715 738 msgstr "<command>hg archive</command>"
dongsheng@714 739
dongsheng@714 740 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
dongsheng@714 741 #: ../en/appA-svn.xml:434
dongsheng@714 742 msgid "<command>svn help</command>"
dongsheng@715 743 msgstr "<command>svn help</command>"
dongsheng@714 744
dongsheng@714 745 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
dongsheng@714 746 #: ../en/appA-svn.xml:435
dongsheng@714 747 msgid "<command>hg help</command>"
dongsheng@715 748 msgstr "<command>hg help</command>"
dongsheng@714 749
dongsheng@714 750 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
dongsheng@714 751 #: ../en/appA-svn.xml:439
dongsheng@714 752 msgid "<command>svn import</command>"
dongsheng@715 753 msgstr "<command>svn import</command>"
dongsheng@714 754
dongsheng@714 755 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
dongsheng@714 756 #: ../en/appA-svn.xml:440
dongsheng@714 757 msgid "<command>hg addremove</command>; <command>hg commit</command>"
dongsheng@715 758 msgstr "<command>hg addremove</command>; <command>hg commit</command>"
dongsheng@714 759
dongsheng@714 760 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
dongsheng@714 761 #: ../en/appA-svn.xml:445 ../en/appA-svn.xml:450
dongsheng@714 762 msgid "<command>svn info</command>"
dongsheng@715 763 msgstr "<command>svn info</command>"
dongsheng@714 764
dongsheng@714 765 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
dongsheng@714 766 #: ../en/appA-svn.xml:446
dongsheng@714 767 msgid "<command>hg parents</command>"
dongsheng@715 768 msgstr "<command>hg parents</command>"
dongsheng@714 769
dongsheng@714 770 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
dongsheng@714 771 #: ../en/appA-svn.xml:447
dongsheng@714 772 msgid "Shows what revision is checked out"
dongsheng@715 773 msgstr "显示检出的版本信息"
dongsheng@714 774
dongsheng@714 775 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
dongsheng@714 776 #: ../en/appA-svn.xml:451
dongsheng@714 777 msgid "<command>hg showconfig paths.parent</command>"
dongsheng@715 778 msgstr "<command>hg showconfig paths.parent</command>"
dongsheng@714 779
dongsheng@714 780 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
dongsheng@714 781 #: ../en/appA-svn.xml:453
dongsheng@714 782 msgid "Shows what URL is checked out"
dongsheng@715 783 msgstr "显示检出的 URL"
dongsheng@714 784
dongsheng@714 785 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
dongsheng@714 786 #: ../en/appA-svn.xml:456
dongsheng@714 787 msgid "<command>svn list</command>"
dongsheng@715 788 msgstr "<command>svn list</command>"
dongsheng@714 789
dongsheng@714 790 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
dongsheng@714 791 #: ../en/appA-svn.xml:457
dongsheng@714 792 msgid "<command>hg manifest</command>"
dongsheng@715 793 msgstr "<command>hg manifest</command>"
dongsheng@714 794
dongsheng@714 795 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
dongsheng@714 796 #: ../en/appA-svn.xml:461
dongsheng@714 797 msgid "<command>svn log</command>"
dongsheng@715 798 msgstr "<command>svn log</command>"
dongsheng@714 799
dongsheng@714 800 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
dongsheng@714 801 #: ../en/appA-svn.xml:462
dongsheng@714 802 msgid "<command>hg log</command>"
dongsheng@715 803 msgstr "<command>hg log</command>"
dongsheng@714 804
dongsheng@714 805 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
dongsheng@714 806 #: ../en/appA-svn.xml:466
dongsheng@714 807 msgid "<command>svn merge</command>"
dongsheng@714 808 msgstr ""
dongsheng@714 809
dongsheng@714 810 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
dongsheng@714 811 #: ../en/appA-svn.xml:467
dongsheng@714 812 msgid "<command>hg merge</command>"
dongsheng@715 813 msgstr "<command>hg merge</command>"
dongsheng@714 814
dongsheng@714 815 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
dongsheng@714 816 #: ../en/appA-svn.xml:471
dongsheng@714 817 msgid "<command>svn mkdir</command>"
dongsheng@715 818 msgstr "<command>svn mkdir</command>"
dongsheng@714 819
dongsheng@714 820 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
dongsheng@714 821 #: ../en/appA-svn.xml:473
dongsheng@714 822 msgid "Mercurial does not track directories"
dongsheng@715 823 msgstr "Mercurial 不跟踪目录"
dongsheng@714 824
dongsheng@714 825 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
dongsheng@714 826 #: ../en/appA-svn.xml:476
dongsheng@714 827 msgid "<command>svn move</command> (<command>svn rename</command>)"
dongsheng@715 828 msgstr "<command>svn move</command> (<command>svn rename</command>)"
dongsheng@714 829
dongsheng@714 830 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
dongsheng@714 831 #: ../en/appA-svn.xml:478
dongsheng@714 832 msgid "<command>hg rename</command>"
dongsheng@715 833 msgstr "<command>hg rename</command>"
dongsheng@714 834
dongsheng@714 835 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
dongsheng@714 836 #: ../en/appA-svn.xml:482
dongsheng@714 837 msgid "<command>svn resolved</command>"
dongsheng@715 838 msgstr "<command>svn resolved</command>"
dongsheng@714 839
dongsheng@714 840 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
dongsheng@714 841 #: ../en/appA-svn.xml:483
dongsheng@714 842 msgid "<command>hg resolve -m</command>"
dongsheng@715 843 msgstr "<command>hg resolve -m</command>"
dongsheng@714 844
dongsheng@714 845 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
dongsheng@714 846 #: ../en/appA-svn.xml:487
dongsheng@714 847 msgid "<command>svn revert</command>"
dongsheng@715 848 msgstr "<command>svn revert</command>"
dongsheng@714 849
dongsheng@714 850 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
dongsheng@714 851 #: ../en/appA-svn.xml:488
dongsheng@714 852 msgid "<command>hg revert</command>"
dongsheng@715 853 msgstr "<command>hg revert</command>"
dongsheng@714 854
dongsheng@714 855 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
dongsheng@714 856 #: ../en/appA-svn.xml:492
dongsheng@714 857 msgid "<command>svn status</command>"
dongsheng@715 858 msgstr "<command>svn status</command>"
dongsheng@714 859
dongsheng@714 860 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
dongsheng@714 861 #: ../en/appA-svn.xml:493
dongsheng@714 862 msgid "<command>hg status</command>"
dongsheng@715 863 msgstr "<command>hg status</command>"
dongsheng@714 864
dongsheng@714 865 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
dongsheng@714 866 #: ../en/appA-svn.xml:497
dongsheng@714 867 msgid "<command>svn update</command>"
dongsheng@715 868 msgstr "<command>svn update</command>"
dongsheng@714 869
dongsheng@714 870 #. type: Content of: <book><appendix><sect1><sect2><table><tgroup><tbody><row><entry>
dongsheng@714 871 #: ../en/appA-svn.xml:498
dongsheng@714 872 msgid "<command>hg pull -u</command>"
dongsheng@715 873 msgstr "<command>hg pull -u</command>"
dongsheng@714 874
dongsheng@714 875 #. type: Content of: <book><appendix><sect1><title>
dongsheng@714 876 #: ../en/appA-svn.xml:508
dongsheng@714 877 msgid "Useful tips for newcomers"
dongsheng@715 878 msgstr "新手需要了解的技巧"
dongsheng@714 879
dongsheng@714 880 #. type: Content of: <book><appendix><sect1><para>
dongsheng@714 881 #: ../en/appA-svn.xml:510
dongsheng@714 882 msgid ""
dongsheng@714 883 "Under some revision control systems, printing a diff for a single committed "
dongsheng@714 884 "revision can be painful. For instance, with Subversion, to see what changed "
dongsheng@714 885 "in revision 104654, you must type <command>svn diff -r104653:104654</"
dongsheng@714 886 "command>. Mercurial eliminates the need to type the revision ID twice in this "
dongsheng@714 887 "common case. For a plain diff, <command>hg export 104654</command>. For a log "
dongsheng@714 888 "message followed by a diff, <command>hg log -r104654 -p</command>."
dongsheng@714 889 msgstr ""
dongsheng@714 890
dongsheng@714 891 #. type: Content of: <book><appendix><sect1><para>
dongsheng@714 892 #: ../en/appA-svn.xml:519
dongsheng@714 893 msgid ""
dongsheng@714 894 "When you run <command>hg status</command> without any arguments, it prints "
dongsheng@714 895 "the status of the entire tree, with paths relative to the root of the "
dongsheng@714 896 "repository. This makes it tricky to copy a file name from the output of "
dongsheng@714 897 "<command>hg status</command> into the command line. If you supply a file or "
dongsheng@714 898 "directory name to <command>hg status</command>, it will print paths relative "
dongsheng@714 899 "to your current location instead. So to get tree-wide status from "
dongsheng@714 900 "<command>hg status</command>, with paths that are relative to your current "
dongsheng@714 901 "directory and not the root of the repository, feed the output of <command>hg "
dongsheng@714 902 "root</command> into <command>hg status</command>. You can easily do this as "
dongsheng@714 903 "follows on a Unix-like system:"
dongsheng@714 904 msgstr ""
dongsheng@714 905
dongsheng@714 906 #. type: Content of: <book><appendix><sect1><screen><userinput>
dongsheng@714 907 #: ../en/appA-svn.xml:532
dongsheng@714 908 msgid "hg status `hg root`"
dongsheng@715 909 msgstr "hg status `hg root`"
dongsheng@714 910
dongsheng@714 911 #. type: Content of: <book><appendix><title>
dongsheng@627 912 #: ../en/appB-mq-ref.xml:5
dongsheng@627 913 msgid "Mercurial Queues reference"
dongsheng@627 914 msgstr "Mercurial 队列参考"
dongsheng@627 915
dongsheng@627 916 #. type: Content of: <book><appendix><sect1><title>
dongsheng@627 917 #: ../en/appB-mq-ref.xml:8
dongsheng@627 918 msgid "MQ command reference"
dongsheng@627 919 msgstr "MQ 命令参考"
dongsheng@627 920
dongsheng@627 921 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 922 #: ../en/appB-mq-ref.xml:10
dongsheng@627 923 msgid ""
dongsheng@627 924 "For an overview of the commands provided by MQ, use the command <command role="
dongsheng@627 925 "\"hg-cmd\">hg help mq</command>."
dongsheng@627 926 msgstr ""
dongsheng@627 927
dongsheng@627 928 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@627 929 #: ../en/appB-mq-ref.xml:14
songdongsheng@668 930 msgid ""
songdongsheng@668 931 "<command role=\"hg-ext-mq\">qapplied</command>&emdash;print applied patches"
dongsheng@661 932 msgstr "<command role=\"hg-ext-mq\">qapplied</command>—显示已应用的补丁"
dongsheng@627 933
dongsheng@627 934 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@627 935 #: ../en/appB-mq-ref.xml:17
dongsheng@627 936 msgid ""
dongsheng@627 937 "The <command role=\"hg-ext-mq\">qapplied</command> command prints the current "
dongsheng@627 938 "stack of applied patches. Patches are printed in oldest-to-newest order, so "
dongsheng@627 939 "the last patch in the list is the <quote>top</quote> patch."
dongsheng@627 940 msgstr ""
dongsheng@627 941
dongsheng@627 942 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@627 943 #: ../en/appB-mq-ref.xml:24
songdongsheng@668 944 msgid ""
songdongsheng@668 945 "<command role=\"hg-ext-mq\">qcommit</command>&emdash;commit changes in the "
songdongsheng@668 946 "queue repository"
dongsheng@661 947 msgstr "<command role=\"hg-ext-mq\">qcommit</command>—提交队列中的修改"
dongsheng@627 948
dongsheng@627 949 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@627 950 #: ../en/appB-mq-ref.xml:27
dongsheng@627 951 msgid ""
dongsheng@627 952 "The <command role=\"hg-ext-mq\">qcommit</command> command commits any "
dongsheng@627 953 "outstanding changes in the <filename role=\"special\" class=\"directory\">.hg/"
dongsheng@627 954 "patches</filename> repository. This command only works if the <filename role="
dongsheng@627 955 "\"special\" class=\"directory\">.hg/patches</filename> directory is a "
dongsheng@627 956 "repository, i.e. you created the directory using <command role=\"hg-cmd\">hg "
dongsheng@627 957 "qinit <option role=\"hg-ext-mq-cmd-qinit-opt\">-c</option></command> or ran "
dongsheng@627 958 "<command role=\"hg-cmd\">hg init</command> in the directory after running "
dongsheng@627 959 "<command role=\"hg-ext-mq\">qinit</command>."
dongsheng@627 960 msgstr ""
dongsheng@627 961
dongsheng@627 962 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@627 963 #: ../en/appB-mq-ref.xml:39
dongsheng@627 964 msgid ""
dongsheng@627 965 "This command is shorthand for <command role=\"hg-cmd\">hg commit --cwd .hg/"
dongsheng@627 966 "patches</command>."
dongsheng@627 967 msgstr ""
dongsheng@627 968
dongsheng@650 969 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@650 970 #: ../en/appB-mq-ref.xml:43
songdongsheng@668 971 msgid ""
songdongsheng@668 972 "<command role=\"hg-ext-mq\">qdelete</command>&emdash;delete a patch from the "
dongsheng@653 973 "<filename role=\"special\">series</filename> file"
dongsheng@653 974 msgstr ""
dongsheng@661 975 "<command role=\"hg-ext-mq\">qdelete</command>—从文件 <filename role=\"special"
dongsheng@661 976 "\">series</filename> 中删除补丁"
dongsheng@650 977
dongsheng@627 978 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 979 #: ../en/appB-mq-ref.xml:48
dongsheng@627 980 msgid ""
dongsheng@627 981 "The <command role=\"hg-ext-mq\">qdelete</command> command removes the entry "
dongsheng@627 982 "for a patch from the <filename role=\"special\">series</filename> file in the "
dongsheng@627 983 "<filename role=\"special\" class=\"directory\">.hg/patches</filename> "
dongsheng@627 984 "directory. It does not pop the patch if the patch is already applied. By "
dongsheng@627 985 "default, it does not delete the patch file; use the <option role=\"hg-ext-mq-"
dongsheng@627 986 "cmd-qdel-opt\">-f</option> option to do that."
dongsheng@627 987 msgstr ""
dongsheng@627 988
dongsheng@627 989 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 990 #: ../en/appB-mq-ref.xml:57 ../en/appB-mq-ref.xml:109 ../en/appB-mq-ref.xml:167
dongsheng@714 991 #: ../en/appB-mq-ref.xml:207 ../en/appB-mq-ref.xml:274
dongsheng@714 992 #: ../en/appB-mq-ref.xml:345 ../en/appB-mq-ref.xml:414
dongsheng@714 993 #: ../en/appB-mq-ref.xml:492
dongsheng@627 994 msgid "Options:"
songdongsheng@668 995 msgstr "选项:"
dongsheng@627 996
dongsheng@627 997 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 998 #: ../en/appB-mq-ref.xml:59
dongsheng@627 999 msgid ""
dongsheng@627 1000 "<option role=\"hg-ext-mq-cmd-qdel-opt\">-f</option>: Delete the patch file."
dongsheng@627 1001 msgstr ""
dongsheng@627 1002
dongsheng@627 1003 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@650 1004 #: ../en/appB-mq-ref.xml:66
songdongsheng@668 1005 msgid ""
songdongsheng@668 1006 "<command role=\"hg-ext-mq\">qdiff</command>&emdash;print a diff of the "
songdongsheng@668 1007 "topmost applied patch"
dongsheng@661 1008 msgstr "<command role=\"hg-ext-mq\">qdiff</command>—显示最新应用补丁的差异"
dongsheng@627 1009
dongsheng@627 1010 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 1011 #: ../en/appB-mq-ref.xml:69
dongsheng@627 1012 msgid ""
dongsheng@627 1013 "The <command role=\"hg-ext-mq\">qdiff</command> command prints a diff of the "
dongsheng@627 1014 "topmost applied patch. It is equivalent to <command role=\"hg-cmd\">hg diff -"
dongsheng@627 1015 "r-2:-1</command>."
dongsheng@627 1016 msgstr ""
dongsheng@627 1017
dongsheng@627 1018 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@650 1019 #: ../en/appB-mq-ref.xml:75
dongsheng@714 1020 msgid ""
dongsheng@714 1021 "<command role=\"hg-ext-mq\">qfold</command>&emdash;move applied patches into "
dongsheng@714 1022 "repository history"
dongsheng@715 1023 msgstr ""
dongsheng@715 1024 "<command role=\"hg-ext-mq\">qfold</command>&emdash;将已应用的补丁提交到版本库"
dongsheng@714 1025
dongsheng@714 1026 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 1027 #: ../en/appB-mq-ref.xml:78
dongsheng@714 1028 msgid ""
dongsheng@714 1029 "The <command>hg qfinish</command> command converts the specified applied "
dongsheng@714 1030 "patches into permanent changes by moving them out of MQ's control so that "
dongsheng@714 1031 "they will be treated as normal repository history."
dongsheng@714 1032 msgstr ""
dongsheng@714 1033
dongsheng@714 1034 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@714 1035 #: ../en/appB-mq-ref.xml:85
songdongsheng@668 1036 msgid ""
songdongsheng@668 1037 "<command role=\"hg-ext-mq\">qfold</command>&emdash;merge (<quote>fold</"
songdongsheng@668 1038 "quote>) several patches into one"
dongsheng@661 1039 msgstr ""
dongsheng@661 1040 "<command role=\"hg-ext-mq\">qfold</command>—将多个补丁合并(<quote>折叠</"
dongsheng@661 1041 "quote>)成一个"
dongsheng@627 1042
dongsheng@627 1043 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 1044 #: ../en/appB-mq-ref.xml:88
dongsheng@627 1045 msgid ""
dongsheng@627 1046 "The <command role=\"hg-ext-mq\">qfold</command> command merges multiple "
dongsheng@627 1047 "patches into the topmost applied patch, so that the topmost applied patch "
dongsheng@627 1048 "makes the union of all of the changes in the patches in question."
dongsheng@627 1049 msgstr ""
dongsheng@627 1050
dongsheng@627 1051 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 1052 #: ../en/appB-mq-ref.xml:93
dongsheng@627 1053 msgid ""
dongsheng@627 1054 "The patches to fold must not be applied; <command role=\"hg-ext-mq\">qfold</"
dongsheng@627 1055 "command> will exit with an error if any is. The order in which patches are "
dongsheng@627 1056 "folded is significant; <command role=\"hg-cmd\">hg qfold a b</command> means "
dongsheng@627 1057 "<quote>apply the current topmost patch, followed by <literal>a</literal>, "
dongsheng@627 1058 "followed by <literal>b</literal></quote>."
dongsheng@627 1059 msgstr ""
dongsheng@627 1060
dongsheng@627 1061 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 1062 #: ../en/appB-mq-ref.xml:101
dongsheng@627 1063 msgid ""
dongsheng@627 1064 "The comments from the folded patches are appended to the comments of the "
dongsheng@627 1065 "destination patch, with each block of comments separated by three asterisk "
dongsheng@627 1066 "(<quote><literal>*</literal></quote>) characters. Use the <option role=\"hg-"
dongsheng@627 1067 "ext-mq-cmd-qfold-opt\">-e</option> option to edit the commit message for the "
dongsheng@627 1068 "combined patch/changeset after the folding has completed."
dongsheng@627 1069 msgstr ""
dongsheng@627 1070
dongsheng@627 1071 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 1072 #: ../en/appB-mq-ref.xml:111
dongsheng@627 1073 msgid ""
dongsheng@627 1074 "<option role=\"hg-ext-mq-cmd-qfold-opt\">-e</option>: Edit the commit message "
dongsheng@627 1075 "and patch description for the newly folded patch."
dongsheng@627 1076 msgstr ""
zhaopingsun@1036 1077 "<option role=\"hg-ext-mq-cmd-qfold-opt\">-e</option>:为新创建的补丁编辑提交信"
zhaopingsun@1036 1078 "息和补丁说明。"
dongsheng@627 1079
dongsheng@627 1080 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 1081 #: ../en/appB-mq-ref.xml:116
dongsheng@627 1082 msgid ""
dongsheng@627 1083 "<option role=\"hg-ext-mq-cmd-qfold-opt\">-l</option>: Use the contents of the "
dongsheng@627 1084 "given file as the new commit message and patch description for the folded "
dongsheng@627 1085 "patch."
dongsheng@627 1086 msgstr ""
zhaopingsun@1036 1087 "<option role=\"hg-ext-mq-cmd-qfold-opt\">-l</option>: 使用给定文件的内容作为创"
zhaopingsun@1036 1088 "建补丁新的提交信息和补丁说明。"
dongsheng@627 1089
dongsheng@627 1090 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 1091 #: ../en/appB-mq-ref.xml:121
dongsheng@627 1092 msgid ""
dongsheng@627 1093 "<option role=\"hg-ext-mq-cmd-qfold-opt\">-m</option>: Use the given text as "
dongsheng@627 1094 "the new commit message and patch description for the folded patch."
dongsheng@627 1095 msgstr ""
dongsheng@627 1096
dongsheng@627 1097 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@714 1098 #: ../en/appB-mq-ref.xml:129
songdongsheng@668 1099 msgid ""
songdongsheng@668 1100 "<command role=\"hg-ext-mq\">qheader</command>&emdash;display the header/"
songdongsheng@668 1101 "description of a patch"
dongsheng@661 1102 msgstr "<command role=\"hg-ext-mq\">qheader</command>—显示补丁头部描述"
dongsheng@627 1103
dongsheng@627 1104 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 1105 #: ../en/appB-mq-ref.xml:133
dongsheng@627 1106 msgid ""
dongsheng@627 1107 "The <command role=\"hg-ext-mq\">qheader</command> command prints the header, "
dongsheng@627 1108 "or description, of a patch. By default, it prints the header of the topmost "
dongsheng@627 1109 "applied patch. Given an argument, it prints the header of the named patch."
dongsheng@627 1110 msgstr ""
dongsheng@627 1111
dongsheng@627 1112 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@714 1113 #: ../en/appB-mq-ref.xml:140
songdongsheng@668 1114 msgid ""
songdongsheng@668 1115 "<command role=\"hg-ext-mq\">qimport</command>&emdash;import a third-party "
songdongsheng@668 1116 "patch into the queue"
dongsheng@661 1117 msgstr "<command role=\"hg-ext-mq\">qimport</command>—将第三方补丁导入队列"
dongsheng@627 1118
dongsheng@627 1119 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 1120 #: ../en/appB-mq-ref.xml:143
dongsheng@627 1121 msgid ""
dongsheng@627 1122 "The <command role=\"hg-ext-mq\">qimport</command> command adds an entry for "
dongsheng@627 1123 "an external patch to the <filename role=\"special\">series</filename> file, "
dongsheng@627 1124 "and copies the patch into the <filename role=\"special\" class=\"directory\">."
dongsheng@627 1125 "hg/patches</filename> directory. It adds the entry immediately after the "
dongsheng@627 1126 "topmost applied patch, but does not push the patch."
dongsheng@627 1127 msgstr ""
dongsheng@627 1128
dongsheng@627 1129 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 1130 #: ../en/appB-mq-ref.xml:151
dongsheng@627 1131 msgid ""
dongsheng@627 1132 "If the <filename role=\"special\" class=\"directory\">.hg/patches</filename> "
dongsheng@627 1133 "directory is a repository, <command role=\"hg-ext-mq\">qimport</command> "
dongsheng@627 1134 "automatically does an <command role=\"hg-cmd\">hg add</command> of the "
dongsheng@627 1135 "imported patch."
dongsheng@627 1136 msgstr ""
dongsheng@627 1137
dongsheng@627 1138 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@714 1139 #: ../en/appB-mq-ref.xml:159
songdongsheng@668 1140 msgid ""
songdongsheng@668 1141 "<command role=\"hg-ext-mq\">qinit</command>&emdash;prepare a repository to "
songdongsheng@668 1142 "work with MQ"
dongsheng@661 1143 msgstr "<command role=\"hg-ext-mq\">qinit</command>—为使用 MQ 配置版本库"
dongsheng@627 1144
dongsheng@627 1145 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 1146 #: ../en/appB-mq-ref.xml:162
dongsheng@627 1147 msgid ""
dongsheng@627 1148 "The <command role=\"hg-ext-mq\">qinit</command> command prepares a repository "
dongsheng@627 1149 "to work with MQ. It creates a directory called <filename role=\"special\" "
dongsheng@627 1150 "class=\"directory\">.hg/patches</filename>."
dongsheng@627 1151 msgstr ""
dongsheng@627 1152
dongsheng@627 1153 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 1154 #: ../en/appB-mq-ref.xml:169
dongsheng@627 1155 msgid ""
dongsheng@627 1156 "<option role=\"hg-ext-mq-cmd-qinit-opt\">-c</option>: Create <filename role="
dongsheng@627 1157 "\"special\" class=\"directory\">.hg/patches</filename> as a repository in its "
dongsheng@627 1158 "own right. Also creates a <filename role=\"special\">.hgignore</filename> "
dongsheng@627 1159 "file that will ignore the <filename role=\"special\">status</filename> file."
dongsheng@627 1160 msgstr ""
dongsheng@627 1161
dongsheng@627 1162 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 1163 #: ../en/appB-mq-ref.xml:179
dongsheng@627 1164 msgid ""
dongsheng@627 1165 "When the <filename role=\"special\" class=\"directory\">.hg/patches</"
dongsheng@627 1166 "filename> directory is a repository, the <command role=\"hg-ext-mq\">qimport</"
dongsheng@627 1167 "command> and <command role=\"hg-ext-mq\">qnew</command> commands "
dongsheng@627 1168 "automatically <command role=\"hg-cmd\">hg add</command> new patches."
dongsheng@627 1169 msgstr ""
dongsheng@627 1170
dongsheng@627 1171 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@714 1172 #: ../en/appB-mq-ref.xml:188
songdongsheng@668 1173 msgid "<command role=\"hg-ext-mq\">qnew</command>&emdash;create a new patch"
dongsheng@661 1174 msgstr "<command role=\"hg-ext-mq\">qnew</command>—创建新补丁"
dongsheng@627 1175
dongsheng@627 1176 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 1177 #: ../en/appB-mq-ref.xml:191
dongsheng@627 1178 msgid ""
dongsheng@627 1179 "The <command role=\"hg-ext-mq\">qnew</command> command creates a new patch. "
dongsheng@627 1180 "It takes one mandatory argument, the name to use for the patch file. The "
dongsheng@627 1181 "newly created patch is created empty by default. It is added to the "
dongsheng@627 1182 "<filename role=\"special\">series</filename> file after the current topmost "
dongsheng@627 1183 "applied patch, and is immediately pushed on top of that patch."
dongsheng@627 1184 msgstr ""
dongsheng@627 1185
dongsheng@627 1186 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 1187 #: ../en/appB-mq-ref.xml:199
dongsheng@627 1188 msgid ""
dongsheng@627 1189 "If <command role=\"hg-ext-mq\">qnew</command> finds modified files in the "
dongsheng@627 1190 "working directory, it will refuse to create a new patch unless the <option "
dongsheng@627 1191 "role=\"hg-ext-mq-cmd-qnew-opt\">-f</option> option is used (see below). This "
songdongsheng@710 1192 "behavior allows you to <command role=\"hg-ext-mq\">qrefresh</command> your "
dongsheng@627 1193 "topmost applied patch before you apply a new patch on top of it."
dongsheng@627 1194 msgstr ""
dongsheng@627 1195
dongsheng@627 1196 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 1197 #: ../en/appB-mq-ref.xml:209
dongsheng@627 1198 msgid ""
dongsheng@627 1199 "<option role=\"hg-ext-mq-cmd-qnew-opt\">-f</option>: Create a new patch if "
dongsheng@627 1200 "the contents of the working directory are modified. Any outstanding "
dongsheng@627 1201 "modifications are added to the newly created patch, so after this command "
dongsheng@627 1202 "completes, the working directory will no longer be modified."
dongsheng@627 1203 msgstr ""
dongsheng@627 1204
dongsheng@627 1205 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 1206 #: ../en/appB-mq-ref.xml:216
dongsheng@627 1207 msgid ""
dongsheng@627 1208 "<option role=\"hg-ext-mq-cmd-qnew-opt\">-m</option>: Use the given text as "
dongsheng@627 1209 "the commit message. This text will be stored at the beginning of the patch "
dongsheng@627 1210 "file, before the patch data."
dongsheng@627 1211 msgstr ""
dongsheng@627 1212
dongsheng@627 1213 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@714 1214 #: ../en/appB-mq-ref.xml:225
songdongsheng@668 1215 msgid ""
songdongsheng@668 1216 "<command role=\"hg-ext-mq\">qnext</command>&emdash;print the name of the next "
songdongsheng@668 1217 "patch"
dongsheng@661 1218 msgstr "<command role=\"hg-ext-mq\">qnext</command>—显示下个补丁的名称"
dongsheng@627 1219
dongsheng@627 1220 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 1221 #: ../en/appB-mq-ref.xml:228
dongsheng@627 1222 msgid ""
dongsheng@627 1223 "The <command role=\"hg-ext-mq\">qnext</command> command prints the name name "
dongsheng@627 1224 "of the next patch in the <filename role=\"special\">series</filename> file "
dongsheng@627 1225 "after the topmost applied patch. This patch will become the topmost applied "
dongsheng@627 1226 "patch if you run <command role=\"hg-ext-mq\">qpush</command>."
dongsheng@627 1227 msgstr ""
dongsheng@627 1228
dongsheng@627 1229 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@714 1230 #: ../en/appB-mq-ref.xml:237
songdongsheng@668 1231 msgid ""
songdongsheng@668 1232 "<command role=\"hg-ext-mq\">qpop</command>&emdash;pop patches off the stack"
dongsheng@661 1233 msgstr "<command role=\"hg-ext-mq\">qpop</command>—删除堆栈顶部的补丁"
dongsheng@627 1234
dongsheng@627 1235 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 1236 #: ../en/appB-mq-ref.xml:240
dongsheng@627 1237 msgid ""
dongsheng@627 1238 "The <command role=\"hg-ext-mq\">qpop</command> command removes applied "
dongsheng@627 1239 "patches from the top of the stack of applied patches. By default, it removes "
dongsheng@627 1240 "only one patch."
dongsheng@627 1241 msgstr ""
dongsheng@627 1242
dongsheng@627 1243 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 1244 #: ../en/appB-mq-ref.xml:244
dongsheng@627 1245 msgid ""
dongsheng@627 1246 "This command removes the changesets that represent the popped patches from "
dongsheng@627 1247 "the repository, and updates the working directory to undo the effects of the "
dongsheng@627 1248 "patches."
dongsheng@627 1249 msgstr ""
dongsheng@627 1250
dongsheng@627 1251 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 1252 #: ../en/appB-mq-ref.xml:248
dongsheng@627 1253 msgid ""
dongsheng@627 1254 "This command takes an optional argument, which it uses as the name or index "
dongsheng@627 1255 "of the patch to pop to. If given a name, it will pop patches until the named "
dongsheng@627 1256 "patch is the topmost applied patch. If given a number, <command role=\"hg-"
dongsheng@627 1257 "ext-mq\">qpop</command> treats the number as an index into the entries in the "
dongsheng@627 1258 "series file, counting from zero (empty lines and lines containing only "
dongsheng@627 1259 "comments do not count). It pops patches until the patch identified by the "
dongsheng@627 1260 "given index is the topmost applied patch."
dongsheng@627 1261 msgstr ""
dongsheng@627 1262
dongsheng@627 1263 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 1264 #: ../en/appB-mq-ref.xml:258
dongsheng@627 1265 msgid ""
dongsheng@627 1266 "The <command role=\"hg-ext-mq\">qpop</command> command does not read or write "
dongsheng@627 1267 "patches or the <filename role=\"special\">series</filename> file. It is thus "
dongsheng@627 1268 "safe to <command role=\"hg-ext-mq\">qpop</command> a patch that you have "
dongsheng@627 1269 "removed from the <filename role=\"special\">series</filename> file, or a "
dongsheng@627 1270 "patch that you have renamed or deleted entirely. In the latter two cases, "
dongsheng@627 1271 "use the name of the patch as it was when you applied it."
dongsheng@627 1272 msgstr ""
dongsheng@627 1273
dongsheng@627 1274 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 1275 #: ../en/appB-mq-ref.xml:267
dongsheng@627 1276 msgid ""
dongsheng@627 1277 "By default, the <command role=\"hg-ext-mq\">qpop</command> command will not "
dongsheng@627 1278 "pop any patches if the working directory has been modified. You can override "
songdongsheng@710 1279 "this behavior using the <option role=\"hg-ext-mq-cmd-qpop-opt\">-f</option> "
dongsheng@627 1280 "option, which reverts all modifications in the working directory."
dongsheng@627 1281 msgstr ""
dongsheng@627 1282
dongsheng@627 1283 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 1284 #: ../en/appB-mq-ref.xml:276
dongsheng@627 1285 msgid ""
dongsheng@627 1286 "<option role=\"hg-ext-mq-cmd-qpop-opt\">-a</option>: Pop all applied "
dongsheng@627 1287 "patches. This returns the repository to its state before you applied any "
dongsheng@627 1288 "patches."
dongsheng@627 1289 msgstr ""
dongsheng@627 1290
dongsheng@627 1291 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 1292 #: ../en/appB-mq-ref.xml:281
dongsheng@627 1293 msgid ""
dongsheng@627 1294 "<option role=\"hg-ext-mq-cmd-qpop-opt\">-f</option>: Forcibly revert any "
dongsheng@627 1295 "modifications to the working directory when popping."
dongsheng@627 1296 msgstr ""
dongsheng@627 1297
dongsheng@627 1298 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 1299 #: ../en/appB-mq-ref.xml:286
dongsheng@627 1300 msgid ""
dongsheng@627 1301 "<option role=\"hg-ext-mq-cmd-qpop-opt\">-n</option>: Pop a patch from the "
dongsheng@627 1302 "named queue."
dongsheng@627 1303 msgstr ""
dongsheng@627 1304
dongsheng@627 1305 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 1306 #: ../en/appB-mq-ref.xml:291
dongsheng@627 1307 msgid ""
dongsheng@627 1308 "The <command role=\"hg-ext-mq\">qpop</command> command removes one line from "
dongsheng@627 1309 "the end of the <filename role=\"special\">status</filename> file for each "
dongsheng@627 1310 "patch that it pops."
dongsheng@627 1311 msgstr ""
dongsheng@627 1312
dongsheng@627 1313 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@714 1314 #: ../en/appB-mq-ref.xml:298
songdongsheng@668 1315 msgid ""
songdongsheng@668 1316 "<command role=\"hg-ext-mq\">qprev</command>&emdash;print the name of the "
songdongsheng@668 1317 "previous patch"
dongsheng@661 1318 msgstr "<command role=\"hg-ext-mq\">qprev</command>—显示上个补丁的名称"
dongsheng@627 1319
dongsheng@627 1320 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 1321 #: ../en/appB-mq-ref.xml:301
dongsheng@627 1322 msgid ""
dongsheng@627 1323 "The <command role=\"hg-ext-mq\">qprev</command> command prints the name of "
dongsheng@627 1324 "the patch in the <filename role=\"special\">series</filename> file that comes "
dongsheng@627 1325 "before the topmost applied patch. This will become the topmost applied patch "
dongsheng@627 1326 "if you run <command role=\"hg-ext-mq\">qpop</command>."
dongsheng@627 1327 msgstr ""
dongsheng@627 1328
dongsheng@627 1329 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@714 1330 #: ../en/appB-mq-ref.xml:310
songdongsheng@668 1331 msgid ""
songdongsheng@668 1332 "<command role=\"hg-ext-mq\">qpush</command>&emdash;push patches onto the stack"
dongsheng@661 1333 msgstr "<command role=\"hg-ext-mq\">qpush</command>—增加补丁到堆栈"
dongsheng@627 1334
dongsheng@627 1335 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 1336 #: ../en/appB-mq-ref.xml:313
dongsheng@627 1337 msgid ""
dongsheng@627 1338 "The <command role=\"hg-ext-mq\">qpush</command> command adds patches onto the "
dongsheng@627 1339 "applied stack. By default, it adds only one patch."
dongsheng@627 1340 msgstr ""
dongsheng@627 1341
dongsheng@627 1342 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 1343 #: ../en/appB-mq-ref.xml:317
dongsheng@627 1344 msgid ""
dongsheng@627 1345 "This command creates a new changeset to represent each applied patch, and "
dongsheng@627 1346 "updates the working directory to apply the effects of the patches."
dongsheng@627 1347 msgstr ""
dongsheng@627 1348
dongsheng@627 1349 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 1350 #: ../en/appB-mq-ref.xml:321
dongsheng@627 1351 msgid "The default data used when creating a changeset are as follows:"
dongsheng@627 1352 msgstr ""
dongsheng@627 1353
dongsheng@627 1354 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 1355 #: ../en/appB-mq-ref.xml:324
dongsheng@627 1356 msgid ""
dongsheng@627 1357 "The commit date and time zone are the current date and time zone. Because "
dongsheng@627 1358 "these data are used to compute the identity of a changeset, this means that "
dongsheng@627 1359 "if you <command role=\"hg-ext-mq\">qpop</command> a patch and <command role="
dongsheng@627 1360 "\"hg-ext-mq\">qpush</command> it again, the changeset that you push will have "
dongsheng@627 1361 "a different identity than the changeset you popped."
dongsheng@627 1362 msgstr ""
dongsheng@627 1363
dongsheng@627 1364 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 1365 #: ../en/appB-mq-ref.xml:332
dongsheng@627 1366 msgid ""
dongsheng@627 1367 "The author is the same as the default used by the <command role=\"hg-cmd\">hg "
dongsheng@627 1368 "commit</command> command."
dongsheng@627 1369 msgstr ""
dongsheng@627 1370
dongsheng@627 1371 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 1372 #: ../en/appB-mq-ref.xml:336
dongsheng@627 1373 msgid ""
dongsheng@627 1374 "The commit message is any text from the patch file that comes before the "
dongsheng@627 1375 "first diff header. If there is no such text, a default commit message is "
dongsheng@627 1376 "used that identifies the name of the patch."
dongsheng@627 1377 msgstr ""
dongsheng@627 1378
dongsheng@627 1379 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 1380 #: ../en/appB-mq-ref.xml:341
dongsheng@714 1381 msgid ""
dongsheng@714 1382 "If a patch contains a Mercurial patch header, the information in the patch "
dongsheng@714 1383 "header overrides these defaults."
dongsheng@627 1384 msgstr ""
dongsheng@627 1385
dongsheng@627 1386 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 1387 #: ../en/appB-mq-ref.xml:347
dongsheng@627 1388 msgid ""
dongsheng@627 1389 "<option role=\"hg-ext-mq-cmd-qpush-opt\">-a</option>: Push all unapplied "
dongsheng@627 1390 "patches from the <filename role=\"special\">series</filename> file until "
dongsheng@627 1391 "there are none left to push."
dongsheng@627 1392 msgstr ""
dongsheng@627 1393
dongsheng@627 1394 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 1395 #: ../en/appB-mq-ref.xml:353
dongsheng@627 1396 msgid ""
dongsheng@627 1397 "<option role=\"hg-ext-mq-cmd-qpush-opt\">-l</option>: Add the name of the "
dongsheng@627 1398 "patch to the end of the commit message."
dongsheng@627 1399 msgstr ""
dongsheng@627 1400
dongsheng@627 1401 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 1402 #: ../en/appB-mq-ref.xml:357
dongsheng@627 1403 msgid ""
dongsheng@627 1404 "<option role=\"hg-ext-mq-cmd-qpush-opt\">-m</option>: If a patch fails to "
dongsheng@627 1405 "apply cleanly, use the entry for the patch in another saved queue to compute "
dongsheng@627 1406 "the parameters for a three-way merge, and perform a three-way merge using the "
dongsheng@627 1407 "normal Mercurial merge machinery. Use the resolution of the merge as the new "
dongsheng@627 1408 "patch content."
dongsheng@627 1409 msgstr ""
dongsheng@627 1410
dongsheng@627 1411 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 1412 #: ../en/appB-mq-ref.xml:365
dongsheng@627 1413 msgid ""
dongsheng@627 1414 "<option role=\"hg-ext-mq-cmd-qpush-opt\">-n</option>: Use the named queue if "
dongsheng@627 1415 "merging while pushing."
dongsheng@627 1416 msgstr ""
dongsheng@627 1417
dongsheng@627 1418 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 1419 #: ../en/appB-mq-ref.xml:370
dongsheng@627 1420 msgid ""
dongsheng@627 1421 "The <command role=\"hg-ext-mq\">qpush</command> command reads, but does not "
dongsheng@627 1422 "modify, the <filename role=\"special\">series</filename> file. It appends "
dongsheng@627 1423 "one line to the <command role=\"hg-cmd\">hg status</command> file for each "
dongsheng@627 1424 "patch that it pushes."
dongsheng@627 1425 msgstr ""
dongsheng@627 1426
dongsheng@627 1427 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@714 1428 #: ../en/appB-mq-ref.xml:378
songdongsheng@668 1429 msgid ""
songdongsheng@668 1430 "<command role=\"hg-ext-mq\">qrefresh</command>&emdash;update the topmost "
songdongsheng@668 1431 "applied patch"
dongsheng@661 1432 msgstr "<command role=\"hg-ext-mq\">qrefresh</command>—更新最新的补丁"
dongsheng@627 1433
dongsheng@627 1434 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 1435 #: ../en/appB-mq-ref.xml:382
dongsheng@627 1436 msgid ""
dongsheng@627 1437 "The <command role=\"hg-ext-mq\">qrefresh</command> command updates the "
dongsheng@627 1438 "topmost applied patch. It modifies the patch, removes the old changeset that "
dongsheng@627 1439 "represented the patch, and creates a new changeset to represent the modified "
dongsheng@627 1440 "patch."
dongsheng@627 1441 msgstr ""
dongsheng@627 1442
dongsheng@627 1443 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 1444 #: ../en/appB-mq-ref.xml:388
dongsheng@627 1445 msgid ""
dongsheng@627 1446 "The <command role=\"hg-ext-mq\">qrefresh</command> command looks for the "
dongsheng@627 1447 "following modifications:"
dongsheng@627 1448 msgstr ""
dongsheng@627 1449
dongsheng@627 1450 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 1451 #: ../en/appB-mq-ref.xml:391
dongsheng@627 1452 msgid ""
dongsheng@627 1453 "Changes to the commit message, i.e. the text before the first diff header in "
dongsheng@627 1454 "the patch file, are reflected in the new changeset that represents the patch."
dongsheng@627 1455 msgstr ""
dongsheng@627 1456
dongsheng@627 1457 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 1458 #: ../en/appB-mq-ref.xml:396
dongsheng@627 1459 msgid ""
dongsheng@627 1460 "Modifications to tracked files in the working directory are added to the "
dongsheng@627 1461 "patch."
dongsheng@627 1462 msgstr ""
dongsheng@627 1463
dongsheng@627 1464 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 1465 #: ../en/appB-mq-ref.xml:399
dongsheng@627 1466 msgid ""
dongsheng@627 1467 "Changes to the files tracked using <command role=\"hg-cmd\">hg add</command>, "
dongsheng@627 1468 "<command role=\"hg-cmd\">hg copy</command>, <command role=\"hg-cmd\">hg "
dongsheng@627 1469 "remove</command>, or <command role=\"hg-cmd\">hg rename</command>. Added "
dongsheng@627 1470 "files and copy and rename destinations are added to the patch, while removed "
dongsheng@627 1471 "files and rename sources are removed."
dongsheng@627 1472 msgstr ""
dongsheng@627 1473
dongsheng@627 1474 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 1475 #: ../en/appB-mq-ref.xml:408
dongsheng@627 1476 msgid ""
dongsheng@627 1477 "Even if <command role=\"hg-ext-mq\">qrefresh</command> detects no changes, it "
dongsheng@627 1478 "still recreates the changeset that represents the patch. This causes the "
dongsheng@627 1479 "identity of the changeset to differ from the previous changeset that "
dongsheng@627 1480 "identified the patch."
dongsheng@627 1481 msgstr ""
dongsheng@627 1482
dongsheng@627 1483 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 1484 #: ../en/appB-mq-ref.xml:416
dongsheng@627 1485 msgid ""
dongsheng@627 1486 "<option role=\"hg-ext-mq-cmd-qrefresh-opt\">-e</option>: Modify the commit "
dongsheng@627 1487 "and patch description, using the preferred text editor."
dongsheng@627 1488 msgstr ""
dongsheng@627 1489
dongsheng@627 1490 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 1491 #: ../en/appB-mq-ref.xml:421
dongsheng@627 1492 msgid ""
dongsheng@627 1493 "<option role=\"hg-ext-mq-cmd-qrefresh-opt\">-m</option>: Modify the commit "
dongsheng@627 1494 "message and patch description, using the given text."
dongsheng@627 1495 msgstr ""
dongsheng@627 1496
dongsheng@627 1497 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 1498 #: ../en/appB-mq-ref.xml:426
dongsheng@627 1499 msgid ""
dongsheng@627 1500 "<option role=\"hg-ext-mq-cmd-qrefresh-opt\">-l</option>: Modify the commit "
dongsheng@627 1501 "message and patch description, using text from the given file."
dongsheng@627 1502 msgstr ""
dongsheng@627 1503
dongsheng@627 1504 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@714 1505 #: ../en/appB-mq-ref.xml:434
songdongsheng@668 1506 msgid "<command role=\"hg-ext-mq\">qrename</command>&emdash;rename a patch"
dongsheng@661 1507 msgstr "<command role=\"hg-ext-mq\">qrename</command>—改名补丁"
dongsheng@627 1508
dongsheng@627 1509 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 1510 #: ../en/appB-mq-ref.xml:437
dongsheng@627 1511 msgid ""
dongsheng@627 1512 "The <command role=\"hg-ext-mq\">qrename</command> command renames a patch, "
dongsheng@627 1513 "and changes the entry for the patch in the <filename role=\"special\">series</"
dongsheng@627 1514 "filename> file."
dongsheng@627 1515 msgstr ""
dongsheng@627 1516
dongsheng@627 1517 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 1518 #: ../en/appB-mq-ref.xml:441
dongsheng@627 1519 msgid ""
dongsheng@627 1520 "With a single argument, <command role=\"hg-ext-mq\">qrename</command> renames "
dongsheng@627 1521 "the topmost applied patch. With two arguments, it renames its first argument "
dongsheng@627 1522 "to its second."
dongsheng@627 1523 msgstr ""
dongsheng@627 1524
dongsheng@627 1525 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@714 1526 #: ../en/appB-mq-ref.xml:448
songdongsheng@668 1527 msgid ""
songdongsheng@668 1528 "<command role=\"hg-ext-mq\">qseries</command>&emdash;print the entire patch "
songdongsheng@668 1529 "series"
dongsheng@661 1530 msgstr "<command role=\"hg-ext-mq\">qseries</command>—显示补丁序列"
dongsheng@627 1531
dongsheng@627 1532 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 1533 #: ../en/appB-mq-ref.xml:451
dongsheng@627 1534 msgid ""
dongsheng@627 1535 "The <command role=\"hg-ext-mq\">qseries</command> command prints the entire "
dongsheng@627 1536 "patch series from the <filename role=\"special\">series</filename> file. It "
dongsheng@627 1537 "prints only patch names, not empty lines or comments. It prints in order "
dongsheng@627 1538 "from first to be applied to last."
dongsheng@627 1539 msgstr ""
dongsheng@627 1540
dongsheng@627 1541 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@714 1542 #: ../en/appB-mq-ref.xml:459
songdongsheng@668 1543 msgid ""
songdongsheng@668 1544 "<command role=\"hg-ext-mq\">qtop</command>&emdash;print the name of the "
songdongsheng@668 1545 "current patch"
dongsheng@661 1546 msgstr "<command role=\"hg-ext-mq\">qtop</command>—显示当前补丁的名称"
dongsheng@627 1547
dongsheng@627 1548 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 1549 #: ../en/appB-mq-ref.xml:462
dongsheng@627 1550 msgid ""
dongsheng@627 1551 "The <command role=\"hg-ext-mq\">qtop</command> prints the name of the topmost "
dongsheng@627 1552 "currently applied patch."
dongsheng@627 1553 msgstr ""
dongsheng@627 1554
dongsheng@627 1555 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@714 1556 #: ../en/appB-mq-ref.xml:467
songdongsheng@668 1557 msgid ""
songdongsheng@668 1558 "<command role=\"hg-ext-mq\">qunapplied</command>&emdash;print patches not yet "
songdongsheng@668 1559 "applied"
dongsheng@661 1560 msgstr "<command role=\"hg-ext-mq\">qunapplied</command>—显示尚未应用的补丁"
dongsheng@627 1561
dongsheng@627 1562 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 1563 #: ../en/appB-mq-ref.xml:471
dongsheng@627 1564 msgid ""
dongsheng@627 1565 "The <command role=\"hg-ext-mq\">qunapplied</command> command prints the names "
dongsheng@627 1566 "of patches from the <filename role=\"special\">series</filename> file that "
dongsheng@627 1567 "are not yet applied. It prints them in order from the next patch that will "
dongsheng@627 1568 "be pushed to the last."
dongsheng@627 1569 msgstr ""
dongsheng@627 1570
dongsheng@627 1571 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@714 1572 #: ../en/appB-mq-ref.xml:479
songdongsheng@668 1573 msgid ""
songdongsheng@668 1574 "<command role=\"hg-cmd\">hg strip</command>&emdash;remove a revision and "
songdongsheng@668 1575 "descendants"
dongsheng@661 1576 msgstr "<command role=\"hg-cmd\">hg strip</command>—删除一个版本及其后继"
dongsheng@627 1577
dongsheng@627 1578 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 1579 #: ../en/appB-mq-ref.xml:482
dongsheng@627 1580 msgid ""
dongsheng@627 1581 "The <command role=\"hg-cmd\">hg strip</command> command removes a revision, "
dongsheng@627 1582 "and all of its descendants, from the repository. It undoes the effects of "
dongsheng@627 1583 "the removed revisions from the repository, and updates the working directory "
dongsheng@627 1584 "to the first parent of the removed revision."
dongsheng@627 1585 msgstr ""
dongsheng@627 1586
dongsheng@627 1587 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 1588 #: ../en/appB-mq-ref.xml:488
dongsheng@627 1589 msgid ""
dongsheng@627 1590 "The <command role=\"hg-cmd\">hg strip</command> command saves a backup of the "
dongsheng@627 1591 "removed changesets in a bundle, so that they can be reapplied if removed in "
dongsheng@627 1592 "error."
dongsheng@627 1593 msgstr ""
dongsheng@627 1594
dongsheng@627 1595 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 1596 #: ../en/appB-mq-ref.xml:494
dongsheng@627 1597 msgid ""
dongsheng@627 1598 "<option role=\"hg-opt-strip\">-b</option>: Save unrelated changesets that are "
dongsheng@627 1599 "intermixed with the stripped changesets in the backup bundle."
dongsheng@627 1600 msgstr ""
dongsheng@627 1601
dongsheng@627 1602 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 1603 #: ../en/appB-mq-ref.xml:498
dongsheng@627 1604 msgid ""
dongsheng@627 1605 "<option role=\"hg-opt-strip\">-f</option>: If a branch has multiple heads, "
dongsheng@714 1606 "remove all heads."
dongsheng@627 1607 msgstr ""
dongsheng@627 1608
dongsheng@627 1609 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 1610 #: ../en/appB-mq-ref.xml:501
dongsheng@714 1611 msgid "<option role=\"hg-opt-strip\">-n</option>: Do not save a backup bundle."
dongsheng@714 1612 msgstr ""
dongsheng@714 1613
dongsheng@714 1614 #. type: Content of: <book><appendix><sect1><title>
dongsheng@650 1615 #: ../en/appB-mq-ref.xml:508
dongsheng@627 1616 msgid "MQ file reference"
dongsheng@627 1617 msgstr "MQ 文件参考"
dongsheng@627 1618
dongsheng@627 1619 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@714 1620 #: ../en/appB-mq-ref.xml:511
dongsheng@627 1621 msgid "The <filename role=\"special\">series</filename> file"
dongsheng@627 1622 msgstr "<filename role=\"special\">序列</filename>文件"
dongsheng@627 1623
dongsheng@627 1624 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 1625 #: ../en/appB-mq-ref.xml:514
dongsheng@627 1626 msgid ""
dongsheng@627 1627 "The <filename role=\"special\">series</filename> file contains a list of the "
dongsheng@627 1628 "names of all patches that MQ can apply. It is represented as a list of "
dongsheng@627 1629 "names, with one name saved per line. Leading and trailing white space in "
dongsheng@627 1630 "each line are ignored."
dongsheng@627 1631 msgstr ""
dongsheng@627 1632
dongsheng@627 1633 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 1634 #: ../en/appB-mq-ref.xml:520
dongsheng@627 1635 msgid ""
dongsheng@627 1636 "Lines may contain comments. A comment begins with the <quote><literal>#</"
dongsheng@627 1637 "literal></quote> character, and extends to the end of the line. Empty lines, "
dongsheng@627 1638 "and lines that contain only comments, are ignored."
dongsheng@627 1639 msgstr ""
dongsheng@627 1640
dongsheng@627 1641 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 1642 #: ../en/appB-mq-ref.xml:525
dongsheng@627 1643 msgid ""
dongsheng@627 1644 "You will often need to edit the <filename role=\"special\">series</filename> "
dongsheng@627 1645 "file by hand, hence the support for comments and empty lines noted above. "
dongsheng@627 1646 "For example, you can comment out a patch temporarily, and <command role=\"hg-"
dongsheng@627 1647 "ext-mq\">qpush</command> will skip over that patch when applying patches. "
dongsheng@627 1648 "You can also change the order in which patches are applied by reordering "
dongsheng@627 1649 "their entries in the <filename role=\"special\">series</filename> file."
dongsheng@627 1650 msgstr ""
dongsheng@627 1651
dongsheng@627 1652 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 1653 #: ../en/appB-mq-ref.xml:534
dongsheng@627 1654 msgid ""
dongsheng@627 1655 "Placing the <filename role=\"special\">series</filename> file under revision "
dongsheng@627 1656 "control is also supported; it is a good idea to place all of the patches that "
dongsheng@627 1657 "it refers to under revision control, as well. If you create a patch "
dongsheng@627 1658 "directory using the <option role=\"hg-ext-mq-cmd-qinit-opt\">-c</option> "
dongsheng@627 1659 "option to <command role=\"hg-ext-mq\">qinit</command>, this will be done for "
dongsheng@627 1660 "you automatically."
dongsheng@627 1661 msgstr ""
dongsheng@627 1662
dongsheng@627 1663 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@714 1664 #: ../en/appB-mq-ref.xml:544
dongsheng@627 1665 msgid "The <filename role=\"special\">status</filename> file"
dongsheng@627 1666 msgstr "<filename role=\"special\">状态</filename>文件"
dongsheng@627 1667
dongsheng@627 1668 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@714 1669 #: ../en/appB-mq-ref.xml:547
dongsheng@627 1670 msgid ""
dongsheng@627 1671 "The <filename role=\"special\">status</filename> file contains the names and "
dongsheng@627 1672 "changeset hashes of all patches that MQ currently has applied. Unlike the "
dongsheng@627 1673 "<filename role=\"special\">series</filename> file, this file is not intended "
dongsheng@627 1674 "for editing. You should not place this file under revision control, or "
dongsheng@627 1675 "modify it in any way. It is used by MQ strictly for internal book-keeping."
dongsheng@627 1676 msgstr ""
dongsheng@627 1677
dongsheng@627 1678 #. type: Content of: <book><appendix><title>
dongsheng@627 1679 #: ../en/appC-srcinstall.xml:5
dongsheng@627 1680 msgid "Installing Mercurial from source"
dongsheng@627 1681 msgstr "从源代码安装 Mercurial"
dongsheng@627 1682
dongsheng@627 1683 #. type: Content of: <book><appendix><sect1><title>
dongsheng@627 1684 #: ../en/appC-srcinstall.xml:8
dongsheng@627 1685 msgid "On a Unix-like system"
dongsheng@627 1686 msgstr "类 Unix 系统"
dongsheng@627 1687
dongsheng@627 1688 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 1689 #: ../en/appC-srcinstall.xml:10
dongsheng@627 1690 msgid ""
dongsheng@627 1691 "If you are using a Unix-like system that has a sufficiently recent version of "
dongsheng@627 1692 "Python (2.3 or newer) available, it is easy to install Mercurial from source."
dongsheng@627 1693 msgstr ""
songdongsheng@711 1694 "如果你使用类 Unix 系统,并且有足够新的 Python (2.3 更新),从源代码安装 "
songdongsheng@711 1695 "Mercurial 就很容易了。"
dongsheng@627 1696
dongsheng@627 1697 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
dongsheng@627 1698 #: ../en/appC-srcinstall.xml:14
dongsheng@627 1699 msgid ""
dongsheng@627 1700 "Download a recent source tarball from <ulink url=\"http://www.selenic.com/"
dongsheng@627 1701 "mercurial/download\">http://www.selenic.com/mercurial/download</ulink>."
dongsheng@627 1702 msgstr ""
songdongsheng@711 1703 "从 <ulink url=\"http://www.selenic.com/mercurial/download\">http://www."
songdongsheng@711 1704 "selenic.com/mercurial/download</ulink> 下载最新的源代码。"
dongsheng@627 1705
dongsheng@627 1706 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
dongsheng@627 1707 #: ../en/appC-srcinstall.xml:17
dongsheng@627 1708 msgid "Unpack the tarball:"
songdongsheng@711 1709 msgstr "解压:"
dongsheng@627 1710
dongsheng@627 1711 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
dongsheng@627 1712 #: ../en/appC-srcinstall.xml:20
dongsheng@627 1713 msgid ""
dongsheng@627 1714 "Go into the source directory and run the installer script. This will build "
dongsheng@627 1715 "Mercurial and install it in your home directory."
songdongsheng@711 1716 msgstr "进入源代码目录,执行安装教本。这会构建 Mercurial,安装到你的家目录。"
dongsheng@627 1717
dongsheng@627 1718 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 1719 #: ../en/appC-srcinstall.xml:27
dongsheng@627 1720 msgid ""
dongsheng@627 1721 "Once the install finishes, Mercurial will be in the <literal>bin</literal> "
dongsheng@627 1722 "subdirectory of your home directory. Don't forget to make sure that this "
dongsheng@627 1723 "directory is present in your shell's search path."
dongsheng@627 1724 msgstr ""
songdongsheng@711 1725 "安装完成后,Mercurial 就位于家目录的 <literal>bin</literal> 子目录。不要忘记将"
songdongsheng@711 1726 "这个目录加入到你的可执行文件搜索路径中。"
dongsheng@627 1727
dongsheng@627 1728 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 1729 #: ../en/appC-srcinstall.xml:32
dongsheng@627 1730 msgid ""
dongsheng@627 1731 "You will probably need to set the <envar>PYTHONPATH</envar> environment "
dongsheng@627 1732 "variable so that the Mercurial executable can find the rest of the Mercurial "
dongsheng@627 1733 "packages. For example, on my laptop, I have set it to <literal>/home/bos/lib/"
dongsheng@627 1734 "python</literal>. The exact path that you will need to use depends on how "
dongsheng@627 1735 "Python was built for your system, but should be easy to figure out. If "
dongsheng@627 1736 "you're uncertain, look through the output of the installer script above, and "
dongsheng@627 1737 "see where the contents of the <literal>mercurial</literal> directory were "
dongsheng@627 1738 "installed to."
dongsheng@627 1739 msgstr ""
songdongsheng@711 1740 "你可能需要设置环境变量 <envar>PYTHONPATH</envar>,以便 Mercurial 可执行文件能"
songdongsheng@711 1741 "找到 Mercurial 包。例如,在我的笔记本电脑中,必须设置为 <literal>/home/bos/"
songdongsheng@711 1742 "lib/python</literal>。你需要使用的路径依赖于 Python 的构建方式,这很容易找出"
songdongsheng@711 1743 "来。如果你不确定,仔细察看上面的安装脚本输出,检查包含 <literal>mercurial</"
songdongsheng@711 1744 "literal> 目录的内容的安装位置。"
dongsheng@627 1745
dongsheng@627 1746 #. type: Content of: <book><appendix><sect1><title>
dongsheng@627 1747 #: ../en/appC-srcinstall.xml:44
dongsheng@627 1748 msgid "On Windows"
dongsheng@627 1749 msgstr "Windows 系统"
dongsheng@627 1750
dongsheng@627 1751 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 1752 #: ../en/appC-srcinstall.xml:46
dongsheng@627 1753 msgid ""
dongsheng@627 1754 "Building and installing Mercurial on Windows requires a variety of tools, a "
dongsheng@627 1755 "fair amount of technical knowledge, and considerable patience. I very much "
dongsheng@627 1756 "<emphasis>do not recommend</emphasis> this route if you are a <quote>casual "
dongsheng@627 1757 "user</quote>. Unless you intend to hack on Mercurial, I strongly suggest "
dongsheng@627 1758 "that you use a binary package instead."
dongsheng@627 1759 msgstr ""
songdongsheng@711 1760 "在 Windows 中构建和安装 Mercurial 需要各种工具,相当多的技术背景,以及足够的耐"
songdongsheng@711 1761 "心。如果你是一个<quote>初级用户</quote>,我<emphasis>很不赞成</emphasis>这个方"
songdongsheng@711 1762 "法。我强烈建议你使用二进制安装包,除非你想深入研究 Mercurial 本身。"
dongsheng@627 1763
dongsheng@627 1764 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 1765 #: ../en/appC-srcinstall.xml:53
dongsheng@627 1766 msgid ""
dongsheng@627 1767 "If you are intent on building Mercurial from source on Windows, follow the "
dongsheng@627 1768 "<quote>hard way</quote> directions on the Mercurial wiki at <ulink url="
dongsheng@627 1769 "\"http://www.selenic.com/mercurial/wiki/index.cgi/WindowsInstall\">http://www."
dongsheng@627 1770 "selenic.com/mercurial/wiki/index.cgi/WindowsInstall</ulink>, and expect the "
dongsheng@627 1771 "process to involve a lot of fiddly work."
dongsheng@627 1772 msgstr ""
songdongsheng@711 1773 "If you are intent on building Mercurial from source on Windows, follow the "
songdongsheng@711 1774 "<quote>hard way</quote> directions on the Mercurial wiki at <ulink url="
songdongsheng@711 1775 "\"http://www.selenic.com/mercurial/wiki/index.cgi/WindowsInstall\">http://www."
songdongsheng@711 1776 "selenic.com/mercurial/wiki/index.cgi/WindowsInstall</ulink>, and expect the "
songdongsheng@711 1777 "process to involve a lot of fiddly work."
dongsheng@627 1778
dongsheng@627 1779 #. type: Content of: <book><appendix><title>
dongsheng@627 1780 #: ../en/appD-license.xml:5
dongsheng@627 1781 msgid "Open Publication License"
songdongsheng@711 1782 msgstr "开放出版协议"
dongsheng@627 1783
dongsheng@627 1784 #. type: Content of: <book><appendix><para>
dongsheng@627 1785 #: ../en/appD-license.xml:7
dongsheng@627 1786 msgid "Version 1.0, 8 June 1999"
songdongsheng@711 1787 msgstr "版本 1.0,1999 年 6 月 8 日。"
dongsheng@627 1788
dongsheng@627 1789 #. type: Content of: <book><appendix><sect1><title>
dongsheng@627 1790 #: ../en/appD-license.xml:10
dongsheng@627 1791 msgid "Requirements on both unmodified and modified versions"
dongsheng@627 1792 msgstr ""
dongsheng@627 1793
dongsheng@627 1794 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 1795 #: ../en/appD-license.xml:13
dongsheng@627 1796 msgid ""
dongsheng@627 1797 "The Open Publication works may be reproduced and distributed in whole or in "
dongsheng@627 1798 "part, in any medium physical or electronic, provided that the terms of this "
dongsheng@627 1799 "license are adhered to, and that this license or an incorporation of it by "
dongsheng@627 1800 "reference (with any options elected by the author(s) and/or publisher) is "
dongsheng@627 1801 "displayed in the reproduction."
dongsheng@627 1802 msgstr ""
dongsheng@627 1803
dongsheng@627 1804 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 1805 #: ../en/appD-license.xml:20
dongsheng@627 1806 msgid "Proper form for an incorporation by reference is as follows:"
dongsheng@627 1807 msgstr ""
dongsheng@627 1808
dongsheng@627 1809 #. type: Content of: <book><appendix><sect1><blockquote><para>
dongsheng@627 1810 #: ../en/appD-license.xml:24
dongsheng@627 1811 msgid ""
dongsheng@627 1812 "Copyright (c) <emphasis>year</emphasis> by <emphasis>author's name or "
dongsheng@627 1813 "designee</emphasis>. This material may be distributed only subject to the "
dongsheng@627 1814 "terms and conditions set forth in the Open Publication License, v<emphasis>x."
dongsheng@627 1815 "y</emphasis> or later (the latest version is presently available at <ulink "
dongsheng@627 1816 "url=\"http://www.opencontent.org/openpub/\">http://www.opencontent.org/"
dongsheng@627 1817 "openpub/</ulink>)."
dongsheng@627 1818 msgstr ""
dongsheng@627 1819
dongsheng@627 1820 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 1821 #: ../en/appD-license.xml:33
dongsheng@627 1822 msgid ""
dongsheng@627 1823 "The reference must be immediately followed with any options elected by the "
songdongsheng@658 1824 "author(s) and/or publisher of the document (see <xref linkend=\"sec:opl:"
songdongsheng@658 1825 "options\"/>)."
dongsheng@627 1826 msgstr ""
dongsheng@627 1827
dongsheng@627 1828 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 1829 #: ../en/appD-license.xml:37
dongsheng@627 1830 msgid ""
dongsheng@627 1831 "Commercial redistribution of Open Publication-licensed material is permitted."
dongsheng@627 1832 msgstr ""
dongsheng@627 1833
dongsheng@627 1834 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 1835 #: ../en/appD-license.xml:40
dongsheng@627 1836 msgid ""
dongsheng@627 1837 "Any publication in standard (paper) book form shall require the citation of "
dongsheng@627 1838 "the original publisher and author. The publisher and author's names shall "
dongsheng@627 1839 "appear on all outer surfaces of the book. On all outer surfaces of the book "
dongsheng@627 1840 "the original publisher's name shall be as large as the title of the work and "
dongsheng@627 1841 "cited as possessive with respect to the title."
dongsheng@627 1842 msgstr ""
dongsheng@627 1843
dongsheng@627 1844 #. type: Content of: <book><appendix><sect1><title>
dongsheng@627 1845 #: ../en/appD-license.xml:49
dongsheng@627 1846 msgid "Copyright"
dongsheng@627 1847 msgstr ""
dongsheng@627 1848
dongsheng@627 1849 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 1850 #: ../en/appD-license.xml:51
dongsheng@627 1851 msgid ""
dongsheng@627 1852 "The copyright to each Open Publication is owned by its author(s) or designee."
dongsheng@627 1853 msgstr ""
dongsheng@627 1854
dongsheng@627 1855 #. type: Content of: <book><appendix><sect1><title>
dongsheng@627 1856 #: ../en/appD-license.xml:56
dongsheng@627 1857 msgid "Scope of license"
dongsheng@627 1858 msgstr ""
dongsheng@627 1859
dongsheng@627 1860 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 1861 #: ../en/appD-license.xml:58
dongsheng@627 1862 msgid ""
dongsheng@627 1863 "The following license terms apply to all Open Publication works, unless "
dongsheng@627 1864 "otherwise explicitly stated in the document."
dongsheng@627 1865 msgstr ""
dongsheng@627 1866
dongsheng@627 1867 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 1868 #: ../en/appD-license.xml:62
dongsheng@627 1869 msgid ""
dongsheng@627 1870 "Mere aggregation of Open Publication works or a portion of an Open "
dongsheng@627 1871 "Publication work with other works or programs on the same media shall not "
dongsheng@627 1872 "cause this license to apply to those other works. The aggregate work shall "
dongsheng@627 1873 "contain a notice specifying the inclusion of the Open Publication material "
dongsheng@627 1874 "and appropriate copyright notice."
dongsheng@627 1875 msgstr ""
dongsheng@627 1876
dongsheng@627 1877 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 1878 #: ../en/appD-license.xml:69
dongsheng@627 1879 msgid ""
dongsheng@627 1880 "<emphasis role=\"bold\">Severability</emphasis>. If any part of this license "
dongsheng@627 1881 "is found to be unenforceable in any jurisdiction, the remaining portions of "
dongsheng@627 1882 "the license remain in force."
dongsheng@627 1883 msgstr ""
dongsheng@627 1884
dongsheng@627 1885 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 1886 #: ../en/appD-license.xml:74
dongsheng@627 1887 msgid ""
dongsheng@627 1888 "<emphasis role=\"bold\">No warranty</emphasis>. Open Publication works are "
dongsheng@627 1889 "licensed and provided <quote>as is</quote> without warranty of any kind, "
dongsheng@627 1890 "express or implied, including, but not limited to, the implied warranties of "
dongsheng@627 1891 "merchantability and fitness for a particular purpose or a warranty of non-"
dongsheng@627 1892 "infringement."
dongsheng@627 1893 msgstr ""
dongsheng@627 1894
dongsheng@627 1895 #. type: Content of: <book><appendix><sect1><title>
dongsheng@627 1896 #: ../en/appD-license.xml:83
dongsheng@627 1897 msgid "Requirements on modified works"
dongsheng@627 1898 msgstr ""
dongsheng@627 1899
dongsheng@627 1900 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 1901 #: ../en/appD-license.xml:85
dongsheng@627 1902 msgid ""
dongsheng@627 1903 "All modified versions of documents covered by this license, including "
dongsheng@627 1904 "translations, anthologies, compilations and partial documents, must meet the "
dongsheng@627 1905 "following requirements:"
dongsheng@627 1906 msgstr ""
dongsheng@627 1907
dongsheng@627 1908 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
dongsheng@627 1909 #: ../en/appD-license.xml:90
dongsheng@627 1910 msgid "The modified version must be labeled as such."
dongsheng@627 1911 msgstr ""
dongsheng@627 1912
dongsheng@627 1913 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
dongsheng@627 1914 #: ../en/appD-license.xml:93
dongsheng@627 1915 msgid ""
dongsheng@627 1916 "The person making the modifications must be identified and the modifications "
dongsheng@627 1917 "dated."
dongsheng@627 1918 msgstr ""
dongsheng@627 1919
dongsheng@627 1920 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
dongsheng@627 1921 #: ../en/appD-license.xml:96
dongsheng@627 1922 msgid ""
dongsheng@627 1923 "Acknowledgement of the original author and publisher if applicable must be "
dongsheng@627 1924 "retained according to normal academic citation practices."
dongsheng@627 1925 msgstr ""
dongsheng@627 1926
dongsheng@627 1927 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
dongsheng@627 1928 #: ../en/appD-license.xml:100
dongsheng@627 1929 msgid "The location of the original unmodified document must be identified."
dongsheng@627 1930 msgstr ""
dongsheng@627 1931
dongsheng@627 1932 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
dongsheng@627 1933 #: ../en/appD-license.xml:103
dongsheng@627 1934 msgid ""
dongsheng@627 1935 "The original author's (or authors') name(s) may not be used to assert or "
dongsheng@627 1936 "imply endorsement of the resulting document without the original author's (or "
dongsheng@627 1937 "authors') permission."
dongsheng@627 1938 msgstr ""
dongsheng@627 1939
dongsheng@627 1940 #. type: Content of: <book><appendix><sect1><title>
dongsheng@627 1941 #: ../en/appD-license.xml:111
dongsheng@627 1942 msgid "Good-practice recommendations"
dongsheng@627 1943 msgstr ""
dongsheng@627 1944
dongsheng@627 1945 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 1946 #: ../en/appD-license.xml:113
dongsheng@627 1947 msgid ""
dongsheng@627 1948 "In addition to the requirements of this license, it is requested from and "
dongsheng@627 1949 "strongly recommended of redistributors that:"
dongsheng@627 1950 msgstr ""
dongsheng@627 1951
dongsheng@627 1952 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
dongsheng@627 1953 #: ../en/appD-license.xml:118
dongsheng@627 1954 msgid ""
dongsheng@627 1955 "If you are distributing Open Publication works on hardcopy or CD-ROM, you "
dongsheng@627 1956 "provide email notification to the authors of your intent to redistribute at "
dongsheng@627 1957 "least thirty days before your manuscript or media freeze, to give the authors "
dongsheng@627 1958 "time to provide updated documents. This notification should describe "
dongsheng@627 1959 "modifications, if any, made to the document."
dongsheng@627 1960 msgstr ""
dongsheng@627 1961
dongsheng@627 1962 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
dongsheng@627 1963 #: ../en/appD-license.xml:125
dongsheng@627 1964 msgid ""
dongsheng@627 1965 "All substantive modifications (including deletions) be either clearly marked "
dongsheng@627 1966 "up in the document or else described in an attachment to the document."
dongsheng@627 1967 msgstr ""
dongsheng@627 1968
dongsheng@627 1969 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
dongsheng@627 1970 #: ../en/appD-license.xml:129
dongsheng@627 1971 msgid ""
dongsheng@627 1972 "Finally, while it is not mandatory under this license, it is considered good "
dongsheng@627 1973 "form to offer a free copy of any hardcopy and CD-ROM expression of an Open "
dongsheng@627 1974 "Publication-licensed work to its author(s)."
dongsheng@627 1975 msgstr ""
dongsheng@627 1976
dongsheng@627 1977 #. type: Content of: <book><appendix><sect1><title>
dongsheng@627 1978 #: ../en/appD-license.xml:137
dongsheng@627 1979 msgid "License options"
dongsheng@627 1980 msgstr ""
dongsheng@627 1981
dongsheng@627 1982 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 1983 #: ../en/appD-license.xml:139
dongsheng@627 1984 msgid ""
dongsheng@627 1985 "The author(s) and/or publisher of an Open Publication-licensed document may "
dongsheng@627 1986 "elect certain options by appending language to the reference to or copy of "
dongsheng@627 1987 "the license. These options are considered part of the license instance and "
dongsheng@627 1988 "must be included with the license (or its incorporation by reference) in "
dongsheng@627 1989 "derived works."
dongsheng@627 1990 msgstr ""
dongsheng@627 1991
dongsheng@627 1992 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
dongsheng@627 1993 #: ../en/appD-license.xml:147
dongsheng@627 1994 msgid ""
dongsheng@627 1995 "To prohibit distribution of substantively modified versions without the "
dongsheng@627 1996 "explicit permission of the author(s). <quote>Substantive modification</quote> "
dongsheng@627 1997 "is defined as a change to the semantic content of the document, and excludes "
dongsheng@627 1998 "mere changes in format or typographical corrections."
dongsheng@627 1999 msgstr ""
dongsheng@627 2000
dongsheng@627 2001 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
dongsheng@627 2002 #: ../en/appD-license.xml:154
dongsheng@627 2003 msgid ""
dongsheng@627 2004 "To accomplish this, add the phrase <quote>Distribution of substantively "
dongsheng@627 2005 "modified versions of this document is prohibited without the explicit "
dongsheng@627 2006 "permission of the copyright holder.</quote> to the license reference or copy."
dongsheng@627 2007 msgstr ""
dongsheng@627 2008
dongsheng@627 2009 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
dongsheng@627 2010 #: ../en/appD-license.xml:160
dongsheng@627 2011 msgid ""
dongsheng@627 2012 "To prohibit any publication of this work or derivative works in whole or in "
dongsheng@627 2013 "part in standard (paper) book form for commercial purposes is prohibited "
dongsheng@627 2014 "unless prior permission is obtained from the copyright holder."
dongsheng@627 2015 msgstr ""
dongsheng@627 2016
dongsheng@627 2017 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
dongsheng@627 2018 #: ../en/appD-license.xml:165
dongsheng@627 2019 msgid ""
dongsheng@627 2020 "To accomplish this, add the phrase <quote>Distribution of the work or "
dongsheng@627 2021 "derivative of the work in any standard (paper) book form is prohibited unless "
dongsheng@627 2022 "prior permission is obtained from the copyright holder.</quote> to the "
dongsheng@627 2023 "license reference or copy."
dongsheng@627 2024 msgstr ""
dongsheng@627 2025
dongsheng@653 2026 #. type: Content of: <book><preface><title>
dongsheng@653 2027 #: ../en/ch00-preface.xml:5
dongsheng@653 2028 msgid "Preface"
dongsheng@653 2029 msgstr "序言"
dongsheng@653 2030
dongsheng@653 2031 #. type: Content of: <book><preface><sect1><title>
dongsheng@653 2032 #: ../en/ch00-preface.xml:8
dongsheng@714 2033 msgid "Technical storytelling"
dongsheng@715 2034 msgstr "技术背景"
dongsheng@714 2035
dongsheng@714 2036 #. type: Content of: <book><preface><sect1><para>
dongsheng@714 2037 #: ../en/ch00-preface.xml:10
dongsheng@714 2038 msgid ""
dongsheng@714 2039 "A few years ago, when I wanted to explain why I believed that distributed "
dongsheng@714 2040 "revision control is important, the field was then so new that there was "
dongsheng@714 2041 "almost no published literature to refer people to."
dongsheng@714 2042 msgstr ""
zhaopingsun@1036 2043 "数年之前,当我想解释为什么我相信分布式版本控制非常重要的时候,这个领域实在太新"
zhaopingsun@1036 2044 "了,几乎没有公开的文献供人们参考。"
dongsheng@714 2045
dongsheng@714 2046 #. type: Content of: <book><preface><sect1><para>
dongsheng@714 2047 #: ../en/ch00-preface.xml:15
dongsheng@714 2048 msgid ""
dongsheng@714 2049 "Although at that time I spent some time working on the internals of Mercurial "
dongsheng@714 2050 "itself, I switched to writing this book because that seemed like the most "
dongsheng@714 2051 "effective way to help the software to reach a wide audience, along with the "
dongsheng@714 2052 "idea that revision control ought to be distributed in nature. I publish the "
dongsheng@714 2053 "book online under a liberal license for the same reason: to get the word out."
dongsheng@714 2054 msgstr ""
zhaopingsun@1036 2055 "虽然在那个时候,我已经在Mercurial的内核上花了一些时间,我转而写这本书是因为我"
zhaopingsun@1036 2056 "发现这可能是帮助软件吸引更多用户,和让大家接受版本控制本质上就应该是分布式的最"
zhaopingsun@1036 2057 "有效的方式,我把这本书在网上以自由许可的方式发布也是基于同样的原因:让大家都了"
zhaopingsun@1036 2058 "解。"
dongsheng@714 2059
dongsheng@714 2060 #. type: Content of: <book><preface><sect1><para>
dongsheng@714 2061 #: ../en/ch00-preface.xml:23
dongsheng@714 2062 msgid ""
dongsheng@714 2063 "There's a familiar rhythm to a good software book that closely resembles "
dongsheng@714 2064 "telling a story: What is this thing? Why does it matter? How will it help me? "
dongsheng@714 2065 "How do I use it? In this book, I try to answer those questions for "
dongsheng@714 2066 "distributed revision control in general, and for Mercurial in particular."
dongsheng@714 2067 msgstr ""
zhaopingsun@1036 2068 "一本好的关于软件的书应该和讲故事类似:这是个什么东西?为什么需要它?它会怎样帮"
zhaopingsun@1036 2069 "助我?我怎么使用它?本书中,我会为分布式版本控制回答这些问题,特别是"
zhaopingsun@1036 2070 "Mercurial。"
dongsheng@714 2071
dongsheng@714 2072 #. type: Content of: <book><preface><sect1><title>
dongsheng@714 2073 #: ../en/ch00-preface.xml:31
dongsheng@714 2074 msgid "Thank you for supporting Mercurial"
dongsheng@716 2075 msgstr "谢谢你支持 Mercurial"
dongsheng@714 2076
dongsheng@714 2077 #. type: Content of: <book><preface><sect1><para>
dongsheng@714 2078 #: ../en/ch00-preface.xml:33
dongsheng@714 2079 msgid ""
dongsheng@714 2080 "By purchasing a copy of this book, you are supporting the continued "
dongsheng@714 2081 "development and freedom of Mercurial in particular, and of open source and "
dongsheng@714 2082 "free software in general. O'Reilly Media and I are donating my royalties on "
dongsheng@714 2083 "the sales of this book to the Software Freedom Conservancy (<ulink url="
dongsheng@714 2084 "\"http://www.softwarefreedom.org/\">http://www.softwarefreedom.org/</ulink>) "
dongsheng@714 2085 "which provides clerical and legal support to Mercurial and a number of other "
dongsheng@714 2086 "prominent and worthy open source software projects."
dongsheng@714 2087 msgstr ""
zhaopingsun@1036 2088 "通过购买此书,你支持了开源和自由软件的持续发展和自由,特别是Mercurial。"
zhaopingsun@1036 2089 "O'Reilly Media和我将本书的收入捐献给Software Freedom Conservancy (<ulink url="
zhaopingsun@1036 2090 "\"http://www.softwarefreedom.org/\">http://www.softwarefreedom.org/</ulink>) ,"
zhaopingsun@1036 2091 "这个组织为Mercurial和其他一些有潜力和价值的开源软件项目提供了办公和法律支持。"
dongsheng@714 2092
dongsheng@714 2093 #. type: Content of: <book><preface><sect1><title>
dongsheng@714 2094 #: ../en/ch00-preface.xml:45
dongsheng@714 2095 msgid "Acknowledgments"
dongsheng@716 2096 msgstr "致谢"
dongsheng@714 2097
dongsheng@714 2098 #. type: Content of: <book><preface><sect1><para>
dongsheng@714 2099 #: ../en/ch00-preface.xml:47
dongsheng@714 2100 msgid ""
dongsheng@714 2101 "This book would not exist were it not for the efforts of Matt Mackall, the "
dongsheng@714 2102 "author and project lead of Mercurial. He is ably assisted by hundreds of "
dongsheng@714 2103 "volunteer contributors across the world."
dongsheng@714 2104 msgstr ""
zhaopingsun@1036 2105 "没有Matt Mackall,Mercurial项目的开发者和领导的努力,这本书不可能存在。他得到"
zhaopingsun@1036 2106 "了全球数以百计的志愿者的帮助。"
dongsheng@714 2107
dongsheng@714 2108 #. type: Content of: <book><preface><sect1><para>
dongsheng@714 2109 #: ../en/ch00-preface.xml:52
dongsheng@714 2110 msgid ""
dongsheng@714 2111 "My children, Cian and Ruairi, always stood ready to help me to unwind with "
dongsheng@714 2112 "wonderful, madcap little-boy games. I'd also like to thank my ex-wife, "
dongsheng@714 2113 "Shannon, for her support."
dongsheng@714 2114 msgstr ""
dongsheng@714 2115
dongsheng@714 2116 #. type: Content of: <book><preface><sect1><para>
dongsheng@714 2117 #: ../en/ch00-preface.xml:56
dongsheng@714 2118 msgid ""
dongsheng@714 2119 "My colleagues and friends provided help and support in innumerable ways. "
dongsheng@714 2120 "This list of people is necessarily very incomplete: Stephen Hahn, Karyn "
dongsheng@714 2121 "Ritter, Bonnie Corwin, James Vasile, Matt Norwood, Eben Moglen, Bradley Kuhn, "
dongsheng@714 2122 "Robert Walsh, Jeremy Fitzhardinge, Rachel Chalmers."
dongsheng@714 2123 msgstr ""
zhaopingsun@1036 2124 "我的同事和朋友以各种方式提供了帮助和支持,这里的名单非常不全:Stephen Hahn, "
zhaopingsun@1036 2125 "Karyn Ritter, Bonnie Corwin, James Vasile, Matt Norwood, Eben Moglen, Bradley "
zhaopingsun@1036 2126 "Kuhn, Robert Walsh, Jeremy Fitzhardinge, Rachel Chalmers."
dongsheng@714 2127
dongsheng@714 2128 #. type: Content of: <book><preface><sect1><para>
dongsheng@714 2129 #: ../en/ch00-preface.xml:62
dongsheng@714 2130 msgid ""
dongsheng@714 2131 "I developed this book in the open, posting drafts of chapters to the book web "
dongsheng@714 2132 "site as I completed them. Readers then submitted feedback using a web "
dongsheng@714 2133 "application that I developed. By the time I finished writing the book, more "
dongsheng@714 2134 "than 100 people had submitted comments, an amazing number considering that "
dongsheng@714 2135 "the comment system was live for only about two months towards the end of the "
dongsheng@714 2136 "writing process."
dongsheng@714 2137 msgstr ""
zhaopingsun@1036 2138 "我以开放的方式完成了本书,当我完成各章的草稿后,就将其放在了网上。读者可以使用"
zhaopingsun@1036 2139 "我开发的一个网络程序提交反馈。到我完成本书时,有100多人提交了评论。考虑到评论"
zhaopingsun@1036 2140 "系统是在写作完成之前两个月才开放的,这是一个惊人的数字。"
dongsheng@714 2141
dongsheng@714 2142 #. type: Content of: <book><preface><sect1><para>
dongsheng@714 2143 #: ../en/ch00-preface.xml:70
dongsheng@714 2144 msgid ""
dongsheng@714 2145 "I would particularly like to recognize the following people, who between them "
dongsheng@714 2146 "contributed over a third of the total number of comments. I would like to "
dongsheng@714 2147 "thank them for their care and effort in providing so much detailed feedback."
dongsheng@714 2148 msgstr ""
zhaopingsun@1036 2149 "我特别希望认识以下人员,他们中有的人提交了超过总数三分之一的评论。我要感谢他们"
zhaopingsun@1036 2150 "的关心和努力,提供了那么多详细的反馈。"
dongsheng@714 2151
dongsheng@714 2152 #. type: Content of: <book><preface><sect1><para>
dongsheng@714 2153 #: ../en/ch00-preface.xml:75
dongsheng@714 2154 msgid ""
dongsheng@714 2155 "Martin Geisler, Damien Cassou, Alexey Bakhirkin, Till Plewe, Dan Himes, Paul "
dongsheng@714 2156 "Sargent, Gokberk Hamurcu, Matthijs van der Vleuten, Michael Chermside, John "
dongsheng@714 2157 "Mulligan, Jordi Fita, Jon Parise."
dongsheng@714 2158 msgstr ""
dongsheng@714 2159
dongsheng@714 2160 #. type: Content of: <book><preface><sect1><para>
dongsheng@714 2161 #: ../en/ch00-preface.xml:80
dongsheng@714 2162 msgid ""
dongsheng@714 2163 "I also want to acknowledge the help of the many people who caught errors and "
dongsheng@714 2164 "provided helpful suggestions throughout the book."
zhaopingsun@1036 2165 msgstr "我同样要感谢许多在书中找出错误和提供了有帮助的建议的人。"
dongsheng@714 2166
dongsheng@714 2167 #. type: Content of: <book><preface><sect1><para>
dongsheng@714 2168 #: ../en/ch00-preface.xml:84
dongsheng@714 2169 msgid ""
dongsheng@714 2170 "Jeremy W. Sherman, Brian Mearns, Vincent Furia, Iwan Luijks, Billy Edwards, "
dongsheng@714 2171 "Andreas Sliwka, Paweł Sołyga, Eric Hanchrow, Steve Nicolai, Michał Masłowski, "
dongsheng@714 2172 "Kevin Fitch, Johan Holmberg, Hal Wine, Volker Simonis, Thomas P Jakobsen, Ted "
dongsheng@714 2173 "Stresen-Reuter, Stephen Rasku, Raphael Das Gupta, Ned Batchelder, Lou Keeble, "
dongsheng@714 2174 "Li Linxiao, Kao Cardoso Félix, Joseph Wecker, Jon Prescot, Jon Maken, John "
dongsheng@714 2175 "Yeary, Jason Harris, Geoffrey Zheng, Fredrik Jonson, Ed Davies, David "
dongsheng@714 2176 "Zumbrunnen, David Mercer, David Cabana, Ben Karel, Alan Franzoni, Yousry "
dongsheng@714 2177 "Abdallah, Whitney Young, Vinay Sajip, Tom Towle, Tim Ottinger, Thomas "
dongsheng@714 2178 "Schraitle, Tero Saarni, Ted Mielczarek, Svetoslav Agafonkin, Shaun Rowland, "
dongsheng@714 2179 "Rocco Rutte, Polo-Francois Poli, Philip Jenvey, Petr Tesałék, Peter R. "
dongsheng@714 2180 "Annema, Paul Bonser, Olivier Scherler, Olivier Fournier, Nick Parker, Nick "
dongsheng@714 2181 "Fabry, Nicholas Guarracino, Mike Driscoll, Mike Coleman, Mietek Bák, Michael "
dongsheng@714 2182 "Maloney, László Nagy, Kent Johnson, Julio Nobrega, Jord Fita, Jonathan March, "
dongsheng@714 2183 "Jonas Nockert, Jim Tittsler, Jeduan Cornejo Legorreta, Jan Larres, James "
dongsheng@714 2184 "Murphy, Henri Wiechers, Hagen Möbius, Gábor Farkas, Fabien Engels, Evert Rol, "
dongsheng@714 2185 "Evan Willms, Eduardo Felipe Castegnaro, Dennis Decker Jensen, Deniz Dogan, "
dongsheng@714 2186 "David Smith, Daed Lee, Christine Slotty, Charles Merriam, Guillaume Catto, "
dongsheng@714 2187 "Brian Dorsey, Bob Nystrom, Benoit Boissinot, Avi Rosenschein, Andrew Watts, "
dongsheng@714 2188 "Andrew Donkin, Alexey Rodriguez, Ahmed Chaudhary."
dongsheng@714 2189 msgstr ""
dongsheng@714 2190
dongsheng@714 2191 #. type: Content of: <book><preface><sect1><title>
dongsheng@714 2192 #: ../en/ch00-preface.xml:111
dongsheng@714 2193 msgid "Conventions Used in This Book"
dongsheng@716 2194 msgstr "本书的约定"
dongsheng@714 2195
dongsheng@714 2196 #. type: Content of: <book><preface><sect1><para>
dongsheng@714 2197 #: ../en/ch00-preface.xml:113
dongsheng@714 2198 msgid "The following typographical conventions are used in this book:"
dongsheng@716 2199 msgstr "本书使用如下的印刷约定:"
dongsheng@714 2200
dongsheng@714 2201 #. type: Content of: <book><preface><sect1><variablelist><varlistentry><term>
dongsheng@714 2202 #: ../en/ch00-preface.xml:118
dongsheng@714 2203 msgid "Italic"
dongsheng@716 2204 msgstr "斜体"
dongsheng@714 2205
dongsheng@714 2206 #. type: Content of: <book><preface><sect1><variablelist><varlistentry><listitem><para>
dongsheng@714 2207 #: ../en/ch00-preface.xml:121
dongsheng@714 2208 msgid ""
dongsheng@714 2209 "Indicates new terms, URLs, email addresses, filenames, and file extensions."
dongsheng@716 2210 msgstr "标识新术语,URL,电子邮件地址,文件名称与扩展名。"
dongsheng@714 2211
dongsheng@714 2212 #. type: Content of: <book><preface><sect1><variablelist><varlistentry><term>
dongsheng@714 2213 #: ../en/ch00-preface.xml:127
dongsheng@714 2214 msgid "<literal>Constant width</literal>"
dongsheng@716 2215 msgstr "<literal>等宽</literal>"
dongsheng@714 2216
dongsheng@714 2217 #. type: Content of: <book><preface><sect1><variablelist><varlistentry><listitem><para>
dongsheng@714 2218 #: ../en/ch00-preface.xml:130
dongsheng@714 2219 msgid ""
dongsheng@714 2220 "Used for program listings, as well as within paragraphs to refer to program "
dongsheng@714 2221 "elements such as variable or function names, databases, data types, "
dongsheng@714 2222 "environment variables, statements, and keywords."
dongsheng@714 2223 msgstr ""
dongsheng@716 2224 "用于程序列表,以及段内引用的程序元素,例如变量、函数名称、数据库、数据类型、环"
dongsheng@716 2225 "境变量、声明和关键字。"
dongsheng@714 2226
dongsheng@714 2227 #. type: Content of: <book><preface><sect1><variablelist><varlistentry><term>
dongsheng@714 2228 #: ../en/ch00-preface.xml:138
dongsheng@714 2229 msgid "<userinput>Constant width bold</userinput>"
dongsheng@716 2230 msgstr "<userinput>等宽粗体</userinput>"
dongsheng@714 2231
dongsheng@714 2232 #. type: Content of: <book><preface><sect1><variablelist><varlistentry><listitem><para>
dongsheng@714 2233 #: ../en/ch00-preface.xml:141
dongsheng@714 2234 msgid "Shows commands or other text that should be typed literally by the user."
dongsheng@716 2235 msgstr "标识命令或者其它用户应该逐字输入的文本。"
dongsheng@714 2236
dongsheng@714 2237 #. type: Content of: <book><preface><sect1><variablelist><varlistentry><term>
dongsheng@714 2238 #: ../en/ch00-preface.xml:147
dongsheng@714 2239 msgid "<replaceable>Constant width italic</replaceable>"
dongsheng@716 2240 msgstr "<replaceable>等宽斜体</replaceable>"
dongsheng@714 2241
dongsheng@714 2242 #. type: Content of: <book><preface><sect1><variablelist><varlistentry><listitem><para>
dongsheng@714 2243 #: ../en/ch00-preface.xml:150
dongsheng@714 2244 msgid ""
dongsheng@714 2245 "Shows text that should be replaced with user-supplied values or by values "
dongsheng@714 2246 "determined by context."
dongsheng@716 2247 msgstr "标识应该被用户提供的值或者取决于上下文的值替换的文本。"
dongsheng@714 2248
dongsheng@714 2249 #. type: Content of: <book><preface><sect1><tip><para>
dongsheng@714 2250 #: ../en/ch00-preface.xml:157
dongsheng@714 2251 msgid "This icon signifies a tip, suggestion, or general note."
dongsheng@716 2252 msgstr "此图标表示提示,建议或者一般的的注释。"
dongsheng@714 2253
dongsheng@714 2254 #. type: Content of: <book><preface><sect1><caution><para>
dongsheng@714 2255 #: ../en/ch00-preface.xml:162
dongsheng@714 2256 msgid "This icon indicates a warning or caution."
dongsheng@716 2257 msgstr "此图标表示警告。"
dongsheng@714 2258
dongsheng@714 2259 #. type: Content of: <book><preface><sect1><title>
dongsheng@714 2260 #: ../en/ch00-preface.xml:167
dongsheng@714 2261 msgid "Using Code Examples"
dongsheng@716 2262 msgstr "使用样例代码"
dongsheng@714 2263
dongsheng@714 2264 #. type: Content of: <book><preface><sect1><para>
dongsheng@714 2265 #: ../en/ch00-preface.xml:169
dongsheng@714 2266 msgid ""
dongsheng@714 2267 "This book is here to help you get your job done. In general, you may use the "
dongsheng@714 2268 "code in this book in your programs and documentation. You do not need to "
dongsheng@714 2269 "contact us for permission unless you’re reproducing a significant portion of "
dongsheng@714 2270 "the code. For example, writing a program that uses several chunks of code "
dongsheng@714 2271 "from this book does not require permission. Selling or distributing a CD-ROM "
dongsheng@714 2272 "of examples from O’Reilly books does require permission. Answering a "
dongsheng@714 2273 "question by citing this book and quoting example code does not require "
dongsheng@714 2274 "permission. Incorporating a significant amount of example code from this book "
dongsheng@714 2275 "into your product’s documentation does require permission."
dongsheng@714 2276 msgstr ""
dongsheng@714 2277
dongsheng@714 2278 #. type: Content of: <book><preface><sect1><para>
dongsheng@714 2279 #: ../en/ch00-preface.xml:181
dongsheng@714 2280 msgid ""
dongsheng@714 2281 "We appreciate, but do not require, attribution. An attribution usually "
dongsheng@714 2282 "includes the title, author, publisher, and ISBN. For example: “<emphasis>Book "
dongsheng@714 2283 "Title</emphasis> by Some Author. Copyright 2008 O’Reilly Media, Inc., 978-0-"
dongsheng@714 2284 "596-xxxx-x.”"
dongsheng@714 2285 msgstr ""
dongsheng@714 2286
dongsheng@714 2287 #. type: Content of: <book><preface><sect1><para>
dongsheng@714 2288 #: ../en/ch00-preface.xml:187
dongsheng@714 2289 msgid ""
dongsheng@714 2290 "If you feel your use of code examples falls outside fair use or the "
dongsheng@714 2291 "permission given above, feel free to contact us at <email>permissions@oreilly."
dongsheng@714 2292 "com</email>."
dongsheng@714 2293 msgstr ""
dongsheng@714 2294
dongsheng@714 2295 #. type: Content of: <book><preface><sect1><title>
dongsheng@714 2296 #: ../en/ch00-preface.xml:193
dongsheng@714 2297 msgid "Safari® Books Online"
dongsheng@716 2298 msgstr "Safari® 在线书库"
dongsheng@714 2299
dongsheng@714 2300 #. type: Content of: <book><preface><sect1><note><para>
dongsheng@714 2301 #: ../en/ch00-preface.xml:196
dongsheng@714 2302 msgid ""
dongsheng@714 2303 "When you see a Safari® Books Online icon on the cover of your favorite "
dongsheng@714 2304 "technology book, that means the book is available online through the O’Reilly "
dongsheng@714 2305 "Network Safari Bookshelf."
dongsheng@714 2306 msgstr ""
dongsheng@714 2307
dongsheng@714 2308 #. type: Content of: <book><preface><sect1><para>
dongsheng@714 2309 #: ../en/ch00-preface.xml:202
dongsheng@714 2310 msgid ""
dongsheng@714 2311 "Safari offers a solution that’s better than e-books. It’s a virtual library "
dongsheng@714 2312 "that lets you easily search thousands of top tech books, cut and paste code "
dongsheng@714 2313 "samples, download chapters, and find quick answers when you need the most "
dongsheng@714 2314 "accurate, current information. Try it for free at <ulink role=\"orm:hideurl:"
dongsheng@714 2315 "ital\" url=\"http://my.safaribooksonline.com/?portal=oreilly\">http://my."
dongsheng@714 2316 "safaribooksonline.com</ulink>."
dongsheng@714 2317 msgstr ""
dongsheng@714 2318
dongsheng@714 2319 #. type: Content of: <book><preface><sect1><title>
dongsheng@714 2320 #: ../en/ch00-preface.xml:211
dongsheng@714 2321 msgid "How to Contact Us"
dongsheng@716 2322 msgstr "联系我们"
dongsheng@714 2323
dongsheng@714 2324 #. type: Content of: <book><preface><sect1><para>
dongsheng@714 2325 #: ../en/ch00-preface.xml:213
dongsheng@714 2326 msgid ""
dongsheng@714 2327 "Please address comments and questions concerning this book to the publisher:"
dongsheng@714 2328 msgstr ""
dongsheng@714 2329
dongsheng@714 2330 #. type: Content of: <book><preface><sect1><simplelist><member>
dongsheng@714 2331 #: ../en/ch00-preface.xml:217
dongsheng@714 2332 msgid "O’Reilly Media, Inc."
dongsheng@714 2333 msgstr ""
dongsheng@714 2334
dongsheng@714 2335 #. type: Content of: <book><preface><sect1><simplelist><member>
dongsheng@714 2336 #: ../en/ch00-preface.xml:219
dongsheng@714 2337 msgid "1005 Gravenstein Highway North"
dongsheng@714 2338 msgstr ""
dongsheng@714 2339
dongsheng@714 2340 #. type: Content of: <book><preface><sect1><simplelist><member>
dongsheng@714 2341 #: ../en/ch00-preface.xml:221
dongsheng@714 2342 msgid "Sebastopol, CA 95472"
dongsheng@714 2343 msgstr ""
dongsheng@714 2344
dongsheng@714 2345 #. type: Content of: <book><preface><sect1><simplelist><member>
dongsheng@714 2346 #: ../en/ch00-preface.xml:223
dongsheng@714 2347 msgid "800-998-9938 (in the United States or Canada)"
dongsheng@714 2348 msgstr ""
dongsheng@714 2349
dongsheng@714 2350 #. type: Content of: <book><preface><sect1><simplelist><member>
dongsheng@714 2351 #: ../en/ch00-preface.xml:225
dongsheng@714 2352 msgid "707-829-0515 (international or local)"
dongsheng@714 2353 msgstr ""
dongsheng@714 2354
dongsheng@714 2355 #. type: Content of: <book><preface><sect1><simplelist><member>
dongsheng@714 2356 #: ../en/ch00-preface.xml:227
dongsheng@714 2357 msgid "707 829-0104 (fax)"
dongsheng@714 2358 msgstr ""
dongsheng@714 2359
dongsheng@714 2360 #. type: Content of: <book><preface><sect1><para>
dongsheng@714 2361 #: ../en/ch00-preface.xml:230
dongsheng@714 2362 msgid ""
dongsheng@714 2363 "We have a web page for this book, where we list errata, examples, and any "
dongsheng@714 2364 "additional information. You can access this page at:"
dongsheng@714 2365 msgstr ""
dongsheng@714 2366
dongsheng@714 2367 #. type: Content of: <book><preface><sect1><simplelist><member>
dongsheng@714 2368 #: ../en/ch00-preface.xml:235
dongsheng@714 2369 msgid ""
dongsheng@714 2370 "<ulink url=\"http://www.oreilly.com/catalog/&lt;catalog page&gt;\"></ulink>"
dongsheng@714 2371 msgstr ""
dongsheng@714 2372
dongsheng@714 2373 #. type: Content of: <book><preface><sect1><remark>
dongsheng@714 2374 #: ../en/ch00-preface.xml:239
dongsheng@714 2375 msgid "Don’t forget to update the &lt;url&gt; attribute, too."
dongsheng@714 2376 msgstr ""
dongsheng@714 2377
dongsheng@714 2378 #. type: Content of: <book><preface><sect1><para>
dongsheng@714 2379 #: ../en/ch00-preface.xml:242
dongsheng@714 2380 msgid "To comment or ask technical questions about this book, send email to:"
dongsheng@714 2381 msgstr ""
dongsheng@714 2382
dongsheng@714 2383 #. type: Content of: <book><preface><sect1><simplelist><member>
dongsheng@714 2384 #: ../en/ch00-preface.xml:246
dongsheng@714 2385 msgid "<email>bookquestions@oreilly.com</email>"
dongsheng@715 2386 msgstr "<email>bookquestions@oreilly.com</email>"
dongsheng@714 2387
dongsheng@714 2388 #. type: Content of: <book><preface><sect1><para>
dongsheng@714 2389 #: ../en/ch00-preface.xml:249
dongsheng@714 2390 msgid ""
dongsheng@714 2391 "For more information about our books, conferences, Resource Centers, and the "
dongsheng@714 2392 "O’Reilly Network, see our web site at:"
dongsheng@714 2393 msgstr ""
dongsheng@714 2394
dongsheng@714 2395 #. type: Content of: <book><preface><sect1><simplelist><member>
dongsheng@714 2396 #: ../en/ch00-preface.xml:253
dongsheng@714 2397 msgid "<ulink url=\"http://www.oreilly.com\"></ulink>"
dongsheng@715 2398 msgstr "<ulink url=\"http://www.oreilly.com\"></ulink>"
dongsheng@714 2399
dongsheng@714 2400 #. type: Content of: <book><chapter><title>
dongsheng@714 2401 #: ../en/ch01-intro.xml:5
dongsheng@714 2402 msgid "How did we get here?"
dongsheng@876 2403 msgstr "写在前面"
dongsheng@714 2404
dongsheng@714 2405 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 2406 #: ../en/ch01-intro.xml:8
dongsheng@653 2407 msgid "Why revision control? Why Mercurial?"
dongsheng@653 2408 msgstr "为什么使用版本控制? 为什么使用 Mercurial?"
dongsheng@653 2409
dongsheng@714 2410 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 2411 #: ../en/ch01-intro.xml:10
dongsheng@653 2412 msgid ""
dongsheng@653 2413 "Revision control is the process of managing multiple versions of a piece of "
dongsheng@653 2414 "information. In its simplest form, this is something that many people do by "
dongsheng@653 2415 "hand: every time you modify a file, save it under a new name that contains a "
dongsheng@653 2416 "number, each one higher than the number of the preceding version."
dongsheng@653 2417 msgstr ""
zhaopingsun@1036 2418 "版本控制是管理一些信息的多个版本的过程。它最简单的形式莫过于:每次你修改一个文"
zhaopingsun@1036 2419 "件后都重新命名保存,文件名中包含一个数字,每次修改后这个数字都增加。这通常是许"
zhaopingsun@1036 2420 "多人手工完成的。"
dongsheng@653 2421
dongsheng@714 2422 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 2423 #: ../en/ch01-intro.xml:16
dongsheng@653 2424 msgid ""
dongsheng@653 2425 "Manually managing multiple versions of even a single file is an error-prone "
dongsheng@653 2426 "task, though, so software tools to help automate this process have long been "
dongsheng@653 2427 "available. The earliest automated revision control tools were intended to "
dongsheng@653 2428 "help a single user to manage revisions of a single file. Over the past few "
dongsheng@653 2429 "decades, the scope of revision control tools has expanded greatly; they now "
dongsheng@653 2430 "manage multiple files, and help multiple people to work together. The best "
dongsheng@653 2431 "modern revision control tools have no problem coping with thousands of people "
dongsheng@653 2432 "working together on projects that consist of hundreds of thousands of files."
dongsheng@653 2433 msgstr ""
zhaopingsun@1036 2434 "然而,手工管理即使是一个文件的多个版本也是很容易出错的,所以很早就有软件工具来"
zhaopingsun@1036 2435 "使这个过程自动化。最早的自动化软件管理工具的目标是帮助一个用户管理一个文件的版"
zhaopingsun@1036 2436 "本。在过去的几十年里,版本控制工具的范围得到极大扩展;现在它们可以管理多个文"
zhaopingsun@1036 2437 "件,帮助许多人一起工作。最新的版本控制工具可以支持上包含成数十万个文件,几千个"
zhaopingsun@1036 2438 "人一起工作的项目。"
dongsheng@653 2439
dongsheng@714 2440 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 2441 #: ../en/ch01-intro.xml:27
dongsheng@653 2442 msgid ""
dongsheng@653 2443 "The arrival of distributed revision control is relatively recent, and so far "
dongsheng@653 2444 "this new field has grown due to people's willingness to explore ill-charted "
dongsheng@653 2445 "territory."
dongsheng@653 2446 msgstr ""
zhaopingsun@1036 2447 "分布式版本控制是最近才出现的,但是由于人们愿意探索新的疆域,目前这一新的领域已"
zhaopingsun@1036 2448 "经得到了长足的发展"
dongsheng@653 2449
dongsheng@714 2450 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 2451 #: ../en/ch01-intro.xml:31
dongsheng@653 2452 msgid ""
dongsheng@653 2453 "I am writing a book about distributed revision control because I believe that "
dongsheng@653 2454 "it is an important subject that deserves a field guide. I chose to write "
dongsheng@653 2455 "about Mercurial because it is the easiest tool to learn the terrain with, and "
dongsheng@653 2456 "yet it scales to the demands of real, challenging environments where many "
dongsheng@653 2457 "other revision control tools buckle."
dongsheng@653 2458 msgstr ""
zhaopingsun@1036 2459 "我写这本关于分布式版本控制的书是因为我相信这个领域应该有一个指南。我选择"
zhaopingsun@1036 2460 "Mercurial是因为它是在这个领域中学习最容易上手的工具,并且它能够满足真实的,挑"
zhaopingsun@1036 2461 "战性的环境的要求,而其他版本控制工具只能望而兴叹。"
dongsheng@653 2462
dongsheng@714 2463 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 2464 #: ../en/ch01-intro.xml:39
dongsheng@653 2465 msgid "Why use revision control?"
dongsheng@653 2466 msgstr "为什么使用版本控制?"
dongsheng@653 2467
dongsheng@714 2468 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 2469 #: ../en/ch01-intro.xml:41
dongsheng@653 2470 msgid ""
dongsheng@653 2471 "There are a number of reasons why you or your team might want to use an "
dongsheng@653 2472 "automated revision control tool for a project."
dongsheng@653 2473 msgstr ""
zhaopingsun@1036 2474 "为什么你或者你的团队可能需要在项目中使用自动化版本控制工具呢?有很多理由。"
dongsheng@653 2475
dongsheng@714 2476 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 2477 #: ../en/ch01-intro.xml:46
dongsheng@653 2478 msgid ""
dongsheng@653 2479 "It will track the history and evolution of your project, so you don't have "
dongsheng@653 2480 "to. For every change, you'll have a log of <emphasis>who</emphasis> made it; "
dongsheng@653 2481 "<emphasis>why</emphasis> they made it; <emphasis>when</emphasis> they made "
dongsheng@653 2482 "it; and <emphasis>what</emphasis> the change was."
dongsheng@653 2483 msgstr ""
zhaopingsun@1036 2484 "因为它能记录你的项目的历史和演化,所以你不必再给每个变更都记录日志,<emphasis>"
zhaopingsun@1036 2485 "谁</emphasis>做的;<emphasis>为什么</emphasis>他们这样做;<emphasis>什么时候</"
zhaopingsun@1036 2486 "emphasis>做的;做了<emphasis>什么</emphasis>修改。"
dongsheng@653 2487
dongsheng@714 2488 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 2489 #: ../en/ch01-intro.xml:53
dongsheng@653 2490 msgid ""
dongsheng@653 2491 "When you're working with other people, revision control software makes it "
dongsheng@653 2492 "easier for you to collaborate. For example, when people more or less "
dongsheng@653 2493 "simultaneously make potentially incompatible changes, the software will help "
dongsheng@653 2494 "you to identify and resolve those conflicts."
dongsheng@653 2495 msgstr ""
zhaopingsun@1036 2496 "当你和其他人一起工作的时候,版本控制工具让你合作的更容易。例如,当许多人或多或"
zhaopingsun@1036 2497 "少的同时进行有可能冲突的修改的时候,软件可以帮助你确定和解决这些冲突。"
dongsheng@653 2498
dongsheng@714 2499 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 2500 #: ../en/ch01-intro.xml:59
dongsheng@653 2501 msgid ""
dongsheng@653 2502 "It can help you to recover from mistakes. If you make a change that later "
dongsheng@653 2503 "turns out to be in error, you can revert to an earlier version of one or more "
dongsheng@653 2504 "files. In fact, a <emphasis>really</emphasis> good revision control tool "
dongsheng@653 2505 "will even help you to efficiently figure out exactly when a problem was "
songdongsheng@658 2506 "introduced (see <xref linkend=\"sec:undo:bisect\"/> for details)."
dongsheng@653 2507 msgstr ""
zhaopingsun@1036 2508 "它能帮助你修正错误。如果你做了一个修改,但是后来发现这是个错误,你能恢复到一个"
zhaopingsun@1036 2509 "或者多个文件以前的版本。实际上,一个<emphasis>相当</emphasis>好的版本控制工具"
zhaopingsun@1036 2510 "甚至会帮助你找出什么什么是时候引入的这个问题(详细信息参考<xref linkend=\"sec:"
zhaopingsun@1036 2511 "undo:bisect\"/>)。 "
dongsheng@653 2512
dongsheng@714 2513 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 2514 #: ../en/ch01-intro.xml:66
dongsheng@653 2515 msgid ""
dongsheng@653 2516 "It will help you to work simultaneously on, and manage the drift between, "
dongsheng@653 2517 "multiple versions of your project."
zhaopingsun@1036 2518 msgstr "它能帮助你同时工作于项目的多个版本,并管理它们的差异。"
dongsheng@653 2519
dongsheng@714 2520 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 2521 #: ../en/ch01-intro.xml:71
dongsheng@653 2522 msgid ""
songdongsheng@668 2523 "Most of these reasons are equally valid&emdash;at least in theory&emdash;"
songdongsheng@668 2524 "whether you're working on a project by yourself, or with a hundred other "
songdongsheng@668 2525 "people."
dongsheng@653 2526 msgstr ""
zhaopingsun@1036 2527 "大多数这些理由都是等效的&emdash;至少在理论上&emdash;不管你是一个人做项目还是和"
zhaopingsun@1036 2528 "几百个人一起。"
dongsheng@653 2529
dongsheng@714 2530 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 2531 #: ../en/ch01-intro.xml:76
dongsheng@653 2532 msgid ""
dongsheng@653 2533 "A key question about the practicality of revision control at these two "
dongsheng@653 2534 "different scales (<quote>lone hacker</quote> and <quote>huge team</quote>) is "
dongsheng@653 2535 "how its <emphasis>benefits</emphasis> compare to its <emphasis>costs</"
dongsheng@653 2536 "emphasis>. A revision control tool that's difficult to understand or use is "
dongsheng@653 2537 "going to impose a high cost."
dongsheng@653 2538 msgstr ""
zhaopingsun@1036 2539 "版本控制在在不同尺度上(<quote>单个黑客</quote>和<quote>一个大项目组</quote>)"
zhaopingsun@1036 2540 "实践的一个关键问题是它的<emphasis>性价</emphasis>比怎么样。一个很难理解和使用"
zhaopingsun@1036 2541 "的版本控制工具会让你的代价很高。"
dongsheng@653 2542
dongsheng@714 2543 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 2544 #: ../en/ch01-intro.xml:84
dongsheng@653 2545 msgid ""
dongsheng@653 2546 "A five-hundred-person project is likely to collapse under its own weight "
dongsheng@653 2547 "almost immediately without a revision control tool and process. In this case, "
dongsheng@653 2548 "the cost of using revision control might hardly seem worth considering, since "
dongsheng@653 2549 "<emphasis>without</emphasis> it, failure is almost guaranteed."
dongsheng@653 2550 msgstr ""
zhaopingsun@1036 2551 "如果没有版本控制工具和过程,一个五百人的项目很快就可能就将自己压垮。在这种情况"
zhaopingsun@1036 2552 "下,版本控制的代价基本上不用考虑,因为没有它,失败几乎是一定的。"
dongsheng@653 2553
dongsheng@714 2554 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 2555 #: ../en/ch01-intro.xml:91
dongsheng@653 2556 msgid ""
dongsheng@653 2557 "On the other hand, a one-person <quote>quick hack</quote> might seem like a "
dongsheng@653 2558 "poor place to use a revision control tool, because surely the cost of using "
dongsheng@653 2559 "one must be close to the overall cost of the project. Right?"
dongsheng@653 2560 msgstr ""
zhaopingsun@1036 2561 "另一方面,一个人的<quote>快速编程</quote>看起来并不适合使用版本控制工具,因为"
zhaopingsun@1036 2562 "使用一个版本控制工具的代价就是整个项目的代价,对吧?"
dongsheng@653 2563
dongsheng@714 2564 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 2565 #: ../en/ch01-intro.xml:96
dongsheng@653 2566 msgid ""
dongsheng@653 2567 "Mercurial uniquely supports <emphasis>both</emphasis> of these scales of "
dongsheng@653 2568 "development. You can learn the basics in just a few minutes, and due to its "
dongsheng@653 2569 "low overhead, you can apply revision control to the smallest of projects with "
dongsheng@653 2570 "ease. Its simplicity means you won't have a lot of abstruse concepts or "
dongsheng@653 2571 "command sequences competing for mental space with whatever you're "
dongsheng@653 2572 "<emphasis>really</emphasis> trying to do. At the same time, Mercurial's high "
dongsheng@653 2573 "performance and peer-to-peer nature let you scale painlessly to handle large "
dongsheng@653 2574 "projects."
dongsheng@653 2575 msgstr ""
zhaopingsun@1036 2576 "Mercurial的独特之处就是它<emphasis>同时</emphasis>支持这两种尺度的开发。你可以"
zhaopingsun@1036 2577 "在几分钟之内学会基本的使用,因为代价很小,你可以很方便的在最小的项目上应用版本"
zhaopingsun@1036 2578 "管理。它的简洁性意味着不会有很多艰深的概念和命令干扰你<emphasis>真正</"
zhaopingsun@1036 2579 "emphasis>的工作。同时,Mercurial高性能和点对点的特性可以让你轻易的应对大的项"
zhaopingsun@1036 2580 "目。"
dongsheng@653 2581
dongsheng@714 2582 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 2583 #: ../en/ch01-intro.xml:106
dongsheng@653 2584 msgid ""
dongsheng@653 2585 "No revision control tool can rescue a poorly run project, but a good choice "
dongsheng@653 2586 "of tools can make a huge difference to the fluidity with which you can work "
dongsheng@653 2587 "on a project."
dongsheng@653 2588 msgstr ""
zhaopingsun@1036 2589 "没有一个版本控制工具能拯救一个糟糕的项目,但是在项目中选择好的工具会大大的提高"
zhaopingsun@1036 2590 "效率,正是工欲善其事,必先利其器。"
dongsheng@653 2591
dongsheng@714 2592 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 2593 #: ../en/ch01-intro.xml:113
dongsheng@653 2594 msgid "The many names of revision control"
dongsheng@653 2595 msgstr "版本控制的别名"
dongsheng@653 2596
dongsheng@714 2597 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 2598 #: ../en/ch01-intro.xml:115
dongsheng@653 2599 msgid ""
dongsheng@653 2600 "Revision control is a diverse field, so much so that it is referred to by "
dongsheng@653 2601 "many names and acronyms. Here are a few of the more common variations you'll "
dongsheng@653 2602 "encounter:"
dongsheng@653 2603 msgstr ""
zhaopingsun@1036 2604 "版本控制是一个各自为政的领域,以至于有很多名称和缩略语,下面是你可能遇到的一些"
zhaopingsun@1036 2605 "常用的术语:"
dongsheng@653 2606
dongsheng@714 2607 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 2608 #: ../en/ch01-intro.xml:119
dongsheng@653 2609 msgid "Revision control (RCS)"
dongsheng@653 2610 msgstr "版本控制(RCS)"
dongsheng@653 2611
dongsheng@714 2612 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 2613 #: ../en/ch01-intro.xml:120
dongsheng@653 2614 msgid "Software configuration management (SCM), or configuration management"
dongsheng@653 2615 msgstr "软件配置管理(SCM),或配置管理"
dongsheng@653 2616
dongsheng@714 2617 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 2618 #: ../en/ch01-intro.xml:122
dongsheng@653 2619 msgid "Source code management"
dongsheng@653 2620 msgstr "源代码管理"
dongsheng@653 2621
dongsheng@714 2622 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 2623 #: ../en/ch01-intro.xml:123
dongsheng@653 2624 msgid "Source code control, or source control"
dongsheng@653 2625 msgstr "源代码控制,或源控制"
dongsheng@653 2626
dongsheng@714 2627 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 2628 #: ../en/ch01-intro.xml:125
dongsheng@653 2629 msgid "Version control (VCS)"
dongsheng@653 2630 msgstr "版本控制(VCS)"
dongsheng@653 2631
dongsheng@714 2632 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 2633 #: ../en/ch01-intro.xml:127
dongsheng@653 2634 msgid ""
dongsheng@653 2635 "Some people claim that these terms actually have different meanings, but in "
dongsheng@653 2636 "practice they overlap so much that there's no agreed or even useful way to "
dongsheng@653 2637 "tease them apart."
dongsheng@653 2638 msgstr ""
zhaopingsun@1036 2639 "有些人声称这些术语有不同的含义,但实际上它们的含义太重叠了,根本没有一致的,甚"
zhaopingsun@1036 2640 "至有用的方式来区别它们。"
dongsheng@653 2641
dongsheng@714 2642 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 2643 #: ../en/ch01-intro.xml:135
dongsheng@653 2644 msgid "About the examples in this book"
dongsheng@653 2645 msgstr "本书的例子"
dongsheng@653 2646
dongsheng@714 2647 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 2648 #: ../en/ch01-intro.xml:137
dongsheng@653 2649 msgid ""
dongsheng@653 2650 "This book takes an unusual approach to code samples. Every example is "
songdongsheng@668 2651 "<quote>live</quote>&emdash;each one is actually the result of a shell script "
songdongsheng@668 2652 "that executes the Mercurial commands you see. Every time an image of the "
songdongsheng@668 2653 "book is built from its sources, all the example scripts are automatically "
songdongsheng@668 2654 "run, and their current results compared against their expected results."
dongsheng@653 2655 msgstr ""
dongsheng@653 2656
dongsheng@714 2657 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 2658 #: ../en/ch01-intro.xml:144
dongsheng@653 2659 msgid ""
dongsheng@653 2660 "The advantage of this approach is that the examples are always accurate; they "
songdongsheng@710 2661 "describe <emphasis>exactly</emphasis> the behavior of the version of "
dongsheng@653 2662 "Mercurial that's mentioned at the front of the book. If I update the version "
dongsheng@653 2663 "of Mercurial that I'm documenting, and the output of some command changes, "
dongsheng@653 2664 "the build fails."
dongsheng@653 2665 msgstr ""
dongsheng@653 2666
dongsheng@714 2667 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 2668 #: ../en/ch01-intro.xml:151
dongsheng@653 2669 msgid ""
dongsheng@653 2670 "There is a small disadvantage to this approach, which is that the dates and "
dongsheng@653 2671 "times you'll see in examples tend to be <quote>squashed</quote> together in a "
dongsheng@653 2672 "way that they wouldn't be if the same commands were being typed by a human. "
dongsheng@653 2673 "Where a human can issue no more than one command every few seconds, with any "
dongsheng@653 2674 "resulting timestamps correspondingly spread out, my automated example scripts "
dongsheng@653 2675 "run many commands in one second."
dongsheng@653 2676 msgstr ""
dongsheng@653 2677
dongsheng@714 2678 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 2679 #: ../en/ch01-intro.xml:159
dongsheng@653 2680 msgid ""
dongsheng@653 2681 "As an instance of this, several consecutive commits in an example can show up "
dongsheng@653 2682 "as having occurred during the same second. You can see this occur in the "
songdongsheng@658 2683 "<literal role=\"hg-ext\">bisect</literal> example in <xref linkend=\"sec:undo:"
songdongsheng@658 2684 "bisect\"/>, for instance."
dongsheng@653 2685 msgstr ""
dongsheng@653 2686
dongsheng@714 2687 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 2688 #: ../en/ch01-intro.xml:165
dongsheng@653 2689 msgid ""
dongsheng@653 2690 "So when you're reading examples, don't place too much weight on the dates or "
dongsheng@653 2691 "times you see in the output of commands. But <emphasis>do</emphasis> be "
songdongsheng@710 2692 "confident that the behavior you're seeing is consistent and reproducible."
dongsheng@653 2693 msgstr ""
zhaopingsun@1036 2694 "所以当你研究这些例子的时候,不要太注意命令输出的日期和时间。但是<emphasis>要</"
zhaopingsun@1036 2695 "emphasis>保证你看到的行为是一致的和可以再现的。"
dongsheng@653 2696
dongsheng@714 2697 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 2698 #: ../en/ch01-intro.xml:173
dongsheng@653 2699 msgid "Trends in the field"
dongsheng@653 2700 msgstr "版本控制的发展趋势"
dongsheng@653 2701
dongsheng@714 2702 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 2703 #: ../en/ch01-intro.xml:175
dongsheng@653 2704 msgid ""
dongsheng@653 2705 "There has been an unmistakable trend in the development and use of revision "
dongsheng@653 2706 "control tools over the past four decades, as people have become familiar with "
dongsheng@653 2707 "the capabilities of their tools and constrained by their limitations."
dongsheng@653 2708 msgstr ""
zhaopingsun@1036 2709 "在过去的四十年中,随着人们越来越熟悉他们的工具的能力和限制,开发和使用版本控制"
zhaopingsun@1036 2710 "工具出现了明确的趋势。 "
dongsheng@653 2711
dongsheng@714 2712 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 2713 #: ../en/ch01-intro.xml:180
dongsheng@653 2714 msgid ""
dongsheng@653 2715 "The first generation began by managing single files on individual computers. "
dongsheng@653 2716 "Although these tools represented a huge advance over ad-hoc manual revision "
dongsheng@653 2717 "control, their locking model and reliance on a single computer limited them "
dongsheng@653 2718 "to small, tightly-knit teams."
dongsheng@653 2719 msgstr ""
zhaopingsun@1036 2720 "在第一代软件开始于在个人计算机上管理单个文件。虽然这些工具比手工管理版本有了巨"
zhaopingsun@1036 2721 "大的飞跃。但是加锁模型和依赖于单个计算机限制了他们之能用于小的,组织严密的团"
zhaopingsun@1036 2722 "队。"
dongsheng@653 2723
dongsheng@714 2724 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 2725 #: ../en/ch01-intro.xml:186
dongsheng@653 2726 msgid ""
dongsheng@653 2727 "The second generation loosened these constraints by moving to network-"
dongsheng@653 2728 "centered architectures, and managing entire projects at a time. As projects "
dongsheng@653 2729 "grew larger, they ran into new problems. With clients needing to talk to "
dongsheng@653 2730 "servers very frequently, server scaling became an issue for large projects. "
dongsheng@653 2731 "An unreliable network connection could prevent remote users from being able "
dongsheng@653 2732 "to talk to the server at all. As open source projects started making read-"
dongsheng@653 2733 "only access available anonymously to anyone, people without commit privileges "
dongsheng@653 2734 "found that they could not use the tools to interact with a project in a "
dongsheng@653 2735 "natural way, as they could not record their changes."
dongsheng@653 2736 msgstr ""
zhaopingsun@1036 2737 "第二代软件因为采用以网络为中心的结构,一次性管理整个项目而放松了这些限制。随着"
zhaopingsun@1036 2738 "项目增长,又出现了新的问题。客户需要频繁的和服务器交互,服务器的可伸缩性成为大"
zhaopingsun@1036 2739 "项目的主要问题。不可靠的网络会妨碍客户和服务器的交互。随着开源项目开始开放只读"
zhaopingsun@1036 2740 "权限给匿名用户,没有提交权限的用户发现他们不能以自然的方式使用工具和项目交互,"
zhaopingsun@1036 2741 "因为他们不能记录他们的修改。"
dongsheng@653 2742
dongsheng@714 2743 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 2744 #: ../en/ch01-intro.xml:198
dongsheng@653 2745 msgid ""
dongsheng@653 2746 "The current generation of revision control tools is peer-to-peer in nature. "
dongsheng@653 2747 "All of these systems have dropped the dependency on a single central server, "
dongsheng@653 2748 "and allow people to distribute their revision control data to where it's "
dongsheng@653 2749 "actually needed. Collaboration over the Internet has moved from constrained "
dongsheng@653 2750 "by technology to a matter of choice and consensus. Modern tools can operate "
dongsheng@653 2751 "offline indefinitely and autonomously, with a network connection only needed "
dongsheng@653 2752 "when syncing changes with another repository."
dongsheng@653 2753 msgstr ""
zhaopingsun@1036 2754 "新一代的版本控制工具本质上是点对点的。所有的这些系统都抛弃了对单个中央服务器的"
zhaopingsun@1036 2755 "依赖,允许用户发布他们的版本控制数据到任何需要的地方。通过互联网的协作摆脱了技"
zhaopingsun@1036 2756 "术的限制,走向选择和审查。现代的工具可以进行自治的,不受限制的离线操作。只需要"
zhaopingsun@1037 2757 "在有网络的时候和其他的版本库同步即可。"
dongsheng@653 2758
dongsheng@714 2759 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 2760 #: ../en/ch01-intro.xml:210
dongsheng@653 2761 msgid "A few of the advantages of distributed revision control"
dongsheng@653 2762 msgstr "分布版本控制的优点"
dongsheng@653 2763
dongsheng@714 2764 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 2765 #: ../en/ch01-intro.xml:213
dongsheng@653 2766 msgid ""
dongsheng@653 2767 "Even though distributed revision control tools have for several years been as "
dongsheng@653 2768 "robust and usable as their previous-generation counterparts, people using "
dongsheng@653 2769 "older tools have not yet necessarily woken up to their advantages. There are "
dongsheng@653 2770 "a number of ways in which distributed tools shine relative to centralised "
dongsheng@653 2771 "ones."
dongsheng@653 2772 msgstr ""
zhaopingsun@1035 2773 "与他们的上一代竞争者相比,虽然分布式版本控制工具多年来已经很稳定和实用了,但是"
zhaopingsun@1035 2774 "使用旧的工具的人们还没有完全了解它们的优点,分布式的工具在很多方面明显由于集中"
zhaopingsun@1035 2775 "式的工具。"
dongsheng@653 2776
dongsheng@714 2777 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 2778 #: ../en/ch01-intro.xml:220
dongsheng@653 2779 msgid ""
dongsheng@653 2780 "For an individual developer, distributed tools are almost always much faster "
dongsheng@653 2781 "than centralised tools. This is for a simple reason: a centralised tool "
dongsheng@653 2782 "needs to talk over the network for many common operations, because most "
dongsheng@653 2783 "metadata is stored in a single copy on the central server. A distributed "
dongsheng@653 2784 "tool stores all of its metadata locally. All else being equal, talking over "
dongsheng@653 2785 "the network adds overhead to a centralised tool. Don't underestimate the "
dongsheng@653 2786 "value of a snappy, responsive tool: you're going to spend a lot of time "
dongsheng@653 2787 "interacting with your revision control software."
dongsheng@653 2788 msgstr ""
zhaopingsun@1035 2789 "对于个人开发者,分布式工具几乎永远比集中式工具快的多。原因很简单:集中式工具的"
zhaopingsun@1035 2790 "很多操作需要网络交互,因为大部分元数据都只在中央服务器上有一份拷贝。而一个分布"
zhaopingsun@1035 2791 "式工具将所有的元数据保存在本地。其他的相同,通过网络的交互增加了集中式工具的负"
zhaopingsun@1035 2792 "担。不要低估了反应迅速的工具的价值:你要花很多时间和你的版本控制软件交互。"
dongsheng@653 2793
dongsheng@714 2794 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 2795 #: ../en/ch01-intro.xml:231
dongsheng@653 2796 msgid ""
dongsheng@653 2797 "Distributed tools are indifferent to the vagaries of your server "
dongsheng@653 2798 "infrastructure, again because they replicate metadata to so many locations. "
dongsheng@653 2799 "If you use a centralised system and your server catches fire, you'd better "
dongsheng@653 2800 "hope that your backup media are reliable, and that your last backup was "
dongsheng@653 2801 "recent and actually worked. With a distributed tool, you have many backups "
dongsheng@653 2802 "available on every contributor's computer."
dongsheng@653 2803 msgstr ""
zhaopingsun@1035 2804 "分布式工具对你的服务器结构并不感冒,因为他们在将元数据复制到很多地方。如果你的"
zhaopingsun@1035 2805 "集中式系统和你的服务器着火了,你最好希望你的备份介质是可靠的,同时你最后的备份"
zhaopingsun@1035 2806 "是最近的,而且还能用。而对于分布式工具,你在贡献者的计算机上有很多备份。"
dongsheng@653 2807
dongsheng@714 2808 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 2809 #: ../en/ch01-intro.xml:239
dongsheng@653 2810 msgid ""
dongsheng@653 2811 "The reliability of your network will affect distributed tools far less than "
dongsheng@653 2812 "it will centralised tools. You can't even use a centralised tool without a "
dongsheng@653 2813 "network connection, except for a few highly constrained commands. With a "
dongsheng@653 2814 "distributed tool, if your network connection goes down while you're working, "
dongsheng@653 2815 "you may not even notice. The only thing you won't be able to do is talk to "
dongsheng@653 2816 "repositories on other computers, something that is relatively rare compared "
dongsheng@653 2817 "with local operations. If you have a far-flung team of collaborators, this "
dongsheng@653 2818 "may be significant."
dongsheng@653 2819 msgstr ""
zhaopingsun@1035 2820 "网络的可靠性对分布式工具的影响要远远小于集中式工具。如果没有网络你根本不能使用"
zhaopingsun@1035 2821 "集中式工具,除了少数几个功能有限命令。而对于分布式工具,即使在你工作的时候网络"
zhaopingsun@1037 2822 "瘫痪了,你可能根本不会注意到。你不能做的事情仅仅是不能和其它计算机上的版本库交"
zhaopingsun@1037 2823 "互了,这种事在本地操作相当罕见。而如果你的团队有异地的人员,那这就很有可能了。"
dongsheng@653 2824
dongsheng@714 2825 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 2826 #: ../en/ch01-intro.xml:250
dongsheng@653 2827 msgid "Advantages for open source projects"
dongsheng@653 2828 msgstr "开源项目的优点"
dongsheng@653 2829
dongsheng@714 2830 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 2831 #: ../en/ch01-intro.xml:252
dongsheng@653 2832 msgid ""
dongsheng@653 2833 "If you take a shine to an open source project and decide that you would like "
dongsheng@653 2834 "to start hacking on it, and that project uses a distributed revision control "
dongsheng@653 2835 "tool, you are at once a peer with the people who consider themselves the "
dongsheng@653 2836 "<quote>core</quote> of that project. If they publish their repositories, you "
dongsheng@653 2837 "can immediately copy their project history, start making changes, and record "
dongsheng@653 2838 "your work, using the same tools in the same ways as insiders. By contrast, "
dongsheng@653 2839 "with a centralised tool, you must use the software in a <quote>read only</"
dongsheng@653 2840 "quote> mode unless someone grants you permission to commit changes to their "
dongsheng@653 2841 "central server. Until then, you won't be able to record changes, and your "
dongsheng@653 2842 "local modifications will be at risk of corruption any time you try to update "
dongsheng@653 2843 "your client's view of the repository."
dongsheng@653 2844 msgstr ""
zhaopingsun@1037 2845 "如果你喜欢一个开源项目并且决定准备开始改进它,同时这个项目使用分布式版本控制工"
zhaopingsun@1037 2846 "具的话,你立刻可以和其他人一样认为自己成为项目的<quote>核心</quote>。如果他们"
zhaopingsun@1037 2847 "发布了他们的版本库,你可以立即拷贝他们的项目。开始修改,记录你自己的工作,和内"
zhaopingsun@1037 2848 "部人员一样使用同样的工具。相比之下,如果使用集中式工具,除非有人给你向中央服务"
zhaopingsun@1037 2849 "器提交修改的权限,你只能用只读的方式使用软件。这样,你就不能记录你的修改,而且"
zhaopingsun@1037 2850 "当你从版本库更新的时候,本地的修改随时有崩溃的可能。 "
dongsheng@653 2851
dongsheng@714 2852 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
dongsheng@714 2853 #: ../en/ch01-intro.xml:268
dongsheng@653 2854 msgid "The forking non-problem"
dongsheng@660 2855 msgstr "分叉不是问题"
dongsheng@653 2856
dongsheng@714 2857 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 2858 #: ../en/ch01-intro.xml:270
dongsheng@653 2859 msgid ""
dongsheng@653 2860 "It has been suggested that distributed revision control tools pose some sort "
dongsheng@653 2861 "of risk to open source projects because they make it easy to <quote>fork</"
dongsheng@653 2862 "quote> the development of a project. A fork happens when there are "
dongsheng@653 2863 "differences in opinion or attitude between groups of developers that cause "
dongsheng@653 2864 "them to decide that they can't work together any longer. Each side takes a "
dongsheng@653 2865 "more or less complete copy of the project's source code, and goes off in its "
dongsheng@653 2866 "own direction."
dongsheng@653 2867 msgstr ""
dongsheng@653 2868
dongsheng@714 2869 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 2870 #: ../en/ch01-intro.xml:280
dongsheng@653 2871 msgid ""
dongsheng@653 2872 "Sometimes the camps in a fork decide to reconcile their differences. With a "
dongsheng@653 2873 "centralised revision control system, the <emphasis>technical</emphasis> "
dongsheng@653 2874 "process of reconciliation is painful, and has to be performed largely by "
dongsheng@653 2875 "hand. You have to decide whose revision history is going to <quote>win</"
dongsheng@653 2876 "quote>, and graft the other team's changes into the tree somehow. This "
dongsheng@653 2877 "usually loses some or all of one side's revision history."
dongsheng@653 2878 msgstr ""
dongsheng@653 2879
dongsheng@714 2880 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 2881 #: ../en/ch01-intro.xml:289
dongsheng@653 2882 msgid ""
dongsheng@653 2883 "What distributed tools do with respect to forking is they make forking the "
dongsheng@653 2884 "<emphasis>only</emphasis> way to develop a project. Every single change that "
dongsheng@653 2885 "you make is potentially a fork point. The great strength of this approach is "
dongsheng@653 2886 "that a distributed revision control tool has to be really good at "
dongsheng@653 2887 "<emphasis>merging</emphasis> forks, because forks are absolutely fundamental: "
dongsheng@653 2888 "they happen all the time."
dongsheng@653 2889 msgstr ""
dongsheng@653 2890
dongsheng@714 2891 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 2892 #: ../en/ch01-intro.xml:298
dongsheng@653 2893 msgid ""
dongsheng@653 2894 "If every piece of work that everybody does, all the time, is framed in terms "
dongsheng@653 2895 "of forking and merging, then what the open source world refers to as a "
dongsheng@653 2896 "<quote>fork</quote> becomes <emphasis>purely</emphasis> a social issue. If "
dongsheng@653 2897 "anything, distributed tools <emphasis>lower</emphasis> the likelihood of a "
dongsheng@653 2898 "fork:"
dongsheng@653 2899 msgstr ""
dongsheng@653 2900
dongsheng@714 2901 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@714 2902 #: ../en/ch01-intro.xml:305
dongsheng@653 2903 msgid ""
dongsheng@653 2904 "They eliminate the social distinction that centralised tools impose: that "
dongsheng@653 2905 "between insiders (people with commit access) and outsiders (people without)."
dongsheng@653 2906 msgstr ""
dongsheng@653 2907
dongsheng@714 2908 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@714 2909 #: ../en/ch01-intro.xml:309
dongsheng@653 2910 msgid ""
dongsheng@653 2911 "They make it easier to reconcile after a social fork, because all that's "
dongsheng@653 2912 "involved from the perspective of the revision control software is just "
dongsheng@653 2913 "another merge."
dongsheng@653 2914 msgstr ""
dongsheng@653 2915
dongsheng@714 2916 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 2917 #: ../en/ch01-intro.xml:314
dongsheng@653 2918 msgid ""
dongsheng@653 2919 "Some people resist distributed tools because they want to retain tight "
dongsheng@653 2920 "control over their projects, and they believe that centralised tools give "
dongsheng@653 2921 "them this control. However, if you're of this belief, and you publish your "
dongsheng@653 2922 "CVS or Subversion repositories publicly, there are plenty of tools available "
dongsheng@653 2923 "that can pull out your entire project's history (albeit slowly) and recreate "
dongsheng@653 2924 "it somewhere that you don't control. So while your control in this case is "
dongsheng@653 2925 "illusory, you are forgoing the ability to fluidly collaborate with whatever "
dongsheng@653 2926 "people feel compelled to mirror and fork your history."
dongsheng@653 2927 msgstr ""
zhaopingsun@1038 2928 "有些人拒绝分布式工具因为他们想保持对项目的控制,他们相信集中式工具会给他们这种"
zhaopingsun@1038 2929 "控制。如果你这种想法,并你将CVS或者Subversion版本库向大众发布了,那么别人可用"
zhaopingsun@1038 2930 "现有的很多工具将整个项目的历史抓取出来(可能很慢),在其它你控制不了的地方重建"
zhaopingsun@1038 2931 "版本库。这时你的控制只不过是一种幻觉罢了,一些人被迫从你的版本库创建映像和分"
zhaopingsun@1038 2932 "支,而你失去了和他们协作的机会。"
dongsheng@653 2933
dongsheng@714 2934 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 2935 #: ../en/ch01-intro.xml:329
dongsheng@653 2936 msgid "Advantages for commercial projects"
dongsheng@653 2937 msgstr "商业项目的优点"
dongsheng@653 2938
dongsheng@714 2939 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 2940 #: ../en/ch01-intro.xml:331
dongsheng@653 2941 msgid ""
dongsheng@653 2942 "Many commercial projects are undertaken by teams that are scattered across "
dongsheng@653 2943 "the globe. Contributors who are far from a central server will see slower "
dongsheng@653 2944 "command execution and perhaps less reliability. Commercial revision control "
dongsheng@653 2945 "systems attempt to ameliorate these problems with remote-site replication add-"
dongsheng@653 2946 "ons that are typically expensive to buy and cantankerous to administer. A "
dongsheng@653 2947 "distributed system doesn't suffer from these problems in the first place. "
dongsheng@653 2948 "Better yet, you can easily set up multiple authoritative servers, say one per "
dongsheng@653 2949 "site, so that there's no redundant communication between repositories over "
dongsheng@653 2950 "expensive long-haul network links."
dongsheng@653 2951 msgstr ""
zhaopingsun@1038 2952 "遍布全球的团队正在进行许多商业项目。远离中央服务器的贡献者会发现执行命令速度很"
zhaopingsun@1038 2953 "慢同时不怎么可靠。商业的版本控制系统改善这个问题的办法就是让你购买远程复制插"
zhaopingsun@1038 2954 "件,这通常很昂贵,并且很难管理。分布式系统首先不会有这样的问题。其次,你可以很"
zhaopingsun@1038 2955 "容易的建立多个授权服务器,假设每个站点一个,这样可以避免在昂贵的长途线路上的冗"
zhaopingsun@1038 2956 "余的通讯。"
dongsheng@653 2957
dongsheng@714 2958 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 2959 #: ../en/ch01-intro.xml:343
dongsheng@653 2960 msgid ""
dongsheng@653 2961 "Centralised revision control systems tend to have relatively low "
dongsheng@653 2962 "scalability. It's not unusual for an expensive centralised system to fall "
dongsheng@653 2963 "over under the combined load of just a few dozen concurrent users. Once "
dongsheng@653 2964 "again, the typical response tends to be an expensive and clunky replication "
songdongsheng@668 2965 "facility. Since the load on a central server&emdash;if you have one at "
songdongsheng@668 2966 "all&emdash;is many times lower with a distributed tool (because all of the "
songdongsheng@668 2967 "data is replicated everywhere), a single cheap server can handle the needs of "
songdongsheng@668 2968 "a much larger team, and replication to balance load becomes a simple matter "
songdongsheng@668 2969 "of scripting."
dongsheng@653 2970 msgstr ""
zhaopingsun@1038 2971 "集中式的版本控制系统的扩展性相对较低。只要不多的并行用户的组合负载就可以将一个"
zhaopingsun@1038 2972 "昂贵的中央服务器压垮。同样,典型的反应就是昂贵笨重的复制设备。因为中央服务器的"
zhaopingsun@1038 2973 "最大负载&emdash;如果你有的话&emdash;比分布式工具低很多(因为所有的数据要北复制"
zhaopingsun@1038 2974 "到其它地方),一个廉价的服务器就可以满足一个相当大的团队的要求,为平衡负载而进"
zhaopingsun@1038 2975 "行的复制只需要简单的脚本就够了。"
dongsheng@653 2976
dongsheng@714 2977 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 2978 #: ../en/ch01-intro.xml:355
dongsheng@653 2979 msgid ""
dongsheng@653 2980 "If you have an employee in the field, troubleshooting a problem at a "
dongsheng@653 2981 "customer's site, they'll benefit from distributed revision control. The tool "
dongsheng@653 2982 "will let them generate custom builds, try different fixes in isolation from "
dongsheng@653 2983 "each other, and search efficiently through history for the sources of bugs "
dongsheng@653 2984 "and regressions in the customer's environment, all without needing to connect "
dongsheng@653 2985 "to your company's network."
dongsheng@653 2986 msgstr ""
zhaopingsun@1038 2987 "如果你有员工需要在客户方解决问题,那么他们会受益于分布式版本控制。工具允许他们"
zhaopingsun@1039 2988 "创建定制的环境,互相独立的尝试不同的解决方案。并且可以高效的从历史代码中查找"
zhaopingsun@1039 2989 "bug的根源,在客户环境中进行回归,所有的这些都不需要连接公司的网络。"
dongsheng@653 2990
dongsheng@714 2991 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 2992 #: ../en/ch01-intro.xml:366
dongsheng@653 2993 msgid "Why choose Mercurial?"
dongsheng@653 2994 msgstr "为什么选择 Mercurial?"
dongsheng@653 2995
dongsheng@714 2996 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 2997 #: ../en/ch01-intro.xml:368
dongsheng@653 2998 msgid ""
dongsheng@653 2999 "Mercurial has a unique set of properties that make it a particularly good "
dongsheng@653 3000 "choice as a revision control system."
zhaopingsun@1039 3001 msgstr "Mercurial是一个非常好的版本控制系统,因为它有很多独一无二的特点。"
dongsheng@653 3002
dongsheng@714 3003 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 3004 #: ../en/ch01-intro.xml:371
dongsheng@653 3005 msgid "It is easy to learn and use."
zhaopingsun@1039 3006 msgstr "它易学易用。"
dongsheng@653 3007
dongsheng@714 3008 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 3009 #: ../en/ch01-intro.xml:372
songdongsheng@667 3010 msgid "It is lightweight."
zhaopingsun@1039 3011 msgstr "它轻量级。"
dongsheng@653 3012
dongsheng@714 3013 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 3014 #: ../en/ch01-intro.xml:373
songdongsheng@667 3015 msgid "It scales excellently."
zhaopingsun@1039 3016 msgstr "它扩展性很好。"
songdongsheng@667 3017
dongsheng@714 3018 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 3019 #: ../en/ch01-intro.xml:374
dongsheng@653 3020 msgid "It is easy to customise."
zhaopingsun@1039 3021 msgstr "它很容易定制。"
dongsheng@653 3022
dongsheng@714 3023 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 3024 #: ../en/ch01-intro.xml:377
dongsheng@653 3025 msgid ""
dongsheng@653 3026 "If you are at all familiar with revision control systems, you should be able "
dongsheng@653 3027 "to get up and running with Mercurial in less than five minutes. Even if not, "
dongsheng@653 3028 "it will take no more than a few minutes longer. Mercurial's command and "
dongsheng@653 3029 "feature sets are generally uniform and consistent, so you can keep track of a "
dongsheng@653 3030 "few general rules instead of a host of exceptions."
dongsheng@653 3031 msgstr ""
zhaopingsun@1039 3032 "如果你熟悉版本控制系统,你在五分钟之内只能就可以使用Mercurial工作了。即使你不"
zhaopingsun@1039 3033 "熟悉,也不过是再多花几分钟。Mercurial的命令和功能集非常统一一致,你只要遵守几"
zhaopingsun@1039 3034 "个通用的规则就够了,很少有例外。"
dongsheng@653 3035
dongsheng@714 3036 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 3037 #: ../en/ch01-intro.xml:384
dongsheng@653 3038 msgid ""
dongsheng@653 3039 "On a small project, you can start working with Mercurial in moments. Creating "
dongsheng@653 3040 "new changes and branches; transferring changes around (whether locally or "
dongsheng@653 3041 "over a network); and history and status operations are all fast. Mercurial "
dongsheng@653 3042 "attempts to stay nimble and largely out of your way by combining low "
dongsheng@653 3043 "cognitive overhead with blazingly fast operations."
dongsheng@653 3044 msgstr ""
zhaopingsun@1040 3045 "在很小的项目上,你马上就可以使用Mercurial开始工作。创建新的修改和分支;到处交"
zhaopingsun@1040 3046 "换修改(不管本机还是通过网络);获取历史和状态数据非常快。Mercurial努力保持小"
zhaopingsun@1040 3047 "巧灵活,在眨眼之间就能完成操作。"
dongsheng@653 3048
dongsheng@714 3049 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 3050 #: ../en/ch01-intro.xml:391
dongsheng@653 3051 msgid ""
dongsheng@653 3052 "The usefulness of Mercurial is not limited to small projects: it is used by "
dongsheng@653 3053 "projects with hundreds to thousands of contributors, each containing tens of "
dongsheng@653 3054 "thousands of files and hundreds of megabytes of source code."
dongsheng@653 3055 msgstr ""
zhaopingsun@1040 3056 "不仅小的项目可以使用Mercurial:有成百上千的贡献者的项目也在使用它,这些项目每"
zhaopingsun@1040 3057 "个都有上万个文件和几百兆的源码。"
dongsheng@653 3058
dongsheng@714 3059 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 3060 #: ../en/ch01-intro.xml:396
dongsheng@653 3061 msgid ""
dongsheng@653 3062 "If the core functionality of Mercurial is not enough for you, it's easy to "
dongsheng@653 3063 "build on. Mercurial is well suited to scripting tasks, and its clean "
dongsheng@653 3064 "internals and implementation in Python make it easy to add features in the "
dongsheng@653 3065 "form of extensions. There are a number of popular and useful extensions "
dongsheng@653 3066 "already available, ranging from helping to identify bugs to improving "
dongsheng@653 3067 "performance."
dongsheng@653 3068 msgstr ""
zhaopingsun@1040 3069 "如果觉得Mercurial的核心功能不能满足要求,你很容易在现有基础上开发。Mercurial非"
zhaopingsun@1040 3070 "常适合于脚本任务,它的核心简洁,并且用Python实现,用扩展的方式增加新的功能非常"
zhaopingsun@1040 3071 "方便,现在已经有很多流行和有用的扩展了,像帮助你确定bug或者提高性能等。"
dongsheng@653 3072
dongsheng@714 3073 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 3074 #: ../en/ch01-intro.xml:406
dongsheng@653 3075 msgid "Mercurial compared with other tools"
dongsheng@653 3076 msgstr "Mercurial 与其它工具的比较"
dongsheng@653 3077
dongsheng@714 3078 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 3079 #: ../en/ch01-intro.xml:408
dongsheng@653 3080 msgid ""
dongsheng@653 3081 "Before you read on, please understand that this section necessarily reflects "
dongsheng@653 3082 "my own experiences, interests, and (dare I say it) biases. I have used every "
dongsheng@653 3083 "one of the revision control tools listed below, in most cases for several "
dongsheng@653 3084 "years at a time."
dongsheng@653 3085 msgstr ""
zhaopingsun@1041 3086 "在你继续阅读之前,请理解本节完全反映了我的个人经验,兴趣,和偏好(我敢说)。下"
zhaopingsun@1041 3087 "面列的每个版本控制工具我都使用过,大多数情况下都用过好几年。"
dongsheng@653 3088
dongsheng@714 3089 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 3090 #: ../en/ch01-intro.xml:418
dongsheng@653 3091 msgid ""
dongsheng@653 3092 "Subversion is a popular revision control tool, developed to replace CVS. It "
dongsheng@653 3093 "has a centralised client/server architecture."
dongsheng@653 3094 msgstr ""
zhaopingsun@1041 3095 "Subversion是一个流行的版本控制工具,是用来替代CVS的,它采用的是集中式的客户/服"
zhaopingsun@1041 3096 "务器结构。"
dongsheng@653 3097
dongsheng@714 3098 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 3099 #: ../en/ch01-intro.xml:422
dongsheng@653 3100 msgid ""
dongsheng@653 3101 "Subversion and Mercurial have similarly named commands for performing the "
dongsheng@653 3102 "same operations, so if you're familiar with one, it is easy to learn to use "
dongsheng@653 3103 "the other. Both tools are portable to all popular operating systems."
dongsheng@653 3104 msgstr ""
zhaopingsun@1041 3105 "Subversion和Mercurial相同操作的命令的命名上非常相似,所以如果你熟悉一个,很容"
zhaopingsun@1041 3106 "易学会另外一个,两个工具都可以在大多数平台上运行。"
dongsheng@653 3107
dongsheng@714 3108 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 3109 #: ../en/ch01-intro.xml:427
dongsheng@653 3110 msgid ""
dongsheng@653 3111 "Prior to version 1.5, Subversion had no useful support for merges. At the "
dongsheng@653 3112 "time of writing, its merge tracking capability is new, and known to be <ulink "
dongsheng@653 3113 "url=\"http://svnbook.red-bean.com/nightly/en/svn.branchmerge.advanced."
dongsheng@653 3114 "html#svn.branchmerge.advanced.finalword\">complicated and buggy</ulink>."
dongsheng@653 3115 msgstr ""
zhaopingsun@1041 3116 "在1.5版之前,Subversion对合并的支持并不好。在我写本书的时候,它刚新增了并跟踪"
zhaopingsun@1041 3117 "的功能,出名的<ulink url=\"http://svnbook.red-bean.com/nightly/en/svn."
zhaopingsun@1041 3118 "branchmerge.advanced.html#svn.branchmerge.advanced.finalword\">复杂和容易出错"
zhaopingsun@1041 3119 "</ulink>。"
dongsheng@653 3120
dongsheng@714 3121 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 3122 #: ../en/ch01-intro.xml:433
dongsheng@653 3123 msgid ""
dongsheng@653 3124 "Mercurial has a substantial performance advantage over Subversion on every "
dongsheng@653 3125 "revision control operation I have benchmarked. I have measured its advantage "
dongsheng@653 3126 "as ranging from a factor of two to a factor of six when compared with "
dongsheng@653 3127 "Subversion 1.4.3's <emphasis>ra_local</emphasis> file store, which is the "
dongsheng@653 3128 "fastest access method available. In more realistic deployments involving a "
dongsheng@653 3129 "network-based store, Subversion will be at a substantially larger "
dongsheng@653 3130 "disadvantage. Because many Subversion commands must talk to the server and "
dongsheng@653 3131 "Subversion does not have useful replication facilities, server capacity and "
dongsheng@653 3132 "network bandwidth become bottlenecks for modestly large projects."
dongsheng@653 3133 msgstr ""
zhaopingsun@1041 3134 "在我测量过的每个版本控制操作上Mercurial都比Subversion有很大的性能优势。差距从"
zhaopingsun@1041 3135 "两个数量级到六个数量级不等,我用的是Subversion 1.4.3的<emphasis>ra_local</"
zhaopingsun@1041 3136 "emphasis>文件存储方式,这是已知的最快的存取方式了。在实际的部署中包括网络存"
zhaopingsun@1041 3137 "储,那么Subversion的劣势更大。因为很多Subversion命令必须和主机交互,并且因为"
zhaopingsun@1041 3138 "Subversion没有好的复制机制,使得对于中的等大小的项目而言,服务器容量和网络带宽"
zhaopingsun@1041 3139 "成为主要瓶颈。"
dongsheng@653 3140
dongsheng@714 3141 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 3142 #: ../en/ch01-intro.xml:446
dongsheng@653 3143 msgid ""
dongsheng@653 3144 "Additionally, Subversion incurs substantial storage overhead to avoid network "
dongsheng@653 3145 "transactions for a few common operations, such as finding modified files "
dongsheng@653 3146 "(<literal>status</literal>) and displaying modifications against the current "
dongsheng@653 3147 "revision (<literal>diff</literal>). As a result, a Subversion working copy "
dongsheng@653 3148 "is often the same size as, or larger than, a Mercurial repository and working "
dongsheng@653 3149 "directory, even though the Mercurial repository contains a complete history "
dongsheng@653 3150 "of the project."
dongsheng@653 3151 msgstr ""
dongsheng@653 3152
dongsheng@714 3153 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 3154 #: ../en/ch01-intro.xml:456
dongsheng@653 3155 msgid ""
dongsheng@653 3156 "Subversion is widely supported by third party tools. Mercurial currently "
dongsheng@653 3157 "lags considerably in this area. This gap is closing, however, and indeed "
dongsheng@653 3158 "some of Mercurial's GUI tools now outshine their Subversion equivalents. "
dongsheng@653 3159 "Like Mercurial, Subversion has an excellent user manual."
dongsheng@653 3160 msgstr ""
dongsheng@653 3161
dongsheng@714 3162 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 3163 #: ../en/ch01-intro.xml:462
dongsheng@653 3164 msgid ""
dongsheng@653 3165 "Because Subversion doesn't store revision history on the client, it is well "
dongsheng@653 3166 "suited to managing projects that deal with lots of large, opaque binary "
dongsheng@653 3167 "files. If you check in fifty revisions to an incompressible 10MB file, "
dongsheng@653 3168 "Subversion's client-side space usage stays constant The space used by any "
dongsheng@653 3169 "distributed SCM will grow rapidly in proportion to the number of revisions, "
dongsheng@653 3170 "because the differences between each revision are large."
dongsheng@653 3171 msgstr ""
dongsheng@653 3172
dongsheng@714 3173 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 3174 #: ../en/ch01-intro.xml:471
dongsheng@653 3175 msgid ""
dongsheng@653 3176 "In addition, it's often difficult or, more usually, impossible to merge "
dongsheng@653 3177 "different versions of a binary file. Subversion's ability to let a user lock "
dongsheng@653 3178 "a file, so that they temporarily have the exclusive right to commit changes "
dongsheng@653 3179 "to it, can be a significant advantage to a project where binary files are "
dongsheng@653 3180 "widely used."
dongsheng@653 3181 msgstr ""
dongsheng@653 3182
dongsheng@714 3183 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 3184 #: ../en/ch01-intro.xml:478
dongsheng@653 3185 msgid ""
dongsheng@653 3186 "Mercurial can import revision history from a Subversion repository. It can "
dongsheng@653 3187 "also export revision history to a Subversion repository. This makes it easy "
dongsheng@653 3188 "to <quote>test the waters</quote> and use Mercurial and Subversion in "
dongsheng@653 3189 "parallel before deciding to switch. History conversion is incremental, so "
dongsheng@653 3190 "you can perform an initial conversion, then small additional conversions "
dongsheng@653 3191 "afterwards to bring in new changes."
dongsheng@653 3192 msgstr ""
dongsheng@653 3193
dongsheng@714 3194 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 3195 #: ../en/ch01-intro.xml:490 ../en/ch01-intro.xml:629
dongsheng@653 3196 msgid "Git"
songdongsheng@668 3197 msgstr "Git"
dongsheng@653 3198
dongsheng@714 3199 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 3200 #: ../en/ch01-intro.xml:492
dongsheng@653 3201 msgid ""
dongsheng@653 3202 "Git is a distributed revision control tool that was developed for managing "
dongsheng@653 3203 "the Linux kernel source tree. Like Mercurial, its early design was somewhat "
dongsheng@653 3204 "influenced by Monotone."
dongsheng@653 3205 msgstr ""
dongsheng@653 3206
dongsheng@714 3207 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 3208 #: ../en/ch01-intro.xml:497
dongsheng@653 3209 msgid ""
dongsheng@653 3210 "Git has a very large command set, with version 1.5.0 providing 139 individual "
dongsheng@653 3211 "commands. It has something of a reputation for being difficult to learn. "
dongsheng@653 3212 "Compared to Git, Mercurial has a strong focus on simplicity."
dongsheng@653 3213 msgstr ""
dongsheng@653 3214
dongsheng@714 3215 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 3216 #: ../en/ch01-intro.xml:502
dongsheng@653 3217 msgid ""
dongsheng@653 3218 "In terms of performance, Git is extremely fast. In several cases, it is "
dongsheng@653 3219 "faster than Mercurial, at least on Linux, while Mercurial performs better on "
dongsheng@653 3220 "other operations. However, on Windows, the performance and general level of "
dongsheng@653 3221 "support that Git provides is, at the time of writing, far behind that of "
dongsheng@653 3222 "Mercurial."
dongsheng@653 3223 msgstr ""
dongsheng@653 3224
dongsheng@714 3225 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 3226 #: ../en/ch01-intro.xml:509
dongsheng@653 3227 msgid ""
dongsheng@653 3228 "While a Mercurial repository needs no maintenance, a Git repository requires "
dongsheng@653 3229 "frequent manual <quote>repacks</quote> of its metadata. Without these, "
dongsheng@653 3230 "performance degrades, while space usage grows rapidly. A server that "
dongsheng@653 3231 "contains many Git repositories that are not rigorously and frequently "
dongsheng@653 3232 "repacked will become heavily disk-bound during backups, and there have been "
dongsheng@653 3233 "instances of daily backups taking far longer than 24 hours as a result. A "
dongsheng@653 3234 "freshly packed Git repository is slightly smaller than a Mercurial "
dongsheng@653 3235 "repository, but an unpacked repository is several orders of magnitude larger."
dongsheng@653 3236 msgstr ""
dongsheng@653 3237
dongsheng@714 3238 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 3239 #: ../en/ch01-intro.xml:520
dongsheng@653 3240 msgid ""
dongsheng@653 3241 "The core of Git is written in C. Many Git commands are implemented as shell "
dongsheng@653 3242 "or Perl scripts, and the quality of these scripts varies widely. I have "
dongsheng@653 3243 "encountered several instances where scripts charged along blindly in the "
dongsheng@653 3244 "presence of errors that should have been fatal."
dongsheng@653 3245 msgstr ""
dongsheng@653 3246
dongsheng@714 3247 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 3248 #: ../en/ch01-intro.xml:526
dongsheng@653 3249 msgid "Mercurial can import revision history from a Git repository."
dongsheng@653 3250 msgstr ""
dongsheng@653 3251
dongsheng@714 3252 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 3253 #: ../en/ch01-intro.xml:534
dongsheng@653 3254 msgid ""
dongsheng@653 3255 "CVS is probably the most widely used revision control tool in the world. Due "
dongsheng@653 3256 "to its age and internal untidiness, it has been only lightly maintained for "
dongsheng@653 3257 "many years."
dongsheng@653 3258 msgstr ""
dongsheng@653 3259
dongsheng@714 3260 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 3261 #: ../en/ch01-intro.xml:538
dongsheng@653 3262 msgid ""
dongsheng@653 3263 "It has a centralised client/server architecture. It does not group related "
dongsheng@653 3264 "file changes into atomic commits, making it easy for people to <quote>break "
dongsheng@653 3265 "the build</quote>: one person can successfully commit part of a change and "
dongsheng@653 3266 "then be blocked by the need for a merge, causing other people to see only a "
dongsheng@653 3267 "portion of the work they intended to do. This also affects how you work with "
dongsheng@653 3268 "project history. If you want to see all of the modifications someone made as "
dongsheng@653 3269 "part of a task, you will need to manually inspect the descriptions and "
dongsheng@653 3270 "timestamps of the changes made to each file involved (if you even know what "
dongsheng@653 3271 "those files were)."
dongsheng@653 3272 msgstr ""
dongsheng@653 3273
dongsheng@714 3274 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 3275 #: ../en/ch01-intro.xml:550
dongsheng@653 3276 msgid ""
dongsheng@653 3277 "CVS has a muddled notion of tags and branches that I will not attempt to even "
dongsheng@653 3278 "describe. It does not support renaming of files or directories well, making "
dongsheng@653 3279 "it easy to corrupt a repository. It has almost no internal consistency "
dongsheng@653 3280 "checking capabilities, so it is usually not even possible to tell whether or "
dongsheng@653 3281 "how a repository is corrupt. I would not recommend CVS for any project, "
dongsheng@653 3282 "existing or new."
dongsheng@653 3283 msgstr ""
dongsheng@653 3284
dongsheng@714 3285 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 3286 #: ../en/ch01-intro.xml:558
dongsheng@653 3287 msgid ""
dongsheng@653 3288 "Mercurial can import CVS revision history. However, there are a few caveats "
dongsheng@653 3289 "that apply; these are true of every other revision control tool's CVS "
dongsheng@653 3290 "importer, too. Due to CVS's lack of atomic changes and unversioned "
dongsheng@653 3291 "filesystem hierarchy, it is not possible to reconstruct CVS history "
dongsheng@653 3292 "completely accurately; some guesswork is involved, and renames will usually "
dongsheng@653 3293 "not show up. Because a lot of advanced CVS administration has to be done by "
dongsheng@653 3294 "hand and is hence error-prone, it's common for CVS importers to run into "
dongsheng@653 3295 "multiple problems with corrupted repositories (completely bogus revision "
dongsheng@653 3296 "timestamps and files that have remained locked for over a decade are just two "
dongsheng@653 3297 "of the less interesting problems I can recall from personal experience)."
dongsheng@653 3298 msgstr ""
dongsheng@653 3299
dongsheng@714 3300 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 3301 #: ../en/ch01-intro.xml:572
dongsheng@653 3302 msgid "Mercurial can import revision history from a CVS repository."
dongsheng@653 3303 msgstr ""
dongsheng@653 3304
dongsheng@714 3305 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 3306 #: ../en/ch01-intro.xml:578
dongsheng@653 3307 msgid "Commercial tools"
dongsheng@653 3308 msgstr "商业工具"
dongsheng@653 3309
dongsheng@714 3310 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 3311 #: ../en/ch01-intro.xml:580
dongsheng@653 3312 msgid ""
dongsheng@653 3313 "Perforce has a centralised client/server architecture, with no client-side "
dongsheng@653 3314 "caching of any data. Unlike modern revision control tools, Perforce requires "
dongsheng@653 3315 "that a user run a command to inform the server about every file they intend "
dongsheng@653 3316 "to edit."
dongsheng@653 3317 msgstr ""
dongsheng@653 3318
dongsheng@714 3319 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 3320 #: ../en/ch01-intro.xml:586
dongsheng@653 3321 msgid ""
dongsheng@653 3322 "The performance of Perforce is quite good for small teams, but it falls off "
dongsheng@653 3323 "rapidly as the number of users grows beyond a few dozen. Modestly large "
dongsheng@653 3324 "Perforce installations require the deployment of proxies to cope with the "
dongsheng@653 3325 "load their users generate."
dongsheng@653 3326 msgstr ""
dongsheng@653 3327
dongsheng@714 3328 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 3329 #: ../en/ch01-intro.xml:595
dongsheng@653 3330 msgid "Choosing a revision control tool"
dongsheng@653 3331 msgstr "选择版本控制工具"
dongsheng@653 3332
dongsheng@714 3333 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 3334 #: ../en/ch01-intro.xml:597
dongsheng@653 3335 msgid ""
dongsheng@653 3336 "With the exception of CVS, all of the tools listed above have unique "
dongsheng@653 3337 "strengths that suit them to particular styles of work. There is no single "
dongsheng@653 3338 "revision control tool that is best in all situations."
dongsheng@653 3339 msgstr ""
dongsheng@653 3340
dongsheng@714 3341 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 3342 #: ../en/ch01-intro.xml:602
dongsheng@653 3343 msgid ""
dongsheng@653 3344 "As an example, Subversion is a good choice for working with frequently edited "
dongsheng@653 3345 "binary files, due to its centralised nature and support for file locking."
dongsheng@653 3346 msgstr ""
dongsheng@653 3347
dongsheng@714 3348 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 3349 #: ../en/ch01-intro.xml:606
dongsheng@653 3350 msgid ""
dongsheng@653 3351 "I personally find Mercurial's properties of simplicity, performance, and good "
dongsheng@653 3352 "merge support to be a compelling combination that has served me well for "
dongsheng@653 3353 "several years."
dongsheng@653 3354 msgstr ""
dongsheng@653 3355
dongsheng@714 3356 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 3357 #: ../en/ch01-intro.xml:614
dongsheng@653 3358 msgid "Switching from another tool to Mercurial"
dongsheng@653 3359 msgstr "从其它工具切换到 Mercurial"
dongsheng@653 3360
dongsheng@714 3361 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 3362 #: ../en/ch01-intro.xml:616
dongsheng@653 3363 msgid ""
dongsheng@653 3364 "Mercurial is bundled with an extension named <literal role=\"hg-ext"
dongsheng@653 3365 "\">convert</literal>, which can incrementally import revision history from "
dongsheng@653 3366 "several other revision control tools. By <quote>incremental</quote>, I mean "
dongsheng@653 3367 "that you can convert all of a project's history to date in one go, then rerun "
dongsheng@653 3368 "the conversion later to obtain new changes that happened after the initial "
dongsheng@653 3369 "conversion."
dongsheng@653 3370 msgstr ""
dongsheng@653 3371
dongsheng@714 3372 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 3373 #: ../en/ch01-intro.xml:624
dongsheng@653 3374 msgid ""
dongsheng@653 3375 "The revision control tools supported by <literal role=\"hg-ext\">convert</"
dongsheng@653 3376 "literal> are as follows:"
dongsheng@653 3377 msgstr "<literal role=\"hg-ext\">convert</literal> 支持的版本控制工具有:"
dongsheng@653 3378
dongsheng@714 3379 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 3380 #: ../en/ch01-intro.xml:632
dongsheng@653 3381 msgid ""
dongsheng@653 3382 "In addition, <literal role=\"hg-ext\">convert</literal> can export changes "
dongsheng@653 3383 "from Mercurial to Subversion. This makes it possible to try Subversion and "
dongsheng@653 3384 "Mercurial in parallel before committing to a switchover, without risking the "
dongsheng@653 3385 "loss of any work."
dongsheng@653 3386 msgstr ""
dongsheng@653 3387
dongsheng@714 3388 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 3389 #: ../en/ch01-intro.xml:638
dongsheng@653 3390 msgid ""
dongsheng@653 3391 "The <command role=\"hg-ext-convert\">convert</command> command is easy to "
dongsheng@653 3392 "use. Simply point it at the path or URL of the source repository, optionally "
dongsheng@653 3393 "give it the name of the destination repository, and it will start working. "
dongsheng@653 3394 "After the initial conversion, just run the same command again to import new "
dongsheng@653 3395 "changes."
dongsheng@653 3396 msgstr ""
dongsheng@653 3397
dongsheng@714 3398 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 3399 #: ../en/ch01-intro.xml:647
dongsheng@653 3400 msgid "A short history of revision control"
dongsheng@653 3401 msgstr "版本控制简史"
dongsheng@653 3402
dongsheng@714 3403 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 3404 #: ../en/ch01-intro.xml:649
dongsheng@653 3405 msgid ""
dongsheng@653 3406 "The best known of the old-time revision control tools is SCCS (Source Code "
dongsheng@653 3407 "Control System), which Marc Rochkind wrote at Bell Labs, in the early 1970s. "
dongsheng@653 3408 "SCCS operated on individual files, and required every person working on a "
dongsheng@653 3409 "project to have access to a shared workspace on a single system. Only one "
dongsheng@653 3410 "person could modify a file at any time; arbitration for access to files was "
dongsheng@653 3411 "via locks. It was common for people to lock files, and later forget to "
dongsheng@653 3412 "unlock them, preventing anyone else from modifying those files without the "
dongsheng@653 3413 "help of an administrator."
dongsheng@653 3414 msgstr ""
dongsheng@653 3415
dongsheng@714 3416 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 3417 #: ../en/ch01-intro.xml:660
dongsheng@653 3418 msgid ""
dongsheng@653 3419 "Walter Tichy developed a free alternative to SCCS in the early 1980s; he "
dongsheng@653 3420 "called his program RCS (Revision Control System). Like SCCS, RCS required "
dongsheng@653 3421 "developers to work in a single shared workspace, and to lock files to prevent "
dongsheng@653 3422 "multiple people from modifying them simultaneously."
dongsheng@653 3423 msgstr ""
dongsheng@653 3424
dongsheng@714 3425 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 3426 #: ../en/ch01-intro.xml:666
dongsheng@653 3427 msgid ""
dongsheng@653 3428 "Later in the 1980s, Dick Grune used RCS as a building block for a set of "
dongsheng@653 3429 "shell scripts he initially called cmt, but then renamed to CVS (Concurrent "
dongsheng@653 3430 "Versions System). The big innovation of CVS was that it let developers work "
dongsheng@653 3431 "simultaneously and somewhat independently in their own personal workspaces. "
dongsheng@653 3432 "The personal workspaces prevented developers from stepping on each other's "
dongsheng@653 3433 "toes all the time, as was common with SCCS and RCS. Each developer had a copy "
dongsheng@653 3434 "of every project file, and could modify their copies independently. They had "
dongsheng@653 3435 "to merge their edits prior to committing changes to the central repository."
dongsheng@653 3436 msgstr ""
dongsheng@653 3437
dongsheng@714 3438 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 3439 #: ../en/ch01-intro.xml:677
dongsheng@653 3440 msgid ""
dongsheng@653 3441 "Brian Berliner took Grune's original scripts and rewrote them in C, releasing "
dongsheng@653 3442 "in 1989 the code that has since developed into the modern version of CVS. "
dongsheng@653 3443 "CVS subsequently acquired the ability to operate over a network connection, "
dongsheng@653 3444 "giving it a client/server architecture. CVS's architecture is centralised; "
dongsheng@653 3445 "only the server has a copy of the history of the project. Client workspaces "
dongsheng@653 3446 "just contain copies of recent versions of the project's files, and a little "
dongsheng@653 3447 "metadata to tell them where the server is. CVS has been enormously "
dongsheng@653 3448 "successful; it is probably the world's most widely used revision control "
dongsheng@653 3449 "system."
dongsheng@653 3450 msgstr ""
dongsheng@653 3451
dongsheng@714 3452 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 3453 #: ../en/ch01-intro.xml:688
dongsheng@653 3454 msgid ""
dongsheng@653 3455 "In the early 1990s, Sun Microsystems developed an early distributed revision "
dongsheng@653 3456 "control system, called TeamWare. A TeamWare workspace contains a complete "
dongsheng@653 3457 "copy of the project's history. TeamWare has no notion of a central "
dongsheng@653 3458 "repository. (CVS relied upon RCS for its history storage; TeamWare used "
dongsheng@653 3459 "SCCS.)"
dongsheng@653 3460 msgstr ""
dongsheng@653 3461
dongsheng@714 3462 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 3463 #: ../en/ch01-intro.xml:695
dongsheng@653 3464 msgid ""
dongsheng@653 3465 "As the 1990s progressed, awareness grew of a number of problems with CVS. It "
dongsheng@653 3466 "records simultaneous changes to multiple files individually, instead of "
dongsheng@653 3467 "grouping them together as a single logically atomic operation. It does not "
dongsheng@653 3468 "manage its file hierarchy well; it is easy to make a mess of a repository by "
dongsheng@653 3469 "renaming files and directories. Worse, its source code is difficult to read "
dongsheng@653 3470 "and maintain, which made the <quote>pain level</quote> of fixing these "
dongsheng@653 3471 "architectural problems prohibitive."
dongsheng@653 3472 msgstr ""
dongsheng@653 3473
dongsheng@714 3474 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 3475 #: ../en/ch01-intro.xml:705
dongsheng@653 3476 msgid ""
dongsheng@653 3477 "In 2001, Jim Blandy and Karl Fogel, two developers who had worked on CVS, "
dongsheng@653 3478 "started a project to replace it with a tool that would have a better "
dongsheng@653 3479 "architecture and cleaner code. The result, Subversion, does not stray from "
dongsheng@653 3480 "CVS's centralised client/server model, but it adds multi-file atomic commits, "
dongsheng@653 3481 "better namespace management, and a number of other features that make it a "
dongsheng@653 3482 "generally better tool than CVS. Since its initial release, it has rapidly "
dongsheng@653 3483 "grown in popularity."
dongsheng@653 3484 msgstr ""
dongsheng@653 3485
dongsheng@714 3486 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 3487 #: ../en/ch01-intro.xml:714
dongsheng@653 3488 msgid ""
dongsheng@653 3489 "More or less simultaneously, Graydon Hoare began working on an ambitious "
dongsheng@653 3490 "distributed revision control system that he named Monotone. While Monotone "
dongsheng@653 3491 "addresses many of CVS's design flaws and has a peer-to-peer architecture, it "
dongsheng@653 3492 "goes beyond earlier (and subsequent) revision control tools in a number of "
dongsheng@653 3493 "innovative ways. It uses cryptographic hashes as identifiers, and has an "
dongsheng@653 3494 "integral notion of <quote>trust</quote> for code from different sources."
dongsheng@653 3495 msgstr ""
dongsheng@653 3496
dongsheng@714 3497 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 3498 #: ../en/ch01-intro.xml:723
dongsheng@653 3499 msgid ""
dongsheng@653 3500 "Mercurial began life in 2005. While a few aspects of its design are "
dongsheng@653 3501 "influenced by Monotone, Mercurial focuses on ease of use, high performance, "
dongsheng@653 3502 "and scalability to very large projects."
dongsheng@653 3503 msgstr ""
dongsheng@653 3504
dongsheng@627 3505 #. type: Content of: <book><chapter><title>
dongsheng@714 3506 #: ../en/ch02-tour-basic.xml:5
dongsheng@627 3507 msgid "A tour of Mercurial: the basics"
dongsheng@627 3508 msgstr "Mercurial 教程: 基础知识"
dongsheng@627 3509
dongsheng@627 3510 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 3511 #: ../en/ch02-tour-basic.xml:8
dongsheng@627 3512 msgid "Installing Mercurial on your system"
dongsheng@627 3513 msgstr "安装 Mercurial"
dongsheng@627 3514
dongsheng@627 3515 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 3516 #: ../en/ch02-tour-basic.xml:10
dongsheng@627 3517 msgid ""
dongsheng@627 3518 "Prebuilt binary packages of Mercurial are available for every popular "
dongsheng@627 3519 "operating system. These make it easy to start using Mercurial on your "
dongsheng@627 3520 "computer immediately."
dongsheng@627 3521 msgstr ""
dongsheng@644 3522 "对于每种流行的操作系统,都有已经构建的二进制软件包。这让在你的计算机上开始使"
dongsheng@644 3523 "用 Mercurial 变得很容易。"
dongsheng@627 3524
dongsheng@627 3525 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 3526 #: ../en/ch02-tour-basic.xml:15
songdongsheng@667 3527 msgid "Windows"
songdongsheng@668 3528 msgstr "Windows"
songdongsheng@667 3529
songdongsheng@667 3530 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 3531 #: ../en/ch02-tour-basic.xml:17
songdongsheng@667 3532 msgid ""
songdongsheng@667 3533 "The best version of Mercurial for Windows is TortoiseHg, which can be found "
songdongsheng@667 3534 "at <ulink url=\"http://bitbucket.org/tortoisehg/stable/wiki/Home\">http://"
songdongsheng@667 3535 "bitbucket.org/tortoisehg/stable/wiki/Home</ulink>. This package has no "
songdongsheng@667 3536 "external dependencies; it <quote>just works</quote>. It provides both "
songdongsheng@667 3537 "command line and graphical user interfaces."
songdongsheng@667 3538 msgstr ""
songdongsheng@711 3539 "Windows 中最好的 Mercurial 版本是TortoiseHg,它的主页地址是 <ulink url="
songdongsheng@711 3540 "\"http://bitbucket.org/tortoisehg/stable/wiki/Home\">http://bitbucket.org/"
songdongsheng@711 3541 "tortoisehg/stable/wiki/Home</ulink>。这个软件没有外部依赖,它可以<quote>独立工"
songdongsheng@711 3542 "作</quote>,同时提供了命令行和图形用户界面。"
songdongsheng@667 3543
songdongsheng@667 3544 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 3545 #: ../en/ch02-tour-basic.xml:27
songdongsheng@667 3546 msgid "Mac OS X"
songdongsheng@667 3547 msgstr "Mac OS X"
songdongsheng@667 3548
songdongsheng@667 3549 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 3550 #: ../en/ch02-tour-basic.xml:29
songdongsheng@667 3551 msgid ""
songdongsheng@667 3552 "Lee Cantey publishes an installer of Mercurial for Mac OS X at <ulink url="
songdongsheng@667 3553 "\"http://mercurial.berkwood.com\">http://mercurial.berkwood.com</ulink>."
songdongsheng@667 3554 msgstr ""
songdongsheng@711 3555 "Lee Cantey 为 Mac OS X 在 <ulink url=\"http://mercurial.berkwood.com"
songdongsheng@711 3556 "\">http://mercurial.berkwood.com</ulink> 发布了 Mercurial 安装程序。"
songdongsheng@667 3557
songdongsheng@667 3558 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 3559 #: ../en/ch02-tour-basic.xml:35
dongsheng@627 3560 msgid "Linux"
dongsheng@644 3561 msgstr "Linux"
dongsheng@627 3562
dongsheng@627 3563 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 3564 #: ../en/ch02-tour-basic.xml:37
dongsheng@627 3565 msgid ""
dongsheng@627 3566 "Because each Linux distribution has its own packaging tools, policies, and "
dongsheng@627 3567 "rate of development, it's difficult to give a comprehensive set of "
dongsheng@627 3568 "instructions on how to install Mercurial binaries. The version of Mercurial "
dongsheng@627 3569 "that you will end up with can vary depending on how active the person is who "
dongsheng@627 3570 "maintains the package for your distribution."
dongsheng@627 3571 msgstr ""
dongsheng@644 3572 "由于每种 Linux 发行版都有自己的包管理工具,开发策略和进度,从而很难给出安装 "
dongsheng@644 3573 "Mercurial 二进制包的全面说明。你安装的 Mercurial 版本,在很大程度上依赖于你所"
dongsheng@644 3574 "使用的发行版的 Mercurial 维护者的活跃程度。"
dongsheng@627 3575
dongsheng@627 3576 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 3577 #: ../en/ch02-tour-basic.xml:44
dongsheng@627 3578 msgid ""
dongsheng@627 3579 "To keep things simple, I will focus on installing Mercurial from the command "
dongsheng@627 3580 "line under the most popular Linux distributions. Most of these distributions "
dongsheng@627 3581 "provide graphical package managers that will let you install Mercurial with a "
dongsheng@627 3582 "single click; the package name to look for is <literal>mercurial</literal>."
dongsheng@627 3583 msgstr ""
dongsheng@644 3584 "为了让事情简单,我会致力于说明在最流行的 Linux 发行版中,从命令行安装 "
dongsheng@644 3585 "Mercurial 的方法。这些发行版都提供了图形界面的包管理器,让你通过点击鼠标安装 "
dongsheng@644 3586 "Mercurial;寻找的包名称是 <literal>mercurial</literal>。"
dongsheng@627 3587
dongsheng@627 3588 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 3589 #: ../en/ch02-tour-basic.xml:52
songdongsheng@667 3590 msgid "Ubuntu and Debian:"
songdongsheng@668 3591 msgstr "Ubuntu 与 Debian:"
dongsheng@627 3592
dongsheng@627 3593 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 3594 #: ../en/ch02-tour-basic.xml:54
dongsheng@714 3595 msgid "Fedora:"
dongsheng@715 3596 msgstr "Fedora:"
dongsheng@714 3597
dongsheng@714 3598 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 3599 #: ../en/ch02-tour-basic.xml:56
dongsheng@714 3600 msgid "OpenSUSE:"
dongsheng@715 3601 msgstr "OpenSUSE:"
dongsheng@627 3602
dongsheng@627 3603 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 3604 #: ../en/ch02-tour-basic.xml:58
dongsheng@627 3605 msgid "Gentoo:"
dongsheng@644 3606 msgstr "Gentoo:"
dongsheng@627 3607
dongsheng@646 3608 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 3609 #: ../en/ch02-tour-basic.xml:64
dongsheng@627 3610 msgid "Solaris"
dongsheng@646 3611 msgstr "Solaris"
dongsheng@646 3612
dongsheng@646 3613 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 3614 #: ../en/ch02-tour-basic.xml:66
dongsheng@627 3615 msgid ""
dongsheng@627 3616 "SunFreeWare, at <ulink url=\"http://www.sunfreeware.com\">http://www."
songdongsheng@667 3617 "sunfreeware.com</ulink>, provides prebuilt packages of Mercurial."
dongsheng@627 3618 msgstr ""
dongsheng@646 3619 "位于 <ulink url=\"http://www.sunfreeware.com\">http://www.sunfreeware.com</"
songdongsheng@668 3620 "ulink> 的 SunFreeWare 提供了 Mercurial 的二进制安装包。"
dongsheng@646 3621
dongsheng@627 3622 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 3623 #: ../en/ch02-tour-basic.xml:75
dongsheng@627 3624 msgid "Getting started"
dongsheng@627 3625 msgstr "开始"
dongsheng@627 3626
dongsheng@627 3627 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 3628 #: ../en/ch02-tour-basic.xml:77
dongsheng@627 3629 msgid ""
dongsheng@627 3630 "To begin, we'll use the <command role=\"hg-cmd\">hg version</command> command "
dongsheng@714 3631 "to find out whether Mercurial is installed properly. The actual version "
dongsheng@714 3632 "information that it prints isn't so important; we simply care whether the "
dongsheng@714 3633 "command runs and prints anything at all."
dongsheng@627 3634 msgstr ""
songdongsheng@711 3635 "首先,我们使用 <command role=\"hg-cmd\">hg version</command> 命令检查 "
dongsheng@715 3636 "Mercurial 是否已经正确安装。它打印出来的实际版本信息并不重要;我们只关心它是否"
dongsheng@715 3637 "能够运行,打印出信息。"
dongsheng@627 3638
dongsheng@627 3639 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 3640 #: ../en/ch02-tour-basic.xml:86
dongsheng@627 3641 msgid "Built-in help"
dongsheng@627 3642 msgstr "内置帮助"
dongsheng@627 3643
dongsheng@627 3644 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 3645 #: ../en/ch02-tour-basic.xml:88
dongsheng@627 3646 msgid ""
dongsheng@627 3647 "Mercurial provides a built-in help system. This is invaluable for those "
dongsheng@627 3648 "times when you find yourself stuck trying to remember how to run a command. "
dongsheng@627 3649 "If you are completely stuck, simply run <command role=\"hg-cmd\">hg help</"
dongsheng@627 3650 "command>; it will print a brief list of commands, along with a description of "
dongsheng@627 3651 "what each does. If you ask for help on a specific command (as below), it "
dongsheng@627 3652 "prints more detailed information."
dongsheng@627 3653 msgstr ""
songdongsheng@711 3654 "Mercurial 内置了帮助系统。当你不记得如何执行一个命令时,它会给你重要的帮助。如"
songdongsheng@711 3655 "果你完全没有头绪,那就直接运行 <command role=\"hg-cmd\">hg help</command>;它"
songdongsheng@711 3656 "会给出命令的简短列表,还描述了每个命令的作用。如果你需要具体命令的帮助(下述),"
songdongsheng@711 3657 "它会给出更详细的信息。"
dongsheng@627 3658
dongsheng@627 3659 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 3660 #: ../en/ch02-tour-basic.xml:99
dongsheng@627 3661 msgid ""
dongsheng@627 3662 "For a more impressive level of detail (which you won't usually need) run "
dongsheng@627 3663 "<command role=\"hg-cmd\">hg help <option role=\"hg-opt-global\">-v</option></"
dongsheng@627 3664 "command>. The <option role=\"hg-opt-global\">-v</option> option is short for "
dongsheng@627 3665 "<option role=\"hg-opt-global\">--verbose</option>, and tells Mercurial to "
dongsheng@627 3666 "print more information than it usually would."
dongsheng@627 3667 msgstr ""
songdongsheng@711 3668 "要获得更多的详细信息(通常不需要),可以执行 <command role=\"hg-cmd\">hg help "
songdongsheng@711 3669 "<option role=\"hg-opt-global\">-v</option></command>。选项 <option role=\"hg-"
songdongsheng@711 3670 "opt-global\">-v</option> 是 <option role=\"hg-opt-global\">--verbose</option> "
songdongsheng@711 3671 "的短格式,告诉 Mercurial 要打印通常不需要的更多信息。"
dongsheng@627 3672
dongsheng@627 3673 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 3674 #: ../en/ch02-tour-basic.xml:110
dongsheng@627 3675 msgid "Working with a repository"
dongsheng@627 3676 msgstr "使用版本库"
dongsheng@627 3677
dongsheng@627 3678 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 3679 #: ../en/ch02-tour-basic.xml:112
dongsheng@627 3680 msgid ""
dongsheng@627 3681 "In Mercurial, everything happens inside a <emphasis>repository</emphasis>. "
dongsheng@627 3682 "The repository for a project contains all of the files that <quote>belong to</"
dongsheng@627 3683 "quote> that project, along with a historical record of the project's files."
dongsheng@627 3684 msgstr ""
dongsheng@627 3685
dongsheng@627 3686 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 3687 #: ../en/ch02-tour-basic.xml:118
dongsheng@627 3688 msgid ""
dongsheng@627 3689 "There's nothing particularly magical about a repository; it is simply a "
dongsheng@627 3690 "directory tree in your filesystem that Mercurial treats as special. You can "
dongsheng@627 3691 "rename or delete a repository any time you like, using either the command "
dongsheng@627 3692 "line or your file browser."
dongsheng@627 3693 msgstr ""
dongsheng@627 3694
dongsheng@627 3695 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 3696 #: ../en/ch02-tour-basic.xml:125
dongsheng@627 3697 msgid "Making a local copy of a repository"
dongsheng@627 3698 msgstr "创建版本库的工作副本"
dongsheng@627 3699
dongsheng@627 3700 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 3701 #: ../en/ch02-tour-basic.xml:127
dongsheng@627 3702 msgid ""
dongsheng@627 3703 "<emphasis>Copying</emphasis> a repository is just a little bit special. "
dongsheng@627 3704 "While you could use a normal file copying command to make a copy of a "
dongsheng@627 3705 "repository, it's best to use a built-in command that Mercurial provides. "
dongsheng@627 3706 "This command is called <command role=\"hg-cmd\">hg clone</command>, because "
songdongsheng@667 3707 "it makes an identical copy of an existing repository."
songdongsheng@667 3708 msgstr ""
songdongsheng@667 3709
songdongsheng@667 3710 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 3711 #: ../en/ch02-tour-basic.xml:136
songdongsheng@667 3712 msgid ""
songdongsheng@667 3713 "One advantage of using <command role=\"hg-cmd\">hg clone</command> is that, "
songdongsheng@667 3714 "as we can see above, it lets us clone repositories over the network. Another "
songdongsheng@667 3715 "is that it remembers where we cloned from, which we'll find useful soon when "
songdongsheng@667 3716 "we want to fetch new changes from another repository."
songdongsheng@667 3717 msgstr ""
songdongsheng@667 3718
songdongsheng@667 3719 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 3720 #: ../en/ch02-tour-basic.xml:142
dongsheng@627 3721 msgid ""
dongsheng@627 3722 "If our clone succeeded, we should now have a local directory called <filename "
dongsheng@627 3723 "class=\"directory\">hello</filename>. This directory will contain some files."
dongsheng@627 3724 msgstr ""
dongsheng@627 3725
dongsheng@627 3726 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 3727 #: ../en/ch02-tour-basic.xml:148
dongsheng@627 3728 msgid ""
dongsheng@627 3729 "These files have the same contents and history in our repository as they do "
dongsheng@627 3730 "in the repository we cloned."
dongsheng@627 3731 msgstr ""
dongsheng@627 3732
dongsheng@627 3733 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 3734 #: ../en/ch02-tour-basic.xml:151
dongsheng@627 3735 msgid ""
dongsheng@627 3736 "Every Mercurial repository is complete, self-contained, and independent. It "
songdongsheng@667 3737 "contains its own private copy of a project's files and history. As we just "
songdongsheng@667 3738 "mentioned, a cloned repository remembers the location of the repository it "
songdongsheng@667 3739 "was cloned from, but Mercurial will not communicate with that repository, or "
songdongsheng@667 3740 "any other, unless you tell it to."
songdongsheng@667 3741 msgstr ""
songdongsheng@667 3742
songdongsheng@667 3743 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 3744 #: ../en/ch02-tour-basic.xml:158
dongsheng@627 3745 msgid ""
dongsheng@627 3746 "What this means for now is that we're free to experiment with our repository, "
dongsheng@627 3747 "safe in the knowledge that it's a private <quote>sandbox</quote> that won't "
dongsheng@627 3748 "affect anyone else."
dongsheng@627 3749 msgstr ""
dongsheng@627 3750
dongsheng@627 3751 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 3752 #: ../en/ch02-tour-basic.xml:164
dongsheng@627 3753 msgid "What's in a repository?"
dongsheng@627 3754 msgstr "什么是版本库?"
dongsheng@627 3755
dongsheng@627 3756 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 3757 #: ../en/ch02-tour-basic.xml:166
dongsheng@627 3758 msgid ""
dongsheng@627 3759 "When we take a more detailed look inside a repository, we can see that it "
dongsheng@627 3760 "contains a directory named <filename class=\"directory\">.hg</filename>. "
dongsheng@627 3761 "This is where Mercurial keeps all of its metadata for the repository."
dongsheng@627 3762 msgstr ""
dongsheng@627 3763
dongsheng@627 3764 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 3765 #: ../en/ch02-tour-basic.xml:173
dongsheng@627 3766 msgid ""
dongsheng@627 3767 "The contents of the <filename class=\"directory\">.hg</filename> directory "
dongsheng@627 3768 "and its subdirectories are private to Mercurial. Every other file and "
dongsheng@627 3769 "directory in the repository is yours to do with as you please."
dongsheng@627 3770 msgstr ""
dongsheng@627 3771
dongsheng@627 3772 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 3773 #: ../en/ch02-tour-basic.xml:179
dongsheng@627 3774 msgid ""
dongsheng@627 3775 "To introduce a little terminology, the <filename class=\"directory\">.hg</"
dongsheng@627 3776 "filename> directory is the <quote>real</quote> repository, and all of the "
dongsheng@627 3777 "files and directories that coexist with it are said to live in the "
dongsheng@627 3778 "<emphasis>working directory</emphasis>. An easy way to remember the "
dongsheng@627 3779 "distinction is that the <emphasis>repository</emphasis> contains the "
dongsheng@627 3780 "<emphasis>history</emphasis> of your project, while the <emphasis>working "
dongsheng@627 3781 "directory</emphasis> contains a <emphasis>snapshot</emphasis> of your project "
dongsheng@627 3782 "at a particular point in history."
dongsheng@627 3783 msgstr ""
dongsheng@627 3784
dongsheng@627 3785 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 3786 #: ../en/ch02-tour-basic.xml:194
dongsheng@627 3787 msgid "A tour through history"
dongsheng@627 3788 msgstr "回溯历史"
dongsheng@627 3789
dongsheng@627 3790 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 3791 #: ../en/ch02-tour-basic.xml:196
dongsheng@627 3792 msgid ""
dongsheng@627 3793 "One of the first things we might want to do with a new, unfamiliar repository "
dongsheng@627 3794 "is understand its history. The <command role=\"hg-cmd\">hg log</command> "
songdongsheng@667 3795 "command gives us a view of the history of changes in the repository."
songdongsheng@667 3796 msgstr ""
songdongsheng@667 3797
songdongsheng@667 3798 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 3799 #: ../en/ch02-tour-basic.xml:203
dongsheng@627 3800 msgid ""
dongsheng@627 3801 "By default, this command prints a brief paragraph of output for each change "
dongsheng@627 3802 "to the project that was recorded. In Mercurial terminology, we call each of "
dongsheng@627 3803 "these recorded events a <emphasis>changeset</emphasis>, because it can "
dongsheng@627 3804 "contain a record of changes to several files."
dongsheng@627 3805 msgstr ""
dongsheng@627 3806
dongsheng@627 3807 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 3808 #: ../en/ch02-tour-basic.xml:209
dongsheng@627 3809 msgid ""
dongsheng@627 3810 "The fields in a record of output from <command role=\"hg-cmd\">hg log</"
dongsheng@627 3811 "command> are as follows."
dongsheng@627 3812 msgstr ""
dongsheng@627 3813
dongsheng@627 3814 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 3815 #: ../en/ch02-tour-basic.xml:213
dongsheng@627 3816 msgid ""
dongsheng@627 3817 "<literal>changeset</literal>: This field has the format of a number, followed "
songdongsheng@667 3818 "by a colon, followed by a hexadecimal (or <emphasis>hex</emphasis>) string. "
songdongsheng@667 3819 "These are <emphasis>identifiers</emphasis> for the changeset. The hex string "
songdongsheng@667 3820 "is a unique identifier: the same hex string will always refer to the same "
dongsheng@714 3821 "changeset in every copy of this repository. The number is shorter and easier "
dongsheng@714 3822 "to type than the hex string, but it isn't unique: the same number in two "
dongsheng@714 3823 "different clones of a repository may identify different changesets."
dongsheng@627 3824 msgstr ""
dongsheng@627 3825
dongsheng@627 3826 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 3827 #: ../en/ch02-tour-basic.xml:224
dongsheng@627 3828 msgid ""
dongsheng@627 3829 "<literal>user</literal>: The identity of the person who created the "
dongsheng@627 3830 "changeset. This is a free-form field, but it most often contains a person's "
dongsheng@627 3831 "name and email address."
dongsheng@627 3832 msgstr ""
dongsheng@627 3833
dongsheng@627 3834 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 3835 #: ../en/ch02-tour-basic.xml:228
dongsheng@627 3836 msgid ""
dongsheng@627 3837 "<literal>date</literal>: The date and time on which the changeset was "
dongsheng@627 3838 "created, and the timezone in which it was created. (The date and time are "
dongsheng@627 3839 "local to that timezone; they display what time and date it was for the person "
dongsheng@627 3840 "who created the changeset.)"
dongsheng@627 3841 msgstr ""
dongsheng@627 3842
dongsheng@627 3843 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 3844 #: ../en/ch02-tour-basic.xml:233
dongsheng@627 3845 msgid ""
dongsheng@627 3846 "<literal>summary</literal>: The first line of the text message that the "
dongsheng@627 3847 "creator of the changeset entered to describe the changeset."
dongsheng@627 3848 msgstr ""
dongsheng@627 3849
songdongsheng@667 3850 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 3851 #: ../en/ch02-tour-basic.xml:237
songdongsheng@667 3852 msgid ""
songdongsheng@667 3853 "Some changesets, such as the first in the list above, have a <literal>tag</"
songdongsheng@667 3854 "literal> field. A tag is another way to identify a changeset, by giving it "
songdongsheng@667 3855 "an easy-to-remember name. (The tag named <literal>tip</literal> is special: "
songdongsheng@667 3856 "it always refers to the newest change in a repository.)"
songdongsheng@667 3857 msgstr ""
songdongsheng@667 3858
songdongsheng@667 3859 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 3860 #: ../en/ch02-tour-basic.xml:245
dongsheng@627 3861 msgid ""
dongsheng@627 3862 "The default output printed by <command role=\"hg-cmd\">hg log</command> is "
dongsheng@627 3863 "purely a summary; it is missing a lot of detail."
dongsheng@627 3864 msgstr ""
dongsheng@627 3865
dongsheng@627 3866 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 3867 #: ../en/ch02-tour-basic.xml:249
dongsheng@627 3868 msgid ""
songdongsheng@658 3869 "<xref linkend=\"fig:tour-basic:history\"/> provides a graphical "
songdongsheng@658 3870 "representation of the history of the <filename class=\"directory\">hello</"
songdongsheng@658 3871 "filename> repository, to make it a little easier to see which direction "
songdongsheng@658 3872 "history is <quote>flowing</quote> in. We'll be returning to this figure "
songdongsheng@658 3873 "several times in this chapter and the chapter that follows."
songdongsheng@658 3874 msgstr ""
songdongsheng@658 3875
songdongsheng@658 3876 #. type: Content of: <book><chapter><sect1><figure><title>
dongsheng@714 3877 #: ../en/ch02-tour-basic.xml:258
dongsheng@627 3878 msgid ""
dongsheng@627 3879 "Graphical history of the <filename class=\"directory\">hello</filename> "
dongsheng@627 3880 "repository"
dongsheng@660 3881 msgstr "版本库 <filename class=\"directory\">hello</filename> 的历史图"
dongsheng@627 3882
songdongsheng@658 3883 #. type: Content of: <book><chapter><sect1><figure>
dongsheng@714 3884 #: ../en/ch02-tour-basic.xml:260 ../en/ch03-tour-merge.xml:61
dongsheng@714 3885 #: ../en/ch03-tour-merge.xml:207 ../en/ch04-concepts.xml:290
songdongsheng@658 3886 msgid "<placeholder type=\"mediaobject\" id=\"0\"/>"
songdongsheng@658 3887 msgstr ""
songdongsheng@658 3888
songdongsheng@658 3889 #. type: Content of: <book><chapter><sect1><figure><mediaobject>
dongsheng@714 3890 #: ../en/ch02-tour-basic.xml:261
songdongsheng@658 3891 msgid ""
songdongsheng@658 3892 "<imageobject><imagedata fileref=\"figs/tour-history.png\"/></imageobject>"
songdongsheng@658 3893 msgstr ""
songdongsheng@658 3894
songdongsheng@658 3895 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject><textobject><phrase>
dongsheng@714 3896 #: ../en/ch02-tour-basic.xml:262 ../en/ch03-tour-merge.xml:63
dongsheng@714 3897 #: ../en/ch03-tour-merge.xml:95 ../en/ch03-tour-merge.xml:182
dongsheng@714 3898 #: ../en/ch03-tour-merge.xml:209 ../en/ch03-tour-merge.xml:279
dongsheng@714 3899 #: ../en/ch04-concepts.xml:59 ../en/ch04-concepts.xml:108
dongsheng@714 3900 #: ../en/ch04-concepts.xml:198 ../en/ch04-concepts.xml:292
dongsheng@714 3901 #: ../en/ch04-concepts.xml:347 ../en/ch04-concepts.xml:362
dongsheng@714 3902 #: ../en/ch04-concepts.xml:403 ../en/ch04-concepts.xml:423
dongsheng@714 3903 #: ../en/ch04-concepts.xml:469 ../en/ch06-collab.xml:316
dongsheng@714 3904 #: ../en/ch09-undo.xml:344 ../en/ch09-undo.xml:391 ../en/ch09-undo.xml:464
dongsheng@714 3905 #: ../en/ch09-undo.xml:502 ../en/ch09-undo.xml:658 ../en/ch09-undo.xml:682
dongsheng@714 3906 #: ../en/ch09-undo.xml:700 ../en/ch09-undo.xml:714 ../en/ch09-undo.xml:727
dongsheng@714 3907 #: ../en/ch12-mq.xml:413
songdongsheng@658 3908 msgid "XXX add text"
songdongsheng@658 3909 msgstr ""
songdongsheng@658 3910
dongsheng@627 3911 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 3912 #: ../en/ch02-tour-basic.xml:267
dongsheng@627 3913 msgid "Changesets, revisions, and talking to other people"
songdongsheng@665 3914 msgstr "修改集,版本,与其它用户交互"
dongsheng@627 3915
dongsheng@627 3916 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 3917 #: ../en/ch02-tour-basic.xml:270
dongsheng@627 3918 msgid ""
dongsheng@627 3919 "As English is a notoriously sloppy language, and computer science has a "
dongsheng@627 3920 "hallowed history of terminological confusion (why use one term when four will "
dongsheng@627 3921 "do?), revision control has a variety of words and phrases that mean the same "
dongsheng@627 3922 "thing. If you are talking about Mercurial history with other people, you "
dongsheng@627 3923 "will find that the word <quote>changeset</quote> is often compressed to "
dongsheng@627 3924 "<quote>change</quote> or (when written) <quote>cset</quote>, and sometimes a "
dongsheng@627 3925 "changeset is referred to as a <quote>revision</quote> or a <quote>rev</quote>."
dongsheng@627 3926 msgstr ""
dongsheng@627 3927
dongsheng@627 3928 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 3929 #: ../en/ch02-tour-basic.xml:280
dongsheng@627 3930 msgid ""
dongsheng@627 3931 "While it doesn't matter what <emphasis>word</emphasis> you use to refer to "
dongsheng@627 3932 "the concept of <quote>a changeset</quote>, the <emphasis>identifier</"
dongsheng@627 3933 "emphasis> that you use to refer to <quote>a <emphasis>specific</emphasis> "
dongsheng@627 3934 "changeset</quote> is of great importance. Recall that the <literal>changeset</"
dongsheng@627 3935 "literal> field in the output from <command role=\"hg-cmd\">hg log</command> "
dongsheng@627 3936 "identifies a changeset using both a number and a hexadecimal string."
dongsheng@627 3937 msgstr ""
dongsheng@627 3938
dongsheng@627 3939 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 3940 #: ../en/ch02-tour-basic.xml:289
songdongsheng@667 3941 msgid ""
songdongsheng@667 3942 "The revision number is a handy notation that is <emphasis>only valid in that "
songdongsheng@667 3943 "repository</emphasis>."
songdongsheng@658 3944 msgstr ""
songdongsheng@658 3945
songdongsheng@658 3946 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 3947 #: ../en/ch02-tour-basic.xml:292
dongsheng@627 3948 msgid ""
songdongsheng@667 3949 "The hexadecimal string is the <emphasis>permanent, unchanging identifier</"
dongsheng@627 3950 "emphasis> that will always identify that exact changeset in <emphasis>every</"
dongsheng@627 3951 "emphasis> copy of the repository."
dongsheng@627 3952 msgstr ""
dongsheng@627 3953
dongsheng@627 3954 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 3955 #: ../en/ch02-tour-basic.xml:298
dongsheng@627 3956 msgid ""
dongsheng@627 3957 "This distinction is important. If you send someone an email talking about "
dongsheng@627 3958 "<quote>revision 33</quote>, there's a high likelihood that their revision 33 "
dongsheng@627 3959 "will <emphasis>not be the same</emphasis> as yours. The reason for this is "
dongsheng@627 3960 "that a revision number depends on the order in which changes arrived in a "
dongsheng@627 3961 "repository, and there is no guarantee that the same changes will happen in "
songdongsheng@667 3962 "the same order in different repositories. Three changes <literal>a,b,c</"
songdongsheng@667 3963 "literal> can easily appear in one repository as <literal>0,1,2</literal>, "
songdongsheng@667 3964 "while in another as <literal>0,2,1</literal>."
songdongsheng@667 3965 msgstr ""
songdongsheng@667 3966
songdongsheng@667 3967 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 3968 #: ../en/ch02-tour-basic.xml:310
dongsheng@627 3969 msgid ""
dongsheng@627 3970 "Mercurial uses revision numbers purely as a convenient shorthand. If you "
dongsheng@627 3971 "need to discuss a changeset with someone, or make a record of a changeset for "
dongsheng@627 3972 "some other reason (for example, in a bug report), use the hexadecimal "
dongsheng@627 3973 "identifier."
dongsheng@627 3974 msgstr ""
dongsheng@627 3975
dongsheng@627 3976 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 3977 #: ../en/ch02-tour-basic.xml:318
dongsheng@627 3978 msgid "Viewing specific revisions"
dongsheng@627 3979 msgstr "察看指定版本"
dongsheng@627 3980
dongsheng@627 3981 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 3982 #: ../en/ch02-tour-basic.xml:320
dongsheng@627 3983 msgid ""
dongsheng@627 3984 "To narrow the output of <command role=\"hg-cmd\">hg log</command> down to a "
dongsheng@627 3985 "single revision, use the <option role=\"hg-opt-log\">-r</option> (or <option "
dongsheng@627 3986 "role=\"hg-opt-log\">--rev</option>) option. You can use either a revision "
songdongsheng@667 3987 "number or a hexadecimal identifier, and you can provide as many revisions as "
songdongsheng@667 3988 "you want."
songdongsheng@667 3989 msgstr ""
songdongsheng@667 3990
songdongsheng@667 3991 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 3992 #: ../en/ch02-tour-basic.xml:329
dongsheng@627 3993 msgid ""
dongsheng@627 3994 "If you want to see the history of several revisions without having to list "
dongsheng@627 3995 "each one, you can use <emphasis>range notation</emphasis>; this lets you "
dongsheng@627 3996 "express the idea <quote>I want all revisions between <literal>abc</literal> "
dongsheng@627 3997 "and <literal>def</literal>, inclusive</quote>."
dongsheng@627 3998 msgstr ""
dongsheng@627 3999
dongsheng@627 4000 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 4001 #: ../en/ch02-tour-basic.xml:337
dongsheng@627 4002 msgid ""
dongsheng@627 4003 "Mercurial also honours the order in which you specify revisions, so <command "
dongsheng@627 4004 "role=\"hg-cmd\">hg log -r 2:4</command> prints 2, 3, and 4. while <command "
dongsheng@627 4005 "role=\"hg-cmd\">hg log -r 4:2</command> prints 4, 3, and 2."
dongsheng@627 4006 msgstr ""
dongsheng@627 4007
dongsheng@627 4008 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 4009 #: ../en/ch02-tour-basic.xml:344
dongsheng@627 4010 msgid "More detailed information"
dongsheng@627 4011 msgstr "更详细的信息"
dongsheng@627 4012
dongsheng@627 4013 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 4014 #: ../en/ch02-tour-basic.xml:346
dongsheng@627 4015 msgid ""
dongsheng@627 4016 "While the summary information printed by <command role=\"hg-cmd\">hg log</"
dongsheng@627 4017 "command> is useful if you already know what you're looking for, you may need "
dongsheng@627 4018 "to see a complete description of the change, or a list of the files changed, "
dongsheng@627 4019 "if you're trying to decide whether a changeset is the one you're looking for. "
dongsheng@627 4020 "The <command role=\"hg-cmd\">hg log</command> command's <option role=\"hg-opt-"
dongsheng@627 4021 "global\">-v</option> (or <option role=\"hg-opt-global\">--verbose</option>) "
dongsheng@627 4022 "option gives you this extra detail."
dongsheng@627 4023 msgstr ""
dongsheng@627 4024
dongsheng@627 4025 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 4026 #: ../en/ch02-tour-basic.xml:358
dongsheng@627 4027 msgid ""
dongsheng@627 4028 "If you want to see both the description and content of a change, add the "
dongsheng@627 4029 "<option role=\"hg-opt-log\">-p</option> (or <option role=\"hg-opt-log\">--"
dongsheng@627 4030 "patch</option>) option. This displays the content of a change as a "
dongsheng@627 4031 "<emphasis>unified diff</emphasis> (if you've never seen a unified diff "
songdongsheng@658 4032 "before, see <xref linkend=\"sec:mq:patch\"/> for an overview)."
dongsheng@627 4033 msgstr ""
dongsheng@627 4034
songdongsheng@667 4035 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 4036 #: ../en/ch02-tour-basic.xml:368
songdongsheng@667 4037 msgid ""
songdongsheng@667 4038 "The <option role=\"hg-opt-log\">-p</option> option is tremendously useful, so "
songdongsheng@667 4039 "it's well worth remembering."
songdongsheng@667 4040 msgstr ""
songdongsheng@667 4041
dongsheng@627 4042 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 4043 #: ../en/ch02-tour-basic.xml:375
dongsheng@627 4044 msgid "All about command options"
dongsheng@627 4045 msgstr "命令选项"
dongsheng@627 4046
dongsheng@627 4047 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 4048 #: ../en/ch02-tour-basic.xml:377
dongsheng@627 4049 msgid ""
dongsheng@627 4050 "Let's take a brief break from exploring Mercurial commands to discuss a "
dongsheng@627 4051 "pattern in the way that they work; you may find this useful to keep in mind "
dongsheng@627 4052 "as we continue our tour."
dongsheng@627 4053 msgstr ""
dongsheng@627 4054
dongsheng@627 4055 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 4056 #: ../en/ch02-tour-basic.xml:381
dongsheng@627 4057 msgid ""
dongsheng@627 4058 "Mercurial has a consistent and straightforward approach to dealing with the "
dongsheng@627 4059 "options that you can pass to commands. It follows the conventions for "
dongsheng@627 4060 "options that are common to modern Linux and Unix systems."
dongsheng@627 4061 msgstr ""
dongsheng@627 4062
dongsheng@627 4063 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 4064 #: ../en/ch02-tour-basic.xml:388
dongsheng@627 4065 msgid ""
dongsheng@627 4066 "Every option has a long name. For example, as we've already seen, the "
dongsheng@627 4067 "<command role=\"hg-cmd\">hg log</command> command accepts a <option role=\"hg-"
dongsheng@627 4068 "opt-log\">--rev</option> option."
dongsheng@627 4069 msgstr ""
dongsheng@627 4070
dongsheng@627 4071 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 4072 #: ../en/ch02-tour-basic.xml:394
dongsheng@627 4073 msgid ""
dongsheng@627 4074 "Most options have short names, too. Instead of <option role=\"hg-opt-log\">--"
dongsheng@627 4075 "rev</option>, we can use <option role=\"hg-opt-log\">-r</option>. (The "
dongsheng@627 4076 "reason that some options don't have short names is that the options in "
dongsheng@627 4077 "question are rarely used.)"
dongsheng@627 4078 msgstr ""
dongsheng@627 4079
dongsheng@627 4080 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 4081 #: ../en/ch02-tour-basic.xml:401
songdongsheng@667 4082 msgid ""
songdongsheng@667 4083 "Long options start with two dashes (e.g. <option role=\"hg-opt-log\">--rev</"
dongsheng@627 4084 "option>), while short options start with one (e.g. <option role=\"hg-opt-log"
dongsheng@627 4085 "\">-r</option>)."
dongsheng@627 4086 msgstr ""
dongsheng@627 4087
dongsheng@627 4088 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 4089 #: ../en/ch02-tour-basic.xml:407
dongsheng@627 4090 msgid ""
dongsheng@627 4091 "Option naming and usage is consistent across commands. For example, every "
dongsheng@627 4092 "command that lets you specify a changeset ID or revision number accepts both "
dongsheng@627 4093 "<option role=\"hg-opt-log\">-r</option> and <option role=\"hg-opt-log\">--"
dongsheng@627 4094 "rev</option> arguments."
dongsheng@627 4095 msgstr ""
dongsheng@627 4096
songdongsheng@667 4097 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 4098 #: ../en/ch02-tour-basic.xml:414
songdongsheng@667 4099 msgid ""
songdongsheng@667 4100 "If you are using short options, you can save typing by running them together. "
songdongsheng@667 4101 "For example, the command <command role=\"hg-cmd\">hg log -v -p -r 2</command> "
songdongsheng@667 4102 "can be written as <command role=\"hg-cmd\">hg log -vpr2</command>."
songdongsheng@667 4103 msgstr ""
songdongsheng@667 4104
songdongsheng@667 4105 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 4106 #: ../en/ch02-tour-basic.xml:421
dongsheng@714 4107 msgid ""
dongsheng@714 4108 "In the examples throughout this book, I usually use short options instead of "
dongsheng@714 4109 "long. This simply reflects my own preference, so don't read anything "
dongsheng@714 4110 "significant into it."
dongsheng@714 4111 msgstr ""
dongsheng@714 4112
dongsheng@714 4113 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 4114 #: ../en/ch02-tour-basic.xml:425
dongsheng@627 4115 msgid ""
dongsheng@627 4116 "Most commands that print output of some kind will print more output when "
dongsheng@627 4117 "passed a <option role=\"hg-opt-global\">-v</option> (or <option role=\"hg-opt-"
dongsheng@627 4118 "global\">--verbose</option>) option, and less when passed <option role=\"hg-"
dongsheng@627 4119 "opt-global\">-q</option> (or <option role=\"hg-opt-global\">--quiet</option>)."
dongsheng@627 4120 msgstr ""
dongsheng@627 4121
songdongsheng@667 4122 #. type: Content of: <book><chapter><sect1><note><title>
dongsheng@714 4123 #: ../en/ch02-tour-basic.xml:432
songdongsheng@667 4124 msgid "Option naming consistency"
songdongsheng@667 4125 msgstr ""
songdongsheng@667 4126
songdongsheng@667 4127 #. type: Content of: <book><chapter><sect1><note><para>
dongsheng@714 4128 #: ../en/ch02-tour-basic.xml:434
songdongsheng@667 4129 msgid ""
songdongsheng@667 4130 "Almost always, Mercurial commands use consistent option names to refer to the "
songdongsheng@667 4131 "same concepts. For instance, if a command deals with changesets, you'll "
songdongsheng@667 4132 "always identify them with <option role=\"hg-opt-log\">--rev</option> or "
songdongsheng@667 4133 "<option role=\"hg-opt-log\">-r</option>. This consistent use of option names "
songdongsheng@667 4134 "makes it easier to remember what options a particular command takes."
songdongsheng@667 4135 msgstr ""
songdongsheng@667 4136
dongsheng@627 4137 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 4138 #: ../en/ch02-tour-basic.xml:445
dongsheng@627 4139 msgid "Making and reviewing changes"
dongsheng@627 4140 msgstr "创建和复审修改"
dongsheng@627 4141
dongsheng@627 4142 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 4143 #: ../en/ch02-tour-basic.xml:447
dongsheng@627 4144 msgid ""
dongsheng@627 4145 "Now that we have a grasp of viewing history in Mercurial, let's take a look "
dongsheng@627 4146 "at making some changes and examining them."
dongsheng@627 4147 msgstr ""
dongsheng@627 4148
dongsheng@627 4149 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 4150 #: ../en/ch02-tour-basic.xml:451
dongsheng@627 4151 msgid ""
dongsheng@627 4152 "The first thing we'll do is isolate our experiment in a repository of its "
dongsheng@627 4153 "own. We use the <command role=\"hg-cmd\">hg clone</command> command, but we "
dongsheng@627 4154 "don't need to clone a copy of the remote repository. Since we already have a "
dongsheng@627 4155 "copy of it locally, we can just clone that instead. This is much faster than "
dongsheng@627 4156 "cloning over the network, and cloning a local repository uses less disk space "
songdongsheng@667 4157 "in most cases, too<placeholder type=\"footnote\" id=\"0\"/>."
songdongsheng@667 4158 msgstr ""
songdongsheng@667 4159
songdongsheng@667 4160 #. type: Content of: <book><chapter><sect1><para><footnote><para>
dongsheng@714 4161 #: ../en/ch02-tour-basic.xml:458
songdongsheng@667 4162 msgid ""
songdongsheng@667 4163 "The saving of space arises when source and destination repositories are on "
songdongsheng@667 4164 "the same filesystem, in which case Mercurial will use hardlinks to do copy-on-"
songdongsheng@667 4165 "write sharing of its internal metadata. If that explanation meant nothing to "
songdongsheng@667 4166 "you, don't worry: everything happens transparently and automatically, and you "
songdongsheng@667 4167 "don't need to understand it."
songdongsheng@667 4168 msgstr ""
songdongsheng@667 4169
songdongsheng@667 4170 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 4171 #: ../en/ch02-tour-basic.xml:468
dongsheng@627 4172 msgid ""
dongsheng@627 4173 "As an aside, it's often good practice to keep a <quote>pristine</quote> copy "
dongsheng@627 4174 "of a remote repository around, which you can then make temporary clones of to "
dongsheng@627 4175 "create sandboxes for each task you want to work on. This lets you work on "
dongsheng@627 4176 "multiple tasks in parallel, each isolated from the others until it's complete "
dongsheng@627 4177 "and you're ready to integrate it back. Because local clones are so cheap, "
dongsheng@627 4178 "there's almost no overhead to cloning and destroying repositories whenever "
dongsheng@627 4179 "you want."
dongsheng@627 4180 msgstr ""
dongsheng@627 4181
dongsheng@627 4182 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 4183 #: ../en/ch02-tour-basic.xml:477
dongsheng@627 4184 msgid ""
dongsheng@627 4185 "In our <filename class=\"directory\">my-hello</filename> repository, we have "
dongsheng@627 4186 "a file <filename>hello.c</filename> that contains the classic <quote>hello, "
songdongsheng@667 4187 "world</quote> program."
songdongsheng@667 4188 msgstr ""
songdongsheng@667 4189
songdongsheng@667 4190 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 4191 #: ../en/ch02-tour-basic.xml:483
songdongsheng@667 4192 msgid "Let's edit this file so that it prints a second line of output."
songdongsheng@667 4193 msgstr ""
songdongsheng@667 4194
songdongsheng@667 4195 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 4196 #: ../en/ch02-tour-basic.xml:488
dongsheng@627 4197 msgid ""
dongsheng@627 4198 "Mercurial's <command role=\"hg-cmd\">hg status</command> command will tell us "
dongsheng@627 4199 "what Mercurial knows about the files in the repository."
dongsheng@627 4200 msgstr ""
dongsheng@627 4201
dongsheng@627 4202 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 4203 #: ../en/ch02-tour-basic.xml:494
dongsheng@627 4204 msgid ""
dongsheng@627 4205 "The <command role=\"hg-cmd\">hg status</command> command prints no output for "
dongsheng@627 4206 "some files, but a line starting with <quote><literal>M</literal></quote> for "
dongsheng@627 4207 "<filename>hello.c</filename>. Unless you tell it to, <command role=\"hg-cmd"
dongsheng@627 4208 "\">hg status</command> will not print any output for files that have not been "
dongsheng@627 4209 "modified."
dongsheng@627 4210 msgstr ""
dongsheng@627 4211
dongsheng@627 4212 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 4213 #: ../en/ch02-tour-basic.xml:501
dongsheng@627 4214 msgid ""
dongsheng@627 4215 "The <quote><literal>M</literal></quote> indicates that Mercurial has noticed "
dongsheng@627 4216 "that we modified <filename>hello.c</filename>. We didn't need to "
dongsheng@627 4217 "<emphasis>inform</emphasis> Mercurial that we were going to modify the file "
dongsheng@627 4218 "before we started, or that we had modified the file after we were done; it "
dongsheng@627 4219 "was able to figure this out itself."
dongsheng@627 4220 msgstr ""
dongsheng@627 4221
dongsheng@627 4222 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 4223 #: ../en/ch02-tour-basic.xml:509
songdongsheng@667 4224 msgid ""
songdongsheng@667 4225 "It's somewhat helpful to know that we've modified <filename>hello.c</"
dongsheng@627 4226 "filename>, but we might prefer to know exactly <emphasis>what</emphasis> "
dongsheng@627 4227 "changes we've made to it. To do this, we use the <command role=\"hg-cmd\">hg "
dongsheng@627 4228 "diff</command> command."
dongsheng@627 4229 msgstr ""
dongsheng@627 4230
dongsheng@627 4231 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 4232 #: ../en/ch02-tour-basic.xml:518 ../en/ch12-mq.xml:187
songdongsheng@667 4233 msgid "Understanding patches"
songdongsheng@667 4234 msgstr "理解补丁"
songdongsheng@667 4235
songdongsheng@667 4236 #. type: Content of: <book><chapter><sect1><tip><para>
dongsheng@714 4237 #: ../en/ch02-tour-basic.xml:520
songdongsheng@667 4238 msgid ""
songdongsheng@667 4239 "Remember to take a look at <xref linkend=\"sec:mq:patch\"/> if you don't know "
songdongsheng@667 4240 "how to read output above."
songdongsheng@667 4241 msgstr ""
songdongsheng@667 4242
songdongsheng@667 4243 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 4244 #: ../en/ch02-tour-basic.xml:526
dongsheng@627 4245 msgid "Recording changes in a new changeset"
dongsheng@627 4246 msgstr "在新修改集中记录修改"
dongsheng@627 4247
dongsheng@627 4248 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 4249 #: ../en/ch02-tour-basic.xml:528
dongsheng@627 4250 msgid ""
dongsheng@627 4251 "We can modify files, build and test our changes, and use <command role=\"hg-"
dongsheng@627 4252 "cmd\">hg status</command> and <command role=\"hg-cmd\">hg diff</command> to "
dongsheng@627 4253 "review our changes, until we're satisfied with what we've done and arrive at "
dongsheng@627 4254 "a natural stopping point where we want to record our work in a new changeset."
dongsheng@627 4255 msgstr ""
dongsheng@627 4256
dongsheng@627 4257 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 4258 #: ../en/ch02-tour-basic.xml:535
dongsheng@627 4259 msgid ""
dongsheng@627 4260 "The <command role=\"hg-cmd\">hg commit</command> command lets us create a new "
dongsheng@627 4261 "changeset; we'll usually refer to this as <quote>making a commit</quote> or "
dongsheng@627 4262 "<quote>committing</quote>."
dongsheng@627 4263 msgstr ""
dongsheng@627 4264
dongsheng@627 4265 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 4266 #: ../en/ch02-tour-basic.xml:541
dongsheng@627 4267 msgid "Setting up a username"
dongsheng@627 4268 msgstr "配置用户名称"
dongsheng@627 4269
dongsheng@627 4270 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 4271 #: ../en/ch02-tour-basic.xml:543
dongsheng@627 4272 msgid ""
dongsheng@627 4273 "When you try to run <command role=\"hg-cmd\">hg commit</command> for the "
dongsheng@627 4274 "first time, it is not guaranteed to succeed. Mercurial records your name and "
dongsheng@627 4275 "address with each change that you commit, so that you and others will later "
dongsheng@627 4276 "be able to tell who made each change. Mercurial tries to automatically "
dongsheng@627 4277 "figure out a sensible username to commit the change with. It will attempt "
dongsheng@627 4278 "each of the following methods, in order:"
dongsheng@627 4279 msgstr ""
dongsheng@627 4280
dongsheng@627 4281 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
dongsheng@714 4282 #: ../en/ch02-tour-basic.xml:552
dongsheng@627 4283 msgid ""
dongsheng@627 4284 "If you specify a <option role=\"hg-opt-commit\">-u</option> option to the "
dongsheng@627 4285 "<command role=\"hg-cmd\">hg commit</command> command on the command line, "
dongsheng@627 4286 "followed by a username, this is always given the highest precedence."
dongsheng@627 4287 msgstr ""
dongsheng@627 4288
dongsheng@627 4289 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
dongsheng@714 4290 #: ../en/ch02-tour-basic.xml:557
dongsheng@627 4291 msgid ""
dongsheng@627 4292 "If you have set the <envar>HGUSER</envar> environment variable, this is "
dongsheng@627 4293 "checked next."
dongsheng@627 4294 msgstr ""
dongsheng@627 4295
dongsheng@627 4296 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
dongsheng@714 4297 #: ../en/ch02-tour-basic.xml:560
dongsheng@627 4298 msgid ""
dongsheng@627 4299 "If you create a file in your home directory called <filename role=\"special"
dongsheng@627 4300 "\">.hgrc</filename>, with a <envar role=\"rc-item-ui\">username</envar> "
dongsheng@627 4301 "entry, that will be used next. To see what the contents of this file should "
songdongsheng@658 4302 "look like, refer to <xref linkend=\"sec:tour-basic:username\"/> below."
dongsheng@627 4303 msgstr ""
dongsheng@627 4304
dongsheng@627 4305 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
dongsheng@714 4306 #: ../en/ch02-tour-basic.xml:568
dongsheng@627 4307 msgid ""
dongsheng@627 4308 "If you have set the <envar>EMAIL</envar> environment variable, this will be "
dongsheng@627 4309 "used next."
dongsheng@627 4310 msgstr ""
dongsheng@627 4311
dongsheng@627 4312 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
dongsheng@714 4313 #: ../en/ch02-tour-basic.xml:571
dongsheng@627 4314 msgid ""
dongsheng@627 4315 "Mercurial will query your system to find out your local user name and host "
dongsheng@627 4316 "name, and construct a username from these components. Since this often "
dongsheng@627 4317 "results in a username that is not very useful, it will print a warning if it "
dongsheng@627 4318 "has to do this."
dongsheng@627 4319 msgstr ""
dongsheng@627 4320
dongsheng@627 4321 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 4322 #: ../en/ch02-tour-basic.xml:578
dongsheng@627 4323 msgid ""
dongsheng@627 4324 "If all of these mechanisms fail, Mercurial will fail, printing an error "
dongsheng@627 4325 "message. In this case, it will not let you commit until you set up a "
dongsheng@627 4326 "username."
dongsheng@627 4327 msgstr ""
dongsheng@627 4328
dongsheng@627 4329 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 4330 #: ../en/ch02-tour-basic.xml:582
dongsheng@627 4331 msgid ""
dongsheng@627 4332 "You should think of the <envar>HGUSER</envar> environment variable and the "
dongsheng@627 4333 "<option role=\"hg-opt-commit\">-u</option> option to the <command role=\"hg-"
dongsheng@627 4334 "cmd\">hg commit</command> command as ways to <emphasis>override</emphasis> "
dongsheng@627 4335 "Mercurial's default selection of username. For normal use, the simplest and "
dongsheng@627 4336 "most robust way to set a username for yourself is by creating a <filename "
dongsheng@627 4337 "role=\"special\">.hgrc</filename> file; see below for details."
dongsheng@627 4338 msgstr ""
dongsheng@627 4339
dongsheng@627 4340 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
dongsheng@714 4341 #: ../en/ch02-tour-basic.xml:591
dongsheng@627 4342 msgid "Creating a Mercurial configuration file"
dongsheng@627 4343 msgstr "创建 Mercurial 的配置文件"
dongsheng@627 4344
dongsheng@627 4345 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 4346 #: ../en/ch02-tour-basic.xml:593
dongsheng@627 4347 msgid ""
songdongsheng@710 4348 "To set a user name, use your favorite editor to create a file called "
dongsheng@627 4349 "<filename role=\"special\">.hgrc</filename> in your home directory. "
dongsheng@627 4350 "Mercurial will use this file to look up your personalised configuration "
dongsheng@627 4351 "settings. The initial contents of your <filename role=\"special\">.hgrc</"
dongsheng@627 4352 "filename> should look like this."
dongsheng@627 4353 msgstr ""
dongsheng@627 4354
dongsheng@714 4355 #. type: Content of: <book><chapter><sect1><sect2><sect3><tip><title>
dongsheng@714 4356 #: ../en/ch02-tour-basic.xml:602
dongsheng@714 4357 msgid "<quote>Home directory</quote> on Windows"
dongsheng@714 4358 msgstr ""
dongsheng@714 4359
dongsheng@714 4360 #. type: Content of: <book><chapter><sect1><sect2><sect3><tip><para>
dongsheng@714 4361 #: ../en/ch02-tour-basic.xml:604
dongsheng@714 4362 msgid ""
dongsheng@714 4363 "When we refer to your home directory, on an English language installation of "
dongsheng@714 4364 "Windows this will usually be a folder named after your user name in "
dongsheng@714 4365 "<filename>C:\\Documents and Settings</filename>. You can find out the exact "
dongsheng@714 4366 "name of your home directory by opening a command prompt window and running "
dongsheng@714 4367 "the following command."
dongsheng@714 4368 msgstr ""
dongsheng@714 4369
dongsheng@714 4370 #. type: Content of: <book><chapter><sect1><sect2><sect3><tip><screen><prompt>
dongsheng@714 4371 #: ../en/ch02-tour-basic.xml:612
dongsheng@714 4372 msgid "C:\\>"
dongsheng@715 4373 msgstr "C:\\>"
dongsheng@714 4374
dongsheng@714 4375 #. type: Content of: <book><chapter><sect1><sect2><sect3><tip><screen><userinput>
dongsheng@714 4376 #: ../en/ch02-tour-basic.xml:612
dongsheng@714 4377 msgid "echo %UserProfile%"
dongsheng@715 4378 msgstr "echo %UserProfile%"
songdongsheng@667 4379
dongsheng@627 4380 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 4381 #: ../en/ch02-tour-basic.xml:619
dongsheng@627 4382 msgid ""
dongsheng@627 4383 "The <quote><literal>[ui]</literal></quote> line begins a <emphasis>section</"
dongsheng@627 4384 "emphasis> of the config file, so you can read the <quote><literal>username "
dongsheng@627 4385 "= ...</literal></quote> line as meaning <quote>set the value of the "
dongsheng@627 4386 "<literal>username</literal> item in the <literal>ui</literal> section</"
dongsheng@627 4387 "quote>. A section continues until a new section begins, or the end of the "
dongsheng@627 4388 "file. Mercurial ignores empty lines and treats any text from "
dongsheng@627 4389 "<quote><literal>#</literal></quote> to the end of a line as a comment."
dongsheng@627 4390 msgstr ""
dongsheng@627 4391
dongsheng@627 4392 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
dongsheng@714 4393 #: ../en/ch02-tour-basic.xml:632
dongsheng@627 4394 msgid "Choosing a user name"
dongsheng@627 4395 msgstr "选择用户名称"
dongsheng@627 4396
dongsheng@627 4397 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 4398 #: ../en/ch02-tour-basic.xml:634
dongsheng@627 4399 msgid ""
dongsheng@627 4400 "You can use any text you like as the value of the <literal>username</literal> "
songdongsheng@667 4401 "config item, since this information is for reading by other people, but will "
songdongsheng@667 4402 "not be interpreted by Mercurial. The convention that most people follow is "
songdongsheng@667 4403 "to use their name and email address, as in the example above."
dongsheng@627 4404 msgstr ""
dongsheng@627 4405
dongsheng@627 4406 #. type: Content of: <book><chapter><sect1><sect2><sect3><note><para>
dongsheng@714 4407 #: ../en/ch02-tour-basic.xml:641
dongsheng@627 4408 msgid ""
dongsheng@627 4409 "Mercurial's built-in web server obfuscates email addresses, to make it more "
dongsheng@627 4410 "difficult for the email harvesting tools that spammers use. This reduces the "
dongsheng@627 4411 "likelihood that you'll start receiving more junk email if you publish a "
dongsheng@627 4412 "Mercurial repository on the web."
dongsheng@627 4413 msgstr ""
dongsheng@627 4414
dongsheng@627 4415 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 4416 #: ../en/ch02-tour-basic.xml:650
dongsheng@627 4417 msgid "Writing a commit message"
dongsheng@627 4418 msgstr "写提交日志"
dongsheng@627 4419
dongsheng@627 4420 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 4421 #: ../en/ch02-tour-basic.xml:652
dongsheng@627 4422 msgid ""
dongsheng@627 4423 "When we commit a change, Mercurial drops us into a text editor, to enter a "
dongsheng@627 4424 "message that will describe the modifications we've made in this changeset. "
dongsheng@627 4425 "This is called the <emphasis>commit message</emphasis>. It will be a record "
dongsheng@627 4426 "for readers of what we did and why, and it will be printed by <command role="
dongsheng@627 4427 "\"hg-cmd\">hg log</command> after we've finished committing."
dongsheng@627 4428 msgstr ""
dongsheng@627 4429
dongsheng@627 4430 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 4431 #: ../en/ch02-tour-basic.xml:662
dongsheng@627 4432 msgid ""
dongsheng@627 4433 "The editor that the <command role=\"hg-cmd\">hg commit</command> command "
songdongsheng@667 4434 "drops us into will contain an empty line or two, followed by a number of "
songdongsheng@667 4435 "lines starting with <quote><literal>HG:</literal></quote>."
songdongsheng@667 4436 msgstr ""
songdongsheng@667 4437
songdongsheng@667 4438 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 4439 #: ../en/ch02-tour-basic.xml:676
dongsheng@627 4440 msgid ""
dongsheng@627 4441 "Mercurial ignores the lines that start with <quote><literal>HG:</literal></"
dongsheng@627 4442 "quote>; it uses them only to tell us which files it's recording changes to. "
dongsheng@627 4443 "Modifying or deleting these lines has no effect."
dongsheng@627 4444 msgstr ""
dongsheng@627 4445
dongsheng@627 4446 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 4447 #: ../en/ch02-tour-basic.xml:682
dongsheng@627 4448 msgid "Writing a good commit message"
dongsheng@627 4449 msgstr "写好提交日志"
dongsheng@627 4450
dongsheng@627 4451 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 4452 #: ../en/ch02-tour-basic.xml:684
dongsheng@627 4453 msgid ""
dongsheng@627 4454 "Since <command role=\"hg-cmd\">hg log</command> only prints the first line of "
dongsheng@627 4455 "a commit message by default, it's best to write a commit message whose first "
dongsheng@627 4456 "line stands alone. Here's a real example of a commit message that "
dongsheng@627 4457 "<emphasis>doesn't</emphasis> follow this guideline, and hence has a summary "
dongsheng@627 4458 "that is not readable."
dongsheng@627 4459 msgstr ""
dongsheng@627 4460
dongsheng@627 4461 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 4462 #: ../en/ch02-tour-basic.xml:697
dongsheng@627 4463 msgid ""
dongsheng@627 4464 "As far as the remainder of the contents of the commit message are concerned, "
dongsheng@627 4465 "there are no hard-and-fast rules. Mercurial itself doesn't interpret or care "
dongsheng@627 4466 "about the contents of the commit message, though your project may have "
dongsheng@627 4467 "policies that dictate a certain kind of formatting."
dongsheng@627 4468 msgstr ""
dongsheng@627 4469
dongsheng@627 4470 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 4471 #: ../en/ch02-tour-basic.xml:702
dongsheng@627 4472 msgid ""
dongsheng@627 4473 "My personal preference is for short, but informative, commit messages that "
dongsheng@627 4474 "tell me something that I can't figure out with a quick glance at the output "
dongsheng@627 4475 "of <command role=\"hg-cmd\">hg log --patch</command>."
dongsheng@627 4476 msgstr ""
dongsheng@627 4477
dongsheng@714 4478 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 4479 #: ../en/ch02-tour-basic.xml:706
dongsheng@714 4480 msgid ""
dongsheng@714 4481 "If we run the <command role=\"hg-cmd\">hg commit</command> command without "
dongsheng@714 4482 "any arguments, it records all of the changes we've made, as reported by "
dongsheng@714 4483 "<command role=\"hg-cmd\">hg status</command> and <command role=\"hg-cmd\">hg "
dongsheng@714 4484 "diff</command>."
dongsheng@714 4485 msgstr ""
dongsheng@714 4486
dongsheng@714 4487 #. type: Content of: <book><chapter><sect1><sect2><note><title>
dongsheng@714 4488 #: ../en/ch02-tour-basic.xml:713
dongsheng@714 4489 msgid "A surprise for Subversion users"
dongsheng@714 4490 msgstr ""
dongsheng@714 4491
dongsheng@714 4492 #. type: Content of: <book><chapter><sect1><sect2><note><para>
dongsheng@714 4493 #: ../en/ch02-tour-basic.xml:715
dongsheng@714 4494 msgid ""
dongsheng@714 4495 "Like other Mercurial commands, if we don't supply explicit names to commit to "
dongsheng@714 4496 "the <command role=\"hg-cmd\">hg commit</command>, it will operate across a "
dongsheng@714 4497 "repository's entire working directory. Be wary of this if you're coming from "
dongsheng@714 4498 "the Subversion or CVS world, since you might expect it to operate only on the "
dongsheng@714 4499 "current directory that you happen to be visiting and its subdirectories."
dongsheng@714 4500 msgstr ""
dongsheng@714 4501
dongsheng@627 4502 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 4503 #: ../en/ch02-tour-basic.xml:726
dongsheng@627 4504 msgid "Aborting a commit"
dongsheng@627 4505 msgstr "终止提交"
dongsheng@627 4506
dongsheng@627 4507 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 4508 #: ../en/ch02-tour-basic.xml:728
dongsheng@627 4509 msgid ""
dongsheng@627 4510 "If you decide that you don't want to commit while in the middle of editing a "
dongsheng@627 4511 "commit message, simply exit from your editor without saving the file that "
dongsheng@627 4512 "it's editing. This will cause nothing to happen to either the repository or "
dongsheng@627 4513 "the working directory."
dongsheng@627 4514 msgstr ""
dongsheng@627 4515
dongsheng@627 4516 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 4517 #: ../en/ch02-tour-basic.xml:736
dongsheng@627 4518 msgid "Admiring our new handiwork"
songdongsheng@665 4519 msgstr "欣赏我们的成果"
dongsheng@627 4520
dongsheng@627 4521 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 4522 #: ../en/ch02-tour-basic.xml:738
dongsheng@627 4523 msgid ""
dongsheng@627 4524 "Once we've finished the commit, we can use the <command role=\"hg-cmd\">hg "
dongsheng@627 4525 "tip</command> command to display the changeset we just created. This command "
dongsheng@627 4526 "produces output that is identical to <command role=\"hg-cmd\">hg log</"
dongsheng@627 4527 "command>, but it only displays the newest revision in the repository."
dongsheng@627 4528 msgstr ""
dongsheng@627 4529
dongsheng@627 4530 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 4531 #: ../en/ch02-tour-basic.xml:746
songdongsheng@667 4532 msgid ""
songdongsheng@667 4533 "We refer to the newest revision in the repository as the <emphasis>tip "
songdongsheng@667 4534 "revision</emphasis>, or simply the <emphasis>tip</emphasis>."
songdongsheng@667 4535 msgstr ""
songdongsheng@667 4536
songdongsheng@667 4537 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 4538 #: ../en/ch02-tour-basic.xml:750
songdongsheng@667 4539 msgid ""
songdongsheng@667 4540 "By the way, the <command role=\"hg-cmd\">hg tip</command> command accepts "
songdongsheng@667 4541 "many of the same options as <command role=\"hg-cmd\">hg log</command>, so "
songdongsheng@667 4542 "<option role=\"hg-opt-global\">-v</option> above indicates <quote>be verbose</"
songdongsheng@667 4543 "quote>, <option role=\"hg-opt-tip\">-p</option> specifies <quote>print a "
songdongsheng@667 4544 "patch</quote>. The use of <option role=\"hg-opt-tip\">-p</option> to print "
songdongsheng@667 4545 "patches is another example of the consistent naming we mentioned earlier."
dongsheng@627 4546 msgstr ""
dongsheng@627 4547
dongsheng@627 4548 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 4549 #: ../en/ch02-tour-basic.xml:762
dongsheng@627 4550 msgid "Sharing changes"
dongsheng@627 4551 msgstr "共享修改"
dongsheng@627 4552
dongsheng@627 4553 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 4554 #: ../en/ch02-tour-basic.xml:764
dongsheng@627 4555 msgid ""
dongsheng@627 4556 "We mentioned earlier that repositories in Mercurial are self-contained. This "
dongsheng@627 4557 "means that the changeset we just created exists only in our <filename class="
dongsheng@627 4558 "\"directory\">my-hello</filename> repository. Let's look at a few ways that "
dongsheng@627 4559 "we can propagate this change into other repositories."
dongsheng@627 4560 msgstr ""
dongsheng@627 4561
dongsheng@627 4562 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 4563 #: ../en/ch02-tour-basic.xml:772
dongsheng@627 4564 msgid "Pulling changes from another repository"
dongsheng@627 4565 msgstr "从其它版本库取得修改"
dongsheng@627 4566
dongsheng@627 4567 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 4568 #: ../en/ch02-tour-basic.xml:774
dongsheng@627 4569 msgid ""
dongsheng@627 4570 "To get started, let's clone our original <filename class=\"directory\">hello</"
dongsheng@627 4571 "filename> repository, which does not contain the change we just committed. "
dongsheng@627 4572 "We'll call our temporary repository <filename class=\"directory\">hello-pull</"
dongsheng@627 4573 "filename>."
dongsheng@627 4574 msgstr ""
dongsheng@627 4575
dongsheng@627 4576 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 4577 #: ../en/ch02-tour-basic.xml:782
dongsheng@627 4578 msgid ""
dongsheng@627 4579 "We'll use the <command role=\"hg-cmd\">hg pull</command> command to bring "
dongsheng@627 4580 "changes from <filename class=\"directory\">my-hello</filename> into <filename "
dongsheng@627 4581 "class=\"directory\">hello-pull</filename>. However, blindly pulling unknown "
dongsheng@627 4582 "changes into a repository is a somewhat scary prospect. Mercurial provides "
dongsheng@627 4583 "the <command role=\"hg-cmd\">hg incoming</command> command to tell us what "
dongsheng@627 4584 "changes the <command role=\"hg-cmd\">hg pull</command> command "
dongsheng@627 4585 "<emphasis>would</emphasis> pull into the repository, without actually pulling "
dongsheng@627 4586 "the changes in."
dongsheng@627 4587 msgstr ""
dongsheng@627 4588
dongsheng@627 4589 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 4590 #: ../en/ch02-tour-basic.xml:795
dongsheng@714 4591 msgid ""
dongsheng@714 4592 "Bringing changes into a repository is a simple matter of running the <command "
dongsheng@714 4593 "role=\"hg-cmd\">hg pull</command> command, and optionally telling it which "
dongsheng@714 4594 "repository to pull from."
dongsheng@714 4595 msgstr ""
dongsheng@714 4596
dongsheng@714 4597 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 4598 #: ../en/ch02-tour-basic.xml:801
dongsheng@714 4599 msgid ""
dongsheng@714 4600 "As you can see from the before-and-after output of <command role=\"hg-cmd"
dongsheng@714 4601 "\">hg tip</command>, we have successfully pulled changes into our "
dongsheng@714 4602 "repository. However, Mercurial separates pulling changes in from updating "
dongsheng@714 4603 "the working directory. There remains one step before we will see the changes "
dongsheng@714 4604 "that we just pulled appear in the working directory."
dongsheng@714 4605 msgstr ""
dongsheng@714 4606
dongsheng@714 4607 #. type: Content of: <book><chapter><sect1><sect2><tip><title>
dongsheng@714 4608 #: ../en/ch02-tour-basic.xml:810
dongsheng@714 4609 msgid "Pulling specific changes"
dongsheng@715 4610 msgstr "提取指定的修改"
dongsheng@714 4611
dongsheng@714 4612 #. type: Content of: <book><chapter><sect1><sect2><tip><para>
dongsheng@714 4613 #: ../en/ch02-tour-basic.xml:812
dongsheng@714 4614 msgid ""
dongsheng@714 4615 "It is possible that due to the delay between running <command role=\"hg-cmd"
dongsheng@714 4616 "\">hg incoming</command> and <command role=\"hg-cmd\">hg pull</command>, you "
dongsheng@714 4617 "may not see all changesets that will be brought from the other repository. "
songdongsheng@667 4618 "Suppose you're pulling changes from a repository on the network somewhere. "
songdongsheng@667 4619 "While you are looking at the <command role=\"hg-cmd\">hg incoming</command> "
songdongsheng@667 4620 "output, and before you pull those changes, someone might have committed "
songdongsheng@667 4621 "something in the remote repository. This means that it's possible to pull "
songdongsheng@667 4622 "more changes than you saw when using <command role=\"hg-cmd\">hg incoming</"
songdongsheng@667 4623 "command>."
songdongsheng@667 4624 msgstr ""
songdongsheng@667 4625
dongsheng@714 4626 #. type: Content of: <book><chapter><sect1><sect2><tip><para>
dongsheng@714 4627 #: ../en/ch02-tour-basic.xml:824
dongsheng@714 4628 msgid ""
dongsheng@714 4629 "If you only want to pull precisely the changes that were listed by <command "
dongsheng@714 4630 "role=\"hg-cmd\">hg incoming</command>, or you have some other reason to pull "
dongsheng@714 4631 "a subset of changes, simply identify the change that you want to pull by its "
dongsheng@714 4632 "changeset ID, e.g. <command>hg pull -r7e95bb</command>."
dongsheng@627 4633 msgstr ""
dongsheng@627 4634
dongsheng@627 4635 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 4636 #: ../en/ch02-tour-basic.xml:834
dongsheng@627 4637 msgid "Updating the working directory"
dongsheng@627 4638 msgstr "更新工作目录"
dongsheng@627 4639
dongsheng@627 4640 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 4641 #: ../en/ch02-tour-basic.xml:836
dongsheng@627 4642 msgid ""
dongsheng@627 4643 "We have so far glossed over the relationship between a repository and its "
dongsheng@627 4644 "working directory. The <command role=\"hg-cmd\">hg pull</command> command "
songdongsheng@658 4645 "that we ran in <xref linkend=\"sec:tour:pull\"/> brought changes into the "
songdongsheng@658 4646 "repository, but if we check, there's no sign of those changes in the working "
songdongsheng@658 4647 "directory. This is because <command role=\"hg-cmd\">hg pull</command> does "
songdongsheng@658 4648 "not (by default) touch the working directory. Instead, we use the <command "
songdongsheng@658 4649 "role=\"hg-cmd\">hg update</command> command to do this."
songdongsheng@658 4650 msgstr ""
songdongsheng@658 4651
songdongsheng@658 4652 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 4653 #: ../en/ch02-tour-basic.xml:848
dongsheng@627 4654 msgid ""
dongsheng@627 4655 "It might seem a bit strange that <command role=\"hg-cmd\">hg pull</command> "
dongsheng@627 4656 "doesn't update the working directory automatically. There's actually a good "
dongsheng@627 4657 "reason for this: you can use <command role=\"hg-cmd\">hg update</command> to "
dongsheng@627 4658 "update the working directory to the state it was in at <emphasis>any "
dongsheng@627 4659 "revision</emphasis> in the history of the repository. If you had the working "
songdongsheng@668 4660 "directory updated to an old revision&emdash;to hunt down the origin of a bug, "
songdongsheng@668 4661 "say&emdash;and ran a <command role=\"hg-cmd\">hg pull</command> which "
songdongsheng@668 4662 "automatically updated the working directory to a new revision, you might not "
songdongsheng@668 4663 "be terribly happy."
songdongsheng@667 4664 msgstr ""
songdongsheng@667 4665
songdongsheng@667 4666 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 4667 #: ../en/ch02-tour-basic.xml:860
dongsheng@714 4668 msgid ""
dongsheng@714 4669 "Since pull-then-update is such a common sequence of operations, Mercurial "
dongsheng@714 4670 "lets you combine the two by passing the <option role=\"hg-opt-pull\">-u</"
dongsheng@714 4671 "option> option to <command role=\"hg-cmd\">hg pull</command>."
dongsheng@714 4672 msgstr ""
dongsheng@714 4673
dongsheng@714 4674 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 4675 #: ../en/ch02-tour-basic.xml:865
dongsheng@627 4676 msgid ""
dongsheng@627 4677 "If you look back at the output of <command role=\"hg-cmd\">hg pull</command> "
songdongsheng@658 4678 "in <xref linkend=\"sec:tour:pull\"/> when we ran it without <option role=\"hg-"
songdongsheng@658 4679 "opt-pull\">-u</option>, you can see that it printed a helpful reminder that "
dongsheng@714 4680 "we'd have to take an explicit step to update the working directory."
dongsheng@714 4681 msgstr ""
dongsheng@714 4682
dongsheng@714 4683 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 4684 #: ../en/ch02-tour-basic.xml:872
dongsheng@627 4685 msgid ""
dongsheng@627 4686 "To find out what revision the working directory is at, use the <command role="
dongsheng@627 4687 "\"hg-cmd\">hg parents</command> command."
dongsheng@627 4688 msgstr ""
dongsheng@627 4689
dongsheng@627 4690 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 4691 #: ../en/ch02-tour-basic.xml:878
songdongsheng@658 4692 msgid ""
songdongsheng@658 4693 "If you look back at <xref linkend=\"fig:tour-basic:history\"/>, you'll see "
songdongsheng@658 4694 "arrows connecting each changeset. The node that the arrow leads "
songdongsheng@658 4695 "<emphasis>from</emphasis> in each case is a parent, and the node that the "
songdongsheng@658 4696 "arrow leads <emphasis>to</emphasis> is its child. The working directory has "
songdongsheng@658 4697 "a parent in just the same way; this is the changeset that the working "
songdongsheng@658 4698 "directory currently contains."
songdongsheng@658 4699 msgstr ""
songdongsheng@658 4700
songdongsheng@658 4701 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 4702 #: ../en/ch02-tour-basic.xml:887
dongsheng@627 4703 msgid ""
dongsheng@627 4704 "To update the working directory to a particular revision, give a revision "
dongsheng@627 4705 "number or changeset ID to the <command role=\"hg-cmd\">hg update</command> "
dongsheng@627 4706 "command."
dongsheng@627 4707 msgstr ""
dongsheng@627 4708
dongsheng@627 4709 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 4710 #: ../en/ch02-tour-basic.xml:893
dongsheng@627 4711 msgid ""
dongsheng@627 4712 "If you omit an explicit revision, <command role=\"hg-cmd\">hg update</"
dongsheng@627 4713 "command> will update to the tip revision, as shown by the second call to "
dongsheng@627 4714 "<command role=\"hg-cmd\">hg update</command> in the example above."
dongsheng@627 4715 msgstr ""
dongsheng@627 4716
dongsheng@627 4717 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 4718 #: ../en/ch02-tour-basic.xml:901
dongsheng@627 4719 msgid "Pushing changes to another repository"
dongsheng@627 4720 msgstr "发布修改到其它版本库"
dongsheng@627 4721
dongsheng@627 4722 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 4723 #: ../en/ch02-tour-basic.xml:903
dongsheng@627 4724 msgid ""
dongsheng@627 4725 "Mercurial lets us push changes to another repository, from the repository "
dongsheng@714 4726 "we're currently visiting. As with the example of <command role=\"hg-cmd\">hg "
dongsheng@627 4727 "pull</command> above, we'll create a temporary repository to push our changes "
dongsheng@627 4728 "into."
dongsheng@627 4729 msgstr ""
dongsheng@627 4730
dongsheng@627 4731 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 4732 #: ../en/ch02-tour-basic.xml:911
dongsheng@627 4733 msgid ""
dongsheng@627 4734 "The <command role=\"hg-cmd\">hg outgoing</command> command tells us what "
dongsheng@627 4735 "changes would be pushed into another repository."
dongsheng@627 4736 msgstr ""
dongsheng@627 4737
dongsheng@627 4738 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 4739 #: ../en/ch02-tour-basic.xml:917
dongsheng@627 4740 msgid ""
dongsheng@627 4741 "And the <command role=\"hg-cmd\">hg push</command> command does the actual "
dongsheng@627 4742 "push."
dongsheng@627 4743 msgstr ""
dongsheng@627 4744
dongsheng@627 4745 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 4746 #: ../en/ch02-tour-basic.xml:922
dongsheng@627 4747 msgid ""
dongsheng@627 4748 "As with <command role=\"hg-cmd\">hg pull</command>, the <command role=\"hg-cmd"
dongsheng@627 4749 "\">hg push</command> command does not update the working directory in the "
songdongsheng@667 4750 "repository that it's pushing changes into. Unlike <command role=\"hg-cmd\">hg "
songdongsheng@667 4751 "pull</command>, <command role=\"hg-cmd\">hg push</command> does not provide a "
songdongsheng@667 4752 "<literal>-u</literal> option that updates the other repository's working "
songdongsheng@667 4753 "directory. This asymmetry is deliberate: the repository we're pushing to "
songdongsheng@667 4754 "might be on a remote server and shared between several people. If we were to "
songdongsheng@667 4755 "update its working directory while someone was working in it, their work "
songdongsheng@667 4756 "would be disrupted."
songdongsheng@667 4757 msgstr ""
songdongsheng@667 4758
songdongsheng@667 4759 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 4760 #: ../en/ch02-tour-basic.xml:934
dongsheng@627 4761 msgid ""
dongsheng@627 4762 "What happens if we try to pull or push changes and the receiving repository "
dongsheng@627 4763 "already has those changes? Nothing too exciting."
dongsheng@627 4764 msgstr ""
dongsheng@627 4765
dongsheng@627 4766 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 4767 #: ../en/ch02-tour-basic.xml:942
dongsheng@714 4768 msgid "Default locations"
dongsheng@716 4769 msgstr "默认位置"
dongsheng@714 4770
dongsheng@714 4771 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 4772 #: ../en/ch02-tour-basic.xml:944
dongsheng@714 4773 msgid ""
dongsheng@714 4774 "When we clone a repository, Mercurial records the location of the repository "
dongsheng@714 4775 "we cloned in the <filename>.hg/hgrc</filename> file of the new repository. "
dongsheng@714 4776 "If we don't supply a location to <command>hg pull</command> from or "
dongsheng@714 4777 "<command>hg push</command> to, those commands will use this location as a "
dongsheng@714 4778 "default. The <command>hg incoming</command> and <command>hg outgoing</"
dongsheng@714 4779 "command> commands do so too."
dongsheng@714 4780 msgstr ""
dongsheng@714 4781
dongsheng@714 4782 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 4783 #: ../en/ch02-tour-basic.xml:952
dongsheng@714 4784 msgid ""
dongsheng@714 4785 "If you open a repository's <filename>.hg/hgrc</filename> file in a text "
dongsheng@714 4786 "editor, you will see contents like the following."
dongsheng@714 4787 msgstr ""
dongsheng@714 4788
dongsheng@714 4789 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 4790 #: ../en/ch02-tour-basic.xml:959
dongsheng@714 4791 msgid ""
dongsheng@714 4792 "It is possible&emdash;and often useful&emdash;to have the default location "
dongsheng@714 4793 "for <command>hg push</command> and <command>hg outgoing</command> be "
dongsheng@714 4794 "different from those for <command>hg pull</command> and <command>hg incoming</"
dongsheng@714 4795 "command>. We can do this by adding a <literal>default-push</literal> entry "
dongsheng@714 4796 "to the <literal>[paths]</literal> section of the <filename>.hg/hgrc</"
dongsheng@714 4797 "filename> file, as follows."
dongsheng@714 4798 msgstr ""
dongsheng@714 4799
dongsheng@714 4800 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 4801 #: ../en/ch02-tour-basic.xml:973
dongsheng@627 4802 msgid "Sharing changes over a network"
dongsheng@627 4803 msgstr "通过网络共享修改"
dongsheng@627 4804
dongsheng@627 4805 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 4806 #: ../en/ch02-tour-basic.xml:975
dongsheng@627 4807 msgid ""
dongsheng@627 4808 "The commands we have covered in the previous few sections are not limited to "
dongsheng@627 4809 "working with local repositories. Each works in exactly the same fashion over "
dongsheng@627 4810 "a network connection; simply pass in a URL instead of a local path."
dongsheng@627 4811 msgstr ""
dongsheng@627 4812
dongsheng@627 4813 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 4814 #: ../en/ch02-tour-basic.xml:983
dongsheng@627 4815 msgid ""
dongsheng@627 4816 "In this example, we can see what changes we could push to the remote "
dongsheng@627 4817 "repository, but the repository is understandably not set up to let anonymous "
dongsheng@627 4818 "users push to it."
dongsheng@627 4819 msgstr ""
dongsheng@627 4820
dongsheng@714 4821 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 4822 #: ../en/ch02-tour-basic.xml:993
dongsheng@714 4823 msgid "Starting a new project"
dongsheng@715 4824 msgstr "开始新项目"
dongsheng@714 4825
dongsheng@714 4826 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 4827 #: ../en/ch02-tour-basic.xml:995
dongsheng@714 4828 msgid ""
dongsheng@714 4829 "It is just as easy to begin a new project as to work on one that already "
dongsheng@714 4830 "exists. The <command>hg init</command> command creates a new, empty "
dongsheng@714 4831 "Mercurial repository."
dongsheng@714 4832 msgstr ""
dongsheng@714 4833
dongsheng@714 4834 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 4835 #: ../en/ch02-tour-basic.xml:1001
dongsheng@714 4836 msgid ""
dongsheng@714 4837 "This simply creates a repository named <filename>myproject</filename> in the "
dongsheng@714 4838 "current directory."
dongsheng@714 4839 msgstr ""
dongsheng@714 4840
dongsheng@714 4841 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 4842 #: ../en/ch02-tour-basic.xml:1006
dongsheng@714 4843 msgid ""
dongsheng@714 4844 "We can tell that <filename>myproject</filename> is a Mercurial repository, "
dongsheng@714 4845 "because it contains a <filename>.hg</filename> directory."
dongsheng@714 4846 msgstr ""
dongsheng@714 4847
dongsheng@714 4848 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 4849 #: ../en/ch02-tour-basic.xml:1012
dongsheng@714 4850 msgid ""
dongsheng@714 4851 "If we want to add some pre-existing files to the repository, we copy them "
dongsheng@714 4852 "into place, and tell Mercurial to start tracking them using the <command>hg "
dongsheng@714 4853 "add</command> command."
dongsheng@714 4854 msgstr ""
dongsheng@714 4855
dongsheng@714 4856 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 4857 #: ../en/ch02-tour-basic.xml:1018
dongsheng@714 4858 msgid ""
dongsheng@714 4859 "Once we are satisfied that our project looks right, we commit our changes."
dongsheng@714 4860 msgstr ""
dongsheng@714 4861
dongsheng@714 4862 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 4863 #: ../en/ch02-tour-basic.xml:1023
dongsheng@714 4864 msgid ""
dongsheng@714 4865 "It takes just a few moments to start using Mercurial on a new project, which "
dongsheng@714 4866 "is part of its appeal. Revision control is now so easy to work with, we can "
dongsheng@714 4867 "use it on the smallest of projects that we might not have considered with a "
dongsheng@714 4868 "more complicated tool."
dongsheng@714 4869 msgstr ""
dongsheng@714 4870
dongsheng@627 4871 #. type: Content of: <book><chapter><title>
dongsheng@714 4872 #: ../en/ch03-tour-merge.xml:5
dongsheng@627 4873 msgid "A tour of Mercurial: merging work"
dongsheng@627 4874 msgstr "Mercurial 教程: 合并工作"
dongsheng@627 4875
dongsheng@627 4876 #. type: Content of: <book><chapter><para>
dongsheng@714 4877 #: ../en/ch03-tour-merge.xml:7
dongsheng@627 4878 msgid ""
dongsheng@627 4879 "We've now covered cloning a repository, making changes in a repository, and "
dongsheng@627 4880 "pulling or pushing changes from one repository into another. Our next step "
dongsheng@627 4881 "is <emphasis>merging</emphasis> changes from separate repositories."
dongsheng@627 4882 msgstr ""
dongsheng@627 4883
dongsheng@627 4884 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 4885 #: ../en/ch03-tour-merge.xml:13
dongsheng@627 4886 msgid "Merging streams of work"
dongsheng@627 4887 msgstr "合并的流程"
dongsheng@627 4888
dongsheng@627 4889 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 4890 #: ../en/ch03-tour-merge.xml:15
dongsheng@627 4891 msgid ""
dongsheng@627 4892 "Merging is a fundamental part of working with a distributed revision control "
dongsheng@714 4893 "tool. Here are a few cases in which the need to merge work arises."
dongsheng@627 4894 msgstr ""
dongsheng@627 4895
dongsheng@627 4896 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 4897 #: ../en/ch03-tour-merge.xml:20
dongsheng@627 4898 msgid ""
dongsheng@627 4899 "Alice and Bob each have a personal copy of a repository for a project they're "
dongsheng@627 4900 "collaborating on. Alice fixes a bug in her repository; Bob adds a new "
dongsheng@627 4901 "feature in his. They want the shared repository to contain both the bug fix "
dongsheng@627 4902 "and the new feature."
dongsheng@627 4903 msgstr ""
dongsheng@627 4904
dongsheng@627 4905 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 4906 #: ../en/ch03-tour-merge.xml:27
dongsheng@714 4907 msgid ""
dongsheng@714 4908 "Cynthia frequently works on several different tasks for a single project at "
dongsheng@714 4909 "once, each safely isolated in its own repository. Working this way means that "
dongsheng@714 4910 "she often needs to merge one piece of her own work with another."
dongsheng@714 4911 msgstr ""
dongsheng@714 4912
dongsheng@714 4913 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 4914 #: ../en/ch03-tour-merge.xml:35
dongsheng@714 4915 msgid ""
dongsheng@714 4916 "Because we need to merge often, Mercurial makes the process easy. Let's walk "
dongsheng@714 4917 "through a merge. We'll begin by cloning yet another repository (see how "
dongsheng@714 4918 "often they spring up?) and making a change in it."
dongsheng@714 4919 msgstr ""
dongsheng@714 4920
dongsheng@714 4921 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 4922 #: ../en/ch03-tour-merge.xml:42
dongsheng@627 4923 msgid ""
dongsheng@627 4924 "We should now have two copies of <filename>hello.c</filename> with different "
dongsheng@627 4925 "contents. The histories of the two repositories have also diverged, as "
dongsheng@714 4926 "illustrated in <xref linkend=\"fig:tour-merge:sep-repos\"/>. Here is a copy "
dongsheng@714 4927 "of our file from one repository."
dongsheng@714 4928 msgstr ""
dongsheng@714 4929
dongsheng@714 4930 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 4931 #: ../en/ch03-tour-merge.xml:51
dongsheng@714 4932 msgid "And here is our slightly different version from the other repository."
songdongsheng@658 4933 msgstr ""
songdongsheng@658 4934
songdongsheng@658 4935 #. type: Content of: <book><chapter><sect1><figure><title>
dongsheng@714 4936 #: ../en/ch03-tour-merge.xml:57
dongsheng@627 4937 msgid ""
dongsheng@627 4938 "Divergent recent histories of the <filename class=\"directory\">my-hello</"
dongsheng@627 4939 "filename> and <filename class=\"directory\">my-new-hello</filename> "
dongsheng@627 4940 "repositories"
dongsheng@627 4941 msgstr ""
dongsheng@660 4942 "<filename class=\"directory\">my-hello</filename> 与 <filename class="
dongsheng@660 4943 "\"directory\">my-new-hello</filename> 最新的历史分叉"
dongsheng@627 4944
songdongsheng@658 4945 #. type: Content of: <book><chapter><sect1><figure><mediaobject>
dongsheng@714 4946 #: ../en/ch03-tour-merge.xml:62
songdongsheng@658 4947 msgid ""
songdongsheng@658 4948 "<imageobject><imagedata fileref=\"figs/tour-merge-sep-repos.png\"/></"
songdongsheng@658 4949 "imageobject>"
songdongsheng@658 4950 msgstr ""
songdongsheng@658 4951
songdongsheng@658 4952 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 4953 #: ../en/ch03-tour-merge.xml:67
dongsheng@627 4954 msgid ""
dongsheng@627 4955 "We already know that pulling changes from our <filename class=\"directory"
dongsheng@627 4956 "\">my-hello</filename> repository will have no effect on the working "
dongsheng@627 4957 "directory."
dongsheng@627 4958 msgstr ""
dongsheng@627 4959
dongsheng@627 4960 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 4961 #: ../en/ch03-tour-merge.xml:73
dongsheng@627 4962 msgid ""
dongsheng@627 4963 "However, the <command role=\"hg-cmd\">hg pull</command> command says "
dongsheng@627 4964 "something about <quote>heads</quote>."
dongsheng@627 4965 msgstr ""
dongsheng@627 4966
dongsheng@627 4967 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 4968 #: ../en/ch03-tour-merge.xml:77
dongsheng@627 4969 msgid "Head changesets"
songdongsheng@665 4970 msgstr "顶点修改集"
dongsheng@627 4971
dongsheng@627 4972 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 4973 #: ../en/ch03-tour-merge.xml:79
dongsheng@714 4974 msgid ""
dongsheng@714 4975 "Remember that Mercurial records what the parent of each change is. If a "
dongsheng@714 4976 "change has a parent, we call it a child or descendant of the parent. A head "
dongsheng@714 4977 "is a change that has no children. The tip revision is thus a head, because "
dongsheng@714 4978 "the newest revision in a repository doesn't have any children. There are "
dongsheng@714 4979 "times when a repository can contain more than one head."
dongsheng@627 4980 msgstr ""
dongsheng@627 4981
songdongsheng@658 4982 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
dongsheng@714 4983 #: ../en/ch03-tour-merge.xml:88
dongsheng@627 4984 msgid ""
dongsheng@627 4985 "Repository contents after pulling from <filename class=\"directory\">my-"
dongsheng@627 4986 "hello</filename> into <filename class=\"directory\">my-new-hello</filename>"
dongsheng@627 4987 msgstr ""
dongsheng@660 4988 "从 <filename class=\"directory\">my-hello</filename> 拉到 <filename class="
dongsheng@660 4989 "\"directory\">my-new-hello</filename> 之后版本库的内容"
dongsheng@627 4990
songdongsheng@658 4991 #. type: Content of: <book><chapter><sect1><sect2><figure>
dongsheng@714 4992 #: ../en/ch03-tour-merge.xml:91 ../en/ch03-tour-merge.xml:178
dongsheng@714 4993 #: ../en/ch03-tour-merge.xml:275 ../en/ch04-concepts.xml:57
dongsheng@714 4994 #: ../en/ch04-concepts.xml:106 ../en/ch04-concepts.xml:196
dongsheng@714 4995 #: ../en/ch04-concepts.xml:345 ../en/ch04-concepts.xml:360
dongsheng@714 4996 #: ../en/ch04-concepts.xml:401 ../en/ch04-concepts.xml:421
dongsheng@714 4997 #: ../en/ch04-concepts.xml:465 ../en/ch06-collab.xml:314
dongsheng@714 4998 #: ../en/ch09-undo.xml:342 ../en/ch09-undo.xml:389 ../en/ch09-undo.xml:462
dongsheng@714 4999 #: ../en/ch09-undo.xml:500 ../en/ch09-undo.xml:656 ../en/ch09-undo.xml:680
dongsheng@714 5000 #: ../en/ch09-undo.xml:698 ../en/ch09-undo.xml:712 ../en/ch09-undo.xml:725
dongsheng@714 5001 #: ../en/ch12-mq.xml:411
songdongsheng@658 5002 msgid " <placeholder type=\"mediaobject\" id=\"0\"/>"
songdongsheng@658 5003 msgstr ""
songdongsheng@658 5004
songdongsheng@658 5005 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
dongsheng@714 5006 #: ../en/ch03-tour-merge.xml:92
songdongsheng@658 5007 msgid ""
songdongsheng@658 5008 "<imageobject> <imagedata fileref=\"figs/tour-merge-pull.png\"/> </imageobject>"
songdongsheng@658 5009 msgstr ""
songdongsheng@658 5010
songdongsheng@658 5011 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 5012 #: ../en/ch03-tour-merge.xml:99
songdongsheng@658 5013 msgid ""
songdongsheng@658 5014 "In <xref linkend=\"fig:tour-merge:pull\"/>, you can see the effect of the "
songdongsheng@658 5015 "pull from <filename class=\"directory\">my-hello</filename> into <filename "
songdongsheng@658 5016 "class=\"directory\">my-new-hello</filename>. The history that was already "
songdongsheng@658 5017 "present in <filename class=\"directory\">my-new-hello</filename> is "
songdongsheng@658 5018 "untouched, but a new revision has been added. By referring to <xref linkend="
songdongsheng@658 5019 "\"fig:tour-merge:sep-repos\"/>, we can see that the <emphasis>changeset ID</"
songdongsheng@658 5020 "emphasis> remains the same in the new repository, but the <emphasis>revision "
songdongsheng@658 5021 "number</emphasis> has changed. (This, incidentally, is a fine example of why "
songdongsheng@658 5022 "it's not safe to use revision numbers when discussing changesets.) We can "
songdongsheng@658 5023 "view the heads in a repository using the <command role=\"hg-cmd\">hg heads</"
songdongsheng@658 5024 "command> command."
dongsheng@627 5025 msgstr ""
dongsheng@627 5026
dongsheng@627 5027 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 5028 #: ../en/ch03-tour-merge.xml:118
dongsheng@627 5029 msgid "Performing the merge"
dongsheng@627 5030 msgstr "执行合并"
dongsheng@627 5031
dongsheng@627 5032 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 5033 #: ../en/ch03-tour-merge.xml:120
dongsheng@627 5034 msgid ""
dongsheng@627 5035 "What happens if we try to use the normal <command role=\"hg-cmd\">hg update</"
dongsheng@627 5036 "command> command to update to the new tip?"
dongsheng@627 5037 msgstr ""
dongsheng@627 5038
dongsheng@627 5039 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 5040 #: ../en/ch03-tour-merge.xml:126
dongsheng@627 5041 msgid ""
dongsheng@627 5042 "Mercurial is telling us that the <command role=\"hg-cmd\">hg update</command> "
dongsheng@627 5043 "command won't do a merge; it won't update the working directory when it "
dongsheng@714 5044 "thinks we might want to do a merge, unless we force it to do so. "
dongsheng@714 5045 "(Incidentally, forcing the update with <command>hg update -C</command> would "
dongsheng@714 5046 "revert any uncommitted changes in the working directory.)"
dongsheng@714 5047 msgstr ""
dongsheng@714 5048
dongsheng@714 5049 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 5050 #: ../en/ch03-tour-merge.xml:134
dongsheng@714 5051 msgid ""
dongsheng@714 5052 "To start a merge between the two heads, we use the <command role=\"hg-cmd"
dongsheng@714 5053 "\">hg merge</command> command."
dongsheng@715 5054 msgstr ""
dongsheng@715 5055 "我们使用 <command role=\"hg-cmd\">hg merge</command> 命令来合并两个顶点。"
dongsheng@714 5056
dongsheng@714 5057 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 5058 #: ../en/ch03-tour-merge.xml:139
dongsheng@714 5059 msgid ""
dongsheng@714 5060 "We resolve the contents of <filename>hello.c</filename> This updates the "
dongsheng@714 5061 "working directory so that it contains changes from <emphasis>both</emphasis> "
dongsheng@714 5062 "heads, which is reflected in both the output of <command role=\"hg-cmd\">hg "
dongsheng@714 5063 "parents</command> and the contents of <filename>hello.c</filename>."
dongsheng@627 5064 msgstr ""
dongsheng@627 5065
dongsheng@627 5066 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 5067 #: ../en/ch03-tour-merge.xml:151
dongsheng@627 5068 msgid "Committing the results of the merge"
dongsheng@627 5069 msgstr "提交合并结果"
dongsheng@627 5070
dongsheng@627 5071 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 5072 #: ../en/ch03-tour-merge.xml:153
dongsheng@627 5073 msgid ""
dongsheng@627 5074 "Whenever we've done a merge, <command role=\"hg-cmd\">hg parents</command> "
dongsheng@627 5075 "will display two parents until we <command role=\"hg-cmd\">hg commit</"
dongsheng@627 5076 "command> the results of the merge."
dongsheng@627 5077 msgstr ""
dongsheng@627 5078
dongsheng@627 5079 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 5080 #: ../en/ch03-tour-merge.xml:160
dongsheng@627 5081 msgid ""
dongsheng@627 5082 "We now have a new tip revision; notice that it has <emphasis>both</emphasis> "
dongsheng@627 5083 "of our former heads as its parents. These are the same revisions that were "
dongsheng@627 5084 "previously displayed by <command role=\"hg-cmd\">hg parents</command>."
dongsheng@627 5085 msgstr ""
dongsheng@627 5086
dongsheng@627 5087 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 5088 #: ../en/ch03-tour-merge.xml:167
songdongsheng@658 5089 msgid ""
songdongsheng@658 5090 "In <xref linkend=\"fig:tour-merge:merge\"/>, you can see a representation of "
songdongsheng@658 5091 "what happens to the working directory during the merge, and how this affects "
songdongsheng@658 5092 "the repository when the commit happens. During the merge, the working "
songdongsheng@658 5093 "directory has two parent changesets, and these become the parents of the new "
songdongsheng@658 5094 "changeset."
dongsheng@627 5095 msgstr ""
dongsheng@627 5096
songdongsheng@710 5097 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
dongsheng@714 5098 #: ../en/ch03-tour-merge.xml:176
songdongsheng@710 5099 msgid "Working directory and repository during merge, and following commit"
songdongsheng@710 5100 msgstr "在合并期间,以及提交之后的工作目录与版本库"
songdongsheng@710 5101
songdongsheng@710 5102 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
dongsheng@714 5103 #: ../en/ch03-tour-merge.xml:179
songdongsheng@710 5104 msgid ""
songdongsheng@710 5105 "<imageobject> <imagedata fileref=\"figs/tour-merge-merge.png\"/> </"
songdongsheng@710 5106 "imageobject>"
songdongsheng@710 5107 msgstr ""
songdongsheng@710 5108
songdongsheng@710 5109 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 5110 #: ../en/ch03-tour-merge.xml:186
songdongsheng@710 5111 msgid ""
songdongsheng@710 5112 "We sometimes talk about a merge having <emphasis>sides</emphasis>: the left "
songdongsheng@710 5113 "side is the first parent in the output of <command role=\"hg-cmd\">hg "
songdongsheng@710 5114 "parents</command>, and the right side is the second. If the working "
songdongsheng@710 5115 "directory was at e.g. revision 5 before we began a merge, that revision will "
songdongsheng@710 5116 "become the left side of the merge."
songdongsheng@710 5117 msgstr ""
songdongsheng@710 5118
dongsheng@627 5119 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 5120 #: ../en/ch03-tour-merge.xml:196
dongsheng@627 5121 msgid "Merging conflicting changes"
dongsheng@627 5122 msgstr "合并有冲突的改变"
dongsheng@627 5123
dongsheng@627 5124 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 5125 #: ../en/ch03-tour-merge.xml:198
dongsheng@627 5126 msgid ""
dongsheng@627 5127 "Most merges are simple affairs, but sometimes you'll find yourself merging "
songdongsheng@710 5128 "changes where each side modifies the same portions of the same files. Unless "
songdongsheng@710 5129 "both modifications are identical, this results in a <emphasis>conflict</"
songdongsheng@710 5130 "emphasis>, where you have to decide how to reconcile the different changes "
songdongsheng@710 5131 "into something coherent."
dongsheng@627 5132 msgstr ""
dongsheng@627 5133
songdongsheng@658 5134 #. type: Content of: <book><chapter><sect1><figure><title>
dongsheng@714 5135 #: ../en/ch03-tour-merge.xml:206
songdongsheng@658 5136 msgid "Conflicting changes to a document"
dongsheng@660 5137 msgstr "冲突的修改"
songdongsheng@658 5138
songdongsheng@658 5139 #. type: Content of: <book><chapter><sect1><figure><mediaobject>
dongsheng@714 5140 #: ../en/ch03-tour-merge.xml:208
songdongsheng@658 5141 msgid ""
songdongsheng@658 5142 "<imageobject><imagedata fileref=\"figs/tour-merge-conflict.png\"/></"
dongsheng@627 5143 "imageobject>"
dongsheng@627 5144 msgstr ""
dongsheng@627 5145
songdongsheng@658 5146 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 5147 #: ../en/ch03-tour-merge.xml:213
songdongsheng@658 5148 msgid ""
songdongsheng@658 5149 "<xref linkend=\"fig:tour-merge:conflict\"/> illustrates an instance of two "
songdongsheng@658 5150 "conflicting changes to a document. We started with a single version of the "
songdongsheng@658 5151 "file; then we made some changes; while someone else made different changes to "
songdongsheng@658 5152 "the same text. Our task in resolving the conflicting changes is to decide "
songdongsheng@658 5153 "what the file should look like."
songdongsheng@658 5154 msgstr ""
songdongsheng@658 5155
songdongsheng@658 5156 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 5157 #: ../en/ch03-tour-merge.xml:220
dongsheng@627 5158 msgid ""
dongsheng@627 5159 "Mercurial doesn't have a built-in facility for handling conflicts. Instead, "
songdongsheng@710 5160 "it runs an external program, usually one that displays some kind of graphical "
songdongsheng@710 5161 "conflict resolution interface. By default, Mercurial tries to find one of "
songdongsheng@710 5162 "several different merging tools that are likely to be installed on your "
songdongsheng@710 5163 "system. It first tries a few fully automatic merging tools; if these don't "
songdongsheng@710 5164 "succeed (because the resolution process requires human guidance) or aren't "
songdongsheng@710 5165 "present, it tries a few different graphical merging tools."
songdongsheng@710 5166 msgstr ""
songdongsheng@710 5167
songdongsheng@710 5168 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 5169 #: ../en/ch03-tour-merge.xml:230
dongsheng@714 5170 msgid ""
dongsheng@714 5171 "It's also possible to get Mercurial to run a specific program or script, by "
dongsheng@714 5172 "setting the <envar>HGMERGE</envar> environment variable to the name of your "
dongsheng@714 5173 "preferred program."
dongsheng@627 5174 msgstr ""
dongsheng@627 5175
dongsheng@627 5176 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 5177 #: ../en/ch03-tour-merge.xml:236
dongsheng@627 5178 msgid "Using a graphical merge tool"
dongsheng@627 5179 msgstr "使用图形合并工具"
dongsheng@627 5180
dongsheng@627 5181 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 5182 #: ../en/ch03-tour-merge.xml:238
dongsheng@627 5183 msgid ""
dongsheng@627 5184 "My preferred graphical merge tool is <command>kdiff3</command>, which I'll "
dongsheng@627 5185 "use to describe the features that are common to graphical file merging "
dongsheng@627 5186 "tools. You can see a screenshot of <command>kdiff3</command> in action in "
songdongsheng@658 5187 "<xref linkend=\"fig:tour-merge:kdiff3\"/>. The kind of merge it is "
songdongsheng@658 5188 "performing is called a <emphasis>three-way merge</emphasis>, because there "
songdongsheng@658 5189 "are three different versions of the file of interest to us. The tool thus "
songdongsheng@658 5190 "splits the upper portion of the window into three panes:"
dongsheng@627 5191 msgstr ""
dongsheng@627 5192
dongsheng@627 5193 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 5194 #: ../en/ch03-tour-merge.xml:248
dongsheng@627 5195 msgid ""
dongsheng@627 5196 "At the left is the <emphasis>base</emphasis> version of the file, i.e. the "
dongsheng@627 5197 "most recent version from which the two versions we're trying to merge are "
dongsheng@627 5198 "descended."
dongsheng@627 5199 msgstr ""
dongsheng@627 5200
dongsheng@627 5201 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 5202 #: ../en/ch03-tour-merge.xml:253
dongsheng@627 5203 msgid ""
dongsheng@627 5204 "In the middle is <quote>our</quote> version of the file, with the contents "
dongsheng@627 5205 "that we modified."
dongsheng@627 5206 msgstr ""
dongsheng@627 5207
dongsheng@627 5208 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 5209 #: ../en/ch03-tour-merge.xml:256
dongsheng@627 5210 msgid ""
dongsheng@627 5211 "On the right is <quote>their</quote> version of the file, the one that from "
dongsheng@627 5212 "the changeset that we're trying to merge with."
dongsheng@627 5213 msgstr ""
dongsheng@627 5214
dongsheng@627 5215 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 5216 #: ../en/ch03-tour-merge.xml:260
dongsheng@627 5217 msgid ""
dongsheng@627 5218 "In the pane below these is the current <emphasis>result</emphasis> of the "
dongsheng@627 5219 "merge. Our task is to replace all of the red text, which indicates unresolved "
dongsheng@627 5220 "conflicts, with some sensible merger of the <quote>ours</quote> and "
dongsheng@627 5221 "<quote>theirs</quote> versions of the file."
dongsheng@627 5222 msgstr ""
dongsheng@627 5223
dongsheng@627 5224 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 5225 #: ../en/ch03-tour-merge.xml:267
dongsheng@627 5226 msgid ""
dongsheng@627 5227 "All four of these panes are <emphasis>locked together</emphasis>; if we "
dongsheng@627 5228 "scroll vertically or horizontally in any of them, the others are updated to "
dongsheng@627 5229 "display the corresponding sections of their respective files."
dongsheng@627 5230 msgstr ""
dongsheng@627 5231
songdongsheng@658 5232 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
dongsheng@714 5233 #: ../en/ch03-tour-merge.xml:273
songdongsheng@658 5234 msgid "Using <command>kdiff3</command> to merge versions of a file"
dongsheng@660 5235 msgstr "使用 <command>kdiff3</command> 合并文件的不同版本"
songdongsheng@658 5236
songdongsheng@658 5237 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
dongsheng@714 5238 #: ../en/ch03-tour-merge.xml:276
songdongsheng@658 5239 msgid ""
songdongsheng@658 5240 "<imageobject> <imagedata width=\"100%\" fileref=\"figs/kdiff3.png\"/></"
dongsheng@630 5241 "imageobject>"
dongsheng@627 5242 msgstr ""
dongsheng@627 5243
songdongsheng@658 5244 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 5245 #: ../en/ch03-tour-merge.xml:284
dongsheng@627 5246 msgid ""
dongsheng@627 5247 "For each conflicting portion of the file, we can choose to resolve the "
dongsheng@627 5248 "conflict using some combination of text from the base version, ours, or "
dongsheng@627 5249 "theirs. We can also manually edit the merged file at any time, in case we "
dongsheng@627 5250 "need to make further modifications."
dongsheng@627 5251 msgstr ""
dongsheng@627 5252
dongsheng@627 5253 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 5254 #: ../en/ch03-tour-merge.xml:290
dongsheng@627 5255 msgid ""
dongsheng@627 5256 "There are <emphasis>many</emphasis> file merging tools available, too many to "
dongsheng@627 5257 "cover here. They vary in which platforms they are available for, and in "
dongsheng@627 5258 "their particular strengths and weaknesses. Most are tuned for merging files "
dongsheng@627 5259 "containing plain text, while a few are aimed at specialised file formats "
dongsheng@627 5260 "(generally XML)."
dongsheng@627 5261 msgstr ""
dongsheng@627 5262
dongsheng@627 5263 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 5264 #: ../en/ch03-tour-merge.xml:299
dongsheng@627 5265 msgid "A worked example"
dongsheng@627 5266 msgstr "合并实例"
dongsheng@627 5267
dongsheng@627 5268 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 5269 #: ../en/ch03-tour-merge.xml:301
songdongsheng@658 5270 msgid ""
songdongsheng@658 5271 "In this example, we will reproduce the file modification history of <xref "
songdongsheng@658 5272 "linkend=\"fig:tour-merge:conflict\"/> above. Let's begin by creating a "
songdongsheng@658 5273 "repository with a base version of our document."
songdongsheng@658 5274 msgstr ""
songdongsheng@658 5275
songdongsheng@658 5276 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 5277 #: ../en/ch03-tour-merge.xml:308
dongsheng@627 5278 msgid "We'll clone the repository and make a change to the file."
dongsheng@627 5279 msgstr ""
dongsheng@627 5280
dongsheng@627 5281 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 5282 #: ../en/ch03-tour-merge.xml:313
dongsheng@627 5283 msgid ""
dongsheng@627 5284 "And another clone, to simulate someone else making a change to the file. "
dongsheng@627 5285 "(This hints at the idea that it's not all that unusual to merge with yourself "
dongsheng@627 5286 "when you isolate tasks in separate repositories, and indeed to find and "
dongsheng@627 5287 "resolve conflicts while doing so.)"
dongsheng@627 5288 msgstr ""
dongsheng@627 5289
dongsheng@627 5290 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 5291 #: ../en/ch03-tour-merge.xml:321
dongsheng@627 5292 msgid ""
dongsheng@627 5293 "Having created two different versions of the file, we'll set up an "
dongsheng@627 5294 "environment suitable for running our merge."
dongsheng@627 5295 msgstr ""
dongsheng@627 5296
dongsheng@627 5297 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 5298 #: ../en/ch03-tour-merge.xml:327
songdongsheng@710 5299 msgid ""
songdongsheng@710 5300 "In this example, I'll set <envar>HGMERGE</envar> to tell Mercurial to use the "
songdongsheng@710 5301 "non-interactive <command>merge</command> command. This is bundled with many "
songdongsheng@710 5302 "Unix-like systems. (If you're following this example on your computer, don't "
dongsheng@714 5303 "bother setting <envar>HGMERGE</envar>. You'll get dropped into a GUI file "
dongsheng@714 5304 "merge tool instead, which is much preferable.)"
dongsheng@714 5305 msgstr ""
dongsheng@714 5306
dongsheng@714 5307 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 5308 #: ../en/ch03-tour-merge.xml:337
dongsheng@627 5309 msgid ""
dongsheng@627 5310 "Because <command>merge</command> can't resolve the conflicting changes, it "
dongsheng@627 5311 "leaves <emphasis>merge markers</emphasis> inside the file that has conflicts, "
dongsheng@627 5312 "indicating which lines have conflicts, and whether they came from our version "
dongsheng@627 5313 "of the file or theirs."
dongsheng@627 5314 msgstr ""
dongsheng@627 5315
dongsheng@627 5316 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 5317 #: ../en/ch03-tour-merge.xml:343
dongsheng@627 5318 msgid ""
dongsheng@627 5319 "Mercurial can tell from the way <command>merge</command> exits that it wasn't "
dongsheng@627 5320 "able to merge successfully, so it tells us what commands we'll need to run if "
dongsheng@627 5321 "we want to redo the merging operation. This could be useful if, for example, "
dongsheng@627 5322 "we were running a graphical merge tool and quit because we were confused or "
dongsheng@627 5323 "realised we had made a mistake."
dongsheng@627 5324 msgstr ""
dongsheng@627 5325
dongsheng@627 5326 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 5327 #: ../en/ch03-tour-merge.xml:350
dongsheng@627 5328 msgid ""
dongsheng@627 5329 "If automatic or manual merges fail, there's nothing to prevent us from "
dongsheng@627 5330 "<quote>fixing up</quote> the affected files ourselves, and committing the "
dongsheng@627 5331 "results of our merge:"
dongsheng@627 5332 msgstr ""
dongsheng@627 5333
dongsheng@714 5334 #. type: Content of: <book><chapter><sect1><sect2><note><title>
dongsheng@714 5335 #: ../en/ch03-tour-merge.xml:357
dongsheng@714 5336 msgid "Where is the <command>hg resolve</command> command?"
dongsheng@715 5337 msgstr "在哪里能找到 <command role=\"hg-cmd\">hg resolve</command> 命令?"
dongsheng@714 5338
dongsheng@714 5339 #. type: Content of: <book><chapter><sect1><sect2><note><para>
dongsheng@714 5340 #: ../en/ch03-tour-merge.xml:359
dongsheng@714 5341 msgid ""
dongsheng@714 5342 "The <command>hg resolve</command> command was introduced in Mercurial 1.1, "
dongsheng@714 5343 "which was released in December 2008. If you are using an older version of "
dongsheng@714 5344 "Mercurial (run <command>hg version</command> to see), this command will not "
dongsheng@714 5345 "be present. If your version of Mercurial is older than 1.1, you should "
dongsheng@714 5346 "strongly consider upgrading to a newer version before trying to tackle "
dongsheng@714 5347 "complicated merges."
dongsheng@714 5348 msgstr ""
dongsheng@714 5349
dongsheng@627 5350 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 5351 #: ../en/ch03-tour-merge.xml:371
dongsheng@627 5352 msgid "Simplifying the pull-merge-commit sequence"
dongsheng@627 5353 msgstr "简化拉-合并-提交程序"
dongsheng@627 5354
dongsheng@627 5355 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 5356 #: ../en/ch03-tour-merge.xml:373
dongsheng@627 5357 msgid ""
dongsheng@627 5358 "The process of merging changes as outlined above is straightforward, but "
dongsheng@627 5359 "requires running three commands in sequence."
dongsheng@627 5360 msgstr ""
dongsheng@627 5361
dongsheng@627 5362 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 5363 #: ../en/ch03-tour-merge.xml:379
dongsheng@627 5364 msgid ""
dongsheng@627 5365 "In the case of the final commit, you also need to enter a commit message, "
dongsheng@627 5366 "which is almost always going to be a piece of uninteresting "
dongsheng@627 5367 "<quote>boilerplate</quote> text."
dongsheng@627 5368 msgstr ""
dongsheng@627 5369
dongsheng@627 5370 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 5371 #: ../en/ch03-tour-merge.xml:383
dongsheng@627 5372 msgid ""
dongsheng@627 5373 "It would be nice to reduce the number of steps needed, if this were "
dongsheng@627 5374 "possible. Indeed, Mercurial is distributed with an extension called <literal "
dongsheng@627 5375 "role=\"hg-ext\">fetch</literal> that does just this."
dongsheng@627 5376 msgstr ""
dongsheng@627 5377
dongsheng@627 5378 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 5379 #: ../en/ch03-tour-merge.xml:388
dongsheng@627 5380 msgid ""
dongsheng@627 5381 "Mercurial provides a flexible extension mechanism that lets people extend its "
dongsheng@627 5382 "functionality, while keeping the core of Mercurial small and easy to deal "
dongsheng@627 5383 "with. Some extensions add new commands that you can use from the command "
dongsheng@627 5384 "line, while others work <quote>behind the scenes,</quote> for example adding "
dongsheng@714 5385 "capabilities to Mercurial's built-in server mode."
dongsheng@714 5386 msgstr ""
dongsheng@714 5387
dongsheng@714 5388 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 5389 #: ../en/ch03-tour-merge.xml:395
dongsheng@627 5390 msgid ""
dongsheng@627 5391 "The <literal role=\"hg-ext\">fetch</literal> extension adds a new command "
dongsheng@627 5392 "called, not surprisingly, <command role=\"hg-cmd\">hg fetch</command>. This "
songdongsheng@710 5393 "extension acts as a combination of <command role=\"hg-cmd\">hg pull -u</"
songdongsheng@710 5394 "command>, <command role=\"hg-cmd\">hg merge</command> and <command role=\"hg-"
songdongsheng@710 5395 "cmd\">hg commit</command>. It begins by pulling changes from another "
dongsheng@627 5396 "repository into the current repository. If it finds that the changes added a "
dongsheng@714 5397 "new head to the repository, it updates to the new head, begins a merge, then "
dongsheng@714 5398 "(if the merge succeeded) commits the result of the merge with an "
dongsheng@714 5399 "automatically-generated commit message. If no new heads were added, it "
dongsheng@714 5400 "updates the working directory to the new tip changeset."
dongsheng@714 5401 msgstr ""
dongsheng@714 5402
dongsheng@714 5403 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 5404 #: ../en/ch03-tour-merge.xml:409
dongsheng@627 5405 msgid ""
dongsheng@627 5406 "Enabling the <literal role=\"hg-ext\">fetch</literal> extension is easy. "
songdongsheng@710 5407 "Edit the <filename role=\"special\">.hgrc</filename> file in your home "
songdongsheng@710 5408 "directory, and either go to the <literal role=\"rc-extensions\">extensions</"
songdongsheng@710 5409 "literal> section or create an <literal role=\"rc-extensions\">extensions</"
songdongsheng@710 5410 "literal> section. Then add a line that simply reads <quote><literal>fetch=</"
songdongsheng@710 5411 "literal></quote>."
songdongsheng@710 5412 msgstr ""
songdongsheng@710 5413
songdongsheng@710 5414 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 5415 #: ../en/ch03-tour-merge.xml:421
songdongsheng@710 5416 msgid ""
songdongsheng@710 5417 "(Normally, the right-hand side of the <quote><literal>=</literal></quote> "
songdongsheng@710 5418 "would indicate where to find the extension, but since the <literal role=\"hg-"
dongsheng@627 5419 "ext\">fetch</literal> extension is in the standard distribution, Mercurial "
dongsheng@627 5420 "knows where to search for it.)"
dongsheng@627 5421 msgstr ""
dongsheng@627 5422
dongsheng@714 5423 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 5424 #: ../en/ch03-tour-merge.xml:429
dongsheng@714 5425 msgid "Renaming, copying, and merging"
dongsheng@715 5426 msgstr "改名,复制与合并"
dongsheng@714 5427
dongsheng@714 5428 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 5429 #: ../en/ch03-tour-merge.xml:431
dongsheng@714 5430 msgid ""
dongsheng@714 5431 "During the life of a project, we will often want to change the layout of its "
dongsheng@714 5432 "files and directories. This can be as simple as renaming a single file, or as "
dongsheng@714 5433 "complex as restructuring the entire hierarchy of files within the project."
dongsheng@714 5434 msgstr ""
dongsheng@714 5435
dongsheng@714 5436 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 5437 #: ../en/ch03-tour-merge.xml:436
dongsheng@714 5438 msgid ""
dongsheng@714 5439 "Mercurial supports these kinds of complex changes fluently, provided we tell "
dongsheng@714 5440 "it what we're doing. If we want to rename a file, we should use the "
dongsheng@714 5441 "<command>hg rename</command><placeholder type=\"footnote\" id=\"0\"/> command "
dongsheng@714 5442 "to rename it, so that Mercurial can do the right thing later when we merge."
dongsheng@714 5443 msgstr ""
dongsheng@714 5444
dongsheng@714 5445 #. type: Content of: <book><chapter><sect1><para><footnote><para>
dongsheng@714 5446 #: ../en/ch03-tour-merge.xml:439
dongsheng@714 5447 msgid ""
dongsheng@714 5448 "If you're a Unix user, you'll be glad to know that the <command>hg rename</"
dongsheng@714 5449 "command> command can be abbreviated as <command>hg mv</command>."
dongsheng@714 5450 msgstr ""
dongsheng@714 5451
dongsheng@714 5452 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 5453 #: ../en/ch03-tour-merge.xml:445
dongsheng@714 5454 msgid ""
dongsheng@714 5455 "We will cover the use of these commands in more detail in <xref linkend="
dongsheng@714 5456 "\"chap:daily.copy\"/>."
dongsheng@714 5457 msgstr ""
dongsheng@714 5458
dongsheng@627 5459 #. type: Content of: <book><chapter><title>
dongsheng@714 5460 #: ../en/ch04-concepts.xml:5
dongsheng@627 5461 msgid "Behind the scenes"
dongsheng@627 5462 msgstr "Mercurial 内幕"
dongsheng@627 5463
dongsheng@627 5464 #. type: Content of: <book><chapter><para>
dongsheng@714 5465 #: ../en/ch04-concepts.xml:7
dongsheng@627 5466 msgid ""
dongsheng@627 5467 "Unlike many revision control systems, the concepts upon which Mercurial is "
dongsheng@627 5468 "built are simple enough that it's easy to understand how the software really "
songdongsheng@710 5469 "works. Knowing these details certainly isn't necessary, so it is certainly "
songdongsheng@710 5470 "safe to skip this chapter. However, I think you will get more out of the "
songdongsheng@710 5471 "software with a <quote>mental model</quote> of what's going on."
dongsheng@627 5472 msgstr ""
dongsheng@627 5473
dongsheng@627 5474 #. type: Content of: <book><chapter><para>
dongsheng@714 5475 #: ../en/ch04-concepts.xml:14
songdongsheng@710 5476 msgid ""
songdongsheng@710 5477 "Being able to understand what's going on behind the scenes gives me "
songdongsheng@710 5478 "confidence that Mercurial has been carefully designed to be both "
songdongsheng@710 5479 "<emphasis>safe</emphasis> and <emphasis>efficient</emphasis>. And just as "
songdongsheng@710 5480 "importantly, if it's easy for me to retain a good idea of what the software "
songdongsheng@710 5481 "is doing when I perform a revision control task, I'm less likely to be "
songdongsheng@710 5482 "surprised by its behavior."
dongsheng@627 5483 msgstr ""
dongsheng@627 5484
dongsheng@627 5485 #. type: Content of: <book><chapter><para>
dongsheng@714 5486 #: ../en/ch04-concepts.xml:22
dongsheng@627 5487 msgid ""
dongsheng@627 5488 "In this chapter, we'll initially cover the core concepts behind Mercurial's "
dongsheng@627 5489 "design, then continue to discuss some of the interesting details of its "
dongsheng@627 5490 "implementation."
dongsheng@627 5491 msgstr ""
dongsheng@627 5492
dongsheng@627 5493 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 5494 #: ../en/ch04-concepts.xml:27
dongsheng@627 5495 msgid "Mercurial's historical record"
dongsheng@627 5496 msgstr "Mercurial 的历史记录"
dongsheng@627 5497
dongsheng@627 5498 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 5499 #: ../en/ch04-concepts.xml:30
dongsheng@627 5500 msgid "Tracking the history of a single file"
dongsheng@627 5501 msgstr "跟踪单一文件的历史"
dongsheng@627 5502
dongsheng@627 5503 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 5504 #: ../en/ch04-concepts.xml:32
dongsheng@627 5505 msgid ""
dongsheng@627 5506 "When Mercurial tracks modifications to a file, it stores the history of that "
dongsheng@627 5507 "file in a metadata object called a <emphasis>filelog</emphasis>. Each entry "
dongsheng@627 5508 "in the filelog contains enough information to reconstruct one revision of the "
dongsheng@627 5509 "file that is being tracked. Filelogs are stored as files in the <filename "
dongsheng@627 5510 "role=\"special\" class=\"directory\">.hg/store/data</filename> directory. A "
dongsheng@627 5511 "filelog contains two kinds of information: revision data, and an index to "
dongsheng@627 5512 "help Mercurial to find a revision efficiently."
dongsheng@627 5513 msgstr ""
dongsheng@627 5514
dongsheng@627 5515 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 5516 #: ../en/ch04-concepts.xml:43
dongsheng@627 5517 msgid ""
dongsheng@627 5518 "A file that is large, or has a lot of history, has its filelog stored in "
dongsheng@627 5519 "separate data (<quote><literal>.d</literal></quote> suffix) and index "
dongsheng@627 5520 "(<quote><literal>.i</literal></quote> suffix) files. For small files without "
dongsheng@627 5521 "much history, the revision data and index are combined in a single "
dongsheng@627 5522 "<quote><literal>.i</literal></quote> file. The correspondence between a file "
dongsheng@627 5523 "in the working directory and the filelog that tracks its history in the "
songdongsheng@658 5524 "repository is illustrated in <xref linkend=\"fig:concepts:filelog\"/>."
songdongsheng@658 5525 msgstr ""
songdongsheng@658 5526
songdongsheng@658 5527 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
dongsheng@714 5528 #: ../en/ch04-concepts.xml:55
dongsheng@627 5529 msgid ""
dongsheng@627 5530 "Relationships between files in working directory and filelogs in repository"
dongsheng@660 5531 msgstr "工作目录中的文件与版本库中的文件日志之间的关系"
dongsheng@627 5532
songdongsheng@658 5533 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
dongsheng@714 5534 #: ../en/ch04-concepts.xml:58
songdongsheng@658 5535 msgid "<imageobject><imagedata fileref=\"figs/filelog.png\"/></imageobject>"
songdongsheng@658 5536 msgstr ""
songdongsheng@658 5537
dongsheng@627 5538 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 5539 #: ../en/ch04-concepts.xml:65
dongsheng@627 5540 msgid "Managing tracked files"
dongsheng@627 5541 msgstr "管理跟踪的文件"
dongsheng@627 5542
dongsheng@627 5543 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 5544 #: ../en/ch04-concepts.xml:67
dongsheng@627 5545 msgid ""
dongsheng@627 5546 "Mercurial uses a structure called a <emphasis>manifest</emphasis> to collect "
dongsheng@627 5547 "together information about the files that it tracks. Each entry in the "
dongsheng@627 5548 "manifest contains information about the files present in a single changeset. "
dongsheng@627 5549 "An entry records which files are present in the changeset, the revision of "
dongsheng@627 5550 "each file, and a few other pieces of file metadata."
dongsheng@627 5551 msgstr ""
dongsheng@627 5552
dongsheng@627 5553 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 5554 #: ../en/ch04-concepts.xml:77
dongsheng@627 5555 msgid "Recording changeset information"
dongsheng@627 5556 msgstr "记录修改集信息"
dongsheng@627 5557
dongsheng@627 5558 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 5559 #: ../en/ch04-concepts.xml:79
dongsheng@627 5560 msgid ""
dongsheng@627 5561 "The <emphasis>changelog</emphasis> contains information about each "
dongsheng@627 5562 "changeset. Each revision records who committed a change, the changeset "
dongsheng@627 5563 "comment, other pieces of changeset-related information, and the revision of "
dongsheng@627 5564 "the manifest to use."
dongsheng@627 5565 msgstr ""
dongsheng@627 5566
dongsheng@627 5567 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 5568 #: ../en/ch04-concepts.xml:87
dongsheng@627 5569 msgid "Relationships between revisions"
dongsheng@627 5570 msgstr "版本之间的关系"
dongsheng@627 5571
dongsheng@627 5572 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 5573 #: ../en/ch04-concepts.xml:89
dongsheng@627 5574 msgid ""
dongsheng@627 5575 "Within a changelog, a manifest, or a filelog, each revision stores a pointer "
dongsheng@627 5576 "to its immediate parent (or to its two parents, if it's a merge revision). "
dongsheng@627 5577 "As I mentioned above, there are also relationships between revisions "
dongsheng@627 5578 "<emphasis>across</emphasis> these structures, and they are hierarchical in "
dongsheng@627 5579 "nature."
dongsheng@627 5580 msgstr ""
dongsheng@627 5581
dongsheng@627 5582 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 5583 #: ../en/ch04-concepts.xml:96
dongsheng@627 5584 msgid ""
dongsheng@627 5585 "For every changeset in a repository, there is exactly one revision stored in "
dongsheng@627 5586 "the changelog. Each revision of the changelog contains a pointer to a single "
dongsheng@627 5587 "revision of the manifest. A revision of the manifest stores a pointer to a "
dongsheng@627 5588 "single revision of each filelog tracked when that changeset was created. "
songdongsheng@658 5589 "These relationships are illustrated in <xref linkend=\"fig:concepts:metadata"
songdongsheng@658 5590 "\"/>."
songdongsheng@658 5591 msgstr ""
songdongsheng@658 5592
songdongsheng@658 5593 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
dongsheng@714 5594 #: ../en/ch04-concepts.xml:105
dongsheng@627 5595 msgid "Metadata relationships"
dongsheng@660 5596 msgstr "元数据之间的关系"
dongsheng@627 5597
songdongsheng@658 5598 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
dongsheng@714 5599 #: ../en/ch04-concepts.xml:107
songdongsheng@658 5600 msgid "<imageobject><imagedata fileref=\"figs/metadata.png\"/></imageobject>"
songdongsheng@658 5601 msgstr ""
songdongsheng@658 5602
songdongsheng@658 5603 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 5604 #: ../en/ch04-concepts.xml:112
dongsheng@627 5605 msgid ""
dongsheng@627 5606 "As the illustration shows, there is <emphasis>not</emphasis> a <quote>one to "
dongsheng@627 5607 "one</quote> relationship between revisions in the changelog, manifest, or "
dongsheng@714 5608 "filelog. If a file that Mercurial tracks hasn't changed between two "
dongsheng@627 5609 "changesets, the entry for that file in the two revisions of the manifest will "
dongsheng@714 5610 "point to the same revision of its filelog<placeholder type=\"footnote\" id=\"0"
dongsheng@714 5611 "\"/>."
dongsheng@714 5612 msgstr ""
dongsheng@714 5613
dongsheng@714 5614 #. type: Content of: <book><chapter><sect1><sect2><para><footnote><para>
dongsheng@714 5615 #: ../en/ch04-concepts.xml:119
dongsheng@714 5616 msgid ""
dongsheng@714 5617 "It is possible (though unusual) for the manifest to remain the same between "
dongsheng@714 5618 "two changesets, in which case the changelog entries for those changesets will "
dongsheng@714 5619 "point to the same revision of the manifest."
dongsheng@627 5620 msgstr ""
dongsheng@627 5621
dongsheng@627 5622 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 5623 #: ../en/ch04-concepts.xml:128
dongsheng@627 5624 msgid "Safe, efficient storage"
dongsheng@627 5625 msgstr "安全,高效的存储"
dongsheng@627 5626
dongsheng@627 5627 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 5628 #: ../en/ch04-concepts.xml:130
dongsheng@627 5629 msgid ""
dongsheng@627 5630 "The underpinnings of changelogs, manifests, and filelogs are provided by a "
dongsheng@627 5631 "single structure called the <emphasis>revlog</emphasis>."
dongsheng@627 5632 msgstr ""
dongsheng@627 5633
dongsheng@627 5634 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 5635 #: ../en/ch04-concepts.xml:135
dongsheng@627 5636 msgid "Efficient storage"
dongsheng@627 5637 msgstr "高效存储"
dongsheng@627 5638
dongsheng@627 5639 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 5640 #: ../en/ch04-concepts.xml:137
dongsheng@627 5641 msgid ""
dongsheng@627 5642 "The revlog provides efficient storage of revisions using a <emphasis>delta</"
dongsheng@627 5643 "emphasis> mechanism. Instead of storing a complete copy of a file for each "
dongsheng@627 5644 "revision, it stores the changes needed to transform an older revision into "
dongsheng@627 5645 "the new revision. For many kinds of file data, these deltas are typically a "
dongsheng@627 5646 "fraction of a percent of the size of a full copy of a file."
dongsheng@627 5647 msgstr ""
dongsheng@627 5648
dongsheng@627 5649 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 5650 #: ../en/ch04-concepts.xml:145
dongsheng@627 5651 msgid ""
dongsheng@627 5652 "Some obsolete revision control systems can only work with deltas of text "
dongsheng@627 5653 "files. They must either store binary files as complete snapshots or encoded "
dongsheng@627 5654 "into a text representation, both of which are wasteful approaches. Mercurial "
dongsheng@627 5655 "can efficiently handle deltas of files with arbitrary binary contents; it "
dongsheng@627 5656 "doesn't need to treat text as special."
dongsheng@627 5657 msgstr ""
dongsheng@627 5658
dongsheng@627 5659 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 5660 #: ../en/ch04-concepts.xml:154
dongsheng@627 5661 msgid "Safe operation"
dongsheng@627 5662 msgstr "安全操作"
dongsheng@627 5663
dongsheng@627 5664 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 5665 #: ../en/ch04-concepts.xml:156
dongsheng@627 5666 msgid ""
dongsheng@627 5667 "Mercurial only ever <emphasis>appends</emphasis> data to the end of a revlog "
dongsheng@627 5668 "file. It never modifies a section of a file after it has written it. This is "
dongsheng@627 5669 "both more robust and efficient than schemes that need to modify or rewrite "
dongsheng@627 5670 "data."
dongsheng@627 5671 msgstr ""
dongsheng@627 5672
dongsheng@627 5673 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 5674 #: ../en/ch04-concepts.xml:162
dongsheng@627 5675 msgid ""
dongsheng@627 5676 "In addition, Mercurial treats every write as part of a <emphasis>transaction</"
dongsheng@627 5677 "emphasis> that can span a number of files. A transaction is "
dongsheng@627 5678 "<emphasis>atomic</emphasis>: either the entire transaction succeeds and its "
dongsheng@627 5679 "effects are all visible to readers in one go, or the whole thing is undone. "
dongsheng@627 5680 "This guarantee of atomicity means that if you're running two copies of "
dongsheng@627 5681 "Mercurial, where one is reading data and one is writing it, the reader will "
dongsheng@627 5682 "never see a partially written result that might confuse it."
dongsheng@627 5683 msgstr ""
dongsheng@627 5684
dongsheng@627 5685 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 5686 #: ../en/ch04-concepts.xml:172
dongsheng@627 5687 msgid ""
dongsheng@627 5688 "The fact that Mercurial only appends to files makes it easier to provide this "
dongsheng@627 5689 "transactional guarantee. The easier it is to do stuff like this, the more "
dongsheng@627 5690 "confident you should be that it's done correctly."
dongsheng@627 5691 msgstr ""
dongsheng@627 5692
dongsheng@627 5693 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 5694 #: ../en/ch04-concepts.xml:179
dongsheng@627 5695 msgid "Fast retrieval"
dongsheng@627 5696 msgstr "快速检索"
dongsheng@627 5697
dongsheng@627 5698 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 5699 #: ../en/ch04-concepts.xml:181
dongsheng@627 5700 msgid ""
dongsheng@627 5701 "Mercurial cleverly avoids a pitfall common to all earlier revision control "
dongsheng@627 5702 "systems: the problem of <emphasis>inefficient retrieval</emphasis>. Most "
dongsheng@627 5703 "revision control systems store the contents of a revision as an incremental "
dongsheng@714 5704 "series of modifications against a <quote>snapshot</quote>. (Some base the "
dongsheng@714 5705 "snapshot on the oldest revision, others on the newest.) To reconstruct a "
dongsheng@627 5706 "specific revision, you must first read the snapshot, and then every one of "
dongsheng@627 5707 "the revisions between the snapshot and your target revision. The more "
dongsheng@627 5708 "history that a file accumulates, the more revisions you must read, hence the "
dongsheng@627 5709 "longer it takes to reconstruct a particular revision."
dongsheng@627 5710 msgstr ""
dongsheng@627 5711
songdongsheng@658 5712 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
dongsheng@714 5713 #: ../en/ch04-concepts.xml:195
songdongsheng@658 5714 msgid "Snapshot of a revlog, with incremental deltas"
dongsheng@660 5715 msgstr "版本日志的快照,以及增量差异"
songdongsheng@658 5716
songdongsheng@658 5717 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
dongsheng@714 5718 #: ../en/ch04-concepts.xml:197
songdongsheng@658 5719 msgid "<imageobject><imagedata fileref=\"figs/snapshot.png\"/></imageobject>"
songdongsheng@658 5720 msgstr ""
songdongsheng@658 5721
songdongsheng@658 5722 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 5723 #: ../en/ch04-concepts.xml:202
dongsheng@627 5724 msgid ""
dongsheng@627 5725 "The innovation that Mercurial applies to this problem is simple but "
dongsheng@627 5726 "effective. Once the cumulative amount of delta information stored since the "
dongsheng@627 5727 "last snapshot exceeds a fixed threshold, it stores a new snapshot "
dongsheng@627 5728 "(compressed, of course), instead of another delta. This makes it possible to "
dongsheng@627 5729 "reconstruct <emphasis>any</emphasis> revision of a file quickly. This "
dongsheng@627 5730 "approach works so well that it has since been copied by several other "
dongsheng@627 5731 "revision control systems."
dongsheng@627 5732 msgstr ""
dongsheng@627 5733
dongsheng@627 5734 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 5735 #: ../en/ch04-concepts.xml:211
songdongsheng@658 5736 msgid ""
songdongsheng@658 5737 "<xref linkend=\"fig:concepts:snapshot\"/> illustrates the idea. In an entry "
songdongsheng@658 5738 "in a revlog's index file, Mercurial stores the range of entries from the data "
songdongsheng@658 5739 "file that it must read to reconstruct a particular revision."
dongsheng@627 5740 msgstr ""
dongsheng@627 5741
dongsheng@627 5742 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
dongsheng@714 5743 #: ../en/ch04-concepts.xml:217
dongsheng@627 5744 msgid "Aside: the influence of video compression"
dongsheng@660 5745 msgstr "旁白: 视频压缩的影响"
dongsheng@627 5746
dongsheng@627 5747 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 5748 #: ../en/ch04-concepts.xml:219
dongsheng@627 5749 msgid ""
dongsheng@627 5750 "If you're familiar with video compression or have ever watched a TV feed "
dongsheng@627 5751 "through a digital cable or satellite service, you may know that most video "
dongsheng@627 5752 "compression schemes store each frame of video as a delta against its "
dongsheng@714 5753 "predecessor frame."
dongsheng@627 5754 msgstr ""
dongsheng@627 5755
dongsheng@627 5756 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 5757 #: ../en/ch04-concepts.xml:225
dongsheng@714 5758 msgid ""
dongsheng@714 5759 "Mercurial borrows this idea to make it possible to reconstruct a revision "
dongsheng@714 5760 "from a snapshot and a small number of deltas."
dongsheng@627 5761 msgstr ""
dongsheng@627 5762
dongsheng@627 5763 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 5764 #: ../en/ch04-concepts.xml:232
dongsheng@627 5765 msgid "Identification and strong integrity"
dongsheng@627 5766 msgstr "鉴别和强完整性"
dongsheng@627 5767
dongsheng@627 5768 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 5769 #: ../en/ch04-concepts.xml:234
dongsheng@627 5770 msgid ""
dongsheng@627 5771 "Along with delta or snapshot information, a revlog entry contains a "
dongsheng@627 5772 "cryptographic hash of the data that it represents. This makes it difficult "
dongsheng@627 5773 "to forge the contents of a revision, and easy to detect accidental corruption."
dongsheng@627 5774 msgstr ""
dongsheng@627 5775
dongsheng@627 5776 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 5777 #: ../en/ch04-concepts.xml:239
dongsheng@627 5778 msgid ""
dongsheng@627 5779 "Hashes provide more than a mere check against corruption; they are used as "
dongsheng@627 5780 "the identifiers for revisions. The changeset identification hashes that you "
dongsheng@627 5781 "see as an end user are from revisions of the changelog. Although filelogs "
dongsheng@627 5782 "and the manifest also use hashes, Mercurial only uses these behind the scenes."
dongsheng@627 5783 msgstr ""
dongsheng@627 5784
dongsheng@627 5785 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 5786 #: ../en/ch04-concepts.xml:246
dongsheng@627 5787 msgid ""
dongsheng@627 5788 "Mercurial verifies that hashes are correct when it retrieves file revisions "
dongsheng@627 5789 "and when it pulls changes from another repository. If it encounters an "
dongsheng@627 5790 "integrity problem, it will complain and stop whatever it's doing."
dongsheng@627 5791 msgstr ""
dongsheng@627 5792
dongsheng@627 5793 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 5794 #: ../en/ch04-concepts.xml:251
dongsheng@627 5795 msgid ""
dongsheng@627 5796 "In addition to the effect it has on retrieval efficiency, Mercurial's use of "
dongsheng@627 5797 "periodic snapshots makes it more robust against partial data corruption. If "
dongsheng@627 5798 "a revlog becomes partly corrupted due to a hardware error or system bug, it's "
dongsheng@627 5799 "often possible to reconstruct some or most revisions from the uncorrupted "
dongsheng@627 5800 "sections of the revlog, both before and after the corrupted section. This "
dongsheng@627 5801 "would not be possible with a delta-only storage model."
dongsheng@627 5802 msgstr ""
dongsheng@627 5803
dongsheng@627 5804 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 5805 #: ../en/ch04-concepts.xml:263
dongsheng@627 5806 msgid "Revision history, branching, and merging"
dongsheng@627 5807 msgstr "修订历史,分支与合并"
dongsheng@627 5808
dongsheng@627 5809 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 5810 #: ../en/ch04-concepts.xml:265
dongsheng@627 5811 msgid ""
dongsheng@627 5812 "Every entry in a Mercurial revlog knows the identity of its immediate "
dongsheng@627 5813 "ancestor revision, usually referred to as its <emphasis>parent</emphasis>. "
dongsheng@627 5814 "In fact, a revision contains room for not one parent, but two. Mercurial "
dongsheng@627 5815 "uses a special hash, called the <quote>null ID</quote>, to represent the idea "
dongsheng@627 5816 "<quote>there is no parent here</quote>. This hash is simply a string of "
dongsheng@627 5817 "zeroes."
dongsheng@627 5818 msgstr ""
dongsheng@627 5819
dongsheng@627 5820 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 5821 #: ../en/ch04-concepts.xml:273
songdongsheng@658 5822 msgid ""
songdongsheng@658 5823 "In <xref linkend=\"fig:concepts:revlog\"/>, you can see an example of the "
songdongsheng@658 5824 "conceptual structure of a revlog. Filelogs, manifests, and changelogs all "
songdongsheng@658 5825 "have this same structure; they differ only in the kind of data stored in each "
songdongsheng@658 5826 "delta or snapshot."
songdongsheng@658 5827 msgstr ""
songdongsheng@658 5828
songdongsheng@658 5829 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 5830 #: ../en/ch04-concepts.xml:279
dongsheng@627 5831 msgid ""
dongsheng@627 5832 "The first revision in a revlog (at the bottom of the image) has the null ID "
dongsheng@627 5833 "in both of its parent slots. For a <quote>normal</quote> revision, its first "
dongsheng@627 5834 "parent slot contains the ID of its parent revision, and its second contains "
dongsheng@627 5835 "the null ID, indicating that the revision has only one real parent. Any two "
dongsheng@627 5836 "revisions that have the same parent ID are branches. A revision that "
dongsheng@627 5837 "represents a merge between branches has two normal revision IDs in its parent "
dongsheng@627 5838 "slots."
dongsheng@627 5839 msgstr ""
dongsheng@627 5840
songdongsheng@658 5841 #. type: Content of: <book><chapter><sect1><figure><title>
dongsheng@714 5842 #: ../en/ch04-concepts.xml:289
songdongsheng@658 5843 msgid "The conceptual structure of a revlog"
dongsheng@660 5844 msgstr "版本日志的设计结构"
songdongsheng@658 5845
songdongsheng@658 5846 #. type: Content of: <book><chapter><sect1><figure><mediaobject>
dongsheng@714 5847 #: ../en/ch04-concepts.xml:291
songdongsheng@658 5848 msgid "<imageobject><imagedata fileref=\"figs/revlog.png\"/></imageobject>"
dongsheng@641 5849 msgstr ""
dongsheng@641 5850
dongsheng@627 5851 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 5852 #: ../en/ch04-concepts.xml:298
dongsheng@627 5853 msgid "The working directory"
dongsheng@627 5854 msgstr "工作目录"
dongsheng@627 5855
dongsheng@627 5856 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 5857 #: ../en/ch04-concepts.xml:300
dongsheng@627 5858 msgid ""
dongsheng@627 5859 "In the working directory, Mercurial stores a snapshot of the files from the "
dongsheng@627 5860 "repository as of a particular changeset."
dongsheng@627 5861 msgstr ""
dongsheng@627 5862
dongsheng@627 5863 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 5864 #: ../en/ch04-concepts.xml:303
dongsheng@627 5865 msgid ""
dongsheng@627 5866 "The working directory <quote>knows</quote> which changeset it contains. When "
dongsheng@627 5867 "you update the working directory to contain a particular changeset, Mercurial "
dongsheng@627 5868 "looks up the appropriate revision of the manifest to find out which files it "
dongsheng@627 5869 "was tracking at the time that changeset was committed, and which revision of "
dongsheng@627 5870 "each file was then current. It then recreates a copy of each of those files, "
dongsheng@627 5871 "with the same contents it had when the changeset was committed."
dongsheng@627 5872 msgstr ""
dongsheng@627 5873
dongsheng@627 5874 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 5875 #: ../en/ch04-concepts.xml:312
dongsheng@714 5876 msgid ""
dongsheng@714 5877 "The <emphasis>dirstate</emphasis> is a special structure that contains "
dongsheng@714 5878 "Mercurial's knowledge of the working directory. It is maintained as a file "
dongsheng@714 5879 "named <filename>.hg/dirstate</filename> inside a repository. The dirstate "
dongsheng@714 5880 "details which changeset the working directory is updated to, and all of the "
dongsheng@714 5881 "files that Mercurial is tracking in the working directory. It also lets "
dongsheng@714 5882 "Mercurial quickly notice changed files, by recording their checkout times and "
dongsheng@714 5883 "sizes."
dongsheng@714 5884 msgstr ""
dongsheng@714 5885
dongsheng@714 5886 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 5887 #: ../en/ch04-concepts.xml:322
dongsheng@627 5888 msgid ""
dongsheng@627 5889 "Just as a revision of a revlog has room for two parents, so that it can "
dongsheng@627 5890 "represent either a normal revision (with one parent) or a merge of two "
dongsheng@627 5891 "earlier revisions, the dirstate has slots for two parents. When you use the "
dongsheng@627 5892 "<command role=\"hg-cmd\">hg update</command> command, the changeset that you "
dongsheng@627 5893 "update to is stored in the <quote>first parent</quote> slot, and the null ID "
dongsheng@627 5894 "in the second. When you <command role=\"hg-cmd\">hg merge</command> with "
dongsheng@627 5895 "another changeset, the first parent remains unchanged, and the second parent "
dongsheng@627 5896 "is filled in with the changeset you're merging with. The <command role=\"hg-"
dongsheng@627 5897 "cmd\">hg parents</command> command tells you what the parents of the dirstate "
dongsheng@627 5898 "are."
dongsheng@627 5899 msgstr ""
dongsheng@627 5900
dongsheng@627 5901 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 5902 #: ../en/ch04-concepts.xml:336
dongsheng@627 5903 msgid "What happens when you commit"
dongsheng@627 5904 msgstr "当你提交时发生的事情"
dongsheng@627 5905
dongsheng@627 5906 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 5907 #: ../en/ch04-concepts.xml:338
dongsheng@627 5908 msgid ""
dongsheng@627 5909 "The dirstate stores parent information for more than just book-keeping "
dongsheng@627 5910 "purposes. Mercurial uses the parents of the dirstate as <emphasis>the "
dongsheng@627 5911 "parents of a new changeset</emphasis> when you perform a commit."
dongsheng@627 5912 msgstr ""
dongsheng@627 5913
songdongsheng@658 5914 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
dongsheng@714 5915 #: ../en/ch04-concepts.xml:344
dongsheng@627 5916 msgid "The working directory can have two parents"
dongsheng@660 5917 msgstr "工作目录可以有两个父亲"
dongsheng@627 5918
songdongsheng@658 5919 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
dongsheng@714 5920 #: ../en/ch04-concepts.xml:346
songdongsheng@658 5921 msgid "<imageobject><imagedata fileref=\"figs/wdir.png\"/></imageobject>"
songdongsheng@658 5922 msgstr ""
songdongsheng@658 5923
songdongsheng@658 5924 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 5925 #: ../en/ch04-concepts.xml:351
songdongsheng@658 5926 msgid ""
songdongsheng@658 5927 "<xref linkend=\"fig:concepts:wdir\"/> shows the normal state of the working "
songdongsheng@658 5928 "directory, where it has a single changeset as parent. That changeset is the "
songdongsheng@658 5929 "<emphasis>tip</emphasis>, the newest changeset in the repository that has no "
songdongsheng@658 5930 "children."
songdongsheng@658 5931 msgstr ""
songdongsheng@658 5932
songdongsheng@658 5933 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
dongsheng@714 5934 #: ../en/ch04-concepts.xml:358
dongsheng@627 5935 msgid "The working directory gains new parents after a commit"
dongsheng@660 5936 msgstr "提交之后,工作目录的父亲就改变了"
dongsheng@627 5937
songdongsheng@658 5938 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
dongsheng@714 5939 #: ../en/ch04-concepts.xml:361
songdongsheng@658 5940 msgid ""
songdongsheng@658 5941 "<imageobject><imagedata fileref=\"figs/wdir-after-commit.png\"/></imageobject>"
songdongsheng@658 5942 msgstr ""
songdongsheng@658 5943
songdongsheng@658 5944 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 5945 #: ../en/ch04-concepts.xml:366
dongsheng@627 5946 msgid ""
dongsheng@627 5947 "It's useful to think of the working directory as <quote>the changeset I'm "
dongsheng@627 5948 "about to commit</quote>. Any files that you tell Mercurial that you've "
dongsheng@627 5949 "added, removed, renamed, or copied will be reflected in that changeset, as "
dongsheng@627 5950 "will modifications to any files that Mercurial is already tracking; the new "
dongsheng@627 5951 "changeset will have the parents of the working directory as its parents."
dongsheng@627 5952 msgstr ""
dongsheng@627 5953
dongsheng@627 5954 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 5955 #: ../en/ch04-concepts.xml:374
dongsheng@627 5956 msgid ""
dongsheng@627 5957 "After a commit, Mercurial will update the parents of the working directory, "
dongsheng@627 5958 "so that the first parent is the ID of the new changeset, and the second is "
songdongsheng@658 5959 "the null ID. This is shown in <xref linkend=\"fig:concepts:wdir-after-commit"
songdongsheng@658 5960 "\"/>. Mercurial doesn't touch any of the files in the working directory when "
songdongsheng@658 5961 "you commit; it just modifies the dirstate to note its new parents."
dongsheng@641 5962 msgstr ""
dongsheng@641 5963
dongsheng@641 5964 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 5965 #: ../en/ch04-concepts.xml:385
dongsheng@627 5966 msgid "Creating a new head"
dongsheng@627 5967 msgstr "创建新顶点"
dongsheng@627 5968
dongsheng@627 5969 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 5970 #: ../en/ch04-concepts.xml:387
dongsheng@627 5971 msgid ""
dongsheng@627 5972 "It's perfectly normal to update the working directory to a changeset other "
dongsheng@627 5973 "than the current tip. For example, you might want to know what your project "
dongsheng@627 5974 "looked like last Tuesday, or you could be looking through changesets to see "
dongsheng@627 5975 "which one introduced a bug. In cases like this, the natural thing to do is "
dongsheng@627 5976 "update the working directory to the changeset you're interested in, and then "
dongsheng@627 5977 "examine the files in the working directory directly to see their contents as "
dongsheng@627 5978 "they were when you committed that changeset. The effect of this is shown in "
songdongsheng@658 5979 "<xref linkend=\"fig:concepts:wdir-pre-branch\"/>."
songdongsheng@658 5980 msgstr ""
songdongsheng@658 5981
songdongsheng@658 5982 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
dongsheng@714 5983 #: ../en/ch04-concepts.xml:399
dongsheng@627 5984 msgid "The working directory, updated to an older changeset"
dongsheng@660 5985 msgstr "同步到旧修改集的工作目录"
dongsheng@627 5986
songdongsheng@658 5987 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
dongsheng@714 5988 #: ../en/ch04-concepts.xml:402
songdongsheng@658 5989 msgid ""
songdongsheng@658 5990 "<imageobject><imagedata fileref=\"figs/wdir-pre-branch.png\"/></imageobject>"
songdongsheng@658 5991 msgstr ""
songdongsheng@658 5992
songdongsheng@658 5993 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 5994 #: ../en/ch04-concepts.xml:407
dongsheng@627 5995 msgid ""
dongsheng@627 5996 "Having updated the working directory to an older changeset, what happens if "
dongsheng@627 5997 "you make some changes, and then commit? Mercurial behaves in the same way as "
dongsheng@627 5998 "I outlined above. The parents of the working directory become the parents of "
dongsheng@627 5999 "the new changeset. This new changeset has no children, so it becomes the new "
dongsheng@627 6000 "tip. And the repository now contains two changesets that have no children; "
dongsheng@627 6001 "we call these <emphasis>heads</emphasis>. You can see the structure that "
songdongsheng@658 6002 "this creates in <xref linkend=\"fig:concepts:wdir-branch\"/>."
songdongsheng@658 6003 msgstr ""
songdongsheng@658 6004
songdongsheng@658 6005 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
dongsheng@714 6006 #: ../en/ch04-concepts.xml:419
dongsheng@627 6007 msgid "After a commit made while synced to an older changeset"
dongsheng@660 6008 msgstr "对同步到旧修改集的工作目录提交之后"
dongsheng@627 6009
songdongsheng@658 6010 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
dongsheng@714 6011 #: ../en/ch04-concepts.xml:422
songdongsheng@658 6012 msgid "<imageobject><imagedata fileref=\"figs/wdir-branch.png\"/></imageobject>"
songdongsheng@658 6013 msgstr ""
songdongsheng@658 6014
dongsheng@627 6015 #. type: Content of: <book><chapter><sect1><sect2><note><para>
dongsheng@714 6016 #: ../en/ch04-concepts.xml:428
dongsheng@627 6017 msgid ""
dongsheng@627 6018 "If you're new to Mercurial, you should keep in mind a common <quote>error</"
dongsheng@627 6019 "quote>, which is to use the <command role=\"hg-cmd\">hg pull</command> "
dongsheng@627 6020 "command without any options. By default, the <command role=\"hg-cmd\">hg "
dongsheng@627 6021 "pull</command> command <emphasis>does not</emphasis> update the working "
dongsheng@627 6022 "directory, so you'll bring new changesets into your repository, but the "
dongsheng@627 6023 "working directory will stay synced at the same changeset as before the pull. "
dongsheng@627 6024 "If you make some changes and commit afterwards, you'll thus create a new "
dongsheng@627 6025 "head, because your working directory isn't synced to whatever the current tip "
dongsheng@714 6026 "is. To combine the operation of a pull, followed by an update, run "
dongsheng@714 6027 "<command>hg pull -u</command>."
dongsheng@627 6028 msgstr ""
dongsheng@627 6029
dongsheng@627 6030 #. type: Content of: <book><chapter><sect1><sect2><note><para>
dongsheng@714 6031 #: ../en/ch04-concepts.xml:442
dongsheng@627 6032 msgid ""
dongsheng@627 6033 "I put the word <quote>error</quote> in quotes because all that you need to do "
dongsheng@714 6034 "to rectify the situation where you created a new head by accident is <command "
dongsheng@714 6035 "role=\"hg-cmd\">hg merge</command>, then <command role=\"hg-cmd\">hg commit</"
dongsheng@714 6036 "command>. In other words, this almost never has negative consequences; it's "
dongsheng@714 6037 "just something of a surprise for newcomers. I'll discuss other ways to avoid "
dongsheng@714 6038 "this behavior, and why Mercurial behaves in this initially surprising way, "
dongsheng@714 6039 "later on."
songdongsheng@710 6040 msgstr ""
songdongsheng@710 6041
songdongsheng@710 6042 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 6043 #: ../en/ch04-concepts.xml:455
songdongsheng@710 6044 msgid "Merging changes"
songdongsheng@711 6045 msgstr "合并修改"
songdongsheng@710 6046
songdongsheng@710 6047 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6048 #: ../en/ch04-concepts.xml:457
dongsheng@627 6049 msgid ""
dongsheng@627 6050 "When you run the <command role=\"hg-cmd\">hg merge</command> command, "
dongsheng@627 6051 "Mercurial leaves the first parent of the working directory unchanged, and "
dongsheng@627 6052 "sets the second parent to the changeset you're merging with, as shown in "
songdongsheng@658 6053 "<xref linkend=\"fig:concepts:wdir-merge\"/>."
songdongsheng@658 6054 msgstr ""
songdongsheng@658 6055
songdongsheng@658 6056 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
dongsheng@714 6057 #: ../en/ch04-concepts.xml:464
dongsheng@627 6058 msgid "Merging two heads"
dongsheng@660 6059 msgstr "合并两个顶点"
dongsheng@627 6060
songdongsheng@658 6061 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
dongsheng@714 6062 #: ../en/ch04-concepts.xml:466
songdongsheng@658 6063 msgid ""
songdongsheng@658 6064 "<imageobject> <imagedata fileref=\"figs/wdir-merge.png\"/> </imageobject>"
songdongsheng@658 6065 msgstr ""
songdongsheng@658 6066
songdongsheng@658 6067 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6068 #: ../en/ch04-concepts.xml:473
dongsheng@627 6069 msgid ""
dongsheng@627 6070 "Mercurial also has to modify the working directory, to merge the files "
dongsheng@627 6071 "managed in the two changesets. Simplified a little, the merging process goes "
dongsheng@627 6072 "like this, for every file in the manifests of both changesets."
dongsheng@627 6073 msgstr ""
dongsheng@627 6074
dongsheng@627 6075 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 6076 #: ../en/ch04-concepts.xml:478
dongsheng@627 6077 msgid "If neither changeset has modified a file, do nothing with that file."
dongsheng@627 6078 msgstr ""
dongsheng@627 6079
dongsheng@627 6080 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 6081 #: ../en/ch04-concepts.xml:481
dongsheng@627 6082 msgid ""
dongsheng@627 6083 "If one changeset has modified a file, and the other hasn't, create the "
dongsheng@627 6084 "modified copy of the file in the working directory."
dongsheng@627 6085 msgstr ""
dongsheng@627 6086
dongsheng@627 6087 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 6088 #: ../en/ch04-concepts.xml:485
dongsheng@627 6089 msgid ""
dongsheng@627 6090 "If one changeset has removed a file, and the other hasn't (or has also "
dongsheng@627 6091 "deleted it), delete the file from the working directory."
dongsheng@627 6092 msgstr ""
dongsheng@627 6093
dongsheng@627 6094 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 6095 #: ../en/ch04-concepts.xml:489
dongsheng@627 6096 msgid ""
dongsheng@627 6097 "If one changeset has removed a file, but the other has modified the file, ask "
dongsheng@627 6098 "the user what to do: keep the modified file, or remove it?"
dongsheng@627 6099 msgstr ""
dongsheng@627 6100
dongsheng@627 6101 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 6102 #: ../en/ch04-concepts.xml:493
dongsheng@627 6103 msgid ""
dongsheng@627 6104 "If both changesets have modified a file, invoke an external merge program to "
dongsheng@627 6105 "choose the new contents for the merged file. This may require input from the "
dongsheng@627 6106 "user."
dongsheng@627 6107 msgstr ""
dongsheng@627 6108
dongsheng@627 6109 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 6110 #: ../en/ch04-concepts.xml:498
dongsheng@627 6111 msgid ""
dongsheng@627 6112 "If one changeset has modified a file, and the other has renamed or copied the "
dongsheng@627 6113 "file, make sure that the changes follow the new name of the file."
dongsheng@627 6114 msgstr ""
dongsheng@627 6115
dongsheng@627 6116 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6117 #: ../en/ch04-concepts.xml:502
dongsheng@627 6118 msgid ""
songdongsheng@668 6119 "There are more details&emdash;merging has plenty of corner cases&emdash;but "
songdongsheng@668 6120 "these are the most common choices that are involved in a merge. As you can "
songdongsheng@668 6121 "see, most cases are completely automatic, and indeed most merges finish "
dongsheng@627 6122 "automatically, without requiring your input to resolve any conflicts."
dongsheng@627 6123 msgstr ""
dongsheng@627 6124
dongsheng@627 6125 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6126 #: ../en/ch04-concepts.xml:509
dongsheng@627 6127 msgid ""
dongsheng@627 6128 "When you're thinking about what happens when you commit after a merge, once "
dongsheng@627 6129 "again the working directory is <quote>the changeset I'm about to commit</"
dongsheng@627 6130 "quote>. After the <command role=\"hg-cmd\">hg merge</command> command "
dongsheng@627 6131 "completes, the working directory has two parents; these will become the "
dongsheng@627 6132 "parents of the new changeset."
dongsheng@627 6133 msgstr ""
dongsheng@627 6134
dongsheng@627 6135 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6136 #: ../en/ch04-concepts.xml:516
dongsheng@627 6137 msgid ""
dongsheng@627 6138 "Mercurial lets you perform multiple merges, but you must commit the results "
dongsheng@627 6139 "of each individual merge as you go. This is necessary because Mercurial only "
dongsheng@627 6140 "tracks two parents for both revisions and the working directory. While it "
dongsheng@714 6141 "would be technically feasible to merge multiple changesets at once, Mercurial "
dongsheng@714 6142 "avoids this for simplicity. With multi-way merges, the risks of user "
dongsheng@714 6143 "confusion, nasty conflict resolution, and making a terrible mess of a merge "
dongsheng@714 6144 "would grow intolerable."
dongsheng@627 6145 msgstr ""
dongsheng@627 6146
songdongsheng@710 6147 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 6148 #: ../en/ch04-concepts.xml:529
songdongsheng@710 6149 msgid "Merging and renames"
songdongsheng@711 6150 msgstr "合并与改名"
songdongsheng@710 6151
songdongsheng@710 6152 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6153 #: ../en/ch04-concepts.xml:531
songdongsheng@710 6154 msgid ""
songdongsheng@710 6155 "A surprising number of revision control systems pay little or no attention to "
songdongsheng@710 6156 "a file's <emphasis>name</emphasis> over time. For instance, it used to be "
songdongsheng@710 6157 "common that if a file got renamed on one side of a merge, the changes from "
songdongsheng@710 6158 "the other side would be silently dropped."
songdongsheng@710 6159 msgstr ""
songdongsheng@710 6160
songdongsheng@710 6161 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6162 #: ../en/ch04-concepts.xml:537
songdongsheng@710 6163 msgid ""
songdongsheng@710 6164 "Mercurial records metadata when you tell it to perform a rename or copy. It "
songdongsheng@710 6165 "uses this metadata during a merge to do the right thing in the case of a "
songdongsheng@710 6166 "merge. For instance, if I rename a file, and you edit it without renaming "
songdongsheng@710 6167 "it, when we merge our work the file will be renamed and have your edits "
songdongsheng@710 6168 "applied."
songdongsheng@710 6169 msgstr ""
songdongsheng@710 6170
dongsheng@627 6171 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 6172 #: ../en/ch04-concepts.xml:547
dongsheng@627 6173 msgid "Other interesting design features"
dongsheng@627 6174 msgstr "其它有趣的设计特性"
dongsheng@627 6175
dongsheng@627 6176 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 6177 #: ../en/ch04-concepts.xml:549
dongsheng@627 6178 msgid ""
dongsheng@627 6179 "In the sections above, I've tried to highlight some of the most important "
dongsheng@627 6180 "aspects of Mercurial's design, to illustrate that it pays careful attention "
dongsheng@627 6181 "to reliability and performance. However, the attention to detail doesn't "
dongsheng@627 6182 "stop there. There are a number of other aspects of Mercurial's construction "
dongsheng@627 6183 "that I personally find interesting. I'll detail a few of them here, separate "
dongsheng@627 6184 "from the <quote>big ticket</quote> items above, so that if you're interested, "
dongsheng@627 6185 "you can gain a better idea of the amount of thinking that goes into a well-"
dongsheng@627 6186 "designed system."
dongsheng@627 6187 msgstr ""
dongsheng@627 6188
dongsheng@627 6189 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 6190 #: ../en/ch04-concepts.xml:560
dongsheng@627 6191 msgid "Clever compression"
dongsheng@627 6192 msgstr "智能压缩"
dongsheng@627 6193
dongsheng@627 6194 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6195 #: ../en/ch04-concepts.xml:562
dongsheng@627 6196 msgid ""
dongsheng@627 6197 "When appropriate, Mercurial will store both snapshots and deltas in "
dongsheng@627 6198 "compressed form. It does this by always <emphasis>trying to</emphasis> "
dongsheng@627 6199 "compress a snapshot or delta, but only storing the compressed version if it's "
dongsheng@627 6200 "smaller than the uncompressed version."
dongsheng@627 6201 msgstr ""
dongsheng@627 6202
dongsheng@627 6203 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6204 #: ../en/ch04-concepts.xml:568
dongsheng@627 6205 msgid ""
dongsheng@627 6206 "This means that Mercurial does <quote>the right thing</quote> when storing a "
dongsheng@627 6207 "file whose native form is compressed, such as a <literal>zip</literal> "
dongsheng@627 6208 "archive or a JPEG image. When these types of files are compressed a second "
dongsheng@627 6209 "time, the resulting file is usually bigger than the once-compressed form, and "
dongsheng@627 6210 "so Mercurial will store the plain <literal>zip</literal> or JPEG."
dongsheng@627 6211 msgstr ""
dongsheng@627 6212
dongsheng@627 6213 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6214 #: ../en/ch04-concepts.xml:576
dongsheng@627 6215 msgid ""
dongsheng@627 6216 "Deltas between revisions of a compressed file are usually larger than "
dongsheng@627 6217 "snapshots of the file, and Mercurial again does <quote>the right thing</"
dongsheng@627 6218 "quote> in these cases. It finds that such a delta exceeds the threshold at "
dongsheng@627 6219 "which it should store a complete snapshot of the file, so it stores the "
dongsheng@627 6220 "snapshot, again saving space compared to a naive delta-only approach."
dongsheng@627 6221 msgstr ""
dongsheng@627 6222
dongsheng@627 6223 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
dongsheng@714 6224 #: ../en/ch04-concepts.xml:585
dongsheng@627 6225 msgid "Network recompression"
dongsheng@627 6226 msgstr "网络重新压缩"
dongsheng@627 6227
dongsheng@627 6228 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 6229 #: ../en/ch04-concepts.xml:587
dongsheng@627 6230 msgid ""
dongsheng@627 6231 "When storing revisions on disk, Mercurial uses the <quote>deflate</quote> "
dongsheng@627 6232 "compression algorithm (the same one used by the popular <literal>zip</"
dongsheng@627 6233 "literal> archive format), which balances good speed with a respectable "
dongsheng@627 6234 "compression ratio. However, when transmitting revision data over a network "
dongsheng@627 6235 "connection, Mercurial uncompresses the compressed revision data."
dongsheng@627 6236 msgstr ""
dongsheng@627 6237
dongsheng@627 6238 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 6239 #: ../en/ch04-concepts.xml:595
dongsheng@627 6240 msgid ""
dongsheng@627 6241 "If the connection is over HTTP, Mercurial recompresses the entire stream of "
dongsheng@627 6242 "data using a compression algorithm that gives a better compression ratio (the "
dongsheng@627 6243 "Burrows-Wheeler algorithm from the widely used <literal>bzip2</literal> "
dongsheng@627 6244 "compression package). This combination of algorithm and compression of the "
dongsheng@627 6245 "entire stream (instead of a revision at a time) substantially reduces the "
dongsheng@627 6246 "number of bytes to be transferred, yielding better network performance over "
songdongsheng@710 6247 "most kinds of network."
dongsheng@627 6248 msgstr ""
dongsheng@627 6249
dongsheng@627 6250 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 6251 #: ../en/ch04-concepts.xml:605
dongsheng@714 6252 msgid ""
dongsheng@714 6253 "If the connection is over <command>ssh</command>, Mercurial "
dongsheng@627 6254 "<emphasis>doesn't</emphasis> recompress the stream, because <command>ssh</"
dongsheng@714 6255 "command> can already do this itself. You can tell Mercurial to always use "
dongsheng@714 6256 "<command>ssh</command>'s compression feature by editing the <filename>.hgrc</"
dongsheng@714 6257 "filename> file in your home directory as follows."
dongsheng@627 6258 msgstr ""
dongsheng@627 6259
dongsheng@627 6260 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 6261 #: ../en/ch04-concepts.xml:620
dongsheng@627 6262 msgid "Read/write ordering and atomicity"
dongsheng@627 6263 msgstr "读写顺序与原子性"
dongsheng@627 6264
dongsheng@627 6265 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6266 #: ../en/ch04-concepts.xml:622
dongsheng@627 6267 msgid ""
dongsheng@627 6268 "Appending to files isn't the whole story when it comes to guaranteeing that a "
songdongsheng@658 6269 "reader won't see a partial write. If you recall <xref linkend=\"fig:concepts:"
songdongsheng@658 6270 "metadata\"/>, revisions in the changelog point to revisions in the manifest, "
songdongsheng@658 6271 "and revisions in the manifest point to revisions in filelogs. This hierarchy "
songdongsheng@658 6272 "is deliberate."
songdongsheng@658 6273 msgstr ""
songdongsheng@658 6274
songdongsheng@658 6275 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6276 #: ../en/ch04-concepts.xml:629
dongsheng@627 6277 msgid ""
dongsheng@627 6278 "A writer starts a transaction by writing filelog and manifest data, and "
dongsheng@627 6279 "doesn't write any changelog data until those are finished. A reader starts "
dongsheng@627 6280 "by reading changelog data, then manifest data, followed by filelog data."
dongsheng@627 6281 msgstr ""
dongsheng@627 6282
dongsheng@627 6283 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6284 #: ../en/ch04-concepts.xml:634
dongsheng@627 6285 msgid ""
dongsheng@627 6286 "Since the writer has always finished writing filelog and manifest data before "
dongsheng@627 6287 "it writes to the changelog, a reader will never read a pointer to a partially "
dongsheng@627 6288 "written manifest revision from the changelog, and it will never read a "
dongsheng@627 6289 "pointer to a partially written filelog revision from the manifest."
dongsheng@627 6290 msgstr ""
dongsheng@627 6291
dongsheng@627 6292 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 6293 #: ../en/ch04-concepts.xml:642
dongsheng@627 6294 msgid "Concurrent access"
dongsheng@627 6295 msgstr "并发访问"
dongsheng@627 6296
dongsheng@627 6297 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6298 #: ../en/ch04-concepts.xml:644
dongsheng@627 6299 msgid ""
dongsheng@627 6300 "The read/write ordering and atomicity guarantees mean that Mercurial never "
dongsheng@627 6301 "needs to <emphasis>lock</emphasis> a repository when it's reading data, even "
dongsheng@627 6302 "if the repository is being written to while the read is occurring. This has a "
dongsheng@627 6303 "big effect on scalability; you can have an arbitrary number of Mercurial "
dongsheng@714 6304 "processes safely reading data from a repository all at once, no matter "
dongsheng@627 6305 "whether it's being written to or not."
dongsheng@627 6306 msgstr ""
dongsheng@627 6307
dongsheng@627 6308 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6309 #: ../en/ch04-concepts.xml:653
dongsheng@627 6310 msgid ""
dongsheng@627 6311 "The lockless nature of reading means that if you're sharing a repository on a "
dongsheng@627 6312 "multi-user system, you don't need to grant other local users permission to "
dongsheng@627 6313 "<emphasis>write</emphasis> to your repository in order for them to be able to "
dongsheng@627 6314 "clone it or pull changes from it; they only need <emphasis>read</emphasis> "
dongsheng@627 6315 "permission. (This is <emphasis>not</emphasis> a common feature among "
dongsheng@627 6316 "revision control systems, so don't take it for granted! Most require readers "
dongsheng@627 6317 "to be able to lock a repository to access it safely, and this requires write "
dongsheng@627 6318 "permission on at least one directory, which of course makes for all kinds of "
dongsheng@627 6319 "nasty and annoying security and administrative problems.)"
dongsheng@627 6320 msgstr ""
dongsheng@627 6321
dongsheng@627 6322 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6323 #: ../en/ch04-concepts.xml:666
dongsheng@627 6324 msgid ""
dongsheng@627 6325 "Mercurial uses locks to ensure that only one process can write to a "
dongsheng@627 6326 "repository at a time (the locking mechanism is safe even over filesystems "
dongsheng@627 6327 "that are notoriously hostile to locking, such as NFS). If a repository is "
dongsheng@627 6328 "locked, a writer will wait for a while to retry if the repository becomes "
dongsheng@627 6329 "unlocked, but if the repository remains locked for too long, the process "
dongsheng@627 6330 "attempting to write will time out after a while. This means that your daily "
dongsheng@627 6331 "automated scripts won't get stuck forever and pile up if a system crashes "
dongsheng@627 6332 "unnoticed, for example. (Yes, the timeout is configurable, from zero to "
dongsheng@627 6333 "infinity.)"
dongsheng@627 6334 msgstr ""
dongsheng@627 6335
dongsheng@627 6336 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
dongsheng@714 6337 #: ../en/ch04-concepts.xml:678
dongsheng@627 6338 msgid "Safe dirstate access"
dongsheng@627 6339 msgstr "安全的目录状态访问"
dongsheng@627 6340
dongsheng@627 6341 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 6342 #: ../en/ch04-concepts.xml:680
dongsheng@627 6343 msgid ""
dongsheng@627 6344 "As with revision data, Mercurial doesn't take a lock to read the dirstate "
dongsheng@627 6345 "file; it does acquire a lock to write it. To avoid the possibility of "
dongsheng@627 6346 "reading a partially written copy of the dirstate file, Mercurial writes to a "
dongsheng@627 6347 "file with a unique name in the same directory as the dirstate file, then "
dongsheng@627 6348 "renames the temporary file atomically to <filename>dirstate</filename>. The "
dongsheng@627 6349 "file named <filename>dirstate</filename> is thus guaranteed to be complete, "
dongsheng@627 6350 "not partially written."
dongsheng@627 6351 msgstr ""
dongsheng@627 6352
dongsheng@627 6353 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 6354 #: ../en/ch04-concepts.xml:693
dongsheng@627 6355 msgid "Avoiding seeks"
dongsheng@627 6356 msgstr "避免查找"
dongsheng@627 6357
dongsheng@627 6358 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6359 #: ../en/ch04-concepts.xml:695
dongsheng@627 6360 msgid ""
dongsheng@627 6361 "Critical to Mercurial's performance is the avoidance of seeks of the disk "
dongsheng@627 6362 "head, since any seek is far more expensive than even a comparatively large "
dongsheng@627 6363 "read operation."
dongsheng@627 6364 msgstr ""
dongsheng@627 6365
dongsheng@627 6366 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6367 #: ../en/ch04-concepts.xml:699
dongsheng@627 6368 msgid ""
dongsheng@627 6369 "This is why, for example, the dirstate is stored in a single file. If there "
dongsheng@627 6370 "were a dirstate file per directory that Mercurial tracked, the disk would "
dongsheng@627 6371 "seek once per directory. Instead, Mercurial reads the entire single dirstate "
dongsheng@627 6372 "file in one step."
dongsheng@627 6373 msgstr ""
dongsheng@627 6374
dongsheng@627 6375 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6376 #: ../en/ch04-concepts.xml:705
dongsheng@627 6377 msgid ""
dongsheng@627 6378 "Mercurial also uses a <quote>copy on write</quote> scheme when cloning a "
dongsheng@627 6379 "repository on local storage. Instead of copying every revlog file from the "
dongsheng@627 6380 "old repository into the new repository, it makes a <quote>hard link</quote>, "
dongsheng@627 6381 "which is a shorthand way to say <quote>these two names point to the same "
dongsheng@627 6382 "file</quote>. When Mercurial is about to write to one of a revlog's files, "
dongsheng@627 6383 "it checks to see if the number of names pointing at the file is greater than "
dongsheng@627 6384 "one. If it is, more than one repository is using the file, so Mercurial "
dongsheng@627 6385 "makes a new copy of the file that is private to this repository."
dongsheng@627 6386 msgstr ""
dongsheng@627 6387
dongsheng@627 6388 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6389 #: ../en/ch04-concepts.xml:716
dongsheng@627 6390 msgid ""
dongsheng@627 6391 "A few revision control developers have pointed out that this idea of making a "
dongsheng@627 6392 "complete private copy of a file is not very efficient in its use of storage. "
dongsheng@627 6393 "While this is true, storage is cheap, and this method gives the highest "
dongsheng@627 6394 "performance while deferring most book-keeping to the operating system. An "
dongsheng@627 6395 "alternative scheme would most likely reduce performance and increase the "
dongsheng@714 6396 "complexity of the software, but speed and simplicity are key to the "
dongsheng@627 6397 "<quote>feel</quote> of day-to-day use."
dongsheng@627 6398 msgstr ""
dongsheng@627 6399
dongsheng@627 6400 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 6401 #: ../en/ch04-concepts.xml:728
dongsheng@627 6402 msgid "Other contents of the dirstate"
dongsheng@627 6403 msgstr "目录状态的其它内容"
dongsheng@627 6404
dongsheng@627 6405 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6406 #: ../en/ch04-concepts.xml:730
dongsheng@627 6407 msgid ""
dongsheng@627 6408 "Because Mercurial doesn't force you to tell it when you're modifying a file, "
dongsheng@627 6409 "it uses the dirstate to store some extra information so it can determine "
dongsheng@627 6410 "efficiently whether you have modified a file. For each file in the working "
dongsheng@627 6411 "directory, it stores the time that it last modified the file itself, and the "
dongsheng@627 6412 "size of the file at that time."
dongsheng@627 6413 msgstr ""
dongsheng@627 6414
dongsheng@627 6415 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6416 #: ../en/ch04-concepts.xml:737
dongsheng@627 6417 msgid ""
dongsheng@627 6418 "When you explicitly <command role=\"hg-cmd\">hg add</command>, <command role="
dongsheng@627 6419 "\"hg-cmd\">hg remove</command>, <command role=\"hg-cmd\">hg rename</command> "
dongsheng@627 6420 "or <command role=\"hg-cmd\">hg copy</command> files, Mercurial updates the "
dongsheng@627 6421 "dirstate so that it knows what to do with those files when you commit."
dongsheng@627 6422 msgstr ""
dongsheng@627 6423
dongsheng@627 6424 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6425 #: ../en/ch04-concepts.xml:744
dongsheng@714 6426 msgid ""
dongsheng@714 6427 "The dirstate helps Mercurial to efficiently check the status of files in a "
dongsheng@714 6428 "repository."
dongsheng@714 6429 msgstr ""
dongsheng@714 6430
dongsheng@714 6431 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 6432 #: ../en/ch04-concepts.xml:749
dongsheng@714 6433 msgid ""
dongsheng@714 6434 "When Mercurial checks the state of a file in the working directory, it first "
dongsheng@714 6435 "checks a file's modification time against the time in the dirstate that "
dongsheng@714 6436 "records when Mercurial last wrote the file. If the last modified time is the "
dongsheng@714 6437 "same as the time when Mercurial wrote the file, the file must not have been "
dongsheng@714 6438 "modified, so Mercurial does not need to check any further."
dongsheng@714 6439 msgstr ""
dongsheng@714 6440
dongsheng@714 6441 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 6442 #: ../en/ch04-concepts.xml:758
dongsheng@714 6443 msgid ""
dongsheng@714 6444 "If the file's size has changed, the file must have been modified. If the "
dongsheng@714 6445 "modification time has changed, but the size has not, only then does Mercurial "
dongsheng@714 6446 "need to actually read the contents of the file to see if it has changed."
dongsheng@714 6447 msgstr ""
dongsheng@714 6448
dongsheng@714 6449 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6450 #: ../en/ch04-concepts.xml:766
dongsheng@714 6451 msgid ""
dongsheng@714 6452 "Storing the modification time and size dramatically reduces the number of "
dongsheng@714 6453 "read operations that Mercurial needs to perform when we run commands like "
dongsheng@714 6454 "<command>hg status</command>. This results in large performance improvements."
dongsheng@627 6455 msgstr ""
dongsheng@627 6456
dongsheng@627 6457 #. type: Content of: <book><chapter><title>
dongsheng@714 6458 #: ../en/ch05-daily.xml:5
dongsheng@627 6459 msgid "Mercurial in daily use"
dongsheng@627 6460 msgstr "Mercurial 的日常使用"
dongsheng@627 6461
dongsheng@627 6462 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 6463 #: ../en/ch05-daily.xml:8
dongsheng@627 6464 msgid "Telling Mercurial which files to track"
dongsheng@627 6465 msgstr "告诉 Mercurial 要跟踪哪些文件"
dongsheng@627 6466
dongsheng@627 6467 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 6468 #: ../en/ch05-daily.xml:10
dongsheng@627 6469 msgid ""
dongsheng@627 6470 "Mercurial does not work with files in your repository unless you tell it to "
dongsheng@627 6471 "manage them. The <command role=\"hg-cmd\">hg status</command> command will "
dongsheng@627 6472 "tell you which files Mercurial doesn't know about; it uses a <quote><literal>?"
dongsheng@627 6473 "</literal></quote> to display such files."
dongsheng@627 6474 msgstr ""
dongsheng@627 6475
dongsheng@627 6476 #
dongsheng@627 6477 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 6478 #: ../en/ch05-daily.xml:17
dongsheng@627 6479 msgid ""
dongsheng@627 6480 "To tell Mercurial to track a file, use the <command role=\"hg-cmd\">hg add</"
dongsheng@627 6481 "command> command. Once you have added a file, the entry in the output of "
dongsheng@627 6482 "<command role=\"hg-cmd\">hg status</command> for that file changes from "
dongsheng@627 6483 "<quote><literal>?</literal></quote> to <quote><literal>A</literal></quote>."
dongsheng@627 6484 msgstr ""
dongsheng@627 6485
dongsheng@627 6486 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 6487 #: ../en/ch05-daily.xml:26
dongsheng@627 6488 msgid ""
dongsheng@627 6489 "After you run a <command role=\"hg-cmd\">hg commit</command>, the files that "
dongsheng@627 6490 "you added before the commit will no longer be listed in the output of "
songdongsheng@710 6491 "<command role=\"hg-cmd\">hg status</command>. The reason for this is that by "
songdongsheng@710 6492 "default, <command role=\"hg-cmd\">hg status</command> only tells you about "
songdongsheng@710 6493 "<quote>interesting</quote> files&emdash;those that you have (for example) "
songdongsheng@710 6494 "modified, removed, or renamed. If you have a repository that contains "
songdongsheng@710 6495 "thousands of files, you will rarely want to know about files that Mercurial "
songdongsheng@710 6496 "is tracking, but that have not changed. (You can still get this information; "
songdongsheng@710 6497 "we'll return to this later.)"
dongsheng@627 6498 msgstr ""
dongsheng@627 6499
dongsheng@627 6500 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 6501 #: ../en/ch05-daily.xml:38
dongsheng@627 6502 msgid ""
dongsheng@627 6503 "Once you add a file, Mercurial doesn't do anything with it immediately. "
dongsheng@627 6504 "Instead, it will take a snapshot of the file's state the next time you "
dongsheng@627 6505 "perform a commit. It will then continue to track the changes you make to the "
dongsheng@627 6506 "file every time you commit, until you remove the file."
dongsheng@627 6507 msgstr ""
dongsheng@627 6508
dongsheng@627 6509 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 6510 #: ../en/ch05-daily.xml:45
dongsheng@627 6511 msgid "Explicit versus implicit file naming"
dongsheng@627 6512 msgstr "明确与隐含文件命名"
dongsheng@627 6513
dongsheng@627 6514 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6515 #: ../en/ch05-daily.xml:47
dongsheng@627 6516 msgid ""
songdongsheng@710 6517 "A useful behavior that Mercurial has is that if you pass the name of a "
dongsheng@627 6518 "directory to a command, every Mercurial command will treat this as <quote>I "
dongsheng@627 6519 "want to operate on every file in this directory and its subdirectories</"
dongsheng@627 6520 "quote>."
dongsheng@627 6521 msgstr ""
dongsheng@627 6522
dongsheng@627 6523 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6524 #: ../en/ch05-daily.xml:54
dongsheng@627 6525 msgid ""
dongsheng@627 6526 "Notice in this example that Mercurial printed the names of the files it "
songdongsheng@710 6527 "added, whereas it didn't do so when we added the file named <filename>myfile."
songdongsheng@710 6528 "txt</filename> in the earlier example."
dongsheng@627 6529 msgstr ""
dongsheng@627 6530
dongsheng@627 6531 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6532 #: ../en/ch05-daily.xml:59
dongsheng@627 6533 msgid ""
dongsheng@627 6534 "What's going on is that in the former case, we explicitly named the file to "
songdongsheng@710 6535 "add on the command line. The assumption that Mercurial makes in such cases "
songdongsheng@710 6536 "is that we know what we are doing, and it doesn't print any output."
dongsheng@627 6537 msgstr ""
dongsheng@627 6538
dongsheng@627 6539 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6540 #: ../en/ch05-daily.xml:64
dongsheng@627 6541 msgid ""
dongsheng@627 6542 "However, when we <emphasis>imply</emphasis> the names of files by giving the "
dongsheng@627 6543 "name of a directory, Mercurial takes the extra step of printing the name of "
dongsheng@627 6544 "each file that it does something with. This makes it more clear what is "
dongsheng@627 6545 "happening, and reduces the likelihood of a silent and nasty surprise. This "
songdongsheng@710 6546 "behavior is common to most Mercurial commands."
dongsheng@627 6547 msgstr ""
dongsheng@627 6548
dongsheng@627 6549 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 6550 #: ../en/ch05-daily.xml:73
songdongsheng@710 6551 msgid "Mercurial tracks files, not directories"
songdongsheng@711 6552 msgstr "Mercurial 只跟踪文件,不跟踪目录"
dongsheng@627 6553
dongsheng@627 6554 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6555 #: ../en/ch05-daily.xml:75
dongsheng@627 6556 msgid ""
dongsheng@627 6557 "Mercurial does not track directory information. Instead, it tracks the path "
dongsheng@627 6558 "to a file. Before creating a file, it first creates any missing directory "
dongsheng@627 6559 "components of the path. After it deletes a file, it then deletes any empty "
dongsheng@627 6560 "directories that were in the deleted file's path. This sounds like a trivial "
dongsheng@627 6561 "distinction, but it has one minor practical consequence: it is not possible "
dongsheng@627 6562 "to represent a completely empty directory in Mercurial."
dongsheng@627 6563 msgstr ""
dongsheng@627 6564
dongsheng@627 6565 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6566 #: ../en/ch05-daily.xml:84
dongsheng@627 6567 msgid ""
dongsheng@627 6568 "Empty directories are rarely useful, and there are unintrusive workarounds "
dongsheng@627 6569 "that you can use to achieve an appropriate effect. The developers of "
dongsheng@627 6570 "Mercurial thus felt that the complexity that would be required to manage "
dongsheng@627 6571 "empty directories was not worth the limited benefit this feature would bring."
dongsheng@627 6572 msgstr ""
dongsheng@627 6573
dongsheng@627 6574 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6575 #: ../en/ch05-daily.xml:91
dongsheng@627 6576 msgid ""
dongsheng@627 6577 "If you need an empty directory in your repository, there are a few ways to "
dongsheng@627 6578 "achieve this. One is to create a directory, then <command role=\"hg-cmd\">hg "
dongsheng@627 6579 "add</command> a <quote>hidden</quote> file to that directory. On Unix-like "
dongsheng@627 6580 "systems, any file name that begins with a period (<quote><literal>.</"
dongsheng@627 6581 "literal></quote>) is treated as hidden by most commands and GUI tools. This "
dongsheng@627 6582 "approach is illustrated below."
dongsheng@627 6583 msgstr ""
dongsheng@627 6584
dongsheng@627 6585 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6586 #: ../en/ch05-daily.xml:102
dongsheng@627 6587 msgid ""
dongsheng@627 6588 "Another way to tackle a need for an empty directory is to simply create one "
dongsheng@627 6589 "in your automated build scripts before they will need it."
dongsheng@627 6590 msgstr ""
dongsheng@627 6591
dongsheng@627 6592 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 6593 #: ../en/ch05-daily.xml:109
dongsheng@627 6594 msgid "How to stop tracking a file"
dongsheng@627 6595 msgstr "如何停止跟踪文件"
dongsheng@627 6596
dongsheng@627 6597 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 6598 #: ../en/ch05-daily.xml:111
dongsheng@627 6599 msgid ""
dongsheng@627 6600 "Once you decide that a file no longer belongs in your repository, use the "
songdongsheng@710 6601 "<command role=\"hg-cmd\">hg remove</command> command. This deletes the file, "
dongsheng@714 6602 "and tells Mercurial to stop tracking it (which will occur at the next "
dongsheng@714 6603 "commit). A removed file is represented in the output of <command role=\"hg-"
dongsheng@714 6604 "cmd\">hg status</command> with a <quote><literal>R</literal></quote>."
dongsheng@714 6605 msgstr ""
dongsheng@714 6606
dongsheng@714 6607 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 6608 #: ../en/ch05-daily.xml:121
dongsheng@627 6609 msgid ""
dongsheng@627 6610 "After you <command role=\"hg-cmd\">hg remove</command> a file, Mercurial will "
dongsheng@627 6611 "no longer track changes to that file, even if you recreate a file with the "
dongsheng@627 6612 "same name in your working directory. If you do recreate a file with the same "
dongsheng@627 6613 "name and want Mercurial to track the new file, simply <command role=\"hg-cmd"
dongsheng@627 6614 "\">hg add</command> it. Mercurial will know that the newly added file is not "
dongsheng@627 6615 "related to the old file of the same name."
dongsheng@627 6616 msgstr ""
dongsheng@627 6617
dongsheng@627 6618 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 6619 #: ../en/ch05-daily.xml:130
dongsheng@627 6620 msgid "Removing a file does not affect its history"
dongsheng@627 6621 msgstr "删除文件不影响历史"
dongsheng@627 6622
dongsheng@627 6623 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6624 #: ../en/ch05-daily.xml:132
dongsheng@627 6625 msgid "It is important to understand that removing a file has only two effects."
dongsheng@627 6626 msgstr ""
dongsheng@627 6627
dongsheng@627 6628 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 6629 #: ../en/ch05-daily.xml:135
dongsheng@627 6630 msgid "It removes the current version of the file from the working directory."
dongsheng@627 6631 msgstr ""
dongsheng@627 6632
dongsheng@627 6633 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 6634 #: ../en/ch05-daily.xml:138
dongsheng@627 6635 msgid ""
dongsheng@627 6636 "It stops Mercurial from tracking changes to the file, from the time of the "
dongsheng@627 6637 "next commit."
dongsheng@627 6638 msgstr ""
dongsheng@627 6639
dongsheng@627 6640 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6641 #: ../en/ch05-daily.xml:141
dongsheng@627 6642 msgid ""
dongsheng@627 6643 "Removing a file <emphasis>does not</emphasis> in any way alter the "
dongsheng@627 6644 "<emphasis>history</emphasis> of the file."
dongsheng@627 6645 msgstr ""
dongsheng@627 6646
dongsheng@627 6647 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6648 #: ../en/ch05-daily.xml:144
dongsheng@627 6649 msgid ""
songdongsheng@710 6650 "If you update the working directory to a changeset that was committed when it "
songdongsheng@710 6651 "was still tracking a file that you later removed, the file will reappear in "
songdongsheng@710 6652 "the working directory, with the contents it had when you committed that "
songdongsheng@710 6653 "changeset. If you then update the working directory to a later changeset, in "
songdongsheng@710 6654 "which the file had been removed, Mercurial will once again remove the file "
songdongsheng@710 6655 "from the working directory."
songdongsheng@710 6656 msgstr ""
songdongsheng@710 6657
songdongsheng@710 6658 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 6659 #: ../en/ch05-daily.xml:155
dongsheng@627 6660 msgid "Missing files"
dongsheng@627 6661 msgstr "丢失的文件"
dongsheng@627 6662
dongsheng@627 6663 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6664 #: ../en/ch05-daily.xml:157
dongsheng@627 6665 msgid ""
dongsheng@627 6666 "Mercurial considers a file that you have deleted, but not used <command role="
dongsheng@627 6667 "\"hg-cmd\">hg remove</command> to delete, to be <emphasis>missing</"
dongsheng@627 6668 "emphasis>. A missing file is represented with <quote><literal>!</literal></"
dongsheng@627 6669 "quote> in the output of <command role=\"hg-cmd\">hg status</command>. "
dongsheng@627 6670 "Mercurial commands will not generally do anything with missing files."
dongsheng@627 6671 msgstr ""
dongsheng@627 6672
dongsheng@627 6673 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6674 #: ../en/ch05-daily.xml:167
dongsheng@627 6675 msgid ""
dongsheng@627 6676 "If your repository contains a file that <command role=\"hg-cmd\">hg status</"
dongsheng@627 6677 "command> reports as missing, and you want the file to stay gone, you can run "
dongsheng@627 6678 "<command role=\"hg-cmd\">hg remove <option role=\"hg-opt-remove\">--after</"
dongsheng@627 6679 "option></command> at any time later on, to tell Mercurial that you really did "
dongsheng@627 6680 "mean to remove the file."
dongsheng@627 6681 msgstr ""
dongsheng@627 6682
dongsheng@627 6683 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6684 #: ../en/ch05-daily.xml:177
dongsheng@627 6685 msgid ""
dongsheng@627 6686 "On the other hand, if you deleted the missing file by accident, give <command "
dongsheng@627 6687 "role=\"hg-cmd\">hg revert</command> the name of the file to recover. It will "
dongsheng@627 6688 "reappear, in unmodified form."
dongsheng@627 6689 msgstr ""
dongsheng@627 6690
dongsheng@627 6691 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 6692 #: ../en/ch05-daily.xml:186
dongsheng@627 6693 msgid "Aside: why tell Mercurial explicitly to remove a file?"
dongsheng@627 6694 msgstr "旁白: 为什么要明确告诉 Mercurial 删除文件?"
dongsheng@627 6695
dongsheng@627 6696 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6697 #: ../en/ch05-daily.xml:189
dongsheng@627 6698 msgid ""
dongsheng@627 6699 "You might wonder why Mercurial requires you to explicitly tell it that you "
dongsheng@627 6700 "are deleting a file. Early during the development of Mercurial, it let you "
dongsheng@627 6701 "delete a file however you pleased; Mercurial would notice the absence of the "
dongsheng@627 6702 "file automatically when you next ran a <command role=\"hg-cmd\">hg commit</"
dongsheng@627 6703 "command>, and stop tracking the file. In practice, this made it too easy to "
dongsheng@627 6704 "accidentally remove a file without noticing."
dongsheng@627 6705 msgstr ""
dongsheng@627 6706
dongsheng@627 6707 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 6708 #: ../en/ch05-daily.xml:200
songdongsheng@668 6709 msgid "Useful shorthand&emdash;adding and removing files in one step"
dongsheng@661 6710 msgstr "有用的速记—一个步骤添加和删除文件"
dongsheng@627 6711
dongsheng@627 6712 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6713 #: ../en/ch05-daily.xml:203
dongsheng@627 6714 msgid ""
dongsheng@627 6715 "Mercurial offers a combination command, <command role=\"hg-cmd\">hg "
dongsheng@627 6716 "addremove</command>, that adds untracked files and marks missing files as "
dongsheng@627 6717 "removed."
dongsheng@627 6718 msgstr ""
dongsheng@627 6719
dongsheng@627 6720 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6721 #: ../en/ch05-daily.xml:209
dongsheng@627 6722 msgid ""
dongsheng@627 6723 "The <command role=\"hg-cmd\">hg commit</command> command also provides a "
dongsheng@627 6724 "<option role=\"hg-opt-commit\">-A</option> option that performs this same add-"
dongsheng@627 6725 "and-remove, immediately followed by a commit."
dongsheng@627 6726 msgstr ""
dongsheng@627 6727
dongsheng@627 6728 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 6729 #: ../en/ch05-daily.xml:219
dongsheng@627 6730 msgid "Copying files"
dongsheng@627 6731 msgstr "复制文件"
dongsheng@627 6732
dongsheng@627 6733 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 6734 #: ../en/ch05-daily.xml:221
dongsheng@627 6735 msgid ""
dongsheng@627 6736 "Mercurial provides a <command role=\"hg-cmd\">hg copy</command> command that "
dongsheng@627 6737 "lets you make a new copy of a file. When you copy a file using this command, "
dongsheng@627 6738 "Mercurial makes a record of the fact that the new file is a copy of the "
dongsheng@627 6739 "original file. It treats these copied files specially when you merge your "
dongsheng@627 6740 "work with someone else's."
dongsheng@627 6741 msgstr ""
dongsheng@627 6742
dongsheng@627 6743 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 6744 #: ../en/ch05-daily.xml:229
dongsheng@627 6745 msgid "The results of copying during a merge"
dongsheng@627 6746 msgstr "合并期间的复制结果"
dongsheng@627 6747
dongsheng@627 6748 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6749 #: ../en/ch05-daily.xml:231
dongsheng@627 6750 msgid ""
dongsheng@627 6751 "What happens during a merge is that changes <quote>follow</quote> a copy. To "
dongsheng@627 6752 "best illustrate what this means, let's create an example. We'll start with "
dongsheng@627 6753 "the usual tiny repository that contains a single file."
dongsheng@627 6754 msgstr ""
dongsheng@627 6755
dongsheng@627 6756 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6757 #: ../en/ch05-daily.xml:238
dongsheng@627 6758 msgid ""
dongsheng@627 6759 "We need to do some work in parallel, so that we'll have something to merge. "
dongsheng@627 6760 "So let's clone our repository."
dongsheng@627 6761 msgstr ""
dongsheng@627 6762
dongsheng@627 6763 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6764 #: ../en/ch05-daily.xml:244
dongsheng@627 6765 msgid ""
dongsheng@627 6766 "Back in our initial repository, let's use the <command role=\"hg-cmd\">hg "
dongsheng@627 6767 "copy</command> command to make a copy of the first file we created."
dongsheng@627 6768 msgstr ""
dongsheng@627 6769
dongsheng@627 6770 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6771 #: ../en/ch05-daily.xml:250
dongsheng@627 6772 msgid ""
dongsheng@627 6773 "If we look at the output of the <command role=\"hg-cmd\">hg status</command> "
dongsheng@627 6774 "command afterwards, the copied file looks just like a normal added file."
dongsheng@627 6775 msgstr ""
dongsheng@627 6776
dongsheng@627 6777 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6778 #: ../en/ch05-daily.xml:256
dongsheng@627 6779 msgid ""
dongsheng@627 6780 "But if we pass the <option role=\"hg-opt-status\">-C</option> option to "
dongsheng@627 6781 "<command role=\"hg-cmd\">hg status</command>, it prints another line of "
dongsheng@627 6782 "output: this is the file that our newly-added file was copied <emphasis>from</"
dongsheng@627 6783 "emphasis>."
dongsheng@627 6784 msgstr ""
dongsheng@627 6785
dongsheng@627 6786 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6787 #: ../en/ch05-daily.xml:264
dongsheng@627 6788 msgid ""
dongsheng@627 6789 "Now, back in the repository we cloned, let's make a change in parallel. "
dongsheng@627 6790 "We'll add a line of content to the original file that we created."
dongsheng@627 6791 msgstr ""
dongsheng@627 6792
dongsheng@627 6793 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6794 #: ../en/ch05-daily.xml:270
dongsheng@627 6795 msgid ""
dongsheng@627 6796 "Now we have a modified <filename>file</filename> in this repository. When we "
dongsheng@627 6797 "pull the changes from the first repository, and merge the two heads, "
dongsheng@627 6798 "Mercurial will propagate the changes that we made locally to <filename>file</"
dongsheng@627 6799 "filename> into its copy, <filename>new-file</filename>."
dongsheng@627 6800 msgstr ""
dongsheng@627 6801
dongsheng@627 6802 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 6803 #: ../en/ch05-daily.xml:280
dongsheng@627 6804 msgid "Why should changes follow copies?"
dongsheng@627 6805 msgstr "为什么复制后需要后续修改?"
dongsheng@627 6806
dongsheng@627 6807 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6808 #: ../en/ch05-daily.xml:282
songdongsheng@710 6809 msgid ""
songdongsheng@710 6810 "This behavior&emdash;of changes to a file propagating out to copies of the "
songdongsheng@710 6811 "file&emdash;might seem esoteric, but in most cases it's highly desirable."
songdongsheng@710 6812 msgstr ""
songdongsheng@710 6813
songdongsheng@710 6814 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6815 #: ../en/ch05-daily.xml:286
dongsheng@627 6816 msgid ""
dongsheng@627 6817 "First of all, remember that this propagation <emphasis>only</emphasis> "
dongsheng@627 6818 "happens when you merge. So if you <command role=\"hg-cmd\">hg copy</command> "
dongsheng@627 6819 "a file, and subsequently modify the original file during the normal course of "
dongsheng@627 6820 "your work, nothing will happen."
dongsheng@627 6821 msgstr ""
dongsheng@627 6822
dongsheng@627 6823 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6824 #: ../en/ch05-daily.xml:292
dongsheng@627 6825 msgid ""
dongsheng@627 6826 "The second thing to know is that modifications will only propagate across a "
songdongsheng@710 6827 "copy as long as the changeset that you're merging changes from "
songdongsheng@710 6828 "<emphasis>hasn't yet seen</emphasis> the copy."
songdongsheng@710 6829 msgstr ""
songdongsheng@710 6830
songdongsheng@710 6831 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6832 #: ../en/ch05-daily.xml:297
dongsheng@627 6833 msgid ""
dongsheng@627 6834 "The reason that Mercurial does this is as follows. Let's say I make an "
dongsheng@627 6835 "important bug fix in a source file, and commit my changes. Meanwhile, you've "
dongsheng@627 6836 "decided to <command role=\"hg-cmd\">hg copy</command> the file in your "
dongsheng@627 6837 "repository, without knowing about the bug or having seen the fix, and you "
dongsheng@627 6838 "have started hacking on your copy of the file."
dongsheng@627 6839 msgstr ""
dongsheng@627 6840
dongsheng@627 6841 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6842 #: ../en/ch05-daily.xml:304
dongsheng@627 6843 msgid ""
dongsheng@627 6844 "If you pulled and merged my changes, and Mercurial <emphasis>didn't</"
songdongsheng@710 6845 "emphasis> propagate changes across copies, your new source file would now "
songdongsheng@710 6846 "contain the bug, and unless you knew to propagate the bug fix by hand, the "
songdongsheng@710 6847 "bug would <emphasis>remain</emphasis> in your copy of the file."
songdongsheng@710 6848 msgstr ""
songdongsheng@710 6849
songdongsheng@710 6850 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6851 #: ../en/ch05-daily.xml:310
dongsheng@627 6852 msgid ""
dongsheng@627 6853 "By automatically propagating the change that fixed the bug from the original "
dongsheng@627 6854 "file to the copy, Mercurial prevents this class of problem. To my knowledge, "
dongsheng@627 6855 "Mercurial is the <emphasis>only</emphasis> revision control system that "
dongsheng@627 6856 "propagates changes across copies like this."
dongsheng@627 6857 msgstr ""
dongsheng@627 6858
dongsheng@627 6859 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6860 #: ../en/ch05-daily.xml:316
dongsheng@627 6861 msgid ""
dongsheng@627 6862 "Once your change history has a record that the copy and subsequent merge "
dongsheng@627 6863 "occurred, there's usually no further need to propagate changes from the "
dongsheng@627 6864 "original file to the copied file, and that's why Mercurial only propagates "
songdongsheng@710 6865 "changes across copies at the first merge, and not afterwards."
songdongsheng@710 6866 msgstr ""
songdongsheng@710 6867
songdongsheng@710 6868 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 6869 #: ../en/ch05-daily.xml:324
dongsheng@627 6870 msgid "How to make changes <emphasis>not</emphasis> follow a copy"
dongsheng@627 6871 msgstr "如何让复制后<emphasis>不</emphasis>修改?"
dongsheng@627 6872
dongsheng@627 6873 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6874 #: ../en/ch05-daily.xml:327
dongsheng@627 6875 msgid ""
dongsheng@627 6876 "If, for some reason, you decide that this business of automatically "
dongsheng@627 6877 "propagating changes across copies is not for you, simply use your system's "
dongsheng@627 6878 "normal file copy command (on Unix-like systems, that's <command>cp</command>) "
dongsheng@627 6879 "to make a copy of a file, then <command role=\"hg-cmd\">hg add</command> the "
songdongsheng@658 6880 "new copy by hand. Before you do so, though, please do reread <xref linkend="
songdongsheng@710 6881 "\"sec:daily:why-copy\"/>, and make an informed decision that this behavior is "
songdongsheng@710 6882 "not appropriate to your specific case."
songdongsheng@710 6883 msgstr ""
songdongsheng@710 6884
songdongsheng@710 6885 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 6886 #: ../en/ch05-daily.xml:340
songdongsheng@710 6887 msgid "Behavior of the <command role=\"hg-cmd\">hg copy</command> command"
dongsheng@627 6888 msgstr "命令 <command role=\"hg-cmd\">hg copy</command> 的特性"
dongsheng@627 6889
dongsheng@627 6890 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6891 #: ../en/ch05-daily.xml:343
dongsheng@627 6892 msgid ""
dongsheng@627 6893 "When you use the <command role=\"hg-cmd\">hg copy</command> command, "
dongsheng@627 6894 "Mercurial makes a copy of each source file as it currently stands in the "
dongsheng@627 6895 "working directory. This means that if you make some modifications to a file, "
dongsheng@627 6896 "then <command role=\"hg-cmd\">hg copy</command> it without first having "
dongsheng@627 6897 "committed those changes, the new copy will also contain the modifications you "
songdongsheng@710 6898 "have made up until that point. (I find this behavior a little "
dongsheng@627 6899 "counterintuitive, which is why I mention it here.)"
dongsheng@627 6900 msgstr ""
dongsheng@627 6901
dongsheng@627 6902 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6903 #: ../en/ch05-daily.xml:353
dongsheng@627 6904 msgid ""
dongsheng@627 6905 "The <command role=\"hg-cmd\">hg copy</command> command acts similarly to the "
dongsheng@627 6906 "Unix <command>cp</command> command (you can use the <command role=\"hg-cmd"
songdongsheng@710 6907 "\">hg cp</command> alias if you prefer). We must supply two or more "
songdongsheng@710 6908 "arguments, of which the last is treated as the <emphasis>destination</"
songdongsheng@710 6909 "emphasis>, and all others are <emphasis>sources</emphasis>."
songdongsheng@710 6910 msgstr ""
songdongsheng@710 6911
songdongsheng@710 6912 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6913 #: ../en/ch05-daily.xml:361
songdongsheng@710 6914 msgid ""
songdongsheng@710 6915 "If you pass <command role=\"hg-cmd\">hg copy</command> a single file as the "
songdongsheng@710 6916 "source, and the destination does not exist, it creates a new file with that "
songdongsheng@710 6917 "name."
songdongsheng@710 6918 msgstr ""
songdongsheng@710 6919
songdongsheng@710 6920 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6921 #: ../en/ch05-daily.xml:367
dongsheng@627 6922 msgid ""
dongsheng@627 6923 "If the destination is a directory, Mercurial copies its sources into that "
dongsheng@627 6924 "directory."
dongsheng@627 6925 msgstr ""
dongsheng@627 6926
dongsheng@627 6927 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6928 #: ../en/ch05-daily.xml:372
dongsheng@627 6929 msgid ""
dongsheng@627 6930 "Copying a directory is recursive, and preserves the directory structure of "
dongsheng@627 6931 "the source."
dongsheng@627 6932 msgstr ""
dongsheng@627 6933
dongsheng@627 6934 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6935 #: ../en/ch05-daily.xml:378
dongsheng@627 6936 msgid ""
dongsheng@627 6937 "If the source and destination are both directories, the source tree is "
dongsheng@627 6938 "recreated in the destination directory."
dongsheng@627 6939 msgstr ""
dongsheng@627 6940
songdongsheng@710 6941 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 6942 #: ../en/ch05-daily.xml:383
songdongsheng@710 6943 msgid ""
songdongsheng@710 6944 "As with the <command role=\"hg-cmd\">hg remove</command> command, if you copy "
dongsheng@627 6945 "a file manually and then want Mercurial to know that you've copied the file, "
dongsheng@627 6946 "simply use the <option role=\"hg-opt-copy\">--after</option> option to "
dongsheng@627 6947 "<command role=\"hg-cmd\">hg copy</command>."
dongsheng@627 6948 msgstr ""
dongsheng@627 6949
dongsheng@627 6950 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 6951 #: ../en/ch05-daily.xml:394
dongsheng@627 6952 msgid "Renaming files"
dongsheng@627 6953 msgstr "改名文件"
dongsheng@627 6954
dongsheng@627 6955 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 6956 #: ../en/ch05-daily.xml:396
dongsheng@627 6957 msgid ""
dongsheng@627 6958 "It's rather more common to need to rename a file than to make a copy of it. "
dongsheng@627 6959 "The reason I discussed the <command role=\"hg-cmd\">hg copy</command> command "
dongsheng@627 6960 "before talking about renaming files is that Mercurial treats a rename in "
dongsheng@627 6961 "essentially the same way as a copy. Therefore, knowing what Mercurial does "
dongsheng@627 6962 "when you copy a file tells you what to expect when you rename a file."
dongsheng@627 6963 msgstr ""
dongsheng@627 6964
dongsheng@627 6965 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 6966 #: ../en/ch05-daily.xml:404
dongsheng@627 6967 msgid ""
dongsheng@627 6968 "When you use the <command role=\"hg-cmd\">hg rename</command> command, "
dongsheng@627 6969 "Mercurial makes a copy of each source file, then deletes it and marks the "
dongsheng@627 6970 "file as removed."
dongsheng@627 6971 msgstr ""
dongsheng@627 6972
dongsheng@627 6973 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 6974 #: ../en/ch05-daily.xml:410
dongsheng@627 6975 msgid ""
dongsheng@627 6976 "The <command role=\"hg-cmd\">hg status</command> command shows the newly "
dongsheng@627 6977 "copied file as added, and the copied-from file as removed."
dongsheng@627 6978 msgstr ""
dongsheng@627 6979
dongsheng@627 6980 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 6981 #: ../en/ch05-daily.xml:416
dongsheng@627 6982 msgid ""
dongsheng@627 6983 "As with the results of a <command role=\"hg-cmd\">hg copy</command>, we must "
dongsheng@627 6984 "use the <option role=\"hg-opt-status\">-C</option> option to <command role="
dongsheng@627 6985 "\"hg-cmd\">hg status</command> to see that the added file is really being "
dongsheng@627 6986 "tracked by Mercurial as a copy of the original, now removed, file."
dongsheng@627 6987 msgstr ""
dongsheng@627 6988
dongsheng@627 6989 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 6990 #: ../en/ch05-daily.xml:425
dongsheng@627 6991 msgid ""
dongsheng@627 6992 "As with <command role=\"hg-cmd\">hg remove</command> and <command role=\"hg-"
dongsheng@627 6993 "cmd\">hg copy</command>, you can tell Mercurial about a rename after the fact "
dongsheng@627 6994 "using the <option role=\"hg-opt-rename\">--after</option> option. In most "
songdongsheng@710 6995 "other respects, the behavior of the <command role=\"hg-cmd\">hg rename</"
dongsheng@627 6996 "command> command, and the options it accepts, are similar to the <command "
dongsheng@627 6997 "role=\"hg-cmd\">hg copy</command> command."
dongsheng@627 6998 msgstr ""
dongsheng@627 6999
songdongsheng@710 7000 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 7001 #: ../en/ch05-daily.xml:434
songdongsheng@710 7002 msgid ""
songdongsheng@710 7003 "If you're familiar with the Unix command line, you'll be glad to know that "
songdongsheng@710 7004 "<command role=\"hg-cmd\">hg rename</command> command can be invoked as "
songdongsheng@710 7005 "<command role=\"hg-cmd\">hg mv</command>."
songdongsheng@710 7006 msgstr ""
songdongsheng@710 7007
songdongsheng@710 7008 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 7009 #: ../en/ch05-daily.xml:440
dongsheng@627 7010 msgid "Renaming files and merging changes"
dongsheng@627 7011 msgstr "改名文件与合并修改"
dongsheng@627 7012
dongsheng@627 7013 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 7014 #: ../en/ch05-daily.xml:442
dongsheng@627 7015 msgid ""
dongsheng@627 7016 "Since Mercurial's rename is implemented as copy-and-remove, the same "
dongsheng@627 7017 "propagation of changes happens when you merge after a rename as after a copy."
dongsheng@627 7018 msgstr ""
dongsheng@627 7019
dongsheng@627 7020 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 7021 #: ../en/ch05-daily.xml:446
dongsheng@627 7022 msgid ""
dongsheng@627 7023 "If I modify a file, and you rename it to a new name, and then we merge our "
dongsheng@627 7024 "respective changes, my modifications to the file under its original name will "
dongsheng@627 7025 "be propagated into the file under its new name. (This is something you might "
dongsheng@627 7026 "expect to <quote>simply work,</quote> but not all revision control systems "
dongsheng@627 7027 "actually do this.)"
dongsheng@627 7028 msgstr ""
dongsheng@627 7029
dongsheng@627 7030 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 7031 #: ../en/ch05-daily.xml:453
dongsheng@627 7032 msgid ""
dongsheng@627 7033 "Whereas having changes follow a copy is a feature where you can perhaps nod "
dongsheng@627 7034 "and say <quote>yes, that might be useful,</quote> it should be clear that "
dongsheng@627 7035 "having them follow a rename is definitely important. Without this facility, "
dongsheng@627 7036 "it would simply be too easy for changes to become orphaned when files are "
dongsheng@627 7037 "renamed."
dongsheng@627 7038 msgstr ""
dongsheng@627 7039
dongsheng@627 7040 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 7041 #: ../en/ch05-daily.xml:462
dongsheng@627 7042 msgid "Divergent renames and merging"
dongsheng@627 7043 msgstr "改名与合并的分歧"
dongsheng@627 7044
dongsheng@627 7045 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 7046 #: ../en/ch05-daily.xml:464
dongsheng@627 7047 msgid ""
songdongsheng@668 7048 "The case of diverging names occurs when two developers start with a "
songdongsheng@668 7049 "file&emdash;let's call it <filename>foo</filename>&emdash;in their respective "
dongsheng@627 7050 "repositories."
dongsheng@627 7051 msgstr ""
dongsheng@627 7052
dongsheng@627 7053 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 7054 #: ../en/ch05-daily.xml:471
dongsheng@627 7055 msgid "Anne renames the file to <filename>bar</filename>."
dongsheng@627 7056 msgstr ""
dongsheng@627 7057
dongsheng@627 7058 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 7059 #: ../en/ch05-daily.xml:475
songdongsheng@710 7060 msgid ""
songdongsheng@710 7061 "Meanwhile, Bob renames it to <filename>quux</filename>. (Remember that "
songdongsheng@710 7062 "<command role=\"hg-cmd\">hg mv</command> is an alias for <command role=\"hg-"
songdongsheng@710 7063 "cmd\">hg rename</command>.)"
songdongsheng@710 7064 msgstr ""
songdongsheng@710 7065
songdongsheng@710 7066 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 7067 #: ../en/ch05-daily.xml:482
dongsheng@627 7068 msgid ""
dongsheng@627 7069 "I like to think of this as a conflict because each developer has expressed "
dongsheng@627 7070 "different intentions about what the file ought to be named."
dongsheng@627 7071 msgstr ""
dongsheng@627 7072
songdongsheng@710 7073 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 7074 #: ../en/ch05-daily.xml:486
dongsheng@627 7075 msgid ""
dongsheng@627 7076 "What do you think should happen when they merge their work? Mercurial's "
songdongsheng@710 7077 "actual behavior is that it always preserves <emphasis>both</emphasis> names "
dongsheng@627 7078 "when it merges changesets that contain divergent renames."
dongsheng@627 7079 msgstr ""
dongsheng@627 7080
dongsheng@627 7081 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 7082 #: ../en/ch05-daily.xml:493
songdongsheng@710 7083 msgid ""
songdongsheng@710 7084 "Notice that while Mercurial warns about the divergent renames, it leaves it "
dongsheng@627 7085 "up to you to do something about the divergence after the merge."
dongsheng@627 7086 msgstr ""
dongsheng@627 7087
dongsheng@627 7088 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 7089 #: ../en/ch05-daily.xml:499
dongsheng@627 7090 msgid "Convergent renames and merging"
dongsheng@627 7091 msgstr "收敛改名与合并"
dongsheng@627 7092
dongsheng@627 7093 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 7094 #: ../en/ch05-daily.xml:501
dongsheng@627 7095 msgid ""
dongsheng@627 7096 "Another kind of rename conflict occurs when two people choose to rename "
dongsheng@627 7097 "different <emphasis>source</emphasis> files to the same "
dongsheng@627 7098 "<emphasis>destination</emphasis>. In this case, Mercurial runs its normal "
dongsheng@627 7099 "merge machinery, and lets you guide it to a suitable resolution."
dongsheng@627 7100 msgstr ""
dongsheng@627 7101
dongsheng@627 7102 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 7103 #: ../en/ch05-daily.xml:509
dongsheng@627 7104 msgid "Other name-related corner cases"
dongsheng@627 7105 msgstr "其它名称相关的角落"
dongsheng@627 7106
dongsheng@627 7107 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 7108 #: ../en/ch05-daily.xml:511
dongsheng@627 7109 msgid ""
dongsheng@627 7110 "Mercurial has a longstanding bug in which it fails to handle a merge where "
dongsheng@627 7111 "one side has a file with a given name, while another has a directory with the "
dongsheng@627 7112 "same name. This is documented as <ulink role=\"hg-bug\" url=\"http://www."
dongsheng@627 7113 "selenic.com/mercurial/bts/issue29\">issue 29</ulink>."
dongsheng@627 7114 msgstr ""
dongsheng@627 7115
dongsheng@627 7116 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 7117 #: ../en/ch05-daily.xml:524
dongsheng@627 7118 msgid "Recovering from mistakes"
dongsheng@627 7119 msgstr "从错误恢复"
dongsheng@627 7120
dongsheng@627 7121 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 7122 #: ../en/ch05-daily.xml:526
dongsheng@627 7123 msgid ""
dongsheng@627 7124 "Mercurial has some useful commands that will help you to recover from some "
dongsheng@627 7125 "common mistakes."
dongsheng@627 7126 msgstr ""
dongsheng@627 7127
dongsheng@627 7128 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 7129 #: ../en/ch05-daily.xml:529
dongsheng@627 7130 msgid ""
dongsheng@627 7131 "The <command role=\"hg-cmd\">hg revert</command> command lets you undo "
dongsheng@627 7132 "changes that you have made to your working directory. For example, if you "
dongsheng@627 7133 "<command role=\"hg-cmd\">hg add</command> a file by accident, just run "
dongsheng@627 7134 "<command role=\"hg-cmd\">hg revert</command> with the name of the file you "
dongsheng@627 7135 "added, and while the file won't be touched in any way, it won't be tracked "
dongsheng@627 7136 "for adding by Mercurial any longer, either. You can also use <command role="
dongsheng@627 7137 "\"hg-cmd\">hg revert</command> to get rid of erroneous changes to a file."
dongsheng@627 7138 msgstr ""
dongsheng@627 7139
dongsheng@627 7140 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 7141 #: ../en/ch05-daily.xml:539
dongsheng@714 7142 msgid ""
dongsheng@714 7143 "It is helpful to remember that the <command role=\"hg-cmd\">hg revert</"
dongsheng@714 7144 "command> command is useful for changes that you have not yet committed. Once "
dongsheng@714 7145 "you've committed a change, if you decide it was a mistake, you can still do "
dongsheng@627 7146 "something about it, though your options may be more limited."
dongsheng@627 7147 msgstr ""
dongsheng@627 7148
dongsheng@627 7149 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 7150 #: ../en/ch05-daily.xml:546
dongsheng@627 7151 msgid ""
dongsheng@627 7152 "For more information about the <command role=\"hg-cmd\">hg revert</command> "
dongsheng@627 7153 "command, and details about how to deal with changes you have already "
songdongsheng@658 7154 "committed, see <xref linkend=\"chap:undo\"/>."
dongsheng@627 7155 msgstr ""
dongsheng@627 7156
songdongsheng@710 7157 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 7158 #: ../en/ch05-daily.xml:553
songdongsheng@710 7159 msgid "Dealing with tricky merges"
songdongsheng@711 7160 msgstr "合并的技巧"
songdongsheng@710 7161
songdongsheng@710 7162 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 7163 #: ../en/ch05-daily.xml:555
songdongsheng@710 7164 msgid ""
songdongsheng@710 7165 "In a complicated or large project, it's not unusual for a merge of two "
songdongsheng@710 7166 "changesets to result in some headaches. Suppose there's a big source file "
songdongsheng@710 7167 "that's been extensively edited by each side of a merge: this is almost "
songdongsheng@710 7168 "inevitably going to result in conflicts, some of which can take a few tries "
songdongsheng@710 7169 "to sort out."
songdongsheng@710 7170 msgstr ""
songdongsheng@710 7171
songdongsheng@710 7172 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 7173 #: ../en/ch05-daily.xml:562
songdongsheng@710 7174 msgid ""
songdongsheng@710 7175 "Let's develop a simple case of this and see how to deal with it. We'll start "
songdongsheng@710 7176 "off with a repository containing one file, and clone it twice."
songdongsheng@710 7177 msgstr ""
songdongsheng@710 7178
songdongsheng@710 7179 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 7180 #: ../en/ch05-daily.xml:568
songdongsheng@710 7181 msgid "In one clone, we'll modify the file in one way."
songdongsheng@710 7182 msgstr ""
songdongsheng@710 7183
songdongsheng@710 7184 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 7185 #: ../en/ch05-daily.xml:572
songdongsheng@710 7186 msgid "In another, we'll modify the file differently."
songdongsheng@710 7187 msgstr ""
songdongsheng@710 7188
songdongsheng@710 7189 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 7190 #: ../en/ch05-daily.xml:576
songdongsheng@710 7191 msgid "Next, we'll pull each set of changes into our original repo."
songdongsheng@710 7192 msgstr ""
songdongsheng@710 7193
songdongsheng@710 7194 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 7195 #: ../en/ch05-daily.xml:581
songdongsheng@710 7196 msgid "We expect our repository to now contain two heads."
songdongsheng@710 7197 msgstr ""
songdongsheng@710 7198
songdongsheng@710 7199 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 7200 #: ../en/ch05-daily.xml:585
songdongsheng@710 7201 msgid ""
songdongsheng@710 7202 "Normally, if we run <command role=\"hg-cmd\">hg merge</command> at this "
songdongsheng@710 7203 "point, it will drop us into a GUI that will let us manually resolve the "
songdongsheng@710 7204 "conflicting edits to <filename>myfile.txt</filename>. However, to simplify "
songdongsheng@710 7205 "things for presentation here, we'd like the merge to fail immediately "
songdongsheng@710 7206 "instead. Here's one way we can do so."
songdongsheng@710 7207 msgstr ""
songdongsheng@710 7208
songdongsheng@710 7209 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 7210 #: ../en/ch05-daily.xml:594
songdongsheng@710 7211 msgid ""
songdongsheng@710 7212 "We've told Mercurial's merge machinery to run the command <command>false</"
songdongsheng@710 7213 "command> (which, as we desire, fails immediately) if it detects a merge that "
songdongsheng@710 7214 "it can't sort out automatically."
songdongsheng@710 7215 msgstr ""
songdongsheng@710 7216
songdongsheng@710 7217 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 7218 #: ../en/ch05-daily.xml:599
songdongsheng@710 7219 msgid ""
songdongsheng@710 7220 "If we now fire up <command role=\"hg-cmd\">hg merge</command>, it should "
songdongsheng@710 7221 "grind to a halt and report a failure."
songdongsheng@710 7222 msgstr ""
songdongsheng@710 7223
songdongsheng@710 7224 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 7225 #: ../en/ch05-daily.xml:605
songdongsheng@710 7226 msgid ""
songdongsheng@710 7227 "Even if we don't notice that the merge failed, Mercurial will prevent us from "
songdongsheng@710 7228 "accidentally committing the result of a failed merge."
songdongsheng@710 7229 msgstr ""
songdongsheng@710 7230
songdongsheng@710 7231 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 7232 #: ../en/ch05-daily.xml:611
songdongsheng@710 7233 msgid ""
songdongsheng@710 7234 "When <command role=\"hg-cmd\">hg commit</command> fails in this case, it "
songdongsheng@710 7235 "suggests that we use the unfamiliar <command role=\"hg-cmd\">hg resolve</"
songdongsheng@710 7236 "command> command. As usual, <command role=\"hg-cmd\">hg help resolve</"
songdongsheng@710 7237 "command> will print a helpful synopsis."
songdongsheng@710 7238 msgstr ""
songdongsheng@710 7239
songdongsheng@710 7240 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 7241 #: ../en/ch05-daily.xml:618
songdongsheng@710 7242 msgid "File resolution states"
dongsheng@716 7243 msgstr "文件的解决状态"
songdongsheng@710 7244
songdongsheng@710 7245 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 7246 #: ../en/ch05-daily.xml:620
songdongsheng@710 7247 msgid ""
songdongsheng@710 7248 "When a merge occurs, most files will usually remain unmodified. For each "
songdongsheng@710 7249 "file where Mercurial has to do something, it tracks the state of the file."
songdongsheng@710 7250 msgstr ""
songdongsheng@710 7251
songdongsheng@710 7252 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 7253 #: ../en/ch05-daily.xml:626
songdongsheng@710 7254 msgid ""
songdongsheng@710 7255 "A <emphasis>resolved</emphasis> file has been successfully merged, either "
songdongsheng@710 7256 "automatically by Mercurial or manually with human intervention."
songdongsheng@710 7257 msgstr ""
songdongsheng@710 7258
songdongsheng@710 7259 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 7260 #: ../en/ch05-daily.xml:631
songdongsheng@710 7261 msgid ""
songdongsheng@710 7262 "An <emphasis>unresolved</emphasis> file was not merged successfully, and "
songdongsheng@710 7263 "needs more attention."
songdongsheng@710 7264 msgstr ""
songdongsheng@710 7265
songdongsheng@710 7266 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 7267 #: ../en/ch05-daily.xml:636
songdongsheng@710 7268 msgid ""
songdongsheng@710 7269 "If Mercurial sees <emphasis>any</emphasis> file in the unresolved state after "
songdongsheng@710 7270 "a merge, it considers the merge to have failed. Fortunately, we do not need "
songdongsheng@710 7271 "to restart the entire merge from scratch."
songdongsheng@710 7272 msgstr ""
songdongsheng@710 7273
songdongsheng@710 7274 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 7275 #: ../en/ch05-daily.xml:641
songdongsheng@710 7276 msgid ""
songdongsheng@710 7277 "The <option role=\"hg-opt-resolve\">--list</option> or <option role=\"hg-opt-"
songdongsheng@710 7278 "resolve\">-l</option> option to <command role=\"hg-cmd\">hg resolve</command> "
songdongsheng@710 7279 "prints out the state of each merged file."
songdongsheng@710 7280 msgstr ""
songdongsheng@710 7281
songdongsheng@710 7282 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 7283 #: ../en/ch05-daily.xml:648
songdongsheng@710 7284 msgid ""
songdongsheng@710 7285 "In the output from <command role=\"hg-cmd\">hg resolve</command>, a resolved "
songdongsheng@710 7286 "file is marked with <literal>R</literal>, while an unresolved file is marked "
songdongsheng@710 7287 "with <literal>U</literal>. If any files are listed with <literal>U</"
songdongsheng@710 7288 "literal>, we know that an attempt to commit the results of the merge will "
songdongsheng@710 7289 "fail."
songdongsheng@710 7290 msgstr ""
songdongsheng@710 7291
songdongsheng@710 7292 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 7293 #: ../en/ch05-daily.xml:657
songdongsheng@710 7294 msgid "Resolving a file merge"
songdongsheng@711 7295 msgstr "合并文件"
songdongsheng@710 7296
songdongsheng@710 7297 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 7298 #: ../en/ch05-daily.xml:659
songdongsheng@710 7299 msgid ""
songdongsheng@710 7300 "We have several options to move a file from the unresolved into the resolved "
songdongsheng@710 7301 "state. By far the most common is to rerun <command role=\"hg-cmd\">hg "
songdongsheng@710 7302 "resolve</command>. If we pass the names of individual files or directories, "
songdongsheng@710 7303 "it will retry the merges of any unresolved files present in those locations. "
songdongsheng@710 7304 "We can also pass the <option role=\"hg-opt-resolve\">--all</option> or "
songdongsheng@710 7305 "<option role=\"hg-opt-resolve\">-a</option> option, which will retry the "
songdongsheng@710 7306 "merges of <emphasis>all</emphasis> unresolved files."
songdongsheng@710 7307 msgstr ""
songdongsheng@710 7308
songdongsheng@710 7309 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 7310 #: ../en/ch05-daily.xml:669
songdongsheng@710 7311 msgid ""
songdongsheng@710 7312 "Mercurial also lets us modify the resolution state of a file directly. We "
songdongsheng@710 7313 "can manually mark a file as resolved using the <option role=\"hg-opt-resolve"
songdongsheng@710 7314 "\">--mark</option> option, or as unresolved using the <option role=\"hg-opt-"
songdongsheng@710 7315 "resolve\">--unmark</option> option. This allows us to clean up a "
songdongsheng@710 7316 "particularly messy merge by hand, and to keep track of our progress with each "
songdongsheng@710 7317 "file as we go."
songdongsheng@710 7318 msgstr ""
songdongsheng@710 7319
dongsheng@714 7320 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 7321 #: ../en/ch05-daily.xml:680
dongsheng@714 7322 msgid "More useful diffs"
dongsheng@716 7323 msgstr "更有用的差异"
dongsheng@714 7324
dongsheng@714 7325 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 7326 #: ../en/ch05-daily.xml:682
dongsheng@714 7327 msgid ""
dongsheng@714 7328 "The default output of the <command role=\"hg-cmd\">hg diff</command> command "
dongsheng@714 7329 "is backwards compatible with the regular <command>diff</command> command, but "
dongsheng@714 7330 "this has some drawbacks."
dongsheng@714 7331 msgstr ""
dongsheng@714 7332
dongsheng@714 7333 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 7334 #: ../en/ch05-daily.xml:687
dongsheng@714 7335 msgid ""
dongsheng@714 7336 "Consider the case where we use <command role=\"hg-cmd\">hg rename</command> "
dongsheng@714 7337 "to rename a file."
dongsheng@715 7338 msgstr ""
dongsheng@715 7339 "设想我们使用 <command role=\"hg-cmd\">hg rename</command> 命令来改名文件。"
dongsheng@714 7340
dongsheng@714 7341 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 7342 #: ../en/ch05-daily.xml:692
dongsheng@714 7343 msgid ""
dongsheng@714 7344 "The output of <command role=\"hg-cmd\">hg diff</command> above obscures the "
dongsheng@714 7345 "fact that we simply renamed a file. The <command role=\"hg-cmd\">hg diff</"
dongsheng@714 7346 "command> command accepts an option, <option>--git</option> or <option>-g</"
dongsheng@714 7347 "option>, to use a newer diff format that displays such information in a more "
dongsheng@714 7348 "readable form."
dongsheng@714 7349 msgstr ""
dongsheng@714 7350
dongsheng@714 7351 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 7352 #: ../en/ch05-daily.xml:701
dongsheng@714 7353 msgid ""
dongsheng@714 7354 "This option also helps with a case that can otherwise be confusing: a file "
dongsheng@714 7355 "that appears to be modified according to <command role=\"hg-cmd\">hg status</"
dongsheng@714 7356 "command>, but for which <command role=\"hg-cmd\">hg diff</command> prints "
dongsheng@714 7357 "nothing. This situation can arise if we change the file's execute permissions."
dongsheng@714 7358 msgstr ""
dongsheng@714 7359
dongsheng@714 7360 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 7361 #: ../en/ch05-daily.xml:710
dongsheng@714 7362 msgid ""
dongsheng@714 7363 "The normal <command>diff</command> command pays no attention to file "
dongsheng@714 7364 "permissions, which is why <command role=\"hg-cmd\">hg diff</command> prints "
dongsheng@714 7365 "nothing by default. If we supply it with the <option>-g</option> option, it "
dongsheng@714 7366 "tells us what really happened."
dongsheng@714 7367 msgstr ""
dongsheng@714 7368
dongsheng@714 7369 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 7370 #: ../en/ch05-daily.xml:720
dongsheng@714 7371 msgid "Which files to manage, and which to avoid"
dongsheng@716 7372 msgstr "需要管理哪些文件,应该避免的事情"
dongsheng@714 7373
dongsheng@714 7374 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 7375 #: ../en/ch05-daily.xml:722
dongsheng@714 7376 msgid ""
dongsheng@714 7377 "Revision control systems are generally best at managing text files that are "
dongsheng@714 7378 "written by humans, such as source code, where the files do not change much "
dongsheng@714 7379 "from one revision to the next. Some centralized revision control systems can "
dongsheng@714 7380 "also deal tolerably well with binary files, such as bitmap images."
dongsheng@714 7381 msgstr ""
dongsheng@714 7382
dongsheng@714 7383 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 7384 #: ../en/ch05-daily.xml:728
dongsheng@714 7385 msgid ""
dongsheng@714 7386 "For instance, a game development team will typically manage both its source "
dongsheng@714 7387 "code and all of its binary assets (e.g. geometry data, textures, map layouts) "
dongsheng@714 7388 "in a revision control system."
dongsheng@714 7389 msgstr ""
dongsheng@714 7390
dongsheng@714 7391 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 7392 #: ../en/ch05-daily.xml:733
dongsheng@714 7393 msgid ""
dongsheng@714 7394 "Because it is usually impossible to merge two conflicting modifications to a "
dongsheng@714 7395 "binary file, centralized systems often provide a file locking mechanism that "
dongsheng@714 7396 "allow a user to say <quote>I am the only person who can edit this file</"
dongsheng@714 7397 "quote>."
dongsheng@714 7398 msgstr ""
dongsheng@714 7399
dongsheng@714 7400 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 7401 #: ../en/ch05-daily.xml:739
dongsheng@714 7402 msgid ""
dongsheng@714 7403 "Compared to a centralized system, a distributed revision control system "
dongsheng@714 7404 "changes some of the factors that guide decisions over which files to manage "
dongsheng@714 7405 "and how."
dongsheng@714 7406 msgstr ""
dongsheng@714 7407
dongsheng@714 7408 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 7409 #: ../en/ch05-daily.xml:743
dongsheng@714 7410 msgid ""
dongsheng@714 7411 "For instance, a distributed revision control system cannot, by its nature, "
dongsheng@714 7412 "offer a file locking facility. There is thus no built-in mechanism to "
dongsheng@714 7413 "prevent two people from making conflicting changes to a binary file. If you "
dongsheng@714 7414 "have a team where several people may be editing binary files frequently, it "
dongsheng@714 7415 "may not be a good idea to use Mercurial&emdash;or any other distributed "
dongsheng@714 7416 "revision control system&emdash;to manage those files."
dongsheng@714 7417 msgstr ""
dongsheng@714 7418
dongsheng@714 7419 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 7420 #: ../en/ch05-daily.xml:751
dongsheng@714 7421 msgid ""
dongsheng@714 7422 "When storing modifications to a file, Mercurial usually saves only the "
dongsheng@714 7423 "differences between the previous and current versions of the file. For most "
dongsheng@714 7424 "text files, this is extremely efficient. However, some files (particularly "
dongsheng@714 7425 "binary files) are laid out in such a way that even a small change to a file's "
dongsheng@714 7426 "logical content results in many or most of the bytes inside the file "
dongsheng@714 7427 "changing. For instance, compressed files are particularly susceptible to "
dongsheng@714 7428 "this. If the differences between each successive version of a file are always "
dongsheng@714 7429 "large, Mercurial will not be able to store the file's revision history very "
dongsheng@714 7430 "efficiently. This can affect both local storage needs and the amount of time "
dongsheng@714 7431 "it takes to clone a repository."
dongsheng@714 7432 msgstr ""
dongsheng@714 7433
dongsheng@714 7434 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 7435 #: ../en/ch05-daily.xml:764
dongsheng@714 7436 msgid ""
dongsheng@714 7437 "To get an idea of how this could affect you in practice, suppose you want to "
dongsheng@714 7438 "use Mercurial to manage an OpenOffice document. OpenOffice stores documents "
dongsheng@714 7439 "on disk as compressed zip files. Edit even a single letter of your document "
dongsheng@714 7440 "in OpenOffice, and almost every byte in the entire file will change when you "
dongsheng@714 7441 "save it. Now suppose that file is 2MB in size. Because most of the file "
dongsheng@714 7442 "changes every time you save, Mercurial will have to store all 2MB of the file "
dongsheng@714 7443 "every time you commit, even though from your perspective, perhaps only a few "
dongsheng@714 7444 "words are changing each time. A single frequently-edited file that is not "
dongsheng@714 7445 "friendly to Mercurial's storage assumptions can easily have an outsized "
dongsheng@714 7446 "effect on the size of the repository."
dongsheng@714 7447 msgstr ""
dongsheng@714 7448
dongsheng@714 7449 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 7450 #: ../en/ch05-daily.xml:777
dongsheng@714 7451 msgid ""
dongsheng@714 7452 "Even worse, if both you and someone else edit the OpenOffice document you're "
dongsheng@714 7453 "working on, there is no useful way to merge your work. In fact, there isn't "
dongsheng@714 7454 "even a good way to tell what the differences are between your respective "
dongsheng@714 7455 "changes."
dongsheng@714 7456 msgstr ""
dongsheng@714 7457
dongsheng@714 7458 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 7459 #: ../en/ch05-daily.xml:782
dongsheng@714 7460 msgid ""
dongsheng@714 7461 "There are thus a few clear recommendations about specific kinds of files to "
dongsheng@714 7462 "be very careful with."
dongsheng@714 7463 msgstr ""
dongsheng@714 7464
dongsheng@714 7465 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 7466 #: ../en/ch05-daily.xml:787
dongsheng@714 7467 msgid ""
dongsheng@714 7468 "Files that are very large and incompressible, e.g. ISO CD-ROM images, will by "
dongsheng@714 7469 "virtue of sheer size make clones over a network very slow."
dongsheng@714 7470 msgstr ""
dongsheng@714 7471
dongsheng@714 7472 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 7473 #: ../en/ch05-daily.xml:792
dongsheng@714 7474 msgid ""
dongsheng@714 7475 "Files that change a lot from one revision to the next may be expensive to "
dongsheng@714 7476 "store if you edit them frequently, and conflicts due to concurrent edits may "
dongsheng@714 7477 "be difficult to resolve."
dongsheng@714 7478 msgstr ""
dongsheng@714 7479
dongsheng@714 7480 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 7481 #: ../en/ch05-daily.xml:801
dongsheng@714 7482 msgid "Backups and mirroring"
dongsheng@715 7483 msgstr "备份与镜像"
dongsheng@714 7484
dongsheng@714 7485 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 7486 #: ../en/ch05-daily.xml:803
dongsheng@714 7487 msgid ""
dongsheng@714 7488 "Since Mercurial maintains a complete copy of history in each clone, everyone "
dongsheng@714 7489 "who uses Mercurial to collaborate on a project can potentially act as a "
dongsheng@714 7490 "source of backups in the event of a catastrophe. If a central repository "
dongsheng@714 7491 "becomes unavailable, you can construct a replacement simply by cloning a copy "
dongsheng@714 7492 "of the repository from one contributor, and pulling any changes they may not "
dongsheng@714 7493 "have seen from others."
dongsheng@714 7494 msgstr ""
dongsheng@714 7495
dongsheng@714 7496 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 7497 #: ../en/ch05-daily.xml:811
dongsheng@714 7498 msgid ""
dongsheng@714 7499 "It is simple to use Mercurial to perform off-site backups and remote "
dongsheng@714 7500 "mirrors. Set up a periodic job (e.g. via the <command>cron</command> "
dongsheng@714 7501 "command) on a remote server to pull changes from your master repositories "
dongsheng@714 7502 "every hour. This will only be tricky in the unlikely case that the number of "
dongsheng@714 7503 "master repositories you maintain changes frequently, in which case you'll "
dongsheng@714 7504 "need to do a little scripting to refresh the list of repositories to back up."
dongsheng@714 7505 msgstr ""
dongsheng@714 7506
dongsheng@714 7507 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 7508 #: ../en/ch05-daily.xml:820
dongsheng@714 7509 msgid ""
dongsheng@714 7510 "If you perform traditional backups of your master repositories to tape or "
dongsheng@714 7511 "disk, and you want to back up a repository named <filename>myrepo</filename>, "
dongsheng@714 7512 "use <command>hg clone -U myrepo myrepo.bak</command> to create a clone of "
dongsheng@714 7513 "<filename>myrepo</filename> before you start your backups. The <option>-U</"
dongsheng@714 7514 "option> option doesn't check out a working directory after the clone "
dongsheng@714 7515 "completes, since that would be superfluous and make the backup take longer."
dongsheng@714 7516 msgstr ""
dongsheng@714 7517
dongsheng@714 7518 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 7519 #: ../en/ch05-daily.xml:829
dongsheng@714 7520 msgid ""
dongsheng@714 7521 "If you then back up <filename>myrepo.bak</filename> instead of "
dongsheng@714 7522 "<filename>myrepo</filename>, you will be guaranteed to have a consistent "
dongsheng@714 7523 "snapshot of your repository that won't be pushed to by an insomniac developer "
dongsheng@714 7524 "in mid-backup."
dongsheng@714 7525 msgstr ""
dongsheng@714 7526
dongsheng@627 7527 #. type: Content of: <book><chapter><title>
dongsheng@714 7528 #: ../en/ch06-collab.xml:5
dongsheng@627 7529 msgid "Collaborating with other people"
dongsheng@627 7530 msgstr "团体协作"
dongsheng@627 7531
dongsheng@627 7532 #. type: Content of: <book><chapter><para>
dongsheng@714 7533 #: ../en/ch06-collab.xml:7
dongsheng@627 7534 msgid ""
dongsheng@627 7535 "As a completely decentralised tool, Mercurial doesn't impose any policy on "
dongsheng@627 7536 "how people ought to work with each other. However, if you're new to "
dongsheng@627 7537 "distributed revision control, it helps to have some tools and examples in "
dongsheng@627 7538 "mind when you're thinking about possible workflow models."
dongsheng@627 7539 msgstr ""
dongsheng@627 7540
dongsheng@627 7541 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 7542 #: ../en/ch06-collab.xml:14
dongsheng@627 7543 msgid "Mercurial's web interface"
dongsheng@630 7544 msgstr "Mercurial 的 web 接口"
dongsheng@627 7545
dongsheng@627 7546 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 7547 #: ../en/ch06-collab.xml:16
dongsheng@627 7548 msgid ""
dongsheng@627 7549 "Mercurial has a powerful web interface that provides several useful "
dongsheng@627 7550 "capabilities."
dongsheng@627 7551 msgstr ""
dongsheng@627 7552
dongsheng@627 7553 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 7554 #: ../en/ch06-collab.xml:19
dongsheng@627 7555 msgid ""
dongsheng@627 7556 "For interactive use, the web interface lets you browse a single repository or "
dongsheng@627 7557 "a collection of repositories. You can view the history of a repository, "
dongsheng@627 7558 "examine each change (comments and diffs), and view the contents of each "
songdongsheng@710 7559 "directory and file. You can even get a view of history that gives a "
songdongsheng@710 7560 "graphical view of the relationships between individual changes and merges."
songdongsheng@710 7561 msgstr ""
songdongsheng@710 7562
songdongsheng@710 7563 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 7564 #: ../en/ch06-collab.xml:26
songdongsheng@710 7565 msgid ""
songdongsheng@710 7566 "Also for human consumption, the web interface provides Atom and RSS feeds of "
songdongsheng@710 7567 "the changes in a repository. This lets you <quote>subscribe</quote> to a "
songdongsheng@710 7568 "repository using your favorite feed reader, and be automatically notified of "
dongsheng@627 7569 "activity in that repository as soon as it happens. I find this capability "
dongsheng@627 7570 "much more convenient than the model of subscribing to a mailing list to which "
dongsheng@627 7571 "notifications are sent, as it requires no additional configuration on the "
dongsheng@627 7572 "part of whoever is serving the repository."
dongsheng@627 7573 msgstr ""
dongsheng@627 7574
dongsheng@627 7575 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 7576 #: ../en/ch06-collab.xml:36
dongsheng@627 7577 msgid ""
dongsheng@627 7578 "The web interface also lets remote users clone a repository, pull changes "
dongsheng@627 7579 "from it, and (when the server is configured to permit it) push changes back "
dongsheng@627 7580 "to it. Mercurial's HTTP tunneling protocol aggressively compresses data, so "
dongsheng@627 7581 "that it works efficiently even over low-bandwidth network connections."
dongsheng@627 7582 msgstr ""
dongsheng@627 7583
dongsheng@627 7584 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 7585 #: ../en/ch06-collab.xml:42
dongsheng@627 7586 msgid ""
dongsheng@627 7587 "The easiest way to get started with the web interface is to use your web "
dongsheng@627 7588 "browser to visit an existing repository, such as the master Mercurial "
songdongsheng@710 7589 "repository at <ulink url=\"http://www.selenic.com/repo/hg\">http://www."
songdongsheng@710 7590 "selenic.com/repo/hg</ulink>."
songdongsheng@710 7591 msgstr ""
songdongsheng@710 7592
songdongsheng@710 7593 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 7594 #: ../en/ch06-collab.xml:47
dongsheng@627 7595 msgid ""
dongsheng@627 7596 "If you're interested in providing a web interface to your own repositories, "
songdongsheng@710 7597 "there are several good ways to do this."
songdongsheng@710 7598 msgstr ""
songdongsheng@710 7599
songdongsheng@710 7600 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 7601 #: ../en/ch06-collab.xml:51
songdongsheng@710 7602 msgid ""
songdongsheng@710 7603 "The easiest and fastest way to get started in an informal environment is to "
songdongsheng@710 7604 "use the <command role=\"hg-cmd\">hg serve</command> command, which is best "
songdongsheng@710 7605 "suited to short-term <quote>lightweight</quote> serving. See <xref linkend="
songdongsheng@710 7606 "\"sec:collab:serve\"/> below for details of how to use this command."
songdongsheng@710 7607 msgstr ""
songdongsheng@710 7608
songdongsheng@710 7609 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 7610 #: ../en/ch06-collab.xml:58
songdongsheng@710 7611 msgid ""
songdongsheng@710 7612 "For longer-lived repositories that you'd like to have permanently available, "
dongsheng@714 7613 "there are several public hosting services available. Some are free to open "
dongsheng@714 7614 "source projects, while others offer paid commercial hosting. An up-to-date "
dongsheng@714 7615 "list is available at <ulink url=\"http://www.selenic.com/mercurial/wiki/index."
dongsheng@714 7616 "cgi/MercurialHosting\">http://www.selenic.com/mercurial/wiki/index.cgi/"
dongsheng@714 7617 "MercurialHosting</ulink>."
dongsheng@714 7618 msgstr ""
dongsheng@714 7619
dongsheng@714 7620 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 7621 #: ../en/ch06-collab.xml:65
songdongsheng@710 7622 msgid ""
songdongsheng@710 7623 "If you would prefer to host your own repositories, Mercurial has built-in "
songdongsheng@710 7624 "support for several popular hosting technologies, most notably CGI (Common "
songdongsheng@710 7625 "Gateway Interface), and WSGI (Web Services Gateway Interface). See <xref "
songdongsheng@710 7626 "linkend=\"sec:collab:cgi\"/> for details of CGI and WSGI configuration."
dongsheng@627 7627 msgstr ""
dongsheng@627 7628
dongsheng@627 7629 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 7630 #: ../en/ch06-collab.xml:74
dongsheng@627 7631 msgid "Collaboration models"
dongsheng@630 7632 msgstr "协作模型"
dongsheng@627 7633
dongsheng@627 7634 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 7635 #: ../en/ch06-collab.xml:76
dongsheng@627 7636 msgid ""
dongsheng@627 7637 "With a suitably flexible tool, making decisions about workflow is much more "
dongsheng@627 7638 "of a social engineering challenge than a technical one. Mercurial imposes few "
dongsheng@627 7639 "limitations on how you can structure the flow of work in a project, so it's "
dongsheng@627 7640 "up to you and your group to set up and live with a model that matches your "
dongsheng@627 7641 "own particular needs."
dongsheng@627 7642 msgstr ""
dongsheng@627 7643
dongsheng@627 7644 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 7645 #: ../en/ch06-collab.xml:84
dongsheng@627 7646 msgid "Factors to keep in mind"
dongsheng@630 7647 msgstr "要牢记的因素"
dongsheng@627 7648
dongsheng@627 7649 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 7650 #: ../en/ch06-collab.xml:86
dongsheng@627 7651 msgid ""
dongsheng@627 7652 "The most important aspect of any model that you must keep in mind is how well "
dongsheng@627 7653 "it matches the needs and capabilities of the people who will be using it. "
dongsheng@627 7654 "This might seem self-evident; even so, you still can't afford to forget it "
dongsheng@627 7655 "for a moment."
dongsheng@627 7656 msgstr ""
dongsheng@627 7657
dongsheng@627 7658 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 7659 #: ../en/ch06-collab.xml:92
dongsheng@627 7660 msgid ""
dongsheng@627 7661 "I once put together a workflow model that seemed to make perfect sense to me, "
dongsheng@627 7662 "but that caused a considerable amount of consternation and strife within my "
dongsheng@627 7663 "development team. In spite of my attempts to explain why we needed a complex "
dongsheng@627 7664 "set of branches, and how changes ought to flow between them, a few team "
dongsheng@627 7665 "members revolted. Even though they were smart people, they didn't want to "
dongsheng@627 7666 "pay attention to the constraints we were operating under, or face the "
dongsheng@627 7667 "consequences of those constraints in the details of the model that I was "
dongsheng@627 7668 "advocating."
dongsheng@627 7669 msgstr ""
dongsheng@627 7670
dongsheng@627 7671 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 7672 #: ../en/ch06-collab.xml:102
dongsheng@627 7673 msgid ""
dongsheng@627 7674 "Don't sweep foreseeable social or technical problems under the rug. Whatever "
dongsheng@627 7675 "scheme you put into effect, you should plan for mistakes and problem "
dongsheng@627 7676 "scenarios. Consider adding automated machinery to prevent, or quickly "
dongsheng@627 7677 "recover from, trouble that you can anticipate. As an example, if you intend "
dongsheng@627 7678 "to have a branch with not-for-release changes in it, you'd do well to think "
dongsheng@627 7679 "early about the possibility that someone might accidentally merge those "
dongsheng@627 7680 "changes into a release branch. You could avoid this particular problem by "
dongsheng@627 7681 "writing a hook that prevents changes from being merged from an inappropriate "
dongsheng@627 7682 "branch."
dongsheng@627 7683 msgstr ""
dongsheng@627 7684
dongsheng@627 7685 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 7686 #: ../en/ch06-collab.xml:116
dongsheng@627 7687 msgid "Informal anarchy"
dongsheng@630 7688 msgstr "无政府状态"
dongsheng@627 7689
dongsheng@627 7690 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 7691 #: ../en/ch06-collab.xml:118
dongsheng@627 7692 msgid ""
dongsheng@627 7693 "I wouldn't suggest an <quote>anything goes</quote> approach as something "
dongsheng@627 7694 "sustainable, but it's a model that's easy to grasp, and it works perfectly "
dongsheng@627 7695 "well in a few unusual situations."
dongsheng@627 7696 msgstr ""
dongsheng@627 7697
dongsheng@627 7698 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 7699 #: ../en/ch06-collab.xml:123
dongsheng@627 7700 msgid ""
dongsheng@627 7701 "As one example, many projects have a loose-knit group of collaborators who "
dongsheng@627 7702 "rarely physically meet each other. Some groups like to overcome the "
songdongsheng@710 7703 "isolation of working at a distance by organizing occasional <quote>sprints</"
dongsheng@627 7704 "quote>. In a sprint, a number of people get together in a single location (a "
dongsheng@627 7705 "company's conference room, a hotel meeting room, that kind of place) and "
dongsheng@627 7706 "spend several days more or less locked in there, hacking intensely on a "
dongsheng@627 7707 "handful of projects."
dongsheng@627 7708 msgstr ""
dongsheng@627 7709
dongsheng@627 7710 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 7711 #: ../en/ch06-collab.xml:132
songdongsheng@710 7712 msgid ""
songdongsheng@710 7713 "A sprint or a hacking session in a coffee shop are the perfect places to use "
songdongsheng@710 7714 "the <command role=\"hg-cmd\">hg serve</command> command, since <command role="
songdongsheng@710 7715 "\"hg-cmd\">hg serve</command> does not require any fancy server "
songdongsheng@710 7716 "infrastructure. You can get started with <command role=\"hg-cmd\">hg serve</"
songdongsheng@710 7717 "command> in moments, by reading <xref linkend=\"sec:collab:serve\"/> below. "
songdongsheng@710 7718 "Then simply tell the person next to you that you're running a server, send "
songdongsheng@710 7719 "the URL to them in an instant message, and you immediately have a quick-"
songdongsheng@710 7720 "turnaround way to work together. They can type your URL into their web "
songdongsheng@710 7721 "browser and quickly review your changes; or they can pull a bugfix from you "
songdongsheng@710 7722 "and verify it; or they can clone a branch containing a new feature and try it "
songdongsheng@710 7723 "out."
songdongsheng@710 7724 msgstr ""
songdongsheng@710 7725
songdongsheng@710 7726 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 7727 #: ../en/ch06-collab.xml:146
dongsheng@627 7728 msgid ""
dongsheng@627 7729 "The charm, and the problem, with doing things in an ad hoc fashion like this "
dongsheng@627 7730 "is that only people who know about your changes, and where they are, can see "
dongsheng@627 7731 "them. Such an informal approach simply doesn't scale beyond a handful "
songdongsheng@710 7732 "people, because each individual needs to know about <emphasis>n</emphasis> "
songdongsheng@710 7733 "different repositories to pull from."
songdongsheng@710 7734 msgstr ""
songdongsheng@710 7735
songdongsheng@710 7736 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 7737 #: ../en/ch06-collab.xml:156
dongsheng@627 7738 msgid "A single central repository"
dongsheng@630 7739 msgstr "单一中央版本库"
dongsheng@627 7740
dongsheng@627 7741 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 7742 #: ../en/ch06-collab.xml:158
dongsheng@627 7743 msgid ""
dongsheng@627 7744 "For smaller projects migrating from a centralised revision control tool, "
dongsheng@627 7745 "perhaps the easiest way to get started is to have changes flow through a "
dongsheng@627 7746 "single shared central repository. This is also the most common "
dongsheng@627 7747 "<quote>building block</quote> for more ambitious workflow schemes."
dongsheng@627 7748 msgstr ""
dongsheng@627 7749
dongsheng@627 7750 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 7751 #: ../en/ch06-collab.xml:164
dongsheng@627 7752 msgid ""
dongsheng@627 7753 "Contributors start by cloning a copy of this repository. They can pull "
dongsheng@627 7754 "changes from it whenever they need to, and some (perhaps all) developers have "
dongsheng@627 7755 "permission to push a change back when they're ready for other people to see "
dongsheng@627 7756 "it."
dongsheng@627 7757 msgstr ""
dongsheng@627 7758
dongsheng@627 7759 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 7760 #: ../en/ch06-collab.xml:169
dongsheng@627 7761 msgid ""
dongsheng@627 7762 "Under this model, it can still often make sense for people to pull changes "
dongsheng@627 7763 "directly from each other, without going through the central repository. "
dongsheng@627 7764 "Consider a case in which I have a tentative bug fix, but I am worried that if "
dongsheng@627 7765 "I were to publish it to the central repository, it might subsequently break "
dongsheng@627 7766 "everyone else's trees as they pull it. To reduce the potential for damage, I "
dongsheng@627 7767 "can ask you to clone my repository into a temporary repository of your own "
dongsheng@627 7768 "and test it. This lets us put off publishing the potentially unsafe change "
dongsheng@627 7769 "until it has had a little testing."
dongsheng@627 7770 msgstr ""
dongsheng@627 7771
dongsheng@627 7772 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 7773 #: ../en/ch06-collab.xml:180
songdongsheng@710 7774 msgid ""
songdongsheng@710 7775 "If a team is hosting its own repository in this kind of scenario, people will "
songdongsheng@710 7776 "usually use the <command>ssh</command> protocol to securely push changes to "
songdongsheng@710 7777 "the central repository, as documented in <xref linkend=\"sec:collab:ssh\"/>. "
songdongsheng@710 7778 "It's also usual to publish a read-only copy of the repository over HTTP, as "
songdongsheng@710 7779 "in <xref linkend=\"sec:collab:cgi\"/>. Publishing over HTTP satisfies the "
songdongsheng@710 7780 "needs of people who don't have push access, and those who want to use web "
songdongsheng@710 7781 "browsers to browse the repository's history."
songdongsheng@710 7782 msgstr ""
songdongsheng@710 7783
songdongsheng@710 7784 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 7785 #: ../en/ch06-collab.xml:193
songdongsheng@710 7786 msgid "A hosted central repository"
songdongsheng@711 7787 msgstr "托管的中央版本库"
songdongsheng@710 7788
songdongsheng@710 7789 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 7790 #: ../en/ch06-collab.xml:195
songdongsheng@710 7791 msgid ""
songdongsheng@710 7792 "A wonderful thing about public hosting services like <ulink url=\"http://"
songdongsheng@710 7793 "bitbucket.org/\">Bitbucket</ulink> is that not only do they handle the fiddly "
songdongsheng@710 7794 "server configuration details, such as user accounts, authentication, and "
songdongsheng@710 7795 "secure wire protocols, they provide additional infrastructure to make this "
songdongsheng@710 7796 "model work well."
songdongsheng@710 7797 msgstr ""
songdongsheng@710 7798
songdongsheng@710 7799 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 7800 #: ../en/ch06-collab.xml:202
songdongsheng@710 7801 msgid ""
songdongsheng@710 7802 "For instance, a well-engineered hosting service will let people clone their "
songdongsheng@710 7803 "own copies of a repository with a single click. This lets people work in "
songdongsheng@710 7804 "separate spaces and share their changes when they're ready."
songdongsheng@710 7805 msgstr ""
songdongsheng@710 7806
songdongsheng@710 7807 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 7808 #: ../en/ch06-collab.xml:207
songdongsheng@710 7809 msgid ""
songdongsheng@710 7810 "In addition, a good hosting service will let people communicate with each "
songdongsheng@710 7811 "other, for instance to say <quote>there are changes ready for you to review "
songdongsheng@710 7812 "in this tree</quote>."
songdongsheng@710 7813 msgstr ""
songdongsheng@710 7814
songdongsheng@710 7815 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 7816 #: ../en/ch06-collab.xml:214
dongsheng@627 7817 msgid "Working with multiple branches"
dongsheng@630 7818 msgstr "使用多个分支工作"
dongsheng@627 7819
dongsheng@627 7820 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 7821 #: ../en/ch06-collab.xml:216
dongsheng@627 7822 msgid ""
dongsheng@627 7823 "Projects of any significant size naturally tend to make progress on several "
dongsheng@627 7824 "fronts simultaneously. In the case of software, it's common for a project to "
dongsheng@627 7825 "go through periodic official releases. A release might then go into "
dongsheng@627 7826 "<quote>maintenance mode</quote> for a while after its first publication; "
dongsheng@627 7827 "maintenance releases tend to contain only bug fixes, not new features. In "
dongsheng@627 7828 "parallel with these maintenance releases, one or more future releases may be "
dongsheng@627 7829 "under development. People normally use the word <quote>branch</quote> to "
dongsheng@627 7830 "refer to one of these many slightly different directions in which development "
dongsheng@627 7831 "is proceeding."
dongsheng@627 7832 msgstr ""
dongsheng@627 7833
dongsheng@627 7834 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 7835 #: ../en/ch06-collab.xml:229
dongsheng@627 7836 msgid ""
dongsheng@627 7837 "Mercurial is particularly well suited to managing a number of simultaneous, "
dongsheng@627 7838 "but not identical, branches. Each <quote>development direction</quote> can "
dongsheng@627 7839 "live in its own central repository, and you can merge changes from one to "
dongsheng@627 7840 "another as the need arises. Because repositories are independent of each "
dongsheng@627 7841 "other, unstable changes in a development branch will never affect a stable "
songdongsheng@710 7842 "branch unless someone explicitly merges those changes into the stable branch."
songdongsheng@710 7843 msgstr ""
songdongsheng@710 7844
songdongsheng@710 7845 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 7846 #: ../en/ch06-collab.xml:238
dongsheng@627 7847 msgid ""
dongsheng@627 7848 "Here's an example of how this can work in practice. Let's say you have one "
dongsheng@627 7849 "<quote>main branch</quote> on a central server."
dongsheng@627 7850 msgstr ""
dongsheng@627 7851
dongsheng@627 7852 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 7853 #: ../en/ch06-collab.xml:244
dongsheng@627 7854 msgid "People clone it, make changes locally, test them, and push them back."
dongsheng@627 7855 msgstr ""
dongsheng@627 7856
dongsheng@627 7857 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 7858 #: ../en/ch06-collab.xml:247
dongsheng@627 7859 msgid ""
dongsheng@627 7860 "Once the main branch reaches a release milestone, you can use the <command "
dongsheng@627 7861 "role=\"hg-cmd\">hg tag</command> command to give a permanent name to the "
dongsheng@627 7862 "milestone revision."
dongsheng@627 7863 msgstr ""
dongsheng@627 7864
dongsheng@627 7865 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 7866 #: ../en/ch06-collab.xml:253
dongsheng@627 7867 msgid "Let's say some ongoing development occurs on the main branch."
dongsheng@627 7868 msgstr ""
dongsheng@627 7869
dongsheng@627 7870 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 7871 #: ../en/ch06-collab.xml:258
dongsheng@627 7872 msgid ""
dongsheng@627 7873 "Using the tag that was recorded at the milestone, people who clone that "
dongsheng@627 7874 "repository at any time in the future can use <command role=\"hg-cmd\">hg "
dongsheng@627 7875 "update</command> to get a copy of the working directory exactly as it was "
dongsheng@627 7876 "when that tagged revision was committed."
dongsheng@627 7877 msgstr ""
dongsheng@627 7878
songdongsheng@710 7879 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 7880 #: ../en/ch06-collab.xml:266
songdongsheng@710 7881 msgid ""
songdongsheng@710 7882 "In addition, immediately after the main branch is tagged, we can then clone "
songdongsheng@710 7883 "the main branch on the server to a new <quote>stable</quote> branch, also on "
songdongsheng@710 7884 "the server."
songdongsheng@710 7885 msgstr ""
songdongsheng@710 7886
songdongsheng@710 7887 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 7888 #: ../en/ch06-collab.xml:272
songdongsheng@710 7889 msgid ""
songdongsheng@710 7890 "If we need to make a change to the stable branch, we can then clone "
songdongsheng@710 7891 "<emphasis>that</emphasis> repository, make our changes, commit, and push our "
songdongsheng@710 7892 "changes back there."
songdongsheng@710 7893 msgstr ""
songdongsheng@710 7894
songdongsheng@710 7895 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 7896 #: ../en/ch06-collab.xml:279
dongsheng@627 7897 msgid ""
dongsheng@627 7898 "Because Mercurial repositories are independent, and Mercurial doesn't move "
dongsheng@627 7899 "changes around automatically, the stable and main branches are "
songdongsheng@710 7900 "<emphasis>isolated</emphasis> from each other. The changes that we made on "
dongsheng@627 7901 "the main branch don't <quote>leak</quote> to the stable branch, and vice "
dongsheng@627 7902 "versa."
dongsheng@627 7903 msgstr ""
dongsheng@627 7904
dongsheng@627 7905 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 7906 #: ../en/ch06-collab.xml:286
songdongsheng@710 7907 msgid ""
songdongsheng@710 7908 "We'll often want all of our bugfixes on the stable branch to show up on the "
songdongsheng@710 7909 "main branch, too. Rather than rewrite a bugfix on the main branch, we can "
dongsheng@627 7910 "simply pull and merge changes from the stable to the main branch, and "
songdongsheng@710 7911 "Mercurial will bring those bugfixes in for us."
songdongsheng@710 7912 msgstr ""
songdongsheng@710 7913
songdongsheng@710 7914 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 7915 #: ../en/ch06-collab.xml:294
dongsheng@627 7916 msgid ""
dongsheng@627 7917 "The main branch will still contain changes that are not on the stable branch, "
dongsheng@627 7918 "but it will also contain all of the bugfixes from the stable branch. The "
songdongsheng@710 7919 "stable branch remains unaffected by these changes, since changes are only "
songdongsheng@710 7920 "flowing from the stable to the main branch, and not the other way."
dongsheng@627 7921 msgstr ""
dongsheng@627 7922
songdongsheng@658 7923 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
dongsheng@714 7924 #: ../en/ch06-collab.xml:303 ../en/ch06-collab.xml:313
dongsheng@627 7925 msgid "Feature branches"
dongsheng@630 7926 msgstr "特性分支"
dongsheng@627 7927
dongsheng@627 7928 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 7929 #: ../en/ch06-collab.xml:305
dongsheng@627 7930 msgid ""
dongsheng@627 7931 "For larger projects, an effective way to manage change is to break up a team "
dongsheng@627 7932 "into smaller groups. Each group has a shared branch of its own, cloned from "
dongsheng@627 7933 "a single <quote>master</quote> branch used by the entire project. People "
dongsheng@627 7934 "working on an individual branch are typically quite isolated from "
dongsheng@627 7935 "developments on other branches."
dongsheng@627 7936 msgstr ""
dongsheng@627 7937
songdongsheng@658 7938 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
dongsheng@714 7939 #: ../en/ch06-collab.xml:315
dongsheng@641 7940 msgid ""
songdongsheng@658 7941 "<imageobject><imagedata width=\"100%\" fileref=\"figs/feature-branches.png\"/"
songdongsheng@658 7942 "></imageobject>"
songdongsheng@658 7943 msgstr ""
songdongsheng@658 7944
songdongsheng@658 7945 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 7946 #: ../en/ch06-collab.xml:320
dongsheng@627 7947 msgid ""
dongsheng@627 7948 "When a particular feature is deemed to be in suitable shape, someone on that "
dongsheng@627 7949 "feature team pulls and merges from the master branch into the feature branch, "
dongsheng@627 7950 "then pushes back up to the master branch."
dongsheng@627 7951 msgstr ""
dongsheng@627 7952
dongsheng@627 7953 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 7954 #: ../en/ch06-collab.xml:327
dongsheng@627 7955 msgid "The release train"
dongsheng@630 7956 msgstr "发布列车"
dongsheng@627 7957
dongsheng@627 7958 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 7959 #: ../en/ch06-collab.xml:329
songdongsheng@710 7960 msgid ""
songdongsheng@710 7961 "Some projects are organized on a <quote>train</quote> basis: a release is "
dongsheng@627 7962 "scheduled to happen every few months, and whatever features are ready when "
dongsheng@627 7963 "the <quote>train</quote> is ready to leave are allowed in."
dongsheng@627 7964 msgstr ""
dongsheng@627 7965
dongsheng@627 7966 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 7967 #: ../en/ch06-collab.xml:334
dongsheng@627 7968 msgid ""
dongsheng@627 7969 "This model resembles working with feature branches. The difference is that "
dongsheng@627 7970 "when a feature branch misses a train, someone on the feature team pulls and "
dongsheng@627 7971 "merges the changes that went out on that train release into the feature "
dongsheng@627 7972 "branch, and the team continues its work on top of that release so that their "
dongsheng@627 7973 "feature can make the next release."
dongsheng@627 7974 msgstr ""
dongsheng@627 7975
dongsheng@627 7976 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 7977 #: ../en/ch06-collab.xml:343
dongsheng@627 7978 msgid "The Linux kernel model"
dongsheng@630 7979 msgstr "Linux 内核模型"
dongsheng@627 7980
dongsheng@627 7981 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 7982 #: ../en/ch06-collab.xml:345
dongsheng@627 7983 msgid ""
dongsheng@627 7984 "The development of the Linux kernel has a shallow hierarchical structure, "
dongsheng@627 7985 "surrounded by a cloud of apparent chaos. Because most Linux developers use "
dongsheng@627 7986 "<command>git</command>, a distributed revision control tool with capabilities "
dongsheng@627 7987 "similar to Mercurial, it's useful to describe the way work flows in that "
dongsheng@627 7988 "environment; if you like the ideas, the approach translates well across tools."
dongsheng@627 7989 msgstr ""
dongsheng@627 7990
dongsheng@627 7991 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 7992 #: ../en/ch06-collab.xml:353
dongsheng@627 7993 msgid ""
dongsheng@627 7994 "At the center of the community sits Linus Torvalds, the creator of Linux. He "
dongsheng@627 7995 "publishes a single source repository that is considered the "
dongsheng@627 7996 "<quote>authoritative</quote> current tree by the entire developer community. "
dongsheng@627 7997 "Anyone can clone Linus's tree, but he is very choosy about whose trees he "
dongsheng@627 7998 "pulls from."
dongsheng@627 7999 msgstr ""
dongsheng@627 8000
dongsheng@627 8001 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 8002 #: ../en/ch06-collab.xml:360
dongsheng@627 8003 msgid ""
dongsheng@627 8004 "Linus has a number of <quote>trusted lieutenants</quote>. As a general rule, "
dongsheng@627 8005 "he pulls whatever changes they publish, in most cases without even reviewing "
dongsheng@627 8006 "those changes. Some of those lieutenants are generally agreed to be "
dongsheng@627 8007 "<quote>maintainers</quote>, responsible for specific subsystems within the "
dongsheng@627 8008 "kernel. If a random kernel hacker wants to make a change to a subsystem that "
dongsheng@627 8009 "they want to end up in Linus's tree, they must find out who the subsystem's "
dongsheng@627 8010 "maintainer is, and ask that maintainer to take their change. If the "
dongsheng@627 8011 "maintainer reviews their changes and agrees to take them, they'll pass them "
dongsheng@627 8012 "along to Linus in due course."
dongsheng@627 8013 msgstr ""
dongsheng@627 8014
dongsheng@627 8015 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 8016 #: ../en/ch06-collab.xml:372
dongsheng@627 8017 msgid ""
dongsheng@627 8018 "Individual lieutenants have their own approaches to reviewing, accepting, and "
dongsheng@627 8019 "publishing changes; and for deciding when to feed them to Linus. In "
dongsheng@627 8020 "addition, there are several well known branches that people use for different "
dongsheng@627 8021 "purposes. For example, a few people maintain <quote>stable</quote> "
dongsheng@627 8022 "repositories of older versions of the kernel, to which they apply critical "
dongsheng@627 8023 "fixes as needed. Some maintainers publish multiple trees: one for "
dongsheng@627 8024 "experimental changes; one for changes that they are about to feed upstream; "
dongsheng@627 8025 "and so on. Others just publish a single tree."
dongsheng@627 8026 msgstr ""
dongsheng@627 8027
dongsheng@627 8028 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 8029 #: ../en/ch06-collab.xml:383
dongsheng@627 8030 msgid ""
dongsheng@627 8031 "This model has two notable features. The first is that it's <quote>pull "
dongsheng@627 8032 "only</quote>. You have to ask, convince, or beg another developer to take a "
dongsheng@627 8033 "change from you, because there are almost no trees to which more than one "
dongsheng@627 8034 "person can push, and there's no way to push changes into a tree that someone "
dongsheng@627 8035 "else controls."
dongsheng@627 8036 msgstr ""
dongsheng@627 8037
dongsheng@627 8038 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 8039 #: ../en/ch06-collab.xml:390
dongsheng@627 8040 msgid ""
dongsheng@627 8041 "The second is that it's based on reputation and acclaim. If you're an "
dongsheng@627 8042 "unknown, Linus will probably ignore changes from you without even "
dongsheng@627 8043 "responding. But a subsystem maintainer will probably review them, and will "
dongsheng@627 8044 "likely take them if they pass their criteria for suitability. The more "
dongsheng@627 8045 "<quote>good</quote> changes you contribute to a maintainer, the more likely "
dongsheng@627 8046 "they are to trust your judgment and accept your changes. If you're well-"
dongsheng@627 8047 "known and maintain a long-lived branch for something Linus hasn't yet "
dongsheng@627 8048 "accepted, people with similar interests may pull your changes regularly to "
dongsheng@627 8049 "keep up with your work."
dongsheng@627 8050 msgstr ""
dongsheng@627 8051
dongsheng@627 8052 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 8053 #: ../en/ch06-collab.xml:401
dongsheng@627 8054 msgid ""
dongsheng@627 8055 "Reputation and acclaim don't necessarily cross subsystem or <quote>people</"
dongsheng@627 8056 "quote> boundaries. If you're a respected but specialised storage hacker, and "
dongsheng@627 8057 "you try to fix a networking bug, that change will receive a level of scrutiny "
dongsheng@627 8058 "from a network maintainer comparable to a change from a complete stranger."
dongsheng@627 8059 msgstr ""
dongsheng@627 8060
dongsheng@627 8061 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 8062 #: ../en/ch06-collab.xml:408
dongsheng@627 8063 msgid ""
dongsheng@627 8064 "To people who come from more orderly project backgrounds, the comparatively "
dongsheng@627 8065 "chaotic Linux kernel development process often seems completely insane. It's "
dongsheng@627 8066 "subject to the whims of individuals; people make sweeping changes whenever "
dongsheng@627 8067 "they deem it appropriate; and the pace of development is astounding. And yet "
dongsheng@627 8068 "Linux is a highly successful, well-regarded piece of software."
dongsheng@627 8069 msgstr ""
dongsheng@627 8070
dongsheng@627 8071 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 8072 #: ../en/ch06-collab.xml:418
dongsheng@627 8073 msgid "Pull-only versus shared-push collaboration"
dongsheng@630 8074 msgstr "只读与共享写协作"
dongsheng@627 8075
dongsheng@627 8076 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 8077 #: ../en/ch06-collab.xml:420
dongsheng@627 8078 msgid ""
dongsheng@627 8079 "A perpetual source of heat in the open source community is whether a "
dongsheng@627 8080 "development model in which people only ever pull changes from others is "
dongsheng@627 8081 "<quote>better than</quote> one in which multiple people can push changes to a "
dongsheng@627 8082 "shared repository."
dongsheng@627 8083 msgstr ""
dongsheng@627 8084
dongsheng@627 8085 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 8086 #: ../en/ch06-collab.xml:426
dongsheng@627 8087 msgid ""
dongsheng@627 8088 "Typically, the backers of the shared-push model use tools that actively "
dongsheng@627 8089 "enforce this approach. If you're using a centralised revision control tool "
dongsheng@627 8090 "such as Subversion, there's no way to make a choice over which model you'll "
dongsheng@627 8091 "use: the tool gives you shared-push, and if you want to do anything else, "
dongsheng@627 8092 "you'll have to roll your own approach on top (such as applying a patch by "
dongsheng@627 8093 "hand)."
dongsheng@627 8094 msgstr ""
dongsheng@627 8095
dongsheng@627 8096 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 8097 #: ../en/ch06-collab.xml:434
songdongsheng@710 8098 msgid ""
songdongsheng@710 8099 "A good distributed revision control tool will support both models. You and "
songdongsheng@710 8100 "your collaborators can then structure how you work together based on your own "
songdongsheng@710 8101 "needs and preferences, not on what contortions your tools force you into."
songdongsheng@710 8102 msgstr ""
songdongsheng@710 8103
songdongsheng@710 8104 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 8105 #: ../en/ch06-collab.xml:441
dongsheng@627 8106 msgid "Where collaboration meets branch management"
dongsheng@630 8107 msgstr "协作与分支管理"
dongsheng@627 8108
dongsheng@627 8109 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 8110 #: ../en/ch06-collab.xml:443
dongsheng@627 8111 msgid ""
dongsheng@627 8112 "Once you and your team set up some shared repositories and start propagating "
dongsheng@627 8113 "changes back and forth between local and shared repos, you begin to face a "
dongsheng@627 8114 "related, but slightly different challenge: that of managing the multiple "
dongsheng@627 8115 "directions in which your team may be moving at once. Even though this "
dongsheng@627 8116 "subject is intimately related to how your team collaborates, it's dense "
songdongsheng@658 8117 "enough to merit treatment of its own, in <xref linkend=\"chap:branch\"/>."
dongsheng@627 8118 msgstr ""
dongsheng@627 8119
dongsheng@627 8120 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 8121 #: ../en/ch06-collab.xml:455
dongsheng@627 8122 msgid "The technical side of sharing"
dongsheng@630 8123 msgstr "共享的技术因素"
dongsheng@627 8124
dongsheng@627 8125 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 8126 #: ../en/ch06-collab.xml:457
songdongsheng@710 8127 msgid ""
songdongsheng@710 8128 "The remainder of this chapter is devoted to the question of sharing changes "
songdongsheng@710 8129 "with your collaborators."
dongsheng@627 8130 msgstr ""
dongsheng@627 8131
dongsheng@627 8132 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 8133 #: ../en/ch06-collab.xml:462
dongsheng@627 8134 msgid "Informal sharing with <command role=\"hg-cmd\">hg serve</command>"
dongsheng@630 8135 msgstr "使用 <command role=\"hg-cmd\">hg serve</command> 进行非正式共享"
dongsheng@627 8136
dongsheng@627 8137 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 8138 #: ../en/ch06-collab.xml:465
dongsheng@627 8139 msgid ""
dongsheng@627 8140 "Mercurial's <command role=\"hg-cmd\">hg serve</command> command is "
dongsheng@627 8141 "wonderfully suited to small, tight-knit, and fast-paced group environments. "
dongsheng@627 8142 "It also provides a great way to get a feel for using Mercurial commands over "
dongsheng@627 8143 "a network."
dongsheng@627 8144 msgstr ""
dongsheng@627 8145
dongsheng@627 8146 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 8147 #: ../en/ch06-collab.xml:470
dongsheng@627 8148 msgid ""
dongsheng@627 8149 "Run <command role=\"hg-cmd\">hg serve</command> inside a repository, and in "
dongsheng@627 8150 "under a second it will bring up a specialised HTTP server; this will accept "
dongsheng@627 8151 "connections from any client, and serve up data for that repository until you "
dongsheng@627 8152 "terminate it. Anyone who knows the URL of the server you just started, and "
dongsheng@627 8153 "can talk to your computer over the network, can then use a web browser or "
dongsheng@627 8154 "Mercurial to read data from that repository. A URL for a <command role=\"hg-"
dongsheng@627 8155 "cmd\">hg serve</command> instance running on a laptop is likely to look "
dongsheng@627 8156 "something like <literal>http://my-laptop.local:8000/</literal>."
dongsheng@627 8157 msgstr ""
dongsheng@627 8158
dongsheng@627 8159 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 8160 #: ../en/ch06-collab.xml:481
dongsheng@627 8161 msgid ""
dongsheng@627 8162 "The <command role=\"hg-cmd\">hg serve</command> command is <emphasis>not</"
dongsheng@627 8163 "emphasis> a general-purpose web server. It can do only two things:"
dongsheng@627 8164 msgstr ""
dongsheng@627 8165
dongsheng@627 8166 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 8167 #: ../en/ch06-collab.xml:485
dongsheng@627 8168 msgid ""
dongsheng@627 8169 "Allow people to browse the history of the repository it's serving, from their "
dongsheng@627 8170 "normal web browsers."
dongsheng@627 8171 msgstr ""
dongsheng@627 8172
dongsheng@627 8173 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 8174 #: ../en/ch06-collab.xml:489
dongsheng@627 8175 msgid ""
dongsheng@627 8176 "Speak Mercurial's wire protocol, so that people can <command role=\"hg-cmd"
dongsheng@627 8177 "\">hg clone</command> or <command role=\"hg-cmd\">hg pull</command> changes "
dongsheng@627 8178 "from that repository."
dongsheng@627 8179 msgstr ""
dongsheng@627 8180
dongsheng@627 8181 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 8182 #: ../en/ch06-collab.xml:494
dongsheng@627 8183 msgid ""
dongsheng@627 8184 "In particular, <command role=\"hg-cmd\">hg serve</command> won't allow remote "
dongsheng@627 8185 "users to <emphasis>modify</emphasis> your repository. It's intended for read-"
dongsheng@627 8186 "only use."
dongsheng@627 8187 msgstr ""
dongsheng@627 8188
dongsheng@627 8189 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 8190 #: ../en/ch06-collab.xml:498
dongsheng@627 8191 msgid ""
dongsheng@627 8192 "If you're getting started with Mercurial, there's nothing to prevent you from "
dongsheng@627 8193 "using <command role=\"hg-cmd\">hg serve</command> to serve up a repository on "
dongsheng@627 8194 "your own computer, then use commands like <command role=\"hg-cmd\">hg clone</"
dongsheng@627 8195 "command>, <command role=\"hg-cmd\">hg incoming</command>, and so on to talk "
dongsheng@627 8196 "to that server as if the repository was hosted remotely. This can help you to "
dongsheng@627 8197 "quickly get acquainted with using commands on network-hosted repositories."
dongsheng@627 8198 msgstr ""
dongsheng@627 8199
dongsheng@627 8200 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 8201 #: ../en/ch06-collab.xml:508
dongsheng@627 8202 msgid "A few things to keep in mind"
dongsheng@630 8203 msgstr "要牢记的几件事"
dongsheng@627 8204
dongsheng@627 8205 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 8206 #: ../en/ch06-collab.xml:510
dongsheng@627 8207 msgid ""
dongsheng@627 8208 "Because it provides unauthenticated read access to all clients, you should "
dongsheng@627 8209 "only use <command role=\"hg-cmd\">hg serve</command> in an environment where "
dongsheng@627 8210 "you either don't care, or have complete control over, who can access your "
dongsheng@627 8211 "network and pull data from your repository."
dongsheng@627 8212 msgstr ""
dongsheng@627 8213
dongsheng@627 8214 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 8215 #: ../en/ch06-collab.xml:516
dongsheng@627 8216 msgid ""
dongsheng@627 8217 "The <command role=\"hg-cmd\">hg serve</command> command knows nothing about "
dongsheng@627 8218 "any firewall software you might have installed on your system or network. It "
dongsheng@627 8219 "cannot detect or control your firewall software. If other people are unable "
dongsheng@627 8220 "to talk to a running <command role=\"hg-cmd\">hg serve</command> instance, "
dongsheng@627 8221 "the second thing you should do (<emphasis>after</emphasis> you make sure that "
dongsheng@627 8222 "they're using the correct URL) is check your firewall configuration."
dongsheng@627 8223 msgstr ""
dongsheng@627 8224
dongsheng@627 8225 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 8226 #: ../en/ch06-collab.xml:525
dongsheng@627 8227 msgid ""
dongsheng@627 8228 "By default, <command role=\"hg-cmd\">hg serve</command> listens for incoming "
dongsheng@627 8229 "connections on port 8000. If another process is already listening on the "
dongsheng@627 8230 "port you want to use, you can specify a different port to listen on using the "
dongsheng@627 8231 "<option role=\"hg-opt-serve\">-p</option> option."
dongsheng@627 8232 msgstr ""
dongsheng@627 8233
dongsheng@627 8234 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 8235 #: ../en/ch06-collab.xml:531
dongsheng@627 8236 msgid ""
dongsheng@627 8237 "Normally, when <command role=\"hg-cmd\">hg serve</command> starts, it prints "
dongsheng@627 8238 "no output, which can be a bit unnerving. If you'd like to confirm that it is "
dongsheng@627 8239 "indeed running correctly, and find out what URL you should send to your "
dongsheng@627 8240 "collaborators, start it with the <option role=\"hg-opt-global\">-v</option> "
dongsheng@627 8241 "option."
dongsheng@627 8242 msgstr ""
dongsheng@627 8243
dongsheng@627 8244 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 8245 #: ../en/ch06-collab.xml:541
dongsheng@627 8246 msgid "Using the Secure Shell (ssh) protocol"
dongsheng@630 8247 msgstr "使用 ssh 协议"
dongsheng@627 8248
dongsheng@627 8249 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 8250 #: ../en/ch06-collab.xml:543
dongsheng@627 8251 msgid ""
dongsheng@627 8252 "You can pull and push changes securely over a network connection using the "
dongsheng@627 8253 "Secure Shell (<literal>ssh</literal>) protocol. To use this successfully, "
dongsheng@627 8254 "you may have to do a little bit of configuration on the client or server "
dongsheng@627 8255 "sides."
dongsheng@627 8256 msgstr ""
dongsheng@627 8257
dongsheng@627 8258 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 8259 #: ../en/ch06-collab.xml:548
songdongsheng@710 8260 msgid ""
songdongsheng@710 8261 "If you're not familiar with ssh, it's the name of both a command and a "
songdongsheng@710 8262 "network protocol that let you securely communicate with another computer. To "
songdongsheng@710 8263 "use it with Mercurial, you'll be setting up one or more user accounts on a "
songdongsheng@710 8264 "server so that remote users can log in and execute commands."
songdongsheng@710 8265 msgstr ""
songdongsheng@710 8266
songdongsheng@710 8267 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 8268 #: ../en/ch06-collab.xml:554
dongsheng@627 8269 msgid ""
dongsheng@627 8270 "(If you <emphasis>are</emphasis> familiar with ssh, you'll probably find some "
dongsheng@627 8271 "of the material that follows to be elementary in nature.)"
dongsheng@627 8272 msgstr ""
dongsheng@627 8273
dongsheng@627 8274 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 8275 #: ../en/ch06-collab.xml:559
dongsheng@627 8276 msgid "How to read and write ssh URLs"
dongsheng@630 8277 msgstr "如何读写 ssh 路径"
dongsheng@627 8278
dongsheng@627 8279 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 8280 #: ../en/ch06-collab.xml:561
songdongsheng@658 8281 msgid "An ssh URL tends to look like this:"
songdongsheng@658 8282 msgstr ""
songdongsheng@658 8283
songdongsheng@658 8284 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
dongsheng@714 8285 #: ../en/ch06-collab.xml:564
songdongsheng@658 8286 msgid ""
songdongsheng@658 8287 "The <quote><literal>ssh://</literal></quote> part tells Mercurial to use the "
songdongsheng@658 8288 "ssh protocol."
dongsheng@627 8289 msgstr ""
dongsheng@627 8290
dongsheng@627 8291 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
dongsheng@714 8292 #: ../en/ch06-collab.xml:567
dongsheng@627 8293 msgid ""
dongsheng@627 8294 "The <quote><literal>bos@</literal></quote> component indicates what username "
dongsheng@627 8295 "to log into the server as. You can leave this out if the remote username is "
dongsheng@627 8296 "the same as your local username."
dongsheng@627 8297 msgstr ""
dongsheng@627 8298
dongsheng@627 8299 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
dongsheng@714 8300 #: ../en/ch06-collab.xml:572
dongsheng@627 8301 msgid ""
dongsheng@627 8302 "The <quote><literal>hg.serpentine.com</literal></quote> gives the hostname of "
dongsheng@627 8303 "the server to log into."
dongsheng@627 8304 msgstr ""
dongsheng@627 8305
dongsheng@627 8306 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
dongsheng@714 8307 #: ../en/ch06-collab.xml:576
dongsheng@627 8308 msgid ""
dongsheng@627 8309 "The <quote>:22</quote> identifies the port number to connect to the server "
dongsheng@650 8310 "on. The default port is 22, so you only need to specify a colon and port "
dongsheng@650 8311 "number if you're <emphasis>not</emphasis> using port 22."
dongsheng@627 8312 msgstr ""
dongsheng@627 8313
dongsheng@627 8314 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
dongsheng@714 8315 #: ../en/ch06-collab.xml:581
dongsheng@627 8316 msgid ""
dongsheng@627 8317 "The remainder of the URL is the local path to the repository on the server."
dongsheng@627 8318 msgstr ""
dongsheng@627 8319
dongsheng@627 8320 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 8321 #: ../en/ch06-collab.xml:585
dongsheng@627 8322 msgid ""
dongsheng@627 8323 "There's plenty of scope for confusion with the path component of ssh URLs, as "
dongsheng@627 8324 "there is no standard way for tools to interpret it. Some programs behave "
dongsheng@627 8325 "differently than others when dealing with these paths. This isn't an ideal "
dongsheng@627 8326 "situation, but it's unlikely to change. Please read the following paragraphs "
dongsheng@627 8327 "carefully."
dongsheng@627 8328 msgstr ""
dongsheng@627 8329
dongsheng@627 8330 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 8331 #: ../en/ch06-collab.xml:592
dongsheng@627 8332 msgid ""
dongsheng@627 8333 "Mercurial treats the path to a repository on the server as relative to the "
dongsheng@627 8334 "remote user's home directory. For example, if user <literal>foo</literal> on "
dongsheng@627 8335 "the server has a home directory of <filename class=\"directory\">/home/foo</"
dongsheng@627 8336 "filename>, then an ssh URL that contains a path component of <filename class="
dongsheng@627 8337 "\"directory\">bar</filename> <emphasis>really</emphasis> refers to the "
dongsheng@627 8338 "directory <filename class=\"directory\">/home/foo/bar</filename>."
dongsheng@627 8339 msgstr ""
dongsheng@627 8340
dongsheng@627 8341 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 8342 #: ../en/ch06-collab.xml:601
dongsheng@627 8343 msgid ""
dongsheng@627 8344 "If you want to specify a path relative to another user's home directory, you "
dongsheng@627 8345 "can use a path that starts with a tilde character followed by the user's name "
dongsheng@627 8346 "(let's call them <literal>otheruser</literal>), like this."
dongsheng@627 8347 msgstr ""
dongsheng@627 8348
dongsheng@627 8349 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 8350 #: ../en/ch06-collab.xml:607
dongsheng@627 8351 msgid ""
dongsheng@627 8352 "And if you really want to specify an <emphasis>absolute</emphasis> path on "
dongsheng@627 8353 "the server, begin the path component with two slashes, as in this example."
dongsheng@627 8354 msgstr ""
dongsheng@627 8355
dongsheng@627 8356 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 8357 #: ../en/ch06-collab.xml:614
dongsheng@627 8358 msgid "Finding an ssh client for your system"
dongsheng@630 8359 msgstr "为你的系统寻找 ssh 客户端"
dongsheng@627 8360
dongsheng@627 8361 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 8362 #: ../en/ch06-collab.xml:616
dongsheng@627 8363 msgid ""
dongsheng@627 8364 "Almost every Unix-like system comes with OpenSSH preinstalled. If you're "
dongsheng@627 8365 "using such a system, run <literal>which ssh</literal> to find out if the "
dongsheng@627 8366 "<command>ssh</command> command is installed (it's usually in <filename class="
dongsheng@627 8367 "\"directory\">/usr/bin</filename>). In the unlikely event that it isn't "
dongsheng@627 8368 "present, take a look at your system documentation to figure out how to "
dongsheng@627 8369 "install it."
dongsheng@627 8370 msgstr ""
dongsheng@627 8371
dongsheng@627 8372 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 8373 #: ../en/ch06-collab.xml:624
songdongsheng@710 8374 msgid ""
songdongsheng@710 8375 "On Windows, the TortoiseHg package is bundled with a version of Simon "
songdongsheng@710 8376 "Tatham's excellent <command>plink</command> command, and you should not need "
songdongsheng@710 8377 "to do any further configuration."
songdongsheng@710 8378 msgstr ""
songdongsheng@710 8379
songdongsheng@710 8380 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 8381 #: ../en/ch06-collab.xml:631
dongsheng@627 8382 msgid "Generating a key pair"
dongsheng@630 8383 msgstr "产生密钥对"
dongsheng@627 8384
dongsheng@627 8385 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 8386 #: ../en/ch06-collab.xml:633
dongsheng@627 8387 msgid ""
dongsheng@627 8388 "To avoid the need to repetitively type a password every time you need to use "
songdongsheng@710 8389 "your ssh client, I recommend generating a key pair."
songdongsheng@710 8390 msgstr ""
songdongsheng@710 8391
songdongsheng@710 8392 #. type: Content of: <book><chapter><sect1><sect2><tip><title>
dongsheng@714 8393 #: ../en/ch06-collab.xml:638
songdongsheng@710 8394 msgid "Key pairs are not mandatory"
songdongsheng@710 8395 msgstr ""
songdongsheng@710 8396
songdongsheng@710 8397 #. type: Content of: <book><chapter><sect1><sect2><tip><para>
dongsheng@714 8398 #: ../en/ch06-collab.xml:640
songdongsheng@710 8399 msgid ""
songdongsheng@710 8400 "Mercurial knows nothing about ssh authentication or key pairs. You can, if "
songdongsheng@710 8401 "you like, safely ignore this section and the one that follows until you grow "
songdongsheng@710 8402 "tired of repeatedly typing ssh passwords."
songdongsheng@710 8403 msgstr ""
songdongsheng@710 8404
songdongsheng@710 8405 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 8406 #: ../en/ch06-collab.xml:648
songdongsheng@710 8407 msgid ""
songdongsheng@710 8408 "On a Unix-like system, the <command>ssh-keygen</command> command will do the "
songdongsheng@710 8409 "trick."
songdongsheng@710 8410 msgstr ""
songdongsheng@710 8411
songdongsheng@710 8412 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 8413 #: ../en/ch06-collab.xml:651
songdongsheng@710 8414 msgid ""
songdongsheng@710 8415 "On Windows, if you're using TortoiseHg, you may need to download a command "
songdongsheng@710 8416 "named <command>puttygen</command> from <ulink url=\"http://www.chiark."
songdongsheng@710 8417 "greenend.org.uk/~sgtatham/putty\">the PuTTY web site</ulink> to generate a "
songdongsheng@710 8418 "key pair. See <ulink url=\"http://the.earth.li/~sgtatham/putty/0.60/htmldoc/"
songdongsheng@710 8419 "Chapter8.html#pubkey-puttygen\">the <command>puttygen</command> "
songdongsheng@710 8420 "documentation</ulink> for details of how use the command."
songdongsheng@710 8421 msgstr ""
songdongsheng@710 8422
songdongsheng@710 8423 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 8424 #: ../en/ch06-collab.xml:663
dongsheng@627 8425 msgid ""
dongsheng@627 8426 "When you generate a key pair, it's usually <emphasis>highly</emphasis> "
dongsheng@627 8427 "advisable to protect it with a passphrase. (The only time that you might not "
dongsheng@627 8428 "want to do this is when you're using the ssh protocol for automated tasks on "
dongsheng@627 8429 "a secure network.)"
dongsheng@627 8430 msgstr ""
dongsheng@627 8431
dongsheng@627 8432 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 8433 #: ../en/ch06-collab.xml:669
dongsheng@627 8434 msgid ""
dongsheng@627 8435 "Simply generating a key pair isn't enough, however. You'll need to add the "
dongsheng@627 8436 "public key to the set of authorised keys for whatever user you're logging in "
dongsheng@627 8437 "remotely as. For servers using OpenSSH (the vast majority), this will mean "
dongsheng@627 8438 "adding the public key to a list in a file called <filename role=\"special"
dongsheng@627 8439 "\">authorized_keys</filename> in their <filename role=\"special\" class="
dongsheng@627 8440 "\"directory\">.ssh</filename> directory."
dongsheng@627 8441 msgstr ""
dongsheng@627 8442
dongsheng@627 8443 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 8444 #: ../en/ch06-collab.xml:678
dongsheng@627 8445 msgid ""
dongsheng@627 8446 "On a Unix-like system, your public key will have a <filename>.pub</filename> "
dongsheng@627 8447 "extension. If you're using <command>puttygen</command> on Windows, you can "
dongsheng@627 8448 "save the public key to a file of your choosing, or paste it from the window "
dongsheng@627 8449 "it's displayed in straight into the <filename role=\"special"
dongsheng@627 8450 "\">authorized_keys</filename> file."
dongsheng@627 8451 msgstr ""
dongsheng@627 8452
dongsheng@627 8453 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 8454 #: ../en/ch06-collab.xml:686
dongsheng@627 8455 msgid "Using an authentication agent"
dongsheng@630 8456 msgstr "使用认证代理"
dongsheng@627 8457
dongsheng@627 8458 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 8459 #: ../en/ch06-collab.xml:688
dongsheng@627 8460 msgid ""
dongsheng@627 8461 "An authentication agent is a daemon that stores passphrases in memory (so it "
dongsheng@627 8462 "will forget passphrases if you log out and log back in again). An ssh client "
dongsheng@627 8463 "will notice if it's running, and query it for a passphrase. If there's no "
dongsheng@627 8464 "authentication agent running, or the agent doesn't store the necessary "
dongsheng@627 8465 "passphrase, you'll have to type your passphrase every time Mercurial tries to "
dongsheng@627 8466 "communicate with a server on your behalf (e.g. whenever you pull or push "
dongsheng@627 8467 "changes)."
dongsheng@627 8468 msgstr ""
dongsheng@627 8469
dongsheng@627 8470 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 8471 #: ../en/ch06-collab.xml:697
dongsheng@627 8472 msgid ""
dongsheng@627 8473 "The downside of storing passphrases in an agent is that it's possible for a "
dongsheng@627 8474 "well-prepared attacker to recover the plain text of your passphrases, in some "
dongsheng@627 8475 "cases even if your system has been power-cycled. You should make your own "
dongsheng@627 8476 "judgment as to whether this is an acceptable risk. It certainly saves a lot "
dongsheng@627 8477 "of repeated typing."
dongsheng@627 8478 msgstr ""
dongsheng@627 8479
songdongsheng@710 8480 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 8481 #: ../en/ch06-collab.xml:706
dongsheng@627 8482 msgid ""
dongsheng@627 8483 "On Unix-like systems, the agent is called <command>ssh-agent</command>, and "
dongsheng@627 8484 "it's often run automatically for you when you log in. You'll need to use the "
songdongsheng@710 8485 "<command>ssh-add</command> command to add passphrases to the agent's store."
songdongsheng@710 8486 msgstr ""
songdongsheng@710 8487
songdongsheng@710 8488 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 8489 #: ../en/ch06-collab.xml:713
songdongsheng@710 8490 msgid ""
songdongsheng@710 8491 "On Windows, if you're using TortoiseHg, the <command>pageant</command> "
songdongsheng@710 8492 "command acts as the agent. As with <command>puttygen</command>, you'll need "
songdongsheng@710 8493 "to <ulink url=\"http://www.chiark.greenend.org.uk/%7Esgtatham/putty/download."
songdongsheng@710 8494 "html\">download <command>pageant</command></ulink> from the PuTTY web site "
songdongsheng@710 8495 "and read <ulink url=\"http://the.earth.li/~sgtatham/putty/0.60/htmldoc/"
songdongsheng@710 8496 "Chapter9.html#pageant\">its documentation</ulink>. The <command>pageant</"
songdongsheng@710 8497 "command> command adds an icon to your system tray that will let you manage "
songdongsheng@710 8498 "stored passphrases."
songdongsheng@710 8499 msgstr ""
songdongsheng@710 8500
songdongsheng@710 8501 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 8502 #: ../en/ch06-collab.xml:728
dongsheng@627 8503 msgid "Configuring the server side properly"
dongsheng@630 8504 msgstr "正确配置服务器端"
dongsheng@627 8505
dongsheng@627 8506 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 8507 #: ../en/ch06-collab.xml:730
songdongsheng@710 8508 msgid ""
songdongsheng@710 8509 "Because ssh can be fiddly to set up if you're new to it, a variety of things "
songdongsheng@710 8510 "can go wrong. Add Mercurial on top, and there's plenty more scope for head-"
songdongsheng@710 8511 "scratching. Most of these potential problems occur on the server side, not "
songdongsheng@710 8512 "the client side. The good news is that once you've gotten a configuration "
songdongsheng@710 8513 "working, it will usually continue to work indefinitely."
songdongsheng@710 8514 msgstr ""
songdongsheng@710 8515
songdongsheng@710 8516 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 8517 #: ../en/ch06-collab.xml:738
dongsheng@627 8518 msgid ""
dongsheng@627 8519 "Before you try using Mercurial to talk to an ssh server, it's best to make "
dongsheng@627 8520 "sure that you can use the normal <command>ssh</command> or <command>putty</"
dongsheng@627 8521 "command> command to talk to the server first. If you run into problems with "
dongsheng@627 8522 "using these commands directly, Mercurial surely won't work. Worse, it will "
dongsheng@627 8523 "obscure the underlying problem. Any time you want to debug ssh-related "
dongsheng@627 8524 "Mercurial problems, you should drop back to making sure that plain ssh client "
dongsheng@627 8525 "commands work first, <emphasis>before</emphasis> you worry about whether "
dongsheng@627 8526 "there's a problem with Mercurial."
dongsheng@627 8527 msgstr ""
dongsheng@627 8528
dongsheng@627 8529 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 8530 #: ../en/ch06-collab.xml:749
dongsheng@627 8531 msgid ""
dongsheng@627 8532 "The first thing to be sure of on the server side is that you can actually log "
dongsheng@627 8533 "in from another machine at all. If you can't use <command>ssh</command> or "
dongsheng@627 8534 "<command>putty</command> to log in, the error message you get may give you a "
dongsheng@627 8535 "few hints as to what's wrong. The most common problems are as follows."
dongsheng@627 8536 msgstr ""
dongsheng@627 8537
dongsheng@627 8538 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 8539 #: ../en/ch06-collab.xml:756
dongsheng@627 8540 msgid ""
dongsheng@627 8541 "If you get a <quote>connection refused</quote> error, either there isn't an "
dongsheng@627 8542 "SSH daemon running on the server at all, or it's inaccessible due to firewall "
dongsheng@627 8543 "configuration."
dongsheng@627 8544 msgstr ""
dongsheng@627 8545
dongsheng@627 8546 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 8547 #: ../en/ch06-collab.xml:761
dongsheng@627 8548 msgid ""
dongsheng@627 8549 "If you get a <quote>no route to host</quote> error, you either have an "
dongsheng@627 8550 "incorrect address for the server or a seriously locked down firewall that "
dongsheng@627 8551 "won't admit its existence at all."
dongsheng@627 8552 msgstr ""
dongsheng@627 8553
dongsheng@627 8554 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 8555 #: ../en/ch06-collab.xml:766
dongsheng@627 8556 msgid ""
dongsheng@627 8557 "If you get a <quote>permission denied</quote> error, you may have mistyped "
dongsheng@627 8558 "the username on the server, or you could have mistyped your key's passphrase "
dongsheng@627 8559 "or the remote user's password."
dongsheng@627 8560 msgstr ""
dongsheng@627 8561
dongsheng@627 8562 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 8563 #: ../en/ch06-collab.xml:771
dongsheng@627 8564 msgid ""
dongsheng@627 8565 "In summary, if you're having trouble talking to the server's ssh daemon, "
dongsheng@627 8566 "first make sure that one is running at all. On many systems it will be "
dongsheng@627 8567 "installed, but disabled, by default. Once you're done with this step, you "
dongsheng@627 8568 "should then check that the server's firewall is configured to allow incoming "
dongsheng@627 8569 "connections on the port the ssh daemon is listening on (usually 22). Don't "
dongsheng@627 8570 "worry about more exotic possibilities for misconfiguration until you've "
dongsheng@627 8571 "checked these two first."
dongsheng@627 8572 msgstr ""
dongsheng@627 8573
dongsheng@627 8574 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 8575 #: ../en/ch06-collab.xml:781
dongsheng@627 8576 msgid ""
dongsheng@627 8577 "If you're using an authentication agent on the client side to store "
dongsheng@627 8578 "passphrases for your keys, you ought to be able to log into the server "
dongsheng@627 8579 "without being prompted for a passphrase or a password. If you're prompted "
dongsheng@627 8580 "for a passphrase, there are a few possible culprits."
dongsheng@627 8581 msgstr ""
dongsheng@627 8582
dongsheng@627 8583 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 8584 #: ../en/ch06-collab.xml:787
dongsheng@627 8585 msgid ""
dongsheng@627 8586 "You might have forgotten to use <command>ssh-add</command> or "
dongsheng@627 8587 "<command>pageant</command> to store the passphrase."
dongsheng@627 8588 msgstr ""
dongsheng@627 8589
dongsheng@627 8590 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 8591 #: ../en/ch06-collab.xml:791
songdongsheng@658 8592 msgid "You might have stored the passphrase for the wrong key."
songdongsheng@658 8593 msgstr ""
songdongsheng@658 8594
songdongsheng@658 8595 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 8596 #: ../en/ch06-collab.xml:794
dongsheng@627 8597 msgid ""
dongsheng@627 8598 "If you're being prompted for the remote user's password, there are another "
dongsheng@627 8599 "few possible problems to check."
dongsheng@627 8600 msgstr ""
dongsheng@627 8601
dongsheng@627 8602 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 8603 #: ../en/ch06-collab.xml:797
dongsheng@627 8604 msgid ""
dongsheng@627 8605 "Either the user's home directory or their <filename role=\"special\" class="
dongsheng@627 8606 "\"directory\">.ssh</filename> directory might have excessively liberal "
dongsheng@627 8607 "permissions. As a result, the ssh daemon will not trust or read their "
dongsheng@627 8608 "<filename role=\"special\">authorized_keys</filename> file. For example, a "
dongsheng@627 8609 "group-writable home or <filename role=\"special\" class=\"directory\">.ssh</"
dongsheng@627 8610 "filename> directory will often cause this symptom."
dongsheng@627 8611 msgstr ""
dongsheng@627 8612
dongsheng@627 8613 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 8614 #: ../en/ch06-collab.xml:806
dongsheng@627 8615 msgid ""
dongsheng@627 8616 "The user's <filename role=\"special\">authorized_keys</filename> file may "
dongsheng@627 8617 "have a problem. If anyone other than the user owns or can write to that file, "
dongsheng@627 8618 "the ssh daemon will not trust or read it."
dongsheng@627 8619 msgstr ""
dongsheng@627 8620
dongsheng@627 8621 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 8622 #: ../en/ch06-collab.xml:813
dongsheng@627 8623 msgid ""
dongsheng@627 8624 "In the ideal world, you should be able to run the following command "
dongsheng@627 8625 "successfully, and it should print exactly one line of output, the current "
dongsheng@627 8626 "date and time."
dongsheng@627 8627 msgstr ""
dongsheng@627 8628
dongsheng@627 8629 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 8630 #: ../en/ch06-collab.xml:818
dongsheng@627 8631 msgid ""
dongsheng@627 8632 "If, on your server, you have login scripts that print banners or other junk "
dongsheng@627 8633 "even when running non-interactive commands like this, you should fix them "
dongsheng@627 8634 "before you continue, so that they only print output if they're run "
dongsheng@627 8635 "interactively. Otherwise these banners will at least clutter up Mercurial's "
dongsheng@627 8636 "output. Worse, they could potentially cause problems with running Mercurial "
dongsheng@714 8637 "commands remotely. Mercurial tries to detect and ignore banners in non-"
dongsheng@627 8638 "interactive <command>ssh</command> sessions, but it is not foolproof. (If "
dongsheng@627 8639 "you're editing your login scripts on your server, the usual way to see if a "
dongsheng@627 8640 "login script is running in an interactive shell is to check the return code "
dongsheng@627 8641 "from the command <literal>tty -s</literal>.)"
dongsheng@627 8642 msgstr ""
dongsheng@627 8643
dongsheng@627 8644 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 8645 #: ../en/ch06-collab.xml:832
dongsheng@627 8646 msgid ""
dongsheng@627 8647 "Once you've verified that plain old ssh is working with your server, the next "
dongsheng@627 8648 "step is to ensure that Mercurial runs on the server. The following command "
dongsheng@627 8649 "should run successfully:"
dongsheng@627 8650 msgstr ""
dongsheng@627 8651
dongsheng@627 8652 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 8653 #: ../en/ch06-collab.xml:839
dongsheng@627 8654 msgid ""
dongsheng@627 8655 "If you see an error message instead of normal <command role=\"hg-cmd\">hg "
dongsheng@627 8656 "version</command> output, this is usually because you haven't installed "
dongsheng@627 8657 "Mercurial to <filename class=\"directory\">/usr/bin</filename>. Don't worry "
dongsheng@627 8658 "if this is the case; you don't need to do that. But you should check for a "
dongsheng@627 8659 "few possible problems."
dongsheng@627 8660 msgstr ""
dongsheng@627 8661
dongsheng@627 8662 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 8663 #: ../en/ch06-collab.xml:846
dongsheng@627 8664 msgid ""
dongsheng@627 8665 "Is Mercurial really installed on the server at all? I know this sounds "
dongsheng@627 8666 "trivial, but it's worth checking!"
dongsheng@627 8667 msgstr ""
dongsheng@627 8668
dongsheng@627 8669 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 8670 #: ../en/ch06-collab.xml:850
dongsheng@627 8671 msgid ""
dongsheng@627 8672 "Maybe your shell's search path (usually set via the <envar>PATH</envar> "
dongsheng@627 8673 "environment variable) is simply misconfigured."
dongsheng@627 8674 msgstr ""
dongsheng@627 8675
dongsheng@627 8676 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 8677 #: ../en/ch06-collab.xml:854
dongsheng@627 8678 msgid ""
dongsheng@627 8679 "Perhaps your <envar>PATH</envar> environment variable is only being set to "
dongsheng@627 8680 "point to the location of the <command>hg</command> executable if the login "
dongsheng@627 8681 "session is interactive. This can happen if you're setting the path in the "
dongsheng@627 8682 "wrong shell login script. See your shell's documentation for details."
dongsheng@627 8683 msgstr ""
dongsheng@627 8684
dongsheng@627 8685 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 8686 #: ../en/ch06-collab.xml:861
dongsheng@627 8687 msgid ""
dongsheng@627 8688 "The <envar>PYTHONPATH</envar> environment variable may need to contain the "
dongsheng@627 8689 "path to the Mercurial Python modules. It might not be set at all; it could "
dongsheng@627 8690 "be incorrect; or it may be set only if the login is interactive."
dongsheng@627 8691 msgstr ""
dongsheng@627 8692
dongsheng@627 8693 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 8694 #: ../en/ch06-collab.xml:868
dongsheng@627 8695 msgid ""
dongsheng@627 8696 "If you can run <command role=\"hg-cmd\">hg version</command> over an ssh "
dongsheng@627 8697 "connection, well done! You've got the server and client sorted out. You "
dongsheng@627 8698 "should now be able to use Mercurial to access repositories hosted by that "
dongsheng@627 8699 "username on that server. If you run into problems with Mercurial and ssh at "
dongsheng@627 8700 "this point, try using the <option role=\"hg-opt-global\">--debug</option> "
dongsheng@627 8701 "option to get a clearer picture of what's going on."
dongsheng@627 8702 msgstr ""
dongsheng@627 8703
dongsheng@627 8704 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 8705 #: ../en/ch06-collab.xml:877
dongsheng@627 8706 msgid "Using compression with ssh"
dongsheng@630 8707 msgstr "通过 ssh 使用压缩"
dongsheng@627 8708
dongsheng@627 8709 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 8710 #: ../en/ch06-collab.xml:879
dongsheng@627 8711 msgid ""
dongsheng@627 8712 "Mercurial does not compress data when it uses the ssh protocol, because the "
songdongsheng@710 8713 "ssh protocol can transparently compress data. However, the default behavior "
dongsheng@627 8714 "of ssh clients is <emphasis>not</emphasis> to request compression."
dongsheng@627 8715 msgstr ""
dongsheng@627 8716
dongsheng@627 8717 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 8718 #: ../en/ch06-collab.xml:884
dongsheng@627 8719 msgid ""
dongsheng@627 8720 "Over any network other than a fast LAN (even a wireless network), using "
dongsheng@627 8721 "compression is likely to significantly speed up Mercurial's network "
dongsheng@627 8722 "operations. For example, over a WAN, someone measured compression as "
dongsheng@627 8723 "reducing the amount of time required to clone a particularly large repository "
dongsheng@627 8724 "from 51 minutes to 17 minutes."
dongsheng@627 8725 msgstr ""
dongsheng@627 8726
dongsheng@627 8727 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 8728 #: ../en/ch06-collab.xml:891
dongsheng@627 8729 msgid ""
dongsheng@627 8730 "Both <command>ssh</command> and <command>plink</command> accept a <option "
dongsheng@627 8731 "role=\"cmd-opt-ssh\">-C</option> option which turns on compression. You can "
dongsheng@650 8732 "easily edit your <filename role=\"special\">~/.hgrc</filename> to enable "
songdongsheng@710 8733 "compression for all of Mercurial's uses of the ssh protocol. Here is how to "
songdongsheng@710 8734 "do so for regular <command>ssh</command> on Unix-like systems, for example."
songdongsheng@710 8735 msgstr ""
songdongsheng@710 8736
songdongsheng@710 8737 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 8738 #: ../en/ch06-collab.xml:901
songdongsheng@710 8739 msgid ""
songdongsheng@710 8740 "If you use <command>ssh</command> on a Unix-like system, you can configure it "
songdongsheng@710 8741 "to always use compression when talking to your server. To do this, edit your "
songdongsheng@710 8742 "<filename role=\"special\">.ssh/config</filename> file (which may not yet "
songdongsheng@710 8743 "exist), as follows."
songdongsheng@710 8744 msgstr ""
songdongsheng@710 8745
songdongsheng@710 8746 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 8747 #: ../en/ch06-collab.xml:911
songdongsheng@710 8748 msgid ""
songdongsheng@710 8749 "This defines a hostname alias, <literal>hg</literal>. When you use that "
songdongsheng@710 8750 "hostname on the <command>ssh</command> command line or in a Mercurial "
songdongsheng@710 8751 "<literal>ssh</literal>-protocol URL, it will cause <command>ssh</command> to "
songdongsheng@710 8752 "connect to <literal>hg.example.com</literal> and use compression. This gives "
songdongsheng@710 8753 "you both a shorter name to type and compression, each of which is a good "
songdongsheng@710 8754 "thing in its own right."
dongsheng@627 8755 msgstr ""
dongsheng@627 8756
dongsheng@627 8757 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 8758 #: ../en/ch06-collab.xml:923
dongsheng@627 8759 msgid "Serving over HTTP using CGI"
dongsheng@630 8760 msgstr "使用 CGI 通过 HTTP 提供服务"
dongsheng@627 8761
dongsheng@627 8762 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 8763 #: ../en/ch06-collab.xml:925
songdongsheng@710 8764 msgid ""
songdongsheng@710 8765 "The simplest way to host one or more repositories in a permanent way is to "
songdongsheng@710 8766 "use a web server and Mercurial's CGI support."
songdongsheng@710 8767 msgstr ""
songdongsheng@710 8768
songdongsheng@710 8769 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 8770 #: ../en/ch06-collab.xml:929
dongsheng@627 8771 msgid ""
dongsheng@627 8772 "Depending on how ambitious you are, configuring Mercurial's CGI interface can "
dongsheng@627 8773 "take anything from a few moments to several hours."
dongsheng@627 8774 msgstr ""
dongsheng@627 8775
dongsheng@627 8776 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 8777 #: ../en/ch06-collab.xml:933
dongsheng@627 8778 msgid ""
dongsheng@627 8779 "We'll begin with the simplest of examples, and work our way towards a more "
dongsheng@627 8780 "complex configuration. Even for the most basic case, you're almost certainly "
dongsheng@627 8781 "going to need to read and modify your web server's configuration."
dongsheng@627 8782 msgstr ""
dongsheng@627 8783
songdongsheng@710 8784 #. type: Content of: <book><chapter><sect1><note><title>
dongsheng@714 8785 #: ../en/ch06-collab.xml:939
songdongsheng@710 8786 msgid "High pain tolerance required"
songdongsheng@710 8787 msgstr ""
songdongsheng@710 8788
dongsheng@627 8789 #. type: Content of: <book><chapter><sect1><note><para>
dongsheng@714 8790 #: ../en/ch06-collab.xml:941
dongsheng@627 8791 msgid ""
dongsheng@627 8792 "Configuring a web server is a complex, fiddly, and highly system-dependent "
dongsheng@627 8793 "activity. I can't possibly give you instructions that will cover anything "
dongsheng@627 8794 "like all of the cases you will encounter. Please use your discretion and "
dongsheng@627 8795 "judgment in following the sections below. Be prepared to make plenty of "
dongsheng@627 8796 "mistakes, and to spend a lot of time reading your server's error logs."
dongsheng@627 8797 msgstr ""
dongsheng@627 8798
songdongsheng@710 8799 #. type: Content of: <book><chapter><sect1><note><para>
dongsheng@714 8800 #: ../en/ch06-collab.xml:949
songdongsheng@710 8801 msgid ""
songdongsheng@710 8802 "If you don't have a strong stomach for tweaking configurations over and over, "
songdongsheng@710 8803 "or a compelling need to host your own services, you might want to try one of "
songdongsheng@710 8804 "the public hosting services that I mentioned earlier."
songdongsheng@710 8805 msgstr ""
songdongsheng@710 8806
songdongsheng@710 8807 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 8808 #: ../en/ch06-collab.xml:956
dongsheng@627 8809 msgid "Web server configuration checklist"
dongsheng@630 8810 msgstr "Web 服务器配置检查表"
dongsheng@627 8811
dongsheng@627 8812 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 8813 #: ../en/ch06-collab.xml:958
dongsheng@627 8814 msgid ""
dongsheng@627 8815 "Before you continue, do take a few moments to check a few aspects of your "
dongsheng@627 8816 "system's setup."
dongsheng@627 8817 msgstr ""
dongsheng@627 8818
dongsheng@627 8819 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
dongsheng@714 8820 #: ../en/ch06-collab.xml:962
songdongsheng@710 8821 msgid ""
songdongsheng@710 8822 "Do you have a web server installed at all? Mac OS X and some Linux "
songdongsheng@710 8823 "distributions ship with Apache, but many other systems may not have a web "
songdongsheng@710 8824 "server installed."
dongsheng@627 8825 msgstr ""
dongsheng@627 8826
dongsheng@627 8827 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
dongsheng@714 8828 #: ../en/ch06-collab.xml:967
dongsheng@627 8829 msgid ""
dongsheng@627 8830 "If you have a web server installed, is it actually running? On most systems, "
dongsheng@627 8831 "even if one is present, it will be disabled by default."
dongsheng@627 8832 msgstr ""
dongsheng@627 8833
dongsheng@627 8834 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
dongsheng@714 8835 #: ../en/ch06-collab.xml:971
dongsheng@627 8836 msgid ""
dongsheng@627 8837 "Is your server configured to allow you to run CGI programs in the directory "
dongsheng@627 8838 "where you plan to do so? Most servers default to explicitly disabling the "
dongsheng@627 8839 "ability to run CGI programs."
dongsheng@627 8840 msgstr ""
dongsheng@627 8841
dongsheng@627 8842 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 8843 #: ../en/ch06-collab.xml:977
dongsheng@627 8844 msgid ""
dongsheng@627 8845 "If you don't have a web server installed, and don't have substantial "
dongsheng@627 8846 "experience configuring Apache, you should consider using the "
dongsheng@627 8847 "<literal>lighttpd</literal> web server instead of Apache. Apache has a well-"
dongsheng@627 8848 "deserved reputation for baroque and confusing configuration. While "
dongsheng@627 8849 "<literal>lighttpd</literal> is less capable in some ways than Apache, most of "
dongsheng@627 8850 "these capabilities are not relevant to serving Mercurial repositories. And "
dongsheng@627 8851 "<literal>lighttpd</literal> is undeniably <emphasis>much</emphasis> easier to "
dongsheng@627 8852 "get started with than Apache."
dongsheng@627 8853 msgstr ""
dongsheng@627 8854
dongsheng@627 8855 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 8856 #: ../en/ch06-collab.xml:990
dongsheng@627 8857 msgid "Basic CGI configuration"
dongsheng@630 8858 msgstr "基本 CGI 配置"
dongsheng@627 8859
dongsheng@627 8860 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 8861 #: ../en/ch06-collab.xml:992
dongsheng@627 8862 msgid ""
dongsheng@627 8863 "On Unix-like systems, it's common for users to have a subdirectory named "
dongsheng@627 8864 "something like <filename class=\"directory\">public_html</filename> in their "
dongsheng@627 8865 "home directory, from which they can serve up web pages. A file named "
dongsheng@627 8866 "<filename>foo</filename> in this directory will be accessible at a URL of the "
dongsheng@650 8867 "form <literal>http://www.example.com/username/foo</literal>."
dongsheng@650 8868 msgstr ""
dongsheng@650 8869
dongsheng@650 8870 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 8871 #: ../en/ch06-collab.xml:1000
dongsheng@627 8872 msgid ""
dongsheng@627 8873 "To get started, find the <filename role=\"special\">hgweb.cgi</filename> "
dongsheng@627 8874 "script that should be present in your Mercurial installation. If you can't "
dongsheng@627 8875 "quickly find a local copy on your system, simply download one from the master "
dongsheng@627 8876 "Mercurial repository at <ulink url=\"http://www.selenic.com/repo/hg/raw-file/"
dongsheng@627 8877 "tip/hgweb.cgi\">http://www.selenic.com/repo/hg/raw-file/tip/hgweb.cgi</ulink>."
dongsheng@627 8878 msgstr ""
dongsheng@627 8879
dongsheng@627 8880 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 8881 #: ../en/ch06-collab.xml:1007 ../en/ch06-collab.xml:1175
dongsheng@627 8882 msgid ""
dongsheng@627 8883 "You'll need to copy this script into your <filename class=\"directory"
dongsheng@627 8884 "\">public_html</filename> directory, and ensure that it's executable."
dongsheng@627 8885 msgstr ""
dongsheng@627 8886
dongsheng@627 8887 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 8888 #: ../en/ch06-collab.xml:1012
dongsheng@627 8889 msgid ""
dongsheng@627 8890 "The <literal>755</literal> argument to <command>chmod</command> is a little "
dongsheng@627 8891 "more general than just making the script executable: it ensures that the "
dongsheng@627 8892 "script is executable by anyone, and that <quote>group</quote> and "
dongsheng@627 8893 "<quote>other</quote> write permissions are <emphasis>not</emphasis> set. If "
dongsheng@627 8894 "you were to leave those write permissions enabled, Apache's <literal>suexec</"
dongsheng@627 8895 "literal> subsystem would likely refuse to execute the script. In fact, "
dongsheng@627 8896 "<literal>suexec</literal> also insists that the <emphasis>directory</"
dongsheng@627 8897 "emphasis> in which the script resides must not be writable by others."
dongsheng@627 8898 msgstr ""
dongsheng@627 8899
dongsheng@627 8900 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
dongsheng@714 8901 #: ../en/ch06-collab.xml:1026
dongsheng@627 8902 msgid "What could <emphasis>possibly</emphasis> go wrong?"
dongsheng@630 8903 msgstr "什么<emphasis>可能</emphasis>会出错?"
dongsheng@627 8904
dongsheng@627 8905 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 8906 #: ../en/ch06-collab.xml:1029
dongsheng@627 8907 msgid ""
dongsheng@627 8908 "Once you've copied the CGI script into place, go into a web browser, and try "
dongsheng@714 8909 "to open the URL <literal>http://myhostname/~myuser/hgweb.cgi</literal>, "
dongsheng@714 8910 "<emphasis>but</emphasis> brace yourself for instant failure. There's a high "
dongsheng@714 8911 "probability that trying to visit this URL will fail, and there are many "
dongsheng@714 8912 "possible reasons for this. In fact, you're likely to stumble over almost "
dongsheng@714 8913 "every one of the possible errors below, so please read carefully. The "
dongsheng@714 8914 "following are all of the problems I ran into on a system running Fedora 7, "
dongsheng@714 8915 "with a fresh installation of Apache, and a user account that I created "
dongsheng@714 8916 "specially to perform this exercise."
dongsheng@627 8917 msgstr ""
dongsheng@627 8918
dongsheng@627 8919 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 8920 #: ../en/ch06-collab.xml:1042
dongsheng@627 8921 msgid ""
dongsheng@627 8922 "Your web server may have per-user directories disabled. If you're using "
dongsheng@627 8923 "Apache, search your config file for a <literal>UserDir</literal> directive. "
dongsheng@627 8924 "If there's none present, per-user directories will be disabled. If one "
dongsheng@627 8925 "exists, but its value is <literal>disabled</literal>, then per-user "
dongsheng@627 8926 "directories will be disabled. Otherwise, the string after <literal>UserDir</"
dongsheng@627 8927 "literal> gives the name of the subdirectory that Apache will look in under "
dongsheng@627 8928 "your home directory, for example <filename class=\"directory\">public_html</"
dongsheng@627 8929 "filename>."
dongsheng@627 8930 msgstr ""
dongsheng@627 8931
dongsheng@627 8932 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 8933 #: ../en/ch06-collab.xml:1053
dongsheng@627 8934 msgid ""
dongsheng@627 8935 "Your file access permissions may be too restrictive. The web server must be "
dongsheng@627 8936 "able to traverse your home directory and directories under your <filename "
dongsheng@627 8937 "class=\"directory\">public_html</filename> directory, and read files under "
dongsheng@627 8938 "the latter too. Here's a quick recipe to help you to make your permissions "
dongsheng@627 8939 "more appropriate."
dongsheng@627 8940 msgstr ""
dongsheng@627 8941
dongsheng@627 8942 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 8943 #: ../en/ch06-collab.xml:1063
dongsheng@627 8944 msgid ""
dongsheng@627 8945 "The other possibility with permissions is that you might get a completely "
dongsheng@627 8946 "empty window when you try to load the script. In this case, it's likely that "
dongsheng@627 8947 "your access permissions are <emphasis>too permissive</emphasis>. Apache's "
dongsheng@627 8948 "<literal>suexec</literal> subsystem won't execute a script that's group- or "
dongsheng@627 8949 "world-writable, for example."
dongsheng@627 8950 msgstr ""
dongsheng@627 8951
dongsheng@627 8952 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 8953 #: ../en/ch06-collab.xml:1070
dongsheng@627 8954 msgid ""
dongsheng@627 8955 "Your web server may be configured to disallow execution of CGI programs in "
dongsheng@627 8956 "your per-user web directory. Here's Apache's default per-user configuration "
dongsheng@627 8957 "from my Fedora system."
dongsheng@627 8958 msgstr ""
dongsheng@627 8959
dongsheng@627 8960 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 8961 #: ../en/ch06-collab.xml:1077
dongsheng@627 8962 msgid ""
dongsheng@627 8963 "If you find a similar-looking <literal>Directory</literal> group in your "
dongsheng@627 8964 "Apache configuration, the directive to look at inside it is <literal>Options</"
dongsheng@627 8965 "literal>. Add <literal>ExecCGI</literal> to the end of this list if it's "
dongsheng@627 8966 "missing, and restart the web server."
dongsheng@627 8967 msgstr ""
dongsheng@627 8968
dongsheng@627 8969 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 8970 #: ../en/ch06-collab.xml:1084
dongsheng@627 8971 msgid ""
dongsheng@627 8972 "If you find that Apache serves you the text of the CGI script instead of "
dongsheng@627 8973 "executing it, you may need to either uncomment (if already present) or add a "
dongsheng@627 8974 "directive like this."
dongsheng@627 8975 msgstr ""
dongsheng@627 8976
dongsheng@627 8977 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 8978 #: ../en/ch06-collab.xml:1090
dongsheng@627 8979 msgid ""
dongsheng@627 8980 "The next possibility is that you might be served with a colourful Python "
dongsheng@627 8981 "backtrace claiming that it can't import a <literal>mercurial</literal>-"
dongsheng@627 8982 "related module. This is actually progress! The server is now capable of "
dongsheng@627 8983 "executing your CGI script. This error is only likely to occur if you're "
dongsheng@627 8984 "running a private installation of Mercurial, instead of a system-wide "
dongsheng@627 8985 "version. Remember that the web server runs the CGI program without any of "
dongsheng@627 8986 "the environment variables that you take for granted in an interactive "
dongsheng@627 8987 "session. If this error happens to you, edit your copy of <filename role="
dongsheng@627 8988 "\"special\">hgweb.cgi</filename> and follow the directions inside it to "
dongsheng@627 8989 "correctly set your <envar>PYTHONPATH</envar> environment variable."
dongsheng@627 8990 msgstr ""
dongsheng@627 8991
dongsheng@627 8992 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 8993 #: ../en/ch06-collab.xml:1104
dongsheng@714 8994 msgid ""
dongsheng@714 8995 "Finally, you are <emphasis>certain</emphasis> to be served with another "
dongsheng@627 8996 "colourful Python backtrace: this one will complain that it can't find "
dongsheng@627 8997 "<filename class=\"directory\">/path/to/repository</filename>. Edit your "
dongsheng@627 8998 "<filename role=\"special\">hgweb.cgi</filename> script and replace the "
dongsheng@627 8999 "<filename class=\"directory\">/path/to/repository</filename> string with the "
dongsheng@627 9000 "complete path to the repository you want to serve up."
dongsheng@627 9001 msgstr ""
dongsheng@627 9002
dongsheng@627 9003 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 9004 #: ../en/ch06-collab.xml:1114
dongsheng@627 9005 msgid ""
dongsheng@627 9006 "At this point, when you try to reload the page, you should be presented with "
dongsheng@627 9007 "a nice HTML view of your repository's history. Whew!"
dongsheng@627 9008 msgstr ""
dongsheng@627 9009
dongsheng@627 9010 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
dongsheng@714 9011 #: ../en/ch06-collab.xml:1120
dongsheng@627 9012 msgid "Configuring lighttpd"
dongsheng@630 9013 msgstr "配置 lighttpd"
dongsheng@627 9014
dongsheng@627 9015 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 9016 #: ../en/ch06-collab.xml:1122
dongsheng@627 9017 msgid ""
dongsheng@627 9018 "To be exhaustive in my experiments, I tried configuring the increasingly "
dongsheng@627 9019 "popular <literal>lighttpd</literal> web server to serve the same repository "
dongsheng@627 9020 "as I described with Apache above. I had already overcome all of the problems "
dongsheng@627 9021 "I outlined with Apache, many of which are not server-specific. As a result, "
dongsheng@627 9022 "I was fairly sure that my file and directory permissions were good, and that "
dongsheng@627 9023 "my <filename role=\"special\">hgweb.cgi</filename> script was properly edited."
dongsheng@627 9024 msgstr ""
dongsheng@627 9025
dongsheng@627 9026 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 9027 #: ../en/ch06-collab.xml:1132
dongsheng@627 9028 msgid ""
dongsheng@627 9029 "Once I had Apache running, getting <literal>lighttpd</literal> to serve the "
dongsheng@627 9030 "repository was a snap (in other words, even if you're trying to use "
dongsheng@627 9031 "<literal>lighttpd</literal>, you should read the Apache section). I first "
dongsheng@627 9032 "had to edit the <literal>mod_access</literal> section of its config file to "
dongsheng@627 9033 "enable <literal>mod_cgi</literal> and <literal>mod_userdir</literal>, both of "
dongsheng@627 9034 "which were disabled by default on my system. I then added a few lines to the "
dongsheng@627 9035 "end of the config file, to configure these modules."
dongsheng@627 9036 msgstr ""
dongsheng@627 9037
dongsheng@627 9038 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 9039 #: ../en/ch06-collab.xml:1144
dongsheng@627 9040 msgid ""
dongsheng@627 9041 "With this done, <literal>lighttpd</literal> ran immediately for me. If I had "
dongsheng@627 9042 "configured <literal>lighttpd</literal> before Apache, I'd almost certainly "
dongsheng@627 9043 "have run into many of the same system-level configuration problems as I did "
dongsheng@627 9044 "with Apache. However, I found <literal>lighttpd</literal> to be noticeably "
dongsheng@627 9045 "easier to configure than Apache, even though I've used Apache for over a "
dongsheng@627 9046 "decade, and this was my first exposure to <literal>lighttpd</literal>."
dongsheng@627 9047 msgstr ""
dongsheng@627 9048
dongsheng@627 9049 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 9050 #: ../en/ch06-collab.xml:1157
dongsheng@627 9051 msgid "Sharing multiple repositories with one CGI script"
dongsheng@630 9052 msgstr "使用一个 CGI 脚本共享多个版本库"
dongsheng@627 9053
dongsheng@627 9054 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 9055 #: ../en/ch06-collab.xml:1159
dongsheng@627 9056 msgid ""
dongsheng@627 9057 "The <filename role=\"special\">hgweb.cgi</filename> script only lets you "
dongsheng@627 9058 "publish a single repository, which is an annoying restriction. If you want "
dongsheng@627 9059 "to publish more than one without wracking yourself with multiple copies of "
dongsheng@627 9060 "the same script, each with different names, a better choice is to use the "
dongsheng@627 9061 "<filename role=\"special\">hgwebdir.cgi</filename> script."
dongsheng@627 9062 msgstr ""
dongsheng@627 9063
dongsheng@627 9064 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 9065 #: ../en/ch06-collab.xml:1167
dongsheng@627 9066 msgid ""
dongsheng@627 9067 "The procedure to configure <filename role=\"special\">hgwebdir.cgi</filename> "
dongsheng@627 9068 "is only a little more involved than for <filename role=\"special\">hgweb.cgi</"
dongsheng@627 9069 "filename>. First, you must obtain a copy of the script. If you don't have "
dongsheng@627 9070 "one handy, you can download a copy from the master Mercurial repository at "
dongsheng@627 9071 "<ulink url=\"http://www.selenic.com/repo/hg/raw-file/tip/hgwebdir.cgi"
dongsheng@627 9072 "\">http://www.selenic.com/repo/hg/raw-file/tip/hgwebdir.cgi</ulink>."
dongsheng@627 9073 msgstr ""
dongsheng@627 9074
dongsheng@627 9075 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 9076 #: ../en/ch06-collab.xml:1182
dongsheng@714 9077 msgid ""
dongsheng@714 9078 "With basic configuration out of the way, try to visit <literal>http://"
dongsheng@714 9079 "myhostname/~myuser/hgwebdir.cgi</literal> in your\tbrowser. It should "
dongsheng@714 9080 "display an empty list of repositories. If you get a blank window or error "
dongsheng@714 9081 "message, try walking through the list of potential problems in <xref linkend="
dongsheng@714 9082 "\"sec:collab:wtf\"/>."
dongsheng@714 9083 msgstr ""
dongsheng@714 9084
dongsheng@714 9085 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 9086 #: ../en/ch06-collab.xml:1190
dongsheng@627 9087 msgid ""
dongsheng@627 9088 "The <filename role=\"special\">hgwebdir.cgi</filename> script relies on an "
dongsheng@627 9089 "external configuration file. By default, it searches for a file named "
dongsheng@627 9090 "<filename role=\"special\">hgweb.config</filename> in the same directory as "
dongsheng@627 9091 "itself. You'll need to create this file, and make it world-readable. The "
dongsheng@627 9092 "format of the file is similar to a Windows <quote>ini</quote> file, as "
dongsheng@627 9093 "understood by Python's <literal>ConfigParser</literal> <citation>web:"
dongsheng@627 9094 "configparser</citation> module."
dongsheng@627 9095 msgstr ""
dongsheng@627 9096
dongsheng@627 9097 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 9098 #: ../en/ch06-collab.xml:1200
dongsheng@627 9099 msgid ""
dongsheng@627 9100 "The easiest way to configure <filename role=\"special\">hgwebdir.cgi</"
dongsheng@627 9101 "filename> is with a section named <literal>collections</literal>. This will "
dongsheng@627 9102 "automatically publish <emphasis>every</emphasis> repository under the "
dongsheng@627 9103 "directories you name. The section should look like this:"
dongsheng@627 9104 msgstr ""
dongsheng@627 9105
dongsheng@627 9106 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 9107 #: ../en/ch06-collab.xml:1208
dongsheng@627 9108 msgid ""
dongsheng@627 9109 "Mercurial interprets this by looking at the directory name on the "
dongsheng@627 9110 "<emphasis>right</emphasis> hand side of the <quote><literal>=</literal></"
dongsheng@627 9111 "quote> sign; finding repositories in that directory hierarchy; and using the "
dongsheng@627 9112 "text on the <emphasis>left</emphasis> to strip off matching text from the "
dongsheng@627 9113 "names it will actually list in the web interface. The remaining component of "
dongsheng@627 9114 "a path after this stripping has occurred is called a <quote>virtual path</"
dongsheng@627 9115 "quote>."
dongsheng@627 9116 msgstr ""
dongsheng@627 9117
dongsheng@627 9118 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 9119 #: ../en/ch06-collab.xml:1217
dongsheng@627 9120 msgid ""
dongsheng@627 9121 "Given the example above, if we have a repository whose local path is "
dongsheng@627 9122 "<filename class=\"directory\">/my/root/this/repo</filename>, the CGI script "
dongsheng@627 9123 "will strip the leading <filename class=\"directory\">/my/root</filename> from "
dongsheng@627 9124 "the name, and publish the repository with a virtual path of <filename class="
dongsheng@627 9125 "\"directory\">this/repo</filename>. If the base URL for our CGI script is "
dongsheng@714 9126 "<literal>http://myhostname/~myuser/hgwebdir.cgi</literal>, the complete URL "
dongsheng@714 9127 "for that repository will be <literal>http://myhostname/~myuser/hgwebdir.cgi/"
dongsheng@714 9128 "this/repo</literal>."
dongsheng@714 9129 msgstr ""
dongsheng@714 9130
dongsheng@714 9131 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 9132 #: ../en/ch06-collab.xml:1229
dongsheng@627 9133 msgid ""
dongsheng@627 9134 "If we replace <filename class=\"directory\">/my/root</filename> on the left "
dongsheng@627 9135 "hand side of this example with <filename class=\"directory\">/my</filename>, "
dongsheng@627 9136 "then <filename role=\"special\">hgwebdir.cgi</filename> will only strip off "
dongsheng@627 9137 "<filename class=\"directory\">/my</filename> from the repository name, and "
dongsheng@627 9138 "will give us a virtual path of <filename class=\"directory\">root/this/repo</"
dongsheng@627 9139 "filename> instead of <filename class=\"directory\">this/repo</filename>."
dongsheng@627 9140 msgstr ""
dongsheng@627 9141
dongsheng@627 9142 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 9143 #: ../en/ch06-collab.xml:1239
dongsheng@627 9144 msgid ""
dongsheng@627 9145 "The <filename role=\"special\">hgwebdir.cgi</filename> script will "
dongsheng@627 9146 "recursively search each directory listed in the <literal>collections</"
dongsheng@627 9147 "literal> section of its configuration file, but it will <literal>not</"
dongsheng@627 9148 "literal> recurse into the repositories it finds."
dongsheng@627 9149 msgstr ""
dongsheng@627 9150
dongsheng@627 9151 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 9152 #: ../en/ch06-collab.xml:1245
dongsheng@627 9153 msgid ""
dongsheng@627 9154 "The <literal>collections</literal> mechanism makes it easy to publish many "
dongsheng@627 9155 "repositories in a <quote>fire and forget</quote> manner. You only need to "
dongsheng@627 9156 "set up the CGI script and configuration file one time. Afterwards, you can "
dongsheng@627 9157 "publish or unpublish a repository at any time by simply moving it into, or "
dongsheng@627 9158 "out of, the directory hierarchy in which you've configured <filename role="
dongsheng@627 9159 "\"special\">hgwebdir.cgi</filename> to look."
dongsheng@627 9160 msgstr ""
dongsheng@627 9161
dongsheng@627 9162 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
dongsheng@714 9163 #: ../en/ch06-collab.xml:1255
dongsheng@627 9164 msgid "Explicitly specifying which repositories to publish"
dongsheng@630 9165 msgstr "明确指出要发布的版本库"
dongsheng@627 9166
dongsheng@627 9167 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 9168 #: ../en/ch06-collab.xml:1258
dongsheng@627 9169 msgid ""
dongsheng@627 9170 "In addition to the <literal>collections</literal> mechanism, the <filename "
dongsheng@627 9171 "role=\"special\">hgwebdir.cgi</filename> script allows you to publish a "
dongsheng@627 9172 "specific list of repositories. To do so, create a <literal>paths</literal> "
dongsheng@627 9173 "section, with contents of the following form."
dongsheng@627 9174 msgstr ""
dongsheng@627 9175
dongsheng@627 9176 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 9177 #: ../en/ch06-collab.xml:1267
dongsheng@627 9178 msgid ""
dongsheng@627 9179 "In this case, the virtual path (the component that will appear in a URL) is "
dongsheng@627 9180 "on the left hand side of each definition, while the path to the repository is "
dongsheng@627 9181 "on the right. Notice that there does not need to be any relationship between "
dongsheng@627 9182 "the virtual path you choose and the location of a repository in your "
dongsheng@627 9183 "filesystem."
dongsheng@627 9184 msgstr ""
dongsheng@627 9185
dongsheng@627 9186 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 9187 #: ../en/ch06-collab.xml:1274
dongsheng@627 9188 msgid ""
dongsheng@627 9189 "If you wish, you can use both the <literal>collections</literal> and "
dongsheng@627 9190 "<literal>paths</literal> mechanisms simultaneously in a single configuration "
dongsheng@627 9191 "file."
dongsheng@627 9192 msgstr ""
dongsheng@627 9193
songdongsheng@710 9194 #. type: Content of: <book><chapter><sect1><sect2><sect3><note><title>
dongsheng@714 9195 #: ../en/ch06-collab.xml:1280
songdongsheng@710 9196 msgid "Beware duplicate virtual paths"
songdongsheng@710 9197 msgstr ""
songdongsheng@710 9198
dongsheng@627 9199 #. type: Content of: <book><chapter><sect1><sect2><sect3><note><para>
dongsheng@714 9200 #: ../en/ch06-collab.xml:1282
songdongsheng@710 9201 msgid ""
songdongsheng@710 9202 "If several repositories have the same virtual path, <filename role=\"special"
dongsheng@627 9203 "\">hgwebdir.cgi</filename> will not report an error. Instead, it will behave "
dongsheng@627 9204 "unpredictably."
dongsheng@627 9205 msgstr ""
dongsheng@627 9206
dongsheng@627 9207 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 9208 #: ../en/ch06-collab.xml:1291
dongsheng@627 9209 msgid "Downloading source archives"
dongsheng@630 9210 msgstr "下载源代码档案包"
dongsheng@627 9211
dongsheng@627 9212 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 9213 #: ../en/ch06-collab.xml:1293
dongsheng@627 9214 msgid ""
dongsheng@627 9215 "Mercurial's web interface lets users download an archive of any revision. "
dongsheng@627 9216 "This archive will contain a snapshot of the working directory as of that "
dongsheng@627 9217 "revision, but it will not contain a copy of the repository data."
dongsheng@627 9218 msgstr ""
dongsheng@627 9219
dongsheng@627 9220 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 9221 #: ../en/ch06-collab.xml:1298
dongsheng@627 9222 msgid ""
dongsheng@627 9223 "By default, this feature is not enabled. To enable it, you'll need to add an "
dongsheng@627 9224 "<envar role=\"rc-item-web\">allow_archive</envar> item to the <literal role="
dongsheng@650 9225 "\"rc-web\">web</literal> section of your <filename role=\"special\">~/.hgrc</"
songdongsheng@710 9226 "filename>; see below for details."
songdongsheng@710 9227 msgstr ""
songdongsheng@710 9228
songdongsheng@710 9229 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 9230 #: ../en/ch06-collab.xml:1305
dongsheng@627 9231 msgid "Web configuration options"
dongsheng@630 9232 msgstr "Web 配置选项"
dongsheng@627 9233
dongsheng@627 9234 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 9235 #: ../en/ch06-collab.xml:1307
dongsheng@627 9236 msgid ""
dongsheng@627 9237 "Mercurial's web interfaces (the <command role=\"hg-cmd\">hg serve</command> "
dongsheng@627 9238 "command, and the <filename role=\"special\">hgweb.cgi</filename> and "
dongsheng@627 9239 "<filename role=\"special\">hgwebdir.cgi</filename> scripts) have a number of "
dongsheng@627 9240 "configuration options that you can set. These belong in a section named "
dongsheng@627 9241 "<literal role=\"rc-web\">web</literal>."
dongsheng@627 9242 msgstr ""
dongsheng@627 9243
dongsheng@627 9244 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 9245 #: ../en/ch06-collab.xml:1315
dongsheng@627 9246 msgid ""
dongsheng@627 9247 "<envar role=\"rc-item-web\">allow_archive</envar>: Determines which (if any) "
dongsheng@627 9248 "archive download mechanisms Mercurial supports. If you enable this feature, "
dongsheng@627 9249 "users of the web interface will be able to download an archive of whatever "
dongsheng@627 9250 "revision of a repository they are viewing. To enable the archive feature, "
dongsheng@627 9251 "this item must take the form of a sequence of words drawn from the list below."
dongsheng@627 9252 msgstr ""
dongsheng@627 9253
dongsheng@627 9254 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
dongsheng@714 9255 #: ../en/ch06-collab.xml:1324
dongsheng@627 9256 msgid ""
dongsheng@627 9257 "<literal>bz2</literal>: A <command>tar</command> archive, compressed using "
dongsheng@627 9258 "<literal>bzip2</literal> compression. This has the best compression ratio, "
dongsheng@627 9259 "but uses the most CPU time on the server."
dongsheng@627 9260 msgstr ""
dongsheng@627 9261
dongsheng@627 9262 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
dongsheng@714 9263 #: ../en/ch06-collab.xml:1330
dongsheng@627 9264 msgid ""
dongsheng@627 9265 "<literal>gz</literal>: A <command>tar</command> archive, compressed using "
dongsheng@627 9266 "<literal>gzip</literal> compression."
dongsheng@627 9267 msgstr ""
dongsheng@627 9268
dongsheng@627 9269 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
dongsheng@714 9270 #: ../en/ch06-collab.xml:1334
dongsheng@627 9271 msgid ""
dongsheng@627 9272 "<literal>zip</literal>: A <command>zip</command> archive, compressed using "
dongsheng@627 9273 "LZW compression. This format has the worst compression ratio, but is widely "
dongsheng@627 9274 "used in the Windows world."
dongsheng@627 9275 msgstr ""
dongsheng@627 9276
dongsheng@627 9277 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 9278 #: ../en/ch06-collab.xml:1340
dongsheng@627 9279 msgid ""
dongsheng@627 9280 "If you provide an empty list, or don't have an <envar role=\"rc-item-web"
dongsheng@627 9281 "\">allow_archive</envar> entry at all, this feature will be disabled. Here "
dongsheng@627 9282 "is an example of how to enable all three supported formats."
dongsheng@627 9283 msgstr ""
dongsheng@627 9284
dongsheng@627 9285 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 9286 #: ../en/ch06-collab.xml:1347
dongsheng@627 9287 msgid ""
dongsheng@627 9288 "<envar role=\"rc-item-web\">allowpull</envar>: Boolean. Determines whether "
dongsheng@627 9289 "the web interface allows remote users to <command role=\"hg-cmd\">hg pull</"
dongsheng@627 9290 "command> and <command role=\"hg-cmd\">hg clone</command> this repository over "
dongsheng@627 9291 "HTTP. If set to <literal>no</literal> or <literal>false</literal>, only the "
dongsheng@627 9292 "<quote>human-oriented</quote> portion of the web interface is available."
dongsheng@627 9293 msgstr ""
dongsheng@627 9294
dongsheng@627 9295 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 9296 #: ../en/ch06-collab.xml:1356
dongsheng@627 9297 msgid ""
dongsheng@627 9298 "<envar role=\"rc-item-web\">contact</envar>: String. A free-form (but "
dongsheng@627 9299 "preferably brief) string identifying the person or group in charge of the "
dongsheng@627 9300 "repository. This often contains the name and email address of a person or "
dongsheng@627 9301 "mailing list. It often makes sense to place this entry in a repository's own "
dongsheng@627 9302 "<filename role=\"special\">.hg/hgrc</filename> file, but it can make sense to "
dongsheng@650 9303 "use in a global <filename role=\"special\">~/.hgrc</filename> if every "
dongsheng@627 9304 "repository has a single maintainer."
dongsheng@627 9305 msgstr ""
dongsheng@627 9306
dongsheng@627 9307 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 9308 #: ../en/ch06-collab.xml:1367
dongsheng@627 9309 msgid ""
dongsheng@627 9310 "<envar role=\"rc-item-web\">maxchanges</envar>: Integer. The default maximum "
dongsheng@627 9311 "number of changesets to display in a single page of output."
dongsheng@627 9312 msgstr ""
dongsheng@627 9313
dongsheng@627 9314 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 9315 #: ../en/ch06-collab.xml:1371
dongsheng@627 9316 msgid ""
dongsheng@627 9317 "<envar role=\"rc-item-web\">maxfiles</envar>: Integer. The default maximum "
dongsheng@627 9318 "number of modified files to display in a single page of output."
dongsheng@627 9319 msgstr ""
dongsheng@627 9320
dongsheng@627 9321 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 9322 #: ../en/ch06-collab.xml:1375
dongsheng@627 9323 msgid ""
dongsheng@627 9324 "<envar role=\"rc-item-web\">stripes</envar>: Integer. If the web interface "
dongsheng@627 9325 "displays alternating <quote>stripes</quote> to make it easier to visually "
dongsheng@627 9326 "align rows when you are looking at a table, this number controls the number "
dongsheng@627 9327 "of rows in each stripe."
dongsheng@627 9328 msgstr ""
dongsheng@627 9329
dongsheng@627 9330 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 9331 #: ../en/ch06-collab.xml:1381
dongsheng@627 9332 msgid ""
dongsheng@627 9333 "<envar role=\"rc-item-web\">style</envar>: Controls the template Mercurial "
songdongsheng@710 9334 "uses to display the web interface. Mercurial ships with several web "
songdongsheng@710 9335 "templates."
songdongsheng@710 9336 msgstr ""
songdongsheng@710 9337
songdongsheng@710 9338 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
dongsheng@714 9339 #: ../en/ch06-collab.xml:1387
songdongsheng@710 9340 msgid "<literal>coal</literal> is monochromatic."
songdongsheng@710 9341 msgstr ""
songdongsheng@710 9342
songdongsheng@710 9343 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
dongsheng@714 9344 #: ../en/ch06-collab.xml:1390
songdongsheng@710 9345 msgid ""
songdongsheng@710 9346 "<literal>gitweb</literal> emulates the visual style of git's web interface."
songdongsheng@710 9347 msgstr ""
songdongsheng@710 9348
songdongsheng@710 9349 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
dongsheng@714 9350 #: ../en/ch06-collab.xml:1394
songdongsheng@710 9351 msgid "<literal>monoblue</literal> uses solid blues and greys."
songdongsheng@710 9352 msgstr ""
songdongsheng@710 9353
songdongsheng@710 9354 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
dongsheng@714 9355 #: ../en/ch06-collab.xml:1398
songdongsheng@710 9356 msgid "<literal>paper</literal> is the default."
songdongsheng@710 9357 msgstr ""
songdongsheng@710 9358
songdongsheng@710 9359 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
dongsheng@714 9360 #: ../en/ch06-collab.xml:1401
songdongsheng@710 9361 msgid "<literal>spartan</literal> was the default for a long time."
dongsheng@627 9362 msgstr ""
dongsheng@627 9363
dongsheng@627 9364 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 9365 #: ../en/ch06-collab.xml:1405
songdongsheng@710 9366 msgid ""
songdongsheng@710 9367 "You can also specify a custom template of your own; see <xref linkend=\"chap:"
songdongsheng@710 9368 "template\"/> for details. Here, you can see how to enable the "
songdongsheng@710 9369 "<literal>gitweb</literal> style."
songdongsheng@710 9370 msgstr ""
songdongsheng@710 9371
songdongsheng@710 9372 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 9373 #: ../en/ch06-collab.xml:1413
dongsheng@627 9374 msgid ""
dongsheng@627 9375 "<envar role=\"rc-item-web\">templates</envar>: Path. The directory in which "
dongsheng@627 9376 "to search for template files. By default, Mercurial searches in the "
dongsheng@627 9377 "directory in which it was installed."
dongsheng@627 9378 msgstr ""
dongsheng@627 9379
dongsheng@627 9380 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 9381 #: ../en/ch06-collab.xml:1418
dongsheng@627 9382 msgid ""
dongsheng@627 9383 "If you are using <filename role=\"special\">hgwebdir.cgi</filename>, you can "
dongsheng@627 9384 "place a few configuration items in a <literal role=\"rc-web\">web</literal> "
dongsheng@627 9385 "section of the <filename role=\"special\">hgweb.config</filename> file "
dongsheng@650 9386 "instead of a <filename role=\"special\">~/.hgrc</filename> file, for "
dongsheng@627 9387 "convenience. These items are <envar role=\"rc-item-web\">motd</envar> and "
dongsheng@627 9388 "<envar role=\"rc-item-web\">style</envar>."
dongsheng@627 9389 msgstr ""
dongsheng@627 9390
dongsheng@627 9391 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
dongsheng@714 9392 #: ../en/ch06-collab.xml:1429
dongsheng@627 9393 msgid "Options specific to an individual repository"
dongsheng@630 9394 msgstr "针对单个版本库的选项"
dongsheng@627 9395
dongsheng@627 9396 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 9397 #: ../en/ch06-collab.xml:1431
dongsheng@627 9398 msgid ""
dongsheng@627 9399 "A few <literal role=\"rc-web\">web</literal> configuration items ought to be "
dongsheng@627 9400 "placed in a repository's local <filename role=\"special\">.hg/hgrc</"
dongsheng@650 9401 "filename>, rather than a user's or global <filename role=\"special\">~/.hgrc</"
dongsheng@627 9402 "filename>."
dongsheng@627 9403 msgstr ""
dongsheng@627 9404
dongsheng@627 9405 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@714 9406 #: ../en/ch06-collab.xml:1436
dongsheng@627 9407 msgid ""
dongsheng@627 9408 "<envar role=\"rc-item-web\">description</envar>: String. A free-form (but "
dongsheng@627 9409 "preferably brief) string that describes the contents or purpose of the "
dongsheng@627 9410 "repository."
dongsheng@627 9411 msgstr ""
dongsheng@627 9412
dongsheng@627 9413 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@714 9414 #: ../en/ch06-collab.xml:1441
dongsheng@627 9415 msgid ""
dongsheng@627 9416 "<envar role=\"rc-item-web\">name</envar>: String. The name to use for the "
dongsheng@627 9417 "repository in the web interface. This overrides the default name, which is "
dongsheng@627 9418 "the last component of the repository's path."
dongsheng@627 9419 msgstr ""
dongsheng@627 9420
dongsheng@627 9421 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
dongsheng@714 9422 #: ../en/ch06-collab.xml:1449
dongsheng@627 9423 msgid ""
dongsheng@627 9424 "Options specific to the <command role=\"hg-cmd\">hg serve</command> command"
dongsheng@630 9425 msgstr "命令 <command role=\"hg-cmd\">hg serve</command> 的选项"
dongsheng@627 9426
dongsheng@627 9427 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 9428 #: ../en/ch06-collab.xml:1452
dongsheng@627 9429 msgid ""
dongsheng@627 9430 "Some of the items in the <literal role=\"rc-web\">web</literal> section of a "
dongsheng@650 9431 "<filename role=\"special\">~/.hgrc</filename> file are only for use with the "
dongsheng@650 9432 "<command role=\"hg-cmd\">hg serve</command> command."
dongsheng@627 9433 msgstr ""
dongsheng@627 9434
dongsheng@627 9435 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@714 9436 #: ../en/ch06-collab.xml:1458
dongsheng@627 9437 msgid ""
dongsheng@627 9438 "<envar role=\"rc-item-web\">accesslog</envar>: Path. The name of a file into "
dongsheng@627 9439 "which to write an access log. By default, the <command role=\"hg-cmd\">hg "
dongsheng@627 9440 "serve</command> command writes this information to standard output, not to a "
dongsheng@627 9441 "file. Log entries are written in the standard <quote>combined</quote> file "
dongsheng@627 9442 "format used by almost all web servers."
dongsheng@627 9443 msgstr ""
dongsheng@627 9444
dongsheng@627 9445 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@714 9446 #: ../en/ch06-collab.xml:1466
dongsheng@627 9447 msgid ""
dongsheng@627 9448 "<envar role=\"rc-item-web\">address</envar>: String. The local address on "
dongsheng@627 9449 "which the server should listen for incoming connections. By default, the "
dongsheng@627 9450 "server listens on all addresses."
dongsheng@627 9451 msgstr ""
dongsheng@627 9452
dongsheng@627 9453 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@714 9454 #: ../en/ch06-collab.xml:1471
dongsheng@627 9455 msgid ""
dongsheng@627 9456 "<envar role=\"rc-item-web\">errorlog</envar>: Path. The name of a file into "
dongsheng@627 9457 "which to write an error log. By default, the <command role=\"hg-cmd\">hg "
dongsheng@627 9458 "serve</command> command writes this information to standard error, not to a "
dongsheng@627 9459 "file."
dongsheng@627 9460 msgstr ""
dongsheng@627 9461
dongsheng@627 9462 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@714 9463 #: ../en/ch06-collab.xml:1477
dongsheng@627 9464 msgid ""
dongsheng@627 9465 "<envar role=\"rc-item-web\">ipv6</envar>: Boolean. Whether to use the IPv6 "
dongsheng@627 9466 "protocol. By default, IPv6 is not used."
dongsheng@627 9467 msgstr ""
dongsheng@627 9468
dongsheng@627 9469 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@714 9470 #: ../en/ch06-collab.xml:1481
dongsheng@627 9471 msgid ""
dongsheng@627 9472 "<envar role=\"rc-item-web\">port</envar>: Integer. The TCP port number on "
dongsheng@627 9473 "which the server should listen. The default port number used is 8000."
dongsheng@627 9474 msgstr ""
dongsheng@627 9475
dongsheng@627 9476 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
dongsheng@714 9477 #: ../en/ch06-collab.xml:1488
dongsheng@650 9478 msgid ""
dongsheng@650 9479 "Choosing the right <filename role=\"special\">~/.hgrc</filename> file to add "
dongsheng@650 9480 "<literal role=\"rc-web\">web</literal> items to"
dongsheng@627 9481 msgstr ""
dongsheng@653 9482 "选择正确的 <filename role=\"special\"> ~/.hgrc</filename> 文件增加到 <literal "
dongsheng@630 9483 "role=\"rc-web\">web</literal> 条目"
dongsheng@627 9484
dongsheng@627 9485 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 9486 #: ../en/ch06-collab.xml:1492
dongsheng@627 9487 msgid ""
dongsheng@627 9488 "It is important to remember that a web server like Apache or "
dongsheng@627 9489 "<literal>lighttpd</literal> will run under a user ID that is different to "
dongsheng@627 9490 "yours. CGI scripts run by your server, such as <filename role=\"special"
dongsheng@627 9491 "\">hgweb.cgi</filename>, will usually also run under that user ID."
dongsheng@627 9492 msgstr ""
dongsheng@627 9493
dongsheng@627 9494 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 9495 #: ../en/ch06-collab.xml:1499
dongsheng@627 9496 msgid ""
dongsheng@627 9497 "If you add <literal role=\"rc-web\">web</literal> items to your own personal "
dongsheng@650 9498 "<filename role=\"special\">~/.hgrc</filename> file, CGI scripts won't read "
dongsheng@650 9499 "that <filename role=\"special\">~/.hgrc</filename> file. Those settings will "
songdongsheng@710 9500 "thus only affect the behavior of the <command role=\"hg-cmd\">hg serve</"
dongsheng@627 9501 "command> command when you run it. To cause CGI scripts to see your settings, "
dongsheng@650 9502 "either create a <filename role=\"special\">~/.hgrc</filename> file in the "
dongsheng@627 9503 "home directory of the user ID that runs your web server, or add those "
songdongsheng@710 9504 "settings to a system-wide <filename role=\"special\">hgrc</filename> file."
songdongsheng@710 9505 msgstr ""
songdongsheng@710 9506
songdongsheng@710 9507 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 9508 #: ../en/ch06-collab.xml:1514
songdongsheng@710 9509 msgid "System-wide configuration"
songdongsheng@711 9510 msgstr "全局配置"
songdongsheng@710 9511
songdongsheng@710 9512 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 9513 #: ../en/ch06-collab.xml:1516
songdongsheng@710 9514 msgid ""
songdongsheng@710 9515 "On Unix-like systems shared by multiple users (such as a server to which "
songdongsheng@710 9516 "people publish changes), it often makes sense to set up some global default "
songdongsheng@710 9517 "behaviors, such as what theme to use in web interfaces."
songdongsheng@710 9518 msgstr ""
songdongsheng@710 9519
songdongsheng@710 9520 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 9521 #: ../en/ch06-collab.xml:1521
songdongsheng@710 9522 msgid ""
songdongsheng@710 9523 "If a file named <filename>/etc/mercurial/hgrc</filename> exists, Mercurial "
songdongsheng@710 9524 "will read it at startup time and apply any configuration settings it finds in "
songdongsheng@710 9525 "that file. It will also look for files ending in a <literal>.rc</literal> "
songdongsheng@710 9526 "extension in a directory named <filename>/etc/mercurial/hgrc.d</filename>, "
songdongsheng@710 9527 "and apply any configuration settings it finds in each of those files."
songdongsheng@710 9528 msgstr ""
songdongsheng@710 9529
songdongsheng@710 9530 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 9531 #: ../en/ch06-collab.xml:1530
songdongsheng@710 9532 msgid "Making Mercurial more trusting"
songdongsheng@711 9533 msgstr "让 Mercurial 更可信"
songdongsheng@710 9534
songdongsheng@710 9535 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 9536 #: ../en/ch06-collab.xml:1532
songdongsheng@710 9537 msgid ""
songdongsheng@710 9538 "One situation in which a global <filename>hgrc</filename> can be useful is if "
songdongsheng@710 9539 "users are pulling changes owned by other users. By default, Mercurial will "
songdongsheng@710 9540 "not trust most of the configuration items in a <filename>.hg/hgrc</filename> "
songdongsheng@710 9541 "file inside a repository that is owned by a different user. If we clone or "
songdongsheng@710 9542 "pull changes from such a repository, Mercurial will print a warning stating "
songdongsheng@710 9543 "that it does not trust their <filename>.hg/hgrc</filename>."
songdongsheng@710 9544 msgstr ""
songdongsheng@710 9545
songdongsheng@710 9546 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 9547 #: ../en/ch06-collab.xml:1541
songdongsheng@710 9548 msgid ""
songdongsheng@710 9549 "If everyone in a particular Unix group is on the same team and "
songdongsheng@710 9550 "<emphasis>should</emphasis> trust each other's configuration settings, or we "
songdongsheng@710 9551 "want to trust particular users, we can override Mercurial's skeptical "
songdongsheng@710 9552 "defaults by creating a system-wide <filename>hgrc</filename> file such as the "
songdongsheng@710 9553 "following:"
dongsheng@627 9554 msgstr ""
dongsheng@627 9555
dongsheng@627 9556 #. type: Content of: <book><chapter><title>
dongsheng@714 9557 #: ../en/ch07-filenames.xml:5
dongsheng@627 9558 msgid "File names and pattern matching"
dongsheng@627 9559 msgstr "文件名称与模式匹配"
dongsheng@627 9560
dongsheng@627 9561 #. type: Content of: <book><chapter><para>
dongsheng@714 9562 #: ../en/ch07-filenames.xml:7
dongsheng@627 9563 msgid ""
dongsheng@627 9564 "Mercurial provides mechanisms that let you work with file names in a "
dongsheng@627 9565 "consistent and expressive way."
dongsheng@627 9566 msgstr ""
dongsheng@627 9567
dongsheng@627 9568 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 9569 #: ../en/ch07-filenames.xml:11
dongsheng@627 9570 msgid "Simple file naming"
dongsheng@630 9571 msgstr "简单文件名称"
dongsheng@627 9572
dongsheng@627 9573 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 9574 #: ../en/ch07-filenames.xml:13
dongsheng@627 9575 msgid ""
dongsheng@627 9576 "Mercurial uses a unified piece of machinery <quote>under the hood</quote> to "
dongsheng@627 9577 "handle file names. Every command behaves uniformly with respect to file "
dongsheng@627 9578 "names. The way in which commands work with file names is as follows."
dongsheng@627 9579 msgstr ""
dongsheng@627 9580
dongsheng@627 9581 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 9582 #: ../en/ch07-filenames.xml:18
dongsheng@627 9583 msgid ""
dongsheng@627 9584 "If you explicitly name real files on the command line, Mercurial works with "
dongsheng@627 9585 "exactly those files, as you would expect. &interaction.filenames.files;"
dongsheng@627 9586 msgstr ""
dongsheng@627 9587
dongsheng@627 9588 #
dongsheng@627 9589 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 9590 #: ../en/ch07-filenames.xml:22
dongsheng@627 9591 msgid ""
dongsheng@627 9592 "When you provide a directory name, Mercurial will interpret this as "
dongsheng@627 9593 "<quote>operate on every file in this directory and its subdirectories</"
dongsheng@627 9594 "quote>. Mercurial traverses the files and subdirectories in a directory in "
dongsheng@627 9595 "alphabetical order. When it encounters a subdirectory, it will traverse that "
dongsheng@627 9596 "subdirectory before continuing with the current directory."
dongsheng@627 9597 msgstr ""
dongsheng@627 9598
dongsheng@627 9599 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 9600 #: ../en/ch07-filenames.xml:33
dongsheng@627 9601 msgid "Running commands without any file names"
dongsheng@630 9602 msgstr "不提供文件名称的执行命令"
dongsheng@627 9603
dongsheng@627 9604 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 9605 #: ../en/ch07-filenames.xml:35
dongsheng@627 9606 msgid ""
songdongsheng@710 9607 "Mercurial's commands that work with file names have useful default behaviors "
dongsheng@627 9608 "when you invoke them without providing any file names or patterns. What kind "
songdongsheng@710 9609 "of behavior you should expect depends on what the command does. Here are a "
dongsheng@627 9610 "few rules of thumb you can use to predict what a command is likely to do if "
dongsheng@627 9611 "you don't give it any names to work with."
dongsheng@627 9612 msgstr ""
dongsheng@627 9613
dongsheng@627 9614 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 9615 #: ../en/ch07-filenames.xml:42
dongsheng@627 9616 msgid ""
dongsheng@627 9617 "Most commands will operate on the entire working directory. This is what the "
dongsheng@627 9618 "<command role=\"hg-cmd\">hg add</command> command does, for example."
dongsheng@627 9619 msgstr ""
dongsheng@627 9620
dongsheng@627 9621 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 9622 #: ../en/ch07-filenames.xml:46
dongsheng@627 9623 msgid ""
dongsheng@627 9624 "If the command has effects that are difficult or impossible to reverse, it "
dongsheng@627 9625 "will force you to explicitly provide at least one name or pattern (see "
dongsheng@627 9626 "below). This protects you from accidentally deleting files by running "
dongsheng@627 9627 "<command role=\"hg-cmd\">hg remove</command> with no arguments, for example."
dongsheng@627 9628 msgstr ""
dongsheng@627 9629
dongsheng@627 9630 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 9631 #: ../en/ch07-filenames.xml:54
dongsheng@627 9632 msgid ""
songdongsheng@710 9633 "It's easy to work around these default behaviors if they don't suit you. If "
dongsheng@627 9634 "a command normally operates on the whole working directory, you can invoke it "
dongsheng@627 9635 "on just the current directory and its subdirectories by giving it the name "
dongsheng@627 9636 "<quote><filename class=\"directory\">.</filename></quote>."
dongsheng@627 9637 msgstr ""
dongsheng@627 9638
dongsheng@627 9639 #
dongsheng@627 9640 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 9641 #: ../en/ch07-filenames.xml:62
dongsheng@627 9642 msgid ""
dongsheng@627 9643 "Along the same lines, some commands normally print file names relative to the "
dongsheng@627 9644 "root of the repository, even if you're invoking them from a subdirectory. "
dongsheng@627 9645 "Such a command will print file names relative to your subdirectory if you "
dongsheng@627 9646 "give it explicit names. Here, we're going to run <command role=\"hg-cmd\">hg "
dongsheng@627 9647 "status</command> from a subdirectory, and get it to operate on the entire "
dongsheng@627 9648 "working directory while printing file names relative to our subdirectory, by "
dongsheng@627 9649 "passing it the output of the <command role=\"hg-cmd\">hg root</command> "
dongsheng@627 9650 "command."
dongsheng@627 9651 msgstr ""
dongsheng@627 9652
dongsheng@627 9653 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 9654 #: ../en/ch07-filenames.xml:76
dongsheng@627 9655 msgid "Telling you what's going on"
dongsheng@630 9656 msgstr "告诉你正在做什么"
dongsheng@627 9657
dongsheng@627 9658 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 9659 #: ../en/ch07-filenames.xml:78
dongsheng@627 9660 msgid ""
dongsheng@627 9661 "The <command role=\"hg-cmd\">hg add</command> example in the preceding "
dongsheng@627 9662 "section illustrates something else that's helpful about Mercurial commands. "
dongsheng@627 9663 "If a command operates on a file that you didn't name explicitly on the "
dongsheng@627 9664 "command line, it will usually print the name of the file, so that you will "
dongsheng@627 9665 "not be surprised what's going on."
dongsheng@627 9666 msgstr ""
dongsheng@627 9667
dongsheng@627 9668 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 9669 #: ../en/ch07-filenames.xml:85
dongsheng@627 9670 msgid ""
dongsheng@627 9671 "The principle here is of <emphasis>least surprise</emphasis>. If you've "
dongsheng@627 9672 "exactly named a file on the command line, there's no point in repeating it "
dongsheng@627 9673 "back at you. If Mercurial is acting on a file <emphasis>implicitly</"
songdongsheng@710 9674 "emphasis>, e.g. because you provided no names, or a directory, or a pattern "
songdongsheng@710 9675 "(see below), it is safest to tell you what files it's operating on."
dongsheng@627 9676 msgstr ""
dongsheng@627 9677
dongsheng@627 9678 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 9679 #: ../en/ch07-filenames.xml:92
dongsheng@627 9680 msgid ""
dongsheng@627 9681 "For commands that behave this way, you can silence them using the <option "
dongsheng@627 9682 "role=\"hg-opt-global\">-q</option> option. You can also get them to print "
dongsheng@627 9683 "the name of every file, even those you've named explicitly, using the <option "
dongsheng@627 9684 "role=\"hg-opt-global\">-v</option> option."
dongsheng@627 9685 msgstr ""
dongsheng@627 9686
dongsheng@627 9687 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 9688 #: ../en/ch07-filenames.xml:100
dongsheng@627 9689 msgid "Using patterns to identify files"
dongsheng@630 9690 msgstr "使用模式标识文件"
dongsheng@627 9691
dongsheng@627 9692 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 9693 #: ../en/ch07-filenames.xml:102
dongsheng@627 9694 msgid ""
dongsheng@627 9695 "In addition to working with file and directory names, Mercurial lets you use "
dongsheng@627 9696 "<emphasis>patterns</emphasis> to identify files. Mercurial's pattern "
dongsheng@627 9697 "handling is expressive."
dongsheng@627 9698 msgstr ""
dongsheng@627 9699
dongsheng@627 9700 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 9701 #: ../en/ch07-filenames.xml:106
dongsheng@627 9702 msgid ""
dongsheng@627 9703 "On Unix-like systems (Linux, MacOS, etc.), the job of matching file names to "
dongsheng@627 9704 "patterns normally falls to the shell. On these systems, you must explicitly "
dongsheng@627 9705 "tell Mercurial that a name is a pattern. On Windows, the shell does not "
dongsheng@627 9706 "expand patterns, so Mercurial will automatically identify names that are "
dongsheng@627 9707 "patterns, and expand them for you."
dongsheng@627 9708 msgstr ""
dongsheng@627 9709
dongsheng@627 9710 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 9711 #: ../en/ch07-filenames.xml:113
dongsheng@627 9712 msgid ""
dongsheng@627 9713 "To provide a pattern in place of a regular name on the command line, the "
dongsheng@627 9714 "mechanism is simple:"
dongsheng@627 9715 msgstr ""
dongsheng@627 9716
dongsheng@627 9717 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 9718 #: ../en/ch07-filenames.xml:116
dongsheng@627 9719 msgid ""
dongsheng@627 9720 "That is, a pattern is identified by a short text string that says what kind "
dongsheng@627 9721 "of pattern this is, followed by a colon, followed by the actual pattern."
dongsheng@627 9722 msgstr ""
dongsheng@627 9723
dongsheng@627 9724 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 9725 #: ../en/ch07-filenames.xml:120
dongsheng@627 9726 msgid ""
dongsheng@627 9727 "Mercurial supports two kinds of pattern syntax. The most frequently used is "
dongsheng@627 9728 "called <literal>glob</literal>; this is the same kind of pattern matching "
dongsheng@627 9729 "used by the Unix shell, and should be familiar to Windows command prompt "
dongsheng@627 9730 "users, too."
dongsheng@627 9731 msgstr ""
dongsheng@627 9732
dongsheng@627 9733 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 9734 #: ../en/ch07-filenames.xml:125
dongsheng@627 9735 msgid ""
dongsheng@627 9736 "When Mercurial does automatic pattern matching on Windows, it uses "
dongsheng@627 9737 "<literal>glob</literal> syntax. You can thus omit the <quote><literal>glob:</"
dongsheng@627 9738 "literal></quote> prefix on Windows, but it's safe to use it, too."
dongsheng@627 9739 msgstr ""
dongsheng@627 9740
dongsheng@627 9741 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 9742 #: ../en/ch07-filenames.xml:130
dongsheng@627 9743 msgid ""
dongsheng@627 9744 "The <literal>re</literal> syntax is more powerful; it lets you specify "
dongsheng@627 9745 "patterns using regular expressions, also known as regexps."
dongsheng@627 9746 msgstr ""
dongsheng@627 9747
dongsheng@627 9748 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 9749 #: ../en/ch07-filenames.xml:134
dongsheng@627 9750 msgid ""
dongsheng@627 9751 "By the way, in the examples that follow, notice that I'm careful to wrap all "
dongsheng@627 9752 "of my patterns in quote characters, so that they won't get expanded by the "
dongsheng@627 9753 "shell before Mercurial sees them."
dongsheng@627 9754 msgstr ""
dongsheng@627 9755
dongsheng@627 9756 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 9757 #: ../en/ch07-filenames.xml:140
dongsheng@627 9758 msgid "Shell-style <literal>glob</literal> patterns"
dongsheng@630 9759 msgstr "外壳风格的 <literal>glob</literal> 模式"
dongsheng@627 9760
dongsheng@627 9761 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 9762 #: ../en/ch07-filenames.xml:142
dongsheng@627 9763 msgid ""
dongsheng@627 9764 "This is an overview of the kinds of patterns you can use when you're matching "
dongsheng@627 9765 "on glob patterns."
dongsheng@627 9766 msgstr ""
dongsheng@627 9767
dongsheng@627 9768 #
dongsheng@627 9769 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 9770 #: ../en/ch07-filenames.xml:145
dongsheng@627 9771 msgid ""
dongsheng@627 9772 "The <quote><literal>*</literal></quote> character matches any string, within "
dongsheng@627 9773 "a single directory."
dongsheng@627 9774 msgstr ""
dongsheng@627 9775
dongsheng@627 9776 #
dongsheng@627 9777 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 9778 #: ../en/ch07-filenames.xml:150
dongsheng@627 9779 msgid ""
dongsheng@627 9780 "The <quote><literal>**</literal></quote> pattern matches any string, and "
dongsheng@627 9781 "crosses directory boundaries. It's not a standard Unix glob token, but it's "
dongsheng@627 9782 "accepted by several popular Unix shells, and is very useful."
dongsheng@627 9783 msgstr ""
dongsheng@627 9784
dongsheng@627 9785 #
dongsheng@627 9786 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 9787 #: ../en/ch07-filenames.xml:157
dongsheng@627 9788 msgid ""
dongsheng@627 9789 "The <quote><literal>?</literal></quote> pattern matches any single character."
dongsheng@627 9790 msgstr ""
dongsheng@627 9791
dongsheng@627 9792 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 9793 #: ../en/ch07-filenames.xml:162
dongsheng@627 9794 msgid ""
dongsheng@627 9795 "The <quote><literal>[</literal></quote> character begins a "
dongsheng@627 9796 "<emphasis>character class</emphasis>. This matches any single character "
dongsheng@627 9797 "within the class. The class ends with a <quote><literal>]</literal></quote> "
dongsheng@627 9798 "character. A class may contain multiple <emphasis>range</emphasis>s of the "
dongsheng@627 9799 "form <quote><literal>a-f</literal></quote>, which is shorthand for "
dongsheng@627 9800 "<quote><literal>abcdef</literal></quote>."
dongsheng@627 9801 msgstr ""
dongsheng@627 9802
dongsheng@627 9803 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 9804 #: ../en/ch07-filenames.xml:172
dongsheng@627 9805 msgid ""
dongsheng@627 9806 "If the first character after the <quote><literal>[</literal></quote> in a "
dongsheng@627 9807 "character class is a <quote><literal>!</literal></quote>, it "
dongsheng@627 9808 "<emphasis>negates</emphasis> the class, making it match any single character "
dongsheng@627 9809 "not in the class."
dongsheng@627 9810 msgstr ""
dongsheng@627 9811
dongsheng@627 9812 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 9813 #: ../en/ch07-filenames.xml:178
dongsheng@627 9814 msgid ""
dongsheng@627 9815 "A <quote><literal>{</literal></quote> begins a group of subpatterns, where "
dongsheng@627 9816 "the whole group matches if any subpattern in the group matches. The "
dongsheng@627 9817 "<quote><literal>,</literal></quote> character separates subpatterns, and "
dongsheng@627 9818 "<quote><literal>}</literal></quote> ends the group."
dongsheng@627 9819 msgstr ""
dongsheng@627 9820
dongsheng@627 9821 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
dongsheng@714 9822 #: ../en/ch07-filenames.xml:187
dongsheng@627 9823 msgid "Watch out!"
dongsheng@630 9824 msgstr "千万小心!"
dongsheng@627 9825
dongsheng@627 9826 #
dongsheng@627 9827 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 9828 #: ../en/ch07-filenames.xml:189
dongsheng@627 9829 msgid ""
dongsheng@627 9830 "Don't forget that if you want to match a pattern in any directory, you should "
dongsheng@627 9831 "not be using the <quote><literal>*</literal></quote> match-any token, as this "
dongsheng@627 9832 "will only match within one directory. Instead, use the <quote><literal>**</"
dongsheng@627 9833 "literal></quote> token. This small example illustrates the difference "
dongsheng@627 9834 "between the two."
dongsheng@627 9835 msgstr ""
dongsheng@627 9836
dongsheng@627 9837 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 9838 #: ../en/ch07-filenames.xml:201
dongsheng@627 9839 msgid "Regular expression matching with <literal>re</literal> patterns"
dongsheng@630 9840 msgstr "使用 <literal>re</literal> 模式的正则表达式匹配"
dongsheng@627 9841
dongsheng@627 9842 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 9843 #: ../en/ch07-filenames.xml:204
dongsheng@627 9844 msgid ""
dongsheng@627 9845 "Mercurial accepts the same regular expression syntax as the Python "
dongsheng@627 9846 "programming language (it uses Python's regexp engine internally). This is "
dongsheng@627 9847 "based on the Perl language's regexp syntax, which is the most popular dialect "
dongsheng@627 9848 "in use (it's also used in Java, for example)."
dongsheng@627 9849 msgstr ""
dongsheng@627 9850
dongsheng@627 9851 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 9852 #: ../en/ch07-filenames.xml:210
dongsheng@627 9853 msgid ""
dongsheng@627 9854 "I won't discuss Mercurial's regexp dialect in any detail here, as regexps are "
dongsheng@627 9855 "not often used. Perl-style regexps are in any case already exhaustively "
dongsheng@627 9856 "documented on a multitude of web sites, and in many books. Instead, I will "
dongsheng@627 9857 "focus here on a few things you should know if you find yourself needing to "
dongsheng@627 9858 "use regexps with Mercurial."
dongsheng@627 9859 msgstr ""
dongsheng@627 9860
dongsheng@627 9861 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 9862 #: ../en/ch07-filenames.xml:217
dongsheng@627 9863 msgid ""
dongsheng@627 9864 "A regexp is matched against an entire file name, relative to the root of the "
dongsheng@627 9865 "repository. In other words, even if you're already in subbdirectory "
dongsheng@627 9866 "<filename class=\"directory\">foo</filename>, if you want to match files "
dongsheng@627 9867 "under this directory, your pattern must start with <quote><literal>foo/</"
dongsheng@627 9868 "literal></quote>."
dongsheng@627 9869 msgstr ""
dongsheng@627 9870
dongsheng@627 9871 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 9872 #: ../en/ch07-filenames.xml:224
dongsheng@627 9873 msgid ""
dongsheng@627 9874 "One thing to note, if you're familiar with Perl-style regexps, is that "
dongsheng@627 9875 "Mercurial's are <emphasis>rooted</emphasis>. That is, a regexp starts "
dongsheng@627 9876 "matching against the beginning of a string; it doesn't look for a match "
dongsheng@627 9877 "anywhere within the string. To match anywhere in a string, start your "
dongsheng@627 9878 "pattern with <quote><literal>.*</literal></quote>."
dongsheng@627 9879 msgstr ""
dongsheng@627 9880
dongsheng@627 9881 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 9882 #: ../en/ch07-filenames.xml:234
dongsheng@627 9883 msgid "Filtering files"
dongsheng@630 9884 msgstr "过滤文件"
dongsheng@627 9885
dongsheng@627 9886 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 9887 #: ../en/ch07-filenames.xml:236
dongsheng@627 9888 msgid ""
dongsheng@627 9889 "Not only does Mercurial give you a variety of ways to specify files; it lets "
dongsheng@627 9890 "you further winnow those files using <emphasis>filters</emphasis>. Commands "
dongsheng@627 9891 "that work with file names accept two filtering options."
dongsheng@627 9892 msgstr ""
dongsheng@627 9893
dongsheng@627 9894 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 9895 #: ../en/ch07-filenames.xml:241
dongsheng@627 9896 msgid ""
dongsheng@627 9897 "<option role=\"hg-opt-global\">-I</option>, or <option role=\"hg-opt-global"
dongsheng@627 9898 "\">--include</option>, lets you specify a pattern that file names must match "
dongsheng@627 9899 "in order to be processed."
dongsheng@627 9900 msgstr ""
dongsheng@627 9901
dongsheng@627 9902 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 9903 #: ../en/ch07-filenames.xml:246
dongsheng@627 9904 msgid ""
dongsheng@627 9905 "<option role=\"hg-opt-global\">-X</option>, or <option role=\"hg-opt-global"
dongsheng@627 9906 "\">--exclude</option>, gives you a way to <emphasis>avoid</emphasis> "
dongsheng@627 9907 "processing files, if they match this pattern."
dongsheng@627 9908 msgstr ""
dongsheng@627 9909
dongsheng@627 9910 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 9911 #: ../en/ch07-filenames.xml:251
dongsheng@627 9912 msgid ""
dongsheng@627 9913 "You can provide multiple <option role=\"hg-opt-global\">-I</option> and "
dongsheng@627 9914 "<option role=\"hg-opt-global\">-X</option> options on the command line, and "
dongsheng@627 9915 "intermix them as you please. Mercurial interprets the patterns you provide "
dongsheng@627 9916 "using glob syntax by default (but you can use regexps if you need to)."
dongsheng@627 9917 msgstr ""
dongsheng@627 9918
dongsheng@627 9919 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 9920 #: ../en/ch07-filenames.xml:258
dongsheng@627 9921 msgid ""
dongsheng@627 9922 "You can read a <option role=\"hg-opt-global\">-I</option> filter as "
dongsheng@627 9923 "<quote>process only the files that match this filter</quote>."
dongsheng@627 9924 msgstr ""
dongsheng@627 9925
dongsheng@627 9926 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 9927 #: ../en/ch07-filenames.xml:264
dongsheng@627 9928 msgid ""
dongsheng@627 9929 "The <option role=\"hg-opt-global\">-X</option> filter is best read as "
dongsheng@627 9930 "<quote>process only the files that don't match this pattern</quote>."
dongsheng@627 9931 msgstr ""
dongsheng@627 9932
dongsheng@627 9933 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 9934 #: ../en/ch07-filenames.xml:272
songdongsheng@710 9935 msgid "Permanently ignoring unwanted files and directories"
songdongsheng@711 9936 msgstr "始终忽略不需要的文件和目录"
dongsheng@627 9937
dongsheng@627 9938 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 9939 #: ../en/ch07-filenames.xml:274
songdongsheng@710 9940 msgid ""
songdongsheng@710 9941 "When you create a new repository, the chances are that over time it will grow "
songdongsheng@710 9942 "to contain files that ought to <emphasis>not</emphasis> be managed by "
songdongsheng@710 9943 "Mercurial, but which you don't want to see listed every time you run "
songdongsheng@710 9944 "<command>hg status</command>. For instance, <quote>build products</quote> "
songdongsheng@710 9945 "are files that are created as part of a build but which should not be managed "
songdongsheng@710 9946 "by a revision control system. The most common build products are output "
songdongsheng@710 9947 "files produced by software tools such as compilers. As another example, many "
songdongsheng@710 9948 "text editors litter a directory with lock files, temporary working files, and "
songdongsheng@710 9949 "backup files, which it also makes no sense to manage."
songdongsheng@710 9950 msgstr ""
songdongsheng@710 9951
songdongsheng@710 9952 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 9953 #: ../en/ch07-filenames.xml:286
songdongsheng@710 9954 msgid ""
songdongsheng@710 9955 "To have Mercurial permanently ignore such files, create a file named "
songdongsheng@710 9956 "<filename>.hgignore</filename> in the root of your repository. You "
songdongsheng@710 9957 "<emphasis>should</emphasis> <command>hg add</command> this file so that it "
songdongsheng@710 9958 "gets tracked with the rest of your repository contents, since your "
songdongsheng@710 9959 "collaborators will probably find it useful too."
songdongsheng@710 9960 msgstr ""
songdongsheng@710 9961
songdongsheng@710 9962 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 9963 #: ../en/ch07-filenames.xml:293
songdongsheng@710 9964 msgid ""
songdongsheng@710 9965 "By default, the <filename>.hgignore</filename> file should contain a list of "
songdongsheng@710 9966 "regular expressions, one per line. Empty lines are skipped. Most people "
songdongsheng@710 9967 "prefer to describe the files they want to ignore using the <quote>glob</"
songdongsheng@710 9968 "quote> syntax that we described above, so a typical <filename>.hgignore</"
songdongsheng@710 9969 "filename> file will start with this directive:"
songdongsheng@710 9970 msgstr ""
songdongsheng@710 9971
songdongsheng@710 9972 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 9973 #: ../en/ch07-filenames.xml:302
songdongsheng@710 9974 msgid ""
songdongsheng@710 9975 "This tells Mercurial to interpret the lines that follow as glob patterns, not "
songdongsheng@710 9976 "regular expressions."
songdongsheng@710 9977 msgstr ""
songdongsheng@710 9978
songdongsheng@710 9979 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 9980 #: ../en/ch07-filenames.xml:305
songdongsheng@710 9981 msgid "Here is a typical-looking <filename>.hgignore</filename> file."
dongsheng@627 9982 msgstr ""
dongsheng@627 9983
dongsheng@627 9984 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 9985 #: ../en/ch07-filenames.xml:329
dongsheng@627 9986 msgid "Case sensitivity"
dongsheng@630 9987 msgstr "大小写敏感性"
dongsheng@627 9988
dongsheng@627 9989 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 9990 #: ../en/ch07-filenames.xml:331
dongsheng@627 9991 msgid ""
dongsheng@627 9992 "If you're working in a mixed development environment that contains both Linux "
dongsheng@627 9993 "(or other Unix) systems and Macs or Windows systems, you should keep in the "
dongsheng@627 9994 "back of your mind the knowledge that they treat the case (<quote>N</quote> "
dongsheng@627 9995 "versus <quote>n</quote>) of file names in incompatible ways. This is not "
dongsheng@627 9996 "very likely to affect you, and it's easy to deal with if it does, but it "
dongsheng@627 9997 "could surprise you if you don't know about it."
dongsheng@627 9998 msgstr ""
dongsheng@627 9999
dongsheng@627 10000 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 10001 #: ../en/ch07-filenames.xml:340
dongsheng@627 10002 msgid ""
dongsheng@627 10003 "Operating systems and filesystems differ in the way they handle the "
dongsheng@627 10004 "<emphasis>case</emphasis> of characters in file and directory names. There "
dongsheng@627 10005 "are three common ways to handle case in names."
dongsheng@627 10006 msgstr ""
dongsheng@627 10007
dongsheng@627 10008 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 10009 #: ../en/ch07-filenames.xml:345
dongsheng@627 10010 msgid ""
dongsheng@627 10011 "Completely case insensitive. Uppercase and lowercase versions of a letter "
dongsheng@627 10012 "are treated as identical, both when creating a file and during subsequent "
dongsheng@627 10013 "accesses. This is common on older DOS-based systems."
dongsheng@627 10014 msgstr ""
dongsheng@627 10015
dongsheng@627 10016 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 10017 #: ../en/ch07-filenames.xml:350
dongsheng@627 10018 msgid ""
dongsheng@627 10019 "Case preserving, but insensitive. When a file or directory is created, the "
dongsheng@627 10020 "case of its name is stored, and can be retrieved and displayed by the "
dongsheng@627 10021 "operating system. When an existing file is being looked up, its case is "
dongsheng@627 10022 "ignored. This is the standard arrangement on Windows and MacOS. The names "
dongsheng@627 10023 "<filename>foo</filename> and <filename>FoO</filename> identify the same "
dongsheng@627 10024 "file. This treatment of uppercase and lowercase letters as interchangeable "
dongsheng@627 10025 "is also referred to as <emphasis>case folding</emphasis>."
dongsheng@627 10026 msgstr ""
dongsheng@627 10027
dongsheng@627 10028 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 10029 #: ../en/ch07-filenames.xml:361
dongsheng@627 10030 msgid ""
dongsheng@627 10031 "Case sensitive. The case of a name is significant at all times. The names "
dongsheng@714 10032 "<filename>foo</filename> and <filename>FoO</filename> identify different "
dongsheng@714 10033 "files. This is the way Linux and Unix systems normally work."
dongsheng@714 10034 msgstr ""
dongsheng@714 10035
dongsheng@714 10036 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 10037 #: ../en/ch07-filenames.xml:368
dongsheng@627 10038 msgid ""
dongsheng@627 10039 "On Unix-like systems, it is possible to have any or all of the above ways of "
dongsheng@627 10040 "handling case in action at once. For example, if you use a USB thumb drive "
dongsheng@627 10041 "formatted with a FAT32 filesystem on a Linux system, Linux will handle names "
dongsheng@627 10042 "on that filesystem in a case preserving, but insensitive, way."
dongsheng@627 10043 msgstr ""
dongsheng@627 10044
dongsheng@627 10045 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 10046 #: ../en/ch07-filenames.xml:375
dongsheng@627 10047 msgid "Safe, portable repository storage"
dongsheng@630 10048 msgstr "安全,可移植的版本库存储"
dongsheng@627 10049
dongsheng@627 10050 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 10051 #: ../en/ch07-filenames.xml:377
dongsheng@627 10052 msgid ""
dongsheng@627 10053 "Mercurial's repository storage mechanism is <emphasis>case safe</emphasis>. "
dongsheng@627 10054 "It translates file names so that they can be safely stored on both case "
dongsheng@627 10055 "sensitive and case insensitive filesystems. This means that you can use "
dongsheng@627 10056 "normal file copying tools to transfer a Mercurial repository onto, for "
dongsheng@627 10057 "example, a USB thumb drive, and safely move that drive and repository back "
dongsheng@627 10058 "and forth between a Mac, a PC running Windows, and a Linux box."
dongsheng@627 10059 msgstr ""
dongsheng@627 10060
dongsheng@627 10061 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 10062 #: ../en/ch07-filenames.xml:388
dongsheng@627 10063 msgid "Detecting case conflicts"
dongsheng@630 10064 msgstr "检测大小写冲突"
dongsheng@627 10065
dongsheng@627 10066 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 10067 #: ../en/ch07-filenames.xml:390
dongsheng@627 10068 msgid ""
dongsheng@627 10069 "When operating in the working directory, Mercurial honours the naming policy "
dongsheng@627 10070 "of the filesystem where the working directory is located. If the filesystem "
dongsheng@627 10071 "is case preserving, but insensitive, Mercurial will treat names that differ "
dongsheng@627 10072 "only in case as the same."
dongsheng@627 10073 msgstr ""
dongsheng@627 10074
dongsheng@627 10075 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 10076 #: ../en/ch07-filenames.xml:396
dongsheng@627 10077 msgid ""
dongsheng@627 10078 "An important aspect of this approach is that it is possible to commit a "
dongsheng@627 10079 "changeset on a case sensitive (typically Linux or Unix) filesystem that will "
dongsheng@627 10080 "cause trouble for users on case insensitive (usually Windows and MacOS) "
dongsheng@627 10081 "users. If a Linux user commits changes to two files, one named "
dongsheng@627 10082 "<filename>myfile.c</filename> and the other named <filename>MyFile.C</"
dongsheng@627 10083 "filename>, they will be stored correctly in the repository. And in the "
dongsheng@627 10084 "working directories of other Linux users, they will be correctly represented "
dongsheng@627 10085 "as separate files."
dongsheng@627 10086 msgstr ""
dongsheng@627 10087
dongsheng@627 10088 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 10089 #: ../en/ch07-filenames.xml:407
dongsheng@627 10090 msgid ""
dongsheng@627 10091 "If a Windows or Mac user pulls this change, they will not initially have a "
dongsheng@627 10092 "problem, because Mercurial's repository storage mechanism is case safe. "
dongsheng@627 10093 "However, once they try to <command role=\"hg-cmd\">hg update</command> the "
dongsheng@627 10094 "working directory to that changeset, or <command role=\"hg-cmd\">hg merge</"
dongsheng@627 10095 "command> with that changeset, Mercurial will spot the conflict between the "
dongsheng@627 10096 "two file names that the filesystem would treat as the same, and forbid the "
dongsheng@627 10097 "update or merge from occurring."
dongsheng@627 10098 msgstr ""
dongsheng@627 10099
dongsheng@627 10100 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 10101 #: ../en/ch07-filenames.xml:419
dongsheng@627 10102 msgid "Fixing a case conflict"
dongsheng@630 10103 msgstr "修正大小写冲突"
dongsheng@627 10104
dongsheng@627 10105 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 10106 #: ../en/ch07-filenames.xml:421
dongsheng@627 10107 msgid ""
dongsheng@627 10108 "If you are using Windows or a Mac in a mixed environment where some of your "
dongsheng@627 10109 "collaborators are using Linux or Unix, and Mercurial reports a case folding "
dongsheng@627 10110 "conflict when you try to <command role=\"hg-cmd\">hg update</command> or "
dongsheng@627 10111 "<command role=\"hg-cmd\">hg merge</command>, the procedure to fix the problem "
dongsheng@627 10112 "is simple."
dongsheng@627 10113 msgstr ""
dongsheng@627 10114
dongsheng@627 10115 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 10116 #: ../en/ch07-filenames.xml:428
dongsheng@627 10117 msgid ""
dongsheng@627 10118 "Just find a nearby Linux or Unix box, clone the problem repository onto it, "
dongsheng@627 10119 "and use Mercurial's <command role=\"hg-cmd\">hg rename</command> command to "
dongsheng@627 10120 "change the names of any offending files or directories so that they will no "
dongsheng@627 10121 "longer cause case folding conflicts. Commit this change, <command role=\"hg-"
dongsheng@627 10122 "cmd\">hg pull</command> or <command role=\"hg-cmd\">hg push</command> it "
dongsheng@627 10123 "across to your Windows or MacOS system, and <command role=\"hg-cmd\">hg "
dongsheng@627 10124 "update</command> to the revision with the non-conflicting names."
dongsheng@627 10125 msgstr ""
dongsheng@627 10126
dongsheng@627 10127 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 10128 #: ../en/ch07-filenames.xml:438
dongsheng@627 10129 msgid ""
dongsheng@627 10130 "The changeset with case-conflicting names will remain in your project's "
dongsheng@627 10131 "history, and you still won't be able to <command role=\"hg-cmd\">hg update</"
dongsheng@627 10132 "command> your working directory to that changeset on a Windows or MacOS "
dongsheng@627 10133 "system, but you can continue development unimpeded."
dongsheng@627 10134 msgstr ""
dongsheng@627 10135
dongsheng@627 10136 #. type: Content of: <book><chapter><title>
dongsheng@714 10137 #: ../en/ch08-branch.xml:5
dongsheng@627 10138 msgid "Managing releases and branchy development"
dongsheng@627 10139 msgstr "发布管理与分支开发"
dongsheng@627 10140
dongsheng@627 10141 #. type: Content of: <book><chapter><para>
dongsheng@714 10142 #: ../en/ch08-branch.xml:7
dongsheng@627 10143 msgid ""
dongsheng@627 10144 "Mercurial provides several mechanisms for you to manage a project that is "
dongsheng@627 10145 "making progress on multiple fronts at once. To understand these mechanisms, "
dongsheng@627 10146 "let's first take a brief look at a fairly normal software project structure."
dongsheng@627 10147 msgstr ""
dongsheng@627 10148
dongsheng@627 10149 #. type: Content of: <book><chapter><para>
dongsheng@714 10150 #: ../en/ch08-branch.xml:12
dongsheng@627 10151 msgid ""
dongsheng@627 10152 "Many software projects issue periodic <quote>major</quote> releases that "
dongsheng@627 10153 "contain substantial new features. In parallel, they may issue <quote>minor</"
dongsheng@627 10154 "quote> releases. These are usually identical to the major releases off which "
dongsheng@627 10155 "they're based, but with a few bugs fixed."
dongsheng@627 10156 msgstr ""
dongsheng@627 10157
dongsheng@627 10158 #. type: Content of: <book><chapter><para>
dongsheng@714 10159 #: ../en/ch08-branch.xml:18
dongsheng@627 10160 msgid ""
dongsheng@627 10161 "In this chapter, we'll start by talking about how to keep records of project "
dongsheng@627 10162 "milestones such as releases. We'll then continue on to talk about the flow "
dongsheng@627 10163 "of work between different phases of a project, and how Mercurial can help you "
dongsheng@627 10164 "to isolate and manage this work."
dongsheng@627 10165 msgstr ""
dongsheng@627 10166
dongsheng@627 10167 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 10168 #: ../en/ch08-branch.xml:25
dongsheng@627 10169 msgid "Giving a persistent name to a revision"
dongsheng@635 10170 msgstr "给版本指定一个永久的名称"
dongsheng@627 10171
dongsheng@627 10172 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 10173 #: ../en/ch08-branch.xml:27
dongsheng@627 10174 msgid ""
dongsheng@627 10175 "Once you decide that you'd like to call a particular revision a "
dongsheng@627 10176 "<quote>release</quote>, it's a good idea to record the identity of that "
dongsheng@627 10177 "revision. This will let you reproduce that release at a later date, for "
dongsheng@627 10178 "whatever purpose you might need at the time (reproducing a bug, porting to a "
dongsheng@627 10179 "new platform, etc). &interaction.tag.init;"
dongsheng@627 10180 msgstr ""
dongsheng@627 10181
dongsheng@627 10182 #
dongsheng@627 10183 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 10184 #: ../en/ch08-branch.xml:34
dongsheng@627 10185 msgid ""
dongsheng@627 10186 "Mercurial lets you give a permanent name to any revision using the <command "
dongsheng@627 10187 "role=\"hg-cmd\">hg tag</command> command. Not surprisingly, these names are "
dongsheng@627 10188 "called <quote>tags</quote>."
dongsheng@627 10189 msgstr ""
dongsheng@627 10190
dongsheng@627 10191 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 10192 #: ../en/ch08-branch.xml:40
dongsheng@627 10193 msgid ""
dongsheng@627 10194 "A tag is nothing more than a <quote>symbolic name</quote> for a revision. "
dongsheng@627 10195 "Tags exist purely for your convenience, so that you have a handy permanent "
dongsheng@627 10196 "way to refer to a revision; Mercurial doesn't interpret the tag names you use "
dongsheng@627 10197 "in any way. Neither does Mercurial place any restrictions on the name of a "
dongsheng@627 10198 "tag, beyond a few that are necessary to ensure that a tag can be parsed "
dongsheng@627 10199 "unambiguously. A tag name cannot contain any of the following characters:"
dongsheng@627 10200 msgstr ""
dongsheng@627 10201
dongsheng@627 10202 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 10203 #: ../en/ch08-branch.xml:49
dongsheng@627 10204 msgid "Colon (ASCII 58, <quote><literal>:</literal></quote>)"
dongsheng@627 10205 msgstr ""
dongsheng@627 10206
dongsheng@627 10207 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 10208 #: ../en/ch08-branch.xml:52
dongsheng@627 10209 msgid "Carriage return (ASCII 13, <quote><literal>\\r</literal></quote>)"
dongsheng@627 10210 msgstr ""
dongsheng@627 10211
dongsheng@627 10212 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 10213 #: ../en/ch08-branch.xml:55
dongsheng@627 10214 msgid "Newline (ASCII 10, <quote><literal>\\n</literal></quote>)"
dongsheng@627 10215 msgstr ""
dongsheng@627 10216
dongsheng@627 10217 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 10218 #: ../en/ch08-branch.xml:59
dongsheng@627 10219 msgid ""
dongsheng@627 10220 "You can use the <command role=\"hg-cmd\">hg tags</command> command to display "
dongsheng@627 10221 "the tags present in your repository. In the output, each tagged revision is "
dongsheng@627 10222 "identified first by its name, then by revision number, and finally by the "
dongsheng@627 10223 "unique hash of the revision."
dongsheng@627 10224 msgstr ""
dongsheng@627 10225
dongsheng@627 10226 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 10227 #: ../en/ch08-branch.xml:67
dongsheng@627 10228 msgid ""
dongsheng@627 10229 "Notice that <literal>tip</literal> is listed in the output of <command role="
dongsheng@627 10230 "\"hg-cmd\">hg tags</command>. The <literal>tip</literal> tag is a special "
dongsheng@627 10231 "<quote>floating</quote> tag, which always identifies the newest revision in "
dongsheng@627 10232 "the repository."
dongsheng@627 10233 msgstr ""
dongsheng@627 10234
dongsheng@627 10235 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 10236 #: ../en/ch08-branch.xml:73
dongsheng@627 10237 msgid ""
dongsheng@627 10238 "In the output of the <command role=\"hg-cmd\">hg tags</command> command, tags "
dongsheng@627 10239 "are listed in reverse order, by revision number. This usually means that "
dongsheng@627 10240 "recent tags are listed before older tags. It also means that <literal>tip</"
dongsheng@627 10241 "literal> is always going to be the first tag listed in the output of <command "
dongsheng@627 10242 "role=\"hg-cmd\">hg tags</command>."
dongsheng@627 10243 msgstr ""
dongsheng@627 10244
dongsheng@627 10245 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 10246 #: ../en/ch08-branch.xml:80
dongsheng@627 10247 msgid ""
dongsheng@627 10248 "When you run <command role=\"hg-cmd\">hg log</command>, if it displays a "
dongsheng@627 10249 "revision that has tags associated with it, it will print those tags."
dongsheng@627 10250 msgstr ""
dongsheng@627 10251
dongsheng@627 10252 #
dongsheng@627 10253 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 10254 #: ../en/ch08-branch.xml:86
dongsheng@627 10255 msgid ""
dongsheng@627 10256 "Any time you need to provide a revision ID to a Mercurial command, the "
dongsheng@627 10257 "command will accept a tag name in its place. Internally, Mercurial will "
dongsheng@627 10258 "translate your tag name into the corresponding revision ID, then use that."
dongsheng@627 10259 msgstr ""
dongsheng@627 10260
dongsheng@627 10261 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 10262 #: ../en/ch08-branch.xml:93
dongsheng@627 10263 msgid ""
dongsheng@627 10264 "There's no limit on the number of tags you can have in a repository, or on "
dongsheng@627 10265 "the number of tags that a single revision can have. As a practical matter, "
dongsheng@627 10266 "it's not a great idea to have <quote>too many</quote> (a number which will "
dongsheng@627 10267 "vary from project to project), simply because tags are supposed to help you "
dongsheng@627 10268 "to find revisions. If you have lots of tags, the ease of using them to "
dongsheng@627 10269 "identify revisions diminishes rapidly."
dongsheng@627 10270 msgstr ""
dongsheng@627 10271
dongsheng@627 10272 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 10273 #: ../en/ch08-branch.xml:101
dongsheng@627 10274 msgid ""
dongsheng@627 10275 "For example, if your project has milestones as frequent as every few days, "
dongsheng@627 10276 "it's perfectly reasonable to tag each one of those. But if you have a "
dongsheng@627 10277 "continuous build system that makes sure every revision can be built cleanly, "
dongsheng@627 10278 "you'd be introducing a lot of noise if you were to tag every clean build. "
dongsheng@627 10279 "Instead, you could tag failed builds (on the assumption that they're rare!), "
dongsheng@627 10280 "or simply not use tags to track buildability."
dongsheng@627 10281 msgstr ""
dongsheng@627 10282
dongsheng@627 10283 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 10284 #: ../en/ch08-branch.xml:109
dongsheng@627 10285 msgid ""
dongsheng@627 10286 "If you want to remove a tag that you no longer want, use <command role=\"hg-"
dongsheng@627 10287 "cmd\">hg tag --remove</command>."
dongsheng@627 10288 msgstr ""
dongsheng@627 10289
dongsheng@627 10290 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 10291 #: ../en/ch08-branch.xml:114
dongsheng@627 10292 msgid ""
dongsheng@627 10293 "You can also modify a tag at any time, so that it identifies a different "
dongsheng@627 10294 "revision, by simply issuing a new <command role=\"hg-cmd\">hg tag</command> "
dongsheng@627 10295 "command. You'll have to use the <option role=\"hg-opt-tag\">-f</option> "
dongsheng@627 10296 "option to tell Mercurial that you <emphasis>really</emphasis> want to update "
dongsheng@627 10297 "the tag."
dongsheng@627 10298 msgstr ""
dongsheng@627 10299
dongsheng@627 10300 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 10301 #: ../en/ch08-branch.xml:123
dongsheng@627 10302 msgid ""
dongsheng@627 10303 "There will still be a permanent record of the previous identity of the tag, "
dongsheng@627 10304 "but Mercurial will no longer use it. There's thus no penalty to tagging the "
dongsheng@627 10305 "wrong revision; all you have to do is turn around and tag the correct "
dongsheng@627 10306 "revision once you discover your error."
dongsheng@627 10307 msgstr ""
dongsheng@627 10308
dongsheng@627 10309 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 10310 #: ../en/ch08-branch.xml:129
dongsheng@627 10311 msgid ""
dongsheng@627 10312 "Mercurial stores tags in a normal revision-controlled file in your "
songdongsheng@710 10313 "repository. If you've created any tags, you'll find them in a file in the "
songdongsheng@710 10314 "root of your repository named <filename role=\"special\">.hgtags</filename>. "
songdongsheng@710 10315 "When you run the <command role=\"hg-cmd\">hg tag</command> command, Mercurial "
songdongsheng@710 10316 "modifies this file, then automatically commits the change to it. This means "
songdongsheng@710 10317 "that every time you run <command role=\"hg-cmd\">hg tag</command>, you'll see "
songdongsheng@710 10318 "a corresponding changeset in the output of <command role=\"hg-cmd\">hg log</"
songdongsheng@710 10319 "command>."
dongsheng@627 10320 msgstr ""
dongsheng@627 10321
dongsheng@627 10322 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 10323 #: ../en/ch08-branch.xml:142
dongsheng@627 10324 msgid "Handling tag conflicts during a merge"
dongsheng@635 10325 msgstr "在合并期间处理标签冲突"
dongsheng@627 10326
dongsheng@627 10327 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 10328 #: ../en/ch08-branch.xml:144
dongsheng@627 10329 msgid ""
dongsheng@627 10330 "You won't often need to care about the <filename role=\"special\">.hgtags</"
dongsheng@627 10331 "filename> file, but it sometimes makes its presence known during a merge. "
dongsheng@627 10332 "The format of the file is simple: it consists of a series of lines. Each "
dongsheng@627 10333 "line starts with a changeset hash, followed by a space, followed by the name "
dongsheng@627 10334 "of a tag."
dongsheng@627 10335 msgstr ""
dongsheng@627 10336
dongsheng@627 10337 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 10338 #: ../en/ch08-branch.xml:151
dongsheng@627 10339 msgid ""
dongsheng@627 10340 "If you're resolving a conflict in the <filename role=\"special\">.hgtags</"
dongsheng@627 10341 "filename> file during a merge, there's one twist to modifying the <filename "
dongsheng@627 10342 "role=\"special\">.hgtags</filename> file: when Mercurial is parsing the tags "
dongsheng@627 10343 "in a repository, it <emphasis>never</emphasis> reads the working copy of the "
dongsheng@627 10344 "<filename role=\"special\">.hgtags</filename> file. Instead, it reads the "
dongsheng@627 10345 "<emphasis>most recently committed</emphasis> revision of the file."
dongsheng@627 10346 msgstr ""
dongsheng@627 10347
dongsheng@627 10348 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 10349 #: ../en/ch08-branch.xml:161
dongsheng@627 10350 msgid ""
dongsheng@627 10351 "An unfortunate consequence of this design is that you can't actually verify "
dongsheng@627 10352 "that your merged <filename role=\"special\">.hgtags</filename> file is "
dongsheng@627 10353 "correct until <emphasis>after</emphasis> you've committed a change. So if "
dongsheng@627 10354 "you find yourself resolving a conflict on <filename role=\"special\">.hgtags</"
dongsheng@627 10355 "filename> during a merge, be sure to run <command role=\"hg-cmd\">hg tags</"
dongsheng@627 10356 "command> after you commit. If it finds an error in the <filename role="
dongsheng@627 10357 "\"special\">.hgtags</filename> file, it will report the location of the "
dongsheng@627 10358 "error, which you can then fix and commit. You should then run <command role="
dongsheng@627 10359 "\"hg-cmd\">hg tags</command> again, just to be sure that your fix is correct."
dongsheng@627 10360 msgstr ""
dongsheng@627 10361
dongsheng@627 10362 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 10363 #: ../en/ch08-branch.xml:176
dongsheng@627 10364 msgid "Tags and cloning"
dongsheng@635 10365 msgstr "标签与克隆"
dongsheng@627 10366
dongsheng@627 10367 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 10368 #: ../en/ch08-branch.xml:178
dongsheng@627 10369 msgid ""
dongsheng@627 10370 "You may have noticed that the <command role=\"hg-cmd\">hg clone</command> "
dongsheng@627 10371 "command has a <option role=\"hg-opt-clone\">-r</option> option that lets you "
dongsheng@627 10372 "clone an exact copy of the repository as of a particular changeset. The new "
dongsheng@627 10373 "clone will not contain any project history that comes after the revision you "
dongsheng@627 10374 "specified. This has an interaction with tags that can surprise the unwary."
dongsheng@627 10375 msgstr ""
dongsheng@627 10376
dongsheng@627 10377 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 10378 #: ../en/ch08-branch.xml:186
dongsheng@627 10379 msgid ""
dongsheng@627 10380 "Recall that a tag is stored as a revision to the <filename role=\"special\">."
dongsheng@714 10381 "hgtags</filename> file. When you create a tag, the changeset in which its "
dongsheng@714 10382 "recorded refers to an older changeset. When you run <command role=\"hg-cmd"
dongsheng@714 10383 "\">hg clone -r foo</command> to clone a repository as of tag <literal>foo</"
dongsheng@714 10384 "literal>, the new clone <emphasis>will not contain any revision newer than "
dongsheng@714 10385 "the one the tag refers to, including the revision where the tag was created</"
dongsheng@714 10386 "emphasis>. The result is that you'll get exactly the right subset of the "
dongsheng@627 10387 "project's history in the new repository, but <emphasis>not</emphasis> the tag "
dongsheng@627 10388 "you might have expected."
dongsheng@627 10389 msgstr ""
dongsheng@627 10390
dongsheng@627 10391 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 10392 #: ../en/ch08-branch.xml:201
dongsheng@627 10393 msgid "When permanent tags are too much"
dongsheng@635 10394 msgstr "当永久标签太多的时候"
dongsheng@627 10395
dongsheng@627 10396 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 10397 #: ../en/ch08-branch.xml:203
dongsheng@627 10398 msgid ""
dongsheng@627 10399 "Since Mercurial's tags are revision controlled and carried around with a "
dongsheng@627 10400 "project's history, everyone you work with will see the tags you create. But "
dongsheng@627 10401 "giving names to revisions has uses beyond simply noting that revision "
dongsheng@627 10402 "<literal>4237e45506ee</literal> is really <literal>v2.0.2</literal>. If "
dongsheng@627 10403 "you're trying to track down a subtle bug, you might want a tag to remind you "
dongsheng@627 10404 "of something like <quote>Anne saw the symptoms with this revision</quote>."
dongsheng@627 10405 msgstr ""
dongsheng@627 10406
dongsheng@627 10407 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 10408 #: ../en/ch08-branch.xml:213
dongsheng@627 10409 msgid ""
dongsheng@627 10410 "For cases like this, what you might want to use are <emphasis>local</"
dongsheng@627 10411 "emphasis> tags. You can create a local tag with the <option role=\"hg-opt-tag"
dongsheng@627 10412 "\">-l</option> option to the <command role=\"hg-cmd\">hg tag</command> "
dongsheng@627 10413 "command. This will store the tag in a file called <filename role=\"special"
dongsheng@627 10414 "\">.hg/localtags</filename>. Unlike <filename role=\"special\">.hgtags</"
dongsheng@627 10415 "filename>, <filename role=\"special\">.hg/localtags</filename> is not "
dongsheng@627 10416 "revision controlled. Any tags you create using <option role=\"hg-opt-tag\">-"
dongsheng@627 10417 "l</option> remain strictly local to the repository you're currently working "
dongsheng@627 10418 "in."
dongsheng@627 10419 msgstr ""
dongsheng@627 10420
dongsheng@627 10421 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 10422 #: ../en/ch08-branch.xml:228
songdongsheng@668 10423 msgid "The flow of changes&emdash;big picture vs. little"
dongsheng@661 10424 msgstr "修改流程—宏观与微观"
dongsheng@627 10425
dongsheng@627 10426 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 10427 #: ../en/ch08-branch.xml:230
dongsheng@714 10428 msgid ""
dongsheng@714 10429 "To return to the outline I sketched at the beginning of the chapter, let's "
dongsheng@627 10430 "think about a project that has multiple concurrent pieces of work under "
dongsheng@627 10431 "development at once."
dongsheng@627 10432 msgstr ""
dongsheng@627 10433
dongsheng@627 10434 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 10435 #: ../en/ch08-branch.xml:235
dongsheng@627 10436 msgid ""
dongsheng@627 10437 "There might be a push for a new <quote>main</quote> release; a new minor "
dongsheng@627 10438 "bugfix release to the last main release; and an unexpected <quote>hot fix</"
dongsheng@627 10439 "quote> to an old release that is now in maintenance mode."
dongsheng@627 10440 msgstr ""
dongsheng@627 10441
dongsheng@627 10442 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 10443 #: ../en/ch08-branch.xml:240
dongsheng@627 10444 msgid ""
dongsheng@627 10445 "The usual way people refer to these different concurrent directions of "
dongsheng@627 10446 "development is as <quote>branches</quote>. However, we've already seen "
dongsheng@627 10447 "numerous times that Mercurial treats <emphasis>all of history</emphasis> as a "
dongsheng@627 10448 "series of branches and merges. Really, what we have here is two ideas that "
dongsheng@627 10449 "are peripherally related, but which happen to share a name."
dongsheng@627 10450 msgstr ""
dongsheng@627 10451
dongsheng@627 10452 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 10453 #: ../en/ch08-branch.xml:247
dongsheng@627 10454 msgid ""
dongsheng@627 10455 "<quote>Big picture</quote> branches represent the sweep of a project's "
dongsheng@627 10456 "evolution; people give them names, and talk about them in conversation."
dongsheng@627 10457 msgstr ""
dongsheng@627 10458
dongsheng@627 10459 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 10460 #: ../en/ch08-branch.xml:251
dongsheng@627 10461 msgid ""
dongsheng@627 10462 "<quote>Little picture</quote> branches are artefacts of the day-to-day "
dongsheng@627 10463 "activity of developing and merging changes. They expose the narrative of how "
dongsheng@627 10464 "the code was developed."
dongsheng@627 10465 msgstr ""
dongsheng@627 10466
dongsheng@627 10467 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 10468 #: ../en/ch08-branch.xml:259
dongsheng@627 10469 msgid "Managing big-picture branches in repositories"
dongsheng@635 10470 msgstr "在版本库中管理分支"
dongsheng@627 10471
dongsheng@627 10472 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 10473 #: ../en/ch08-branch.xml:261
dongsheng@627 10474 msgid ""
dongsheng@627 10475 "The easiest way to isolate a <quote>big picture</quote> branch in Mercurial "
songdongsheng@668 10476 "is in a dedicated repository. If you have an existing shared "
songdongsheng@668 10477 "repository&emdash;let's call it <literal>myproject</literal>&emdash;that "
songdongsheng@668 10478 "reaches a <quote>1.0</quote> milestone, you can start to prepare for future "
songdongsheng@668 10479 "maintenance releases on top of version 1.0 by tagging the revision from which "
songdongsheng@668 10480 "you prepared the 1.0 release."
dongsheng@627 10481 msgstr ""
dongsheng@627 10482
dongsheng@627 10483 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 10484 #: ../en/ch08-branch.xml:271
dongsheng@627 10485 msgid ""
dongsheng@627 10486 "You can then clone a new shared <literal>myproject-1.0.1</literal> repository "
dongsheng@627 10487 "as of that tag."
dongsheng@627 10488 msgstr ""
dongsheng@627 10489
dongsheng@627 10490 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 10491 #: ../en/ch08-branch.xml:277
dongsheng@627 10492 msgid ""
dongsheng@627 10493 "Afterwards, if someone needs to work on a bug fix that ought to go into an "
dongsheng@627 10494 "upcoming 1.0.1 minor release, they clone the <literal>myproject-1.0.1</"
dongsheng@627 10495 "literal> repository, make their changes, and push them back."
dongsheng@627 10496 msgstr ""
dongsheng@627 10497
dongsheng@627 10498 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 10499 #: ../en/ch08-branch.xml:284
dongsheng@627 10500 msgid ""
dongsheng@627 10501 "Meanwhile, development for the next major release can continue, isolated and "
dongsheng@627 10502 "unabated, in the <literal>myproject</literal> repository."
dongsheng@627 10503 msgstr ""
dongsheng@627 10504
dongsheng@627 10505 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 10506 #: ../en/ch08-branch.xml:292
dongsheng@627 10507 msgid "Don't repeat yourself: merging across branches"
dongsheng@635 10508 msgstr "不要重复劳动:在分支间合并"
dongsheng@627 10509
dongsheng@627 10510 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 10511 #: ../en/ch08-branch.xml:294
dongsheng@627 10512 msgid ""
dongsheng@627 10513 "In many cases, if you have a bug to fix on a maintenance branch, the chances "
dongsheng@627 10514 "are good that the bug exists on your project's main branch (and possibly "
dongsheng@627 10515 "other maintenance branches, too). It's a rare developer who wants to fix the "
dongsheng@627 10516 "same bug multiple times, so let's look at a few ways that Mercurial can help "
dongsheng@627 10517 "you to manage these bugfixes without duplicating your work."
dongsheng@627 10518 msgstr ""
dongsheng@627 10519
dongsheng@627 10520 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 10521 #: ../en/ch08-branch.xml:302
dongsheng@627 10522 msgid ""
dongsheng@627 10523 "In the simplest instance, all you need to do is pull changes from your "
dongsheng@627 10524 "maintenance branch into your local clone of the target branch."
dongsheng@627 10525 msgstr ""
dongsheng@627 10526
dongsheng@627 10527 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 10528 #: ../en/ch08-branch.xml:308
dongsheng@627 10529 msgid ""
dongsheng@627 10530 "You'll then need to merge the heads of the two branches, and push back to the "
dongsheng@627 10531 "main branch."
dongsheng@627 10532 msgstr ""
dongsheng@627 10533
dongsheng@627 10534 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 10535 #: ../en/ch08-branch.xml:315
dongsheng@627 10536 msgid "Naming branches within one repository"
dongsheng@635 10537 msgstr "版本库中的命名分支"
dongsheng@627 10538
dongsheng@627 10539 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 10540 #: ../en/ch08-branch.xml:317
dongsheng@627 10541 msgid ""
dongsheng@627 10542 "In most instances, isolating branches in repositories is the right approach. "
dongsheng@627 10543 "Its simplicity makes it easy to understand; and so it's hard to make "
dongsheng@627 10544 "mistakes. There's a one-to-one relationship between branches you're working "
dongsheng@627 10545 "in and directories on your system. This lets you use normal (non-Mercurial-"
dongsheng@627 10546 "aware) tools to work on files within a branch/repository."
dongsheng@627 10547 msgstr ""
dongsheng@627 10548
dongsheng@627 10549 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 10550 #: ../en/ch08-branch.xml:324
dongsheng@627 10551 msgid ""
dongsheng@627 10552 "If you're more in the <quote>power user</quote> category (<emphasis>and</"
dongsheng@627 10553 "emphasis> your collaborators are too), there is an alternative way of "
dongsheng@627 10554 "handling branches that you can consider. I've already mentioned the human-"
dongsheng@627 10555 "level distinction between <quote>small picture</quote> and <quote>big "
dongsheng@627 10556 "picture</quote> branches. While Mercurial works with multiple <quote>small "
dongsheng@627 10557 "picture</quote> branches in a repository all the time (for example after you "
dongsheng@627 10558 "pull changes in, but before you merge them), it can <emphasis>also</emphasis> "
dongsheng@627 10559 "work with multiple <quote>big picture</quote> branches."
dongsheng@627 10560 msgstr ""
dongsheng@627 10561
dongsheng@627 10562 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 10563 #: ../en/ch08-branch.xml:335
dongsheng@627 10564 msgid ""
dongsheng@627 10565 "The key to working this way is that Mercurial lets you assign a persistent "
dongsheng@627 10566 "<emphasis>name</emphasis> to a branch. There always exists a branch named "
dongsheng@627 10567 "<literal>default</literal>. Even before you start naming branches yourself, "
dongsheng@627 10568 "you can find traces of the <literal>default</literal> branch if you look for "
dongsheng@627 10569 "them."
dongsheng@627 10570 msgstr ""
dongsheng@627 10571
dongsheng@627 10572 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 10573 #: ../en/ch08-branch.xml:342
dongsheng@627 10574 msgid ""
dongsheng@627 10575 "As an example, when you run the <command role=\"hg-cmd\">hg commit</command> "
dongsheng@627 10576 "command, and it pops up your editor so that you can enter a commit message, "
dongsheng@627 10577 "look for a line that contains the text <quote><literal>HG: branch default</"
dongsheng@627 10578 "literal></quote> at the bottom. This is telling you that your commit will "
dongsheng@627 10579 "occur on the branch named <literal>default</literal>."
dongsheng@627 10580 msgstr ""
dongsheng@627 10581
dongsheng@627 10582 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 10583 #: ../en/ch08-branch.xml:349
dongsheng@627 10584 msgid ""
dongsheng@627 10585 "To start working with named branches, use the <command role=\"hg-cmd\">hg "
dongsheng@627 10586 "branches</command> command. This command lists the named branches already "
dongsheng@627 10587 "present in your repository, telling you which changeset is the tip of each."
dongsheng@627 10588 msgstr ""
dongsheng@627 10589
dongsheng@627 10590 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 10591 #: ../en/ch08-branch.xml:356
dongsheng@627 10592 msgid ""
dongsheng@627 10593 "Since you haven't created any named branches yet, the only one that exists is "
dongsheng@627 10594 "<literal>default</literal>."
dongsheng@627 10595 msgstr ""
dongsheng@627 10596
dongsheng@627 10597 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 10598 #: ../en/ch08-branch.xml:359
dongsheng@627 10599 msgid ""
dongsheng@627 10600 "To find out what the <quote>current</quote> branch is, run the <command role="
dongsheng@627 10601 "\"hg-cmd\">hg branch</command> command, giving it no arguments. This tells "
dongsheng@627 10602 "you what branch the parent of the current changeset is on."
dongsheng@627 10603 msgstr ""
dongsheng@627 10604
dongsheng@627 10605 #
dongsheng@627 10606 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 10607 #: ../en/ch08-branch.xml:366
dongsheng@627 10608 msgid ""
dongsheng@627 10609 "To create a new branch, run the <command role=\"hg-cmd\">hg branch</command> "
dongsheng@627 10610 "command again. This time, give it one argument: the name of the branch you "
dongsheng@627 10611 "want to create."
dongsheng@627 10612 msgstr ""
dongsheng@627 10613
dongsheng@627 10614 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 10615 #: ../en/ch08-branch.xml:372
dongsheng@627 10616 msgid ""
dongsheng@627 10617 "After you've created a branch, you might wonder what effect the <command role="
dongsheng@627 10618 "\"hg-cmd\">hg branch</command> command has had. What do the <command role="
dongsheng@627 10619 "\"hg-cmd\">hg status</command> and <command role=\"hg-cmd\">hg tip</command> "
dongsheng@627 10620 "commands report?"
dongsheng@627 10621 msgstr ""
dongsheng@627 10622
dongsheng@627 10623 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 10624 #: ../en/ch08-branch.xml:379
dongsheng@627 10625 msgid ""
dongsheng@627 10626 "Nothing has changed in the working directory, and there's been no new history "
dongsheng@627 10627 "created. As this suggests, running the <command role=\"hg-cmd\">hg branch</"
dongsheng@627 10628 "command> command has no permanent effect; it only tells Mercurial what branch "
dongsheng@627 10629 "name to use the <emphasis>next</emphasis> time you commit a changeset."
dongsheng@627 10630 msgstr ""
dongsheng@627 10631
dongsheng@627 10632 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 10633 #: ../en/ch08-branch.xml:386
dongsheng@627 10634 msgid ""
dongsheng@627 10635 "When you commit a change, Mercurial records the name of the branch on which "
dongsheng@627 10636 "you committed. Once you've switched from the <literal>default</literal> "
dongsheng@627 10637 "branch to another and committed, you'll see the name of the new branch show "
dongsheng@627 10638 "up in the output of <command role=\"hg-cmd\">hg log</command>, <command role="
dongsheng@627 10639 "\"hg-cmd\">hg tip</command>, and other commands that display the same kind of "
dongsheng@627 10640 "output."
dongsheng@627 10641 msgstr ""
dongsheng@627 10642
dongsheng@627 10643 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 10644 #: ../en/ch08-branch.xml:396
dongsheng@627 10645 msgid ""
dongsheng@627 10646 "The <command role=\"hg-cmd\">hg log</command>-like commands will print the "
dongsheng@627 10647 "branch name of every changeset that's not on the <literal>default</literal> "
dongsheng@627 10648 "branch. As a result, if you never use named branches, you'll never see this "
dongsheng@627 10649 "information."
dongsheng@627 10650 msgstr ""
dongsheng@627 10651
dongsheng@627 10652 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 10653 #: ../en/ch08-branch.xml:401
dongsheng@627 10654 msgid ""
dongsheng@627 10655 "Once you've named a branch and committed a change with that name, every "
dongsheng@627 10656 "subsequent commit that descends from that change will inherit the same branch "
dongsheng@627 10657 "name. You can change the name of a branch at any time, using the <command "
dongsheng@627 10658 "role=\"hg-cmd\">hg branch</command> command."
dongsheng@627 10659 msgstr ""
dongsheng@627 10660
dongsheng@627 10661 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 10662 #: ../en/ch08-branch.xml:409
dongsheng@627 10663 msgid ""
dongsheng@627 10664 "In practice, this is something you won't do very often, as branch names tend "
dongsheng@627 10665 "to have fairly long lifetimes. (This isn't a rule, just an observation.)"
dongsheng@627 10666 msgstr ""
dongsheng@627 10667
dongsheng@627 10668 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 10669 #: ../en/ch08-branch.xml:415
dongsheng@627 10670 msgid "Dealing with multiple named branches in a repository"
dongsheng@635 10671 msgstr "在版本库中处理多个命名分支"
dongsheng@627 10672
dongsheng@627 10673 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 10674 #: ../en/ch08-branch.xml:418
dongsheng@627 10675 msgid ""
dongsheng@627 10676 "If you have more than one named branch in a repository, Mercurial will "
dongsheng@714 10677 "remember the branch that your working directory is on when you start a "
dongsheng@714 10678 "command like <command role=\"hg-cmd\">hg update</command> or <command role="
dongsheng@714 10679 "\"hg-cmd\">hg pull -u</command>. It will update the working directory to the "
dongsheng@714 10680 "tip of this branch, no matter what the <quote>repo-wide</quote> tip is. To "
dongsheng@714 10681 "update to a revision that's on a different named branch, you may need to use "
dongsheng@714 10682 "the <option role=\"hg-opt-update\">-C</option> option to <command role=\"hg-"
dongsheng@714 10683 "cmd\">hg update</command>."
dongsheng@714 10684 msgstr ""
dongsheng@714 10685
dongsheng@714 10686 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 10687 #: ../en/ch08-branch.xml:428
dongsheng@627 10688 msgid ""
songdongsheng@710 10689 "This behavior is a little subtle, so let's see it in action. First, let's "
dongsheng@627 10690 "remind ourselves what branch we're currently on, and what branches are in our "
dongsheng@627 10691 "repository."
dongsheng@627 10692 msgstr ""
dongsheng@627 10693
dongsheng@627 10694 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 10695 #: ../en/ch08-branch.xml:434
dongsheng@627 10696 msgid ""
dongsheng@627 10697 "We're on the <literal>bar</literal> branch, but there also exists an older "
dongsheng@627 10698 "<command role=\"hg-cmd\">hg foo</command> branch."
dongsheng@627 10699 msgstr ""
dongsheng@627 10700
dongsheng@627 10701 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 10702 #: ../en/ch08-branch.xml:438
dongsheng@627 10703 msgid ""
dongsheng@627 10704 "We can <command role=\"hg-cmd\">hg update</command> back and forth between "
dongsheng@627 10705 "the tips of the <literal>foo</literal> and <literal>bar</literal> branches "
dongsheng@627 10706 "without needing to use the <option role=\"hg-opt-update\">-C</option> option, "
dongsheng@627 10707 "because this only involves going backwards and forwards linearly through our "
dongsheng@627 10708 "change history."
dongsheng@627 10709 msgstr ""
dongsheng@627 10710
dongsheng@627 10711 #
dongsheng@627 10712 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 10713 #: ../en/ch08-branch.xml:447
dongsheng@627 10714 msgid ""
dongsheng@627 10715 "If we go back to the <literal>foo</literal> branch and then run <command role="
dongsheng@627 10716 "\"hg-cmd\">hg update</command>, it will keep us on <literal>foo</literal>, "
dongsheng@627 10717 "not move us to the tip of <literal>bar</literal>."
dongsheng@627 10718 msgstr ""
dongsheng@627 10719
dongsheng@627 10720 #
dongsheng@627 10721 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 10722 #: ../en/ch08-branch.xml:454
dongsheng@627 10723 msgid ""
dongsheng@627 10724 "Committing a new change on the <literal>foo</literal> branch introduces a new "
dongsheng@627 10725 "head."
dongsheng@627 10726 msgstr ""
dongsheng@627 10727
dongsheng@627 10728 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 10729 #: ../en/ch08-branch.xml:461
dongsheng@627 10730 msgid "Branch names and merging"
dongsheng@635 10731 msgstr "分支名称与合并"
dongsheng@627 10732
dongsheng@627 10733 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 10734 #: ../en/ch08-branch.xml:463
dongsheng@627 10735 msgid ""
dongsheng@627 10736 "As you've probably noticed, merges in Mercurial are not symmetrical. Let's "
dongsheng@627 10737 "say our repository has two heads, 17 and 23. If I <command role=\"hg-cmd"
dongsheng@627 10738 "\">hg update</command> to 17 and then <command role=\"hg-cmd\">hg merge</"
dongsheng@627 10739 "command> with 23, Mercurial records 17 as the first parent of the merge, and "
dongsheng@627 10740 "23 as the second. Whereas if I <command role=\"hg-cmd\">hg update</command> "
dongsheng@627 10741 "to 23 and then <command role=\"hg-cmd\">hg merge</command> with 17, it "
dongsheng@627 10742 "records 23 as the first parent, and 17 as the second."
dongsheng@627 10743 msgstr ""
dongsheng@627 10744
dongsheng@627 10745 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 10746 #: ../en/ch08-branch.xml:473
dongsheng@627 10747 msgid ""
dongsheng@627 10748 "This affects Mercurial's choice of branch name when you merge. After a "
dongsheng@627 10749 "merge, Mercurial will retain the branch name of the first parent when you "
dongsheng@627 10750 "commit the result of the merge. If your first parent's branch name is "
dongsheng@627 10751 "<literal>foo</literal>, and you merge with <literal>bar</literal>, the branch "
dongsheng@627 10752 "name will still be <literal>foo</literal> after you merge."
dongsheng@627 10753 msgstr ""
dongsheng@627 10754
dongsheng@627 10755 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 10756 #: ../en/ch08-branch.xml:480
dongsheng@627 10757 msgid ""
dongsheng@627 10758 "It's not unusual for a repository to contain multiple heads, each with the "
dongsheng@627 10759 "same branch name. Let's say I'm working on the <literal>foo</literal> "
dongsheng@627 10760 "branch, and so are you. We commit different changes; I pull your changes; I "
dongsheng@627 10761 "now have two heads, each claiming to be on the <literal>foo</literal> "
dongsheng@627 10762 "branch. The result of a merge will be a single head on the <literal>foo</"
dongsheng@627 10763 "literal> branch, as you might hope."
dongsheng@627 10764 msgstr ""
dongsheng@627 10765
dongsheng@627 10766 #
dongsheng@627 10767 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 10768 #: ../en/ch08-branch.xml:488
dongsheng@627 10769 msgid ""
dongsheng@627 10770 "But if I'm working on the <literal>bar</literal> branch, and I merge work "
dongsheng@627 10771 "from the <literal>foo</literal> branch, the result will remain on the "
dongsheng@627 10772 "<literal>bar</literal> branch."
dongsheng@627 10773 msgstr ""
dongsheng@627 10774
dongsheng@627 10775 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 10776 #: ../en/ch08-branch.xml:494
dongsheng@627 10777 msgid ""
dongsheng@627 10778 "To give a more concrete example, if I'm working on the <literal>bleeding-"
dongsheng@627 10779 "edge</literal> branch, and I want to bring in the latest fixes from the "
dongsheng@627 10780 "<literal>stable</literal> branch, Mercurial will choose the <quote>right</"
dongsheng@627 10781 "quote> (<literal>bleeding-edge</literal>) branch name when I pull and merge "
dongsheng@627 10782 "from <literal>stable</literal>."
dongsheng@627 10783 msgstr ""
dongsheng@627 10784
dongsheng@627 10785 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 10786 #: ../en/ch08-branch.xml:503
dongsheng@627 10787 msgid "Branch naming is generally useful"
dongsheng@635 10788 msgstr "分支名称通常都很有用"
dongsheng@627 10789
dongsheng@627 10790 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 10791 #: ../en/ch08-branch.xml:505
dongsheng@627 10792 msgid ""
dongsheng@627 10793 "You shouldn't think of named branches as applicable only to situations where "
dongsheng@627 10794 "you have multiple long-lived branches cohabiting in a single repository. "
dongsheng@627 10795 "They're very useful even in the one-branch-per-repository case."
dongsheng@627 10796 msgstr ""
dongsheng@627 10797
dongsheng@627 10798 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 10799 #: ../en/ch08-branch.xml:510
dongsheng@627 10800 msgid ""
dongsheng@627 10801 "In the simplest case, giving a name to each branch gives you a permanent "
dongsheng@627 10802 "record of which branch a changeset originated on. This gives you more "
dongsheng@627 10803 "context when you're trying to follow the history of a long-lived branchy "
dongsheng@627 10804 "project."
dongsheng@627 10805 msgstr ""
dongsheng@627 10806
dongsheng@627 10807 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 10808 #: ../en/ch08-branch.xml:515
dongsheng@627 10809 msgid ""
dongsheng@627 10810 "If you're working with shared repositories, you can set up a <literal role="
dongsheng@627 10811 "\"hook\">pretxnchangegroup</literal> hook on each that will block incoming "
dongsheng@627 10812 "changes that have the <quote>wrong</quote> branch name. This provides a "
dongsheng@627 10813 "simple, but effective, defence against people accidentally pushing changes "
dongsheng@627 10814 "from a <quote>bleeding edge</quote> branch to a <quote>stable</quote> "
dongsheng@627 10815 "branch. Such a hook might look like this inside the shared repo's <filename "
dongsheng@627 10816 "role=\"special\"> /.hgrc</filename>."
dongsheng@627 10817 msgstr ""
dongsheng@627 10818
dongsheng@627 10819 #. type: Content of: <book><chapter><title>
dongsheng@714 10820 #: ../en/ch09-undo.xml:5
dongsheng@627 10821 msgid "Finding and fixing mistakes"
dongsheng@627 10822 msgstr "查找和修改错误"
dongsheng@627 10823
dongsheng@627 10824 #. type: Content of: <book><chapter><para>
dongsheng@714 10825 #: ../en/ch09-undo.xml:7
dongsheng@627 10826 msgid ""
dongsheng@627 10827 "To err might be human, but to really handle the consequences well takes a top-"
dongsheng@627 10828 "notch revision control system. In this chapter, we'll discuss some of the "
dongsheng@627 10829 "techniques you can use when you find that a problem has crept into your "
dongsheng@627 10830 "project. Mercurial has some highly capable features that will help you to "
dongsheng@627 10831 "isolate the sources of problems, and to handle them appropriately."
dongsheng@627 10832 msgstr ""
dongsheng@627 10833
dongsheng@627 10834 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 10835 #: ../en/ch09-undo.xml:15
dongsheng@627 10836 msgid "Erasing local history"
dongsheng@635 10837 msgstr "销毁本地历史"
dongsheng@627 10838
dongsheng@627 10839 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 10840 #: ../en/ch09-undo.xml:18
dongsheng@627 10841 msgid "The accidental commit"
dongsheng@635 10842 msgstr "意外的提交"
dongsheng@627 10843
dongsheng@627 10844 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 10845 #: ../en/ch09-undo.xml:20
dongsheng@627 10846 msgid ""
dongsheng@627 10847 "I have the occasional but persistent problem of typing rather more quickly "
dongsheng@627 10848 "than I can think, which sometimes results in me committing a changeset that "
dongsheng@627 10849 "is either incomplete or plain wrong. In my case, the usual kind of "
dongsheng@627 10850 "incomplete changeset is one in which I've created a new source file, but "
dongsheng@627 10851 "forgotten to <command role=\"hg-cmd\">hg add</command> it. A <quote>plain "
dongsheng@627 10852 "wrong</quote> changeset is not as common, but no less annoying."
dongsheng@627 10853 msgstr ""
dongsheng@627 10854
dongsheng@627 10855 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 10856 #: ../en/ch09-undo.xml:31
dongsheng@627 10857 msgid "Rolling back a transaction"
dongsheng@635 10858 msgstr "回滚一个事务"
dongsheng@627 10859
dongsheng@627 10860 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 10861 #: ../en/ch09-undo.xml:33
dongsheng@627 10862 msgid ""
songdongsheng@658 10863 "In <xref linkend=\"sec:concepts:txn\"/>, I mentioned that Mercurial treats "
songdongsheng@658 10864 "each modification of a repository as a <emphasis>transaction</emphasis>. "
songdongsheng@658 10865 "Every time you commit a changeset or pull changes from another repository, "
songdongsheng@658 10866 "Mercurial remembers what you did. You can undo, or <emphasis>roll back</"
songdongsheng@658 10867 "emphasis>, exactly one of these actions using the <command role=\"hg-cmd\">hg "
songdongsheng@658 10868 "rollback</command> command. (See <xref linkend=\"sec:undo:rollback-after-push"
songdongsheng@658 10869 "\"/> for an important caveat about the use of this command.)"
dongsheng@627 10870 msgstr ""
dongsheng@627 10871
dongsheng@627 10872 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 10873 #: ../en/ch09-undo.xml:43
dongsheng@627 10874 msgid ""
dongsheng@627 10875 "Here's a mistake that I often find myself making: committing a change in "
dongsheng@627 10876 "which I've created a new file, but forgotten to <command role=\"hg-cmd\">hg "
dongsheng@627 10877 "add</command> it."
dongsheng@627 10878 msgstr ""
dongsheng@627 10879
dongsheng@627 10880 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 10881 #: ../en/ch09-undo.xml:50
dongsheng@627 10882 msgid ""
dongsheng@627 10883 "Looking at the output of <command role=\"hg-cmd\">hg status</command> after "
dongsheng@627 10884 "the commit immediately confirms the error."
dongsheng@627 10885 msgstr ""
dongsheng@627 10886
dongsheng@627 10887 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 10888 #: ../en/ch09-undo.xml:56
dongsheng@627 10889 msgid ""
dongsheng@627 10890 "The commit captured the changes to the file <filename>a</filename>, but not "
dongsheng@627 10891 "the new file <filename>b</filename>. If I were to push this changeset to a "
dongsheng@627 10892 "repository that I shared with a colleague, the chances are high that "
dongsheng@627 10893 "something in <filename>a</filename> would refer to <filename>b</filename>, "
dongsheng@627 10894 "which would not be present in their repository when they pulled my changes. "
dongsheng@627 10895 "I would thus become the object of some indignation."
dongsheng@627 10896 msgstr ""
dongsheng@627 10897
dongsheng@627 10898 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 10899 #: ../en/ch09-undo.xml:65
dongsheng@627 10900 msgid ""
songdongsheng@668 10901 "However, luck is with me&emdash;I've caught my error before I pushed the "
songdongsheng@668 10902 "changeset. I use the <command role=\"hg-cmd\">hg rollback</command> command, "
songdongsheng@668 10903 "and Mercurial makes that last changeset vanish."
dongsheng@627 10904 msgstr ""
dongsheng@627 10905
dongsheng@627 10906 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 10907 #: ../en/ch09-undo.xml:72
dongsheng@627 10908 msgid ""
dongsheng@627 10909 "Notice that the changeset is no longer present in the repository's history, "
dongsheng@627 10910 "and the working directory once again thinks that the file <filename>a</"
dongsheng@627 10911 "filename> is modified. The commit and rollback have left the working "
dongsheng@627 10912 "directory exactly as it was prior to the commit; the changeset has been "
dongsheng@627 10913 "completely erased. I can now safely <command role=\"hg-cmd\">hg add</"
dongsheng@627 10914 "command> the file <filename>b</filename>, and rerun my commit."
dongsheng@627 10915 msgstr ""
dongsheng@627 10916
dongsheng@627 10917 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 10918 #: ../en/ch09-undo.xml:85
dongsheng@627 10919 msgid "The erroneous pull"
dongsheng@635 10920 msgstr "错误的抓取"
dongsheng@627 10921
dongsheng@627 10922 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 10923 #: ../en/ch09-undo.xml:87
dongsheng@627 10924 msgid ""
dongsheng@627 10925 "It's common practice with Mercurial to maintain separate development branches "
dongsheng@627 10926 "of a project in different repositories. Your development team might have one "
dongsheng@627 10927 "shared repository for your project's <quote>0.9</quote> release, and another, "
dongsheng@627 10928 "containing different changes, for the <quote>1.0</quote> release."
dongsheng@627 10929 msgstr ""
dongsheng@627 10930
dongsheng@627 10931 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 10932 #: ../en/ch09-undo.xml:94
dongsheng@627 10933 msgid ""
dongsheng@627 10934 "Given this, you can imagine that the consequences could be messy if you had a "
dongsheng@627 10935 "local <quote>0.9</quote> repository, and accidentally pulled changes from the "
dongsheng@627 10936 "shared <quote>1.0</quote> repository into it. At worst, you could be paying "
dongsheng@627 10937 "insufficient attention, and push those changes into the shared <quote>0.9</"
dongsheng@627 10938 "quote> tree, confusing your entire team (but don't worry, we'll return to "
dongsheng@627 10939 "this horror scenario later). However, it's more likely that you'll notice "
dongsheng@627 10940 "immediately, because Mercurial will display the URL it's pulling from, or you "
dongsheng@627 10941 "will see it pull a suspiciously large number of changes into the repository."
dongsheng@627 10942 msgstr ""
dongsheng@627 10943
dongsheng@627 10944 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 10945 #: ../en/ch09-undo.xml:106
dongsheng@627 10946 msgid ""
dongsheng@627 10947 "The <command role=\"hg-cmd\">hg rollback</command> command will work nicely "
dongsheng@627 10948 "to expunge all of the changesets that you just pulled. Mercurial groups all "
dongsheng@627 10949 "changes from one <command role=\"hg-cmd\">hg pull</command> into a single "
dongsheng@627 10950 "transaction, so one <command role=\"hg-cmd\">hg rollback</command> is all you "
dongsheng@627 10951 "need to undo this mistake."
dongsheng@627 10952 msgstr ""
dongsheng@627 10953
dongsheng@627 10954 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 10955 #: ../en/ch09-undo.xml:115
dongsheng@627 10956 msgid "Rolling back is useless once you've pushed"
dongsheng@635 10957 msgstr "当完成推送后,回滚是无效的"
dongsheng@627 10958
dongsheng@627 10959 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 10960 #: ../en/ch09-undo.xml:117
dongsheng@627 10961 msgid ""
dongsheng@627 10962 "The value of the <command role=\"hg-cmd\">hg rollback</command> command drops "
dongsheng@627 10963 "to zero once you've pushed your changes to another repository. Rolling back "
dongsheng@627 10964 "a change makes it disappear entirely, but <emphasis>only</emphasis> in the "
dongsheng@627 10965 "repository in which you perform the <command role=\"hg-cmd\">hg rollback</"
dongsheng@627 10966 "command>. Because a rollback eliminates history, there's no way for the "
dongsheng@627 10967 "disappearance of a change to propagate between repositories."
dongsheng@627 10968 msgstr ""
dongsheng@627 10969
dongsheng@627 10970 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 10971 #: ../en/ch09-undo.xml:126
dongsheng@627 10972 msgid ""
songdongsheng@668 10973 "If you've pushed a change to another repository&emdash;particularly if it's a "
songdongsheng@668 10974 "shared repository&emdash;it has essentially <quote>escaped into the wild,</"
dongsheng@714 10975 "quote> and you'll have to recover from your mistake in a different way. If "
dongsheng@714 10976 "you push a changeset somewhere, then roll it back, then pull from the "
dongsheng@714 10977 "repository you pushed to, the changeset you thought you'd gotten rid of will "
dongsheng@714 10978 "simply reappear in your repository."
dongsheng@714 10979 msgstr ""
dongsheng@714 10980
dongsheng@714 10981 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 10982 #: ../en/ch09-undo.xml:135
dongsheng@627 10983 msgid ""
dongsheng@627 10984 "(If you absolutely know for sure that the change you want to roll back is the "
dongsheng@627 10985 "most recent change in the repository that you pushed to, <emphasis>and</"
dongsheng@627 10986 "emphasis> you know that nobody else could have pulled it from that "
dongsheng@627 10987 "repository, you can roll back the changeset there, too, but you really should "
dongsheng@714 10988 "not expect this to work reliably. Sooner or later a change really will make "
dongsheng@714 10989 "it into a repository that you don't directly control (or have forgotten "
dongsheng@714 10990 "about), and come back to bite you.)"
dongsheng@627 10991 msgstr ""
dongsheng@627 10992
dongsheng@627 10993 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 10994 #: ../en/ch09-undo.xml:147
dongsheng@627 10995 msgid "You can only roll back once"
dongsheng@635 10996 msgstr "你只能回滚一次"
dongsheng@627 10997
dongsheng@627 10998 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 10999 #: ../en/ch09-undo.xml:149
dongsheng@627 11000 msgid ""
dongsheng@627 11001 "Mercurial stores exactly one transaction in its transaction log; that "
dongsheng@627 11002 "transaction is the most recent one that occurred in the repository. This "
dongsheng@627 11003 "means that you can only roll back one transaction. If you expect to be able "
songdongsheng@710 11004 "to roll back one transaction, then its predecessor, this is not the behavior "
dongsheng@627 11005 "you will get."
dongsheng@627 11006 msgstr ""
dongsheng@627 11007
dongsheng@627 11008 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 11009 #: ../en/ch09-undo.xml:158
dongsheng@627 11010 msgid ""
dongsheng@627 11011 "Once you've rolled back one transaction in a repository, you can't roll back "
dongsheng@627 11012 "again in that repository until you perform another commit or pull."
dongsheng@627 11013 msgstr ""
dongsheng@627 11014
dongsheng@627 11015 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 11016 #: ../en/ch09-undo.xml:165
dongsheng@627 11017 msgid "Reverting the mistaken change"
dongsheng@635 11018 msgstr "撤销错误的修改"
dongsheng@627 11019
dongsheng@627 11020 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 11021 #: ../en/ch09-undo.xml:167
dongsheng@627 11022 msgid ""
dongsheng@627 11023 "If you make a modification to a file, and decide that you really didn't want "
dongsheng@627 11024 "to change the file at all, and you haven't yet committed your changes, the "
dongsheng@627 11025 "<command role=\"hg-cmd\">hg revert</command> command is the one you'll need. "
dongsheng@627 11026 "It looks at the changeset that's the parent of the working directory, and "
dongsheng@627 11027 "restores the contents of the file to their state as of that changeset. "
dongsheng@627 11028 "(That's a long-winded way of saying that, in the normal case, it undoes your "
dongsheng@627 11029 "modifications.)"
dongsheng@627 11030 msgstr ""
dongsheng@627 11031
dongsheng@627 11032 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 11033 #: ../en/ch09-undo.xml:176
dongsheng@627 11034 msgid ""
dongsheng@627 11035 "Let's illustrate how the <command role=\"hg-cmd\">hg revert</command> command "
dongsheng@627 11036 "works with yet another small example. We'll begin by modifying a file that "
dongsheng@627 11037 "Mercurial is already tracking."
dongsheng@627 11038 msgstr ""
dongsheng@627 11039
dongsheng@627 11040 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 11041 #: ../en/ch09-undo.xml:183
dongsheng@627 11042 msgid ""
dongsheng@627 11043 "If we don't want that change, we can simply <command role=\"hg-cmd\">hg "
dongsheng@627 11044 "revert</command> the file."
dongsheng@627 11045 msgstr ""
dongsheng@627 11046
dongsheng@627 11047 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 11048 #: ../en/ch09-undo.xml:189
dongsheng@627 11049 msgid ""
dongsheng@627 11050 "The <command role=\"hg-cmd\">hg revert</command> command provides us with an "
dongsheng@627 11051 "extra degree of safety by saving our modified file with a <filename>.orig</"
dongsheng@627 11052 "filename> extension."
dongsheng@627 11053 msgstr ""
dongsheng@627 11054
dongsheng@714 11055 #. type: Content of: <book><chapter><sect1><tip><title>
dongsheng@714 11056 #: ../en/ch09-undo.xml:197
dongsheng@714 11057 msgid "Be careful with <filename>.orig</filename> files"
dongsheng@715 11058 msgstr "小心 <filename>.orig</filename> 文件"
dongsheng@714 11059
dongsheng@714 11060 #. type: Content of: <book><chapter><sect1><tip><para>
dongsheng@714 11061 #: ../en/ch09-undo.xml:199
dongsheng@714 11062 msgid ""
dongsheng@714 11063 "It's extremely unlikely that you are either using Mercurial to manage files "
dongsheng@714 11064 "with <filename>.orig</filename> extensions or that you even care about the "
dongsheng@714 11065 "contents of such files. Just in case, though, it's useful to remember that "
dongsheng@714 11066 "<command role=\"hg-cmd\">hg revert</command> will unconditionally overwrite "
dongsheng@714 11067 "an existing file with a <filename>.orig</filename> extension. For instance, "
dongsheng@714 11068 "if you already have a file named <filename>foo.orig</filename> when you "
dongsheng@714 11069 "revert <filename>foo</filename>, the contents of <filename>foo.orig</"
dongsheng@714 11070 "filename> will be clobbered."
dongsheng@714 11071 msgstr ""
dongsheng@714 11072
dongsheng@714 11073 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 11074 #: ../en/ch09-undo.xml:211
dongsheng@627 11075 msgid ""
dongsheng@627 11076 "Here is a summary of the cases that the <command role=\"hg-cmd\">hg revert</"
dongsheng@627 11077 "command> command can deal with. We will describe each of these in more "
dongsheng@627 11078 "detail in the section that follows."
dongsheng@627 11079 msgstr ""
dongsheng@627 11080
dongsheng@627 11081 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 11082 #: ../en/ch09-undo.xml:216
dongsheng@627 11083 msgid "If you modify a file, it will restore the file to its unmodified state."
dongsheng@627 11084 msgstr ""
dongsheng@627 11085
dongsheng@627 11086 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 11087 #: ../en/ch09-undo.xml:219
dongsheng@627 11088 msgid ""
dongsheng@627 11089 "If you <command role=\"hg-cmd\">hg add</command> a file, it will undo the "
dongsheng@627 11090 "<quote>added</quote> state of the file, but leave the file itself untouched."
dongsheng@627 11091 msgstr ""
dongsheng@627 11092
dongsheng@627 11093 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 11094 #: ../en/ch09-undo.xml:223
dongsheng@627 11095 msgid ""
dongsheng@627 11096 "If you delete a file without telling Mercurial, it will restore the file to "
dongsheng@627 11097 "its unmodified contents."
dongsheng@627 11098 msgstr ""
dongsheng@627 11099
dongsheng@627 11100 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 11101 #: ../en/ch09-undo.xml:226
dongsheng@627 11102 msgid ""
dongsheng@627 11103 "If you use the <command role=\"hg-cmd\">hg remove</command> command to remove "
dongsheng@627 11104 "a file, it will undo the <quote>removed</quote> state of the file, and "
dongsheng@627 11105 "restore the file to its unmodified contents."
dongsheng@627 11106 msgstr ""
dongsheng@627 11107
dongsheng@627 11108 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 11109 #: ../en/ch09-undo.xml:233
dongsheng@627 11110 msgid "File management errors"
dongsheng@635 11111 msgstr "文件管理错误"
dongsheng@627 11112
dongsheng@627 11113 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 11114 #: ../en/ch09-undo.xml:235
dongsheng@627 11115 msgid ""
dongsheng@627 11116 "The <command role=\"hg-cmd\">hg revert</command> command is useful for more "
dongsheng@627 11117 "than just modified files. It lets you reverse the results of all of "
songdongsheng@668 11118 "Mercurial's file management commands&emdash;<command role=\"hg-cmd\">hg add</"
dongsheng@627 11119 "command>, <command role=\"hg-cmd\">hg remove</command>, and so on."
dongsheng@627 11120 msgstr ""
dongsheng@627 11121
dongsheng@627 11122 #
dongsheng@627 11123 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 11124 #: ../en/ch09-undo.xml:241
dongsheng@627 11125 msgid ""
dongsheng@627 11126 "If you <command role=\"hg-cmd\">hg add</command> a file, then decide that in "
dongsheng@627 11127 "fact you don't want Mercurial to track it, use <command role=\"hg-cmd\">hg "
dongsheng@627 11128 "revert</command> to undo the add. Don't worry; Mercurial will not modify the "
dongsheng@627 11129 "file in any way. It will just <quote>unmark</quote> the file."
dongsheng@627 11130 msgstr ""
dongsheng@627 11131
dongsheng@627 11132 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 11133 #: ../en/ch09-undo.xml:249
dongsheng@627 11134 msgid ""
dongsheng@627 11135 "Similarly, if you ask Mercurial to <command role=\"hg-cmd\">hg remove</"
dongsheng@627 11136 "command> a file, you can use <command role=\"hg-cmd\">hg revert</command> to "
dongsheng@627 11137 "restore it to the contents it had as of the parent of the working directory. "
dongsheng@627 11138 "&interaction.daily.revert.remove; This works just as well for a file that you "
dongsheng@627 11139 "deleted by hand, without telling Mercurial (recall that in Mercurial "
dongsheng@627 11140 "terminology, this kind of file is called <quote>missing</quote>)."
dongsheng@627 11141 msgstr ""
dongsheng@627 11142
dongsheng@627 11143 #
dongsheng@627 11144 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 11145 #: ../en/ch09-undo.xml:260
dongsheng@627 11146 msgid ""
dongsheng@627 11147 "If you revert a <command role=\"hg-cmd\">hg copy</command>, the copied-to "
dongsheng@627 11148 "file remains in your working directory afterwards, untracked. Since a copy "
dongsheng@627 11149 "doesn't affect the copied-from file in any way, Mercurial doesn't do anything "
dongsheng@627 11150 "with the copied-from file."
dongsheng@627 11151 msgstr ""
dongsheng@627 11152
dongsheng@627 11153 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 11154 #: ../en/ch09-undo.xml:271
dongsheng@627 11155 msgid "Dealing with committed changes"
dongsheng@635 11156 msgstr "处理已经提交的修改"
dongsheng@627 11157
dongsheng@627 11158 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 11159 #: ../en/ch09-undo.xml:273
dongsheng@714 11160 msgid ""
dongsheng@714 11161 "Consider a case where you have committed a change <emphasis>a</emphasis>, and "
dongsheng@714 11162 "another change <emphasis>b</emphasis> on top of it; you then realise that "
dongsheng@714 11163 "change <emphasis>a</emphasis> was incorrect. Mercurial lets you <quote>back "
dongsheng@714 11164 "out</quote> an entire changeset automatically, and building blocks that let "
dongsheng@714 11165 "you reverse part of a changeset by hand."
dongsheng@714 11166 msgstr ""
dongsheng@714 11167
dongsheng@714 11168 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 11169 #: ../en/ch09-undo.xml:281
dongsheng@627 11170 msgid ""
dongsheng@627 11171 "Before you read this section, here's something to keep in mind: the <command "
dongsheng@714 11172 "role=\"hg-cmd\">hg backout</command> command undoes the effect of a change by "
dongsheng@714 11173 "<emphasis>adding</emphasis> to your repository's history, not by modifying or "
dongsheng@714 11174 "erasing it. It's the right tool to use if you're fixing bugs, but not if "
dongsheng@714 11175 "you're trying to undo some change that has catastrophic consequences. To "
dongsheng@714 11176 "deal with those, see <xref linkend=\"sec:undo:aaaiiieee\"/>."
dongsheng@627 11177 msgstr ""
dongsheng@627 11178
dongsheng@627 11179 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 11180 #: ../en/ch09-undo.xml:291
dongsheng@627 11181 msgid "Backing out a changeset"
dongsheng@635 11182 msgstr "恢复一个修改集"
dongsheng@627 11183
dongsheng@627 11184 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 11185 #: ../en/ch09-undo.xml:293
dongsheng@627 11186 msgid ""
dongsheng@627 11187 "The <command role=\"hg-cmd\">hg backout</command> command lets you "
dongsheng@627 11188 "<quote>undo</quote> the effects of an entire changeset in an automated "
dongsheng@627 11189 "fashion. Because Mercurial's history is immutable, this command "
dongsheng@627 11190 "<emphasis>does not</emphasis> get rid of the changeset you want to undo. "
dongsheng@627 11191 "Instead, it creates a new changeset that <emphasis>reverses</emphasis> the "
dongsheng@627 11192 "effect of the to-be-undone changeset."
dongsheng@627 11193 msgstr ""
dongsheng@627 11194
dongsheng@627 11195 #
dongsheng@627 11196 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 11197 #: ../en/ch09-undo.xml:302
dongsheng@627 11198 msgid ""
dongsheng@627 11199 "The operation of the <command role=\"hg-cmd\">hg backout</command> command is "
dongsheng@627 11200 "a little intricate, so let's illustrate it with some examples. First, we'll "
dongsheng@627 11201 "create a repository with some simple changes."
dongsheng@627 11202 msgstr ""
dongsheng@627 11203
dongsheng@627 11204 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 11205 #: ../en/ch09-undo.xml:309
dongsheng@627 11206 msgid ""
dongsheng@627 11207 "The <command role=\"hg-cmd\">hg backout</command> command takes a single "
dongsheng@627 11208 "changeset ID as its argument; this is the changeset to back out. Normally, "
dongsheng@627 11209 "<command role=\"hg-cmd\">hg backout</command> will drop you into a text "
dongsheng@627 11210 "editor to write a commit message, so you can record why you're backing the "
dongsheng@627 11211 "change out. In this example, we provide a commit message on the command line "
dongsheng@627 11212 "using the <option role=\"hg-opt-backout\">-m</option> option."
dongsheng@627 11213 msgstr ""
dongsheng@627 11214
dongsheng@627 11215 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 11216 #: ../en/ch09-undo.xml:320
dongsheng@627 11217 msgid "Backing out the tip changeset"
dongsheng@635 11218 msgstr "恢复顶点修改集"
dongsheng@627 11219
dongsheng@627 11220 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 11221 #: ../en/ch09-undo.xml:322
dongsheng@627 11222 msgid "We're going to start by backing out the last changeset we committed."
dongsheng@627 11223 msgstr ""
dongsheng@627 11224
dongsheng@627 11225 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 11226 #: ../en/ch09-undo.xml:327
dongsheng@627 11227 msgid ""
dongsheng@627 11228 "You can see that the second line from <filename>myfile</filename> is no "
dongsheng@627 11229 "longer present. Taking a look at the output of <command role=\"hg-cmd\">hg "
dongsheng@627 11230 "log</command> gives us an idea of what the <command role=\"hg-cmd\">hg "
dongsheng@627 11231 "backout</command> command has done. &interaction.backout.simple.log; Notice "
dongsheng@627 11232 "that the new changeset that <command role=\"hg-cmd\">hg backout</command> has "
dongsheng@627 11233 "created is a child of the changeset we backed out. It's easier to see this "
songdongsheng@658 11234 "in <xref linkend=\"fig:undo:backout\"/>, which presents a graphical view of "
songdongsheng@658 11235 "the change history. As you can see, the history is nice and linear."
songdongsheng@658 11236 msgstr ""
songdongsheng@658 11237
songdongsheng@658 11238 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
dongsheng@714 11239 #: ../en/ch09-undo.xml:340 ../en/ch09-undo.xml:460
dongsheng@627 11240 msgid ""
dongsheng@627 11241 "Backing out a change using the <command role=\"hg-cmd\">hg backout</command> "
dongsheng@627 11242 "command"
dongsheng@660 11243 msgstr "使用 <command role=\"hg-cmd\">hg backout</command> 恢复一个修改"
dongsheng@627 11244
songdongsheng@658 11245 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
dongsheng@714 11246 #: ../en/ch09-undo.xml:343
songdongsheng@658 11247 msgid "<imageobject><imagedata fileref=\"figs/undo-simple.png\"/></imageobject>"
songdongsheng@658 11248 msgstr ""
songdongsheng@658 11249
dongsheng@627 11250 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 11251 #: ../en/ch09-undo.xml:350
dongsheng@627 11252 msgid "Backing out a non-tip change"
dongsheng@635 11253 msgstr "恢复非顶点的修改"
dongsheng@627 11254
dongsheng@627 11255 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 11256 #: ../en/ch09-undo.xml:352
dongsheng@627 11257 msgid ""
dongsheng@627 11258 "If you want to back out a change other than the last one you committed, pass "
dongsheng@627 11259 "the <option role=\"hg-opt-backout\">--merge</option> option to the <command "
dongsheng@627 11260 "role=\"hg-cmd\">hg backout</command> command."
dongsheng@627 11261 msgstr ""
dongsheng@627 11262
dongsheng@627 11263 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 11264 #: ../en/ch09-undo.xml:359
dongsheng@627 11265 msgid ""
dongsheng@627 11266 "This makes backing out any changeset a <quote>one-shot</quote> operation "
dongsheng@627 11267 "that's usually simple and fast."
dongsheng@627 11268 msgstr ""
dongsheng@627 11269
dongsheng@627 11270 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 11271 #: ../en/ch09-undo.xml:365
dongsheng@627 11272 msgid ""
dongsheng@627 11273 "If you take a look at the contents of <filename>myfile</filename> after the "
dongsheng@627 11274 "backout finishes, you'll see that the first and third changes are present, "
dongsheng@627 11275 "but not the second."
dongsheng@627 11276 msgstr ""
dongsheng@627 11277
dongsheng@627 11278 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 11279 #: ../en/ch09-undo.xml:372
songdongsheng@658 11280 msgid ""
songdongsheng@658 11281 "As the graphical history in <xref linkend=\"fig:undo:backout-non-tip\"/> "
dongsheng@714 11282 "illustrates, Mercurial still commits one change in this kind of situation "
dongsheng@714 11283 "(the box-shaped node is the ones that Mercurial commits automatically), but "
dongsheng@714 11284 "the revision graph now looks different. Before Mercurial begins the backout "
dongsheng@714 11285 "process, it first remembers what the current parent of the working directory "
dongsheng@714 11286 "is. It then backs out the target changeset, and commits that as a "
dongsheng@714 11287 "changeset. Finally, it merges back to the previous parent of the working "
dongsheng@714 11288 "directory, but notice that it <emphasis>does not commit</emphasis> the result "
dongsheng@714 11289 "of the merge. The repository now contains two heads, and the working "
dongsheng@714 11290 "directory is in a merge state."
dongsheng@627 11291 msgstr ""
dongsheng@627 11292
songdongsheng@658 11293 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
dongsheng@714 11294 #: ../en/ch09-undo.xml:387
dongsheng@627 11295 msgid ""
dongsheng@627 11296 "Automated backout of a non-tip change using the <command role=\"hg-cmd\">hg "
dongsheng@627 11297 "backout</command> command"
dongsheng@660 11298 msgstr "使用 <command role=\"hg-cmd\">hg backout</command> 自动恢复非顶点的修改"
dongsheng@627 11299
songdongsheng@658 11300 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
dongsheng@714 11301 #: ../en/ch09-undo.xml:390
songdongsheng@658 11302 msgid ""
songdongsheng@658 11303 "<imageobject><imagedata fileref=\"figs/undo-non-tip.png\"/></imageobject>"
songdongsheng@658 11304 msgstr ""
songdongsheng@658 11305
songdongsheng@658 11306 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 11307 #: ../en/ch09-undo.xml:395
dongsheng@627 11308 msgid ""
dongsheng@627 11309 "The result is that you end up <quote>back where you were</quote>, only with "
dongsheng@627 11310 "some extra history that undoes the effect of the changeset you wanted to back "
dongsheng@627 11311 "out."
dongsheng@627 11312 msgstr ""
dongsheng@627 11313
dongsheng@714 11314 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 11315 #: ../en/ch09-undo.xml:399
dongsheng@714 11316 msgid ""
dongsheng@714 11317 "You might wonder why Mercurial does not commit the result of the merge that "
dongsheng@714 11318 "it performed. The reason lies in Mercurial behaving conservatively: a merge "
dongsheng@714 11319 "naturally has more scope for error than simply undoing the effect of the tip "
dongsheng@714 11320 "changeset, so your work will be safest if you first inspect (and test!) the "
dongsheng@714 11321 "result of the merge, <emphasis>then</emphasis> commit it."
dongsheng@714 11322 msgstr ""
dongsheng@714 11323
dongsheng@627 11324 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
dongsheng@714 11325 #: ../en/ch09-undo.xml:408
dongsheng@627 11326 msgid "Always use the <option role=\"hg-opt-backout\">--merge</option> option"
dongsheng@635 11327 msgstr "始终使用选项 <option role=\"hg-opt-backout\">--merge</option>"
dongsheng@627 11328
dongsheng@627 11329 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 11330 #: ../en/ch09-undo.xml:411
dongsheng@627 11331 msgid ""
dongsheng@627 11332 "In fact, since the <option role=\"hg-opt-backout\">--merge</option> option "
dongsheng@627 11333 "will do the <quote>right thing</quote> whether or not the changeset you're "
dongsheng@627 11334 "backing out is the tip (i.e. it won't try to merge if it's backing out the "
dongsheng@627 11335 "tip, since there's no need), you should <emphasis>always</emphasis> use this "
dongsheng@627 11336 "option when you run the <command role=\"hg-cmd\">hg backout</command> command."
dongsheng@627 11337 msgstr ""
dongsheng@627 11338
dongsheng@627 11339 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 11340 #: ../en/ch09-undo.xml:422
dongsheng@627 11341 msgid "Gaining more control of the backout process"
dongsheng@635 11342 msgstr "在恢复处理中获得更多控制"
dongsheng@627 11343
dongsheng@627 11344 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 11345 #: ../en/ch09-undo.xml:424
dongsheng@627 11346 msgid ""
dongsheng@627 11347 "While I've recommended that you always use the <option role=\"hg-opt-backout"
dongsheng@627 11348 "\">--merge</option> option when backing out a change, the <command role=\"hg-"
dongsheng@627 11349 "cmd\">hg backout</command> command lets you decide how to merge a backout "
dongsheng@627 11350 "changeset. Taking control of the backout process by hand is something you "
dongsheng@627 11351 "will rarely need to do, but it can be useful to understand what the <command "
dongsheng@627 11352 "role=\"hg-cmd\">hg backout</command> command is doing for you automatically. "
dongsheng@627 11353 "To illustrate this, let's clone our first repository, but omit the backout "
dongsheng@627 11354 "change that it contains."
dongsheng@627 11355 msgstr ""
dongsheng@627 11356
dongsheng@627 11357 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 11358 #: ../en/ch09-undo.xml:437
dongsheng@627 11359 msgid ""
dongsheng@627 11360 "As with our earlier example, We'll commit a third changeset, then back out "
dongsheng@627 11361 "its parent, and see what happens."
dongsheng@627 11362 msgstr ""
dongsheng@627 11363
dongsheng@627 11364 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 11365 #: ../en/ch09-undo.xml:443
dongsheng@627 11366 msgid ""
dongsheng@627 11367 "Our new changeset is again a descendant of the changeset we backout out; it's "
dongsheng@627 11368 "thus a new head, <emphasis>not</emphasis> a descendant of the changeset that "
dongsheng@627 11369 "was the tip. The <command role=\"hg-cmd\">hg backout</command> command was "
dongsheng@627 11370 "quite explicit in telling us this."
dongsheng@627 11371 msgstr ""
dongsheng@627 11372
dongsheng@627 11373 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 11374 #: ../en/ch09-undo.xml:451
dongsheng@627 11375 msgid ""
dongsheng@627 11376 "Again, it's easier to see what has happened by looking at a graph of the "
songdongsheng@658 11377 "revision history, in <xref linkend=\"fig:undo:backout-manual\"/>. This makes "
songdongsheng@658 11378 "it clear that when we use <command role=\"hg-cmd\">hg backout</command> to "
songdongsheng@658 11379 "back out a change other than the tip, Mercurial adds a new head to the "
songdongsheng@658 11380 "repository (the change it committed is box-shaped)."
songdongsheng@658 11381 msgstr ""
songdongsheng@658 11382
songdongsheng@658 11383 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
dongsheng@714 11384 #: ../en/ch09-undo.xml:463
songdongsheng@658 11385 msgid "<imageobject><imagedata fileref=\"figs/undo-manual.png\"/></imageobject>"
songdongsheng@658 11386 msgstr ""
songdongsheng@658 11387
songdongsheng@658 11388 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 11389 #: ../en/ch09-undo.xml:468
dongsheng@627 11390 msgid ""
dongsheng@627 11391 "After the <command role=\"hg-cmd\">hg backout</command> command has "
dongsheng@627 11392 "completed, it leaves the new <quote>backout</quote> changeset as the parent "
dongsheng@627 11393 "of the working directory."
dongsheng@627 11394 msgstr ""
dongsheng@627 11395
dongsheng@627 11396 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 11397 #: ../en/ch09-undo.xml:475
dongsheng@627 11398 msgid "Now we have two isolated sets of changes."
dongsheng@627 11399 msgstr ""
dongsheng@627 11400
dongsheng@627 11401 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 11402 #: ../en/ch09-undo.xml:479
dongsheng@627 11403 msgid ""
dongsheng@627 11404 "Let's think about what we expect to see as the contents of <filename>myfile</"
dongsheng@627 11405 "filename> now. The first change should be present, because we've never "
dongsheng@627 11406 "backed it out. The second change should be missing, as that's the change we "
dongsheng@627 11407 "backed out. Since the history graph shows the third change as a separate "
dongsheng@627 11408 "head, we <emphasis>don't</emphasis> expect to see the third change present in "
dongsheng@627 11409 "<filename>myfile</filename>."
dongsheng@627 11410 msgstr ""
dongsheng@627 11411
dongsheng@627 11412 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 11413 #: ../en/ch09-undo.xml:489
dongsheng@627 11414 msgid ""
dongsheng@627 11415 "To get the third change back into the file, we just do a normal merge of our "
dongsheng@627 11416 "two heads."
dongsheng@627 11417 msgstr ""
dongsheng@627 11418
dongsheng@627 11419 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 11420 #: ../en/ch09-undo.xml:494
songdongsheng@658 11421 msgid ""
songdongsheng@658 11422 "Afterwards, the graphical history of our repository looks like <xref linkend="
songdongsheng@658 11423 "\"fig:undo:backout-manual-merge\"/>."
songdongsheng@658 11424 msgstr ""
songdongsheng@658 11425
songdongsheng@658 11426 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
dongsheng@714 11427 #: ../en/ch09-undo.xml:499
dongsheng@627 11428 msgid "Manually merging a backout change"
dongsheng@660 11429 msgstr "手工合并恢复修改"
dongsheng@627 11430
songdongsheng@658 11431 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
dongsheng@714 11432 #: ../en/ch09-undo.xml:501
songdongsheng@658 11433 msgid ""
songdongsheng@658 11434 "<imageobject><imagedata fileref=\"figs/undo-manual-merge.png\"/></imageobject>"
songdongsheng@658 11435 msgstr ""
songdongsheng@658 11436
dongsheng@627 11437 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 11438 #: ../en/ch09-undo.xml:508
dongsheng@627 11439 msgid "Why <command role=\"hg-cmd\">hg backout</command> works as it does"
dongsheng@635 11440 msgstr "<command role=\"hg-cmd\">hg backout</command> 的内幕"
dongsheng@627 11441
dongsheng@627 11442 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 11443 #: ../en/ch09-undo.xml:511
dongsheng@627 11444 msgid ""
dongsheng@627 11445 "Here's a brief description of how the <command role=\"hg-cmd\">hg backout</"
dongsheng@627 11446 "command> command works."
dongsheng@627 11447 msgstr ""
dongsheng@627 11448
dongsheng@627 11449 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
dongsheng@714 11450 #: ../en/ch09-undo.xml:514
dongsheng@627 11451 msgid ""
dongsheng@627 11452 "It ensures that the working directory is <quote>clean</quote>, i.e. that the "
dongsheng@627 11453 "output of <command role=\"hg-cmd\">hg status</command> would be empty."
dongsheng@627 11454 msgstr ""
dongsheng@627 11455
dongsheng@627 11456 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
dongsheng@714 11457 #: ../en/ch09-undo.xml:518
dongsheng@627 11458 msgid ""
dongsheng@627 11459 "It remembers the current parent of the working directory. Let's call this "
dongsheng@714 11460 "changeset <literal>orig</literal>."
dongsheng@627 11461 msgstr ""
dongsheng@627 11462
dongsheng@627 11463 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
dongsheng@714 11464 #: ../en/ch09-undo.xml:522
dongsheng@627 11465 msgid ""
dongsheng@627 11466 "It does the equivalent of a <command role=\"hg-cmd\">hg update</command> to "
dongsheng@627 11467 "sync the working directory to the changeset you want to back out. Let's call "
dongsheng@714 11468 "this changeset <literal>backout</literal>."
dongsheng@627 11469 msgstr ""
dongsheng@627 11470
dongsheng@627 11471 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
dongsheng@714 11472 #: ../en/ch09-undo.xml:527
dongsheng@627 11473 msgid ""
dongsheng@627 11474 "It finds the parent of that changeset. Let's call that changeset "
dongsheng@627 11475 "<literal>parent</literal>."
dongsheng@627 11476 msgstr ""
dongsheng@627 11477
dongsheng@627 11478 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
dongsheng@714 11479 #: ../en/ch09-undo.xml:530
dongsheng@627 11480 msgid ""
dongsheng@627 11481 "For each file that the <literal>backout</literal> changeset affected, it does "
dongsheng@627 11482 "the equivalent of a <command role=\"hg-cmd\">hg revert -r parent</command> on "
dongsheng@627 11483 "that file, to restore it to the contents it had before that changeset was "
dongsheng@627 11484 "committed."
dongsheng@627 11485 msgstr ""
dongsheng@627 11486
dongsheng@627 11487 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
dongsheng@714 11488 #: ../en/ch09-undo.xml:537
dongsheng@627 11489 msgid ""
dongsheng@627 11490 "It commits the result as a new changeset. This changeset has "
dongsheng@627 11491 "<literal>backout</literal> as its parent."
dongsheng@627 11492 msgstr ""
dongsheng@627 11493
dongsheng@627 11494 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
dongsheng@714 11495 #: ../en/ch09-undo.xml:541
dongsheng@627 11496 msgid ""
dongsheng@627 11497 "If you specify <option role=\"hg-opt-backout\">--merge</option> on the "
dongsheng@627 11498 "command line, it merges with <literal>orig</literal>, and commits the result "
dongsheng@627 11499 "of the merge."
dongsheng@627 11500 msgstr ""
dongsheng@627 11501
dongsheng@627 11502 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 11503 #: ../en/ch09-undo.xml:547
dongsheng@627 11504 msgid ""
dongsheng@627 11505 "An alternative way to implement the <command role=\"hg-cmd\">hg backout</"
dongsheng@627 11506 "command> command would be to <command role=\"hg-cmd\">hg export</command> the "
dongsheng@627 11507 "to-be-backed-out changeset as a diff, then use the <option role=\"cmd-opt-"
dongsheng@627 11508 "patch\">--reverse</option> option to the <command>patch</command> command to "
dongsheng@627 11509 "reverse the effect of the change without fiddling with the working "
dongsheng@627 11510 "directory. This sounds much simpler, but it would not work nearly as well."
dongsheng@627 11511 msgstr ""
dongsheng@627 11512
dongsheng@627 11513 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 11514 #: ../en/ch09-undo.xml:557
dongsheng@627 11515 msgid ""
dongsheng@627 11516 "The reason that <command role=\"hg-cmd\">hg backout</command> does an update, "
dongsheng@627 11517 "a commit, a merge, and another commit is to give the merge machinery the best "
dongsheng@627 11518 "chance to do a good job when dealing with all the changes <emphasis>between</"
dongsheng@627 11519 "emphasis> the change you're backing out and the current tip."
dongsheng@627 11520 msgstr ""
dongsheng@627 11521
dongsheng@627 11522 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 11523 #: ../en/ch09-undo.xml:564
dongsheng@627 11524 msgid ""
dongsheng@627 11525 "If you're backing out a changeset that's 100 revisions back in your project's "
dongsheng@627 11526 "history, the chances that the <command>patch</command> command will be able "
dongsheng@627 11527 "to apply a reverse diff cleanly are not good, because intervening changes are "
dongsheng@627 11528 "likely to have <quote>broken the context</quote> that <command>patch</"
dongsheng@627 11529 "command> uses to determine whether it can apply a patch (if this sounds like "
songdongsheng@658 11530 "gibberish, see <xref linkend=\"sec:mq:patch\"/> for a discussion of the "
dongsheng@627 11531 "<command>patch</command> command). Also, Mercurial's merge machinery will "
dongsheng@627 11532 "handle files and directories being renamed, permission changes, and "
dongsheng@627 11533 "modifications to binary files, none of which <command>patch</command> can "
dongsheng@627 11534 "deal with."
dongsheng@627 11535 msgstr ""
dongsheng@627 11536
dongsheng@627 11537 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 11538 #: ../en/ch09-undo.xml:581
dongsheng@627 11539 msgid "Changes that should never have been"
dongsheng@635 11540 msgstr "不该发生的修改"
dongsheng@627 11541
dongsheng@627 11542 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 11543 #: ../en/ch09-undo.xml:583
dongsheng@627 11544 msgid ""
dongsheng@627 11545 "Most of the time, the <command role=\"hg-cmd\">hg backout</command> command "
dongsheng@627 11546 "is exactly what you need if you want to undo the effects of a change. It "
dongsheng@627 11547 "leaves a permanent record of exactly what you did, both when committing the "
dongsheng@627 11548 "original changeset and when you cleaned up after it."
dongsheng@627 11549 msgstr ""
dongsheng@627 11550
dongsheng@627 11551 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 11552 #: ../en/ch09-undo.xml:589
dongsheng@627 11553 msgid ""
dongsheng@627 11554 "On rare occasions, though, you may find that you've committed a change that "
dongsheng@627 11555 "really should not be present in the repository at all. For example, it would "
dongsheng@627 11556 "be very unusual, and usually considered a mistake, to commit a software "
dongsheng@627 11557 "project's object files as well as its source files. Object files have almost "
dongsheng@627 11558 "no intrinsic value, and they're <emphasis>big</emphasis>, so they increase "
dongsheng@627 11559 "the size of the repository and the amount of time it takes to clone or pull "
dongsheng@627 11560 "changes."
dongsheng@627 11561 msgstr ""
dongsheng@627 11562
dongsheng@627 11563 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 11564 #: ../en/ch09-undo.xml:598
dongsheng@627 11565 msgid ""
dongsheng@627 11566 "Before I discuss the options that you have if you commit a <quote>brown paper "
dongsheng@627 11567 "bag</quote> change (the kind that's so bad that you want to pull a brown "
dongsheng@627 11568 "paper bag over your head), let me first discuss some approaches that probably "
dongsheng@627 11569 "won't work."
dongsheng@627 11570 msgstr ""
dongsheng@627 11571
dongsheng@627 11572 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 11573 #: ../en/ch09-undo.xml:603
dongsheng@627 11574 msgid ""
songdongsheng@668 11575 "Since Mercurial treats history as accumulative&emdash;every change builds on "
songdongsheng@668 11576 "top of all changes that preceded it&emdash;you generally can't just make "
songdongsheng@668 11577 "disastrous changes disappear. The one exception is when you've just "
songdongsheng@668 11578 "committed a change, and it hasn't been pushed or pulled into another "
songdongsheng@668 11579 "repository. That's when you can safely use the <command role=\"hg-cmd\">hg "
songdongsheng@668 11580 "rollback</command> command, as I detailed in <xref linkend=\"sec:undo:rollback"
songdongsheng@668 11581 "\"/>."
songdongsheng@658 11582 msgstr ""
songdongsheng@658 11583
songdongsheng@658 11584 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 11585 #: ../en/ch09-undo.xml:612
dongsheng@627 11586 msgid ""
dongsheng@627 11587 "After you've pushed a bad change to another repository, you <emphasis>could</"
dongsheng@627 11588 "emphasis> still use <command role=\"hg-cmd\">hg rollback</command> to make "
dongsheng@627 11589 "your local copy of the change disappear, but it won't have the consequences "
dongsheng@627 11590 "you want. The change will still be present in the remote repository, so it "
dongsheng@627 11591 "will reappear in your local repository the next time you pull."
dongsheng@627 11592 msgstr ""
dongsheng@627 11593
dongsheng@627 11594 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 11595 #: ../en/ch09-undo.xml:620
dongsheng@627 11596 msgid ""
dongsheng@627 11597 "If a situation like this arises, and you know which repositories your bad "
dongsheng@627 11598 "change has propagated into, you can <emphasis>try</emphasis> to get rid of "
dongsheng@714 11599 "the change from <emphasis>every</emphasis> one of those repositories. This "
dongsheng@627 11600 "is, of course, not a satisfactory solution: if you miss even a single "
dongsheng@627 11601 "repository while you're expunging, the change is still <quote>in the wild</"
dongsheng@627 11602 "quote>, and could propagate further."
dongsheng@627 11603 msgstr ""
dongsheng@627 11604
dongsheng@627 11605 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 11606 #: ../en/ch09-undo.xml:628
dongsheng@627 11607 msgid ""
dongsheng@627 11608 "If you've committed one or more changes <emphasis>after</emphasis> the change "
dongsheng@627 11609 "that you'd like to see disappear, your options are further reduced. Mercurial "
dongsheng@627 11610 "doesn't provide a way to <quote>punch a hole</quote> in history, leaving "
dongsheng@627 11611 "changesets intact."
dongsheng@627 11612 msgstr ""
dongsheng@627 11613
dongsheng@627 11614 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 11615 #: ../en/ch09-undo.xml:635
dongsheng@714 11616 msgid "Backing out a merge"
dongsheng@715 11617 msgstr "撤销一个合并"
dongsheng@714 11618
dongsheng@714 11619 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 11620 #: ../en/ch09-undo.xml:637
dongsheng@714 11621 msgid ""
dongsheng@714 11622 "Since merges are often complicated, it is not unheard of for a merge to be "
dongsheng@714 11623 "mangled badly, but committed erroneously. Mercurial provides an important "
dongsheng@714 11624 "safeguard against bad merges by refusing to commit unresolved files, but "
dongsheng@714 11625 "human ingenuity guarantees that it is still possible to mess a merge up and "
dongsheng@714 11626 "commit it."
dongsheng@714 11627 msgstr ""
dongsheng@714 11628
dongsheng@714 11629 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 11630 #: ../en/ch09-undo.xml:644
dongsheng@714 11631 msgid ""
dongsheng@714 11632 "Given a bad merge that has been committed, usually the best way to approach "
dongsheng@714 11633 "it is to simply try to repair the damage by hand. A complete disaster that "
dongsheng@714 11634 "cannot be easily fixed up by hand ought to be very rare, but the <command "
dongsheng@714 11635 "role=\"hg-cmd\">hg backout</command> command may help in making the cleanup "
dongsheng@714 11636 "easier. It offers a <option role=\"hg-opt-backout\">--parent</option> option, "
dongsheng@714 11637 "which lets you specify which parent to revert to when backing out a merge."
dongsheng@714 11638 msgstr ""
dongsheng@714 11639
dongsheng@714 11640 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
dongsheng@714 11641 #: ../en/ch09-undo.xml:655
dongsheng@714 11642 msgid "A bad merge"
dongsheng@716 11643 msgstr "错误的合并"
dongsheng@714 11644
dongsheng@714 11645 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
dongsheng@714 11646 #: ../en/ch09-undo.xml:657
dongsheng@714 11647 msgid "<imageobject><imagedata fileref=\"figs/bad-merge-1.png\"/></imageobject>"
dongsheng@714 11648 msgstr ""
dongsheng@714 11649
dongsheng@714 11650 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 11651 #: ../en/ch09-undo.xml:662
dongsheng@714 11652 msgid ""
dongsheng@714 11653 "Suppose we have a revision graph like that in <xref linkend=\"fig:undo:bad-"
dongsheng@714 11654 "merge-1\"/>. What we'd like is to <emphasis>redo</emphasis> the merge of "
dongsheng@714 11655 "revisions 2 and 3."
dongsheng@714 11656 msgstr ""
dongsheng@714 11657
dongsheng@714 11658 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 11659 #: ../en/ch09-undo.xml:667
dongsheng@714 11660 msgid "One way to do so would be as follows."
dongsheng@714 11661 msgstr ""
dongsheng@714 11662
dongsheng@714 11663 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
dongsheng@714 11664 #: ../en/ch09-undo.xml:671
dongsheng@714 11665 msgid ""
dongsheng@714 11666 "Call <command role=\"hg-cmd\">hg backout --rev=4 --parent=2</command>. This "
dongsheng@714 11667 "tells <command role=\"hg-cmd\">hg backout</command> to back out revision 4, "
dongsheng@714 11668 "which is the bad merge, and to when deciding which revision to prefer, to "
dongsheng@714 11669 "choose parent 2, one of the parents of the merge. The effect can be seen in "
dongsheng@714 11670 "<xref linkend=\"fig:undo:bad-merge-2\"/>."
dongsheng@714 11671 msgstr ""
dongsheng@714 11672
dongsheng@714 11673 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><figure><title>
dongsheng@714 11674 #: ../en/ch09-undo.xml:679
dongsheng@714 11675 msgid "Backing out the merge, favoring one parent"
dongsheng@715 11676 msgstr "拆除合并,关注一个父亲"
dongsheng@714 11677
dongsheng@714 11678 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><figure><mediaobject>
dongsheng@714 11679 #: ../en/ch09-undo.xml:681
dongsheng@714 11680 msgid "<imageobject><imagedata fileref=\"figs/bad-merge-2.png\"/></imageobject>"
dongsheng@714 11681 msgstr ""
dongsheng@715 11682 "<imageobject><imagedata fileref=\"figs/bad-merge-2.png\"/></imageobject>"
dongsheng@714 11683
dongsheng@714 11684 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
dongsheng@714 11685 #: ../en/ch09-undo.xml:688
dongsheng@714 11686 msgid ""
dongsheng@714 11687 "Call <command role=\"hg-cmd\">hg backout --rev=4 --parent=3</command>. This "
dongsheng@714 11688 "tells <command role=\"hg-cmd\">hg backout</command> to back out revision 4 "
dongsheng@714 11689 "again, but this time to choose parent 3, the other parent of the merge. The "
dongsheng@714 11690 "result is visible in <xref linkend=\"fig:undo:bad-merge-3\"/>, in which the "
dongsheng@714 11691 "repository now contains three heads."
dongsheng@714 11692 msgstr ""
dongsheng@714 11693
dongsheng@714 11694 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><figure><title>
dongsheng@714 11695 #: ../en/ch09-undo.xml:696
dongsheng@714 11696 msgid "Backing out the merge, favoring the other parent"
dongsheng@715 11697 msgstr "拆除合并,关注其它父亲"
dongsheng@714 11698
dongsheng@714 11699 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><figure><mediaobject>
dongsheng@714 11700 #: ../en/ch09-undo.xml:699
dongsheng@714 11701 msgid "<imageobject><imagedata fileref=\"figs/bad-merge-3.png\"/></imageobject>"
dongsheng@714 11702 msgstr ""
dongsheng@715 11703 "<imageobject><imagedata fileref=\"figs/bad-merge-3.png\"/></imageobject>"
dongsheng@714 11704
dongsheng@714 11705 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
dongsheng@714 11706 #: ../en/ch09-undo.xml:706
dongsheng@714 11707 msgid ""
dongsheng@714 11708 "Redo the bad merge by merging the two backout heads, which reduces the number "
dongsheng@714 11709 "of heads in the repository to two, as can be seen in <xref linkend=\"fig:undo:"
dongsheng@714 11710 "bad-merge-4\"/>."
dongsheng@714 11711 msgstr ""
dongsheng@714 11712
dongsheng@714 11713 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><figure><title>
dongsheng@714 11714 #: ../en/ch09-undo.xml:711 ../en/ch09-undo.xml:724
dongsheng@714 11715 msgid "Merging the backouts"
dongsheng@715 11716 msgstr "合并拆除"
dongsheng@714 11717
dongsheng@714 11718 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><figure><mediaobject>
dongsheng@714 11719 #: ../en/ch09-undo.xml:713
dongsheng@714 11720 msgid "<imageobject><imagedata fileref=\"figs/bad-merge-4.png\"/></imageobject>"
dongsheng@714 11721 msgstr ""
dongsheng@715 11722 "<imageobject><imagedata fileref=\"figs/bad-merge-4.png\"/></imageobject>"
dongsheng@714 11723
dongsheng@714 11724 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
dongsheng@714 11725 #: ../en/ch09-undo.xml:720
dongsheng@714 11726 msgid ""
dongsheng@714 11727 "Merge with the commit that was made after the bad merge, as shown in <xref "
dongsheng@714 11728 "linkend=\"fig:undo:bad-merge-5\"/>."
dongsheng@714 11729 msgstr ""
dongsheng@714 11730
dongsheng@714 11731 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><figure><mediaobject>
dongsheng@714 11732 #: ../en/ch09-undo.xml:726
dongsheng@714 11733 msgid "<imageobject><imagedata fileref=\"figs/bad-merge-5.png\"/></imageobject>"
dongsheng@714 11734 msgstr ""
dongsheng@714 11735
dongsheng@714 11736 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 11737 #: ../en/ch09-undo.xml:735
dongsheng@627 11738 msgid "Protect yourself from <quote>escaped</quote> changes"
dongsheng@635 11739 msgstr "使用<quote>校验</quote>修改来保护你自己"
dongsheng@627 11740
dongsheng@627 11741 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 11742 #: ../en/ch09-undo.xml:738
dongsheng@627 11743 msgid ""
dongsheng@627 11744 "If you've committed some changes to your local repository and they've been "
dongsheng@627 11745 "pushed or pulled somewhere else, this isn't necessarily a disaster. You can "
dongsheng@627 11746 "protect yourself ahead of time against some classes of bad changeset. This "
dongsheng@627 11747 "is particularly easy if your team usually pulls changes from a central "
dongsheng@627 11748 "repository."
dongsheng@627 11749 msgstr ""
dongsheng@627 11750
dongsheng@627 11751 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 11752 #: ../en/ch09-undo.xml:745
dongsheng@627 11753 msgid ""
dongsheng@627 11754 "By configuring some hooks on that repository to validate incoming changesets "
songdongsheng@658 11755 "(see chapter <xref linkend=\"chap:hook\"/>), you can automatically prevent "
dongsheng@627 11756 "some kinds of bad changeset from being pushed to the central repository at "
dongsheng@627 11757 "all. With such a configuration in place, some kinds of bad changeset will "
dongsheng@627 11758 "naturally tend to <quote>die out</quote> because they can't propagate into "
dongsheng@627 11759 "the central repository. Better yet, this happens without any need for "
dongsheng@627 11760 "explicit intervention."
dongsheng@627 11761 msgstr ""
dongsheng@627 11762
dongsheng@627 11763 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 11764 #: ../en/ch09-undo.xml:755
dongsheng@627 11765 msgid ""
dongsheng@627 11766 "For instance, an incoming change hook that verifies that a changeset will "
dongsheng@714 11767 "actually compile can prevent people from inadvertently <quote>breaking the "
dongsheng@627 11768 "build</quote>."
dongsheng@627 11769 msgstr ""
dongsheng@627 11770
dongsheng@714 11771 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 11772 #: ../en/ch09-undo.xml:762
dongsheng@714 11773 msgid "What to do about sensitive changes that escape"
dongsheng@716 11774 msgstr "处理敏感信息泄漏的方法"
dongsheng@714 11775
dongsheng@714 11776 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 11777 #: ../en/ch09-undo.xml:764
dongsheng@714 11778 msgid ""
dongsheng@714 11779 "Even a carefully run project can suffer an unfortunate event such as the "
dongsheng@714 11780 "committing and uncontrolled propagation of a file that contains important "
dongsheng@714 11781 "passwords."
dongsheng@714 11782 msgstr ""
dongsheng@714 11783
dongsheng@714 11784 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 11785 #: ../en/ch09-undo.xml:768
dongsheng@714 11786 msgid ""
dongsheng@714 11787 "If something like this happens to you, and the information that gets "
dongsheng@714 11788 "accidentally propagated is truly sensitive, your first step should be to "
dongsheng@714 11789 "mitigate the effect of the leak without trying to control the leak itself. If "
dongsheng@714 11790 "you are not 100% certain that you know exactly who could have seen the "
dongsheng@714 11791 "changes, you should immediately change passwords, cancel credit cards, or "
dongsheng@714 11792 "find some other way to make sure that the information that has leaked is no "
dongsheng@714 11793 "longer useful. In other words, assume that the change has propagated far and "
dongsheng@714 11794 "wide, and that there's nothing more you can do."
dongsheng@714 11795 msgstr ""
dongsheng@714 11796
dongsheng@714 11797 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 11798 #: ../en/ch09-undo.xml:779
dongsheng@714 11799 msgid ""
dongsheng@714 11800 "You might hope that there would be mechanisms you could use to either figure "
dongsheng@714 11801 "out who has seen a change or to erase the change permanently everywhere, but "
dongsheng@714 11802 "there are good reasons why these are not possible."
dongsheng@714 11803 msgstr ""
dongsheng@714 11804
dongsheng@714 11805 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 11806 #: ../en/ch09-undo.xml:784
dongsheng@714 11807 msgid ""
dongsheng@714 11808 "Mercurial does not provide an audit trail of who has pulled changes from a "
dongsheng@714 11809 "repository, because it is usually either impossible to record such "
dongsheng@714 11810 "information or trivial to spoof it. In a multi-user or networked "
dongsheng@714 11811 "environment, you should thus be extremely skeptical of yourself if you think "
dongsheng@714 11812 "that you have identified every place that a sensitive changeset has "
dongsheng@714 11813 "propagated to. Don't forget that people can and will send bundles by email, "
dongsheng@714 11814 "have their backup software save data offsite, carry repositories on USB "
dongsheng@714 11815 "sticks, and find other completely innocent ways to confound your attempts to "
dongsheng@714 11816 "track down every copy of a problematic change."
dongsheng@714 11817 msgstr ""
dongsheng@714 11818
dongsheng@714 11819 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 11820 #: ../en/ch09-undo.xml:796
dongsheng@714 11821 msgid ""
dongsheng@714 11822 "Mercurial also does not provide a way to make a file or changeset completely "
dongsheng@714 11823 "disappear from history, because there is no way to enforce its disappearance; "
dongsheng@714 11824 "someone could easily modify their copy of Mercurial to ignore such "
dongsheng@714 11825 "directives. In addition, even if Mercurial provided such a capability, "
dongsheng@714 11826 "someone who simply hadn't pulled a <quote>make this file disappear</quote> "
dongsheng@714 11827 "changeset wouldn't be affected by it, nor would web crawlers visiting at the "
dongsheng@714 11828 "wrong time, disk backups, or other mechanisms. Indeed, no distributed "
dongsheng@714 11829 "revision control system can make data reliably vanish. Providing the illusion "
dongsheng@714 11830 "of such control could easily give a false sense of security, and be worse "
dongsheng@714 11831 "than not providing it at all."
dongsheng@714 11832 msgstr ""
dongsheng@714 11833
dongsheng@627 11834 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 11835 #: ../en/ch09-undo.xml:812
dongsheng@627 11836 msgid "Finding the source of a bug"
dongsheng@635 11837 msgstr "查找问题的根源"
dongsheng@627 11838
dongsheng@627 11839 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 11840 #: ../en/ch09-undo.xml:814
dongsheng@627 11841 msgid ""
dongsheng@627 11842 "While it's all very well to be able to back out a changeset that introduced a "
dongsheng@627 11843 "bug, this requires that you know which changeset to back out. Mercurial "
dongsheng@627 11844 "provides an invaluable command, called <command role=\"hg-cmd\">hg bisect</"
dongsheng@627 11845 "command>, that helps you to automate this process and accomplish it very "
dongsheng@627 11846 "efficiently."
dongsheng@627 11847 msgstr ""
dongsheng@627 11848
dongsheng@627 11849 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 11850 #: ../en/ch09-undo.xml:821
dongsheng@627 11851 msgid ""
dongsheng@627 11852 "The idea behind the <command role=\"hg-cmd\">hg bisect</command> command is "
songdongsheng@710 11853 "that a changeset has introduced some change of behavior that you can identify "
dongsheng@714 11854 "with a simple pass/fail test. You don't know which piece of code introduced "
dongsheng@714 11855 "the change, but you know how to test for the presence of the bug. The "
dongsheng@714 11856 "<command role=\"hg-cmd\">hg bisect</command> command uses your test to direct "
dongsheng@714 11857 "its search for the changeset that introduced the code that caused the bug."
dongsheng@714 11858 msgstr ""
dongsheng@714 11859
dongsheng@714 11860 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 11861 #: ../en/ch09-undo.xml:830
dongsheng@627 11862 msgid ""
dongsheng@627 11863 "Here are a few scenarios to help you understand how you might apply this "
dongsheng@627 11864 "command."
dongsheng@627 11865 msgstr ""
dongsheng@627 11866
dongsheng@627 11867 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 11868 #: ../en/ch09-undo.xml:833
dongsheng@627 11869 msgid ""
dongsheng@627 11870 "The most recent version of your software has a bug that you remember wasn't "
dongsheng@627 11871 "present a few weeks ago, but you don't know when it was introduced. Here, "
dongsheng@627 11872 "your binary test checks for the presence of that bug."
dongsheng@627 11873 msgstr ""
dongsheng@627 11874
dongsheng@627 11875 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 11876 #: ../en/ch09-undo.xml:838
dongsheng@627 11877 msgid ""
dongsheng@627 11878 "You fixed a bug in a rush, and now it's time to close the entry in your "
dongsheng@627 11879 "team's bug database. The bug database requires a changeset ID when you close "
dongsheng@627 11880 "an entry, but you don't remember which changeset you fixed the bug in. Once "
dongsheng@627 11881 "again, your binary test checks for the presence of the bug."
dongsheng@627 11882 msgstr ""
dongsheng@627 11883
dongsheng@627 11884 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 11885 #: ../en/ch09-undo.xml:845
dongsheng@627 11886 msgid ""
dongsheng@627 11887 "Your software works correctly, but runs 15% slower than the last time you "
dongsheng@627 11888 "measured it. You want to know which changeset introduced the performance "
dongsheng@627 11889 "regression. In this case, your binary test measures the performance of your "
dongsheng@627 11890 "software, to see whether it's <quote>fast</quote> or <quote>slow</quote>."
dongsheng@627 11891 msgstr ""
dongsheng@627 11892
dongsheng@627 11893 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 11894 #: ../en/ch09-undo.xml:852
dongsheng@627 11895 msgid ""
dongsheng@627 11896 "The sizes of the components of your project that you ship exploded recently, "
dongsheng@627 11897 "and you suspect that something changed in the way you build your project."
dongsheng@627 11898 msgstr ""
dongsheng@627 11899
dongsheng@627 11900 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 11901 #: ../en/ch09-undo.xml:857
dongsheng@627 11902 msgid ""
dongsheng@627 11903 "From these examples, it should be clear that the <command role=\"hg-cmd\">hg "
dongsheng@627 11904 "bisect</command> command is not useful only for finding the sources of bugs. "
dongsheng@627 11905 "You can use it to find any <quote>emergent property</quote> of a repository "
dongsheng@627 11906 "(anything that you can't find from a simple text search of the files in the "
dongsheng@627 11907 "tree) for which you can write a binary test."
dongsheng@627 11908 msgstr ""
dongsheng@627 11909
dongsheng@627 11910 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 11911 #: ../en/ch09-undo.xml:864
dongsheng@627 11912 msgid ""
dongsheng@627 11913 "We'll introduce a little bit of terminology here, just to make it clear which "
dongsheng@627 11914 "parts of the search process are your responsibility, and which are "
dongsheng@627 11915 "Mercurial's. A <emphasis>test</emphasis> is something that <emphasis>you</"
dongsheng@627 11916 "emphasis> run when <command role=\"hg-cmd\">hg bisect</command> chooses a "
dongsheng@627 11917 "changeset. A <emphasis>probe</emphasis> is what <command role=\"hg-cmd\">hg "
dongsheng@627 11918 "bisect</command> runs to tell whether a revision is good. Finally, we'll use "
dongsheng@627 11919 "the word <quote>bisect</quote>, as both a noun and a verb, to stand in for "
dongsheng@627 11920 "the phrase <quote>search using the <command role=\"hg-cmd\">hg bisect</"
dongsheng@627 11921 "command> command</quote>."
dongsheng@627 11922 msgstr ""
dongsheng@627 11923
dongsheng@627 11924 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 11925 #: ../en/ch09-undo.xml:877
dongsheng@627 11926 msgid ""
dongsheng@627 11927 "One simple way to automate the searching process would be simply to probe "
dongsheng@627 11928 "every changeset. However, this scales poorly. If it took ten minutes to "
dongsheng@627 11929 "test a single changeset, and you had 10,000 changesets in your repository, "
dongsheng@627 11930 "the exhaustive approach would take on average 35 <emphasis>days</emphasis> to "
dongsheng@627 11931 "find the changeset that introduced a bug. Even if you knew that the bug was "
dongsheng@627 11932 "introduced by one of the last 500 changesets, and limited your search to "
dongsheng@627 11933 "those, you'd still be looking at over 40 hours to find the changeset that "
dongsheng@627 11934 "introduced your bug."
dongsheng@627 11935 msgstr ""
dongsheng@627 11936
dongsheng@627 11937 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 11938 #: ../en/ch09-undo.xml:887
dongsheng@627 11939 msgid ""
dongsheng@627 11940 "What the <command role=\"hg-cmd\">hg bisect</command> command does is use its "
dongsheng@627 11941 "knowledge of the <quote>shape</quote> of your project's revision history to "
dongsheng@627 11942 "perform a search in time proportional to the <emphasis>logarithm</emphasis> "
dongsheng@627 11943 "of the number of changesets to check (the kind of search it performs is "
dongsheng@627 11944 "called a dichotomic search). With this approach, searching through 10,000 "
dongsheng@627 11945 "changesets will take less than three hours, even at ten minutes per test (the "
dongsheng@627 11946 "search will require about 14 tests). Limit your search to the last hundred "
dongsheng@627 11947 "changesets, and it will take only about an hour (roughly seven tests)."
dongsheng@627 11948 msgstr ""
dongsheng@627 11949
dongsheng@627 11950 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 11951 #: ../en/ch09-undo.xml:898
dongsheng@627 11952 msgid ""
dongsheng@627 11953 "The <command role=\"hg-cmd\">hg bisect</command> command is aware of the "
dongsheng@627 11954 "<quote>branchy</quote> nature of a Mercurial project's revision history, so "
dongsheng@627 11955 "it has no problems dealing with branches, merges, or multiple heads in a "
dongsheng@627 11956 "repository. It can prune entire branches of history with a single probe, "
dongsheng@627 11957 "which is how it operates so efficiently."
dongsheng@627 11958 msgstr ""
dongsheng@627 11959
dongsheng@627 11960 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 11961 #: ../en/ch09-undo.xml:906
dongsheng@627 11962 msgid "Using the <command role=\"hg-cmd\">hg bisect</command> command"
dongsheng@635 11963 msgstr "使用命令 <command role=\"hg-cmd\">hg bisect</command>"
dongsheng@627 11964
dongsheng@627 11965 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 11966 #: ../en/ch09-undo.xml:909
dongsheng@627 11967 msgid ""
dongsheng@627 11968 "Here's an example of <command role=\"hg-cmd\">hg bisect</command> in action."
dongsheng@627 11969 msgstr ""
dongsheng@627 11970
dongsheng@627 11971 #. type: Content of: <book><chapter><sect1><sect2><note><para>
dongsheng@714 11972 #: ../en/ch09-undo.xml:913
dongsheng@627 11973 msgid ""
dongsheng@627 11974 "In versions 0.9.5 and earlier of Mercurial, <command role=\"hg-cmd\">hg "
dongsheng@627 11975 "bisect</command> was not a core command: it was distributed with Mercurial as "
dongsheng@627 11976 "an extension. This section describes the built-in command, not the old "
dongsheng@627 11977 "extension."
dongsheng@627 11978 msgstr ""
dongsheng@627 11979
dongsheng@627 11980 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 11981 #: ../en/ch09-undo.xml:920
dongsheng@627 11982 msgid ""
dongsheng@627 11983 "Now let's create a repository, so that we can try out the <command role=\"hg-"
dongsheng@627 11984 "cmd\">hg bisect</command> command in isolation."
dongsheng@627 11985 msgstr ""
dongsheng@627 11986
dongsheng@627 11987 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 11988 #: ../en/ch09-undo.xml:926
dongsheng@627 11989 msgid ""
dongsheng@627 11990 "We'll simulate a project that has a bug in it in a simple-minded way: create "
dongsheng@627 11991 "trivial changes in a loop, and nominate one specific change that will have "
dongsheng@627 11992 "the <quote>bug</quote>. This loop creates 35 changesets, each adding a "
dongsheng@627 11993 "single file to the repository. We'll represent our <quote>bug</quote> with a "
dongsheng@627 11994 "file that contains the text <quote>i have a gub</quote>."
dongsheng@627 11995 msgstr ""
dongsheng@627 11996
dongsheng@627 11997 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 11998 #: ../en/ch09-undo.xml:936
dongsheng@627 11999 msgid ""
dongsheng@627 12000 "The next thing that we'd like to do is figure out how to use the <command "
dongsheng@627 12001 "role=\"hg-cmd\">hg bisect</command> command. We can use Mercurial's normal "
dongsheng@627 12002 "built-in help mechanism for this."
dongsheng@627 12003 msgstr ""
dongsheng@627 12004
dongsheng@627 12005 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12006 #: ../en/ch09-undo.xml:943
dongsheng@627 12007 msgid ""
dongsheng@627 12008 "The <command role=\"hg-cmd\">hg bisect</command> command works in steps. "
dongsheng@627 12009 "Each step proceeds as follows."
dongsheng@627 12010 msgstr ""
dongsheng@627 12011
dongsheng@627 12012 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
dongsheng@714 12013 #: ../en/ch09-undo.xml:946
dongsheng@627 12014 msgid "You run your binary test."
dongsheng@627 12015 msgstr ""
dongsheng@627 12016
dongsheng@627 12017 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><itemizedlist><listitem><para>
dongsheng@714 12018 #: ../en/ch09-undo.xml:948
dongsheng@627 12019 msgid ""
dongsheng@627 12020 "If the test succeeded, you tell <command role=\"hg-cmd\">hg bisect</command> "
dongsheng@714 12021 "by running the <command role=\"hg-cmd\">hg bisect --good</command> command."
dongsheng@715 12022 msgstr ""
dongsheng@715 12023 "当测试成功后,使用 <command role=\"hg-cmd\">hg bisect --good</command> 命令告"
dongsheng@715 12024 "诉 <command role=\"hg-cmd\">hg bisect</command> 命令。"
dongsheng@627 12025
dongsheng@627 12026 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><itemizedlist><listitem><para>
dongsheng@714 12027 #: ../en/ch09-undo.xml:953
dongsheng@714 12028 msgid ""
dongsheng@714 12029 "If it failed, run the <command role=\"hg-cmd\">hg bisect --bad</command> "
dongsheng@627 12030 "command."
dongsheng@715 12031 msgstr ""
dongsheng@715 12032 "如果失败,执行 <command role=\"hg-cmd\">hg bisect --bad</command> 命令。"
dongsheng@627 12033
dongsheng@627 12034 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
dongsheng@714 12035 #: ../en/ch09-undo.xml:957
dongsheng@627 12036 msgid ""
dongsheng@627 12037 "The command uses your information to decide which changeset to test next."
dongsheng@627 12038 msgstr ""
dongsheng@627 12039
dongsheng@627 12040 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
dongsheng@714 12041 #: ../en/ch09-undo.xml:960
dongsheng@627 12042 msgid ""
dongsheng@627 12043 "It updates the working directory to that changeset, and the process begins "
dongsheng@627 12044 "again."
dongsheng@627 12045 msgstr ""
dongsheng@627 12046
dongsheng@627 12047 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12048 #: ../en/ch09-undo.xml:963
dongsheng@627 12049 msgid ""
dongsheng@627 12050 "The process ends when <command role=\"hg-cmd\">hg bisect</command> identifies "
dongsheng@627 12051 "a unique changeset that marks the point where your test transitioned from "
dongsheng@627 12052 "<quote>succeeding</quote> to <quote>failing</quote>."
dongsheng@627 12053 msgstr ""
dongsheng@627 12054
dongsheng@627 12055 #
dongsheng@627 12056 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12057 #: ../en/ch09-undo.xml:968
dongsheng@627 12058 msgid ""
dongsheng@627 12059 "To start the search, we must run the <command role=\"hg-cmd\">hg bisect --"
dongsheng@627 12060 "reset</command> command."
dongsheng@627 12061 msgstr ""
dongsheng@627 12062
dongsheng@627 12063 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12064 #: ../en/ch09-undo.xml:973
dongsheng@627 12065 msgid ""
dongsheng@627 12066 "In our case, the binary test we use is simple: we check to see if any file in "
dongsheng@627 12067 "the repository contains the string <quote>i have a gub</quote>. If it does, "
dongsheng@627 12068 "this changeset contains the change that <quote>caused the bug</quote>. By "
dongsheng@627 12069 "convention, a changeset that has the property we're searching for is "
dongsheng@627 12070 "<quote>bad</quote>, while one that doesn't is <quote>good</quote>."
dongsheng@627 12071 msgstr ""
dongsheng@627 12072
dongsheng@627 12073 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12074 #: ../en/ch09-undo.xml:981
dongsheng@627 12075 msgid ""
dongsheng@627 12076 "Most of the time, the revision to which the working directory is synced "
dongsheng@627 12077 "(usually the tip) already exhibits the problem introduced by the buggy "
dongsheng@627 12078 "change, so we'll mark it as <quote>bad</quote>."
dongsheng@627 12079 msgstr ""
dongsheng@627 12080
dongsheng@627 12081 #
dongsheng@627 12082 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12083 #: ../en/ch09-undo.xml:988
dongsheng@627 12084 msgid ""
dongsheng@627 12085 "Our next task is to nominate a changeset that we know <emphasis>doesn't</"
dongsheng@627 12086 "emphasis> have the bug; the <command role=\"hg-cmd\">hg bisect</command> "
dongsheng@627 12087 "command will <quote>bracket</quote> its search between the first pair of good "
dongsheng@627 12088 "and bad changesets. In our case, we know that revision 10 didn't have the "
dongsheng@627 12089 "bug. (I'll have more words about choosing the first <quote>good</quote> "
dongsheng@627 12090 "changeset later.)"
dongsheng@627 12091 msgstr ""
dongsheng@627 12092
dongsheng@627 12093 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12094 #: ../en/ch09-undo.xml:998
dongsheng@627 12095 msgid "Notice that this command printed some output."
dongsheng@627 12096 msgstr ""
dongsheng@627 12097
dongsheng@627 12098 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 12099 #: ../en/ch09-undo.xml:1000
dongsheng@627 12100 msgid ""
dongsheng@627 12101 "It told us how many changesets it must consider before it can identify the "
dongsheng@627 12102 "one that introduced the bug, and how many tests that will require."
dongsheng@627 12103 msgstr ""
dongsheng@627 12104
dongsheng@627 12105 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 12106 #: ../en/ch09-undo.xml:1004
dongsheng@627 12107 msgid ""
dongsheng@627 12108 "It updated the working directory to the next changeset to test, and told us "
dongsheng@627 12109 "which changeset it's testing."
dongsheng@627 12110 msgstr ""
dongsheng@627 12111
dongsheng@627 12112 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12113 #: ../en/ch09-undo.xml:1009
dongsheng@627 12114 msgid ""
dongsheng@627 12115 "We now run our test in the working directory. We use the <command>grep</"
dongsheng@627 12116 "command> command to see if our <quote>bad</quote> file is present in the "
dongsheng@627 12117 "working directory. If it is, this revision is bad; if not, this revision is "
dongsheng@627 12118 "good. &interaction.bisect.search.step1;"
dongsheng@627 12119 msgstr ""
dongsheng@627 12120
dongsheng@627 12121 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12122 #: ../en/ch09-undo.xml:1015
dongsheng@627 12123 msgid ""
dongsheng@627 12124 "This test looks like a perfect candidate for automation, so let's turn it "
dongsheng@627 12125 "into a shell function."
dongsheng@627 12126 msgstr ""
dongsheng@627 12127
dongsheng@627 12128 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12129 #: ../en/ch09-undo.xml:1019
dongsheng@627 12130 msgid ""
dongsheng@627 12131 "We can now run an entire test step with a single command, <literal>mytest</"
dongsheng@627 12132 "literal>."
dongsheng@627 12133 msgstr ""
dongsheng@627 12134
dongsheng@627 12135 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12136 #: ../en/ch09-undo.xml:1024
dongsheng@627 12137 msgid "A few more invocations of our canned test step command, and we're done."
dongsheng@627 12138 msgstr ""
dongsheng@627 12139
dongsheng@627 12140 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12141 #: ../en/ch09-undo.xml:1029
dongsheng@627 12142 msgid ""
dongsheng@627 12143 "Even though we had 40 changesets to search through, the <command role=\"hg-cmd"
dongsheng@627 12144 "\">hg bisect</command> command let us find the changeset that introduced our "
dongsheng@627 12145 "<quote>bug</quote> with only five tests. Because the number of tests that "
dongsheng@627 12146 "the <command role=\"hg-cmd\">hg bisect</command> command performs grows "
dongsheng@627 12147 "logarithmically with the number of changesets to search, the advantage that "
dongsheng@627 12148 "it has over the <quote>brute force</quote> search approach increases with "
dongsheng@627 12149 "every changeset you add."
dongsheng@627 12150 msgstr ""
dongsheng@627 12151
dongsheng@627 12152 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 12153 #: ../en/ch09-undo.xml:1040
dongsheng@627 12154 msgid "Cleaning up after your search"
dongsheng@635 12155 msgstr "搜索后的清理"
dongsheng@627 12156
dongsheng@714 12157 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12158 #: ../en/ch09-undo.xml:1042
dongsheng@627 12159 msgid ""
dongsheng@627 12160 "When you're finished using the <command role=\"hg-cmd\">hg bisect</command> "
dongsheng@714 12161 "command in a repository, you can use the <command role=\"hg-cmd\">hg bisect --"
dongsheng@627 12162 "reset</command> command to drop the information it was using to drive your "
dongsheng@627 12163 "search. The command doesn't use much space, so it doesn't matter if you "
dongsheng@627 12164 "forget to run this command. However, <command role=\"hg-cmd\">hg bisect</"
dongsheng@627 12165 "command> won't let you start a new search in that repository until you do a "
dongsheng@714 12166 "<command role=\"hg-cmd\">hg bisect --reset</command>."
dongsheng@627 12167 msgstr ""
dongsheng@627 12168
dongsheng@627 12169 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 12170 #: ../en/ch09-undo.xml:1057
dongsheng@627 12171 msgid "Tips for finding bugs effectively"
dongsheng@635 12172 msgstr "有效查找问题的技巧"
dongsheng@627 12173
dongsheng@627 12174 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 12175 #: ../en/ch09-undo.xml:1060
dongsheng@627 12176 msgid "Give consistent input"
dongsheng@635 12177 msgstr "给出一致的输入"
dongsheng@627 12178
dongsheng@627 12179 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12180 #: ../en/ch09-undo.xml:1062
dongsheng@627 12181 msgid ""
dongsheng@627 12182 "The <command role=\"hg-cmd\">hg bisect</command> command requires that you "
dongsheng@627 12183 "correctly report the result of every test you perform. If you tell it that a "
dongsheng@627 12184 "test failed when it really succeeded, it <emphasis>might</emphasis> be able "
dongsheng@627 12185 "to detect the inconsistency. If it can identify an inconsistency in your "
dongsheng@627 12186 "reports, it will tell you that a particular changeset is both good and bad. "
dongsheng@627 12187 "However, it can't do this perfectly; it's about as likely to report the wrong "
dongsheng@627 12188 "changeset as the source of the bug."
dongsheng@627 12189 msgstr ""
dongsheng@627 12190
dongsheng@627 12191 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 12192 #: ../en/ch09-undo.xml:1074
dongsheng@627 12193 msgid "Automate as much as possible"
dongsheng@635 12194 msgstr "尽量自动"
dongsheng@627 12195
dongsheng@627 12196 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12197 #: ../en/ch09-undo.xml:1076
dongsheng@627 12198 msgid ""
dongsheng@627 12199 "When I started using the <command role=\"hg-cmd\">hg bisect</command> "
dongsheng@627 12200 "command, I tried a few times to run my tests by hand, on the command line. "
dongsheng@627 12201 "This is an approach that I, at least, am not suited to. After a few tries, I "
dongsheng@627 12202 "found that I was making enough mistakes that I was having to restart my "
dongsheng@627 12203 "searches several times before finally getting correct results."
dongsheng@627 12204 msgstr ""
dongsheng@627 12205
dongsheng@627 12206 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12207 #: ../en/ch09-undo.xml:1084
dongsheng@627 12208 msgid ""
dongsheng@627 12209 "My initial problems with driving the <command role=\"hg-cmd\">hg bisect</"
dongsheng@627 12210 "command> command by hand occurred even with simple searches on small "
dongsheng@627 12211 "repositories; if the problem you're looking for is more subtle, or the number "
dongsheng@627 12212 "of tests that <command role=\"hg-cmd\">hg bisect</command> must perform "
dongsheng@627 12213 "increases, the likelihood of operator error ruining the search is much "
dongsheng@627 12214 "higher. Once I started automating my tests, I had much better results."
dongsheng@627 12215 msgstr ""
dongsheng@627 12216
dongsheng@627 12217 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12218 #: ../en/ch09-undo.xml:1093
dongsheng@627 12219 msgid "The key to automated testing is twofold:"
dongsheng@627 12220 msgstr ""
dongsheng@627 12221
dongsheng@627 12222 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 12223 #: ../en/ch09-undo.xml:1095
dongsheng@627 12224 msgid "always test for the same symptom, and"
dongsheng@627 12225 msgstr ""
dongsheng@627 12226
dongsheng@627 12227 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 12228 #: ../en/ch09-undo.xml:1097
dongsheng@627 12229 msgid ""
dongsheng@627 12230 "always feed consistent input to the <command role=\"hg-cmd\">hg bisect</"
dongsheng@627 12231 "command> command."
dongsheng@627 12232 msgstr ""
dongsheng@627 12233
dongsheng@627 12234 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12235 #: ../en/ch09-undo.xml:1100
dongsheng@627 12236 msgid ""
dongsheng@627 12237 "In my tutorial example above, the <command>grep</command> command tests for "
dongsheng@627 12238 "the symptom, and the <literal>if</literal> statement takes the result of this "
dongsheng@627 12239 "check and ensures that we always feed the same input to the <command role="
dongsheng@627 12240 "\"hg-cmd\">hg bisect</command> command. The <literal>mytest</literal> "
dongsheng@627 12241 "function marries these together in a reproducible way, so that every test is "
dongsheng@627 12242 "uniform and consistent."
dongsheng@627 12243 msgstr ""
dongsheng@627 12244
dongsheng@627 12245 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 12246 #: ../en/ch09-undo.xml:1110
dongsheng@627 12247 msgid "Check your results"
dongsheng@635 12248 msgstr "检查你的结果"
dongsheng@627 12249
dongsheng@627 12250 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12251 #: ../en/ch09-undo.xml:1112
dongsheng@627 12252 msgid ""
dongsheng@627 12253 "Because the output of a <command role=\"hg-cmd\">hg bisect</command> search "
dongsheng@627 12254 "is only as good as the input you give it, don't take the changeset it reports "
dongsheng@627 12255 "as the absolute truth. A simple way to cross-check its report is to manually "
dongsheng@627 12256 "run your test at each of the following changesets:"
dongsheng@627 12257 msgstr ""
dongsheng@627 12258
dongsheng@627 12259 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 12260 #: ../en/ch09-undo.xml:1118
dongsheng@627 12261 msgid ""
dongsheng@627 12262 "The changeset that it reports as the first bad revision. Your test should "
dongsheng@627 12263 "still report this as bad."
dongsheng@627 12264 msgstr ""
dongsheng@627 12265
dongsheng@627 12266 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 12267 #: ../en/ch09-undo.xml:1122
dongsheng@627 12268 msgid ""
dongsheng@627 12269 "The parent of that changeset (either parent, if it's a merge). Your test "
dongsheng@627 12270 "should report this changeset as good."
dongsheng@627 12271 msgstr ""
dongsheng@627 12272
dongsheng@627 12273 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 12274 #: ../en/ch09-undo.xml:1126
dongsheng@627 12275 msgid ""
dongsheng@627 12276 "A child of that changeset. Your test should report this changeset as bad."
dongsheng@627 12277 msgstr ""
dongsheng@627 12278
dongsheng@627 12279 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 12280 #: ../en/ch09-undo.xml:1132
dongsheng@627 12281 msgid "Beware interference between bugs"
dongsheng@635 12282 msgstr "谨防问题之间的冲突"
dongsheng@627 12283
dongsheng@627 12284 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12285 #: ../en/ch09-undo.xml:1134
dongsheng@627 12286 msgid ""
dongsheng@627 12287 "It's possible that your search for one bug could be disrupted by the presence "
dongsheng@627 12288 "of another. For example, let's say your software crashes at revision 100, "
dongsheng@627 12289 "and worked correctly at revision 50. Unknown to you, someone else introduced "
dongsheng@627 12290 "a different crashing bug at revision 60, and fixed it at revision 80. This "
dongsheng@627 12291 "could distort your results in one of several ways."
dongsheng@627 12292 msgstr ""
dongsheng@627 12293
dongsheng@627 12294 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12295 #: ../en/ch09-undo.xml:1142
dongsheng@627 12296 msgid ""
dongsheng@627 12297 "It is possible that this other bug completely <quote>masks</quote> yours, "
dongsheng@627 12298 "which is to say that it occurs before your bug has a chance to manifest "
dongsheng@627 12299 "itself. If you can't avoid that other bug (for example, it prevents your "
dongsheng@627 12300 "project from building), and so can't tell whether your bug is present in a "
dongsheng@627 12301 "particular changeset, the <command role=\"hg-cmd\">hg bisect</command> "
dongsheng@627 12302 "command cannot help you directly. Instead, you can mark a changeset as "
dongsheng@627 12303 "untested by running <command role=\"hg-cmd\">hg bisect --skip</command>."
dongsheng@627 12304 msgstr ""
dongsheng@627 12305
dongsheng@627 12306 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12307 #: ../en/ch09-undo.xml:1152
dongsheng@627 12308 msgid ""
dongsheng@627 12309 "A different problem could arise if your test for a bug's presence is not "
dongsheng@627 12310 "specific enough. If you check for <quote>my program crashes</quote>, then "
dongsheng@627 12311 "both your crashing bug and an unrelated crashing bug that masks it will look "
dongsheng@627 12312 "like the same thing, and mislead <command role=\"hg-cmd\">hg bisect</command>."
dongsheng@627 12313 msgstr ""
dongsheng@627 12314
dongsheng@627 12315 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12316 #: ../en/ch09-undo.xml:1159
dongsheng@627 12317 msgid ""
dongsheng@627 12318 "Another useful situation in which to use <command role=\"hg-cmd\">hg bisect --"
dongsheng@627 12319 "skip</command> is if you can't test a revision because your project was in a "
dongsheng@627 12320 "broken and hence untestable state at that revision, perhaps because someone "
dongsheng@627 12321 "checked in a change that prevented the project from building."
dongsheng@627 12322 msgstr ""
dongsheng@627 12323
dongsheng@627 12324 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 12325 #: ../en/ch09-undo.xml:1168
dongsheng@627 12326 msgid "Bracket your search lazily"
dongsheng@635 12327 msgstr "减少你的查找工作"
dongsheng@627 12328
dongsheng@627 12329 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12330 #: ../en/ch09-undo.xml:1170
dongsheng@627 12331 msgid ""
dongsheng@627 12332 "Choosing the first <quote>good</quote> and <quote>bad</quote> changesets that "
dongsheng@627 12333 "will mark the end points of your search is often easy, but it bears a little "
dongsheng@627 12334 "discussion nevertheless. From the perspective of <command role=\"hg-cmd\">hg "
dongsheng@627 12335 "bisect</command>, the <quote>newest</quote> changeset is conventionally "
dongsheng@627 12336 "<quote>bad</quote>, and the older changeset is <quote>good</quote>."
dongsheng@627 12337 msgstr ""
dongsheng@627 12338
dongsheng@627 12339 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12340 #: ../en/ch09-undo.xml:1178
dongsheng@627 12341 msgid ""
dongsheng@627 12342 "If you're having trouble remembering when a suitable <quote>good</quote> "
dongsheng@627 12343 "change was, so that you can tell <command role=\"hg-cmd\">hg bisect</"
dongsheng@627 12344 "command>, you could do worse than testing changesets at random. Just "
dongsheng@627 12345 "remember to eliminate contenders that can't possibly exhibit the bug (perhaps "
dongsheng@627 12346 "because the feature with the bug isn't present yet) and those where another "
dongsheng@627 12347 "problem masks the bug (as I discussed above)."
dongsheng@627 12348 msgstr ""
dongsheng@627 12349
dongsheng@627 12350 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12351 #: ../en/ch09-undo.xml:1187
dongsheng@627 12352 msgid ""
dongsheng@627 12353 "Even if you end up <quote>early</quote> by thousands of changesets or months "
dongsheng@627 12354 "of history, you will only add a handful of tests to the total number that "
dongsheng@627 12355 "<command role=\"hg-cmd\">hg bisect</command> must perform, thanks to its "
songdongsheng@710 12356 "logarithmic behavior."
dongsheng@627 12357 msgstr ""
dongsheng@627 12358
dongsheng@627 12359 #. type: Content of: <book><chapter><title>
dongsheng@714 12360 #: ../en/ch10-hook.xml:5
dongsheng@627 12361 msgid "Handling repository events with hooks"
dongsheng@627 12362 msgstr "使用钩子处理版本库事件"
dongsheng@627 12363
dongsheng@627 12364 #. type: Content of: <book><chapter><para>
dongsheng@714 12365 #: ../en/ch10-hook.xml:7
dongsheng@627 12366 msgid ""
dongsheng@627 12367 "Mercurial offers a powerful mechanism to let you perform automated actions in "
dongsheng@627 12368 "response to events that occur in a repository. In some cases, you can even "
dongsheng@627 12369 "control Mercurial's response to those events."
dongsheng@627 12370 msgstr ""
dongsheng@627 12371
dongsheng@627 12372 #. type: Content of: <book><chapter><para>
dongsheng@714 12373 #: ../en/ch10-hook.xml:12
dongsheng@627 12374 msgid ""
dongsheng@627 12375 "The name Mercurial uses for one of these actions is a <emphasis>hook</"
dongsheng@627 12376 "emphasis>. Hooks are called <quote>triggers</quote> in some revision control "
dongsheng@627 12377 "systems, but the two names refer to the same idea."
dongsheng@627 12378 msgstr ""
dongsheng@627 12379
dongsheng@627 12380 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 12381 #: ../en/ch10-hook.xml:18
dongsheng@627 12382 msgid "An overview of hooks in Mercurial"
dongsheng@635 12383 msgstr "Mercurial 钩子概述"
dongsheng@627 12384
dongsheng@627 12385 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 12386 #: ../en/ch10-hook.xml:20
dongsheng@627 12387 msgid ""
songdongsheng@658 12388 "Here is a brief list of the hooks that Mercurial supports. We will revisit "
songdongsheng@658 12389 "each of these hooks in more detail later, in <xref linkend=\"sec:hook:ref\"/>."
dongsheng@627 12390 msgstr ""
dongsheng@627 12391
dongsheng@714 12392 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 12393 #: ../en/ch10-hook.xml:24
dongsheng@714 12394 msgid ""
dongsheng@714 12395 "Each of the hooks whose description begins with the word <quote>Controlling</"
dongsheng@714 12396 "quote> has the ability to determine whether an activity can proceed. If the "
dongsheng@714 12397 "hook succeeds, the activity may proceed; if it fails, the activity is either "
dongsheng@714 12398 "not permitted or undone, depending on the hook."
dongsheng@714 12399 msgstr ""
dongsheng@714 12400
dongsheng@627 12401 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 12402 #: ../en/ch10-hook.xml:31
dongsheng@627 12403 msgid ""
dongsheng@627 12404 "<literal role=\"hook\">changegroup</literal>: This is run after a group of "
dongsheng@627 12405 "changesets has been brought into the repository from elsewhere."
dongsheng@627 12406 msgstr ""
dongsheng@627 12407
dongsheng@627 12408 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 12409 #: ../en/ch10-hook.xml:35
dongsheng@627 12410 msgid ""
dongsheng@627 12411 "<literal role=\"hook\">commit</literal>: This is run after a new changeset "
dongsheng@627 12412 "has been created in the local repository."
dongsheng@627 12413 msgstr ""
dongsheng@627 12414
dongsheng@627 12415 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 12416 #: ../en/ch10-hook.xml:39
dongsheng@627 12417 msgid ""
dongsheng@627 12418 "<literal role=\"hook\">incoming</literal>: This is run once for each new "
dongsheng@627 12419 "changeset that is brought into the repository from elsewhere. Notice the "
dongsheng@627 12420 "difference from <literal role=\"hook\">changegroup</literal>, which is run "
dongsheng@627 12421 "once per <emphasis>group</emphasis> of changesets brought in."
dongsheng@627 12422 msgstr ""
dongsheng@627 12423
dongsheng@627 12424 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 12425 #: ../en/ch10-hook.xml:46
dongsheng@627 12426 msgid ""
dongsheng@627 12427 "<literal role=\"hook\">outgoing</literal>: This is run after a group of "
dongsheng@627 12428 "changesets has been transmitted from this repository."
dongsheng@627 12429 msgstr ""
dongsheng@627 12430
dongsheng@627 12431 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 12432 #: ../en/ch10-hook.xml:50
dongsheng@627 12433 msgid ""
dongsheng@627 12434 "<literal role=\"hook\">prechangegroup</literal>: This is run before starting "
dongsheng@627 12435 "to bring a group of changesets into the repository."
dongsheng@627 12436 msgstr ""
dongsheng@627 12437
dongsheng@627 12438 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 12439 #: ../en/ch10-hook.xml:55
dongsheng@627 12440 msgid ""
dongsheng@627 12441 "<literal role=\"hook\">precommit</literal>: Controlling. This is run before "
dongsheng@627 12442 "starting a commit."
dongsheng@627 12443 msgstr ""
dongsheng@627 12444
dongsheng@627 12445 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 12446 #: ../en/ch10-hook.xml:59
dongsheng@627 12447 msgid ""
dongsheng@627 12448 "<literal role=\"hook\">preoutgoing</literal>: Controlling. This is run before "
dongsheng@627 12449 "starting to transmit a group of changesets from this repository."
dongsheng@627 12450 msgstr ""
dongsheng@627 12451
dongsheng@627 12452 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 12453 #: ../en/ch10-hook.xml:64
dongsheng@627 12454 msgid ""
dongsheng@627 12455 "<literal role=\"hook\">pretag</literal>: Controlling. This is run before "
dongsheng@627 12456 "creating a tag."
dongsheng@627 12457 msgstr ""
dongsheng@627 12458
dongsheng@627 12459 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 12460 #: ../en/ch10-hook.xml:68
dongsheng@627 12461 msgid ""
dongsheng@627 12462 "<literal role=\"hook\">pretxnchangegroup</literal>: Controlling. This is run "
dongsheng@627 12463 "after a group of changesets has been brought into the local repository from "
dongsheng@627 12464 "another, but before the transaction completes that will make the changes "
dongsheng@627 12465 "permanent in the repository."
dongsheng@627 12466 msgstr ""
dongsheng@627 12467
dongsheng@627 12468 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 12469 #: ../en/ch10-hook.xml:76
dongsheng@627 12470 msgid ""
dongsheng@627 12471 "<literal role=\"hook\">pretxncommit</literal>: Controlling. This is run after "
dongsheng@627 12472 "a new changeset has been created in the local repository, but before the "
dongsheng@627 12473 "transaction completes that will make it permanent."
dongsheng@627 12474 msgstr ""
dongsheng@627 12475
dongsheng@627 12476 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 12477 #: ../en/ch10-hook.xml:82
dongsheng@627 12478 msgid ""
dongsheng@627 12479 "<literal role=\"hook\">preupdate</literal>: Controlling. This is run before "
dongsheng@627 12480 "starting an update or merge of the working directory."
dongsheng@627 12481 msgstr ""
dongsheng@627 12482
dongsheng@627 12483 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 12484 #: ../en/ch10-hook.xml:87
dongsheng@627 12485 msgid ""
dongsheng@627 12486 "<literal role=\"hook\">tag</literal>: This is run after a tag is created."
dongsheng@627 12487 msgstr ""
dongsheng@627 12488
dongsheng@627 12489 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 12490 #: ../en/ch10-hook.xml:91
dongsheng@627 12491 msgid ""
dongsheng@627 12492 "<literal role=\"hook\">update</literal>: This is run after an update or merge "
dongsheng@627 12493 "of the working directory has finished."
dongsheng@627 12494 msgstr ""
dongsheng@627 12495
dongsheng@627 12496 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 12497 #: ../en/ch10-hook.xml:99
dongsheng@627 12498 msgid "Hooks and security"
dongsheng@635 12499 msgstr "钩子与安全性"
dongsheng@627 12500
dongsheng@627 12501 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 12502 #: ../en/ch10-hook.xml:102
dongsheng@627 12503 msgid "Hooks are run with your privileges"
dongsheng@635 12504 msgstr "钩子以你的特权执行"
dongsheng@627 12505
dongsheng@627 12506 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12507 #: ../en/ch10-hook.xml:104
dongsheng@627 12508 msgid ""
dongsheng@627 12509 "When you run a Mercurial command in a repository, and the command causes a "
dongsheng@627 12510 "hook to run, that hook runs on <emphasis>your</emphasis> system, under "
dongsheng@627 12511 "<emphasis>your</emphasis> user account, with <emphasis>your</emphasis> "
dongsheng@627 12512 "privilege level. Since hooks are arbitrary pieces of executable code, you "
dongsheng@627 12513 "should treat them with an appropriate level of suspicion. Do not install a "
dongsheng@627 12514 "hook unless you are confident that you know who created it and what it does."
dongsheng@627 12515 msgstr ""
dongsheng@627 12516
dongsheng@627 12517 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12518 #: ../en/ch10-hook.xml:115
dongsheng@627 12519 msgid ""
dongsheng@627 12520 "In some cases, you may be exposed to hooks that you did not install "
dongsheng@627 12521 "yourself. If you work with Mercurial on an unfamiliar system, Mercurial will "
dongsheng@650 12522 "run hooks defined in that system's global <filename role=\"special\">~/.hgrc</"
dongsheng@650 12523 "filename> file."
dongsheng@650 12524 msgstr ""
dongsheng@650 12525
dongsheng@650 12526 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12527 #: ../en/ch10-hook.xml:122
dongsheng@627 12528 msgid ""
dongsheng@627 12529 "If you are working with a repository owned by another user, Mercurial can run "
dongsheng@627 12530 "hooks defined in that user's repository, but it will still run them as "
dongsheng@627 12531 "<quote>you</quote>. For example, if you <command role=\"hg-cmd\">hg pull</"
dongsheng@627 12532 "command> from that repository, and its <filename role=\"special\">.hg/hgrc</"
dongsheng@627 12533 "filename> defines a local <literal role=\"hook\">outgoing</literal> hook, "
dongsheng@627 12534 "that hook will run under your user account, even though you don't own that "
dongsheng@627 12535 "repository."
dongsheng@627 12536 msgstr ""
dongsheng@627 12537
dongsheng@627 12538 #. type: Content of: <book><chapter><sect1><sect2><note><para>
dongsheng@714 12539 #: ../en/ch10-hook.xml:134
dongsheng@627 12540 msgid ""
dongsheng@627 12541 "This only applies if you are pulling from a repository on a local or network "
dongsheng@627 12542 "filesystem. If you're pulling over http or ssh, any <literal role=\"hook"
dongsheng@627 12543 "\">outgoing</literal> hook will run under whatever account is executing the "
dongsheng@627 12544 "server process, on the server."
dongsheng@627 12545 msgstr ""
dongsheng@627 12546
dongsheng@627 12547 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12548 #: ../en/ch10-hook.xml:142
dongsheng@714 12549 msgid ""
dongsheng@714 12550 "To see what hooks are defined in a repository, use the <command role=\"hg-cmd"
dongsheng@714 12551 "\">hg showconfig hooks</command> command. If you are working in one "
dongsheng@627 12552 "repository, but talking to another that you do not own (e.g. using <command "
dongsheng@627 12553 "role=\"hg-cmd\">hg pull</command> or <command role=\"hg-cmd\">hg incoming</"
dongsheng@627 12554 "command>), remember that it is the other repository's hooks you should be "
dongsheng@627 12555 "checking, not your own."
dongsheng@627 12556 msgstr ""
dongsheng@627 12557
dongsheng@627 12558 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 12559 #: ../en/ch10-hook.xml:153
dongsheng@627 12560 msgid "Hooks do not propagate"
dongsheng@635 12561 msgstr "钩子不会传播"
dongsheng@627 12562
dongsheng@627 12563 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12564 #: ../en/ch10-hook.xml:155
dongsheng@627 12565 msgid ""
dongsheng@627 12566 "In Mercurial, hooks are not revision controlled, and do not propagate when "
dongsheng@627 12567 "you clone, or pull from, a repository. The reason for this is simple: a hook "
dongsheng@627 12568 "is a completely arbitrary piece of executable code. It runs under your user "
dongsheng@627 12569 "identity, with your privilege level, on your machine."
dongsheng@627 12570 msgstr ""
dongsheng@627 12571
dongsheng@627 12572 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12573 #: ../en/ch10-hook.xml:162
dongsheng@627 12574 msgid ""
dongsheng@627 12575 "It would be extremely reckless for any distributed revision control system to "
dongsheng@627 12576 "implement revision-controlled hooks, as this would offer an easily "
dongsheng@627 12577 "exploitable way to subvert the accounts of users of the revision control "
dongsheng@627 12578 "system."
dongsheng@627 12579 msgstr ""
dongsheng@627 12580
dongsheng@627 12581 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12582 #: ../en/ch10-hook.xml:168
dongsheng@627 12583 msgid ""
dongsheng@627 12584 "Since Mercurial does not propagate hooks, if you are collaborating with other "
dongsheng@627 12585 "people on a common project, you should not assume that they are using the "
dongsheng@627 12586 "same Mercurial hooks as you are, or that theirs are correctly configured. "
dongsheng@627 12587 "You should document the hooks you expect people to use."
dongsheng@627 12588 msgstr ""
dongsheng@627 12589
dongsheng@627 12590 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12591 #: ../en/ch10-hook.xml:175
dongsheng@627 12592 msgid ""
dongsheng@627 12593 "In a corporate intranet, this is somewhat easier to control, as you can for "
dongsheng@627 12594 "example provide a <quote>standard</quote> installation of Mercurial on an NFS "
dongsheng@650 12595 "filesystem, and use a site-wide <filename role=\"special\">~/.hgrc</filename> "
dongsheng@650 12596 "file to define hooks that all users will see. However, this too has its "
dongsheng@627 12597 "limits; see below."
dongsheng@627 12598 msgstr ""
dongsheng@627 12599
dongsheng@627 12600 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 12601 #: ../en/ch10-hook.xml:184
dongsheng@627 12602 msgid "Hooks can be overridden"
dongsheng@635 12603 msgstr "钩子可以被覆盖"
dongsheng@627 12604
dongsheng@627 12605 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12606 #: ../en/ch10-hook.xml:186
dongsheng@627 12607 msgid ""
dongsheng@627 12608 "Mercurial allows you to override a hook definition by redefining the hook. "
dongsheng@627 12609 "You can disable it by setting its value to the empty string, or change its "
songdongsheng@710 12610 "behavior as you wish."
dongsheng@627 12611 msgstr ""
dongsheng@627 12612
dongsheng@627 12613 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12614 #: ../en/ch10-hook.xml:191
dongsheng@650 12615 msgid ""
dongsheng@650 12616 "If you deploy a system- or site-wide <filename role=\"special\">~/.hgrc</"
dongsheng@650 12617 "filename> file that defines some hooks, you should thus understand that your "
dongsheng@650 12618 "users can disable or override those hooks."
dongsheng@650 12619 msgstr ""
dongsheng@650 12620
dongsheng@650 12621 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 12622 #: ../en/ch10-hook.xml:199
dongsheng@627 12623 msgid "Ensuring that critical hooks are run"
dongsheng@635 12624 msgstr "确保关键钩子的执行"
dongsheng@627 12625
dongsheng@627 12626 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12627 #: ../en/ch10-hook.xml:201
dongsheng@627 12628 msgid ""
dongsheng@627 12629 "Sometimes you may want to enforce a policy that you do not want others to be "
dongsheng@627 12630 "able to work around. For example, you may have a requirement that every "
dongsheng@627 12631 "changeset must pass a rigorous set of tests. Defining this requirement via a "
dongsheng@650 12632 "hook in a site-wide <filename role=\"special\">~/.hgrc</filename> won't work "
dongsheng@650 12633 "for remote users on laptops, and of course local users can subvert it at will "
dongsheng@650 12634 "by overriding the hook."
dongsheng@650 12635 msgstr ""
dongsheng@650 12636
dongsheng@650 12637 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12638 #: ../en/ch10-hook.xml:210
dongsheng@627 12639 msgid ""
dongsheng@627 12640 "Instead, you can set up your policies for use of Mercurial so that people are "
dongsheng@627 12641 "expected to propagate changes through a well-known <quote>canonical</quote> "
dongsheng@627 12642 "server that you have locked down and configured appropriately."
dongsheng@627 12643 msgstr ""
dongsheng@627 12644
dongsheng@627 12645 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12646 #: ../en/ch10-hook.xml:216
dongsheng@627 12647 msgid ""
dongsheng@627 12648 "One way to do this is via a combination of social engineering and "
dongsheng@627 12649 "technology. Set up a restricted-access account; users can push changes over "
dongsheng@627 12650 "the network to repositories managed by this account, but they cannot log into "
dongsheng@627 12651 "the account and run normal shell commands. In this scenario, a user can "
dongsheng@627 12652 "commit a changeset that contains any old garbage they want."
dongsheng@627 12653 msgstr ""
dongsheng@627 12654
dongsheng@627 12655 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12656 #: ../en/ch10-hook.xml:225
dongsheng@627 12657 msgid ""
dongsheng@627 12658 "When someone pushes a changeset to the server that everyone pulls from, the "
dongsheng@627 12659 "server will test the changeset before it accepts it as permanent, and reject "
dongsheng@627 12660 "it if it fails to pass the test suite. If people only pull changes from this "
dongsheng@627 12661 "filtering server, it will serve to ensure that all changes that people pull "
dongsheng@627 12662 "have been automatically vetted."
dongsheng@627 12663 msgstr ""
dongsheng@627 12664
dongsheng@627 12665 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 12666 #: ../en/ch10-hook.xml:237
dongsheng@627 12667 msgid "A short tutorial on using hooks"
dongsheng@635 12668 msgstr "使用钩子的简短指南"
dongsheng@627 12669
dongsheng@627 12670 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 12671 #: ../en/ch10-hook.xml:239
dongsheng@627 12672 msgid ""
dongsheng@627 12673 "It is easy to write a Mercurial hook. Let's start with a hook that runs when "
dongsheng@627 12674 "you finish a <command role=\"hg-cmd\">hg commit</command>, and simply prints "
dongsheng@627 12675 "the hash of the changeset you just created. The hook is called <literal role="
dongsheng@627 12676 "\"hook\">commit</literal>."
dongsheng@627 12677 msgstr ""
dongsheng@627 12678
dongsheng@627 12679 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 12680 #: ../en/ch10-hook.xml:246
dongsheng@627 12681 msgid "All hooks follow the pattern in this example."
dongsheng@627 12682 msgstr ""
dongsheng@627 12683
dongsheng@627 12684 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 12685 #: ../en/ch10-hook.xml:250
dongsheng@627 12686 msgid ""
dongsheng@627 12687 "You add an entry to the <literal role=\"rc-hooks\">hooks</literal> section of "
dongsheng@650 12688 "your <filename role=\"special\">~/.hgrc</filename>. On the left is the name "
dongsheng@627 12689 "of the event to trigger on; on the right is the action to take. As you can "
dongsheng@627 12690 "see, you can run an arbitrary shell command in a hook. Mercurial passes "
dongsheng@627 12691 "extra information to the hook using environment variables (look for "
dongsheng@627 12692 "<envar>HG_NODE</envar> in the example)."
dongsheng@627 12693 msgstr ""
dongsheng@627 12694
dongsheng@627 12695 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 12696 #: ../en/ch10-hook.xml:260
dongsheng@627 12697 msgid "Performing multiple actions per event"
dongsheng@635 12698 msgstr "每个事件执行多个操作"
dongsheng@627 12699
dongsheng@627 12700 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12701 #: ../en/ch10-hook.xml:262
dongsheng@627 12702 msgid ""
dongsheng@627 12703 "Quite often, you will want to define more than one hook for a particular kind "
dongsheng@627 12704 "of event, as shown below."
dongsheng@627 12705 msgstr ""
dongsheng@627 12706
dongsheng@627 12707 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12708 #: ../en/ch10-hook.xml:267
dongsheng@627 12709 msgid ""
dongsheng@627 12710 "Mercurial lets you do this by adding an <emphasis>extension</emphasis> to the "
dongsheng@627 12711 "end of a hook's name. You extend a hook's name by giving the name of the "
dongsheng@627 12712 "hook, followed by a full stop (the <quote><literal>.</literal></quote> "
dongsheng@627 12713 "character), followed by some more text of your choosing. For example, "
dongsheng@627 12714 "Mercurial will run both <literal>commit.foo</literal> and <literal>commit."
dongsheng@627 12715 "bar</literal> when the <literal>commit</literal> event occurs."
dongsheng@627 12716 msgstr ""
dongsheng@627 12717
dongsheng@627 12718 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12719 #: ../en/ch10-hook.xml:278
dongsheng@627 12720 msgid ""
dongsheng@627 12721 "To give a well-defined order of execution when there are multiple hooks "
dongsheng@627 12722 "defined for an event, Mercurial sorts hooks by extension, and executes the "
dongsheng@627 12723 "hook commands in this sorted order. In the above example, it will execute "
dongsheng@627 12724 "<literal>commit.bar</literal> before <literal>commit.foo</literal>, and "
dongsheng@627 12725 "<literal>commit</literal> before both."
dongsheng@627 12726 msgstr ""
dongsheng@627 12727
dongsheng@627 12728 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12729 #: ../en/ch10-hook.xml:287
dongsheng@627 12730 msgid ""
dongsheng@627 12731 "It is a good idea to use a somewhat descriptive extension when you define a "
dongsheng@627 12732 "new hook. This will help you to remember what the hook was for. If the hook "
dongsheng@627 12733 "fails, you'll get an error message that contains the hook name and extension, "
dongsheng@627 12734 "so using a descriptive extension could give you an immediate hint as to why "
songdongsheng@658 12735 "the hook failed (see <xref linkend=\"sec:hook:perm\"/> for an example)."
dongsheng@627 12736 msgstr ""
dongsheng@627 12737
dongsheng@627 12738 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 12739 #: ../en/ch10-hook.xml:298
dongsheng@627 12740 msgid "Controlling whether an activity can proceed"
dongsheng@635 12741 msgstr "控制处理的活动"
dongsheng@627 12742
dongsheng@627 12743 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12744 #: ../en/ch10-hook.xml:300
dongsheng@627 12745 msgid ""
dongsheng@627 12746 "In our earlier examples, we used the <literal role=\"hook\">commit</literal> "
dongsheng@627 12747 "hook, which is run after a commit has completed. This is one of several "
dongsheng@627 12748 "Mercurial hooks that run after an activity finishes. Such hooks have no way "
dongsheng@627 12749 "of influencing the activity itself."
dongsheng@627 12750 msgstr ""
dongsheng@627 12751
dongsheng@627 12752 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12753 #: ../en/ch10-hook.xml:307
dongsheng@627 12754 msgid ""
dongsheng@627 12755 "Mercurial defines a number of events that occur before an activity starts; or "
dongsheng@627 12756 "after it starts, but before it finishes. Hooks that trigger on these events "
dongsheng@627 12757 "have the added ability to choose whether the activity can continue, or will "
dongsheng@627 12758 "abort."
dongsheng@627 12759 msgstr ""
dongsheng@627 12760
dongsheng@627 12761 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12762 #: ../en/ch10-hook.xml:313
dongsheng@627 12763 msgid ""
dongsheng@627 12764 "The <literal role=\"hook\">pretxncommit</literal> hook runs after a commit "
dongsheng@627 12765 "has all but completed. In other words, the metadata representing the "
dongsheng@627 12766 "changeset has been written out to disk, but the transaction has not yet been "
dongsheng@627 12767 "allowed to complete. The <literal role=\"hook\">pretxncommit</literal> hook "
dongsheng@627 12768 "has the ability to decide whether the transaction can complete, or must be "
dongsheng@627 12769 "rolled back."
dongsheng@627 12770 msgstr ""
dongsheng@627 12771
dongsheng@627 12772 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12773 #: ../en/ch10-hook.xml:322
dongsheng@627 12774 msgid ""
dongsheng@627 12775 "If the <literal role=\"hook\">pretxncommit</literal> hook exits with a status "
dongsheng@627 12776 "code of zero, the transaction is allowed to complete; the commit finishes; "
dongsheng@627 12777 "and the <literal role=\"hook\">commit</literal> hook is run. If the <literal "
dongsheng@627 12778 "role=\"hook\">pretxncommit</literal> hook exits with a non-zero status code, "
dongsheng@627 12779 "the transaction is rolled back; the metadata representing the changeset is "
dongsheng@627 12780 "erased; and the <literal role=\"hook\">commit</literal> hook is not run."
dongsheng@627 12781 msgstr ""
dongsheng@627 12782
dongsheng@627 12783 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12784 #: ../en/ch10-hook.xml:334
dongsheng@627 12785 msgid ""
dongsheng@627 12786 "The hook in the example above checks that a commit comment contains a bug "
dongsheng@627 12787 "ID. If it does, the commit can complete. If not, the commit is rolled back."
dongsheng@627 12788 msgstr ""
dongsheng@627 12789
dongsheng@627 12790 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 12791 #: ../en/ch10-hook.xml:342
dongsheng@627 12792 msgid "Writing your own hooks"
dongsheng@635 12793 msgstr "编写钩子"
dongsheng@627 12794
dongsheng@627 12795 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 12796 #: ../en/ch10-hook.xml:344
dongsheng@627 12797 msgid ""
dongsheng@627 12798 "When you are writing a hook, you might find it useful to run Mercurial either "
dongsheng@627 12799 "with the <option role=\"hg-opt-global\">-v</option> option, or the <envar "
dongsheng@627 12800 "role=\"rc-item-ui\">verbose</envar> config item set to <quote>true</quote>. "
dongsheng@627 12801 "When you do so, Mercurial will print a message before it calls each hook."
dongsheng@627 12802 msgstr ""
dongsheng@627 12803
dongsheng@627 12804 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 12805 #: ../en/ch10-hook.xml:353
dongsheng@627 12806 msgid "Choosing how your hook should run"
dongsheng@635 12807 msgstr "选择钩子的执行方式"
dongsheng@627 12808
dongsheng@627 12809 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12810 #: ../en/ch10-hook.xml:355
dongsheng@627 12811 msgid ""
songdongsheng@668 12812 "You can write a hook either as a normal program&emdash;typically a shell "
songdongsheng@668 12813 "script&emdash;or as a Python function that is executed within the Mercurial "
songdongsheng@668 12814 "process."
dongsheng@627 12815 msgstr ""
dongsheng@627 12816
dongsheng@627 12817 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12818 #: ../en/ch10-hook.xml:360
dongsheng@627 12819 msgid ""
dongsheng@627 12820 "Writing a hook as an external program has the advantage that it requires no "
dongsheng@627 12821 "knowledge of Mercurial's internals. You can call normal Mercurial commands "
dongsheng@627 12822 "to get any added information you need. The trade-off is that external hooks "
dongsheng@627 12823 "are slower than in-process hooks."
dongsheng@627 12824 msgstr ""
dongsheng@627 12825
dongsheng@627 12826 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12827 #: ../en/ch10-hook.xml:367
dongsheng@627 12828 msgid ""
dongsheng@627 12829 "An in-process Python hook has complete access to the Mercurial API, and does "
dongsheng@627 12830 "not <quote>shell out</quote> to another process, so it is inherently faster "
dongsheng@627 12831 "than an external hook. It is also easier to obtain much of the information "
dongsheng@627 12832 "that a hook requires by using the Mercurial API than by running Mercurial "
dongsheng@627 12833 "commands."
dongsheng@627 12834 msgstr ""
dongsheng@627 12835
dongsheng@627 12836 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12837 #: ../en/ch10-hook.xml:375
dongsheng@627 12838 msgid ""
dongsheng@627 12839 "If you are comfortable with Python, or require high performance, writing your "
dongsheng@627 12840 "hooks in Python may be a good choice. However, when you have a "
dongsheng@627 12841 "straightforward hook to write and you don't need to care about performance "
dongsheng@627 12842 "(probably the majority of hooks), a shell script is perfectly fine."
dongsheng@627 12843 msgstr ""
dongsheng@627 12844
dongsheng@627 12845 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 12846 #: ../en/ch10-hook.xml:384
dongsheng@627 12847 msgid "Hook parameters"
dongsheng@635 12848 msgstr "钩子的参数"
dongsheng@627 12849
dongsheng@627 12850 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12851 #: ../en/ch10-hook.xml:386
dongsheng@627 12852 msgid ""
dongsheng@627 12853 "Mercurial calls each hook with a set of well-defined parameters. In Python, "
dongsheng@627 12854 "a parameter is passed as a keyword argument to your hook function. For an "
dongsheng@627 12855 "external program, a parameter is passed as an environment variable."
dongsheng@627 12856 msgstr ""
dongsheng@627 12857
dongsheng@627 12858 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12859 #: ../en/ch10-hook.xml:392
dongsheng@627 12860 msgid ""
dongsheng@627 12861 "Whether your hook is written in Python or as a shell script, the hook-"
dongsheng@627 12862 "specific parameter names and values will be the same. A boolean parameter "
dongsheng@627 12863 "will be represented as a boolean value in Python, but as the number 1 (for "
dongsheng@627 12864 "<quote>true</quote>) or 0 (for <quote>false</quote>) as an environment "
dongsheng@627 12865 "variable for an external hook. If a hook parameter is named <literal>foo</"
dongsheng@627 12866 "literal>, the keyword argument for a Python hook will also be named "
dongsheng@627 12867 "<literal>foo</literal>, while the environment variable for an external hook "
dongsheng@627 12868 "will be named <literal>HG_FOO</literal>."
dongsheng@627 12869 msgstr ""
dongsheng@627 12870
dongsheng@627 12871 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 12872 #: ../en/ch10-hook.xml:406
dongsheng@627 12873 msgid "Hook return values and activity control"
dongsheng@635 12874 msgstr "钩子的返回值与活动控制"
dongsheng@627 12875
dongsheng@627 12876 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12877 #: ../en/ch10-hook.xml:408
dongsheng@627 12878 msgid ""
dongsheng@627 12879 "A hook that executes successfully must exit with a status of zero if "
dongsheng@627 12880 "external, or return boolean <quote>false</quote> if in-process. Failure is "
dongsheng@627 12881 "indicated with a non-zero exit status from an external hook, or an in-process "
dongsheng@627 12882 "hook returning boolean <quote>true</quote>. If an in-process hook raises an "
dongsheng@627 12883 "exception, the hook is considered to have failed."
dongsheng@627 12884 msgstr ""
dongsheng@627 12885
dongsheng@627 12886 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12887 #: ../en/ch10-hook.xml:416
dongsheng@627 12888 msgid ""
dongsheng@627 12889 "For a hook that controls whether an activity can proceed, zero/false means "
dongsheng@627 12890 "<quote>allow</quote>, while non-zero/true/exception means <quote>deny</quote>."
dongsheng@627 12891 msgstr ""
dongsheng@627 12892
dongsheng@627 12893 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 12894 #: ../en/ch10-hook.xml:423
dongsheng@627 12895 msgid "Writing an external hook"
dongsheng@635 12896 msgstr "编写外部钩子"
dongsheng@627 12897
dongsheng@627 12898 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12899 #: ../en/ch10-hook.xml:425
dongsheng@650 12900 msgid ""
dongsheng@650 12901 "When you define an external hook in your <filename role=\"special\">~/.hgrc</"
dongsheng@650 12902 "filename> and the hook is run, its value is passed to your shell, which "
dongsheng@627 12903 "interprets it. This means that you can use normal shell constructs in the "
dongsheng@627 12904 "body of the hook."
dongsheng@627 12905 msgstr ""
dongsheng@627 12906
dongsheng@627 12907 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12908 #: ../en/ch10-hook.xml:432
dongsheng@627 12909 msgid ""
dongsheng@627 12910 "An executable hook is always run with its current directory set to a "
dongsheng@627 12911 "repository's root directory."
dongsheng@627 12912 msgstr ""
dongsheng@627 12913
dongsheng@627 12914 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12915 #: ../en/ch10-hook.xml:436
dongsheng@627 12916 msgid ""
dongsheng@627 12917 "Each hook parameter is passed in as an environment variable; the name is "
dongsheng@627 12918 "upper-cased, and prefixed with the string <quote><literal>HG_</literal></"
dongsheng@627 12919 "quote>."
dongsheng@627 12920 msgstr ""
dongsheng@627 12921
dongsheng@627 12922 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12923 #: ../en/ch10-hook.xml:441
dongsheng@627 12924 msgid ""
dongsheng@627 12925 "With the exception of hook parameters, Mercurial does not set or modify any "
dongsheng@627 12926 "environment variables when running a hook. This is useful to remember if you "
dongsheng@627 12927 "are writing a site-wide hook that may be run by a number of different users "
dongsheng@627 12928 "with differing environment variables set. In multi-user situations, you "
dongsheng@627 12929 "should not rely on environment variables being set to the values you have in "
dongsheng@627 12930 "your environment when testing the hook."
dongsheng@627 12931 msgstr ""
dongsheng@627 12932
dongsheng@627 12933 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 12934 #: ../en/ch10-hook.xml:452
dongsheng@627 12935 msgid "Telling Mercurial to use an in-process hook"
dongsheng@642 12936 msgstr "让 Mercurial 使用进程内钩子"
dongsheng@627 12937
dongsheng@627 12938 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12939 #: ../en/ch10-hook.xml:454
dongsheng@650 12940 msgid ""
dongsheng@650 12941 "The <filename role=\"special\">~/.hgrc</filename> syntax for defining an in-"
dongsheng@627 12942 "process hook is slightly different than for an executable hook. The value of "
dongsheng@627 12943 "the hook must start with the text <quote><literal>python:</literal></quote>, "
dongsheng@627 12944 "and continue with the fully-qualified name of a callable object to use as the "
dongsheng@627 12945 "hook's value."
dongsheng@627 12946 msgstr ""
dongsheng@627 12947
dongsheng@627 12948 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12949 #: ../en/ch10-hook.xml:462
dongsheng@627 12950 msgid ""
dongsheng@627 12951 "The module in which a hook lives is automatically imported when a hook is "
dongsheng@627 12952 "run. So long as you have the module name and <envar>PYTHONPATH</envar> "
dongsheng@627 12953 "right, it should <quote>just work</quote>."
dongsheng@627 12954 msgstr ""
dongsheng@627 12955
dongsheng@627 12956 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12957 #: ../en/ch10-hook.xml:468
dongsheng@650 12958 msgid ""
dongsheng@650 12959 "The following <filename role=\"special\">~/.hgrc</filename> example snippet "
dongsheng@627 12960 "illustrates the syntax and meaning of the notions we just described."
dongsheng@627 12961 msgstr ""
dongsheng@627 12962
dongsheng@627 12963 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12964 #: ../en/ch10-hook.xml:474
dongsheng@627 12965 msgid ""
dongsheng@627 12966 "When Mercurial runs the <literal>commit.example</literal> hook, it imports "
dongsheng@627 12967 "<literal>mymodule.submodule</literal>, looks for the callable object named "
dongsheng@627 12968 "<literal>myhook</literal>, and calls it."
dongsheng@627 12969 msgstr ""
dongsheng@627 12970
dongsheng@627 12971 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 12972 #: ../en/ch10-hook.xml:482
dongsheng@627 12973 msgid "Writing an in-process hook"
dongsheng@635 12974 msgstr "编写进程内钩子"
dongsheng@627 12975
dongsheng@627 12976 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12977 #: ../en/ch10-hook.xml:484
dongsheng@627 12978 msgid ""
dongsheng@627 12979 "The simplest in-process hook does nothing, but illustrates the basic shape of "
dongsheng@627 12980 "the hook API:"
dongsheng@627 12981 msgstr ""
dongsheng@627 12982
dongsheng@627 12983 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 12984 #: ../en/ch10-hook.xml:489
dongsheng@627 12985 msgid ""
dongsheng@627 12986 "The first argument to a Python hook is always a <literal role=\"py-mod-"
dongsheng@627 12987 "mercurial.ui\">ui</literal> object. The second is a repository object; at "
dongsheng@627 12988 "the moment, it is always an instance of <literal role=\"py-mod-mercurial."
dongsheng@627 12989 "localrepo\">localrepository</literal>. Following these two arguments are "
dongsheng@627 12990 "other keyword arguments. Which ones are passed in depends on the hook being "
dongsheng@627 12991 "called, but a hook can ignore arguments it doesn't care about by dropping "
dongsheng@627 12992 "them into a keyword argument dict, as with <literal>**kwargs</literal> above."
dongsheng@627 12993 msgstr ""
dongsheng@627 12994
dongsheng@627 12995 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 12996 #: ../en/ch10-hook.xml:504
dongsheng@627 12997 msgid "Some hook examples"
dongsheng@635 12998 msgstr "钩子样例"
dongsheng@627 12999
dongsheng@627 13000 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 13001 #: ../en/ch10-hook.xml:507
dongsheng@627 13002 msgid "Writing meaningful commit messages"
dongsheng@635 13003 msgstr "编写有意义的提交日志"
dongsheng@627 13004
dongsheng@627 13005 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 13006 #: ../en/ch10-hook.xml:509
dongsheng@627 13007 msgid ""
dongsheng@627 13008 "It's hard to imagine a useful commit message being very short. The simple "
dongsheng@627 13009 "<literal role=\"hook\">pretxncommit</literal> hook of the example below will "
dongsheng@627 13010 "prevent you from committing a changeset with a message that is less than ten "
dongsheng@627 13011 "bytes long."
dongsheng@627 13012 msgstr ""
dongsheng@627 13013
dongsheng@627 13014 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 13015 #: ../en/ch10-hook.xml:519
dongsheng@627 13016 msgid "Checking for trailing whitespace"
dongsheng@635 13017 msgstr "检查行尾空格"
dongsheng@627 13018
dongsheng@627 13019 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 13020 #: ../en/ch10-hook.xml:521
dongsheng@627 13021 msgid ""
dongsheng@627 13022 "An interesting use of a commit-related hook is to help you to write cleaner "
dongsheng@627 13023 "code. A simple example of <quote>cleaner code</quote> is the dictum that a "
dongsheng@627 13024 "change should not add any new lines of text that contain <quote>trailing "
dongsheng@627 13025 "whitespace</quote>. Trailing whitespace is a series of space and tab "
dongsheng@627 13026 "characters at the end of a line of text. In most cases, trailing whitespace "
dongsheng@627 13027 "is unnecessary, invisible noise, but it is occasionally problematic, and "
dongsheng@627 13028 "people often prefer to get rid of it."
dongsheng@627 13029 msgstr ""
dongsheng@627 13030
dongsheng@627 13031 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 13032 #: ../en/ch10-hook.xml:532
dongsheng@627 13033 msgid ""
dongsheng@627 13034 "You can use either the <literal role=\"hook\">precommit</literal> or <literal "
dongsheng@627 13035 "role=\"hook\">pretxncommit</literal> hook to tell whether you have a trailing "
dongsheng@627 13036 "whitespace problem. If you use the <literal role=\"hook\">precommit</"
dongsheng@627 13037 "literal> hook, the hook will not know which files you are committing, so it "
dongsheng@627 13038 "will have to check every modified file in the repository for trailing white "
dongsheng@627 13039 "space. If you want to commit a change to just the file <filename>foo</"
dongsheng@627 13040 "filename>, but the file <filename>bar</filename> contains trailing "
dongsheng@627 13041 "whitespace, doing a check in the <literal role=\"hook\">precommit</literal> "
dongsheng@627 13042 "hook will prevent you from committing <filename>foo</filename> due to the "
dongsheng@627 13043 "problem with <filename>bar</filename>. This doesn't seem right."
dongsheng@627 13044 msgstr ""
dongsheng@627 13045
dongsheng@627 13046 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 13047 #: ../en/ch10-hook.xml:548
dongsheng@627 13048 msgid ""
dongsheng@627 13049 "Should you choose the <literal role=\"hook\">pretxncommit</literal> hook, the "
dongsheng@627 13050 "check won't occur until just before the transaction for the commit "
dongsheng@627 13051 "completes. This will allow you to check for problems only the exact files "
dongsheng@627 13052 "that are being committed. However, if you entered the commit message "
dongsheng@627 13053 "interactively and the hook fails, the transaction will roll back; you'll have "
dongsheng@627 13054 "to re-enter the commit message after you fix the trailing whitespace and run "
dongsheng@627 13055 "<command role=\"hg-cmd\">hg commit</command> again."
dongsheng@627 13056 msgstr ""
dongsheng@627 13057
dongsheng@627 13058 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 13059 #: ../en/ch10-hook.xml:561
dongsheng@627 13060 msgid ""
dongsheng@627 13061 "In this example, we introduce a simple <literal role=\"hook\">pretxncommit</"
dongsheng@627 13062 "literal> hook that checks for trailing whitespace. This hook is short, but "
dongsheng@627 13063 "not very helpful. It exits with an error status if a change adds a line with "
dongsheng@627 13064 "trailing whitespace to any file, but does not print any information that "
dongsheng@627 13065 "might help us to identify the offending file or line. It also has the nice "
dongsheng@627 13066 "property of not paying attention to unmodified lines; only lines that "
dongsheng@627 13067 "introduce new trailing whitespace cause problems."
dongsheng@627 13068 msgstr ""
dongsheng@627 13069
dongsheng@627 13070 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 13071 #: ../en/ch10-hook.xml:574
dongsheng@627 13072 msgid ""
dongsheng@627 13073 "The above version is much more complex, but also more useful. It parses a "
dongsheng@627 13074 "unified diff to see if any lines add trailing whitespace, and prints the name "
dongsheng@627 13075 "of the file and the line number of each such occurrence. Even better, if the "
dongsheng@627 13076 "change adds trailing whitespace, this hook saves the commit comment and "
dongsheng@627 13077 "prints the name of the save file before exiting and telling Mercurial to roll "
dongsheng@627 13078 "the transaction back, so you can use the <option role=\"hg-opt-commit\">-l "
dongsheng@627 13079 "filename</option> option to <command role=\"hg-cmd\">hg commit</command> to "
dongsheng@627 13080 "reuse the saved commit message once you've corrected the problem."
dongsheng@627 13081 msgstr ""
dongsheng@627 13082
dongsheng@627 13083 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 13084 #: ../en/ch10-hook.xml:588
dongsheng@714 13085 msgid ""
dongsheng@714 13086 "As a final aside, note in the example above the use of <command>sed</"
dongsheng@627 13087 "command>'s in-place editing feature to get rid of trailing whitespace from a "
dongsheng@714 13088 "file. This is concise and useful enough that I will reproduce it here (using "
dongsheng@714 13089 "<command>perl</command> for good measure)."
dongsheng@627 13090 msgstr ""
dongsheng@627 13091
dongsheng@627 13092 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 13093 #: ../en/ch10-hook.xml:598
dongsheng@627 13094 msgid "Bundled hooks"
dongsheng@635 13095 msgstr "内置的钩子"
dongsheng@627 13096
dongsheng@627 13097 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 13098 #: ../en/ch10-hook.xml:600
dongsheng@627 13099 msgid ""
dongsheng@627 13100 "Mercurial ships with several bundled hooks. You can find them in the "
dongsheng@627 13101 "<filename class=\"directory\">hgext</filename> directory of a Mercurial "
dongsheng@627 13102 "source tree. If you are using a Mercurial binary package, the hooks will be "
dongsheng@627 13103 "located in the <filename class=\"directory\">hgext</filename> directory of "
dongsheng@627 13104 "wherever your package installer put Mercurial."
dongsheng@627 13105 msgstr ""
dongsheng@627 13106
dongsheng@627 13107 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 13108 #: ../en/ch10-hook.xml:609
songdongsheng@668 13109 msgid ""
songdongsheng@668 13110 "<literal role=\"hg-ext\">acl</literal>&emdash;access control for parts of a "
dongsheng@627 13111 "repository"
dongsheng@661 13112 msgstr "<literal role=\"hg-ext\">acl</literal>—版本库的访问控制"
dongsheng@627 13113
dongsheng@627 13114 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 13115 #: ../en/ch10-hook.xml:612
dongsheng@627 13116 msgid ""
dongsheng@627 13117 "The <literal role=\"hg-ext\">acl</literal> extension lets you control which "
dongsheng@627 13118 "remote users are allowed to push changesets to a networked server. You can "
dongsheng@627 13119 "protect any portion of a repository (including the entire repo), so that a "
dongsheng@627 13120 "specific remote user can push changes that do not affect the protected "
dongsheng@627 13121 "portion."
dongsheng@627 13122 msgstr ""
dongsheng@627 13123
dongsheng@627 13124 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 13125 #: ../en/ch10-hook.xml:620
dongsheng@627 13126 msgid ""
dongsheng@627 13127 "This extension implements access control based on the identity of the user "
dongsheng@627 13128 "performing a push, <emphasis>not</emphasis> on who committed the changesets "
dongsheng@627 13129 "they're pushing. It makes sense to use this hook only if you have a locked-"
dongsheng@627 13130 "down server environment that authenticates remote users, and you want to be "
dongsheng@627 13131 "sure that only specific users are allowed to push changes to that server."
dongsheng@627 13132 msgstr ""
dongsheng@627 13133
dongsheng@627 13134 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
dongsheng@714 13135 #: ../en/ch10-hook.xml:630
dongsheng@627 13136 msgid "Configuring the <literal role=\"hook\">acl</literal> hook"
dongsheng@635 13137 msgstr "配置 <literal role=\"hook\">acl</literal> 钩子"
dongsheng@627 13138
dongsheng@627 13139 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 13140 #: ../en/ch10-hook.xml:633
dongsheng@627 13141 msgid ""
dongsheng@627 13142 "In order to manage incoming changesets, the <literal role=\"hg-ext\">acl</"
dongsheng@627 13143 "literal> hook must be used as a <literal role=\"hook\">pretxnchangegroup</"
dongsheng@627 13144 "literal> hook. This lets it see which files are modified by each incoming "
dongsheng@627 13145 "changeset, and roll back a group of changesets if they modify "
dongsheng@627 13146 "<quote>forbidden</quote> files. Example:"
dongsheng@627 13147 msgstr ""
dongsheng@627 13148
dongsheng@627 13149 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 13150 #: ../en/ch10-hook.xml:643
dongsheng@627 13151 msgid ""
dongsheng@627 13152 "The <literal role=\"hg-ext\">acl</literal> extension is configured using "
dongsheng@627 13153 "three sections."
dongsheng@627 13154 msgstr ""
dongsheng@627 13155
dongsheng@627 13156 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 13157 #: ../en/ch10-hook.xml:647
dongsheng@627 13158 msgid ""
dongsheng@627 13159 "The <literal role=\"rc-acl\">acl</literal> section has only one entry, <envar "
dongsheng@627 13160 "role=\"rc-item-acl\">sources</envar>, which lists the sources of incoming "
dongsheng@627 13161 "changesets that the hook should pay attention to. You don't normally need to "
dongsheng@627 13162 "configure this section."
dongsheng@627 13163 msgstr ""
dongsheng@627 13164
dongsheng@627 13165 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@714 13166 #: ../en/ch10-hook.xml:654
dongsheng@627 13167 msgid ""
dongsheng@627 13168 "<envar role=\"rc-item-acl\">serve</envar>: Control incoming changesets that "
dongsheng@627 13169 "are arriving from a remote repository over http or ssh. This is the default "
dongsheng@627 13170 "value of <envar role=\"rc-item-acl\">sources</envar>, and usually the only "
dongsheng@627 13171 "setting you'll need for this configuration item."
dongsheng@627 13172 msgstr ""
dongsheng@627 13173
dongsheng@627 13174 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@714 13175 #: ../en/ch10-hook.xml:662
dongsheng@627 13176 msgid ""
dongsheng@627 13177 "<envar role=\"rc-item-acl\">pull</envar>: Control incoming changesets that "
dongsheng@627 13178 "are arriving via a pull from a local repository."
dongsheng@627 13179 msgstr ""
dongsheng@627 13180
dongsheng@627 13181 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@714 13182 #: ../en/ch10-hook.xml:667
dongsheng@627 13183 msgid ""
dongsheng@627 13184 "<envar role=\"rc-item-acl\">push</envar>: Control incoming changesets that "
dongsheng@627 13185 "are arriving via a push from a local repository."
dongsheng@627 13186 msgstr ""
dongsheng@627 13187
dongsheng@627 13188 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@714 13189 #: ../en/ch10-hook.xml:672
dongsheng@627 13190 msgid ""
dongsheng@627 13191 "<envar role=\"rc-item-acl\">bundle</envar>: Control incoming changesets that "
dongsheng@627 13192 "are arriving from another repository via a bundle."
dongsheng@627 13193 msgstr ""
dongsheng@627 13194
dongsheng@627 13195 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 13196 #: ../en/ch10-hook.xml:678
dongsheng@627 13197 msgid ""
dongsheng@627 13198 "The <literal role=\"rc-acl.allow\">acl.allow</literal> section controls the "
dongsheng@627 13199 "users that are allowed to add changesets to the repository. If this section "
dongsheng@627 13200 "is not present, all users that are not explicitly denied are allowed. If "
dongsheng@627 13201 "this section is present, all users that are not explicitly allowed are denied "
dongsheng@627 13202 "(so an empty section means that all users are denied)."
dongsheng@627 13203 msgstr ""
dongsheng@627 13204
dongsheng@627 13205 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 13206 #: ../en/ch10-hook.xml:687
dongsheng@627 13207 msgid ""
dongsheng@627 13208 "The <literal role=\"rc-acl.deny\">acl.deny</literal> section determines which "
dongsheng@627 13209 "users are denied from adding changesets to the repository. If this section "
dongsheng@627 13210 "is not present or is empty, no users are denied."
dongsheng@627 13211 msgstr ""
dongsheng@627 13212
dongsheng@627 13213 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 13214 #: ../en/ch10-hook.xml:693
dongsheng@627 13215 msgid ""
dongsheng@627 13216 "The syntaxes for the <literal role=\"rc-acl.allow\">acl.allow</literal> and "
dongsheng@627 13217 "<literal role=\"rc-acl.deny\">acl.deny</literal> sections are identical. On "
dongsheng@627 13218 "the left of each entry is a glob pattern that matches files or directories, "
dongsheng@627 13219 "relative to the root of the repository; on the right, a user name."
dongsheng@627 13220 msgstr ""
dongsheng@627 13221
dongsheng@627 13222 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 13223 #: ../en/ch10-hook.xml:701
dongsheng@627 13224 msgid ""
dongsheng@627 13225 "In the following example, the user <literal>docwriter</literal> can only push "
dongsheng@627 13226 "changes to the <filename class=\"directory\">docs</filename> subtree of the "
dongsheng@627 13227 "repository, while <literal>intern</literal> can push changes to any file or "
dongsheng@627 13228 "directory except <filename class=\"directory\">source/sensitive</filename>."
dongsheng@627 13229 msgstr ""
dongsheng@627 13230
dongsheng@627 13231 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
dongsheng@714 13232 #: ../en/ch10-hook.xml:715 ../en/ch10-hook.xml:979 ../en/ch10-hook.xml:1169
dongsheng@627 13233 msgid "Testing and troubleshooting"
dongsheng@635 13234 msgstr "测试与问题处理"
dongsheng@627 13235
dongsheng@627 13236 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 13237 #: ../en/ch10-hook.xml:717
dongsheng@627 13238 msgid ""
dongsheng@627 13239 "If you want to test the <literal role=\"hg-ext\">acl</literal> hook, run it "
dongsheng@627 13240 "with Mercurial's debugging output enabled. Since you'll probably be running "
dongsheng@627 13241 "it on a server where it's not convenient (or sometimes possible) to pass in "
dongsheng@627 13242 "the <option role=\"hg-opt-global\">--debug</option> option, don't forget that "
dongsheng@650 13243 "you can enable debugging output in your <filename role=\"special\">~/.hgrc</"
dongsheng@627 13244 "filename>:"
dongsheng@627 13245 msgstr ""
dongsheng@627 13246
dongsheng@627 13247 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 13248 #: ../en/ch10-hook.xml:728
dongsheng@627 13249 msgid ""
dongsheng@627 13250 "With this enabled, the <literal role=\"hg-ext\">acl</literal> hook will print "
dongsheng@627 13251 "enough information to let you figure out why it is allowing or forbidding "
dongsheng@627 13252 "pushes from specific users."
dongsheng@627 13253 msgstr ""
dongsheng@627 13254
dongsheng@627 13255 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 13256 #: ../en/ch10-hook.xml:737
songdongsheng@668 13257 msgid ""
songdongsheng@668 13258 "<literal role=\"hg-ext\">bugzilla</literal>&emdash;integration with Bugzilla"
dongsheng@661 13259 msgstr "<literal role=\"hg-ext\">bugzilla</literal>—与 Bugzilla 的集成"
dongsheng@627 13260
dongsheng@627 13261 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 13262 #: ../en/ch10-hook.xml:741
dongsheng@627 13263 msgid ""
dongsheng@627 13264 "The <literal role=\"hg-ext\">bugzilla</literal> extension adds a comment to a "
dongsheng@627 13265 "Bugzilla bug whenever it finds a reference to that bug ID in a commit "
dongsheng@627 13266 "comment. You can install this hook on a shared server, so that any time a "
dongsheng@627 13267 "remote user pushes changes to this server, the hook gets run."
dongsheng@627 13268 msgstr ""
dongsheng@627 13269
dongsheng@627 13270 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 13271 #: ../en/ch10-hook.xml:748
dongsheng@627 13272 msgid ""
dongsheng@627 13273 "It adds a comment to the bug that looks like this (you can configure the "
songdongsheng@668 13274 "contents of the comment&emdash;see below):"
dongsheng@627 13275 msgstr ""
dongsheng@627 13276
dongsheng@627 13277 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 13278 #: ../en/ch10-hook.xml:757
dongsheng@627 13279 msgid ""
dongsheng@627 13280 "The value of this hook is that it automates the process of updating a bug any "
dongsheng@627 13281 "time a changeset refers to it. If you configure the hook properly, it makes "
dongsheng@627 13282 "it easy for people to browse straight from a Bugzilla bug to a changeset that "
dongsheng@627 13283 "refers to that bug."
dongsheng@627 13284 msgstr ""
dongsheng@627 13285
dongsheng@627 13286 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 13287 #: ../en/ch10-hook.xml:764
dongsheng@627 13288 msgid ""
dongsheng@627 13289 "You can use the code in this hook as a starting point for some more exotic "
dongsheng@627 13290 "Bugzilla integration recipes. Here are a few possibilities:"
dongsheng@627 13291 msgstr ""
dongsheng@627 13292
dongsheng@627 13293 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 13294 #: ../en/ch10-hook.xml:769
dongsheng@627 13295 msgid ""
dongsheng@627 13296 "Require that every changeset pushed to the server have a valid bug ID in its "
dongsheng@627 13297 "commit comment. In this case, you'd want to configure the hook as a <literal "
dongsheng@627 13298 "role=\"hook\">pretxncommit</literal> hook. This would allow the hook to "
dongsheng@627 13299 "reject changes that didn't contain bug IDs."
dongsheng@627 13300 msgstr ""
dongsheng@627 13301
dongsheng@627 13302 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 13303 #: ../en/ch10-hook.xml:777
dongsheng@627 13304 msgid ""
dongsheng@627 13305 "Allow incoming changesets to automatically modify the <emphasis>state</"
dongsheng@627 13306 "emphasis> of a bug, as well as simply adding a comment. For example, the "
dongsheng@627 13307 "hook could recognise the string <quote>fixed bug 31337</quote> as indicating "
dongsheng@627 13308 "that it should update the state of bug 31337 to <quote>requires testing</"
dongsheng@627 13309 "quote>."
dongsheng@627 13310 msgstr ""
dongsheng@627 13311
dongsheng@627 13312 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
dongsheng@714 13313 #: ../en/ch10-hook.xml:787
dongsheng@627 13314 msgid "Configuring the <literal role=\"hook\">bugzilla</literal> hook"
dongsheng@635 13315 msgstr "配置 <literal role=\"hook\">bugzilla</literal> 钩子"
dongsheng@627 13316
dongsheng@627 13317 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 13318 #: ../en/ch10-hook.xml:790
dongsheng@650 13319 msgid ""
dongsheng@650 13320 "You should configure this hook in your server's <filename role=\"special\">~/."
dongsheng@650 13321 "hgrc</filename> as an <literal role=\"hook\">incoming</literal> hook, for "
dongsheng@627 13322 "example as follows:"
dongsheng@627 13323 msgstr ""
dongsheng@627 13324
dongsheng@627 13325 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 13326 #: ../en/ch10-hook.xml:798
dongsheng@627 13327 msgid ""
dongsheng@627 13328 "Because of the specialised nature of this hook, and because Bugzilla was not "
dongsheng@627 13329 "written with this kind of integration in mind, configuring this hook is a "
dongsheng@627 13330 "somewhat involved process."
dongsheng@627 13331 msgstr ""
dongsheng@627 13332
dongsheng@627 13333 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 13334 #: ../en/ch10-hook.xml:804
dongsheng@627 13335 msgid ""
dongsheng@627 13336 "Before you begin, you must install the MySQL bindings for Python on the host"
dongsheng@627 13337 "(s) where you'll be running the hook. If this is not available as a binary "
dongsheng@627 13338 "package for your system, you can download it from <citation>web:mysql-python</"
dongsheng@627 13339 "citation>."
dongsheng@627 13340 msgstr ""
dongsheng@627 13341
dongsheng@627 13342 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 13343 #: ../en/ch10-hook.xml:811
dongsheng@627 13344 msgid ""
dongsheng@627 13345 "Configuration information for this hook lives in the <literal role=\"rc-"
dongsheng@650 13346 "bugzilla\">bugzilla</literal> section of your <filename role=\"special\">~/."
dongsheng@627 13347 "hgrc</filename>."
dongsheng@627 13348 msgstr ""
dongsheng@627 13349
dongsheng@627 13350 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@714 13351 #: ../en/ch10-hook.xml:816
dongsheng@627 13352 msgid ""
dongsheng@627 13353 "<envar role=\"rc-item-bugzilla\">version</envar>: The version of Bugzilla "
dongsheng@627 13354 "installed on the server. The database schema that Bugzilla uses changes "
dongsheng@714 13355 "occasionally, so this hook has to know exactly which schema to use."
dongsheng@627 13356 msgstr ""
dongsheng@627 13357
dongsheng@627 13358 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@714 13359 #: ../en/ch10-hook.xml:822
dongsheng@627 13360 msgid ""
dongsheng@627 13361 "<envar role=\"rc-item-bugzilla\">host</envar>: The hostname of the MySQL "
dongsheng@627 13362 "server that stores your Bugzilla data. The database must be configured to "
dongsheng@627 13363 "allow connections from whatever host you are running the <literal role=\"hook"
dongsheng@627 13364 "\">bugzilla</literal> hook on."
dongsheng@627 13365 msgstr ""
dongsheng@627 13366
dongsheng@627 13367 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@714 13368 #: ../en/ch10-hook.xml:829
dongsheng@627 13369 msgid ""
dongsheng@627 13370 "<envar role=\"rc-item-bugzilla\">user</envar>: The username with which to "
dongsheng@627 13371 "connect to the MySQL server. The database must be configured to allow this "
dongsheng@627 13372 "user to connect from whatever host you are running the <literal role=\"hook"
dongsheng@627 13373 "\">bugzilla</literal> hook on. This user must be able to access and modify "
dongsheng@627 13374 "Bugzilla tables. The default value of this item is <literal>bugs</literal>, "
dongsheng@627 13375 "which is the standard name of the Bugzilla user in a MySQL database."
dongsheng@627 13376 msgstr ""
dongsheng@627 13377
dongsheng@627 13378 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@714 13379 #: ../en/ch10-hook.xml:840
dongsheng@627 13380 msgid ""
dongsheng@627 13381 "<envar role=\"rc-item-bugzilla\">password</envar>: The MySQL password for the "
dongsheng@627 13382 "user you configured above. This is stored as plain text, so you should make "
dongsheng@650 13383 "sure that unauthorised users cannot read the <filename role=\"special\">~/."
dongsheng@650 13384 "hgrc</filename> file where you store this information."
dongsheng@627 13385 msgstr ""
dongsheng@627 13386
dongsheng@627 13387 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@714 13388 #: ../en/ch10-hook.xml:849
dongsheng@627 13389 msgid ""
dongsheng@627 13390 "<envar role=\"rc-item-bugzilla\">db</envar>: The name of the Bugzilla "
dongsheng@627 13391 "database on the MySQL server. The default value of this item is "
dongsheng@627 13392 "<literal>bugs</literal>, which is the standard name of the MySQL database "
dongsheng@627 13393 "where Bugzilla stores its data."
dongsheng@627 13394 msgstr ""
dongsheng@627 13395
dongsheng@627 13396 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@714 13397 #: ../en/ch10-hook.xml:856
dongsheng@627 13398 msgid ""
dongsheng@627 13399 "<envar role=\"rc-item-bugzilla\">notify</envar>: If you want Bugzilla to send "
dongsheng@627 13400 "out a notification email to subscribers after this hook has added a comment "
dongsheng@627 13401 "to a bug, you will need this hook to run a command whenever it updates the "
dongsheng@627 13402 "database. The command to run depends on where you have installed Bugzilla, "
dongsheng@627 13403 "but it will typically look something like this, if you have Bugzilla "
dongsheng@627 13404 "installed in <filename class=\"directory\">/var/www/html/bugzilla</filename>:"
dongsheng@627 13405 msgstr ""
dongsheng@627 13406
dongsheng@627 13407 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@714 13408 #: ../en/ch10-hook.xml:869
dongsheng@627 13409 msgid ""
dongsheng@627 13410 "The Bugzilla <literal>processmail</literal> program expects to be given a bug "
dongsheng@627 13411 "ID (the hook replaces <quote><literal>%s</literal></quote> with the bug ID) "
dongsheng@627 13412 "and an email address. It also expects to be able to write to some files in "
dongsheng@627 13413 "the directory that it runs in. If Bugzilla and this hook are not installed "
dongsheng@627 13414 "on the same machine, you will need to find a way to run <literal>processmail</"
dongsheng@627 13415 "literal> on the server where Bugzilla is installed."
dongsheng@627 13416 msgstr ""
dongsheng@627 13417
dongsheng@627 13418 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
dongsheng@714 13419 #: ../en/ch10-hook.xml:884
dongsheng@627 13420 msgid "Mapping committer names to Bugzilla user names"
dongsheng@635 13421 msgstr "提交者的名称与 Bugzilla 用户名称的映射"
dongsheng@627 13422
dongsheng@627 13423 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 13424 #: ../en/ch10-hook.xml:886
dongsheng@627 13425 msgid ""
dongsheng@627 13426 "By default, the <literal role=\"hg-ext\">bugzilla</literal> hook tries to use "
dongsheng@627 13427 "the email address of a changeset's committer as the Bugzilla user name with "
dongsheng@627 13428 "which to update a bug. If this does not suit your needs, you can map "
dongsheng@627 13429 "committer email addresses to Bugzilla user names using a <literal role=\"rc-"
dongsheng@627 13430 "usermap\">usermap</literal> section."
dongsheng@627 13431 msgstr ""
dongsheng@627 13432
dongsheng@627 13433 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 13434 #: ../en/ch10-hook.xml:895
dongsheng@627 13435 msgid ""
dongsheng@627 13436 "Each item in the <literal role=\"rc-usermap\">usermap</literal> section "
dongsheng@627 13437 "contains an email address on the left, and a Bugzilla user name on the right."
dongsheng@627 13438 msgstr ""
dongsheng@627 13439
dongsheng@627 13440 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 13441 #: ../en/ch10-hook.xml:902
dongsheng@627 13442 msgid ""
dongsheng@627 13443 "You can either keep the <literal role=\"rc-usermap\">usermap</literal> data "
dongsheng@627 13444 "in a normal <filename role=\"special\">~/.hgrc</filename>, or tell the "
dongsheng@627 13445 "<literal role=\"hg-ext\">bugzilla</literal> hook to read the information from "
dongsheng@627 13446 "an external <filename>usermap</filename> file. In the latter case, you can "
dongsheng@627 13447 "store <filename>usermap</filename> data by itself in (for example) a user-"
dongsheng@627 13448 "modifiable repository. This makes it possible to let your users maintain "
dongsheng@627 13449 "their own <envar role=\"rc-item-bugzilla\">usermap</envar> entries. The main "
dongsheng@650 13450 "<filename role=\"special\">~/.hgrc</filename> file might look like this:"
dongsheng@627 13451 msgstr ""
dongsheng@627 13452
dongsheng@627 13453 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 13454 #: ../en/ch10-hook.xml:918
dongsheng@627 13455 msgid ""
dongsheng@627 13456 "While the <filename>usermap</filename> file that it refers to might look like "
dongsheng@627 13457 "this:"
dongsheng@627 13458 msgstr ""
dongsheng@627 13459
dongsheng@627 13460 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
dongsheng@714 13461 #: ../en/ch10-hook.xml:926
dongsheng@627 13462 msgid "Configuring the text that gets added to a bug"
dongsheng@635 13463 msgstr "配置增加到问题中的正文"
dongsheng@627 13464
dongsheng@627 13465 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 13466 #: ../en/ch10-hook.xml:928
dongsheng@627 13467 msgid ""
dongsheng@627 13468 "You can configure the text that this hook adds as a comment; you specify it "
dongsheng@650 13469 "in the form of a Mercurial template. Several <filename role=\"special\">~/."
dongsheng@650 13470 "hgrc</filename> entries (still in the <literal role=\"rc-bugzilla\">bugzilla</"
songdongsheng@710 13471 "literal> section) control this behavior."
dongsheng@627 13472 msgstr ""
dongsheng@627 13473
dongsheng@627 13474 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@714 13475 #: ../en/ch10-hook.xml:935
dongsheng@627 13476 msgid ""
dongsheng@627 13477 "<literal>strip</literal>: The number of leading path elements to strip from a "
dongsheng@627 13478 "repository's path name to construct a partial path for a URL. For example, if "
dongsheng@627 13479 "the repositories on your server live under <filename class=\"directory\">/"
dongsheng@627 13480 "home/hg/repos</filename>, and you have a repository whose path is <filename "
dongsheng@627 13481 "class=\"directory\">/home/hg/repos/app/tests</filename>, then setting "
dongsheng@627 13482 "<literal>strip</literal> to <literal>4</literal> will give a partial path of "
dongsheng@627 13483 "<filename class=\"directory\">app/tests</filename>. The hook will make this "
dongsheng@627 13484 "partial path available when expanding a template, as <literal>webroot</"
dongsheng@627 13485 "literal>."
dongsheng@627 13486 msgstr ""
dongsheng@627 13487
dongsheng@627 13488 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@714 13489 #: ../en/ch10-hook.xml:949
dongsheng@627 13490 msgid ""
dongsheng@627 13491 "<literal>template</literal>: The text of the template to use. In addition to "
dongsheng@627 13492 "the usual changeset-related variables, this template can use <literal>hgweb</"
dongsheng@627 13493 "literal> (the value of the <literal>hgweb</literal> configuration item above) "
dongsheng@627 13494 "and <literal>webroot</literal> (the path constructed using <literal>strip</"
dongsheng@627 13495 "literal> above)."
dongsheng@627 13496 msgstr ""
dongsheng@627 13497
dongsheng@627 13498 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 13499 #: ../en/ch10-hook.xml:959
dongsheng@627 13500 msgid ""
dongsheng@627 13501 "In addition, you can add a <envar role=\"rc-item-web\">baseurl</envar> item "
dongsheng@627 13502 "to the <literal role=\"rc-web\">web</literal> section of your <filename role="
dongsheng@650 13503 "\"special\">~/.hgrc</filename>. The <literal role=\"hg-ext\">bugzilla</"
dongsheng@627 13504 "literal> hook will make this available when expanding a template, as the base "
dongsheng@627 13505 "string to use when constructing a URL that will let users browse from a "
dongsheng@627 13506 "Bugzilla comment to view a changeset. Example:"
dongsheng@627 13507 msgstr ""
dongsheng@627 13508
dongsheng@627 13509 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 13510 #: ../en/ch10-hook.xml:971
dongsheng@627 13511 msgid ""
dongsheng@627 13512 "Here is an example set of <literal role=\"hg-ext\">bugzilla</literal> hook "
dongsheng@627 13513 "config information."
dongsheng@627 13514 msgstr ""
dongsheng@627 13515
dongsheng@627 13516 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 13517 #: ../en/ch10-hook.xml:981
dongsheng@627 13518 msgid ""
dongsheng@627 13519 "The most common problems with configuring the <literal role=\"hg-ext"
dongsheng@627 13520 "\">bugzilla</literal> hook relate to running Bugzilla's "
dongsheng@627 13521 "<filename>processmail</filename> script and mapping committer names to user "
dongsheng@627 13522 "names."
dongsheng@627 13523 msgstr ""
dongsheng@627 13524
dongsheng@627 13525 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 13526 #: ../en/ch10-hook.xml:987
dongsheng@627 13527 msgid ""
songdongsheng@658 13528 "Recall from <xref linkend=\"sec:hook:bugzilla:config\"/> above that the user "
songdongsheng@658 13529 "that runs the Mercurial process on the server is also the one that will run "
songdongsheng@658 13530 "the <filename>processmail</filename> script. The <filename>processmail</"
songdongsheng@658 13531 "filename> script sometimes causes Bugzilla to write to files in its "
songdongsheng@658 13532 "configuration directory, and Bugzilla's configuration files are usually owned "
songdongsheng@658 13533 "by the user that your web server runs under."
dongsheng@627 13534 msgstr ""
dongsheng@627 13535
dongsheng@627 13536 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 13537 #: ../en/ch10-hook.xml:998
dongsheng@627 13538 msgid ""
dongsheng@627 13539 "You can cause <filename>processmail</filename> to be run with the suitable "
dongsheng@627 13540 "user's identity using the <command>sudo</command> command. Here is an "
dongsheng@627 13541 "example entry for a <filename>sudoers</filename> file."
dongsheng@627 13542 msgstr ""
dongsheng@627 13543
dongsheng@627 13544 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 13545 #: ../en/ch10-hook.xml:1005
dongsheng@627 13546 msgid ""
dongsheng@627 13547 "This allows the <literal>hg_user</literal> user to run a "
dongsheng@627 13548 "<filename>processmail-wrapper</filename> program under the identity of "
dongsheng@627 13549 "<literal>httpd_user</literal>."
dongsheng@627 13550 msgstr ""
dongsheng@627 13551
dongsheng@627 13552 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 13553 #: ../en/ch10-hook.xml:1010
dongsheng@627 13554 msgid ""
dongsheng@627 13555 "This indirection through a wrapper script is necessary, because "
dongsheng@627 13556 "<filename>processmail</filename> expects to be run with its current directory "
dongsheng@627 13557 "set to wherever you installed Bugzilla; you can't specify that kind of "
dongsheng@627 13558 "constraint in a <filename>sudoers</filename> file. The contents of the "
dongsheng@627 13559 "wrapper script are simple:"
dongsheng@627 13560 msgstr ""
dongsheng@627 13561
dongsheng@627 13562 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 13563 #: ../en/ch10-hook.xml:1019
dongsheng@627 13564 msgid ""
dongsheng@627 13565 "It doesn't seem to matter what email address you pass to "
dongsheng@627 13566 "<filename>processmail</filename>."
dongsheng@627 13567 msgstr ""
dongsheng@627 13568
dongsheng@627 13569 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 13570 #: ../en/ch10-hook.xml:1023
dongsheng@627 13571 msgid ""
dongsheng@627 13572 "If your <literal role=\"rc-usermap\">usermap</literal> is not set up "
dongsheng@627 13573 "correctly, users will see an error message from the <literal role=\"hg-ext"
dongsheng@627 13574 "\">bugzilla</literal> hook when they push changes to the server. The error "
dongsheng@627 13575 "message will look like this:"
dongsheng@627 13576 msgstr ""
dongsheng@627 13577
dongsheng@627 13578 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 13579 #: ../en/ch10-hook.xml:1030
dongsheng@627 13580 msgid ""
dongsheng@627 13581 "What this means is that the committer's address, <literal>john.q."
dongsheng@627 13582 "public@example.com</literal>, is not a valid Bugzilla user name, nor does it "
dongsheng@627 13583 "have an entry in your <literal role=\"rc-usermap\">usermap</literal> that "
dongsheng@627 13584 "maps it to a valid Bugzilla user name."
dongsheng@627 13585 msgstr ""
dongsheng@627 13586
dongsheng@627 13587 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 13588 #: ../en/ch10-hook.xml:1040
songdongsheng@668 13589 msgid ""
songdongsheng@668 13590 "<literal role=\"hg-ext\">notify</literal>&emdash;send email notifications"
dongsheng@661 13591 msgstr "<literal role=\"hg-ext\">notify</literal>—邮件通知"
dongsheng@627 13592
dongsheng@627 13593 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 13594 #: ../en/ch10-hook.xml:1043
dongsheng@627 13595 msgid ""
dongsheng@627 13596 "Although Mercurial's built-in web server provides RSS feeds of changes in "
dongsheng@627 13597 "every repository, many people prefer to receive change notifications via "
dongsheng@627 13598 "email. The <literal role=\"hg-ext\">notify</literal> hook lets you send out "
dongsheng@627 13599 "notifications to a set of email addresses whenever changesets arrive that "
dongsheng@627 13600 "those subscribers are interested in."
dongsheng@627 13601 msgstr ""
dongsheng@627 13602
dongsheng@627 13603 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 13604 #: ../en/ch10-hook.xml:1051
dongsheng@627 13605 msgid ""
dongsheng@627 13606 "As with the <literal role=\"hg-ext\">bugzilla</literal> hook, the <literal "
dongsheng@627 13607 "role=\"hg-ext\">notify</literal> hook is template-driven, so you can "
dongsheng@627 13608 "customise the contents of the notification messages that it sends."
dongsheng@627 13609 msgstr ""
dongsheng@627 13610
dongsheng@627 13611 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 13612 #: ../en/ch10-hook.xml:1057
dongsheng@627 13613 msgid ""
dongsheng@627 13614 "By default, the <literal role=\"hg-ext\">notify</literal> hook includes a "
dongsheng@627 13615 "diff of every changeset that it sends out; you can limit the size of the "
dongsheng@627 13616 "diff, or turn this feature off entirely. It is useful for letting "
dongsheng@627 13617 "subscribers review changes immediately, rather than clicking to follow a URL."
dongsheng@627 13618 msgstr ""
dongsheng@627 13619
dongsheng@627 13620 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
dongsheng@714 13621 #: ../en/ch10-hook.xml:1065
dongsheng@627 13622 msgid "Configuring the <literal role=\"hg-ext\">notify</literal> hook"
dongsheng@635 13623 msgstr "配置 <literal role=\"hg-ext\">notify</literal> 钩子"
dongsheng@627 13624
dongsheng@627 13625 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 13626 #: ../en/ch10-hook.xml:1068
dongsheng@627 13627 msgid ""
dongsheng@627 13628 "You can set up the <literal role=\"hg-ext\">notify</literal> hook to send one "
dongsheng@627 13629 "email message per incoming changeset, or one per incoming group of changesets "
dongsheng@627 13630 "(all those that arrived in a single pull or push)."
dongsheng@627 13631 msgstr ""
dongsheng@627 13632
dongsheng@627 13633 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 13634 #: ../en/ch10-hook.xml:1080
dongsheng@627 13635 msgid ""
dongsheng@627 13636 "Configuration information for this hook lives in the <literal role=\"rc-notify"
dongsheng@650 13637 "\">notify</literal> section of a <filename role=\"special\">~/.hgrc</"
dongsheng@650 13638 "filename> file."
dongsheng@627 13639 msgstr ""
dongsheng@627 13640
dongsheng@627 13641 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@714 13642 #: ../en/ch10-hook.xml:1085
dongsheng@627 13643 msgid ""
dongsheng@627 13644 "<envar role=\"rc-item-notify\">test</envar>: By default, this hook does not "
dongsheng@627 13645 "send out email at all; instead, it prints the message that it "
dongsheng@627 13646 "<emphasis>would</emphasis> send. Set this item to <literal>false</literal> "
dongsheng@627 13647 "to allow email to be sent. The reason that sending of email is turned off by "
dongsheng@627 13648 "default is that it takes several tries to configure this extension exactly as "
dongsheng@627 13649 "you would like, and it would be bad form to spam subscribers with a number of "
dongsheng@627 13650 "<quote>broken</quote> notifications while you debug your configuration."
dongsheng@627 13651 msgstr ""
dongsheng@627 13652
dongsheng@627 13653 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@714 13654 #: ../en/ch10-hook.xml:1097
dongsheng@627 13655 msgid ""
dongsheng@627 13656 "<envar role=\"rc-item-notify\">config</envar>: The path to a configuration "
dongsheng@627 13657 "file that contains subscription information. This is kept separate from the "
dongsheng@650 13658 "main <filename role=\"special\">~/.hgrc</filename> so that you can maintain "
dongsheng@627 13659 "it in a repository of its own. People can then clone that repository, update "
dongsheng@627 13660 "their subscriptions, and push the changes back to your server."
dongsheng@627 13661 msgstr ""
dongsheng@627 13662
dongsheng@627 13663 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@714 13664 #: ../en/ch10-hook.xml:1106
dongsheng@627 13665 msgid ""
dongsheng@627 13666 "<envar role=\"rc-item-notify\">strip</envar>: The number of leading path "
dongsheng@627 13667 "separator characters to strip from a repository's path, when deciding whether "
dongsheng@627 13668 "a repository has subscribers. For example, if the repositories on your "
dongsheng@627 13669 "server live in <filename class=\"directory\">/home/hg/repos</filename>, and "
dongsheng@627 13670 "<literal role=\"hg-ext\">notify</literal> is considering a repository named "
dongsheng@627 13671 "<filename class=\"directory\">/home/hg/repos/shared/test</filename>, setting "
dongsheng@627 13672 "<envar role=\"rc-item-notify\">strip</envar> to <literal>4</literal> will "
dongsheng@627 13673 "cause <literal role=\"hg-ext\">notify</literal> to trim the path it considers "
dongsheng@627 13674 "down to <filename class=\"directory\">shared/test</filename>, and it will "
dongsheng@627 13675 "match subscribers against that."
dongsheng@627 13676 msgstr ""
dongsheng@627 13677
dongsheng@627 13678 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@714 13679 #: ../en/ch10-hook.xml:1123
dongsheng@627 13680 msgid ""
dongsheng@627 13681 "<envar role=\"rc-item-notify\">template</envar>: The template text to use "
dongsheng@627 13682 "when sending messages. This specifies both the contents of the message "
dongsheng@627 13683 "header and its body."
dongsheng@627 13684 msgstr ""
dongsheng@627 13685
dongsheng@627 13686 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@714 13687 #: ../en/ch10-hook.xml:1129
dongsheng@627 13688 msgid ""
dongsheng@627 13689 "<envar role=\"rc-item-notify\">maxdiff</envar>: The maximum number of lines "
dongsheng@627 13690 "of diff data to append to the end of a message. If a diff is longer than "
dongsheng@627 13691 "this, it is truncated. By default, this is set to 300. Set this to "
dongsheng@627 13692 "<literal>0</literal> to omit diffs from notification emails."
dongsheng@627 13693 msgstr ""
dongsheng@627 13694
dongsheng@627 13695 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@714 13696 #: ../en/ch10-hook.xml:1138
dongsheng@627 13697 msgid ""
dongsheng@627 13698 "<envar role=\"rc-item-notify\">sources</envar>: A list of sources of "
dongsheng@627 13699 "changesets to consider. This lets you limit <literal role=\"hg-ext\">notify</"
dongsheng@627 13700 "literal> to only sending out email about changes that remote users pushed "
songdongsheng@658 13701 "into this repository via a server, for example. See <xref linkend=\"sec:hook:"
songdongsheng@658 13702 "sources\"/> for the sources you can specify here."
dongsheng@627 13703 msgstr ""
dongsheng@627 13704
dongsheng@627 13705 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 13706 #: ../en/ch10-hook.xml:1149
dongsheng@627 13707 msgid ""
dongsheng@627 13708 "If you set the <envar role=\"rc-item-web\">baseurl</envar> item in the "
dongsheng@627 13709 "<literal role=\"rc-web\">web</literal> section, you can use it in a template; "
dongsheng@627 13710 "it will be available as <literal>webroot</literal>."
dongsheng@627 13711 msgstr ""
dongsheng@627 13712
dongsheng@627 13713 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 13714 #: ../en/ch10-hook.xml:1155
dongsheng@627 13715 msgid ""
dongsheng@627 13716 "Here is an example set of <literal role=\"hg-ext\">notify</literal> "
dongsheng@627 13717 "configuration information."
dongsheng@627 13718 msgstr ""
dongsheng@627 13719
dongsheng@627 13720 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 13721 #: ../en/ch10-hook.xml:1161
dongsheng@627 13722 msgid "This will produce a message that looks like the following:"
dongsheng@627 13723 msgstr ""
dongsheng@627 13724
dongsheng@627 13725 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 13726 #: ../en/ch10-hook.xml:1171
dongsheng@627 13727 msgid ""
dongsheng@627 13728 "Do not forget that by default, the <literal role=\"hg-ext\">notify</literal> "
dongsheng@627 13729 "extension <emphasis>will not send any mail</emphasis> until you explicitly "
dongsheng@627 13730 "configure it to do so, by setting <envar role=\"rc-item-notify\">test</envar> "
dongsheng@627 13731 "to <literal>false</literal>. Until you do that, it simply prints the message "
dongsheng@627 13732 "it <emphasis>would</emphasis> send."
dongsheng@627 13733 msgstr ""
dongsheng@627 13734
dongsheng@627 13735 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 13736 #: ../en/ch10-hook.xml:1183
dongsheng@627 13737 msgid "Information for writers of hooks"
dongsheng@635 13738 msgstr "编写钩子的信息"
dongsheng@627 13739
dongsheng@627 13740 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 13741 #: ../en/ch10-hook.xml:1186
dongsheng@627 13742 msgid "In-process hook execution"
dongsheng@635 13743 msgstr "进程内钩子的执行"
dongsheng@627 13744
dongsheng@627 13745 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 13746 #: ../en/ch10-hook.xml:1188
dongsheng@627 13747 msgid "An in-process hook is called with arguments of the following form:"
dongsheng@627 13748 msgstr ""
dongsheng@627 13749
dongsheng@627 13750 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 13751 #: ../en/ch10-hook.xml:1192
dongsheng@627 13752 msgid ""
dongsheng@627 13753 "The <literal>ui</literal> parameter is a <literal role=\"py-mod-mercurial.ui"
dongsheng@627 13754 "\">ui</literal> object. The <literal>repo</literal> parameter is a <literal "
dongsheng@627 13755 "role=\"py-mod-mercurial.localrepo\">localrepository</literal> object. The "
dongsheng@627 13756 "names and values of the <literal>**kwargs</literal> parameters depend on the "
dongsheng@627 13757 "hook being invoked, with the following common features:"
dongsheng@627 13758 msgstr ""
dongsheng@627 13759
dongsheng@627 13760 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 13761 #: ../en/ch10-hook.xml:1201
dongsheng@627 13762 msgid ""
dongsheng@627 13763 "If a parameter is named <literal>node</literal> or <literal>parentN</"
dongsheng@627 13764 "literal>, it will contain a hexadecimal changeset ID. The empty string is "
dongsheng@627 13765 "used to represent <quote>null changeset ID</quote> instead of a string of "
dongsheng@627 13766 "zeroes."
dongsheng@627 13767 msgstr ""
dongsheng@627 13768
dongsheng@627 13769 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 13770 #: ../en/ch10-hook.xml:1208
dongsheng@627 13771 msgid ""
dongsheng@627 13772 "If a parameter is named <literal>url</literal>, it will contain the URL of a "
dongsheng@627 13773 "remote repository, if that can be determined."
dongsheng@627 13774 msgstr ""
dongsheng@627 13775
dongsheng@627 13776 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 13777 #: ../en/ch10-hook.xml:1213
dongsheng@627 13778 msgid ""
dongsheng@627 13779 "Boolean-valued parameters are represented as Python <literal>bool</literal> "
dongsheng@627 13780 "objects."
dongsheng@627 13781 msgstr ""
dongsheng@627 13782
dongsheng@627 13783 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 13784 #: ../en/ch10-hook.xml:1218
dongsheng@627 13785 msgid ""
dongsheng@627 13786 "An in-process hook is called without a change to the process's working "
dongsheng@627 13787 "directory (unlike external hooks, which are run in the root of the "
dongsheng@627 13788 "repository). It must not change the process's working directory, or it will "
dongsheng@627 13789 "cause any calls it makes into the Mercurial API to fail."
dongsheng@627 13790 msgstr ""
dongsheng@627 13791
dongsheng@627 13792 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 13793 #: ../en/ch10-hook.xml:1225
dongsheng@627 13794 msgid ""
dongsheng@627 13795 "If a hook returns a boolean <quote>false</quote> value, it is considered to "
dongsheng@627 13796 "have succeeded. If it returns a boolean <quote>true</quote> value or raises "
dongsheng@627 13797 "an exception, it is considered to have failed. A useful way to think of the "
dongsheng@627 13798 "calling convention is <quote>tell me if you fail</quote>."
dongsheng@627 13799 msgstr ""
dongsheng@627 13800
dongsheng@627 13801 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 13802 #: ../en/ch10-hook.xml:1232
dongsheng@627 13803 msgid ""
dongsheng@627 13804 "Note that changeset IDs are passed into Python hooks as hexadecimal strings, "
dongsheng@627 13805 "not the binary hashes that Mercurial's APIs normally use. To convert a hash "
dongsheng@650 13806 "from hex to binary, use the <literal>bin</literal> function."
dongsheng@650 13807 msgstr ""
dongsheng@650 13808
dongsheng@650 13809 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 13810 #: ../en/ch10-hook.xml:1240
dongsheng@627 13811 msgid "External hook execution"
dongsheng@635 13812 msgstr "外部钩子的执行"
dongsheng@627 13813
dongsheng@627 13814 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 13815 #: ../en/ch10-hook.xml:1242
dongsheng@627 13816 msgid ""
dongsheng@627 13817 "An external hook is passed to the shell of the user running Mercurial. "
dongsheng@627 13818 "Features of that shell, such as variable substitution and command "
dongsheng@627 13819 "redirection, are available. The hook is run in the root directory of the "
dongsheng@627 13820 "repository (unlike in-process hooks, which are run in the same directory that "
dongsheng@627 13821 "Mercurial was run in)."
dongsheng@627 13822 msgstr ""
dongsheng@627 13823
dongsheng@627 13824 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 13825 #: ../en/ch10-hook.xml:1250
dongsheng@627 13826 msgid ""
dongsheng@627 13827 "Hook parameters are passed to the hook as environment variables. Each "
dongsheng@627 13828 "environment variable's name is converted in upper case and prefixed with the "
dongsheng@627 13829 "string <quote><literal>HG_</literal></quote>. For example, if the name of a "
dongsheng@627 13830 "parameter is <quote><literal>node</literal></quote>, the name of the "
dongsheng@627 13831 "environment variable representing that parameter will be "
dongsheng@627 13832 "<quote><literal>HG_NODE</literal></quote>."
dongsheng@627 13833 msgstr ""
dongsheng@627 13834
dongsheng@627 13835 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 13836 #: ../en/ch10-hook.xml:1259
dongsheng@627 13837 msgid ""
dongsheng@627 13838 "A boolean parameter is represented as the string <quote><literal>1</literal></"
dongsheng@627 13839 "quote> for <quote>true</quote>, <quote><literal>0</literal></quote> for "
dongsheng@627 13840 "<quote>false</quote>. If an environment variable is named <envar>HG_NODE</"
dongsheng@627 13841 "envar>, <envar>HG_PARENT1</envar> or <envar>HG_PARENT2</envar>, it contains a "
dongsheng@627 13842 "changeset ID represented as a hexadecimal string. The empty string is used "
dongsheng@627 13843 "to represent <quote>null changeset ID</quote> instead of a string of zeroes. "
dongsheng@627 13844 "If an environment variable is named <envar>HG_URL</envar>, it will contain "
dongsheng@627 13845 "the URL of a remote repository, if that can be determined."
dongsheng@627 13846 msgstr ""
dongsheng@627 13847
dongsheng@627 13848 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 13849 #: ../en/ch10-hook.xml:1271
dongsheng@627 13850 msgid ""
dongsheng@627 13851 "If a hook exits with a status of zero, it is considered to have succeeded. "
dongsheng@627 13852 "If it exits with a non-zero status, it is considered to have failed."
dongsheng@627 13853 msgstr ""
dongsheng@627 13854
dongsheng@627 13855 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 13856 #: ../en/ch10-hook.xml:1278
dongsheng@627 13857 msgid "Finding out where changesets come from"
dongsheng@635 13858 msgstr "检查修改集来自何处"
dongsheng@627 13859
dongsheng@627 13860 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 13861 #: ../en/ch10-hook.xml:1280
dongsheng@627 13862 msgid ""
dongsheng@627 13863 "A hook that involves the transfer of changesets between a local repository "
dongsheng@627 13864 "and another may be able to find out information about the <quote>far side</"
dongsheng@627 13865 "quote>. Mercurial knows <emphasis>how</emphasis> changes are being "
dongsheng@627 13866 "transferred, and in many cases <emphasis>where</emphasis> they are being "
dongsheng@627 13867 "transferred to or from."
dongsheng@627 13868 msgstr ""
dongsheng@627 13869
dongsheng@627 13870 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
dongsheng@714 13871 #: ../en/ch10-hook.xml:1289
dongsheng@627 13872 msgid "Sources of changesets"
dongsheng@635 13873 msgstr "修改集的来源"
dongsheng@627 13874
dongsheng@627 13875 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 13876 #: ../en/ch10-hook.xml:1291
dongsheng@627 13877 msgid ""
dongsheng@627 13878 "Mercurial will tell a hook what means are, or were, used to transfer "
dongsheng@627 13879 "changesets between repositories. This is provided by Mercurial in a Python "
dongsheng@627 13880 "parameter named <literal>source</literal>, or an environment variable named "
dongsheng@627 13881 "<envar>HG_SOURCE</envar>."
dongsheng@627 13882 msgstr ""
dongsheng@627 13883
dongsheng@627 13884 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@714 13885 #: ../en/ch10-hook.xml:1299
dongsheng@627 13886 msgid ""
dongsheng@627 13887 "<literal>serve</literal>: Changesets are transferred to or from a remote "
dongsheng@627 13888 "repository over http or ssh."
dongsheng@627 13889 msgstr ""
dongsheng@627 13890
dongsheng@627 13891 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@714 13892 #: ../en/ch10-hook.xml:1304
dongsheng@627 13893 msgid ""
dongsheng@627 13894 "<literal>pull</literal>: Changesets are being transferred via a pull from one "
dongsheng@627 13895 "repository into another."
dongsheng@627 13896 msgstr ""
dongsheng@627 13897
dongsheng@627 13898 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@714 13899 #: ../en/ch10-hook.xml:1309
dongsheng@627 13900 msgid ""
dongsheng@627 13901 "<literal>push</literal>: Changesets are being transferred via a push from one "
dongsheng@627 13902 "repository into another."
dongsheng@627 13903 msgstr ""
dongsheng@627 13904
dongsheng@627 13905 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@714 13906 #: ../en/ch10-hook.xml:1314
dongsheng@627 13907 msgid ""
dongsheng@627 13908 "<literal>bundle</literal>: Changesets are being transferred to or from a "
dongsheng@627 13909 "bundle."
dongsheng@627 13910 msgstr ""
dongsheng@627 13911
dongsheng@627 13912 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
dongsheng@714 13913 #: ../en/ch10-hook.xml:1321
songdongsheng@668 13914 msgid "Where changes are going&emdash;remote repository URLs"
dongsheng@661 13915 msgstr "修改集要到哪里—远程版本库的地址"
dongsheng@627 13916
dongsheng@627 13917 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 13918 #: ../en/ch10-hook.xml:1324
dongsheng@627 13919 msgid ""
dongsheng@627 13920 "When possible, Mercurial will tell a hook the location of the <quote>far "
dongsheng@627 13921 "side</quote> of an activity that transfers changeset data between "
dongsheng@627 13922 "repositories. This is provided by Mercurial in a Python parameter named "
dongsheng@627 13923 "<literal>url</literal>, or an environment variable named <envar>HG_URL</"
dongsheng@627 13924 "envar>."
dongsheng@627 13925 msgstr ""
dongsheng@627 13926
dongsheng@627 13927 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@714 13928 #: ../en/ch10-hook.xml:1332
dongsheng@627 13929 msgid ""
dongsheng@627 13930 "This information is not always known. If a hook is invoked in a repository "
dongsheng@627 13931 "that is being served via http or ssh, Mercurial cannot tell where the remote "
dongsheng@627 13932 "repository is, but it may know where the client is connecting from. In such "
dongsheng@627 13933 "cases, the URL will take one of the following forms:"
dongsheng@627 13934 msgstr ""
dongsheng@627 13935
dongsheng@627 13936 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@714 13937 #: ../en/ch10-hook.xml:1339
dongsheng@627 13938 msgid ""
songdongsheng@668 13939 "<literal>remote:ssh:1.2.3.4</literal>&emdash;remote ssh client, at the IP "
songdongsheng@668 13940 "address <literal>1.2.3.4</literal>."
dongsheng@627 13941 msgstr ""
dongsheng@627 13942
dongsheng@627 13943 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@714 13944 #: ../en/ch10-hook.xml:1344
dongsheng@627 13945 msgid ""
songdongsheng@668 13946 "<literal>remote:http:1.2.3.4</literal>&emdash;remote http client, at the IP "
songdongsheng@668 13947 "address <literal>1.2.3.4</literal>. If the client is using SSL, this will be "
songdongsheng@668 13948 "of the form <literal>remote:https:1.2.3.4</literal>."
dongsheng@627 13949 msgstr ""
dongsheng@627 13950
dongsheng@627 13951 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@714 13952 #: ../en/ch10-hook.xml:1351
songdongsheng@668 13953 msgid "Empty&emdash;no information could be discovered about the remote client."
dongsheng@627 13954 msgstr ""
dongsheng@627 13955
dongsheng@627 13956 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 13957 #: ../en/ch10-hook.xml:1359
dongsheng@627 13958 msgid "Hook reference"
dongsheng@635 13959 msgstr "钩子参考"
dongsheng@627 13960
dongsheng@627 13961 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 13962 #: ../en/ch10-hook.xml:1362
songdongsheng@668 13963 msgid ""
songdongsheng@668 13964 "<literal role=\"hook\">changegroup</literal>&emdash;after remote changesets "
songdongsheng@668 13965 "added"
dongsheng@661 13966 msgstr "<literal role=\"hook\">changegroup</literal>—增加远程修改集之后"
dongsheng@627 13967
dongsheng@627 13968 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 13969 #: ../en/ch10-hook.xml:1365
dongsheng@627 13970 msgid ""
dongsheng@627 13971 "This hook is run after a group of pre-existing changesets has been added to "
dongsheng@627 13972 "the repository, for example via a <command role=\"hg-cmd\">hg pull</command> "
dongsheng@627 13973 "or <command role=\"hg-cmd\">hg unbundle</command>. This hook is run once per "
dongsheng@627 13974 "operation that added one or more changesets. This is in contrast to the "
dongsheng@627 13975 "<literal role=\"hook\">incoming</literal> hook, which is run once per "
dongsheng@627 13976 "changeset, regardless of whether the changesets arrive in a group."
dongsheng@627 13977 msgstr ""
dongsheng@627 13978
dongsheng@627 13979 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 13980 #: ../en/ch10-hook.xml:1375
dongsheng@627 13981 msgid ""
dongsheng@627 13982 "Some possible uses for this hook include kicking off an automated build or "
dongsheng@627 13983 "test of the added changesets, updating a bug database, or notifying "
dongsheng@627 13984 "subscribers that a repository contains new changes."
dongsheng@627 13985 msgstr ""
dongsheng@627 13986
dongsheng@627 13987 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 13988 #: ../en/ch10-hook.xml:1381 ../en/ch10-hook.xml:1421 ../en/ch10-hook.xml:1465
dongsheng@714 13989 #: ../en/ch10-hook.xml:1507 ../en/ch10-hook.xml:1562 ../en/ch10-hook.xml:1602
dongsheng@714 13990 #: ../en/ch10-hook.xml:1638 ../en/ch10-hook.xml:1672 ../en/ch10-hook.xml:1736
dongsheng@714 13991 #: ../en/ch10-hook.xml:1794 ../en/ch10-hook.xml:1830 ../en/ch10-hook.xml:1857
dongsheng@627 13992 msgid "Parameters to this hook:"
dongsheng@627 13993 msgstr ""
dongsheng@627 13994
dongsheng@627 13995 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 13996 #: ../en/ch10-hook.xml:1384 ../en/ch10-hook.xml:1739
dongsheng@627 13997 msgid ""
dongsheng@627 13998 "<literal>node</literal>: A changeset ID. The changeset ID of the first "
dongsheng@627 13999 "changeset in the group that was added. All changesets between this and "
dongsheng@650 14000 "<literal role=\"tag\">tip</literal>, inclusive, were added by a single "
dongsheng@650 14001 "<command role=\"hg-cmd\">hg pull</command>, <command role=\"hg-cmd\">hg push</"
dongsheng@650 14002 "command> or <command role=\"hg-cmd\">hg unbundle</command>."
dongsheng@627 14003 msgstr ""
dongsheng@627 14004
dongsheng@627 14005 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 14006 #: ../en/ch10-hook.xml:1393 ../en/ch10-hook.xml:1472 ../en/ch10-hook.xml:1565
dongsheng@714 14007 #: ../en/ch10-hook.xml:1749
dongsheng@627 14008 msgid ""
songdongsheng@658 14009 "<literal>source</literal>: A string. The source of these changes. See <xref "
songdongsheng@658 14010 "linkend=\"sec:hook:sources\"/> for details."
dongsheng@627 14011 msgstr ""
dongsheng@627 14012
dongsheng@627 14013 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 14014 #: ../en/ch10-hook.xml:1398 ../en/ch10-hook.xml:1477 ../en/ch10-hook.xml:1528
dongsheng@714 14015 #: ../en/ch10-hook.xml:1570 ../en/ch10-hook.xml:1651 ../en/ch10-hook.xml:1754
dongsheng@627 14016 msgid ""
dongsheng@627 14017 "<literal>url</literal>: A URL. The location of the remote repository, if "
songdongsheng@658 14018 "known. See <xref linkend=\"sec:hook:url\"/> for more information."
songdongsheng@658 14019 msgstr ""
songdongsheng@658 14020
songdongsheng@658 14021 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 14022 #: ../en/ch10-hook.xml:1404
songdongsheng@658 14023 msgid ""
songdongsheng@658 14024 "See also: <literal role=\"hook\">incoming</literal> (<xref linkend=\"sec:hook:"
songdongsheng@658 14025 "incoming\"/>), <literal role=\"hook\">prechangegroup</literal> (<xref linkend="
songdongsheng@658 14026 "\"sec:hook:prechangegroup\"/>), <literal role=\"hook\">pretxnchangegroup</"
songdongsheng@658 14027 "literal> (<xref linkend=\"sec:hook:pretxnchangegroup\"/>)"
dongsheng@627 14028 msgstr ""
dongsheng@627 14029
dongsheng@627 14030 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 14031 #: ../en/ch10-hook.xml:1415
songdongsheng@668 14032 msgid ""
songdongsheng@668 14033 "<literal role=\"hook\">commit</literal>&emdash;after a new changeset is "
songdongsheng@668 14034 "created"
dongsheng@661 14035 msgstr "<literal role=\"hook\">commit</literal>—创建新修改集之后"
dongsheng@627 14036
dongsheng@627 14037 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 14038 #: ../en/ch10-hook.xml:1418
dongsheng@627 14039 msgid "This hook is run after a new changeset has been created."
dongsheng@627 14040 msgstr ""
dongsheng@627 14041
dongsheng@627 14042 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 14043 #: ../en/ch10-hook.xml:1424 ../en/ch10-hook.xml:1797
dongsheng@627 14044 msgid ""
dongsheng@627 14045 "<literal>node</literal>: A changeset ID. The changeset ID of the newly "
dongsheng@627 14046 "committed changeset."
dongsheng@627 14047 msgstr ""
dongsheng@627 14048
dongsheng@627 14049 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 14050 #: ../en/ch10-hook.xml:1428 ../en/ch10-hook.xml:1801
dongsheng@627 14051 msgid ""
dongsheng@627 14052 "<literal>parent1</literal>: A changeset ID. The changeset ID of the first "
dongsheng@627 14053 "parent of the newly committed changeset."
dongsheng@627 14054 msgstr ""
dongsheng@627 14055
dongsheng@627 14056 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 14057 #: ../en/ch10-hook.xml:1433 ../en/ch10-hook.xml:1806
dongsheng@627 14058 msgid ""
dongsheng@627 14059 "<literal>parent2</literal>: A changeset ID. The changeset ID of the second "
dongsheng@627 14060 "parent of the newly committed changeset."
dongsheng@627 14061 msgstr ""
dongsheng@627 14062
dongsheng@627 14063 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 14064 #: ../en/ch10-hook.xml:1439
songdongsheng@658 14065 msgid ""
songdongsheng@658 14066 "See also: <literal role=\"hook\">precommit</literal> (<xref linkend=\"sec:"
songdongsheng@658 14067 "hook:precommit\"/>), <literal role=\"hook\">pretxncommit</literal> (<xref "
songdongsheng@658 14068 "linkend=\"sec:hook:pretxncommit\"/>)"
dongsheng@627 14069 msgstr ""
dongsheng@627 14070
dongsheng@627 14071 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 14072 #: ../en/ch10-hook.xml:1448
songdongsheng@668 14073 msgid ""
songdongsheng@668 14074 "<literal role=\"hook\">incoming</literal>&emdash;after one remote changeset "
songdongsheng@668 14075 "is added"
dongsheng@661 14076 msgstr "<literal role=\"hook\">incoming</literal>—增加远程修改集之后"
dongsheng@627 14077
dongsheng@627 14078 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 14079 #: ../en/ch10-hook.xml:1451
dongsheng@627 14080 msgid ""
dongsheng@627 14081 "This hook is run after a pre-existing changeset has been added to the "
dongsheng@627 14082 "repository, for example via a <command role=\"hg-cmd\">hg push</command>. If "
dongsheng@627 14083 "a group of changesets was added in a single operation, this hook is called "
dongsheng@627 14084 "once for each added changeset."
dongsheng@627 14085 msgstr ""
dongsheng@627 14086
dongsheng@627 14087 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 14088 #: ../en/ch10-hook.xml:1458
dongsheng@627 14089 msgid ""
dongsheng@627 14090 "You can use this hook for the same purposes as the <literal role=\"hook"
songdongsheng@658 14091 "\">changegroup</literal> hook (<xref linkend=\"sec:hook:changegroup\"/>); "
songdongsheng@658 14092 "it's simply more convenient sometimes to run a hook once per group of "
dongsheng@627 14093 "changesets, while other times it's handier once per changeset."
dongsheng@627 14094 msgstr ""
dongsheng@627 14095
dongsheng@627 14096 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 14097 #: ../en/ch10-hook.xml:1468
dongsheng@627 14098 msgid ""
dongsheng@627 14099 "<literal>node</literal>: A changeset ID. The ID of the newly added changeset."
dongsheng@627 14100 msgstr ""
dongsheng@627 14101
dongsheng@627 14102 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 14103 #: ../en/ch10-hook.xml:1483
songdongsheng@658 14104 msgid ""
songdongsheng@658 14105 "See also: <literal role=\"hook\">changegroup</literal> (<xref linkend=\"sec:"
songdongsheng@658 14106 "hook:changegroup\"/>) <literal role=\"hook\">prechangegroup</literal> (<xref "
songdongsheng@658 14107 "linkend=\"sec:hook:prechangegroup\"/>), <literal role=\"hook"
songdongsheng@658 14108 "\">pretxnchangegroup</literal> (<xref linkend=\"sec:hook:pretxnchangegroup\"/"
songdongsheng@658 14109 ">)"
dongsheng@627 14110 msgstr ""
dongsheng@627 14111
dongsheng@627 14112 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 14113 #: ../en/ch10-hook.xml:1494
songdongsheng@668 14114 msgid ""
songdongsheng@668 14115 "<literal role=\"hook\">outgoing</literal>&emdash;after changesets are "
songdongsheng@668 14116 "propagated"
dongsheng@661 14117 msgstr "<literal role=\"hook\">outgoing</literal>—传播修改集之后"
dongsheng@627 14118
dongsheng@627 14119 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 14120 #: ../en/ch10-hook.xml:1497
dongsheng@627 14121 msgid ""
dongsheng@627 14122 "This hook is run after a group of changesets has been propagated out of this "
dongsheng@627 14123 "repository, for example by a <command role=\"hg-cmd\">hg push</command> or "
dongsheng@627 14124 "<command role=\"hg-cmd\">hg bundle</command> command."
dongsheng@627 14125 msgstr ""
dongsheng@627 14126
dongsheng@627 14127 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 14128 #: ../en/ch10-hook.xml:1503
dongsheng@627 14129 msgid ""
dongsheng@627 14130 "One possible use for this hook is to notify administrators that changes have "
dongsheng@627 14131 "been pulled."
dongsheng@627 14132 msgstr ""
dongsheng@627 14133
dongsheng@627 14134 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 14135 #: ../en/ch10-hook.xml:1510
dongsheng@627 14136 msgid ""
dongsheng@627 14137 "<literal>node</literal>: A changeset ID. The changeset ID of the first "
dongsheng@627 14138 "changeset of the group that was sent."
dongsheng@627 14139 msgstr ""
dongsheng@627 14140
dongsheng@627 14141 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 14142 #: ../en/ch10-hook.xml:1515
dongsheng@627 14143 msgid ""
dongsheng@627 14144 "<literal>source</literal>: A string. The source of the of the operation (see "
songdongsheng@658 14145 "<xref linkend=\"sec:hook:sources\"/>). If a remote client pulled changes "
songdongsheng@658 14146 "from this repository, <literal>source</literal> will be <literal>serve</"
songdongsheng@658 14147 "literal>. If the client that obtained changes from this repository was "
songdongsheng@658 14148 "local, <literal>source</literal> will be <literal>bundle</literal>, "
songdongsheng@658 14149 "<literal>pull</literal>, or <literal>push</literal>, depending on the "
songdongsheng@658 14150 "operation the client performed."
songdongsheng@658 14151 msgstr ""
songdongsheng@658 14152
songdongsheng@658 14153 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 14154 #: ../en/ch10-hook.xml:1534
songdongsheng@658 14155 msgid ""
songdongsheng@658 14156 "See also: <literal role=\"hook\">preoutgoing</literal> (<xref linkend=\"sec:"
songdongsheng@658 14157 "hook:preoutgoing\"/>)"
dongsheng@627 14158 msgstr ""
dongsheng@627 14159
dongsheng@627 14160 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 14161 #: ../en/ch10-hook.xml:1541
songdongsheng@668 14162 msgid ""
songdongsheng@668 14163 "<literal role=\"hook\">prechangegroup</literal>&emdash;before starting to add "
songdongsheng@668 14164 "remote changesets"
dongsheng@661 14165 msgstr "<literal role=\"hook\">prechangegroup</literal>—增加远程修改集之前"
dongsheng@627 14166
dongsheng@627 14167 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 14168 #: ../en/ch10-hook.xml:1545
dongsheng@627 14169 msgid ""
dongsheng@627 14170 "This controlling hook is run before Mercurial begins to add a group of "
dongsheng@627 14171 "changesets from another repository."
dongsheng@627 14172 msgstr ""
dongsheng@627 14173
dongsheng@627 14174 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 14175 #: ../en/ch10-hook.xml:1549
dongsheng@627 14176 msgid ""
dongsheng@627 14177 "This hook does not have any information about the changesets to be added, "
dongsheng@627 14178 "because it is run before transmission of those changesets is allowed to "
dongsheng@627 14179 "begin. If this hook fails, the changesets will not be transmitted."
dongsheng@627 14180 msgstr ""
dongsheng@627 14181
dongsheng@627 14182 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 14183 #: ../en/ch10-hook.xml:1555
dongsheng@627 14184 msgid ""
dongsheng@627 14185 "One use for this hook is to prevent external changes from being added to a "
dongsheng@627 14186 "repository. For example, you could use this to <quote>freeze</quote> a "
dongsheng@627 14187 "server-hosted branch temporarily or permanently so that users cannot push to "
dongsheng@627 14188 "it, while still allowing a local administrator to modify the repository."
dongsheng@627 14189 msgstr ""
dongsheng@627 14190
dongsheng@627 14191 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 14192 #: ../en/ch10-hook.xml:1576
songdongsheng@658 14193 msgid ""
songdongsheng@658 14194 "See also: <literal role=\"hook\">changegroup</literal> (<xref linkend=\"sec:"
songdongsheng@658 14195 "hook:changegroup\"/>), <literal role=\"hook\">incoming</literal> (<xref "
songdongsheng@658 14196 "linkend=\"sec:hook:incoming\"/>), <literal role=\"hook\">pretxnchangegroup</"
songdongsheng@658 14197 "literal> (<xref linkend=\"sec:hook:pretxnchangegroup\"/>)"
dongsheng@627 14198 msgstr ""
dongsheng@627 14199
dongsheng@627 14200 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 14201 #: ../en/ch10-hook.xml:1587
songdongsheng@668 14202 msgid ""
songdongsheng@668 14203 "<literal role=\"hook\">precommit</literal>&emdash;before starting to commit a "
dongsheng@627 14204 "changeset"
dongsheng@661 14205 msgstr "<literal role=\"hook\">precommit</literal>—提交修改集之前"
dongsheng@627 14206
dongsheng@627 14207 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 14208 #: ../en/ch10-hook.xml:1590
dongsheng@627 14209 msgid ""
dongsheng@627 14210 "This hook is run before Mercurial begins to commit a new changeset. It is run "
dongsheng@627 14211 "before Mercurial has any of the metadata for the commit, such as the files to "
dongsheng@627 14212 "be committed, the commit message, or the commit date."
dongsheng@627 14213 msgstr ""
dongsheng@627 14214
dongsheng@627 14215 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 14216 #: ../en/ch10-hook.xml:1596
dongsheng@627 14217 msgid ""
dongsheng@627 14218 "One use for this hook is to disable the ability to commit new changesets, "
dongsheng@627 14219 "while still allowing incoming changesets. Another is to run a build or test, "
dongsheng@627 14220 "and only allow the commit to begin if the build or test succeeds."
dongsheng@627 14221 msgstr ""
dongsheng@627 14222
dongsheng@627 14223 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 14224 #: ../en/ch10-hook.xml:1605
dongsheng@627 14225 msgid ""
dongsheng@627 14226 "<literal>parent1</literal>: A changeset ID. The changeset ID of the first "
dongsheng@627 14227 "parent of the working directory."
dongsheng@627 14228 msgstr ""
dongsheng@627 14229
dongsheng@627 14230 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 14231 #: ../en/ch10-hook.xml:1610
dongsheng@627 14232 msgid ""
dongsheng@627 14233 "<literal>parent2</literal>: A changeset ID. The changeset ID of the second "
dongsheng@627 14234 "parent of the working directory."
dongsheng@627 14235 msgstr ""
dongsheng@627 14236
dongsheng@627 14237 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 14238 #: ../en/ch10-hook.xml:1615
dongsheng@627 14239 msgid ""
dongsheng@627 14240 "If the commit proceeds, the parents of the working directory will become the "
dongsheng@627 14241 "parents of the new changeset."
dongsheng@627 14242 msgstr ""
dongsheng@627 14243
dongsheng@627 14244 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 14245 #: ../en/ch10-hook.xml:1619
dongsheng@627 14246 msgid ""
songdongsheng@658 14247 "See also: <literal role=\"hook\">commit</literal> (<xref linkend=\"sec:hook:"
songdongsheng@658 14248 "commit\"/>), <literal role=\"hook\">pretxncommit</literal> (<xref linkend="
songdongsheng@658 14249 "\"sec:hook:pretxncommit\"/>)"
dongsheng@627 14250 msgstr ""
dongsheng@627 14251
dongsheng@627 14252 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 14253 #: ../en/ch10-hook.xml:1627
songdongsheng@668 14254 msgid ""
songdongsheng@668 14255 "<literal role=\"hook\">preoutgoing</literal>&emdash;before starting to "
songdongsheng@668 14256 "propagate changesets"
dongsheng@661 14257 msgstr "<literal role=\"hook\">preoutgoing</literal>—传播修改集之前"
dongsheng@627 14258
dongsheng@627 14259 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 14260 #: ../en/ch10-hook.xml:1630
dongsheng@627 14261 msgid ""
dongsheng@627 14262 "This hook is invoked before Mercurial knows the identities of the changesets "
dongsheng@627 14263 "to be transmitted."
dongsheng@627 14264 msgstr ""
dongsheng@627 14265
dongsheng@627 14266 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 14267 #: ../en/ch10-hook.xml:1634
dongsheng@627 14268 msgid ""
dongsheng@627 14269 "One use for this hook is to prevent changes from being transmitted to another "
dongsheng@627 14270 "repository."
dongsheng@627 14271 msgstr ""
dongsheng@627 14272
dongsheng@627 14273 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 14274 #: ../en/ch10-hook.xml:1641
dongsheng@627 14275 msgid ""
dongsheng@627 14276 "<literal>source</literal>: A string. The source of the operation that is "
songdongsheng@658 14277 "attempting to obtain changes from this repository (see <xref linkend=\"sec:"
songdongsheng@658 14278 "hook:sources\"/>). See the documentation for the <literal>source</literal> "
songdongsheng@658 14279 "parameter to the <literal role=\"hook\">outgoing</literal> hook, in <xref "
songdongsheng@658 14280 "linkend=\"sec:hook:outgoing\"/>, for possible values of this parameter."
songdongsheng@658 14281 msgstr ""
songdongsheng@658 14282
songdongsheng@658 14283 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 14284 #: ../en/ch10-hook.xml:1657
songdongsheng@658 14285 msgid ""
songdongsheng@658 14286 "See also: <literal role=\"hook\">outgoing</literal> (<xref linkend=\"sec:hook:"
songdongsheng@658 14287 "outgoing\"/>)"
dongsheng@627 14288 msgstr ""
dongsheng@627 14289
dongsheng@627 14290 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 14291 #: ../en/ch10-hook.xml:1664
songdongsheng@668 14292 msgid ""
songdongsheng@668 14293 "<literal role=\"hook\">pretag</literal>&emdash;before tagging a changeset"
dongsheng@661 14294 msgstr "<literal role=\"hook\">pretag</literal>—创建标签之前"
dongsheng@627 14295
dongsheng@627 14296 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 14297 #: ../en/ch10-hook.xml:1667
dongsheng@627 14298 msgid ""
dongsheng@627 14299 "This controlling hook is run before a tag is created. If the hook succeeds, "
dongsheng@627 14300 "creation of the tag proceeds. If the hook fails, the tag is not created."
dongsheng@627 14301 msgstr ""
dongsheng@627 14302
dongsheng@627 14303 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 14304 #: ../en/ch10-hook.xml:1675
dongsheng@627 14305 msgid ""
dongsheng@627 14306 "<literal>local</literal>: A boolean. Whether the tag is local to this "
dongsheng@627 14307 "repository instance (i.e. stored in <filename role=\"special\">.hg/localtags</"
dongsheng@627 14308 "filename>) or managed by Mercurial (stored in <filename role=\"special\">."
dongsheng@627 14309 "hgtags</filename>)."
dongsheng@627 14310 msgstr ""
dongsheng@627 14311
dongsheng@627 14312 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 14313 #: ../en/ch10-hook.xml:1682
dongsheng@627 14314 msgid ""
dongsheng@627 14315 "<literal>node</literal>: A changeset ID. The ID of the changeset to be "
dongsheng@627 14316 "tagged."
dongsheng@627 14317 msgstr ""
dongsheng@627 14318
dongsheng@627 14319 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 14320 #: ../en/ch10-hook.xml:1686
dongsheng@627 14321 msgid "<literal>tag</literal>: A string. The name of the tag to be created."
dongsheng@627 14322 msgstr ""
dongsheng@627 14323
dongsheng@627 14324 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 14325 #: ../en/ch10-hook.xml:1691
dongsheng@627 14326 msgid ""
dongsheng@627 14327 "If the tag to be created is revision-controlled, the <literal role=\"hook"
dongsheng@627 14328 "\">precommit</literal> and <literal role=\"hook\">pretxncommit</literal> "
songdongsheng@658 14329 "hooks (<xref linkend=\"sec:hook:commit\"/> and <xref linkend=\"sec:hook:"
songdongsheng@658 14330 "pretxncommit\"/>) will also be run."
dongsheng@627 14331 msgstr ""
dongsheng@627 14332
dongsheng@627 14333 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 14334 #: ../en/ch10-hook.xml:1699
dongsheng@627 14335 msgid ""
songdongsheng@658 14336 "See also: <literal role=\"hook\">tag</literal> (<xref linkend=\"sec:hook:tag"
songdongsheng@658 14337 "\"/>)"
dongsheng@627 14338 msgstr ""
dongsheng@627 14339
dongsheng@627 14340 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 14341 #: ../en/ch10-hook.xml:1705
songdongsheng@668 14342 msgid ""
songdongsheng@668 14343 "<literal role=\"hook\">pretxnchangegroup</literal>&emdash;before completing "
songdongsheng@668 14344 "addition of remote changesets"
dongsheng@661 14345 msgstr ""
dongsheng@661 14346 "<literal role=\"hook\">pretxnchangegroup</literal>—完成增加远程修改集之前"
dongsheng@627 14347
dongsheng@627 14348 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 14349 #: ../en/ch10-hook.xml:1709
dongsheng@627 14350 msgid ""
songdongsheng@668 14351 "This controlling hook is run before a transaction&emdash;that manages the "
songdongsheng@668 14352 "addition of a group of new changesets from outside the repository&emdash;"
songdongsheng@668 14353 "completes. If the hook succeeds, the transaction completes, and all of the "
songdongsheng@668 14354 "changesets become permanent within this repository. If the hook fails, the "
songdongsheng@668 14355 "transaction is rolled back, and the data for the changesets is erased."
dongsheng@627 14356 msgstr ""
dongsheng@627 14357
dongsheng@627 14358 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 14359 #: ../en/ch10-hook.xml:1718
dongsheng@627 14360 msgid ""
dongsheng@627 14361 "This hook can access the metadata associated with the almost-added "
dongsheng@627 14362 "changesets, but it should not do anything permanent with this data. It must "
dongsheng@627 14363 "also not modify the working directory."
dongsheng@627 14364 msgstr ""
dongsheng@627 14365
dongsheng@627 14366 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 14367 #: ../en/ch10-hook.xml:1724
dongsheng@627 14368 msgid ""
dongsheng@627 14369 "While this hook is running, if other Mercurial processes access this "
dongsheng@627 14370 "repository, they will be able to see the almost-added changesets as if they "
dongsheng@627 14371 "are permanent. This may lead to race conditions if you do not take steps to "
dongsheng@627 14372 "avoid them."
dongsheng@627 14373 msgstr ""
dongsheng@627 14374
dongsheng@627 14375 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 14376 #: ../en/ch10-hook.xml:1731
dongsheng@627 14377 msgid ""
dongsheng@627 14378 "This hook can be used to automatically vet a group of changesets. If the "
dongsheng@627 14379 "hook fails, all of the changesets are <quote>rejected</quote> when the "
dongsheng@627 14380 "transaction rolls back."
dongsheng@627 14381 msgstr ""
dongsheng@627 14382
dongsheng@627 14383 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 14384 #: ../en/ch10-hook.xml:1760
songdongsheng@658 14385 msgid ""
songdongsheng@658 14386 "See also: <literal role=\"hook\">changegroup</literal> (<xref linkend=\"sec:"
songdongsheng@658 14387 "hook:changegroup\"/>), <literal role=\"hook\">incoming</literal> (<xref "
songdongsheng@658 14388 "linkend=\"sec:hook:incoming\"/>), <literal role=\"hook\">prechangegroup</"
songdongsheng@658 14389 "literal> (<xref linkend=\"sec:hook:prechangegroup\"/>)"
dongsheng@627 14390 msgstr ""
dongsheng@627 14391
dongsheng@627 14392 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 14393 #: ../en/ch10-hook.xml:1771
songdongsheng@668 14394 msgid ""
songdongsheng@668 14395 "<literal role=\"hook\">pretxncommit</literal>&emdash;before completing commit "
songdongsheng@668 14396 "of new changeset"
dongsheng@661 14397 msgstr "<literal role=\"hook\">pretxncommit</literal>—完成提交之前"
dongsheng@627 14398
dongsheng@627 14399 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 14400 #: ../en/ch10-hook.xml:1774
dongsheng@627 14401 msgid ""
songdongsheng@668 14402 "This controlling hook is run before a transaction&emdash;that manages a new "
songdongsheng@668 14403 "commit&emdash;completes. If the hook succeeds, the transaction completes and "
songdongsheng@668 14404 "the changeset becomes permanent within this repository. If the hook fails, "
songdongsheng@668 14405 "the transaction is rolled back, and the commit data is erased."
dongsheng@627 14406 msgstr ""
dongsheng@627 14407
dongsheng@627 14408 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 14409 #: ../en/ch10-hook.xml:1782
dongsheng@627 14410 msgid ""
dongsheng@627 14411 "This hook can access the metadata associated with the almost-new changeset, "
dongsheng@627 14412 "but it should not do anything permanent with this data. It must also not "
dongsheng@627 14413 "modify the working directory."
dongsheng@627 14414 msgstr ""
dongsheng@627 14415
dongsheng@627 14416 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 14417 #: ../en/ch10-hook.xml:1788
dongsheng@627 14418 msgid ""
dongsheng@627 14419 "While this hook is running, if other Mercurial processes access this "
dongsheng@627 14420 "repository, they will be able to see the almost-new changeset as if it is "
dongsheng@627 14421 "permanent. This may lead to race conditions if you do not take steps to "
dongsheng@627 14422 "avoid them."
dongsheng@627 14423 msgstr ""
dongsheng@627 14424
dongsheng@627 14425 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 14426 #: ../en/ch10-hook.xml:1812
songdongsheng@658 14427 msgid ""
songdongsheng@658 14428 "See also: <literal role=\"hook\">precommit</literal> (<xref linkend=\"sec:"
songdongsheng@658 14429 "hook:precommit\"/>)"
dongsheng@660 14430 msgstr ""
dongsheng@660 14431 "参见: <literal role=\"hook\">precommit</literal> (<xref linkend=\"sec:hook:"
dongsheng@660 14432 "precommit\"/>)"
dongsheng@627 14433
dongsheng@627 14434 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 14435 #: ../en/ch10-hook.xml:1819
songdongsheng@668 14436 msgid ""
songdongsheng@668 14437 "<literal role=\"hook\">preupdate</literal>&emdash;before updating or merging "
songdongsheng@668 14438 "working directory"
dongsheng@661 14439 msgstr "<literal role=\"hook\">preupdate</literal>—更新或合并工作目录之前"
dongsheng@627 14440
dongsheng@627 14441 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 14442 #: ../en/ch10-hook.xml:1822
dongsheng@627 14443 msgid ""
dongsheng@627 14444 "This controlling hook is run before an update or merge of the working "
dongsheng@627 14445 "directory begins. It is run only if Mercurial's normal pre-update checks "
dongsheng@627 14446 "determine that the update or merge can proceed. If the hook succeeds, the "
dongsheng@627 14447 "update or merge may proceed; if it fails, the update or merge does not start."
dongsheng@627 14448 msgstr ""
dongsheng@627 14449
dongsheng@627 14450 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 14451 #: ../en/ch10-hook.xml:1833
songdongsheng@658 14452 msgid ""
songdongsheng@658 14453 "<literal>parent1</literal>: A changeset ID. The ID of the parent that the "
dongsheng@627 14454 "working directory is to be updated to. If the working directory is being "
dongsheng@627 14455 "merged, it will not change this parent."
dongsheng@627 14456 msgstr ""
dongsheng@627 14457
dongsheng@627 14458 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 14459 #: ../en/ch10-hook.xml:1839
songdongsheng@658 14460 msgid ""
songdongsheng@658 14461 "<literal>parent2</literal>: A changeset ID. Only set if the working directory "
songdongsheng@658 14462 "is being merged. The ID of the revision that the working directory is being "
songdongsheng@658 14463 "merged with."
songdongsheng@658 14464 msgstr ""
songdongsheng@658 14465
songdongsheng@658 14466 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 14467 #: ../en/ch10-hook.xml:1846
songdongsheng@658 14468 msgid ""
songdongsheng@658 14469 "See also: <literal role=\"hook\">update</literal> (<xref linkend=\"sec:hook:"
songdongsheng@658 14470 "update\"/>)"
dongsheng@627 14471 msgstr ""
dongsheng@627 14472
dongsheng@627 14473 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 14474 #: ../en/ch10-hook.xml:1851
songdongsheng@668 14475 msgid "<literal role=\"hook\">tag</literal>&emdash;after tagging a changeset"
dongsheng@661 14476 msgstr "<literal role=\"hook\">tag</literal>—创建标签之后"
dongsheng@627 14477
dongsheng@627 14478 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 14479 #: ../en/ch10-hook.xml:1854
dongsheng@627 14480 msgid "This hook is run after a tag has been created."
dongsheng@627 14481 msgstr ""
dongsheng@627 14482
dongsheng@627 14483 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 14484 #: ../en/ch10-hook.xml:1860
dongsheng@627 14485 msgid ""
dongsheng@627 14486 "<literal>local</literal>: A boolean. Whether the new tag is local to this "
dongsheng@627 14487 "repository instance (i.e. stored in <filename role=\"special\">.hg/"
dongsheng@627 14488 "localtags</filename>) or managed by Mercurial (stored in <filename role="
dongsheng@627 14489 "\"special\">.hgtags</filename>)."
dongsheng@627 14490 msgstr ""
dongsheng@627 14491
dongsheng@627 14492 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 14493 #: ../en/ch10-hook.xml:1868
dongsheng@627 14494 msgid ""
dongsheng@627 14495 "<literal>node</literal>: A changeset ID. The ID of the changeset that was "
dongsheng@627 14496 "tagged."
dongsheng@627 14497 msgstr ""
dongsheng@627 14498
dongsheng@627 14499 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 14500 #: ../en/ch10-hook.xml:1872
dongsheng@627 14501 msgid "<literal>tag</literal>: A string. The name of the tag that was created."
dongsheng@627 14502 msgstr ""
dongsheng@627 14503
dongsheng@627 14504 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 14505 #: ../en/ch10-hook.xml:1877
dongsheng@627 14506 msgid ""
dongsheng@627 14507 "If the created tag is revision-controlled, the <literal role=\"hook\">commit</"
songdongsheng@658 14508 "literal> hook (section <xref linkend=\"sec:hook:commit\"/>) is run before "
dongsheng@627 14509 "this hook."
dongsheng@627 14510 msgstr ""
dongsheng@627 14511
dongsheng@627 14512 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 14513 #: ../en/ch10-hook.xml:1882
songdongsheng@658 14514 msgid ""
songdongsheng@658 14515 "See also: <literal role=\"hook\">pretag</literal> (<xref linkend=\"sec:hook:"
songdongsheng@658 14516 "pretag\"/>)"
dongsheng@660 14517 msgstr ""
dongsheng@660 14518 "参见: <literal role=\"hook\">pretag</literal> (<xref linkend=\"sec:hook:pretag"
dongsheng@660 14519 "\"/>)"
dongsheng@627 14520
dongsheng@627 14521 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 14522 #: ../en/ch10-hook.xml:1888
songdongsheng@668 14523 msgid ""
songdongsheng@668 14524 "<literal role=\"hook\">update</literal>&emdash;after updating or merging "
songdongsheng@668 14525 "working directory"
dongsheng@661 14526 msgstr "<literal role=\"hook\">update</literal>—更新或合并工作目录之后"
dongsheng@627 14527
dongsheng@627 14528 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 14529 #: ../en/ch10-hook.xml:1891
dongsheng@627 14530 msgid ""
dongsheng@627 14531 "This hook is run after an update or merge of the working directory "
dongsheng@627 14532 "completes. Since a merge can fail (if the external <command>hgmerge</"
dongsheng@627 14533 "command> command fails to resolve conflicts in a file), this hook "
dongsheng@627 14534 "communicates whether the update or merge completed cleanly."
dongsheng@627 14535 msgstr ""
dongsheng@627 14536
dongsheng@627 14537 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 14538 #: ../en/ch10-hook.xml:1899
dongsheng@627 14539 msgid ""
dongsheng@627 14540 "<literal>error</literal>: A boolean. Indicates whether the update or merge "
dongsheng@627 14541 "completed successfully."
dongsheng@627 14542 msgstr ""
dongsheng@627 14543
dongsheng@627 14544 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 14545 #: ../en/ch10-hook.xml:1904
dongsheng@627 14546 msgid ""
dongsheng@627 14547 "<literal>parent1</literal>: A changeset ID. The ID of the parent that the "
dongsheng@627 14548 "working directory was updated to. If the working directory was merged, it "
dongsheng@627 14549 "will not have changed this parent."
dongsheng@627 14550 msgstr ""
dongsheng@627 14551
dongsheng@627 14552 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 14553 #: ../en/ch10-hook.xml:1910
dongsheng@627 14554 msgid ""
dongsheng@627 14555 "<literal>parent2</literal>: A changeset ID. Only set if the working "
dongsheng@627 14556 "directory was merged. The ID of the revision that the working directory was "
dongsheng@627 14557 "merged with."
dongsheng@627 14558 msgstr ""
dongsheng@627 14559
dongsheng@627 14560 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 14561 #: ../en/ch10-hook.xml:1916
songdongsheng@658 14562 msgid ""
songdongsheng@658 14563 "See also: <literal role=\"hook\">preupdate</literal> (<xref linkend=\"sec:"
songdongsheng@658 14564 "hook:preupdate\"/>)"
dongsheng@627 14565 msgstr ""
dongsheng@627 14566
dongsheng@627 14567 #. type: Content of: <book><chapter><title>
dongsheng@714 14568 #: ../en/ch11-template.xml:5
dongsheng@714 14569 msgid "Customizing the output of Mercurial"
dongsheng@627 14570 msgstr "定制 Mercurial 的输出"
dongsheng@627 14571
dongsheng@627 14572 #. type: Content of: <book><chapter><para>
dongsheng@714 14573 #: ../en/ch11-template.xml:7
dongsheng@627 14574 msgid ""
dongsheng@627 14575 "Mercurial provides a powerful mechanism to let you control how it displays "
dongsheng@627 14576 "information. The mechanism is based on templates. You can use templates to "
dongsheng@714 14577 "generate specific output for a single command, or to customize the entire "
dongsheng@627 14578 "appearance of the built-in web interface."
dongsheng@627 14579 msgstr ""
dongsheng@627 14580
dongsheng@627 14581 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 14582 #: ../en/ch11-template.xml:14
dongsheng@627 14583 msgid "Using precanned output styles"
dongsheng@636 14584 msgstr "使用预定义的输出样式"
dongsheng@627 14585
dongsheng@627 14586 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 14587 #: ../en/ch11-template.xml:16
dongsheng@627 14588 msgid ""
dongsheng@627 14589 "Packaged with Mercurial are some output styles that you can use immediately. "
dongsheng@627 14590 "A style is simply a precanned template that someone wrote and installed "
dongsheng@627 14591 "somewhere that Mercurial can find."
dongsheng@627 14592 msgstr ""
dongsheng@627 14593
dongsheng@627 14594 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 14595 #: ../en/ch11-template.xml:21
dongsheng@627 14596 msgid ""
dongsheng@627 14597 "Before we take a look at Mercurial's bundled styles, let's review its normal "
dongsheng@627 14598 "output."
dongsheng@627 14599 msgstr ""
dongsheng@627 14600
dongsheng@627 14601 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 14602 #: ../en/ch11-template.xml:26
dongsheng@627 14603 msgid ""
songdongsheng@668 14604 "This is somewhat informative, but it takes up a lot of space&emdash;five "
songdongsheng@668 14605 "lines of output per changeset. The <literal>compact</literal> style reduces "
songdongsheng@668 14606 "this to three lines, presented in a sparse manner."
dongsheng@627 14607 msgstr ""
dongsheng@627 14608
dongsheng@627 14609 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 14610 #: ../en/ch11-template.xml:33
dongsheng@627 14611 msgid ""
dongsheng@627 14612 "The <literal>changelog</literal> style hints at the expressive power of "
dongsheng@627 14613 "Mercurial's templating engine. This style attempts to follow the GNU "
dongsheng@627 14614 "Project's changelog guidelines<citation>web:changelog</citation>."
dongsheng@627 14615 msgstr ""
dongsheng@627 14616
dongsheng@627 14617 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 14618 #: ../en/ch11-template.xml:40
dongsheng@627 14619 msgid ""
dongsheng@627 14620 "You will not be shocked to learn that Mercurial's default output style is "
dongsheng@627 14621 "named <literal>default</literal>."
dongsheng@627 14622 msgstr ""
dongsheng@627 14623
dongsheng@627 14624 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 14625 #: ../en/ch11-template.xml:44
dongsheng@627 14626 msgid "Setting a default style"
dongsheng@636 14627 msgstr "设置默认样式"
dongsheng@627 14628
dongsheng@627 14629 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 14630 #: ../en/ch11-template.xml:46
dongsheng@627 14631 msgid ""
dongsheng@627 14632 "You can modify the output style that Mercurial will use for every command by "
dongsheng@650 14633 "editing your <filename role=\"special\">~/.hgrc</filename> file, naming the "
dongsheng@627 14634 "style you would prefer to use."
dongsheng@627 14635 msgstr ""
dongsheng@627 14636
dongsheng@627 14637 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 14638 #: ../en/ch11-template.xml:54
dongsheng@627 14639 msgid ""
dongsheng@627 14640 "If you write a style of your own, you can use it by either providing the path "
dongsheng@627 14641 "to your style file, or copying your style file into a location where "
dongsheng@627 14642 "Mercurial can find it (typically the <literal>templates</literal> "
dongsheng@627 14643 "subdirectory of your Mercurial install directory)."
dongsheng@627 14644 msgstr ""
dongsheng@627 14645
dongsheng@627 14646 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 14647 #: ../en/ch11-template.xml:63
dongsheng@627 14648 msgid "Commands that support styles and templates"
dongsheng@636 14649 msgstr "支持样式和模版的命令"
dongsheng@627 14650
dongsheng@627 14651 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 14652 #: ../en/ch11-template.xml:65
dongsheng@627 14653 msgid ""
dongsheng@627 14654 "All of Mercurial's <quote><literal>log</literal>-like</quote> commands let "
dongsheng@627 14655 "you use styles and templates: <command role=\"hg-cmd\">hg incoming</command>, "
dongsheng@627 14656 "<command role=\"hg-cmd\">hg log</command>, <command role=\"hg-cmd\">hg "
dongsheng@627 14657 "outgoing</command>, and <command role=\"hg-cmd\">hg tip</command>."
dongsheng@627 14658 msgstr ""
dongsheng@627 14659
dongsheng@627 14660 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 14661 #: ../en/ch11-template.xml:72
dongsheng@627 14662 msgid ""
dongsheng@627 14663 "As I write this manual, these are so far the only commands that support "
dongsheng@627 14664 "styles and templates. Since these are the most important commands that need "
dongsheng@714 14665 "customizable output, there has been little pressure from the Mercurial user "
dongsheng@627 14666 "community to add style and template support to other commands."
dongsheng@627 14667 msgstr ""
dongsheng@627 14668
dongsheng@627 14669 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 14670 #: ../en/ch11-template.xml:80
dongsheng@627 14671 msgid "The basics of templating"
dongsheng@636 14672 msgstr "模版基础"
dongsheng@627 14673
dongsheng@627 14674 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 14675 #: ../en/ch11-template.xml:82
dongsheng@627 14676 msgid ""
dongsheng@627 14677 "At its simplest, a Mercurial template is a piece of text. Some of the text "
dongsheng@627 14678 "never changes, while other parts are <emphasis>expanded</emphasis>, or "
dongsheng@627 14679 "replaced with new text, when necessary."
dongsheng@627 14680 msgstr ""
dongsheng@627 14681
dongsheng@627 14682 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 14683 #: ../en/ch11-template.xml:87
dongsheng@627 14684 msgid ""
dongsheng@627 14685 "Before we continue, let's look again at a simple example of Mercurial's "
dongsheng@627 14686 "normal output."
dongsheng@627 14687 msgstr ""
dongsheng@627 14688
dongsheng@627 14689 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 14690 #: ../en/ch11-template.xml:92
dongsheng@627 14691 msgid ""
dongsheng@627 14692 "Now, let's run the same command, but using a template to change its output."
dongsheng@627 14693 msgstr ""
dongsheng@627 14694
dongsheng@627 14695 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 14696 #: ../en/ch11-template.xml:97
dongsheng@627 14697 msgid ""
dongsheng@627 14698 "The example above illustrates the simplest possible template; it's just a "
dongsheng@627 14699 "piece of static text, printed once for each changeset. The <option role=\"hg-"
dongsheng@627 14700 "opt-log\">--template</option> option to the <command role=\"hg-cmd\">hg log</"
dongsheng@627 14701 "command> command tells Mercurial to use the given text as the template when "
dongsheng@627 14702 "printing each changeset."
dongsheng@627 14703 msgstr ""
dongsheng@627 14704
dongsheng@627 14705 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 14706 #: ../en/ch11-template.xml:105
dongsheng@627 14707 msgid ""
dongsheng@627 14708 "Notice that the template string above ends with the text <quote><literal>\\n</"
dongsheng@627 14709 "literal></quote>. This is an <emphasis>escape sequence</emphasis>, telling "
dongsheng@627 14710 "Mercurial to print a newline at the end of each template item. If you omit "
songdongsheng@658 14711 "this newline, Mercurial will run each piece of output together. See <xref "
songdongsheng@658 14712 "linkend=\"sec:template:escape\"/> for more details of escape sequences."
dongsheng@627 14713 msgstr ""
dongsheng@627 14714
dongsheng@627 14715 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 14716 #: ../en/ch11-template.xml:113
dongsheng@627 14717 msgid ""
dongsheng@627 14718 "A template that prints a fixed string of text all the time isn't very useful; "
dongsheng@627 14719 "let's try something a bit more complex."
dongsheng@627 14720 msgstr ""
dongsheng@627 14721
dongsheng@627 14722 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 14723 #: ../en/ch11-template.xml:119
dongsheng@627 14724 msgid ""
dongsheng@627 14725 "As you can see, the string <quote><literal>{desc}</literal></quote> in the "
dongsheng@627 14726 "template has been replaced in the output with the description of each "
dongsheng@627 14727 "changeset. Every time Mercurial finds text enclosed in curly braces "
dongsheng@627 14728 "(<quote><literal>{</literal></quote> and <quote><literal>}</literal></"
dongsheng@627 14729 "quote>), it will try to replace the braces and text with the expansion of "
dongsheng@627 14730 "whatever is inside. To print a literal curly brace, you must escape it, as "
songdongsheng@658 14731 "described in <xref linkend=\"sec:template:escape\"/>."
dongsheng@627 14732 msgstr ""
dongsheng@627 14733
dongsheng@627 14734 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 14735 #: ../en/ch11-template.xml:131
dongsheng@627 14736 msgid "Common template keywords"
dongsheng@636 14737 msgstr "模版关键字"
dongsheng@627 14738
dongsheng@627 14739 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 14740 #: ../en/ch11-template.xml:133
dongsheng@627 14741 msgid ""
dongsheng@627 14742 "You can start writing simple templates immediately using the keywords below."
dongsheng@627 14743 msgstr ""
dongsheng@627 14744
dongsheng@627 14745 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 14746 #: ../en/ch11-template.xml:137
dongsheng@627 14747 msgid ""
dongsheng@627 14748 "<literal role=\"template-keyword\">author</literal>: String. The unmodified "
dongsheng@627 14749 "author of the changeset."
dongsheng@627 14750 msgstr ""
dongsheng@627 14751
dongsheng@627 14752 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 14753 #: ../en/ch11-template.xml:141
dongsheng@627 14754 msgid ""
dongsheng@627 14755 "<literal role=\"template-keyword\">branches</literal>: String. The name of "
dongsheng@627 14756 "the branch on which the changeset was committed. Will be empty if the branch "
dongsheng@627 14757 "name was <literal>default</literal>."
dongsheng@627 14758 msgstr ""
dongsheng@627 14759
dongsheng@627 14760 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 14761 #: ../en/ch11-template.xml:147
dongsheng@627 14762 msgid ""
dongsheng@627 14763 "<literal role=\"template-keyword\">date</literal>: Date information. The "
dongsheng@627 14764 "date when the changeset was committed. This is <emphasis>not</emphasis> "
dongsheng@627 14765 "human-readable; you must pass it through a filter that will render it "
songdongsheng@658 14766 "appropriately. See <xref linkend=\"sec:template:filter\"/> for more "
dongsheng@627 14767 "information on filters. The date is expressed as a pair of numbers. The "
dongsheng@627 14768 "first number is a Unix UTC timestamp (seconds since January 1, 1970); the "
dongsheng@627 14769 "second is the offset of the committer's timezone from UTC, in seconds."
dongsheng@627 14770 msgstr ""
dongsheng@627 14771
dongsheng@627 14772 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 14773 #: ../en/ch11-template.xml:158
dongsheng@627 14774 msgid ""
dongsheng@627 14775 "<literal role=\"template-keyword\">desc</literal>: String. The text of the "
dongsheng@627 14776 "changeset description."
dongsheng@627 14777 msgstr ""
dongsheng@627 14778
dongsheng@627 14779 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 14780 #: ../en/ch11-template.xml:161
dongsheng@627 14781 msgid ""
dongsheng@627 14782 "<literal role=\"template-keyword\">files</literal>: List of strings. All "
dongsheng@627 14783 "files modified, added, or removed by this changeset."
dongsheng@627 14784 msgstr ""
dongsheng@627 14785
dongsheng@627 14786 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 14787 #: ../en/ch11-template.xml:166
dongsheng@627 14788 msgid ""
dongsheng@627 14789 "<literal role=\"template-keyword\">file_adds</literal>: List of strings. "
dongsheng@627 14790 "Files added by this changeset."
dongsheng@627 14791 msgstr ""
dongsheng@627 14792
dongsheng@627 14793 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 14794 #: ../en/ch11-template.xml:170
dongsheng@627 14795 msgid ""
dongsheng@627 14796 "<literal role=\"template-keyword\">file_dels</literal>: List of strings. "
dongsheng@627 14797 "Files removed by this changeset."
dongsheng@627 14798 msgstr ""
dongsheng@627 14799
dongsheng@627 14800 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 14801 #: ../en/ch11-template.xml:174
dongsheng@627 14802 msgid ""
dongsheng@627 14803 "<literal role=\"template-keyword\">node</literal>: String. The changeset "
dongsheng@627 14804 "identification hash, as a 40-character hexadecimal string."
dongsheng@627 14805 msgstr ""
dongsheng@627 14806
dongsheng@627 14807 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 14808 #: ../en/ch11-template.xml:178
dongsheng@627 14809 msgid ""
dongsheng@627 14810 "<literal role=\"template-keyword\">parents</literal>: List of strings. The "
dongsheng@627 14811 "parents of the changeset."
dongsheng@627 14812 msgstr ""
dongsheng@627 14813
dongsheng@627 14814 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 14815 #: ../en/ch11-template.xml:182
dongsheng@627 14816 msgid ""
dongsheng@627 14817 "<literal role=\"template-keyword\">rev</literal>: Integer. The repository-"
dongsheng@627 14818 "local changeset revision number."
dongsheng@627 14819 msgstr ""
dongsheng@627 14820
dongsheng@627 14821 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 14822 #: ../en/ch11-template.xml:186
dongsheng@627 14823 msgid ""
dongsheng@627 14824 "<literal role=\"template-keyword\">tags</literal>: List of strings. Any tags "
dongsheng@627 14825 "associated with the changeset."
dongsheng@627 14826 msgstr ""
dongsheng@627 14827
dongsheng@627 14828 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 14829 #: ../en/ch11-template.xml:192
dongsheng@627 14830 msgid ""
dongsheng@627 14831 "A few simple experiments will show us what to expect when we use these "
dongsheng@627 14832 "keywords; you can see the results below."
dongsheng@627 14833 msgstr ""
dongsheng@627 14834
dongsheng@627 14835 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 14836 #: ../en/ch11-template.xml:197
dongsheng@627 14837 msgid ""
dongsheng@627 14838 "As we noted above, the date keyword does not produce human-readable output, "
dongsheng@627 14839 "so we must treat it specially. This involves using a <emphasis>filter</"
songdongsheng@658 14840 "emphasis>, about which more in <xref linkend=\"sec:template:filter\"/>."
dongsheng@627 14841 msgstr ""
dongsheng@627 14842
dongsheng@627 14843 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 14844 #: ../en/ch11-template.xml:206
dongsheng@627 14845 msgid "Escape sequences"
dongsheng@636 14846 msgstr "转义序列"
dongsheng@627 14847
dongsheng@627 14848 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 14849 #: ../en/ch11-template.xml:208
dongsheng@627 14850 msgid ""
dongsheng@627 14851 "Mercurial's templating engine recognises the most commonly used escape "
dongsheng@627 14852 "sequences in strings. When it sees a backslash (<quote><literal>\\</"
dongsheng@627 14853 "literal></quote>) character, it looks at the following character and "
dongsheng@627 14854 "substitutes the two characters with a single replacement, as described below."
dongsheng@627 14855 msgstr ""
dongsheng@627 14856
dongsheng@627 14857 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 14858 #: ../en/ch11-template.xml:215
dongsheng@650 14859 msgid ""
dongsheng@650 14860 "<literal>\\</literal>: Backslash, <quote><literal>\\</literal></quote>, ASCII "
dongsheng@650 14861 "134."
dongsheng@627 14862 msgstr ""
dongsheng@627 14863
dongsheng@627 14864 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 14865 #: ../en/ch11-template.xml:219
dongsheng@650 14866 msgid "<literal>\\n</literal>: Newline, ASCII 12."
dongsheng@627 14867 msgstr ""
dongsheng@627 14868
dongsheng@627 14869 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 14870 #: ../en/ch11-template.xml:222
dongsheng@650 14871 msgid "<literal>\\r</literal>: Carriage return, ASCII 15."
dongsheng@627 14872 msgstr ""
dongsheng@627 14873
dongsheng@627 14874 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 14875 #: ../en/ch11-template.xml:225
dongsheng@650 14876 msgid "<literal>\\t</literal>: Tab, ASCII 11."
dongsheng@627 14877 msgstr ""
dongsheng@627 14878
dongsheng@627 14879 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 14880 #: ../en/ch11-template.xml:228
dongsheng@650 14881 msgid "<literal>\\v</literal>: Vertical tab, ASCII 13."
dongsheng@627 14882 msgstr ""
dongsheng@627 14883
dongsheng@627 14884 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 14885 #: ../en/ch11-template.xml:231
dongsheng@714 14886 msgid ""
dongsheng@714 14887 "<literal>\\{</literal>: Open curly brace, <quote><literal>{</literal></"
dongsheng@714 14888 "quote>, ASCII 173."
dongsheng@627 14889 msgstr ""
dongsheng@627 14890
dongsheng@627 14891 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 14892 #: ../en/ch11-template.xml:235
dongsheng@714 14893 msgid ""
dongsheng@714 14894 "<literal>\\}</literal>: Close curly brace, <quote><literal>}</literal></"
dongsheng@714 14895 "quote>, ASCII 175."
dongsheng@714 14896 msgstr ""
dongsheng@714 14897
dongsheng@714 14898 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 14899 #: ../en/ch11-template.xml:240
dongsheng@627 14900 msgid ""
dongsheng@627 14901 "As indicated above, if you want the expansion of a template to contain a "
dongsheng@627 14902 "literal <quote><literal>\\</literal></quote>, <quote><literal>{</literal></"
dongsheng@627 14903 "quote>, or <quote><literal>{</literal></quote> character, you must escape it."
dongsheng@627 14904 msgstr ""
dongsheng@627 14905
dongsheng@627 14906 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 14907 #: ../en/ch11-template.xml:248
dongsheng@627 14908 msgid "Filtering keywords to change their results"
dongsheng@636 14909 msgstr "通过过滤关键字来修改输出结果"
dongsheng@627 14910
dongsheng@627 14911 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 14912 #: ../en/ch11-template.xml:250
dongsheng@627 14913 msgid ""
dongsheng@627 14914 "Some of the results of template expansion are not immediately easy to use. "
dongsheng@627 14915 "Mercurial lets you specify an optional chain of <emphasis>filters</emphasis> "
dongsheng@627 14916 "to modify the result of expanding a keyword. You have already seen a common "
dongsheng@627 14917 "filter, <literal role=\"template-kw-filt-date\">isodate</literal>, in action "
dongsheng@627 14918 "above, to make a date readable."
dongsheng@627 14919 msgstr ""
dongsheng@627 14920
dongsheng@627 14921 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 14922 #: ../en/ch11-template.xml:257
dongsheng@627 14923 msgid ""
dongsheng@627 14924 "Below is a list of the most commonly used filters that Mercurial supports. "
dongsheng@627 14925 "While some filters can be applied to any text, others can only be used in "
dongsheng@627 14926 "specific circumstances. The name of each filter is followed first by an "
dongsheng@627 14927 "indication of where it can be used, then a description of its effect."
dongsheng@627 14928 msgstr ""
dongsheng@627 14929
dongsheng@627 14930 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 14931 #: ../en/ch11-template.xml:264
dongsheng@627 14932 msgid ""
dongsheng@627 14933 "<literal role=\"template-filter\">addbreaks</literal>: Any text. Add an XHTML "
dongsheng@627 14934 "<quote><literal>&lt;br/&gt;</literal></quote> tag before the end of every "
dongsheng@627 14935 "line except the last. For example, <quote><literal>foo\\nbar</literal></"
dongsheng@627 14936 "quote> becomes <quote><literal>foo&lt;br/&gt;\\nbar</literal></quote>."
dongsheng@627 14937 msgstr ""
dongsheng@627 14938
dongsheng@627 14939 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 14940 #: ../en/ch11-template.xml:271
dongsheng@627 14941 msgid ""
dongsheng@627 14942 "<literal role=\"template-kw-filt-date\">age</literal>: <literal role="
dongsheng@627 14943 "\"template-keyword\">date</literal> keyword. Render the age of the date, "
dongsheng@627 14944 "relative to the current time. Yields a string like <quote><literal>10 "
dongsheng@627 14945 "minutes</literal></quote>."
dongsheng@627 14946 msgstr ""
dongsheng@627 14947
dongsheng@627 14948 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 14949 #: ../en/ch11-template.xml:278
dongsheng@627 14950 msgid ""
dongsheng@627 14951 "<literal role=\"template-filter\">basename</literal>: Any text, but most "
dongsheng@627 14952 "useful for the <literal role=\"template-keyword\">files</literal> keyword and "
dongsheng@627 14953 "its relatives. Treat the text as a path, and return the basename. For "
dongsheng@627 14954 "example, <quote><literal>foo/bar/baz</literal></quote> becomes "
dongsheng@627 14955 "<quote><literal>baz</literal></quote>."
dongsheng@627 14956 msgstr ""
dongsheng@627 14957
dongsheng@627 14958 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 14959 #: ../en/ch11-template.xml:287
dongsheng@627 14960 msgid ""
dongsheng@627 14961 "<literal role=\"template-kw-filt-date\">date</literal>: <literal role="
dongsheng@627 14962 "\"template-keyword\">date</literal> keyword. Render a date in a similar "
dongsheng@627 14963 "format to the Unix <literal role=\"template-keyword\">date</literal> command, "
dongsheng@627 14964 "but with timezone included. Yields a string like <quote><literal>Mon Sep 04 "
dongsheng@627 14965 "15:13:13 2006 -0700</literal></quote>."
dongsheng@627 14966 msgstr ""
dongsheng@627 14967
dongsheng@627 14968 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 14969 #: ../en/ch11-template.xml:295
dongsheng@627 14970 msgid ""
dongsheng@627 14971 "<literal role=\"template-kw-filt-author\">domain</literal>: Any text, but "
dongsheng@627 14972 "most useful for the <literal role=\"template-keyword\">author</literal> "
dongsheng@627 14973 "keyword. Finds the first string that looks like an email address, and "
dongsheng@627 14974 "extract just the domain component. For example, <quote><literal>Bryan "
dongsheng@627 14975 "O'Sullivan &lt;bos@serpentine.com&gt;</literal></quote> becomes "
dongsheng@627 14976 "<quote><literal>serpentine.com</literal></quote>."
dongsheng@627 14977 msgstr ""
dongsheng@627 14978
dongsheng@627 14979 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 14980 #: ../en/ch11-template.xml:305
dongsheng@627 14981 msgid ""
dongsheng@627 14982 "<literal role=\"template-kw-filt-author\">email</literal>: Any text, but most "
dongsheng@627 14983 "useful for the <literal role=\"template-keyword\">author</literal> keyword. "
dongsheng@627 14984 "Extract the first string that looks like an email address. For example, "
dongsheng@627 14985 "<quote><literal>Bryan O'Sullivan &lt;bos@serpentine.com&gt;</literal></quote> "
dongsheng@627 14986 "becomes <quote><literal>bos@serpentine.com</literal></quote>."
dongsheng@627 14987 msgstr ""
dongsheng@627 14988
dongsheng@627 14989 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 14990 #: ../en/ch11-template.xml:314
dongsheng@627 14991 msgid ""
dongsheng@627 14992 "<literal role=\"template-filter\">escape</literal>: Any text. Replace the "
dongsheng@627 14993 "special XML/XHTML characters <quote><literal>&amp;</literal></quote>, "
dongsheng@627 14994 "<quote><literal>&lt;</literal></quote> and <quote><literal>&gt;</literal></"
dongsheng@627 14995 "quote> with XML entities."
dongsheng@627 14996 msgstr ""
dongsheng@627 14997
dongsheng@627 14998 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 14999 #: ../en/ch11-template.xml:322
dongsheng@627 15000 msgid ""
dongsheng@627 15001 "<literal role=\"template-filter\">fill68</literal>: Any text. Wrap the text "
dongsheng@627 15002 "to fit in 68 columns. This is useful before you pass text through the "
dongsheng@627 15003 "<literal role=\"template-filter\">tabindent</literal> filter, and still want "
dongsheng@627 15004 "it to fit in an 80-column fixed-font window."
dongsheng@627 15005 msgstr ""
dongsheng@627 15006
dongsheng@627 15007 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 15008 #: ../en/ch11-template.xml:330
dongsheng@627 15009 msgid ""
dongsheng@627 15010 "<literal role=\"template-filter\">fill76</literal>: Any text. Wrap the text "
dongsheng@627 15011 "to fit in 76 columns."
dongsheng@627 15012 msgstr ""
dongsheng@627 15013
dongsheng@627 15014 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 15015 #: ../en/ch11-template.xml:334
dongsheng@627 15016 msgid ""
dongsheng@627 15017 "<literal role=\"template-filter\">firstline</literal>: Any text. Yield the "
dongsheng@627 15018 "first line of text, without any trailing newlines."
dongsheng@627 15019 msgstr ""
dongsheng@627 15020
dongsheng@627 15021 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 15022 #: ../en/ch11-template.xml:339
dongsheng@627 15023 msgid ""
dongsheng@627 15024 "<literal role=\"template-kw-filt-date\">hgdate</literal>: <literal role="
dongsheng@627 15025 "\"template-keyword\">date</literal> keyword. Render the date as a pair of "
dongsheng@627 15026 "readable numbers. Yields a string like <quote><literal>1157407993 25200</"
dongsheng@627 15027 "literal></quote>."
dongsheng@627 15028 msgstr ""
dongsheng@627 15029
dongsheng@627 15030 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 15031 #: ../en/ch11-template.xml:346
dongsheng@627 15032 msgid ""
dongsheng@627 15033 "<literal role=\"template-kw-filt-date\">isodate</literal>: <literal role="
dongsheng@627 15034 "\"template-keyword\">date</literal> keyword. Render the date as a text "
dongsheng@627 15035 "string in ISO 8601 format. Yields a string like <quote><literal>2006-09-04 "
dongsheng@627 15036 "15:13:13 -0700</literal></quote>."
dongsheng@627 15037 msgstr ""
dongsheng@627 15038
dongsheng@627 15039 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 15040 #: ../en/ch11-template.xml:353
dongsheng@627 15041 msgid ""
dongsheng@627 15042 "<literal role=\"template-filter\">obfuscate</literal>: Any text, but most "
dongsheng@627 15043 "useful for the <literal role=\"template-keyword\">author</literal> keyword. "
dongsheng@627 15044 "Yield the input text rendered as a sequence of XML entities. This helps to "
dongsheng@627 15045 "defeat some particularly stupid screen-scraping email harvesting spambots."
dongsheng@627 15046 msgstr ""
dongsheng@627 15047
dongsheng@627 15048 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 15049 #: ../en/ch11-template.xml:361
dongsheng@627 15050 msgid ""
dongsheng@627 15051 "<literal role=\"template-kw-filt-author\">person</literal>: Any text, but "
dongsheng@627 15052 "most useful for the <literal role=\"template-keyword\">author</literal> "
dongsheng@627 15053 "keyword. Yield the text before an email address. For example, "
dongsheng@627 15054 "<quote><literal>Bryan O'Sullivan &lt;bos@serpentine.com&gt;</literal></quote> "
dongsheng@627 15055 "becomes <quote><literal>Bryan O'Sullivan</literal></quote>."
dongsheng@627 15056 msgstr ""
dongsheng@627 15057
dongsheng@627 15058 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 15059 #: ../en/ch11-template.xml:370
dongsheng@627 15060 msgid ""
dongsheng@627 15061 "<literal role=\"template-kw-filt-date\">rfc822date</literal>: <literal role="
dongsheng@627 15062 "\"template-keyword\">date</literal> keyword. Render a date using the same "
dongsheng@627 15063 "format used in email headers. Yields a string like <quote><literal>Mon, 04 "
dongsheng@627 15064 "Sep 2006 15:13:13 -0700</literal></quote>."
dongsheng@627 15065 msgstr ""
dongsheng@627 15066
dongsheng@627 15067 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 15068 #: ../en/ch11-template.xml:377
dongsheng@627 15069 msgid ""
dongsheng@627 15070 "<literal role=\"template-kw-filt-node\">short</literal>: Changeset hash. "
dongsheng@627 15071 "Yield the short form of a changeset hash, i.e. a 12-character hexadecimal "
dongsheng@627 15072 "string."
dongsheng@627 15073 msgstr ""
dongsheng@627 15074
dongsheng@627 15075 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 15076 #: ../en/ch11-template.xml:382
dongsheng@627 15077 msgid ""
dongsheng@627 15078 "<literal role=\"template-kw-filt-date\">shortdate</literal>: <literal role="
dongsheng@627 15079 "\"template-keyword\">date</literal> keyword. Render the year, month, and day "
dongsheng@627 15080 "of the date. Yields a string like <quote><literal>2006-09-04</literal></"
dongsheng@627 15081 "quote>."
dongsheng@627 15082 msgstr ""
dongsheng@627 15083
dongsheng@627 15084 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 15085 #: ../en/ch11-template.xml:388
dongsheng@627 15086 msgid ""
dongsheng@627 15087 "<literal role=\"template-filter\">strip</literal>: Any text. Strip all "
dongsheng@627 15088 "leading and trailing whitespace from the string."
dongsheng@627 15089 msgstr ""
dongsheng@627 15090
dongsheng@627 15091 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 15092 #: ../en/ch11-template.xml:392
dongsheng@627 15093 msgid ""
dongsheng@627 15094 "<literal role=\"template-filter\">tabindent</literal>: Any text. Yield the "
dongsheng@627 15095 "text, with every line except the first starting with a tab character."
dongsheng@627 15096 msgstr ""
dongsheng@627 15097
dongsheng@627 15098 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 15099 #: ../en/ch11-template.xml:397
dongsheng@627 15100 msgid ""
dongsheng@627 15101 "<literal role=\"template-filter\">urlescape</literal>: Any text. Escape all "
dongsheng@627 15102 "characters that are considered <quote>special</quote> by URL parsers. For "
dongsheng@627 15103 "example, <literal>foo bar</literal> becomes <literal>foo%20bar</literal>."
dongsheng@627 15104 msgstr ""
dongsheng@627 15105
dongsheng@627 15106 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 15107 #: ../en/ch11-template.xml:404
dongsheng@627 15108 msgid ""
dongsheng@627 15109 "<literal role=\"template-kw-filt-author\">user</literal>: Any text, but most "
dongsheng@627 15110 "useful for the <literal role=\"template-keyword\">author</literal> keyword. "
dongsheng@627 15111 "Return the <quote>user</quote> portion of an email address. For example, "
dongsheng@627 15112 "<quote><literal>Bryan O'Sullivan &lt;bos@serpentine.com&gt;</literal></quote> "
dongsheng@627 15113 "becomes <quote><literal>bos</literal></quote>."
dongsheng@627 15114 msgstr ""
dongsheng@627 15115
dongsheng@627 15116 #. type: Content of: <book><chapter><sect1><note><para>
dongsheng@714 15117 #: ../en/ch11-template.xml:418
dongsheng@627 15118 msgid ""
dongsheng@627 15119 "If you try to apply a filter to a piece of data that it cannot process, "
dongsheng@627 15120 "Mercurial will fail and print a Python exception. For example, trying to run "
dongsheng@627 15121 "the output of the <literal role=\"template-keyword\">desc</literal> keyword "
dongsheng@627 15122 "into the <literal role=\"template-kw-filt-date\">isodate</literal> filter is "
dongsheng@627 15123 "not a good idea."
dongsheng@627 15124 msgstr ""
dongsheng@627 15125
dongsheng@627 15126 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 15127 #: ../en/ch11-template.xml:427
dongsheng@627 15128 msgid "Combining filters"
dongsheng@636 15129 msgstr "组合过滤器"
dongsheng@627 15130
dongsheng@627 15131 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 15132 #: ../en/ch11-template.xml:429
dongsheng@627 15133 msgid ""
dongsheng@627 15134 "It is easy to combine filters to yield output in the form you would like. "
dongsheng@627 15135 "The following chain of filters tidies up a description, then makes sure that "
dongsheng@627 15136 "it fits cleanly into 68 columns, then indents it by a further 8 characters "
dongsheng@627 15137 "(at least on Unix-like systems, where a tab is conventionally 8 characters "
dongsheng@627 15138 "wide)."
dongsheng@627 15139 msgstr ""
dongsheng@627 15140
dongsheng@627 15141 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 15142 #: ../en/ch11-template.xml:438
dongsheng@627 15143 msgid ""
dongsheng@627 15144 "Note the use of <quote><literal>\\t</literal></quote> (a tab character) in "
dongsheng@627 15145 "the template to force the first line to be indented; this is necessary since "
dongsheng@627 15146 "<literal role=\"template-keyword\">tabindent</literal> indents all lines "
dongsheng@627 15147 "<emphasis>except</emphasis> the first."
dongsheng@627 15148 msgstr ""
dongsheng@627 15149
dongsheng@627 15150 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 15151 #: ../en/ch11-template.xml:444
dongsheng@627 15152 msgid ""
dongsheng@627 15153 "Keep in mind that the order of filters in a chain is significant. The first "
dongsheng@627 15154 "filter is applied to the result of the keyword; the second to the result of "
dongsheng@627 15155 "the first filter; and so on. For example, using <literal>fill68|tabindent</"
dongsheng@627 15156 "literal> gives very different results from <literal>tabindent|fill68</"
dongsheng@627 15157 "literal>."
dongsheng@627 15158 msgstr ""
dongsheng@627 15159
dongsheng@627 15160 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 15161 #: ../en/ch11-template.xml:454
dongsheng@627 15162 msgid "From templates to styles"
dongsheng@636 15163 msgstr "从模版到样式"
dongsheng@627 15164
dongsheng@627 15165 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 15166 #: ../en/ch11-template.xml:456
dongsheng@627 15167 msgid ""
dongsheng@627 15168 "A command line template provides a quick and simple way to format some "
dongsheng@627 15169 "output. Templates can become verbose, though, and it's useful to be able to "
dongsheng@627 15170 "give a template a name. A style file is a template with a name, stored in a "
dongsheng@627 15171 "file."
dongsheng@627 15172 msgstr ""
dongsheng@627 15173
dongsheng@627 15174 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 15175 #: ../en/ch11-template.xml:461
dongsheng@627 15176 msgid ""
dongsheng@627 15177 "More than that, using a style file unlocks the power of Mercurial's "
dongsheng@627 15178 "templating engine in ways that are not possible using the command line "
dongsheng@627 15179 "<option role=\"hg-opt-log\">--template</option> option."
dongsheng@627 15180 msgstr ""
dongsheng@627 15181
dongsheng@627 15182 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 15183 #: ../en/ch11-template.xml:467
dongsheng@627 15184 msgid "The simplest of style files"
dongsheng@636 15185 msgstr "最简单的样式文件"
dongsheng@627 15186
dongsheng@627 15187 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 15188 #: ../en/ch11-template.xml:469
dongsheng@627 15189 msgid "Our simple style file contains just one line:"
dongsheng@627 15190 msgstr ""
dongsheng@627 15191
dongsheng@627 15192 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 15193 #: ../en/ch11-template.xml:473
dongsheng@627 15194 msgid ""
dongsheng@627 15195 "This tells Mercurial, <quote>if you're printing a changeset, use the text on "
dongsheng@627 15196 "the right as the template</quote>."
dongsheng@627 15197 msgstr ""
dongsheng@627 15198
dongsheng@627 15199 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 15200 #: ../en/ch11-template.xml:479
dongsheng@627 15201 msgid "Style file syntax"
dongsheng@636 15202 msgstr "样式文件语法"
dongsheng@627 15203
dongsheng@627 15204 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 15205 #: ../en/ch11-template.xml:481
dongsheng@627 15206 msgid "The syntax rules for a style file are simple."
dongsheng@627 15207 msgstr ""
dongsheng@627 15208
dongsheng@627 15209 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 15210 #: ../en/ch11-template.xml:484
dongsheng@627 15211 msgid "The file is processed one line at a time."
dongsheng@627 15212 msgstr ""
dongsheng@627 15213
dongsheng@627 15214 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 15215 #: ../en/ch11-template.xml:487
dongsheng@627 15216 msgid "Leading and trailing white space are ignored."
dongsheng@627 15217 msgstr ""
dongsheng@627 15218
dongsheng@627 15219 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 15220 #: ../en/ch11-template.xml:490
songdongsheng@658 15221 msgid "Empty lines are skipped."
songdongsheng@658 15222 msgstr ""
songdongsheng@658 15223
songdongsheng@658 15224 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 15225 #: ../en/ch11-template.xml:492
dongsheng@627 15226 msgid ""
dongsheng@627 15227 "If a line starts with either of the characters <quote><literal>#</literal></"
dongsheng@627 15228 "quote> or <quote><literal>;</literal></quote>, the entire line is treated as "
dongsheng@627 15229 "a comment, and skipped as if empty."
dongsheng@627 15230 msgstr ""
dongsheng@627 15231
dongsheng@627 15232 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 15233 #: ../en/ch11-template.xml:497
dongsheng@627 15234 msgid ""
dongsheng@627 15235 "A line starts with a keyword. This must start with an alphabetic character "
dongsheng@627 15236 "or underscore, and can subsequently contain any alphanumeric character or "
dongsheng@627 15237 "underscore. (In regexp notation, a keyword must match <literal>[A-Za-z_][A-"
dongsheng@627 15238 "Za-z0-9_]*</literal>.)"
dongsheng@627 15239 msgstr ""
dongsheng@627 15240
dongsheng@627 15241 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 15242 #: ../en/ch11-template.xml:503
dongsheng@627 15243 msgid ""
dongsheng@627 15244 "The next element must be an <quote><literal>=</literal></quote> character, "
dongsheng@627 15245 "which can be preceded or followed by an arbitrary amount of white space."
dongsheng@627 15246 msgstr ""
dongsheng@627 15247
dongsheng@627 15248 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 15249 #: ../en/ch11-template.xml:508
dongsheng@627 15250 msgid ""
dongsheng@627 15251 "If the rest of the line starts and ends with matching quote characters "
dongsheng@627 15252 "(either single or double quote), it is treated as a template body."
dongsheng@627 15253 msgstr ""
dongsheng@627 15254
dongsheng@627 15255 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 15256 #: ../en/ch11-template.xml:512
dongsheng@627 15257 msgid ""
dongsheng@627 15258 "If the rest of the line <emphasis>does not</emphasis> start with a quote "
dongsheng@627 15259 "character, it is treated as the name of a file; the contents of this file "
dongsheng@627 15260 "will be read and used as a template body."
dongsheng@627 15261 msgstr ""
dongsheng@627 15262
dongsheng@627 15263 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 15264 #: ../en/ch11-template.xml:521
dongsheng@627 15265 msgid "Style files by example"
dongsheng@636 15266 msgstr "样式文件例子"
dongsheng@627 15267
dongsheng@627 15268 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 15269 #: ../en/ch11-template.xml:523
dongsheng@627 15270 msgid ""
dongsheng@627 15271 "To illustrate how to write a style file, we will construct a few by example. "
dongsheng@627 15272 "Rather than provide a complete style file and walk through it, we'll mirror "
dongsheng@627 15273 "the usual process of developing a style file by starting with something very "
dongsheng@627 15274 "simple, and walking through a series of successively more complete examples."
dongsheng@627 15275 msgstr ""
dongsheng@627 15276
dongsheng@627 15277 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 15278 #: ../en/ch11-template.xml:530
dongsheng@627 15279 msgid "Identifying mistakes in style files"
dongsheng@636 15280 msgstr "在样式文件中定位错误"
dongsheng@627 15281
dongsheng@627 15282 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 15283 #: ../en/ch11-template.xml:532
dongsheng@627 15284 msgid ""
dongsheng@627 15285 "If Mercurial encounters a problem in a style file you are working on, it "
dongsheng@627 15286 "prints a terse error message that, once you figure out what it means, is "
dongsheng@627 15287 "actually quite useful."
dongsheng@627 15288 msgstr ""
dongsheng@627 15289
dongsheng@627 15290 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 15291 #: ../en/ch11-template.xml:538
dongsheng@627 15292 msgid ""
dongsheng@627 15293 "Notice that <filename>broken.style</filename> attempts to define a "
dongsheng@627 15294 "<literal>changeset</literal> keyword, but forgets to give any content for it. "
dongsheng@627 15295 "When instructed to use this style file, Mercurial promptly complains."
dongsheng@627 15296 msgstr ""
dongsheng@627 15297
dongsheng@627 15298 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 15299 #: ../en/ch11-template.xml:545
dongsheng@627 15300 msgid "This error message looks intimidating, but it is not too hard to follow."
dongsheng@627 15301 msgstr ""
dongsheng@627 15302
dongsheng@627 15303 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 15304 #: ../en/ch11-template.xml:549
dongsheng@627 15305 msgid ""
dongsheng@627 15306 "The first component is simply Mercurial's way of saying <quote>I am giving "
dongsheng@627 15307 "up</quote>."
dongsheng@627 15308 msgstr ""
dongsheng@627 15309
dongsheng@627 15310 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 15311 #: ../en/ch11-template.xml:553
dongsheng@627 15312 msgid "Next comes the name of the style file that contains the error."
dongsheng@627 15313 msgstr ""
dongsheng@627 15314
dongsheng@627 15315 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 15316 #: ../en/ch11-template.xml:557
dongsheng@627 15317 msgid ""
dongsheng@627 15318 "Following the file name is the line number where the error was encountered."
dongsheng@627 15319 msgstr ""
dongsheng@627 15320
dongsheng@627 15321 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 15322 #: ../en/ch11-template.xml:561
dongsheng@627 15323 msgid "Finally, a description of what went wrong."
dongsheng@627 15324 msgstr ""
dongsheng@627 15325
dongsheng@627 15326 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 15327 #: ../en/ch11-template.xml:565
dongsheng@627 15328 msgid ""
dongsheng@627 15329 "The description of the problem is not always clear (as in this case), but "
dongsheng@627 15330 "even when it is cryptic, it is almost always trivial to visually inspect the "
dongsheng@627 15331 "offending line in the style file and see what is wrong."
dongsheng@627 15332 msgstr ""
dongsheng@627 15333
dongsheng@627 15334 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 15335 #: ../en/ch11-template.xml:574
dongsheng@627 15336 msgid "Uniquely identifying a repository"
dongsheng@636 15337 msgstr "版本库的唯一标识"
dongsheng@627 15338
dongsheng@627 15339 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 15340 #: ../en/ch11-template.xml:576
dongsheng@627 15341 msgid ""
dongsheng@627 15342 "If you would like to be able to identify a Mercurial repository <quote>fairly "
dongsheng@627 15343 "uniquely</quote> using a short string as an identifier, you can use the first "
dongsheng@627 15344 "revision in the repository."
dongsheng@627 15345 msgstr ""
dongsheng@627 15346
dongsheng@627 15347 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 15348 #: ../en/ch11-template.xml:583
dongsheng@714 15349 msgid ""
dongsheng@714 15350 "This is likely to be unique, and so it is useful in many cases. There are a "
dongsheng@714 15351 "few caveats."
dongsheng@627 15352 msgstr ""
dongsheng@627 15353
dongsheng@627 15354 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 15355 #: ../en/ch11-template.xml:586
dongsheng@627 15356 msgid ""
dongsheng@627 15357 "It will not work in a completely empty repository, because such a repository "
dongsheng@627 15358 "does not have a revision zero."
dongsheng@627 15359 msgstr ""
dongsheng@627 15360
dongsheng@627 15361 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 15362 #: ../en/ch11-template.xml:590
dongsheng@627 15363 msgid ""
dongsheng@627 15364 "Neither will it work in the (extremely rare) case where a repository is a "
dongsheng@627 15365 "merge of two or more formerly independent repositories, and you still have "
dongsheng@627 15366 "those repositories around."
dongsheng@627 15367 msgstr ""
dongsheng@627 15368
dongsheng@627 15369 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 15370 #: ../en/ch11-template.xml:595
dongsheng@627 15371 msgid "Here are some uses to which you could put this identifier:"
dongsheng@627 15372 msgstr ""
dongsheng@627 15373
dongsheng@627 15374 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 15375 #: ../en/ch11-template.xml:598
dongsheng@627 15376 msgid ""
dongsheng@627 15377 "As a key into a table for a database that manages repositories on a server."
dongsheng@627 15378 msgstr ""
dongsheng@627 15379
dongsheng@627 15380 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 15381 #: ../en/ch11-template.xml:601
dongsheng@627 15382 msgid ""
dongsheng@627 15383 "As half of a {<emphasis>repository ID</emphasis>, <emphasis>revision ID</"
dongsheng@627 15384 "emphasis>} tuple. Save this information away when you run an automated build "
dongsheng@627 15385 "or other activity, so that you can <quote>replay</quote> the build later if "
dongsheng@627 15386 "necessary."
dongsheng@627 15387 msgstr ""
dongsheng@627 15388
dongsheng@627 15389 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 15390 #: ../en/ch11-template.xml:611
dongsheng@714 15391 msgid "Listing files on multiple lines"
dongsheng@716 15392 msgstr "每行列出一个文件"
dongsheng@714 15393
dongsheng@714 15394 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 15395 #: ../en/ch11-template.xml:613
dongsheng@714 15396 msgid ""
dongsheng@714 15397 "Suppose we want to list the files changed by a changeset, one per line, with "
dongsheng@714 15398 "a little indentation before each file name."
dongsheng@714 15399 msgstr ""
dongsheng@714 15400
dongsheng@714 15401 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 15402 #: ../en/ch11-template.xml:621
dongsheng@627 15403 msgid "Mimicking Subversion's output"
dongsheng@636 15404 msgstr "模仿 Subversion 的输出"
dongsheng@627 15405
dongsheng@627 15406 #
dongsheng@627 15407 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 15408 #: ../en/ch11-template.xml:623
dongsheng@627 15409 msgid ""
dongsheng@627 15410 "Let's try to emulate the default output format used by another revision "
dongsheng@627 15411 "control tool, Subversion."
dongsheng@627 15412 msgstr ""
dongsheng@627 15413
dongsheng@627 15414 #
dongsheng@627 15415 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 15416 #: ../en/ch11-template.xml:628
dongsheng@627 15417 msgid ""
dongsheng@627 15418 "Since Subversion's output style is fairly simple, it is easy to copy-and-"
dongsheng@627 15419 "paste a hunk of its output into a file, and replace the text produced above "
dongsheng@627 15420 "by Subversion with the template values we'd like to see expanded."
dongsheng@627 15421 msgstr ""
dongsheng@627 15422
dongsheng@627 15423 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 15424 #: ../en/ch11-template.xml:635
dongsheng@627 15425 msgid ""
dongsheng@627 15426 "There are a few small ways in which this template deviates from the output "
dongsheng@627 15427 "produced by Subversion."
dongsheng@627 15428 msgstr ""
dongsheng@627 15429
dongsheng@627 15430 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 15431 #: ../en/ch11-template.xml:638
dongsheng@627 15432 msgid ""
dongsheng@627 15433 "Subversion prints a <quote>readable</quote> date (the <quote><literal>Wed, 27 "
dongsheng@627 15434 "Sep 2006</literal></quote> in the example output above) in parentheses. "
dongsheng@627 15435 "Mercurial's templating engine does not provide a way to display a date in "
dongsheng@627 15436 "this format without also printing the time and time zone."
dongsheng@627 15437 msgstr ""
dongsheng@627 15438
dongsheng@627 15439 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 15440 #: ../en/ch11-template.xml:645
dongsheng@627 15441 msgid ""
dongsheng@627 15442 "We emulate Subversion's printing of <quote>separator</quote> lines full of "
dongsheng@627 15443 "<quote><literal>-</literal></quote> characters by ending the template with "
dongsheng@627 15444 "such a line. We use the templating engine's <literal role=\"template-keyword"
dongsheng@627 15445 "\">header</literal> keyword to print a separator line as the first line of "
dongsheng@627 15446 "output (see below), thus achieving similar output to Subversion."
dongsheng@627 15447 msgstr ""
dongsheng@627 15448
dongsheng@627 15449 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 15450 #: ../en/ch11-template.xml:654
dongsheng@627 15451 msgid ""
dongsheng@627 15452 "Subversion's output includes a count in the header of the number of lines in "
dongsheng@627 15453 "the commit message. We cannot replicate this in Mercurial; the templating "
dongsheng@627 15454 "engine does not currently provide a filter that counts the number of lines "
dongsheng@627 15455 "the template generates."
dongsheng@627 15456 msgstr ""
dongsheng@627 15457
dongsheng@627 15458 #
dongsheng@627 15459 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 15460 #: ../en/ch11-template.xml:660
dongsheng@627 15461 msgid ""
dongsheng@627 15462 "It took me no more than a minute or two of work to replace literal text from "
dongsheng@627 15463 "an example of Subversion's output with some keywords and filters to give the "
dongsheng@627 15464 "template above. The style file simply refers to the template."
dongsheng@627 15465 msgstr ""
dongsheng@627 15466
dongsheng@627 15467 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 15468 #: ../en/ch11-template.xml:667
dongsheng@627 15469 msgid ""
dongsheng@627 15470 "We could have included the text of the template file directly in the style "
dongsheng@627 15471 "file by enclosing it in quotes and replacing the newlines with "
dongsheng@627 15472 "<quote><literal>\\n</literal></quote> sequences, but it would have made the "
dongsheng@627 15473 "style file too difficult to read. Readability is a good guide when you're "
dongsheng@627 15474 "trying to decide whether some text belongs in a style file, or in a template "
dongsheng@627 15475 "file that the style file points to. If the style file will look too big or "
dongsheng@627 15476 "cluttered if you insert a literal piece of text, drop it into a template "
dongsheng@627 15477 "instead."
dongsheng@627 15478 msgstr ""
dongsheng@627 15479
dongsheng@627 15480 #. type: Content of: <book><chapter><title>
dongsheng@714 15481 #: ../en/ch12-mq.xml:5
dongsheng@627 15482 msgid "Managing change with Mercurial Queues"
dongsheng@627 15483 msgstr "使用 MQ 管理修改"
dongsheng@627 15484
dongsheng@627 15485 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 15486 #: ../en/ch12-mq.xml:8
dongsheng@627 15487 msgid "The patch management problem"
dongsheng@636 15488 msgstr "补丁的管理问题"
dongsheng@627 15489
dongsheng@627 15490 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 15491 #: ../en/ch12-mq.xml:10
dongsheng@627 15492 msgid ""
dongsheng@627 15493 "Here is a common scenario: you need to install a software package from "
dongsheng@627 15494 "source, but you find a bug that you must fix in the source before you can "
dongsheng@627 15495 "start using the package. You make your changes, forget about the package for "
dongsheng@627 15496 "a while, and a few months later you need to upgrade to a newer version of the "
dongsheng@627 15497 "package. If the newer version of the package still has the bug, you must "
dongsheng@627 15498 "extract your fix from the older source tree and apply it against the newer "
dongsheng@627 15499 "version. This is a tedious task, and it's easy to make mistakes."
dongsheng@627 15500 msgstr ""
dongsheng@627 15501
dongsheng@627 15502 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 15503 #: ../en/ch12-mq.xml:20
dongsheng@627 15504 msgid ""
dongsheng@627 15505 "This is a simple case of the <quote>patch management</quote> problem. You "
dongsheng@627 15506 "have an <quote>upstream</quote> source tree that you can't change; you need "
dongsheng@627 15507 "to make some local changes on top of the upstream tree; and you'd like to be "
dongsheng@627 15508 "able to keep those changes separate, so that you can apply them to newer "
dongsheng@627 15509 "versions of the upstream source."
dongsheng@627 15510 msgstr ""
dongsheng@627 15511
dongsheng@627 15512 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 15513 #: ../en/ch12-mq.xml:27
dongsheng@627 15514 msgid ""
dongsheng@627 15515 "The patch management problem arises in many situations. Probably the most "
dongsheng@627 15516 "visible is that a user of an open source software project will contribute a "
dongsheng@627 15517 "bug fix or new feature to the project's maintainers in the form of a patch."
dongsheng@627 15518 msgstr ""
dongsheng@627 15519
dongsheng@627 15520 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 15521 #: ../en/ch12-mq.xml:32
dongsheng@627 15522 msgid ""
dongsheng@627 15523 "Distributors of operating systems that include open source software often "
dongsheng@627 15524 "need to make changes to the packages they distribute so that they will build "
dongsheng@627 15525 "properly in their environments."
dongsheng@627 15526 msgstr ""
dongsheng@627 15527
dongsheng@627 15528 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 15529 #: ../en/ch12-mq.xml:37
dongsheng@627 15530 msgid ""
dongsheng@627 15531 "When you have few changes to maintain, it is easy to manage a single patch "
dongsheng@627 15532 "using the standard <command>diff</command> and <command>patch</command> "
songdongsheng@658 15533 "programs (see <xref linkend=\"sec:mq:patch\"/> for a discussion of these "
songdongsheng@658 15534 "tools). Once the number of changes grows, it starts to make sense to maintain "
songdongsheng@658 15535 "patches as discrete <quote>chunks of work,</quote> so that for example a "
songdongsheng@658 15536 "single patch will contain only one bug fix (the patch might modify several "
songdongsheng@658 15537 "files, but it's doing <quote>only one thing</quote>), and you may have a "
songdongsheng@658 15538 "number of such patches for different bugs you need fixed and local changes "
songdongsheng@658 15539 "you require. In this situation, if you submit a bug fix patch to the "
dongsheng@627 15540 "upstream maintainers of a package and they include your fix in a subsequent "
dongsheng@627 15541 "release, you can simply drop that single patch when you're updating to the "
dongsheng@627 15542 "newer release."
dongsheng@627 15543 msgstr ""
dongsheng@627 15544
dongsheng@627 15545 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 15546 #: ../en/ch12-mq.xml:52
dongsheng@627 15547 msgid ""
dongsheng@627 15548 "Maintaining a single patch against an upstream tree is a little tedious and "
dongsheng@627 15549 "error-prone, but not difficult. However, the complexity of the problem grows "
dongsheng@627 15550 "rapidly as the number of patches you have to maintain increases. With more "
dongsheng@627 15551 "than a tiny number of patches in hand, understanding which ones you have "
dongsheng@627 15552 "applied and maintaining them moves from messy to overwhelming."
dongsheng@627 15553 msgstr ""
dongsheng@627 15554
dongsheng@627 15555 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 15556 #: ../en/ch12-mq.xml:59
dongsheng@627 15557 msgid ""
dongsheng@627 15558 "Fortunately, Mercurial includes a powerful extension, Mercurial Queues (or "
dongsheng@627 15559 "simply <quote>MQ</quote>), that massively simplifies the patch management "
dongsheng@627 15560 "problem."
dongsheng@627 15561 msgstr ""
dongsheng@627 15562
dongsheng@627 15563 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 15564 #: ../en/ch12-mq.xml:65
dongsheng@627 15565 msgid "The prehistory of Mercurial Queues"
dongsheng@636 15566 msgstr "MQ 的历史"
dongsheng@627 15567
dongsheng@627 15568 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 15569 #: ../en/ch12-mq.xml:67
dongsheng@627 15570 msgid ""
dongsheng@627 15571 "During the late 1990s, several Linux kernel developers started to maintain "
songdongsheng@710 15572 "<quote>patch series</quote> that modified the behavior of the Linux kernel. "
dongsheng@627 15573 "Some of these series were focused on stability, some on feature coverage, and "
dongsheng@627 15574 "others were more speculative."
dongsheng@627 15575 msgstr ""
dongsheng@627 15576
dongsheng@627 15577 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 15578 #: ../en/ch12-mq.xml:73
dongsheng@627 15579 msgid ""
dongsheng@627 15580 "The sizes of these patch series grew rapidly. In 2002, Andrew Morton "
dongsheng@627 15581 "published some shell scripts he had been using to automate the task of "
dongsheng@627 15582 "managing his patch queues. Andrew was successfully using these scripts to "
dongsheng@627 15583 "manage hundreds (sometimes thousands) of patches on top of the Linux kernel."
dongsheng@627 15584 msgstr ""
dongsheng@627 15585
dongsheng@627 15586 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 15587 #: ../en/ch12-mq.xml:80
dongsheng@627 15588 msgid "A patchwork quilt"
dongsheng@627 15589 msgstr ""
dongsheng@627 15590
dongsheng@627 15591 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 15592 #: ../en/ch12-mq.xml:82
dongsheng@627 15593 msgid ""
dongsheng@627 15594 "In early 2003, Andreas Gruenbacher and Martin Quinson borrowed the approach "
dongsheng@627 15595 "of Andrew's scripts and published a tool called <quote>patchwork quilt</"
dongsheng@627 15596 "quote> <citation>web:quilt</citation>, or simply <quote>quilt</quote> (see "
dongsheng@627 15597 "<citation>gruenbacher:2005</citation> for a paper describing it). Because "
dongsheng@627 15598 "quilt substantially automated patch management, it rapidly gained a large "
dongsheng@627 15599 "following among open source software developers."
dongsheng@627 15600 msgstr ""
dongsheng@627 15601
dongsheng@627 15602 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 15603 #: ../en/ch12-mq.xml:91
dongsheng@627 15604 msgid ""
dongsheng@627 15605 "Quilt manages a <emphasis>stack of patches</emphasis> on top of a directory "
dongsheng@627 15606 "tree. To begin, you tell quilt to manage a directory tree, and tell it which "
dongsheng@627 15607 "files you want to manage; it stores away the names and contents of those "
dongsheng@627 15608 "files. To fix a bug, you create a new patch (using a single command), edit "
dongsheng@627 15609 "the files you need to fix, then <quote>refresh</quote> the patch."
dongsheng@627 15610 msgstr ""
dongsheng@627 15611
dongsheng@627 15612 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 15613 #: ../en/ch12-mq.xml:99
dongsheng@627 15614 msgid ""
dongsheng@627 15615 "The refresh step causes quilt to scan the directory tree; it updates the "
dongsheng@627 15616 "patch with all of the changes you have made. You can create another patch on "
dongsheng@627 15617 "top of the first, which will track the changes required to modify the tree "
dongsheng@627 15618 "from <quote>tree with one patch applied</quote> to <quote>tree with two "
dongsheng@627 15619 "patches applied</quote>."
dongsheng@627 15620 msgstr ""
dongsheng@627 15621
dongsheng@627 15622 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 15623 #: ../en/ch12-mq.xml:106
dongsheng@627 15624 msgid ""
dongsheng@627 15625 "You can <emphasis>change</emphasis> which patches are applied to the tree. "
dongsheng@627 15626 "If you <quote>pop</quote> a patch, the changes made by that patch will vanish "
dongsheng@627 15627 "from the directory tree. Quilt remembers which patches you have popped, "
dongsheng@627 15628 "though, so you can <quote>push</quote> a popped patch again, and the "
dongsheng@627 15629 "directory tree will be restored to contain the modifications in the patch. "
dongsheng@627 15630 "Most importantly, you can run the <quote>refresh</quote> command at any time, "
dongsheng@627 15631 "and the topmost applied patch will be updated. This means that you can, at "
dongsheng@627 15632 "any time, change both which patches are applied and what modifications those "
dongsheng@627 15633 "patches make."
dongsheng@627 15634 msgstr ""
dongsheng@627 15635
dongsheng@627 15636 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 15637 #: ../en/ch12-mq.xml:118
dongsheng@627 15638 msgid ""
dongsheng@627 15639 "Quilt knows nothing about revision control tools, so it works equally well on "
dongsheng@627 15640 "top of an unpacked tarball or a Subversion working copy."
dongsheng@627 15641 msgstr ""
dongsheng@627 15642
dongsheng@627 15643 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 15644 #: ../en/ch12-mq.xml:124
dongsheng@627 15645 msgid "From patchwork quilt to Mercurial Queues"
dongsheng@636 15646 msgstr "从 patchwork quilt 到 MQ"
dongsheng@627 15647
dongsheng@627 15648 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 15649 #: ../en/ch12-mq.xml:126
dongsheng@627 15650 msgid ""
dongsheng@627 15651 "In mid-2005, Chris Mason took the features of quilt and wrote an extension "
songdongsheng@710 15652 "that he called Mercurial Queues, which added quilt-like behavior to Mercurial."
dongsheng@627 15653 msgstr ""
dongsheng@627 15654
dongsheng@627 15655 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 15656 #: ../en/ch12-mq.xml:130
dongsheng@627 15657 msgid ""
dongsheng@627 15658 "The key difference between quilt and MQ is that quilt knows nothing about "
dongsheng@627 15659 "revision control systems, while MQ is <emphasis>integrated</emphasis> into "
dongsheng@627 15660 "Mercurial. Each patch that you push is represented as a Mercurial "
dongsheng@627 15661 "changeset. Pop a patch, and the changeset goes away."
dongsheng@627 15662 msgstr ""
dongsheng@627 15663
dongsheng@627 15664 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 15665 #: ../en/ch12-mq.xml:136
dongsheng@627 15666 msgid ""
dongsheng@627 15667 "Because quilt does not care about revision control tools, it is still a "
dongsheng@627 15668 "tremendously useful piece of software to know about for situations where you "
dongsheng@627 15669 "cannot use Mercurial and MQ."
dongsheng@627 15670 msgstr ""
dongsheng@627 15671
dongsheng@627 15672 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 15673 #: ../en/ch12-mq.xml:144
dongsheng@627 15674 msgid "The huge advantage of MQ"
dongsheng@636 15675 msgstr "MQ 的巨大优势"
dongsheng@627 15676
dongsheng@627 15677 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 15678 #: ../en/ch12-mq.xml:146
dongsheng@627 15679 msgid ""
dongsheng@627 15680 "I cannot overstate the value that MQ offers through the unification of "
dongsheng@627 15681 "patches and revision control."
dongsheng@627 15682 msgstr ""
dongsheng@627 15683
dongsheng@627 15684 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 15685 #: ../en/ch12-mq.xml:149
dongsheng@627 15686 msgid ""
dongsheng@627 15687 "A major reason that patches have persisted in the free software and open "
songdongsheng@668 15688 "source world&emdash;in spite of the availability of increasingly capable "
songdongsheng@668 15689 "revision control tools over the years&emdash;is the <emphasis>agility</"
songdongsheng@668 15690 "emphasis> they offer."
dongsheng@627 15691 msgstr ""
dongsheng@627 15692
dongsheng@627 15693 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 15694 #: ../en/ch12-mq.xml:155
dongsheng@627 15695 msgid ""
dongsheng@627 15696 "Traditional revision control tools make a permanent, irreversible record of "
dongsheng@627 15697 "everything that you do. While this has great value, it's also somewhat "
dongsheng@627 15698 "stifling. If you want to perform a wild-eyed experiment, you have to be "
songdongsheng@668 15699 "careful in how you go about it, or you risk leaving unneeded&emdash;or worse, "
songdongsheng@668 15700 "misleading or destabilising&emdash;traces of your missteps and errors in the "
dongsheng@627 15701 "permanent revision record."
dongsheng@627 15702 msgstr ""
dongsheng@627 15703
dongsheng@627 15704 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 15705 #: ../en/ch12-mq.xml:163
dongsheng@627 15706 msgid ""
dongsheng@627 15707 "By contrast, MQ's marriage of distributed revision control with patches makes "
dongsheng@627 15708 "it much easier to isolate your work. Your patches live on top of normal "
dongsheng@627 15709 "revision history, and you can make them disappear or reappear at will. If "
dongsheng@627 15710 "you don't like a patch, you can drop it. If a patch isn't quite as you want "
songdongsheng@668 15711 "it to be, simply fix it&emdash;as many times as you need to, until you have "
songdongsheng@668 15712 "refined it into the form you desire."
dongsheng@627 15713 msgstr ""
dongsheng@627 15714
dongsheng@627 15715 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 15716 #: ../en/ch12-mq.xml:171
dongsheng@627 15717 msgid ""
dongsheng@627 15718 "As an example, the integration of patches with revision control makes "
songdongsheng@668 15719 "understanding patches and debugging their effects&emdash;and their interplay "
songdongsheng@668 15720 "with the code they're based on&emdash;<emphasis>enormously</emphasis> easier. "
songdongsheng@668 15721 "Since every applied patch has an associated changeset, you can give <command "
songdongsheng@668 15722 "role=\"hg-cmd\">hg log</command> a file name to see which changesets and "
songdongsheng@668 15723 "patches affected the file. You can use the <command role=\"hg-cmd\">hg "
songdongsheng@668 15724 "bisect</command> command to binary-search through all changesets and applied "
songdongsheng@668 15725 "patches to see where a bug got introduced or fixed. You can use the <command "
songdongsheng@668 15726 "role=\"hg-cmd\">hg annotate</command> command to see which changeset or patch "
songdongsheng@668 15727 "modified a particular line of a source file. And so on."
dongsheng@627 15728 msgstr ""
dongsheng@627 15729
dongsheng@627 15730 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 15731 #: ../en/ch12-mq.xml:189
dongsheng@627 15732 msgid ""
dongsheng@627 15733 "Because MQ doesn't hide its patch-oriented nature, it is helpful to "
dongsheng@627 15734 "understand what patches are, and a little about the tools that work with them."
dongsheng@627 15735 msgstr ""
dongsheng@627 15736
dongsheng@627 15737 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 15738 #: ../en/ch12-mq.xml:193
dongsheng@627 15739 msgid ""
dongsheng@627 15740 "The traditional Unix <command>diff</command> command compares two files, and "
dongsheng@627 15741 "prints a list of differences between them. The <command>patch</command> "
dongsheng@627 15742 "command understands these differences as <emphasis>modifications</emphasis> "
dongsheng@627 15743 "to make to a file. Take a look below for a simple example of these commands "
dongsheng@627 15744 "in action."
dongsheng@627 15745 msgstr ""
dongsheng@627 15746
dongsheng@627 15747 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 15748 #: ../en/ch12-mq.xml:202
dongsheng@627 15749 msgid ""
dongsheng@627 15750 "The type of file that <command>diff</command> generates (and <command>patch</"
dongsheng@627 15751 "command> takes as input) is called a <quote>patch</quote> or a <quote>diff</"
dongsheng@627 15752 "quote>; there is no difference between a patch and a diff. (We'll use the "
dongsheng@627 15753 "term <quote>patch</quote>, since it's more commonly used.)"
dongsheng@627 15754 msgstr ""
dongsheng@627 15755
dongsheng@627 15756 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 15757 #: ../en/ch12-mq.xml:208
dongsheng@627 15758 msgid ""
dongsheng@627 15759 "A patch file can start with arbitrary text; the <command>patch</command> "
dongsheng@627 15760 "command ignores this text, but MQ uses it as the commit message when creating "
dongsheng@627 15761 "changesets. To find the beginning of the patch content, <command>patch</"
dongsheng@627 15762 "command> searches for the first line that starts with the string "
dongsheng@627 15763 "<quote><literal>diff -</literal></quote>."
dongsheng@627 15764 msgstr ""
dongsheng@627 15765
dongsheng@627 15766 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 15767 #: ../en/ch12-mq.xml:215
dongsheng@627 15768 msgid ""
dongsheng@627 15769 "MQ works with <emphasis>unified</emphasis> diffs (<command>patch</command> "
dongsheng@627 15770 "can accept several other diff formats, but MQ doesn't). A unified diff "
dongsheng@627 15771 "contains two kinds of header. The <emphasis>file header</emphasis> describes "
dongsheng@627 15772 "the file being modified; it contains the name of the file to modify. When "
dongsheng@627 15773 "<command>patch</command> sees a new file header, it looks for a file with "
dongsheng@627 15774 "that name to start modifying."
dongsheng@627 15775 msgstr ""
dongsheng@627 15776
dongsheng@627 15777 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 15778 #: ../en/ch12-mq.xml:223
dongsheng@627 15779 msgid ""
dongsheng@627 15780 "After the file header comes a series of <emphasis>hunks</emphasis>. Each "
dongsheng@627 15781 "hunk starts with a header; this identifies the range of line numbers within "
dongsheng@627 15782 "the file that the hunk should modify. Following the header, a hunk starts "
dongsheng@627 15783 "and ends with a few (usually three) lines of text from the unmodified file; "
dongsheng@627 15784 "these are called the <emphasis>context</emphasis> for the hunk. If there's "
dongsheng@627 15785 "only a small amount of context between successive hunks, <command>diff</"
dongsheng@627 15786 "command> doesn't print a new hunk header; it just runs the hunks together, "
dongsheng@627 15787 "with a few lines of context between modifications."
dongsheng@627 15788 msgstr ""
dongsheng@627 15789
dongsheng@627 15790 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 15791 #: ../en/ch12-mq.xml:235
dongsheng@627 15792 msgid ""
dongsheng@627 15793 "Each line of context begins with a space character. Within the hunk, a line "
dongsheng@627 15794 "that begins with <quote><literal>-</literal></quote> means <quote>remove this "
dongsheng@627 15795 "line,</quote> while a line that begins with <quote><literal>+</literal></"
dongsheng@627 15796 "quote> means <quote>insert this line.</quote> For example, a line that is "
dongsheng@627 15797 "modified is represented by one deletion and one insertion."
dongsheng@627 15798 msgstr ""
dongsheng@627 15799
dongsheng@627 15800 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 15801 #: ../en/ch12-mq.xml:243
dongsheng@627 15802 msgid ""
songdongsheng@658 15803 "We will return to some of the more subtle aspects of patches later (in <xref "
songdongsheng@658 15804 "linkend=\"sec:mq:adv-patch\"/>), but you should have enough information now "
songdongsheng@658 15805 "to use MQ."
dongsheng@627 15806 msgstr ""
dongsheng@627 15807
dongsheng@627 15808 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 15809 #: ../en/ch12-mq.xml:250
dongsheng@627 15810 msgid "Getting started with Mercurial Queues"
dongsheng@636 15811 msgstr "开始使用 MQ"
dongsheng@627 15812
dongsheng@627 15813 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 15814 #: ../en/ch12-mq.xml:252
dongsheng@627 15815 msgid ""
dongsheng@627 15816 "Because MQ is implemented as an extension, you must explicitly enable before "
dongsheng@627 15817 "you can use it. (You don't need to download anything; MQ ships with the "
dongsheng@627 15818 "standard Mercurial distribution.) To enable MQ, edit your <filename role="
dongsheng@627 15819 "\"home\">~/.hgrc</filename> file, and add the lines below."
dongsheng@627 15820 msgstr ""
dongsheng@627 15821
dongsheng@627 15822 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 15823 #: ../en/ch12-mq.xml:262
dongsheng@627 15824 msgid ""
dongsheng@627 15825 "Once the extension is enabled, it will make a number of new commands "
dongsheng@627 15826 "available. To verify that the extension is working, you can use <command "
dongsheng@627 15827 "role=\"hg-cmd\">hg help</command> to see if the <command role=\"hg-ext-mq"
dongsheng@627 15828 "\">qinit</command> command is now available."
dongsheng@627 15829 msgstr ""
dongsheng@627 15830
dongsheng@627 15831 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 15832 #: ../en/ch12-mq.xml:270
dongsheng@627 15833 msgid ""
dongsheng@627 15834 "You can use MQ with <emphasis>any</emphasis> Mercurial repository, and its "
dongsheng@627 15835 "commands only operate within that repository. To get started, simply prepare "
dongsheng@627 15836 "the repository using the <command role=\"hg-ext-mq\">qinit</command> command."
dongsheng@627 15837 msgstr ""
dongsheng@627 15838
dongsheng@627 15839 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 15840 #: ../en/ch12-mq.xml:277
dongsheng@627 15841 msgid ""
dongsheng@627 15842 "This command creates an empty directory called <filename role=\"special\" "
dongsheng@627 15843 "class=\"directory\">.hg/patches</filename>, where MQ will keep its metadata. "
dongsheng@627 15844 "As with many Mercurial commands, the <command role=\"hg-ext-mq\">qinit</"
dongsheng@627 15845 "command> command prints nothing if it succeeds."
dongsheng@627 15846 msgstr ""
dongsheng@627 15847
dongsheng@627 15848 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 15849 #: ../en/ch12-mq.xml:284
dongsheng@627 15850 msgid "Creating a new patch"
dongsheng@636 15851 msgstr "创建新补丁"
dongsheng@627 15852
dongsheng@627 15853 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 15854 #: ../en/ch12-mq.xml:286
dongsheng@627 15855 msgid ""
dongsheng@627 15856 "To begin work on a new patch, use the <command role=\"hg-ext-mq\">qnew</"
dongsheng@627 15857 "command> command. This command takes one argument, the name of the patch to "
dongsheng@627 15858 "create."
dongsheng@627 15859 msgstr ""
dongsheng@627 15860
dongsheng@627 15861 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 15862 #: ../en/ch12-mq.xml:290
dongsheng@627 15863 msgid ""
dongsheng@627 15864 "MQ will use this as the name of an actual file in the <filename role=\"special"
dongsheng@627 15865 "\" class=\"directory\">.hg/patches</filename> directory, as you can see below."
dongsheng@627 15866 msgstr ""
dongsheng@627 15867
dongsheng@627 15868 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 15869 #: ../en/ch12-mq.xml:297
dongsheng@627 15870 msgid ""
dongsheng@627 15871 "Also newly present in the <filename role=\"special\" class=\"directory\">.hg/"
dongsheng@627 15872 "patches</filename> directory are two other files, <filename role=\"special"
dongsheng@627 15873 "\">series</filename> and <filename role=\"special\">status</filename>. The "
dongsheng@627 15874 "<filename role=\"special\">series</filename> file lists all of the patches "
dongsheng@627 15875 "that MQ knows about for this repository, with one patch per line. Mercurial "
dongsheng@627 15876 "uses the <filename role=\"special\">status</filename> file for internal book-"
dongsheng@627 15877 "keeping; it tracks all of the patches that MQ has <emphasis>applied</"
dongsheng@627 15878 "emphasis> in this repository."
dongsheng@627 15879 msgstr ""
dongsheng@627 15880
dongsheng@627 15881 #. type: Content of: <book><chapter><sect1><sect2><note><para>
dongsheng@714 15882 #: ../en/ch12-mq.xml:309
dongsheng@627 15883 msgid ""
dongsheng@627 15884 "You may sometimes want to edit the <filename role=\"special\">series</"
dongsheng@627 15885 "filename> file by hand; for example, to change the sequence in which some "
dongsheng@627 15886 "patches are applied. However, manually editing the <filename role=\"special"
dongsheng@627 15887 "\">status</filename> file is almost always a bad idea, as it's easy to "
dongsheng@627 15888 "corrupt MQ's idea of what is happening."
dongsheng@627 15889 msgstr ""
dongsheng@627 15890
dongsheng@627 15891 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 15892 #: ../en/ch12-mq.xml:318
dongsheng@627 15893 msgid ""
dongsheng@627 15894 "Once you have created your new patch, you can edit files in the working "
dongsheng@627 15895 "directory as you usually would. All of the normal Mercurial commands, such "
dongsheng@627 15896 "as <command role=\"hg-cmd\">hg diff</command> and <command role=\"hg-cmd\">hg "
dongsheng@627 15897 "annotate</command>, work exactly as they did before."
dongsheng@627 15898 msgstr ""
dongsheng@627 15899
dongsheng@627 15900 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 15901 #: ../en/ch12-mq.xml:326
dongsheng@627 15902 msgid "Refreshing a patch"
dongsheng@636 15903 msgstr "刷新补丁"
dongsheng@627 15904
dongsheng@627 15905 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 15906 #: ../en/ch12-mq.xml:328
dongsheng@627 15907 msgid ""
dongsheng@627 15908 "When you reach a point where you want to save your work, use the <command "
dongsheng@627 15909 "role=\"hg-ext-mq\">qrefresh</command> command to update the patch you are "
dongsheng@627 15910 "working on."
dongsheng@627 15911 msgstr ""
dongsheng@627 15912
dongsheng@627 15913 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 15914 #: ../en/ch12-mq.xml:334
dongsheng@627 15915 msgid ""
dongsheng@627 15916 "This command folds the changes you have made in the working directory into "
dongsheng@627 15917 "your patch, and updates its corresponding changeset to contain those changes."
dongsheng@627 15918 msgstr ""
dongsheng@627 15919
dongsheng@627 15920 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 15921 #: ../en/ch12-mq.xml:338
dongsheng@627 15922 msgid ""
dongsheng@627 15923 "You can run <command role=\"hg-ext-mq\">qrefresh</command> as often as you "
dongsheng@627 15924 "like, so it's a good way to <quote>checkpoint</quote> your work. Refresh "
dongsheng@627 15925 "your patch at an opportune time; try an experiment; and if the experiment "
dongsheng@627 15926 "doesn't work out, <command role=\"hg-cmd\">hg revert</command> your "
dongsheng@627 15927 "modifications back to the last time you refreshed."
dongsheng@627 15928 msgstr ""
dongsheng@627 15929
dongsheng@627 15930 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 15931 #: ../en/ch12-mq.xml:349
dongsheng@627 15932 msgid "Stacking and tracking patches"
dongsheng@636 15933 msgstr "堆叠和跟踪补丁"
dongsheng@627 15934
dongsheng@627 15935 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 15936 #: ../en/ch12-mq.xml:351
dongsheng@627 15937 msgid ""
dongsheng@627 15938 "Once you have finished working on a patch, or need to work on another, you "
dongsheng@627 15939 "can use the <command role=\"hg-ext-mq\">qnew</command> command again to "
dongsheng@627 15940 "create a new patch. Mercurial will apply this patch on top of your existing "
dongsheng@627 15941 "patch."
dongsheng@627 15942 msgstr ""
dongsheng@627 15943
dongsheng@627 15944 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 15945 #: ../en/ch12-mq.xml:359
dongsheng@627 15946 msgid ""
dongsheng@627 15947 "Notice that the patch contains the changes in our prior patch as part of its "
dongsheng@627 15948 "context (you can see this more clearly in the output of <command role=\"hg-cmd"
dongsheng@627 15949 "\">hg annotate</command>)."
dongsheng@627 15950 msgstr ""
dongsheng@627 15951
dongsheng@627 15952 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 15953 #: ../en/ch12-mq.xml:364
dongsheng@627 15954 msgid ""
dongsheng@627 15955 "So far, with the exception of <command role=\"hg-ext-mq\">qnew</command> and "
dongsheng@627 15956 "<command role=\"hg-ext-mq\">qrefresh</command>, we've been careful to only "
dongsheng@627 15957 "use regular Mercurial commands. However, MQ provides many commands that are "
dongsheng@627 15958 "easier to use when you are thinking about patches, as illustrated below."
dongsheng@627 15959 msgstr ""
dongsheng@627 15960
dongsheng@627 15961 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 15962 #: ../en/ch12-mq.xml:374
dongsheng@627 15963 msgid ""
dongsheng@627 15964 "The <command role=\"hg-ext-mq\">qseries</command> command lists every patch "
dongsheng@627 15965 "that MQ knows about in this repository, from oldest to newest (most recently "
dongsheng@627 15966 "<emphasis>created</emphasis>)."
dongsheng@627 15967 msgstr ""
dongsheng@627 15968
dongsheng@627 15969 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 15970 #: ../en/ch12-mq.xml:380
dongsheng@627 15971 msgid ""
dongsheng@627 15972 "The <command role=\"hg-ext-mq\">qapplied</command> command lists every patch "
dongsheng@627 15973 "that MQ has <emphasis>applied</emphasis> in this repository, again from "
dongsheng@627 15974 "oldest to newest (most recently applied)."
dongsheng@627 15975 msgstr ""
dongsheng@627 15976
dongsheng@627 15977 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 15978 #: ../en/ch12-mq.xml:389
dongsheng@627 15979 msgid "Manipulating the patch stack"
dongsheng@636 15980 msgstr "操作补丁堆栈"
dongsheng@627 15981
dongsheng@627 15982 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 15983 #: ../en/ch12-mq.xml:391
dongsheng@627 15984 msgid ""
dongsheng@627 15985 "The previous discussion implied that there must be a difference between "
dongsheng@627 15986 "<quote>known</quote> and <quote>applied</quote> patches, and there is. MQ "
dongsheng@627 15987 "can manage a patch without it being applied in the repository."
dongsheng@627 15988 msgstr ""
dongsheng@627 15989
dongsheng@627 15990 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 15991 #: ../en/ch12-mq.xml:396
dongsheng@627 15992 msgid ""
dongsheng@627 15993 "An <emphasis>applied</emphasis> patch has a corresponding changeset in the "
dongsheng@627 15994 "repository, and the effects of the patch and changeset are visible in the "
dongsheng@627 15995 "working directory. You can undo the application of a patch using the "
dongsheng@627 15996 "<command role=\"hg-ext-mq\">qpop</command> command. MQ still <emphasis>knows "
dongsheng@627 15997 "about</emphasis>, or manages, a popped patch, but the patch no longer has a "
dongsheng@627 15998 "corresponding changeset in the repository, and the working directory does not "
songdongsheng@658 15999 "contain the changes made by the patch. <xref linkend=\"fig:mq:stack\"/> "
songdongsheng@658 16000 "illustrates the difference between applied and tracked patches."
songdongsheng@658 16001 msgstr ""
songdongsheng@658 16002
songdongsheng@658 16003 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
dongsheng@714 16004 #: ../en/ch12-mq.xml:409
songdongsheng@658 16005 msgid "Applied and unapplied patches in the MQ patch stack"
dongsheng@660 16006 msgstr "在 MQ 补丁堆栈中应用和撤销补丁"
songdongsheng@658 16007
songdongsheng@658 16008 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
dongsheng@714 16009 #: ../en/ch12-mq.xml:412
songdongsheng@658 16010 msgid "<imageobject><imagedata fileref=\"figs/mq-stack.png\"/></imageobject>"
dongsheng@627 16011 msgstr ""
dongsheng@627 16012
dongsheng@627 16013 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 16014 #: ../en/ch12-mq.xml:417
dongsheng@627 16015 msgid ""
dongsheng@627 16016 "You can reapply an unapplied, or popped, patch using the <command role=\"hg-"
dongsheng@627 16017 "ext-mq\">qpush</command> command. This creates a new changeset to correspond "
dongsheng@627 16018 "to the patch, and the patch's changes once again become present in the "
dongsheng@627 16019 "working directory. See below for examples of <command role=\"hg-ext-mq"
dongsheng@627 16020 "\">qpop</command> and <command role=\"hg-ext-mq\">qpush</command> in action."
dongsheng@627 16021 msgstr ""
dongsheng@627 16022
dongsheng@627 16023 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 16024 #: ../en/ch12-mq.xml:427
dongsheng@627 16025 msgid ""
dongsheng@627 16026 "Notice that once we have popped a patch or two patches, the output of "
dongsheng@627 16027 "<command role=\"hg-ext-mq\">qseries</command> remains the same, while that of "
dongsheng@627 16028 "<command role=\"hg-ext-mq\">qapplied</command> has changed."
dongsheng@627 16029 msgstr ""
dongsheng@627 16030
dongsheng@627 16031 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 16032 #: ../en/ch12-mq.xml:435
dongsheng@627 16033 msgid "Pushing and popping many patches"
dongsheng@636 16034 msgstr "压入或弹出多个补丁"
dongsheng@627 16035
dongsheng@627 16036 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 16037 #: ../en/ch12-mq.xml:437
dongsheng@627 16038 msgid ""
dongsheng@627 16039 "While <command role=\"hg-ext-mq\">qpush</command> and <command role=\"hg-ext-"
dongsheng@627 16040 "mq\">qpop</command> each operate on a single patch at a time by default, you "
dongsheng@627 16041 "can push and pop many patches in one go. The <option role=\"hg-ext-mq-cmd-"
dongsheng@1034 16042 "qpush-opt\">-a</option> option to <command role=\"hg-ext-mq\">qpush</command> "
dongsheng@1034 16043 "causes it to push all unapplied patches, while the <option role=\"hg-ext-mq-"
dongsheng@1034 16044 "cmd-qpop-opt\">-a</option> option to <command role=\"hg-ext-mq\">qpop</"
dongsheng@627 16045 "command> causes it to pop all applied patches. (For some more ways to push "
songdongsheng@658 16046 "and pop many patches, see <xref linkend=\"sec:mq:perf\"/> below.)"
dongsheng@627 16047 msgstr ""
dongsheng@627 16048
dongsheng@627 16049 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 16050 #: ../en/ch12-mq.xml:453
dongsheng@627 16051 msgid "Safety checks, and overriding them"
dongsheng@636 16052 msgstr "安全的检查,然后覆盖它们"
dongsheng@627 16053
dongsheng@627 16054 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 16055 #: ../en/ch12-mq.xml:455
dongsheng@627 16056 msgid ""
dongsheng@627 16057 "Several MQ commands check the working directory before they do anything, and "
dongsheng@627 16058 "fail if they find any modifications. They do this to ensure that you won't "
dongsheng@627 16059 "lose any changes that you have made, but not yet incorporated into a patch. "
dongsheng@627 16060 "The example below illustrates this; the <command role=\"hg-ext-mq\">qnew</"
dongsheng@627 16061 "command> command will not create a new patch if there are outstanding "
dongsheng@627 16062 "changes, caused in this case by the <command role=\"hg-cmd\">hg add</command> "
dongsheng@627 16063 "of <filename>file3</filename>."
dongsheng@627 16064 msgstr ""
dongsheng@627 16065
dongsheng@627 16066 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 16067 #: ../en/ch12-mq.xml:467
dongsheng@627 16068 msgid ""
dongsheng@627 16069 "Commands that check the working directory all take an <quote>I know what I'm "
dongsheng@627 16070 "doing</quote> option, which is always named <option>-f</option>. The exact "
dongsheng@627 16071 "meaning of <option>-f</option> depends on the command. For example, <command "
dongsheng@1034 16072 "role=\"hg-cmd\">hg qnew <option role=\"hg-ext-mq-cmd-qnew-opt\">-f</option></"
dongsheng@1034 16073 "command> will incorporate any outstanding changes into the new patch it "
dongsheng@1034 16074 "creates, but <command role=\"hg-cmd\">hg qpop <option role=\"hg-ext-mq-cmd-"
dongsheng@1034 16075 "qpop-opt\">-f</option></command> will revert modifications to any files "
dongsheng@627 16076 "affected by the patch that it is popping. Be sure to read the documentation "
dongsheng@627 16077 "for a command's <option>-f</option> option before you use it!"
dongsheng@627 16078 msgstr ""
dongsheng@627 16079
dongsheng@627 16080 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 16081 #: ../en/ch12-mq.xml:482
dongsheng@627 16082 msgid "Working on several patches at once"
dongsheng@636 16083 msgstr "同时处理多个补丁"
dongsheng@627 16084
dongsheng@627 16085 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 16086 #: ../en/ch12-mq.xml:484
dongsheng@627 16087 msgid ""
dongsheng@627 16088 "The <command role=\"hg-ext-mq\">qrefresh</command> command always refreshes "
dongsheng@627 16089 "the <emphasis>topmost</emphasis> applied patch. This means that you can "
dongsheng@627 16090 "suspend work on one patch (by refreshing it), pop or push to make a different "
dongsheng@627 16091 "patch the top, and work on <emphasis>that</emphasis> patch for a while."
dongsheng@627 16092 msgstr ""
dongsheng@627 16093
dongsheng@627 16094 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 16095 #: ../en/ch12-mq.xml:491
dongsheng@627 16096 msgid ""
dongsheng@627 16097 "Here's an example that illustrates how you can use this ability. Let's say "
dongsheng@627 16098 "you're developing a new feature as two patches. The first is a change to the "
songdongsheng@668 16099 "core of your software, and the second&emdash;layered on top of the "
songdongsheng@668 16100 "first&emdash;changes the user interface to use the code you just added to the "
songdongsheng@668 16101 "core. If you notice a bug in the core while you're working on the UI patch, "
songdongsheng@668 16102 "it's easy to fix the core. Simply <command role=\"hg-ext-mq\">qrefresh</"
songdongsheng@668 16103 "command> the UI patch to save your in-progress changes, and <command role="
songdongsheng@668 16104 "\"hg-ext-mq\">qpop</command> down to the core patch. Fix the core bug, "
songdongsheng@668 16105 "<command role=\"hg-ext-mq\">qrefresh</command> the core patch, and <command "
songdongsheng@668 16106 "role=\"hg-ext-mq\">qpush</command> back to the UI patch to continue where you "
songdongsheng@668 16107 "left off."
dongsheng@627 16108 msgstr ""
dongsheng@627 16109
dongsheng@627 16110 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 16111 #: ../en/ch12-mq.xml:508
dongsheng@627 16112 msgid "More about patches"
dongsheng@636 16113 msgstr "关于补丁的更多信息"
dongsheng@627 16114
dongsheng@627 16115 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 16116 #: ../en/ch12-mq.xml:510
dongsheng@627 16117 msgid ""
dongsheng@627 16118 "MQ uses the GNU <command>patch</command> command to apply patches, so it's "
dongsheng@627 16119 "helpful to know a few more detailed aspects of how <command>patch</command> "
dongsheng@627 16120 "works, and about patches themselves."
dongsheng@627 16121 msgstr ""
dongsheng@627 16122
dongsheng@627 16123 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 16124 #: ../en/ch12-mq.xml:516
dongsheng@627 16125 msgid "The strip count"
dongsheng@636 16126 msgstr "修剪计数"
dongsheng@627 16127
dongsheng@627 16128 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 16129 #: ../en/ch12-mq.xml:518
dongsheng@627 16130 msgid ""
dongsheng@627 16131 "If you look at the file headers in a patch, you will notice that the "
dongsheng@627 16132 "pathnames usually have an extra component on the front that isn't present in "
dongsheng@627 16133 "the actual path name. This is a holdover from the way that people used to "
dongsheng@627 16134 "generate patches (people still do this, but it's somewhat rare with modern "
dongsheng@627 16135 "revision control tools)."
dongsheng@627 16136 msgstr ""
dongsheng@627 16137
dongsheng@627 16138 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 16139 #: ../en/ch12-mq.xml:525
dongsheng@627 16140 msgid ""
dongsheng@627 16141 "Alice would unpack a tarball, edit her files, then decide that she wanted to "
dongsheng@627 16142 "create a patch. So she'd rename her working directory, unpack the tarball "
dongsheng@627 16143 "again (hence the need for the rename), and use the <option role=\"cmd-opt-diff"
dongsheng@627 16144 "\">-r</option> and <option role=\"cmd-opt-diff\">-N</option> options to "
dongsheng@627 16145 "<command>diff</command> to recursively generate a patch between the "
dongsheng@627 16146 "unmodified directory and the modified one. The result would be that the name "
dongsheng@627 16147 "of the unmodified directory would be at the front of the left-hand path in "
dongsheng@627 16148 "every file header, and the name of the modified directory would be at the "
dongsheng@627 16149 "front of the right-hand path."
dongsheng@627 16150 msgstr ""
dongsheng@627 16151
dongsheng@627 16152 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 16153 #: ../en/ch12-mq.xml:538
dongsheng@627 16154 msgid ""
dongsheng@627 16155 "Since someone receiving a patch from the Alices of the net would be unlikely "
dongsheng@627 16156 "to have unmodified and modified directories with exactly the same names, the "
dongsheng@627 16157 "<command>patch</command> command has a <option role=\"cmd-opt-patch\">-p</"
dongsheng@627 16158 "option> option that indicates the number of leading path name components to "
dongsheng@627 16159 "strip when trying to apply a patch. This number is called the "
dongsheng@627 16160 "<emphasis>strip count</emphasis>."
dongsheng@627 16161 msgstr ""
dongsheng@627 16162
dongsheng@627 16163 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 16164 #: ../en/ch12-mq.xml:546
dongsheng@627 16165 msgid ""
dongsheng@627 16166 "An option of <quote><literal>-p1</literal></quote> means <quote>use a strip "
dongsheng@627 16167 "count of one</quote>. If <command>patch</command> sees a file name "
dongsheng@627 16168 "<filename>foo/bar/baz</filename> in a file header, it will strip "
dongsheng@627 16169 "<filename>foo</filename> and try to patch a file named <filename>bar/baz</"
dongsheng@627 16170 "filename>. (Strictly speaking, the strip count refers to the number of "
dongsheng@627 16171 "<emphasis>path separators</emphasis> (and the components that go with them ) "
dongsheng@627 16172 "to strip. A strip count of one will turn <filename>foo/bar</filename> into "
dongsheng@627 16173 "<filename>bar</filename>, but <filename>/foo/bar</filename> (notice the extra "
dongsheng@627 16174 "leading slash) into <filename>foo/bar</filename>.)"
dongsheng@627 16175 msgstr ""
dongsheng@627 16176
dongsheng@627 16177 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 16178 #: ../en/ch12-mq.xml:559
dongsheng@627 16179 msgid ""
dongsheng@627 16180 "The <quote>standard</quote> strip count for patches is one; almost all "
dongsheng@627 16181 "patches contain one leading path name component that needs to be stripped. "
dongsheng@627 16182 "Mercurial's <command role=\"hg-cmd\">hg diff</command> command generates path "
dongsheng@627 16183 "names in this form, and the <command role=\"hg-cmd\">hg import</command> "
dongsheng@627 16184 "command and MQ expect patches to have a strip count of one."
dongsheng@627 16185 msgstr ""
dongsheng@627 16186
dongsheng@627 16187 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 16188 #: ../en/ch12-mq.xml:567
dongsheng@627 16189 msgid ""
dongsheng@627 16190 "If you receive a patch from someone that you want to add to your patch queue, "
dongsheng@627 16191 "and the patch needs a strip count other than one, you cannot just <command "
dongsheng@627 16192 "role=\"hg-ext-mq\">qimport</command> the patch, because <command role=\"hg-"
dongsheng@627 16193 "ext-mq\">qimport</command> does not yet have a <literal>-p</literal> option "
dongsheng@627 16194 "(see <ulink role=\"hg-bug\" url=\"http://www.selenic.com/mercurial/bts/"
dongsheng@627 16195 "issue311\">issue 311</ulink>). Your best bet is to <command role=\"hg-ext-mq"
dongsheng@627 16196 "\">qnew</command> a patch of your own, then use <command>patch -pN</command> "
dongsheng@627 16197 "to apply their patch, followed by <command role=\"hg-cmd\">hg addremove</"
dongsheng@627 16198 "command> to pick up any files added or removed by the patch, followed by "
dongsheng@627 16199 "<command role=\"hg-ext-mq\">hg qrefresh</command>. This complexity may become "
dongsheng@627 16200 "unnecessary; see <ulink role=\"hg-bug\" url=\"http://www.selenic.com/"
dongsheng@627 16201 "mercurial/bts/issue311\">issue 311</ulink> for details."
dongsheng@627 16202 msgstr ""
dongsheng@627 16203
dongsheng@627 16204 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 16205 #: ../en/ch12-mq.xml:587
dongsheng@627 16206 msgid "Strategies for applying a patch"
dongsheng@636 16207 msgstr "应用补丁的策略"
dongsheng@627 16208
dongsheng@627 16209 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 16210 #: ../en/ch12-mq.xml:589
dongsheng@627 16211 msgid ""
dongsheng@627 16212 "When <command>patch</command> applies a hunk, it tries a handful of "
dongsheng@627 16213 "successively less accurate strategies to try to make the hunk apply. This "
dongsheng@627 16214 "falling-back technique often makes it possible to take a patch that was "
dongsheng@627 16215 "generated against an old version of a file, and apply it against a newer "
dongsheng@627 16216 "version of that file."
dongsheng@627 16217 msgstr ""
dongsheng@627 16218
dongsheng@627 16219 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 16220 #: ../en/ch12-mq.xml:596
dongsheng@627 16221 msgid ""
dongsheng@627 16222 "First, <command>patch</command> tries an exact match, where the line numbers, "
dongsheng@627 16223 "the context, and the text to be modified must apply exactly. If it cannot "
dongsheng@627 16224 "make an exact match, it tries to find an exact match for the context, without "
dongsheng@627 16225 "honouring the line numbering information. If this succeeds, it prints a line "
dongsheng@627 16226 "of output saying that the hunk was applied, but at some <emphasis>offset</"
dongsheng@627 16227 "emphasis> from the original line number."
dongsheng@627 16228 msgstr ""
dongsheng@627 16229
dongsheng@627 16230 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 16231 #: ../en/ch12-mq.xml:605
dongsheng@627 16232 msgid ""
dongsheng@627 16233 "If a context-only match fails, <command>patch</command> removes the first and "
dongsheng@627 16234 "last lines of the context, and tries a <emphasis>reduced</emphasis> context-"
dongsheng@627 16235 "only match. If the hunk with reduced context succeeds, it prints a message "
dongsheng@627 16236 "saying that it applied the hunk with a <emphasis>fuzz factor</emphasis> (the "
dongsheng@627 16237 "number after the fuzz factor indicates how many lines of context "
dongsheng@627 16238 "<command>patch</command> had to trim before the patch applied)."
dongsheng@627 16239 msgstr ""
dongsheng@627 16240
dongsheng@627 16241 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 16242 #: ../en/ch12-mq.xml:614
dongsheng@627 16243 msgid ""
dongsheng@627 16244 "When neither of these techniques works, <command>patch</command> prints a "
dongsheng@627 16245 "message saying that the hunk in question was rejected. It saves rejected "
dongsheng@627 16246 "hunks (also simply called <quote>rejects</quote>) to a file with the same "
dongsheng@627 16247 "name, and an added <filename role=\"special\">.rej</filename> extension. It "
dongsheng@627 16248 "also saves an unmodified copy of the file with a <filename role=\"special\">."
dongsheng@627 16249 "orig</filename> extension; the copy of the file without any extensions will "
dongsheng@627 16250 "contain any changes made by hunks that <emphasis>did</emphasis> apply "
dongsheng@627 16251 "cleanly. If you have a patch that modifies <filename>foo</filename> with six "
dongsheng@627 16252 "hunks, and one of them fails to apply, you will have: an unmodified "
dongsheng@627 16253 "<filename>foo.orig</filename>, a <filename>foo.rej</filename> containing one "
dongsheng@627 16254 "hunk, and <filename>foo</filename>, containing the changes made by the five "
dongsheng@627 16255 "successful hunks."
dongsheng@627 16256 msgstr ""
dongsheng@627 16257
dongsheng@627 16258 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 16259 #: ../en/ch12-mq.xml:632
dongsheng@627 16260 msgid "Some quirks of patch representation"
dongsheng@636 16261 msgstr "补丁的一些特性"
dongsheng@627 16262
dongsheng@627 16263 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 16264 #: ../en/ch12-mq.xml:634
dongsheng@627 16265 msgid ""
dongsheng@627 16266 "There are a few useful things to know about how <command>patch</command> "
dongsheng@627 16267 "works with files."
dongsheng@627 16268 msgstr ""
dongsheng@627 16269
dongsheng@627 16270 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 16271 #: ../en/ch12-mq.xml:637
dongsheng@627 16272 msgid ""
dongsheng@627 16273 "This should already be obvious, but <command>patch</command> cannot handle "
dongsheng@627 16274 "binary files."
dongsheng@627 16275 msgstr ""
dongsheng@627 16276
dongsheng@627 16277 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 16278 #: ../en/ch12-mq.xml:641
dongsheng@627 16279 msgid ""
dongsheng@627 16280 "Neither does it care about the executable bit; it creates new files as "
dongsheng@627 16281 "readable, but not executable."
dongsheng@627 16282 msgstr ""
dongsheng@627 16283
dongsheng@627 16284 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 16285 #: ../en/ch12-mq.xml:645
dongsheng@627 16286 msgid ""
dongsheng@627 16287 "<command>patch</command> treats the removal of a file as a diff between the "
dongsheng@627 16288 "file to be removed and the empty file. So your idea of <quote>I deleted this "
dongsheng@627 16289 "file</quote> looks like <quote>every line of this file was deleted</quote> in "
dongsheng@627 16290 "a patch."
dongsheng@627 16291 msgstr ""
dongsheng@627 16292
dongsheng@627 16293 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 16294 #: ../en/ch12-mq.xml:651
dongsheng@627 16295 msgid ""
dongsheng@627 16296 "It treats the addition of a file as a diff between the empty file and the "
dongsheng@627 16297 "file to be added. So in a patch, your idea of <quote>I added this file</"
dongsheng@627 16298 "quote> looks like <quote>every line of this file was added</quote>."
dongsheng@627 16299 msgstr ""
dongsheng@627 16300
dongsheng@627 16301 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 16302 #: ../en/ch12-mq.xml:657
dongsheng@627 16303 msgid ""
dongsheng@627 16304 "It treats a renamed file as the removal of the old name, and the addition of "
dongsheng@627 16305 "the new name. This means that renamed files have a big footprint in "
dongsheng@627 16306 "patches. (Note also that Mercurial does not currently try to infer when "
dongsheng@627 16307 "files have been renamed or copied in a patch.)"
dongsheng@627 16308 msgstr ""
dongsheng@627 16309
dongsheng@627 16310 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 16311 #: ../en/ch12-mq.xml:663
dongsheng@627 16312 msgid ""
dongsheng@627 16313 "<command>patch</command> cannot represent empty files, so you cannot use a "
dongsheng@627 16314 "patch to represent the notion <quote>I added this empty file to the tree</"
dongsheng@627 16315 "quote>."
dongsheng@627 16316 msgstr ""
dongsheng@627 16317
dongsheng@627 16318 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 16319 #: ../en/ch12-mq.xml:671
dongsheng@627 16320 msgid "Beware the fuzz"
dongsheng@636 16321 msgstr "当心毛刺"
dongsheng@627 16322
dongsheng@627 16323 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 16324 #: ../en/ch12-mq.xml:673
dongsheng@627 16325 msgid ""
dongsheng@627 16326 "While applying a hunk at an offset, or with a fuzz factor, will often be "
dongsheng@627 16327 "completely successful, these inexact techniques naturally leave open the "
dongsheng@627 16328 "possibility of corrupting the patched file. The most common cases typically "
dongsheng@627 16329 "involve applying a patch twice, or at an incorrect location in the file. If "
dongsheng@627 16330 "<command>patch</command> or <command role=\"hg-ext-mq\">qpush</command> ever "
dongsheng@627 16331 "mentions an offset or fuzz factor, you should make sure that the modified "
dongsheng@627 16332 "files are correct afterwards."
dongsheng@627 16333 msgstr ""
dongsheng@627 16334
dongsheng@627 16335 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 16336 #: ../en/ch12-mq.xml:683
dongsheng@627 16337 msgid ""
dongsheng@627 16338 "It's often a good idea to refresh a patch that has applied with an offset or "
dongsheng@627 16339 "fuzz factor; refreshing the patch generates new context information that will "
dongsheng@627 16340 "make it apply cleanly. I say <quote>often,</quote> not <quote>always,</"
dongsheng@627 16341 "quote> because sometimes refreshing a patch will make it fail to apply "
dongsheng@627 16342 "against a different revision of the underlying files. In some cases, such as "
dongsheng@627 16343 "when you're maintaining a patch that must sit on top of multiple versions of "
dongsheng@627 16344 "a source tree, it's acceptable to have a patch apply with some fuzz, provided "
dongsheng@627 16345 "you've verified the results of the patching process in such cases."
dongsheng@627 16346 msgstr ""
dongsheng@627 16347
dongsheng@627 16348 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 16349 #: ../en/ch12-mq.xml:696
dongsheng@627 16350 msgid "Handling rejection"
dongsheng@636 16351 msgstr "处理拒绝"
dongsheng@627 16352
dongsheng@627 16353 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 16354 #: ../en/ch12-mq.xml:698
dongsheng@627 16355 msgid ""
dongsheng@627 16356 "If <command role=\"hg-ext-mq\">qpush</command> fails to apply a patch, it "
dongsheng@627 16357 "will print an error message and exit. If it has left <filename role=\"special"
dongsheng@627 16358 "\">.rej</filename> files behind, it is usually best to fix up the rejected "
dongsheng@627 16359 "hunks before you push more patches or do any further work."
dongsheng@627 16360 msgstr ""
dongsheng@627 16361
dongsheng@627 16362 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 16363 #: ../en/ch12-mq.xml:704
dongsheng@627 16364 msgid ""
dongsheng@627 16365 "If your patch <emphasis>used to</emphasis> apply cleanly, and no longer does "
dongsheng@627 16366 "because you've changed the underlying code that your patches are based on, "
songdongsheng@658 16367 "Mercurial Queues can help; see <xref linkend=\"sec:mq:merge\"/> for details."
songdongsheng@658 16368 msgstr ""
songdongsheng@658 16369
songdongsheng@658 16370 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 16371 #: ../en/ch12-mq.xml:709
dongsheng@627 16372 msgid ""
dongsheng@627 16373 "Unfortunately, there aren't any great techniques for dealing with rejected "
dongsheng@627 16374 "hunks. Most often, you'll need to view the <filename role=\"special\">.rej</"
dongsheng@627 16375 "filename> file and edit the target file, applying the rejected hunks by hand."
dongsheng@627 16376 msgstr ""
dongsheng@627 16377
dongsheng@627 16378 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 16379 #: ../en/ch12-mq.xml:714
dongsheng@714 16380 msgid ""
dongsheng@714 16381 "A Linux kernel hacker, Chris Mason (the author of Mercurial Queues), wrote a "
dongsheng@714 16382 "tool called <command>mpatch</command> (<ulink url=\"http://oss.oracle.com/"
dongsheng@714 16383 "~mason/mpatch/\">http://oss.oracle.com/~mason/mpatch/</ulink>), which takes a "
dongsheng@714 16384 "simple approach to automating the application of hunks rejected by "
dongsheng@714 16385 "<command>patch</command>. The <command>mpatch</command> command can help "
dongsheng@714 16386 "with four common reasons that a hunk may be rejected:"
dongsheng@627 16387 msgstr ""
dongsheng@627 16388
dongsheng@627 16389 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 16390 #: ../en/ch12-mq.xml:724
dongsheng@627 16391 msgid "The context in the middle of a hunk has changed."
dongsheng@627 16392 msgstr ""
dongsheng@627 16393
dongsheng@627 16394 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 16395 #: ../en/ch12-mq.xml:727
dongsheng@627 16396 msgid "A hunk is missing some context at the beginning or end."
dongsheng@627 16397 msgstr ""
dongsheng@627 16398
dongsheng@627 16399 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 16400 #: ../en/ch12-mq.xml:730
dongsheng@627 16401 msgid ""
songdongsheng@668 16402 "A large hunk might apply better&emdash;either entirely or in part&emdash;if "
songdongsheng@668 16403 "it was broken up into smaller hunks."
dongsheng@627 16404 msgstr ""
dongsheng@627 16405
dongsheng@627 16406 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 16407 #: ../en/ch12-mq.xml:734
dongsheng@627 16408 msgid ""
dongsheng@627 16409 "A hunk removes lines with slightly different content than those currently "
dongsheng@627 16410 "present in the file."
dongsheng@627 16411 msgstr ""
dongsheng@627 16412
dongsheng@627 16413 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 16414 #: ../en/ch12-mq.xml:738
dongsheng@714 16415 msgid ""
dongsheng@714 16416 "If you use <command>mpatch</command>, you should be doubly careful to check "
dongsheng@714 16417 "your results when you're done. In fact, <command>mpatch</command> enforces "
dongsheng@714 16418 "this method of double-checking the tool's output, by automatically dropping "
dongsheng@714 16419 "you into a merge program when it has done its job, so that you can verify its "
dongsheng@714 16420 "work and finish off any remaining merges."
dongsheng@627 16421 msgstr ""
dongsheng@627 16422
dongsheng@627 16423 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 16424 #: ../en/ch12-mq.xml:749
dongsheng@714 16425 msgid "More on patch management"
dongsheng@715 16426 msgstr "补丁管理进阶"
dongsheng@714 16427
dongsheng@714 16428 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 16429 #: ../en/ch12-mq.xml:751
dongsheng@714 16430 msgid ""
dongsheng@714 16431 "As you grow familiar with MQ, you will find yourself wanting to perform other "
dongsheng@714 16432 "kinds of patch management operations."
dongsheng@714 16433 msgstr ""
dongsheng@714 16434
dongsheng@714 16435 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 16436 #: ../en/ch12-mq.xml:755
dongsheng@714 16437 msgid "Deleting unwanted patches"
dongsheng@715 16438 msgstr "删除不需要的补丁"
dongsheng@714 16439
dongsheng@714 16440 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 16441 #: ../en/ch12-mq.xml:757
dongsheng@714 16442 msgid ""
dongsheng@714 16443 "If you want to get rid of a patch, use the <command role=\"hg-ext-mq\">hg "
dongsheng@714 16444 "qdelete</command> command to delete the patch file and remove its entry from "
dongsheng@714 16445 "the patch series. If you try to delete a patch that is still applied, "
dongsheng@714 16446 "<command role=\"hg-ext-mq\">hg qdelete</command> will refuse."
dongsheng@714 16447 msgstr ""
dongsheng@714 16448
dongsheng@714 16449 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 16450 #: ../en/ch12-mq.xml:767
dongsheng@714 16451 msgid "Converting to and from permanent revisions"
dongsheng@716 16452 msgstr "与持久版本的相互转换"
dongsheng@714 16453
dongsheng@714 16454 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 16455 #: ../en/ch12-mq.xml:769
dongsheng@714 16456 msgid ""
dongsheng@714 16457 "Once you're done working on a patch and want to turn it into a permanent "
dongsheng@714 16458 "changeset, use the <command role=\"hg-ext-mq\">hg qfinish</command> command. "
dongsheng@714 16459 "Pass a revision to the command to identify the patch that you want to turn "
dongsheng@714 16460 "into a regular changeset; this patch must already be applied."
dongsheng@714 16461 msgstr ""
dongsheng@714 16462
dongsheng@714 16463 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 16464 #: ../en/ch12-mq.xml:777
dongsheng@714 16465 msgid ""
dongsheng@714 16466 "The <command role=\"hg-ext-mq\">hg qfinish</command> command accepts an "
dongsheng@714 16467 "<option>--all</option> or <option>-a</option> option, which turns all applied "
dongsheng@714 16468 "patches into regular changesets."
dongsheng@714 16469 msgstr ""
dongsheng@714 16470
dongsheng@714 16471 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 16472 #: ../en/ch12-mq.xml:782
dongsheng@714 16473 msgid ""
dongsheng@714 16474 "It is also possible to turn an existing changeset into a patch, by passing "
dongsheng@714 16475 "the <option>-r</option> option to <command role=\"hg-ext-mq\">hg qimport</"
dongsheng@714 16476 "command>."
dongsheng@714 16477 msgstr ""
dongsheng@714 16478
dongsheng@714 16479 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 16480 #: ../en/ch12-mq.xml:788
dongsheng@714 16481 msgid ""
dongsheng@714 16482 "Note that it only makes sense to convert a changeset into a patch if you have "
dongsheng@714 16483 "not propagated that changeset into any other repositories. The imported "
dongsheng@714 16484 "changeset's ID will change every time you refresh the patch, which will make "
dongsheng@714 16485 "Mercurial treat it as unrelated to the original changeset if you have pushed "
dongsheng@714 16486 "it somewhere else."
dongsheng@714 16487 msgstr ""
dongsheng@714 16488
dongsheng@714 16489 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 16490 #: ../en/ch12-mq.xml:798
dongsheng@627 16491 msgid "Getting the best performance out of MQ"
dongsheng@636 16492 msgstr "MQ 的性能"
dongsheng@627 16493
dongsheng@627 16494 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 16495 #: ../en/ch12-mq.xml:800
dongsheng@714 16496 msgid ""
dongsheng@714 16497 "MQ is very efficient at handling a large number of patches. I ran some "
dongsheng@627 16498 "performance experiments in mid-2006 for a talk that I gave at the 2006 "
dongsheng@714 16499 "EuroPython conference (on modern hardware, you should expect better "
dongsheng@714 16500 "performance than you'll see below). I used as my data set the Linux 2.6.17-"
dongsheng@714 16501 "mm1 patch series, which consists of 1,738 patches. I applied these on top of "
dongsheng@714 16502 "a Linux kernel repository containing all 27,472 revisions between Linux "
dongsheng@714 16503 "2.6.12-rc2 and Linux 2.6.17."
dongsheng@714 16504 msgstr ""
dongsheng@714 16505
dongsheng@714 16506 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 16507 #: ../en/ch12-mq.xml:809
dongsheng@627 16508 msgid ""
dongsheng@627 16509 "On my old, slow laptop, I was able to <command role=\"hg-cmd\">hg qpush "
dongsheng@1034 16510 "<option role=\"hg-ext-mq-cmd-qpush-opt\">-a</option></command> all 1,738 "
dongsheng@627 16511 "patches in 3.5 minutes, and <command role=\"hg-cmd\">hg qpop <option role="
dongsheng@1034 16512 "\"hg-ext-mq-cmd-qpop-opt\">-a</option></command> them all in 30 seconds. (On "
dongsheng@1034 16513 "a newer laptop, the time to push all patches dropped to two minutes.) I "
dongsheng@627 16514 "could <command role=\"hg-ext-mq\">qrefresh</command> one of the biggest "
dongsheng@627 16515 "patches (which made 22,779 lines of changes to 287 files) in 6.6 seconds."
dongsheng@627 16516 msgstr ""
dongsheng@627 16517
dongsheng@627 16518 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 16519 #: ../en/ch12-mq.xml:820
dongsheng@627 16520 msgid ""
dongsheng@627 16521 "Clearly, MQ is well suited to working in large trees, but there are a few "
dongsheng@627 16522 "tricks you can use to get the best performance of it."
dongsheng@627 16523 msgstr ""
dongsheng@627 16524
dongsheng@627 16525 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 16526 #: ../en/ch12-mq.xml:824
dongsheng@627 16527 msgid ""
dongsheng@627 16528 "First of all, try to <quote>batch</quote> operations together. Every time "
dongsheng@627 16529 "you run <command role=\"hg-ext-mq\">qpush</command> or <command role=\"hg-ext-"
dongsheng@627 16530 "mq\">qpop</command>, these commands scan the working directory once to make "
dongsheng@627 16531 "sure you haven't made some changes and then forgotten to run <command role="
dongsheng@627 16532 "\"hg-ext-mq\">qrefresh</command>. On a small tree, the time that this scan "
dongsheng@627 16533 "takes is unnoticeable. However, on a medium-sized tree (containing tens of "
dongsheng@627 16534 "thousands of files), it can take a second or more."
dongsheng@627 16535 msgstr ""
dongsheng@627 16536
dongsheng@627 16537 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 16538 #: ../en/ch12-mq.xml:835
dongsheng@627 16539 msgid ""
dongsheng@627 16540 "The <command role=\"hg-ext-mq\">qpush</command> and <command role=\"hg-ext-mq"
dongsheng@627 16541 "\">qpop</command> commands allow you to push and pop multiple patches at a "
dongsheng@627 16542 "time. You can identify the <quote>destination patch</quote> that you want to "
dongsheng@627 16543 "end up at. When you <command role=\"hg-ext-mq\">qpush</command> with a "
dongsheng@627 16544 "destination specified, it will push patches until that patch is at the top of "
dongsheng@627 16545 "the applied stack. When you <command role=\"hg-ext-mq\">qpop</command> to a "
dongsheng@627 16546 "destination, MQ will pop patches until the destination patch is at the top."
dongsheng@627 16547 msgstr ""
dongsheng@627 16548
dongsheng@627 16549 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 16550 #: ../en/ch12-mq.xml:845
dongsheng@627 16551 msgid ""
dongsheng@627 16552 "You can identify a destination patch using either the name of the patch, or "
dongsheng@627 16553 "by number. If you use numeric addressing, patches are counted from zero; "
dongsheng@627 16554 "this means that the first patch is zero, the second is one, and so on."
dongsheng@627 16555 msgstr ""
dongsheng@627 16556
dongsheng@627 16557 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 16558 #: ../en/ch12-mq.xml:852
dongsheng@627 16559 msgid "Updating your patches when the underlying code changes"
dongsheng@636 16560 msgstr "当基础代码改变时,更新补丁的方法"
dongsheng@627 16561
dongsheng@627 16562 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 16563 #: ../en/ch12-mq.xml:855
dongsheng@627 16564 msgid ""
dongsheng@627 16565 "It's common to have a stack of patches on top of an underlying repository "
dongsheng@627 16566 "that you don't modify directly. If you're working on changes to third-party "
dongsheng@627 16567 "code, or on a feature that is taking longer to develop than the rate of "
dongsheng@627 16568 "change of the code beneath, you will often need to sync up with the "
dongsheng@627 16569 "underlying code, and fix up any hunks in your patches that no longer apply. "
dongsheng@627 16570 "This is called <emphasis>rebasing</emphasis> your patch series."
dongsheng@627 16571 msgstr ""
dongsheng@627 16572
dongsheng@627 16573 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 16574 #: ../en/ch12-mq.xml:864
dongsheng@627 16575 msgid ""
dongsheng@627 16576 "The simplest way to do this is to <command role=\"hg-cmd\">hg qpop <option "
dongsheng@627 16577 "role=\"hg-ext-mq-cmd-qpop-opt\">hg -a</option></command> your patches, then "
dongsheng@627 16578 "<command role=\"hg-cmd\">hg pull</command> changes into the underlying "
dongsheng@627 16579 "repository, and finally <command role=\"hg-cmd\">hg qpush <option role=\"hg-"
dongsheng@1034 16580 "ext-mq-cmd-qpop-opt\">-a</option></command> your patches again. MQ will stop "
dongsheng@1034 16581 "pushing any time it runs across a patch that fails to apply during conflicts, "
dongsheng@1034 16582 "allowing you to fix your conflicts, <command role=\"hg-ext-mq\">qrefresh</"
dongsheng@1034 16583 "command> the affected patch, and continue pushing until you have fixed your "
dongsheng@1034 16584 "entire stack."
dongsheng@627 16585 msgstr ""
dongsheng@627 16586
dongsheng@627 16587 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 16588 #: ../en/ch12-mq.xml:876
dongsheng@627 16589 msgid ""
dongsheng@627 16590 "This approach is easy to use and works well if you don't expect changes to "
dongsheng@627 16591 "the underlying code to affect how well your patches apply. If your patch "
dongsheng@627 16592 "stack touches code that is modified frequently or invasively in the "
dongsheng@627 16593 "underlying repository, however, fixing up rejected hunks by hand quickly "
dongsheng@627 16594 "becomes tiresome."
dongsheng@627 16595 msgstr ""
dongsheng@627 16596
dongsheng@627 16597 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 16598 #: ../en/ch12-mq.xml:883
dongsheng@627 16599 msgid ""
dongsheng@627 16600 "It's possible to partially automate the rebasing process. If your patches "
dongsheng@627 16601 "apply cleanly against some revision of the underlying repo, MQ can use this "
dongsheng@627 16602 "information to help you to resolve conflicts between your patches and a "
dongsheng@627 16603 "different revision."
dongsheng@627 16604 msgstr ""
dongsheng@627 16605
dongsheng@627 16606 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 16607 #: ../en/ch12-mq.xml:889
songdongsheng@658 16608 msgid "The process is a little involved."
songdongsheng@658 16609 msgstr ""
songdongsheng@658 16610
songdongsheng@658 16611 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
dongsheng@714 16612 #: ../en/ch12-mq.xml:891
dongsheng@627 16613 msgid ""
dongsheng@627 16614 "To begin, <command role=\"hg-cmd\">hg qpush -a</command> all of your patches "
dongsheng@627 16615 "on top of the revision where you know that they apply cleanly."
dongsheng@627 16616 msgstr ""
dongsheng@627 16617
dongsheng@627 16618 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
dongsheng@714 16619 #: ../en/ch12-mq.xml:895
dongsheng@627 16620 msgid ""
dongsheng@627 16621 "Save a backup copy of your patch directory using <command role=\"hg-cmd\">hg "
dongsheng@627 16622 "qsave <option role=\"hg-ext-mq-cmd-qsave-opt\">hg -e</option> <option role="
dongsheng@627 16623 "\"hg-ext-mq-cmd-qsave-opt\">hg -c</option></command>. This prints the name "
dongsheng@627 16624 "of the directory that it has saved the patches in. It will save the patches "
dongsheng@627 16625 "to a directory called <filename role=\"special\" class=\"directory\">.hg/"
dongsheng@627 16626 "patches.N</filename>, where <literal>N</literal> is a small integer. It also "
dongsheng@627 16627 "commits a <quote>save changeset</quote> on top of your applied patches; this "
dongsheng@627 16628 "is for internal book-keeping, and records the states of the <filename role="
dongsheng@627 16629 "\"special\">series</filename> and <filename role=\"special\">status</"
dongsheng@627 16630 "filename> files."
dongsheng@627 16631 msgstr ""
dongsheng@627 16632
dongsheng@627 16633 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
dongsheng@714 16634 #: ../en/ch12-mq.xml:909
dongsheng@627 16635 msgid ""
dongsheng@627 16636 "Use <command role=\"hg-cmd\">hg pull</command> to bring new changes into the "
dongsheng@627 16637 "underlying repository. (Don't run <command role=\"hg-cmd\">hg pull -u</"
dongsheng@627 16638 "command>; see below for why.)"
dongsheng@627 16639 msgstr ""
dongsheng@627 16640
dongsheng@627 16641 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
dongsheng@714 16642 #: ../en/ch12-mq.xml:914
dongsheng@627 16643 msgid ""
dongsheng@627 16644 "Update to the new tip revision, using <command role=\"hg-cmd\">hg update "
dongsheng@627 16645 "<option role=\"hg-opt-update\">-C</option></command> to override the patches "
dongsheng@627 16646 "you have pushed."
dongsheng@627 16647 msgstr ""
dongsheng@627 16648
dongsheng@627 16649 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
dongsheng@714 16650 #: ../en/ch12-mq.xml:919
dongsheng@650 16651 msgid ""
dongsheng@650 16652 "Merge all patches using <command>hg qpush -m -a</command>. The <option role="
dongsheng@650 16653 "\"hg-ext-mq-cmd-qpush-opt\">-m</option> option to <command role=\"hg-ext-mq"
dongsheng@650 16654 "\">qpush</command> tells MQ to perform a three-way merge if the patch fails "
dongsheng@650 16655 "to apply."
dongsheng@650 16656 msgstr ""
dongsheng@650 16657
dongsheng@650 16658 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 16659 #: ../en/ch12-mq.xml:927
dongsheng@627 16660 msgid ""
dongsheng@627 16661 "During the <command role=\"hg-cmd\">hg qpush <option role=\"hg-ext-mq-cmd-"
dongsheng@627 16662 "qpush-opt\">hg -m</option></command>, each patch in the <filename role="
dongsheng@627 16663 "\"special\">series</filename> file is applied normally. If a patch applies "
dongsheng@627 16664 "with fuzz or rejects, MQ looks at the queue you <command role=\"hg-ext-mq"
dongsheng@627 16665 "\">qsave</command>d, and performs a three-way merge with the corresponding "
dongsheng@627 16666 "changeset. This merge uses Mercurial's normal merge machinery, so it may pop "
dongsheng@627 16667 "up a GUI merge tool to help you to resolve problems."
dongsheng@627 16668 msgstr ""
dongsheng@627 16669
dongsheng@627 16670 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 16671 #: ../en/ch12-mq.xml:937
dongsheng@627 16672 msgid ""
dongsheng@627 16673 "When you finish resolving the effects of a patch, MQ refreshes your patch "
dongsheng@627 16674 "based on the result of the merge."
dongsheng@627 16675 msgstr ""
dongsheng@627 16676
dongsheng@627 16677 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 16678 #: ../en/ch12-mq.xml:940
dongsheng@627 16679 msgid ""
dongsheng@627 16680 "At the end of this process, your repository will have one extra head from the "
dongsheng@627 16681 "old patch queue, and a copy of the old patch queue will be in <filename role="
dongsheng@627 16682 "\"special\" class=\"directory\">.hg/patches.N</filename>. You can remove the "
dongsheng@627 16683 "extra head using <command role=\"hg-cmd\">hg qpop -a -n patches.N</command> "
dongsheng@627 16684 "or <command role=\"hg-cmd\">hg strip</command>. You can delete <filename "
dongsheng@627 16685 "role=\"special\" class=\"directory\">.hg/patches.N</filename> once you are "
dongsheng@627 16686 "sure that you no longer need it as a backup."
dongsheng@627 16687 msgstr ""
dongsheng@627 16688
dongsheng@627 16689 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 16690 #: ../en/ch12-mq.xml:952
dongsheng@627 16691 msgid "Identifying patches"
dongsheng@636 16692 msgstr "标识补丁"
dongsheng@627 16693
dongsheng@627 16694 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 16695 #: ../en/ch12-mq.xml:954
dongsheng@627 16696 msgid ""
dongsheng@627 16697 "MQ commands that work with patches let you refer to a patch either by using "
dongsheng@627 16698 "its name or by a number. By name is obvious enough; pass the name "
dongsheng@627 16699 "<filename>foo.patch</filename> to <command role=\"hg-ext-mq\">qpush</"
dongsheng@627 16700 "command>, for example, and it will push patches until <filename>foo.patch</"
dongsheng@627 16701 "filename> is applied."
dongsheng@627 16702 msgstr ""
dongsheng@627 16703
dongsheng@627 16704 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 16705 #: ../en/ch12-mq.xml:961
dongsheng@627 16706 msgid ""
dongsheng@627 16707 "As a shortcut, you can refer to a patch using both a name and a numeric "
dongsheng@627 16708 "offset; <literal>foo.patch-2</literal> means <quote>two patches before "
dongsheng@627 16709 "<literal>foo.patch</literal></quote>, while <literal>bar.patch+4</literal> "
dongsheng@627 16710 "means <quote>four patches after <literal>bar.patch</literal></quote>."
dongsheng@627 16711 msgstr ""
dongsheng@627 16712
dongsheng@627 16713 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 16714 #: ../en/ch12-mq.xml:967
dongsheng@627 16715 msgid ""
dongsheng@627 16716 "Referring to a patch by index isn't much different. The first patch printed "
dongsheng@627 16717 "in the output of <command role=\"hg-ext-mq\">qseries</command> is patch zero "
dongsheng@627 16718 "(yes, it's one of those start-at-zero counting systems); the second is patch "
dongsheng@627 16719 "one; and so on."
dongsheng@627 16720 msgstr ""
dongsheng@627 16721
dongsheng@627 16722 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 16723 #: ../en/ch12-mq.xml:973
dongsheng@627 16724 msgid ""
dongsheng@627 16725 "MQ also makes it easy to work with patches when you are using normal "
dongsheng@627 16726 "Mercurial commands. Every command that accepts a changeset ID will also "
dongsheng@627 16727 "accept the name of an applied patch. MQ augments the tags normally in the "
dongsheng@627 16728 "repository with an eponymous one for each applied patch. In addition, the "
dongsheng@650 16729 "special tags <literal role=\"tag\">qbase</literal> and <literal role=\"tag"
dongsheng@650 16730 "\">qtip</literal> identify the <quote>bottom-most</quote> and topmost applied "
dongsheng@650 16731 "patches, respectively."
dongsheng@650 16732 msgstr ""
dongsheng@650 16733
dongsheng@650 16734 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 16735 #: ../en/ch12-mq.xml:983
dongsheng@627 16736 msgid ""
dongsheng@627 16737 "These additions to Mercurial's normal tagging capabilities make dealing with "
dongsheng@627 16738 "patches even more of a breeze."
dongsheng@627 16739 msgstr ""
dongsheng@627 16740
dongsheng@627 16741 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 16742 #: ../en/ch12-mq.xml:986
dongsheng@627 16743 msgid "Want to patchbomb a mailing list with your latest series of changes?"
dongsheng@627 16744 msgstr ""
dongsheng@627 16745
dongsheng@627 16746 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 16747 #: ../en/ch12-mq.xml:989
songdongsheng@658 16748 msgid ""
songdongsheng@658 16749 "(Don't know what <quote>patchbombing</quote> is? See <xref linkend=\"sec:"
songdongsheng@658 16750 "hgext:patchbomb\"/>.)"
dongsheng@627 16751 msgstr ""
dongsheng@627 16752
dongsheng@627 16753 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 16754 #: ../en/ch12-mq.xml:992
dongsheng@627 16755 msgid ""
dongsheng@627 16756 "Need to see all of the patches since <literal>foo.patch</literal> that have "
dongsheng@627 16757 "touched files in a subdirectory of your tree?"
dongsheng@627 16758 msgstr ""
dongsheng@627 16759
dongsheng@650 16760 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 16761 #: ../en/ch12-mq.xml:999
dongsheng@627 16762 msgid ""
dongsheng@627 16763 "Because MQ makes the names of patches available to the rest of Mercurial "
dongsheng@627 16764 "through its normal internal tag machinery, you don't need to type in the "
dongsheng@627 16765 "entire name of a patch when you want to identify it by name."
dongsheng@627 16766 msgstr ""
dongsheng@627 16767
dongsheng@627 16768 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 16769 #: ../en/ch12-mq.xml:1004
dongsheng@627 16770 msgid ""
dongsheng@627 16771 "Another nice consequence of representing patch names as tags is that when you "
dongsheng@627 16772 "run the <command role=\"hg-cmd\">hg log</command> command, it will display a "
dongsheng@627 16773 "patch's name as a tag, simply as part of its normal output. This makes it "
dongsheng@627 16774 "easy to visually distinguish applied patches from underlying <quote>normal</"
dongsheng@627 16775 "quote> revisions. The following example shows a few normal Mercurial "
dongsheng@627 16776 "commands in use with applied patches."
dongsheng@627 16777 msgstr ""
dongsheng@627 16778
dongsheng@627 16779 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 16780 #: ../en/ch12-mq.xml:1017
dongsheng@627 16781 msgid "Useful things to know about"
dongsheng@636 16782 msgstr "其它需要了解的东西"
dongsheng@627 16783
dongsheng@627 16784 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 16785 #: ../en/ch12-mq.xml:1019
dongsheng@627 16786 msgid ""
dongsheng@627 16787 "There are a number of aspects of MQ usage that don't fit tidily into sections "
dongsheng@627 16788 "of their own, but that are good to know. Here they are, in one place."
dongsheng@627 16789 msgstr ""
dongsheng@627 16790
dongsheng@627 16791 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 16792 #: ../en/ch12-mq.xml:1024
dongsheng@627 16793 msgid ""
dongsheng@627 16794 "Normally, when you <command role=\"hg-ext-mq\">qpop</command> a patch and "
dongsheng@627 16795 "<command role=\"hg-ext-mq\">qpush</command> it again, the changeset that "
dongsheng@627 16796 "represents the patch after the pop/push will have a <emphasis>different "
dongsheng@627 16797 "identity</emphasis> than the changeset that represented the hash beforehand. "
songdongsheng@658 16798 "See <xref linkend=\"sec:mqref:cmd:qpush\"/> for information as to why this is."
dongsheng@627 16799 msgstr ""
dongsheng@627 16800
dongsheng@627 16801 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 16802 #: ../en/ch12-mq.xml:1033
dongsheng@627 16803 msgid ""
dongsheng@627 16804 "It's not a good idea to <command role=\"hg-cmd\">hg merge</command> changes "
dongsheng@627 16805 "from another branch with a patch changeset, at least if you want to maintain "
dongsheng@627 16806 "the <quote>patchiness</quote> of that changeset and changesets below it on "
dongsheng@627 16807 "the patch stack. If you try to do this, it will appear to succeed, but MQ "
dongsheng@627 16808 "will become confused."
dongsheng@627 16809 msgstr ""
dongsheng@627 16810
dongsheng@627 16811 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 16812 #: ../en/ch12-mq.xml:1044
dongsheng@627 16813 msgid "Managing patches in a repository"
dongsheng@636 16814 msgstr "在版本库管理补丁"
dongsheng@627 16815
dongsheng@627 16816 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 16817 #: ../en/ch12-mq.xml:1046
dongsheng@627 16818 msgid ""
dongsheng@627 16819 "Because MQ's <filename role=\"special\" class=\"directory\">.hg/patches</"
dongsheng@627 16820 "filename> directory resides outside a Mercurial repository's working "
dongsheng@627 16821 "directory, the <quote>underlying</quote> Mercurial repository knows nothing "
dongsheng@627 16822 "about the management or presence of patches."
dongsheng@627 16823 msgstr ""
dongsheng@627 16824
dongsheng@627 16825 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 16826 #: ../en/ch12-mq.xml:1052
dongsheng@627 16827 msgid ""
dongsheng@627 16828 "This presents the interesting possibility of managing the contents of the "
dongsheng@627 16829 "patch directory as a Mercurial repository in its own right. This can be a "
dongsheng@627 16830 "useful way to work. For example, you can work on a patch for a while, "
dongsheng@627 16831 "<command role=\"hg-ext-mq\">qrefresh</command> it, then <command role=\"hg-cmd"
dongsheng@627 16832 "\">hg commit</command> the current state of the patch. This lets you "
dongsheng@627 16833 "<quote>roll back</quote> to that version of the patch later on."
dongsheng@627 16834 msgstr ""
dongsheng@627 16835
dongsheng@627 16836 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 16837 #: ../en/ch12-mq.xml:1061
dongsheng@627 16838 msgid ""
dongsheng@627 16839 "You can then share different versions of the same patch stack among multiple "
dongsheng@627 16840 "underlying repositories. I use this when I am developing a Linux kernel "
dongsheng@627 16841 "feature. I have a pristine copy of my kernel sources for each of several CPU "
dongsheng@627 16842 "architectures, and a cloned repository under each that contains the patches I "
dongsheng@627 16843 "am working on. When I want to test a change on a different architecture, I "
dongsheng@627 16844 "push my current patches to the patch repository associated with that kernel "
dongsheng@627 16845 "tree, pop and push all of my patches, and build and test that kernel."
dongsheng@627 16846 msgstr ""
dongsheng@627 16847
dongsheng@627 16848 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 16849 #: ../en/ch12-mq.xml:1071
dongsheng@627 16850 msgid ""
dongsheng@627 16851 "Managing patches in a repository makes it possible for multiple developers to "
dongsheng@627 16852 "work on the same patch series without colliding with each other, all on top "
dongsheng@627 16853 "of an underlying source base that they may or may not control."
dongsheng@627 16854 msgstr ""
dongsheng@627 16855
dongsheng@627 16856 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 16857 #: ../en/ch12-mq.xml:1077
dongsheng@627 16858 msgid "MQ support for patch repositories"
dongsheng@636 16859 msgstr "MQ 支持补丁版本库"
dongsheng@627 16860
dongsheng@627 16861 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 16862 #: ../en/ch12-mq.xml:1079
dongsheng@627 16863 msgid ""
dongsheng@627 16864 "MQ helps you to work with the <filename role=\"special\" class=\"directory\">."
dongsheng@627 16865 "hg/patches</filename> directory as a repository; when you prepare a "
dongsheng@627 16866 "repository for working with patches using <command role=\"hg-ext-mq\">qinit</"
dongsheng@627 16867 "command>, you can pass the <option role=\"hg-ext-mq-cmd-qinit-opt\">hg -c</"
dongsheng@627 16868 "option> option to create the <filename role=\"special\" class=\"directory\">."
dongsheng@627 16869 "hg/patches</filename> directory as a Mercurial repository."
dongsheng@627 16870 msgstr ""
dongsheng@627 16871
dongsheng@627 16872 #. type: Content of: <book><chapter><sect1><sect2><note><para>
dongsheng@714 16873 #: ../en/ch12-mq.xml:1089
dongsheng@627 16874 msgid ""
dongsheng@627 16875 "If you forget to use the <option role=\"hg-ext-mq-cmd-qinit-opt\">hg -c</"
dongsheng@627 16876 "option> option, you can simply go into the <filename role=\"special\" class="
dongsheng@627 16877 "\"directory\">.hg/patches</filename> directory at any time and run <command "
dongsheng@627 16878 "role=\"hg-cmd\">hg init</command>. Don't forget to add an entry for the "
dongsheng@627 16879 "<filename role=\"special\">status</filename> file to the <filename role="
dongsheng@627 16880 "\"special\">.hgignore</filename> file, though"
dongsheng@627 16881 msgstr ""
dongsheng@627 16882
dongsheng@627 16883 #. type: Content of: <book><chapter><sect1><sect2><note><para>
dongsheng@714 16884 #: ../en/ch12-mq.xml:1098
dongsheng@627 16885 msgid ""
dongsheng@627 16886 "(<command role=\"hg-cmd\">hg qinit <option role=\"hg-ext-mq-cmd-qinit-opt"
dongsheng@627 16887 "\">hg -c</option></command> does this for you automatically); you "
dongsheng@627 16888 "<emphasis>really</emphasis> don't want to manage the <filename role=\"special"
dongsheng@627 16889 "\">status</filename> file."
dongsheng@627 16890 msgstr ""
dongsheng@627 16891
dongsheng@627 16892 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 16893 #: ../en/ch12-mq.xml:1105
dongsheng@627 16894 msgid ""
dongsheng@627 16895 "As a convenience, if MQ notices that the <filename class=\"directory\">.hg/"
dongsheng@627 16896 "patches</filename> directory is a repository, it will automatically <command "
dongsheng@627 16897 "role=\"hg-cmd\">hg add</command> every patch that you create and import."
dongsheng@627 16898 msgstr ""
dongsheng@627 16899
dongsheng@627 16900 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 16901 #: ../en/ch12-mq.xml:1110
dongsheng@627 16902 msgid ""
dongsheng@627 16903 "MQ provides a shortcut command, <command role=\"hg-ext-mq\">qcommit</"
dongsheng@627 16904 "command>, that runs <command role=\"hg-cmd\">hg commit</command> in the "
dongsheng@627 16905 "<filename role=\"special\" class=\"directory\">.hg/patches</filename> "
dongsheng@627 16906 "directory. This saves some bothersome typing."
dongsheng@627 16907 msgstr ""
dongsheng@627 16908
dongsheng@627 16909 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 16910 #: ../en/ch12-mq.xml:1116
dongsheng@627 16911 msgid ""
dongsheng@627 16912 "Finally, as a convenience to manage the patch directory, you can define the "
dongsheng@627 16913 "alias <command>mq</command> on Unix systems. For example, on Linux systems "
dongsheng@627 16914 "using the <command>bash</command> shell, you can include the following "
dongsheng@627 16915 "snippet in your <filename role=\"home\">~/.bashrc</filename>."
dongsheng@627 16916 msgstr ""
dongsheng@627 16917
dongsheng@627 16918 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 16919 #: ../en/ch12-mq.xml:1125
dongsheng@627 16920 msgid ""
dongsheng@627 16921 "You can then issue commands of the form <command>mq pull</command> from the "
dongsheng@627 16922 "main repository."
dongsheng@627 16923 msgstr ""
dongsheng@627 16924
dongsheng@627 16925 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 16926 #: ../en/ch12-mq.xml:1130
dongsheng@627 16927 msgid "A few things to watch out for"
dongsheng@636 16928 msgstr "需要注意的事情"
dongsheng@627 16929
dongsheng@627 16930 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 16931 #: ../en/ch12-mq.xml:1132
dongsheng@627 16932 msgid ""
dongsheng@627 16933 "MQ's support for working with a repository full of patches is limited in a "
dongsheng@627 16934 "few small respects."
dongsheng@627 16935 msgstr ""
dongsheng@627 16936
dongsheng@627 16937 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 16938 #: ../en/ch12-mq.xml:1135
dongsheng@627 16939 msgid ""
dongsheng@627 16940 "MQ cannot automatically detect changes that you make to the patch directory. "
dongsheng@627 16941 "If you <command role=\"hg-cmd\">hg pull</command>, manually edit, or <command "
dongsheng@627 16942 "role=\"hg-cmd\">hg update</command> changes to patches or the <filename role="
dongsheng@627 16943 "\"special\">series</filename> file, you will have to <command role=\"hg-cmd"
dongsheng@1034 16944 "\">hg qpop <option role=\"hg-ext-mq-cmd-qpop-opt\">-a</option></command> and "
dongsheng@1034 16945 "then <command role=\"hg-cmd\">hg qpush <option role=\"hg-ext-mq-cmd-qpush-opt"
dongsheng@1034 16946 "\">-a</option></command> in the underlying repository to see those changes "
dongsheng@1034 16947 "show up there. If you forget to do this, you can confuse MQ's idea of which "
dongsheng@1034 16948 "patches are applied."
dongsheng@627 16949 msgstr ""
dongsheng@627 16950
dongsheng@627 16951 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 16952 #: ../en/ch12-mq.xml:1151
dongsheng@627 16953 msgid "Third party tools for working with patches"
dongsheng@636 16954 msgstr "操作补丁的第三方工具"
dongsheng@627 16955
dongsheng@627 16956 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 16957 #: ../en/ch12-mq.xml:1153
dongsheng@627 16958 msgid ""
dongsheng@627 16959 "Once you've been working with patches for a while, you'll find yourself "
dongsheng@627 16960 "hungry for tools that will help you to understand and manipulate the patches "
dongsheng@627 16961 "you're dealing with."
dongsheng@627 16962 msgstr ""
dongsheng@627 16963
dongsheng@627 16964 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 16965 #: ../en/ch12-mq.xml:1157
dongsheng@627 16966 msgid ""
dongsheng@627 16967 "The <command>diffstat</command> command <citation>web:diffstat</citation> "
dongsheng@627 16968 "generates a histogram of the modifications made to each file in a patch. It "
songdongsheng@668 16969 "provides a good way to <quote>get a sense of</quote> a patch&emdash;which "
songdongsheng@668 16970 "files it affects, and how much change it introduces to each file and as a "
songdongsheng@668 16971 "whole. (I find that it's a good idea to use <command>diffstat</command>'s "
songdongsheng@668 16972 "<option role=\"cmd-opt-diffstat\">-p</option> option as a matter of course, "
songdongsheng@668 16973 "as otherwise it will try to do clever things with prefixes of file names that "
songdongsheng@668 16974 "inevitably confuse at least me.)"
dongsheng@627 16975 msgstr ""
dongsheng@627 16976
dongsheng@627 16977 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 16978 #: ../en/ch12-mq.xml:1171
dongsheng@627 16979 msgid ""
dongsheng@627 16980 "The <literal role=\"package\">patchutils</literal> package <citation>web:"
dongsheng@627 16981 "patchutils</citation> is invaluable. It provides a set of small utilities "
dongsheng@627 16982 "that follow the <quote>Unix philosophy;</quote> each does one useful thing "
dongsheng@627 16983 "with a patch. The <literal role=\"package\">patchutils</literal> command I "
dongsheng@627 16984 "use most is <command>filterdiff</command>, which extracts subsets from a "
dongsheng@627 16985 "patch file. For example, given a patch that modifies hundreds of files "
dongsheng@627 16986 "across dozens of directories, a single invocation of <command>filterdiff</"
dongsheng@627 16987 "command> can generate a smaller patch that only touches files whose names "
songdongsheng@658 16988 "match a particular glob pattern. See <xref linkend=\"mq-collab:tips:interdiff"
songdongsheng@658 16989 "\"/> for another example."
dongsheng@627 16990 msgstr ""
dongsheng@627 16991
dongsheng@627 16992 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 16993 #: ../en/ch12-mq.xml:1187
dongsheng@627 16994 msgid "Good ways to work with patches"
dongsheng@636 16995 msgstr "操作补丁的好习惯"
dongsheng@627 16996
dongsheng@627 16997 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 16998 #: ../en/ch12-mq.xml:1189
dongsheng@627 16999 msgid ""
dongsheng@627 17000 "Whether you are working on a patch series to submit to a free software or "
dongsheng@627 17001 "open source project, or a series that you intend to treat as a sequence of "
dongsheng@627 17002 "regular changesets when you're done, you can use some simple techniques to "
songdongsheng@710 17003 "keep your work well organized."
dongsheng@627 17004 msgstr ""
dongsheng@627 17005
dongsheng@627 17006 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 17007 #: ../en/ch12-mq.xml:1195
dongsheng@627 17008 msgid ""
dongsheng@627 17009 "Give your patches descriptive names. A good name for a patch might be "
dongsheng@627 17010 "<filename>rework-device-alloc.patch</filename>, because it will immediately "
dongsheng@627 17011 "give you a hint what the purpose of the patch is. Long names shouldn't be a "
dongsheng@627 17012 "problem; you won't be typing the names often, but you <emphasis>will</"
dongsheng@627 17013 "emphasis> be running commands like <command role=\"hg-ext-mq\">qapplied</"
dongsheng@627 17014 "command> and <command role=\"hg-ext-mq\">qtop</command> over and over. Good "
dongsheng@627 17015 "naming becomes especially important when you have a number of patches to work "
dongsheng@627 17016 "with, or if you are juggling a number of different tasks and your patches "
dongsheng@627 17017 "only get a fraction of your attention."
dongsheng@627 17018 msgstr ""
dongsheng@627 17019
dongsheng@627 17020 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 17021 #: ../en/ch12-mq.xml:1207
dongsheng@627 17022 msgid ""
dongsheng@627 17023 "Be aware of what patch you're working on. Use the <command role=\"hg-ext-mq"
songdongsheng@668 17024 "\">qtop</command> command and skim over the text of your patches "
songdongsheng@668 17025 "frequently&emdash;for example, using <command role=\"hg-cmd\">hg tip <option "
songdongsheng@668 17026 "role=\"hg-opt-tip\">-p</option></command>)&emdash;to be sure of where you "
songdongsheng@668 17027 "stand. I have several times worked on and <command role=\"hg-ext-mq"
songdongsheng@668 17028 "\">qrefresh</command>ed a patch other than the one I intended, and it's often "
songdongsheng@668 17029 "tricky to migrate changes into the right patch after making them in the wrong "
songdongsheng@668 17030 "one."
dongsheng@627 17031 msgstr ""
dongsheng@627 17032
dongsheng@627 17033 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 17034 #: ../en/ch12-mq.xml:1217
dongsheng@627 17035 msgid ""
dongsheng@627 17036 "For this reason, it is very much worth investing a little time to learn how "
songdongsheng@658 17037 "to use some of the third-party tools I described in <xref linkend=\"sec:mq:"
songdongsheng@658 17038 "tools\"/>, particularly <command>diffstat</command> and <command>filterdiff</"
songdongsheng@658 17039 "command>. The former will give you a quick idea of what changes your patch "
songdongsheng@658 17040 "is making, while the latter makes it easy to splice hunks selectively out of "
songdongsheng@658 17041 "one patch and into another."
dongsheng@627 17042 msgstr ""
dongsheng@627 17043
dongsheng@627 17044 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 17045 #: ../en/ch12-mq.xml:1228
dongsheng@627 17046 msgid "MQ cookbook"
dongsheng@636 17047 msgstr "MQ 手册"
dongsheng@627 17048
dongsheng@627 17049 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 17050 #: ../en/ch12-mq.xml:1231
dongsheng@627 17051 msgid "Manage <quote>trivial</quote> patches"
dongsheng@636 17052 msgstr "管理<quote>琐碎的</quote>补丁"
dongsheng@627 17053
dongsheng@627 17054 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 17055 #: ../en/ch12-mq.xml:1233
dongsheng@627 17056 msgid ""
dongsheng@627 17057 "Because the overhead of dropping files into a new Mercurial repository is so "
dongsheng@627 17058 "low, it makes a lot of sense to manage patches this way even if you simply "
dongsheng@627 17059 "want to make a few changes to a source tarball that you downloaded."
dongsheng@627 17060 msgstr ""
dongsheng@627 17061
dongsheng@627 17062 #
dongsheng@627 17063 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 17064 #: ../en/ch12-mq.xml:1238
dongsheng@627 17065 msgid ""
dongsheng@627 17066 "Begin by downloading and unpacking the source tarball, and turning it into a "
dongsheng@627 17067 "Mercurial repository."
dongsheng@627 17068 msgstr ""
dongsheng@627 17069
dongsheng@627 17070 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 17071 #: ../en/ch12-mq.xml:1243
dongsheng@627 17072 msgid "Continue by creating a patch stack and making your changes."
dongsheng@627 17073 msgstr ""
dongsheng@627 17074
dongsheng@627 17075 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 17076 #: ../en/ch12-mq.xml:1248
dongsheng@627 17077 msgid ""
dongsheng@627 17078 "Let's say a few weeks or months pass, and your package author releases a new "
dongsheng@627 17079 "version. First, bring their changes into the repository."
dongsheng@627 17080 msgstr ""
dongsheng@627 17081
dongsheng@627 17082 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 17083 #: ../en/ch12-mq.xml:1254
dongsheng@627 17084 msgid ""
dongsheng@627 17085 "The pipeline starting with <command role=\"hg-cmd\">hg locate</command> above "
dongsheng@627 17086 "deletes all files in the working directory, so that <command role=\"hg-cmd"
dongsheng@627 17087 "\">hg commit</command>'s <option role=\"hg-opt-commit\">--addremove</option> "
dongsheng@627 17088 "option can actually tell which files have really been removed in the newer "
dongsheng@627 17089 "version of the source."
dongsheng@627 17090 msgstr ""
dongsheng@627 17091
dongsheng@627 17092 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 17093 #: ../en/ch12-mq.xml:1262
dongsheng@627 17094 msgid "Finally, you can apply your patches on top of the new tree."
dongsheng@627 17095 msgstr ""
dongsheng@627 17096
dongsheng@627 17097 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 17098 #: ../en/ch12-mq.xml:1269
dongsheng@627 17099 msgid "Combining entire patches"
dongsheng@636 17100 msgstr "组合全部的补丁"
dongsheng@627 17101
dongsheng@627 17102 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 17103 #: ../en/ch12-mq.xml:1271
dongsheng@627 17104 msgid ""
dongsheng@627 17105 "MQ provides a command, <command role=\"hg-ext-mq\">qfold</command> that lets "
dongsheng@627 17106 "you combine entire patches. This <quote>folds</quote> the patches you name, "
dongsheng@627 17107 "in the order you name them, into the topmost applied patch, and concatenates "
dongsheng@627 17108 "their descriptions onto the end of its description. The patches that you "
dongsheng@627 17109 "fold must be unapplied before you fold them."
dongsheng@627 17110 msgstr ""
dongsheng@627 17111
dongsheng@627 17112 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 17113 #: ../en/ch12-mq.xml:1279
dongsheng@627 17114 msgid ""
dongsheng@627 17115 "The order in which you fold patches matters. If your topmost applied patch "
dongsheng@627 17116 "is <literal>foo</literal>, and you <command role=\"hg-ext-mq\">qfold</"
dongsheng@627 17117 "command> <literal>bar</literal> and <literal>quux</literal> into it, you will "
dongsheng@627 17118 "end up with a patch that has the same effect as if you applied first "
dongsheng@627 17119 "<literal>foo</literal>, then <literal>bar</literal>, followed by "
dongsheng@627 17120 "<literal>quux</literal>."
dongsheng@627 17121 msgstr ""
dongsheng@627 17122
dongsheng@627 17123 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 17124 #: ../en/ch12-mq.xml:1290
dongsheng@627 17125 msgid "Merging part of one patch into another"
dongsheng@636 17126 msgstr "合并补丁的部分内容到其它补丁"
dongsheng@627 17127
dongsheng@627 17128 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 17129 #: ../en/ch12-mq.xml:1292
dongsheng@627 17130 msgid ""
dongsheng@627 17131 "Merging <emphasis>part</emphasis> of one patch into another is more difficult "
dongsheng@627 17132 "than combining entire patches."
dongsheng@627 17133 msgstr ""
dongsheng@627 17134
dongsheng@627 17135 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 17136 #: ../en/ch12-mq.xml:1296
dongsheng@627 17137 msgid ""
dongsheng@627 17138 "If you want to move changes to entire files, you can use <command>filterdiff</"
dongsheng@627 17139 "command>'s <option role=\"cmd-opt-filterdiff\">-i</option> and <option role="
dongsheng@627 17140 "\"cmd-opt-filterdiff\">-x</option> options to choose the modifications to "
dongsheng@627 17141 "snip out of one patch, concatenating its output onto the end of the patch you "
dongsheng@627 17142 "want to merge into. You usually won't need to modify the patch you've merged "
dongsheng@627 17143 "the changes from. Instead, MQ will report some rejected hunks when you "
dongsheng@627 17144 "<command role=\"hg-ext-mq\">qpush</command> it (from the hunks you moved into "
dongsheng@627 17145 "the other patch), and you can simply <command role=\"hg-ext-mq\">qrefresh</"
dongsheng@627 17146 "command> the patch to drop the duplicate hunks."
dongsheng@627 17147 msgstr ""
dongsheng@627 17148
dongsheng@627 17149 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 17150 #: ../en/ch12-mq.xml:1309
dongsheng@627 17151 msgid ""
dongsheng@627 17152 "If you have a patch that has multiple hunks modifying a file, and you only "
dongsheng@627 17153 "want to move a few of those hunks, the job becomes more messy, but you can "
dongsheng@627 17154 "still partly automate it. Use <command>lsdiff -nvv</command> to print some "
dongsheng@627 17155 "metadata about the patch."
dongsheng@627 17156 msgstr ""
dongsheng@627 17157
dongsheng@627 17158 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 17159 #: ../en/ch12-mq.xml:1317
dongsheng@627 17160 msgid "This command prints three different kinds of number:"
dongsheng@627 17161 msgstr ""
dongsheng@627 17162
dongsheng@627 17163 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 17164 #: ../en/ch12-mq.xml:1320
dongsheng@627 17165 msgid ""
dongsheng@627 17166 "(in the first column) a <emphasis>file number</emphasis> to identify each "
dongsheng@627 17167 "file modified in the patch;"
dongsheng@627 17168 msgstr ""
dongsheng@627 17169
dongsheng@627 17170 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 17171 #: ../en/ch12-mq.xml:1324
dongsheng@627 17172 msgid ""
dongsheng@627 17173 "(on the next line, indented) the line number within a modified file where a "
dongsheng@627 17174 "hunk starts; and"
dongsheng@627 17175 msgstr ""
dongsheng@627 17176
dongsheng@627 17177 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 17178 #: ../en/ch12-mq.xml:1327
dongsheng@627 17179 msgid ""
dongsheng@627 17180 "(on the same line) a <emphasis>hunk number</emphasis> to identify that hunk."
dongsheng@627 17181 msgstr ""
dongsheng@627 17182
dongsheng@627 17183 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 17184 #: ../en/ch12-mq.xml:1331
dongsheng@627 17185 msgid ""
dongsheng@627 17186 "You'll have to use some visual inspection, and reading of the patch, to "
dongsheng@627 17187 "identify the file and hunk numbers you'll want, but you can then pass them to "
dongsheng@627 17188 "to <command>filterdiff</command>'s <option role=\"cmd-opt-filterdiff\">--"
dongsheng@627 17189 "files</option> and <option role=\"cmd-opt-filterdiff\">--hunks</option> "
dongsheng@627 17190 "options, to select exactly the file and hunk you want to extract."
dongsheng@627 17191 msgstr ""
dongsheng@627 17192
dongsheng@627 17193 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 17194 #: ../en/ch12-mq.xml:1339
dongsheng@627 17195 msgid ""
dongsheng@627 17196 "Once you have this hunk, you can concatenate it onto the end of your "
songdongsheng@658 17197 "destination patch and continue with the remainder of <xref linkend=\"sec:mq:"
songdongsheng@658 17198 "combine\"/>."
dongsheng@627 17199 msgstr ""
dongsheng@627 17200
dongsheng@627 17201 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 17202 #: ../en/ch12-mq.xml:1346
dongsheng@627 17203 msgid "Differences between quilt and MQ"
dongsheng@636 17204 msgstr "MQ 与 quilt 的区别"
dongsheng@627 17205
dongsheng@627 17206 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 17207 #: ../en/ch12-mq.xml:1348
dongsheng@627 17208 msgid ""
dongsheng@627 17209 "If you are already familiar with quilt, MQ provides a similar command set. "
dongsheng@627 17210 "There are a few differences in the way that it works."
dongsheng@627 17211 msgstr ""
dongsheng@627 17212
dongsheng@627 17213 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 17214 #: ../en/ch12-mq.xml:1352
dongsheng@627 17215 msgid ""
dongsheng@627 17216 "You will already have noticed that most quilt commands have MQ counterparts "
dongsheng@627 17217 "that simply begin with a <quote><literal>q</literal></quote>. The exceptions "
dongsheng@627 17218 "are quilt's <literal>add</literal> and <literal>remove</literal> commands, "
dongsheng@627 17219 "the counterparts for which are the normal Mercurial <command role=\"hg-cmd"
dongsheng@627 17220 "\">hg add</command> and <command role=\"hg-cmd\">hg remove</command> "
dongsheng@627 17221 "commands. There is no MQ equivalent of the quilt <literal>edit</literal> "
dongsheng@627 17222 "command."
dongsheng@627 17223 msgstr ""
dongsheng@627 17224
dongsheng@627 17225 #. type: Content of: <book><chapter><title>
dongsheng@714 17226 #: ../en/ch13-mq-collab.xml:5
dongsheng@627 17227 msgid "Advanced uses of Mercurial Queues"
dongsheng@627 17228 msgstr "MQ 的高级用法"
dongsheng@627 17229
dongsheng@627 17230 #. type: Content of: <book><chapter><para>
dongsheng@714 17231 #: ../en/ch13-mq-collab.xml:7
dongsheng@627 17232 msgid ""
dongsheng@627 17233 "While it's easy to pick up straightforward uses of Mercurial Queues, use of a "
dongsheng@627 17234 "little discipline and some of MQ's less frequently used capabilities makes it "
dongsheng@627 17235 "possible to work in complicated development environments."
dongsheng@627 17236 msgstr ""
dongsheng@627 17237
dongsheng@627 17238 #. type: Content of: <book><chapter><para>
dongsheng@714 17239 #: ../en/ch13-mq-collab.xml:12
dongsheng@627 17240 msgid ""
dongsheng@627 17241 "In this chapter, I will use as an example a technique I have used to manage "
dongsheng@627 17242 "the development of an Infiniband device driver for the Linux kernel. The "
dongsheng@627 17243 "driver in question is large (at least as drivers go), with 25,000 lines of "
dongsheng@627 17244 "code spread across 35 source files. It is maintained by a small team of "
dongsheng@627 17245 "developers."
dongsheng@627 17246 msgstr ""
dongsheng@627 17247
dongsheng@627 17248 #. type: Content of: <book><chapter><para>
dongsheng@714 17249 #: ../en/ch13-mq-collab.xml:18
dongsheng@627 17250 msgid ""
dongsheng@627 17251 "While much of the material in this chapter is specific to Linux, the same "
dongsheng@627 17252 "principles apply to any code base for which you're not the primary owner, and "
dongsheng@627 17253 "upon which you need to do a lot of development."
dongsheng@627 17254 msgstr ""
dongsheng@627 17255
dongsheng@627 17256 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 17257 #: ../en/ch13-mq-collab.xml:24
dongsheng@627 17258 msgid "The problem of many targets"
dongsheng@636 17259 msgstr "多个目标的问题"
dongsheng@627 17260
dongsheng@627 17261 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 17262 #: ../en/ch13-mq-collab.xml:26
dongsheng@627 17263 msgid ""
dongsheng@627 17264 "The Linux kernel changes rapidly, and has never been internally stable; "
dongsheng@627 17265 "developers frequently make drastic changes between releases. This means that "
dongsheng@627 17266 "a version of the driver that works well with a particular released version of "
dongsheng@627 17267 "the kernel will not even <emphasis>compile</emphasis> correctly against, "
dongsheng@627 17268 "typically, any other version."
dongsheng@627 17269 msgstr ""
dongsheng@627 17270
dongsheng@627 17271 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 17272 #: ../en/ch13-mq-collab.xml:33
dongsheng@627 17273 msgid ""
dongsheng@627 17274 "To maintain a driver, we have to keep a number of distinct versions of Linux "
dongsheng@627 17275 "in mind."
dongsheng@627 17276 msgstr ""
dongsheng@627 17277
dongsheng@627 17278 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 17279 #: ../en/ch13-mq-collab.xml:36
dongsheng@627 17280 msgid ""
dongsheng@627 17281 "One target is the main Linux kernel development tree. Maintenance of the code "
dongsheng@627 17282 "is in this case partly shared by other developers in the kernel community, "
dongsheng@627 17283 "who make <quote>drive-by</quote> modifications to the driver as they develop "
dongsheng@627 17284 "and refine kernel subsystems."
dongsheng@627 17285 msgstr ""
dongsheng@627 17286
dongsheng@627 17287 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 17288 #: ../en/ch13-mq-collab.xml:42
dongsheng@627 17289 msgid ""
dongsheng@627 17290 "We also maintain a number of <quote>backports</quote> to older versions of "
dongsheng@627 17291 "the Linux kernel, to support the needs of customers who are running older "
dongsheng@627 17292 "Linux distributions that do not incorporate our drivers. (To "
dongsheng@627 17293 "<emphasis>backport</emphasis> a piece of code is to modify it to work in an "
dongsheng@627 17294 "older version of its target environment than the version it was developed "
dongsheng@627 17295 "for.)"
dongsheng@627 17296 msgstr ""
dongsheng@627 17297
dongsheng@627 17298 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 17299 #: ../en/ch13-mq-collab.xml:50
dongsheng@627 17300 msgid ""
dongsheng@627 17301 "Finally, we make software releases on a schedule that is necessarily not "
dongsheng@627 17302 "aligned with those used by Linux distributors and kernel developers, so that "
dongsheng@627 17303 "we can deliver new features to customers without forcing them to upgrade "
dongsheng@627 17304 "their entire kernels or distributions."
dongsheng@627 17305 msgstr ""
dongsheng@627 17306
dongsheng@627 17307 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 17308 #: ../en/ch13-mq-collab.xml:58
dongsheng@627 17309 msgid "Tempting approaches that don't work well"
dongsheng@636 17310 msgstr "工作不好的诱人方法"
dongsheng@627 17311
dongsheng@627 17312 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 17313 #: ../en/ch13-mq-collab.xml:60
dongsheng@627 17314 msgid ""
dongsheng@627 17315 "There are two <quote>standard</quote> ways to maintain a piece of software "
dongsheng@627 17316 "that has to target many different environments."
dongsheng@627 17317 msgstr ""
dongsheng@627 17318
dongsheng@627 17319 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 17320 #: ../en/ch13-mq-collab.xml:64
dongsheng@627 17321 msgid ""
dongsheng@627 17322 "The first is to maintain a number of branches, each intended for a single "
dongsheng@627 17323 "target. The trouble with this approach is that you must maintain iron "
dongsheng@627 17324 "discipline in the flow of changes between repositories. A new feature or bug "
dongsheng@627 17325 "fix must start life in a <quote>pristine</quote> repository, then percolate "
dongsheng@627 17326 "out to every backport repository. Backport changes are more limited in the "
dongsheng@627 17327 "branches they should propagate to; a backport change that is applied to a "
dongsheng@627 17328 "branch where it doesn't belong will probably stop the driver from compiling."
dongsheng@627 17329 msgstr ""
dongsheng@627 17330
dongsheng@627 17331 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 17332 #: ../en/ch13-mq-collab.xml:74
dongsheng@627 17333 msgid ""
dongsheng@627 17334 "The second is to maintain a single source tree filled with conditional "
dongsheng@627 17335 "statements that turn chunks of code on or off depending on the intended "
dongsheng@627 17336 "target. Because these <quote>ifdefs</quote> are not allowed in the Linux "
dongsheng@627 17337 "kernel tree, a manual or automatic process must be followed to strip them out "
dongsheng@627 17338 "and yield a clean tree. A code base maintained in this fashion rapidly "
dongsheng@627 17339 "becomes a rat's nest of conditional blocks that are difficult to understand "
dongsheng@627 17340 "and maintain."
dongsheng@627 17341 msgstr ""
dongsheng@627 17342
dongsheng@627 17343 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 17344 #: ../en/ch13-mq-collab.xml:83
dongsheng@627 17345 msgid ""
dongsheng@627 17346 "Neither of these approaches is well suited to a situation where you don't "
dongsheng@627 17347 "<quote>own</quote> the canonical copy of a source tree. In the case of a "
dongsheng@627 17348 "Linux driver that is distributed with the standard kernel, Linus's tree "
dongsheng@627 17349 "contains the copy of the code that will be treated by the world as "
dongsheng@627 17350 "canonical. The upstream version of <quote>my</quote> driver can be modified "
dongsheng@627 17351 "by people I don't know, without me even finding out about it until after the "
dongsheng@627 17352 "changes show up in Linus's tree."
dongsheng@627 17353 msgstr ""
dongsheng@627 17354
dongsheng@627 17355 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 17356 #: ../en/ch13-mq-collab.xml:93
dongsheng@627 17357 msgid ""
dongsheng@627 17358 "These approaches have the added weakness of making it difficult to generate "
dongsheng@627 17359 "well-formed patches to submit upstream."
dongsheng@627 17360 msgstr ""
dongsheng@627 17361
dongsheng@627 17362 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 17363 #: ../en/ch13-mq-collab.xml:97
dongsheng@627 17364 msgid ""
dongsheng@627 17365 "In principle, Mercurial Queues seems like a good candidate to manage a "
dongsheng@627 17366 "development scenario such as the above. While this is indeed the case, MQ "
dongsheng@627 17367 "contains a few added features that make the job more pleasant."
dongsheng@627 17368 msgstr ""
dongsheng@627 17369
dongsheng@627 17370 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 17371 #: ../en/ch13-mq-collab.xml:105
dongsheng@627 17372 msgid "Conditionally applying patches with guards"
dongsheng@636 17373 msgstr "有条件的应用补丁"
dongsheng@627 17374
dongsheng@627 17375 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 17376 #: ../en/ch13-mq-collab.xml:107
dongsheng@627 17377 msgid ""
dongsheng@627 17378 "Perhaps the best way to maintain sanity with so many targets is to be able to "
dongsheng@627 17379 "choose specific patches to apply for a given situation. MQ provides a "
dongsheng@627 17380 "feature called <quote>guards</quote> (which originates with quilt's "
dongsheng@627 17381 "<literal>guards</literal> command) that does just this. To start off, let's "
dongsheng@627 17382 "create a simple repository for experimenting in."
dongsheng@627 17383 msgstr ""
dongsheng@627 17384
dongsheng@627 17385 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 17386 #: ../en/ch13-mq-collab.xml:116
dongsheng@627 17387 msgid ""
dongsheng@627 17388 "This gives us a tiny repository that contains two patches that don't have any "
dongsheng@627 17389 "dependencies on each other, because they touch different files."
dongsheng@627 17390 msgstr ""
dongsheng@627 17391
dongsheng@627 17392 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 17393 #: ../en/ch13-mq-collab.xml:120
dongsheng@627 17394 msgid ""
dongsheng@627 17395 "The idea behind conditional application is that you can <quote>tag</quote> a "
dongsheng@627 17396 "patch with a <emphasis>guard</emphasis>, which is simply a text string of "
dongsheng@627 17397 "your choosing, then tell MQ to select specific guards to use when applying "
dongsheng@627 17398 "patches. MQ will then either apply, or skip over, a guarded patch, depending "
dongsheng@627 17399 "on the guards that you have selected."
dongsheng@627 17400 msgstr ""
dongsheng@627 17401
dongsheng@627 17402 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 17403 #: ../en/ch13-mq-collab.xml:127
dongsheng@627 17404 msgid ""
dongsheng@627 17405 "A patch can have an arbitrary number of guards; each one is "
dongsheng@627 17406 "<emphasis>positive</emphasis> (<quote>apply this patch if this guard is "
dongsheng@627 17407 "selected</quote>) or <emphasis>negative</emphasis> (<quote>skip this patch if "
dongsheng@627 17408 "this guard is selected</quote>). A patch with no guards is always applied."
dongsheng@627 17409 msgstr ""
dongsheng@627 17410
dongsheng@627 17411 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 17412 #: ../en/ch13-mq-collab.xml:135
dongsheng@627 17413 msgid "Controlling the guards on a patch"
dongsheng@636 17414 msgstr "控制补丁的应用条件"
dongsheng@627 17415
dongsheng@627 17416 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 17417 #: ../en/ch13-mq-collab.xml:137
dongsheng@627 17418 msgid ""
dongsheng@627 17419 "The <command role=\"hg-ext-mq\">qguard</command> command lets you determine "
dongsheng@627 17420 "which guards should apply to a patch, or display the guards that are already "
dongsheng@627 17421 "in effect. Without any arguments, it displays the guards on the current "
dongsheng@627 17422 "topmost patch."
dongsheng@627 17423 msgstr ""
dongsheng@627 17424
dongsheng@627 17425 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 17426 #: ../en/ch13-mq-collab.xml:144
dongsheng@627 17427 msgid ""
dongsheng@627 17428 "To set a positive guard on a patch, prefix the name of the guard with a "
dongsheng@627 17429 "<quote><literal>+</literal></quote>."
dongsheng@627 17430 msgstr ""
dongsheng@627 17431
dongsheng@627 17432 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 17433 #: ../en/ch13-mq-collab.xml:149
dongsheng@627 17434 msgid ""
dongsheng@627 17435 "To set a negative guard on a patch, prefix the name of the guard with a "
dongsheng@627 17436 "<quote><literal>-</literal></quote>."
dongsheng@627 17437 msgstr ""
dongsheng@627 17438
dongsheng@714 17439 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 17440 #: ../en/ch13-mq-collab.xml:155
dongsheng@714 17441 msgid ""
dongsheng@714 17442 "Notice that we prefixed the arguments to the <command>hg qguard</command> "
dongsheng@714 17443 "command with a <literal>--</literal> here, so that Mercurial would not "
dongsheng@714 17444 "interpret the text <literal>-quux</literal> as an option."
dongsheng@714 17445 msgstr ""
dongsheng@714 17446
dongsheng@714 17447 #. type: Content of: <book><chapter><sect1><note><title>
dongsheng@714 17448 #: ../en/ch13-mq-collab.xml:161
dongsheng@714 17449 msgid "Setting vs. modifying"
dongsheng@714 17450 msgstr ""
dongsheng@714 17451
dongsheng@627 17452 #. type: Content of: <book><chapter><sect1><note><para>
dongsheng@714 17453 #: ../en/ch13-mq-collab.xml:163
dongsheng@627 17454 msgid ""
dongsheng@627 17455 "The <command role=\"hg-ext-mq\">qguard</command> command <emphasis>sets</"
dongsheng@627 17456 "emphasis> the guards on a patch; it doesn't <emphasis>modify</emphasis> "
dongsheng@627 17457 "them. What this means is that if you run <command role=\"hg-cmd\">hg qguard "
dongsheng@627 17458 "+a +b</command> on a patch, then <command role=\"hg-cmd\">hg qguard +c</"
dongsheng@627 17459 "command> on the same patch, the <emphasis>only</emphasis> guard that will be "
dongsheng@627 17460 "set on it afterwards is <literal>+c</literal>."
dongsheng@627 17461 msgstr ""
dongsheng@627 17462
dongsheng@627 17463 #
dongsheng@627 17464 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 17465 #: ../en/ch13-mq-collab.xml:172
dongsheng@627 17466 msgid ""
dongsheng@627 17467 "Mercurial stores guards in the <filename role=\"special\">series</filename> "
dongsheng@627 17468 "file; the form in which they are stored is easy both to understand and to "
dongsheng@627 17469 "edit by hand. (In other words, you don't have to use the <command role=\"hg-"
dongsheng@627 17470 "ext-mq\">qguard</command> command if you don't want to; it's okay to simply "
dongsheng@627 17471 "edit the <filename role=\"special\">series</filename> file.)"
dongsheng@627 17472 msgstr ""
dongsheng@627 17473
dongsheng@627 17474 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 17475 #: ../en/ch13-mq-collab.xml:184
dongsheng@627 17476 msgid "Selecting the guards to use"
dongsheng@636 17477 msgstr "选择使用的条件"
dongsheng@627 17478
dongsheng@627 17479 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 17480 #: ../en/ch13-mq-collab.xml:186
dongsheng@627 17481 msgid ""
dongsheng@627 17482 "The <command role=\"hg-ext-mq\">qselect</command> command determines which "
dongsheng@627 17483 "guards are active at a given time. The effect of this is to determine which "
dongsheng@627 17484 "patches MQ will apply the next time you run <command role=\"hg-ext-mq"
dongsheng@627 17485 "\">qpush</command>. It has no other effect; in particular, it doesn't do "
dongsheng@627 17486 "anything to patches that are already applied."
dongsheng@627 17487 msgstr ""
dongsheng@627 17488
dongsheng@627 17489 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 17490 #: ../en/ch13-mq-collab.xml:193
dongsheng@627 17491 msgid ""
dongsheng@627 17492 "With no arguments, the <command role=\"hg-ext-mq\">qselect</command> command "
dongsheng@627 17493 "lists the guards currently in effect, one per line of output. Each argument "
dongsheng@627 17494 "is treated as the name of a guard to apply."
dongsheng@627 17495 msgstr ""
dongsheng@627 17496
dongsheng@627 17497 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 17498 #: ../en/ch13-mq-collab.xml:200
dongsheng@627 17499 msgid ""
dongsheng@627 17500 "In case you're interested, the currently selected guards are stored in the "
dongsheng@627 17501 "<filename role=\"special\">guards</filename> file."
dongsheng@627 17502 msgstr ""
dongsheng@627 17503
dongsheng@627 17504 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 17505 #: ../en/ch13-mq-collab.xml:205
dongsheng@627 17506 msgid ""
dongsheng@627 17507 "We can see the effect the selected guards have when we run <command role=\"hg-"
dongsheng@627 17508 "ext-mq\">qpush</command>."
dongsheng@627 17509 msgstr ""
dongsheng@627 17510
dongsheng@627 17511 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 17512 #: ../en/ch13-mq-collab.xml:210
dongsheng@627 17513 msgid ""
dongsheng@627 17514 "A guard cannot start with a <quote><literal>+</literal></quote> or "
dongsheng@627 17515 "<quote><literal>-</literal></quote> character. The name of a guard must not "
dongsheng@627 17516 "contain white space, but most other characters are acceptable. If you try to "
dongsheng@627 17517 "use a guard with an invalid name, MQ will complain:"
dongsheng@627 17518 msgstr ""
dongsheng@627 17519
dongsheng@627 17520 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 17521 #: ../en/ch13-mq-collab.xml:219
dongsheng@627 17522 msgid "Changing the selected guards changes the patches that are applied."
dongsheng@627 17523 msgstr ""
dongsheng@627 17524
dongsheng@627 17525 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 17526 #: ../en/ch13-mq-collab.xml:224
dongsheng@627 17527 msgid ""
dongsheng@627 17528 "You can see in the example below that negative guards take precedence over "
dongsheng@627 17529 "positive guards."
dongsheng@627 17530 msgstr ""
dongsheng@627 17531
dongsheng@627 17532 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 17533 #: ../en/ch13-mq-collab.xml:231
dongsheng@627 17534 msgid "MQ's rules for applying patches"
dongsheng@636 17535 msgstr "MQ 应用补丁的规则"
dongsheng@627 17536
dongsheng@627 17537 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 17538 #: ../en/ch13-mq-collab.xml:233
dongsheng@627 17539 msgid ""
dongsheng@627 17540 "The rules that MQ uses when deciding whether to apply a patch are as follows."
dongsheng@627 17541 msgstr ""
dongsheng@627 17542
dongsheng@627 17543 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 17544 #: ../en/ch13-mq-collab.xml:236
dongsheng@627 17545 msgid "A patch that has no guards is always applied."
dongsheng@627 17546 msgstr ""
dongsheng@627 17547
dongsheng@627 17548 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 17549 #: ../en/ch13-mq-collab.xml:239
dongsheng@627 17550 msgid ""
dongsheng@627 17551 "If the patch has any negative guard that matches any currently selected "
dongsheng@627 17552 "guard, the patch is skipped."
dongsheng@627 17553 msgstr ""
dongsheng@627 17554
dongsheng@627 17555 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 17556 #: ../en/ch13-mq-collab.xml:242
dongsheng@627 17557 msgid ""
dongsheng@627 17558 "If the patch has any positive guard that matches any currently selected "
dongsheng@627 17559 "guard, the patch is applied."
dongsheng@627 17560 msgstr ""
dongsheng@627 17561
dongsheng@627 17562 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 17563 #: ../en/ch13-mq-collab.xml:245
dongsheng@627 17564 msgid ""
dongsheng@627 17565 "If the patch has positive or negative guards, but none matches any currently "
dongsheng@627 17566 "selected guard, the patch is skipped."
dongsheng@627 17567 msgstr ""
dongsheng@627 17568
dongsheng@627 17569 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 17570 #: ../en/ch13-mq-collab.xml:252
dongsheng@627 17571 msgid "Trimming the work environment"
dongsheng@636 17572 msgstr "修剪工作环境"
dongsheng@627 17573
dongsheng@627 17574 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 17575 #: ../en/ch13-mq-collab.xml:254
dongsheng@627 17576 msgid ""
dongsheng@627 17577 "In working on the device driver I mentioned earlier, I don't apply the "
dongsheng@627 17578 "patches to a normal Linux kernel tree. Instead, I use a repository that "
dongsheng@627 17579 "contains only a snapshot of the source files and headers that are relevant to "
dongsheng@627 17580 "Infiniband development. This repository is 1% the size of a kernel "
dongsheng@627 17581 "repository, so it's easier to work with."
dongsheng@627 17582 msgstr ""
dongsheng@627 17583
dongsheng@627 17584 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 17585 #: ../en/ch13-mq-collab.xml:261
dongsheng@627 17586 msgid ""
dongsheng@627 17587 "I then choose a <quote>base</quote> version on top of which the patches are "
dongsheng@627 17588 "applied. This is a snapshot of the Linux kernel tree as of a revision of my "
dongsheng@627 17589 "choosing. When I take the snapshot, I record the changeset ID from the "
dongsheng@627 17590 "kernel repository in the commit message. Since the snapshot preserves the "
dongsheng@627 17591 "<quote>shape</quote> and content of the relevant parts of the kernel tree, I "
dongsheng@627 17592 "can apply my patches on top of either my tiny repository or a normal kernel "
dongsheng@627 17593 "tree."
dongsheng@627 17594 msgstr ""
dongsheng@627 17595
dongsheng@627 17596 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 17597 #: ../en/ch13-mq-collab.xml:270
dongsheng@627 17598 msgid ""
dongsheng@627 17599 "Normally, the base tree atop which the patches apply should be a snapshot of "
dongsheng@627 17600 "a very recent upstream tree. This best facilitates the development of "
dongsheng@627 17601 "patches that can easily be submitted upstream with few or no modifications."
dongsheng@627 17602 msgstr ""
dongsheng@627 17603
dongsheng@627 17604 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 17605 #: ../en/ch13-mq-collab.xml:277
dongsheng@627 17606 msgid "Dividing up the <filename role=\"special\">series</filename> file"
dongsheng@636 17607 msgstr "分类补丁<filename role=\"special\">系列</filename>"
dongsheng@627 17608
dongsheng@627 17609 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 17610 #: ../en/ch13-mq-collab.xml:280
dongsheng@627 17611 msgid ""
dongsheng@627 17612 "I categorise the patches in the <filename role=\"special\">series</filename> "
dongsheng@627 17613 "file into a number of logical groups. Each section of like patches begins "
dongsheng@627 17614 "with a block of comments that describes the purpose of the patches that "
dongsheng@627 17615 "follow."
dongsheng@627 17616 msgstr ""
dongsheng@627 17617
dongsheng@627 17618 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 17619 #: ../en/ch13-mq-collab.xml:286
dongsheng@627 17620 msgid ""
dongsheng@627 17621 "The sequence of patch groups that I maintain follows. The ordering of these "
dongsheng@627 17622 "groups is important; I'll describe why after I introduce the groups."
dongsheng@627 17623 msgstr ""
dongsheng@627 17624
dongsheng@627 17625 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 17626 #: ../en/ch13-mq-collab.xml:290
dongsheng@627 17627 msgid ""
dongsheng@627 17628 "The <quote>accepted</quote> group. Patches that the development team has "
dongsheng@627 17629 "submitted to the maintainer of the Infiniband subsystem, and which he has "
dongsheng@627 17630 "accepted, but which are not present in the snapshot that the tiny repository "
dongsheng@627 17631 "is based on. These are <quote>read only</quote> patches, present only to "
dongsheng@627 17632 "transform the tree into a similar state as it is in the upstream maintainer's "
dongsheng@627 17633 "repository."
dongsheng@627 17634 msgstr ""
dongsheng@627 17635
dongsheng@627 17636 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 17637 #: ../en/ch13-mq-collab.xml:298
dongsheng@627 17638 msgid ""
dongsheng@627 17639 "The <quote>rework</quote> group. Patches that I have submitted, but that the "
dongsheng@627 17640 "upstream maintainer has requested modifications to before he will accept them."
dongsheng@627 17641 msgstr ""
dongsheng@627 17642
dongsheng@627 17643 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 17644 #: ../en/ch13-mq-collab.xml:303
dongsheng@627 17645 msgid ""
dongsheng@627 17646 "The <quote>pending</quote> group. Patches that I have not yet submitted to "
dongsheng@627 17647 "the upstream maintainer, but which we have finished working on. These will be "
dongsheng@627 17648 "<quote>read only</quote> for a while. If the upstream maintainer accepts "
dongsheng@627 17649 "them upon submission, I'll move them to the end of the <quote>accepted</"
dongsheng@627 17650 "quote> group. If he requests that I modify any, I'll move them to the "
dongsheng@627 17651 "beginning of the <quote>rework</quote> group."
dongsheng@627 17652 msgstr ""
dongsheng@627 17653
dongsheng@627 17654 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 17655 #: ../en/ch13-mq-collab.xml:312
dongsheng@627 17656 msgid ""
dongsheng@627 17657 "The <quote>in progress</quote> group. Patches that are actively being "
dongsheng@627 17658 "developed, and should not be submitted anywhere yet."
dongsheng@627 17659 msgstr ""
dongsheng@627 17660
dongsheng@627 17661 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 17662 #: ../en/ch13-mq-collab.xml:316
dongsheng@627 17663 msgid ""
dongsheng@627 17664 "The <quote>backport</quote> group. Patches that adapt the source tree to "
dongsheng@627 17665 "older versions of the kernel tree."
dongsheng@627 17666 msgstr ""
dongsheng@627 17667
dongsheng@627 17668 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 17669 #: ../en/ch13-mq-collab.xml:320
dongsheng@627 17670 msgid ""
dongsheng@627 17671 "The <quote>do not ship</quote> group. Patches that for some reason should "
dongsheng@627 17672 "never be submitted upstream. For example, one such patch might change "
dongsheng@627 17673 "embedded driver identification strings to make it easier to distinguish, in "
dongsheng@627 17674 "the field, between an out-of-tree version of the driver and a version shipped "
dongsheng@627 17675 "by a distribution vendor."
dongsheng@627 17676 msgstr ""
dongsheng@627 17677
dongsheng@627 17678 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 17679 #: ../en/ch13-mq-collab.xml:328
dongsheng@627 17680 msgid ""
dongsheng@627 17681 "Now to return to the reasons for ordering groups of patches in this way. We "
dongsheng@627 17682 "would like the lowest patches in the stack to be as stable as possible, so "
dongsheng@627 17683 "that we will not need to rework higher patches due to changes in context. "
dongsheng@627 17684 "Putting patches that will never be changed first in the <filename role="
dongsheng@627 17685 "\"special\">series</filename> file serves this purpose."
dongsheng@627 17686 msgstr ""
dongsheng@627 17687
dongsheng@627 17688 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 17689 #: ../en/ch13-mq-collab.xml:336
dongsheng@627 17690 msgid ""
dongsheng@627 17691 "We would also like the patches that we know we'll need to modify to be "
dongsheng@627 17692 "applied on top of a source tree that resembles the upstream tree as closely "
dongsheng@627 17693 "as possible. This is why we keep accepted patches around for a while."
dongsheng@627 17694 msgstr ""
dongsheng@627 17695
dongsheng@627 17696 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 17697 #: ../en/ch13-mq-collab.xml:341
dongsheng@627 17698 msgid ""
dongsheng@627 17699 "The <quote>backport</quote> and <quote>do not ship</quote> patches float at "
dongsheng@627 17700 "the end of the <filename role=\"special\">series</filename> file. The "
dongsheng@627 17701 "backport patches must be applied on top of all other patches, and the "
dongsheng@627 17702 "<quote>do not ship</quote> patches might as well stay out of harm's way."
dongsheng@627 17703 msgstr ""
dongsheng@627 17704
dongsheng@627 17705 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 17706 #: ../en/ch13-mq-collab.xml:350
dongsheng@627 17707 msgid "Maintaining the patch series"
dongsheng@636 17708 msgstr "维护补丁系列"
dongsheng@627 17709
dongsheng@627 17710 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 17711 #: ../en/ch13-mq-collab.xml:352
dongsheng@627 17712 msgid ""
dongsheng@627 17713 "In my work, I use a number of guards to control which patches are to be "
dongsheng@627 17714 "applied."
dongsheng@627 17715 msgstr ""
dongsheng@627 17716
dongsheng@627 17717 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 17718 #: ../en/ch13-mq-collab.xml:356
dongsheng@627 17719 msgid ""
dongsheng@627 17720 "<quote>Accepted</quote> patches are guarded with <literal>accepted</"
dongsheng@627 17721 "literal>. I enable this guard most of the time. When I'm applying the "
dongsheng@627 17722 "patches on top of a tree where the patches are already present, I can turn "
dongsheng@627 17723 "this patch off, and the patches that follow it will apply cleanly."
dongsheng@627 17724 msgstr ""
dongsheng@627 17725
dongsheng@627 17726 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 17727 #: ../en/ch13-mq-collab.xml:363
dongsheng@627 17728 msgid ""
dongsheng@627 17729 "Patches that are <quote>finished</quote>, but not yet submitted, have no "
dongsheng@627 17730 "guards. If I'm applying the patch stack to a copy of the upstream tree, I "
dongsheng@627 17731 "don't need to enable any guards in order to get a reasonably safe source tree."
dongsheng@627 17732 msgstr ""
dongsheng@627 17733
dongsheng@627 17734 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 17735 #: ../en/ch13-mq-collab.xml:369
dongsheng@627 17736 msgid ""
dongsheng@627 17737 "Those patches that need reworking before being resubmitted are guarded with "
dongsheng@627 17738 "<literal>rework</literal>."
dongsheng@627 17739 msgstr ""
dongsheng@627 17740
dongsheng@627 17741 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 17742 #: ../en/ch13-mq-collab.xml:373
dongsheng@627 17743 msgid ""
dongsheng@627 17744 "For those patches that are still under development, I use <literal>devel</"
dongsheng@627 17745 "literal>."
dongsheng@627 17746 msgstr ""
dongsheng@627 17747
dongsheng@627 17748 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 17749 #: ../en/ch13-mq-collab.xml:376
dongsheng@627 17750 msgid ""
dongsheng@627 17751 "A backport patch may have several guards, one for each version of the kernel "
dongsheng@627 17752 "to which it applies. For example, a patch that backports a piece of code to "
dongsheng@627 17753 "2.6.9 will have a <literal>2.6.9</literal> guard."
dongsheng@627 17754 msgstr ""
dongsheng@627 17755
dongsheng@627 17756 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 17757 #: ../en/ch13-mq-collab.xml:381
dongsheng@627 17758 msgid ""
dongsheng@627 17759 "This variety of guards gives me considerable flexibility in determining what "
dongsheng@627 17760 "kind of source tree I want to end up with. For most situations, the "
dongsheng@627 17761 "selection of appropriate guards is automated during the build process, but I "
dongsheng@627 17762 "can manually tune the guards to use for less common circumstances."
dongsheng@627 17763 msgstr ""
dongsheng@627 17764
dongsheng@627 17765 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 17766 #: ../en/ch13-mq-collab.xml:388
dongsheng@627 17767 msgid "The art of writing backport patches"
dongsheng@636 17768 msgstr "编写向后移植补丁的艺术"
dongsheng@627 17769
dongsheng@627 17770 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 17771 #: ../en/ch13-mq-collab.xml:390
dongsheng@627 17772 msgid ""
dongsheng@627 17773 "Using MQ, writing a backport patch is a simple process. All such a patch has "
dongsheng@627 17774 "to do is modify a piece of code that uses a kernel feature not present in the "
dongsheng@627 17775 "older version of the kernel, so that the driver continues to work correctly "
dongsheng@627 17776 "under that older version."
dongsheng@627 17777 msgstr ""
dongsheng@627 17778
dongsheng@627 17779 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 17780 #: ../en/ch13-mq-collab.xml:396
dongsheng@627 17781 msgid ""
dongsheng@627 17782 "A useful goal when writing a good backport patch is to make your code look as "
dongsheng@627 17783 "if it was written for the older version of the kernel you're targeting. The "
dongsheng@627 17784 "less obtrusive the patch, the easier it will be to understand and maintain. "
dongsheng@627 17785 "If you're writing a collection of backport patches to avoid the <quote>rat's "
dongsheng@627 17786 "nest</quote> effect of lots of <literal>#ifdef</literal>s (hunks of source "
dongsheng@627 17787 "code that are only used conditionally) in your code, don't introduce version-"
dongsheng@627 17788 "dependent <literal>#ifdef</literal>s into the patches. Instead, write "
dongsheng@627 17789 "several patches, each of which makes unconditional changes, and control their "
dongsheng@627 17790 "application using guards."
dongsheng@627 17791 msgstr ""
dongsheng@627 17792
dongsheng@627 17793 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 17794 #: ../en/ch13-mq-collab.xml:409
dongsheng@627 17795 msgid ""
dongsheng@627 17796 "There are two reasons to divide backport patches into a distinct group, away "
dongsheng@627 17797 "from the <quote>regular</quote> patches whose effects they modify. The first "
dongsheng@627 17798 "is that intermingling the two makes it more difficult to use a tool like the "
dongsheng@627 17799 "<literal role=\"hg-ext\">patchbomb</literal> extension to automate the "
dongsheng@627 17800 "process of submitting the patches to an upstream maintainer. The second is "
dongsheng@627 17801 "that a backport patch could perturb the context in which a subsequent regular "
dongsheng@627 17802 "patch is applied, making it impossible to apply the regular patch cleanly "
dongsheng@627 17803 "<emphasis>without</emphasis> the earlier backport patch already being applied."
dongsheng@627 17804 msgstr ""
dongsheng@627 17805
dongsheng@627 17806 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 17807 #: ../en/ch13-mq-collab.xml:424
dongsheng@627 17808 msgid "Useful tips for developing with MQ"
dongsheng@636 17809 msgstr "使用 MQ 开发的技巧"
dongsheng@627 17810
dongsheng@627 17811 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 17812 #: ../en/ch13-mq-collab.xml:427
dongsheng@627 17813 msgid "Organising patches in directories"
dongsheng@636 17814 msgstr "将补丁放到几个目录中"
dongsheng@627 17815
dongsheng@627 17816 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 17817 #: ../en/ch13-mq-collab.xml:429
dongsheng@627 17818 msgid ""
dongsheng@627 17819 "If you're working on a substantial project with MQ, it's not difficult to "
dongsheng@627 17820 "accumulate a large number of patches. For example, I have one patch "
dongsheng@627 17821 "repository that contains over 250 patches."
dongsheng@627 17822 msgstr ""
dongsheng@627 17823
dongsheng@627 17824 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 17825 #: ../en/ch13-mq-collab.xml:434
dongsheng@627 17826 msgid ""
dongsheng@627 17827 "If you can group these patches into separate logical categories, you can if "
dongsheng@627 17828 "you like store them in different directories; MQ has no problems with patch "
dongsheng@627 17829 "names that contain path separators."
dongsheng@627 17830 msgstr ""
dongsheng@627 17831
dongsheng@627 17832 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 17833 #: ../en/ch13-mq-collab.xml:441
dongsheng@627 17834 msgid "Viewing the history of a patch"
dongsheng@636 17835 msgstr "察看补丁的历史"
dongsheng@627 17836
dongsheng@627 17837 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 17838 #: ../en/ch13-mq-collab.xml:443
dongsheng@627 17839 msgid ""
dongsheng@627 17840 "If you're developing a set of patches over a long time, it's a good idea to "
songdongsheng@658 17841 "maintain them in a repository, as discussed in <xref linkend=\"sec:mq:repo\"/"
songdongsheng@658 17842 ">. If you do so, you'll quickly discover that using the <command role=\"hg-"
songdongsheng@658 17843 "cmd\">hg diff</command> command to look at the history of changes to a patch "
songdongsheng@658 17844 "is unworkable. This is in part because you're looking at the second "
dongsheng@627 17845 "derivative of the real code (a diff of a diff), but also because MQ adds "
dongsheng@627 17846 "noise to the process by modifying time stamps and directory names when it "
dongsheng@627 17847 "updates a patch."
dongsheng@627 17848 msgstr ""
dongsheng@627 17849
dongsheng@627 17850 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 17851 #: ../en/ch13-mq-collab.xml:455
dongsheng@627 17852 msgid ""
dongsheng@627 17853 "However, you can use the <literal role=\"hg-ext\">extdiff</literal> "
dongsheng@627 17854 "extension, which is bundled with Mercurial, to turn a diff of two versions of "
dongsheng@627 17855 "a patch into something readable. To do this, you will need a third-party "
dongsheng@627 17856 "package called <literal role=\"package\">patchutils</literal> <citation>web:"
dongsheng@627 17857 "patchutils</citation>. This provides a command named <command>interdiff</"
dongsheng@627 17858 "command>, which shows the differences between two diffs as a diff. Used on "
dongsheng@627 17859 "two versions of the same diff, it generates a diff that represents the diff "
dongsheng@627 17860 "from the first to the second version."
dongsheng@627 17861 msgstr ""
dongsheng@627 17862
dongsheng@627 17863 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 17864 #: ../en/ch13-mq-collab.xml:466
dongsheng@627 17865 msgid ""
dongsheng@627 17866 "You can enable the <literal role=\"hg-ext\">extdiff</literal> extension in "
dongsheng@627 17867 "the usual way, by adding a line to the <literal role=\"rc-extensions"
dongsheng@650 17868 "\">extensions</literal> section of your <filename role=\"special\">~/.hgrc</"
dongsheng@627 17869 "filename>."
dongsheng@627 17870 msgstr ""
dongsheng@627 17871
dongsheng@627 17872 #
dongsheng@1034 17873 #. &example.hg-interdiff;
dongsheng@714 17874 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 17875 #: ../en/ch13-mq-collab.xml:473
dongsheng@627 17876 msgid ""
dongsheng@627 17877 "The <command>interdiff</command> command expects to be passed the names of "
dongsheng@627 17878 "two files, but the <literal role=\"hg-ext\">extdiff</literal> extension "
dongsheng@627 17879 "passes the program it runs a pair of directories, each of which can contain "
dongsheng@627 17880 "an arbitrary number of files. We thus need a small program that will run "
dongsheng@627 17881 "<command>interdiff</command> on each pair of files in these two directories. "
dongsheng@627 17882 "This program is available as <filename role=\"special\">hg-interdiff</"
dongsheng@627 17883 "filename> in the <filename class=\"directory\">examples</filename> directory "
dongsheng@627 17884 "of the source code repository that accompanies this book."
dongsheng@627 17885 msgstr ""
dongsheng@627 17886
dongsheng@627 17887 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 17888 #: ../en/ch13-mq-collab.xml:485
dongsheng@627 17889 msgid ""
dongsheng@627 17890 "With the <filename role=\"special\">hg-interdiff</filename> program in your "
dongsheng@627 17891 "shell's search path, you can run it as follows, from inside an MQ patch "
dongsheng@627 17892 "directory:"
dongsheng@627 17893 msgstr ""
dongsheng@627 17894
dongsheng@627 17895 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 17896 #: ../en/ch13-mq-collab.xml:489
dongsheng@627 17897 msgid ""
dongsheng@627 17898 "Since you'll probably want to use this long-winded command a lot, you can get "
dongsheng@627 17899 "<literal role=\"hg-ext\">hgext</literal> to make it available as a normal "
dongsheng@650 17900 "Mercurial command, again by editing your <filename role=\"special\">~/.hgrc</"
dongsheng@627 17901 "filename>."
dongsheng@627 17902 msgstr ""
dongsheng@627 17903
dongsheng@627 17904 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 17905 #: ../en/ch13-mq-collab.xml:496
dongsheng@627 17906 msgid ""
dongsheng@627 17907 "This directs <literal role=\"hg-ext\">hgext</literal> to make an "
dongsheng@627 17908 "<literal>interdiff</literal> command available, so you can now shorten the "
dongsheng@627 17909 "previous invocation of <command role=\"hg-ext-extdiff\">extdiff</command> to "
dongsheng@627 17910 "something a little more wieldy."
dongsheng@627 17911 msgstr ""
dongsheng@627 17912
dongsheng@627 17913 #. type: Content of: <book><chapter><sect1><sect2><note><para>
dongsheng@714 17914 #: ../en/ch13-mq-collab.xml:504
dongsheng@627 17915 msgid ""
dongsheng@627 17916 "The <command>interdiff</command> command works well only if the underlying "
dongsheng@627 17917 "files against which versions of a patch are generated remain the same. If "
dongsheng@627 17918 "you create a patch, modify the underlying files, and then regenerate the "
dongsheng@627 17919 "patch, <command>interdiff</command> may not produce useful output."
dongsheng@627 17920 msgstr ""
dongsheng@627 17921
dongsheng@627 17922 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 17923 #: ../en/ch13-mq-collab.xml:512
dongsheng@627 17924 msgid ""
dongsheng@627 17925 "The <literal role=\"hg-ext\">extdiff</literal> extension is useful for more "
dongsheng@627 17926 "than merely improving the presentation of MQ patches. To read more about it, "
songdongsheng@658 17927 "go to <xref linkend=\"sec:hgext:extdiff\"/>."
dongsheng@627 17928 msgstr ""
dongsheng@627 17929
dongsheng@627 17930 #. type: Content of: <book><chapter><title>
dongsheng@714 17931 #: ../en/ch14-hgext.xml:5
dongsheng@627 17932 msgid "Adding functionality with extensions"
dongsheng@627 17933 msgstr "使用扩展增加功能"
dongsheng@627 17934
dongsheng@627 17935 #. type: Content of: <book><chapter><para>
dongsheng@714 17936 #: ../en/ch14-hgext.xml:7
dongsheng@627 17937 msgid ""
dongsheng@627 17938 "While the core of Mercurial is quite complete from a functionality "
dongsheng@627 17939 "standpoint, it's deliberately shorn of fancy features. This approach of "
dongsheng@627 17940 "preserving simplicity keeps the software easy to deal with for both "
dongsheng@627 17941 "maintainers and users."
dongsheng@627 17942 msgstr ""
dongsheng@627 17943
dongsheng@627 17944 #. type: Content of: <book><chapter><para>
dongsheng@714 17945 #: ../en/ch14-hgext.xml:12
dongsheng@627 17946 msgid ""
dongsheng@627 17947 "However, Mercurial doesn't box you in with an inflexible command set: you can "
dongsheng@627 17948 "add features to it as <emphasis>extensions</emphasis> (sometimes known as "
dongsheng@627 17949 "<emphasis>plugins</emphasis>). We've already discussed a few of these "
dongsheng@627 17950 "extensions in earlier chapters."
dongsheng@627 17951 msgstr ""
dongsheng@627 17952
dongsheng@627 17953 #. type: Content of: <book><chapter><itemizedlist><listitem><para>
dongsheng@714 17954 #: ../en/ch14-hgext.xml:18
dongsheng@627 17955 msgid ""
songdongsheng@658 17956 "<xref linkend=\"sec:tour-merge:fetch\"/> covers the <literal role=\"hg-ext"
songdongsheng@658 17957 "\">fetch</literal> extension; this combines pulling new changes and merging "
songdongsheng@658 17958 "them with local changes into a single command, <command role=\"hg-ext-fetch"
songdongsheng@658 17959 "\">fetch</command>."
dongsheng@627 17960 msgstr ""
dongsheng@627 17961
dongsheng@627 17962 #. type: Content of: <book><chapter><itemizedlist><listitem><para>
dongsheng@714 17963 #: ../en/ch14-hgext.xml:24
dongsheng@627 17964 msgid ""
songdongsheng@658 17965 "In <xref linkend=\"chap:hook\"/>, we covered several extensions that are "
songdongsheng@658 17966 "useful for hook-related functionality: <literal role=\"hg-ext\">acl</literal> "
songdongsheng@658 17967 "adds access control lists; <literal role=\"hg-ext\">bugzilla</literal> adds "
songdongsheng@658 17968 "integration with the Bugzilla bug tracking system; and <literal role=\"hg-ext"
songdongsheng@658 17969 "\">notify</literal> sends notification emails on new changes."
dongsheng@627 17970 msgstr ""
dongsheng@627 17971
dongsheng@627 17972 #. type: Content of: <book><chapter><itemizedlist><listitem><para>
dongsheng@714 17973 #: ../en/ch14-hgext.xml:33
dongsheng@627 17974 msgid ""
dongsheng@627 17975 "The Mercurial Queues patch management extension is so invaluable that it "
songdongsheng@658 17976 "merits two chapters and an appendix all to itself. <xref linkend=\"chap:mq\"/"
songdongsheng@658 17977 "> covers the basics; <xref linkend=\"chap:mq-collab\"/> discusses advanced "
songdongsheng@658 17978 "topics; and <xref linkend=\"chap:mqref\"/> goes into detail on each command."
dongsheng@627 17979 msgstr ""
dongsheng@627 17980
dongsheng@627 17981 #. type: Content of: <book><chapter><para>
dongsheng@714 17982 #: ../en/ch14-hgext.xml:43
dongsheng@627 17983 msgid ""
dongsheng@627 17984 "In this chapter, we'll cover some of the other extensions that are available "
dongsheng@627 17985 "for Mercurial, and briefly touch on some of the machinery you'll need to know "
dongsheng@627 17986 "about if you want to write an extension of your own."
dongsheng@627 17987 msgstr ""
dongsheng@627 17988
dongsheng@627 17989 #. type: Content of: <book><chapter><itemizedlist><listitem><para>
dongsheng@714 17990 #: ../en/ch14-hgext.xml:48
dongsheng@627 17991 msgid ""
songdongsheng@658 17992 "In <xref linkend=\"sec:hgext:inotify\"/>, we'll discuss the possibility of "
songdongsheng@658 17993 "<emphasis>huge</emphasis> performance improvements using the <literal role="
songdongsheng@658 17994 "\"hg-ext\">inotify</literal> extension."
dongsheng@627 17995 msgstr ""
dongsheng@627 17996
dongsheng@627 17997 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 17998 #: ../en/ch14-hgext.xml:55
dongsheng@627 17999 msgid ""
dongsheng@627 18000 "Improve performance with the <literal role=\"hg-ext\">inotify</literal> "
dongsheng@627 18001 "extension"
dongsheng@636 18002 msgstr "使用扩展 <literal role=\"hg-ext\">inotify</literal> 以提高性能"
dongsheng@627 18003
dongsheng@627 18004 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 18005 #: ../en/ch14-hgext.xml:58
dongsheng@627 18006 msgid ""
dongsheng@627 18007 "Are you interested in having some of the most common Mercurial operations run "
dongsheng@627 18008 "as much as a hundred times faster? Read on!"
dongsheng@627 18009 msgstr ""
dongsheng@627 18010
dongsheng@627 18011 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 18012 #: ../en/ch14-hgext.xml:62
dongsheng@627 18013 msgid ""
dongsheng@627 18014 "Mercurial has great performance under normal circumstances. For example, "
dongsheng@627 18015 "when you run the <command role=\"hg-cmd\">hg status</command> command, "
dongsheng@627 18016 "Mercurial has to scan almost every directory and file in your repository so "
dongsheng@627 18017 "that it can display file status. Many other Mercurial commands need to do "
dongsheng@627 18018 "the same work behind the scenes; for example, the <command role=\"hg-cmd\">hg "
dongsheng@627 18019 "diff</command> command uses the status machinery to avoid doing an expensive "
dongsheng@627 18020 "comparison operation on files that obviously haven't changed."
dongsheng@627 18021 msgstr ""
dongsheng@627 18022
dongsheng@627 18023 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 18024 #: ../en/ch14-hgext.xml:72
dongsheng@627 18025 msgid ""
dongsheng@627 18026 "Because obtaining file status is crucial to good performance, the authors of "
dongsheng@627 18027 "Mercurial have optimised this code to within an inch of its life. However, "
dongsheng@627 18028 "there's no avoiding the fact that when you run <command role=\"hg-cmd\">hg "
dongsheng@627 18029 "status</command>, Mercurial is going to have to perform at least one "
dongsheng@627 18030 "expensive system call for each managed file to determine whether it's changed "
dongsheng@627 18031 "since the last time Mercurial checked. For a sufficiently large repository, "
dongsheng@627 18032 "this can take a long time."
dongsheng@627 18033 msgstr ""
dongsheng@627 18034
dongsheng@627 18035 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 18036 #: ../en/ch14-hgext.xml:82
dongsheng@627 18037 msgid ""
dongsheng@627 18038 "To put a number on the magnitude of this effect, I created a repository "
dongsheng@627 18039 "containing 150,000 managed files. I timed <command role=\"hg-cmd\">hg "
dongsheng@627 18040 "status</command> as taking ten seconds to run, even when <emphasis>none</"
dongsheng@627 18041 "emphasis> of those files had been modified."
dongsheng@627 18042 msgstr ""
dongsheng@627 18043
dongsheng@627 18044 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 18045 #: ../en/ch14-hgext.xml:88
dongsheng@627 18046 msgid ""
dongsheng@627 18047 "Many modern operating systems contain a file notification facility. If a "
dongsheng@627 18048 "program signs up to an appropriate service, the operating system will notify "
dongsheng@627 18049 "it every time a file of interest is created, modified, or deleted. On Linux "
dongsheng@627 18050 "systems, the kernel component that does this is called <literal>inotify</"
dongsheng@627 18051 "literal>."
dongsheng@627 18052 msgstr ""
dongsheng@627 18053
dongsheng@627 18054 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 18055 #: ../en/ch14-hgext.xml:95
dongsheng@627 18056 msgid ""
dongsheng@627 18057 "Mercurial's <literal role=\"hg-ext\">inotify</literal> extension talks to the "
dongsheng@627 18058 "kernel's <literal>inotify</literal> component to optimise <command role=\"hg-"
dongsheng@627 18059 "cmd\">hg status</command> commands. The extension has two components. A "
dongsheng@627 18060 "daemon sits in the background and receives notifications from the "
dongsheng@627 18061 "<literal>inotify</literal> subsystem. It also listens for connections from a "
songdongsheng@710 18062 "regular Mercurial command. The extension modifies Mercurial's behavior so "
dongsheng@627 18063 "that instead of scanning the filesystem, it queries the daemon. Since the "
dongsheng@627 18064 "daemon has perfect information about the state of the repository, it can "
dongsheng@627 18065 "respond with a result instantaneously, avoiding the need to scan every "
dongsheng@627 18066 "directory and file in the repository."
dongsheng@627 18067 msgstr ""
dongsheng@627 18068
dongsheng@627 18069 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 18070 #: ../en/ch14-hgext.xml:108
dongsheng@627 18071 msgid ""
dongsheng@627 18072 "Recall the ten seconds that I measured plain Mercurial as taking to run "
dongsheng@627 18073 "<command role=\"hg-cmd\">hg status</command> on a 150,000 file repository. "
dongsheng@627 18074 "With the <literal role=\"hg-ext\">inotify</literal> extension enabled, the "
dongsheng@627 18075 "time dropped to 0.1 seconds, a factor of <emphasis>one hundred</emphasis> "
dongsheng@627 18076 "faster."
dongsheng@627 18077 msgstr ""
dongsheng@627 18078
dongsheng@627 18079 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 18080 #: ../en/ch14-hgext.xml:115
dongsheng@627 18081 msgid "Before we continue, please pay attention to some caveats."
dongsheng@627 18082 msgstr ""
dongsheng@627 18083
dongsheng@627 18084 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 18085 #: ../en/ch14-hgext.xml:118
dongsheng@627 18086 msgid ""
dongsheng@627 18087 "The <literal role=\"hg-ext\">inotify</literal> extension is Linux-specific. "
dongsheng@627 18088 "Because it interfaces directly to the Linux kernel's <literal>inotify</"
dongsheng@627 18089 "literal> subsystem, it does not work on other operating systems."
dongsheng@627 18090 msgstr ""
dongsheng@627 18091
dongsheng@627 18092 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 18093 #: ../en/ch14-hgext.xml:123
dongsheng@627 18094 msgid ""
dongsheng@627 18095 "It should work on any Linux distribution that was released after early 2005. "
dongsheng@627 18096 "Older distributions are likely to have a kernel that lacks <literal>inotify</"
dongsheng@627 18097 "literal>, or a version of <literal>glibc</literal> that does not have the "
dongsheng@627 18098 "necessary interfacing support."
dongsheng@627 18099 msgstr ""
dongsheng@627 18100
dongsheng@627 18101 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@714 18102 #: ../en/ch14-hgext.xml:130
dongsheng@627 18103 msgid ""
dongsheng@627 18104 "Not all filesystems are suitable for use with the <literal role=\"hg-ext"
dongsheng@627 18105 "\">inotify</literal> extension. Network filesystems such as NFS are a non-"
dongsheng@627 18106 "starter, for example, particularly if you're running Mercurial on several "
dongsheng@627 18107 "systems, all mounting the same network filesystem. The kernel's "
dongsheng@627 18108 "<literal>inotify</literal> system has no way of knowing about changes made on "
dongsheng@627 18109 "another system. Most local filesystems (e.g. ext3, XFS, ReiserFS) should "
dongsheng@627 18110 "work fine."
dongsheng@627 18111 msgstr ""
dongsheng@627 18112
dongsheng@627 18113 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 18114 #: ../en/ch14-hgext.xml:141
dongsheng@627 18115 msgid ""
dongsheng@627 18116 "The <literal role=\"hg-ext\">inotify</literal> extension is not yet shipped "
dongsheng@627 18117 "with Mercurial as of May 2007, so it's a little more involved to set up than "
dongsheng@627 18118 "other extensions. But the performance improvement is worth it!"
dongsheng@627 18119 msgstr ""
dongsheng@627 18120
dongsheng@627 18121 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 18122 #: ../en/ch14-hgext.xml:146
dongsheng@627 18123 msgid ""
dongsheng@627 18124 "The extension currently comes in two parts: a set of patches to the Mercurial "
dongsheng@627 18125 "source code, and a library of Python bindings to the <literal>inotify</"
dongsheng@627 18126 "literal> subsystem."
dongsheng@627 18127 msgstr ""
dongsheng@627 18128
dongsheng@627 18129 #. type: Content of: <book><chapter><sect1><note><para>
dongsheng@714 18130 #: ../en/ch14-hgext.xml:150
dongsheng@627 18131 msgid ""
dongsheng@627 18132 "There are <emphasis>two</emphasis> Python <literal>inotify</literal> binding "
dongsheng@627 18133 "libraries. One of them is called <literal>pyinotify</literal>, and is "
dongsheng@627 18134 "packaged by some Linux distributions as <literal>python-inotify</literal>. "
dongsheng@627 18135 "This is <emphasis>not</emphasis> the one you'll need, as it is too buggy and "
dongsheng@627 18136 "inefficient to be practical."
dongsheng@627 18137 msgstr ""
dongsheng@627 18138
dongsheng@627 18139 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 18140 #: ../en/ch14-hgext.xml:157
dongsheng@627 18141 msgid ""
dongsheng@627 18142 "To get going, it's best to already have a functioning copy of Mercurial "
dongsheng@627 18143 "installed."
dongsheng@627 18144 msgstr ""
dongsheng@627 18145
dongsheng@627 18146 #. type: Content of: <book><chapter><sect1><note><para>
dongsheng@714 18147 #: ../en/ch14-hgext.xml:160
dongsheng@627 18148 msgid ""
dongsheng@627 18149 "If you follow the instructions below, you'll be <emphasis>replacing</"
dongsheng@627 18150 "emphasis> and overwriting any existing installation of Mercurial that you "
dongsheng@627 18151 "might already have, using the latest <quote>bleeding edge</quote> Mercurial "
dongsheng@627 18152 "code. Don't say you weren't warned!"
dongsheng@627 18153 msgstr ""
dongsheng@627 18154
dongsheng@627 18155 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
dongsheng@714 18156 #: ../en/ch14-hgext.xml:167
dongsheng@627 18157 msgid ""
dongsheng@627 18158 "Clone the Python <literal>inotify</literal> binding repository. Build and "
dongsheng@627 18159 "install it."
dongsheng@627 18160 msgstr ""
dongsheng@627 18161
dongsheng@627 18162 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
dongsheng@714 18163 #: ../en/ch14-hgext.xml:174
dongsheng@627 18164 msgid ""
dongsheng@627 18165 "Clone the <filename class=\"directory\">crew</filename> Mercurial "
dongsheng@627 18166 "repository. Clone the <literal role=\"hg-ext\">inotify</literal> patch "
dongsheng@627 18167 "repository so that Mercurial Queues will be able to apply patches to your "
dongsheng@627 18168 "cope of the <filename class=\"directory\">crew</filename> repository."
dongsheng@627 18169 msgstr ""
dongsheng@627 18170
dongsheng@627 18171 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
dongsheng@714 18172 #: ../en/ch14-hgext.xml:184
dongsheng@627 18173 msgid ""
dongsheng@627 18174 "Make sure that you have the Mercurial Queues extension, <literal role=\"hg-ext"
songdongsheng@658 18175 "\">mq</literal>, enabled. If you've never used MQ, read <xref linkend=\"sec:"
songdongsheng@658 18176 "mq:start\"/> to get started quickly."
dongsheng@627 18177 msgstr ""
dongsheng@627 18178
dongsheng@627 18179 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
dongsheng@714 18180 #: ../en/ch14-hgext.xml:190
dongsheng@627 18181 msgid ""
dongsheng@627 18182 "Go into the <filename class=\"directory\">inotify</filename> repo, and apply "
dongsheng@627 18183 "all of the <literal role=\"hg-ext\">inotify</literal> patches using the "
dongsheng@627 18184 "<option role=\"hg-ext-mq-cmd-qpush-opt\">hg -a</option> option to the "
dongsheng@627 18185 "<command role=\"hg-ext-mq\">qpush</command> command."
dongsheng@627 18186 msgstr ""
dongsheng@627 18187
dongsheng@627 18188 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
dongsheng@714 18189 #: ../en/ch14-hgext.xml:199
dongsheng@627 18190 msgid ""
dongsheng@627 18191 "If you get an error message from <command role=\"hg-ext-mq\">qpush</command>, "
dongsheng@627 18192 "you should not continue. Instead, ask for help."
dongsheng@627 18193 msgstr ""
dongsheng@627 18194
dongsheng@627 18195 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
dongsheng@714 18196 #: ../en/ch14-hgext.xml:203
dongsheng@627 18197 msgid "Build and install the patched version of Mercurial."
dongsheng@627 18198 msgstr ""
dongsheng@627 18199
dongsheng@627 18200 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 18201 #: ../en/ch14-hgext.xml:209
dongsheng@627 18202 msgid ""
dongsheng@627 18203 "Once you've build a suitably patched version of Mercurial, all you need to do "
dongsheng@627 18204 "to enable the <literal role=\"hg-ext\">inotify</literal> extension is add an "
dongsheng@650 18205 "entry to your <filename role=\"special\">~/.hgrc</filename>."
dongsheng@650 18206 msgstr ""
dongsheng@650 18207
dongsheng@650 18208 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 18209 #: ../en/ch14-hgext.xml:214
dongsheng@627 18210 msgid ""
dongsheng@627 18211 "When the <literal role=\"hg-ext\">inotify</literal> extension is enabled, "
dongsheng@627 18212 "Mercurial will automatically and transparently start the status daemon the "
dongsheng@627 18213 "first time you run a command that needs status in a repository. It runs one "
dongsheng@627 18214 "status daemon per repository."
dongsheng@627 18215 msgstr ""
dongsheng@627 18216
dongsheng@627 18217 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 18218 #: ../en/ch14-hgext.xml:220
dongsheng@627 18219 msgid ""
dongsheng@627 18220 "The status daemon is started silently, and runs in the background. If you "
dongsheng@627 18221 "look at a list of running processes after you've enabled the <literal role="
dongsheng@627 18222 "\"hg-ext\">inotify</literal> extension and run a few commands in different "
dongsheng@627 18223 "repositories, you'll thus see a few <literal>hg</literal> processes sitting "
dongsheng@627 18224 "around, waiting for updates from the kernel and queries from Mercurial."
dongsheng@627 18225 msgstr ""
dongsheng@627 18226
dongsheng@627 18227 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 18228 #: ../en/ch14-hgext.xml:228
dongsheng@627 18229 msgid ""
dongsheng@627 18230 "The first time you run a Mercurial command in a repository when you have the "
dongsheng@627 18231 "<literal role=\"hg-ext\">inotify</literal> extension enabled, it will run "
dongsheng@627 18232 "with about the same performance as a normal Mercurial command. This is "
dongsheng@627 18233 "because the status daemon needs to perform a normal status scan so that it "
dongsheng@627 18234 "has a baseline against which to apply later updates from the kernel. "
dongsheng@627 18235 "However, <emphasis>every</emphasis> subsequent command that does any kind of "
dongsheng@627 18236 "status check should be noticeably faster on repositories of even fairly "
dongsheng@627 18237 "modest size. Better yet, the bigger your repository is, the greater a "
dongsheng@627 18238 "performance advantage you'll see. The <literal role=\"hg-ext\">inotify</"
dongsheng@627 18239 "literal> daemon makes status operations almost instantaneous on repositories "
dongsheng@627 18240 "of all sizes!"
dongsheng@627 18241 msgstr ""
dongsheng@627 18242
dongsheng@627 18243 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 18244 #: ../en/ch14-hgext.xml:242
dongsheng@627 18245 msgid ""
dongsheng@627 18246 "If you like, you can manually start a status daemon using the <command role="
dongsheng@627 18247 "\"hg-ext-inotify\">inserve</command> command. This gives you slightly finer "
dongsheng@627 18248 "control over how the daemon ought to run. This command will of course only "
dongsheng@627 18249 "be available when the <literal role=\"hg-ext\">inotify</literal> extension is "
dongsheng@627 18250 "enabled."
dongsheng@627 18251 msgstr ""
dongsheng@627 18252
dongsheng@627 18253 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 18254 #: ../en/ch14-hgext.xml:249
dongsheng@627 18255 msgid ""
dongsheng@627 18256 "When you're using the <literal role=\"hg-ext\">inotify</literal> extension, "
dongsheng@627 18257 "you should notice <emphasis>no difference at all</emphasis> in Mercurial's "
songdongsheng@710 18258 "behavior, with the sole exception of status-related commands running a whole "
dongsheng@627 18259 "lot faster than they used to. You should specifically expect that commands "
dongsheng@627 18260 "will not print different output; neither should they give different results. "
dongsheng@627 18261 "If either of these situations occurs, please report a bug."
dongsheng@627 18262 msgstr ""
dongsheng@627 18263
dongsheng@627 18264 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 18265 #: ../en/ch14-hgext.xml:260
dongsheng@627 18266 msgid ""
dongsheng@627 18267 "Flexible diff support with the <literal role=\"hg-ext\">extdiff</literal> "
dongsheng@627 18268 "extension"
dongsheng@636 18269 msgstr "使用扩展 <literal role=\"hg-ext\">extdiff</literal> 以扩展差异支持"
dongsheng@627 18270
dongsheng@627 18271 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 18272 #: ../en/ch14-hgext.xml:263
dongsheng@627 18273 msgid ""
dongsheng@627 18274 "Mercurial's built-in <command role=\"hg-cmd\">hg diff</command> command "
dongsheng@627 18275 "outputs plaintext unified diffs."
dongsheng@627 18276 msgstr ""
dongsheng@627 18277 "Mercurial 内置命令 <command role=\"hg-cmd\">hg diff</command> 的输出与统一差异"
dongsheng@627 18278 "不同。"
dongsheng@627 18279
dongsheng@627 18280 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 18281 #: ../en/ch14-hgext.xml:268
dongsheng@627 18282 msgid ""
dongsheng@627 18283 "If you would like to use an external tool to display modifications, you'll "
dongsheng@627 18284 "want to use the <literal role=\"hg-ext\">extdiff</literal> extension. This "
dongsheng@627 18285 "will let you use, for example, a graphical diff tool."
dongsheng@627 18286 msgstr ""
dongsheng@627 18287
dongsheng@627 18288 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 18289 #: ../en/ch14-hgext.xml:273
dongsheng@627 18290 msgid ""
dongsheng@627 18291 "The <literal role=\"hg-ext\">extdiff</literal> extension is bundled with "
dongsheng@627 18292 "Mercurial, so it's easy to set up. In the <literal role=\"rc-extensions"
dongsheng@650 18293 "\">extensions</literal> section of your <filename role=\"special\">~/.hgrc</"
dongsheng@627 18294 "filename>, simply add a one-line entry to enable the extension."
dongsheng@627 18295 msgstr ""
dongsheng@627 18296
dongsheng@627 18297 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 18298 #: ../en/ch14-hgext.xml:280
dongsheng@627 18299 msgid ""
dongsheng@627 18300 "This introduces a command named <command role=\"hg-ext-extdiff\">extdiff</"
dongsheng@627 18301 "command>, which by default uses your system's <command>diff</command> command "
dongsheng@627 18302 "to generate a unified diff in the same form as the built-in <command role="
dongsheng@627 18303 "\"hg-cmd\">hg diff</command> command."
dongsheng@627 18304 msgstr ""
dongsheng@627 18305
dongsheng@627 18306 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 18307 #: ../en/ch14-hgext.xml:288
dongsheng@627 18308 msgid ""
dongsheng@627 18309 "The result won't be exactly the same as with the built-in <command role=\"hg-"
dongsheng@627 18310 "cmd\">hg diff</command> variations, because the output of <command>diff</"
dongsheng@627 18311 "command> varies from one system to another, even when passed the same options."
dongsheng@627 18312 msgstr ""
dongsheng@627 18313
dongsheng@627 18314 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 18315 #: ../en/ch14-hgext.xml:293
dongsheng@627 18316 msgid ""
dongsheng@627 18317 "As the <quote><literal>making snapshot</literal></quote> lines of output "
dongsheng@627 18318 "above imply, the <command role=\"hg-ext-extdiff\">extdiff</command> command "
dongsheng@627 18319 "works by creating two snapshots of your source tree. The first snapshot is "
dongsheng@627 18320 "of the source revision; the second, of the target revision or working "
dongsheng@627 18321 "directory. The <command role=\"hg-ext-extdiff\">extdiff</command> command "
dongsheng@627 18322 "generates these snapshots in a temporary directory, passes the name of each "
dongsheng@627 18323 "directory to an external diff viewer, then deletes the temporary directory. "
dongsheng@627 18324 "For efficiency, it only snapshots the directories and files that have changed "
dongsheng@627 18325 "between the two revisions."
dongsheng@627 18326 msgstr ""
dongsheng@627 18327
dongsheng@627 18328 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 18329 #: ../en/ch14-hgext.xml:306
dongsheng@627 18330 msgid ""
dongsheng@627 18331 "Snapshot directory names have the same base name as your repository. If your "
dongsheng@627 18332 "repository path is <filename class=\"directory\">/quux/bar/foo</filename>, "
dongsheng@627 18333 "then <filename class=\"directory\">foo</filename> will be the name of each "
dongsheng@627 18334 "snapshot directory. Each snapshot directory name has its changeset ID "
dongsheng@627 18335 "appended, if appropriate. If a snapshot is of revision "
dongsheng@627 18336 "<literal>a631aca1083f</literal>, the directory will be named <filename class="
dongsheng@627 18337 "\"directory\">foo.a631aca1083f</filename>. A snapshot of the working "
dongsheng@627 18338 "directory won't have a changeset ID appended, so it would just be <filename "
dongsheng@627 18339 "class=\"directory\">foo</filename> in this example. To see what this looks "
dongsheng@627 18340 "like in practice, look again at the <command role=\"hg-ext-extdiff\">extdiff</"
dongsheng@627 18341 "command> example above. Notice that the diff has the snapshot directory "
dongsheng@627 18342 "names embedded in its header."
dongsheng@627 18343 msgstr ""
dongsheng@627 18344
dongsheng@627 18345 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 18346 #: ../en/ch14-hgext.xml:322
dongsheng@627 18347 msgid ""
dongsheng@627 18348 "The <command role=\"hg-ext-extdiff\">extdiff</command> command accepts two "
dongsheng@627 18349 "important options. The <option role=\"hg-ext-extdiff-cmd-extdiff-opt\">hg -p</"
dongsheng@627 18350 "option> option lets you choose a program to view differences with, instead of "
dongsheng@627 18351 "<command>diff</command>. With the <option role=\"hg-ext-extdiff-cmd-extdiff-"
dongsheng@627 18352 "opt\">hg -o</option> option, you can change the options that <command role="
dongsheng@627 18353 "\"hg-ext-extdiff\">extdiff</command> passes to the program (by default, these "
dongsheng@627 18354 "options are <quote><literal>-Npru</literal></quote>, which only make sense if "
dongsheng@627 18355 "you're running <command>diff</command>). In other respects, the <command "
dongsheng@627 18356 "role=\"hg-ext-extdiff\">extdiff</command> command acts similarly to the built-"
dongsheng@627 18357 "in <command role=\"hg-cmd\">hg diff</command> command: you use the same "
dongsheng@627 18358 "option names, syntax, and arguments to specify the revisions you want, the "
dongsheng@627 18359 "files you want, and so on."
dongsheng@627 18360 msgstr ""
dongsheng@627 18361
dongsheng@627 18362 #
dongsheng@627 18363 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 18364 #: ../en/ch14-hgext.xml:339
dongsheng@627 18365 msgid ""
dongsheng@627 18366 "As an example, here's how to run the normal system <command>diff</command> "
dongsheng@627 18367 "command, getting it to generate context diffs (using the <option role=\"cmd-"
dongsheng@627 18368 "opt-diff\">-c</option> option) instead of unified diffs, and five lines of "
dongsheng@627 18369 "context instead of the default three (passing <literal>5</literal> as the "
dongsheng@627 18370 "argument to the <option role=\"cmd-opt-diff\">-C</option> option)."
dongsheng@627 18371 msgstr ""
dongsheng@627 18372
dongsheng@627 18373 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 18374 #: ../en/ch14-hgext.xml:348
dongsheng@627 18375 msgid ""
dongsheng@627 18376 "Launching a visual diff tool is just as easy. Here's how to launch the "
dongsheng@627 18377 "<command>kdiff3</command> viewer."
dongsheng@627 18378 msgstr ""
dongsheng@627 18379
dongsheng@627 18380 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 18381 #: ../en/ch14-hgext.xml:352
dongsheng@627 18382 msgid ""
dongsheng@627 18383 "If your diff viewing command can't deal with directories, you can easily work "
dongsheng@627 18384 "around this with a little scripting. For an example of such scripting in "
dongsheng@627 18385 "action with the <literal role=\"hg-ext\">mq</literal> extension and the "
songdongsheng@658 18386 "<command>interdiff</command> command, see <xref linkend=\"mq-collab:tips:"
songdongsheng@658 18387 "interdiff\"/>."
dongsheng@627 18388 msgstr ""
dongsheng@627 18389
dongsheng@627 18390 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 18391 #: ../en/ch14-hgext.xml:360
dongsheng@627 18392 msgid "Defining command aliases"
dongsheng@636 18393 msgstr "定义命令的别名"
dongsheng@627 18394
dongsheng@627 18395 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 18396 #: ../en/ch14-hgext.xml:362
dongsheng@627 18397 msgid ""
dongsheng@627 18398 "It can be cumbersome to remember the options to both the <command role=\"hg-"
dongsheng@627 18399 "ext-extdiff\">extdiff</command> command and the diff viewer you want to use, "
dongsheng@627 18400 "so the <literal role=\"hg-ext\">extdiff</literal> extension lets you define "
dongsheng@627 18401 "<emphasis>new</emphasis> commands that will invoke your diff viewer with "
dongsheng@627 18402 "exactly the right options."
dongsheng@627 18403 msgstr ""
dongsheng@627 18404
dongsheng@627 18405 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 18406 #: ../en/ch14-hgext.xml:369
dongsheng@650 18407 msgid ""
dongsheng@650 18408 "All you need to do is edit your <filename role=\"special\">~/.hgrc</"
dongsheng@627 18409 "filename>, and add a section named <literal role=\"rc-extdiff\">extdiff</"
dongsheng@627 18410 "literal>. Inside this section, you can define multiple commands. Here's how "
dongsheng@627 18411 "to add a <literal>kdiff3</literal> command. Once you've defined this, you "
dongsheng@627 18412 "can type <quote><literal>hg kdiff3</literal></quote> and the <literal role="
dongsheng@627 18413 "\"hg-ext\">extdiff</literal> extension will run <command>kdiff3</command> for "
dongsheng@627 18414 "you."
dongsheng@627 18415 msgstr ""
dongsheng@627 18416
dongsheng@627 18417 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 18418 #: ../en/ch14-hgext.xml:379
dongsheng@627 18419 msgid ""
dongsheng@627 18420 "If you leave the right hand side of the definition empty, as above, the "
dongsheng@627 18421 "<literal role=\"hg-ext\">extdiff</literal> extension uses the name of the "
dongsheng@627 18422 "command you defined as the name of the external program to run. But these "
dongsheng@627 18423 "names don't have to be the same. Here, we define a command named "
dongsheng@627 18424 "<quote><literal>hg wibble</literal></quote>, which runs <command>kdiff3</"
dongsheng@627 18425 "command>."
dongsheng@627 18426 msgstr ""
dongsheng@627 18427
dongsheng@627 18428 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 18429 #: ../en/ch14-hgext.xml:389
dongsheng@627 18430 msgid ""
dongsheng@627 18431 "You can also specify the default options that you want to invoke your diff "
dongsheng@627 18432 "viewing program with. The prefix to use is <quote><literal>opts.</literal></"
dongsheng@627 18433 "quote>, followed by the name of the command to which the options apply. This "
dongsheng@627 18434 "example defines a <quote><literal>hg vimdiff</literal></quote> command that "
dongsheng@627 18435 "runs the <command>vim</command> editor's <literal>DirDiff</literal> extension."
dongsheng@627 18436 msgstr ""
dongsheng@627 18437
dongsheng@627 18438 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 18439 #: ../en/ch14-hgext.xml:403
dongsheng@627 18440 msgid ""
dongsheng@627 18441 "Cherrypicking changes with the <literal role=\"hg-ext\">transplant</literal> "
dongsheng@627 18442 "extension"
dongsheng@636 18443 msgstr "使用扩展 <literal role=\"hg-ext\">transplant</literal> 以挑选修改"
dongsheng@627 18444
dongsheng@627 18445 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 18446 #: ../en/ch14-hgext.xml:406
dongsheng@627 18447 msgid "Need to have a long chat with Brendan about this."
dongsheng@627 18448 msgstr ""
dongsheng@627 18449
dongsheng@627 18450 #. type: Content of: <book><chapter><sect1><title>
dongsheng@714 18451 #: ../en/ch14-hgext.xml:410
dongsheng@627 18452 msgid ""
dongsheng@627 18453 "Send changes via email with the <literal role=\"hg-ext\">patchbomb</literal> "
dongsheng@627 18454 "extension"
dongsheng@627 18455 msgstr ""
dongsheng@636 18456 "使用扩展 <literal role=\"hg-ext\">patchbomb</literal> 通过 email 发送修改"
dongsheng@627 18457
dongsheng@627 18458 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 18459 #: ../en/ch14-hgext.xml:413
dongsheng@627 18460 msgid ""
dongsheng@627 18461 "Many projects have a culture of <quote>change review</quote>, in which people "
dongsheng@627 18462 "send their modifications to a mailing list for others to read and comment on "
dongsheng@627 18463 "before they commit the final version to a shared repository. Some projects "
dongsheng@627 18464 "have people who act as gatekeepers; they apply changes from other people to a "
dongsheng@627 18465 "repository to which those others don't have access."
dongsheng@627 18466 msgstr ""
dongsheng@627 18467
dongsheng@627 18468 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 18469 #: ../en/ch14-hgext.xml:421
dongsheng@627 18470 msgid ""
dongsheng@627 18471 "Mercurial makes it easy to send changes over email for review or application, "
dongsheng@627 18472 "via its <literal role=\"hg-ext\">patchbomb</literal> extension. The "
dongsheng@627 18473 "extension is so named because changes are formatted as patches, and it's "
dongsheng@627 18474 "usual to send one changeset per email message. Sending a long series of "
dongsheng@627 18475 "changes by email is thus much like <quote>bombing</quote> the recipient's "
dongsheng@627 18476 "inbox, hence <quote>patchbomb</quote>."
dongsheng@627 18477 msgstr ""
dongsheng@627 18478
dongsheng@627 18479 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 18480 #: ../en/ch14-hgext.xml:429
dongsheng@627 18481 msgid ""
dongsheng@627 18482 "As usual, the basic configuration of the <literal role=\"hg-ext\">patchbomb</"
dongsheng@627 18483 "literal> extension takes just one or two lines in your <filename role="
dongsheng@627 18484 "\"special\"> /.hgrc</filename>."
dongsheng@627 18485 msgstr ""
dongsheng@627 18486
dongsheng@627 18487 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 18488 #: ../en/ch14-hgext.xml:435
dongsheng@627 18489 msgid ""
dongsheng@627 18490 "Once you've enabled the extension, you will have a new command available, "
dongsheng@627 18491 "named <command role=\"hg-ext-patchbomb\">email</command>."
dongsheng@627 18492 msgstr ""
dongsheng@627 18493
dongsheng@627 18494 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 18495 #: ../en/ch14-hgext.xml:439
dongsheng@627 18496 msgid ""
dongsheng@627 18497 "The safest and best way to invoke the <command role=\"hg-ext-patchbomb"
dongsheng@627 18498 "\">email</command> command is to <emphasis>always</emphasis> run it first "
dongsheng@627 18499 "with the <option role=\"hg-ext-patchbomb-cmd-email-opt\">hg -n</option> "
dongsheng@627 18500 "option. This will show you what the command <emphasis>would</emphasis> send, "
dongsheng@627 18501 "without actually sending anything. Once you've had a quick glance over the "
dongsheng@627 18502 "changes and verified that you are sending the right ones, you can rerun the "
dongsheng@627 18503 "same command, with the <option role=\"hg-ext-patchbomb-cmd-email-opt\">hg -n</"
dongsheng@627 18504 "option> option removed."
dongsheng@627 18505 msgstr ""
dongsheng@627 18506
dongsheng@627 18507 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 18508 #: ../en/ch14-hgext.xml:450
dongsheng@627 18509 msgid ""
dongsheng@627 18510 "The <command role=\"hg-ext-patchbomb\">email</command> command accepts the "
dongsheng@627 18511 "same kind of revision syntax as every other Mercurial command. For example, "
dongsheng@627 18512 "this command will send every revision between 7 and <literal>tip</literal>, "
dongsheng@627 18513 "inclusive."
dongsheng@627 18514 msgstr ""
dongsheng@627 18515
dongsheng@627 18516 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 18517 #: ../en/ch14-hgext.xml:455
dongsheng@627 18518 msgid ""
dongsheng@627 18519 "You can also specify a <emphasis>repository</emphasis> to compare with. If "
dongsheng@627 18520 "you provide a repository but no revisions, the <command role=\"hg-ext-"
dongsheng@627 18521 "patchbomb\">email</command> command will send all revisions in the local "
dongsheng@627 18522 "repository that are not present in the remote repository. If you "
dongsheng@627 18523 "additionally specify revisions or a branch name (the latter using the <option "
dongsheng@627 18524 "role=\"hg-ext-patchbomb-cmd-email-opt\">hg -b</option> option), this will "
dongsheng@627 18525 "constrain the revisions sent."
dongsheng@627 18526 msgstr ""
dongsheng@627 18527
dongsheng@627 18528 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 18529 #: ../en/ch14-hgext.xml:464
dongsheng@627 18530 msgid ""
dongsheng@627 18531 "It's perfectly safe to run the <command role=\"hg-ext-patchbomb\">email</"
dongsheng@627 18532 "command> command without the names of the people you want to send to: if you "
dongsheng@627 18533 "do this, it will just prompt you for those values interactively. (If you're "
dongsheng@627 18534 "using a Linux or Unix-like system, you should have enhanced "
dongsheng@627 18535 "<literal>readline</literal>-style editing capabilities when entering those "
dongsheng@627 18536 "headers, too, which is useful.)"
dongsheng@627 18537 msgstr ""
dongsheng@627 18538
dongsheng@627 18539 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 18540 #: ../en/ch14-hgext.xml:472
dongsheng@627 18541 msgid ""
dongsheng@627 18542 "When you are sending just one revision, the <command role=\"hg-ext-patchbomb"
dongsheng@627 18543 "\">email</command> command will by default use the first line of the "
dongsheng@627 18544 "changeset description as the subject of the single email message it sends."
dongsheng@627 18545 msgstr ""
dongsheng@627 18546
dongsheng@627 18547 #. type: Content of: <book><chapter><sect1><para>
dongsheng@714 18548 #: ../en/ch14-hgext.xml:477
dongsheng@627 18549 msgid ""
dongsheng@627 18550 "If you send multiple revisions, the <command role=\"hg-ext-patchbomb\">email</"
dongsheng@627 18551 "command> command will usually send one message per changeset. It will "
dongsheng@627 18552 "preface the series with an introductory message, in which you should describe "
dongsheng@627 18553 "the purpose of the series of changes you're sending."
dongsheng@627 18554 msgstr ""
dongsheng@627 18555
dongsheng@627 18556 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@714 18557 #: ../en/ch14-hgext.xml:484
songdongsheng@710 18558 msgid "Changing the behavior of patchbombs"
dongsheng@636 18559 msgstr "修改 patchbomb 的行为"
dongsheng@627 18560
dongsheng@627 18561 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@714 18562 #: ../en/ch14-hgext.xml:486
dongsheng@627 18563 msgid ""
dongsheng@627 18564 "Not every project has exactly the same conventions for sending changes in "
dongsheng@627 18565 "email; the <literal role=\"hg-ext\">patchbomb</literal> extension tries to "
dongsheng@627 18566 "accommodate a number of variations through command line options."
dongsheng@627 18567 msgstr ""
dongsheng@627 18568
dongsheng@627 18569 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 18570 #: ../en/ch14-hgext.xml:492
dongsheng@627 18571 msgid ""
dongsheng@627 18572 "You can write a subject for the introductory message on the command line "
dongsheng@627 18573 "using the <option role=\"hg-ext-patchbomb-cmd-email-opt\">hg -s</option> "
dongsheng@627 18574 "option. This takes one argument, the text of the subject to use."
dongsheng@627 18575 msgstr ""
dongsheng@627 18576
dongsheng@627 18577 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 18578 #: ../en/ch14-hgext.xml:498
dongsheng@627 18579 msgid ""
dongsheng@627 18580 "To change the email address from which the messages originate, use the "
dongsheng@627 18581 "<option role=\"hg-ext-patchbomb-cmd-email-opt\">hg -f</option> option. This "
dongsheng@627 18582 "takes one argument, the email address to use."
dongsheng@627 18583 msgstr ""
dongsheng@627 18584
dongsheng@627 18585 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 18586 #: ../en/ch14-hgext.xml:504
dongsheng@627 18587 msgid ""
songdongsheng@710 18588 "The default behavior is to send unified diffs (see <xref linkend=\"sec:mq:"
songdongsheng@658 18589 "patch\"/> for a description of the format), one per message. You can send a "
songdongsheng@658 18590 "binary bundle instead with the <option role=\"hg-ext-patchbomb-cmd-email-opt"
songdongsheng@658 18591 "\">hg -b</option> option."
dongsheng@627 18592 msgstr ""
dongsheng@627 18593
dongsheng@627 18594 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 18595 #: ../en/ch14-hgext.xml:512
dongsheng@627 18596 msgid ""
dongsheng@627 18597 "Unified diffs are normally prefaced with a metadata header. You can omit "
dongsheng@627 18598 "this, and send unadorned diffs, with the <option role=\"hg-ext-patchbomb-cmd-"
dongsheng@627 18599 "email-opt\">hg --plain</option> option."
dongsheng@627 18600 msgstr ""
dongsheng@627 18601
dongsheng@627 18602 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 18603 #: ../en/ch14-hgext.xml:518
dongsheng@627 18604 msgid ""
dongsheng@627 18605 "Diffs are normally sent <quote>inline</quote>, in the same body part as the "
dongsheng@627 18606 "description of a patch. This makes it easiest for the largest number of "
dongsheng@627 18607 "readers to quote and respond to parts of a diff, as some mail clients will "
dongsheng@627 18608 "only quote the first MIME body part in a message. If you'd prefer to send the "
dongsheng@627 18609 "description and the diff in separate body parts, use the <option role=\"hg-"
dongsheng@627 18610 "ext-patchbomb-cmd-email-opt\">hg -a</option> option."
dongsheng@627 18611 msgstr ""
dongsheng@627 18612
dongsheng@627 18613 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 18614 #: ../en/ch14-hgext.xml:528
dongsheng@627 18615 msgid ""
dongsheng@627 18616 "Instead of sending mail messages, you can write them to an <literal>mbox</"
dongsheng@627 18617 "literal>-format mail folder using the <option role=\"hg-ext-patchbomb-cmd-"
dongsheng@627 18618 "email-opt\">hg -m</option> option. That option takes one argument, the name "
dongsheng@627 18619 "of the file to write to."
dongsheng@627 18620 msgstr ""
dongsheng@627 18621
dongsheng@627 18622 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@714 18623 #: ../en/ch14-hgext.xml:535
dongsheng@627 18624 msgid ""
dongsheng@627 18625 "If you would like to add a <command>diffstat</command>-format summary to each "
dongsheng@627 18626 "patch, and one to the introductory message, use the <option role=\"hg-ext-"
dongsheng@627 18627 "patchbomb-cmd-email-opt\">hg -d</option> option. The <command>diffstat</"
dongsheng@627 18628 "command> command displays a table containing the name of each file patched, "
dongsheng@627 18629 "the number of lines affected, and a histogram showing how much each file is "
dongsheng@627 18630 "modified. This gives readers a qualitative glance at how complex a patch is."
dongsheng@627 18631 msgstr ""