hgbook

annotate po/zh.po @ 710:8613844dd2cf

Update po files with source xml files
author Dongsheng Song <songdongsheng@live.cn>
date Sat Apr 18 10:09:11 2009 +0800 (2009-04-18)
parents 55e2953f82d6
children 364d2ce9e055
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"
songdongsheng@710 44 "POT-Creation-Date: 2009-04-18 10:05+0800\n"
songdongsheng@668 45 "PO-Revision-Date: 2009-04-05 12:10+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@627 56 #: ../en/00book.xml:41
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@627 61 #: ../en/00book.xml:46
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>
songdongsheng@667 66 #: ../en/00book.xml:48
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>
songdongsheng@667 71 #: ../en/00book.xml:52
dongsheng@627 72 msgid "Bryan"
dongsheng@643 73 msgstr "Bryan"
dongsheng@627 74
dongsheng@627 75 #. type: Content of: <book><bookinfo><authorgroup><author><surname>
songdongsheng@667 76 #: ../en/00book.xml:53
dongsheng@627 77 msgid "O'Sullivan"
dongsheng@643 78 msgstr "O'Sullivan"
dongsheng@627 79
dongsheng@627 80 #. type: Content of: <book><bookinfo>
songdongsheng@667 81 #: ../en/00book.xml:57
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@627 92 #: ../en/appB-mq-ref.xml:5
dongsheng@627 93 msgid "Mercurial Queues reference"
dongsheng@627 94 msgstr "Mercurial 队列参考"
dongsheng@627 95
dongsheng@627 96 #. type: Content of: <book><appendix><sect1><title>
dongsheng@627 97 #: ../en/appB-mq-ref.xml:8
dongsheng@627 98 msgid "MQ command reference"
dongsheng@627 99 msgstr "MQ 命令参考"
dongsheng@627 100
dongsheng@627 101 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 102 #: ../en/appB-mq-ref.xml:10
dongsheng@627 103 msgid ""
dongsheng@627 104 "For an overview of the commands provided by MQ, use the command <command role="
dongsheng@627 105 "\"hg-cmd\">hg help mq</command>."
dongsheng@627 106 msgstr ""
dongsheng@627 107
dongsheng@627 108 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@627 109 #: ../en/appB-mq-ref.xml:14
songdongsheng@668 110 msgid ""
songdongsheng@668 111 "<command role=\"hg-ext-mq\">qapplied</command>&emdash;print applied patches"
dongsheng@661 112 msgstr "<command role=\"hg-ext-mq\">qapplied</command>—显示已应用的补丁"
dongsheng@627 113
dongsheng@627 114 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@627 115 #: ../en/appB-mq-ref.xml:17
dongsheng@627 116 msgid ""
dongsheng@627 117 "The <command role=\"hg-ext-mq\">qapplied</command> command prints the current "
dongsheng@627 118 "stack of applied patches. Patches are printed in oldest-to-newest order, so "
dongsheng@627 119 "the last patch in the list is the <quote>top</quote> patch."
dongsheng@627 120 msgstr ""
dongsheng@627 121
dongsheng@627 122 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@627 123 #: ../en/appB-mq-ref.xml:24
songdongsheng@668 124 msgid ""
songdongsheng@668 125 "<command role=\"hg-ext-mq\">qcommit</command>&emdash;commit changes in the "
songdongsheng@668 126 "queue repository"
dongsheng@661 127 msgstr "<command role=\"hg-ext-mq\">qcommit</command>—提交队列中的修改"
dongsheng@627 128
dongsheng@627 129 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@627 130 #: ../en/appB-mq-ref.xml:27
dongsheng@627 131 msgid ""
dongsheng@627 132 "The <command role=\"hg-ext-mq\">qcommit</command> command commits any "
dongsheng@627 133 "outstanding changes in the <filename role=\"special\" class=\"directory\">.hg/"
dongsheng@627 134 "patches</filename> repository. This command only works if the <filename role="
dongsheng@627 135 "\"special\" class=\"directory\">.hg/patches</filename> directory is a "
dongsheng@627 136 "repository, i.e. you created the directory using <command role=\"hg-cmd\">hg "
dongsheng@627 137 "qinit <option role=\"hg-ext-mq-cmd-qinit-opt\">-c</option></command> or ran "
dongsheng@627 138 "<command role=\"hg-cmd\">hg init</command> in the directory after running "
dongsheng@627 139 "<command role=\"hg-ext-mq\">qinit</command>."
dongsheng@627 140 msgstr ""
dongsheng@627 141
dongsheng@627 142 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@627 143 #: ../en/appB-mq-ref.xml:39
dongsheng@627 144 msgid ""
dongsheng@627 145 "This command is shorthand for <command role=\"hg-cmd\">hg commit --cwd .hg/"
dongsheng@627 146 "patches</command>."
dongsheng@627 147 msgstr ""
dongsheng@627 148
dongsheng@650 149 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@650 150 #: ../en/appB-mq-ref.xml:43
songdongsheng@668 151 msgid ""
songdongsheng@668 152 "<command role=\"hg-ext-mq\">qdelete</command>&emdash;delete a patch from the "
dongsheng@653 153 "<filename role=\"special\">series</filename> file"
dongsheng@653 154 msgstr ""
dongsheng@661 155 "<command role=\"hg-ext-mq\">qdelete</command>—从文件 <filename role=\"special"
dongsheng@661 156 "\">series</filename> 中删除补丁"
dongsheng@650 157
dongsheng@627 158 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 159 #: ../en/appB-mq-ref.xml:48
dongsheng@627 160 msgid ""
dongsheng@627 161 "The <command role=\"hg-ext-mq\">qdelete</command> command removes the entry "
dongsheng@627 162 "for a patch from the <filename role=\"special\">series</filename> file in the "
dongsheng@627 163 "<filename role=\"special\" class=\"directory\">.hg/patches</filename> "
dongsheng@627 164 "directory. It does not pop the patch if the patch is already applied. By "
dongsheng@627 165 "default, it does not delete the patch file; use the <option role=\"hg-ext-mq-"
dongsheng@627 166 "cmd-qdel-opt\">-f</option> option to do that."
dongsheng@627 167 msgstr ""
dongsheng@627 168
dongsheng@627 169 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 170 #: ../en/appB-mq-ref.xml:57 ../en/appB-mq-ref.xml:99 ../en/appB-mq-ref.xml:157
dongsheng@650 171 #: ../en/appB-mq-ref.xml:197 ../en/appB-mq-ref.xml:264
dongsheng@650 172 #: ../en/appB-mq-ref.xml:335 ../en/appB-mq-ref.xml:404
dongsheng@650 173 #: ../en/appB-mq-ref.xml:497
dongsheng@627 174 msgid "Options:"
songdongsheng@668 175 msgstr "选项:"
dongsheng@627 176
dongsheng@627 177 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 178 #: ../en/appB-mq-ref.xml:59
dongsheng@627 179 msgid ""
dongsheng@627 180 "<option role=\"hg-ext-mq-cmd-qdel-opt\">-f</option>: Delete the patch file."
dongsheng@627 181 msgstr ""
dongsheng@627 182
dongsheng@627 183 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@650 184 #: ../en/appB-mq-ref.xml:66
songdongsheng@668 185 msgid ""
songdongsheng@668 186 "<command role=\"hg-ext-mq\">qdiff</command>&emdash;print a diff of the "
songdongsheng@668 187 "topmost applied patch"
dongsheng@661 188 msgstr "<command role=\"hg-ext-mq\">qdiff</command>—显示最新应用补丁的差异"
dongsheng@627 189
dongsheng@627 190 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 191 #: ../en/appB-mq-ref.xml:69
dongsheng@627 192 msgid ""
dongsheng@627 193 "The <command role=\"hg-ext-mq\">qdiff</command> command prints a diff of the "
dongsheng@627 194 "topmost applied patch. It is equivalent to <command role=\"hg-cmd\">hg diff -"
dongsheng@627 195 "r-2:-1</command>."
dongsheng@627 196 msgstr ""
dongsheng@627 197
dongsheng@627 198 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@650 199 #: ../en/appB-mq-ref.xml:75
songdongsheng@668 200 msgid ""
songdongsheng@668 201 "<command role=\"hg-ext-mq\">qfold</command>&emdash;merge (<quote>fold</"
songdongsheng@668 202 "quote>) several patches into one"
dongsheng@661 203 msgstr ""
dongsheng@661 204 "<command role=\"hg-ext-mq\">qfold</command>—将多个补丁合并(<quote>折叠</"
dongsheng@661 205 "quote>)成一个"
dongsheng@627 206
dongsheng@627 207 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 208 #: ../en/appB-mq-ref.xml:78
dongsheng@627 209 msgid ""
dongsheng@627 210 "The <command role=\"hg-ext-mq\">qfold</command> command merges multiple "
dongsheng@627 211 "patches into the topmost applied patch, so that the topmost applied patch "
dongsheng@627 212 "makes the union of all of the changes in the patches in question."
dongsheng@627 213 msgstr ""
dongsheng@627 214
dongsheng@627 215 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 216 #: ../en/appB-mq-ref.xml:83
dongsheng@627 217 msgid ""
dongsheng@627 218 "The patches to fold must not be applied; <command role=\"hg-ext-mq\">qfold</"
dongsheng@627 219 "command> will exit with an error if any is. The order in which patches are "
dongsheng@627 220 "folded is significant; <command role=\"hg-cmd\">hg qfold a b</command> means "
dongsheng@627 221 "<quote>apply the current topmost patch, followed by <literal>a</literal>, "
dongsheng@627 222 "followed by <literal>b</literal></quote>."
dongsheng@627 223 msgstr ""
dongsheng@627 224
dongsheng@627 225 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 226 #: ../en/appB-mq-ref.xml:91
dongsheng@627 227 msgid ""
dongsheng@627 228 "The comments from the folded patches are appended to the comments of the "
dongsheng@627 229 "destination patch, with each block of comments separated by three asterisk "
dongsheng@627 230 "(<quote><literal>*</literal></quote>) characters. Use the <option role=\"hg-"
dongsheng@627 231 "ext-mq-cmd-qfold-opt\">-e</option> option to edit the commit message for the "
dongsheng@627 232 "combined patch/changeset after the folding has completed."
dongsheng@627 233 msgstr ""
dongsheng@627 234
dongsheng@627 235 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 236 #: ../en/appB-mq-ref.xml:101
dongsheng@627 237 msgid ""
dongsheng@627 238 "<option role=\"hg-ext-mq-cmd-qfold-opt\">-e</option>: Edit the commit message "
dongsheng@627 239 "and patch description for the newly folded patch."
dongsheng@627 240 msgstr ""
dongsheng@627 241
dongsheng@627 242 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 243 #: ../en/appB-mq-ref.xml:106
dongsheng@627 244 msgid ""
dongsheng@627 245 "<option role=\"hg-ext-mq-cmd-qfold-opt\">-l</option>: Use the contents of the "
dongsheng@627 246 "given file as the new commit message and patch description for the folded "
dongsheng@627 247 "patch."
dongsheng@627 248 msgstr ""
dongsheng@627 249
dongsheng@627 250 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 251 #: ../en/appB-mq-ref.xml:111
dongsheng@627 252 msgid ""
dongsheng@627 253 "<option role=\"hg-ext-mq-cmd-qfold-opt\">-m</option>: Use the given text as "
dongsheng@627 254 "the new commit message and patch description for the folded patch."
dongsheng@627 255 msgstr ""
dongsheng@627 256
dongsheng@627 257 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@650 258 #: ../en/appB-mq-ref.xml:119
songdongsheng@668 259 msgid ""
songdongsheng@668 260 "<command role=\"hg-ext-mq\">qheader</command>&emdash;display the header/"
songdongsheng@668 261 "description of a patch"
dongsheng@661 262 msgstr "<command role=\"hg-ext-mq\">qheader</command>—显示补丁头部描述"
dongsheng@627 263
dongsheng@627 264 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 265 #: ../en/appB-mq-ref.xml:123
dongsheng@627 266 msgid ""
dongsheng@627 267 "The <command role=\"hg-ext-mq\">qheader</command> command prints the header, "
dongsheng@627 268 "or description, of a patch. By default, it prints the header of the topmost "
dongsheng@627 269 "applied patch. Given an argument, it prints the header of the named patch."
dongsheng@627 270 msgstr ""
dongsheng@627 271
dongsheng@627 272 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@650 273 #: ../en/appB-mq-ref.xml:130
songdongsheng@668 274 msgid ""
songdongsheng@668 275 "<command role=\"hg-ext-mq\">qimport</command>&emdash;import a third-party "
songdongsheng@668 276 "patch into the queue"
dongsheng@661 277 msgstr "<command role=\"hg-ext-mq\">qimport</command>—将第三方补丁导入队列"
dongsheng@627 278
dongsheng@627 279 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 280 #: ../en/appB-mq-ref.xml:133
dongsheng@627 281 msgid ""
dongsheng@627 282 "The <command role=\"hg-ext-mq\">qimport</command> command adds an entry for "
dongsheng@627 283 "an external patch to the <filename role=\"special\">series</filename> file, "
dongsheng@627 284 "and copies the patch into the <filename role=\"special\" class=\"directory\">."
dongsheng@627 285 "hg/patches</filename> directory. It adds the entry immediately after the "
dongsheng@627 286 "topmost applied patch, but does not push the patch."
dongsheng@627 287 msgstr ""
dongsheng@627 288
dongsheng@627 289 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 290 #: ../en/appB-mq-ref.xml:141
dongsheng@627 291 msgid ""
dongsheng@627 292 "If the <filename role=\"special\" class=\"directory\">.hg/patches</filename> "
dongsheng@627 293 "directory is a repository, <command role=\"hg-ext-mq\">qimport</command> "
dongsheng@627 294 "automatically does an <command role=\"hg-cmd\">hg add</command> of the "
dongsheng@627 295 "imported patch."
dongsheng@627 296 msgstr ""
dongsheng@627 297
dongsheng@627 298 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@650 299 #: ../en/appB-mq-ref.xml:149
songdongsheng@668 300 msgid ""
songdongsheng@668 301 "<command role=\"hg-ext-mq\">qinit</command>&emdash;prepare a repository to "
songdongsheng@668 302 "work with MQ"
dongsheng@661 303 msgstr "<command role=\"hg-ext-mq\">qinit</command>—为使用 MQ 配置版本库"
dongsheng@627 304
dongsheng@627 305 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 306 #: ../en/appB-mq-ref.xml:152
dongsheng@627 307 msgid ""
dongsheng@627 308 "The <command role=\"hg-ext-mq\">qinit</command> command prepares a repository "
dongsheng@627 309 "to work with MQ. It creates a directory called <filename role=\"special\" "
dongsheng@627 310 "class=\"directory\">.hg/patches</filename>."
dongsheng@627 311 msgstr ""
dongsheng@627 312
dongsheng@627 313 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 314 #: ../en/appB-mq-ref.xml:159
dongsheng@627 315 msgid ""
dongsheng@627 316 "<option role=\"hg-ext-mq-cmd-qinit-opt\">-c</option>: Create <filename role="
dongsheng@627 317 "\"special\" class=\"directory\">.hg/patches</filename> as a repository in its "
dongsheng@627 318 "own right. Also creates a <filename role=\"special\">.hgignore</filename> "
dongsheng@627 319 "file that will ignore the <filename role=\"special\">status</filename> file."
dongsheng@627 320 msgstr ""
dongsheng@627 321
dongsheng@627 322 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 323 #: ../en/appB-mq-ref.xml:169
dongsheng@627 324 msgid ""
dongsheng@627 325 "When the <filename role=\"special\" class=\"directory\">.hg/patches</"
dongsheng@627 326 "filename> directory is a repository, the <command role=\"hg-ext-mq\">qimport</"
dongsheng@627 327 "command> and <command role=\"hg-ext-mq\">qnew</command> commands "
dongsheng@627 328 "automatically <command role=\"hg-cmd\">hg add</command> new patches."
dongsheng@627 329 msgstr ""
dongsheng@627 330
dongsheng@627 331 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@650 332 #: ../en/appB-mq-ref.xml:178
songdongsheng@668 333 msgid "<command role=\"hg-ext-mq\">qnew</command>&emdash;create a new patch"
dongsheng@661 334 msgstr "<command role=\"hg-ext-mq\">qnew</command>—创建新补丁"
dongsheng@627 335
dongsheng@627 336 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 337 #: ../en/appB-mq-ref.xml:181
dongsheng@627 338 msgid ""
dongsheng@627 339 "The <command role=\"hg-ext-mq\">qnew</command> command creates a new patch. "
dongsheng@627 340 "It takes one mandatory argument, the name to use for the patch file. The "
dongsheng@627 341 "newly created patch is created empty by default. It is added to the "
dongsheng@627 342 "<filename role=\"special\">series</filename> file after the current topmost "
dongsheng@627 343 "applied patch, and is immediately pushed on top of that patch."
dongsheng@627 344 msgstr ""
dongsheng@627 345
dongsheng@627 346 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 347 #: ../en/appB-mq-ref.xml:189
dongsheng@627 348 msgid ""
dongsheng@627 349 "If <command role=\"hg-ext-mq\">qnew</command> finds modified files in the "
dongsheng@627 350 "working directory, it will refuse to create a new patch unless the <option "
dongsheng@627 351 "role=\"hg-ext-mq-cmd-qnew-opt\">-f</option> option is used (see below). This "
songdongsheng@710 352 "behavior allows you to <command role=\"hg-ext-mq\">qrefresh</command> your "
dongsheng@627 353 "topmost applied patch before you apply a new patch on top of it."
dongsheng@627 354 msgstr ""
dongsheng@627 355
dongsheng@627 356 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 357 #: ../en/appB-mq-ref.xml:199
dongsheng@627 358 msgid ""
dongsheng@627 359 "<option role=\"hg-ext-mq-cmd-qnew-opt\">-f</option>: Create a new patch if "
dongsheng@627 360 "the contents of the working directory are modified. Any outstanding "
dongsheng@627 361 "modifications are added to the newly created patch, so after this command "
dongsheng@627 362 "completes, the working directory will no longer be modified."
dongsheng@627 363 msgstr ""
dongsheng@627 364
dongsheng@627 365 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 366 #: ../en/appB-mq-ref.xml:206
dongsheng@627 367 msgid ""
dongsheng@627 368 "<option role=\"hg-ext-mq-cmd-qnew-opt\">-m</option>: Use the given text as "
dongsheng@627 369 "the commit message. This text will be stored at the beginning of the patch "
dongsheng@627 370 "file, before the patch data."
dongsheng@627 371 msgstr ""
dongsheng@627 372
dongsheng@627 373 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@650 374 #: ../en/appB-mq-ref.xml:215
songdongsheng@668 375 msgid ""
songdongsheng@668 376 "<command role=\"hg-ext-mq\">qnext</command>&emdash;print the name of the next "
songdongsheng@668 377 "patch"
dongsheng@661 378 msgstr "<command role=\"hg-ext-mq\">qnext</command>—显示下个补丁的名称"
dongsheng@627 379
dongsheng@627 380 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 381 #: ../en/appB-mq-ref.xml:218
dongsheng@627 382 msgid ""
dongsheng@627 383 "The <command role=\"hg-ext-mq\">qnext</command> command prints the name name "
dongsheng@627 384 "of the next patch in the <filename role=\"special\">series</filename> file "
dongsheng@627 385 "after the topmost applied patch. This patch will become the topmost applied "
dongsheng@627 386 "patch if you run <command role=\"hg-ext-mq\">qpush</command>."
dongsheng@627 387 msgstr ""
dongsheng@627 388
dongsheng@627 389 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@650 390 #: ../en/appB-mq-ref.xml:227
songdongsheng@668 391 msgid ""
songdongsheng@668 392 "<command role=\"hg-ext-mq\">qpop</command>&emdash;pop patches off the stack"
dongsheng@661 393 msgstr "<command role=\"hg-ext-mq\">qpop</command>—删除堆栈顶部的补丁"
dongsheng@627 394
dongsheng@627 395 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 396 #: ../en/appB-mq-ref.xml:230
dongsheng@627 397 msgid ""
dongsheng@627 398 "The <command role=\"hg-ext-mq\">qpop</command> command removes applied "
dongsheng@627 399 "patches from the top of the stack of applied patches. By default, it removes "
dongsheng@627 400 "only one patch."
dongsheng@627 401 msgstr ""
dongsheng@627 402
dongsheng@627 403 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 404 #: ../en/appB-mq-ref.xml:234
dongsheng@627 405 msgid ""
dongsheng@627 406 "This command removes the changesets that represent the popped patches from "
dongsheng@627 407 "the repository, and updates the working directory to undo the effects of the "
dongsheng@627 408 "patches."
dongsheng@627 409 msgstr ""
dongsheng@627 410
dongsheng@627 411 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 412 #: ../en/appB-mq-ref.xml:238
dongsheng@627 413 msgid ""
dongsheng@627 414 "This command takes an optional argument, which it uses as the name or index "
dongsheng@627 415 "of the patch to pop to. If given a name, it will pop patches until the named "
dongsheng@627 416 "patch is the topmost applied patch. If given a number, <command role=\"hg-"
dongsheng@627 417 "ext-mq\">qpop</command> treats the number as an index into the entries in the "
dongsheng@627 418 "series file, counting from zero (empty lines and lines containing only "
dongsheng@627 419 "comments do not count). It pops patches until the patch identified by the "
dongsheng@627 420 "given index is the topmost applied patch."
dongsheng@627 421 msgstr ""
dongsheng@627 422
dongsheng@627 423 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 424 #: ../en/appB-mq-ref.xml:248
dongsheng@627 425 msgid ""
dongsheng@627 426 "The <command role=\"hg-ext-mq\">qpop</command> command does not read or write "
dongsheng@627 427 "patches or the <filename role=\"special\">series</filename> file. It is thus "
dongsheng@627 428 "safe to <command role=\"hg-ext-mq\">qpop</command> a patch that you have "
dongsheng@627 429 "removed from the <filename role=\"special\">series</filename> file, or a "
dongsheng@627 430 "patch that you have renamed or deleted entirely. In the latter two cases, "
dongsheng@627 431 "use the name of the patch as it was when you applied it."
dongsheng@627 432 msgstr ""
dongsheng@627 433
dongsheng@627 434 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 435 #: ../en/appB-mq-ref.xml:257
dongsheng@627 436 msgid ""
dongsheng@627 437 "By default, the <command role=\"hg-ext-mq\">qpop</command> command will not "
dongsheng@627 438 "pop any patches if the working directory has been modified. You can override "
songdongsheng@710 439 "this behavior using the <option role=\"hg-ext-mq-cmd-qpop-opt\">-f</option> "
dongsheng@627 440 "option, which reverts all modifications in the working directory."
dongsheng@627 441 msgstr ""
dongsheng@627 442
dongsheng@627 443 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 444 #: ../en/appB-mq-ref.xml:266
dongsheng@627 445 msgid ""
dongsheng@627 446 "<option role=\"hg-ext-mq-cmd-qpop-opt\">-a</option>: Pop all applied "
dongsheng@627 447 "patches. This returns the repository to its state before you applied any "
dongsheng@627 448 "patches."
dongsheng@627 449 msgstr ""
dongsheng@627 450
dongsheng@627 451 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 452 #: ../en/appB-mq-ref.xml:271
dongsheng@627 453 msgid ""
dongsheng@627 454 "<option role=\"hg-ext-mq-cmd-qpop-opt\">-f</option>: Forcibly revert any "
dongsheng@627 455 "modifications to the working directory when popping."
dongsheng@627 456 msgstr ""
dongsheng@627 457
dongsheng@627 458 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 459 #: ../en/appB-mq-ref.xml:276
dongsheng@627 460 msgid ""
dongsheng@627 461 "<option role=\"hg-ext-mq-cmd-qpop-opt\">-n</option>: Pop a patch from the "
dongsheng@627 462 "named queue."
dongsheng@627 463 msgstr ""
dongsheng@627 464
dongsheng@627 465 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 466 #: ../en/appB-mq-ref.xml:281
dongsheng@627 467 msgid ""
dongsheng@627 468 "The <command role=\"hg-ext-mq\">qpop</command> command removes one line from "
dongsheng@627 469 "the end of the <filename role=\"special\">status</filename> file for each "
dongsheng@627 470 "patch that it pops."
dongsheng@627 471 msgstr ""
dongsheng@627 472
dongsheng@627 473 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@650 474 #: ../en/appB-mq-ref.xml:288
songdongsheng@668 475 msgid ""
songdongsheng@668 476 "<command role=\"hg-ext-mq\">qprev</command>&emdash;print the name of the "
songdongsheng@668 477 "previous patch"
dongsheng@661 478 msgstr "<command role=\"hg-ext-mq\">qprev</command>—显示上个补丁的名称"
dongsheng@627 479
dongsheng@627 480 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 481 #: ../en/appB-mq-ref.xml:291
dongsheng@627 482 msgid ""
dongsheng@627 483 "The <command role=\"hg-ext-mq\">qprev</command> command prints the name of "
dongsheng@627 484 "the patch in the <filename role=\"special\">series</filename> file that comes "
dongsheng@627 485 "before the topmost applied patch. This will become the topmost applied patch "
dongsheng@627 486 "if you run <command role=\"hg-ext-mq\">qpop</command>."
dongsheng@627 487 msgstr ""
dongsheng@627 488
dongsheng@627 489 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@650 490 #: ../en/appB-mq-ref.xml:300
songdongsheng@668 491 msgid ""
songdongsheng@668 492 "<command role=\"hg-ext-mq\">qpush</command>&emdash;push patches onto the stack"
dongsheng@661 493 msgstr "<command role=\"hg-ext-mq\">qpush</command>—增加补丁到堆栈"
dongsheng@627 494
dongsheng@627 495 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 496 #: ../en/appB-mq-ref.xml:303
dongsheng@627 497 msgid ""
dongsheng@627 498 "The <command role=\"hg-ext-mq\">qpush</command> command adds patches onto the "
dongsheng@627 499 "applied stack. By default, it adds only one patch."
dongsheng@627 500 msgstr ""
dongsheng@627 501
dongsheng@627 502 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 503 #: ../en/appB-mq-ref.xml:307
dongsheng@627 504 msgid ""
dongsheng@627 505 "This command creates a new changeset to represent each applied patch, and "
dongsheng@627 506 "updates the working directory to apply the effects of the patches."
dongsheng@627 507 msgstr ""
dongsheng@627 508
dongsheng@627 509 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 510 #: ../en/appB-mq-ref.xml:311
dongsheng@627 511 msgid "The default data used when creating a changeset are as follows:"
dongsheng@627 512 msgstr ""
dongsheng@627 513
dongsheng@627 514 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 515 #: ../en/appB-mq-ref.xml:314
dongsheng@627 516 msgid ""
dongsheng@627 517 "The commit date and time zone are the current date and time zone. Because "
dongsheng@627 518 "these data are used to compute the identity of a changeset, this means that "
dongsheng@627 519 "if you <command role=\"hg-ext-mq\">qpop</command> a patch and <command role="
dongsheng@627 520 "\"hg-ext-mq\">qpush</command> it again, the changeset that you push will have "
dongsheng@627 521 "a different identity than the changeset you popped."
dongsheng@627 522 msgstr ""
dongsheng@627 523
dongsheng@627 524 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 525 #: ../en/appB-mq-ref.xml:322
dongsheng@627 526 msgid ""
dongsheng@627 527 "The author is the same as the default used by the <command role=\"hg-cmd\">hg "
dongsheng@627 528 "commit</command> command."
dongsheng@627 529 msgstr ""
dongsheng@627 530
dongsheng@627 531 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 532 #: ../en/appB-mq-ref.xml:326
dongsheng@627 533 msgid ""
dongsheng@627 534 "The commit message is any text from the patch file that comes before the "
dongsheng@627 535 "first diff header. If there is no such text, a default commit message is "
dongsheng@627 536 "used that identifies the name of the patch."
dongsheng@627 537 msgstr ""
dongsheng@627 538
dongsheng@627 539 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 540 #: ../en/appB-mq-ref.xml:331
dongsheng@627 541 msgid ""
dongsheng@627 542 "If a patch contains a Mercurial patch header (XXX add link), the information "
dongsheng@627 543 "in the patch header overrides these defaults."
dongsheng@627 544 msgstr ""
dongsheng@627 545
dongsheng@627 546 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 547 #: ../en/appB-mq-ref.xml:337
dongsheng@627 548 msgid ""
dongsheng@627 549 "<option role=\"hg-ext-mq-cmd-qpush-opt\">-a</option>: Push all unapplied "
dongsheng@627 550 "patches from the <filename role=\"special\">series</filename> file until "
dongsheng@627 551 "there are none left to push."
dongsheng@627 552 msgstr ""
dongsheng@627 553
dongsheng@627 554 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 555 #: ../en/appB-mq-ref.xml:343
dongsheng@627 556 msgid ""
dongsheng@627 557 "<option role=\"hg-ext-mq-cmd-qpush-opt\">-l</option>: Add the name of the "
dongsheng@627 558 "patch to the end of the commit message."
dongsheng@627 559 msgstr ""
dongsheng@627 560
dongsheng@627 561 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 562 #: ../en/appB-mq-ref.xml:347
dongsheng@627 563 msgid ""
dongsheng@627 564 "<option role=\"hg-ext-mq-cmd-qpush-opt\">-m</option>: If a patch fails to "
dongsheng@627 565 "apply cleanly, use the entry for the patch in another saved queue to compute "
dongsheng@627 566 "the parameters for a three-way merge, and perform a three-way merge using the "
dongsheng@627 567 "normal Mercurial merge machinery. Use the resolution of the merge as the new "
dongsheng@627 568 "patch content."
dongsheng@627 569 msgstr ""
dongsheng@627 570
dongsheng@627 571 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 572 #: ../en/appB-mq-ref.xml:355
dongsheng@627 573 msgid ""
dongsheng@627 574 "<option role=\"hg-ext-mq-cmd-qpush-opt\">-n</option>: Use the named queue if "
dongsheng@627 575 "merging while pushing."
dongsheng@627 576 msgstr ""
dongsheng@627 577
dongsheng@627 578 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 579 #: ../en/appB-mq-ref.xml:360
dongsheng@627 580 msgid ""
dongsheng@627 581 "The <command role=\"hg-ext-mq\">qpush</command> command reads, but does not "
dongsheng@627 582 "modify, the <filename role=\"special\">series</filename> file. It appends "
dongsheng@627 583 "one line to the <command role=\"hg-cmd\">hg status</command> file for each "
dongsheng@627 584 "patch that it pushes."
dongsheng@627 585 msgstr ""
dongsheng@627 586
dongsheng@627 587 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@650 588 #: ../en/appB-mq-ref.xml:368
songdongsheng@668 589 msgid ""
songdongsheng@668 590 "<command role=\"hg-ext-mq\">qrefresh</command>&emdash;update the topmost "
songdongsheng@668 591 "applied patch"
dongsheng@661 592 msgstr "<command role=\"hg-ext-mq\">qrefresh</command>—更新最新的补丁"
dongsheng@627 593
dongsheng@627 594 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 595 #: ../en/appB-mq-ref.xml:372
dongsheng@627 596 msgid ""
dongsheng@627 597 "The <command role=\"hg-ext-mq\">qrefresh</command> command updates the "
dongsheng@627 598 "topmost applied patch. It modifies the patch, removes the old changeset that "
dongsheng@627 599 "represented the patch, and creates a new changeset to represent the modified "
dongsheng@627 600 "patch."
dongsheng@627 601 msgstr ""
dongsheng@627 602
dongsheng@627 603 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 604 #: ../en/appB-mq-ref.xml:378
dongsheng@627 605 msgid ""
dongsheng@627 606 "The <command role=\"hg-ext-mq\">qrefresh</command> command looks for the "
dongsheng@627 607 "following modifications:"
dongsheng@627 608 msgstr ""
dongsheng@627 609
dongsheng@627 610 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 611 #: ../en/appB-mq-ref.xml:381
dongsheng@627 612 msgid ""
dongsheng@627 613 "Changes to the commit message, i.e. the text before the first diff header in "
dongsheng@627 614 "the patch file, are reflected in the new changeset that represents the patch."
dongsheng@627 615 msgstr ""
dongsheng@627 616
dongsheng@627 617 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 618 #: ../en/appB-mq-ref.xml:386
dongsheng@627 619 msgid ""
dongsheng@627 620 "Modifications to tracked files in the working directory are added to the "
dongsheng@627 621 "patch."
dongsheng@627 622 msgstr ""
dongsheng@627 623
dongsheng@627 624 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 625 #: ../en/appB-mq-ref.xml:389
dongsheng@627 626 msgid ""
dongsheng@627 627 "Changes to the files tracked using <command role=\"hg-cmd\">hg add</command>, "
dongsheng@627 628 "<command role=\"hg-cmd\">hg copy</command>, <command role=\"hg-cmd\">hg "
dongsheng@627 629 "remove</command>, or <command role=\"hg-cmd\">hg rename</command>. Added "
dongsheng@627 630 "files and copy and rename destinations are added to the patch, while removed "
dongsheng@627 631 "files and rename sources are removed."
dongsheng@627 632 msgstr ""
dongsheng@627 633
dongsheng@627 634 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 635 #: ../en/appB-mq-ref.xml:398
dongsheng@627 636 msgid ""
dongsheng@627 637 "Even if <command role=\"hg-ext-mq\">qrefresh</command> detects no changes, it "
dongsheng@627 638 "still recreates the changeset that represents the patch. This causes the "
dongsheng@627 639 "identity of the changeset to differ from the previous changeset that "
dongsheng@627 640 "identified the patch."
dongsheng@627 641 msgstr ""
dongsheng@627 642
dongsheng@627 643 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 644 #: ../en/appB-mq-ref.xml:406
dongsheng@627 645 msgid ""
dongsheng@627 646 "<option role=\"hg-ext-mq-cmd-qrefresh-opt\">-e</option>: Modify the commit "
dongsheng@627 647 "and patch description, using the preferred text editor."
dongsheng@627 648 msgstr ""
dongsheng@627 649
dongsheng@627 650 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 651 #: ../en/appB-mq-ref.xml:411
dongsheng@627 652 msgid ""
dongsheng@627 653 "<option role=\"hg-ext-mq-cmd-qrefresh-opt\">-m</option>: Modify the commit "
dongsheng@627 654 "message and patch description, using the given text."
dongsheng@627 655 msgstr ""
dongsheng@627 656
dongsheng@627 657 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 658 #: ../en/appB-mq-ref.xml:416
dongsheng@627 659 msgid ""
dongsheng@627 660 "<option role=\"hg-ext-mq-cmd-qrefresh-opt\">-l</option>: Modify the commit "
dongsheng@627 661 "message and patch description, using text from the given file."
dongsheng@627 662 msgstr ""
dongsheng@627 663
dongsheng@627 664 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@650 665 #: ../en/appB-mq-ref.xml:424
songdongsheng@668 666 msgid "<command role=\"hg-ext-mq\">qrename</command>&emdash;rename a patch"
dongsheng@661 667 msgstr "<command role=\"hg-ext-mq\">qrename</command>—改名补丁"
dongsheng@627 668
dongsheng@627 669 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 670 #: ../en/appB-mq-ref.xml:427
dongsheng@627 671 msgid ""
dongsheng@627 672 "The <command role=\"hg-ext-mq\">qrename</command> command renames a patch, "
dongsheng@627 673 "and changes the entry for the patch in the <filename role=\"special\">series</"
dongsheng@627 674 "filename> file."
dongsheng@627 675 msgstr ""
dongsheng@627 676
dongsheng@627 677 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 678 #: ../en/appB-mq-ref.xml:431
dongsheng@627 679 msgid ""
dongsheng@627 680 "With a single argument, <command role=\"hg-ext-mq\">qrename</command> renames "
dongsheng@627 681 "the topmost applied patch. With two arguments, it renames its first argument "
dongsheng@627 682 "to its second."
dongsheng@627 683 msgstr ""
dongsheng@627 684
dongsheng@627 685 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@650 686 #: ../en/appB-mq-ref.xml:438
songdongsheng@668 687 msgid ""
songdongsheng@668 688 "<command role=\"hg-ext-mq\">qrestore</command>&emdash;restore saved queue "
songdongsheng@668 689 "state"
dongsheng@661 690 msgstr "<command role=\"hg-ext-mq\">qrestore</command>—恢复保存的队列"
dongsheng@627 691
dongsheng@627 692 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 693 #: ../en/appB-mq-ref.xml:442
dongsheng@627 694 msgid "XXX No idea what this does."
dongsheng@627 695 msgstr ""
dongsheng@627 696
dongsheng@627 697 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@650 698 #: ../en/appB-mq-ref.xml:446
songdongsheng@668 699 msgid ""
songdongsheng@668 700 "<command role=\"hg-ext-mq\">qsave</command>&emdash;save current queue state"
dongsheng@661 701 msgstr "<command role=\"hg-ext-mq\">qsave</command>—保存当前的队列状态"
dongsheng@627 702
dongsheng@627 703 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 704 #: ../en/appB-mq-ref.xml:449
dongsheng@627 705 msgid "XXX Likewise."
dongsheng@627 706 msgstr ""
dongsheng@627 707
dongsheng@627 708 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@650 709 #: ../en/appB-mq-ref.xml:453
songdongsheng@668 710 msgid ""
songdongsheng@668 711 "<command role=\"hg-ext-mq\">qseries</command>&emdash;print the entire patch "
songdongsheng@668 712 "series"
dongsheng@661 713 msgstr "<command role=\"hg-ext-mq\">qseries</command>—显示补丁序列"
dongsheng@627 714
dongsheng@627 715 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 716 #: ../en/appB-mq-ref.xml:456
dongsheng@627 717 msgid ""
dongsheng@627 718 "The <command role=\"hg-ext-mq\">qseries</command> command prints the entire "
dongsheng@627 719 "patch series from the <filename role=\"special\">series</filename> file. It "
dongsheng@627 720 "prints only patch names, not empty lines or comments. It prints in order "
dongsheng@627 721 "from first to be applied to last."
dongsheng@627 722 msgstr ""
dongsheng@627 723
dongsheng@627 724 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@650 725 #: ../en/appB-mq-ref.xml:464
songdongsheng@668 726 msgid ""
songdongsheng@668 727 "<command role=\"hg-ext-mq\">qtop</command>&emdash;print the name of the "
songdongsheng@668 728 "current patch"
dongsheng@661 729 msgstr "<command role=\"hg-ext-mq\">qtop</command>—显示当前补丁的名称"
dongsheng@627 730
dongsheng@627 731 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 732 #: ../en/appB-mq-ref.xml:467
dongsheng@627 733 msgid ""
dongsheng@627 734 "The <command role=\"hg-ext-mq\">qtop</command> prints the name of the topmost "
dongsheng@627 735 "currently applied patch."
dongsheng@627 736 msgstr ""
dongsheng@627 737
dongsheng@627 738 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@650 739 #: ../en/appB-mq-ref.xml:472
songdongsheng@668 740 msgid ""
songdongsheng@668 741 "<command role=\"hg-ext-mq\">qunapplied</command>&emdash;print patches not yet "
songdongsheng@668 742 "applied"
dongsheng@661 743 msgstr "<command role=\"hg-ext-mq\">qunapplied</command>—显示尚未应用的补丁"
dongsheng@627 744
dongsheng@627 745 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 746 #: ../en/appB-mq-ref.xml:476
dongsheng@627 747 msgid ""
dongsheng@627 748 "The <command role=\"hg-ext-mq\">qunapplied</command> command prints the names "
dongsheng@627 749 "of patches from the <filename role=\"special\">series</filename> file that "
dongsheng@627 750 "are not yet applied. It prints them in order from the next patch that will "
dongsheng@627 751 "be pushed to the last."
dongsheng@627 752 msgstr ""
dongsheng@627 753
dongsheng@627 754 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@650 755 #: ../en/appB-mq-ref.xml:484
songdongsheng@668 756 msgid ""
songdongsheng@668 757 "<command role=\"hg-cmd\">hg strip</command>&emdash;remove a revision and "
songdongsheng@668 758 "descendants"
dongsheng@661 759 msgstr "<command role=\"hg-cmd\">hg strip</command>—删除一个版本及其后继"
dongsheng@627 760
dongsheng@627 761 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 762 #: ../en/appB-mq-ref.xml:487
dongsheng@627 763 msgid ""
dongsheng@627 764 "The <command role=\"hg-cmd\">hg strip</command> command removes a revision, "
dongsheng@627 765 "and all of its descendants, from the repository. It undoes the effects of "
dongsheng@627 766 "the removed revisions from the repository, and updates the working directory "
dongsheng@627 767 "to the first parent of the removed revision."
dongsheng@627 768 msgstr ""
dongsheng@627 769
dongsheng@627 770 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 771 #: ../en/appB-mq-ref.xml:493
dongsheng@627 772 msgid ""
dongsheng@627 773 "The <command role=\"hg-cmd\">hg strip</command> command saves a backup of the "
dongsheng@627 774 "removed changesets in a bundle, so that they can be reapplied if removed in "
dongsheng@627 775 "error."
dongsheng@627 776 msgstr ""
dongsheng@627 777
dongsheng@627 778 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 779 #: ../en/appB-mq-ref.xml:499
dongsheng@627 780 msgid ""
dongsheng@627 781 "<option role=\"hg-opt-strip\">-b</option>: Save unrelated changesets that are "
dongsheng@627 782 "intermixed with the stripped changesets in the backup bundle."
dongsheng@627 783 msgstr ""
dongsheng@627 784
dongsheng@627 785 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 786 #: ../en/appB-mq-ref.xml:503
dongsheng@627 787 msgid ""
dongsheng@627 788 "<option role=\"hg-opt-strip\">-f</option>: If a branch has multiple heads, "
dongsheng@627 789 "remove all heads. XXX This should be renamed, and use <literal>-f</literal> "
dongsheng@627 790 "to strip revs when there are pending changes."
dongsheng@627 791 msgstr ""
dongsheng@627 792
dongsheng@627 793 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 794 #: ../en/appB-mq-ref.xml:508
dongsheng@627 795 msgid "<option role=\"hg-opt-strip\">-n</option>: Do not save a backup bundle."
dongsheng@627 796 msgstr ""
dongsheng@627 797
dongsheng@627 798 #. type: Content of: <book><appendix><sect1><title>
dongsheng@650 799 #: ../en/appB-mq-ref.xml:515
dongsheng@627 800 msgid "MQ file reference"
dongsheng@627 801 msgstr "MQ 文件参考"
dongsheng@627 802
dongsheng@627 803 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@650 804 #: ../en/appB-mq-ref.xml:518
dongsheng@627 805 msgid "The <filename role=\"special\">series</filename> file"
dongsheng@627 806 msgstr "<filename role=\"special\">序列</filename>文件"
dongsheng@627 807
dongsheng@627 808 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 809 #: ../en/appB-mq-ref.xml:521
dongsheng@627 810 msgid ""
dongsheng@627 811 "The <filename role=\"special\">series</filename> file contains a list of the "
dongsheng@627 812 "names of all patches that MQ can apply. It is represented as a list of "
dongsheng@627 813 "names, with one name saved per line. Leading and trailing white space in "
dongsheng@627 814 "each line are ignored."
dongsheng@627 815 msgstr ""
dongsheng@627 816
dongsheng@627 817 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 818 #: ../en/appB-mq-ref.xml:527
dongsheng@627 819 msgid ""
dongsheng@627 820 "Lines may contain comments. A comment begins with the <quote><literal>#</"
dongsheng@627 821 "literal></quote> character, and extends to the end of the line. Empty lines, "
dongsheng@627 822 "and lines that contain only comments, are ignored."
dongsheng@627 823 msgstr ""
dongsheng@627 824
dongsheng@627 825 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 826 #: ../en/appB-mq-ref.xml:532
dongsheng@627 827 msgid ""
dongsheng@627 828 "You will often need to edit the <filename role=\"special\">series</filename> "
dongsheng@627 829 "file by hand, hence the support for comments and empty lines noted above. "
dongsheng@627 830 "For example, you can comment out a patch temporarily, and <command role=\"hg-"
dongsheng@627 831 "ext-mq\">qpush</command> will skip over that patch when applying patches. "
dongsheng@627 832 "You can also change the order in which patches are applied by reordering "
dongsheng@627 833 "their entries in the <filename role=\"special\">series</filename> file."
dongsheng@627 834 msgstr ""
dongsheng@627 835
dongsheng@627 836 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 837 #: ../en/appB-mq-ref.xml:541
dongsheng@627 838 msgid ""
dongsheng@627 839 "Placing the <filename role=\"special\">series</filename> file under revision "
dongsheng@627 840 "control is also supported; it is a good idea to place all of the patches that "
dongsheng@627 841 "it refers to under revision control, as well. If you create a patch "
dongsheng@627 842 "directory using the <option role=\"hg-ext-mq-cmd-qinit-opt\">-c</option> "
dongsheng@627 843 "option to <command role=\"hg-ext-mq\">qinit</command>, this will be done for "
dongsheng@627 844 "you automatically."
dongsheng@627 845 msgstr ""
dongsheng@627 846
dongsheng@627 847 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@650 848 #: ../en/appB-mq-ref.xml:551
dongsheng@627 849 msgid "The <filename role=\"special\">status</filename> file"
dongsheng@627 850 msgstr "<filename role=\"special\">状态</filename>文件"
dongsheng@627 851
dongsheng@627 852 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 853 #: ../en/appB-mq-ref.xml:554
dongsheng@627 854 msgid ""
dongsheng@627 855 "The <filename role=\"special\">status</filename> file contains the names and "
dongsheng@627 856 "changeset hashes of all patches that MQ currently has applied. Unlike the "
dongsheng@627 857 "<filename role=\"special\">series</filename> file, this file is not intended "
dongsheng@627 858 "for editing. You should not place this file under revision control, or "
dongsheng@627 859 "modify it in any way. It is used by MQ strictly for internal book-keeping."
dongsheng@627 860 msgstr ""
dongsheng@627 861
dongsheng@627 862 #. type: Content of: <book><appendix><title>
dongsheng@627 863 #: ../en/appC-srcinstall.xml:5
dongsheng@627 864 msgid "Installing Mercurial from source"
dongsheng@627 865 msgstr "从源代码安装 Mercurial"
dongsheng@627 866
dongsheng@627 867 #. type: Content of: <book><appendix><sect1><title>
dongsheng@627 868 #: ../en/appC-srcinstall.xml:8
dongsheng@627 869 msgid "On a Unix-like system"
dongsheng@627 870 msgstr "类 Unix 系统"
dongsheng@627 871
dongsheng@627 872 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 873 #: ../en/appC-srcinstall.xml:10
dongsheng@627 874 msgid ""
dongsheng@627 875 "If you are using a Unix-like system that has a sufficiently recent version of "
dongsheng@627 876 "Python (2.3 or newer) available, it is easy to install Mercurial from source."
dongsheng@627 877 msgstr ""
dongsheng@627 878
dongsheng@627 879 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
dongsheng@627 880 #: ../en/appC-srcinstall.xml:14
dongsheng@627 881 msgid ""
dongsheng@627 882 "Download a recent source tarball from <ulink url=\"http://www.selenic.com/"
dongsheng@627 883 "mercurial/download\">http://www.selenic.com/mercurial/download</ulink>."
dongsheng@627 884 msgstr ""
dongsheng@627 885
dongsheng@627 886 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
dongsheng@627 887 #: ../en/appC-srcinstall.xml:17
dongsheng@627 888 msgid "Unpack the tarball:"
dongsheng@627 889 msgstr ""
dongsheng@627 890
dongsheng@627 891 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
dongsheng@627 892 #: ../en/appC-srcinstall.xml:20
dongsheng@627 893 msgid ""
dongsheng@627 894 "Go into the source directory and run the installer script. This will build "
dongsheng@627 895 "Mercurial and install it in your home directory."
dongsheng@627 896 msgstr ""
dongsheng@627 897
dongsheng@627 898 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 899 #: ../en/appC-srcinstall.xml:27
dongsheng@627 900 msgid ""
dongsheng@627 901 "Once the install finishes, Mercurial will be in the <literal>bin</literal> "
dongsheng@627 902 "subdirectory of your home directory. Don't forget to make sure that this "
dongsheng@627 903 "directory is present in your shell's search path."
dongsheng@627 904 msgstr ""
dongsheng@627 905
dongsheng@627 906 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 907 #: ../en/appC-srcinstall.xml:32
dongsheng@627 908 msgid ""
dongsheng@627 909 "You will probably need to set the <envar>PYTHONPATH</envar> environment "
dongsheng@627 910 "variable so that the Mercurial executable can find the rest of the Mercurial "
dongsheng@627 911 "packages. For example, on my laptop, I have set it to <literal>/home/bos/lib/"
dongsheng@627 912 "python</literal>. The exact path that you will need to use depends on how "
dongsheng@627 913 "Python was built for your system, but should be easy to figure out. If "
dongsheng@627 914 "you're uncertain, look through the output of the installer script above, and "
dongsheng@627 915 "see where the contents of the <literal>mercurial</literal> directory were "
dongsheng@627 916 "installed to."
dongsheng@627 917 msgstr ""
dongsheng@627 918
dongsheng@627 919 #. type: Content of: <book><appendix><sect1><title>
dongsheng@627 920 #: ../en/appC-srcinstall.xml:44
dongsheng@627 921 msgid "On Windows"
dongsheng@627 922 msgstr "Windows 系统"
dongsheng@627 923
dongsheng@627 924 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 925 #: ../en/appC-srcinstall.xml:46
dongsheng@627 926 msgid ""
dongsheng@627 927 "Building and installing Mercurial on Windows requires a variety of tools, a "
dongsheng@627 928 "fair amount of technical knowledge, and considerable patience. I very much "
dongsheng@627 929 "<emphasis>do not recommend</emphasis> this route if you are a <quote>casual "
dongsheng@627 930 "user</quote>. Unless you intend to hack on Mercurial, I strongly suggest "
dongsheng@627 931 "that you use a binary package instead."
dongsheng@627 932 msgstr ""
dongsheng@627 933
dongsheng@627 934 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 935 #: ../en/appC-srcinstall.xml:53
dongsheng@627 936 msgid ""
dongsheng@627 937 "If you are intent on building Mercurial from source on Windows, follow the "
dongsheng@627 938 "<quote>hard way</quote> directions on the Mercurial wiki at <ulink url="
dongsheng@627 939 "\"http://www.selenic.com/mercurial/wiki/index.cgi/WindowsInstall\">http://www."
dongsheng@627 940 "selenic.com/mercurial/wiki/index.cgi/WindowsInstall</ulink>, and expect the "
dongsheng@627 941 "process to involve a lot of fiddly work."
dongsheng@627 942 msgstr ""
dongsheng@627 943
dongsheng@627 944 #. type: Content of: <book><appendix><title>
dongsheng@627 945 #: ../en/appD-license.xml:5
dongsheng@627 946 msgid "Open Publication License"
dongsheng@627 947 msgstr ""
dongsheng@627 948
dongsheng@627 949 #. type: Content of: <book><appendix><para>
dongsheng@627 950 #: ../en/appD-license.xml:7
dongsheng@627 951 msgid "Version 1.0, 8 June 1999"
dongsheng@627 952 msgstr ""
dongsheng@627 953
dongsheng@627 954 #. type: Content of: <book><appendix><sect1><title>
dongsheng@627 955 #: ../en/appD-license.xml:10
dongsheng@627 956 msgid "Requirements on both unmodified and modified versions"
dongsheng@627 957 msgstr ""
dongsheng@627 958
dongsheng@627 959 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 960 #: ../en/appD-license.xml:13
dongsheng@627 961 msgid ""
dongsheng@627 962 "The Open Publication works may be reproduced and distributed in whole or in "
dongsheng@627 963 "part, in any medium physical or electronic, provided that the terms of this "
dongsheng@627 964 "license are adhered to, and that this license or an incorporation of it by "
dongsheng@627 965 "reference (with any options elected by the author(s) and/or publisher) is "
dongsheng@627 966 "displayed in the reproduction."
dongsheng@627 967 msgstr ""
dongsheng@627 968
dongsheng@627 969 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 970 #: ../en/appD-license.xml:20
dongsheng@627 971 msgid "Proper form for an incorporation by reference is as follows:"
dongsheng@627 972 msgstr ""
dongsheng@627 973
dongsheng@627 974 #. type: Content of: <book><appendix><sect1><blockquote><para>
dongsheng@627 975 #: ../en/appD-license.xml:24
dongsheng@627 976 msgid ""
dongsheng@627 977 "Copyright (c) <emphasis>year</emphasis> by <emphasis>author's name or "
dongsheng@627 978 "designee</emphasis>. This material may be distributed only subject to the "
dongsheng@627 979 "terms and conditions set forth in the Open Publication License, v<emphasis>x."
dongsheng@627 980 "y</emphasis> or later (the latest version is presently available at <ulink "
dongsheng@627 981 "url=\"http://www.opencontent.org/openpub/\">http://www.opencontent.org/"
dongsheng@627 982 "openpub/</ulink>)."
dongsheng@627 983 msgstr ""
dongsheng@627 984
dongsheng@627 985 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 986 #: ../en/appD-license.xml:33
dongsheng@627 987 msgid ""
dongsheng@627 988 "The reference must be immediately followed with any options elected by the "
songdongsheng@658 989 "author(s) and/or publisher of the document (see <xref linkend=\"sec:opl:"
songdongsheng@658 990 "options\"/>)."
dongsheng@627 991 msgstr ""
dongsheng@627 992
dongsheng@627 993 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 994 #: ../en/appD-license.xml:37
dongsheng@627 995 msgid ""
dongsheng@627 996 "Commercial redistribution of Open Publication-licensed material is permitted."
dongsheng@627 997 msgstr ""
dongsheng@627 998
dongsheng@627 999 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 1000 #: ../en/appD-license.xml:40
dongsheng@627 1001 msgid ""
dongsheng@627 1002 "Any publication in standard (paper) book form shall require the citation of "
dongsheng@627 1003 "the original publisher and author. The publisher and author's names shall "
dongsheng@627 1004 "appear on all outer surfaces of the book. On all outer surfaces of the book "
dongsheng@627 1005 "the original publisher's name shall be as large as the title of the work and "
dongsheng@627 1006 "cited as possessive with respect to the title."
dongsheng@627 1007 msgstr ""
dongsheng@627 1008
dongsheng@627 1009 #. type: Content of: <book><appendix><sect1><title>
dongsheng@627 1010 #: ../en/appD-license.xml:49
dongsheng@627 1011 msgid "Copyright"
dongsheng@627 1012 msgstr ""
dongsheng@627 1013
dongsheng@627 1014 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 1015 #: ../en/appD-license.xml:51
dongsheng@627 1016 msgid ""
dongsheng@627 1017 "The copyright to each Open Publication is owned by its author(s) or designee."
dongsheng@627 1018 msgstr ""
dongsheng@627 1019
dongsheng@627 1020 #. type: Content of: <book><appendix><sect1><title>
dongsheng@627 1021 #: ../en/appD-license.xml:56
dongsheng@627 1022 msgid "Scope of license"
dongsheng@627 1023 msgstr ""
dongsheng@627 1024
dongsheng@627 1025 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 1026 #: ../en/appD-license.xml:58
dongsheng@627 1027 msgid ""
dongsheng@627 1028 "The following license terms apply to all Open Publication works, unless "
dongsheng@627 1029 "otherwise explicitly stated in the document."
dongsheng@627 1030 msgstr ""
dongsheng@627 1031
dongsheng@627 1032 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 1033 #: ../en/appD-license.xml:62
dongsheng@627 1034 msgid ""
dongsheng@627 1035 "Mere aggregation of Open Publication works or a portion of an Open "
dongsheng@627 1036 "Publication work with other works or programs on the same media shall not "
dongsheng@627 1037 "cause this license to apply to those other works. The aggregate work shall "
dongsheng@627 1038 "contain a notice specifying the inclusion of the Open Publication material "
dongsheng@627 1039 "and appropriate copyright notice."
dongsheng@627 1040 msgstr ""
dongsheng@627 1041
dongsheng@627 1042 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 1043 #: ../en/appD-license.xml:69
dongsheng@627 1044 msgid ""
dongsheng@627 1045 "<emphasis role=\"bold\">Severability</emphasis>. If any part of this license "
dongsheng@627 1046 "is found to be unenforceable in any jurisdiction, the remaining portions of "
dongsheng@627 1047 "the license remain in force."
dongsheng@627 1048 msgstr ""
dongsheng@627 1049
dongsheng@627 1050 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 1051 #: ../en/appD-license.xml:74
dongsheng@627 1052 msgid ""
dongsheng@627 1053 "<emphasis role=\"bold\">No warranty</emphasis>. Open Publication works are "
dongsheng@627 1054 "licensed and provided <quote>as is</quote> without warranty of any kind, "
dongsheng@627 1055 "express or implied, including, but not limited to, the implied warranties of "
dongsheng@627 1056 "merchantability and fitness for a particular purpose or a warranty of non-"
dongsheng@627 1057 "infringement."
dongsheng@627 1058 msgstr ""
dongsheng@627 1059
dongsheng@627 1060 #. type: Content of: <book><appendix><sect1><title>
dongsheng@627 1061 #: ../en/appD-license.xml:83
dongsheng@627 1062 msgid "Requirements on modified works"
dongsheng@627 1063 msgstr ""
dongsheng@627 1064
dongsheng@627 1065 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 1066 #: ../en/appD-license.xml:85
dongsheng@627 1067 msgid ""
dongsheng@627 1068 "All modified versions of documents covered by this license, including "
dongsheng@627 1069 "translations, anthologies, compilations and partial documents, must meet the "
dongsheng@627 1070 "following requirements:"
dongsheng@627 1071 msgstr ""
dongsheng@627 1072
dongsheng@627 1073 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
dongsheng@627 1074 #: ../en/appD-license.xml:90
dongsheng@627 1075 msgid "The modified version must be labeled as such."
dongsheng@627 1076 msgstr ""
dongsheng@627 1077
dongsheng@627 1078 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
dongsheng@627 1079 #: ../en/appD-license.xml:93
dongsheng@627 1080 msgid ""
dongsheng@627 1081 "The person making the modifications must be identified and the modifications "
dongsheng@627 1082 "dated."
dongsheng@627 1083 msgstr ""
dongsheng@627 1084
dongsheng@627 1085 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
dongsheng@627 1086 #: ../en/appD-license.xml:96
dongsheng@627 1087 msgid ""
dongsheng@627 1088 "Acknowledgement of the original author and publisher if applicable must be "
dongsheng@627 1089 "retained according to normal academic citation practices."
dongsheng@627 1090 msgstr ""
dongsheng@627 1091
dongsheng@627 1092 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
dongsheng@627 1093 #: ../en/appD-license.xml:100
dongsheng@627 1094 msgid "The location of the original unmodified document must be identified."
dongsheng@627 1095 msgstr ""
dongsheng@627 1096
dongsheng@627 1097 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
dongsheng@627 1098 #: ../en/appD-license.xml:103
dongsheng@627 1099 msgid ""
dongsheng@627 1100 "The original author's (or authors') name(s) may not be used to assert or "
dongsheng@627 1101 "imply endorsement of the resulting document without the original author's (or "
dongsheng@627 1102 "authors') permission."
dongsheng@627 1103 msgstr ""
dongsheng@627 1104
dongsheng@627 1105 #. type: Content of: <book><appendix><sect1><title>
dongsheng@627 1106 #: ../en/appD-license.xml:111
dongsheng@627 1107 msgid "Good-practice recommendations"
dongsheng@627 1108 msgstr ""
dongsheng@627 1109
dongsheng@627 1110 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 1111 #: ../en/appD-license.xml:113
dongsheng@627 1112 msgid ""
dongsheng@627 1113 "In addition to the requirements of this license, it is requested from and "
dongsheng@627 1114 "strongly recommended of redistributors that:"
dongsheng@627 1115 msgstr ""
dongsheng@627 1116
dongsheng@627 1117 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
dongsheng@627 1118 #: ../en/appD-license.xml:118
dongsheng@627 1119 msgid ""
dongsheng@627 1120 "If you are distributing Open Publication works on hardcopy or CD-ROM, you "
dongsheng@627 1121 "provide email notification to the authors of your intent to redistribute at "
dongsheng@627 1122 "least thirty days before your manuscript or media freeze, to give the authors "
dongsheng@627 1123 "time to provide updated documents. This notification should describe "
dongsheng@627 1124 "modifications, if any, made to the document."
dongsheng@627 1125 msgstr ""
dongsheng@627 1126
dongsheng@627 1127 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
dongsheng@627 1128 #: ../en/appD-license.xml:125
dongsheng@627 1129 msgid ""
dongsheng@627 1130 "All substantive modifications (including deletions) be either clearly marked "
dongsheng@627 1131 "up in the document or else described in an attachment to the document."
dongsheng@627 1132 msgstr ""
dongsheng@627 1133
dongsheng@627 1134 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
dongsheng@627 1135 #: ../en/appD-license.xml:129
dongsheng@627 1136 msgid ""
dongsheng@627 1137 "Finally, while it is not mandatory under this license, it is considered good "
dongsheng@627 1138 "form to offer a free copy of any hardcopy and CD-ROM expression of an Open "
dongsheng@627 1139 "Publication-licensed work to its author(s)."
dongsheng@627 1140 msgstr ""
dongsheng@627 1141
dongsheng@627 1142 #. type: Content of: <book><appendix><sect1><title>
dongsheng@627 1143 #: ../en/appD-license.xml:137
dongsheng@627 1144 msgid "License options"
dongsheng@627 1145 msgstr ""
dongsheng@627 1146
dongsheng@627 1147 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 1148 #: ../en/appD-license.xml:139
dongsheng@627 1149 msgid ""
dongsheng@627 1150 "The author(s) and/or publisher of an Open Publication-licensed document may "
dongsheng@627 1151 "elect certain options by appending language to the reference to or copy of "
dongsheng@627 1152 "the license. These options are considered part of the license instance and "
dongsheng@627 1153 "must be included with the license (or its incorporation by reference) in "
dongsheng@627 1154 "derived works."
dongsheng@627 1155 msgstr ""
dongsheng@627 1156
dongsheng@627 1157 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
dongsheng@627 1158 #: ../en/appD-license.xml:147
dongsheng@627 1159 msgid ""
dongsheng@627 1160 "To prohibit distribution of substantively modified versions without the "
dongsheng@627 1161 "explicit permission of the author(s). <quote>Substantive modification</quote> "
dongsheng@627 1162 "is defined as a change to the semantic content of the document, and excludes "
dongsheng@627 1163 "mere changes in format or typographical corrections."
dongsheng@627 1164 msgstr ""
dongsheng@627 1165
dongsheng@627 1166 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
dongsheng@627 1167 #: ../en/appD-license.xml:154
dongsheng@627 1168 msgid ""
dongsheng@627 1169 "To accomplish this, add the phrase <quote>Distribution of substantively "
dongsheng@627 1170 "modified versions of this document is prohibited without the explicit "
dongsheng@627 1171 "permission of the copyright holder.</quote> to the license reference or copy."
dongsheng@627 1172 msgstr ""
dongsheng@627 1173
dongsheng@627 1174 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
dongsheng@627 1175 #: ../en/appD-license.xml:160
dongsheng@627 1176 msgid ""
dongsheng@627 1177 "To prohibit any publication of this work or derivative works in whole or in "
dongsheng@627 1178 "part in standard (paper) book form for commercial purposes is prohibited "
dongsheng@627 1179 "unless prior permission is obtained from the copyright holder."
dongsheng@627 1180 msgstr ""
dongsheng@627 1181
dongsheng@627 1182 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
dongsheng@627 1183 #: ../en/appD-license.xml:165
dongsheng@627 1184 msgid ""
dongsheng@627 1185 "To accomplish this, add the phrase <quote>Distribution of the work or "
dongsheng@627 1186 "derivative of the work in any standard (paper) book form is prohibited unless "
dongsheng@627 1187 "prior permission is obtained from the copyright holder.</quote> to the "
dongsheng@627 1188 "license reference or copy."
dongsheng@627 1189 msgstr ""
dongsheng@627 1190
dongsheng@653 1191 #. type: Content of: <book><preface><title>
dongsheng@653 1192 #: ../en/ch00-preface.xml:5
dongsheng@653 1193 msgid "Preface"
dongsheng@653 1194 msgstr "序言"
dongsheng@653 1195
dongsheng@653 1196 #. type: Content of: <book><preface><sect1><title>
dongsheng@653 1197 #: ../en/ch00-preface.xml:8
dongsheng@653 1198 msgid "Why revision control? Why Mercurial?"
dongsheng@653 1199 msgstr "为什么使用版本控制? 为什么使用 Mercurial?"
dongsheng@653 1200
dongsheng@653 1201 #. type: Content of: <book><preface><sect1><para>
dongsheng@653 1202 #: ../en/ch00-preface.xml:10
dongsheng@653 1203 msgid ""
dongsheng@653 1204 "Revision control is the process of managing multiple versions of a piece of "
dongsheng@653 1205 "information. In its simplest form, this is something that many people do by "
dongsheng@653 1206 "hand: every time you modify a file, save it under a new name that contains a "
dongsheng@653 1207 "number, each one higher than the number of the preceding version."
dongsheng@653 1208 msgstr ""
dongsheng@653 1209
dongsheng@653 1210 #. type: Content of: <book><preface><sect1><para>
dongsheng@653 1211 #: ../en/ch00-preface.xml:16
dongsheng@653 1212 msgid ""
dongsheng@653 1213 "Manually managing multiple versions of even a single file is an error-prone "
dongsheng@653 1214 "task, though, so software tools to help automate this process have long been "
dongsheng@653 1215 "available. The earliest automated revision control tools were intended to "
dongsheng@653 1216 "help a single user to manage revisions of a single file. Over the past few "
dongsheng@653 1217 "decades, the scope of revision control tools has expanded greatly; they now "
dongsheng@653 1218 "manage multiple files, and help multiple people to work together. The best "
dongsheng@653 1219 "modern revision control tools have no problem coping with thousands of people "
dongsheng@653 1220 "working together on projects that consist of hundreds of thousands of files."
dongsheng@653 1221 msgstr ""
dongsheng@653 1222
dongsheng@653 1223 #. type: Content of: <book><preface><sect1><para>
dongsheng@653 1224 #: ../en/ch00-preface.xml:27
dongsheng@653 1225 msgid ""
dongsheng@653 1226 "The arrival of distributed revision control is relatively recent, and so far "
dongsheng@653 1227 "this new field has grown due to people's willingness to explore ill-charted "
dongsheng@653 1228 "territory."
dongsheng@653 1229 msgstr ""
dongsheng@653 1230
dongsheng@653 1231 #. type: Content of: <book><preface><sect1><para>
dongsheng@653 1232 #: ../en/ch00-preface.xml:31
dongsheng@653 1233 msgid ""
dongsheng@653 1234 "I am writing a book about distributed revision control because I believe that "
dongsheng@653 1235 "it is an important subject that deserves a field guide. I chose to write "
dongsheng@653 1236 "about Mercurial because it is the easiest tool to learn the terrain with, and "
dongsheng@653 1237 "yet it scales to the demands of real, challenging environments where many "
dongsheng@653 1238 "other revision control tools buckle."
dongsheng@653 1239 msgstr ""
dongsheng@653 1240
dongsheng@653 1241 #. type: Content of: <book><preface><sect1><sect2><title>
dongsheng@653 1242 #: ../en/ch00-preface.xml:39
dongsheng@653 1243 msgid "Why use revision control?"
dongsheng@653 1244 msgstr "为什么使用版本控制?"
dongsheng@653 1245
dongsheng@653 1246 #. type: Content of: <book><preface><sect1><sect2><para>
dongsheng@653 1247 #: ../en/ch00-preface.xml:41
dongsheng@653 1248 msgid ""
dongsheng@653 1249 "There are a number of reasons why you or your team might want to use an "
dongsheng@653 1250 "automated revision control tool for a project."
dongsheng@653 1251 msgstr ""
dongsheng@653 1252
dongsheng@653 1253 #. type: Content of: <book><preface><sect1><sect2><itemizedlist><listitem><para>
dongsheng@653 1254 #: ../en/ch00-preface.xml:46
dongsheng@653 1255 msgid ""
dongsheng@653 1256 "It will track the history and evolution of your project, so you don't have "
dongsheng@653 1257 "to. For every change, you'll have a log of <emphasis>who</emphasis> made it; "
dongsheng@653 1258 "<emphasis>why</emphasis> they made it; <emphasis>when</emphasis> they made "
dongsheng@653 1259 "it; and <emphasis>what</emphasis> the change was."
dongsheng@653 1260 msgstr ""
dongsheng@653 1261
dongsheng@653 1262 #. type: Content of: <book><preface><sect1><sect2><itemizedlist><listitem><para>
dongsheng@653 1263 #: ../en/ch00-preface.xml:53
dongsheng@653 1264 msgid ""
dongsheng@653 1265 "When you're working with other people, revision control software makes it "
dongsheng@653 1266 "easier for you to collaborate. For example, when people more or less "
dongsheng@653 1267 "simultaneously make potentially incompatible changes, the software will help "
dongsheng@653 1268 "you to identify and resolve those conflicts."
dongsheng@653 1269 msgstr ""
dongsheng@653 1270
dongsheng@653 1271 #. type: Content of: <book><preface><sect1><sect2><itemizedlist><listitem><para>
dongsheng@653 1272 #: ../en/ch00-preface.xml:59
dongsheng@653 1273 msgid ""
dongsheng@653 1274 "It can help you to recover from mistakes. If you make a change that later "
dongsheng@653 1275 "turns out to be in error, you can revert to an earlier version of one or more "
dongsheng@653 1276 "files. In fact, a <emphasis>really</emphasis> good revision control tool "
dongsheng@653 1277 "will even help you to efficiently figure out exactly when a problem was "
songdongsheng@658 1278 "introduced (see <xref linkend=\"sec:undo:bisect\"/> for details)."
dongsheng@653 1279 msgstr ""
dongsheng@653 1280
dongsheng@653 1281 #. type: Content of: <book><preface><sect1><sect2><itemizedlist><listitem><para>
dongsheng@653 1282 #: ../en/ch00-preface.xml:66
dongsheng@653 1283 msgid ""
dongsheng@653 1284 "It will help you to work simultaneously on, and manage the drift between, "
dongsheng@653 1285 "multiple versions of your project."
dongsheng@653 1286 msgstr ""
dongsheng@653 1287
dongsheng@653 1288 #. type: Content of: <book><preface><sect1><sect2><para>
dongsheng@653 1289 #: ../en/ch00-preface.xml:71
dongsheng@653 1290 msgid ""
songdongsheng@668 1291 "Most of these reasons are equally valid&emdash;at least in theory&emdash;"
songdongsheng@668 1292 "whether you're working on a project by yourself, or with a hundred other "
songdongsheng@668 1293 "people."
dongsheng@653 1294 msgstr ""
dongsheng@653 1295
dongsheng@653 1296 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 1297 #: ../en/ch00-preface.xml:76
dongsheng@653 1298 msgid ""
dongsheng@653 1299 "A key question about the practicality of revision control at these two "
dongsheng@653 1300 "different scales (<quote>lone hacker</quote> and <quote>huge team</quote>) is "
dongsheng@653 1301 "how its <emphasis>benefits</emphasis> compare to its <emphasis>costs</"
dongsheng@653 1302 "emphasis>. A revision control tool that's difficult to understand or use is "
dongsheng@653 1303 "going to impose a high cost."
dongsheng@653 1304 msgstr ""
dongsheng@653 1305
dongsheng@653 1306 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 1307 #: ../en/ch00-preface.xml:84
dongsheng@653 1308 msgid ""
dongsheng@653 1309 "A five-hundred-person project is likely to collapse under its own weight "
dongsheng@653 1310 "almost immediately without a revision control tool and process. In this case, "
dongsheng@653 1311 "the cost of using revision control might hardly seem worth considering, since "
dongsheng@653 1312 "<emphasis>without</emphasis> it, failure is almost guaranteed."
dongsheng@653 1313 msgstr ""
dongsheng@653 1314
dongsheng@653 1315 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 1316 #: ../en/ch00-preface.xml:91
dongsheng@653 1317 msgid ""
dongsheng@653 1318 "On the other hand, a one-person <quote>quick hack</quote> might seem like a "
dongsheng@653 1319 "poor place to use a revision control tool, because surely the cost of using "
dongsheng@653 1320 "one must be close to the overall cost of the project. Right?"
dongsheng@653 1321 msgstr ""
dongsheng@653 1322
dongsheng@653 1323 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 1324 #: ../en/ch00-preface.xml:96
dongsheng@653 1325 msgid ""
dongsheng@653 1326 "Mercurial uniquely supports <emphasis>both</emphasis> of these scales of "
dongsheng@653 1327 "development. You can learn the basics in just a few minutes, and due to its "
dongsheng@653 1328 "low overhead, you can apply revision control to the smallest of projects with "
dongsheng@653 1329 "ease. Its simplicity means you won't have a lot of abstruse concepts or "
dongsheng@653 1330 "command sequences competing for mental space with whatever you're "
dongsheng@653 1331 "<emphasis>really</emphasis> trying to do. At the same time, Mercurial's high "
dongsheng@653 1332 "performance and peer-to-peer nature let you scale painlessly to handle large "
dongsheng@653 1333 "projects."
dongsheng@653 1334 msgstr ""
dongsheng@653 1335
dongsheng@653 1336 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 1337 #: ../en/ch00-preface.xml:106
dongsheng@653 1338 msgid ""
dongsheng@653 1339 "No revision control tool can rescue a poorly run project, but a good choice "
dongsheng@653 1340 "of tools can make a huge difference to the fluidity with which you can work "
dongsheng@653 1341 "on a project."
dongsheng@653 1342 msgstr ""
dongsheng@653 1343
dongsheng@653 1344 #. type: Content of: <book><preface><sect1><sect2><title>
songdongsheng@667 1345 #: ../en/ch00-preface.xml:113
dongsheng@653 1346 msgid "The many names of revision control"
dongsheng@653 1347 msgstr "版本控制的别名"
dongsheng@653 1348
dongsheng@653 1349 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 1350 #: ../en/ch00-preface.xml:115
dongsheng@653 1351 msgid ""
dongsheng@653 1352 "Revision control is a diverse field, so much so that it is referred to by "
dongsheng@653 1353 "many names and acronyms. Here are a few of the more common variations you'll "
dongsheng@653 1354 "encounter:"
dongsheng@653 1355 msgstr ""
dongsheng@653 1356
dongsheng@653 1357 #. type: Content of: <book><preface><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@667 1358 #: ../en/ch00-preface.xml:119
dongsheng@653 1359 msgid "Revision control (RCS)"
dongsheng@653 1360 msgstr "版本控制(RCS)"
dongsheng@653 1361
dongsheng@653 1362 #. type: Content of: <book><preface><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@667 1363 #: ../en/ch00-preface.xml:120
dongsheng@653 1364 msgid "Software configuration management (SCM), or configuration management"
dongsheng@653 1365 msgstr "软件配置管理(SCM),或配置管理"
dongsheng@653 1366
dongsheng@653 1367 #. type: Content of: <book><preface><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@667 1368 #: ../en/ch00-preface.xml:122
dongsheng@653 1369 msgid "Source code management"
dongsheng@653 1370 msgstr "源代码管理"
dongsheng@653 1371
dongsheng@653 1372 #. type: Content of: <book><preface><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@667 1373 #: ../en/ch00-preface.xml:123
dongsheng@653 1374 msgid "Source code control, or source control"
dongsheng@653 1375 msgstr "源代码控制,或源控制"
dongsheng@653 1376
dongsheng@653 1377 #. type: Content of: <book><preface><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@667 1378 #: ../en/ch00-preface.xml:125
dongsheng@653 1379 msgid "Version control (VCS)"
dongsheng@653 1380 msgstr "版本控制(VCS)"
dongsheng@653 1381
dongsheng@653 1382 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 1383 #: ../en/ch00-preface.xml:127
dongsheng@653 1384 msgid ""
dongsheng@653 1385 "Some people claim that these terms actually have different meanings, but in "
dongsheng@653 1386 "practice they overlap so much that there's no agreed or even useful way to "
dongsheng@653 1387 "tease them apart."
dongsheng@653 1388 msgstr ""
dongsheng@653 1389
dongsheng@653 1390 #. type: Content of: <book><preface><sect1><title>
songdongsheng@667 1391 #: ../en/ch00-preface.xml:135
dongsheng@653 1392 msgid "This book is a work in progress"
dongsheng@653 1393 msgstr "本书正在编写中"
dongsheng@653 1394
dongsheng@653 1395 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 1396 #: ../en/ch00-preface.xml:137
dongsheng@653 1397 msgid ""
dongsheng@653 1398 "I am releasing this book while I am still writing it, in the hope that it "
dongsheng@653 1399 "will prove useful to others. I am writing under an open license in the hope "
dongsheng@653 1400 "that you, my readers, will contribute feedback and perhaps content of your "
dongsheng@653 1401 "own."
dongsheng@653 1402 msgstr ""
dongsheng@653 1403
dongsheng@653 1404 #. type: Content of: <book><preface><sect1><title>
songdongsheng@667 1405 #: ../en/ch00-preface.xml:144
dongsheng@653 1406 msgid "About the examples in this book"
dongsheng@653 1407 msgstr "本书的例子"
dongsheng@653 1408
dongsheng@653 1409 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 1410 #: ../en/ch00-preface.xml:146
dongsheng@653 1411 msgid ""
dongsheng@653 1412 "This book takes an unusual approach to code samples. Every example is "
songdongsheng@668 1413 "<quote>live</quote>&emdash;each one is actually the result of a shell script "
songdongsheng@668 1414 "that executes the Mercurial commands you see. Every time an image of the "
songdongsheng@668 1415 "book is built from its sources, all the example scripts are automatically "
songdongsheng@668 1416 "run, and their current results compared against their expected results."
dongsheng@653 1417 msgstr ""
dongsheng@653 1418
dongsheng@653 1419 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 1420 #: ../en/ch00-preface.xml:153
dongsheng@653 1421 msgid ""
dongsheng@653 1422 "The advantage of this approach is that the examples are always accurate; they "
songdongsheng@710 1423 "describe <emphasis>exactly</emphasis> the behavior of the version of "
dongsheng@653 1424 "Mercurial that's mentioned at the front of the book. If I update the version "
dongsheng@653 1425 "of Mercurial that I'm documenting, and the output of some command changes, "
dongsheng@653 1426 "the build fails."
dongsheng@653 1427 msgstr ""
dongsheng@653 1428
dongsheng@653 1429 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 1430 #: ../en/ch00-preface.xml:160
dongsheng@653 1431 msgid ""
dongsheng@653 1432 "There is a small disadvantage to this approach, which is that the dates and "
dongsheng@653 1433 "times you'll see in examples tend to be <quote>squashed</quote> together in a "
dongsheng@653 1434 "way that they wouldn't be if the same commands were being typed by a human. "
dongsheng@653 1435 "Where a human can issue no more than one command every few seconds, with any "
dongsheng@653 1436 "resulting timestamps correspondingly spread out, my automated example scripts "
dongsheng@653 1437 "run many commands in one second."
dongsheng@653 1438 msgstr ""
dongsheng@653 1439
dongsheng@653 1440 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 1441 #: ../en/ch00-preface.xml:168
dongsheng@653 1442 msgid ""
dongsheng@653 1443 "As an instance of this, several consecutive commits in an example can show up "
dongsheng@653 1444 "as having occurred during the same second. You can see this occur in the "
songdongsheng@658 1445 "<literal role=\"hg-ext\">bisect</literal> example in <xref linkend=\"sec:undo:"
songdongsheng@658 1446 "bisect\"/>, for instance."
dongsheng@653 1447 msgstr ""
dongsheng@653 1448
dongsheng@653 1449 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 1450 #: ../en/ch00-preface.xml:174
dongsheng@653 1451 msgid ""
dongsheng@653 1452 "So when you're reading examples, don't place too much weight on the dates or "
dongsheng@653 1453 "times you see in the output of commands. But <emphasis>do</emphasis> be "
songdongsheng@710 1454 "confident that the behavior you're seeing is consistent and reproducible."
dongsheng@653 1455 msgstr ""
dongsheng@653 1456
dongsheng@653 1457 #. type: Content of: <book><preface><sect1><title>
songdongsheng@667 1458 #: ../en/ch00-preface.xml:182
dongsheng@653 1459 msgid "Trends in the field"
dongsheng@653 1460 msgstr "版本控制的发展趋势"
dongsheng@653 1461
dongsheng@653 1462 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 1463 #: ../en/ch00-preface.xml:184
dongsheng@653 1464 msgid ""
dongsheng@653 1465 "There has been an unmistakable trend in the development and use of revision "
dongsheng@653 1466 "control tools over the past four decades, as people have become familiar with "
dongsheng@653 1467 "the capabilities of their tools and constrained by their limitations."
dongsheng@653 1468 msgstr ""
dongsheng@653 1469
dongsheng@653 1470 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 1471 #: ../en/ch00-preface.xml:189
dongsheng@653 1472 msgid ""
dongsheng@653 1473 "The first generation began by managing single files on individual computers. "
dongsheng@653 1474 "Although these tools represented a huge advance over ad-hoc manual revision "
dongsheng@653 1475 "control, their locking model and reliance on a single computer limited them "
dongsheng@653 1476 "to small, tightly-knit teams."
dongsheng@653 1477 msgstr ""
dongsheng@653 1478
dongsheng@653 1479 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 1480 #: ../en/ch00-preface.xml:195
dongsheng@653 1481 msgid ""
dongsheng@653 1482 "The second generation loosened these constraints by moving to network-"
dongsheng@653 1483 "centered architectures, and managing entire projects at a time. As projects "
dongsheng@653 1484 "grew larger, they ran into new problems. With clients needing to talk to "
dongsheng@653 1485 "servers very frequently, server scaling became an issue for large projects. "
dongsheng@653 1486 "An unreliable network connection could prevent remote users from being able "
dongsheng@653 1487 "to talk to the server at all. As open source projects started making read-"
dongsheng@653 1488 "only access available anonymously to anyone, people without commit privileges "
dongsheng@653 1489 "found that they could not use the tools to interact with a project in a "
dongsheng@653 1490 "natural way, as they could not record their changes."
dongsheng@653 1491 msgstr ""
dongsheng@653 1492
dongsheng@653 1493 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 1494 #: ../en/ch00-preface.xml:207
dongsheng@653 1495 msgid ""
dongsheng@653 1496 "The current generation of revision control tools is peer-to-peer in nature. "
dongsheng@653 1497 "All of these systems have dropped the dependency on a single central server, "
dongsheng@653 1498 "and allow people to distribute their revision control data to where it's "
dongsheng@653 1499 "actually needed. Collaboration over the Internet has moved from constrained "
dongsheng@653 1500 "by technology to a matter of choice and consensus. Modern tools can operate "
dongsheng@653 1501 "offline indefinitely and autonomously, with a network connection only needed "
dongsheng@653 1502 "when syncing changes with another repository."
dongsheng@653 1503 msgstr ""
dongsheng@653 1504
dongsheng@653 1505 #. type: Content of: <book><preface><sect1><title>
songdongsheng@667 1506 #: ../en/ch00-preface.xml:219
dongsheng@653 1507 msgid "A few of the advantages of distributed revision control"
dongsheng@653 1508 msgstr "分布版本控制的优点"
dongsheng@653 1509
dongsheng@653 1510 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 1511 #: ../en/ch00-preface.xml:222
dongsheng@653 1512 msgid ""
dongsheng@653 1513 "Even though distributed revision control tools have for several years been as "
dongsheng@653 1514 "robust and usable as their previous-generation counterparts, people using "
dongsheng@653 1515 "older tools have not yet necessarily woken up to their advantages. There are "
dongsheng@653 1516 "a number of ways in which distributed tools shine relative to centralised "
dongsheng@653 1517 "ones."
dongsheng@653 1518 msgstr ""
dongsheng@653 1519
dongsheng@653 1520 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 1521 #: ../en/ch00-preface.xml:229
dongsheng@653 1522 msgid ""
dongsheng@653 1523 "For an individual developer, distributed tools are almost always much faster "
dongsheng@653 1524 "than centralised tools. This is for a simple reason: a centralised tool "
dongsheng@653 1525 "needs to talk over the network for many common operations, because most "
dongsheng@653 1526 "metadata is stored in a single copy on the central server. A distributed "
dongsheng@653 1527 "tool stores all of its metadata locally. All else being equal, talking over "
dongsheng@653 1528 "the network adds overhead to a centralised tool. Don't underestimate the "
dongsheng@653 1529 "value of a snappy, responsive tool: you're going to spend a lot of time "
dongsheng@653 1530 "interacting with your revision control software."
dongsheng@653 1531 msgstr ""
dongsheng@653 1532
dongsheng@653 1533 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 1534 #: ../en/ch00-preface.xml:240
dongsheng@653 1535 msgid ""
dongsheng@653 1536 "Distributed tools are indifferent to the vagaries of your server "
dongsheng@653 1537 "infrastructure, again because they replicate metadata to so many locations. "
dongsheng@653 1538 "If you use a centralised system and your server catches fire, you'd better "
dongsheng@653 1539 "hope that your backup media are reliable, and that your last backup was "
dongsheng@653 1540 "recent and actually worked. With a distributed tool, you have many backups "
dongsheng@653 1541 "available on every contributor's computer."
dongsheng@653 1542 msgstr ""
dongsheng@653 1543
dongsheng@653 1544 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 1545 #: ../en/ch00-preface.xml:248
dongsheng@653 1546 msgid ""
dongsheng@653 1547 "The reliability of your network will affect distributed tools far less than "
dongsheng@653 1548 "it will centralised tools. You can't even use a centralised tool without a "
dongsheng@653 1549 "network connection, except for a few highly constrained commands. With a "
dongsheng@653 1550 "distributed tool, if your network connection goes down while you're working, "
dongsheng@653 1551 "you may not even notice. The only thing you won't be able to do is talk to "
dongsheng@653 1552 "repositories on other computers, something that is relatively rare compared "
dongsheng@653 1553 "with local operations. If you have a far-flung team of collaborators, this "
dongsheng@653 1554 "may be significant."
dongsheng@653 1555 msgstr ""
dongsheng@653 1556
dongsheng@653 1557 #. type: Content of: <book><preface><sect1><sect2><title>
songdongsheng@667 1558 #: ../en/ch00-preface.xml:259
dongsheng@653 1559 msgid "Advantages for open source projects"
dongsheng@653 1560 msgstr "开源项目的优点"
dongsheng@653 1561
dongsheng@653 1562 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 1563 #: ../en/ch00-preface.xml:261
dongsheng@653 1564 msgid ""
dongsheng@653 1565 "If you take a shine to an open source project and decide that you would like "
dongsheng@653 1566 "to start hacking on it, and that project uses a distributed revision control "
dongsheng@653 1567 "tool, you are at once a peer with the people who consider themselves the "
dongsheng@653 1568 "<quote>core</quote> of that project. If they publish their repositories, you "
dongsheng@653 1569 "can immediately copy their project history, start making changes, and record "
dongsheng@653 1570 "your work, using the same tools in the same ways as insiders. By contrast, "
dongsheng@653 1571 "with a centralised tool, you must use the software in a <quote>read only</"
dongsheng@653 1572 "quote> mode unless someone grants you permission to commit changes to their "
dongsheng@653 1573 "central server. Until then, you won't be able to record changes, and your "
dongsheng@653 1574 "local modifications will be at risk of corruption any time you try to update "
dongsheng@653 1575 "your client's view of the repository."
dongsheng@653 1576 msgstr ""
dongsheng@653 1577
dongsheng@653 1578 #. type: Content of: <book><preface><sect1><sect2><sect3><title>
songdongsheng@667 1579 #: ../en/ch00-preface.xml:277
dongsheng@653 1580 msgid "The forking non-problem"
dongsheng@660 1581 msgstr "分叉不是问题"
dongsheng@653 1582
dongsheng@653 1583 #. type: Content of: <book><preface><sect1><sect2><sect3><para>
songdongsheng@667 1584 #: ../en/ch00-preface.xml:279
dongsheng@653 1585 msgid ""
dongsheng@653 1586 "It has been suggested that distributed revision control tools pose some sort "
dongsheng@653 1587 "of risk to open source projects because they make it easy to <quote>fork</"
dongsheng@653 1588 "quote> the development of a project. A fork happens when there are "
dongsheng@653 1589 "differences in opinion or attitude between groups of developers that cause "
dongsheng@653 1590 "them to decide that they can't work together any longer. Each side takes a "
dongsheng@653 1591 "more or less complete copy of the project's source code, and goes off in its "
dongsheng@653 1592 "own direction."
dongsheng@653 1593 msgstr ""
dongsheng@653 1594
dongsheng@653 1595 #. type: Content of: <book><preface><sect1><sect2><sect3><para>
songdongsheng@667 1596 #: ../en/ch00-preface.xml:289
dongsheng@653 1597 msgid ""
dongsheng@653 1598 "Sometimes the camps in a fork decide to reconcile their differences. With a "
dongsheng@653 1599 "centralised revision control system, the <emphasis>technical</emphasis> "
dongsheng@653 1600 "process of reconciliation is painful, and has to be performed largely by "
dongsheng@653 1601 "hand. You have to decide whose revision history is going to <quote>win</"
dongsheng@653 1602 "quote>, and graft the other team's changes into the tree somehow. This "
dongsheng@653 1603 "usually loses some or all of one side's revision history."
dongsheng@653 1604 msgstr ""
dongsheng@653 1605
dongsheng@653 1606 #. type: Content of: <book><preface><sect1><sect2><sect3><para>
songdongsheng@667 1607 #: ../en/ch00-preface.xml:298
dongsheng@653 1608 msgid ""
dongsheng@653 1609 "What distributed tools do with respect to forking is they make forking the "
dongsheng@653 1610 "<emphasis>only</emphasis> way to develop a project. Every single change that "
dongsheng@653 1611 "you make is potentially a fork point. The great strength of this approach is "
dongsheng@653 1612 "that a distributed revision control tool has to be really good at "
dongsheng@653 1613 "<emphasis>merging</emphasis> forks, because forks are absolutely fundamental: "
dongsheng@653 1614 "they happen all the time."
dongsheng@653 1615 msgstr ""
dongsheng@653 1616
dongsheng@653 1617 #. type: Content of: <book><preface><sect1><sect2><sect3><para>
songdongsheng@667 1618 #: ../en/ch00-preface.xml:307
dongsheng@653 1619 msgid ""
dongsheng@653 1620 "If every piece of work that everybody does, all the time, is framed in terms "
dongsheng@653 1621 "of forking and merging, then what the open source world refers to as a "
dongsheng@653 1622 "<quote>fork</quote> becomes <emphasis>purely</emphasis> a social issue. If "
dongsheng@653 1623 "anything, distributed tools <emphasis>lower</emphasis> the likelihood of a "
dongsheng@653 1624 "fork:"
dongsheng@653 1625 msgstr ""
dongsheng@653 1626
dongsheng@653 1627 #. type: Content of: <book><preface><sect1><sect2><sect3><itemizedlist><listitem><para>
songdongsheng@667 1628 #: ../en/ch00-preface.xml:314
dongsheng@653 1629 msgid ""
dongsheng@653 1630 "They eliminate the social distinction that centralised tools impose: that "
dongsheng@653 1631 "between insiders (people with commit access) and outsiders (people without)."
dongsheng@653 1632 msgstr ""
dongsheng@653 1633
dongsheng@653 1634 #. type: Content of: <book><preface><sect1><sect2><sect3><itemizedlist><listitem><para>
songdongsheng@667 1635 #: ../en/ch00-preface.xml:318
dongsheng@653 1636 msgid ""
dongsheng@653 1637 "They make it easier to reconcile after a social fork, because all that's "
dongsheng@653 1638 "involved from the perspective of the revision control software is just "
dongsheng@653 1639 "another merge."
dongsheng@653 1640 msgstr ""
dongsheng@653 1641
dongsheng@653 1642 #. type: Content of: <book><preface><sect1><sect2><sect3><para>
songdongsheng@667 1643 #: ../en/ch00-preface.xml:323
dongsheng@653 1644 msgid ""
dongsheng@653 1645 "Some people resist distributed tools because they want to retain tight "
dongsheng@653 1646 "control over their projects, and they believe that centralised tools give "
dongsheng@653 1647 "them this control. However, if you're of this belief, and you publish your "
dongsheng@653 1648 "CVS or Subversion repositories publicly, there are plenty of tools available "
dongsheng@653 1649 "that can pull out your entire project's history (albeit slowly) and recreate "
dongsheng@653 1650 "it somewhere that you don't control. So while your control in this case is "
dongsheng@653 1651 "illusory, you are forgoing the ability to fluidly collaborate with whatever "
dongsheng@653 1652 "people feel compelled to mirror and fork your history."
dongsheng@653 1653 msgstr ""
dongsheng@653 1654
dongsheng@653 1655 #. type: Content of: <book><preface><sect1><sect2><title>
songdongsheng@667 1656 #: ../en/ch00-preface.xml:338
dongsheng@653 1657 msgid "Advantages for commercial projects"
dongsheng@653 1658 msgstr "商业项目的优点"
dongsheng@653 1659
dongsheng@653 1660 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 1661 #: ../en/ch00-preface.xml:340
dongsheng@653 1662 msgid ""
dongsheng@653 1663 "Many commercial projects are undertaken by teams that are scattered across "
dongsheng@653 1664 "the globe. Contributors who are far from a central server will see slower "
dongsheng@653 1665 "command execution and perhaps less reliability. Commercial revision control "
dongsheng@653 1666 "systems attempt to ameliorate these problems with remote-site replication add-"
dongsheng@653 1667 "ons that are typically expensive to buy and cantankerous to administer. A "
dongsheng@653 1668 "distributed system doesn't suffer from these problems in the first place. "
dongsheng@653 1669 "Better yet, you can easily set up multiple authoritative servers, say one per "
dongsheng@653 1670 "site, so that there's no redundant communication between repositories over "
dongsheng@653 1671 "expensive long-haul network links."
dongsheng@653 1672 msgstr ""
dongsheng@653 1673
dongsheng@653 1674 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 1675 #: ../en/ch00-preface.xml:352
dongsheng@653 1676 msgid ""
dongsheng@653 1677 "Centralised revision control systems tend to have relatively low "
dongsheng@653 1678 "scalability. It's not unusual for an expensive centralised system to fall "
dongsheng@653 1679 "over under the combined load of just a few dozen concurrent users. Once "
dongsheng@653 1680 "again, the typical response tends to be an expensive and clunky replication "
songdongsheng@668 1681 "facility. Since the load on a central server&emdash;if you have one at "
songdongsheng@668 1682 "all&emdash;is many times lower with a distributed tool (because all of the "
songdongsheng@668 1683 "data is replicated everywhere), a single cheap server can handle the needs of "
songdongsheng@668 1684 "a much larger team, and replication to balance load becomes a simple matter "
songdongsheng@668 1685 "of scripting."
dongsheng@653 1686 msgstr ""
dongsheng@653 1687
dongsheng@653 1688 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 1689 #: ../en/ch00-preface.xml:364
dongsheng@653 1690 msgid ""
dongsheng@653 1691 "If you have an employee in the field, troubleshooting a problem at a "
dongsheng@653 1692 "customer's site, they'll benefit from distributed revision control. The tool "
dongsheng@653 1693 "will let them generate custom builds, try different fixes in isolation from "
dongsheng@653 1694 "each other, and search efficiently through history for the sources of bugs "
dongsheng@653 1695 "and regressions in the customer's environment, all without needing to connect "
dongsheng@653 1696 "to your company's network."
dongsheng@653 1697 msgstr ""
dongsheng@653 1698
dongsheng@653 1699 #. type: Content of: <book><preface><sect1><title>
songdongsheng@667 1700 #: ../en/ch00-preface.xml:375
dongsheng@653 1701 msgid "Why choose Mercurial?"
dongsheng@653 1702 msgstr "为什么选择 Mercurial?"
dongsheng@653 1703
dongsheng@653 1704 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 1705 #: ../en/ch00-preface.xml:377
dongsheng@653 1706 msgid ""
dongsheng@653 1707 "Mercurial has a unique set of properties that make it a particularly good "
dongsheng@653 1708 "choice as a revision control system."
dongsheng@653 1709 msgstr ""
dongsheng@653 1710
dongsheng@653 1711 #. type: Content of: <book><preface><sect1><itemizedlist><listitem><para>
songdongsheng@667 1712 #: ../en/ch00-preface.xml:380
dongsheng@653 1713 msgid "It is easy to learn and use."
dongsheng@653 1714 msgstr ""
dongsheng@653 1715
dongsheng@653 1716 #. type: Content of: <book><preface><sect1><itemizedlist><listitem><para>
dongsheng@653 1717 #: ../en/ch00-preface.xml:381
songdongsheng@667 1718 msgid "It is lightweight."
dongsheng@653 1719 msgstr ""
dongsheng@653 1720
dongsheng@653 1721 #. type: Content of: <book><preface><sect1><itemizedlist><listitem><para>
dongsheng@653 1722 #: ../en/ch00-preface.xml:382
songdongsheng@667 1723 msgid "It scales excellently."
songdongsheng@667 1724 msgstr ""
songdongsheng@667 1725
songdongsheng@667 1726 #. type: Content of: <book><preface><sect1><itemizedlist><listitem><para>
songdongsheng@667 1727 #: ../en/ch00-preface.xml:383
dongsheng@653 1728 msgid "It is easy to customise."
dongsheng@653 1729 msgstr ""
dongsheng@653 1730
dongsheng@653 1731 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 1732 #: ../en/ch00-preface.xml:386
dongsheng@653 1733 msgid ""
dongsheng@653 1734 "If you are at all familiar with revision control systems, you should be able "
dongsheng@653 1735 "to get up and running with Mercurial in less than five minutes. Even if not, "
dongsheng@653 1736 "it will take no more than a few minutes longer. Mercurial's command and "
dongsheng@653 1737 "feature sets are generally uniform and consistent, so you can keep track of a "
dongsheng@653 1738 "few general rules instead of a host of exceptions."
dongsheng@653 1739 msgstr ""
dongsheng@653 1740
dongsheng@653 1741 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 1742 #: ../en/ch00-preface.xml:393
dongsheng@653 1743 msgid ""
dongsheng@653 1744 "On a small project, you can start working with Mercurial in moments. Creating "
dongsheng@653 1745 "new changes and branches; transferring changes around (whether locally or "
dongsheng@653 1746 "over a network); and history and status operations are all fast. Mercurial "
dongsheng@653 1747 "attempts to stay nimble and largely out of your way by combining low "
dongsheng@653 1748 "cognitive overhead with blazingly fast operations."
dongsheng@653 1749 msgstr ""
dongsheng@653 1750
dongsheng@653 1751 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 1752 #: ../en/ch00-preface.xml:400
dongsheng@653 1753 msgid ""
dongsheng@653 1754 "The usefulness of Mercurial is not limited to small projects: it is used by "
dongsheng@653 1755 "projects with hundreds to thousands of contributors, each containing tens of "
dongsheng@653 1756 "thousands of files and hundreds of megabytes of source code."
dongsheng@653 1757 msgstr ""
dongsheng@653 1758
dongsheng@653 1759 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 1760 #: ../en/ch00-preface.xml:405
dongsheng@653 1761 msgid ""
dongsheng@653 1762 "If the core functionality of Mercurial is not enough for you, it's easy to "
dongsheng@653 1763 "build on. Mercurial is well suited to scripting tasks, and its clean "
dongsheng@653 1764 "internals and implementation in Python make it easy to add features in the "
dongsheng@653 1765 "form of extensions. There are a number of popular and useful extensions "
dongsheng@653 1766 "already available, ranging from helping to identify bugs to improving "
dongsheng@653 1767 "performance."
dongsheng@653 1768 msgstr ""
dongsheng@653 1769
dongsheng@653 1770 #. type: Content of: <book><preface><sect1><title>
songdongsheng@667 1771 #: ../en/ch00-preface.xml:415
dongsheng@653 1772 msgid "Mercurial compared with other tools"
dongsheng@653 1773 msgstr "Mercurial 与其它工具的比较"
dongsheng@653 1774
dongsheng@653 1775 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 1776 #: ../en/ch00-preface.xml:417
dongsheng@653 1777 msgid ""
dongsheng@653 1778 "Before you read on, please understand that this section necessarily reflects "
dongsheng@653 1779 "my own experiences, interests, and (dare I say it) biases. I have used every "
dongsheng@653 1780 "one of the revision control tools listed below, in most cases for several "
dongsheng@653 1781 "years at a time."
dongsheng@653 1782 msgstr ""
dongsheng@653 1783
dongsheng@653 1784 #. type: Content of: <book><preface><sect1><itemizedlist><listitem><para>
songdongsheng@667 1785 #: ../en/ch00-preface.xml:425 ../en/ch00-preface.xml:636
dongsheng@653 1786 msgid "Subversion"
dongsheng@653 1787 msgstr ""
dongsheng@653 1788
dongsheng@653 1789 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 1790 #: ../en/ch00-preface.xml:427
dongsheng@653 1791 msgid ""
dongsheng@653 1792 "Subversion is a popular revision control tool, developed to replace CVS. It "
dongsheng@653 1793 "has a centralised client/server architecture."
dongsheng@653 1794 msgstr ""
dongsheng@653 1795
dongsheng@653 1796 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 1797 #: ../en/ch00-preface.xml:431
dongsheng@653 1798 msgid ""
dongsheng@653 1799 "Subversion and Mercurial have similarly named commands for performing the "
dongsheng@653 1800 "same operations, so if you're familiar with one, it is easy to learn to use "
dongsheng@653 1801 "the other. Both tools are portable to all popular operating systems."
dongsheng@653 1802 msgstr ""
dongsheng@653 1803
dongsheng@653 1804 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 1805 #: ../en/ch00-preface.xml:436
dongsheng@653 1806 msgid ""
dongsheng@653 1807 "Prior to version 1.5, Subversion had no useful support for merges. At the "
dongsheng@653 1808 "time of writing, its merge tracking capability is new, and known to be <ulink "
dongsheng@653 1809 "url=\"http://svnbook.red-bean.com/nightly/en/svn.branchmerge.advanced."
dongsheng@653 1810 "html#svn.branchmerge.advanced.finalword\">complicated and buggy</ulink>."
dongsheng@653 1811 msgstr ""
dongsheng@653 1812
dongsheng@653 1813 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 1814 #: ../en/ch00-preface.xml:442
dongsheng@653 1815 msgid ""
dongsheng@653 1816 "Mercurial has a substantial performance advantage over Subversion on every "
dongsheng@653 1817 "revision control operation I have benchmarked. I have measured its advantage "
dongsheng@653 1818 "as ranging from a factor of two to a factor of six when compared with "
dongsheng@653 1819 "Subversion 1.4.3's <emphasis>ra_local</emphasis> file store, which is the "
dongsheng@653 1820 "fastest access method available. In more realistic deployments involving a "
dongsheng@653 1821 "network-based store, Subversion will be at a substantially larger "
dongsheng@653 1822 "disadvantage. Because many Subversion commands must talk to the server and "
dongsheng@653 1823 "Subversion does not have useful replication facilities, server capacity and "
dongsheng@653 1824 "network bandwidth become bottlenecks for modestly large projects."
dongsheng@653 1825 msgstr ""
dongsheng@653 1826
dongsheng@653 1827 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 1828 #: ../en/ch00-preface.xml:455
dongsheng@653 1829 msgid ""
dongsheng@653 1830 "Additionally, Subversion incurs substantial storage overhead to avoid network "
dongsheng@653 1831 "transactions for a few common operations, such as finding modified files "
dongsheng@653 1832 "(<literal>status</literal>) and displaying modifications against the current "
dongsheng@653 1833 "revision (<literal>diff</literal>). As a result, a Subversion working copy "
dongsheng@653 1834 "is often the same size as, or larger than, a Mercurial repository and working "
dongsheng@653 1835 "directory, even though the Mercurial repository contains a complete history "
dongsheng@653 1836 "of the project."
dongsheng@653 1837 msgstr ""
dongsheng@653 1838
dongsheng@653 1839 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 1840 #: ../en/ch00-preface.xml:465
dongsheng@653 1841 msgid ""
dongsheng@653 1842 "Subversion is widely supported by third party tools. Mercurial currently "
dongsheng@653 1843 "lags considerably in this area. This gap is closing, however, and indeed "
dongsheng@653 1844 "some of Mercurial's GUI tools now outshine their Subversion equivalents. "
dongsheng@653 1845 "Like Mercurial, Subversion has an excellent user manual."
dongsheng@653 1846 msgstr ""
dongsheng@653 1847
dongsheng@653 1848 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 1849 #: ../en/ch00-preface.xml:471
dongsheng@653 1850 msgid ""
dongsheng@653 1851 "Because Subversion doesn't store revision history on the client, it is well "
dongsheng@653 1852 "suited to managing projects that deal with lots of large, opaque binary "
dongsheng@653 1853 "files. If you check in fifty revisions to an incompressible 10MB file, "
dongsheng@653 1854 "Subversion's client-side space usage stays constant The space used by any "
dongsheng@653 1855 "distributed SCM will grow rapidly in proportion to the number of revisions, "
dongsheng@653 1856 "because the differences between each revision are large."
dongsheng@653 1857 msgstr ""
dongsheng@653 1858
dongsheng@653 1859 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 1860 #: ../en/ch00-preface.xml:480
dongsheng@653 1861 msgid ""
dongsheng@653 1862 "In addition, it's often difficult or, more usually, impossible to merge "
dongsheng@653 1863 "different versions of a binary file. Subversion's ability to let a user lock "
dongsheng@653 1864 "a file, so that they temporarily have the exclusive right to commit changes "
dongsheng@653 1865 "to it, can be a significant advantage to a project where binary files are "
dongsheng@653 1866 "widely used."
dongsheng@653 1867 msgstr ""
dongsheng@653 1868
dongsheng@653 1869 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 1870 #: ../en/ch00-preface.xml:487
dongsheng@653 1871 msgid ""
dongsheng@653 1872 "Mercurial can import revision history from a Subversion repository. It can "
dongsheng@653 1873 "also export revision history to a Subversion repository. This makes it easy "
dongsheng@653 1874 "to <quote>test the waters</quote> and use Mercurial and Subversion in "
dongsheng@653 1875 "parallel before deciding to switch. History conversion is incremental, so "
dongsheng@653 1876 "you can perform an initial conversion, then small additional conversions "
dongsheng@653 1877 "afterwards to bring in new changes."
dongsheng@653 1878 msgstr ""
dongsheng@653 1879
dongsheng@653 1880 #. type: Content of: <book><preface><sect1><itemizedlist><listitem><para>
songdongsheng@667 1881 #: ../en/ch00-preface.xml:499 ../en/ch00-preface.xml:638
dongsheng@653 1882 msgid "Git"
songdongsheng@668 1883 msgstr "Git"
dongsheng@653 1884
dongsheng@653 1885 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 1886 #: ../en/ch00-preface.xml:501
dongsheng@653 1887 msgid ""
dongsheng@653 1888 "Git is a distributed revision control tool that was developed for managing "
dongsheng@653 1889 "the Linux kernel source tree. Like Mercurial, its early design was somewhat "
dongsheng@653 1890 "influenced by Monotone."
dongsheng@653 1891 msgstr ""
dongsheng@653 1892
dongsheng@653 1893 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 1894 #: ../en/ch00-preface.xml:506
dongsheng@653 1895 msgid ""
dongsheng@653 1896 "Git has a very large command set, with version 1.5.0 providing 139 individual "
dongsheng@653 1897 "commands. It has something of a reputation for being difficult to learn. "
dongsheng@653 1898 "Compared to Git, Mercurial has a strong focus on simplicity."
dongsheng@653 1899 msgstr ""
dongsheng@653 1900
dongsheng@653 1901 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 1902 #: ../en/ch00-preface.xml:511
dongsheng@653 1903 msgid ""
dongsheng@653 1904 "In terms of performance, Git is extremely fast. In several cases, it is "
dongsheng@653 1905 "faster than Mercurial, at least on Linux, while Mercurial performs better on "
dongsheng@653 1906 "other operations. However, on Windows, the performance and general level of "
dongsheng@653 1907 "support that Git provides is, at the time of writing, far behind that of "
dongsheng@653 1908 "Mercurial."
dongsheng@653 1909 msgstr ""
dongsheng@653 1910
dongsheng@653 1911 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 1912 #: ../en/ch00-preface.xml:518
dongsheng@653 1913 msgid ""
dongsheng@653 1914 "While a Mercurial repository needs no maintenance, a Git repository requires "
dongsheng@653 1915 "frequent manual <quote>repacks</quote> of its metadata. Without these, "
dongsheng@653 1916 "performance degrades, while space usage grows rapidly. A server that "
dongsheng@653 1917 "contains many Git repositories that are not rigorously and frequently "
dongsheng@653 1918 "repacked will become heavily disk-bound during backups, and there have been "
dongsheng@653 1919 "instances of daily backups taking far longer than 24 hours as a result. A "
dongsheng@653 1920 "freshly packed Git repository is slightly smaller than a Mercurial "
dongsheng@653 1921 "repository, but an unpacked repository is several orders of magnitude larger."
dongsheng@653 1922 msgstr ""
dongsheng@653 1923
dongsheng@653 1924 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 1925 #: ../en/ch00-preface.xml:529
dongsheng@653 1926 msgid ""
dongsheng@653 1927 "The core of Git is written in C. Many Git commands are implemented as shell "
dongsheng@653 1928 "or Perl scripts, and the quality of these scripts varies widely. I have "
dongsheng@653 1929 "encountered several instances where scripts charged along blindly in the "
dongsheng@653 1930 "presence of errors that should have been fatal."
dongsheng@653 1931 msgstr ""
dongsheng@653 1932
dongsheng@653 1933 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 1934 #: ../en/ch00-preface.xml:535
dongsheng@653 1935 msgid "Mercurial can import revision history from a Git repository."
dongsheng@653 1936 msgstr ""
dongsheng@653 1937
dongsheng@653 1938 #. type: Content of: <book><preface><sect1><itemizedlist><listitem><para>
songdongsheng@667 1939 #: ../en/ch00-preface.xml:541 ../en/ch00-preface.xml:637
dongsheng@653 1940 msgid "CVS"
songdongsheng@668 1941 msgstr "CVS"
dongsheng@653 1942
dongsheng@653 1943 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 1944 #: ../en/ch00-preface.xml:543
dongsheng@653 1945 msgid ""
dongsheng@653 1946 "CVS is probably the most widely used revision control tool in the world. Due "
dongsheng@653 1947 "to its age and internal untidiness, it has been only lightly maintained for "
dongsheng@653 1948 "many years."
dongsheng@653 1949 msgstr ""
dongsheng@653 1950
dongsheng@653 1951 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 1952 #: ../en/ch00-preface.xml:547
dongsheng@653 1953 msgid ""
dongsheng@653 1954 "It has a centralised client/server architecture. It does not group related "
dongsheng@653 1955 "file changes into atomic commits, making it easy for people to <quote>break "
dongsheng@653 1956 "the build</quote>: one person can successfully commit part of a change and "
dongsheng@653 1957 "then be blocked by the need for a merge, causing other people to see only a "
dongsheng@653 1958 "portion of the work they intended to do. This also affects how you work with "
dongsheng@653 1959 "project history. If you want to see all of the modifications someone made as "
dongsheng@653 1960 "part of a task, you will need to manually inspect the descriptions and "
dongsheng@653 1961 "timestamps of the changes made to each file involved (if you even know what "
dongsheng@653 1962 "those files were)."
dongsheng@653 1963 msgstr ""
dongsheng@653 1964
dongsheng@653 1965 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 1966 #: ../en/ch00-preface.xml:559
dongsheng@653 1967 msgid ""
dongsheng@653 1968 "CVS has a muddled notion of tags and branches that I will not attempt to even "
dongsheng@653 1969 "describe. It does not support renaming of files or directories well, making "
dongsheng@653 1970 "it easy to corrupt a repository. It has almost no internal consistency "
dongsheng@653 1971 "checking capabilities, so it is usually not even possible to tell whether or "
dongsheng@653 1972 "how a repository is corrupt. I would not recommend CVS for any project, "
dongsheng@653 1973 "existing or new."
dongsheng@653 1974 msgstr ""
dongsheng@653 1975
dongsheng@653 1976 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 1977 #: ../en/ch00-preface.xml:567
dongsheng@653 1978 msgid ""
dongsheng@653 1979 "Mercurial can import CVS revision history. However, there are a few caveats "
dongsheng@653 1980 "that apply; these are true of every other revision control tool's CVS "
dongsheng@653 1981 "importer, too. Due to CVS's lack of atomic changes and unversioned "
dongsheng@653 1982 "filesystem hierarchy, it is not possible to reconstruct CVS history "
dongsheng@653 1983 "completely accurately; some guesswork is involved, and renames will usually "
dongsheng@653 1984 "not show up. Because a lot of advanced CVS administration has to be done by "
dongsheng@653 1985 "hand and is hence error-prone, it's common for CVS importers to run into "
dongsheng@653 1986 "multiple problems with corrupted repositories (completely bogus revision "
dongsheng@653 1987 "timestamps and files that have remained locked for over a decade are just two "
dongsheng@653 1988 "of the less interesting problems I can recall from personal experience)."
dongsheng@653 1989 msgstr ""
dongsheng@653 1990
dongsheng@653 1991 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 1992 #: ../en/ch00-preface.xml:581
dongsheng@653 1993 msgid "Mercurial can import revision history from a CVS repository."
dongsheng@653 1994 msgstr ""
dongsheng@653 1995
dongsheng@653 1996 #. type: Content of: <book><preface><sect1><sect2><title>
songdongsheng@667 1997 #: ../en/ch00-preface.xml:587
dongsheng@653 1998 msgid "Commercial tools"
dongsheng@653 1999 msgstr "商业工具"
dongsheng@653 2000
dongsheng@653 2001 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 2002 #: ../en/ch00-preface.xml:589
dongsheng@653 2003 msgid ""
dongsheng@653 2004 "Perforce has a centralised client/server architecture, with no client-side "
dongsheng@653 2005 "caching of any data. Unlike modern revision control tools, Perforce requires "
dongsheng@653 2006 "that a user run a command to inform the server about every file they intend "
dongsheng@653 2007 "to edit."
dongsheng@653 2008 msgstr ""
dongsheng@653 2009
dongsheng@653 2010 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 2011 #: ../en/ch00-preface.xml:595
dongsheng@653 2012 msgid ""
dongsheng@653 2013 "The performance of Perforce is quite good for small teams, but it falls off "
dongsheng@653 2014 "rapidly as the number of users grows beyond a few dozen. Modestly large "
dongsheng@653 2015 "Perforce installations require the deployment of proxies to cope with the "
dongsheng@653 2016 "load their users generate."
dongsheng@653 2017 msgstr ""
dongsheng@653 2018
dongsheng@653 2019 #. type: Content of: <book><preface><sect1><sect2><title>
songdongsheng@667 2020 #: ../en/ch00-preface.xml:604
dongsheng@653 2021 msgid "Choosing a revision control tool"
dongsheng@653 2022 msgstr "选择版本控制工具"
dongsheng@653 2023
dongsheng@653 2024 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 2025 #: ../en/ch00-preface.xml:606
dongsheng@653 2026 msgid ""
dongsheng@653 2027 "With the exception of CVS, all of the tools listed above have unique "
dongsheng@653 2028 "strengths that suit them to particular styles of work. There is no single "
dongsheng@653 2029 "revision control tool that is best in all situations."
dongsheng@653 2030 msgstr ""
dongsheng@653 2031
dongsheng@653 2032 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 2033 #: ../en/ch00-preface.xml:611
dongsheng@653 2034 msgid ""
dongsheng@653 2035 "As an example, Subversion is a good choice for working with frequently edited "
dongsheng@653 2036 "binary files, due to its centralised nature and support for file locking."
dongsheng@653 2037 msgstr ""
dongsheng@653 2038
dongsheng@653 2039 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 2040 #: ../en/ch00-preface.xml:615
dongsheng@653 2041 msgid ""
dongsheng@653 2042 "I personally find Mercurial's properties of simplicity, performance, and good "
dongsheng@653 2043 "merge support to be a compelling combination that has served me well for "
dongsheng@653 2044 "several years."
dongsheng@653 2045 msgstr ""
dongsheng@653 2046
dongsheng@653 2047 #. type: Content of: <book><preface><sect1><title>
songdongsheng@667 2048 #: ../en/ch00-preface.xml:623
dongsheng@653 2049 msgid "Switching from another tool to Mercurial"
dongsheng@653 2050 msgstr "从其它工具切换到 Mercurial"
dongsheng@653 2051
dongsheng@653 2052 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 2053 #: ../en/ch00-preface.xml:625
dongsheng@653 2054 msgid ""
dongsheng@653 2055 "Mercurial is bundled with an extension named <literal role=\"hg-ext"
dongsheng@653 2056 "\">convert</literal>, which can incrementally import revision history from "
dongsheng@653 2057 "several other revision control tools. By <quote>incremental</quote>, I mean "
dongsheng@653 2058 "that you can convert all of a project's history to date in one go, then rerun "
dongsheng@653 2059 "the conversion later to obtain new changes that happened after the initial "
dongsheng@653 2060 "conversion."
dongsheng@653 2061 msgstr ""
dongsheng@653 2062
dongsheng@653 2063 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 2064 #: ../en/ch00-preface.xml:633
dongsheng@653 2065 msgid ""
dongsheng@653 2066 "The revision control tools supported by <literal role=\"hg-ext\">convert</"
dongsheng@653 2067 "literal> are as follows:"
dongsheng@653 2068 msgstr "<literal role=\"hg-ext\">convert</literal> 支持的版本控制工具有:"
dongsheng@653 2069
dongsheng@653 2070 #. type: Content of: <book><preface><sect1><itemizedlist><listitem><para>
songdongsheng@667 2071 #: ../en/ch00-preface.xml:639
dongsheng@653 2072 msgid "Darcs"
songdongsheng@668 2073 msgstr "Darcs"
dongsheng@653 2074
dongsheng@653 2075 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 2076 #: ../en/ch00-preface.xml:641
dongsheng@653 2077 msgid ""
dongsheng@653 2078 "In addition, <literal role=\"hg-ext\">convert</literal> can export changes "
dongsheng@653 2079 "from Mercurial to Subversion. This makes it possible to try Subversion and "
dongsheng@653 2080 "Mercurial in parallel before committing to a switchover, without risking the "
dongsheng@653 2081 "loss of any work."
dongsheng@653 2082 msgstr ""
dongsheng@653 2083
dongsheng@653 2084 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 2085 #: ../en/ch00-preface.xml:647
dongsheng@653 2086 msgid ""
dongsheng@653 2087 "The <command role=\"hg-ext-convert\">convert</command> command is easy to "
dongsheng@653 2088 "use. Simply point it at the path or URL of the source repository, optionally "
dongsheng@653 2089 "give it the name of the destination repository, and it will start working. "
dongsheng@653 2090 "After the initial conversion, just run the same command again to import new "
dongsheng@653 2091 "changes."
dongsheng@653 2092 msgstr ""
dongsheng@653 2093
dongsheng@653 2094 #. type: Content of: <book><preface><sect1><title>
songdongsheng@667 2095 #: ../en/ch00-preface.xml:656
dongsheng@653 2096 msgid "A short history of revision control"
dongsheng@653 2097 msgstr "版本控制简史"
dongsheng@653 2098
dongsheng@653 2099 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 2100 #: ../en/ch00-preface.xml:658
dongsheng@653 2101 msgid ""
dongsheng@653 2102 "The best known of the old-time revision control tools is SCCS (Source Code "
dongsheng@653 2103 "Control System), which Marc Rochkind wrote at Bell Labs, in the early 1970s. "
dongsheng@653 2104 "SCCS operated on individual files, and required every person working on a "
dongsheng@653 2105 "project to have access to a shared workspace on a single system. Only one "
dongsheng@653 2106 "person could modify a file at any time; arbitration for access to files was "
dongsheng@653 2107 "via locks. It was common for people to lock files, and later forget to "
dongsheng@653 2108 "unlock them, preventing anyone else from modifying those files without the "
dongsheng@653 2109 "help of an administrator."
dongsheng@653 2110 msgstr ""
dongsheng@653 2111
dongsheng@653 2112 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 2113 #: ../en/ch00-preface.xml:669
dongsheng@653 2114 msgid ""
dongsheng@653 2115 "Walter Tichy developed a free alternative to SCCS in the early 1980s; he "
dongsheng@653 2116 "called his program RCS (Revision Control System). Like SCCS, RCS required "
dongsheng@653 2117 "developers to work in a single shared workspace, and to lock files to prevent "
dongsheng@653 2118 "multiple people from modifying them simultaneously."
dongsheng@653 2119 msgstr ""
dongsheng@653 2120
dongsheng@653 2121 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 2122 #: ../en/ch00-preface.xml:675
dongsheng@653 2123 msgid ""
dongsheng@653 2124 "Later in the 1980s, Dick Grune used RCS as a building block for a set of "
dongsheng@653 2125 "shell scripts he initially called cmt, but then renamed to CVS (Concurrent "
dongsheng@653 2126 "Versions System). The big innovation of CVS was that it let developers work "
dongsheng@653 2127 "simultaneously and somewhat independently in their own personal workspaces. "
dongsheng@653 2128 "The personal workspaces prevented developers from stepping on each other's "
dongsheng@653 2129 "toes all the time, as was common with SCCS and RCS. Each developer had a copy "
dongsheng@653 2130 "of every project file, and could modify their copies independently. They had "
dongsheng@653 2131 "to merge their edits prior to committing changes to the central repository."
dongsheng@653 2132 msgstr ""
dongsheng@653 2133
dongsheng@653 2134 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 2135 #: ../en/ch00-preface.xml:686
dongsheng@653 2136 msgid ""
dongsheng@653 2137 "Brian Berliner took Grune's original scripts and rewrote them in C, releasing "
dongsheng@653 2138 "in 1989 the code that has since developed into the modern version of CVS. "
dongsheng@653 2139 "CVS subsequently acquired the ability to operate over a network connection, "
dongsheng@653 2140 "giving it a client/server architecture. CVS's architecture is centralised; "
dongsheng@653 2141 "only the server has a copy of the history of the project. Client workspaces "
dongsheng@653 2142 "just contain copies of recent versions of the project's files, and a little "
dongsheng@653 2143 "metadata to tell them where the server is. CVS has been enormously "
dongsheng@653 2144 "successful; it is probably the world's most widely used revision control "
dongsheng@653 2145 "system."
dongsheng@653 2146 msgstr ""
dongsheng@653 2147
dongsheng@653 2148 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 2149 #: ../en/ch00-preface.xml:697
dongsheng@653 2150 msgid ""
dongsheng@653 2151 "In the early 1990s, Sun Microsystems developed an early distributed revision "
dongsheng@653 2152 "control system, called TeamWare. A TeamWare workspace contains a complete "
dongsheng@653 2153 "copy of the project's history. TeamWare has no notion of a central "
dongsheng@653 2154 "repository. (CVS relied upon RCS for its history storage; TeamWare used "
dongsheng@653 2155 "SCCS.)"
dongsheng@653 2156 msgstr ""
dongsheng@653 2157
dongsheng@653 2158 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 2159 #: ../en/ch00-preface.xml:704
dongsheng@653 2160 msgid ""
dongsheng@653 2161 "As the 1990s progressed, awareness grew of a number of problems with CVS. It "
dongsheng@653 2162 "records simultaneous changes to multiple files individually, instead of "
dongsheng@653 2163 "grouping them together as a single logically atomic operation. It does not "
dongsheng@653 2164 "manage its file hierarchy well; it is easy to make a mess of a repository by "
dongsheng@653 2165 "renaming files and directories. Worse, its source code is difficult to read "
dongsheng@653 2166 "and maintain, which made the <quote>pain level</quote> of fixing these "
dongsheng@653 2167 "architectural problems prohibitive."
dongsheng@653 2168 msgstr ""
dongsheng@653 2169
dongsheng@653 2170 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 2171 #: ../en/ch00-preface.xml:714
dongsheng@653 2172 msgid ""
dongsheng@653 2173 "In 2001, Jim Blandy and Karl Fogel, two developers who had worked on CVS, "
dongsheng@653 2174 "started a project to replace it with a tool that would have a better "
dongsheng@653 2175 "architecture and cleaner code. The result, Subversion, does not stray from "
dongsheng@653 2176 "CVS's centralised client/server model, but it adds multi-file atomic commits, "
dongsheng@653 2177 "better namespace management, and a number of other features that make it a "
dongsheng@653 2178 "generally better tool than CVS. Since its initial release, it has rapidly "
dongsheng@653 2179 "grown in popularity."
dongsheng@653 2180 msgstr ""
dongsheng@653 2181
dongsheng@653 2182 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 2183 #: ../en/ch00-preface.xml:723
dongsheng@653 2184 msgid ""
dongsheng@653 2185 "More or less simultaneously, Graydon Hoare began working on an ambitious "
dongsheng@653 2186 "distributed revision control system that he named Monotone. While Monotone "
dongsheng@653 2187 "addresses many of CVS's design flaws and has a peer-to-peer architecture, it "
dongsheng@653 2188 "goes beyond earlier (and subsequent) revision control tools in a number of "
dongsheng@653 2189 "innovative ways. It uses cryptographic hashes as identifiers, and has an "
dongsheng@653 2190 "integral notion of <quote>trust</quote> for code from different sources."
dongsheng@653 2191 msgstr ""
dongsheng@653 2192
dongsheng@653 2193 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 2194 #: ../en/ch00-preface.xml:732
dongsheng@653 2195 msgid ""
dongsheng@653 2196 "Mercurial began life in 2005. While a few aspects of its design are "
dongsheng@653 2197 "influenced by Monotone, Mercurial focuses on ease of use, high performance, "
dongsheng@653 2198 "and scalability to very large projects."
dongsheng@653 2199 msgstr ""
dongsheng@653 2200
dongsheng@653 2201 #. type: Content of: <book><preface><sect1><title>
songdongsheng@667 2202 #: ../en/ch00-preface.xml:740
songdongsheng@668 2203 msgid "Colophon&emdash;this book is Free"
dongsheng@661 2204 msgstr "后记—本书是自由的!"
dongsheng@653 2205
dongsheng@653 2206 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 2207 #: ../en/ch00-preface.xml:742
dongsheng@653 2208 msgid ""
dongsheng@653 2209 "This book is licensed under the Open Publication License, and is produced "
dongsheng@653 2210 "entirely using Free Software tools. It is typeset with DocBook XML. "
dongsheng@653 2211 "Illustrations are drawn and rendered with <ulink url=\"http://www.inkscape."
dongsheng@653 2212 "org/\">Inkscape</ulink>."
dongsheng@653 2213 msgstr ""
dongsheng@653 2214
dongsheng@653 2215 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 2216 #: ../en/ch00-preface.xml:747
dongsheng@653 2217 msgid ""
dongsheng@653 2218 "The complete source code for this book is published as a Mercurial "
dongsheng@653 2219 "repository, at <ulink url=\"http://hg.serpentine.com/mercurial/book\">http://"
dongsheng@653 2220 "hg.serpentine.com/mercurial/book</ulink>."
dongsheng@653 2221 msgstr ""
dongsheng@653 2222
dongsheng@627 2223 #. type: Content of: <book><chapter><title>
dongsheng@650 2224 #: ../en/ch01-tour-basic.xml:5
dongsheng@627 2225 msgid "A tour of Mercurial: the basics"
dongsheng@627 2226 msgstr "Mercurial 教程: 基础知识"
dongsheng@627 2227
dongsheng@627 2228 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 2229 #: ../en/ch01-tour-basic.xml:8
dongsheng@627 2230 msgid "Installing Mercurial on your system"
dongsheng@627 2231 msgstr "安装 Mercurial"
dongsheng@627 2232
dongsheng@627 2233 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 2234 #: ../en/ch01-tour-basic.xml:10
dongsheng@627 2235 msgid ""
dongsheng@627 2236 "Prebuilt binary packages of Mercurial are available for every popular "
dongsheng@627 2237 "operating system. These make it easy to start using Mercurial on your "
dongsheng@627 2238 "computer immediately."
dongsheng@627 2239 msgstr ""
dongsheng@644 2240 "对于每种流行的操作系统,都有已经构建的二进制软件包。这让在你的计算机上开始使"
dongsheng@644 2241 "用 Mercurial 变得很容易。"
dongsheng@627 2242
dongsheng@627 2243 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 2244 #: ../en/ch01-tour-basic.xml:15
songdongsheng@667 2245 msgid "Windows"
songdongsheng@668 2246 msgstr "Windows"
songdongsheng@667 2247
songdongsheng@667 2248 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 2249 #: ../en/ch01-tour-basic.xml:17
songdongsheng@667 2250 msgid ""
songdongsheng@667 2251 "The best version of Mercurial for Windows is TortoiseHg, which can be found "
songdongsheng@667 2252 "at <ulink url=\"http://bitbucket.org/tortoisehg/stable/wiki/Home\">http://"
songdongsheng@667 2253 "bitbucket.org/tortoisehg/stable/wiki/Home</ulink>. This package has no "
songdongsheng@667 2254 "external dependencies; it <quote>just works</quote>. It provides both "
songdongsheng@667 2255 "command line and graphical user interfaces."
songdongsheng@667 2256 msgstr ""
songdongsheng@667 2257
songdongsheng@667 2258 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@667 2259 #: ../en/ch01-tour-basic.xml:27
songdongsheng@667 2260 msgid "Mac OS X"
songdongsheng@667 2261 msgstr "Mac OS X"
songdongsheng@667 2262
songdongsheng@667 2263 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 2264 #: ../en/ch01-tour-basic.xml:29
songdongsheng@667 2265 msgid ""
songdongsheng@667 2266 "Lee Cantey publishes an installer of Mercurial for Mac OS X at <ulink url="
songdongsheng@667 2267 "\"http://mercurial.berkwood.com\">http://mercurial.berkwood.com</ulink>."
songdongsheng@667 2268 msgstr ""
songdongsheng@667 2269
songdongsheng@667 2270 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@667 2271 #: ../en/ch01-tour-basic.xml:35
dongsheng@627 2272 msgid "Linux"
dongsheng@644 2273 msgstr "Linux"
dongsheng@627 2274
dongsheng@627 2275 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 2276 #: ../en/ch01-tour-basic.xml:37
dongsheng@627 2277 msgid ""
dongsheng@627 2278 "Because each Linux distribution has its own packaging tools, policies, and "
dongsheng@627 2279 "rate of development, it's difficult to give a comprehensive set of "
dongsheng@627 2280 "instructions on how to install Mercurial binaries. The version of Mercurial "
dongsheng@627 2281 "that you will end up with can vary depending on how active the person is who "
dongsheng@627 2282 "maintains the package for your distribution."
dongsheng@627 2283 msgstr ""
dongsheng@644 2284 "由于每种 Linux 发行版都有自己的包管理工具,开发策略和进度,从而很难给出安装 "
dongsheng@644 2285 "Mercurial 二进制包的全面说明。你安装的 Mercurial 版本,在很大程度上依赖于你所"
dongsheng@644 2286 "使用的发行版的 Mercurial 维护者的活跃程度。"
dongsheng@627 2287
dongsheng@627 2288 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 2289 #: ../en/ch01-tour-basic.xml:44
dongsheng@627 2290 msgid ""
dongsheng@627 2291 "To keep things simple, I will focus on installing Mercurial from the command "
dongsheng@627 2292 "line under the most popular Linux distributions. Most of these distributions "
dongsheng@627 2293 "provide graphical package managers that will let you install Mercurial with a "
dongsheng@627 2294 "single click; the package name to look for is <literal>mercurial</literal>."
dongsheng@627 2295 msgstr ""
dongsheng@644 2296 "为了让事情简单,我会致力于说明在最流行的 Linux 发行版中,从命令行安装 "
dongsheng@644 2297 "Mercurial 的方法。这些发行版都提供了图形界面的包管理器,让你通过点击鼠标安装 "
dongsheng@644 2298 "Mercurial;寻找的包名称是 <literal>mercurial</literal>。"
dongsheng@627 2299
dongsheng@627 2300 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@667 2301 #: ../en/ch01-tour-basic.xml:52
songdongsheng@667 2302 msgid "Ubuntu and Debian:"
songdongsheng@668 2303 msgstr "Ubuntu 与 Debian:"
dongsheng@627 2304
dongsheng@627 2305 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@667 2306 #: ../en/ch01-tour-basic.xml:54
songdongsheng@667 2307 msgid "Fedora and OpenSUSE:"
songdongsheng@668 2308 msgstr "Fedora and OpenSUSE:"
dongsheng@627 2309
dongsheng@627 2310 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@667 2311 #: ../en/ch01-tour-basic.xml:56
dongsheng@627 2312 msgid "Gentoo:"
dongsheng@644 2313 msgstr "Gentoo:"
dongsheng@627 2314
dongsheng@646 2315 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@667 2316 #: ../en/ch01-tour-basic.xml:62
dongsheng@627 2317 msgid "Solaris"
dongsheng@646 2318 msgstr "Solaris"
dongsheng@646 2319
dongsheng@646 2320 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 2321 #: ../en/ch01-tour-basic.xml:64
dongsheng@627 2322 msgid ""
dongsheng@627 2323 "SunFreeWare, at <ulink url=\"http://www.sunfreeware.com\">http://www."
songdongsheng@667 2324 "sunfreeware.com</ulink>, provides prebuilt packages of Mercurial."
dongsheng@627 2325 msgstr ""
dongsheng@646 2326 "位于 <ulink url=\"http://www.sunfreeware.com\">http://www.sunfreeware.com</"
songdongsheng@668 2327 "ulink> 的 SunFreeWare 提供了 Mercurial 的二进制安装包。"
dongsheng@646 2328
dongsheng@627 2329 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@667 2330 #: ../en/ch01-tour-basic.xml:73
dongsheng@627 2331 msgid "Getting started"
dongsheng@627 2332 msgstr "开始"
dongsheng@627 2333
dongsheng@627 2334 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@667 2335 #: ../en/ch01-tour-basic.xml:75
dongsheng@627 2336 msgid ""
dongsheng@627 2337 "To begin, we'll use the <command role=\"hg-cmd\">hg version</command> command "
dongsheng@627 2338 "to find out whether Mercurial is actually installed properly. The actual "
dongsheng@627 2339 "version information that it prints isn't so important; it's whether it prints "
dongsheng@627 2340 "anything at all that we care about."
dongsheng@627 2341 msgstr ""
dongsheng@627 2342
dongsheng@627 2343 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@667 2344 #: ../en/ch01-tour-basic.xml:84
dongsheng@627 2345 msgid "Built-in help"
dongsheng@627 2346 msgstr "内置帮助"
dongsheng@627 2347
dongsheng@627 2348 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 2349 #: ../en/ch01-tour-basic.xml:86
dongsheng@627 2350 msgid ""
dongsheng@627 2351 "Mercurial provides a built-in help system. This is invaluable for those "
dongsheng@627 2352 "times when you find yourself stuck trying to remember how to run a command. "
dongsheng@627 2353 "If you are completely stuck, simply run <command role=\"hg-cmd\">hg help</"
dongsheng@627 2354 "command>; it will print a brief list of commands, along with a description of "
dongsheng@627 2355 "what each does. If you ask for help on a specific command (as below), it "
dongsheng@627 2356 "prints more detailed information."
dongsheng@627 2357 msgstr ""
dongsheng@627 2358
dongsheng@627 2359 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 2360 #: ../en/ch01-tour-basic.xml:97
dongsheng@627 2361 msgid ""
dongsheng@627 2362 "For a more impressive level of detail (which you won't usually need) run "
dongsheng@627 2363 "<command role=\"hg-cmd\">hg help <option role=\"hg-opt-global\">-v</option></"
dongsheng@627 2364 "command>. The <option role=\"hg-opt-global\">-v</option> option is short for "
dongsheng@627 2365 "<option role=\"hg-opt-global\">--verbose</option>, and tells Mercurial to "
dongsheng@627 2366 "print more information than it usually would."
dongsheng@627 2367 msgstr ""
dongsheng@627 2368
dongsheng@627 2369 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@667 2370 #: ../en/ch01-tour-basic.xml:108
dongsheng@627 2371 msgid "Working with a repository"
dongsheng@627 2372 msgstr "使用版本库"
dongsheng@627 2373
dongsheng@627 2374 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@667 2375 #: ../en/ch01-tour-basic.xml:110
dongsheng@627 2376 msgid ""
dongsheng@627 2377 "In Mercurial, everything happens inside a <emphasis>repository</emphasis>. "
dongsheng@627 2378 "The repository for a project contains all of the files that <quote>belong to</"
dongsheng@627 2379 "quote> that project, along with a historical record of the project's files."
dongsheng@627 2380 msgstr ""
dongsheng@627 2381
dongsheng@627 2382 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@667 2383 #: ../en/ch01-tour-basic.xml:116
dongsheng@627 2384 msgid ""
dongsheng@627 2385 "There's nothing particularly magical about a repository; it is simply a "
dongsheng@627 2386 "directory tree in your filesystem that Mercurial treats as special. You can "
dongsheng@627 2387 "rename or delete a repository any time you like, using either the command "
dongsheng@627 2388 "line or your file browser."
dongsheng@627 2389 msgstr ""
dongsheng@627 2390
dongsheng@627 2391 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@667 2392 #: ../en/ch01-tour-basic.xml:123
dongsheng@627 2393 msgid "Making a local copy of a repository"
dongsheng@627 2394 msgstr "创建版本库的工作副本"
dongsheng@627 2395
dongsheng@627 2396 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 2397 #: ../en/ch01-tour-basic.xml:125
dongsheng@627 2398 msgid ""
dongsheng@627 2399 "<emphasis>Copying</emphasis> a repository is just a little bit special. "
dongsheng@627 2400 "While you could use a normal file copying command to make a copy of a "
dongsheng@627 2401 "repository, it's best to use a built-in command that Mercurial provides. "
dongsheng@627 2402 "This command is called <command role=\"hg-cmd\">hg clone</command>, because "
songdongsheng@667 2403 "it makes an identical copy of an existing repository."
songdongsheng@667 2404 msgstr ""
songdongsheng@667 2405
songdongsheng@667 2406 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 2407 #: ../en/ch01-tour-basic.xml:134
songdongsheng@667 2408 msgid ""
songdongsheng@667 2409 "One advantage of using <command role=\"hg-cmd\">hg clone</command> is that, "
songdongsheng@667 2410 "as we can see above, it lets us clone repositories over the network. Another "
songdongsheng@667 2411 "is that it remembers where we cloned from, which we'll find useful soon when "
songdongsheng@667 2412 "we want to fetch new changes from another repository."
songdongsheng@667 2413 msgstr ""
songdongsheng@667 2414
songdongsheng@667 2415 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 2416 #: ../en/ch01-tour-basic.xml:140
dongsheng@627 2417 msgid ""
dongsheng@627 2418 "If our clone succeeded, we should now have a local directory called <filename "
dongsheng@627 2419 "class=\"directory\">hello</filename>. This directory will contain some files."
dongsheng@627 2420 msgstr ""
dongsheng@627 2421
dongsheng@627 2422 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 2423 #: ../en/ch01-tour-basic.xml:146
dongsheng@627 2424 msgid ""
dongsheng@627 2425 "These files have the same contents and history in our repository as they do "
dongsheng@627 2426 "in the repository we cloned."
dongsheng@627 2427 msgstr ""
dongsheng@627 2428
dongsheng@627 2429 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 2430 #: ../en/ch01-tour-basic.xml:149
dongsheng@627 2431 msgid ""
dongsheng@627 2432 "Every Mercurial repository is complete, self-contained, and independent. It "
songdongsheng@667 2433 "contains its own private copy of a project's files and history. As we just "
songdongsheng@667 2434 "mentioned, a cloned repository remembers the location of the repository it "
songdongsheng@667 2435 "was cloned from, but Mercurial will not communicate with that repository, or "
songdongsheng@667 2436 "any other, unless you tell it to."
songdongsheng@667 2437 msgstr ""
songdongsheng@667 2438
songdongsheng@667 2439 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 2440 #: ../en/ch01-tour-basic.xml:156
dongsheng@627 2441 msgid ""
dongsheng@627 2442 "What this means for now is that we're free to experiment with our repository, "
dongsheng@627 2443 "safe in the knowledge that it's a private <quote>sandbox</quote> that won't "
dongsheng@627 2444 "affect anyone else."
dongsheng@627 2445 msgstr ""
dongsheng@627 2446
dongsheng@627 2447 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@667 2448 #: ../en/ch01-tour-basic.xml:162
dongsheng@627 2449 msgid "What's in a repository?"
dongsheng@627 2450 msgstr "什么是版本库?"
dongsheng@627 2451
dongsheng@627 2452 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 2453 #: ../en/ch01-tour-basic.xml:164
dongsheng@627 2454 msgid ""
dongsheng@627 2455 "When we take a more detailed look inside a repository, we can see that it "
dongsheng@627 2456 "contains a directory named <filename class=\"directory\">.hg</filename>. "
dongsheng@627 2457 "This is where Mercurial keeps all of its metadata for the repository."
dongsheng@627 2458 msgstr ""
dongsheng@627 2459
dongsheng@627 2460 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 2461 #: ../en/ch01-tour-basic.xml:171
dongsheng@627 2462 msgid ""
dongsheng@627 2463 "The contents of the <filename class=\"directory\">.hg</filename> directory "
dongsheng@627 2464 "and its subdirectories are private to Mercurial. Every other file and "
dongsheng@627 2465 "directory in the repository is yours to do with as you please."
dongsheng@627 2466 msgstr ""
dongsheng@627 2467
dongsheng@627 2468 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 2469 #: ../en/ch01-tour-basic.xml:177
dongsheng@627 2470 msgid ""
dongsheng@627 2471 "To introduce a little terminology, the <filename class=\"directory\">.hg</"
dongsheng@627 2472 "filename> directory is the <quote>real</quote> repository, and all of the "
dongsheng@627 2473 "files and directories that coexist with it are said to live in the "
dongsheng@627 2474 "<emphasis>working directory</emphasis>. An easy way to remember the "
dongsheng@627 2475 "distinction is that the <emphasis>repository</emphasis> contains the "
dongsheng@627 2476 "<emphasis>history</emphasis> of your project, while the <emphasis>working "
dongsheng@627 2477 "directory</emphasis> contains a <emphasis>snapshot</emphasis> of your project "
dongsheng@627 2478 "at a particular point in history."
dongsheng@627 2479 msgstr ""
dongsheng@627 2480
dongsheng@627 2481 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@667 2482 #: ../en/ch01-tour-basic.xml:192
dongsheng@627 2483 msgid "A tour through history"
dongsheng@627 2484 msgstr "回溯历史"
dongsheng@627 2485
dongsheng@627 2486 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@667 2487 #: ../en/ch01-tour-basic.xml:194
dongsheng@627 2488 msgid ""
dongsheng@627 2489 "One of the first things we might want to do with a new, unfamiliar repository "
dongsheng@627 2490 "is understand its history. The <command role=\"hg-cmd\">hg log</command> "
songdongsheng@667 2491 "command gives us a view of the history of changes in the repository."
songdongsheng@667 2492 msgstr ""
songdongsheng@667 2493
songdongsheng@667 2494 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@667 2495 #: ../en/ch01-tour-basic.xml:201
dongsheng@627 2496 msgid ""
dongsheng@627 2497 "By default, this command prints a brief paragraph of output for each change "
dongsheng@627 2498 "to the project that was recorded. In Mercurial terminology, we call each of "
dongsheng@627 2499 "these recorded events a <emphasis>changeset</emphasis>, because it can "
dongsheng@627 2500 "contain a record of changes to several files."
dongsheng@627 2501 msgstr ""
dongsheng@627 2502
dongsheng@627 2503 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@667 2504 #: ../en/ch01-tour-basic.xml:207
dongsheng@627 2505 msgid ""
dongsheng@627 2506 "The fields in a record of output from <command role=\"hg-cmd\">hg log</"
dongsheng@627 2507 "command> are as follows."
dongsheng@627 2508 msgstr ""
dongsheng@627 2509
dongsheng@627 2510 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@667 2511 #: ../en/ch01-tour-basic.xml:211
dongsheng@627 2512 msgid ""
dongsheng@627 2513 "<literal>changeset</literal>: This field has the format of a number, followed "
songdongsheng@667 2514 "by a colon, followed by a hexadecimal (or <emphasis>hex</emphasis>) string. "
songdongsheng@667 2515 "These are <emphasis>identifiers</emphasis> for the changeset. The hex string "
songdongsheng@667 2516 "is a unique identifier: the same hex string will always refer to the same "
songdongsheng@667 2517 "changeset. The number is shorter and easier to type than the hex string, but "
songdongsheng@667 2518 "it isn't unique: the same number in two different clones of a repository may "
songdongsheng@667 2519 "identify different changesets. Why provide the number at all, then? For "
songdongsheng@667 2520 "local convenience."
dongsheng@627 2521 msgstr ""
dongsheng@627 2522
dongsheng@627 2523 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@667 2524 #: ../en/ch01-tour-basic.xml:223
dongsheng@627 2525 msgid ""
dongsheng@627 2526 "<literal>user</literal>: The identity of the person who created the "
dongsheng@627 2527 "changeset. This is a free-form field, but it most often contains a person's "
dongsheng@627 2528 "name and email address."
dongsheng@627 2529 msgstr ""
dongsheng@627 2530
dongsheng@627 2531 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@667 2532 #: ../en/ch01-tour-basic.xml:227
dongsheng@627 2533 msgid ""
dongsheng@627 2534 "<literal>date</literal>: The date and time on which the changeset was "
dongsheng@627 2535 "created, and the timezone in which it was created. (The date and time are "
dongsheng@627 2536 "local to that timezone; they display what time and date it was for the person "
dongsheng@627 2537 "who created the changeset.)"
dongsheng@627 2538 msgstr ""
dongsheng@627 2539
dongsheng@627 2540 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@667 2541 #: ../en/ch01-tour-basic.xml:232
dongsheng@627 2542 msgid ""
dongsheng@627 2543 "<literal>summary</literal>: The first line of the text message that the "
dongsheng@627 2544 "creator of the changeset entered to describe the changeset."
dongsheng@627 2545 msgstr ""
dongsheng@627 2546
songdongsheng@667 2547 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@667 2548 #: ../en/ch01-tour-basic.xml:236
songdongsheng@667 2549 msgid ""
songdongsheng@667 2550 "Some changesets, such as the first in the list above, have a <literal>tag</"
songdongsheng@667 2551 "literal> field. A tag is another way to identify a changeset, by giving it "
songdongsheng@667 2552 "an easy-to-remember name. (The tag named <literal>tip</literal> is special: "
songdongsheng@667 2553 "it always refers to the newest change in a repository.)"
songdongsheng@667 2554 msgstr ""
songdongsheng@667 2555
songdongsheng@667 2556 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@667 2557 #: ../en/ch01-tour-basic.xml:244
dongsheng@627 2558 msgid ""
dongsheng@627 2559 "The default output printed by <command role=\"hg-cmd\">hg log</command> is "
dongsheng@627 2560 "purely a summary; it is missing a lot of detail."
dongsheng@627 2561 msgstr ""
dongsheng@627 2562
dongsheng@627 2563 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@667 2564 #: ../en/ch01-tour-basic.xml:248
dongsheng@627 2565 msgid ""
songdongsheng@658 2566 "<xref linkend=\"fig:tour-basic:history\"/> provides a graphical "
songdongsheng@658 2567 "representation of the history of the <filename class=\"directory\">hello</"
songdongsheng@658 2568 "filename> repository, to make it a little easier to see which direction "
songdongsheng@658 2569 "history is <quote>flowing</quote> in. We'll be returning to this figure "
songdongsheng@658 2570 "several times in this chapter and the chapter that follows."
songdongsheng@658 2571 msgstr ""
songdongsheng@658 2572
songdongsheng@658 2573 #. type: Content of: <book><chapter><sect1><figure><title>
songdongsheng@667 2574 #: ../en/ch01-tour-basic.xml:257
dongsheng@627 2575 msgid ""
dongsheng@627 2576 "Graphical history of the <filename class=\"directory\">hello</filename> "
dongsheng@627 2577 "repository"
dongsheng@660 2578 msgstr "版本库 <filename class=\"directory\">hello</filename> 的历史图"
dongsheng@627 2579
songdongsheng@658 2580 #. type: Content of: <book><chapter><sect1><figure>
songdongsheng@667 2581 #: ../en/ch01-tour-basic.xml:259 ../en/ch02-tour-merge.xml:50
songdongsheng@710 2582 #: ../en/ch02-tour-merge.xml:188 ../en/ch03-concepts.xml:295
songdongsheng@658 2583 msgid "<placeholder type=\"mediaobject\" id=\"0\"/>"
songdongsheng@658 2584 msgstr ""
songdongsheng@658 2585
songdongsheng@658 2586 #. type: Content of: <book><chapter><sect1><figure><mediaobject>
songdongsheng@667 2587 #: ../en/ch01-tour-basic.xml:260
songdongsheng@658 2588 msgid ""
songdongsheng@658 2589 "<imageobject><imagedata fileref=\"figs/tour-history.png\"/></imageobject>"
songdongsheng@658 2590 msgstr ""
songdongsheng@658 2591
songdongsheng@658 2592 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject><textobject><phrase>
songdongsheng@667 2593 #: ../en/ch01-tour-basic.xml:261 ../en/ch02-tour-merge.xml:52
songdongsheng@710 2594 #: ../en/ch02-tour-merge.xml:82 ../en/ch02-tour-merge.xml:163
songdongsheng@710 2595 #: ../en/ch02-tour-merge.xml:190 ../en/ch02-tour-merge.xml:260
songdongsheng@710 2596 #: ../en/ch03-concepts.xml:59 ../en/ch03-concepts.xml:108
songdongsheng@710 2597 #: ../en/ch03-concepts.xml:193 ../en/ch03-concepts.xml:297
songdongsheng@710 2598 #: ../en/ch03-concepts.xml:348 ../en/ch03-concepts.xml:363
songdongsheng@710 2599 #: ../en/ch03-concepts.xml:404 ../en/ch03-concepts.xml:424
songdongsheng@710 2600 #: ../en/ch03-concepts.xml:467 ../en/ch05-collab.xml:322
songdongsheng@658 2601 #: ../en/ch08-undo.xml:365 ../en/ch08-undo.xml:412 ../en/ch08-undo.xml:477
songdongsheng@658 2602 #: ../en/ch08-undo.xml:515 ../en/ch11-mq.xml:412
songdongsheng@658 2603 msgid "XXX add text"
songdongsheng@658 2604 msgstr ""
songdongsheng@658 2605
dongsheng@627 2606 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@667 2607 #: ../en/ch01-tour-basic.xml:266
dongsheng@627 2608 msgid "Changesets, revisions, and talking to other people"
songdongsheng@665 2609 msgstr "修改集,版本,与其它用户交互"
dongsheng@627 2610
dongsheng@627 2611 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 2612 #: ../en/ch01-tour-basic.xml:269
dongsheng@627 2613 msgid ""
dongsheng@627 2614 "As English is a notoriously sloppy language, and computer science has a "
dongsheng@627 2615 "hallowed history of terminological confusion (why use one term when four will "
dongsheng@627 2616 "do?), revision control has a variety of words and phrases that mean the same "
dongsheng@627 2617 "thing. If you are talking about Mercurial history with other people, you "
dongsheng@627 2618 "will find that the word <quote>changeset</quote> is often compressed to "
dongsheng@627 2619 "<quote>change</quote> or (when written) <quote>cset</quote>, and sometimes a "
dongsheng@627 2620 "changeset is referred to as a <quote>revision</quote> or a <quote>rev</quote>."
dongsheng@627 2621 msgstr ""
dongsheng@627 2622
dongsheng@627 2623 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 2624 #: ../en/ch01-tour-basic.xml:279
dongsheng@627 2625 msgid ""
dongsheng@627 2626 "While it doesn't matter what <emphasis>word</emphasis> you use to refer to "
dongsheng@627 2627 "the concept of <quote>a changeset</quote>, the <emphasis>identifier</"
dongsheng@627 2628 "emphasis> that you use to refer to <quote>a <emphasis>specific</emphasis> "
dongsheng@627 2629 "changeset</quote> is of great importance. Recall that the <literal>changeset</"
dongsheng@627 2630 "literal> field in the output from <command role=\"hg-cmd\">hg log</command> "
dongsheng@627 2631 "identifies a changeset using both a number and a hexadecimal string."
dongsheng@627 2632 msgstr ""
dongsheng@627 2633
dongsheng@627 2634 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@667 2635 #: ../en/ch01-tour-basic.xml:288
songdongsheng@667 2636 msgid ""
songdongsheng@667 2637 "The revision number is a handy notation that is <emphasis>only valid in that "
songdongsheng@667 2638 "repository</emphasis>."
songdongsheng@658 2639 msgstr ""
songdongsheng@658 2640
songdongsheng@658 2641 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 2642 #: ../en/ch01-tour-basic.xml:291
dongsheng@627 2643 msgid ""
songdongsheng@667 2644 "The hexadecimal string is the <emphasis>permanent, unchanging identifier</"
dongsheng@627 2645 "emphasis> that will always identify that exact changeset in <emphasis>every</"
dongsheng@627 2646 "emphasis> copy of the repository."
dongsheng@627 2647 msgstr ""
dongsheng@627 2648
dongsheng@627 2649 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 2650 #: ../en/ch01-tour-basic.xml:297
dongsheng@627 2651 msgid ""
dongsheng@627 2652 "This distinction is important. If you send someone an email talking about "
dongsheng@627 2653 "<quote>revision 33</quote>, there's a high likelihood that their revision 33 "
dongsheng@627 2654 "will <emphasis>not be the same</emphasis> as yours. The reason for this is "
dongsheng@627 2655 "that a revision number depends on the order in which changes arrived in a "
dongsheng@627 2656 "repository, and there is no guarantee that the same changes will happen in "
songdongsheng@667 2657 "the same order in different repositories. Three changes <literal>a,b,c</"
songdongsheng@667 2658 "literal> can easily appear in one repository as <literal>0,1,2</literal>, "
songdongsheng@667 2659 "while in another as <literal>0,2,1</literal>."
songdongsheng@667 2660 msgstr ""
songdongsheng@667 2661
songdongsheng@667 2662 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 2663 #: ../en/ch01-tour-basic.xml:309
dongsheng@627 2664 msgid ""
dongsheng@627 2665 "Mercurial uses revision numbers purely as a convenient shorthand. If you "
dongsheng@627 2666 "need to discuss a changeset with someone, or make a record of a changeset for "
dongsheng@627 2667 "some other reason (for example, in a bug report), use the hexadecimal "
dongsheng@627 2668 "identifier."
dongsheng@627 2669 msgstr ""
dongsheng@627 2670
dongsheng@627 2671 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@667 2672 #: ../en/ch01-tour-basic.xml:317
dongsheng@627 2673 msgid "Viewing specific revisions"
dongsheng@627 2674 msgstr "察看指定版本"
dongsheng@627 2675
dongsheng@627 2676 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 2677 #: ../en/ch01-tour-basic.xml:319
dongsheng@627 2678 msgid ""
dongsheng@627 2679 "To narrow the output of <command role=\"hg-cmd\">hg log</command> down to a "
dongsheng@627 2680 "single revision, use the <option role=\"hg-opt-log\">-r</option> (or <option "
dongsheng@627 2681 "role=\"hg-opt-log\">--rev</option>) option. You can use either a revision "
songdongsheng@667 2682 "number or a hexadecimal identifier, and you can provide as many revisions as "
songdongsheng@667 2683 "you want."
songdongsheng@667 2684 msgstr ""
songdongsheng@667 2685
songdongsheng@667 2686 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 2687 #: ../en/ch01-tour-basic.xml:328
dongsheng@627 2688 msgid ""
dongsheng@627 2689 "If you want to see the history of several revisions without having to list "
dongsheng@627 2690 "each one, you can use <emphasis>range notation</emphasis>; this lets you "
dongsheng@627 2691 "express the idea <quote>I want all revisions between <literal>abc</literal> "
dongsheng@627 2692 "and <literal>def</literal>, inclusive</quote>."
dongsheng@627 2693 msgstr ""
dongsheng@627 2694
dongsheng@627 2695 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 2696 #: ../en/ch01-tour-basic.xml:336
dongsheng@627 2697 msgid ""
dongsheng@627 2698 "Mercurial also honours the order in which you specify revisions, so <command "
dongsheng@627 2699 "role=\"hg-cmd\">hg log -r 2:4</command> prints 2, 3, and 4. while <command "
dongsheng@627 2700 "role=\"hg-cmd\">hg log -r 4:2</command> prints 4, 3, and 2."
dongsheng@627 2701 msgstr ""
dongsheng@627 2702
dongsheng@627 2703 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@667 2704 #: ../en/ch01-tour-basic.xml:343
dongsheng@627 2705 msgid "More detailed information"
dongsheng@627 2706 msgstr "更详细的信息"
dongsheng@627 2707
dongsheng@627 2708 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 2709 #: ../en/ch01-tour-basic.xml:345
dongsheng@627 2710 msgid ""
dongsheng@627 2711 "While the summary information printed by <command role=\"hg-cmd\">hg log</"
dongsheng@627 2712 "command> is useful if you already know what you're looking for, you may need "
dongsheng@627 2713 "to see a complete description of the change, or a list of the files changed, "
dongsheng@627 2714 "if you're trying to decide whether a changeset is the one you're looking for. "
dongsheng@627 2715 "The <command role=\"hg-cmd\">hg log</command> command's <option role=\"hg-opt-"
dongsheng@627 2716 "global\">-v</option> (or <option role=\"hg-opt-global\">--verbose</option>) "
dongsheng@627 2717 "option gives you this extra detail."
dongsheng@627 2718 msgstr ""
dongsheng@627 2719
dongsheng@627 2720 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 2721 #: ../en/ch01-tour-basic.xml:357
dongsheng@627 2722 msgid ""
dongsheng@627 2723 "If you want to see both the description and content of a change, add the "
dongsheng@627 2724 "<option role=\"hg-opt-log\">-p</option> (or <option role=\"hg-opt-log\">--"
dongsheng@627 2725 "patch</option>) option. This displays the content of a change as a "
dongsheng@627 2726 "<emphasis>unified diff</emphasis> (if you've never seen a unified diff "
songdongsheng@658 2727 "before, see <xref linkend=\"sec:mq:patch\"/> for an overview)."
dongsheng@627 2728 msgstr ""
dongsheng@627 2729
songdongsheng@667 2730 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 2731 #: ../en/ch01-tour-basic.xml:367
songdongsheng@667 2732 msgid ""
songdongsheng@667 2733 "The <option role=\"hg-opt-log\">-p</option> option is tremendously useful, so "
songdongsheng@667 2734 "it's well worth remembering."
songdongsheng@667 2735 msgstr ""
songdongsheng@667 2736
dongsheng@627 2737 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@667 2738 #: ../en/ch01-tour-basic.xml:374
dongsheng@627 2739 msgid "All about command options"
dongsheng@627 2740 msgstr "命令选项"
dongsheng@627 2741
dongsheng@627 2742 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@667 2743 #: ../en/ch01-tour-basic.xml:376
dongsheng@627 2744 msgid ""
dongsheng@627 2745 "Let's take a brief break from exploring Mercurial commands to discuss a "
dongsheng@627 2746 "pattern in the way that they work; you may find this useful to keep in mind "
dongsheng@627 2747 "as we continue our tour."
dongsheng@627 2748 msgstr ""
dongsheng@627 2749
dongsheng@627 2750 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@667 2751 #: ../en/ch01-tour-basic.xml:380
dongsheng@627 2752 msgid ""
dongsheng@627 2753 "Mercurial has a consistent and straightforward approach to dealing with the "
dongsheng@627 2754 "options that you can pass to commands. It follows the conventions for "
dongsheng@627 2755 "options that are common to modern Linux and Unix systems."
dongsheng@627 2756 msgstr ""
dongsheng@627 2757
dongsheng@627 2758 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@667 2759 #: ../en/ch01-tour-basic.xml:387
dongsheng@627 2760 msgid ""
dongsheng@627 2761 "Every option has a long name. For example, as we've already seen, the "
dongsheng@627 2762 "<command role=\"hg-cmd\">hg log</command> command accepts a <option role=\"hg-"
dongsheng@627 2763 "opt-log\">--rev</option> option."
dongsheng@627 2764 msgstr ""
dongsheng@627 2765
dongsheng@627 2766 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@667 2767 #: ../en/ch01-tour-basic.xml:393
dongsheng@627 2768 msgid ""
dongsheng@627 2769 "Most options have short names, too. Instead of <option role=\"hg-opt-log\">--"
dongsheng@627 2770 "rev</option>, we can use <option role=\"hg-opt-log\">-r</option>. (The "
dongsheng@627 2771 "reason that some options don't have short names is that the options in "
dongsheng@627 2772 "question are rarely used.)"
dongsheng@627 2773 msgstr ""
dongsheng@627 2774
dongsheng@627 2775 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@667 2776 #: ../en/ch01-tour-basic.xml:400
songdongsheng@667 2777 msgid ""
songdongsheng@667 2778 "Long options start with two dashes (e.g. <option role=\"hg-opt-log\">--rev</"
dongsheng@627 2779 "option>), while short options start with one (e.g. <option role=\"hg-opt-log"
dongsheng@627 2780 "\">-r</option>)."
dongsheng@627 2781 msgstr ""
dongsheng@627 2782
dongsheng@627 2783 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@667 2784 #: ../en/ch01-tour-basic.xml:406
dongsheng@627 2785 msgid ""
dongsheng@627 2786 "Option naming and usage is consistent across commands. For example, every "
dongsheng@627 2787 "command that lets you specify a changeset ID or revision number accepts both "
dongsheng@627 2788 "<option role=\"hg-opt-log\">-r</option> and <option role=\"hg-opt-log\">--"
dongsheng@627 2789 "rev</option> arguments."
dongsheng@627 2790 msgstr ""
dongsheng@627 2791
songdongsheng@667 2792 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@667 2793 #: ../en/ch01-tour-basic.xml:413
songdongsheng@667 2794 msgid ""
songdongsheng@667 2795 "If you are using short options, you can save typing by running them together. "
songdongsheng@667 2796 "For example, the command <command role=\"hg-cmd\">hg log -v -p -r 2</command> "
songdongsheng@667 2797 "can be written as <command role=\"hg-cmd\">hg log -vpr2</command>."
songdongsheng@667 2798 msgstr ""
songdongsheng@667 2799
songdongsheng@667 2800 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@667 2801 #: ../en/ch01-tour-basic.xml:420
dongsheng@627 2802 msgid ""
dongsheng@627 2803 "In the examples throughout this book, I use short options instead of long. "
dongsheng@627 2804 "This just reflects my own preference, so don't read anything significant into "
dongsheng@627 2805 "it."
dongsheng@627 2806 msgstr ""
dongsheng@627 2807
dongsheng@627 2808 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@667 2809 #: ../en/ch01-tour-basic.xml:424
dongsheng@627 2810 msgid ""
dongsheng@627 2811 "Most commands that print output of some kind will print more output when "
dongsheng@627 2812 "passed a <option role=\"hg-opt-global\">-v</option> (or <option role=\"hg-opt-"
dongsheng@627 2813 "global\">--verbose</option>) option, and less when passed <option role=\"hg-"
dongsheng@627 2814 "opt-global\">-q</option> (or <option role=\"hg-opt-global\">--quiet</option>)."
dongsheng@627 2815 msgstr ""
dongsheng@627 2816
songdongsheng@667 2817 #. type: Content of: <book><chapter><sect1><note><title>
songdongsheng@667 2818 #: ../en/ch01-tour-basic.xml:431
songdongsheng@667 2819 msgid "Option naming consistency"
songdongsheng@667 2820 msgstr ""
songdongsheng@667 2821
songdongsheng@667 2822 #. type: Content of: <book><chapter><sect1><note><para>
songdongsheng@667 2823 #: ../en/ch01-tour-basic.xml:433
songdongsheng@667 2824 msgid ""
songdongsheng@667 2825 "Almost always, Mercurial commands use consistent option names to refer to the "
songdongsheng@667 2826 "same concepts. For instance, if a command deals with changesets, you'll "
songdongsheng@667 2827 "always identify them with <option role=\"hg-opt-log\">--rev</option> or "
songdongsheng@667 2828 "<option role=\"hg-opt-log\">-r</option>. This consistent use of option names "
songdongsheng@667 2829 "makes it easier to remember what options a particular command takes."
songdongsheng@667 2830 msgstr ""
songdongsheng@667 2831
dongsheng@627 2832 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@667 2833 #: ../en/ch01-tour-basic.xml:444
dongsheng@627 2834 msgid "Making and reviewing changes"
dongsheng@627 2835 msgstr "创建和复审修改"
dongsheng@627 2836
dongsheng@627 2837 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@667 2838 #: ../en/ch01-tour-basic.xml:446
dongsheng@627 2839 msgid ""
dongsheng@627 2840 "Now that we have a grasp of viewing history in Mercurial, let's take a look "
dongsheng@627 2841 "at making some changes and examining them."
dongsheng@627 2842 msgstr ""
dongsheng@627 2843
dongsheng@627 2844 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@667 2845 #: ../en/ch01-tour-basic.xml:450
dongsheng@627 2846 msgid ""
dongsheng@627 2847 "The first thing we'll do is isolate our experiment in a repository of its "
dongsheng@627 2848 "own. We use the <command role=\"hg-cmd\">hg clone</command> command, but we "
dongsheng@627 2849 "don't need to clone a copy of the remote repository. Since we already have a "
dongsheng@627 2850 "copy of it locally, we can just clone that instead. This is much faster than "
dongsheng@627 2851 "cloning over the network, and cloning a local repository uses less disk space "
songdongsheng@667 2852 "in most cases, too<placeholder type=\"footnote\" id=\"0\"/>."
songdongsheng@667 2853 msgstr ""
songdongsheng@667 2854
songdongsheng@667 2855 #. type: Content of: <book><chapter><sect1><para><footnote><para>
songdongsheng@667 2856 #: ../en/ch01-tour-basic.xml:457
songdongsheng@667 2857 msgid ""
songdongsheng@667 2858 "The saving of space arises when source and destination repositories are on "
songdongsheng@667 2859 "the same filesystem, in which case Mercurial will use hardlinks to do copy-on-"
songdongsheng@667 2860 "write sharing of its internal metadata. If that explanation meant nothing to "
songdongsheng@667 2861 "you, don't worry: everything happens transparently and automatically, and you "
songdongsheng@667 2862 "don't need to understand it."
songdongsheng@667 2863 msgstr ""
songdongsheng@667 2864
songdongsheng@667 2865 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@667 2866 #: ../en/ch01-tour-basic.xml:467
dongsheng@627 2867 msgid ""
dongsheng@627 2868 "As an aside, it's often good practice to keep a <quote>pristine</quote> copy "
dongsheng@627 2869 "of a remote repository around, which you can then make temporary clones of to "
dongsheng@627 2870 "create sandboxes for each task you want to work on. This lets you work on "
dongsheng@627 2871 "multiple tasks in parallel, each isolated from the others until it's complete "
dongsheng@627 2872 "and you're ready to integrate it back. Because local clones are so cheap, "
dongsheng@627 2873 "there's almost no overhead to cloning and destroying repositories whenever "
dongsheng@627 2874 "you want."
dongsheng@627 2875 msgstr ""
dongsheng@627 2876
dongsheng@627 2877 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@667 2878 #: ../en/ch01-tour-basic.xml:476
dongsheng@627 2879 msgid ""
dongsheng@627 2880 "In our <filename class=\"directory\">my-hello</filename> repository, we have "
dongsheng@627 2881 "a file <filename>hello.c</filename> that contains the classic <quote>hello, "
songdongsheng@667 2882 "world</quote> program."
songdongsheng@667 2883 msgstr ""
songdongsheng@667 2884
songdongsheng@667 2885 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@667 2886 #: ../en/ch01-tour-basic.xml:482
songdongsheng@667 2887 msgid "Let's edit this file so that it prints a second line of output."
songdongsheng@667 2888 msgstr ""
songdongsheng@667 2889
songdongsheng@667 2890 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@667 2891 #: ../en/ch01-tour-basic.xml:487
dongsheng@627 2892 msgid ""
dongsheng@627 2893 "Mercurial's <command role=\"hg-cmd\">hg status</command> command will tell us "
dongsheng@627 2894 "what Mercurial knows about the files in the repository."
dongsheng@627 2895 msgstr ""
dongsheng@627 2896
dongsheng@627 2897 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@667 2898 #: ../en/ch01-tour-basic.xml:493
dongsheng@627 2899 msgid ""
dongsheng@627 2900 "The <command role=\"hg-cmd\">hg status</command> command prints no output for "
dongsheng@627 2901 "some files, but a line starting with <quote><literal>M</literal></quote> for "
dongsheng@627 2902 "<filename>hello.c</filename>. Unless you tell it to, <command role=\"hg-cmd"
dongsheng@627 2903 "\">hg status</command> will not print any output for files that have not been "
dongsheng@627 2904 "modified."
dongsheng@627 2905 msgstr ""
dongsheng@627 2906
dongsheng@627 2907 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@667 2908 #: ../en/ch01-tour-basic.xml:500
dongsheng@627 2909 msgid ""
dongsheng@627 2910 "The <quote><literal>M</literal></quote> indicates that Mercurial has noticed "
dongsheng@627 2911 "that we modified <filename>hello.c</filename>. We didn't need to "
dongsheng@627 2912 "<emphasis>inform</emphasis> Mercurial that we were going to modify the file "
dongsheng@627 2913 "before we started, or that we had modified the file after we were done; it "
dongsheng@627 2914 "was able to figure this out itself."
dongsheng@627 2915 msgstr ""
dongsheng@627 2916
dongsheng@627 2917 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@667 2918 #: ../en/ch01-tour-basic.xml:508
songdongsheng@667 2919 msgid ""
songdongsheng@667 2920 "It's somewhat helpful to know that we've modified <filename>hello.c</"
dongsheng@627 2921 "filename>, but we might prefer to know exactly <emphasis>what</emphasis> "
dongsheng@627 2922 "changes we've made to it. To do this, we use the <command role=\"hg-cmd\">hg "
dongsheng@627 2923 "diff</command> command."
dongsheng@627 2924 msgstr ""
dongsheng@627 2925
dongsheng@627 2926 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@667 2927 #: ../en/ch01-tour-basic.xml:517 ../en/ch11-mq.xml:187
songdongsheng@667 2928 msgid "Understanding patches"
songdongsheng@667 2929 msgstr "理解补丁"
songdongsheng@667 2930
songdongsheng@667 2931 #. type: Content of: <book><chapter><sect1><tip><para>
songdongsheng@667 2932 #: ../en/ch01-tour-basic.xml:519
songdongsheng@667 2933 msgid ""
songdongsheng@667 2934 "Remember to take a look at <xref linkend=\"sec:mq:patch\"/> if you don't know "
songdongsheng@667 2935 "how to read output above."
songdongsheng@667 2936 msgstr ""
songdongsheng@667 2937
songdongsheng@667 2938 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@667 2939 #: ../en/ch01-tour-basic.xml:525
dongsheng@627 2940 msgid "Recording changes in a new changeset"
dongsheng@627 2941 msgstr "在新修改集中记录修改"
dongsheng@627 2942
dongsheng@627 2943 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@667 2944 #: ../en/ch01-tour-basic.xml:527
dongsheng@627 2945 msgid ""
dongsheng@627 2946 "We can modify files, build and test our changes, and use <command role=\"hg-"
dongsheng@627 2947 "cmd\">hg status</command> and <command role=\"hg-cmd\">hg diff</command> to "
dongsheng@627 2948 "review our changes, until we're satisfied with what we've done and arrive at "
dongsheng@627 2949 "a natural stopping point where we want to record our work in a new changeset."
dongsheng@627 2950 msgstr ""
dongsheng@627 2951
dongsheng@627 2952 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@667 2953 #: ../en/ch01-tour-basic.xml:534
dongsheng@627 2954 msgid ""
dongsheng@627 2955 "The <command role=\"hg-cmd\">hg commit</command> command lets us create a new "
dongsheng@627 2956 "changeset; we'll usually refer to this as <quote>making a commit</quote> or "
dongsheng@627 2957 "<quote>committing</quote>."
dongsheng@627 2958 msgstr ""
dongsheng@627 2959
dongsheng@627 2960 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@667 2961 #: ../en/ch01-tour-basic.xml:540
dongsheng@627 2962 msgid "Setting up a username"
dongsheng@627 2963 msgstr "配置用户名称"
dongsheng@627 2964
dongsheng@627 2965 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 2966 #: ../en/ch01-tour-basic.xml:542
dongsheng@627 2967 msgid ""
dongsheng@627 2968 "When you try to run <command role=\"hg-cmd\">hg commit</command> for the "
dongsheng@627 2969 "first time, it is not guaranteed to succeed. Mercurial records your name and "
dongsheng@627 2970 "address with each change that you commit, so that you and others will later "
dongsheng@627 2971 "be able to tell who made each change. Mercurial tries to automatically "
dongsheng@627 2972 "figure out a sensible username to commit the change with. It will attempt "
dongsheng@627 2973 "each of the following methods, in order:"
dongsheng@627 2974 msgstr ""
dongsheng@627 2975
dongsheng@627 2976 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
songdongsheng@667 2977 #: ../en/ch01-tour-basic.xml:551
dongsheng@627 2978 msgid ""
dongsheng@627 2979 "If you specify a <option role=\"hg-opt-commit\">-u</option> option to the "
dongsheng@627 2980 "<command role=\"hg-cmd\">hg commit</command> command on the command line, "
dongsheng@627 2981 "followed by a username, this is always given the highest precedence."
dongsheng@627 2982 msgstr ""
dongsheng@627 2983
dongsheng@627 2984 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
songdongsheng@667 2985 #: ../en/ch01-tour-basic.xml:556
dongsheng@627 2986 msgid ""
dongsheng@627 2987 "If you have set the <envar>HGUSER</envar> environment variable, this is "
dongsheng@627 2988 "checked next."
dongsheng@627 2989 msgstr ""
dongsheng@627 2990
dongsheng@627 2991 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
songdongsheng@667 2992 #: ../en/ch01-tour-basic.xml:559
dongsheng@627 2993 msgid ""
dongsheng@627 2994 "If you create a file in your home directory called <filename role=\"special"
dongsheng@627 2995 "\">.hgrc</filename>, with a <envar role=\"rc-item-ui\">username</envar> "
dongsheng@627 2996 "entry, that will be used next. To see what the contents of this file should "
songdongsheng@658 2997 "look like, refer to <xref linkend=\"sec:tour-basic:username\"/> below."
dongsheng@627 2998 msgstr ""
dongsheng@627 2999
dongsheng@627 3000 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
songdongsheng@667 3001 #: ../en/ch01-tour-basic.xml:567
dongsheng@627 3002 msgid ""
dongsheng@627 3003 "If you have set the <envar>EMAIL</envar> environment variable, this will be "
dongsheng@627 3004 "used next."
dongsheng@627 3005 msgstr ""
dongsheng@627 3006
dongsheng@627 3007 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
songdongsheng@667 3008 #: ../en/ch01-tour-basic.xml:570
dongsheng@627 3009 msgid ""
dongsheng@627 3010 "Mercurial will query your system to find out your local user name and host "
dongsheng@627 3011 "name, and construct a username from these components. Since this often "
dongsheng@627 3012 "results in a username that is not very useful, it will print a warning if it "
dongsheng@627 3013 "has to do this."
dongsheng@627 3014 msgstr ""
dongsheng@627 3015
dongsheng@627 3016 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3017 #: ../en/ch01-tour-basic.xml:577
dongsheng@627 3018 msgid ""
dongsheng@627 3019 "If all of these mechanisms fail, Mercurial will fail, printing an error "
dongsheng@627 3020 "message. In this case, it will not let you commit until you set up a "
dongsheng@627 3021 "username."
dongsheng@627 3022 msgstr ""
dongsheng@627 3023
dongsheng@627 3024 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3025 #: ../en/ch01-tour-basic.xml:581
dongsheng@627 3026 msgid ""
dongsheng@627 3027 "You should think of the <envar>HGUSER</envar> environment variable and the "
dongsheng@627 3028 "<option role=\"hg-opt-commit\">-u</option> option to the <command role=\"hg-"
dongsheng@627 3029 "cmd\">hg commit</command> command as ways to <emphasis>override</emphasis> "
dongsheng@627 3030 "Mercurial's default selection of username. For normal use, the simplest and "
dongsheng@627 3031 "most robust way to set a username for yourself is by creating a <filename "
dongsheng@627 3032 "role=\"special\">.hgrc</filename> file; see below for details."
dongsheng@627 3033 msgstr ""
dongsheng@627 3034
dongsheng@627 3035 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
songdongsheng@667 3036 #: ../en/ch01-tour-basic.xml:590
dongsheng@627 3037 msgid "Creating a Mercurial configuration file"
dongsheng@627 3038 msgstr "创建 Mercurial 的配置文件"
dongsheng@627 3039
dongsheng@627 3040 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@667 3041 #: ../en/ch01-tour-basic.xml:592
dongsheng@627 3042 msgid ""
songdongsheng@710 3043 "To set a user name, use your favorite editor to create a file called "
dongsheng@627 3044 "<filename role=\"special\">.hgrc</filename> in your home directory. "
dongsheng@627 3045 "Mercurial will use this file to look up your personalised configuration "
dongsheng@627 3046 "settings. The initial contents of your <filename role=\"special\">.hgrc</"
dongsheng@627 3047 "filename> should look like this."
dongsheng@627 3048 msgstr ""
dongsheng@627 3049
songdongsheng@667 3050 #. type: Content of: <book><chapter><sect1><sect2><sect3><remark>
songdongsheng@667 3051 #: ../en/ch01-tour-basic.xml:600
songdongsheng@667 3052 msgid "Figure out what the appropriate directory is on Windows."
songdongsheng@667 3053 msgstr ""
songdongsheng@667 3054
dongsheng@627 3055 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@667 3056 #: ../en/ch01-tour-basic.xml:607
dongsheng@627 3057 msgid ""
dongsheng@627 3058 "The <quote><literal>[ui]</literal></quote> line begins a <emphasis>section</"
dongsheng@627 3059 "emphasis> of the config file, so you can read the <quote><literal>username "
dongsheng@627 3060 "= ...</literal></quote> line as meaning <quote>set the value of the "
dongsheng@627 3061 "<literal>username</literal> item in the <literal>ui</literal> section</"
dongsheng@627 3062 "quote>. A section continues until a new section begins, or the end of the "
dongsheng@627 3063 "file. Mercurial ignores empty lines and treats any text from "
dongsheng@627 3064 "<quote><literal>#</literal></quote> to the end of a line as a comment."
dongsheng@627 3065 msgstr ""
dongsheng@627 3066
dongsheng@627 3067 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
songdongsheng@667 3068 #: ../en/ch01-tour-basic.xml:620
dongsheng@627 3069 msgid "Choosing a user name"
dongsheng@627 3070 msgstr "选择用户名称"
dongsheng@627 3071
dongsheng@627 3072 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@667 3073 #: ../en/ch01-tour-basic.xml:622
dongsheng@627 3074 msgid ""
dongsheng@627 3075 "You can use any text you like as the value of the <literal>username</literal> "
songdongsheng@667 3076 "config item, since this information is for reading by other people, but will "
songdongsheng@667 3077 "not be interpreted by Mercurial. The convention that most people follow is "
songdongsheng@667 3078 "to use their name and email address, as in the example above."
dongsheng@627 3079 msgstr ""
dongsheng@627 3080
dongsheng@627 3081 #. type: Content of: <book><chapter><sect1><sect2><sect3><note><para>
songdongsheng@667 3082 #: ../en/ch01-tour-basic.xml:629
dongsheng@627 3083 msgid ""
dongsheng@627 3084 "Mercurial's built-in web server obfuscates email addresses, to make it more "
dongsheng@627 3085 "difficult for the email harvesting tools that spammers use. This reduces the "
dongsheng@627 3086 "likelihood that you'll start receiving more junk email if you publish a "
dongsheng@627 3087 "Mercurial repository on the web."
dongsheng@627 3088 msgstr ""
dongsheng@627 3089
dongsheng@627 3090 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@667 3091 #: ../en/ch01-tour-basic.xml:639
dongsheng@627 3092 msgid "Writing a commit message"
dongsheng@627 3093 msgstr "写提交日志"
dongsheng@627 3094
dongsheng@627 3095 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3096 #: ../en/ch01-tour-basic.xml:641
dongsheng@627 3097 msgid ""
dongsheng@627 3098 "When we commit a change, Mercurial drops us into a text editor, to enter a "
dongsheng@627 3099 "message that will describe the modifications we've made in this changeset. "
dongsheng@627 3100 "This is called the <emphasis>commit message</emphasis>. It will be a record "
dongsheng@627 3101 "for readers of what we did and why, and it will be printed by <command role="
dongsheng@627 3102 "\"hg-cmd\">hg log</command> after we've finished committing."
dongsheng@627 3103 msgstr ""
dongsheng@627 3104
dongsheng@627 3105 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3106 #: ../en/ch01-tour-basic.xml:651
dongsheng@627 3107 msgid ""
dongsheng@627 3108 "The editor that the <command role=\"hg-cmd\">hg commit</command> command "
songdongsheng@667 3109 "drops us into will contain an empty line or two, followed by a number of "
songdongsheng@667 3110 "lines starting with <quote><literal>HG:</literal></quote>."
songdongsheng@667 3111 msgstr ""
songdongsheng@667 3112
songdongsheng@667 3113 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3114 #: ../en/ch01-tour-basic.xml:665
dongsheng@627 3115 msgid ""
dongsheng@627 3116 "Mercurial ignores the lines that start with <quote><literal>HG:</literal></"
dongsheng@627 3117 "quote>; it uses them only to tell us which files it's recording changes to. "
dongsheng@627 3118 "Modifying or deleting these lines has no effect."
dongsheng@627 3119 msgstr ""
dongsheng@627 3120
dongsheng@627 3121 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@667 3122 #: ../en/ch01-tour-basic.xml:671
dongsheng@627 3123 msgid "Writing a good commit message"
dongsheng@627 3124 msgstr "写好提交日志"
dongsheng@627 3125
dongsheng@627 3126 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3127 #: ../en/ch01-tour-basic.xml:673
dongsheng@627 3128 msgid ""
dongsheng@627 3129 "Since <command role=\"hg-cmd\">hg log</command> only prints the first line of "
dongsheng@627 3130 "a commit message by default, it's best to write a commit message whose first "
dongsheng@627 3131 "line stands alone. Here's a real example of a commit message that "
dongsheng@627 3132 "<emphasis>doesn't</emphasis> follow this guideline, and hence has a summary "
dongsheng@627 3133 "that is not readable."
dongsheng@627 3134 msgstr ""
dongsheng@627 3135
dongsheng@627 3136 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3137 #: ../en/ch01-tour-basic.xml:687
dongsheng@627 3138 msgid ""
dongsheng@627 3139 "As far as the remainder of the contents of the commit message are concerned, "
dongsheng@627 3140 "there are no hard-and-fast rules. Mercurial itself doesn't interpret or care "
dongsheng@627 3141 "about the contents of the commit message, though your project may have "
dongsheng@627 3142 "policies that dictate a certain kind of formatting."
dongsheng@627 3143 msgstr ""
dongsheng@627 3144
dongsheng@627 3145 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3146 #: ../en/ch01-tour-basic.xml:693
dongsheng@627 3147 msgid ""
dongsheng@627 3148 "My personal preference is for short, but informative, commit messages that "
dongsheng@627 3149 "tell me something that I can't figure out with a quick glance at the output "
dongsheng@627 3150 "of <command role=\"hg-cmd\">hg log --patch</command>."
dongsheng@627 3151 msgstr ""
dongsheng@627 3152
dongsheng@627 3153 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@667 3154 #: ../en/ch01-tour-basic.xml:700
dongsheng@627 3155 msgid "Aborting a commit"
dongsheng@627 3156 msgstr "终止提交"
dongsheng@627 3157
dongsheng@627 3158 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3159 #: ../en/ch01-tour-basic.xml:702
dongsheng@627 3160 msgid ""
dongsheng@627 3161 "If you decide that you don't want to commit while in the middle of editing a "
dongsheng@627 3162 "commit message, simply exit from your editor without saving the file that "
dongsheng@627 3163 "it's editing. This will cause nothing to happen to either the repository or "
dongsheng@627 3164 "the working directory."
dongsheng@627 3165 msgstr ""
dongsheng@627 3166
dongsheng@627 3167 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3168 #: ../en/ch01-tour-basic.xml:707
dongsheng@627 3169 msgid ""
dongsheng@627 3170 "If we run the <command role=\"hg-cmd\">hg commit</command> command without "
dongsheng@627 3171 "any arguments, it records all of the changes we've made, as reported by "
dongsheng@627 3172 "<command role=\"hg-cmd\">hg status</command> and <command role=\"hg-cmd\">hg "
dongsheng@627 3173 "diff</command>."
dongsheng@627 3174 msgstr ""
dongsheng@627 3175
dongsheng@627 3176 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@667 3177 #: ../en/ch01-tour-basic.xml:714
dongsheng@627 3178 msgid "Admiring our new handiwork"
songdongsheng@665 3179 msgstr "欣赏我们的成果"
dongsheng@627 3180
dongsheng@627 3181 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3182 #: ../en/ch01-tour-basic.xml:716
dongsheng@627 3183 msgid ""
dongsheng@627 3184 "Once we've finished the commit, we can use the <command role=\"hg-cmd\">hg "
dongsheng@627 3185 "tip</command> command to display the changeset we just created. This command "
dongsheng@627 3186 "produces output that is identical to <command role=\"hg-cmd\">hg log</"
dongsheng@627 3187 "command>, but it only displays the newest revision in the repository."
dongsheng@627 3188 msgstr ""
dongsheng@627 3189
dongsheng@627 3190 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3191 #: ../en/ch01-tour-basic.xml:725
songdongsheng@667 3192 msgid ""
songdongsheng@667 3193 "We refer to the newest revision in the repository as the <emphasis>tip "
songdongsheng@667 3194 "revision</emphasis>, or simply the <emphasis>tip</emphasis>."
songdongsheng@667 3195 msgstr ""
songdongsheng@667 3196
songdongsheng@667 3197 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3198 #: ../en/ch01-tour-basic.xml:729
songdongsheng@667 3199 msgid ""
songdongsheng@667 3200 "By the way, the <command role=\"hg-cmd\">hg tip</command> command accepts "
songdongsheng@667 3201 "many of the same options as <command role=\"hg-cmd\">hg log</command>, so "
songdongsheng@667 3202 "<option role=\"hg-opt-global\">-v</option> above indicates <quote>be verbose</"
songdongsheng@667 3203 "quote>, <option role=\"hg-opt-tip\">-p</option> specifies <quote>print a "
songdongsheng@667 3204 "patch</quote>. The use of <option role=\"hg-opt-tip\">-p</option> to print "
songdongsheng@667 3205 "patches is another example of the consistent naming we mentioned earlier."
dongsheng@627 3206 msgstr ""
dongsheng@627 3207
dongsheng@627 3208 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@667 3209 #: ../en/ch01-tour-basic.xml:741
dongsheng@627 3210 msgid "Sharing changes"
dongsheng@627 3211 msgstr "共享修改"
dongsheng@627 3212
dongsheng@627 3213 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@667 3214 #: ../en/ch01-tour-basic.xml:743
dongsheng@627 3215 msgid ""
dongsheng@627 3216 "We mentioned earlier that repositories in Mercurial are self-contained. This "
dongsheng@627 3217 "means that the changeset we just created exists only in our <filename class="
dongsheng@627 3218 "\"directory\">my-hello</filename> repository. Let's look at a few ways that "
dongsheng@627 3219 "we can propagate this change into other repositories."
dongsheng@627 3220 msgstr ""
dongsheng@627 3221
dongsheng@627 3222 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@667 3223 #: ../en/ch01-tour-basic.xml:751
dongsheng@627 3224 msgid "Pulling changes from another repository"
dongsheng@627 3225 msgstr "从其它版本库取得修改"
dongsheng@627 3226
dongsheng@627 3227 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3228 #: ../en/ch01-tour-basic.xml:752
dongsheng@627 3229 msgid ""
dongsheng@627 3230 "To get started, let's clone our original <filename class=\"directory\">hello</"
dongsheng@627 3231 "filename> repository, which does not contain the change we just committed. "
dongsheng@627 3232 "We'll call our temporary repository <filename class=\"directory\">hello-pull</"
dongsheng@627 3233 "filename>."
dongsheng@627 3234 msgstr ""
dongsheng@627 3235
dongsheng@627 3236 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3237 #: ../en/ch01-tour-basic.xml:760
dongsheng@627 3238 msgid ""
dongsheng@627 3239 "We'll use the <command role=\"hg-cmd\">hg pull</command> command to bring "
dongsheng@627 3240 "changes from <filename class=\"directory\">my-hello</filename> into <filename "
dongsheng@627 3241 "class=\"directory\">hello-pull</filename>. However, blindly pulling unknown "
dongsheng@627 3242 "changes into a repository is a somewhat scary prospect. Mercurial provides "
dongsheng@627 3243 "the <command role=\"hg-cmd\">hg incoming</command> command to tell us what "
dongsheng@627 3244 "changes the <command role=\"hg-cmd\">hg pull</command> command "
dongsheng@627 3245 "<emphasis>would</emphasis> pull into the repository, without actually pulling "
dongsheng@627 3246 "the changes in."
dongsheng@627 3247 msgstr ""
dongsheng@627 3248
dongsheng@627 3249 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3250 #: ../en/ch01-tour-basic.xml:773
songdongsheng@667 3251 msgid ""
songdongsheng@667 3252 "Suppose you're pulling changes from a repository on the network somewhere. "
songdongsheng@667 3253 "While you are looking at the <command role=\"hg-cmd\">hg incoming</command> "
songdongsheng@667 3254 "output, and before you pull those changes, someone might have committed "
songdongsheng@667 3255 "something in the remote repository. This means that it's possible to pull "
songdongsheng@667 3256 "more changes than you saw when using <command role=\"hg-cmd\">hg incoming</"
songdongsheng@667 3257 "command>."
songdongsheng@667 3258 msgstr ""
songdongsheng@667 3259
songdongsheng@667 3260 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3261 #: ../en/ch01-tour-basic.xml:781
dongsheng@627 3262 msgid ""
dongsheng@627 3263 "Bringing changes into a repository is a simple matter of running the <command "
dongsheng@627 3264 "role=\"hg-cmd\">hg pull</command> command, and telling it which repository to "
dongsheng@627 3265 "pull from."
dongsheng@627 3266 msgstr ""
dongsheng@627 3267
dongsheng@627 3268 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3269 #: ../en/ch01-tour-basic.xml:788
dongsheng@627 3270 msgid ""
dongsheng@627 3271 "As you can see from the before-and-after output of <command role=\"hg-cmd"
dongsheng@627 3272 "\">hg tip</command>, we have successfully pulled changes into our "
dongsheng@627 3273 "repository. There remains one step before we can see these changes in the "
dongsheng@627 3274 "working directory."
dongsheng@627 3275 msgstr ""
dongsheng@627 3276
dongsheng@627 3277 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@667 3278 #: ../en/ch01-tour-basic.xml:796
dongsheng@627 3279 msgid "Updating the working directory"
dongsheng@627 3280 msgstr "更新工作目录"
dongsheng@627 3281
dongsheng@627 3282 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3283 #: ../en/ch01-tour-basic.xml:798
dongsheng@627 3284 msgid ""
dongsheng@627 3285 "We have so far glossed over the relationship between a repository and its "
dongsheng@627 3286 "working directory. The <command role=\"hg-cmd\">hg pull</command> command "
songdongsheng@658 3287 "that we ran in <xref linkend=\"sec:tour:pull\"/> brought changes into the "
songdongsheng@658 3288 "repository, but if we check, there's no sign of those changes in the working "
songdongsheng@658 3289 "directory. This is because <command role=\"hg-cmd\">hg pull</command> does "
songdongsheng@658 3290 "not (by default) touch the working directory. Instead, we use the <command "
songdongsheng@658 3291 "role=\"hg-cmd\">hg update</command> command to do this."
songdongsheng@658 3292 msgstr ""
songdongsheng@658 3293
songdongsheng@658 3294 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3295 #: ../en/ch01-tour-basic.xml:810
dongsheng@627 3296 msgid ""
dongsheng@627 3297 "It might seem a bit strange that <command role=\"hg-cmd\">hg pull</command> "
dongsheng@627 3298 "doesn't update the working directory automatically. There's actually a good "
dongsheng@627 3299 "reason for this: you can use <command role=\"hg-cmd\">hg update</command> to "
dongsheng@627 3300 "update the working directory to the state it was in at <emphasis>any "
dongsheng@627 3301 "revision</emphasis> in the history of the repository. If you had the working "
songdongsheng@668 3302 "directory updated to an old revision&emdash;to hunt down the origin of a bug, "
songdongsheng@668 3303 "say&emdash;and ran a <command role=\"hg-cmd\">hg pull</command> which "
songdongsheng@668 3304 "automatically updated the working directory to a new revision, you might not "
songdongsheng@668 3305 "be terribly happy."
songdongsheng@667 3306 msgstr ""
songdongsheng@667 3307
songdongsheng@667 3308 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3309 #: ../en/ch01-tour-basic.xml:821
dongsheng@627 3310 msgid ""
dongsheng@627 3311 "However, since pull-then-update is such a common thing to do, Mercurial lets "
dongsheng@627 3312 "you combine the two by passing the <option role=\"hg-opt-pull\">-u</option> "
dongsheng@627 3313 "option to <command role=\"hg-cmd\">hg pull</command>."
dongsheng@627 3314 msgstr ""
dongsheng@627 3315
dongsheng@627 3316 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3317 #: ../en/ch01-tour-basic.xml:826
dongsheng@627 3318 msgid ""
dongsheng@627 3319 "If you look back at the output of <command role=\"hg-cmd\">hg pull</command> "
songdongsheng@658 3320 "in <xref linkend=\"sec:tour:pull\"/> when we ran it without <option role=\"hg-"
songdongsheng@658 3321 "opt-pull\">-u</option>, you can see that it printed a helpful reminder that "
songdongsheng@658 3322 "we'd have to take an explicit step to update the working directory:"
songdongsheng@658 3323 msgstr ""
songdongsheng@658 3324
songdongsheng@658 3325 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3326 #: ../en/ch01-tour-basic.xml:835
dongsheng@627 3327 msgid ""
dongsheng@627 3328 "To find out what revision the working directory is at, use the <command role="
dongsheng@627 3329 "\"hg-cmd\">hg parents</command> command."
dongsheng@627 3330 msgstr ""
dongsheng@627 3331
dongsheng@627 3332 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3333 #: ../en/ch01-tour-basic.xml:841
songdongsheng@658 3334 msgid ""
songdongsheng@658 3335 "If you look back at <xref linkend=\"fig:tour-basic:history\"/>, you'll see "
songdongsheng@658 3336 "arrows connecting each changeset. The node that the arrow leads "
songdongsheng@658 3337 "<emphasis>from</emphasis> in each case is a parent, and the node that the "
songdongsheng@658 3338 "arrow leads <emphasis>to</emphasis> is its child. The working directory has "
songdongsheng@658 3339 "a parent in just the same way; this is the changeset that the working "
songdongsheng@658 3340 "directory currently contains."
songdongsheng@658 3341 msgstr ""
songdongsheng@658 3342
songdongsheng@658 3343 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3344 #: ../en/ch01-tour-basic.xml:850
dongsheng@627 3345 msgid ""
dongsheng@627 3346 "To update the working directory to a particular revision, give a revision "
dongsheng@627 3347 "number or changeset ID to the <command role=\"hg-cmd\">hg update</command> "
dongsheng@627 3348 "command."
dongsheng@627 3349 msgstr ""
dongsheng@627 3350
dongsheng@627 3351 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3352 #: ../en/ch01-tour-basic.xml:857
dongsheng@627 3353 msgid ""
dongsheng@627 3354 "If you omit an explicit revision, <command role=\"hg-cmd\">hg update</"
dongsheng@627 3355 "command> will update to the tip revision, as shown by the second call to "
dongsheng@627 3356 "<command role=\"hg-cmd\">hg update</command> in the example above."
dongsheng@627 3357 msgstr ""
dongsheng@627 3358
dongsheng@627 3359 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@667 3360 #: ../en/ch01-tour-basic.xml:865
dongsheng@627 3361 msgid "Pushing changes to another repository"
dongsheng@627 3362 msgstr "发布修改到其它版本库"
dongsheng@627 3363
dongsheng@627 3364 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3365 #: ../en/ch01-tour-basic.xml:867
dongsheng@627 3366 msgid ""
dongsheng@627 3367 "Mercurial lets us push changes to another repository, from the repository "
dongsheng@627 3368 "we're currently visiting. As with the example of <command role=\"hg-cmd\">hg "
dongsheng@627 3369 "pull</command> above, we'll create a temporary repository to push our changes "
dongsheng@627 3370 "into."
dongsheng@627 3371 msgstr ""
dongsheng@627 3372
dongsheng@627 3373 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3374 #: ../en/ch01-tour-basic.xml:875
dongsheng@627 3375 msgid ""
dongsheng@627 3376 "The <command role=\"hg-cmd\">hg outgoing</command> command tells us what "
dongsheng@627 3377 "changes would be pushed into another repository."
dongsheng@627 3378 msgstr ""
dongsheng@627 3379
dongsheng@627 3380 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3381 #: ../en/ch01-tour-basic.xml:881
dongsheng@627 3382 msgid ""
dongsheng@627 3383 "And the <command role=\"hg-cmd\">hg push</command> command does the actual "
dongsheng@627 3384 "push."
dongsheng@627 3385 msgstr ""
dongsheng@627 3386
dongsheng@627 3387 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3388 #: ../en/ch01-tour-basic.xml:887
dongsheng@627 3389 msgid ""
dongsheng@627 3390 "As with <command role=\"hg-cmd\">hg pull</command>, the <command role=\"hg-cmd"
dongsheng@627 3391 "\">hg push</command> command does not update the working directory in the "
songdongsheng@667 3392 "repository that it's pushing changes into. Unlike <command role=\"hg-cmd\">hg "
songdongsheng@667 3393 "pull</command>, <command role=\"hg-cmd\">hg push</command> does not provide a "
songdongsheng@667 3394 "<literal>-u</literal> option that updates the other repository's working "
songdongsheng@667 3395 "directory. This asymmetry is deliberate: the repository we're pushing to "
songdongsheng@667 3396 "might be on a remote server and shared between several people. If we were to "
songdongsheng@667 3397 "update its working directory while someone was working in it, their work "
songdongsheng@667 3398 "would be disrupted."
songdongsheng@667 3399 msgstr ""
songdongsheng@667 3400
songdongsheng@667 3401 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3402 #: ../en/ch01-tour-basic.xml:899
dongsheng@627 3403 msgid ""
dongsheng@627 3404 "What happens if we try to pull or push changes and the receiving repository "
dongsheng@627 3405 "already has those changes? Nothing too exciting."
dongsheng@627 3406 msgstr ""
dongsheng@627 3407
dongsheng@627 3408 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@667 3409 #: ../en/ch01-tour-basic.xml:906
dongsheng@627 3410 msgid "Sharing changes over a network"
dongsheng@627 3411 msgstr "通过网络共享修改"
dongsheng@627 3412
dongsheng@627 3413 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3414 #: ../en/ch01-tour-basic.xml:908
dongsheng@627 3415 msgid ""
dongsheng@627 3416 "The commands we have covered in the previous few sections are not limited to "
dongsheng@627 3417 "working with local repositories. Each works in exactly the same fashion over "
dongsheng@627 3418 "a network connection; simply pass in a URL instead of a local path."
dongsheng@627 3419 msgstr ""
dongsheng@627 3420
dongsheng@627 3421 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3422 #: ../en/ch01-tour-basic.xml:916
dongsheng@627 3423 msgid ""
dongsheng@627 3424 "In this example, we can see what changes we could push to the remote "
dongsheng@627 3425 "repository, but the repository is understandably not set up to let anonymous "
dongsheng@627 3426 "users push to it."
dongsheng@627 3427 msgstr ""
dongsheng@627 3428
dongsheng@627 3429 #. type: Content of: <book><chapter><title>
dongsheng@650 3430 #: ../en/ch02-tour-merge.xml:5
dongsheng@627 3431 msgid "A tour of Mercurial: merging work"
dongsheng@627 3432 msgstr "Mercurial 教程: 合并工作"
dongsheng@627 3433
dongsheng@627 3434 #. type: Content of: <book><chapter><para>
dongsheng@650 3435 #: ../en/ch02-tour-merge.xml:7
dongsheng@627 3436 msgid ""
dongsheng@627 3437 "We've now covered cloning a repository, making changes in a repository, and "
dongsheng@627 3438 "pulling or pushing changes from one repository into another. Our next step "
dongsheng@627 3439 "is <emphasis>merging</emphasis> changes from separate repositories."
dongsheng@627 3440 msgstr ""
dongsheng@627 3441
dongsheng@627 3442 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 3443 #: ../en/ch02-tour-merge.xml:13
dongsheng@627 3444 msgid "Merging streams of work"
dongsheng@627 3445 msgstr "合并的流程"
dongsheng@627 3446
dongsheng@627 3447 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 3448 #: ../en/ch02-tour-merge.xml:15
dongsheng@627 3449 msgid ""
dongsheng@627 3450 "Merging is a fundamental part of working with a distributed revision control "
dongsheng@627 3451 "tool."
dongsheng@627 3452 msgstr ""
dongsheng@627 3453
dongsheng@627 3454 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 3455 #: ../en/ch02-tour-merge.xml:18
dongsheng@627 3456 msgid ""
dongsheng@627 3457 "Alice and Bob each have a personal copy of a repository for a project they're "
dongsheng@627 3458 "collaborating on. Alice fixes a bug in her repository; Bob adds a new "
dongsheng@627 3459 "feature in his. They want the shared repository to contain both the bug fix "
dongsheng@627 3460 "and the new feature."
dongsheng@627 3461 msgstr ""
dongsheng@627 3462
dongsheng@627 3463 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 3464 #: ../en/ch02-tour-merge.xml:24
dongsheng@627 3465 msgid ""
dongsheng@627 3466 "I frequently work on several different tasks for a single project at once, "
dongsheng@627 3467 "each safely isolated in its own repository. Working this way means that I "
dongsheng@627 3468 "often need to merge one piece of my own work with another."
dongsheng@627 3469 msgstr ""
dongsheng@627 3470
dongsheng@627 3471 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 3472 #: ../en/ch02-tour-merge.xml:30
dongsheng@627 3473 msgid ""
dongsheng@627 3474 "Because merging is such a common thing to need to do, Mercurial makes it "
dongsheng@627 3475 "easy. Let's walk through the process. We'll begin by cloning yet another "
dongsheng@627 3476 "repository (see how often they spring up?) and making a change in it."
dongsheng@627 3477 msgstr ""
dongsheng@627 3478
dongsheng@627 3479 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 3480 #: ../en/ch02-tour-merge.xml:37
dongsheng@627 3481 msgid ""
dongsheng@627 3482 "We should now have two copies of <filename>hello.c</filename> with different "
dongsheng@627 3483 "contents. The histories of the two repositories have also diverged, as "
songdongsheng@658 3484 "illustrated in <xref linkend=\"fig:tour-merge:sep-repos\"/>."
songdongsheng@658 3485 msgstr ""
songdongsheng@658 3486
songdongsheng@658 3487 #. type: Content of: <book><chapter><sect1><figure><title>
songdongsheng@658 3488 #: ../en/ch02-tour-merge.xml:46
dongsheng@627 3489 msgid ""
dongsheng@627 3490 "Divergent recent histories of the <filename class=\"directory\">my-hello</"
dongsheng@627 3491 "filename> and <filename class=\"directory\">my-new-hello</filename> "
dongsheng@627 3492 "repositories"
dongsheng@627 3493 msgstr ""
dongsheng@660 3494 "<filename class=\"directory\">my-hello</filename> 与 <filename class="
dongsheng@660 3495 "\"directory\">my-new-hello</filename> 最新的历史分叉"
dongsheng@627 3496
songdongsheng@658 3497 #. type: Content of: <book><chapter><sect1><figure><mediaobject>
songdongsheng@658 3498 #: ../en/ch02-tour-merge.xml:51
songdongsheng@658 3499 msgid ""
songdongsheng@658 3500 "<imageobject><imagedata fileref=\"figs/tour-merge-sep-repos.png\"/></"
songdongsheng@658 3501 "imageobject>"
songdongsheng@658 3502 msgstr ""
songdongsheng@658 3503
songdongsheng@658 3504 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 3505 #: ../en/ch02-tour-merge.xml:56
dongsheng@627 3506 msgid ""
dongsheng@627 3507 "We already know that pulling changes from our <filename class=\"directory"
dongsheng@627 3508 "\">my-hello</filename> repository will have no effect on the working "
dongsheng@627 3509 "directory."
dongsheng@627 3510 msgstr ""
dongsheng@627 3511
dongsheng@627 3512 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 3513 #: ../en/ch02-tour-merge.xml:62
dongsheng@627 3514 msgid ""
dongsheng@627 3515 "However, the <command role=\"hg-cmd\">hg pull</command> command says "
dongsheng@627 3516 "something about <quote>heads</quote>."
dongsheng@627 3517 msgstr ""
dongsheng@627 3518
dongsheng@627 3519 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 3520 #: ../en/ch02-tour-merge.xml:66
dongsheng@627 3521 msgid "Head changesets"
songdongsheng@665 3522 msgstr "顶点修改集"
dongsheng@627 3523
dongsheng@627 3524 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 3525 #: ../en/ch02-tour-merge.xml:68
dongsheng@627 3526 msgid ""
dongsheng@627 3527 "A head is a change that has no descendants, or children, as they're also "
dongsheng@627 3528 "known. The tip revision is thus a head, because the newest revision in a "
dongsheng@627 3529 "repository doesn't have any children, but a repository can contain more than "
dongsheng@627 3530 "one head."
dongsheng@627 3531 msgstr ""
dongsheng@627 3532
songdongsheng@658 3533 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
songdongsheng@658 3534 #: ../en/ch02-tour-merge.xml:75
dongsheng@627 3535 msgid ""
dongsheng@627 3536 "Repository contents after pulling from <filename class=\"directory\">my-"
dongsheng@627 3537 "hello</filename> into <filename class=\"directory\">my-new-hello</filename>"
dongsheng@627 3538 msgstr ""
dongsheng@660 3539 "从 <filename class=\"directory\">my-hello</filename> 拉到 <filename class="
dongsheng@660 3540 "\"directory\">my-new-hello</filename> 之后版本库的内容"
dongsheng@627 3541
songdongsheng@658 3542 #. type: Content of: <book><chapter><sect1><sect2><figure>
songdongsheng@710 3543 #: ../en/ch02-tour-merge.xml:78 ../en/ch02-tour-merge.xml:159
songdongsheng@710 3544 #: ../en/ch02-tour-merge.xml:256 ../en/ch03-concepts.xml:57
songdongsheng@710 3545 #: ../en/ch03-concepts.xml:106 ../en/ch03-concepts.xml:191
songdongsheng@710 3546 #: ../en/ch03-concepts.xml:346 ../en/ch03-concepts.xml:361
songdongsheng@710 3547 #: ../en/ch03-concepts.xml:402 ../en/ch03-concepts.xml:422
songdongsheng@710 3548 #: ../en/ch03-concepts.xml:463 ../en/ch05-collab.xml:320
songdongsheng@658 3549 #: ../en/ch08-undo.xml:363 ../en/ch08-undo.xml:410 ../en/ch08-undo.xml:475
songdongsheng@658 3550 #: ../en/ch08-undo.xml:513 ../en/ch11-mq.xml:410
songdongsheng@658 3551 msgid " <placeholder type=\"mediaobject\" id=\"0\"/>"
songdongsheng@658 3552 msgstr ""
songdongsheng@658 3553
songdongsheng@658 3554 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
songdongsheng@658 3555 #: ../en/ch02-tour-merge.xml:79
songdongsheng@658 3556 msgid ""
songdongsheng@658 3557 "<imageobject> <imagedata fileref=\"figs/tour-merge-pull.png\"/> </imageobject>"
songdongsheng@658 3558 msgstr ""
songdongsheng@658 3559
songdongsheng@658 3560 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 3561 #: ../en/ch02-tour-merge.xml:86
songdongsheng@658 3562 msgid ""
songdongsheng@658 3563 "In <xref linkend=\"fig:tour-merge:pull\"/>, you can see the effect of the "
songdongsheng@658 3564 "pull from <filename class=\"directory\">my-hello</filename> into <filename "
songdongsheng@658 3565 "class=\"directory\">my-new-hello</filename>. The history that was already "
songdongsheng@658 3566 "present in <filename class=\"directory\">my-new-hello</filename> is "
songdongsheng@658 3567 "untouched, but a new revision has been added. By referring to <xref linkend="
songdongsheng@658 3568 "\"fig:tour-merge:sep-repos\"/>, we can see that the <emphasis>changeset ID</"
songdongsheng@658 3569 "emphasis> remains the same in the new repository, but the <emphasis>revision "
songdongsheng@658 3570 "number</emphasis> has changed. (This, incidentally, is a fine example of why "
songdongsheng@658 3571 "it's not safe to use revision numbers when discussing changesets.) We can "
songdongsheng@658 3572 "view the heads in a repository using the <command role=\"hg-cmd\">hg heads</"
songdongsheng@658 3573 "command> command."
dongsheng@627 3574 msgstr ""
dongsheng@627 3575
dongsheng@627 3576 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 3577 #: ../en/ch02-tour-merge.xml:105
dongsheng@627 3578 msgid "Performing the merge"
dongsheng@627 3579 msgstr "执行合并"
dongsheng@627 3580
dongsheng@627 3581 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 3582 #: ../en/ch02-tour-merge.xml:107
dongsheng@627 3583 msgid ""
dongsheng@627 3584 "What happens if we try to use the normal <command role=\"hg-cmd\">hg update</"
dongsheng@627 3585 "command> command to update to the new tip?"
dongsheng@627 3586 msgstr ""
dongsheng@627 3587
dongsheng@627 3588 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 3589 #: ../en/ch02-tour-merge.xml:113
dongsheng@627 3590 msgid ""
dongsheng@627 3591 "Mercurial is telling us that the <command role=\"hg-cmd\">hg update</command> "
dongsheng@627 3592 "command won't do a merge; it won't update the working directory when it "
songdongsheng@710 3593 "thinks we might want to do a merge, unless we force it to do so. Instead, we "
songdongsheng@710 3594 "use the <command role=\"hg-cmd\">hg merge</command> command to merge the two "
songdongsheng@710 3595 "heads."
songdongsheng@710 3596 msgstr ""
songdongsheng@710 3597
songdongsheng@710 3598 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 3599 #: ../en/ch02-tour-merge.xml:122
dongsheng@627 3600 msgid ""
dongsheng@627 3601 "This updates the working directory so that it contains changes from "
dongsheng@627 3602 "<emphasis>both</emphasis> heads, which is reflected in both the output of "
dongsheng@627 3603 "<command role=\"hg-cmd\">hg parents</command> and the contents of "
dongsheng@627 3604 "<filename>hello.c</filename>."
dongsheng@627 3605 msgstr ""
dongsheng@627 3606
dongsheng@627 3607 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 3608 #: ../en/ch02-tour-merge.xml:132
dongsheng@627 3609 msgid "Committing the results of the merge"
dongsheng@627 3610 msgstr "提交合并结果"
dongsheng@627 3611
dongsheng@627 3612 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 3613 #: ../en/ch02-tour-merge.xml:134
dongsheng@627 3614 msgid ""
dongsheng@627 3615 "Whenever we've done a merge, <command role=\"hg-cmd\">hg parents</command> "
dongsheng@627 3616 "will display two parents until we <command role=\"hg-cmd\">hg commit</"
dongsheng@627 3617 "command> the results of the merge."
dongsheng@627 3618 msgstr ""
dongsheng@627 3619
dongsheng@627 3620 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 3621 #: ../en/ch02-tour-merge.xml:141
dongsheng@627 3622 msgid ""
dongsheng@627 3623 "We now have a new tip revision; notice that it has <emphasis>both</emphasis> "
dongsheng@627 3624 "of our former heads as its parents. These are the same revisions that were "
dongsheng@627 3625 "previously displayed by <command role=\"hg-cmd\">hg parents</command>."
dongsheng@627 3626 msgstr ""
dongsheng@627 3627
dongsheng@627 3628 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 3629 #: ../en/ch02-tour-merge.xml:148
songdongsheng@658 3630 msgid ""
songdongsheng@658 3631 "In <xref linkend=\"fig:tour-merge:merge\"/>, you can see a representation of "
songdongsheng@658 3632 "what happens to the working directory during the merge, and how this affects "
songdongsheng@658 3633 "the repository when the commit happens. During the merge, the working "
songdongsheng@658 3634 "directory has two parent changesets, and these become the parents of the new "
songdongsheng@658 3635 "changeset."
dongsheng@627 3636 msgstr ""
dongsheng@627 3637
songdongsheng@710 3638 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
songdongsheng@710 3639 #: ../en/ch02-tour-merge.xml:157
songdongsheng@710 3640 msgid "Working directory and repository during merge, and following commit"
songdongsheng@710 3641 msgstr "在合并期间,以及提交之后的工作目录与版本库"
songdongsheng@710 3642
songdongsheng@710 3643 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
songdongsheng@710 3644 #: ../en/ch02-tour-merge.xml:160
songdongsheng@710 3645 msgid ""
songdongsheng@710 3646 "<imageobject> <imagedata fileref=\"figs/tour-merge-merge.png\"/> </"
songdongsheng@710 3647 "imageobject>"
songdongsheng@710 3648 msgstr ""
songdongsheng@710 3649
songdongsheng@710 3650 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 3651 #: ../en/ch02-tour-merge.xml:167
songdongsheng@710 3652 msgid ""
songdongsheng@710 3653 "We sometimes talk about a merge having <emphasis>sides</emphasis>: the left "
songdongsheng@710 3654 "side is the first parent in the output of <command role=\"hg-cmd\">hg "
songdongsheng@710 3655 "parents</command>, and the right side is the second. If the working "
songdongsheng@710 3656 "directory was at e.g. revision 5 before we began a merge, that revision will "
songdongsheng@710 3657 "become the left side of the merge."
songdongsheng@710 3658 msgstr ""
songdongsheng@710 3659
dongsheng@627 3660 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@710 3661 #: ../en/ch02-tour-merge.xml:177
dongsheng@627 3662 msgid "Merging conflicting changes"
dongsheng@627 3663 msgstr "合并有冲突的改变"
dongsheng@627 3664
dongsheng@627 3665 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 3666 #: ../en/ch02-tour-merge.xml:179
dongsheng@627 3667 msgid ""
dongsheng@627 3668 "Most merges are simple affairs, but sometimes you'll find yourself merging "
songdongsheng@710 3669 "changes where each side modifies the same portions of the same files. Unless "
songdongsheng@710 3670 "both modifications are identical, this results in a <emphasis>conflict</"
songdongsheng@710 3671 "emphasis>, where you have to decide how to reconcile the different changes "
songdongsheng@710 3672 "into something coherent."
dongsheng@627 3673 msgstr ""
dongsheng@627 3674
songdongsheng@658 3675 #. type: Content of: <book><chapter><sect1><figure><title>
songdongsheng@710 3676 #: ../en/ch02-tour-merge.xml:187
songdongsheng@658 3677 msgid "Conflicting changes to a document"
dongsheng@660 3678 msgstr "冲突的修改"
songdongsheng@658 3679
songdongsheng@658 3680 #. type: Content of: <book><chapter><sect1><figure><mediaobject>
songdongsheng@710 3681 #: ../en/ch02-tour-merge.xml:189
songdongsheng@658 3682 msgid ""
songdongsheng@658 3683 "<imageobject><imagedata fileref=\"figs/tour-merge-conflict.png\"/></"
dongsheng@627 3684 "imageobject>"
dongsheng@627 3685 msgstr ""
dongsheng@627 3686
songdongsheng@658 3687 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 3688 #: ../en/ch02-tour-merge.xml:194
songdongsheng@658 3689 msgid ""
songdongsheng@658 3690 "<xref linkend=\"fig:tour-merge:conflict\"/> illustrates an instance of two "
songdongsheng@658 3691 "conflicting changes to a document. We started with a single version of the "
songdongsheng@658 3692 "file; then we made some changes; while someone else made different changes to "
songdongsheng@658 3693 "the same text. Our task in resolving the conflicting changes is to decide "
songdongsheng@658 3694 "what the file should look like."
songdongsheng@658 3695 msgstr ""
songdongsheng@658 3696
songdongsheng@658 3697 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 3698 #: ../en/ch02-tour-merge.xml:201
dongsheng@627 3699 msgid ""
dongsheng@627 3700 "Mercurial doesn't have a built-in facility for handling conflicts. Instead, "
songdongsheng@710 3701 "it runs an external program, usually one that displays some kind of graphical "
songdongsheng@710 3702 "conflict resolution interface. By default, Mercurial tries to find one of "
songdongsheng@710 3703 "several different merging tools that are likely to be installed on your "
songdongsheng@710 3704 "system. It first tries a few fully automatic merging tools; if these don't "
songdongsheng@710 3705 "succeed (because the resolution process requires human guidance) or aren't "
songdongsheng@710 3706 "present, it tries a few different graphical merging tools."
songdongsheng@710 3707 msgstr ""
songdongsheng@710 3708
songdongsheng@710 3709 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 3710 #: ../en/ch02-tour-merge.xml:211
dongsheng@627 3711 msgid ""
dongsheng@627 3712 "It's also possible to get Mercurial to run another program or script instead "
dongsheng@627 3713 "of <command>hgmerge</command>, by setting the <envar>HGMERGE</envar> "
dongsheng@627 3714 "environment variable to the name of your preferred program."
dongsheng@627 3715 msgstr ""
dongsheng@627 3716
dongsheng@627 3717 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 3718 #: ../en/ch02-tour-merge.xml:217
dongsheng@627 3719 msgid "Using a graphical merge tool"
dongsheng@627 3720 msgstr "使用图形合并工具"
dongsheng@627 3721
dongsheng@627 3722 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 3723 #: ../en/ch02-tour-merge.xml:219
dongsheng@627 3724 msgid ""
dongsheng@627 3725 "My preferred graphical merge tool is <command>kdiff3</command>, which I'll "
dongsheng@627 3726 "use to describe the features that are common to graphical file merging "
dongsheng@627 3727 "tools. You can see a screenshot of <command>kdiff3</command> in action in "
songdongsheng@658 3728 "<xref linkend=\"fig:tour-merge:kdiff3\"/>. The kind of merge it is "
songdongsheng@658 3729 "performing is called a <emphasis>three-way merge</emphasis>, because there "
songdongsheng@658 3730 "are three different versions of the file of interest to us. The tool thus "
songdongsheng@658 3731 "splits the upper portion of the window into three panes:"
dongsheng@627 3732 msgstr ""
dongsheng@627 3733
dongsheng@627 3734 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@710 3735 #: ../en/ch02-tour-merge.xml:229
dongsheng@627 3736 msgid ""
dongsheng@627 3737 "At the left is the <emphasis>base</emphasis> version of the file, i.e. the "
dongsheng@627 3738 "most recent version from which the two versions we're trying to merge are "
dongsheng@627 3739 "descended."
dongsheng@627 3740 msgstr ""
dongsheng@627 3741
dongsheng@627 3742 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@710 3743 #: ../en/ch02-tour-merge.xml:234
dongsheng@627 3744 msgid ""
dongsheng@627 3745 "In the middle is <quote>our</quote> version of the file, with the contents "
dongsheng@627 3746 "that we modified."
dongsheng@627 3747 msgstr ""
dongsheng@627 3748
dongsheng@627 3749 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@710 3750 #: ../en/ch02-tour-merge.xml:237
dongsheng@627 3751 msgid ""
dongsheng@627 3752 "On the right is <quote>their</quote> version of the file, the one that from "
dongsheng@627 3753 "the changeset that we're trying to merge with."
dongsheng@627 3754 msgstr ""
dongsheng@627 3755
dongsheng@627 3756 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 3757 #: ../en/ch02-tour-merge.xml:241
dongsheng@627 3758 msgid ""
dongsheng@627 3759 "In the pane below these is the current <emphasis>result</emphasis> of the "
dongsheng@627 3760 "merge. Our task is to replace all of the red text, which indicates unresolved "
dongsheng@627 3761 "conflicts, with some sensible merger of the <quote>ours</quote> and "
dongsheng@627 3762 "<quote>theirs</quote> versions of the file."
dongsheng@627 3763 msgstr ""
dongsheng@627 3764
dongsheng@627 3765 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 3766 #: ../en/ch02-tour-merge.xml:248
dongsheng@627 3767 msgid ""
dongsheng@627 3768 "All four of these panes are <emphasis>locked together</emphasis>; if we "
dongsheng@627 3769 "scroll vertically or horizontally in any of them, the others are updated to "
dongsheng@627 3770 "display the corresponding sections of their respective files."
dongsheng@627 3771 msgstr ""
dongsheng@627 3772
songdongsheng@658 3773 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
songdongsheng@710 3774 #: ../en/ch02-tour-merge.xml:254
songdongsheng@658 3775 msgid "Using <command>kdiff3</command> to merge versions of a file"
dongsheng@660 3776 msgstr "使用 <command>kdiff3</command> 合并文件的不同版本"
songdongsheng@658 3777
songdongsheng@658 3778 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
songdongsheng@710 3779 #: ../en/ch02-tour-merge.xml:257
songdongsheng@658 3780 msgid ""
songdongsheng@658 3781 "<imageobject> <imagedata width=\"100%\" fileref=\"figs/kdiff3.png\"/></"
dongsheng@630 3782 "imageobject>"
dongsheng@627 3783 msgstr ""
dongsheng@627 3784
songdongsheng@658 3785 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 3786 #: ../en/ch02-tour-merge.xml:265
dongsheng@627 3787 msgid ""
dongsheng@627 3788 "For each conflicting portion of the file, we can choose to resolve the "
dongsheng@627 3789 "conflict using some combination of text from the base version, ours, or "
dongsheng@627 3790 "theirs. We can also manually edit the merged file at any time, in case we "
dongsheng@627 3791 "need to make further modifications."
dongsheng@627 3792 msgstr ""
dongsheng@627 3793
dongsheng@627 3794 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 3795 #: ../en/ch02-tour-merge.xml:271
dongsheng@627 3796 msgid ""
dongsheng@627 3797 "There are <emphasis>many</emphasis> file merging tools available, too many to "
dongsheng@627 3798 "cover here. They vary in which platforms they are available for, and in "
dongsheng@627 3799 "their particular strengths and weaknesses. Most are tuned for merging files "
dongsheng@627 3800 "containing plain text, while a few are aimed at specialised file formats "
dongsheng@627 3801 "(generally XML)."
dongsheng@627 3802 msgstr ""
dongsheng@627 3803
dongsheng@627 3804 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 3805 #: ../en/ch02-tour-merge.xml:280
dongsheng@627 3806 msgid "A worked example"
dongsheng@627 3807 msgstr "合并实例"
dongsheng@627 3808
dongsheng@627 3809 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 3810 #: ../en/ch02-tour-merge.xml:282
songdongsheng@658 3811 msgid ""
songdongsheng@658 3812 "In this example, we will reproduce the file modification history of <xref "
songdongsheng@658 3813 "linkend=\"fig:tour-merge:conflict\"/> above. Let's begin by creating a "
songdongsheng@658 3814 "repository with a base version of our document."
songdongsheng@658 3815 msgstr ""
songdongsheng@658 3816
songdongsheng@658 3817 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 3818 #: ../en/ch02-tour-merge.xml:289
dongsheng@627 3819 msgid "We'll clone the repository and make a change to the file."
dongsheng@627 3820 msgstr ""
dongsheng@627 3821
dongsheng@627 3822 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 3823 #: ../en/ch02-tour-merge.xml:294
dongsheng@627 3824 msgid ""
dongsheng@627 3825 "And another clone, to simulate someone else making a change to the file. "
dongsheng@627 3826 "(This hints at the idea that it's not all that unusual to merge with yourself "
dongsheng@627 3827 "when you isolate tasks in separate repositories, and indeed to find and "
dongsheng@627 3828 "resolve conflicts while doing so.)"
dongsheng@627 3829 msgstr ""
dongsheng@627 3830
dongsheng@627 3831 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 3832 #: ../en/ch02-tour-merge.xml:302
dongsheng@627 3833 msgid ""
dongsheng@627 3834 "Having created two different versions of the file, we'll set up an "
dongsheng@627 3835 "environment suitable for running our merge."
dongsheng@627 3836 msgstr ""
dongsheng@627 3837
dongsheng@627 3838 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 3839 #: ../en/ch02-tour-merge.xml:308
songdongsheng@710 3840 msgid ""
songdongsheng@710 3841 "In this example, I'll set <envar>HGMERGE</envar> to tell Mercurial to use the "
songdongsheng@710 3842 "non-interactive <command>merge</command> command. This is bundled with many "
songdongsheng@710 3843 "Unix-like systems. (If you're following this example on your computer, don't "
songdongsheng@710 3844 "bother setting <envar>HGMERGE</envar>.)"
dongsheng@627 3845 msgstr ""
dongsheng@627 3846
dongsheng@627 3847 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 3848 #: ../en/ch02-tour-merge.xml:317
dongsheng@627 3849 msgid ""
dongsheng@627 3850 "Because <command>merge</command> can't resolve the conflicting changes, it "
dongsheng@627 3851 "leaves <emphasis>merge markers</emphasis> inside the file that has conflicts, "
dongsheng@627 3852 "indicating which lines have conflicts, and whether they came from our version "
dongsheng@627 3853 "of the file or theirs."
dongsheng@627 3854 msgstr ""
dongsheng@627 3855
dongsheng@627 3856 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 3857 #: ../en/ch02-tour-merge.xml:323
dongsheng@627 3858 msgid ""
dongsheng@627 3859 "Mercurial can tell from the way <command>merge</command> exits that it wasn't "
dongsheng@627 3860 "able to merge successfully, so it tells us what commands we'll need to run if "
dongsheng@627 3861 "we want to redo the merging operation. This could be useful if, for example, "
dongsheng@627 3862 "we were running a graphical merge tool and quit because we were confused or "
dongsheng@627 3863 "realised we had made a mistake."
dongsheng@627 3864 msgstr ""
dongsheng@627 3865
dongsheng@627 3866 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 3867 #: ../en/ch02-tour-merge.xml:330
dongsheng@627 3868 msgid ""
dongsheng@627 3869 "If automatic or manual merges fail, there's nothing to prevent us from "
dongsheng@627 3870 "<quote>fixing up</quote> the affected files ourselves, and committing the "
dongsheng@627 3871 "results of our merge:"
dongsheng@627 3872 msgstr ""
dongsheng@627 3873
dongsheng@627 3874 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@658 3875 #: ../en/ch02-tour-merge.xml:339
dongsheng@627 3876 msgid "Simplifying the pull-merge-commit sequence"
dongsheng@627 3877 msgstr "简化拉-合并-提交程序"
dongsheng@627 3878
dongsheng@627 3879 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 3880 #: ../en/ch02-tour-merge.xml:341
dongsheng@627 3881 msgid ""
dongsheng@627 3882 "The process of merging changes as outlined above is straightforward, but "
dongsheng@627 3883 "requires running three commands in sequence."
dongsheng@627 3884 msgstr ""
dongsheng@627 3885
dongsheng@627 3886 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 3887 #: ../en/ch02-tour-merge.xml:347
dongsheng@627 3888 msgid ""
dongsheng@627 3889 "In the case of the final commit, you also need to enter a commit message, "
dongsheng@627 3890 "which is almost always going to be a piece of uninteresting "
dongsheng@627 3891 "<quote>boilerplate</quote> text."
dongsheng@627 3892 msgstr ""
dongsheng@627 3893
dongsheng@627 3894 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 3895 #: ../en/ch02-tour-merge.xml:351
dongsheng@627 3896 msgid ""
dongsheng@627 3897 "It would be nice to reduce the number of steps needed, if this were "
dongsheng@627 3898 "possible. Indeed, Mercurial is distributed with an extension called <literal "
dongsheng@627 3899 "role=\"hg-ext\">fetch</literal> that does just this."
dongsheng@627 3900 msgstr ""
dongsheng@627 3901
dongsheng@627 3902 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 3903 #: ../en/ch02-tour-merge.xml:356
dongsheng@627 3904 msgid ""
dongsheng@627 3905 "Mercurial provides a flexible extension mechanism that lets people extend its "
dongsheng@627 3906 "functionality, while keeping the core of Mercurial small and easy to deal "
dongsheng@627 3907 "with. Some extensions add new commands that you can use from the command "
dongsheng@627 3908 "line, while others work <quote>behind the scenes,</quote> for example adding "
dongsheng@627 3909 "capabilities to the server."
dongsheng@627 3910 msgstr ""
dongsheng@627 3911
dongsheng@627 3912 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 3913 #: ../en/ch02-tour-merge.xml:363
dongsheng@627 3914 msgid ""
dongsheng@627 3915 "The <literal role=\"hg-ext\">fetch</literal> extension adds a new command "
dongsheng@627 3916 "called, not surprisingly, <command role=\"hg-cmd\">hg fetch</command>. This "
songdongsheng@710 3917 "extension acts as a combination of <command role=\"hg-cmd\">hg pull -u</"
songdongsheng@710 3918 "command>, <command role=\"hg-cmd\">hg merge</command> and <command role=\"hg-"
songdongsheng@710 3919 "cmd\">hg commit</command>. It begins by pulling changes from another "
dongsheng@627 3920 "repository into the current repository. If it finds that the changes added a "
songdongsheng@710 3921 "new head to the repository, it begins a merge, then (if the merge succeeded) "
songdongsheng@710 3922 "commits the result of the merge with an automatically-generated commit "
songdongsheng@710 3923 "message. If no new heads were added, it updates the working directory to the "
songdongsheng@710 3924 "new tip changeset."
dongsheng@627 3925 msgstr ""
dongsheng@627 3926
dongsheng@627 3927 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 3928 #: ../en/ch02-tour-merge.xml:376
dongsheng@627 3929 msgid ""
dongsheng@627 3930 "Enabling the <literal role=\"hg-ext\">fetch</literal> extension is easy. "
songdongsheng@710 3931 "Edit the <filename role=\"special\">.hgrc</filename> file in your home "
songdongsheng@710 3932 "directory, and either go to the <literal role=\"rc-extensions\">extensions</"
songdongsheng@710 3933 "literal> section or create an <literal role=\"rc-extensions\">extensions</"
songdongsheng@710 3934 "literal> section. Then add a line that simply reads <quote><literal>fetch=</"
songdongsheng@710 3935 "literal></quote>."
songdongsheng@710 3936 msgstr ""
songdongsheng@710 3937
songdongsheng@710 3938 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 3939 #: ../en/ch02-tour-merge.xml:388
songdongsheng@710 3940 msgid ""
songdongsheng@710 3941 "(Normally, the right-hand side of the <quote><literal>=</literal></quote> "
songdongsheng@710 3942 "would indicate where to find the extension, but since the <literal role=\"hg-"
dongsheng@627 3943 "ext\">fetch</literal> extension is in the standard distribution, Mercurial "
dongsheng@627 3944 "knows where to search for it.)"
dongsheng@627 3945 msgstr ""
dongsheng@627 3946
dongsheng@627 3947 #. type: Content of: <book><chapter><title>
dongsheng@650 3948 #: ../en/ch03-concepts.xml:5
dongsheng@627 3949 msgid "Behind the scenes"
dongsheng@627 3950 msgstr "Mercurial 内幕"
dongsheng@627 3951
dongsheng@627 3952 #. type: Content of: <book><chapter><para>
dongsheng@650 3953 #: ../en/ch03-concepts.xml:7
dongsheng@627 3954 msgid ""
dongsheng@627 3955 "Unlike many revision control systems, the concepts upon which Mercurial is "
dongsheng@627 3956 "built are simple enough that it's easy to understand how the software really "
songdongsheng@710 3957 "works. Knowing these details certainly isn't necessary, so it is certainly "
songdongsheng@710 3958 "safe to skip this chapter. However, I think you will get more out of the "
songdongsheng@710 3959 "software with a <quote>mental model</quote> of what's going on."
dongsheng@627 3960 msgstr ""
dongsheng@627 3961
dongsheng@627 3962 #. type: Content of: <book><chapter><para>
songdongsheng@710 3963 #: ../en/ch03-concepts.xml:14
songdongsheng@710 3964 msgid ""
songdongsheng@710 3965 "Being able to understand what's going on behind the scenes gives me "
songdongsheng@710 3966 "confidence that Mercurial has been carefully designed to be both "
songdongsheng@710 3967 "<emphasis>safe</emphasis> and <emphasis>efficient</emphasis>. And just as "
songdongsheng@710 3968 "importantly, if it's easy for me to retain a good idea of what the software "
songdongsheng@710 3969 "is doing when I perform a revision control task, I'm less likely to be "
songdongsheng@710 3970 "surprised by its behavior."
dongsheng@627 3971 msgstr ""
dongsheng@627 3972
dongsheng@627 3973 #. type: Content of: <book><chapter><para>
songdongsheng@710 3974 #: ../en/ch03-concepts.xml:22
dongsheng@627 3975 msgid ""
dongsheng@627 3976 "In this chapter, we'll initially cover the core concepts behind Mercurial's "
dongsheng@627 3977 "design, then continue to discuss some of the interesting details of its "
dongsheng@627 3978 "implementation."
dongsheng@627 3979 msgstr ""
dongsheng@627 3980
dongsheng@627 3981 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@710 3982 #: ../en/ch03-concepts.xml:27
dongsheng@627 3983 msgid "Mercurial's historical record"
dongsheng@627 3984 msgstr "Mercurial 的历史记录"
dongsheng@627 3985
dongsheng@627 3986 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 3987 #: ../en/ch03-concepts.xml:30
dongsheng@627 3988 msgid "Tracking the history of a single file"
dongsheng@627 3989 msgstr "跟踪单一文件的历史"
dongsheng@627 3990
dongsheng@627 3991 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 3992 #: ../en/ch03-concepts.xml:32
dongsheng@627 3993 msgid ""
dongsheng@627 3994 "When Mercurial tracks modifications to a file, it stores the history of that "
dongsheng@627 3995 "file in a metadata object called a <emphasis>filelog</emphasis>. Each entry "
dongsheng@627 3996 "in the filelog contains enough information to reconstruct one revision of the "
dongsheng@627 3997 "file that is being tracked. Filelogs are stored as files in the <filename "
dongsheng@627 3998 "role=\"special\" class=\"directory\">.hg/store/data</filename> directory. A "
dongsheng@627 3999 "filelog contains two kinds of information: revision data, and an index to "
dongsheng@627 4000 "help Mercurial to find a revision efficiently."
dongsheng@627 4001 msgstr ""
dongsheng@627 4002
dongsheng@627 4003 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 4004 #: ../en/ch03-concepts.xml:43
dongsheng@627 4005 msgid ""
dongsheng@627 4006 "A file that is large, or has a lot of history, has its filelog stored in "
dongsheng@627 4007 "separate data (<quote><literal>.d</literal></quote> suffix) and index "
dongsheng@627 4008 "(<quote><literal>.i</literal></quote> suffix) files. For small files without "
dongsheng@627 4009 "much history, the revision data and index are combined in a single "
dongsheng@627 4010 "<quote><literal>.i</literal></quote> file. The correspondence between a file "
dongsheng@627 4011 "in the working directory and the filelog that tracks its history in the "
songdongsheng@658 4012 "repository is illustrated in <xref linkend=\"fig:concepts:filelog\"/>."
songdongsheng@658 4013 msgstr ""
songdongsheng@658 4014
songdongsheng@658 4015 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
songdongsheng@710 4016 #: ../en/ch03-concepts.xml:55
dongsheng@627 4017 msgid ""
dongsheng@627 4018 "Relationships between files in working directory and filelogs in repository"
dongsheng@660 4019 msgstr "工作目录中的文件与版本库中的文件日志之间的关系"
dongsheng@627 4020
songdongsheng@658 4021 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
songdongsheng@710 4022 #: ../en/ch03-concepts.xml:58
songdongsheng@658 4023 msgid "<imageobject><imagedata fileref=\"figs/filelog.png\"/></imageobject>"
songdongsheng@658 4024 msgstr ""
songdongsheng@658 4025
dongsheng@627 4026 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 4027 #: ../en/ch03-concepts.xml:65
dongsheng@627 4028 msgid "Managing tracked files"
dongsheng@627 4029 msgstr "管理跟踪的文件"
dongsheng@627 4030
dongsheng@627 4031 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 4032 #: ../en/ch03-concepts.xml:67
dongsheng@627 4033 msgid ""
dongsheng@627 4034 "Mercurial uses a structure called a <emphasis>manifest</emphasis> to collect "
dongsheng@627 4035 "together information about the files that it tracks. Each entry in the "
dongsheng@627 4036 "manifest contains information about the files present in a single changeset. "
dongsheng@627 4037 "An entry records which files are present in the changeset, the revision of "
dongsheng@627 4038 "each file, and a few other pieces of file metadata."
dongsheng@627 4039 msgstr ""
dongsheng@627 4040
dongsheng@627 4041 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 4042 #: ../en/ch03-concepts.xml:77
dongsheng@627 4043 msgid "Recording changeset information"
dongsheng@627 4044 msgstr "记录修改集信息"
dongsheng@627 4045
dongsheng@627 4046 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 4047 #: ../en/ch03-concepts.xml:79
dongsheng@627 4048 msgid ""
dongsheng@627 4049 "The <emphasis>changelog</emphasis> contains information about each "
dongsheng@627 4050 "changeset. Each revision records who committed a change, the changeset "
dongsheng@627 4051 "comment, other pieces of changeset-related information, and the revision of "
dongsheng@627 4052 "the manifest to use."
dongsheng@627 4053 msgstr ""
dongsheng@627 4054
dongsheng@627 4055 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 4056 #: ../en/ch03-concepts.xml:87
dongsheng@627 4057 msgid "Relationships between revisions"
dongsheng@627 4058 msgstr "版本之间的关系"
dongsheng@627 4059
dongsheng@627 4060 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 4061 #: ../en/ch03-concepts.xml:89
dongsheng@627 4062 msgid ""
dongsheng@627 4063 "Within a changelog, a manifest, or a filelog, each revision stores a pointer "
dongsheng@627 4064 "to its immediate parent (or to its two parents, if it's a merge revision). "
dongsheng@627 4065 "As I mentioned above, there are also relationships between revisions "
dongsheng@627 4066 "<emphasis>across</emphasis> these structures, and they are hierarchical in "
dongsheng@627 4067 "nature."
dongsheng@627 4068 msgstr ""
dongsheng@627 4069
dongsheng@627 4070 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 4071 #: ../en/ch03-concepts.xml:96
dongsheng@627 4072 msgid ""
dongsheng@627 4073 "For every changeset in a repository, there is exactly one revision stored in "
dongsheng@627 4074 "the changelog. Each revision of the changelog contains a pointer to a single "
dongsheng@627 4075 "revision of the manifest. A revision of the manifest stores a pointer to a "
dongsheng@627 4076 "single revision of each filelog tracked when that changeset was created. "
songdongsheng@658 4077 "These relationships are illustrated in <xref linkend=\"fig:concepts:metadata"
songdongsheng@658 4078 "\"/>."
songdongsheng@658 4079 msgstr ""
songdongsheng@658 4080
songdongsheng@658 4081 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
songdongsheng@710 4082 #: ../en/ch03-concepts.xml:105
dongsheng@627 4083 msgid "Metadata relationships"
dongsheng@660 4084 msgstr "元数据之间的关系"
dongsheng@627 4085
songdongsheng@658 4086 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
songdongsheng@710 4087 #: ../en/ch03-concepts.xml:107
songdongsheng@658 4088 msgid "<imageobject><imagedata fileref=\"figs/metadata.png\"/></imageobject>"
songdongsheng@658 4089 msgstr ""
songdongsheng@658 4090
songdongsheng@658 4091 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 4092 #: ../en/ch03-concepts.xml:112
dongsheng@627 4093 msgid ""
dongsheng@627 4094 "As the illustration shows, there is <emphasis>not</emphasis> a <quote>one to "
dongsheng@627 4095 "one</quote> relationship between revisions in the changelog, manifest, or "
dongsheng@627 4096 "filelog. If the manifest hasn't changed between two changesets, the changelog "
dongsheng@627 4097 "entries for those changesets will point to the same revision of the "
dongsheng@627 4098 "manifest. If a file that Mercurial tracks hasn't changed between two "
dongsheng@627 4099 "changesets, the entry for that file in the two revisions of the manifest will "
dongsheng@627 4100 "point to the same revision of its filelog."
dongsheng@627 4101 msgstr ""
dongsheng@627 4102
dongsheng@627 4103 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@710 4104 #: ../en/ch03-concepts.xml:125
dongsheng@627 4105 msgid "Safe, efficient storage"
dongsheng@627 4106 msgstr "安全,高效的存储"
dongsheng@627 4107
dongsheng@627 4108 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 4109 #: ../en/ch03-concepts.xml:127
dongsheng@627 4110 msgid ""
dongsheng@627 4111 "The underpinnings of changelogs, manifests, and filelogs are provided by a "
dongsheng@627 4112 "single structure called the <emphasis>revlog</emphasis>."
dongsheng@627 4113 msgstr ""
dongsheng@627 4114
dongsheng@627 4115 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 4116 #: ../en/ch03-concepts.xml:132
dongsheng@627 4117 msgid "Efficient storage"
dongsheng@627 4118 msgstr "高效存储"
dongsheng@627 4119
dongsheng@627 4120 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 4121 #: ../en/ch03-concepts.xml:134
dongsheng@627 4122 msgid ""
dongsheng@627 4123 "The revlog provides efficient storage of revisions using a <emphasis>delta</"
dongsheng@627 4124 "emphasis> mechanism. Instead of storing a complete copy of a file for each "
dongsheng@627 4125 "revision, it stores the changes needed to transform an older revision into "
dongsheng@627 4126 "the new revision. For many kinds of file data, these deltas are typically a "
dongsheng@627 4127 "fraction of a percent of the size of a full copy of a file."
dongsheng@627 4128 msgstr ""
dongsheng@627 4129
dongsheng@627 4130 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 4131 #: ../en/ch03-concepts.xml:142
dongsheng@627 4132 msgid ""
dongsheng@627 4133 "Some obsolete revision control systems can only work with deltas of text "
dongsheng@627 4134 "files. They must either store binary files as complete snapshots or encoded "
dongsheng@627 4135 "into a text representation, both of which are wasteful approaches. Mercurial "
dongsheng@627 4136 "can efficiently handle deltas of files with arbitrary binary contents; it "
dongsheng@627 4137 "doesn't need to treat text as special."
dongsheng@627 4138 msgstr ""
dongsheng@627 4139
dongsheng@627 4140 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 4141 #: ../en/ch03-concepts.xml:151
dongsheng@627 4142 msgid "Safe operation"
dongsheng@627 4143 msgstr "安全操作"
dongsheng@627 4144
dongsheng@627 4145 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 4146 #: ../en/ch03-concepts.xml:153
dongsheng@627 4147 msgid ""
dongsheng@627 4148 "Mercurial only ever <emphasis>appends</emphasis> data to the end of a revlog "
dongsheng@627 4149 "file. It never modifies a section of a file after it has written it. This is "
dongsheng@627 4150 "both more robust and efficient than schemes that need to modify or rewrite "
dongsheng@627 4151 "data."
dongsheng@627 4152 msgstr ""
dongsheng@627 4153
dongsheng@627 4154 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 4155 #: ../en/ch03-concepts.xml:159
dongsheng@627 4156 msgid ""
dongsheng@627 4157 "In addition, Mercurial treats every write as part of a <emphasis>transaction</"
dongsheng@627 4158 "emphasis> that can span a number of files. A transaction is "
dongsheng@627 4159 "<emphasis>atomic</emphasis>: either the entire transaction succeeds and its "
dongsheng@627 4160 "effects are all visible to readers in one go, or the whole thing is undone. "
dongsheng@627 4161 "This guarantee of atomicity means that if you're running two copies of "
dongsheng@627 4162 "Mercurial, where one is reading data and one is writing it, the reader will "
dongsheng@627 4163 "never see a partially written result that might confuse it."
dongsheng@627 4164 msgstr ""
dongsheng@627 4165
dongsheng@627 4166 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 4167 #: ../en/ch03-concepts.xml:169
dongsheng@627 4168 msgid ""
dongsheng@627 4169 "The fact that Mercurial only appends to files makes it easier to provide this "
dongsheng@627 4170 "transactional guarantee. The easier it is to do stuff like this, the more "
dongsheng@627 4171 "confident you should be that it's done correctly."
dongsheng@627 4172 msgstr ""
dongsheng@627 4173
dongsheng@627 4174 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 4175 #: ../en/ch03-concepts.xml:176
dongsheng@627 4176 msgid "Fast retrieval"
dongsheng@627 4177 msgstr "快速检索"
dongsheng@627 4178
dongsheng@627 4179 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 4180 #: ../en/ch03-concepts.xml:178
dongsheng@627 4181 msgid ""
dongsheng@627 4182 "Mercurial cleverly avoids a pitfall common to all earlier revision control "
dongsheng@627 4183 "systems: the problem of <emphasis>inefficient retrieval</emphasis>. Most "
dongsheng@627 4184 "revision control systems store the contents of a revision as an incremental "
dongsheng@627 4185 "series of modifications against a <quote>snapshot</quote>. To reconstruct a "
dongsheng@627 4186 "specific revision, you must first read the snapshot, and then every one of "
dongsheng@627 4187 "the revisions between the snapshot and your target revision. The more "
dongsheng@627 4188 "history that a file accumulates, the more revisions you must read, hence the "
dongsheng@627 4189 "longer it takes to reconstruct a particular revision."
dongsheng@627 4190 msgstr ""
dongsheng@627 4191
songdongsheng@658 4192 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
songdongsheng@710 4193 #: ../en/ch03-concepts.xml:190
songdongsheng@658 4194 msgid "Snapshot of a revlog, with incremental deltas"
dongsheng@660 4195 msgstr "版本日志的快照,以及增量差异"
songdongsheng@658 4196
songdongsheng@658 4197 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
songdongsheng@710 4198 #: ../en/ch03-concepts.xml:192
songdongsheng@658 4199 msgid "<imageobject><imagedata fileref=\"figs/snapshot.png\"/></imageobject>"
songdongsheng@658 4200 msgstr ""
songdongsheng@658 4201
songdongsheng@658 4202 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 4203 #: ../en/ch03-concepts.xml:197
dongsheng@627 4204 msgid ""
dongsheng@627 4205 "The innovation that Mercurial applies to this problem is simple but "
dongsheng@627 4206 "effective. Once the cumulative amount of delta information stored since the "
dongsheng@627 4207 "last snapshot exceeds a fixed threshold, it stores a new snapshot "
dongsheng@627 4208 "(compressed, of course), instead of another delta. This makes it possible to "
dongsheng@627 4209 "reconstruct <emphasis>any</emphasis> revision of a file quickly. This "
dongsheng@627 4210 "approach works so well that it has since been copied by several other "
dongsheng@627 4211 "revision control systems."
dongsheng@627 4212 msgstr ""
dongsheng@627 4213
dongsheng@627 4214 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 4215 #: ../en/ch03-concepts.xml:206
songdongsheng@658 4216 msgid ""
songdongsheng@658 4217 "<xref linkend=\"fig:concepts:snapshot\"/> illustrates the idea. In an entry "
songdongsheng@658 4218 "in a revlog's index file, Mercurial stores the range of entries from the data "
songdongsheng@658 4219 "file that it must read to reconstruct a particular revision."
dongsheng@627 4220 msgstr ""
dongsheng@627 4221
dongsheng@627 4222 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
songdongsheng@710 4223 #: ../en/ch03-concepts.xml:212
dongsheng@627 4224 msgid "Aside: the influence of video compression"
dongsheng@660 4225 msgstr "旁白: 视频压缩的影响"
dongsheng@627 4226
dongsheng@627 4227 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@710 4228 #: ../en/ch03-concepts.xml:214
dongsheng@627 4229 msgid ""
dongsheng@627 4230 "If you're familiar with video compression or have ever watched a TV feed "
dongsheng@627 4231 "through a digital cable or satellite service, you may know that most video "
dongsheng@627 4232 "compression schemes store each frame of video as a delta against its "
dongsheng@627 4233 "predecessor frame. In addition, these schemes use <quote>lossy</quote> "
dongsheng@627 4234 "compression techniques to increase the compression ratio, so visual errors "
dongsheng@627 4235 "accumulate over the course of a number of inter-frame deltas."
dongsheng@627 4236 msgstr ""
dongsheng@627 4237
dongsheng@627 4238 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@710 4239 #: ../en/ch03-concepts.xml:223
dongsheng@627 4240 msgid ""
dongsheng@627 4241 "Because it's possible for a video stream to <quote>drop out</quote> "
dongsheng@627 4242 "occasionally due to signal glitches, and to limit the accumulation of "
dongsheng@627 4243 "artefacts introduced by the lossy compression process, video encoders "
dongsheng@627 4244 "periodically insert a complete frame (called a <quote>key frame</quote>) into "
dongsheng@627 4245 "the video stream; the next delta is generated against that frame. This means "
dongsheng@627 4246 "that if the video signal gets interrupted, it will resume once the next key "
dongsheng@627 4247 "frame is received. Also, the accumulation of encoding errors restarts anew "
dongsheng@627 4248 "with each key frame."
dongsheng@627 4249 msgstr ""
dongsheng@627 4250
dongsheng@627 4251 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 4252 #: ../en/ch03-concepts.xml:237
dongsheng@627 4253 msgid "Identification and strong integrity"
dongsheng@627 4254 msgstr "鉴别和强完整性"
dongsheng@627 4255
dongsheng@627 4256 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 4257 #: ../en/ch03-concepts.xml:239
dongsheng@627 4258 msgid ""
dongsheng@627 4259 "Along with delta or snapshot information, a revlog entry contains a "
dongsheng@627 4260 "cryptographic hash of the data that it represents. This makes it difficult "
dongsheng@627 4261 "to forge the contents of a revision, and easy to detect accidental corruption."
dongsheng@627 4262 msgstr ""
dongsheng@627 4263
dongsheng@627 4264 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 4265 #: ../en/ch03-concepts.xml:244
dongsheng@627 4266 msgid ""
dongsheng@627 4267 "Hashes provide more than a mere check against corruption; they are used as "
dongsheng@627 4268 "the identifiers for revisions. The changeset identification hashes that you "
dongsheng@627 4269 "see as an end user are from revisions of the changelog. Although filelogs "
dongsheng@627 4270 "and the manifest also use hashes, Mercurial only uses these behind the scenes."
dongsheng@627 4271 msgstr ""
dongsheng@627 4272
dongsheng@627 4273 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 4274 #: ../en/ch03-concepts.xml:251
dongsheng@627 4275 msgid ""
dongsheng@627 4276 "Mercurial verifies that hashes are correct when it retrieves file revisions "
dongsheng@627 4277 "and when it pulls changes from another repository. If it encounters an "
dongsheng@627 4278 "integrity problem, it will complain and stop whatever it's doing."
dongsheng@627 4279 msgstr ""
dongsheng@627 4280
dongsheng@627 4281 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 4282 #: ../en/ch03-concepts.xml:256
dongsheng@627 4283 msgid ""
dongsheng@627 4284 "In addition to the effect it has on retrieval efficiency, Mercurial's use of "
dongsheng@627 4285 "periodic snapshots makes it more robust against partial data corruption. If "
dongsheng@627 4286 "a revlog becomes partly corrupted due to a hardware error or system bug, it's "
dongsheng@627 4287 "often possible to reconstruct some or most revisions from the uncorrupted "
dongsheng@627 4288 "sections of the revlog, both before and after the corrupted section. This "
dongsheng@627 4289 "would not be possible with a delta-only storage model."
dongsheng@627 4290 msgstr ""
dongsheng@627 4291
dongsheng@627 4292 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@710 4293 #: ../en/ch03-concepts.xml:268
dongsheng@627 4294 msgid "Revision history, branching, and merging"
dongsheng@627 4295 msgstr "修订历史,分支与合并"
dongsheng@627 4296
dongsheng@627 4297 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 4298 #: ../en/ch03-concepts.xml:270
dongsheng@627 4299 msgid ""
dongsheng@627 4300 "Every entry in a Mercurial revlog knows the identity of its immediate "
dongsheng@627 4301 "ancestor revision, usually referred to as its <emphasis>parent</emphasis>. "
dongsheng@627 4302 "In fact, a revision contains room for not one parent, but two. Mercurial "
dongsheng@627 4303 "uses a special hash, called the <quote>null ID</quote>, to represent the idea "
dongsheng@627 4304 "<quote>there is no parent here</quote>. This hash is simply a string of "
dongsheng@627 4305 "zeroes."
dongsheng@627 4306 msgstr ""
dongsheng@627 4307
dongsheng@627 4308 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 4309 #: ../en/ch03-concepts.xml:278
songdongsheng@658 4310 msgid ""
songdongsheng@658 4311 "In <xref linkend=\"fig:concepts:revlog\"/>, you can see an example of the "
songdongsheng@658 4312 "conceptual structure of a revlog. Filelogs, manifests, and changelogs all "
songdongsheng@658 4313 "have this same structure; they differ only in the kind of data stored in each "
songdongsheng@658 4314 "delta or snapshot."
songdongsheng@658 4315 msgstr ""
songdongsheng@658 4316
songdongsheng@658 4317 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 4318 #: ../en/ch03-concepts.xml:284
dongsheng@627 4319 msgid ""
dongsheng@627 4320 "The first revision in a revlog (at the bottom of the image) has the null ID "
dongsheng@627 4321 "in both of its parent slots. For a <quote>normal</quote> revision, its first "
dongsheng@627 4322 "parent slot contains the ID of its parent revision, and its second contains "
dongsheng@627 4323 "the null ID, indicating that the revision has only one real parent. Any two "
dongsheng@627 4324 "revisions that have the same parent ID are branches. A revision that "
dongsheng@627 4325 "represents a merge between branches has two normal revision IDs in its parent "
dongsheng@627 4326 "slots."
dongsheng@627 4327 msgstr ""
dongsheng@627 4328
songdongsheng@658 4329 #. type: Content of: <book><chapter><sect1><figure><title>
songdongsheng@710 4330 #: ../en/ch03-concepts.xml:294
songdongsheng@658 4331 msgid "The conceptual structure of a revlog"
dongsheng@660 4332 msgstr "版本日志的设计结构"
songdongsheng@658 4333
songdongsheng@658 4334 #. type: Content of: <book><chapter><sect1><figure><mediaobject>
songdongsheng@710 4335 #: ../en/ch03-concepts.xml:296
songdongsheng@658 4336 msgid "<imageobject><imagedata fileref=\"figs/revlog.png\"/></imageobject>"
dongsheng@641 4337 msgstr ""
dongsheng@641 4338
dongsheng@627 4339 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@710 4340 #: ../en/ch03-concepts.xml:303
dongsheng@627 4341 msgid "The working directory"
dongsheng@627 4342 msgstr "工作目录"
dongsheng@627 4343
dongsheng@627 4344 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 4345 #: ../en/ch03-concepts.xml:305
dongsheng@627 4346 msgid ""
dongsheng@627 4347 "In the working directory, Mercurial stores a snapshot of the files from the "
dongsheng@627 4348 "repository as of a particular changeset."
dongsheng@627 4349 msgstr ""
dongsheng@627 4350
dongsheng@627 4351 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 4352 #: ../en/ch03-concepts.xml:308
dongsheng@627 4353 msgid ""
dongsheng@627 4354 "The working directory <quote>knows</quote> which changeset it contains. When "
dongsheng@627 4355 "you update the working directory to contain a particular changeset, Mercurial "
dongsheng@627 4356 "looks up the appropriate revision of the manifest to find out which files it "
dongsheng@627 4357 "was tracking at the time that changeset was committed, and which revision of "
dongsheng@627 4358 "each file was then current. It then recreates a copy of each of those files, "
dongsheng@627 4359 "with the same contents it had when the changeset was committed."
dongsheng@627 4360 msgstr ""
dongsheng@627 4361
dongsheng@627 4362 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 4363 #: ../en/ch03-concepts.xml:317
dongsheng@627 4364 msgid ""
dongsheng@627 4365 "The <emphasis>dirstate</emphasis> contains Mercurial's knowledge of the "
dongsheng@627 4366 "working directory. This details which changeset the working directory is "
dongsheng@627 4367 "updated to, and all of the files that Mercurial is tracking in the working "
dongsheng@627 4368 "directory."
dongsheng@627 4369 msgstr ""
dongsheng@627 4370
dongsheng@627 4371 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 4372 #: ../en/ch03-concepts.xml:323
dongsheng@627 4373 msgid ""
dongsheng@627 4374 "Just as a revision of a revlog has room for two parents, so that it can "
dongsheng@627 4375 "represent either a normal revision (with one parent) or a merge of two "
dongsheng@627 4376 "earlier revisions, the dirstate has slots for two parents. When you use the "
dongsheng@627 4377 "<command role=\"hg-cmd\">hg update</command> command, the changeset that you "
dongsheng@627 4378 "update to is stored in the <quote>first parent</quote> slot, and the null ID "
dongsheng@627 4379 "in the second. When you <command role=\"hg-cmd\">hg merge</command> with "
dongsheng@627 4380 "another changeset, the first parent remains unchanged, and the second parent "
dongsheng@627 4381 "is filled in with the changeset you're merging with. The <command role=\"hg-"
dongsheng@627 4382 "cmd\">hg parents</command> command tells you what the parents of the dirstate "
dongsheng@627 4383 "are."
dongsheng@627 4384 msgstr ""
dongsheng@627 4385
dongsheng@627 4386 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 4387 #: ../en/ch03-concepts.xml:337
dongsheng@627 4388 msgid "What happens when you commit"
dongsheng@627 4389 msgstr "当你提交时发生的事情"
dongsheng@627 4390
dongsheng@627 4391 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 4392 #: ../en/ch03-concepts.xml:339
dongsheng@627 4393 msgid ""
dongsheng@627 4394 "The dirstate stores parent information for more than just book-keeping "
dongsheng@627 4395 "purposes. Mercurial uses the parents of the dirstate as <emphasis>the "
dongsheng@627 4396 "parents of a new changeset</emphasis> when you perform a commit."
dongsheng@627 4397 msgstr ""
dongsheng@627 4398
songdongsheng@658 4399 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
songdongsheng@710 4400 #: ../en/ch03-concepts.xml:345
dongsheng@627 4401 msgid "The working directory can have two parents"
dongsheng@660 4402 msgstr "工作目录可以有两个父亲"
dongsheng@627 4403
songdongsheng@658 4404 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
songdongsheng@710 4405 #: ../en/ch03-concepts.xml:347
songdongsheng@658 4406 msgid "<imageobject><imagedata fileref=\"figs/wdir.png\"/></imageobject>"
songdongsheng@658 4407 msgstr ""
songdongsheng@658 4408
songdongsheng@658 4409 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 4410 #: ../en/ch03-concepts.xml:352
songdongsheng@658 4411 msgid ""
songdongsheng@658 4412 "<xref linkend=\"fig:concepts:wdir\"/> shows the normal state of the working "
songdongsheng@658 4413 "directory, where it has a single changeset as parent. That changeset is the "
songdongsheng@658 4414 "<emphasis>tip</emphasis>, the newest changeset in the repository that has no "
songdongsheng@658 4415 "children."
songdongsheng@658 4416 msgstr ""
songdongsheng@658 4417
songdongsheng@658 4418 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
songdongsheng@710 4419 #: ../en/ch03-concepts.xml:359
dongsheng@627 4420 msgid "The working directory gains new parents after a commit"
dongsheng@660 4421 msgstr "提交之后,工作目录的父亲就改变了"
dongsheng@627 4422
songdongsheng@658 4423 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
songdongsheng@710 4424 #: ../en/ch03-concepts.xml:362
songdongsheng@658 4425 msgid ""
songdongsheng@658 4426 "<imageobject><imagedata fileref=\"figs/wdir-after-commit.png\"/></imageobject>"
songdongsheng@658 4427 msgstr ""
songdongsheng@658 4428
songdongsheng@658 4429 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 4430 #: ../en/ch03-concepts.xml:367
dongsheng@627 4431 msgid ""
dongsheng@627 4432 "It's useful to think of the working directory as <quote>the changeset I'm "
dongsheng@627 4433 "about to commit</quote>. Any files that you tell Mercurial that you've "
dongsheng@627 4434 "added, removed, renamed, or copied will be reflected in that changeset, as "
dongsheng@627 4435 "will modifications to any files that Mercurial is already tracking; the new "
dongsheng@627 4436 "changeset will have the parents of the working directory as its parents."
dongsheng@627 4437 msgstr ""
dongsheng@627 4438
dongsheng@627 4439 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 4440 #: ../en/ch03-concepts.xml:375
dongsheng@627 4441 msgid ""
dongsheng@627 4442 "After a commit, Mercurial will update the parents of the working directory, "
dongsheng@627 4443 "so that the first parent is the ID of the new changeset, and the second is "
songdongsheng@658 4444 "the null ID. This is shown in <xref linkend=\"fig:concepts:wdir-after-commit"
songdongsheng@658 4445 "\"/>. Mercurial doesn't touch any of the files in the working directory when "
songdongsheng@658 4446 "you commit; it just modifies the dirstate to note its new parents."
dongsheng@641 4447 msgstr ""
dongsheng@641 4448
dongsheng@641 4449 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 4450 #: ../en/ch03-concepts.xml:386
dongsheng@627 4451 msgid "Creating a new head"
dongsheng@627 4452 msgstr "创建新顶点"
dongsheng@627 4453
dongsheng@627 4454 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 4455 #: ../en/ch03-concepts.xml:388
dongsheng@627 4456 msgid ""
dongsheng@627 4457 "It's perfectly normal to update the working directory to a changeset other "
dongsheng@627 4458 "than the current tip. For example, you might want to know what your project "
dongsheng@627 4459 "looked like last Tuesday, or you could be looking through changesets to see "
dongsheng@627 4460 "which one introduced a bug. In cases like this, the natural thing to do is "
dongsheng@627 4461 "update the working directory to the changeset you're interested in, and then "
dongsheng@627 4462 "examine the files in the working directory directly to see their contents as "
dongsheng@627 4463 "they were when you committed that changeset. The effect of this is shown in "
songdongsheng@658 4464 "<xref linkend=\"fig:concepts:wdir-pre-branch\"/>."
songdongsheng@658 4465 msgstr ""
songdongsheng@658 4466
songdongsheng@658 4467 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
songdongsheng@710 4468 #: ../en/ch03-concepts.xml:400
dongsheng@627 4469 msgid "The working directory, updated to an older changeset"
dongsheng@660 4470 msgstr "同步到旧修改集的工作目录"
dongsheng@627 4471
songdongsheng@658 4472 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
songdongsheng@710 4473 #: ../en/ch03-concepts.xml:403
songdongsheng@658 4474 msgid ""
songdongsheng@658 4475 "<imageobject><imagedata fileref=\"figs/wdir-pre-branch.png\"/></imageobject>"
songdongsheng@658 4476 msgstr ""
songdongsheng@658 4477
songdongsheng@658 4478 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 4479 #: ../en/ch03-concepts.xml:408
dongsheng@627 4480 msgid ""
dongsheng@627 4481 "Having updated the working directory to an older changeset, what happens if "
dongsheng@627 4482 "you make some changes, and then commit? Mercurial behaves in the same way as "
dongsheng@627 4483 "I outlined above. The parents of the working directory become the parents of "
dongsheng@627 4484 "the new changeset. This new changeset has no children, so it becomes the new "
dongsheng@627 4485 "tip. And the repository now contains two changesets that have no children; "
dongsheng@627 4486 "we call these <emphasis>heads</emphasis>. You can see the structure that "
songdongsheng@658 4487 "this creates in <xref linkend=\"fig:concepts:wdir-branch\"/>."
songdongsheng@658 4488 msgstr ""
songdongsheng@658 4489
songdongsheng@658 4490 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
songdongsheng@710 4491 #: ../en/ch03-concepts.xml:420
dongsheng@627 4492 msgid "After a commit made while synced to an older changeset"
dongsheng@660 4493 msgstr "对同步到旧修改集的工作目录提交之后"
dongsheng@627 4494
songdongsheng@658 4495 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
songdongsheng@710 4496 #: ../en/ch03-concepts.xml:423
songdongsheng@658 4497 msgid "<imageobject><imagedata fileref=\"figs/wdir-branch.png\"/></imageobject>"
songdongsheng@658 4498 msgstr ""
songdongsheng@658 4499
dongsheng@627 4500 #. type: Content of: <book><chapter><sect1><sect2><note><para>
songdongsheng@710 4501 #: ../en/ch03-concepts.xml:429
dongsheng@627 4502 msgid ""
dongsheng@627 4503 "If you're new to Mercurial, you should keep in mind a common <quote>error</"
dongsheng@627 4504 "quote>, which is to use the <command role=\"hg-cmd\">hg pull</command> "
dongsheng@627 4505 "command without any options. By default, the <command role=\"hg-cmd\">hg "
dongsheng@627 4506 "pull</command> command <emphasis>does not</emphasis> update the working "
dongsheng@627 4507 "directory, so you'll bring new changesets into your repository, but the "
dongsheng@627 4508 "working directory will stay synced at the same changeset as before the pull. "
dongsheng@627 4509 "If you make some changes and commit afterwards, you'll thus create a new "
dongsheng@627 4510 "head, because your working directory isn't synced to whatever the current tip "
dongsheng@627 4511 "is."
dongsheng@627 4512 msgstr ""
dongsheng@627 4513
dongsheng@627 4514 #. type: Content of: <book><chapter><sect1><sect2><note><para>
songdongsheng@710 4515 #: ../en/ch03-concepts.xml:441
dongsheng@627 4516 msgid ""
dongsheng@627 4517 "I put the word <quote>error</quote> in quotes because all that you need to do "
dongsheng@627 4518 "to rectify this situation is <command role=\"hg-cmd\">hg merge</command>, "
dongsheng@627 4519 "then <command role=\"hg-cmd\">hg commit</command>. In other words, this "
songdongsheng@710 4520 "almost never has negative consequences; it's just something of a surprise for "
songdongsheng@710 4521 "newcomers. I'll discuss other ways to avoid this behavior, and why Mercurial "
songdongsheng@710 4522 "behaves in this initially surprising way, later on."
songdongsheng@710 4523 msgstr ""
songdongsheng@710 4524
songdongsheng@710 4525 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 4526 #: ../en/ch03-concepts.xml:453
songdongsheng@710 4527 #, fuzzy
songdongsheng@710 4528 msgid "Merging changes"
songdongsheng@710 4529 msgstr "共享修改"
songdongsheng@710 4530
songdongsheng@710 4531 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 4532 #: ../en/ch03-concepts.xml:455
dongsheng@627 4533 msgid ""
dongsheng@627 4534 "When you run the <command role=\"hg-cmd\">hg merge</command> command, "
dongsheng@627 4535 "Mercurial leaves the first parent of the working directory unchanged, and "
dongsheng@627 4536 "sets the second parent to the changeset you're merging with, as shown in "
songdongsheng@658 4537 "<xref linkend=\"fig:concepts:wdir-merge\"/>."
songdongsheng@658 4538 msgstr ""
songdongsheng@658 4539
songdongsheng@658 4540 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
songdongsheng@710 4541 #: ../en/ch03-concepts.xml:462
dongsheng@627 4542 msgid "Merging two heads"
dongsheng@660 4543 msgstr "合并两个顶点"
dongsheng@627 4544
songdongsheng@658 4545 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
songdongsheng@710 4546 #: ../en/ch03-concepts.xml:464
songdongsheng@658 4547 msgid ""
songdongsheng@658 4548 "<imageobject> <imagedata fileref=\"figs/wdir-merge.png\"/> </imageobject>"
songdongsheng@658 4549 msgstr ""
songdongsheng@658 4550
songdongsheng@658 4551 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 4552 #: ../en/ch03-concepts.xml:471
dongsheng@627 4553 msgid ""
dongsheng@627 4554 "Mercurial also has to modify the working directory, to merge the files "
dongsheng@627 4555 "managed in the two changesets. Simplified a little, the merging process goes "
dongsheng@627 4556 "like this, for every file in the manifests of both changesets."
dongsheng@627 4557 msgstr ""
dongsheng@627 4558
dongsheng@627 4559 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@710 4560 #: ../en/ch03-concepts.xml:476
dongsheng@627 4561 msgid "If neither changeset has modified a file, do nothing with that file."
dongsheng@627 4562 msgstr ""
dongsheng@627 4563
dongsheng@627 4564 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@710 4565 #: ../en/ch03-concepts.xml:479
dongsheng@627 4566 msgid ""
dongsheng@627 4567 "If one changeset has modified a file, and the other hasn't, create the "
dongsheng@627 4568 "modified copy of the file in the working directory."
dongsheng@627 4569 msgstr ""
dongsheng@627 4570
dongsheng@627 4571 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@710 4572 #: ../en/ch03-concepts.xml:483
dongsheng@627 4573 msgid ""
dongsheng@627 4574 "If one changeset has removed a file, and the other hasn't (or has also "
dongsheng@627 4575 "deleted it), delete the file from the working directory."
dongsheng@627 4576 msgstr ""
dongsheng@627 4577
dongsheng@627 4578 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@710 4579 #: ../en/ch03-concepts.xml:487
dongsheng@627 4580 msgid ""
dongsheng@627 4581 "If one changeset has removed a file, but the other has modified the file, ask "
dongsheng@627 4582 "the user what to do: keep the modified file, or remove it?"
dongsheng@627 4583 msgstr ""
dongsheng@627 4584
dongsheng@627 4585 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@710 4586 #: ../en/ch03-concepts.xml:491
dongsheng@627 4587 msgid ""
dongsheng@627 4588 "If both changesets have modified a file, invoke an external merge program to "
dongsheng@627 4589 "choose the new contents for the merged file. This may require input from the "
dongsheng@627 4590 "user."
dongsheng@627 4591 msgstr ""
dongsheng@627 4592
dongsheng@627 4593 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@710 4594 #: ../en/ch03-concepts.xml:496
dongsheng@627 4595 msgid ""
dongsheng@627 4596 "If one changeset has modified a file, and the other has renamed or copied the "
dongsheng@627 4597 "file, make sure that the changes follow the new name of the file."
dongsheng@627 4598 msgstr ""
dongsheng@627 4599
dongsheng@627 4600 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 4601 #: ../en/ch03-concepts.xml:500
dongsheng@627 4602 msgid ""
songdongsheng@668 4603 "There are more details&emdash;merging has plenty of corner cases&emdash;but "
songdongsheng@668 4604 "these are the most common choices that are involved in a merge. As you can "
songdongsheng@668 4605 "see, most cases are completely automatic, and indeed most merges finish "
dongsheng@627 4606 "automatically, without requiring your input to resolve any conflicts."
dongsheng@627 4607 msgstr ""
dongsheng@627 4608
dongsheng@627 4609 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 4610 #: ../en/ch03-concepts.xml:507
dongsheng@627 4611 msgid ""
dongsheng@627 4612 "When you're thinking about what happens when you commit after a merge, once "
dongsheng@627 4613 "again the working directory is <quote>the changeset I'm about to commit</"
dongsheng@627 4614 "quote>. After the <command role=\"hg-cmd\">hg merge</command> command "
dongsheng@627 4615 "completes, the working directory has two parents; these will become the "
dongsheng@627 4616 "parents of the new changeset."
dongsheng@627 4617 msgstr ""
dongsheng@627 4618
dongsheng@627 4619 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 4620 #: ../en/ch03-concepts.xml:514
dongsheng@627 4621 msgid ""
dongsheng@627 4622 "Mercurial lets you perform multiple merges, but you must commit the results "
dongsheng@627 4623 "of each individual merge as you go. This is necessary because Mercurial only "
dongsheng@627 4624 "tracks two parents for both revisions and the working directory. While it "
dongsheng@627 4625 "would be technically possible to merge multiple changesets at once, the "
dongsheng@627 4626 "prospect of user confusion and making a terrible mess of a merge immediately "
dongsheng@627 4627 "becomes overwhelming."
dongsheng@627 4628 msgstr ""
dongsheng@627 4629
songdongsheng@710 4630 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 4631 #: ../en/ch03-concepts.xml:525
songdongsheng@710 4632 #, fuzzy
songdongsheng@710 4633 msgid "Merging and renames"
songdongsheng@710 4634 msgstr "合并顶点"
songdongsheng@710 4635
songdongsheng@710 4636 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 4637 #: ../en/ch03-concepts.xml:527
songdongsheng@710 4638 msgid ""
songdongsheng@710 4639 "A surprising number of revision control systems pay little or no attention to "
songdongsheng@710 4640 "a file's <emphasis>name</emphasis> over time. For instance, it used to be "
songdongsheng@710 4641 "common that if a file got renamed on one side of a merge, the changes from "
songdongsheng@710 4642 "the other side would be silently dropped."
songdongsheng@710 4643 msgstr ""
songdongsheng@710 4644
songdongsheng@710 4645 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 4646 #: ../en/ch03-concepts.xml:533
songdongsheng@710 4647 msgid ""
songdongsheng@710 4648 "Mercurial records metadata when you tell it to perform a rename or copy. It "
songdongsheng@710 4649 "uses this metadata during a merge to do the right thing in the case of a "
songdongsheng@710 4650 "merge. For instance, if I rename a file, and you edit it without renaming "
songdongsheng@710 4651 "it, when we merge our work the file will be renamed and have your edits "
songdongsheng@710 4652 "applied."
songdongsheng@710 4653 msgstr ""
songdongsheng@710 4654
dongsheng@627 4655 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@710 4656 #: ../en/ch03-concepts.xml:543
dongsheng@627 4657 msgid "Other interesting design features"
dongsheng@627 4658 msgstr "其它有趣的设计特性"
dongsheng@627 4659
dongsheng@627 4660 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 4661 #: ../en/ch03-concepts.xml:545
dongsheng@627 4662 msgid ""
dongsheng@627 4663 "In the sections above, I've tried to highlight some of the most important "
dongsheng@627 4664 "aspects of Mercurial's design, to illustrate that it pays careful attention "
dongsheng@627 4665 "to reliability and performance. However, the attention to detail doesn't "
dongsheng@627 4666 "stop there. There are a number of other aspects of Mercurial's construction "
dongsheng@627 4667 "that I personally find interesting. I'll detail a few of them here, separate "
dongsheng@627 4668 "from the <quote>big ticket</quote> items above, so that if you're interested, "
dongsheng@627 4669 "you can gain a better idea of the amount of thinking that goes into a well-"
dongsheng@627 4670 "designed system."
dongsheng@627 4671 msgstr ""
dongsheng@627 4672
dongsheng@627 4673 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 4674 #: ../en/ch03-concepts.xml:556
dongsheng@627 4675 msgid "Clever compression"
dongsheng@627 4676 msgstr "智能压缩"
dongsheng@627 4677
dongsheng@627 4678 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 4679 #: ../en/ch03-concepts.xml:558
dongsheng@627 4680 msgid ""
dongsheng@627 4681 "When appropriate, Mercurial will store both snapshots and deltas in "
dongsheng@627 4682 "compressed form. It does this by always <emphasis>trying to</emphasis> "
dongsheng@627 4683 "compress a snapshot or delta, but only storing the compressed version if it's "
dongsheng@627 4684 "smaller than the uncompressed version."
dongsheng@627 4685 msgstr ""
dongsheng@627 4686
dongsheng@627 4687 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 4688 #: ../en/ch03-concepts.xml:564
dongsheng@627 4689 msgid ""
dongsheng@627 4690 "This means that Mercurial does <quote>the right thing</quote> when storing a "
dongsheng@627 4691 "file whose native form is compressed, such as a <literal>zip</literal> "
dongsheng@627 4692 "archive or a JPEG image. When these types of files are compressed a second "
dongsheng@627 4693 "time, the resulting file is usually bigger than the once-compressed form, and "
dongsheng@627 4694 "so Mercurial will store the plain <literal>zip</literal> or JPEG."
dongsheng@627 4695 msgstr ""
dongsheng@627 4696
dongsheng@627 4697 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 4698 #: ../en/ch03-concepts.xml:572
dongsheng@627 4699 msgid ""
dongsheng@627 4700 "Deltas between revisions of a compressed file are usually larger than "
dongsheng@627 4701 "snapshots of the file, and Mercurial again does <quote>the right thing</"
dongsheng@627 4702 "quote> in these cases. It finds that such a delta exceeds the threshold at "
dongsheng@627 4703 "which it should store a complete snapshot of the file, so it stores the "
dongsheng@627 4704 "snapshot, again saving space compared to a naive delta-only approach."
dongsheng@627 4705 msgstr ""
dongsheng@627 4706
dongsheng@627 4707 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
songdongsheng@710 4708 #: ../en/ch03-concepts.xml:581
dongsheng@627 4709 msgid "Network recompression"
dongsheng@627 4710 msgstr "网络重新压缩"
dongsheng@627 4711
dongsheng@627 4712 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@710 4713 #: ../en/ch03-concepts.xml:583
dongsheng@627 4714 msgid ""
dongsheng@627 4715 "When storing revisions on disk, Mercurial uses the <quote>deflate</quote> "
dongsheng@627 4716 "compression algorithm (the same one used by the popular <literal>zip</"
dongsheng@627 4717 "literal> archive format), which balances good speed with a respectable "
dongsheng@627 4718 "compression ratio. However, when transmitting revision data over a network "
dongsheng@627 4719 "connection, Mercurial uncompresses the compressed revision data."
dongsheng@627 4720 msgstr ""
dongsheng@627 4721
dongsheng@627 4722 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@710 4723 #: ../en/ch03-concepts.xml:591
dongsheng@627 4724 msgid ""
dongsheng@627 4725 "If the connection is over HTTP, Mercurial recompresses the entire stream of "
dongsheng@627 4726 "data using a compression algorithm that gives a better compression ratio (the "
dongsheng@627 4727 "Burrows-Wheeler algorithm from the widely used <literal>bzip2</literal> "
dongsheng@627 4728 "compression package). This combination of algorithm and compression of the "
dongsheng@627 4729 "entire stream (instead of a revision at a time) substantially reduces the "
dongsheng@627 4730 "number of bytes to be transferred, yielding better network performance over "
songdongsheng@710 4731 "most kinds of network."
dongsheng@627 4732 msgstr ""
dongsheng@627 4733
dongsheng@627 4734 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@710 4735 #: ../en/ch03-concepts.xml:601
dongsheng@627 4736 msgid ""
dongsheng@627 4737 "(If the connection is over <command>ssh</command>, Mercurial "
dongsheng@627 4738 "<emphasis>doesn't</emphasis> recompress the stream, because <command>ssh</"
dongsheng@627 4739 "command> can already do this itself.)"
dongsheng@627 4740 msgstr ""
dongsheng@627 4741
dongsheng@627 4742 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 4743 #: ../en/ch03-concepts.xml:609
dongsheng@627 4744 msgid "Read/write ordering and atomicity"
dongsheng@627 4745 msgstr "读写顺序与原子性"
dongsheng@627 4746
dongsheng@627 4747 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 4748 #: ../en/ch03-concepts.xml:611
dongsheng@627 4749 msgid ""
dongsheng@627 4750 "Appending to files isn't the whole story when it comes to guaranteeing that a "
songdongsheng@658 4751 "reader won't see a partial write. If you recall <xref linkend=\"fig:concepts:"
songdongsheng@658 4752 "metadata\"/>, revisions in the changelog point to revisions in the manifest, "
songdongsheng@658 4753 "and revisions in the manifest point to revisions in filelogs. This hierarchy "
songdongsheng@658 4754 "is deliberate."
songdongsheng@658 4755 msgstr ""
songdongsheng@658 4756
songdongsheng@658 4757 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 4758 #: ../en/ch03-concepts.xml:619
dongsheng@627 4759 msgid ""
dongsheng@627 4760 "A writer starts a transaction by writing filelog and manifest data, and "
dongsheng@627 4761 "doesn't write any changelog data until those are finished. A reader starts "
dongsheng@627 4762 "by reading changelog data, then manifest data, followed by filelog data."
dongsheng@627 4763 msgstr ""
dongsheng@627 4764
dongsheng@627 4765 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 4766 #: ../en/ch03-concepts.xml:624
dongsheng@627 4767 msgid ""
dongsheng@627 4768 "Since the writer has always finished writing filelog and manifest data before "
dongsheng@627 4769 "it writes to the changelog, a reader will never read a pointer to a partially "
dongsheng@627 4770 "written manifest revision from the changelog, and it will never read a "
dongsheng@627 4771 "pointer to a partially written filelog revision from the manifest."
dongsheng@627 4772 msgstr ""
dongsheng@627 4773
dongsheng@627 4774 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 4775 #: ../en/ch03-concepts.xml:632
dongsheng@627 4776 msgid "Concurrent access"
dongsheng@627 4777 msgstr "并发访问"
dongsheng@627 4778
dongsheng@627 4779 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 4780 #: ../en/ch03-concepts.xml:634
dongsheng@627 4781 msgid ""
dongsheng@627 4782 "The read/write ordering and atomicity guarantees mean that Mercurial never "
dongsheng@627 4783 "needs to <emphasis>lock</emphasis> a repository when it's reading data, even "
dongsheng@627 4784 "if the repository is being written to while the read is occurring. This has a "
dongsheng@627 4785 "big effect on scalability; you can have an arbitrary number of Mercurial "
dongsheng@627 4786 "processes safely reading data from a repository safely all at once, no matter "
dongsheng@627 4787 "whether it's being written to or not."
dongsheng@627 4788 msgstr ""
dongsheng@627 4789
dongsheng@627 4790 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 4791 #: ../en/ch03-concepts.xml:643
dongsheng@627 4792 msgid ""
dongsheng@627 4793 "The lockless nature of reading means that if you're sharing a repository on a "
dongsheng@627 4794 "multi-user system, you don't need to grant other local users permission to "
dongsheng@627 4795 "<emphasis>write</emphasis> to your repository in order for them to be able to "
dongsheng@627 4796 "clone it or pull changes from it; they only need <emphasis>read</emphasis> "
dongsheng@627 4797 "permission. (This is <emphasis>not</emphasis> a common feature among "
dongsheng@627 4798 "revision control systems, so don't take it for granted! Most require readers "
dongsheng@627 4799 "to be able to lock a repository to access it safely, and this requires write "
dongsheng@627 4800 "permission on at least one directory, which of course makes for all kinds of "
dongsheng@627 4801 "nasty and annoying security and administrative problems.)"
dongsheng@627 4802 msgstr ""
dongsheng@627 4803
dongsheng@627 4804 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 4805 #: ../en/ch03-concepts.xml:656
dongsheng@627 4806 msgid ""
dongsheng@627 4807 "Mercurial uses locks to ensure that only one process can write to a "
dongsheng@627 4808 "repository at a time (the locking mechanism is safe even over filesystems "
dongsheng@627 4809 "that are notoriously hostile to locking, such as NFS). If a repository is "
dongsheng@627 4810 "locked, a writer will wait for a while to retry if the repository becomes "
dongsheng@627 4811 "unlocked, but if the repository remains locked for too long, the process "
dongsheng@627 4812 "attempting to write will time out after a while. This means that your daily "
dongsheng@627 4813 "automated scripts won't get stuck forever and pile up if a system crashes "
dongsheng@627 4814 "unnoticed, for example. (Yes, the timeout is configurable, from zero to "
dongsheng@627 4815 "infinity.)"
dongsheng@627 4816 msgstr ""
dongsheng@627 4817
dongsheng@627 4818 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
songdongsheng@710 4819 #: ../en/ch03-concepts.xml:668
dongsheng@627 4820 msgid "Safe dirstate access"
dongsheng@627 4821 msgstr "安全的目录状态访问"
dongsheng@627 4822
dongsheng@627 4823 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@710 4824 #: ../en/ch03-concepts.xml:670
dongsheng@627 4825 msgid ""
dongsheng@627 4826 "As with revision data, Mercurial doesn't take a lock to read the dirstate "
dongsheng@627 4827 "file; it does acquire a lock to write it. To avoid the possibility of "
dongsheng@627 4828 "reading a partially written copy of the dirstate file, Mercurial writes to a "
dongsheng@627 4829 "file with a unique name in the same directory as the dirstate file, then "
dongsheng@627 4830 "renames the temporary file atomically to <filename>dirstate</filename>. The "
dongsheng@627 4831 "file named <filename>dirstate</filename> is thus guaranteed to be complete, "
dongsheng@627 4832 "not partially written."
dongsheng@627 4833 msgstr ""
dongsheng@627 4834
dongsheng@627 4835 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 4836 #: ../en/ch03-concepts.xml:683
dongsheng@627 4837 msgid "Avoiding seeks"
dongsheng@627 4838 msgstr "避免查找"
dongsheng@627 4839
dongsheng@627 4840 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 4841 #: ../en/ch03-concepts.xml:685
dongsheng@627 4842 msgid ""
dongsheng@627 4843 "Critical to Mercurial's performance is the avoidance of seeks of the disk "
dongsheng@627 4844 "head, since any seek is far more expensive than even a comparatively large "
dongsheng@627 4845 "read operation."
dongsheng@627 4846 msgstr ""
dongsheng@627 4847
dongsheng@627 4848 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 4849 #: ../en/ch03-concepts.xml:689
dongsheng@627 4850 msgid ""
dongsheng@627 4851 "This is why, for example, the dirstate is stored in a single file. If there "
dongsheng@627 4852 "were a dirstate file per directory that Mercurial tracked, the disk would "
dongsheng@627 4853 "seek once per directory. Instead, Mercurial reads the entire single dirstate "
dongsheng@627 4854 "file in one step."
dongsheng@627 4855 msgstr ""
dongsheng@627 4856
dongsheng@627 4857 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 4858 #: ../en/ch03-concepts.xml:695
dongsheng@627 4859 msgid ""
dongsheng@627 4860 "Mercurial also uses a <quote>copy on write</quote> scheme when cloning a "
dongsheng@627 4861 "repository on local storage. Instead of copying every revlog file from the "
dongsheng@627 4862 "old repository into the new repository, it makes a <quote>hard link</quote>, "
dongsheng@627 4863 "which is a shorthand way to say <quote>these two names point to the same "
dongsheng@627 4864 "file</quote>. When Mercurial is about to write to one of a revlog's files, "
dongsheng@627 4865 "it checks to see if the number of names pointing at the file is greater than "
dongsheng@627 4866 "one. If it is, more than one repository is using the file, so Mercurial "
dongsheng@627 4867 "makes a new copy of the file that is private to this repository."
dongsheng@627 4868 msgstr ""
dongsheng@627 4869
dongsheng@627 4870 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 4871 #: ../en/ch03-concepts.xml:706
dongsheng@627 4872 msgid ""
dongsheng@627 4873 "A few revision control developers have pointed out that this idea of making a "
dongsheng@627 4874 "complete private copy of a file is not very efficient in its use of storage. "
dongsheng@627 4875 "While this is true, storage is cheap, and this method gives the highest "
dongsheng@627 4876 "performance while deferring most book-keeping to the operating system. An "
dongsheng@627 4877 "alternative scheme would most likely reduce performance and increase the "
dongsheng@627 4878 "complexity of the software, each of which is much more important to the "
dongsheng@627 4879 "<quote>feel</quote> of day-to-day use."
dongsheng@627 4880 msgstr ""
dongsheng@627 4881
dongsheng@627 4882 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 4883 #: ../en/ch03-concepts.xml:718
dongsheng@627 4884 msgid "Other contents of the dirstate"
dongsheng@627 4885 msgstr "目录状态的其它内容"
dongsheng@627 4886
dongsheng@627 4887 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 4888 #: ../en/ch03-concepts.xml:720
dongsheng@627 4889 msgid ""
dongsheng@627 4890 "Because Mercurial doesn't force you to tell it when you're modifying a file, "
dongsheng@627 4891 "it uses the dirstate to store some extra information so it can determine "
dongsheng@627 4892 "efficiently whether you have modified a file. For each file in the working "
dongsheng@627 4893 "directory, it stores the time that it last modified the file itself, and the "
dongsheng@627 4894 "size of the file at that time."
dongsheng@627 4895 msgstr ""
dongsheng@627 4896
dongsheng@627 4897 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 4898 #: ../en/ch03-concepts.xml:727
dongsheng@627 4899 msgid ""
dongsheng@627 4900 "When you explicitly <command role=\"hg-cmd\">hg add</command>, <command role="
dongsheng@627 4901 "\"hg-cmd\">hg remove</command>, <command role=\"hg-cmd\">hg rename</command> "
dongsheng@627 4902 "or <command role=\"hg-cmd\">hg copy</command> files, Mercurial updates the "
dongsheng@627 4903 "dirstate so that it knows what to do with those files when you commit."
dongsheng@627 4904 msgstr ""
dongsheng@627 4905
dongsheng@627 4906 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 4907 #: ../en/ch03-concepts.xml:734
dongsheng@627 4908 msgid ""
dongsheng@627 4909 "When Mercurial is checking the states of files in the working directory, it "
dongsheng@627 4910 "first checks a file's modification time. If that has not changed, the file "
dongsheng@627 4911 "must not have been modified. If the file's size has changed, the file must "
dongsheng@627 4912 "have been modified. If the modification time has changed, but the size has "
dongsheng@627 4913 "not, only then does Mercurial need to read the actual contents of the file to "
dongsheng@627 4914 "see if they've changed. Storing these few extra pieces of information "
dongsheng@627 4915 "dramatically reduces the amount of data that Mercurial needs to read, which "
dongsheng@627 4916 "yields large performance improvements compared to other revision control "
dongsheng@627 4917 "systems."
dongsheng@627 4918 msgstr ""
dongsheng@627 4919
dongsheng@627 4920 #. type: Content of: <book><chapter><title>
dongsheng@650 4921 #: ../en/ch04-daily.xml:5
dongsheng@627 4922 msgid "Mercurial in daily use"
dongsheng@627 4923 msgstr "Mercurial 的日常使用"
dongsheng@627 4924
dongsheng@627 4925 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 4926 #: ../en/ch04-daily.xml:8
dongsheng@627 4927 msgid "Telling Mercurial which files to track"
dongsheng@627 4928 msgstr "告诉 Mercurial 要跟踪哪些文件"
dongsheng@627 4929
dongsheng@627 4930 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 4931 #: ../en/ch04-daily.xml:10
dongsheng@627 4932 msgid ""
dongsheng@627 4933 "Mercurial does not work with files in your repository unless you tell it to "
dongsheng@627 4934 "manage them. The <command role=\"hg-cmd\">hg status</command> command will "
dongsheng@627 4935 "tell you which files Mercurial doesn't know about; it uses a <quote><literal>?"
dongsheng@627 4936 "</literal></quote> to display such files."
dongsheng@627 4937 msgstr ""
dongsheng@627 4938
dongsheng@627 4939 #
dongsheng@627 4940 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 4941 #: ../en/ch04-daily.xml:17
dongsheng@627 4942 msgid ""
dongsheng@627 4943 "To tell Mercurial to track a file, use the <command role=\"hg-cmd\">hg add</"
dongsheng@627 4944 "command> command. Once you have added a file, the entry in the output of "
dongsheng@627 4945 "<command role=\"hg-cmd\">hg status</command> for that file changes from "
dongsheng@627 4946 "<quote><literal>?</literal></quote> to <quote><literal>A</literal></quote>."
dongsheng@627 4947 msgstr ""
dongsheng@627 4948
dongsheng@627 4949 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 4950 #: ../en/ch04-daily.xml:26
dongsheng@627 4951 msgid ""
dongsheng@627 4952 "After you run a <command role=\"hg-cmd\">hg commit</command>, the files that "
dongsheng@627 4953 "you added before the commit will no longer be listed in the output of "
songdongsheng@710 4954 "<command role=\"hg-cmd\">hg status</command>. The reason for this is that by "
songdongsheng@710 4955 "default, <command role=\"hg-cmd\">hg status</command> only tells you about "
songdongsheng@710 4956 "<quote>interesting</quote> files&emdash;those that you have (for example) "
songdongsheng@710 4957 "modified, removed, or renamed. If you have a repository that contains "
songdongsheng@710 4958 "thousands of files, you will rarely want to know about files that Mercurial "
songdongsheng@710 4959 "is tracking, but that have not changed. (You can still get this information; "
songdongsheng@710 4960 "we'll return to this later.)"
dongsheng@627 4961 msgstr ""
dongsheng@627 4962
dongsheng@627 4963 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 4964 #: ../en/ch04-daily.xml:38
dongsheng@627 4965 msgid ""
dongsheng@627 4966 "Once you add a file, Mercurial doesn't do anything with it immediately. "
dongsheng@627 4967 "Instead, it will take a snapshot of the file's state the next time you "
dongsheng@627 4968 "perform a commit. It will then continue to track the changes you make to the "
dongsheng@627 4969 "file every time you commit, until you remove the file."
dongsheng@627 4970 msgstr ""
dongsheng@627 4971
dongsheng@627 4972 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 4973 #: ../en/ch04-daily.xml:45
dongsheng@627 4974 msgid "Explicit versus implicit file naming"
dongsheng@627 4975 msgstr "明确与隐含文件命名"
dongsheng@627 4976
dongsheng@627 4977 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 4978 #: ../en/ch04-daily.xml:47
dongsheng@627 4979 msgid ""
songdongsheng@710 4980 "A useful behavior that Mercurial has is that if you pass the name of a "
dongsheng@627 4981 "directory to a command, every Mercurial command will treat this as <quote>I "
dongsheng@627 4982 "want to operate on every file in this directory and its subdirectories</"
dongsheng@627 4983 "quote>."
dongsheng@627 4984 msgstr ""
dongsheng@627 4985
dongsheng@627 4986 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 4987 #: ../en/ch04-daily.xml:54
dongsheng@627 4988 msgid ""
dongsheng@627 4989 "Notice in this example that Mercurial printed the names of the files it "
songdongsheng@710 4990 "added, whereas it didn't do so when we added the file named <filename>myfile."
songdongsheng@710 4991 "txt</filename> in the earlier example."
dongsheng@627 4992 msgstr ""
dongsheng@627 4993
dongsheng@627 4994 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 4995 #: ../en/ch04-daily.xml:59
dongsheng@627 4996 msgid ""
dongsheng@627 4997 "What's going on is that in the former case, we explicitly named the file to "
songdongsheng@710 4998 "add on the command line. The assumption that Mercurial makes in such cases "
songdongsheng@710 4999 "is that we know what we are doing, and it doesn't print any output."
dongsheng@627 5000 msgstr ""
dongsheng@627 5001
dongsheng@627 5002 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5003 #: ../en/ch04-daily.xml:64
dongsheng@627 5004 msgid ""
dongsheng@627 5005 "However, when we <emphasis>imply</emphasis> the names of files by giving the "
dongsheng@627 5006 "name of a directory, Mercurial takes the extra step of printing the name of "
dongsheng@627 5007 "each file that it does something with. This makes it more clear what is "
dongsheng@627 5008 "happening, and reduces the likelihood of a silent and nasty surprise. This "
songdongsheng@710 5009 "behavior is common to most Mercurial commands."
dongsheng@627 5010 msgstr ""
dongsheng@627 5011
dongsheng@627 5012 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 5013 #: ../en/ch04-daily.xml:73
songdongsheng@710 5014 #, fuzzy
songdongsheng@710 5015 msgid "Mercurial tracks files, not directories"
dongsheng@627 5016 msgstr "旁白: Mercurial 只跟踪文件,不跟踪目录"
dongsheng@627 5017
dongsheng@627 5018 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5019 #: ../en/ch04-daily.xml:75
dongsheng@627 5020 msgid ""
dongsheng@627 5021 "Mercurial does not track directory information. Instead, it tracks the path "
dongsheng@627 5022 "to a file. Before creating a file, it first creates any missing directory "
dongsheng@627 5023 "components of the path. After it deletes a file, it then deletes any empty "
dongsheng@627 5024 "directories that were in the deleted file's path. This sounds like a trivial "
dongsheng@627 5025 "distinction, but it has one minor practical consequence: it is not possible "
dongsheng@627 5026 "to represent a completely empty directory in Mercurial."
dongsheng@627 5027 msgstr ""
dongsheng@627 5028
dongsheng@627 5029 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5030 #: ../en/ch04-daily.xml:84
dongsheng@627 5031 msgid ""
dongsheng@627 5032 "Empty directories are rarely useful, and there are unintrusive workarounds "
dongsheng@627 5033 "that you can use to achieve an appropriate effect. The developers of "
dongsheng@627 5034 "Mercurial thus felt that the complexity that would be required to manage "
dongsheng@627 5035 "empty directories was not worth the limited benefit this feature would bring."
dongsheng@627 5036 msgstr ""
dongsheng@627 5037
dongsheng@627 5038 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5039 #: ../en/ch04-daily.xml:91
dongsheng@627 5040 msgid ""
dongsheng@627 5041 "If you need an empty directory in your repository, there are a few ways to "
dongsheng@627 5042 "achieve this. One is to create a directory, then <command role=\"hg-cmd\">hg "
dongsheng@627 5043 "add</command> a <quote>hidden</quote> file to that directory. On Unix-like "
dongsheng@627 5044 "systems, any file name that begins with a period (<quote><literal>.</"
dongsheng@627 5045 "literal></quote>) is treated as hidden by most commands and GUI tools. This "
dongsheng@627 5046 "approach is illustrated below."
dongsheng@627 5047 msgstr ""
dongsheng@627 5048
dongsheng@627 5049 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5050 #: ../en/ch04-daily.xml:102
dongsheng@627 5051 msgid ""
dongsheng@627 5052 "Another way to tackle a need for an empty directory is to simply create one "
dongsheng@627 5053 "in your automated build scripts before they will need it."
dongsheng@627 5054 msgstr ""
dongsheng@627 5055
dongsheng@627 5056 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 5057 #: ../en/ch04-daily.xml:109
dongsheng@627 5058 msgid "How to stop tracking a file"
dongsheng@627 5059 msgstr "如何停止跟踪文件"
dongsheng@627 5060
dongsheng@627 5061 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 5062 #: ../en/ch04-daily.xml:111
dongsheng@627 5063 msgid ""
dongsheng@627 5064 "Once you decide that a file no longer belongs in your repository, use the "
songdongsheng@710 5065 "<command role=\"hg-cmd\">hg remove</command> command. This deletes the file, "
dongsheng@627 5066 "and tells Mercurial to stop tracking it. A removed file is represented in "
dongsheng@627 5067 "the output of <command role=\"hg-cmd\">hg status</command> with a "
dongsheng@627 5068 "<quote><literal>R</literal></quote>."
dongsheng@627 5069 msgstr ""
dongsheng@627 5070
dongsheng@627 5071 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 5072 #: ../en/ch04-daily.xml:120
dongsheng@627 5073 msgid ""
dongsheng@627 5074 "After you <command role=\"hg-cmd\">hg remove</command> a file, Mercurial will "
dongsheng@627 5075 "no longer track changes to that file, even if you recreate a file with the "
dongsheng@627 5076 "same name in your working directory. If you do recreate a file with the same "
dongsheng@627 5077 "name and want Mercurial to track the new file, simply <command role=\"hg-cmd"
dongsheng@627 5078 "\">hg add</command> it. Mercurial will know that the newly added file is not "
dongsheng@627 5079 "related to the old file of the same name."
dongsheng@627 5080 msgstr ""
dongsheng@627 5081
dongsheng@627 5082 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 5083 #: ../en/ch04-daily.xml:129
dongsheng@627 5084 msgid "Removing a file does not affect its history"
dongsheng@627 5085 msgstr "删除文件不影响历史"
dongsheng@627 5086
dongsheng@627 5087 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5088 #: ../en/ch04-daily.xml:131
dongsheng@627 5089 msgid "It is important to understand that removing a file has only two effects."
dongsheng@627 5090 msgstr ""
dongsheng@627 5091
dongsheng@627 5092 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 5093 #: ../en/ch04-daily.xml:134
dongsheng@627 5094 msgid "It removes the current version of the file from the working directory."
dongsheng@627 5095 msgstr ""
dongsheng@627 5096
dongsheng@627 5097 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 5098 #: ../en/ch04-daily.xml:137
dongsheng@627 5099 msgid ""
dongsheng@627 5100 "It stops Mercurial from tracking changes to the file, from the time of the "
dongsheng@627 5101 "next commit."
dongsheng@627 5102 msgstr ""
dongsheng@627 5103
dongsheng@627 5104 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5105 #: ../en/ch04-daily.xml:140
dongsheng@627 5106 msgid ""
dongsheng@627 5107 "Removing a file <emphasis>does not</emphasis> in any way alter the "
dongsheng@627 5108 "<emphasis>history</emphasis> of the file."
dongsheng@627 5109 msgstr ""
dongsheng@627 5110
dongsheng@627 5111 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5112 #: ../en/ch04-daily.xml:143
dongsheng@627 5113 msgid ""
songdongsheng@710 5114 "If you update the working directory to a changeset that was committed when it "
songdongsheng@710 5115 "was still tracking a file that you later removed, the file will reappear in "
songdongsheng@710 5116 "the working directory, with the contents it had when you committed that "
songdongsheng@710 5117 "changeset. If you then update the working directory to a later changeset, in "
songdongsheng@710 5118 "which the file had been removed, Mercurial will once again remove the file "
songdongsheng@710 5119 "from the working directory."
songdongsheng@710 5120 msgstr ""
songdongsheng@710 5121
songdongsheng@710 5122 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 5123 #: ../en/ch04-daily.xml:154
dongsheng@627 5124 msgid "Missing files"
dongsheng@627 5125 msgstr "丢失的文件"
dongsheng@627 5126
dongsheng@627 5127 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 5128 #: ../en/ch04-daily.xml:156
dongsheng@627 5129 msgid ""
dongsheng@627 5130 "Mercurial considers a file that you have deleted, but not used <command role="
dongsheng@627 5131 "\"hg-cmd\">hg remove</command> to delete, to be <emphasis>missing</"
dongsheng@627 5132 "emphasis>. A missing file is represented with <quote><literal>!</literal></"
dongsheng@627 5133 "quote> in the output of <command role=\"hg-cmd\">hg status</command>. "
dongsheng@627 5134 "Mercurial commands will not generally do anything with missing files."
dongsheng@627 5135 msgstr ""
dongsheng@627 5136
dongsheng@627 5137 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 5138 #: ../en/ch04-daily.xml:166
dongsheng@627 5139 msgid ""
dongsheng@627 5140 "If your repository contains a file that <command role=\"hg-cmd\">hg status</"
dongsheng@627 5141 "command> reports as missing, and you want the file to stay gone, you can run "
dongsheng@627 5142 "<command role=\"hg-cmd\">hg remove <option role=\"hg-opt-remove\">--after</"
dongsheng@627 5143 "option></command> at any time later on, to tell Mercurial that you really did "
dongsheng@627 5144 "mean to remove the file."
dongsheng@627 5145 msgstr ""
dongsheng@627 5146
dongsheng@627 5147 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 5148 #: ../en/ch04-daily.xml:176
dongsheng@627 5149 msgid ""
dongsheng@627 5150 "On the other hand, if you deleted the missing file by accident, give <command "
dongsheng@627 5151 "role=\"hg-cmd\">hg revert</command> the name of the file to recover. It will "
dongsheng@627 5152 "reappear, in unmodified form."
dongsheng@627 5153 msgstr ""
dongsheng@627 5154
dongsheng@627 5155 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 5156 #: ../en/ch04-daily.xml:185
dongsheng@627 5157 msgid "Aside: why tell Mercurial explicitly to remove a file?"
dongsheng@627 5158 msgstr "旁白: 为什么要明确告诉 Mercurial 删除文件?"
dongsheng@627 5159
dongsheng@627 5160 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 5161 #: ../en/ch04-daily.xml:188
dongsheng@627 5162 msgid ""
dongsheng@627 5163 "You might wonder why Mercurial requires you to explicitly tell it that you "
dongsheng@627 5164 "are deleting a file. Early during the development of Mercurial, it let you "
dongsheng@627 5165 "delete a file however you pleased; Mercurial would notice the absence of the "
dongsheng@627 5166 "file automatically when you next ran a <command role=\"hg-cmd\">hg commit</"
dongsheng@627 5167 "command>, and stop tracking the file. In practice, this made it too easy to "
dongsheng@627 5168 "accidentally remove a file without noticing."
dongsheng@627 5169 msgstr ""
dongsheng@627 5170
dongsheng@627 5171 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 5172 #: ../en/ch04-daily.xml:199
songdongsheng@668 5173 msgid "Useful shorthand&emdash;adding and removing files in one step"
dongsheng@661 5174 msgstr "有用的速记—一个步骤添加和删除文件"
dongsheng@627 5175
dongsheng@627 5176 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 5177 #: ../en/ch04-daily.xml:202
dongsheng@627 5178 msgid ""
dongsheng@627 5179 "Mercurial offers a combination command, <command role=\"hg-cmd\">hg "
dongsheng@627 5180 "addremove</command>, that adds untracked files and marks missing files as "
dongsheng@627 5181 "removed."
dongsheng@627 5182 msgstr ""
dongsheng@627 5183
dongsheng@627 5184 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 5185 #: ../en/ch04-daily.xml:208
dongsheng@627 5186 msgid ""
dongsheng@627 5187 "The <command role=\"hg-cmd\">hg commit</command> command also provides a "
dongsheng@627 5188 "<option role=\"hg-opt-commit\">-A</option> option that performs this same add-"
dongsheng@627 5189 "and-remove, immediately followed by a commit."
dongsheng@627 5190 msgstr ""
dongsheng@627 5191
dongsheng@627 5192 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@710 5193 #: ../en/ch04-daily.xml:218
dongsheng@627 5194 msgid "Copying files"
dongsheng@627 5195 msgstr "复制文件"
dongsheng@627 5196
dongsheng@627 5197 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 5198 #: ../en/ch04-daily.xml:220
dongsheng@627 5199 msgid ""
dongsheng@627 5200 "Mercurial provides a <command role=\"hg-cmd\">hg copy</command> command that "
dongsheng@627 5201 "lets you make a new copy of a file. When you copy a file using this command, "
dongsheng@627 5202 "Mercurial makes a record of the fact that the new file is a copy of the "
dongsheng@627 5203 "original file. It treats these copied files specially when you merge your "
dongsheng@627 5204 "work with someone else's."
dongsheng@627 5205 msgstr ""
dongsheng@627 5206
dongsheng@627 5207 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 5208 #: ../en/ch04-daily.xml:228
dongsheng@627 5209 msgid "The results of copying during a merge"
dongsheng@627 5210 msgstr "合并期间的复制结果"
dongsheng@627 5211
dongsheng@627 5212 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 5213 #: ../en/ch04-daily.xml:230
dongsheng@627 5214 msgid ""
dongsheng@627 5215 "What happens during a merge is that changes <quote>follow</quote> a copy. To "
dongsheng@627 5216 "best illustrate what this means, let's create an example. We'll start with "
dongsheng@627 5217 "the usual tiny repository that contains a single file."
dongsheng@627 5218 msgstr ""
dongsheng@627 5219
dongsheng@627 5220 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 5221 #: ../en/ch04-daily.xml:237
dongsheng@627 5222 msgid ""
dongsheng@627 5223 "We need to do some work in parallel, so that we'll have something to merge. "
dongsheng@627 5224 "So let's clone our repository."
dongsheng@627 5225 msgstr ""
dongsheng@627 5226
dongsheng@627 5227 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 5228 #: ../en/ch04-daily.xml:243
dongsheng@627 5229 msgid ""
dongsheng@627 5230 "Back in our initial repository, let's use the <command role=\"hg-cmd\">hg "
dongsheng@627 5231 "copy</command> command to make a copy of the first file we created."
dongsheng@627 5232 msgstr ""
dongsheng@627 5233
dongsheng@627 5234 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 5235 #: ../en/ch04-daily.xml:249
dongsheng@627 5236 msgid ""
dongsheng@627 5237 "If we look at the output of the <command role=\"hg-cmd\">hg status</command> "
dongsheng@627 5238 "command afterwards, the copied file looks just like a normal added file."
dongsheng@627 5239 msgstr ""
dongsheng@627 5240
dongsheng@627 5241 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 5242 #: ../en/ch04-daily.xml:255
dongsheng@627 5243 msgid ""
dongsheng@627 5244 "But if we pass the <option role=\"hg-opt-status\">-C</option> option to "
dongsheng@627 5245 "<command role=\"hg-cmd\">hg status</command>, it prints another line of "
dongsheng@627 5246 "output: this is the file that our newly-added file was copied <emphasis>from</"
dongsheng@627 5247 "emphasis>."
dongsheng@627 5248 msgstr ""
dongsheng@627 5249
dongsheng@627 5250 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 5251 #: ../en/ch04-daily.xml:263
dongsheng@627 5252 msgid ""
dongsheng@627 5253 "Now, back in the repository we cloned, let's make a change in parallel. "
dongsheng@627 5254 "We'll add a line of content to the original file that we created."
dongsheng@627 5255 msgstr ""
dongsheng@627 5256
dongsheng@627 5257 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 5258 #: ../en/ch04-daily.xml:269
dongsheng@627 5259 msgid ""
dongsheng@627 5260 "Now we have a modified <filename>file</filename> in this repository. When we "
dongsheng@627 5261 "pull the changes from the first repository, and merge the two heads, "
dongsheng@627 5262 "Mercurial will propagate the changes that we made locally to <filename>file</"
dongsheng@627 5263 "filename> into its copy, <filename>new-file</filename>."
dongsheng@627 5264 msgstr ""
dongsheng@627 5265
dongsheng@627 5266 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 5267 #: ../en/ch04-daily.xml:279
dongsheng@627 5268 msgid "Why should changes follow copies?"
dongsheng@627 5269 msgstr "为什么复制后需要后续修改?"
dongsheng@627 5270
dongsheng@627 5271 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 5272 #: ../en/ch04-daily.xml:281
songdongsheng@710 5273 msgid ""
songdongsheng@710 5274 "This behavior&emdash;of changes to a file propagating out to copies of the "
songdongsheng@710 5275 "file&emdash;might seem esoteric, but in most cases it's highly desirable."
songdongsheng@710 5276 msgstr ""
songdongsheng@710 5277
songdongsheng@710 5278 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 5279 #: ../en/ch04-daily.xml:285
dongsheng@627 5280 msgid ""
dongsheng@627 5281 "First of all, remember that this propagation <emphasis>only</emphasis> "
dongsheng@627 5282 "happens when you merge. So if you <command role=\"hg-cmd\">hg copy</command> "
dongsheng@627 5283 "a file, and subsequently modify the original file during the normal course of "
dongsheng@627 5284 "your work, nothing will happen."
dongsheng@627 5285 msgstr ""
dongsheng@627 5286
dongsheng@627 5287 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 5288 #: ../en/ch04-daily.xml:291
dongsheng@627 5289 msgid ""
dongsheng@627 5290 "The second thing to know is that modifications will only propagate across a "
songdongsheng@710 5291 "copy as long as the changeset that you're merging changes from "
songdongsheng@710 5292 "<emphasis>hasn't yet seen</emphasis> the copy."
songdongsheng@710 5293 msgstr ""
songdongsheng@710 5294
songdongsheng@710 5295 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 5296 #: ../en/ch04-daily.xml:296
dongsheng@627 5297 msgid ""
dongsheng@627 5298 "The reason that Mercurial does this is as follows. Let's say I make an "
dongsheng@627 5299 "important bug fix in a source file, and commit my changes. Meanwhile, you've "
dongsheng@627 5300 "decided to <command role=\"hg-cmd\">hg copy</command> the file in your "
dongsheng@627 5301 "repository, without knowing about the bug or having seen the fix, and you "
dongsheng@627 5302 "have started hacking on your copy of the file."
dongsheng@627 5303 msgstr ""
dongsheng@627 5304
dongsheng@627 5305 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 5306 #: ../en/ch04-daily.xml:303
dongsheng@627 5307 msgid ""
dongsheng@627 5308 "If you pulled and merged my changes, and Mercurial <emphasis>didn't</"
songdongsheng@710 5309 "emphasis> propagate changes across copies, your new source file would now "
songdongsheng@710 5310 "contain the bug, and unless you knew to propagate the bug fix by hand, the "
songdongsheng@710 5311 "bug would <emphasis>remain</emphasis> in your copy of the file."
songdongsheng@710 5312 msgstr ""
songdongsheng@710 5313
songdongsheng@710 5314 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 5315 #: ../en/ch04-daily.xml:309
dongsheng@627 5316 msgid ""
dongsheng@627 5317 "By automatically propagating the change that fixed the bug from the original "
dongsheng@627 5318 "file to the copy, Mercurial prevents this class of problem. To my knowledge, "
dongsheng@627 5319 "Mercurial is the <emphasis>only</emphasis> revision control system that "
dongsheng@627 5320 "propagates changes across copies like this."
dongsheng@627 5321 msgstr ""
dongsheng@627 5322
dongsheng@627 5323 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 5324 #: ../en/ch04-daily.xml:315
dongsheng@627 5325 msgid ""
dongsheng@627 5326 "Once your change history has a record that the copy and subsequent merge "
dongsheng@627 5327 "occurred, there's usually no further need to propagate changes from the "
dongsheng@627 5328 "original file to the copied file, and that's why Mercurial only propagates "
songdongsheng@710 5329 "changes across copies at the first merge, and not afterwards."
songdongsheng@710 5330 msgstr ""
songdongsheng@710 5331
songdongsheng@710 5332 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 5333 #: ../en/ch04-daily.xml:323
dongsheng@627 5334 msgid "How to make changes <emphasis>not</emphasis> follow a copy"
dongsheng@627 5335 msgstr "如何让复制后<emphasis>不</emphasis>修改?"
dongsheng@627 5336
dongsheng@627 5337 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 5338 #: ../en/ch04-daily.xml:326
dongsheng@627 5339 msgid ""
dongsheng@627 5340 "If, for some reason, you decide that this business of automatically "
dongsheng@627 5341 "propagating changes across copies is not for you, simply use your system's "
dongsheng@627 5342 "normal file copy command (on Unix-like systems, that's <command>cp</command>) "
dongsheng@627 5343 "to make a copy of a file, then <command role=\"hg-cmd\">hg add</command> the "
songdongsheng@658 5344 "new copy by hand. Before you do so, though, please do reread <xref linkend="
songdongsheng@710 5345 "\"sec:daily:why-copy\"/>, and make an informed decision that this behavior is "
songdongsheng@710 5346 "not appropriate to your specific case."
songdongsheng@710 5347 msgstr ""
songdongsheng@710 5348
songdongsheng@710 5349 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 5350 #: ../en/ch04-daily.xml:339
songdongsheng@710 5351 #, fuzzy
songdongsheng@710 5352 msgid "Behavior of the <command role=\"hg-cmd\">hg copy</command> command"
dongsheng@627 5353 msgstr "命令 <command role=\"hg-cmd\">hg copy</command> 的特性"
dongsheng@627 5354
dongsheng@627 5355 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 5356 #: ../en/ch04-daily.xml:342
dongsheng@627 5357 msgid ""
dongsheng@627 5358 "When you use the <command role=\"hg-cmd\">hg copy</command> command, "
dongsheng@627 5359 "Mercurial makes a copy of each source file as it currently stands in the "
dongsheng@627 5360 "working directory. This means that if you make some modifications to a file, "
dongsheng@627 5361 "then <command role=\"hg-cmd\">hg copy</command> it without first having "
dongsheng@627 5362 "committed those changes, the new copy will also contain the modifications you "
songdongsheng@710 5363 "have made up until that point. (I find this behavior a little "
dongsheng@627 5364 "counterintuitive, which is why I mention it here.)"
dongsheng@627 5365 msgstr ""
dongsheng@627 5366
dongsheng@627 5367 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 5368 #: ../en/ch04-daily.xml:352
dongsheng@627 5369 msgid ""
dongsheng@627 5370 "The <command role=\"hg-cmd\">hg copy</command> command acts similarly to the "
dongsheng@627 5371 "Unix <command>cp</command> command (you can use the <command role=\"hg-cmd"
songdongsheng@710 5372 "\">hg cp</command> alias if you prefer). We must supply two or more "
songdongsheng@710 5373 "arguments, of which the last is treated as the <emphasis>destination</"
songdongsheng@710 5374 "emphasis>, and all others are <emphasis>sources</emphasis>."
songdongsheng@710 5375 msgstr ""
songdongsheng@710 5376
songdongsheng@710 5377 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 5378 #: ../en/ch04-daily.xml:360
songdongsheng@710 5379 msgid ""
songdongsheng@710 5380 "If you pass <command role=\"hg-cmd\">hg copy</command> a single file as the "
songdongsheng@710 5381 "source, and the destination does not exist, it creates a new file with that "
songdongsheng@710 5382 "name."
songdongsheng@710 5383 msgstr ""
songdongsheng@710 5384
songdongsheng@710 5385 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 5386 #: ../en/ch04-daily.xml:366
dongsheng@627 5387 msgid ""
dongsheng@627 5388 "If the destination is a directory, Mercurial copies its sources into that "
dongsheng@627 5389 "directory."
dongsheng@627 5390 msgstr ""
dongsheng@627 5391
dongsheng@627 5392 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 5393 #: ../en/ch04-daily.xml:371
dongsheng@627 5394 msgid ""
dongsheng@627 5395 "Copying a directory is recursive, and preserves the directory structure of "
dongsheng@627 5396 "the source."
dongsheng@627 5397 msgstr ""
dongsheng@627 5398
dongsheng@627 5399 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 5400 #: ../en/ch04-daily.xml:377
dongsheng@627 5401 msgid ""
dongsheng@627 5402 "If the source and destination are both directories, the source tree is "
dongsheng@627 5403 "recreated in the destination directory."
dongsheng@627 5404 msgstr ""
dongsheng@627 5405
songdongsheng@710 5406 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 5407 #: ../en/ch04-daily.xml:382
songdongsheng@710 5408 msgid ""
songdongsheng@710 5409 "As with the <command role=\"hg-cmd\">hg remove</command> command, if you copy "
dongsheng@627 5410 "a file manually and then want Mercurial to know that you've copied the file, "
dongsheng@627 5411 "simply use the <option role=\"hg-opt-copy\">--after</option> option to "
dongsheng@627 5412 "<command role=\"hg-cmd\">hg copy</command>."
dongsheng@627 5413 msgstr ""
dongsheng@627 5414
dongsheng@627 5415 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@710 5416 #: ../en/ch04-daily.xml:393
dongsheng@627 5417 msgid "Renaming files"
dongsheng@627 5418 msgstr "改名文件"
dongsheng@627 5419
dongsheng@627 5420 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 5421 #: ../en/ch04-daily.xml:395
dongsheng@627 5422 msgid ""
dongsheng@627 5423 "It's rather more common to need to rename a file than to make a copy of it. "
dongsheng@627 5424 "The reason I discussed the <command role=\"hg-cmd\">hg copy</command> command "
dongsheng@627 5425 "before talking about renaming files is that Mercurial treats a rename in "
dongsheng@627 5426 "essentially the same way as a copy. Therefore, knowing what Mercurial does "
dongsheng@627 5427 "when you copy a file tells you what to expect when you rename a file."
dongsheng@627 5428 msgstr ""
dongsheng@627 5429
dongsheng@627 5430 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 5431 #: ../en/ch04-daily.xml:403
dongsheng@627 5432 msgid ""
dongsheng@627 5433 "When you use the <command role=\"hg-cmd\">hg rename</command> command, "
dongsheng@627 5434 "Mercurial makes a copy of each source file, then deletes it and marks the "
dongsheng@627 5435 "file as removed."
dongsheng@627 5436 msgstr ""
dongsheng@627 5437
dongsheng@627 5438 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 5439 #: ../en/ch04-daily.xml:409
dongsheng@627 5440 msgid ""
dongsheng@627 5441 "The <command role=\"hg-cmd\">hg status</command> command shows the newly "
dongsheng@627 5442 "copied file as added, and the copied-from file as removed."
dongsheng@627 5443 msgstr ""
dongsheng@627 5444
dongsheng@627 5445 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 5446 #: ../en/ch04-daily.xml:415
dongsheng@627 5447 msgid ""
dongsheng@627 5448 "As with the results of a <command role=\"hg-cmd\">hg copy</command>, we must "
dongsheng@627 5449 "use the <option role=\"hg-opt-status\">-C</option> option to <command role="
dongsheng@627 5450 "\"hg-cmd\">hg status</command> to see that the added file is really being "
dongsheng@627 5451 "tracked by Mercurial as a copy of the original, now removed, file."
dongsheng@627 5452 msgstr ""
dongsheng@627 5453
dongsheng@627 5454 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 5455 #: ../en/ch04-daily.xml:424
dongsheng@627 5456 msgid ""
dongsheng@627 5457 "As with <command role=\"hg-cmd\">hg remove</command> and <command role=\"hg-"
dongsheng@627 5458 "cmd\">hg copy</command>, you can tell Mercurial about a rename after the fact "
dongsheng@627 5459 "using the <option role=\"hg-opt-rename\">--after</option> option. In most "
songdongsheng@710 5460 "other respects, the behavior of the <command role=\"hg-cmd\">hg rename</"
dongsheng@627 5461 "command> command, and the options it accepts, are similar to the <command "
dongsheng@627 5462 "role=\"hg-cmd\">hg copy</command> command."
dongsheng@627 5463 msgstr ""
dongsheng@627 5464
songdongsheng@710 5465 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 5466 #: ../en/ch04-daily.xml:433
songdongsheng@710 5467 msgid ""
songdongsheng@710 5468 "If you're familiar with the Unix command line, you'll be glad to know that "
songdongsheng@710 5469 "<command role=\"hg-cmd\">hg rename</command> command can be invoked as "
songdongsheng@710 5470 "<command role=\"hg-cmd\">hg mv</command>."
songdongsheng@710 5471 msgstr ""
songdongsheng@710 5472
songdongsheng@710 5473 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 5474 #: ../en/ch04-daily.xml:439
dongsheng@627 5475 msgid "Renaming files and merging changes"
dongsheng@627 5476 msgstr "改名文件与合并修改"
dongsheng@627 5477
dongsheng@627 5478 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 5479 #: ../en/ch04-daily.xml:441
dongsheng@627 5480 msgid ""
dongsheng@627 5481 "Since Mercurial's rename is implemented as copy-and-remove, the same "
dongsheng@627 5482 "propagation of changes happens when you merge after a rename as after a copy."
dongsheng@627 5483 msgstr ""
dongsheng@627 5484
dongsheng@627 5485 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 5486 #: ../en/ch04-daily.xml:445
dongsheng@627 5487 msgid ""
dongsheng@627 5488 "If I modify a file, and you rename it to a new name, and then we merge our "
dongsheng@627 5489 "respective changes, my modifications to the file under its original name will "
dongsheng@627 5490 "be propagated into the file under its new name. (This is something you might "
dongsheng@627 5491 "expect to <quote>simply work,</quote> but not all revision control systems "
dongsheng@627 5492 "actually do this.)"
dongsheng@627 5493 msgstr ""
dongsheng@627 5494
dongsheng@627 5495 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 5496 #: ../en/ch04-daily.xml:452
dongsheng@627 5497 msgid ""
dongsheng@627 5498 "Whereas having changes follow a copy is a feature where you can perhaps nod "
dongsheng@627 5499 "and say <quote>yes, that might be useful,</quote> it should be clear that "
dongsheng@627 5500 "having them follow a rename is definitely important. Without this facility, "
dongsheng@627 5501 "it would simply be too easy for changes to become orphaned when files are "
dongsheng@627 5502 "renamed."
dongsheng@627 5503 msgstr ""
dongsheng@627 5504
dongsheng@627 5505 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 5506 #: ../en/ch04-daily.xml:461
dongsheng@627 5507 msgid "Divergent renames and merging"
dongsheng@627 5508 msgstr "改名与合并的分歧"
dongsheng@627 5509
dongsheng@627 5510 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 5511 #: ../en/ch04-daily.xml:463
dongsheng@627 5512 msgid ""
songdongsheng@668 5513 "The case of diverging names occurs when two developers start with a "
songdongsheng@668 5514 "file&emdash;let's call it <filename>foo</filename>&emdash;in their respective "
dongsheng@627 5515 "repositories."
dongsheng@627 5516 msgstr ""
dongsheng@627 5517
dongsheng@627 5518 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 5519 #: ../en/ch04-daily.xml:470
dongsheng@627 5520 msgid "Anne renames the file to <filename>bar</filename>."
dongsheng@627 5521 msgstr ""
dongsheng@627 5522
dongsheng@627 5523 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 5524 #: ../en/ch04-daily.xml:474
songdongsheng@710 5525 msgid ""
songdongsheng@710 5526 "Meanwhile, Bob renames it to <filename>quux</filename>. (Remember that "
songdongsheng@710 5527 "<command role=\"hg-cmd\">hg mv</command> is an alias for <command role=\"hg-"
songdongsheng@710 5528 "cmd\">hg rename</command>.)"
songdongsheng@710 5529 msgstr ""
songdongsheng@710 5530
songdongsheng@710 5531 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 5532 #: ../en/ch04-daily.xml:481
dongsheng@627 5533 msgid ""
dongsheng@627 5534 "I like to think of this as a conflict because each developer has expressed "
dongsheng@627 5535 "different intentions about what the file ought to be named."
dongsheng@627 5536 msgstr ""
dongsheng@627 5537
songdongsheng@710 5538 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 5539 #: ../en/ch04-daily.xml:485
dongsheng@627 5540 msgid ""
dongsheng@627 5541 "What do you think should happen when they merge their work? Mercurial's "
songdongsheng@710 5542 "actual behavior is that it always preserves <emphasis>both</emphasis> names "
dongsheng@627 5543 "when it merges changesets that contain divergent renames."
dongsheng@627 5544 msgstr ""
dongsheng@627 5545
dongsheng@627 5546 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 5547 #: ../en/ch04-daily.xml:492
songdongsheng@710 5548 msgid ""
songdongsheng@710 5549 "Notice that while Mercurial warns about the divergent renames, it leaves it "
dongsheng@627 5550 "up to you to do something about the divergence after the merge."
dongsheng@627 5551 msgstr ""
dongsheng@627 5552
dongsheng@627 5553 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 5554 #: ../en/ch04-daily.xml:498
dongsheng@627 5555 msgid "Convergent renames and merging"
dongsheng@627 5556 msgstr "收敛改名与合并"
dongsheng@627 5557
dongsheng@627 5558 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 5559 #: ../en/ch04-daily.xml:500
dongsheng@627 5560 msgid ""
dongsheng@627 5561 "Another kind of rename conflict occurs when two people choose to rename "
dongsheng@627 5562 "different <emphasis>source</emphasis> files to the same "
dongsheng@627 5563 "<emphasis>destination</emphasis>. In this case, Mercurial runs its normal "
dongsheng@627 5564 "merge machinery, and lets you guide it to a suitable resolution."
dongsheng@627 5565 msgstr ""
dongsheng@627 5566
dongsheng@627 5567 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 5568 #: ../en/ch04-daily.xml:508
dongsheng@627 5569 msgid "Other name-related corner cases"
dongsheng@627 5570 msgstr "其它名称相关的角落"
dongsheng@627 5571
dongsheng@627 5572 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 5573 #: ../en/ch04-daily.xml:510
dongsheng@627 5574 msgid ""
dongsheng@627 5575 "Mercurial has a longstanding bug in which it fails to handle a merge where "
dongsheng@627 5576 "one side has a file with a given name, while another has a directory with the "
dongsheng@627 5577 "same name. This is documented as <ulink role=\"hg-bug\" url=\"http://www."
dongsheng@627 5578 "selenic.com/mercurial/bts/issue29\">issue 29</ulink>."
dongsheng@627 5579 msgstr ""
dongsheng@627 5580
dongsheng@627 5581 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@710 5582 #: ../en/ch04-daily.xml:523
dongsheng@627 5583 msgid "Recovering from mistakes"
dongsheng@627 5584 msgstr "从错误恢复"
dongsheng@627 5585
dongsheng@627 5586 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 5587 #: ../en/ch04-daily.xml:525
dongsheng@627 5588 msgid ""
dongsheng@627 5589 "Mercurial has some useful commands that will help you to recover from some "
dongsheng@627 5590 "common mistakes."
dongsheng@627 5591 msgstr ""
dongsheng@627 5592
dongsheng@627 5593 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 5594 #: ../en/ch04-daily.xml:528
dongsheng@627 5595 msgid ""
dongsheng@627 5596 "The <command role=\"hg-cmd\">hg revert</command> command lets you undo "
dongsheng@627 5597 "changes that you have made to your working directory. For example, if you "
dongsheng@627 5598 "<command role=\"hg-cmd\">hg add</command> a file by accident, just run "
dongsheng@627 5599 "<command role=\"hg-cmd\">hg revert</command> with the name of the file you "
dongsheng@627 5600 "added, and while the file won't be touched in any way, it won't be tracked "
dongsheng@627 5601 "for adding by Mercurial any longer, either. You can also use <command role="
dongsheng@627 5602 "\"hg-cmd\">hg revert</command> to get rid of erroneous changes to a file."
dongsheng@627 5603 msgstr ""
dongsheng@627 5604
dongsheng@627 5605 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 5606 #: ../en/ch04-daily.xml:538
songdongsheng@710 5607 msgid ""
songdongsheng@710 5608 "It's good to remember that the <command role=\"hg-cmd\">hg revert</command> "
dongsheng@627 5609 "command is useful for changes that you have not yet committed. Once you've "
dongsheng@627 5610 "committed a change, if you decide it was a mistake, you can still do "
dongsheng@627 5611 "something about it, though your options may be more limited."
dongsheng@627 5612 msgstr ""
dongsheng@627 5613
dongsheng@627 5614 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 5615 #: ../en/ch04-daily.xml:544
dongsheng@627 5616 msgid ""
dongsheng@627 5617 "For more information about the <command role=\"hg-cmd\">hg revert</command> "
dongsheng@627 5618 "command, and details about how to deal with changes you have already "
songdongsheng@658 5619 "committed, see <xref linkend=\"chap:undo\"/>."
dongsheng@627 5620 msgstr ""
dongsheng@627 5621
songdongsheng@710 5622 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@710 5623 #: ../en/ch04-daily.xml:551
songdongsheng@710 5624 #, fuzzy
songdongsheng@710 5625 msgid "Dealing with tricky merges"
songdongsheng@710 5626 msgstr "处理已经提交的修改"
songdongsheng@710 5627
songdongsheng@710 5628 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 5629 #: ../en/ch04-daily.xml:553
songdongsheng@710 5630 msgid ""
songdongsheng@710 5631 "In a complicated or large project, it's not unusual for a merge of two "
songdongsheng@710 5632 "changesets to result in some headaches. Suppose there's a big source file "
songdongsheng@710 5633 "that's been extensively edited by each side of a merge: this is almost "
songdongsheng@710 5634 "inevitably going to result in conflicts, some of which can take a few tries "
songdongsheng@710 5635 "to sort out."
songdongsheng@710 5636 msgstr ""
songdongsheng@710 5637
songdongsheng@710 5638 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 5639 #: ../en/ch04-daily.xml:560
songdongsheng@710 5640 msgid ""
songdongsheng@710 5641 "Let's develop a simple case of this and see how to deal with it. We'll start "
songdongsheng@710 5642 "off with a repository containing one file, and clone it twice."
songdongsheng@710 5643 msgstr ""
songdongsheng@710 5644
songdongsheng@710 5645 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 5646 #: ../en/ch04-daily.xml:566
songdongsheng@710 5647 msgid "In one clone, we'll modify the file in one way."
songdongsheng@710 5648 msgstr ""
songdongsheng@710 5649
songdongsheng@710 5650 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 5651 #: ../en/ch04-daily.xml:570
songdongsheng@710 5652 msgid "In another, we'll modify the file differently."
songdongsheng@710 5653 msgstr ""
songdongsheng@710 5654
songdongsheng@710 5655 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 5656 #: ../en/ch04-daily.xml:574
songdongsheng@710 5657 msgid "Next, we'll pull each set of changes into our original repo."
songdongsheng@710 5658 msgstr ""
songdongsheng@710 5659
songdongsheng@710 5660 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 5661 #: ../en/ch04-daily.xml:579
songdongsheng@710 5662 msgid "We expect our repository to now contain two heads."
songdongsheng@710 5663 msgstr ""
songdongsheng@710 5664
songdongsheng@710 5665 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 5666 #: ../en/ch04-daily.xml:583
songdongsheng@710 5667 msgid ""
songdongsheng@710 5668 "Normally, if we run <command role=\"hg-cmd\">hg merge</command> at this "
songdongsheng@710 5669 "point, it will drop us into a GUI that will let us manually resolve the "
songdongsheng@710 5670 "conflicting edits to <filename>myfile.txt</filename>. However, to simplify "
songdongsheng@710 5671 "things for presentation here, we'd like the merge to fail immediately "
songdongsheng@710 5672 "instead. Here's one way we can do so."
songdongsheng@710 5673 msgstr ""
songdongsheng@710 5674
songdongsheng@710 5675 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 5676 #: ../en/ch04-daily.xml:592
songdongsheng@710 5677 msgid ""
songdongsheng@710 5678 "We've told Mercurial's merge machinery to run the command <command>false</"
songdongsheng@710 5679 "command> (which, as we desire, fails immediately) if it detects a merge that "
songdongsheng@710 5680 "it can't sort out automatically."
songdongsheng@710 5681 msgstr ""
songdongsheng@710 5682
songdongsheng@710 5683 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 5684 #: ../en/ch04-daily.xml:597
songdongsheng@710 5685 msgid ""
songdongsheng@710 5686 "If we now fire up <command role=\"hg-cmd\">hg merge</command>, it should "
songdongsheng@710 5687 "grind to a halt and report a failure."
songdongsheng@710 5688 msgstr ""
songdongsheng@710 5689
songdongsheng@710 5690 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 5691 #: ../en/ch04-daily.xml:603
songdongsheng@710 5692 msgid ""
songdongsheng@710 5693 "Even if we don't notice that the merge failed, Mercurial will prevent us from "
songdongsheng@710 5694 "accidentally committing the result of a failed merge."
songdongsheng@710 5695 msgstr ""
songdongsheng@710 5696
songdongsheng@710 5697 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 5698 #: ../en/ch04-daily.xml:609
songdongsheng@710 5699 msgid ""
songdongsheng@710 5700 "When <command role=\"hg-cmd\">hg commit</command> fails in this case, it "
songdongsheng@710 5701 "suggests that we use the unfamiliar <command role=\"hg-cmd\">hg resolve</"
songdongsheng@710 5702 "command> command. As usual, <command role=\"hg-cmd\">hg help resolve</"
songdongsheng@710 5703 "command> will print a helpful synopsis."
songdongsheng@710 5704 msgstr ""
songdongsheng@710 5705
songdongsheng@710 5706 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 5707 #: ../en/ch04-daily.xml:616
songdongsheng@710 5708 msgid "File resolution states"
songdongsheng@710 5709 msgstr ""
songdongsheng@710 5710
songdongsheng@710 5711 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 5712 #: ../en/ch04-daily.xml:618
songdongsheng@710 5713 msgid ""
songdongsheng@710 5714 "When a merge occurs, most files will usually remain unmodified. For each "
songdongsheng@710 5715 "file where Mercurial has to do something, it tracks the state of the file."
songdongsheng@710 5716 msgstr ""
songdongsheng@710 5717
songdongsheng@710 5718 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@710 5719 #: ../en/ch04-daily.xml:624
songdongsheng@710 5720 msgid ""
songdongsheng@710 5721 "A <emphasis>resolved</emphasis> file has been successfully merged, either "
songdongsheng@710 5722 "automatically by Mercurial or manually with human intervention."
songdongsheng@710 5723 msgstr ""
songdongsheng@710 5724
songdongsheng@710 5725 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@710 5726 #: ../en/ch04-daily.xml:629
songdongsheng@710 5727 msgid ""
songdongsheng@710 5728 "An <emphasis>unresolved</emphasis> file was not merged successfully, and "
songdongsheng@710 5729 "needs more attention."
songdongsheng@710 5730 msgstr ""
songdongsheng@710 5731
songdongsheng@710 5732 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 5733 #: ../en/ch04-daily.xml:634
songdongsheng@710 5734 msgid ""
songdongsheng@710 5735 "If Mercurial sees <emphasis>any</emphasis> file in the unresolved state after "
songdongsheng@710 5736 "a merge, it considers the merge to have failed. Fortunately, we do not need "
songdongsheng@710 5737 "to restart the entire merge from scratch."
songdongsheng@710 5738 msgstr ""
songdongsheng@710 5739
songdongsheng@710 5740 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 5741 #: ../en/ch04-daily.xml:639
songdongsheng@710 5742 msgid ""
songdongsheng@710 5743 "The <option role=\"hg-opt-resolve\">--list</option> or <option role=\"hg-opt-"
songdongsheng@710 5744 "resolve\">-l</option> option to <command role=\"hg-cmd\">hg resolve</command> "
songdongsheng@710 5745 "prints out the state of each merged file."
songdongsheng@710 5746 msgstr ""
songdongsheng@710 5747
songdongsheng@710 5748 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 5749 #: ../en/ch04-daily.xml:646
songdongsheng@710 5750 msgid ""
songdongsheng@710 5751 "In the output from <command role=\"hg-cmd\">hg resolve</command>, a resolved "
songdongsheng@710 5752 "file is marked with <literal>R</literal>, while an unresolved file is marked "
songdongsheng@710 5753 "with <literal>U</literal>. If any files are listed with <literal>U</"
songdongsheng@710 5754 "literal>, we know that an attempt to commit the results of the merge will "
songdongsheng@710 5755 "fail."
songdongsheng@710 5756 msgstr ""
songdongsheng@710 5757
songdongsheng@710 5758 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 5759 #: ../en/ch04-daily.xml:655
songdongsheng@710 5760 #, fuzzy
songdongsheng@710 5761 msgid "Resolving a file merge"
songdongsheng@710 5762 msgstr "执行合并"
songdongsheng@710 5763
songdongsheng@710 5764 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 5765 #: ../en/ch04-daily.xml:657
songdongsheng@710 5766 msgid ""
songdongsheng@710 5767 "We have several options to move a file from the unresolved into the resolved "
songdongsheng@710 5768 "state. By far the most common is to rerun <command role=\"hg-cmd\">hg "
songdongsheng@710 5769 "resolve</command>. If we pass the names of individual files or directories, "
songdongsheng@710 5770 "it will retry the merges of any unresolved files present in those locations. "
songdongsheng@710 5771 "We can also pass the <option role=\"hg-opt-resolve\">--all</option> or "
songdongsheng@710 5772 "<option role=\"hg-opt-resolve\">-a</option> option, which will retry the "
songdongsheng@710 5773 "merges of <emphasis>all</emphasis> unresolved files."
songdongsheng@710 5774 msgstr ""
songdongsheng@710 5775
songdongsheng@710 5776 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 5777 #: ../en/ch04-daily.xml:667
songdongsheng@710 5778 msgid ""
songdongsheng@710 5779 "Mercurial also lets us modify the resolution state of a file directly. We "
songdongsheng@710 5780 "can manually mark a file as resolved using the <option role=\"hg-opt-resolve"
songdongsheng@710 5781 "\">--mark</option> option, or as unresolved using the <option role=\"hg-opt-"
songdongsheng@710 5782 "resolve\">--unmark</option> option. This allows us to clean up a "
songdongsheng@710 5783 "particularly messy merge by hand, and to keep track of our progress with each "
songdongsheng@710 5784 "file as we go."
songdongsheng@710 5785 msgstr ""
songdongsheng@710 5786
dongsheng@627 5787 #. type: Content of: <book><chapter><title>
dongsheng@650 5788 #: ../en/ch05-collab.xml:5
dongsheng@627 5789 msgid "Collaborating with other people"
dongsheng@627 5790 msgstr "团体协作"
dongsheng@627 5791
dongsheng@627 5792 #. type: Content of: <book><chapter><para>
dongsheng@650 5793 #: ../en/ch05-collab.xml:7
dongsheng@627 5794 msgid ""
dongsheng@627 5795 "As a completely decentralised tool, Mercurial doesn't impose any policy on "
dongsheng@627 5796 "how people ought to work with each other. However, if you're new to "
dongsheng@627 5797 "distributed revision control, it helps to have some tools and examples in "
dongsheng@627 5798 "mind when you're thinking about possible workflow models."
dongsheng@627 5799 msgstr ""
dongsheng@627 5800
dongsheng@627 5801 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 5802 #: ../en/ch05-collab.xml:14
dongsheng@627 5803 msgid "Mercurial's web interface"
dongsheng@630 5804 msgstr "Mercurial 的 web 接口"
dongsheng@627 5805
dongsheng@627 5806 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 5807 #: ../en/ch05-collab.xml:16
dongsheng@627 5808 msgid ""
dongsheng@627 5809 "Mercurial has a powerful web interface that provides several useful "
dongsheng@627 5810 "capabilities."
dongsheng@627 5811 msgstr ""
dongsheng@627 5812
dongsheng@627 5813 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 5814 #: ../en/ch05-collab.xml:19
dongsheng@627 5815 msgid ""
dongsheng@627 5816 "For interactive use, the web interface lets you browse a single repository or "
dongsheng@627 5817 "a collection of repositories. You can view the history of a repository, "
dongsheng@627 5818 "examine each change (comments and diffs), and view the contents of each "
songdongsheng@710 5819 "directory and file. You can even get a view of history that gives a "
songdongsheng@710 5820 "graphical view of the relationships between individual changes and merges."
songdongsheng@710 5821 msgstr ""
songdongsheng@710 5822
songdongsheng@710 5823 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 5824 #: ../en/ch05-collab.xml:26
songdongsheng@710 5825 msgid ""
songdongsheng@710 5826 "Also for human consumption, the web interface provides Atom and RSS feeds of "
songdongsheng@710 5827 "the changes in a repository. This lets you <quote>subscribe</quote> to a "
songdongsheng@710 5828 "repository using your favorite feed reader, and be automatically notified of "
dongsheng@627 5829 "activity in that repository as soon as it happens. I find this capability "
dongsheng@627 5830 "much more convenient than the model of subscribing to a mailing list to which "
dongsheng@627 5831 "notifications are sent, as it requires no additional configuration on the "
dongsheng@627 5832 "part of whoever is serving the repository."
dongsheng@627 5833 msgstr ""
dongsheng@627 5834
dongsheng@627 5835 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 5836 #: ../en/ch05-collab.xml:36
dongsheng@627 5837 msgid ""
dongsheng@627 5838 "The web interface also lets remote users clone a repository, pull changes "
dongsheng@627 5839 "from it, and (when the server is configured to permit it) push changes back "
dongsheng@627 5840 "to it. Mercurial's HTTP tunneling protocol aggressively compresses data, so "
dongsheng@627 5841 "that it works efficiently even over low-bandwidth network connections."
dongsheng@627 5842 msgstr ""
dongsheng@627 5843
dongsheng@627 5844 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 5845 #: ../en/ch05-collab.xml:42
dongsheng@627 5846 msgid ""
dongsheng@627 5847 "The easiest way to get started with the web interface is to use your web "
dongsheng@627 5848 "browser to visit an existing repository, such as the master Mercurial "
songdongsheng@710 5849 "repository at <ulink url=\"http://www.selenic.com/repo/hg\">http://www."
songdongsheng@710 5850 "selenic.com/repo/hg</ulink>."
songdongsheng@710 5851 msgstr ""
songdongsheng@710 5852
songdongsheng@710 5853 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 5854 #: ../en/ch05-collab.xml:47
dongsheng@627 5855 msgid ""
dongsheng@627 5856 "If you're interested in providing a web interface to your own repositories, "
songdongsheng@710 5857 "there are several good ways to do this."
songdongsheng@710 5858 msgstr ""
songdongsheng@710 5859
songdongsheng@710 5860 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 5861 #: ../en/ch05-collab.xml:51
songdongsheng@710 5862 msgid ""
songdongsheng@710 5863 "The easiest and fastest way to get started in an informal environment is to "
songdongsheng@710 5864 "use the <command role=\"hg-cmd\">hg serve</command> command, which is best "
songdongsheng@710 5865 "suited to short-term <quote>lightweight</quote> serving. See <xref linkend="
songdongsheng@710 5866 "\"sec:collab:serve\"/> below for details of how to use this command."
songdongsheng@710 5867 msgstr ""
songdongsheng@710 5868
songdongsheng@710 5869 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 5870 #: ../en/ch05-collab.xml:58
songdongsheng@710 5871 msgid ""
songdongsheng@710 5872 "For longer-lived repositories that you'd like to have permanently available, "
songdongsheng@710 5873 "there are several public hosting services available."
songdongsheng@710 5874 msgstr ""
songdongsheng@710 5875
songdongsheng@710 5876 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@710 5877 #: ../en/ch05-collab.xml:64
songdongsheng@710 5878 msgid ""
songdongsheng@710 5879 "Bitbucket, at <ulink url=\"http://bitbucket.org/\">http://bitbucket.org/</"
songdongsheng@710 5880 "ulink>, provides free hosting for open source projects, and paid hosting for "
songdongsheng@710 5881 "commercial projects."
songdongsheng@710 5882 msgstr ""
songdongsheng@710 5883
songdongsheng@710 5884 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 5885 #: ../en/ch05-collab.xml:71
songdongsheng@710 5886 msgid ""
songdongsheng@710 5887 "If you would prefer to host your own repositories, Mercurial has built-in "
songdongsheng@710 5888 "support for several popular hosting technologies, most notably CGI (Common "
songdongsheng@710 5889 "Gateway Interface), and WSGI (Web Services Gateway Interface). See <xref "
songdongsheng@710 5890 "linkend=\"sec:collab:cgi\"/> for details of CGI and WSGI configuration."
dongsheng@627 5891 msgstr ""
dongsheng@627 5892
dongsheng@627 5893 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@710 5894 #: ../en/ch05-collab.xml:80
dongsheng@627 5895 msgid "Collaboration models"
dongsheng@630 5896 msgstr "协作模型"
dongsheng@627 5897
dongsheng@627 5898 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 5899 #: ../en/ch05-collab.xml:82
dongsheng@627 5900 msgid ""
dongsheng@627 5901 "With a suitably flexible tool, making decisions about workflow is much more "
dongsheng@627 5902 "of a social engineering challenge than a technical one. Mercurial imposes few "
dongsheng@627 5903 "limitations on how you can structure the flow of work in a project, so it's "
dongsheng@627 5904 "up to you and your group to set up and live with a model that matches your "
dongsheng@627 5905 "own particular needs."
dongsheng@627 5906 msgstr ""
dongsheng@627 5907
dongsheng@627 5908 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 5909 #: ../en/ch05-collab.xml:90
dongsheng@627 5910 msgid "Factors to keep in mind"
dongsheng@630 5911 msgstr "要牢记的因素"
dongsheng@627 5912
dongsheng@627 5913 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 5914 #: ../en/ch05-collab.xml:92
dongsheng@627 5915 msgid ""
dongsheng@627 5916 "The most important aspect of any model that you must keep in mind is how well "
dongsheng@627 5917 "it matches the needs and capabilities of the people who will be using it. "
dongsheng@627 5918 "This might seem self-evident; even so, you still can't afford to forget it "
dongsheng@627 5919 "for a moment."
dongsheng@627 5920 msgstr ""
dongsheng@627 5921
dongsheng@627 5922 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 5923 #: ../en/ch05-collab.xml:98
dongsheng@627 5924 msgid ""
dongsheng@627 5925 "I once put together a workflow model that seemed to make perfect sense to me, "
dongsheng@627 5926 "but that caused a considerable amount of consternation and strife within my "
dongsheng@627 5927 "development team. In spite of my attempts to explain why we needed a complex "
dongsheng@627 5928 "set of branches, and how changes ought to flow between them, a few team "
dongsheng@627 5929 "members revolted. Even though they were smart people, they didn't want to "
dongsheng@627 5930 "pay attention to the constraints we were operating under, or face the "
dongsheng@627 5931 "consequences of those constraints in the details of the model that I was "
dongsheng@627 5932 "advocating."
dongsheng@627 5933 msgstr ""
dongsheng@627 5934
dongsheng@627 5935 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 5936 #: ../en/ch05-collab.xml:108
dongsheng@627 5937 msgid ""
dongsheng@627 5938 "Don't sweep foreseeable social or technical problems under the rug. Whatever "
dongsheng@627 5939 "scheme you put into effect, you should plan for mistakes and problem "
dongsheng@627 5940 "scenarios. Consider adding automated machinery to prevent, or quickly "
dongsheng@627 5941 "recover from, trouble that you can anticipate. As an example, if you intend "
dongsheng@627 5942 "to have a branch with not-for-release changes in it, you'd do well to think "
dongsheng@627 5943 "early about the possibility that someone might accidentally merge those "
dongsheng@627 5944 "changes into a release branch. You could avoid this particular problem by "
dongsheng@627 5945 "writing a hook that prevents changes from being merged from an inappropriate "
dongsheng@627 5946 "branch."
dongsheng@627 5947 msgstr ""
dongsheng@627 5948
dongsheng@627 5949 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 5950 #: ../en/ch05-collab.xml:122
dongsheng@627 5951 msgid "Informal anarchy"
dongsheng@630 5952 msgstr "无政府状态"
dongsheng@627 5953
dongsheng@627 5954 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 5955 #: ../en/ch05-collab.xml:124
dongsheng@627 5956 msgid ""
dongsheng@627 5957 "I wouldn't suggest an <quote>anything goes</quote> approach as something "
dongsheng@627 5958 "sustainable, but it's a model that's easy to grasp, and it works perfectly "
dongsheng@627 5959 "well in a few unusual situations."
dongsheng@627 5960 msgstr ""
dongsheng@627 5961
dongsheng@627 5962 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 5963 #: ../en/ch05-collab.xml:129
dongsheng@627 5964 msgid ""
dongsheng@627 5965 "As one example, many projects have a loose-knit group of collaborators who "
dongsheng@627 5966 "rarely physically meet each other. Some groups like to overcome the "
songdongsheng@710 5967 "isolation of working at a distance by organizing occasional <quote>sprints</"
dongsheng@627 5968 "quote>. In a sprint, a number of people get together in a single location (a "
dongsheng@627 5969 "company's conference room, a hotel meeting room, that kind of place) and "
dongsheng@627 5970 "spend several days more or less locked in there, hacking intensely on a "
dongsheng@627 5971 "handful of projects."
dongsheng@627 5972 msgstr ""
dongsheng@627 5973
dongsheng@627 5974 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 5975 #: ../en/ch05-collab.xml:138
songdongsheng@710 5976 msgid ""
songdongsheng@710 5977 "A sprint or a hacking session in a coffee shop are the perfect places to use "
songdongsheng@710 5978 "the <command role=\"hg-cmd\">hg serve</command> command, since <command role="
songdongsheng@710 5979 "\"hg-cmd\">hg serve</command> does not require any fancy server "
songdongsheng@710 5980 "infrastructure. You can get started with <command role=\"hg-cmd\">hg serve</"
songdongsheng@710 5981 "command> in moments, by reading <xref linkend=\"sec:collab:serve\"/> below. "
songdongsheng@710 5982 "Then simply tell the person next to you that you're running a server, send "
songdongsheng@710 5983 "the URL to them in an instant message, and you immediately have a quick-"
songdongsheng@710 5984 "turnaround way to work together. They can type your URL into their web "
songdongsheng@710 5985 "browser and quickly review your changes; or they can pull a bugfix from you "
songdongsheng@710 5986 "and verify it; or they can clone a branch containing a new feature and try it "
songdongsheng@710 5987 "out."
songdongsheng@710 5988 msgstr ""
songdongsheng@710 5989
songdongsheng@710 5990 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 5991 #: ../en/ch05-collab.xml:152
dongsheng@627 5992 msgid ""
dongsheng@627 5993 "The charm, and the problem, with doing things in an ad hoc fashion like this "
dongsheng@627 5994 "is that only people who know about your changes, and where they are, can see "
dongsheng@627 5995 "them. Such an informal approach simply doesn't scale beyond a handful "
songdongsheng@710 5996 "people, because each individual needs to know about <emphasis>n</emphasis> "
songdongsheng@710 5997 "different repositories to pull from."
songdongsheng@710 5998 msgstr ""
songdongsheng@710 5999
songdongsheng@710 6000 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 6001 #: ../en/ch05-collab.xml:162
dongsheng@627 6002 msgid "A single central repository"
dongsheng@630 6003 msgstr "单一中央版本库"
dongsheng@627 6004
dongsheng@627 6005 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6006 #: ../en/ch05-collab.xml:164
dongsheng@627 6007 msgid ""
dongsheng@627 6008 "For smaller projects migrating from a centralised revision control tool, "
dongsheng@627 6009 "perhaps the easiest way to get started is to have changes flow through a "
dongsheng@627 6010 "single shared central repository. This is also the most common "
dongsheng@627 6011 "<quote>building block</quote> for more ambitious workflow schemes."
dongsheng@627 6012 msgstr ""
dongsheng@627 6013
dongsheng@627 6014 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6015 #: ../en/ch05-collab.xml:170
dongsheng@627 6016 msgid ""
dongsheng@627 6017 "Contributors start by cloning a copy of this repository. They can pull "
dongsheng@627 6018 "changes from it whenever they need to, and some (perhaps all) developers have "
dongsheng@627 6019 "permission to push a change back when they're ready for other people to see "
dongsheng@627 6020 "it."
dongsheng@627 6021 msgstr ""
dongsheng@627 6022
dongsheng@627 6023 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6024 #: ../en/ch05-collab.xml:175
dongsheng@627 6025 msgid ""
dongsheng@627 6026 "Under this model, it can still often make sense for people to pull changes "
dongsheng@627 6027 "directly from each other, without going through the central repository. "
dongsheng@627 6028 "Consider a case in which I have a tentative bug fix, but I am worried that if "
dongsheng@627 6029 "I were to publish it to the central repository, it might subsequently break "
dongsheng@627 6030 "everyone else's trees as they pull it. To reduce the potential for damage, I "
dongsheng@627 6031 "can ask you to clone my repository into a temporary repository of your own "
dongsheng@627 6032 "and test it. This lets us put off publishing the potentially unsafe change "
dongsheng@627 6033 "until it has had a little testing."
dongsheng@627 6034 msgstr ""
dongsheng@627 6035
dongsheng@627 6036 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6037 #: ../en/ch05-collab.xml:186
songdongsheng@710 6038 msgid ""
songdongsheng@710 6039 "If a team is hosting its own repository in this kind of scenario, people will "
songdongsheng@710 6040 "usually use the <command>ssh</command> protocol to securely push changes to "
songdongsheng@710 6041 "the central repository, as documented in <xref linkend=\"sec:collab:ssh\"/>. "
songdongsheng@710 6042 "It's also usual to publish a read-only copy of the repository over HTTP, as "
songdongsheng@710 6043 "in <xref linkend=\"sec:collab:cgi\"/>. Publishing over HTTP satisfies the "
songdongsheng@710 6044 "needs of people who don't have push access, and those who want to use web "
songdongsheng@710 6045 "browsers to browse the repository's history."
songdongsheng@710 6046 msgstr ""
songdongsheng@710 6047
songdongsheng@710 6048 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 6049 #: ../en/ch05-collab.xml:199
songdongsheng@710 6050 #, fuzzy
songdongsheng@710 6051 msgid "A hosted central repository"
songdongsheng@710 6052 msgstr "单一中央版本库"
songdongsheng@710 6053
songdongsheng@710 6054 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6055 #: ../en/ch05-collab.xml:201
songdongsheng@710 6056 msgid ""
songdongsheng@710 6057 "A wonderful thing about public hosting services like <ulink url=\"http://"
songdongsheng@710 6058 "bitbucket.org/\">Bitbucket</ulink> is that not only do they handle the fiddly "
songdongsheng@710 6059 "server configuration details, such as user accounts, authentication, and "
songdongsheng@710 6060 "secure wire protocols, they provide additional infrastructure to make this "
songdongsheng@710 6061 "model work well."
songdongsheng@710 6062 msgstr ""
songdongsheng@710 6063
songdongsheng@710 6064 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6065 #: ../en/ch05-collab.xml:208
songdongsheng@710 6066 msgid ""
songdongsheng@710 6067 "For instance, a well-engineered hosting service will let people clone their "
songdongsheng@710 6068 "own copies of a repository with a single click. This lets people work in "
songdongsheng@710 6069 "separate spaces and share their changes when they're ready."
songdongsheng@710 6070 msgstr ""
songdongsheng@710 6071
songdongsheng@710 6072 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6073 #: ../en/ch05-collab.xml:213
songdongsheng@710 6074 msgid ""
songdongsheng@710 6075 "In addition, a good hosting service will let people communicate with each "
songdongsheng@710 6076 "other, for instance to say <quote>there are changes ready for you to review "
songdongsheng@710 6077 "in this tree</quote>."
songdongsheng@710 6078 msgstr ""
songdongsheng@710 6079
songdongsheng@710 6080 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 6081 #: ../en/ch05-collab.xml:220
dongsheng@627 6082 msgid "Working with multiple branches"
dongsheng@630 6083 msgstr "使用多个分支工作"
dongsheng@627 6084
dongsheng@627 6085 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6086 #: ../en/ch05-collab.xml:222
dongsheng@627 6087 msgid ""
dongsheng@627 6088 "Projects of any significant size naturally tend to make progress on several "
dongsheng@627 6089 "fronts simultaneously. In the case of software, it's common for a project to "
dongsheng@627 6090 "go through periodic official releases. A release might then go into "
dongsheng@627 6091 "<quote>maintenance mode</quote> for a while after its first publication; "
dongsheng@627 6092 "maintenance releases tend to contain only bug fixes, not new features. In "
dongsheng@627 6093 "parallel with these maintenance releases, one or more future releases may be "
dongsheng@627 6094 "under development. People normally use the word <quote>branch</quote> to "
dongsheng@627 6095 "refer to one of these many slightly different directions in which development "
dongsheng@627 6096 "is proceeding."
dongsheng@627 6097 msgstr ""
dongsheng@627 6098
dongsheng@627 6099 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6100 #: ../en/ch05-collab.xml:235
dongsheng@627 6101 msgid ""
dongsheng@627 6102 "Mercurial is particularly well suited to managing a number of simultaneous, "
dongsheng@627 6103 "but not identical, branches. Each <quote>development direction</quote> can "
dongsheng@627 6104 "live in its own central repository, and you can merge changes from one to "
dongsheng@627 6105 "another as the need arises. Because repositories are independent of each "
dongsheng@627 6106 "other, unstable changes in a development branch will never affect a stable "
songdongsheng@710 6107 "branch unless someone explicitly merges those changes into the stable branch."
songdongsheng@710 6108 msgstr ""
songdongsheng@710 6109
songdongsheng@710 6110 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6111 #: ../en/ch05-collab.xml:244
dongsheng@627 6112 msgid ""
dongsheng@627 6113 "Here's an example of how this can work in practice. Let's say you have one "
dongsheng@627 6114 "<quote>main branch</quote> on a central server."
dongsheng@627 6115 msgstr ""
dongsheng@627 6116
dongsheng@627 6117 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6118 #: ../en/ch05-collab.xml:250
dongsheng@627 6119 msgid "People clone it, make changes locally, test them, and push them back."
dongsheng@627 6120 msgstr ""
dongsheng@627 6121
dongsheng@627 6122 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6123 #: ../en/ch05-collab.xml:253
dongsheng@627 6124 msgid ""
dongsheng@627 6125 "Once the main branch reaches a release milestone, you can use the <command "
dongsheng@627 6126 "role=\"hg-cmd\">hg tag</command> command to give a permanent name to the "
dongsheng@627 6127 "milestone revision."
dongsheng@627 6128 msgstr ""
dongsheng@627 6129
dongsheng@627 6130 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6131 #: ../en/ch05-collab.xml:259
dongsheng@627 6132 msgid "Let's say some ongoing development occurs on the main branch."
dongsheng@627 6133 msgstr ""
dongsheng@627 6134
dongsheng@627 6135 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6136 #: ../en/ch05-collab.xml:264
dongsheng@627 6137 msgid ""
dongsheng@627 6138 "Using the tag that was recorded at the milestone, people who clone that "
dongsheng@627 6139 "repository at any time in the future can use <command role=\"hg-cmd\">hg "
dongsheng@627 6140 "update</command> to get a copy of the working directory exactly as it was "
dongsheng@627 6141 "when that tagged revision was committed."
dongsheng@627 6142 msgstr ""
dongsheng@627 6143
songdongsheng@710 6144 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6145 #: ../en/ch05-collab.xml:272
songdongsheng@710 6146 msgid ""
songdongsheng@710 6147 "In addition, immediately after the main branch is tagged, we can then clone "
songdongsheng@710 6148 "the main branch on the server to a new <quote>stable</quote> branch, also on "
songdongsheng@710 6149 "the server."
songdongsheng@710 6150 msgstr ""
songdongsheng@710 6151
songdongsheng@710 6152 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6153 #: ../en/ch05-collab.xml:278
songdongsheng@710 6154 msgid ""
songdongsheng@710 6155 "If we need to make a change to the stable branch, we can then clone "
songdongsheng@710 6156 "<emphasis>that</emphasis> repository, make our changes, commit, and push our "
songdongsheng@710 6157 "changes back there."
songdongsheng@710 6158 msgstr ""
songdongsheng@710 6159
songdongsheng@710 6160 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6161 #: ../en/ch05-collab.xml:285
dongsheng@627 6162 msgid ""
dongsheng@627 6163 "Because Mercurial repositories are independent, and Mercurial doesn't move "
dongsheng@627 6164 "changes around automatically, the stable and main branches are "
songdongsheng@710 6165 "<emphasis>isolated</emphasis> from each other. The changes that we made on "
dongsheng@627 6166 "the main branch don't <quote>leak</quote> to the stable branch, and vice "
dongsheng@627 6167 "versa."
dongsheng@627 6168 msgstr ""
dongsheng@627 6169
dongsheng@627 6170 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6171 #: ../en/ch05-collab.xml:292
songdongsheng@710 6172 msgid ""
songdongsheng@710 6173 "We'll often want all of our bugfixes on the stable branch to show up on the "
songdongsheng@710 6174 "main branch, too. Rather than rewrite a bugfix on the main branch, we can "
dongsheng@627 6175 "simply pull and merge changes from the stable to the main branch, and "
songdongsheng@710 6176 "Mercurial will bring those bugfixes in for us."
songdongsheng@710 6177 msgstr ""
songdongsheng@710 6178
songdongsheng@710 6179 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6180 #: ../en/ch05-collab.xml:300
dongsheng@627 6181 msgid ""
dongsheng@627 6182 "The main branch will still contain changes that are not on the stable branch, "
dongsheng@627 6183 "but it will also contain all of the bugfixes from the stable branch. The "
songdongsheng@710 6184 "stable branch remains unaffected by these changes, since changes are only "
songdongsheng@710 6185 "flowing from the stable to the main branch, and not the other way."
dongsheng@627 6186 msgstr ""
dongsheng@627 6187
songdongsheng@658 6188 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
songdongsheng@710 6189 #: ../en/ch05-collab.xml:309 ../en/ch05-collab.xml:319
dongsheng@627 6190 msgid "Feature branches"
dongsheng@630 6191 msgstr "特性分支"
dongsheng@627 6192
dongsheng@627 6193 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6194 #: ../en/ch05-collab.xml:311
dongsheng@627 6195 msgid ""
dongsheng@627 6196 "For larger projects, an effective way to manage change is to break up a team "
dongsheng@627 6197 "into smaller groups. Each group has a shared branch of its own, cloned from "
dongsheng@627 6198 "a single <quote>master</quote> branch used by the entire project. People "
dongsheng@627 6199 "working on an individual branch are typically quite isolated from "
dongsheng@627 6200 "developments on other branches."
dongsheng@627 6201 msgstr ""
dongsheng@627 6202
songdongsheng@658 6203 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
songdongsheng@710 6204 #: ../en/ch05-collab.xml:321
dongsheng@641 6205 msgid ""
songdongsheng@658 6206 "<imageobject><imagedata width=\"100%\" fileref=\"figs/feature-branches.png\"/"
songdongsheng@658 6207 "></imageobject>"
songdongsheng@658 6208 msgstr ""
songdongsheng@658 6209
songdongsheng@658 6210 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6211 #: ../en/ch05-collab.xml:326
dongsheng@627 6212 msgid ""
dongsheng@627 6213 "When a particular feature is deemed to be in suitable shape, someone on that "
dongsheng@627 6214 "feature team pulls and merges from the master branch into the feature branch, "
dongsheng@627 6215 "then pushes back up to the master branch."
dongsheng@627 6216 msgstr ""
dongsheng@627 6217
dongsheng@627 6218 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 6219 #: ../en/ch05-collab.xml:333
dongsheng@627 6220 msgid "The release train"
dongsheng@630 6221 msgstr "发布列车"
dongsheng@627 6222
dongsheng@627 6223 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6224 #: ../en/ch05-collab.xml:335
songdongsheng@710 6225 msgid ""
songdongsheng@710 6226 "Some projects are organized on a <quote>train</quote> basis: a release is "
dongsheng@627 6227 "scheduled to happen every few months, and whatever features are ready when "
dongsheng@627 6228 "the <quote>train</quote> is ready to leave are allowed in."
dongsheng@627 6229 msgstr ""
dongsheng@627 6230
dongsheng@627 6231 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6232 #: ../en/ch05-collab.xml:340
dongsheng@627 6233 msgid ""
dongsheng@627 6234 "This model resembles working with feature branches. The difference is that "
dongsheng@627 6235 "when a feature branch misses a train, someone on the feature team pulls and "
dongsheng@627 6236 "merges the changes that went out on that train release into the feature "
dongsheng@627 6237 "branch, and the team continues its work on top of that release so that their "
dongsheng@627 6238 "feature can make the next release."
dongsheng@627 6239 msgstr ""
dongsheng@627 6240
dongsheng@627 6241 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 6242 #: ../en/ch05-collab.xml:349
dongsheng@627 6243 msgid "The Linux kernel model"
dongsheng@630 6244 msgstr "Linux 内核模型"
dongsheng@627 6245
dongsheng@627 6246 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6247 #: ../en/ch05-collab.xml:351
dongsheng@627 6248 msgid ""
dongsheng@627 6249 "The development of the Linux kernel has a shallow hierarchical structure, "
dongsheng@627 6250 "surrounded by a cloud of apparent chaos. Because most Linux developers use "
dongsheng@627 6251 "<command>git</command>, a distributed revision control tool with capabilities "
dongsheng@627 6252 "similar to Mercurial, it's useful to describe the way work flows in that "
dongsheng@627 6253 "environment; if you like the ideas, the approach translates well across tools."
dongsheng@627 6254 msgstr ""
dongsheng@627 6255
dongsheng@627 6256 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6257 #: ../en/ch05-collab.xml:359
dongsheng@627 6258 msgid ""
dongsheng@627 6259 "At the center of the community sits Linus Torvalds, the creator of Linux. He "
dongsheng@627 6260 "publishes a single source repository that is considered the "
dongsheng@627 6261 "<quote>authoritative</quote> current tree by the entire developer community. "
dongsheng@627 6262 "Anyone can clone Linus's tree, but he is very choosy about whose trees he "
dongsheng@627 6263 "pulls from."
dongsheng@627 6264 msgstr ""
dongsheng@627 6265
dongsheng@627 6266 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6267 #: ../en/ch05-collab.xml:366
dongsheng@627 6268 msgid ""
dongsheng@627 6269 "Linus has a number of <quote>trusted lieutenants</quote>. As a general rule, "
dongsheng@627 6270 "he pulls whatever changes they publish, in most cases without even reviewing "
dongsheng@627 6271 "those changes. Some of those lieutenants are generally agreed to be "
dongsheng@627 6272 "<quote>maintainers</quote>, responsible for specific subsystems within the "
dongsheng@627 6273 "kernel. If a random kernel hacker wants to make a change to a subsystem that "
dongsheng@627 6274 "they want to end up in Linus's tree, they must find out who the subsystem's "
dongsheng@627 6275 "maintainer is, and ask that maintainer to take their change. If the "
dongsheng@627 6276 "maintainer reviews their changes and agrees to take them, they'll pass them "
dongsheng@627 6277 "along to Linus in due course."
dongsheng@627 6278 msgstr ""
dongsheng@627 6279
dongsheng@627 6280 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6281 #: ../en/ch05-collab.xml:378
dongsheng@627 6282 msgid ""
dongsheng@627 6283 "Individual lieutenants have their own approaches to reviewing, accepting, and "
dongsheng@627 6284 "publishing changes; and for deciding when to feed them to Linus. In "
dongsheng@627 6285 "addition, there are several well known branches that people use for different "
dongsheng@627 6286 "purposes. For example, a few people maintain <quote>stable</quote> "
dongsheng@627 6287 "repositories of older versions of the kernel, to which they apply critical "
dongsheng@627 6288 "fixes as needed. Some maintainers publish multiple trees: one for "
dongsheng@627 6289 "experimental changes; one for changes that they are about to feed upstream; "
dongsheng@627 6290 "and so on. Others just publish a single tree."
dongsheng@627 6291 msgstr ""
dongsheng@627 6292
dongsheng@627 6293 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6294 #: ../en/ch05-collab.xml:389
dongsheng@627 6295 msgid ""
dongsheng@627 6296 "This model has two notable features. The first is that it's <quote>pull "
dongsheng@627 6297 "only</quote>. You have to ask, convince, or beg another developer to take a "
dongsheng@627 6298 "change from you, because there are almost no trees to which more than one "
dongsheng@627 6299 "person can push, and there's no way to push changes into a tree that someone "
dongsheng@627 6300 "else controls."
dongsheng@627 6301 msgstr ""
dongsheng@627 6302
dongsheng@627 6303 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6304 #: ../en/ch05-collab.xml:396
dongsheng@627 6305 msgid ""
dongsheng@627 6306 "The second is that it's based on reputation and acclaim. If you're an "
dongsheng@627 6307 "unknown, Linus will probably ignore changes from you without even "
dongsheng@627 6308 "responding. But a subsystem maintainer will probably review them, and will "
dongsheng@627 6309 "likely take them if they pass their criteria for suitability. The more "
dongsheng@627 6310 "<quote>good</quote> changes you contribute to a maintainer, the more likely "
dongsheng@627 6311 "they are to trust your judgment and accept your changes. If you're well-"
dongsheng@627 6312 "known and maintain a long-lived branch for something Linus hasn't yet "
dongsheng@627 6313 "accepted, people with similar interests may pull your changes regularly to "
dongsheng@627 6314 "keep up with your work."
dongsheng@627 6315 msgstr ""
dongsheng@627 6316
dongsheng@627 6317 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6318 #: ../en/ch05-collab.xml:407
dongsheng@627 6319 msgid ""
dongsheng@627 6320 "Reputation and acclaim don't necessarily cross subsystem or <quote>people</"
dongsheng@627 6321 "quote> boundaries. If you're a respected but specialised storage hacker, and "
dongsheng@627 6322 "you try to fix a networking bug, that change will receive a level of scrutiny "
dongsheng@627 6323 "from a network maintainer comparable to a change from a complete stranger."
dongsheng@627 6324 msgstr ""
dongsheng@627 6325
dongsheng@627 6326 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6327 #: ../en/ch05-collab.xml:414
dongsheng@627 6328 msgid ""
dongsheng@627 6329 "To people who come from more orderly project backgrounds, the comparatively "
dongsheng@627 6330 "chaotic Linux kernel development process often seems completely insane. It's "
dongsheng@627 6331 "subject to the whims of individuals; people make sweeping changes whenever "
dongsheng@627 6332 "they deem it appropriate; and the pace of development is astounding. And yet "
dongsheng@627 6333 "Linux is a highly successful, well-regarded piece of software."
dongsheng@627 6334 msgstr ""
dongsheng@627 6335
dongsheng@627 6336 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 6337 #: ../en/ch05-collab.xml:424
dongsheng@627 6338 msgid "Pull-only versus shared-push collaboration"
dongsheng@630 6339 msgstr "只读与共享写协作"
dongsheng@627 6340
dongsheng@627 6341 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6342 #: ../en/ch05-collab.xml:426
dongsheng@627 6343 msgid ""
dongsheng@627 6344 "A perpetual source of heat in the open source community is whether a "
dongsheng@627 6345 "development model in which people only ever pull changes from others is "
dongsheng@627 6346 "<quote>better than</quote> one in which multiple people can push changes to a "
dongsheng@627 6347 "shared repository."
dongsheng@627 6348 msgstr ""
dongsheng@627 6349
dongsheng@627 6350 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6351 #: ../en/ch05-collab.xml:432
dongsheng@627 6352 msgid ""
dongsheng@627 6353 "Typically, the backers of the shared-push model use tools that actively "
dongsheng@627 6354 "enforce this approach. If you're using a centralised revision control tool "
dongsheng@627 6355 "such as Subversion, there's no way to make a choice over which model you'll "
dongsheng@627 6356 "use: the tool gives you shared-push, and if you want to do anything else, "
dongsheng@627 6357 "you'll have to roll your own approach on top (such as applying a patch by "
dongsheng@627 6358 "hand)."
dongsheng@627 6359 msgstr ""
dongsheng@627 6360
dongsheng@627 6361 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6362 #: ../en/ch05-collab.xml:440
songdongsheng@710 6363 msgid ""
songdongsheng@710 6364 "A good distributed revision control tool will support both models. You and "
songdongsheng@710 6365 "your collaborators can then structure how you work together based on your own "
songdongsheng@710 6366 "needs and preferences, not on what contortions your tools force you into."
songdongsheng@710 6367 msgstr ""
songdongsheng@710 6368
songdongsheng@710 6369 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 6370 #: ../en/ch05-collab.xml:447
dongsheng@627 6371 msgid "Where collaboration meets branch management"
dongsheng@630 6372 msgstr "协作与分支管理"
dongsheng@627 6373
dongsheng@627 6374 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6375 #: ../en/ch05-collab.xml:449
dongsheng@627 6376 msgid ""
dongsheng@627 6377 "Once you and your team set up some shared repositories and start propagating "
dongsheng@627 6378 "changes back and forth between local and shared repos, you begin to face a "
dongsheng@627 6379 "related, but slightly different challenge: that of managing the multiple "
dongsheng@627 6380 "directions in which your team may be moving at once. Even though this "
dongsheng@627 6381 "subject is intimately related to how your team collaborates, it's dense "
songdongsheng@658 6382 "enough to merit treatment of its own, in <xref linkend=\"chap:branch\"/>."
dongsheng@627 6383 msgstr ""
dongsheng@627 6384
dongsheng@627 6385 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@710 6386 #: ../en/ch05-collab.xml:461
dongsheng@627 6387 msgid "The technical side of sharing"
dongsheng@630 6388 msgstr "共享的技术因素"
dongsheng@627 6389
dongsheng@627 6390 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 6391 #: ../en/ch05-collab.xml:463
songdongsheng@710 6392 msgid ""
songdongsheng@710 6393 "The remainder of this chapter is devoted to the question of sharing changes "
songdongsheng@710 6394 "with your collaborators."
dongsheng@627 6395 msgstr ""
dongsheng@627 6396
dongsheng@627 6397 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@710 6398 #: ../en/ch05-collab.xml:468
dongsheng@627 6399 msgid "Informal sharing with <command role=\"hg-cmd\">hg serve</command>"
dongsheng@630 6400 msgstr "使用 <command role=\"hg-cmd\">hg serve</command> 进行非正式共享"
dongsheng@627 6401
dongsheng@627 6402 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 6403 #: ../en/ch05-collab.xml:471
dongsheng@627 6404 msgid ""
dongsheng@627 6405 "Mercurial's <command role=\"hg-cmd\">hg serve</command> command is "
dongsheng@627 6406 "wonderfully suited to small, tight-knit, and fast-paced group environments. "
dongsheng@627 6407 "It also provides a great way to get a feel for using Mercurial commands over "
dongsheng@627 6408 "a network."
dongsheng@627 6409 msgstr ""
dongsheng@627 6410
dongsheng@627 6411 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 6412 #: ../en/ch05-collab.xml:476
dongsheng@627 6413 msgid ""
dongsheng@627 6414 "Run <command role=\"hg-cmd\">hg serve</command> inside a repository, and in "
dongsheng@627 6415 "under a second it will bring up a specialised HTTP server; this will accept "
dongsheng@627 6416 "connections from any client, and serve up data for that repository until you "
dongsheng@627 6417 "terminate it. Anyone who knows the URL of the server you just started, and "
dongsheng@627 6418 "can talk to your computer over the network, can then use a web browser or "
dongsheng@627 6419 "Mercurial to read data from that repository. A URL for a <command role=\"hg-"
dongsheng@627 6420 "cmd\">hg serve</command> instance running on a laptop is likely to look "
dongsheng@627 6421 "something like <literal>http://my-laptop.local:8000/</literal>."
dongsheng@627 6422 msgstr ""
dongsheng@627 6423
dongsheng@627 6424 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 6425 #: ../en/ch05-collab.xml:487
dongsheng@627 6426 msgid ""
dongsheng@627 6427 "The <command role=\"hg-cmd\">hg serve</command> command is <emphasis>not</"
dongsheng@627 6428 "emphasis> a general-purpose web server. It can do only two things:"
dongsheng@627 6429 msgstr ""
dongsheng@627 6430
dongsheng@627 6431 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@710 6432 #: ../en/ch05-collab.xml:491
dongsheng@627 6433 msgid ""
dongsheng@627 6434 "Allow people to browse the history of the repository it's serving, from their "
dongsheng@627 6435 "normal web browsers."
dongsheng@627 6436 msgstr ""
dongsheng@627 6437
dongsheng@627 6438 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@710 6439 #: ../en/ch05-collab.xml:495
dongsheng@627 6440 msgid ""
dongsheng@627 6441 "Speak Mercurial's wire protocol, so that people can <command role=\"hg-cmd"
dongsheng@627 6442 "\">hg clone</command> or <command role=\"hg-cmd\">hg pull</command> changes "
dongsheng@627 6443 "from that repository."
dongsheng@627 6444 msgstr ""
dongsheng@627 6445
dongsheng@627 6446 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 6447 #: ../en/ch05-collab.xml:500
dongsheng@627 6448 msgid ""
dongsheng@627 6449 "In particular, <command role=\"hg-cmd\">hg serve</command> won't allow remote "
dongsheng@627 6450 "users to <emphasis>modify</emphasis> your repository. It's intended for read-"
dongsheng@627 6451 "only use."
dongsheng@627 6452 msgstr ""
dongsheng@627 6453
dongsheng@627 6454 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 6455 #: ../en/ch05-collab.xml:504
dongsheng@627 6456 msgid ""
dongsheng@627 6457 "If you're getting started with Mercurial, there's nothing to prevent you from "
dongsheng@627 6458 "using <command role=\"hg-cmd\">hg serve</command> to serve up a repository on "
dongsheng@627 6459 "your own computer, then use commands like <command role=\"hg-cmd\">hg clone</"
dongsheng@627 6460 "command>, <command role=\"hg-cmd\">hg incoming</command>, and so on to talk "
dongsheng@627 6461 "to that server as if the repository was hosted remotely. This can help you to "
dongsheng@627 6462 "quickly get acquainted with using commands on network-hosted repositories."
dongsheng@627 6463 msgstr ""
dongsheng@627 6464
dongsheng@627 6465 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 6466 #: ../en/ch05-collab.xml:514
dongsheng@627 6467 msgid "A few things to keep in mind"
dongsheng@630 6468 msgstr "要牢记的几件事"
dongsheng@627 6469
dongsheng@627 6470 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6471 #: ../en/ch05-collab.xml:516
dongsheng@627 6472 msgid ""
dongsheng@627 6473 "Because it provides unauthenticated read access to all clients, you should "
dongsheng@627 6474 "only use <command role=\"hg-cmd\">hg serve</command> in an environment where "
dongsheng@627 6475 "you either don't care, or have complete control over, who can access your "
dongsheng@627 6476 "network and pull data from your repository."
dongsheng@627 6477 msgstr ""
dongsheng@627 6478
dongsheng@627 6479 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6480 #: ../en/ch05-collab.xml:522
dongsheng@627 6481 msgid ""
dongsheng@627 6482 "The <command role=\"hg-cmd\">hg serve</command> command knows nothing about "
dongsheng@627 6483 "any firewall software you might have installed on your system or network. It "
dongsheng@627 6484 "cannot detect or control your firewall software. If other people are unable "
dongsheng@627 6485 "to talk to a running <command role=\"hg-cmd\">hg serve</command> instance, "
dongsheng@627 6486 "the second thing you should do (<emphasis>after</emphasis> you make sure that "
dongsheng@627 6487 "they're using the correct URL) is check your firewall configuration."
dongsheng@627 6488 msgstr ""
dongsheng@627 6489
dongsheng@627 6490 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6491 #: ../en/ch05-collab.xml:531
dongsheng@627 6492 msgid ""
dongsheng@627 6493 "By default, <command role=\"hg-cmd\">hg serve</command> listens for incoming "
dongsheng@627 6494 "connections on port 8000. If another process is already listening on the "
dongsheng@627 6495 "port you want to use, you can specify a different port to listen on using the "
dongsheng@627 6496 "<option role=\"hg-opt-serve\">-p</option> option."
dongsheng@627 6497 msgstr ""
dongsheng@627 6498
dongsheng@627 6499 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6500 #: ../en/ch05-collab.xml:537
dongsheng@627 6501 msgid ""
dongsheng@627 6502 "Normally, when <command role=\"hg-cmd\">hg serve</command> starts, it prints "
dongsheng@627 6503 "no output, which can be a bit unnerving. If you'd like to confirm that it is "
dongsheng@627 6504 "indeed running correctly, and find out what URL you should send to your "
dongsheng@627 6505 "collaborators, start it with the <option role=\"hg-opt-global\">-v</option> "
dongsheng@627 6506 "option."
dongsheng@627 6507 msgstr ""
dongsheng@627 6508
dongsheng@627 6509 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@710 6510 #: ../en/ch05-collab.xml:547
dongsheng@627 6511 msgid "Using the Secure Shell (ssh) protocol"
dongsheng@630 6512 msgstr "使用 ssh 协议"
dongsheng@627 6513
dongsheng@627 6514 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 6515 #: ../en/ch05-collab.xml:549
dongsheng@627 6516 msgid ""
dongsheng@627 6517 "You can pull and push changes securely over a network connection using the "
dongsheng@627 6518 "Secure Shell (<literal>ssh</literal>) protocol. To use this successfully, "
dongsheng@627 6519 "you may have to do a little bit of configuration on the client or server "
dongsheng@627 6520 "sides."
dongsheng@627 6521 msgstr ""
dongsheng@627 6522
dongsheng@627 6523 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 6524 #: ../en/ch05-collab.xml:554
songdongsheng@710 6525 msgid ""
songdongsheng@710 6526 "If you're not familiar with ssh, it's the name of both a command and a "
songdongsheng@710 6527 "network protocol that let you securely communicate with another computer. To "
songdongsheng@710 6528 "use it with Mercurial, you'll be setting up one or more user accounts on a "
songdongsheng@710 6529 "server so that remote users can log in and execute commands."
songdongsheng@710 6530 msgstr ""
songdongsheng@710 6531
songdongsheng@710 6532 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 6533 #: ../en/ch05-collab.xml:560
dongsheng@627 6534 msgid ""
dongsheng@627 6535 "(If you <emphasis>are</emphasis> familiar with ssh, you'll probably find some "
dongsheng@627 6536 "of the material that follows to be elementary in nature.)"
dongsheng@627 6537 msgstr ""
dongsheng@627 6538
dongsheng@627 6539 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 6540 #: ../en/ch05-collab.xml:565
dongsheng@627 6541 msgid "How to read and write ssh URLs"
dongsheng@630 6542 msgstr "如何读写 ssh 路径"
dongsheng@627 6543
dongsheng@627 6544 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6545 #: ../en/ch05-collab.xml:567
songdongsheng@658 6546 msgid "An ssh URL tends to look like this:"
songdongsheng@658 6547 msgstr ""
songdongsheng@658 6548
songdongsheng@658 6549 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
songdongsheng@710 6550 #: ../en/ch05-collab.xml:570
songdongsheng@658 6551 msgid ""
songdongsheng@658 6552 "The <quote><literal>ssh://</literal></quote> part tells Mercurial to use the "
songdongsheng@658 6553 "ssh protocol."
dongsheng@627 6554 msgstr ""
dongsheng@627 6555
dongsheng@627 6556 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
songdongsheng@710 6557 #: ../en/ch05-collab.xml:573
dongsheng@627 6558 msgid ""
dongsheng@627 6559 "The <quote><literal>bos@</literal></quote> component indicates what username "
dongsheng@627 6560 "to log into the server as. You can leave this out if the remote username is "
dongsheng@627 6561 "the same as your local username."
dongsheng@627 6562 msgstr ""
dongsheng@627 6563
dongsheng@627 6564 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
songdongsheng@710 6565 #: ../en/ch05-collab.xml:578
dongsheng@627 6566 msgid ""
dongsheng@627 6567 "The <quote><literal>hg.serpentine.com</literal></quote> gives the hostname of "
dongsheng@627 6568 "the server to log into."
dongsheng@627 6569 msgstr ""
dongsheng@627 6570
dongsheng@627 6571 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
songdongsheng@710 6572 #: ../en/ch05-collab.xml:582
dongsheng@627 6573 msgid ""
dongsheng@627 6574 "The <quote>:22</quote> identifies the port number to connect to the server "
dongsheng@650 6575 "on. The default port is 22, so you only need to specify a colon and port "
dongsheng@650 6576 "number if you're <emphasis>not</emphasis> using port 22."
dongsheng@627 6577 msgstr ""
dongsheng@627 6578
dongsheng@627 6579 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
songdongsheng@710 6580 #: ../en/ch05-collab.xml:587
dongsheng@627 6581 msgid ""
dongsheng@627 6582 "The remainder of the URL is the local path to the repository on the server."
dongsheng@627 6583 msgstr ""
dongsheng@627 6584
dongsheng@627 6585 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6586 #: ../en/ch05-collab.xml:591
dongsheng@627 6587 msgid ""
dongsheng@627 6588 "There's plenty of scope for confusion with the path component of ssh URLs, as "
dongsheng@627 6589 "there is no standard way for tools to interpret it. Some programs behave "
dongsheng@627 6590 "differently than others when dealing with these paths. This isn't an ideal "
dongsheng@627 6591 "situation, but it's unlikely to change. Please read the following paragraphs "
dongsheng@627 6592 "carefully."
dongsheng@627 6593 msgstr ""
dongsheng@627 6594
dongsheng@627 6595 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6596 #: ../en/ch05-collab.xml:598
dongsheng@627 6597 msgid ""
dongsheng@627 6598 "Mercurial treats the path to a repository on the server as relative to the "
dongsheng@627 6599 "remote user's home directory. For example, if user <literal>foo</literal> on "
dongsheng@627 6600 "the server has a home directory of <filename class=\"directory\">/home/foo</"
dongsheng@627 6601 "filename>, then an ssh URL that contains a path component of <filename class="
dongsheng@627 6602 "\"directory\">bar</filename> <emphasis>really</emphasis> refers to the "
dongsheng@627 6603 "directory <filename class=\"directory\">/home/foo/bar</filename>."
dongsheng@627 6604 msgstr ""
dongsheng@627 6605
dongsheng@627 6606 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6607 #: ../en/ch05-collab.xml:607
dongsheng@627 6608 msgid ""
dongsheng@627 6609 "If you want to specify a path relative to another user's home directory, you "
dongsheng@627 6610 "can use a path that starts with a tilde character followed by the user's name "
dongsheng@627 6611 "(let's call them <literal>otheruser</literal>), like this."
dongsheng@627 6612 msgstr ""
dongsheng@627 6613
dongsheng@627 6614 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6615 #: ../en/ch05-collab.xml:613
dongsheng@627 6616 msgid ""
dongsheng@627 6617 "And if you really want to specify an <emphasis>absolute</emphasis> path on "
dongsheng@627 6618 "the server, begin the path component with two slashes, as in this example."
dongsheng@627 6619 msgstr ""
dongsheng@627 6620
dongsheng@627 6621 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 6622 #: ../en/ch05-collab.xml:620
dongsheng@627 6623 msgid "Finding an ssh client for your system"
dongsheng@630 6624 msgstr "为你的系统寻找 ssh 客户端"
dongsheng@627 6625
dongsheng@627 6626 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6627 #: ../en/ch05-collab.xml:622
dongsheng@627 6628 msgid ""
dongsheng@627 6629 "Almost every Unix-like system comes with OpenSSH preinstalled. If you're "
dongsheng@627 6630 "using such a system, run <literal>which ssh</literal> to find out if the "
dongsheng@627 6631 "<command>ssh</command> command is installed (it's usually in <filename class="
dongsheng@627 6632 "\"directory\">/usr/bin</filename>). In the unlikely event that it isn't "
dongsheng@627 6633 "present, take a look at your system documentation to figure out how to "
dongsheng@627 6634 "install it."
dongsheng@627 6635 msgstr ""
dongsheng@627 6636
dongsheng@627 6637 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6638 #: ../en/ch05-collab.xml:630
songdongsheng@710 6639 msgid ""
songdongsheng@710 6640 "On Windows, the TortoiseHg package is bundled with a version of Simon "
songdongsheng@710 6641 "Tatham's excellent <command>plink</command> command, and you should not need "
songdongsheng@710 6642 "to do any further configuration."
songdongsheng@710 6643 msgstr ""
songdongsheng@710 6644
songdongsheng@710 6645 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 6646 #: ../en/ch05-collab.xml:637
dongsheng@627 6647 msgid "Generating a key pair"
dongsheng@630 6648 msgstr "产生密钥对"
dongsheng@627 6649
dongsheng@627 6650 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6651 #: ../en/ch05-collab.xml:639
dongsheng@627 6652 msgid ""
dongsheng@627 6653 "To avoid the need to repetitively type a password every time you need to use "
songdongsheng@710 6654 "your ssh client, I recommend generating a key pair."
songdongsheng@710 6655 msgstr ""
songdongsheng@710 6656
songdongsheng@710 6657 #. type: Content of: <book><chapter><sect1><sect2><tip><title>
songdongsheng@710 6658 #: ../en/ch05-collab.xml:644
songdongsheng@710 6659 msgid "Key pairs are not mandatory"
songdongsheng@710 6660 msgstr ""
songdongsheng@710 6661
songdongsheng@710 6662 #. type: Content of: <book><chapter><sect1><sect2><tip><para>
songdongsheng@710 6663 #: ../en/ch05-collab.xml:646
songdongsheng@710 6664 msgid ""
songdongsheng@710 6665 "Mercurial knows nothing about ssh authentication or key pairs. You can, if "
songdongsheng@710 6666 "you like, safely ignore this section and the one that follows until you grow "
songdongsheng@710 6667 "tired of repeatedly typing ssh passwords."
songdongsheng@710 6668 msgstr ""
songdongsheng@710 6669
songdongsheng@710 6670 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@710 6671 #: ../en/ch05-collab.xml:654
songdongsheng@710 6672 msgid ""
songdongsheng@710 6673 "On a Unix-like system, the <command>ssh-keygen</command> command will do the "
songdongsheng@710 6674 "trick."
songdongsheng@710 6675 msgstr ""
songdongsheng@710 6676
songdongsheng@710 6677 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@710 6678 #: ../en/ch05-collab.xml:657
songdongsheng@710 6679 msgid ""
songdongsheng@710 6680 "On Windows, if you're using TortoiseHg, you may need to download a command "
songdongsheng@710 6681 "named <command>puttygen</command> from <ulink url=\"http://www.chiark."
songdongsheng@710 6682 "greenend.org.uk/~sgtatham/putty\">the PuTTY web site</ulink> to generate a "
songdongsheng@710 6683 "key pair. See <ulink url=\"http://the.earth.li/~sgtatham/putty/0.60/htmldoc/"
songdongsheng@710 6684 "Chapter8.html#pubkey-puttygen\">the <command>puttygen</command> "
songdongsheng@710 6685 "documentation</ulink> for details of how use the command."
songdongsheng@710 6686 msgstr ""
songdongsheng@710 6687
songdongsheng@710 6688 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6689 #: ../en/ch05-collab.xml:669
dongsheng@627 6690 msgid ""
dongsheng@627 6691 "When you generate a key pair, it's usually <emphasis>highly</emphasis> "
dongsheng@627 6692 "advisable to protect it with a passphrase. (The only time that you might not "
dongsheng@627 6693 "want to do this is when you're using the ssh protocol for automated tasks on "
dongsheng@627 6694 "a secure network.)"
dongsheng@627 6695 msgstr ""
dongsheng@627 6696
dongsheng@627 6697 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6698 #: ../en/ch05-collab.xml:675
dongsheng@627 6699 msgid ""
dongsheng@627 6700 "Simply generating a key pair isn't enough, however. You'll need to add the "
dongsheng@627 6701 "public key to the set of authorised keys for whatever user you're logging in "
dongsheng@627 6702 "remotely as. For servers using OpenSSH (the vast majority), this will mean "
dongsheng@627 6703 "adding the public key to a list in a file called <filename role=\"special"
dongsheng@627 6704 "\">authorized_keys</filename> in their <filename role=\"special\" class="
dongsheng@627 6705 "\"directory\">.ssh</filename> directory."
dongsheng@627 6706 msgstr ""
dongsheng@627 6707
dongsheng@627 6708 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6709 #: ../en/ch05-collab.xml:684
dongsheng@627 6710 msgid ""
dongsheng@627 6711 "On a Unix-like system, your public key will have a <filename>.pub</filename> "
dongsheng@627 6712 "extension. If you're using <command>puttygen</command> on Windows, you can "
dongsheng@627 6713 "save the public key to a file of your choosing, or paste it from the window "
dongsheng@627 6714 "it's displayed in straight into the <filename role=\"special"
dongsheng@627 6715 "\">authorized_keys</filename> file."
dongsheng@627 6716 msgstr ""
dongsheng@627 6717
dongsheng@627 6718 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 6719 #: ../en/ch05-collab.xml:692
dongsheng@627 6720 msgid "Using an authentication agent"
dongsheng@630 6721 msgstr "使用认证代理"
dongsheng@627 6722
dongsheng@627 6723 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6724 #: ../en/ch05-collab.xml:694
dongsheng@627 6725 msgid ""
dongsheng@627 6726 "An authentication agent is a daemon that stores passphrases in memory (so it "
dongsheng@627 6727 "will forget passphrases if you log out and log back in again). An ssh client "
dongsheng@627 6728 "will notice if it's running, and query it for a passphrase. If there's no "
dongsheng@627 6729 "authentication agent running, or the agent doesn't store the necessary "
dongsheng@627 6730 "passphrase, you'll have to type your passphrase every time Mercurial tries to "
dongsheng@627 6731 "communicate with a server on your behalf (e.g. whenever you pull or push "
dongsheng@627 6732 "changes)."
dongsheng@627 6733 msgstr ""
dongsheng@627 6734
dongsheng@627 6735 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6736 #: ../en/ch05-collab.xml:703
dongsheng@627 6737 msgid ""
dongsheng@627 6738 "The downside of storing passphrases in an agent is that it's possible for a "
dongsheng@627 6739 "well-prepared attacker to recover the plain text of your passphrases, in some "
dongsheng@627 6740 "cases even if your system has been power-cycled. You should make your own "
dongsheng@627 6741 "judgment as to whether this is an acceptable risk. It certainly saves a lot "
dongsheng@627 6742 "of repeated typing."
dongsheng@627 6743 msgstr ""
dongsheng@627 6744
songdongsheng@710 6745 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@710 6746 #: ../en/ch05-collab.xml:712
dongsheng@627 6747 msgid ""
dongsheng@627 6748 "On Unix-like systems, the agent is called <command>ssh-agent</command>, and "
dongsheng@627 6749 "it's often run automatically for you when you log in. You'll need to use the "
songdongsheng@710 6750 "<command>ssh-add</command> command to add passphrases to the agent's store."
songdongsheng@710 6751 msgstr ""
songdongsheng@710 6752
songdongsheng@710 6753 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@710 6754 #: ../en/ch05-collab.xml:719
songdongsheng@710 6755 msgid ""
songdongsheng@710 6756 "On Windows, if you're using TortoiseHg, the <command>pageant</command> "
songdongsheng@710 6757 "command acts as the agent. As with <command>puttygen</command>, you'll need "
songdongsheng@710 6758 "to <ulink url=\"http://www.chiark.greenend.org.uk/%7Esgtatham/putty/download."
songdongsheng@710 6759 "html\">download <command>pageant</command></ulink> from the PuTTY web site "
songdongsheng@710 6760 "and read <ulink url=\"http://the.earth.li/~sgtatham/putty/0.60/htmldoc/"
songdongsheng@710 6761 "Chapter9.html#pageant\">its documentation</ulink>. The <command>pageant</"
songdongsheng@710 6762 "command> command adds an icon to your system tray that will let you manage "
songdongsheng@710 6763 "stored passphrases."
songdongsheng@710 6764 msgstr ""
songdongsheng@710 6765
songdongsheng@710 6766 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 6767 #: ../en/ch05-collab.xml:734
dongsheng@627 6768 msgid "Configuring the server side properly"
dongsheng@630 6769 msgstr "正确配置服务器端"
dongsheng@627 6770
dongsheng@627 6771 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6772 #: ../en/ch05-collab.xml:736
songdongsheng@710 6773 msgid ""
songdongsheng@710 6774 "Because ssh can be fiddly to set up if you're new to it, a variety of things "
songdongsheng@710 6775 "can go wrong. Add Mercurial on top, and there's plenty more scope for head-"
songdongsheng@710 6776 "scratching. Most of these potential problems occur on the server side, not "
songdongsheng@710 6777 "the client side. The good news is that once you've gotten a configuration "
songdongsheng@710 6778 "working, it will usually continue to work indefinitely."
songdongsheng@710 6779 msgstr ""
songdongsheng@710 6780
songdongsheng@710 6781 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6782 #: ../en/ch05-collab.xml:744
dongsheng@627 6783 msgid ""
dongsheng@627 6784 "Before you try using Mercurial to talk to an ssh server, it's best to make "
dongsheng@627 6785 "sure that you can use the normal <command>ssh</command> or <command>putty</"
dongsheng@627 6786 "command> command to talk to the server first. If you run into problems with "
dongsheng@627 6787 "using these commands directly, Mercurial surely won't work. Worse, it will "
dongsheng@627 6788 "obscure the underlying problem. Any time you want to debug ssh-related "
dongsheng@627 6789 "Mercurial problems, you should drop back to making sure that plain ssh client "
dongsheng@627 6790 "commands work first, <emphasis>before</emphasis> you worry about whether "
dongsheng@627 6791 "there's a problem with Mercurial."
dongsheng@627 6792 msgstr ""
dongsheng@627 6793
dongsheng@627 6794 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6795 #: ../en/ch05-collab.xml:755
dongsheng@627 6796 msgid ""
dongsheng@627 6797 "The first thing to be sure of on the server side is that you can actually log "
dongsheng@627 6798 "in from another machine at all. If you can't use <command>ssh</command> or "
dongsheng@627 6799 "<command>putty</command> to log in, the error message you get may give you a "
dongsheng@627 6800 "few hints as to what's wrong. The most common problems are as follows."
dongsheng@627 6801 msgstr ""
dongsheng@627 6802
dongsheng@627 6803 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@710 6804 #: ../en/ch05-collab.xml:762
dongsheng@627 6805 msgid ""
dongsheng@627 6806 "If you get a <quote>connection refused</quote> error, either there isn't an "
dongsheng@627 6807 "SSH daemon running on the server at all, or it's inaccessible due to firewall "
dongsheng@627 6808 "configuration."
dongsheng@627 6809 msgstr ""
dongsheng@627 6810
dongsheng@627 6811 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@710 6812 #: ../en/ch05-collab.xml:767
dongsheng@627 6813 msgid ""
dongsheng@627 6814 "If you get a <quote>no route to host</quote> error, you either have an "
dongsheng@627 6815 "incorrect address for the server or a seriously locked down firewall that "
dongsheng@627 6816 "won't admit its existence at all."
dongsheng@627 6817 msgstr ""
dongsheng@627 6818
dongsheng@627 6819 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@710 6820 #: ../en/ch05-collab.xml:772
dongsheng@627 6821 msgid ""
dongsheng@627 6822 "If you get a <quote>permission denied</quote> error, you may have mistyped "
dongsheng@627 6823 "the username on the server, or you could have mistyped your key's passphrase "
dongsheng@627 6824 "or the remote user's password."
dongsheng@627 6825 msgstr ""
dongsheng@627 6826
dongsheng@627 6827 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6828 #: ../en/ch05-collab.xml:777
dongsheng@627 6829 msgid ""
dongsheng@627 6830 "In summary, if you're having trouble talking to the server's ssh daemon, "
dongsheng@627 6831 "first make sure that one is running at all. On many systems it will be "
dongsheng@627 6832 "installed, but disabled, by default. Once you're done with this step, you "
dongsheng@627 6833 "should then check that the server's firewall is configured to allow incoming "
dongsheng@627 6834 "connections on the port the ssh daemon is listening on (usually 22). Don't "
dongsheng@627 6835 "worry about more exotic possibilities for misconfiguration until you've "
dongsheng@627 6836 "checked these two first."
dongsheng@627 6837 msgstr ""
dongsheng@627 6838
dongsheng@627 6839 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6840 #: ../en/ch05-collab.xml:787
dongsheng@627 6841 msgid ""
dongsheng@627 6842 "If you're using an authentication agent on the client side to store "
dongsheng@627 6843 "passphrases for your keys, you ought to be able to log into the server "
dongsheng@627 6844 "without being prompted for a passphrase or a password. If you're prompted "
dongsheng@627 6845 "for a passphrase, there are a few possible culprits."
dongsheng@627 6846 msgstr ""
dongsheng@627 6847
dongsheng@627 6848 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@710 6849 #: ../en/ch05-collab.xml:793
dongsheng@627 6850 msgid ""
dongsheng@627 6851 "You might have forgotten to use <command>ssh-add</command> or "
dongsheng@627 6852 "<command>pageant</command> to store the passphrase."
dongsheng@627 6853 msgstr ""
dongsheng@627 6854
dongsheng@627 6855 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@710 6856 #: ../en/ch05-collab.xml:797
songdongsheng@658 6857 msgid "You might have stored the passphrase for the wrong key."
songdongsheng@658 6858 msgstr ""
songdongsheng@658 6859
songdongsheng@658 6860 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6861 #: ../en/ch05-collab.xml:800
dongsheng@627 6862 msgid ""
dongsheng@627 6863 "If you're being prompted for the remote user's password, there are another "
dongsheng@627 6864 "few possible problems to check."
dongsheng@627 6865 msgstr ""
dongsheng@627 6866
dongsheng@627 6867 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@710 6868 #: ../en/ch05-collab.xml:803
dongsheng@627 6869 msgid ""
dongsheng@627 6870 "Either the user's home directory or their <filename role=\"special\" class="
dongsheng@627 6871 "\"directory\">.ssh</filename> directory might have excessively liberal "
dongsheng@627 6872 "permissions. As a result, the ssh daemon will not trust or read their "
dongsheng@627 6873 "<filename role=\"special\">authorized_keys</filename> file. For example, a "
dongsheng@627 6874 "group-writable home or <filename role=\"special\" class=\"directory\">.ssh</"
dongsheng@627 6875 "filename> directory will often cause this symptom."
dongsheng@627 6876 msgstr ""
dongsheng@627 6877
dongsheng@627 6878 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@710 6879 #: ../en/ch05-collab.xml:812
dongsheng@627 6880 msgid ""
dongsheng@627 6881 "The user's <filename role=\"special\">authorized_keys</filename> file may "
dongsheng@627 6882 "have a problem. If anyone other than the user owns or can write to that file, "
dongsheng@627 6883 "the ssh daemon will not trust or read it."
dongsheng@627 6884 msgstr ""
dongsheng@627 6885
dongsheng@627 6886 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6887 #: ../en/ch05-collab.xml:819
dongsheng@627 6888 msgid ""
dongsheng@627 6889 "In the ideal world, you should be able to run the following command "
dongsheng@627 6890 "successfully, and it should print exactly one line of output, the current "
dongsheng@627 6891 "date and time."
dongsheng@627 6892 msgstr ""
dongsheng@627 6893
dongsheng@627 6894 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6895 #: ../en/ch05-collab.xml:824
dongsheng@627 6896 msgid ""
dongsheng@627 6897 "If, on your server, you have login scripts that print banners or other junk "
dongsheng@627 6898 "even when running non-interactive commands like this, you should fix them "
dongsheng@627 6899 "before you continue, so that they only print output if they're run "
dongsheng@627 6900 "interactively. Otherwise these banners will at least clutter up Mercurial's "
dongsheng@627 6901 "output. Worse, they could potentially cause problems with running Mercurial "
dongsheng@627 6902 "commands remotely. Mercurial makes tries to detect and ignore banners in non-"
dongsheng@627 6903 "interactive <command>ssh</command> sessions, but it is not foolproof. (If "
dongsheng@627 6904 "you're editing your login scripts on your server, the usual way to see if a "
dongsheng@627 6905 "login script is running in an interactive shell is to check the return code "
dongsheng@627 6906 "from the command <literal>tty -s</literal>.)"
dongsheng@627 6907 msgstr ""
dongsheng@627 6908
dongsheng@627 6909 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6910 #: ../en/ch05-collab.xml:838
dongsheng@627 6911 msgid ""
dongsheng@627 6912 "Once you've verified that plain old ssh is working with your server, the next "
dongsheng@627 6913 "step is to ensure that Mercurial runs on the server. The following command "
dongsheng@627 6914 "should run successfully:"
dongsheng@627 6915 msgstr ""
dongsheng@627 6916
dongsheng@627 6917 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6918 #: ../en/ch05-collab.xml:845
dongsheng@627 6919 msgid ""
dongsheng@627 6920 "If you see an error message instead of normal <command role=\"hg-cmd\">hg "
dongsheng@627 6921 "version</command> output, this is usually because you haven't installed "
dongsheng@627 6922 "Mercurial to <filename class=\"directory\">/usr/bin</filename>. Don't worry "
dongsheng@627 6923 "if this is the case; you don't need to do that. But you should check for a "
dongsheng@627 6924 "few possible problems."
dongsheng@627 6925 msgstr ""
dongsheng@627 6926
dongsheng@627 6927 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@710 6928 #: ../en/ch05-collab.xml:852
dongsheng@627 6929 msgid ""
dongsheng@627 6930 "Is Mercurial really installed on the server at all? I know this sounds "
dongsheng@627 6931 "trivial, but it's worth checking!"
dongsheng@627 6932 msgstr ""
dongsheng@627 6933
dongsheng@627 6934 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@710 6935 #: ../en/ch05-collab.xml:856
dongsheng@627 6936 msgid ""
dongsheng@627 6937 "Maybe your shell's search path (usually set via the <envar>PATH</envar> "
dongsheng@627 6938 "environment variable) is simply misconfigured."
dongsheng@627 6939 msgstr ""
dongsheng@627 6940
dongsheng@627 6941 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@710 6942 #: ../en/ch05-collab.xml:860
dongsheng@627 6943 msgid ""
dongsheng@627 6944 "Perhaps your <envar>PATH</envar> environment variable is only being set to "
dongsheng@627 6945 "point to the location of the <command>hg</command> executable if the login "
dongsheng@627 6946 "session is interactive. This can happen if you're setting the path in the "
dongsheng@627 6947 "wrong shell login script. See your shell's documentation for details."
dongsheng@627 6948 msgstr ""
dongsheng@627 6949
dongsheng@627 6950 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@710 6951 #: ../en/ch05-collab.xml:867
dongsheng@627 6952 msgid ""
dongsheng@627 6953 "The <envar>PYTHONPATH</envar> environment variable may need to contain the "
dongsheng@627 6954 "path to the Mercurial Python modules. It might not be set at all; it could "
dongsheng@627 6955 "be incorrect; or it may be set only if the login is interactive."
dongsheng@627 6956 msgstr ""
dongsheng@627 6957
dongsheng@627 6958 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6959 #: ../en/ch05-collab.xml:874
dongsheng@627 6960 msgid ""
dongsheng@627 6961 "If you can run <command role=\"hg-cmd\">hg version</command> over an ssh "
dongsheng@627 6962 "connection, well done! You've got the server and client sorted out. You "
dongsheng@627 6963 "should now be able to use Mercurial to access repositories hosted by that "
dongsheng@627 6964 "username on that server. If you run into problems with Mercurial and ssh at "
dongsheng@627 6965 "this point, try using the <option role=\"hg-opt-global\">--debug</option> "
dongsheng@627 6966 "option to get a clearer picture of what's going on."
dongsheng@627 6967 msgstr ""
dongsheng@627 6968
dongsheng@627 6969 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 6970 #: ../en/ch05-collab.xml:883
dongsheng@627 6971 msgid "Using compression with ssh"
dongsheng@630 6972 msgstr "通过 ssh 使用压缩"
dongsheng@627 6973
dongsheng@627 6974 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6975 #: ../en/ch05-collab.xml:885
dongsheng@627 6976 msgid ""
dongsheng@627 6977 "Mercurial does not compress data when it uses the ssh protocol, because the "
songdongsheng@710 6978 "ssh protocol can transparently compress data. However, the default behavior "
dongsheng@627 6979 "of ssh clients is <emphasis>not</emphasis> to request compression."
dongsheng@627 6980 msgstr ""
dongsheng@627 6981
dongsheng@627 6982 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6983 #: ../en/ch05-collab.xml:890
dongsheng@627 6984 msgid ""
dongsheng@627 6985 "Over any network other than a fast LAN (even a wireless network), using "
dongsheng@627 6986 "compression is likely to significantly speed up Mercurial's network "
dongsheng@627 6987 "operations. For example, over a WAN, someone measured compression as "
dongsheng@627 6988 "reducing the amount of time required to clone a particularly large repository "
dongsheng@627 6989 "from 51 minutes to 17 minutes."
dongsheng@627 6990 msgstr ""
dongsheng@627 6991
dongsheng@627 6992 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 6993 #: ../en/ch05-collab.xml:897
dongsheng@627 6994 msgid ""
dongsheng@627 6995 "Both <command>ssh</command> and <command>plink</command> accept a <option "
dongsheng@627 6996 "role=\"cmd-opt-ssh\">-C</option> option which turns on compression. You can "
dongsheng@650 6997 "easily edit your <filename role=\"special\">~/.hgrc</filename> to enable "
songdongsheng@710 6998 "compression for all of Mercurial's uses of the ssh protocol. Here is how to "
songdongsheng@710 6999 "do so for regular <command>ssh</command> on Unix-like systems, for example."
songdongsheng@710 7000 msgstr ""
songdongsheng@710 7001
songdongsheng@710 7002 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 7003 #: ../en/ch05-collab.xml:907
songdongsheng@710 7004 msgid ""
songdongsheng@710 7005 "If you use <command>ssh</command> on a Unix-like system, you can configure it "
songdongsheng@710 7006 "to always use compression when talking to your server. To do this, edit your "
songdongsheng@710 7007 "<filename role=\"special\">.ssh/config</filename> file (which may not yet "
songdongsheng@710 7008 "exist), as follows."
songdongsheng@710 7009 msgstr ""
songdongsheng@710 7010
songdongsheng@710 7011 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 7012 #: ../en/ch05-collab.xml:917
songdongsheng@710 7013 msgid ""
songdongsheng@710 7014 "This defines a hostname alias, <literal>hg</literal>. When you use that "
songdongsheng@710 7015 "hostname on the <command>ssh</command> command line or in a Mercurial "
songdongsheng@710 7016 "<literal>ssh</literal>-protocol URL, it will cause <command>ssh</command> to "
songdongsheng@710 7017 "connect to <literal>hg.example.com</literal> and use compression. This gives "
songdongsheng@710 7018 "you both a shorter name to type and compression, each of which is a good "
songdongsheng@710 7019 "thing in its own right."
dongsheng@627 7020 msgstr ""
dongsheng@627 7021
dongsheng@627 7022 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@710 7023 #: ../en/ch05-collab.xml:929
dongsheng@627 7024 msgid "Serving over HTTP using CGI"
dongsheng@630 7025 msgstr "使用 CGI 通过 HTTP 提供服务"
dongsheng@627 7026
dongsheng@627 7027 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 7028 #: ../en/ch05-collab.xml:931
songdongsheng@710 7029 msgid ""
songdongsheng@710 7030 "The simplest way to host one or more repositories in a permanent way is to "
songdongsheng@710 7031 "use a web server and Mercurial's CGI support."
songdongsheng@710 7032 msgstr ""
songdongsheng@710 7033
songdongsheng@710 7034 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 7035 #: ../en/ch05-collab.xml:935
dongsheng@627 7036 msgid ""
dongsheng@627 7037 "Depending on how ambitious you are, configuring Mercurial's CGI interface can "
dongsheng@627 7038 "take anything from a few moments to several hours."
dongsheng@627 7039 msgstr ""
dongsheng@627 7040
dongsheng@627 7041 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 7042 #: ../en/ch05-collab.xml:939
dongsheng@627 7043 msgid ""
dongsheng@627 7044 "We'll begin with the simplest of examples, and work our way towards a more "
dongsheng@627 7045 "complex configuration. Even for the most basic case, you're almost certainly "
dongsheng@627 7046 "going to need to read and modify your web server's configuration."
dongsheng@627 7047 msgstr ""
dongsheng@627 7048
songdongsheng@710 7049 #. type: Content of: <book><chapter><sect1><note><title>
songdongsheng@710 7050 #: ../en/ch05-collab.xml:945
songdongsheng@710 7051 msgid "High pain tolerance required"
songdongsheng@710 7052 msgstr ""
songdongsheng@710 7053
dongsheng@627 7054 #. type: Content of: <book><chapter><sect1><note><para>
songdongsheng@710 7055 #: ../en/ch05-collab.xml:947
dongsheng@627 7056 msgid ""
dongsheng@627 7057 "Configuring a web server is a complex, fiddly, and highly system-dependent "
dongsheng@627 7058 "activity. I can't possibly give you instructions that will cover anything "
dongsheng@627 7059 "like all of the cases you will encounter. Please use your discretion and "
dongsheng@627 7060 "judgment in following the sections below. Be prepared to make plenty of "
dongsheng@627 7061 "mistakes, and to spend a lot of time reading your server's error logs."
dongsheng@627 7062 msgstr ""
dongsheng@627 7063
songdongsheng@710 7064 #. type: Content of: <book><chapter><sect1><note><para>
songdongsheng@710 7065 #: ../en/ch05-collab.xml:955
songdongsheng@710 7066 msgid ""
songdongsheng@710 7067 "If you don't have a strong stomach for tweaking configurations over and over, "
songdongsheng@710 7068 "or a compelling need to host your own services, you might want to try one of "
songdongsheng@710 7069 "the public hosting services that I mentioned earlier."
songdongsheng@710 7070 msgstr ""
songdongsheng@710 7071
songdongsheng@710 7072 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 7073 #: ../en/ch05-collab.xml:962
dongsheng@627 7074 msgid "Web server configuration checklist"
dongsheng@630 7075 msgstr "Web 服务器配置检查表"
dongsheng@627 7076
dongsheng@627 7077 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 7078 #: ../en/ch05-collab.xml:964
dongsheng@627 7079 msgid ""
dongsheng@627 7080 "Before you continue, do take a few moments to check a few aspects of your "
dongsheng@627 7081 "system's setup."
dongsheng@627 7082 msgstr ""
dongsheng@627 7083
dongsheng@627 7084 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
songdongsheng@710 7085 #: ../en/ch05-collab.xml:968
songdongsheng@710 7086 msgid ""
songdongsheng@710 7087 "Do you have a web server installed at all? Mac OS X and some Linux "
songdongsheng@710 7088 "distributions ship with Apache, but many other systems may not have a web "
songdongsheng@710 7089 "server installed."
dongsheng@627 7090 msgstr ""
dongsheng@627 7091
dongsheng@627 7092 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
songdongsheng@710 7093 #: ../en/ch05-collab.xml:973
dongsheng@627 7094 msgid ""
dongsheng@627 7095 "If you have a web server installed, is it actually running? On most systems, "
dongsheng@627 7096 "even if one is present, it will be disabled by default."
dongsheng@627 7097 msgstr ""
dongsheng@627 7098
dongsheng@627 7099 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
songdongsheng@710 7100 #: ../en/ch05-collab.xml:977
dongsheng@627 7101 msgid ""
dongsheng@627 7102 "Is your server configured to allow you to run CGI programs in the directory "
dongsheng@627 7103 "where you plan to do so? Most servers default to explicitly disabling the "
dongsheng@627 7104 "ability to run CGI programs."
dongsheng@627 7105 msgstr ""
dongsheng@627 7106
dongsheng@627 7107 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 7108 #: ../en/ch05-collab.xml:983
dongsheng@627 7109 msgid ""
dongsheng@627 7110 "If you don't have a web server installed, and don't have substantial "
dongsheng@627 7111 "experience configuring Apache, you should consider using the "
dongsheng@627 7112 "<literal>lighttpd</literal> web server instead of Apache. Apache has a well-"
dongsheng@627 7113 "deserved reputation for baroque and confusing configuration. While "
dongsheng@627 7114 "<literal>lighttpd</literal> is less capable in some ways than Apache, most of "
dongsheng@627 7115 "these capabilities are not relevant to serving Mercurial repositories. And "
dongsheng@627 7116 "<literal>lighttpd</literal> is undeniably <emphasis>much</emphasis> easier to "
dongsheng@627 7117 "get started with than Apache."
dongsheng@627 7118 msgstr ""
dongsheng@627 7119
dongsheng@627 7120 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 7121 #: ../en/ch05-collab.xml:996
dongsheng@627 7122 msgid "Basic CGI configuration"
dongsheng@630 7123 msgstr "基本 CGI 配置"
dongsheng@627 7124
dongsheng@627 7125 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 7126 #: ../en/ch05-collab.xml:998
dongsheng@627 7127 msgid ""
dongsheng@627 7128 "On Unix-like systems, it's common for users to have a subdirectory named "
dongsheng@627 7129 "something like <filename class=\"directory\">public_html</filename> in their "
dongsheng@627 7130 "home directory, from which they can serve up web pages. A file named "
dongsheng@627 7131 "<filename>foo</filename> in this directory will be accessible at a URL of the "
dongsheng@650 7132 "form <literal>http://www.example.com/username/foo</literal>."
dongsheng@650 7133 msgstr ""
dongsheng@650 7134
dongsheng@650 7135 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 7136 #: ../en/ch05-collab.xml:1006
dongsheng@627 7137 msgid ""
dongsheng@627 7138 "To get started, find the <filename role=\"special\">hgweb.cgi</filename> "
dongsheng@627 7139 "script that should be present in your Mercurial installation. If you can't "
dongsheng@627 7140 "quickly find a local copy on your system, simply download one from the master "
dongsheng@627 7141 "Mercurial repository at <ulink url=\"http://www.selenic.com/repo/hg/raw-file/"
dongsheng@627 7142 "tip/hgweb.cgi\">http://www.selenic.com/repo/hg/raw-file/tip/hgweb.cgi</ulink>."
dongsheng@627 7143 msgstr ""
dongsheng@627 7144
dongsheng@627 7145 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 7146 #: ../en/ch05-collab.xml:1013 ../en/ch05-collab.xml:1182
dongsheng@627 7147 msgid ""
dongsheng@627 7148 "You'll need to copy this script into your <filename class=\"directory"
dongsheng@627 7149 "\">public_html</filename> directory, and ensure that it's executable."
dongsheng@627 7150 msgstr ""
dongsheng@627 7151
dongsheng@627 7152 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 7153 #: ../en/ch05-collab.xml:1018
dongsheng@627 7154 msgid ""
dongsheng@627 7155 "The <literal>755</literal> argument to <command>chmod</command> is a little "
dongsheng@627 7156 "more general than just making the script executable: it ensures that the "
dongsheng@627 7157 "script is executable by anyone, and that <quote>group</quote> and "
dongsheng@627 7158 "<quote>other</quote> write permissions are <emphasis>not</emphasis> set. If "
dongsheng@627 7159 "you were to leave those write permissions enabled, Apache's <literal>suexec</"
dongsheng@627 7160 "literal> subsystem would likely refuse to execute the script. In fact, "
dongsheng@627 7161 "<literal>suexec</literal> also insists that the <emphasis>directory</"
dongsheng@627 7162 "emphasis> in which the script resides must not be writable by others."
dongsheng@627 7163 msgstr ""
dongsheng@627 7164
dongsheng@627 7165 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
songdongsheng@710 7166 #: ../en/ch05-collab.xml:1032
dongsheng@627 7167 msgid "What could <emphasis>possibly</emphasis> go wrong?"
dongsheng@630 7168 msgstr "什么<emphasis>可能</emphasis>会出错?"
dongsheng@627 7169
dongsheng@627 7170 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@710 7171 #: ../en/ch05-collab.xml:1035
dongsheng@627 7172 msgid ""
dongsheng@627 7173 "Once you've copied the CGI script into place, go into a web browser, and try "
dongsheng@627 7174 "to open the URL <ulink url=\"http://myhostname/ myuser/hgweb.cgi\">http://"
dongsheng@627 7175 "myhostname/ myuser/hgweb.cgi</ulink>, <emphasis>but</emphasis> brace yourself "
dongsheng@627 7176 "for instant failure. There's a high probability that trying to visit this "
dongsheng@627 7177 "URL will fail, and there are many possible reasons for this. In fact, you're "
dongsheng@627 7178 "likely to stumble over almost every one of the possible errors below, so "
dongsheng@627 7179 "please read carefully. The following are all of the problems I ran into on a "
dongsheng@627 7180 "system running Fedora 7, with a fresh installation of Apache, and a user "
dongsheng@627 7181 "account that I created specially to perform this exercise."
dongsheng@627 7182 msgstr ""
dongsheng@627 7183
dongsheng@627 7184 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@710 7185 #: ../en/ch05-collab.xml:1049
dongsheng@627 7186 msgid ""
dongsheng@627 7187 "Your web server may have per-user directories disabled. If you're using "
dongsheng@627 7188 "Apache, search your config file for a <literal>UserDir</literal> directive. "
dongsheng@627 7189 "If there's none present, per-user directories will be disabled. If one "
dongsheng@627 7190 "exists, but its value is <literal>disabled</literal>, then per-user "
dongsheng@627 7191 "directories will be disabled. Otherwise, the string after <literal>UserDir</"
dongsheng@627 7192 "literal> gives the name of the subdirectory that Apache will look in under "
dongsheng@627 7193 "your home directory, for example <filename class=\"directory\">public_html</"
dongsheng@627 7194 "filename>."
dongsheng@627 7195 msgstr ""
dongsheng@627 7196
dongsheng@627 7197 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@710 7198 #: ../en/ch05-collab.xml:1060
dongsheng@627 7199 msgid ""
dongsheng@627 7200 "Your file access permissions may be too restrictive. The web server must be "
dongsheng@627 7201 "able to traverse your home directory and directories under your <filename "
dongsheng@627 7202 "class=\"directory\">public_html</filename> directory, and read files under "
dongsheng@627 7203 "the latter too. Here's a quick recipe to help you to make your permissions "
dongsheng@627 7204 "more appropriate."
dongsheng@627 7205 msgstr ""
dongsheng@627 7206
dongsheng@627 7207 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@710 7208 #: ../en/ch05-collab.xml:1070
dongsheng@627 7209 msgid ""
dongsheng@627 7210 "The other possibility with permissions is that you might get a completely "
dongsheng@627 7211 "empty window when you try to load the script. In this case, it's likely that "
dongsheng@627 7212 "your access permissions are <emphasis>too permissive</emphasis>. Apache's "
dongsheng@627 7213 "<literal>suexec</literal> subsystem won't execute a script that's group- or "
dongsheng@627 7214 "world-writable, for example."
dongsheng@627 7215 msgstr ""
dongsheng@627 7216
dongsheng@627 7217 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@710 7218 #: ../en/ch05-collab.xml:1077
dongsheng@627 7219 msgid ""
dongsheng@627 7220 "Your web server may be configured to disallow execution of CGI programs in "
dongsheng@627 7221 "your per-user web directory. Here's Apache's default per-user configuration "
dongsheng@627 7222 "from my Fedora system."
dongsheng@627 7223 msgstr ""
dongsheng@627 7224
dongsheng@627 7225 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@710 7226 #: ../en/ch05-collab.xml:1084
dongsheng@627 7227 msgid ""
dongsheng@627 7228 "If you find a similar-looking <literal>Directory</literal> group in your "
dongsheng@627 7229 "Apache configuration, the directive to look at inside it is <literal>Options</"
dongsheng@627 7230 "literal>. Add <literal>ExecCGI</literal> to the end of this list if it's "
dongsheng@627 7231 "missing, and restart the web server."
dongsheng@627 7232 msgstr ""
dongsheng@627 7233
dongsheng@627 7234 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@710 7235 #: ../en/ch05-collab.xml:1091
dongsheng@627 7236 msgid ""
dongsheng@627 7237 "If you find that Apache serves you the text of the CGI script instead of "
dongsheng@627 7238 "executing it, you may need to either uncomment (if already present) or add a "
dongsheng@627 7239 "directive like this."
dongsheng@627 7240 msgstr ""
dongsheng@627 7241
dongsheng@627 7242 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@710 7243 #: ../en/ch05-collab.xml:1097
dongsheng@627 7244 msgid ""
dongsheng@627 7245 "The next possibility is that you might be served with a colourful Python "
dongsheng@627 7246 "backtrace claiming that it can't import a <literal>mercurial</literal>-"
dongsheng@627 7247 "related module. This is actually progress! The server is now capable of "
dongsheng@627 7248 "executing your CGI script. This error is only likely to occur if you're "
dongsheng@627 7249 "running a private installation of Mercurial, instead of a system-wide "
dongsheng@627 7250 "version. Remember that the web server runs the CGI program without any of "
dongsheng@627 7251 "the environment variables that you take for granted in an interactive "
dongsheng@627 7252 "session. If this error happens to you, edit your copy of <filename role="
dongsheng@627 7253 "\"special\">hgweb.cgi</filename> and follow the directions inside it to "
dongsheng@627 7254 "correctly set your <envar>PYTHONPATH</envar> environment variable."
dongsheng@627 7255 msgstr ""
dongsheng@627 7256
dongsheng@627 7257 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@710 7258 #: ../en/ch05-collab.xml:1111
dongsheng@627 7259 msgid ""
dongsheng@627 7260 "Finally, you are <emphasis>certain</emphasis> to by served with another "
dongsheng@627 7261 "colourful Python backtrace: this one will complain that it can't find "
dongsheng@627 7262 "<filename class=\"directory\">/path/to/repository</filename>. Edit your "
dongsheng@627 7263 "<filename role=\"special\">hgweb.cgi</filename> script and replace the "
dongsheng@627 7264 "<filename class=\"directory\">/path/to/repository</filename> string with the "
dongsheng@627 7265 "complete path to the repository you want to serve up."
dongsheng@627 7266 msgstr ""
dongsheng@627 7267
dongsheng@627 7268 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@710 7269 #: ../en/ch05-collab.xml:1121
dongsheng@627 7270 msgid ""
dongsheng@627 7271 "At this point, when you try to reload the page, you should be presented with "
dongsheng@627 7272 "a nice HTML view of your repository's history. Whew!"
dongsheng@627 7273 msgstr ""
dongsheng@627 7274
dongsheng@627 7275 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
songdongsheng@710 7276 #: ../en/ch05-collab.xml:1127
dongsheng@627 7277 msgid "Configuring lighttpd"
dongsheng@630 7278 msgstr "配置 lighttpd"
dongsheng@627 7279
dongsheng@627 7280 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@710 7281 #: ../en/ch05-collab.xml:1129
dongsheng@627 7282 msgid ""
dongsheng@627 7283 "To be exhaustive in my experiments, I tried configuring the increasingly "
dongsheng@627 7284 "popular <literal>lighttpd</literal> web server to serve the same repository "
dongsheng@627 7285 "as I described with Apache above. I had already overcome all of the problems "
dongsheng@627 7286 "I outlined with Apache, many of which are not server-specific. As a result, "
dongsheng@627 7287 "I was fairly sure that my file and directory permissions were good, and that "
dongsheng@627 7288 "my <filename role=\"special\">hgweb.cgi</filename> script was properly edited."
dongsheng@627 7289 msgstr ""
dongsheng@627 7290
dongsheng@627 7291 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@710 7292 #: ../en/ch05-collab.xml:1139
dongsheng@627 7293 msgid ""
dongsheng@627 7294 "Once I had Apache running, getting <literal>lighttpd</literal> to serve the "
dongsheng@627 7295 "repository was a snap (in other words, even if you're trying to use "
dongsheng@627 7296 "<literal>lighttpd</literal>, you should read the Apache section). I first "
dongsheng@627 7297 "had to edit the <literal>mod_access</literal> section of its config file to "
dongsheng@627 7298 "enable <literal>mod_cgi</literal> and <literal>mod_userdir</literal>, both of "
dongsheng@627 7299 "which were disabled by default on my system. I then added a few lines to the "
dongsheng@627 7300 "end of the config file, to configure these modules."
dongsheng@627 7301 msgstr ""
dongsheng@627 7302
dongsheng@627 7303 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@710 7304 #: ../en/ch05-collab.xml:1151
dongsheng@627 7305 msgid ""
dongsheng@627 7306 "With this done, <literal>lighttpd</literal> ran immediately for me. If I had "
dongsheng@627 7307 "configured <literal>lighttpd</literal> before Apache, I'd almost certainly "
dongsheng@627 7308 "have run into many of the same system-level configuration problems as I did "
dongsheng@627 7309 "with Apache. However, I found <literal>lighttpd</literal> to be noticeably "
dongsheng@627 7310 "easier to configure than Apache, even though I've used Apache for over a "
dongsheng@627 7311 "decade, and this was my first exposure to <literal>lighttpd</literal>."
dongsheng@627 7312 msgstr ""
dongsheng@627 7313
dongsheng@627 7314 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 7315 #: ../en/ch05-collab.xml:1164
dongsheng@627 7316 msgid "Sharing multiple repositories with one CGI script"
dongsheng@630 7317 msgstr "使用一个 CGI 脚本共享多个版本库"
dongsheng@627 7318
dongsheng@627 7319 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 7320 #: ../en/ch05-collab.xml:1166
dongsheng@627 7321 msgid ""
dongsheng@627 7322 "The <filename role=\"special\">hgweb.cgi</filename> script only lets you "
dongsheng@627 7323 "publish a single repository, which is an annoying restriction. If you want "
dongsheng@627 7324 "to publish more than one without wracking yourself with multiple copies of "
dongsheng@627 7325 "the same script, each with different names, a better choice is to use the "
dongsheng@627 7326 "<filename role=\"special\">hgwebdir.cgi</filename> script."
dongsheng@627 7327 msgstr ""
dongsheng@627 7328
dongsheng@627 7329 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 7330 #: ../en/ch05-collab.xml:1174
dongsheng@627 7331 msgid ""
dongsheng@627 7332 "The procedure to configure <filename role=\"special\">hgwebdir.cgi</filename> "
dongsheng@627 7333 "is only a little more involved than for <filename role=\"special\">hgweb.cgi</"
dongsheng@627 7334 "filename>. First, you must obtain a copy of the script. If you don't have "
dongsheng@627 7335 "one handy, you can download a copy from the master Mercurial repository at "
dongsheng@627 7336 "<ulink url=\"http://www.selenic.com/repo/hg/raw-file/tip/hgwebdir.cgi"
dongsheng@627 7337 "\">http://www.selenic.com/repo/hg/raw-file/tip/hgwebdir.cgi</ulink>."
dongsheng@627 7338 msgstr ""
dongsheng@627 7339
dongsheng@627 7340 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 7341 #: ../en/ch05-collab.xml:1189
dongsheng@627 7342 msgid ""
dongsheng@627 7343 "With basic configuration out of the way, try to visit <ulink url=\"http://"
dongsheng@627 7344 "myhostname/ myuser/hgwebdir.cgi\">http://myhostname/ myuser/hgwebdir.cgi</"
dongsheng@627 7345 "ulink> in your browser. It should display an empty list of repositories. If "
dongsheng@627 7346 "you get a blank window or error message, try walking through the list of "
songdongsheng@658 7347 "potential problems in <xref linkend=\"sec:collab:wtf\"/>."
songdongsheng@658 7348 msgstr ""
songdongsheng@658 7349
songdongsheng@658 7350 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 7351 #: ../en/ch05-collab.xml:1198
dongsheng@627 7352 msgid ""
dongsheng@627 7353 "The <filename role=\"special\">hgwebdir.cgi</filename> script relies on an "
dongsheng@627 7354 "external configuration file. By default, it searches for a file named "
dongsheng@627 7355 "<filename role=\"special\">hgweb.config</filename> in the same directory as "
dongsheng@627 7356 "itself. You'll need to create this file, and make it world-readable. The "
dongsheng@627 7357 "format of the file is similar to a Windows <quote>ini</quote> file, as "
dongsheng@627 7358 "understood by Python's <literal>ConfigParser</literal> <citation>web:"
dongsheng@627 7359 "configparser</citation> module."
dongsheng@627 7360 msgstr ""
dongsheng@627 7361
dongsheng@627 7362 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 7363 #: ../en/ch05-collab.xml:1208
dongsheng@627 7364 msgid ""
dongsheng@627 7365 "The easiest way to configure <filename role=\"special\">hgwebdir.cgi</"
dongsheng@627 7366 "filename> is with a section named <literal>collections</literal>. This will "
dongsheng@627 7367 "automatically publish <emphasis>every</emphasis> repository under the "
dongsheng@627 7368 "directories you name. The section should look like this:"
dongsheng@627 7369 msgstr ""
dongsheng@627 7370
dongsheng@627 7371 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 7372 #: ../en/ch05-collab.xml:1216
dongsheng@627 7373 msgid ""
dongsheng@627 7374 "Mercurial interprets this by looking at the directory name on the "
dongsheng@627 7375 "<emphasis>right</emphasis> hand side of the <quote><literal>=</literal></"
dongsheng@627 7376 "quote> sign; finding repositories in that directory hierarchy; and using the "
dongsheng@627 7377 "text on the <emphasis>left</emphasis> to strip off matching text from the "
dongsheng@627 7378 "names it will actually list in the web interface. The remaining component of "
dongsheng@627 7379 "a path after this stripping has occurred is called a <quote>virtual path</"
dongsheng@627 7380 "quote>."
dongsheng@627 7381 msgstr ""
dongsheng@627 7382
dongsheng@627 7383 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 7384 #: ../en/ch05-collab.xml:1225
dongsheng@627 7385 msgid ""
dongsheng@627 7386 "Given the example above, if we have a repository whose local path is "
dongsheng@627 7387 "<filename class=\"directory\">/my/root/this/repo</filename>, the CGI script "
dongsheng@627 7388 "will strip the leading <filename class=\"directory\">/my/root</filename> from "
dongsheng@627 7389 "the name, and publish the repository with a virtual path of <filename class="
dongsheng@627 7390 "\"directory\">this/repo</filename>. If the base URL for our CGI script is "
dongsheng@627 7391 "<ulink url=\"http://myhostname/ myuser/hgwebdir.cgi\">http://myhostname/ "
dongsheng@627 7392 "myuser/hgwebdir.cgi</ulink>, the complete URL for that repository will be "
dongsheng@627 7393 "<ulink url=\"http://myhostname/ myuser/hgwebdir.cgi/this/repo\">http://"
dongsheng@627 7394 "myhostname/ myuser/hgwebdir.cgi/this/repo</ulink>."
dongsheng@627 7395 msgstr ""
dongsheng@627 7396
dongsheng@627 7397 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 7398 #: ../en/ch05-collab.xml:1239
dongsheng@627 7399 msgid ""
dongsheng@627 7400 "If we replace <filename class=\"directory\">/my/root</filename> on the left "
dongsheng@627 7401 "hand side of this example with <filename class=\"directory\">/my</filename>, "
dongsheng@627 7402 "then <filename role=\"special\">hgwebdir.cgi</filename> will only strip off "
dongsheng@627 7403 "<filename class=\"directory\">/my</filename> from the repository name, and "
dongsheng@627 7404 "will give us a virtual path of <filename class=\"directory\">root/this/repo</"
dongsheng@627 7405 "filename> instead of <filename class=\"directory\">this/repo</filename>."
dongsheng@627 7406 msgstr ""
dongsheng@627 7407
dongsheng@627 7408 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 7409 #: ../en/ch05-collab.xml:1249
dongsheng@627 7410 msgid ""
dongsheng@627 7411 "The <filename role=\"special\">hgwebdir.cgi</filename> script will "
dongsheng@627 7412 "recursively search each directory listed in the <literal>collections</"
dongsheng@627 7413 "literal> section of its configuration file, but it will <literal>not</"
dongsheng@627 7414 "literal> recurse into the repositories it finds."
dongsheng@627 7415 msgstr ""
dongsheng@627 7416
dongsheng@627 7417 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 7418 #: ../en/ch05-collab.xml:1255
dongsheng@627 7419 msgid ""
dongsheng@627 7420 "The <literal>collections</literal> mechanism makes it easy to publish many "
dongsheng@627 7421 "repositories in a <quote>fire and forget</quote> manner. You only need to "
dongsheng@627 7422 "set up the CGI script and configuration file one time. Afterwards, you can "
dongsheng@627 7423 "publish or unpublish a repository at any time by simply moving it into, or "
dongsheng@627 7424 "out of, the directory hierarchy in which you've configured <filename role="
dongsheng@627 7425 "\"special\">hgwebdir.cgi</filename> to look."
dongsheng@627 7426 msgstr ""
dongsheng@627 7427
dongsheng@627 7428 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
songdongsheng@710 7429 #: ../en/ch05-collab.xml:1265
dongsheng@627 7430 msgid "Explicitly specifying which repositories to publish"
dongsheng@630 7431 msgstr "明确指出要发布的版本库"
dongsheng@627 7432
dongsheng@627 7433 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@710 7434 #: ../en/ch05-collab.xml:1268
dongsheng@627 7435 msgid ""
dongsheng@627 7436 "In addition to the <literal>collections</literal> mechanism, the <filename "
dongsheng@627 7437 "role=\"special\">hgwebdir.cgi</filename> script allows you to publish a "
dongsheng@627 7438 "specific list of repositories. To do so, create a <literal>paths</literal> "
dongsheng@627 7439 "section, with contents of the following form."
dongsheng@627 7440 msgstr ""
dongsheng@627 7441
dongsheng@627 7442 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@710 7443 #: ../en/ch05-collab.xml:1277
dongsheng@627 7444 msgid ""
dongsheng@627 7445 "In this case, the virtual path (the component that will appear in a URL) is "
dongsheng@627 7446 "on the left hand side of each definition, while the path to the repository is "
dongsheng@627 7447 "on the right. Notice that there does not need to be any relationship between "
dongsheng@627 7448 "the virtual path you choose and the location of a repository in your "
dongsheng@627 7449 "filesystem."
dongsheng@627 7450 msgstr ""
dongsheng@627 7451
dongsheng@627 7452 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@710 7453 #: ../en/ch05-collab.xml:1284
dongsheng@627 7454 msgid ""
dongsheng@627 7455 "If you wish, you can use both the <literal>collections</literal> and "
dongsheng@627 7456 "<literal>paths</literal> mechanisms simultaneously in a single configuration "
dongsheng@627 7457 "file."
dongsheng@627 7458 msgstr ""
dongsheng@627 7459
songdongsheng@710 7460 #. type: Content of: <book><chapter><sect1><sect2><sect3><note><title>
songdongsheng@710 7461 #: ../en/ch05-collab.xml:1290
songdongsheng@710 7462 msgid "Beware duplicate virtual paths"
songdongsheng@710 7463 msgstr ""
songdongsheng@710 7464
dongsheng@627 7465 #. type: Content of: <book><chapter><sect1><sect2><sect3><note><para>
songdongsheng@710 7466 #: ../en/ch05-collab.xml:1292
songdongsheng@710 7467 msgid ""
songdongsheng@710 7468 "If several repositories have the same virtual path, <filename role=\"special"
dongsheng@627 7469 "\">hgwebdir.cgi</filename> will not report an error. Instead, it will behave "
dongsheng@627 7470 "unpredictably."
dongsheng@627 7471 msgstr ""
dongsheng@627 7472
dongsheng@627 7473 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 7474 #: ../en/ch05-collab.xml:1301
dongsheng@627 7475 msgid "Downloading source archives"
dongsheng@630 7476 msgstr "下载源代码档案包"
dongsheng@627 7477
dongsheng@627 7478 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 7479 #: ../en/ch05-collab.xml:1303
dongsheng@627 7480 msgid ""
dongsheng@627 7481 "Mercurial's web interface lets users download an archive of any revision. "
dongsheng@627 7482 "This archive will contain a snapshot of the working directory as of that "
dongsheng@627 7483 "revision, but it will not contain a copy of the repository data."
dongsheng@627 7484 msgstr ""
dongsheng@627 7485
dongsheng@627 7486 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 7487 #: ../en/ch05-collab.xml:1308
dongsheng@627 7488 msgid ""
dongsheng@627 7489 "By default, this feature is not enabled. To enable it, you'll need to add an "
dongsheng@627 7490 "<envar role=\"rc-item-web\">allow_archive</envar> item to the <literal role="
dongsheng@650 7491 "\"rc-web\">web</literal> section of your <filename role=\"special\">~/.hgrc</"
songdongsheng@710 7492 "filename>; see below for details."
songdongsheng@710 7493 msgstr ""
songdongsheng@710 7494
songdongsheng@710 7495 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 7496 #: ../en/ch05-collab.xml:1315
dongsheng@627 7497 msgid "Web configuration options"
dongsheng@630 7498 msgstr "Web 配置选项"
dongsheng@627 7499
dongsheng@627 7500 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 7501 #: ../en/ch05-collab.xml:1317
dongsheng@627 7502 msgid ""
dongsheng@627 7503 "Mercurial's web interfaces (the <command role=\"hg-cmd\">hg serve</command> "
dongsheng@627 7504 "command, and the <filename role=\"special\">hgweb.cgi</filename> and "
dongsheng@627 7505 "<filename role=\"special\">hgwebdir.cgi</filename> scripts) have a number of "
dongsheng@627 7506 "configuration options that you can set. These belong in a section named "
dongsheng@627 7507 "<literal role=\"rc-web\">web</literal>."
dongsheng@627 7508 msgstr ""
dongsheng@627 7509
dongsheng@627 7510 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@710 7511 #: ../en/ch05-collab.xml:1325
dongsheng@627 7512 msgid ""
dongsheng@627 7513 "<envar role=\"rc-item-web\">allow_archive</envar>: Determines which (if any) "
dongsheng@627 7514 "archive download mechanisms Mercurial supports. If you enable this feature, "
dongsheng@627 7515 "users of the web interface will be able to download an archive of whatever "
dongsheng@627 7516 "revision of a repository they are viewing. To enable the archive feature, "
dongsheng@627 7517 "this item must take the form of a sequence of words drawn from the list below."
dongsheng@627 7518 msgstr ""
dongsheng@627 7519
dongsheng@627 7520 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
songdongsheng@710 7521 #: ../en/ch05-collab.xml:1334
dongsheng@627 7522 msgid ""
dongsheng@627 7523 "<literal>bz2</literal>: A <command>tar</command> archive, compressed using "
dongsheng@627 7524 "<literal>bzip2</literal> compression. This has the best compression ratio, "
dongsheng@627 7525 "but uses the most CPU time on the server."
dongsheng@627 7526 msgstr ""
dongsheng@627 7527
dongsheng@627 7528 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
songdongsheng@710 7529 #: ../en/ch05-collab.xml:1340
dongsheng@627 7530 msgid ""
dongsheng@627 7531 "<literal>gz</literal>: A <command>tar</command> archive, compressed using "
dongsheng@627 7532 "<literal>gzip</literal> compression."
dongsheng@627 7533 msgstr ""
dongsheng@627 7534
dongsheng@627 7535 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
songdongsheng@710 7536 #: ../en/ch05-collab.xml:1344
dongsheng@627 7537 msgid ""
dongsheng@627 7538 "<literal>zip</literal>: A <command>zip</command> archive, compressed using "
dongsheng@627 7539 "LZW compression. This format has the worst compression ratio, but is widely "
dongsheng@627 7540 "used in the Windows world."
dongsheng@627 7541 msgstr ""
dongsheng@627 7542
dongsheng@627 7543 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@710 7544 #: ../en/ch05-collab.xml:1350
dongsheng@627 7545 msgid ""
dongsheng@627 7546 "If you provide an empty list, or don't have an <envar role=\"rc-item-web"
dongsheng@627 7547 "\">allow_archive</envar> entry at all, this feature will be disabled. Here "
dongsheng@627 7548 "is an example of how to enable all three supported formats."
dongsheng@627 7549 msgstr ""
dongsheng@627 7550
dongsheng@627 7551 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@710 7552 #: ../en/ch05-collab.xml:1357
dongsheng@627 7553 msgid ""
dongsheng@627 7554 "<envar role=\"rc-item-web\">allowpull</envar>: Boolean. Determines whether "
dongsheng@627 7555 "the web interface allows remote users to <command role=\"hg-cmd\">hg pull</"
dongsheng@627 7556 "command> and <command role=\"hg-cmd\">hg clone</command> this repository over "
dongsheng@627 7557 "HTTP. If set to <literal>no</literal> or <literal>false</literal>, only the "
dongsheng@627 7558 "<quote>human-oriented</quote> portion of the web interface is available."
dongsheng@627 7559 msgstr ""
dongsheng@627 7560
dongsheng@627 7561 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@710 7562 #: ../en/ch05-collab.xml:1366
dongsheng@627 7563 msgid ""
dongsheng@627 7564 "<envar role=\"rc-item-web\">contact</envar>: String. A free-form (but "
dongsheng@627 7565 "preferably brief) string identifying the person or group in charge of the "
dongsheng@627 7566 "repository. This often contains the name and email address of a person or "
dongsheng@627 7567 "mailing list. It often makes sense to place this entry in a repository's own "
dongsheng@627 7568 "<filename role=\"special\">.hg/hgrc</filename> file, but it can make sense to "
dongsheng@650 7569 "use in a global <filename role=\"special\">~/.hgrc</filename> if every "
dongsheng@627 7570 "repository has a single maintainer."
dongsheng@627 7571 msgstr ""
dongsheng@627 7572
dongsheng@627 7573 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@710 7574 #: ../en/ch05-collab.xml:1377
dongsheng@627 7575 msgid ""
dongsheng@627 7576 "<envar role=\"rc-item-web\">maxchanges</envar>: Integer. The default maximum "
dongsheng@627 7577 "number of changesets to display in a single page of output."
dongsheng@627 7578 msgstr ""
dongsheng@627 7579
dongsheng@627 7580 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@710 7581 #: ../en/ch05-collab.xml:1381
dongsheng@627 7582 msgid ""
dongsheng@627 7583 "<envar role=\"rc-item-web\">maxfiles</envar>: Integer. The default maximum "
dongsheng@627 7584 "number of modified files to display in a single page of output."
dongsheng@627 7585 msgstr ""
dongsheng@627 7586
dongsheng@627 7587 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@710 7588 #: ../en/ch05-collab.xml:1385
dongsheng@627 7589 msgid ""
dongsheng@627 7590 "<envar role=\"rc-item-web\">stripes</envar>: Integer. If the web interface "
dongsheng@627 7591 "displays alternating <quote>stripes</quote> to make it easier to visually "
dongsheng@627 7592 "align rows when you are looking at a table, this number controls the number "
dongsheng@627 7593 "of rows in each stripe."
dongsheng@627 7594 msgstr ""
dongsheng@627 7595
dongsheng@627 7596 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@710 7597 #: ../en/ch05-collab.xml:1391
dongsheng@627 7598 msgid ""
dongsheng@627 7599 "<envar role=\"rc-item-web\">style</envar>: Controls the template Mercurial "
songdongsheng@710 7600 "uses to display the web interface. Mercurial ships with several web "
songdongsheng@710 7601 "templates."
songdongsheng@710 7602 msgstr ""
songdongsheng@710 7603
songdongsheng@710 7604 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
songdongsheng@710 7605 #: ../en/ch05-collab.xml:1397
songdongsheng@710 7606 msgid "<literal>coal</literal> is monochromatic."
songdongsheng@710 7607 msgstr ""
songdongsheng@710 7608
songdongsheng@710 7609 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
songdongsheng@710 7610 #: ../en/ch05-collab.xml:1400
songdongsheng@710 7611 msgid ""
songdongsheng@710 7612 "<literal>gitweb</literal> emulates the visual style of git's web interface."
songdongsheng@710 7613 msgstr ""
songdongsheng@710 7614
songdongsheng@710 7615 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
songdongsheng@710 7616 #: ../en/ch05-collab.xml:1404
songdongsheng@710 7617 msgid "<literal>monoblue</literal> uses solid blues and greys."
songdongsheng@710 7618 msgstr ""
songdongsheng@710 7619
songdongsheng@710 7620 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
songdongsheng@710 7621 #: ../en/ch05-collab.xml:1408
songdongsheng@710 7622 msgid "<literal>paper</literal> is the default."
songdongsheng@710 7623 msgstr ""
songdongsheng@710 7624
songdongsheng@710 7625 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
songdongsheng@710 7626 #: ../en/ch05-collab.xml:1411
songdongsheng@710 7627 msgid "<literal>spartan</literal> was the default for a long time."
dongsheng@627 7628 msgstr ""
dongsheng@627 7629
dongsheng@627 7630 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@710 7631 #: ../en/ch05-collab.xml:1415
songdongsheng@710 7632 msgid ""
songdongsheng@710 7633 "You can also specify a custom template of your own; see <xref linkend=\"chap:"
songdongsheng@710 7634 "template\"/> for details. Here, you can see how to enable the "
songdongsheng@710 7635 "<literal>gitweb</literal> style."
songdongsheng@710 7636 msgstr ""
songdongsheng@710 7637
songdongsheng@710 7638 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@710 7639 #: ../en/ch05-collab.xml:1423
dongsheng@627 7640 msgid ""
dongsheng@627 7641 "<envar role=\"rc-item-web\">templates</envar>: Path. The directory in which "
dongsheng@627 7642 "to search for template files. By default, Mercurial searches in the "
dongsheng@627 7643 "directory in which it was installed."
dongsheng@627 7644 msgstr ""
dongsheng@627 7645
dongsheng@627 7646 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 7647 #: ../en/ch05-collab.xml:1428
dongsheng@627 7648 msgid ""
dongsheng@627 7649 "If you are using <filename role=\"special\">hgwebdir.cgi</filename>, you can "
dongsheng@627 7650 "place a few configuration items in a <literal role=\"rc-web\">web</literal> "
dongsheng@627 7651 "section of the <filename role=\"special\">hgweb.config</filename> file "
dongsheng@650 7652 "instead of a <filename role=\"special\">~/.hgrc</filename> file, for "
dongsheng@627 7653 "convenience. These items are <envar role=\"rc-item-web\">motd</envar> and "
dongsheng@627 7654 "<envar role=\"rc-item-web\">style</envar>."
dongsheng@627 7655 msgstr ""
dongsheng@627 7656
dongsheng@627 7657 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
songdongsheng@710 7658 #: ../en/ch05-collab.xml:1439
dongsheng@627 7659 msgid "Options specific to an individual repository"
dongsheng@630 7660 msgstr "针对单个版本库的选项"
dongsheng@627 7661
dongsheng@627 7662 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@710 7663 #: ../en/ch05-collab.xml:1441
dongsheng@627 7664 msgid ""
dongsheng@627 7665 "A few <literal role=\"rc-web\">web</literal> configuration items ought to be "
dongsheng@627 7666 "placed in a repository's local <filename role=\"special\">.hg/hgrc</"
dongsheng@650 7667 "filename>, rather than a user's or global <filename role=\"special\">~/.hgrc</"
dongsheng@627 7668 "filename>."
dongsheng@627 7669 msgstr ""
dongsheng@627 7670
dongsheng@627 7671 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
songdongsheng@710 7672 #: ../en/ch05-collab.xml:1446
dongsheng@627 7673 msgid ""
dongsheng@627 7674 "<envar role=\"rc-item-web\">description</envar>: String. A free-form (but "
dongsheng@627 7675 "preferably brief) string that describes the contents or purpose of the "
dongsheng@627 7676 "repository."
dongsheng@627 7677 msgstr ""
dongsheng@627 7678
dongsheng@627 7679 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
songdongsheng@710 7680 #: ../en/ch05-collab.xml:1451
dongsheng@627 7681 msgid ""
dongsheng@627 7682 "<envar role=\"rc-item-web\">name</envar>: String. The name to use for the "
dongsheng@627 7683 "repository in the web interface. This overrides the default name, which is "
dongsheng@627 7684 "the last component of the repository's path."
dongsheng@627 7685 msgstr ""
dongsheng@627 7686
dongsheng@627 7687 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
songdongsheng@710 7688 #: ../en/ch05-collab.xml:1459
dongsheng@627 7689 msgid ""
dongsheng@627 7690 "Options specific to the <command role=\"hg-cmd\">hg serve</command> command"
dongsheng@630 7691 msgstr "命令 <command role=\"hg-cmd\">hg serve</command> 的选项"
dongsheng@627 7692
dongsheng@627 7693 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@710 7694 #: ../en/ch05-collab.xml:1462
dongsheng@627 7695 msgid ""
dongsheng@627 7696 "Some of the items in the <literal role=\"rc-web\">web</literal> section of a "
dongsheng@650 7697 "<filename role=\"special\">~/.hgrc</filename> file are only for use with the "
dongsheng@650 7698 "<command role=\"hg-cmd\">hg serve</command> command."
dongsheng@627 7699 msgstr ""
dongsheng@627 7700
dongsheng@627 7701 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
songdongsheng@710 7702 #: ../en/ch05-collab.xml:1468
dongsheng@627 7703 msgid ""
dongsheng@627 7704 "<envar role=\"rc-item-web\">accesslog</envar>: Path. The name of a file into "
dongsheng@627 7705 "which to write an access log. By default, the <command role=\"hg-cmd\">hg "
dongsheng@627 7706 "serve</command> command writes this information to standard output, not to a "
dongsheng@627 7707 "file. Log entries are written in the standard <quote>combined</quote> file "
dongsheng@627 7708 "format used by almost all web servers."
dongsheng@627 7709 msgstr ""
dongsheng@627 7710
dongsheng@627 7711 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
songdongsheng@710 7712 #: ../en/ch05-collab.xml:1476
dongsheng@627 7713 msgid ""
dongsheng@627 7714 "<envar role=\"rc-item-web\">address</envar>: String. The local address on "
dongsheng@627 7715 "which the server should listen for incoming connections. By default, the "
dongsheng@627 7716 "server listens on all addresses."
dongsheng@627 7717 msgstr ""
dongsheng@627 7718
dongsheng@627 7719 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
songdongsheng@710 7720 #: ../en/ch05-collab.xml:1481
dongsheng@627 7721 msgid ""
dongsheng@627 7722 "<envar role=\"rc-item-web\">errorlog</envar>: Path. The name of a file into "
dongsheng@627 7723 "which to write an error log. By default, the <command role=\"hg-cmd\">hg "
dongsheng@627 7724 "serve</command> command writes this information to standard error, not to a "
dongsheng@627 7725 "file."
dongsheng@627 7726 msgstr ""
dongsheng@627 7727
dongsheng@627 7728 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
songdongsheng@710 7729 #: ../en/ch05-collab.xml:1487
dongsheng@627 7730 msgid ""
dongsheng@627 7731 "<envar role=\"rc-item-web\">ipv6</envar>: Boolean. Whether to use the IPv6 "
dongsheng@627 7732 "protocol. By default, IPv6 is not used."
dongsheng@627 7733 msgstr ""
dongsheng@627 7734
dongsheng@627 7735 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
songdongsheng@710 7736 #: ../en/ch05-collab.xml:1491
dongsheng@627 7737 msgid ""
dongsheng@627 7738 "<envar role=\"rc-item-web\">port</envar>: Integer. The TCP port number on "
dongsheng@627 7739 "which the server should listen. The default port number used is 8000."
dongsheng@627 7740 msgstr ""
dongsheng@627 7741
dongsheng@627 7742 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
songdongsheng@710 7743 #: ../en/ch05-collab.xml:1498
dongsheng@650 7744 msgid ""
dongsheng@650 7745 "Choosing the right <filename role=\"special\">~/.hgrc</filename> file to add "
dongsheng@650 7746 "<literal role=\"rc-web\">web</literal> items to"
dongsheng@627 7747 msgstr ""
dongsheng@653 7748 "选择正确的 <filename role=\"special\"> ~/.hgrc</filename> 文件增加到 <literal "
dongsheng@630 7749 "role=\"rc-web\">web</literal> 条目"
dongsheng@627 7750
dongsheng@627 7751 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@710 7752 #: ../en/ch05-collab.xml:1502
dongsheng@627 7753 msgid ""
dongsheng@627 7754 "It is important to remember that a web server like Apache or "
dongsheng@627 7755 "<literal>lighttpd</literal> will run under a user ID that is different to "
dongsheng@627 7756 "yours. CGI scripts run by your server, such as <filename role=\"special"
dongsheng@627 7757 "\">hgweb.cgi</filename>, will usually also run under that user ID."
dongsheng@627 7758 msgstr ""
dongsheng@627 7759
dongsheng@627 7760 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@710 7761 #: ../en/ch05-collab.xml:1509
dongsheng@627 7762 msgid ""
dongsheng@627 7763 "If you add <literal role=\"rc-web\">web</literal> items to your own personal "
dongsheng@650 7764 "<filename role=\"special\">~/.hgrc</filename> file, CGI scripts won't read "
dongsheng@650 7765 "that <filename role=\"special\">~/.hgrc</filename> file. Those settings will "
songdongsheng@710 7766 "thus only affect the behavior of the <command role=\"hg-cmd\">hg serve</"
dongsheng@627 7767 "command> command when you run it. To cause CGI scripts to see your settings, "
dongsheng@650 7768 "either create a <filename role=\"special\">~/.hgrc</filename> file in the "
dongsheng@627 7769 "home directory of the user ID that runs your web server, or add those "
songdongsheng@710 7770 "settings to a system-wide <filename role=\"special\">hgrc</filename> file."
songdongsheng@710 7771 msgstr ""
songdongsheng@710 7772
songdongsheng@710 7773 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@710 7774 #: ../en/ch05-collab.xml:1524
songdongsheng@710 7775 #, fuzzy
songdongsheng@710 7776 msgid "System-wide configuration"
songdongsheng@710 7777 msgstr "基本 CGI 配置"
songdongsheng@710 7778
songdongsheng@710 7779 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 7780 #: ../en/ch05-collab.xml:1526
songdongsheng@710 7781 msgid ""
songdongsheng@710 7782 "On Unix-like systems shared by multiple users (such as a server to which "
songdongsheng@710 7783 "people publish changes), it often makes sense to set up some global default "
songdongsheng@710 7784 "behaviors, such as what theme to use in web interfaces."
songdongsheng@710 7785 msgstr ""
songdongsheng@710 7786
songdongsheng@710 7787 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 7788 #: ../en/ch05-collab.xml:1531
songdongsheng@710 7789 msgid ""
songdongsheng@710 7790 "If a file named <filename>/etc/mercurial/hgrc</filename> exists, Mercurial "
songdongsheng@710 7791 "will read it at startup time and apply any configuration settings it finds in "
songdongsheng@710 7792 "that file. It will also look for files ending in a <literal>.rc</literal> "
songdongsheng@710 7793 "extension in a directory named <filename>/etc/mercurial/hgrc.d</filename>, "
songdongsheng@710 7794 "and apply any configuration settings it finds in each of those files."
songdongsheng@710 7795 msgstr ""
songdongsheng@710 7796
songdongsheng@710 7797 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 7798 #: ../en/ch05-collab.xml:1540
songdongsheng@710 7799 #, fuzzy
songdongsheng@710 7800 msgid "Making Mercurial more trusting"
songdongsheng@710 7801 msgstr "安装 Mercurial"
songdongsheng@710 7802
songdongsheng@710 7803 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 7804 #: ../en/ch05-collab.xml:1542
songdongsheng@710 7805 msgid ""
songdongsheng@710 7806 "One situation in which a global <filename>hgrc</filename> can be useful is if "
songdongsheng@710 7807 "users are pulling changes owned by other users. By default, Mercurial will "
songdongsheng@710 7808 "not trust most of the configuration items in a <filename>.hg/hgrc</filename> "
songdongsheng@710 7809 "file inside a repository that is owned by a different user. If we clone or "
songdongsheng@710 7810 "pull changes from such a repository, Mercurial will print a warning stating "
songdongsheng@710 7811 "that it does not trust their <filename>.hg/hgrc</filename>."
songdongsheng@710 7812 msgstr ""
songdongsheng@710 7813
songdongsheng@710 7814 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 7815 #: ../en/ch05-collab.xml:1551
songdongsheng@710 7816 msgid ""
songdongsheng@710 7817 "If everyone in a particular Unix group is on the same team and "
songdongsheng@710 7818 "<emphasis>should</emphasis> trust each other's configuration settings, or we "
songdongsheng@710 7819 "want to trust particular users, we can override Mercurial's skeptical "
songdongsheng@710 7820 "defaults by creating a system-wide <filename>hgrc</filename> file such as the "
songdongsheng@710 7821 "following:"
dongsheng@627 7822 msgstr ""
dongsheng@627 7823
dongsheng@627 7824 #. type: Content of: <book><chapter><title>
dongsheng@650 7825 #: ../en/ch06-filenames.xml:5
dongsheng@627 7826 msgid "File names and pattern matching"
dongsheng@627 7827 msgstr "文件名称与模式匹配"
dongsheng@627 7828
dongsheng@627 7829 #. type: Content of: <book><chapter><para>
dongsheng@650 7830 #: ../en/ch06-filenames.xml:7
dongsheng@627 7831 msgid ""
dongsheng@627 7832 "Mercurial provides mechanisms that let you work with file names in a "
dongsheng@627 7833 "consistent and expressive way."
dongsheng@627 7834 msgstr ""
dongsheng@627 7835
dongsheng@627 7836 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 7837 #: ../en/ch06-filenames.xml:11
dongsheng@627 7838 msgid "Simple file naming"
dongsheng@630 7839 msgstr "简单文件名称"
dongsheng@627 7840
dongsheng@627 7841 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 7842 #: ../en/ch06-filenames.xml:13
dongsheng@627 7843 msgid ""
dongsheng@627 7844 "Mercurial uses a unified piece of machinery <quote>under the hood</quote> to "
dongsheng@627 7845 "handle file names. Every command behaves uniformly with respect to file "
dongsheng@627 7846 "names. The way in which commands work with file names is as follows."
dongsheng@627 7847 msgstr ""
dongsheng@627 7848
dongsheng@627 7849 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 7850 #: ../en/ch06-filenames.xml:18
dongsheng@627 7851 msgid ""
dongsheng@627 7852 "If you explicitly name real files on the command line, Mercurial works with "
dongsheng@627 7853 "exactly those files, as you would expect. &interaction.filenames.files;"
dongsheng@627 7854 msgstr ""
dongsheng@627 7855
dongsheng@627 7856 #
dongsheng@627 7857 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 7858 #: ../en/ch06-filenames.xml:22
dongsheng@627 7859 msgid ""
dongsheng@627 7860 "When you provide a directory name, Mercurial will interpret this as "
dongsheng@627 7861 "<quote>operate on every file in this directory and its subdirectories</"
dongsheng@627 7862 "quote>. Mercurial traverses the files and subdirectories in a directory in "
dongsheng@627 7863 "alphabetical order. When it encounters a subdirectory, it will traverse that "
dongsheng@627 7864 "subdirectory before continuing with the current directory."
dongsheng@627 7865 msgstr ""
dongsheng@627 7866
dongsheng@627 7867 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 7868 #: ../en/ch06-filenames.xml:33
dongsheng@627 7869 msgid "Running commands without any file names"
dongsheng@630 7870 msgstr "不提供文件名称的执行命令"
dongsheng@627 7871
dongsheng@627 7872 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 7873 #: ../en/ch06-filenames.xml:35
dongsheng@627 7874 msgid ""
songdongsheng@710 7875 "Mercurial's commands that work with file names have useful default behaviors "
dongsheng@627 7876 "when you invoke them without providing any file names or patterns. What kind "
songdongsheng@710 7877 "of behavior you should expect depends on what the command does. Here are a "
dongsheng@627 7878 "few rules of thumb you can use to predict what a command is likely to do if "
dongsheng@627 7879 "you don't give it any names to work with."
dongsheng@627 7880 msgstr ""
dongsheng@627 7881
dongsheng@627 7882 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 7883 #: ../en/ch06-filenames.xml:42
dongsheng@627 7884 msgid ""
dongsheng@627 7885 "Most commands will operate on the entire working directory. This is what the "
dongsheng@627 7886 "<command role=\"hg-cmd\">hg add</command> command does, for example."
dongsheng@627 7887 msgstr ""
dongsheng@627 7888
dongsheng@627 7889 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 7890 #: ../en/ch06-filenames.xml:46
dongsheng@627 7891 msgid ""
dongsheng@627 7892 "If the command has effects that are difficult or impossible to reverse, it "
dongsheng@627 7893 "will force you to explicitly provide at least one name or pattern (see "
dongsheng@627 7894 "below). This protects you from accidentally deleting files by running "
dongsheng@627 7895 "<command role=\"hg-cmd\">hg remove</command> with no arguments, for example."
dongsheng@627 7896 msgstr ""
dongsheng@627 7897
dongsheng@627 7898 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 7899 #: ../en/ch06-filenames.xml:54
dongsheng@627 7900 msgid ""
songdongsheng@710 7901 "It's easy to work around these default behaviors if they don't suit you. If "
dongsheng@627 7902 "a command normally operates on the whole working directory, you can invoke it "
dongsheng@627 7903 "on just the current directory and its subdirectories by giving it the name "
dongsheng@627 7904 "<quote><filename class=\"directory\">.</filename></quote>."
dongsheng@627 7905 msgstr ""
dongsheng@627 7906
dongsheng@627 7907 #
dongsheng@627 7908 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 7909 #: ../en/ch06-filenames.xml:62
dongsheng@627 7910 msgid ""
dongsheng@627 7911 "Along the same lines, some commands normally print file names relative to the "
dongsheng@627 7912 "root of the repository, even if you're invoking them from a subdirectory. "
dongsheng@627 7913 "Such a command will print file names relative to your subdirectory if you "
dongsheng@627 7914 "give it explicit names. Here, we're going to run <command role=\"hg-cmd\">hg "
dongsheng@627 7915 "status</command> from a subdirectory, and get it to operate on the entire "
dongsheng@627 7916 "working directory while printing file names relative to our subdirectory, by "
dongsheng@627 7917 "passing it the output of the <command role=\"hg-cmd\">hg root</command> "
dongsheng@627 7918 "command."
dongsheng@627 7919 msgstr ""
dongsheng@627 7920
dongsheng@627 7921 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 7922 #: ../en/ch06-filenames.xml:76
dongsheng@627 7923 msgid "Telling you what's going on"
dongsheng@630 7924 msgstr "告诉你正在做什么"
dongsheng@627 7925
dongsheng@627 7926 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 7927 #: ../en/ch06-filenames.xml:78
dongsheng@627 7928 msgid ""
dongsheng@627 7929 "The <command role=\"hg-cmd\">hg add</command> example in the preceding "
dongsheng@627 7930 "section illustrates something else that's helpful about Mercurial commands. "
dongsheng@627 7931 "If a command operates on a file that you didn't name explicitly on the "
dongsheng@627 7932 "command line, it will usually print the name of the file, so that you will "
dongsheng@627 7933 "not be surprised what's going on."
dongsheng@627 7934 msgstr ""
dongsheng@627 7935
dongsheng@627 7936 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 7937 #: ../en/ch06-filenames.xml:85
dongsheng@627 7938 msgid ""
dongsheng@627 7939 "The principle here is of <emphasis>least surprise</emphasis>. If you've "
dongsheng@627 7940 "exactly named a file on the command line, there's no point in repeating it "
dongsheng@627 7941 "back at you. If Mercurial is acting on a file <emphasis>implicitly</"
songdongsheng@710 7942 "emphasis>, e.g. because you provided no names, or a directory, or a pattern "
songdongsheng@710 7943 "(see below), it is safest to tell you what files it's operating on."
dongsheng@627 7944 msgstr ""
dongsheng@627 7945
dongsheng@627 7946 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 7947 #: ../en/ch06-filenames.xml:92
dongsheng@627 7948 msgid ""
dongsheng@627 7949 "For commands that behave this way, you can silence them using the <option "
dongsheng@627 7950 "role=\"hg-opt-global\">-q</option> option. You can also get them to print "
dongsheng@627 7951 "the name of every file, even those you've named explicitly, using the <option "
dongsheng@627 7952 "role=\"hg-opt-global\">-v</option> option."
dongsheng@627 7953 msgstr ""
dongsheng@627 7954
dongsheng@627 7955 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 7956 #: ../en/ch06-filenames.xml:100
dongsheng@627 7957 msgid "Using patterns to identify files"
dongsheng@630 7958 msgstr "使用模式标识文件"
dongsheng@627 7959
dongsheng@627 7960 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 7961 #: ../en/ch06-filenames.xml:102
dongsheng@627 7962 msgid ""
dongsheng@627 7963 "In addition to working with file and directory names, Mercurial lets you use "
dongsheng@627 7964 "<emphasis>patterns</emphasis> to identify files. Mercurial's pattern "
dongsheng@627 7965 "handling is expressive."
dongsheng@627 7966 msgstr ""
dongsheng@627 7967
dongsheng@627 7968 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 7969 #: ../en/ch06-filenames.xml:106
dongsheng@627 7970 msgid ""
dongsheng@627 7971 "On Unix-like systems (Linux, MacOS, etc.), the job of matching file names to "
dongsheng@627 7972 "patterns normally falls to the shell. On these systems, you must explicitly "
dongsheng@627 7973 "tell Mercurial that a name is a pattern. On Windows, the shell does not "
dongsheng@627 7974 "expand patterns, so Mercurial will automatically identify names that are "
dongsheng@627 7975 "patterns, and expand them for you."
dongsheng@627 7976 msgstr ""
dongsheng@627 7977
dongsheng@627 7978 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 7979 #: ../en/ch06-filenames.xml:113
dongsheng@627 7980 msgid ""
dongsheng@627 7981 "To provide a pattern in place of a regular name on the command line, the "
dongsheng@627 7982 "mechanism is simple:"
dongsheng@627 7983 msgstr ""
dongsheng@627 7984
dongsheng@627 7985 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 7986 #: ../en/ch06-filenames.xml:116
dongsheng@627 7987 msgid ""
dongsheng@627 7988 "That is, a pattern is identified by a short text string that says what kind "
dongsheng@627 7989 "of pattern this is, followed by a colon, followed by the actual pattern."
dongsheng@627 7990 msgstr ""
dongsheng@627 7991
dongsheng@627 7992 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 7993 #: ../en/ch06-filenames.xml:120
dongsheng@627 7994 msgid ""
dongsheng@627 7995 "Mercurial supports two kinds of pattern syntax. The most frequently used is "
dongsheng@627 7996 "called <literal>glob</literal>; this is the same kind of pattern matching "
dongsheng@627 7997 "used by the Unix shell, and should be familiar to Windows command prompt "
dongsheng@627 7998 "users, too."
dongsheng@627 7999 msgstr ""
dongsheng@627 8000
dongsheng@627 8001 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8002 #: ../en/ch06-filenames.xml:125
dongsheng@627 8003 msgid ""
dongsheng@627 8004 "When Mercurial does automatic pattern matching on Windows, it uses "
dongsheng@627 8005 "<literal>glob</literal> syntax. You can thus omit the <quote><literal>glob:</"
dongsheng@627 8006 "literal></quote> prefix on Windows, but it's safe to use it, too."
dongsheng@627 8007 msgstr ""
dongsheng@627 8008
dongsheng@627 8009 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8010 #: ../en/ch06-filenames.xml:130
dongsheng@627 8011 msgid ""
dongsheng@627 8012 "The <literal>re</literal> syntax is more powerful; it lets you specify "
dongsheng@627 8013 "patterns using regular expressions, also known as regexps."
dongsheng@627 8014 msgstr ""
dongsheng@627 8015
dongsheng@627 8016 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8017 #: ../en/ch06-filenames.xml:134
dongsheng@627 8018 msgid ""
dongsheng@627 8019 "By the way, in the examples that follow, notice that I'm careful to wrap all "
dongsheng@627 8020 "of my patterns in quote characters, so that they won't get expanded by the "
dongsheng@627 8021 "shell before Mercurial sees them."
dongsheng@627 8022 msgstr ""
dongsheng@627 8023
dongsheng@627 8024 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 8025 #: ../en/ch06-filenames.xml:140
dongsheng@627 8026 msgid "Shell-style <literal>glob</literal> patterns"
dongsheng@630 8027 msgstr "外壳风格的 <literal>glob</literal> 模式"
dongsheng@627 8028
dongsheng@627 8029 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 8030 #: ../en/ch06-filenames.xml:142
dongsheng@627 8031 msgid ""
dongsheng@627 8032 "This is an overview of the kinds of patterns you can use when you're matching "
dongsheng@627 8033 "on glob patterns."
dongsheng@627 8034 msgstr ""
dongsheng@627 8035
dongsheng@627 8036 #
dongsheng@627 8037 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 8038 #: ../en/ch06-filenames.xml:145
dongsheng@627 8039 msgid ""
dongsheng@627 8040 "The <quote><literal>*</literal></quote> character matches any string, within "
dongsheng@627 8041 "a single directory."
dongsheng@627 8042 msgstr ""
dongsheng@627 8043
dongsheng@627 8044 #
dongsheng@627 8045 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 8046 #: ../en/ch06-filenames.xml:150
dongsheng@627 8047 msgid ""
dongsheng@627 8048 "The <quote><literal>**</literal></quote> pattern matches any string, and "
dongsheng@627 8049 "crosses directory boundaries. It's not a standard Unix glob token, but it's "
dongsheng@627 8050 "accepted by several popular Unix shells, and is very useful."
dongsheng@627 8051 msgstr ""
dongsheng@627 8052
dongsheng@627 8053 #
dongsheng@627 8054 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 8055 #: ../en/ch06-filenames.xml:157
dongsheng@627 8056 msgid ""
dongsheng@627 8057 "The <quote><literal>?</literal></quote> pattern matches any single character."
dongsheng@627 8058 msgstr ""
dongsheng@627 8059
dongsheng@627 8060 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 8061 #: ../en/ch06-filenames.xml:162
dongsheng@627 8062 msgid ""
dongsheng@627 8063 "The <quote><literal>[</literal></quote> character begins a "
dongsheng@627 8064 "<emphasis>character class</emphasis>. This matches any single character "
dongsheng@627 8065 "within the class. The class ends with a <quote><literal>]</literal></quote> "
dongsheng@627 8066 "character. A class may contain multiple <emphasis>range</emphasis>s of the "
dongsheng@627 8067 "form <quote><literal>a-f</literal></quote>, which is shorthand for "
dongsheng@627 8068 "<quote><literal>abcdef</literal></quote>."
dongsheng@627 8069 msgstr ""
dongsheng@627 8070
dongsheng@627 8071 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 8072 #: ../en/ch06-filenames.xml:172
dongsheng@627 8073 msgid ""
dongsheng@627 8074 "If the first character after the <quote><literal>[</literal></quote> in a "
dongsheng@627 8075 "character class is a <quote><literal>!</literal></quote>, it "
dongsheng@627 8076 "<emphasis>negates</emphasis> the class, making it match any single character "
dongsheng@627 8077 "not in the class."
dongsheng@627 8078 msgstr ""
dongsheng@627 8079
dongsheng@627 8080 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 8081 #: ../en/ch06-filenames.xml:178
dongsheng@627 8082 msgid ""
dongsheng@627 8083 "A <quote><literal>{</literal></quote> begins a group of subpatterns, where "
dongsheng@627 8084 "the whole group matches if any subpattern in the group matches. The "
dongsheng@627 8085 "<quote><literal>,</literal></quote> character separates subpatterns, and "
dongsheng@627 8086 "<quote><literal>}</literal></quote> ends the group."
dongsheng@627 8087 msgstr ""
dongsheng@627 8088
dongsheng@627 8089 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
dongsheng@650 8090 #: ../en/ch06-filenames.xml:187
dongsheng@627 8091 msgid "Watch out!"
dongsheng@630 8092 msgstr "千万小心!"
dongsheng@627 8093
dongsheng@627 8094 #
dongsheng@627 8095 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 8096 #: ../en/ch06-filenames.xml:189
dongsheng@627 8097 msgid ""
dongsheng@627 8098 "Don't forget that if you want to match a pattern in any directory, you should "
dongsheng@627 8099 "not be using the <quote><literal>*</literal></quote> match-any token, as this "
dongsheng@627 8100 "will only match within one directory. Instead, use the <quote><literal>**</"
dongsheng@627 8101 "literal></quote> token. This small example illustrates the difference "
dongsheng@627 8102 "between the two."
dongsheng@627 8103 msgstr ""
dongsheng@627 8104
dongsheng@627 8105 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 8106 #: ../en/ch06-filenames.xml:201
dongsheng@627 8107 msgid "Regular expression matching with <literal>re</literal> patterns"
dongsheng@630 8108 msgstr "使用 <literal>re</literal> 模式的正则表达式匹配"
dongsheng@627 8109
dongsheng@627 8110 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 8111 #: ../en/ch06-filenames.xml:204
dongsheng@627 8112 msgid ""
dongsheng@627 8113 "Mercurial accepts the same regular expression syntax as the Python "
dongsheng@627 8114 "programming language (it uses Python's regexp engine internally). This is "
dongsheng@627 8115 "based on the Perl language's regexp syntax, which is the most popular dialect "
dongsheng@627 8116 "in use (it's also used in Java, for example)."
dongsheng@627 8117 msgstr ""
dongsheng@627 8118
dongsheng@627 8119 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 8120 #: ../en/ch06-filenames.xml:210
dongsheng@627 8121 msgid ""
dongsheng@627 8122 "I won't discuss Mercurial's regexp dialect in any detail here, as regexps are "
dongsheng@627 8123 "not often used. Perl-style regexps are in any case already exhaustively "
dongsheng@627 8124 "documented on a multitude of web sites, and in many books. Instead, I will "
dongsheng@627 8125 "focus here on a few things you should know if you find yourself needing to "
dongsheng@627 8126 "use regexps with Mercurial."
dongsheng@627 8127 msgstr ""
dongsheng@627 8128
dongsheng@627 8129 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 8130 #: ../en/ch06-filenames.xml:217
dongsheng@627 8131 msgid ""
dongsheng@627 8132 "A regexp is matched against an entire file name, relative to the root of the "
dongsheng@627 8133 "repository. In other words, even if you're already in subbdirectory "
dongsheng@627 8134 "<filename class=\"directory\">foo</filename>, if you want to match files "
dongsheng@627 8135 "under this directory, your pattern must start with <quote><literal>foo/</"
dongsheng@627 8136 "literal></quote>."
dongsheng@627 8137 msgstr ""
dongsheng@627 8138
dongsheng@627 8139 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 8140 #: ../en/ch06-filenames.xml:224
dongsheng@627 8141 msgid ""
dongsheng@627 8142 "One thing to note, if you're familiar with Perl-style regexps, is that "
dongsheng@627 8143 "Mercurial's are <emphasis>rooted</emphasis>. That is, a regexp starts "
dongsheng@627 8144 "matching against the beginning of a string; it doesn't look for a match "
dongsheng@627 8145 "anywhere within the string. To match anywhere in a string, start your "
dongsheng@627 8146 "pattern with <quote><literal>.*</literal></quote>."
dongsheng@627 8147 msgstr ""
dongsheng@627 8148
dongsheng@627 8149 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 8150 #: ../en/ch06-filenames.xml:234
dongsheng@627 8151 msgid "Filtering files"
dongsheng@630 8152 msgstr "过滤文件"
dongsheng@627 8153
dongsheng@627 8154 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8155 #: ../en/ch06-filenames.xml:236
dongsheng@627 8156 msgid ""
dongsheng@627 8157 "Not only does Mercurial give you a variety of ways to specify files; it lets "
dongsheng@627 8158 "you further winnow those files using <emphasis>filters</emphasis>. Commands "
dongsheng@627 8159 "that work with file names accept two filtering options."
dongsheng@627 8160 msgstr ""
dongsheng@627 8161
dongsheng@627 8162 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 8163 #: ../en/ch06-filenames.xml:241
dongsheng@627 8164 msgid ""
dongsheng@627 8165 "<option role=\"hg-opt-global\">-I</option>, or <option role=\"hg-opt-global"
dongsheng@627 8166 "\">--include</option>, lets you specify a pattern that file names must match "
dongsheng@627 8167 "in order to be processed."
dongsheng@627 8168 msgstr ""
dongsheng@627 8169
dongsheng@627 8170 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 8171 #: ../en/ch06-filenames.xml:246
dongsheng@627 8172 msgid ""
dongsheng@627 8173 "<option role=\"hg-opt-global\">-X</option>, or <option role=\"hg-opt-global"
dongsheng@627 8174 "\">--exclude</option>, gives you a way to <emphasis>avoid</emphasis> "
dongsheng@627 8175 "processing files, if they match this pattern."
dongsheng@627 8176 msgstr ""
dongsheng@627 8177
dongsheng@627 8178 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8179 #: ../en/ch06-filenames.xml:251
dongsheng@627 8180 msgid ""
dongsheng@627 8181 "You can provide multiple <option role=\"hg-opt-global\">-I</option> and "
dongsheng@627 8182 "<option role=\"hg-opt-global\">-X</option> options on the command line, and "
dongsheng@627 8183 "intermix them as you please. Mercurial interprets the patterns you provide "
dongsheng@627 8184 "using glob syntax by default (but you can use regexps if you need to)."
dongsheng@627 8185 msgstr ""
dongsheng@627 8186
dongsheng@627 8187 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8188 #: ../en/ch06-filenames.xml:258
dongsheng@627 8189 msgid ""
dongsheng@627 8190 "You can read a <option role=\"hg-opt-global\">-I</option> filter as "
dongsheng@627 8191 "<quote>process only the files that match this filter</quote>."
dongsheng@627 8192 msgstr ""
dongsheng@627 8193
dongsheng@627 8194 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8195 #: ../en/ch06-filenames.xml:264
dongsheng@627 8196 msgid ""
dongsheng@627 8197 "The <option role=\"hg-opt-global\">-X</option> filter is best read as "
dongsheng@627 8198 "<quote>process only the files that don't match this pattern</quote>."
dongsheng@627 8199 msgstr ""
dongsheng@627 8200
dongsheng@627 8201 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 8202 #: ../en/ch06-filenames.xml:272
songdongsheng@710 8203 #, fuzzy
songdongsheng@710 8204 msgid "Permanently ignoring unwanted files and directories"
dongsheng@630 8205 msgstr "忽略不需要的文件和目录"
dongsheng@627 8206
dongsheng@627 8207 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8208 #: ../en/ch06-filenames.xml:274
songdongsheng@710 8209 msgid ""
songdongsheng@710 8210 "When you create a new repository, the chances are that over time it will grow "
songdongsheng@710 8211 "to contain files that ought to <emphasis>not</emphasis> be managed by "
songdongsheng@710 8212 "Mercurial, but which you don't want to see listed every time you run "
songdongsheng@710 8213 "<command>hg status</command>. For instance, <quote>build products</quote> "
songdongsheng@710 8214 "are files that are created as part of a build but which should not be managed "
songdongsheng@710 8215 "by a revision control system. The most common build products are output "
songdongsheng@710 8216 "files produced by software tools such as compilers. As another example, many "
songdongsheng@710 8217 "text editors litter a directory with lock files, temporary working files, and "
songdongsheng@710 8218 "backup files, which it also makes no sense to manage."
songdongsheng@710 8219 msgstr ""
songdongsheng@710 8220
songdongsheng@710 8221 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 8222 #: ../en/ch06-filenames.xml:286
songdongsheng@710 8223 msgid ""
songdongsheng@710 8224 "To have Mercurial permanently ignore such files, create a file named "
songdongsheng@710 8225 "<filename>.hgignore</filename> in the root of your repository. You "
songdongsheng@710 8226 "<emphasis>should</emphasis> <command>hg add</command> this file so that it "
songdongsheng@710 8227 "gets tracked with the rest of your repository contents, since your "
songdongsheng@710 8228 "collaborators will probably find it useful too."
songdongsheng@710 8229 msgstr ""
songdongsheng@710 8230
songdongsheng@710 8231 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 8232 #: ../en/ch06-filenames.xml:293
songdongsheng@710 8233 msgid ""
songdongsheng@710 8234 "By default, the <filename>.hgignore</filename> file should contain a list of "
songdongsheng@710 8235 "regular expressions, one per line. Empty lines are skipped. Most people "
songdongsheng@710 8236 "prefer to describe the files they want to ignore using the <quote>glob</"
songdongsheng@710 8237 "quote> syntax that we described above, so a typical <filename>.hgignore</"
songdongsheng@710 8238 "filename> file will start with this directive:"
songdongsheng@710 8239 msgstr ""
songdongsheng@710 8240
songdongsheng@710 8241 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 8242 #: ../en/ch06-filenames.xml:302
songdongsheng@710 8243 msgid ""
songdongsheng@710 8244 "This tells Mercurial to interpret the lines that follow as glob patterns, not "
songdongsheng@710 8245 "regular expressions."
songdongsheng@710 8246 msgstr ""
songdongsheng@710 8247
songdongsheng@710 8248 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 8249 #: ../en/ch06-filenames.xml:305
songdongsheng@710 8250 msgid "Here is a typical-looking <filename>.hgignore</filename> file."
dongsheng@627 8251 msgstr ""
dongsheng@627 8252
dongsheng@627 8253 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@710 8254 #: ../en/ch06-filenames.xml:329
dongsheng@627 8255 msgid "Case sensitivity"
dongsheng@630 8256 msgstr "大小写敏感性"
dongsheng@627 8257
dongsheng@627 8258 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 8259 #: ../en/ch06-filenames.xml:331
dongsheng@627 8260 msgid ""
dongsheng@627 8261 "If you're working in a mixed development environment that contains both Linux "
dongsheng@627 8262 "(or other Unix) systems and Macs or Windows systems, you should keep in the "
dongsheng@627 8263 "back of your mind the knowledge that they treat the case (<quote>N</quote> "
dongsheng@627 8264 "versus <quote>n</quote>) of file names in incompatible ways. This is not "
dongsheng@627 8265 "very likely to affect you, and it's easy to deal with if it does, but it "
dongsheng@627 8266 "could surprise you if you don't know about it."
dongsheng@627 8267 msgstr ""
dongsheng@627 8268
dongsheng@627 8269 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 8270 #: ../en/ch06-filenames.xml:340
dongsheng@627 8271 msgid ""
dongsheng@627 8272 "Operating systems and filesystems differ in the way they handle the "
dongsheng@627 8273 "<emphasis>case</emphasis> of characters in file and directory names. There "
dongsheng@627 8274 "are three common ways to handle case in names."
dongsheng@627 8275 msgstr ""
dongsheng@627 8276
dongsheng@627 8277 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@710 8278 #: ../en/ch06-filenames.xml:345
dongsheng@627 8279 msgid ""
dongsheng@627 8280 "Completely case insensitive. Uppercase and lowercase versions of a letter "
dongsheng@627 8281 "are treated as identical, both when creating a file and during subsequent "
dongsheng@627 8282 "accesses. This is common on older DOS-based systems."
dongsheng@627 8283 msgstr ""
dongsheng@627 8284
dongsheng@627 8285 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@710 8286 #: ../en/ch06-filenames.xml:350
dongsheng@627 8287 msgid ""
dongsheng@627 8288 "Case preserving, but insensitive. When a file or directory is created, the "
dongsheng@627 8289 "case of its name is stored, and can be retrieved and displayed by the "
dongsheng@627 8290 "operating system. When an existing file is being looked up, its case is "
dongsheng@627 8291 "ignored. This is the standard arrangement on Windows and MacOS. The names "
dongsheng@627 8292 "<filename>foo</filename> and <filename>FoO</filename> identify the same "
dongsheng@627 8293 "file. This treatment of uppercase and lowercase letters as interchangeable "
dongsheng@627 8294 "is also referred to as <emphasis>case folding</emphasis>."
dongsheng@627 8295 msgstr ""
dongsheng@627 8296
dongsheng@627 8297 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@710 8298 #: ../en/ch06-filenames.xml:361
dongsheng@627 8299 msgid ""
dongsheng@627 8300 "Case sensitive. The case of a name is significant at all times. The names "
dongsheng@627 8301 "<filename>foo</filename> and {FoO} identify different files. This is the way "
dongsheng@627 8302 "Linux and Unix systems normally work."
dongsheng@627 8303 msgstr ""
dongsheng@627 8304
dongsheng@627 8305 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@710 8306 #: ../en/ch06-filenames.xml:367
dongsheng@627 8307 msgid ""
dongsheng@627 8308 "On Unix-like systems, it is possible to have any or all of the above ways of "
dongsheng@627 8309 "handling case in action at once. For example, if you use a USB thumb drive "
dongsheng@627 8310 "formatted with a FAT32 filesystem on a Linux system, Linux will handle names "
dongsheng@627 8311 "on that filesystem in a case preserving, but insensitive, way."
dongsheng@627 8312 msgstr ""
dongsheng@627 8313
dongsheng@627 8314 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 8315 #: ../en/ch06-filenames.xml:374
dongsheng@627 8316 msgid "Safe, portable repository storage"
dongsheng@630 8317 msgstr "安全,可移植的版本库存储"
dongsheng@627 8318
dongsheng@627 8319 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 8320 #: ../en/ch06-filenames.xml:376
dongsheng@627 8321 msgid ""
dongsheng@627 8322 "Mercurial's repository storage mechanism is <emphasis>case safe</emphasis>. "
dongsheng@627 8323 "It translates file names so that they can be safely stored on both case "
dongsheng@627 8324 "sensitive and case insensitive filesystems. This means that you can use "
dongsheng@627 8325 "normal file copying tools to transfer a Mercurial repository onto, for "
dongsheng@627 8326 "example, a USB thumb drive, and safely move that drive and repository back "
dongsheng@627 8327 "and forth between a Mac, a PC running Windows, and a Linux box."
dongsheng@627 8328 msgstr ""
dongsheng@627 8329
dongsheng@627 8330 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 8331 #: ../en/ch06-filenames.xml:387
dongsheng@627 8332 msgid "Detecting case conflicts"
dongsheng@630 8333 msgstr "检测大小写冲突"
dongsheng@627 8334
dongsheng@627 8335 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 8336 #: ../en/ch06-filenames.xml:389
dongsheng@627 8337 msgid ""
dongsheng@627 8338 "When operating in the working directory, Mercurial honours the naming policy "
dongsheng@627 8339 "of the filesystem where the working directory is located. If the filesystem "
dongsheng@627 8340 "is case preserving, but insensitive, Mercurial will treat names that differ "
dongsheng@627 8341 "only in case as the same."
dongsheng@627 8342 msgstr ""
dongsheng@627 8343
dongsheng@627 8344 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 8345 #: ../en/ch06-filenames.xml:395
dongsheng@627 8346 msgid ""
dongsheng@627 8347 "An important aspect of this approach is that it is possible to commit a "
dongsheng@627 8348 "changeset on a case sensitive (typically Linux or Unix) filesystem that will "
dongsheng@627 8349 "cause trouble for users on case insensitive (usually Windows and MacOS) "
dongsheng@627 8350 "users. If a Linux user commits changes to two files, one named "
dongsheng@627 8351 "<filename>myfile.c</filename> and the other named <filename>MyFile.C</"
dongsheng@627 8352 "filename>, they will be stored correctly in the repository. And in the "
dongsheng@627 8353 "working directories of other Linux users, they will be correctly represented "
dongsheng@627 8354 "as separate files."
dongsheng@627 8355 msgstr ""
dongsheng@627 8356
dongsheng@627 8357 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 8358 #: ../en/ch06-filenames.xml:406
dongsheng@627 8359 msgid ""
dongsheng@627 8360 "If a Windows or Mac user pulls this change, they will not initially have a "
dongsheng@627 8361 "problem, because Mercurial's repository storage mechanism is case safe. "
dongsheng@627 8362 "However, once they try to <command role=\"hg-cmd\">hg update</command> the "
dongsheng@627 8363 "working directory to that changeset, or <command role=\"hg-cmd\">hg merge</"
dongsheng@627 8364 "command> with that changeset, Mercurial will spot the conflict between the "
dongsheng@627 8365 "two file names that the filesystem would treat as the same, and forbid the "
dongsheng@627 8366 "update or merge from occurring."
dongsheng@627 8367 msgstr ""
dongsheng@627 8368
dongsheng@627 8369 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@710 8370 #: ../en/ch06-filenames.xml:418
dongsheng@627 8371 msgid "Fixing a case conflict"
dongsheng@630 8372 msgstr "修正大小写冲突"
dongsheng@627 8373
dongsheng@627 8374 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 8375 #: ../en/ch06-filenames.xml:420
dongsheng@627 8376 msgid ""
dongsheng@627 8377 "If you are using Windows or a Mac in a mixed environment where some of your "
dongsheng@627 8378 "collaborators are using Linux or Unix, and Mercurial reports a case folding "
dongsheng@627 8379 "conflict when you try to <command role=\"hg-cmd\">hg update</command> or "
dongsheng@627 8380 "<command role=\"hg-cmd\">hg merge</command>, the procedure to fix the problem "
dongsheng@627 8381 "is simple."
dongsheng@627 8382 msgstr ""
dongsheng@627 8383
dongsheng@627 8384 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 8385 #: ../en/ch06-filenames.xml:427
dongsheng@627 8386 msgid ""
dongsheng@627 8387 "Just find a nearby Linux or Unix box, clone the problem repository onto it, "
dongsheng@627 8388 "and use Mercurial's <command role=\"hg-cmd\">hg rename</command> command to "
dongsheng@627 8389 "change the names of any offending files or directories so that they will no "
dongsheng@627 8390 "longer cause case folding conflicts. Commit this change, <command role=\"hg-"
dongsheng@627 8391 "cmd\">hg pull</command> or <command role=\"hg-cmd\">hg push</command> it "
dongsheng@627 8392 "across to your Windows or MacOS system, and <command role=\"hg-cmd\">hg "
dongsheng@627 8393 "update</command> to the revision with the non-conflicting names."
dongsheng@627 8394 msgstr ""
dongsheng@627 8395
dongsheng@627 8396 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@710 8397 #: ../en/ch06-filenames.xml:437
dongsheng@627 8398 msgid ""
dongsheng@627 8399 "The changeset with case-conflicting names will remain in your project's "
dongsheng@627 8400 "history, and you still won't be able to <command role=\"hg-cmd\">hg update</"
dongsheng@627 8401 "command> your working directory to that changeset on a Windows or MacOS "
dongsheng@627 8402 "system, but you can continue development unimpeded."
dongsheng@627 8403 msgstr ""
dongsheng@627 8404
dongsheng@627 8405 #. type: Content of: <book><chapter><title>
dongsheng@650 8406 #: ../en/ch07-branch.xml:5
dongsheng@627 8407 msgid "Managing releases and branchy development"
dongsheng@627 8408 msgstr "发布管理与分支开发"
dongsheng@627 8409
dongsheng@627 8410 #. type: Content of: <book><chapter><para>
dongsheng@650 8411 #: ../en/ch07-branch.xml:7
dongsheng@627 8412 msgid ""
dongsheng@627 8413 "Mercurial provides several mechanisms for you to manage a project that is "
dongsheng@627 8414 "making progress on multiple fronts at once. To understand these mechanisms, "
dongsheng@627 8415 "let's first take a brief look at a fairly normal software project structure."
dongsheng@627 8416 msgstr ""
dongsheng@627 8417
dongsheng@627 8418 #. type: Content of: <book><chapter><para>
dongsheng@650 8419 #: ../en/ch07-branch.xml:12
dongsheng@627 8420 msgid ""
dongsheng@627 8421 "Many software projects issue periodic <quote>major</quote> releases that "
dongsheng@627 8422 "contain substantial new features. In parallel, they may issue <quote>minor</"
dongsheng@627 8423 "quote> releases. These are usually identical to the major releases off which "
dongsheng@627 8424 "they're based, but with a few bugs fixed."
dongsheng@627 8425 msgstr ""
dongsheng@627 8426
dongsheng@627 8427 #. type: Content of: <book><chapter><para>
dongsheng@650 8428 #: ../en/ch07-branch.xml:18
dongsheng@627 8429 msgid ""
dongsheng@627 8430 "In this chapter, we'll start by talking about how to keep records of project "
dongsheng@627 8431 "milestones such as releases. We'll then continue on to talk about the flow "
dongsheng@627 8432 "of work between different phases of a project, and how Mercurial can help you "
dongsheng@627 8433 "to isolate and manage this work."
dongsheng@627 8434 msgstr ""
dongsheng@627 8435
dongsheng@627 8436 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 8437 #: ../en/ch07-branch.xml:25
dongsheng@627 8438 msgid "Giving a persistent name to a revision"
dongsheng@635 8439 msgstr "给版本指定一个永久的名称"
dongsheng@627 8440
dongsheng@627 8441 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8442 #: ../en/ch07-branch.xml:27
dongsheng@627 8443 msgid ""
dongsheng@627 8444 "Once you decide that you'd like to call a particular revision a "
dongsheng@627 8445 "<quote>release</quote>, it's a good idea to record the identity of that "
dongsheng@627 8446 "revision. This will let you reproduce that release at a later date, for "
dongsheng@627 8447 "whatever purpose you might need at the time (reproducing a bug, porting to a "
dongsheng@627 8448 "new platform, etc). &interaction.tag.init;"
dongsheng@627 8449 msgstr ""
dongsheng@627 8450
dongsheng@627 8451 #
dongsheng@627 8452 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8453 #: ../en/ch07-branch.xml:34
dongsheng@627 8454 msgid ""
dongsheng@627 8455 "Mercurial lets you give a permanent name to any revision using the <command "
dongsheng@627 8456 "role=\"hg-cmd\">hg tag</command> command. Not surprisingly, these names are "
dongsheng@627 8457 "called <quote>tags</quote>."
dongsheng@627 8458 msgstr ""
dongsheng@627 8459
dongsheng@627 8460 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8461 #: ../en/ch07-branch.xml:40
dongsheng@627 8462 msgid ""
dongsheng@627 8463 "A tag is nothing more than a <quote>symbolic name</quote> for a revision. "
dongsheng@627 8464 "Tags exist purely for your convenience, so that you have a handy permanent "
dongsheng@627 8465 "way to refer to a revision; Mercurial doesn't interpret the tag names you use "
dongsheng@627 8466 "in any way. Neither does Mercurial place any restrictions on the name of a "
dongsheng@627 8467 "tag, beyond a few that are necessary to ensure that a tag can be parsed "
dongsheng@627 8468 "unambiguously. A tag name cannot contain any of the following characters:"
dongsheng@627 8469 msgstr ""
dongsheng@627 8470
dongsheng@627 8471 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 8472 #: ../en/ch07-branch.xml:49
dongsheng@627 8473 msgid "Colon (ASCII 58, <quote><literal>:</literal></quote>)"
dongsheng@627 8474 msgstr ""
dongsheng@627 8475
dongsheng@627 8476 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 8477 #: ../en/ch07-branch.xml:52
dongsheng@627 8478 msgid "Carriage return (ASCII 13, <quote><literal>\\r</literal></quote>)"
dongsheng@627 8479 msgstr ""
dongsheng@627 8480
dongsheng@627 8481 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 8482 #: ../en/ch07-branch.xml:55
dongsheng@627 8483 msgid "Newline (ASCII 10, <quote><literal>\\n</literal></quote>)"
dongsheng@627 8484 msgstr ""
dongsheng@627 8485
dongsheng@627 8486 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8487 #: ../en/ch07-branch.xml:59
dongsheng@627 8488 msgid ""
dongsheng@627 8489 "You can use the <command role=\"hg-cmd\">hg tags</command> command to display "
dongsheng@627 8490 "the tags present in your repository. In the output, each tagged revision is "
dongsheng@627 8491 "identified first by its name, then by revision number, and finally by the "
dongsheng@627 8492 "unique hash of the revision."
dongsheng@627 8493 msgstr ""
dongsheng@627 8494
dongsheng@627 8495 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8496 #: ../en/ch07-branch.xml:67
dongsheng@627 8497 msgid ""
dongsheng@627 8498 "Notice that <literal>tip</literal> is listed in the output of <command role="
dongsheng@627 8499 "\"hg-cmd\">hg tags</command>. The <literal>tip</literal> tag is a special "
dongsheng@627 8500 "<quote>floating</quote> tag, which always identifies the newest revision in "
dongsheng@627 8501 "the repository."
dongsheng@627 8502 msgstr ""
dongsheng@627 8503
dongsheng@627 8504 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8505 #: ../en/ch07-branch.xml:73
dongsheng@627 8506 msgid ""
dongsheng@627 8507 "In the output of the <command role=\"hg-cmd\">hg tags</command> command, tags "
dongsheng@627 8508 "are listed in reverse order, by revision number. This usually means that "
dongsheng@627 8509 "recent tags are listed before older tags. It also means that <literal>tip</"
dongsheng@627 8510 "literal> is always going to be the first tag listed in the output of <command "
dongsheng@627 8511 "role=\"hg-cmd\">hg tags</command>."
dongsheng@627 8512 msgstr ""
dongsheng@627 8513
dongsheng@627 8514 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8515 #: ../en/ch07-branch.xml:80
dongsheng@627 8516 msgid ""
dongsheng@627 8517 "When you run <command role=\"hg-cmd\">hg log</command>, if it displays a "
dongsheng@627 8518 "revision that has tags associated with it, it will print those tags."
dongsheng@627 8519 msgstr ""
dongsheng@627 8520
dongsheng@627 8521 #
dongsheng@627 8522 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8523 #: ../en/ch07-branch.xml:86
dongsheng@627 8524 msgid ""
dongsheng@627 8525 "Any time you need to provide a revision ID to a Mercurial command, the "
dongsheng@627 8526 "command will accept a tag name in its place. Internally, Mercurial will "
dongsheng@627 8527 "translate your tag name into the corresponding revision ID, then use that."
dongsheng@627 8528 msgstr ""
dongsheng@627 8529
dongsheng@627 8530 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8531 #: ../en/ch07-branch.xml:93
dongsheng@627 8532 msgid ""
dongsheng@627 8533 "There's no limit on the number of tags you can have in a repository, or on "
dongsheng@627 8534 "the number of tags that a single revision can have. As a practical matter, "
dongsheng@627 8535 "it's not a great idea to have <quote>too many</quote> (a number which will "
dongsheng@627 8536 "vary from project to project), simply because tags are supposed to help you "
dongsheng@627 8537 "to find revisions. If you have lots of tags, the ease of using them to "
dongsheng@627 8538 "identify revisions diminishes rapidly."
dongsheng@627 8539 msgstr ""
dongsheng@627 8540
dongsheng@627 8541 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8542 #: ../en/ch07-branch.xml:101
dongsheng@627 8543 msgid ""
dongsheng@627 8544 "For example, if your project has milestones as frequent as every few days, "
dongsheng@627 8545 "it's perfectly reasonable to tag each one of those. But if you have a "
dongsheng@627 8546 "continuous build system that makes sure every revision can be built cleanly, "
dongsheng@627 8547 "you'd be introducing a lot of noise if you were to tag every clean build. "
dongsheng@627 8548 "Instead, you could tag failed builds (on the assumption that they're rare!), "
dongsheng@627 8549 "or simply not use tags to track buildability."
dongsheng@627 8550 msgstr ""
dongsheng@627 8551
dongsheng@627 8552 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8553 #: ../en/ch07-branch.xml:109
dongsheng@627 8554 msgid ""
dongsheng@627 8555 "If you want to remove a tag that you no longer want, use <command role=\"hg-"
dongsheng@627 8556 "cmd\">hg tag --remove</command>."
dongsheng@627 8557 msgstr ""
dongsheng@627 8558
dongsheng@627 8559 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8560 #: ../en/ch07-branch.xml:114
dongsheng@627 8561 msgid ""
dongsheng@627 8562 "You can also modify a tag at any time, so that it identifies a different "
dongsheng@627 8563 "revision, by simply issuing a new <command role=\"hg-cmd\">hg tag</command> "
dongsheng@627 8564 "command. You'll have to use the <option role=\"hg-opt-tag\">-f</option> "
dongsheng@627 8565 "option to tell Mercurial that you <emphasis>really</emphasis> want to update "
dongsheng@627 8566 "the tag."
dongsheng@627 8567 msgstr ""
dongsheng@627 8568
dongsheng@627 8569 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8570 #: ../en/ch07-branch.xml:123
dongsheng@627 8571 msgid ""
dongsheng@627 8572 "There will still be a permanent record of the previous identity of the tag, "
dongsheng@627 8573 "but Mercurial will no longer use it. There's thus no penalty to tagging the "
dongsheng@627 8574 "wrong revision; all you have to do is turn around and tag the correct "
dongsheng@627 8575 "revision once you discover your error."
dongsheng@627 8576 msgstr ""
dongsheng@627 8577
dongsheng@627 8578 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8579 #: ../en/ch07-branch.xml:129
dongsheng@627 8580 msgid ""
dongsheng@627 8581 "Mercurial stores tags in a normal revision-controlled file in your "
songdongsheng@710 8582 "repository. If you've created any tags, you'll find them in a file in the "
songdongsheng@710 8583 "root of your repository named <filename role=\"special\">.hgtags</filename>. "
songdongsheng@710 8584 "When you run the <command role=\"hg-cmd\">hg tag</command> command, Mercurial "
songdongsheng@710 8585 "modifies this file, then automatically commits the change to it. This means "
songdongsheng@710 8586 "that every time you run <command role=\"hg-cmd\">hg tag</command>, you'll see "
songdongsheng@710 8587 "a corresponding changeset in the output of <command role=\"hg-cmd\">hg log</"
songdongsheng@710 8588 "command>."
dongsheng@627 8589 msgstr ""
dongsheng@627 8590
dongsheng@627 8591 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 8592 #: ../en/ch07-branch.xml:142
dongsheng@627 8593 msgid "Handling tag conflicts during a merge"
dongsheng@635 8594 msgstr "在合并期间处理标签冲突"
dongsheng@627 8595
dongsheng@627 8596 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 8597 #: ../en/ch07-branch.xml:144
dongsheng@627 8598 msgid ""
dongsheng@627 8599 "You won't often need to care about the <filename role=\"special\">.hgtags</"
dongsheng@627 8600 "filename> file, but it sometimes makes its presence known during a merge. "
dongsheng@627 8601 "The format of the file is simple: it consists of a series of lines. Each "
dongsheng@627 8602 "line starts with a changeset hash, followed by a space, followed by the name "
dongsheng@627 8603 "of a tag."
dongsheng@627 8604 msgstr ""
dongsheng@627 8605
dongsheng@627 8606 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 8607 #: ../en/ch07-branch.xml:151
dongsheng@627 8608 msgid ""
dongsheng@627 8609 "If you're resolving a conflict in the <filename role=\"special\">.hgtags</"
dongsheng@627 8610 "filename> file during a merge, there's one twist to modifying the <filename "
dongsheng@627 8611 "role=\"special\">.hgtags</filename> file: when Mercurial is parsing the tags "
dongsheng@627 8612 "in a repository, it <emphasis>never</emphasis> reads the working copy of the "
dongsheng@627 8613 "<filename role=\"special\">.hgtags</filename> file. Instead, it reads the "
dongsheng@627 8614 "<emphasis>most recently committed</emphasis> revision of the file."
dongsheng@627 8615 msgstr ""
dongsheng@627 8616
dongsheng@627 8617 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 8618 #: ../en/ch07-branch.xml:161
dongsheng@627 8619 msgid ""
dongsheng@627 8620 "An unfortunate consequence of this design is that you can't actually verify "
dongsheng@627 8621 "that your merged <filename role=\"special\">.hgtags</filename> file is "
dongsheng@627 8622 "correct until <emphasis>after</emphasis> you've committed a change. So if "
dongsheng@627 8623 "you find yourself resolving a conflict on <filename role=\"special\">.hgtags</"
dongsheng@627 8624 "filename> during a merge, be sure to run <command role=\"hg-cmd\">hg tags</"
dongsheng@627 8625 "command> after you commit. If it finds an error in the <filename role="
dongsheng@627 8626 "\"special\">.hgtags</filename> file, it will report the location of the "
dongsheng@627 8627 "error, which you can then fix and commit. You should then run <command role="
dongsheng@627 8628 "\"hg-cmd\">hg tags</command> again, just to be sure that your fix is correct."
dongsheng@627 8629 msgstr ""
dongsheng@627 8630
dongsheng@627 8631 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 8632 #: ../en/ch07-branch.xml:176
dongsheng@627 8633 msgid "Tags and cloning"
dongsheng@635 8634 msgstr "标签与克隆"
dongsheng@627 8635
dongsheng@627 8636 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 8637 #: ../en/ch07-branch.xml:178
dongsheng@627 8638 msgid ""
dongsheng@627 8639 "You may have noticed that the <command role=\"hg-cmd\">hg clone</command> "
dongsheng@627 8640 "command has a <option role=\"hg-opt-clone\">-r</option> option that lets you "
dongsheng@627 8641 "clone an exact copy of the repository as of a particular changeset. The new "
dongsheng@627 8642 "clone will not contain any project history that comes after the revision you "
dongsheng@627 8643 "specified. This has an interaction with tags that can surprise the unwary."
dongsheng@627 8644 msgstr ""
dongsheng@627 8645
dongsheng@627 8646 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 8647 #: ../en/ch07-branch.xml:186
dongsheng@627 8648 msgid ""
dongsheng@627 8649 "Recall that a tag is stored as a revision to the <filename role=\"special\">."
dongsheng@627 8650 "hgtags</filename> file, so that when you create a tag, the changeset in which "
dongsheng@627 8651 "it's recorded necessarily refers to an older changeset. When you run "
dongsheng@627 8652 "<command role=\"hg-cmd\">hg clone -r foo</command> to clone a repository as "
dongsheng@627 8653 "of tag <literal>foo</literal>, the new clone <emphasis>will not contain the "
dongsheng@627 8654 "history that created the tag</emphasis> that you used to clone the "
dongsheng@627 8655 "repository. The result is that you'll get exactly the right subset of the "
dongsheng@627 8656 "project's history in the new repository, but <emphasis>not</emphasis> the tag "
dongsheng@627 8657 "you might have expected."
dongsheng@627 8658 msgstr ""
dongsheng@627 8659
dongsheng@627 8660 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 8661 #: ../en/ch07-branch.xml:201
dongsheng@627 8662 msgid "When permanent tags are too much"
dongsheng@635 8663 msgstr "当永久标签太多的时候"
dongsheng@627 8664
dongsheng@627 8665 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 8666 #: ../en/ch07-branch.xml:203
dongsheng@627 8667 msgid ""
dongsheng@627 8668 "Since Mercurial's tags are revision controlled and carried around with a "
dongsheng@627 8669 "project's history, everyone you work with will see the tags you create. But "
dongsheng@627 8670 "giving names to revisions has uses beyond simply noting that revision "
dongsheng@627 8671 "<literal>4237e45506ee</literal> is really <literal>v2.0.2</literal>. If "
dongsheng@627 8672 "you're trying to track down a subtle bug, you might want a tag to remind you "
dongsheng@627 8673 "of something like <quote>Anne saw the symptoms with this revision</quote>."
dongsheng@627 8674 msgstr ""
dongsheng@627 8675
dongsheng@627 8676 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 8677 #: ../en/ch07-branch.xml:213
dongsheng@627 8678 msgid ""
dongsheng@627 8679 "For cases like this, what you might want to use are <emphasis>local</"
dongsheng@627 8680 "emphasis> tags. You can create a local tag with the <option role=\"hg-opt-tag"
dongsheng@627 8681 "\">-l</option> option to the <command role=\"hg-cmd\">hg tag</command> "
dongsheng@627 8682 "command. This will store the tag in a file called <filename role=\"special"
dongsheng@627 8683 "\">.hg/localtags</filename>. Unlike <filename role=\"special\">.hgtags</"
dongsheng@627 8684 "filename>, <filename role=\"special\">.hg/localtags</filename> is not "
dongsheng@627 8685 "revision controlled. Any tags you create using <option role=\"hg-opt-tag\">-"
dongsheng@627 8686 "l</option> remain strictly local to the repository you're currently working "
dongsheng@627 8687 "in."
dongsheng@627 8688 msgstr ""
dongsheng@627 8689
dongsheng@627 8690 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 8691 #: ../en/ch07-branch.xml:228
songdongsheng@668 8692 msgid "The flow of changes&emdash;big picture vs. little"
dongsheng@661 8693 msgstr "修改流程—宏观与微观"
dongsheng@627 8694
dongsheng@627 8695 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8696 #: ../en/ch07-branch.xml:230
dongsheng@627 8697 msgid ""
dongsheng@627 8698 "To return to the outline I sketched at the beginning of a chapter, let's "
dongsheng@627 8699 "think about a project that has multiple concurrent pieces of work under "
dongsheng@627 8700 "development at once."
dongsheng@627 8701 msgstr ""
dongsheng@627 8702
dongsheng@627 8703 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8704 #: ../en/ch07-branch.xml:234
dongsheng@627 8705 msgid ""
dongsheng@627 8706 "There might be a push for a new <quote>main</quote> release; a new minor "
dongsheng@627 8707 "bugfix release to the last main release; and an unexpected <quote>hot fix</"
dongsheng@627 8708 "quote> to an old release that is now in maintenance mode."
dongsheng@627 8709 msgstr ""
dongsheng@627 8710
dongsheng@627 8711 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8712 #: ../en/ch07-branch.xml:239
dongsheng@627 8713 msgid ""
dongsheng@627 8714 "The usual way people refer to these different concurrent directions of "
dongsheng@627 8715 "development is as <quote>branches</quote>. However, we've already seen "
dongsheng@627 8716 "numerous times that Mercurial treats <emphasis>all of history</emphasis> as a "
dongsheng@627 8717 "series of branches and merges. Really, what we have here is two ideas that "
dongsheng@627 8718 "are peripherally related, but which happen to share a name."
dongsheng@627 8719 msgstr ""
dongsheng@627 8720
dongsheng@627 8721 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 8722 #: ../en/ch07-branch.xml:246
dongsheng@627 8723 msgid ""
dongsheng@627 8724 "<quote>Big picture</quote> branches represent the sweep of a project's "
dongsheng@627 8725 "evolution; people give them names, and talk about them in conversation."
dongsheng@627 8726 msgstr ""
dongsheng@627 8727
dongsheng@627 8728 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 8729 #: ../en/ch07-branch.xml:250
dongsheng@627 8730 msgid ""
dongsheng@627 8731 "<quote>Little picture</quote> branches are artefacts of the day-to-day "
dongsheng@627 8732 "activity of developing and merging changes. They expose the narrative of how "
dongsheng@627 8733 "the code was developed."
dongsheng@627 8734 msgstr ""
dongsheng@627 8735
dongsheng@627 8736 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 8737 #: ../en/ch07-branch.xml:258
dongsheng@627 8738 msgid "Managing big-picture branches in repositories"
dongsheng@635 8739 msgstr "在版本库中管理分支"
dongsheng@627 8740
dongsheng@627 8741 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8742 #: ../en/ch07-branch.xml:260
dongsheng@627 8743 msgid ""
dongsheng@627 8744 "The easiest way to isolate a <quote>big picture</quote> branch in Mercurial "
songdongsheng@668 8745 "is in a dedicated repository. If you have an existing shared "
songdongsheng@668 8746 "repository&emdash;let's call it <literal>myproject</literal>&emdash;that "
songdongsheng@668 8747 "reaches a <quote>1.0</quote> milestone, you can start to prepare for future "
songdongsheng@668 8748 "maintenance releases on top of version 1.0 by tagging the revision from which "
songdongsheng@668 8749 "you prepared the 1.0 release."
dongsheng@627 8750 msgstr ""
dongsheng@627 8751
dongsheng@627 8752 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8753 #: ../en/ch07-branch.xml:270
dongsheng@627 8754 msgid ""
dongsheng@627 8755 "You can then clone a new shared <literal>myproject-1.0.1</literal> repository "
dongsheng@627 8756 "as of that tag."
dongsheng@627 8757 msgstr ""
dongsheng@627 8758
dongsheng@627 8759 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8760 #: ../en/ch07-branch.xml:276
dongsheng@627 8761 msgid ""
dongsheng@627 8762 "Afterwards, if someone needs to work on a bug fix that ought to go into an "
dongsheng@627 8763 "upcoming 1.0.1 minor release, they clone the <literal>myproject-1.0.1</"
dongsheng@627 8764 "literal> repository, make their changes, and push them back."
dongsheng@627 8765 msgstr ""
dongsheng@627 8766
dongsheng@627 8767 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8768 #: ../en/ch07-branch.xml:283
dongsheng@627 8769 msgid ""
dongsheng@627 8770 "Meanwhile, development for the next major release can continue, isolated and "
dongsheng@627 8771 "unabated, in the <literal>myproject</literal> repository."
dongsheng@627 8772 msgstr ""
dongsheng@627 8773
dongsheng@627 8774 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 8775 #: ../en/ch07-branch.xml:291
dongsheng@627 8776 msgid "Don't repeat yourself: merging across branches"
dongsheng@635 8777 msgstr "不要重复劳动:在分支间合并"
dongsheng@627 8778
dongsheng@627 8779 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8780 #: ../en/ch07-branch.xml:293
dongsheng@627 8781 msgid ""
dongsheng@627 8782 "In many cases, if you have a bug to fix on a maintenance branch, the chances "
dongsheng@627 8783 "are good that the bug exists on your project's main branch (and possibly "
dongsheng@627 8784 "other maintenance branches, too). It's a rare developer who wants to fix the "
dongsheng@627 8785 "same bug multiple times, so let's look at a few ways that Mercurial can help "
dongsheng@627 8786 "you to manage these bugfixes without duplicating your work."
dongsheng@627 8787 msgstr ""
dongsheng@627 8788
dongsheng@627 8789 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8790 #: ../en/ch07-branch.xml:301
dongsheng@627 8791 msgid ""
dongsheng@627 8792 "In the simplest instance, all you need to do is pull changes from your "
dongsheng@627 8793 "maintenance branch into your local clone of the target branch."
dongsheng@627 8794 msgstr ""
dongsheng@627 8795
dongsheng@627 8796 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8797 #: ../en/ch07-branch.xml:307
dongsheng@627 8798 msgid ""
dongsheng@627 8799 "You'll then need to merge the heads of the two branches, and push back to the "
dongsheng@627 8800 "main branch."
dongsheng@627 8801 msgstr ""
dongsheng@627 8802
dongsheng@627 8803 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 8804 #: ../en/ch07-branch.xml:314
dongsheng@627 8805 msgid "Naming branches within one repository"
dongsheng@635 8806 msgstr "版本库中的命名分支"
dongsheng@627 8807
dongsheng@627 8808 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8809 #: ../en/ch07-branch.xml:316
dongsheng@627 8810 msgid ""
dongsheng@627 8811 "In most instances, isolating branches in repositories is the right approach. "
dongsheng@627 8812 "Its simplicity makes it easy to understand; and so it's hard to make "
dongsheng@627 8813 "mistakes. There's a one-to-one relationship between branches you're working "
dongsheng@627 8814 "in and directories on your system. This lets you use normal (non-Mercurial-"
dongsheng@627 8815 "aware) tools to work on files within a branch/repository."
dongsheng@627 8816 msgstr ""
dongsheng@627 8817
dongsheng@627 8818 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8819 #: ../en/ch07-branch.xml:323
dongsheng@627 8820 msgid ""
dongsheng@627 8821 "If you're more in the <quote>power user</quote> category (<emphasis>and</"
dongsheng@627 8822 "emphasis> your collaborators are too), there is an alternative way of "
dongsheng@627 8823 "handling branches that you can consider. I've already mentioned the human-"
dongsheng@627 8824 "level distinction between <quote>small picture</quote> and <quote>big "
dongsheng@627 8825 "picture</quote> branches. While Mercurial works with multiple <quote>small "
dongsheng@627 8826 "picture</quote> branches in a repository all the time (for example after you "
dongsheng@627 8827 "pull changes in, but before you merge them), it can <emphasis>also</emphasis> "
dongsheng@627 8828 "work with multiple <quote>big picture</quote> branches."
dongsheng@627 8829 msgstr ""
dongsheng@627 8830
dongsheng@627 8831 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8832 #: ../en/ch07-branch.xml:334
dongsheng@627 8833 msgid ""
dongsheng@627 8834 "The key to working this way is that Mercurial lets you assign a persistent "
dongsheng@627 8835 "<emphasis>name</emphasis> to a branch. There always exists a branch named "
dongsheng@627 8836 "<literal>default</literal>. Even before you start naming branches yourself, "
dongsheng@627 8837 "you can find traces of the <literal>default</literal> branch if you look for "
dongsheng@627 8838 "them."
dongsheng@627 8839 msgstr ""
dongsheng@627 8840
dongsheng@627 8841 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8842 #: ../en/ch07-branch.xml:341
dongsheng@627 8843 msgid ""
dongsheng@627 8844 "As an example, when you run the <command role=\"hg-cmd\">hg commit</command> "
dongsheng@627 8845 "command, and it pops up your editor so that you can enter a commit message, "
dongsheng@627 8846 "look for a line that contains the text <quote><literal>HG: branch default</"
dongsheng@627 8847 "literal></quote> at the bottom. This is telling you that your commit will "
dongsheng@627 8848 "occur on the branch named <literal>default</literal>."
dongsheng@627 8849 msgstr ""
dongsheng@627 8850
dongsheng@627 8851 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8852 #: ../en/ch07-branch.xml:348
dongsheng@627 8853 msgid ""
dongsheng@627 8854 "To start working with named branches, use the <command role=\"hg-cmd\">hg "
dongsheng@627 8855 "branches</command> command. This command lists the named branches already "
dongsheng@627 8856 "present in your repository, telling you which changeset is the tip of each."
dongsheng@627 8857 msgstr ""
dongsheng@627 8858
dongsheng@627 8859 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8860 #: ../en/ch07-branch.xml:355
dongsheng@627 8861 msgid ""
dongsheng@627 8862 "Since you haven't created any named branches yet, the only one that exists is "
dongsheng@627 8863 "<literal>default</literal>."
dongsheng@627 8864 msgstr ""
dongsheng@627 8865
dongsheng@627 8866 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8867 #: ../en/ch07-branch.xml:358
dongsheng@627 8868 msgid ""
dongsheng@627 8869 "To find out what the <quote>current</quote> branch is, run the <command role="
dongsheng@627 8870 "\"hg-cmd\">hg branch</command> command, giving it no arguments. This tells "
dongsheng@627 8871 "you what branch the parent of the current changeset is on."
dongsheng@627 8872 msgstr ""
dongsheng@627 8873
dongsheng@627 8874 #
dongsheng@627 8875 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8876 #: ../en/ch07-branch.xml:365
dongsheng@627 8877 msgid ""
dongsheng@627 8878 "To create a new branch, run the <command role=\"hg-cmd\">hg branch</command> "
dongsheng@627 8879 "command again. This time, give it one argument: the name of the branch you "
dongsheng@627 8880 "want to create."
dongsheng@627 8881 msgstr ""
dongsheng@627 8882
dongsheng@627 8883 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8884 #: ../en/ch07-branch.xml:371
dongsheng@627 8885 msgid ""
dongsheng@627 8886 "After you've created a branch, you might wonder what effect the <command role="
dongsheng@627 8887 "\"hg-cmd\">hg branch</command> command has had. What do the <command role="
dongsheng@627 8888 "\"hg-cmd\">hg status</command> and <command role=\"hg-cmd\">hg tip</command> "
dongsheng@627 8889 "commands report?"
dongsheng@627 8890 msgstr ""
dongsheng@627 8891
dongsheng@627 8892 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8893 #: ../en/ch07-branch.xml:378
dongsheng@627 8894 msgid ""
dongsheng@627 8895 "Nothing has changed in the working directory, and there's been no new history "
dongsheng@627 8896 "created. As this suggests, running the <command role=\"hg-cmd\">hg branch</"
dongsheng@627 8897 "command> command has no permanent effect; it only tells Mercurial what branch "
dongsheng@627 8898 "name to use the <emphasis>next</emphasis> time you commit a changeset."
dongsheng@627 8899 msgstr ""
dongsheng@627 8900
dongsheng@627 8901 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8902 #: ../en/ch07-branch.xml:385
dongsheng@627 8903 msgid ""
dongsheng@627 8904 "When you commit a change, Mercurial records the name of the branch on which "
dongsheng@627 8905 "you committed. Once you've switched from the <literal>default</literal> "
dongsheng@627 8906 "branch to another and committed, you'll see the name of the new branch show "
dongsheng@627 8907 "up in the output of <command role=\"hg-cmd\">hg log</command>, <command role="
dongsheng@627 8908 "\"hg-cmd\">hg tip</command>, and other commands that display the same kind of "
dongsheng@627 8909 "output."
dongsheng@627 8910 msgstr ""
dongsheng@627 8911
dongsheng@627 8912 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8913 #: ../en/ch07-branch.xml:395
dongsheng@627 8914 msgid ""
dongsheng@627 8915 "The <command role=\"hg-cmd\">hg log</command>-like commands will print the "
dongsheng@627 8916 "branch name of every changeset that's not on the <literal>default</literal> "
dongsheng@627 8917 "branch. As a result, if you never use named branches, you'll never see this "
dongsheng@627 8918 "information."
dongsheng@627 8919 msgstr ""
dongsheng@627 8920
dongsheng@627 8921 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8922 #: ../en/ch07-branch.xml:400
dongsheng@627 8923 msgid ""
dongsheng@627 8924 "Once you've named a branch and committed a change with that name, every "
dongsheng@627 8925 "subsequent commit that descends from that change will inherit the same branch "
dongsheng@627 8926 "name. You can change the name of a branch at any time, using the <command "
dongsheng@627 8927 "role=\"hg-cmd\">hg branch</command> command."
dongsheng@627 8928 msgstr ""
dongsheng@627 8929
dongsheng@627 8930 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8931 #: ../en/ch07-branch.xml:408
dongsheng@627 8932 msgid ""
dongsheng@627 8933 "In practice, this is something you won't do very often, as branch names tend "
dongsheng@627 8934 "to have fairly long lifetimes. (This isn't a rule, just an observation.)"
dongsheng@627 8935 msgstr ""
dongsheng@627 8936
dongsheng@627 8937 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 8938 #: ../en/ch07-branch.xml:414
dongsheng@627 8939 msgid "Dealing with multiple named branches in a repository"
dongsheng@635 8940 msgstr "在版本库中处理多个命名分支"
dongsheng@627 8941
dongsheng@627 8942 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8943 #: ../en/ch07-branch.xml:417
dongsheng@627 8944 msgid ""
dongsheng@627 8945 "If you have more than one named branch in a repository, Mercurial will "
dongsheng@627 8946 "remember the branch that your working directory on when you start a command "
dongsheng@627 8947 "like <command role=\"hg-cmd\">hg update</command> or <command role=\"hg-cmd"
dongsheng@627 8948 "\">hg pull -u</command>. It will update the working directory to the tip of "
dongsheng@627 8949 "this branch, no matter what the <quote>repo-wide</quote> tip is. To update "
dongsheng@627 8950 "to a revision that's on a different named branch, you may need to use the "
dongsheng@627 8951 "<option role=\"hg-opt-update\">-C</option> option to <command role=\"hg-cmd"
dongsheng@627 8952 "\">hg update</command>."
dongsheng@627 8953 msgstr ""
dongsheng@627 8954
dongsheng@627 8955 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8956 #: ../en/ch07-branch.xml:427
dongsheng@627 8957 msgid ""
songdongsheng@710 8958 "This behavior is a little subtle, so let's see it in action. First, let's "
dongsheng@627 8959 "remind ourselves what branch we're currently on, and what branches are in our "
dongsheng@627 8960 "repository."
dongsheng@627 8961 msgstr ""
dongsheng@627 8962
dongsheng@627 8963 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8964 #: ../en/ch07-branch.xml:433
dongsheng@627 8965 msgid ""
dongsheng@627 8966 "We're on the <literal>bar</literal> branch, but there also exists an older "
dongsheng@627 8967 "<command role=\"hg-cmd\">hg foo</command> branch."
dongsheng@627 8968 msgstr ""
dongsheng@627 8969
dongsheng@627 8970 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8971 #: ../en/ch07-branch.xml:437
dongsheng@627 8972 msgid ""
dongsheng@627 8973 "We can <command role=\"hg-cmd\">hg update</command> back and forth between "
dongsheng@627 8974 "the tips of the <literal>foo</literal> and <literal>bar</literal> branches "
dongsheng@627 8975 "without needing to use the <option role=\"hg-opt-update\">-C</option> option, "
dongsheng@627 8976 "because this only involves going backwards and forwards linearly through our "
dongsheng@627 8977 "change history."
dongsheng@627 8978 msgstr ""
dongsheng@627 8979
dongsheng@627 8980 #
dongsheng@627 8981 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8982 #: ../en/ch07-branch.xml:446
dongsheng@627 8983 msgid ""
dongsheng@627 8984 "If we go back to the <literal>foo</literal> branch and then run <command role="
dongsheng@627 8985 "\"hg-cmd\">hg update</command>, it will keep us on <literal>foo</literal>, "
dongsheng@627 8986 "not move us to the tip of <literal>bar</literal>."
dongsheng@627 8987 msgstr ""
dongsheng@627 8988
dongsheng@627 8989 #
dongsheng@627 8990 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8991 #: ../en/ch07-branch.xml:453
dongsheng@627 8992 msgid ""
dongsheng@627 8993 "Committing a new change on the <literal>foo</literal> branch introduces a new "
dongsheng@627 8994 "head."
dongsheng@627 8995 msgstr ""
dongsheng@627 8996
dongsheng@627 8997 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 8998 #: ../en/ch07-branch.xml:460
dongsheng@627 8999 msgid "Branch names and merging"
dongsheng@635 9000 msgstr "分支名称与合并"
dongsheng@627 9001
dongsheng@627 9002 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 9003 #: ../en/ch07-branch.xml:462
dongsheng@627 9004 msgid ""
dongsheng@627 9005 "As you've probably noticed, merges in Mercurial are not symmetrical. Let's "
dongsheng@627 9006 "say our repository has two heads, 17 and 23. If I <command role=\"hg-cmd"
dongsheng@627 9007 "\">hg update</command> to 17 and then <command role=\"hg-cmd\">hg merge</"
dongsheng@627 9008 "command> with 23, Mercurial records 17 as the first parent of the merge, and "
dongsheng@627 9009 "23 as the second. Whereas if I <command role=\"hg-cmd\">hg update</command> "
dongsheng@627 9010 "to 23 and then <command role=\"hg-cmd\">hg merge</command> with 17, it "
dongsheng@627 9011 "records 23 as the first parent, and 17 as the second."
dongsheng@627 9012 msgstr ""
dongsheng@627 9013
dongsheng@627 9014 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 9015 #: ../en/ch07-branch.xml:472
dongsheng@627 9016 msgid ""
dongsheng@627 9017 "This affects Mercurial's choice of branch name when you merge. After a "
dongsheng@627 9018 "merge, Mercurial will retain the branch name of the first parent when you "
dongsheng@627 9019 "commit the result of the merge. If your first parent's branch name is "
dongsheng@627 9020 "<literal>foo</literal>, and you merge with <literal>bar</literal>, the branch "
dongsheng@627 9021 "name will still be <literal>foo</literal> after you merge."
dongsheng@627 9022 msgstr ""
dongsheng@627 9023
dongsheng@627 9024 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 9025 #: ../en/ch07-branch.xml:479
dongsheng@627 9026 msgid ""
dongsheng@627 9027 "It's not unusual for a repository to contain multiple heads, each with the "
dongsheng@627 9028 "same branch name. Let's say I'm working on the <literal>foo</literal> "
dongsheng@627 9029 "branch, and so are you. We commit different changes; I pull your changes; I "
dongsheng@627 9030 "now have two heads, each claiming to be on the <literal>foo</literal> "
dongsheng@627 9031 "branch. The result of a merge will be a single head on the <literal>foo</"
dongsheng@627 9032 "literal> branch, as you might hope."
dongsheng@627 9033 msgstr ""
dongsheng@627 9034
dongsheng@627 9035 #
dongsheng@627 9036 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 9037 #: ../en/ch07-branch.xml:487
dongsheng@627 9038 msgid ""
dongsheng@627 9039 "But if I'm working on the <literal>bar</literal> branch, and I merge work "
dongsheng@627 9040 "from the <literal>foo</literal> branch, the result will remain on the "
dongsheng@627 9041 "<literal>bar</literal> branch."
dongsheng@627 9042 msgstr ""
dongsheng@627 9043
dongsheng@627 9044 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 9045 #: ../en/ch07-branch.xml:493
dongsheng@627 9046 msgid ""
dongsheng@627 9047 "To give a more concrete example, if I'm working on the <literal>bleeding-"
dongsheng@627 9048 "edge</literal> branch, and I want to bring in the latest fixes from the "
dongsheng@627 9049 "<literal>stable</literal> branch, Mercurial will choose the <quote>right</"
dongsheng@627 9050 "quote> (<literal>bleeding-edge</literal>) branch name when I pull and merge "
dongsheng@627 9051 "from <literal>stable</literal>."
dongsheng@627 9052 msgstr ""
dongsheng@627 9053
dongsheng@627 9054 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 9055 #: ../en/ch07-branch.xml:502
dongsheng@627 9056 msgid "Branch naming is generally useful"
dongsheng@635 9057 msgstr "分支名称通常都很有用"
dongsheng@627 9058
dongsheng@627 9059 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 9060 #: ../en/ch07-branch.xml:504
dongsheng@627 9061 msgid ""
dongsheng@627 9062 "You shouldn't think of named branches as applicable only to situations where "
dongsheng@627 9063 "you have multiple long-lived branches cohabiting in a single repository. "
dongsheng@627 9064 "They're very useful even in the one-branch-per-repository case."
dongsheng@627 9065 msgstr ""
dongsheng@627 9066
dongsheng@627 9067 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 9068 #: ../en/ch07-branch.xml:509
dongsheng@627 9069 msgid ""
dongsheng@627 9070 "In the simplest case, giving a name to each branch gives you a permanent "
dongsheng@627 9071 "record of which branch a changeset originated on. This gives you more "
dongsheng@627 9072 "context when you're trying to follow the history of a long-lived branchy "
dongsheng@627 9073 "project."
dongsheng@627 9074 msgstr ""
dongsheng@627 9075
dongsheng@627 9076 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 9077 #: ../en/ch07-branch.xml:514
dongsheng@627 9078 msgid ""
dongsheng@627 9079 "If you're working with shared repositories, you can set up a <literal role="
dongsheng@627 9080 "\"hook\">pretxnchangegroup</literal> hook on each that will block incoming "
dongsheng@627 9081 "changes that have the <quote>wrong</quote> branch name. This provides a "
dongsheng@627 9082 "simple, but effective, defence against people accidentally pushing changes "
dongsheng@627 9083 "from a <quote>bleeding edge</quote> branch to a <quote>stable</quote> "
dongsheng@627 9084 "branch. Such a hook might look like this inside the shared repo's <filename "
dongsheng@627 9085 "role=\"special\"> /.hgrc</filename>."
dongsheng@627 9086 msgstr ""
dongsheng@627 9087
dongsheng@627 9088 #. type: Content of: <book><chapter><title>
dongsheng@650 9089 #: ../en/ch08-undo.xml:5
dongsheng@627 9090 msgid "Finding and fixing mistakes"
dongsheng@627 9091 msgstr "查找和修改错误"
dongsheng@627 9092
dongsheng@627 9093 #. type: Content of: <book><chapter><para>
dongsheng@650 9094 #: ../en/ch08-undo.xml:7
dongsheng@627 9095 msgid ""
dongsheng@627 9096 "To err might be human, but to really handle the consequences well takes a top-"
dongsheng@627 9097 "notch revision control system. In this chapter, we'll discuss some of the "
dongsheng@627 9098 "techniques you can use when you find that a problem has crept into your "
dongsheng@627 9099 "project. Mercurial has some highly capable features that will help you to "
dongsheng@627 9100 "isolate the sources of problems, and to handle them appropriately."
dongsheng@627 9101 msgstr ""
dongsheng@627 9102
dongsheng@627 9103 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 9104 #: ../en/ch08-undo.xml:15
dongsheng@627 9105 msgid "Erasing local history"
dongsheng@635 9106 msgstr "销毁本地历史"
dongsheng@627 9107
dongsheng@627 9108 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 9109 #: ../en/ch08-undo.xml:18
dongsheng@627 9110 msgid "The accidental commit"
dongsheng@635 9111 msgstr "意外的提交"
dongsheng@627 9112
dongsheng@627 9113 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 9114 #: ../en/ch08-undo.xml:20
dongsheng@627 9115 msgid ""
dongsheng@627 9116 "I have the occasional but persistent problem of typing rather more quickly "
dongsheng@627 9117 "than I can think, which sometimes results in me committing a changeset that "
dongsheng@627 9118 "is either incomplete or plain wrong. In my case, the usual kind of "
dongsheng@627 9119 "incomplete changeset is one in which I've created a new source file, but "
dongsheng@627 9120 "forgotten to <command role=\"hg-cmd\">hg add</command> it. A <quote>plain "
dongsheng@627 9121 "wrong</quote> changeset is not as common, but no less annoying."
dongsheng@627 9122 msgstr ""
dongsheng@627 9123
dongsheng@627 9124 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 9125 #: ../en/ch08-undo.xml:31
dongsheng@627 9126 msgid "Rolling back a transaction"
dongsheng@635 9127 msgstr "回滚一个事务"
dongsheng@627 9128
dongsheng@627 9129 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 9130 #: ../en/ch08-undo.xml:33
dongsheng@627 9131 msgid ""
songdongsheng@658 9132 "In <xref linkend=\"sec:concepts:txn\"/>, I mentioned that Mercurial treats "
songdongsheng@658 9133 "each modification of a repository as a <emphasis>transaction</emphasis>. "
songdongsheng@658 9134 "Every time you commit a changeset or pull changes from another repository, "
songdongsheng@658 9135 "Mercurial remembers what you did. You can undo, or <emphasis>roll back</"
songdongsheng@658 9136 "emphasis>, exactly one of these actions using the <command role=\"hg-cmd\">hg "
songdongsheng@658 9137 "rollback</command> command. (See <xref linkend=\"sec:undo:rollback-after-push"
songdongsheng@658 9138 "\"/> for an important caveat about the use of this command.)"
dongsheng@627 9139 msgstr ""
dongsheng@627 9140
dongsheng@627 9141 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 9142 #: ../en/ch08-undo.xml:43
dongsheng@627 9143 msgid ""
dongsheng@627 9144 "Here's a mistake that I often find myself making: committing a change in "
dongsheng@627 9145 "which I've created a new file, but forgotten to <command role=\"hg-cmd\">hg "
dongsheng@627 9146 "add</command> it."
dongsheng@627 9147 msgstr ""
dongsheng@627 9148
dongsheng@627 9149 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 9150 #: ../en/ch08-undo.xml:50
dongsheng@627 9151 msgid ""
dongsheng@627 9152 "Looking at the output of <command role=\"hg-cmd\">hg status</command> after "
dongsheng@627 9153 "the commit immediately confirms the error."
dongsheng@627 9154 msgstr ""
dongsheng@627 9155
dongsheng@627 9156 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 9157 #: ../en/ch08-undo.xml:56
dongsheng@627 9158 msgid ""
dongsheng@627 9159 "The commit captured the changes to the file <filename>a</filename>, but not "
dongsheng@627 9160 "the new file <filename>b</filename>. If I were to push this changeset to a "
dongsheng@627 9161 "repository that I shared with a colleague, the chances are high that "
dongsheng@627 9162 "something in <filename>a</filename> would refer to <filename>b</filename>, "
dongsheng@627 9163 "which would not be present in their repository when they pulled my changes. "
dongsheng@627 9164 "I would thus become the object of some indignation."
dongsheng@627 9165 msgstr ""
dongsheng@627 9166
dongsheng@627 9167 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 9168 #: ../en/ch08-undo.xml:65
dongsheng@627 9169 msgid ""
songdongsheng@668 9170 "However, luck is with me&emdash;I've caught my error before I pushed the "
songdongsheng@668 9171 "changeset. I use the <command role=\"hg-cmd\">hg rollback</command> command, "
songdongsheng@668 9172 "and Mercurial makes that last changeset vanish."
dongsheng@627 9173 msgstr ""
dongsheng@627 9174
dongsheng@627 9175 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 9176 #: ../en/ch08-undo.xml:72
dongsheng@627 9177 msgid ""
dongsheng@627 9178 "Notice that the changeset is no longer present in the repository's history, "
dongsheng@627 9179 "and the working directory once again thinks that the file <filename>a</"
dongsheng@627 9180 "filename> is modified. The commit and rollback have left the working "
dongsheng@627 9181 "directory exactly as it was prior to the commit; the changeset has been "
dongsheng@627 9182 "completely erased. I can now safely <command role=\"hg-cmd\">hg add</"
dongsheng@627 9183 "command> the file <filename>b</filename>, and rerun my commit."
dongsheng@627 9184 msgstr ""
dongsheng@627 9185
dongsheng@627 9186 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 9187 #: ../en/ch08-undo.xml:85
dongsheng@627 9188 msgid "The erroneous pull"
dongsheng@635 9189 msgstr "错误的抓取"
dongsheng@627 9190
dongsheng@627 9191 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 9192 #: ../en/ch08-undo.xml:87
dongsheng@627 9193 msgid ""
dongsheng@627 9194 "It's common practice with Mercurial to maintain separate development branches "
dongsheng@627 9195 "of a project in different repositories. Your development team might have one "
dongsheng@627 9196 "shared repository for your project's <quote>0.9</quote> release, and another, "
dongsheng@627 9197 "containing different changes, for the <quote>1.0</quote> release."
dongsheng@627 9198 msgstr ""
dongsheng@627 9199
dongsheng@627 9200 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 9201 #: ../en/ch08-undo.xml:94
dongsheng@627 9202 msgid ""
dongsheng@627 9203 "Given this, you can imagine that the consequences could be messy if you had a "
dongsheng@627 9204 "local <quote>0.9</quote> repository, and accidentally pulled changes from the "
dongsheng@627 9205 "shared <quote>1.0</quote> repository into it. At worst, you could be paying "
dongsheng@627 9206 "insufficient attention, and push those changes into the shared <quote>0.9</"
dongsheng@627 9207 "quote> tree, confusing your entire team (but don't worry, we'll return to "
dongsheng@627 9208 "this horror scenario later). However, it's more likely that you'll notice "
dongsheng@627 9209 "immediately, because Mercurial will display the URL it's pulling from, or you "
dongsheng@627 9210 "will see it pull a suspiciously large number of changes into the repository."
dongsheng@627 9211 msgstr ""
dongsheng@627 9212
dongsheng@627 9213 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 9214 #: ../en/ch08-undo.xml:106
dongsheng@627 9215 msgid ""
dongsheng@627 9216 "The <command role=\"hg-cmd\">hg rollback</command> command will work nicely "
dongsheng@627 9217 "to expunge all of the changesets that you just pulled. Mercurial groups all "
dongsheng@627 9218 "changes from one <command role=\"hg-cmd\">hg pull</command> into a single "
dongsheng@627 9219 "transaction, so one <command role=\"hg-cmd\">hg rollback</command> is all you "
dongsheng@627 9220 "need to undo this mistake."
dongsheng@627 9221 msgstr ""
dongsheng@627 9222
dongsheng@627 9223 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 9224 #: ../en/ch08-undo.xml:115
dongsheng@627 9225 msgid "Rolling back is useless once you've pushed"
dongsheng@635 9226 msgstr "当完成推送后,回滚是无效的"
dongsheng@627 9227
dongsheng@627 9228 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 9229 #: ../en/ch08-undo.xml:117
dongsheng@627 9230 msgid ""
dongsheng@627 9231 "The value of the <command role=\"hg-cmd\">hg rollback</command> command drops "
dongsheng@627 9232 "to zero once you've pushed your changes to another repository. Rolling back "
dongsheng@627 9233 "a change makes it disappear entirely, but <emphasis>only</emphasis> in the "
dongsheng@627 9234 "repository in which you perform the <command role=\"hg-cmd\">hg rollback</"
dongsheng@627 9235 "command>. Because a rollback eliminates history, there's no way for the "
dongsheng@627 9236 "disappearance of a change to propagate between repositories."
dongsheng@627 9237 msgstr ""
dongsheng@627 9238
dongsheng@627 9239 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 9240 #: ../en/ch08-undo.xml:126
dongsheng@627 9241 msgid ""
songdongsheng@668 9242 "If you've pushed a change to another repository&emdash;particularly if it's a "
songdongsheng@668 9243 "shared repository&emdash;it has essentially <quote>escaped into the wild,</"
songdongsheng@668 9244 "quote> and you'll have to recover from your mistake in a different way. What "
songdongsheng@668 9245 "will happen if you push a changeset somewhere, then roll it back, then pull "
songdongsheng@668 9246 "from the repository you pushed to, is that the changeset will reappear in "
songdongsheng@668 9247 "your repository."
dongsheng@627 9248 msgstr ""
dongsheng@627 9249
dongsheng@627 9250 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 9251 #: ../en/ch08-undo.xml:135
dongsheng@627 9252 msgid ""
dongsheng@627 9253 "(If you absolutely know for sure that the change you want to roll back is the "
dongsheng@627 9254 "most recent change in the repository that you pushed to, <emphasis>and</"
dongsheng@627 9255 "emphasis> you know that nobody else could have pulled it from that "
dongsheng@627 9256 "repository, you can roll back the changeset there, too, but you really should "
dongsheng@627 9257 "really not rely on this working reliably. If you do this, sooner or later a "
dongsheng@627 9258 "change really will make it into a repository that you don't directly control "
dongsheng@627 9259 "(or have forgotten about), and come back to bite you.)"
dongsheng@627 9260 msgstr ""
dongsheng@627 9261
dongsheng@627 9262 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 9263 #: ../en/ch08-undo.xml:147
dongsheng@627 9264 msgid "You can only roll back once"
dongsheng@635 9265 msgstr "你只能回滚一次"
dongsheng@627 9266
dongsheng@627 9267 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 9268 #: ../en/ch08-undo.xml:149
dongsheng@627 9269 msgid ""
dongsheng@627 9270 "Mercurial stores exactly one transaction in its transaction log; that "
dongsheng@627 9271 "transaction is the most recent one that occurred in the repository. This "
dongsheng@627 9272 "means that you can only roll back one transaction. If you expect to be able "
songdongsheng@710 9273 "to roll back one transaction, then its predecessor, this is not the behavior "
dongsheng@627 9274 "you will get."
dongsheng@627 9275 msgstr ""
dongsheng@627 9276
dongsheng@627 9277 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 9278 #: ../en/ch08-undo.xml:158
dongsheng@627 9279 msgid ""
dongsheng@627 9280 "Once you've rolled back one transaction in a repository, you can't roll back "
dongsheng@627 9281 "again in that repository until you perform another commit or pull."
dongsheng@627 9282 msgstr ""
dongsheng@627 9283
dongsheng@627 9284 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 9285 #: ../en/ch08-undo.xml:165
dongsheng@627 9286 msgid "Reverting the mistaken change"
dongsheng@635 9287 msgstr "撤销错误的修改"
dongsheng@627 9288
dongsheng@627 9289 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 9290 #: ../en/ch08-undo.xml:167
dongsheng@627 9291 msgid ""
dongsheng@627 9292 "If you make a modification to a file, and decide that you really didn't want "
dongsheng@627 9293 "to change the file at all, and you haven't yet committed your changes, the "
dongsheng@627 9294 "<command role=\"hg-cmd\">hg revert</command> command is the one you'll need. "
dongsheng@627 9295 "It looks at the changeset that's the parent of the working directory, and "
dongsheng@627 9296 "restores the contents of the file to their state as of that changeset. "
dongsheng@627 9297 "(That's a long-winded way of saying that, in the normal case, it undoes your "
dongsheng@627 9298 "modifications.)"
dongsheng@627 9299 msgstr ""
dongsheng@627 9300
dongsheng@627 9301 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 9302 #: ../en/ch08-undo.xml:176
dongsheng@627 9303 msgid ""
dongsheng@627 9304 "Let's illustrate how the <command role=\"hg-cmd\">hg revert</command> command "
dongsheng@627 9305 "works with yet another small example. We'll begin by modifying a file that "
dongsheng@627 9306 "Mercurial is already tracking."
dongsheng@627 9307 msgstr ""
dongsheng@627 9308
dongsheng@627 9309 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 9310 #: ../en/ch08-undo.xml:183
dongsheng@627 9311 msgid ""
dongsheng@627 9312 "If we don't want that change, we can simply <command role=\"hg-cmd\">hg "
dongsheng@627 9313 "revert</command> the file."
dongsheng@627 9314 msgstr ""
dongsheng@627 9315
dongsheng@627 9316 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 9317 #: ../en/ch08-undo.xml:189
dongsheng@627 9318 msgid ""
dongsheng@627 9319 "The <command role=\"hg-cmd\">hg revert</command> command provides us with an "
dongsheng@627 9320 "extra degree of safety by saving our modified file with a <filename>.orig</"
dongsheng@627 9321 "filename> extension."
dongsheng@627 9322 msgstr ""
dongsheng@627 9323
dongsheng@627 9324 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 9325 #: ../en/ch08-undo.xml:196
dongsheng@627 9326 msgid ""
dongsheng@627 9327 "Here is a summary of the cases that the <command role=\"hg-cmd\">hg revert</"
dongsheng@627 9328 "command> command can deal with. We will describe each of these in more "
dongsheng@627 9329 "detail in the section that follows."
dongsheng@627 9330 msgstr ""
dongsheng@627 9331
dongsheng@627 9332 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 9333 #: ../en/ch08-undo.xml:201
dongsheng@627 9334 msgid "If you modify a file, it will restore the file to its unmodified state."
dongsheng@627 9335 msgstr ""
dongsheng@627 9336
dongsheng@627 9337 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 9338 #: ../en/ch08-undo.xml:204
dongsheng@627 9339 msgid ""
dongsheng@627 9340 "If you <command role=\"hg-cmd\">hg add</command> a file, it will undo the "
dongsheng@627 9341 "<quote>added</quote> state of the file, but leave the file itself untouched."
dongsheng@627 9342 msgstr ""
dongsheng@627 9343
dongsheng@627 9344 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 9345 #: ../en/ch08-undo.xml:208
dongsheng@627 9346 msgid ""
dongsheng@627 9347 "If you delete a file without telling Mercurial, it will restore the file to "
dongsheng@627 9348 "its unmodified contents."
dongsheng@627 9349 msgstr ""
dongsheng@627 9350
dongsheng@627 9351 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 9352 #: ../en/ch08-undo.xml:211
dongsheng@627 9353 msgid ""
dongsheng@627 9354 "If you use the <command role=\"hg-cmd\">hg remove</command> command to remove "
dongsheng@627 9355 "a file, it will undo the <quote>removed</quote> state of the file, and "
dongsheng@627 9356 "restore the file to its unmodified contents."
dongsheng@627 9357 msgstr ""
dongsheng@627 9358
dongsheng@627 9359 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 9360 #: ../en/ch08-undo.xml:218
dongsheng@627 9361 msgid "File management errors"
dongsheng@635 9362 msgstr "文件管理错误"
dongsheng@627 9363
dongsheng@627 9364 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 9365 #: ../en/ch08-undo.xml:220
dongsheng@627 9366 msgid ""
dongsheng@627 9367 "The <command role=\"hg-cmd\">hg revert</command> command is useful for more "
dongsheng@627 9368 "than just modified files. It lets you reverse the results of all of "
songdongsheng@668 9369 "Mercurial's file management commands&emdash;<command role=\"hg-cmd\">hg add</"
dongsheng@627 9370 "command>, <command role=\"hg-cmd\">hg remove</command>, and so on."
dongsheng@627 9371 msgstr ""
dongsheng@627 9372
dongsheng@627 9373 #
dongsheng@627 9374 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 9375 #: ../en/ch08-undo.xml:226
dongsheng@627 9376 msgid ""
dongsheng@627 9377 "If you <command role=\"hg-cmd\">hg add</command> a file, then decide that in "
dongsheng@627 9378 "fact you don't want Mercurial to track it, use <command role=\"hg-cmd\">hg "
dongsheng@627 9379 "revert</command> to undo the add. Don't worry; Mercurial will not modify the "
dongsheng@627 9380 "file in any way. It will just <quote>unmark</quote> the file."
dongsheng@627 9381 msgstr ""
dongsheng@627 9382
dongsheng@627 9383 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 9384 #: ../en/ch08-undo.xml:234
dongsheng@627 9385 msgid ""
dongsheng@627 9386 "Similarly, if you ask Mercurial to <command role=\"hg-cmd\">hg remove</"
dongsheng@627 9387 "command> a file, you can use <command role=\"hg-cmd\">hg revert</command> to "
dongsheng@627 9388 "restore it to the contents it had as of the parent of the working directory. "
dongsheng@627 9389 "&interaction.daily.revert.remove; This works just as well for a file that you "
dongsheng@627 9390 "deleted by hand, without telling Mercurial (recall that in Mercurial "
dongsheng@627 9391 "terminology, this kind of file is called <quote>missing</quote>)."
dongsheng@627 9392 msgstr ""
dongsheng@627 9393
dongsheng@627 9394 #
dongsheng@627 9395 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 9396 #: ../en/ch08-undo.xml:245
dongsheng@627 9397 msgid ""
dongsheng@627 9398 "If you revert a <command role=\"hg-cmd\">hg copy</command>, the copied-to "
dongsheng@627 9399 "file remains in your working directory afterwards, untracked. Since a copy "
dongsheng@627 9400 "doesn't affect the copied-from file in any way, Mercurial doesn't do anything "
dongsheng@627 9401 "with the copied-from file."
dongsheng@627 9402 msgstr ""
dongsheng@627 9403
dongsheng@627 9404 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
dongsheng@650 9405 #: ../en/ch08-undo.xml:254
dongsheng@627 9406 msgid "A slightly special case: reverting a rename"
dongsheng@635 9407 msgstr "一个稍微特别的案例:撤销改名"
dongsheng@627 9408
dongsheng@627 9409 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 9410 #: ../en/ch08-undo.xml:256
dongsheng@627 9411 msgid ""
dongsheng@627 9412 "If you <command role=\"hg-cmd\">hg rename</command> a file, there is one "
dongsheng@627 9413 "small detail that you should remember. When you <command role=\"hg-cmd\">hg "
dongsheng@627 9414 "revert</command> a rename, it's not enough to provide the name of the renamed-"
dongsheng@627 9415 "to file, as you can see here."
dongsheng@627 9416 msgstr ""
dongsheng@627 9417
dongsheng@627 9418 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 9419 #: ../en/ch08-undo.xml:264
dongsheng@627 9420 msgid ""
dongsheng@627 9421 "As you can see from the output of <command role=\"hg-cmd\">hg status</"
dongsheng@627 9422 "command>, the renamed-to file is no longer identified as added, but the "
dongsheng@627 9423 "renamed-<emphasis>from</emphasis> file is still removed! This is counter-"
dongsheng@627 9424 "intuitive (at least to me), but at least it's easy to deal with."
dongsheng@627 9425 msgstr ""
dongsheng@627 9426
dongsheng@627 9427 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 9428 #: ../en/ch08-undo.xml:273
dongsheng@627 9429 msgid ""
dongsheng@627 9430 "So remember, to revert a <command role=\"hg-cmd\">hg rename</command>, you "
dongsheng@627 9431 "must provide <emphasis>both</emphasis> the source and destination names."
dongsheng@627 9432 msgstr ""
dongsheng@627 9433
dongsheng@627 9434 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 9435 #: ../en/ch08-undo.xml:278
dongsheng@627 9436 msgid "% TODO: the output doesn't look like it will be removed!"
dongsheng@627 9437 msgstr ""
dongsheng@627 9438
dongsheng@627 9439 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 9440 #: ../en/ch08-undo.xml:281
dongsheng@627 9441 msgid ""
dongsheng@627 9442 "(By the way, if you rename a file, then modify the renamed-to file, then "
dongsheng@627 9443 "revert both components of the rename, when Mercurial restores the file that "
dongsheng@627 9444 "was removed as part of the rename, it will be unmodified. If you need the "
dongsheng@627 9445 "modifications in the renamed-to file to show up in the renamed-from file, "
dongsheng@627 9446 "don't forget to copy them over.)"
dongsheng@627 9447 msgstr ""
dongsheng@627 9448
dongsheng@627 9449 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 9450 #: ../en/ch08-undo.xml:288
dongsheng@627 9451 msgid ""
dongsheng@627 9452 "These fiddly aspects of reverting a rename arguably constitute a small bug in "
dongsheng@627 9453 "Mercurial."
dongsheng@627 9454 msgstr ""
dongsheng@627 9455
dongsheng@627 9456 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 9457 #: ../en/ch08-undo.xml:295
dongsheng@627 9458 msgid "Dealing with committed changes"
dongsheng@635 9459 msgstr "处理已经提交的修改"
dongsheng@627 9460
dongsheng@627 9461 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 9462 #: ../en/ch08-undo.xml:297
dongsheng@627 9463 msgid ""
dongsheng@627 9464 "Consider a case where you have committed a change $a$, and another change $b$ "
dongsheng@627 9465 "on top of it; you then realise that change $a$ was incorrect. Mercurial lets "
dongsheng@627 9466 "you <quote>back out</quote> an entire changeset automatically, and building "
dongsheng@627 9467 "blocks that let you reverse part of a changeset by hand."
dongsheng@627 9468 msgstr ""
dongsheng@627 9469
dongsheng@627 9470 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 9471 #: ../en/ch08-undo.xml:303
dongsheng@627 9472 msgid ""
dongsheng@627 9473 "Before you read this section, here's something to keep in mind: the <command "
dongsheng@627 9474 "role=\"hg-cmd\">hg backout</command> command undoes changes by "
dongsheng@627 9475 "<emphasis>adding</emphasis> history, not by modifying or erasing it. It's "
dongsheng@627 9476 "the right tool to use if you're fixing bugs, but not if you're trying to undo "
dongsheng@627 9477 "some change that has catastrophic consequences. To deal with those, see "
songdongsheng@658 9478 "<xref linkend=\"sec:undo:aaaiiieee\"/>."
dongsheng@627 9479 msgstr ""
dongsheng@627 9480
dongsheng@627 9481 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 9482 #: ../en/ch08-undo.xml:312
dongsheng@627 9483 msgid "Backing out a changeset"
dongsheng@635 9484 msgstr "恢复一个修改集"
dongsheng@627 9485
dongsheng@627 9486 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 9487 #: ../en/ch08-undo.xml:314
dongsheng@627 9488 msgid ""
dongsheng@627 9489 "The <command role=\"hg-cmd\">hg backout</command> command lets you "
dongsheng@627 9490 "<quote>undo</quote> the effects of an entire changeset in an automated "
dongsheng@627 9491 "fashion. Because Mercurial's history is immutable, this command "
dongsheng@627 9492 "<emphasis>does not</emphasis> get rid of the changeset you want to undo. "
dongsheng@627 9493 "Instead, it creates a new changeset that <emphasis>reverses</emphasis> the "
dongsheng@627 9494 "effect of the to-be-undone changeset."
dongsheng@627 9495 msgstr ""
dongsheng@627 9496
dongsheng@627 9497 #
dongsheng@627 9498 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 9499 #: ../en/ch08-undo.xml:323
dongsheng@627 9500 msgid ""
dongsheng@627 9501 "The operation of the <command role=\"hg-cmd\">hg backout</command> command is "
dongsheng@627 9502 "a little intricate, so let's illustrate it with some examples. First, we'll "
dongsheng@627 9503 "create a repository with some simple changes."
dongsheng@627 9504 msgstr ""
dongsheng@627 9505
dongsheng@627 9506 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 9507 #: ../en/ch08-undo.xml:330
dongsheng@627 9508 msgid ""
dongsheng@627 9509 "The <command role=\"hg-cmd\">hg backout</command> command takes a single "
dongsheng@627 9510 "changeset ID as its argument; this is the changeset to back out. Normally, "
dongsheng@627 9511 "<command role=\"hg-cmd\">hg backout</command> will drop you into a text "
dongsheng@627 9512 "editor to write a commit message, so you can record why you're backing the "
dongsheng@627 9513 "change out. In this example, we provide a commit message on the command line "
dongsheng@627 9514 "using the <option role=\"hg-opt-backout\">-m</option> option."
dongsheng@627 9515 msgstr ""
dongsheng@627 9516
dongsheng@627 9517 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 9518 #: ../en/ch08-undo.xml:341
dongsheng@627 9519 msgid "Backing out the tip changeset"
dongsheng@635 9520 msgstr "恢复顶点修改集"
dongsheng@627 9521
dongsheng@627 9522 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 9523 #: ../en/ch08-undo.xml:343
dongsheng@627 9524 msgid "We're going to start by backing out the last changeset we committed."
dongsheng@627 9525 msgstr ""
dongsheng@627 9526
dongsheng@627 9527 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 9528 #: ../en/ch08-undo.xml:348
dongsheng@627 9529 msgid ""
dongsheng@627 9530 "You can see that the second line from <filename>myfile</filename> is no "
dongsheng@627 9531 "longer present. Taking a look at the output of <command role=\"hg-cmd\">hg "
dongsheng@627 9532 "log</command> gives us an idea of what the <command role=\"hg-cmd\">hg "
dongsheng@627 9533 "backout</command> command has done. &interaction.backout.simple.log; Notice "
dongsheng@627 9534 "that the new changeset that <command role=\"hg-cmd\">hg backout</command> has "
dongsheng@627 9535 "created is a child of the changeset we backed out. It's easier to see this "
songdongsheng@658 9536 "in <xref linkend=\"fig:undo:backout\"/>, which presents a graphical view of "
songdongsheng@658 9537 "the change history. As you can see, the history is nice and linear."
songdongsheng@658 9538 msgstr ""
songdongsheng@658 9539
songdongsheng@658 9540 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
songdongsheng@658 9541 #: ../en/ch08-undo.xml:361 ../en/ch08-undo.xml:473
dongsheng@627 9542 msgid ""
dongsheng@627 9543 "Backing out a change using the <command role=\"hg-cmd\">hg backout</command> "
dongsheng@627 9544 "command"
dongsheng@660 9545 msgstr "使用 <command role=\"hg-cmd\">hg backout</command> 恢复一个修改"
dongsheng@627 9546
songdongsheng@658 9547 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
songdongsheng@658 9548 #: ../en/ch08-undo.xml:364
songdongsheng@658 9549 msgid "<imageobject><imagedata fileref=\"figs/undo-simple.png\"/></imageobject>"
songdongsheng@658 9550 msgstr ""
songdongsheng@658 9551
dongsheng@627 9552 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 9553 #: ../en/ch08-undo.xml:371
dongsheng@627 9554 msgid "Backing out a non-tip change"
dongsheng@635 9555 msgstr "恢复非顶点的修改"
dongsheng@627 9556
dongsheng@627 9557 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 9558 #: ../en/ch08-undo.xml:373
dongsheng@627 9559 msgid ""
dongsheng@627 9560 "If you want to back out a change other than the last one you committed, pass "
dongsheng@627 9561 "the <option role=\"hg-opt-backout\">--merge</option> option to the <command "
dongsheng@627 9562 "role=\"hg-cmd\">hg backout</command> command."
dongsheng@627 9563 msgstr ""
dongsheng@627 9564
dongsheng@627 9565 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 9566 #: ../en/ch08-undo.xml:380
dongsheng@627 9567 msgid ""
dongsheng@627 9568 "This makes backing out any changeset a <quote>one-shot</quote> operation "
dongsheng@627 9569 "that's usually simple and fast."
dongsheng@627 9570 msgstr ""
dongsheng@627 9571
dongsheng@627 9572 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 9573 #: ../en/ch08-undo.xml:386
dongsheng@627 9574 msgid ""
dongsheng@627 9575 "If you take a look at the contents of <filename>myfile</filename> after the "
dongsheng@627 9576 "backout finishes, you'll see that the first and third changes are present, "
dongsheng@627 9577 "but not the second."
dongsheng@627 9578 msgstr ""
dongsheng@627 9579
dongsheng@627 9580 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 9581 #: ../en/ch08-undo.xml:393
songdongsheng@658 9582 msgid ""
songdongsheng@658 9583 "As the graphical history in <xref linkend=\"fig:undo:backout-non-tip\"/> "
songdongsheng@658 9584 "illustrates, Mercurial actually commits <emphasis>two</emphasis> changes in "
songdongsheng@658 9585 "this kind of situation (the box-shaped nodes are the ones that Mercurial "
songdongsheng@658 9586 "commits automatically). Before Mercurial begins the backout process, it "
songdongsheng@658 9587 "first remembers what the current parent of the working directory is. It then "
songdongsheng@658 9588 "backs out the target changeset, and commits that as a changeset. Finally, it "
songdongsheng@658 9589 "merges back to the previous parent of the working directory, and commits the "
songdongsheng@658 9590 "result of the merge."
songdongsheng@658 9591 msgstr ""
songdongsheng@658 9592
songdongsheng@658 9593 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 9594 #: ../en/ch08-undo.xml:404
dongsheng@627 9595 msgid ""
dongsheng@627 9596 "% TODO: to me it looks like mercurial doesn't commit the second merge "
dongsheng@627 9597 "automatically!"
dongsheng@627 9598 msgstr ""
dongsheng@627 9599
songdongsheng@658 9600 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
songdongsheng@658 9601 #: ../en/ch08-undo.xml:408
dongsheng@627 9602 msgid ""
dongsheng@627 9603 "Automated backout of a non-tip change using the <command role=\"hg-cmd\">hg "
dongsheng@627 9604 "backout</command> command"
dongsheng@660 9605 msgstr "使用 <command role=\"hg-cmd\">hg backout</command> 自动恢复非顶点的修改"
dongsheng@627 9606
songdongsheng@658 9607 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
songdongsheng@658 9608 #: ../en/ch08-undo.xml:411
songdongsheng@658 9609 msgid ""
songdongsheng@658 9610 "<imageobject><imagedata fileref=\"figs/undo-non-tip.png\"/></imageobject>"
songdongsheng@658 9611 msgstr ""
songdongsheng@658 9612
songdongsheng@658 9613 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 9614 #: ../en/ch08-undo.xml:416
dongsheng@627 9615 msgid ""
dongsheng@627 9616 "The result is that you end up <quote>back where you were</quote>, only with "
dongsheng@627 9617 "some extra history that undoes the effect of the changeset you wanted to back "
dongsheng@627 9618 "out."
dongsheng@627 9619 msgstr ""
dongsheng@627 9620
dongsheng@627 9621 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
songdongsheng@658 9622 #: ../en/ch08-undo.xml:421
dongsheng@627 9623 msgid "Always use the <option role=\"hg-opt-backout\">--merge</option> option"
dongsheng@635 9624 msgstr "始终使用选项 <option role=\"hg-opt-backout\">--merge</option>"
dongsheng@627 9625
dongsheng@627 9626 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@658 9627 #: ../en/ch08-undo.xml:424
dongsheng@627 9628 msgid ""
dongsheng@627 9629 "In fact, since the <option role=\"hg-opt-backout\">--merge</option> option "
dongsheng@627 9630 "will do the <quote>right thing</quote> whether or not the changeset you're "
dongsheng@627 9631 "backing out is the tip (i.e. it won't try to merge if it's backing out the "
dongsheng@627 9632 "tip, since there's no need), you should <emphasis>always</emphasis> use this "
dongsheng@627 9633 "option when you run the <command role=\"hg-cmd\">hg backout</command> command."
dongsheng@627 9634 msgstr ""
dongsheng@627 9635
dongsheng@627 9636 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 9637 #: ../en/ch08-undo.xml:435
dongsheng@627 9638 msgid "Gaining more control of the backout process"
dongsheng@635 9639 msgstr "在恢复处理中获得更多控制"
dongsheng@627 9640
dongsheng@627 9641 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 9642 #: ../en/ch08-undo.xml:437
dongsheng@627 9643 msgid ""
dongsheng@627 9644 "While I've recommended that you always use the <option role=\"hg-opt-backout"
dongsheng@627 9645 "\">--merge</option> option when backing out a change, the <command role=\"hg-"
dongsheng@627 9646 "cmd\">hg backout</command> command lets you decide how to merge a backout "
dongsheng@627 9647 "changeset. Taking control of the backout process by hand is something you "
dongsheng@627 9648 "will rarely need to do, but it can be useful to understand what the <command "
dongsheng@627 9649 "role=\"hg-cmd\">hg backout</command> command is doing for you automatically. "
dongsheng@627 9650 "To illustrate this, let's clone our first repository, but omit the backout "
dongsheng@627 9651 "change that it contains."
dongsheng@627 9652 msgstr ""
dongsheng@627 9653
dongsheng@627 9654 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 9655 #: ../en/ch08-undo.xml:450
dongsheng@627 9656 msgid ""
dongsheng@627 9657 "As with our earlier example, We'll commit a third changeset, then back out "
dongsheng@627 9658 "its parent, and see what happens."
dongsheng@627 9659 msgstr ""
dongsheng@627 9660
dongsheng@627 9661 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 9662 #: ../en/ch08-undo.xml:456
dongsheng@627 9663 msgid ""
dongsheng@627 9664 "Our new changeset is again a descendant of the changeset we backout out; it's "
dongsheng@627 9665 "thus a new head, <emphasis>not</emphasis> a descendant of the changeset that "
dongsheng@627 9666 "was the tip. The <command role=\"hg-cmd\">hg backout</command> command was "
dongsheng@627 9667 "quite explicit in telling us this."
dongsheng@627 9668 msgstr ""
dongsheng@627 9669
dongsheng@627 9670 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 9671 #: ../en/ch08-undo.xml:464
dongsheng@627 9672 msgid ""
dongsheng@627 9673 "Again, it's easier to see what has happened by looking at a graph of the "
songdongsheng@658 9674 "revision history, in <xref linkend=\"fig:undo:backout-manual\"/>. This makes "
songdongsheng@658 9675 "it clear that when we use <command role=\"hg-cmd\">hg backout</command> to "
songdongsheng@658 9676 "back out a change other than the tip, Mercurial adds a new head to the "
songdongsheng@658 9677 "repository (the change it committed is box-shaped)."
songdongsheng@658 9678 msgstr ""
songdongsheng@658 9679
songdongsheng@658 9680 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
songdongsheng@658 9681 #: ../en/ch08-undo.xml:476
songdongsheng@658 9682 msgid "<imageobject><imagedata fileref=\"figs/undo-manual.png\"/></imageobject>"
songdongsheng@658 9683 msgstr ""
songdongsheng@658 9684
songdongsheng@658 9685 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 9686 #: ../en/ch08-undo.xml:481
dongsheng@627 9687 msgid ""
dongsheng@627 9688 "After the <command role=\"hg-cmd\">hg backout</command> command has "
dongsheng@627 9689 "completed, it leaves the new <quote>backout</quote> changeset as the parent "
dongsheng@627 9690 "of the working directory."
dongsheng@627 9691 msgstr ""
dongsheng@627 9692
dongsheng@627 9693 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 9694 #: ../en/ch08-undo.xml:488
dongsheng@627 9695 msgid "Now we have two isolated sets of changes."
dongsheng@627 9696 msgstr ""
dongsheng@627 9697
dongsheng@627 9698 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 9699 #: ../en/ch08-undo.xml:492
dongsheng@627 9700 msgid ""
dongsheng@627 9701 "Let's think about what we expect to see as the contents of <filename>myfile</"
dongsheng@627 9702 "filename> now. The first change should be present, because we've never "
dongsheng@627 9703 "backed it out. The second change should be missing, as that's the change we "
dongsheng@627 9704 "backed out. Since the history graph shows the third change as a separate "
dongsheng@627 9705 "head, we <emphasis>don't</emphasis> expect to see the third change present in "
dongsheng@627 9706 "<filename>myfile</filename>."
dongsheng@627 9707 msgstr ""
dongsheng@627 9708
dongsheng@627 9709 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 9710 #: ../en/ch08-undo.xml:502
dongsheng@627 9711 msgid ""
dongsheng@627 9712 "To get the third change back into the file, we just do a normal merge of our "
dongsheng@627 9713 "two heads."
dongsheng@627 9714 msgstr ""
dongsheng@627 9715
dongsheng@627 9716 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 9717 #: ../en/ch08-undo.xml:507
songdongsheng@658 9718 msgid ""
songdongsheng@658 9719 "Afterwards, the graphical history of our repository looks like <xref linkend="
songdongsheng@658 9720 "\"fig:undo:backout-manual-merge\"/>."
songdongsheng@658 9721 msgstr ""
songdongsheng@658 9722
songdongsheng@658 9723 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
songdongsheng@658 9724 #: ../en/ch08-undo.xml:512
dongsheng@627 9725 msgid "Manually merging a backout change"
dongsheng@660 9726 msgstr "手工合并恢复修改"
dongsheng@627 9727
songdongsheng@658 9728 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
songdongsheng@658 9729 #: ../en/ch08-undo.xml:514
songdongsheng@658 9730 msgid ""
songdongsheng@658 9731 "<imageobject><imagedata fileref=\"figs/undo-manual-merge.png\"/></imageobject>"
songdongsheng@658 9732 msgstr ""
songdongsheng@658 9733
dongsheng@627 9734 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 9735 #: ../en/ch08-undo.xml:521
dongsheng@627 9736 msgid "Why <command role=\"hg-cmd\">hg backout</command> works as it does"
dongsheng@635 9737 msgstr "<command role=\"hg-cmd\">hg backout</command> 的内幕"
dongsheng@627 9738
dongsheng@627 9739 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 9740 #: ../en/ch08-undo.xml:524
dongsheng@627 9741 msgid ""
dongsheng@627 9742 "Here's a brief description of how the <command role=\"hg-cmd\">hg backout</"
dongsheng@627 9743 "command> command works."
dongsheng@627 9744 msgstr ""
dongsheng@627 9745
dongsheng@627 9746 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
songdongsheng@658 9747 #: ../en/ch08-undo.xml:527
dongsheng@627 9748 msgid ""
dongsheng@627 9749 "It ensures that the working directory is <quote>clean</quote>, i.e. that the "
dongsheng@627 9750 "output of <command role=\"hg-cmd\">hg status</command> would be empty."
dongsheng@627 9751 msgstr ""
dongsheng@627 9752
dongsheng@627 9753 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
songdongsheng@658 9754 #: ../en/ch08-undo.xml:531
dongsheng@627 9755 msgid ""
dongsheng@627 9756 "It remembers the current parent of the working directory. Let's call this "
dongsheng@627 9757 "changeset <literal>orig</literal>"
dongsheng@627 9758 msgstr ""
dongsheng@627 9759
dongsheng@627 9760 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
songdongsheng@658 9761 #: ../en/ch08-undo.xml:535
dongsheng@627 9762 msgid ""
dongsheng@627 9763 "It does the equivalent of a <command role=\"hg-cmd\">hg update</command> to "
dongsheng@627 9764 "sync the working directory to the changeset you want to back out. Let's call "
dongsheng@627 9765 "this changeset <literal>backout</literal>"
dongsheng@627 9766 msgstr ""
dongsheng@627 9767
dongsheng@627 9768 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
songdongsheng@658 9769 #: ../en/ch08-undo.xml:540
dongsheng@627 9770 msgid ""
dongsheng@627 9771 "It finds the parent of that changeset. Let's call that changeset "
dongsheng@627 9772 "<literal>parent</literal>."
dongsheng@627 9773 msgstr ""
dongsheng@627 9774
dongsheng@627 9775 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
songdongsheng@658 9776 #: ../en/ch08-undo.xml:543
dongsheng@627 9777 msgid ""
dongsheng@627 9778 "For each file that the <literal>backout</literal> changeset affected, it does "
dongsheng@627 9779 "the equivalent of a <command role=\"hg-cmd\">hg revert -r parent</command> on "
dongsheng@627 9780 "that file, to restore it to the contents it had before that changeset was "
dongsheng@627 9781 "committed."
dongsheng@627 9782 msgstr ""
dongsheng@627 9783
dongsheng@627 9784 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
songdongsheng@658 9785 #: ../en/ch08-undo.xml:550
dongsheng@627 9786 msgid ""
dongsheng@627 9787 "It commits the result as a new changeset. This changeset has "
dongsheng@627 9788 "<literal>backout</literal> as its parent."
dongsheng@627 9789 msgstr ""
dongsheng@627 9790
dongsheng@627 9791 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
songdongsheng@658 9792 #: ../en/ch08-undo.xml:554
dongsheng@627 9793 msgid ""
dongsheng@627 9794 "If you specify <option role=\"hg-opt-backout\">--merge</option> on the "
dongsheng@627 9795 "command line, it merges with <literal>orig</literal>, and commits the result "
dongsheng@627 9796 "of the merge."
dongsheng@627 9797 msgstr ""
dongsheng@627 9798
dongsheng@627 9799 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 9800 #: ../en/ch08-undo.xml:560
dongsheng@627 9801 msgid ""
dongsheng@627 9802 "An alternative way to implement the <command role=\"hg-cmd\">hg backout</"
dongsheng@627 9803 "command> command would be to <command role=\"hg-cmd\">hg export</command> the "
dongsheng@627 9804 "to-be-backed-out changeset as a diff, then use the <option role=\"cmd-opt-"
dongsheng@627 9805 "patch\">--reverse</option> option to the <command>patch</command> command to "
dongsheng@627 9806 "reverse the effect of the change without fiddling with the working "
dongsheng@627 9807 "directory. This sounds much simpler, but it would not work nearly as well."
dongsheng@627 9808 msgstr ""
dongsheng@627 9809
dongsheng@627 9810 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 9811 #: ../en/ch08-undo.xml:570
dongsheng@627 9812 msgid ""
dongsheng@627 9813 "The reason that <command role=\"hg-cmd\">hg backout</command> does an update, "
dongsheng@627 9814 "a commit, a merge, and another commit is to give the merge machinery the best "
dongsheng@627 9815 "chance to do a good job when dealing with all the changes <emphasis>between</"
dongsheng@627 9816 "emphasis> the change you're backing out and the current tip."
dongsheng@627 9817 msgstr ""
dongsheng@627 9818
dongsheng@627 9819 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 9820 #: ../en/ch08-undo.xml:577
dongsheng@627 9821 msgid ""
dongsheng@627 9822 "If you're backing out a changeset that's 100 revisions back in your project's "
dongsheng@627 9823 "history, the chances that the <command>patch</command> command will be able "
dongsheng@627 9824 "to apply a reverse diff cleanly are not good, because intervening changes are "
dongsheng@627 9825 "likely to have <quote>broken the context</quote> that <command>patch</"
dongsheng@627 9826 "command> uses to determine whether it can apply a patch (if this sounds like "
songdongsheng@658 9827 "gibberish, see <xref linkend=\"sec:mq:patch\"/> for a discussion of the "
dongsheng@627 9828 "<command>patch</command> command). Also, Mercurial's merge machinery will "
dongsheng@627 9829 "handle files and directories being renamed, permission changes, and "
dongsheng@627 9830 "modifications to binary files, none of which <command>patch</command> can "
dongsheng@627 9831 "deal with."
dongsheng@627 9832 msgstr ""
dongsheng@627 9833
dongsheng@627 9834 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@658 9835 #: ../en/ch08-undo.xml:594
dongsheng@627 9836 msgid "Changes that should never have been"
dongsheng@635 9837 msgstr "不该发生的修改"
dongsheng@627 9838
dongsheng@627 9839 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 9840 #: ../en/ch08-undo.xml:596
dongsheng@627 9841 msgid ""
dongsheng@627 9842 "Most of the time, the <command role=\"hg-cmd\">hg backout</command> command "
dongsheng@627 9843 "is exactly what you need if you want to undo the effects of a change. It "
dongsheng@627 9844 "leaves a permanent record of exactly what you did, both when committing the "
dongsheng@627 9845 "original changeset and when you cleaned up after it."
dongsheng@627 9846 msgstr ""
dongsheng@627 9847
dongsheng@627 9848 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 9849 #: ../en/ch08-undo.xml:602
dongsheng@627 9850 msgid ""
dongsheng@627 9851 "On rare occasions, though, you may find that you've committed a change that "
dongsheng@627 9852 "really should not be present in the repository at all. For example, it would "
dongsheng@627 9853 "be very unusual, and usually considered a mistake, to commit a software "
dongsheng@627 9854 "project's object files as well as its source files. Object files have almost "
dongsheng@627 9855 "no intrinsic value, and they're <emphasis>big</emphasis>, so they increase "
dongsheng@627 9856 "the size of the repository and the amount of time it takes to clone or pull "
dongsheng@627 9857 "changes."
dongsheng@627 9858 msgstr ""
dongsheng@627 9859
dongsheng@627 9860 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 9861 #: ../en/ch08-undo.xml:611
dongsheng@627 9862 msgid ""
dongsheng@627 9863 "Before I discuss the options that you have if you commit a <quote>brown paper "
dongsheng@627 9864 "bag</quote> change (the kind that's so bad that you want to pull a brown "
dongsheng@627 9865 "paper bag over your head), let me first discuss some approaches that probably "
dongsheng@627 9866 "won't work."
dongsheng@627 9867 msgstr ""
dongsheng@627 9868
dongsheng@627 9869 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 9870 #: ../en/ch08-undo.xml:616
dongsheng@627 9871 msgid ""
songdongsheng@668 9872 "Since Mercurial treats history as accumulative&emdash;every change builds on "
songdongsheng@668 9873 "top of all changes that preceded it&emdash;you generally can't just make "
songdongsheng@668 9874 "disastrous changes disappear. The one exception is when you've just "
songdongsheng@668 9875 "committed a change, and it hasn't been pushed or pulled into another "
songdongsheng@668 9876 "repository. That's when you can safely use the <command role=\"hg-cmd\">hg "
songdongsheng@668 9877 "rollback</command> command, as I detailed in <xref linkend=\"sec:undo:rollback"
songdongsheng@668 9878 "\"/>."
songdongsheng@658 9879 msgstr ""
songdongsheng@658 9880
songdongsheng@658 9881 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 9882 #: ../en/ch08-undo.xml:625
dongsheng@627 9883 msgid ""
dongsheng@627 9884 "After you've pushed a bad change to another repository, you <emphasis>could</"
dongsheng@627 9885 "emphasis> still use <command role=\"hg-cmd\">hg rollback</command> to make "
dongsheng@627 9886 "your local copy of the change disappear, but it won't have the consequences "
dongsheng@627 9887 "you want. The change will still be present in the remote repository, so it "
dongsheng@627 9888 "will reappear in your local repository the next time you pull."
dongsheng@627 9889 msgstr ""
dongsheng@627 9890
dongsheng@627 9891 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 9892 #: ../en/ch08-undo.xml:633
dongsheng@627 9893 msgid ""
dongsheng@627 9894 "If a situation like this arises, and you know which repositories your bad "
dongsheng@627 9895 "change has propagated into, you can <emphasis>try</emphasis> to get rid of "
dongsheng@627 9896 "the changeefrom <emphasis>every</emphasis> one of those repositories. This "
dongsheng@627 9897 "is, of course, not a satisfactory solution: if you miss even a single "
dongsheng@627 9898 "repository while you're expunging, the change is still <quote>in the wild</"
dongsheng@627 9899 "quote>, and could propagate further."
dongsheng@627 9900 msgstr ""
dongsheng@627 9901
dongsheng@627 9902 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 9903 #: ../en/ch08-undo.xml:641
dongsheng@627 9904 msgid ""
dongsheng@627 9905 "If you've committed one or more changes <emphasis>after</emphasis> the change "
dongsheng@627 9906 "that you'd like to see disappear, your options are further reduced. Mercurial "
dongsheng@627 9907 "doesn't provide a way to <quote>punch a hole</quote> in history, leaving "
dongsheng@627 9908 "changesets intact."
dongsheng@627 9909 msgstr ""
dongsheng@627 9910
dongsheng@627 9911 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 9912 #: ../en/ch08-undo.xml:647
dongsheng@627 9913 msgid ""
dongsheng@627 9914 "XXX This needs filling out. The <literal>hg-replay</literal> script in the "
dongsheng@627 9915 "<literal>examples</literal> directory works, but doesn't handle merge "
dongsheng@627 9916 "changesets. Kind of an important omission."
dongsheng@627 9917 msgstr ""
dongsheng@627 9918
dongsheng@627 9919 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 9920 #: ../en/ch08-undo.xml:653
dongsheng@627 9921 msgid "Protect yourself from <quote>escaped</quote> changes"
dongsheng@635 9922 msgstr "使用<quote>校验</quote>修改来保护你自己"
dongsheng@627 9923
dongsheng@627 9924 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 9925 #: ../en/ch08-undo.xml:656
dongsheng@627 9926 msgid ""
dongsheng@627 9927 "If you've committed some changes to your local repository and they've been "
dongsheng@627 9928 "pushed or pulled somewhere else, this isn't necessarily a disaster. You can "
dongsheng@627 9929 "protect yourself ahead of time against some classes of bad changeset. This "
dongsheng@627 9930 "is particularly easy if your team usually pulls changes from a central "
dongsheng@627 9931 "repository."
dongsheng@627 9932 msgstr ""
dongsheng@627 9933
dongsheng@627 9934 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 9935 #: ../en/ch08-undo.xml:663
dongsheng@627 9936 msgid ""
dongsheng@627 9937 "By configuring some hooks on that repository to validate incoming changesets "
songdongsheng@658 9938 "(see chapter <xref linkend=\"chap:hook\"/>), you can automatically prevent "
dongsheng@627 9939 "some kinds of bad changeset from being pushed to the central repository at "
dongsheng@627 9940 "all. With such a configuration in place, some kinds of bad changeset will "
dongsheng@627 9941 "naturally tend to <quote>die out</quote> because they can't propagate into "
dongsheng@627 9942 "the central repository. Better yet, this happens without any need for "
dongsheng@627 9943 "explicit intervention."
dongsheng@627 9944 msgstr ""
dongsheng@627 9945
dongsheng@627 9946 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 9947 #: ../en/ch08-undo.xml:673
dongsheng@627 9948 msgid ""
dongsheng@627 9949 "For instance, an incoming change hook that verifies that a changeset will "
dongsheng@627 9950 "actually compile can prevent people from inadvertantly <quote>breaking the "
dongsheng@627 9951 "build</quote>."
dongsheng@627 9952 msgstr ""
dongsheng@627 9953
dongsheng@627 9954 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@658 9955 #: ../en/ch08-undo.xml:680
dongsheng@627 9956 msgid "Finding the source of a bug"
dongsheng@635 9957 msgstr "查找问题的根源"
dongsheng@627 9958
dongsheng@627 9959 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 9960 #: ../en/ch08-undo.xml:682
dongsheng@627 9961 msgid ""
dongsheng@627 9962 "While it's all very well to be able to back out a changeset that introduced a "
dongsheng@627 9963 "bug, this requires that you know which changeset to back out. Mercurial "
dongsheng@627 9964 "provides an invaluable command, called <command role=\"hg-cmd\">hg bisect</"
dongsheng@627 9965 "command>, that helps you to automate this process and accomplish it very "
dongsheng@627 9966 "efficiently."
dongsheng@627 9967 msgstr ""
dongsheng@627 9968
dongsheng@627 9969 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 9970 #: ../en/ch08-undo.xml:689
dongsheng@627 9971 msgid ""
dongsheng@627 9972 "The idea behind the <command role=\"hg-cmd\">hg bisect</command> command is "
songdongsheng@710 9973 "that a changeset has introduced some change of behavior that you can identify "
songdongsheng@710 9974 "with a simple binary test. You don't know which piece of code introduced the "
songdongsheng@710 9975 "change, but you know how to test for the presence of the bug. The <command "
songdongsheng@710 9976 "role=\"hg-cmd\">hg bisect</command> command uses your test to direct its "
songdongsheng@710 9977 "search for the changeset that introduced the code that caused the bug."
dongsheng@627 9978 msgstr ""
dongsheng@627 9979
dongsheng@627 9980 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 9981 #: ../en/ch08-undo.xml:698
dongsheng@627 9982 msgid ""
dongsheng@627 9983 "Here are a few scenarios to help you understand how you might apply this "
dongsheng@627 9984 "command."
dongsheng@627 9985 msgstr ""
dongsheng@627 9986
dongsheng@627 9987 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 9988 #: ../en/ch08-undo.xml:701
dongsheng@627 9989 msgid ""
dongsheng@627 9990 "The most recent version of your software has a bug that you remember wasn't "
dongsheng@627 9991 "present a few weeks ago, but you don't know when it was introduced. Here, "
dongsheng@627 9992 "your binary test checks for the presence of that bug."
dongsheng@627 9993 msgstr ""
dongsheng@627 9994
dongsheng@627 9995 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 9996 #: ../en/ch08-undo.xml:706
dongsheng@627 9997 msgid ""
dongsheng@627 9998 "You fixed a bug in a rush, and now it's time to close the entry in your "
dongsheng@627 9999 "team's bug database. The bug database requires a changeset ID when you close "
dongsheng@627 10000 "an entry, but you don't remember which changeset you fixed the bug in. Once "
dongsheng@627 10001 "again, your binary test checks for the presence of the bug."
dongsheng@627 10002 msgstr ""
dongsheng@627 10003
dongsheng@627 10004 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 10005 #: ../en/ch08-undo.xml:713
dongsheng@627 10006 msgid ""
dongsheng@627 10007 "Your software works correctly, but runs 15% slower than the last time you "
dongsheng@627 10008 "measured it. You want to know which changeset introduced the performance "
dongsheng@627 10009 "regression. In this case, your binary test measures the performance of your "
dongsheng@627 10010 "software, to see whether it's <quote>fast</quote> or <quote>slow</quote>."
dongsheng@627 10011 msgstr ""
dongsheng@627 10012
dongsheng@627 10013 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 10014 #: ../en/ch08-undo.xml:720
dongsheng@627 10015 msgid ""
dongsheng@627 10016 "The sizes of the components of your project that you ship exploded recently, "
dongsheng@627 10017 "and you suspect that something changed in the way you build your project."
dongsheng@627 10018 msgstr ""
dongsheng@627 10019
dongsheng@627 10020 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 10021 #: ../en/ch08-undo.xml:725
dongsheng@627 10022 msgid ""
dongsheng@627 10023 "From these examples, it should be clear that the <command role=\"hg-cmd\">hg "
dongsheng@627 10024 "bisect</command> command is not useful only for finding the sources of bugs. "
dongsheng@627 10025 "You can use it to find any <quote>emergent property</quote> of a repository "
dongsheng@627 10026 "(anything that you can't find from a simple text search of the files in the "
dongsheng@627 10027 "tree) for which you can write a binary test."
dongsheng@627 10028 msgstr ""
dongsheng@627 10029
dongsheng@627 10030 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 10031 #: ../en/ch08-undo.xml:732
dongsheng@627 10032 msgid ""
dongsheng@627 10033 "We'll introduce a little bit of terminology here, just to make it clear which "
dongsheng@627 10034 "parts of the search process are your responsibility, and which are "
dongsheng@627 10035 "Mercurial's. A <emphasis>test</emphasis> is something that <emphasis>you</"
dongsheng@627 10036 "emphasis> run when <command role=\"hg-cmd\">hg bisect</command> chooses a "
dongsheng@627 10037 "changeset. A <emphasis>probe</emphasis> is what <command role=\"hg-cmd\">hg "
dongsheng@627 10038 "bisect</command> runs to tell whether a revision is good. Finally, we'll use "
dongsheng@627 10039 "the word <quote>bisect</quote>, as both a noun and a verb, to stand in for "
dongsheng@627 10040 "the phrase <quote>search using the <command role=\"hg-cmd\">hg bisect</"
dongsheng@627 10041 "command> command</quote>."
dongsheng@627 10042 msgstr ""
dongsheng@627 10043
dongsheng@627 10044 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 10045 #: ../en/ch08-undo.xml:745
dongsheng@627 10046 msgid ""
dongsheng@627 10047 "One simple way to automate the searching process would be simply to probe "
dongsheng@627 10048 "every changeset. However, this scales poorly. If it took ten minutes to "
dongsheng@627 10049 "test a single changeset, and you had 10,000 changesets in your repository, "
dongsheng@627 10050 "the exhaustive approach would take on average 35 <emphasis>days</emphasis> to "
dongsheng@627 10051 "find the changeset that introduced a bug. Even if you knew that the bug was "
dongsheng@627 10052 "introduced by one of the last 500 changesets, and limited your search to "
dongsheng@627 10053 "those, you'd still be looking at over 40 hours to find the changeset that "
dongsheng@627 10054 "introduced your bug."
dongsheng@627 10055 msgstr ""
dongsheng@627 10056
dongsheng@627 10057 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 10058 #: ../en/ch08-undo.xml:755
dongsheng@627 10059 msgid ""
dongsheng@627 10060 "What the <command role=\"hg-cmd\">hg bisect</command> command does is use its "
dongsheng@627 10061 "knowledge of the <quote>shape</quote> of your project's revision history to "
dongsheng@627 10062 "perform a search in time proportional to the <emphasis>logarithm</emphasis> "
dongsheng@627 10063 "of the number of changesets to check (the kind of search it performs is "
dongsheng@627 10064 "called a dichotomic search). With this approach, searching through 10,000 "
dongsheng@627 10065 "changesets will take less than three hours, even at ten minutes per test (the "
dongsheng@627 10066 "search will require about 14 tests). Limit your search to the last hundred "
dongsheng@627 10067 "changesets, and it will take only about an hour (roughly seven tests)."
dongsheng@627 10068 msgstr ""
dongsheng@627 10069
dongsheng@627 10070 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 10071 #: ../en/ch08-undo.xml:766
dongsheng@627 10072 msgid ""
dongsheng@627 10073 "The <command role=\"hg-cmd\">hg bisect</command> command is aware of the "
dongsheng@627 10074 "<quote>branchy</quote> nature of a Mercurial project's revision history, so "
dongsheng@627 10075 "it has no problems dealing with branches, merges, or multiple heads in a "
dongsheng@627 10076 "repository. It can prune entire branches of history with a single probe, "
dongsheng@627 10077 "which is how it operates so efficiently."
dongsheng@627 10078 msgstr ""
dongsheng@627 10079
dongsheng@627 10080 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 10081 #: ../en/ch08-undo.xml:774
dongsheng@627 10082 msgid "Using the <command role=\"hg-cmd\">hg bisect</command> command"
dongsheng@635 10083 msgstr "使用命令 <command role=\"hg-cmd\">hg bisect</command>"
dongsheng@627 10084
dongsheng@627 10085 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10086 #: ../en/ch08-undo.xml:777
dongsheng@627 10087 msgid ""
dongsheng@627 10088 "Here's an example of <command role=\"hg-cmd\">hg bisect</command> in action."
dongsheng@627 10089 msgstr ""
dongsheng@627 10090
dongsheng@627 10091 #. type: Content of: <book><chapter><sect1><sect2><note><para>
songdongsheng@658 10092 #: ../en/ch08-undo.xml:781
dongsheng@627 10093 msgid ""
dongsheng@627 10094 "In versions 0.9.5 and earlier of Mercurial, <command role=\"hg-cmd\">hg "
dongsheng@627 10095 "bisect</command> was not a core command: it was distributed with Mercurial as "
dongsheng@627 10096 "an extension. This section describes the built-in command, not the old "
dongsheng@627 10097 "extension."
dongsheng@627 10098 msgstr ""
dongsheng@627 10099
dongsheng@627 10100 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10101 #: ../en/ch08-undo.xml:788
dongsheng@627 10102 msgid ""
dongsheng@627 10103 "Now let's create a repository, so that we can try out the <command role=\"hg-"
dongsheng@627 10104 "cmd\">hg bisect</command> command in isolation."
dongsheng@627 10105 msgstr ""
dongsheng@627 10106
dongsheng@627 10107 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10108 #: ../en/ch08-undo.xml:794
dongsheng@627 10109 msgid ""
dongsheng@627 10110 "We'll simulate a project that has a bug in it in a simple-minded way: create "
dongsheng@627 10111 "trivial changes in a loop, and nominate one specific change that will have "
dongsheng@627 10112 "the <quote>bug</quote>. This loop creates 35 changesets, each adding a "
dongsheng@627 10113 "single file to the repository. We'll represent our <quote>bug</quote> with a "
dongsheng@627 10114 "file that contains the text <quote>i have a gub</quote>."
dongsheng@627 10115 msgstr ""
dongsheng@627 10116
dongsheng@627 10117 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10118 #: ../en/ch08-undo.xml:804
dongsheng@627 10119 msgid ""
dongsheng@627 10120 "The next thing that we'd like to do is figure out how to use the <command "
dongsheng@627 10121 "role=\"hg-cmd\">hg bisect</command> command. We can use Mercurial's normal "
dongsheng@627 10122 "built-in help mechanism for this."
dongsheng@627 10123 msgstr ""
dongsheng@627 10124
dongsheng@627 10125 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10126 #: ../en/ch08-undo.xml:811
dongsheng@627 10127 msgid ""
dongsheng@627 10128 "The <command role=\"hg-cmd\">hg bisect</command> command works in steps. "
dongsheng@627 10129 "Each step proceeds as follows."
dongsheng@627 10130 msgstr ""
dongsheng@627 10131
dongsheng@627 10132 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
songdongsheng@658 10133 #: ../en/ch08-undo.xml:814
dongsheng@627 10134 msgid "You run your binary test."
dongsheng@627 10135 msgstr ""
dongsheng@627 10136
dongsheng@627 10137 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><itemizedlist><listitem><para>
songdongsheng@658 10138 #: ../en/ch08-undo.xml:816
dongsheng@627 10139 msgid ""
dongsheng@627 10140 "If the test succeeded, you tell <command role=\"hg-cmd\">hg bisect</command> "
dongsheng@627 10141 "by running the <command role=\"hg-cmd\">hg bisect good</command> command."
dongsheng@627 10142 msgstr ""
dongsheng@627 10143
dongsheng@627 10144 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><itemizedlist><listitem><para>
songdongsheng@658 10145 #: ../en/ch08-undo.xml:821
dongsheng@627 10146 msgid ""
dongsheng@627 10147 "If it failed, run the <command role=\"hg-cmd\">hg bisect bad</command> "
dongsheng@627 10148 "command."
dongsheng@627 10149 msgstr ""
dongsheng@627 10150
dongsheng@627 10151 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
songdongsheng@658 10152 #: ../en/ch08-undo.xml:825
dongsheng@627 10153 msgid ""
dongsheng@627 10154 "The command uses your information to decide which changeset to test next."
dongsheng@627 10155 msgstr ""
dongsheng@627 10156
dongsheng@627 10157 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
songdongsheng@658 10158 #: ../en/ch08-undo.xml:828
dongsheng@627 10159 msgid ""
dongsheng@627 10160 "It updates the working directory to that changeset, and the process begins "
dongsheng@627 10161 "again."
dongsheng@627 10162 msgstr ""
dongsheng@627 10163
dongsheng@627 10164 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10165 #: ../en/ch08-undo.xml:831
dongsheng@627 10166 msgid ""
dongsheng@627 10167 "The process ends when <command role=\"hg-cmd\">hg bisect</command> identifies "
dongsheng@627 10168 "a unique changeset that marks the point where your test transitioned from "
dongsheng@627 10169 "<quote>succeeding</quote> to <quote>failing</quote>."
dongsheng@627 10170 msgstr ""
dongsheng@627 10171
dongsheng@627 10172 #
dongsheng@627 10173 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10174 #: ../en/ch08-undo.xml:836
dongsheng@627 10175 msgid ""
dongsheng@627 10176 "To start the search, we must run the <command role=\"hg-cmd\">hg bisect --"
dongsheng@627 10177 "reset</command> command."
dongsheng@627 10178 msgstr ""
dongsheng@627 10179
dongsheng@627 10180 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10181 #: ../en/ch08-undo.xml:841
dongsheng@627 10182 msgid ""
dongsheng@627 10183 "In our case, the binary test we use is simple: we check to see if any file in "
dongsheng@627 10184 "the repository contains the string <quote>i have a gub</quote>. If it does, "
dongsheng@627 10185 "this changeset contains the change that <quote>caused the bug</quote>. By "
dongsheng@627 10186 "convention, a changeset that has the property we're searching for is "
dongsheng@627 10187 "<quote>bad</quote>, while one that doesn't is <quote>good</quote>."
dongsheng@627 10188 msgstr ""
dongsheng@627 10189
dongsheng@627 10190 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10191 #: ../en/ch08-undo.xml:849
dongsheng@627 10192 msgid ""
dongsheng@627 10193 "Most of the time, the revision to which the working directory is synced "
dongsheng@627 10194 "(usually the tip) already exhibits the problem introduced by the buggy "
dongsheng@627 10195 "change, so we'll mark it as <quote>bad</quote>."
dongsheng@627 10196 msgstr ""
dongsheng@627 10197
dongsheng@627 10198 #
dongsheng@627 10199 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10200 #: ../en/ch08-undo.xml:856
dongsheng@627 10201 msgid ""
dongsheng@627 10202 "Our next task is to nominate a changeset that we know <emphasis>doesn't</"
dongsheng@627 10203 "emphasis> have the bug; the <command role=\"hg-cmd\">hg bisect</command> "
dongsheng@627 10204 "command will <quote>bracket</quote> its search between the first pair of good "
dongsheng@627 10205 "and bad changesets. In our case, we know that revision 10 didn't have the "
dongsheng@627 10206 "bug. (I'll have more words about choosing the first <quote>good</quote> "
dongsheng@627 10207 "changeset later.)"
dongsheng@627 10208 msgstr ""
dongsheng@627 10209
dongsheng@627 10210 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10211 #: ../en/ch08-undo.xml:866
dongsheng@627 10212 msgid "Notice that this command printed some output."
dongsheng@627 10213 msgstr ""
dongsheng@627 10214
dongsheng@627 10215 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 10216 #: ../en/ch08-undo.xml:868
dongsheng@627 10217 msgid ""
dongsheng@627 10218 "It told us how many changesets it must consider before it can identify the "
dongsheng@627 10219 "one that introduced the bug, and how many tests that will require."
dongsheng@627 10220 msgstr ""
dongsheng@627 10221
dongsheng@627 10222 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 10223 #: ../en/ch08-undo.xml:872
dongsheng@627 10224 msgid ""
dongsheng@627 10225 "It updated the working directory to the next changeset to test, and told us "
dongsheng@627 10226 "which changeset it's testing."
dongsheng@627 10227 msgstr ""
dongsheng@627 10228
dongsheng@627 10229 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10230 #: ../en/ch08-undo.xml:877
dongsheng@627 10231 msgid ""
dongsheng@627 10232 "We now run our test in the working directory. We use the <command>grep</"
dongsheng@627 10233 "command> command to see if our <quote>bad</quote> file is present in the "
dongsheng@627 10234 "working directory. If it is, this revision is bad; if not, this revision is "
dongsheng@627 10235 "good. &interaction.bisect.search.step1;"
dongsheng@627 10236 msgstr ""
dongsheng@627 10237
dongsheng@627 10238 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10239 #: ../en/ch08-undo.xml:883
dongsheng@627 10240 msgid ""
dongsheng@627 10241 "This test looks like a perfect candidate for automation, so let's turn it "
dongsheng@627 10242 "into a shell function."
dongsheng@627 10243 msgstr ""
dongsheng@627 10244
dongsheng@627 10245 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10246 #: ../en/ch08-undo.xml:887
dongsheng@627 10247 msgid ""
dongsheng@627 10248 "We can now run an entire test step with a single command, <literal>mytest</"
dongsheng@627 10249 "literal>."
dongsheng@627 10250 msgstr ""
dongsheng@627 10251
dongsheng@627 10252 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10253 #: ../en/ch08-undo.xml:892
dongsheng@627 10254 msgid "A few more invocations of our canned test step command, and we're done."
dongsheng@627 10255 msgstr ""
dongsheng@627 10256
dongsheng@627 10257 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10258 #: ../en/ch08-undo.xml:897
dongsheng@627 10259 msgid ""
dongsheng@627 10260 "Even though we had 40 changesets to search through, the <command role=\"hg-cmd"
dongsheng@627 10261 "\">hg bisect</command> command let us find the changeset that introduced our "
dongsheng@627 10262 "<quote>bug</quote> with only five tests. Because the number of tests that "
dongsheng@627 10263 "the <command role=\"hg-cmd\">hg bisect</command> command performs grows "
dongsheng@627 10264 "logarithmically with the number of changesets to search, the advantage that "
dongsheng@627 10265 "it has over the <quote>brute force</quote> search approach increases with "
dongsheng@627 10266 "every changeset you add."
dongsheng@627 10267 msgstr ""
dongsheng@627 10268
dongsheng@627 10269 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 10270 #: ../en/ch08-undo.xml:908
dongsheng@627 10271 msgid "Cleaning up after your search"
dongsheng@635 10272 msgstr "搜索后的清理"
dongsheng@627 10273
dongsheng@627 10274 #
dongsheng@627 10275 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10276 #: ../en/ch08-undo.xml:910
dongsheng@627 10277 msgid ""
dongsheng@627 10278 "When you're finished using the <command role=\"hg-cmd\">hg bisect</command> "
dongsheng@627 10279 "command in a repository, you can use the <command role=\"hg-cmd\">hg bisect "
dongsheng@627 10280 "reset</command> command to drop the information it was using to drive your "
dongsheng@627 10281 "search. The command doesn't use much space, so it doesn't matter if you "
dongsheng@627 10282 "forget to run this command. However, <command role=\"hg-cmd\">hg bisect</"
dongsheng@627 10283 "command> won't let you start a new search in that repository until you do a "
dongsheng@627 10284 "<command role=\"hg-cmd\">hg bisect reset</command>."
dongsheng@627 10285 msgstr ""
dongsheng@627 10286
dongsheng@627 10287 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@658 10288 #: ../en/ch08-undo.xml:925
dongsheng@627 10289 msgid "Tips for finding bugs effectively"
dongsheng@635 10290 msgstr "有效查找问题的技巧"
dongsheng@627 10291
dongsheng@627 10292 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 10293 #: ../en/ch08-undo.xml:928
dongsheng@627 10294 msgid "Give consistent input"
dongsheng@635 10295 msgstr "给出一致的输入"
dongsheng@627 10296
dongsheng@627 10297 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10298 #: ../en/ch08-undo.xml:930
dongsheng@627 10299 msgid ""
dongsheng@627 10300 "The <command role=\"hg-cmd\">hg bisect</command> command requires that you "
dongsheng@627 10301 "correctly report the result of every test you perform. If you tell it that a "
dongsheng@627 10302 "test failed when it really succeeded, it <emphasis>might</emphasis> be able "
dongsheng@627 10303 "to detect the inconsistency. If it can identify an inconsistency in your "
dongsheng@627 10304 "reports, it will tell you that a particular changeset is both good and bad. "
dongsheng@627 10305 "However, it can't do this perfectly; it's about as likely to report the wrong "
dongsheng@627 10306 "changeset as the source of the bug."
dongsheng@627 10307 msgstr ""
dongsheng@627 10308
dongsheng@627 10309 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 10310 #: ../en/ch08-undo.xml:942
dongsheng@627 10311 msgid "Automate as much as possible"
dongsheng@635 10312 msgstr "尽量自动"
dongsheng@627 10313
dongsheng@627 10314 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10315 #: ../en/ch08-undo.xml:944
dongsheng@627 10316 msgid ""
dongsheng@627 10317 "When I started using the <command role=\"hg-cmd\">hg bisect</command> "
dongsheng@627 10318 "command, I tried a few times to run my tests by hand, on the command line. "
dongsheng@627 10319 "This is an approach that I, at least, am not suited to. After a few tries, I "
dongsheng@627 10320 "found that I was making enough mistakes that I was having to restart my "
dongsheng@627 10321 "searches several times before finally getting correct results."
dongsheng@627 10322 msgstr ""
dongsheng@627 10323
dongsheng@627 10324 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10325 #: ../en/ch08-undo.xml:952
dongsheng@627 10326 msgid ""
dongsheng@627 10327 "My initial problems with driving the <command role=\"hg-cmd\">hg bisect</"
dongsheng@627 10328 "command> command by hand occurred even with simple searches on small "
dongsheng@627 10329 "repositories; if the problem you're looking for is more subtle, or the number "
dongsheng@627 10330 "of tests that <command role=\"hg-cmd\">hg bisect</command> must perform "
dongsheng@627 10331 "increases, the likelihood of operator error ruining the search is much "
dongsheng@627 10332 "higher. Once I started automating my tests, I had much better results."
dongsheng@627 10333 msgstr ""
dongsheng@627 10334
dongsheng@627 10335 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10336 #: ../en/ch08-undo.xml:961
dongsheng@627 10337 msgid "The key to automated testing is twofold:"
dongsheng@627 10338 msgstr ""
dongsheng@627 10339
dongsheng@627 10340 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 10341 #: ../en/ch08-undo.xml:963
dongsheng@627 10342 msgid "always test for the same symptom, and"
dongsheng@627 10343 msgstr ""
dongsheng@627 10344
dongsheng@627 10345 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 10346 #: ../en/ch08-undo.xml:965
dongsheng@627 10347 msgid ""
dongsheng@627 10348 "always feed consistent input to the <command role=\"hg-cmd\">hg bisect</"
dongsheng@627 10349 "command> command."
dongsheng@627 10350 msgstr ""
dongsheng@627 10351
dongsheng@627 10352 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10353 #: ../en/ch08-undo.xml:968
dongsheng@627 10354 msgid ""
dongsheng@627 10355 "In my tutorial example above, the <command>grep</command> command tests for "
dongsheng@627 10356 "the symptom, and the <literal>if</literal> statement takes the result of this "
dongsheng@627 10357 "check and ensures that we always feed the same input to the <command role="
dongsheng@627 10358 "\"hg-cmd\">hg bisect</command> command. The <literal>mytest</literal> "
dongsheng@627 10359 "function marries these together in a reproducible way, so that every test is "
dongsheng@627 10360 "uniform and consistent."
dongsheng@627 10361 msgstr ""
dongsheng@627 10362
dongsheng@627 10363 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 10364 #: ../en/ch08-undo.xml:978
dongsheng@627 10365 msgid "Check your results"
dongsheng@635 10366 msgstr "检查你的结果"
dongsheng@627 10367
dongsheng@627 10368 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10369 #: ../en/ch08-undo.xml:980
dongsheng@627 10370 msgid ""
dongsheng@627 10371 "Because the output of a <command role=\"hg-cmd\">hg bisect</command> search "
dongsheng@627 10372 "is only as good as the input you give it, don't take the changeset it reports "
dongsheng@627 10373 "as the absolute truth. A simple way to cross-check its report is to manually "
dongsheng@627 10374 "run your test at each of the following changesets:"
dongsheng@627 10375 msgstr ""
dongsheng@627 10376
dongsheng@627 10377 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 10378 #: ../en/ch08-undo.xml:986
dongsheng@627 10379 msgid ""
dongsheng@627 10380 "The changeset that it reports as the first bad revision. Your test should "
dongsheng@627 10381 "still report this as bad."
dongsheng@627 10382 msgstr ""
dongsheng@627 10383
dongsheng@627 10384 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 10385 #: ../en/ch08-undo.xml:990
dongsheng@627 10386 msgid ""
dongsheng@627 10387 "The parent of that changeset (either parent, if it's a merge). Your test "
dongsheng@627 10388 "should report this changeset as good."
dongsheng@627 10389 msgstr ""
dongsheng@627 10390
dongsheng@627 10391 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 10392 #: ../en/ch08-undo.xml:994
dongsheng@627 10393 msgid ""
dongsheng@627 10394 "A child of that changeset. Your test should report this changeset as bad."
dongsheng@627 10395 msgstr ""
dongsheng@627 10396
dongsheng@627 10397 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 10398 #: ../en/ch08-undo.xml:1000
dongsheng@627 10399 msgid "Beware interference between bugs"
dongsheng@635 10400 msgstr "谨防问题之间的冲突"
dongsheng@627 10401
dongsheng@627 10402 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10403 #: ../en/ch08-undo.xml:1002
dongsheng@627 10404 msgid ""
dongsheng@627 10405 "It's possible that your search for one bug could be disrupted by the presence "
dongsheng@627 10406 "of another. For example, let's say your software crashes at revision 100, "
dongsheng@627 10407 "and worked correctly at revision 50. Unknown to you, someone else introduced "
dongsheng@627 10408 "a different crashing bug at revision 60, and fixed it at revision 80. This "
dongsheng@627 10409 "could distort your results in one of several ways."
dongsheng@627 10410 msgstr ""
dongsheng@627 10411
dongsheng@627 10412 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10413 #: ../en/ch08-undo.xml:1010
dongsheng@627 10414 msgid ""
dongsheng@627 10415 "It is possible that this other bug completely <quote>masks</quote> yours, "
dongsheng@627 10416 "which is to say that it occurs before your bug has a chance to manifest "
dongsheng@627 10417 "itself. If you can't avoid that other bug (for example, it prevents your "
dongsheng@627 10418 "project from building), and so can't tell whether your bug is present in a "
dongsheng@627 10419 "particular changeset, the <command role=\"hg-cmd\">hg bisect</command> "
dongsheng@627 10420 "command cannot help you directly. Instead, you can mark a changeset as "
dongsheng@627 10421 "untested by running <command role=\"hg-cmd\">hg bisect --skip</command>."
dongsheng@627 10422 msgstr ""
dongsheng@627 10423
dongsheng@627 10424 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10425 #: ../en/ch08-undo.xml:1020
dongsheng@627 10426 msgid ""
dongsheng@627 10427 "A different problem could arise if your test for a bug's presence is not "
dongsheng@627 10428 "specific enough. If you check for <quote>my program crashes</quote>, then "
dongsheng@627 10429 "both your crashing bug and an unrelated crashing bug that masks it will look "
dongsheng@627 10430 "like the same thing, and mislead <command role=\"hg-cmd\">hg bisect</command>."
dongsheng@627 10431 msgstr ""
dongsheng@627 10432
dongsheng@627 10433 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10434 #: ../en/ch08-undo.xml:1027
dongsheng@627 10435 msgid ""
dongsheng@627 10436 "Another useful situation in which to use <command role=\"hg-cmd\">hg bisect --"
dongsheng@627 10437 "skip</command> is if you can't test a revision because your project was in a "
dongsheng@627 10438 "broken and hence untestable state at that revision, perhaps because someone "
dongsheng@627 10439 "checked in a change that prevented the project from building."
dongsheng@627 10440 msgstr ""
dongsheng@627 10441
dongsheng@627 10442 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 10443 #: ../en/ch08-undo.xml:1036
dongsheng@627 10444 msgid "Bracket your search lazily"
dongsheng@635 10445 msgstr "减少你的查找工作"
dongsheng@627 10446
dongsheng@627 10447 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10448 #: ../en/ch08-undo.xml:1038
dongsheng@627 10449 msgid ""
dongsheng@627 10450 "Choosing the first <quote>good</quote> and <quote>bad</quote> changesets that "
dongsheng@627 10451 "will mark the end points of your search is often easy, but it bears a little "
dongsheng@627 10452 "discussion nevertheless. From the perspective of <command role=\"hg-cmd\">hg "
dongsheng@627 10453 "bisect</command>, the <quote>newest</quote> changeset is conventionally "
dongsheng@627 10454 "<quote>bad</quote>, and the older changeset is <quote>good</quote>."
dongsheng@627 10455 msgstr ""
dongsheng@627 10456
dongsheng@627 10457 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10458 #: ../en/ch08-undo.xml:1046
dongsheng@627 10459 msgid ""
dongsheng@627 10460 "If you're having trouble remembering when a suitable <quote>good</quote> "
dongsheng@627 10461 "change was, so that you can tell <command role=\"hg-cmd\">hg bisect</"
dongsheng@627 10462 "command>, you could do worse than testing changesets at random. Just "
dongsheng@627 10463 "remember to eliminate contenders that can't possibly exhibit the bug (perhaps "
dongsheng@627 10464 "because the feature with the bug isn't present yet) and those where another "
dongsheng@627 10465 "problem masks the bug (as I discussed above)."
dongsheng@627 10466 msgstr ""
dongsheng@627 10467
dongsheng@627 10468 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10469 #: ../en/ch08-undo.xml:1055
dongsheng@627 10470 msgid ""
dongsheng@627 10471 "Even if you end up <quote>early</quote> by thousands of changesets or months "
dongsheng@627 10472 "of history, you will only add a handful of tests to the total number that "
dongsheng@627 10473 "<command role=\"hg-cmd\">hg bisect</command> must perform, thanks to its "
songdongsheng@710 10474 "logarithmic behavior."
dongsheng@627 10475 msgstr ""
dongsheng@627 10476
dongsheng@627 10477 #. type: Content of: <book><chapter><title>
dongsheng@650 10478 #: ../en/ch09-hook.xml:5
dongsheng@627 10479 msgid "Handling repository events with hooks"
dongsheng@627 10480 msgstr "使用钩子处理版本库事件"
dongsheng@627 10481
dongsheng@627 10482 #. type: Content of: <book><chapter><para>
dongsheng@650 10483 #: ../en/ch09-hook.xml:7
dongsheng@627 10484 msgid ""
dongsheng@627 10485 "Mercurial offers a powerful mechanism to let you perform automated actions in "
dongsheng@627 10486 "response to events that occur in a repository. In some cases, you can even "
dongsheng@627 10487 "control Mercurial's response to those events."
dongsheng@627 10488 msgstr ""
dongsheng@627 10489
dongsheng@627 10490 #. type: Content of: <book><chapter><para>
dongsheng@650 10491 #: ../en/ch09-hook.xml:12
dongsheng@627 10492 msgid ""
dongsheng@627 10493 "The name Mercurial uses for one of these actions is a <emphasis>hook</"
dongsheng@627 10494 "emphasis>. Hooks are called <quote>triggers</quote> in some revision control "
dongsheng@627 10495 "systems, but the two names refer to the same idea."
dongsheng@627 10496 msgstr ""
dongsheng@627 10497
dongsheng@627 10498 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 10499 #: ../en/ch09-hook.xml:18
dongsheng@627 10500 msgid "An overview of hooks in Mercurial"
dongsheng@635 10501 msgstr "Mercurial 钩子概述"
dongsheng@627 10502
dongsheng@627 10503 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 10504 #: ../en/ch09-hook.xml:20
dongsheng@627 10505 msgid ""
songdongsheng@658 10506 "Here is a brief list of the hooks that Mercurial supports. We will revisit "
songdongsheng@658 10507 "each of these hooks in more detail later, in <xref linkend=\"sec:hook:ref\"/>."
dongsheng@627 10508 msgstr ""
dongsheng@627 10509
dongsheng@627 10510 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 10511 #: ../en/ch09-hook.xml:25
dongsheng@627 10512 msgid ""
dongsheng@627 10513 "<literal role=\"hook\">changegroup</literal>: This is run after a group of "
dongsheng@627 10514 "changesets has been brought into the repository from elsewhere."
dongsheng@627 10515 msgstr ""
dongsheng@627 10516
dongsheng@627 10517 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 10518 #: ../en/ch09-hook.xml:29
dongsheng@627 10519 msgid ""
dongsheng@627 10520 "<literal role=\"hook\">commit</literal>: This is run after a new changeset "
dongsheng@627 10521 "has been created in the local repository."
dongsheng@627 10522 msgstr ""
dongsheng@627 10523
dongsheng@627 10524 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 10525 #: ../en/ch09-hook.xml:33
dongsheng@627 10526 msgid ""
dongsheng@627 10527 "<literal role=\"hook\">incoming</literal>: This is run once for each new "
dongsheng@627 10528 "changeset that is brought into the repository from elsewhere. Notice the "
dongsheng@627 10529 "difference from <literal role=\"hook\">changegroup</literal>, which is run "
dongsheng@627 10530 "once per <emphasis>group</emphasis> of changesets brought in."
dongsheng@627 10531 msgstr ""
dongsheng@627 10532
dongsheng@627 10533 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 10534 #: ../en/ch09-hook.xml:40
dongsheng@627 10535 msgid ""
dongsheng@627 10536 "<literal role=\"hook\">outgoing</literal>: This is run after a group of "
dongsheng@627 10537 "changesets has been transmitted from this repository."
dongsheng@627 10538 msgstr ""
dongsheng@627 10539
dongsheng@627 10540 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 10541 #: ../en/ch09-hook.xml:44
dongsheng@627 10542 msgid ""
dongsheng@627 10543 "<literal role=\"hook\">prechangegroup</literal>: This is run before starting "
dongsheng@627 10544 "to bring a group of changesets into the repository."
dongsheng@627 10545 msgstr ""
dongsheng@627 10546
dongsheng@627 10547 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 10548 #: ../en/ch09-hook.xml:49
dongsheng@627 10549 msgid ""
dongsheng@627 10550 "<literal role=\"hook\">precommit</literal>: Controlling. This is run before "
dongsheng@627 10551 "starting a commit."
dongsheng@627 10552 msgstr ""
dongsheng@627 10553
dongsheng@627 10554 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 10555 #: ../en/ch09-hook.xml:53
dongsheng@627 10556 msgid ""
dongsheng@627 10557 "<literal role=\"hook\">preoutgoing</literal>: Controlling. This is run before "
dongsheng@627 10558 "starting to transmit a group of changesets from this repository."
dongsheng@627 10559 msgstr ""
dongsheng@627 10560
dongsheng@627 10561 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 10562 #: ../en/ch09-hook.xml:58
dongsheng@627 10563 msgid ""
dongsheng@627 10564 "<literal role=\"hook\">pretag</literal>: Controlling. This is run before "
dongsheng@627 10565 "creating a tag."
dongsheng@627 10566 msgstr ""
dongsheng@627 10567
dongsheng@627 10568 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 10569 #: ../en/ch09-hook.xml:62
dongsheng@627 10570 msgid ""
dongsheng@627 10571 "<literal role=\"hook\">pretxnchangegroup</literal>: Controlling. This is run "
dongsheng@627 10572 "after a group of changesets has been brought into the local repository from "
dongsheng@627 10573 "another, but before the transaction completes that will make the changes "
dongsheng@627 10574 "permanent in the repository."
dongsheng@627 10575 msgstr ""
dongsheng@627 10576
dongsheng@627 10577 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 10578 #: ../en/ch09-hook.xml:70
dongsheng@627 10579 msgid ""
dongsheng@627 10580 "<literal role=\"hook\">pretxncommit</literal>: Controlling. This is run after "
dongsheng@627 10581 "a new changeset has been created in the local repository, but before the "
dongsheng@627 10582 "transaction completes that will make it permanent."
dongsheng@627 10583 msgstr ""
dongsheng@627 10584
dongsheng@627 10585 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 10586 #: ../en/ch09-hook.xml:76
dongsheng@627 10587 msgid ""
dongsheng@627 10588 "<literal role=\"hook\">preupdate</literal>: Controlling. This is run before "
dongsheng@627 10589 "starting an update or merge of the working directory."
dongsheng@627 10590 msgstr ""
dongsheng@627 10591
dongsheng@627 10592 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 10593 #: ../en/ch09-hook.xml:81
dongsheng@627 10594 msgid ""
dongsheng@627 10595 "<literal role=\"hook\">tag</literal>: This is run after a tag is created."
dongsheng@627 10596 msgstr ""
dongsheng@627 10597
dongsheng@627 10598 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 10599 #: ../en/ch09-hook.xml:85
dongsheng@627 10600 msgid ""
dongsheng@627 10601 "<literal role=\"hook\">update</literal>: This is run after an update or merge "
dongsheng@627 10602 "of the working directory has finished."
dongsheng@627 10603 msgstr ""
dongsheng@627 10604
dongsheng@627 10605 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 10606 #: ../en/ch09-hook.xml:90
dongsheng@627 10607 msgid ""
dongsheng@627 10608 "Each of the hooks whose description begins with the word <quote>Controlling</"
dongsheng@627 10609 "quote> has the ability to determine whether an activity can proceed. If the "
dongsheng@627 10610 "hook succeeds, the activity may proceed; if it fails, the activity is either "
dongsheng@627 10611 "not permitted or undone, depending on the hook."
dongsheng@627 10612 msgstr ""
dongsheng@627 10613
dongsheng@627 10614 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 10615 #: ../en/ch09-hook.xml:99
dongsheng@627 10616 msgid "Hooks and security"
dongsheng@635 10617 msgstr "钩子与安全性"
dongsheng@627 10618
dongsheng@627 10619 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 10620 #: ../en/ch09-hook.xml:102
dongsheng@627 10621 msgid "Hooks are run with your privileges"
dongsheng@635 10622 msgstr "钩子以你的特权执行"
dongsheng@627 10623
dongsheng@627 10624 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 10625 #: ../en/ch09-hook.xml:104
dongsheng@627 10626 msgid ""
dongsheng@627 10627 "When you run a Mercurial command in a repository, and the command causes a "
dongsheng@627 10628 "hook to run, that hook runs on <emphasis>your</emphasis> system, under "
dongsheng@627 10629 "<emphasis>your</emphasis> user account, with <emphasis>your</emphasis> "
dongsheng@627 10630 "privilege level. Since hooks are arbitrary pieces of executable code, you "
dongsheng@627 10631 "should treat them with an appropriate level of suspicion. Do not install a "
dongsheng@627 10632 "hook unless you are confident that you know who created it and what it does."
dongsheng@627 10633 msgstr ""
dongsheng@627 10634
dongsheng@627 10635 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 10636 #: ../en/ch09-hook.xml:115
dongsheng@627 10637 msgid ""
dongsheng@627 10638 "In some cases, you may be exposed to hooks that you did not install "
dongsheng@627 10639 "yourself. If you work with Mercurial on an unfamiliar system, Mercurial will "
dongsheng@650 10640 "run hooks defined in that system's global <filename role=\"special\">~/.hgrc</"
dongsheng@650 10641 "filename> file."
dongsheng@650 10642 msgstr ""
dongsheng@650 10643
dongsheng@650 10644 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 10645 #: ../en/ch09-hook.xml:122
dongsheng@627 10646 msgid ""
dongsheng@627 10647 "If you are working with a repository owned by another user, Mercurial can run "
dongsheng@627 10648 "hooks defined in that user's repository, but it will still run them as "
dongsheng@627 10649 "<quote>you</quote>. For example, if you <command role=\"hg-cmd\">hg pull</"
dongsheng@627 10650 "command> from that repository, and its <filename role=\"special\">.hg/hgrc</"
dongsheng@627 10651 "filename> defines a local <literal role=\"hook\">outgoing</literal> hook, "
dongsheng@627 10652 "that hook will run under your user account, even though you don't own that "
dongsheng@627 10653 "repository."
dongsheng@627 10654 msgstr ""
dongsheng@627 10655
dongsheng@627 10656 #. type: Content of: <book><chapter><sect1><sect2><note><para>
dongsheng@650 10657 #: ../en/ch09-hook.xml:134
dongsheng@627 10658 msgid ""
dongsheng@627 10659 "This only applies if you are pulling from a repository on a local or network "
dongsheng@627 10660 "filesystem. If you're pulling over http or ssh, any <literal role=\"hook"
dongsheng@627 10661 "\">outgoing</literal> hook will run under whatever account is executing the "
dongsheng@627 10662 "server process, on the server."
dongsheng@627 10663 msgstr ""
dongsheng@627 10664
dongsheng@627 10665 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 10666 #: ../en/ch09-hook.xml:142
dongsheng@627 10667 msgid ""
dongsheng@627 10668 "XXX To see what hooks are defined in a repository, use the <command role=\"hg-"
dongsheng@627 10669 "cmd\">hg config hooks</command> command. If you are working in one "
dongsheng@627 10670 "repository, but talking to another that you do not own (e.g. using <command "
dongsheng@627 10671 "role=\"hg-cmd\">hg pull</command> or <command role=\"hg-cmd\">hg incoming</"
dongsheng@627 10672 "command>), remember that it is the other repository's hooks you should be "
dongsheng@627 10673 "checking, not your own."
dongsheng@627 10674 msgstr ""
dongsheng@627 10675
dongsheng@627 10676 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 10677 #: ../en/ch09-hook.xml:153
dongsheng@627 10678 msgid "Hooks do not propagate"
dongsheng@635 10679 msgstr "钩子不会传播"
dongsheng@627 10680
dongsheng@627 10681 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 10682 #: ../en/ch09-hook.xml:155
dongsheng@627 10683 msgid ""
dongsheng@627 10684 "In Mercurial, hooks are not revision controlled, and do not propagate when "
dongsheng@627 10685 "you clone, or pull from, a repository. The reason for this is simple: a hook "
dongsheng@627 10686 "is a completely arbitrary piece of executable code. It runs under your user "
dongsheng@627 10687 "identity, with your privilege level, on your machine."
dongsheng@627 10688 msgstr ""
dongsheng@627 10689
dongsheng@627 10690 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 10691 #: ../en/ch09-hook.xml:162
dongsheng@627 10692 msgid ""
dongsheng@627 10693 "It would be extremely reckless for any distributed revision control system to "
dongsheng@627 10694 "implement revision-controlled hooks, as this would offer an easily "
dongsheng@627 10695 "exploitable way to subvert the accounts of users of the revision control "
dongsheng@627 10696 "system."
dongsheng@627 10697 msgstr ""
dongsheng@627 10698
dongsheng@627 10699 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 10700 #: ../en/ch09-hook.xml:168
dongsheng@627 10701 msgid ""
dongsheng@627 10702 "Since Mercurial does not propagate hooks, if you are collaborating with other "
dongsheng@627 10703 "people on a common project, you should not assume that they are using the "
dongsheng@627 10704 "same Mercurial hooks as you are, or that theirs are correctly configured. "
dongsheng@627 10705 "You should document the hooks you expect people to use."
dongsheng@627 10706 msgstr ""
dongsheng@627 10707
dongsheng@627 10708 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 10709 #: ../en/ch09-hook.xml:175
dongsheng@627 10710 msgid ""
dongsheng@627 10711 "In a corporate intranet, this is somewhat easier to control, as you can for "
dongsheng@627 10712 "example provide a <quote>standard</quote> installation of Mercurial on an NFS "
dongsheng@650 10713 "filesystem, and use a site-wide <filename role=\"special\">~/.hgrc</filename> "
dongsheng@650 10714 "file to define hooks that all users will see. However, this too has its "
dongsheng@627 10715 "limits; see below."
dongsheng@627 10716 msgstr ""
dongsheng@627 10717
dongsheng@627 10718 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 10719 #: ../en/ch09-hook.xml:184
dongsheng@627 10720 msgid "Hooks can be overridden"
dongsheng@635 10721 msgstr "钩子可以被覆盖"
dongsheng@627 10722
dongsheng@627 10723 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 10724 #: ../en/ch09-hook.xml:186
dongsheng@627 10725 msgid ""
dongsheng@627 10726 "Mercurial allows you to override a hook definition by redefining the hook. "
dongsheng@627 10727 "You can disable it by setting its value to the empty string, or change its "
songdongsheng@710 10728 "behavior as you wish."
dongsheng@627 10729 msgstr ""
dongsheng@627 10730
dongsheng@627 10731 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 10732 #: ../en/ch09-hook.xml:191
dongsheng@650 10733 msgid ""
dongsheng@650 10734 "If you deploy a system- or site-wide <filename role=\"special\">~/.hgrc</"
dongsheng@650 10735 "filename> file that defines some hooks, you should thus understand that your "
dongsheng@650 10736 "users can disable or override those hooks."
dongsheng@650 10737 msgstr ""
dongsheng@650 10738
dongsheng@650 10739 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 10740 #: ../en/ch09-hook.xml:199
dongsheng@627 10741 msgid "Ensuring that critical hooks are run"
dongsheng@635 10742 msgstr "确保关键钩子的执行"
dongsheng@627 10743
dongsheng@627 10744 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 10745 #: ../en/ch09-hook.xml:201
dongsheng@627 10746 msgid ""
dongsheng@627 10747 "Sometimes you may want to enforce a policy that you do not want others to be "
dongsheng@627 10748 "able to work around. For example, you may have a requirement that every "
dongsheng@627 10749 "changeset must pass a rigorous set of tests. Defining this requirement via a "
dongsheng@650 10750 "hook in a site-wide <filename role=\"special\">~/.hgrc</filename> won't work "
dongsheng@650 10751 "for remote users on laptops, and of course local users can subvert it at will "
dongsheng@650 10752 "by overriding the hook."
dongsheng@650 10753 msgstr ""
dongsheng@650 10754
dongsheng@650 10755 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 10756 #: ../en/ch09-hook.xml:210
dongsheng@627 10757 msgid ""
dongsheng@627 10758 "Instead, you can set up your policies for use of Mercurial so that people are "
dongsheng@627 10759 "expected to propagate changes through a well-known <quote>canonical</quote> "
dongsheng@627 10760 "server that you have locked down and configured appropriately."
dongsheng@627 10761 msgstr ""
dongsheng@627 10762
dongsheng@627 10763 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 10764 #: ../en/ch09-hook.xml:216
dongsheng@627 10765 msgid ""
dongsheng@627 10766 "One way to do this is via a combination of social engineering and "
dongsheng@627 10767 "technology. Set up a restricted-access account; users can push changes over "
dongsheng@627 10768 "the network to repositories managed by this account, but they cannot log into "
dongsheng@627 10769 "the account and run normal shell commands. In this scenario, a user can "
dongsheng@627 10770 "commit a changeset that contains any old garbage they want."
dongsheng@627 10771 msgstr ""
dongsheng@627 10772
dongsheng@627 10773 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 10774 #: ../en/ch09-hook.xml:225
dongsheng@627 10775 msgid ""
dongsheng@627 10776 "When someone pushes a changeset to the server that everyone pulls from, the "
dongsheng@627 10777 "server will test the changeset before it accepts it as permanent, and reject "
dongsheng@627 10778 "it if it fails to pass the test suite. If people only pull changes from this "
dongsheng@627 10779 "filtering server, it will serve to ensure that all changes that people pull "
dongsheng@627 10780 "have been automatically vetted."
dongsheng@627 10781 msgstr ""
dongsheng@627 10782
dongsheng@627 10783 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 10784 #: ../en/ch09-hook.xml:236
dongsheng@627 10785 msgid "Care with <literal>pretxn</literal> hooks in a shared-access repository"
dongsheng@635 10786 msgstr "在共享版本库中注意 <literal>pretxn</literal> 钩子"
dongsheng@627 10787
dongsheng@627 10788 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 10789 #: ../en/ch09-hook.xml:239
dongsheng@627 10790 msgid ""
dongsheng@627 10791 "If you want to use hooks to do some automated work in a repository that a "
dongsheng@627 10792 "number of people have shared access to, you need to be careful in how you do "
dongsheng@627 10793 "this."
dongsheng@627 10794 msgstr ""
dongsheng@627 10795
dongsheng@627 10796 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 10797 #: ../en/ch09-hook.xml:244
dongsheng@627 10798 msgid ""
dongsheng@627 10799 "Mercurial only locks a repository when it is writing to the repository, and "
dongsheng@627 10800 "only the parts of Mercurial that write to the repository pay attention to "
dongsheng@627 10801 "locks. Write locks are necessary to prevent multiple simultaneous writers "
dongsheng@627 10802 "from scribbling on each other's work, corrupting the repository."
dongsheng@627 10803 msgstr ""
dongsheng@627 10804
dongsheng@627 10805 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 10806 #: ../en/ch09-hook.xml:251
dongsheng@627 10807 msgid ""
dongsheng@627 10808 "Because Mercurial is careful with the order in which it reads and writes "
dongsheng@627 10809 "data, it does not need to acquire a lock when it wants to read data from the "
dongsheng@627 10810 "repository. The parts of Mercurial that read from the repository never pay "
dongsheng@627 10811 "attention to locks. This lockless reading scheme greatly increases "
dongsheng@627 10812 "performance and concurrency."
dongsheng@627 10813 msgstr ""
dongsheng@627 10814
dongsheng@627 10815 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 10816 #: ../en/ch09-hook.xml:259
dongsheng@627 10817 msgid ""
dongsheng@627 10818 "With great performance comes a trade-off, though, one which has the potential "
dongsheng@627 10819 "to cause you trouble unless you're aware of it. To describe this requires a "
dongsheng@627 10820 "little detail about how Mercurial adds changesets to a repository and reads "
dongsheng@627 10821 "those changes."
dongsheng@627 10822 msgstr ""
dongsheng@627 10823
dongsheng@627 10824 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 10825 #: ../en/ch09-hook.xml:266
dongsheng@627 10826 msgid ""
dongsheng@627 10827 "When Mercurial <emphasis>writes</emphasis> metadata, it writes it straight "
dongsheng@627 10828 "into the destination file. It writes file data first, then manifest data "
dongsheng@627 10829 "(which contains pointers to the new file data), then changelog data (which "
dongsheng@627 10830 "contains pointers to the new manifest data). Before the first write to each "
dongsheng@627 10831 "file, it stores a record of where the end of the file was in its transaction "
dongsheng@627 10832 "log. If the transaction must be rolled back, Mercurial simply truncates each "
dongsheng@627 10833 "file back to the size it was before the transaction began."
dongsheng@627 10834 msgstr ""
dongsheng@627 10835
dongsheng@627 10836 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 10837 #: ../en/ch09-hook.xml:277
dongsheng@627 10838 msgid ""
dongsheng@627 10839 "When Mercurial <emphasis>reads</emphasis> metadata, it reads the changelog "
dongsheng@627 10840 "first, then everything else. Since a reader will only access parts of the "
dongsheng@627 10841 "manifest or file metadata that it can see in the changelog, it can never see "
dongsheng@627 10842 "partially written data."
dongsheng@627 10843 msgstr ""
dongsheng@627 10844
dongsheng@627 10845 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 10846 #: ../en/ch09-hook.xml:283
dongsheng@627 10847 msgid ""
dongsheng@627 10848 "Some controlling hooks (<literal role=\"hook\">pretxncommit</literal> and "
dongsheng@627 10849 "<literal role=\"hook\">pretxnchangegroup</literal>) run when a transaction is "
dongsheng@627 10850 "almost complete. All of the metadata has been written, but Mercurial can "
dongsheng@627 10851 "still roll the transaction back and cause the newly-written data to disappear."
dongsheng@627 10852 msgstr ""
dongsheng@627 10853
dongsheng@627 10854 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 10855 #: ../en/ch09-hook.xml:291
dongsheng@627 10856 msgid ""
dongsheng@627 10857 "If one of these hooks runs for long, it opens a window of time during which a "
dongsheng@627 10858 "reader can see the metadata for changesets that are not yet permanent, and "
dongsheng@627 10859 "should not be thought of as <quote>really there</quote>. The longer the hook "
dongsheng@627 10860 "runs, the longer that window is open."
dongsheng@627 10861 msgstr ""
dongsheng@627 10862
dongsheng@627 10863 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 10864 #: ../en/ch09-hook.xml:299
dongsheng@627 10865 msgid "The problem illustrated"
dongsheng@635 10866 msgstr "问题的演示"
dongsheng@627 10867
dongsheng@627 10868 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 10869 #: ../en/ch09-hook.xml:301
dongsheng@627 10870 msgid ""
dongsheng@627 10871 "In principle, a good use for the <literal role=\"hook\">pretxnchangegroup</"
dongsheng@627 10872 "literal> hook would be to automatically build and test incoming changes "
dongsheng@627 10873 "before they are accepted into a central repository. This could let you "
dongsheng@627 10874 "guarantee that nobody can push changes to this repository that <quote>break "
dongsheng@627 10875 "the build</quote>. But if a client can pull changes while they're being "
dongsheng@627 10876 "tested, the usefulness of the test is zero; an unsuspecting someone can pull "
dongsheng@627 10877 "untested changes, potentially breaking their build."
dongsheng@627 10878 msgstr ""
dongsheng@627 10879
dongsheng@627 10880 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 10881 #: ../en/ch09-hook.xml:312
dongsheng@627 10882 msgid ""
dongsheng@627 10883 "The safest technological answer to this challenge is to set up such a "
dongsheng@627 10884 "<quote>gatekeeper</quote> repository as <emphasis>unidirectional</emphasis>. "
dongsheng@627 10885 "Let it take changes pushed in from the outside, but do not allow anyone to "
dongsheng@627 10886 "pull changes from it (use the <literal role=\"hook\">preoutgoing</literal> "
dongsheng@627 10887 "hook to lock it down). Configure a <literal role=\"hook\">changegroup</"
dongsheng@627 10888 "literal> hook so that if a build or test succeeds, the hook will push the new "
dongsheng@627 10889 "changes out to another repository that people <emphasis>can</emphasis> pull "
dongsheng@627 10890 "from."
dongsheng@627 10891 msgstr ""
dongsheng@627 10892
dongsheng@627 10893 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 10894 #: ../en/ch09-hook.xml:324
dongsheng@627 10895 msgid ""
dongsheng@627 10896 "In practice, putting a centralised bottleneck like this in place is not often "
dongsheng@627 10897 "a good idea, and transaction visibility has nothing to do with the problem. "
songdongsheng@668 10898 "As the size of a project&emdash;and the time it takes to build and "
songdongsheng@668 10899 "test&emdash;grows, you rapidly run into a wall with this <quote>try before "
songdongsheng@668 10900 "you buy</quote> approach, where you have more changesets to test than time in "
songdongsheng@668 10901 "which to deal with them. The inevitable result is frustration on the part of "
songdongsheng@668 10902 "all involved."
dongsheng@627 10903 msgstr ""
dongsheng@627 10904
dongsheng@627 10905 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 10906 #: ../en/ch09-hook.xml:335
dongsheng@627 10907 msgid ""
dongsheng@627 10908 "An approach that scales better is to get people to build and test before they "
dongsheng@627 10909 "push, then run automated builds and tests centrally <emphasis>after</"
dongsheng@627 10910 "emphasis> a push, to be sure all is well. The advantage of this approach is "
dongsheng@627 10911 "that it does not impose a limit on the rate at which the repository can "
dongsheng@627 10912 "accept changes."
dongsheng@627 10913 msgstr ""
dongsheng@627 10914
dongsheng@627 10915 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 10916 #: ../en/ch09-hook.xml:346
dongsheng@627 10917 msgid "A short tutorial on using hooks"
dongsheng@635 10918 msgstr "使用钩子的简短指南"
dongsheng@627 10919
dongsheng@627 10920 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 10921 #: ../en/ch09-hook.xml:348
dongsheng@627 10922 msgid ""
dongsheng@627 10923 "It is easy to write a Mercurial hook. Let's start with a hook that runs when "
dongsheng@627 10924 "you finish a <command role=\"hg-cmd\">hg commit</command>, and simply prints "
dongsheng@627 10925 "the hash of the changeset you just created. The hook is called <literal role="
dongsheng@627 10926 "\"hook\">commit</literal>."
dongsheng@627 10927 msgstr ""
dongsheng@627 10928
dongsheng@627 10929 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 10930 #: ../en/ch09-hook.xml:355
dongsheng@627 10931 msgid "All hooks follow the pattern in this example."
dongsheng@627 10932 msgstr ""
dongsheng@627 10933
dongsheng@627 10934 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 10935 #: ../en/ch09-hook.xml:359
dongsheng@627 10936 msgid ""
dongsheng@627 10937 "You add an entry to the <literal role=\"rc-hooks\">hooks</literal> section of "
dongsheng@650 10938 "your <filename role=\"special\">~/.hgrc</filename>. On the left is the name "
dongsheng@627 10939 "of the event to trigger on; on the right is the action to take. As you can "
dongsheng@627 10940 "see, you can run an arbitrary shell command in a hook. Mercurial passes "
dongsheng@627 10941 "extra information to the hook using environment variables (look for "
dongsheng@627 10942 "<envar>HG_NODE</envar> in the example)."
dongsheng@627 10943 msgstr ""
dongsheng@627 10944
dongsheng@627 10945 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 10946 #: ../en/ch09-hook.xml:369
dongsheng@627 10947 msgid "Performing multiple actions per event"
dongsheng@635 10948 msgstr "每个事件执行多个操作"
dongsheng@627 10949
dongsheng@627 10950 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 10951 #: ../en/ch09-hook.xml:371
dongsheng@627 10952 msgid ""
dongsheng@627 10953 "Quite often, you will want to define more than one hook for a particular kind "
dongsheng@627 10954 "of event, as shown below."
dongsheng@627 10955 msgstr ""
dongsheng@627 10956
dongsheng@627 10957 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 10958 #: ../en/ch09-hook.xml:376
dongsheng@627 10959 msgid ""
dongsheng@627 10960 "Mercurial lets you do this by adding an <emphasis>extension</emphasis> to the "
dongsheng@627 10961 "end of a hook's name. You extend a hook's name by giving the name of the "
dongsheng@627 10962 "hook, followed by a full stop (the <quote><literal>.</literal></quote> "
dongsheng@627 10963 "character), followed by some more text of your choosing. For example, "
dongsheng@627 10964 "Mercurial will run both <literal>commit.foo</literal> and <literal>commit."
dongsheng@627 10965 "bar</literal> when the <literal>commit</literal> event occurs."
dongsheng@627 10966 msgstr ""
dongsheng@627 10967
dongsheng@627 10968 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 10969 #: ../en/ch09-hook.xml:387
dongsheng@627 10970 msgid ""
dongsheng@627 10971 "To give a well-defined order of execution when there are multiple hooks "
dongsheng@627 10972 "defined for an event, Mercurial sorts hooks by extension, and executes the "
dongsheng@627 10973 "hook commands in this sorted order. In the above example, it will execute "
dongsheng@627 10974 "<literal>commit.bar</literal> before <literal>commit.foo</literal>, and "
dongsheng@627 10975 "<literal>commit</literal> before both."
dongsheng@627 10976 msgstr ""
dongsheng@627 10977
dongsheng@627 10978 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 10979 #: ../en/ch09-hook.xml:396
dongsheng@627 10980 msgid ""
dongsheng@627 10981 "It is a good idea to use a somewhat descriptive extension when you define a "
dongsheng@627 10982 "new hook. This will help you to remember what the hook was for. If the hook "
dongsheng@627 10983 "fails, you'll get an error message that contains the hook name and extension, "
dongsheng@627 10984 "so using a descriptive extension could give you an immediate hint as to why "
songdongsheng@658 10985 "the hook failed (see <xref linkend=\"sec:hook:perm\"/> for an example)."
dongsheng@627 10986 msgstr ""
dongsheng@627 10987
dongsheng@627 10988 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 10989 #: ../en/ch09-hook.xml:407
dongsheng@627 10990 msgid "Controlling whether an activity can proceed"
dongsheng@635 10991 msgstr "控制处理的活动"
dongsheng@627 10992
dongsheng@627 10993 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 10994 #: ../en/ch09-hook.xml:409
dongsheng@627 10995 msgid ""
dongsheng@627 10996 "In our earlier examples, we used the <literal role=\"hook\">commit</literal> "
dongsheng@627 10997 "hook, which is run after a commit has completed. This is one of several "
dongsheng@627 10998 "Mercurial hooks that run after an activity finishes. Such hooks have no way "
dongsheng@627 10999 "of influencing the activity itself."
dongsheng@627 11000 msgstr ""
dongsheng@627 11001
dongsheng@627 11002 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11003 #: ../en/ch09-hook.xml:416
dongsheng@627 11004 msgid ""
dongsheng@627 11005 "Mercurial defines a number of events that occur before an activity starts; or "
dongsheng@627 11006 "after it starts, but before it finishes. Hooks that trigger on these events "
dongsheng@627 11007 "have the added ability to choose whether the activity can continue, or will "
dongsheng@627 11008 "abort."
dongsheng@627 11009 msgstr ""
dongsheng@627 11010
dongsheng@627 11011 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11012 #: ../en/ch09-hook.xml:422
dongsheng@627 11013 msgid ""
dongsheng@627 11014 "The <literal role=\"hook\">pretxncommit</literal> hook runs after a commit "
dongsheng@627 11015 "has all but completed. In other words, the metadata representing the "
dongsheng@627 11016 "changeset has been written out to disk, but the transaction has not yet been "
dongsheng@627 11017 "allowed to complete. The <literal role=\"hook\">pretxncommit</literal> hook "
dongsheng@627 11018 "has the ability to decide whether the transaction can complete, or must be "
dongsheng@627 11019 "rolled back."
dongsheng@627 11020 msgstr ""
dongsheng@627 11021
dongsheng@627 11022 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11023 #: ../en/ch09-hook.xml:431
dongsheng@627 11024 msgid ""
dongsheng@627 11025 "If the <literal role=\"hook\">pretxncommit</literal> hook exits with a status "
dongsheng@627 11026 "code of zero, the transaction is allowed to complete; the commit finishes; "
dongsheng@627 11027 "and the <literal role=\"hook\">commit</literal> hook is run. If the <literal "
dongsheng@627 11028 "role=\"hook\">pretxncommit</literal> hook exits with a non-zero status code, "
dongsheng@627 11029 "the transaction is rolled back; the metadata representing the changeset is "
dongsheng@627 11030 "erased; and the <literal role=\"hook\">commit</literal> hook is not run."
dongsheng@627 11031 msgstr ""
dongsheng@627 11032
dongsheng@627 11033 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11034 #: ../en/ch09-hook.xml:443
dongsheng@627 11035 msgid ""
dongsheng@627 11036 "The hook in the example above checks that a commit comment contains a bug "
dongsheng@627 11037 "ID. If it does, the commit can complete. If not, the commit is rolled back."
dongsheng@627 11038 msgstr ""
dongsheng@627 11039
dongsheng@627 11040 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 11041 #: ../en/ch09-hook.xml:451
dongsheng@627 11042 msgid "Writing your own hooks"
dongsheng@635 11043 msgstr "编写钩子"
dongsheng@627 11044
dongsheng@627 11045 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 11046 #: ../en/ch09-hook.xml:453
dongsheng@627 11047 msgid ""
dongsheng@627 11048 "When you are writing a hook, you might find it useful to run Mercurial either "
dongsheng@627 11049 "with the <option role=\"hg-opt-global\">-v</option> option, or the <envar "
dongsheng@627 11050 "role=\"rc-item-ui\">verbose</envar> config item set to <quote>true</quote>. "
dongsheng@627 11051 "When you do so, Mercurial will print a message before it calls each hook."
dongsheng@627 11052 msgstr ""
dongsheng@627 11053
dongsheng@627 11054 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 11055 #: ../en/ch09-hook.xml:462
dongsheng@627 11056 msgid "Choosing how your hook should run"
dongsheng@635 11057 msgstr "选择钩子的执行方式"
dongsheng@627 11058
dongsheng@627 11059 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11060 #: ../en/ch09-hook.xml:464
dongsheng@627 11061 msgid ""
songdongsheng@668 11062 "You can write a hook either as a normal program&emdash;typically a shell "
songdongsheng@668 11063 "script&emdash;or as a Python function that is executed within the Mercurial "
songdongsheng@668 11064 "process."
dongsheng@627 11065 msgstr ""
dongsheng@627 11066
dongsheng@627 11067 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11068 #: ../en/ch09-hook.xml:469
dongsheng@627 11069 msgid ""
dongsheng@627 11070 "Writing a hook as an external program has the advantage that it requires no "
dongsheng@627 11071 "knowledge of Mercurial's internals. You can call normal Mercurial commands "
dongsheng@627 11072 "to get any added information you need. The trade-off is that external hooks "
dongsheng@627 11073 "are slower than in-process hooks."
dongsheng@627 11074 msgstr ""
dongsheng@627 11075
dongsheng@627 11076 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11077 #: ../en/ch09-hook.xml:476
dongsheng@627 11078 msgid ""
dongsheng@627 11079 "An in-process Python hook has complete access to the Mercurial API, and does "
dongsheng@627 11080 "not <quote>shell out</quote> to another process, so it is inherently faster "
dongsheng@627 11081 "than an external hook. It is also easier to obtain much of the information "
dongsheng@627 11082 "that a hook requires by using the Mercurial API than by running Mercurial "
dongsheng@627 11083 "commands."
dongsheng@627 11084 msgstr ""
dongsheng@627 11085
dongsheng@627 11086 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11087 #: ../en/ch09-hook.xml:484
dongsheng@627 11088 msgid ""
dongsheng@627 11089 "If you are comfortable with Python, or require high performance, writing your "
dongsheng@627 11090 "hooks in Python may be a good choice. However, when you have a "
dongsheng@627 11091 "straightforward hook to write and you don't need to care about performance "
dongsheng@627 11092 "(probably the majority of hooks), a shell script is perfectly fine."
dongsheng@627 11093 msgstr ""
dongsheng@627 11094
dongsheng@627 11095 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 11096 #: ../en/ch09-hook.xml:493
dongsheng@627 11097 msgid "Hook parameters"
dongsheng@635 11098 msgstr "钩子的参数"
dongsheng@627 11099
dongsheng@627 11100 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11101 #: ../en/ch09-hook.xml:495
dongsheng@627 11102 msgid ""
dongsheng@627 11103 "Mercurial calls each hook with a set of well-defined parameters. In Python, "
dongsheng@627 11104 "a parameter is passed as a keyword argument to your hook function. For an "
dongsheng@627 11105 "external program, a parameter is passed as an environment variable."
dongsheng@627 11106 msgstr ""
dongsheng@627 11107
dongsheng@627 11108 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11109 #: ../en/ch09-hook.xml:501
dongsheng@627 11110 msgid ""
dongsheng@627 11111 "Whether your hook is written in Python or as a shell script, the hook-"
dongsheng@627 11112 "specific parameter names and values will be the same. A boolean parameter "
dongsheng@627 11113 "will be represented as a boolean value in Python, but as the number 1 (for "
dongsheng@627 11114 "<quote>true</quote>) or 0 (for <quote>false</quote>) as an environment "
dongsheng@627 11115 "variable for an external hook. If a hook parameter is named <literal>foo</"
dongsheng@627 11116 "literal>, the keyword argument for a Python hook will also be named "
dongsheng@627 11117 "<literal>foo</literal>, while the environment variable for an external hook "
dongsheng@627 11118 "will be named <literal>HG_FOO</literal>."
dongsheng@627 11119 msgstr ""
dongsheng@627 11120
dongsheng@627 11121 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 11122 #: ../en/ch09-hook.xml:515
dongsheng@627 11123 msgid "Hook return values and activity control"
dongsheng@635 11124 msgstr "钩子的返回值与活动控制"
dongsheng@627 11125
dongsheng@627 11126 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11127 #: ../en/ch09-hook.xml:517
dongsheng@627 11128 msgid ""
dongsheng@627 11129 "A hook that executes successfully must exit with a status of zero if "
dongsheng@627 11130 "external, or return boolean <quote>false</quote> if in-process. Failure is "
dongsheng@627 11131 "indicated with a non-zero exit status from an external hook, or an in-process "
dongsheng@627 11132 "hook returning boolean <quote>true</quote>. If an in-process hook raises an "
dongsheng@627 11133 "exception, the hook is considered to have failed."
dongsheng@627 11134 msgstr ""
dongsheng@627 11135
dongsheng@627 11136 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11137 #: ../en/ch09-hook.xml:525
dongsheng@627 11138 msgid ""
dongsheng@627 11139 "For a hook that controls whether an activity can proceed, zero/false means "
dongsheng@627 11140 "<quote>allow</quote>, while non-zero/true/exception means <quote>deny</quote>."
dongsheng@627 11141 msgstr ""
dongsheng@627 11142
dongsheng@627 11143 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 11144 #: ../en/ch09-hook.xml:532
dongsheng@627 11145 msgid "Writing an external hook"
dongsheng@635 11146 msgstr "编写外部钩子"
dongsheng@627 11147
dongsheng@627 11148 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11149 #: ../en/ch09-hook.xml:534
dongsheng@650 11150 msgid ""
dongsheng@650 11151 "When you define an external hook in your <filename role=\"special\">~/.hgrc</"
dongsheng@650 11152 "filename> and the hook is run, its value is passed to your shell, which "
dongsheng@627 11153 "interprets it. This means that you can use normal shell constructs in the "
dongsheng@627 11154 "body of the hook."
dongsheng@627 11155 msgstr ""
dongsheng@627 11156
dongsheng@627 11157 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11158 #: ../en/ch09-hook.xml:541
dongsheng@627 11159 msgid ""
dongsheng@627 11160 "An executable hook is always run with its current directory set to a "
dongsheng@627 11161 "repository's root directory."
dongsheng@627 11162 msgstr ""
dongsheng@627 11163
dongsheng@627 11164 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11165 #: ../en/ch09-hook.xml:545
dongsheng@627 11166 msgid ""
dongsheng@627 11167 "Each hook parameter is passed in as an environment variable; the name is "
dongsheng@627 11168 "upper-cased, and prefixed with the string <quote><literal>HG_</literal></"
dongsheng@627 11169 "quote>."
dongsheng@627 11170 msgstr ""
dongsheng@627 11171
dongsheng@627 11172 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11173 #: ../en/ch09-hook.xml:550
dongsheng@627 11174 msgid ""
dongsheng@627 11175 "With the exception of hook parameters, Mercurial does not set or modify any "
dongsheng@627 11176 "environment variables when running a hook. This is useful to remember if you "
dongsheng@627 11177 "are writing a site-wide hook that may be run by a number of different users "
dongsheng@627 11178 "with differing environment variables set. In multi-user situations, you "
dongsheng@627 11179 "should not rely on environment variables being set to the values you have in "
dongsheng@627 11180 "your environment when testing the hook."
dongsheng@627 11181 msgstr ""
dongsheng@627 11182
dongsheng@627 11183 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 11184 #: ../en/ch09-hook.xml:561
dongsheng@627 11185 msgid "Telling Mercurial to use an in-process hook"
dongsheng@642 11186 msgstr "让 Mercurial 使用进程内钩子"
dongsheng@627 11187
dongsheng@627 11188 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11189 #: ../en/ch09-hook.xml:563
dongsheng@650 11190 msgid ""
dongsheng@650 11191 "The <filename role=\"special\">~/.hgrc</filename> syntax for defining an in-"
dongsheng@627 11192 "process hook is slightly different than for an executable hook. The value of "
dongsheng@627 11193 "the hook must start with the text <quote><literal>python:</literal></quote>, "
dongsheng@627 11194 "and continue with the fully-qualified name of a callable object to use as the "
dongsheng@627 11195 "hook's value."
dongsheng@627 11196 msgstr ""
dongsheng@627 11197
dongsheng@627 11198 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11199 #: ../en/ch09-hook.xml:571
dongsheng@627 11200 msgid ""
dongsheng@627 11201 "The module in which a hook lives is automatically imported when a hook is "
dongsheng@627 11202 "run. So long as you have the module name and <envar>PYTHONPATH</envar> "
dongsheng@627 11203 "right, it should <quote>just work</quote>."
dongsheng@627 11204 msgstr ""
dongsheng@627 11205
dongsheng@627 11206 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11207 #: ../en/ch09-hook.xml:577
dongsheng@650 11208 msgid ""
dongsheng@650 11209 "The following <filename role=\"special\">~/.hgrc</filename> example snippet "
dongsheng@627 11210 "illustrates the syntax and meaning of the notions we just described."
dongsheng@627 11211 msgstr ""
dongsheng@627 11212
dongsheng@627 11213 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11214 #: ../en/ch09-hook.xml:583
dongsheng@627 11215 msgid ""
dongsheng@627 11216 "When Mercurial runs the <literal>commit.example</literal> hook, it imports "
dongsheng@627 11217 "<literal>mymodule.submodule</literal>, looks for the callable object named "
dongsheng@627 11218 "<literal>myhook</literal>, and calls it."
dongsheng@627 11219 msgstr ""
dongsheng@627 11220
dongsheng@627 11221 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 11222 #: ../en/ch09-hook.xml:591
dongsheng@627 11223 msgid "Writing an in-process hook"
dongsheng@635 11224 msgstr "编写进程内钩子"
dongsheng@627 11225
dongsheng@627 11226 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11227 #: ../en/ch09-hook.xml:593
dongsheng@627 11228 msgid ""
dongsheng@627 11229 "The simplest in-process hook does nothing, but illustrates the basic shape of "
dongsheng@627 11230 "the hook API:"
dongsheng@627 11231 msgstr ""
dongsheng@627 11232
dongsheng@627 11233 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11234 #: ../en/ch09-hook.xml:598
dongsheng@627 11235 msgid ""
dongsheng@627 11236 "The first argument to a Python hook is always a <literal role=\"py-mod-"
dongsheng@627 11237 "mercurial.ui\">ui</literal> object. The second is a repository object; at "
dongsheng@627 11238 "the moment, it is always an instance of <literal role=\"py-mod-mercurial."
dongsheng@627 11239 "localrepo\">localrepository</literal>. Following these two arguments are "
dongsheng@627 11240 "other keyword arguments. Which ones are passed in depends on the hook being "
dongsheng@627 11241 "called, but a hook can ignore arguments it doesn't care about by dropping "
dongsheng@627 11242 "them into a keyword argument dict, as with <literal>**kwargs</literal> above."
dongsheng@627 11243 msgstr ""
dongsheng@627 11244
dongsheng@627 11245 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 11246 #: ../en/ch09-hook.xml:613
dongsheng@627 11247 msgid "Some hook examples"
dongsheng@635 11248 msgstr "钩子样例"
dongsheng@627 11249
dongsheng@627 11250 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 11251 #: ../en/ch09-hook.xml:616
dongsheng@627 11252 msgid "Writing meaningful commit messages"
dongsheng@635 11253 msgstr "编写有意义的提交日志"
dongsheng@627 11254
dongsheng@627 11255 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11256 #: ../en/ch09-hook.xml:618
dongsheng@627 11257 msgid ""
dongsheng@627 11258 "It's hard to imagine a useful commit message being very short. The simple "
dongsheng@627 11259 "<literal role=\"hook\">pretxncommit</literal> hook of the example below will "
dongsheng@627 11260 "prevent you from committing a changeset with a message that is less than ten "
dongsheng@627 11261 "bytes long."
dongsheng@627 11262 msgstr ""
dongsheng@627 11263
dongsheng@627 11264 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 11265 #: ../en/ch09-hook.xml:628
dongsheng@627 11266 msgid "Checking for trailing whitespace"
dongsheng@635 11267 msgstr "检查行尾空格"
dongsheng@627 11268
dongsheng@627 11269 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11270 #: ../en/ch09-hook.xml:630
dongsheng@627 11271 msgid ""
dongsheng@627 11272 "An interesting use of a commit-related hook is to help you to write cleaner "
dongsheng@627 11273 "code. A simple example of <quote>cleaner code</quote> is the dictum that a "
dongsheng@627 11274 "change should not add any new lines of text that contain <quote>trailing "
dongsheng@627 11275 "whitespace</quote>. Trailing whitespace is a series of space and tab "
dongsheng@627 11276 "characters at the end of a line of text. In most cases, trailing whitespace "
dongsheng@627 11277 "is unnecessary, invisible noise, but it is occasionally problematic, and "
dongsheng@627 11278 "people often prefer to get rid of it."
dongsheng@627 11279 msgstr ""
dongsheng@627 11280
dongsheng@627 11281 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11282 #: ../en/ch09-hook.xml:641
dongsheng@627 11283 msgid ""
dongsheng@627 11284 "You can use either the <literal role=\"hook\">precommit</literal> or <literal "
dongsheng@627 11285 "role=\"hook\">pretxncommit</literal> hook to tell whether you have a trailing "
dongsheng@627 11286 "whitespace problem. If you use the <literal role=\"hook\">precommit</"
dongsheng@627 11287 "literal> hook, the hook will not know which files you are committing, so it "
dongsheng@627 11288 "will have to check every modified file in the repository for trailing white "
dongsheng@627 11289 "space. If you want to commit a change to just the file <filename>foo</"
dongsheng@627 11290 "filename>, but the file <filename>bar</filename> contains trailing "
dongsheng@627 11291 "whitespace, doing a check in the <literal role=\"hook\">precommit</literal> "
dongsheng@627 11292 "hook will prevent you from committing <filename>foo</filename> due to the "
dongsheng@627 11293 "problem with <filename>bar</filename>. This doesn't seem right."
dongsheng@627 11294 msgstr ""
dongsheng@627 11295
dongsheng@627 11296 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11297 #: ../en/ch09-hook.xml:657
dongsheng@627 11298 msgid ""
dongsheng@627 11299 "Should you choose the <literal role=\"hook\">pretxncommit</literal> hook, the "
dongsheng@627 11300 "check won't occur until just before the transaction for the commit "
dongsheng@627 11301 "completes. This will allow you to check for problems only the exact files "
dongsheng@627 11302 "that are being committed. However, if you entered the commit message "
dongsheng@627 11303 "interactively and the hook fails, the transaction will roll back; you'll have "
dongsheng@627 11304 "to re-enter the commit message after you fix the trailing whitespace and run "
dongsheng@627 11305 "<command role=\"hg-cmd\">hg commit</command> again."
dongsheng@627 11306 msgstr ""
dongsheng@627 11307
dongsheng@627 11308 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11309 #: ../en/ch09-hook.xml:670
dongsheng@627 11310 msgid ""
dongsheng@627 11311 "In this example, we introduce a simple <literal role=\"hook\">pretxncommit</"
dongsheng@627 11312 "literal> hook that checks for trailing whitespace. This hook is short, but "
dongsheng@627 11313 "not very helpful. It exits with an error status if a change adds a line with "
dongsheng@627 11314 "trailing whitespace to any file, but does not print any information that "
dongsheng@627 11315 "might help us to identify the offending file or line. It also has the nice "
dongsheng@627 11316 "property of not paying attention to unmodified lines; only lines that "
dongsheng@627 11317 "introduce new trailing whitespace cause problems."
dongsheng@627 11318 msgstr ""
dongsheng@627 11319
dongsheng@627 11320 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11321 #: ../en/ch09-hook.xml:681
dongsheng@627 11322 msgid ""
dongsheng@627 11323 "The above version is much more complex, but also more useful. It parses a "
dongsheng@627 11324 "unified diff to see if any lines add trailing whitespace, and prints the name "
dongsheng@627 11325 "of the file and the line number of each such occurrence. Even better, if the "
dongsheng@627 11326 "change adds trailing whitespace, this hook saves the commit comment and "
dongsheng@627 11327 "prints the name of the save file before exiting and telling Mercurial to roll "
dongsheng@627 11328 "the transaction back, so you can use the <option role=\"hg-opt-commit\">-l "
dongsheng@627 11329 "filename</option> option to <command role=\"hg-cmd\">hg commit</command> to "
dongsheng@627 11330 "reuse the saved commit message once you've corrected the problem."
dongsheng@627 11331 msgstr ""
dongsheng@627 11332
dongsheng@627 11333 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11334 #: ../en/ch09-hook.xml:695
dongsheng@627 11335 msgid ""
dongsheng@627 11336 "As a final aside, note in the example above the use of <command>perl</"
dongsheng@627 11337 "command>'s in-place editing feature to get rid of trailing whitespace from a "
dongsheng@627 11338 "file. This is concise and useful enough that I will reproduce it here."
dongsheng@627 11339 msgstr ""
dongsheng@627 11340
dongsheng@627 11341 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 11342 #: ../en/ch09-hook.xml:705
dongsheng@627 11343 msgid "Bundled hooks"
dongsheng@635 11344 msgstr "内置的钩子"
dongsheng@627 11345
dongsheng@627 11346 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 11347 #: ../en/ch09-hook.xml:707
dongsheng@627 11348 msgid ""
dongsheng@627 11349 "Mercurial ships with several bundled hooks. You can find them in the "
dongsheng@627 11350 "<filename class=\"directory\">hgext</filename> directory of a Mercurial "
dongsheng@627 11351 "source tree. If you are using a Mercurial binary package, the hooks will be "
dongsheng@627 11352 "located in the <filename class=\"directory\">hgext</filename> directory of "
dongsheng@627 11353 "wherever your package installer put Mercurial."
dongsheng@627 11354 msgstr ""
dongsheng@627 11355
dongsheng@627 11356 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 11357 #: ../en/ch09-hook.xml:716
songdongsheng@668 11358 msgid ""
songdongsheng@668 11359 "<literal role=\"hg-ext\">acl</literal>&emdash;access control for parts of a "
dongsheng@627 11360 "repository"
dongsheng@661 11361 msgstr "<literal role=\"hg-ext\">acl</literal>—版本库的访问控制"
dongsheng@627 11362
dongsheng@627 11363 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11364 #: ../en/ch09-hook.xml:719
dongsheng@627 11365 msgid ""
dongsheng@627 11366 "The <literal role=\"hg-ext\">acl</literal> extension lets you control which "
dongsheng@627 11367 "remote users are allowed to push changesets to a networked server. You can "
dongsheng@627 11368 "protect any portion of a repository (including the entire repo), so that a "
dongsheng@627 11369 "specific remote user can push changes that do not affect the protected "
dongsheng@627 11370 "portion."
dongsheng@627 11371 msgstr ""
dongsheng@627 11372
dongsheng@627 11373 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11374 #: ../en/ch09-hook.xml:727
dongsheng@627 11375 msgid ""
dongsheng@627 11376 "This extension implements access control based on the identity of the user "
dongsheng@627 11377 "performing a push, <emphasis>not</emphasis> on who committed the changesets "
dongsheng@627 11378 "they're pushing. It makes sense to use this hook only if you have a locked-"
dongsheng@627 11379 "down server environment that authenticates remote users, and you want to be "
dongsheng@627 11380 "sure that only specific users are allowed to push changes to that server."
dongsheng@627 11381 msgstr ""
dongsheng@627 11382
dongsheng@627 11383 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
dongsheng@650 11384 #: ../en/ch09-hook.xml:737
dongsheng@627 11385 msgid "Configuring the <literal role=\"hook\">acl</literal> hook"
dongsheng@635 11386 msgstr "配置 <literal role=\"hook\">acl</literal> 钩子"
dongsheng@627 11387
dongsheng@627 11388 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11389 #: ../en/ch09-hook.xml:740
dongsheng@627 11390 msgid ""
dongsheng@627 11391 "In order to manage incoming changesets, the <literal role=\"hg-ext\">acl</"
dongsheng@627 11392 "literal> hook must be used as a <literal role=\"hook\">pretxnchangegroup</"
dongsheng@627 11393 "literal> hook. This lets it see which files are modified by each incoming "
dongsheng@627 11394 "changeset, and roll back a group of changesets if they modify "
dongsheng@627 11395 "<quote>forbidden</quote> files. Example:"
dongsheng@627 11396 msgstr ""
dongsheng@627 11397
dongsheng@627 11398 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11399 #: ../en/ch09-hook.xml:750
dongsheng@627 11400 msgid ""
dongsheng@627 11401 "The <literal role=\"hg-ext\">acl</literal> extension is configured using "
dongsheng@627 11402 "three sections."
dongsheng@627 11403 msgstr ""
dongsheng@627 11404
dongsheng@627 11405 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11406 #: ../en/ch09-hook.xml:754
dongsheng@627 11407 msgid ""
dongsheng@627 11408 "The <literal role=\"rc-acl\">acl</literal> section has only one entry, <envar "
dongsheng@627 11409 "role=\"rc-item-acl\">sources</envar>, which lists the sources of incoming "
dongsheng@627 11410 "changesets that the hook should pay attention to. You don't normally need to "
dongsheng@627 11411 "configure this section."
dongsheng@627 11412 msgstr ""
dongsheng@627 11413
dongsheng@627 11414 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@650 11415 #: ../en/ch09-hook.xml:761
dongsheng@627 11416 msgid ""
dongsheng@627 11417 "<envar role=\"rc-item-acl\">serve</envar>: Control incoming changesets that "
dongsheng@627 11418 "are arriving from a remote repository over http or ssh. This is the default "
dongsheng@627 11419 "value of <envar role=\"rc-item-acl\">sources</envar>, and usually the only "
dongsheng@627 11420 "setting you'll need for this configuration item."
dongsheng@627 11421 msgstr ""
dongsheng@627 11422
dongsheng@627 11423 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@650 11424 #: ../en/ch09-hook.xml:769
dongsheng@627 11425 msgid ""
dongsheng@627 11426 "<envar role=\"rc-item-acl\">pull</envar>: Control incoming changesets that "
dongsheng@627 11427 "are arriving via a pull from a local repository."
dongsheng@627 11428 msgstr ""
dongsheng@627 11429
dongsheng@627 11430 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@650 11431 #: ../en/ch09-hook.xml:774
dongsheng@627 11432 msgid ""
dongsheng@627 11433 "<envar role=\"rc-item-acl\">push</envar>: Control incoming changesets that "
dongsheng@627 11434 "are arriving via a push from a local repository."
dongsheng@627 11435 msgstr ""
dongsheng@627 11436
dongsheng@627 11437 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@650 11438 #: ../en/ch09-hook.xml:779
dongsheng@627 11439 msgid ""
dongsheng@627 11440 "<envar role=\"rc-item-acl\">bundle</envar>: Control incoming changesets that "
dongsheng@627 11441 "are arriving from another repository via a bundle."
dongsheng@627 11442 msgstr ""
dongsheng@627 11443
dongsheng@627 11444 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11445 #: ../en/ch09-hook.xml:785
dongsheng@627 11446 msgid ""
dongsheng@627 11447 "The <literal role=\"rc-acl.allow\">acl.allow</literal> section controls the "
dongsheng@627 11448 "users that are allowed to add changesets to the repository. If this section "
dongsheng@627 11449 "is not present, all users that are not explicitly denied are allowed. If "
dongsheng@627 11450 "this section is present, all users that are not explicitly allowed are denied "
dongsheng@627 11451 "(so an empty section means that all users are denied)."
dongsheng@627 11452 msgstr ""
dongsheng@627 11453
dongsheng@627 11454 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11455 #: ../en/ch09-hook.xml:794
dongsheng@627 11456 msgid ""
dongsheng@627 11457 "The <literal role=\"rc-acl.deny\">acl.deny</literal> section determines which "
dongsheng@627 11458 "users are denied from adding changesets to the repository. If this section "
dongsheng@627 11459 "is not present or is empty, no users are denied."
dongsheng@627 11460 msgstr ""
dongsheng@627 11461
dongsheng@627 11462 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11463 #: ../en/ch09-hook.xml:800
dongsheng@627 11464 msgid ""
dongsheng@627 11465 "The syntaxes for the <literal role=\"rc-acl.allow\">acl.allow</literal> and "
dongsheng@627 11466 "<literal role=\"rc-acl.deny\">acl.deny</literal> sections are identical. On "
dongsheng@627 11467 "the left of each entry is a glob pattern that matches files or directories, "
dongsheng@627 11468 "relative to the root of the repository; on the right, a user name."
dongsheng@627 11469 msgstr ""
dongsheng@627 11470
dongsheng@627 11471 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11472 #: ../en/ch09-hook.xml:808
dongsheng@627 11473 msgid ""
dongsheng@627 11474 "In the following example, the user <literal>docwriter</literal> can only push "
dongsheng@627 11475 "changes to the <filename class=\"directory\">docs</filename> subtree of the "
dongsheng@627 11476 "repository, while <literal>intern</literal> can push changes to any file or "
dongsheng@627 11477 "directory except <filename class=\"directory\">source/sensitive</filename>."
dongsheng@627 11478 msgstr ""
dongsheng@627 11479
dongsheng@627 11480 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
songdongsheng@658 11481 #: ../en/ch09-hook.xml:822 ../en/ch09-hook.xml:1089 ../en/ch09-hook.xml:1279
dongsheng@627 11482 msgid "Testing and troubleshooting"
dongsheng@635 11483 msgstr "测试与问题处理"
dongsheng@627 11484
dongsheng@627 11485 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11486 #: ../en/ch09-hook.xml:824
dongsheng@627 11487 msgid ""
dongsheng@627 11488 "If you want to test the <literal role=\"hg-ext\">acl</literal> hook, run it "
dongsheng@627 11489 "with Mercurial's debugging output enabled. Since you'll probably be running "
dongsheng@627 11490 "it on a server where it's not convenient (or sometimes possible) to pass in "
dongsheng@627 11491 "the <option role=\"hg-opt-global\">--debug</option> option, don't forget that "
dongsheng@650 11492 "you can enable debugging output in your <filename role=\"special\">~/.hgrc</"
dongsheng@627 11493 "filename>:"
dongsheng@627 11494 msgstr ""
dongsheng@627 11495
dongsheng@627 11496 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11497 #: ../en/ch09-hook.xml:835
dongsheng@627 11498 msgid ""
dongsheng@627 11499 "With this enabled, the <literal role=\"hg-ext\">acl</literal> hook will print "
dongsheng@627 11500 "enough information to let you figure out why it is allowing or forbidding "
dongsheng@627 11501 "pushes from specific users."
dongsheng@627 11502 msgstr ""
dongsheng@627 11503
dongsheng@627 11504 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 11505 #: ../en/ch09-hook.xml:844
songdongsheng@668 11506 msgid ""
songdongsheng@668 11507 "<literal role=\"hg-ext\">bugzilla</literal>&emdash;integration with Bugzilla"
dongsheng@661 11508 msgstr "<literal role=\"hg-ext\">bugzilla</literal>—与 Bugzilla 的集成"
dongsheng@627 11509
dongsheng@627 11510 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11511 #: ../en/ch09-hook.xml:848
dongsheng@627 11512 msgid ""
dongsheng@627 11513 "The <literal role=\"hg-ext\">bugzilla</literal> extension adds a comment to a "
dongsheng@627 11514 "Bugzilla bug whenever it finds a reference to that bug ID in a commit "
dongsheng@627 11515 "comment. You can install this hook on a shared server, so that any time a "
dongsheng@627 11516 "remote user pushes changes to this server, the hook gets run."
dongsheng@627 11517 msgstr ""
dongsheng@627 11518
dongsheng@627 11519 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11520 #: ../en/ch09-hook.xml:855
dongsheng@627 11521 msgid ""
dongsheng@627 11522 "It adds a comment to the bug that looks like this (you can configure the "
songdongsheng@668 11523 "contents of the comment&emdash;see below):"
dongsheng@627 11524 msgstr ""
dongsheng@627 11525
dongsheng@627 11526 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11527 #: ../en/ch09-hook.xml:864
dongsheng@627 11528 msgid ""
dongsheng@627 11529 "The value of this hook is that it automates the process of updating a bug any "
dongsheng@627 11530 "time a changeset refers to it. If you configure the hook properly, it makes "
dongsheng@627 11531 "it easy for people to browse straight from a Bugzilla bug to a changeset that "
dongsheng@627 11532 "refers to that bug."
dongsheng@627 11533 msgstr ""
dongsheng@627 11534
dongsheng@627 11535 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11536 #: ../en/ch09-hook.xml:871
dongsheng@627 11537 msgid ""
dongsheng@627 11538 "You can use the code in this hook as a starting point for some more exotic "
dongsheng@627 11539 "Bugzilla integration recipes. Here are a few possibilities:"
dongsheng@627 11540 msgstr ""
dongsheng@627 11541
dongsheng@627 11542 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 11543 #: ../en/ch09-hook.xml:876
dongsheng@627 11544 msgid ""
dongsheng@627 11545 "Require that every changeset pushed to the server have a valid bug ID in its "
dongsheng@627 11546 "commit comment. In this case, you'd want to configure the hook as a <literal "
dongsheng@627 11547 "role=\"hook\">pretxncommit</literal> hook. This would allow the hook to "
dongsheng@627 11548 "reject changes that didn't contain bug IDs."
dongsheng@627 11549 msgstr ""
dongsheng@627 11550
dongsheng@627 11551 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 11552 #: ../en/ch09-hook.xml:884
dongsheng@627 11553 msgid ""
dongsheng@627 11554 "Allow incoming changesets to automatically modify the <emphasis>state</"
dongsheng@627 11555 "emphasis> of a bug, as well as simply adding a comment. For example, the "
dongsheng@627 11556 "hook could recognise the string <quote>fixed bug 31337</quote> as indicating "
dongsheng@627 11557 "that it should update the state of bug 31337 to <quote>requires testing</"
dongsheng@627 11558 "quote>."
dongsheng@627 11559 msgstr ""
dongsheng@627 11560
dongsheng@627 11561 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
dongsheng@650 11562 #: ../en/ch09-hook.xml:894
dongsheng@627 11563 msgid "Configuring the <literal role=\"hook\">bugzilla</literal> hook"
dongsheng@635 11564 msgstr "配置 <literal role=\"hook\">bugzilla</literal> 钩子"
dongsheng@627 11565
dongsheng@627 11566 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11567 #: ../en/ch09-hook.xml:897
dongsheng@650 11568 msgid ""
dongsheng@650 11569 "You should configure this hook in your server's <filename role=\"special\">~/."
dongsheng@650 11570 "hgrc</filename> as an <literal role=\"hook\">incoming</literal> hook, for "
dongsheng@627 11571 "example as follows:"
dongsheng@627 11572 msgstr ""
dongsheng@627 11573
dongsheng@627 11574 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11575 #: ../en/ch09-hook.xml:905
dongsheng@627 11576 msgid ""
dongsheng@627 11577 "Because of the specialised nature of this hook, and because Bugzilla was not "
dongsheng@627 11578 "written with this kind of integration in mind, configuring this hook is a "
dongsheng@627 11579 "somewhat involved process."
dongsheng@627 11580 msgstr ""
dongsheng@627 11581
dongsheng@627 11582 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11583 #: ../en/ch09-hook.xml:911
dongsheng@627 11584 msgid ""
dongsheng@627 11585 "Before you begin, you must install the MySQL bindings for Python on the host"
dongsheng@627 11586 "(s) where you'll be running the hook. If this is not available as a binary "
dongsheng@627 11587 "package for your system, you can download it from <citation>web:mysql-python</"
dongsheng@627 11588 "citation>."
dongsheng@627 11589 msgstr ""
dongsheng@627 11590
dongsheng@627 11591 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11592 #: ../en/ch09-hook.xml:918
dongsheng@627 11593 msgid ""
dongsheng@627 11594 "Configuration information for this hook lives in the <literal role=\"rc-"
dongsheng@650 11595 "bugzilla\">bugzilla</literal> section of your <filename role=\"special\">~/."
dongsheng@627 11596 "hgrc</filename>."
dongsheng@627 11597 msgstr ""
dongsheng@627 11598
dongsheng@627 11599 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@650 11600 #: ../en/ch09-hook.xml:923
dongsheng@627 11601 msgid ""
dongsheng@627 11602 "<envar role=\"rc-item-bugzilla\">version</envar>: The version of Bugzilla "
dongsheng@627 11603 "installed on the server. The database schema that Bugzilla uses changes "
dongsheng@627 11604 "occasionally, so this hook has to know exactly which schema to use. At the "
dongsheng@627 11605 "moment, the only version supported is <literal>2.16</literal>."
dongsheng@627 11606 msgstr ""
dongsheng@627 11607
dongsheng@627 11608 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@650 11609 #: ../en/ch09-hook.xml:932
dongsheng@627 11610 msgid ""
dongsheng@627 11611 "<envar role=\"rc-item-bugzilla\">host</envar>: The hostname of the MySQL "
dongsheng@627 11612 "server that stores your Bugzilla data. The database must be configured to "
dongsheng@627 11613 "allow connections from whatever host you are running the <literal role=\"hook"
dongsheng@627 11614 "\">bugzilla</literal> hook on."
dongsheng@627 11615 msgstr ""
dongsheng@627 11616
dongsheng@627 11617 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@650 11618 #: ../en/ch09-hook.xml:939
dongsheng@627 11619 msgid ""
dongsheng@627 11620 "<envar role=\"rc-item-bugzilla\">user</envar>: The username with which to "
dongsheng@627 11621 "connect to the MySQL server. The database must be configured to allow this "
dongsheng@627 11622 "user to connect from whatever host you are running the <literal role=\"hook"
dongsheng@627 11623 "\">bugzilla</literal> hook on. This user must be able to access and modify "
dongsheng@627 11624 "Bugzilla tables. The default value of this item is <literal>bugs</literal>, "
dongsheng@627 11625 "which is the standard name of the Bugzilla user in a MySQL database."
dongsheng@627 11626 msgstr ""
dongsheng@627 11627
dongsheng@627 11628 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@650 11629 #: ../en/ch09-hook.xml:950
dongsheng@627 11630 msgid ""
dongsheng@627 11631 "<envar role=\"rc-item-bugzilla\">password</envar>: The MySQL password for the "
dongsheng@627 11632 "user you configured above. This is stored as plain text, so you should make "
dongsheng@650 11633 "sure that unauthorised users cannot read the <filename role=\"special\">~/."
dongsheng@650 11634 "hgrc</filename> file where you store this information."
dongsheng@627 11635 msgstr ""
dongsheng@627 11636
dongsheng@627 11637 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@650 11638 #: ../en/ch09-hook.xml:959
dongsheng@627 11639 msgid ""
dongsheng@627 11640 "<envar role=\"rc-item-bugzilla\">db</envar>: The name of the Bugzilla "
dongsheng@627 11641 "database on the MySQL server. The default value of this item is "
dongsheng@627 11642 "<literal>bugs</literal>, which is the standard name of the MySQL database "
dongsheng@627 11643 "where Bugzilla stores its data."
dongsheng@627 11644 msgstr ""
dongsheng@627 11645
dongsheng@627 11646 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@650 11647 #: ../en/ch09-hook.xml:966
dongsheng@627 11648 msgid ""
dongsheng@627 11649 "<envar role=\"rc-item-bugzilla\">notify</envar>: If you want Bugzilla to send "
dongsheng@627 11650 "out a notification email to subscribers after this hook has added a comment "
dongsheng@627 11651 "to a bug, you will need this hook to run a command whenever it updates the "
dongsheng@627 11652 "database. The command to run depends on where you have installed Bugzilla, "
dongsheng@627 11653 "but it will typically look something like this, if you have Bugzilla "
dongsheng@627 11654 "installed in <filename class=\"directory\">/var/www/html/bugzilla</filename>:"
dongsheng@627 11655 msgstr ""
dongsheng@627 11656
dongsheng@627 11657 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@650 11658 #: ../en/ch09-hook.xml:979
dongsheng@627 11659 msgid ""
dongsheng@627 11660 "The Bugzilla <literal>processmail</literal> program expects to be given a bug "
dongsheng@627 11661 "ID (the hook replaces <quote><literal>%s</literal></quote> with the bug ID) "
dongsheng@627 11662 "and an email address. It also expects to be able to write to some files in "
dongsheng@627 11663 "the directory that it runs in. If Bugzilla and this hook are not installed "
dongsheng@627 11664 "on the same machine, you will need to find a way to run <literal>processmail</"
dongsheng@627 11665 "literal> on the server where Bugzilla is installed."
dongsheng@627 11666 msgstr ""
dongsheng@627 11667
dongsheng@627 11668 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
dongsheng@650 11669 #: ../en/ch09-hook.xml:994
dongsheng@627 11670 msgid "Mapping committer names to Bugzilla user names"
dongsheng@635 11671 msgstr "提交者的名称与 Bugzilla 用户名称的映射"
dongsheng@627 11672
dongsheng@627 11673 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11674 #: ../en/ch09-hook.xml:996
dongsheng@627 11675 msgid ""
dongsheng@627 11676 "By default, the <literal role=\"hg-ext\">bugzilla</literal> hook tries to use "
dongsheng@627 11677 "the email address of a changeset's committer as the Bugzilla user name with "
dongsheng@627 11678 "which to update a bug. If this does not suit your needs, you can map "
dongsheng@627 11679 "committer email addresses to Bugzilla user names using a <literal role=\"rc-"
dongsheng@627 11680 "usermap\">usermap</literal> section."
dongsheng@627 11681 msgstr ""
dongsheng@627 11682
dongsheng@627 11683 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11684 #: ../en/ch09-hook.xml:1005
dongsheng@627 11685 msgid ""
dongsheng@627 11686 "Each item in the <literal role=\"rc-usermap\">usermap</literal> section "
dongsheng@627 11687 "contains an email address on the left, and a Bugzilla user name on the right."
dongsheng@627 11688 msgstr ""
dongsheng@627 11689
dongsheng@627 11690 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11691 #: ../en/ch09-hook.xml:1012
dongsheng@627 11692 msgid ""
dongsheng@627 11693 "You can either keep the <literal role=\"rc-usermap\">usermap</literal> data "
dongsheng@627 11694 "in a normal <filename role=\"special\">~/.hgrc</filename>, or tell the "
dongsheng@627 11695 "<literal role=\"hg-ext\">bugzilla</literal> hook to read the information from "
dongsheng@627 11696 "an external <filename>usermap</filename> file. In the latter case, you can "
dongsheng@627 11697 "store <filename>usermap</filename> data by itself in (for example) a user-"
dongsheng@627 11698 "modifiable repository. This makes it possible to let your users maintain "
dongsheng@627 11699 "their own <envar role=\"rc-item-bugzilla\">usermap</envar> entries. The main "
dongsheng@650 11700 "<filename role=\"special\">~/.hgrc</filename> file might look like this:"
dongsheng@627 11701 msgstr ""
dongsheng@627 11702
dongsheng@627 11703 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11704 #: ../en/ch09-hook.xml:1028
dongsheng@627 11705 msgid ""
dongsheng@627 11706 "While the <filename>usermap</filename> file that it refers to might look like "
dongsheng@627 11707 "this:"
dongsheng@627 11708 msgstr ""
dongsheng@627 11709
dongsheng@627 11710 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
dongsheng@650 11711 #: ../en/ch09-hook.xml:1036
dongsheng@627 11712 msgid "Configuring the text that gets added to a bug"
dongsheng@635 11713 msgstr "配置增加到问题中的正文"
dongsheng@627 11714
dongsheng@627 11715 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11716 #: ../en/ch09-hook.xml:1038
dongsheng@627 11717 msgid ""
dongsheng@627 11718 "You can configure the text that this hook adds as a comment; you specify it "
dongsheng@650 11719 "in the form of a Mercurial template. Several <filename role=\"special\">~/."
dongsheng@650 11720 "hgrc</filename> entries (still in the <literal role=\"rc-bugzilla\">bugzilla</"
songdongsheng@710 11721 "literal> section) control this behavior."
dongsheng@627 11722 msgstr ""
dongsheng@627 11723
dongsheng@627 11724 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@650 11725 #: ../en/ch09-hook.xml:1045
dongsheng@627 11726 msgid ""
dongsheng@627 11727 "<literal>strip</literal>: The number of leading path elements to strip from a "
dongsheng@627 11728 "repository's path name to construct a partial path for a URL. For example, if "
dongsheng@627 11729 "the repositories on your server live under <filename class=\"directory\">/"
dongsheng@627 11730 "home/hg/repos</filename>, and you have a repository whose path is <filename "
dongsheng@627 11731 "class=\"directory\">/home/hg/repos/app/tests</filename>, then setting "
dongsheng@627 11732 "<literal>strip</literal> to <literal>4</literal> will give a partial path of "
dongsheng@627 11733 "<filename class=\"directory\">app/tests</filename>. The hook will make this "
dongsheng@627 11734 "partial path available when expanding a template, as <literal>webroot</"
dongsheng@627 11735 "literal>."
dongsheng@627 11736 msgstr ""
dongsheng@627 11737
dongsheng@627 11738 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@650 11739 #: ../en/ch09-hook.xml:1059
dongsheng@627 11740 msgid ""
dongsheng@627 11741 "<literal>template</literal>: The text of the template to use. In addition to "
dongsheng@627 11742 "the usual changeset-related variables, this template can use <literal>hgweb</"
dongsheng@627 11743 "literal> (the value of the <literal>hgweb</literal> configuration item above) "
dongsheng@627 11744 "and <literal>webroot</literal> (the path constructed using <literal>strip</"
dongsheng@627 11745 "literal> above)."
dongsheng@627 11746 msgstr ""
dongsheng@627 11747
dongsheng@627 11748 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11749 #: ../en/ch09-hook.xml:1069
dongsheng@627 11750 msgid ""
dongsheng@627 11751 "In addition, you can add a <envar role=\"rc-item-web\">baseurl</envar> item "
dongsheng@627 11752 "to the <literal role=\"rc-web\">web</literal> section of your <filename role="
dongsheng@650 11753 "\"special\">~/.hgrc</filename>. The <literal role=\"hg-ext\">bugzilla</"
dongsheng@627 11754 "literal> hook will make this available when expanding a template, as the base "
dongsheng@627 11755 "string to use when constructing a URL that will let users browse from a "
dongsheng@627 11756 "Bugzilla comment to view a changeset. Example:"
dongsheng@627 11757 msgstr ""
dongsheng@627 11758
dongsheng@627 11759 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11760 #: ../en/ch09-hook.xml:1081
dongsheng@627 11761 msgid ""
dongsheng@627 11762 "Here is an example set of <literal role=\"hg-ext\">bugzilla</literal> hook "
dongsheng@627 11763 "config information."
dongsheng@627 11764 msgstr ""
dongsheng@627 11765
dongsheng@627 11766 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11767 #: ../en/ch09-hook.xml:1091
dongsheng@627 11768 msgid ""
dongsheng@627 11769 "The most common problems with configuring the <literal role=\"hg-ext"
dongsheng@627 11770 "\">bugzilla</literal> hook relate to running Bugzilla's "
dongsheng@627 11771 "<filename>processmail</filename> script and mapping committer names to user "
dongsheng@627 11772 "names."
dongsheng@627 11773 msgstr ""
dongsheng@627 11774
dongsheng@627 11775 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11776 #: ../en/ch09-hook.xml:1097
dongsheng@627 11777 msgid ""
songdongsheng@658 11778 "Recall from <xref linkend=\"sec:hook:bugzilla:config\"/> above that the user "
songdongsheng@658 11779 "that runs the Mercurial process on the server is also the one that will run "
songdongsheng@658 11780 "the <filename>processmail</filename> script. The <filename>processmail</"
songdongsheng@658 11781 "filename> script sometimes causes Bugzilla to write to files in its "
songdongsheng@658 11782 "configuration directory, and Bugzilla's configuration files are usually owned "
songdongsheng@658 11783 "by the user that your web server runs under."
dongsheng@627 11784 msgstr ""
dongsheng@627 11785
dongsheng@627 11786 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11787 #: ../en/ch09-hook.xml:1108
dongsheng@627 11788 msgid ""
dongsheng@627 11789 "You can cause <filename>processmail</filename> to be run with the suitable "
dongsheng@627 11790 "user's identity using the <command>sudo</command> command. Here is an "
dongsheng@627 11791 "example entry for a <filename>sudoers</filename> file."
dongsheng@627 11792 msgstr ""
dongsheng@627 11793
dongsheng@627 11794 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11795 #: ../en/ch09-hook.xml:1115
dongsheng@627 11796 msgid ""
dongsheng@627 11797 "This allows the <literal>hg_user</literal> user to run a "
dongsheng@627 11798 "<filename>processmail-wrapper</filename> program under the identity of "
dongsheng@627 11799 "<literal>httpd_user</literal>."
dongsheng@627 11800 msgstr ""
dongsheng@627 11801
dongsheng@627 11802 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11803 #: ../en/ch09-hook.xml:1120
dongsheng@627 11804 msgid ""
dongsheng@627 11805 "This indirection through a wrapper script is necessary, because "
dongsheng@627 11806 "<filename>processmail</filename> expects to be run with its current directory "
dongsheng@627 11807 "set to wherever you installed Bugzilla; you can't specify that kind of "
dongsheng@627 11808 "constraint in a <filename>sudoers</filename> file. The contents of the "
dongsheng@627 11809 "wrapper script are simple:"
dongsheng@627 11810 msgstr ""
dongsheng@627 11811
dongsheng@627 11812 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11813 #: ../en/ch09-hook.xml:1129
dongsheng@627 11814 msgid ""
dongsheng@627 11815 "It doesn't seem to matter what email address you pass to "
dongsheng@627 11816 "<filename>processmail</filename>."
dongsheng@627 11817 msgstr ""
dongsheng@627 11818
dongsheng@627 11819 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11820 #: ../en/ch09-hook.xml:1133
dongsheng@627 11821 msgid ""
dongsheng@627 11822 "If your <literal role=\"rc-usermap\">usermap</literal> is not set up "
dongsheng@627 11823 "correctly, users will see an error message from the <literal role=\"hg-ext"
dongsheng@627 11824 "\">bugzilla</literal> hook when they push changes to the server. The error "
dongsheng@627 11825 "message will look like this:"
dongsheng@627 11826 msgstr ""
dongsheng@627 11827
dongsheng@627 11828 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11829 #: ../en/ch09-hook.xml:1140
dongsheng@627 11830 msgid ""
dongsheng@627 11831 "What this means is that the committer's address, <literal>john.q."
dongsheng@627 11832 "public@example.com</literal>, is not a valid Bugzilla user name, nor does it "
dongsheng@627 11833 "have an entry in your <literal role=\"rc-usermap\">usermap</literal> that "
dongsheng@627 11834 "maps it to a valid Bugzilla user name."
dongsheng@627 11835 msgstr ""
dongsheng@627 11836
dongsheng@627 11837 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 11838 #: ../en/ch09-hook.xml:1150
songdongsheng@668 11839 msgid ""
songdongsheng@668 11840 "<literal role=\"hg-ext\">notify</literal>&emdash;send email notifications"
dongsheng@661 11841 msgstr "<literal role=\"hg-ext\">notify</literal>—邮件通知"
dongsheng@627 11842
dongsheng@627 11843 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11844 #: ../en/ch09-hook.xml:1153
dongsheng@627 11845 msgid ""
dongsheng@627 11846 "Although Mercurial's built-in web server provides RSS feeds of changes in "
dongsheng@627 11847 "every repository, many people prefer to receive change notifications via "
dongsheng@627 11848 "email. The <literal role=\"hg-ext\">notify</literal> hook lets you send out "
dongsheng@627 11849 "notifications to a set of email addresses whenever changesets arrive that "
dongsheng@627 11850 "those subscribers are interested in."
dongsheng@627 11851 msgstr ""
dongsheng@627 11852
dongsheng@627 11853 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11854 #: ../en/ch09-hook.xml:1161
dongsheng@627 11855 msgid ""
dongsheng@627 11856 "As with the <literal role=\"hg-ext\">bugzilla</literal> hook, the <literal "
dongsheng@627 11857 "role=\"hg-ext\">notify</literal> hook is template-driven, so you can "
dongsheng@627 11858 "customise the contents of the notification messages that it sends."
dongsheng@627 11859 msgstr ""
dongsheng@627 11860
dongsheng@627 11861 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11862 #: ../en/ch09-hook.xml:1167
dongsheng@627 11863 msgid ""
dongsheng@627 11864 "By default, the <literal role=\"hg-ext\">notify</literal> hook includes a "
dongsheng@627 11865 "diff of every changeset that it sends out; you can limit the size of the "
dongsheng@627 11866 "diff, or turn this feature off entirely. It is useful for letting "
dongsheng@627 11867 "subscribers review changes immediately, rather than clicking to follow a URL."
dongsheng@627 11868 msgstr ""
dongsheng@627 11869
dongsheng@627 11870 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
dongsheng@650 11871 #: ../en/ch09-hook.xml:1175
dongsheng@627 11872 msgid "Configuring the <literal role=\"hg-ext\">notify</literal> hook"
dongsheng@635 11873 msgstr "配置 <literal role=\"hg-ext\">notify</literal> 钩子"
dongsheng@627 11874
dongsheng@627 11875 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11876 #: ../en/ch09-hook.xml:1178
dongsheng@627 11877 msgid ""
dongsheng@627 11878 "You can set up the <literal role=\"hg-ext\">notify</literal> hook to send one "
dongsheng@627 11879 "email message per incoming changeset, or one per incoming group of changesets "
dongsheng@627 11880 "(all those that arrived in a single pull or push)."
dongsheng@627 11881 msgstr ""
dongsheng@627 11882
dongsheng@627 11883 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11884 #: ../en/ch09-hook.xml:1190
dongsheng@627 11885 msgid ""
dongsheng@627 11886 "Configuration information for this hook lives in the <literal role=\"rc-notify"
dongsheng@650 11887 "\">notify</literal> section of a <filename role=\"special\">~/.hgrc</"
dongsheng@650 11888 "filename> file."
dongsheng@627 11889 msgstr ""
dongsheng@627 11890
dongsheng@627 11891 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@650 11892 #: ../en/ch09-hook.xml:1195
dongsheng@627 11893 msgid ""
dongsheng@627 11894 "<envar role=\"rc-item-notify\">test</envar>: By default, this hook does not "
dongsheng@627 11895 "send out email at all; instead, it prints the message that it "
dongsheng@627 11896 "<emphasis>would</emphasis> send. Set this item to <literal>false</literal> "
dongsheng@627 11897 "to allow email to be sent. The reason that sending of email is turned off by "
dongsheng@627 11898 "default is that it takes several tries to configure this extension exactly as "
dongsheng@627 11899 "you would like, and it would be bad form to spam subscribers with a number of "
dongsheng@627 11900 "<quote>broken</quote> notifications while you debug your configuration."
dongsheng@627 11901 msgstr ""
dongsheng@627 11902
dongsheng@627 11903 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@650 11904 #: ../en/ch09-hook.xml:1207
dongsheng@627 11905 msgid ""
dongsheng@627 11906 "<envar role=\"rc-item-notify\">config</envar>: The path to a configuration "
dongsheng@627 11907 "file that contains subscription information. This is kept separate from the "
dongsheng@650 11908 "main <filename role=\"special\">~/.hgrc</filename> so that you can maintain "
dongsheng@627 11909 "it in a repository of its own. People can then clone that repository, update "
dongsheng@627 11910 "their subscriptions, and push the changes back to your server."
dongsheng@627 11911 msgstr ""
dongsheng@627 11912
dongsheng@627 11913 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@650 11914 #: ../en/ch09-hook.xml:1216
dongsheng@627 11915 msgid ""
dongsheng@627 11916 "<envar role=\"rc-item-notify\">strip</envar>: The number of leading path "
dongsheng@627 11917 "separator characters to strip from a repository's path, when deciding whether "
dongsheng@627 11918 "a repository has subscribers. For example, if the repositories on your "
dongsheng@627 11919 "server live in <filename class=\"directory\">/home/hg/repos</filename>, and "
dongsheng@627 11920 "<literal role=\"hg-ext\">notify</literal> is considering a repository named "
dongsheng@627 11921 "<filename class=\"directory\">/home/hg/repos/shared/test</filename>, setting "
dongsheng@627 11922 "<envar role=\"rc-item-notify\">strip</envar> to <literal>4</literal> will "
dongsheng@627 11923 "cause <literal role=\"hg-ext\">notify</literal> to trim the path it considers "
dongsheng@627 11924 "down to <filename class=\"directory\">shared/test</filename>, and it will "
dongsheng@627 11925 "match subscribers against that."
dongsheng@627 11926 msgstr ""
dongsheng@627 11927
dongsheng@627 11928 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@650 11929 #: ../en/ch09-hook.xml:1233
dongsheng@627 11930 msgid ""
dongsheng@627 11931 "<envar role=\"rc-item-notify\">template</envar>: The template text to use "
dongsheng@627 11932 "when sending messages. This specifies both the contents of the message "
dongsheng@627 11933 "header and its body."
dongsheng@627 11934 msgstr ""
dongsheng@627 11935
dongsheng@627 11936 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@650 11937 #: ../en/ch09-hook.xml:1239
dongsheng@627 11938 msgid ""
dongsheng@627 11939 "<envar role=\"rc-item-notify\">maxdiff</envar>: The maximum number of lines "
dongsheng@627 11940 "of diff data to append to the end of a message. If a diff is longer than "
dongsheng@627 11941 "this, it is truncated. By default, this is set to 300. Set this to "
dongsheng@627 11942 "<literal>0</literal> to omit diffs from notification emails."
dongsheng@627 11943 msgstr ""
dongsheng@627 11944
dongsheng@627 11945 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@650 11946 #: ../en/ch09-hook.xml:1248
dongsheng@627 11947 msgid ""
dongsheng@627 11948 "<envar role=\"rc-item-notify\">sources</envar>: A list of sources of "
dongsheng@627 11949 "changesets to consider. This lets you limit <literal role=\"hg-ext\">notify</"
dongsheng@627 11950 "literal> to only sending out email about changes that remote users pushed "
songdongsheng@658 11951 "into this repository via a server, for example. See <xref linkend=\"sec:hook:"
songdongsheng@658 11952 "sources\"/> for the sources you can specify here."
dongsheng@627 11953 msgstr ""
dongsheng@627 11954
dongsheng@627 11955 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@658 11956 #: ../en/ch09-hook.xml:1259
dongsheng@627 11957 msgid ""
dongsheng@627 11958 "If you set the <envar role=\"rc-item-web\">baseurl</envar> item in the "
dongsheng@627 11959 "<literal role=\"rc-web\">web</literal> section, you can use it in a template; "
dongsheng@627 11960 "it will be available as <literal>webroot</literal>."
dongsheng@627 11961 msgstr ""
dongsheng@627 11962
dongsheng@627 11963 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@658 11964 #: ../en/ch09-hook.xml:1265
dongsheng@627 11965 msgid ""
dongsheng@627 11966 "Here is an example set of <literal role=\"hg-ext\">notify</literal> "
dongsheng@627 11967 "configuration information."
dongsheng@627 11968 msgstr ""
dongsheng@627 11969
dongsheng@627 11970 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@658 11971 #: ../en/ch09-hook.xml:1271
dongsheng@627 11972 msgid "This will produce a message that looks like the following:"
dongsheng@627 11973 msgstr ""
dongsheng@627 11974
dongsheng@627 11975 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@658 11976 #: ../en/ch09-hook.xml:1281
dongsheng@627 11977 msgid ""
dongsheng@627 11978 "Do not forget that by default, the <literal role=\"hg-ext\">notify</literal> "
dongsheng@627 11979 "extension <emphasis>will not send any mail</emphasis> until you explicitly "
dongsheng@627 11980 "configure it to do so, by setting <envar role=\"rc-item-notify\">test</envar> "
dongsheng@627 11981 "to <literal>false</literal>. Until you do that, it simply prints the message "
dongsheng@627 11982 "it <emphasis>would</emphasis> send."
dongsheng@627 11983 msgstr ""
dongsheng@627 11984
dongsheng@627 11985 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@658 11986 #: ../en/ch09-hook.xml:1293
dongsheng@627 11987 msgid "Information for writers of hooks"
dongsheng@635 11988 msgstr "编写钩子的信息"
dongsheng@627 11989
dongsheng@627 11990 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 11991 #: ../en/ch09-hook.xml:1296
dongsheng@627 11992 msgid "In-process hook execution"
dongsheng@635 11993 msgstr "进程内钩子的执行"
dongsheng@627 11994
dongsheng@627 11995 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 11996 #: ../en/ch09-hook.xml:1298
dongsheng@627 11997 msgid "An in-process hook is called with arguments of the following form:"
dongsheng@627 11998 msgstr ""
dongsheng@627 11999
dongsheng@627 12000 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 12001 #: ../en/ch09-hook.xml:1302
dongsheng@627 12002 msgid ""
dongsheng@627 12003 "The <literal>ui</literal> parameter is a <literal role=\"py-mod-mercurial.ui"
dongsheng@627 12004 "\">ui</literal> object. The <literal>repo</literal> parameter is a <literal "
dongsheng@627 12005 "role=\"py-mod-mercurial.localrepo\">localrepository</literal> object. The "
dongsheng@627 12006 "names and values of the <literal>**kwargs</literal> parameters depend on the "
dongsheng@627 12007 "hook being invoked, with the following common features:"
dongsheng@627 12008 msgstr ""
dongsheng@627 12009
dongsheng@627 12010 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 12011 #: ../en/ch09-hook.xml:1311
dongsheng@627 12012 msgid ""
dongsheng@627 12013 "If a parameter is named <literal>node</literal> or <literal>parentN</"
dongsheng@627 12014 "literal>, it will contain a hexadecimal changeset ID. The empty string is "
dongsheng@627 12015 "used to represent <quote>null changeset ID</quote> instead of a string of "
dongsheng@627 12016 "zeroes."
dongsheng@627 12017 msgstr ""
dongsheng@627 12018
dongsheng@627 12019 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 12020 #: ../en/ch09-hook.xml:1318
dongsheng@627 12021 msgid ""
dongsheng@627 12022 "If a parameter is named <literal>url</literal>, it will contain the URL of a "
dongsheng@627 12023 "remote repository, if that can be determined."
dongsheng@627 12024 msgstr ""
dongsheng@627 12025
dongsheng@627 12026 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 12027 #: ../en/ch09-hook.xml:1323
dongsheng@627 12028 msgid ""
dongsheng@627 12029 "Boolean-valued parameters are represented as Python <literal>bool</literal> "
dongsheng@627 12030 "objects."
dongsheng@627 12031 msgstr ""
dongsheng@627 12032
dongsheng@627 12033 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 12034 #: ../en/ch09-hook.xml:1328
dongsheng@627 12035 msgid ""
dongsheng@627 12036 "An in-process hook is called without a change to the process's working "
dongsheng@627 12037 "directory (unlike external hooks, which are run in the root of the "
dongsheng@627 12038 "repository). It must not change the process's working directory, or it will "
dongsheng@627 12039 "cause any calls it makes into the Mercurial API to fail."
dongsheng@627 12040 msgstr ""
dongsheng@627 12041
dongsheng@627 12042 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 12043 #: ../en/ch09-hook.xml:1335
dongsheng@627 12044 msgid ""
dongsheng@627 12045 "If a hook returns a boolean <quote>false</quote> value, it is considered to "
dongsheng@627 12046 "have succeeded. If it returns a boolean <quote>true</quote> value or raises "
dongsheng@627 12047 "an exception, it is considered to have failed. A useful way to think of the "
dongsheng@627 12048 "calling convention is <quote>tell me if you fail</quote>."
dongsheng@627 12049 msgstr ""
dongsheng@627 12050
dongsheng@627 12051 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 12052 #: ../en/ch09-hook.xml:1342
dongsheng@627 12053 msgid ""
dongsheng@627 12054 "Note that changeset IDs are passed into Python hooks as hexadecimal strings, "
dongsheng@627 12055 "not the binary hashes that Mercurial's APIs normally use. To convert a hash "
dongsheng@650 12056 "from hex to binary, use the <literal>bin</literal> function."
dongsheng@650 12057 msgstr ""
dongsheng@650 12058
dongsheng@650 12059 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 12060 #: ../en/ch09-hook.xml:1350
dongsheng@627 12061 msgid "External hook execution"
dongsheng@635 12062 msgstr "外部钩子的执行"
dongsheng@627 12063
dongsheng@627 12064 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 12065 #: ../en/ch09-hook.xml:1352
dongsheng@627 12066 msgid ""
dongsheng@627 12067 "An external hook is passed to the shell of the user running Mercurial. "
dongsheng@627 12068 "Features of that shell, such as variable substitution and command "
dongsheng@627 12069 "redirection, are available. The hook is run in the root directory of the "
dongsheng@627 12070 "repository (unlike in-process hooks, which are run in the same directory that "
dongsheng@627 12071 "Mercurial was run in)."
dongsheng@627 12072 msgstr ""
dongsheng@627 12073
dongsheng@627 12074 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 12075 #: ../en/ch09-hook.xml:1360
dongsheng@627 12076 msgid ""
dongsheng@627 12077 "Hook parameters are passed to the hook as environment variables. Each "
dongsheng@627 12078 "environment variable's name is converted in upper case and prefixed with the "
dongsheng@627 12079 "string <quote><literal>HG_</literal></quote>. For example, if the name of a "
dongsheng@627 12080 "parameter is <quote><literal>node</literal></quote>, the name of the "
dongsheng@627 12081 "environment variable representing that parameter will be "
dongsheng@627 12082 "<quote><literal>HG_NODE</literal></quote>."
dongsheng@627 12083 msgstr ""
dongsheng@627 12084
dongsheng@627 12085 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 12086 #: ../en/ch09-hook.xml:1369
dongsheng@627 12087 msgid ""
dongsheng@627 12088 "A boolean parameter is represented as the string <quote><literal>1</literal></"
dongsheng@627 12089 "quote> for <quote>true</quote>, <quote><literal>0</literal></quote> for "
dongsheng@627 12090 "<quote>false</quote>. If an environment variable is named <envar>HG_NODE</"
dongsheng@627 12091 "envar>, <envar>HG_PARENT1</envar> or <envar>HG_PARENT2</envar>, it contains a "
dongsheng@627 12092 "changeset ID represented as a hexadecimal string. The empty string is used "
dongsheng@627 12093 "to represent <quote>null changeset ID</quote> instead of a string of zeroes. "
dongsheng@627 12094 "If an environment variable is named <envar>HG_URL</envar>, it will contain "
dongsheng@627 12095 "the URL of a remote repository, if that can be determined."
dongsheng@627 12096 msgstr ""
dongsheng@627 12097
dongsheng@627 12098 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 12099 #: ../en/ch09-hook.xml:1381
dongsheng@627 12100 msgid ""
dongsheng@627 12101 "If a hook exits with a status of zero, it is considered to have succeeded. "
dongsheng@627 12102 "If it exits with a non-zero status, it is considered to have failed."
dongsheng@627 12103 msgstr ""
dongsheng@627 12104
dongsheng@627 12105 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 12106 #: ../en/ch09-hook.xml:1388
dongsheng@627 12107 msgid "Finding out where changesets come from"
dongsheng@635 12108 msgstr "检查修改集来自何处"
dongsheng@627 12109
dongsheng@627 12110 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 12111 #: ../en/ch09-hook.xml:1390
dongsheng@627 12112 msgid ""
dongsheng@627 12113 "A hook that involves the transfer of changesets between a local repository "
dongsheng@627 12114 "and another may be able to find out information about the <quote>far side</"
dongsheng@627 12115 "quote>. Mercurial knows <emphasis>how</emphasis> changes are being "
dongsheng@627 12116 "transferred, and in many cases <emphasis>where</emphasis> they are being "
dongsheng@627 12117 "transferred to or from."
dongsheng@627 12118 msgstr ""
dongsheng@627 12119
dongsheng@627 12120 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
songdongsheng@658 12121 #: ../en/ch09-hook.xml:1399
dongsheng@627 12122 msgid "Sources of changesets"
dongsheng@635 12123 msgstr "修改集的来源"
dongsheng@627 12124
dongsheng@627 12125 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@658 12126 #: ../en/ch09-hook.xml:1401
dongsheng@627 12127 msgid ""
dongsheng@627 12128 "Mercurial will tell a hook what means are, or were, used to transfer "
dongsheng@627 12129 "changesets between repositories. This is provided by Mercurial in a Python "
dongsheng@627 12130 "parameter named <literal>source</literal>, or an environment variable named "
dongsheng@627 12131 "<envar>HG_SOURCE</envar>."
dongsheng@627 12132 msgstr ""
dongsheng@627 12133
dongsheng@627 12134 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
songdongsheng@658 12135 #: ../en/ch09-hook.xml:1409
dongsheng@627 12136 msgid ""
dongsheng@627 12137 "<literal>serve</literal>: Changesets are transferred to or from a remote "
dongsheng@627 12138 "repository over http or ssh."
dongsheng@627 12139 msgstr ""
dongsheng@627 12140
dongsheng@627 12141 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
songdongsheng@658 12142 #: ../en/ch09-hook.xml:1414
dongsheng@627 12143 msgid ""
dongsheng@627 12144 "<literal>pull</literal>: Changesets are being transferred via a pull from one "
dongsheng@627 12145 "repository into another."
dongsheng@627 12146 msgstr ""
dongsheng@627 12147
dongsheng@627 12148 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
songdongsheng@658 12149 #: ../en/ch09-hook.xml:1419
dongsheng@627 12150 msgid ""
dongsheng@627 12151 "<literal>push</literal>: Changesets are being transferred via a push from one "
dongsheng@627 12152 "repository into another."
dongsheng@627 12153 msgstr ""
dongsheng@627 12154
dongsheng@627 12155 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
songdongsheng@658 12156 #: ../en/ch09-hook.xml:1424
dongsheng@627 12157 msgid ""
dongsheng@627 12158 "<literal>bundle</literal>: Changesets are being transferred to or from a "
dongsheng@627 12159 "bundle."
dongsheng@627 12160 msgstr ""
dongsheng@627 12161
dongsheng@627 12162 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
songdongsheng@658 12163 #: ../en/ch09-hook.xml:1431
songdongsheng@668 12164 msgid "Where changes are going&emdash;remote repository URLs"
dongsheng@661 12165 msgstr "修改集要到哪里—远程版本库的地址"
dongsheng@627 12166
dongsheng@627 12167 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@658 12168 #: ../en/ch09-hook.xml:1434
dongsheng@627 12169 msgid ""
dongsheng@627 12170 "When possible, Mercurial will tell a hook the location of the <quote>far "
dongsheng@627 12171 "side</quote> of an activity that transfers changeset data between "
dongsheng@627 12172 "repositories. This is provided by Mercurial in a Python parameter named "
dongsheng@627 12173 "<literal>url</literal>, or an environment variable named <envar>HG_URL</"
dongsheng@627 12174 "envar>."
dongsheng@627 12175 msgstr ""
dongsheng@627 12176
dongsheng@627 12177 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@658 12178 #: ../en/ch09-hook.xml:1442
dongsheng@627 12179 msgid ""
dongsheng@627 12180 "This information is not always known. If a hook is invoked in a repository "
dongsheng@627 12181 "that is being served via http or ssh, Mercurial cannot tell where the remote "
dongsheng@627 12182 "repository is, but it may know where the client is connecting from. In such "
dongsheng@627 12183 "cases, the URL will take one of the following forms:"
dongsheng@627 12184 msgstr ""
dongsheng@627 12185
dongsheng@627 12186 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
songdongsheng@658 12187 #: ../en/ch09-hook.xml:1449
dongsheng@627 12188 msgid ""
songdongsheng@668 12189 "<literal>remote:ssh:1.2.3.4</literal>&emdash;remote ssh client, at the IP "
songdongsheng@668 12190 "address <literal>1.2.3.4</literal>."
dongsheng@627 12191 msgstr ""
dongsheng@627 12192
dongsheng@627 12193 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
songdongsheng@658 12194 #: ../en/ch09-hook.xml:1454
dongsheng@627 12195 msgid ""
songdongsheng@668 12196 "<literal>remote:http:1.2.3.4</literal>&emdash;remote http client, at the IP "
songdongsheng@668 12197 "address <literal>1.2.3.4</literal>. If the client is using SSL, this will be "
songdongsheng@668 12198 "of the form <literal>remote:https:1.2.3.4</literal>."
dongsheng@627 12199 msgstr ""
dongsheng@627 12200
dongsheng@627 12201 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
songdongsheng@658 12202 #: ../en/ch09-hook.xml:1461
songdongsheng@668 12203 msgid "Empty&emdash;no information could be discovered about the remote client."
dongsheng@627 12204 msgstr ""
dongsheng@627 12205
dongsheng@627 12206 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@658 12207 #: ../en/ch09-hook.xml:1470
dongsheng@627 12208 msgid "Hook reference"
dongsheng@635 12209 msgstr "钩子参考"
dongsheng@627 12210
dongsheng@627 12211 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 12212 #: ../en/ch09-hook.xml:1473
songdongsheng@668 12213 msgid ""
songdongsheng@668 12214 "<literal role=\"hook\">changegroup</literal>&emdash;after remote changesets "
songdongsheng@668 12215 "added"
dongsheng@661 12216 msgstr "<literal role=\"hook\">changegroup</literal>—增加远程修改集之后"
dongsheng@627 12217
dongsheng@627 12218 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 12219 #: ../en/ch09-hook.xml:1476
dongsheng@627 12220 msgid ""
dongsheng@627 12221 "This hook is run after a group of pre-existing changesets has been added to "
dongsheng@627 12222 "the repository, for example via a <command role=\"hg-cmd\">hg pull</command> "
dongsheng@627 12223 "or <command role=\"hg-cmd\">hg unbundle</command>. This hook is run once per "
dongsheng@627 12224 "operation that added one or more changesets. This is in contrast to the "
dongsheng@627 12225 "<literal role=\"hook\">incoming</literal> hook, which is run once per "
dongsheng@627 12226 "changeset, regardless of whether the changesets arrive in a group."
dongsheng@627 12227 msgstr ""
dongsheng@627 12228
dongsheng@627 12229 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 12230 #: ../en/ch09-hook.xml:1486
dongsheng@627 12231 msgid ""
dongsheng@627 12232 "Some possible uses for this hook include kicking off an automated build or "
dongsheng@627 12233 "test of the added changesets, updating a bug database, or notifying "
dongsheng@627 12234 "subscribers that a repository contains new changes."
dongsheng@627 12235 msgstr ""
dongsheng@627 12236
dongsheng@627 12237 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 12238 #: ../en/ch09-hook.xml:1492 ../en/ch09-hook.xml:1532 ../en/ch09-hook.xml:1576
dongsheng@650 12239 #: ../en/ch09-hook.xml:1618 ../en/ch09-hook.xml:1673 ../en/ch09-hook.xml:1713
songdongsheng@658 12240 #: ../en/ch09-hook.xml:1749 ../en/ch09-hook.xml:1783 ../en/ch09-hook.xml:1846
songdongsheng@658 12241 #: ../en/ch09-hook.xml:1904 ../en/ch09-hook.xml:1940 ../en/ch09-hook.xml:1967
dongsheng@627 12242 msgid "Parameters to this hook:"
dongsheng@627 12243 msgstr ""
dongsheng@627 12244
dongsheng@627 12245 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 12246 #: ../en/ch09-hook.xml:1495 ../en/ch09-hook.xml:1849
dongsheng@627 12247 msgid ""
dongsheng@627 12248 "<literal>node</literal>: A changeset ID. The changeset ID of the first "
dongsheng@627 12249 "changeset in the group that was added. All changesets between this and "
dongsheng@650 12250 "<literal role=\"tag\">tip</literal>, inclusive, were added by a single "
dongsheng@650 12251 "<command role=\"hg-cmd\">hg pull</command>, <command role=\"hg-cmd\">hg push</"
dongsheng@650 12252 "command> or <command role=\"hg-cmd\">hg unbundle</command>."
dongsheng@627 12253 msgstr ""
dongsheng@627 12254
dongsheng@627 12255 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 12256 #: ../en/ch09-hook.xml:1504 ../en/ch09-hook.xml:1583 ../en/ch09-hook.xml:1676
dongsheng@650 12257 #: ../en/ch09-hook.xml:1859
dongsheng@627 12258 msgid ""
songdongsheng@658 12259 "<literal>source</literal>: A string. The source of these changes. See <xref "
songdongsheng@658 12260 "linkend=\"sec:hook:sources\"/> for details."
dongsheng@627 12261 msgstr ""
dongsheng@627 12262
dongsheng@627 12263 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 12264 #: ../en/ch09-hook.xml:1509 ../en/ch09-hook.xml:1588 ../en/ch09-hook.xml:1639
songdongsheng@658 12265 #: ../en/ch09-hook.xml:1681 ../en/ch09-hook.xml:1762 ../en/ch09-hook.xml:1864
dongsheng@627 12266 msgid ""
dongsheng@627 12267 "<literal>url</literal>: A URL. The location of the remote repository, if "
songdongsheng@658 12268 "known. See <xref linkend=\"sec:hook:url\"/> for more information."
songdongsheng@658 12269 msgstr ""
songdongsheng@658 12270
songdongsheng@658 12271 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 12272 #: ../en/ch09-hook.xml:1515
songdongsheng@658 12273 msgid ""
songdongsheng@658 12274 "See also: <literal role=\"hook\">incoming</literal> (<xref linkend=\"sec:hook:"
songdongsheng@658 12275 "incoming\"/>), <literal role=\"hook\">prechangegroup</literal> (<xref linkend="
songdongsheng@658 12276 "\"sec:hook:prechangegroup\"/>), <literal role=\"hook\">pretxnchangegroup</"
songdongsheng@658 12277 "literal> (<xref linkend=\"sec:hook:pretxnchangegroup\"/>)"
dongsheng@627 12278 msgstr ""
dongsheng@627 12279
dongsheng@627 12280 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 12281 #: ../en/ch09-hook.xml:1526
songdongsheng@668 12282 msgid ""
songdongsheng@668 12283 "<literal role=\"hook\">commit</literal>&emdash;after a new changeset is "
songdongsheng@668 12284 "created"
dongsheng@661 12285 msgstr "<literal role=\"hook\">commit</literal>—创建新修改集之后"
dongsheng@627 12286
dongsheng@627 12287 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 12288 #: ../en/ch09-hook.xml:1529
dongsheng@627 12289 msgid "This hook is run after a new changeset has been created."
dongsheng@627 12290 msgstr ""
dongsheng@627 12291
dongsheng@627 12292 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 12293 #: ../en/ch09-hook.xml:1535 ../en/ch09-hook.xml:1907
dongsheng@627 12294 msgid ""
dongsheng@627 12295 "<literal>node</literal>: A changeset ID. The changeset ID of the newly "
dongsheng@627 12296 "committed changeset."
dongsheng@627 12297 msgstr ""
dongsheng@627 12298
dongsheng@627 12299 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 12300 #: ../en/ch09-hook.xml:1539 ../en/ch09-hook.xml:1911
dongsheng@627 12301 msgid ""
dongsheng@627 12302 "<literal>parent1</literal>: A changeset ID. The changeset ID of the first "
dongsheng@627 12303 "parent of the newly committed changeset."
dongsheng@627 12304 msgstr ""
dongsheng@627 12305
dongsheng@627 12306 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 12307 #: ../en/ch09-hook.xml:1544 ../en/ch09-hook.xml:1916
dongsheng@627 12308 msgid ""
dongsheng@627 12309 "<literal>parent2</literal>: A changeset ID. The changeset ID of the second "
dongsheng@627 12310 "parent of the newly committed changeset."
dongsheng@627 12311 msgstr ""
dongsheng@627 12312
dongsheng@627 12313 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 12314 #: ../en/ch09-hook.xml:1550
songdongsheng@658 12315 msgid ""
songdongsheng@658 12316 "See also: <literal role=\"hook\">precommit</literal> (<xref linkend=\"sec:"
songdongsheng@658 12317 "hook:precommit\"/>), <literal role=\"hook\">pretxncommit</literal> (<xref "
songdongsheng@658 12318 "linkend=\"sec:hook:pretxncommit\"/>)"
dongsheng@627 12319 msgstr ""
dongsheng@627 12320
dongsheng@627 12321 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 12322 #: ../en/ch09-hook.xml:1559
songdongsheng@668 12323 msgid ""
songdongsheng@668 12324 "<literal role=\"hook\">incoming</literal>&emdash;after one remote changeset "
songdongsheng@668 12325 "is added"
dongsheng@661 12326 msgstr "<literal role=\"hook\">incoming</literal>—增加远程修改集之后"
dongsheng@627 12327
dongsheng@627 12328 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 12329 #: ../en/ch09-hook.xml:1562
dongsheng@627 12330 msgid ""
dongsheng@627 12331 "This hook is run after a pre-existing changeset has been added to the "
dongsheng@627 12332 "repository, for example via a <command role=\"hg-cmd\">hg push</command>. If "
dongsheng@627 12333 "a group of changesets was added in a single operation, this hook is called "
dongsheng@627 12334 "once for each added changeset."
dongsheng@627 12335 msgstr ""
dongsheng@627 12336
dongsheng@627 12337 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 12338 #: ../en/ch09-hook.xml:1569
dongsheng@627 12339 msgid ""
dongsheng@627 12340 "You can use this hook for the same purposes as the <literal role=\"hook"
songdongsheng@658 12341 "\">changegroup</literal> hook (<xref linkend=\"sec:hook:changegroup\"/>); "
songdongsheng@658 12342 "it's simply more convenient sometimes to run a hook once per group of "
dongsheng@627 12343 "changesets, while other times it's handier once per changeset."
dongsheng@627 12344 msgstr ""
dongsheng@627 12345
dongsheng@627 12346 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 12347 #: ../en/ch09-hook.xml:1579
dongsheng@627 12348 msgid ""
dongsheng@627 12349 "<literal>node</literal>: A changeset ID. The ID of the newly added changeset."
dongsheng@627 12350 msgstr ""
dongsheng@627 12351
dongsheng@627 12352 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 12353 #: ../en/ch09-hook.xml:1594
songdongsheng@658 12354 msgid ""
songdongsheng@658 12355 "See also: <literal role=\"hook\">changegroup</literal> (<xref linkend=\"sec:"
songdongsheng@658 12356 "hook:changegroup\"/>) <literal role=\"hook\">prechangegroup</literal> (<xref "
songdongsheng@658 12357 "linkend=\"sec:hook:prechangegroup\"/>), <literal role=\"hook"
songdongsheng@658 12358 "\">pretxnchangegroup</literal> (<xref linkend=\"sec:hook:pretxnchangegroup\"/"
songdongsheng@658 12359 ">)"
dongsheng@627 12360 msgstr ""
dongsheng@627 12361
dongsheng@627 12362 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 12363 #: ../en/ch09-hook.xml:1605
songdongsheng@668 12364 msgid ""
songdongsheng@668 12365 "<literal role=\"hook\">outgoing</literal>&emdash;after changesets are "
songdongsheng@668 12366 "propagated"
dongsheng@661 12367 msgstr "<literal role=\"hook\">outgoing</literal>—传播修改集之后"
dongsheng@627 12368
dongsheng@627 12369 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 12370 #: ../en/ch09-hook.xml:1608
dongsheng@627 12371 msgid ""
dongsheng@627 12372 "This hook is run after a group of changesets has been propagated out of this "
dongsheng@627 12373 "repository, for example by a <command role=\"hg-cmd\">hg push</command> or "
dongsheng@627 12374 "<command role=\"hg-cmd\">hg bundle</command> command."
dongsheng@627 12375 msgstr ""
dongsheng@627 12376
dongsheng@627 12377 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 12378 #: ../en/ch09-hook.xml:1614
dongsheng@627 12379 msgid ""
dongsheng@627 12380 "One possible use for this hook is to notify administrators that changes have "
dongsheng@627 12381 "been pulled."
dongsheng@627 12382 msgstr ""
dongsheng@627 12383
dongsheng@627 12384 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 12385 #: ../en/ch09-hook.xml:1621
dongsheng@627 12386 msgid ""
dongsheng@627 12387 "<literal>node</literal>: A changeset ID. The changeset ID of the first "
dongsheng@627 12388 "changeset of the group that was sent."
dongsheng@627 12389 msgstr ""
dongsheng@627 12390
dongsheng@627 12391 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 12392 #: ../en/ch09-hook.xml:1626
dongsheng@627 12393 msgid ""
dongsheng@627 12394 "<literal>source</literal>: A string. The source of the of the operation (see "
songdongsheng@658 12395 "<xref linkend=\"sec:hook:sources\"/>). If a remote client pulled changes "
songdongsheng@658 12396 "from this repository, <literal>source</literal> will be <literal>serve</"
songdongsheng@658 12397 "literal>. If the client that obtained changes from this repository was "
songdongsheng@658 12398 "local, <literal>source</literal> will be <literal>bundle</literal>, "
songdongsheng@658 12399 "<literal>pull</literal>, or <literal>push</literal>, depending on the "
songdongsheng@658 12400 "operation the client performed."
songdongsheng@658 12401 msgstr ""
songdongsheng@658 12402
songdongsheng@658 12403 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 12404 #: ../en/ch09-hook.xml:1645
songdongsheng@658 12405 msgid ""
songdongsheng@658 12406 "See also: <literal role=\"hook\">preoutgoing</literal> (<xref linkend=\"sec:"
songdongsheng@658 12407 "hook:preoutgoing\"/>)"
dongsheng@627 12408 msgstr ""
dongsheng@627 12409
dongsheng@627 12410 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 12411 #: ../en/ch09-hook.xml:1652
songdongsheng@668 12412 msgid ""
songdongsheng@668 12413 "<literal role=\"hook\">prechangegroup</literal>&emdash;before starting to add "
songdongsheng@668 12414 "remote changesets"
dongsheng@661 12415 msgstr "<literal role=\"hook\">prechangegroup</literal>—增加远程修改集之前"
dongsheng@627 12416
dongsheng@627 12417 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 12418 #: ../en/ch09-hook.xml:1656
dongsheng@627 12419 msgid ""
dongsheng@627 12420 "This controlling hook is run before Mercurial begins to add a group of "
dongsheng@627 12421 "changesets from another repository."
dongsheng@627 12422 msgstr ""
dongsheng@627 12423
dongsheng@627 12424 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 12425 #: ../en/ch09-hook.xml:1660
dongsheng@627 12426 msgid ""
dongsheng@627 12427 "This hook does not have any information about the changesets to be added, "
dongsheng@627 12428 "because it is run before transmission of those changesets is allowed to "
dongsheng@627 12429 "begin. If this hook fails, the changesets will not be transmitted."
dongsheng@627 12430 msgstr ""
dongsheng@627 12431
dongsheng@627 12432 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 12433 #: ../en/ch09-hook.xml:1666
dongsheng@627 12434 msgid ""
dongsheng@627 12435 "One use for this hook is to prevent external changes from being added to a "
dongsheng@627 12436 "repository. For example, you could use this to <quote>freeze</quote> a "
dongsheng@627 12437 "server-hosted branch temporarily or permanently so that users cannot push to "
dongsheng@627 12438 "it, while still allowing a local administrator to modify the repository."
dongsheng@627 12439 msgstr ""
dongsheng@627 12440
dongsheng@627 12441 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 12442 #: ../en/ch09-hook.xml:1687
songdongsheng@658 12443 msgid ""
songdongsheng@658 12444 "See also: <literal role=\"hook\">changegroup</literal> (<xref linkend=\"sec:"
songdongsheng@658 12445 "hook:changegroup\"/>), <literal role=\"hook\">incoming</literal> (<xref "
songdongsheng@658 12446 "linkend=\"sec:hook:incoming\"/>), <literal role=\"hook\">pretxnchangegroup</"
songdongsheng@658 12447 "literal> (<xref linkend=\"sec:hook:pretxnchangegroup\"/>)"
dongsheng@627 12448 msgstr ""
dongsheng@627 12449
dongsheng@627 12450 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 12451 #: ../en/ch09-hook.xml:1698
songdongsheng@668 12452 msgid ""
songdongsheng@668 12453 "<literal role=\"hook\">precommit</literal>&emdash;before starting to commit a "
dongsheng@627 12454 "changeset"
dongsheng@661 12455 msgstr "<literal role=\"hook\">precommit</literal>—提交修改集之前"
dongsheng@627 12456
dongsheng@627 12457 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 12458 #: ../en/ch09-hook.xml:1701
dongsheng@627 12459 msgid ""
dongsheng@627 12460 "This hook is run before Mercurial begins to commit a new changeset. It is run "
dongsheng@627 12461 "before Mercurial has any of the metadata for the commit, such as the files to "
dongsheng@627 12462 "be committed, the commit message, or the commit date."
dongsheng@627 12463 msgstr ""
dongsheng@627 12464
dongsheng@627 12465 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 12466 #: ../en/ch09-hook.xml:1707
dongsheng@627 12467 msgid ""
dongsheng@627 12468 "One use for this hook is to disable the ability to commit new changesets, "
dongsheng@627 12469 "while still allowing incoming changesets. Another is to run a build or test, "
dongsheng@627 12470 "and only allow the commit to begin if the build or test succeeds."
dongsheng@627 12471 msgstr ""
dongsheng@627 12472
dongsheng@627 12473 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 12474 #: ../en/ch09-hook.xml:1716
dongsheng@627 12475 msgid ""
dongsheng@627 12476 "<literal>parent1</literal>: A changeset ID. The changeset ID of the first "
dongsheng@627 12477 "parent of the working directory."
dongsheng@627 12478 msgstr ""
dongsheng@627 12479
dongsheng@627 12480 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 12481 #: ../en/ch09-hook.xml:1721
dongsheng@627 12482 msgid ""
dongsheng@627 12483 "<literal>parent2</literal>: A changeset ID. The changeset ID of the second "
dongsheng@627 12484 "parent of the working directory."
dongsheng@627 12485 msgstr ""
dongsheng@627 12486
dongsheng@627 12487 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 12488 #: ../en/ch09-hook.xml:1726
dongsheng@627 12489 msgid ""
dongsheng@627 12490 "If the commit proceeds, the parents of the working directory will become the "
dongsheng@627 12491 "parents of the new changeset."
dongsheng@627 12492 msgstr ""
dongsheng@627 12493
dongsheng@627 12494 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 12495 #: ../en/ch09-hook.xml:1730
dongsheng@627 12496 msgid ""
songdongsheng@658 12497 "See also: <literal role=\"hook\">commit</literal> (<xref linkend=\"sec:hook:"
songdongsheng@658 12498 "commit\"/>), <literal role=\"hook\">pretxncommit</literal> (<xref linkend="
songdongsheng@658 12499 "\"sec:hook:pretxncommit\"/>)"
dongsheng@627 12500 msgstr ""
dongsheng@627 12501
dongsheng@627 12502 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 12503 #: ../en/ch09-hook.xml:1738
songdongsheng@668 12504 msgid ""
songdongsheng@668 12505 "<literal role=\"hook\">preoutgoing</literal>&emdash;before starting to "
songdongsheng@668 12506 "propagate changesets"
dongsheng@661 12507 msgstr "<literal role=\"hook\">preoutgoing</literal>—传播修改集之前"
dongsheng@627 12508
dongsheng@627 12509 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 12510 #: ../en/ch09-hook.xml:1741
dongsheng@627 12511 msgid ""
dongsheng@627 12512 "This hook is invoked before Mercurial knows the identities of the changesets "
dongsheng@627 12513 "to be transmitted."
dongsheng@627 12514 msgstr ""
dongsheng@627 12515
dongsheng@627 12516 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 12517 #: ../en/ch09-hook.xml:1745
dongsheng@627 12518 msgid ""
dongsheng@627 12519 "One use for this hook is to prevent changes from being transmitted to another "
dongsheng@627 12520 "repository."
dongsheng@627 12521 msgstr ""
dongsheng@627 12522
dongsheng@627 12523 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 12524 #: ../en/ch09-hook.xml:1752
dongsheng@627 12525 msgid ""
dongsheng@627 12526 "<literal>source</literal>: A string. The source of the operation that is "
songdongsheng@658 12527 "attempting to obtain changes from this repository (see <xref linkend=\"sec:"
songdongsheng@658 12528 "hook:sources\"/>). See the documentation for the <literal>source</literal> "
songdongsheng@658 12529 "parameter to the <literal role=\"hook\">outgoing</literal> hook, in <xref "
songdongsheng@658 12530 "linkend=\"sec:hook:outgoing\"/>, for possible values of this parameter."
songdongsheng@658 12531 msgstr ""
songdongsheng@658 12532
songdongsheng@658 12533 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 12534 #: ../en/ch09-hook.xml:1768
songdongsheng@658 12535 msgid ""
songdongsheng@658 12536 "See also: <literal role=\"hook\">outgoing</literal> (<xref linkend=\"sec:hook:"
songdongsheng@658 12537 "outgoing\"/>)"
dongsheng@627 12538 msgstr ""
dongsheng@627 12539
dongsheng@627 12540 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 12541 #: ../en/ch09-hook.xml:1775
songdongsheng@668 12542 msgid ""
songdongsheng@668 12543 "<literal role=\"hook\">pretag</literal>&emdash;before tagging a changeset"
dongsheng@661 12544 msgstr "<literal role=\"hook\">pretag</literal>—创建标签之前"
dongsheng@627 12545
dongsheng@627 12546 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 12547 #: ../en/ch09-hook.xml:1778
dongsheng@627 12548 msgid ""
dongsheng@627 12549 "This controlling hook is run before a tag is created. If the hook succeeds, "
dongsheng@627 12550 "creation of the tag proceeds. If the hook fails, the tag is not created."
dongsheng@627 12551 msgstr ""
dongsheng@627 12552
dongsheng@627 12553 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 12554 #: ../en/ch09-hook.xml:1786
dongsheng@627 12555 msgid ""
dongsheng@627 12556 "<literal>local</literal>: A boolean. Whether the tag is local to this "
dongsheng@627 12557 "repository instance (i.e. stored in <filename role=\"special\">.hg/localtags</"
dongsheng@627 12558 "filename>) or managed by Mercurial (stored in <filename role=\"special\">."
dongsheng@627 12559 "hgtags</filename>)."
dongsheng@627 12560 msgstr ""
dongsheng@627 12561
dongsheng@627 12562 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 12563 #: ../en/ch09-hook.xml:1793
dongsheng@627 12564 msgid ""
dongsheng@627 12565 "<literal>node</literal>: A changeset ID. The ID of the changeset to be "
dongsheng@627 12566 "tagged."
dongsheng@627 12567 msgstr ""
dongsheng@627 12568
dongsheng@627 12569 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 12570 #: ../en/ch09-hook.xml:1797
dongsheng@627 12571 msgid "<literal>tag</literal>: A string. The name of the tag to be created."
dongsheng@627 12572 msgstr ""
dongsheng@627 12573
dongsheng@627 12574 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 12575 #: ../en/ch09-hook.xml:1802
dongsheng@627 12576 msgid ""
dongsheng@627 12577 "If the tag to be created is revision-controlled, the <literal role=\"hook"
dongsheng@627 12578 "\">precommit</literal> and <literal role=\"hook\">pretxncommit</literal> "
songdongsheng@658 12579 "hooks (<xref linkend=\"sec:hook:commit\"/> and <xref linkend=\"sec:hook:"
songdongsheng@658 12580 "pretxncommit\"/>) will also be run."
dongsheng@627 12581 msgstr ""
dongsheng@627 12582
dongsheng@627 12583 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 12584 #: ../en/ch09-hook.xml:1810
dongsheng@627 12585 msgid ""
songdongsheng@658 12586 "See also: <literal role=\"hook\">tag</literal> (<xref linkend=\"sec:hook:tag"
songdongsheng@658 12587 "\"/>)"
dongsheng@627 12588 msgstr ""
dongsheng@627 12589
dongsheng@627 12590 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 12591 #: ../en/ch09-hook.xml:1815
songdongsheng@668 12592 msgid ""
songdongsheng@668 12593 "<literal role=\"hook\">pretxnchangegroup</literal>&emdash;before completing "
songdongsheng@668 12594 "addition of remote changesets"
dongsheng@661 12595 msgstr ""
dongsheng@661 12596 "<literal role=\"hook\">pretxnchangegroup</literal>—完成增加远程修改集之前"
dongsheng@627 12597
dongsheng@627 12598 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 12599 #: ../en/ch09-hook.xml:1819
dongsheng@627 12600 msgid ""
songdongsheng@668 12601 "This controlling hook is run before a transaction&emdash;that manages the "
songdongsheng@668 12602 "addition of a group of new changesets from outside the repository&emdash;"
songdongsheng@668 12603 "completes. If the hook succeeds, the transaction completes, and all of the "
songdongsheng@668 12604 "changesets become permanent within this repository. If the hook fails, the "
songdongsheng@668 12605 "transaction is rolled back, and the data for the changesets is erased."
dongsheng@627 12606 msgstr ""
dongsheng@627 12607
dongsheng@627 12608 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 12609 #: ../en/ch09-hook.xml:1828
dongsheng@627 12610 msgid ""
dongsheng@627 12611 "This hook can access the metadata associated with the almost-added "
dongsheng@627 12612 "changesets, but it should not do anything permanent with this data. It must "
dongsheng@627 12613 "also not modify the working directory."
dongsheng@627 12614 msgstr ""
dongsheng@627 12615
dongsheng@627 12616 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 12617 #: ../en/ch09-hook.xml:1834
dongsheng@627 12618 msgid ""
dongsheng@627 12619 "While this hook is running, if other Mercurial processes access this "
dongsheng@627 12620 "repository, they will be able to see the almost-added changesets as if they "
dongsheng@627 12621 "are permanent. This may lead to race conditions if you do not take steps to "
dongsheng@627 12622 "avoid them."
dongsheng@627 12623 msgstr ""
dongsheng@627 12624
dongsheng@627 12625 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 12626 #: ../en/ch09-hook.xml:1841
dongsheng@627 12627 msgid ""
dongsheng@627 12628 "This hook can be used to automatically vet a group of changesets. If the "
dongsheng@627 12629 "hook fails, all of the changesets are <quote>rejected</quote> when the "
dongsheng@627 12630 "transaction rolls back."
dongsheng@627 12631 msgstr ""
dongsheng@627 12632
dongsheng@627 12633 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 12634 #: ../en/ch09-hook.xml:1870
songdongsheng@658 12635 msgid ""
songdongsheng@658 12636 "See also: <literal role=\"hook\">changegroup</literal> (<xref linkend=\"sec:"
songdongsheng@658 12637 "hook:changegroup\"/>), <literal role=\"hook\">incoming</literal> (<xref "
songdongsheng@658 12638 "linkend=\"sec:hook:incoming\"/>), <literal role=\"hook\">prechangegroup</"
songdongsheng@658 12639 "literal> (<xref linkend=\"sec:hook:prechangegroup\"/>)"
dongsheng@627 12640 msgstr ""
dongsheng@627 12641
dongsheng@627 12642 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 12643 #: ../en/ch09-hook.xml:1881
songdongsheng@668 12644 msgid ""
songdongsheng@668 12645 "<literal role=\"hook\">pretxncommit</literal>&emdash;before completing commit "
songdongsheng@668 12646 "of new changeset"
dongsheng@661 12647 msgstr "<literal role=\"hook\">pretxncommit</literal>—完成提交之前"
dongsheng@627 12648
dongsheng@627 12649 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 12650 #: ../en/ch09-hook.xml:1884
dongsheng@627 12651 msgid ""
songdongsheng@668 12652 "This controlling hook is run before a transaction&emdash;that manages a new "
songdongsheng@668 12653 "commit&emdash;completes. If the hook succeeds, the transaction completes and "
songdongsheng@668 12654 "the changeset becomes permanent within this repository. If the hook fails, "
songdongsheng@668 12655 "the transaction is rolled back, and the commit data is erased."
dongsheng@627 12656 msgstr ""
dongsheng@627 12657
dongsheng@627 12658 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 12659 #: ../en/ch09-hook.xml:1892
dongsheng@627 12660 msgid ""
dongsheng@627 12661 "This hook can access the metadata associated with the almost-new changeset, "
dongsheng@627 12662 "but it should not do anything permanent with this data. It must also not "
dongsheng@627 12663 "modify the working directory."
dongsheng@627 12664 msgstr ""
dongsheng@627 12665
dongsheng@627 12666 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 12667 #: ../en/ch09-hook.xml:1898
dongsheng@627 12668 msgid ""
dongsheng@627 12669 "While this hook is running, if other Mercurial processes access this "
dongsheng@627 12670 "repository, they will be able to see the almost-new changeset as if it is "
dongsheng@627 12671 "permanent. This may lead to race conditions if you do not take steps to "
dongsheng@627 12672 "avoid them."
dongsheng@627 12673 msgstr ""
dongsheng@627 12674
dongsheng@627 12675 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 12676 #: ../en/ch09-hook.xml:1922
songdongsheng@658 12677 msgid ""
songdongsheng@658 12678 "See also: <literal role=\"hook\">precommit</literal> (<xref linkend=\"sec:"
songdongsheng@658 12679 "hook:precommit\"/>)"
dongsheng@660 12680 msgstr ""
dongsheng@660 12681 "参见: <literal role=\"hook\">precommit</literal> (<xref linkend=\"sec:hook:"
dongsheng@660 12682 "precommit\"/>)"
dongsheng@627 12683
dongsheng@627 12684 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 12685 #: ../en/ch09-hook.xml:1929
songdongsheng@668 12686 msgid ""
songdongsheng@668 12687 "<literal role=\"hook\">preupdate</literal>&emdash;before updating or merging "
songdongsheng@668 12688 "working directory"
dongsheng@661 12689 msgstr "<literal role=\"hook\">preupdate</literal>—更新或合并工作目录之前"
dongsheng@627 12690
dongsheng@627 12691 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 12692 #: ../en/ch09-hook.xml:1932
dongsheng@627 12693 msgid ""
dongsheng@627 12694 "This controlling hook is run before an update or merge of the working "
dongsheng@627 12695 "directory begins. It is run only if Mercurial's normal pre-update checks "
dongsheng@627 12696 "determine that the update or merge can proceed. If the hook succeeds, the "
dongsheng@627 12697 "update or merge may proceed; if it fails, the update or merge does not start."
dongsheng@627 12698 msgstr ""
dongsheng@627 12699
dongsheng@627 12700 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 12701 #: ../en/ch09-hook.xml:1943
songdongsheng@658 12702 msgid ""
songdongsheng@658 12703 "<literal>parent1</literal>: A changeset ID. The ID of the parent that the "
dongsheng@627 12704 "working directory is to be updated to. If the working directory is being "
dongsheng@627 12705 "merged, it will not change this parent."
dongsheng@627 12706 msgstr ""
dongsheng@627 12707
dongsheng@627 12708 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 12709 #: ../en/ch09-hook.xml:1949
songdongsheng@658 12710 msgid ""
songdongsheng@658 12711 "<literal>parent2</literal>: A changeset ID. Only set if the working directory "
songdongsheng@658 12712 "is being merged. The ID of the revision that the working directory is being "
songdongsheng@658 12713 "merged with."
songdongsheng@658 12714 msgstr ""
songdongsheng@658 12715
songdongsheng@658 12716 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 12717 #: ../en/ch09-hook.xml:1956
songdongsheng@658 12718 msgid ""
songdongsheng@658 12719 "See also: <literal role=\"hook\">update</literal> (<xref linkend=\"sec:hook:"
songdongsheng@658 12720 "update\"/>)"
dongsheng@627 12721 msgstr ""
dongsheng@627 12722
dongsheng@627 12723 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 12724 #: ../en/ch09-hook.xml:1961
songdongsheng@668 12725 msgid "<literal role=\"hook\">tag</literal>&emdash;after tagging a changeset"
dongsheng@661 12726 msgstr "<literal role=\"hook\">tag</literal>—创建标签之后"
dongsheng@627 12727
dongsheng@627 12728 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 12729 #: ../en/ch09-hook.xml:1964
dongsheng@627 12730 msgid "This hook is run after a tag has been created."
dongsheng@627 12731 msgstr ""
dongsheng@627 12732
dongsheng@627 12733 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 12734 #: ../en/ch09-hook.xml:1970
dongsheng@627 12735 msgid ""
dongsheng@627 12736 "<literal>local</literal>: A boolean. Whether the new tag is local to this "
dongsheng@627 12737 "repository instance (i.e. stored in <filename role=\"special\">.hg/"
dongsheng@627 12738 "localtags</filename>) or managed by Mercurial (stored in <filename role="
dongsheng@627 12739 "\"special\">.hgtags</filename>)."
dongsheng@627 12740 msgstr ""
dongsheng@627 12741
dongsheng@627 12742 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 12743 #: ../en/ch09-hook.xml:1978
dongsheng@627 12744 msgid ""
dongsheng@627 12745 "<literal>node</literal>: A changeset ID. The ID of the changeset that was "
dongsheng@627 12746 "tagged."
dongsheng@627 12747 msgstr ""
dongsheng@627 12748
dongsheng@627 12749 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 12750 #: ../en/ch09-hook.xml:1982
dongsheng@627 12751 msgid "<literal>tag</literal>: A string. The name of the tag that was created."
dongsheng@627 12752 msgstr ""
dongsheng@627 12753
dongsheng@627 12754 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 12755 #: ../en/ch09-hook.xml:1987
dongsheng@627 12756 msgid ""
dongsheng@627 12757 "If the created tag is revision-controlled, the <literal role=\"hook\">commit</"
songdongsheng@658 12758 "literal> hook (section <xref linkend=\"sec:hook:commit\"/>) is run before "
dongsheng@627 12759 "this hook."
dongsheng@627 12760 msgstr ""
dongsheng@627 12761
dongsheng@627 12762 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 12763 #: ../en/ch09-hook.xml:1992
songdongsheng@658 12764 msgid ""
songdongsheng@658 12765 "See also: <literal role=\"hook\">pretag</literal> (<xref linkend=\"sec:hook:"
songdongsheng@658 12766 "pretag\"/>)"
dongsheng@660 12767 msgstr ""
dongsheng@660 12768 "参见: <literal role=\"hook\">pretag</literal> (<xref linkend=\"sec:hook:pretag"
dongsheng@660 12769 "\"/>)"
dongsheng@627 12770
dongsheng@627 12771 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 12772 #: ../en/ch09-hook.xml:1998
songdongsheng@668 12773 msgid ""
songdongsheng@668 12774 "<literal role=\"hook\">update</literal>&emdash;after updating or merging "
songdongsheng@668 12775 "working directory"
dongsheng@661 12776 msgstr "<literal role=\"hook\">update</literal>—更新或合并工作目录之后"
dongsheng@627 12777
dongsheng@627 12778 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 12779 #: ../en/ch09-hook.xml:2001
dongsheng@627 12780 msgid ""
dongsheng@627 12781 "This hook is run after an update or merge of the working directory "
dongsheng@627 12782 "completes. Since a merge can fail (if the external <command>hgmerge</"
dongsheng@627 12783 "command> command fails to resolve conflicts in a file), this hook "
dongsheng@627 12784 "communicates whether the update or merge completed cleanly."
dongsheng@627 12785 msgstr ""
dongsheng@627 12786
dongsheng@627 12787 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 12788 #: ../en/ch09-hook.xml:2009
dongsheng@627 12789 msgid ""
dongsheng@627 12790 "<literal>error</literal>: A boolean. Indicates whether the update or merge "
dongsheng@627 12791 "completed successfully."
dongsheng@627 12792 msgstr ""
dongsheng@627 12793
dongsheng@627 12794 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 12795 #: ../en/ch09-hook.xml:2014
dongsheng@627 12796 msgid ""
dongsheng@627 12797 "<literal>parent1</literal>: A changeset ID. The ID of the parent that the "
dongsheng@627 12798 "working directory was updated to. If the working directory was merged, it "
dongsheng@627 12799 "will not have changed this parent."
dongsheng@627 12800 msgstr ""
dongsheng@627 12801
dongsheng@627 12802 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 12803 #: ../en/ch09-hook.xml:2020
dongsheng@627 12804 msgid ""
dongsheng@627 12805 "<literal>parent2</literal>: A changeset ID. Only set if the working "
dongsheng@627 12806 "directory was merged. The ID of the revision that the working directory was "
dongsheng@627 12807 "merged with."
dongsheng@627 12808 msgstr ""
dongsheng@627 12809
dongsheng@627 12810 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 12811 #: ../en/ch09-hook.xml:2026
songdongsheng@658 12812 msgid ""
songdongsheng@658 12813 "See also: <literal role=\"hook\">preupdate</literal> (<xref linkend=\"sec:"
songdongsheng@658 12814 "hook:preupdate\"/>)"
dongsheng@627 12815 msgstr ""
dongsheng@627 12816
dongsheng@627 12817 #. type: Content of: <book><chapter><title>
dongsheng@650 12818 #: ../en/ch10-template.xml:5
dongsheng@627 12819 msgid "Customising the output of Mercurial"
dongsheng@627 12820 msgstr "定制 Mercurial 的输出"
dongsheng@627 12821
dongsheng@627 12822 #. type: Content of: <book><chapter><para>
dongsheng@650 12823 #: ../en/ch10-template.xml:7
dongsheng@627 12824 msgid ""
dongsheng@627 12825 "Mercurial provides a powerful mechanism to let you control how it displays "
dongsheng@627 12826 "information. The mechanism is based on templates. You can use templates to "
dongsheng@627 12827 "generate specific output for a single command, or to customise the entire "
dongsheng@627 12828 "appearance of the built-in web interface."
dongsheng@627 12829 msgstr ""
dongsheng@627 12830
dongsheng@627 12831 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 12832 #: ../en/ch10-template.xml:14
dongsheng@627 12833 msgid "Using precanned output styles"
dongsheng@636 12834 msgstr "使用预定义的输出样式"
dongsheng@627 12835
dongsheng@627 12836 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 12837 #: ../en/ch10-template.xml:16
dongsheng@627 12838 msgid ""
dongsheng@627 12839 "Packaged with Mercurial are some output styles that you can use immediately. "
dongsheng@627 12840 "A style is simply a precanned template that someone wrote and installed "
dongsheng@627 12841 "somewhere that Mercurial can find."
dongsheng@627 12842 msgstr ""
dongsheng@627 12843
dongsheng@627 12844 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 12845 #: ../en/ch10-template.xml:21
dongsheng@627 12846 msgid ""
dongsheng@627 12847 "Before we take a look at Mercurial's bundled styles, let's review its normal "
dongsheng@627 12848 "output."
dongsheng@627 12849 msgstr ""
dongsheng@627 12850
dongsheng@627 12851 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 12852 #: ../en/ch10-template.xml:26
dongsheng@627 12853 msgid ""
songdongsheng@668 12854 "This is somewhat informative, but it takes up a lot of space&emdash;five "
songdongsheng@668 12855 "lines of output per changeset. The <literal>compact</literal> style reduces "
songdongsheng@668 12856 "this to three lines, presented in a sparse manner."
dongsheng@627 12857 msgstr ""
dongsheng@627 12858
dongsheng@627 12859 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 12860 #: ../en/ch10-template.xml:33
dongsheng@627 12861 msgid ""
dongsheng@627 12862 "The <literal>changelog</literal> style hints at the expressive power of "
dongsheng@627 12863 "Mercurial's templating engine. This style attempts to follow the GNU "
dongsheng@627 12864 "Project's changelog guidelines<citation>web:changelog</citation>."
dongsheng@627 12865 msgstr ""
dongsheng@627 12866
dongsheng@627 12867 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 12868 #: ../en/ch10-template.xml:40
dongsheng@627 12869 msgid ""
dongsheng@627 12870 "You will not be shocked to learn that Mercurial's default output style is "
dongsheng@627 12871 "named <literal>default</literal>."
dongsheng@627 12872 msgstr ""
dongsheng@627 12873
dongsheng@627 12874 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 12875 #: ../en/ch10-template.xml:44
dongsheng@627 12876 msgid "Setting a default style"
dongsheng@636 12877 msgstr "设置默认样式"
dongsheng@627 12878
dongsheng@627 12879 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 12880 #: ../en/ch10-template.xml:46
dongsheng@627 12881 msgid ""
dongsheng@627 12882 "You can modify the output style that Mercurial will use for every command by "
dongsheng@650 12883 "editing your <filename role=\"special\">~/.hgrc</filename> file, naming the "
dongsheng@627 12884 "style you would prefer to use."
dongsheng@627 12885 msgstr ""
dongsheng@627 12886
dongsheng@627 12887 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 12888 #: ../en/ch10-template.xml:54
dongsheng@627 12889 msgid ""
dongsheng@627 12890 "If you write a style of your own, you can use it by either providing the path "
dongsheng@627 12891 "to your style file, or copying your style file into a location where "
dongsheng@627 12892 "Mercurial can find it (typically the <literal>templates</literal> "
dongsheng@627 12893 "subdirectory of your Mercurial install directory)."
dongsheng@627 12894 msgstr ""
dongsheng@627 12895
dongsheng@627 12896 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 12897 #: ../en/ch10-template.xml:63
dongsheng@627 12898 msgid "Commands that support styles and templates"
dongsheng@636 12899 msgstr "支持样式和模版的命令"
dongsheng@627 12900
dongsheng@627 12901 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 12902 #: ../en/ch10-template.xml:65
dongsheng@627 12903 msgid ""
dongsheng@627 12904 "All of Mercurial's <quote><literal>log</literal>-like</quote> commands let "
dongsheng@627 12905 "you use styles and templates: <command role=\"hg-cmd\">hg incoming</command>, "
dongsheng@627 12906 "<command role=\"hg-cmd\">hg log</command>, <command role=\"hg-cmd\">hg "
dongsheng@627 12907 "outgoing</command>, and <command role=\"hg-cmd\">hg tip</command>."
dongsheng@627 12908 msgstr ""
dongsheng@627 12909
dongsheng@627 12910 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 12911 #: ../en/ch10-template.xml:72
dongsheng@627 12912 msgid ""
dongsheng@627 12913 "As I write this manual, these are so far the only commands that support "
dongsheng@627 12914 "styles and templates. Since these are the most important commands that need "
dongsheng@627 12915 "customisable output, there has been little pressure from the Mercurial user "
dongsheng@627 12916 "community to add style and template support to other commands."
dongsheng@627 12917 msgstr ""
dongsheng@627 12918
dongsheng@627 12919 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 12920 #: ../en/ch10-template.xml:80
dongsheng@627 12921 msgid "The basics of templating"
dongsheng@636 12922 msgstr "模版基础"
dongsheng@627 12923
dongsheng@627 12924 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 12925 #: ../en/ch10-template.xml:82
dongsheng@627 12926 msgid ""
dongsheng@627 12927 "At its simplest, a Mercurial template is a piece of text. Some of the text "
dongsheng@627 12928 "never changes, while other parts are <emphasis>expanded</emphasis>, or "
dongsheng@627 12929 "replaced with new text, when necessary."
dongsheng@627 12930 msgstr ""
dongsheng@627 12931
dongsheng@627 12932 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 12933 #: ../en/ch10-template.xml:87
dongsheng@627 12934 msgid ""
dongsheng@627 12935 "Before we continue, let's look again at a simple example of Mercurial's "
dongsheng@627 12936 "normal output."
dongsheng@627 12937 msgstr ""
dongsheng@627 12938
dongsheng@627 12939 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 12940 #: ../en/ch10-template.xml:92
dongsheng@627 12941 msgid ""
dongsheng@627 12942 "Now, let's run the same command, but using a template to change its output."
dongsheng@627 12943 msgstr ""
dongsheng@627 12944
dongsheng@627 12945 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 12946 #: ../en/ch10-template.xml:97
dongsheng@627 12947 msgid ""
dongsheng@627 12948 "The example above illustrates the simplest possible template; it's just a "
dongsheng@627 12949 "piece of static text, printed once for each changeset. The <option role=\"hg-"
dongsheng@627 12950 "opt-log\">--template</option> option to the <command role=\"hg-cmd\">hg log</"
dongsheng@627 12951 "command> command tells Mercurial to use the given text as the template when "
dongsheng@627 12952 "printing each changeset."
dongsheng@627 12953 msgstr ""
dongsheng@627 12954
dongsheng@627 12955 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 12956 #: ../en/ch10-template.xml:105
dongsheng@627 12957 msgid ""
dongsheng@627 12958 "Notice that the template string above ends with the text <quote><literal>\\n</"
dongsheng@627 12959 "literal></quote>. This is an <emphasis>escape sequence</emphasis>, telling "
dongsheng@627 12960 "Mercurial to print a newline at the end of each template item. If you omit "
songdongsheng@658 12961 "this newline, Mercurial will run each piece of output together. See <xref "
songdongsheng@658 12962 "linkend=\"sec:template:escape\"/> for more details of escape sequences."
dongsheng@627 12963 msgstr ""
dongsheng@627 12964
dongsheng@627 12965 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 12966 #: ../en/ch10-template.xml:113
dongsheng@627 12967 msgid ""
dongsheng@627 12968 "A template that prints a fixed string of text all the time isn't very useful; "
dongsheng@627 12969 "let's try something a bit more complex."
dongsheng@627 12970 msgstr ""
dongsheng@627 12971
dongsheng@627 12972 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 12973 #: ../en/ch10-template.xml:119
dongsheng@627 12974 msgid ""
dongsheng@627 12975 "As you can see, the string <quote><literal>{desc}</literal></quote> in the "
dongsheng@627 12976 "template has been replaced in the output with the description of each "
dongsheng@627 12977 "changeset. Every time Mercurial finds text enclosed in curly braces "
dongsheng@627 12978 "(<quote><literal>{</literal></quote> and <quote><literal>}</literal></"
dongsheng@627 12979 "quote>), it will try to replace the braces and text with the expansion of "
dongsheng@627 12980 "whatever is inside. To print a literal curly brace, you must escape it, as "
songdongsheng@658 12981 "described in <xref linkend=\"sec:template:escape\"/>."
dongsheng@627 12982 msgstr ""
dongsheng@627 12983
dongsheng@627 12984 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@658 12985 #: ../en/ch10-template.xml:131
dongsheng@627 12986 msgid "Common template keywords"
dongsheng@636 12987 msgstr "模版关键字"
dongsheng@627 12988
dongsheng@627 12989 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 12990 #: ../en/ch10-template.xml:133
dongsheng@627 12991 msgid ""
dongsheng@627 12992 "You can start writing simple templates immediately using the keywords below."
dongsheng@627 12993 msgstr ""
dongsheng@627 12994
dongsheng@627 12995 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 12996 #: ../en/ch10-template.xml:137
dongsheng@627 12997 msgid ""
dongsheng@627 12998 "<literal role=\"template-keyword\">author</literal>: String. The unmodified "
dongsheng@627 12999 "author of the changeset."
dongsheng@627 13000 msgstr ""
dongsheng@627 13001
dongsheng@627 13002 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13003 #: ../en/ch10-template.xml:141
dongsheng@627 13004 msgid ""
dongsheng@627 13005 "<literal role=\"template-keyword\">branches</literal>: String. The name of "
dongsheng@627 13006 "the branch on which the changeset was committed. Will be empty if the branch "
dongsheng@627 13007 "name was <literal>default</literal>."
dongsheng@627 13008 msgstr ""
dongsheng@627 13009
dongsheng@627 13010 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13011 #: ../en/ch10-template.xml:147
dongsheng@627 13012 msgid ""
dongsheng@627 13013 "<literal role=\"template-keyword\">date</literal>: Date information. The "
dongsheng@627 13014 "date when the changeset was committed. This is <emphasis>not</emphasis> "
dongsheng@627 13015 "human-readable; you must pass it through a filter that will render it "
songdongsheng@658 13016 "appropriately. See <xref linkend=\"sec:template:filter\"/> for more "
dongsheng@627 13017 "information on filters. The date is expressed as a pair of numbers. The "
dongsheng@627 13018 "first number is a Unix UTC timestamp (seconds since January 1, 1970); the "
dongsheng@627 13019 "second is the offset of the committer's timezone from UTC, in seconds."
dongsheng@627 13020 msgstr ""
dongsheng@627 13021
dongsheng@627 13022 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13023 #: ../en/ch10-template.xml:158
dongsheng@627 13024 msgid ""
dongsheng@627 13025 "<literal role=\"template-keyword\">desc</literal>: String. The text of the "
dongsheng@627 13026 "changeset description."
dongsheng@627 13027 msgstr ""
dongsheng@627 13028
dongsheng@627 13029 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13030 #: ../en/ch10-template.xml:161
dongsheng@627 13031 msgid ""
dongsheng@627 13032 "<literal role=\"template-keyword\">files</literal>: List of strings. All "
dongsheng@627 13033 "files modified, added, or removed by this changeset."
dongsheng@627 13034 msgstr ""
dongsheng@627 13035
dongsheng@627 13036 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13037 #: ../en/ch10-template.xml:166
dongsheng@627 13038 msgid ""
dongsheng@627 13039 "<literal role=\"template-keyword\">file_adds</literal>: List of strings. "
dongsheng@627 13040 "Files added by this changeset."
dongsheng@627 13041 msgstr ""
dongsheng@627 13042
dongsheng@627 13043 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13044 #: ../en/ch10-template.xml:170
dongsheng@627 13045 msgid ""
dongsheng@627 13046 "<literal role=\"template-keyword\">file_dels</literal>: List of strings. "
dongsheng@627 13047 "Files removed by this changeset."
dongsheng@627 13048 msgstr ""
dongsheng@627 13049
dongsheng@627 13050 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13051 #: ../en/ch10-template.xml:174
dongsheng@627 13052 msgid ""
dongsheng@627 13053 "<literal role=\"template-keyword\">node</literal>: String. The changeset "
dongsheng@627 13054 "identification hash, as a 40-character hexadecimal string."
dongsheng@627 13055 msgstr ""
dongsheng@627 13056
dongsheng@627 13057 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13058 #: ../en/ch10-template.xml:178
dongsheng@627 13059 msgid ""
dongsheng@627 13060 "<literal role=\"template-keyword\">parents</literal>: List of strings. The "
dongsheng@627 13061 "parents of the changeset."
dongsheng@627 13062 msgstr ""
dongsheng@627 13063
dongsheng@627 13064 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13065 #: ../en/ch10-template.xml:182
dongsheng@627 13066 msgid ""
dongsheng@627 13067 "<literal role=\"template-keyword\">rev</literal>: Integer. The repository-"
dongsheng@627 13068 "local changeset revision number."
dongsheng@627 13069 msgstr ""
dongsheng@627 13070
dongsheng@627 13071 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13072 #: ../en/ch10-template.xml:186
dongsheng@627 13073 msgid ""
dongsheng@627 13074 "<literal role=\"template-keyword\">tags</literal>: List of strings. Any tags "
dongsheng@627 13075 "associated with the changeset."
dongsheng@627 13076 msgstr ""
dongsheng@627 13077
dongsheng@627 13078 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 13079 #: ../en/ch10-template.xml:191
dongsheng@627 13080 msgid ""
dongsheng@627 13081 "A few simple experiments will show us what to expect when we use these "
dongsheng@627 13082 "keywords; you can see the results below."
dongsheng@627 13083 msgstr ""
dongsheng@627 13084
dongsheng@627 13085 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 13086 #: ../en/ch10-template.xml:196
dongsheng@627 13087 msgid ""
dongsheng@627 13088 "As we noted above, the date keyword does not produce human-readable output, "
dongsheng@627 13089 "so we must treat it specially. This involves using a <emphasis>filter</"
songdongsheng@658 13090 "emphasis>, about which more in <xref linkend=\"sec:template:filter\"/>."
dongsheng@627 13091 msgstr ""
dongsheng@627 13092
dongsheng@627 13093 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@658 13094 #: ../en/ch10-template.xml:205
dongsheng@627 13095 msgid "Escape sequences"
dongsheng@636 13096 msgstr "转义序列"
dongsheng@627 13097
dongsheng@627 13098 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 13099 #: ../en/ch10-template.xml:207
dongsheng@627 13100 msgid ""
dongsheng@627 13101 "Mercurial's templating engine recognises the most commonly used escape "
dongsheng@627 13102 "sequences in strings. When it sees a backslash (<quote><literal>\\</"
dongsheng@627 13103 "literal></quote>) character, it looks at the following character and "
dongsheng@627 13104 "substitutes the two characters with a single replacement, as described below."
dongsheng@627 13105 msgstr ""
dongsheng@627 13106
dongsheng@627 13107 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13108 #: ../en/ch10-template.xml:214
dongsheng@650 13109 msgid ""
dongsheng@650 13110 "<literal>\\</literal>: Backslash, <quote><literal>\\</literal></quote>, ASCII "
dongsheng@650 13111 "134."
dongsheng@627 13112 msgstr ""
dongsheng@627 13113
dongsheng@627 13114 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13115 #: ../en/ch10-template.xml:218
dongsheng@650 13116 msgid "<literal>\\n</literal>: Newline, ASCII 12."
dongsheng@627 13117 msgstr ""
dongsheng@627 13118
dongsheng@627 13119 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13120 #: ../en/ch10-template.xml:221
dongsheng@650 13121 msgid "<literal>\\r</literal>: Carriage return, ASCII 15."
dongsheng@627 13122 msgstr ""
dongsheng@627 13123
dongsheng@627 13124 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13125 #: ../en/ch10-template.xml:224
dongsheng@650 13126 msgid "<literal>\\t</literal>: Tab, ASCII 11."
dongsheng@627 13127 msgstr ""
dongsheng@627 13128
dongsheng@627 13129 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13130 #: ../en/ch10-template.xml:227
dongsheng@650 13131 msgid "<literal>\\v</literal>: Vertical tab, ASCII 13."
dongsheng@627 13132 msgstr ""
dongsheng@627 13133
dongsheng@627 13134 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13135 #: ../en/ch10-template.xml:230
dongsheng@650 13136 msgid ""
dongsheng@650 13137 "<literal>{</literal>: Open curly brace, <quote><literal>{</literal></quote>, "
dongsheng@650 13138 "ASCII 173."
dongsheng@627 13139 msgstr ""
dongsheng@627 13140
dongsheng@627 13141 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13142 #: ../en/ch10-template.xml:234
dongsheng@650 13143 msgid ""
dongsheng@650 13144 "<literal>}</literal>: Close curly brace, <quote><literal>}</literal></quote>, "
dongsheng@650 13145 "ASCII 175."
dongsheng@650 13146 msgstr ""
dongsheng@650 13147
dongsheng@650 13148 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 13149 #: ../en/ch10-template.xml:239
dongsheng@627 13150 msgid ""
dongsheng@627 13151 "As indicated above, if you want the expansion of a template to contain a "
dongsheng@627 13152 "literal <quote><literal>\\</literal></quote>, <quote><literal>{</literal></"
dongsheng@627 13153 "quote>, or <quote><literal>{</literal></quote> character, you must escape it."
dongsheng@627 13154 msgstr ""
dongsheng@627 13155
dongsheng@627 13156 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@658 13157 #: ../en/ch10-template.xml:247
dongsheng@627 13158 msgid "Filtering keywords to change their results"
dongsheng@636 13159 msgstr "通过过滤关键字来修改输出结果"
dongsheng@627 13160
dongsheng@627 13161 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 13162 #: ../en/ch10-template.xml:249
dongsheng@627 13163 msgid ""
dongsheng@627 13164 "Some of the results of template expansion are not immediately easy to use. "
dongsheng@627 13165 "Mercurial lets you specify an optional chain of <emphasis>filters</emphasis> "
dongsheng@627 13166 "to modify the result of expanding a keyword. You have already seen a common "
dongsheng@627 13167 "filter, <literal role=\"template-kw-filt-date\">isodate</literal>, in action "
dongsheng@627 13168 "above, to make a date readable."
dongsheng@627 13169 msgstr ""
dongsheng@627 13170
dongsheng@627 13171 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 13172 #: ../en/ch10-template.xml:256
dongsheng@627 13173 msgid ""
dongsheng@627 13174 "Below is a list of the most commonly used filters that Mercurial supports. "
dongsheng@627 13175 "While some filters can be applied to any text, others can only be used in "
dongsheng@627 13176 "specific circumstances. The name of each filter is followed first by an "
dongsheng@627 13177 "indication of where it can be used, then a description of its effect."
dongsheng@627 13178 msgstr ""
dongsheng@627 13179
dongsheng@627 13180 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13181 #: ../en/ch10-template.xml:263
dongsheng@627 13182 msgid ""
dongsheng@627 13183 "<literal role=\"template-filter\">addbreaks</literal>: Any text. Add an XHTML "
dongsheng@627 13184 "<quote><literal>&lt;br/&gt;</literal></quote> tag before the end of every "
dongsheng@627 13185 "line except the last. For example, <quote><literal>foo\\nbar</literal></"
dongsheng@627 13186 "quote> becomes <quote><literal>foo&lt;br/&gt;\\nbar</literal></quote>."
dongsheng@627 13187 msgstr ""
dongsheng@627 13188
dongsheng@627 13189 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13190 #: ../en/ch10-template.xml:270
dongsheng@627 13191 msgid ""
dongsheng@627 13192 "<literal role=\"template-kw-filt-date\">age</literal>: <literal role="
dongsheng@627 13193 "\"template-keyword\">date</literal> keyword. Render the age of the date, "
dongsheng@627 13194 "relative to the current time. Yields a string like <quote><literal>10 "
dongsheng@627 13195 "minutes</literal></quote>."
dongsheng@627 13196 msgstr ""
dongsheng@627 13197
dongsheng@627 13198 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13199 #: ../en/ch10-template.xml:277
dongsheng@627 13200 msgid ""
dongsheng@627 13201 "<literal role=\"template-filter\">basename</literal>: Any text, but most "
dongsheng@627 13202 "useful for the <literal role=\"template-keyword\">files</literal> keyword and "
dongsheng@627 13203 "its relatives. Treat the text as a path, and return the basename. For "
dongsheng@627 13204 "example, <quote><literal>foo/bar/baz</literal></quote> becomes "
dongsheng@627 13205 "<quote><literal>baz</literal></quote>."
dongsheng@627 13206 msgstr ""
dongsheng@627 13207
dongsheng@627 13208 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13209 #: ../en/ch10-template.xml:286
dongsheng@627 13210 msgid ""
dongsheng@627 13211 "<literal role=\"template-kw-filt-date\">date</literal>: <literal role="
dongsheng@627 13212 "\"template-keyword\">date</literal> keyword. Render a date in a similar "
dongsheng@627 13213 "format to the Unix <literal role=\"template-keyword\">date</literal> command, "
dongsheng@627 13214 "but with timezone included. Yields a string like <quote><literal>Mon Sep 04 "
dongsheng@627 13215 "15:13:13 2006 -0700</literal></quote>."
dongsheng@627 13216 msgstr ""
dongsheng@627 13217
dongsheng@627 13218 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13219 #: ../en/ch10-template.xml:294
dongsheng@627 13220 msgid ""
dongsheng@627 13221 "<literal role=\"template-kw-filt-author\">domain</literal>: Any text, but "
dongsheng@627 13222 "most useful for the <literal role=\"template-keyword\">author</literal> "
dongsheng@627 13223 "keyword. Finds the first string that looks like an email address, and "
dongsheng@627 13224 "extract just the domain component. For example, <quote><literal>Bryan "
dongsheng@627 13225 "O'Sullivan &lt;bos@serpentine.com&gt;</literal></quote> becomes "
dongsheng@627 13226 "<quote><literal>serpentine.com</literal></quote>."
dongsheng@627 13227 msgstr ""
dongsheng@627 13228
dongsheng@627 13229 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13230 #: ../en/ch10-template.xml:304
dongsheng@627 13231 msgid ""
dongsheng@627 13232 "<literal role=\"template-kw-filt-author\">email</literal>: Any text, but most "
dongsheng@627 13233 "useful for the <literal role=\"template-keyword\">author</literal> keyword. "
dongsheng@627 13234 "Extract the first string that looks like an email address. For example, "
dongsheng@627 13235 "<quote><literal>Bryan O'Sullivan &lt;bos@serpentine.com&gt;</literal></quote> "
dongsheng@627 13236 "becomes <quote><literal>bos@serpentine.com</literal></quote>."
dongsheng@627 13237 msgstr ""
dongsheng@627 13238
dongsheng@627 13239 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13240 #: ../en/ch10-template.xml:313
dongsheng@627 13241 msgid ""
dongsheng@627 13242 "<literal role=\"template-filter\">escape</literal>: Any text. Replace the "
dongsheng@627 13243 "special XML/XHTML characters <quote><literal>&amp;</literal></quote>, "
dongsheng@627 13244 "<quote><literal>&lt;</literal></quote> and <quote><literal>&gt;</literal></"
dongsheng@627 13245 "quote> with XML entities."
dongsheng@627 13246 msgstr ""
dongsheng@627 13247
dongsheng@627 13248 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13249 #: ../en/ch10-template.xml:321
dongsheng@627 13250 msgid ""
dongsheng@627 13251 "<literal role=\"template-filter\">fill68</literal>: Any text. Wrap the text "
dongsheng@627 13252 "to fit in 68 columns. This is useful before you pass text through the "
dongsheng@627 13253 "<literal role=\"template-filter\">tabindent</literal> filter, and still want "
dongsheng@627 13254 "it to fit in an 80-column fixed-font window."
dongsheng@627 13255 msgstr ""
dongsheng@627 13256
dongsheng@627 13257 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13258 #: ../en/ch10-template.xml:329
dongsheng@627 13259 msgid ""
dongsheng@627 13260 "<literal role=\"template-filter\">fill76</literal>: Any text. Wrap the text "
dongsheng@627 13261 "to fit in 76 columns."
dongsheng@627 13262 msgstr ""
dongsheng@627 13263
dongsheng@627 13264 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13265 #: ../en/ch10-template.xml:333
dongsheng@627 13266 msgid ""
dongsheng@627 13267 "<literal role=\"template-filter\">firstline</literal>: Any text. Yield the "
dongsheng@627 13268 "first line of text, without any trailing newlines."
dongsheng@627 13269 msgstr ""
dongsheng@627 13270
dongsheng@627 13271 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13272 #: ../en/ch10-template.xml:338
dongsheng@627 13273 msgid ""
dongsheng@627 13274 "<literal role=\"template-kw-filt-date\">hgdate</literal>: <literal role="
dongsheng@627 13275 "\"template-keyword\">date</literal> keyword. Render the date as a pair of "
dongsheng@627 13276 "readable numbers. Yields a string like <quote><literal>1157407993 25200</"
dongsheng@627 13277 "literal></quote>."
dongsheng@627 13278 msgstr ""
dongsheng@627 13279
dongsheng@627 13280 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13281 #: ../en/ch10-template.xml:345
dongsheng@627 13282 msgid ""
dongsheng@627 13283 "<literal role=\"template-kw-filt-date\">isodate</literal>: <literal role="
dongsheng@627 13284 "\"template-keyword\">date</literal> keyword. Render the date as a text "
dongsheng@627 13285 "string in ISO 8601 format. Yields a string like <quote><literal>2006-09-04 "
dongsheng@627 13286 "15:13:13 -0700</literal></quote>."
dongsheng@627 13287 msgstr ""
dongsheng@627 13288
dongsheng@627 13289 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13290 #: ../en/ch10-template.xml:352
dongsheng@627 13291 msgid ""
dongsheng@627 13292 "<literal role=\"template-filter\">obfuscate</literal>: Any text, but most "
dongsheng@627 13293 "useful for the <literal role=\"template-keyword\">author</literal> keyword. "
dongsheng@627 13294 "Yield the input text rendered as a sequence of XML entities. This helps to "
dongsheng@627 13295 "defeat some particularly stupid screen-scraping email harvesting spambots."
dongsheng@627 13296 msgstr ""
dongsheng@627 13297
dongsheng@627 13298 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13299 #: ../en/ch10-template.xml:360
dongsheng@627 13300 msgid ""
dongsheng@627 13301 "<literal role=\"template-kw-filt-author\">person</literal>: Any text, but "
dongsheng@627 13302 "most useful for the <literal role=\"template-keyword\">author</literal> "
dongsheng@627 13303 "keyword. Yield the text before an email address. For example, "
dongsheng@627 13304 "<quote><literal>Bryan O'Sullivan &lt;bos@serpentine.com&gt;</literal></quote> "
dongsheng@627 13305 "becomes <quote><literal>Bryan O'Sullivan</literal></quote>."
dongsheng@627 13306 msgstr ""
dongsheng@627 13307
dongsheng@627 13308 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13309 #: ../en/ch10-template.xml:369
dongsheng@627 13310 msgid ""
dongsheng@627 13311 "<literal role=\"template-kw-filt-date\">rfc822date</literal>: <literal role="
dongsheng@627 13312 "\"template-keyword\">date</literal> keyword. Render a date using the same "
dongsheng@627 13313 "format used in email headers. Yields a string like <quote><literal>Mon, 04 "
dongsheng@627 13314 "Sep 2006 15:13:13 -0700</literal></quote>."
dongsheng@627 13315 msgstr ""
dongsheng@627 13316
dongsheng@627 13317 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13318 #: ../en/ch10-template.xml:376
dongsheng@627 13319 msgid ""
dongsheng@627 13320 "<literal role=\"template-kw-filt-node\">short</literal>: Changeset hash. "
dongsheng@627 13321 "Yield the short form of a changeset hash, i.e. a 12-character hexadecimal "
dongsheng@627 13322 "string."
dongsheng@627 13323 msgstr ""
dongsheng@627 13324
dongsheng@627 13325 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13326 #: ../en/ch10-template.xml:381
dongsheng@627 13327 msgid ""
dongsheng@627 13328 "<literal role=\"template-kw-filt-date\">shortdate</literal>: <literal role="
dongsheng@627 13329 "\"template-keyword\">date</literal> keyword. Render the year, month, and day "
dongsheng@627 13330 "of the date. Yields a string like <quote><literal>2006-09-04</literal></"
dongsheng@627 13331 "quote>."
dongsheng@627 13332 msgstr ""
dongsheng@627 13333
dongsheng@627 13334 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13335 #: ../en/ch10-template.xml:387
dongsheng@627 13336 msgid ""
dongsheng@627 13337 "<literal role=\"template-filter\">strip</literal>: Any text. Strip all "
dongsheng@627 13338 "leading and trailing whitespace from the string."
dongsheng@627 13339 msgstr ""
dongsheng@627 13340
dongsheng@627 13341 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13342 #: ../en/ch10-template.xml:391
dongsheng@627 13343 msgid ""
dongsheng@627 13344 "<literal role=\"template-filter\">tabindent</literal>: Any text. Yield the "
dongsheng@627 13345 "text, with every line except the first starting with a tab character."
dongsheng@627 13346 msgstr ""
dongsheng@627 13347
dongsheng@627 13348 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13349 #: ../en/ch10-template.xml:396
dongsheng@627 13350 msgid ""
dongsheng@627 13351 "<literal role=\"template-filter\">urlescape</literal>: Any text. Escape all "
dongsheng@627 13352 "characters that are considered <quote>special</quote> by URL parsers. For "
dongsheng@627 13353 "example, <literal>foo bar</literal> becomes <literal>foo%20bar</literal>."
dongsheng@627 13354 msgstr ""
dongsheng@627 13355
dongsheng@627 13356 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13357 #: ../en/ch10-template.xml:403
dongsheng@627 13358 msgid ""
dongsheng@627 13359 "<literal role=\"template-kw-filt-author\">user</literal>: Any text, but most "
dongsheng@627 13360 "useful for the <literal role=\"template-keyword\">author</literal> keyword. "
dongsheng@627 13361 "Return the <quote>user</quote> portion of an email address. For example, "
dongsheng@627 13362 "<quote><literal>Bryan O'Sullivan &lt;bos@serpentine.com&gt;</literal></quote> "
dongsheng@627 13363 "becomes <quote><literal>bos</literal></quote>."
dongsheng@627 13364 msgstr ""
dongsheng@627 13365
dongsheng@627 13366 #. type: Content of: <book><chapter><sect1><note><para>
songdongsheng@658 13367 #: ../en/ch10-template.xml:416
dongsheng@627 13368 msgid ""
dongsheng@627 13369 "If you try to apply a filter to a piece of data that it cannot process, "
dongsheng@627 13370 "Mercurial will fail and print a Python exception. For example, trying to run "
dongsheng@627 13371 "the output of the <literal role=\"template-keyword\">desc</literal> keyword "
dongsheng@627 13372 "into the <literal role=\"template-kw-filt-date\">isodate</literal> filter is "
dongsheng@627 13373 "not a good idea."
dongsheng@627 13374 msgstr ""
dongsheng@627 13375
dongsheng@627 13376 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 13377 #: ../en/ch10-template.xml:425
dongsheng@627 13378 msgid "Combining filters"
dongsheng@636 13379 msgstr "组合过滤器"
dongsheng@627 13380
dongsheng@627 13381 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 13382 #: ../en/ch10-template.xml:427
dongsheng@627 13383 msgid ""
dongsheng@627 13384 "It is easy to combine filters to yield output in the form you would like. "
dongsheng@627 13385 "The following chain of filters tidies up a description, then makes sure that "
dongsheng@627 13386 "it fits cleanly into 68 columns, then indents it by a further 8 characters "
dongsheng@627 13387 "(at least on Unix-like systems, where a tab is conventionally 8 characters "
dongsheng@627 13388 "wide)."
dongsheng@627 13389 msgstr ""
dongsheng@627 13390
dongsheng@627 13391 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 13392 #: ../en/ch10-template.xml:436
dongsheng@627 13393 msgid ""
dongsheng@627 13394 "Note the use of <quote><literal>\\t</literal></quote> (a tab character) in "
dongsheng@627 13395 "the template to force the first line to be indented; this is necessary since "
dongsheng@627 13396 "<literal role=\"template-keyword\">tabindent</literal> indents all lines "
dongsheng@627 13397 "<emphasis>except</emphasis> the first."
dongsheng@627 13398 msgstr ""
dongsheng@627 13399
dongsheng@627 13400 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 13401 #: ../en/ch10-template.xml:442
dongsheng@627 13402 msgid ""
dongsheng@627 13403 "Keep in mind that the order of filters in a chain is significant. The first "
dongsheng@627 13404 "filter is applied to the result of the keyword; the second to the result of "
dongsheng@627 13405 "the first filter; and so on. For example, using <literal>fill68|tabindent</"
dongsheng@627 13406 "literal> gives very different results from <literal>tabindent|fill68</"
dongsheng@627 13407 "literal>."
dongsheng@627 13408 msgstr ""
dongsheng@627 13409
dongsheng@627 13410 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@658 13411 #: ../en/ch10-template.xml:453
dongsheng@627 13412 msgid "From templates to styles"
dongsheng@636 13413 msgstr "从模版到样式"
dongsheng@627 13414
dongsheng@627 13415 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 13416 #: ../en/ch10-template.xml:455
dongsheng@627 13417 msgid ""
dongsheng@627 13418 "A command line template provides a quick and simple way to format some "
dongsheng@627 13419 "output. Templates can become verbose, though, and it's useful to be able to "
dongsheng@627 13420 "give a template a name. A style file is a template with a name, stored in a "
dongsheng@627 13421 "file."
dongsheng@627 13422 msgstr ""
dongsheng@627 13423
dongsheng@627 13424 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 13425 #: ../en/ch10-template.xml:460
dongsheng@627 13426 msgid ""
dongsheng@627 13427 "More than that, using a style file unlocks the power of Mercurial's "
dongsheng@627 13428 "templating engine in ways that are not possible using the command line "
dongsheng@627 13429 "<option role=\"hg-opt-log\">--template</option> option."
dongsheng@627 13430 msgstr ""
dongsheng@627 13431
dongsheng@627 13432 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 13433 #: ../en/ch10-template.xml:466
dongsheng@627 13434 msgid "The simplest of style files"
dongsheng@636 13435 msgstr "最简单的样式文件"
dongsheng@627 13436
dongsheng@627 13437 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 13438 #: ../en/ch10-template.xml:468
dongsheng@627 13439 msgid "Our simple style file contains just one line:"
dongsheng@627 13440 msgstr ""
dongsheng@627 13441
dongsheng@627 13442 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 13443 #: ../en/ch10-template.xml:472
dongsheng@627 13444 msgid ""
dongsheng@627 13445 "This tells Mercurial, <quote>if you're printing a changeset, use the text on "
dongsheng@627 13446 "the right as the template</quote>."
dongsheng@627 13447 msgstr ""
dongsheng@627 13448
dongsheng@627 13449 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 13450 #: ../en/ch10-template.xml:478
dongsheng@627 13451 msgid "Style file syntax"
dongsheng@636 13452 msgstr "样式文件语法"
dongsheng@627 13453
dongsheng@627 13454 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 13455 #: ../en/ch10-template.xml:480
dongsheng@627 13456 msgid "The syntax rules for a style file are simple."
dongsheng@627 13457 msgstr ""
dongsheng@627 13458
dongsheng@627 13459 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 13460 #: ../en/ch10-template.xml:483
dongsheng@627 13461 msgid "The file is processed one line at a time."
dongsheng@627 13462 msgstr ""
dongsheng@627 13463
dongsheng@627 13464 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 13465 #: ../en/ch10-template.xml:486
dongsheng@627 13466 msgid "Leading and trailing white space are ignored."
dongsheng@627 13467 msgstr ""
dongsheng@627 13468
dongsheng@627 13469 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 13470 #: ../en/ch10-template.xml:489
songdongsheng@658 13471 msgid "Empty lines are skipped."
songdongsheng@658 13472 msgstr ""
songdongsheng@658 13473
songdongsheng@658 13474 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 13475 #: ../en/ch10-template.xml:491
dongsheng@627 13476 msgid ""
dongsheng@627 13477 "If a line starts with either of the characters <quote><literal>#</literal></"
dongsheng@627 13478 "quote> or <quote><literal>;</literal></quote>, the entire line is treated as "
dongsheng@627 13479 "a comment, and skipped as if empty."
dongsheng@627 13480 msgstr ""
dongsheng@627 13481
dongsheng@627 13482 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 13483 #: ../en/ch10-template.xml:496
dongsheng@627 13484 msgid ""
dongsheng@627 13485 "A line starts with a keyword. This must start with an alphabetic character "
dongsheng@627 13486 "or underscore, and can subsequently contain any alphanumeric character or "
dongsheng@627 13487 "underscore. (In regexp notation, a keyword must match <literal>[A-Za-z_][A-"
dongsheng@627 13488 "Za-z0-9_]*</literal>.)"
dongsheng@627 13489 msgstr ""
dongsheng@627 13490
dongsheng@627 13491 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 13492 #: ../en/ch10-template.xml:502
dongsheng@627 13493 msgid ""
dongsheng@627 13494 "The next element must be an <quote><literal>=</literal></quote> character, "
dongsheng@627 13495 "which can be preceded or followed by an arbitrary amount of white space."
dongsheng@627 13496 msgstr ""
dongsheng@627 13497
dongsheng@627 13498 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 13499 #: ../en/ch10-template.xml:507
dongsheng@627 13500 msgid ""
dongsheng@627 13501 "If the rest of the line starts and ends with matching quote characters "
dongsheng@627 13502 "(either single or double quote), it is treated as a template body."
dongsheng@627 13503 msgstr ""
dongsheng@627 13504
dongsheng@627 13505 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 13506 #: ../en/ch10-template.xml:511
dongsheng@627 13507 msgid ""
dongsheng@627 13508 "If the rest of the line <emphasis>does not</emphasis> start with a quote "
dongsheng@627 13509 "character, it is treated as the name of a file; the contents of this file "
dongsheng@627 13510 "will be read and used as a template body."
dongsheng@627 13511 msgstr ""
dongsheng@627 13512
dongsheng@627 13513 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@658 13514 #: ../en/ch10-template.xml:520
dongsheng@627 13515 msgid "Style files by example"
dongsheng@636 13516 msgstr "样式文件例子"
dongsheng@627 13517
dongsheng@627 13518 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 13519 #: ../en/ch10-template.xml:522
dongsheng@627 13520 msgid ""
dongsheng@627 13521 "To illustrate how to write a style file, we will construct a few by example. "
dongsheng@627 13522 "Rather than provide a complete style file and walk through it, we'll mirror "
dongsheng@627 13523 "the usual process of developing a style file by starting with something very "
dongsheng@627 13524 "simple, and walking through a series of successively more complete examples."
dongsheng@627 13525 msgstr ""
dongsheng@627 13526
dongsheng@627 13527 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 13528 #: ../en/ch10-template.xml:529
dongsheng@627 13529 msgid "Identifying mistakes in style files"
dongsheng@636 13530 msgstr "在样式文件中定位错误"
dongsheng@627 13531
dongsheng@627 13532 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 13533 #: ../en/ch10-template.xml:531
dongsheng@627 13534 msgid ""
dongsheng@627 13535 "If Mercurial encounters a problem in a style file you are working on, it "
dongsheng@627 13536 "prints a terse error message that, once you figure out what it means, is "
dongsheng@627 13537 "actually quite useful."
dongsheng@627 13538 msgstr ""
dongsheng@627 13539
dongsheng@627 13540 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 13541 #: ../en/ch10-template.xml:537
dongsheng@627 13542 msgid ""
dongsheng@627 13543 "Notice that <filename>broken.style</filename> attempts to define a "
dongsheng@627 13544 "<literal>changeset</literal> keyword, but forgets to give any content for it. "
dongsheng@627 13545 "When instructed to use this style file, Mercurial promptly complains."
dongsheng@627 13546 msgstr ""
dongsheng@627 13547
dongsheng@627 13548 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 13549 #: ../en/ch10-template.xml:544
dongsheng@627 13550 msgid "This error message looks intimidating, but it is not too hard to follow."
dongsheng@627 13551 msgstr ""
dongsheng@627 13552
dongsheng@627 13553 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 13554 #: ../en/ch10-template.xml:548
dongsheng@627 13555 msgid ""
dongsheng@627 13556 "The first component is simply Mercurial's way of saying <quote>I am giving "
dongsheng@627 13557 "up</quote>."
dongsheng@627 13558 msgstr ""
dongsheng@627 13559
dongsheng@627 13560 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 13561 #: ../en/ch10-template.xml:552
dongsheng@627 13562 msgid "Next comes the name of the style file that contains the error."
dongsheng@627 13563 msgstr ""
dongsheng@627 13564
dongsheng@627 13565 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 13566 #: ../en/ch10-template.xml:556
dongsheng@627 13567 msgid ""
dongsheng@627 13568 "Following the file name is the line number where the error was encountered."
dongsheng@627 13569 msgstr ""
dongsheng@627 13570
dongsheng@627 13571 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 13572 #: ../en/ch10-template.xml:560
dongsheng@627 13573 msgid "Finally, a description of what went wrong."
dongsheng@627 13574 msgstr ""
dongsheng@627 13575
dongsheng@627 13576 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 13577 #: ../en/ch10-template.xml:564
dongsheng@627 13578 msgid ""
dongsheng@627 13579 "The description of the problem is not always clear (as in this case), but "
dongsheng@627 13580 "even when it is cryptic, it is almost always trivial to visually inspect the "
dongsheng@627 13581 "offending line in the style file and see what is wrong."
dongsheng@627 13582 msgstr ""
dongsheng@627 13583
dongsheng@627 13584 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 13585 #: ../en/ch10-template.xml:572
dongsheng@627 13586 msgid "Uniquely identifying a repository"
dongsheng@636 13587 msgstr "版本库的唯一标识"
dongsheng@627 13588
dongsheng@627 13589 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 13590 #: ../en/ch10-template.xml:574
dongsheng@627 13591 msgid ""
dongsheng@627 13592 "If you would like to be able to identify a Mercurial repository <quote>fairly "
dongsheng@627 13593 "uniquely</quote> using a short string as an identifier, you can use the first "
dongsheng@627 13594 "revision in the repository."
dongsheng@627 13595 msgstr ""
dongsheng@627 13596
dongsheng@627 13597 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 13598 #: ../en/ch10-template.xml:581
dongsheng@627 13599 msgid ""
dongsheng@627 13600 "This is not guaranteed to be unique, but it is nevertheless useful in many "
dongsheng@627 13601 "cases."
dongsheng@627 13602 msgstr ""
dongsheng@627 13603
dongsheng@627 13604 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 13605 #: ../en/ch10-template.xml:584
dongsheng@627 13606 msgid ""
dongsheng@627 13607 "It will not work in a completely empty repository, because such a repository "
dongsheng@627 13608 "does not have a revision zero."
dongsheng@627 13609 msgstr ""
dongsheng@627 13610
dongsheng@627 13611 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 13612 #: ../en/ch10-template.xml:588
dongsheng@627 13613 msgid ""
dongsheng@627 13614 "Neither will it work in the (extremely rare) case where a repository is a "
dongsheng@627 13615 "merge of two or more formerly independent repositories, and you still have "
dongsheng@627 13616 "those repositories around."
dongsheng@627 13617 msgstr ""
dongsheng@627 13618
dongsheng@627 13619 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 13620 #: ../en/ch10-template.xml:593
dongsheng@627 13621 msgid "Here are some uses to which you could put this identifier:"
dongsheng@627 13622 msgstr ""
dongsheng@627 13623
dongsheng@627 13624 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 13625 #: ../en/ch10-template.xml:596
dongsheng@627 13626 msgid ""
dongsheng@627 13627 "As a key into a table for a database that manages repositories on a server."
dongsheng@627 13628 msgstr ""
dongsheng@627 13629
dongsheng@627 13630 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 13631 #: ../en/ch10-template.xml:599
dongsheng@627 13632 msgid ""
dongsheng@627 13633 "As half of a {<emphasis>repository ID</emphasis>, <emphasis>revision ID</"
dongsheng@627 13634 "emphasis>} tuple. Save this information away when you run an automated build "
dongsheng@627 13635 "or other activity, so that you can <quote>replay</quote> the build later if "
dongsheng@627 13636 "necessary."
dongsheng@627 13637 msgstr ""
dongsheng@627 13638
dongsheng@627 13639 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 13640 #: ../en/ch10-template.xml:608
dongsheng@627 13641 msgid "Mimicking Subversion's output"
dongsheng@636 13642 msgstr "模仿 Subversion 的输出"
dongsheng@627 13643
dongsheng@627 13644 #
dongsheng@627 13645 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 13646 #: ../en/ch10-template.xml:610
dongsheng@627 13647 msgid ""
dongsheng@627 13648 "Let's try to emulate the default output format used by another revision "
dongsheng@627 13649 "control tool, Subversion."
dongsheng@627 13650 msgstr ""
dongsheng@627 13651
dongsheng@627 13652 #
dongsheng@627 13653 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 13654 #: ../en/ch10-template.xml:615
dongsheng@627 13655 msgid ""
dongsheng@627 13656 "Since Subversion's output style is fairly simple, it is easy to copy-and-"
dongsheng@627 13657 "paste a hunk of its output into a file, and replace the text produced above "
dongsheng@627 13658 "by Subversion with the template values we'd like to see expanded."
dongsheng@627 13659 msgstr ""
dongsheng@627 13660
dongsheng@627 13661 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 13662 #: ../en/ch10-template.xml:622
dongsheng@627 13663 msgid ""
dongsheng@627 13664 "There are a few small ways in which this template deviates from the output "
dongsheng@627 13665 "produced by Subversion."
dongsheng@627 13666 msgstr ""
dongsheng@627 13667
dongsheng@627 13668 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 13669 #: ../en/ch10-template.xml:625
dongsheng@627 13670 msgid ""
dongsheng@627 13671 "Subversion prints a <quote>readable</quote> date (the <quote><literal>Wed, 27 "
dongsheng@627 13672 "Sep 2006</literal></quote> in the example output above) in parentheses. "
dongsheng@627 13673 "Mercurial's templating engine does not provide a way to display a date in "
dongsheng@627 13674 "this format without also printing the time and time zone."
dongsheng@627 13675 msgstr ""
dongsheng@627 13676
dongsheng@627 13677 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 13678 #: ../en/ch10-template.xml:632
dongsheng@627 13679 msgid ""
dongsheng@627 13680 "We emulate Subversion's printing of <quote>separator</quote> lines full of "
dongsheng@627 13681 "<quote><literal>-</literal></quote> characters by ending the template with "
dongsheng@627 13682 "such a line. We use the templating engine's <literal role=\"template-keyword"
dongsheng@627 13683 "\">header</literal> keyword to print a separator line as the first line of "
dongsheng@627 13684 "output (see below), thus achieving similar output to Subversion."
dongsheng@627 13685 msgstr ""
dongsheng@627 13686
dongsheng@627 13687 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 13688 #: ../en/ch10-template.xml:641
dongsheng@627 13689 msgid ""
dongsheng@627 13690 "Subversion's output includes a count in the header of the number of lines in "
dongsheng@627 13691 "the commit message. We cannot replicate this in Mercurial; the templating "
dongsheng@627 13692 "engine does not currently provide a filter that counts the number of lines "
dongsheng@627 13693 "the template generates."
dongsheng@627 13694 msgstr ""
dongsheng@627 13695
dongsheng@627 13696 #
dongsheng@627 13697 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 13698 #: ../en/ch10-template.xml:647
dongsheng@627 13699 msgid ""
dongsheng@627 13700 "It took me no more than a minute or two of work to replace literal text from "
dongsheng@627 13701 "an example of Subversion's output with some keywords and filters to give the "
dongsheng@627 13702 "template above. The style file simply refers to the template."
dongsheng@627 13703 msgstr ""
dongsheng@627 13704
dongsheng@627 13705 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 13706 #: ../en/ch10-template.xml:654
dongsheng@627 13707 msgid ""
dongsheng@627 13708 "We could have included the text of the template file directly in the style "
dongsheng@627 13709 "file by enclosing it in quotes and replacing the newlines with "
dongsheng@627 13710 "<quote><literal>\\n</literal></quote> sequences, but it would have made the "
dongsheng@627 13711 "style file too difficult to read. Readability is a good guide when you're "
dongsheng@627 13712 "trying to decide whether some text belongs in a style file, or in a template "
dongsheng@627 13713 "file that the style file points to. If the style file will look too big or "
dongsheng@627 13714 "cluttered if you insert a literal piece of text, drop it into a template "
dongsheng@627 13715 "instead."
dongsheng@627 13716 msgstr ""
dongsheng@627 13717
dongsheng@627 13718 #. type: Content of: <book><chapter><title>
dongsheng@650 13719 #: ../en/ch11-mq.xml:5
dongsheng@627 13720 msgid "Managing change with Mercurial Queues"
dongsheng@627 13721 msgstr "使用 MQ 管理修改"
dongsheng@627 13722
dongsheng@627 13723 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 13724 #: ../en/ch11-mq.xml:8
dongsheng@627 13725 msgid "The patch management problem"
dongsheng@636 13726 msgstr "补丁的管理问题"
dongsheng@627 13727
dongsheng@627 13728 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 13729 #: ../en/ch11-mq.xml:10
dongsheng@627 13730 msgid ""
dongsheng@627 13731 "Here is a common scenario: you need to install a software package from "
dongsheng@627 13732 "source, but you find a bug that you must fix in the source before you can "
dongsheng@627 13733 "start using the package. You make your changes, forget about the package for "
dongsheng@627 13734 "a while, and a few months later you need to upgrade to a newer version of the "
dongsheng@627 13735 "package. If the newer version of the package still has the bug, you must "
dongsheng@627 13736 "extract your fix from the older source tree and apply it against the newer "
dongsheng@627 13737 "version. This is a tedious task, and it's easy to make mistakes."
dongsheng@627 13738 msgstr ""
dongsheng@627 13739
dongsheng@627 13740 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 13741 #: ../en/ch11-mq.xml:20
dongsheng@627 13742 msgid ""
dongsheng@627 13743 "This is a simple case of the <quote>patch management</quote> problem. You "
dongsheng@627 13744 "have an <quote>upstream</quote> source tree that you can't change; you need "
dongsheng@627 13745 "to make some local changes on top of the upstream tree; and you'd like to be "
dongsheng@627 13746 "able to keep those changes separate, so that you can apply them to newer "
dongsheng@627 13747 "versions of the upstream source."
dongsheng@627 13748 msgstr ""
dongsheng@627 13749
dongsheng@627 13750 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 13751 #: ../en/ch11-mq.xml:27
dongsheng@627 13752 msgid ""
dongsheng@627 13753 "The patch management problem arises in many situations. Probably the most "
dongsheng@627 13754 "visible is that a user of an open source software project will contribute a "
dongsheng@627 13755 "bug fix or new feature to the project's maintainers in the form of a patch."
dongsheng@627 13756 msgstr ""
dongsheng@627 13757
dongsheng@627 13758 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 13759 #: ../en/ch11-mq.xml:32
dongsheng@627 13760 msgid ""
dongsheng@627 13761 "Distributors of operating systems that include open source software often "
dongsheng@627 13762 "need to make changes to the packages they distribute so that they will build "
dongsheng@627 13763 "properly in their environments."
dongsheng@627 13764 msgstr ""
dongsheng@627 13765
dongsheng@627 13766 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 13767 #: ../en/ch11-mq.xml:37
dongsheng@627 13768 msgid ""
dongsheng@627 13769 "When you have few changes to maintain, it is easy to manage a single patch "
dongsheng@627 13770 "using the standard <command>diff</command> and <command>patch</command> "
songdongsheng@658 13771 "programs (see <xref linkend=\"sec:mq:patch\"/> for a discussion of these "
songdongsheng@658 13772 "tools). Once the number of changes grows, it starts to make sense to maintain "
songdongsheng@658 13773 "patches as discrete <quote>chunks of work,</quote> so that for example a "
songdongsheng@658 13774 "single patch will contain only one bug fix (the patch might modify several "
songdongsheng@658 13775 "files, but it's doing <quote>only one thing</quote>), and you may have a "
songdongsheng@658 13776 "number of such patches for different bugs you need fixed and local changes "
songdongsheng@658 13777 "you require. In this situation, if you submit a bug fix patch to the "
dongsheng@627 13778 "upstream maintainers of a package and they include your fix in a subsequent "
dongsheng@627 13779 "release, you can simply drop that single patch when you're updating to the "
dongsheng@627 13780 "newer release."
dongsheng@627 13781 msgstr ""
dongsheng@627 13782
dongsheng@627 13783 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 13784 #: ../en/ch11-mq.xml:52
dongsheng@627 13785 msgid ""
dongsheng@627 13786 "Maintaining a single patch against an upstream tree is a little tedious and "
dongsheng@627 13787 "error-prone, but not difficult. However, the complexity of the problem grows "
dongsheng@627 13788 "rapidly as the number of patches you have to maintain increases. With more "
dongsheng@627 13789 "than a tiny number of patches in hand, understanding which ones you have "
dongsheng@627 13790 "applied and maintaining them moves from messy to overwhelming."
dongsheng@627 13791 msgstr ""
dongsheng@627 13792
dongsheng@627 13793 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 13794 #: ../en/ch11-mq.xml:59
dongsheng@627 13795 msgid ""
dongsheng@627 13796 "Fortunately, Mercurial includes a powerful extension, Mercurial Queues (or "
dongsheng@627 13797 "simply <quote>MQ</quote>), that massively simplifies the patch management "
dongsheng@627 13798 "problem."
dongsheng@627 13799 msgstr ""
dongsheng@627 13800
dongsheng@627 13801 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 13802 #: ../en/ch11-mq.xml:65
dongsheng@627 13803 msgid "The prehistory of Mercurial Queues"
dongsheng@636 13804 msgstr "MQ 的历史"
dongsheng@627 13805
dongsheng@627 13806 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 13807 #: ../en/ch11-mq.xml:67
dongsheng@627 13808 msgid ""
dongsheng@627 13809 "During the late 1990s, several Linux kernel developers started to maintain "
songdongsheng@710 13810 "<quote>patch series</quote> that modified the behavior of the Linux kernel. "
dongsheng@627 13811 "Some of these series were focused on stability, some on feature coverage, and "
dongsheng@627 13812 "others were more speculative."
dongsheng@627 13813 msgstr ""
dongsheng@627 13814
dongsheng@627 13815 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 13816 #: ../en/ch11-mq.xml:73
dongsheng@627 13817 msgid ""
dongsheng@627 13818 "The sizes of these patch series grew rapidly. In 2002, Andrew Morton "
dongsheng@627 13819 "published some shell scripts he had been using to automate the task of "
dongsheng@627 13820 "managing his patch queues. Andrew was successfully using these scripts to "
dongsheng@627 13821 "manage hundreds (sometimes thousands) of patches on top of the Linux kernel."
dongsheng@627 13822 msgstr ""
dongsheng@627 13823
dongsheng@627 13824 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 13825 #: ../en/ch11-mq.xml:80
dongsheng@627 13826 msgid "A patchwork quilt"
dongsheng@627 13827 msgstr ""
dongsheng@627 13828
dongsheng@627 13829 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 13830 #: ../en/ch11-mq.xml:82
dongsheng@627 13831 msgid ""
dongsheng@627 13832 "In early 2003, Andreas Gruenbacher and Martin Quinson borrowed the approach "
dongsheng@627 13833 "of Andrew's scripts and published a tool called <quote>patchwork quilt</"
dongsheng@627 13834 "quote> <citation>web:quilt</citation>, or simply <quote>quilt</quote> (see "
dongsheng@627 13835 "<citation>gruenbacher:2005</citation> for a paper describing it). Because "
dongsheng@627 13836 "quilt substantially automated patch management, it rapidly gained a large "
dongsheng@627 13837 "following among open source software developers."
dongsheng@627 13838 msgstr ""
dongsheng@627 13839
dongsheng@627 13840 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 13841 #: ../en/ch11-mq.xml:91
dongsheng@627 13842 msgid ""
dongsheng@627 13843 "Quilt manages a <emphasis>stack of patches</emphasis> on top of a directory "
dongsheng@627 13844 "tree. To begin, you tell quilt to manage a directory tree, and tell it which "
dongsheng@627 13845 "files you want to manage; it stores away the names and contents of those "
dongsheng@627 13846 "files. To fix a bug, you create a new patch (using a single command), edit "
dongsheng@627 13847 "the files you need to fix, then <quote>refresh</quote> the patch."
dongsheng@627 13848 msgstr ""
dongsheng@627 13849
dongsheng@627 13850 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 13851 #: ../en/ch11-mq.xml:99
dongsheng@627 13852 msgid ""
dongsheng@627 13853 "The refresh step causes quilt to scan the directory tree; it updates the "
dongsheng@627 13854 "patch with all of the changes you have made. You can create another patch on "
dongsheng@627 13855 "top of the first, which will track the changes required to modify the tree "
dongsheng@627 13856 "from <quote>tree with one patch applied</quote> to <quote>tree with two "
dongsheng@627 13857 "patches applied</quote>."
dongsheng@627 13858 msgstr ""
dongsheng@627 13859
dongsheng@627 13860 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 13861 #: ../en/ch11-mq.xml:106
dongsheng@627 13862 msgid ""
dongsheng@627 13863 "You can <emphasis>change</emphasis> which patches are applied to the tree. "
dongsheng@627 13864 "If you <quote>pop</quote> a patch, the changes made by that patch will vanish "
dongsheng@627 13865 "from the directory tree. Quilt remembers which patches you have popped, "
dongsheng@627 13866 "though, so you can <quote>push</quote> a popped patch again, and the "
dongsheng@627 13867 "directory tree will be restored to contain the modifications in the patch. "
dongsheng@627 13868 "Most importantly, you can run the <quote>refresh</quote> command at any time, "
dongsheng@627 13869 "and the topmost applied patch will be updated. This means that you can, at "
dongsheng@627 13870 "any time, change both which patches are applied and what modifications those "
dongsheng@627 13871 "patches make."
dongsheng@627 13872 msgstr ""
dongsheng@627 13873
dongsheng@627 13874 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 13875 #: ../en/ch11-mq.xml:118
dongsheng@627 13876 msgid ""
dongsheng@627 13877 "Quilt knows nothing about revision control tools, so it works equally well on "
dongsheng@627 13878 "top of an unpacked tarball or a Subversion working copy."
dongsheng@627 13879 msgstr ""
dongsheng@627 13880
dongsheng@627 13881 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 13882 #: ../en/ch11-mq.xml:124
dongsheng@627 13883 msgid "From patchwork quilt to Mercurial Queues"
dongsheng@636 13884 msgstr "从 patchwork quilt 到 MQ"
dongsheng@627 13885
dongsheng@627 13886 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 13887 #: ../en/ch11-mq.xml:126
dongsheng@627 13888 msgid ""
dongsheng@627 13889 "In mid-2005, Chris Mason took the features of quilt and wrote an extension "
songdongsheng@710 13890 "that he called Mercurial Queues, which added quilt-like behavior to Mercurial."
dongsheng@627 13891 msgstr ""
dongsheng@627 13892
dongsheng@627 13893 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 13894 #: ../en/ch11-mq.xml:130
dongsheng@627 13895 msgid ""
dongsheng@627 13896 "The key difference between quilt and MQ is that quilt knows nothing about "
dongsheng@627 13897 "revision control systems, while MQ is <emphasis>integrated</emphasis> into "
dongsheng@627 13898 "Mercurial. Each patch that you push is represented as a Mercurial "
dongsheng@627 13899 "changeset. Pop a patch, and the changeset goes away."
dongsheng@627 13900 msgstr ""
dongsheng@627 13901
dongsheng@627 13902 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 13903 #: ../en/ch11-mq.xml:136
dongsheng@627 13904 msgid ""
dongsheng@627 13905 "Because quilt does not care about revision control tools, it is still a "
dongsheng@627 13906 "tremendously useful piece of software to know about for situations where you "
dongsheng@627 13907 "cannot use Mercurial and MQ."
dongsheng@627 13908 msgstr ""
dongsheng@627 13909
dongsheng@627 13910 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 13911 #: ../en/ch11-mq.xml:144
dongsheng@627 13912 msgid "The huge advantage of MQ"
dongsheng@636 13913 msgstr "MQ 的巨大优势"
dongsheng@627 13914
dongsheng@627 13915 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 13916 #: ../en/ch11-mq.xml:146
dongsheng@627 13917 msgid ""
dongsheng@627 13918 "I cannot overstate the value that MQ offers through the unification of "
dongsheng@627 13919 "patches and revision control."
dongsheng@627 13920 msgstr ""
dongsheng@627 13921
dongsheng@627 13922 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 13923 #: ../en/ch11-mq.xml:149
dongsheng@627 13924 msgid ""
dongsheng@627 13925 "A major reason that patches have persisted in the free software and open "
songdongsheng@668 13926 "source world&emdash;in spite of the availability of increasingly capable "
songdongsheng@668 13927 "revision control tools over the years&emdash;is the <emphasis>agility</"
songdongsheng@668 13928 "emphasis> they offer."
dongsheng@627 13929 msgstr ""
dongsheng@627 13930
dongsheng@627 13931 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 13932 #: ../en/ch11-mq.xml:155
dongsheng@627 13933 msgid ""
dongsheng@627 13934 "Traditional revision control tools make a permanent, irreversible record of "
dongsheng@627 13935 "everything that you do. While this has great value, it's also somewhat "
dongsheng@627 13936 "stifling. If you want to perform a wild-eyed experiment, you have to be "
songdongsheng@668 13937 "careful in how you go about it, or you risk leaving unneeded&emdash;or worse, "
songdongsheng@668 13938 "misleading or destabilising&emdash;traces of your missteps and errors in the "
dongsheng@627 13939 "permanent revision record."
dongsheng@627 13940 msgstr ""
dongsheng@627 13941
dongsheng@627 13942 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 13943 #: ../en/ch11-mq.xml:163
dongsheng@627 13944 msgid ""
dongsheng@627 13945 "By contrast, MQ's marriage of distributed revision control with patches makes "
dongsheng@627 13946 "it much easier to isolate your work. Your patches live on top of normal "
dongsheng@627 13947 "revision history, and you can make them disappear or reappear at will. If "
dongsheng@627 13948 "you don't like a patch, you can drop it. If a patch isn't quite as you want "
songdongsheng@668 13949 "it to be, simply fix it&emdash;as many times as you need to, until you have "
songdongsheng@668 13950 "refined it into the form you desire."
dongsheng@627 13951 msgstr ""
dongsheng@627 13952
dongsheng@627 13953 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 13954 #: ../en/ch11-mq.xml:171
dongsheng@627 13955 msgid ""
dongsheng@627 13956 "As an example, the integration of patches with revision control makes "
songdongsheng@668 13957 "understanding patches and debugging their effects&emdash;and their interplay "
songdongsheng@668 13958 "with the code they're based on&emdash;<emphasis>enormously</emphasis> easier. "
songdongsheng@668 13959 "Since every applied patch has an associated changeset, you can give <command "
songdongsheng@668 13960 "role=\"hg-cmd\">hg log</command> a file name to see which changesets and "
songdongsheng@668 13961 "patches affected the file. You can use the <command role=\"hg-cmd\">hg "
songdongsheng@668 13962 "bisect</command> command to binary-search through all changesets and applied "
songdongsheng@668 13963 "patches to see where a bug got introduced or fixed. You can use the <command "
songdongsheng@668 13964 "role=\"hg-cmd\">hg annotate</command> command to see which changeset or patch "
songdongsheng@668 13965 "modified a particular line of a source file. And so on."
dongsheng@627 13966 msgstr ""
dongsheng@627 13967
dongsheng@627 13968 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 13969 #: ../en/ch11-mq.xml:189
dongsheng@627 13970 msgid ""
dongsheng@627 13971 "Because MQ doesn't hide its patch-oriented nature, it is helpful to "
dongsheng@627 13972 "understand what patches are, and a little about the tools that work with them."
dongsheng@627 13973 msgstr ""
dongsheng@627 13974
dongsheng@627 13975 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 13976 #: ../en/ch11-mq.xml:193
dongsheng@627 13977 msgid ""
dongsheng@627 13978 "The traditional Unix <command>diff</command> command compares two files, and "
dongsheng@627 13979 "prints a list of differences between them. The <command>patch</command> "
dongsheng@627 13980 "command understands these differences as <emphasis>modifications</emphasis> "
dongsheng@627 13981 "to make to a file. Take a look below for a simple example of these commands "
dongsheng@627 13982 "in action."
dongsheng@627 13983 msgstr ""
dongsheng@627 13984
dongsheng@627 13985 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 13986 #: ../en/ch11-mq.xml:202
dongsheng@627 13987 msgid ""
dongsheng@627 13988 "The type of file that <command>diff</command> generates (and <command>patch</"
dongsheng@627 13989 "command> takes as input) is called a <quote>patch</quote> or a <quote>diff</"
dongsheng@627 13990 "quote>; there is no difference between a patch and a diff. (We'll use the "
dongsheng@627 13991 "term <quote>patch</quote>, since it's more commonly used.)"
dongsheng@627 13992 msgstr ""
dongsheng@627 13993
dongsheng@627 13994 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 13995 #: ../en/ch11-mq.xml:208
dongsheng@627 13996 msgid ""
dongsheng@627 13997 "A patch file can start with arbitrary text; the <command>patch</command> "
dongsheng@627 13998 "command ignores this text, but MQ uses it as the commit message when creating "
dongsheng@627 13999 "changesets. To find the beginning of the patch content, <command>patch</"
dongsheng@627 14000 "command> searches for the first line that starts with the string "
dongsheng@627 14001 "<quote><literal>diff -</literal></quote>."
dongsheng@627 14002 msgstr ""
dongsheng@627 14003
dongsheng@627 14004 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 14005 #: ../en/ch11-mq.xml:215
dongsheng@627 14006 msgid ""
dongsheng@627 14007 "MQ works with <emphasis>unified</emphasis> diffs (<command>patch</command> "
dongsheng@627 14008 "can accept several other diff formats, but MQ doesn't). A unified diff "
dongsheng@627 14009 "contains two kinds of header. The <emphasis>file header</emphasis> describes "
dongsheng@627 14010 "the file being modified; it contains the name of the file to modify. When "
dongsheng@627 14011 "<command>patch</command> sees a new file header, it looks for a file with "
dongsheng@627 14012 "that name to start modifying."
dongsheng@627 14013 msgstr ""
dongsheng@627 14014
dongsheng@627 14015 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 14016 #: ../en/ch11-mq.xml:223
dongsheng@627 14017 msgid ""
dongsheng@627 14018 "After the file header comes a series of <emphasis>hunks</emphasis>. Each "
dongsheng@627 14019 "hunk starts with a header; this identifies the range of line numbers within "
dongsheng@627 14020 "the file that the hunk should modify. Following the header, a hunk starts "
dongsheng@627 14021 "and ends with a few (usually three) lines of text from the unmodified file; "
dongsheng@627 14022 "these are called the <emphasis>context</emphasis> for the hunk. If there's "
dongsheng@627 14023 "only a small amount of context between successive hunks, <command>diff</"
dongsheng@627 14024 "command> doesn't print a new hunk header; it just runs the hunks together, "
dongsheng@627 14025 "with a few lines of context between modifications."
dongsheng@627 14026 msgstr ""
dongsheng@627 14027
dongsheng@627 14028 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 14029 #: ../en/ch11-mq.xml:235
dongsheng@627 14030 msgid ""
dongsheng@627 14031 "Each line of context begins with a space character. Within the hunk, a line "
dongsheng@627 14032 "that begins with <quote><literal>-</literal></quote> means <quote>remove this "
dongsheng@627 14033 "line,</quote> while a line that begins with <quote><literal>+</literal></"
dongsheng@627 14034 "quote> means <quote>insert this line.</quote> For example, a line that is "
dongsheng@627 14035 "modified is represented by one deletion and one insertion."
dongsheng@627 14036 msgstr ""
dongsheng@627 14037
dongsheng@627 14038 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 14039 #: ../en/ch11-mq.xml:243
dongsheng@627 14040 msgid ""
songdongsheng@658 14041 "We will return to some of the more subtle aspects of patches later (in <xref "
songdongsheng@658 14042 "linkend=\"sec:mq:adv-patch\"/>), but you should have enough information now "
songdongsheng@658 14043 "to use MQ."
dongsheng@627 14044 msgstr ""
dongsheng@627 14045
dongsheng@627 14046 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 14047 #: ../en/ch11-mq.xml:250
dongsheng@627 14048 msgid "Getting started with Mercurial Queues"
dongsheng@636 14049 msgstr "开始使用 MQ"
dongsheng@627 14050
dongsheng@627 14051 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 14052 #: ../en/ch11-mq.xml:252
dongsheng@627 14053 msgid ""
dongsheng@627 14054 "Because MQ is implemented as an extension, you must explicitly enable before "
dongsheng@627 14055 "you can use it. (You don't need to download anything; MQ ships with the "
dongsheng@627 14056 "standard Mercurial distribution.) To enable MQ, edit your <filename role="
dongsheng@627 14057 "\"home\">~/.hgrc</filename> file, and add the lines below."
dongsheng@627 14058 msgstr ""
dongsheng@627 14059
dongsheng@627 14060 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 14061 #: ../en/ch11-mq.xml:262
dongsheng@627 14062 msgid ""
dongsheng@627 14063 "Once the extension is enabled, it will make a number of new commands "
dongsheng@627 14064 "available. To verify that the extension is working, you can use <command "
dongsheng@627 14065 "role=\"hg-cmd\">hg help</command> to see if the <command role=\"hg-ext-mq"
dongsheng@627 14066 "\">qinit</command> command is now available."
dongsheng@627 14067 msgstr ""
dongsheng@627 14068
dongsheng@627 14069 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 14070 #: ../en/ch11-mq.xml:270
dongsheng@627 14071 msgid ""
dongsheng@627 14072 "You can use MQ with <emphasis>any</emphasis> Mercurial repository, and its "
dongsheng@627 14073 "commands only operate within that repository. To get started, simply prepare "
dongsheng@627 14074 "the repository using the <command role=\"hg-ext-mq\">qinit</command> command."
dongsheng@627 14075 msgstr ""
dongsheng@627 14076
dongsheng@627 14077 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 14078 #: ../en/ch11-mq.xml:277
dongsheng@627 14079 msgid ""
dongsheng@627 14080 "This command creates an empty directory called <filename role=\"special\" "
dongsheng@627 14081 "class=\"directory\">.hg/patches</filename>, where MQ will keep its metadata. "
dongsheng@627 14082 "As with many Mercurial commands, the <command role=\"hg-ext-mq\">qinit</"
dongsheng@627 14083 "command> command prints nothing if it succeeds."
dongsheng@627 14084 msgstr ""
dongsheng@627 14085
dongsheng@627 14086 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 14087 #: ../en/ch11-mq.xml:284
dongsheng@627 14088 msgid "Creating a new patch"
dongsheng@636 14089 msgstr "创建新补丁"
dongsheng@627 14090
dongsheng@627 14091 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 14092 #: ../en/ch11-mq.xml:286
dongsheng@627 14093 msgid ""
dongsheng@627 14094 "To begin work on a new patch, use the <command role=\"hg-ext-mq\">qnew</"
dongsheng@627 14095 "command> command. This command takes one argument, the name of the patch to "
dongsheng@627 14096 "create."
dongsheng@627 14097 msgstr ""
dongsheng@627 14098
dongsheng@627 14099 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 14100 #: ../en/ch11-mq.xml:290
dongsheng@627 14101 msgid ""
dongsheng@627 14102 "MQ will use this as the name of an actual file in the <filename role=\"special"
dongsheng@627 14103 "\" class=\"directory\">.hg/patches</filename> directory, as you can see below."
dongsheng@627 14104 msgstr ""
dongsheng@627 14105
dongsheng@627 14106 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 14107 #: ../en/ch11-mq.xml:297
dongsheng@627 14108 msgid ""
dongsheng@627 14109 "Also newly present in the <filename role=\"special\" class=\"directory\">.hg/"
dongsheng@627 14110 "patches</filename> directory are two other files, <filename role=\"special"
dongsheng@627 14111 "\">series</filename> and <filename role=\"special\">status</filename>. The "
dongsheng@627 14112 "<filename role=\"special\">series</filename> file lists all of the patches "
dongsheng@627 14113 "that MQ knows about for this repository, with one patch per line. Mercurial "
dongsheng@627 14114 "uses the <filename role=\"special\">status</filename> file for internal book-"
dongsheng@627 14115 "keeping; it tracks all of the patches that MQ has <emphasis>applied</"
dongsheng@627 14116 "emphasis> in this repository."
dongsheng@627 14117 msgstr ""
dongsheng@627 14118
dongsheng@627 14119 #. type: Content of: <book><chapter><sect1><sect2><note><para>
dongsheng@650 14120 #: ../en/ch11-mq.xml:309
dongsheng@627 14121 msgid ""
dongsheng@627 14122 "You may sometimes want to edit the <filename role=\"special\">series</"
dongsheng@627 14123 "filename> file by hand; for example, to change the sequence in which some "
dongsheng@627 14124 "patches are applied. However, manually editing the <filename role=\"special"
dongsheng@627 14125 "\">status</filename> file is almost always a bad idea, as it's easy to "
dongsheng@627 14126 "corrupt MQ's idea of what is happening."
dongsheng@627 14127 msgstr ""
dongsheng@627 14128
dongsheng@627 14129 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 14130 #: ../en/ch11-mq.xml:318
dongsheng@627 14131 msgid ""
dongsheng@627 14132 "Once you have created your new patch, you can edit files in the working "
dongsheng@627 14133 "directory as you usually would. All of the normal Mercurial commands, such "
dongsheng@627 14134 "as <command role=\"hg-cmd\">hg diff</command> and <command role=\"hg-cmd\">hg "
dongsheng@627 14135 "annotate</command>, work exactly as they did before."
dongsheng@627 14136 msgstr ""
dongsheng@627 14137
dongsheng@627 14138 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 14139 #: ../en/ch11-mq.xml:326
dongsheng@627 14140 msgid "Refreshing a patch"
dongsheng@636 14141 msgstr "刷新补丁"
dongsheng@627 14142
dongsheng@627 14143 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 14144 #: ../en/ch11-mq.xml:328
dongsheng@627 14145 msgid ""
dongsheng@627 14146 "When you reach a point where you want to save your work, use the <command "
dongsheng@627 14147 "role=\"hg-ext-mq\">qrefresh</command> command to update the patch you are "
dongsheng@627 14148 "working on."
dongsheng@627 14149 msgstr ""
dongsheng@627 14150
dongsheng@627 14151 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 14152 #: ../en/ch11-mq.xml:334
dongsheng@627 14153 msgid ""
dongsheng@627 14154 "This command folds the changes you have made in the working directory into "
dongsheng@627 14155 "your patch, and updates its corresponding changeset to contain those changes."
dongsheng@627 14156 msgstr ""
dongsheng@627 14157
dongsheng@627 14158 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 14159 #: ../en/ch11-mq.xml:338
dongsheng@627 14160 msgid ""
dongsheng@627 14161 "You can run <command role=\"hg-ext-mq\">qrefresh</command> as often as you "
dongsheng@627 14162 "like, so it's a good way to <quote>checkpoint</quote> your work. Refresh "
dongsheng@627 14163 "your patch at an opportune time; try an experiment; and if the experiment "
dongsheng@627 14164 "doesn't work out, <command role=\"hg-cmd\">hg revert</command> your "
dongsheng@627 14165 "modifications back to the last time you refreshed."
dongsheng@627 14166 msgstr ""
dongsheng@627 14167
dongsheng@627 14168 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 14169 #: ../en/ch11-mq.xml:349
dongsheng@627 14170 msgid "Stacking and tracking patches"
dongsheng@636 14171 msgstr "堆叠和跟踪补丁"
dongsheng@627 14172
dongsheng@627 14173 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 14174 #: ../en/ch11-mq.xml:351
dongsheng@627 14175 msgid ""
dongsheng@627 14176 "Once you have finished working on a patch, or need to work on another, you "
dongsheng@627 14177 "can use the <command role=\"hg-ext-mq\">qnew</command> command again to "
dongsheng@627 14178 "create a new patch. Mercurial will apply this patch on top of your existing "
dongsheng@627 14179 "patch."
dongsheng@627 14180 msgstr ""
dongsheng@627 14181
dongsheng@627 14182 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 14183 #: ../en/ch11-mq.xml:358
dongsheng@627 14184 msgid ""
dongsheng@627 14185 "Notice that the patch contains the changes in our prior patch as part of its "
dongsheng@627 14186 "context (you can see this more clearly in the output of <command role=\"hg-cmd"
dongsheng@627 14187 "\">hg annotate</command>)."
dongsheng@627 14188 msgstr ""
dongsheng@627 14189
dongsheng@627 14190 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 14191 #: ../en/ch11-mq.xml:363
dongsheng@627 14192 msgid ""
dongsheng@627 14193 "So far, with the exception of <command role=\"hg-ext-mq\">qnew</command> and "
dongsheng@627 14194 "<command role=\"hg-ext-mq\">qrefresh</command>, we've been careful to only "
dongsheng@627 14195 "use regular Mercurial commands. However, MQ provides many commands that are "
dongsheng@627 14196 "easier to use when you are thinking about patches, as illustrated below."
dongsheng@627 14197 msgstr ""
dongsheng@627 14198
dongsheng@627 14199 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 14200 #: ../en/ch11-mq.xml:373
dongsheng@627 14201 msgid ""
dongsheng@627 14202 "The <command role=\"hg-ext-mq\">qseries</command> command lists every patch "
dongsheng@627 14203 "that MQ knows about in this repository, from oldest to newest (most recently "
dongsheng@627 14204 "<emphasis>created</emphasis>)."
dongsheng@627 14205 msgstr ""
dongsheng@627 14206
dongsheng@627 14207 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 14208 #: ../en/ch11-mq.xml:379
dongsheng@627 14209 msgid ""
dongsheng@627 14210 "The <command role=\"hg-ext-mq\">qapplied</command> command lists every patch "
dongsheng@627 14211 "that MQ has <emphasis>applied</emphasis> in this repository, again from "
dongsheng@627 14212 "oldest to newest (most recently applied)."
dongsheng@627 14213 msgstr ""
dongsheng@627 14214
dongsheng@627 14215 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 14216 #: ../en/ch11-mq.xml:388
dongsheng@627 14217 msgid "Manipulating the patch stack"
dongsheng@636 14218 msgstr "操作补丁堆栈"
dongsheng@627 14219
dongsheng@627 14220 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 14221 #: ../en/ch11-mq.xml:390
dongsheng@627 14222 msgid ""
dongsheng@627 14223 "The previous discussion implied that there must be a difference between "
dongsheng@627 14224 "<quote>known</quote> and <quote>applied</quote> patches, and there is. MQ "
dongsheng@627 14225 "can manage a patch without it being applied in the repository."
dongsheng@627 14226 msgstr ""
dongsheng@627 14227
dongsheng@627 14228 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 14229 #: ../en/ch11-mq.xml:395
dongsheng@627 14230 msgid ""
dongsheng@627 14231 "An <emphasis>applied</emphasis> patch has a corresponding changeset in the "
dongsheng@627 14232 "repository, and the effects of the patch and changeset are visible in the "
dongsheng@627 14233 "working directory. You can undo the application of a patch using the "
dongsheng@627 14234 "<command role=\"hg-ext-mq\">qpop</command> command. MQ still <emphasis>knows "
dongsheng@627 14235 "about</emphasis>, or manages, a popped patch, but the patch no longer has a "
dongsheng@627 14236 "corresponding changeset in the repository, and the working directory does not "
songdongsheng@658 14237 "contain the changes made by the patch. <xref linkend=\"fig:mq:stack\"/> "
songdongsheng@658 14238 "illustrates the difference between applied and tracked patches."
songdongsheng@658 14239 msgstr ""
songdongsheng@658 14240
songdongsheng@658 14241 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
songdongsheng@658 14242 #: ../en/ch11-mq.xml:408
songdongsheng@658 14243 msgid "Applied and unapplied patches in the MQ patch stack"
dongsheng@660 14244 msgstr "在 MQ 补丁堆栈中应用和撤销补丁"
songdongsheng@658 14245
songdongsheng@658 14246 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
dongsheng@650 14247 #: ../en/ch11-mq.xml:411
songdongsheng@658 14248 msgid "<imageobject><imagedata fileref=\"figs/mq-stack.png\"/></imageobject>"
dongsheng@627 14249 msgstr ""
dongsheng@627 14250
dongsheng@627 14251 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 14252 #: ../en/ch11-mq.xml:416
dongsheng@627 14253 msgid ""
dongsheng@627 14254 "You can reapply an unapplied, or popped, patch using the <command role=\"hg-"
dongsheng@627 14255 "ext-mq\">qpush</command> command. This creates a new changeset to correspond "
dongsheng@627 14256 "to the patch, and the patch's changes once again become present in the "
dongsheng@627 14257 "working directory. See below for examples of <command role=\"hg-ext-mq"
dongsheng@627 14258 "\">qpop</command> and <command role=\"hg-ext-mq\">qpush</command> in action."
dongsheng@627 14259 msgstr ""
dongsheng@627 14260
dongsheng@627 14261 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 14262 #: ../en/ch11-mq.xml:425
dongsheng@627 14263 msgid ""
dongsheng@627 14264 "Notice that once we have popped a patch or two patches, the output of "
dongsheng@627 14265 "<command role=\"hg-ext-mq\">qseries</command> remains the same, while that of "
dongsheng@627 14266 "<command role=\"hg-ext-mq\">qapplied</command> has changed."
dongsheng@627 14267 msgstr ""
dongsheng@627 14268
dongsheng@627 14269 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 14270 #: ../en/ch11-mq.xml:433
dongsheng@627 14271 msgid "Pushing and popping many patches"
dongsheng@636 14272 msgstr "压入或弹出多个补丁"
dongsheng@627 14273
dongsheng@627 14274 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 14275 #: ../en/ch11-mq.xml:435
dongsheng@627 14276 msgid ""
dongsheng@627 14277 "While <command role=\"hg-ext-mq\">qpush</command> and <command role=\"hg-ext-"
dongsheng@627 14278 "mq\">qpop</command> each operate on a single patch at a time by default, you "
dongsheng@627 14279 "can push and pop many patches in one go. The <option role=\"hg-ext-mq-cmd-"
dongsheng@627 14280 "qpush-opt\">hg -a</option> option to <command role=\"hg-ext-mq\">qpush</"
dongsheng@627 14281 "command> causes it to push all unapplied patches, while the <option role=\"hg-"
dongsheng@627 14282 "ext-mq-cmd-qpop-opt\">-a</option> option to <command role=\"hg-ext-mq\">qpop</"
dongsheng@627 14283 "command> causes it to pop all applied patches. (For some more ways to push "
songdongsheng@658 14284 "and pop many patches, see <xref linkend=\"sec:mq:perf\"/> below.)"
dongsheng@627 14285 msgstr ""
dongsheng@627 14286
dongsheng@627 14287 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 14288 #: ../en/ch11-mq.xml:451
dongsheng@627 14289 msgid "Safety checks, and overriding them"
dongsheng@636 14290 msgstr "安全的检查,然后覆盖它们"
dongsheng@627 14291
dongsheng@627 14292 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 14293 #: ../en/ch11-mq.xml:453
dongsheng@627 14294 msgid ""
dongsheng@627 14295 "Several MQ commands check the working directory before they do anything, and "
dongsheng@627 14296 "fail if they find any modifications. They do this to ensure that you won't "
dongsheng@627 14297 "lose any changes that you have made, but not yet incorporated into a patch. "
dongsheng@627 14298 "The example below illustrates this; the <command role=\"hg-ext-mq\">qnew</"
dongsheng@627 14299 "command> command will not create a new patch if there are outstanding "
dongsheng@627 14300 "changes, caused in this case by the <command role=\"hg-cmd\">hg add</command> "
dongsheng@627 14301 "of <filename>file3</filename>."
dongsheng@627 14302 msgstr ""
dongsheng@627 14303
dongsheng@627 14304 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 14305 #: ../en/ch11-mq.xml:465
dongsheng@627 14306 msgid ""
dongsheng@627 14307 "Commands that check the working directory all take an <quote>I know what I'm "
dongsheng@627 14308 "doing</quote> option, which is always named <option>-f</option>. The exact "
dongsheng@627 14309 "meaning of <option>-f</option> depends on the command. For example, <command "
dongsheng@627 14310 "role=\"hg-cmd\">hg qnew <option role=\"hg-ext-mq-cmd-qnew-opt\">hg -f</"
dongsheng@627 14311 "option></command> will incorporate any outstanding changes into the new patch "
dongsheng@627 14312 "it creates, but <command role=\"hg-cmd\">hg qpop <option role=\"hg-ext-mq-cmd-"
dongsheng@627 14313 "qpop-opt\">hg -f</option></command> will revert modifications to any files "
dongsheng@627 14314 "affected by the patch that it is popping. Be sure to read the documentation "
dongsheng@627 14315 "for a command's <option>-f</option> option before you use it!"
dongsheng@627 14316 msgstr ""
dongsheng@627 14317
dongsheng@627 14318 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 14319 #: ../en/ch11-mq.xml:480
dongsheng@627 14320 msgid "Working on several patches at once"
dongsheng@636 14321 msgstr "同时处理多个补丁"
dongsheng@627 14322
dongsheng@627 14323 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 14324 #: ../en/ch11-mq.xml:482
dongsheng@627 14325 msgid ""
dongsheng@627 14326 "The <command role=\"hg-ext-mq\">qrefresh</command> command always refreshes "
dongsheng@627 14327 "the <emphasis>topmost</emphasis> applied patch. This means that you can "
dongsheng@627 14328 "suspend work on one patch (by refreshing it), pop or push to make a different "
dongsheng@627 14329 "patch the top, and work on <emphasis>that</emphasis> patch for a while."
dongsheng@627 14330 msgstr ""
dongsheng@627 14331
dongsheng@627 14332 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 14333 #: ../en/ch11-mq.xml:489
dongsheng@627 14334 msgid ""
dongsheng@627 14335 "Here's an example that illustrates how you can use this ability. Let's say "
dongsheng@627 14336 "you're developing a new feature as two patches. The first is a change to the "
songdongsheng@668 14337 "core of your software, and the second&emdash;layered on top of the "
songdongsheng@668 14338 "first&emdash;changes the user interface to use the code you just added to the "
songdongsheng@668 14339 "core. If you notice a bug in the core while you're working on the UI patch, "
songdongsheng@668 14340 "it's easy to fix the core. Simply <command role=\"hg-ext-mq\">qrefresh</"
songdongsheng@668 14341 "command> the UI patch to save your in-progress changes, and <command role="
songdongsheng@668 14342 "\"hg-ext-mq\">qpop</command> down to the core patch. Fix the core bug, "
songdongsheng@668 14343 "<command role=\"hg-ext-mq\">qrefresh</command> the core patch, and <command "
songdongsheng@668 14344 "role=\"hg-ext-mq\">qpush</command> back to the UI patch to continue where you "
songdongsheng@668 14345 "left off."
dongsheng@627 14346 msgstr ""
dongsheng@627 14347
dongsheng@627 14348 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@658 14349 #: ../en/ch11-mq.xml:506
dongsheng@627 14350 msgid "More about patches"
dongsheng@636 14351 msgstr "关于补丁的更多信息"
dongsheng@627 14352
dongsheng@627 14353 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 14354 #: ../en/ch11-mq.xml:508
dongsheng@627 14355 msgid ""
dongsheng@627 14356 "MQ uses the GNU <command>patch</command> command to apply patches, so it's "
dongsheng@627 14357 "helpful to know a few more detailed aspects of how <command>patch</command> "
dongsheng@627 14358 "works, and about patches themselves."
dongsheng@627 14359 msgstr ""
dongsheng@627 14360
dongsheng@627 14361 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 14362 #: ../en/ch11-mq.xml:514
dongsheng@627 14363 msgid "The strip count"
dongsheng@636 14364 msgstr "修剪计数"
dongsheng@627 14365
dongsheng@627 14366 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 14367 #: ../en/ch11-mq.xml:516
dongsheng@627 14368 msgid ""
dongsheng@627 14369 "If you look at the file headers in a patch, you will notice that the "
dongsheng@627 14370 "pathnames usually have an extra component on the front that isn't present in "
dongsheng@627 14371 "the actual path name. This is a holdover from the way that people used to "
dongsheng@627 14372 "generate patches (people still do this, but it's somewhat rare with modern "
dongsheng@627 14373 "revision control tools)."
dongsheng@627 14374 msgstr ""
dongsheng@627 14375
dongsheng@627 14376 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 14377 #: ../en/ch11-mq.xml:523
dongsheng@627 14378 msgid ""
dongsheng@627 14379 "Alice would unpack a tarball, edit her files, then decide that she wanted to "
dongsheng@627 14380 "create a patch. So she'd rename her working directory, unpack the tarball "
dongsheng@627 14381 "again (hence the need for the rename), and use the <option role=\"cmd-opt-diff"
dongsheng@627 14382 "\">-r</option> and <option role=\"cmd-opt-diff\">-N</option> options to "
dongsheng@627 14383 "<command>diff</command> to recursively generate a patch between the "
dongsheng@627 14384 "unmodified directory and the modified one. The result would be that the name "
dongsheng@627 14385 "of the unmodified directory would be at the front of the left-hand path in "
dongsheng@627 14386 "every file header, and the name of the modified directory would be at the "
dongsheng@627 14387 "front of the right-hand path."
dongsheng@627 14388 msgstr ""
dongsheng@627 14389
dongsheng@627 14390 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 14391 #: ../en/ch11-mq.xml:536
dongsheng@627 14392 msgid ""
dongsheng@627 14393 "Since someone receiving a patch from the Alices of the net would be unlikely "
dongsheng@627 14394 "to have unmodified and modified directories with exactly the same names, the "
dongsheng@627 14395 "<command>patch</command> command has a <option role=\"cmd-opt-patch\">-p</"
dongsheng@627 14396 "option> option that indicates the number of leading path name components to "
dongsheng@627 14397 "strip when trying to apply a patch. This number is called the "
dongsheng@627 14398 "<emphasis>strip count</emphasis>."
dongsheng@627 14399 msgstr ""
dongsheng@627 14400
dongsheng@627 14401 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 14402 #: ../en/ch11-mq.xml:544
dongsheng@627 14403 msgid ""
dongsheng@627 14404 "An option of <quote><literal>-p1</literal></quote> means <quote>use a strip "
dongsheng@627 14405 "count of one</quote>. If <command>patch</command> sees a file name "
dongsheng@627 14406 "<filename>foo/bar/baz</filename> in a file header, it will strip "
dongsheng@627 14407 "<filename>foo</filename> and try to patch a file named <filename>bar/baz</"
dongsheng@627 14408 "filename>. (Strictly speaking, the strip count refers to the number of "
dongsheng@627 14409 "<emphasis>path separators</emphasis> (and the components that go with them ) "
dongsheng@627 14410 "to strip. A strip count of one will turn <filename>foo/bar</filename> into "
dongsheng@627 14411 "<filename>bar</filename>, but <filename>/foo/bar</filename> (notice the extra "
dongsheng@627 14412 "leading slash) into <filename>foo/bar</filename>.)"
dongsheng@627 14413 msgstr ""
dongsheng@627 14414
dongsheng@627 14415 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 14416 #: ../en/ch11-mq.xml:557
dongsheng@627 14417 msgid ""
dongsheng@627 14418 "The <quote>standard</quote> strip count for patches is one; almost all "
dongsheng@627 14419 "patches contain one leading path name component that needs to be stripped. "
dongsheng@627 14420 "Mercurial's <command role=\"hg-cmd\">hg diff</command> command generates path "
dongsheng@627 14421 "names in this form, and the <command role=\"hg-cmd\">hg import</command> "
dongsheng@627 14422 "command and MQ expect patches to have a strip count of one."
dongsheng@627 14423 msgstr ""
dongsheng@627 14424
dongsheng@627 14425 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 14426 #: ../en/ch11-mq.xml:565
dongsheng@627 14427 msgid ""
dongsheng@627 14428 "If you receive a patch from someone that you want to add to your patch queue, "
dongsheng@627 14429 "and the patch needs a strip count other than one, you cannot just <command "
dongsheng@627 14430 "role=\"hg-ext-mq\">qimport</command> the patch, because <command role=\"hg-"
dongsheng@627 14431 "ext-mq\">qimport</command> does not yet have a <literal>-p</literal> option "
dongsheng@627 14432 "(see <ulink role=\"hg-bug\" url=\"http://www.selenic.com/mercurial/bts/"
dongsheng@627 14433 "issue311\">issue 311</ulink>). Your best bet is to <command role=\"hg-ext-mq"
dongsheng@627 14434 "\">qnew</command> a patch of your own, then use <command>patch -pN</command> "
dongsheng@627 14435 "to apply their patch, followed by <command role=\"hg-cmd\">hg addremove</"
dongsheng@627 14436 "command> to pick up any files added or removed by the patch, followed by "
dongsheng@627 14437 "<command role=\"hg-ext-mq\">hg qrefresh</command>. This complexity may become "
dongsheng@627 14438 "unnecessary; see <ulink role=\"hg-bug\" url=\"http://www.selenic.com/"
dongsheng@627 14439 "mercurial/bts/issue311\">issue 311</ulink> for details."
dongsheng@627 14440 msgstr ""
dongsheng@627 14441
dongsheng@627 14442 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 14443 #: ../en/ch11-mq.xml:584
dongsheng@627 14444 msgid "Strategies for applying a patch"
dongsheng@636 14445 msgstr "应用补丁的策略"
dongsheng@627 14446
dongsheng@627 14447 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 14448 #: ../en/ch11-mq.xml:586
dongsheng@627 14449 msgid ""
dongsheng@627 14450 "When <command>patch</command> applies a hunk, it tries a handful of "
dongsheng@627 14451 "successively less accurate strategies to try to make the hunk apply. This "
dongsheng@627 14452 "falling-back technique often makes it possible to take a patch that was "
dongsheng@627 14453 "generated against an old version of a file, and apply it against a newer "
dongsheng@627 14454 "version of that file."
dongsheng@627 14455 msgstr ""
dongsheng@627 14456
dongsheng@627 14457 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 14458 #: ../en/ch11-mq.xml:593
dongsheng@627 14459 msgid ""
dongsheng@627 14460 "First, <command>patch</command> tries an exact match, where the line numbers, "
dongsheng@627 14461 "the context, and the text to be modified must apply exactly. If it cannot "
dongsheng@627 14462 "make an exact match, it tries to find an exact match for the context, without "
dongsheng@627 14463 "honouring the line numbering information. If this succeeds, it prints a line "
dongsheng@627 14464 "of output saying that the hunk was applied, but at some <emphasis>offset</"
dongsheng@627 14465 "emphasis> from the original line number."
dongsheng@627 14466 msgstr ""
dongsheng@627 14467
dongsheng@627 14468 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 14469 #: ../en/ch11-mq.xml:602
dongsheng@627 14470 msgid ""
dongsheng@627 14471 "If a context-only match fails, <command>patch</command> removes the first and "
dongsheng@627 14472 "last lines of the context, and tries a <emphasis>reduced</emphasis> context-"
dongsheng@627 14473 "only match. If the hunk with reduced context succeeds, it prints a message "
dongsheng@627 14474 "saying that it applied the hunk with a <emphasis>fuzz factor</emphasis> (the "
dongsheng@627 14475 "number after the fuzz factor indicates how many lines of context "
dongsheng@627 14476 "<command>patch</command> had to trim before the patch applied)."
dongsheng@627 14477 msgstr ""
dongsheng@627 14478
dongsheng@627 14479 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 14480 #: ../en/ch11-mq.xml:611
dongsheng@627 14481 msgid ""
dongsheng@627 14482 "When neither of these techniques works, <command>patch</command> prints a "
dongsheng@627 14483 "message saying that the hunk in question was rejected. It saves rejected "
dongsheng@627 14484 "hunks (also simply called <quote>rejects</quote>) to a file with the same "
dongsheng@627 14485 "name, and an added <filename role=\"special\">.rej</filename> extension. It "
dongsheng@627 14486 "also saves an unmodified copy of the file with a <filename role=\"special\">."
dongsheng@627 14487 "orig</filename> extension; the copy of the file without any extensions will "
dongsheng@627 14488 "contain any changes made by hunks that <emphasis>did</emphasis> apply "
dongsheng@627 14489 "cleanly. If you have a patch that modifies <filename>foo</filename> with six "
dongsheng@627 14490 "hunks, and one of them fails to apply, you will have: an unmodified "
dongsheng@627 14491 "<filename>foo.orig</filename>, a <filename>foo.rej</filename> containing one "
dongsheng@627 14492 "hunk, and <filename>foo</filename>, containing the changes made by the five "
dongsheng@627 14493 "successful hunks."
dongsheng@627 14494 msgstr ""
dongsheng@627 14495
dongsheng@627 14496 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 14497 #: ../en/ch11-mq.xml:629
dongsheng@627 14498 msgid "Some quirks of patch representation"
dongsheng@636 14499 msgstr "补丁的一些特性"
dongsheng@627 14500
dongsheng@627 14501 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 14502 #: ../en/ch11-mq.xml:631
dongsheng@627 14503 msgid ""
dongsheng@627 14504 "There are a few useful things to know about how <command>patch</command> "
dongsheng@627 14505 "works with files."
dongsheng@627 14506 msgstr ""
dongsheng@627 14507
dongsheng@627 14508 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 14509 #: ../en/ch11-mq.xml:634
dongsheng@627 14510 msgid ""
dongsheng@627 14511 "This should already be obvious, but <command>patch</command> cannot handle "
dongsheng@627 14512 "binary files."
dongsheng@627 14513 msgstr ""
dongsheng@627 14514
dongsheng@627 14515 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 14516 #: ../en/ch11-mq.xml:638
dongsheng@627 14517 msgid ""
dongsheng@627 14518 "Neither does it care about the executable bit; it creates new files as "
dongsheng@627 14519 "readable, but not executable."
dongsheng@627 14520 msgstr ""
dongsheng@627 14521
dongsheng@627 14522 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 14523 #: ../en/ch11-mq.xml:642
dongsheng@627 14524 msgid ""
dongsheng@627 14525 "<command>patch</command> treats the removal of a file as a diff between the "
dongsheng@627 14526 "file to be removed and the empty file. So your idea of <quote>I deleted this "
dongsheng@627 14527 "file</quote> looks like <quote>every line of this file was deleted</quote> in "
dongsheng@627 14528 "a patch."
dongsheng@627 14529 msgstr ""
dongsheng@627 14530
dongsheng@627 14531 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 14532 #: ../en/ch11-mq.xml:648
dongsheng@627 14533 msgid ""
dongsheng@627 14534 "It treats the addition of a file as a diff between the empty file and the "
dongsheng@627 14535 "file to be added. So in a patch, your idea of <quote>I added this file</"
dongsheng@627 14536 "quote> looks like <quote>every line of this file was added</quote>."
dongsheng@627 14537 msgstr ""
dongsheng@627 14538
dongsheng@627 14539 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 14540 #: ../en/ch11-mq.xml:654
dongsheng@627 14541 msgid ""
dongsheng@627 14542 "It treats a renamed file as the removal of the old name, and the addition of "
dongsheng@627 14543 "the new name. This means that renamed files have a big footprint in "
dongsheng@627 14544 "patches. (Note also that Mercurial does not currently try to infer when "
dongsheng@627 14545 "files have been renamed or copied in a patch.)"
dongsheng@627 14546 msgstr ""
dongsheng@627 14547
dongsheng@627 14548 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 14549 #: ../en/ch11-mq.xml:660
dongsheng@627 14550 msgid ""
dongsheng@627 14551 "<command>patch</command> cannot represent empty files, so you cannot use a "
dongsheng@627 14552 "patch to represent the notion <quote>I added this empty file to the tree</"
dongsheng@627 14553 "quote>."
dongsheng@627 14554 msgstr ""
dongsheng@627 14555
dongsheng@627 14556 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 14557 #: ../en/ch11-mq.xml:667
dongsheng@627 14558 msgid "Beware the fuzz"
dongsheng@636 14559 msgstr "当心毛刺"
dongsheng@627 14560
dongsheng@627 14561 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 14562 #: ../en/ch11-mq.xml:669
dongsheng@627 14563 msgid ""
dongsheng@627 14564 "While applying a hunk at an offset, or with a fuzz factor, will often be "
dongsheng@627 14565 "completely successful, these inexact techniques naturally leave open the "
dongsheng@627 14566 "possibility of corrupting the patched file. The most common cases typically "
dongsheng@627 14567 "involve applying a patch twice, or at an incorrect location in the file. If "
dongsheng@627 14568 "<command>patch</command> or <command role=\"hg-ext-mq\">qpush</command> ever "
dongsheng@627 14569 "mentions an offset or fuzz factor, you should make sure that the modified "
dongsheng@627 14570 "files are correct afterwards."
dongsheng@627 14571 msgstr ""
dongsheng@627 14572
dongsheng@627 14573 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 14574 #: ../en/ch11-mq.xml:679
dongsheng@627 14575 msgid ""
dongsheng@627 14576 "It's often a good idea to refresh a patch that has applied with an offset or "
dongsheng@627 14577 "fuzz factor; refreshing the patch generates new context information that will "
dongsheng@627 14578 "make it apply cleanly. I say <quote>often,</quote> not <quote>always,</"
dongsheng@627 14579 "quote> because sometimes refreshing a patch will make it fail to apply "
dongsheng@627 14580 "against a different revision of the underlying files. In some cases, such as "
dongsheng@627 14581 "when you're maintaining a patch that must sit on top of multiple versions of "
dongsheng@627 14582 "a source tree, it's acceptable to have a patch apply with some fuzz, provided "
dongsheng@627 14583 "you've verified the results of the patching process in such cases."
dongsheng@627 14584 msgstr ""
dongsheng@627 14585
dongsheng@627 14586 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 14587 #: ../en/ch11-mq.xml:692
dongsheng@627 14588 msgid "Handling rejection"
dongsheng@636 14589 msgstr "处理拒绝"
dongsheng@627 14590
dongsheng@627 14591 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 14592 #: ../en/ch11-mq.xml:694
dongsheng@627 14593 msgid ""
dongsheng@627 14594 "If <command role=\"hg-ext-mq\">qpush</command> fails to apply a patch, it "
dongsheng@627 14595 "will print an error message and exit. If it has left <filename role=\"special"
dongsheng@627 14596 "\">.rej</filename> files behind, it is usually best to fix up the rejected "
dongsheng@627 14597 "hunks before you push more patches or do any further work."
dongsheng@627 14598 msgstr ""
dongsheng@627 14599
dongsheng@627 14600 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 14601 #: ../en/ch11-mq.xml:700
dongsheng@627 14602 msgid ""
dongsheng@627 14603 "If your patch <emphasis>used to</emphasis> apply cleanly, and no longer does "
dongsheng@627 14604 "because you've changed the underlying code that your patches are based on, "
songdongsheng@658 14605 "Mercurial Queues can help; see <xref linkend=\"sec:mq:merge\"/> for details."
songdongsheng@658 14606 msgstr ""
songdongsheng@658 14607
songdongsheng@658 14608 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 14609 #: ../en/ch11-mq.xml:705
dongsheng@627 14610 msgid ""
dongsheng@627 14611 "Unfortunately, there aren't any great techniques for dealing with rejected "
dongsheng@627 14612 "hunks. Most often, you'll need to view the <filename role=\"special\">.rej</"
dongsheng@627 14613 "filename> file and edit the target file, applying the rejected hunks by hand."
dongsheng@627 14614 msgstr ""
dongsheng@627 14615
dongsheng@627 14616 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 14617 #: ../en/ch11-mq.xml:710
dongsheng@627 14618 msgid ""
dongsheng@627 14619 "If you're feeling adventurous, Neil Brown, a Linux kernel hacker, wrote a "
dongsheng@627 14620 "tool called <command>wiggle</command> <citation>web:wiggle</citation>, which "
dongsheng@627 14621 "is more vigorous than <command>patch</command> in its attempts to make a "
dongsheng@627 14622 "patch apply."
dongsheng@627 14623 msgstr ""
dongsheng@627 14624
dongsheng@627 14625 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 14626 #: ../en/ch11-mq.xml:716
dongsheng@627 14627 msgid ""
dongsheng@627 14628 "Another Linux kernel hacker, Chris Mason (the author of Mercurial Queues), "
dongsheng@627 14629 "wrote a similar tool called <command>mpatch</command> <citation>web:mpatch</"
dongsheng@627 14630 "citation>, which takes a simple approach to automating the application of "
dongsheng@627 14631 "hunks rejected by <command>patch</command>. The <command>mpatch</command> "
dongsheng@627 14632 "command can help with four common reasons that a hunk may be rejected:"
dongsheng@627 14633 msgstr ""
dongsheng@627 14634
dongsheng@627 14635 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 14636 #: ../en/ch11-mq.xml:725
dongsheng@627 14637 msgid "The context in the middle of a hunk has changed."
dongsheng@627 14638 msgstr ""
dongsheng@627 14639
dongsheng@627 14640 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 14641 #: ../en/ch11-mq.xml:728
dongsheng@627 14642 msgid "A hunk is missing some context at the beginning or end."
dongsheng@627 14643 msgstr ""
dongsheng@627 14644
dongsheng@627 14645 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 14646 #: ../en/ch11-mq.xml:731
dongsheng@627 14647 msgid ""
songdongsheng@668 14648 "A large hunk might apply better&emdash;either entirely or in part&emdash;if "
songdongsheng@668 14649 "it was broken up into smaller hunks."
dongsheng@627 14650 msgstr ""
dongsheng@627 14651
dongsheng@627 14652 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 14653 #: ../en/ch11-mq.xml:735
dongsheng@627 14654 msgid ""
dongsheng@627 14655 "A hunk removes lines with slightly different content than those currently "
dongsheng@627 14656 "present in the file."
dongsheng@627 14657 msgstr ""
dongsheng@627 14658
dongsheng@627 14659 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 14660 #: ../en/ch11-mq.xml:739
dongsheng@627 14661 msgid ""
dongsheng@627 14662 "If you use <command>wiggle</command> or <command>mpatch</command>, you should "
dongsheng@627 14663 "be doubly careful to check your results when you're done. In fact, "
dongsheng@627 14664 "<command>mpatch</command> enforces this method of double-checking the tool's "
dongsheng@627 14665 "output, by automatically dropping you into a merge program when it has done "
dongsheng@627 14666 "its job, so that you can verify its work and finish off any remaining merges."
dongsheng@627 14667 msgstr ""
dongsheng@627 14668
dongsheng@627 14669 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@658 14670 #: ../en/ch11-mq.xml:751
dongsheng@627 14671 msgid "Getting the best performance out of MQ"
dongsheng@636 14672 msgstr "MQ 的性能"
dongsheng@627 14673
dongsheng@627 14674 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 14675 #: ../en/ch11-mq.xml:753
dongsheng@627 14676 msgid ""
dongsheng@627 14677 "MQ is very efficient at handling a large number of patches. I ran some "
dongsheng@627 14678 "performance experiments in mid-2006 for a talk that I gave at the 2006 "
dongsheng@627 14679 "EuroPython conference <citation>web:europython</citation>. I used as my data "
dongsheng@627 14680 "set the Linux 2.6.17-mm1 patch series, which consists of 1,738 patches. I "
dongsheng@627 14681 "applied these on top of a Linux kernel repository containing all 27,472 "
dongsheng@627 14682 "revisions between Linux 2.6.12-rc2 and Linux 2.6.17."
dongsheng@627 14683 msgstr ""
dongsheng@627 14684
dongsheng@627 14685 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 14686 #: ../en/ch11-mq.xml:762
dongsheng@627 14687 msgid ""
dongsheng@627 14688 "On my old, slow laptop, I was able to <command role=\"hg-cmd\">hg qpush "
dongsheng@627 14689 "<option role=\"hg-ext-mq-cmd-qpush-opt\">hg -a</option></command> all 1,738 "
dongsheng@627 14690 "patches in 3.5 minutes, and <command role=\"hg-cmd\">hg qpop <option role="
dongsheng@627 14691 "\"hg-ext-mq-cmd-qpop-opt\">hg -a</option></command> them all in 30 seconds. "
dongsheng@627 14692 "(On a newer laptop, the time to push all patches dropped to two minutes.) I "
dongsheng@627 14693 "could <command role=\"hg-ext-mq\">qrefresh</command> one of the biggest "
dongsheng@627 14694 "patches (which made 22,779 lines of changes to 287 files) in 6.6 seconds."
dongsheng@627 14695 msgstr ""
dongsheng@627 14696
dongsheng@627 14697 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 14698 #: ../en/ch11-mq.xml:773
dongsheng@627 14699 msgid ""
dongsheng@627 14700 "Clearly, MQ is well suited to working in large trees, but there are a few "
dongsheng@627 14701 "tricks you can use to get the best performance of it."
dongsheng@627 14702 msgstr ""
dongsheng@627 14703
dongsheng@627 14704 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 14705 #: ../en/ch11-mq.xml:777
dongsheng@627 14706 msgid ""
dongsheng@627 14707 "First of all, try to <quote>batch</quote> operations together. Every time "
dongsheng@627 14708 "you run <command role=\"hg-ext-mq\">qpush</command> or <command role=\"hg-ext-"
dongsheng@627 14709 "mq\">qpop</command>, these commands scan the working directory once to make "
dongsheng@627 14710 "sure you haven't made some changes and then forgotten to run <command role="
dongsheng@627 14711 "\"hg-ext-mq\">qrefresh</command>. On a small tree, the time that this scan "
dongsheng@627 14712 "takes is unnoticeable. However, on a medium-sized tree (containing tens of "
dongsheng@627 14713 "thousands of files), it can take a second or more."
dongsheng@627 14714 msgstr ""
dongsheng@627 14715
dongsheng@627 14716 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 14717 #: ../en/ch11-mq.xml:788
dongsheng@627 14718 msgid ""
dongsheng@627 14719 "The <command role=\"hg-ext-mq\">qpush</command> and <command role=\"hg-ext-mq"
dongsheng@627 14720 "\">qpop</command> commands allow you to push and pop multiple patches at a "
dongsheng@627 14721 "time. You can identify the <quote>destination patch</quote> that you want to "
dongsheng@627 14722 "end up at. When you <command role=\"hg-ext-mq\">qpush</command> with a "
dongsheng@627 14723 "destination specified, it will push patches until that patch is at the top of "
dongsheng@627 14724 "the applied stack. When you <command role=\"hg-ext-mq\">qpop</command> to a "
dongsheng@627 14725 "destination, MQ will pop patches until the destination patch is at the top."
dongsheng@627 14726 msgstr ""
dongsheng@627 14727
dongsheng@627 14728 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 14729 #: ../en/ch11-mq.xml:798
dongsheng@627 14730 msgid ""
dongsheng@627 14731 "You can identify a destination patch using either the name of the patch, or "
dongsheng@627 14732 "by number. If you use numeric addressing, patches are counted from zero; "
dongsheng@627 14733 "this means that the first patch is zero, the second is one, and so on."
dongsheng@627 14734 msgstr ""
dongsheng@627 14735
dongsheng@627 14736 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@658 14737 #: ../en/ch11-mq.xml:805
dongsheng@627 14738 msgid "Updating your patches when the underlying code changes"
dongsheng@636 14739 msgstr "当基础代码改变时,更新补丁的方法"
dongsheng@627 14740
dongsheng@627 14741 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 14742 #: ../en/ch11-mq.xml:808
dongsheng@627 14743 msgid ""
dongsheng@627 14744 "It's common to have a stack of patches on top of an underlying repository "
dongsheng@627 14745 "that you don't modify directly. If you're working on changes to third-party "
dongsheng@627 14746 "code, or on a feature that is taking longer to develop than the rate of "
dongsheng@627 14747 "change of the code beneath, you will often need to sync up with the "
dongsheng@627 14748 "underlying code, and fix up any hunks in your patches that no longer apply. "
dongsheng@627 14749 "This is called <emphasis>rebasing</emphasis> your patch series."
dongsheng@627 14750 msgstr ""
dongsheng@627 14751
dongsheng@627 14752 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 14753 #: ../en/ch11-mq.xml:817
dongsheng@627 14754 msgid ""
dongsheng@627 14755 "The simplest way to do this is to <command role=\"hg-cmd\">hg qpop <option "
dongsheng@627 14756 "role=\"hg-ext-mq-cmd-qpop-opt\">hg -a</option></command> your patches, then "
dongsheng@627 14757 "<command role=\"hg-cmd\">hg pull</command> changes into the underlying "
dongsheng@627 14758 "repository, and finally <command role=\"hg-cmd\">hg qpush <option role=\"hg-"
dongsheng@627 14759 "ext-mq-cmd-qpop-opt\">hg -a</option></command> your patches again. MQ will "
dongsheng@627 14760 "stop pushing any time it runs across a patch that fails to apply during "
dongsheng@627 14761 "conflicts, allowing you to fix your conflicts, <command role=\"hg-ext-mq"
dongsheng@627 14762 "\">qrefresh</command> the affected patch, and continue pushing until you have "
dongsheng@627 14763 "fixed your entire stack."
dongsheng@627 14764 msgstr ""
dongsheng@627 14765
dongsheng@627 14766 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 14767 #: ../en/ch11-mq.xml:829
dongsheng@627 14768 msgid ""
dongsheng@627 14769 "This approach is easy to use and works well if you don't expect changes to "
dongsheng@627 14770 "the underlying code to affect how well your patches apply. If your patch "
dongsheng@627 14771 "stack touches code that is modified frequently or invasively in the "
dongsheng@627 14772 "underlying repository, however, fixing up rejected hunks by hand quickly "
dongsheng@627 14773 "becomes tiresome."
dongsheng@627 14774 msgstr ""
dongsheng@627 14775
dongsheng@627 14776 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 14777 #: ../en/ch11-mq.xml:836
dongsheng@627 14778 msgid ""
dongsheng@627 14779 "It's possible to partially automate the rebasing process. If your patches "
dongsheng@627 14780 "apply cleanly against some revision of the underlying repo, MQ can use this "
dongsheng@627 14781 "information to help you to resolve conflicts between your patches and a "
dongsheng@627 14782 "different revision."
dongsheng@627 14783 msgstr ""
dongsheng@627 14784
dongsheng@627 14785 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 14786 #: ../en/ch11-mq.xml:842
songdongsheng@658 14787 msgid "The process is a little involved."
songdongsheng@658 14788 msgstr ""
songdongsheng@658 14789
songdongsheng@658 14790 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
dongsheng@650 14791 #: ../en/ch11-mq.xml:844
dongsheng@627 14792 msgid ""
dongsheng@627 14793 "To begin, <command role=\"hg-cmd\">hg qpush -a</command> all of your patches "
dongsheng@627 14794 "on top of the revision where you know that they apply cleanly."
dongsheng@627 14795 msgstr ""
dongsheng@627 14796
dongsheng@627 14797 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
songdongsheng@658 14798 #: ../en/ch11-mq.xml:848
dongsheng@627 14799 msgid ""
dongsheng@627 14800 "Save a backup copy of your patch directory using <command role=\"hg-cmd\">hg "
dongsheng@627 14801 "qsave <option role=\"hg-ext-mq-cmd-qsave-opt\">hg -e</option> <option role="
dongsheng@627 14802 "\"hg-ext-mq-cmd-qsave-opt\">hg -c</option></command>. This prints the name "
dongsheng@627 14803 "of the directory that it has saved the patches in. It will save the patches "
dongsheng@627 14804 "to a directory called <filename role=\"special\" class=\"directory\">.hg/"
dongsheng@627 14805 "patches.N</filename>, where <literal>N</literal> is a small integer. It also "
dongsheng@627 14806 "commits a <quote>save changeset</quote> on top of your applied patches; this "
dongsheng@627 14807 "is for internal book-keeping, and records the states of the <filename role="
dongsheng@627 14808 "\"special\">series</filename> and <filename role=\"special\">status</"
dongsheng@627 14809 "filename> files."
dongsheng@627 14810 msgstr ""
dongsheng@627 14811
dongsheng@627 14812 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
songdongsheng@658 14813 #: ../en/ch11-mq.xml:862
dongsheng@627 14814 msgid ""
dongsheng@627 14815 "Use <command role=\"hg-cmd\">hg pull</command> to bring new changes into the "
dongsheng@627 14816 "underlying repository. (Don't run <command role=\"hg-cmd\">hg pull -u</"
dongsheng@627 14817 "command>; see below for why.)"
dongsheng@627 14818 msgstr ""
dongsheng@627 14819
dongsheng@627 14820 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
songdongsheng@658 14821 #: ../en/ch11-mq.xml:867
dongsheng@627 14822 msgid ""
dongsheng@627 14823 "Update to the new tip revision, using <command role=\"hg-cmd\">hg update "
dongsheng@627 14824 "<option role=\"hg-opt-update\">-C</option></command> to override the patches "
dongsheng@627 14825 "you have pushed."
dongsheng@627 14826 msgstr ""
dongsheng@627 14827
dongsheng@627 14828 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
songdongsheng@658 14829 #: ../en/ch11-mq.xml:872
dongsheng@650 14830 msgid ""
dongsheng@650 14831 "Merge all patches using <command>hg qpush -m -a</command>. The <option role="
dongsheng@650 14832 "\"hg-ext-mq-cmd-qpush-opt\">-m</option> option to <command role=\"hg-ext-mq"
dongsheng@650 14833 "\">qpush</command> tells MQ to perform a three-way merge if the patch fails "
dongsheng@650 14834 "to apply."
dongsheng@650 14835 msgstr ""
dongsheng@650 14836
dongsheng@650 14837 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 14838 #: ../en/ch11-mq.xml:880
dongsheng@627 14839 msgid ""
dongsheng@627 14840 "During the <command role=\"hg-cmd\">hg qpush <option role=\"hg-ext-mq-cmd-"
dongsheng@627 14841 "qpush-opt\">hg -m</option></command>, each patch in the <filename role="
dongsheng@627 14842 "\"special\">series</filename> file is applied normally. If a patch applies "
dongsheng@627 14843 "with fuzz or rejects, MQ looks at the queue you <command role=\"hg-ext-mq"
dongsheng@627 14844 "\">qsave</command>d, and performs a three-way merge with the corresponding "
dongsheng@627 14845 "changeset. This merge uses Mercurial's normal merge machinery, so it may pop "
dongsheng@627 14846 "up a GUI merge tool to help you to resolve problems."
dongsheng@627 14847 msgstr ""
dongsheng@627 14848
dongsheng@627 14849 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 14850 #: ../en/ch11-mq.xml:890
dongsheng@627 14851 msgid ""
dongsheng@627 14852 "When you finish resolving the effects of a patch, MQ refreshes your patch "
dongsheng@627 14853 "based on the result of the merge."
dongsheng@627 14854 msgstr ""
dongsheng@627 14855
dongsheng@627 14856 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 14857 #: ../en/ch11-mq.xml:893
dongsheng@627 14858 msgid ""
dongsheng@627 14859 "At the end of this process, your repository will have one extra head from the "
dongsheng@627 14860 "old patch queue, and a copy of the old patch queue will be in <filename role="
dongsheng@627 14861 "\"special\" class=\"directory\">.hg/patches.N</filename>. You can remove the "
dongsheng@627 14862 "extra head using <command role=\"hg-cmd\">hg qpop -a -n patches.N</command> "
dongsheng@627 14863 "or <command role=\"hg-cmd\">hg strip</command>. You can delete <filename "
dongsheng@627 14864 "role=\"special\" class=\"directory\">.hg/patches.N</filename> once you are "
dongsheng@627 14865 "sure that you no longer need it as a backup."
dongsheng@627 14866 msgstr ""
dongsheng@627 14867
dongsheng@627 14868 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@658 14869 #: ../en/ch11-mq.xml:905
dongsheng@627 14870 msgid "Identifying patches"
dongsheng@636 14871 msgstr "标识补丁"
dongsheng@627 14872
dongsheng@627 14873 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 14874 #: ../en/ch11-mq.xml:907
dongsheng@627 14875 msgid ""
dongsheng@627 14876 "MQ commands that work with patches let you refer to a patch either by using "
dongsheng@627 14877 "its name or by a number. By name is obvious enough; pass the name "
dongsheng@627 14878 "<filename>foo.patch</filename> to <command role=\"hg-ext-mq\">qpush</"
dongsheng@627 14879 "command>, for example, and it will push patches until <filename>foo.patch</"
dongsheng@627 14880 "filename> is applied."
dongsheng@627 14881 msgstr ""
dongsheng@627 14882
dongsheng@627 14883 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 14884 #: ../en/ch11-mq.xml:914
dongsheng@627 14885 msgid ""
dongsheng@627 14886 "As a shortcut, you can refer to a patch using both a name and a numeric "
dongsheng@627 14887 "offset; <literal>foo.patch-2</literal> means <quote>two patches before "
dongsheng@627 14888 "<literal>foo.patch</literal></quote>, while <literal>bar.patch+4</literal> "
dongsheng@627 14889 "means <quote>four patches after <literal>bar.patch</literal></quote>."
dongsheng@627 14890 msgstr ""
dongsheng@627 14891
dongsheng@627 14892 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 14893 #: ../en/ch11-mq.xml:920
dongsheng@627 14894 msgid ""
dongsheng@627 14895 "Referring to a patch by index isn't much different. The first patch printed "
dongsheng@627 14896 "in the output of <command role=\"hg-ext-mq\">qseries</command> is patch zero "
dongsheng@627 14897 "(yes, it's one of those start-at-zero counting systems); the second is patch "
dongsheng@627 14898 "one; and so on."
dongsheng@627 14899 msgstr ""
dongsheng@627 14900
dongsheng@627 14901 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 14902 #: ../en/ch11-mq.xml:926
dongsheng@627 14903 msgid ""
dongsheng@627 14904 "MQ also makes it easy to work with patches when you are using normal "
dongsheng@627 14905 "Mercurial commands. Every command that accepts a changeset ID will also "
dongsheng@627 14906 "accept the name of an applied patch. MQ augments the tags normally in the "
dongsheng@627 14907 "repository with an eponymous one for each applied patch. In addition, the "
dongsheng@650 14908 "special tags <literal role=\"tag\">qbase</literal> and <literal role=\"tag"
dongsheng@650 14909 "\">qtip</literal> identify the <quote>bottom-most</quote> and topmost applied "
dongsheng@650 14910 "patches, respectively."
dongsheng@650 14911 msgstr ""
dongsheng@650 14912
dongsheng@650 14913 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 14914 #: ../en/ch11-mq.xml:936
dongsheng@627 14915 msgid ""
dongsheng@627 14916 "These additions to Mercurial's normal tagging capabilities make dealing with "
dongsheng@627 14917 "patches even more of a breeze."
dongsheng@627 14918 msgstr ""
dongsheng@627 14919
dongsheng@627 14920 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 14921 #: ../en/ch11-mq.xml:939
dongsheng@627 14922 msgid "Want to patchbomb a mailing list with your latest series of changes?"
dongsheng@627 14923 msgstr ""
dongsheng@627 14924
dongsheng@627 14925 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 14926 #: ../en/ch11-mq.xml:942
songdongsheng@658 14927 msgid ""
songdongsheng@658 14928 "(Don't know what <quote>patchbombing</quote> is? See <xref linkend=\"sec:"
songdongsheng@658 14929 "hgext:patchbomb\"/>.)"
dongsheng@627 14930 msgstr ""
dongsheng@627 14931
dongsheng@627 14932 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 14933 #: ../en/ch11-mq.xml:945
dongsheng@627 14934 msgid ""
dongsheng@627 14935 "Need to see all of the patches since <literal>foo.patch</literal> that have "
dongsheng@627 14936 "touched files in a subdirectory of your tree?"
dongsheng@627 14937 msgstr ""
dongsheng@627 14938
dongsheng@650 14939 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 14940 #: ../en/ch11-mq.xml:952
dongsheng@627 14941 msgid ""
dongsheng@627 14942 "Because MQ makes the names of patches available to the rest of Mercurial "
dongsheng@627 14943 "through its normal internal tag machinery, you don't need to type in the "
dongsheng@627 14944 "entire name of a patch when you want to identify it by name."
dongsheng@627 14945 msgstr ""
dongsheng@627 14946
dongsheng@627 14947 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 14948 #: ../en/ch11-mq.xml:957
dongsheng@627 14949 msgid ""
dongsheng@627 14950 "Another nice consequence of representing patch names as tags is that when you "
dongsheng@627 14951 "run the <command role=\"hg-cmd\">hg log</command> command, it will display a "
dongsheng@627 14952 "patch's name as a tag, simply as part of its normal output. This makes it "
dongsheng@627 14953 "easy to visually distinguish applied patches from underlying <quote>normal</"
dongsheng@627 14954 "quote> revisions. The following example shows a few normal Mercurial "
dongsheng@627 14955 "commands in use with applied patches."
dongsheng@627 14956 msgstr ""
dongsheng@627 14957
dongsheng@627 14958 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@658 14959 #: ../en/ch11-mq.xml:970
dongsheng@627 14960 msgid "Useful things to know about"
dongsheng@636 14961 msgstr "其它需要了解的东西"
dongsheng@627 14962
dongsheng@627 14963 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 14964 #: ../en/ch11-mq.xml:972
dongsheng@627 14965 msgid ""
dongsheng@627 14966 "There are a number of aspects of MQ usage that don't fit tidily into sections "
dongsheng@627 14967 "of their own, but that are good to know. Here they are, in one place."
dongsheng@627 14968 msgstr ""
dongsheng@627 14969
dongsheng@627 14970 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 14971 #: ../en/ch11-mq.xml:977
dongsheng@627 14972 msgid ""
dongsheng@627 14973 "Normally, when you <command role=\"hg-ext-mq\">qpop</command> a patch and "
dongsheng@627 14974 "<command role=\"hg-ext-mq\">qpush</command> it again, the changeset that "
dongsheng@627 14975 "represents the patch after the pop/push will have a <emphasis>different "
dongsheng@627 14976 "identity</emphasis> than the changeset that represented the hash beforehand. "
songdongsheng@658 14977 "See <xref linkend=\"sec:mqref:cmd:qpush\"/> for information as to why this is."
dongsheng@627 14978 msgstr ""
dongsheng@627 14979
dongsheng@627 14980 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 14981 #: ../en/ch11-mq.xml:986
dongsheng@627 14982 msgid ""
dongsheng@627 14983 "It's not a good idea to <command role=\"hg-cmd\">hg merge</command> changes "
dongsheng@627 14984 "from another branch with a patch changeset, at least if you want to maintain "
dongsheng@627 14985 "the <quote>patchiness</quote> of that changeset and changesets below it on "
dongsheng@627 14986 "the patch stack. If you try to do this, it will appear to succeed, but MQ "
dongsheng@627 14987 "will become confused."
dongsheng@627 14988 msgstr ""
dongsheng@627 14989
dongsheng@627 14990 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@658 14991 #: ../en/ch11-mq.xml:997
dongsheng@627 14992 msgid "Managing patches in a repository"
dongsheng@636 14993 msgstr "在版本库管理补丁"
dongsheng@627 14994
dongsheng@627 14995 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 14996 #: ../en/ch11-mq.xml:999
dongsheng@627 14997 msgid ""
dongsheng@627 14998 "Because MQ's <filename role=\"special\" class=\"directory\">.hg/patches</"
dongsheng@627 14999 "filename> directory resides outside a Mercurial repository's working "
dongsheng@627 15000 "directory, the <quote>underlying</quote> Mercurial repository knows nothing "
dongsheng@627 15001 "about the management or presence of patches."
dongsheng@627 15002 msgstr ""
dongsheng@627 15003
dongsheng@627 15004 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 15005 #: ../en/ch11-mq.xml:1005
dongsheng@627 15006 msgid ""
dongsheng@627 15007 "This presents the interesting possibility of managing the contents of the "
dongsheng@627 15008 "patch directory as a Mercurial repository in its own right. This can be a "
dongsheng@627 15009 "useful way to work. For example, you can work on a patch for a while, "
dongsheng@627 15010 "<command role=\"hg-ext-mq\">qrefresh</command> it, then <command role=\"hg-cmd"
dongsheng@627 15011 "\">hg commit</command> the current state of the patch. This lets you "
dongsheng@627 15012 "<quote>roll back</quote> to that version of the patch later on."
dongsheng@627 15013 msgstr ""
dongsheng@627 15014
dongsheng@627 15015 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 15016 #: ../en/ch11-mq.xml:1014
dongsheng@627 15017 msgid ""
dongsheng@627 15018 "You can then share different versions of the same patch stack among multiple "
dongsheng@627 15019 "underlying repositories. I use this when I am developing a Linux kernel "
dongsheng@627 15020 "feature. I have a pristine copy of my kernel sources for each of several CPU "
dongsheng@627 15021 "architectures, and a cloned repository under each that contains the patches I "
dongsheng@627 15022 "am working on. When I want to test a change on a different architecture, I "
dongsheng@627 15023 "push my current patches to the patch repository associated with that kernel "
dongsheng@627 15024 "tree, pop and push all of my patches, and build and test that kernel."
dongsheng@627 15025 msgstr ""
dongsheng@627 15026
dongsheng@627 15027 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 15028 #: ../en/ch11-mq.xml:1024
dongsheng@627 15029 msgid ""
dongsheng@627 15030 "Managing patches in a repository makes it possible for multiple developers to "
dongsheng@627 15031 "work on the same patch series without colliding with each other, all on top "
dongsheng@627 15032 "of an underlying source base that they may or may not control."
dongsheng@627 15033 msgstr ""
dongsheng@627 15034
dongsheng@627 15035 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 15036 #: ../en/ch11-mq.xml:1030
dongsheng@627 15037 msgid "MQ support for patch repositories"
dongsheng@636 15038 msgstr "MQ 支持补丁版本库"
dongsheng@627 15039
dongsheng@627 15040 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 15041 #: ../en/ch11-mq.xml:1032
dongsheng@627 15042 msgid ""
dongsheng@627 15043 "MQ helps you to work with the <filename role=\"special\" class=\"directory\">."
dongsheng@627 15044 "hg/patches</filename> directory as a repository; when you prepare a "
dongsheng@627 15045 "repository for working with patches using <command role=\"hg-ext-mq\">qinit</"
dongsheng@627 15046 "command>, you can pass the <option role=\"hg-ext-mq-cmd-qinit-opt\">hg -c</"
dongsheng@627 15047 "option> option to create the <filename role=\"special\" class=\"directory\">."
dongsheng@627 15048 "hg/patches</filename> directory as a Mercurial repository."
dongsheng@627 15049 msgstr ""
dongsheng@627 15050
dongsheng@627 15051 #. type: Content of: <book><chapter><sect1><sect2><note><para>
songdongsheng@658 15052 #: ../en/ch11-mq.xml:1042
dongsheng@627 15053 msgid ""
dongsheng@627 15054 "If you forget to use the <option role=\"hg-ext-mq-cmd-qinit-opt\">hg -c</"
dongsheng@627 15055 "option> option, you can simply go into the <filename role=\"special\" class="
dongsheng@627 15056 "\"directory\">.hg/patches</filename> directory at any time and run <command "
dongsheng@627 15057 "role=\"hg-cmd\">hg init</command>. Don't forget to add an entry for the "
dongsheng@627 15058 "<filename role=\"special\">status</filename> file to the <filename role="
dongsheng@627 15059 "\"special\">.hgignore</filename> file, though"
dongsheng@627 15060 msgstr ""
dongsheng@627 15061
dongsheng@627 15062 #. type: Content of: <book><chapter><sect1><sect2><note><para>
songdongsheng@658 15063 #: ../en/ch11-mq.xml:1051
dongsheng@627 15064 msgid ""
dongsheng@627 15065 "(<command role=\"hg-cmd\">hg qinit <option role=\"hg-ext-mq-cmd-qinit-opt"
dongsheng@627 15066 "\">hg -c</option></command> does this for you automatically); you "
dongsheng@627 15067 "<emphasis>really</emphasis> don't want to manage the <filename role=\"special"
dongsheng@627 15068 "\">status</filename> file."
dongsheng@627 15069 msgstr ""
dongsheng@627 15070
dongsheng@627 15071 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 15072 #: ../en/ch11-mq.xml:1058
dongsheng@627 15073 msgid ""
dongsheng@627 15074 "As a convenience, if MQ notices that the <filename class=\"directory\">.hg/"
dongsheng@627 15075 "patches</filename> directory is a repository, it will automatically <command "
dongsheng@627 15076 "role=\"hg-cmd\">hg add</command> every patch that you create and import."
dongsheng@627 15077 msgstr ""
dongsheng@627 15078
dongsheng@627 15079 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 15080 #: ../en/ch11-mq.xml:1063
dongsheng@627 15081 msgid ""
dongsheng@627 15082 "MQ provides a shortcut command, <command role=\"hg-ext-mq\">qcommit</"
dongsheng@627 15083 "command>, that runs <command role=\"hg-cmd\">hg commit</command> in the "
dongsheng@627 15084 "<filename role=\"special\" class=\"directory\">.hg/patches</filename> "
dongsheng@627 15085 "directory. This saves some bothersome typing."
dongsheng@627 15086 msgstr ""
dongsheng@627 15087
dongsheng@627 15088 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 15089 #: ../en/ch11-mq.xml:1069
dongsheng@627 15090 msgid ""
dongsheng@627 15091 "Finally, as a convenience to manage the patch directory, you can define the "
dongsheng@627 15092 "alias <command>mq</command> on Unix systems. For example, on Linux systems "
dongsheng@627 15093 "using the <command>bash</command> shell, you can include the following "
dongsheng@627 15094 "snippet in your <filename role=\"home\">~/.bashrc</filename>."
dongsheng@627 15095 msgstr ""
dongsheng@627 15096
dongsheng@627 15097 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 15098 #: ../en/ch11-mq.xml:1078
dongsheng@627 15099 msgid ""
dongsheng@627 15100 "You can then issue commands of the form <command>mq pull</command> from the "
dongsheng@627 15101 "main repository."
dongsheng@627 15102 msgstr ""
dongsheng@627 15103
dongsheng@627 15104 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 15105 #: ../en/ch11-mq.xml:1083
dongsheng@627 15106 msgid "A few things to watch out for"
dongsheng@636 15107 msgstr "需要注意的事情"
dongsheng@627 15108
dongsheng@627 15109 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 15110 #: ../en/ch11-mq.xml:1085
dongsheng@627 15111 msgid ""
dongsheng@627 15112 "MQ's support for working with a repository full of patches is limited in a "
dongsheng@627 15113 "few small respects."
dongsheng@627 15114 msgstr ""
dongsheng@627 15115
dongsheng@627 15116 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 15117 #: ../en/ch11-mq.xml:1088
dongsheng@627 15118 msgid ""
dongsheng@627 15119 "MQ cannot automatically detect changes that you make to the patch directory. "
dongsheng@627 15120 "If you <command role=\"hg-cmd\">hg pull</command>, manually edit, or <command "
dongsheng@627 15121 "role=\"hg-cmd\">hg update</command> changes to patches or the <filename role="
dongsheng@627 15122 "\"special\">series</filename> file, you will have to <command role=\"hg-cmd"
dongsheng@627 15123 "\">hg qpop <option role=\"hg-ext-mq-cmd-qpop-opt\">hg -a</option></command> "
dongsheng@627 15124 "and then <command role=\"hg-cmd\">hg qpush <option role=\"hg-ext-mq-cmd-qpush-"
dongsheng@627 15125 "opt\">hg -a</option></command> in the underlying repository to see those "
dongsheng@627 15126 "changes show up there. If you forget to do this, you can confuse MQ's idea "
dongsheng@627 15127 "of which patches are applied."
dongsheng@627 15128 msgstr ""
dongsheng@627 15129
dongsheng@627 15130 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@658 15131 #: ../en/ch11-mq.xml:1104
dongsheng@627 15132 msgid "Third party tools for working with patches"
dongsheng@636 15133 msgstr "操作补丁的第三方工具"
dongsheng@627 15134
dongsheng@627 15135 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 15136 #: ../en/ch11-mq.xml:1106
dongsheng@627 15137 msgid ""
dongsheng@627 15138 "Once you've been working with patches for a while, you'll find yourself "
dongsheng@627 15139 "hungry for tools that will help you to understand and manipulate the patches "
dongsheng@627 15140 "you're dealing with."
dongsheng@627 15141 msgstr ""
dongsheng@627 15142
dongsheng@627 15143 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 15144 #: ../en/ch11-mq.xml:1110
dongsheng@627 15145 msgid ""
dongsheng@627 15146 "The <command>diffstat</command> command <citation>web:diffstat</citation> "
dongsheng@627 15147 "generates a histogram of the modifications made to each file in a patch. It "
songdongsheng@668 15148 "provides a good way to <quote>get a sense of</quote> a patch&emdash;which "
songdongsheng@668 15149 "files it affects, and how much change it introduces to each file and as a "
songdongsheng@668 15150 "whole. (I find that it's a good idea to use <command>diffstat</command>'s "
songdongsheng@668 15151 "<option role=\"cmd-opt-diffstat\">-p</option> option as a matter of course, "
songdongsheng@668 15152 "as otherwise it will try to do clever things with prefixes of file names that "
songdongsheng@668 15153 "inevitably confuse at least me.)"
dongsheng@627 15154 msgstr ""
dongsheng@627 15155
dongsheng@627 15156 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 15157 #: ../en/ch11-mq.xml:1124
dongsheng@627 15158 msgid ""
dongsheng@627 15159 "The <literal role=\"package\">patchutils</literal> package <citation>web:"
dongsheng@627 15160 "patchutils</citation> is invaluable. It provides a set of small utilities "
dongsheng@627 15161 "that follow the <quote>Unix philosophy;</quote> each does one useful thing "
dongsheng@627 15162 "with a patch. The <literal role=\"package\">patchutils</literal> command I "
dongsheng@627 15163 "use most is <command>filterdiff</command>, which extracts subsets from a "
dongsheng@627 15164 "patch file. For example, given a patch that modifies hundreds of files "
dongsheng@627 15165 "across dozens of directories, a single invocation of <command>filterdiff</"
dongsheng@627 15166 "command> can generate a smaller patch that only touches files whose names "
songdongsheng@658 15167 "match a particular glob pattern. See <xref linkend=\"mq-collab:tips:interdiff"
songdongsheng@658 15168 "\"/> for another example."
dongsheng@627 15169 msgstr ""
dongsheng@627 15170
dongsheng@627 15171 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@658 15172 #: ../en/ch11-mq.xml:1140
dongsheng@627 15173 msgid "Good ways to work with patches"
dongsheng@636 15174 msgstr "操作补丁的好习惯"
dongsheng@627 15175
dongsheng@627 15176 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 15177 #: ../en/ch11-mq.xml:1142
dongsheng@627 15178 msgid ""
dongsheng@627 15179 "Whether you are working on a patch series to submit to a free software or "
dongsheng@627 15180 "open source project, or a series that you intend to treat as a sequence of "
dongsheng@627 15181 "regular changesets when you're done, you can use some simple techniques to "
songdongsheng@710 15182 "keep your work well organized."
dongsheng@627 15183 msgstr ""
dongsheng@627 15184
dongsheng@627 15185 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 15186 #: ../en/ch11-mq.xml:1148
dongsheng@627 15187 msgid ""
dongsheng@627 15188 "Give your patches descriptive names. A good name for a patch might be "
dongsheng@627 15189 "<filename>rework-device-alloc.patch</filename>, because it will immediately "
dongsheng@627 15190 "give you a hint what the purpose of the patch is. Long names shouldn't be a "
dongsheng@627 15191 "problem; you won't be typing the names often, but you <emphasis>will</"
dongsheng@627 15192 "emphasis> be running commands like <command role=\"hg-ext-mq\">qapplied</"
dongsheng@627 15193 "command> and <command role=\"hg-ext-mq\">qtop</command> over and over. Good "
dongsheng@627 15194 "naming becomes especially important when you have a number of patches to work "
dongsheng@627 15195 "with, or if you are juggling a number of different tasks and your patches "
dongsheng@627 15196 "only get a fraction of your attention."
dongsheng@627 15197 msgstr ""
dongsheng@627 15198
dongsheng@627 15199 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 15200 #: ../en/ch11-mq.xml:1160
dongsheng@627 15201 msgid ""
dongsheng@627 15202 "Be aware of what patch you're working on. Use the <command role=\"hg-ext-mq"
songdongsheng@668 15203 "\">qtop</command> command and skim over the text of your patches "
songdongsheng@668 15204 "frequently&emdash;for example, using <command role=\"hg-cmd\">hg tip <option "
songdongsheng@668 15205 "role=\"hg-opt-tip\">-p</option></command>)&emdash;to be sure of where you "
songdongsheng@668 15206 "stand. I have several times worked on and <command role=\"hg-ext-mq"
songdongsheng@668 15207 "\">qrefresh</command>ed a patch other than the one I intended, and it's often "
songdongsheng@668 15208 "tricky to migrate changes into the right patch after making them in the wrong "
songdongsheng@668 15209 "one."
dongsheng@627 15210 msgstr ""
dongsheng@627 15211
dongsheng@627 15212 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 15213 #: ../en/ch11-mq.xml:1170
dongsheng@627 15214 msgid ""
dongsheng@627 15215 "For this reason, it is very much worth investing a little time to learn how "
songdongsheng@658 15216 "to use some of the third-party tools I described in <xref linkend=\"sec:mq:"
songdongsheng@658 15217 "tools\"/>, particularly <command>diffstat</command> and <command>filterdiff</"
songdongsheng@658 15218 "command>. The former will give you a quick idea of what changes your patch "
songdongsheng@658 15219 "is making, while the latter makes it easy to splice hunks selectively out of "
songdongsheng@658 15220 "one patch and into another."
dongsheng@627 15221 msgstr ""
dongsheng@627 15222
dongsheng@627 15223 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@658 15224 #: ../en/ch11-mq.xml:1181
dongsheng@627 15225 msgid "MQ cookbook"
dongsheng@636 15226 msgstr "MQ 手册"
dongsheng@627 15227
dongsheng@627 15228 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 15229 #: ../en/ch11-mq.xml:1184
dongsheng@627 15230 msgid "Manage <quote>trivial</quote> patches"
dongsheng@636 15231 msgstr "管理<quote>琐碎的</quote>补丁"
dongsheng@627 15232
dongsheng@627 15233 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 15234 #: ../en/ch11-mq.xml:1186
dongsheng@627 15235 msgid ""
dongsheng@627 15236 "Because the overhead of dropping files into a new Mercurial repository is so "
dongsheng@627 15237 "low, it makes a lot of sense to manage patches this way even if you simply "
dongsheng@627 15238 "want to make a few changes to a source tarball that you downloaded."
dongsheng@627 15239 msgstr ""
dongsheng@627 15240
dongsheng@627 15241 #
dongsheng@627 15242 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 15243 #: ../en/ch11-mq.xml:1191
dongsheng@627 15244 msgid ""
dongsheng@627 15245 "Begin by downloading and unpacking the source tarball, and turning it into a "
dongsheng@627 15246 "Mercurial repository."
dongsheng@627 15247 msgstr ""
dongsheng@627 15248
dongsheng@627 15249 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 15250 #: ../en/ch11-mq.xml:1196
dongsheng@627 15251 msgid "Continue by creating a patch stack and making your changes."
dongsheng@627 15252 msgstr ""
dongsheng@627 15253
dongsheng@627 15254 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 15255 #: ../en/ch11-mq.xml:1201
dongsheng@627 15256 msgid ""
dongsheng@627 15257 "Let's say a few weeks or months pass, and your package author releases a new "
dongsheng@627 15258 "version. First, bring their changes into the repository."
dongsheng@627 15259 msgstr ""
dongsheng@627 15260
dongsheng@627 15261 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 15262 #: ../en/ch11-mq.xml:1207
dongsheng@627 15263 msgid ""
dongsheng@627 15264 "The pipeline starting with <command role=\"hg-cmd\">hg locate</command> above "
dongsheng@627 15265 "deletes all files in the working directory, so that <command role=\"hg-cmd"
dongsheng@627 15266 "\">hg commit</command>'s <option role=\"hg-opt-commit\">--addremove</option> "
dongsheng@627 15267 "option can actually tell which files have really been removed in the newer "
dongsheng@627 15268 "version of the source."
dongsheng@627 15269 msgstr ""
dongsheng@627 15270
dongsheng@627 15271 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 15272 #: ../en/ch11-mq.xml:1215
dongsheng@627 15273 msgid "Finally, you can apply your patches on top of the new tree."
dongsheng@627 15274 msgstr ""
dongsheng@627 15275
dongsheng@627 15276 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 15277 #: ../en/ch11-mq.xml:1222
dongsheng@627 15278 msgid "Combining entire patches"
dongsheng@636 15279 msgstr "组合全部的补丁"
dongsheng@627 15280
dongsheng@627 15281 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 15282 #: ../en/ch11-mq.xml:1224
dongsheng@627 15283 msgid ""
dongsheng@627 15284 "MQ provides a command, <command role=\"hg-ext-mq\">qfold</command> that lets "
dongsheng@627 15285 "you combine entire patches. This <quote>folds</quote> the patches you name, "
dongsheng@627 15286 "in the order you name them, into the topmost applied patch, and concatenates "
dongsheng@627 15287 "their descriptions onto the end of its description. The patches that you "
dongsheng@627 15288 "fold must be unapplied before you fold them."
dongsheng@627 15289 msgstr ""
dongsheng@627 15290
dongsheng@627 15291 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 15292 #: ../en/ch11-mq.xml:1232
dongsheng@627 15293 msgid ""
dongsheng@627 15294 "The order in which you fold patches matters. If your topmost applied patch "
dongsheng@627 15295 "is <literal>foo</literal>, and you <command role=\"hg-ext-mq\">qfold</"
dongsheng@627 15296 "command> <literal>bar</literal> and <literal>quux</literal> into it, you will "
dongsheng@627 15297 "end up with a patch that has the same effect as if you applied first "
dongsheng@627 15298 "<literal>foo</literal>, then <literal>bar</literal>, followed by "
dongsheng@627 15299 "<literal>quux</literal>."
dongsheng@627 15300 msgstr ""
dongsheng@627 15301
dongsheng@627 15302 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 15303 #: ../en/ch11-mq.xml:1243
dongsheng@627 15304 msgid "Merging part of one patch into another"
dongsheng@636 15305 msgstr "合并补丁的部分内容到其它补丁"
dongsheng@627 15306
dongsheng@627 15307 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 15308 #: ../en/ch11-mq.xml:1245
dongsheng@627 15309 msgid ""
dongsheng@627 15310 "Merging <emphasis>part</emphasis> of one patch into another is more difficult "
dongsheng@627 15311 "than combining entire patches."
dongsheng@627 15312 msgstr ""
dongsheng@627 15313
dongsheng@627 15314 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 15315 #: ../en/ch11-mq.xml:1249
dongsheng@627 15316 msgid ""
dongsheng@627 15317 "If you want to move changes to entire files, you can use <command>filterdiff</"
dongsheng@627 15318 "command>'s <option role=\"cmd-opt-filterdiff\">-i</option> and <option role="
dongsheng@627 15319 "\"cmd-opt-filterdiff\">-x</option> options to choose the modifications to "
dongsheng@627 15320 "snip out of one patch, concatenating its output onto the end of the patch you "
dongsheng@627 15321 "want to merge into. You usually won't need to modify the patch you've merged "
dongsheng@627 15322 "the changes from. Instead, MQ will report some rejected hunks when you "
dongsheng@627 15323 "<command role=\"hg-ext-mq\">qpush</command> it (from the hunks you moved into "
dongsheng@627 15324 "the other patch), and you can simply <command role=\"hg-ext-mq\">qrefresh</"
dongsheng@627 15325 "command> the patch to drop the duplicate hunks."
dongsheng@627 15326 msgstr ""
dongsheng@627 15327
dongsheng@627 15328 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 15329 #: ../en/ch11-mq.xml:1262
dongsheng@627 15330 msgid ""
dongsheng@627 15331 "If you have a patch that has multiple hunks modifying a file, and you only "
dongsheng@627 15332 "want to move a few of those hunks, the job becomes more messy, but you can "
dongsheng@627 15333 "still partly automate it. Use <command>lsdiff -nvv</command> to print some "
dongsheng@627 15334 "metadata about the patch."
dongsheng@627 15335 msgstr ""
dongsheng@627 15336
dongsheng@627 15337 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 15338 #: ../en/ch11-mq.xml:1270
dongsheng@627 15339 msgid "This command prints three different kinds of number:"
dongsheng@627 15340 msgstr ""
dongsheng@627 15341
dongsheng@627 15342 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 15343 #: ../en/ch11-mq.xml:1273
dongsheng@627 15344 msgid ""
dongsheng@627 15345 "(in the first column) a <emphasis>file number</emphasis> to identify each "
dongsheng@627 15346 "file modified in the patch;"
dongsheng@627 15347 msgstr ""
dongsheng@627 15348
dongsheng@627 15349 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 15350 #: ../en/ch11-mq.xml:1277
dongsheng@627 15351 msgid ""
dongsheng@627 15352 "(on the next line, indented) the line number within a modified file where a "
dongsheng@627 15353 "hunk starts; and"
dongsheng@627 15354 msgstr ""
dongsheng@627 15355
dongsheng@627 15356 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 15357 #: ../en/ch11-mq.xml:1280
dongsheng@627 15358 msgid ""
dongsheng@627 15359 "(on the same line) a <emphasis>hunk number</emphasis> to identify that hunk."
dongsheng@627 15360 msgstr ""
dongsheng@627 15361
dongsheng@627 15362 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 15363 #: ../en/ch11-mq.xml:1284
dongsheng@627 15364 msgid ""
dongsheng@627 15365 "You'll have to use some visual inspection, and reading of the patch, to "
dongsheng@627 15366 "identify the file and hunk numbers you'll want, but you can then pass them to "
dongsheng@627 15367 "to <command>filterdiff</command>'s <option role=\"cmd-opt-filterdiff\">--"
dongsheng@627 15368 "files</option> and <option role=\"cmd-opt-filterdiff\">--hunks</option> "
dongsheng@627 15369 "options, to select exactly the file and hunk you want to extract."
dongsheng@627 15370 msgstr ""
dongsheng@627 15371
dongsheng@627 15372 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 15373 #: ../en/ch11-mq.xml:1292
dongsheng@627 15374 msgid ""
dongsheng@627 15375 "Once you have this hunk, you can concatenate it onto the end of your "
songdongsheng@658 15376 "destination patch and continue with the remainder of <xref linkend=\"sec:mq:"
songdongsheng@658 15377 "combine\"/>."
dongsheng@627 15378 msgstr ""
dongsheng@627 15379
dongsheng@627 15380 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@658 15381 #: ../en/ch11-mq.xml:1299
dongsheng@627 15382 msgid "Differences between quilt and MQ"
dongsheng@636 15383 msgstr "MQ 与 quilt 的区别"
dongsheng@627 15384
dongsheng@627 15385 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 15386 #: ../en/ch11-mq.xml:1301
dongsheng@627 15387 msgid ""
dongsheng@627 15388 "If you are already familiar with quilt, MQ provides a similar command set. "
dongsheng@627 15389 "There are a few differences in the way that it works."
dongsheng@627 15390 msgstr ""
dongsheng@627 15391
dongsheng@627 15392 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 15393 #: ../en/ch11-mq.xml:1305
dongsheng@627 15394 msgid ""
dongsheng@627 15395 "You will already have noticed that most quilt commands have MQ counterparts "
dongsheng@627 15396 "that simply begin with a <quote><literal>q</literal></quote>. The exceptions "
dongsheng@627 15397 "are quilt's <literal>add</literal> and <literal>remove</literal> commands, "
dongsheng@627 15398 "the counterparts for which are the normal Mercurial <command role=\"hg-cmd"
dongsheng@627 15399 "\">hg add</command> and <command role=\"hg-cmd\">hg remove</command> "
dongsheng@627 15400 "commands. There is no MQ equivalent of the quilt <literal>edit</literal> "
dongsheng@627 15401 "command."
dongsheng@627 15402 msgstr ""
dongsheng@627 15403
dongsheng@627 15404 #. type: Content of: <book><chapter><title>
dongsheng@650 15405 #: ../en/ch12-mq-collab.xml:5
dongsheng@627 15406 msgid "Advanced uses of Mercurial Queues"
dongsheng@627 15407 msgstr "MQ 的高级用法"
dongsheng@627 15408
dongsheng@627 15409 #. type: Content of: <book><chapter><para>
dongsheng@650 15410 #: ../en/ch12-mq-collab.xml:7
dongsheng@627 15411 msgid ""
dongsheng@627 15412 "While it's easy to pick up straightforward uses of Mercurial Queues, use of a "
dongsheng@627 15413 "little discipline and some of MQ's less frequently used capabilities makes it "
dongsheng@627 15414 "possible to work in complicated development environments."
dongsheng@627 15415 msgstr ""
dongsheng@627 15416
dongsheng@627 15417 #. type: Content of: <book><chapter><para>
dongsheng@650 15418 #: ../en/ch12-mq-collab.xml:12
dongsheng@627 15419 msgid ""
dongsheng@627 15420 "In this chapter, I will use as an example a technique I have used to manage "
dongsheng@627 15421 "the development of an Infiniband device driver for the Linux kernel. The "
dongsheng@627 15422 "driver in question is large (at least as drivers go), with 25,000 lines of "
dongsheng@627 15423 "code spread across 35 source files. It is maintained by a small team of "
dongsheng@627 15424 "developers."
dongsheng@627 15425 msgstr ""
dongsheng@627 15426
dongsheng@627 15427 #. type: Content of: <book><chapter><para>
dongsheng@650 15428 #: ../en/ch12-mq-collab.xml:18
dongsheng@627 15429 msgid ""
dongsheng@627 15430 "While much of the material in this chapter is specific to Linux, the same "
dongsheng@627 15431 "principles apply to any code base for which you're not the primary owner, and "
dongsheng@627 15432 "upon which you need to do a lot of development."
dongsheng@627 15433 msgstr ""
dongsheng@627 15434
dongsheng@627 15435 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 15436 #: ../en/ch12-mq-collab.xml:24
dongsheng@627 15437 msgid "The problem of many targets"
dongsheng@636 15438 msgstr "多个目标的问题"
dongsheng@627 15439
dongsheng@627 15440 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 15441 #: ../en/ch12-mq-collab.xml:26
dongsheng@627 15442 msgid ""
dongsheng@627 15443 "The Linux kernel changes rapidly, and has never been internally stable; "
dongsheng@627 15444 "developers frequently make drastic changes between releases. This means that "
dongsheng@627 15445 "a version of the driver that works well with a particular released version of "
dongsheng@627 15446 "the kernel will not even <emphasis>compile</emphasis> correctly against, "
dongsheng@627 15447 "typically, any other version."
dongsheng@627 15448 msgstr ""
dongsheng@627 15449
dongsheng@627 15450 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 15451 #: ../en/ch12-mq-collab.xml:33
dongsheng@627 15452 msgid ""
dongsheng@627 15453 "To maintain a driver, we have to keep a number of distinct versions of Linux "
dongsheng@627 15454 "in mind."
dongsheng@627 15455 msgstr ""
dongsheng@627 15456
dongsheng@627 15457 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 15458 #: ../en/ch12-mq-collab.xml:36
dongsheng@627 15459 msgid ""
dongsheng@627 15460 "One target is the main Linux kernel development tree. Maintenance of the code "
dongsheng@627 15461 "is in this case partly shared by other developers in the kernel community, "
dongsheng@627 15462 "who make <quote>drive-by</quote> modifications to the driver as they develop "
dongsheng@627 15463 "and refine kernel subsystems."
dongsheng@627 15464 msgstr ""
dongsheng@627 15465
dongsheng@627 15466 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 15467 #: ../en/ch12-mq-collab.xml:42
dongsheng@627 15468 msgid ""
dongsheng@627 15469 "We also maintain a number of <quote>backports</quote> to older versions of "
dongsheng@627 15470 "the Linux kernel, to support the needs of customers who are running older "
dongsheng@627 15471 "Linux distributions that do not incorporate our drivers. (To "
dongsheng@627 15472 "<emphasis>backport</emphasis> a piece of code is to modify it to work in an "
dongsheng@627 15473 "older version of its target environment than the version it was developed "
dongsheng@627 15474 "for.)"
dongsheng@627 15475 msgstr ""
dongsheng@627 15476
dongsheng@627 15477 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 15478 #: ../en/ch12-mq-collab.xml:50
dongsheng@627 15479 msgid ""
dongsheng@627 15480 "Finally, we make software releases on a schedule that is necessarily not "
dongsheng@627 15481 "aligned with those used by Linux distributors and kernel developers, so that "
dongsheng@627 15482 "we can deliver new features to customers without forcing them to upgrade "
dongsheng@627 15483 "their entire kernels or distributions."
dongsheng@627 15484 msgstr ""
dongsheng@627 15485
dongsheng@627 15486 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 15487 #: ../en/ch12-mq-collab.xml:58
dongsheng@627 15488 msgid "Tempting approaches that don't work well"
dongsheng@636 15489 msgstr "工作不好的诱人方法"
dongsheng@627 15490
dongsheng@627 15491 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 15492 #: ../en/ch12-mq-collab.xml:60
dongsheng@627 15493 msgid ""
dongsheng@627 15494 "There are two <quote>standard</quote> ways to maintain a piece of software "
dongsheng@627 15495 "that has to target many different environments."
dongsheng@627 15496 msgstr ""
dongsheng@627 15497
dongsheng@627 15498 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 15499 #: ../en/ch12-mq-collab.xml:64
dongsheng@627 15500 msgid ""
dongsheng@627 15501 "The first is to maintain a number of branches, each intended for a single "
dongsheng@627 15502 "target. The trouble with this approach is that you must maintain iron "
dongsheng@627 15503 "discipline in the flow of changes between repositories. A new feature or bug "
dongsheng@627 15504 "fix must start life in a <quote>pristine</quote> repository, then percolate "
dongsheng@627 15505 "out to every backport repository. Backport changes are more limited in the "
dongsheng@627 15506 "branches they should propagate to; a backport change that is applied to a "
dongsheng@627 15507 "branch where it doesn't belong will probably stop the driver from compiling."
dongsheng@627 15508 msgstr ""
dongsheng@627 15509
dongsheng@627 15510 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 15511 #: ../en/ch12-mq-collab.xml:74
dongsheng@627 15512 msgid ""
dongsheng@627 15513 "The second is to maintain a single source tree filled with conditional "
dongsheng@627 15514 "statements that turn chunks of code on or off depending on the intended "
dongsheng@627 15515 "target. Because these <quote>ifdefs</quote> are not allowed in the Linux "
dongsheng@627 15516 "kernel tree, a manual or automatic process must be followed to strip them out "
dongsheng@627 15517 "and yield a clean tree. A code base maintained in this fashion rapidly "
dongsheng@627 15518 "becomes a rat's nest of conditional blocks that are difficult to understand "
dongsheng@627 15519 "and maintain."
dongsheng@627 15520 msgstr ""
dongsheng@627 15521
dongsheng@627 15522 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 15523 #: ../en/ch12-mq-collab.xml:83
dongsheng@627 15524 msgid ""
dongsheng@627 15525 "Neither of these approaches is well suited to a situation where you don't "
dongsheng@627 15526 "<quote>own</quote> the canonical copy of a source tree. In the case of a "
dongsheng@627 15527 "Linux driver that is distributed with the standard kernel, Linus's tree "
dongsheng@627 15528 "contains the copy of the code that will be treated by the world as "
dongsheng@627 15529 "canonical. The upstream version of <quote>my</quote> driver can be modified "
dongsheng@627 15530 "by people I don't know, without me even finding out about it until after the "
dongsheng@627 15531 "changes show up in Linus's tree."
dongsheng@627 15532 msgstr ""
dongsheng@627 15533
dongsheng@627 15534 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 15535 #: ../en/ch12-mq-collab.xml:93
dongsheng@627 15536 msgid ""
dongsheng@627 15537 "These approaches have the added weakness of making it difficult to generate "
dongsheng@627 15538 "well-formed patches to submit upstream."
dongsheng@627 15539 msgstr ""
dongsheng@627 15540
dongsheng@627 15541 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 15542 #: ../en/ch12-mq-collab.xml:97
dongsheng@627 15543 msgid ""
dongsheng@627 15544 "In principle, Mercurial Queues seems like a good candidate to manage a "
dongsheng@627 15545 "development scenario such as the above. While this is indeed the case, MQ "
dongsheng@627 15546 "contains a few added features that make the job more pleasant."
dongsheng@627 15547 msgstr ""
dongsheng@627 15548
dongsheng@627 15549 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 15550 #: ../en/ch12-mq-collab.xml:105
dongsheng@627 15551 msgid "Conditionally applying patches with guards"
dongsheng@636 15552 msgstr "有条件的应用补丁"
dongsheng@627 15553
dongsheng@627 15554 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 15555 #: ../en/ch12-mq-collab.xml:107
dongsheng@627 15556 msgid ""
dongsheng@627 15557 "Perhaps the best way to maintain sanity with so many targets is to be able to "
dongsheng@627 15558 "choose specific patches to apply for a given situation. MQ provides a "
dongsheng@627 15559 "feature called <quote>guards</quote> (which originates with quilt's "
dongsheng@627 15560 "<literal>guards</literal> command) that does just this. To start off, let's "
dongsheng@627 15561 "create a simple repository for experimenting in."
dongsheng@627 15562 msgstr ""
dongsheng@627 15563
dongsheng@627 15564 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 15565 #: ../en/ch12-mq-collab.xml:116
dongsheng@627 15566 msgid ""
dongsheng@627 15567 "This gives us a tiny repository that contains two patches that don't have any "
dongsheng@627 15568 "dependencies on each other, because they touch different files."
dongsheng@627 15569 msgstr ""
dongsheng@627 15570
dongsheng@627 15571 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 15572 #: ../en/ch12-mq-collab.xml:120
dongsheng@627 15573 msgid ""
dongsheng@627 15574 "The idea behind conditional application is that you can <quote>tag</quote> a "
dongsheng@627 15575 "patch with a <emphasis>guard</emphasis>, which is simply a text string of "
dongsheng@627 15576 "your choosing, then tell MQ to select specific guards to use when applying "
dongsheng@627 15577 "patches. MQ will then either apply, or skip over, a guarded patch, depending "
dongsheng@627 15578 "on the guards that you have selected."
dongsheng@627 15579 msgstr ""
dongsheng@627 15580
dongsheng@627 15581 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 15582 #: ../en/ch12-mq-collab.xml:127
dongsheng@627 15583 msgid ""
dongsheng@627 15584 "A patch can have an arbitrary number of guards; each one is "
dongsheng@627 15585 "<emphasis>positive</emphasis> (<quote>apply this patch if this guard is "
dongsheng@627 15586 "selected</quote>) or <emphasis>negative</emphasis> (<quote>skip this patch if "
dongsheng@627 15587 "this guard is selected</quote>). A patch with no guards is always applied."
dongsheng@627 15588 msgstr ""
dongsheng@627 15589
dongsheng@627 15590 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 15591 #: ../en/ch12-mq-collab.xml:135
dongsheng@627 15592 msgid "Controlling the guards on a patch"
dongsheng@636 15593 msgstr "控制补丁的应用条件"
dongsheng@627 15594
dongsheng@627 15595 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 15596 #: ../en/ch12-mq-collab.xml:137
dongsheng@627 15597 msgid ""
dongsheng@627 15598 "The <command role=\"hg-ext-mq\">qguard</command> command lets you determine "
dongsheng@627 15599 "which guards should apply to a patch, or display the guards that are already "
dongsheng@627 15600 "in effect. Without any arguments, it displays the guards on the current "
dongsheng@627 15601 "topmost patch."
dongsheng@627 15602 msgstr ""
dongsheng@627 15603
dongsheng@627 15604 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 15605 #: ../en/ch12-mq-collab.xml:144
dongsheng@627 15606 msgid ""
dongsheng@627 15607 "To set a positive guard on a patch, prefix the name of the guard with a "
dongsheng@627 15608 "<quote><literal>+</literal></quote>."
dongsheng@627 15609 msgstr ""
dongsheng@627 15610
dongsheng@627 15611 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 15612 #: ../en/ch12-mq-collab.xml:149
dongsheng@627 15613 msgid ""
dongsheng@627 15614 "To set a negative guard on a patch, prefix the name of the guard with a "
dongsheng@627 15615 "<quote><literal>-</literal></quote>."
dongsheng@627 15616 msgstr ""
dongsheng@627 15617
dongsheng@627 15618 #. type: Content of: <book><chapter><sect1><note><para>
dongsheng@650 15619 #: ../en/ch12-mq-collab.xml:156
dongsheng@627 15620 msgid ""
dongsheng@627 15621 "The <command role=\"hg-ext-mq\">qguard</command> command <emphasis>sets</"
dongsheng@627 15622 "emphasis> the guards on a patch; it doesn't <emphasis>modify</emphasis> "
dongsheng@627 15623 "them. What this means is that if you run <command role=\"hg-cmd\">hg qguard "
dongsheng@627 15624 "+a +b</command> on a patch, then <command role=\"hg-cmd\">hg qguard +c</"
dongsheng@627 15625 "command> on the same patch, the <emphasis>only</emphasis> guard that will be "
dongsheng@627 15626 "set on it afterwards is <literal>+c</literal>."
dongsheng@627 15627 msgstr ""
dongsheng@627 15628
dongsheng@627 15629 #
dongsheng@627 15630 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 15631 #: ../en/ch12-mq-collab.xml:165
dongsheng@627 15632 msgid ""
dongsheng@627 15633 "Mercurial stores guards in the <filename role=\"special\">series</filename> "
dongsheng@627 15634 "file; the form in which they are stored is easy both to understand and to "
dongsheng@627 15635 "edit by hand. (In other words, you don't have to use the <command role=\"hg-"
dongsheng@627 15636 "ext-mq\">qguard</command> command if you don't want to; it's okay to simply "
dongsheng@627 15637 "edit the <filename role=\"special\">series</filename> file.)"
dongsheng@627 15638 msgstr ""
dongsheng@627 15639
dongsheng@627 15640 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 15641 #: ../en/ch12-mq-collab.xml:177
dongsheng@627 15642 msgid "Selecting the guards to use"
dongsheng@636 15643 msgstr "选择使用的条件"
dongsheng@627 15644
dongsheng@627 15645 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 15646 #: ../en/ch12-mq-collab.xml:179
dongsheng@627 15647 msgid ""
dongsheng@627 15648 "The <command role=\"hg-ext-mq\">qselect</command> command determines which "
dongsheng@627 15649 "guards are active at a given time. The effect of this is to determine which "
dongsheng@627 15650 "patches MQ will apply the next time you run <command role=\"hg-ext-mq"
dongsheng@627 15651 "\">qpush</command>. It has no other effect; in particular, it doesn't do "
dongsheng@627 15652 "anything to patches that are already applied."
dongsheng@627 15653 msgstr ""
dongsheng@627 15654
dongsheng@627 15655 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 15656 #: ../en/ch12-mq-collab.xml:186
dongsheng@627 15657 msgid ""
dongsheng@627 15658 "With no arguments, the <command role=\"hg-ext-mq\">qselect</command> command "
dongsheng@627 15659 "lists the guards currently in effect, one per line of output. Each argument "
dongsheng@627 15660 "is treated as the name of a guard to apply."
dongsheng@627 15661 msgstr ""
dongsheng@627 15662
dongsheng@627 15663 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 15664 #: ../en/ch12-mq-collab.xml:193
dongsheng@627 15665 msgid ""
dongsheng@627 15666 "In case you're interested, the currently selected guards are stored in the "
dongsheng@627 15667 "<filename role=\"special\">guards</filename> file."
dongsheng@627 15668 msgstr ""
dongsheng@627 15669
dongsheng@627 15670 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 15671 #: ../en/ch12-mq-collab.xml:198
dongsheng@627 15672 msgid ""
dongsheng@627 15673 "We can see the effect the selected guards have when we run <command role=\"hg-"
dongsheng@627 15674 "ext-mq\">qpush</command>."
dongsheng@627 15675 msgstr ""
dongsheng@627 15676
dongsheng@627 15677 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 15678 #: ../en/ch12-mq-collab.xml:203
dongsheng@627 15679 msgid ""
dongsheng@627 15680 "A guard cannot start with a <quote><literal>+</literal></quote> or "
dongsheng@627 15681 "<quote><literal>-</literal></quote> character. The name of a guard must not "
dongsheng@627 15682 "contain white space, but most other characters are acceptable. If you try to "
dongsheng@627 15683 "use a guard with an invalid name, MQ will complain:"
dongsheng@627 15684 msgstr ""
dongsheng@627 15685
dongsheng@627 15686 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 15687 #: ../en/ch12-mq-collab.xml:212
dongsheng@627 15688 msgid "Changing the selected guards changes the patches that are applied."
dongsheng@627 15689 msgstr ""
dongsheng@627 15690
dongsheng@627 15691 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 15692 #: ../en/ch12-mq-collab.xml:217
dongsheng@627 15693 msgid ""
dongsheng@627 15694 "You can see in the example below that negative guards take precedence over "
dongsheng@627 15695 "positive guards."
dongsheng@627 15696 msgstr ""
dongsheng@627 15697
dongsheng@627 15698 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 15699 #: ../en/ch12-mq-collab.xml:224
dongsheng@627 15700 msgid "MQ's rules for applying patches"
dongsheng@636 15701 msgstr "MQ 应用补丁的规则"
dongsheng@627 15702
dongsheng@627 15703 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 15704 #: ../en/ch12-mq-collab.xml:226
dongsheng@627 15705 msgid ""
dongsheng@627 15706 "The rules that MQ uses when deciding whether to apply a patch are as follows."
dongsheng@627 15707 msgstr ""
dongsheng@627 15708
dongsheng@627 15709 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 15710 #: ../en/ch12-mq-collab.xml:229
dongsheng@627 15711 msgid "A patch that has no guards is always applied."
dongsheng@627 15712 msgstr ""
dongsheng@627 15713
dongsheng@627 15714 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 15715 #: ../en/ch12-mq-collab.xml:232
dongsheng@627 15716 msgid ""
dongsheng@627 15717 "If the patch has any negative guard that matches any currently selected "
dongsheng@627 15718 "guard, the patch is skipped."
dongsheng@627 15719 msgstr ""
dongsheng@627 15720
dongsheng@627 15721 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 15722 #: ../en/ch12-mq-collab.xml:235
dongsheng@627 15723 msgid ""
dongsheng@627 15724 "If the patch has any positive guard that matches any currently selected "
dongsheng@627 15725 "guard, the patch is applied."
dongsheng@627 15726 msgstr ""
dongsheng@627 15727
dongsheng@627 15728 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 15729 #: ../en/ch12-mq-collab.xml:238
dongsheng@627 15730 msgid ""
dongsheng@627 15731 "If the patch has positive or negative guards, but none matches any currently "
dongsheng@627 15732 "selected guard, the patch is skipped."
dongsheng@627 15733 msgstr ""
dongsheng@627 15734
dongsheng@627 15735 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 15736 #: ../en/ch12-mq-collab.xml:245
dongsheng@627 15737 msgid "Trimming the work environment"
dongsheng@636 15738 msgstr "修剪工作环境"
dongsheng@627 15739
dongsheng@627 15740 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 15741 #: ../en/ch12-mq-collab.xml:247
dongsheng@627 15742 msgid ""
dongsheng@627 15743 "In working on the device driver I mentioned earlier, I don't apply the "
dongsheng@627 15744 "patches to a normal Linux kernel tree. Instead, I use a repository that "
dongsheng@627 15745 "contains only a snapshot of the source files and headers that are relevant to "
dongsheng@627 15746 "Infiniband development. This repository is 1% the size of a kernel "
dongsheng@627 15747 "repository, so it's easier to work with."
dongsheng@627 15748 msgstr ""
dongsheng@627 15749
dongsheng@627 15750 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 15751 #: ../en/ch12-mq-collab.xml:254
dongsheng@627 15752 msgid ""
dongsheng@627 15753 "I then choose a <quote>base</quote> version on top of which the patches are "
dongsheng@627 15754 "applied. This is a snapshot of the Linux kernel tree as of a revision of my "
dongsheng@627 15755 "choosing. When I take the snapshot, I record the changeset ID from the "
dongsheng@627 15756 "kernel repository in the commit message. Since the snapshot preserves the "
dongsheng@627 15757 "<quote>shape</quote> and content of the relevant parts of the kernel tree, I "
dongsheng@627 15758 "can apply my patches on top of either my tiny repository or a normal kernel "
dongsheng@627 15759 "tree."
dongsheng@627 15760 msgstr ""
dongsheng@627 15761
dongsheng@627 15762 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 15763 #: ../en/ch12-mq-collab.xml:263
dongsheng@627 15764 msgid ""
dongsheng@627 15765 "Normally, the base tree atop which the patches apply should be a snapshot of "
dongsheng@627 15766 "a very recent upstream tree. This best facilitates the development of "
dongsheng@627 15767 "patches that can easily be submitted upstream with few or no modifications."
dongsheng@627 15768 msgstr ""
dongsheng@627 15769
dongsheng@627 15770 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 15771 #: ../en/ch12-mq-collab.xml:270
dongsheng@627 15772 msgid "Dividing up the <filename role=\"special\">series</filename> file"
dongsheng@636 15773 msgstr "分类补丁<filename role=\"special\">系列</filename>"
dongsheng@627 15774
dongsheng@627 15775 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 15776 #: ../en/ch12-mq-collab.xml:273
dongsheng@627 15777 msgid ""
dongsheng@627 15778 "I categorise the patches in the <filename role=\"special\">series</filename> "
dongsheng@627 15779 "file into a number of logical groups. Each section of like patches begins "
dongsheng@627 15780 "with a block of comments that describes the purpose of the patches that "
dongsheng@627 15781 "follow."
dongsheng@627 15782 msgstr ""
dongsheng@627 15783
dongsheng@627 15784 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 15785 #: ../en/ch12-mq-collab.xml:279
dongsheng@627 15786 msgid ""
dongsheng@627 15787 "The sequence of patch groups that I maintain follows. The ordering of these "
dongsheng@627 15788 "groups is important; I'll describe why after I introduce the groups."
dongsheng@627 15789 msgstr ""
dongsheng@627 15790
dongsheng@627 15791 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 15792 #: ../en/ch12-mq-collab.xml:283
dongsheng@627 15793 msgid ""
dongsheng@627 15794 "The <quote>accepted</quote> group. Patches that the development team has "
dongsheng@627 15795 "submitted to the maintainer of the Infiniband subsystem, and which he has "
dongsheng@627 15796 "accepted, but which are not present in the snapshot that the tiny repository "
dongsheng@627 15797 "is based on. These are <quote>read only</quote> patches, present only to "
dongsheng@627 15798 "transform the tree into a similar state as it is in the upstream maintainer's "
dongsheng@627 15799 "repository."
dongsheng@627 15800 msgstr ""
dongsheng@627 15801
dongsheng@627 15802 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 15803 #: ../en/ch12-mq-collab.xml:291
dongsheng@627 15804 msgid ""
dongsheng@627 15805 "The <quote>rework</quote> group. Patches that I have submitted, but that the "
dongsheng@627 15806 "upstream maintainer has requested modifications to before he will accept them."
dongsheng@627 15807 msgstr ""
dongsheng@627 15808
dongsheng@627 15809 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 15810 #: ../en/ch12-mq-collab.xml:296
dongsheng@627 15811 msgid ""
dongsheng@627 15812 "The <quote>pending</quote> group. Patches that I have not yet submitted to "
dongsheng@627 15813 "the upstream maintainer, but which we have finished working on. These will be "
dongsheng@627 15814 "<quote>read only</quote> for a while. If the upstream maintainer accepts "
dongsheng@627 15815 "them upon submission, I'll move them to the end of the <quote>accepted</"
dongsheng@627 15816 "quote> group. If he requests that I modify any, I'll move them to the "
dongsheng@627 15817 "beginning of the <quote>rework</quote> group."
dongsheng@627 15818 msgstr ""
dongsheng@627 15819
dongsheng@627 15820 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 15821 #: ../en/ch12-mq-collab.xml:305
dongsheng@627 15822 msgid ""
dongsheng@627 15823 "The <quote>in progress</quote> group. Patches that are actively being "
dongsheng@627 15824 "developed, and should not be submitted anywhere yet."
dongsheng@627 15825 msgstr ""
dongsheng@627 15826
dongsheng@627 15827 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 15828 #: ../en/ch12-mq-collab.xml:309
dongsheng@627 15829 msgid ""
dongsheng@627 15830 "The <quote>backport</quote> group. Patches that adapt the source tree to "
dongsheng@627 15831 "older versions of the kernel tree."
dongsheng@627 15832 msgstr ""
dongsheng@627 15833
dongsheng@627 15834 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 15835 #: ../en/ch12-mq-collab.xml:313
dongsheng@627 15836 msgid ""
dongsheng@627 15837 "The <quote>do not ship</quote> group. Patches that for some reason should "
dongsheng@627 15838 "never be submitted upstream. For example, one such patch might change "
dongsheng@627 15839 "embedded driver identification strings to make it easier to distinguish, in "
dongsheng@627 15840 "the field, between an out-of-tree version of the driver and a version shipped "
dongsheng@627 15841 "by a distribution vendor."
dongsheng@627 15842 msgstr ""
dongsheng@627 15843
dongsheng@627 15844 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 15845 #: ../en/ch12-mq-collab.xml:321
dongsheng@627 15846 msgid ""
dongsheng@627 15847 "Now to return to the reasons for ordering groups of patches in this way. We "
dongsheng@627 15848 "would like the lowest patches in the stack to be as stable as possible, so "
dongsheng@627 15849 "that we will not need to rework higher patches due to changes in context. "
dongsheng@627 15850 "Putting patches that will never be changed first in the <filename role="
dongsheng@627 15851 "\"special\">series</filename> file serves this purpose."
dongsheng@627 15852 msgstr ""
dongsheng@627 15853
dongsheng@627 15854 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 15855 #: ../en/ch12-mq-collab.xml:329
dongsheng@627 15856 msgid ""
dongsheng@627 15857 "We would also like the patches that we know we'll need to modify to be "
dongsheng@627 15858 "applied on top of a source tree that resembles the upstream tree as closely "
dongsheng@627 15859 "as possible. This is why we keep accepted patches around for a while."
dongsheng@627 15860 msgstr ""
dongsheng@627 15861
dongsheng@627 15862 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 15863 #: ../en/ch12-mq-collab.xml:334
dongsheng@627 15864 msgid ""
dongsheng@627 15865 "The <quote>backport</quote> and <quote>do not ship</quote> patches float at "
dongsheng@627 15866 "the end of the <filename role=\"special\">series</filename> file. The "
dongsheng@627 15867 "backport patches must be applied on top of all other patches, and the "
dongsheng@627 15868 "<quote>do not ship</quote> patches might as well stay out of harm's way."
dongsheng@627 15869 msgstr ""
dongsheng@627 15870
dongsheng@627 15871 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 15872 #: ../en/ch12-mq-collab.xml:343
dongsheng@627 15873 msgid "Maintaining the patch series"
dongsheng@636 15874 msgstr "维护补丁系列"
dongsheng@627 15875
dongsheng@627 15876 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 15877 #: ../en/ch12-mq-collab.xml:345
dongsheng@627 15878 msgid ""
dongsheng@627 15879 "In my work, I use a number of guards to control which patches are to be "
dongsheng@627 15880 "applied."
dongsheng@627 15881 msgstr ""
dongsheng@627 15882
dongsheng@627 15883 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 15884 #: ../en/ch12-mq-collab.xml:349
dongsheng@627 15885 msgid ""
dongsheng@627 15886 "<quote>Accepted</quote> patches are guarded with <literal>accepted</"
dongsheng@627 15887 "literal>. I enable this guard most of the time. When I'm applying the "
dongsheng@627 15888 "patches on top of a tree where the patches are already present, I can turn "
dongsheng@627 15889 "this patch off, and the patches that follow it will apply cleanly."
dongsheng@627 15890 msgstr ""
dongsheng@627 15891
dongsheng@627 15892 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 15893 #: ../en/ch12-mq-collab.xml:356
dongsheng@627 15894 msgid ""
dongsheng@627 15895 "Patches that are <quote>finished</quote>, but not yet submitted, have no "
dongsheng@627 15896 "guards. If I'm applying the patch stack to a copy of the upstream tree, I "
dongsheng@627 15897 "don't need to enable any guards in order to get a reasonably safe source tree."
dongsheng@627 15898 msgstr ""
dongsheng@627 15899
dongsheng@627 15900 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 15901 #: ../en/ch12-mq-collab.xml:362
dongsheng@627 15902 msgid ""
dongsheng@627 15903 "Those patches that need reworking before being resubmitted are guarded with "
dongsheng@627 15904 "<literal>rework</literal>."
dongsheng@627 15905 msgstr ""
dongsheng@627 15906
dongsheng@627 15907 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 15908 #: ../en/ch12-mq-collab.xml:366
dongsheng@627 15909 msgid ""
dongsheng@627 15910 "For those patches that are still under development, I use <literal>devel</"
dongsheng@627 15911 "literal>."
dongsheng@627 15912 msgstr ""
dongsheng@627 15913
dongsheng@627 15914 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 15915 #: ../en/ch12-mq-collab.xml:369
dongsheng@627 15916 msgid ""
dongsheng@627 15917 "A backport patch may have several guards, one for each version of the kernel "
dongsheng@627 15918 "to which it applies. For example, a patch that backports a piece of code to "
dongsheng@627 15919 "2.6.9 will have a <literal>2.6.9</literal> guard."
dongsheng@627 15920 msgstr ""
dongsheng@627 15921
dongsheng@627 15922 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 15923 #: ../en/ch12-mq-collab.xml:374
dongsheng@627 15924 msgid ""
dongsheng@627 15925 "This variety of guards gives me considerable flexibility in determining what "
dongsheng@627 15926 "kind of source tree I want to end up with. For most situations, the "
dongsheng@627 15927 "selection of appropriate guards is automated during the build process, but I "
dongsheng@627 15928 "can manually tune the guards to use for less common circumstances."
dongsheng@627 15929 msgstr ""
dongsheng@627 15930
dongsheng@627 15931 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 15932 #: ../en/ch12-mq-collab.xml:381
dongsheng@627 15933 msgid "The art of writing backport patches"
dongsheng@636 15934 msgstr "编写向后移植补丁的艺术"
dongsheng@627 15935
dongsheng@627 15936 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 15937 #: ../en/ch12-mq-collab.xml:383
dongsheng@627 15938 msgid ""
dongsheng@627 15939 "Using MQ, writing a backport patch is a simple process. All such a patch has "
dongsheng@627 15940 "to do is modify a piece of code that uses a kernel feature not present in the "
dongsheng@627 15941 "older version of the kernel, so that the driver continues to work correctly "
dongsheng@627 15942 "under that older version."
dongsheng@627 15943 msgstr ""
dongsheng@627 15944
dongsheng@627 15945 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 15946 #: ../en/ch12-mq-collab.xml:389
dongsheng@627 15947 msgid ""
dongsheng@627 15948 "A useful goal when writing a good backport patch is to make your code look as "
dongsheng@627 15949 "if it was written for the older version of the kernel you're targeting. The "
dongsheng@627 15950 "less obtrusive the patch, the easier it will be to understand and maintain. "
dongsheng@627 15951 "If you're writing a collection of backport patches to avoid the <quote>rat's "
dongsheng@627 15952 "nest</quote> effect of lots of <literal>#ifdef</literal>s (hunks of source "
dongsheng@627 15953 "code that are only used conditionally) in your code, don't introduce version-"
dongsheng@627 15954 "dependent <literal>#ifdef</literal>s into the patches. Instead, write "
dongsheng@627 15955 "several patches, each of which makes unconditional changes, and control their "
dongsheng@627 15956 "application using guards."
dongsheng@627 15957 msgstr ""
dongsheng@627 15958
dongsheng@627 15959 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 15960 #: ../en/ch12-mq-collab.xml:402
dongsheng@627 15961 msgid ""
dongsheng@627 15962 "There are two reasons to divide backport patches into a distinct group, away "
dongsheng@627 15963 "from the <quote>regular</quote> patches whose effects they modify. The first "
dongsheng@627 15964 "is that intermingling the two makes it more difficult to use a tool like the "
dongsheng@627 15965 "<literal role=\"hg-ext\">patchbomb</literal> extension to automate the "
dongsheng@627 15966 "process of submitting the patches to an upstream maintainer. The second is "
dongsheng@627 15967 "that a backport patch could perturb the context in which a subsequent regular "
dongsheng@627 15968 "patch is applied, making it impossible to apply the regular patch cleanly "
dongsheng@627 15969 "<emphasis>without</emphasis> the earlier backport patch already being applied."
dongsheng@627 15970 msgstr ""
dongsheng@627 15971
dongsheng@627 15972 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 15973 #: ../en/ch12-mq-collab.xml:417
dongsheng@627 15974 msgid "Useful tips for developing with MQ"
dongsheng@636 15975 msgstr "使用 MQ 开发的技巧"
dongsheng@627 15976
dongsheng@627 15977 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 15978 #: ../en/ch12-mq-collab.xml:420
dongsheng@627 15979 msgid "Organising patches in directories"
dongsheng@636 15980 msgstr "将补丁放到几个目录中"
dongsheng@627 15981
dongsheng@627 15982 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 15983 #: ../en/ch12-mq-collab.xml:422
dongsheng@627 15984 msgid ""
dongsheng@627 15985 "If you're working on a substantial project with MQ, it's not difficult to "
dongsheng@627 15986 "accumulate a large number of patches. For example, I have one patch "
dongsheng@627 15987 "repository that contains over 250 patches."
dongsheng@627 15988 msgstr ""
dongsheng@627 15989
dongsheng@627 15990 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 15991 #: ../en/ch12-mq-collab.xml:427
dongsheng@627 15992 msgid ""
dongsheng@627 15993 "If you can group these patches into separate logical categories, you can if "
dongsheng@627 15994 "you like store them in different directories; MQ has no problems with patch "
dongsheng@627 15995 "names that contain path separators."
dongsheng@627 15996 msgstr ""
dongsheng@627 15997
dongsheng@627 15998 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 15999 #: ../en/ch12-mq-collab.xml:434
dongsheng@627 16000 msgid "Viewing the history of a patch"
dongsheng@636 16001 msgstr "察看补丁的历史"
dongsheng@627 16002
dongsheng@627 16003 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 16004 #: ../en/ch12-mq-collab.xml:436
dongsheng@627 16005 msgid ""
dongsheng@627 16006 "If you're developing a set of patches over a long time, it's a good idea to "
songdongsheng@658 16007 "maintain them in a repository, as discussed in <xref linkend=\"sec:mq:repo\"/"
songdongsheng@658 16008 ">. If you do so, you'll quickly discover that using the <command role=\"hg-"
songdongsheng@658 16009 "cmd\">hg diff</command> command to look at the history of changes to a patch "
songdongsheng@658 16010 "is unworkable. This is in part because you're looking at the second "
dongsheng@627 16011 "derivative of the real code (a diff of a diff), but also because MQ adds "
dongsheng@627 16012 "noise to the process by modifying time stamps and directory names when it "
dongsheng@627 16013 "updates a patch."
dongsheng@627 16014 msgstr ""
dongsheng@627 16015
dongsheng@627 16016 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 16017 #: ../en/ch12-mq-collab.xml:448
dongsheng@627 16018 msgid ""
dongsheng@627 16019 "However, you can use the <literal role=\"hg-ext\">extdiff</literal> "
dongsheng@627 16020 "extension, which is bundled with Mercurial, to turn a diff of two versions of "
dongsheng@627 16021 "a patch into something readable. To do this, you will need a third-party "
dongsheng@627 16022 "package called <literal role=\"package\">patchutils</literal> <citation>web:"
dongsheng@627 16023 "patchutils</citation>. This provides a command named <command>interdiff</"
dongsheng@627 16024 "command>, which shows the differences between two diffs as a diff. Used on "
dongsheng@627 16025 "two versions of the same diff, it generates a diff that represents the diff "
dongsheng@627 16026 "from the first to the second version."
dongsheng@627 16027 msgstr ""
dongsheng@627 16028
dongsheng@627 16029 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 16030 #: ../en/ch12-mq-collab.xml:459
dongsheng@627 16031 msgid ""
dongsheng@627 16032 "You can enable the <literal role=\"hg-ext\">extdiff</literal> extension in "
dongsheng@627 16033 "the usual way, by adding a line to the <literal role=\"rc-extensions"
dongsheng@650 16034 "\">extensions</literal> section of your <filename role=\"special\">~/.hgrc</"
dongsheng@627 16035 "filename>."
dongsheng@627 16036 msgstr ""
dongsheng@627 16037
dongsheng@627 16038 #
songdongsheng@710 16039 #. &example.hg-interdiff;
dongsheng@627 16040 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 16041 #: ../en/ch12-mq-collab.xml:466
dongsheng@627 16042 msgid ""
dongsheng@627 16043 "The <command>interdiff</command> command expects to be passed the names of "
dongsheng@627 16044 "two files, but the <literal role=\"hg-ext\">extdiff</literal> extension "
dongsheng@627 16045 "passes the program it runs a pair of directories, each of which can contain "
dongsheng@627 16046 "an arbitrary number of files. We thus need a small program that will run "
dongsheng@627 16047 "<command>interdiff</command> on each pair of files in these two directories. "
dongsheng@627 16048 "This program is available as <filename role=\"special\">hg-interdiff</"
dongsheng@627 16049 "filename> in the <filename class=\"directory\">examples</filename> directory "
dongsheng@627 16050 "of the source code repository that accompanies this book."
dongsheng@627 16051 msgstr ""
dongsheng@627 16052
dongsheng@627 16053 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 16054 #: ../en/ch12-mq-collab.xml:478
dongsheng@627 16055 msgid ""
dongsheng@627 16056 "With the <filename role=\"special\">hg-interdiff</filename> program in your "
dongsheng@627 16057 "shell's search path, you can run it as follows, from inside an MQ patch "
dongsheng@627 16058 "directory:"
dongsheng@627 16059 msgstr ""
dongsheng@627 16060
dongsheng@627 16061 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 16062 #: ../en/ch12-mq-collab.xml:482
dongsheng@627 16063 msgid ""
dongsheng@627 16064 "Since you'll probably want to use this long-winded command a lot, you can get "
dongsheng@627 16065 "<literal role=\"hg-ext\">hgext</literal> to make it available as a normal "
dongsheng@650 16066 "Mercurial command, again by editing your <filename role=\"special\">~/.hgrc</"
dongsheng@627 16067 "filename>."
dongsheng@627 16068 msgstr ""
dongsheng@627 16069
dongsheng@627 16070 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 16071 #: ../en/ch12-mq-collab.xml:489
dongsheng@627 16072 msgid ""
dongsheng@627 16073 "This directs <literal role=\"hg-ext\">hgext</literal> to make an "
dongsheng@627 16074 "<literal>interdiff</literal> command available, so you can now shorten the "
dongsheng@627 16075 "previous invocation of <command role=\"hg-ext-extdiff\">extdiff</command> to "
dongsheng@627 16076 "something a little more wieldy."
dongsheng@627 16077 msgstr ""
dongsheng@627 16078
dongsheng@627 16079 #. type: Content of: <book><chapter><sect1><sect2><note><para>
dongsheng@650 16080 #: ../en/ch12-mq-collab.xml:497
dongsheng@627 16081 msgid ""
dongsheng@627 16082 "The <command>interdiff</command> command works well only if the underlying "
dongsheng@627 16083 "files against which versions of a patch are generated remain the same. If "
dongsheng@627 16084 "you create a patch, modify the underlying files, and then regenerate the "
dongsheng@627 16085 "patch, <command>interdiff</command> may not produce useful output."
dongsheng@627 16086 msgstr ""
dongsheng@627 16087
dongsheng@627 16088 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 16089 #: ../en/ch12-mq-collab.xml:505
dongsheng@627 16090 msgid ""
dongsheng@627 16091 "The <literal role=\"hg-ext\">extdiff</literal> extension is useful for more "
dongsheng@627 16092 "than merely improving the presentation of MQ patches. To read more about it, "
songdongsheng@658 16093 "go to <xref linkend=\"sec:hgext:extdiff\"/>."
dongsheng@627 16094 msgstr ""
dongsheng@627 16095
dongsheng@627 16096 #. type: Content of: <book><chapter><title>
dongsheng@650 16097 #: ../en/ch13-hgext.xml:5
dongsheng@627 16098 msgid "Adding functionality with extensions"
dongsheng@627 16099 msgstr "使用扩展增加功能"
dongsheng@627 16100
dongsheng@627 16101 #. type: Content of: <book><chapter><para>
dongsheng@650 16102 #: ../en/ch13-hgext.xml:7
dongsheng@627 16103 msgid ""
dongsheng@627 16104 "While the core of Mercurial is quite complete from a functionality "
dongsheng@627 16105 "standpoint, it's deliberately shorn of fancy features. This approach of "
dongsheng@627 16106 "preserving simplicity keeps the software easy to deal with for both "
dongsheng@627 16107 "maintainers and users."
dongsheng@627 16108 msgstr ""
dongsheng@627 16109
dongsheng@627 16110 #. type: Content of: <book><chapter><para>
dongsheng@650 16111 #: ../en/ch13-hgext.xml:12
dongsheng@627 16112 msgid ""
dongsheng@627 16113 "However, Mercurial doesn't box you in with an inflexible command set: you can "
dongsheng@627 16114 "add features to it as <emphasis>extensions</emphasis> (sometimes known as "
dongsheng@627 16115 "<emphasis>plugins</emphasis>). We've already discussed a few of these "
dongsheng@627 16116 "extensions in earlier chapters."
dongsheng@627 16117 msgstr ""
dongsheng@627 16118
dongsheng@627 16119 #. type: Content of: <book><chapter><itemizedlist><listitem><para>
dongsheng@650 16120 #: ../en/ch13-hgext.xml:18
dongsheng@627 16121 msgid ""
songdongsheng@658 16122 "<xref linkend=\"sec:tour-merge:fetch\"/> covers the <literal role=\"hg-ext"
songdongsheng@658 16123 "\">fetch</literal> extension; this combines pulling new changes and merging "
songdongsheng@658 16124 "them with local changes into a single command, <command role=\"hg-ext-fetch"
songdongsheng@658 16125 "\">fetch</command>."
dongsheng@627 16126 msgstr ""
dongsheng@627 16127
dongsheng@627 16128 #. type: Content of: <book><chapter><itemizedlist><listitem><para>
dongsheng@650 16129 #: ../en/ch13-hgext.xml:24
dongsheng@627 16130 msgid ""
songdongsheng@658 16131 "In <xref linkend=\"chap:hook\"/>, we covered several extensions that are "
songdongsheng@658 16132 "useful for hook-related functionality: <literal role=\"hg-ext\">acl</literal> "
songdongsheng@658 16133 "adds access control lists; <literal role=\"hg-ext\">bugzilla</literal> adds "
songdongsheng@658 16134 "integration with the Bugzilla bug tracking system; and <literal role=\"hg-ext"
songdongsheng@658 16135 "\">notify</literal> sends notification emails on new changes."
dongsheng@627 16136 msgstr ""
dongsheng@627 16137
dongsheng@627 16138 #. type: Content of: <book><chapter><itemizedlist><listitem><para>
dongsheng@650 16139 #: ../en/ch13-hgext.xml:33
dongsheng@627 16140 msgid ""
dongsheng@627 16141 "The Mercurial Queues patch management extension is so invaluable that it "
songdongsheng@658 16142 "merits two chapters and an appendix all to itself. <xref linkend=\"chap:mq\"/"
songdongsheng@658 16143 "> covers the basics; <xref linkend=\"chap:mq-collab\"/> discusses advanced "
songdongsheng@658 16144 "topics; and <xref linkend=\"chap:mqref\"/> goes into detail on each command."
dongsheng@627 16145 msgstr ""
dongsheng@627 16146
dongsheng@627 16147 #. type: Content of: <book><chapter><para>
dongsheng@650 16148 #: ../en/ch13-hgext.xml:43
dongsheng@627 16149 msgid ""
dongsheng@627 16150 "In this chapter, we'll cover some of the other extensions that are available "
dongsheng@627 16151 "for Mercurial, and briefly touch on some of the machinery you'll need to know "
dongsheng@627 16152 "about if you want to write an extension of your own."
dongsheng@627 16153 msgstr ""
dongsheng@627 16154
dongsheng@627 16155 #. type: Content of: <book><chapter><itemizedlist><listitem><para>
dongsheng@650 16156 #: ../en/ch13-hgext.xml:48
dongsheng@627 16157 msgid ""
songdongsheng@658 16158 "In <xref linkend=\"sec:hgext:inotify\"/>, we'll discuss the possibility of "
songdongsheng@658 16159 "<emphasis>huge</emphasis> performance improvements using the <literal role="
songdongsheng@658 16160 "\"hg-ext\">inotify</literal> extension."
dongsheng@627 16161 msgstr ""
dongsheng@627 16162
dongsheng@627 16163 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 16164 #: ../en/ch13-hgext.xml:55
dongsheng@627 16165 msgid ""
dongsheng@627 16166 "Improve performance with the <literal role=\"hg-ext\">inotify</literal> "
dongsheng@627 16167 "extension"
dongsheng@636 16168 msgstr "使用扩展 <literal role=\"hg-ext\">inotify</literal> 以提高性能"
dongsheng@627 16169
dongsheng@627 16170 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16171 #: ../en/ch13-hgext.xml:58
dongsheng@627 16172 msgid ""
dongsheng@627 16173 "Are you interested in having some of the most common Mercurial operations run "
dongsheng@627 16174 "as much as a hundred times faster? Read on!"
dongsheng@627 16175 msgstr ""
dongsheng@627 16176
dongsheng@627 16177 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16178 #: ../en/ch13-hgext.xml:62
dongsheng@627 16179 msgid ""
dongsheng@627 16180 "Mercurial has great performance under normal circumstances. For example, "
dongsheng@627 16181 "when you run the <command role=\"hg-cmd\">hg status</command> command, "
dongsheng@627 16182 "Mercurial has to scan almost every directory and file in your repository so "
dongsheng@627 16183 "that it can display file status. Many other Mercurial commands need to do "
dongsheng@627 16184 "the same work behind the scenes; for example, the <command role=\"hg-cmd\">hg "
dongsheng@627 16185 "diff</command> command uses the status machinery to avoid doing an expensive "
dongsheng@627 16186 "comparison operation on files that obviously haven't changed."
dongsheng@627 16187 msgstr ""
dongsheng@627 16188
dongsheng@627 16189 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16190 #: ../en/ch13-hgext.xml:72
dongsheng@627 16191 msgid ""
dongsheng@627 16192 "Because obtaining file status is crucial to good performance, the authors of "
dongsheng@627 16193 "Mercurial have optimised this code to within an inch of its life. However, "
dongsheng@627 16194 "there's no avoiding the fact that when you run <command role=\"hg-cmd\">hg "
dongsheng@627 16195 "status</command>, Mercurial is going to have to perform at least one "
dongsheng@627 16196 "expensive system call for each managed file to determine whether it's changed "
dongsheng@627 16197 "since the last time Mercurial checked. For a sufficiently large repository, "
dongsheng@627 16198 "this can take a long time."
dongsheng@627 16199 msgstr ""
dongsheng@627 16200
dongsheng@627 16201 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16202 #: ../en/ch13-hgext.xml:82
dongsheng@627 16203 msgid ""
dongsheng@627 16204 "To put a number on the magnitude of this effect, I created a repository "
dongsheng@627 16205 "containing 150,000 managed files. I timed <command role=\"hg-cmd\">hg "
dongsheng@627 16206 "status</command> as taking ten seconds to run, even when <emphasis>none</"
dongsheng@627 16207 "emphasis> of those files had been modified."
dongsheng@627 16208 msgstr ""
dongsheng@627 16209
dongsheng@627 16210 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16211 #: ../en/ch13-hgext.xml:88
dongsheng@627 16212 msgid ""
dongsheng@627 16213 "Many modern operating systems contain a file notification facility. If a "
dongsheng@627 16214 "program signs up to an appropriate service, the operating system will notify "
dongsheng@627 16215 "it every time a file of interest is created, modified, or deleted. On Linux "
dongsheng@627 16216 "systems, the kernel component that does this is called <literal>inotify</"
dongsheng@627 16217 "literal>."
dongsheng@627 16218 msgstr ""
dongsheng@627 16219
dongsheng@627 16220 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16221 #: ../en/ch13-hgext.xml:95
dongsheng@627 16222 msgid ""
dongsheng@627 16223 "Mercurial's <literal role=\"hg-ext\">inotify</literal> extension talks to the "
dongsheng@627 16224 "kernel's <literal>inotify</literal> component to optimise <command role=\"hg-"
dongsheng@627 16225 "cmd\">hg status</command> commands. The extension has two components. A "
dongsheng@627 16226 "daemon sits in the background and receives notifications from the "
dongsheng@627 16227 "<literal>inotify</literal> subsystem. It also listens for connections from a "
songdongsheng@710 16228 "regular Mercurial command. The extension modifies Mercurial's behavior so "
dongsheng@627 16229 "that instead of scanning the filesystem, it queries the daemon. Since the "
dongsheng@627 16230 "daemon has perfect information about the state of the repository, it can "
dongsheng@627 16231 "respond with a result instantaneously, avoiding the need to scan every "
dongsheng@627 16232 "directory and file in the repository."
dongsheng@627 16233 msgstr ""
dongsheng@627 16234
dongsheng@627 16235 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16236 #: ../en/ch13-hgext.xml:108
dongsheng@627 16237 msgid ""
dongsheng@627 16238 "Recall the ten seconds that I measured plain Mercurial as taking to run "
dongsheng@627 16239 "<command role=\"hg-cmd\">hg status</command> on a 150,000 file repository. "
dongsheng@627 16240 "With the <literal role=\"hg-ext\">inotify</literal> extension enabled, the "
dongsheng@627 16241 "time dropped to 0.1 seconds, a factor of <emphasis>one hundred</emphasis> "
dongsheng@627 16242 "faster."
dongsheng@627 16243 msgstr ""
dongsheng@627 16244
dongsheng@627 16245 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16246 #: ../en/ch13-hgext.xml:115
dongsheng@627 16247 msgid "Before we continue, please pay attention to some caveats."
dongsheng@627 16248 msgstr ""
dongsheng@627 16249
dongsheng@627 16250 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 16251 #: ../en/ch13-hgext.xml:118
dongsheng@627 16252 msgid ""
dongsheng@627 16253 "The <literal role=\"hg-ext\">inotify</literal> extension is Linux-specific. "
dongsheng@627 16254 "Because it interfaces directly to the Linux kernel's <literal>inotify</"
dongsheng@627 16255 "literal> subsystem, it does not work on other operating systems."
dongsheng@627 16256 msgstr ""
dongsheng@627 16257
dongsheng@627 16258 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 16259 #: ../en/ch13-hgext.xml:123
dongsheng@627 16260 msgid ""
dongsheng@627 16261 "It should work on any Linux distribution that was released after early 2005. "
dongsheng@627 16262 "Older distributions are likely to have a kernel that lacks <literal>inotify</"
dongsheng@627 16263 "literal>, or a version of <literal>glibc</literal> that does not have the "
dongsheng@627 16264 "necessary interfacing support."
dongsheng@627 16265 msgstr ""
dongsheng@627 16266
dongsheng@627 16267 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 16268 #: ../en/ch13-hgext.xml:130
dongsheng@627 16269 msgid ""
dongsheng@627 16270 "Not all filesystems are suitable for use with the <literal role=\"hg-ext"
dongsheng@627 16271 "\">inotify</literal> extension. Network filesystems such as NFS are a non-"
dongsheng@627 16272 "starter, for example, particularly if you're running Mercurial on several "
dongsheng@627 16273 "systems, all mounting the same network filesystem. The kernel's "
dongsheng@627 16274 "<literal>inotify</literal> system has no way of knowing about changes made on "
dongsheng@627 16275 "another system. Most local filesystems (e.g. ext3, XFS, ReiserFS) should "
dongsheng@627 16276 "work fine."
dongsheng@627 16277 msgstr ""
dongsheng@627 16278
dongsheng@627 16279 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16280 #: ../en/ch13-hgext.xml:141
dongsheng@627 16281 msgid ""
dongsheng@627 16282 "The <literal role=\"hg-ext\">inotify</literal> extension is not yet shipped "
dongsheng@627 16283 "with Mercurial as of May 2007, so it's a little more involved to set up than "
dongsheng@627 16284 "other extensions. But the performance improvement is worth it!"
dongsheng@627 16285 msgstr ""
dongsheng@627 16286
dongsheng@627 16287 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16288 #: ../en/ch13-hgext.xml:146
dongsheng@627 16289 msgid ""
dongsheng@627 16290 "The extension currently comes in two parts: a set of patches to the Mercurial "
dongsheng@627 16291 "source code, and a library of Python bindings to the <literal>inotify</"
dongsheng@627 16292 "literal> subsystem."
dongsheng@627 16293 msgstr ""
dongsheng@627 16294
dongsheng@627 16295 #. type: Content of: <book><chapter><sect1><note><para>
dongsheng@650 16296 #: ../en/ch13-hgext.xml:150
dongsheng@627 16297 msgid ""
dongsheng@627 16298 "There are <emphasis>two</emphasis> Python <literal>inotify</literal> binding "
dongsheng@627 16299 "libraries. One of them is called <literal>pyinotify</literal>, and is "
dongsheng@627 16300 "packaged by some Linux distributions as <literal>python-inotify</literal>. "
dongsheng@627 16301 "This is <emphasis>not</emphasis> the one you'll need, as it is too buggy and "
dongsheng@627 16302 "inefficient to be practical."
dongsheng@627 16303 msgstr ""
dongsheng@627 16304
dongsheng@627 16305 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16306 #: ../en/ch13-hgext.xml:157
dongsheng@627 16307 msgid ""
dongsheng@627 16308 "To get going, it's best to already have a functioning copy of Mercurial "
dongsheng@627 16309 "installed."
dongsheng@627 16310 msgstr ""
dongsheng@627 16311
dongsheng@627 16312 #. type: Content of: <book><chapter><sect1><note><para>
dongsheng@650 16313 #: ../en/ch13-hgext.xml:160
dongsheng@627 16314 msgid ""
dongsheng@627 16315 "If you follow the instructions below, you'll be <emphasis>replacing</"
dongsheng@627 16316 "emphasis> and overwriting any existing installation of Mercurial that you "
dongsheng@627 16317 "might already have, using the latest <quote>bleeding edge</quote> Mercurial "
dongsheng@627 16318 "code. Don't say you weren't warned!"
dongsheng@627 16319 msgstr ""
dongsheng@627 16320
dongsheng@627 16321 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
dongsheng@650 16322 #: ../en/ch13-hgext.xml:167
dongsheng@627 16323 msgid ""
dongsheng@627 16324 "Clone the Python <literal>inotify</literal> binding repository. Build and "
dongsheng@627 16325 "install it."
dongsheng@627 16326 msgstr ""
dongsheng@627 16327
dongsheng@627 16328 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
dongsheng@650 16329 #: ../en/ch13-hgext.xml:174
dongsheng@627 16330 msgid ""
dongsheng@627 16331 "Clone the <filename class=\"directory\">crew</filename> Mercurial "
dongsheng@627 16332 "repository. Clone the <literal role=\"hg-ext\">inotify</literal> patch "
dongsheng@627 16333 "repository so that Mercurial Queues will be able to apply patches to your "
dongsheng@627 16334 "cope of the <filename class=\"directory\">crew</filename> repository."
dongsheng@627 16335 msgstr ""
dongsheng@627 16336
dongsheng@627 16337 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
dongsheng@650 16338 #: ../en/ch13-hgext.xml:184
dongsheng@627 16339 msgid ""
dongsheng@627 16340 "Make sure that you have the Mercurial Queues extension, <literal role=\"hg-ext"
songdongsheng@658 16341 "\">mq</literal>, enabled. If you've never used MQ, read <xref linkend=\"sec:"
songdongsheng@658 16342 "mq:start\"/> to get started quickly."
dongsheng@627 16343 msgstr ""
dongsheng@627 16344
dongsheng@627 16345 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
dongsheng@650 16346 #: ../en/ch13-hgext.xml:190
dongsheng@627 16347 msgid ""
dongsheng@627 16348 "Go into the <filename class=\"directory\">inotify</filename> repo, and apply "
dongsheng@627 16349 "all of the <literal role=\"hg-ext\">inotify</literal> patches using the "
dongsheng@627 16350 "<option role=\"hg-ext-mq-cmd-qpush-opt\">hg -a</option> option to the "
dongsheng@627 16351 "<command role=\"hg-ext-mq\">qpush</command> command."
dongsheng@627 16352 msgstr ""
dongsheng@627 16353
dongsheng@627 16354 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
dongsheng@650 16355 #: ../en/ch13-hgext.xml:199
dongsheng@627 16356 msgid ""
dongsheng@627 16357 "If you get an error message from <command role=\"hg-ext-mq\">qpush</command>, "
dongsheng@627 16358 "you should not continue. Instead, ask for help."
dongsheng@627 16359 msgstr ""
dongsheng@627 16360
dongsheng@627 16361 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
dongsheng@650 16362 #: ../en/ch13-hgext.xml:203
dongsheng@627 16363 msgid "Build and install the patched version of Mercurial."
dongsheng@627 16364 msgstr ""
dongsheng@627 16365
dongsheng@627 16366 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16367 #: ../en/ch13-hgext.xml:209
dongsheng@627 16368 msgid ""
dongsheng@627 16369 "Once you've build a suitably patched version of Mercurial, all you need to do "
dongsheng@627 16370 "to enable the <literal role=\"hg-ext\">inotify</literal> extension is add an "
dongsheng@650 16371 "entry to your <filename role=\"special\">~/.hgrc</filename>."
dongsheng@650 16372 msgstr ""
dongsheng@650 16373
dongsheng@650 16374 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16375 #: ../en/ch13-hgext.xml:214
dongsheng@627 16376 msgid ""
dongsheng@627 16377 "When the <literal role=\"hg-ext\">inotify</literal> extension is enabled, "
dongsheng@627 16378 "Mercurial will automatically and transparently start the status daemon the "
dongsheng@627 16379 "first time you run a command that needs status in a repository. It runs one "
dongsheng@627 16380 "status daemon per repository."
dongsheng@627 16381 msgstr ""
dongsheng@627 16382
dongsheng@627 16383 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16384 #: ../en/ch13-hgext.xml:220
dongsheng@627 16385 msgid ""
dongsheng@627 16386 "The status daemon is started silently, and runs in the background. If you "
dongsheng@627 16387 "look at a list of running processes after you've enabled the <literal role="
dongsheng@627 16388 "\"hg-ext\">inotify</literal> extension and run a few commands in different "
dongsheng@627 16389 "repositories, you'll thus see a few <literal>hg</literal> processes sitting "
dongsheng@627 16390 "around, waiting for updates from the kernel and queries from Mercurial."
dongsheng@627 16391 msgstr ""
dongsheng@627 16392
dongsheng@627 16393 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16394 #: ../en/ch13-hgext.xml:228
dongsheng@627 16395 msgid ""
dongsheng@627 16396 "The first time you run a Mercurial command in a repository when you have the "
dongsheng@627 16397 "<literal role=\"hg-ext\">inotify</literal> extension enabled, it will run "
dongsheng@627 16398 "with about the same performance as a normal Mercurial command. This is "
dongsheng@627 16399 "because the status daemon needs to perform a normal status scan so that it "
dongsheng@627 16400 "has a baseline against which to apply later updates from the kernel. "
dongsheng@627 16401 "However, <emphasis>every</emphasis> subsequent command that does any kind of "
dongsheng@627 16402 "status check should be noticeably faster on repositories of even fairly "
dongsheng@627 16403 "modest size. Better yet, the bigger your repository is, the greater a "
dongsheng@627 16404 "performance advantage you'll see. The <literal role=\"hg-ext\">inotify</"
dongsheng@627 16405 "literal> daemon makes status operations almost instantaneous on repositories "
dongsheng@627 16406 "of all sizes!"
dongsheng@627 16407 msgstr ""
dongsheng@627 16408
dongsheng@627 16409 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16410 #: ../en/ch13-hgext.xml:242
dongsheng@627 16411 msgid ""
dongsheng@627 16412 "If you like, you can manually start a status daemon using the <command role="
dongsheng@627 16413 "\"hg-ext-inotify\">inserve</command> command. This gives you slightly finer "
dongsheng@627 16414 "control over how the daemon ought to run. This command will of course only "
dongsheng@627 16415 "be available when the <literal role=\"hg-ext\">inotify</literal> extension is "
dongsheng@627 16416 "enabled."
dongsheng@627 16417 msgstr ""
dongsheng@627 16418
dongsheng@627 16419 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16420 #: ../en/ch13-hgext.xml:249
dongsheng@627 16421 msgid ""
dongsheng@627 16422 "When you're using the <literal role=\"hg-ext\">inotify</literal> extension, "
dongsheng@627 16423 "you should notice <emphasis>no difference at all</emphasis> in Mercurial's "
songdongsheng@710 16424 "behavior, with the sole exception of status-related commands running a whole "
dongsheng@627 16425 "lot faster than they used to. You should specifically expect that commands "
dongsheng@627 16426 "will not print different output; neither should they give different results. "
dongsheng@627 16427 "If either of these situations occurs, please report a bug."
dongsheng@627 16428 msgstr ""
dongsheng@627 16429
dongsheng@627 16430 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 16431 #: ../en/ch13-hgext.xml:260
dongsheng@627 16432 msgid ""
dongsheng@627 16433 "Flexible diff support with the <literal role=\"hg-ext\">extdiff</literal> "
dongsheng@627 16434 "extension"
dongsheng@636 16435 msgstr "使用扩展 <literal role=\"hg-ext\">extdiff</literal> 以扩展差异支持"
dongsheng@627 16436
dongsheng@627 16437 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16438 #: ../en/ch13-hgext.xml:263
dongsheng@627 16439 msgid ""
dongsheng@627 16440 "Mercurial's built-in <command role=\"hg-cmd\">hg diff</command> command "
dongsheng@627 16441 "outputs plaintext unified diffs."
dongsheng@627 16442 msgstr ""
dongsheng@627 16443 "Mercurial 内置命令 <command role=\"hg-cmd\">hg diff</command> 的输出与统一差异"
dongsheng@627 16444 "不同。"
dongsheng@627 16445
dongsheng@627 16446 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16447 #: ../en/ch13-hgext.xml:268
dongsheng@627 16448 msgid ""
dongsheng@627 16449 "If you would like to use an external tool to display modifications, you'll "
dongsheng@627 16450 "want to use the <literal role=\"hg-ext\">extdiff</literal> extension. This "
dongsheng@627 16451 "will let you use, for example, a graphical diff tool."
dongsheng@627 16452 msgstr ""
dongsheng@627 16453
dongsheng@627 16454 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16455 #: ../en/ch13-hgext.xml:273
dongsheng@627 16456 msgid ""
dongsheng@627 16457 "The <literal role=\"hg-ext\">extdiff</literal> extension is bundled with "
dongsheng@627 16458 "Mercurial, so it's easy to set up. In the <literal role=\"rc-extensions"
dongsheng@650 16459 "\">extensions</literal> section of your <filename role=\"special\">~/.hgrc</"
dongsheng@627 16460 "filename>, simply add a one-line entry to enable the extension."
dongsheng@627 16461 msgstr ""
dongsheng@627 16462
dongsheng@627 16463 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16464 #: ../en/ch13-hgext.xml:280
dongsheng@627 16465 msgid ""
dongsheng@627 16466 "This introduces a command named <command role=\"hg-ext-extdiff\">extdiff</"
dongsheng@627 16467 "command>, which by default uses your system's <command>diff</command> command "
dongsheng@627 16468 "to generate a unified diff in the same form as the built-in <command role="
dongsheng@627 16469 "\"hg-cmd\">hg diff</command> command."
dongsheng@627 16470 msgstr ""
dongsheng@627 16471
dongsheng@627 16472 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16473 #: ../en/ch13-hgext.xml:288
dongsheng@627 16474 msgid ""
dongsheng@627 16475 "The result won't be exactly the same as with the built-in <command role=\"hg-"
dongsheng@627 16476 "cmd\">hg diff</command> variations, because the output of <command>diff</"
dongsheng@627 16477 "command> varies from one system to another, even when passed the same options."
dongsheng@627 16478 msgstr ""
dongsheng@627 16479
dongsheng@627 16480 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16481 #: ../en/ch13-hgext.xml:293
dongsheng@627 16482 msgid ""
dongsheng@627 16483 "As the <quote><literal>making snapshot</literal></quote> lines of output "
dongsheng@627 16484 "above imply, the <command role=\"hg-ext-extdiff\">extdiff</command> command "
dongsheng@627 16485 "works by creating two snapshots of your source tree. The first snapshot is "
dongsheng@627 16486 "of the source revision; the second, of the target revision or working "
dongsheng@627 16487 "directory. The <command role=\"hg-ext-extdiff\">extdiff</command> command "
dongsheng@627 16488 "generates these snapshots in a temporary directory, passes the name of each "
dongsheng@627 16489 "directory to an external diff viewer, then deletes the temporary directory. "
dongsheng@627 16490 "For efficiency, it only snapshots the directories and files that have changed "
dongsheng@627 16491 "between the two revisions."
dongsheng@627 16492 msgstr ""
dongsheng@627 16493
dongsheng@627 16494 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16495 #: ../en/ch13-hgext.xml:306
dongsheng@627 16496 msgid ""
dongsheng@627 16497 "Snapshot directory names have the same base name as your repository. If your "
dongsheng@627 16498 "repository path is <filename class=\"directory\">/quux/bar/foo</filename>, "
dongsheng@627 16499 "then <filename class=\"directory\">foo</filename> will be the name of each "
dongsheng@627 16500 "snapshot directory. Each snapshot directory name has its changeset ID "
dongsheng@627 16501 "appended, if appropriate. If a snapshot is of revision "
dongsheng@627 16502 "<literal>a631aca1083f</literal>, the directory will be named <filename class="
dongsheng@627 16503 "\"directory\">foo.a631aca1083f</filename>. A snapshot of the working "
dongsheng@627 16504 "directory won't have a changeset ID appended, so it would just be <filename "
dongsheng@627 16505 "class=\"directory\">foo</filename> in this example. To see what this looks "
dongsheng@627 16506 "like in practice, look again at the <command role=\"hg-ext-extdiff\">extdiff</"
dongsheng@627 16507 "command> example above. Notice that the diff has the snapshot directory "
dongsheng@627 16508 "names embedded in its header."
dongsheng@627 16509 msgstr ""
dongsheng@627 16510
dongsheng@627 16511 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16512 #: ../en/ch13-hgext.xml:322
dongsheng@627 16513 msgid ""
dongsheng@627 16514 "The <command role=\"hg-ext-extdiff\">extdiff</command> command accepts two "
dongsheng@627 16515 "important options. The <option role=\"hg-ext-extdiff-cmd-extdiff-opt\">hg -p</"
dongsheng@627 16516 "option> option lets you choose a program to view differences with, instead of "
dongsheng@627 16517 "<command>diff</command>. With the <option role=\"hg-ext-extdiff-cmd-extdiff-"
dongsheng@627 16518 "opt\">hg -o</option> option, you can change the options that <command role="
dongsheng@627 16519 "\"hg-ext-extdiff\">extdiff</command> passes to the program (by default, these "
dongsheng@627 16520 "options are <quote><literal>-Npru</literal></quote>, which only make sense if "
dongsheng@627 16521 "you're running <command>diff</command>). In other respects, the <command "
dongsheng@627 16522 "role=\"hg-ext-extdiff\">extdiff</command> command acts similarly to the built-"
dongsheng@627 16523 "in <command role=\"hg-cmd\">hg diff</command> command: you use the same "
dongsheng@627 16524 "option names, syntax, and arguments to specify the revisions you want, the "
dongsheng@627 16525 "files you want, and so on."
dongsheng@627 16526 msgstr ""
dongsheng@627 16527
dongsheng@627 16528 #
dongsheng@627 16529 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16530 #: ../en/ch13-hgext.xml:339
dongsheng@627 16531 msgid ""
dongsheng@627 16532 "As an example, here's how to run the normal system <command>diff</command> "
dongsheng@627 16533 "command, getting it to generate context diffs (using the <option role=\"cmd-"
dongsheng@627 16534 "opt-diff\">-c</option> option) instead of unified diffs, and five lines of "
dongsheng@627 16535 "context instead of the default three (passing <literal>5</literal> as the "
dongsheng@627 16536 "argument to the <option role=\"cmd-opt-diff\">-C</option> option)."
dongsheng@627 16537 msgstr ""
dongsheng@627 16538
dongsheng@627 16539 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16540 #: ../en/ch13-hgext.xml:348
dongsheng@627 16541 msgid ""
dongsheng@627 16542 "Launching a visual diff tool is just as easy. Here's how to launch the "
dongsheng@627 16543 "<command>kdiff3</command> viewer."
dongsheng@627 16544 msgstr ""
dongsheng@627 16545
dongsheng@627 16546 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16547 #: ../en/ch13-hgext.xml:352
dongsheng@627 16548 msgid ""
dongsheng@627 16549 "If your diff viewing command can't deal with directories, you can easily work "
dongsheng@627 16550 "around this with a little scripting. For an example of such scripting in "
dongsheng@627 16551 "action with the <literal role=\"hg-ext\">mq</literal> extension and the "
songdongsheng@658 16552 "<command>interdiff</command> command, see <xref linkend=\"mq-collab:tips:"
songdongsheng@658 16553 "interdiff\"/>."
dongsheng@627 16554 msgstr ""
dongsheng@627 16555
dongsheng@627 16556 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 16557 #: ../en/ch13-hgext.xml:360
dongsheng@627 16558 msgid "Defining command aliases"
dongsheng@636 16559 msgstr "定义命令的别名"
dongsheng@627 16560
dongsheng@627 16561 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 16562 #: ../en/ch13-hgext.xml:362
dongsheng@627 16563 msgid ""
dongsheng@627 16564 "It can be cumbersome to remember the options to both the <command role=\"hg-"
dongsheng@627 16565 "ext-extdiff\">extdiff</command> command and the diff viewer you want to use, "
dongsheng@627 16566 "so the <literal role=\"hg-ext\">extdiff</literal> extension lets you define "
dongsheng@627 16567 "<emphasis>new</emphasis> commands that will invoke your diff viewer with "
dongsheng@627 16568 "exactly the right options."
dongsheng@627 16569 msgstr ""
dongsheng@627 16570
dongsheng@627 16571 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 16572 #: ../en/ch13-hgext.xml:369
dongsheng@650 16573 msgid ""
dongsheng@650 16574 "All you need to do is edit your <filename role=\"special\">~/.hgrc</"
dongsheng@627 16575 "filename>, and add a section named <literal role=\"rc-extdiff\">extdiff</"
dongsheng@627 16576 "literal>. Inside this section, you can define multiple commands. Here's how "
dongsheng@627 16577 "to add a <literal>kdiff3</literal> command. Once you've defined this, you "
dongsheng@627 16578 "can type <quote><literal>hg kdiff3</literal></quote> and the <literal role="
dongsheng@627 16579 "\"hg-ext\">extdiff</literal> extension will run <command>kdiff3</command> for "
dongsheng@627 16580 "you."
dongsheng@627 16581 msgstr ""
dongsheng@627 16582
dongsheng@627 16583 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 16584 #: ../en/ch13-hgext.xml:379
dongsheng@627 16585 msgid ""
dongsheng@627 16586 "If you leave the right hand side of the definition empty, as above, the "
dongsheng@627 16587 "<literal role=\"hg-ext\">extdiff</literal> extension uses the name of the "
dongsheng@627 16588 "command you defined as the name of the external program to run. But these "
dongsheng@627 16589 "names don't have to be the same. Here, we define a command named "
dongsheng@627 16590 "<quote><literal>hg wibble</literal></quote>, which runs <command>kdiff3</"
dongsheng@627 16591 "command>."
dongsheng@627 16592 msgstr ""
dongsheng@627 16593
dongsheng@627 16594 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 16595 #: ../en/ch13-hgext.xml:389
dongsheng@627 16596 msgid ""
dongsheng@627 16597 "You can also specify the default options that you want to invoke your diff "
dongsheng@627 16598 "viewing program with. The prefix to use is <quote><literal>opts.</literal></"
dongsheng@627 16599 "quote>, followed by the name of the command to which the options apply. This "
dongsheng@627 16600 "example defines a <quote><literal>hg vimdiff</literal></quote> command that "
dongsheng@627 16601 "runs the <command>vim</command> editor's <literal>DirDiff</literal> extension."
dongsheng@627 16602 msgstr ""
dongsheng@627 16603
dongsheng@627 16604 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 16605 #: ../en/ch13-hgext.xml:403
dongsheng@627 16606 msgid ""
dongsheng@627 16607 "Cherrypicking changes with the <literal role=\"hg-ext\">transplant</literal> "
dongsheng@627 16608 "extension"
dongsheng@636 16609 msgstr "使用扩展 <literal role=\"hg-ext\">transplant</literal> 以挑选修改"
dongsheng@627 16610
dongsheng@627 16611 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16612 #: ../en/ch13-hgext.xml:406
dongsheng@627 16613 msgid "Need to have a long chat with Brendan about this."
dongsheng@627 16614 msgstr ""
dongsheng@627 16615
dongsheng@627 16616 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 16617 #: ../en/ch13-hgext.xml:410
dongsheng@627 16618 msgid ""
dongsheng@627 16619 "Send changes via email with the <literal role=\"hg-ext\">patchbomb</literal> "
dongsheng@627 16620 "extension"
dongsheng@627 16621 msgstr ""
dongsheng@636 16622 "使用扩展 <literal role=\"hg-ext\">patchbomb</literal> 通过 email 发送修改"
dongsheng@627 16623
dongsheng@627 16624 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16625 #: ../en/ch13-hgext.xml:413
dongsheng@627 16626 msgid ""
dongsheng@627 16627 "Many projects have a culture of <quote>change review</quote>, in which people "
dongsheng@627 16628 "send their modifications to a mailing list for others to read and comment on "
dongsheng@627 16629 "before they commit the final version to a shared repository. Some projects "
dongsheng@627 16630 "have people who act as gatekeepers; they apply changes from other people to a "
dongsheng@627 16631 "repository to which those others don't have access."
dongsheng@627 16632 msgstr ""
dongsheng@627 16633
dongsheng@627 16634 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16635 #: ../en/ch13-hgext.xml:421
dongsheng@627 16636 msgid ""
dongsheng@627 16637 "Mercurial makes it easy to send changes over email for review or application, "
dongsheng@627 16638 "via its <literal role=\"hg-ext\">patchbomb</literal> extension. The "
dongsheng@627 16639 "extension is so named because changes are formatted as patches, and it's "
dongsheng@627 16640 "usual to send one changeset per email message. Sending a long series of "
dongsheng@627 16641 "changes by email is thus much like <quote>bombing</quote> the recipient's "
dongsheng@627 16642 "inbox, hence <quote>patchbomb</quote>."
dongsheng@627 16643 msgstr ""
dongsheng@627 16644
dongsheng@627 16645 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16646 #: ../en/ch13-hgext.xml:429
dongsheng@627 16647 msgid ""
dongsheng@627 16648 "As usual, the basic configuration of the <literal role=\"hg-ext\">patchbomb</"
dongsheng@627 16649 "literal> extension takes just one or two lines in your <filename role="
dongsheng@627 16650 "\"special\"> /.hgrc</filename>."
dongsheng@627 16651 msgstr ""
dongsheng@627 16652
dongsheng@627 16653 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16654 #: ../en/ch13-hgext.xml:435
dongsheng@627 16655 msgid ""
dongsheng@627 16656 "Once you've enabled the extension, you will have a new command available, "
dongsheng@627 16657 "named <command role=\"hg-ext-patchbomb\">email</command>."
dongsheng@627 16658 msgstr ""
dongsheng@627 16659
dongsheng@627 16660 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16661 #: ../en/ch13-hgext.xml:439
dongsheng@627 16662 msgid ""
dongsheng@627 16663 "The safest and best way to invoke the <command role=\"hg-ext-patchbomb"
dongsheng@627 16664 "\">email</command> command is to <emphasis>always</emphasis> run it first "
dongsheng@627 16665 "with the <option role=\"hg-ext-patchbomb-cmd-email-opt\">hg -n</option> "
dongsheng@627 16666 "option. This will show you what the command <emphasis>would</emphasis> send, "
dongsheng@627 16667 "without actually sending anything. Once you've had a quick glance over the "
dongsheng@627 16668 "changes and verified that you are sending the right ones, you can rerun the "
dongsheng@627 16669 "same command, with the <option role=\"hg-ext-patchbomb-cmd-email-opt\">hg -n</"
dongsheng@627 16670 "option> option removed."
dongsheng@627 16671 msgstr ""
dongsheng@627 16672
dongsheng@627 16673 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16674 #: ../en/ch13-hgext.xml:450
dongsheng@627 16675 msgid ""
dongsheng@627 16676 "The <command role=\"hg-ext-patchbomb\">email</command> command accepts the "
dongsheng@627 16677 "same kind of revision syntax as every other Mercurial command. For example, "
dongsheng@627 16678 "this command will send every revision between 7 and <literal>tip</literal>, "
dongsheng@627 16679 "inclusive."
dongsheng@627 16680 msgstr ""
dongsheng@627 16681
dongsheng@627 16682 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16683 #: ../en/ch13-hgext.xml:455
dongsheng@627 16684 msgid ""
dongsheng@627 16685 "You can also specify a <emphasis>repository</emphasis> to compare with. If "
dongsheng@627 16686 "you provide a repository but no revisions, the <command role=\"hg-ext-"
dongsheng@627 16687 "patchbomb\">email</command> command will send all revisions in the local "
dongsheng@627 16688 "repository that are not present in the remote repository. If you "
dongsheng@627 16689 "additionally specify revisions or a branch name (the latter using the <option "
dongsheng@627 16690 "role=\"hg-ext-patchbomb-cmd-email-opt\">hg -b</option> option), this will "
dongsheng@627 16691 "constrain the revisions sent."
dongsheng@627 16692 msgstr ""
dongsheng@627 16693
dongsheng@627 16694 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16695 #: ../en/ch13-hgext.xml:464
dongsheng@627 16696 msgid ""
dongsheng@627 16697 "It's perfectly safe to run the <command role=\"hg-ext-patchbomb\">email</"
dongsheng@627 16698 "command> command without the names of the people you want to send to: if you "
dongsheng@627 16699 "do this, it will just prompt you for those values interactively. (If you're "
dongsheng@627 16700 "using a Linux or Unix-like system, you should have enhanced "
dongsheng@627 16701 "<literal>readline</literal>-style editing capabilities when entering those "
dongsheng@627 16702 "headers, too, which is useful.)"
dongsheng@627 16703 msgstr ""
dongsheng@627 16704
dongsheng@627 16705 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16706 #: ../en/ch13-hgext.xml:472
dongsheng@627 16707 msgid ""
dongsheng@627 16708 "When you are sending just one revision, the <command role=\"hg-ext-patchbomb"
dongsheng@627 16709 "\">email</command> command will by default use the first line of the "
dongsheng@627 16710 "changeset description as the subject of the single email message it sends."
dongsheng@627 16711 msgstr ""
dongsheng@627 16712
dongsheng@627 16713 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16714 #: ../en/ch13-hgext.xml:477
dongsheng@627 16715 msgid ""
dongsheng@627 16716 "If you send multiple revisions, the <command role=\"hg-ext-patchbomb\">email</"
dongsheng@627 16717 "command> command will usually send one message per changeset. It will "
dongsheng@627 16718 "preface the series with an introductory message, in which you should describe "
dongsheng@627 16719 "the purpose of the series of changes you're sending."
dongsheng@627 16720 msgstr ""
dongsheng@627 16721
dongsheng@627 16722 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 16723 #: ../en/ch13-hgext.xml:484
songdongsheng@710 16724 #, fuzzy
songdongsheng@710 16725 msgid "Changing the behavior of patchbombs"
dongsheng@636 16726 msgstr "修改 patchbomb 的行为"
dongsheng@627 16727
dongsheng@627 16728 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 16729 #: ../en/ch13-hgext.xml:486
dongsheng@627 16730 msgid ""
dongsheng@627 16731 "Not every project has exactly the same conventions for sending changes in "
dongsheng@627 16732 "email; the <literal role=\"hg-ext\">patchbomb</literal> extension tries to "
dongsheng@627 16733 "accommodate a number of variations through command line options."
dongsheng@627 16734 msgstr ""
dongsheng@627 16735
dongsheng@627 16736 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 16737 #: ../en/ch13-hgext.xml:492
dongsheng@627 16738 msgid ""
dongsheng@627 16739 "You can write a subject for the introductory message on the command line "
dongsheng@627 16740 "using the <option role=\"hg-ext-patchbomb-cmd-email-opt\">hg -s</option> "
dongsheng@627 16741 "option. This takes one argument, the text of the subject to use."
dongsheng@627 16742 msgstr ""
dongsheng@627 16743
dongsheng@627 16744 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 16745 #: ../en/ch13-hgext.xml:498
dongsheng@627 16746 msgid ""
dongsheng@627 16747 "To change the email address from which the messages originate, use the "
dongsheng@627 16748 "<option role=\"hg-ext-patchbomb-cmd-email-opt\">hg -f</option> option. This "
dongsheng@627 16749 "takes one argument, the email address to use."
dongsheng@627 16750 msgstr ""
dongsheng@627 16751
dongsheng@627 16752 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 16753 #: ../en/ch13-hgext.xml:504
dongsheng@627 16754 msgid ""
songdongsheng@710 16755 "The default behavior is to send unified diffs (see <xref linkend=\"sec:mq:"
songdongsheng@658 16756 "patch\"/> for a description of the format), one per message. You can send a "
songdongsheng@658 16757 "binary bundle instead with the <option role=\"hg-ext-patchbomb-cmd-email-opt"
songdongsheng@658 16758 "\">hg -b</option> option."
dongsheng@627 16759 msgstr ""
dongsheng@627 16760
dongsheng@627 16761 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 16762 #: ../en/ch13-hgext.xml:512
dongsheng@627 16763 msgid ""
dongsheng@627 16764 "Unified diffs are normally prefaced with a metadata header. You can omit "
dongsheng@627 16765 "this, and send unadorned diffs, with the <option role=\"hg-ext-patchbomb-cmd-"
dongsheng@627 16766 "email-opt\">hg --plain</option> option."
dongsheng@627 16767 msgstr ""
dongsheng@627 16768
dongsheng@627 16769 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 16770 #: ../en/ch13-hgext.xml:518
dongsheng@627 16771 msgid ""
dongsheng@627 16772 "Diffs are normally sent <quote>inline</quote>, in the same body part as the "
dongsheng@627 16773 "description of a patch. This makes it easiest for the largest number of "
dongsheng@627 16774 "readers to quote and respond to parts of a diff, as some mail clients will "
dongsheng@627 16775 "only quote the first MIME body part in a message. If you'd prefer to send the "
dongsheng@627 16776 "description and the diff in separate body parts, use the <option role=\"hg-"
dongsheng@627 16777 "ext-patchbomb-cmd-email-opt\">hg -a</option> option."
dongsheng@627 16778 msgstr ""
dongsheng@627 16779
dongsheng@627 16780 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 16781 #: ../en/ch13-hgext.xml:528
dongsheng@627 16782 msgid ""
dongsheng@627 16783 "Instead of sending mail messages, you can write them to an <literal>mbox</"
dongsheng@627 16784 "literal>-format mail folder using the <option role=\"hg-ext-patchbomb-cmd-"
dongsheng@627 16785 "email-opt\">hg -m</option> option. That option takes one argument, the name "
dongsheng@627 16786 "of the file to write to."
dongsheng@627 16787 msgstr ""
dongsheng@627 16788
dongsheng@627 16789 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 16790 #: ../en/ch13-hgext.xml:535
dongsheng@627 16791 msgid ""
dongsheng@627 16792 "If you would like to add a <command>diffstat</command>-format summary to each "
dongsheng@627 16793 "patch, and one to the introductory message, use the <option role=\"hg-ext-"
dongsheng@627 16794 "patchbomb-cmd-email-opt\">hg -d</option> option. The <command>diffstat</"
dongsheng@627 16795 "command> command displays a table containing the name of each file patched, "
dongsheng@627 16796 "the number of lines affected, and a histogram showing how much each file is "
dongsheng@627 16797 "modified. This gives readers a qualitative glance at how complex a patch is."
dongsheng@627 16798 msgstr ""